Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 12 commits
  • 10 files changed
  • 0 commit comments
  • 3 contributors
Commits on Nov 11, 2010
Shaun McCormick Added ability to sort by publishedon in tagLister 6c9db59
Commits on Dec 19, 2010
mikrobi Added &tag parameter to be able to specify the tag manually. 6ac11ff
Commits on Jan 03, 2011
Shaun McCormick [#10] Add urldecode to tag var in getResourcesTag to fix encoded char…
…s; [#15] Add fix to allow for &tag property in getResourcesTag snippet
c536d17
Commits on Mar 07, 2011
Shaun McCormick Update gitignore 29302f9
Shaun McCormick - [#16] Add lastCls, condition if tag is equal tagList count.
- [#16] Add element (value: getResources) to default properties
0c230c0
Shaun McCormick [#18] Add ability to sortBy=`rand` to randomly sort tags in tagLister…
… snippet
6f823c7
Commits on Mar 29, 2011
Shaun McCormick Fix queries for sqlsrv support f60e3d3
Shaun McCormick [#17] Fix issue with tolinks and key parameter e619ff7
Commits on Nov 15, 2011
Shaun McCormick Better handling of furls for tags with modBlog c133f92
Shaun McCormick Update build version 5295dfd
Commits on Dec 13, 2011
Oori Merge commit '5295dfdf6f27cb5c309f6d04b0d6a88444ad3ff5' b0404aa
Oori Fix useTagFurl: support other TVs
1.$tagKey used to build the url
2.(misc) removed plural ('tagS --> tag'),  to have same naming in both snippets.
633efd0
View
2  .gitignore
@@ -1,2 +1,4 @@
_build/build.config.php
config.core.php
+.idea
+nbproject
View
5 _build/build.transport.php
@@ -38,7 +38,7 @@
/* define package */
define('PKG_NAME','tagLister');
define('PKG_NAME_LOWER','taglister');
-define('PKG_VERSION','1.1.0');
+define('PKG_VERSION','1.1.4');
define('PKG_RELEASE','pl');
/* define sources */
@@ -111,7 +111,8 @@
/* now pack in the license file, readme and setup options */
$builder->setPackageAttributes(array(
'license' => file_get_contents($sources['docs'] . 'license.txt'),
- 'readme' => file_get_contents($sources['docs'] . 'readme.txt')."\n".file_get_contents($sources['docs'].'changelog.txt'),
+ 'readme' => file_get_contents($sources['docs'] . 'readme.txt'),
+ 'changelog' => file_get_contents($sources['docs'].'changelog.txt'),
//'setup-options' => array(
// 'source' => $sources['build'].'setup.options.php',
// ),
View
8 _build/data/properties/properties.getresourcestag.php
@@ -240,6 +240,14 @@
'lexicon' => 'taglister:properties',
)
,array(
+ 'name' => 'element',
+ 'desc' => 'prop_grt.element_desc',
+ 'type' => 'textfield',
+ 'options' => '',
+ 'value' => 'getResources',
+ 'lexicon' => 'taglister:properties',
+ )
+ ,array(
'name' => 'pageNavVar',
'desc' => 'prop_grt.pagenavvar_desc',
'type' => 'textfield',
View
18 core/components/taglister/docs/changelog.txt
@@ -1,5 +1,23 @@
Changelog for tagLister.
+tagLister 1.1.3
+===============
+- [#17] Fix issue with tolinks and key parameter
+- Fix queries for sqlsrv support
+
+tagLister 1.1.2
+===============
+- [#18] Add ability to sortBy=`rand` to randomly sort tags in tagLister snippet
+- [#16] Add lastCls, condition if tag is equal tagList count.
+- [#16] Add element (value: getResources) to default properties
+- [#15] Add fix to allow for &tag property in getResourcesTag snippet
+- [#10] Add urldecode to tag var in getResourcesTag to fix encoded chars
+
+tagLister 1.1.1
+===============
+- Added ability to sort by publishedon in tagLister
+- Added idx placeholder to each tag
+
tagLister 1.1.0
===============
- Added active tag: Set css class (activeCls) for currently selected tag. Used in conjunction with a content listing snippet (like getResourcesTag)
View
2  core/components/taglister/elements/chunks/tag.chunk.tpl
@@ -1 +1 @@
-<li class="[[+cls]]"><a href="[[~[[+target]]? &[[+tagVar]]=`[[+tag]]` &[[+tagKeyVar]]=`[[+tagKey]]`]]">[[+tag]]</a> ([[+count]])</li>
+<li class="[[+cls]]"><a href="[[+url]]">[[+tag]]</a> ([[+count]])</li>
View
13 core/components/taglister/elements/snippets/getresourcestag.snippet.php
@@ -33,17 +33,18 @@
$tagKey = (!empty($tagKeyVar) && !empty($_GET[$tagKeyVar]))? $_GET[$tagKeyVar] : $modx->getOption('tagKey',$scriptProperties,'tags');
$tagRequestParam = $modx->getOption('tagRequestParam',$scriptProperties,'tag');
$grSnippet = $modx->getOption('grSnippet',$scriptProperties,'getPage');
-
-if (!empty($_GET[$tagRequestParam])) {
+$tag = $modx->getOption('tag',$scriptProperties,urldecode($_GET[$tagRequestParam]));
+if (!empty($tag)) {
+ $tag = $modx->stripTags($tag);
$tagSearchType = $modx->getOption('tagSearchType',$scriptProperties,'exact');
if ($tagSearchType == 'contains') {
- $scriptProperties['tvFilters'] = $tagKey.'==%'.$modx->stripTags(urldecode($_GET[$tagRequestParam])).'%';
+ $scriptProperties['tvFilters'] = $tagKey.'==%'.$tag.'%';
} else if ($tagSearchType == 'beginswith') {
- $scriptProperties['tvFilters'] = $tagKey.'==%'.$modx->stripTags(urldecode($_GET[$tagRequestParam])).'';
+ $scriptProperties['tvFilters'] = $tagKey.'==%'.$tag.'';
} else if ($tagSearchType == 'endswith') {
- $scriptProperties['tvFilters'] = $tagKey.'=='.$modx->stripTags(urldecode($_GET[$tagRequestParam])).'%';
+ $scriptProperties['tvFilters'] = $tagKey.'=='.$tag.'%';
} else {
- $scriptProperties['tvFilters'] = $tagKey.'=='.$modx->stripTags(urldecode($_GET[$tagRequestParam])).'';
+ $scriptProperties['tvFilters'] = $tagKey.'=='.$tag.'';
}
}
$elementObj = $modx->getObject('modSnippet', array('name' => $grSnippet));
View
49 core/components/taglister/elements/snippets/taglister.snippet.php
@@ -26,6 +26,10 @@
/**
* tagLister snippet
*
+ * @var modX
+ * @var TagLister $tagLister
+ * @var array $scriptProperties
+ *
* @package taglister
*/
$tagLister = $modx->getService('taglister','TagLister',$modx->getOption('taglister.core_path',null,$modx->getOption('core_path').'components/taglister/').'model/taglister/',$scriptProperties);
@@ -40,8 +44,8 @@
$tagVar = $modx->getOption('tagVar',$scriptProperties,'tag');
$tagKeyVar = $modx->getOption('tagKeyVar',$scriptProperties,'key');
$limit = $modx->getOption('limit',$scriptProperties,10);
-$sortBy = $modx->getOption('sortBy',$scriptProperties,'count');
-$sortDir = $modx->getOption('sortDir',$scriptProperties,'ASC');
+$sortBy = strtolower($modx->getOption('sortBy',$scriptProperties,'count'));
+$sortDir = strtoupper($modx->getOption('sortDir',$scriptProperties,'ASC'));
$cls = $modx->getOption('cls',$scriptProperties,'');
$altCls = $modx->getOption('altCls',$scriptProperties,'');
$firstCls = $modx->getOption('firstCls',$scriptProperties,'');
@@ -53,6 +57,7 @@
$toLower = $modx->getOption('toLower',$scriptProperties,false);
$weights = $modx->getOption('weights',$scriptProperties,0);
$weightCls = $modx->getOption('weightCls',$scriptProperties,'');
+$useTagFurl = $modx->getOption('useTagFurl',$scriptProperties,false);
/* parents support */
$parents = isset($parents) ? explode(',', $parents) : array();
@@ -68,9 +73,9 @@
$c = $modx->newQuery('modTemplateVarResource');
$c->innerJoin('modTemplateVar','TemplateVar');
$c->innerJoin('modResource','Resource');
-$c->leftJoin('modUser','CreatedBy','`CreatedBy`.`id` = `Resource`.`createdby`');
-$c->leftJoin('modUser','PublishedBy','`PublishedBy`.`id` = `Resource`.`publishedby`');
-$c->leftJoin('modUser','EditedBy','`EditedBy`.`id` = `Resource`.`editedby`');
+$c->leftJoin('modUser','CreatedBy','CreatedBy.id = Resource.createdby');
+$c->leftJoin('modUser','PublishedBy','PublishedBy.id = Resource.publishedby');
+$c->leftJoin('modUser','EditedBy','EditedBy.id = Resource.editedby');
$tvPk = (int)$tv;
if (!empty($tvPk)) {
$c->where(array('TemplateVar.id' => $tvPk));
@@ -78,8 +83,16 @@
$c->where(array('TemplateVar.name' => $tv));
}
if (!empty($parents)) {
+ $children = array();
+ foreach ($parents as $parent) {
+ $kids = $modx->getChildIds($parent);
+ foreach ($kids as $kid) {
+ $children[] = $kid;
+ }
+ }
+ $children = array_unique($children);
$c->where(array(
- 'Resource.parent:IN' => $parents,
+ 'Resource.id:IN' => $children,
));
}
if (!$modx->getOption('includeDeleted',$scriptProperties,false)) {
@@ -96,6 +109,11 @@
$c->where($where);
}
}
+if ($sortBy == 'publishedon') {
+ $c->sortby('Resource.publishedon',$sortDir);
+} else if (in_array($sortBy,array('rand','random','rand()'))) {
+ $c->sortby('RAND()','');
+}
$tags = $modx->getCollection('modTemplateVarResource',$c);
/* parse TV values */
@@ -121,10 +139,12 @@
/* sort */
switch ($sortBy.'-'.$sortDir) {
+ case 'publishedon-DESC': case 'publishedon-ASC': break;
case 'tag-ASC': ksort($tagList); break;
case 'tag-DESC': krsort($tagList); break;
case 'count-DESC': asort($tagList); break;
case 'count-ASC': default: arsort($tagList); break;
+ case 'rand-ASC': case 'random-ASC': case 'rand()-asc': $tagList = $tagLister->ashuffle($tagList); break;
}
/* iterate */
@@ -134,13 +154,13 @@
if ($i >= $limit) break;
$tagCls = $cls.((!empty($altCls) && $i % 2)? ' '.$altCls : '');
if (!empty($firstCls) && $i == 0) $tagCls .= ' '.$firstCls;
- if (!empty($lastCls) && $i+1 >= $limit) $tagCls .= ' '.$lastCls;
+ if (!empty($lastCls) && ($i+1 >= $limit || $i == $count)) $tagCls .= ' '.$lastCls;
/* if tag is currently being viewed, mark as active */
if (!empty($activeCls) && $tag==$activeTag && (empty($activeKey) || $tv==$activeKey)) $tagCls .= ' '.$activeCls;
/* handle weighting for css */
if (!empty($weights) && !empty($weightCls)) $tagCls .= ' '.$weightCls.ceil($count / (max($tagList) / $weights));
- $output[] = $tagLister->getChunk($tpl,array(
+ $tagArray = array(
'tag' => $tag,
'tagVar' => $tagVar,
'tagKey' => $tv,
@@ -149,7 +169,18 @@
'target' => $target,
'cls' => $tagCls,
'idx' => $i,
- ));
+ );
+ $tagParams = array();
+ if (empty($useTagFurl)) {
+ $tagParams[$tagVar] = $tag;
+ $tagParams[$tagKeyVar] = $tv;
+ }
+ $tagArray['url'] = $modx->makeUrl($target,'',$tagParams);
+ if (!empty($useTagFurl)) {
+ $tagArray['url'] = rtrim($tagArray['url'],'/').'/'.$tv.'/'.urlencode($tag);
+ }
+
+ $output[] = $tagLister->getChunk($tpl,$tagArray);
$totalTags += $count;
$i++;
}
View
24 core/components/taglister/elements/snippets/tolinks.snippet.php
@@ -26,6 +26,10 @@
/**
* tolinks snippet. Creates links out of tags.
*
+ * @var modX $modx
+ * @var tagLister $tagLister
+ * @var array $scriptProperties
+ *
* @package taglister
*/
$tagLister = $modx->getService('taglister','TagLister',$modx->getOption('taglister.core_path',null,$modx->getOption('core_path').'components/taglister/').'model/taglister/',$scriptProperties);
@@ -34,13 +38,13 @@
/* setup default properties */
$inputDelim = $modx->getOption('inputDelim',$scriptProperties,',');
$outputDelim = $modx->getOption('outputDelim',$scriptProperties,', ');
-$key = $modx->getOption('key',$scriptProperties,'tag'); /* backwards compat */
-$tagRequestParam = $modx->getOption('tagRequestParam',$scriptProperties,$key);
+$tagRequestParam = $modx->getOption('tagRequestParam',$scriptProperties,'tag');
$tagKeyVar = $modx->getOption('tagKeyVar',$scriptProperties,'key');
$tagKey = $modx->getOption('tagKey',$scriptProperties,'tags');
$target = !empty($scriptProperties['target']) ? $scriptProperties['target'] : $modx->resource->get('id');
$tpl = $modx->getOption('tpl',$scriptProperties,'link');
$cls = $modx->getOption('cls',$scriptProperties,'tl-tag');
+$useTagFurl = $modx->getOption('useTagFurl',$scriptProperties,false);
/* get items */
$items = $modx->getOption('items',$scriptProperties,'');
@@ -66,15 +70,21 @@
foreach ($items as $item) {
$itemArray = array();
$itemArray['item'] = trim($item);
- $params = array(
- $tagRequestParam => $itemArray['item'],
- $tagKeyVar => $tagKey,
- );
+ $params = array();
+ if (empty($useTagFurl)) {
+ $params = array(
+ $tagRequestParam => $itemArray['item'],
+ $tagKeyVar => $tagKey,
+ );
+ }
+
if (!empty($extraParams)) {
$params = array_merge($extraParams,$params);
}
$itemArray['url'] = $modx->makeUrl($target,'',$params);
- $itemArray['url'] = str_replace(' ','+',$itemArray['url']);
+ if (!empty($useTagFurl)) {
+ $itemArray['url'] = rtrim($itemArray['url'],'/').'/'.$tagKey.'/'.urlencode($itemArray['item']);
+ }
$itemArray['cls'] = $cls;
$tags[] = $tagLister->getChunk($tpl,$itemArray);
}
View
1  core/components/taglister/lexicon/en/properties.inc.php
@@ -112,6 +112,7 @@
$_lang['prop_grt.pagevarkey_desc'] = 'The key of a property that indicates the current page.';
$_lang['prop_grt.totalvar_desc'] = 'The key of a placeholder that must contain the total records in the limitable collection being paged.';
$_lang['prop_grt.pagelimit_desc'] = 'The maximum number of pages to display when rendering paging controls.';
+$_lang['prop_grt.element_desc'] = 'The element name that will be called by the getPage instance.';
$_lang['prop_grt.elementclass_desc'] = 'The class of element that will be called by the getPage snippet instance.';
$_lang['prop_grt.pagenavvar_desc'] = 'The key of a placeholder to be set with the paging navigation controls.';
$_lang['prop_grt.pagenavtpl_desc'] = 'Content representing a single page navigation control.';
View
18 core/components/taglister/model/taglister/taglister.class.php
@@ -91,4 +91,22 @@ private function _getTplChunk($name) {
return $chunk;
}
+ /**
+ * Shuffle an associative array
+ *
+ * @param array $list The array to shuffle
+ * @return array The shuffled array
+ */
+ public function ashuffle(array $list = array()) {
+ if (!is_array($list)) return $list;
+
+ $keys = array_keys($list);
+ shuffle($keys);
+ $random = array();
+ foreach ($keys as $key) {
+ $random[$key] = $list[$key];
+ }
+
+ return $random;
+ }
}

No commit comments for this range

Something went wrong with that request. Please try again.