Skip to content

Commit

Permalink
[#30453] Tags: Pagination not working when linking to a tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
dextercowley committed Apr 6, 2013
1 parent dba18d1 commit 7d119bc
Show file tree
Hide file tree
Showing 19 changed files with 1,111 additions and 579 deletions.
332 changes: 240 additions & 92 deletions administrator/components/com_tags/config.xml

Large diffs are not rendered by default.

321 changes: 187 additions & 134 deletions administrator/components/com_tags/models/forms/tag.xml

Large diffs are not rendered by default.

62 changes: 40 additions & 22 deletions administrator/language/en-GB/en-GB.com_tags.ini
Expand Up @@ -5,9 +5,10 @@

COM_TAGS="Tags"
COM_TAGS_ALL="All"
COM_TAGS_ALL_TAGS_DESCRIPTION_DESC="Description to display at top of tags list"
COM_TAGS_ALL_TAGS_MEDIA_DESC="The image to display at the top of the tags list"
COM_TAGS_ALL_TAGS_MEDIA_LABEL="Tags Image"
COM_TAGS_ALL_TAGS_DESCRIPTION_DESC="Description to display at the heading of tags list"
COM_TAGS_ALL_TAGS_DESCRIPTION_LABEL="Heading Description"
COM_TAGS_ALL_TAGS_MEDIA_DESC="The image to display in the heading of the tags list"
COM_TAGS_ALL_TAGS_MEDIA_LABEL="Heading Image File"
COM_TAGS_ANY="Any"
COM_TAGS_BASE_ADD_TITLE="Tag Manager: Add New Tag"
COM_TAGS_BASE_EDIT_TITLE="Tag Manager: Edit Tag"
Expand All @@ -17,10 +18,22 @@ COM_TAGS_BATCH_CANNOT_EDIT="You are not allowed to edit tags."
COM_TAGS_BATCH_OPTIONS="Batch process the selected tags"
COM_TAGS_BATCH_TIP="Actions will apply to chosen Tags."
COM_TAGS_COMPACT_COLUMNS_LABEL="Number of columns"
COM_TAGS_CONFIG_ALL_TAGS_SETTINGS_DESC="Global settings for the Tags List layout"
COM_TAGS_CONFIG_ALL_TAGS_SETTINGS_LABEL="Tags list"
COM_TAGS_CONFIG_TAG_SETTINGS_DESC="Configuration Settings"
COM_TAGS_CONFIG_TAG_SETTINGS_LABEL="General Settings"
COM_TAGS_CONFIG_ALL_TAGS_FIELD_LAYOUT_DESC="Choose a default layout for List of all tags."
COM_TAGS_CONFIG_ALL_TAGS_FIELD_LAYOUT_LABEL="Default List All Tags Layout"
COM_TAGS_CONFIG_ALL_TAGS_SETTINGS_DESC="These settings apply for a List of all Tags unless they are changed for a specific menu item."
COM_TAGS_CONFIG_ALL_TAGS_SETTINGS_LABEL="List All Tags Options"
COM_TAGS_CONFIG_DATA_ENTRY_SETTINGS_DESC="These settings control the way tags are entered."
COM_TAGS_CONFIG_DATA_ENTRY_SETTINGS_LABEL="Data Entry Options"
COM_TAGS_CONFIG_INTEGRATION_SETTINGS_DESC="These settings determine how the Tags Component will integrate with other extensions."
COM_TAGS_CONFIG_NUMBER_OF_ITEMS="Number of Items Tagged"
COM_TAGS_CONFIG_SELECTION_SETTINGS_DESC="These settings control which items get selected in the Tagged Items list layouts."
COM_TAGS_CONFIG_SELECTION_SETTINGS_LABEL="Item Selection Options"
COM_TAGS_CONFIG_SHARED_SETTINGS_DESC="These settings apply to all tag layouts unless they are changed for a specific menu item."
COM_TAGS_CONFIG_SHARED_SETTINGS_LABEL="Shared Layout Options"
COM_TAGS_CONFIG_TAG_SETTINGS_DESC="These settings apply for a Tagged Items List or Compact List of Tagged Items unless they are changed for a specific menu item."
COM_TAGS_CONFIG_TAG_SETTINGS_LABEL="Tagged Items Options"
COM_TAGS_CONFIG_TAGGED_ITEMS_FIELD_LAYOUT_DESC="Choose a default layout for tagged items. This layout will be used when a user clicks on a tag that doesn't have a menu item defined."
COM_TAGS_CONFIG_TAGGED_ITEMS_FIELD_LAYOUT_LABEL="Default Tagged Items Layout"
COM_TAGS_CONFIGURATION="Tags Configuration"
COM_TAGS_DELETE_NOT_ALLOWED="Delete not allowed for tag %s. "
COM_TAGS_DESCRIPTION_DESC="Enter an optional tag description in the text-area."
Expand All @@ -46,7 +59,7 @@ COM_TAGS_FIELD_INTRO_LABEL="Teaser image"
COM_TAGS_FIELD_ITEM_BODY_DESC="Show the body for each item."
COM_TAGS_FIELD_LANGUAGE_DESC="Assign a language to this tag."
COM_TAGS_FIELD_LANGUAGE_FILTER_DESC="Optionally filter the list of tags based on language"
COM_TAGS_FIELD_LANGUAGE_FILTER_LABEL="Language filter"
COM_TAGS_FIELD_LANGUAGE_FILTER_LABEL="Language Filter"
COM_TAGS_FIELD_PARENT_DESC="Select a Parent tag"
COM_TAGS_FIELD_PARENT_LABEL="Parent"
COM_TAGS_FIELD_PARENT_TAG_DESC="If set only tags that are direct children of the selected tag will be displayed."
Expand All @@ -70,16 +83,19 @@ COM_TAGS_HAS_SUBCATEGORY_ITEMS="%d items are assigned to this tag's subtags."
COM_TAGS_HAS_SUBCATEGORY_ITEMS_1="%d item is assigned to one of this tag's subtags."
COM_TAGS_INCLUDE="Include"
COM_TAGS_INCLUDE_CHILDREN_DESC="Include or exclude child tags from the result list for a tag"
COM_TAGS_INCLUDE_CHILDREN_LABEL="Child tags"
COM_TAGS_INCLUDE_CHILDREN_LABEL="Child Tags"
COM_TAGS_ITEM_ASSOCIATIONS_FIELDSET_DESC="Multilanguage only! This choice will only display if the Language Filter parameter 'Item Associations' is set to 'Yes'. Choose a category item for the target language. This association will let the Language Switcher module redirect to the associated category item in another language. If used, make sure to display the Language switcher module on the concerned pages. A category item set to language 'All' can't be associated."
COM_TAGS_ITEM_ASSOCIATIONS_FIELDSET_LABEL="Tag Item Associations"
COM_TAGS_ITEM_FIELD_ASSOCIATION_NO_VALUE="- No association -"
COM_TAGS_ITEM_OPTIONS="Item Options"
COM_TAGS_ITEMS_SEARCH_FILTER="Search"
COM_TAGS_LEFT="Left"
COM_TAGS_LIST_ALL_SELECTION_OPTIONS="Selection Options"
COM_TAGS_LIST_MAX_CHARACTERS_DESC="The maximum number of characters to display from the description in each tag."
COM_TAGS_LIST_MAX_CHARACTERS_LABEL="Maximum characters"
COM_TAGS_LIST_MAX_CHARACTERS_LABEL="Maximum Characters"
COM_TAGS_LIST_MAX_DESC="The maximum number of results to return"
COM_TAGS_LIST_MAX_LABEL="Maximum"
COM_TAGS_LIST_MAX_LABEL="Maximum Items"
COM_TAGS_LIST_SELECTION_OPTIONS="Item Selection Options"
COM_TAGS_MANAGER_TAGS="Tags"
COM_TAGS_MATCH_COUNT="Number of matching tags"
COM_TAGS_N_ITEMS_ARCHIVED="%d tags successfully archived"
Expand All @@ -100,47 +116,49 @@ COM_TAGS_NUMBER_COLUMNS_DESC="Number of columns to arrange the tags in. Note tha
COM_TAGS_NUMBER_TAG_ITEMS_DESC="Shows the number of items with a given tag"
COM_TAGS_NUMBER_TAG_ITEMS_LABEL="Show number of items"
COM_TAGS_OPTIONS="Tag Options"
COM_TAGS_PAGINATION_OPTIONS="Pagination Options"
COM_TAGS_REBUILD_FAILURE="Failed rebuilding Tags tree data."
COM_TAGS_REBUILD_SUCCESS="Tags tree data successfully rebuilt."
COM_TAGS_RIGHT="Right"
COM_TAGS_SAVE_SUCCESS="Tag successfully saved"
COM_TAGS_SEARCH_TYPE_DESC="All will return items that have all of the tags. Any will return items that have at least one of the tags."
COM_TAGS_SEARCH_TYPE_LABEL="Match Type"
COM_TAGS_SHOW_ALL_TAGS_DESCRIPTION_DESC="Shows a description at the top of the tags list"
COM_TAGS_SHOW_ALL_TAGS_DESCRIPTION_LABEL="Description"
COM_TAGS_SHOW_ALL_TAGS_IMAGE_DESC="Shows an image at the top of the tags list."
COM_TAGS_SHOW_ALL_TAGS_IMAGE_LABEL="Tags Image"
COM_TAGS_SHOW_ALL_TAGS_DESCRIPTION_DESC="Optional description to show at the top of the all tags list"
COM_TAGS_SHOW_ALL_TAGS_DESCRIPTION_LABEL="Heading Description"
COM_TAGS_SHOW_ALL_TAGS_IMAGE_DESC="Shows an image at the heading of the tags list."
COM_TAGS_SHOW_ALL_TAGS_IMAGE_LABEL="Show Heading Image"
COM_TAGS_SHOW_EMPTY_TAG_DESC="Show empty tags"
COM_TAGS_SHOW_ITEM_BODY_DESC="Show or hide the body text for the tagged items"
COM_TAGS_SHOW_ITEM_BODY_LABEL="Item body"
COM_TAGS_SHOW_ITEM_DESCRIPTION_DESC="Shows or hides the description for each tag listed"
COM_TAGS_SHOW_ITEM_DESCRIPTION_LABEL="Tag descriptions"
COM_TAGS_SHOW_ITEM_DESCRIPTION_LABEL="Tag Descriptions"
COM_TAGS_SHOW_ITEM_IMAGE_DESC="Shows the first image for each item in the list"
COM_TAGS_SHOW_ITEM_IMAGE_LABEL="Tag image"
COM_TAGS_SHOW_ITEM_IMAGE_LABEL="Item Images"
COM_TAGS_SHOW_TAG_BODY_DESC="For a layout with one tag, show the tag description."
COM_TAGS_SHOW_TAG_BODY_LABEL="Show tag description"
COM_TAGS_SHOW_TAG_DESCRIPTION_DESC="Show or hide the description for the tag (only used when a single tag is selected)"
COM_TAGS_SHOW_TAG_DESCRIPTION_LABEL="Tag Description"
COM_TAGS_SHOW_TAG_IMAGE_DESC="For a layout with one tag, show the image for the tag"
COM_TAGS_SHOW_TAG_IMAGE_LABEL="Show image"
COM_TAGS_SHOW_TAG_IMAGE_LABEL="Tag Image"
COM_TAGS_SHOW_TAG_LIST_DESCRIPTION_LABEL="Description"
COM_TAGS_SHOW_TAG_TITLE_DESC="For a layout with one tag, show the tag name"
COM_TAGS_SHOW_TAG_TITLE_LABEL="Show tag name"
COM_TAGS_SUBSLIDER_DRILL_TAG_LIST_LABEL="Options for each item in the list."
COM_TAGS_TAG_FIELD_MODE_AJAX="AJAX"
COM_TAGS_TAG_FIELD_MODE_DESC="Ajax mode searches tags while typing and allows you on the fly tag creation. Nested tags show you a nested view with all the available tags"
COM_TAGS_TAG_FIELD_MODE_LABEL="Tag field mode"
COM_TAGS_TAG_FIELD_MODE_LABEL="Tag Entry Mode"
COM_TAGS_TAG_FIELD_MODE_NESTED="Nested"
COM_TAGS_TAG_LIST_DESCRIPTION_DESC="Show or hide the description for the tag"
COM_TAGS_TAG_LIST_DESCRIPTION_DESC="Optional description to show at the top of the list. For example, this can be used when you have a layout that includes more than one tag."
COM_TAGS_TAG_LIST_DESCRIPTION_LABEL="Layout Description"
COM_TAGS_TAG_LIST_FIELD_ITEM_DESCRIPTION_LABEL="Item body"
COM_TAGS_TAG_LIST_ITEM_DESCRIPTION_DESC="Shows the body text for the individual items (depends on the source table)"
COM_TAGS_TAG_LIST_ITEM_HITS_DESC="Shows the number of hits for each individual item"
COM_TAGS_TAG_LIST_MEDIA_DESC="Show the tag image (full image)"
COM_TAGS_TAG_LIST_MEDIA_LABEL="Image"
COM_TAGS_TAG_LIST_SHOW_ITEM_IMAGE_DESC="Shows the image for each item"
COM_TAGS_TAG_LIST_SHOW_ITEM_IMAGE_LABEL="Item image"
COM_TAGS_TAG_LIST_SHOW_TAG_DESCRIPTION_DESC="Shows the description for the tag defining the list (only applies for single tag lists)."
COM_TAGS_TAG_LIST_SHOW_TAG_DESCRIPTION_LABEL="Item description"
COM_TAGS_TAG_LIST_SHOW_ITEM_DESCRIPTION_DESC="Whether to show or hide the description for each item in the list. The length may be limited using the Maximum Characters option."
COM_TAGS_TAG_LIST_SHOW_ITEM_DESCRIPTION_LABEL="Item description"
COM_TAGS_TAG_VIEW_LIST_DESC="Displays a compact list of items that have been tagged with the selected tags"
COM_TAGS_TAG_VIEW_LIST_OPTION="List view options"
COM_TAGS_TAG_VIEW_LIST_TITLE="Tagged items list"
Expand Down
97 changes: 88 additions & 9 deletions components/com_tags/models/tag.php
Expand Up @@ -34,6 +34,44 @@ class TagsModelTag extends JModelList
*/
protected $items = null;

/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
* @since 3.1
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'core_content_id', 'c.core_content_id',
'core_title', 'c.core_title',
'core_type_alias', 'c.core_type_alias',
'core_checked_out_user_id', 'c.core_checked_out_user_id',
'core_checked_out_time', 'c.core_checked_out_time',
'core_catid', 'c.core_catid',
'core_state', 'c.core_state',
'core_access', 'c.core_access',
'core_created_user_id', 'c.core_created_user_id',
'core_created_time', 'c.core_created_time',
'core_modified_time', 'c.core_modified_time',
'core_ordering', 'c.core_ordering',
'core_featured', 'c.core_featured',
'core_language', 'c.core_language',
'core_hits', 'c.core_hits',
'core_publish_up', 'c.core_publish_up',
'core_publish_down', 'c.core_publish_down',
'core_images', 'c.core_images',
'core_urls', 'c.core_urls',
'match_count',
);
}

