first commit

This commit is contained in:
2025-06-17 11:53:18 +02:00
commit 9f0f7ba12b
8804 changed files with 1369176 additions and 0 deletions

View File

@ -0,0 +1,29 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
* @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
*/
use Joomla\Component\Newsfeeds\Site\Helper\RouteHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Newsfeeds Component Route Helper
*
* @since 1.5
*
* @deprecated 4.3 will be removed in 6.0
* Use Joomla\Component\Newsfeeds\Site\Helper\RouteHelper instead
*/
abstract class NewsfeedsHelperRoute extends RouteHelper
{
}

View File

@ -0,0 +1,60 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Newsfeeds\Site\Controller;
use Joomla\CMS\MVC\Controller\BaseController;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Newsfeeds Component Controller
*
* @since 1.5
*/
class DisplayController extends BaseController
{
/**
* Method to show a newsfeeds view
*
* @param boolean $cachable If true, the view output will be cached
* @param array $urlparams An array of safe URL parameters and their variable types.
* @see \Joomla\CMS\Filter\InputFilter::clean() for valid values.
*
* @return static This object to support chaining.
*
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
$cachable = true;
// Set the default view name and format from the Request.
$vName = $this->input->get('view', 'categories');
$this->input->set('view', $vName);
if ($this->app->getIdentity()->get('id') || ($this->input->getMethod() === 'POST' && $vName === 'category')) {
$cachable = false;
}
$safeurlparams = [
'id' => 'INT',
'limit' => 'UINT',
'limitstart' => 'UINT',
'filter_order' => 'CMD',
'filter_order_Dir' => 'CMD',
'lang' => 'CMD',
];
return parent::display($cachable, $safeurlparams);
}
}

View File

@ -0,0 +1,64 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Newsfeeds\Site\Helper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Associations;
use Joomla\Component\Categories\Administrator\Helper\CategoryAssociationHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Newsfeeds Component Association Helper
*
* @since 3.0
*/
abstract class AssociationHelper extends CategoryAssociationHelper
{
/**
* Method to get the associations for a given item
*
* @param integer $id Id of the item
* @param string $view Name of the view
*
* @return array Array of associations for the item
*
* @since 3.0
*/
public static function getAssociations($id = 0, $view = null)
{
$jinput = Factory::getApplication()->getInput();
$view = $view ?? $jinput->get('view');
$id = empty($id) ? $jinput->getInt('id') : $id;
if ($view === 'newsfeed') {
if ($id) {
$associations = Associations::getAssociations('com_newsfeeds', '#__newsfeeds', 'com_newsfeeds.item', $id);
$return = [];
foreach ($associations as $tag => $item) {
$return[$tag] = RouteHelper::getNewsfeedRoute($item->id, (int) $item->catid, $item->language);
}
return $return;
}
}
if ($view === 'category' || $view === 'categories') {
return self::getCategoryAssociations($id, 'com_newsfeeds');
}
return [];
}
}

View File

@ -0,0 +1,81 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Newsfeeds\Site\Helper;
use Joomla\CMS\Categories\CategoryNode;
use Joomla\CMS\Language\Multilanguage;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Newsfeeds Component Route Helper
*
* @since 1.5
*/
abstract class RouteHelper
{
/**
* getNewsfeedRoute
*
* @param int $id menu itemid
* @param int $catid category id
* @param int $language language
*
* @return string
*/
public static function getNewsfeedRoute($id, $catid, $language = 0)
{
// Create the link
$link = 'index.php?option=com_newsfeeds&view=newsfeed&id=' . $id;
if ((int) $catid > 1) {
$link .= '&catid=' . $catid;
}
if ($language && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
}
return $link;
}
/**
* getCategoryRoute
*
* @param int $catid category id
* @param int $language language
*
* @return string
*/
public static function getCategoryRoute($catid, $language = 0)
{
if ($catid instanceof CategoryNode) {
$id = $catid->id;
} else {
$id = (int) $catid;
}
if ($id < 1) {
$link = '';
} else {
// Create the link
$link = 'index.php?option=com_newsfeeds&view=category&id=' . $id;
if ($language && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
}
}
return $link;
}
}

View File

@ -0,0 +1,156 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Newsfeeds\Site\Model;
use Joomla\CMS\Categories\Categories;
use Joomla\CMS\Categories\CategoryNode;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\Registry\Registry;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* This models supports retrieving lists of newsfeed categories.
*
* @since 1.6
*/
class CategoriesModel extends ListModel
{
/**
* Model context string.
*
* @var string
*/
public $_context = 'com_newsfeeds.categories';
/**
* The category context (allows other extensions to derived from this model).
*
* @var string
*/
protected $_extension = 'com_newsfeeds';
/**
* Parent category of the current one
*
* @var CategoryNode|null
*/
private $_parent = null;
/**
* Array of child-categories
*
* @var CategoryNode[]|null
*/
private $_items = null;
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field
* @param string $direction An optional direction [asc|desc]
*
* @return void
*
* @throws \Exception
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = Factory::getApplication();
$this->setState('filter.extension', $this->_extension);
// Get the parent id if defined.
$parentId = $app->getInput()->getInt('id');
$this->setState('filter.parentId', $parentId);
$params = $app->getParams();
$this->setState('params', $params);
$this->setState('filter.published', 1);
$this->setState('filter.access', true);
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.extension');
$id .= ':' . $this->getState('filter.published');
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.parentId');
return parent::getStoreId($id);
}
/**
* redefine the function and add some properties to make the styling easier
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
if ($this->_items === null) {
$app = Factory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
if ($active) {
$params = $active->getParams();
} else {
$params = new Registry();
}
$options = [];
$options['countItems'] = $params->get('show_cat_items_cat', 1) || !$params->get('show_empty_categories_cat', 0);
$categories = Categories::getInstance('Newsfeeds', $options);
$this->_parent = $categories->get($this->getState('filter.parentId', 'root'));
if (\is_object($this->_parent)) {
$this->_items = $this->_parent->getChildren();
} else {
$this->_items = false;
}
}
return $this->_items;
}
/**
* get the Parent
*
* @return null
*/
public function getParent()
{
if (!\is_object($this->_parent)) {
$this->getItems();
}
return $this->_parent;
}
}

View File

