예제 #1
0
    protected function renderItem(JoomlaRokMenuNode &$item, RokMenuNodeTree &$menu)
    {
        global $gantry;
        $wrapper_css = '';
        $ul_css = '';
        $group_css = '';
        $item_params = new JParameter($item->getParams());
        //get columns count for children
        $columns = $item_params->get('fusion_columns', 1);
        //get custom image
        $custom_image = $item_params->get('fusion_customimage');
        $custom_class = $item_params->get('fusion_customclass');
        if ($custom_image && $custom_image != -1) {
            $item->addLinkClass('image');
        } else {
            $item->addLinkClass('bullet');
        }
        if ($custom_class != '') {
            $item->addListItemClass($custom_class);
        }
        $dropdown_width = $item_params->get('fusion_dropdown_width');
        $column_widths = explode(",", $item_params->get('fusion_column_widths'));
        if (trim($columns) == '') {
            $columns = 1;
        }
        if (trim($dropdown_width) == '') {
            $dropdown_width = 180;
        }
        $wrapper_css = ' style="width:' . trim($dropdown_width) . 'px;"';
        $col_total = 0;
        $cols_left = $columns;
        if (trim($column_widths[0] != '')) {
            for ($i = 0; $i < $columns; $i++) {
                if (isset($column_widths[$i])) {
                    $ul_css[] = ' style="width:' . trim($column_widths[$i]) . 'px;"';
                    $col_total += $column_widths[$i];
                    $cols_left--;
                } else {
                    $col_width = floor(intval((intval($dropdown_width) - $col_total) / $cols_left));
                    $ul_css[] = ' style="width:' . $col_width . 'px;"';
                }
            }
        } else {
            for ($i = 0; $i < $columns; $i++) {
                $col_width = floor(intval($dropdown_width) / $columns);
                $ul_css[] = ' style="width:' . $col_width . 'px;"';
            }
        }
        $grouping = $item_params->get('fusion_children_group');
        if ($grouping == 1) {
            $item->addListItemClass('grouped-parent');
        }
        $child_type = $item_params->get('fusion_children_type');
        $child_type = $child_type == '' ? 'menuitems' : $child_type;
        $distribution = $item_params->get('fusion_distribution');
        $manual_distribution = explode(",", $item_params->get('fusion_manual_distribution'));
        $modules = array();
        if ($child_type == 'modules') {
            $modules_id = $item_params->get('fusion_modules');
            $ids = is_array($modules_id) ? $modules_id : array($modules_id);
            foreach ($ids as $id) {
                if ($module = $this->getModule($id)) {
                    $modules[] = $module;
                }
            }
            $group_css = ' type-module';
        } elseif ($child_type == 'modulepos') {
            $modules_pos = $item_params->get('fusion_module_positions');
            $positions = is_array($modules_pos) ? $modules_pos : array($modules_pos);
            foreach ($positions as $pos) {
                $mod = $this->getModules($pos);
                $modules = array_merge($modules, $mod);
            }
            $group_css = ' type-module';
        }
        //not so elegant solution to add subtext
        $item_subtext = $item_params->get('fusion_item_subtext', '');
        if ($item_subtext == '') {
            $item_subtext = false;
        } else {
            $item->addLinkClass('subtext');
        }
        //sort out module children:
        if ($child_type != "menuitems") {
            $document =& JFactory::getDocument();
            $renderer = $document->loadRenderer('module');
            $params = array('style' => 'fusion');
            $mod_contents = array();
            foreach ($modules as $mod) {
                $mod_contents[] = $renderer->render($mod, $params);
            }
            $item->setChildren($mod_contents);
            $link_classes = explode(' ', $item->getLinkClasses());
            //replace orphan with daddy if needed
            if ($item->hasChildren() && in_array('orphan', $link_classes)) {
                $link_classes[array_search('orphan', $link_classes)] = 'daddy';
            }
            $item->setLinkClasses($link_classes);
        }
        ?>
        <li <?php 
        if ($item->hasListItemClasses()) {
            ?>
class="<?php 
            echo $item->getListItemClasses();
            ?>
"<?php 
        }
        ?>
 <?php 
        if ($item->hasCssId() && $this->activeid) {
            ?>
id="<?php 
            echo $item->getCssId();
            ?>
"<?php 
        }
        ?>
>
            <?php 
        if ($item->getType() == 'menuitem') {
            ?>
            	<?php 
            $urlCheck = JRoute::_($this->curPageURL($item->getLink()), true);
            if ($urlCheck) {
                $activeToTop = ' active-to-top';
            } else {
                $activeToTop = '';
            }
            ?>
                <a <?php 
            if ($item->hasLinkClasses()) {
                ?>
class="<?php 
                echo $item->getLinkClasses() . $activeToTop;
                ?>
"<?php 
            }
            ?>
 <?php 
            if ($item->hasLink()) {
                ?>
href="<?php 
                echo $item->getLink();
                ?>
"<?php 
            }
            ?>
 <?php 
            if ($item->hasTarget()) {
                ?>
target="<?php 
                echo $item->getTarget();
                ?>
"<?php 
            }
            ?>
 <?php 
            if ($item->hasAttribute('onclick')) {
                ?>
onclick="<?php 
                echo $item->getAttribute('onclick');
                ?>
"<?php 
            }
            if ($item->hasLinkAttribs()) {
                ?>
 <?php 
                echo $item->getLinkAttribs();
            }
            ?>
>
                    <span>
                    <?php 
            if ($custom_image && $custom_image != -1) {
                ?>
                        <img src="<?php 
                echo $gantry->templateUrl . "/images/icons/" . $custom_image;
                ?>
" alt="<?php 
                echo $custom_image;
                ?>
" />
                    <?php 
            }
            ?>
                    <?php 
            echo $item->getTitle();
            ?>
                    <?php 
            if (!empty($item_subtext)) {
                ?>
                    <em><?php 
                echo $item_subtext;
                ?>
</em>
                    <?php 
            }
            ?>
                    <?php 
            if ($item->getParent() == RokNavMenu::TOP_LEVEL_PARENT_ID && $item->hasChildren()) {
                ?>
                    <span class="daddyicon"></span>
                    <?php 
            }
            ?>
                    </span>
                </a>
            <?php 
        } elseif ($item->getType() == 'separator') {
            ?>
                <span <?php 
            if ($item->hasLinkClasses()) {
                ?>
class="<?php 
                echo $item->getLinkClasses();
                ?>
 nolink"<?php 
            }
            ?>
>
                    <span>
                        <?php 
            if ($custom_image && $custom_image != -1) {
                ?>
                            <img src="<?php 
                echo $gantry->templateUrl . "/images/icons/" . $custom_image;
                ?>
" alt="<?php 
                echo $custom_image;
                ?>
" />
                        <?php 
            }
            ?>
                    <?php 
            echo $item->getTitle();
            ?>
                    <?php 
            if (!empty($item_subtext)) {
                ?>
                    <em><?php 
                echo $item_subtext;
                ?>
</em>
                    <?php 
            }
            ?>
                    <?php 
            if ($item->getParent() == RokNavMenu::TOP_LEVEL_PARENT_ID && $item->hasChildren()) {
                ?>
                    <span class="daddyicon"></span>
                    <?php 
            }
            ?>
                    </span>
                </span>
            <?php 
        }
        ?>

            <?php 
        if ($item->hasChildren()) {
            ?>
                <?php 
            if ($grouping == 0 or $item->getLevel() == 0) {
                if ($distribution == 'inorder') {
                    $count = sizeof($item->getChildren());
                    $items_per_col = intval(ceil($count / $columns));
                    $children_cols = array_chunk($item->getChildren(), $items_per_col);
                } elseif ($distribution == 'manual') {
                    $children_cols = $this->array_fill($item->getChildren(), $columns, $manual_distribution);
                } else {
                    $children_cols = $this->array_chunkd($item->getChildren(), $columns);
                }
                $col_counter = 0;
                ?>
                    <div class="fusion-submenu-wrapper level<?php 
                echo intval($item->getLevel()) + 2;
                ?>
 primary-overlay-<?php 
                global $gantry;
                echo $gantry->get('primary-overlay');
                if ($columns > 1) {
                    echo ' columns' . $columns;
                }
                ?>
"<?php 
                echo $wrapper_css;
                ?>
>
                        <?php 
                foreach ($children_cols as $col) {
                    ?>

                        <ul class="level<?php 
                    echo intval($item->getLevel()) + 2;
                    ?>
"<?php 
                    echo $ul_css[$col_counter++];
                    ?>
>
                            <?php 
                    foreach ($col as $child) {
                        ?>
                                <?php 
                        if ($child_type == 'menuitems') {
                            ?>
                                    <?php 
                            $this->renderItem($child, $menu);
                            ?>
                                <?php 
                        } else {
                            ?>
                                    <li>
                                        <div class="fusion-modules item">
                                        <?php 
                            echo $child;
                            ?>
                                        </div>
                                    </li>
                                <?php 
                        }
                        ?>
                            <?php 
                    }
                    ?>
                        </ul>

                        <?php 
                }
                ?>
                        <div class="drop-bot"></div>
                    </div>
                <?php 
            } else {
                ?>
                    <div class="fusion-grouped<?php 
                echo $group_css;
                ?>
">
                        <ol>
                            <?php 
                foreach ($item->getChildren() as $child) {
                    ?>
                                <?php 
                    if ($child_type == 'menuitems') {
                        ?>
                                    <?php 
                        $this->renderItem($child, $menu);
                        ?>
                                <?php 
                    } else {
                        ?>
                                    <li>
                                        <div class="fusion-modules item">
                                        <?php 
                        echo $child;
                        ?>
                                        </div>
                                    </li>
                                <?php 
                    }
                    ?>
                            <?php 
                }
                ?>
                        </ol>
                    </div>

                <?php 
            }
            ?>
            <?php 
        }
        ?>
        </li>
        <?php 
    }
