Exemplo n.º 1
0
 function to_menu($channels, $structure, $sectionLevel = 0, $cumul = 0)
 {
     global $smarty;
     include_once 'lib/smarty_tiki/function.sefurl.php';
     $options = array();
     $cant = 0;
     if (empty($channels)) {
         return array('cant' => 0, 'data' => array());
     }
     foreach ($channels as $channel) {
         if (empty($channel['sub'])) {
             if (isset($options[$cant - 1]['sectionLevel'])) {
                 $level = $options[$cant - 1]['sectionLevel'];
                 while ($level-- > $sectionLevel) {
                     $options[] = array('type' => '-', 'sectionLevel' => $level);
                     ++$cant;
                 }
             }
         }
         $option['name'] = empty($channel['page_alias']) ? $channel['pageName'] : $channel['page_alias'];
         $option['type'] = empty($channel['sub']) ? 'o' : ($sectionLevel ? $sectionLevel : 's');
         $option['url'] = smarty_function_sefurl(array('page' => $channel['pageName'], 'structure' => $structure, 'page_ref_id' => $channel['page_ref_id'], 'sefurl' => 'n'), $smarty);
         $option['canonic'] = '((' . $channel['pageName'] . '))';
         $option['sefurl'] = smarty_function_sefurl(array('page' => $channel['pageName'], 'structure' => $structure, 'page_ref_id' => $channel['page_ref_id']), $smarty);
         $option['position'] = $cant + $cumul;
         $option['sectionLevel'] = $sectionLevel;
         $option['url'] = str_replace('&', '&', $option['url']);
         // as of Tiki 7 menu items get encoded later
         $option['sefurl'] = str_replace('&', '&', $option['sefurl']);
         $option['optionId'] = $channel['page_ref_id'];
         ++$cant;
         $options[] = $option;
         if (!empty($channel['sub'])) {
             $oSub = $this->to_menu($channel['sub'], $structure, $sectionLevel + 1, $cant + $cumul);
             $cant += $oSub['cant'];
             $options = array_merge($options, $oSub['data']);
         }
     }
     return array('data' => $options, 'cant' => $cant);
 }
Exemplo n.º 2
0
function breadcrumb_buildStructureTrail($structure_path, $cnt, $loclass, $showLinks = true)
{
    global $structure, $info, $page;
    $len = count($structure_path) + $cnt;
    TikiLib::lib('smarty')->loadPlugin('smarty_function_sefurl');
    // special sefurl only for structures - TODO merge with others
    if ($structure != 'y' || !$info) {
        return false;
    }
    $res = array();
    foreach ($structure_path as $crumb) {
        $cnt += 1;
        if ($len != $cnt) {
            $ret = '';
            if ($showLinks && ($crumb['pageName'] != $page || $crumb['page_alias'] != $page)) {
                $url = smarty_function_sefurl(array('page' => $crumb['pageName'], 'structure' => $structure_path[0]['pageName']), TikiLib::lib('smarty'));
                $ret .= '<a class="' . $loclass . '" accesskey="' . $cnt . '" href="' . $url . '">';
            }
            if ($crumb['page_alias']) {
                $ret .= $crumb['page_alias'];
            } else {
                $ret .= $crumb['pageName'];
            }
            if ($showLinks && ($crumb['pageName'] != $page || $crumb['page_alias'] != $page)) {
                $ret .= '</a>';
            }
            $res[] = $ret;
        } else {
            $res[] = '';
        }
    }
    return $res;
}