mirror of
https://github.com/joomla-extensions/weblinks.git
synced 2024-06-03 15:00:48 +00:00
f6a5e30925
This reverts commit c4b4dfcc6f
.
114 lines
2.7 KiB
PHP
114 lines
2.7 KiB
PHP
<?php
|
|
/**
|
|
* @package Joomla.Site
|
|
* @subpackage com_weblinks
|
|
*
|
|
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
*/
|
|
|
|
namespace Joomla\Component\Weblinks\Site\View\Category;
|
|
|
|
use Joomla\CMS\MVC\View\CategoryView;
|
|
use Joomla\CMS\Router\Route;
|
|
use Joomla\Component\Weblinks\Site\Helper\RouteHelper;
|
|
use Joomla\Registry\Registry;
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
/**
|
|
* HTML View class for the WebLinks component
|
|
*
|
|
* @since 1.5
|
|
*/
|
|
class HtmlView extends CategoryView
|
|
{
|
|
/**
|
|
* @var string The name of the extension for the category
|
|
* @since 3.2
|
|
*/
|
|
protected $extension = 'com_weblinks';
|
|
|
|
/**
|
|
* 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 a Error object.
|
|
*/
|
|
public function display($tpl = null)
|
|
{
|
|
parent::commonCategoryDisplay();
|
|
|
|
// Prepare the data.
|
|
// Compute the weblink slug & link url.
|
|
foreach ($this->items as $item)
|
|
{
|
|
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
|
|
|
|
if ($item->params->get('count_clicks', $this->params->get('count_clicks', 1)) == 1)
|
|
{
|
|
$item->link = Route::_('index.php?option=com_weblinks&task=weblink.go&id=' . $item->id);
|
|
}
|
|
else
|
|
{
|
|
$item->link = $item->url;
|
|
}
|
|
|
|
$temp = new Registry;
|
|
$temp->loadString($item->params);
|
|
$item->params = clone $this->params;
|
|
$item->params->merge($temp);
|
|
}
|
|
|
|
return parent::display($tpl);
|
|
}
|
|
|
|
/**
|
|
* Prepares the document
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function prepareDocument()
|
|
{
|
|
parent::prepareDocument();
|
|
|
|
parent::addFeed();
|
|
|
|
if ($this->menuItemMatchCategory)
|
|
{
|
|
// If the active menu item is linked directly to the category being displayed, no further process is needed
|
|
return;
|
|
}
|
|
|
|
// Get ID of the category from active menu item
|
|
$menu = $this->menu;
|
|
|
|
if ($menu && $menu->component == 'com_weblinks' && isset($menu->query['view'])
|
|
&& in_array($menu->query['view'], ['categories', 'category']))
|
|
{
|
|
$id = $menu->query['id'];
|
|
}
|
|
else
|
|
{
|
|
$id = 0;
|
|
}
|
|
|
|
$path = [['title' => $this->category->title, 'link' => '']];
|
|
$category = $this->category->getParent();
|
|
|
|
while ($category !== null && $category->id != $id && $category->id !== 'root')
|
|
{
|
|
$path[] = ['title' => $category->title, 'link' => RouteHelper::getCategoryRoute($category->id, $category->language)];
|
|
$category = $category->getParent();
|
|
}
|
|
|
|
$path = array_reverse($path);
|
|
|
|
foreach ($path as $item)
|
|
{
|
|
$this->pathway->addItem($item['title'], $item['link']);
|
|
}
|
|
}
|
|
}
|