/** * Load hook file * * @return void */ function _load() { if (defined('_T3_HOOK_CUSTOM')) { return; } define('_T3_HOOK_CUSTOM', 1); //include hook. Get all path to hook.php in themes $paths = T3Path::getPath('hook.php', true); if (is_array($paths)) { foreach ($paths as $path) { include $path; } } }
/** * Load block content * * @param $block string * Block name - the real block is tpls/blocks/[blockname].php * * @return string Block content */ function loadBlock($block, $vars = array()) { if (!$this->_block) { $this->_block = $block; } $path = T3Path::getPath('tpls/system/' . $block . '.php'); if (!$path) { $path = T3Path::getPath('tpls/blocks/' . $block . '.php'); } ob_start(); if ($path) { include $path; } else { echo "<div class=\"error\">Block [{$block}] not found!</div>"; } $content = ob_get_contents(); ob_end_clean(); if (isset($vars['spl'])) { $content = preg_replace('#(<[A-Za-z]+[^>^\\/]*)>#', '\\1 data-original="' . $block . '"' . (isset($vars['spl']) ? ' data-spotlight="' . $vars['name'] . '"' : '') . '>', $content, 1); $this->_block = null; } echo isset($vars['spl']) ? $content : "<div class=\"t3-admin-layout-section\">" . $content . "</div>"; }
/** * Load block content * * @param $block string * Block name - the real block is tpls/blocks/[blockname].php * * @return string Block content */ function loadLayout($layout) { $path = T3Path::getPath('tpls/' . $layout . '.php', 'tpls/default.php'); if (is_file($path)) { include $path; } else { echo "<div class=\"error\">Layout [{$layout}] or [Default] not found!</div>"; } }
/** * ------------------------------------------------------------------------ * JA T3v2 System Plugin for J3.x * ------------------------------------------------------------------------ * Copyright (C) 2004-2011 J.O.O.M Solutions Co., Ltd. All Rights Reserved. * @license - GNU/GPL, http://www.gnu.org/licenses/gpl.html * Author: J.O.O.M Solutions Co., Ltd * Websites: http://www.joomlart.com - http://www.joomlancers.com * ------------------------------------------------------------------------ */ // No direct access defined('_JEXEC') or die; $t3_based_path = JPATH_SITE . DS . 'templates' . DS . T3_ACTIVE_TEMPLATE . DS; $layout = str_replace($t3_based_path, '', $t3_current_layout); $layout_path = T3Path::getPath($layout); if (!$layout_path) { //Detect if it is module or component $parts = explode(DS, $layout, 4); $type = ''; if (isset($parts[1])) { $type = $parts[1]; } if ($type) { if (preg_match('/^com_/', $type)) { //component $layout_path = JPATH_SITE . DS . 'components' . DS . $parts[1] . DS . 'views' . DS . $parts[2] . DS . 'tmpl' . DS . $parts[3]; } else { if (preg_match('/^mod_/', $type)) { //component $layout_path = JPATH_SITE . DS . 'modules' . DS . $parts[1] . DS . 'tmpl' . DS . $parts[2];
/** * Load block layout * * @param string &layout Block name - the real block is tpls/[layout].php * * @return null */ function loadLayout($layout) { $path = T3Path::getPath('tpls/' . $layout . '.php', 'tpls/default.php'); JDispatcher::getInstance()->trigger('onT3LoadLayout', array(&$path, $layout)); if (is_file($path)) { if ($this->responcls && !$this->getParam('responsive', 1)) { ob_start(); include $path; $buffer = ob_get_contents(); ob_end_clean(); //replace $buffer = preg_replace_callback('@class\\s?=\\s?(\'|")(([^\'"]*)(' . implode('|', $this->prefixes) . ')+([^\'"]*))(\'|")@m', array($this, 'responCls'), $buffer); //output echo $buffer; } else { include $path; } // append modules in debug position if ($this->getParam('snippet_debug', 0) && $this->countModules('debug')) { $this->getBuffer('modules', 'debug'); } } else { echo "<div class=\"error\">Layout [{$layout}] or [Default] not found!</div>"; } }
/** * Implement event onGetLayoutPath to return the layout which override by T3 & T3 templates * This event is fired by overriding ModuleHelper class * Return path to layout if found, false if not * * @param string $module The name of the module * @param string $layout The name of the module layout. If alternative * layout, in the form template:filename. * * @return null */ function onGetLayoutPath($module, $layout) { // Detect layout path in T3 themes if (defined('T3_PLUGIN') && T3::detect()) { T3::import('core/path'); $tPath = T3Path::getPath('html/' . $module . '/' . $layout . '.php'); if ($tPath) { return $tPath; } } return false; }
/** * Return the pagination footer. * * @return string Pagination footer. * @since 11.1 */ public function getListFooter() { $app = JFactory::getApplication(); $list = array(); $list['prefix'] = $this->prefix; $list['limit'] = $this->limit; $list['limitstart'] = $this->limitstart; $list['total'] = $this->total; $list['limitfield'] = $this->getLimitBox(); $list['pagescounter'] = $this->getPagesCounter(); $list['pageslinks'] = $this->getPagesLinks(); if (T3Common::detect()) { $chromePath = T3Path::getPath('html' . DS . 'pagination.php', false); } else { $chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/pagination.php'; } if (file_exists($chromePath)) { require_once $chromePath; if (function_exists('pagination_list_footer')) { return pagination_list_footer($list); } } return $this->_list_footer($list); }
/** * Sets an entire array of search paths for templates or resources. * * @param string The type of path to set, typically 'template'. * @param string|array The new set of search paths. If null or false, resets to the current directory only. */ protected function _setPath($type, $path) { jimport('joomla.application.helper'); $component = JApplicationHelper::getComponentName(); $app = JFactory::getApplication(); // Clear out the prior search dirs $this->_path[$type] = array(); // Actually add the user-specified directories $this->_addPath($type, $path); // Always add the fallback directories as last resort switch (strtolower($type)) { case 'template': // Set the alternative template search dir if (isset($app)) { $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component); $fallback = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . $this->getName(); //if it is T3 template, update search path for template if (T3Common::detect()) { if (is_array($fallback1 = T3Path::getPath('html' . DS . $component . DS . $this->getName(), true))) { $fallback = array_reverse($fallback1); } } $this->_addPath('template', $fallback); } break; } }
/** * Sets an entire array of search paths for templates or resources. * * @access protected * @param string $type The type of path to set, typically 'template'. * @param string|array $path The new set of search paths. If null or * false, resets to the current directory only. */ function _setPath($type, $path) { global $mainframe, $option; // clear out the prior search dirs $this->_path[$type] = array(); // actually add the user-specified directories $this->_addPath($type, $path); // always add the fallback directories as last resort switch (strtolower($type)) { case 'template': // set the alternative template search dir if (isset($mainframe)) { $option = preg_replace('/[^A-Z0-9_\\.-]/i', '', $option); $fallback = JPATH_BASE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . $option . DS . $this->getName(); //if it is T3 template, update search path for template if (T3Common::detect()) { if (is_array($fallback1 = T3Path::getPath('html' . DS . $option . DS . $this->getName(), true))) { $fallback = array_reverse($fallback1); } } $this->_addPath('template', $fallback); } break; } }
/** * Load layout content * @param $layout string Block name - the real block is tpls/blocks/[blockname].php * * @return none */ function loadLayout($layout) { $path = T3Path::getPath('tpls/' . $layout . '.php', 'tpls/default.php'); if ($path) { // include $path; $html = $this->loadFile($path); // parse and replace jdoc $html = $this->_parse($html); echo $html; } else { echo "<div class=\"error\">Layout [{$layout}] or [Default] not found!</div>"; } }
/** * * Clone Profile */ public static function duplicate($path) { $theme = JFactory::getApplication()->input->getCmd('theme'); $from = JFactory::getApplication()->input->getCmd('from'); $result = array(); if (empty($theme) || empty($from)) { return self::error(JText::_('T3_TM_INVALID_DATA_TO_SAVE')); } $source = $path . '/less/themes/' . $from; if (!JFolder::exists($source)) { // try to find the source in local $source = T3Path::getPath('less/themes/' . $from); if (!$source) { return self::error(JText::sprintf('T3_TM_NOT_FOUND', $from)); } } // $dest = $path . '/less/themes/' . $theme; // clone to local $dest = T3Path::getLocalPath('less/themes/' . $theme); if (JFolder::exists($dest)) { return self::error(JText::sprintf('T3_TM_EXISTED', $theme)); } // copy $from to $theme $status = @JFolder::copy($source, $dest); $rtlsource = $path . '/less/rtl/' . $from; if (!JFolder::exists($rtlsource)) { // try to find the source in local $rtlsource = T3Path::getPath('less/rtl/' . $from); } if ($rtlsource) { $rtldest = T3Path::getLocalPath('less/rtl/' . $theme); // copy $from to $theme @JFolder::copy($rtlsource, $rtldest); } $result = array(); if ($status) { $result['success'] = JText::_('T3_TM_CLONE_SUCCESSFULLY'); $result['theme'] = $theme; $result['reset'] = true; $result['type'] = 'duplicate'; } else { return self::error(JText::_('T3_TM_OPERATION_FAILED')); } //LessHelper::compileForTemplate(T3_TEMPLATE_PATH , $theme); T3::import('core/less'); T3Less::compileAll($theme); return self::response($result); }
/** * Get layout path * * @return string Layout path */ function getLayout() { if (JRequest::getCmd('tmpl') == 'component') { $layout_path = T3Path::getPath("page/component.php"); if ($layout_path) { return $layout_path; } } if (JRequest::getCmd('ajax')) { $layout_path = T3Path::getPath("page/ajax." . JRequest::getCmd('ajax') . ".php"); if ($layout_path) { return $layout_path; } } $mobile = T3Common::mobile_device_detect(); if ($mobile) { // try to find layout render $layout_path = T3Path::getPath("page/{$mobile}.php"); if (!$layout_path) { $layout_path = T3Path::getPath("page/handheld.php"); } if (!$layout_path) { $layout_path = T3Path::getPath("page/default.php"); } } else { $layout_path = T3Path::getPath("page/default.php"); } return $layout_path; }
<?php if (is_dir(T3Path::path('layoutinfo', true))) { ?> <link type="text/css" rel="stylesheet" href="<?php echo T3Path::url('layoutinfo/style.css', true); ?> " /> <script type="text/javascript" src="<?php echo T3Path::url('layoutinfo/script.js', true); ?> "></script> <?php } else { ?> <?php if (T3Path::getPath('layoutinfo')) { ?> <link type="text/css" rel="stylesheet" href="<?php echo T3Path::getUrl('layoutinfo/style.css'); ?> " /> <script type="text/javascript" src="<?php echo T3Path::getUrl('layoutinfo/script.js'); ?> "></script> <?php } ?> <?php } }
/** * Implement event onGetLayoutPath to return the layout which override by T3 & T3 templates * This event is fired by overriding ModuleHelper class * Return path to layout if found, false if not * * @param string $module The name of the module * @param string $layout The name of the module layout. If alternative * layout, in the form template:filename. * * @return null */ function onGetLayoutPath($module, $layout) { // Detect layout path in T3 themes if (T3::detect()) { $tPath = T3Path::getPath('html/' . $module . '/' . $layout . '.php'); if ($tPath) return $tPath; } return false; }
/** * Load block layout * * @param string &layout Block name - the real block is tpls/[layout].php * * @return null */ function loadLayout($layout) { $path = T3Path::getPath('tpls/' . $layout . '.php', 'tpls/default.php'); JDispatcher::getInstance()->trigger('onT3LoadLayout', array(&$path, $layout)); if (is_file($path)) { ob_start(); include $path; $buffer = ob_get_contents(); ob_end_clean(); if ($this->responcls && !$this->getParam('responsive', 1)) { //replace $buffer = preg_replace_callback('@class\\s?=\\s?(\'|")(([^\'"]*)(' . implode('|', $this->prefixes) . ')+([^\'"]*))(\'|")@m', array($this, 'responCls'), $buffer); } // check if exist megamenu renderer, place megamenurender on the top to render megamenu before render head if (preg_match_all('/(<jdoc:include type="megamenu"[^>]*>)/i', $buffer, $match)) { foreach ($match[1] as $m) { $buffer = str_replace('type="megamenu"', 'type="megamenurender"', $m) . $buffer; T3::import('renderer/megamenurender'); } } //output echo $buffer; } else { echo "<div class=\"error\">Layout [{$layout}] or [Default] not found!</div>"; } }
/** * Return the pagination footer. * * @return string Pagination footer. * * @since 11.1 */ public function getListFooter() { $app = JFactory::getApplication(); $list = array(); $list['prefix'] = $this->prefix; $list['limit'] = $this->limit; $list['limitstart'] = $this->limitstart; $list['total'] = $this->total; $list['limitfield'] = $this->getLimitBox(); $list['pagescounter'] = $this->getPagesCounter(); $list['pageslinks'] = $this->getPagesLinks(); // T3: detect if chrome pagination.php in template or in plugin $chromePath = T3Path::getPath('html/pagination.php'); // $chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/pagination.php'; if (file_exists($chromePath)) { include_once $chromePath; if (function_exists('pagination_list_footer')) { return pagination_list_footer($list); } } return $this->_list_footer($list); }
/** * function loadParam * load and re-render parameters * * @return render success or not */ function renderAdmin() { $frwXml = T3_ADMIN_PATH . '/' . T3_ADMIN . '.xml'; $tplXml = T3_TEMPLATE_PATH . '/templateDetails.xml'; $cusXml = T3Path::getPath('etc/assets.xml'); $jtpl = T3_ADMIN_PATH . '/admin/tpls/default.php'; if (file_exists($tplXml) && file_exists($jtpl)) { T3::import('depend/t3form'); //get the current joomla default instance $form = JForm::getInstance('com_templates.style', 'style', array('control' => 'jform', 'load_data' => true)); //wrap $form = new T3Form($form); //remove all fields from group 'params' and reload them again in right other base on template.xml $form->removeGroup('params'); //load the template $form->loadFile(T3_PATH . '/params/template.xml'); //overwrite / extend with params of template $form->loadFile($tplXml, true, '//config'); //overwrite / extend with custom config in custom/etc/assets.xml if ($cusXml && file_exists($cusXml)) { $form->loadFile($cusXml, true, '//config'); } // extend parameters T3Bot::prepareForm($form); $xml = JFactory::getXML($tplXml); $fxml = JFactory::getXML($frwXml); $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('id, title')->from('#__template_styles')->where('template=' . $db->quote(T3_TEMPLATE)); $db->setQuery($query); $styles = $db->loadObjectList(); foreach ($styles as $key => &$style) { $style->title = ucwords(str_replace('_', ' ', $style->title)); } $session = JFactory::getSession(); $t3lock = $session->get('T3.t3lock', 'overview_params'); $session->set('T3.t3lock', null); $input = JFactory::getApplication()->input; include $jtpl; /* //search for global parameters $japp = JFactory::getApplication(); $pglobals = array(); foreach($form->getGroup('params') as $param){ if($form->getFieldAttribute($param->fieldname, 'global', 0, 'params')){ $pglobals[] = array('name' => $param->fieldname, 'value' => $form->getValue($param->fieldname, 'params')); } } $japp->setUserState('oparams', $pglobals); */ return true; } return false; }
public static function copy() { // Initialize some variables $input = JFactory::getApplication()->input; $template = $input->getCmd('template'); $original = $input->getCmd('original'); $layout = $input->getCmd('layout'); //safe name $layout = JApplication::stringURLSafe($layout); if (!$template || !$original || !$layout) { return self::error(JText::_('T3_LAYOUT_INVALID_DATA_TO_SAVE')); } // clone to CUSTOM dir $source = T3Path::getPath('tpls/' . $original . '.php'); $dest = T3Path::getLocalPath('tpls/' . $layout . '.php'); $confsource = T3Path::getPath('etc/layout/' . $layout . '.ini'); $confdest = T3Path::getLocalPath('etc/layout/' . $layout . '.ini'); $params = new JRegistry(); $params->loadObject($_POST); $data = $params->toString('INI'); if (!is_dir(dirname($confdest))) { JFolder::create(dirname($confdest)); } if (!is_dir(dirname($dest))) { JFolder::create(dirname($dest)); } if ($data && !@JFile::write($confdest, $data)) { return self::error(JText::_('T3_LAYOUT_OPERATION_FAILED')); } // Check if original file exists if (JFile::exists($source)) { // Check if the desired file already exists if (!JFile::exists($dest)) { if (!JFile::copy($source, $dest)) { return self::error(JText::_('T3_LAYOUT_OPERATION_FAILED')); } //clone configuration file, we only copy if the target file does not exist if (!JFile::exists($confdest) && JFile::exists($confsource)) { JFile::copy($confsource, $confdest); } } else { return self::error(JText::_('T3_LAYOUT_EXISTED')); } } else { return self::error(JText::_('T3_LAYOUT_NOT_FOUND')); } return self::response(array('successful' => JText::_('T3_LAYOUT_SAVE_SUCCESSFULLY'), 'original' => $original, 'layout' => $layout, 'type' => 'clone')); }
/** * Implement event onGetLayoutPath to return the layout which override by T3 & T3 templates * This event is fired by overriding ModuleHelper class * Return path to layout if found, false if not * * @param string $module The name of the module * @param string $layout The name of the module layout. If alternative * layout, in the form template:filename. * * @return null */ function onGetLayoutPath($module, $layout) { // Detect layout path in T3 themes if (T3Common::detect()) { $tPath = T3Path::getPath('html' . DS . $module . DS . $layout . '.php', false); if ($tPath) { return $tPath; } } return false; }
/** * Return the pagination footer * * @access public * @return string Pagination footer * @since 1.0 */ function getListFooter() { global $mainframe; $list = array(); $list['limit'] = $this->limit; $list['limitstart'] = $this->limitstart; $list['total'] = $this->total; $list['limitfield'] = $this->getLimitBox(); $list['pagescounter'] = $this->getPagesCounter(); $list['pageslinks'] = $this->getPagesLinks(); if (T3Common::detect()) { $chromePath = T3Path::getPath('html' . DS . 'pagination.php', false); } else { $chromePath = JPATH_THEMES . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'pagination.php'; } if (file_exists($chromePath)) { require_once $chromePath; if (function_exists('pagination_list_footer')) { return pagination_list_footer($list); } } return $this->_list_footer($list); }