[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

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

   1  <?php
   2  /*

   3  $Id: html_output.php 14 2006-07-28 17:42:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   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      $parameters = tep_output_string($parameters);
  17      if ($page == '') {
  18        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>');
  19      }
  20      if ($connection == 'NONSSL') {
  21        $link = HTTP_SERVER . DIR_WS_ADMIN;
  22      } elseif ($connection == 'SSL') {
  23        if (ENABLE_SSL == 'true') {
  24          $link = HTTPS_SERVER . DIR_WS_ADMIN;
  25        } else {
  26          $link = HTTP_SERVER . DIR_WS_ADMIN;
  27        }
  28      } else {
  29        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>');
  30      }
  31      if ($parameters == '') {
  32        $link = $link . $page . '?' . SID;
  33      } else {
  34        $link = $link . $page . '?' . $parameters . '&' . SID;
  35      }
  36  
  37      while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
  38  
  39      return $link;
  40    }
  41  
  42    function tep_catalog_href_link($page = '', $parameters = '', $connection = 'NONSSL') {
  43      if ($connection == 'NONSSL') {
  44        $link = HTTP_CATALOG_SERVER . DIR_WS_CATALOG;
  45      } elseif ($connection == 'SSL') {
  46        if (ENABLE_SSL_CATALOG == 'true') {
  47          $link = HTTPS_CATALOG_SERVER . DIR_WS_CATALOG;
  48        } else {
  49          $link = HTTP_CATALOG_SERVER . DIR_WS_CATALOG;
  50        }
  51      } else {
  52        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>');
  53      }
  54      if ($parameters == '') {
  55        $link .= $page;
  56      } else {
  57        $link .= $page . '?' . $parameters;
  58      }
  59  
  60      while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
  61  
  62      return $link;
  63    }
  64  
  65  ////

  66  // The HTML image wrapper function

  67  // LINE CHNAGED: MS2 update 501112 - changed 'params' to 'parameters'

  68    function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
  69  // BOF: MS2 update 501112-Added all 'tep_not_null()'

  70      $image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"';
  71  
  72      if (tep_not_null($alt)) {
  73        $image .= ' title=" ' . tep_output_string($alt) . ' "';
  74      }
  75  
  76      if (tep_not_null($width) || tep_not_null($height)) {
  77        $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"';
  78      }
  79  
  80      if (tep_not_null($parameters)) $image .= ' ' . $parameters;
  81  
  82  // EOF: MS2 update 501112

  83      $image .= '>';
  84  
  85      return $image;
  86    }
  87  
  88  ////

  89  // The HTML form submit button wrapper function

  90  // Outputs a button in the selected language

  91    function tep_image_submit($image, $alt = '', $parameters = '') {
  92      global $language;
  93  
  94      $image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" border="0" alt="' . tep_output_string($alt) . '"';
  95  
  96      if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "';
  97  
  98      if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters;
  99  
 100      $image_submit .= '>';
 101  
 102      return $image_submit;
 103    }
 104  
 105  ////

 106  // Draw a 1 pixel black line

 107    function tep_black_line() {
 108      return tep_image(DIR_WS_IMAGES . 'pixel_black.gif', '', '100%', '1');
 109    }
 110  
 111  ////

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

 113    function tep_draw_separator($image = 'pixel_black.gif', $width = '100%', $height = '1') {
 114      return tep_image(DIR_WS_IMAGES . $image, '', $width, $height);
 115    }
 116  
 117  ////

 118  // Output a function button in the selected language

 119    function tep_image_button($image, $alt = '', $params = '') {
 120      global $language;
 121  
 122      return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $params);
 123    }
 124  
 125  ////

 126  // javascript to dynamically update the states/provinces list when the country is changed

 127  // TABLES: zones

 128    function tep_js_zone_list($country, $form, $field) {
 129      $countries_query = tep_db_query("select distinct zone_country_id from " . TABLE_ZONES . " order by zone_country_id");
 130      $num_country = 1;
 131      $output_string = '';
 132      while ($countries = tep_db_fetch_array($countries_query)) {
 133        if ($num_country == 1) {
 134          $output_string .= '  if (' . $country . ' == "' . $countries['zone_country_id'] . '") {' . "\n";
 135        } else {
 136          $output_string .= '  } else if (' . $country . ' == "' . $countries['zone_country_id'] . '") {' . "\n";
 137        }
 138  
 139        $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");
 140  
 141        $num_state = 1;
 142        while ($states = tep_db_fetch_array($states_query)) {
 143          if ($num_state == '1') $output_string .= '    ' . $form . '.' . $field . '.options[0] = new Option("' . PLEASE_SELECT . '", "");' . "\n";
 144          $output_string .= '    ' . $form . '.' . $field . '.options[' . $num_state . '] = new Option("' . $states['zone_name'] . '", "' . $states['zone_id'] . '");' . "\n";
 145          $num_state++;
 146        }
 147        $num_country++;
 148      }
 149      $output_string .= '  } else {' . "\n" .
 150                        '    ' . $form . '.' . $field . '.options[0] = new Option("' . TYPE_BELOW . '", "");' . "\n" .
 151                        '  }' . "\n";
 152  
 153      return $output_string;
 154    }
 155  
 156  ////

 157  // Output a form

 158    function tep_draw_form($name, $action, $parameters = '', $method = 'post', $params = '') {
 159      $form = '<form name="' . tep_output_string($name) . '" action="';
 160      if (tep_not_null($parameters)) {
 161        $form .= tep_href_link($action, $parameters);
 162      } else {
 163        $form .= tep_href_link($action);
 164      }
 165      $form .= '" method="' . tep_output_string($method) . '"';
 166      if (tep_not_null($params)) {
 167        $form .= ' ' . $params;
 168      }
 169      $form .= '>';
 170  
 171      return $form;
 172    }
 173  
 174  ////

 175  // Output a form input field

 176    function tep_draw_input_field($name, $value = '', $parameters = '', $required = false, $type = 'text', $reinsert_value = true) {
 177      global $HTTP_GET_VARS, $HTTP_POST_VARS;
 178      $field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';
 179  
 180      if ( ($reinsert_value == true) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) {
 181        if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) {
 182          $value = stripslashes($HTTP_GET_VARS[$name]);
 183        } elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) {
 184          $value = stripslashes($HTTP_POST_VARS[$name]);
 185        }
 186      }
 187  
 188      if (tep_not_null($value)) {
 189        $field .= ' value="' . tep_output_string($value) . '"';
 190      }
 191  
 192      if (tep_not_null($parameters)) $field .= ' ' . $parameters;
 193  
 194      $field .= '>';
 195  
 196      if ($required == true) $field .= TEXT_FIELD_REQUIRED;
 197  
 198      return $field;
 199    }
 200  
 201  ////

 202  // Output a form password field

 203    function tep_draw_password_field($name, $value = '', $required = false) {
 204      $field = tep_draw_input_field($name, $value, 'maxlength="40"', $required, 'password', false);
 205  
 206      return $field;
 207    }
 208  
 209  ////

 210  // Output a form filefield

 211    function tep_draw_file_field($name, $required = false) {
 212      $field = tep_draw_input_field($name, '', '', $required, 'file');
 213  
 214      return $field;
 215    }
 216  
 217  ////

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

 219  // BOF: MOD - Admin w/access levels

 220  //  function tep_draw_selection_field($name, $type, $value = '', $checked = false, $compare = '') {

 221  //    $selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';

 222  //

 223  //    if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"';

 224  //

 225  //    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)) ) {

 226  //      $selection .= ' CHECKED';

 227  //    }

 228    function tep_draw_selection_field($name, $type, $value = '', $checked = false, $compare = '', $parameter = '') {
 229      global $HTTP_GET_VARS, $HTTP_POST_VARS;
 230      $selection = '<input type="' . $type . '" name="' . $name . '"';
 231      if ($value != '') {
 232        $selection .= ' value="' . $value . '"';
 233      }
 234      if ( ($checked == true) || (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name]) && (($HTTP_GET_VARS[$name] == 'on') || (stripslashes($HTTP_GET_VARS[$name]) == $value))) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name]) && (($HTTP_POST_VARS[$name] == 'on') || (stripslashes($HTTP_POST_VARS[$name]) == $value))) || (tep_not_null($compare) && ($value == $compare)) ) {
 235        $selection .= ' CHECKED';
 236      }
 237      if ($parameter != '') {
 238        $selection .= ' ' . $parameter;
 239      }
 240  // EOF: MOD - Admin w/access levels

 241      $selection .= '>';
 242  
 243      return $selection;
 244    }
 245  
 246  ////

 247  // Output a form checkbox field - Admin w/levels added "$parameter" to 4 fuctions and returns below

 248    function tep_draw_checkbox_field($name, $value = '', $checked = false, $compare = '', $parameter = '') {
 249      return tep_draw_selection_field($name, 'checkbox', $value, $checked, $compare, $parameter);
 250    }
 251  
 252  ////

 253  // Output a form radio field

 254    function tep_draw_radio_field($name, $value = '', $checked = false, $compare = '', $parameter = '') {
 255      return tep_draw_selection_field($name, 'radio', $value, $checked, $compare, $parameter);
 256    }
 257  
 258  ////

 259  // Output a form textarea field

 260    function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) {
 261      global $HTTP_GET_VARS, $HTTP_POST_VARS;
 262      $field = '<textarea name="' . tep_output_string($name) . '" wrap="' . tep_output_string($wrap) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"';
 263  
 264      if (tep_not_null($parameters)) $field .= ' ' . $parameters;
 265  
 266      $field .= '>';
 267  
 268      if ( ($reinsert_value == true) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) {
 269        if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) {
 270          $field .= tep_output_string_protected(stripslashes($HTTP_GET_VARS[$name]));
 271        } elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) {
 272          $field .= tep_output_string_protected(stripslashes($HTTP_POST_VARS[$name]));
 273        }
 274      } elseif (tep_not_null($text)) {
 275  // LINE CHANGED: MS2 update 501112 - Added 'tep_output_string_protected()'

 276        $field .= tep_output_string_protected($text);
 277      }
 278  
 279      $field .= '</textarea>';
 280  
 281      return $field;
 282    }
 283  
 284  // BOF: MOD - WYSIWYG FCKeditor

 285  // Output a form textarea field w/ fckeditor

 286    function tep_draw_fckeditor($name, $width, $height, $text) {
 287  
 288      $oFCKeditor = new FCKeditor($name);
 289      $oFCKeditor -> Width  = $width;
 290      $oFCKeditor -> Height = $height;
 291      $oFCKeditor -> BasePath    = (DIR_WS_FCKEDITOR);
 292      $oFCKeditor -> Value = $text;
 293  
 294      $field = $oFCKeditor->Create($name);
 295  
 296      return $field;
 297    }
 298  // EOF: MOD - WYSIWYG FCKeditor

 299  
 300  ////

 301  // Output a form hidden field

 302    function tep_draw_hidden_field($name, $value = '', $parameters = '') {
 303      global $HTTP_GET_VARS, $HTTP_POST_VARS;
 304      $field = '<input type="hidden" name="' . tep_output_string($name) . '"';
 305  
 306      if (tep_not_null($value)) {
 307        $field .= ' value="' . tep_output_string($value) . '"';
 308      } elseif ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) {
 309        if ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) ) {
 310          $field .= ' value="' . tep_output_string(stripslashes($HTTP_GET_VARS[$name])) . '"';
 311        } elseif ( (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) {
 312          $field .= ' value="' . tep_output_string(stripslashes($HTTP_POST_VARS[$name])) . '"';
 313        }
 314      }
 315  
 316      if (tep_not_null($parameters)) $field .= ' ' . $parameters;
 317  
 318      $field .= '>';
 319  
 320      return $field;
 321    }
 322  
 323  ////

 324  // Hide form elements

 325    function tep_hide_session_id() {
 326      $string = '';
 327  
 328      if (defined('SID') && tep_not_null(SID)) {
 329        $string = tep_draw_hidden_field(tep_session_name(), tep_session_id());
 330      }
 331  
 332      return $string;
 333    }
 334  
 335  ////

 336  // Output a form pull down menu

 337    function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
 338      global $HTTP_GET_VARS, $HTTP_POST_VARS;
 339      $field = '<select name="' . tep_output_string($name) . '"';
 340  
 341      if (tep_not_null($parameters)) $field .= ' ' . $parameters;
 342  
 343      $field .= '>';
 344  
 345      if (empty($default) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) {
 346        if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) {
 347          $default = stripslashes($HTTP_GET_VARS[$name]);
 348        } elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) {
 349          $default = stripslashes($HTTP_POST_VARS[$name]);
 350        }
 351      }
 352  
 353      for ($i=0, $n=sizeof($values); $i<$n; $i++) {
 354        $field .= '<option value="' . tep_output_string($values[$i]['id']) . '"';
 355        if ($default == $values[$i]['id']) {
 356          $field .= ' SELECTED';
 357        }
 358  
 359        $field .= '>' . tep_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => '&#039;', '<' => '&lt;', '>' => '&gt;')) . '</option>';
 360      }
 361      $field .= '</select>';
 362  
 363      if ($required == true) $field .= TEXT_FIELD_REQUIRED;
 364  
 365      return $field;
 366    }
 367  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7