| [ Index ] |
PHP Cross Reference of Joomla 1.5.26 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version $Id: application.php 22244 2011-10-16 15:50:00Z dextercowley $ 4 * @package Joomla.Framework 5 * @subpackage Application 6 * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. 7 * @license GNU/GPL, see LICENSE.php 8 * Joomla! is free software. This version may have been modified pursuant 9 * to the GNU General Public License, and as distributed it includes or 10 * is derivative of works licensed under the GNU General Public License or 11 * other free or open source software licenses. 12 * See COPYRIGHT.php for copyright notices and details. 13 */ 14 15 // Check to ensure this file is within the rest of the framework 16 defined('JPATH_BASE') or die(); 17 18 jimport('joomla.event.dispatcher'); 19 20 /** 21 * Base class for a Joomla! application. 22 * 23 * Acts as a Factory class for application specific objects and provides many 24 * supporting API functions. Derived clases should supply the route(), dispatch() 25 * and render() functions. 26 * 27 * @abstract 28 * @package Joomla.Framework 29 * @subpackage Application 30 * @since 1.5 31 */ 32 33 class JApplication extends JObject 34 { 35 /** 36 * The client identifier. 37 * 38 * @var integer 39 * @access protected 40 * @since 1.5 41 */ 42 var $_clientId = null; 43 44 /** 45 * The application message queue. 46 * 47 * @var array 48 * @access protected 49 */ 50 var $_messageQueue = array(); 51 52 /** 53 * The name of the application 54 * 55 * @var array 56 * @access protected 57 */ 58 var $_name = null; 59 60 /** 61 * The scope of the application 62 * 63 * @var string 64 * @access public 65 */ 66 var $scope = null; 67 68 /** 69 * Class constructor. 70 * 71 * @param integer A client identifier. 72 */ 73 function __construct($config = array()) 74 { 75 jimport('joomla.utilities.utility'); 76 77 //set the view name 78 $this->_name = $this->getName(); 79 $this->_clientId = $config['clientId']; 80 81 //Enable sessions by default 82 if(!isset($config['session'])) { 83 $config['session'] = true; 84 } 85 86 //Set the session default name 87 if(!isset($config['session_name'])) { 88 $config['session_name'] = $this->_name; 89 } 90 91 //Set the default configuration file 92 if(!isset($config['config_file'])) { 93 $config['config_file'] = 'configuration.php'; 94 } 95 96 //create the configuration object 97 $this->_createConfiguration(JPATH_CONFIGURATION.DS.$config['config_file']); 98 99 //create the session if a session name is passed 100 if($config['session'] !== false) { 101 $this->_createSession(JUtility::getHash($config['session_name'])); 102 } 103 104 $this->set( 'requestTime', gmdate('Y-m-d H:i') ); 105 } 106 107 /** 108 * Returns a reference to the global JApplication object, only creating it if it 109 * doesn't already exist. 110 * 111 * This method must be invoked as: 112 * <pre> $menu = &JApplication::getInstance();</pre> 113 * 114 * @access public 115 * @param mixed $id A client identifier or name. 116 * @param array $config An optional associative array of configuration settings. 117 * @return JApplication The appliction object. 118 * @since 1.5 119 */ 120 function &getInstance($client, $config = array(), $prefix = 'J') 121 { 122 static $instances; 123 124 if (!isset( $instances )) { 125 $instances = array(); 126 } 127 128 if (empty($instances[$client])) 129 { 130 //Load the router object 131 jimport('joomla.application.helper'); 132 $info =& JApplicationHelper::getClientInfo($client, true); 133 134 $path = $info->path.DS.'includes'.DS.'application.php'; 135 if(file_exists($path)) 136 { 137 require_once $path; 138 139 // Create a JRouter object 140 $classname = $prefix.ucfirst($client); 141 $instance = new $classname($config); 142 } 143 else 144 { 145 $error = JError::raiseError(500, 'Unable to load application: '.$client); 146 return $error; 147 } 148 149 $instances[$client] =& $instance; 150 } 151 152 return $instances[$client]; 153 } 154 155 /** 156 * Initialise the application. 157 * 158 * @param array An optional associative array of configuration settings. 159 * @access public 160 */ 161 function initialise($options = array()) 162 { 163 jimport('joomla.plugin.helper'); 164 165 //Set the language in the class 166 $config =& JFactory::getConfig(); 167 168 // Check that we were given a language in the array (since by default may be blank) 169 if(isset($options['language'])) { 170 $config->setValue('config.language', $options['language']); 171 } 172 173 // Set user specific editor 174 $user =& JFactory::getUser(); 175 $editor = $user->getParam('editor', $this->getCfg('editor')); 176 $editor = JPluginHelper::isEnabled('editors', $editor) ? $editor : $this->getCfg('editor'); 177 $config->setValue('config.editor', $editor); 178 } 179 180 /** 181 * Route the application. 182 * 183 * Routing is the process of examining the request environment to determine which 184 * component should receive the request. The component optional parameters 185 * are then set in the request object to be processed when the application is being 186 * dispatched. 187 * 188 * @abstract 189 * @access public 190 */ 191 function route() 192 { 193 // get the full request URI 194 $uri = clone(JURI::getInstance()); 195 196 $router =& $this->getRouter(); 197 $result = $router->parse($uri); 198 199 JRequest::set($result, 'get', false ); 200 } 201 202 /** 203 * Dispatch the applicaiton. 204 * 205 * Dispatching is the process of pulling the option from the request object and 206 * mapping them to a component. If the component does not exist, it handles 207 * determining a default component to dispatch. 208 * 209 * @abstract 210 * @access public 211 */ 212 function dispatch($component) 213 { 214 $document =& JFactory::getDocument(); 215 216 $document->setTitle( $this->getCfg('sitename' ). ' - ' .JText::_( 'Administration' )); 217 $document->setDescription( $this->getCfg('MetaDesc') ); 218 219 $contents = JComponentHelper::renderComponent($component); 220 $document->setBuffer($contents, 'component'); 221 } 222 223 /** 224 * Render the application. 225 * 226 * Rendering is the process of pushing the document buffers into the template 227 * placeholders, retrieving data from the document and pushing it into 228 * the JResponse buffer. 229 * 230 * @abstract 231 * @access public 232 */ 233 function render() 234 { 235 $params = array( 236 'template' => $this->getTemplate(), 237 'file' => 'index.php', 238 'directory' => JPATH_THEMES 239 ); 240 241 $document =& JFactory::getDocument(); 242 $data = $document->render($this->getCfg('caching'), $params ); 243 JResponse::setBody($data); 244 } 245 246 /** 247 * Exit the application. 248 * 249 * @access public 250 * @param int Exit code 251 */ 252 function close( $code = 0 ) { 253 exit($code); 254 } 255 256 /** 257 * Redirect to another URL. 258 * 259 * Optionally enqueues a message in the system message queue (which will be displayed 260 * the next time a page is loaded) using the enqueueMessage method. If the headers have 261 * not been sent the redirect will be accomplished using a "301 Moved Permanently" or "303 See Other" 262 * code in the header pointing to the new location depending upon the moved flag. If the headers 263 * have already been sent this will be accomplished using a JavaScript statement. 264 * 265 * @access public 266 * @param string $url The URL to redirect to. Can only be http/https URL 267 * @param string $msg An optional message to display on redirect. 268 * @param string $msgType An optional message type. 269 * @param boolean True if the page is 301 Permanently Moved, otherwise 303 See Other is assumed. 270 * @return none; calls exit(). 271 * @since 1.5 272 * @see JApplication::enqueueMessage() 273 */ 274 function redirect( $url, $msg='', $msgType='message', $moved = false ) 275 { 276 // check for relative internal links 277 if (preg_match( '#^index[2]?.php#', $url )) { 278 $url = JURI::base() . $url; 279 } 280 281 // Strip out any line breaks 282 $url = preg_split("/[\r\n]/", $url); 283 $url = $url[0]; 284 285 // If we don't start with a http we need to fix this before we proceed 286 // We could validly start with something else (e.g. ftp), though this would 287 // be unlikely and isn't supported by this API 288 if (!preg_match( '#^http#i', $url )) { 289 $uri =& JURI::getInstance(); 290 $prefix = $uri->toString(Array('scheme', 'user', 'pass', 'host', 'port')); 291 292 if ($url[0] == '/') { 293 // we just need the prefix since we have a path relative to the root 294 $url = $prefix . $url; 295 } 296 else { 297 // its relative to where we are now, so lets add that 298 $parts = explode('/', $uri->toString(Array('path'))); 299 array_pop($parts); 300 $path = implode('/',$parts).'/'; 301 $url = $prefix . $path . $url; 302 } 303 } 304 305 306 // If the message exists, enqueue it 307 if (trim( $msg )) { 308 $this->enqueueMessage($msg, $msgType); 309 } 310 311 // Persist messages if they exist 312 if (count($this->_messageQueue)) { 313 $session =& JFactory::getSession(); 314 $session->set('application.queue', $this->_messageQueue); 315 } 316 317 // If the headers have been sent, then we cannot send an additional location header 318 // so we will output a javascript redirect statement. 319 if (headers_sent()) { 320 echo "<script>document.location.href='$url';</script>\n"; 321 } 322 else { 323 if (!$moved && strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'webkit') !== false) { 324 // WebKit browser - Do not use 303, as it causes subresources reload (https://bugs.webkit.org/show_bug.cgi?id=38690) 325 echo '<html><head><meta http-equiv="refresh" content="0;'. $url .'" /></head><body></body></html>'; 326 } 327 else { 328 // All other browsers, use the more efficient HTTP header method 329 header($moved ? 'HTTP/1.1 301 Moved Permanently' : 'HTTP/1.1 303 See other'); 330 header('Location: '.$url); 331 } 332 } 333 334 $this->close(); 335 } 336 337 /** 338 * Enqueue a system message. 339 * 340 * @access public 341 * @param string $msg The message to enqueue. 342 * @param string $type The message type. 343 * @return void 344 * @since 1.5 345 */ 346 function enqueueMessage( $msg, $type = 'message' ) 347 { 348 // For empty queue, if messages exists in the session, enqueue them first 349 if (!count($this->_messageQueue)) 350 { 351 $session =& JFactory::getSession(); 352 $sessionQueue = $session->get('application.queue'); 353 if (count($sessionQueue)) { 354 $this->_messageQueue = $sessionQueue; 355 $session->set('application.queue', null); 356 } 357 } 358 // Enqueue the message 359 $this->_messageQueue[] = array('message' => $msg, 'type' => strtolower($type)); 360 } 361 362 /** 363 * Get the system message queue. 364 * 365 * @access public 366 * @return The system message queue. 367 * @since 1.5 368 */ 369 function getMessageQueue() 370 { 371 // For empty queue, if messages exists in the session, enqueue them 372 if (!count($this->_messageQueue)) 373 { 374 $session =& JFactory::getSession(); 375 $sessionQueue = $session->get('application.queue'); 376 if (count($sessionQueue)) { 377 $this->_messageQueue = $sessionQueue; 378 $session->set('application.queue', null); 379 } 380 } 381 return $this->_messageQueue; 382 } 383 384 /** 385 * Gets a configuration value. 386 * 387 * @access public 388 * @param string The name of the value to get. 389 * @return mixed The user state. 390 * @example application/japplication-getcfg.php Getting a configuration value 391 */ 392 function getCfg( $varname ) 393 { 394 $config =& JFactory::getConfig(); 395 return $config->getValue('config.' . $varname); 396 } 397 398 /** 399 * Method to get the application name 400 * 401 * The dispatcher name by default parsed using the classname, or it can be set 402 * by passing a $config['name'] in the class constructor 403 * 404 * @access public 405 * @return string The name of the dispatcher 406 * @since 1.5 407 */ 408 function getName() 409 { 410 $name = $this->_name; 411 412 if (empty( $name )) 413 { 414 $r = null; 415 if ( !preg_match( '/J(.*)/i', get_class( $this ), $r ) ) { 416 JError::raiseError(500, "JApplication::getName() : Can\'t get or parse class name."); 417 } 418 $name = strtolower( $r[1] ); 419 } 420 421 return $name; 422 } 423 424 /** 425 * Gets a user state. 426 * 427 * @access public 428 * @param string The path of the state. 429 * @return mixed The user state. 430 */ 431 function getUserState( $key ) 432 { 433 $session =& JFactory::getSession(); 434 $registry =& $session->get('registry'); 435 if(!is_null($registry)) { 436 return $registry->getValue($key); 437 } 438 return null; 439 } 440 441 /** 442 * Sets the value of a user state variable. 443 * 444 * @access public 445 * @param string The path of the state. 446 * @param string The value of the variable. 447 * @return mixed The previous state, if one existed. 448 */ 449 function setUserState( $key, $value ) 450 { 451 $session =& JFactory::getSession(); 452 $registry =& $session->get('registry'); 453 if(!is_null($registry)) { 454 return $registry->setValue($key, $value); 455 } 456 return null; 457 } 458 459 /** 460 * Gets the value of a user state variable. 461 * 462 * @access public 463 * @param string The key of the user state variable. 464 * @param string The name of the variable passed in a request. 465 * @param string The default value for the variable if not found. Optional. 466 * @param string Filter for the variable, for valid values see {@link JFilterInput::clean()}. Optional. 467 * @return The request user state. 468 */ 469 function getUserStateFromRequest( $key, $request, $default = null, $type = 'none' ) 470 { 471 $old_state = $this->getUserState( $key ); 472 $cur_state = (!is_null($old_state)) ? $old_state : $default; 473 $new_state = JRequest::getVar($request, null, 'default', $type); 474 475 // Save the new value only if it was set in this request 476 if ($new_state !== null) { 477 $this->setUserState($key, $new_state); 478 } else { 479 $new_state = $cur_state; 480 } 481 482 return $new_state; 483 } 484 485 /** 486 * Registers a handler to a particular event group. 487 * 488 * @static 489 * @param string The event name. 490 * @param mixed The handler, a function or an instance of a event object. 491 * @return void 492 * @since 1.5 493 */ 494 function registerEvent($event, $handler) 495 { 496 $dispatcher =& JDispatcher::getInstance(); 497 $dispatcher->register($event, $handler); 498 } 499 500 /** 501 * Calls all handlers associated with an event group. 502 * 503 * @static 504 * @param string The event name. 505 * @param array An array of arguments. 506 * @return array An array of results from each function call. 507 * @since 1.5 508 */ 509 function triggerEvent($event, $args=null) 510 { 511 $dispatcher =& JDispatcher::getInstance(); 512 return $dispatcher->trigger($event, $args); 513 } 514 515 /** 516 * Login authentication function. 517 * 518 * Username and encoded password are passed the the onLoginUser event which 519 * is responsible for the user validation. A successful validation updates 520 * the current session record with the users details. 521 * 522 * Username and encoded password are sent as credentials (along with other 523 * possibilities) to each observer (authentication plugin) for user 524 * validation. Successful validation will update the current session with 525 * the user details. 526 * 527 * @param array Array( 'username' => string, 'password' => string ) 528 * @param array Array( 'remember' => boolean ) 529 * @return boolean True on success. 530 * @access public 531 * @since 1.5 532 */ 533 function login($credentials, $options = array()) 534 { 535 // Get the global JAuthentication object 536 jimport( 'joomla.user.authentication'); 537 $authenticate = & JAuthentication::getInstance(); 538 $response = $authenticate->authenticate($credentials, $options); 539 540 if ($response->status === JAUTHENTICATE_STATUS_SUCCESS) 541 { 542 $session = &JFactory::getSession(); 543 544 // we fork the session to prevent session fixation issues 545 $session->fork(); 546 $this->_createSession($session->getId()); 547 548 // Import the user plugin group 549 JPluginHelper::importPlugin('user'); 550 551 // OK, the credentials are authenticated. Lets fire the onLogin event 552 $results = $this->triggerEvent('onLoginUser', array((array)$response, $options)); 553 554 /* 555 * If any of the user plugins did not successfully complete the login routine 556 * then the whole method fails. 557 * 558 * Any errors raised should be done in the plugin as this provides the ability 559 * to provide much more information about why the routine may have failed. 560 */ 561 562 if (!in_array(false, $results, true)) 563 { 564 // Set the remember me cookie if enabled 565 if (isset($options['remember']) && $options['remember']) 566 { 567 jimport('joomla.utilities.simplecrypt'); 568 jimport('joomla.utilities.utility'); 569 570 // Create the encryption key, apply extra hardening using the user agent string 571 $agent = @$_SERVER['HTTP_USER_AGENT']; 572 // Ignore empty and crackish user agents 573 if ($agent != '' && $agent != 'JLOGIN_REMEMBER') { 574 $key = JUtility::getHash($agent); 575 $crypt = new JSimpleCrypt($key); 576 $rcookie = $crypt->encrypt(serialize($credentials)); 577 $lifetime = time() + 365*24*60*60; 578 setcookie(JUtility::getHash('JLOGIN_REMEMBER'), $rcookie, $lifetime, '/'); 579 } 580 } 581 return true; 582 } 583 } 584 585 // Trigger onLoginFailure Event 586 $this->triggerEvent('onLoginFailure', array((array)$response)); 587 588 589 // If silent is set, just return false 590 if (isset($options['silent']) && $options['silent']) { 591 return false; 592 } 593 594 // Return the error 595 return JError::raiseWarning('SOME_ERROR_CODE', JText::_('E_LOGIN_AUTHENTICATE')); 596 } 597 598 /** 599 * Logout authentication function. 600 * 601 * Passed the current user information to the onLogoutUser event and reverts the current 602 * session record back to 'anonymous' parameters. 603 * 604 * @param int $userid The user to load - Can be an integer or string - If string, it is converted to ID automatically 605 * @param array $options Array( 'clientid' => array of client id's ) 606 * 607 * @access public 608 */ 609 function logout($userid = null, $options = array()) 610 { 611 // Initialize variables 612 $retval = false; 613 614 // Get a user object from the JApplication 615 $user = &JFactory::getUser($userid); 616 617 // Build the credentials array 618 $parameters['username'] = $user->get('username'); 619 $parameters['id'] = $user->get('id'); 620 621 // Set clientid in the options array if it hasn't been set already 622 if(empty($options['clientid'])) { 623 $options['clientid'][] = $this->getClientId(); 624 } 625 626 // Import the user plugin group 627 JPluginHelper::importPlugin('user'); 628 629 // OK, the credentials are built. Lets fire the onLogout event 630 $results = $this->triggerEvent('onLogoutUser', array($parameters, $options)); 631 632 /* 633 * If any of the authentication plugins did not successfully complete 634 * the logout routine then the whole method fails. Any errors raised 635 * should be done in the plugin as this provides the ability to provide 636 * much more information about why the routine may have failed. 637 */ 638 if (!in_array(false, $results, true)) { 639 setcookie( JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, '/' ); 640 return true; 641 } 642 643 // Trigger onLoginFailure Event 644 $this->triggerEvent('onLogoutFailure', array($parameters)); 645 646 return false; 647 } 648 649 /** 650 * Gets the name of the current template. 651 * 652 * @return string 653 */ 654 function getTemplate() 655 { 656 return 'system'; 657 } 658 659 /** 660 * Return a reference to the application JRouter object. 661 * 662 * @access public 663 * @param array $options An optional associative array of configuration settings. 664 * @return JRouter. 665 * @since 1.5 666 */ 667 function &getRouter($name = null, $options = array()) 668 { 669 if(!isset($name)) { 670 $name = $this->_name; 671 } 672 673 jimport( 'joomla.application.router' ); 674 $router =& JRouter::getInstance($name, $options); 675 if (JError::isError($router)) { 676 $null = null; 677 return $null; 678 } 679 return $router; 680 } 681 682 /** 683 * Return a reference to the application JPathway object. 684 * 685 * @access public 686 * @param array $options An optional associative array of configuration settings. 687 * @return object JPathway. 688 * @since 1.5 689 */ 690 function &getPathway($name = null, $options = array()) 691 { 692 if(!isset($name)) { 693 $name = $this->_name; 694 } 695 696 jimport( 'joomla.application.pathway' ); 697 $pathway =& JPathway::getInstance($name, $options); 698 if (JError::isError($pathway)) { 699 $null = null; 700 return $null; 701 } 702 return $pathway; 703 } 704 705 /** 706 * Return a reference to the application JPathway object. 707 * 708 * @access public 709 * @param array $options An optional associative array of configuration settings. 710 * @return object JMenu. 711 * @since 1.5 712 */ 713 function &getMenu($name = null, $options = array()) 714 { 715 if(!isset($name)) { 716 $name = $this->_name; 717 } 718 719 jimport( 'joomla.application.menu' ); 720 $menu =& JMenu::getInstance($name, $options); 721 if (JError::isError($menu)) { 722 $null = null; 723 return $null; 724 } 725 return $menu; 726 } 727 728 /** 729 * Create the configuration registry 730 * 731 * @access private 732 * @param string $file The path to the configuration file 733 * return JConfig 734 */ 735 function &_createConfiguration($file) 736 { 737 jimport( 'joomla.registry.registry' ); 738 739 require_once( $file ); 740 741 // Create the JConfig object 742 $config = new JConfig(); 743 744 // Get the global configuration object 745 $registry =& JFactory::getConfig(); 746 747 // Load the configuration values into the registry 748 $registry->loadObject($config); 749 750 return $config; 751 } 752 753 /** 754 * Create the user session. 755 * 756 * Old sessions are flushed based on the configuration value for the cookie 757 * lifetime. If an existing session, then the last access time is updated. 758 * If a new session, a session id is generated and a record is created in 759 * the #__sessions table. 760 * 761 * @access private 762 * @param string The sessions name. 763 * @return object JSession on success. May call exit() on database error. 764 * @since 1.5 765 */ 766 function &_createSession( $name ) 767 { 768 $options = array(); 769 $options['name'] = $name; 770 switch($this->_clientId) { 771 case 0: 772 if($this->getCfg('force_ssl') == 2) { 773 $options['force_ssl'] = true; 774 } 775 break; 776 case 1: 777 if($this->getCfg('force_ssl') >= 1) { 778 $options['force_ssl'] = true; 779 } 780 break; 781 } 782 783 $session =& JFactory::getSession($options); 784 785 jimport('joomla.database.table'); 786 $storage = & JTable::getInstance('session'); 787 $storage->purge($session->getExpire()); 788 789 // Session exists and is not expired, update time in session table 790 if ($storage->load($session->getId())) { 791 $storage->update(); 792 return $session; 793 } 794 795 //Session doesn't exist yet, initalise and store it in the session table 796 $session->set('registry', new JRegistry('session')); 797 $session->set('user', new JUser()); 798 799 if (!$storage->insert( $session->getId(), $this->getClientId())) { 800 jexit( $storage->getError()); 801 } 802 803 return $session; 804 } 805 806 807 /** 808 * Gets the client id of the current running application. 809 * 810 * @access public 811 * @return int A client identifier. 812 * @since 1.5 813 */ 814 function getClientId( ) 815 { 816 return $this->_clientId; 817 } 818 819 /** 820 * Is admin interface? 821 * 822 * @access public 823 * @return boolean True if this application is administrator. 824 * @since 1.0.2 825 */ 826 function isAdmin() 827 { 828 return ($this->_clientId == 1); 829 } 830 831 /** 832 * Is site interface? 833 * 834 * @access public 835 * @return boolean True if this application is site. 836 * @since 1.5 837 */ 838 function isSite() 839 { 840 return ($this->_clientId == 0); 841 } 842 843 /** 844 * Deprecated functions 845 */ 846 847 /** 848 * Deprecated, use JPathWay->addItem() method instead. 849 * 850 * @since 1.0 851 * @deprecated As of version 1.5 852 * @see JPathWay::addItem() 853 */ 854 function appendPathWay( $name, $link = null ) 855 { 856 /* 857 * To provide backward compatability if no second parameter is set 858 * set it to null 859 */ 860 if ($link == null) { 861 $link = ''; 862 } 863 864 $pathway =& $this->getPathway(); 865 866 if( defined( '_JLEGACY' ) && $link == '' ) 867 { 868 $matches = array(); 869 870 $links = preg_match_all ( '/<a[^>]+href="([^"]*)"[^>]*>([^<]*)<\/a>/ui', $name, $matches, PREG_SET_ORDER ); 871 872 foreach( $matches AS $match) { 873 // Add each item to the pathway object 874 if( !$pathway->addItem( $match[2], $match[1] ) ) { 875 return false; 876 } 877 } 878 return true; 879 } 880 else 881 { 882 // Add item to the pathway object 883 if ($pathway->addItem($name, $link)) { 884 return true; 885 } 886 } 887 888 return false; 889 } 890 891 /** 892 * Deprecated, use JPathway->getPathWayNames() method instead. 893 * 894 * @since 1.0 895 * @deprecated As of version 1.5 896 * @see JPathWay::getPathWayNames() 897 */ 898 function getCustomPathWay() 899 { 900 $pathway = $this->getPathway(); 901 return $pathway->getPathWayNames(); 902 } 903 904 /** 905 * Deprecated, use JDocument->get( 'head' ) instead. 906 * 907 * @since 1.0 908 * @deprecated As of version 1.5 909 * @see JDocument 910 * @see JObject::get() 911 */ 912 function getHead() 913 { 914 $document=& JFactory::getDocument(); 915 return $document->get('head'); 916 } 917 918 /** 919 * Deprecated, use JDocument->setMetaData instead. 920 * 921 * @since 1.0 922 * @deprecated As of version 1.5 923 * @param string Name of the metadata tag 924 * @param string Content of the metadata tag 925 * @param string Deprecated, ignored 926 * @param string Deprecated, ignored 927 * @see JDocument::setMetaData() 928 */ 929 function addMetaTag( $name, $content, $prepend = '', $append = '' ) 930 { 931 $document=& JFactory::getDocument(); 932 $document->setMetadata($name, $content); 933 } 934 935 /** 936 * Deprecated, use JDocument->setMetaData instead. 937 * 938 * @since 1.0 939 * @deprecated As of version 1.5 940 * @param string Name of the metadata tag 941 * @param string Content of the metadata tag 942 * @see JDocument::setMetaData() 943 */ 944 function appendMetaTag( $name, $content ) 945 { 946 $this->addMetaTag($name, $content); 947 } 948 949 /** 950 * Deprecated, use JDocument->setMetaData instead 951 * 952 * @since 1.0 953 * @deprecated As of version 1.5 954 * @param string Name of the metadata tag 955 * @param string Content of the metadata tag 956 * @see JDocument::setMetaData() 957 */ 958 function prependMetaTag( $name, $content ) 959 { 960 $this->addMetaTag($name, $content); 961 } 962 963 /** 964 * Deprecated, use JDocument->addCustomTag instead (only when document type is HTML). 965 * 966 * @since 1.0 967 * @deprecated As of version 1.5 968 * @param string Valid HTML 969 * @see JDocumentHTML::addCustomTag() 970 */ 971 function addCustomHeadTag( $html ) 972 { 973 $document=& JFactory::getDocument(); 974 if($document->getType() == 'html') { 975 $document->addCustomTag($html); 976 } 977 } 978 979 /** 980 * Deprecated. 981 * 982 * @since 1.0 983 * @deprecated As of version 1.5 984 */ 985 function getBlogSectionCount( ) 986 { 987 $menus = &JSite::getMenu(); 988 return count($menus->getItems('type', 'content_blog_section')); 989 } 990 991 /** 992 * Deprecated. 993 * 994 * @since 1.0 995 * @deprecated As of version 1.5 996 */ 997 function getBlogCategoryCount( ) 998 { 999 $menus = &JSite::getMenu(); 1000 return count($menus->getItems('type', 'content_blog_category')); 1001 } 1002 1003 /** 1004 * Deprecated. 1005 * 1006 * @since 1.0 1007 * @deprecated As of version 1.5 1008 */ 1009 function getGlobalBlogSectionCount( ) 1010 { 1011 $menus = &JSite::getMenu(); 1012 return count($menus->getItems('type', 'content_blog_section')); 1013 } 1014 1015 /** 1016 * Deprecated. 1017 * 1018 * @since 1.0 1019 * @deprecated As of version 1.5 1020 */ 1021 function getStaticContentCount( ) 1022 { 1023 $menus = &JSite::getMenu(); 1024 return count($menus->getItems('type', 'content_typed')); 1025 } 1026 1027 /** 1028 * Deprecated. 1029 * 1030 * @since 1.0 1031 * @deprecated As of version 1.5 1032 */ 1033 function getContentItemLinkCount( ) 1034 { 1035 $menus = &JSite::getMenu(); 1036 return count($menus->getItems('type', 'content_item_link')); 1037 } 1038 1039 /** 1040 * Deprecated, use JApplicationHelper::getPath instead. 1041 * 1042 * @since 1.0 1043 * @deprecated As of version 1.5 1044 * @see JApplicationHelper::getPath() 1045 */ 1046 function getPath($varname, $user_option = null) 1047 { 1048 jimport('joomla.application.helper'); 1049 return JApplicationHelper::getPath ($varname, $user_option); 1050 } 1051 1052 /** 1053 * Deprecated, use JURI::base() instead. 1054 * 1055 * @since 1.0 1056 * @deprecated As of version 1.5 1057 * @see JURI::base() 1058 */ 1059 function getBasePath($client=0, $addTrailingSlash = true) 1060 { 1061 return JURI::base(); 1062 } 1063 1064 /** 1065 * Deprecated, use JFactory::getUser instead. 1066 * 1067 * @since 1.0 1068 * @deprecated As of version 1.5 1069 * @see JFactory::getUser() 1070 */ 1071 function &getUser() 1072 { 1073 $user =& JFactory::getUser(); 1074 return $user; 1075 } 1076 1077 /** 1078 * Deprecated, use ContentHelper::getItemid instead. 1079 * 1080 * @since 1.0 1081 * @deprecated As of version 1.5 1082 * @see ContentHelperRoute::getArticleRoute() 1083 */ 1084 function getItemid( $id ) 1085 { 1086 require_once JPATH_SITE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php'; 1087 1088 // Load the article data to know what section/category it is in. 1089 $article =& JTable::getInstance('content'); 1090 $article->load($id); 1091 1092 $needles = array( 1093 'article' => (int) $id, 1094 'category' => (int) $article->catid, 1095 'section' => (int) $article->sectionid, 1096 ); 1097 1098 $item = ContentHelperRoute::_findItem($needles); 1099 $return = is_object($item) ? $item->id : null; 1100 1101 return $return; 1102 } 1103 1104 /** 1105 * Deprecated, use JDocument::setTitle instead. 1106 * 1107 * @since 1.0 1108 * @deprecated As of version 1.5 1109 * @see JDocument::setTitle() 1110 */ 1111 function setPageTitle( $title=null ) 1112 { 1113 $document=& JFactory::getDocument(); 1114 $document->setTitle($title); 1115 } 1116 1117 /** 1118 * Deprecated, use JDocument::getTitle instead. 1119 * 1120 * @since 1.0 1121 * @deprecated As of version 1.5 1122 * @see JDocument::getTitle() 1123 */ 1124 function getPageTitle() 1125 { 1126 $document=& JFactory::getDocument(); 1127 return $document->getTitle(); 1128 } 1129 }
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 |