PageRenderTime 19ms CodeModel.GetById 9ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

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