function &createTemplate($option, $isAdmin = false, $useCache = false) { global $mainframe; $bodyHtml = ''; $files = null; jimport('joomla.template.template'); $tmpl = new JTemplate(); // load the wrapper and common templates $tmpl->readTemplatesFromFile('page.html'); $tmpl->applyInputFilter('ShortModifiers'); // load the stock templates if (is_array($files)) { foreach ($files as $file) { $tmpl->readTemplatesFromInput($file); } } // TODO: Do the protocol better $tmpl->addVar('form', 'formAction', basename(str_replace(array('"', '<', '>', "'"), '', $_SERVER["PHP_SELF"]))); $tmpl->addVar('form', 'formName', 'adminForm'); $tmpl->setRoot(dirname(__FILE__) . '/tmpl'); $tmpl->setNamespace('mos'); if ($bodyHtml) { $tmpl->setAttribute('body', 'src', $bodyHtml); } return $tmpl; }
/** * Create a template object * * @access private * @param array An array of support template files to load * @return object JTemplate * @since 1.5 */ function &_createTemplate($files = array()) { jimport('joomla.template.template'); $conf =& JFactory::getConfig(); $tmpl = new JTemplate(); // patTemplate if ($conf->getValue('config.caching')) { $tmpl->enableTemplateCache('File', JPATH_BASE . DS . 'cache' . DS); } $tmpl->setNamespace('jtmpl'); // load the wrapper and common templates $tmpl->readTemplatesFromFile('page.html'); $tmpl->applyInputFilter('ShortModifiers'); // load the stock templates if (is_array($files)) { foreach ($files as $file) { $tmpl->readTemplatesFromInput($file); } } $tmpl->addGlobalVar('option', $GLOBALS['option']); $tmpl->addGlobalVar('self', str_replace(array('"', '<', '>', "'"), '', $_SERVER["PHP_SELF"])); $tmpl->addGlobalVar('uri_query', $_SERVER['QUERY_STRING']); $tmpl->addGlobalVar('REQUEST_URI', JRequest::getURI()); if (isset($GLOBALS['Itemid'])) { $tmpl->addGlobalVar('itemid', $GLOBALS['Itemid']); } return $tmpl; }