[ PHPXref.com ] [ Generated: Sun Jul 20 19:13:40 2008 ] [ osCommRes 1.2.0 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

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

   1  <?php
   2  /*

   3  

   4    osCommerce, Open Source E-Commerce Solutions

   5    http://www.oscommerce.com

   6  

   7    Copyright (c) 2003 osCommerce

   8    

   9    osCommRes, Services Online

  10    http://www.oscommres.com

  11  

  12    Copyright (c) 2005 osCommRes

  13  

  14    Released under the GNU General Public License

  15  */
  16  ////

  17  // The HTML href link wrapper function

  18    function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {
  19      global $request_type, $session_started, $SID;
  20  
  21      if (!tep_not_null($page)) {
  22        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>');
  23      }
  24  
  25      if ($connection == 'NONSSL') {
  26        $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
  27      } elseif ($connection == 'SSL') {
  28        if (ENABLE_SSL == true) {
  29          $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;
  30        } else {
  31          $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
  32        }
  33      } else {
  34        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>');
  35      }
  36  
  37      if (tep_not_null($parameters)) {
  38        $link .= $page . '?' . tep_output_string($parameters);
  39        $separator = '&';
  40      } else {
  41        $link .= $page;
  42        $separator = '?';
  43      }
  44  
  45      while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
  46  
  47  // Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined

  48      if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
  49        if (tep_not_null($SID)) {
  50          $_sid = $SID;
  51        } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == true) ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
  52          if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {
  53            $_sid = tep_session_name() . '=' . tep_session_id();
  54          }
  55        }
  56      }
  57  
  58      if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
  59        while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);
  60  
  61        $link = str_replace('?', '/', $link);
  62        $link = str_replace('&', '/', $link);
  63        $link = str_replace('=', '/', $link);
  64  
  65        $separator = '?';
  66      }
  67  
  68      if (isset($_sid)) {
  69        //$link .= $separator . $_sid;

  70        $link .= $separator . tep_output_string($_sid);
  71  
  72      }
  73  
  74      return $link;
  75    }
  76  
  77  ////

  78  // The HTML image wrapper function

  79    function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
  80      if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
  81        return false;
  82      }
  83  
  84  // alt is added to the img tag even if it is null to prevent browsers from outputting

  85  // the image filename as default

  86      $image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"';
  87  
  88      if (tep_not_null($alt)) {
  89        $image .= ' title=" ' . tep_output_string($alt) . ' "';
  90      }
  91  
  92      if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) {
  93        if ($image_size = @getimagesize($src)) {
  94          if (empty($width) && tep_not_null($height)) {
  95            $ratio = $height / $image_size[1];
  96            $width = $image_size[0] * $ratio;
  97          } elseif (tep_not_null($width) && empty($height)) {
  98            $ratio = $width / $image_size[0];
  99            $height = $image_size[1] * $ratio;
 100          } elseif (empty($width) && empty($height)) {
 101            $width = $image_size[0];
 102            $height = $image_size[1];
 103          }
 104        } elseif (IMAGE_REQUIRED == 'false') {
 105          return false;
 106        }
 107      }
 108  
 109      if (tep_not_null($width) && tep_not_null($height)) {
 110        $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"';
 111      }
 112  
 113      if (tep_not_null($parameters)) $image .= ' ' . $parameters;
 114  
 115      $image .= '>';
 116  
 117      return $image;
 118    }
 119  
 120  ////

 121  // The HTML form submit button wrapper function

 122  // Outputs a button in the selected language

 123    function tep_image_submit($image, $alt = '', $parameters = '') {
 124      global $language;
 125  
 126      $image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" border="0" alt="' . tep_output_string($alt) . '"';
 127  
 128      if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "';
 129  
 130      if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters;
 131  
 132      $image_submit .= '>';
 133  
 134      return $image_submit;
 135    }
 136  
 137  ////

 138  // Output a function button in the selected language

 139    function tep_image_button($image, $alt = '', $parameters = '') {
 140      global $language;
 141  
 142      return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $parameters);
 143    }
 144  
 145  ////

 146  // Output a separator either through whitespace, or with an image

 147    function tep_draw_separator($image = 'pixel_black.gif', $width = '100%', $height = '1') {
 148      return tep_image(DIR_WS_IMAGES . $image, '', $width, $height);
 149    }
 150  
 151  ////

 152  // Output a form

 153    function tep_draw_form($name, $action, $method = 'post', $parameters = '') {
 154      $form = '<form name="' . tep_output_string($name) . '" action="' . tep_output_string($action) . '" method="' . tep_output_string($method) . '"';
 155  
 156      if (tep_not_null($parameters)) $form .= ' ' . $parameters;
 157  
 158      $form .= '>';
 159  
 160      return $form;
 161    }
 162  
 163  ////

 164  // Output a form input field

 165    function tep_draw_input_field($name, $value = '', $parameters = '', $type = 'text', $reinsert_value = true) {
 166      $field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';
 167  
 168      if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) {
 169        $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"';
 170      } elseif (tep_not_null($value)) {
 171        $field .= ' value="' . tep_output_string($value) . '"';
 172      }
 173  
 174      if (tep_not_null($parameters)) $field .= ' ' . $parameters;
 175  
 176      $field .= '>';
 177  
 178      return $field;
 179    }
 180  
 181  ////

 182  // Output a form password field

 183    function tep_draw_password_field($name, $value = '', $parameters = 'maxlength="40"') {
 184      return tep_draw_input_field($name, $value, $parameters, 'password', false);
 185    }
 186  
 187  ////

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

 189    function tep_draw_selection_field($name, $type, $value = '', $checked = false, $parameters = '') {
 190      $selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';
 191  
 192      if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"';
 193  
 194      if ( ($checked == true) || ( isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ( ($GLOBALS[$name] == 'on') || (isset($value) && (stripslashes($GLOBALS[$name]) == $value)) ) ) ) {
 195        $selection .= ' CHECKED';
 196      }
 197  
 198      if (tep_not_null($parameters)) $selection .= ' ' . $parameters;
 199  
 200      $selection .= '>';
 201  
 202      return $selection;
 203    }
 204  
 205  ////

 206  // Output a form checkbox field

 207    function tep_draw_checkbox_field($name, $value = '', $checked = false, $parameters = '') {
 208      return tep_draw_selection_field($name, 'checkbox', $value, $checked, $parameters);
 209    }
 210  
 211  ////

 212  // Output a form radio field

 213    function tep_draw_radio_field($name, $value = '', $checked = false, $parameters = '') {
 214      return tep_draw_selection_field($name, 'radio', $value, $checked, $parameters);
 215    }
 216  
 217  ////

 218  // Output a form textarea field

 219    function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) {
 220      $field = '<textarea name="' . tep_output_string($name) . '" wrap="' . tep_output_string($wrap) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"';
 221  
 222      if (tep_not_null($parameters)) $field .= ' ' . $parameters;
 223  
 224      $field .= '>';
 225  
 226      if ( (isset($GLOBALS[$name])) && ($reinsert_value == true) ) {
 227            $field .= tep_output_string_protected(stripslashes($GLOBALS[$name]));
 228        } elseif (tep_not_null($text)) {
 229          $field .= tep_output_string_protected($text);
 230        }
 231  
 232  $field .= '</textarea>';
 233  
 234      return $field;
 235    }
 236  
 237  ////

 238  // Output a form hidden field

 239    function tep_draw_hidden_field($name, $value = '', $parameters = '') {
 240      $field = '<input type="hidden" name="' . tep_output_string($name) . '"';
 241  
 242      if (tep_not_null($value)) {
 243        $field .= ' value="' . tep_output_string($value) . '"';
 244      } elseif (isset($GLOBALS[$name])) {
 245        $field .= ' value="' . tep_output_string(stripslashes($GLOBALS[$name])) . '"';
 246      }
 247  
 248      if (tep_not_null($parameters)) $field .= ' ' . $parameters;
 249  
 250      $field .= '>';
 251  
 252      return $field;
 253    }
 254  
 255  ////

 256  // Hide form elements

 257    function tep_hide_session_id() {
 258      global $session_started, $SID;
 259  
 260      if (($session_started == true) && tep_not_null($SID)) {
 261        return tep_draw_hidden_field(tep_session_name(), tep_session_id());
 262      }
 263    }
 264  
 265  ////

 266  // Output a form pull down menu

 267    function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
 268      $field = '<select name="' . tep_output_string($name) . '"';
 269  
 270      if (tep_not_null($parameters)) $field .= ' ' . $parameters;
 271  
 272      $field .= '>';
 273  
 274      if (empty($default) && isset($GLOBALS[$name])) $default = stripslashes($GLOBALS[$name]);
 275  
 276      for ($i=0, $n=sizeof($values); $i<$n; $i++) {
 277        $field .= '<option value="' . tep_output_string($values[$i]['id']) . '"';
 278        if ($default == $values[$i]['id']) {
 279          $field .= ' SELECTED';
 280        }
 281  
 282        $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => '&#039;', '<' => '&lt;', '>' => '&gt;')) . '</option>';
 283      }
 284      $field .= '</select>';
 285  
 286      if ($required == true) $field .= TEXT_FIELD_REQUIRED;
 287  
 288      return $field;
 289    }
 290  
 291  ////

 292  // Creates a pull-down list of countries

 293    function tep_get_country_list($name, $selected = '', $parameters = '') {
 294      $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
 295      $countries = tep_get_countries();
 296  
 297      for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
 298        $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);
 299      }
 300  
 301      return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
 302    }
 303  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]