Source for file function.pagerabc.php
Documentation is available at function.pagerabc.php
* Zikula Application Framework
* @link http://www.zikula.org
* @version $Id: function.pagerabc.php 24342 2008-06-06 12:03:14Z markwest $
* @author Peter Dudas <duda at bigfish dot hu>
* @package Zikula_Template_Plugins
* -------------------------------------------------------------
* Purpose: Displays alphabetical selection links
* Author: Peter Dudas <duda at bigfish dot hu>
* Martin Andersen; API links for ShortURL compliance
* -------------------------------------------------------------
* Changes: 2002/09/25 - created
* 2005/04/30 msandersen - Added Span with Pager class, uses API for links when link to API module, various tweaks
* 2005/08/20 msandersen - Changed forwardvars behaviour to be consistent with pager plugin:
* If forwardvars is not set, ALL the URL vars are forwarded.
* Fixed bug where if forwardvars weren't specifically set with "module,func" these core vars would not be used at all in the links
* Added support for use on the Startpage, where the vars are taken from the config starttype, startfunc, and startargs vars.
* Fixed the example below.
* <!--[pagerabc posvar="abc" class_num="dl" class_numon="header" separator=" - " names="A,B;C,D;E,F;G,H;I,J;K,L;M,N,O;P,Q,R;S,T;U,V,W,X,Y,Z"]-->
* <a class="header" href="index.php?module=Example&abc=A,B"> A,B
* </a> - <a class="dl" href="index.php?module=Example&abc=C,D"> C,D
* </a> - <a class="dl" href="index.php?module=Example&abc=E,F"> E,F
* </a> - <a class="dl" href="index.php?module=Example&abc=G,H"> G,H
* </a> - <a class="dl" href="index.php?module=Example&abc=I,J"> I,J
* </a> - <a class="dl" href="index.php?module=Example&abc=K,L"> K,L
* </a> - <a class="dl" href="index.php?module=Example&abc=M,N,O"> M,N,O
* </a> - <a class="dl" href="index.php?module=Example&abc=P,Q,R"> P,Q,R
* </a> - <a class="dl" href="index.php?module=Example&abc=S,T"> S,T
* </a> - <a class="dl" href="index.php?module=Example&abc=U,V,W,X,Y,Z"> U,V,W,X,Y,Z
* @param string $posvar - name of the variable that contains the position data, eg "letter"
* @param cvs $forwardvars - comma- semicolon- or space-delimited list of POST and GET variables to forward in the pager links. If unset, all vars are forwarded.
* @param cvs $additionalvars - comma- semicolon- or space-delimited list of additional variable and value pairs to forward in the links. eg "foo=2,bar=4"
* @param string $class_num - class for the pager links (<a> tags)
* @param string $class_numon - class for the active page
* @param string $separator - string to put between the letters, eg "|" makes | A | B | C | D |
* @param string $printempty - print empty sel ('-')
* @param string $lang - language
* @param array $names - values to select from (array or csv)
* @param string $skin - use predefined values (hu - hungarian ABC)
foreach($params as $tmp=> $value) {
if (!isset ($separator)) {
if (!isset ($class_numon)) {
$class_numon = 'pn-pagerselected';
$out = '<span class="pager">'. "\n";
$names = $values = array('A','Á','B','C','D','E','É','F','G','H','I','Í','J','K','L','M','N','O','Ó','Ö','O','P','Q','R','S','T','U','Ú','Ü','U','V','W','X','Y','Z');
//$names = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U' ,'V','W','X','Y','Z');
//$values = array('A,Á','B','C','D','E,É','F','G','H','I,Í','J','K','L','M','N','O,Ó,Ö,O','P','Q','R','S','T','U,Ú,Ü,U','V','W','X','Y','Z');
$names = $values = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
// create an empty result set
// If startmodule, check startargs for posvar
if (empty($module) && empty($name)) {
foreach ($funcargs as $funcarg) {
if ($argument[0]== $posvar)
$Request[$posvar] = $argument[1];
// If $forwardvars set, add only listed vars to query string, else add all POST and GET vars
if (isset ($forwardvars)) {
$forwardvars = preg_split('/[,;\s]/', $forwardvars, - 1, PREG_SPLIT_NO_EMPTY);
foreach ((array) $forwardvars as $key => $var) {
if (!empty($var) AND (!empty($Request[$var]))) {
$vars[$var] = $Request[$var];
// $url .= $val.'='.$Request[$val];
if (isset ($additionalvars)) {
$additionalvars = preg_split('/[,;\s]/', $additionalvars, - 1, PREG_SPLIT_NO_EMPTY);
foreach ((array) $additionalvars as $var) {
if (!empty($var) && !empty($additionalvar[1])) {
$vars[$additionalvar[0]] = $additionalvar[1];
// $url .= '&'.$additionalvar[0].'='.$additionalvar[1];
// Get module information
// If link to API module, not an Admin mod, and ShortURLs set, use ModURL API instead
$modurl = (($modinfo['type'] == 2 || $modinfo['type'] == 3) && ($type == 'user') && !pnConfigGetVar('ShortURLs'));
if (!$modurl) { // Non-API URLs
// Don't show default type and func for shorter URL
$query = 'module='. $modname. ($func!= 'main' ? '&func='. $func : ''). ($type!= 'user' ? '&type='. $type : '');
foreach($vars as $key=> $value) {
foreach($value as $var) {
} elseif (!empty($value)) {
$url = $_SERVER['PHP_SELF']. '?'. $query;
if (isset ($printempty) && $printempty == true) {
if (!empty($class_num)) {
$tmp = ' class="'. $class_num. '"';
$urltemp = ($modurl ? pnModURL($modname, $type, $func, $vars) : $url. '&'. $posvar. '=');
$out .= '<a'. $tmp. ' href="'. $urltemp. '"> -'. "\n</a>". $separator;
foreach($names as $i => $name) {
if (!empty($class_numon)) {
if (isset ($Request[$posvar]) && $Request[$posvar] == $values[$i]) {
$tmp = ' class="'. $class_numon. '"';
} elseif (!empty($class_num)) {
$tmp = ' class="'. $class_num. '"';
$vars[$posvar] = $values[$i];
$urltemp = ($modurl ? pnModURL($modname, $type, $func, $vars) : $url. '&'. $posvar. '='. $values[$i]);
$out .= '<a'. $tmp. ' href="'. $urltemp. '">'. $name. "</a>\n";
|