[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/administrator/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    Media
   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  
  18  // Make sure the user is authorized to view this page
  19  $user = & JFactory::getUser();
  20  if (!$user->authorize( 'com_media', 'manage' )) {
  21      $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH'));
  22  }
  23  
  24  $params =& JComponentHelper::getParams('com_media');
  25  
  26  // Load the admin HTML view
  27  require_once ( JPATH_COMPONENT.DS.'helpers'.DS.'media.php' );
  28  
  29  // Set the path definitions
  30  $view = JRequest::getCmd('view',null);
  31  $popup_upload = JRequest::getCmd('pop_up',null);
  32  $path = "file_path";
  33  if(substr(strtolower($view),0,6) == "images" || $popup_upload == 1) $path = "image_path";
  34  define('COM_MEDIA_BASE',    JPath::clean(JPATH_ROOT.DS.$params->get($path, 'images'.DS.'stories')));
  35  define('COM_MEDIA_BASEURL', JURI::root().$params->get($path, 'images/stories'));
  36  
  37  // Require the base controller
  38  require_once  (JPATH_COMPONENT.DS.'controller.php');
  39  
  40  $cmd = JRequest::getCmd('task', null);
  41  
  42  if (strpos($cmd, '.') != false)
  43  {
  44      // We have a defined controller/task pair -- lets split them out
  45      list($controllerName, $task) = explode('.', $cmd);
  46  
  47      // Define the controller name and path
  48      $controllerName    = strtolower($controllerName);
  49      $controllerPath    = JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php';
  50  
  51      // If the controller file path exists, include it ... else lets die with a 500 error
  52      if (file_exists($controllerPath)) {
  53          require_once($controllerPath);
  54      } else {
  55          JError::raiseError(500, 'Invalid Controller');
  56      }
  57  }
  58  else
  59  {
  60      // Base controller, just set the task :)
  61      $controllerName = null;
  62      $task = $cmd;
  63  }
  64  
  65  // Set the name for the controller and instantiate it
  66  $controllerClass = 'MediaController'.ucfirst($controllerName);
  67  if (class_exists($controllerClass)) {
  68      $controller = new $controllerClass();
  69  } else {
  70      JError::raiseError(500, 'Invalid Controller Class');
  71  }
  72  
  73  // Perform the Request task
  74  $controller->execute($task);
  75  
  76  // Redirect if set by the controller
  77  $controller->redirect();


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