/** * Include another template into current template * @return \Zo2Html */ public function load($key) { $tplFile = $this->_path->getPath($this->_namespace . '/' . $key); if ($tplFile) { $properties = $this->getProperties(); extract($properties, EXTR_REFS); include $tplFile; } return $this; }
/** * * @param type $cacheFile * @return boolean */ public function loadCache($cacheFile) { /** * @todo Check modified time with current time to force reload cache */ $cacheFile = $this->path->getFile('cache://' . md5($cacheFile)); if ($cacheFile) { $buffer = JFile::read($cacheFile); return $buffer; } return false; }
/** * * @param string $className */ public function autoloadByPsr2($className) { $parts = $this->splitClassname($className); $prefix = array_shift($parts); /* Joomla prefix */ if ($prefix != 'J') { $key = strtolower($prefix . '://' . implode('/', $parts)) . '.php'; $path = Zo2Path::getInstance(); $filePath = $path->getPath($key); if ($filePath) { require_once $filePath; } } }
/** * * @return string */ private function _generateJavascripts() { $combineJs = Zo2Framework::getParam('combine_js', 0); $developmentMode = Zo2Framework::getParam('development_mode', 0); $jsHtml = array(); /** * Only do combine when asked and not in development mode */ if ($combineJs == 1 && $developmentMode == 0) { $jsFile = 'cache/zo2_' . md5(serialize($this->_javascripts)) . '.js'; $jsFilePath = JPATH_ROOT . '/' . $jsFile; $jsContent = array(); /** * @todo Cache combined file instead generate it everytimes */ foreach ($this->_javascripts as $javascript => $path) { /* Optimize output javascripts content */ if (Zo2Framework::getParam('optimzie_js', 0) == 1) { $jsContent[] = Zo2HelperCompiler::javascript(file_get_contents($path)); } else { $jsContent[] = file_get_contents($path); } } /* Save to combined file */ file_put_contents($jsFilePath, implode(PHP_EOL, $jsContent)); /* Generate HTML to load it */ $jsHtml[] = '<script type="text/javascript" src="' . rtrim(JUri::root(true), '/') . '/' . $jsFile . '"></script>'; } else { /* Just load js files without touching */ foreach ($this->_javascripts as $javascript => $path) { $jsHtml[] = '<script type="text/javascript" src="' . Zo2Path::getInstance()->toUrl($javascript) . '"></script>'; } } /* Custom javascripts code */ $jsDeclarationHtml[] = '<script>jQuery(document).ready( function () {'; foreach ($this->_javascriptDeclarations as $javascriptDeclaration) { /* Optimize output javascripts content */ if (Zo2Framework::getParam('optimzie_js', 0) == 1) { $jsDeclarationHtml[] = Zo2HelperCompiler::javascript($javascriptDeclaration); } else { $jsDeclarationHtml[] = $javascriptDeclaration; } } $jsDeclarationHtml[] = ' }); </script>'; return trim(implode(PHP_EOL, $jsHtml) . PHP_EOL . implode(PHP_EOL, $jsDeclarationHtml)); }
} ?> > <?php echo Zo2Html::field('image', array('label' => JText::_('ZO2_ADMIN_GENERAL_LABEL_BACKGROUND_IMAGE'), 'description' => JText::_('ZO2_ADMIN_GENERAL_DESC_BACKGROUND_IMAGE'), 'class_wrap' => 'zo2-background-image', 'class' => 'zo2-background-image'), array('id' => 'zo2_background_image', 'name' => 'zo2_background_image', 'value' => $preset_data['bg_image'])); ?> <hr /> <div class="zo2_themes_label"> <?php echo JText::_('ZO2_TEMPLATE_THEME_PATTERN_BACKGROUND'); ?> </div> <div class="zo2_themes_for"> <ul class="options background-select"> <?php $zPath = Zo2Path::getInstance(); $backgroundsDir = Zo2Factory::getPath("templates://assets/zo2/images/background-patterns"); $bgPatterns = glob($backgroundsDir . '/*.*'); if (count($bgPatterns) > 0) { foreach ($bgPatterns as $pattern) { if (is_array(getimagesize($pattern))) { $selected = ''; $pattern_src = $zPath->toUrl($pattern); $pattern_path = str_replace(JPATH_ROOT . DIRECTORY_SEPARATOR, '', $pattern); if (isset($preset_data['bg_pattern']) && $pattern_path == $preset_data['bg_pattern']) { $selected = 'selected'; } echo '<li class="' . $selected . '"><img rel="' . $pattern_path . '" src="' . $pattern_src . '" /></li>'; } } }
/** * Return url by input key * @param type $name * @return type */ public static function getUrl($key) { return Zo2Path::getInstance()->getUrl($key); }
/** * * @param type $key * @return string|boolean */ public function getPath($key) { return $this->_path->getPath($key); }
/** * Framework init */ public function init() { if (!defined('ZO2_LOADED')) { $this->template = Zo2Factory::getTemplate(); /* Load language */ $language = JFactory::getLanguage(); $language->load('plg_system_zo2', ZO2PATH_ROOT); JHtml::_('jquery.framework'); $jinput = JFactory::getApplication()->input; /** * Init framework variables */ $this->path = Zo2Path::getInstance(); /* Zo2 root dir */ $this->path->registerNamespace('zo2', ZO2PATH_ROOT); /* Zo2 html */ $this->path->registerNamespace('html', ZO2PATH_ROOT . '/html'); /* Zo2 assets */ $this->path->registerNamespace('assets', ZO2PATH_ROOT . '/assets'); /** * Zo2 template */ $templateName = $this->template->template; $this->path->registerNamespace('zo2', JPATH_ROOT . '/templates/' . $templateName); $this->path->registerNamespace('assets', JPATH_ROOT . '/templates/' . $templateName . '/assets'); /* Current */ $this->path->registerNamespace('templates', JPATH_ROOT . '/templates/' . $templateName); /* Override Zo2 html directory */ $this->path->registerNamespace('html', JPATH_ROOT . '/templates/' . $templateName . '/html'); /** * Init Zo2 objects */ $this->assets = Zo2Assets::getInstance(); if (JFactory::getApplication()->isAdmin()) { JHtml::_('jquery.ui', array('core', 'sortable')); $this->profile = Zo2Factory::getProfile(); } else { $this->profile = Zo2Factory::getProfile(); } $this->layout = new Zo2Layout($this->profile->layout); $this->_loadAssets(); define('ZO2_LOADED', 1); } }