Annotation of /mambo/branches/4.6/includes/pathway.php
Parent Directory
|
Revision Log
Revision 1 -
(view)
(download)
Original Path: mambo/trunk/includes/pathway.php
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | * @version $Id: pathway.php,v 1.1 2005/07/22 01:57:13 eddieajau Exp $ | ||
| 4 : | * @package Mambo | ||
| 5 : | * @copyright (C) 2000 - 2005 Miro International Pty Ltd | ||
| 6 : | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL | ||
| 7 : | * Mambo is Free Software | ||
| 8 : | */ | ||
| 9 : | |||
| 10 : | /** ensure this file is being included by a parent file */ | ||
| 11 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 12 : | |||
| 13 : | function pathwayMakeLink( $id, $name, $link, $parent ) { | ||
| 14 : | $mitem = new stdClass(); | ||
| 15 : | $mitem->id = $id; | ||
| 16 : | $mitem->name = $mitem->name = html_entity_decode( $name ); | ||
| 17 : | $mitem->link = $link; | ||
| 18 : | $mitem->parent = $parent; | ||
| 19 : | $mitem->type = ''; | ||
| 20 : | |||
| 21 : | return $mitem; | ||
| 22 : | } | ||
| 23 : | |||
| 24 : | /** | ||
| 25 : | * Outputs the pathway breadcrumbs | ||
| 26 : | * @param database A database connector object | ||
| 27 : | * @param int The db id field value of the current menu item | ||
| 28 : | */ | ||
| 29 : | function showPathway( $Itemid ) { | ||
| 30 : | global $database, $option, $task, $mainframe, $mosConfig_absolute_path, $mosConfig_live_site; | ||
| 31 : | global $SERVER_SOFTWARE, $QUERY_STRING, $REQUEST_URI; | ||
| 32 : | |||
| 33 : | // get the home page | ||
| 34 : | $database->setQuery( "SELECT *" | ||
| 35 : | . "\nFROM #__menu" | ||
| 36 : | . "\nWHERE menutype='mainmenu' AND published='1'" | ||
| 37 : | . "\nORDER BY parent, ordering LIMIT 1" | ||
| 38 : | ); | ||
| 39 : | $home_menu = new mosMenu( $database ); | ||
| 40 : | $database->loadObject( $home_menu ); | ||
| 41 : | |||
| 42 : | // the the whole menu array and index the array by the id | ||
| 43 : | $database->setQuery( "SELECT id, name, link, parent, type" | ||
| 44 : | . "\nFROM #__menu" | ||
| 45 : | . "\nWHERE published='1'" | ||
| 46 : | . "\nORDER BY parent, ordering" | ||
| 47 : | ); | ||
| 48 : | $mitems = $database->loadObjectList( 'id' ); | ||
| 49 : | |||
| 50 : | $isWin = (substr(PHP_OS, 0, 3) == 'WIN'); | ||
| 51 : | $optionstring = $isWin ? $QUERY_STRING : $REQUEST_URI; | ||
| 52 : | |||
| 53 : | // are we at the home page or not | ||
| 54 : | $homekeys = array_keys( $mitems ); | ||
| 55 : | $home = @$mitems[$home_menu->id]->name; | ||
| 56 : | $path = ""; | ||
| 57 : | |||
| 58 : | // this is a patch job for the frontpage items! aje | ||
| 59 : | if ($Itemid == $home_menu->id) { | ||
| 60 : | switch ($option) { | ||
| 61 : | case 'content': | ||
| 62 : | $id = intval( mosGetParam( $_REQUEST, 'id', 0 ) ); | ||
| 63 : | if ($task=='blogsection'){ | ||
| 64 : | |||
| 65 : | $database->setQuery( "SELECT title FROM #__sections WHERE id=$id" ); | ||
| 66 : | } else if ( $task=='blogcategory' ) { | ||
| 67 : | $database->setQuery( "SELECT title FROM #__categories WHERE id=$id" ); | ||
| 68 : | } else { | ||
| 69 : | $database->setQuery( "SELECT title, catid FROM #__content WHERE id=$id" ); | ||
| 70 : | } | ||
| 71 : | |||
| 72 : | $row = null; | ||
| 73 : | $database->loadObject( $row ); | ||
| 74 : | |||
| 75 : | $id = max( array_keys( $mitems ) ) + 1; | ||
| 76 : | |||
| 77 : | // add the content item | ||
| 78 : | $mitem2 = pathwayMakeLink( | ||
| 79 : | $Itemid, | ||
| 80 : | $row->title, | ||
| 81 : | "", | ||
| 82 : | 1 | ||
| 83 : | ); | ||
| 84 : | $mitems[$id] = $mitem2; | ||
| 85 : | $Itemid = $id; | ||
| 86 : | |||
| 87 : | $home = '<a href="'. sefRelToAbs('index.php') .'" class="pathway">'. $home .'</a>'; | ||
| 88 : | break; | ||
| 89 : | |||
| 90 : | } | ||
| 91 : | } | ||
| 92 : | |||
| 93 : | switch( @$mitems[$Itemid]->type ) { | ||
| 94 : | case 'content_section': | ||
| 95 : | $id = intval( mosGetParam( $_REQUEST, 'id', 0 ) ); | ||
| 96 : | |||
| 97 : | switch ($task) { | ||
| 98 : | case 'category': | ||
| 99 : | if ($id) { | ||
| 100 : | $database->setQuery( "SELECT title FROM #__categories WHERE id=$id" ); | ||
| 101 : | $title = $database->loadResult(); | ||
| 102 : | |||
| 103 : | $id = max( array_keys( $mitems ) ) + 1; | ||
| 104 : | $mitem = pathwayMakeLink( | ||
| 105 : | $id, | ||
| 106 : | $title, | ||
| 107 : | 'index.php?option='. $option .'&task='. $task .'&id='. $id .'&Itemid='. $Itemid, | ||
| 108 : | $Itemid | ||
| 109 : | ); | ||
| 110 : | $mitems[$id] = $mitem; | ||
| 111 : | $Itemid = $id; | ||
| 112 : | } | ||
| 113 : | break; | ||
| 114 : | |||
| 115 : | case 'view': | ||
| 116 : | if ($id) { | ||
| 117 : | // load the content item name and category | ||
| 118 : | $database->setQuery( "SELECT title, catid, id FROM #__content WHERE id=$id" ); | ||
| 119 : | $row = null; | ||
| 120 : | $database->loadObject( $row ); | ||
| 121 : | |||
| 122 : | // load and add the category | ||
| 123 : | $database->setQuery( "SELECT c.title AS title, s.id AS sectionid " | ||
| 124 : | ."FROM #__categories AS c " | ||
| 125 : | ."LEFT JOIN #__sections AS s " | ||
| 126 : | ."ON c.section=s.id " | ||
| 127 : | ."WHERE c.id=$row->catid" ); | ||
| 128 : | $result = $database->loadObjectList(); | ||
| 129 : | |||
| 130 : | $title = $result[0]->title; | ||
| 131 : | $sectionid = $result[0]->sectionid; | ||
| 132 : | |||
| 133 : | $id = max( array_keys( $mitems ) ) + 1; | ||
| 134 : | $mitem1 = pathwayMakeLink( | ||
| 135 : | $Itemid, | ||
| 136 : | $title, | ||
| 137 : | 'index.php?option='. $option .'&task=category§ionid='. $sectionid .'&id='. $row->catid, | ||
| 138 : | $Itemid | ||
| 139 : | ); | ||
| 140 : | $mitems[$id] = $mitem1; | ||
| 141 : | |||
| 142 : | // add the final content item | ||
| 143 : | $id++; | ||
| 144 : | $mitem2 = pathwayMakeLink( | ||
| 145 : | $Itemid, | ||
| 146 : | $row->title, | ||
| 147 : | "", | ||
| 148 : | $id-1 | ||
| 149 : | ); | ||
| 150 : | $mitems[$id] = $mitem2; | ||
| 151 : | $Itemid = $id; | ||
| 152 : | |||
| 153 : | } | ||
| 154 : | break; | ||
| 155 : | } | ||
| 156 : | break; | ||
| 157 : | |||
| 158 : | case 'content_category': | ||
| 159 : | $id = intval( mosGetParam( $_REQUEST, 'id', 0 ) ); | ||
| 160 : | |||
| 161 : | switch ($task) { | ||
| 162 : | |||
| 163 : | case 'view': | ||
| 164 : | if ($id) { | ||
| 165 : | // load the content item name and category | ||
| 166 : | $database->setQuery( "SELECT title, catid FROM #__content WHERE id=$id" ); | ||
| 167 : | $row = null; | ||
| 168 : | $database->loadObject( $row ); | ||
| 169 : | |||
| 170 : | $id = max( array_keys( $mitems ) ) + 1; | ||
| 171 : | // add the final content item | ||
| 172 : | $mitem2 = pathwayMakeLink( | ||
| 173 : | $Itemid, | ||
| 174 : | $row->title, | ||
| 175 : | "", | ||
| 176 : | $Itemid | ||
| 177 : | ); | ||
| 178 : | $mitems[$id] = $mitem2; | ||
| 179 : | $Itemid = $id; | ||
| 180 : | |||
| 181 : | } | ||
| 182 : | break; | ||
| 183 : | } | ||
| 184 : | break; | ||
| 185 : | |||
| 186 : | case 'content_blog_category': | ||
| 187 : | case 'content_blog_section': | ||
| 188 : | switch ($task) { | ||
| 189 : | case 'view': | ||
| 190 : | $id = intval( mosGetParam( $_REQUEST, 'id', 0 ) ); | ||
| 191 : | |||
| 192 : | if ($id) { | ||
| 193 : | // load the content item name and category | ||
| 194 : | $database->setQuery( "SELECT title, catid FROM #__content WHERE id=$id" ); | ||
| 195 : | $row = null; | ||
| 196 : | $database->loadObject( $row ); | ||
| 197 : | |||
| 198 : | $id = max( array_keys( $mitems ) ) + 1; | ||
| 199 : | $mitem2 = pathwayMakeLink( | ||
| 200 : | $Itemid, | ||
| 201 : | $row->title, | ||
| 202 : | "", | ||
| 203 : | $Itemid | ||
| 204 : | ); | ||
| 205 : | $mitems[$id] = $mitem2; | ||
| 206 : | $Itemid = $id; | ||
| 207 : | |||
| 208 : | } | ||
| 209 : | break; | ||
| 210 : | } | ||
| 211 : | break; | ||
| 212 : | } | ||
| 213 : | |||
| 214 : | $i = count( $mitems ); | ||
| 215 : | $mid = $Itemid; | ||
| 216 : | |||
| 217 : | $imgPath = 'templates/' . $mainframe->getTemplate() . '/images/arrow.png'; | ||
| 218 : | if (file_exists( "$mosConfig_absolute_path/$imgPath" )){ | ||
| 219 : | $img = '<img src="' . $mosConfig_live_site . '/' . $imgPath . '" border="0" alt="arrow" />'; | ||
| 220 : | } else { | ||
| 221 : | $imgPath = '/images/M_images/arrow.png'; | ||
| 222 : | if (file_exists( $mosConfig_absolute_path . $imgPath )){ | ||
| 223 : | $img = '<img src="' . $mosConfig_live_site . '/images/M_images/arrow.png" alt="arrow" />'; | ||
| 224 : | } else { | ||
| 225 : | $img = '>'; | ||
| 226 : | } | ||
| 227 : | } | ||
| 228 : | |||
| 229 : | while ($i--) { | ||
| 230 : | if (!$mid || empty( $mitems[$mid] ) || $mid == 1 || !eregi("option", $optionstring)) { | ||
| 231 : | break; | ||
| 232 : | } | ||
| 233 : | $item =& $mitems[$mid]; | ||
| 234 : | |||
| 235 : | // converts & to & for xtml compliance | ||
| 236 : | $itemname = ampReplace( $item->name ); | ||
| 237 : | |||
| 238 : | // if it is the current page, then display a non hyperlink | ||
| 239 : | if ($item->id == $Itemid || empty( $mid ) || empty($item->link)) { | ||
| 240 : | $newlink = " $itemname"; | ||
| 241 : | } else if (isset($item->type) && $item->type == 'url') { | ||
| 242 : | $correctLink = eregi( 'http://', $item->link); | ||
| 243 : | if ($correctLink==1) { | ||
| 244 : | $newlink = '<a href="'. $item->link .'" target="_window" class="pathway">'. $itemname .'</a>'; | ||
| 245 : | } else { | ||
| 246 : | $newlink = $itemname; | ||
| 247 : | } | ||
| 248 : | } else { | ||
| 249 : | $newlink = '<a href="'. sefRelToAbs( $item->link .'&Itemid='. $item->id ) .'" class="pathway">'. $itemname .'</a>'; | ||
| 250 : | } | ||
| 251 : | |||
| 252 : | $newlink = ampReplace( $newlink ); | ||
| 253 : | |||
| 254 : | if (trim($newlink)!="") { | ||
| 255 : | $path = $img .' '. $newlink .' '. $path; | ||
| 256 : | } else { | ||
| 257 : | $path = ''; | ||
| 258 : | } | ||
| 259 : | |||
| 260 : | $mid = $item->parent; | ||
| 261 : | } | ||
| 262 : | |||
| 263 : | if ( eregi( 'option', $optionstring ) && trim( $path ) ) { | ||
| 264 : | $home = '<a href="'. sefRelToAbs( 'index.php' ) .'" class="pathway">'. $home .'</a>'; | ||
| 265 : | } | ||
| 266 : | |||
| 267 : | if ($mainframe->getCustomPathWay()){ | ||
| 268 : | $path .= $img . ' '; | ||
| 269 : | $path .= implode ("$img " ,$mainframe->getCustomPathWay()); | ||
| 270 : | } | ||
| 271 : | |||
| 272 : | echo ( "<span class=\"pathway\">". $home ." ". $path ."</span>\n" ); | ||
| 273 : | } | ||
| 274 : | |||
| 275 : | // code placed in a function to prevent messing up global variables | ||
| 276 : | showPathway( $Itemid ); | ||
| 277 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

