コード例 #1
0
ファイル: function.menu.php プロジェクト: jkimdon/cohomeals
function smarty_function_menu($params, $smarty)
{
    global $headerlib, $prefs;
    $default = array('css' => 'y');
    if (isset($params['params'])) {
        $params = array_merge($params, $params['params']);
        unset($params['params']);
    }
    $params = array_merge($default, $params);
    extract($params, EXTR_SKIP);
    if (empty($link_on_section) || $link_on_section == 'y') {
        $smarty->assign('link_on_section', 'y');
    } else {
        $smarty->assign('link_on_section', 'n');
    }
    if (empty($translate)) {
        $translate = 'y';
    }
    $smarty->assignByRef('translate', $translate);
    if (empty($menu_cookie)) {
        $menu_cookie = 'y';
    }
    $smarty->assignByRef('menu_cookie', $menu_cookie);
    if (empty($drilldown)) {
        $drilldown = 'n';
    }
    if ($css !== 'n' && $prefs['feature_cssmenus'] == 'y' && $drilldown != 'y') {
        static $idCssmenu = 0;
        if (empty($type)) {
            $type = 'vert';
        }
        $css = "cssmenu_{$type}.css";
        $headerlib->add_jsfile('lib/menubuilder/menu.js');
        $tpl = 'tiki-user_cssmenu.tpl';
        $smarty->assign('menu_type', $type);
        if (!isset($css_id)) {
            //adding $css_id parameter to customize menu id and prevent automatic id renaming when a menu is removed
            $smarty->assign('idCssmenu', $idCssmenu++);
        } else {
            $smarty->assign('idCssmenu', $css_id);
        }
    } elseif ($drilldown == 'y') {
        $tpl = 'tiki-user_drilldownmenu.tpl';
    } else {
        $tpl = 'tiki-user_menu.tpl';
    }
    list($menu_info, $channels) = get_menu_with_selections($params);
    $smarty->assign('menu_channels', $channels['data']);
    $smarty->assign('menu_info', $menu_info);
    $smarty->assign('escape_menu_labels', $prefs['menus_item_names_raw'] === 'n' && isset($menu_info['parse']) && $menu_info['parse'] === 'n');
    $data = $smarty->fetch($tpl);
    $menulib = TikiLib::lib('menu');
    return $menulib->clean_menu_html($data);
}
コード例 #2
0
ファイル: function.menu.php プロジェクト: rjsmelo/tiki
function smarty_function_menu($params, $smarty)
{
    global $prefs;
    $headerlib = TikiLib::lib('header');
    $default = array('css' => 'y');
    if (isset($params['params'])) {
        $params = array_merge($params, $params['params']);
        unset($params['params']);
    }
    $params = array_merge($default, $params);
    extract($params, EXTR_SKIP);
    if ($prefs['javascript_enabled'] !== 'y') {
        $params['css'] = 'y';
        $params['bootstrap'] = 'n';
        $params['type'] = 'horiz';
    }
    if (empty($link_on_section) || $link_on_section == 'y') {
        $smarty->assign('link_on_section', 'y');
    } else {
        $smarty->assign('link_on_section', 'n');
    }
    if (empty($translate)) {
        $translate = 'y';
    }
    $smarty->assignByRef('translate', $translate);
    if (empty($menu_cookie)) {
        $menu_cookie = 'y';
    }
    $smarty->assignByRef('menu_cookie', $menu_cookie);
    if (empty($drilldown)) {
        $drilldown = 'n';
    }
    if ($params['css'] !== 'n' && $prefs['feature_cssmenus'] == 'y') {
        static $idCssmenu = 0;
        if (empty($params['type'])) {
            $params['type'] = 'vert';
        }
        $headerlib->add_jsfile('lib/menubuilder/menu.js');
        $tpl = 'tiki-user_cssmenu.tpl';
        $smarty->assign('menu_type', $params['type']);
        if (!isset($css_id)) {
            //adding $css_id parameter to customize menu id and prevent automatic id renaming when a menu is removed
            $smarty->assign('idCssmenu', $idCssmenu++);
        } else {
            $smarty->assign('idCssmenu', $css_id);
        }
        if ($drilldown == 'y') {
            $smarty->assign('drilldownmenu', $drilldown);
        }
    } else {
        $tpl = 'tiki-user_menu.tpl';
    }
    list($menu_info, $channels) = get_menu_with_selections($params);
    $smarty->assign('menu_channels', $channels['data']);
    $smarty->assign('menu_info', $menu_info);
    if (isset($params['bootstrap']) && $params['bootstrap'] !== 'n') {
        $structured = array();
        $activeSection = null;
        foreach ($channels['data'] as $element) {
            if ($element['type'] == 's') {
                if ($activeSection) {
                    $structured[] = $activeSection;
                }
                $activeSection = $element;
                $activeSection['children'] = array();
            } elseif ($element['type'] == 'o') {
                if ($activeSection) {
                    $activeSection['children'][] = $element;
                } else {
                    $structured[] = $element;
                }
            } elseif ($element['type'] == '-') {
                if ($activeSection) {
                    $structured[] = $activeSection;
                }
                $activeSection = null;
            }
        }
        if ($activeSection) {
            $structured[] = $activeSection;
        }
        $smarty->assign('list', $structured);
        switch ($params['bootstrap']) {
            case 'navbar':
                return $smarty->fetch('bootstrap_menu_navbar.tpl');
            case 'y':
                if (isset($params['type']) && $params['type'] == "horiz") {
                    return $smarty->fetch('bootstrap_menu_navbar.tpl');
                } else {
                    return $smarty->fetch('bootstrap_menu.tpl');
                }
            default:
                return $smarty->fetch('bootstrap_menu.tpl');
        }
    }
    $data = $smarty->fetch($tpl);
    $menulib = TikiLib::lib('menu');
    return $menulib->clean_menu_html($data);
}
コード例 #3
0
ファイル: breadcrumblib.php プロジェクト: linuxwhy/tiki-1
/**
 * @param $crumbs
 * @param $menuId
 * @param null $startLevel
 * @param null $stopLevel
 * @return array
 */
function breadcrumb_buildMenuCrumbs($crumbs, $menuId, $startLevel = null, $stopLevel = null)
{
    include_once 'lib/smarty_tiki/function.menu.php';
    list($menu_info, $menuOptions) = get_menu_with_selections(array('id' => $menuId));
    $newCrumbs = array();
    if (count($crumbs) > 0) {
        $newCrumbs[] = $crumbs[0];
    }
    $level = 0;
    $foundSelected = false;
    foreach ($menuOptions['data'] as $option) {
        if (!empty($option['selectedAscendant']) || !empty($option['selected'])) {
            $foundSelected = true;
            if ($startLevel === null || $level >= $startLevel) {
                if ($stopLevel === null || $level <= $stopLevel) {
                    $newCrumbs[] = new Breadcrumb($option['name'], '', $option['sefurl']);
                }
            }
            $level++;
        }
    }
    if (!$foundSelected && count($crumbs) > 1) {
        $newCrumbs[] = $crumbs[1];
    }
    return $newCrumbs;
}