/components/com_content/controller.php

https://bitbucket.org/eternaware/joomus · PHP · 81 lines · 39 code · 12 blank · 30 comment · 13 complexity · 1fa4343614f6d24e8a3feba854e5df37 MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joomla.Site
  4. * @subpackage com_content
  5. *
  6. * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9. defined('_JEXEC') or die;
  10. /**
  11. * Content Component Controller
  12. *
  13. * @package Joomla.Site
  14. * @subpackage com_content
  15. * @since 1.5
  16. */
  17. class ContentController extends JControllerLegacy
  18. {
  19. public function __construct($config = array())
  20. {
  21. $this->input = JFactory::getApplication()->input;
  22. // Article frontpage Editor pagebreak proxying:
  23. if ($this->input->get('view') === 'article' && $this->input->get('layout') === 'pagebreak')
  24. {
  25. $config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
  26. }
  27. // Article frontpage Editor article proxying:
  28. elseif($this->input->get('view') === 'articles' && $this->input->get('layout') === 'modal')
  29. {
  30. JHtml::_('stylesheet', 'system/adminlist.css', array(), true);
  31. $config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
  32. }
  33. parent::__construct($config);
  34. }
  35. /**
  36. * Method to display a view.
  37. *
  38. * @param boolean If true, the view output will be cached
  39. * @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  40. *
  41. * @return JController This object to support chaining.
  42. * @since 1.5
  43. */
  44. public function display($cachable = false, $urlparams = false)
  45. {
  46. $cachable = true;
  47. // Set the default view name and format from the Request.
  48. // Note we are using a_id to avoid collisions with the router and the return page.
  49. // Frontend is a bit messier than the backend.
  50. $id = $this->input->getInt('a_id');
  51. $vName = $this->input->getCmd('view', 'categories');
  52. $this->input->set('view', $vName);
  53. $user = JFactory::getUser();
  54. if ($user->get('id') ||
  55. ($this->input->getMethod() == 'POST' &&
  56. (($vName == 'category' && $this->input->get('layout') != 'blog') || $vName == 'archive' ))) {
  57. $cachable = false;
  58. }
  59. $safeurlparams = array('catid' => 'INT', 'id' => 'INT', 'cid' => 'ARRAY', 'year' => 'INT', 'month' => 'INT', 'limit' => 'UINT', 'limitstart' => 'UINT',
  60. 'showall' => 'INT', 'return' => 'BASE64', 'filter' => 'STRING', 'filter_order' => 'CMD', 'filter_order_Dir' => 'CMD', 'filter-search' => 'STRING', 'print' => 'BOOLEAN', 'lang' => 'CMD');
  61. // Check for edit form.
  62. if ($vName == 'form' && !$this->checkEditId('com_content.edit.article', $id)) {
  63. // Somehow the person just went to the form - we don't allow that.
  64. return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
  65. }
  66. parent::display($cachable, $safeurlparams);
  67. return $this;
  68. }
  69. }