[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/administrator/components/com_weblinks/ -> controller.php (source)

   1  <?php
   2  /**
   3   * @version        $Id: controller.php 14401 2010-01-26 14:10:00Z louis $
   4   * @package        Joomla
   5   * @subpackage    Content
   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  // Check to ensure this file is included in Joomla!
  16  defined('_JEXEC') or die( 'Restricted access' );
  17  
  18  jimport( 'joomla.application.component.controller' );
  19  
  20  /**
  21   * Weblinks Weblink Controller
  22   *
  23   * @package        Joomla
  24   * @subpackage    Weblinks
  25   * @since 1.5
  26   */
  27  class WeblinksController extends JController
  28  {
  29  	function __construct($config = array())
  30      {
  31          parent::__construct($config);
  32  
  33          // Register Extra tasks
  34          $this->registerTask( 'add',  'display' );
  35          $this->registerTask( 'edit', 'display' );
  36      }
  37  
  38  	function display( )
  39      {
  40          switch($this->getTask())
  41          {
  42              case 'add'     :
  43              {
  44                  JRequest::setVar( 'hidemainmenu', 1 );
  45                  JRequest::setVar( 'layout', 'form'  );
  46                  JRequest::setVar( 'view'  , 'weblink');
  47                  JRequest::setVar( 'edit', false );
  48  
  49                  // Checkout the weblink
  50                  $model = $this->getModel('weblink');
  51                  $model->checkout();
  52              } break;
  53              case 'edit'    :
  54              {
  55                  JRequest::setVar( 'hidemainmenu', 1 );
  56                  JRequest::setVar( 'layout', 'form'  );
  57                  JRequest::setVar( 'view'  , 'weblink');
  58                  JRequest::setVar( 'edit', true );
  59  
  60                  // Checkout the weblink
  61                  $model = $this->getModel('weblink');
  62                  $model->checkout();
  63              } break;
  64          }
  65  
  66          parent::display();
  67      }
  68  
  69  	function save()
  70      {
  71          // Check for request forgeries
  72          JRequest::checkToken() or jexit( 'Invalid Token' );
  73  
  74          $post    = JRequest::get('post');
  75          $cid    = JRequest::getVar( 'cid', array(0), 'post', 'array' );
  76          $post['id'] = (int) $cid[0];
  77  
  78          $model = $this->getModel('weblink');
  79  
  80          if ($model->store($post)) {
  81              $msg = JText::_( 'Weblink Saved' );
  82          } else {
  83              $msg = JText::_( 'Error Saving Weblink' );
  84          }
  85  
  86          // Check the table in so it can be edited.... we are done with it anyway
  87          $model->checkin();
  88          $link = 'index.php?option=com_weblinks';
  89          $this->setRedirect($link, $msg);
  90      }
  91  
  92  	function remove()
  93      {
  94          // Check for request forgeries
  95          JRequest::checkToken() or jexit( 'Invalid Token' );
  96  
  97          $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
  98          JArrayHelper::toInteger($cid);
  99  
 100          if (count( $cid ) < 1) {
 101              JError::raiseError(500, JText::_( 'Select an item to delete' ) );
 102          }
 103  
 104          $model = $this->getModel('weblink');
 105          if(!$model->delete($cid)) {
 106              echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
 107          }
 108  
 109          $this->setRedirect( 'index.php?option=com_weblinks' );
 110      }
 111  
 112  
 113  	function publish()
 114      {
 115          // Check for request forgeries
 116          JRequest::checkToken() or jexit( 'Invalid Token' );
 117  
 118          $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
 119          JArrayHelper::toInteger($cid);
 120  
 121          if (count( $cid ) < 1) {
 122              JError::raiseError(500, JText::_( 'Select an item to publish' ) );
 123          }
 124  
 125          $model = $this->getModel('weblink');
 126          if(!$model->publish($cid, 1)) {
 127              echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
 128          }
 129  
 130          $this->setRedirect( 'index.php?option=com_weblinks' );
 131      }
 132  
 133  
 134  	function unpublish()
 135      {
 136          // Check for request forgeries
 137          JRequest::checkToken() or jexit( 'Invalid Token' );
 138  
 139          $cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
 140          JArrayHelper::toInteger($cid);
 141  
 142          if (count( $cid ) < 1) {
 143              JError::raiseError(500, JText::_( 'Select an item to unpublish' ) );
 144          }
 145  
 146          $model = $this->getModel('weblink');
 147          if(!$model->publish($cid, 0)) {
 148              echo "<script> alert('".$model->getError(true)."'); window.history.go(-1); </script>\n";
 149          }
 150  
 151          $this->setRedirect( 'index.php?option=com_weblinks' );
 152      }
 153  
 154  	function cancel()
 155      {
 156          // Check for request forgeries
 157          JRequest::checkToken() or jexit( 'Invalid Token' );
 158  
 159          // Checkin the weblink
 160          $model = $this->getModel('weblink');
 161          $model->checkin();
 162  
 163          $this->setRedirect( 'index.php?option=com_weblinks' );
 164      }
 165  
 166  
 167  	function orderup()
 168      {
 169          // Check for request forgeries
 170          JRequest::checkToken() or jexit( 'Invalid Token' );
 171  
 172          $model = $this->getModel('weblink');
 173          $model->move(-1);
 174  
 175          $this->setRedirect( 'index.php?option=com_weblinks');
 176      }
 177  
 178  	function orderdown()
 179      {
 180          // Check for request forgeries
 181          JRequest::checkToken() or jexit( 'Invalid Token' );
 182  
 183          $model = $this->getModel('weblink');
 184          $model->move(1);
 185  
 186          $this->setRedirect( 'index.php?option=com_weblinks');
 187      }
 188  
 189  	function saveorder()
 190      {
 191          // Check for request forgeries
 192          JRequest::checkToken() or jexit( 'Invalid Token' );
 193  
 194          $cid     = JRequest::getVar( 'cid', array(), 'post', 'array' );
 195          $order     = JRequest::getVar( 'order', array(), 'post', 'array' );
 196          JArrayHelper::toInteger($cid);
 197          JArrayHelper::toInteger($order);
 198  
 199          $model = $this->getModel('weblink');
 200          $model->saveorder($cid, $order);
 201  
 202          $msg = JText::_( 'New ordering saved' );
 203          $this->setRedirect( 'index.php?option=com_weblinks', $msg );
 204      }
 205  }


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