mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 05:07:27 +02:00
Nextprev shortcode fix to handle proper dropdown navigation;
Admin UI - new nextprev parameters
This commit is contained in:
@@ -31,7 +31,11 @@
|
|||||||
* - amount (integer| string 'all') [required]: Records per page, always 1 when we counting pages (see 'type' parameter), ignored where tmpl_prefix is not set and 'old_np' pref is false
|
* - amount (integer| string 'all') [required]: Records per page, always 1 when we counting pages (see 'type' parameter), ignored where tmpl_prefix is not set and 'old_np' pref is false
|
||||||
* - current (integer)[required]: Current record/page
|
* - current (integer)[required]: Current record/page
|
||||||
* - type (string page|record) [optional]: What kind of navigation logic we need, default is 'record' (the old way)
|
* - type (string page|record) [optional]: What kind of navigation logic we need, default is 'record' (the old way)
|
||||||
* - url (rawurlencode'd string) [required]: URL template, will be rawurldecode'd after parameters are parsed to array
|
*
|
||||||
|
* - url (rawurlencode'd string) [required]: URL template, will be rawurldecode'd after parameters are parsed to array, '--AMP--' strings will be replaced with '&'
|
||||||
|
* NOTE: URL should be DOUBLE encoded, which means you need to encode the query only of passed URL (W3C standards) and rawurlencode the whole URL string
|
||||||
|
* The reason to do this is to not break the whole shortcode $parm string, shortcode itself is doing decode once, which means we'll end up with correct, W3C compliant URL string
|
||||||
|
*
|
||||||
* Preffered 'FROM' template is now '--FROM--' (instead '[FROM]')
|
* Preffered 'FROM' template is now '--FROM--' (instead '[FROM]')
|
||||||
* - caption (rawurlencode'd string) [optional]: Label, rawurldecode'd after parameters are parsed to array, language constants are supported
|
* - caption (rawurlencode'd string) [optional]: Label, rawurldecode'd after parameters are parsed to array, language constants are supported
|
||||||
* - pagetitle (rawurlencode'd string) [optional]: Page labels, rawurldecode'd after parameters are parsed to array,
|
* - pagetitle (rawurlencode'd string) [optional]: Page labels, rawurldecode'd after parameters are parsed to array,
|
||||||
@@ -60,30 +64,44 @@ function nextprev_shortcode($parm = '')
|
|||||||
*/
|
*/
|
||||||
if(strpos($parm, 'total=') !== false)
|
if(strpos($parm, 'total=') !== false)
|
||||||
{
|
{
|
||||||
// Calculate
|
|
||||||
parse_str($parm, $parm);
|
parse_str($parm, $parm);
|
||||||
|
|
||||||
|
// Calculate
|
||||||
$total_items = intval($parm['total']);
|
$total_items = intval($parm['total']);
|
||||||
|
$check_render = true;
|
||||||
|
|
||||||
// search for template keys - default_start, default_end etc.
|
// search for template keys - default_start, default_end etc.
|
||||||
if(isset($parm['tmpl_prefix']))
|
if(isset($parm['tmpl_prefix']))
|
||||||
{
|
{
|
||||||
// forced
|
// forced
|
||||||
$tprefix = vartrue($parm['tmpl_prefix'], 'default');
|
$tprefix = vartrue($parm['tmpl_prefix'], 'default');
|
||||||
$perpage = $parm['amount'] !== 'all' ? intval($parm['amount']) : $total_items;
|
//$perpage = $parm['amount'] !== 'all' ? intval($parm['amount']) : $total_items;
|
||||||
}
|
}
|
||||||
// default, based on prefs
|
// default, based on prefs
|
||||||
elseif($pref['old_np'])
|
elseif($pref['old_np'])
|
||||||
{
|
{
|
||||||
|
|
||||||
$tprefix = 'default';
|
$tprefix = 'default';
|
||||||
$perpage = $parm['amount'] !== 'all' ? intval($parm['amount']) : $total_items;
|
//$perpage = $parm['amount'] !== 'all' ? intval($parm['amount']) : $total_items;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$tprefix = 'dropdown';
|
$tprefix = 'dropdown';
|
||||||
$perpage = $total_items; // amount is ignored
|
//$parm['amount'] = 'all';
|
||||||
}
|
}
|
||||||
$tprefix .= '_';
|
$tprefix .= '_';
|
||||||
|
|
||||||
|
if($parm['amount'] === 'all')
|
||||||
|
{
|
||||||
|
$perpage = 1; // amount is ignored
|
||||||
|
$check_render = ($total_items > 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$perpage = intval($parm['amount']);
|
||||||
|
}
|
||||||
|
if(!$check_render) { return ''; }
|
||||||
|
|
||||||
// TODO - rename old_np to something more meaningful
|
// TODO - rename old_np to something more meaningful
|
||||||
|
|
||||||
$current_start = intval($parm['current']);
|
$current_start = intval($parm['current']);
|
||||||
@@ -112,8 +130,8 @@ function nextprev_shortcode($parm = '')
|
|||||||
|
|
||||||
if($total_pages <= 1) { return ''; }
|
if($total_pages <= 1) { return ''; }
|
||||||
|
|
||||||
// urldecoded by parse_str()
|
// urldecoded once by parse_str()
|
||||||
$url = str_replace('--FROM--', '[FROM]', $parm['url']);
|
$url = str_replace(array('--FROM--', '--AMP--'), array('[FROM]', '&'), $parm['url']);
|
||||||
|
|
||||||
// Simple parser vars
|
// Simple parser vars
|
||||||
$e_vars = new e_vars(array(
|
$e_vars = new e_vars(array(
|
||||||
|
@@ -1704,7 +1704,15 @@ class e_form
|
|||||||
|
|
||||||
if($tree && $amount)
|
if($tree && $amount)
|
||||||
{
|
{
|
||||||
$parms = $total.",".$amount.",".$from.",".$url.'?'.($options['np_query'] ? $options['np_query'].'&' : '').'from=[FROM]';
|
// New nextprev SC parameters
|
||||||
|
$parms = 'total='.$total;
|
||||||
|
$parms .= '&amount='.$amount;
|
||||||
|
$parms .= '¤t='.$from;
|
||||||
|
// NOTE - the whole url is double encoded - reason is to not break parms query string
|
||||||
|
// 'np_query' should be proper (urlencode'd) url query string
|
||||||
|
$url = rawurlencode($url.'?'.(varset($options['np_query']) ? str_replace(array('&', '&'), array('&', '&'), $options['np_query']).'&' : '').'from=[FROM]');
|
||||||
|
$parms .= '&url='.$url;
|
||||||
|
//$parms = $total.",".$amount.",".$from.",".$url.'?'.($options['np_query'] ? $options['np_query'].'&' : '').'from=[FROM]';
|
||||||
//$text .= $tp->parseTemplate("{NEXTPREV={$parms}}");
|
//$text .= $tp->parseTemplate("{NEXTPREV={$parms}}");
|
||||||
$nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}");
|
$nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}");
|
||||||
if ($nextprev)
|
if ($nextprev)
|
||||||
|
Reference in New Issue
Block a user