Source for file legacy.php

Documentation is available at legacy.php

  1. <?php
  2. /**
  3. @version        $Id: legacy.php 10066 2008-02-26 04:20:57Z ian $
  4. @package        Joomla
  5. @copyright    Copyright (C) 2005 - 2008 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. // no direct access
  15. defined'_JEXEC' or die'Restricted access' );
  16.  
  17. jimport'joomla.plugin.plugin' );
  18.  
  19. /**
  20.  * Joomla! Debug plugin
  21.  *
  22.  * @author        Johan Janssens <johan.janssens@joomla.org>
  23.  * @package        Joomla
  24.  * @subpackage    System
  25.  */
  26. class  plgSystemLegacy extends JPlugin
  27. {
  28.     /**
  29.      * Constructor
  30.      *
  31.      * For php4 compatability we must not use the __constructor as a constructor for plugins
  32.      * because func_get_args ( void ) returns a copy of all passed arguments NOT references.
  33.      * This causes problems with cross-referencing necessary for the observer design pattern.
  34.      *
  35.      * @param    object        $subject The object to observe
  36.       * @param     array          $config  An array that holds the plugin configuration
  37.      * @since    1.0
  38.      */
  39.     function plgSystemLegacy($subject$config)
  40.     {
  41.         parent::__construct($subject$config);
  42.  
  43.         global $mainframe;
  44.  
  45.         // Define the 1.0 legacy mode constant
  46.         define('_JLEGACY''1.0');
  47.  
  48.         // Set global configuration var for legacy mode
  49.         $config &JFactory::getConfig();
  50.         $config->setValue('config.legacy'1);
  51.  
  52.         // Import library dependencies
  53.         require_once(dirname(__FILE__).DS.'legacy'.DS.'classes.php');
  54.         require_once(dirname(__FILE__).DS.'legacy'.DS.'functions.php');
  55.  
  56.         // Register legacy classes for autoloading
  57.         JLoader::register('mosAdminMenus'   dirname(__FILE__).DS.'legacy'.DS.'adminmenus.php');
  58.         JLoader::register('mosCache'        dirname(__FILE__).DS.'legacy'.DS.'cache.php');
  59.         JLoader::register('mosCategory'     dirname(__FILE__).DS.'legacy'.DS.'category.php');
  60.         JLoader::register('mosCommonHTML'   dirname(__FILE__).DS.'legacy'.DS.'commonhtml.php');
  61.         JLoader::register('mosComponent'    dirname(__FILE__).DS.'legacy'.DS.'component.php');
  62.         JLoader::register('mosContent'      dirname(__FILE__).DS.'legacy'.DS.'content.php');
  63.         JLoader::register('mosDBTable'      dirname(__FILE__).DS.'legacy'.DS.'dbtable.php');
  64.         JLoader::register('mosHTML'         dirname(__FILE__).DS.'legacy'.DS.'html.php');
  65.         JLoader::register('mosInstaller'    dirname(__FILE__).DS.'legacy'.DS.'installer.php');
  66.         JLoader::register('mosMainFrame'    dirname(__FILE__).DS.'legacy'.DS.'mainframe.php');
  67.         JLoader::register('mosMambot'       dirname(__FILE__).DS.'legacy'.DS.'mambot.php');
  68.         JLoader::register('mosMambotHandler'dirname(__FILE__).DS.'legacy'.DS.'mambothandler.php');
  69.         JLoader::register('mosMenu'         dirname(__FILE__).DS.'legacy'.DS.'menu.php');
  70.         JLoader::register('mosMenuBar'      dirname(__FILE__).DS.'legacy'.DS.'menubar.php');
  71.         JLoader::register('mosModule'       dirname(__FILE__).DS.'legacy'.DS.'module.php');
  72.         //JLoader::register('mosPageNav'    , dirname(__FILE__).DS.'legacy'.DS.'pagination.php');
  73.         JLoader::register('mosParameters'   dirname(__FILE__).DS.'legacy'.DS.'parameters.php');
  74.         JLoader::register('patFactory'      dirname(__FILE__).DS.'legacy'.DS.'patfactory.php');
  75.         JLoader::register('mosProfiler'     dirname(__FILE__).DS.'legacy'.DS.'profiler.php');
  76.         JLoader::register('mosSection'      dirname(__FILE__).DS.'legacy'.DS.'section.php');
  77.         JLoader::register('mosSession'      dirname(__FILE__).DS.'legacy'.DS.'session.php');
  78.         JLoader::register('mosToolbar'      dirname(__FILE__).DS.'legacy'.DS.'toolbar.php');
  79.         JLoader::register('mosUser'         dirname(__FILE__).DS.'legacy'.DS.'user.php');
  80.  
  81.         // Register class for the database, depends on which db type has been selected for use
  82.         $dbtype    $config->getValue('config.dbtype''mysql');
  83.         JLoader::register('database'        dirname(__FILE__).DS.'legacy'.DS.$dbtype.'.php');
  84.  
  85.         /**
  86.          * Legacy define, _ISO define not used anymore. All output is forced as utf-8.
  87.          * @deprecated    As of version 1.5
  88.          */
  89.         define('_ISO','charset=utf-8');
  90.  
  91.         /**
  92.          * Legacy constant, use _JEXEC instead
  93.          * @deprecated    As of version 1.5
  94.          */
  95.         define'_VALID_MOS');
  96.  
  97.         /**
  98.          * Legacy constant, use _JEXEC instead
  99.          * @deprecated    As of version 1.5
  100.          */
  101.         define'_MOS_MAMBO_INCLUDED');
  102.  
  103.         /**
  104.          * Legacy constant, use DATE_FORMAT_LC instead
  105.          * @deprecated    As of version 1.5
  106.          */
  107.         DEFINE('_DATE_FORMAT_LC'JText::_('DATE_FORMAT_LC1') )//Uses PHP's strftime Command Format
  108.  
  109.         /**
  110.          * Legacy constant, use DATE_FORMAT_LC2 instead
  111.          * @deprecated    As of version 1.5
  112.          */
  113.         DEFINE('_DATE_FORMAT_LC2'JText::_('DATE_FORMAT_LC2'));
  114.  
  115.         /**
  116.          * Legacy constant, use JFilterInput instead
  117.          * @deprecated    As of version 1.5
  118.          */
  119.         DEFINE"_MOS_NOTRIM"0x0001 );
  120.  
  121.         /**
  122.          * Legacy constant, use JFilterInput instead
  123.          * @deprecated    As of version 1.5
  124.          */
  125.         DEFINE"_MOS_ALLOWHTML"0x0002 );
  126.  
  127.         /**
  128.          * Legacy constant, use JFilterInput instead
  129.          * @deprecated    As of version 1.5
  130.          */
  131.         DEFINE"_MOS_ALLOWRAW"0x0004 );
  132.  
  133.         /**
  134.          * Legacy global, use JVersion->getLongVersion() instead
  135.          * @name $_VERSION
  136.          * @deprecated    As of version 1.5
  137.          */
  138.          $GLOBALS['_VERSION']    new JVersion();
  139.          $version                $GLOBALS['_VERSION']->getLongVersion();
  140.  
  141.         /**
  142.          * Legacy global, use JFactory::getDBO() instead
  143.          * @name $database
  144.          * @deprecated    As of version 1.5
  145.          */
  146.         $conf =JFactory::getConfig();
  147.         $GLOBALS['database'new database($conf->getValue('config.host')$conf->getValue('config.user')$conf->getValue('config.password')$conf->getValue('config.db')$conf->getValue('config.dbprefix'));
  148.         $GLOBALS['database']->debug($conf->getValue('config.debug'));
  149.  
  150.         /**
  151.          * Legacy global, use JFactory::getUser() [JUser object] instead
  152.          * @name $my
  153.          * @deprecated    As of version 1.5
  154.          */
  155.         $user    =JFactory::getUser();
  156.  
  157.         $GLOBALS['my']      = (object)$user->getProperties();
  158.         $GLOBALS['my']->gid    $user->get('aid'0);
  159.  
  160.         /**
  161.          * Insert configuration values into global scope (for backwards compatibility)
  162.          * @deprecated    As of version 1.5
  163.          */
  164.  
  165.         $temp new JConfig;
  166.         foreach (get_object_vars($tempas $k => $v{
  167.             $name 'mosConfig_'.$k;
  168.             $GLOBALS[$name$v;
  169.         }
  170.  
  171.         $GLOBALS['mosConfig_live_site']        substr_replace(JURI::root()''-11);
  172.         $GLOBALS['mosConfig_absolute_path']    JPATH_SITE;
  173.         $GLOBALS['mosConfig_cachepath']    JPATH_BASE.DS.'cache';
  174.  
  175.         $GLOBALS['mosConfig_offset_user']    0;
  176.  
  177.         $lang =JFactory::getLanguage();
  178.         $GLOBALS['mosConfig_lang']          $lang->getBackwardLang();
  179.  
  180.         $config->setValue('config.live_site',         $GLOBALS['mosConfig_live_site']);
  181.         $config->setValue('config.absolute_path',     $GLOBALS['mosConfig_absolute_path']);
  182.         $config->setValue('config.lang',             $GLOBALS['mosConfig_lang']);
  183.  
  184.         /**
  185.          * Legacy global, use JFactory::getUser() instead
  186.          * @name $acl
  187.          * @deprecated    As of version 1.5
  188.          */
  189.         $acl =JFactory::getACL();
  190.  
  191.         // Legacy ACL's for backward compat
  192.         $acl->addACL'administration''edit''users''super administrator''components''all' );
  193.         $acl->addACL'administration''edit''users''administrator''components''all' );
  194.         $acl->addACL'administration''edit''users''super administrator''user properties''block_user' );
  195.         $acl->addACL'administration''manage''users''super administrator''components''com_users' );
  196.         $acl->addACL'administration''manage''users''administrator''components''com_users' );
  197.         $acl->addACL'administration''config''users''super administrator' );
  198.         //$acl->addACL( 'administration', 'config', 'users', 'administrator' );
  199.  
  200.         $acl->addACL'action''add''users''author''content''all' );
  201.         $acl->addACL'action''add''users''editor''content''all' );
  202.         $acl->addACL'action''add''users''publisher''content''all' );
  203.         $acl->addACL'action''edit''users''author''content''own' );
  204.         $acl->addACL'action''edit''users''editor''content''all' );
  205.         $acl->addACL'action''edit''users''publisher''content''all' );
  206.         $acl->addACL'action''publish''users''publisher''content''all' );
  207.  
  208.         $acl->addACL'action''add''users''manager''content''all' );
  209.         $acl->addACL'action''edit''users''manager''content''all' );
  210.         $acl->addACL'action''publish''users''manager''content''all' );
  211.  
  212.         $acl->addACL'action''add''users''administrator''content''all' );
  213.         $acl->addACL'action''edit''users''administrator''content''all' );
  214.         $acl->addACL'action''publish''users''administrator''content''all' );
  215.  
  216.         $acl->addACL'action''add''users''super administrator''content''all' );
  217.         $acl->addACL'action''edit''users''super administrator''content''all' );
  218.         $acl->addACL'action''publish''users''super administrator''content''all' );
  219.  
  220.         $acl->addACL'com_syndicate''manage''users''super administrator' );
  221.         $acl->addACL'com_syndicate''manage''users''administrator' );
  222.         $acl->addACL'com_syndicate''manage''users''manager' );
  223.  
  224.         $GLOBALS['acl'=$acl;
  225.  
  226.         /**
  227.          * Legacy global
  228.          * @name $task
  229.          * @deprecated    As of version 1.5
  230.          */
  231.         $GLOBALS['task'JRequest::getString('task');
  232.  
  233.         /**
  234.          * Load the site language file (the old way - to be deprecated)
  235.          * @deprecated    As of version 1.5
  236.          */
  237.         global $mosConfig_lang;
  238.         $mosConfig_lang JFilterInput::clean($mosConfig_lang'cmd');
  239.         $file JPATH_SITE.DS.'language'.DS.$mosConfig_lang.'.php';
  240.         if (file_exists$file )) {
  241.             require_once$file);
  242.         else {
  243.             $file JPATH_SITE.DS.'language'.DS.'english.php';
  244.             if (file_exists$file )) {
  245.                 require_once$file );
  246.             }
  247.         }
  248.  
  249.         /**
  250.          *  Legacy global
  251.          *     use JApplicaiton->registerEvent and JApplication->triggerEvent for event handling
  252.          *  use JPlugingHelper::importPlugin to load bot code
  253.          *  @deprecated As of version 1.5
  254.          */
  255.         $GLOBALS['_MAMBOTS'new mosMambotHandler();
  256.     }
  257.  
  258.     function onAfterRoute()
  259.     {
  260.         global $mainframe;
  261.         if ($mainframe->isAdmin()) {
  262.             return;
  263.         }
  264.  
  265.         switch(JRequest::getCmd('option'))
  266.         {
  267.             case 'com_content'   :
  268.                 $this->routeContent();
  269.                 break;
  270.             case 'com_newsfeeds' :
  271.                 $this->routeNewsfeeds();
  272.                 break;
  273.             case 'com_weblinks' :
  274.                 $this->routeWeblinks();
  275.                 break;
  276.             case 'com_frontpage' :
  277.                 JRequest::setVar('option''com_content');
  278.                 JRequest::setVar('view''frontpage');
  279.                 break;
  280.             case 'com_login'     :
  281.                 JRequest::setVar('option''com_user');
  282.                 JRequest::setVar('view''login');
  283.                 break;
  284.             case 'com_registration'     :
  285.                 JRequest::setVar('option''com_user');
  286.                 JRequest::setVar('view''register');
  287.                 break;
  288.          }
  289.  
  290.         /**
  291.          * Legacy global, use JApplication::getTemplate() instead
  292.          * @name $cur_template
  293.          * @deprecated    As of version 1.5
  294.          */
  295.         $GLOBALS['cur_template'$mainframe->getTemplate();
  296.     }
  297.  
  298.     function routeContent()
  299.     {
  300.         $viewName    JRequest::getCmd'view''article' );
  301.         $layout        JRequest::getCmd'layout''default' );
  302.  
  303.         // interceptors to support legacy urls
  304.         switchJRequest::getCmd('task'))
  305.         {
  306.             //index.php?option=com_content&task=x&id=x&Itemid=x
  307.             case 'blogsection':
  308.                 $viewName    'section';
  309.                 $layout 'blog';
  310.                 break;
  311.             case 'section':
  312.                 $viewName    'section';
  313.                 break;
  314.             case 'category':
  315.                 $viewName    'category';
  316.                 break;
  317.             case 'blogcategory':
  318.                 $viewName    'category';
  319.                 $layout 'blog';
  320.                 break;
  321.             case 'archivesection':
  322.             case 'archivecategory':
  323.                 $viewName    'archive';
  324.                 break;
  325.             case 'frontpage' :
  326.                 $viewName 'frontpage';
  327.                 break;
  328.             case 'view':
  329.                 $viewName    'article';
  330.                 break;
  331.         }
  332.  
  333.         JRequest::setVar('layout'$layout);
  334.         JRequest::setVar('view'$viewName);
  335.     }
  336.  
  337.     function routeNewsfeeds()
  338.     {
  339.         $viewName JRequest::getCmd'view''categories' );
  340.  
  341.         // interceptors to support legacy urls
  342.         switchJRequest::getCmd('task'))
  343.         {
  344.             //index.php?option=com_newsfeeds&task=x&catid=xid=x&Itemid=x
  345.             case 'view':
  346.                 $viewName    'newsfeed';
  347.                 break;
  348.  
  349.             default:
  350.             {
  351.                 if(JRequest::getInt('catid'&& !JRequest::getCmd('view')) {
  352.                     $viewName 'category';
  353.                 }
  354.             }
  355.         }
  356.  
  357.         JRequest::setVar('view'$viewName);
  358.     }
  359.  
  360.     function routeWeblinks()
  361.     {
  362.         $viewName JRequest::getCmd'view''categories' );
  363.  
  364.         // interceptors to support legacy urls
  365.         switchJRequest::getCmd('task'))
  366.         {
  367.             //index.php?option=com_weblinks&task=x&catid=xid=x
  368.             case 'view':
  369.                 $viewName    'weblink';
  370.                 break;
  371.  
  372.             default:
  373.             {
  374.                 if(($catid JRequest::getInt('catid')) && !JRequest::getCmd('view')) {
  375.                     $viewName 'category';
  376.                     JRequest::setVar('id'$catid);
  377.                 }
  378.             }
  379.         }
  380.  
  381.         JRequest::setVar('view'$viewName);
  382.     }
  383. }

Documentation generated on Sun, 06 Apr 2008 07:14:22 +0200 by phpDocumentor 1.4.0a2