예제 #2
0
    protected function renderItem(JoomlaRokMenuNode &$item, RokMenuNodeTree &$menu)
    {
        /** @var $gantry Gantry */
        global $gantry;
        $wrapper_css = '';
        $ul_css = '';
        $group_css = '';
        $item_params = $item->getParams();
        //get columns count for children
        $columns = $item_params->get('dropdown_columns', 1);
        //get custom image
        $custom_image = $item_params->get('dropdown_customimage');
        //get the custom icon
        $custom_icon = $item_params->get('dropdown_customicon');
        //get the custom class
        $custom_class = $item_params->get('dropdown_customclass');
        //add default link class
        $item->addLinkClass('item');
        if ($custom_image && $custom_image != -1) {
            $item->addLinkClass('image');
        }
        if ($custom_icon && $custom_icon != -1) {
            $item->addLinkClass('icon');
        }
        if ($custom_class != '') {
            $item->addListItemClass($custom_class);
        }
        $dropdown_width = intval(trim($item_params->get('dropdown_dropdown_width')));
        $column_widths = explode(",", $item_params->get('dropdown_column_widths'));
        if (trim($columns) == '') {
            $columns = 1;
        }
        if ($dropdown_width == 0) {
            $dropdown_width = 180;
        }
        $wrapper_css = ' style="width:' . $dropdown_width . 'px;"';
        $col_total = 0;
        $cols_left = $columns;
        if (trim($column_widths[0] != '')) {
            for ($i = 0; $i < $columns; $i++) {
                if (isset($column_widths[$i])) {
                    $ul_css[] = ' style="width:' . trim(intval($column_widths[$i])) . 'px;"';
                    $col_total += intval($column_widths[$i]);
                    $cols_left--;
                } else {
                    $col_width = floor(intval((intval($dropdown_width) - $col_total) / $cols_left));
                    $ul_css[] = ' style="width:' . $col_width . 'px;"';
                }
            }
        } else {
            for ($i = 0; $i < $columns; $i++) {
                $col_width = floor(intval($dropdown_width) / $columns);
                $ul_css[] = ' style="width:' . $col_width . 'px;"';
            }
        }
        $grouping = $item_params->get('dropdown_children_group');
        if ($grouping == 1) {
            $item->addListItemClass('grouped');
        }
        $child_type = $item_params->get('dropdown_children_type');
        $child_type = $child_type == '' ? 'menuitems' : $child_type;
        $distribution = $item_params->get('dropdown_distribution');
        $manual_distribution = explode(",", $item_params->get('dropdown_manual_distribution'));
        $modules = array();
        if ($child_type == 'modules') {
            $modules_id = $item_params->get('dropdown_modules');
            $ids = is_array($modules_id) ? $modules_id : array($modules_id);
            foreach ($ids as $id) {
                if ($module = $this->getModule($id)) {
                    $modules[] = $module;
                }
            }
            $group_css = ' type-module';
        } elseif ($child_type == 'modulepos') {
            $modules_pos = $item_params->get('dropdown_module_positions');
            $positions = is_array($modules_pos) ? $modules_pos : array($modules_pos);
            foreach ($positions as $pos) {
                $mod = $this->getModules($pos);
                $modules = array_merge($modules, $mod);
            }
            $group_css = ' type-module';
        }
        //not so elegant solution to add subtext
        $item_subtext = $item_params->get('dropdown_item_subtext', '');
        if ($item_subtext == '') {
            $item_subtext = false;
        } else {
            $item->addLinkClass('subtext');
        }
        //sort out module children:
        if ($child_type != "menuitems") {
            $document = JFactory::getDocument();
            $renderer = $document->loadRenderer('module');
            $params = array('style' => 'dropdown');
            $mod_contents = array();
            foreach ($modules as $mod) {
                $mod_contents[] = $renderer->render($mod, $params);
            }
            $item->setChildren($mod_contents);
            $link_classes = explode(' ', $item->getLinkClasses());
            $item->setLinkClasses($link_classes);
        }
        if ($item->getType() != 'menuitem') {
            $item->setLink('javascript:void(0);');
        }
        ?>
        <li <?php 
        if ($item->hasListItemClasses()) {
            ?>
class="<?php 
            echo $item->getListItemClasses();
            ?>
"<?php 
        }
        ?>
 <?php 
        if ($item->hasCssId() && $this->activeid) {
            ?>
id="<?php 
            echo $item->getCssId();
            ?>
"<?php 
        }
        ?>
>

            <a <?php 
        if ($item->hasLinkClasses()) {
            ?>
class="<?php 
            echo $item->getLinkClasses();
            ?>
"<?php 
        }
        ?>
 <?php 
        if ($item->hasLink()) {
            ?>
href="<?php 
            echo $item->getLink();
            ?>
"<?php 
        }
        ?>
 <?php 
        if ($item->hasTarget()) {
            ?>
target="<?php 
            echo $item->getTarget();
            ?>
"<?php 
        }
        ?>
 <?php 
        if ($item->hasAttribute('onclick')) {
            ?>
onclick="<?php 
            echo $item->getAttribute('onclick');
            ?>
"<?php 
        }
        if ($item->hasLinkAttribs()) {
            ?>
 <?php 
            echo $item->getLinkAttribs();
        }
        ?>
>

                <?php 
        if ($custom_image && $custom_image != -1) {
            ?>
                    <img class="menu-image" src="<?php 
            echo $gantry->templateUrl . "/images/icons/" . $custom_image;
            ?>
" alt="<?php 
            echo $custom_image;
            ?>
" />
                <?php 
        }
        ?>
                <?php 
        if ($custom_icon && $custom_icon != -1) {
            echo '<i class="' . $custom_icon . '">' . $item->getTitle() . '</i>';
        } else {
            echo $item->getTitle();
        }
        if (!empty($item_subtext)) {
            echo '<em>' . $item_subtext . '</em>';
        }
        ?>
                <?php 
        // Comment this out if you don't need a 1px bottom border fix
        if ($item->hasChildren()) {
            ?>
                <span class="border-fixer"></span>
                <?php 
        }
        ?>
            </a>


            <?php 
        if ($item->hasChildren()) {
            ?>

                <?php 
            if ($grouping == 0 or $item->getLevel() == 0) {
                if ($distribution == 'inorder') {
                    $count = sizeof($item->getChildren());
                    $items_per_col = intval(ceil($count / $columns));
                    $children_cols = array_chunk($item->getChildren(), $items_per_col);
                } elseif ($distribution == 'manual') {
                    $children_cols = $this->array_fill($item->getChildren(), $columns, $manual_distribution);
                } else {
                    $children_cols = $this->array_chunkd($item->getChildren(), $columns);
                }
                $col_counter = 0;
                ?>
                    <div class="dropdown <?php 
                if ($item->getLevel() > 0) {
                    echo 'flyout ';
                }
                echo 'columns-' . $columns . ' ';
                ?>
"<?php 
                echo $wrapper_css;
                ?>
>
                        <?php 
                foreach ($children_cols as $col) {
                    ?>
                        <div class="column col<?php 
                    echo intval($col_counter) + 1;
                    ?>
" <?php 
                    echo $ul_css[$col_counter++];
                    ?>
>
                            <ul class="l<?php 
                    echo $item->getLevel() + 2;
                    ?>
">
                                <?php 
                    foreach ($col as $child) {
                        ?>
                                    <?php 
                        if ($child_type == 'menuitems') {
                            ?>
                                        <?php 
                            $this->renderItem($child, $menu);
                            ?>
                                    <?php 
                        } else {
                            ?>
                                        <li class="modules">
                                            <div class="module-content">
                                                <?php 
                            echo $child;
                            ?>
                                            </div>
                                        </li>
                                    <?php 
                        }
                        ?>
                                <?php 
                    }
                    ?>
                            </ul>
                        </div>
                        <?php 
                }
                ?>
                    </div>

                <?php 
            } else {
                ?>

                    <ol class="<?php 
                echo $group_css;
                ?>
">
                        <?php 
                foreach ($item->getChildren() as $child) {
                    ?>
                            <?php 
                    if ($child_type == 'menuitems') {
                        ?>
                                <?php 
                        $this->renderItem($child, $menu);
                        ?>
                            <?php 
                    } else {
                        ?>
                                <li class="modules">
                                    <div class="module-content">
                                        <?php 
                        echo $child;
                        ?>
                                    </div>
                                </li>
                            <?php 
                    }
                    ?>
                        <?php 
                }
                ?>
                    </ol>

                <?php 
            }
            ?>
            <?php 
        }
        ?>
        </li>
        <?php 
    }