
Public Member Functions | |
| isPluginPresent ($formalname, $andPublished=false) | |
| getMambotsForTrigger ($trigger) | |
| loadBotGroup ($group) | |
| trigger ($event, $args=null, $doUnpublished=false, $maxbot=0) | |
| countBots ($event) | |
| triggerOnce ($event, $args=null, $doUnpublished=false) | |
| call ($event) | |
Static Public Member Functions | |
| static | getInstance () |
Protected Member Functions | |
| __construct () | |
Protected Attributes | |
| $extensiondir = '/mambots/' | |
Static Protected Attributes | |
| static | $instance = __CLASS__ |
Private Member Functions | |
| runOneBot ($botkey, $args, $event, $botparams, $published) | |
Private Attributes | |
| $_events = array() | |
| $_bots = null | |
| $_bot_objects = array() | |
| $_botsByName = array() | |
Static Private Attributes | |
| static | $defaults |
Definition at line 67 of file aliroMambot.php.
| aliroMambotHandler::__construct | ( | ) | [protected] |
Definition at line 84 of file aliroMambot.php.
References aliroCoreDatabase::getInstance().
00084 { 00085 $database = aliroCoreDatabase::getInstance(); 00086 $this->_bots = $database->doSQLget( "SELECT element, class, triggers, published, params, 0 AS isdefault FROM #__mambots ORDER BY ordering"); 00087 foreach ($this->_bots as $bot) $this->_botsByName[$bot->element] = true; 00088 foreach (self::$defaults as $trigger=>$default) { 00089 $defobj = new stdClass; 00090 $defobj->class = $default; 00091 $defobj->triggers = $trigger; 00092 $defobj->isdefault = 1; 00093 array_push($this->_bots, $defobj); 00094 } 00095 foreach ($this->_bots as $key=>$bot) { 00096 $triggers = explode (',', $bot->triggers); 00097 foreach ($triggers as $trigger) $this->_events[trim($trigger)][] = $key; 00098 } 00099 }
| static aliroMambotHandler::getInstance | ( | ) | [static] |
Definition at line 101 of file aliroMambot.php.
Referenced by aliroEditor::__construct(), aliroUserRequest::doControl(), bot_nulleditor::editorArea(), aliroUserSession::forceLogout(), mosMambotHandler::getInstance(), aliroUserAuthenticator::logout(), aliroPage404::searchuri(), and aliroUserAuthenticator::systemLogin().
00101 { 00102 return is_object(self::$instance) ? self::$instance : (self::$instance = parent::getCachedSingleton(self::$instance)); 00103 }
| aliroMambotHandler::isPluginPresent | ( | $ | formalname, | |
| $ | andPublished = false | |||
| ) |
Definition at line 105 of file aliroMambot.php.
00105 { 00106 if (!isset($this->_botsByName[$formalname])) return false; 00107 if (!$andPublished) return true; 00108 $bot = $this->_botsByName[$formalname]; 00109 return $bot->published ? true : false; 00110 }
| aliroMambotHandler::getMambotsForTrigger | ( | $ | trigger | ) |
Definition at line 113 of file aliroMambot.php.
00113 { 00114 if (isset($this->_events[$trigger])) foreach ($this->_events[$trigger] as $botkey) { 00115 $results[] = $this->_bots[$botkey]; 00116 } 00117 else $results = array(); 00118 return $results; 00119 }
| aliroMambotHandler::loadBotGroup | ( | $ | group | ) |
| aliroMambotHandler::trigger | ( | $ | event, | |
| $ | args = null, |
|||
| $ | doUnpublished = false, |
|||
| $ | maxbot = 0 | |||
| ) |
Definition at line 128 of file aliroMambot.php.
References published(), and runOneBot().
Referenced by call(), and triggerOnce().
00128 { 00129 if ($args === null) $args = array(); 00130 elseif (!is_array($args)) $args = array($args); 00131 $result = array(); 00132 $botcount = 0; 00133 if (isset( $this->_events[$event] )) foreach ($this->_events[$event] as $botkey) { 00134 $bot = $this->_bots[$botkey]; 00135 if ($bot->isdefault) { 00136 if (!isset($defaultbotkey)) $defaultbotkey = $botkey; 00137 } 00138 else { 00139 $botparams = new aliroParameters($bot->params); 00140 if ($doUnpublished OR $bot->published) { 00141 $result[] = $this->runOneBot($botkey, $args, $event, $botparams, $bot->published); 00142 $botcount ++; 00143 if ($maxbot AND $botcount >= $maxbot) break; 00144 } 00145 } 00146 } 00147 if (0 == $botcount AND isset($defaultbotkey)) $result[] = $this->runOneBot($defaultbotkey, $args, $event, '', '1'); 00148 return $result; 00149 }
| aliroMambotHandler::runOneBot | ( | $ | botkey, | |
| $ | args, | |||
| $ | event, | |||
| $ | botparams, | |||
| $ | published | |||
| ) | [private] |
Definition at line 151 of file aliroMambot.php.
Referenced by trigger().
00151 { 00152 if (isset($this->_bot_objects[$botkey])) $botobject = $this->_bot_objects[$botkey]; 00153 else $botobject = $this->_bot_objects[$botkey] = new $this->_bots[$botkey]->class; 00154 array_unshift($args, $event, $botparams, $published); 00155 return call_user_func_array(array($botobject, 'perform'), $args); 00156 }
| aliroMambotHandler::countBots | ( | $ | event | ) |
| aliroMambotHandler::triggerOnce | ( | $ | event, | |
| $ | args = null, |
|||
| $ | doUnpublished = false | |||
| ) |
Definition at line 163 of file aliroMambot.php.
References trigger().
00163 { 00164 return $this->trigger ($event, $args, $doUnpublished, 1); 00165 }
| aliroMambotHandler::call | ( | $ | event | ) |
Definition at line 168 of file aliroMambot.php.
References trigger().
00168 { 00169 $args = func_get_args(); 00170 array_shift($args); 00171 $result = $this->trigger($event, $args); 00172 if (isset($result[0])) return $result[0]; 00173 return null; 00174 }
aliroMambotHandler::$instance = __CLASS__ [static, protected] |
Definition at line 69 of file aliroMambot.php.
aliroMambotHandler::$defaults [static, private] |
Initial value:
array (
'onIniEditor' => 'bot_nulleditor',
'onGetEditorContents' => 'bot_nulleditor',
'onEditorArea' => 'bot_nulleditor'
)
Definition at line 71 of file aliroMambot.php.
aliroMambotHandler::$_events = array() [private] |
Definition at line 77 of file aliroMambot.php.
aliroMambotHandler::$_bots = null [private] |
Definition at line 78 of file aliroMambot.php.
aliroMambotHandler::$_bot_objects = array() [private] |
Definition at line 79 of file aliroMambot.php.
aliroMambotHandler::$_botsByName = array() [private] |
Definition at line 80 of file aliroMambot.php.
aliroMambotHandler::$extensiondir = '/mambots/' [protected] |
Definition at line 82 of file aliroMambot.php.
1.5.5