[ Index ] |
|
Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1 |
1 <?php 2 // 3 // +----------------------------------------------------------------------+ 4 // |zen-cart Open Source E-commerce | 5 // +----------------------------------------------------------------------+ 6 // | Copyright (c) 2003 The zen-cart developers | 7 // | | 8 // | http://www.zen-cart.com/index.php | 9 // | | 10 // | Portions Copyright (c) 2003 osCommerce | 11 // +----------------------------------------------------------------------+ 12 // | This source file is subject to version 2.0 of the GPL license, | 13 // | that is bundled with this package in the file LICENSE, and is | 14 // | available through the world-wide-web at the following url: | 15 // | http://www.zen-cart.com/license/2_0.txt. | 16 // | If you did not receive a copy of the zen-cart license and are unable | 17 // | to obtain it through the world-wide-web, please send a note to | 18 // | license@zen-cart.com so we can mail you a copy immediately. | 19 // +----------------------------------------------------------------------+ 20 // $Id: html_output.php 3089 2006-03-01 18:32:25Z ajeh $ 21 // 22 23 //// 24 // The HTML href link wrapper function 25 function zen_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true) { 26 global $request_type, $session_started, $http_domain, $https_domain; 27 if ($page == '') { 28 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>zen_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>'); 29 } 30 31 if ($connection == 'NONSSL') { 32 $link = HTTP_SERVER . DIR_WS_ADMIN; 33 } elseif ($connection == 'SSL') { 34 if (ENABLE_SSL_ADMIN == 'true') { 35 $link = HTTPS_SERVER . DIR_WS_HTTPS_ADMIN; 36 } else { 37 $link = HTTP_SERVER . DIR_WS_ADMIN; 38 } 39 } else { 40 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>zen_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>'); 41 } 42 if (!strstr($page, '.php')) $page .= '.php'; 43 if ($parameters == '') { 44 $link = $link . $page; 45 $separator = '?'; 46 } else { 47 $link = $link . $page . '?' . $parameters; 48 $separator = '&'; 49 } 50 51 while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1); 52 53 // Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined 54 if ( ($add_session_id == true) && ($session_started == true) ) { 55 if (defined('SID') && zen_not_null(SID)) { 56 $sid = SID; 57 } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL_ADMIN == 'true') ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) { 58 //die($connection); 59 if ($http_domain != $https_domain) { 60 $sid = zen_session_name() . '=' . zen_session_id(); 61 } 62 } 63 } 64 65 if (isset($sid)) { 66 $link .= $separator . $sid; 67 } 68 69 return $link; 70 } 71 72 function zen_catalog_href_link($page = '', $parameters = '', $connection = 'NONSSL') { 73 if ($connection == 'NONSSL') { 74 $link = HTTP_CATALOG_SERVER . DIR_WS_CATALOG; 75 } elseif ($connection == 'SSL') { 76 if (ENABLE_SSL_CATALOG == 'true') { 77 $link = HTTPS_CATALOG_SERVER . DIR_WS_HTTPS_CATALOG; 78 } else { 79 $link = HTTP_CATALOG_SERVER . DIR_WS_CATALOG; 80 } 81 } else { 82 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>zen_href_link(\'' . $page . '\', \'' . $parameters . '\', \'' . $connection . '\')</b>'); 83 } 84 if ($parameters == '') { 85 $link .= 'index.php?main_page='. $page; 86 } else { 87 $link .= 'index.php?main_page='. $page . "&" . zen_output_string($parameters); 88 } 89 90 while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1); 91 92 return $link; 93 } 94 95 //// 96 // The HTML image wrapper function 97 function zen_image($src, $alt = '', $width = '', $height = '', $params = '') { 98 $image = '<img src="' . $src . '" border="0" alt="' . $alt . '"'; 99 if ($alt) { 100 $image .= ' title=" ' . $alt . ' "'; 101 } 102 if ($width) { 103 $image .= ' width="' . $width . '"'; 104 } 105 if ($height) { 106 $image .= ' height="' . $height . '"'; 107 } 108 if ($params) { 109 $image .= ' ' . $params; 110 } 111 $image .= '>'; 112 113 return $image; 114 } 115 116 //// 117 // The HTML form submit button wrapper function 118 // Outputs a button in the selected language 119 function zen_image_submit($image, $alt = '', $parameters = '') { 120 global $language; 121 122 $image_submit = '<input type="image" src="' . zen_output_string(DIR_WS_LANGUAGES . $_SESSION['language'] . '/images/buttons/' . $image) . '" border="0" alt="' . zen_output_string($alt) . '"'; 123 124 if (zen_not_null($alt)) $image_submit .= ' title=" ' . zen_output_string($alt) . ' "'; 125 126 if (zen_not_null($parameters)) $image_submit .= ' ' . $parameters; 127 128 $image_submit .= '>'; 129 130 return $image_submit; 131 } 132 133 //// 134 // Draw a 1 pixel black line 135 function zen_black_line() { 136 return zen_image(DIR_WS_IMAGES . 'pixel_black.gif', '', '100%', '1'); 137 } 138 139 //// 140 // Output a separator either through whitespace, or with an image 141 function zen_draw_separator($image = 'pixel_black.gif', $width = '100%', $height = '1') { 142 return zen_image(DIR_WS_IMAGES . $image, '', $width, $height); 143 } 144 145 //// 146 // Output a function button in the selected language 147 function zen_image_button($image, $alt = '', $params = '') { 148 global $language; 149 150 return zen_image(DIR_WS_LANGUAGES . $_SESSION['language'] . '/images/buttons/' . $image, $alt, '', '', $params); 151 } 152 153 //// 154 // javascript to dynamically update the states/provinces list when the country is changed 155 // TABLES: zones 156 function zen_js_zone_list($country, $form, $field) { 157 global $db; 158 $countries = $db->Execute("select distinct zone_country_id 159 from " . TABLE_ZONES . " 160 order by zone_country_id"); 161 162 $num_country = 1; 163 $output_string = ''; 164 while (!$countries->EOF) { 165 if ($num_country == 1) { 166 $output_string .= ' if (' . $country . ' == "' . $countries->fields['zone_country_id'] . '") {' . "\n"; 167 } else { 168 $output_string .= ' } else if (' . $country . ' == "' . $countries->fields['zone_country_id'] . '") {' . "\n"; 169 } 170 171 $states = $db->Execute("select zone_name, zone_id 172 from " . TABLE_ZONES . " 173 where zone_country_id = '" . $countries->fields['zone_country_id'] . "' 174 order by zone_name"); 175 176 177 $num_state = 1; 178 while (!$states->EOF) { 179 if ($num_state == '1') $output_string .= ' ' . $form . '.' . $field . '.options[0] = new Option("' . PLEASE_SELECT . '", "");' . "\n"; 180 $output_string .= ' ' . $form . '.' . $field . '.options[' . $num_state . '] = new Option("' . $states->fields['zone_name'] . '", "' . $states->fields['zone_id'] . '");' . "\n"; 181 $num_state++; 182 $states->MoveNext(); 183 } 184 $num_country++; 185 $countries->MoveNext(); 186 } 187 $output_string .= ' } else {' . "\n" . 188 ' ' . $form . '.' . $field . '.options[0] = new Option("' . TYPE_BELOW . '", "");' . "\n" . 189 ' }' . "\n"; 190 191 return $output_string; 192 } 193 194 //// 195 // Output a form 196 function zen_draw_form($name, $action, $parameters = '', $method = 'post', $params = '', $usessl = 'false') { 197 $form = '<form name="' . zen_output_string($name) . '" action="'; 198 if (zen_not_null($parameters)) { 199 if ($usessl) { 200 $form .= zen_href_link($action, $parameters, 'NONSSL'); 201 } else { 202 $form .= zen_href_link($action, $parameters, 'NONSSL'); 203 } 204 } else { 205 if ($usessl) { 206 $form .= zen_href_link($action, '', 'NONSSL'); 207 } else { 208 $form .= zen_href_link($action, '', 'NONSSL'); 209 } 210 } 211 $form .= '" method="' . zen_output_string($method) . '"'; 212 if (zen_not_null($params)) { 213 $form .= ' ' . $params; 214 } 215 $form .= '>'; 216 return $form; 217 } 218 219 //// 220 // Output a form input field 221 function zen_draw_input_field($name, $value = '', $parameters = '', $required = false, $type = 'text', $reinsert_value = true) { 222 $field = '<input type="' . zen_output_string($type) . '" name="' . zen_output_string($name) . '"'; 223 224 if (isset($GLOBALS[$name]) && ($reinsert_value == true) && is_string($GLOBALS[$name])) { 225 $field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"'; 226 } elseif (zen_not_null($value)) { 227 $field .= ' value="' . zen_output_string($value) . '"'; 228 } 229 230 if (zen_not_null($parameters)) $field .= ' ' . $parameters; 231 232 $field .= '>'; 233 234 if ($required == true) $field .= TEXT_FIELD_REQUIRED; 235 236 return $field; 237 } 238 239 //// 240 // Output a form password field 241 function zen_draw_password_field($name, $value = '', $required = false) { 242 $field = zen_draw_input_field($name, $value, 'maxlength="40"', $required, 'password', false); 243 244 return $field; 245 } 246 247 //// 248 // Output a form filefield 249 function zen_draw_file_field($name, $required = false) { 250 $field = zen_draw_input_field($name, '', ' size="50" ', $required, 'file'); 251 252 return $field; 253 } 254 255 //// 256 // Output a selection field - alias function for zen_draw_checkbox_field() and zen_draw_radio_field() 257 function zen_draw_selection_field($name, $type, $value = '', $checked = false, $compare = '', $parameters = '') { 258 $selection = '<input type="' . zen_output_string($type) . '" name="' . zen_output_string($name) . '"'; 259 260 if (zen_not_null($value)) $selection .= ' value="' . zen_output_string($value) . '"'; 261 262 if ( ($checked == true) || (isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ($GLOBALS[$name] == 'on')) || (isset($value) && isset($GLOBALS[$name]) && (stripslashes($GLOBALS[$name]) == $value)) || (zen_not_null($value) && zen_not_null($compare) && ($value == $compare)) ) { 263 $selection .= ' CHECKED'; 264 } 265 266 if (zen_not_null($parameters)) $selection .= ' ' . $parameters; 267 268 $selection .= '>'; 269 270 return $selection; 271 } 272 273 //// 274 // Output a form checkbox field 275 function zen_draw_checkbox_field($name, $value = '', $checked = false, $compare = '', $parameters = '') { 276 return zen_draw_selection_field($name, 'checkbox', $value, $checked, $compare, $parameters); 277 } 278 279 //// 280 // Output a form radio field 281 function zen_draw_radio_field($name, $value = '', $checked = false, $compare = '', $parameters = '') { 282 return zen_draw_selection_field($name, 'radio', $value, $checked, $compare, $parameters); 283 } 284 285 //// 286 // Output a form textarea field 287 function zen_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) { 288 $field = '<textarea name="' . zen_output_string($name) . '" wrap="' . zen_output_string($wrap) . '" cols="' . zen_output_string($width) . '" rows="' . zen_output_string($height) . '"'; 289 290 if (zen_not_null($parameters)) $field .= ' ' . $parameters; 291 292 $field .= '>'; 293 294 if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) { 295 $field .= stripslashes($GLOBALS[$name]); 296 } elseif (zen_not_null($text)) { 297 $field .= $text; 298 } 299 300 $field .= '</textarea>'; 301 302 return $field; 303 } 304 305 //// 306 // Output a form hidden field 307 function zen_draw_hidden_field($name, $value = '', $parameters = '') { 308 $field = '<input type="hidden" name="' . zen_output_string($name) . '"'; 309 310 if (zen_not_null($value)) { 311 $field .= ' value="' . zen_output_string($value) . '"'; 312 } elseif (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) { 313 $field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"'; 314 } 315 316 if (zen_not_null($parameters)) $field .= ' ' . $parameters; 317 318 $field .= '>'; 319 320 return $field; 321 } 322 323 //// 324 // Output a form pull down menu 325 function zen_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) { 326 // $field = '<select name="' . zen_output_string($name) . '"'; 327 $field = '<select rel="dropdown" name="' . zen_output_string($name) . '"'; 328 329 if (zen_not_null($parameters)) $field .= ' ' . $parameters; 330 331 $field .= '>'; 332 333 if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]); 334 335 for ($i=0, $n=sizeof($values); $i<$n; $i++) { 336 $field .= '<option value="' . zen_output_string($values[$i]['id']) . '"'; 337 if ($default == $values[$i]['id']) { 338 $field .= ' SELECTED'; 339 } 340 341 $field .= '>' . zen_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>'; 342 } 343 $field .= '</select>'; 344 345 if ($required == true) $field .= TEXT_FIELD_REQUIRED; 346 347 return $field; 348 } 349 //// 350 // Hide form elements 351 function zen_hide_session_id() { 352 global $session_started; 353 354 if ( ($session_started == true) && defined('SID') && zen_not_null(SID) ) { 355 return zen_draw_hidden_field(zen_session_name(), zen_session_id()); 356 } 357 } 358 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 16:45:43 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |