| | |
| | | private $objectsmap = array(); |
| | | private $template_contents = array(); |
| | | |
| | | private $required_plugins = array('filesystem_attachments'); |
| | | private $required_plugins = array('filesystem_attachments'); |
| | | private $active_hook = false; |
| | | |
| | | /** |
| | | * This implements the 'singleton' design pattern |
| | |
| | | if (!$loaded) { |
| | | $fn = $plugins_dir->path . DIRECTORY_SEPARATOR . $plugin_name . DIRECTORY_SEPARATOR . $plugin_name . '.php'; |
| | | if (file_exists($fn)) { |
| | | include($fn); |
| | | include_once($fn); |
| | | |
| | | if (class_exists($plugin_name, false)) { |
| | | $plugin = new $plugin_name($this); |
| | | // check inheritance |
| | | if (is_subclass_of($plugin, 'rcube_plugin')) { |
| | | $plugin->init(); |
| | | $this->plugins[] = $plugin; |
| | | $loaded = true; |
| | | if (!$plugin->task || preg_match('/('.$plugin->task.')/i', $rcmail->task)) { |
| | | $plugin->init(); |
| | | $this->plugins[] = $plugin; |
| | | } |
| | | $loaded = true; |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | public function exec_hook($hook, $args = array()) |
| | | { |
| | | if (!is_array($args)) |
| | | $args = array('arg' => $args); |
| | | |
| | | $args += array('abort' => false); |
| | | $this->active_hook = $hook; |
| | | |
| | | foreach ((array)$this->handlers[$hook] as $callback) { |
| | | $ret = call_user_func($callback, $args); |
| | |
| | | break; |
| | | } |
| | | |
| | | $this->active_hook = false; |
| | | return $args; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Check if a plugin hook is currently processing. |
| | | * Mainly used to prevent loops and recursion. |
| | | * |
| | | * @param string Hook to check (optional) |
| | | * @return boolean True if any/the given hook is currently processed, otherwise false |
| | | */ |
| | | public function is_processing($hook = null) |
| | | { |
| | | return $this->active_hook && (!$hook || $this->active_hook == $hook); |
| | | } |
| | | |
| | | /** |
| | | * Include a plugin script file in the current HTML page |
| | | */ |
| | |
| | | private function template_container_hook($attrib) |
| | | { |
| | | $container = $attrib['name']; |
| | | return array('content' => $this->template_contents[$container]); |
| | | return array('content' => $attrib['content'] . $this->template_contents[$container]); |
| | | } |
| | | |
| | | /** |