/**
  * Send a set of headers to the client (i.e. browser) to tell it how to display
  * the data inside the response body.
  * @param string Specifies the contect type of the response body
  * @param boolean In case of an error message, this var will be set to TRUE
  * @param string Message describing the error in case of an error
  */
 function sendHeaders($type = "xml", $error = false, $error_msg = "")
 {
     //using 'echo @header()', because that seems to implicitely work in some
     //WAMP environments. Why? Pfff, beats me.
     echo @header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     //HTTP/1.1
     echo @header("Cache-Control: no-store, no-cache, must-revalidate");
     echo @header("Cache-Control: post-check=0, pre-check=0", false);
     //HTTP/1.0
     echo @header("Pragma: no-cache");
     $encoding = zmgFactory::getConfig()->get('locale/encoding');
     if (empty($encoding)) {
         $encoding = "UTF-8";
     }
     if ($error) {
         echo @header("zmg_result: " . _ZMG_RPC_RESULT_KO);
         echo @header("zmg_message: " . urlencode($error_msg));
     } else {
         echo @header("zmg_result: " . _ZMG_RPC_RESULT_OK);
     }
     if ($type == "xml") {
         echo @header("Content-type:text/xml; charset=" . $encoding);
     } else {
         if ($type == "plain") {
             echo @header("Content-type:text/plain; charset=" . $encoding);
         } else {
             if ($type == "js" || $type == "json") {
                 echo @header("Content-type:text/javascript; charset=" . $encoding);
             }
         }
     }
 }
 function process(&$medium, &$gallery)
 {
     $ok = true;
     //innocent, until proven guilty ;)
     $events =& zmgFactory::getEvents();
     $config =& zmgFactory::getConfig();
     $imagetools =& zmgToolboxConstants::getImageTools();
     $toolkey = intval($config->get('plugins/toolbox/general/conversiontool'));
     $imagetool = $imagetools[$toolkey - 1];
     zmgimport('org.zoomfactory.var.plugins.toolbox.tools.' . $imagetool . 'Tool');
     $klass = 'zmg' . ucfirst($imagetool) . 'Tool';
     $file = $medium->getAbsPath();
     $size = getimagesize($file);
     $img_meta = array('width' => $size[0], 'height' => $size[1], 'extension' => $medium->getExtension(), 'jpeg_qty' => $config->get('plugins/toolbox/general/jpegquality'));
     $metadata = $events->fire('ongetimagemetadata', false, $medium);
     //rotate image
     //TODO
     //resize to thumbnail
     if ($ok && !file_exists($medium->getAbsPath(ZMG_MEDIUM_THUMBNAIL))) {
         $ok = call_user_func_array(array($klass, 'resize'), array($file, $medium->getAbsPath(ZMG_MEDIUM_THUMBNAIL), intval($config->get('plugins/toolbox/general/imagesizethumbnail')), $img_meta));
     }
     //resize to viewsize format
     $maxSize = intval($config->get('plugins/toolbox/general/imagesizemax'));
     if ($ok && !file_exists($medium->getAbsPath(ZMG_MEDIUM_VIEWSIZE)) && ($img_meta['width'] > $maxSize || $img_meta['height'] > $maxSize)) {
         $ok = call_user_func_array(array($klass, 'resize'), array($file, $medium->getAbsPath(ZMG_MEDIUM_VIEWSIZE), intval($config->get('plugins/toolbox/general/imagesizethumbnail')), $img_meta));
     }
     //apply watermarks
     //TODO
     if ($ok) {
         $ok = $events->fire('onputimagemetadata', false, $medium, $metadata);
     }
     return $ok;
 }
 function storeDelegate(&$event)
 {
     $aView = $event->getArgument('view');
     $view = implode(':', $aView);
     $config =& zmgFactory::getConfig();
     $events =& zmgFactory::getEvents();
     $request =& zmgFactory::getRequest();
     switch ($view) {
         case "admin:settings:store":
             $request->setResult($config->update($_POST, false));
             break;
         case stristr($view, "admin:settings:plugins:autodetect"):
             $tool = trim($aView[count($aView) - 1]);
             if ($tool == "autodetect") {
                 $tool = "all";
             } else {
                 $tool = array($tool);
             }
             $events->fire('onautodetect', false, $tool);
             break;
         case stristr($view, "admin:update:mediacount"):
             $filter = intval(array_pop($aView));
             $zoom =& zmgFactory::getEvents()->fire('ongetcore');
             $request->setResult($zoom->getMediumCount($filter));
             break;
         case "admin:galleryedit:store":
             zmgimport('org.zoomfactory.var.plugins.datastore.stores.galleryStore');
             zmgGalleryStore::process();
             break;
         case "admin:galleryedit:delete":
             zmgimport('org.zoomfactory.var.plugins.datastore.stores.galleryStore');
             zmgGalleryStore::delete();
             break;
         case "admin:mediumedit:store":
             zmgimport('org.zoomfactory.var.plugins.datastore.stores.mediumStore');
             zmgMediumStore::process();
             break;
         case stristr($view, "admin:mediaupload:store"):
             //SWFUpload needs HTTP headers to signal the user...
             $method = stristr($view, "jupload") ? "jupload" : "swfupload";
             $events->fire('onupload', false, $method);
             //exit;
             break;
         case stristr($view, "admin:mediaupload:update"):
             $gid = array_pop($aView);
             $events->fire('onuploadupdate', false, $gid);
             break;
         case stristr($view, "admin:update:mediacount"):
             $gid = intval(array_pop($aView));
             $zoom =& zmgFactory::getEvents()->fire('ongetcore');
             echo $zoom->getMediumCount($gid);
             break;
         default:
             break;
     }
 }
 function getPath()
 {
     $config =& zmgFactory::getConfig();
     $path = trim($config->get('plugins/toolbox/pdftotext/path'));
     $override = intval($config->get('plugins/toolbox/pdftotext/override'));
     if ($path == "auto") {
         $path = zmgDocumentTool::detectPath();
     }
     return $path;
 }
 function getPath()
 {
     $config =& zmgFactory::getConfig();
     $path = trim($config->get('plugins/toolbox/ffmpeg/path'));
     $override = intval($config->get('plugins/toolbox/ffmpeg/override'));
     if ($path == "auto") {
         $path = zmgVideoTool::detectPath();
     }
     return $path;
 }
 function getImageMetadata($event)
 {
     $medium = $event->getArgument('medium');
     $data = array('headers' => null, 'exif' => null, 'xmp' => null, 'irb' => null, 'finfo' => null);
     $ext = $medium->getExtension();
     $file = $medium->getAbsPath();
     if (zmgFactory::getConfig()->get('plugins/jpeg_metadata/general/readwrite') && ($ext == "jpg" || $ext == "jpeg") && !ZMG_SAFEMODE_ON) {
         //import libs first (duh ;) )
         $jmt_dir = "v" . str_replace('.', '_', ZMG_JMT_VERSION);
         zmgimport('org.zoomfactory.var.plugins.jpeg_metadata.' . $jmt_dir . '.EXIF');
         //takes care of some deferred loading as well
         zmgimport('org.zoomfactory.var.plugins.jpeg_metadata.' . $jmt_dir . '.Photoshop_File_Info');
         // Retreive the EXIF, XMP and Photoshop IRB information from
         // the existing file, so that it can be updated later on...
         $data['headers'] = get_jpeg_header_data($file);
         $data['exif'] = get_EXIF_JPEG($file);
         $data['xmp'] = read_XMP_array_from_text(get_XMP_text($data['headers']));
         $data['irb'] = get_Photoshop_IRB($data['headers']);
         $data['finfo'] = get_photoshop_file_info($data['exif'], $data['xmp'], $data['irb']);
         // Check if there is a default for the date defined
         if (!array_key_exists('date', $data['finfo']) || array_key_exists('date', $data['finfo']) && $data['finfo']['date'] == '') {
             // No default for the date defined
             // figure out a default from the file
             // Check if there is a EXIF Tag 36867 "Date and Time of Original"
             if ($data['exif'] != false && array_key_exists(0, $data['exif']) && array_key_exists(34665, $data['exif'][0]) && array_key_exists(0, $data['exif'][0][34665]) && array_key_exists(36867, $data['exif'][0][34665][0])) {
                 // Tag "Date and Time of Original" found - use it for the default date
                 $data['finfo']['date'] = $data['exif'][0][34665][0][36867]['Data'][0];
                 $data['finfo']['date'] = preg_replace("/(\\d\\d\\d\\d):(\\d\\d):(\\d\\d)( \\d\\d:\\d\\d:\\d\\d)/", "\$1-\$2-\$3", $data['finfo']['date']);
             } elseif ($data['exif'] != false && array_key_exists(0, $data['exif']) && array_key_exists(34665, $data['exif'][0]) && array_key_exists(0, $data['exif'][0][34665]) && array_key_exists(36868, $data['exif'][0][34665][0])) {
                 // Check if there is a EXIF Tag 36868 "Date and Time when Digitized"
                 // Tag "Date and Time when Digitized" found - use it for the default date
                 $data['finfo']['date'] = $data['exif'][0][34665][0][36868]['Data'][0];
                 $data['finfo']['date'] = preg_replace("/(\\d\\d\\d\\d):(\\d\\d):(\\d\\d)( \\d\\d:\\d\\d:\\d\\d)/", "\$1-\$2-\$3", $data['finfo']['date']);
             } else {
                 if ($data['exif'] != false && array_key_exists(0, $data['exif']) && array_key_exists(306, $data['exif'][0])) {
                     // Check if there is a EXIF Tag 306 "Date and Time"
                     // Tag "Date and Time" found - use it for the default date
                     $data['finfo']['date'] = $data['exif'][0][306]['Data'][0];
                     $data['finfo']['date'] = preg_replace("/(\\d\\d\\d\\d):(\\d\\d):(\\d\\d)( \\d\\d:\\d\\d:\\d\\d)/", "\$1-\$2-\$3", $data['finfo']['date']);
                 } else {
                     // Couldn't find an EXIF date in the image
                     // Set default date as creation date of file
                     $data['finfo']['date'] = date("Y-m-d", filectime($file));
                 }
             }
         }
     }
     return zmgJpeg_metadataPlugin::interpretImageData($data, $medium->filename);
 }
 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 &getFTPClient()
 {
     $cfg = zmgFactory::getConfig()->get('plugins/safemode/credentials');
     zmgimport('org.zoomfactory.var.plugins.ftp.zmgFTP');
     return zmgFTP::getInstance($cfg['host'], $cfg['port'], array('root' => $cfg['root']), $cfg['user'], $cfg['pass']);
 }
 * @license http://www.gnu.org/copyleft/gpl.html GPL
 */
