[ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * @version $Id: pathway.php 5750 2006-11-12 22:12:52Z akede $ 4 * @package Joomla 5 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved. 6 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php 7 * Joomla! is free software. This version may have been modified pursuant 8 * to the GNU General Public License, and as distributed it includes or 9 * is derivative of works licensed under the GNU General Public License or 10 * other free or open source software licenses. 11 * See COPYRIGHT.php for copyright notices and details. 12 */ 13 14 // no direct access 15 defined( '_VALID_MOS' ) or die( 'Restricted access' ); 16 17 function pathwayMakeLink( $id, $name, $link, $parent ) { 18 $mitem = new stdClass(); 19 $mitem->id = $id; 20 $mitem->name = html_entity_decode( $name ); 21 $mitem->link = $link; 22 $mitem->parent = $parent; 23 $mitem->type = ''; 24 25 return $mitem; 26 } 27 28 /** 29 * Outputs the pathway breadcrumbs 30 * @param database A database connector object 31 * @param int The db id field value of the current menu item 32 */ 33 function showPathway( $Itemid ) { 34 global $database, $option, $task, $mainframe, $mosConfig_absolute_path, $mosConfig_live_site, $my; 35 36 // the the whole menu array and index the array by the id 37 $query = "SELECT id, name, link, parent, type, menutype, access" 38 . "\n FROM #__menu" 39 . "\n WHERE published = 1" 40 . "\n AND access <= " . (int) $my->gid 41 . "\n ORDER BY menutype, parent, ordering" 42 ; 43 $database->setQuery( $query ); 44 $mitems = $database->loadObjectList( 'id' ); 45 46 // get the home page 47 $home_menu = new mosMenu( $database ); 48 foreach( $mitems as $mitem ) { 49 if ( $mitem->menutype == 'mainmenu' ) { 50 $home_menu = $mitem; 51 break; 52 } 53 } 54 55 $optionstring = ''; 56 if ( isset( $_SERVER['REQUEST_URI'] ) ) { 57 $optionstring = $_SERVER['REQUEST_URI']; 58 } else if ( isset( $_SERVER['QUERY_STRING'] ) ) { 59 $optionstring = $_SERVER['QUERY_STRING']; 60 } 61 62 // are we at the home page or not 63 $homekeys = array_keys( $mitems ); 64 $home = @$mitems[$home_menu->id]->name; 65 $path = ''; 66 67 // this is a patch job for the frontpage items! aje 68 if ($Itemid == $home_menu->id) { 69 switch ($option) { 70 case 'content': 71 $id = intval( mosGetParam( $_REQUEST, 'id', 0 ) ); 72 73 if ($task=='blogsection'){ 74 $query = "SELECT title, id" 75 . "\n FROM #__sections" 76 . "\n WHERE id = " . (int) $id 77 ; 78 } else if ( $task=='blogcategory' ) { 79 $query = "SELECT title, id" 80 . "\n FROM #__categories" 81 . "\n WHERE id = " . (int) $id 82 ; 83 } else { 84 $query = "SELECT title, catid, id" 85 . "\n FROM #__content" 86 . "\n WHERE id = " . (int) $id 87 ; 88 } 89 $database->setQuery( $query ); 90 91 $row = null; 92 $database->loadObject( $row ); 93 94 $id = max( array_keys( $mitems ) ) + 1; 95 96 // add the content item 97 $mitem2 = pathwayMakeLink( 98 $Itemid, 99 $row->title, 100 '', 101 1 102 ); 103 $mitems[$id] = $mitem2; 104 $Itemid = $id; 105 106 $home = '<a href="'. sefRelToAbs( 'index.php' ) .'" class="pathway">'. $home .'</a>'; 107 break; 108 } 109 } 110 111 // breadcrumbs for content items 112 switch( @$mitems[$Itemid]->type ) { 113 // menu item = List - Content Section 114 case 'content_section': 115 $id = intval( mosGetParam( $_REQUEST, 'id', 0 ) ); 116 117 switch ($task) { 118 case 'category': 119 if ($id) { 120 $query = "SELECT title, id" 121 . "\n FROM #__categories" 122 . "\n WHERE id = " . (int) $id 123 . "\n AND access <= " . (int) $my->id 124 ; 125 $database->setQuery( $query ); 126 $title = $database->loadResult(); 127 128 $id = max( array_keys( $mitems ) ) + 1; 129 $mitem = pathwayMakeLink( 130 $id, 131 $title, 132 'index.php?option='. $option .'&task='. $task .'&id='. $id .'&Itemid='. $Itemid, 133 $Itemid 134 ); 135 136 $mitems[$id] = $mitem; 137 $Itemid = $id; 138 } 139 break; 140 141 case 'view': 142 if ($id) { 143 // load the content item name and category 144 $query = "SELECT title, catid, id, access" 145 . "\n FROM #__content" 146 . "\n WHERE id = " . (int) $id 147 ; 148 $database->setQuery( $query ); 149 $row = null; 150 $database->loadObject( $row ); 151 152 // load and add the category 153 $query = "SELECT c.title AS title, s.id AS sectionid, c.id AS id, c.access AS cat_access" 154 . "\n FROM #__categories AS c" 155 . "\n LEFT JOIN #__sections AS s" 156 . "\n ON c.section = s.id" 157 . "\n WHERE c.id = " . (int) $row->catid 158 . "\n AND c.access <= " . (int) $my->id 159 ; 160 $database->setQuery( $query ); 161 $result = $database->loadObjectList(); 162 163 $title = $result[0]->title; 164 $sectionid = $result[0]->sectionid; 165 166 $id = max( array_keys( $mitems ) ) + 1; 167 $mitem1 = pathwayMakeLink( 168 $Itemid, 169 $title, 170 'index.php?option='. $option .'&task=category§ionid='. $sectionid .'&id='. $row->catid, 171 $Itemid 172 ); 173 174 $mitems[$id] = $mitem1; 175 176 if ( $row->access <= $my->gid ) { 177 // add the final content item 178 $id++; 179 $mitem2 = pathwayMakeLink( 180 $Itemid, 181 $row->title, 182 '', 183 $id-1 184 ); 185 186 $mitems[$id] = $mitem2; 187 } 188 $Itemid = $id; 189 190 } 191 break; 192 } 193 break; 194 195 // menu item = Table - Content Category 196 case 'content_category': 197 $id = intval( mosGetParam( $_REQUEST, 'id', 0 ) ); 198 199 switch ($task) { 200 case 'view': 201 if ($id) { 202 // load the content item name and category 203 $query = "SELECT title, catid, id" 204 . "\n FROM #__content" 205 . "\n WHERE id = " . (int) $id 206 . "\n AND access <= " . (int) $my->id 207 ; 208 $database->setQuery( $query ); 209 $row = null; 210 $database->loadObject( $row ); 211 212 $id = max( array_keys( $mitems ) ) + 1; 213 // add the final content item 214 $mitem2 = pathwayMakeLink( 215 $Itemid, 216 $row->title, 217 '', 218 $Itemid 219 ); 220 221 $mitems[$id] = $mitem2; 222 $Itemid = $id; 223 224 } 225 break; 226 } 227 break; 228 229 // menu item = Blog - Content Category 230 // menu item = Blog - Content Section 231 case 'content_blog_category': 232 case 'content_blog_section': 233 switch ($task) { 234 case 'view': 235 $id = intval( mosGetParam( $_REQUEST, 'id', 0 ) ); 236 if ($id) { 237 // load the content item name and category 238 239 $query = "SELECT title, catid, id" 240 . "\n FROM #__content" 241 . "\n WHERE id = " . (int) $id 242 . "\n AND access <= " . (int) $my->id 243 ; 244 $database->setQuery( $query ); 245 $row = null; 246 $database->loadObject( $row ); 247 248 $id = max( array_keys( $mitems ) ) + 1; 249 $mitem2 = pathwayMakeLink( 250 $Itemid, 251 $row->title, 252 '', 253 $Itemid 254 ); 255 $mitems[$id] = $mitem2; 256 $Itemid = $id; 257 258 } 259 break; 260 } 261 break; 262 } 263 264 $i = count( $mitems ); 265 $mid = $Itemid; 266 267 $imgPath = 'templates/' . $mainframe->getTemplate() . '/images/arrow.png'; 268 if (file_exists( "$mosConfig_absolute_path/$imgPath" )){ 269 $img = '<img src="' . $mosConfig_live_site . '/' . $imgPath . '" border="0" alt="arrow" />'; 270 } else { 271 $imgPath = '/images/M_images/arrow.png'; 272 if (file_exists( $mosConfig_absolute_path . $imgPath )){ 273 $img = '<img src="' . $mosConfig_live_site . '/images/M_images/arrow.png" alt="arrow" />'; 274 } else { 275 $img = '>'; 276 } 277 } 278 279 while ($i--) { 280 if (!$mid || empty( $mitems[$mid] ) || $Itemid == $home_menu->id || !eregi("option", $optionstring)) { 281 break; 282 } 283 $item =& $mitems[$mid]; 284 285 $itemname = stripslashes( $item->name ); 286 287 // if it is the current page, then display a non hyperlink 288 if (($item->id == $Itemid && !$mainframe->getCustomPathWay()) || empty( $mid ) || empty($item->link)) { 289 $newlink = " $itemname"; 290 } else if (isset($item->type) && $item->type == 'url') { 291 $correctLink = eregi( 'http://', $item->link); 292 if ($correctLink==1) { 293 $newlink = '<a href="'. $item->link .'" target="_window" class="pathway">'. $itemname .'</a>'; 294 } else { 295 $newlink = $itemname; 296 } 297 } else { 298 $newlink = '<a href="'. sefRelToAbs( $item->link .'&Itemid='. $item->id ) .'" class="pathway">'. $itemname .'</a>'; 299 } 300 301 // converts & to & for xtml compliance 302 $newlink = ampReplace( $newlink ); 303 304 if (trim($newlink)!="") { 305 $path = $img .' '. $newlink .' '. $path; 306 } else { 307 $path = ''; 308 } 309 310 $mid = $item->parent; 311 } 312 313 if ( eregi( 'option', $optionstring ) && trim( $path ) ) { 314 $home = '<a href="'. sefRelToAbs( 'index.php' ) .'" class="pathway">'. $home .'</a>'; 315 } 316 317 if ($mainframe->getCustomPathWay()){ 318 $path .= $img . ' '; 319 $path .= implode ( "$img " ,$mainframe->getCustomPathWay()); 320 } 321 322 if ( $Itemid && $Itemid != 99999999 ) { 323 echo '<span class="pathway">'. $home .' '. $path .'</span>'; 324 } 325 } 326 327 // code placed in a function to prevent messing up global variables 328 if (!defined( '_JOS_PATHWAY' )) { 329 // ensure that functions are declared only once 330 define( '_JOS_PATHWAY', 1 ); 331 332 showPathway( $Itemid ); 333 } 334 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |