/**
  * 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);
 }
Exemplo n.º 2
0
 public static function display()
 {
     CANVAS::import('menu/megamenu');
     $input = JFactory::getApplication()->input;
     //params
     $tplparams = CANVAS::getTplParams();
     //menu type
     $menutype = $input->get('canvasmenu', 'mainmenu');
     //accessLevel
     $canvasacl = (int) $input->get('canvasacl', 1);
     $accessLevel = array(1, $canvasacl);
     if (in_array(3, $accessLevel)) {
         $accessLevel[] = 2;
     }
     $accessLevel = array_unique($accessLevel);
     sort($accessLevel);
     //languages
     $languages = array(trim($input->get('canvaslang', '*')));
     if ($languages[0] != '*') {
         $languages[] = '*';
     }
     //check config
     $currentconfig = $tplparams instanceof JRegistry ? json_decode($tplparams->get('mm_config', ''), true) : null;
     $mmkey = $menutype . ($canvasacl == 1 ? '' : '-' . $canvasacl);
     $mmconfig = array();
     if ($currentconfig) {
         for ($i = $canvasacl; $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;
     //build the menu
     $menu = new CANVASMenuMegamenu($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);
     //output the megamenu key to save
     echo $buffer . '<input id="megamenu-key" type="hidden" name="mmkey" value="' . $mmkey . '"/>';
 }
Exemplo n.º 3
0
/** 
 *------------------------------------------------------------------------------
 * @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;
    }
Exemplo n.º 4
0
 /**
  * function loadParam
  * load and re-render parameters
  *
  * @return render success or not
  */
 function renderAdmin()
 {
     $frwXml = CANVAS_ADMIN_PATH . '/' . CANVAS_ADMIN . '.xml';
     $tplXml = CANVAS_TEMPLATE_PATH . '/templateDetails.xml';
     $cusXml = CANVASPath::getPath('etc/assets.xml');
     $jtpl = CANVAS_ADMIN_PATH . '/admin/tpls/default.php';
     if (file_exists($tplXml) && file_exists($jtpl)) {
         CANVAS::import('depend/canvasform');
         //get the current joomla default instance
         $form = JForm::getInstance('com_templates.style', 'style', array('control' => 'jform', 'load_data' => true));
         //wrap
         $form = new CANVASForm($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(CANVAS_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
         CANVASBot::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(CANVAS_TEMPLATE));
         $db->setQuery($query);
         $styles = $db->loadObjectList();
         foreach ($styles as $key => &$style) {
             $style->title = ucwords(str_replace('_', ' ', $style->title));
         }
         $session = JFactory::getSession();
         $canvaslock = $session->get('CANVAS.canvaslock', 'overview_params');
         $session->set('CANVAS.canvaslock', 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;
 }
Exemplo n.º 5
0
 function getWidget($tpl)
 {
     CANVAS::import('core/widget');
     CANVAS::import('widgets/' . $tpl);
     $objectClass = 'CANVASTemplateWidget' . ucfirst($tpl);
     $object = new $objectClass($this->_tpl->params);
     return $object->renders();
 }
 /**
  * Method to get the field input markup.
  *
  * @return  string  The field input markup.
  */
 function getInput()
 {
     $this->loadAsset();
     CANVAS::import('admin/layout');
     return $this->getPositions();
 }
Exemplo n.º 7
0
<?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;
Exemplo n.º 8
0
 /**
  * @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));
 }
Exemplo n.º 9
0
 /**
  * get CANVASTemplate object for frontend
  * @param $tpl
  * @return bool
  */
 public static function getSite($tpl)
 {
     //when on site, the JDocumentHTML parameter must be pass
     if (empty($tpl)) {
         return false;
     }
     $type = 'Template' . JFactory::getApplication()->input->getCmd('canvastp', '');
     CANVAS::import('core/' . $type);
     // create global canvas template object
     $class = 'CANVAS' . $type;
     return new $class($tpl);
 }
Exemplo n.º 10
0
    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){

					}
				}');
        }
    }
Exemplo n.º 11
0
 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();
         }
     }
 }