defined('_ZMG_EXEC') or die('Restricted access');
include 'zmgFunctions.php';
//make the object factory available for all other classes
zmgimport('org.zoomfactory.lib.zmgFactory');
//load the error handling base class
zmgimport('org.zoomfactory.lib.zmgError');
//initialize Smarty template engine
zmgimport('org.zoomfactory.lib.smarty.Smarty');
//import other useful stuff
zmgimport('org.zoomfactory.lib.zmgHTML');
if (!class_exists('InputFilter')) {
    zmgimport('org.zoomfactory.lib.phpinputfilter.inputfilter');
}
$config =& zmgFactory::getConfig();
$events =& zmgFactory::getEvents();
$request =& zmgFactory::getRequest();
$view =& zmgFactory::getView();
$events->fire('onstartup');
$events->fire('onstarted');
if (!$config->isInstalled()) {
    $config->firstRun();
}
$view->setViewType(zmgEnv::getViewType());
//set error handling options
zmgError::setErrorHandling($config->get('app/errors/defaultmode'), $config->get('app/errors/defaultoption'));
//load php-gettext (used in zoom in 'fallback mode')
zmgimport('org.zoomfactory.lib.phpgettext.gettext_inc');
// gettext setup
T_setlocale(LC_ALL, $config->get('locale/default'));
 function getTableName($name)
 {
     $config =& zmgFactory::getConfig();
     $prefix = $config->get('db/prefix');
     $table = $config->get('db/tables/' . $name);
     if (!empty($prefix) && !empty($table)) {
         return "#__" . $prefix . $table;
     }
     return null;
 }
 /**
  * Chmods files and directories recursively to Zoom global permissions. Available from 1.0.0 up.
  * @param path The starting file or directory (no trailing slash)
  * @return TRUE=all succeeded FALSE=one or more chmods failed
  */
 function chmod($path)
 {
     $config =& zmgFactory::getConfig();
     $fileperms = octdec($config->get('filesystem/fileperms'));
     $dirperms = octdec($config->get('filesystem/dirperms'));
     if (isset($fileperms) || isset($dirperms)) {
         return zmgFileHelper::chmodRecursive($path, $fileperms, $dirperms);
     }
     return true;
 }
 function buildDirStructure()
 {
     zmgimport('org.zoomfactory.lib.helpers.zmgFileHelper');
     $html_file = "<html><body bgcolor=\"#FFFFFF\"></body></html>";
     $root = zmgEnv::getRootPath();
     $mediapath = $root . DS . zmgFactory::getConfig()->get('filesystem/mediapath');
     $dirs = array($mediapath . $this->dir, $mediapath . $this->dir . DS . 'thumbs', $mediapath . $this->dir . DS . 'viewsize');
     foreach ($dirs as $dir) {
         if (zmgFileHelper::createDir($dir, 0777)) {
             if (!zmgFileHelper::write($dir . DS . 'index.html', $html_file)) {
                 zmgError::throwError(T_('Unable to write to file: ') . $dir . DS . 'index.html');
             }
         } else {
             zmgError::throwError(T_('Unable to create directory: ') . $dir);
         }
     }
     return true;
 }