parent::__construct($config);
}

/**
* Method to get a list of items for a list of tags.
*
Expand All @@ -54,7 +92,7 @@ public function getItems()
$item->link = 'index.php?option=' . $explodedTypeAlias[0] . '&view=' . $explodedTypeAlias[1] . '&id=' . $item->content_item_id . ':' . $item->core_alias;

// Get display date
switch ($this->state->params->get('list_show_date'))
switch ($this->state->params->get('tag_list_show_date'))
{
case 'modified':
$item->displayDate = $item->core_modified_time;
Expand Down Expand Up @@ -92,9 +130,9 @@ protected function getListQuery()
$tagId = $this->getState('tag.id') ? : '';

$typesr = $this->getState('tag.typesr');
$orderByOption = $this->getState('params')->get('tag_list_orderby', 'title');
$orderByOption = $this->getState('list.ordering', 'c.core_title');
$includeChildren = $this->state->params->get('include_children', 0);
$orderDir = $this->getState('params')->get('tag_list_orderby_direction', 'ASC');
$orderDir = $this->getState('list.direction', 'ASC');
$matchAll = $this->getState('params')->get('return_any_or_all', 1);
$language = $this->getState('tag.language');
$stateFilter = $this->getState('tag.state');
Expand All @@ -107,6 +145,10 @@ protected function getListQuery()

$listQuery = New JHelperTags;
$query = $listQuery->getTagItemsQuery($tagId, $typesr, $includeChildren, $orderByOption, $orderDir, $matchAll, $language, $stateFilter);
if ($this->state->get('list.filter'))
{
$query->where($this->_db->quoteName('c.core_title') . ' LIKE ' . $this->_db->quote('%' . $this->state->get('list.filter') . '%'));
}

return $query;
}
Expand All @@ -123,10 +165,14 @@ protected function getListQuery()
*
* @since 3.1
*/
protected function populateState($ordering = null, $direction = null)
protected function populateState($ordering = 'c.core_title', $direction = 'ASC')
{
$app = JFactory::getApplication('site');

// Load the parameters.
$params = $app->getParams();
$this->setState('params', $params);

// Load state from the request.
$pk = $app->input->getObject('id');
$pk = (array) $pk;
Expand All @@ -151,17 +197,50 @@ protected function populateState($ordering = null, $direction = null)
$language = $app->input->getString('tag_list_language_filter');
$this->setState('tag.language', $language);

// List state information
$format = $app->input->getWord('format');
if ($format == 'feed')
{
$limit = $app->getCfg('feed_limit');
}
else
{
if ($this->state->params->get('show_pagination_limit'))
{
$limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'uint');
}
else
{
$limit = $this->state->params->get('maximum', 20);
}
}
$this->setState('list.limit', $limit);

