Show
Ignore:
Timestamp:
05/04/06 19:52:43 (6 years ago)
Author:
haas
Message:

many fixes, documentation improvements

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

Legend:

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

    • Property svn:keywords set to Id
  • trunk/trax/vendor/trax/action_view/helpers/active_record_helper.php

    • Property svn:keywords set to Id
    r198 r199  
    204204     *  @todo Document this method 
    205205     *  @uses scaffolding 
     206     *  @uses input_scaffolding() 
    206207     */ 
    207208    function default_input_block() { 
  • trunk/trax/vendor/trax/action_view/helpers/asset_tag_helper.php

    • Property svn:keywords set to Id
    r196 r199  
    3030 
    3131/** 
    32  *  @todo Document this class 
     32 *  Utility to help build HTML/XML link tags for public assets 
    3333 */ 
    3434class AssetTagHelper extends Helpers { 
    3535 
    3636    /** 
     37     *  @var string[] 
     38     */ 
     39    var $javascript_default_sources = null; 
     40 
     41    /** 
    3742     *  @todo Document this method 
    3843     * 
     44     *  @uses javascript_default_sources 
    3945     */ 
    4046    function __construct() { 
    4147        parent::__construct(); 
    42         $this->javascript_default_sources = $GLOBALS['JAVASCRIPT_DEFAULT_SOURCES'] ? $GLOBALS['JAVASCRIPT_DEFAULT_SOURCES'] : array('prototype', 'effects', 'dragdrop', 'controls');     
    43     } 
    44      
    45     /** 
    46      *   @todo Document this method 
    47      * 
     48        $this->javascript_default_sources = 
     49            array_key_exists('JAVASCRIPT_DEFAULT_SOURCES',$GLOBALS) 
     50            ? $GLOBALS['JAVASCRIPT_DEFAULT_SOURCES'] 
     51            : array('prototype', 'effects', 'dragdrop', 'controls');     
     52    } 
     53     
     54    /** 
     55     *  Compute public path to an asset 
     56     * 
     57     *  Build the public path, suitable for inclusion in a URL, to an 
     58     *  asset.  Arguments are the filename, directory and extension of 
     59     *  the asset. 
     60     *  @param string  Filename of asset 
     61     *  @param string  Default directory name, if none in $source 
     62     *  @param string  Default file extension, if none in $source 
     63     *  @return string Public path to the asset 
     64     *  @uses controller_object 
     65     *  @uses ActionController::asset_host 
    4866     */ 
    4967    private function compute_public_path($source, $dir, $ext) { 
     68  
     69        //  Test whether source is a URL, ie. starts something:// 
    5070        if(!preg_match('/^[-a-z]+:\/\//', $source)) { 
     71 
     72            //  Source is not a URL. 
     73            //  If path doesn't start with '/', prefix /$dir/ 
    5174            if($source{0} != '/') { 
    5275                $source = "/{$dir}/{$source}"; 
    5376            } 
     77 
     78            //  If no '.' in source file name, add '.ext' 
    5479            if(!strstr($source, '.')) { 
    5580                $source = "{$source}.{$ext}"; 
    5681            } 
     82 
     83            //  If TRAX_URL_PREFIX non-null, prefix it to path 
    5784            if(!is_null(TRAX_URL_PREFIX)) { 
    5885                $prefix = TRAX_URL_PREFIX; 
     
    6087                    $prefix = "/$prefix"; 
    6188                } 
    62                 $source = $prefix . ((substr($prefix, -1) == "/") ? substr($source, 1) : $source); 
     89                $source = $prefix . ((substr($prefix, -1) == "/") 
     90                                     ? substr($source, 1) : $source); 
    6391            }             
    6492        } 
    65         return $this->controller_object->asset_host . $source; 
    66     } 
    67      
    68     /** 
    69      * Returns path to a javascript asset. Example: 
    70      * 
    71      *  javascript_path "xmlhr" # => /javascripts/xmlhr.js 
     93 
     94        //  If controller defined and has asset_host value 
     95        //  prefix that to path 
     96        //  FIXME: won't this cause a problem if $source was http://...? 
     97        if ( isset($this->controller_object) 
     98             && isset($this->controller_object->asset_host) ) { 
     99            $source = $this->controller_object->asset_host . $source; 
     100        } 
     101        return $source; 
     102    } 
     103     
     104    /** 
     105     *  Compute public path to a javascript asset 
     106     * 
     107     *  Build the public path, suitable for inclusion in a URL, to a 
     108     *  javascript asset.  Argument is the filename of the asset. 
     109     *  Default directory to 'javascripts', extension to '.js' 
     110     *  @param string  Filename of asset, in one of the formats 
     111     *                 accepted as the $filename argument of 
     112     *                 {@link compute_public_path()} 
     113     *  @return string Public path to the javascript asset 
     114     *  @uses compute_public_path() 
    72115     */ 
    73116    function javascript_path($source) { 
     
    76119     
    77120    /** 
    78      * Returns a script include tag per source given as argument. Examples: 
    79      * 
    80      *  javascript_include_tag("xmlhr") # => 
     121     *  Return script include tag for one or more javascript assets 
     122     * 
     123     *  javascript_include_tag("xmlhr"); => 
    81124     *   <script type="text/javascript" src="/javascripts/xmlhr.js"></script> 
    82125     * 
    83      *  javascript_include_tag("common.javascript", "/elsewhere/cools") # => 
     126     *  javascript_include_tag("common.javascript", "/elsewhere/cools"); => 
    84127     *   <script type="text/javascript" src="/javascripts/common.javascript"></script> 
    85128     *   <script type="text/javascript" src="/elsewhere/cools.js"></script> 
    86129     * 
    87      *  javascript_include_tag("defaults") # => 
     130     *  javascript_include_tag("defaults"); => 
    88131     *   <script type="text/javascript" src="/javascripts/prototype.js"></script> 
    89132     *   <script type="text/javascript" src="/javascripts/effects.js"></script> 
    90133     *   <script type="text/javascript" src="/javascripts/controls.js"></script> 
    91134     *   <script type="text/javascript" src="/javascripts/dragdrop.js"></script>    
     135     *  @param mixed  The arguments are zero or more strings, followed 
     136     *                by an optional array containing options 
     137     *  @return string 
     138     *  @uses content_tag() 
     139     *  @uses javascript_default_sources 
     140     *  @uses javascript_path() 
    92141     */ 
    93142    function javascript_include_tag() { 
    94143        if(func_num_args() > 0) { 
    95144            $sources = func_get_args();      
    96             $options = (is_array(end($sources)) ? array_pop($sources) : array());           
     145            $options = (is_array(end($sources)) 
     146                        ? array_pop($sources) : array());           
    97147            if(in_array('defaults', $sources)) { 
    98148                if(is_array($this->javascript_default_sources)) { 
    99                     $sources = array_merge($this->javascript_default_sources, $sources);     
     149                    $sources = array_merge($this->javascript_default_sources, 
     150                                           $sources);     
    100151                }                   
    101152                if(file_exists(TRAX_PUBLIC. "/javascripts/application.js")) { 
     
    108159            foreach($sources as $source) { 
    109160                $source = $this->javascript_path($source); 
    110                 $contents[] = $this->content_tag("script", "", array_merge(array("type" => "text/javascript", "src" => $source), $options)); 
     161                $contents[] = $this->content_tag("script", "", 
     162                     array_merge(array("type" => "text/javascript", 
     163                                       "src" => $source), $options)); 
    111164            } 
    112165            return implode("", $contents); 
     
    115168     
    116169    /** 
    117      * Returns path to a stylesheet asset. Example: 
    118      * 
    119      *  stylesheet_path("style") # => /stylesheets/style.css 
     170     *  Compute public path to a stylesheet asset 
     171     * 
     172     *  Build the public path, suitable for inclusion in a URL, to a 
     173     *  stylesheet asset.  Argument is the filename of the asset. 
     174     *  Default directory to 'stylesheets', extension to '.css' 
     175     *  @param string  Filename of asset, in one of the formats 
     176     *                 accepted as the $filename argument of 
     177     *                 {@link compute_public_path()} 
     178     *  @return string Public path to the stylesheet asset 
    120179     *  @uses compute_public_path() 
    121180     */ 
    122181    function stylesheet_path($source) { 
    123         return $this->compute_public_path($source, 'stylesheets', 'css'); #should be stylesheets 
    124     } 
    125      
    126     /** 
    127      * Returns a css link tag per source given as argument.  
    128      * 
    129      * Examples: 
    130      * 
    131      *  stylesheet_link_tag("style") # => 
    132      *   <link href="/stylesheets/style.css" media="screen" rel="Stylesheet" type="text/css" /> 
    133      * 
    134      *  stylesheet_link_tag("style", array("media" => "all")) # => 
    135      *   <link href="/stylesheets/style.css" media="all" rel="Stylesheet" type="text/css" /> 
    136      * 
    137      *  stylesheet_link_tag("random.styles", "/css/stylish") # => 
    138      *   <link href="/stylesheets/random.styles" media="screen" rel="Stylesheet" type="text/css" /> 
    139      *   <link href="/css/stylish.css" media="screen" rel="Stylesheet" type="text/css" /> 
     182        return $this->compute_public_path($source, 'stylesheets', 'css'); 
     183    } 
     184     
     185    /** 
     186     *  Build link tags to one or more stylesheet assets 
     187     * 
     188     *  @param mixed  One or more assets, optionally followed by an 
     189     *                array describing options to apply to the tags 
     190     *                generated for these assets.<br>  Each asset is a 
     191     *                string in one of the formats accepted as value 
     192     *                of the $source argument of 
     193     *                {@link stylesheet_path()}.<br>  The optional last 
     194     *                argument is an array whose keys are names of 
     195     *                attributes of the link tag and whose corresponding 
     196     *                values are the values assigned to each 
     197     *                attribute.  If omitted, options default to: 
     198     *                <ul> 
     199     *                  <li>"rel" => "Stylesheet"</li> 
     200     *                  <li>"type" => "text/css"</li> 
     201     *                  <li>"media" => "screen"</li> 
     202     *                  <li>"href" => <i>path-to-source</i></li> 
     203     *                </ul> 
     204     *  @return string  A link tag for each asset in the argument list 
    140205     *  @uses stylesheet_path() 
    141206     *  @uses tag() 
     
    144209        if(func_num_args() > 0) { 
    145210            $sources = func_get_args();      
    146             $options = (is_array(end($sources)) ? array_pop($sources) : array()); 
     211            $options = (is_array(end($sources)) 
     212                        ? array_pop($sources) : array()); 
    147213            $contents = array(); 
    148214            foreach($sources as $source) { 
    149215                $source = $this->stylesheet_path($source); 
    150                 $contents[] = $this->tag("link", array_merge(array("rel" => "Stylesheet", "type" => "text/css", "media" => "screen", "href" => $source), $options)); 
     216                $contents[] = $this->tag("link", 
     217                   array_merge(array("rel" => "Stylesheet", 
     218                                     "type" => "text/css", 
     219                                     "media" => "screen", 
     220                                     "href" => $source), $options)); 
    151221            } 
    152222            return implode("", $contents); 
     
    155225     
    156226    /** 
    157      * Returns path to an image asset. Example: 
    158      * 
    159      * The src can be supplied as a... 
    160      * * full path, like "/my_images/image.gif" 
    161      * * file name, like "rss.gif", that gets expanded to "/images/rss.gif" 
    162      * * file name without extension, like "logo", that gets expanded to "/images/logo.png" 
    163      *  @uses compute_public_path 
     227     *  Compute public path to a image asset 
     228     * 
     229     *  Build the public path, suitable for inclusion in a URL, to a 
     230     *  image asset.  Argument is the filename of the asset. 
     231     *  Default directory to 'images', extension to '.png' 
     232     *  @param string  Filename of asset, in one of the formats 
     233     *                 accepted as the $filename argument of 
     234     *                 {@link compute_public_path()} 
     235     *  @return string Public path to the image asset 
     236     *  @uses compute_public_path() 
    164237     */ 
    165238    function image_path($source) { 
    166         return $this->compute_public_path($source, 'images', 'png'); #should be images 
    167     } 
    168      
    169     /** 
    170      * Returns an image tag converting the $options instead html options on the tag, but with these special cases: 
    171      * 
    172      * * <tt>:alt</tt> - If no alt text is given, the file name part of the src is used (capitalized and without the extension) 
    173      * * <tt>:size</tt> - Supplied as "XxY", so "30x45" becomes width="30" and height="45" 
    174      * 
    175      * The src can be supplied as a... 
    176      * * full path, like "/my_images/image.gif" 
    177      * * file name, like "rss.gif", that gets expanded to "/images/rss.gif" 
    178      * * file name without extension, like "logo", that gets expanded to "/images/logo.png" 
    179      *  @uses Inflector::capitalize() 
     239        return $this->compute_public_path($source, 'images', 'png'); 
     240    } 
     241     
     242    /** 
     243     *  Build image tags to an image asset 
     244     * 
     245     *  @param mixed  An image asset optionally followed by an 
     246     *                array describing options to apply to the tag 
     247     *                generated for this asset.<br>The asset is a 
     248     *                string in one of the formats accepted as value 
     249     *                of the $source argument of 
     250     *                {@link image_path()}.<br>  The optional second 
     251     *                argument is an array whose keys are names of 
     252     *                attributes of the image tag and whose corresponding 
     253     *                values are the values assigned to each 
     254     *                attribute.  The image size can be specified in 
     255     *                two ways: by specifying option values "width" => 
     256     *                <i>width</i> and "height" => <i>height</i>, or 
     257     *                by specifying option "size" => "<i>width</i> 
     258     *                x <i>height</i>".  If omitted, options default to: 
     259     *                <ul> 
     260     *                  <li>"alt" => <i>humanized filename</i></li> 
     261     *                  <li>"width" and "height" value computed from 
     262     *                       value of "size"</li> 
     263     *                </ul> 
     264     *  @return string  A image tag for each asset in the argument list 
    180265     *  @uses image_path() 
    181266     *  @uses tag() 
     
    183268    function image_tag($source, $options = array()) { 
    184269        $options['src'] = $this->image_path($source); 
    185         $options['alt'] = $options['alt'] ? $options['alt'] : Inflector::capitalize(reset($file_array = explode('.', basename($options['src'])))); 
    186          
     270        $options['alt'] = array_key_exists('alt',$options) 
     271            ? $options['alt'] 
     272            : Inflector::capitalize(reset($file_array = 
     273                             explode('.', basename($options['src'])))); 
    187274        if(isset($options['size'])) { 
    188275            $size = explode('x', $options["size"]);          
     
    191278            unset($options['size']); 
    192279        } 
    193          
    194280        return $this->tag("img", $options); 
    195281    } 
    196282     
    197283    /** 
    198      * Returns a link tag that browsers and news readers can use to auto-detect a RSS or ATOM feed for this page. The $type can 
    199      * either be <tt>:rss</tt> (default) or <tt>:atom</tt> and the $options follow the url_for() style of declaring a link target. 
    200      * 
    201      * Examples: 
    202      *  auto_discovery_link_tag # => 
    203      *   <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.curenthost.com/controller/action" /> 
    204      *  auto_discovery_link_tag(:atom) # => 
    205      *   <link rel="alternate" type="application/atom+xml" title="ATOM" href="http://www.curenthost.com/controller/action" /> 
    206      *  auto_discovery_link_tag(:rss, {:action => "feed"}) # => 
    207      *   <link rel="alternate" type="application/rss+xml" title="RSS" href="http://www.curenthost.com/controller/feed" /> 
    208      *  auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => "My RSS"}) # => 
    209      *   <link rel="alternate" type="application/rss+xml" title="My RSS" href="http://www.curenthost.com/controller/feed" /> 
    210         *  @uses tag() 
    211      */ 
    212     function auto_discovery_link_tag($type = 'rss', $options = array(), $tag_options = array()) { 
     284     *  Returns a link tag that browsers and news readers can use to 
     285     *  auto-detect a RSS or ATOM feed for this page. The $type can  
     286     *  either be <tt>:rss</tt> (default) or <tt>:atom</tt> and the 
     287     *  $options follow the url_for() style of declaring a link 
     288     *  target.  
     289     * 
     290     *  Examples: 
     291     *  auto_discovery_link_tag  => 
     292     *   <link rel="alternate" type="application/rss+xml" title="RSS" 
     293     *  href="http://www.curenthost.com/controller/action" />  
     294     *  auto_discovery_link_tag(:atom) => 
     295     *   <link rel="alternate" type="application/atom+xml" 
     296     *  title="ATOM" 
     297     *  href="http://www.curenthost.com/controller/action" />  
     298     *  auto_discovery_link_tag(:rss, {:action => "feed"}) => 
     299     *   <link rel="alternate" type="application/rss+xml" title="RSS" 
     300     *  href="http://www.curenthost.com/controller/feed" />  
     301     *  auto_discovery_link_tag(:rss, {:action => "feed"}, {:title => 
     302     *  "My RSS"})  =>  
     303     *   <link rel="alternate" type="application/rss+xml" title="My 
     304     *  RSS" href="http://www.curenthost.com/controller/feed" />  
     305     *  @uses tag() 
     306     *  @uses url_for() 
     307     */ 
     308    function auto_discovery_link_tag($type = 'rss', $options = array(), 
     309                                     $tag_options = array()) { 
    213310        return $this->tag( 
    214311          "link", array( 
    215           "rel" => ($tag_options['rel'] ? $tag_options['rel'] : "alternate"), 
    216           "type" => ($tag_options['type'] ? $tag_options['type'] : "application/{$type}+xml"), 
    217           "title" => ($tag_options['title'] ? $tag_options['title'] : strtoupper($type)), 
    218           "href" => url_for(array_merge($options, array('only_path' => false)))) 
    219         ); 
     312                        "rel" => (array_key_exists('rel',$tag_options) 
     313                                  ? $tag_options['rel'] : "alternate"), 
     314                        "type" => (array_key_exists('type',$tag_options) 
     315                                   ? $tag_options['type'] 
     316                                   : "application/{$type}+xml"), 
     317                        "title" => (array_key_exists('title',$tag_options) 
     318                                    ? $tag_options['title'] 
     319                                    : strtoupper($type)), 
     320                        "href" => url_for(array_merge($options, 
     321                                         array('only_path' => false)))) 
     322          ); 
    220323    }     
    221324} 
    222325 
    223  
    224 /** 
    225  *  @todo Document this method   
    226  *  Avialble functions for use in views 
    227  *  auto_discovery_link_tag($type = 'rss', $options = array(), $tag_options = array()) 
     326/** 
     327 *  Make a new AssetTagHelper object and call its auto_discovery_link_tag() method 
    228328 *  @uses AssetTagHelper::auto_discovery_link_tag() 
    229329 */ 
     
    231331    $asset_helper = new AssetTagHelper(); 
    232332    $args = func_get_args(); 
    233     return call_user_func_array(array($asset_helper, 'auto_discovery_link_tag'), $args); 
    234 } 
    235  
    236 /** 
    237  *  @todo Document this method   
    238  *  image_tag($source, $options = array()) 
     333    return call_user_func_array(array($asset_helper, 
     334                                      'auto_discovery_link_tag'), $args); 
     335} 
     336 
     337/** 
     338 *  Make a new AssetTagHelper object and call its image_tag() method 
    239339 *  @uses AssetTagHelper::image_tag() 
    240340 */ 
     
    246346 
    247347/** 
    248  *  @todo Document this method   
    249  *  stylesheet_link_tag($sources) 
     348 *  Make a new AssetTagHelper object and call its stylesheet_link_tag() method 
    250349 *  @uses AssetTagHelper::stylesheet_link_tag() 
    251350 */ 
     
    253352    $asset_helper = new AssetTagHelper(); 
    254353    $args = func_get_args(); 
    255     return call_user_func_array(array($asset_helper, 'stylesheet_link_tag'), $args); 
    256 } 
    257  
    258 /** 
    259  *  @todo Document this method 
    260  *  javascript_include_tag($sources) 
     354    return call_user_func_array(array($asset_helper, 
     355                                      'stylesheet_link_tag'), $args); 
     356} 
     357 
     358/** 
     359 *  Make a new AssetTagHelper object and call its javascript_include_tag() method 
    261360 *  @uses AssetTagHelper::javascript_include_tag() 
    262361 */ 
     
    264363    $asset_helper = new AssetTagHelper(); 
    265364    $args = func_get_args(); 
    266     return call_user_func_array(array($asset_helper, 'javascript_include_tag'), $args); 
     365    return call_user_func_array(array($asset_helper, 
     366                                      'javascript_include_tag'), $args); 
    267367} 
    268368 
  • trunk/trax/vendor/trax/action_view/helpers/date_helper.php

    • Property svn:keywords set to Id
    r198 r199  
    343343     *  @param mixed[]  Output format options: 
    344344     *  <ul> 
    345      *    <li><samp>'field_seperator' => '</samp><i>somestring</i><samp>'</samp><br /> 
     345     *    <li><samp>'field_separator' => '</samp><i>somestring</i><samp>'</samp><br /> 
    346346     *      String to insert between the month and year selectors.  If 
    347347     *      none is specified, default value is <samp>' / '</samp></li> 
     
    372372        $options['start_year'] = date("Y"); 
    373373        $options['end_year'] = date("Y") + 7; 
    374         $options['field_seperator'] = " / ";         
     374        $options['field_separator'] = " / ";         
    375375 
    376376        //  Find name and initial value of year field, 
     
    396396        //  Output month and year selectors in desired order 
    397397        if($options['month_before_year']) { 
    398             $select_html =  $month_select . $options['field_seperator'] 
     398            $select_html =  $month_select . $options['field_separator'] 
    399399                .  $year_select;      
    400400        } else { 
    401             $select_html =  $year_select . $options['field_seperator'] 
     401            $select_html =  $year_select . $options['field_separator'] 
    402402                .  $month_select; 
    403403        } 
     
    11431143     *    <li><samp>'discard_year' => true</samp> Don't show a year 
    11441144     *      menu.  If absent or false, year menu will be output.</li> 
    1145      *    <li><samp>'field_seperator' => '</samp><i>string</i><samp>'</samp> 
     1145     *    <li><samp>'field_separator' => '</samp><i>string</i><samp>'</samp> 
    11461146     *      String to insert between the submenus in the output.  If 
    11471147     *      absent, one blank will be inserted.</li>  
     
    11711171//                  . " attribute='$this->attribute_name'"); 
    11721172//        error_log("options=".var_export($options,true)); 
     1173 
     1174        //  Handle historically misspelled options 
     1175        if (array_key_exists('field_seperator', $options)) { 
     1176            $options['field_separator'] = $options['field_seperator']; 
     1177            unset($options['field_seperator']); 
     1178        } 
    11731179        $defaults = array('discard_type' => true); 
    11741180        $options  = array_merge($defaults, $options); 
     
    12411247        //  (default blank) 
    12421248        if(count($date_select)) { 
    1243             $seperator = array_key_exists('field_seperator',$options) 
    1244                 ? $options['field_seperator'] : " "; 
    1245             $date_select = implode($seperator, $date_select);             
     1249            $separator = array_key_exists('field_separator',$options) 
     1250                ? $options['field_separator'] : " "; 
     1251            $date_select = implode($separator, $date_select);             
    12461252        } 
    12471253 
     
    13921398        $options['start_year'] = date("Y"); 
    13931399        $options['end_year'] = date("Y") + 7; 
    1394         $options['field_seperator'] = " / "; 
     1400        $options['field_separator'] = " / "; 
    13951401        return $this->to_date_select_tag($options);                
    13961402    }   
  • trunk/trax/vendor/trax/action_view/helpers/form_helper.php

    • Property svn:keywords set to Id
  • trunk/trax/vendor/trax/action_view/helpers/form_options_helper.php

    • Property svn:keywords set to Id
  • trunk/trax/vendor/trax/action_view/helpers/form_tag_helper.php

    • Property svn:keywords set to Id
  • trunk/trax/vendor/trax/action_view/helpers/javascript_helper.php

    • Property svn:keywords set to Id
  • trunk/trax/vendor/trax/action_view/helpers/url_helper.php

    • Property svn:keywords set to Id
    r196 r199  
    3131/** 
    3232 *  @todo Document this class 
    33  *  @package PHPonTrax 
    3433 */ 
    3534class UrlHelper extends Helpers { 
    3635 
    3736    /** 
    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. 
     37     * Creates a link tag of the given +name+ using an URL created by 
     38     * the set of +options+.  
     39     * It's also possible to pass a string instead of an options hash 
     40     * to get a link tag that just points without consideration. If 
     41     * null is passed as a name, the link itself will become the 
     42     * name.  
     43     * The $html_options have a special feature for creating 
     44     * javascript confirm alerts where if you pass ":confirm" => 'Are 
     45     * you sure?',  
     46     * the link will be guarded with a JS popup asking that 
     47     * question. If the user accepts, the link is processed, otherwise 
     48     * not.  
    4349     * 
    4450     * Example: 
    45      *   link_to("Delete this page", array(":action" => "delete", ":id" => $page->id), array(":confirm" => "Are you sure?")) 
     51     *   link_to("Delete this page", array(":action" => "delete", 
     52     * ":id" => $page->id), array(":confirm" => "Are you sure?"))  
     53     *  @return string 
     54     *  @uses content_tag() 
     55     *  @uses convert_confirm_option_to_javascript() 
     56     *  @uses url_for() 
    4657     */ 
    4758    function link_to($name, $options = array(), $html_options = array()) { 
    48         $html_options = $this->convert_confirm_option_to_javascript($html_options); 
     59        $html_options = 
     60            $this->convert_confirm_option_to_javascript($html_options); 
    4961        if(is_string($options)) { 
    5062            $href = array("href" => $options); 
     
    90102    /** 
    91103     *  @todo Document this method 
     104     *  @param mixed[] 
     105     *  @param mixed[] 
     106     *  @return mixed[] 
    92107     */ 
    93108    function convert_boolean_attributes(&$html_options, $bool_attrs) { 
     
    102117    /** 
    103118     *  @todo Document this method 
     119     *  @param string 
     120     *  @param mixed[] 
     121     *  @param mixed[] 
     122     *  @return string 
     123     *  @uses convert_boolean_attributes() 
     124     *  @uses convert_confirm_option_to_javascript() 
     125     *  @uses url_for() 
    104126     */ 
    105127    function button_to($name, $options = array(), $html_options = null) { 
     
    115137        } 
    116138 
    117         $html_options = array_merge($html_options, array("type" => "submit", "value" => $name)); 
    118         return "<form method=\"post\" action=\"" .  htmlspecialchars($url) . "\" class=\"button-to\"><div>" . 
    119             $this->tag("input", $html_options) . "</div></form>"; 
    120     } 
    121  
    122     /** 
    123      * This tag is deprecated. Combine the link_to and AssetTagHelper::image_tag yourself instead, like: 
    124      *   link_to(image_tag("rss", array("size" => "30x45"), array("border" => 0)), "http://www.example.com") 
    125      */ 
    126     function link_image_to($src, $options = array(), $html_options = array()) { 
     139        $html_options = array_merge($html_options, 
     140                              array("type" => "submit", "value" => $name)); 
     141        return "<form method=\"post\" action=\"" .  htmlspecialchars($url) 
     142            . "\" class=\"button-to\"><div>" 
     143            . $this->tag("input", $html_options) . "</div></form>"; 
     144    } 
     145 
     146    /** 
     147     * This tag is deprecated. Combine the link_to and 
     148     * AssetTagHelper::image_tag yourself instead, like:  
     149     *   link_to(image_tag("rss", array("size" => "30x45"), 
     150     * array("border" => 0)), "http://www.example.com")  
     151     *  @todo Document this method 
     152     */ 
     153    function link_image_to($src, $options = array(), 
     154                           $html_options = array()) {  
    127155        $image_options = array("src" => (ereg("/", $src) ? $src : "/images/$src")); 
    128156        if (!ereg(".", $image_options["src"])) $image_options["src"] .= ".png"; 
     
    155183 
    156184    /** 
    157      *  Return the URL for the set of $options provided. 
     185     *  Generate URL based on current URL and optional arguments 
     186     * 
     187     *  Output a URL with controller and optional action and id. 
     188     *  The output URL has the same method, host and 
     189     *  <samp>TRAX_URL_PREFIX</samp> as  
     190     *  the current URL.  Controller is either the current controller 
     191     *  or a controller specified in $options.  Action and ID are 
     192     *  optionally specified in $options, or omitted.  The 
     193     *  <samp>':id'</samp> option will be ignored if the <samp>':action'</samp> 
     194     *  option is omitted. 
     195     *  @param mixed[] 
     196     *  <ul> 
     197     *    <li><b>string:</b><br /> 
     198     *      The string value is returned immediately with no 
     199     *      substitutions.</li> 
     200     *    <li><b>array:</b> 
     201     *     <ul> 
     202     *       <li><samp>':controller'=></samp><i>controller value</i></li> 
     203     *       <li><samp>':action'=></samp><i>action value</i></li> 
     204     *       <li><samp>':id'=></samp><i>id value</i></li> 
     205     *     </ul> 
     206     *  </ul> 
     207     *  @return string 
     208     *  @uses controller_path 
    158209     */ 
    159210    function url_for($options = array()) { 
     
    162213        $extra_params = array(); 
    163214        if(is_string($options)) { 
    164             //$url[] = $options; 
     215 
     216            //  Argument is a string, just return it 
    165217            return $options; 
     218 
    166219        } elseif(is_array($options)) { 
     220 
     221            //  Argument is a (possibly empty) array 
     222            //  Start forming URL with this host 
    167223            $url_base = $_SERVER['HTTP_HOST']; 
    168224            if(substr($url_base, -1) == "/") { 
    169225                # remove the ending slash 
    170                 $url_base = substr($url_base, 0, -1);                              
     226                $url_base = substr($url_base, 0, -1); 
    171227            }            
    172              
     228 
     229            //  Method is same as was used by the current URL 
    173230            if($_SERVER['SERVER_PORT'] == 443) { 
    174231                $url_base = "https://".$url_base; 
     
    176233                $url_base = "http://".$url_base; 
    177234            } 
     235            //  Insert value of TRAX_URL_PREFIX (must start with /) 
    178236            if(!is_null(TRAX_URL_PREFIX)) { 
    179                 $url_base .= "/".TRAX_URL_PREFIX; 
     237                $url_base .= TRAX_URL_PREFIX; 
    180238            } 
    181239             
     240            //  Get controller from $options or $controller_path 
    182241            if(array_key_exists(":controller", $options)) { 
    183242                if($controller = $options[":controller"]) { 
     
    192251                $url[] = $controller; 
    193252            } 
    194              
     253 
     254            //  If controller found, get action from $options 
    195255            if(count($url)) { 
    196256                if(array_key_exists(":action", $options)) { 
     
    200260                }  
    201261            } 
     262 
     263            //  If controller and action found, get id from $actions 
    202264            if(count($url) > 1) { 
    203265                if(array_key_exists(":id", $options)) { 
     
    226288            $url_base .= "/";     
    227289        }  
    228         return $url_base . implode("/", $url) . (count($extra_params) ? "?".http_build_query($extra_params) : null); 
     290        return $url_base . implode("/", $url) 
     291            . (count($extra_params) 
     292               ? "?".http_build_query($extra_params) : null); 
    229293    }     
    230294 
     
    232296 
    233297/** 
    234  *  Avialble functions for use in views 
    235  *  @todo Document this function 
     298 *  Make a new UrlHelper object and call its link_to() method 
     299 *  @uses UrlHelper::link_to() 
    236300 */ 
    237301function link_to($name, $options = array(), $html_options = array()) { 
     
    240304} 
    241305 
     306/** 
     307 *  Make a new UrlHelper object and call its link_image_to() method 
     308 *  @uses UrlHelper::link_image_to() 
     309 */ 
    242310function link_image_to($src, $options = array(), $html_options = array()) { 
    243311    $url_helper = new UrlHelper(); 
     
    245313} 
    246314 
     315/** 
     316 *  Make a new UrlHelper object and call its button_to() method 
     317 *  @uses UrlHelper::button_to() 
     318 */ 
    247319function button_to($name, $options = array(), $html_options = null) { 
    248320    $url_helper = new UrlHelper(); 
     
    250322} 
    251323 
     324/** 
     325 *  Make a new UrlHelper object and call its url_for() method 
     326 *  @uses UrlHelper::url_for() 
     327 */ 
    252328function url_for($options = array()) { 
    253329    $url_helper = new UrlHelper();