You've already forked joomla_test
first commit
This commit is contained in:
6
components/com_k2/views/itemlist/metadata.xml
Normal file
6
components/com_k2/views/itemlist/metadata.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
<view title="K2_ITEM_LISTINGS">
|
||||
<message>K2_CREATE_A_MENU_ITEM_LINKING_TO_A_GRID_PAGE_WITH_THE_LATEST_ITEMS_FROM_SPECIFIC_USERS_OR_CATEGORIES_IN_K2</message>
|
||||
</view>
|
||||
</metadata>
|
13
components/com_k2/views/itemlist/tmpl/category.php
Normal file
13
components/com_k2/views/itemlist/tmpl/category.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: category.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
|
||||
* @package K2
|
||||
* @author JoomlaWorks http://www.joomlaworks.net
|
||||
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
?>
|
242
components/com_k2/views/itemlist/tmpl/category.xml
Normal file
242
components/com_k2/views/itemlist/tmpl/category.xml
Normal file
@ -0,0 +1,242 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
<layout title="K2_CATEGORIES">
|
||||
<message>
|
||||
<![CDATA[K2_DISPLAYS_A_LIST_OF_ITEMS_FROM_ONE_OR_MORE_CATEGORIES]]>
|
||||
</message>
|
||||
</layout>
|
||||
<state>
|
||||
<name>K2_CATEGORIES</name>
|
||||
<description>K2_DISPLAYS_A_LIST_OF_ITEMS_FROM_ONE_OR_MORE_CATEGORIES</description>
|
||||
<params addpath="/administrator/components/com_k2/elements">
|
||||
<param name="" type="header" default="K2_SELECT_ONE_OR_MORE_CATEGORIES" label="" description=""/>
|
||||
<param name="categories" type="category" default="" label="K2_SELECT_CATEGORIES" description="K2_IF_YOU_SELECT_MULTIPLE_CATEGORIES_YOU_CAN_ADJUST_ADDITIONAL_PARAMETERS_BELOW_IF_YOU_SELECT_ONLY_ONE_CATEGORY_THEN_K2_WILL_FETCH_THE_OPTIONS_AS_DEFINED_IN_THAT_SPECIFIC_CATEGORYS_OPTIONS_IN_K2_CATEGORIES"/>
|
||||
<param name="catCatalogMode" type="list" default="0" label="K2_FETCH_ITEMS_FROM_CHILDREN_CATEGORIES" description="K2_IF_YOU_SELECT_NO_THEN_ONLY_THE_ITEMS_DIRECTLY_BELONGING_TO_THIS_CATEGORY_WILL_BE_RETRIEVED_IF_YOU_SELECT_YES_THEN_ITEMS_FROM_ALL_SUBCATEGORIES_WILL_BE_RETRIEVED_SETTING_THIS_OPTION_TO_YES_IS_IDEAL_FOR_NEWSPORTALMAGAZINEBLOG_LAYOUTS">
|
||||
<option value="1">K2_NO</option>
|
||||
<option value="0">K2_YES</option>
|
||||
</param>
|
||||
<param name="" type="header" default="K2_LAYOUT_OPTIONS_FOR_SINGLE_CATEGORY_SELECTION" label="" description=""/>
|
||||
<param name="singleCatOrdering" type="list" default="" label="K2_ITEM_ORDERING" description="">
|
||||
<option value="">K2_INHERIT_FROM_CATEGORY</option>
|
||||
<option value="date">K2_OLDEST_FIRST</option>
|
||||
<option value="rdate">K2_MOST_RECENT_FIRST</option>
|
||||
<option value="publishUp">K2_RECENTLY_PUBLISHED</option>
|
||||
<option value="alpha">K2_TITLE_ALPHABETICAL</option>
|
||||
<option value="ralpha">K2_TITLE_REVERSEALPHABETICAL</option>
|
||||
<option value="order">K2_ORDERING</option>
|
||||
<option value="rorder">K2_ORDERING_REVERSE</option>
|
||||
<option value="featured">K2_FEATURED_FIRST</option>
|
||||
<option value="hits">K2_MOST_POPULAR</option>
|
||||
<option value="best">K2_HIGHEST_RATED</option>
|
||||
<option value="modified">K2_LATEST_MODIFIED</option>
|
||||
<option value="rand">K2_RANDOM_ORDERING</option>
|
||||
</param>
|
||||
<param name="" type="header" default="K2_LAYOUT_OPTIONS_FOR_MULTIPLE_CATEGORY_SELECTION" label="" description=""/>
|
||||
<param name="theme" type="template" default="default" label="K2_SELECT_A_TEMPLATE"/>
|
||||
<param name="@spacer" type="spacer" default="" label="" description=""/>
|
||||
<param name="num_leading_items" type="text" size="4" default="2" label="K2_LEADING_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_LEADING"/>
|
||||
<param name="num_leading_columns" type="text" size="4" default="1" label="K2_COLUMNS_FOR_LEADING" description=""/>
|
||||
<param name="leadingImgSize" type="list" default="Large" label="K2_IMAGE_SIZE_FOR_LEADING_ITEMS" description="K2_THE_DIMENSIONS_FOR_EACH_IMAGE_SIZE_ARE_DEFINED_INSIDE_K2S_GLOBAL_PARAMETERS">
|
||||
<option value="XSmall">K2_XSMALL</option>
|
||||
<option value="Small">K2_SMALL</option>
|
||||
<option value="Medium">K2_MEDIUM</option>
|
||||
<option value="Large">K2_LARGE</option>
|
||||
<option value="XLarge">K2_XLARGE</option>
|
||||
<option value="none">K2_NO_IMAGE</option>
|
||||
</param>
|
||||
<param name="@spacer" type="spacer" default="" label="" description=""/>
|
||||
<param name="num_primary_items" type="text" size="4" default="4" label="K2_PRIMARY_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_PRIMARY"/>
|
||||
<param name="num_primary_columns" type="text" size="4" default="2" label="K2_COLUMNS_FOR_PRIMARY" description=""/>
|
||||
<param name="primaryImgSize" type="list" default="Medium" label="K2_IMAGE_SIZE_FOR_PRIMARY_ITEMS" description="K2_THE_DIMENSIONS_FOR_EACH_IMAGE_SIZE_ARE_DEFINED_INSIDE_K2S_GLOBAL_PARAMETERS">
|
||||
<option value="XSmall">K2_XSMALL</option>
|
||||
<option value="Small">K2_SMALL</option>
|
||||
<option value="Medium">K2_MEDIUM</option>
|
||||
<option value="Large">K2_LARGE</option>
|
||||
<option value="XLarge">K2_XLARGE</option>
|
||||
<option value="none">K2_NO_IMAGE</option>
|
||||
</param>
|
||||
<param name="@spacer" type="spacer" default="" label="" description=""/>
|
||||
<param name="num_secondary_items" type="text" size="4" default="4" label="K2_SECONDARY_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_SECONDARY"/>
|
||||
<param name="num_secondary_columns" type="text" size="4" default="1" label="K2_COLUMNS_FOR_SECONDARY" description=""/>
|
||||
<param name="secondaryImgSize" type="list" default="Small" label="K2_IMAGE_SIZE_FOR_SECONDARY_ITEMS" description="K2_THE_DIMENSIONS_FOR_EACH_IMAGE_SIZE_ARE_DEFINED_INSIDE_K2S_GLOBAL_PARAMETERS">
|
||||
<option value="XSmall">K2_XSMALL</option>
|
||||
<option value="Small">K2_SMALL</option>
|
||||
<option value="Medium">K2_MEDIUM</option>
|
||||
<option value="Large">K2_LARGE</option>
|
||||
<option value="XLarge">K2_XLARGE</option>
|
||||
<option value="none">K2_NO_IMAGE</option>
|
||||
</param>
|
||||
<param name="@spacer" type="spacer" default="" label="" description=""/>
|
||||
<param name="num_links" type="text" size="4" default="4" label="K2_LINKS_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_LINKS"/>
|
||||
<param name="num_links_columns" type="text" size="4" default="1" label="K2_COLUMNS_FOR_LINKS" description=""/>
|
||||
<param name="linksImgSize" type="list" default="XSmall" label="K2_IMAGE_SIZE_FOR_LINK_ITEMS" description="K2_THE_DIMENSIONS_FOR_EACH_IMAGE_SIZE_ARE_DEFINED_INSIDE_K2S_GLOBAL_PARAMETERS">
|
||||
<option value="XSmall">K2_XSMALL</option>
|
||||
<option value="Small">K2_SMALL</option>
|
||||
<option value="Medium">K2_MEDIUM</option>
|
||||
<option value="Large">K2_LARGE</option>
|
||||
<option value="XLarge">K2_XLARGE</option>
|
||||
<option value="none">K2_NO_IMAGE</option>
|
||||
</param>
|
||||
<param name="@spacer" type="spacer" default="" label="" description=""/>
|
||||
<param name="catFeaturedItems" type="list" default="1" label="K2_FEATURED_ITEMS" description="">
|
||||
<option value="0">K2_HIDE</option>
|
||||
<option value="1">K2_SHOW</option>
|
||||
<option value="2">K2_SHOW_ONLY_FEATURED_ITEMS</option>
|
||||
</param>
|
||||
<param name="catOrdering" type="list" default="" label="K2_ITEM_ORDERING" description="">
|
||||
<option value="">K2_DEFAULT</option>
|
||||
<option value="date">K2_OLDEST_FIRST</option>
|
||||
<option value="rdate">K2_MOST_RECENT_FIRST</option>
|
||||
<option value="publishUp">K2_RECENTLY_PUBLISHED</option>
|
||||
<option value="alpha">K2_TITLE_ALPHABETICAL</option>
|
||||
<option value="ralpha">K2_TITLE_REVERSEALPHABETICAL</option>
|
||||
<option value="order">K2_ORDERING</option>
|
||||
<option value="rorder">K2_ORDERING_REVERSE</option>
|
||||
<option value="featured">K2_FEATURED_FIRST</option>
|
||||
<option value="hits">K2_MOST_POPULAR</option>
|
||||
<option value="best">K2_HIGHEST_RATED</option>
|
||||
<option value="modified">K2_LATEST_MODIFIED</option>
|
||||
<option value="rand">K2_RANDOM_ORDERING</option>
|
||||
</param>
|
||||
<param name="catPagination" type="list" default="2" label="K2_PAGINATION" description="">
|
||||
<option value="0">K2_HIDE</option>
|
||||
<option value="1">K2_SHOW</option>
|
||||
<option value="2">K2_AUTO</option>
|
||||
</param>
|
||||
<param name="catPaginationResults" type="radio" default="1" label="K2_PAGINATION_RESULTS" description="">
|
||||
<option value="0">K2_HIDE</option>
|
||||
<option value="1">K2_SHOW</option>
|
||||
</param>
|
||||
<param name="@spacer" type="spacer" default="" label="" description=""/>
|
||||
<param name="catFeedLink" type="radio" default="1" label="K2_RSS_FEED_LINK" description="">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</param>
|
||||
<param name="catFeedIcon" type="radio" default="1" label="K2_RSS_FEED_ICON" description="">
|
||||
<option value="0">K2_HIDE</option>
|
||||
<option value="1">K2_SHOW</option>
|
||||
</param>
|
||||
</params>
|
||||
<url>
|
||||
<param name="task" type="hidden" default=""/>
|
||||
<param name="id" type="hidden" default=""/>
|
||||
</url>
|
||||
<fields name="request">
|
||||
<fieldset name="request">
|
||||
<field name="task" type="hidden" default=""/>
|
||||
<field name="id" type="hidden" default=""/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<fields name="params">
|
||||
<fieldset name="basic" addfieldpath="/administrator/components/com_k2/elements">
|
||||
<field name="" type="header" default="K2_SELECT_ONE_OR_MORE_CATEGORIES" label="" description=""/>
|
||||
<field name="categories" type="k2category" default="" label="K2_SELECT_CATEGORIES" description="K2_IF_YOU_SELECT_MULTIPLE_CATEGORIES_YOU_CAN_ADJUST_ADDITIONAL_PARAMETERS_BELOW_IF_YOU_SELECT_ONLY_ONE_CATEGORY_THEN_K2_WILL_FETCH_THE_OPTIONS_AS_DEFINED_IN_THAT_SPECIFIC_CATEGORYS_OPTIONS_IN_K2_CATEGORIES"/>
|
||||
<field name="catCatalogMode" type="list" default="0" label="K2_FETCH_ITEMS_FROM_CHILDREN_CATEGORIES" description="K2_IF_YOU_SELECT_NO_THEN_ONLY_THE_ITEMS_DIRECTLY_BELONGING_TO_THIS_CATEGORY_WILL_BE_RETRIEVED_IF_YOU_SELECT_YES_THEN_ITEMS_FROM_ALL_SUBCATEGORIES_WILL_BE_RETRIEVED_SETTING_THIS_OPTION_TO_YES_IS_IDEAL_FOR_NEWSPORTALMAGAZINEBLOG_LAYOUTS">
|
||||
<option value="1">K2_NO</option>
|
||||
<option value="0">K2_YES</option>
|
||||
</field>
|
||||
<field name="" type="header" default="K2_LAYOUT_OPTIONS_FOR_SINGLE_CATEGORY_SELECTION" label="" description=""/>
|
||||
<field name="singleCatOrdering" type="list" default="" label="K2_ITEM_ORDERING" description="">
|
||||
<option value="">K2_INHERIT_FROM_CATEGORY</option>
|
||||
<option value="date">K2_OLDEST_FIRST</option>
|
||||
<option value="rdate">K2_MOST_RECENT_FIRST</option>
|
||||
<option value="publishUp">K2_RECENTLY_PUBLISHED</option>
|
||||
<option value="alpha">K2_TITLE_ALPHABETICAL</option>
|
||||
<option value="ralpha">K2_TITLE_REVERSEALPHABETICAL</option>
|
||||
<option value="order">K2_ORDERING</option>
|
||||
<option value="rorder">K2_ORDERING_REVERSE</option>
|
||||
<option value="featured">K2_FEATURED_FIRST</option>
|
||||
<option value="hits">K2_MOST_POPULAR</option>
|
||||
<option value="best">K2_HIGHEST_RATED</option>
|
||||
<option value="modified">K2_LATEST_MODIFIED</option>
|
||||
<option value="rand">K2_RANDOM_ORDERING</option>
|
||||
</field>
|
||||
<field name="" type="header" default="K2_LAYOUT_OPTIONS_FOR_MULTIPLE_CATEGORY_SELECTION" label="" description=""/>
|
||||
<field name="theme" type="template" default="default" label="K2_SELECT_A_TEMPLATE"/>
|
||||
<field name="@spacer" type="spacer" default="" label="" description=""/>
|
||||
<field name="num_leading_items" type="text" size="4" default="2" label="K2_LEADING_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_LEADING"/>
|
||||
<field name="num_leading_columns" type="text" size="4" default="1" label="K2_COLUMNS_FOR_LEADING" description=""/>
|
||||
<field name="leadingImgSize" type="list" default="Large" label="K2_IMAGE_SIZE_FOR_LEADING_ITEMS" description="K2_THE_DIMENSIONS_FOR_EACH_IMAGE_SIZE_ARE_DEFINED_INSIDE_K2S_GLOBAL_PARAMETERS">
|
||||
<option value="XSmall">K2_XSMALL</option>
|
||||
<option value="Small">K2_SMALL</option>
|
||||
<option value="Medium">K2_MEDIUM</option>
|
||||
<option value="Large">K2_LARGE</option>
|
||||
<option value="XLarge">K2_XLARGE</option>
|
||||
<option value="none">K2_NO_IMAGE</option>
|
||||
</field>
|
||||
<field name="@spacer" type="spacer" default="" label="" description=""/>
|
||||
<field name="num_primary_items" type="text" size="4" default="4" label="K2_PRIMARY_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_PRIMARY"/>
|
||||
<field name="num_primary_columns" type="text" size="4" default="2" label="K2_COLUMNS_FOR_PRIMARY" description=""/>
|
||||
<field name="primaryImgSize" type="list" default="Medium" label="K2_IMAGE_SIZE_FOR_PRIMARY_ITEMS" description="K2_THE_DIMENSIONS_FOR_EACH_IMAGE_SIZE_ARE_DEFINED_INSIDE_K2S_GLOBAL_PARAMETERS">
|
||||
<option value="XSmall">K2_XSMALL</option>
|
||||
<option value="Small">K2_SMALL</option>
|
||||
<option value="Medium">K2_MEDIUM</option>
|
||||
<option value="Large">K2_LARGE</option>
|
||||
<option value="XLarge">K2_XLARGE</option>
|
||||
<option value="none">K2_NO_IMAGE</option>
|
||||
</field>
|
||||
<field name="@spacer" type="spacer" default="" label="" description=""/>
|
||||
<field name="num_secondary_items" type="text" size="4" default="4" label="K2_SECONDARY_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_SECONDARY"/>
|
||||
<field name="num_secondary_columns" type="text" size="4" default="1" label="K2_COLUMNS_FOR_SECONDARY" description=""/>
|
||||
<field name="secondaryImgSize" type="list" default="Small" label="K2_IMAGE_SIZE_FOR_SECONDARY_ITEMS" description="K2_THE_DIMENSIONS_FOR_EACH_IMAGE_SIZE_ARE_DEFINED_INSIDE_K2S_GLOBAL_PARAMETERS">
|
||||
<option value="XSmall">K2_XSMALL</option>
|
||||
<option value="Small">K2_SMALL</option>
|
||||
<option value="Medium">K2_MEDIUM</option>
|
||||
<option value="Large">K2_LARGE</option>
|
||||
<option value="XLarge">K2_XLARGE</option>
|
||||
<option value="none">K2_NO_IMAGE</option>
|
||||
</field>
|
||||
<field name="@spacer" type="spacer" default="" label="" description=""/>
|
||||
<field name="num_links" type="text" size="4" default="4" label="K2_LINKS_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_LINKS"/>
|
||||
<field name="num_links_columns" type="text" size="4" default="1" label="K2_COLUMNS_FOR_LINKS" description=""/>
|
||||
<field name="linksImgSize" type="list" default="XSmall" label="K2_IMAGE_SIZE_FOR_LINK_ITEMS" description="K2_THE_DIMENSIONS_FOR_EACH_IMAGE_SIZE_ARE_DEFINED_INSIDE_K2S_GLOBAL_PARAMETERS">
|
||||
<option value="XSmall">K2_XSMALL</option>
|
||||
<option value="Small">K2_SMALL</option>
|
||||
<option value="Medium">K2_MEDIUM</option>
|
||||
<option value="Large">K2_LARGE</option>
|
||||
<option value="XLarge">K2_XLARGE</option>
|
||||
<option value="none">K2_NO_IMAGE</option>
|
||||
</field>
|
||||
<field name="@spacer" type="spacer" default="" label="" description=""/>
|
||||
<field name="catFeaturedItems" type="list" default="1" label="K2_FEATURED_ITEMS" description="">
|
||||
<option value="0">K2_HIDE</option>
|
||||
<option value="1">K2_SHOW</option>
|
||||
<option value="2">K2_SHOW_ONLY_FEATURED_ITEMS</option>
|
||||
</field>
|
||||
<field name="catOrdering" type="list" default="" label="K2_ITEM_ORDERING" description="">
|
||||
<option value="">K2_DEFAULT</option>
|
||||
<option value="date">K2_OLDEST_FIRST</option>
|
||||
<option value="rdate">K2_MOST_RECENT_FIRST</option>
|
||||
<option value="publishUp">K2_RECENTLY_PUBLISHED</option>
|
||||
<option value="alpha">K2_TITLE_ALPHABETICAL</option>
|
||||
<option value="ralpha">K2_TITLE_REVERSEALPHABETICAL</option>
|
||||
<option value="order">K2_ORDERING</option>
|
||||
<option value="rorder">K2_ORDERING_REVERSE</option>
|
||||
<option value="featured">K2_FEATURED_FIRST</option>
|
||||
<option value="hits">K2_MOST_POPULAR</option>
|
||||
<option value="best">K2_HIGHEST_RATED</option>
|
||||
<option value="modified">K2_LATEST_MODIFIED</option>
|
||||
<option value="rand">K2_RANDOM_ORDERING</option>
|
||||
</field>
|
||||
<field name="catPagination" type="list" default="2" label="K2_PAGINATION" description="">
|
||||
<option value="0">K2_HIDE</option>
|
||||
<option value="1">K2_SHOW</option>
|
||||
<option value="2">K2_AUTO</option>
|
||||
</field>
|
||||
<field name="catPaginationResults" type="radio" default="1" label="K2_PAGINATION_RESULTS" description="">
|
||||
<option value="0">K2_HIDE</option>
|
||||
<option value="1">K2_SHOW</option>
|
||||
</field>
|
||||
<field name="@spacer" type="spacer" default="" label="" description=""/>
|
||||
<field name="catFeedLink" type="radio" default="1" label="K2_RSS_FEED_LINK" description="">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</field>
|
||||
<field name="catFeedIcon" type="radio" default="1" label="K2_RSS_FEED_ICON" description="">
|
||||
<option value="0">K2_HIDE</option>
|
||||
<option value="1">K2_SHOW</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</state>
|
||||
</metadata>
|
13
components/com_k2/views/itemlist/tmpl/category_item.php
Normal file
13
components/com_k2/views/itemlist/tmpl/category_item.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: category_item.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
|
||||
* @package K2
|
||||
* @author JoomlaWorks http://www.joomlaworks.net
|
||||
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
?>
|
9
components/com_k2/views/itemlist/tmpl/generic.xml
Normal file
9
components/com_k2/views/itemlist/tmpl/generic.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
<layout title="Generic" hidden="true">
|
||||
<message>
|
||||
<![CDATA[This XML file is intentionally left blank to override the pre-v2.5 generic.xml file, which K2 used to create the 'tag' menu item. The 'tag' menu item now has its own tag.xml menu definition file.]]>
|
||||
</message>
|
||||
</layout>
|
||||
<state></state>
|
||||
</metadata>
|
13
components/com_k2/views/itemlist/tmpl/generic_item.php
Normal file
13
components/com_k2/views/itemlist/tmpl/generic_item.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: generic_item.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
|
||||
* @package K2
|
||||
* @author JoomlaWorks http://www.joomlaworks.net
|
||||
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
?>
|
13
components/com_k2/views/itemlist/tmpl/tag.php
Normal file
13
components/com_k2/views/itemlist/tmpl/tag.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: tag.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
|
||||
* @package K2
|
||||
* @author JoomlaWorks http://www.joomlaworks.net
|
||||
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
?>
|
78
components/com_k2/views/itemlist/tmpl/tag.xml
Normal file
78
components/com_k2/views/itemlist/tmpl/tag.xml
Normal file
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
<layout title="K2_TAG">
|
||||
<message>
|
||||
<![CDATA[K2_CREATE_A_MENU_ITEM_LINKING_TO_A_TAG_IN_K2]]>
|
||||
</message>
|
||||
</layout>
|
||||
<state>
|
||||
<name>K2_TAG</name>
|
||||
<description>K2_CREATE_A_MENU_ITEM_LINKING_TO_A_TAG_IN_K2</description>
|
||||
<params addpath="/administrator/components/com_k2/elements">
|
||||
<param name="theme" type="template" default="default" label="K2_SELECT_A_TEMPLATE"/>
|
||||
<param name="categoriesFilter" type="category" default="" label="K2_FILTER_CATEGORIES" description=""/>
|
||||
<param name="tagOrdering" type="list" default="" label="K2_ITEM_ORDERING" description="">
|
||||
<option value="">K2_INHERIT_FROM_PARAMS</option>
|
||||
<option value="id">K2_DEFAULT</option>
|
||||
<option value="date">K2_OLDEST_FIRST</option>
|
||||
<option value="rdate">K2_MOST_RECENT_FIRST</option>
|
||||
<option value="publishUp">K2_RECENTLY_PUBLISHED</option>
|
||||
<option value="alpha">K2_TITLE_ALPHABETICAL</option>
|
||||
<option value="ralpha">K2_TITLE_REVERSEALPHABETICAL</option>
|
||||
<option value="order">K2_ORDERING</option>
|
||||
<option value="rorder">K2_ORDERING_REVERSE</option>
|
||||
<option value="featured">K2_FEATURED_FIRST</option>
|
||||
<option value="hits">K2_MOST_POPULAR</option>
|
||||
<option value="best">K2_HIGHEST_RATED</option>
|
||||
<option value="rand">K2_RANDOM_ORDERING</option>
|
||||
</param>
|
||||
<param name="tagFeedLink" type="radio" default="1" label="K2_RSS_FEED_LINK" description="">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</param>
|
||||
<param name="tagFeedIcon" type="radio" default="1" label="K2_RSS_FEED_ICON" description="">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</param>
|
||||
</params>
|
||||
<url addpath="/administrator/components/com_k2/elements">
|
||||
<param name="tag" type="k2tag" default="" label="K2_SELECT_TAG" description=""/>
|
||||
<param name="task" type="hidden" default="tag"/>
|
||||
</url>
|
||||
<fields name="request">
|
||||
<fieldset name="request" addfieldpath="/administrator/components/com_k2/elements">
|
||||
<field name="tag" type="k2tag" default="" label="K2_SELECT_TAG" description=""/>
|
||||
<field name="task" type="hidden" default="tag"/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<fields name="params">
|
||||
<fieldset name="basic" addfieldpath="/administrator/components/com_k2/elements">
|
||||
<field name="theme" type="template" default="default" label="K2_SELECT_A_TEMPLATE"/>
|
||||
<field name="categoriesFilter" type="k2category" default="" label="K2_FILTER_CATEGORIES" description=""/>
|
||||
<field name="tagOrdering" type="list" default="" label="K2_ITEM_ORDERING" description="">
|
||||
<option value="">K2_INHERIT_FROM_PARAMS</option>
|
||||
<option value="id">K2_DEFAULT</option>
|
||||
<option value="date">K2_OLDEST_FIRST</option>
|
||||
<option value="rdate">K2_MOST_RECENT_FIRST</option>
|
||||
<option value="publishUp">K2_RECENTLY_PUBLISHED</option>
|
||||
<option value="alpha">K2_TITLE_ALPHABETICAL</option>
|
||||
<option value="ralpha">K2_TITLE_REVERSEALPHABETICAL</option>
|
||||
<option value="order">K2_ORDERING</option>
|
||||
<option value="rorder">K2_ORDERING_REVERSE</option>
|
||||
<option value="featured">K2_FEATURED_FIRST</option>
|
||||
<option value="hits">K2_MOST_POPULAR</option>
|
||||
<option value="best">K2_HIGHEST_RATED</option>
|
||||
<option value="rand">K2_RANDOM_ORDERING</option>
|
||||
</field>
|
||||
<field name="tagFeedLink" type="radio" default="1" label="K2_RSS_FEED_LINK" description="">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</field>
|
||||
<field name="tagFeedIcon" type="radio" default="1" label="K2_RSS_FEED_ICON" description="">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</state>
|
||||
</metadata>
|
13
components/com_k2/views/itemlist/tmpl/user.php
Normal file
13
components/com_k2/views/itemlist/tmpl/user.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: user.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
|
||||
* @package K2
|
||||
* @author JoomlaWorks http://www.joomlaworks.net
|
||||
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
?>
|
76
components/com_k2/views/itemlist/tmpl/user.xml
Normal file
76
components/com_k2/views/itemlist/tmpl/user.xml
Normal file
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<metadata>
|
||||
<layout title="K2_USER_PAGE_BLOG">
|
||||
<message>
|
||||
<![CDATA[K2_CREATE_A_MENU_ITEM_LINKING_TO_A_USER_PAGE_BLOG]]>
|
||||
</message>
|
||||
</layout>
|
||||
<state>
|
||||
<name>K2_USER_PAGE_BLOG</name>
|
||||
<description>K2_CREATE_A_MENU_ITEM_LINKING_TO_A_USER_PAGE_BLOG</description>
|
||||
<params addPath="/administrator/components/com_k2/elements">
|
||||
<param name="theme" type="template" default="default" label="K2_SELECT_A_TEMPLATE"/>
|
||||
<param name="userCategoriesFilter" type="categories" multiple="multiple" default="" label="K2_FILTER_CATEGORIES" description=""/>
|
||||
<param name="userOrdering" type="list" default="" label="K2_ITEM_ORDERING" description="">
|
||||
<option value="">K2_DEFAULT</option>
|
||||
<option value="date">K2_OLDEST_FIRST</option>
|
||||
<option value="rdate">K2_MOST_RECENT_FIRST</option>
|
||||
<option value="publishUp">K2_RECENTLY_PUBLISHED</option>
|
||||
<option value="alpha">K2_TITLE_ALPHABETICAL</option>
|
||||
<option value="ralpha">K2_TITLE_REVERSEALPHABETICAL</option>
|
||||
<option value="order">K2_ORDERING</option>
|
||||
<option value="rorder">K2_ORDERING_REVERSE</option>
|
||||
<option value="featured">K2_FEATURED_FIRST</option>
|
||||
<option value="hits">K2_MOST_POPULAR</option>
|
||||
<option value="best">K2_HIGHEST_RATED</option>
|
||||
<option value="rand">K2_RANDOM_ORDERING</option>
|
||||
</param>
|
||||
<param name="userFeedLink" type="radio" default="1" label="K2_RSS_FEED_LINK" description="">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</param>
|
||||
<param name="userFeedIcon" type="radio" default="1" label="K2_RSS_FEED_ICON" description="">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</param>
|
||||
</params>
|
||||
<url addpath="/administrator/components/com_k2/elements">
|
||||
<param name="id" type="user" default="" label="K2_SELECT_USER" description=""/>
|
||||
<param name="task" type="hidden" default="user"/>
|
||||
</url>
|
||||
<fields name="request" addfieldpath="/administrator/components/com_k2/elements">
|
||||
<fieldset name="request">
|
||||
<field name="id" type="k2user" default="" label="K2_SELECT_USER" description=""/>
|
||||
<field name="task" type="hidden" default="user"/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
<fields name="params" addfieldpath="/administrator/components/com_k2/elements">
|
||||
<fieldset name="basic">
|
||||
<field name="theme" type="template" default="default" label="K2_SELECT_A_TEMPLATE"/>
|
||||
<field name="userCategoriesFilter" type="categories" multiple="multiple" default="" label="K2_FILTER_CATEGORIES" description=""/>
|
||||
<field name="userOrdering" type="list" default="" label="K2_ITEM_ORDERING" description="">
|
||||
<option value="">K2_DEFAULT</option>
|
||||
<option value="date">K2_OLDEST_FIRST</option>
|
||||
<option value="rdate">K2_MOST_RECENT_FIRST</option>
|
||||
<option value="publishUp">K2_RECENTLY_PUBLISHED</option>
|
||||
<option value="alpha">K2_TITLE_ALPHABETICAL</option>
|
||||
<option value="ralpha">K2_TITLE_REVERSEALPHABETICAL</option>
|
||||
<option value="order">K2_ORDERING</option>
|
||||
<option value="rorder">K2_ORDERING_REVERSE</option>
|
||||
<option value="featured">K2_FEATURED_FIRST</option>
|
||||
<option value="hits">K2_MOST_POPULAR</option>
|
||||
<option value="best">K2_HIGHEST_RATED</option>
|
||||
<option value="rand">K2_RANDOM_ORDERING</option>
|
||||
</field>
|
||||
<field name="userFeedLink" type="radio" default="1" label="K2_RSS_FEED_LINK" description="">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</field>
|
||||
<field name="userFeedIcon" type="radio" default="1" label="K2_RSS_FEED_ICON" description="">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</state>
|
||||
</metadata>
|
13
components/com_k2/views/itemlist/tmpl/user_item.php
Normal file
13
components/com_k2/views/itemlist/tmpl/user_item.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: user_item.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
|
||||
* @package K2
|
||||
* @author JoomlaWorks http://www.joomlaworks.net
|
||||
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
?>
|
290
components/com_k2/views/itemlist/view.feed.php
Normal file
290
components/com_k2/views/itemlist/view.feed.php
Normal file
@ -0,0 +1,290 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: view.feed.php 1930 2013-02-13 14:11:07Z joomlaworks $
|
||||
* @package K2
|
||||
* @author JoomlaWorks http://www.joomlaworks.net
|
||||
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
jimport('joomla.application.component.view');
|
||||
|
||||
class K2ViewItemlist extends K2View
|
||||
{
|
||||
|
||||
function display($tpl = null)
|
||||
{
|
||||
|
||||
$mainframe = JFactory::getApplication();
|
||||
$params = K2HelperUtilities::getParams('com_k2');
|
||||
$document = JFactory::getDocument();
|
||||
$model = $this->getModel('itemlist');
|
||||
$limitstart = JRequest::getInt('limitstart');
|
||||
$moduleID = JRequest::getInt('moduleID');
|
||||
|
||||
if ($moduleID)
|
||||
{
|
||||
|
||||
$result = $model->getModuleItems($moduleID);
|
||||
$items = $result->items;
|
||||
$title = $result->title;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//Get data depending on task
|
||||
$task = JRequest::getCmd('task');
|
||||
switch ($task)
|
||||
{
|
||||
|
||||
case 'category' :
|
||||
//Get category
|
||||
$id = JRequest::getInt('id');
|
||||
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
|
||||
$category = JTable::getInstance('K2Category', 'Table');
|
||||
$category->load($id);
|
||||
|
||||
// State check
|
||||
if (!$category->published || $category->trash)
|
||||
{
|
||||
JError::raiseError(404, JText::_('K2_CATEGORY_NOT_FOUND'));
|
||||
}
|
||||
|
||||
//Access check
|
||||
$user = JFactory::getUser();
|
||||
if (K2_JVERSION != '15')
|
||||
{
|
||||
if (!in_array($category->access, $user->getAuthorisedViewLevels()))
|
||||
{
|
||||
if ($user->guest)
|
||||
{
|
||||
$uri = JFactory::getURI();
|
||||
$url = 'index.php?option=com_users&view=login&return='.base64_encode($uri->toString());
|
||||
$mainframe->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'));
|
||||
}
|
||||
else
|
||||
{
|
||||
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
$languageFilter = $mainframe->getLanguageFilter();
|
||||
$languageTag = JFactory::getLanguage()->getTag();
|
||||
if ($languageFilter && $category->language != $languageTag && $category->language != '*')
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($category->access > $user->get('aid', 0))
|
||||
{
|
||||
if ($user->guest)
|
||||
{
|
||||
$uri = JFactory::getURI();
|
||||
$url = 'index.php?option=com_user&view=login&return='.base64_encode($uri->toString());
|
||||
$mainframe->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'));
|
||||
}
|
||||
else
|
||||
{
|
||||
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Merge params
|
||||
$cparams = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params);
|
||||
if ($cparams->get('inheritFrom'))
|
||||
{
|
||||
$masterCategory = JTable::getInstance('K2Category', 'Table');
|
||||
$masterCategory->load($cparams->get('inheritFrom'));
|
||||
$cparams = class_exists('JParameter') ? new JParameter($masterCategory->params) : new JRegistry($masterCategory->params);
|
||||
}
|
||||
$params->merge($cparams);
|
||||
|
||||
//Category link
|
||||
$category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id.':'.urlencode($category->alias))));
|
||||
|
||||
//Set featured flag
|
||||
JRequest::setVar('featured', $params->get('catFeaturedItems'));
|
||||
|
||||
//Set title
|
||||
$title = $category->name;
|
||||
|
||||
// Set ordering
|
||||
if ($params->get('singleCatOrdering'))
|
||||
{
|
||||
$ordering = $params->get('singleCatOrdering');
|
||||
}
|
||||
else
|
||||
{
|
||||
$ordering = $params->get('catOrdering');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'user' :
|
||||
//Get user
|
||||
$id = JRequest::getInt('id');
|
||||
$userObject = JFactory::getUser($id);
|
||||
|
||||
//Check user status
|
||||
if ($userObject->block)
|
||||
{
|
||||
JError::raiseError(404, JText::_('K2_USER_NOT_FOUND'));
|
||||
}
|
||||
|
||||
//Set title
|
||||
$title = $userObject->name;
|
||||
|
||||
// Set ordering
|
||||
$ordering = $params->get('userOrdering');
|
||||
|
||||
break;
|
||||
|
||||
case 'tag' :
|
||||
//set title
|
||||
$title = JText::_('K2_DISPLAYING_ITEMS_BY_TAG').' '.JRequest::getVar('tag');
|
||||
|
||||
// Set ordering
|
||||
$ordering = $params->get('tagOrdering');
|
||||
break;
|
||||
|
||||
case 'search' :
|
||||
//Set title
|
||||
$title = JText::_('K2_SEARCH_RESULTS_FOR').' '.JRequest::getVar('searchword');
|
||||
break;
|
||||
|
||||
case 'date' :
|
||||
// Set title
|
||||
if (JRequest::getInt('day'))
|
||||
{
|
||||
$date = strtotime(JRequest::getInt('year').'-'.JRequest::getInt('month').'-'.JRequest::getInt('day'));
|
||||
$dateFormat = (K2_JVERSION == '15') ? '%A, %d %B %Y' : 'l, d F Y';
|
||||
$title = JText::_('K2_ITEMS_FILTERED_BY_DATE').' '.JHTML::_('date', $date, $dateFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
$date = strtotime(JRequest::getInt('year').'-'.JRequest::getInt('month'));
|
||||
$dateFormat = (K2_JVERSION == '15') ? '%B %Y' : 'F Y';
|
||||
$title = JText::_('K2_ITEMS_FILTERED_BY_DATE').' '.JHTML::_('date', $date, $dateFormat);
|
||||
}
|
||||
// Set ordering
|
||||
$ordering = 'rdate';
|
||||
break;
|
||||
|
||||
default :
|
||||
|
||||
//Set featured flag
|
||||
JRequest::setVar('featured', $params->get('catFeaturedItems'));
|
||||
|
||||
//Set title
|
||||
$title = $params->get('page_title');
|
||||
|
||||
// Set ordering
|
||||
$ordering = $params->get('catOrdering');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Various Feed Validations
|
||||
$title = JFilterOutput::ampReplace($title);
|
||||
|
||||
// Get items
|
||||
if (!isset($ordering))
|
||||
{
|
||||
$items = $model->getData();
|
||||
}
|
||||
else
|
||||
{
|
||||
$items = $model->getData($ordering);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Prepare feed items
|
||||
$model = &$this->getModel('item');
|
||||
foreach ($items as $item)
|
||||
{
|
||||
|
||||
$item = $model->prepareFeedItem($item);
|
||||
$item->title = $this->escape($item->title);
|
||||
$item->title = html_entity_decode($item->title);
|
||||
$feedItem = new JFeedItem();
|
||||
$feedItem->title = $item->title;
|
||||
$feedItem->link = $item->link;
|
||||
$feedItem->description = $item->description;
|
||||
$feedItem->date = $item->created;
|
||||
$feedItem->category = $item->category->name;
|
||||
$feedItem->author = $item->author->name;
|
||||
if ($params->get('feedBogusEmail'))
|
||||
{
|
||||
$feedItem->authorEmail = $params->get('feedBogusEmail');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($mainframe->getCfg('feed_email') == 'author')
|
||||
{
|
||||
$feedItem->authorEmail = $item->author->email;
|
||||
}
|
||||
else
|
||||
{
|
||||
$feedItem->authorEmail = $mainframe->getCfg('mailfrom');
|
||||
}
|
||||
}
|
||||
|
||||
// Add item
|
||||
$document->addItem($feedItem);
|
||||
}
|
||||
|
||||
// Set title
|
||||
$document = JFactory::getDocument();
|
||||
$menus = JSite::getMenu();
|
||||
$menu = $menus->getActive();
|
||||
if (is_object($menu))
|
||||
{
|
||||
$menu_params = class_exists('JParameter') ? new JParameter($menu->params) : new JRegistry($menu->params);
|
||||
if (!$menu_params->get('page_title'))
|
||||
$params->set('page_title', $title);
|
||||
}
|
||||
else
|
||||
{
|
||||
$params->set('page_title', $title);
|
||||
}
|
||||
if (K2_JVERSION != '15')
|
||||
{
|
||||
if ($mainframe->getCfg('sitename_pagetitles', 0) == 1)
|
||||
{
|
||||
$title = JText::sprintf('JPAGETITLE', $mainframe->getCfg('sitename'), $params->get('page_title'));
|
||||
$params->set('page_title', $title);
|
||||
}
|
||||
elseif ($mainframe->getCfg('sitename_pagetitles', 0) == 2)
|
||||
{
|
||||
$title = JText::sprintf('JPAGETITLE', $params->get('page_title'), $mainframe->getCfg('sitename'));
|
||||
$params->set('page_title', $title);
|
||||
}
|
||||
}
|
||||
$document->setTitle($params->get('page_title'));
|
||||
|
||||
// Prevent spammers from using the tag view
|
||||
if ($task == 'tag' && !count($items))
|
||||
{
|
||||
$tag = JRequest::getString('tag');
|
||||
$db = JFactory::getDBO();
|
||||
$db->setQuery('SELECT id FROM #__k2_tags WHERE name = '.$db->quote($tag));
|
||||
$tagID = $db->loadResult();
|
||||
if (!$tagID)
|
||||
{
|
||||
JError::raiseError(404, JText::_('K2_NOT_FOUND'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
744
components/com_k2/views/itemlist/view.html.php
Normal file
744
components/com_k2/views/itemlist/view.html.php
Normal file
@ -0,0 +1,744 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: view.html.php 1990 2013-07-04 14:31:30Z lefteris.kavadas $
|
||||
* @package K2
|
||||
* @author JoomlaWorks http://www.joomlaworks.net
|
||||
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die ;
|
||||
|
||||
jimport('joomla.application.component.view');
|
||||
|
||||
class K2ViewItemlist extends K2View
|
||||
{
|
||||
|
||||
function display($tpl = null)
|
||||
{
|
||||
$mainframe = JFactory::getApplication();
|
||||
$params = K2HelperUtilities::getParams('com_k2');
|
||||
$model = $this->getModel('itemlist');
|
||||
$limitstart = JRequest::getInt('limitstart');
|
||||
$view = JRequest::getWord('view');
|
||||
$task = JRequest::getWord('task');
|
||||
$db = JFactory::getDBO();
|
||||
|
||||
// Add link
|
||||
if (K2HelperPermissions::canAddItem())
|
||||
$addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component');
|
||||
$this->assignRef('addLink', $addLink);
|
||||
|
||||
// Get data depending on task
|
||||
switch ($task)
|
||||
{
|
||||
|
||||
case 'category' :
|
||||
// Get category
|
||||
$id = JRequest::getInt('id');
|
||||
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
|
||||
$category = JTable::getInstance('K2Category', 'Table');
|
||||
$category->load($id);
|
||||
$category->event = new stdClass;
|
||||
|
||||
// State check
|
||||
if (!$category->published || $category->trash)
|
||||
{
|
||||
JError::raiseError(404, JText::_('K2_CATEGORY_NOT_FOUND'));
|
||||
}
|
||||
|
||||
// Access check
|
||||
$user = JFactory::getUser();
|
||||
if (K2_JVERSION != '15')
|
||||
{
|
||||
if (!in_array($category->access, $user->getAuthorisedViewLevels()))
|
||||
{
|
||||
|
||||
if ($user->guest)
|
||||
{
|
||||
$uri = JFactory::getURI();
|
||||
$url = 'index.php?option=com_users&view=login&return='.base64_encode($uri->toString());
|
||||
$mainframe->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'));
|
||||
}
|
||||
else
|
||||
{
|
||||
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
$languageFilter = $mainframe->getLanguageFilter();
|
||||
$languageTag = JFactory::getLanguage()->getTag();
|
||||
if ($languageFilter && $category->language != $languageTag && $category->language != '*')
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($category->access > $user->get('aid', 0))
|
||||
{
|
||||
if ($user->guest)
|
||||
{
|
||||
$uri = JFactory::getURI();
|
||||
$url = 'index.php?option=com_user&view=login&return='.base64_encode($uri->toString());
|
||||
$mainframe->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'));
|
||||
}
|
||||
else
|
||||
{
|
||||
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hide the add new item link if user cannot post in the specific category
|
||||
if (!K2HelperPermissions::canAddItem($id))
|
||||
{
|
||||
unset($this->addLink);
|
||||
}
|
||||
|
||||
// Merge params
|
||||
$cparams = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params);
|
||||
|
||||
// Get the meta information before merging params since we do not want them to be inherited
|
||||
$category->metaDescription = $cparams->get('catMetaDesc');
|
||||
$category->metaKeywords = $cparams->get('catMetaKey');
|
||||
$category->metaRobots = $cparams->get('catMetaRobots');
|
||||
$category->metaAuthor = $cparams->get('catMetaAuthor');
|
||||
|
||||
if ($cparams->get('inheritFrom'))
|
||||
{
|
||||
$masterCategory = JTable::getInstance('K2Category', 'Table');
|
||||
$masterCategory->load($cparams->get('inheritFrom'));
|
||||
$cparams = class_exists('JParameter') ? new JParameter($masterCategory->params) : new JRegistry($masterCategory->params);
|
||||
}
|
||||
$params->merge($cparams);
|
||||
|
||||
// Category link
|
||||
$category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id.':'.urlencode($category->alias))));
|
||||
|
||||
// Category image
|
||||
$category->image = K2HelperUtilities::getCategoryImage($category->image, $params);
|
||||
|
||||
// Category plugins
|
||||
$dispatcher = JDispatcher::getInstance();
|
||||
JPluginHelper::importPlugin('content');
|
||||
$category->text = $category->description;
|
||||
if (K2_JVERSION != '15')
|
||||
{
|
||||
$dispatcher->trigger('onContentPrepare', array(
|
||||
'com_k2.category',
|
||||
&$category,
|
||||
&$params,
|
||||
$limitstart
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
$dispatcher->trigger('onPrepareContent', array(
|
||||
&$category,
|
||||
&$params,
|
||||
$limitstart
|
||||
));
|
||||
}
|
||||
|
||||
$category->description = $category->text;
|
||||
|
||||
// Category K2 plugins
|
||||
$category->event->K2CategoryDisplay = '';
|
||||
JPluginHelper::importPlugin('k2');
|
||||
$results = $dispatcher->trigger('onK2CategoryDisplay', array(
|
||||
&$category,
|
||||
&$params,
|
||||
$limitstart
|
||||
));
|
||||
$category->event->K2CategoryDisplay = trim(implode("\n", $results));
|
||||
$category->text = $category->description;
|
||||
$dispatcher->trigger('onK2PrepareContent', array(
|
||||
&$category,
|
||||
&$params,
|
||||
$limitstart
|
||||
));
|
||||
$category->description = $category->text;
|
||||
|
||||
$this->assignRef('category', $category);
|
||||
$this->assignRef('user', $user);
|
||||
|
||||
// Category children
|
||||
$ordering = $params->get('subCatOrdering');
|
||||
$children = $model->getCategoryFirstChildren($id, $ordering);
|
||||
if (count($children))
|
||||
{
|
||||
foreach ($children as $child)
|
||||
{
|
||||
if ($params->get('subCatTitleItemCounter'))
|
||||
{
|
||||
$child->numOfItems = $model->countCategoryItems($child->id);
|
||||
}
|
||||
$child->image = K2HelperUtilities::getCategoryImage($child->image, $params);
|
||||
$child->name = htmlspecialchars($child->name, ENT_QUOTES);
|
||||
$child->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($child->id.':'.urlencode($child->alias))));
|
||||
$subCategories[] = $child;
|
||||
}
|
||||
$this->assignRef('subCategories', $subCategories);
|
||||
}
|
||||
|
||||
// Set limit
|
||||
$limit = $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items') + $params->get('num_links');
|
||||
|
||||
// Set featured flag
|
||||
JRequest::setVar('featured', $params->get('catFeaturedItems'));
|
||||
|
||||
// Set layout
|
||||
$this->setLayout('category');
|
||||
|
||||
// Set title
|
||||
$title = $category->name;
|
||||
$category->name = htmlspecialchars($category->name, ENT_QUOTES);
|
||||
|
||||
// Set ordering
|
||||
if ($params->get('singleCatOrdering'))
|
||||
{
|
||||
$ordering = $params->get('singleCatOrdering');
|
||||
}
|
||||
else
|
||||
{
|
||||
$ordering = $params->get('catOrdering');
|
||||
}
|
||||
|
||||
$addHeadFeedLink = $params->get('catFeedLink');
|
||||
|
||||
break;
|
||||
|
||||
case 'user' :
|
||||
// Get user
|
||||
$id = JRequest::getInt('id');
|
||||
$userObject = JFactory::getUser($id);
|
||||
$userObject->event = new stdClass;
|
||||
|
||||
// Check user status
|
||||
if ($userObject->block)
|
||||
{
|
||||
JError::raiseError(404, JText::_('K2_USER_NOT_FOUND'));
|
||||
}
|
||||
|
||||
// Get K2 user profile
|
||||
$userObject->profile = $model->getUserProfile();
|
||||
|
||||
// User image
|
||||
$userObject->avatar = K2HelperUtilities::getAvatar($userObject->id, $userObject->email, $params->get('userImageWidth'));
|
||||
|
||||
// User K2 plugins
|
||||
$userObject->event->K2UserDisplay = '';
|
||||
if (is_object($userObject->profile) && $userObject->profile->id > 0)
|
||||
{
|
||||
$dispatcher = JDispatcher::getInstance();
|
||||
JPluginHelper::importPlugin('k2');
|
||||
$results = $dispatcher->trigger('onK2UserDisplay', array(
|
||||
&$userObject->profile,
|
||||
&$params,
|
||||
$limitstart
|
||||
));
|
||||
$userObject->event->K2UserDisplay = trim(implode("\n", $results));
|
||||
$userObject->profile->url = htmlspecialchars($userObject->profile->url, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
$this->assignRef('user', $userObject);
|
||||
|
||||
$date = JFactory::getDate();
|
||||
$now = K2_JVERSION == '15' ? $date->toMySQL() : $date->toSql();
|
||||
$this->assignRef('now', $now);
|
||||
|
||||
// Set layout
|
||||
$this->setLayout('user');
|
||||
|
||||
// Set limit
|
||||
$limit = $params->get('userItemCount');
|
||||
|
||||
// Set title
|
||||
$title = $userObject->name;
|
||||
$userObject->name = htmlspecialchars($userObject->name, ENT_QUOTES);
|
||||
|
||||
// Set ordering
|
||||
$ordering = $params->get('userOrdering');
|
||||
|
||||
$addHeadFeedLink = $params->get('userFeedLink', 1);
|
||||
|
||||
break;
|
||||
|
||||
case 'tag' :
|
||||
// Set layout
|
||||
$this->setLayout('tag');
|
||||
|
||||
// Set limit
|
||||
$limit = $params->get('tagItemCount');
|
||||
|
||||
// Set title
|
||||
$title = JText::_('K2_DISPLAYING_ITEMS_BY_TAG').' '.JRequest::getVar('tag');
|
||||
|
||||
// Set ordering
|
||||
$ordering = $params->get('tagOrdering');
|
||||
|
||||
$addHeadFeedLink = $params->get('tagFeedLink', 1);
|
||||
|
||||
break;
|
||||
|
||||
case 'search' :
|
||||
// Set layout
|
||||
$this->setLayout('generic');
|
||||
|
||||
// Set limit
|
||||
$limit = $params->get('genericItemCount');
|
||||
|
||||
// Set title
|
||||
$title = JText::_('K2_SEARCH_RESULTS_FOR').' '.JRequest::getVar('searchword');
|
||||
|
||||
$addHeadFeedLink = $params->get('genericFeedLink', 1);
|
||||
|
||||
break;
|
||||
|
||||
case 'date' :
|
||||
// Set layout
|
||||
$this->setLayout('generic');
|
||||
|
||||
// Set limit
|
||||
$limit = $params->get('genericItemCount');
|
||||
|
||||
// Fix wrong timezone
|
||||
if (function_exists('date_default_timezone_get'))
|
||||
{
|
||||
$originalTimezone = date_default_timezone_get();
|
||||
}
|
||||
if (function_exists('date_default_timezone_set'))
|
||||
{
|
||||
date_default_timezone_set('UTC');
|
||||
}
|
||||
|
||||
// Set title
|
||||
if (JRequest::getInt('day'))
|
||||
{
|
||||
$date = strtotime(JRequest::getInt('year').'-'.JRequest::getInt('month').'-'.JRequest::getInt('day'));
|
||||
$dateFormat = (K2_JVERSION == '15') ? '%A, %d %B %Y' : 'l, d F Y';
|
||||
$title = JText::_('K2_ITEMS_FILTERED_BY_DATE').' '.JHTML::_('date', $date, $dateFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
$date = strtotime(JRequest::getInt('year').'-'.JRequest::getInt('month'));
|
||||
$dateFormat = (K2_JVERSION == '15') ? '%B %Y' : 'F Y';
|
||||
$title = JText::_('K2_ITEMS_FILTERED_BY_DATE').' '.JHTML::_('date', $date, $dateFormat);
|
||||
}
|
||||
|
||||
// Restore the original timezone
|
||||
if (function_exists('date_default_timezone_set') && isset($originalTimezone))
|
||||
{
|
||||
date_default_timezone_set($originalTimezone);
|
||||
}
|
||||
|
||||
// Set ordering
|
||||
$ordering = 'rdate';
|
||||
|
||||
$addHeadFeedLink = $params->get('genericFeedLink', 1);
|
||||
|
||||
break;
|
||||
|
||||
default :
|
||||
// Set layout
|
||||
$this->setLayout('category');
|
||||
$user = JFactory::getUser();
|
||||
$this->assignRef('user', $user);
|
||||
|
||||
// Set limit
|
||||
$limit = $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items') + $params->get('num_links');
|
||||
// Set featured flag
|
||||
JRequest::setVar('featured', $params->get('catFeaturedItems'));
|
||||
|
||||
// Set title
|
||||
$title = $params->get('page_title');
|
||||
|
||||
// Set ordering
|
||||
$ordering = $params->get('catOrdering');
|
||||
|
||||
$addHeadFeedLink = $params->get('catFeedLink', 1);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Set limit for model
|
||||
if (!$limit)
|
||||
$limit = 10;
|
||||
JRequest::setVar('limit', $limit);
|
||||
|
||||
// Get items
|
||||
if (!isset($ordering))
|
||||
{
|
||||
$items = $model->getData();
|
||||
}
|
||||
else
|
||||
{
|
||||
$items = $model->getData($ordering);
|
||||
}
|
||||
|
||||
// Pagination
|
||||
jimport('joomla.html.pagination');
|
||||
$total = count($items) ? $model->getTotal() : 0;
|
||||
$pagination = new JPagination($total, $limitstart, $limit);
|
||||
|
||||
//Prepare items
|
||||
$user = JFactory::getUser();
|
||||
$cache = JFactory::getCache('com_k2_extended');
|
||||
$model = $this->getModel('item');
|
||||
|
||||
for ($i = 0; $i < sizeof($items); $i++)
|
||||
{
|
||||
|
||||
// Ensure that all items have a group. If an item with no group is found then assign to it the leading group
|
||||
$items[$i]->itemGroup = 'leading';
|
||||
|
||||
//Item group
|
||||
if ($task == "category" || $task == "")
|
||||
{
|
||||
if ($i < ($params->get('num_links') + $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items')))
|
||||
$items[$i]->itemGroup = 'links';
|
||||
if ($i < ($params->get('num_secondary_items') + $params->get('num_leading_items') + $params->get('num_primary_items')))
|
||||
$items[$i]->itemGroup = 'secondary';
|
||||
if ($i < ($params->get('num_primary_items') + $params->get('num_leading_items')))
|
||||
$items[$i]->itemGroup = 'primary';
|
||||
if ($i < $params->get('num_leading_items'))
|
||||
$items[$i]->itemGroup = 'leading';
|
||||
}
|
||||
|
||||
// Check if the model should use the cache for preparing the item even if the user is logged in
|
||||
if ($user->guest || $task == 'tag' || $task == 'search' || $task == 'date')
|
||||
{
|
||||
$cacheFlag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cacheFlag = true;
|
||||
if (K2HelperPermissions::canEditItem($items[$i]->created_by, $items[$i]->catid))
|
||||
{
|
||||
$cacheFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Prepare item
|
||||
if ($cacheFlag)
|
||||
{
|
||||
$hits = $items[$i]->hits;
|
||||
$items[$i]->hits = 0;
|
||||
JTable::getInstance('K2Category', 'Table');
|
||||
$items[$i] = $cache->call(array(
|
||||
$model,
|
||||
'prepareItem'
|
||||
), $items[$i], $view, $task);
|
||||
$items[$i]->hits = $hits;
|
||||
}
|
||||
else
|
||||
{
|
||||
$items[$i] = $model->prepareItem($items[$i], $view, $task);
|
||||
}
|
||||
|
||||
// Plugins
|
||||
$items[$i] = $model->execPlugins($items[$i], $view, $task);
|
||||
|
||||
// Trigger comments counter event
|
||||
$dispatcher = JDispatcher::getInstance();
|
||||
JPluginHelper::importPlugin('k2');
|
||||
$results = $dispatcher->trigger('onK2CommentsCounter', array(
|
||||
&$items[$i],
|
||||
&$params,
|
||||
$limitstart
|
||||
));
|
||||
$items[$i]->event->K2CommentsCounter = trim(implode("\n", $results));
|
||||
}
|
||||
|
||||
// Set title
|
||||
$document = JFactory::getDocument();
|
||||
$application = JFactory::getApplication();
|
||||
$menus = $application->getMenu();
|
||||
$menu = $menus->getActive();
|
||||
if (is_object($menu))
|
||||
{
|
||||
if (is_string($menu->params))
|
||||
{
|
||||
$menu_params = K2_JVERSION == '15' ? new JParameter($menu->params) : new JRegistry($menu->params);
|
||||
}
|
||||
else
|
||||
{
|
||||
$menu_params = $menu->params;
|
||||
}
|
||||
if (!$menu_params->get('page_title'))
|
||||
{
|
||||
$params->set('page_title', $title);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$params->set('page_title', $title);
|
||||
}
|
||||
|
||||
// We're adding a new variable here which won't get the appended/prepended site title,
|
||||
// when enabled via Joomla!'s SEO/SEF settings
|
||||
$params->set('page_title_clean', $title);
|
||||
|
||||
if (K2_JVERSION != '15')
|
||||
{
|
||||
if ($mainframe->getCfg('sitename_pagetitles', 0) == 1)
|
||||
{
|
||||
$tmpTitle = JText::sprintf('JPAGETITLE', $mainframe->getCfg('sitename'), $params->get('page_title'));
|
||||
$params->set('page_title', $tmpTitle);
|
||||
}
|
||||
elseif ($mainframe->getCfg('sitename_pagetitles', 0) == 2)
|
||||
{
|
||||
$tmpTitle = JText::sprintf('JPAGETITLE', $params->get('page_title'), $mainframe->getCfg('sitename'));
|
||||
$params->set('page_title', $tmpTitle);
|
||||
}
|
||||
}
|
||||
$document->setTitle($params->get('page_title'));
|
||||
|
||||
// Search - Update the Google Search results container (K2 v2.6.7+)
|
||||
if ($task == 'search')
|
||||
{
|
||||
$googleSearchContainerID = trim($params->get('googleSearchContainer', 'k2GoogleSearchContainer'));
|
||||
if ($googleSearchContainerID == 'k2Container')
|
||||
{
|
||||
$googleSearchContainerID = 'k2GoogleSearchContainer';
|
||||
}
|
||||
$params->set('googleSearchContainer', $googleSearchContainerID);
|
||||
}
|
||||
|
||||
// Set metadata for category
|
||||
if ($task == 'category')
|
||||
{
|
||||
if ($category->metaDescription)
|
||||
{
|
||||
$document->setDescription($category->metaDescription);
|
||||
}
|
||||
else
|
||||
{
|
||||
$metaDescItem = preg_replace("#{(.*?)}(.*?){/(.*?)}#s", '', $this->category->description);
|
||||
$metaDescItem = strip_tags($metaDescItem);
|
||||
$metaDescItem = K2HelperUtilities::characterLimit($metaDescItem, $params->get('metaDescLimit', 150));
|
||||
if (K2_JVERSION != '15')
|
||||
{
|
||||
$metaDescItem = html_entity_decode($metaDescItem);
|
||||
}
|
||||
$document->setDescription($metaDescItem);
|
||||
}
|
||||
if ($category->metaKeywords)
|
||||
{
|
||||
$document->setMetadata('keywords', $category->metaKeywords);
|
||||
}
|
||||
if ($category->metaRobots)
|
||||
{
|
||||
$document->setMetadata('robots', $category->metaRobots);
|
||||
}
|
||||
if ($category->metaAuthor)
|
||||
{
|
||||
$document->setMetadata('author', $category->metaAuthor);
|
||||
}
|
||||
}
|
||||
|
||||
if (K2_JVERSION != '15')
|
||||
{
|
||||
|
||||
// Menu metadata options
|
||||
if ($params->get('menu-meta_description'))
|
||||
{
|
||||
$document->setDescription($params->get('menu-meta_description'));
|
||||
}
|
||||
|
||||
if ($params->get('menu-meta_keywords'))
|
||||
{
|
||||
$document->setMetadata('keywords', $params->get('menu-meta_keywords'));
|
||||
}
|
||||
|
||||
if ($params->get('robots'))
|
||||
{
|
||||
$document->setMetadata('robots', $params->get('robots'));
|
||||
}
|
||||
|
||||
// Menu page display options
|
||||
if ($params->get('page_heading'))
|
||||
{
|
||||
$params->set('page_title', $params->get('page_heading'));
|
||||
}
|
||||
$params->set('show_page_title', $params->get('show_page_heading'));
|
||||
|
||||
}
|
||||
|
||||
// Pathway
|
||||
$pathway = $mainframe->getPathWay();
|
||||
if (!isset($menu->query['task']))
|
||||
$menu->query['task'] = '';
|
||||
if ($menu)
|
||||
{
|
||||
switch ($task)
|
||||
{
|
||||
case 'category' :
|
||||
if ($menu->query['task'] != 'category' || $menu->query['id'] != JRequest::getInt('id'))
|
||||
$pathway->addItem($title, '');
|
||||
break;
|
||||
case 'user' :
|
||||
if ($menu->query['task'] != 'user' || $menu->query['id'] != JRequest::getInt('id'))
|
||||
$pathway->addItem($title, '');
|
||||
break;
|
||||
|
||||
case 'tag' :
|
||||
if ($menu->query['task'] != 'tag' || $menu->query['tag'] != JRequest::getVar('tag'))
|
||||
$pathway->addItem($title, '');
|
||||
break;
|
||||
|
||||
case 'search' :
|
||||
case 'date' :
|
||||
$pathway->addItem($title, '');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Feed link
|
||||
$config = JFactory::getConfig();
|
||||
$menu = $application->getMenu();
|
||||
$default = $menu->getDefault();
|
||||
$active = $menu->getActive();
|
||||
if ($task == 'tag')
|
||||
{
|
||||
$link = K2HelperRoute::getTagRoute(JRequest::getVar('tag'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$link = '';
|
||||
}
|
||||
$sef = K2_JVERSION == '30' ? $config->get('sef') : $config->getValue('config.sef');
|
||||
if (!is_null($active) && $active->id == $default->id && $sef)
|
||||
{
|
||||
$link .= '&Itemid='.$active->id.'&format=feed&limitstart=';
|
||||
}
|
||||
else
|
||||
{
|
||||
$link .= '&format=feed&limitstart=';
|
||||
}
|
||||
|
||||
$feed = JRoute::_($link);
|
||||
$this->assignRef('feed', $feed);
|
||||
|
||||
// Add head feed link
|
||||
if ($addHeadFeedLink)
|
||||
{
|
||||
$attribs = array(
|
||||
'type' => 'application/rss+xml',
|
||||
'title' => 'RSS 2.0'
|
||||
);
|
||||
$document->addHeadLink(JRoute::_($link.'&type=rss'), 'alternate', 'rel', $attribs);
|
||||
$attribs = array(
|
||||
'type' => 'application/atom+xml',
|
||||
'title' => 'Atom 1.0'
|
||||
);
|
||||
$document->addHeadLink(JRoute::_($link.'&type=atom'), 'alternate', 'rel', $attribs);
|
||||
}
|
||||
|
||||
// Assign data
|
||||
if ($task == "category" || $task == "")
|
||||
{
|
||||
|
||||
// Leading items
|
||||
$offset = 0;
|
||||
$length = $params->get('num_leading_items');
|
||||
$leading = array_slice($items, $offset, $length);
|
||||
|
||||
// Primary
|
||||
$offset = (int)$params->get('num_leading_items');
|
||||
$length = (int)$params->get('num_primary_items');
|
||||
$primary = array_slice($items, $offset, $length);
|
||||
|
||||
// Secondary
|
||||
$offset = (int)($params->get('num_leading_items') + $params->get('num_primary_items'));
|
||||
$length = (int)$params->get('num_secondary_items');
|
||||
$secondary = array_slice($items, $offset, $length);
|
||||
|
||||
// Links
|
||||
$offset = (int)($params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items'));
|
||||
$length = (int)$params->get('num_links');
|
||||
$links = array_slice($items, $offset, $length);
|
||||
|
||||
// Assign data
|
||||
$this->assignRef('leading', $leading);
|
||||
$this->assignRef('primary', $primary);
|
||||
$this->assignRef('secondary', $secondary);
|
||||
$this->assignRef('links', $links);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->assignRef('items', $items);
|
||||
}
|
||||
|
||||
// Set default values to avoid division by zero
|
||||
if ($params->get('num_leading_columns') == 0)
|
||||
$params->set('num_leading_columns', 1);
|
||||
if ($params->get('num_primary_columns') == 0)
|
||||
$params->set('num_primary_columns', 1);
|
||||
if ($params->get('num_secondary_columns') == 0)
|
||||
$params->set('num_secondary_columns', 1);
|
||||
if ($params->get('num_links_columns') == 0)
|
||||
$params->set('num_links_columns', 1);
|
||||
|
||||
$this->assignRef('params', $params);
|
||||
$this->assignRef('pagination', $pagination);
|
||||
|
||||
// Set Facebook meta data
|
||||
$document = JFactory::getDocument();
|
||||
$uri = JURI::getInstance();
|
||||
$document->setMetaData('og:url', $uri->toString());
|
||||
$document->setMetaData('og:title', (K2_JVERSION == '15') ? htmlspecialchars($document->getTitle(), ENT_QUOTES, 'UTF-8') : $document->getTitle());
|
||||
$document->setMetaData('og:type', 'website');
|
||||
if ($task == 'category' && $this->category->image && strpos($this->category->image, 'placeholder/category.png') === false)
|
||||
{
|
||||
$image = substr(JURI::root(), 0, -1).str_replace(JURI::root(true), '', $this->category->image);
|
||||
$document->setMetaData('og:image', $image);
|
||||
$document->setMetaData('image', $image);
|
||||
}
|
||||
$document->setMetaData('og:description', strip_tags($document->getDescription()));
|
||||
|
||||
// Look for template files in component folders
|
||||
$this->_addPath('template', JPATH_COMPONENT.DS.'templates');
|
||||
$this->_addPath('template', JPATH_COMPONENT.DS.'templates'.DS.'default');
|
||||
|
||||
// Look for overrides in template folder (K2 template structure)
|
||||
$this->_addPath('template', JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.'templates');
|
||||
$this->_addPath('template', JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.'templates'.DS.'default');
|
||||
|
||||
// Look for overrides in template folder (Joomla! template structure)
|
||||
$this->_addPath('template', JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.'default');
|
||||
$this->_addPath('template', JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2');
|
||||
|
||||
// Look for specific K2 theme files
|
||||
if ($params->get('theme'))
|
||||
{
|
||||
$this->_addPath('template', JPATH_COMPONENT.DS.'templates'.DS.$params->get('theme'));
|
||||
$this->_addPath('template', JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.'templates'.DS.$params->get('theme'));
|
||||
$this->_addPath('template', JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.$params->get('theme'));
|
||||
}
|
||||
|
||||
$nullDate = $db->getNullDate();
|
||||
$this->assignRef('nullDate', $nullDate);
|
||||
$dispatcher = JDispatcher::getInstance();
|
||||
JPluginHelper::importPlugin('k2');
|
||||
$dispatcher->trigger('onK2BeforeViewDisplay');
|
||||
// Prevent spammers from using the tag view
|
||||
if ($task == 'tag' && !count($this->items))
|
||||
{
|
||||
$tag = JRequest::getString('tag');
|
||||
$db = JFactory::getDBO();
|
||||
$db->setQuery('SELECT id FROM #__k2_tags WHERE name = '.$db->quote($tag));
|
||||
$tagID = $db->loadResult();
|
||||
if (!$tagID)
|
||||
{
|
||||
JError::raiseError(404, JText::_('K2_NOT_FOUND'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
}
|
473
components/com_k2/views/itemlist/view.json.php
Normal file
473
components/com_k2/views/itemlist/view.json.php
Normal file
@ -0,0 +1,473 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: view.json.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
|
||||
* @package K2
|
||||
* @author JoomlaWorks http://www.joomlaworks.net
|
||||
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die ;
|
||||
|
||||
jimport('joomla.application.component.view');
|
||||
|
||||
class K2ViewItemlist extends K2View
|
||||
{
|
||||
|
||||
function display($tpl = null)
|
||||
{
|
||||
|
||||
$mainframe = JFactory::getApplication();
|
||||
$params = K2HelperUtilities::getParams('com_k2');
|
||||
$document = JFactory::getDocument();
|
||||
if (K2_JVERSION == '15')
|
||||
{
|
||||
$document->setMimeEncoding('application/json');
|
||||
$document->setType('json');
|
||||
}
|
||||
$model = $this->getModel('itemlist');
|
||||
|
||||
//Set limit for model
|
||||
$limit = JRequest::getInt('limit');
|
||||
if ($limit > 100 || $limit == 0)
|
||||
{
|
||||
$limit = 100;
|
||||
JRequest::setVar('limit', $limit);
|
||||
}
|
||||
$page = JRequest::getInt('page');
|
||||
if ($page <= 0)
|
||||
{
|
||||
$limitstart = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$page--;
|
||||
$limitstart = $page * $limit;
|
||||
}
|
||||
JRequest::setVar('limitstart', $limitstart);
|
||||
|
||||
$view = JRequest::getWord('view');
|
||||
$task = JRequest::getWord('task');
|
||||
|
||||
$response = new JObject();
|
||||
unset($response->_errors);
|
||||
|
||||
// Site
|
||||
$response->site = new stdClass();
|
||||
$uri = JURI::getInstance();
|
||||
$response->site->url = $uri->toString(array('scheme', 'host', 'port'));
|
||||
$config = JFactory::getConfig();
|
||||
$response->site->name = K2_JVERSION == '30' ? $config->get('sitename') : $config->getValue('config.sitename');
|
||||
|
||||
$moduleID = JRequest::getInt('moduleID');
|
||||
if ($moduleID)
|
||||
{
|
||||
|
||||
$result = $model->getModuleItems($moduleID);
|
||||
$items = $result->items;
|
||||
$title = $result->title;
|
||||
$prefix = 'cat';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//Get data depending on task
|
||||
switch ($task)
|
||||
{
|
||||
|
||||
case 'category' :
|
||||
//Get category
|
||||
$id = JRequest::getInt('id');
|
||||
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
|
||||
$category = JTable::getInstance('K2Category', 'Table');
|
||||
$category->load($id);
|
||||
|
||||
// State Check
|
||||
if (!$category->published || $category->trash)
|
||||
{
|
||||
JError::raiseError(404, JText::_('K2_CATEGORY_NOT_FOUND'));
|
||||
}
|
||||
|
||||
//Access check
|
||||
$user = JFactory::getUser();
|
||||
if (K2_JVERSION != '15')
|
||||
{
|
||||
if (!in_array($category->access, $user->getAuthorisedViewLevels()))
|
||||
{
|
||||
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
|
||||
}
|
||||
$languageFilter = $mainframe->getLanguageFilter();
|
||||
$languageTag = JFactory::getLanguage()->getTag();
|
||||
if ($languageFilter && $category->language != $languageTag && $category->language != '*')
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($category->access > $user->get('aid', 0))
|
||||
{
|
||||
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
|
||||
}
|
||||
}
|
||||
|
||||
//Merge params
|
||||
$cparams = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params);
|
||||
if ($cparams->get('inheritFrom'))
|
||||
{
|
||||
$masterCategory = JTable::getInstance('K2Category', 'Table');
|
||||
$masterCategory->load($cparams->get('inheritFrom'));
|
||||
$cparams = class_exists('JParameter') ? new JParameter($masterCategory->params) : new JRegistry($masterCategory->params);
|
||||
}
|
||||
$params->merge($cparams);
|
||||
|
||||
//Category link
|
||||
$category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id.':'.urlencode($category->alias))));
|
||||
|
||||
//Category image
|
||||
$category->image = K2HelperUtilities::getCategoryImage($category->image, $params);
|
||||
|
||||
//Category plugins
|
||||
$dispatcher = JDispatcher::getInstance();
|
||||
JPluginHelper::importPlugin('content');
|
||||
$category->text = $category->description;
|
||||
|
||||
if (K2_JVERSION != '15')
|
||||
{
|
||||
$dispatcher->trigger('onContentPrepare', array('com_k2.category', &$category, &$params, $limitstart));
|
||||
}
|
||||
else
|
||||
{
|
||||
$dispatcher->trigger('onPrepareContent', array(&$category, &$params, $limitstart));
|
||||
}
|
||||
|
||||
$category->description = $category->text;
|
||||
|
||||
//Category K2 plugins
|
||||
$category->event->K2CategoryDisplay = '';
|
||||
JPluginHelper::importPlugin('k2');
|
||||
$results = $dispatcher->trigger('onK2CategoryDisplay', array(&$category, &$params, $limitstart));
|
||||
$category->event->K2CategoryDisplay = trim(implode("\n", $results));
|
||||
$category->text = $category->description;
|
||||
$dispatcher->trigger('onK2PrepareContent', array(&$category, &$params, $limitstart));
|
||||
$category->description = $category->text;
|
||||
|
||||
//Category children
|
||||
$ordering = $params->get('subCatOrdering');
|
||||
$children = $model->getCategoryFirstChildren($id, $ordering);
|
||||
$subCategories = array();
|
||||
if (count($children))
|
||||
{
|
||||
foreach ($children as $child)
|
||||
{
|
||||
if ($params->get('subCatTitleItemCounter'))
|
||||
{
|
||||
$child->numOfItems = $model->countCategoryItems($child->id);
|
||||
}
|
||||
$child->image = K2HelperUtilities::getCategoryImage($child->image, $params);
|
||||
$child->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($child->id.':'.urlencode($child->alias))));
|
||||
unset($child->params);
|
||||
unset($child->access);
|
||||
unset($child->published);
|
||||
unset($child->trash);
|
||||
unset($child->language);
|
||||
$subCategories[] = $child;
|
||||
}
|
||||
}
|
||||
|
||||
//Set featured flag
|
||||
JRequest::setVar('featured', $params->get('catFeaturedItems'));
|
||||
|
||||
//Set title
|
||||
$title = $category->name;
|
||||
|
||||
// Set ordering
|
||||
if ($params->get('singleCatOrdering'))
|
||||
{
|
||||
$ordering = $params->get('singleCatOrdering');
|
||||
}
|
||||
else
|
||||
{
|
||||
$ordering = $params->get('catOrdering');
|
||||
}
|
||||
|
||||
// Set parameters prefix
|
||||
$prefix = 'cat';
|
||||
// Prepare the JSON category object;
|
||||
$row = new JObject();
|
||||
unset($row->_errors);
|
||||
$row->id = $category->id;
|
||||
$row->name = $category->name;
|
||||
$row->alias = $category->alias;
|
||||
$row->link = $category->link;
|
||||
$row->parent = $category->parent;
|
||||
$row->extraFieldsGroup = $category->extraFieldsGroup;
|
||||
$row->image = $category->image;
|
||||
$row->ordering = $category->ordering;
|
||||
//$row->plugins = $category->plugins;
|
||||
$row->events = $category->event;
|
||||
$row->chidlren = $subCategories;
|
||||
$response->category = $row;
|
||||
break;
|
||||
|
||||
case 'user' :
|
||||
//Get user
|
||||
$id = JRequest::getInt('id');
|
||||
$userObject = JFactory::getUser($id);
|
||||
|
||||
//Check user status
|
||||
if ($userObject->block)
|
||||
{
|
||||
JError::raiseError(404, JText::_('K2_USER_NOT_FOUND'));
|
||||
}
|
||||
|
||||
//Get K2 user profile
|
||||
$userObject->profile = $model->getUserProfile();
|
||||
|
||||
//User image
|
||||
$userObject->avatar = K2HelperUtilities::getAvatar($userObject->id, $userObject->email, $params->get('userImageWidth'));
|
||||
|
||||
//User K2 plugins
|
||||
$userObject->event->K2UserDisplay = '';
|
||||
if (is_object($userObject->profile) && $userObject->profile->id > 0)
|
||||
{
|
||||
$dispatcher = JDispatcher::getInstance();
|
||||
JPluginHelper::importPlugin('k2');
|
||||
$results = $dispatcher->trigger('onK2UserDisplay', array(&$userObject->profile, &$params, $limitstart));
|
||||
$userObject->event->K2UserDisplay = trim(implode("\n", $results));
|
||||
$userObject->profile->url = htmlspecialchars($userObject->profile->url, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
}
|
||||
|
||||
//Set title
|
||||
$title = $userObject->name;
|
||||
|
||||
// Set ordering
|
||||
$ordering = $params->get('userOrdering');
|
||||
|
||||
// Set parameters prefix
|
||||
$prefix = 'user';
|
||||
// Prepare the JSON user object;
|
||||
$row = new JObject();
|
||||
unset($row->_errors);
|
||||
//$row->id = $userObject->id;
|
||||
$row->name = $userObject->name;
|
||||
//$row->username = $userObject->username;
|
||||
if (isset($userObject->profile->plugins))
|
||||
{
|
||||
unset($userObject->profile->plugins);
|
||||
}
|
||||
$row->profile = $userObject->profile;
|
||||
$row->avatar = $userObject->avatar;
|
||||
$row->events = $userObject->event;
|
||||
$response->user = $row;
|
||||
break;
|
||||
|
||||
case 'tag' :
|
||||
//Set limit
|
||||
$limit = $params->get('tagItemCount');
|
||||
|
||||
//set title
|
||||
$title = JText::_('K2_DISPLAYING_ITEMS_BY_TAG').' '.JRequest::getVar('tag');
|
||||
|
||||
// Set ordering
|
||||
$ordering = $params->get('tagOrdering');
|
||||
|
||||
// Set parameters prefix
|
||||
$prefix = 'tag';
|
||||
$response->tag = JRequest::getVar('tag');
|
||||
break;
|
||||
|
||||
case 'search' :
|
||||
|
||||
//Set title
|
||||
$title = JText::_('K2_SEARCH_RESULTS_FOR').' '.JRequest::getVar('searchword');
|
||||
|
||||
// Set parameters prefix
|
||||
$prefix = 'generic';
|
||||
$response->search = JRequest::getVar('searchword');
|
||||
break;
|
||||
|
||||
case 'date' :
|
||||
|
||||
// Set title
|
||||
if (JRequest::getInt('day'))
|
||||
{
|
||||
$date = strtotime(JRequest::getInt('year').'-'.JRequest::getInt('month').'-'.JRequest::getInt('day'));
|
||||
$dateFormat = (K2_JVERSION == '15') ? '%A, %d %B %Y' : 'l, d F Y';
|
||||
$title = JText::_('K2_ITEMS_FILTERED_BY_DATE').' '.JHTML::_('date', $date, $dateFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
$date = strtotime(JRequest::getInt('year').'-'.JRequest::getInt('month'));
|
||||
$dateFormat = (K2_JVERSION == '15') ? '%B %Y' : 'F Y';
|
||||
$title = JText::_('K2_ITEMS_FILTERED_BY_DATE').' '.JHTML::_('date', $date, $dateFormat);
|
||||
}
|
||||
// Set ordering
|
||||
$ordering = 'rdate';
|
||||
|
||||
// Set parameters prefix
|
||||
$prefix = 'generic';
|
||||
$response->date = JHTML::_('date', $date, $dateFormat);
|
||||
break;
|
||||
|
||||
default :
|
||||
$user = JFactory::getUser();
|
||||
|
||||
//Set limit
|
||||
$limit = $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items') + $params->get('num_links');
|
||||
//Set featured flag
|
||||
JRequest::setVar('featured', $params->get('catFeaturedItems'));
|
||||
|
||||
//Set title
|
||||
$title = $params->get('page_title');
|
||||
|
||||
// Set ordering
|
||||
$ordering = $params->get('catOrdering');
|
||||
|
||||
// Set parameters prefix
|
||||
$prefix = 'cat';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isset($ordering))
|
||||
{
|
||||
$items = $model->getData();
|
||||
}
|
||||
else
|
||||
{
|
||||
$items = $model->getData($ordering);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Prepare items
|
||||
$user = JFactory::getUser();
|
||||
$cache = JFactory::getCache('com_k2_extended');
|
||||
$model = $this->getModel('item');
|
||||
$rows = array();
|
||||
for ($i = 0; $i < sizeof($items); $i++)
|
||||
{
|
||||
|
||||
//Item group
|
||||
if ($task == "category" || $task == "")
|
||||
{
|
||||
$items[$i]->itemGroup = 'links';
|
||||
|
||||
if ($i < ($params->get('num_links') + $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items')))
|
||||
$items[$i]->itemGroup = 'links';
|
||||
if ($i < ($params->get('num_secondary_items') + $params->get('num_leading_items') + $params->get('num_primary_items')))
|
||||
$items[$i]->itemGroup = 'secondary';
|
||||
if ($i < ($params->get('num_primary_items') + $params->get('num_leading_items')))
|
||||
$items[$i]->itemGroup = 'primary';
|
||||
if ($i < $params->get('num_leading_items'))
|
||||
$items[$i]->itemGroup = 'leading';
|
||||
}
|
||||
else
|
||||
{
|
||||
$items[$i]->itemGroup = '';
|
||||
}
|
||||
|
||||
$itemParams = class_exists('JParameter') ? new JParameter($items[$i]->params) : new JRegistry($items[$i]->params);
|
||||
$itemParams->set($prefix.'ItemIntroText', true);
|
||||
$itemParams->set($prefix.'ItemFullText', true);
|
||||
$itemParams->set($prefix.'ItemTags', true);
|
||||
$itemParams->set($prefix.'ItemExtraFields', true);
|
||||
$itemParams->set($prefix.'ItemAttachments', true);
|
||||
$itemParams->set($prefix.'ItemRating', true);
|
||||
$itemParams->set($prefix.'ItemAuthor', true);
|
||||
$itemParams->set($prefix.'ItemImageGallery', true);
|
||||
$itemParams->set($prefix.'ItemVideo', true);
|
||||
$itemParams->set($prefix.'ItemImage', true);
|
||||
$items[$i]->params = $itemParams->toString();
|
||||
|
||||
//Check if model should use cache for preparing item even if user is logged in
|
||||
if ($user->guest || $task == 'tag' || $task == 'search' || $task == 'date')
|
||||
{
|
||||
$cacheFlag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cacheFlag = true;
|
||||
if (K2HelperPermissions::canEditItem($items[$i]->created_by, $items[$i]->catid))
|
||||
{
|
||||
$cacheFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Prepare item
|
||||
if ($cacheFlag)
|
||||
{
|
||||
$hits = $items[$i]->hits;
|
||||
$items[$i]->hits = 0;
|
||||
JTable::getInstance('K2Category', 'Table');
|
||||
$items[$i] = $cache->call(array($model, 'prepareItem'), $items[$i], $view, $task);
|
||||
$items[$i]->hits = $hits;
|
||||
}
|
||||
else
|
||||
{
|
||||
$items[$i] = $model->prepareItem($items[$i], $view, $task);
|
||||
}
|
||||
|
||||
//Plugins
|
||||
$items[$i] = $model->execPlugins($items[$i], $view, $task);
|
||||
|
||||
//Trigger comments counter event
|
||||
$dispatcher = JDispatcher::getInstance();
|
||||
JPluginHelper::importPlugin('k2');
|
||||
$results = $dispatcher->trigger('onK2CommentsCounter', array(&$items[$i], &$params, $limitstart));
|
||||
$items[$i]->event->K2CommentsCounter = trim(implode("\n", $results));
|
||||
|
||||
// Set default image
|
||||
if ($task == 'user' || $task == 'tag' || $task == 'search' || $task == 'date')
|
||||
{
|
||||
$items[$i]->image = (isset($items[$i]->imageGeneric)) ? $items[$i]->imageGeneric : '';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$moduleID)
|
||||
{
|
||||
K2HelperUtilities::setDefaultImage($items[$i], $view, $params);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$rows[] = $model->prepareJSONItem($items[$i]);
|
||||
|
||||
}
|
||||
|
||||
$response->items = $rows;
|
||||
|
||||
// Prevent spammers from using the tag view
|
||||
if ($task == 'tag' && !count($response->items))
|
||||
{
|
||||
$tag = JRequest::getString('tag');
|
||||
$db = JFactory::getDBO();
|
||||
$db->setQuery('SELECT id FROM #__k2_tags WHERE name = '.$db->quote($tag));
|
||||
$tagID = $db->loadResult();
|
||||
if (!$tagID)
|
||||
{
|
||||
JError::raiseError(404, JText::_('K2_NOT_FOUND'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Output
|
||||
$json = json_encode($response);
|
||||
$callback = JRequest::getCmd('callback');
|
||||
if ($callback)
|
||||
{
|
||||
$document->setMimeEncoding('application/javascript');
|
||||
echo $callback.'('.$json.')';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $json;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
506
components/com_k2/views/itemlist/view.raw.php
Normal file
506
components/com_k2/views/itemlist/view.raw.php
Normal file
@ -0,0 +1,506 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: view.raw.php 1827 2013-01-25 12:01:41Z lefteris.kavadas $
|
||||
* @package K2
|
||||
* @author JoomlaWorks http://www.joomlaworks.net
|
||||
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die ;
|
||||
|
||||
jimport('joomla.application.component.view');
|
||||
|
||||
class K2ViewItemlist extends K2View
|
||||
{
|
||||
|
||||
function display($tpl = null)
|
||||
{
|
||||
|
||||
$mainframe = JFactory::getApplication();
|
||||
$params = K2HelperUtilities::getParams('com_k2');
|
||||
$model = $this->getModel('itemlist');
|
||||
$limitstart = JRequest::getInt('limitstart');
|
||||
$view = JRequest::getWord('view');
|
||||
$task = JRequest::getWord('task');
|
||||
|
||||
//Add link
|
||||
if (K2HelperPermissions::canAddItem())
|
||||
$addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component');
|
||||
$this->assignRef('addLink', $addLink);
|
||||
|
||||
//Get data depending on task
|
||||
switch ($task)
|
||||
{
|
||||
|
||||
case 'category' :
|
||||
//Get category
|
||||
$id = JRequest::getInt('id');
|
||||
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
|
||||
$category = JTable::getInstance('K2Category', 'Table');
|
||||
$category->load($id);
|
||||
|
||||
// State Check
|
||||
if (!$category->published || $category->trash)
|
||||
{
|
||||
JError::raiseError(404, JText::_('K2_CATEGORY_NOT_FOUND'));
|
||||
}
|
||||
|
||||
//Access check
|
||||
$user = JFactory::getUser();
|
||||
if (K2_JVERSION != '15')
|
||||
{
|
||||
if (!in_array($category->access, $user->getAuthorisedViewLevels()))
|
||||
{
|
||||
if ($user->guest)
|
||||
{
|
||||
$uri = JFactory::getURI();
|
||||
$url = 'index.php?option=com_user&view=login&return='.base64_encode($uri->toString());
|
||||
$mainframe->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'));
|
||||
}
|
||||
else
|
||||
{
|
||||
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
$languageFilter = $mainframe->getLanguageFilter();
|
||||
$languageTag = JFactory::getLanguage()->getTag();
|
||||
if ($languageFilter && $category->language != $languageTag && $category->language != '*')
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($category->access > $user->get('aid', 0))
|
||||
{
|
||||
if ($user->guest)
|
||||
{
|
||||
$uri = JFactory::getURI();
|
||||
$url = 'index.php?option=com_user&view=login&return='.base64_encode($uri->toString());
|
||||
$mainframe->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'));
|
||||
}
|
||||
else
|
||||
{
|
||||
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hide the add new item link if user cannot post in the specific category
|
||||
if (!K2HelperPermissions::canAddItem($id))
|
||||
{
|
||||
unset($this->addLink);
|
||||
}
|
||||
|
||||
//Merge params
|
||||
$cparams = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params);
|
||||
if ($cparams->get('inheritFrom'))
|
||||
{
|
||||
$masterCategory = JTable::getInstance('K2Category', 'Table');
|
||||
$masterCategory->load($cparams->get('inheritFrom'));
|
||||
$cparams = class_exists('JParameter') ? new JParameter($masterCategory->params) : new JRegistry($masterCategory->params);
|
||||
}
|
||||
$params->merge($cparams);
|
||||
|
||||
//Category link
|
||||
$category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id.':'.urlencode($category->alias))));
|
||||
|
||||
//Category image
|
||||
$category->image = K2HelperUtilities::getCategoryImage($category->image, $params);
|
||||
|
||||
//Category plugins
|
||||
$dispatcher = JDispatcher::getInstance();
|
||||
JPluginHelper::importPlugin('content');
|
||||
$category->text = $category->description;
|
||||
|
||||
if (K2_JVERSION != '15')
|
||||
{
|
||||
$dispatcher->trigger('onContentPrepare', array('com_k2.category', &$category, &$params, $limitstart));
|
||||
}
|
||||
else
|
||||
{
|
||||
$dispatcher->trigger('onPrepareContent', array(&$category, &$params, $limitstart));
|
||||
}
|
||||
|
||||
$category->description = $category->text;
|
||||
|
||||
//Category K2 plugins
|
||||
$category->event->K2CategoryDisplay = '';
|
||||
JPluginHelper::importPlugin('k2');
|
||||
$results = $dispatcher->trigger('onK2CategoryDisplay', array(&$category, &$params, $limitstart));
|
||||
$category->event->K2CategoryDisplay = trim(implode("\n", $results));
|
||||
$category->text = $category->description;
|
||||
$dispatcher->trigger('onK2PrepareContent', array(&$category, &$params, $limitstart));
|
||||
$category->description = $category->text;
|
||||
|
||||
$this->assignRef('category', $category);
|
||||
$this->assignRef('user', $user);
|
||||
|
||||
//Category children
|
||||
$ordering = $params->get('subCatOrdering');
|
||||
$children = $model->getCategoryFirstChildren($id, $ordering);
|
||||
if (count($children))
|
||||
{
|
||||
foreach ($children as $child)
|
||||
{
|
||||
if ($params->get('subCatTitleItemCounter'))
|
||||
{
|
||||
$child->numOfItems = $model->countCategoryItems($child->id);
|
||||
}
|
||||
$child->image = K2HelperUtilities::getCategoryImage($child->image, $params);
|
||||
$child->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($child->id.':'.urlencode($child->alias))));
|
||||
$subCategories[] = $child;
|
||||
}
|
||||
$this->assignRef('subCategories', $subCategories);
|
||||
}
|
||||
|
||||
//Set limit
|
||||
$limit = $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items') + $params->get('num_links');
|
||||
|
||||
//Set featured flag
|
||||
JRequest::setVar('featured', $params->get('catFeaturedItems'));
|
||||
|
||||
//Set layout
|
||||
$this->setLayout('category');
|
||||
|
||||
//Set title
|
||||
$title = $category->name;
|
||||
|
||||
// Set ordering
|
||||
if ($params->get('singleCatOrdering'))
|
||||
{
|
||||
$ordering = $params->get('singleCatOrdering');
|
||||
}
|
||||
else
|
||||
{
|
||||
$ordering = $params->get('catOrdering');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'user' :
|
||||
//Get user
|
||||
$id = JRequest::getInt('id');
|
||||
$userObject = JFactory::getUser($id);
|
||||
|
||||
//Check user status
|
||||
if ($userObject->block)
|
||||
{
|
||||
JError::raiseError(404, JText::_('K2_USER_NOT_FOUND'));
|
||||
}
|
||||
|
||||
//Get K2 user profile
|
||||
$userObject->profile = $model->getUserProfile();
|
||||
|
||||
//User image
|
||||
$userObject->avatar = K2HelperUtilities::getAvatar($userObject->id, $userObject->email, $params->get('userImageWidth'));
|
||||
|
||||
//User K2 plugins
|
||||
$userObject->event->K2UserDisplay = '';
|
||||
if (is_object($userObject->profile) && $userObject->profile->id > 0)
|
||||
{
|
||||
|
||||
$dispatcher = JDispatcher::getInstance();
|
||||
JPluginHelper::importPlugin('k2');
|
||||
$results = $dispatcher->trigger('onK2UserDisplay', array(&$userObject->profile, &$params, $limitstart));
|
||||
$userObject->event->K2UserDisplay = trim(implode("\n", $results));
|
||||
$userObject->profile->url = htmlspecialchars($userObject->profile->url, ENT_QUOTES, 'UTF-8');
|
||||
|
||||
}
|
||||
|
||||
$this->assignRef('user', $userObject);
|
||||
|
||||
//Set layout
|
||||
$this->setLayout('user');
|
||||
|
||||
//Set limit
|
||||
$limit = $params->get('userItemCount');
|
||||
|
||||
//Set title
|
||||
$title = $userObject->name;
|
||||
|
||||
// Set ordering
|
||||
$ordering = $params->get('userOrdering');
|
||||
|
||||
break;
|
||||
|
||||
case 'tag' :
|
||||
//Set layout
|
||||
$this->setLayout('tag');
|
||||
|
||||
//Set limit
|
||||
$limit = $params->get('tagItemCount');
|
||||
|
||||
//set title
|
||||
$title = JText::_('K2_DISPLAYING_ITEMS_BY_TAG').' '.JRequest::getVar('tag');
|
||||
|
||||
// Set ordering
|
||||
$ordering = $params->get('tagOrdering');
|
||||
break;
|
||||
|
||||
case 'search' :
|
||||
//Set layout
|
||||
$this->setLayout('generic');
|
||||
$tpl = JRequest::getCmd('tpl', null);
|
||||
|
||||
//Set limit
|
||||
$limit = $params->get('genericItemCount');
|
||||
|
||||
//Set title
|
||||
$title = JText::_('K2_SEARCH_RESULTS_FOR').' '.JRequest::getVar('searchword');
|
||||
break;
|
||||
|
||||
case 'date' :
|
||||
//Set layout
|
||||
$this->setLayout('generic');
|
||||
|
||||
//Set limit
|
||||
$limit = $params->get('genericItemCount');
|
||||
|
||||
// Set title
|
||||
if (JRequest::getInt('day'))
|
||||
{
|
||||
$date = strtotime(JRequest::getInt('year').'-'.JRequest::getInt('month').'-'.JRequest::getInt('day'));
|
||||
$dateFormat = (K2_JVERSION == '15') ? '%A, %d %B %Y' : 'l, d F Y';
|
||||
$title = JText::_('K2_ITEMS_FILTERED_BY_DATE').' '.JHTML::_('date', $date, $dateFormat);
|
||||
}
|
||||
else
|
||||
{
|
||||
$date = strtotime(JRequest::getInt('year').'-'.JRequest::getInt('month'));
|
||||
$dateFormat = (K2_JVERSION == '15') ? '%B %Y' : 'F Y';
|
||||
$title = JText::_('K2_ITEMS_FILTERED_BY_DATE').' '.JHTML::_('date', $date, $dateFormat);
|
||||
}
|
||||
// Set ordering
|
||||
$ordering = 'rdate';
|
||||
break;
|
||||
|
||||
default :
|
||||
//Set layout
|
||||
$this->setLayout('category');
|
||||
$user = JFactory::getUser();
|
||||
$this->assignRef('user', $user);
|
||||
|
||||
//Set limit
|
||||
$limit = $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items') + $params->get('num_links');
|
||||
//Set featured flag
|
||||
JRequest::setVar('featured', $params->get('catFeaturedItems'));
|
||||
|
||||
//Set title
|
||||
$title = $params->get('page_title');
|
||||
|
||||
// Set ordering
|
||||
$ordering = $params->get('catOrdering');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
//Set limit for model
|
||||
JRequest::setVar('limit', $limit);
|
||||
|
||||
if (!isset($ordering))
|
||||
{
|
||||
$items = $model->getData();
|
||||
}
|
||||
else
|
||||
{
|
||||
$items = $model->getData($ordering);
|
||||
}
|
||||
|
||||
//Pagination
|
||||
jimport('joomla.html.pagination');
|
||||
$total = count($items) ? $model->getTotal() : 0;
|
||||
$pagination = new JPagination($total, $limitstart, $limit);
|
||||
|
||||
//Prepare items
|
||||
$user = JFactory::getUser();
|
||||
$cache = JFactory::getCache('com_k2_extended');
|
||||
$model = $this->getModel('item');
|
||||
for ($i = 0; $i < sizeof($items); $i++)
|
||||
{
|
||||
|
||||
//Item group
|
||||
if ($task == "category" || $task == "")
|
||||
{
|
||||
if ($i < ($params->get('num_links') + $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items')))
|
||||
$items[$i]->itemGroup = 'links';
|
||||
if ($i < ($params->get('num_secondary_items') + $params->get('num_leading_items') + $params->get('num_primary_items')))
|
||||
$items[$i]->itemGroup = 'secondary';
|
||||
if ($i < ($params->get('num_primary_items') + $params->get('num_leading_items')))
|
||||
$items[$i]->itemGroup = 'primary';
|
||||
if ($i < $params->get('num_leading_items'))
|
||||
$items[$i]->itemGroup = 'leading';
|
||||
}
|
||||
|
||||
//Check if model should use cache for preparing item even if user is logged in
|
||||
if ($user->guest || $task == 'tag' || $task == 'search' || $task == 'date')
|
||||
{
|
||||
$cacheFlag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cacheFlag = true;
|
||||
if (K2HelperPermissions::canEditItem($items[$i]->created_by, $items[$i]->catid))
|
||||
{
|
||||
$cacheFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Prepare item
|
||||
if ($cacheFlag)
|
||||
{
|
||||
$hits = $items[$i]->hits;
|
||||
$items[$i]->hits = 0;
|
||||
JTable::getInstance('K2Category', 'Table');
|
||||
$items[$i] = $cache->call(array($model, 'prepareItem'), $items[$i], $view, $task);
|
||||
$items[$i]->hits = $hits;
|
||||
}
|
||||
else
|
||||
{
|
||||
$items[$i] = $model->prepareItem($items[$i], $view, $task);
|
||||
}
|
||||
|
||||
//Plugins
|
||||
$items[$i] = $model->execPlugins($items[$i], $view, $task);
|
||||
|
||||
//Trigger comments counter event
|
||||
$dispatcher = JDispatcher::getInstance();
|
||||
JPluginHelper::importPlugin('k2');
|
||||
$results = $dispatcher->trigger('onK2CommentsCounter', array(&$items[$i], &$params, $limitstart));
|
||||
$items[$i]->event->K2CommentsCounter = trim(implode("\n", $results));
|
||||
|
||||
}
|
||||
|
||||
//Pathway
|
||||
$pathway = $mainframe->getPathWay();
|
||||
$pathway->addItem($title);
|
||||
|
||||
//Feed link
|
||||
$config = JFactory::getConfig();
|
||||
$menu = $mainframe->getMenu();
|
||||
$default = $menu->getDefault();
|
||||
$active = $menu->getActive();
|
||||
if ($task == 'tag')
|
||||
{
|
||||
$link = K2HelperRoute::getTagRoute(JRequest::getVar('tag'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$link = '';
|
||||
}
|
||||
$sef = K2_JVERSION == '30' ? $config->get('sef') : $config->getValue('config.sef');
|
||||
if (!is_null($active) && $active->id == $default->id && $sef)
|
||||
{
|
||||
$link .= '&Itemid='.$active->id.'&format=feed&limitstart=';
|
||||
}
|
||||
else
|
||||
{
|
||||
$link .= '&format=feed&limitstart=';
|
||||
}
|
||||
|
||||
$feed = JRoute::_($link);
|
||||
$this->assignRef('feed', $feed);
|
||||
|
||||
//Assign data
|
||||
if ($task == "category" || $task == "")
|
||||
{
|
||||
$leading = @array_slice($items, 0, $params->get('num_leading_items'));
|
||||
$primary = @array_slice($items, $params->get('num_leading_items'), $params->get('num_primary_items'));
|
||||
$secondary = @array_slice($items, $params->get('num_leading_items') + $params->get('num_primary_items'), $params->get('num_secondary_items'));
|
||||
$links = @array_slice($items, $params->get('num_leading_items') + $params->get('num_primary_items') + $params->get('num_secondary_items'), $params->get('num_links'));
|
||||
$this->assignRef('leading', $leading);
|
||||
$this->assignRef('primary', $primary);
|
||||
$this->assignRef('secondary', $secondary);
|
||||
$this->assignRef('links', $links);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->assignRef('items', $items);
|
||||
}
|
||||
|
||||
//Set default values to avoid division by zero
|
||||
if ($params->get('num_leading_columns') == 0)
|
||||
$params->set('num_leading_columns', 1);
|
||||
if ($params->get('num_primary_columns') == 0)
|
||||
$params->set('num_primary_columns', 1);
|
||||
if ($params->get('num_secondary_columns') == 0)
|
||||
$params->set('num_secondary_columns', 1);
|
||||
if ($params->get('num_links_columns') == 0)
|
||||
$params->set('num_links_columns', 1);
|
||||
|
||||
$this->assignRef('params', $params);
|
||||
$this->assignRef('pagination', $pagination);
|
||||
|
||||
//Look for template files in component folders
|
||||
$this->_addPath('template', JPATH_COMPONENT.DS.'templates');
|
||||
$this->_addPath('template', JPATH_COMPONENT.DS.'templates'.DS.'default');
|
||||
|
||||
//Look for overrides in template folder (K2 template structure)
|
||||
$this->_addPath('template', JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.'templates');
|
||||
$this->_addPath('template', JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.'templates'.DS.'default');
|
||||
|
||||
//Look for overrides in template folder (Joomla! template structure)
|
||||
$this->_addPath('template', JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.'default');
|
||||
$this->_addPath('template', JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2');
|
||||
|
||||
//Look for specific K2 theme files
|
||||
if ($params->get('theme'))
|
||||
{
|
||||
$this->_addPath('template', JPATH_COMPONENT.DS.'templates'.DS.$params->get('theme'));
|
||||
$this->_addPath('template', JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.'templates'.DS.$params->get('theme'));
|
||||
$this->_addPath('template', JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.$params->get('theme'));
|
||||
}
|
||||
|
||||
$db = JFactory::getDBO();
|
||||
$nullDate = $db->getNullDate();
|
||||
$this->assignRef('nullDate', $nullDate);
|
||||
|
||||
// Prevent spammers from using the tag view
|
||||
if ($task == 'tag' && !count($this->items))
|
||||
{
|
||||
$tag = JRequest::getString('tag');
|
||||
$db = JFactory::getDBO();
|
||||
$db->setQuery('SELECT id FROM #__k2_tags WHERE name = '.$db->quote($tag));
|
||||
$tagID = $db->loadResult();
|
||||
if (!$tagID)
|
||||
{
|
||||
JError::raiseError(404, JText::_('K2_NOT_FOUND'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
function module()
|
||||
{
|
||||
jimport('joomla.application.module.helper');
|
||||
$mainframe = JFactory::getApplication();
|
||||
$moduleID = JRequest::getInt('moduleID');
|
||||
$model = K2Model::getInstance('Itemlist', 'K2Model');
|
||||
if ($moduleID)
|
||||
{
|
||||
$result = $model->getModuleItems($moduleID);
|
||||
$items = $result->items;
|
||||
$componentParams = JComponentHelper::getParams('com_k2');
|
||||
if (is_string($result->params))
|
||||
{
|
||||
$params = class_exists('JParameter') ? new JParameter($result->params) : new JRegistry($result->params);
|
||||
}
|
||||
else
|
||||
{
|
||||
$params = $result->params;
|
||||
}
|
||||
|
||||
if ($params->get('getTemplate'))
|
||||
require (JModuleHelper::getLayoutPath('mod_k2_content', $params->get('getTemplate').DS.'default'));
|
||||
else
|
||||
require (JModuleHelper::getLayoutPath($result->module, 'default'));
|
||||
}
|
||||
$mainframe->close();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user