Show
Ignore:
Timestamp:
02/23/06 20:09:13 (6 years ago)
Author:
john
Message:

added in phpDoc commenting tests docs - Walt

Location:
trunk/trax/vendor/trax/action_view
Files:
7 modified

Legend:

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

    r128 r138  
    11<?php 
    2 # $Id$ 
    3 # 
    4 # Copyright (c) 2005 John Peterson 
    5 # 
    6 # Permission is hereby granted, free of charge, to any person obtaining 
    7 # a copy of this software and associated documentation files (the 
    8 # "Software"), to deal in the Software without restriction, including 
    9 # without limitation the rights to use, copy, modify, merge, publish, 
    10 # distribute, sublicense, and/or sell copies of the Software, and to 
    11 # permit persons to whom the Software is furnished to do so, subject to 
    12 # the following conditions: 
    13 # 
    14 # The above copyright notice and this permission notice shall be 
    15 # included in all copies or substantial portions of the Software. 
    16 # 
    17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
    18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
    19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
    20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
    21 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
    22 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
    23 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     2/** 
     3 *  File containing the Helpers class and associated functions 
     4 * 
     5 *  (PHP 5) 
     6 * 
     7 *  @package PHPonTrax 
     8 *  @version $Id$ 
     9 *  @copyright (c) 2005 John Peterson 
     10 * 
     11 *  Permission is hereby granted, free of charge, to any person obtaining 
     12 *  a copy of this software and associated documentation files (the 
     13 *  "Software"), to deal in the Software without restriction, including 
     14 *  without limitation the rights to use, copy, modify, merge, publish, 
     15 *  distribute, sublicense, and/or sell copies of the Software, and to 
     16 *  permit persons to whom the Software is furnished to do so, subject to 
     17 *  the following conditions: 
     18 * 
     19 *  The above copyright notice and this permission notice shall be 
     20 *  included in all copies or substantial portions of the Software. 
     21 * 
     22 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
     23 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
     24 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
     25 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
     26 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
     27 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
     28 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     29 */ 
    2430 
     31/** 
     32 * 
     33 *  @package PHPonTrax 
     34 */ 
    2535class Helpers { 
    2636 
     37    /** 
     38     * 
     39     */ 
    2740    function __construct() { 
    2841        $this->controller_name = $GLOBALS['current_controller_name']; 
     
    3144    } 
    3245 
     46    /** 
     47     * 
     48     */ 
    3349    function tag_options($options) { 
    3450        if(count($options)) { 
     
    4359    } 
    4460 
    45     # Example: tag("br"); 
    46     # Results: <br /> 
    47     # Example: tag("input", array("type" => "text")); 
    48     # <input type="text" /> 
     61    /** 
     62     *  Generate an HTML or XML tag with optional attributes 
     63     * 
     64     *  Example: tag("br"); 
     65     *   Results: <br /> 
     66     *  Example: tag("input", array("type" => "text")); 
     67     * <input type="text" /> 
     68     */ 
    4969    function tag($name, $options = array(), $open = false) { 
    5070        $html = "<$name "; 
     
    5474    } 
    5575 
    56     # Example: content_tag("p", "Hello world!"); 
    57     # Result: <p>Hello world!</p> 
    58     # Example: content_tag("div", content_tag("p", "Hello world!"), array("class" => "strong")) => 
    59     # Result:<div class="strong"><p>Hello world!</p></div> 
     76    /** 
     77     *  Generate an open/close pair of tags with content between 
     78     * 
     79     *  Example: content_tag("p", "Hello world!"); 
     80     *  Result: <p>Hello world!</p> 
     81     *  Example: content_tag("div", content_tag("p", "Hello world!"), array("class" => "strong")) => 
     82     *  Result:<div class="strong"><p>Hello world!</p></div> 
     83     */ 
    6084    function content_tag($name, $content, $options = array()) { 
    6185        $html .= "<$name "; 
     
    6589    } 
    6690 
    67     # Returns the URL for the set of $options provided. 
     91    /** 
     92     *  Return the URL for the set of $options provided. 
     93     */ 
    6894    function url_for($options = array()) { 
    6995        $url_base = null; 
     
    132158} 
    133159 
    134  
    135 ################################################################################################ 
    136 ## Avialble functions for use in views 
    137 ################################################################################################ 
     160/** 
     161 *  Avialble functions for use in views 
     162 */ 
    138163function content_tag() { 
    139164    $helper = new Helpers(); 
     
    142167} 
    143168 
     169/** 
     170 * 
     171 */ 
    144172function url_for($options = array()) { 
    145173    $helper = new Helpers(); 
  • trunk/trax/vendor/trax/action_view/helpers/active_record_helper.php

    r128 r138  
    11<?php 
    2 # $Id$ 
    3 # 
    4 # Copyright (c) 2005 John Peterson 
    5 # 
    6 # Permission is hereby granted, free of charge, to any person obtaining 
    7 # a copy of this software and associated documentation files (the 
    8 # "Software"), to deal in the Software without restriction, including 
    9 # without limitation the rights to use, copy, modify, merge, publish, 
    10 # distribute, sublicense, and/or sell copies of the Software, and to 
    11 # permit persons to whom the Software is furnished to do so, subject to 
    12 # the following conditions: 
    13 # 
    14 # The above copyright notice and this permission notice shall be 
    15 # included in all copies or substantial portions of the Software. 
    16 # 
    17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
    18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
    19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
    20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
    21 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
    22 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
    23 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
    24  
     2/** 
     3 *  File containing ActiveRecordHelper class and support functions 
     4 * 
     5 *  (PHP 5) 
     6 * 
     7 *  @package PHPonTrax 
     8 *  @version $Id$ 
     9 *  @copyright (c) 2005 John Peterson 
     10 * 
     11 *  Permission is hereby granted, free of charge, to any person obtaining 
     12 *  a copy of this software and associated documentation files (the 
     13 *  "Software"), to deal in the Software without restriction, including 
     14 *  without limitation the rights to use, copy, modify, merge, publish, 
     15 *  distribute, sublicense, and/or sell copies of the Software, and to 
     16 *  permit persons to whom the Software is furnished to do so, subject to 
     17 *  the following conditions: 
     18 * 
     19 *  The above copyright notice and this permission notice shall be 
     20 *  included in all copies or substantial portions of the Software. 
     21 * 
     22 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
     23 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
     24 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
     25 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
     26 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
     27 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
     28 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     29 */ 
     30 
     31/** 
     32 * 
     33 *  @package PHPonTrax 
     34 */ 
    2535class ActiveRecordHelper extends Helpers { 
    2636     
    2737    public $scaffolding = 0; 
    2838 
    29     # Returns a default input tag for the type of object returned by the method. Example 
    30     # (title is a VARCHAR column and holds "Hello World"): 
    31     #   input("post", "title") => 
    32     #     <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /> 
     39    /** 
     40     *  Returns a default input tag for the type of object returned by the method. Example 
     41     *  (title is a VARCHAR column and holds "Hello World"): 
     42     *   input("post", "title") => 
     43     *     <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /> 
     44     */ 
    3345    function input($object_name, $attribute_name, $options = array()) { 
    3446        return $this->to_tag($object_name, $attribute_name, $options);         
    3547    } 
    3648     
     49    /** 
     50     * 
     51     */ 
    3752    function input_scaffolding($object_name, $attribute_name, $options = array()) { 
    3853        return $this->to_scaffold_tag($object_name, $attribute_name, $options);         
    3954    } 
    4055 
    41     # Returns an entire form with input tags and everything for a specified Active Record object. Example 
    42     # (post is a new record that has a title using VARCHAR and a body using TEXT): 
    43     #   form("post") => 
    44     #     <form action='/post/create' method='post'> 
    45     #       <p> 
    46     #         <label for="post_title">Title</label><br /> 
    47     #         <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /> 
    48     #       </p> 
    49     #       <p> 
    50     #         <label for="post_body">Body</label><br /> 
    51     #         <textarea cols="40" id="post_body" name="post[body]" rows="20"> 
    52     #           Back to the hill and over it again! 
    53     #         </textarea> 
    54     #       </p> 
    55     #       <input type='submit' value='Create' /> 
    56     #     </form> 
    57     # 
    58     # It's possible to specialize the form builder by using a different action name and by supplying another 
    59     # block renderer. Example (entry is a new record that has a message attribute using VARCHAR): 
    60     # 
    61     #   form("entry", array('action' => "sign", 'input_block' =>  
    62     #        'foreach($record->content_columns() as $column_name => $column) $contents .= Inflector::humanize($column_name) . ": " . input($record, $column) . "<br />"')) => 
    63     # 
    64     #     <form action='/post/sign' method='post'> 
    65     #       Message: 
    66     #       <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /><br /> 
    67     #       <input type='submit' value='Sign' /> 
    68     #     </form> 
    69     # 
    70     # It's also possible to add additional content to the form by giving it a block, such as: 
    71     # 
    72     #   form("entry", array('action' => "sign", 'block' => 
    73     #     content_tag("b", "Department") . 
    74     #     collection_select("department", "id", $departments, "id", "name")) 
    75     #   ) 
     56    /** 
     57     * Returns an entire form with input tags and everything for a specified Active Record object. Example 
     58     * (post is a new record that has a title using VARCHAR and a body using TEXT): 
     59     *   form("post") => 
     60     *     <form action='/post/create' method='post'> 
     61     *       <p> 
     62     *         <label for="post_title">Title</label><br /> 
     63     *         <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /> 
     64     *       </p> 
     65     *       <p> 
     66     *         <label for="post_body">Body</label><br /> 
     67     *         <textarea cols="40" id="post_body" name="post[body]" rows="20"> 
     68     *           Back to the hill and over it again! 
     69     *         </textarea> 
     70     *       </p> 
     71     *       <input type='submit' value='Create' /> 
     72     *     </form> 
     73     * 
     74     *  It's possible to specialize the form builder by using a different action name and by supplying another 
     75     *  block renderer. Example (entry is a new record that has a message attribute using VARCHAR): 
     76     * 
     77     *   form("entry", array('action' => "sign", 'input_block' =>  
     78     *        'foreach($record->content_columns() as $column_name => $column) $contents .= Inflector::humanize($column_name) . ": " . input($record, $column) . "<br />"')) => 
     79     * 
     80     *     <form action='/post/sign' method='post'> 
     81     *       Message: 
     82     *       <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /><br /> 
     83     *       <input type='submit' value='Sign' /> 
     84     *     </form> 
     85     * 
     86     *  It's also possible to add additional content to the form by giving it a block, such as: 
     87     * 
     88     *   form("entry", array('action' => "sign", 'block' => 
     89     *     content_tag("b", "Department") . 
     90     *     collection_select("department", "id", $departments, "id", "name")) 
     91     *   ) 
     92     */ 
    7693    function form($record_name, $options = array()) { 
    7794        $record = $this->object($record_name); 
     
    89106    } 
    90107 
    91     /* # Returns a string containing the error message attached to the +method+ on the +object+, if one exists. 
    92     # This error message is wrapped in a DIV tag, which can be specialized to include both a +prepend_text+ and +append_text+ 
    93     # to properly introduce the error and a +css_class+ to style it accordingly. Examples (post has an error message 
    94     # "can't be empty" on the title attribute): 
    95     # 
    96     #   <?= error_message_on("post", "title") ?> => 
    97     #     <div class="formError">can't be empty</div> 
    98     # 
    99     #   <?= error_message_on "post", "title", "Title simply ", " (or it won't work)", "inputError" ?> => 
    100     #     <div class="inputError">Title simply can't be empty (or it won't work)</div> */ 
     108    /** 
     109     *  Returns a string containing the error message attached to the +method+ on the +object+, if one exists. 
     110     *  This error message is wrapped in a DIV tag, which can be specialized to include both a +prepend_text+ and +append_text+ 
     111     *  to properly introduce the error and a +css_class+ to style it accordingly. Examples (post has an error message 
     112     *  "can't be empty" on the title attribute): 
     113     * 
     114     *   <?= error_message_on("post", "title") ?> => 
     115     *     <div class="formError">can't be empty</div> 
     116     * 
     117     *   <?= error_message_on "post", "title", "Title simply ", " (or it won't work)", "inputError" ?> => 
     118     *     <div class="inputError">Title simply can't be empty (or it won't work)</div> 
     119     */ 
    101120    function error_message_on($object_name, $attribute_name, $prepend_text = "", $append_text = "", $css_class = "formError") { 
    102121        $this->object_name = $object_name; 
     
    108127    } 
    109128 
    110     # Returns a string with a div containing all the error messages for the object located as an instance variable by the name 
    111     # of <tt>object_name</tt>. This div can be tailored by the following options: 
    112     # 
    113     # * <tt>header_tag</tt> - Used for the header of the error div (default: h2) 
    114     # * <tt>id</tt> - The id of the error div (default: errorExplanation) 
    115     # * <tt>class</tt> - The class of the error div (default: errorExplanation) 
     129    /** 
     130     *  Returns a string with a div containing all the error messages for the object located as an instance variable by the name 
     131     *  of <tt>object_name</tt>. This div can be tailored by the following options: 
     132     * 
     133     * <tt>header_tag</tt> - Used for the header of the error div (default: h2) 
     134     * <tt>id</tt> - The id of the error div (default: errorExplanation) 
     135     * <tt>class</tt> - The class of the error div (default: errorExplanation) 
     136     */ 
    116137    function error_messages_for($object_name, $options = array()) { 
    117138        if(is_object($object_name)) { 
     
    136157    } 
    137158 
     159    /** 
     160     * 
     161     */ 
    138162    function all_input_tags($record, $record_name, $options) { 
    139163        //if($record_name) $this->object_name = $record_name; 
     
    153177    } 
    154178 
     179    /** 
     180     * 
     181     */ 
    155182    function default_input_block() { 
    156183        if($this->scaffolding) { 
     
    161188    } 
    162189     
     190    /** 
     191     * 
     192     */ 
    163193    function to_tag($object_name, $attribute_name, $options = array()) { 
    164194        $this->object_name = $object_name; 
     
    200230    } 
    201231 
     232    /** 
     233     * 
     234     */ 
    202235    function to_scaffold_tag($object_name, $attribute_name, $options = array()) { 
    203236        $this->object_name = $object_name; 
     
    237270    } 
    238271 
     272    /** 
     273     * 
     274     */ 
    239275    function object($object_name = null) { 
    240276        $object_name = $object_name ? $object_name : $this->object_name; 
     
    244280    } 
    245281 
     282    /** 
     283     * 
     284     */ 
    246285    function tag_without_error_wrapping() { 
    247286        $args = func_get_args(); 
     
    249288    } 
    250289 
     290    /** 
     291     * 
     292     */ 
    251293    function tag($name, $options = array()) { 
    252294        if(count($this->object()->errors)) { 
     
    257299    } 
    258300 
     301    /** 
     302     * 
     303     */ 
    259304    function content_tag_without_error_wrapping() { 
    260305        $args = func_get_args(); 
     
    262307    } 
    263308 
     309    /** 
     310     * 
     311     */ 
    264312    function content_tag($name, $value, $options = array()) { 
    265313        if (count($this->object()->errors)) { 
     
    270318    } 
    271319 
     320    /** 
     321     * 
     322     */ 
    272323    function to_date_select_tag_without_error_wrapping() { 
    273324        $form = new DateHelper($this->object_name, $this->attribute_name); 
     
    276327    } 
    277328 
     329    /** 
     330     * 
     331     */ 
    278332    function to_date_select_tag($options = array()) { 
    279333        if (count($this->object()->errors)) { 
     
    284338    } 
    285339 
     340    /** 
     341     * 
     342     */ 
    286343    function to_datetime_select_tag_without_error_wrapping() { 
    287344        $form = new DateHelper($this->object_name, $this->attribute_name); 
     
    290347    } 
    291348 
     349    /** 
     350     * 
     351     */ 
    292352    function to_datetime_select_tag($options = array()) { 
    293353        if (count($this->object()->errors)) { 
     
    298358    } 
    299359 
     360    /** 
     361     * 
     362     */ 
    300363    function error_wrapping($html_tag, $has_error) { 
    301364        return ($has_error ? '<span class="fieldWithErrors">' . $html_tag . '</span>' : $html_tag); 
    302365    } 
    303366 
     367    /** 
     368     * 
     369     */ 
    304370    function error_message() { 
    305371        return $this->object()->errors[$this->attribute_name]; 
    306372    } 
    307373 
     374    /** 
     375     * 
     376     */ 
    308377    function column_type() { 
    309378        $column = $this->object()->column_for_attribute($this->attribute_name); 
     
    313382} 
    314383 
    315 ################################################################################################ 
    316 ## Avialble functions for use in views 
    317 ################################################################################################ 
    318 # error_message_on($object, $attribute_name, $prepend_text = "", $append_text = "", $css_class = "formError") 
     384/** 
     385 * Avialble functions for use in views 
     386 * error_message_on($object, $attribute_name, $prepend_text = "", $append_text = "", $css_class = "formError") 
     387 */ 
    319388function error_message_on() { 
    320389    $ar_helper = new ActiveRecordHelper(); 
     
    323392} 
    324393 
    325 # error_messages_for($object_name, $options = array()) 
     394/** 
     395 * error_messages_for($object_name, $options = array()) 
     396 */ 
    326397function error_messages_for() { 
    327398    $ar_helper = new ActiveRecordHelper(); 
     
    330401} 
    331402 
    332 # form($record_name, $options = array()) 
     403/** 
     404 *  form($record_name, $options = array()) 
     405 */ 
    333406function form() { 
    334407    $ar_helper = new ActiveRecordHelper(); 
     
    337410} 
    338411 
    339 # Returns a default input tag for the type of object returned by the method. Example 
    340 # (title is a VARCHAR column and holds "Hello World"): 
    341 #   input("post", "title") => 
    342 #     <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /> 
     412/** 
     413 *  Returns a default input tag for the type of object returned by the method. Example 
     414 *  (title is a VARCHAR column and holds "Hello World"): 
     415 *   input("post", "title") => 
     416 *    <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /> 
     417 */ 
    343418function input() { 
    344419    $ar_helper = new ActiveRecordHelper(); 
     
    347422} 
    348423 
     424/** 
     425 * 
     426 */ 
    349427function input_scaffolding() { 
    350428    $ar_helper = new ActiveRecordHelper(); 
  • trunk/trax/vendor/trax/action_view/helpers/date_helper.php

    r131 r138  
    11<?php 
    2 # $Id$ 
    3 # 
    4 # Copyright (c) 2005 John Peterson 
    5 # 
    6 # Permission is hereby granted, free of charge, to any person obtaining 
    7 # a copy of this software and associated documentation files (the 
    8 # "Software"), to deal in the Software without restriction, including 
    9 # without limitation the rights to use, copy, modify, merge, publish, 
    10 # distribute, sublicense, and/or sell copies of the Software, and to 
    11 # permit persons to whom the Software is furnished to do so, subject to 
    12 # the following conditions: 
    13 # 
    14 # The above copyright notice and this permission notice shall be 
    15 # included in all copies or substantial portions of the Software. 
    16 # 
    17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
    18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
    19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
    20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
    21 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
    22 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
    23 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
    24  
     2/** 
     3 *  File containing the DateHelper class and support functions 
     4 * 
     5 *  (PHP 5) 
     6 * 
     7 *  @package PHPonTrax 
     8 *  @version $Id$ 
     9 *  @copyright (c) 2005 John Peterson 
     10 * 
     11 *  Permission is hereby granted, free of charge, to any person obtaining 
     12 *  a copy of this software and associated documentation files (the 
     13 *  "Software"), to deal in the Software without restriction, including 
     14 *  without limitation the rights to use, copy, modify, merge, publish, 
     15 *  distribute, sublicense, and/or sell copies of the Software, and to 
     16 *  permit persons to whom the Software is furnished to do so, subject to 
     17 *  the following conditions: 
     18 * 
     19 *  The above copyright notice and this permission notice shall be 
     20 *  included in all copies or substantial portions of the Software. 
     21 * 
     22 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
     23 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
     24 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
     25 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
     26 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
     27 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
     28 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     29 */ 
     30 
     31/** 
     32 * 
     33 *  @package PHPonTrax 
     34 */ 
    2535class DateHelper extends Helpers { 
    2636    public $selected_years = array(); 
     37    /** 
     38     * 
     39     */ 
    2740    function __construct($object_name = null, $attribute_name = null) { 
    2841        parent::__construct(); 
     
    3144    } 
    3245 
     46    /** 
     47     * 
     48     */ 
    3349    private function value() { 
    3450        if(!$value = $this->check_request_for_value()) { 
     
    6682    } 
    6783 
     84    /** 
     85     * 
     86     */ 
    6887    private function object($object_name = null) { 
    6988        $object_name = $object_name ? $object_name : $this->object_name; 
     
    7190    } 
    7291 
     92    /** 
     93     * 
     94     */ 
    7395    private function select_html($type, $options, $prefix = null, $include_blank = false, $discard_type = false) { 
    7496        $select_html  = "<select name=\"$prefix";        
     
    85107    } 
    86108 
     109    /** 
     110     * 
     111     */ 
    87112    private function leading_zero_on_single_digits($number) { 
    88113        return $number > 9 ? $number : "0$number"; 
     
    93118    } 
    94119         
    95     #   datetime_select("post", "written_on") 
    96     #   datetime_select("post", "written_on", array("start_year" => 1995)) 
     120    /** 
     121     *   datetime_select("post", "written_on") 
     122     *   datetime_select("post", "written_on", array("start_year" => 1995)) 
     123     */ 
    97124    function datetime_select($options = array()) {      
    98125        return $this->to_datetime_select_tag($options); 
    99126    }  
    100127     
    101     #   datetime_select("post", "written_on") 
    102     #   datetime_select("post", "written_on", array("start_year" => 1995)) 
     128    /** 
     129     *   datetime_select("post", "written_on") 
     130     *   datetime_select("post", "written_on", array("start_year" => 1995)) 
     131     */ 
    103132    function date_select($options = array()) {    
    104133        return $this->to_date_select_tag($options); 
     
    125154    }                
    126155 
    127     # Returns a set of html select-tags (one for year, month, and day) pre-selected with the +date+. 
     156    /** 
     157     * Returns a set of html select-tags (one for year, month, and day) pre-selected with the +date+. 
     158     */ 
    128159    function select_date($date = null, $options = array()) { 
    129160        $date = is_null($date) ? date("Y-m-d") : $date; 
     
    133164    } 
    134165 
    135     # Returns a set of html select-tags (one for year, month, day, hour, and minute) preselected the +datetime+. 
     166    /** 
     167     * Returns a set of html select-tags (one for year, month, day, hour, and minute) preselected the +datetime+. 
     168     */ 
    136169    function select_datetime($datetime = null, $options = array()) { 
    137170        $datetime = is_null($datetime) ? date("Y-m-d H:i:s") : $datetime; 
     
    143176    } 
    144177 
    145     # Returns a set of html select-tags (one for hour and minute) 
     178    /** 
     179     * Returns a set of html select-tags (one for hour and minute) 
     180     */ 
    146181    function select_time($datetime = null, $options = array()) { 
    147182        $datetime = is_null($datetime) ? date("Y-m-d H:i:s") : $datetime; 
     
    151186    } 
    152187 
    153     # Returns a select tag with options for each of the seconds 0 through 59 with the current second selected. 
    154     # The <tt>second</tt> can also be substituted for a second number. 
    155     # Override the field name using the <tt>:field_name</tt> option, 'second' by default. 
     188    /** 
     189     *  Returns a select tag with options for each of the seconds 0 through 59 with the current second selected. 
     190     *  The <tt>second</tt> can also be substituted for a second number. 
     191     *  Override the field name using the <tt>:field_name</tt> option, 'second' by default. 
     192     */ 
    156193    function select_second($datetime, $options = array()) { 
    157194        $second_options = ""; 
     
    175212    } 
    176213 
    177     # Returns a select tag with options for each of the minutes 0 through 59 with the current minute selected. 
    178     # Also can return a select tag with options by <tt>minute_step</tt> from 0 through 59 with the 00 minute selected 
    179     # The <tt>minute</tt> can also be substituted for a minute number. 
    180     # Override the field name using the <tt>:field_name</tt> option, 'minute' by default. 
     214    /** 
     215     *  Returns a select tag with options for each of the minutes 0 through 59 with the current minute selected. 
     216     *  Also can return a select tag with options by <tt>minute_step</tt> from 0 through 59 with the 00 minute selected 
     217     *  The <tt>minute</tt> can also be substituted for a minute number. 
     218     *  Override the field name using the <tt>:field_name</tt> option, 'minute' by default. 
     219     */ 
    181220    function select_minute($datetime, $options = array()) { 
    182221        $minute_options = ""; 
     
    200239    } 
    201240 
    202     # Returns a select tag with options for each of the hours 0 through 23 with the current hour selected. 
    203     # The <tt>hour</tt> can also be substituted for a hour number. 
    204     # Override the field name using the <tt>:field_name</tt> option, 'hour' by default. 
     241    /** 
     242     *  Returns a select tag with options for each of the hours 0 through 23 with the current hour selected. 
     243     *  The <tt>hour</tt> can also be substituted for a hour number. 
     244     *  Override the field name using the <tt>:field_name</tt> option, 'hour' by default. 
     245     */ 
    205246    function select_hour($datetime, $options = array()) { 
    206247        $hour_options = ""; 
     
    225266    } 
    226267 
    227     # Returns a select tag with options for each of the days 1 through 31 with the current day selected. 
    228     # The <tt>date</tt> can also be substituted for a hour number. 
    229     # Override the field name using the <tt>:field_name</tt> option, 'day' by default. 
     268    /** 
     269     *  Returns a select tag with options for each of the days 1 through 31 with the current day selected. 
     270     *  The <tt>date</tt> can also be substituted for a hour number. 
     271     *  Override the field name using the <tt>:field_name</tt> option, 'day' by default. 
     272     */ 
    230273    function select_day($datetime, $options = array()) { 
    231274        $day_options = ""; 
     
    249292    } 
    250293 
    251     # Returns a select tag with options for each of the months January through December with the current month selected. 
    252     # The month names are presented as keys (what's shown to the user) and the month numbers (1-12) are used as values 
    253     # (what's submitted to the server). It's also possible to use month numbers for the presentation instead of names -- 
    254     # set the <tt>:use_month_numbers</tt> key in +options+ to true for this to happen. If you want both numbers and names, 
    255     # set the <tt>:add_month_numbers</tt> key in +options+ to true. Examples: 
    256     # 
    257     #   select_month(Date.today)                             # Will use keys like "January", "March" 
    258     #   select_month(Date.today, :use_month_numbers => true) # Will use keys like "1", "3" 
    259     #   select_month(Date.today, :add_month_numbers => true) # Will use keys like "1 - January", "3 - March" 
    260     # 
    261     # Override the field name using the <tt>:field_name</tt> option, 'month' by default. 
     294    /** 
     295     *  Returns a select tag with options for each of the months January through December with the current month selected. 
     296     *  The month names are presented as keys (what's shown to the user) and the month numbers (1-12) are used as values 
     297     *  (what's submitted to the server). It's also possible to use month numbers for the presentation instead of names -- 
     298     *  set the <tt>:use_month_numbers</tt> key in +options+ to true for this to happen. If you want both numbers and names, 
     299     *  set the <tt>:add_month_numbers</tt> key in +options+ to true. Examples: 
     300     * 
     301     *   select_month(Date.today)                             # Will use keys like "January", "March" 
     302    *   select_month(Date.today, :use_month_numbers => true) # Will use keys like "1", "3" 
     303    *   select_month(Date.today, :add_month_numbers => true) # Will use keys like "1 - January", "3 - March" 
     304    * 
     305    *  Override the field name using the <tt>:field_name</tt> option, 'month' by default. 
     306   */ 
    262307    function select_month($date, $options = array()) { 
    263308        $month_options = ""; 
     
    287332    } 
    288333 
    289     # Returns a select tag with options for each of the five years on each side of the current, which is selected. The five year radius 
    290     # can be changed using the <tt>:start_year</tt> and <tt>:end_year</tt> keys in the +options+. Both ascending and descending year 
    291     # lists are supported by making <tt>:start_year</tt> less than or greater than <tt>:end_year</tt>. The <tt>date</tt> can also be 
    292     # substituted for a year given as a number. Example: 
    293     # 
    294     #   select_year(Date.today, :start_year => 1992, :end_year => 2007)  # ascending year values 
    295     #   select_year(Date.today, :start_year => 2005, :end_year => 1900)  # descending year values 
    296     # 
    297     # Override the field name using the <tt>:field_name</tt> option, 'year' by default. 
     334    /** 
     335     * Returns a select tag with options for each of the five years on each side of the current, which is selected. The five year radius 
     336     * can be changed using the <tt>:start_year</tt> and <tt>:end_year</tt> keys in the +options+. Both ascending and descending year 
     337     * lists are supported by making <tt>:start_year</tt> less than or greater than <tt>:end_year</tt>. The <tt>date</tt> can also be 
     338     * substituted for a year given as a number. Example: 
     339     * 
     340     *   select_year(Date.today, :start_year => 1992, :end_year => 2007)  # ascending year values 
     341    *   select_year(Date.today, :start_year => 2005, :end_year => 1900)  # descending year values 
     342    * 
     343    * Override the field name using the <tt>:field_name</tt> option, 'year' by default. 
     344    */ 
    298345    function select_year($date, $options = array()) { 
    299346        $year_options = ""; 
     
    320367    } 
    321368 
     369    /** 
     370     * 
     371     */ 
    322372    function to_date_select_tag($options = array()) { 
    323373        $defaults = array('discard_type' => true); 
     
    364414    } 
    365415 
     416    /** 
     417     * 
     418     */ 
    366419    function to_datetime_select_tag($options = array()) { 
    367420        $defaults = array('discard_type' => true); 
     
    405458} 
    406459 
    407 ################################################################################################ 
    408 ## Avialble functions for use in views 
    409 ################################################################################################ 
    410 # select_date($date = null, $options = array()) 
     460/** 
     461  * Avialble functions for use in views 
     462  *  select_date($date = null, $options = array()) 
     463  */ 
    411464function select_date() { 
    412465    $date_helper = new DateHelper(); 
     
    415468} 
    416469 
    417 # select_datetime($datetime = null, $options = array()) 
     470/** 
     471 *  Select_datetime($datetime = null, $options = array()) 
     472 */ 
    418473function select_datetime() { 
    419474    $date_helper = new DateHelper(); 
     
    422477} 
    423478 
    424 # select_expiration_date($datetime = null, $options = array()) 
     479/** 
     480 * select_expiration_date($datetime = null, $options = array()) 
     481 */ 
    425482function select_expiration_date() { 
    426483    $date_helper = new DateHelper(); 
     
    429486} 
    430487 
     488/** 
     489 * 
     490 */ 
    431491function datetime_select($object, $attribute, $options = array()) { 
    432492    $date_helper = new DateHelper($object, $attribute); 
     
    434494} 
    435495 
     496/** 
     497 * 
     498 */ 
    436499function date_select($object, $attribute, $options = array()) { 
    437500    $date_helper = new DateHelper($object, $attribute); 
  • trunk/trax/vendor/trax/action_view/helpers/form_helper.php

    r132 r138  
    11<?php 
    2 # $Id$ 
    3 # 
    4 # Copyright (c) 2005 John Peterson 
    5 # 
    6 # Permission is hereby granted, free of charge, to any person obtaining 
    7 # a copy of this software and associated documentation files (the 
    8 # "Software"), to deal in the Software without restriction, including 
    9 # without limitation the rights to use, copy, modify, merge, publish, 
    10 # distribute, sublicense, and/or sell copies of the Software, and to 
    11 # permit persons to whom the Software is furnished to do so, subject to 
    12 # the following conditions: 
    13 # 
    14 # The above copyright notice and this permission notice shall be 
    15 # included in all copies or substantial portions of the Software. 
    16 # 
    17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
    18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
    19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
    20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
    21 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
    22 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
    23 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
    24  
     2/** 
     3 *  File containing the FormHelper class 
     4 * 
     5 *  (PHP 5) 
     6 * 
     7 *  @package PHPonTrax 
     8 *  @version $Id$ 
     9 *  @copyright (c) 2005 John Peterson 
     10 * 
     11 *  Permission is hereby granted, free of charge, to any person obtaining 
     12 *  a copy of this software and associated documentation files (the 
     13 *  "Software"), to deal in the Software without restriction, including 
     14 *  without limitation the rights to use, copy, modify, merge, publish, 
     15 *  distribute, sublicense, and/or sell copies of the Software, and to 
     16 *  permit persons to whom the Software is furnished to do so, subject to 
     17 *  the following conditions: 
     18 * 
     19 *  The above copyright notice and this permission notice shall be 
     20 *  included in all copies or substantial portions of the Software. 
     21 * 
     22 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
     23 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
     24 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
     25 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
     26 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
     27 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
     28 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     29 */ 
     30 
     31/** 
     32 * 
     33 *  @package PHPonTrax 
     34 */ 
    2535class FormHelper extends Helpers { 
    2636 
     37    /** 
     38     * 
     39     */ 
    2740    function __construct($object_name, $attribute_name) { 
    2841        parent::__construct(); 
     
    3548    } 
    3649 
     50    /** 
     51     * 
     52     */ 
    3753    function value() { 
    3854        if(!$value = $_REQUEST[$this->object_name][$this->attribute_name]) { 
     
    4561    } 
    4662 
     63    /** 
     64     * 
     65     */ 
    4766    function object($object_name = null) { 
    4867        $object_name = $object_name ? $object_name : $this->object_name; 
     
    5069    } 
    5170 
     71    /** 
     72     * 
     73     */ 
    5274    function tag_name() { 
    5375        return "{$this->object_name}[{$this->attribute_name}]"; 
    5476    } 
    5577 
     78    /** 
     79     * 
     80     */ 
    5681    function tag_name_with_index($index) { 
    5782        return "{$this->object_name}[{$index}][{$this->attribute_name}]"; 
    5883    } 
    5984 
     85    /** 
     86     * 
     87     */ 
    6088    function tag_id() { 
    6189        return "{$this->object_name}_{$this->attribute_name}"; 
    6290    } 
    6391 
     92    /** 
     93     * 
     94     */ 
    6495    function tag_id_with_index($index) { 
    6596        return "{$this->object_name}_{$index}_{$this->attribute_name}"; 
    6697    } 
    6798 
     99    /** 
     100     * 
     101     */ 
    68102    function add_default_name_and_id($options) { 
    69103        if(array_key_exists("index", $options)) { 
     
    81115    } 
    82116 
     117    /** 
     118     * 
     119     */ 
    83120    function to_input_field_tag($field_type, $options = array()) { 
    84121        $default_size = $options["maxlength"] ? $options["maxlength"] : $this->default_field_options['size']; 
     
    96133    } 
    97134 
     135    /** 
     136     * 
     137     */ 
    98138    function to_radio_button_tag($tag_value, $options = array()) { 
    99139        $options = array_merge($this->default_radio_options, $options); 
     
    111151    } 
    112152 
     153    /** 
     154     * 
     155     */ 
    113156    function to_text_area_tag($options = array()) { 
    114157        if ($options["size"]) { 
     
    123166    } 
    124167 
     168    /** 
     169     * 
     170     */ 
    125171    function to_check_box_tag($options = array(), $checked_value = "1", $unchecked_value = "0") { 
    126172        $options["type"] = "checkbox"; 
     
    153199    } 
    154200 
     201    /** 
     202     * 
     203     */ 
    155204    function to_boolean_select_tag($options = array()) { 
    156205        $options = $this->add_default_name_and_id($options); 
     
    179228 
    180229 
    181 ################################################################################################ 
    182 ## Avialble functions for use in views 
    183 ################################################################################################ 
    184 # Example: text_field("post", "title"); 
    185 # Result: <input type="text" id="post_title" name="post[title]" value="$post->title" /> 
     230/** 
     231 * Avialble functions for use in views 
     232 *  Example: text_field("post", "title"); 
     233 *  Result: <input type="text" id="post_title" name="post[title]" value="$post->title" /> 
     234 */ 
    186235function text_field($object, $field, $options = array()) { 
    187236    $form = new FormHelper($object, $field); 
     
    189238} 
    190239 
    191 # Works just like text_field, but returns a input tag of the "password" type instead. 
    192 # Example: password_field("user", "password"); 
    193 # Result: <input type="password" id="user_password" name="user[password]" value="$user->password" /> 
     240/** 
     241 *  Works just like text_field, but returns a input tag of the "password" type instead. 
     242 * Example: password_field("user", "password"); 
     243 *  Result: <input type="password" id="user_password" name="user[password]" value="$user->password" /> 
     244 */ 
    194245function password_field($object, $field, $options = array()) { 
    195246    $form = new FormHelper($object, $field); 
     
    197248} 
    198249 
    199 # Works just like text_field, but returns a input tag of the "hidden" type instead. 
    200 # Example: hidden_field("post", "title"); 
    201 # Result: <input type="hidden" id="post_title" name="post[title]" value="$post->title" /> 
     250/** 
     251 *  Works just like text_field, but returns a input tag of the "hidden" type instead. 
     252 *  Example: hidden_field("post", "title"); 
     253 *  Result: <input type="hidden" id="post_title" name="post[title]" value="$post->title" /> 
     254 */ 
    202255function hidden_field($object, $field, $options = array()) { 
    203256    $form = new FormHelper($object, $field); 
     
    205258} 
    206259 
    207 # Works just like text_field, but returns a input tag of the "file" type instead, which won't have any default value. 
     260/** 
     261 * Works just like text_field, but returns a input tag of the "file" type instead, which won't have any default value. 
     262 */ 
    208263function file_field($object, $field, $options = array()) { 
    209264    $form = new FormHelper($object, $field); 
     
    211266} 
    212267 
    213 # Example: text_area("post", "body", array("cols" => 20, "rows" => 40)); 
    214 # Result: <textarea cols="20" rows="40" id="post_body" name="post[body]">$post->body</textarea> 
     268/** 
     269 *  Example: text_area("post", "body", array("cols" => 20, "rows" => 40)); 
     270 *  Result: <textarea cols="20" rows="40" id="post_body" name="post[body]">$post->body</textarea> 
     271 */ 
    215272function text_area($object, $field, $options = array()) { 
    216273    $form = new FormHelper($object, $field); 
     
    218275} 
    219276 
    220 # Returns a checkbox tag tailored for accessing a specified attribute (identified by $field) on an object 
    221 # assigned to the template (identified by $object). It's intended that $field returns an integer and if that 
    222 # integer is above zero, then the checkbox is checked. Additional $options on the input tag can be passed as an 
    223 # array with $options. The $checked_value defaults to 1 while the default $unchecked_value 
    224 # is set to 0 which is convenient for boolean values. Usually unchecked checkboxes don't post anything. 
    225 # We work around this problem by adding a hidden value with the same name as the checkbox. 
     277/** 
     278 * Returns a checkbox tag tailored for accessing a specified attribute (identified by $field) on an object 
     279 * assigned to the template (identified by $object). It's intended that $field returns an integer and if that 
     280 * integer is above zero, then the checkbox is checked. Additional $options on the input tag can be passed as an 
     281 * array with $options. The $checked_value defaults to 1 while the default $unchecked_value 
     282 * is set to 0 which is convenient for boolean values. Usually unchecked checkboxes don't post anything. 
     283 * We work around this problem by adding a hidden value with the same name as the checkbox. 
    226284# 
    227 # Example: Imagine that $post->validated is 1: 
    228 #   check_box("post", "validated"); 
    229 # Result: 
    230 #   <input type="checkbox" id="post_validate" name="post[validated] value="1" checked="checked" /> 
    231 #   <input name="post[validated]" type="hidden" value="0" /> 
     285 * Example: Imagine that $post->validated is 1: 
     286 *   check_box("post", "validated"); 
     287 * Result: 
     288 *   <input type="checkbox" id="post_validate" name="post[validated] value="1" checked="checked" /> 
     289 *   <input name="post[validated]" type="hidden" value="0" /> 
    232290# 
    233 # Example: Imagine that $puppy->gooddog is no: 
    234 #   check_box("puppy", "gooddog", array(), "yes", "no"); 
    235 # Result: 
    236 #     <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog] value="yes" /> 
    237 #     <input name="puppy[gooddog]" type="hidden" value="no" /> 
     291 * Example: Imagine that $puppy->gooddog is no: 
     292 *   check_box("puppy", "gooddog", array(), "yes", "no"); 
     293 * Result: 
     294 *     <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog] value="yes" /> 
     295 *     <input name="puppy[gooddog]" type="hidden" value="no" /> 
     296*/ 
    238297function check_box($object, $field, $options = array(), $checked_value = "1", $unchecked_value = "0") { 
    239298    $form = new FormHelper($object, $field); 
     
    241300} 
    242301 
    243 # Returns a radio button tag for accessing a specified attribute (identified by $field) on an object 
    244 # assigned to the template (identified by $object). If the current value of $field is $tag_value the 
    245 # radio button will be checked. Additional $options on the input tag can be passed as a 
    246 # hash with $options. 
    247 # Example: Imagine that $post->category is "trax": 
    248 #   radio_button("post", "category", "trax"); 
    249 #   radio_button("post", "category", "java"); 
    250 # Result: 
    251 #     <input type="radio" id="post_category" name="post[category] value="trax" checked="checked" /> 
    252 #     <input type="radio" id="post_category" name="post[category] value="java" /> 
     302/** 
     303 * Returns a radio button tag for accessing a specified attribute (identified by $field) on an object 
     304 * assigned to the template (identified by $object). If the current value of $field is $tag_value the 
     305 * radio button will be checked. Additional $options on the input tag can be passed as a 
     306 * hash with $options. 
     307 * Example: Imagine that $post->category is "trax": 
     308 *   radio_button("post", "category", "trax"); 
     309 *   radio_button("post", "category", "java"); 
     310 * Result: 
     311 *     <input type="radio" id="post_category" name="post[category] value="trax" checked="checked" /> 
     312 *     <input type="radio" id="post_category" name="post[category] value="java" /> 
     313*/ 
    253314function radio_button($object, $field, $tag_value, $options = array()) { 
    254315    $form = new FormHelper($object, $field); 
     
    256317} 
    257318 
     319/** 
     320 * 
     321 */ 
    258322function boolean_select($object, $field, $options = array()) { 
    259323    $form = new FormHelper($object, $field); 
  • trunk/trax/vendor/trax/action_view/helpers/form_options_helper.php

    r117 r138  
    11<?php 
    2 # $Id$ 
    3 # 
    4 # Copyright (c) 2005 John Peterson 
    5 # 
    6 # Permission is hereby granted, free of charge, to any person obtaining 
    7 # a copy of this software and associated documentation files (the 
    8 # "Software"), to deal in the Software without restriction, including 
    9 # without limitation the rights to use, copy, modify, merge, publish, 
    10 # distribute, sublicense, and/or sell copies of the Software, and to 
    11 # permit persons to whom the Software is furnished to do so, subject to 
    12 # the following conditions: 
    13 # 
    14 # The above copyright notice and this permission notice shall be 
    15 # included in all copies or substantial portions of the Software. 
    16 # 
    17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
    18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
    19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
    20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
    21 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
    22 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
    23 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
    24  
    25 # All the countries included in the country_options output. 
     2/** 
     3 *  File containing the FormOptionsHelper class and support functions 
     4 * 
     5 *  (PHP 5) 
     6 * 
     7 *  @package PHPonTrax 
     8 *  @version $Id$ 
     9 *  @copyright (c) 2005 John Peterson 
     10 * 
     11 *  Permission is hereby granted, free of charge, to any person obtaining 
     12 *  a copy of this software and associated documentation files (the 
     13 *  "Software"), to deal in the Software without restriction, including 
     14 *  without limitation the rights to use, copy, modify, merge, publish, 
     15 *  distribute, sublicense, and/or sell copies of the Software, and to 
     16 *  permit persons to whom the Software is furnished to do so, subject to 
     17 *  the following conditions: 
     18 * 
     19 *  The above copyright notice and this permission notice shall be 
     20 *  included in all copies or substantial portions of the Software. 
     21 * 
     22 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
     23 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
     24 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
     25 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
     26 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
     27 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
     28 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     29 */ 
     30 
     31/** 
     32 * All the countries included in the country_options output. 
     33 */ 
    2634if(!$GLOBALS['COUNTRIES']) { 
    2735    $GLOBALS['COUNTRIES'] =  
     
    7280} 
    7381 
     82/** 
     83 * 
     84 *  @package PHPonTrax 
     85 */ 
    7486class FormOptionsHelper extends FormHelper { 
    7587     
    76     # Accepts a container (hash, array, enumerable, your type) and returns a string of option tags. Given a container 
    77     # where the elements respond to first and last (such as a two-element array), the "lasts" serve as option values and 
    78     # the "firsts" as option text. Hashes are turned into this form automatically, so the keys become "firsts" and values 
    79     # become lasts. If +selected+ is specified, the matching "last" or element will get the selected option-tag.  +Selected+ 
    80     # may also be an array of values to be selected when using a multiple select. 
    81     # 
    82     # Examples (call, result): 
    83     #   options_for_select([["Dollar", "$"], ["Kroner", "DKK"]]) 
    84     #     <option value="$">Dollar</option>\n<option value="DKK">Kroner</option> 
    85     # 
    86     #   options_for_select([ "VISA", "MasterCard" ], "MasterCard") 
    87     #     <option>VISA</option>\n<option selected="selected">MasterCard</option> 
    88     # 
    89     #   options_for_select({ "Basic" => "$20", "Plus" => "$40" }, "$40") 
    90     #     <option value="$20">Basic</option>\n<option value="$40" selected="selected">Plus</option> 
    91     # 
    92     #   options_for_select([ "VISA", "MasterCard", "Discover" ], ["VISA", "Discover"]) 
    93     #     <option selected="selected">VISA</option>\n<option>MasterCard</option>\n<option selected="selected">Discover</option> 
    94     # 
    95     # NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag. 
     88    /** 
     89     *  Accepts a container (hash, array, enumerable, your type) and returns a string of option tags. Given a container 
     90     *  where the elements respond to first and last (such as a two-element array), the "lasts" serve as option values and 
     91     *  the "firsts" as option text. Hashes are turned into this form automatically, so the keys become "firsts" and values 
     92     *  become lasts. If +selected+ is specified, the matching "last" or element will get the selected option-tag.  +Selected+ 
     93     *  may also be an array of values to be selected when using a multiple select. 
     94     *  
     95     *  Examples (call, result): 
     96     *    options_for_select([["Dollar", "$"], ["Kroner", "DKK"]]) 
     97     *      <option value="$">Dollar</option>\n<option value="DKK">Kroner</option> 
     98     *  
     99     *    options_for_select([ "VISA", "MasterCard" ], "MasterCard") 
     100     *      <option>VISA</option>\n<option selected="selected">MasterCard</option> 
     101     *  
     102     *    options_for_select({ "Basic" => "$20", "Plus" => "$40" }, "$40") 
     103     *      <option value="$20">Basic</option>\n<option value="$40" selected="selected">Plus</option> 
     104     *  
     105     *    options_for_select([ "VISA", "MasterCard", "Discover" ], ["VISA", "Discover"]) 
     106     *      <option selected="selected">VISA</option>\n<option>MasterCard</option>\n<option selected="selected">Discover</option> 
     107     *  
     108     *  NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag. 
     109     */ 
    96110    function options_for_select($choices, $selected = null) { 
    97111        $options = array(); 
     
    113127    } 
    114128     
    115     # Returns a string of option tags that have been compiled by iterating over the +collection+ and assigning the 
    116     # the result of a call to the +value_method+ as the option value and the +text_method+ as the option text. 
    117     # If +selected_value+ is specified, the element returning a match on +value_method+ will get the selected option tag. 
    118     # 
    119     # Example (call, result). Imagine a loop iterating over each +person+ in <tt>@project.people</tt> to generate an input tag: 
    120     #   options_from_collection_for_select(@project.people, "id", "name") 
    121     #     <option value="#{person.id}">#{person.name}</option> 
    122     # 
    123     # NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag. 
     129    /** 
     130     * Returns a string of option tags that have been compiled by iterating over the +collection+ and assigning the 
     131     * the result of a call to the +value_method+ as the option value and the +text_method+ as the option text. 
     132     * If +selected_value+ is specified, the element returning a match on +value_method+ will get the selected option tag. 
     133     * 
     134     * Example (call, result). Imagine a loop iterating over each +person+ in <tt>@project.people</tt> to generate an input tag: 
     135     *   options_from_collection_for_select(@project.people, "id", "name") 
     136     *     <option value="#{person.id}">#{person.name}</option> 
     137     * 
     138     * NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag. 
     139     */ 
    124140    function options_from_collection_for_select($collection, $attribute_value, $attribute_text, $selected_value = null) { 
    125141        $options = array(); 
     
    134150    } 
    135151     
    136     # Returns a string of option tags for pretty much any country in the world. Supply a country name as +selected+ to 
    137     # have it marked as the selected option tag. You can also supply an array of countries as +priority_countries+, so 
    138     # that they will be listed above the rest of the (long) list. 
    139     # 
    140     # NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag. 
     152    /** 
     153     *  Returns a string of option tags for pretty much any country in the world. Supply a country name as +selected+ to 
     154     *  have it marked as the selected option tag. You can also supply an array of countries as +priority_countries+, so 
     155     *  that they will be listed above the rest of the (long) list. 
     156     * 
     157     *  NOTE: Only the option tags are returned, you have to wrap this call in a regular HTML select tag. 
     158     */ 
    141159    function country_options_for_select($selected = null, $priority_countries = array()) { 
    142160        $country_options = ""; 
     
    155173    } 
    156174     
     175    /** 
     176     * 
     177     */ 
    157178    function to_select_tag($choices, $options, $html_options) { 
    158179        $html_options = $this->add_default_name_and_id($html_options); 
     
    160181    } 
    161182     
     183    /** 
     184     * 
     185     */ 
    162186    function to_collection_select_tag($collection, $attribute_value, $attribute_text, $options, $html_options) { 
    163187        $html_options = $this->add_default_name_and_id($html_options); 
     
    165189    } 
    166190     
     191    /** 
     192     * 
     193     */ 
    167194    function to_country_select_tag($priority_countries, $options, $html_options) { 
    168195        $html_options = $this->add_default_name_and_id($html_options); 
     
    170197    } 
    171198 
     199    /** 
     200     * 
     201     */ 
    172202    private function add_options($option_tags, $options, $value = null) { 
    173203        if($options["include_blank"] == true) { 
     
    184214} 
    185215 
    186 ################################################################################################ 
    187 ## Avialble functions for use in views 
    188 ################################################################################################ 
    189 # Create a select tag and a series of contained option tags for the provided object and method. 
    190 # The option currently held by the object will be selected, provided that the object is available. 
    191 # See options_for_select for the required format of the choices parameter. 
    192 # 
    193 # Example with @post.person_id => 1: 
    194 #   select("post", "person_id", Person.find_all.collect {|p| [ p.name, p.id ] }, { :include_blank => true }) 
    195 # 
    196 # could become: 
    197 # 
    198 #   <select name="post[person_id"> 
    199 #     <option></option> 
    200 #     <option value="1" selected="selected">David</option> 
    201 #     <option value="2">Sam</option> 
    202 #     <option value="3">Tobias</option> 
    203 #   </select> 
    204 # 
    205 # This can be used to provide a functionault set of options in the standard way: before r}ering the create form, a 
    206 # new model instance is assigned the functionault options and bound to @model_name. Usually this model is not saved 
    207 # to the database. Instead, a second model object is created when the create request is received. 
    208 # This allows the user to submit a form page more than once with the expected results of creating multiple records. 
    209 # In addition, this allows a single partial to be used to generate form inputs for both edit and create forms. 
     216/** 
     217 * Avialble functions for use in views 
     218 * Create a select tag and a series of contained option tags for the provided object and method. 
     219 * The option currently held by the object will be selected, provided that the object is available. 
     220 * See options_for_select for the required format of the choices parameter. 
     221# 
     222 * Example with @post.person_id => 1: 
     223 *   select("post", "person_id", Person.find_all.collect {|p| [ p.name, p.id ] }, { :include_blank => true }) 
     224# 
     225 * could become: 
     226# 
     227 *   <select name="post[person_id"> 
     228 *     <option></option> 
     229 *     <option value="1" selected="selected">David</option> 
     230 *     <option value="2">Sam</option> 
     231 *     <option value="3">Tobias</option> 
     232 *   </select> 
     233# 
     234 * This can be used to provide a functionault set of options in the standard way: before r}ering the create form, a 
     235 * new model instance is assigned the functionault options and bound to @model_name. Usually this model is not saved 
     236 * to the database. Instead, a second model object is created when the create request is received. 
     237 * This allows the user to submit a form page more than once with the expected results of creating multiple records. 
     238 * In addition, this allows a single partial to be used to generate form inputs for both edit and create forms. 
     239 */ 
    210240function select($object_name, $attribute_name, $choices, $options = array(), $html_options = array()) { 
    211241    $form = new FormOptionsHelper($object_name, $attribute_name); 
     
    213243} 
    214244 
    215 # Return select and option tags for the given object and method using  
    216 # options_from_collection_for_select to generate the list of option tags. 
     245/** 
     246 * Return select and option tags for the given object and method using  
     247 * options_from_collection_for_select to generate the list of option tags. 
     248 */ 
    217249function collection_select($object_name, $attribute_name, $collection, $attribute_value, $attribute_text, $options = array(), $html_options = array()) { 
    218250    $form = new FormOptionsHelper($object_name, $attribute_name); 
     
    220252} 
    221253 
    222 # Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags. 
     254/** 
     255 * Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags. 
     256 */ 
    223257function country_select($object_name, $attribute_name, $priority_countries = null, $options = array(), $html_options = array()) { 
    224258    $form = new FormOptionsHelper($object_name, $attribute_name); 
  • trunk/trax/vendor/trax/action_view/helpers/form_tag_helper.php

    r132 r138  
    11<?php 
    2 # $Id$ 
    3 # 
    4 # Copyright (c) 2005 John Peterson 
    5 # 
    6 # Permission is hereby granted, free of charge, to any person obtaining 
    7 # a copy of this software and associated documentation files (the 
    8 # "Software"), to deal in the Software without restriction, including 
    9 # without limitation the rights to use, copy, modify, merge, publish, 
    10 # distribute, sublicense, and/or sell copies of the Software, and to 
    11 # permit persons to whom the Software is furnished to do so, subject to 
    12 # the following conditions: 
    13 # 
    14 # The above copyright notice and this permission notice shall be 
    15 # included in all copies or substantial portions of the Software. 
    16 # 
    17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
    18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
    19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
    20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
    21 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
    22 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
    23 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
    24  
     2/** 
     3 *  File containing the FormTagHelper class and support functions 
     4 * 
     5 *  (PHP 5) 
     6 * 
     7 *  @package PHPonTrax 
     8 *  @version $Id$ 
     9 *  @copyright (c) 2005 John Peterson 
     10 * 
     11 *  Permission is hereby granted, free of charge, to any person obtaining 
     12 *  a copy of this software and associated documentation files (the 
     13 *  "Software"), to deal in the Software without restriction, including 
     14 *  without limitation the rights to use, copy, modify, merge, publish, 
     15 *  distribute, sublicense, and/or sell copies of the Software, and to 
     16 *  permit persons to whom the Software is furnished to do so, subject to 
     17 *  the following conditions: 
     18 * 
     19 *  The above copyright notice and this permission notice shall be 
     20 *  included in all copies or substantial portions of the Software. 
     21 * 
     22 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
     23 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
     24 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
     25 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
     26 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
     27 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
     28 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     29 */ 
     30 
     31/** 
     32 * 
     33 *  @package PHPonTrax 
     34 */ 
    2535class FormTagHelper extends Helpers { 
    2636 
    27  
     37    /** 
     38     * 
     39     */ 
    2840    private function convert_options($options = array()) { 
    2941        $arr = array('disabled', 'readonly', 'multiple'); 
     
    3446    } 
    3547 
     48    /** 
     49     * 
     50     */ 
    3651    private function boolean_attribute(&$options, $attribute) { 
    3752        if($options[$attribute]) { 
     
    4257    } 
    4358 
     59    /** 
     60     * 
     61     */ 
    4462    function form_tag($url_for_options = array(), $options = array(), $parameters_for_url = array()) { 
    4563        $html_options = array_merge(array("method" => "post"), $options); 
     
    5472    } 
    5573 
     74    /** 
     75     * 
     76     */ 
    5677    function start_form_tag() { 
    5778        $args = func_get_args(); 
     
    5980    } 
    6081 
     82    /** 
     83     * 
     84     */ 
    6185    function select_tag($name, $option_tags = null, $options = array()) { 
    6286        return $this->content_tag("select", $option_tags, array_merge(array("name" => $name, "id" => $name), $this->convert_options($options))); 
    6387    } 
    6488 
     89    /** 
     90     * 
     91     */ 
    6592    function text_field_tag($name, $value = null, $options = array()) { 
    6693        return $this->tag("input", array_merge(array("type" => "text", "name" => $name, "id" => $name, "value" => $value), $this->convert_options($options))); 
    6794    } 
    6895 
     96    /** 
     97     * 
     98     */ 
    6999    function hidden_field_tag($name, $value = null, $options = array()) { 
    70100        return $this->text_field_tag($name, $value, array_merge($options, array("type" => "hidden"))); 
    71101    } 
    72102 
     103    /** 
     104     * 
     105     */ 
    73106    function file_field_tag($name, $options = array()) { 
    74107        return $this->text_field_tag($name, null, array_merge($this->convert_options($options), array("type" => "file"))); 
    75108    } 
    76109 
     110    /** 
     111     * 
     112     */ 
    77113    function password_field_tag($name = "password", $value = null, $options = array()) { 
    78114        return $this->text_field_tag($name, $value, array_merge($this->convert_options($options), array("type" => "password"))); 
    79115    } 
    80116 
     117    /** 
     118     * 
     119     */ 
    81120    function text_area_tag($name, $content = null, $options = array()) { 
    82121        if ($options["size"]) { 
     
    90129    } 
    91130 
     131    /** 
     132     * 
     133     */ 
    92134    function check_box_tag($name, $value = "1", $checked = false, $options = array()) { 
    93135        $html_options = array_merge(array("type" => "checkbox", "name" => $name, "id" => $name, "value" => $value), $this->convert_options($options)); 
     
    96138    } 
    97139 
     140    /** 
     141     * 
     142     */ 
    98143    function radio_button_tag($name, $value, $checked = false, $options = array()) { 
    99144        $html_options = array_merge(array("type" => "radio", "name" => $name, "id" => $name, "value" => $value), $this->convert_options($options)); 
     
    102147    } 
    103148 
     149    /** 
     150     * 
     151     */ 
    104152    function submit_tag($value = "Save changes", $options = array()) { 
    105153        return $this->tag("input", array_merge(array("type" => "submit", "name" => "commit", "value" => $value), $this->convert_options($options))); 
    106154    } 
    107155 
     156    /** 
     157     * 
     158     */ 
    108159    function image_submit_tag($source, $options = array()) { 
    109160        return $this->tag("input", array_merge(array("type" => "image", "src" => image_path($source)), $this->convert_options($options))); 
     
    112163} 
    113164 
    114 ################################################################################################ 
    115 ## Avialble functions for use in views 
    116 ################################################################################################ 
     165/** 
     166 * Avialble functions for use in views 
     167 */ 
    117168function form_tag() { 
    118169    $form_tag_helper = new FormTagHelper(); 
     
    121172} 
    122173 
     174/** 
     175 * 
     176 */ 
    123177function start_form_tag() { 
    124178    $args = func_get_args(); 
     
    126180} 
    127181 
     182/** 
     183 * 
     184 */ 
    128185function end_form_tag() { 
    129186    return "</form>"; 
    130187} 
    131188 
     189/** 
     190 * 
     191 */ 
    132192function select_tag() { 
    133193    $form_tag_helper = new FormTagHelper(); 
     
    136196} 
    137197 
     198/** 
     199 * 
     200 */ 
    138201function text_field_tag() { 
    139202    $form_tag_helper = new FormTagHelper(); 
     
    142205} 
    143206 
     207/** 
     208 * 
     209 */ 
    144210function hidden_field_tag() { 
    145211    $form_tag_helper = new FormTagHelper(); 
     
    148214} 
    149215 
     216/** 
     217 * 
     218 */ 
    150219function file_field_tag() { 
    151220    $form_tag_helper = new FormTagHelper(); 
     
    154223} 
    155224 
     225/** 
     226 * 
     227 */ 
    156228function password_field_tag() { 
    157229    $form_tag_helper = new FormTagHelper(); 
     
    160232} 
    161233 
     234/** 
     235 * 
     236 */ 
    162237function text_area_tag() { 
    163238    $form_tag_helper = new FormTagHelper(); 
     
    166241} 
    167242 
     243/** 
     244 * 
     245 */ 
    168246function check_box_tag() { 
    169247    $form_tag_helper = new FormTagHelper(); 
     
    172250} 
    173251 
     252/** 
     253 * 
     254 */ 
    174255function radio_button_tag() { 
    175256    $form_tag_helper = new FormTagHelper(); 
     
    178259} 
    179260 
     261/** 
     262 * 
     263 */ 
    180264function submit_tag() { 
    181265    $form_tag_helper = new FormTagHelper(); 
     
    184268} 
    185269 
     270/** 
     271 * 
     272 */ 
    186273function image_submit_tag() { 
    187274    $form_tag_helper = new FormTagHelper(); 
  • trunk/trax/vendor/trax/action_view/helpers/url_helper.php

    r117 r138  
    11<?php 
    2 # $Id$ 
    3 # 
    4 # Copyright (c) 2005 John Peterson 
    5 # 
    6 # Permission is hereby granted, free of charge, to any person obtaining 
    7 # a copy of this software and associated documentation files (the 
    8 # "Software"), to deal in the Software without restriction, including 
    9 # without limitation the rights to use, copy, modify, merge, publish, 
    10 # distribute, sublicense, and/or sell copies of the Software, and to 
    11 # permit persons to whom the Software is furnished to do so, subject to 
    12 # the following conditions: 
    13 # 
    14 # The above copyright notice and this permission notice shall be 
    15 # included in all copies or substantial portions of the Software. 
    16 # 
    17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
    18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
    19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
    20 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
    21 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
    22 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
    23 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     2/** 
     3 *  File containing the UrlHelper class and support functions 
     4 * 
     5 *  (PHP 5) 
     6 * 
     7 *  @package PHPonTrax 
     8 *  @version $Id$ 
     9 *  @copyright (c) 2005 John Peterson 
     10 * 
     11 *  Permission is hereby granted, free of charge, to any person obtaining 
     12 *  a copy of this software and associated documentation files (the 
     13 *  "Software"), to deal in the Software without restriction, including 
     14 *  without limitation the rights to use, copy, modify, merge, publish, 
     15 *  distribute, sublicense, and/or sell copies of the Software, and to 
     16 *  permit persons to whom the Software is furnished to do so, subject to 
     17 *  the following conditions: 
     18 * 
     19 *  The above copyright notice and this permission notice shall be 
     20 *  included in all copies or substantial portions of the Software. 
     21 * 
     22 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
     23 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
     24 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
     25 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
     26 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
     27 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
     28 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     29 */ 
    2430 
     31/** 
     32 *  @todo Document this class 
     33 *  @package PHPonTrax 
     34 */ 
    2535class UrlHelper extends Helpers { 
    2636 
    27     # Creates a link tag of the given +name+ using an URL created by the set of +options+. 
    28     # It's also possible to pass a string instead of an options hash to 
    29     # get a link tag that just points without consideration. If null is passed as a name, the link itself will become the name. 
    30     # The $html_options have a special feature for creating javascript confirm alerts where if you pass ":confirm" => 'Are you sure?', 
    31     # the link will be guarded with a JS popup asking that question. If the user accepts, the link is processed, otherwise not. 
    32     # 
    33     # Example: 
    34     #   link_to("Delete this page", array(":action" => "delete", ":id" => $page->id), array(":confirm" => "Are you sure?")) 
     37    /** 
     38     * Creates a link tag of the given +name+ using an URL created by the set of +options+. 
     39     * It's also possible to pass a string instead of an options hash to 
     40     * get a link tag that just points without consideration. If null is passed as a name, the link itself will become the name. 
     41     * The $html_options have a special feature for creating javascript confirm alerts where if you pass ":confirm" => 'Are you sure?', 
     42     * the link will be guarded with a JS popup asking that question. If the user accepts, the link is processed, otherwise not. 
     43     * 
     44     * Example: 
     45     *   link_to("Delete this page", array(":action" => "delete", ":id" => $page->id), array(":confirm" => "Are you sure?")) 
     46     */ 
    3547    function link_to($name, $options = array(), $html_options = array()) { 
    3648        $html_options = $this->convert_confirm_option_to_javascript($html_options); 
     
    6274    } 
    6375 
     76    /** 
     77     *  @todo Document this method 
     78     */ 
    6479    function convert_confirm_option_to_javascript($html_options) { 
    6580        if($html_options['confirm']) { 
     
    7085    } 
    7186 
     87    /** 
     88     *  @todo Document this method 
     89     */ 
    7290    function convert_boolean_attributes(&$html_options, $bool_attrs) { 
    7391        foreach($bool_attrs as $x) { 
     
    8098    } 
    8199 
     100    /** 
     101     *  @todo Document this method 
     102     */ 
    82103    function button_to($name, $options = array(), $html_options = null) { 
    83104        $html_options = (!is_null($html_options) ? $html_options : array()); 
     
    97118    } 
    98119 
    99     # This tag is deprecated. Combine the link_to and AssetTagHelper::image_tag yourself instead, like: 
    100     #   link_to(image_tag("rss", :size => "30x45", :border => 0), "http://www.example.com") 
     120    /** 
     121     * This tag is deprecated. Combine the link_to and AssetTagHelper::image_tag yourself instead, like: 
     122     *   link_to(image_tag("rss", :size => "30x45", :border => 0), "http://www.example.com") 
     123     */ 
    101124    function link_image_to($src, $options = array(), $html_options = array(), $parameters_for_method_reference = array()) { 
    102125        $image_options = array("src" => (ereg("/", $src) ? $src : "/images/$src")); 
     
    131154} 
    132155 
    133 ################################################################################################ 
    134 ## Avialble functions for use in views 
    135 ################################################################################################ 
     156/** 
     157 *  Avialble functions for use in views 
     158 *  @todo Document this function 
     159 */ 
    136160function link_to($name, $options = array(), $html_options = array()) { 
    137161    $url_helper = new UrlHelper();