[ Index ] |
|
Code source de osCommerce 2.2ms2-060817 |
1 <?php 2 /* 3 $Id: html_output.php,v 1.29 2003/06/25 20:32:44 hpdl Exp $ 4 5 osCommerce, Open Source E-Commerce Solutions 6 http://www.oscommerce.com 7 8 Copyright (c) 2003 osCommerce 9 10 Released under the GNU General Public License 11 */ 12 13 //// 14 // The HTML href link wrapper function 15 function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL') { 16 if ($page == '') { 17 die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br><br>Function used:<br><br>tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>'); 18 } 19 if ($connection == 'NONSSL') { 20 $link = HTTP_SERVER . DIR_WS_ADMIN; 21 } elseif ($connection == 'SSL') { 22 if (ENABLE_SSL == 'true') { 23 $link = HTTPS_SERVER . DIR_WS_ADMIN; 24 } else { 25 $link = HTTP_SERVER . DIR_WS_ADMIN; 26 } 27 } else { 28 die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL<br><br>Function used:<br><br>tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>'); 29 } 30 if ($parameters == '') { 31 $link = $link . $page . '?' . SID; 32 } else { 33 $link = $link . $page . '?' . $parameters . '&' . SID; 34 } 35 36 while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1); 37 38 return $link; 39 } 40 41 function tep_catalog_href_link($page = '', $parameters = '', $connection = 'NONSSL') { 42 if ($connection == 'NONSSL') { 43 $link = HTTP_CATALOG_SERVER . DIR_WS_CATALOG; 44 } elseif ($connection == 'SSL') { 45 if (ENABLE_SSL_CATALOG == 'true') { 46 $link = HTTPS_CATALOG_SERVER . DIR_WS_CATALOG; 47 } else { 48 $link = HTTP_CATALOG_SERVER . DIR_WS_CATALOG; 49 } 50 } else { 51 die('</td></tr></table></td></tr></table><br><br><font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL<br><br>Function used:<br><br>tep_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>'); 52 } 53 if ($parameters == '') { 54 $link .= $page; 55 } else { 56 $link .= $page . '?' . $parameters; 57 } 58 59 while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1); 60 61 return $link; 62 } 63 64 //// 65 // The HTML image wrapper function 66 function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') { 67 $image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"'; 68 69 if (tep_not_null($alt)) { 70 $image .= ' title=" ' . tep_output_string($alt) . ' "'; 71 } 72 73 if (tep_not_null($width) && tep_not_null($height)) { 74 $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"'; 75 } 76 77 if (tep_not_null($parameters)) $image .= ' ' . $parameters; 78 79 $image .= '>'; 80 81 return $image; 82 } 83 84 //// 85 // The HTML form submit button wrapper function 86 // Outputs a button in the selected language 87 function tep_image_submit($image, $alt = '', $parameters = '') { 88 global $language; 89 90 $image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" border="0" alt="' . tep_output_string($alt) . '"'; 91 92 if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "'; 93 94 if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters; 95 96 $image_submit .= '>'; 97 98 return $image_submit; 99 } 100 101 //// 102 // Draw a 1 pixel black line 103 function tep_black_line() { 104 return tep_image(DIR_WS_IMAGES . 'pixel_black.gif', '', '100%', '1'); 105 } 106 107 //// 108 // Output a separator either through whitespace, or with an image 109 function tep_draw_separator($image = 'pixel_black.gif', $width = '100%', $height = '1') { 110 return tep_image(DIR_WS_IMAGES . $image, '', $width, $height); 111 } 112 113 //// 114 // Output a function button in the selected language 115 function tep_image_button($image, $alt = '', $params = '') { 116 global $language; 117 118 return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $params); 119 } 120 121 //// 122 // javascript to dynamically update the states/provinces list when the country is changed 123 // TABLES: zones 124 function tep_js_zone_list($country, $form, $field) { 125 $countries_query = tep_db_query("select distinct zone_country_id from " . TABLE_ZONES . " order by zone_country_id"); 126 $num_country = 1; 127 $output_string = ''; 128 while ($countries = tep_db_fetch_array($countries_query)) { 129 if ($num_country == 1) { 130 $output_string .= ' if (' . $country . ' == "' . $countries['zone_country_id'] . '") {' . "\n"; 131 } else { 132 $output_string .= ' } else if (' . $country . ' == "' . $countries['zone_country_id'] . '") {' . "\n"; 133 } 134 135 $states_query = tep_db_query("select zone_name, zone_id from " . TABLE_ZONES . " where zone_country_id = '" . $countries['zone_country_id'] . "' order by zone_name"); 136 137 $num_state = 1; 138 while ($states = tep_db_fetch_array($states_query)) { 139 if ($num_state == '1') $output_string .= ' ' . $form . '.' . $field . '.options[0] = new Option("' . PLEASE_SELECT . '", "");' . "\n"; 140 $output_string .= ' ' . $form . '.' . $field . '.options[' . $num_state . '] = new Option("' . $states['zone_name'] . '", "' . $states['zone_id'] . '");' . "\n"; 141 $num_state++; 142 } 143 $num_country++; 144 } 145 $output_string .= ' } else {' . "\n" . 146 ' ' . $form . '.' . $field . '.options[0] = new Option("' . TYPE_BELOW . '", "");' . "\n" . 147 ' }' . "\n"; 148 149 return $output_string; 150 } 151 152 //// 153 // Output a form 154 function tep_draw_form($name, $action, $parameters = '', $method = 'post', $params = '') { 155 $form = '<form name="' . tep_output_string($name) . '" action="'; 156 if (tep_not_null($parameters)) { 157 $form .= tep_href_link($action, $parameters); 158 } else { 159 $form .= tep_href_link($action); 160 } 161 $form .= '" method="' . tep_output_string($method) . '"'; 162 if (tep_not_null($params)) { 163 $form .= ' ' . $params; 164 } 165 $form .= '>'; 166 167 return $form; 168 } 169 170 //// 171 // Output a form input field 172 function tep_draw_input_field($name, $value = '', $parameters = '', $required = false, $type = 'text', $reinsert_value = true) { 173 $field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"'; 174 175 if (isset($GLOBALS[$name]) && ($reinsert_value == true) && is_string($GLOBALS[$name])) { 176 $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"'; 177 } elseif (tep_not_null($value)) { 178 $field .= ' value="' . tep_output_string($value) . '"'; 179 } 180 181 if (tep_not_null($parameters)) $field .= ' ' . $parameters; 182 183 $field .= '>'; 184 185 if ($required == true) $field .= TEXT_FIELD_REQUIRED; 186 187 return $field; 188 } 189 190 //// 191 // Output a form password field 192 function tep_draw_password_field($name, $value = '', $required = false) { 193 $field = tep_draw_input_field($name, $value, 'maxlength="40"', $required, 'password', false); 194 195 return $field; 196 } 197 198 //// 199 // Output a form filefield 200 function tep_draw_file_field($name, $required = false) { 201 $field = tep_draw_input_field($name, '', '', $required, 'file'); 202 203 return $field; 204 } 205 206 //// 207 // Output a selection field - alias function for tep_draw_checkbox_field() and tep_draw_radio_field() 208 function tep_draw_selection_field($name, $type, $value = '', $checked = false, $compare = '') { 209 $selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"'; 210 211 if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"'; 212 213 if ( ($checked == true) || (isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ($GLOBALS[$name] == 'on')) || (isset($value) && isset($GLOBALS[$name]) && (stripslashes($GLOBALS[$name]) == $value)) || (tep_not_null($value) && tep_not_null($compare) && ($value == $compare)) ) { 214 $selection .= ' CHECKED'; 215 } 216 217 $selection .= '>'; 218 219 return $selection; 220 } 221 222 //// 223 // Output a form checkbox field 224 function tep_draw_checkbox_field($name, $value = '', $checked = false, $compare = '') { 225 return tep_draw_selection_field($name, 'checkbox', $value, $checked, $compare); 226 } 227 228 //// 229 // Output a form radio field 230 function tep_draw_radio_field($name, $value = '', $checked = false, $compare = '') { 231 return tep_draw_selection_field($name, 'radio', $value, $checked, $compare); 232 } 233 234 //// 235 // Output a form textarea field 236 function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) { 237 $field = '<textarea name="' . tep_output_string($name) . '" wrap="' . tep_output_string($wrap) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"'; 238 239 if (tep_not_null($parameters)) $field .= ' ' . $parameters; 240 241 $field .= '>'; 242 243 if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) { 244 $field .= tep_output_string_protected(stripslashes($GLOBALS[$name])); 245 } elseif (tep_not_null($text)) { 246 $field .= tep_output_string_protected($text); 247 } 248 249 $field .= '</textarea>'; 250 251 return $field; 252 } 253 254 //// 255 // Output a form hidden field 256 function tep_draw_hidden_field($name, $value = '', $parameters = '') { 257 $field = '<input type="hidden" name="' . tep_output_string($name) . '"'; 258 259 if (tep_not_null($value)) { 260 $field .= ' value="' . tep_output_string($value) . '"'; 261 } elseif (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) { 262 $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"'; 263 } 264 265 if (tep_not_null($parameters)) $field .= ' ' . $parameters; 266 267 $field .= '>'; 268 269 return $field; 270 } 271 272 //// 273 // Output a form pull down menu 274 function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) { 275 $field = '<select name="' . tep_output_string($name) . '"'; 276 277 if (tep_not_null($parameters)) $field .= ' ' . $parameters; 278 279 $field .= '>'; 280 281 if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]); 282 283 for ($i=0, $n=sizeof($values); $i<$n; $i++) { 284 $field .= '<option value="' . tep_output_string($values[$i]['id']) . '"'; 285 if ($default == $values[$i]['id']) { 286 $field .= ' SELECTED'; 287 } 288 289 $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>'; 290 } 291 $field .= '</select>'; 292 293 if ($required == true) $field .= TEXT_FIELD_REQUIRED; 294 295 return $field; 296 } 297 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 19:48:25 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |