Smarty
[ class tree: Smarty ] [ index: Smarty ] [ all elements ]

Source for file function.alphabar.php

Documentation is available at function.alphabar.php

  1. <?php
  2. /**
  3.  * Smarty plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  * @author xing <xing$synapse.plus.com>
  7.  */
  8.  
  9. /**
  10.  * Smarty {alphabar} function plugin
  11.  *
  12.  * Type:    function
  13.  * Name:    alphabar
  14.  * Input:
  15.  *            - iskip        (optional)    array of chars that can be skipped
  16.  *            - iall        (optional)    if set to anything, it will include a link to all
  17.  *            - ifile        (optional)    set the file where the link should point (default is the current file)
  18.  *            - ipackage    (optional)    set the package the link should point to (default is the current package)
  19.  *            - *            (optional)    anything else that gets added to the pile of items is appended using &amp;$key=$val
  20.  * Example    - {alphabar}
  21.  */
  22. function smarty_function_alphabar$params&$gBitSmarty {
  23.     extract$params );
  24.  
  25.     // work out what the url is
  26.     ifisset$ifile ) ) {
  27.         ifisset$ipackage ) ) {
  28.             if$ipackage == 'root' {
  29.                 $url BIT_ROOT_URL.$ifile;
  30.             else {
  31.                 $url constantstrtoupper$ipackage ).'_PKG_URL' ).$ifile;
  32.             }
  33.         else {
  34.             $url constantstrtoupperACTIVE_PACKAGE ).'_PKG_URL' ).$ifile;
  35.         }
  36.     else {
  37.         $url $_SERVER['SCRIPT_NAME'];
  38.     }
  39.  
  40.     $alphabar_params array'ifile''ipackage''iall' );
  41.     // append any other paramters that were passed in
  42.     $url_params '';
  43.     foreach$params as $key => $val {
  44.         if!empty$val && !in_array$key$alphabar_params ) ) {
  45.             $url_params .= '&amp;'.$key."=".$val;
  46.         }
  47.     }
  48.  
  49.     $ret '<div class="pagination alphabar">';
  50.     $alpha 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','0-9','+' );
  51.     foreach$alpha as $char {
  52.         ifempty$iskip || !in_array$char$iskip )) {
  53.             $wrap array'open' => '''close' => '' );
  54.             if!empty$_REQUEST['char'&& $_REQUEST['char'== strtolower$char )) {
  55.                 $wrap array'open' => '<strong>''close' => '</strong>' );
  56.             }
  57.             $ret .= $wrap['open'].'<a href="'.$url.'?char='.urlencodestrtolower$char )).$url_params.'">'.$char.'</a>'.$wrap['close'].' ';
  58.         }
  59.     }
  60.  
  61.     if!empty$params['iall') ) {
  62.         $ret .= '<a href="'.$url.'?char='.urlencodestrtolower'All' ) ).$url_params.'">'.tra'All' ).'</a> ';
  63.     }
  64.     $ret .= '</div>';
  65.  
  66.     return $ret;
  67. }
  68. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:36 +0000 by phpDocumentor 1.5.0-lsces