@ -0,0 +1,413 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Newsfeeds\Site\Model;
use Joomla\CMS\Categories\Categories;
use Joomla\CMS\Categories\CategoryNode;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\TagsHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\CMS\Table\Table;
use Joomla\Database\ParameterType;
use Joomla\Registry\Registry;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Newsfeeds Component Category Model
*
* @since 1.5
*/
class CategoryModel extends ListModel
{
/**
* Category items data
*
* @var array
*/
protected $_item;
/**
* Array of newsfeeds in the category
*
* @var \stdClass[]
*/
protected $_articles;
/**
* Category left and right of this one
*
* @var CategoryNode[]|null
*/
protected $_siblings;
/**
* Array of child-categories
*
* @var CategoryNode[]|null
*/
protected $_children;
/**
* Parent category of the current one
*
* @var CategoryNode|null
*/
protected $_parent;
/**
* The category that applies.
*
* @var object
*/
protected $_category;
/**
* The list of other newsfeed categories.
*
* @var array
*/
protected $_categories;
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
* @param MVCFactoryInterface $factory The factory.
*
* @see \Joomla\CMS\MVC\Model\BaseDatabaseModel
* @since 3.2
*/
public function __construct($config = [], MVCFactoryInterface $factory = null)
{
if (empty($config['filter_fields'])) {
$config['filter_fields'] = [
'id', 'a.id',
'name', 'a.name',
'numarticles', 'a.numarticles',
'link', 'a.link',
'ordering', 'a.ordering',
];
}
parent::__construct($config, $factory);
}
/**
* Method to get a list of items.
*
* @return mixed An array of objects on success, false on failure.
*/
public function getItems()
{
// Invoke the parent getItems method to get the main list
$items = parent::getItems();
$taggedItems = [];
// Convert the params field into an object, saving original in _params
foreach ($items as $item) {
if (!isset($this->_params)) {
$item->params = new Registry($item->params);
}
// Some contexts may not use tags data at all, so we allow callers to disable loading tag data
if ($this->getState('load_tags', true)) {
$item->tags = new TagsHelper();
$taggedItems[$item->id] = $item;
}
}
// Load tags of all items.
if ($taggedItems) {
$tagsHelper = new TagsHelper();
$itemIds = array_keys($taggedItems);
foreach ($tagsHelper->getMultipleItemTags('com_newsfeeds.newsfeed', $itemIds) as $id => $tags) {
$taggedItems[$id]->tags->itemTags = $tags;
}
}
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return \Joomla\Database\DatabaseQuery An SQL query
*
* @since 1.6
*/
protected function getListQuery()
{
$user = $this->getCurrentUser();
$groups = $user->getAuthorisedViewLevels();
// Create a new query object.
$db = $this->getDatabase();
/** @var \Joomla\Database\DatabaseQuery $query */
$query = $db->getQuery(true);
// Select required fields from the categories.
$query->select($this->getState('list.select', $db->quoteName('a') . '.*'))
->from($db->quoteName('#__newsfeeds', 'a'))
->whereIn($db->quoteName('a.access'), $groups);
// Filter by category.
if ($categoryId = (int) $this->getState('category.id')) {
$query->where($db->quoteName('a.catid') . ' = :categoryId')
->join('LEFT', $db->quoteName('#__categories', 'c'), $db->quoteName('c.id') . ' = ' . $db->quoteName('a.catid'))
->whereIn($db->quoteName('c.access'), $groups)
->bind(':categoryId', $categoryId, ParameterType::INTEGER);
}
// Filter by state
$state = $this->getState('filter.published');
if (is_numeric($state)) {
$state = (int) $state;
$query->where($db->quoteName('a.published') . ' = :state')
->bind(':state', $state, ParameterType::INTEGER);
} else {
$query->where($db->quoteName('a.published') . ' IN (0,1,2)');
}
// Filter by start and end dates.
if ($this->getState('filter.publish_date')) {
$nowDate = Factory::getDate()->toSql();
$query->extendWhere(
'AND',
[
$db->quoteName('a.publish_up') . ' IS NULL',
$db->quoteName('a.publish_up') . ' <= :nowDate1',
],
'OR'
)
->extendWhere(
'AND',
[
$db->quoteName('a.publish_down') . ' IS NULL',
$db->quoteName('a.publish_down') . ' >= :nowDate2',
],
'OR'
)
->bind([':nowDate1', ':nowDate2'], $nowDate);
}
// Filter by search in title
if ($search = $this->getState('list.filter')) {
$search = '%' . $search . '%';
$query->where($db->quoteName('a.name') . ' LIKE :search')
->bind(':search', $search);
}
// Filter by language
if ($this->getState('filter.language')) {
$query->whereIn($db->quoteName('a.language'), [Factory::getApplication()->getLanguage()->getTag(), '*'], ParameterType::STRING);
}
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering', 'a.ordering')) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
return $query;
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @param string $ordering An optional ordering field
* @param string $direction An optional direction [asc|desc]
*
* @return void
*
* @since 1.6
*
* @throws \Exception
*/
protected function populateState($ordering = null, $direction = null)
{
$app = Factory::getApplication();
$input = $app->getInput();
$params = $app->getParams();
$this->setState('params', $params);
// List state information
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->get('list_limit'), 'uint');
$this->setState('list.limit', $limit);
$limitstart = $input->get('limitstart', 0, 'uint');
$this->setState('list.start', $limitstart);
// Optional filter text
$this->setState('list.filter', $input->getString('filter-search'));
$orderCol = $input->get('filter_order', 'ordering');
if (!\in_array($orderCol, $this->filter_fields)) {
$orderCol = 'ordering';
}
$this->setState('list.ordering', $orderCol);
$listOrder = $input->get('filter_order_Dir', 'ASC');
if (!\in_array(strtoupper($listOrder), ['ASC', 'DESC', ''])) {
$listOrder = 'ASC';
}
$this->setState('list.direction', $listOrder);
$id = $input->get('id', 0, 'int');
$this->setState('category.id', $id);
$user = $this->getCurrentUser();
if ((!$user->authorise('core.edit.state', 'com_newsfeeds')) && (!$user->authorise('core.edit', 'com_newsfeeds'))) {
// Limit to published for people who can't edit or edit.state.
$this->setState('filter.published', 1);
// Filter by start and end dates.
$this->setState('filter.publish_date', true);
}
$this->setState('filter.language', Multilanguage::isEnabled());
}
/**
* Method to get category data for the current category
*
* @return object
*
* @since 1.5
*/
public function getCategory()
{
if (!\is_object($this->_item)) {
$app = Factory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
if ($active) {
$params = $active->getParams();
} else {
$params = new Registry();
}
$options = [];
$options['countItems'] = $params->get('show_cat_items', 1) || $params->get('show_empty_categories', 0);
$categories = Categories::getInstance('Newsfeeds', $options);
$this->_item = $categories->get($this->getState('category.id', 'root'));
if (\is_object($this->_item)) {
$this->_children = $this->_item->getChildren();
$this->_parent = false;
if ($this->_item->getParent()) {
$this->_parent = $this->_item->getParent();
}
$this->_rightsibling = $this->_item->getSibling();
$this->_leftsibling = $this->_item->getSibling(false);
} else {
$this->_children = false;
$this->_parent = false;
}
}
return $this->_item;
}
/**
* Get the parent category.
*
* @return mixed An array of categories or false if an error occurs.
*/
public function getParent()
{
if (!\is_object($this->_item)) {
$this->getCategory();
}
return $this->_parent;
}
/**
* Get the sibling (adjacent) categories.
*
* @return mixed An array of categories or false if an error occurs.
*/
public function &getLeftSibling()
{
if (!\is_object($this->_item)) {
$this->getCategory();
}
return $this->_leftsibling;
}
/**
* Get the sibling (adjacent) categories.
*
* @return mixed An array of categories or false if an error occurs.
*/
public function &getRightSibling()
{
if (!\is_object($this->_item)) {
$this->getCategory();
}
return $this->_rightsibling;
}
/**
* Get the child categories.
*
* @return mixed An array of categories or false if an error occurs.
*/
public function &getChildren()
{
if (!\is_object($this->_item)) {
$this->getCategory();
}
return $this->_children;
}
/**
* Increment the hit counter for the category.
*
* @param int $pk Optional primary key of the category to increment.
*
* @return boolean True if successful; false otherwise and internal error set.
*/
public function hit($pk = 0)
{
$input = Factory::getApplication()->getInput();
$hitcount = $input->getInt('hitcount', 1);
if ($hitcount) {
$pk = (!empty($pk)) ? $pk : (int) $this->getState('category.id');
$table = Table::getInstance('Category', '\\Joomla\\CMS\\Table\\');
$table->hit($pk);
}
return true;
}
}

View File

@ -0,0 +1,225 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Newsfeeds\Site\Model;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\ItemModel;
use Joomla\Database\ParameterType;
use Joomla\Registry\Registry;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Newsfeeds Component Newsfeed Model
*
* @since 1.5
*/
class NewsfeedModel extends ItemModel
{
/**
* Model context string.
*
* @var string
* @since 1.6
*/
protected $_context = 'com_newsfeeds.newsfeed';
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @return void
*
* @since 1.6
*/
protected function populateState()
{
$app = Factory::getApplication();
// Load state from the request.
$pk = $app->getInput()->getInt('id');
$this->setState('newsfeed.id', $pk);
$offset = $app->getInput()->get('limitstart', 0, 'uint');
$this->setState('list.offset', $offset);
// Load the parameters.
$params = $app->getParams();
$this->setState('params', $params);
$user = $this->getCurrentUser();
if ((!$user->authorise('core.edit.state', 'com_newsfeeds')) && (!$user->authorise('core.edit', 'com_newsfeeds'))) {
$this->setState('filter.published', 1);
$this->setState('filter.archived', 2);
}
}
/**
* Method to get newsfeed data.
*
* @param integer $pk The id of the newsfeed.
*
* @return mixed Menu item data object on success, false on failure.
*
* @since 1.6
*/
public function &getItem($pk = null)
{
$pk = (int) $pk ?: (int) $this->getState('newsfeed.id');
if ($this->_item === null) {
$this->_item = [];
}
if (!isset($this->_item[$pk])) {
try {
$db = $this->getDatabase();
$query = $db->getQuery(true)
->select(
[
$this->getState('item.select', $db->quoteName('a') . '.*'),
$db->quoteName('c.title', 'category_title'),
$db->quoteName('c.alias', 'category_alias'),
$db->quoteName('c.access', 'category_access'),
$db->quoteName('u.name', 'author'),
$db->quoteName('parent.title', 'parent_title'),
$db->quoteName('parent.id', 'parent_id'),
$db->quoteName('parent.path', 'parent_route'),
$db->quoteName('parent.alias', 'parent_alias'),
]
)
->from($db->quoteName('#__newsfeeds', 'a'))
->join('LEFT', $db->quoteName('#__categories', 'c'), $db->quoteName('c.id') . ' = ' . $db->quoteName('a.catid'))
->join('LEFT', $db->quoteName('#__users', 'u'), $db->quoteName('u.id') . ' = ' . $db->quoteName('a.created_by'))
->join('LEFT', $db->quoteName('#__categories', 'parent'), $db->quoteName('parent.id') . ' = ' . $db->quoteName('c.parent_id'))
->where($db->quoteName('a.id') . ' = :id')
->bind(':id', $pk, ParameterType::INTEGER);
// Filter by published state.
$published = $this->getState('filter.published');
$archived = $this->getState('filter.archived');
if (is_numeric($published)) {
// Filter by start and end dates.
$nowDate = Factory::getDate()->toSql();
$published = (int) $published;
$archived = (int) $archived;
$query->extendWhere(
'AND',
[
$db->quoteName('a.published') . ' = :published1',
$db->quoteName('a.published') . ' = :archived1',
],
'OR'
)
->extendWhere(
'AND',
[
$db->quoteName('a.publish_up') . ' IS NULL',
$db->quoteName('a.publish_up') . ' <= :nowDate1',
],
'OR'
)
->extendWhere(
'AND',
[
$db->quoteName('a.publish_down') . ' IS NULL',
$db->quoteName('a.publish_down') . ' >= :nowDate2',
],
'OR'
)
->extendWhere(
'AND',
[
$db->quoteName('c.published') . ' = :published2',
$db->quoteName('c.published') . ' = :archived2',
],
'OR'
)
->bind([':published1', ':published2'], $published, ParameterType::INTEGER)
->bind([':archived1', ':archived2'], $archived, ParameterType::INTEGER)
->bind([':nowDate1', ':nowDate2'], $nowDate);
}
$db->setQuery($query);
$data = $db->loadObject();
if ($data === null) {
throw new \Exception(Text::_('COM_NEWSFEEDS_ERROR_FEED_NOT_FOUND'), 404);
}
// Check for published state if filter set.
if ((is_numeric($published) || is_numeric($archived)) && $data->published != $published && $data->published != $archived) {
throw new \Exception(Text::_('COM_NEWSFEEDS_ERROR_FEED_NOT_FOUND'), 404);
}
// Convert parameter fields to objects.
$registry = new Registry($data->params);
$data->params = clone $this->getState('params');
$data->params->merge($registry);
$data->metadata = new Registry($data->metadata);
// Compute access permissions.
if ($access = $this->getState('filter.access')) {
// If the access filter has been set, we already know this user can view.
$data->params->set('access-view', true);
} else {
// If no access filter is set, the layout takes some responsibility for display of limited information.
$user = $this->getCurrentUser();
$groups = $user->getAuthorisedViewLevels();
$data->params->set('access-view', \in_array($data->access, $groups) && \in_array($data->category_access, $groups));
}
$this->_item[$pk] = $data;
} catch (\Exception $e) {
$this->setError($e);
$this->_item[$pk] = false;
}
}
return $this->_item[$pk];
}
/**
* Increment the hit counter for the newsfeed.
*
* @param int $pk Optional primary key of the item to increment.
*
* @return boolean True if successful; false otherwise and internal error set.
*
* @since 3.0
*/
public function hit($pk = 0)
{
$input = Factory::getApplication()->getInput();
$hitcount = $input->getInt('hitcount', 1);
if ($hitcount) {
$pk = (!empty($pk)) ? $pk : (int) $this->getState('newsfeed.id');
$table = $this->getTable('Newsfeed', 'Administrator');
$table->hit($pk);
}
return true;
}
}

View File

@ -0,0 +1,38 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Newsfeeds\Site\Service;
use Joomla\CMS\Categories\Categories;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Newsfeed Component Category Tree
*
* @since 1.6
*/
class Category extends Categories
{
/**
* Constructor
*
* @param array $options options
*/
public function __construct($options = [])
{
$options['table'] = '#__newsfeeds';
$options['extension'] = 'com_newsfeeds';
$options['statefield'] = 'published';
parent::__construct($options);
}
}

View File

@ -0,0 +1,268 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Newsfeeds\Site\Service;
use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Categories\CategoryFactoryInterface;
use Joomla\CMS\Categories\CategoryInterface;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Component\Router\RouterView;
use Joomla\CMS\Component\Router\RouterViewConfiguration;
use Joomla\CMS\Component\Router\Rules\MenuRules;
use Joomla\CMS\Component\Router\Rules\NomenuRules;
use Joomla\CMS\Component\Router\Rules\StandardRules;
use Joomla\CMS\Menu\AbstractMenu;
use Joomla\Database\DatabaseInterface;
use Joomla\Database\ParameterType;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Routing class from com_newsfeeds
*
* @since 3.3
*/
class Router extends RouterView
{
/**
* Flag to remove IDs
*
* @var boolean
*/
protected $noIDs = false;
/**
* The category factory
*
* @var CategoryFactoryInterface
*
* @since 4.0.0
*/
private $categoryFactory;
/**
* The category cache
*
* @var array
*
* @since 4.0.0
*/
private $categoryCache = [];
/**
* The db
*
* @var DatabaseInterface
*
* @since 4.0.0
*/
private $db;
/**
* Newsfeeds Component router constructor
*
* @param SiteApplication $app The application object
* @param AbstractMenu $menu The menu object to work with
* @param CategoryFactoryInterface $categoryFactory The category object
* @param DatabaseInterface $db The database object
*/
public function __construct(SiteApplication $app, AbstractMenu $menu, CategoryFactoryInterface $categoryFactory, DatabaseInterface $db)
{
$this->categoryFactory = $categoryFactory;
$this->db = $db;
$params = ComponentHelper::getParams('com_newsfeeds');
$this->noIDs = (bool) $params->get('sef_ids');
$categories = new RouterViewConfiguration('categories');
$categories->setKey('id');
$this->registerView($categories);
$category = new RouterViewConfiguration('category');
$category->setKey('id')->setParent($categories, 'catid')->setNestable();
$this->registerView($category);
$newsfeed = new RouterViewConfiguration('newsfeed');
$newsfeed->setKey('id')->setParent($category, 'catid');
$this->registerView($newsfeed);
parent::__construct($app, $menu);
$this->attachRule(new MenuRules($this));
$this->attachRule(new StandardRules($this));
$this->attachRule(new NomenuRules($this));
}
/**
* Method to get the segment(s) for a category
*
* @param string $id ID of the category to retrieve the segments for
* @param array $query The request that is built right now
*
* @return array|string The segments of this item
*/
public function getCategorySegment($id, $query)
{
$category = $this->getCategories()->get($id);
if ($category) {
$path = array_reverse($category->getPath(), true);
$path[0] = '1:root';
if ($this->noIDs) {
foreach ($path as &$segment) {
list($id, $segment) = explode(':', $segment, 2);
}
}
return $path;
}
return [];
}
/**
* Method to get the segment(s) for a category
*
* @param string $id ID of the category to retrieve the segments for
* @param array $query The request that is built right now
*
* @return array|string The segments of this item
*/
public function getCategoriesSegment($id, $query)
{
return $this->getCategorySegment($id, $query);
}
/**
* Method to get the segment(s) for a newsfeed
*
* @param string $id ID of the newsfeed to retrieve the segments for
* @param array $query The request that is built right now
*
* @return array|string The segments of this item
*/
public function getNewsfeedSegment($id, $query)
{
if (!strpos($id, ':')) {
$id = (int) $id;
$dbquery = $this->db->getQuery(true);
$dbquery->select($this->db->quoteName('alias'))
->from($this->db->quoteName('#__newsfeeds'))
->where($this->db->quoteName('id') . ' = :id')
->bind(':id', $id, ParameterType::INTEGER);
$this->db->setQuery($dbquery);
$id .= ':' . $this->db->loadResult();
}
if ($this->noIDs) {
list($void, $segment) = explode(':', $id, 2);
return [$void => $segment];
}
return [(int) $id => $id];
}
/**
* Method to get the id for a category
*
* @param string $segment Segment to retrieve the ID for
* @param array $query The request that is parsed right now
*
* @return mixed The id of this item or false
*/
public function getCategoryId($segment, $query)
{
if (isset($query['id'])) {
$category = $this->getCategories(['access' => false])->get($query['id']);
if ($category) {
foreach ($category->getChildren() as $child) {
if ($this->noIDs) {
if ($child->alias === $segment) {
return $child->id;
}
} else {
if ($child->id == (int) $segment) {
return $child->id;
}
}
}
}
}
return false;
}
/**
* Method to get the segment(s) for a category
*
* @param string $segment Segment to retrieve the ID for
* @param array $query The request that is parsed right now
*
* @return mixed The id of this item or false
*/
public function getCategoriesId($segment, $query)
{
return $this->getCategoryId($segment, $query);
}
/**
* Method to get the segment(s) for a newsfeed
*
* @param string $segment Segment of the newsfeed to retrieve the ID for
* @param array $query The request that is parsed right now
*
* @return mixed The id of this item or false
*/
public function getNewsfeedId($segment, $query)
{
if ($this->noIDs) {
$dbquery = $this->db->getQuery(true);
$dbquery->select($this->db->quoteName('id'))
->from($this->db->quoteName('#__newsfeeds'))
->where(
[
$this->db->quoteName('alias') . ' = :segment',
$this->db->quoteName('catid') . ' = :id',
]
)
->bind(':segment', $segment)
->bind(':id', $query['id'], ParameterType::INTEGER);
$this->db->setQuery($dbquery);
return (int) $this->db->loadResult();
}
return (int) $segment;
}
/**
* Method to get categories from cache
*
* @param array $options The options for retrieving categories
*
* @return CategoryInterface The object containing categories
*
* @since 4.0.0
*/
private function getCategories(array $options = []): CategoryInterface
{
$key = serialize($options);
if (!isset($this->categoryCache[$key])) {
$this->categoryCache[$key] = $this->categoryFactory->createCategory($options);
}
return $this->categoryCache[$key];
}
}

View File

@ -0,0 +1,39 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Newsfeeds\Site\View\Categories;
use Joomla\CMS\MVC\View\CategoriesView;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Newsfeed categories view.
*
* @since 1.5
*/
class HtmlView extends CategoriesView
{
/**
* Language key for default page heading
*
* @var string
* @since 3.2
*/
protected $pageHeading = 'COM_NEWSFEEDS_DEFAULT_PAGE_TITLE';
/**
* @var string The name of the extension for the category
* @since 3.2
*/
protected $extension = 'com_newsfeeds';
}

View File

@ -0,0 +1,105 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Newsfeeds\Site\View\Category;
use Joomla\CMS\MVC\View\CategoryView;
use Joomla\Component\Newsfeeds\Site\Helper\RouteHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* HTML View class for the Newsfeeds component
*
* @since 1.0
*/
class HtmlView extends CategoryView
{
/**
* @var string Default title to use for page title
* @since 3.2
*/
protected $defaultPageTitle = 'COM_NEWSFEEDS_DEFAULT_PAGE_TITLE';
/**
* @var string The name of the extension for the category
* @since 3.2
*/
protected $extension = 'com_newsfeeds';
/**
* @var string The name of the view to link individual items to
* @since 3.2
*/
protected $viewName = 'newsfeed';
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*/
public function display($tpl = null)
{
$this->commonCategoryDisplay();
// Flag indicates to not add limitstart=0 to URL
$this->pagination->hideEmptyLimitstart = true;
// Prepare the data.
// Compute the newsfeed slug.
foreach ($this->items as $item) {
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
$temp = $item->params;
$item->params = clone $this->params;
$item->params->merge($temp);
}
parent::display($tpl);
}
/**
* Prepares the document
*
* @return void
*/
protected function prepareDocument()
{
parent::prepareDocument();
$menu = $this->menu;
$id = (int) @$menu->query['id'];
if (
$menu && (!isset($menu->query['option']) || $menu->query['option'] !== 'com_newsfeeds' || $menu->query['view'] === 'newsfeed'
|| $id != $this->category->id)
) {
$path = [['title' => $this->category->title, 'link' => '']];
$category = $this->category->getParent();
while (
(!isset($menu->query['option']) || $menu->query['option'] !== 'com_newsfeeds' || $menu->query['view'] === 'newsfeed'
|| $id != $category->id) && $category->id > 1
) {
$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']);
}
}
}
}

View File

@ -0,0 +1,305 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Newsfeeds\Site\View\Newsfeed;
use Joomla\CMS\Categories\Categories;
use Joomla\CMS\Factory;
use Joomla\CMS\Feed\FeedFactory;
use Joomla\CMS\Helper\TagsHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\View\GenericDataException;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\Component\Newsfeeds\Site\Helper\RouteHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* HTML View class for the Newsfeeds component
*
* @since 1.0
*/
class HtmlView extends BaseHtmlView
{
/**
* The model state
*
* @var object
*
* @since 1.6
*/
protected $state;
/**
* The newsfeed item
*
* @var object
*
* @since 1.6
*/
protected $item;
/**
* UNUSED?
*
* @var boolean
*
* @since 1.6
*/
protected $print;
/**
* The current user instance
*
* @var \Joomla\CMS\User\User|null
*
* @since 4.0.0
*/
protected $user = null;
/**
* The page class suffix
*
* @var string
*
* @since 4.0.0
*/
protected $pageclass_sfx = '';
/**
* The page parameters
*
* @var \Joomla\Registry\Registry|null
*
* @since 4.0.0
*/
protected $params;
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*
* @since 1.6
*/
public function display($tpl = null)
{
$app = Factory::getApplication();
$user = $this->getCurrentUser();
// Get view related request variables.
$print = $app->getInput()->getBool('print');
// Get model data.
$state = $this->get('State');
$item = $this->get('Item');
// Check for errors.
// @TODO: Maybe this could go into ComponentHelper::raiseErrors($this->get('Errors'))
if (\count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
}
// Add router helpers.
$item->slug = $item->alias ? ($item->id . ':' . $item->alias) : $item->id;
$item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid;
$item->parent_slug = $item->category_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id;
// Merge newsfeed params. If this is single-newsfeed view, menu params override newsfeed params
// Otherwise, newsfeed params override menu item params
$params = $state->get('params');
$newsfeed_params = clone $item->params;
$active = $app->getMenu()->getActive();
$temp = clone $params;
// Check to see which parameters should take priority
if ($active) {
$currentLink = $active->link;
// If the current view is the active item and a newsfeed view for this feed, then the menu item params take priority
if (strpos($currentLink, 'view=newsfeed') && strpos($currentLink, '&id=' . (string) $item->id)) {
// $item->params are the newsfeed params, $temp are the menu item params
// Merge so that the menu item params take priority
$newsfeed_params->merge($temp);
$item->params = $newsfeed_params;
// Load layout from active query (in case it is an alternative menu item)
if (isset($active->query['layout'])) {
$this->setLayout($active->query['layout']);
}
} else {
// Current view is not a single newsfeed, so the newsfeed params take priority here
// Merge the menu item params with the newsfeed params so that the newsfeed params take priority
$temp->merge($newsfeed_params);
$item->params = $temp;
// Check for alternative layouts (since we are not in a single-newsfeed menu item)
if ($layout = $item->params->get('newsfeed_layout')) {
$this->setLayout($layout);
}
}
} else {
// Merge so that newsfeed params take priority
$temp->merge($newsfeed_params);
$item->params = $temp;
// Check for alternative layouts (since we are not in a single-newsfeed menu item)
if ($layout = $item->params->get('newsfeed_layout')) {
$this->setLayout($layout);
}
}
// Check the access to the newsfeed
$levels = $user->getAuthorisedViewLevels();
if (!\in_array($item->access, $levels) || (\in_array($item->access, $levels) && (!\in_array($item->category_access, $levels)))) {
$app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error');
$app->setHeader('status', 403, true);
return;
}
// Get the current menu item
$params = $app->getParams();
$params->merge($item->params);
try {
$feed = new FeedFactory();
$this->rssDoc = $feed->getFeed($item->link);
} catch (\InvalidArgumentException $e) {
$msg = Text::_('COM_NEWSFEEDS_ERRORS_FEED_NOT_RETRIEVED');
} catch (\RuntimeException $e) {
$msg = Text::_('COM_NEWSFEEDS_ERRORS_FEED_NOT_RETRIEVED');
}
if (empty($this->rssDoc)) {
$msg = Text::_('COM_NEWSFEEDS_ERRORS_FEED_NOT_RETRIEVED');
}
$feed_display_order = $params->get('feed_display_order', 'des');
if ($feed_display_order === 'asc') {
$this->rssDoc->reverseItems();
}
// Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx', ''));
$this->params = $params;
$this->state = $state;
$this->item = $item;
$this->user = $user;
if (!empty($msg)) {
$this->msg = $msg;
}
$this->print = $print;
$item->tags = new TagsHelper();
$item->tags->getItemTags('com_newsfeeds.newsfeed', $item->id);
// Increment the hit counter of the newsfeed.
$model = $this->getModel();
$model->hit();
$this->_prepareDocument();
parent::display($tpl);
}
/**
* Prepares the document
*
* @return void
*
* @since 1.6
*/
protected function _prepareDocument()
{
$app = Factory::getApplication();
$pathway = $app->getPathway();
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $app->getMenu()->getActive();
if ($menu) {
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
} else {
$this->params->def('page_heading', Text::_('COM_NEWSFEEDS_DEFAULT_PAGE_TITLE'));
}
$title = $this->params->get('page_title', '');
$id = (int) @$menu->query['id'];
// If the menu item does not concern this newsfeed
if (
$menu && (!isset($menu->query['option']) || $menu->query['option'] !== 'com_newsfeeds' || $menu->query['view'] !== 'newsfeed'
|| $id != $this->item->id)
) {
// If this is not a single newsfeed menu item, set the page title to the newsfeed title
if ($this->item->name) {
$title = $this->item->name;
}
$path = [['title' => $this->item->name, 'link' => '']];
$category = Categories::getInstance('Newsfeeds')->get($this->item->catid);
while (
(!isset($menu->query['option']) || $menu->query['option'] !== 'com_newsfeeds' || $menu->query['view'] === 'newsfeed'
|| $id != $category->id) && $category->id > 1
) {
$path[] = ['title' => $category->title, 'link' => RouteHelper::getCategoryRoute($category->id)];
$category = $category->getParent();
}
$path = array_reverse($path);
foreach ($path as $item) {
$pathway->addItem($item['title'], $item['link']);
}
}
if (empty($title)) {
$title = $this->item->name;
}
$this->setDocumentTitle($title);
if ($this->item->metadesc) {
$this->getDocument()->setDescription($this->item->metadesc);
} elseif ($this->params->get('menu-meta_description')) {
$this->getDocument()->setDescription($this->params->get('menu-meta_description'));
}
if ($this->params->get('robots')) {
$this->getDocument()->setMetaData('robots', $this->params->get('robots'));
}
if ($app->get('MetaAuthor') == '1') {
$this->getDocument()->setMetaData('author', $this->item->author);
}
$mdata = $this->item->metadata->toArray();
foreach ($mdata as $k => $v) {
if ($v) {
$this->getDocument()->setMetaData($k, $v);
}
}
}
}

View File

@ -0,0 +1,29 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
// Add strings for translations in Javascript.
Text::script('JGLOBAL_EXPAND_CATEGORIES');
Text::script('JGLOBAL_COLLAPSE_CATEGORIES');
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->getRegistry()->addExtensionRegistryFile('com_categories');
$wa->useScript('com_categories.shared-categories-accordion');
?>
<div class="com-newsfeeds-categories categories-list">
<?php echo LayoutHelper::render('joomla.content.categories_default', $this); ?>
<?php echo $this->loadTemplate('items'); ?>
</div>

View File

@ -0,0 +1,332 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<layout title="COM_NEWSFEEDS_CATEGORIES_VIEW_DEFAULT_TITLE" option="COM_NEWSFEEDS_CATEGORIES_VIEW_DEFAULT_OPTION">
<help
key = "Menu_Item:_List_All_News_Feed_Categories"
/>
<message>
<![CDATA[COM_NEWSFEEDS_CATEGORIES_VIEW_DEFAULT_DESC]]>
</message>
</layout>
<!-- Add fields to the request variables for the layout. -->
<fields name="request">
<fieldset name="request"
>
<field
name="id"
type="category"
label="JGLOBAL_FIELD_CATEGORIES_CHOOSE_CATEGORY_LABEL"
extension="com_newsfeeds"
show_root="true"
required="true"
/>
</fieldset>
</fields>
<!-- Add fields to the parameters object for the layout. -->
<fields name="params">
<fieldset name="basic" label="JGLOBAL_CATEGORIES_OPTIONS">
<field
name="show_base_description"
type="list"
label="JGLOBAL_FIELD_SHOW_BASE_DESCRIPTION_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="categories_description"
type="textarea"
label="JGLOBAL_FIELD_CATEGORIES_DESC_LABEL"
cols="25"
rows="5"
/>
<field
name="maxLevelcat"
type="list"
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
useglobal="true"
validate="options"
>
<option value="-1">JALL</option>
<option value="1">J1</option>
<option value="2">J2</option>
<option value="3">J3</option>
<option value="4">J4</option>
<option value="5">J5</option>
</field>
<field
name="show_empty_categories_cat"
type="list"
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_subcat_desc_cat"
type="list"
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_cat_items_cat"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_CAT_ITEMS_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="category" label="JGLOBAL_CATEGORY_OPTIONS" description="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL">
<field
name="show_category_title"
type="list"
label="JGLOBAL_SHOW_CATEGORY_TITLE"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_description"
type="list"
label="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_description_image"
type="list"
label="JGLOBAL_SHOW_CATEGORY_IMAGE_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="maxLevel"
type="list"
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
useglobal="true"
validate="options"
>
<option value="-1">JALL</option>
<option value="0">JNONE</option>
<option value="1">J1</option>
<option value="2">J2</option>
<option value="3">J3</option>
<option value="4">J4</option>
<option value="5">J5</option>
</field>
<field
name="show_empty_categories"
type="list"
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_subcat_desc"
type="list"
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_cat_items"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_CAT_ITEMS_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="advanced" label="JGLOBAL_LIST_LAYOUT_OPTIONS" description="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL">
<field
name="filter_field"
type="list"
label="JGLOBAL_FILTER_FIELD_LABEL"
default=""
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="hide">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_pagination_limit"
type="list"
label="JGLOBAL_DISPLAY_SELECT_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_headings"
type="list"
label="JGLOBAL_SHOW_HEADINGS_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_articles"
type="list"
label="COM_NEWSFEEDS_FIELD_NUM_ARTICLES_COLUMN_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_link"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_LINKS_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_pagination"
type="list"
label="JGLOBAL_PAGINATION_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
<option value="2">JGLOBAL_AUTO</option>
</field>
<field
name="show_pagination_results"
type="list"
label="JGLOBAL_PAGINATION_RESULTS_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="newsfeed" label="COM_NEWSFEEDS_FIELDSET_MORE_OPTIONS_LABEL">
<field
name="show_feed_image"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_IMAGE_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_feed_description"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_DESCRIPTION_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_item_description"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_ITEM_DESCRIPTION_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="feed_character_count"
type="number"
label="COM_NEWSFEEDS_FIELD_CHARACTER_COUNT_LABEL"
description="COM_NEWSFEEDS_FIELD_CHARACTER_COUNT_DESC"
filter="integer"
useglobal="true"
/>
</fieldset>
</fields>
</metadata>

View File

@ -0,0 +1,66 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\Component\Newsfeeds\Site\Helper\RouteHelper;
?>
<?php if ($this->maxLevelcat != 0 && count($this->items[$this->parent->id]) > 0) : ?>
<?php foreach ($this->items[$this->parent->id] as $id => $item) : ?>
<?php if ($this->params->get('show_empty_categories_cat') || $item->numitems || count($item->getChildren())) : ?>
<div class="com-newsfeeds-categories__items">
<h3 class="page-header item-title">
<a href="<?php echo Route::_(RouteHelper::getCategoryRoute($item->id, $item->language)); ?>">
<?php echo $this->escape($item->title); ?>
</a>
<?php if ($this->params->get('show_cat_items_cat') == 1) : ?>
<span class="badge bg-info">
<?php echo Text::_('COM_NEWSFEEDS_NUM_ITEMS'); ?>&nbsp;
<?php echo $item->numitems; ?>
</span>
<?php endif; ?>
<?php if (count($item->getChildren()) > 0 && $this->maxLevelcat > 1) : ?>
<button
type="button"
id="category-btn-<?php echo $item->id; ?>"
data-bs-target="#category-<?php echo $item->id; ?>"
data-bs-toggle="collapse"
class="btn btn-secondary btn-sm float-end"
aria-label="<?php echo Text::_('JGLOBAL_EXPAND_CATEGORIES'); ?>"
>
<span class="icon-plus" aria-hidden="true"></span>
</button>
<?php endif; ?>
</h3>
<?php if ($this->params->get('show_subcat_desc_cat') == 1) : ?>
<?php if ($item->description) : ?>
<div class="com-newsfeeds-categories__description category-desc">
<?php echo HTMLHelper::_('content.prepare', $item->description, '', 'com_newsfeeds.categories'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if (count($item->getChildren()) > 0 && $this->maxLevelcat > 1) : ?>
<div class="com-newsfeeds-categories__children collapse fade" id="category-<?php echo $item->id; ?>">
<?php $this->items[$item->id] = $item->getChildren(); ?>
<?php $this->parent = $item; ?>
<?php $this->maxLevelcat--; ?>
<?php echo $this->loadTemplate('items'); ?>
<?php $this->parent = $item->getParent(); ?>
<?php $this->maxLevelcat++; ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>

View File

@ -0,0 +1,61 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Layout\LayoutHelper;
$htag = $this->params->get('show_page_heading') ? 'h2' : 'h1';
?>
<div class="com-newsfeeds-category newsfeed-category">
<?php if ($this->params->get('show_page_heading')) : ?>
<h1>
<?php echo $this->escape($this->params->get('page_heading')); ?>
</h1>
<?php endif; ?>
<?php if ($this->params->get('show_category_title', 1)) : ?>
<<?php echo $htag; ?>>
<?php echo HTMLHelper::_('content.prepare', $this->category->title, '', 'com_newsfeeds.category.title'); ?>
</<?php echo $htag; ?>>
<?php endif; ?>
<?php if ($this->params->get('show_tags', 1) && !empty($this->category->tags->itemTags)) : ?>
<?php $this->category->tagLayout = new FileLayout('joomla.content.tags'); ?>
<?php echo $this->category->tagLayout->render($this->category->tags->itemTags); ?>
<?php endif; ?>
<?php if ($this->params->get('show_description', 1) || $this->params->def('show_description_image', 1)) : ?>
<div class="com-newsfeeds-category__description category-desc">
<?php if ($this->params->get('show_description_image') && $this->category->getParams()->get('image')) : ?>
<?php echo LayoutHelper::render(
'joomla.html.image',
[
'src' => $this->category->getParams()->get('image'),
'alt' => empty($this->category->getParams()->get('image_alt')) && empty($this->category->getParams()->get('image_alt_empty')) ? false : $this->category->getParams()->get('image_alt'),
]
); ?>
<?php endif; ?>
<?php if ($this->params->get('show_description') && $this->category->description) : ?>
<?php echo HTMLHelper::_('content.prepare', $this->category->description, '', 'com_newsfeeds.category'); ?>
<?php endif; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php echo $this->loadTemplate('items'); ?>
<?php if ($this->maxLevel != 0 && !empty($this->children[$this->category->id])) : ?>
<div class="com-newsfeeds-category__children cat-children">
<h3>
<?php echo Text::_('JGLOBAL_SUBCATEGORIES'); ?>
</h3>
<?php echo $this->loadTemplate('children'); ?>
</div>
<?php endif; ?>
</div>

View File

@ -0,0 +1,259 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<layout title="COM_NEWSFEEDS_CATEGORY_VIEW_DEFAULT_TITLE" option="COM_NEWSFEEDS_CATEGORY_VIEW_DEFAULT_OPTION">
<help
key = "Menu_Item:_List_News_Feeds_in_a_Category"
/>
<message>
<![CDATA[COM_NEWSFEEDS_CATEGORY_VIEW_DEFAULT_DESC]]>
</message>
</layout>
<!-- Add fields to the request variables for the layout. -->
<fields name="request">
<fieldset
name="request"
addfieldprefix="Joomla\Component\Categories\Administrator\Field"
>
<field
name="id"
type="modal_category"
label="JCATEGORY"
extension="com_newsfeeds"
required="true"
select="true"
new="true"
edit="true"
clear="true"
/>
</fieldset>
</fields>
<!-- Add fields to the parameters object for the layout. -->
<fields name="params">
<fieldset name="basic" label="JGLOBAL_CATEGORY_OPTIONS" description="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL">
<field
name="show_category_title"
type="list"
label="JGLOBAL_SHOW_CATEGORY_TITLE"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_description"
type="list"
label="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_description_image"
type="list"
label="JGLOBAL_SHOW_CATEGORY_IMAGE_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="maxLevel"
type="list"
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
useglobal="true"
validate="options"
>
<option value="-1">JALL</option>
<option value="0">JNONE</option>
<option value="1">J1</option>
<option value="2">J2</option>
<option value="3">J3</option>
<option value="4">J4</option>
<option value="5">J5</option>
</field>
<field
name="show_empty_categories"
type="list"
label="JGLOBAL_SHOW_EMPTY_CATEGORIES_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_subcat_desc"
type="list"
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_cat_items"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_CAT_ITEMS_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="advanced" label="JGLOBAL_LIST_LAYOUT_OPTIONS" description="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL">
<field
name="filter_field"
type="list"
label="JGLOBAL_FILTER_FIELD_LABEL"
default=""
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="hide">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_pagination_limit"
type="list"
label="JGLOBAL_DISPLAY_SELECT_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_articles"
type="list"
label="COM_NEWSFEEDS_FIELD_NUM_ARTICLES_COLUMN_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_link"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_LINKS_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_pagination"
type="list"
label="JGLOBAL_PAGINATION_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
<option value="2">JGLOBAL_AUTO</option>
</field>
<field
name="show_pagination_results"
type="list"
label="JGLOBAL_PAGINATION_RESULTS_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="newsfeed" label="COM_NEWSFEEDS_FIELDSET_MORE_OPTIONS_LABEL">
<field
name="show_feed_image"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_IMAGE_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_feed_description"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_DESCRIPTION_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_item_description"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_ITEM_DESCRIPTION_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="feed_character_count"
type="number"
label="COM_NEWSFEEDS_FIELD_CHARACTER_COUNT_LABEL"
description="COM_NEWSFEEDS_FIELD_CHARACTER_COUNT_DESC"
filter="integer"
useglobal="true"
/>
<field
name="feed_display_order"
type="list"
label="COM_NEWSFEEDS_FIELD_FEED_DISPLAY_ORDER_LABEL"
useglobal="true"
validate="options"
>
<option value="des">JGLOBAL_MOST_RECENT_FIRST</option>
<option value="asc">JGLOBAL_OLDEST_FIRST</option>
</field>
</fieldset>
</fields>
</metadata>

View File

@ -0,0 +1,54 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\Component\Newsfeeds\Site\Helper\RouteHelper;
defined('_JEXEC') or die;
?>
<?php if ($this->maxLevel != 0 && count($this->children[$this->category->id]) > 0) : ?>
<ul>
<?php foreach ($this->children[$this->category->id] as $id => $child) : ?>
<?php if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) : ?>
<li>
<span class="item-title">
<a href="<?php echo Route::_(RouteHelper::getCategoryRoute($child->id, $child->language)); ?>">
<?php echo $this->escape($child->title); ?>
</a>
</span>
<?php if ($this->params->get('show_subcat_desc') == 1) : ?>
<?php if ($child->description) : ?>
<div class="category-desc">
<?php echo HTMLHelper::_('content.prepare', $child->description, '', 'com_newsfeeds.category'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($this->params->get('show_cat_items') == 1) : ?>
<span class="badge bg-info">
<?php echo Text::_('COM_NEWSFEEDS_CAT_NUM'); ?>&nbsp;
<?php echo $child->numitems; ?>
</span>
<?php endif; ?>
<?php if (count($child->getChildren()) > 0) : ?>
<?php $this->children[$child->id] = $child->getChildren(); ?>
<?php $this->category = $child; ?>
<?php $this->maxLevel--; ?>
<?php echo $this->loadTemplate('children'); ?>
<?php $this->category = $child->getParent(); ?>
<?php $this->maxLevel++; ?>
<?php endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif;

View File

@ -0,0 +1,98 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
use Joomla\CMS\String\PunycodeHelper;
use Joomla\CMS\Uri\Uri;
use Joomla\Component\Newsfeeds\Site\Helper\RouteHelper;
$n = count($this->items);
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
?>
<div class="com-newsfeeds-category__items">
<?php if (empty($this->items)) : ?>
<p><?php echo Text::_('COM_NEWSFEEDS_NO_ARTICLES'); ?></p>
<?php else : ?>
<form action="<?php echo htmlspecialchars(Uri::getInstance()->toString(), ENT_COMPAT, 'UTF-8'); ?>" method="post" name="adminForm" id="adminForm">
<?php if ($this->params->get('filter_field') !== 'hide' || $this->params->get('show_pagination_limit')) : ?>
<fieldset class="com-newsfeeds-category__filters filters">
<?php if ($this->params->get('filter_field') !== 'hide' && $this->params->get('filter_field') == '1') : ?>
<div class="btn-group">
<label class="filter-search-lbl visually-hidden" for="filter-search">
<?php echo Text::_('COM_NEWSFEEDS_FILTER_LABEL') . '&#160;'; ?>
</label>
<input type="text" name="filter-search" id="filter-search" value="<?php echo $this->escape($this->state->get('list.filter')); ?>" class="inputbox" onchange="document.adminForm.submit();" placeholder="<?php echo Text::_('COM_NEWSFEEDS_FILTER_SEARCH_DESC'); ?>">
</div>
<?php endif; ?>
<?php if ($this->params->get('show_pagination_limit')) : ?>
<div class="btn-group float-end">
<label for="limit" class="visually-hidden">
<?php echo Text::_('JGLOBAL_DISPLAY_NUM'); ?>
</label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<?php endif; ?>
</fieldset>
<?php endif; ?>
<ul class="com-newsfeeds-category__category list-group list-unstyled">
<?php foreach ($this->items as $item) : ?>
<li class="list-group-item">
<?php if ($this->params->get('show_articles')) : ?>
<span class="list-hits badge bg-info float-end">
<?php echo Text::sprintf('COM_NEWSFEEDS_NUM_ARTICLES_COUNT', $item->numarticles); ?>
</span>
<?php endif; ?>
<span class="list float-start">
<div class="list-title">
<a href="<?php echo Route::_(RouteHelper::getNewsfeedRoute($item->slug, $item->catid)); ?>">
<?php echo $item->name; ?>
</a>
</div>
</span>
<?php if ($item->published == 0) : ?>
<span class="badge bg-warning text-light">
<?php echo Text::_('JUNPUBLISHED'); ?>
</span>
<?php endif; ?>
<br>
<?php if ($this->params->get('show_link')) : ?>
<?php $link = PunycodeHelper::urlToUTF8($item->link); ?>
<span class="list float-start">
<a href="<?php echo $item->link; ?>">
<?php echo $link; ?>
</a>
</span>
<br>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php // Add pagination links ?>
<?php if (!empty($this->items)) : ?>
<?php if (($this->params->def('show_pagination', 2) == 1 || ($this->params->get('show_pagination') == 2)) && ($this->pagination->pagesTotal > 1)) : ?>
<div class="com-newsfeeds-category__pagination w-100">
<?php if ($this->params->def('show_pagination_results', 1)) : ?>
<p class="counter float-end pt-3 pe-2">
<?php echo $this->pagination->getPagesCounter(); ?>
</p>
<?php endif; ?>
<?php echo $this->pagination->getPagesLinks(); ?>
</div>
<?php endif; ?>
<?php endif; ?>
</form>
<?php endif; ?>
</div>

View File

@ -0,0 +1,156 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\Filter\OutputFilter;
?>
<?php if (!empty($this->msg)) : ?>
<?php echo $this->msg; ?>
<?php else : ?>
<?php $lang = $this->getLanguage(); ?>
<?php $myrtl = $this->item->rtl; ?>
<?php $direction = ' '; ?>
<?php $isRtl = $lang->isRtl(); ?>
<?php if ($isRtl && $myrtl == 0) : ?>
<?php $direction = ' redirect-rtl'; ?>
<?php elseif ($isRtl && $myrtl == 1) : ?>
<?php $direction = ' redirect-ltr'; ?>
<?php elseif ($isRtl && $myrtl == 2) : ?>
<?php $direction = ' redirect-rtl'; ?>
<?php elseif ($myrtl == 0) : ?>
<?php $direction = ' redirect-ltr'; ?>
<?php elseif ($myrtl == 1) : ?>
<?php $direction = ' redirect-ltr'; ?>
<?php elseif ($myrtl == 2) : ?>
<?php $direction = ' redirect-rtl'; ?>
<?php endif; ?>
<?php $images = json_decode($this->item->images); ?>
<div class="com-newsfeeds-newsfeed newsfeed<?php echo $direction; ?>">
<?php if ($this->params->get('display_num')) : ?>
<h1 class="<?php echo $direction; ?>">
<?php echo $this->escape($this->params->get('page_heading')); ?>
</h1>
<?php endif; ?>
<h2 class="<?php echo $direction; ?>">
<?php if ($this->item->published == 0) : ?>
<span class="badge bg-warning text-light"><?php echo Text::_('JUNPUBLISHED'); ?></span>
<?php endif; ?>
<a href="<?php echo $this->item->link; ?>" target="_blank" rel="noopener">
<?php echo str_replace('&apos;', "'", $this->item->name); ?>
</a>
</h2>
<?php if ($this->params->get('show_tags', 1)) : ?>
<?php $this->item->tagLayout = new FileLayout('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
<?php endif; ?>
<!-- Show Images from Component -->
<?php if (isset($images->image_first) && !empty($images->image_first)) : ?>
<?php $imgfloat = empty($images->float_first) ? $this->params->get('float_first') : $images->float_first; ?>
<div class="com-newsfeeds-newsfeed__first-image img-intro-<?php echo $this->escape($imgfloat); ?>">
<figure>
<?php echo LayoutHelper::render(
'joomla.html.image',
[
'src' => $images->image_first,
'alt' => empty($images->image_first_alt) && empty($images->image_first_alt_empty) ? false : $images->image_first_alt,
]
); ?>
<?php if ($images->image_first_caption) : ?>
<figcaption class="caption"><?php echo $this->escape($images->image_first_caption); ?></figcaption>
<?php endif; ?>
</figure>
</div>
<?php endif; ?>
<?php if (isset($images->image_second) && !empty($images->image_second)) : ?>
<?php $imgfloat = empty($images->float_second) ? $this->params->get('float_second') : $images->float_second; ?>
<div class="com-newsfeeds-newsfeed__second-image float-<?php echo $this->escape($imgfloat); ?> item-image">
<figure>
<?php echo LayoutHelper::render(
'joomla.html.image',
[
'src' => $images->image_second,
'alt' => empty($images->image_second_alt) && empty($images->image_second_alt_empty) ? false : $images->image_second_alt,
]
); ?>
<?php if ($images->image_second_caption) : ?>
<figcaption class="caption"><?php echo $this->escape($images->image_second_caption); ?></figcaption>
<?php endif; ?>
</figure>
</div>
<?php endif; ?>
<!-- Show Description from Component -->
<?php echo $this->item->description; ?>
<!-- Show Feed's Description -->
<?php if ($this->params->get('show_feed_description')) : ?>
<div class="com-newsfeeds-newsfeed__description feed-description">
<?php echo str_replace('&apos;', "'", $this->rssDoc->description); ?>
</div>
<?php endif; ?>
<!-- Show Image -->
<?php if ($this->rssDoc->image && $this->params->get('show_feed_image')) : ?>
<div class="com-newsfeeds-newsfeed__feed-image">
<?php echo LayoutHelper::render(
'joomla.html.image',
[
'src' => $this->rssDoc->image->uri,
'alt' => $this->rssDoc->image->title,
]
); ?>
</div>
<?php endif; ?>
<!-- Show items -->
<?php if (!empty($this->rssDoc[0])) : ?>
<ul class="com-newsfeeds-newsfeed__items">
<?php for ($i = 0; $i < $this->item->numarticles; $i++) : ?>
<?php if (empty($this->rssDoc[$i])) : ?>
<?php break; ?>
<?php endif; ?>
<?php $uri = $this->rssDoc[$i]->uri || !$this->rssDoc[$i]->isPermaLink ? trim($this->rssDoc[$i]->uri) : trim($this->rssDoc[$i]->guid); ?>
<?php $uri = !$uri || stripos($uri, 'http') !== 0 ? $this->item->link : $uri; ?>
<?php $text = $this->rssDoc[$i]->content !== '' ? trim($this->rssDoc[$i]->content) : ''; ?>
<li>
<?php if (!empty($uri)) : ?>
<h3 class="feed-link">
<a href="<?php echo htmlspecialchars($uri); ?>" target="_blank" rel="noopener">
<?php echo trim($this->rssDoc[$i]->title); ?>
</a>
</h3>
<?php else : ?>
<h3 class="feed-link"><?php echo trim($this->rssDoc[$i]->title); ?></h3>
<?php endif; ?>
<?php if ($this->params->get('show_item_description') && $text !== '') : ?>
<div class="feed-item-description">
<?php if ($this->params->get('show_feed_image', 0) == 0) : ?>
<?php $text = OutputFilter::stripImages($text); ?>
<?php endif; ?>
<?php $text = HTMLHelper::_('string.truncate', $text, $this->params->get('feed_character_count')); ?>
<?php echo str_replace('&apos;', "'", $text); ?>
</div>
<?php endif; ?>
</li>
<?php endfor; ?>
</ul>
<?php endif; ?>
</div>
<?php endif; ?>

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<layout title="COM_NEWSFEEDS_NEWSFEED_VIEW_DEFAULT_TITLE" option="COM_NEWSFEEDS_NEWSFEED_VIEW_DEFAULT_OPTION">
<help
key = "Menu_Item:_Single_News_Feed"
/>
<message>
<![CDATA[COM_NEWSFEEDS_NEWSFEED_VIEW_DEFAULT_DESC]]>
</message>
</layout>
<!-- Add fields to the request variables for the layout. -->
<fields name="request">
<fieldset name="request"
addfieldprefix="Joomla\Component\Newsfeeds\Administrator\Field"
>
<field
name="id"
type="modal_newsfeed"
label="COM_NEWSFEEDS_FIELD_SELECT_FEED_LABEL"
required="true"
select="true"
new="true"
edit="true"
clear="true"
/>
</fieldset>
</fields>
<!-- Add fields to the parameters object for the layout. -->
<fields name="params">
<!-- Basic options. -->
<fieldset name="basic" label="COM_NEWSFEEDS_FIELDSET_MORE_OPTIONS_LABEL">
<field
name="show_feed_image"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_IMAGE_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_feed_description"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_DESCRIPTION_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_item_description"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_ITEM_DESCRIPTION_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="show_tags"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_TAGS_LABEL"
useglobal="true"
class="form-select-color-state"
validate="options"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
name="feed_character_count"
type="number"
label="COM_NEWSFEEDS_FIELD_CHARACTER_COUNT_LABEL"
description="COM_NEWSFEEDS_FIELD_CHARACTER_COUNT_DESC"
filter="integer"
useglobal="true"
/>
<field
name="feed_display_order"
type="list"
label="COM_NEWSFEEDS_FIELD_FEED_DISPLAY_ORDER_LABEL"
useglobal="true"
validate="options"
>
<option value="des">JGLOBAL_MOST_RECENT_FIRST</option>
<option value="asc">JGLOBAL_OLDEST_FIRST</option>
</field>
</fieldset>
</fields>
</metadata>