00001 <?php
00007 namespace Habari;
00008
00017 abstract class Plugin extends Pluggable
00018 {
00019
00025 final public function info()
00026 {
00027 static $info;
00028 if ( !isset( $info ) ) {
00029 $info = Plugins::load_info( $this->get_file() );
00030 if ( isset( $info->help ) ) {
00031 Plugins::register( array( $this, '_help_plugin_config_plugin' ), 'filter', 'plugin_config:' . $this->plugin_id(), 8 );
00032 Plugins::register( array( $this, '_help_plugin_ui_plugin' ), 'action', 'plugin_ui:' . $this->plugin_id(), 8 );
00033 }
00034 }
00035 return $info;
00036 }
00037
00044 final public function __construct()
00045 {
00046 parent::__construct();
00047 }
00048
00056 public function _help_plugin_config_plugin( $actions, $plugin_id )
00057 {
00058 if ( $plugin_id == $this->plugin_id() ) {
00059 foreach ( $this->info->help as $help ) {
00060 $name = (string)$help['name'];
00061 if ( $name == '' ) {
00062 $name = '_help';
00063 }
00064
00065 $actions[$name] = _t( '?' );
00066 }
00067 }
00068 return $actions;
00069 }
00070
00077 public function _help_plugin_ui_plugin( $plugin_id, $action )
00078 {
00079 if ( $plugin_id == $this->plugin_id() ) {
00080 foreach ( $this->info->help as $help ) {
00081 if ( ( $action == (string)$help['name'] && (string)$help['name'] != '' ) || ( $action == '_help' && (string)$help['name'] == '' ) ) {
00082 echo '<div class="help">' . ( (string)$help->value ) . '</div>';
00083 }
00084 }
00085 }
00086 }
00087
00092 public function get_version()
00093 {
00094 return (string)$this->info->version;
00095 }
00096 }
00097
00098 ?>