Ejemplo n.º 1
0
 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
     $arr = preg_split(CANVASLess::$rsplitbegin . CANVASLess::$kfilepath . CANVASLess::$rsplitend, $output, -1, PREG_SPLIT_DELIM_CAPTURE);
     $output = '';
     $file = $relpath = '';
     $isfile = false;
     foreach ($arr as $s) {
         if ($isfile) {
             $isfile = false;
             $file = $s;
             $relpath = CANVASLess::relativePath($todir, dirname($file));
             $output .= "\n#" . CANVASLess::$kfilepath . "{content: \"{$file}\";}\n";
         } else {
             $output .= ($file ? CANVASPath::updateUrl($s, $relpath) : $s) . "\n\n";
             $isfile = true;
         }
     }
     return $output;
 }
Ejemplo n.º 2
0
    public function renders()
    {
        ob_start();
        $path = CANVASPath::getPath('tpls/widgets/' . $this->name . '.php');
        if ($path) {
            include $path;
        } else {
            ?>

			<div class="canvas-back-to-top">	
				<!-- BACK TOP TOP BUTTON -->
				<div id="back-to-top" data-spy="affix" data-offset-top="300" class="back-to-top hidden-xs hidden-sm affix-top">
				  <button class="btn btn-primary" title="Back to Top"><i class="fa fa-caret-up"></i></button>
				</div>
				<script type="text/javascript">
				(function($) {
Ejemplo n.º 3
0
    public function renders()
    {
        ob_start();
        $path = CANVASPath::getPath('tpls/widgets/' . $this->name . '.php');
        if ($path) {
            include $path;
        } else {
            ?>

			<!-- MAIN CONTENT -->
			<div id="canvas-content" class="canvas-content">
				<?php 
            if ($this->hasMessage()) {
                ?>
				<jdoc:include type="message" />
				<?php 
            }
            ?>
				<jdoc:include type="component" />
			</div>
Ejemplo n.º 4
0
    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 
Ejemplo n.º 5
0
    public function renders()
    {
        $now = JFactory::getDate('now');
        $date_formet = $this->getParam('date_formet', 'd M Y h:i:s');
        $date = JHtml::_('date', $now, $date_formet);
        ob_start();
        $path = CANVASPath::getPath('tpls/widgets/' . $this->name . '.php');
        if ($path) {
            include $path;
        } else {
            ?>

			<div id="canvas-date" class="canvas-hide">
				<?php 
            echo $date;
            ?>

			</div>
			<?php 
        }
        return ob_get_clean();
    }
Ejemplo n.º 6
0
    public function renders()
    {
        $copyrightinfo = (string) $this->getParam('copyrightinfo');
        ob_start();
        $path = CANVASPath::getPath('tpls/widgets/' . $this->name . '.php');
        if ($path) {
            include $path;
        } else {
            ?>

		<div class="canvas-copyrightinfo">
            <span class="copyright">
                <?php 
            echo $copyrightinfo ? $copyrightinfo : JText::_('CANVAS_DEFAULT_COPYRIGHT');
            ?>

            </span>
		</div>
        <?php 
        }
        return ob_get_clean();
    }
Ejemplo n.º 7
0
    public function renders()
    {
        ob_start();
        $fontresizer_selection = $this->getParam('fontresizer_selection', '#canvas-content');
        $path = CANVASPath::getPath('tpls/widgets/' . $this->name . '.php');
        $this->doc->addScript(CANVAS_URL . '/js/jquery.jfontsize.js');
        if ($path) {
            include $path;
        } else {
            ?>

			<section class="canvas-fontresizer">	
				<!-- BACK TO TOP -->
				 <div id="font-resizer" class="canvas-hide">
					<a class="icon-search-minus" id="canvas-fr-m">A-</a>
					<a class="icon-search" id="canvas-fr-d">A</a>
					<a class="icon-search-plus" id="canvas-fr-p">A+</a>
				</div>
				<script type="text/javascript">
				  //<![CDATA[
				  //jQuery('$selector');
				  (function($){
					$(document).ready(function(){
					  $('<?php 
            echo $fontresizer_selection;
            ?>
').jfontsize({ btnMinusClasseId: '#canvas-fr-m', btnDefaultClasseId: '#canvas-fr-d', btnPlusClasseId: '#canvas-fr-p' });
					});
				  })(jQuery);
				  //]]>
				</script>

			</section>
			<?php 
        }
        return ob_get_clean();
Ejemplo n.º 8
0
 /**
  * Add some other condition assets (css, javascript). Use to parse /etc/assets.xml
  *
  * @return  null
  */
 function addExtraAssets()
 {
     $base = JURI::base(true);
     $regurl = '#(http|https)://([a-zA-Z0-9.]|%[0-9A-Za-z]|/|:[0-9]?)*#iu';
     $afiles = CANVASPath::getAllPath('etc/assets.xml');
     foreach ($afiles as $afile) {
         if (is_file($afile)) {
             //load xml
             $axml = JFactory::getXML($afile);
             //process if exist
             if ($axml) {
                 foreach ($axml as $node => $nodevalue) {
                     //ignore others node
                     if ($node == 'stylesheets' || $node == 'scripts') {
                         foreach ($nodevalue->file as $file) {
                             $compatible = (string) $file['compatible'];
                             if ($compatible) {
                                 $parts = explode(' ', $compatible);
                                 $operator = '=';
                                 //exact equal to
                                 $operand = $parts[0];
                                 if (count($parts) == 2) {
                                     $operator = $parts[0];
                                     $operand = $parts[1];
                                 }
                                 //compare with Joomla version
                                 if (!version_compare(JVERSION, $operand, $operator)) {
                                     continue;
                                 }
                             }
                             $url = (string) $file;
                             if (substr($url, 0, 2) == '//') {
                                 //external link
                             } else {
                                 if ($url[0] == '/') {
                                     //absolute link from based folder
                                     $url = is_file(JPATH_ROOT . $url) ? $base . $url : false;
                                 } else {
                                     if (!preg_match($regurl, $url)) {
                                         //not match a full url -> sure internal link
                                         $url = CANVASPath::getUrl($url);
                                         // so get it
                                     }
                                 }
                             }
                             if ($url) {
                                 if ($node == 'stylesheets') {
                                     $type = $file['type'] ? (string) $file['type'] : 'text/css';
                                     $media = $file['media'] ? (string) $file['media'] : null;
                                     $this->addStylesheet($url, $type, $media);
                                 } else {
                                     $type = $file['type'] ? (string) $file['type'] : 'text/javascript';
                                     $defer = $file['defer'] ? (bool) $file['defer'] : false;
                                     $async = $file['async'] ? (bool) $file['async'] : false;
                                     $this->addScript($url, $type, $defer, $async);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     // template extended styles
     $aparams = $this->_tpl->params->toArray();
     $extras = array();
     $itemid = JFactory::getApplication()->input->get('Itemid');
     foreach ($aparams as $name => $value) {
         if (preg_match('/^theme_extras_(.+)$/', $name, $m)) {
             $extras[$m[1]] = $value;
         }
     }
     if (count($extras)) {
         foreach ($extras as $extra => $pages) {
             if (!is_array($pages) || !count($pages) || in_array(0, $pages)) {
                 continue;
                 // disabled
             }
             if (in_array(-1, $pages) || in_array($itemid, $pages)) {
                 // load this style
                 $this->addCss('extras/' . $extra);
             }
         }
     }
     // load addon lib scripts/styles
     // -------------------------------------------
     // load holder.js
     if ($this->params->get('load_holder_js', 1)) {
         $this->addScript(CANVAS_URL . '/js/holder.js');
     }
     // load wow.js
     if ($this->params->get('load_wow_js', 1)) {
         $this->addScript(CANVAS_URL . '/js/wow.min.js');
     }
     // load animate.css
     if ($this->params->get('load_animate_css', 1)) {
         $this->addStyleSheet(CANVAS_URL . '/css/animate.min.css');
     }
 }
Ejemplo n.º 9
0
 /**
  * @param   $tpl  template object
  * @return  bool  optimize success or not
  */
 public static function optimizecss($tpl)
 {
     $outputpath = JPATH_ROOT . '/' . $tpl->getParam('canvas-assets', 'canvas-assets') . '/css';
     $outputurl = JURI::root(true) . '/' . $tpl->getParam('canvas-assets', 'canvas-assets') . '/css';
     if (!JFile::exists($outputpath)) {
         JFolder::create($outputpath);
         @chmod($outputpath, 0755);
     }
     if (!is_writeable($outputpath)) {
         return false;
     }
     //prepare config
     self::prepare($tpl);
     $doc = JFactory::getDocument();
     //======================= Group css ================= //
     $mediagroup = array();
     $cssgroups = array();
     $stylesheets = array();
     $ielimit = 4095;
     $selcounts = 0;
     $regex = '/\\{.+?\\}|,/s';
     //selector counter
     $csspath = '';
     // group css into media
     $mediagroup['all'] = array();
     $mediagroup['screen'] = array();
     foreach ($doc->_styleSheets as $url => $stylesheet) {
         $media = $stylesheet['media'] ? $stylesheet['media'] : 'all';
         if (empty($mediagroup[$media])) {
             $mediagroup[$media] = array();
         }
         $mediagroup[$media][$url] = $stylesheet;
     }
     foreach ($mediagroup as $media => $group) {
         $stylesheets = array();
         // empty - begin a new group
         foreach ($group as $url => $stylesheet) {
             $url = self::fixUrl($url);
             if ($stylesheet['mime'] == 'text/css' && ($csspath = self::cssPath($url))) {
                 $stylesheet['path'] = $csspath;
                 $stylesheet['data'] = file_get_contents($csspath);
                 $selcount = preg_match_all($regex, $stylesheet['data'], $matched);
                 if (!$selcount) {
                     $selcount = 1;
                     //just for sure
                 }
                 //if we found an @import rule or reach IE limit css selector count, break into the new group
                 if (preg_match('#@import\\s+.+#', $stylesheet['data']) || $selcounts + $selcount >= $ielimit) {
                     if (count($stylesheets)) {
                         $cssgroup = array();
                         $groupname = array();
                         foreach ($stylesheets as $gurl => $gsheet) {
                             $cssgroup[$gurl] = $gsheet;
                             $groupname[] = $gurl;
                         }
                         $cssgroup['groupname'] = implode('', $groupname);
                         $cssgroup['media'] = $media;
                         $cssgroups[] = $cssgroup;
                     }
                     $stylesheets = array($url => $stylesheet);
                     // empty - begin a new group
                     $selcounts = $selcount;
                 } else {
                     $stylesheets[$url] = $stylesheet;
                     $selcounts += $selcount;
                 }
             } else {
                 // first get all the stylsheets up to this point, and get them into
                 // the items array
                 if (count($stylesheets)) {
                     $cssgroup = array();
                     $groupname = array();
                     foreach ($stylesheets as $gurl => $gsheet) {
                         $cssgroup[$gurl] = $gsheet;
                         $groupname[] = $gurl;
                     }
                     $cssgroup['groupname'] = implode('', $groupname);
                     $cssgroup['media'] = $media;
                     $cssgroups[] = $cssgroup;
                 }
                 //mark ignore current stylesheet
                 $cssgroup = array($url => $stylesheet, 'ignore' => true);
                 $cssgroups[] = $cssgroup;
                 $stylesheets = array();
                 // empty - begin a new group
             }
         }
         if (count($stylesheets)) {
             $cssgroup = array();
             $groupname = array();
             foreach ($stylesheets as $gurl => $gsheet) {
                 $cssgroup[$gurl] = $gsheet;
                 $groupname[] = $gurl;
             }
             $cssgroup['groupname'] = implode('', $groupname);
             $cssgroup['media'] = $media;
             $cssgroups[] = $cssgroup;
         }
     }
     //======================= Group css ================= //
     $output = array();
     foreach ($cssgroups as $cssgroup) {
         if (isset($cssgroup['ignore'])) {
             unset($cssgroup['ignore']);
             unset($cssgroup['groupname']);
             unset($cssgroup['media']);
             foreach ($cssgroup as $furl => $fsheet) {
                 $output[$furl] = $fsheet;
             }
         } else {
             $media = $cssgroup['media'];
             $groupname = 'css-' . substr(md5($cssgroup['groupname']), 0, 5) . '.css';
             $groupfile = $outputpath . '/' . $groupname;
             $grouptime = JFile::exists($groupfile) ? @filemtime($groupfile) : -1;
             $rebuild = $grouptime < 0;
             //filemtime == -1 => rebuild
             unset($cssgroup['groupname']);
             unset($cssgroup['media']);
             foreach ($cssgroup as $furl => $fsheet) {
                 if (!$rebuild && @filemtime($fsheet['path']) > $grouptime) {
                     $rebuild = true;
                 }
             }
             if ($rebuild) {
                 $cssdata = array();
                 foreach ($cssgroup as $furl => $fsheet) {
                     $cssdata[] = "\n\n/*===============================";
                     $cssdata[] = $furl;
                     $cssdata[] = "================================================================================*/";
                     $cssmin = self::minifyCss($fsheet['data']);
                     $cssmin = CANVASPath::updateUrl($cssmin, CANVASPath::relativePath($outputurl, dirname($furl)));
                     $cssdata[] = $cssmin;
                 }
                 $cssdata = implode("\n", $cssdata);
                 if (!JFile::write($groupfile, $cssdata)) {
                     // cannot write file, ignore minify
                     return false;
                 }
                 $grouptime = @filemtime($groupfile);
                 @chmod($groupfile, 0644);
             }
             $output[$outputurl . '/' . $groupname . '?t=' . $grouptime % 1000] = array('mime' => 'text/css', 'media' => $media == 'all' ? NULL : $media, 'attribs' => array());
         }
     }
     //apply the change make change
     $doc->_styleSheets = $output;
 }
Ejemplo n.º 10
0
 public static function cb_import_path($match)
 {
     $f = $match[1];
     $newf = CANVASPath::cleanPath(self::$_path . $f);
     return str_replace($f, $newf, $match[0]);
 }
Ejemplo n.º 11
0
    public function renders()
    {
        $twitter = (string) $this->getParam('twitter');
        $facebook = (string) $this->getParam('facebook');
        $gplus = (string) $this->getParam('gplus');
        $rss = (string) $this->getParam('rss');
        ob_start();
        $path = CANVASPath::getPath('tpls/widgets/' . $this->name . '.php');
        if ($path) {
            include $path;
        } else {
            ?>
		<?php 
            if ($twitter or $facebook or $gplus or $rss) {
                ?>
		<div class="canvas-social-icons">	
			<ul class="social-icons list-inline clearfix">
				<?php 
                if (!empty($twitter)) {
                    ?>
					<li class="twitter">
						<a href="https://twitter.com/<?php 
                    echo $twitter;
                    ?>
" rel="author" target="_blank">
							<i class="icon-twitter"></i>
						</a>
					</li>
				<?php 
                }
                ?>
				<?php 
                if (!empty($facebook)) {
                    ?>
					<li class="facebook">
						<a href="https://facebook.com/<?php 
                    echo $facebook;
                    ?>
" rel="author" target="_blank">
							<i class="icon-facebook"></i>
						</a>
					</li>
				<?php 
                }
                ?>
				<?php 
                if (!empty($gplus)) {
                    ?>
					<li class="gplus">
						<a href="https://plus.google.com/<?php 
                    echo $gplus;
                    ?>
" rel="author" target="_blank">
							<i class="icon-google-plus" ></i>
						</a>
					</li>
				<?php 
                }
                ?>
				<?php 
                if (!empty($rss)) {
                    ?>
					<li class="rss">
						<a href="<?php 
                    echo $rss;
                    ?>
" target="_blank">
							<i class="icon-rss" ></i>
						</a>
					</li>
				<?php 
                }
                ?>
			</ul>
		</div>
		<?php 
            }
        }
        return ob_get_clean();
    }
Ejemplo n.º 12
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;
 }
Ejemplo n.º 13
0
 /**
  * Return the pagination footer.
  *
  * @return  string   Pagination footer.
  *
  * @since   11.1
  */
 public function getListFooter()
 {
     $app = JFactory::getApplication();
     $list = array();
     $list['prefix'] = $this->prefix;
     $list['limit'] = $this->limit;
     $list['limitstart'] = $this->limitstart;
     $list['total'] = $this->total;
     $list['limitfield'] = $this->getLimitBox();
     $list['pagescounter'] = $this->getPagesCounter();
     $list['pageslinks'] = $this->getPagesLinks();
     // CANVAS: detect if chrome pagination.php in template or in plugin
     $chromePath = CANVASPath::getPath('html/pagination.php');
     // $chromePath = JPATH_THEMES . '/' . $app->getTemplate() . '/html/pagination.php';
     if (file_exists($chromePath)) {
         include_once $chromePath;
         if (function_exists('pagination_list_footer')) {
             return pagination_list_footer($list);
         }
     }
     return $this->_list_footer($list);
 }
Ejemplo n.º 14
0
 public static function updateUrl($css, $src)
 {
     self::$srcurl = rtrim($src, '/');
     $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/', array('CANVASPath', 'replaceurl'), $css);
     $css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/', array('CANVASPath', 'replaceurl'), $css);
     return $css;
 }
Ejemplo n.º 15
0
 public static function purge()
 {
     // Initialize some variables
     $input = JFactory::getApplication()->input;
     $layout = $input->getCmd('layout');
     $template = $input->getCmd('template');
     if (!$layout) {
         return self::error(JText::_('CANVAS_LAYOUT_UNKNOW_ACTION'));
     }
     // delete custom layout
     $layoutfile = CANVASPath::getLocalPath('tpls/' . $layout . '.php');
     $initfile = CANVASPath::getLocalPath('etc/layout/' . $layout . '.ini');
     // delete default layout
     $defaultlayoutfile = CANVAS_TEMPLATE_PATH . '/tpls/' . $layout . '.php';
     $defaultinitfile = CANVAS_TEMPLATE_PATH . '/etc/layout/' . $layout . '.ini';
     if (!@JFile::delete($layoutfile) || !@JFile::delete($defaultlayoutfile) || !@JFile::delete($initfile) || !@JFile::delete($defaultinitfile)) {
         return self::error(JText::_('CANVAS_LAYOUT_DELETE_FAIL'));
     } else {
         return self::response(array('successful' => JText::_('CANVAS_LAYOUT_DELETE_SUCCESSFULLY'), 'layout' => $layout, 'type' => 'delete'));
     }
 }
Ejemplo n.º 16
0
    public function renders()
    {
        ob_start();
        $path = CANVASPath::getPath('tpls/widgets/' . $this->name . '.php');
        if ($path) {
            include $path;
        } else {
            ?>
				<!-- LOGIN -->
					 <!-- login trigger modal -->
							<?php 
            $user = JFactory::getUser();
            $type = !$user->get('guest') ? 'logout' : 'login';
            ?>
						<div class="canvas-widget login-widget">	
							<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#canvasWidget<?php 
            echo $type;
            ?>
">
							  <i class="fa fa-sign-<?php 
            echo $type == 'login' ? 'in' : 'out';
            ?>
"></i>
							</button>
							<div class="modal fade" id="canvasWidgetlogin" tabindex="-1" role="dialog" aria-labelledby="canvasWidget<?php 
            echo $type;
            ?>
Label" aria-hidden="true">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="modal-header">
											<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
											<h4 class="modal-title" id="canvasWidget<?php 
            echo $type;
            ?>
Label"><?php 
            echo JText::_('JLOGIN');
            ?>
</h4>
										</div>
										<div class="modal-body">
											<form class="form-horizontal" role="form" action="<?php 
            echo JRoute::_('index.php', true);
            ?>
" method="post">
											  <div class="form-group">
												<label for="inputUsername" class="col-sm-4 control-label">
													<?php 
            echo JText::_('USER_NAME');
            ?>
													 <a class="hasTooltip" href="<?php 
            echo JRoute::_('index.php?option=com_users&view=remind');
            ?>
" title="<?php 
            echo JText::_('FORGOT_YOUR_USERNAME');
            ?>
">
													<i class="fa fa-question-circle"></i>
													</a>
												</label>
												
												<div class="col-sm-8">
												  <input type="text" name="username" class="form-control" id="inputUsername" placeholder="Username">
												 
												</div>
											  </div>
											  <div class="form-group">
												<label for="inputUserPassword" class="col-sm-4 control-label"><?php 
            echo JText::_('PASSWORD');
            ?>
													 <a class="hasTooltip" href="<?php 
            echo JRoute::_('index.php?option=com_users&view=reset');
            ?>
" title="<?php 
            echo JText::_('FORGOT_YOUR_PASSWORD');
            ?>
">
													<i class="fa fa-question-circle"></i>
													</a>
												</label>
												<div class="col-sm-8">
												  <input type="password" class="form-control" id="inputUserPassword" name="password" placeholder="Password">
												</div>
											  </div>
											   <?php 
            if (JPluginHelper::isEnabled('system', 'remember')) {
                ?>
												  <div class="form-group">
													<div class="col-sm-offset-2 col-sm-10">
														<div class="checkbox">
															<label>
															  <input type="checkbox" name="remember" > <?php 
                echo JText::_('REMEMBER_ME');
                ?>
															</label>
														</div>
													</div>
												</div>
												<?php 
            }
            ?>
												
												 <div class="form-group">
												<div class="col-sm-offset-2 col-sm-10">
												  <input type="hidden" name="option" value="com_users" />
													<input type="hidden" name="task" value="user.login" />
													<input type="hidden" name="return" value="<?php 
            echo base64_encode(JRoute::_('index.php', true));
            ?>
" />
													<?php 
            echo JHtml::_('form.token');
            ?>
													<button type="submit" class="btn btn-default"><?php 
            echo JText::_('JLOGIN');
            ?>
</button>
													
													  <?php 
            require_once JPATH_SITE . '/components/com_users/helpers/route.php';
            $usersConfig = JComponentHelper::getParams('com_users');
            if ($usersConfig->get('allowUserRegistration')) {
                ?>
														<a class="btn btn-default" href="<?php 
                echo JRoute::_('index.php?option=com_users&view=registration&Itemid=' . UsersHelperRoute::getRegistrationRoute());
                ?>
">
															<?php 
                echo JText::_('JREGISTER');
                ?>
 <span class="fa fa-arrow-right"></span></a>
												<?php 
            }
            ?>
											
													
													
												</div>
											  </div>
											</form>
										</div>
										<div class="modal-footer">
											<button type="button" class="btn btn-default" data-dismiss="modal"><?php 
            echo JText::_('JCLOSE');
            ?>
</button>
										</div>
									</div>
								</div>
							</div>
							
							<div class="modal fade" id="canvasWidgetlogout" tabindex="-1" role="dialog" aria-labelledby="canvasWidget<?php 
            echo $type;
            ?>
Label" aria-hidden="true">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="modal-header">
											<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
											<h4 class="modal-title" id="canvasWidget<?php 
            echo $type;
            ?>
Label"><?php 
            echo JText::_('JLOGOUT');
            ?>
</h4>
										</div>
										<div class="modal-body">
											<form class="form-horizontal" role="form" action="<?php 
            echo JRoute::_('index.php?option=com_users', true);
            ?>
" method="post">
												<div class="form-group">
													
													<div class="col-md-12 logout-button">
														
														<button type="submit" class="btn btn-default"><?php 
            echo JText::_('JLOGOUT');
            ?>
</button>
														
														<input type="hidden" name="option" value="com_users">
														<input type="hidden" name="task" value="user.logout">
														<input type="hidden" name="return" value="<?php 
            echo base64_encode(JRoute::_('index.php', true));
            ?>
" />
														<?php 
            echo JHtml::_('form.token');
            ?>
													</div>
												</div>
											</form>
										</div>
										<div class="modal-footer">
											<button type="button" class="btn btn-default" data-dismiss="modal"><?php 
            echo JText::_('JCLOSE');
            ?>
</button>
										</div>
									</div>
								</div>
							</div>
						</div>
				<!-- //LOGIN -->
			<?php 
        }
        return ob_get_clean();
    }
Ejemplo n.º 17
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;
 }
Ejemplo n.º 18
0
    public function renders()
    {
        // get params
        $sitename = $this->params->get('sitename');
        $slogan = $this->params->get('slogan', '');
        $logotype = $this->params->get('logotype', 'text');
        $logoimage = $logotype == 'image' ? $this->params->get('logoimage', 'templates/' . CANVAS_TEMPLATE . '/images/logo.png') : '';
        $logoimgsm = $logotype == 'image' && $this->params->get('enable_logoimage_sm', 0) ? $this->params->get('logoimage_sm', '') : false;
        if (!$sitename) {
            $sitename = JFactory::getConfig()->get('sitename');
        }
        ob_start();
        $path = CANVASPath::getPath('tpls/widgets/' . $this->name . '.php');
        if ($path) {
            include $path;
        } else {
            ?>
				<!-- LOGO -->
				<div class="logo logo-<?php 
            echo $logotype;
            ?>
">
					<div class="logo-<?php 
            echo $logotype, $logoimgsm ? ' logo-control' : '';
            ?>
">
						<a href="<?php 
            echo JURI::base(true);
            ?>
" title="<?php 
            echo strip_tags($sitename);
            ?>
">
							<?php 
            if ($logotype == 'image') {
                ?>
								<img class="logo-img" src="<?php 
                echo JURI::base(true) . '/' . $logoimage;
                ?>
" alt="<?php 
                echo strip_tags($sitename);
                ?>
" />
							<?php 
            }
            ?>

							<?php 
            if ($logoimgsm) {
                ?>
								<img class="logo-img-sm" src="<?php 
                echo JURI::base(true) . '/' . $logoimgsm;
                ?>
" alt="<?php 
                echo strip_tags($sitename);
                ?>
" />
							<?php 
            }
            ?>
							<?php 
            if ($logotype == 'image') {
                echo '<span class="hide-text">';
            }
            ?>
							
							<?php 
            if (strpos($sitename, '::') !== false) {
                $sitenameTitle = explode('::', $sitename);
                $sitenameTitle = $sitenameTitle[0] . "<span>" . $sitenameTitle[1] . "</span>";
            } else {
                $sitenameTitle = $sitename;
            }
            ?>
							<?php 
            echo $sitenameTitle;
            ?>
							<?php 
            if ($logotype == 'image') {
                echo '</span>';
            }
            ?>
						</a>
					</div>
				</div>
				<!-- //LOGO -->
			<?php 
        }
        return ob_get_clean();
    }
Ejemplo n.º 19
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){

					}
				}');
        }
    }
Ejemplo n.º 20
0
    public function renders()
    {
        JHtml::_('bootstrap.tooltip');
        $CANVASTemplate = new CANVASTemplate();
        $path = CANVASPath::getPath('tpls/widgets/' . $this->name . '.php');
        ob_start();
        if ($path) {
            include $path;
        } else {
            ?>

				<!-- MAIN NAVIGATION -->
				<div id="canvas-mainnav" class="wrap navbar navbar-default <?php 
            echo $this->getParam('navigation_fixed_top', '0') ? 'navbar-fixed-top' : '';
            ?>
 canvas-mainnav">
					
					<?php 
            if ($this->getParam('navigation_fixed_top', '0')) {
                ?>
					<div class="container">
					<?php 
            }
            ?>
					
					<!-- NAVBAR HEADER -->
					<div class="navbar-header">
						
						<?php 
            if ($this->getParam('load_head_logo_nav', 1)) {
                // get params
                $sitename = $this->params->get('sitename');
                $slogan = $this->params->get('slogan', '');
                $logotype = $this->params->get('logotype', 'text');
                $logoimage = $logotype == 'image' ? $this->params->get('logoimage', 'templates/' . CANVAS_TEMPLATE . '/images/logo.png') : '';
                $logoimgsm = $logotype == 'image' && $this->params->get('enable_logoimage_sm', 0) ? $this->params->get('logoimage_sm', '') : false;
                if (!$sitename) {
                    $sitename = JFactory::getConfig()->get('sitename');
                }
                ?>
						<!-- LOGO IN NAVBAR -->
							<!-- LOGO -->
							<div class="logo logo-<?php 
                echo $logotype;
                ?>
">
								<div class="logo-<?php 
                echo $logotype, $logoimgsm ? ' logo-control' : '';
                ?>
">
									<a href="<?php 
                echo JURI::base(true);
                ?>
" title="<?php 
                echo strip_tags($sitename);
                ?>
">
										<?php 
                if ($logotype == 'image') {
                    ?>
											<img class="logo-img" src="<?php 
                    echo JURI::base(true) . '/' . $logoimage;
                    ?>
" alt="<?php 
                    echo strip_tags($sitename);
                    ?>
" />
										<?php 
                }
                ?>
										
										<?php 
                if ($logoimgsm) {
                    ?>
											<img class="logo-img-sm" src="<?php 
                    echo JURI::base(true) . '/' . $logoimgsm;
                    ?>
" alt="<?php 
                    echo strip_tags($sitename);
                    ?>
" />
										<?php 
                }
                ?>
										<?php 
                if ($logotype == 'image') {
                    echo '<span class="hide-text">';
                }
                ?>
										
										<?php 
                if (strpos($sitename, '::') !== false) {
                    $sitenameTitle = explode('::', $sitename);
                    $sitenameTitle = $sitenameTitle[0] . "<span>" . $sitenameTitle[1] . "</span>";
                } else {
                    $sitenameTitle = $sitename;
                }
                ?>
										<?php 
                echo $sitenameTitle;
                ?>
										
										<?php 
                if ($logotype == 'image') {
                    echo '</span>';
                }
                ?>
									</a>
									<?php 
                echo $slogan ? '<span class="site-slogan">' . $slogan . '</span>' : '';
                ?>
								</div>
							</div>
							<!-- //LOGO -->
						<!-- //LOGO IN NAVBAR -->
						<?php 
            }
            ?>
						
						<?php 
            if ($this->getParam('load_head_search_nav', 1)) {
                ?>
						<!-- HEAD SEARCH -->
						<div class="head-search <?php 
                $this->_c('head-search');
                ?>
">     
						  <jdoc:include type="modules" name="<?php 
                $this->_p('head-search');
                ?>
" style="raw" />
						</div>
						<!-- //HEAD SEARCH -->
						<?php 
            }
            ?>
						
						<?php 
            if ($this->getParam('load_head_login_nav', 1)) {
                ?>
						<!-- HEAD SEARCH -->
						<div class="head-login <?php 
                $this->_c('login');
                ?>
">     
						  <!-- login trigger modal -->
							<?php 
                $user = JFactory::getUser();
                $type = !$user->get('guest') ? 'logout' : 'login';
                ?>
							<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#canvasWidget<?php 
                echo $type;
                ?>
">
							  <i class="fa fa-sign-<?php 
                echo $type == 'login' ? 'in' : 'out';
                ?>
"></i>
							</button>
							<div class="modal fade" id="canvasWidgetlogin" tabindex="-1" role="dialog" aria-labelledby="canvasWidget<?php 
                echo $type;
                ?>
Label" aria-hidden="true">
								<div class="modal-dialog">
									<div class="modal-content">
										<div class="modal-header">
											<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
											<h4 class="modal-title" id="canvasWidget<?php 
                echo $type;
                ?>
Label"><?php 
                echo JText::_('JLOGIN');
                ?>
</h4>
										</div>
										<div class="modal-body">
											<form class="form-horizontal" role="form" action="<?php 
                echo JRoute::_('index.php', true);
                ?>
" method="post">
											  <div class="form-group">
												<label for="inputUsername" class="col-sm-4 control-label">
													<?php 
                echo JText::_('USER_NAME');
                ?>
													 <a class="hasTooltip" href="<?php 
                echo JRoute::_('index.php?option=com_users&view=remind');
                ?>
" title="<?php 
                echo JText::_('FORGOT_YOUR_USERNAME');
                ?>
">
													<i class="fa fa-question-circle"></i>
													</a>
												</label>
												
												<div class="col-sm-8">
												  <input type="text" name="username" class="form-control" id="inputUsername" placeholder="Username">
												 
												</div>
											  </div>
											  <div class="form-group">
												<label for="inputUserPassword" class="col-sm-4 control-label"><?php 
                echo JText::_('PASSWORD');
                ?>
													 <a class="hasTooltip" href="<?php 
                echo JRoute::_('index.php?option=com_users&view=reset');
                ?>
" title="<?php 
                echo JText::_('FORGOT_YOUR_PASSWORD');
                ?>
">
													<i class="fa fa-question-circle"></i>
													</a>
												</label>
												<div class="col-sm-8">
												  <input type="password" class="form-control" id="inputUserPassword" name="password" placeholder="Password">
												</div>
											  </div>
											   <?php 
                if (JPluginHelper::isEnabled('system', 'remember')) {
                    ?>
												  <div class="form-group">
													<div class="col-sm-offset-2 col-sm-10">
														<div class="checkbox">
															<label>
															  <input type="checkbox" name="remember" > <?php 
                    echo JText::_('REMEMBER_ME');
                    ?>
															</label>
														</div>
													</div>
												</div>
												<?php 
                }
                ?>
												
												 <div class="form-group">
												<div class="col-sm-offset-2 col-sm-10">
												  <input type="hidden" name="option" value="com_users" />
													<input type="hidden" name="task" value="user.login" />
													<input type="hidden" name="return" value="<?php 
Ejemplo n.º 21
0
 /**
  * Load block content
  *
  * @param $block string block name - the real block is tpls/blocks/[blockname].php
  * @param $vars  array  information of block (used in template layout)
  *
  * @return string Block content
  */
 function loadBlock($block, $vars = array())
 {
     if (!$this->_block) {
         $this->_block = $block;
     }
     $path = CANVASPath::getPath('tpls/system/' . $block . '.php');
     if (!$path) {
         $path = CANVASPath::getPath('tpls/blocks/' . $block . '.php');
     }
     ob_start();
     if ($path) {
         include $path;
     } else {
         echo "<div class=\"error\">Block [{$block}] not found!</div>";
     }
     $content = ob_get_contents();
     ob_end_clean();
     if (isset($vars['spl'])) {
         $content = preg_replace('#(<[A-Za-z]+[^>^\\/]*)>#', '\\1 data-original="' . $block . '"' . (isset($vars['spl']) ? ' data-spotlight="' . $vars['name'] . '"' : '') . '>', $content, 1);
         $this->_block = null;
     }
     echo isset($vars['spl']) ? $content : '<div class="canvas-admin-layout-section"><h5 class="canvas-block-title">' . ucfirst($block) . '</h5>' . $content . '</div>';
 }