PageRenderTime 103ms CodeModel.GetById 60ms app.highlight 9ms RepoModel.GetById 32ms app.codeStats 0ms

/templates/business13/html/mod_roknavmenu/themes/gantry-splitmenu/layout.php

https://bitbucket.org/izubizarreta/https-bitbucket.org-bityvip-alpes
PHP | 135 lines | 111 code | 15 blank | 9 comment | 37 complexity | a1d47dab2c2cd494fe9627b2d162300e MD5 | raw file
  1<?php
  2/**
  3 * @version   3.2.22 August 3, 2012
  4 * @author    RocketTheme http://www.rockettheme.com
  5 * @copyright Copyright (C) 2007 - 2012 RocketTheme, LLC
  6 * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
  7 */
  8
  9
 10// no direct access
 11defined('_JEXEC') or die('Restricted access');
 12
 13class GantrySplitmenuLayout extends AbstractRokMenuLayout
 14{
 15    protected $theme_path;
 16    protected $params;
 17
 18    private $activeid;
 19
 20    public function __construct(&$args)
 21    {
 22        parent::__construct($args);
 23        global $gantry;
 24        $theme_rel_path = "/html/mod_roknavmenu/themes/gantry-splitmenu";
 25        $this->theme_path = $gantry->templatePath . $theme_rel_path;
 26        $this->args['theme_path'] = $this->theme_path;
 27        $this->args['theme_rel_path'] = $gantry->templateUrl. $theme_rel_path;
 28        $this->args['theme_url'] = $this->args['theme_rel_path'];
 29    }
 30
 31    public function stageHeader()
 32    {
 33        global $gantry;
 34
 35        //don't include class_sfx on 3rd level menu
 36        $this->args['class_sfx'] =  (array_key_exists('startlevel', $this->args) && $this->args['startLevel']==1) ? '' : $this->args['class_sfx'];
 37        $this->activeid = (array_key_exists('splitmenu_fusion_enable_current_id', $this->args) && $this->args['splitmenu_fusion_enable_current_id']== 0) ? false : true;
 38
 39        JHtml::_('behavior.mootools');
 40        if ($this->isIe(6)) {
 41            $gantry->addScript(JURI::Root(true).'/modules/mod_roknavmenu/themes/fusion/js/sfhover.js');
 42        }
 43    }
 44
 45    function isIe($version = false)
 46    {
 47        $agent=$_SERVER['HTTP_USER_AGENT'];
 48        $found = strpos($agent,'MSIE ');
 49        if ($found) {
 50                if ($version) {
 51                    $ieversion = substr(substr($agent,$found+5),0,1);
 52                    if ($ieversion == $version) return true;
 53                    else return false;
 54                } else {
 55                    return true;
 56                }
 57
 58            } else {
 59                    return false;
 60            }
 61        if (stristr($agent, 'msie'.$ieversion)) return true;
 62        return false;
 63    }
 64
 65
 66    protected function renderItem(JoomlaRokMenuNode &$item, RokMenuNodeTree &$menu)
 67    {
 68
 69        $item_params = $item->getParams();
 70        //not so elegant solution to add subtext
 71        $item_subtext = $item_params->get('splitmenu_item_subtext','');
 72        if ($item_subtext=='') $item_subtext = false;
 73        else $item->addLinkClass('subtext');
 74        ?>
 75        <li <?php if($item->hasListItemClasses()) : ?>class="<?php echo $item->getListItemClasses()?>"<?php endif;?> <?php if($item->hasCssId() && $this->activeid):?>id="<?php echo $item->getCssId();?>"<?php endif;?>>
 76            <?php if ($item->getType() == 'menuitem') : ?>
 77                <a <?php if($item->hasLinkClasses()):?>class="<?php echo $item->getLinkClasses();?>"<?php endif;?> <?php if($item->hasLink()):?>href="<?php echo $item->getLink();?>"<?php endif;?> <?php if($item->hasTarget()):?>target="<?php echo $item->getTarget();?>"<?php endif;?> <?php if ($item->hasAttribute('onclick')): ?>onclick="<?php echo $item->getAttribute('onclick'); ?>"<?php endif; ?><?php if ($item->hasLinkAttribs()): ?> <?php echo $item->getLinkAttribs(); ?><?php endif; ?>>
 78                    <span>
 79                    <?php echo $item->getTitle();?>
 80                    <?php if (!empty($item_subtext)) :?>
 81                    <em><?php echo $item_subtext; ?></em>
 82                    <?php endif; ?>
 83                    <?php if ($item->getParent() == 0 && $item->hasChildren()): ?>
 84                    <span class="daddyicon"></span>
 85                    <?php endif; ?>
 86					<?php if ($item->getCssId()): ?>
 87					<div class="arrow-indicator"></div>
 88					<?php endif; ?>
 89                    </span>
 90                </a>
 91            <?php elseif($item->getType() == 'separator') : ?>
 92                <span <?php if($item->hasLinkClasses()):?>class="<?php echo $item->getLinkClasses();?> nolink"<?php endif;?>>
 93                    <span>
 94                    <?php echo $item->getTitle();?>
 95                    <?php if (!empty($item_subtext)) :?>
 96                    <em><?php echo $item_subtext; ?></em>
 97                    <?php endif; ?>
 98                    <?php if ($item->getParent() == 0 && $item->hasChildren()): ?>
 99                    <span class="daddyicon"></span>
100                    <?php endif; ?>
101                    </span>
102                </span>
103            <?php endif; ?>
104            <?php if ($item->hasChildren()): ?>
105            <ul class="level<?php echo intval($item->getLevel())+2; ?>">
106                <?php foreach ($item->getChildren() as $child) : ?>
107                    <?php $this->renderItem($child, $menu); ?>
108                <?php endforeach; ?>
109            </ul>
110            <?php endif; ?>
111        </li>
112        <?php
113    }
114
115
116    public function renderMenu(&$menu) {
117        ob_start();
118?>
119<?php if ($menu->getChildren()) : ?>
120<div class="rt-splitmenu">
121	<div class="rt-menubar">
122		<div class="rt-menubar2">
123		    <ul class="menu<?php echo $this->args['class_sfx']; ?> level1" <?php if(array_key_exists('tag_id',$this->args)):?><?php endif;?>>
124		        <?php foreach ($menu->getChildren() as $item) :  ?>
125		             <?php $this->renderItem($item, $menu); ?>
126		        <?php endforeach; ?>
127		    </ul>
128		</div>
129	</div>
130</div>
131<?php endif; ?>
132<?php
133        return ob_get_clean();
134    }
135}