[ Index ]
 

Code source de osCommerce 2.2ms2-060817

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/catalog/includes/functions/ -> html_output.php (source)

   1  <?php
   2  /*
   3    $Id: html_output.php,v 1.56 2003/07/09 01:15:48 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', $add_session_id = true, $search_engine_safe = true) {
  16      global $request_type, $session_started, $SID;
  17  
  18      if (!tep_not_null($page)) {
  19        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>');
  20      }
  21  
  22      if ($connection == 'NONSSL') {
  23        $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
  24      } elseif ($connection == 'SSL') {
  25        if (ENABLE_SSL == true) {
  26          $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;
  27        } else {
  28          $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
  29        }
  30      } else {
  31        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</b><br><br>');
  32      }
  33  
  34      if (tep_not_null($parameters)) {
  35        $link .= $page . '?' . tep_output_string($parameters);
  36        $separator = '&';
  37      } else {
  38        $link .= $page;
  39        $separator = '?';
  40      }
  41  
  42      while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
  43  
  44  // Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined
  45      if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
  46        if (tep_not_null($SID)) {
  47          $_sid = $SID;
  48        } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == true) ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
  49          if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {
  50            $_sid = tep_session_name() . '=' . tep_session_id();
  51          }
  52        }
  53      }
  54  
  55      if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
  56        while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);
  57  
  58        $link = str_replace('?', '/', $link);
  59        $link = str_replace('&', '/', $link);
  60        $link = str_replace('=', '/', $link);
  61  
  62        $separator = '?';
  63      }
  64  
  65      if (isset($_sid)) {
  66        $link .= $separator . tep_output_string($_sid);
  67      }
  68  
  69      return $link;
  70    }
  71  
  72  ////
  73  // The HTML image wrapper function
  74    function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
  75      if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
  76        return false;
  77      }
  78  
  79  // alt is added to the img tag even if it is null to prevent browsers from outputting
  80  // the image filename as default
  81      $image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"';
  82  
  83      if (tep_not_null($alt)) {
  84        $image .= ' title=" ' . tep_output_string($alt) . ' "';
  85      }
  86  
  87      if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) {
  88        if ($image_size = @getimagesize($src)) {
  89          if (empty($width) && tep_not_null($height)) {
  90            $ratio = $height / $image_size[1];
  91            $width = intval($image_size[0] * $ratio);
  92          } elseif (tep_not_null($width) && empty($height)) {
  93            $ratio = $width / $image_size[0];
  94            $height = intval($image_size[1] * $ratio);
  95          } elseif (empty($width) && empty($height)) {
  96            $width = $image_size[0];
  97            $height = $image_size[1];
  98          }
  99        } elseif (IMAGE_REQUIRED == 'false') {
 100          return false;
 101        }
 102      }
 103  
 104      if (tep_not_null($width) && tep_not_null($height)) {
 105        $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"';
 106      }
 107  
 108      if (tep_not_null($parameters)) $image .= ' ' . $parameters;
 109  
 110      $image .= '>';
 111  
 112      return $image;
 113    }
 114  
 115  ////
 116  // The HTML form submit button wrapper function
 117  // Outputs a button in the selected language
 118    function tep_image_submit($image, $alt = '', $parameters = '') {
 119      global $language;
 120  
 121      $image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" border="0" alt="' . tep_output_string($alt) . '"';
 122  
 123      if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "';
 124  
 125      if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters;
 126  
 127      $image_submit .= '>';
 128  
 129      return $image_submit;
 130    }
 131  
 132  ////
 133  // Output a function button in the selected language
 134    function tep_image_button($image, $alt = '', $parameters = '') {
 135      global $language;
 136  
 137      return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $parameters);
 138    }
 139  
 140  ////
 141  // Output a separator either through whitespace, or with an image
 142    function tep_draw_separator($image = 'pixel_black.gif', $width = '100%', $height = '1') {
 143      return tep_image(DIR_WS_IMAGES . $image, '', $width, $height);
 144    }
 145  
 146  ////
 147  // Output a form
 148    function tep_draw_form($name, $action, $method = 'post', $parameters = '') {
 149      $form = '<form name="' . tep_output_string($name) . '" action="' . tep_output_string($action) . '" method="' . tep_output_string($method) . '"';
 150  
 151      if (tep_not_null($parameters)) $form .= ' ' . $parameters;
 152  
 153      $form .= '>';
 154  
 155      return $form;
 156    }
 157  
 158  ////
 159  // Output a form input field
 160    function tep_draw_input_field($name, $value = '', $parameters = '', $type = 'text', $reinsert_value = true) {
 161      $field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';
 162  
 163      if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) {
 164        $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"';
 165      } elseif (tep_not_null($value)) {
 166        $field .= ' value="' . tep_output_string($value) . '"';
 167      }
 168  
 169      if (tep_not_null($parameters)) $field .= ' ' . $parameters;
 170  
 171      $field .= '>';
 172  
 173      return $field;
 174    }
 175  
 176  ////
 177  // Output a form password field
 178    function tep_draw_password_field($name, $value = '', $parameters = 'maxlength="40"') {
 179      return tep_draw_input_field($name, $value, $parameters, 'password', false);
 180    }
 181  
 182  ////
 183  // Output a selection field - alias function for tep_draw_checkbox_field() and tep_draw_radio_field()
 184    function tep_draw_selection_field($name, $type, $value = '', $checked = false, $parameters = '') {
 185      $selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';
 186  
 187      if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"';
 188  
 189      if ( ($checked == true) || ( isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ( ($GLOBALS[$name] == 'on') || (isset($value) && (stripslashes($GLOBALS[$name]) == $value)) ) ) ) {
 190        $selection .= ' CHECKED';
 191      }
 192  
 193      if (tep_not_null($parameters)) $selection .= ' ' . $parameters;
 194  
 195      $selection .= '>';
 196  
 197      return $selection;
 198    }
 199  
 200  ////
 201  // Output a form checkbox field
 202    function tep_draw_checkbox_field($name, $value = '', $checked = false, $parameters = '') {
 203      return tep_draw_selection_field($name, 'checkbox', $value, $checked, $parameters);
 204    }
 205  
 206  ////
 207  // Output a form radio field
 208    function tep_draw_radio_field($name, $value = '', $checked = false, $parameters = '') {
 209      return tep_draw_selection_field($name, 'radio', $value, $checked, $parameters);
 210    }
 211  
 212  ////
 213  // Output a form textarea field
 214    function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) {
 215      $field = '<textarea name="' . tep_output_string($name) . '" wrap="' . tep_output_string($wrap) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"';
 216  
 217      if (tep_not_null($parameters)) $field .= ' ' . $parameters;
 218  
 219      $field .= '>';
 220  
 221      if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) {
 222        $field .= tep_output_string_protected(stripslashes($GLOBALS[$name]));
 223      } elseif (tep_not_null($text)) {
 224        $field .= tep_output_string_protected($text);
 225      }
 226  
 227      $field .= '</textarea>';
 228  
 229      return $field;
 230    }
 231  
 232  ////
 233  // Output a form hidden field
 234    function tep_draw_hidden_field($name, $value = '', $parameters = '') {
 235      $field = '<input type="hidden" name="' . tep_output_string($name) . '"';
 236  
 237      if (tep_not_null($value)) {
 238        $field .= ' value="' . tep_output_string($value) . '"';
 239      } elseif (isset($GLOBALS[$name])) {
 240        $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"';
 241      }
 242  
 243      if (tep_not_null($parameters)) $field .= ' ' . $parameters;
 244  
 245      $field .= '>';
 246  
 247      return $field;
 248    }
 249  
 250  ////
 251  // Hide form elements
 252    function tep_hide_session_id() {
 253      global $session_started, $SID;
 254  
 255      if (($session_started == true) && tep_not_null($SID)) {
 256        return tep_draw_hidden_field(tep_session_name(), tep_session_id());
 257      }
 258    }
 259  
 260  ////
 261  // Output a form pull down menu
 262    function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
 263      $field = '<select name="' . tep_output_string($name) . '"';
 264  
 265      if (tep_not_null($parameters)) $field .= ' ' . $parameters;
 266  
 267      $field .= '>';
 268  
 269      if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);
 270  
 271      for ($i=0, $n=sizeof($values); $i<$n; $i++) {
 272        $field .= '<option value="' . tep_output_string($values[$i]['id']) . '"';
 273        if ($default == $values[$i]['id']) {
 274          $field .= ' SELECTED';
 275        }
 276  
 277        $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => '&#039;', '<' => '&lt;', '>' => '&gt;')) . '</option>';
 278      }
 279      $field .= '</select>';
 280  
 281      if ($required == true) $field .= TEXT_FIELD_REQUIRED;
 282  
 283      return $field;
 284    }
 285  
 286  ////
 287  // Creates a pull-down list of countries
 288    function tep_get_country_list($name, $selected = '', $parameters = '') {
 289      $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
 290      $countries = tep_get_countries();
 291  
 292      for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
 293        $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);
 294      }
 295  
 296      return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
 297    }
 298  ?>


Généré le : Mon Nov 26 19:48:25 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics