|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: |
<?php
/**
* @version $Id: router.php 8180 2007-07-23 05:52:29Z eddieajau $
* @package Joomla.Framework
* @subpackage Application
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();
/**
* Class to create and parse routes for the site application
*
* @package Joomla
* @since 1.5
*/
class JRouterSite extends JRouter
{
/**
* Class constructor
*
* @access public
*/
function __construct($options = array()) {
parent::__construct($options);
}
function parse(&$uri)
{
$vars = array();
// Get the application
$app =& JFactory::getApplication();
if($app->getCfg('force_ssl') == 2 && strtolower($uri->getScheme()) != 'https') {
//forward to https
$uri->setScheme('https');
$app->redirect($uri->toString());
}
// Get the path
$path = $uri->getPath();
//Remove the suffix
if($this->_mode == JROUTER_MODE_SEF)
{
if($app->getCfg('sef_suffix') && !(substr($path, -9) == 'index.php' || substr($path, -1) == '/'))
{
if($suffix = pathinfo($path, PATHINFO_EXTENSION))
{
$path = str_replace('.'.$suffix, '', $path);
$vars['format'] = $suffix;
}
}
}
//Remove basepath
$path = substr_replace($path, '', 0, strlen(JURI::base(true)));
//Remove prefix
$path = str_replace('index.php', '', $path);
//Set the route
$uri->setPath(trim($path , '/'));
$vars += parent::parse($uri);
return $vars;
}
function &build($url)
{
$uri =& parent::build($url);
// Get the path data
$route = $uri->getPath();
//Add the suffix to the uri
if($this->_mode == JROUTER_MODE_SEF && $route)
{
$app =& JFactory::getApplication();
if($app->getCfg('sef_suffix') && !(substr($route, -9) == 'index.php' || substr($route, -1) == '/'))
{
if($format = $uri->getVar('format', 'html'))
{
$route .= '.'.$format;
$uri->delVar('format');
}
}
if($app->getCfg('sef_rewrite'))
{
//Transform the route
$route = str_replace('index.php/', '', $route);
}
}
//Add basepath to the uri
$uri->setPath(JURI::base(true).'/'.$route);
return $uri;
}
function _parseRawRoute(&$uri)
{
$vars = array();
$menu =& JSite::getMenu(true);
//Handle an empty URL (special case)
if(!$uri->getVar('Itemid') && !$uri->getVar('option'))
{
$item = $menu->getDefault();
if(!is_object($item)) return $vars; // No default item set
//Set the information in the request
$vars = $item->query;
//Get the itemid
$vars['Itemid'] = $item->id;
// Set the active menu item
$menu->setActive($vars['Itemid']);
return $vars;
}
//Get the variables from the uri
$this->setVars($uri->getQuery(true));
//Get the itemid, if it hasn't been set force it to null
$this->setVar('Itemid', JRequest::getInt('Itemid', null));
//Only an Itemid ? Get the full information from the itemid
if(count($this->getVars()) == 1)
{
$item = $menu->getItem($this->getVar('Itemid'));
$vars = $vars + $item->query;
}
// Set the active menu item
$menu->setActive($this->getVar('Itemid'));
return $vars;
}
function _parseSefRoute(&$uri)
{
$vars = array();
$menu =& JSite::getMenu(true);
$route = $uri->getPath();
//Get the variables from the uri
$vars = $uri->getQuery(true);
//Handle an empty URL (special case)
if(empty($route))
{
//If route is empty AND option is set in the query, assume it's non-sef url, and parse apropriately
if(isset($vars['option']) || isset($vars['Itemid'])) {
return $this->_parseRawRoute($uri);
}
$item = $menu->getDefault();
//Set the information in the request
$vars = $item->query;
//Get the itemid
$vars['Itemid'] = $item->id;
// Set the active menu item
$menu->setActive($vars['Itemid']);
return $vars;
}
/*
* Parse the application route
*/
if(substr($route, 0, 9) == 'component')
{
$segments = explode('/', $route);
$route = str_replace('component/'.$segments[1], '', $route);
$vars['option'] = 'com_'.$segments[1];
$vars['Itemid'] = null;
}
else
{
//Need to reverse the array (highest sublevels first)
$items = array_reverse($menu->getMenu());
foreach ($items as $item)
{
$lenght = strlen($item->route); //get the lenght of the route
if($lenght > 0 && strpos($route.'/', $item->route.'/') === 0 && $item->type != 'menulink')
{
$route = substr($route, $lenght);
$vars['Itemid'] = $item->id;
$vars['option'] = $item->component;
break;
}
}
}
// Set the active menu item
if ( isset($vars['Itemid']) ) {
$menu->setActive( $vars['Itemid'] );
}
//Set the variables
$this->setVars($vars);
/*
* Parse the component route
*/
if(!empty($route) && isset($this->_vars['option']) )
{
$segments = explode('/', $route);
array_shift($segments);
// Handle component route
$component = preg_replace('/[^A-Z0-9_\.-]/i', '', $this->_vars['option']);
// Use the component routing handler if it exists
$path = JPATH_SITE.DS.'components'.DS.$component.DS.'router.php';
if (file_exists($path) && count($segments))
{
if ($component != "com_search") { // Cheep fix on searches
//decode the route segments
$segments = $this->_decodeSegments($segments);
}
require_once $path;
$function = substr($component, 4).'ParseRoute';
$vars = $function($segments);
$this->setVars($vars);
}
}
else
{
//Set active menu item
if($item =& $menu->getActive()) {
$vars = $item->query;
}
}
return $vars;
}
function _buildRawRoute(&$uri)
{
}
function _buildSefRoute(&$uri)
{
// Get the route
$route = $uri->getPath();
// Get the query data
$query = $uri->getQuery(true);
if(!isset($query['option'])) {
return;
}
$menu =& JSite::getMenu();
/*
* Build the component route
*/
$component = preg_replace('/[^A-Z0-9_\.-]/i', '', $query['option']);
$tmp = '';
// Use the component routing handler if it exists
$path = JPATH_SITE.DS.'components'.DS.$component.DS.'router.php';
// Use the custom routing handler if it exists
if (file_exists($path) && !empty($query))
{
require_once $path;
$function = substr($component, 4).'BuildRoute';
$parts = $function($query);
// encode the route segments
if ($component != "com_search") { // Cheep fix on searches
$parts = $this->_encodeSegments($parts);
}
else { // fix up search for URL
$total = count($parts);
for($i=0; $i<$total; $i++) {
// urlencode twice because it is decoded once after redirect
$parts[$i] = urlencode(urlencode(stripcslashes($parts[$i])));
}
}
$result = implode('/', $parts);
$tmp = ($result != "") ? '/'.$result : '';
}
/*
* Build the application route
*/
$built = false;
if (isset($query['Itemid']) && !empty($query['Itemid']))
{
$item = $menu->getItem($query['Itemid']);
if (is_object($item) && $query['option'] == $item->component) {
$tmp = !empty($tmp) ? $item->route.'/'.$tmp : $item->route;
$built = true;
}
}
if(!$built) {
$tmp = 'component/'.substr($query['option'], 4).'/'.$tmp;
}
$route .= '/'.$tmp;
// Unset unneeded query information
unset($query['Itemid']);
unset($query['option']);
//Set query again in the URI
$uri->setQuery($query);
$uri->setPath($route);
}
function _processParseRules(&$uri)
{
// Process the attached parse rules
$vars = parent::_processParseRules($uri);
// Process the pagination support
if($this->_mode == JROUTER_MODE_SEF)
{
$app =& JFactory::getApplication();
if($start = $uri->getVar('start'))
{
$uri->delVar('start');
$vars['limitstart'] = $start;
}
}
return $vars;
}
function _processBuildRules(&$uri)
{
// Make sure any menu vars are used if no others are specified
if(($this->_mode != JROUTER_MODE_SEF) && $uri->getVar('Itemid') && count($uri->getQuery(true)) == 2)
{
$menu =& JSite::getMenu();
// Get the active menu item
$itemid = $uri->getVar('Itemid');
$item = $menu->getItem($itemid);
$uri->setQuery($item->query);
$uri->setVar('Itemid', $itemid);
}
// Process the attached build rules
parent::_processBuildRules($uri);
// Get the path data
$route = $uri->getPath();
if($this->_mode == JROUTER_MODE_SEF && $route)
{
$app =& JFactory::getApplication();
if ($limitstart = $uri->getVar('limitstart'))
{
$uri->setVar('start', (int) $limitstart);
$uri->delVar('limitstart');
}
}
$uri->setPath($route);
}
function &_createURI($url)
{
//Create the URI
$uri =& parent::_createURI($url);
// Set URI defaults
$menu =& JSite::getMenu();
// Get the itemid form the URI
$itemid = $uri->getVar('Itemid');
if(is_null($itemid))
{
if($option = $uri->getVar('option'))
{
$item = $menu->getItem($this->getVar('Itemid'));
if(isset($item) && $item->component == $option) {
$uri->setVar('Itemid', $item->id);
}
}
else
{
if($option = $this->getVar('option')) {
$uri->setVar('option', $option);
}
if($itemid = $this->getVar('Itemid')) {
$uri->setVar('Itemid', $itemid);
}
}
}
else
{
if(!$uri->getVar('option'))
{
$item = $menu->getItem($itemid);
$uri->setVar('option', $item->component);
}
}
return $uri;
}
}
|
Advertisement
| Hall of Fame |