public static function display() { Plazart::import('menu/megamenu'); $input = JFactory::getApplication()->input; $menutype = $input->get('plazartmenu', 'mainmenu'); $tplparams = $input->get('tplparams', '', 'raw'); // $currentconfig = $tplparams instanceof JRegistry ? json_decode($tplparams->get('mm_config', ''), true) : null; // $mmconfig = ($currentconfig && isset($currentconfig[$menutype])) ? $currentconfig[$menutype] : array(); // $mmconfig['editmode'] = true; //accessLevel $accessLevel = array(); $plazartacl = (int) $input->get('plazartacl', 6); for ($i = 1; $i <= $plazartacl; $i++) { $accessLevel[] = $i; } $accessLevel = array_unique($accessLevel); //languages $languages = array(trim($input->get('plazartlang', '*'))); if ($languages[0] != '*') { $languages[] = '*'; } //check config $currentconfig = $tplparams instanceof JRegistry ? json_decode($tplparams->get('mm_config', ''), true) : null; $mmkey = $menutype . ($plazartacl == 1 ? '' : '-' . $plazartacl); $mmconfig = array(); if ($currentconfig) { for ($i = $plazartacl; $i >= 1; $i--) { $tmmkey = $menutype . ($i == 1 ? '' : '-' . $i); if (isset($currentconfig[$tmmkey])) { $mmconfig = $currentconfig[$tmmkey]; break; } } } if (!is_array($mmconfig)) { $mmconfig = array(); } $mmconfig['editmode'] = true; $mmconfig['access'] = $accessLevel; $mmconfig['language'] = $languages; $menu = new PlazartMenuMegamenu($menutype, $mmconfig); $buffer = $menu->render(true); // replace image path $base = JURI::base(true) . '/'; $protocols = '[a-zA-Z0-9]+:'; //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by : $regex = '#(src)="(?!/|' . $protocols . '|\\#|\')([^"]*)"#m'; $buffer = preg_replace($regex, "\$1=\"{$base}\$2\"", $buffer); //remove invisibile content $buffer = preg_replace(array('@<style[^>]*?>.*?</style>@siu', '@<script[^>]*?.*?</script>@siu'), array('', ''), $buffer); echo $buffer; }
function onExtensionAfterSave($option, $data) { if (Plazart::detect() && $option == 'com_templates.style' && !empty($data->id)) { //get new params value $japp = JFactory::getApplication(); $params = new JRegistry(); $params->loadString($data->params); $oparams = $japp->getUserState('oparams'); //check for changed params $pchanged = array(); foreach ($oparams as $oparam) { if ($params->get($oparam['name']) != $oparam['value']) { $pchanged[] = $oparam['name']; } } //if we have any changed, we will update to global if (count($pchanged)) { //g et all other styles that have thesame template $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select('*')->from('#__template_styles')->where('template=' . $db->quote($data->template)); $db->setQuery($query); $themes = $db->loadObjectList(); //update all global parameters foreach ($themes as $theme) { $registry = new JRegistry(); $registry->loadString($theme->params); foreach ($pchanged as $pname) { $registry->set($pname, $params->get($pname)); //overwrite with new value } $query = $db->getQuery(true); $query->update('#__template_styles')->set('params =' . $db->quote($registry->toString()))->where('id =' . (int) $theme->id)->where('id <>' . (int) $data->id); $db->setQuery($query); $db->query(); } } } }
<?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 *------------------------------------------------------------------------------ */ Plazart::import('menu/megamenu.tpl'); class PlazartMenuMegamenu { protected $children = array(); protected $_items = array(); protected $settings = null; protected $params = null; protected $menu = ''; protected $active_id = 0; protected $active_tree = array(); protected $top_level_caption = false; function __construct($menutype = 'mainmenu', $settings = array(), $params = null) { $app = JFactory::getApplication(); $menu = $app->getMenu('site'); $attributes = array('menutype'); $values = array($menutype);
public static function OptimizeCode() { Plazart::import('core/scriptsdown'); return new PlazartScriptsDown(); }
/** * @param $js * @return string */ public static function minifyJs($js) { Plazart::import('minify/' . self::$jstool); return call_user_func_array(array(self::$jstools[self::$jstool], 'minify'), array($js)); }
public static function afterInit() { $app = JFactory::getApplication(); $input = $app->input; if (!$app->isAdmin()) { // check if need update megamenu configuration if ($app->getTemplate(true)->params->get('mm_config_needupdate')) { Plazart::import('menu/megamenu'); $currentconfig = json_decode($app->getTemplate(true)->params->get('mm_config'), true); if (!is_array($currentconfig)) { $currentconfig = array(); } foreach ($currentconfig as $menutype => $mmconfig) { if (!is_array($mmconfig)) { continue; } $menu = new PlazartMenuMegamenu($menutype, $mmconfig); $children = $menu->get('children'); foreach ($mmconfig as $item => $setting) { if (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++) { // foreach ($sub['rows'] as $row) { for ($k = 0; $k < count($sub['rows'][$j]); $k++) { // foreach ($row as $col) { 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[$menutype] = $mmconfig; } // update megamenu back to other template styles parameter $mm_config = json_encode($currentconfig); // update megamenu back to current template style parameter $params = $app->getTemplate(true)->params; $params->set('mm_config', $mm_config); $app->setTemplate(PLAZART_TEMPLATE, $params); if ($input->get('tplparams')) { $input->set('tplparams', $app->getTemplate(true)->params); } //get all other styles that have the same template $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select('*')->from('#__template_styles')->where('template=' . $db->quote(PLAZART_TEMPLATE))->where('client_id=0'); $db->setQuery($query); $themes = $db->loadObjectList(); //update all global parameters foreach ($themes as $theme) { $registry = new JRegistry(); $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->query(); } // force reload cache template $cache = JFactory::getCache('com_templates', ''); $cache->clean(); } } }
public static function replaceurl($matches) { global $src_url; $url = str_replace(array('"', '\''), '', $matches[1]); $url = Plazart::cleanPath($src_url . '/' . $url); return "url('{$url}')"; }
/** * Update head - detect if devmode or themermode is enabled and less file existed, use less file instead of css */ function updateHead() { // As Joomla 3.0 bootstrap is buggy, we will not use it // We also prevent both Joomla bootstrap and Plazart bootsrap are loaded $plazartbootstrap = false; $jabootstrap = false; $legacy = $this->getParam('bootstrapversion', 3) == 3 ? '' : '/legacy'; if (version_compare(JVERSION, '3.0', 'ge')) { $doc = JFactory::getDocument(); $scripts = array(); foreach ($doc->_scripts as $url => $script) { if (strpos($url, PLAZART_URL . '/bootstrap' . $legacy . '/js/bootstrap.min.js') !== false || strpos($url, PLAZART_TEMPLATE_URL . '/bootstrap' . $legacy . '/js/bootstrap.min.js') !== false) { $plazartbootstrap = true; if ($jabootstrap) { //we already have the Joomla bootstrap and we also replace to Plazart bootstrap continue; } } if (preg_match('@media/jui/js/bootstrap(.min)?.js@', $url)) { if ($plazartbootstrap) { //we have Plazart bootstrap, no need to add Joomla bootstrap continue; } else { $scripts[PLAZART_URL . '/bootstrap' . $legacy . '/js/bootstrap.min.js'] = $script; } $jabootstrap = true; } else { $scripts[$url] = $script; } } $doc->_scripts = $scripts; } // end update javascript $minify = $this->getParam('minify', 0); $minifyjs = $this->getParam('minify_js', 0); $devmode = $this->getParam('devmode', 0); //only check for minify if devmode is disabled if (!$devmode && ($minify || $minifyjs)) { Plazart::import('core/minify'); if ($minify) { PlazartMinify::optimizecss($this); } if ($minifyjs) { PlazartMinify::optimizejs($this); } } }
public static function unittest() { $app = JFactory::getApplication(); $tpl = $app->getTemplate(true); $plazartapp = Plazart::getApp($tpl); $layout = JFactory::getApplication()->input->getCmd('layout', 'default'); ob_start(); $plazartapp->loadLayout($layout); ob_clean(); echo "Positions for layout [{$layout}]: <br />"; var_dump($plazartapp->getPositions()); }
<?php /** * Plazart Framework * Author: Sonle * Version: 4.3 * @copyright Copyright (C) 2012 - 2015 TemPlaza.com. All rights reserved. * @license GNU General Public License version 2 or later */ // No direct access. defined('_JEXEC') or die; //check if plazart plugin is existed if (!defined('PLAZART')) { die(JText::_('Plazart framework does not ready! Please enable Plazart plugin system!')); // throw new Exception('Plazart framework not ready! Please install plazart plugin system!'); } // include framework classes and files $plazart = Plazart::getApp($this); // get configured layout $layout = $plazart->getLayout(); $plazart->loadLayout($layout);