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

Source for file AlphabetFilter.class.php

Documentation is available at AlphabetFilter.class.php

  1. <?php
  2. /**
  3.  * For including this file you have to define the constant "CLASSPATH".
  4.  * Because every include in the framework depends on the CLASSPATH definition.
  5.  * The CLASSPATH means the relative path to the folder that contains the
  6.  * framework GilliGan.
  7.  *
  8.  * @package    html
  9.  * @subpackage components
  10.  */
  11. if!defined"CLASSPATH" ) )
  12. {
  13.   echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
  14.   echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
  15.   exit();
  16. }
  17.  
  18. /**
  19.  *
  20.  */
  21. require_onceCLASSPATH."html/components/WebsiteNavigation.class.php" );
  22.  
  23. /**
  24.  * A class to generate a albabethical list to use as Filter for several data.
  25.  *
  26.  * @package    html
  27.  * @subpackage components
  28.  * @version    0.1.1
  29.  * @author     Daniel Plücken <daniel@debakel.net>
  30.  * @license    http://www.gnu.org/copyleft/lesser.html
  31.  *              GNU Lesser General Public License
  32.  * @copyright  Copyright (c) 2005 Daniel Plücken <daniel@debakel.net>
  33.  *
  34.  *  This library is free software; you can redistribute it and/or
  35.  *  modify it under the terms of the GNU Lesser General Public
  36.  *  License as published by the Free Software Foundation; either
  37.  *  version 2.1 of the License.
  38.  *
  39.  *  This library is distributed in the hope that it will be useful,
  40.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  41.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  42.  *  GNU Lesser General Public License for more details.
  43.  *
  44.  *  You should have received a copy of the GNU Lesser General
  45.  *  Public License along with this library; if not, write to the
  46.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  47.  *  Boston, MA 02111-1307 USA
  48.  */
  49.  
  50. {
  51.    /**
  52.     * @access public
  53.     * @var    string $str_alphabet 
  54.     */
  55.    var $str_alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  56.    /**
  57.     * @access public
  58.     * @var    string $str_href 
  59.     */
  60.    var $str_href = "";
  61.    /**
  62.     * @access public
  63.     * @var    string $str_before_each_Label 
  64.     */
  65.    var $str_before_each_Label = "";
  66.    /**
  67.     * @access public
  68.     * @var    string $str_behind_each_Label 
  69.     */
  70.    var $str_behind_each_Label = "";
  71.    
  72.    /**
  73.     * Constructor.
  74.     * 
  75.     * @version 1.0
  76.     * @since   0.1.0
  77.     * @author  Daniel Plücken <daniel@debakel.net>
  78.     * @access  public
  79.     * @param   $str_href     The hyper reference that should use on click on the
  80.     *                         list item. Place the string "[value]" where you
  81.     *                         want that the alphabetical char from the label of
  82.     *                         the list item should appear.
  83.     * @param   $str_alphabet 
  84.     */
  85.     function AlphabetFilter(
  86.                  $str_href,
  87.                  $str_selected_value,
  88.                  $str_alphabet "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  89.                            )
  90.     {
  91.       $this->str_href = $str_href;
  92.       $this->str_alphabet = $str_alphabet;
  93.     }
  94.  
  95.  
  96.  
  97.    /**
  98.     * Sets the string that should concate in front of the label string.
  99.     *
  100.     * @version 1.0
  101.     * @since   0.1.1
  102.     * @author  Daniel Plücken <daniel@debakel.net>
  103.     * @access  public
  104.     * @param   string $str_before 
  105.     * @return  void 
  106.     */
  107.    function setStringBeforeLabel$str_before )
  108.    $this->str_before_each_Label = $str_before}
  109.  
  110.  
  111.  
  112.    /**
  113.     * Sets the string that should concate behind  the label string.
  114.     *
  115.     * @version 1.0
  116.     * @since   0.1.1
  117.     * @author  Daniel Plücken <daniel@debakel.net>
  118.     * @access  public
  119.     * @param   string $str_before 
  120.     * @return  void 
  121.     */
  122.    function setStringBehindLabel$str_behind )
  123.    $this->str_behind_each_Label = $str_behind}
  124.  
  125.  
  126.  
  127.    /**
  128.     * Sets the style of the a list item identified by his given value.
  129.     *
  130.     * @version 1.0
  131.     * @since   0.1.1
  132.     * @author  Daniel Plücken <daniel@debakel.net>
  133.     * @access  public
  134.     * @param   string $str_value 
  135.     * @param   string $str_style_class 
  136.     * @param   string $str_link_style_class 
  137.     * @param   string $str_freestyle 
  138.     * @param   string $str_link_freestyle 
  139.     * @return  void 
  140.     */
  141.    function setMarkedValue(
  142.                             $str_value,
  143.                             $str_style_class "",
  144.                             $str_link_style_class "",
  145.                             $str_freestyle "",
  146.                             $str_link_freestyle ""
  147.                           )
  148.    {
  149.       $this->build();
  150.       parent::setMarkedValue(
  151.                               $str_value,
  152.                               $str_style_class,
  153.                               $str_link_style_class,
  154.                               $str_freestyle,
  155.                               $str_link_freestyle
  156.                             );
  157.    }
  158.    
  159.  
  160.  
  161.    /**
  162.     * Builds the alphabetic list.
  163.     *
  164.     * @version 1.0
  165.     * @since   0.1.1
  166.     * @author  Daniel Plücken <daniel@debakel.net>
  167.     * @access  public
  168.     * @param   string $str_before 
  169.     * @return  void 
  170.     */
  171.    function build()
  172.    {
  173.        static $already_build false;
  174.        
  175.        if $already_build )
  176.           return;
  177.        
  178.        for $i 0$i strlen$this->str_alphabet )$i++ )
  179.        {
  180.            if $this->str_alphabet[$i== " " )
  181.               $str_label "&nbsp;";
  182.            else
  183.               $str_label htmlentities$this->str_alphabet[$i);
  184.            
  185.            $this->addElement(
  186.                        $this->str_before_each_Label
  187.                       .$str_label
  188.                       .$this->str_behind_each_Label,
  189.                        $this->str_href,
  190.                        $this->str_alphabet[$i]
  191.                             );
  192.        }
  193.        
  194.        $already_build true;
  195.    }
  196.    
  197.  
  198.  
  199.  
  200.    /**
  201.     * Returns a generated string based on the attributes of this HTML-Object.
  202.     *
  203.     * @version 1.1
  204.     * @since   0.1.0
  205.     * @author  Daniel Plücken <daniel@debakel.net>
  206.     * @access  public
  207.     * @return  string 
  208.     */
  209.     function get()
  210.     {
  211.        $this->build();
  212.        
  213.        return parent::get();
  214.     }
  215. // End of class AlphabetFilter
  216. ?>

Documentation generated on Thu, 05 Jun 2008 19:10:05 +0200 by phpDocumentor 1.4.1