Esempio n. 13
0
 /**
  * Return the method of ordering for media.
  * @return string
  * @access public
  */
 function getMediaOrdering()
 {
     $methods = array("", "date_add ASC", "date_add DESC", "filename ASC", "filename DESC", "name ASC", "name DESC");
     return $methods[intval(zmgFactory::getConfig()->get('layout/ordering/media'))];
 }
 function zmgComment(&$db)
 {
     $this->zmgTable(zmgFactory::getConfig()->getTableName('comments'), 'cid', $db);
 }
 function finalizeUpload($gid = 0)
 {
     //finish the SwfUpload sequence...
     if ($gid === 0) {
         return zmgToolboxPlugin::registerError(T_('Upload media'), T_('No valid gallery ID provided'));
     }
     $session =& zmgFactory::getSession();
     $events =& zmgFactory::getEvents();
     $config =& zmgFactory::getConfig();
     $db =& zmgDatabase::getDBO();
     $gallery = new zmgGallery($db);
     $gallery->load($gid);
     //now we got the gallery and its data, retrieve the uploaded media
     $media = $session->get('uploadtool.fancyfiles');
     if (!is_array($media) || count($media) == 0) {
         return zmgToolboxPlugin::registerError(T_('Upload media'), T_('No media have been uploaded; nothing to do.'));
     }
     zmgimport('org.zoomfactory.lib.helpers.zmgFileHelper');
     $src_path = ZMG_ABS_PATH . DS . "etc" . DS . "cache" . DS;
     $dest_path = zmgEnv::getRootPath() . DS . $config->get('filesystem/mediapath') . $gallery->dir . DS;
     foreach ($media as $medium) {
         $obj = new zmgMedium($db);
         $name = zmgSQLEscape(zmgGetParam($_REQUEST, 'zmg_upload_name', ''));
         $descr = zmgSQLEscape(zmgGetParam($_REQUEST, 'zmg_upload_descr', ''));
         $data = array('name' => $name, 'filename' => $medium, 'descr' => $descr, 'published' => 1, 'gid' => $gallery->gid);
         $obj->setGalleryDir($gallery->dir);
         //saves a SQL query later on...
         //do some additional validation of strings
         $data['name'] = $events->fire('onvalidate', $data['name']);
         if (!$data['name']) {
             $data['name'] = $name;
         }
         $data['descr'] = $events->fire('onvalidate', $data['descr']);
         if (!$data['descr']) {
             $data['descr'] = $descr;
         }
         if (!$obj->bind($data)) {
             zmgToolboxPlugin::registerError(T_('Upload media'), T_('Medium could not be saved') . ': ' . $obj->getError());
         } else {
             if (!zmgFileHelper::copy($src_path . $medium, $dest_path . $medium)) {
                 zmgToolboxPlugin::registerError(T_('Upload media'), T_('Unable to copy file') . ' ' . $medium);
             } else {
                 if (!zmgFileHelper::delete($src_path . $medium)) {
                     zmgToolboxPlugin::registerError(T_('Upload media'), T_('Unable to delete temporary file') . ' ' . $medium);
                 } else {
                     if (!zmgToolboxPlugin::processMedium($obj, $gallery)) {
                         zmgToolboxPlugin::registerError(T_('Upload media'), T_('Medium could not be processed') . ' ' . $medium);
                     } else {
                         if (!$obj->store()) {
                             //now save this medium in our DB
                             zmgToolboxPlugin::registerError(T_('Upload media'), T_('Medium could not be saved') . ': ' . $obj->getError());
                         }
                     }
                 }
             }
         }
         //delete medium from session data: fourth parameter as TRUE
         $session->update('uploadtool.fancyfiles', $medium, ZMG_DATATYPE_ARRAY, true);
     }
     zmgToolboxPlugin::throwErrors();
 }
 /**
  * Checks if a user has the right to edit a medium, or if he/ she already
  * edited the medium before.
  *
  * @param int $id
  * @param string $which
  * @param string $filename
  * @return boolean
  * @access public
  */
 function isEdited($id, $which, $filename = '')
 {
     $db =& zmgDatabase::getDBO();
     $table = zmgFactory::getConfig()->getTableName('editmon');
     $today = time() + intval(zmgEnv::getSessionLifetime());
     $sid = md5(zmgEnv::getSessionToken());
     switch ($which) {
         case 'comment':
             $db->setQuery("SELECT edtid FROM " . $table . " WHERE " . "user_session = '{$sid}' AND comment_time > '{$now}' AND " . "object_id = " . zmgSQLEscape($id));
             break;
         case 'vote':
             $db->setQuery("SELECT edtid FROM " . $table . " WHERE " . "user_session = '{$sid}' AND vote_time > '{$now}' AND " . "object_id = " . zmgSQLEscape($id));
             break;
         case 'pass':
             $db->setQuery("SELECT edtid FROM " . $table . " WHERE " . "user_session = '{$sid}' AND pass_time > '{$now}' AND " . "object_id = " . zmgSQLEscape($id));
             break;
         case 'lightbox':
             $db->setQuery("SELECT edtid FROM " . $table . " WHERE " . "user_session = '{$sid}' AND lightbox_time > '{$now}' AND " . "lightbox_file = '" . zmgSQLEscape($filename) . "'");
             break;
     }
     $result = $db->query();
     if (mysql_num_rows($result) > 0) {
         return true;
     } else {
         return false;
     }
 }
 function embedHTML()
 {
     $config =& zmgFactory::getConfig();
     $out = "<div id=\"zmg_plugins_accordion\" class=\"zmg_halfsize\">\n";
     foreach ($this->_plugins as $plugin) {
         $name = $plugin['settings_name'];
         $settings = $plugin['settings'];
         if (is_array($settings)) {
             $out .= "<div class=\"zmg_accordion_panel\">\n" . "<h3 class=\"zmg_accordion_toggler zmg_accordion_start\">" . T_($name) . "</h3>\n" . "<div class=\"zmg_accordion_element zmg_accordion_start\">\n";
             foreach ($settings as $cat => $sub_settings) {
                 $out .= "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n" . "<tr>\n" . "\t<td colspan\"2\">\n" . "\t\t<h3>" . T_(ucfirst($cat)) . "</h3>\n" . "\t</td>\n" . "</tr>\n";
                 foreach ($sub_settings as $setting => $data) {
                     $setting_parts = array('plugins', $plugin['name'], $cat, $setting);
                     $setting_value = $config->get(implode('/', $setting_parts));
                     $input_name = "zmg_" . implode('_', $setting_parts);
                     $out .= "<tr>\n";
                     switch ($data['type']) {
                         case "checkbox":
                             $out .= "\t\t<td width=\"250\">" . T_($data['label']) . "</td><td>";
                             $checked = $setting_value == $data['value'] ? true : false;
                             $out .= $this->_buildCheckboxInput($input_name, $data['value'], $checked) . "</td>\n";
                             break;
                         case "radio":
                             $out .= "\t\t<td width=\"250\">" . T_($data['label']) . "</td><td>";
                             $checked = $setting_value == $data['value'] ? true : false;
                             $out .= $this->_buildRadioInput($input_name, $data['value'], $checked) . "</td>\n";
                             break;
                         case "select":
                             $options = array();
                             foreach ($data as $key => $value) {
                                 if (stristr($key, 'option')) {
                                     $options[] = $value;
                                 }
                             }
                             $out .= "\t\t<td width=\"250\">" . T_($data['label']) . "</td><td>" . $this->_buildSelectInput($input_name, $options, $setting_value) . "</td>\n";
                             break;
                         case "text":
                         case "password":
                             $out .= "\t\t<td width=\"250\">" . T_($data['label']) . "</td><td>" . $this->_buildTextInput($input_name, $setting_value, $data['type'], $data['size']) . "</td>\n";
                             break;
                     }
                     $out .= "</tr>\n";
                 }
                 $out .= "</table>\n";
             }
             $out .= "</div>\n</div>\n";
         } else {
             //$out .= T_('No settings found for this plugin.');
         }
     }
     return $out . "</div>\n";
 }
 /**
  * Public variable, containing the zmgViewHelper - helping ZMG with controlling
  * the views on the different models that the Core exposes.
  *
  * @return zmgViewHelper
  */
 function &getView()
 {
     static $instance_view;
     if (!is_object($instance_view)) {
         zmgimport('org.zoomfactory.lib.helpers.zmgViewHelper');
         $config =& zmgFactory::getConfig();
         $instance_view = new zmgViewHelper($config->get('smarty'), $config->get('app/secret'));
     }
     return $instance_view;
 }
 /**
  * Retrieve a specific configuration setting.
  *
  * @param string The name of the setting in the format of a pathname: 'group/setting'
  */
 function getConfig($path)
 {
     return zmgFactory::getConfig()->get($path);
 }
 function zmgMediumMetadata(&$medium)
 {
     $config =& zmgFactory::getConfig();
     $events =& zmgFactory::getEvents();
     $this->_mid = $medium->mid;
     $this->_ext = $medium->getExtension();
     zmgimport('org.zoomfactory.lib.mime.zmgMimeHelper');
     $path = $medium->getAbsPath(ZMG_MEDIUM_ORIGINAL . $config->get('filesystem/mediapath'));
     if (zmgMimeHelper::isImage($this->_ext)) {
         $this->_raw = $events->fire('ongetimagemetadata', false, $medium);
     } else {
         if (zmgMimeHelper::isAudio($this->_ext)) {
             $this->_raw = $events->fire('ongetaudiometadata', false, $path);
         } else {
             if (zmgMimeHelper::isVideo($this->_ext)) {
                 $this->_raw = $events->fire('ongetvideometadata', false, $path);
             }
         }
     }
 }
 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;
 }