/** * Render megamenu block * * @param string $position The position of the modules to render * @param array $params Associative array of values * @param string $content Module content * * @return string The output of the script * * @since 11.1 */ public function render($info = null, $params = array(), $content = null) { CANVAS::import('menu/canvasbootstrap'); // import the renderer $canvasapp = CANVAS::getApp(); $menutype = empty($params['menutype']) ? $canvasapp->getParam('mm_type', 'mainmenu') : $params['menutype']; JDispatcher::getInstance()->trigger('onCANVASBSMenu', array(&$menutype)); $menu = new CANVASBootstrap($menutype); return $menu->render(true); }
public function renders() { ob_start(); $path = CANVASPath::getPath('tpls/widgets/' . $this->name . '.php'); if ($path) { include $path; } else { ?> <div class="poweredby text-hide"> <a class="canvas-logo canvas-logo-color" href="http://themezart.com/canvas-framework" title="<?php echo JText::_('CANVAS_POWER_BY_TEXT'); ?> " target="_blank" <?php echo method_exists('CANVAS', 'isHome') && CANVAS::isHome() ? '' : 'rel="nofollow"'; ?> ><?php echo JText::_('CANVAS_POWER_BY_HTML'); ?> </a> </div> <?php
/** * Render body class of current page * * @param string $position The position of the modules to render * @param array $params Associative array of values * @param string $content Module content * * @return string The output of the script * * @since 11.1 */ public function render($info, $params = array(), $content = null) { $input = JFactory::getApplication()->input; $canvastpl = CANVAS::getApp(); $pageclass = array(); if ($input->getCmd('option', '')) { $pageclass[] = $input->getCmd('option', ''); } if ($input->getCmd('view', '')) { $pageclass[] = 'view-' . $input->getCmd('view', ''); } if ($input->getCmd('layout', '')) { $pageclass[] = 'layout-' . $input->getCmd('layout', ''); } if ($input->getCmd('task', '')) { $pageclass[] = 'task-' . $input->getCmd('task', ''); } if ($input->getCmd('Itemid', '')) { $pageclass[] = 'itemid-' . $input->getCmd('Itemid', ''); } $menu = JFactory::getApplication()->getMenu(); if ($menu) { $active = $menu->getActive(); $default = $menu->getDefault(); if ($active) { if ($default && $active->id == $default->id) { $pageclass[] = 'home'; } if ($active->params && $active->params->get('pageclass_sfx')) { $pageclass[] = $active->params->get('pageclass_sfx'); } } } $pageclass[] = 'j' . str_replace('.', '', number_format((double) JVERSION, 1, '.', '')); $pageclass = array_unique(array_merge($pageclass, $canvastpl->getPageclass())); JDispatcher::getInstance()->trigger('onCANVASBodyClass', array(&$pageclass)); return implode(' ', $pageclass); }
/** * set caching template and its parameters * @param string $name * @param string $params */ public static function setTemplate($name = '', $params = '') { if (!self::$tmpl) { self::$tmpl = new stdClass(); } if ($name && $params) { self::$tmpl->template = $name; self::$tmpl->params = $params; } }
function getWidget($tpl) { CANVAS::import('core/widget'); CANVAS::import('widgets/' . $tpl); $objectClass = 'CANVASTemplateWidget' . ucfirst($tpl); $object = new $objectClass($this->_tpl->params); return $object->renders(); }
/** * * Show thememagic form */ public static function megamenu() { $tplparams = CANVAS::getTplParams(); $url = JFactory::getURI(); $url->delVar('canvasaction'); $url->delVar('canvastask'); $referer = $url->toString(); $template = CANVAS_TEMPLATE; $styleid = JFactory::getApplication()->input->getCmd('id'); $mm_type = $tplparams && $tplparams instanceof JRegistry ? $tplparams->get('mm_type', '') : null; //Keepalive $config = JFactory::getConfig(); $lifetime = $config->get('lifetime') * 60000; $refreshTime = $lifetime <= 60000 ? 30000 : $lifetime - 60000; // Refresh time is 1 minute less than the liftime assined in the configuration.php file. // The longest refresh period is one hour to prevent integer overflow. if ($refreshTime > 3600000 || $refreshTime <= 0) { $refreshTime = 3600000; } //check config $currentconfig = $tplparams && $tplparams instanceof JRegistry ? $tplparams->get('mm_config', '') : null; if (!$currentconfig) { $currentconfig = '"{}"'; } include CANVAS_ADMIN_PATH . '/admin/megamenu/megamenu.tpl.php'; exit; }
/** * Method to get the field input markup. * * @return string The field input markup. */ function getInput() { $this->loadAsset(); CANVAS::import('admin/layout'); return $this->getPositions(); }
public static function display() { $app = JFactory::getApplication(); $input = $app->input; if (!$app->isAdmin()) { $tpl = $app->getTemplate(true); // get template name if ($input->getCmd('canvasaction') && ($styleid = $input->getInt('styleid', '')) && $tpl->id != $styleid) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('template, params'); $query->from('#__template_styles'); $query->where('client_id = 0'); $query->where('id = ' . $styleid); $db->setQuery($query); $tpl = $db->loadObject(); if ($tpl) { $registry = new JRegistry(); $registry->loadString($tpl->params); $tpl->params = $registry; } if (!$tpl) { die(json_encode(array('error' => JText::_('CANVAS_MSG_UNKNOW_ACTION')))); } } } else { $tplid = $input->getCmd('view') == 'style' ? $input->getCmd('id', 0) : false; if (!$tplid) { die(json_encode(array('error' => JText::_('CANVAS_MSG_UNKNOW_ACTION')))); } $cache = JFactory::getCache('com_templates', ''); if (!($templates = $cache->get('canvastpl'))) { // Load styles $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('id, home, template, s.params'); $query->from('#__template_styles as s'); $query->where('s.client_id = 0'); $query->where('e.enabled = 1'); $query->leftJoin('#__extensions as e ON e.element=s.template AND e.type=' . $db->quote('template') . ' AND e.client_id=s.client_id'); $db->setQuery($query); $templates = $db->loadObjectList('id'); foreach ($templates as &$template) { $registry = new JRegistry(); $registry->loadString($template->params); $template->params = $registry; } $cache->store($templates, 'canvastpl'); } if (isset($templates[$tplid])) { $tpl = $templates[$tplid]; } else { $tpl = $templates[0]; } } //load language for template JFactory::getLanguage()->load('tpl_' . CANVAS_TEMPLATE, JPATH_SITE); //clean all unnecessary datas if (ob_get_length()) { @ob_end_clean(); } $canvasapp = CANVAS::getSite($tpl); $layout = $canvasapp->getLayout(); $canvasapp->loadLayout($layout); $lbuffer = ob_get_clean(); die($lbuffer); }
/** * @param $js * @return string */ public static function minifyJs($js) { CANVAS::import('minify/' . self::$jstool); return call_user_func_array(array(self::$jstools[self::$jstool], 'minify'), array($js)); }
<?php /** *------------------------------------------------------------------------------ * @package CANVAS Framework for Joomla! *------------------------------------------------------------------------------ * @copyright Copyright (C) 2004-2013 ThemezArt.com. All Rights Reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @authors ThemezArt * & t3-framework.org as base version * @Google group: https://groups.google.com/forum/#!forum/canvasfw * @Link: http://themezart.com/canvas-framework *------------------------------------------------------------------------------ */ if (!class_exists('CANVASMenuMegamenuTpl', false)) { CANVAS::import('menu/megamenu.tpl'); } if (is_file(CANVAS_TEMPLATE_PATH . '/html/megamenu.php')) { require_once CANVAS_TEMPLATE_PATH . '/html/megamenu.php'; } class CANVASMenuMegamenu { /** * Internal variables */ protected $_items = array(); protected $children = array(); protected $settings = null; protected $params = null; protected $menu = ''; protected $active_id = 0;
function replaceToolbar($body) { $canvastoolbar = CANVAS_ADMIN_PATH . '/admin/tpls/toolbar.php'; $input = JFactory::getApplication()->input; if (file_exists($canvastoolbar) && class_exists('JToolBar')) { //get the existing toolbar html jimport('joomla.language.help'); $params = CANVAS::getTplParams(); $toolbar = JToolBar::getInstance('toolbar')->render('toolbar'); $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 $canvastoolbar; $canvastoolbar = ob_get_clean(); //replace it $body = str_replace($toolbar, $canvastoolbar, $body); } return $body; }
public static function megamenu() { self::cloneParam('canvasmenu'); JFactory::getLanguage()->load('tpl_' . CANVAS_TEMPLATE, JPATH_SITE); if (!defined('CANVAS')) { die(json_encode(array('error' => JText::_('CANVAS_MSG_PLUGIN_NOT_READY')))); } $action = JFactory::getApplication()->input->get('canvastask', ''); if (empty($action)) { die(json_encode(array('error' => JText::_('CANVAS_MSG_UNKNOW_ACTION')))); } if ($action != 'display') { $user = JFactory::getUser(); if (!$user->authorise('core.manage', 'com_templates')) { die(json_encode(array('error' => JText::_('CANVAS_MSG_NO_PERMISSION')))); } } CANVAS::import('admin/megamenu'); if (method_exists('CANVASAdminMegamenu', $action)) { CANVASAdminMegamenu::$action(); exit; } else { die(json_encode(array('error' => JText::_('CANVAS_MSG_UNKNOW_ACTION')))); } }
public static function addAssets() { $japp = JFactory::getApplication(); $user = JFactory::getUser(); //do nothing when site is offline and user has not login (the offline page is only show login form) if ($japp->getCfg('offline') && !$user->authorise('core.login.offline')) { return; } $jdoc = JFactory::getDocument(); $params = $japp->getTemplate(true)->params; if (defined('CANVAS_THEMER') && $params->get('themermode', 1)) { $jdoc->addStyleSheet(CANVAS_URL . '/css/thememagic.css'); $jdoc->addScript(CANVAS_URL . '/js/thememagic.js'); $theme = $params->get('theme'); $params = new JRegistry(); $themeinfo = new stdClass(); if ($theme) { $themepath = CANVAS_TEMPLATE_PATH . '/less/themes/' . $theme; if (file_exists($themepath . '/variables-custom.less')) { if (!class_exists('JRegistryFormatLESS')) { include_once CANVAS_ADMIN_PATH . '/includes/format/less.php'; } //default variables $varfile = CANVAS_TEMPLATE_PATH . '/less/variables.less'; if (file_exists($varfile)) { $params->loadString(JFile::read($varfile), 'LESS'); //get all less files in "theme" folder $others = JFolder::files($themepath, '.less'); foreach ($others as $other) { //get those developer custom values if ($other == 'variables.less') { $devparams = new JRegistry(); $devparams->loadString(JFile::read($themepath . '/variables.less'), 'LESS'); //overwrite the default variables foreach ($devparams->toArray() as $key => $value) { $params->set($key, $value); } } //ok, we will import it later if ($other != 'variables-custom.less' && $other != 'variables.less') { $themeinfo->{$other} = true; } } //load custom variables $cparams = new JRegistry(); $cparams->loadString(JFile::read($themepath . '/variables-custom.less'), 'LESS'); //and overwrite those defaults variables foreach ($cparams->toArray() as $key => $value) { $params->set($key, $value); } } } } $cache = array(); // a little security if ($user->authorise('core.manage', 'com_templates') || isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], JUri::base() . 'administrator') !== false) { CANVAS::import('core/path'); $baseurl = JUri::base(); //should we provide a list of less path foreach (array(CANVAS_TEMPLATE_PATH . '/less', CANVAS_PATH . '/bootstrap/less', CANVAS_PATH . '/less') as $lesspath) { if (is_dir($lesspath)) { $lessfiles = JFolder::files($lesspath, '.less', true, true); if (is_array($lessfiles)) { foreach ($lessfiles as $less) { $path = ltrim(str_replace(array(JPATH_ROOT, '\\'), array('', '/'), $less), '/'); $path = CANVASPath::cleanPath($path); $fullurl = $baseurl . preg_replace('@(\\+)|(/+)@', '/', $path); $cache[$fullurl] = JFile::read($less); } } } } } //workaround for bootstrap icon path $sparams = new JRegistry(); if (defined('CANVAS_BASE_RSP_IN_CLASS') && CANVAS_BASE_RSP_IN_CLASS) { $sparams->set('icon-font-path', '"' . JUri::base() . 'plugins/system/canvas/base-bs3/bootstrap/fonts/"'); } $jdoc->addScriptDeclaration(' var CANVASTheme = window.CANVASTheme || {}; CANVASTheme.vars = ' . json_encode($params->toArray()) . '; CANVASTheme.svars = ' . json_encode($sparams->toArray()) . '; CANVASTheme.others = ' . json_encode($themeinfo) . '; CANVASTheme.theme = \'' . $theme . '\'; CANVASTheme.template = \'' . CANVAS_TEMPLATE . '\'; CANVASTheme.base = \'' . JURI::base() . '\'; CANVASTheme.cache = ' . json_encode($cache) . '; if(typeof less != \'undefined\'){ //we need to build one - cause the js will have unexpected behavior try{ if(window.parent != window && window.parent.CANVASTheme && window.parent.CANVASTheme.applyLess){ window.parent.CANVASTheme.applyLess(true); } else { less.refresh(); } } catch(e){ } }'); } }
public static function afterInit() { $app = JFactory::getApplication(); $input = $app->input; $tplparams = $app->getTemplate(true)->params; if (!$app->isAdmin()) { // check if need update megamenu configuration if ($tplparams->get('mm_config_needupdate')) { CANVAS::import('menu/megamenu'); CANVAS::import('admin/megamenu'); $currentconfig = @json_decode($tplparams->get('mm_config', ''), true); if (!is_array($currentconfig)) { $currentconfig = array(); } else { $menuassoc = CANVASAdminMegamenu::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 CANVASMenuMegamenu($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); // 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 CANVAS::setTemplate(CANVAS_TEMPLATE, $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(CANVAS_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->execute(); } // force reload cache template $cache = JFactory::getCache('com_templates', ''); $cache->clean(); } } }
<?php /** *------------------------------------------------------------------------------ * @package CANVAS Framework for Joomla! *------------------------------------------------------------------------------ * @copyright Copyright (C) 2004-2013 ThemezArt.com. All Rights Reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @authors ThemezArt * & t3-framework.org as base version * @Link: http://themezart.com/canvas-framework *------------------------------------------------------------------------------ */ CANVAS::import('admin/layout'); ?> <!-- LAYOUT CONFIGURATION PANEL --> <div id="canvas-admin-layout" class="canvas-admin-layout hide"> <div class="canvas-admin-inline-nav clearfix"> <div class="canvas-admin-layout-row-mode clearfix"> <ul class="canvas-admin-layout-modes nav nav-tabs"> <li class="canvas-admin-layout-mode-structure active"><a href="" title="<?php echo JText::_('CANVAS_LAYOUT_MODE_STRUCTURE'); ?> "><?php echo JText::_('CANVAS_LAYOUT_MODE_STRUCTURE'); ?> </a></li> <li class="canvas-admin-layout-mode-layout"><a href="" title="<?php echo JText::_('CANVAS_LAYOUT_MODE_LAYOUT'); ?>
/** * Render megamenu block, then push the output into megamenu renderer to display * * @param string $position The position of the modules to render * @param array $params Associative array of values * @param string $content Module content * * @return string The output of the script * * @since 11.1 */ public function render($info = null, $params = array(), $content = null) { CANVAS::import('menu/megamenu'); $canvasapp = CANVAS::getApp(); //we will check from params $menutype = empty($params['menutype']) ? empty($params['name']) ? $canvasapp->getParam('mm_type', 'mainmenu') : $params['name'] : $params['menutype']; $currentconfig = json_decode($canvasapp->getParam('mm_config', ''), true); //force to array if (!is_array($currentconfig)) { $currentconfig = (array) $currentconfig; } //get user access levels $viewLevels = JFactory::getUser()->getAuthorisedViewLevels(); $mmkey = $menutype; $mmconfig = array(); if (!empty($currentconfig)) { //find best fit configuration based on view level $vlevels = array_merge($viewLevels); if (is_array($vlevels) && in_array(3, $vlevels)) { //we assume, if a user is special, they should be registered also $vlevels[] = 2; } $vlevels = array_unique($vlevels); rsort($vlevels); if (!is_array($vlevels)) { $vlevels = array(); } $vlevels[] = ''; // extend a blank, default key // check if available configuration for language override $langcode = JFactory::getDocument()->language; $shortlangcode = substr($langcode, 0, 2); $types = array($menutype . '-' . $langcode, $menutype . '-' . $shortlangcode, $menutype); foreach ($types as $type) { foreach ($vlevels as $vlevel) { $key = $type . ($vlevel !== '' ? '-' . $vlevel : ''); if (isset($currentconfig[$key])) { $mmkey = $key; $menutype = $type; break 2; } else { if (isset($currentconfig[$type])) { $mmkey = $menutype = $type; break 2; } } } } if (isset($currentconfig[$mmkey])) { $mmconfig = $currentconfig[$mmkey]; if (!is_array($mmconfig)) { $mmconfig = array(); } } } JDispatcher::getInstance()->trigger('onCANVASMegamenu', array(&$menutype, &$mmconfig, &$viewLevels)); $mmconfig['access'] = $viewLevels; $menu = new CANVASMenuMegamenu($menutype, $mmconfig, $canvasapp->_tpl->params); $canvasapp->setBuffer($menu->render(true), 'megamenu', empty($params['name']) ? null : $params['name'], null); return ''; }
/** *------------------------------------------------------------------------------ * @package CANVAS Framework for Joomla! *------------------------------------------------------------------------------ * @copyright Copyright (C) 2004-2013 ThemezArt.com. All Rights Reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @authors ThemezArt * & t3-framework.org as base version * @Google group: https://groups.google.com/forum/#!forum/canvasfw * @Link: http://themezart.com/canvas-framework *------------------------------------------------------------------------------ */ // No direct access defined('_JEXEC') or die; CANVAS::import('core/template'); jimport('joomla.utilities.utility'); /** * CANVASTemplate class provides extended template tools used for CANVAS framework * * @package CANVAS */ class CANVASTemplateLayout extends CANVASTemplate { protected $_block = null; /** * Class constructor * @param object $template Current template instance */ public function __construct($template = null) {
/** *------------------------------------------------------------------------------ * @package CANVAS Framework for Joomla! *------------------------------------------------------------------------------ * @copyright Copyright (C) 2004-2013 ThemezArt.com. All Rights Reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @authors ThemezArt * & t3-framework.org as base version * @Google group: https://groups.google.com/forum/#!forum/canvasfw * @Link: http://themezart.com/canvas-framework *------------------------------------------------------------------------------ */ // No direct access defined('_JEXEC') or die; CANVAS::import('lessphp/less/less'); /** * CANVASLessCompiler class compile less * * @package CANVAS */ class CANVASLessCompiler { public static function compile($source, $path, $todir, $importdirs) { $parser = new Less_Parser(); $parser->SetImportDirs($importdirs); $parser->parse($source, CANVASLess::relativePath($todir, dirname($path)) . basename($path)); $output = $parser->getCss(); return $output; }
/** * Implement event onGetLayoutPath to return the layout which override by CANVAS & CANVAS 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 CANVAS themes if (defined('CANVAS_PLUGIN') && CANVAS::detect()) { CANVAS::import('core/path'); $tPath = CANVASPath::getPath('html/' . $module . '/' . $layout . '.php'); if ($tPath) { return $tPath; } } return false; }
/** * Compile LESS to CSS for a specific theme or all themes * @param string $theme the specific theme */ public static function compileAll($theme = null) { $params = CANVAS::getTplParams(); JFactory::getApplication()->setUserState('current_template_params', $params); // get files need to compile $files = array(); $lesspath = CANVAS_TEMPLATE_REL . '/less/'; $csspath = CANVASPath::getLocalPath('css/', true); $fullpath = JPath::clean(JPATH_ROOT . '/' . $lesspath); // canvas core plugin files $canvasfiles = array('frontend-edit', 'legacy-grid', 'legacy-navigation', 'megamenu', 'off-canvas'); // all less file in less folders $lessFiles = JFolder::files($fullpath, '.less', true, true, array('rtl', 'themes', '.svn', 'CVS', '.DS_Store', '__MACOSX')); $lessContent = ''; $relLessFiles = array(); foreach ($lessFiles as $file) { $lessContent .= JFile::read($file) . "\n"; $relLessFiles[] = ltrim(str_replace($fullpath, '', $file), '/\\'); } $lessFiles = $relLessFiles; // get files imported in this list if (preg_match_all('#^\\s*@import\\s+"([^"]*)"#im', $lessContent, $matches)) { foreach ($lessFiles as $f) { if (!in_array($f, $matches[1])) { $files[] = substr($f, 0, -5); } } //build canvasfiles foreach ($canvasfiles as $key => $file) { if (in_array($file, $files)) { unset($canvasfiles[$key]); } } } // build default if (!$theme || $theme == 'default') { self::buildVars('', 'ltr'); // compile all less files in template "less" folder foreach ($files as $file) { self::compileCss($lesspath . $file . '.less', $csspath . $file . '.css'); } // if the template not overwrite the canvas core, we will compile those missing files if (!empty($canvasfiles)) { foreach ($canvasfiles as $file) { self::compileCss(CANVAS_REL . '/less/' . $file . '.less', $csspath . $file . '.css'); } } } // build themes if (!$theme) { // get themes $themes = JFolder::folders(JPATH_ROOT . '/' . $lesspath . '/themes'); } else { $themes = $theme != 'default' ? (array) $theme : array(); } if (is_array($themes)) { foreach ($themes as $t) { self::buildVars($t, 'ltr'); // compile foreach ($files as $file) { self::compileCss($lesspath . $file . '.less', $csspath . 'themes/' . $t . '/' . $file . '.css'); } if (!empty($canvasfiles)) { foreach ($canvasfiles as $file) { self::compileCss(CANVAS_REL . '/less/' . $file . '.less', $csspath . 'themes/' . $t . '/' . $file . '.css'); } } } } // compile rtl css if ($params && $params->get('build_rtl', 0)) { // compile default if (!$theme || $theme == 'default') { self::buildVars('', 'rtl'); // compile foreach ($files as $file) { self::compileCss($lesspath . $file . '.less', $csspath . 'rtl/' . $file . '.css'); } if (!empty($canvasfiles)) { foreach ($canvasfiles as $file) { self::compileCss(CANVAS_REL . '/less/' . $file . '.less', $csspath . 'rtl/' . $file . '.css'); } } } if (is_array($themes)) { // rtl for themes foreach ($themes as $t) { self::buildVars($t, 'rtl'); // compile foreach ($files as $file) { self::compileCss($lesspath . $file . '.less', $csspath . 'rtl/' . $t . '/' . $file . '.css'); } if (!empty($canvasfiles)) { foreach ($canvasfiles as $file) { self::compileCss(CANVAS_REL . '/less/' . $file . '.less', $csspath . 'rtl/' . $t . '/' . $file . '.css'); } } } } } }
/** * Default fallback function if CC API fails * @param string $js * @return string */ protected function _fallback($js) { //CANVAS Framework CANVAS::import('minify/jsmin'); return JSMin::minify($js); }
/** *------------------------------------------------------------------------------ * @package CANVAS Framework for Joomla! *------------------------------------------------------------------------------ * @copyright Copyright (C) 2004-2013 ThemezArt.com. All Rights Reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @authors ThemezArt * & t3-framework.org as base version * @Google group: https://groups.google.com/forum/#!forum/canvasfw * @Link: http://themezart.com/canvas-framework *------------------------------------------------------------------------------ */ // No direct access defined('_JEXEC') or die; CANVAS::import('lessphp/lessc.inc'); /** * CANVASLessCompiler class compile less * * @package CANVAS */ class CANVASLessCompiler { public static function compile($source, $path, $todir, $importdirs) { // call Less to compile $parser = new lessc(); $parser->setImportDir(array_keys($importdirs)); $parser->setPreserveComments(true); $output = $parser->compile($source); // update url
<?php /** *------------------------------------------------------------------------------ * @package CANVAS Framework for Joomla! *------------------------------------------------------------------------------ * @copyright Copyright (C) 2004-2013 ThemezArt.com. All Rights Reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @authors ThemezArt * & t3-framework.org as base version * @Google group: https://groups.google.com/forum/#!forum/canvasfw * @Link: http://themezart.com/canvas-framework *------------------------------------------------------------------------------ */ if (!class_exists('CANVASBootstrapTpl', false)) { CANVAS::import('menu/canvasbootstrap.tpl'); } class CANVASBootstrap { /** * Internal variables */ protected $menutype; protected $menu; /** * @param string $menutype */ function __construct($menutype = 'mainmenu') { $this->menutype = $menutype; $this->menu = '';