Exemplo n.º 1
0
 /**
  * Will execute a task within a shipping plugin
  * 
  * (non-PHPdoc)
  * @see application/component/JController::execute()
  */
 function execute($task)
 {
     $shippingTask = JRequest::getCmd('shippingTask', '');
     // Check if we are in a shipping method view. If it is so,
     // Try lo load the shipping plugin controller (if any)
     if ($task == "view" && $shippingTask != '') {
         $model = $this->getModel('Shipping', 'TiendaModel');
         $id = JRequest::getInt('id', '0');
         if (!$id) {
             parent::execute($task);
         }
         $model->setId($id);
         // get the data
         // not using getItem here to enable ->checkout (which requires JTable object)
         $row = $model->getTable();
         $row->load((int) $model->getId());
         $element = $row->element;
         // The name of the Shipping Controller should be the same of the $_element name,
         // without the shipping_ prefix and with the first letter Uppercase, and should
         // be placed into a controller.php file inside the root of the plugin
         // Ex: shipping_standard => TiendaControllerShippingStandard in shipping_standard/controller.php
         $controllerName = str_ireplace('shipping_', '', $element);
         $controllerName = ucfirst($controllerName);
         $path = JPATH_SITE . '/plugins/tienda/';
         if (version_compare(JVERSION, '1.6.0', 'ge')) {
             // Joomla! 1.6+ code here
             $controllerPath = $path . $element . '/' . $element . '/controller.php';
         } else {
             // Joomla! 1.5 code here
             $controllerPath = $path . $element . '/controller.php';
         }
         if (file_exists($controllerPath)) {
             require_once $controllerPath;
         } else {
             $controllerName = '';
         }
         $className = 'TiendaControllerShipping' . $controllerName;
         if ($controllerName != '' && class_exists($className)) {
             // Create the controller
             $controller = new $className();
             // Add the view Path
             $controller->addViewPath($path);
             // Perform the requested task
             $controller->execute($shippingTask);
             // Redirect if set by the controller
             $controller->redirect();
         } else {
             parent::execute($task);
         }
     } else {
         parent::execute($task);
     }
 }