| [ Index ] | osCommerce
Docs :: PHP Cross Reference For osCommerce 2.2 MS2 Provided By OSCdox.com |
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 = '', $params = '') { 67 $image = '<img src="' . $src . '" border="0" alt="' . $alt . '"'; 68 if ($alt) { 69 $image .= ' title=" ' . $alt . ' "'; 70 } 71 if ($width) { 72 $image .= ' width="' . $width . '"'; 73 } 74 if ($height) { 75 $image .= ' height="' . $height . '"'; 76 } 77 if ($params) { 78 $image .= ' ' . $params; 79 } 80 $image .= '>'; 81 82 return $image; 83 } 84 85 //// 86 // The HTML form submit button wrapper function 87 // Outputs a button in the selected language 88 function tep_image_submit($image, $alt = '', $parameters = '') { 89 global $language; 90 91 $image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" border="0" alt="' . tep_output_string($alt) . '"'; 92 93 if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "'; 94 95 if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters; 96 97 $image_submit .= '>'; 98 99 return $image_submit; 100 } 101 102 //// 103 // Draw a 1 pixel black line 104 function tep_black_line() { 105 return tep_image(DIR_WS_IMAGES . 'pixel_black.gif', '', '100%', '1'); 106 } 107 108 //// 109 // Output a separator either through whitespace, or with an image 110 function tep_draw_separator($image = 'pixel_black.gif', $width = '100%', $height = '1') { 111 return tep_image(DIR_WS_IMAGES . $image, '', $width, $height); 112 } 113 114 //// 115 // Output a function button in the selected language 116 function tep_image_button($image, $alt = '', $params = '') { 117 global $language; 118 119 return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $params); 120 } 121 122 //// 123 // javascript to dynamically update the states/provinces list when the country is changed 124 // TABLES: zones 125 function tep_js_zone_list($country, $form, $field) { 126 $countries_query = tep_db_query("select distinct zone_country_id from " . TABLE_ZONES . " order by zone_country_id"); 127 $num_country = 1; 128 $output_string = ''; 129 while ($countries = tep_db_fetch_array($countries_query)) { 130 if ($num_country == 1) { 131 $output_string .= ' if (' . $country . ' == "' . $countries['zone_country_id'] . '") {' . "\n"; 132 } else { 133 $output_string .= ' } else if (' . $country . ' == "' . $countries['zone_country_id'] . '") {' . "\n"; 134 } 135 136 $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"); 137 138 $num_state = 1; 139 while ($states = tep_db_fetch_array($states_query)) { 140 if ($num_state == '1') $output_string .= ' ' . $form . '.' . $field . '.options[0] = new Option("' . PLEASE_SELECT . '", "");' . "\n"; 141 $output_string .= ' ' . $form . '.' . $field . '.options[' . $num_state . '] = new Option("' . $states['zone_name'] . '", "' . $states['zone_id'] . '");' . "\n"; 142 $num_state++; 143 } 144 $num_country++; 145 } 146 $output_string .= ' } else {' . "\n" . 147 ' ' . $form . '.' . $field . '.options[0] = new Option("' . TYPE_BELOW . '", "");' . "\n" . 148 ' }' . "\n"; 149 150 return $output_string; 151 } 152 153 //// 154 // Output a form 155 function tep_draw_form($name, $action, $parameters = '', $method = 'post', $params = '') { 156 $form = '<form name="' . tep_output_string($name) . '" action="'; 157 if (tep_not_null($parameters)) { 158 $form .= tep_href_link($action, $parameters); 159 } else { 160 $form .= tep_href_link($action); 161 } 162 $form .= '" method="' . tep_output_string($method) . '"'; 163 if (tep_not_null($params)) { 164 $form .= ' ' . $params; 165 } 166 $form .= '>'; 167 168 return $form; 169 } 170 171 //// 172 // Output a form input field 173 function tep_draw_input_field($name, $value = '', $parameters = '', $required = false, $type = 'text', $reinsert_value = true) { 174 $field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"'; 175 176 if (isset($GLOBALS[$name]) && ($reinsert_value == true) && is_string($GLOBALS[$name])) { 177 $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"'; 178 } elseif (tep_not_null($value)) { 179 $field .= ' value="' . tep_output_string($value) . '"'; 180 } 181 182 if (tep_not_null($parameters)) $field .= ' ' . $parameters; 183 184 $field .= '>'; 185 186 if ($required == true) $field .= TEXT_FIELD_REQUIRED; 187 188 return $field; 189 } 190 191 //// 192 // Output a form password field 193 function tep_draw_password_field($name, $value = '', $required = false) { 194 $field = tep_draw_input_field($name, $value, 'maxlength="40"', $required, 'password', false); 195 196 return $field; 197 } 198 199 //// 200 // Output a form filefield 201 function tep_draw_file_field($name, $required = false) { 202 $field = tep_draw_input_field($name, '', '', $required, 'file'); 203 204 return $field; 205 } 206 207 //// 208 // Output a selection field - alias function for tep_draw_checkbox_field() and tep_draw_radio_field() 209 function tep_draw_selection_field($name, $type, $value = '', $checked = false, $compare = '') { 210 $selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"'; 211 212 if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"'; 213 214 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)) ) { 215 $selection .= ' CHECKED'; 216 } 217 218 $selection .= '>'; 219 220 return $selection; 221 } 222 223 //// 224 // Output a form checkbox field 225 function tep_draw_checkbox_field($name, $value = '', $checked = false, $compare = '') { 226 return tep_draw_selection_field($name, 'checkbox', $value, $checked, $compare); 227 } 228 229 //// 230 // Output a form radio field 231 function tep_draw_radio_field($name, $value = '', $checked = false, $compare = '') { 232 return tep_draw_selection_field($name, 'radio', $value, $checked, $compare); 233 } 234 235 //// 236 // Output a form textarea field 237 function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) { 238 $field = '<textarea name="' . tep_output_string($name) . '" wrap="' . tep_output_string($wrap) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"'; 239 240 if (tep_not_null($parameters)) $field .= ' ' . $parameters; 241 242 $field .= '>'; 243 244 if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) { 245 $field .= stripslashes($GLOBALS[$name]); 246 } elseif (tep_not_null($text)) { 247 $field .= $text; 248 } 249 250 $field .= '</textarea>'; 251 252 return $field; 253 } 254 255 //// 256 // Output a form hidden field 257 function tep_draw_hidden_field($name, $value = '', $parameters = '') { 258 $field = '<input type="hidden" name="' . tep_output_string($name) . '"'; 259 260 if (tep_not_null($value)) { 261 $field .= ' value="' . tep_output_string($value) . '"'; 262 } elseif (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) { 263 $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"'; 264 } 265 266 if (tep_not_null($parameters)) $field .= ' ' . $parameters; 267 268 $field .= '>'; 269 270 return $field; 271 } 272 273 //// 274 // Output a form pull down menu 275 function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) { 276 $field = '<select name="' . tep_output_string($name) . '"'; 277 278 if (tep_not_null($parameters)) $field .= ' ' . $parameters; 279 280 $field .= '>'; 281 282 if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]); 283 284 for ($i=0, $n=sizeof($values); $i<$n; $i++) { 285 $field .= '<option value="' . tep_output_string($values[$i]['id']) . '"'; 286 if ($default == $values[$i]['id']) { 287 $field .= ' SELECTED'; 288 } 289 290 $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>'; 291 } 292 $field .= '</select>'; 293 294 if ($required == true) $field .= TEXT_FIELD_REQUIRED; 295 296 return $field; 297 } 298 ?>
title
Description
Body
title
Description
Body
| Generated: Tue Nov 4 23:53:39 2003 | Hosted By :: AABox.com |
Cross-referenced by PHPXref 0.4 |