[ Index ] |
PHP Cross Reference of osCMax 2.0.4 |
[Summary view] [Print] [Text view]
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 // BOF: MOD - Ultimate SEO URLs - by Chemo 14 function implode_assoc($array, $inner_glue='=', $outer_glue='&') { 15 $output = array(); 16 foreach( $array as $key => $item ) 17 $output[] = $key . $inner_glue . $item; 18 19 return implode($outer_glue, $output); 20 } 21 22 function short_name($str, $limit=3){ 23 if (defined('SEO_URLS_FILTER_SHORT_WORDS')) $limit = SEO_URLS_FILTER_SHORT_WORDS; 24 $foo = explode('-', $str); 25 foreach($foo as $index => $value){ 26 switch (true){ 27 case ( strlen($value) <= $limit ): 28 continue; 29 default: 30 $container[] = $value; 31 break; 32 } 33 } # end foreach 34 $container = ( sizeof($container) > 1 ? implode('-', $container) : $str ); 35 return $container; 36 } 37 // EOF: MOD - Ultimate SEO URLs - by Chemo 38 39 //// 40 //// 41 // Ultimate SEO URLs v2.1 42 // The HTML href link wrapper function 43 function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) { 44 global $seo_urls; 45 if ( !is_object($seo_urls) ){ 46 if ( !class_exists('SEO_URL') ){ 47 include_once (DIR_WS_CLASSES . 'seo.class.php'); 48 } 49 global $languages_id; 50 $seo_urls = new SEO_URL($languages_id); 51 } 52 return $seo_urls->href_link($page, $parameters, $connection, $add_session_id); 53 } 54 55 //// 56 // The HTML image wrapper function 57 function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '') { 58 if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) { 59 return false; 60 } 61 62 // alt is added to the img tag even if it is null to prevent browsers from outputting 63 // the image filename as default 64 $image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"'; 65 66 if (tep_not_null($alt)) { 67 $image .= ' title=" ' . tep_output_string($alt) . ' "'; 68 } 69 70 if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) { 71 if ($image_size = @getimagesize($src)) { 72 if (empty($width) && tep_not_null($height)) { 73 $ratio = $height / $image_size[1]; 74 $width = intval($image_size[0] * $ratio); 75 } elseif (tep_not_null($width) && empty($height)) { 76 $ratio = $width / $image_size[0]; 77 $height = intval($image_size[1] * $ratio); 78 } elseif (empty($width) && empty($height)) { 79 $width = $image_size[0]; 80 $height = $image_size[1]; 81 } 82 } elseif (IMAGE_REQUIRED == 'false') { 83 return false; 84 } 85 } 86 87 if (tep_not_null($width) && tep_not_null($height)) { 88 $image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"'; 89 } 90 91 if (tep_not_null($parameters)) $image .= ' ' . $parameters; 92 93 $image .= '>'; 94 95 return $image; 96 } 97 98 //// 99 // The HTML form submit button wrapper function 100 // Outputs a button in the selected language 101 function tep_image_submit($image, $alt = '', $parameters = '') { 102 global $language; 103 104 $image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" border="0" alt="' . tep_output_string($alt) . '"'; 105 106 if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "'; 107 108 if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters; 109 110 $image_submit .= '>'; 111 112 return $image_submit; 113 } 114 115 //// 116 // Output a function button in the selected language 117 function tep_image_button($image, $alt = '', $parameters = '') { 118 global $language; 119 120 return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $parameters); 121 } 122 123 //// 124 // Output a separator either through whitespace, or with an image 125 function tep_draw_separator($image = 'pixel_black.gif', $width = '100%', $height = '1') { 126 return tep_image(DIR_WS_IMAGES . $image, '', $width, $height); 127 } 128 129 //// 130 // Output a form 131 function tep_draw_form($name, $action, $method = 'post', $parameters = '') { 132 $form = '<form name="' . tep_output_string($name) . '" action="' . tep_output_string($action) . '" method="' . tep_output_string($method) . '"'; 133 134 if (tep_not_null($parameters)) $form .= ' ' . $parameters; 135 136 $form .= '>'; 137 138 return $form; 139 } 140 141 //// 142 // Output a form input field 143 function tep_draw_input_field($name, $value = '', $parameters = '', $type = 'text', $reinsert_value = true) { 144 global $HTTP_GET_VARS, $HTTP_POST_VARS; 145 146 $field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"'; 147 148 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])) ) ) { 149 if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) { 150 $value = stripslashes($HTTP_GET_VARS[$name]); 151 } elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) { 152 $value = stripslashes($HTTP_POST_VARS[$name]); 153 } 154 } 155 156 if (tep_not_null($value)) { 157 $field .= ' value="' . tep_output_string($value) . '"'; 158 } 159 160 if (tep_not_null($parameters)) $field .= ' ' . $parameters; 161 162 $field .= '>'; 163 164 return $field; 165 } 166 167 //// 168 // Output a form password field 169 function tep_draw_password_field($name, $value = '', $parameters = 'maxlength="40"') { 170 return tep_draw_input_field($name, $value, $parameters, 'password', false); 171 } 172 173 //// 174 // Output a selection field - alias function for tep_draw_checkbox_field() and tep_draw_radio_field() 175 function tep_draw_selection_field($name, $type, $value = '', $checked = false, $parameters = '') { 176 global $HTTP_GET_VARS, $HTTP_POST_VARS; 177 178 $selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"'; 179 180 if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"'; 181 182 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))) ) { 183 $selection .= ' CHECKED'; 184 } 185 186 if (tep_not_null($parameters)) $selection .= ' ' . $parameters; 187 188 $selection .= '>'; 189 190 return $selection; 191 } 192 193 //// 194 // Output a form checkbox field 195 function tep_draw_checkbox_field($name, $value = '', $checked = false, $parameters = '') { 196 return tep_draw_selection_field($name, 'checkbox', $value, $checked, $parameters); 197 } 198 199 //// 200 // Output a form radio field 201 function tep_draw_radio_field($name, $value = '', $checked = false, $parameters = '') { 202 return tep_draw_selection_field($name, 'radio', $value, $checked, $parameters); 203 } 204 205 //// 206 // Output a form textarea field 207 function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) { 208 global $HTTP_GET_VARS, $HTTP_POST_VARS; 209 210 $field = '<textarea name="' . tep_output_string($name) . '" wrap="' . tep_output_string($wrap) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"'; 211 212 if (tep_not_null($parameters)) $field .= ' ' . $parameters; 213 214 $field .= '>'; 215 216 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])) ) ) { 217 if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) { 218 $field .= tep_output_string_protected(stripslashes($HTTP_GET_VARS[$name])); 219 } elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) { 220 $field .= tep_output_string_protected(stripslashes($HTTP_POST_VARS[$name])); 221 } 222 } elseif (tep_not_null($text)) { 223 $field .= tep_output_string_protected($text); 224 } 225 226 $field .= '</textarea>'; 227 228 return $field; 229 } 230 231 //// 232 // Output a form hidden field 233 function tep_draw_hidden_field($name, $value = '', $parameters = '') { 234 global $HTTP_GET_VARS, $HTTP_POST_VARS; 235 236 $field = '<input type="hidden" name="' . tep_output_string($name) . '"'; 237 238 if (tep_not_null($value)) { 239 $field .= ' value="' . tep_output_string($value) . '"'; 240 } elseif ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) { 241 if ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) ) { 242 $field .= ' value="' . tep_output_string(stripslashes($HTTP_GET_VARS[$name])) . '"'; 243 } elseif ( (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) { 244 $field .= ' value="' . tep_output_string(stripslashes($HTTP_POST_VARS[$name])) . '"'; 245 } 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 global $HTTP_GET_VARS, $HTTP_POST_VARS; 269 270 $field = '<select name="' . tep_output_string($name) . '"'; 271 272 if (tep_not_null($parameters)) $field .= ' ' . $parameters; 273 274 $field .= '>'; 275 276 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])) ) ) { 277 if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) { 278 $default = stripslashes($HTTP_GET_VARS[$name]); 279 } elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) { 280 $default = stripslashes($HTTP_POST_VARS[$name]); 281 } 282 } 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 299 //// 300 // Creates a pull-down list of countries 301 function tep_get_country_list($name, $selected = '', $parameters = '') { 302 $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT)); 303 $countries = tep_get_countries(); 304 305 for ($i=0, $n=sizeof($countries); $i<$n; $i++) { 306 $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']); 307 } 308 309 return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters); 310 } 311 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Jan 1 13:43:16 2010 | Cross-referenced by PHPXref 0.7 |