Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Vorschau: Plugin API in v2.0
#2
Aber, aber, aber! Schreien einige. Ich moechte gerne die mailScreen-Klasse erweitern, aber es ist doch alles verschluesselt! Wie mache ich das denn?

Dafuer gibt es auch Abhilfe.

Es wird einen Plugin-Ordner geben, unter twlan-dir/lib/plugins/.

Nehmen wir einfach mal einen Beispiel-Code, um die mailScreen zu erweitern.

lib/plugins/MailPlugin.plugin.php
PHP Code:
/**
 * Hello World!
 *
 * @author Christopher <christopher@twlan.org>
 */
class MailPlugin extends AbstractObject implements PluginInterface {
    
    public function 
registerPlugins() {
// $this->plugins->registerScreenMethod($screenClassName, $methodName, $callback);
    
$this->plugins->registerScreenMethod('mailScreen''fooMode', array(&$this'mailFooMode'));
    }
    
    public function 
mailFooMode() {
    
$this->tpl->assign('foo''haha');
    }
    


Dazu legen wir ein Template an!
templates/game_mail_foo.tpl
Code:
<h2>N Abend</h2>

{$foo}

D.h. die game.php?screen=mail&mode=foo wuerde auf die MailExtension::mailFooMode() umgeleitet.

Das wuerde dann so aussehen:
Klick!

Hiermit kann man auch bereits bestehende Methoden, wie zum Beispiel die mailScreen::main() ersetzen.
Reply


Messages In This Thread
Vorschau: Plugin API in v2.0 - by Chrissi - 14.08.2011, 02:04
RE: Vorschau: Plugin API in v2.0 - by Chrissi - 14.08.2011, 02:26
RE: Vorschau: Plugin API in v2.0 - by Chrissi - 14.08.2011, 06:36
RE: Vorschau: Plugin API in v2.0 - by Chrissi - 14.08.2011, 06:53
RE: Vorschau: Plugin API in v2.0 - by Chrissi - 14.08.2011, 14:24
RE: Vorschau: Plugin API in v2.0 - by momk - 14.08.2011, 15:09
RE: Vorschau: Plugin API in v2.0 - by Yannici - 14.08.2011, 17:46
RE: Vorschau: Plugin API in v2.0 - by Milu2K - 14.08.2011, 21:47
RE: Vorschau: Plugin API in v2.0 - by pL4n3 - 14.08.2011, 22:04
RE: Vorschau: Plugin API in v2.0 - by Milu2K - 14.08.2011, 22:08
RE: Vorschau: Plugin API in v2.0 - by Chrissi - 15.08.2011, 00:13



Users browsing this thread: 2 Guest(s)