PageRenderTime 41ms CodeModel.GetById 9ms RepoModel.GetById 1ms app.codeStats 0ms

/contentmanager/code/trunk/administrator/components/com_contentmanager/controllers/templates.php

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 114 lines | 56 code | 18 blank | 40 comment | 7 complexity | ee2f0a0767cc4c9662742bfa4afbfdc1 MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: templates.php 39 2009-05-21 07:32:36Z eddieajau $
  4. * @copyright Copyright (C) 2009 New Life in IT Pty Ltd. All rights reserved.
  5. * @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
  6. * @link http://www.theartofjoomla.com
  7. */
  8. // no direct access
  9. defined('_JEXEC') or die;
  10. jimport('joomla.application.component.controller');
  11. /**
  12. * @package TAOJ.ContentManager
  13. * @subpackage com_contentmanager
  14. */
  15. class ContentManagerControllerTemplates extends JController
  16. {
  17. /**
  18. * Constructor
  19. */
  20. function __construct()
  21. {
  22. parent::__construct();
  23. $this->registerTask('unpublish', 'publish');
  24. $this->registerTask('trash', 'publish');
  25. }
  26. /**
  27. * Display the view
  28. */
  29. function display()
  30. {
  31. }
  32. /**
  33. * Proxy for getModel
  34. */
  35. function &getModel()
  36. {
  37. return parent::getModel('Template', '', array('ignore_request' => true));
  38. }
  39. /**
  40. * Removes an item
  41. */
  42. function delete()
  43. {
  44. // Check for request forgeries
  45. JRequest::checkToken() or die('Invalid Token');
  46. // Get items to remove from the request.
  47. $cid = JRequest::getVar('cid', array(), '', 'array');
  48. if (!is_array($cid) || count($cid) < 1) {
  49. JError::raiseWarning(500, JText::_('Select an item to delete'));
  50. }
  51. else {
  52. // Get the model.
  53. $model = $this->getModel();
  54. // Make sure the item ids are integers
  55. jimport('joomla.utilities.arrayhelper');
  56. JArrayHelper::toInteger($cid);
  57. // Remove the items.
  58. if (!$model->delete($cid)) {
  59. JError::raiseWarning(500, $model->getError());
  60. }
  61. }
  62. $this->setRedirect('index.php?option=com_contentmanager&view=templates');
  63. }
  64. /**
  65. * Method to publish a list of taxa
  66. *
  67. * @access public
  68. * @return void
  69. * @since 1.0
  70. */
  71. function publish()
  72. {
  73. // Check for request forgeries
  74. JRequest::checkToken() or die('Invalid Token');
  75. // Get items to publish from the request.
  76. $cid = JRequest::getVar('cid', array(), '', 'array');
  77. $values = array('publish' => 1, 'unpublish' => 0, 'trash' => -2);
  78. $task = $this->getTask();
  79. $value = JArrayHelper::getValue($values, $task, 0, 'int');
  80. if (!is_array($cid) || count($cid) < 1) {
  81. JError::raiseWarning(500, JText::_('Select an item to publish'));
  82. }
  83. else
  84. {
  85. // Get the model.
  86. $model = $this->getModel();
  87. // Make sure the item ids are integers
  88. JArrayHelper::toInteger($cid);
  89. // Publish the items.
  90. if (!$model->publish($cid, $value)) {
  91. JError::raiseWarning(500, $model->getError());
  92. }
  93. }
  94. $this->setRedirect('index.php?option=com_contentmanager&view=templates');
  95. }
  96. }