1<?php 2/** 3 * @package Joomla.Site 4 * @subpackage com_config 5 * 6 * @copyright Copyright (C) 2005 - 2020 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 * Base Display Controller 14 * 15 * @since 3.2 16 */ 17class ConfigControllerDisplay extends JControllerBase 18{ 19 /** 20 * Application object - Redeclared for proper typehinting 21 * 22 * @var JApplicationCms 23 * @since 3.2 24 */ 25 protected $app; 26 27 /** 28 * Prefix for the view and model classes 29 * 30 * @var string 31 * @since 3.2 32 */ 33 public $prefix = 'Config'; 34 35 /** 36 * Execute the controller. 37 * 38 * @return mixed A rendered view or true 39 * 40 * @since 3.2 41 */ 42 public function execute() 43 { 44 // Get the document object. 45 $document = JFactory::getDocument(); 46 47 $componentFolder = $this->input->getWord('option', 'com_config'); 48 49 if ($this->app->isClient('administrator')) 50 { 51 $viewName = $this->input->getWord('view', 'application'); 52 } 53 else 54 { 55 $viewName = $this->input->getWord('view', 'config'); 56 } 57 58 $viewFormat = $document->getType(); 59 $layoutName = $this->input->getWord('layout', 'default'); 60 61 // Register the layout paths for the view 62 $paths = new SplPriorityQueue; 63 64 if ($this->app->isClient('administrator')) 65 { 66 $paths->insert(JPATH_ADMINISTRATOR . '/components/' . $componentFolder . '/view/' . $viewName . '/tmpl', 1); 67 } 68 else 69 { 70 $paths->insert(JPATH_BASE . '/components/' . $componentFolder . '/view/' . $viewName . '/tmpl', 1); 71 } 72 73 $viewClass = $this->prefix . 'View' . ucfirst($viewName) . ucfirst($viewFormat); 74 $modelClass = $this->prefix . 'Model' . ucfirst($viewName); 75 76 if (class_exists($viewClass)) 77 { 78 $model = new $modelClass; 79 $component = $model->getState()->get('component.option'); 80 81 // Make sure com_joomlaupdate and com_privacy can only be accessed by SuperUser 82 if (in_array(strtolower($component), array('com_joomlaupdate', 'com_privacy')) 83 && !JFactory::getUser()->authorise('core.admin')) 84 { 85 $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error'); 86 87 return; 88 } 89 90 // Access check. 91 if (!JFactory::getUser()->authorise('core.admin', $component) 92 && !JFactory::getUser()->authorise('core.options', $component)) 93 { 94 $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error'); 95 96 return; 97 } 98 99 $view = new $viewClass($model, $paths); 100 101 $view->setLayout($layoutName); 102 103 // Push document object into the view. 104 $view->document = $document; 105 106 // Reply for service requests 107 if ($viewFormat === 'json') 108 { 109 $this->app->allowCache(false); 110 return $view->render(); 111 } 112 113 // Render view. 114 echo $view->render(); 115 } 116 117 return true; 118 } 119} 120