documentation updates

This commit is contained in:
Shish 2012-03-05 13:56:36 +00:00
parent ba0dd8e9f2
commit 383dd0088e
2 changed files with 25 additions and 14 deletions

View file

@ -20,17 +20,27 @@
* *
* \code * \code
* // ext/hello/main.php * // ext/hello/main.php
* public class HelloEvent extends Event {
* public function __construct($username) {
* $this->username = $username;
* }
* }
*
* public class Hello extends Extension { * public class Hello extends Extension {
* public void onPageRequest(PageRequestEvent $event) { * public void onPageRequest(PageRequestEvent $event) {
* global $page, $user; * global $page, $user;
* $this->theme->display_hello($page, $user); * send_event(new HelloEvent($user->name));
* }
* public void onHello(HelloEvent $event) {
* $this->theme->display_hello($event->username);
* } * }
* } * }
* *
* // ext/hello/theme.php * // ext/hello/theme.php
* public class HelloTheme extends Themelet { * public class HelloTheme extends Themelet {
* public void display_hello(Page $page, User $user) { * public void display_hello($username) {
* $page->add_block(new Block("Hello!", "Hello there ".html_escape($user->name)); * global $page;
* $page->add_block(new Block("Hello!", "Hello there ".html_escape($username));
* } * }
* } * }
* *
@ -67,17 +77,25 @@
* find the thread where the original was posted >_< * find the thread where the original was posted >_<
*/ */
abstract class Extension { abstract class Extension {
/** this theme's Themelet object */
var $theme; var $theme;
/** @private */
var $_child; var $_child;
// in PHP5.3, late static bindings can take care of this; __CLASS__ // in PHP5.3, late static bindings can take care of this; __CLASS__
// used here will refer to the subclass // used here will refer to the subclass
// http://php.net/manual/en/language.oop5.late-static-bindings.php // http://php.net/manual/en/language.oop5.late-static-bindings.php
/** @private */
public function i_am(Extension $child) { public function i_am(Extension $child) {
$this->_child = $child; $this->_child = $child;
if(is_null($this->theme)) $this->theme = get_theme_object($child, false); if(is_null($this->theme)) $this->theme = get_theme_object($child, false);
} }
/**
* Override this to change the priority of the extension,
* lower numbered ones will recieve events first
*/
public function get_priority() { public function get_priority() {
return 50; return 50;
} }

View file

@ -12,20 +12,14 @@
* which links to images on an image board, with no wiki or messaging, and so * which links to images on an image board, with no wiki or messaging, and so
* on and so on... * on and so on...
* *
* To learn about the innards of SCore, start with the \ref overview.
*
*
* \page overview High Level Overview
*
* Dijkstra will kill me for personifying my architecture, but I can't think * Dijkstra will kill me for personifying my architecture, but I can't think
* of a better way without going into all the little details. * of a better way without going into all the little details.
*
* There are a bunch of Extension subclasses, they talk to eachother by sending * There are a bunch of Extension subclasses, they talk to eachother by sending
* and recieving Event subclasses. The topic of conversation is decided by the * and recieving Event subclasses. The primary driver for each conversation is the
* initial PageRequestEvent, and each extension puts its notes into the shared * initial PageRequestEvent. If an Extension wants to display something to the
* Page data store. Once the conversation is over, the Page is passed to the * user, it adds a block to the Page data store. Once the conversation is over, the Page is passed to the
* current theme's Layout class which will tidy up the data and present it to * current theme's Layout class which will tidy up the data and present it to
* the user. * the user. To see this in a more practical sense, see \ref hello.
* *
* To learn more about the architecture: * To learn more about the architecture:
* *
@ -36,7 +30,6 @@
* *
* \li \ref scglobals * \li \ref scglobals
* \li \ref unittests * \li \ref unittests
* \li \ref hello
* *
* \page scglobals SCore Globals * \page scglobals SCore Globals
* *