[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/administrator/components/com_config/controllers/ -> component.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: component.php 14401 2010-01-26 14:10:00Z louis $
   4   * @package        Joomla
   5   * @subpackage    Config
   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  require_once( JPATH_COMPONENT.DS.'views'.DS.'component'.DS.'view.php' );
  19  
  20  /**
  21   * Note: this view is intended only to be opened in a popup
  22   * @package        Joomla
  23   * @subpackage    Config
  24   */
  25  class ConfigControllerComponent extends JController
  26  {
  27      /**
  28       * Custom Constructor
  29       */
  30  	function __construct( $default = array())
  31      {
  32          $default['default_task'] = 'edit';
  33          parent::__construct( $default );
  34  
  35          $this->registerTask( 'apply', 'save' );
  36      }
  37  
  38      /**
  39       * Show the configuration edit form
  40       * @param string The URL option
  41       */
  42  	function edit()
  43      {
  44          JRequest::setVar('tmpl', 'component'); //force the component template
  45          $component = JRequest::getCmd( 'component' );
  46  
  47          if (empty( $component ))
  48          {
  49              JError::raiseWarning( 500, 'Not a valid component' );
  50              return false;
  51          }
  52  
  53          // load the component's language file
  54          $lang = & JFactory::getLanguage();
  55          $lang->load( $component );
  56  
  57          $model = $this->getModel('Component' );
  58          $table =& JTable::getInstance('component');
  59  
  60          if (!$table->loadByOption( $component ))
  61          {
  62              JError::raiseWarning( 500, 'Not a valid component' );
  63              return false;
  64          }
  65  
  66          $view = new ConfigViewComponent( );
  67          $view->assignRef('component', $table);
  68          $view->setModel( $model, true );
  69          $view->display();
  70      }
  71  
  72      /**
  73       * Save the configuration
  74       */
  75  	function save()
  76      {
  77          // Check for request forgeries
  78          JRequest::checkToken() or jexit( 'Invalid Token' );
  79  
  80          $component = JRequest::getCmd( 'component' );
  81  
  82          $table =& JTable::getInstance('component');
  83          if (!$table->loadByOption( $component ))
  84          {
  85              JError::raiseWarning( 500, 'Not a valid component' );
  86              return false;
  87          }
  88  
  89          $post = JRequest::get( 'post' );
  90          $post['option'] = $component;
  91          $table->bind( $post );
  92  
  93          // pre-save checks
  94          if (!$table->check()) {
  95              JError::raiseWarning( 500, $table->getError() );
  96              return false;
  97          }
  98  
  99          // save the changes
 100          if (!$table->store()) {
 101              JError::raiseWarning( 500, $table->getError() );
 102              return false;
 103          }
 104  
 105          //$this->setRedirect( 'index.php?option=com_config', $msg );
 106          $this->edit();
 107      }
 108  
 109      /**
 110       * Cancel operation
 111       */
 112  	function cancel()
 113      {
 114          $this->setRedirect( 'index.php' );
 115      }
 116  }


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