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

Source for file HTMLList.class.php

Documentation is available at HTMLList.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.  */
  10. if!defined"CLASSPATH" ) )
  11. {
  12.   echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
  13.   echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
  14.   exit();
  15. }
  16.  
  17. /**
  18.  * Including a class to format plain text.
  19.  */
  20. require_onceCLASSPATH."html/ABSTHTMLTag.class.php" );
  21.  
  22. /**
  23.  * Create HTML-Lists
  24.  *
  25.  * @package   html
  26.  * @version   0.1.1
  27.  * @author    Daniel Plücken <daniel@debakel.net>
  28.  * @license   http://www.gnu.org/copyleft/lesser.html
  29.  *             GNU Lesser General Public License
  30.  * @copyright Copyright (c) 2005 Daniel Plücken <daniel@debakel.net>
  31.  *
  32.  *  This library is free software; you can redistribute it and/or
  33.  *  modify it under the terms of the GNU Lesser General Public
  34.  *  License as published by the Free Software Foundation; either
  35.  *  version 2.1 of the License.
  36.  *
  37.  *  This library is distributed in the hope that it will be useful,
  38.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  39.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  40.  *  GNU Lesser General Public License for more details.
  41.  *
  42.  *  You should have received a copy of the GNU Lesser General
  43.  *  Public License along with this library; if not, write to the
  44.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  45.  *  Boston, MA 02111-1307 USA
  46.  */
  47. class HTMLList extends ABSTHTMLTag
  48. {
  49.    /**
  50.     * @var    string  kind
  51.     * @access private
  52.     */
  53.    var $kind = "ul";
  54.    /**
  55.     * @var    array  $list_arr 
  56.     * @access public
  57.     */
  58.    var $list_arr = array();
  59.    /**
  60.     * @var    array  $style_class_arr 
  61.     * @access public
  62.     */
  63.    var $style_class_arr = array();
  64.    /**
  65.     * @var    array  $freestyle_arr 
  66.     * @access public
  67.     */
  68.    var $freestyle_arr = array();
  69.    /**
  70.     * @var    array  $mouseover_arr 
  71.     * @access public
  72.     */
  73.    var $mouseover_arr = array();
  74.    /**
  75.     * @var    array  $mouseup_arr 
  76.     * @access public
  77.     */
  78.    var $mouseup_arr = array();
  79.    /**
  80.     * @var    array  $mouseout_arr 
  81.     * @access public
  82.     */
  83.    var $mouseout_arr = array();
  84.  
  85.  
  86.  
  87.    /**
  88.     * Constructor.
  89.     *
  90.     * @version 1.0
  91.     * @since   0.1.0
  92.     * @author  Daniel Plücken <daniel@debakel.net>
  93.     * @access  public
  94.     * @param   array    $label_arr 
  95.     * @param   array    $style_class_arr 
  96.     * @return  HTMLList 
  97.     */
  98.    function HTMLList$label_arr array()$style_class_arr array() )
  99.    {
  100.       $this->list_arr =$label_arr;
  101.       $this->style_class_arr =$style_class_arr;
  102.    }
  103.  
  104.  
  105.  
  106.    /**
  107.     * Adds an element to the list.
  108.     *
  109.     * @version 1.1
  110.     * @since   0.1.0
  111.     * @author  Daniel Plücken <daniel@debakel.net>
  112.     * @access  public
  113.     * @param   mixed   $mixed_label 
  114.     * @param   string  $style_class 
  115.     * @param   string  $freestyle 
  116.     * @param   string  $str_mouseup 
  117.     * @param   string  $str_mouseover 
  118.     * @param   string  $str_mouseout 
  119.     * @return  integer The insert position.
  120.     */
  121.    function addElement(
  122.                         $mixed_label,
  123.                         $str_style_class "",
  124.                         $str_freestyle "",
  125.                         $str_mouseup "",
  126.                         $str_mouseover "",
  127.                         $str_mouseout ""
  128.                       )
  129.    {
  130.      $this->list_arr[$mixed_label;
  131.      $this->style_class_arr[$str_style_class;
  132.      $this->freestyle_arr[$str_freestyle;
  133.      $this->mouseup_arr[$str_mouseup;
  134.      $this->mouseover_arr[$str_mouseover;
  135.      $this->mouseout_arr[$str_mouseout;
  136.      
  137.      return count$this->list_arr 1;
  138.    }
  139.  
  140.  
  141.  
  142.    /**
  143.     * Removes the element at $int-index. All elements behind the deleted element
  144.     * moving up by one position.
  145.     *
  146.     * @version 1.1
  147.     * @since   0.1.0
  148.     * @author  Daniel Plücken <daniel@debakel.net>
  149.     * @access  public
  150.     * @param   integer $int Index of the element to remove.
  151.     * @return  void 
  152.     */
  153.    function deleteElementAt&$int )
  154.    {
  155.      array_splice$this->list_arr$int);
  156.      array_splice$this->style_class_arr$int);
  157.      array_splice$this->freestyle_arr$int);
  158.      array_splice$this->mouseup_arr$int);
  159.      array_splice$this->mouseover_arr$int);
  160.      array_splice$this->mouseout_arr$int);
  161.    }
  162.  
  163.  
  164.  
  165.    /**
  166.     * Sets the the kind of this list ("ul" or "ol").
  167.     *
  168.     * @version 1.2
  169.     * @since   0.1.0
  170.     * @author  Daniel Plücken <daniel@debakel.net>
  171.     * @access  public
  172.     * @param   string $kind 
  173.     * @return  string 
  174.     */
  175.    function setKind$kind )
  176.    {
  177.       ifpreg_match"!^(?:o|u)l$!i"$kind ) )
  178.         $this->kind = strtolower$kind );
  179.    }
  180.  
  181.  
  182.    /**
  183.     * Returns a generated string based on the attributes of this HTML-Object.
  184.     *
  185.     * @version 1.2
  186.     * @since   0.1.0
  187.     * @author  Daniel Plücken <daniel@debakel.net>
  188.     * @access  public
  189.     * @return  string 
  190.     */
  191.    function get()
  192.    {
  193.       $this->idExists$this->idtrue );
  194.       
  195.       
  196.       $out  "<!--\r\n\r\n   LIST\r\n "
  197.                          ."* -----\r\n "
  198.                          ."* -----\r\n "
  199.                          ."* -----\r\n-->";
  200.       $out .= "<".$this->kind." "
  201.              .!empty$this->id )
  202.                 ? "id=\"".$this->id."\""
  203.                  ."\r\n       "
  204.                 : ""
  205.               )
  206.              .!empty$this->style_class )
  207.                 ? "class=\"".$this->style_class."\""
  208.                  ."\r\n       "
  209.                 : ""
  210.               )
  211.              .!empty$this->mouseup )
  212.                 ? "onMouseUp=\"".$this->mouseup."\""
  213.                  ."\r\n       "
  214.                 : ""
  215.               )
  216.              .!empty$this->mouseout )
  217.                 ? "onMouseOut=\"".$this->mouseout."\""
  218.                  ."\r\n       "
  219.                 : ""
  220.               )
  221.              .!empty$this->mouseover )
  222.                 ? "onMouseOver=\"".$this->mouseover."\""
  223.                  ."\r\n       "
  224.                 : ""
  225.               )
  226.              .(
  227.                 !empty$this->freestyle )
  228.                 ? "style=\"".$this->freestyle."\""
  229.                  ."\r\n       "
  230.                 : ""
  231.               )
  232.              .!empty$this->other_attributes )
  233.                 ? $this->other_attributes."\r\n"
  234.                 : ""
  235.               )
  236.           ."   ><!--\r\n";
  237.       
  238.       for $i 0$i count$this->list_arr )$i++ )
  239.           $out .= "   --><li "
  240.                            .(
  241.                               !empty$this->style_class_arr[$i)
  242.                               ? "class=\"".$this->style_class_arr[$i]."\""
  243.                                ."\r\n          "
  244.                               : ""
  245.                             )
  246.                            .(
  247.                               !empty$this->mouseup_arr[$i)
  248.                               ? "onMouseup=\"".$this->mouseup_arr[$i]."\""
  249.                                ."\r\n          "
  250.                               : ""
  251.                             )
  252.                            .(
  253.                               !empty$this->mouseover_arr[$i)
  254.                               ? "onMouseover=\"".$this->mouseover_arr[$i]."\""
  255.                                ."\r\n          "
  256.                               : ""
  257.                             )
  258.                            .(
  259.                               !empty$this->mouseout_arr[$i)
  260.                               ? "onMouseout=\"".$this->mouseout_arr[$i]."\""
  261.                                ."\r\n          "
  262.                               : ""
  263.                             )
  264.                            .(
  265.                               !empty$this->freestyle_arr[$i)
  266.                               ? "style=\"".$this->freestyle_arr[$i]."\""
  267.                                ."\r\n          "
  268.                               : ""
  269.                             )."\r\n      >".(
  270.                                     is_object$this->list_arr[$i)
  271.                                     ? $this->list_arr[$i]->get()
  272.                                     : $this->list_arr[$i]
  273.                                       )."</li><!--\r\n";
  274.       
  275.       $out .= "--></".$this->kind.">";
  276.       $out .= "<!--\r\n * -----\r\n "
  277.                       ."* -----\r\n "
  278.                       ."   LIST\r\n\r\n-->";
  279.       
  280.       return $out;
  281.    }
  282. // End of class HTMLList
  283. ?>

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