| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: router.php 14401 2010-01-26 14:10:00Z louis $ 4 * @package Joomla 5 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 6 * @license 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 15 /** 16 * @param array 17 * @return array 18 */ 19 function PollBuildRoute( &$query ) 20 { 21 static $items; 22 23 $segments = array(); 24 $itemid = null; 25 26 // Break up the poll id into numeric and alias values. 27 if (isset($query['id']) && strpos($query['id'], ':')) { 28 list($query['id'], $query['alias']) = explode(':', $query['id'], 2); 29 } 30 31 // Get the menu items for this component. 32 if (!$items) { 33 $component = &JComponentHelper::getComponent('com_poll'); 34 $menu = &JSite::getMenu(); 35 $items = $menu->getItems('componentid', $component->id); 36 } 37 38 // Search for an appropriate menu item. 39 if (is_array($items)) 40 { 41 // If only the option and itemid are specified in the query, return that item. 42 if (!isset($query['view']) && !isset($query['id']) && !isset($query['catid']) && isset($query['Itemid'])) { 43 $itemid = (int) $query['Itemid']; 44 } 45 // Search for a specific link based on the critera given. 46 if (!$itemid) { 47 foreach ($items as $item) 48 { 49 // Check if this menu item links to this view. 50 if (isset($item->query['view']) && $item->query['view'] == 'poll' 51 && isset($query['view']) && $query['view'] != 'category' 52 && isset($item->query['id']) && $item->query['id'] == $query['id']) 53 { 54 $itemid = $item->id; 55 } 56 } 57 } 58 59 // If no specific link has been found, search for a general one. 60 if (!$itemid) { 61 foreach ($items as $item) 62 { 63 if (isset($query['view']) && $query['view'] == 'poll' && isset($item->query['view']) && $item->query['view'] == 'poll') 64 { 65 // Check for an undealt with newsfeed id. 66 if (isset($query['id'])) 67 { 68 // This menu item links to the newsfeed view but we need to append the newsfeed id to it. 69 $itemid = $item->id; 70 $segments[] = isset($query['alias']) ? $query['id'].':'.$query['alias'] : $query['id']; 71 break; 72 } 73 } 74 } 75 } 76 } 77 78 // Check if the router found an appropriate itemid. 79 if (!$itemid) 80 { 81 // Check if a id was specified. 82 if (isset($query['id'])) 83 { 84 if (isset($query['alias'])) { 85 $query['id'] .= ':'.$query['alias']; 86 } 87 88 // Push the id onto the stack. 89 $segments[] = $query['id']; 90 unset($query['id']); 91 unset($query['alias']); 92 } 93 unset($query['view']); 94 } 95 else 96 { 97 $query['Itemid'] = $itemid; 98 99 // Remove the unnecessary URL segments. 100 unset($query['view']); 101 unset($query['id']); 102 unset($query['catid']); 103 unset($query['alias']); 104 } 105 106 return $segments; 107 } 108 109 /** 110 * @param array 111 * @return array 112 */ 113 function PollParseRoute( $segments ) 114 { 115 $vars = array(); 116 117 //Get the active menu item 118 $menu =& JSite::getMenu(); 119 $item =& $menu->getActive(); 120 121 $count = count( $segments ); 122 123 //Standard routing for articles 124 if(!isset($item)) 125 { 126 $vars['id'] = $segments[$count - 1]; 127 return $vars; 128 } 129 130 // Count route segments 131 $vars['id'] = $segments[$count-1]; 132 $vars['view'] = 'poll'; 133 134 return $vars; 135 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Mar 28 15:54:07 2012 | Cross-referenced by PHPXref 0.7.1 |