/contentmanager/code/trunk/administrator/components/com_contentmanager/controllers/templates.php
PHP | 114 lines | 56 code | 18 blank | 40 comment | 7 complexity | ee2f0a0767cc4c9662742bfa4afbfdc1 MD5 | raw file
- <?php
- /**
- * @version $Id: templates.php 39 2009-05-21 07:32:36Z eddieajau $
- * @copyright Copyright (C) 2009 New Life in IT Pty Ltd. All rights reserved.
- * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
- * @link http://www.theartofjoomla.com
- */
- // no direct access
- defined('_JEXEC') or die;
- jimport('joomla.application.component.controller');
- /**
- * @package TAOJ.ContentManager
- * @subpackage com_contentmanager
- */
- class ContentManagerControllerTemplates extends JController
- {
- /**
- * Constructor
- */
- function __construct()
- {
- parent::__construct();
- $this->registerTask('unpublish', 'publish');
- $this->registerTask('trash', 'publish');
- }
- /**
- * Display the view
- */
- function display()
- {
- }
- /**
- * Proxy for getModel
- */
- function &getModel()
- {
- return parent::getModel('Template', '', array('ignore_request' => true));
- }
- /**
- * Removes an item
- */
- function delete()
- {
- // Check for request forgeries
- JRequest::checkToken() or die('Invalid Token');
- // Get items to remove from the request.
- $cid = JRequest::getVar('cid', array(), '', 'array');
- if (!is_array($cid) || count($cid) < 1) {
- JError::raiseWarning(500, JText::_('Select an item to delete'));
- }
- else {
- // Get the model.
- $model = $this->getModel();
- // Make sure the item ids are integers
- jimport('joomla.utilities.arrayhelper');
- JArrayHelper::toInteger($cid);
- // Remove the items.
- if (!$model->delete($cid)) {
- JError::raiseWarning(500, $model->getError());
- }
- }
- $this->setRedirect('index.php?option=com_contentmanager&view=templates');
- }
- /**
- * Method to publish a list of taxa
- *
- * @access public
- * @return void
- * @since 1.0
- */
- function publish()
- {
- // Check for request forgeries
- JRequest::checkToken() or die('Invalid Token');
- // Get items to publish from the request.
- $cid = JRequest::getVar('cid', array(), '', 'array');
- $values = array('publish' => 1, 'unpublish' => 0, 'trash' => -2);
- $task = $this->getTask();
- $value = JArrayHelper::getValue($values, $task, 0, 'int');
- if (!is_array($cid) || count($cid) < 1) {
- JError::raiseWarning(500, JText::_('Select an item to publish'));
- }
- else
- {
- // Get the model.
- $model = $this->getModel();
- // Make sure the item ids are integers
- JArrayHelper::toInteger($cid);
- // Publish the items.
- if (!$model->publish($cid, $value)) {
- JError::raiseWarning(500, $model->getError());
- }
- }
- $this->setRedirect('index.php?option=com_contentmanager&view=templates');
- }
- }