commit 78aa17df5a07b26fabbb8e6bdb4abe5c25dda005 Author: Dmitriy Simushev Date: Mon Apr 21 23:21:06 2014 +0400 Initial commit diff --git a/Mibew/Mibew/Plugin/Boilerplate/Plugin.php b/Mibew/Mibew/Plugin/Boilerplate/Plugin.php new file mode 100644 index 0000000..4401c17 --- /dev/null +++ b/Mibew/Mibew/Plugin/Boilerplate/Plugin.php @@ -0,0 +1,84 @@ +\Mibew\Plugin\\Plugin". It should be placed in + * "/plugins//Mibew/Plugin//Plugin.php" + * file. Names of plugin and directories/files are case sensitive! + * + * To turn the plugin on add the following to /libs/config.php + * + * $plugins_list[] = array( + * 'name' => 'Mibew:Boilerplate', + * 'config' => array(); + * ); + * + */ + +namespace Mibew\Mibew\Plugin\Boilerplate; + +/** + * Defenition of the main plugin class. + * + * Plugin class must implements \Mibew\Plugin\PluginInterface and can extends + * \Mibew\Plugin\AbstractPlugin class. The latter contains basic functions that + * can be helpfull. + */ +class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\PluginInterface +{ + /** + * Determine if the plugin was initialized correctly or not. + * + * By setting this propery to true by default we make the plugin + * initialized by default, so there is no need to add custom contructor + * or initializer. + */ + protected $initialized = true; + + /** + * The main entry point of a plugin + * + * If a plugin extends \Mibew\Plugin\AbstructPlugin class the only method + * that should be implemented is "run". + * + * Here we can attache event listeners and do other job. + */ + public function run() + { + // We need an instatance of EventDispatcher class to attach handlers to + // events. So get it. + $dispatcher = \Mibew\EventDispatcher::getInstance(); + // There are a lot of events. Use a few of them to show how they work. + $dispatcher->attachListener('pageAddCSS', $this, 'addCustomCss'); + } + + /** + * Just attaches custom CSS file to every page that support it (chat windows + * and users waiting screen). + */ + public function addCustomCss(&$args) + { + $args['css'][] = MIBEW_WEB_ROOT . '/' . $this->getFilesPath() . '/css/styles.css'; + } + + /** + * Also we can add dependencies. But make shure that they was loaded BEFORE + * current plugin in config.php + * + * If the plugin depends, for example, on "Abc:BestFeature" and "Xyz:Logger" + * we need to return the following array: + * + * return array( + * 'Abc:BestFeature', + * 'Xyz:Logger', + * ); + * + */ + public static function getDependencies() + { + // This plugin does not depend on others so return an empty array. + return array(); + } +} diff --git a/Mibew/Mibew/Plugin/Boilerplate/css/styles.css b/Mibew/Mibew/Plugin/Boilerplate/css/styles.css new file mode 100644 index 0000000..428ffef --- /dev/null +++ b/Mibew/Mibew/Plugin/Boilerplate/css/styles.css @@ -0,0 +1,3 @@ +/* + * It is an empty styles file. + */ diff --git a/README.md b/README.md new file mode 100644 index 0000000..049d4ef --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Boilerplate plugin + +It does nothing but can be used as a template for a real plugin.