$offset = $app->input->get('limitstart', 0, 'uint');
$this->setState('list.offset', $offset);
$this->setState('list.start', $offset);

// Load the parameters.
$params = $app->getParams();
$this->setState('params', $params);
$itemid = $pkString . ':' . $app->input->get('Itemid', 0, 'int');
$orderCol = $app->getUserStateFromRequest('com_tags.tag.list.' . $itemid . '.filter_order', 'filter_order', '', 'string');
$orderCol = !$orderCol ? $this->state->params->get('tag_list_orderby','c.core_title') : $orderCol;
if (!in_array($orderCol, $this->filter_fields))
{
$orderCol = 'c.core_title';
}
$this->setState('list.ordering', $orderCol);

$listOrder = $app->getUserStateFromRequest('com_tags.tag.list.' . $itemid . '.filter_order_direction', 'filter_order_Dir', '', 'string');
$listOrder = !$listOrder ? $this->state->params->get('tag_list_orderby_direction','ASC') : $listOrder;
if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', '')))
{
$listOrder = 'ASC';
}
$this->setState('list.direction', $listOrder);

$this->setState('tag.state', 1);

// Optional filter text
$this->setState('list.filter', $app->input->getString('filter-search'));
$filterSearch = $app->getUserStateFromRequest('com_tags.tag.list.' . $itemid . '.filter_search', 'filter-search', '', 'string');
$this->setState('list.filter', $filterSearch);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions components/com_tags/views/tag/tmpl/default.php
Expand Up @@ -11,15 +11,15 @@
// Note that there are certain parts of this layout used only when there is exactly one tag.

