[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/components/com_media/ -> media.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: media.php 14401 2010-01-26 14:10:00Z louis $
   4   * @package        Joomla
   5   * @subpackage    Massmail
   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 to the
   9   * GNU General Public License, and as distributed it includes or is derivative
  10   * of works licensed under the GNU General Public License or other free or open
  11   * source software licenses. See COPYRIGHT.php for copyright notices and
  12   * details.
  13   */
  14  
  15  // no direct access
  16  defined('_JEXEC') or die('Restricted access');
  17  $params =& JComponentHelper::getParams('com_media');
  18  // Make sure the user is authorized to view this page
  19  $user = & JFactory::getUser();
  20  if (!$user->authorize( 'com_media', 'popup' )) {
  21      $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH'));
  22  }
  23  
  24  // Set the path definitions
  25  define('COM_MEDIA_BASE',    JPath::clean(JPATH_ROOT.DS.$params->get('image_path', 'images'.DS.'stories')));
  26  define('COM_MEDIA_BASEURL', JURI::root(true).'/'.$params->get('image_path', 'images/stories'));
  27  
  28  // Load the admin HTML view
  29  require_once ( JPATH_COMPONENT_ADMINISTRATOR.DS.'helpers'.DS.'media.php' );
  30  
  31  // Require the base controller
  32  require_once  (JPATH_COMPONENT.DS.'controller.php');
  33  
  34  $cmd = JRequest::getCmd('task', null);
  35  if (strpos($cmd, '.') != false)
  36  {
  37      // We have a defined controller/task pair -- lets split them out
  38      list($controllerName, $task) = explode('.', $cmd);
  39  
  40      // Define the controller name and path
  41      $controllerName    = strtolower($controllerName);
  42      $controllerPath    = JPATH_COMPONENT_ADMINISTRATOR.DS.'controllers'.DS.$controllerName.'.php';
  43  
  44      // If the controller file path exists, include it ... else lets die with a 500 error
  45      if (file_exists($controllerPath)) {
  46          require_once($controllerPath);
  47      } else {
  48          JError::raiseError(500, 'Invalid Controller');
  49      }
  50  }
  51  else
  52  {
  53      // Base controller, just set the task :)
  54      $controllerName = null;
  55      $task = $cmd;
  56  }
  57  // Set the name for the controller and instantiate it
  58  $controllerClass = 'MediaController'.ucfirst($controllerName);
  59  if (class_exists($controllerClass)) {
  60      $controller = new $controllerClass();
  61  } else {
  62      JError::raiseError(500, 'Invalid Controller Class');
  63  }
  64  
  65  // Set the model and view paths to the administrator folders
  66  $controller->addViewPath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views');
  67  $controller->addModelPath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models');
  68  
  69  // Perform the Request task
  70  $controller->execute($task);
  71  
  72  // Redirect if set by the controller
  73  $controller->redirect();


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1