function bubbleEvent(&$event)
 {
     $res = array();
     if (isset($this->_events[$event->type]) && is_array($this->_events[$event->type])) {
         foreach ($this->_events[$event->type] as $klass => $functions) {
             if (is_string($functions)) {
                 $res[] = zmgCallAbstract($klass, $functions, $event);
             } else {
                 if (is_array($functions)) {
                     foreach ($functions as $function => $args) {
                         if (!is_array($args)) {
                             $args = array($args);
                         }
                         $event->mapArguments($args);
                         $res[] = zmgCallAbstract($klass, $function, $event);
                     }
                 }
             }
         }
     }
     if (count($res) == 1) {
         return $res[0];
     }
     return $res;
 }
 /**
  * Call an abstract/ static function that resides within a static class.
  * Note: particularly useful within templates.
  *
  * @see zmgCallAbstract
  */
 function callAbstract($klass, $func, $args = array(0))
 {
     if (!in_array($klass, $this->abstract_whitelist)) {
         return zmgError::throwError('zmgAPIHelper::callAbstract: illegal call.');
     }
     return zmgCallAbstract($klass, $func, $args);
 }
 function autoDetect(&$event)
 {
     $selection = $event->getArgument('selection');
     if (!is_array($selection)) {
         $selection = "all";
     }
     $tools =& zmgToolboxConstants::getTools();
     $imagetools =& zmgToolboxConstants::getImageTools();
     $getall = false;
     if (!is_array($selection) && $selection == "all") {
         $getall = true;
         $selection = $tools;
     }
     $toolkey = intval(zmgFactory::getConfig()->get('plugins/toolbox/general/conversiontool'));
     $imagetool = $imagetools[$toolkey - 1];
     if ($getall) {
         //auto-detect currently selected imagetool first
         zmgimport('org.zoomfactory.var.plugins.toolbox.tools.' . $imagetool . 'Tool');
         zmgCallAbstract('zmg' . ucfirst($imagetool) . 'Tool', 'autoDetect');
     }
     //auto-detect other tools as well
     foreach ($selection as $tool) {
         if (!in_array($tool, $imagetools)) {
             zmgimport('org.zoomfactory.var.plugins.toolbox.tools.' . $tool . 'Tool');
             zmgCallAbstract('zmg' . ucfirst($tool) . 'Tool', 'autoDetect');
         } else {
             if (!$getall) {
                 if ($tool != $imagetool) {
                     zmgimport('org.zoomfactory.var.plugins.toolbox.tools.' . $tool . 'Tool');
                 }
                 zmgCallAbstract('zmg' . ucfirst($tool) . 'Tool', 'autoDetect');
             }
         }
     }
     zmgToolboxPlugin::throwErrors();
 }
 function _buildAdminToolbar()
 {
     if (!ZMG_ADMIN) {
         return $this->throwError('Function may only be called in admin mode.');
     }
     $assets = zmgEnv::getToolbarAssets();
     zmgCallAbstract($assets['classHelper'], $assets['commands']['title'], zmgFactory::getConfig()->get('meta/title'));
     zmgCallAbstract($assets['classHelper'], $assets['commands']['back']);
     zmgCallAbstract($assets['classHelper'], $assets['commands']['spacer']);
     $this->appendConstant('toolbar_node', '"' . $assets['node'] . '"');
     $this->appendConstant('toolbar_buttonclass', '"' . $assets['classButton'] . '"');
 }