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

Source for file form_tag_helper.php

Documentation is available at form_tag_helper.php

  1. <?php
  2. /**
  3.  *  File containing the FormTagHelper class and support functions
  4.  *
  5.  *  (PHP 5)
  6.  *
  7.  *  @package PHPonTrax
  8.  *  @version $Id: form_tag_helper.php 228 2006-07-16 15:53:11Z john $
  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.  *  @todo Document this class
  33.  */
  34. class FormTagHelper extends Helpers {
  35.  
  36.     /**
  37.      *  @todo Document this method
  38.      */
  39.     function form_tag($url_for_options array()$options array()) {
  40.         $html_options array_merge(array("method" => "post")$options);
  41.  
  42.         if(array_key_exists('multipart',$html_options)
  43.        && $html_options['multipart']{
  44.             $html_options['enctype'"multipart/form-data";
  45.             unset($html_options['multipart']);
  46.         }
  47.  
  48.         $html_options['action'url_for($url_for_options);
  49.         return $this->tag("form"$html_optionstrue);
  50.     }
  51.  
  52.     /**
  53.      *  @todo Document this method
  54.      *
  55.      */
  56.     function start_form_tag({
  57.         $args func_get_args();
  58.         return call_user_func_array(array($this'form_tag')$args);
  59.     }
  60.  
  61.     /**
  62.      *  @todo Document this method
  63.      *
  64.      */
  65.     function select_tag($name$option_tags null$options array()) {
  66.         if(is_array($option_tags)) {
  67.             $option_tags implode(''$option_tags);    
  68.         }
  69.         return $this->content_tag("select"$option_tagsarray_merge(array("name" => $name"id" => $name)$this->convert_options($options)));
  70.     }
  71.  
  72.     /**
  73.      *  @todo Document this method
  74.      *
  75.      */
  76.     function text_field_tag($name$value null$options array()) {
  77.         return $this->tag("input"array_merge(array("type" => "text""name" => $name"id" => $name"value" => $value)$this->convert_options($options)));
  78.     }
  79.  
  80.     /**
  81.      *  @todo Document this method
  82.      *
  83.      */
  84.     function hidden_field_tag($name$value null$options array()) {
  85.         return $this->text_field_tag($name$valuearray_merge($optionsarray("type" => "hidden")));
  86.     }
  87.  
  88.     /**
  89.      *  @todo Document this method
  90.      *
  91.      */
  92.     function file_field_tag($name$options array()) {
  93.         return $this->text_field_tag($namenullarray_merge($this->convert_options($options)array("type" => "file")));
  94.     }
  95.  
  96.     /**
  97.      *  @todo Document this method
  98.      *
  99.      */
  100.     function password_field_tag($name "password"$value null$options array()) {
  101.         return $this->text_field_tag($name$valuearray_merge($this->convert_options($options)array("type" => "password")));
  102.     }
  103.  
  104.     /**
  105.      *  @todo Document this method
  106.      *
  107.      */
  108.     function text_area_tag($name$content null$options array()) {
  109.         if ($options["size"]{
  110.             $size explode('x'$options["size"]);
  111.             $options["cols"reset($size);
  112.             $options["rows"end($size);
  113.             unset($options["size"]);
  114.         }
  115.  
  116.         return $this->content_tag("textarea"$contentarray_merge(array("name" => $name"id" => $name)$this->convert_options($options)));
  117.     }
  118.  
  119.     /**
  120.      *  @todo Document this method
  121.      *
  122.      */
  123.     function check_box_tag($name$value "1"$checked false$options array()) {
  124.         $html_options array_merge(array("type" => "checkbox""name" => $name"id" => $name"value" => $value)$this->convert_options($options));
  125.         if ($checked$html_options["checked""checked";
  126.         return $this->tag("input"$html_options);
  127.     }
  128.  
  129.     /**
  130.      *  @todo Document this method
  131.      *
  132.      */
  133.     function radio_button_tag($name$value$checked false$options array()) {
  134.         $html_options array_merge(array("type" => "radio""name" => $name"id" => $name"value" => $value)$this->convert_options($options));
  135.         if ($checked$html_options["checked""checked";
  136.         return $this->tag("input"$html_options);
  137.     }
  138.  
  139.     /**
  140.      *  @todo Document this method
  141.      *
  142.      */
  143.     function submit_tag($value "Save changes"$options array()) {
  144.         return $this->tag("input"array_merge(array("type" => "submit""name" => "commit""value" => $value)$this->convert_options($options)));
  145.     }
  146.  
  147.     /**
  148.      *
  149.      *  @todo Document this method
  150.      *  @uses tag()
  151.      */
  152.     function image_submit_tag($source$options array()) {
  153.         return $this->tag("input",
  154.               array_merge(array("type" => "image",
  155.                         "src" => image_path($source)),
  156.                       $this->convert_options($options)));
  157.     }
  158.  
  159. }
  160.  
  161. /**
  162.  *  @todo Document this method
  163.  *   Avialble functions for use in views
  164.  */
  165. function form_tag({
  166.     $form_tag_helper new FormTagHelper();
  167.     $args func_get_args();
  168.     return call_user_func_array(array($form_tag_helper'form_tag')$args);
  169. }
  170.  
  171. /**
  172.  *  @todo Document this method
  173.  *
  174.  */
  175. function start_form_tag({
  176.     $args func_get_args();
  177.     return call_user_func_array('form_tag'$args);
  178. }
  179.  
  180. /**
  181.  *  @todo Document this method
  182.  *
  183.  */
  184. function end_form_tag({
  185.     return "</form>";
  186. }
  187.  
  188. /**
  189.  *  @todo Document this method
  190.  *
  191.  */
  192. function select_tag({
  193.     $form_tag_helper new FormTagHelper();
  194.     $args func_get_args();
  195.     return call_user_func_array(array($form_tag_helper'select_tag')$args);
  196. }
  197.  
  198. /**
  199.  *  @todo Document this method
  200.  *
  201.  */
  202. function text_field_tag({
  203.     $form_tag_helper new FormTagHelper();
  204.     $args func_get_args();
  205.     return call_user_func_array(array($form_tag_helper'text_field_tag')$args);
  206. }
  207.  
  208. /**
  209.  *  @todo Document this method
  210.  *
  211.  */
  212. function hidden_field_tag({
  213.     $form_tag_helper new FormTagHelper();
  214.     $args func_get_args();
  215.     return call_user_func_array(array($form_tag_helper'hidden_field_tag')$args);
  216. }
  217.  
  218. /**
  219.  *
  220.  *  @todo Document this method
  221.  */
  222. function file_field_tag({
  223.     $form_tag_helper new FormTagHelper();
  224.     $args func_get_args();
  225.     return call_user_func_array(array($form_tag_helper'file_field_tag')$args);
  226. }
  227.  
  228. /**
  229.  *
  230.  *  @todo Document this method
  231.  */
  232. function password_field_tag({
  233.     $form_tag_helper new FormTagHelper();
  234.     $args func_get_args();
  235.     return call_user_func_array(array($form_tag_helper'password_field_tag')$args);
  236. }
  237.  
  238. /**
  239.  *
  240.  *  @todo Document this method
  241.  */
  242. function text_area_tag({
  243.     $form_tag_helper new FormTagHelper();
  244.     $args func_get_args();
  245.     return call_user_func_array(array($form_tag_helper'text_area_tag')$args);
  246. }
  247.  
  248. /**
  249.  *
  250.  *  @todo Document this method
  251.  */
  252. function check_box_tag({
  253.     $form_tag_helper new FormTagHelper();
  254.     $args func_get_args();
  255.     return call_user_func_array(array($form_tag_helper'check_box_tag')$args);
  256. }
  257.  
  258. /**
  259.  *
  260.  *  @todo Document this method
  261.  */
  262. function radio_button_tag({
  263.     $form_tag_helper new FormTagHelper();
  264.     $args func_get_args();
  265.     return call_user_func_array(array($form_tag_helper'radio_button_tag')$args);
  266. }
  267.  
  268. /**
  269.  *
  270.  *  @todo Document this method
  271.  */
  272. function submit_tag({
  273.     $form_tag_helper new FormTagHelper();
  274.     $args func_get_args();
  275.     return call_user_func_array(array($form_tag_helper'submit_tag')$args);
  276. }
  277.  
  278. /**
  279.  *  @todo Document this method
  280.  *
  281.  */
  282. function image_submit_tag({
  283.     $form_tag_helper new FormTagHelper();
  284.     $args func_get_args();
  285.     return call_user_func_array(array($form_tag_helper'image_submit_tag')$args);
  286. }
  287.  
  288. ?>

Documentation generated on Mon, 21 May 2007 22:28:33 -0600 by phpDocumentor 1.3.2