function run($view, $subview, $viewtype) { //mootools & Ajax preparing stuff $this->_type = $viewtype; if (!zmgEnv::isRPC()) { if ($this->_type == "html") { if (ZMG_ADMIN) { $this->_buildAdminToolbar(); } zmgEnv::includeMootools(); $json =& zmgFactory::getJSON(); $lifetime = zmgEnv::getSessionLifetime() * 60000; //in milliseconds //refresh time is 1 minute less than the lifetime assigned in the CMS configuration $refreshTime = $lifetime <= 60000 ? 30000 : $lifetime - 60000; $this->_constants = array_merge($this->_constants, array("req_uri" => "ZMG.CONST.site_uri + '" . zmgEnv::getAjaxURL() . "'", "res_path" => "ZMG.CONST.site_uri + '/components/com_zoom/var/www/templates/" . $this->_active_template . "'", "base_path" => "'" . zmgGetBasePath() . "'", "refreshtime" => $refreshTime, "sessionid" => $json->encode(zmgEnv::getSessionID()), "sessionname" => $json->encode(zmgEnv::getSessionName()))); zmgEnv::appendPageHeader(zmgHTML::buildConstScript($this->_constants)); } } else { if ($this->_type == "xml") { zmgFactory::getRequest()->sendHeaders('xml'); } } if ($this->_type == "html") { //put the HTML headers in the head section of the parent (hosting) document $headers = $this->getHTMLHeaders(zmgEnv::getSiteURL() . '/components/com_zoom/var/www/templates', $this->_type); foreach ($headers as $header) { zmgEnv::appendPageHeader($header); } } //get template file that belongs to the active view: $res =& $this->_getResource('template', $view, $this->_type); if ($res) { $tpl_file = trim($res->firstChild->getAttribute('href')); zmgimport('org.zoomfactory.lib.helpers.zmgAPIHelper'); $api = new zmgAPIHelper(); $api->setParam('subview', $subview); $this->assign('zmgAPI', $api); //the API is accessible for all Smarty templates $this->assign('mediapath', $api->getParam('mediapath')); $this->display($tpl_file); } else { return $this->throwError('No template resource found. Unable to run application.'); } }
function toJSON() { $json =& zmgFactory::getJSON(); return "'gallery': {\n 'gid' : {$this->gid},\n 'name' : " . $json->encode($this->name) . ",\n 'descr' : " . $json->encode($this->descr) . ",\n 'cover_img' : " . $json->encode($this->getCoverImage()) . ",\n 'dir' : " . $json->encode($this->dir) . ",\n 'keywords' : " . $json->encode($this->keywords) . ",\n 'sub_gid' : {$this->sub_gid},\n 'pos' : {$this->pos},\n 'hide_msg' : {$this->hide_msg},\n 'shared' : {$this->shared},\n 'published' : {$this->published},\n 'uid' : {$this->uid},\n 'ordering' : {$this->ordering},\n 'medium_count': " . $this->getMediumCount() . ",\n 'members' : " . $json->encode($this->members) . "\n }"; }
/** * Smarty block function, provides gettext support for smarty. * * The block content is the text that should be translated. * * Any parameter that is sent to the function will be represented as %n in the translation text, * where n is 1 for the first parameter. The following parameters are reserved: * - escape - sets escape mode: * - 'html' for HTML escaping, this is the default. * - 'js' for javascript escaping. * - 'url' for url escaping. * - 'no'/'off'/0 - turns off escaping * - plural - The plural version of the text (2nd parameter of ngettext()) * - count - The item count for plural mode (3rd parameter of ngettext()) */ function smarty_block_t($params, $text, &$smarty) { $text = stripslashes($text); // set escape mode if (isset($params['escape'])) { $escape = $params['escape']; unset($params['escape']); } // set plural version if (isset($params['plural'])) { $plural = $params['plural']; unset($params['plural']); // set count if (isset($params['count'])) { $count = $params['count']; unset($params['count']); } } // use plural if required parameters are set if (isset($count) && isset($plural)) { $text = T_ngettext($text, $plural, $count); } else { // use normal $text = T_gettext($text); } // run strarg if there are parameters if (count($params)) { $text = smarty_gettext_strarg($text, $params); } if (!isset($escape) || $escape == 'html') { // html escape, default $text = nl2br(htmlspecialchars($text)); } elseif (isset($escape)) { switch ($escape) { case 'javascript': case 'js': case 'json': // javascript escape {12-12-2007, mike: modified for JSON support in ZMG} $json =& zmgFactory::getJSON(); $text = $json->encode($text); break; case 'url': // url escape $text = urlencode($text); break; } } return $text; }
function toJSON() { $json =& zmgFactory::getJSON(); return "'comment': {\n 'cid' : {$this->cid},\n 'mid' : {$this->mid},\n 'name' : " . $json->encode($this->name) . ",\n 'content' : " . $json->encode($this->getContent()) . ",\n 'date_add' : " . $json->encode($this->getDate()) . "\n }"; }
function _toJSON($msg) { $json =& zmgFactory::getJSON(); return "{\n 'title' : " . $json->encode($msg[0]) . ",\n 'descr' : " . $json->encode($msg[1]) . "\n }"; }
function jsonHelper($input, $type = 'encode') { $json =& zmgFactory::getJSON(); if ($type == "decode") { return $json->decode($input); } return $json->encode($input); }
function toJSON() { $json =& zmgFactory::getJSON(); $out = "'metadata': {\n 'mid': " . $this->_mid; if ($this->_raw === null || empty($this->_raw)) { return $out . ",'title': " . $json->encode(T_('No Metadata available.')) . "}"; } zmgimport('org.zoomfactory.lib.mime.zmgMimeHelper'); if (zmgMimeHelper::isImage($this->_ext)) { //TODO //print_r($this->_raw); if (empty($this->_raw['title'])) { $out .= ",'title': " . $json->encode(T_('No Metadata available.')) . "}"; } else { $out .= ",\n 'title' : " . $json->encode($this->_raw['title']); if (is_array($this->_raw['IFD'])) { $out .= ","; foreach ($this->_raw['IFD'] as $name => $exif_val) { $out .= $this->interpretJpegMeta($name, $exif_val); } $out = substr($out, 0, -1); } $out .= "}"; } } else { if (zmgMimeHelper::isAudio($this->_ext)) { list($artist, $title, $album, $year, $length, $data) = $this->interpretId3($this->_raw); $out .= ",\n 'title' : " . $json->encode($title) . "," . $json->encode(T_('Artist')) . ": " . $json->encode($artist) . "," . $json->encode(T_('Song')) . ": " . $json->encode($title) . "," . $json->encode(T_('Album')) . ": " . $json->encode($album) . "," . $json->encode(T_('Year')) . ": " . $json->encode($year) . "," . $json->encode(T_('Length')) . ": " . $json->encode($length) . "," . $json->encode(T_('Data')) . ": " . $json->encode($data) . "}"; } else { if (zmgMimeHelper::isVideo($this->_ext)) { //TODO $out .= ",'title': " . $json->encode(T_('No Metadata available.')) . "}"; } } } return $out; }