[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 #CMS - CMS Made Simple 3 #(c)2004 by Ted Kulp (wishy@users.sf.net) 4 #This project's homepage is: http://cmsmadesimple.sf.net 5 # 6 #This program is free software; you can redistribute it and/or modify 7 #it under the terms of the GNU General Public License as published by 8 #the Free Software Foundation; either version 2 of the License, or 9 #(at your option) any later version. 10 # 11 #This program is distributed in the hope that it will be useful, 12 #but WITHOUT ANY WARRANTY; without even the implied warranty of 13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 #GNU General Public License for more details. 15 #You should have received a copy of the GNU General Public License 16 #along with this program; if not, write to the Free Software 17 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 # 19 20 function smarty_cms_function_breadcrumbs($params, &$smarty) 21 { 22 23 global $gCms; 24 $manager = &$gCms->GetHierarchyManager(); 25 26 $thispage = $gCms->variables['content_id']; 27 28 $trail = ""; 29 30 #Check if user has specified a delimiter, otherwise use default 31 if (isset($params['delimiter'])) { 32 $delimiter = $params['delimiter']; 33 } else { 34 $delimiter = ">>"; 35 } 36 37 #Check if user has requested an initial delimiter 38 if (isset($params['initial'])) { 39 if ($params['initial'] == "1") { 40 $trail .= $delimiter . " "; 41 } 42 } 43 44 $root='##ROOT_NODE##'; 45 #Check if user has requested the list to start with a specific page 46 if (isset($params['root'])) { 47 $root = $params['root']; 48 } 49 $root_url=''; 50 #Check if user has requested to overrided the root URL 51 if (isset($params['root_url'])) { 52 $root_url = $params['root_url']; 53 } 54 55 56 $endNode = &$manager->sureGetNodeById($thispage); 57 58 # build path 59 if (isset($endNode)) 60 { 61 $content =& $endNode->getContent(); 62 $path=array($endNode); 63 $currentNode = &$endNode->getParentNode(); 64 while (isset($currentNode) && $currentNode->getLevel() >= 0) 65 { 66 $content = &$currentNode->getContent(); 67 if (isset($content)) 68 { 69 //Add current node to the path and then check to see if 70 //current node is the set root 71 //as long as it's not hidden 72 if( $content->ShowInMenu() && $content->Active() ) 73 { 74 $path[] = $currentNode; 75 } 76 if (strtolower($content->Alias())!=strtolower($root)) 77 { 78 //Get the parent node and loop 79 $currentNode = &$currentNode->getParentNode(); 80 } 81 else 82 { 83 //No need to get the parent node -- we're the set root already 84 break; 85 } 86 } 87 else 88 { 89 //There are more serious problems here, dump out while we can 90 break; 91 } 92 } 93 94 if ($root!='##ROOT_NODE##') { 95 # check if the last added is root. if not, add id 96 $currentNode = &$manager->sureGetNodeByAlias($root); 97 if (isset($currentNode)) 98 { 99 $content = &$currentNode->getContent(); 100 if (isset($content) && (strtolower($content->Alias()) == strtolower($root))) 101 { 102 $node = &$manager->sureGetNodeByAlias($root); 103 if (isset($node)) { 104 $content = &$node->getContent(); 105 if ($content->Id()!=$thispage) 106 $path[] = $node; # do not add if this is the current page 107 } 108 } 109 } 110 } 111 $classid=isset($params['classid'])?(' class="' . $params['classid'] . '"'):''; 112 $currentclassid=isset($params['currentclassid'])?(' class="' . $params['currentclassid'] . '"'):''; 113 # now create the trail (by iterating through the path we built, backwards) 114 for ($i=count($path)-1;$i>=0;$i--) { 115 $node = &$path[$i]; 116 if (isset($node)) 117 { 118 $onecontent = &$node->getContent(); 119 if ($onecontent->Id() != $thispage && $onecontent->Type() != 'seperator') { 120 if (($onecontent->getURL() != "") && ($onecontent->Type() != 'sectionheader')) { 121 if ($onecontent->DefaultContent() && false == empty($root_url)) 122 { 123 $trail .= '<a href="' . $root_url . '"'; 124 } 125 else 126 { 127 $trail .= '<a href="' . $onecontent->getURL() . '"'; 128 } 129 $trail .= $classid; 130 $trail .= '>'; 131 $trail .= cms_htmlentities($onecontent->MenuText()!=''?$onecontent->MenuText():$onecontent->Name()); 132 $trail .= '</a> '; 133 } else { 134 $trail .= "<span $classid>"; 135 $trail .= cms_htmlentities($onecontent->MenuText()!=''?$onecontent->MenuText():$onecontent->Name()); 136 $trail .= '</span>'; 137 $trail .= ' '; 138 } 139 $trail .= $delimiter . ' '; 140 } else { 141 if (isset($params['currentclassid'])) { 142 $trail .= "<span $currentclassid>"; 143 } else { 144 $trail .= '<span class="lastitem">'; 145 } 146 $trail .= cms_htmlentities($onecontent->MenuText()!=''?$onecontent->MenuText():$onecontent->Name()); 147 if (isset($params['currentclassid'])) { 148 $trail .= '</span>'; 149 } else { 150 $trail .= '</span>'; 151 } 152 } 153 } 154 } 155 } 156 157 if (isset($params['starttext']) && $params['starttext'] != '') 158 { 159 $trail = $params['starttext'] . ': ' . $trail; 160 } 161 162 return $trail; 163 164 } 165 166 function smarty_cms_help_function_breadcrumbs() { 167 // tdh added the classid help text 168 ?> 169 <h3>What does this do?</h3> 170 <p>Prints a breadcrumb trail .</p> 171 <h3>How do I use it?</h3> 172 <p>Just insert the tag into your template/page like: <code>{breadcrumbs}</code></p> 173 <h3>What parameters does it take?</h3> 174 <p> 175 <ul> 176 <li><em>(optional)</em> <tt>delimiter</tt> - Text to seperate entries in the list (default ">>").</li> 177 <li><em>(optional)</em> <tt>initial</tt> - 1/0 If set to 1 start the breadcrumbs with a delimiter (default 0).</li> 178 <li><em>(optional)</em> <tt>root</tt> - Page alias of a page you want to always appear as the first page in 179 the list. Can be used to make a page (e.g. the front page) appear to be the root of everything even though it is not.</li> 180 <li><em>(optional)</em> <tt>root_url</tt> - Override the URL of the root page. Useful for making link be to '/' instead of '/home/'. This requires that the root page be set as the default page.</li> 181 182 <li><em>(optional)</em> <tt>classid</tt> - The CSS class for the non current page names, i.e. the first n-1 pages in the list. If the name is a link it is added to the <a href> tags, otherwise it is added to the <span> tags.</li> 183 <li><em>(optional)</em> <tt>currentclassid</tt> - The CSS class for the <span> tag surrounding the current page name.</li> 184 <li><em>(optional)</em> <tt>starttext</tt> - Text to append to the front of the breadcrumbs list, something like "You are here".</li> 185 </ul> 186 </p> 187 <?php 188 } 189 190 function smarty_cms_about_function_breadcrumbs() { 191 ?> 192 <p>Author: Marcus Deglos <<a href="mailto:md@zioncore.com">md@zioncore.com</a>></p> 193 <p>Version: 1.7</p> 194 <p> 195 Change History:<br/> 196 1.1 - Modified to use new content rewrite (wishy)<br /> 197 1.2 - Added parameters: delimiter, initial, and root (arl)<br /> 198 1.3 - Added parameter: classid (tdh / perl4ever)<br /> 199 1.4 - Added parameter currentclassid and fixed some bugs (arl)<br /> 200 1.5 - Modified to use new hierarchy manager<br /> 201 1.6 - Modified to skip any parents that are marked to be "not shown in menu" except for root<br /> 202 1.7 - Added root_url parameter (elijahlofgren)<br /> 203 </p> 204 <?php 205 } 206 # vim:ts=4 sw=4 noet 207 ?>
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 |