formUtility Class Reference

List of all members.

Static Public Member Functions

  • static UpFormat ($key, $format)
    for update format sprintf for key , this var self::$format
  • static image_submit ($image='', $text= '', $parameters= '', $classCss='')
    The HTML form submit button wrapper function.
  • static image_button ($image, $alt= '', $params= '')
  • static draw_form ($name, $action, $parameters= '', $method= 'post', $params= '')
    Output a form.
  • static draw_input_field ($name, $id='', $value= '', $parameters= '', $required=false, $type= 'text', $reinsert_value=true)
  • static draw_selection_field ($name, $id='', $type, $value= '', $checked=false, $compare= '', $parameters= '')
    Output a selection field - alias function for tep_draw_checkbox_field() and tep_draw_radio_field().
  • static draw_textarea_field ($name, $id= '', $width, $height, $text= '', $parameters= '', $reinsert_value=true)
    Output a form textarea field.
  • static draw_hidden_field ($name, $id= '', $value= '', $parameters= '')
    Output a form hidden field.
  • static draw_pull_down_menu ($name, $values, $default= '', $parameters= '', $required=false)
    Output a form pull down menu.
  • static draw_pull_down_radio ($name, $id= '', $values, $default= '', $parameters= '', $required=false)
    Output a form pull down menu on radio set.
  • static draw_pull_down_checkbox ($name, $id= '', $values, $default= '', $parameters= '', $required=false)
    Output a form pull down menu on radio set.

Static Protected Attributes

Static Private Member Functions

  • static gener_id ($id_propose)
  • static HtmlAddId ($id, $name)
    this function creat new id , if is exist, for W3C and id css check

Detailed Description

Definition at line 12 of file formUtility.php.


Member Function Documentation

static formUtility::draw_form ( name,
action,
parameters = '',
method = 'post',
params = '' 
) [static]

Output a form.

Parameters:
$name name html form
$action url or file
$parameters param GET for file or null
$method post/get
$params param html

Definition at line 94 of file formUtility.php.

Referenced by tep_draw_form().

00094                                                                                                      {
00095     $form = '<form id="' . tep_output_string($name) . '" action="';
00096 
00097     if( (substr($action, 0, 4 ) !='http')  ){
00098       if (tep_not_null($parameters))$form .= tep_href_link($action, $parameters);
00099       else $form .= tep_href_link($action);
00100     }
00101     else $form .=$action;
00102 
00103     $form .= '" method="' . tep_output_string($method) . '"';
00104     if (tep_not_null($params)) {
00105       $form .= ' ' . $params;
00106     }
00107     $form .= '>';
00108 
00109     return $form;
00110   }

static formUtility::draw_hidden_field ( name,
id = '',
value = '',
parameters = '' 
) [static]

Output a form hidden field.

Definition at line 165 of file formUtility.php.

Referenced by tep_draw_hidden_field().

00165                                                                                            {
00166     $field = '<input type="hidden" name="' . tep_output_string($name) . '"'
00167             .self::HtmlAddId($id,$name);
00168 
00169     if (tep_not_null($value))  $field .= ' value="' . tep_output_string($value) . '"';
00170     elseif (isset($GLOBALS[$name]) && is_string($GLOBALS[$name]))  $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"';
00171 
00172     if (tep_not_null($parameters)) $field .= ' ' . $parameters;
00173     $field .= ' />';
00174     return $field;
00175   }

static formUtility::draw_input_field ( name,
id = '',
value = '',
parameters = '',
required = false,
type = 'text',
reinsert_value = true 
) [static]

Definition at line 114 of file formUtility.php.

Referenced by tep_draw_file_field(), tep_draw_input_field(), and tep_draw_password_field().

00114                                                                                                                                                    {
00115     $field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"'
00116             .self::HtmlAddId($id,$name);
00117 
00118     if (isset($GLOBALS[$name]) && ($reinsert_value == true) && is_string($GLOBALS[$name]))   $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"';
00119     elseif (tep_not_null($value))  $field .= ' value="' . tep_output_string($value) . '"';
00120 
00121     if (tep_not_null($parameters)) $field .= ' ' . $parameters;
00122 
00123     $field .= ' />';
00124 
00125     if ($required == true) $field .= '<span class="nobr">'.TEXT_FIELD_REQUIRED.'</span>';
00126 
00127     return $field;
00128   }

static formUtility::draw_pull_down_checkbox ( name,
id = '',
values,
default = '',
parameters = '',
required = false 
) [static]

Output a form pull down menu on radio set.

Definition at line 220 of file formUtility.php.

Referenced by tep_draw_pull_down_checkbox().

00220                                                                                                                              {
00221     $field = '<ul>'."\n";
00222     if (!tep_not_null($id))  $id=tep_output_string($name);
00223     if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);
00224     for ($i=0, $n=sizeof($values); $i<$n; $i++) {
00225       $field .=tep_draw_checkbox_field($name, $id.$i, tep_output_string($values[$i]['id']),( ($default == $values[$i]['id'])? true:false), $parameters);
00226       $field .= $values[$i]['text'] . '&nbsp;';
00227     }
00228     $field .= '</ul>';
00229     if ($required == true) $field .= TEXT_FIELD_REQUIRED;
00230 
00231     return $field;
00232   }

static formUtility::draw_pull_down_menu ( name,
values,
default = '',
parameters = '',
required = false 
) [static]

Output a form pull down menu.

Definition at line 180 of file formUtility.php.

Referenced by tep_draw_pull_down_menu().

00180                                                                                                                  {
00181     if (!preg_match('/id=/i',$parameters)) $field = '<select id="' . str_replace(array('[',']'),array(''),tep_output_string($name)) . '" name="' . tep_output_string($name) . '" ';
00182     else $field = '<select  name="' . tep_output_string($name) . '" ';
00183 
00184     if (tep_not_null($parameters)) $field .= ' ' . $parameters;
00185     $field .= '>';
00186     if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes((string)$GLOBALS[$name]);
00187 
00188     for ($i=0, $n=sizeof($values); $i<$n; $i++) {
00189       $field .= '<option value="' . tep_output_string($values[$i]['id']) . '"';
00190       if ($default == $values[$i]['id'])  $field .= ' selected="selected"';
00191       $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => '&#039;', '<' => '&lt;', '>' => '&gt;')) . '</option>';
00192     }
00193     $field .= '</select>';
00194 
00195     if ($required == true) $field .= TEXT_FIELD_REQUIRED;
00196 
00197     return $field;
00198   }

static formUtility::draw_pull_down_radio ( name,
id = '',
values,
default = '',
parameters = '',
required = false 
) [static]

Output a form pull down menu on radio set.

Definition at line 203 of file formUtility.php.

Referenced by tep_draw_pull_down_radio().

00203                                                                                                                           {
00204     $field = '<ul>'."\n";
00205     if (!tep_not_null($id))  $id=tep_output_string($name);
00206     if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);
00207     for ($i=0, $n=sizeof($values); $i<$n; $i++) {
00208       $field .=tep_draw_radio_field($name, $id.$i, tep_output_string($values[$i]['id']),( ($default == $values[$i]['id'])? true:false), $parameters);
00209       $field .= $values[$i]['text'] . '&nbsp;';
00210     }
00211     $field .= '</ul>';
00212     if ($required == true) $field .= TEXT_FIELD_REQUIRED;
00213 
00214     return $field;
00215   }

static formUtility::draw_selection_field ( name,
id = '',
type,
value = '',
checked = false,
compare = '',
parameters = '' 
) [static]

Output a selection field - alias function for tep_draw_checkbox_field() and tep_draw_radio_field().

Definition at line 134 of file formUtility.php.

Referenced by tep_draw_checkbox_field(), tep_draw_radio_field(), and tep_draw_selection_field().

00134                                                                                                                                     {
00135     $selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"'
00136                 .self::HtmlAddId($id,$name);
00137 
00138     if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"';
00139     if ( ($checked == true) || (@$GLOBALS[$name] == 'on') || ($value && (@$GLOBALS[$name] == $value)) || ($value && ($value == $compare)) )  $selection .= ' checked="checked"';
00140     if (tep_not_null($parameters)) $selection .= ' ' . $parameters;
00141     $selection .= ' />';
00142 
00143     return $selection;
00144   }

static formUtility::draw_textarea_field ( name,
id = '',
width,
height,
text = '',
parameters = '',
reinsert_value = true 
) [static]

Output a form textarea field.

Definition at line 149 of file formUtility.php.

Referenced by tep_draw_textarea_field().

00149                                                                                                                                      {
00150     $field = '<textarea name="' . tep_output_string($name) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"'
00151             .self::HtmlAddId($id,$name);
00152 
00153     if (tep_not_null($parameters)) $field .= ' ' . $parameters;
00154     $field .= '>';
00155     if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) )   $field .= tep_output_string_protected(stripslashes($GLOBALS[$name]));
00156     elseif (tep_not_null($text))$field .= tep_output_string_protected($text);
00157     $field .= '</textarea>';
00158     return $field;
00159   }

static formUtility::gener_id ( id_propose  )  [static, private]

Definition at line 23 of file formUtility.php.

00023                                                {
00024     if(!isset(self::$id_check[$id_propose])) return self::$id_check[$id_propose]=$id_propose;
00025     else {
00026       $id=$id_propose.rand(1,3);
00027 
00028      return self::gener_id($id);
00029     }
00030   }

formUtility::HtmlAddId ( id,
name 
) [static, private]

this function creat new id , if is exist, for W3C and id css check

Parameters:
$id string
$name string
Returns:
string id for css balise

Definition at line 39 of file formUtility.php.

00039                                               {
00040     return (!empty($id))
00041             ? ' ' . 'id="' . str_replace(array('[',']'),array(''),tep_output_string(self::gener_id($id))) . '"'
00042             : ' ' . 'id="' . str_replace(array('[',']'),array(''),tep_output_string(self::gener_id($name))) . '"';
00043   }

static formUtility::image_button ( image,
alt = '',
params = '' 
) [static]

Definition at line 80 of file formUtility.php.

Referenced by tep_image_button().

00080                                                                        {
00081     global $language;
00082     return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $params);
00083   }

formUtility::image_submit ( image = '',
alt = '',
parameters = '',
classCss = '' 
) [static]

The HTML form submit button wrapper function.

Parameters:
$image path url image Ou texte
$alt 
$parameters string for inline html
$classCss string for css class additional
Returns:
string <input type="submit" title=" Mettre à jour " value="Mettre à jour" class="button">

Definition at line 64 of file formUtility.php.

Referenced by tep_image_submit().

00064                                                                                             {
00065     return sprintf(self::$format[__function__],
00066                     tep_output_string($text),
00067                     tep_output_string($text) ,
00068                     'button '.$classCss,
00069                       ' '.(tep_not_null($image)? 'src="'.$image.'" ' : '').
00070                       ' '.$parameters
00071                     );
00072   }

formUtility::UpFormat ( key,
format 
) [static]

for update format sprintf for key , this var self::$format

Parameters:
$key string this name function call
$format new string for printf

Definition at line 51 of file formUtility.php.

00051                                                 {
00052     if(isset(self::$format[$key])) self::$format[$key]=$format;
00053   }


Member Data Documentation

formUtility::$format [static, protected]
Initial value:
array(
'image_submit'=>'<input type="submit" value="%s" title="%s"  class="%s" %s />'
                )

Definition at line 17 of file formUtility.php.

Referenced by UpFormat().

formUtility::$id_check = array() [static, protected]

Definition at line 21 of file formUtility.php.


The documentation for this class was generated from the following file: