/** * Load all of plugins * */ public static function load() { if (self::$_loaded) { return; } require __ROOT__ . DS . "configs" . DS . "rplugin.php"; if (empty($plugins) || !is_array($plugins)) { return; } foreach ($plugins as $name => $plugin) { if ($plugin["enabled"]) { $dir = __ROOT__ . DS . "plugins" . DS . $name; if (!is_dir($dir)) { $dir = dirname(dirname(__ROOT__)) . DS . "plugins" . DS . $name; } $initFile = $dir . DS . "init.php"; if (is_file($initFile)) { require $dir . DS . "init.php"; } else { trigger_error("could not find initialize file '{$initFile}' for plugin '{$name}', you can disable it in app/configs/rplugin.php"); } } } self::$_loaded = true; }
/** * Constructor * * @param string &$subject Subject * @param array $config Configuration */ public function __construct(&$subject, $config = array()) { parent::__construct($subject, $config = array()); $this->dcType = $this->_name; }
/** * Constructor * * @param string &$subject Subject * @param array $config Configuration * * @throws UnexpectedValueException */ public function __construct(&$subject, $config = array()) { parent::__construct($subject, $config); }
/** * Execute action * */ public function exec() { Rock::setController($this); if (class_exists("RPlugin")) { RPlugin::callBefore(); } $this->onBefore(); $method = "do" . $this->_action; if (!method_exists($this, $method)) { trigger_error("can not find action '{$this->_action}' in class '" . get_class($this) . "'", E_USER_ERROR); } $ret = $this->{$method}(); if (is_object($ret) && $ret instanceof RView) { $ret->display(); } $this->onAfter(); if (class_exists("RPlugin")) { RPlugin::callAfter(); } }
public function doIndex() { //All plugins $this->plugins = RPlugin::plugins(); $this->display(); }