Файловый менеджер - Редактировать - /home/wuectly/www/03cbe/core.tar
Назад
bot.php 0000604 00000031463 15245573257 0006063 0 ustar 00 <?php /** *------------------------------------------------------------------------------ * @package T3 Framework for Joomla! *------------------------------------------------------------------------------ * @copyright Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @authors JoomlArt, JoomlaBamboo, (contribute to this project at github * & Google group to become co-author) * @Google group: https://groups.google.com/forum/#!forum/t3fw * @Link: http://t3-framework.org *------------------------------------------------------------------------------ */ use Joomla\CMS\Categories\Categories; use Joomla\CMS\Factory; use Joomla\CMS\Form\Form; use Joomla\CMS\Table\Table; use Joomla\Filesystem\File; use Joomla\Filesystem\Folder; use Joomla\Registry\Registry; // No direct access defined('_JEXEC') or die(); /** * T3Bot class * Auto trigger * * @package T3 */ class T3Bot extends Registry { // call before checking & loading T3 public static function preload () { // NO NEED TO reupdate megamenu configuration return; // check if menu is alter, then turn a flag to reupdate megamenu configuration $input = Factory::getApplication()->input; if ($input->get('option') == 'com_menus' && preg_match('#save|apply|trash|remove|delete|publish|order#i', $input->get('task'))) { // get all template styles $db = Factory::getDBO(); $query = $db->getQuery(true); $query ->select('*') ->from('#__template_styles') ->where('client_id=0'); $db->setQuery($query); $themes = $db->loadObjectList(); //update all global parameters foreach($themes as $theme){ $registry = new Registry; $registry->loadString($theme->params); $mm_config = $registry->get('mm_config'); if (!$mm_config) continue; // turn on flag $registry->set('mm_config_needupdate', 1); //overwrite with new value $query = $db->getQuery(true); $query ->update('#__template_styles') ->set('params =' . $db->quote($registry->toString())) ->where('id =' . (int)$theme->id); $db->setQuery($query); $db->execute(); } // force reload cache template $cache = Factory::getCache('com_templates', ''); $cache->clean(); } } // call before call T3::init public static function beforeInit () { } // call after call T3::init public static function afterInit () { $app = Factory::getApplication(); $input = $app->input; $tplparams = $app->getTemplate(true)->params; if (!T3::isAdmin()) { // check if need update megamenu configuration if ($tplparams->get ('mm_config_needupdate')) { T3::import('menu/megamenu'); T3::import('admin/megamenu'); $currentconfig = @json_decode($tplparams->get ('mm_config', ''), true); if (!is_array($currentconfig)){ $currentconfig = array(); } else { $menuassoc = T3AdminMegamenu::menus(); $menulangs = array(); $menutypes = array(); foreach ($menuassoc as $key => $massoc) { $menutypes[] = $massoc->value; $menulangs[$massoc->value] = $massoc->language; } } foreach ($currentconfig as $menukey => $mmconfig) { if (!is_array($mmconfig)){ continue; } $menutype = $menukey; if(!in_array($menutype, $menutypes) && preg_match('@(-(\d))+$@', $menukey, $match)){ $menutype = preg_replace('@(-(\d))+$@', '', $menutype); $access = explode('-', $match[0]); $access[] = 1; $access = array_filter($access); $access = array_unique($access); $mmconfig['access'] = $access; } if(!in_array($menutype, $menutypes)){ continue; } $mmconfig['language'] = $menulangs[$menutype]; $menu = new T3MenuMegamenu ($menutype, $mmconfig); $children = $menu->get ('children'); //remove additional settings unset($mmconfig['language']); unset($mmconfig['access']); foreach ($mmconfig as $item => $setting) { if (is_array($setting) && isset($setting['sub'])) { $sub = &$setting['sub']; $id = (int) substr($item, 5); // remove item- $modify = false; if (!isset($children[$id]) || !count ($children[$id])){ //check and remove any empty row for ($j=0; $j < count($sub['rows']); $j++) { $remove = true; for ($k=0; $k < count($sub['rows'][$j]); $k++) { if (isset($sub['rows'][$j][$k]['position'])) { $remove = false; break; } } if($remove){ $modify = true; unset($sub['rows'][$j]); } } if($modify){ $sub['rows'] = array_values($sub['rows']); //re-index $mmconfig[$item]['sub'] = $sub; } continue; } $items = array(); foreach ($sub['rows'] as $row) { foreach ($row as $col) { if (!isset($col['position'])) { $items[] = $col['item']; } } } // update the order of items $_items = array(); $_itemsids = array(); $firstitem = 0; foreach ($children[$id] as $child) { $_itemsids[] = (int)$child->id; if (!$firstitem) $firstitem = (int)$child->id; if (in_array($child->id, $items)) { $_items [] = (int)$child->id; } } // $_items[0] = $firstitem; if (empty($_items) || $_items[0] != $firstitem) { if (count ($_items) == count($items)) { $_items[0] = $firstitem; } else { array_splice($_items, 0, 0, $firstitem); } } // no need update config for this item if ($items == $_items) continue; // update back to setting $i = 0; $c = count ($_items); for ($j=0; $j < count($sub['rows']); $j++) { for ($k=0; $k < count($sub['rows'][$j]); $k++) { if (!isset($sub['rows'][$j][$k]['position'])) { $sub['rows'][$j][$k]['item'] = $i < $c ? $_items[$i++] : ""; } } } //update - add new rows for new items - at the first rows if(!empty($_items) && count($items) == 0){ $modify = true; array_unshift($sub['rows'], array(array('item' => $_items[0], 'width' => 12))); } //check and remove any empty row for ($j=0; $j < count($sub['rows']); $j++) { $remove = true; for ($k=0; $k < count($sub['rows'][$j]); $k++) { if (isset($sub['rows'][$j][$k]['position']) || in_array($sub['rows'][$j][$k]['item'], $_itemsids)) { $remove = false; break; } } if($remove){ $modify = true; unset($sub['rows'][$j]); } } if($modify){ $sub['rows'] = array_values($sub['rows']); //re-index } $mmconfig[$item]['sub'] = $sub; } } $currentconfig[$menukey] = $mmconfig; } // update megamenu back to other template styles parameter $mm_config = json_encode($currentconfig, JSON_UNESCAPED_UNICODE); // update megamenu back to current template style parameter $template = $app->getTemplate(true); $params = $template->params; $params->set ('mm_config', $mm_config); $template->params = $params; //update the cache T3::setTemplate(T3_TEMPLATE, $params); //get all other styles that have the same template $db = Factory::getDBO(); $query = $db->getQuery(true); $query ->select('*') ->from('#__template_styles') ->where('template=' . $db->quote(T3_TEMPLATE)) ->where('client_id=0'); $db->setQuery($query); $themes = $db->loadObjectList(); //update all global parameters foreach($themes as $theme){ $registry = new Registry; $registry->loadString($theme->params); $registry->set('mm_config', $mm_config); //overwrite with new value $registry->set('mm_config_needupdate', ""); //overwrite with new value $query = $db->getQuery(true); $query ->update('#__template_styles') ->set('params =' . $db->quote($registry->toString())) ->where('id =' . (int)$theme->id); $db->setQuery($query); $db->execute(); } // force reload cache template $cache = Factory::getCache('com_templates', ''); $cache->clean(); } } } // call when prepare form for template parameter // looking in less/extras folder to render parameters for extended template style public static function prepareForm (&$form) { jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); // load add-ons setting $path = T3_TEMPLATE_PATH . '/less/extras'; if (!is_dir ($path)) return ; $files = Folder::files($path, '.less'); if (!$files || !count($files)){ return ; } $extras = array(); foreach ($files as $file) { $extras[] = File::stripExt($file); } if (count($extras)) { //load languages if(!defined('T3_TEMPLATE')){ Factory::getLanguage()->load(T3_PLUGIN, JPATH_ADMINISTRATOR); } $_xml = '<?xml version="1.0"?> <form> <fields name="params"> <fieldset name="addon_params" label="T3_ADDON_LABEL" description="T3_ADDON_DESC"> <field type="t3depend" name="t3_addon_theme_extra" function="@legend" label="T3_ADDON_THEME_EXTRAS_LABEL" description="T3_ADDON_THEME_EXTRAS_DESC" /> '; foreach ($extras as $extra) { $_xml .= ' <field name="theme_extras_'.$extra.'" global="1" type="menuitem" multiple="true" default="" label="'.$extra.'" description="'.$extra.'" published="1" class="t3-extra-setting"> <option value="-1">T3_ADDON_THEME_EXTRAS_ALL</option> <option value="0">T3_ADDON_THEME_EXTRAS_NONE</option> </field>'; } $_xml .= ' </fieldset> </fields> </form> '; $xml = simplexml_load_string($_xml); $form->load ($xml, false); } } public static function extraFields(&$form, $data, $tplpath){ if ($form->getName() == 'com_categories.categorycom_content' || $form->getName() == 'com_content.article') { // check for extrafields overwrite $path = $tplpath . '/etc/extrafields'; if (!is_dir ($path)) return ; $files = Folder::files($path, '.xml'); if (!$files || !count($files)){ return ; } $extras = array(); foreach ($files as $file) { $extras[] = File::stripExt($file); } if (count($extras)) { if ($form->getName() == 'com_categories.categorycom_content'){ //load languages if(!defined('T3_TEMPLATE')){ Factory::getLanguage()->load(T3_PLUGIN, JPATH_ADMINISTRATOR); } $_xml = '<?xml version="1.0"?> <form> <fields name="params"> <fieldset name="t3_extrafields_params" label="T3_EXTRA_FIELDS_GROUP_LABEL" description="T3_EXTRA_FIELDS_GROUP_DESC"> <field name="t3_extrafields" type="list" default="" show_none="true" label="T3_EXTRA_FIELDS_LABEL" description="T3_EXTRA_FIELDS_DESC"> <option value="">JNONE</option>'; foreach ($extras as $extra) { $_xml .= '<option value="' . $extra . '">' . ucfirst($extra) . '</option>'; } $_xml .= ' </field> </fieldset> </fields> </form> '; $xml = simplexml_load_string($_xml); $form->load ($xml, false); } else { $app = Factory::getApplication(); $input = $app->input; $fdata = empty($data) ? $input->post->get('jform', array(), 'array') : (is_object($data) && method_exists($data, 'getProperties') ? $data->getProperties() : (array) $data); if (isset($data->attribs) && is_string($data->attribs)) { $data->attribs = json_decode($data->attribs, true); } if(!empty($fdata['catid']) && is_array($fdata['catid'])) { // create new $catid = end($fdata['catid']); } else { // edit $catid = ($fdata['catid']); } if($catid){ if(version_compare(JVERSION, '3.0', 'lt')){ jimport('joomla.application.categories'); } $categories = Categories::getInstance('Content', array('countItems' => 0 )); $category = $categories->get($catid); $params = $category->params; if(!$params instanceof Registry) { $params = new Registry; $params->loadString($category->params); } if($params instanceof Registry){ $extrafile = $path . '/' . $params->get('t3_extrafields') . '.xml'; if(is_file($extrafile)){ Form::addFormPath($path); $form->loadFile($params->get('t3_extrafields'), false); } } } } } } } public static function onContentBeforeSave($context, $data, $isNew) { if(isset($data->attribs)){ $contentTable = Table::getInstance('Content', 'JTable',array()); $contentTable->load($data->id); $oldAttribs = new Registry($contentTable->attribs); $attribs = new Registry($data->attribs); $oldAttribs->merge($attribs); $data->attribs = $oldAttribs->toString(); } } } defines.php 0000604 00000003030 15245573257 0006701 0 ustar 00 <?php /** *------------------------------------------------------------------------------ * @package T3 Framework for Joomla! *------------------------------------------------------------------------------ * @copyright Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @authors JoomlArt, JoomlaBamboo, (contribute to this project at github * & Google group to become co-author) * @Google group: https://groups.google.com/forum/#!forum/t3fw * @Link: http://t3-framework.org *------------------------------------------------------------------------------ */ use Joomla\CMS\Uri\Uri; // No direct access defined('_JEXEC') or die; define ('T3_PLUGIN', 'plg_system_t3'); //T3 base folder define ('T3_ADMIN', 't3'); define ('T3_ADMIN_PATH', JPATH_ROOT . '/plugins/system/' . T3_ADMIN); define ('T3_ADMIN_URL', Uri::root(true) . '/plugins/system/' . T3_ADMIN); define ('T3_ADMIN_REL', 'plugins/system/' . T3_ADMIN); //T3 secondary base theme folder define ('T3_EX_BASE_PATH', JPATH_ROOT . '/media/t3/themes'); define ('T3_EX_BASE_URL', Uri::root(true) . '/media/t3/themes'); define ('T3_EX_BASE_REL', 'media/t3/themes'); //T3 core base theme define ('T3_CORE_BASE', 'base'); define ('T3_CORE_BASE_PATH', T3_ADMIN_PATH . '/' . T3_CORE_BASE); define ('T3_CORE_BASE_URL', T3_ADMIN_URL . '/' . T3_CORE_BASE); define ('T3_CORE_BASE_REL', T3_ADMIN_REL . '/' . T3_CORE_BASE); // T3 User dir define ('T3_LOCAL_DIR', 'local'); t3j.php 0000604 00000005142 15245573257 0005772 0 ustar 00 <?php /** *------------------------------------------------------------------------------ * @package T3 Framework for Joomla! *------------------------------------------------------------------------------ * @copyright Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @authors JoomlArt, JoomlaBamboo, (contribute to this project at github * & Google group to become co-author) * @Google group: https://groups.google.com/forum/#!forum/t3fw * @Link: http://t3-framework.org *------------------------------------------------------------------------------ */ // no direct access defined('_JEXEC') or die('Restricted access'); /** * T3J class * Make T3 compatible with both Joomla 3.x & 2.5 * @package T3 */ class T3J { /** * The method is available from Joomla 3.1.2 in class JHtml. Changing call JHtml::tooltipText to T3J::tooltipText to make it work on Joomla 2.5 * * Converts a double colon seperated string or 2 separate strings to a string ready for bootstrap tooltips * * @param string $title The title of the tooltip (or combined '::' separated string). * @param string $content The content to tooltip. * @param int $translate If true will pass texts through JText. * @param int $escape If true will pass texts through htmlspecialchars. * * @return string The tooltip string * * @since 3.1.2 */ public static function tooltipText($title = '', $content = '', $translate = 1, $escape = 1) { // Return empty in no title or content is given. if ($title == '' && $content == '') { return ''; } // Split title into title and content if the title contains '::' (old Mootools format). if ($content == '' && !(strpos($title, '::') === false)) { list($title, $content) = explode('::', $title, 2); } // Pass texts through the JText. if ($translate) { $title = JText::_($title); $content = JText::_($content); } // Escape the texts. if ($escape) { $title = str_replace('"', '"', $title); $content = str_replace('"', '"', $content); } // Return only the content if no title is given. if ($title == '') { return $content; } // Return only the title if title and text are the same. if ($title == $content) { return '<strong>' . $title . '</strong>'; } // Return the formated sting combining the title and content. if ($content != '') { return '<strong>' . $title . '</strong><br />' . $content; } // Return only the title. return $title; } } admin.php 0000604 00000033203 15245573257 0006361 0 ustar 00 <?php use Joomla\CMS\Factory; use Joomla\Registry\Registry; /** *------------------------------------------------------------------------------ * @package T3 Framework for Joomla! *------------------------------------------------------------------------------ * @copyright Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @authors JoomlArt, JoomlaBamboo, (contribute to this project at github * & Google group to become co-author) * @Google group: https://groups.google.com/forum/#!forum/t3fw * @Link: http://t3-framework.org *------------------------------------------------------------------------------ */ // Define constant class T3Admin { protected $langs = array(); protected $html = array(); /** * init admin backend to edit template style */ public function init() { $app = Factory::getApplication(); $input = $app->input; if ($input->getCmd('view') == 'style') { $app->set('themes.base', T3_ADMIN_PATH); $app->set('theme', 'admin'); } if(version_compare(JVERSION, '4', 'ge')){ $wa = Factory::getDocument()->getWebAssetManager(); //var_dump($wa->getAssets('script'));die; $wa->registerAsset('script', 'bootstrap.js.bundle', T3_ADMIN_REL . '/admin/bootstrap/js/bootstrap.js', ['dependencies' => 'jquery']); $wa->registerAsset('script', 'jquery', T3_ADMIN_REL . '/admin/js/jquery-1.x.min.js'); $wa->registerAsset('script', 'jquery-noconflict', T3_ADMIN_REL . '/admin/js/jquery.noconflict.js'); //$wa->disableAsset('script', 'bootstrap.init.legacy'); //$wa->useAsset('script', 'bootstrap.js.bundle'); } } public function updateHead() { } /** * function render * render T3 administrator configuration form * * @return render success or not */ public function render(){ $app = Factory::getApplication(); $input = $app->input; if ('style' != $input->getCmd('view')) return; $body = $app->getBody(); $layout = T3_ADMIN_PATH . '/admin/tpls/default.php'; $layout = false; if(file_exists($layout)){ // ob_start(); // $this->renderAdmin(); // $buffer = ob_get_clean(); //this cause backtrack_limit in some server //$body = preg_replace('@<form\s[^>]*name="adminForm"[^>]*>(.*)</form>@msU', $buffer, $body); $opentags = explode('<form', $body); $endtags = explode('</form>', $body); $open = array_shift($opentags); $close = array_pop($endtags); //should not happend if(count($opentags) > 1) { $iopen = 0; $iclose = count($opentags); foreach ($opentags as $index => $value) { if($iopen !== -1 && strpos($value, 'name="adminForm"') === false){ $iopen++; $open = $open . '<form' . $value; } else { $iopen = -1; } if($iclose !== -1 && strpos($endtags[--$iclose], 'name="adminForm"') === false){ $close = $endtags[$iclose] . '</form>' . $close; } else { $iclose = -1; } } } //$body = $open . $this->html['admin'] . $close; //$body = $this->html['admin']; } if(!$input->getCmd('file')){ $body = $this->replaceToolbar($body); } $body = $this->replaceDoctype($body); $app->setBody($body); } public function addAssets() { $japp = Factory::getApplication(); $jdoc = Factory::getDocument(); $db = Factory::getDbo(); $params = T3::getTplParams(); $input = $japp->input; if ('style' != $input->getCmd('view')) return; // load template language Factory::getLanguage()->load ('tpl_'.T3_TEMPLATE.'.sys', JPATH_ROOT, null, true); $langs = array( 'unknownError' => JText::_('T3_MSG_UNKNOWN_ERROR'), 'logoPresent' => JText::_('T3_LAYOUT_LOGO_TEXT'), 'emptyLayoutPosition' => JText::_('T3_LAYOUT_EMPTY_POSITION'), 'defaultLayoutPosition' => JText::_('T3_LAYOUT_DEFAULT_POSITION'), 'layoutConfig' => JText::_('T3_LAYOUT_CONFIG_TITLE'), 'layoutConfigDesc' => JText::_('T3_LAYOUT_CONFIG_DESC'), 'layoutUnknownWidth' => JText::_('T3_LAYOUT_UNKN_WIDTH'), 'layoutPosWidth' => JText::_('T3_LAYOUT_POS_WIDTH'), 'layoutPosName' => JText::_('T3_LAYOUT_POS_NAME'), 'layoutCanNotLoad' => JText::_('T3_LAYOUT_LOAD_ERROR'), 'askCloneLayout' => JText::_('T3_LAYOUT_ASK_ADD_LAYOUT'), 'correctLayoutName' => JText::_('T3_LAYOUT_ASK_CORRECT_NAME'), 'askDeleteLayout' => JText::_('T3_LAYOUT_ASK_DEL_LAYOUT'), 'askDeleteLayoutDesc' => JText::_('T3_LAYOUT_ASK_DEL_LAYOUT_DESC'), 'askPurgeLayout' => JText::_('T3_LAYOUT_ASK_DEL_LAYOUT'), 'askPurgeLayoutDesc' => JText::_('T3_LAYOUT_ASK_PURGE_LAYOUT_DESC'), 'lblDeleteIt' => JText::_('T3_LAYOUT_LABEL_DELETEIT'), 'lblCloneIt' => JText::_('T3_LAYOUT_LABEL_CLONEIT'), 'layoutEditPosition' => JText::_('T3_LAYOUT_EDIT_POSITION'), 'layoutShowPosition' => JText::_('T3_LAYOUT_SHOW_POSITION'), 'layoutHidePosition' => JText::_('T3_LAYOUT_HIDE_POSITION'), 'layoutChangeNumpos' => JText::_('T3_LAYOUT_CHANGE_NUMPOS'), 'layoutDragResize' => JText::_('T3_LAYOUT_DRAG_RESIZE'), 'layoutHiddenposDesc' => JText::_('T3_LAYOUT_HIDDEN_POS_DESC'), 'updateFailedGetList' => JText::_('T3_OVERVIEW_FAILED_GETLIST'), 'updateDownLatest' => JText::_('T3_OVERVIEW_GO_DOWNLOAD'), 'updateCheckUpdate' => JText::_('T3_OVERVIEW_CHECK_UPDATE'), 'updateChkComplete' => JText::_('T3_OVERVIEW_CHK_UPDATE_OK'), 'updateHasNew' => JText::_('T3_OVERVIEW_TPL_NEW'), 'updateCompare' => JText::_('T3_OVERVIEW_TPL_COMPARE'), 'switchResponsiveMode' => JText::_('T3_MSG_SWITCH_RESPONSIVE_MODE') ); //just in case if(!($params instanceof Registry)){ $params = new Registry; } //get extension id of framework and template $query = $db->getQuery(true); $query ->select('extension_id') ->from('#__extensions') ->where('(element='. $db->quote(T3_TEMPLATE) . ' AND type=' . $db->quote('template') . ') OR (element=' . $db->quote(T3_ADMIN) . ' AND type=' . $db->quote('plugin'). ')'); $db->setQuery($query); $results = $db->loadRowList(); $eids = array(); foreach ($results as $eid) { $eids[] = $eid[0]; } //check for version compatible if(version_compare(JVERSION, '3.0', 'ge')){ //JHtml::_('jquery.framework'); JHtml::_('bootstrap.framework'); } else { $jdoc->addStyleSheet(T3_ADMIN_URL . '/admin/bootstrap/css/bootstrap.css'); $jdoc->addScript(T3_ADMIN_URL . '/admin/js/jquery-1.x.min.js'); $jdoc->addScript(T3_ADMIN_URL . '/admin/bootstrap/js/bootstrap.js'); $jdoc->addScript(T3_ADMIN_URL . '/admin/js/jquery.noconflict.js'); } if(!$this->checkAssetsLoaded('chosen.css', '_styleSheets')){ $jdoc->addStyleSheet(T3_ADMIN_URL . '/admin/plugins/chosen/chosen.css'); } $jdoc->addStyleSheet(T3_ADMIN_URL . '/includes/depend/css/depend.css'); $jdoc->addStyleSheet(T3_URL . '/css/layout-preview.css'); $jdoc->addStyleSheet(T3_ADMIN_URL . '/admin/layout/css/layout.css'); if(file_exists(T3_TEMPLATE_PATH . '/admin/layout-custom.css')) { $jdoc->addStyleSheet(T3_TEMPLATE_URL . '/admin/layout-custom.css'); } $jdoc->addStyleSheet(T3_ADMIN_URL . '/admin/css/admin.css'); if(version_compare(JVERSION, '3.0', 'ge')){ $jdoc->addStyleSheet(T3_ADMIN_URL . '/admin/css/admin-j30.css'); if($input->get('file') && version_compare(JVERSION, '3.2', 'ge')){ $jdoc->addStyleSheet(T3_ADMIN_URL . '/admin/css/file-manager.css'); } } else { $jdoc->addStyleSheet(T3_ADMIN_URL . '/admin/css/admin-j25.css'); } if(!$this->checkAssetsLoaded('chosen.jquery.min.js', '_scripts')){ $jdoc->addScript(T3_ADMIN_URL . '/admin/plugins/chosen/chosen.jquery.min.js'); } $jdoc->addScript(T3_ADMIN_URL . '/includes/depend/js/depend.js'); $jdoc->addScript(T3_ADMIN_URL . '/admin/js/json2.js'); $jdoc->addScript(T3_ADMIN_URL . '/admin/js/jimgload.js'); $jdoc->addScript(T3_ADMIN_URL . '/admin/layout/js/layout.js'); if(version_compare(JVERSION, '4','lt')){ $jdoc->addScript(T3_ADMIN_URL . '/admin/js/admin.js'); }else{ $jdoc->addScript(T3_ADMIN_URL . '/admin/js/admin_j4.js'); } $jdoc->addScriptDeclaration ( ' T3Admin = window.T3Admin || {}; T3Admin.adminurl = \'' . JUri::getInstance()->toString() . '\'; T3Admin.t3adminurl = \'' . T3_ADMIN_URL . '\'; T3Admin.baseurl = \'' . JURI::base(true) . '\'; T3Admin.rooturl = \'' . JURI::root() . '\'; T3Admin.template = \'' . T3_TEMPLATE . '\'; T3Admin.templateid = \'' . Factory::getApplication()->input->get('id') . '\'; T3Admin.langs = ' . json_encode($langs) . '; T3Admin.devmode = ' . $params->get('devmode', 0) . '; T3Admin.themermode = ' . $params->get('themermode', 1) . '; T3Admin.eids = [' . implode(',', $eids) .']; T3Admin.telement = \'' . T3_TEMPLATE . '\'; T3Admin.felement = \'' . T3_ADMIN . '\'; T3Admin.jversion = \'' . jversion::MAJOR_VERSION . '\'; T3Admin.themerUrl = \'' . JUri::getInstance()->toString() . '&t3action=theme&t3task=thememagic' . '\'; T3Admin.megamenuUrl = \'' . JUri::getInstance()->toString() . '&t3action=megamenu&t3task=megamenu' . '\'; T3Admin.t3updateurl = \'' . JURI::base() . 'index.php?option=com_installer&view=update&task=update.ajax' . '\'; T3Admin.t3layouturl = \'' . JURI::base() . 'index.php?t3action=layout' . '\'; T3Admin.jupdateUrl = \'' . JURI::base() . 'index.php?option=com_installer&view=update' . '\';' ); // render admin // $this->_renderAdmin(); $this->_renderToolbar(); } public function addJSLang($key = '', $value = '', $overwrite = true){ if($key && $value && ($overwrite || !array_key_exists($key, $this->langs))){ $this->langs[$key] = $value ? $value : JText::_($key); } } /** * function loadParam * load and re-render parameters * * @return render success or not */ function _renderAdmin(){ return; $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 = simplexml_load_file($tplXml); $fxml = simplexml_load_file($frwXml); $db = Factory::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 = Factory::getSession(); $t3lock = $session->get('T3.t3lock', 'overview_params'); $session->set('T3.t3lock', null); $input = Factory::getApplication()->input; ob_start(); include $jtpl; $this->html['admin'] = ob_get_clean(); /* //search for global parameters $japp = Factory::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; } function _renderToolbar() { $t3toolbar = T3_ADMIN_PATH . '/admin/tpls/toolbar.php'; $input = Factory::getApplication()->input; if(file_exists($t3toolbar) && class_exists('JToolBar')){ //get the existing toolbar html jimport('joomla.language.help'); $params = T3::getTplParams(); $this->html['toolbar'] = JToolBar::getInstance('toolbar')->render(); $helpurl = JHelp::createURL($input->getCmd('view') == 'template' ? 'JHELP_EXTENSIONS_TEMPLATE_MANAGER_TEMPLATES_EDIT' : 'JHELP_EXTENSIONS_TEMPLATE_MANAGER_STYLES_EDIT'); $helpurl = htmlspecialchars($helpurl, ENT_QUOTES); //render our toolbar ob_start(); include $t3toolbar; $this->html['t3toolbar'] = ob_get_clean(); } } function replaceToolbar($body){ /* $t3toolbar = T3_ADMIN_PATH . '/admin/tpls/toolbar.php'; $input = Factory::getApplication()->input; if(file_exists($t3toolbar) && class_exists('JToolBar')){ //get the existing toolbar html jimport('joomla.language.help'); $params = T3::getTplParams(); $toolbar = JToolBar::getInstance('toolbar')->render(); $helpurl = JHelp::createURL($input->getCmd('view') == 'template' ? 'JHELP_EXTENSIONS_TEMPLATE_MANAGER_TEMPLATES_EDIT' : 'JHELP_EXTENSIONS_TEMPLATE_MANAGER_STYLES_EDIT'); $helpurl = htmlspecialchars($helpurl, ENT_QUOTES); //render our toolbar ob_start(); include $t3toolbar; $t3toolbar = ob_get_clean(); //replace it $body = str_replace($toolbar, $t3toolbar, $body); } */ //$body = str_replace($this->html['toolbar'], $this->html['t3toolbar'], $body); $body = str_replace('[[TOOLBAR]]', $this->html['t3toolbar'], $body); return $body; } function replaceDoctype($body){ return preg_replace('@<!DOCTYPE\s(.*?)>@', '<!DOCTYPE html>', $body); } function checkAssetsLoaded($pattern, $hash){ $doc = Factory::getDocument(); $hash = $doc->$hash; foreach ($hash as $path => $object) { if(strpos($path, $pattern) !== false){ return true; } } return false; } } ?>