function _loadPlugins()
 {
     zmgimport('org.zoomfactory.lib.helpers.zmgFileHelper');
     $plugin_cats = zmgFileHelper::readDir(ZMG_ABS_PATH . DS . 'var' . DS . 'plugins', '[^index\\.html]');
     $this->_plugins = array();
     foreach ($plugin_cats as $plugin) {
         if ($plugin != "shared") {
             $content = zmgFileHelper::readDir(ZMG_ABS_PATH . DS . 'var' . DS . 'plugins' . DS . $plugin, '[^index\\.html]');
             if (is_array($content) && count($content) > 0) {
                 $plugin_class = "zmg" . ucfirst($plugin) . "Plugin";
                 zmgimport('org.zoomfactory.var.plugins.' . $plugin . '.' . $plugin . 'Plugin');
                 $events = zmgCallAbstract($plugin_class, 'bindEvents');
                 if (is_array($events)) {
                     // update the PluginHelper's event registry
                     $this->_bindEvents($plugin_class, $events);
                 }
                 $this->_plugins[] = array('name' => $plugin, 'classname' => $plugin_class, 'settings' => null, 'events' => $events);
             }
         }
     }
 }
 /**
  * Utility function to read the files in a directory
  * @param string The file system path
  * @param string A filter for the names
  * @param boolean Recurse search into sub-directories
  * @param boolean True if to prepend the full path to the file name
  */
 function readDir($path, $filter = '.', $recurse = false, $fullpath = false)
 {
     $arr = array();
     if (!@is_dir($path)) {
         return $arr;
     }
     $handle = opendir($path);
     while ($file = readdir($handle)) {
         $dir = zmgFileHelper::cleanPath($path . DS . $file, false);
         $isDir = is_dir($dir);
         if ($file != "." && $file != ".." && $file != ".svn") {
             if (preg_match("/{$filter}/", $file)) {
                 if ($fullpath) {
                     $arr[] = trim(zmgFileHelper::cleanPath($path . DS . $file, false));
                 } else {
                     $arr[] = trim($file);
                 }
             }
             if ($recurse && $isDir) {
                 $arr2 = zmgFileHelper::readDir($dir, $filter, $recurse, $fullpath);
                 $arr = array_merge($arr, $arr2);
             }
         }
     }
     closedir($handle);
     asort($arr);
     return $arr;
 }
 function getTemplates()
 {
     if (isset($this) && is_a($this, 'zmgTemplateHelper')) {
         return $this->throwError('This function may only be called statically!');
     }
     $basePath = ZMG_ABS_PATH . DS . 'var' . DS . 'www' . DS . 'templates';
     $baseConfig =& zmgFactory::getConfig()->get('smarty');
     zmgimport('org.zoomfactory.lib.helpers.zmgFileHelper');
     $dirs = zmgFileHelper::readDir($basePath, '[^index\\.html]');
     $tpls = array();
     foreach ($dirs as $dir) {
         if ($dir == "shared" || $dir == "admin") {
             continue;
             //TODO: catch this inside the regex above ('[^index\.html]')...
         }
         if (is_dir($basePath . DS . $dir) && zmgFileHelper::exists($basePath . DS . $dir . DS . 'manifest.xml')) {
             $baseConfig['activetemplate'] = $dir;
             $tpls[] = new zmgTemplateHelper($baseConfig, '', true);
         }
     }
     return $tpls;
 }