Exemplo n.º 12
0
 /**
  * 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 '';
 }
Exemplo n.º 13
0
/**
 *------------------------------------------------------------------------------
 * @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)
    {
Exemplo n.º 14
0
<?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');
?>
Exemplo n.º 15
0
 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'))));
     }
 }
Exemplo n.º 16
0
 /**
  * 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;
 }
Exemplo n.º 17
0
 /**
  * @param   string  $path    file path of less file to compile
  * @param   string  $topath  file path of output css file
  * @return  bool|mixed       compile result or the css compiled content
  */
 public static function compileCss($path, $topath = '', $split = false, $list = null)
 {
     $fromdir = dirname($path);
     $app = JFactory::getApplication();
     $is_rtl = $app->getUserState('current_direction') == 'rtl';
     if (empty($list)) {
         $list = self::parse($path);
     }
     if (empty($list)) {
         return false;
     }
     // join $list
     $content = '';
     $importdirs = array();
     $todir = $topath ? dirname($topath) : $fromdir;
     if (!is_dir(JPATH_ROOT . '/' . $todir)) {
         JFolder::create(JPATH_ROOT . '/' . $todir);
     }
     $importdirs[JPATH_ROOT . '/' . $fromdir] = self::relativePath($todir, $fromdir);
     foreach ($list as $f => $import) {
         if ($import) {
             $importdirs[JPATH_ROOT . '/' . dirname($f)] = self::relativePath($todir, dirname($f));
             $content .= "\n#" . self::$kfilepath . "{content: \"{$f}\";}\n";
             // $content .= "@import \"$import\";\n\n";
             if (is_file(JPATH_ROOT . '/' . $f)) {
                 $less_content = file_get_contents(JPATH_ROOT . '/' . $f);
                 // remove vars/mixins for template & canvas less
                 if (preg_match('@' . preg_quote(CANVAS_TEMPLATE_REL, '@') . '/less/@i', $f) || preg_match('@' . preg_quote(CANVAS_REL, '@') . '/less/@i', $f)) {
                     $less_content = preg_replace(self::$rimportvars, '', $less_content);
                 }
                 self::$_path = CANVASPath::relativePath($fromdir, dirname($f)) . '/';
                 $less_content = preg_replace_callback(self::$rimport, array('CANVASLess', 'cb_import_path'), $less_content);
                 $content .= $less_content;
             }
         } else {
             $content .= "\n#" . self::$kfilepath . "{content: \"{$path}\";}\n";
             $content .= $f . "\n\n";
         }
     }
     // get vars
     $vars_files = explode('|', self::getVars('urls'));
     // build source
     $source = '';
     // build import vars
     foreach ($vars_files as $var) {
         $vars_path = CANVASPath::relativePath($fromdir, dirname($var));
         if ($vars_path) {
             $vars_path .= "/";
         }
         $var_file = $vars_path . basename($var);
         $source .= "@import \"" . $var_file . "\";\n";
     }
     // less content
     $source .= "\n#" . self::$kvarsep . "{content: \"separator\";}\n" . $content;
     // call Less to compile
     $output = CANVASLessCompiler::compile($source, $path, $todir, $importdirs);
     // process content
     //use cssjanus to transform the content
     if ($is_rtl) {
         $output = preg_split(self::$rsplitbegin . self::$krtlsep . self::$rsplitend, $output, -1, PREG_SPLIT_DELIM_CAPTURE);
         $rtlcontent = isset($output[2]) ? $output[2] : false;
         $output = $output[0];
         CANVAS::import('jacssjanus/ja.cssjanus');
         $output = JACSSJanus::transform($output, true);
         // join with rtl content
         if ($rtlcontent) {
             $output = $output . "\n" . $rtlcontent;
         }
     }
     // skip duplicate clearfix
     $arr = preg_split(self::$rsplitbegin . self::$kvarsep . self::$rsplitend, $output, 2);
     if (preg_match('/bootstrap.less/', $path)) {
         $output = implode("\n", $arr);
     } else {
         $output = count($arr) > 1 ? $arr[1] : $arr[0];
     }
     //remove comments and clean up
     $output = preg_replace(self::$rcomment, '', $output);
     $output = preg_replace(self::$rspace, "\n\n", $output);
     // split if needed
     if ($split) {
         //update path and store to files
         $split_contents = preg_split(self::$rsplitbegin . self::$kfilepath . self::$rsplitend, $output, -1, PREG_SPLIT_DELIM_CAPTURE);
         $file_contents = array();
         $file = $path;
         $isfile = false;
         foreach ($split_contents as $chunk) {
             if ($isfile) {
                 $isfile = false;
                 $file = $chunk;
             } else {
                 $file_contents[$file] = (isset($file_contents[$file]) ? $file_contents[$file] : '') . "\n" . $chunk . "\n\n";
                 $isfile = true;
             }
         }
         if (!empty($file_contents)) {
             //output the file to content and add to document
             foreach ($file_contents as $file => $content) {
                 $content = trim($content);
                 $filename = str_replace('/', '.', $file) . '.css';
                 JFile::write(JPATH_ROOT . '/' . $todir . '/' . $filename, $content);
             }
         }
     } else {
         $output = preg_replace(self::$rsplitbegin . self::$kfilepath . self::$rsplitend, '', $output);
         $output = trim($output);
         if ($topath) {
             JFile::write(JPATH_ROOT . '/' . $topath, $output);
         } else {
             return $output;
         }
     }
     // write to path
     return true;
 }
Exemplo n.º 18
0
 /**
  * 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);
 }
Exemplo n.º 19
0
/**
 *------------------------------------------------------------------------------
 * @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
Exemplo n.º 20
0
<?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 = '';