first commit

This commit is contained in:
alazhar
2020-01-02 22:20:31 +07:00
commit 10eb3340ad
5753 changed files with 631345 additions and 0 deletions

View File

@ -0,0 +1,49 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Newsfeeds Component Controller
*
* @package Joomla.Site
* @subpackage com_newsfeeds
* @since 1.5
*/
class NewsfeedsController extends JControllerLegacy
{
/**
* Method to show a newsfeeds view
*
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController 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);
$user = JFactory::getUser();
if ($user->get('id') || ($this->input->getMethod() == 'POST' && $vName = 'category' ))
{
$cachable = false;
}
$safeurlparams = array('id' => 'INT', 'limit' => 'UINT', 'limitstart' => 'UINT', 'filter_order' => 'CMD', 'filter_order_Dir' => 'CMD', 'lang' => 'CMD');
parent::display($cachable, $safeurlparams);
}
}

View File

@ -0,0 +1,69 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JLoader::register('NewsfeedsHelper', JPATH_ADMINISTRATOR . '/components/com_newsfeeds/helpers/newsfeeds.php');
JLoader::register('CategoryHelperAssociation', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/association.php');
/**
* Newsfeeds Component Association Helper
*
* @package Joomla.Site
* @subpackage com_contact
* @since 3.0
*/
abstract class NewsfeedsHelperAssociation extends CategoryHelperAssociation
{
/**
* 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)
{
jimport('helper.route', JPATH_COMPONENT_SITE);
$app = JFactory::getApplication();
$jinput = $app->input;
$view = is_null($view) ? $jinput->get('view') : $view;
$id = empty($id) ? $jinput->getInt('id') : $id;
if ($view == 'newsfeed')
{
if ($id)
{
$associations = JLanguageAssociations::getAssociations('com_newsfeeds', '#__newsfeeds', 'com_newsfeeds.item', $id);
$return = array();
foreach ($associations as $tag => $item)
{
$return[$tag] = NewsfeedsHelperRoute::getNewsfeedRoute($item->id, $item->catid, $item->language);
}
return $return;
}
}
if ($view == 'category' || $view == 'categories')
{
return self::getCategoryAssociations($id, 'com_newsfeeds');
}
return array();
}
}

View File

@ -0,0 +1,28 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Content Component Category Tree
*
* @package Joomla.Site
* @subpackage com_newsfeeds
* @since 1.6
*/
class NewsfeedsCategories extends JCategories
{
public function __construct($options = array())
{
$options['table'] = '#__newsfeeds';
$options['extension'] = 'com_newsfeeds';
$options['statefield'] = 'published';
parent::__construct($options);
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,229 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Newsfeeds Component Route Helper
*
* @package Joomla.Site
* @subpackage com_newsfeeds
* @since 1.5
*/
abstract class NewsfeedsHelperRoute
{
protected static $lookup;
/**
* @param integer The route of the newsfeed
*/
public static function getNewsfeedRoute($id, $catid, $language = 0)
{
$needles = array(
'newsfeed' => array((int) $id)
);
//Create the link
$link = 'index.php?option=com_newsfeeds&view=newsfeed&id='. $id;
if ((int) $catid > 1)
{
$categories = JCategories::getInstance('Newsfeeds');
$category = $categories->get((int) $catid);
if ($category)
{
//TODO Throw error that the category either not exists or is unpublished
$needles['category'] = array_reverse($category->getPath());
$needles['categories'] = $needles['category'];
$link .= '&catid='.$catid;
}
}
if ($language && $language != "*" && JLanguageMultilang::isEnabled())
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.sef AS sef')
->select('a.lang_code AS lang_code')
->from('#__languages AS a');
$db->setQuery($query);
$langs = $db->loadObjectList();
foreach ($langs as $lang)
{
if ($language == $lang->lang_code)
{
$link .= '&lang='.$lang->sef;
$needles['language'] = $language;
}
}
}
if ($item = self::_findItem($needles))
{
$link .= '&Itemid='.$item;
}
elseif ($item = self::_findItem())
{
$link .= '&Itemid='.$item;
}
return $link;
}
public static function getCategoryRoute($catid, $language = 0)
{
if ($catid instanceof JCategoryNode)
{
$id = $catid->id;
$category = $catid;
}
else
{
$id = (int) $catid;
$category = JCategories::getInstance('Newsfeeds')->get($id);
}
if ($id < 1)
{
$link = '';
}
else
{
//Create the link
$link = 'index.php?option=com_newsfeeds&view=category&id='.$id;
$needles = array(
'category' => array($id)
);
if ($language && $language != "*" && JLanguageMultilang::isEnabled())
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('a.sef AS sef')
->select('a.lang_code AS lang_code')
->from('#__languages AS a');
$db->setQuery($query);
$langs = $db->loadObjectList();
foreach ($langs as $lang)
{
if ($language == $lang->lang_code)
{
$link .= '&lang='.$lang->sef;
$needles['language'] = $language;
}
}
}
if ($item = self::_findItem($needles))
{
$link .= '&Itemid='.$item;
}
else
{
if ($category)
{
$catids = array_reverse($category->getPath());
$needles = array(
'category' => $catids,
'categories' => $catids
);
if ($item = self::_findItem($needles))
{
$link .= '&Itemid='.$item;
}
elseif ($item = self::_findItem())
{
$link .= '&Itemid='.$item;
}
}
}
}
return $link;
}
protected static function _findItem($needles = null)
{
$app = JFactory::getApplication();
$menus = $app->getMenu('site');
$language = isset($needles['language']) ? $needles['language'] : '*';
// Prepare the reverse lookup array.
if (!isset(self::$lookup[$language]))
{
self::$lookup[$language] = array();
$component = JComponentHelper::getComponent('com_newsfeeds');
$attributes = array('component_id');
$values = array($component->id);
if ($language != '*')
{
$attributes[] = 'language';
$values[] = array($needles['language'], '*');
}
$items = $menus->getItems($attributes, $values);
foreach ($items as $item)
{
if (isset($item->query) && isset($item->query['view']))
{
$view = $item->query['view'];
if (!isset(self::$lookup[$language][$view]))
{
self::$lookup[$language][$view] = array();
}
if (isset($item->query['id']))
{
// here it will become a bit tricky
// language != * can override existing entries
// language == * cannot override existing entries
if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*')
{
self::$lookup[$language][$view][$item->query['id']] = $item->id;
}
}
}
}
}
if ($needles)
{
foreach ($needles as $view => $ids)
{
if (isset(self::$lookup[$language][$view]))
{
foreach ($ids as $id)
{
if (isset(self::$lookup[$language][$view][(int) $id]))
{
return self::$lookup[$language][$view][(int) $id];
}
}
}
}
}
$active = $menus->getActive();
if ($active && ($active->language == '*' || !JLanguageMultilang::isEnabled()))
{
return $active->id;
}
// if not found, return language specific home link
$default = $menus->getDefault($language);
return !empty($default->id) ? $default->id : null;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
</metadata>

View File

@ -0,0 +1,124 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* This models supports retrieving lists of newsfeed categories.
*
* @package Joomla.Site
* @subpackage com_newsfeeds
* @since 1.6
*/
class NewsfeedsModelCategories extends JModelList
{
/**
* 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';
private $_parent = null;
private $_items = null;
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$this->setState('filter.extension', $this->_extension);
// Get the parent id if defined.
$parentId = $app->input->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 an add some properties to make the styling more easy
*
* @return mixed An array of data items on success, false on failure.
*/
public function getItems()
{
if (!count($this->_items))
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$params = new JRegistry;
if ($active)
{
$params->loadString($active->params);
}
$options = array();
$options['countItems'] = $params->get('show_cat_items_cat', 1) || !$params->get('show_empty_categories_cat', 0);
$categories = JCategories::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;
}
public function getParent()
{
if (!is_object($this->_parent))
{
$this->getItems();
}
return $this->_parent;
}
}

View File

@ -0,0 +1,325 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Newsfeeds Component Category Model
*
* @package Joomla.Site
* @subpackage com_newsfeeds
* @since 1.5
*/
class NewsfeedsModelCategory extends JModelList
{
/**
* Category items data
*
* @var array
*/
protected $_item = null;
protected $_articles = null;
protected $_siblings = null;
protected $_children = null;
protected $_parent = null;
/**
* The category that applies.
*
* @access protected
* @var object
*/
protected $_category = null;
/**
* The list of other newfeed categories.
*
* @access protected
* @var array
*/
protected $_categories = null;
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'name', 'a.name',
'numarticles', 'a.numarticles',
'link', 'a.link',
'ordering', 'a.ordering',
);
}
parent::__construct($config);
}
/**
* 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();
// Convert the params field into an object, saving original in _params
foreach ($items as $item)
{
if (!isset($this->_params))
{
$params = new JRegistry;
$item->params = $params;
$params->loadString($item->params);
}
// Get the tags
$item->tags = new JHelperTags;
$item->tags->getItemTags('com_newsfeeds.newsfeed', $item->id);
}
return $items;
}
/**
* Method to build an SQL query to load the list data.
*
* @return string An SQL query
* @since 1.6
*/
protected function getListQuery()
{
$user = JFactory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select required fields from the categories.
$query->select($this->getState('list.select', 'a.*'))
->from($db->quoteName('#__newsfeeds') . ' AS a')
->where('a.access IN (' . $groups . ')');
// Filter by category.
if ($categoryId = $this->getState('category.id'))
{
$query->where('a.catid = ' . (int) $categoryId)
->join('LEFT', '#__categories AS c ON c.id = a.catid')
->where('c.access IN (' . $groups . ')');
}
// Filter by state
$state = $this->getState('filter.published');
if (is_numeric($state))
{
$query->where('a.published = ' . (int) $state);
}
// Filter by start and end dates.
$nullDate = $db->quote($db->getNullDate());
$date = JFactory::getDate();
$nowDate = $db->quote($date->format($db->getDateFormat()));
if ($this->getState('filter.publish_date'))
{
$query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
}
// Filter by search in title
$search = $this->getState('list.filter');
if (!empty($search))
{
$search = $db->quote('%' . $db->escape($search, true) . '%');
$query->where('(a.name LIKE ' . $search . ')');
}
// Filter by language
if ($this->getState('filter.language'))
{
$query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
// 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.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
$app = JFactory::getApplication();
$params = JComponentHelper::getParams('com_newsfeeds');
// List state information
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'uint');
$this->setState('list.limit', $limit);
$limitstart = $app->input->get('limitstart', 0, 'uint');
$this->setState('list.start', $limitstart);
// Optional filter text
$this->setState('list.filter', $app->input->getString('filter-search'));
$orderCol = $app->input->get('filter_order', 'ordering');
if (!in_array($orderCol, $this->filter_fields))
{
$orderCol = 'ordering';
}
$this->setState('list.ordering', $orderCol);
$listOrder = $app->input->get('filter_order_Dir', 'ASC');
if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', '')))
{
$listOrder = 'ASC';
}
$this->setState('list.direction', $listOrder);
$id = $app->input->get('id', 0, 'int');
$this->setState('category.id', $id);
$user = JFactory::getUser();
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', JLanguageMultilang::isEnabled());
// Load the parameters.
$this->setState('params', $params);
}
/**
* Method to get category data for the current category
*
* @param integer An optional ID
*
* @return object
* @since 1.5
*/
public function getCategory()
{
if (!is_object($this->_item))
{
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$params = new JRegistry;
if ($active)
{
$params->loadString($active->params);
}
$options = array();
$options['countItems'] = $params->get('show_cat_items', 1) || $params->get('show_empty_categories', 0);
$categories = JCategories::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.
*
* @param integer An optional category id. If not supplied, the model state 'category.id' will be used.
*
* @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.
*/
function &getLeftSibling()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_leftsibling;
}
function &getRightSibling()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_rightsibling;
}
/**
* Get the child categories.
*
* @param integer An optional category id. If not supplied, the model state 'category.id' will be used.
*
* @return mixed An array of categories or false if an error occurs.
*/
function &getChildren()
{
if (!is_object($this->_item))
{
$this->getCategory();
}
return $this->_children;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,202 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Newsfeeds Component Newsfeed Model
*
* @package Joomla.Site
* @subpackage com_newsfeeds
* @since 1.5
*/
class NewsfeedsModelNewsfeed extends JModelItem
{
/**
* 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 = JFactory::getApplication('site');
// Load state from the request.
$pk = $app->input->getInt('id');
$this->setState('newsfeed.id', $pk);
$offset = $app->input->get('limitstart', 0, 'uint');
$this->setState('list.offset', $offset);
// Load the parameters.
$params = $app->getParams();
$this->setState('params', $params);
$user = JFactory::getUser();
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 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 = (!empty($pk)) ? $pk : (int) $this->getState('newsfeed.id');
if ($this->_item === null)
{
$this->_item = array();
}
if (!isset($this->_item[$pk]))
{
try
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select($this->getState('item.select', 'a.*'))
->from('#__newsfeeds AS a');
// Join on category table.
$query->select('c.title AS category_title, c.alias AS category_alias, c.access AS category_access')
->join('LEFT', '#__categories AS c on c.id = a.catid');
// Join on user table.
$query->select('u.name AS author')
->join('LEFT', '#__users AS u on u.id = a.created_by');
// Join over the categories to get parent category titles
$query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias')
->join('LEFT', '#__categories as parent ON parent.id = c.parent_id')
->where('a.id = ' . (int) $pk);
// Filter by start and end dates.
$nullDate = $db->quote($db->getNullDate());
$nowDate = $db->quote(JFactory::getDate()->toSql());
// Filter by published state.
$published = $this->getState('filter.published');
$archived = $this->getState('filter.archived');
if (is_numeric($published))
{
$query->where('(a.published = ' . (int) $published . ' OR a.published =' . (int) $archived . ')')
->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')')
->where('(c.published = ' . (int) $published . ' OR c.published =' . (int) $archived . ')');
}
$db->setQuery($query);
$data = $db->loadObject();
if (empty($data))
{
JError::raiseError(404, JText::_('COM_NEWSFEEDS_ERROR_FEED_NOT_FOUND'));
}
// Check for published state if filter set.
if (((is_numeric($published)) || (is_numeric($archived))) && (($data->published != $published) && ($data->published != $archived)))
{
JError::raiseError(404, JText::_('COM_NEWSFEEDS_ERROR_FEED_NOT_FOUND'));
}
// Convert parameter fields to objects.
$registry = new JRegistry;
$registry->loadString($data->params);
$data->params = clone $this->getState('params');
$data->params->merge($registry);
$registry = new JRegistry;
$registry->loadString($data->metadata);
$data->metadata = $registry;
// 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 = JFactory::getUser();
$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 = JFactory::getApplication()->input;
$hitcount = $input->getInt('hitcount', 1);
if ($hitcount)
{
$pk = (!empty($pk)) ? $pk : (int) $this->getState('newsfeed.id');
$db = $this->getDbo();
$db->setQuery(
'UPDATE #__newsfeeds' .
' SET hits = hits + 1' .
' WHERE id = '.(int) $pk
);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
return true;
}
}

View File

@ -0,0 +1,17 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
require_once JPATH_COMPONENT.'/helpers/route.php';
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables');
$controller = JControllerLegacy::getInstance('Newsfeeds');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();

View File

@ -0,0 +1,205 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Build the route for the com_newsfeeds component
*
* @return array An array of URL arguments
*
* @return array The URL arguments to use to assemble the subsequent URL.
*/
function NewsfeedsBuildRoute(&$query)
{
$segments = array();
// get a menu item based on Itemid or currently active
$app = JFactory::getApplication();
$menu = $app->getMenu();
$params = JComponentHelper::getParams('com_newsfeeds');
$advanced = $params->get('sef_advanced_link', 0);
if (empty($query['Itemid']))
{
$menuItem = $menu->getActive();
}
else
{
$menuItem = $menu->getItem($query['Itemid']);
}
$mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view'];
$mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id'];
if (isset($query['view']))
{
$view = $query['view'];
if (empty($query['Itemid']) || empty($menuItem) || $menuItem->component != 'com_newsfeeds')
{
$segments[] = $query['view'];
}
unset($query['view']);
}
// are we dealing with an newsfeed that is attached to a menu item?
if (isset($query['view']) && ($mView == $query['view']) and (isset($query['id'])) and ($mId == (int) $query['id']))
{
unset($query['view']);
unset($query['catid']);
unset($query['id']);
return $segments;
}
if (isset($view) and ($view == 'category' or $view == 'newsfeed'))
{
if ($mId != (int) $query['id'] || $mView != $view)
{
if ($view == 'newsfeed' && isset($query['catid']))
{
$catid = $query['catid'];
}
elseif (isset($query['id']))
{
$catid = $query['id'];
}
$menuCatid = $mId;
$categories = JCategories::getInstance('Newsfeeds');
$category = $categories->get($catid);
if ($category)
{
$path = $category->getPath();
$path = array_reverse($path);
$array = array();
foreach ($path as $id)
{
if ((int) $id == (int) $menuCatid)
{
break;
}
if ($advanced)
{
list($tmp, $id) = explode(':', $id, 2);
}
$array[] = $id;
}
$segments = array_merge($segments, array_reverse($array));
}
if ($view == 'newsfeed')
{
if ($advanced)
{
list($tmp, $id) = explode(':', $query['id'], 2);
}
else
{
$id = $query['id'];
}
$segments[] = $id;
}
}
unset($query['id']);
unset($query['catid']);
}
if (isset($query['layout']))
{
if (!empty($query['Itemid']) && isset($menuItem->query['layout']))
{
if ($query['layout'] == $menuItem->query['layout'])
{
unset($query['layout']);
}
}
else
{
if ($query['layout'] == 'default')
{
unset($query['layout']);
}
}
}
return $segments;
}
/**
* Parse the segments of a URL.
*
* @return array The segments of the URL to parse.
*
* @return array The URL attributes to be used by the application.
*/
function NewsfeedsParseRoute($segments)
{
$vars = array();
//Get the active menu item.
$app = JFactory::getApplication();
$menu = $app->getMenu();
$item = $menu->getActive();
$params = JComponentHelper::getParams('com_newsfeeds');
$advanced = $params->get('sef_advanced_link', 0);
// Count route segments
$count = count($segments);
// Standard routing for newsfeeds.
if (!isset($item))
{
$vars['view'] = $segments[0];
$vars['id'] = $segments[$count - 1];
return $vars;
}
// From the categories view, we can only jump to a category.
$id = (isset($item->query['id']) && $item->query['id'] > 1) ? $item->query['id'] : 'root';
$categories = JCategories::getInstance('Newsfeeds')->get($id)->getChildren();
$vars['catid'] = $id;
$vars['id'] = $id;
$found = 0;
foreach ($segments as $segment)
{
$segment = $advanced ? str_replace(':', '-', $segment) : $segment;
foreach ($categories as $category)
{
if ($category->slug == $segment || $category->alias == $segment)
{
$vars['id'] = $category->id;
$vars['catid'] = $category->id;
$vars['view'] = 'category';
$categories = $category->getChildren();
$found = 1;
break;
}
}
if ($found == 0)
{
if ($advanced)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from('#__newsfeeds')
->where($db->quoteName('catid') . ' = ' . (int) $vars['catid'])
->where($db->quoteName('alias') . ' = ' . $db->quote($db->quote($segment)));
$db->setQuery($query);
$nid = $db->loadResult();
}
else
{
$nid = $segment;
}
$vars['id'] = $nid;
$vars['view'] = 'newsfeed';
}
$found = 0;
}
return $vars;
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,17 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
JHtml::_('behavior.caption');
echo JLayoutHelper::render('joomla.content.categories_default', $this);
echo $this->loadTemplate('items');
?>
</div>

View File

@ -0,0 +1,289 @@
<?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 = "JHELP_MENUS_MENU_ITEM_NEWSFEED_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"
description="JGLOBAL_FIELD_CATEGORIES_CHOOSE_CATEGORY_DESC"
extension="com_newsfeeds"
label="JGLOBAL_FIELD_CATEGORIES_CHOOSE_CATEGORY_LABEL"
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"
description="JGLOBAL_FIELD_SHOW_BASE_DESCRIPTION_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="categories_description" type="textarea"
description="JGLOBAL_FIELD_CATEGORIES_DESC_DESC"
label="JGLOBAL_FIELD_CATEGORIES_DESC_LABEL"
cols="25"
rows="5"
/>
<field name="maxLevelcat" type="list"
description="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC"
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<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"
description="COM_NEWSFEEDS_SHOW_EMPTY_CATEGORIES_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<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"
description="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<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"
description="COM_NEWSFEEDS_FIELD_SHOW_CAT_ITEMS_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="category" label="JGLOBAL_CATEGORY_OPTIONS">
<field name="spacer2" type="spacer" class="text"
label="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
/>
<field name="show_category_title" type="list"
label="JGLOBAL_SHOW_CATEGORY_TITLE"
description="JGLOBAL_SHOW_CATEGORY_TITLE_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_description" type="list"
description="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_DESC"
label="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_description_image" type="list"
description="JGLOBAL_SHOW_CATEGORY_IMAGE_DESC"
label="JGLOBAL_SHOW_CATEGORY_IMAGE_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="maxLevel" type="list"
description="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC"
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<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"
description="COM_NEWSFEEDS_SHOW_EMPTY_CATEGORIES_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_subcat_desc" type="list"
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
description="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field id="show_cat_items"
name="show_cat_items"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_CAT_ITEMS_LABEL"
description="COM_NEWSFEEDS_FIELD_SHOW_CAT_ITEMS_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="advanced" label="JGLOBAL_LIST_LAYOUT_OPTIONS">
<field name="spacer1" type="spacer" class="text"
label="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
/>
<field
name="filter_field"
type="list"
default=""
description="JGLOBAL_FILTER_FIELD_DESC"
label="JGLOBAL_FILTER_FIELD_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="hide">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_pagination_limit"
type="list"
label="JGLOBAL_DISPLAY_SELECT_LABEL"
description="JGLOBAL_DISPLAY_SELECT_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
id="show_headings"
name="show_headings"
type="list"
label="JGLOBAL_SHOW_HEADINGS_LABEL"
description="JGLOBAL_SHOW_HEADINGS_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
id="show_articles"
name="show_articles"
type="list"
label="COM_NEWSFEEDS_FIELD_NUM_ARTICLES_COLUMN_LABEL"
description="COM_NEWSFEEDS_FIELD_NUM_ARTICLES_COLUMN_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
id="show_link"
name="show_link"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_LINKS_LABEL"
description="COM_NEWSFEEDS_FIELD_SHOW_LINKS_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_pagination"
type="list"
label="JGLOBAL_PAGINATION_LABEL"
description="JGLOBAL_PAGINATION_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<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"
description="JGLOBAL_PAGINATION_RESULTS_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<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"
description="COM_NEWSFEEDS_FIELD_SHOW_FEED_IMAGE_DESC"
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_IMAGE_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_feed_description" type="list"
description="COM_NEWSFEEDS_FIELD_SHOW_FEED_DESCRIPTION_DESC"
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_item_description" type="list"
description="COM_NEWSFEEDS_FIELD_SHOW_ITEM_DESCRIPTION_DESC"
label="COM_NEWSFEEDS_FIELD_SHOW_ITEM_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="feed_character_count" type="text"
default="0"
description="COM_NEWSFEEDS_FIELD_CHARACTER_COUNT_DESC"
label="COM_NEWSFEEDS_FIELD_CHARACTER_COUNT_LABEL"
size="6"
/>
</fieldset>
</fields>
</metadata>

View File

@ -0,0 +1,62 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('bootstrap.tooltip');
$class = ' class="first"';
if (count($this->items[$this->parent->id]) > 0 && $this->maxLevelcat != 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())) :
if (!isset($this->items[$this->parent->id][$id + 1]))
{
$class = ' class="last"';
}
?>
<div <?php echo $class; ?> >
<?php $class = ''; ?>
<h3 class="page-header item-title">
<a href="<?php echo JRoute::_(NewsfeedsHelperRoute::getCategoryRoute($item->id));?>">
<?php echo $this->escape($item->title); ?></a>
<?php if ($this->params->get('show_cat_items_cat') == 1) :?>
<span class="badge badge-info tip hasTooltip" title="<?php echo JHtml::tooltipText('COM_NEWSFEEDS_NUM_ITEMS'); ?>">
<?php echo $item->numitems; ?>
</span>
<?php endif; ?>
<?php if (count($item->getChildren()) > 0) : ?>
<a href="#category-<?php echo $item->id;?>" data-toggle="collapse" data-toggle="button" class="btn btn-mini pull-right"><span class="icon-plus"></span></a>
<?php endif;?>
</h3>
<?php if ($this->params->get('show_subcat_desc_cat') == 1) :?>
<?php if ($item->description) : ?>
<div class="category-desc">
<?php echo JHtml::_('content.prepare', $item->description, '', 'com_newsfeeds.categories'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if (count($item->getChildren()) > 0) :?>
<div class="collapse fade" id="category-<?php echo $item->id;?>">
<?php
$this->items[$item->id] = $item->getChildren();
$this->parent = $item;
$this->maxLevelcat--;
echo $this->loadTemplate('items');
$this->parent = $item->getParent();
$this->maxLevelcat++;
?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,122 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Content categories view.
*
* @package Joomla.Site
* @subpackage com_newsfeeds
* @since 1.5
*/
class NewsfeedsViewCategories extends JViewLegacy
{
protected $state = null;
protected $item = null;
protected $items = null;
/**
* Display the view
*
* @return mixed False on error, null otherwise.
*/
public function display($tpl = null)
{
$state = $this->get('State');
$items = $this->get('Items');
$parent = $this->get('Parent');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
if ($items === false)
{
return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
}
if ($parent == false)
{
return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
}
$params = &$state->params;
$items = array($parent->id => $items);
//Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
$this->maxLevelcat = $params->get('maxLevelcat', -1);
$this->params = &$params;
$this->parent = &$parent;
$this->items = &$items;
$this->_prepareDocument();
parent::display($tpl);
}
/**
* Prepares the document
*/
protected function _prepareDocument()
{
$app = JFactory::getApplication();
$menus = $app->getMenu();
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if ($menu)
{
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
}
else
{
$this->params->def('page_heading', JText::_('COM_NEWSFEEDS_DEFAULT_PAGE_TITLE'));
}
$title = $this->params->get('page_title', '');
if (empty($title))
{
$title = $app->getCfg('sitename');
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 1)
{
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 2)
{
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
}
$this->document->setTitle($title);
if ($this->params->get('menu-meta_description'))
{
$this->document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->params->get('menu-meta_keywords'))
{
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots'))
{
$this->document->setMetadata('robots', $this->params->get('robots'));
}
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<view title="COM_NEWSFEEDS_CATEGORY_GROUP_LABEL">
<message>
<![CDATA[COM_NEWSFEEDS_CATEGORY_GROUP_DESC]]>
</message>
</view>
</metadata>

View File

@ -0,0 +1,54 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');
JHtml::_('behavior.caption');
$pageClass = $this->params->get('pageclass_sfx');
?>
<div class="newsfeed-category<?php echo $this->pageclass_sfx;?>">
<?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)) : ?>
<h2>
<?php echo JHtml::_('content.prepare', $this->category->title, '', 'com_newsfeeds.category'); ?>
</h2>
<?php endif; ?>
<?php if ($this->params->get('show_tags', 1) && !empty($this->category->tags->itemTags)) : ?>
<?php $this->category->tagLayout = new JLayoutFile('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="category-desc">
<?php if ($this->params->get('show_description_image') && $this->category->getParams()->get('image')) : ?>
<img src="<?php echo $this->category->getParams()->get('image'); ?>"/>
<?php endif; ?>
<?php if ($this->params->get('show_description') && $this->category->description) : ?>
<?php echo JHtml::_('content.prepare', $this->category->description, '', 'com_newsfeeds.category'); ?>
<?php endif; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php echo $this->loadTemplate('items'); ?>
<?php if (!empty($this->children[$this->category->id])&& $this->maxLevel != 0) : ?>
<div class="cat-children">
<h3><?php echo JText::_('JGLOBAL_SUBCATEGORIES'); ?></h3>
<?php echo $this->loadTemplate('children'); ?>
</div>
<?php endif; ?>
</div>

View File

@ -0,0 +1,241 @@
<?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 = "JHELP_MENUS_MENU_ITEM_NEWSFEED_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"
addfieldpath="/administrator/components/com_newsfeeds/models/fields"
>
<field name="id" type="category"
default="0"
description="COM_NEWSFEEDS_FIELD_SELECT_CATEGORY_DESC"
extension="com_newsfeeds"
label="JCATEGORY"
required="true"
/>
</fieldset>
</fields>
<!-- Add fields to the parameters object for the layout. -->
<fields name="params">
<fieldset name="basic" label="JGLOBAL_CATEGORY_OPTIONS">
<field name="spacer1" type="spacer" class="text"
label="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
/>
<field name="show_category_title" type="list"
label="JGLOBAL_SHOW_CATEGORY_TITLE"
description="JGLOBAL_SHOW_CATEGORY_TITLE_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_description" type="list"
description="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_DESC"
label="JGLOBAL_SHOW_CATEGORY_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_description_image" type="list"
description="JGLOBAL_SHOW_CATEGORY_IMAGE_DESC"
label="JGLOBAL_SHOW_CATEGORY_IMAGE_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="maxLevel" type="list"
description="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_DESC"
label="JGLOBAL_MAXIMUM_CATEGORY_LEVELS_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<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"
description="COM_NEWSFEEDS_SHOW_EMPTY_CATEGORIES_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_subcat_desc" type="list"
label="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_LABEL"
description="JGLOBAL_SHOW_SUBCATEGORIES_DESCRIPTION_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field id="show_cat_items"
name="show_cat_items"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_CAT_ITEMS_LABEL"
description="COM_NEWSFEEDS_FIELD_SHOW_CAT_ITEMS_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
</fieldset>
<fieldset name="advanced" label="JGLOBAL_LIST_LAYOUT_OPTIONS">
<field name="spacer2" type="spacer" class="text"
label="JGLOBAL_SUBSLIDER_DRILL_CATEGORIES_LABEL"
/>
<field
name="filter_field"
type="list"
default=""
description="JGLOBAL_FILTER_FIELD_DESC"
label="JGLOBAL_FILTER_FIELD_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="hide">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_pagination_limit"
type="list"
label="JGLOBAL_DISPLAY_SELECT_LABEL"
description="JGLOBAL_DISPLAY_SELECT_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
id="show_headings"
name="show_headings"
type="list"
label="JGLOBAL_SHOW_HEADINGS_LABEL"
description="JGLOBAL_SHOW_HEADINGS_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
id="show_articles"
name="show_articles"
type="list"
label="COM_NEWSFEEDS_FIELD_NUM_ARTICLES_COLUMN_LABEL"
description="COM_NEWSFEEDS_FIELD_NUM_ARTICLES_COLUMN_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field
id="show_link"
name="show_link"
type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_LINKS_LABEL"
description="COM_NEWSFEEDS_FIELD_SHOW_LINKS_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_pagination"
type="list"
label="JGLOBAL_PAGINATION_LABEL"
description="JGLOBAL_PAGINATION_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<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"
description="JGLOBAL_PAGINATION_RESULTS_DESC">
<option value="">JGLOBAL_USE_GLOBAL</option>
<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"
description="COM_NEWSFEEDS_FIELD_SHOW_FEED_IMAGE_DESC"
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_IMAGE_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_feed_description" type="list"
description="COM_NEWSFEEDS_FIELD_SHOW_FEED_DESCRIPTION_DESC"
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_item_description" type="list"
description="COM_NEWSFEEDS_FIELD_SHOW_ITEM_DESCRIPTION_DESC"
label="COM_NEWSFEEDS_FIELD_SHOW_ITEM_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="feed_character_count" type="text"
default="0"
description="COM_NEWSFEEDS_FIELD_CHARACTER_COUNT_DESC"
label="COM_NEWSFEEDS_FIELD_CHARACTER_COUNT_LABEL"
size="6"
/>
<field name="feed_display_order" type="list"
description="COM_NEWSFEEDS_FIELD_FEED_DISPLAY_ORDER_DESC"
label="COM_NEWSFEEDS_FIELD_FEED_DISPLAY_ORDER_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="des">JGLOBAL_MOST_RECENT_FIRST</option>
<option value="asc">JGLOBAL_OLDEST_FIRST</option>
</field>
</fieldset>
</fields>
</metadata>

View File

@ -0,0 +1,57 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$class = ' class="first"';
if (count($this->children[$this->category->id]) > 0 && $this->maxLevel != 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())) :
if (!isset($this->children[$this->category->id][$id + 1]))
{
$class = ' class="last"';
}
?>
<li<?php echo $class; ?>>
<?php $class = ''; ?>
<span class="item-title"><a href="<?php echo JRoute::_(NewsfeedsHelperRoute::getCategoryRoute($child->id));?>">
<?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 JHtml::_('content.prepare', $child->description, '', 'com_newsfeeds.category'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if ($this->params->get('show_cat_items') == 1) :?>
<dl class="newsfeed-count"><dt>
<?php echo JText::_('COM_NEWSFEEDS_CAT_NUM'); ?></dt>
<dd><?php echo $child->numitems; ?></dd>
</dl>
<?php endif; ?>
<?php if (count($child->getChildren()) > 0) :
$this->children[$child->id] = $child->getChildren();
$this->category = $child;
$this->maxLevel--;
echo $this->loadTemplate('children');
$this->category = $child->getParent();
$this->maxLevel++;
endif; ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif;

View File

@ -0,0 +1,90 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.framework');
$n = count($this->items);
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
?>
<?php if (empty($this->items)) : ?>
<p> <?php echo JText::_('COM_NEWSFEEDS_NO_ARTICLES'); ?></p>
<?php else : ?>
<form action="<?php echo htmlspecialchars(JUri::getInstance()->toString()); ?>" method="post" name="adminForm" id="adminForm">
<?php if ($this->params->get('filter_field') != 'hide' || $this->params->get('show_pagination_limit')) :?>
<fieldset class="filters btn-toolbar">
<?php if ($this->params->get('filter_field') != 'hide') :?>
<div class="btn-group">
<label class="filter-search-lbl element-invisible" for="filter-search"><span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span><?php echo JText::_('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();" title="<?php echo JText::_('COM_NEWSFEEDS_FILTER_SEARCH_DESC'); ?>" placeholder="<?php echo JText::_('COM_NEWSFEEDS_FILTER_SEARCH_DESC'); ?>" />
</div>
<?php endif; ?>
<?php if ($this->params->get('show_pagination_limit')) : ?>
<div class="btn-group pull-right">
<label for="limit" class="element-invisible">
<?php echo JText::_('JGLOBAL_DISPLAY_NUM'); ?>
</label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<?php endif; ?>
</fieldset>
<?php endif; ?>
<ul class="category list-striped list-condensed">
<?php foreach ($this->items as $i => $item) : ?>
<?php if ($this->items[$i]->published == 0) : ?>
<li class="system-unpublished cat-list-row<?php echo $i % 2; ?>">
<?php else: ?>
<li class="cat-list-row<?php echo $i % 2; ?>" >
<?php endif; ?>
<?php if ($this->params->get('show_articles')) : ?>
<span class="list-hits badge badge-info pull-right">
<?php echo JText::sprintf('COM_NEWSFEEDS_NUM_ARTICLES_COUNT', $item->numarticles); ?>
</span>
<?php endif; ?>
<span class="list pull-left">
<div class="list-title">
<a href="<?php echo JRoute::_(NewsFeedsHelperRoute::getNewsfeedRoute($item->slug, $item->catid)); ?>">
<?php echo $item->name; ?></a>
</div>
</span>
<?php if ($this->items[$i]->published == 0) : ?>
<span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span>
<?php endif; ?>
<br />
<?php if ($this->params->get('show_link')) : ?>
<?php $link = JStringPunycode::urlToUTF8($item->link); ?>
<span class="list pull-left">
<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="pagination">
<?php if ($this->params->def('show_pagination_results', 1)) : ?>
<p class="counter pull-right">
<?php echo $this->pagination->getPagesCounter(); ?>
</p>
<?php endif; ?>
<?php echo $this->pagination->getPagesLinks(); ?>
</div>
<?php endif; ?>
<?php endif; ?>
</form>
<?php endif; ?>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,225 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* HTML View class for the Newsfeeds component
*
* @package Joomla.Site
* @subpackage com_newsfeeds
* @since 1.0
*/
class NewsfeedsViewCategory extends JViewLegacy
{
protected $state;
protected $items;
protected $category;
protected $categories;
protected $pagination;
public function display($tpl = null)
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$params = $app->getParams();
// Get some data from the models
$state = $this->get('State');
$items = $this->get('Items');
$category = $this->get('Category');
$children = $this->get('Children');
$parent = $this->get('Parent');
$pagination = $this->get('Pagination');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
if ($category == false)
{
return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
}
if ($parent == false)
{
return JError::raiseError(404, JText::_('JGLOBAL_CATEGORY_NOT_FOUND'));
}
// Check whether category access level allows access.
$groups = $user->getAuthorisedViewLevels();
if (!in_array($category->access, $groups))
{
return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
}
// Prepare the data.
// Compute the newsfeed slug.
for ($i = 0, $n = count($items); $i < $n; $i++)
{
$item = &$items[$i];
$item->slug = $item->alias ? ($item->id.':'.$item->alias) : $item->id;
$temp = new JRegistry;
$temp->loadString($item->params);
$item->params = clone($params);
$item->params->merge($temp);
}
// Setup the category parameters.
$cparams = $category->getParams();
$category->params = clone($params);
$category->params->merge($cparams);
$children = array($category->id => $children);
//Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
$maxLevel = $params->get('maxLevel', -1);
$this->maxLevel = &$maxLevel;
$this->state = &$state;
$this->items = &$items;
$this->category = &$category;
$this->children = &$children;
$this->params = &$params;
$this->parent = &$parent;
$this->pagination = &$pagination;
$this->user = &$user;
// Check for layout override only if this is not the active menu item
// If it is the active menu item, then the view and category id will match
$active = $app->getMenu()->getActive();
if ((!$active) || ((strpos($active->link, 'view=category') === false) || (strpos($active->link, '&id=' . (string) $this->category->id) === false)))
{
if ($layout = $category->params->get('category_layout'))
{
$this->setLayout($layout);
}
}
elseif (isset($active->query['layout']))
{
// We need to set the layout in case this is an alternative menu item (with an alternative layout)
$this->setLayout($active->query['layout']);
}
$this->category->tags = new JHelperTags;
$this->category->tags->getItemTags('com_newsfeeds.category', $this->category->id);
$this->_prepareDocument();
parent::display($tpl);
}
/**
* Prepares the document
*/
protected function _prepareDocument()
{
$app = JFactory::getApplication();
$menus = $app->getMenu();
$pathway = $app->getPathway();
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if ($menu)
{
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
}
else
{
$this->params->def('page_heading', JText::_('COM_NEWSFEEDS_DEFAULT_PAGE_TITLE'));
}
$id = (int) @$menu->query['id'];
if ($menu && ($menu->query['option'] != 'com_newsfeeds' || $menu->query['view'] == 'newsfeed' || $id != $this->category->id))
{
$path = array(array('title' => $this->category->title, 'link' => ''));
$category = $this->category->getParent();
while (($menu->query['option'] != 'com_newsfeeds' || $menu->query['view'] == 'newsfeed' || $id != $category->id) && $category->id > 1)
{
$path[] = array('title' => $category->title, 'link' => NewsfeedsHelperRoute::getCategoryRoute($category->id));
$category = $category->getParent();
}
$path = array_reverse($path);
foreach ($path as $item)
{
$pathway->addItem($item['title'], $item['link']);
}
}
$title = $this->params->get('page_title', '');
if (empty($title))
{
$title = $app->getCfg('sitename');
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 1)
{
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 2)
{
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
}
$this->document->setTitle($title);
if ($this->category->metadesc)
{
$this->document->setDescription($this->category->metadesc);
}
elseif (!$this->category->metadesc && $this->params->get('menu-meta_description'))
{
$this->document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->category->metakey)
{
$this->document->setMetadata('keywords', $this->category->metakey);
}
elseif (!$this->category->metakey && $this->params->get('menu-meta_keywords'))
{
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots'))
{
$this->document->setMetadata('robots', $this->params->get('robots'));
}
if ($app->getCfg('MetaAuthor') == '1')
{
$this->document->setMetaData('author', $this->category->getMetadata()->get('author'));
}
$mdata = $this->category->getMetadata()->toArray();
foreach ($mdata as $k => $v)
{
if ($v)
{
$this->document->setMetadata($k, $v);
}
}
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<view title="NEWSFEEDS_NEWSFEED_INDIVIDUAL_FEED_LABEL">
<message>
<![CDATA[NEWSFEEDS_NEWSFEED_INDIVIDUAL_FEED_DESC]]>
</message>
</view>
</metadata>

View File

@ -0,0 +1,137 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<?php
if (!empty($this->msg))
{
echo $this->msg;
}
else
{
$lang = JFactory::getLanguage();
$myrtl = $this->newsfeed->rtl;
$direction = " ";
if ($lang->isRTL() && $myrtl == 0)
{
$direction = " redirect-rtl";
}
elseif ($lang->isRTL() && $myrtl == 1)
{
$direction = " redirect-ltr";
}
elseif ($lang->isRTL() && $myrtl == 2)
{
$direction = " redirect-rtl";
}
elseif ($myrtl == 0)
{
$direction = " redirect-ltr";
}
elseif ($myrtl == 1)
{
$direction = " redirect-ltr";
}
elseif ($myrtl == 2)
{
$direction = " redirect-rtl";
}
$images = json_decode($this->item->images);
?>
<div class="newsfeed<?php echo $this->pageclass_sfx?><?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="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span>
<?php endif; ?>
<a href="<?php echo $this->item->link; ?>" target="_blank">
<?php echo str_replace('&apos;', "'", $this->item->name); ?></a>
</h2>
<?php if ($this->params->get('show_tags', 1)) : ?>
<?php $this->item->tagLayout = new JLayoutFile('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) and !empty($images->image_first)) : ?>
<?php $imgfloat = (empty($images->float_first)) ? $this->params->get('float_first') : $images->float_first; ?>
<div class="img-intro-<?php echo htmlspecialchars($imgfloat); ?>"> <img
<?php if ($images->image_first_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_first_caption) .'"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_first); ?>" alt="<?php echo htmlspecialchars($images->image_first_alt); ?>"/> </div>
<?php endif; ?>
<?php if (isset($images->image_second) and !empty($images->image_second)) : ?>
<?php $imgfloat = (empty($images->float_second)) ? $this->params->get('float_second') : $images->float_second; ?>
<div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image"> <img
<?php if ($images->image_second_caption):
echo 'class="caption"'.' title="' .htmlspecialchars($images->image_second_caption) .'"';
endif; ?>
src="<?php echo htmlspecialchars($images->image_second); ?>" alt="<?php echo htmlspecialchars($images->image_second_alt); ?>"/> </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="feed-description">
<?php echo str_replace('&apos;', "'", $this->rssDoc->description); ?>
</div>
<?php endif; ?>
<!-- Show Image -->
<?php if (isset($this->rssDoc->image) && isset($this->rssDoc->imagetitle) && $this->params->get('show_feed_image')) : ?>
<div>
<img src="<?php echo $this->rssDoc->image; ?>" alt="<?php echo $this->rssDoc->image->decription; ?>" />
</div>
<?php endif; ?>
<!-- Show items -->
<?php if (!empty($this->rssDoc[0])) { ?>
<ol>
<?php for ($i = 0; $i < $this->item->numarticles; $i++) { ?>
<?php
$uri = !empty($this->rssDoc[$i]->guid) || !is_null($this->rssDoc[$i]->guid) ? $this->rssDoc[$i]->guid : $this->rssDoc[$i]->uri;
$uri = substr($uri, 0, 4) != 'http' ? $this->item->link : $uri;
$text = !empty($this->rssDoc[$i]->content) || !is_null($this->rssDoc[$i]->content) ? $this->rssDoc[$i]->content : $this->rssDoc[$i]->description;
?>
<li>
<?php if (!empty($this->rssDoc[$i]->uri)) : ?>
<a href="<?php echo $this->rssDoc[$i]->uri; ?>" target="_blank">
<?php echo $this->rssDoc[$i]->title; ?></a>
<?php else : ?>
<h3><?php echo '<a target="_blank" href="' .$this->rssDoc[$i]->uri . '">' .$this->rssDoc[$i]->title. '</a>'; ?></h3>
<?php endif; ?>
<?php if ($this->params->get('show_item_description') && !empty($text)) : ?>
<div class="feed-item-description">
<?php if ($this->params->get('show_feed_image', 0) == 0)
{
$text = JFilterOutput::stripImages($text);
}
$text = JHtml::_('string.truncate', $text, $this->params->get('feed_character_count'));
echo str_replace('&apos;', "'", $text);
?>
</div>
<?php endif; ?>
</li>
<?php } ?>
</ol>
<?php } ?>
</div>
<?php } ?>

View File

@ -0,0 +1,87 @@
<?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 = "JHELP_MENUS_MENU_ITEM_NEWSFEED_SINGLE_NEWSFEED"
/>
<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"
addfieldpath="/administrator/components/com_newsfeeds/models/fields"
>
<field name="id" type="modal_newsfeed"
description="COM_NEWSFEEDS_FIELD_SELECT_FEED_DESC"
label="COM_NEWSFEEDS_FIELD_SELECT_FEED_LABEL"
required="true"
edit="true"
clear="false"
/>
</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"
description="COM_NEWSFEEDS_FIELD_SHOW_FEED_IMAGE_DESC"
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_IMAGE_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_feed_description" type="list"
description="COM_NEWSFEEDS_FIELD_SHOW_FEED_DESCRIPTION_DESC"
label="COM_NEWSFEEDS_FIELD_SHOW_FEED_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_item_description" type="list"
description="COM_NEWSFEEDS_FIELD_SHOW_ITEM_DESCRIPTION_DESC"
label="COM_NEWSFEEDS_FIELD_SHOW_ITEM_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_tags" type="list"
label="COM_NEWSFEEDS_FIELD_SHOW_TAGS_LABEL"
description="COM_NEWSFEEDS_FIELD_SHOW_TAGS_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="feed_character_count" type="text"
default="0"
description="COM_NEWSFEEDS_FIELD_CHARACTER_COUNT_DESC"
label="COM_NEWSFEEDS_FIELD_CHARACTER_COUNT_LABEL"
size="6"
/>
<field name="feed_display_order" type="list"
description="COM_NEWSFEEDS_FIELD_FEED_DISPLAY_ORDER_DESC"
label="COM_NEWSFEEDS_FIELD_FEED_DISPLAY_ORDER_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="des">JGLOBAL_MOST_RECENT_FIRST</option>
<option value="asc">JGLOBAL_OLDEST_FIRST</option>
</field>
</fieldset>
</fields>
</metadata>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,315 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* HTML View class for the Newsfeeds component
*
* @package Joomla.Site
* @subpackage com_newsfeeds
* @since 1.0
*/
class NewsfeedsViewNewsfeed extends JViewLegacy
{
/**
* @var object
* @since 1.6
*/
protected $state;
/**
* @var object
* @since 1.6
*/
protected $item;
/**
* @var boolean
* @since 1.6
*/
protected $print;
/**
* @since 1.6
*/
public function display($tpl = null)
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
// Get view related request variables.
$print = $app->input->getBool('print');
// Get model data.
$state = $this->get('State');
$item = $this->get('Item');
if ($item)
{
// Get Category Model data
$categoryModel = JModelLegacy::getInstance('Category', 'NewsfeedsModel', array('ignore_request' => true));
$categoryModel->setState('category.id', $item->catid);
$categoryModel->setState('list.ordering', 'a.name');
$categoryModel->setState('list.direction', 'asc');
// TODO: $items is not used. Remove this line?
$items = $categoryModel->getItems();
}
// Check for errors.
// @TODO Maybe this could go into JComponentHelper::raiseErrors($this->get('Errors'))
if (count($errors = $this->get('Errors')))
{
JError::raiseWarning(500, implode("\n", $errors));
return false;
}
// 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;
// check if cache directory is writeable
$cacheDir = JPATH_CACHE . '/';
if (!is_writable($cacheDir))
{
JError::raiseNotice('0', JText::_('COM_NEWSFEEDS_CACHE_DIRECTORY_UNWRITABLE'));
return;
}
// 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 an 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) or ((in_array($item->access, $levels) and (!in_array($item->category_access, $levels)))))
{
JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR'));
return;
}
// Get the current menu item
$params = $app->getParams();
// Get the newsfeed
$newsfeed = $item;
$temp = new JRegistry;
$temp->loadString($item->params);
$params->merge($temp);
try
{
$feed = new JFeedFactory;
$this->rssDoc = $feed->getFeed($newsfeed->link);
}
catch (InvalidArgumentException $e)
{
$msg = JText::_('COM_NEWSFEEDS_ERRORS_FEED_NOT_RETRIEVED');
}
catch (RunTimeException $e)
{
$msg = JText::_('COM_NEWSFEEDS_ERRORS_FEED_NOT_RETRIEVED');
}
if (empty($this->rssDoc))
{
$msg = JText::_('COM_NEWSFEEDS_ERRORS_FEED_NOT_RETRIEVED');
}
$feed_display_order = $params->get('feed_display_order', 'des');
if ($feed_display_order == 'asc')
{
$newsfeed->items = array_reverse($newsfeed->items);
}
//Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
$this->assignRef('params', $params);
$this->assignRef('newsfeed', $newsfeed);
$this->assignRef('state', $state);
$this->assignRef('item', $item);
$this->assignRef('user', $user);
if (!empty($msg))
{
$this->assignRef('msg', $msg);
}
$this->print = $print;
$item->tags = new JHelperTags;
$item->tags->getItemTags('com_newsfeeds.newsfeed', $item->id);
$this->_prepareDocument();
parent::display($tpl);
}
/**
* Prepares the document
*
* @return void
* @since 1.6
*/
protected function _prepareDocument()
{
$app = JFactory::getApplication();
$menus = $app->getMenu();
$pathway = $app->getPathway();
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if ($menu)
{
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
}
else
{
$this->params->def('page_heading', JText::_('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 && ($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 = array(array('title' => $this->item->name, 'link' => ''));
$category = JCategories::getInstance('Newsfeeds')->get($this->item->catid);
while (($menu->query['option'] != 'com_newsfeeds' || $menu->query['view'] == 'newsfeed' || $id != $category->id) && $category->id > 1)
{
$path[] = array('title' => $category->title, 'link' => NewsfeedsHelperRoute::getCategoryRoute($category->id));
$category = $category->getParent();
}
$path = array_reverse($path);
foreach ($path as $item)
{
$pathway->addItem($item['title'], $item['link']);
}
}
if (empty($title))
{
$title = $app->getCfg('sitename');
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 1)
{
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 2)
{
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
}
if (empty($title))
{
$title = $this->item->name;
}
$this->document->setTitle($title);
if ($this->item->metadesc)
{
$this->document->setDescription($this->item->metadesc);
}
elseif (!$this->item->metadesc && $this->params->get('menu-meta_description'))
{
$this->document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->item->metakey)
{
$this->document->setMetadata('keywords', $this->item->metakey);
}
elseif (!$this->item->metakey && $this->params->get('menu-meta_keywords'))
{
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots'))
{
$this->document->setMetadata('robots', $this->params->get('robots'));
}
if ($app->getCfg('MetaTitle') == '1')
{
$this->document->setMetaData('title', $this->item->name);
}
if ($app->getCfg('MetaAuthor') == '1')
{
$this->document->setMetaData('author', $this->item->author);
}
$mdata = $this->item->metadata->toArray();
foreach ($mdata as $k => $v)
{
if ($v)
{
$this->document->setMetadata($k, $v);
}
}
}
}