Skip to content
Permalink
Browse files

id ranges

  • Loading branch information...
bloatware committed Sep 9, 2019
1 parent 1f439ae commit eaa643fb3972809ea2eb3a93ba4977bddd71f063
Showing with 25 additions and 6 deletions.
  1. +21 −2 textpattern/lib/txplib_misc.php
  2. +1 −1 textpattern/lib/txplib_publish.php
  3. +3 −3 textpattern/publish/taghandlers.php
@@ -5897,7 +5897,26 @@ function in_list($val, $list, $delim = ',')
function do_list($list, $delim = ',')
{
return array_map('trim', explode($delim, $list));
if (is_array($delim)) {
list($delim, $range) = $delim + array(null, null);
}
$list = explode($delim, $list);
if (isset($range)) {
$out = array();
foreach($list as $item) {
if (strpos($item, $range) === false) {
$out[] = trim($item);
} else {
list($start, $end) = explode($range, $item, 2);
$out = array_merge($out, range(trim($start), trim($end)));
}
}
}
return isset($out) ? $out : array_map('trim', $list);
}
/**
@@ -5917,7 +5936,7 @@ function do_list($list, $delim = ',')
function do_list_unique($list, $delim = ',', $flags = TEXTPATTERN_STRIP_EMPTY_STRING)
{
$out = array_unique(array_map('trim', explode($delim, $list)));
$out = array_unique(do_list($list, $delim));
if ($flags & TEXTPATTERN_STRIP_EMPTY) {
$out = array_filter($out);
@@ -902,7 +902,7 @@ function filterAtts($atts = null, $iscustom = null)
// ID
$not = $exclude === true || in_array('id', $exclude) ? 'NOT' : '';
$ids = $id ? ($id === true ? array(article_id()) : array_map('intval', do_list_unique($id))) : array();
$ids = $id ? ($id === true ? array(article_id()) : array_map('intval', do_list_unique($id, array(',', '-')))) : array();
$id = ((!$ids) ? '' : " AND ID $not IN (".join(',', $ids).")")
.(!$excluded ? '' : " AND ID NOT IN (".join(',', $excluded).")");
@@ -660,7 +660,7 @@ function linklist($atts, $thing = null)
}
if ($id) {
$where[] = "id IN ('".join("','", doSlash(do_list_unique($id)))."')";
$where[] = "id IN ('".join("','", doSlash(do_list_unique($id, array(',', '-'))))."')";
}
if ($author) {
@@ -3482,7 +3482,7 @@ function images($atts, $thing = null)
}
if ($id) {
$where[] = "id IN ('".join("','", doSlash(do_list_unique($id)))."')";
$where[] = "id IN ('".join("','", doSlash(do_list_unique($id, array(',', '-'))))."')";
}
if ($author) {
@@ -4706,7 +4706,7 @@ function file_download_list($atts, $thing = null)
$where[] = "category IN ('".join("','", doSlash(do_list_unique($category)))."')";
}
$ids = array_map('intval', do_list_unique($id));
$ids = array_map('intval', do_list_unique($id, array(',', '-')));
if ($id) {
$where[] = "id IN ('".join("','", $ids)."')";

0 comments on commit eaa643f

Please sign in to comment.
You can’t perform that action at this time.