JHtml::addIncludePath(JPATH_COMPONENT.'/helpers');

$isSingleTag = (count($this->item) == 1);
?>
<div class="tag-category<?php echo $this->pageclass_sfx; ?>">
<?php if ($this->params->get('show_page_heading')) : ?>
<h1>
<?php echo $this->escape($this->params->get('page_heading')); ?>
</h1>
<?php endif; ?>
<?php if($this->state->get('show_tag_title', 1)) : ?>
<?php if($this->params->get('show_tag_title', 1)) : ?>
<h2>
<?php echo JHtml::_('content.prepare', $this->document->title, '', 'com_tag.tag'); ?>
</h2>
Expand All @@ -31,19 +31,19 @@
<?php if ($this->params->get('tag_list_show_tag_image', 1) == 1 && !empty($images->image_fulltext)) : ?>
<img src="<?php echo htmlspecialchars($images->image_fulltext);?>">
<?php endif; ?>
<?php $this->params->get('tag_list_show_tag_description'); ?>
<?php if ($this->params->get('tag_list_show_tag_description') == 1 && $this->item[0]->description) : ?>
<?php echo JHtml::_('content.prepare', $this->item[0]->description, '', 'com_tags.tag'); ?>
<?php endif; ?>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php // If there are multiple tags and a description or image has been supplied use that. ?>
<?php elseif ($this->params->get('tag_list_show_tag_description', 1) || $this->params->get('show_description_image', 1)): ?>
<?php if ($this->params->get('tag_list_show_tag_description', 1) || $this->params->get('show_description_image', 1)): ?>
<?php if ($this->params->get('show_description_image', 1) == 1 && $this->params->get('tag_list_image')) :?>
<img src="<?php echo $this->params->get('tag_list_image');?>">
<?php endif; ?>
<?php if ($this->state->params->get('show_description', 1) == 1 && $this->state->params->get('tag_list_description')) :?>
<?php echo JHtml::_('content.prepare', $this->state->params->get('tag_list_description'), '', 'com_tags.tag'); ?>
<?php if ($this->params->get('tag_list_description', '') > '') :?>
<?php echo JHtml::_('content.prepare', $this->params->get('tag_list_description'), '', 'com_tags.tag'); ?>
<?php endif; ?>

<?php endif; ?>
Expand Down

0 comments on commit 7d119bc

Please sign in to comment.