[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 if (!isset($gCms)) exit; 3 4 debug_buffer('', 'Start of Menu Manager Display'); 5 6 $hm =& $gCms->GetHierarchyManager(); 7 8 $usefile = true; 9 $tpl_name = 'simple_navigation.tpl'; 10 11 if (isset($params['template']) && $params['template'] != '') 12 { 13 $tpl_name = $params['template']; 14 if (!endswith($tpl_name, '.tpl')) 15 { 16 $usefile = false; 17 } 18 } 19 20 $mdid = md5($gCms->variables['content_id'].implode('|', $params)); 21 22 $cached = false; 23 $origdepth = 0; 24 /* 25 if ($usefile) 26 $cached = $this->IsFileTemplateCached($tpl_name, $mdid, $gCms->variables['pageinfo']->content_last_modified_date); 27 else 28 $cached = $this->IsDatabaseTemplateCached($tpl_name, $mdid, $gCms->variables['pageinfo']->content_last_modified_date); 29 */ 30 31 if (!$cached) 32 { 33 $nodelist = array(); 34 $count = 0; 35 $getchildren = true; 36 37 $rootnode = null; 38 39 $prevdepth = 1; 40 41 if (isset($params['start_page']) || isset($params['start_element'])) 42 { 43 if (isset($params['start_page'])) 44 $rootnode =& $hm->sureGetNodeByAlias($params['start_page']); 45 else 46 $rootnode =& $hm->getNodeByHierarchy($params['start_element']); 47 48 if (isset($rootnode)) 49 { 50 $content =& $rootnode->GetContent(); 51 if (isset($content)) 52 { 53 if (isset($params['show_root_siblings']) && $params['show_root_siblings'] == '1') 54 { 55 if ($rootnode->getLevel() == 0) 56 { 57 $rootnode =& $hm->getRootNode(); 58 $prevdepth = 1; 59 } 60 else 61 { 62 #Set original depth first before getting parent node 63 #This is slightly hackish, but it works nicely 64 #+1 and +2 fix HM changes of root node level 65 #even more hackish ;) 66 $origdepth = $rootnode->getLevel()+1; 67 $rootnode =& $rootnode->getParentNode(); 68 $prevdepth = $rootnode->getLevel()+2; 69 } 70 } 71 else 72 { 73 if ($content->Active() && ($content->ShowInMenu() || ($params['show_all'] == 1))) 74 { 75 $prevdepth = count(explode('.', $content->Hierarchy())); 76 $this->FillNode($content, $rootnode, $nodelist, $gCms, $count, $prevdepth, $prevdepth); 77 if (isset($params['number_of_levels']) && $params['number_of_levels'] == '1') 78 $getchildren = false; 79 } 80 } 81 } 82 } 83 } 84 else if (isset($params['start_level']) && intval($params['start_level']) > 1) 85 { 86 $curnode =& $hm->sureGetNodeById($gCms->variables['content_id']); 87 if (isset($curnode)) 88 { 89 $curcontent =& $curnode->GetContent(); 90 $properparentpos = $this->nthPos($curcontent->Hierarchy() . '.', '.', intval($params['start_level']) - 1); 91 if ($properparentpos > -1) 92 { 93 $prevdepth = intval($params['start_level']); 94 $rootnode =& $hm->getNodeByHierarchy(substr($curcontent->Hierarchy(), 0, $properparentpos)); 95 } 96 } 97 } 98 else if (isset($params['items'])) 99 { 100 $items = explode(',', $params['items']); 101 if (count($items) > 0) 102 { 103 reset($items); 104 while (list($key) = each($items)) 105 { 106 $oneitem =& $items[$key]; 107 $curnode =& $hm->sureGetNodeByAlias(trim($oneitem)); 108 if ($curnode) 109 { 110 $curcontent =& $curnode->GetContent(); 111 if (isset($curcontent)) 112 { 113 $prevdepth = 1; 114 $newnode =& $this->FillNode($curcontent, $curnode, $nodelist, $gCms, $count, $prevdepth, 1); 115 //$newnode->depth = 1; 116 //$newnode->prevdepth = 1; 117 } 118 } 119 } 120 121 #PHP 4 is stupid. Go through and reset all depths and prevdepths to 1 122 reset($nodelist); 123 while (list($key) = each($nodelist)) 124 { 125 $onenode =& $nodelist[$key]; 126 $onenode->depth = 1; 127 $onenode->prevdepth = 1; 128 } 129 } 130 } 131 else 132 { 133 $rootnode =& $hm->getRootNode(); 134 $prevdepth = 1; 135 } 136 137 $showparents = array(); 138 139 if (isset($params['collapse']) && $params['collapse'] == '1') 140 { 141 $newpos = ''; 142 if (isset($gCms->variables['friendly_position'])) 143 { 144 foreach (explode('.', $gCms->variables['friendly_position']) as $level) 145 { 146 $newpos .= $level . '.'; 147 $showparents[] = $newpos; 148 } 149 } 150 } 151 152 #See if origdepth was ever set... if not, then get it from the prevdepth set earlier 153 if ($origdepth == 0) 154 $origdepth = $prevdepth; 155 156 if (isset($rootnode) && $getchildren) 157 $this->GetChildNodes($rootnode, $nodelist, $gCms, $prevdepth, $count, $params, $origdepth, $showparents); 158 159 if (count($nodelist) > 0) 160 { 161 $smarty =& $this->smarty; 162 $smarty->assign('count', count($nodelist)); 163 $smarty->assign_by_ref('nodelist', $nodelist); 164 if ($usefile) 165 echo $this->ProcessTemplate($tpl_name, $mdid, false, $gCms->variables['content_id']); 166 else 167 echo $this->ProcessTemplateFromDatabase($tpl_name, $mdid, false, $gCms->variables['content_id']); 168 } 169 } 170 /* 171 else 172 { 173 if ($usefile) 174 echo $this->ProcessTemplate($tpl_name, $mdid, true, $gCms->variables['content_id']); 175 else 176 echo $this->ProcessTemplateFromDatabase($tpl_name, $mdid, true, $gCms->variables['content_id']); 177 } 178 */ 179 debug_buffer('', 'End of Menu Manager Display'); 180 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |