98 lines
2.6 KiB
PHP
98 lines
2.6 KiB
PHP
<?php
|
|
/**
|
|
* @package Joomla.Site
|
|
* @subpackage com_foos
|
|
*
|
|
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
*/
|
|
|
|
namespace FooNamespace\Component\Foos\Site\View\Foo;
|
|
|
|
\defined('_JEXEC') or die;
|
|
|
|
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
|
use Joomla\CMS\Factory;
|
|
use Joomla\Registry\Registry;
|
|
|
|
/**
|
|
* HTML Foos View class for the Foo component
|
|
*
|
|
* @since __BUMP_VERSION__
|
|
*/
|
|
class HtmlView extends BaseHtmlView
|
|
{
|
|
/**
|
|
* The page parameters
|
|
*
|
|
* @var \Joomla\Registry\Registry|null
|
|
* @since __BUMP_VERSION__
|
|
*/
|
|
protected $params = null;
|
|
|
|
/**
|
|
* The item model state
|
|
*
|
|
* @var \Joomla\Registry\Registry
|
|
* @since __BUMP_VERSION__
|
|
*/
|
|
protected $state;
|
|
|
|
/**
|
|
* The item object details
|
|
*
|
|
* @var \JObject
|
|
* @since __BUMP_VERSION__
|
|
*/
|
|
protected $item;
|
|
|
|
/**
|
|
* Execute and display a template script.
|
|
*
|
|
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
|
|
*
|
|
* @return mixed A string if successful, otherwise an Error object.
|
|
*/
|
|
public function display($tpl = null)
|
|
{
|
|
$app = Factory::getApplication();
|
|
$item = $this->item = $this->get('Item');
|
|
|
|
$state = $this->get('State');
|
|
$item = $this->get('Item');
|
|
$params = $state->get('params');
|
|
|
|
$temp = clone $params;
|
|
|
|
$active = $app->getMenu()->getActive();
|
|
|
|
if (
|
|
$active
|
|
&& $active->component == 'com_foos'
|
|
&& isset($active->query['view'], $active->query['id'])
|
|
&& $active->query['view'] == 'foo'
|
|
&& $active->query['id'] == $item->id
|
|
) {
|
|
$item->params->merge($temp);
|
|
} else {
|
|
$temp->merge($item->params);
|
|
$item->params = $temp;
|
|
}
|
|
|
|
Factory::getApplication()->triggerEvent('onContentPrepare', ['com_foos.foo', &$item, &$item->params]);
|
|
|
|
// Store the events for later
|
|
$item->event = new \stdClass;
|
|
$results = Factory::getApplication()->triggerEvent('onContentAfterTitle', ['com_foos.foo', &$item, &$item->params]);
|
|
$item->event->afterDisplayTitle = trim(implode("\n", $results));
|
|
|
|
$results = Factory::getApplication()->triggerEvent('onContentBeforeDisplay', ['com_foos.foo', &$item, &$item->params]);
|
|
$item->event->beforeDisplayContent = trim(implode("\n", $results));
|
|
|
|
$results = Factory::getApplication()->triggerEvent('onContentAfterDisplay', ['com_foos.foo', &$item, &$item->params]);
|
|
$item->event->afterDisplayContent = trim(implode("\n", $results));
|
|
|
|
return parent::display($tpl);
|
|
}
|
|
}
|