Show
Ignore:
Timestamp:
03/09/06 12:50:58 (6 years ago)
Author:
haas
Message:

improve various test, documents

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/trax/vendor/trax/action_view/helpers.php

    r160 r165  
    3030 
    3131/** 
    32  * 
    33  *  @package PHPonTrax 
     32 *  Basic helper functions 
    3433 */ 
    3534class Helpers { 
     
    4039    function __construct($object_name = null, $attribute_name = null) { 
    4140        if(substr($object_name, -2) == "[]") { 
    42             $auto_index = true;              
    43         } 
     41            $auto_index = true; 
     42        } else { 
     43            $auto_index = false; 
     44        } 
    4445        $this->auto_index = false; 
    4546        $this->object_name = str_replace("[]", "", $object_name);      
     
    8283     
    8384    /** 
    84      * 
     85     *  Convert array of tag attribute names and values to string 
     86     * 
     87     *  @param string[] $options  
     88     *  @return string 
    8589     */ 
    8690    protected function tag_options($options) { 
     
    9296            sort($html); 
    9397            $html = implode(" ", $html); 
    94         } 
    95         return $html; 
    96     } 
    97  
    98     /** 
    99      * 
     98            return $html; 
     99        } else { 
     100            return ''; 
     101        } 
     102    } 
     103 
     104    /** 
     105     *  Convert selected attributes to proper XML boolean form 
     106     * 
     107     *  @uses boolean_attribute() 
     108     *  @param string[] $options 
     109     *  @return string[] Input argument with selected attributes converted 
     110     *                   to proper XML boolean form 
    100111     */ 
    101112    protected function convert_options($options = array()) { 
    102113        foreach(array('disabled', 'readonly', 'multiple') as $a) { 
    103             $this->boolean_attribute(&$options, $a); 
     114            $this->boolean_attribute($options, $a); 
    104115        } 
    105116        return $options; 
     
    107118 
    108119    /** 
    109      * 
     120     *  Convert an attribute to proper XML boolean form 
     121     * 
     122     *  @param string[] $options 
     123     *  @param string $attribute 
     124     *  @return void Contents of $options have been converted 
    110125     */ 
    111126    protected function boolean_attribute(&$options, $attribute) { 
     
    118133     
    119134    /** 
    120      *  
    121      * Returns a CDATA section for the given +content+.  CDATA sections 
    122      * are used to escape blocks of text containing characters which would 
    123      * otherwise be recognized as markup. CDATA sections begin with the string 
    124      * <tt>&lt;![CDATA[</tt> and end with (and may not contain) the string  
    125      * <tt>]]></tt>.  
     135     *  Wrap CDATA begin and end tags around argument 
     136     * 
     137     *  Returns a CDATA section for the given +content+.  CDATA sections 
     138     *  are used to escape blocks of text containing characters which would 
     139     *  otherwise be recognized as markup. CDATA sections begin with the string 
     140     *  <tt>&lt;![CDATA[</tt> and end with (and may not contain) the string  
     141     *  <tt>]]></tt>.  
     142     *  @param string $content  Content to wrap 
     143     *  @return string          Wrapped argument 
    126144     */ 
    127145    function cdata_section($content) { 
     
    136154     *  Example: tag("input", array("type" => "text")); 
    137155     * <input type="text" /> 
     156     *  @uses tag_options() 
     157     *  @param string $name    Tag name 
     158     *  @param string[] $options Tag attributes to apply 
     159     *  @param boolean $open 
     160     *  <ul> 
     161     *    <li>true =>  make opening tag (end with '>')</li> 
     162     *    <li>false => make self-terminating tag (end with ' \>')</li> 
     163     *  </ul> 
     164     *  @return string The tag, followed by "\n" 
    138165     */ 
    139166    function tag($name, $options = array(), $open = false) { 
     
    149176     *  Example: content_tag("p", "Hello world!"); 
    150177     *  Result: <p>Hello world!</p> 
    151      *  Example: content_tag("div", content_tag("p", "Hello world!"), array("class" => "strong")) => 
     178     *  Example: content_tag("div", content_tag("p", "Hello world!"), 
     179     *           array("class" => "strong")) => 
    152180     *  Result:<div class="strong"><p>Hello world!</p></div> 
     181     *  @uses tag_options() 
     182     *  @param string $name    Tag to wrap around $content 
     183     *  @param string $content Text to put between tags 
     184     *  @param string[] $options Tag attributes to apply 
     185     *  @return string Text wrapped with tag and attributes, 
     186     *                 followed by "\n" 
    153187     */ 
    154188    function content_tag($name, $content, $options = array()) { 
    155         $html .= "<$name "; 
     189        $html = "<$name "; 
    156190        $html .= $this->tag_options($options); 
    157191        $html .= ">$content</$name>"; 
     
    169203 
    170204/** 
    171  *  Avialble functions for use in views 
     205 *  Create a Helpers object and call its content_tag() method 
     206 * 
     207 *  @see Helpers::content_tag() 
     208 *  @param string $name    Tag to wrap around $content 
     209 *  @param string $content Text to put between tags 
     210 *  @param string[] $options Tag attributes to apply 
     211 *  @return string Text wrapped with tag and attributes, 
     212 *                 followed by "\n" 
    172213 */ 
    173214function content_tag() { 
     
    177218} 
    178219 
     220/** 
     221 *  Create a Helpers object and call its tag() method 
     222 * 
     223 *  @see Helpers::tag() 
     224 *  @param string $name    Tag name 
     225 *  @param string[] $options Tag attributes to apply 
     226 *  @param boolean $open 
     227 *  <ul> 
     228 *    <li>true =>  make opening tag (end with '>')</li> 
     229 *    <li>false => make self-terminating tag (end with ' \>')</li> 
     230 *  </ul> 
     231 *  @return string The tag, followed by "\n" 
     232 */ 
    179233function tag() { 
    180234    $helper = new Helpers(); 
     
    183237} 
    184238 
     239/** 
     240 *  Create a Helpers object and call its cdata_section() method 
     241 */ 
    185242function cdata_section() { 
    186243    $helper = new Helpers(); 
     
    189246} 
    190247 
     248// -- set Emacs parameters -- 
     249// Local variables: 
     250// tab-width: 4 
     251// c-basic-offset: 4 
     252// c-hanging-comment-ender-p: nil 
     253// indent-tabs-mode: nil 
     254// End: 
    191255?>