[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 html_output.php

Zen Cart 源代码 html_output.php




下载文件

文件名: html_output.php
文件类型: PHP文件
文件大小: 22.92 KiB
MD5: 4cd022d1d0873928597cb02794f623b7

html_output.php - 关闭高亮
  1. <?php
  2. /**
  3.  * html_output.php
  4.  * HTML-generating functions used throughout the core
  5.  *
  6.  * @package functions
  7.  * @copyright Copyright 2003-2011 Zen Cart Development Team
  8.  * @copyright Portions Copyright 2003 osCommerce
  9.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  10.  * @version $Id: html_output.php 19355 2011-08-21 21:12:09Z drbyte $
  11.  */
  12.  
  13. // Ultimate SEO URLs
  14. // The HTML href link wrapper function
  15.   function zen_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true, $static = false, $use_dir_ws_catalog = true) {
  16.  
  17.         /* QUICK AND DIRTY WAY TO DISABLE REDIRECTS ON PAGES WHEN SEO_URLS_ONLY_IN is enabled IMAGINADW.COM */
  18.         $sefu = explode(",", preg_replace( '/ +/', '', SEO_URLS_ONLY_IN ));
  19.         if((SEO_URLS_ONLY_IN!="") && !in_array($page,$sefu)) {
  20.             return original_zen_href_link($page, $parameters, $connection, $add_session_id, $search_engine_safe, $static, $use_dir_ws_catalog);
  21.         }
  22.  
  23.         if (!isset($GLOBALS['seo_urls']) && !is_object($GLOBALS['seo_urls'])) {
  24.             include_once(DIR_WS_CLASSES . 'seo.url.php');
  25.  
  26.             $GLOBALS['seo_urls'] = &new SEO_URL($_SESSION['languages_id']);
  27.         }
  28.  
  29.         return $GLOBALS['seo_urls']->href_link($page, $parameters, $connection, $add_session_id, $static, $use_dir_ws_catalog);
  30.   }
  31.  
  32. /*
  33.  * The HTML href link wrapper function
  34.  */
  35.   function original_zen_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true, $static = false, $use_dir_ws_catalog = true) {
  36.     global $request_type, $session_started, $http_domain, $https_domain;
  37.  
  38.     if (!zen_not_null($page)) {
  39.       die('</td></tr></table></td></tr></table><br /><br /><strong class="note">Error!<br /><br />Unable to determine the page link!</strong><br /><br /><!--' . $page . '<br />' . $parameters . ' -->');
  40.     }
  41.  
  42.     if ($connection == 'NONSSL') {
  43.       $link = HTTP_SERVER;
  44.     } elseif ($connection == 'SSL') {
  45.       if (ENABLE_SSL == 'true') {
  46.         $link = HTTPS_SERVER ;
  47.       } else {
  48.         $link = HTTP_SERVER;
  49.       }
  50.     } else {
  51.       die('</td></tr></table></td></tr></table><br /><br /><strong class="note">Error!<br /><br />Unable to determine connection method on a link!<br /><br />Known methods: NONSSL SSL</strong><br /><br />');
  52.     }
  53.  
  54.     if ($use_dir_ws_catalog) {
  55.       if ($connection == 'SSL' && ENABLE_SSL == 'true') {
  56.         $link .= DIR_WS_HTTPS_CATALOG;
  57.       } else {
  58.         $link .= DIR_WS_CATALOG;
  59.       }
  60.     }
  61.  
  62.     if (!$static) {
  63.       if (zen_not_null($parameters)) {
  64.         $link .= 'index.php?main_page='. $page . "&" . zen_output_string($parameters);
  65.       } else {
  66.         $link .= 'index.php?main_page=' . $page;
  67.       }
  68.     } else {
  69.       if (zen_not_null($parameters)) {
  70.         $link .= $page . "?" . zen_output_string($parameters);
  71.       } else {
  72.         $link .= $page;
  73.       }
  74.     }
  75.  
  76.     $separator = '&';
  77.  
  78.     while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
  79. // Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined
  80.     if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
  81.       if (defined('SID') && zen_not_null(SID)) {
  82.         $sid = SID;
  83. //      } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL_ADMIN == 'true') ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
  84.       } elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == 'true') ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
  85.         if ($http_domain != $https_domain) {
  86.           $sid = zen_session_name() . '=' . zen_session_id();
  87.         }
  88.       }
  89.     }
  90.  
  91. // clean up the link before processing
  92.     while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);
  93.     while (strstr($link, '&amp;&amp;')) $link = str_replace('&amp;&amp;', '&amp;', $link);
  94.  
  95.     if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
  96.       while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);
  97.  
  98.       $link = str_replace('&amp;', '/', $link);
  99.       $link = str_replace('?', '/', $link);
  100.       $link = str_replace('&', '/', $link);
  101.       $link = str_replace('=', '/', $link);
  102.  
  103.       $separator = '?';
  104.     }
  105.  
  106.     if (isset($sid)) {
  107.       $link .= $separator . zen_output_string($sid);
  108.     }
  109.  
  110. // clean up the link after processing
  111.     while (strstr($link, '&amp;&amp;')) $link = str_replace('&amp;&amp;', '&amp;', $link);
  112.  
  113.     $link = preg_replace('/&/', '&amp;', $link);
  114.     return $link;
  115.   }
  116.  
  117.  
  118. /*
  119.  * The HTML image wrapper function for non-proportional images
  120.  * used when "proportional images" is turned off or if calling from a template directory
  121.  */
  122.   function zen_image_OLD($src, $alt = '', $width = '', $height = '', $parameters = '') {
  123.     global $template_dir;
  124.  
  125. //auto replace with defined missing image
  126.     if ($src == DIR_WS_IMAGES and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
  127.       $src = DIR_WS_IMAGES . PRODUCTS_IMAGE_NO_IMAGE;
  128.     }
  129.  
  130.     if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
  131.       return false;
  132.     }
  133.  
  134.     // if not in current template switch to template_default
  135.     if (!file_exists($src)) {
  136.       $src = str_replace(DIR_WS_TEMPLATES . $template_dir, DIR_WS_TEMPLATES . 'template_default', $src);
  137.     }
  138.  
  139. // alt is added to the img tag even if it is null to prevent browsers from outputting
  140. // the image filename as default
  141.     $image = '<img src="' . zen_output_string($src) . '" alt="' . zen_output_string($alt) . '"';
  142.  
  143.     if (zen_not_null($alt)) {
  144.       $image .= ' title=" ' . zen_output_string($alt) . ' "';
  145.     }
  146.  
  147.     if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height)) ) {
  148.       if ($image_size = @getimagesize($src)) {
  149.         if (empty($width) && zen_not_null($height)) {
  150.           $ratio = $height / $image_size[1];
  151.           $width = $image_size[0] * $ratio;
  152.         } elseif (zen_not_null($width) && empty($height)) {
  153.           $ratio = $width / $image_size[0];
  154.           $height = $image_size[1] * $ratio;
  155.         } elseif (empty($width) && empty($height)) {
  156.           $width = $image_size[0];
  157.           $height = $image_size[1];
  158.         }
  159.       } elseif (IMAGE_REQUIRED == 'false') {
  160.         return false;
  161.       }
  162.     }
  163.  
  164.     if (zen_not_null($width) && zen_not_null($height)) {
  165.       $image .= ' width="' . zen_output_string($width) . '" height="' . zen_output_string($height) . '"';
  166.     }
  167.  
  168.     if (zen_not_null($parameters)) $image .= ' ' . $parameters;
  169.  
  170.     $image .= ' />';
  171.  
  172.     return $image;
  173.   }
  174.  
  175.  
  176. /*
  177.  * The HTML image wrapper function
  178.  */
  179.   function zen_image($src, $alt = '', $width = '', $height = '', $parameters = '') {
  180.     global $template_dir, $zco_notifier;
  181.  
  182.     // soft clean the alt tag
  183.     $alt = zen_clean_html($alt);
  184.  
  185.     // use old method on template images
  186.     if (strstr($src, 'includes/templates') or strstr($src, 'includes/languages') or PROPORTIONAL_IMAGES_STATUS == '0') {
  187.       return zen_image_OLD($src, $alt, $width, $height, $parameters);
  188.     }
  189.  
  190. //auto replace with defined missing image
  191.     if ($src == DIR_WS_IMAGES and PRODUCTS_IMAGE_NO_IMAGE_STATUS == '1') {
  192.       $src = DIR_WS_IMAGES . PRODUCTS_IMAGE_NO_IMAGE;
  193.     }
  194.  
  195.     if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
  196.       return false;
  197.     }
  198.  
  199.     // if not in current template switch to template_default
  200.     if (!file_exists($src)) {
  201.       $src = str_replace(DIR_WS_TEMPLATES . $template_dir, DIR_WS_TEMPLATES . 'template_default', $src);
  202.     }
  203.  
  204.     // hook for handle_image() function such as Image Handler etc
  205.     if (function_exists('handle_image')) {
  206.       $newimg = handle_image($src, $alt, $width, $height, $parameters);
  207.       list($src, $alt, $width, $height, $parameters) = $newimg;
  208.       $zco_notifier->notify('NOTIFY_HANDLE_IMAGE', array($newimg));
  209.     }
  210.  
  211.     // Convert width/height to int for proper validation.
  212.     // intval() used to support compatibility with plugins like image-handler
  213.     $width = empty($width) ? $width : intval($width);
  214.     $height = empty($height) ? $height : intval($height);
  215.  
  216. // alt is added to the img tag even if it is null to prevent browsers from outputting
  217. // the image filename as default
  218.     $image = '<img src="' . zen_output_string($src) . '" alt="' . zen_output_string($alt) . '"';
  219.  
  220.     if (zen_not_null($alt)) {
  221.       $image .= ' title=" ' . zen_output_string($alt) . ' "';
  222.     }
  223.  
  224.     if ( ((CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height))) ) {
  225.       if ($image_size = @getimagesize($src)) {
  226.         if (empty($width) && zen_not_null($height)) {
  227.           $ratio = $height / $image_size[1];
  228.           $width = $image_size[0] * $ratio;
  229.         } elseif (zen_not_null($width) && empty($height)) {
  230.           $ratio = $width / $image_size[0];
  231.           $height = $image_size[1] * $ratio;
  232.         } elseif (empty($width) && empty($height)) {
  233.           $width = $image_size[0];
  234.           $height = $image_size[1];
  235.         }
  236.       } elseif (IMAGE_REQUIRED == 'false') {
  237.         return false;
  238.       }
  239.     }
  240.  
  241.  
  242.     if (zen_not_null($width) && zen_not_null($height) and file_exists($src)) {
  243. //      $image .= ' width="' . zen_output_string($width) . '" height="' . zen_output_string($height) . '"';
  244. // proportional images
  245.       $image_size = @getimagesize($src);
  246.       // fix division by zero error
  247.       $ratio = ($image_size[0] != 0 ? $width / $image_size[0] : 1);
  248.       if ($image_size[1]*$ratio > $height) {
  249.         $ratio = $height / $image_size[1];
  250.         $width = $image_size[0] * $ratio;
  251.       } else {
  252.         $height = $image_size[1] * $ratio;
  253.       }
  254. // only use proportional image when image is larger than proportional size
  255.       if ($image_size[0] < $width and $image_size[1] < $height) {
  256.         $image .= ' width="' . $image_size[0] . '" height="' . intval($image_size[1]) . '"';
  257.       } else {
  258.         $image .= ' width="' . round($width) . '" height="' . round($height) . '"';
  259.       }
  260.     } else {
  261.        // override on missing image to allow for proportional and required/not required
  262.       if (IMAGE_REQUIRED == 'false') {
  263.         return false;
  264.       } else if (substr($src, 0, 4) != 'http') {
  265.         $image .= ' width="' . intval(SMALL_IMAGE_WIDTH) . '" height="' . intval(SMALL_IMAGE_HEIGHT) . '"';
  266.       }
  267.     }
  268.  
  269.     // inject rollover class if one is defined. NOTE: This could end up with 2 "class" elements if $parameters contains "class" already.
  270.     if (defined('IMAGE_ROLLOVER_CLASS') && IMAGE_ROLLOVER_CLASS != '') {
  271.       $parameters .= (zen_not_null($parameters) ? ' ' : '') . 'class="rollover"';
  272.     }
  273.     // add $parameters to the tag output
  274.     if (zen_not_null($parameters)) $image .= ' ' . $parameters;
  275.  
  276.     $image .= ' />';
  277.  
  278.     return $image;
  279.   }
  280.  
  281. /*
  282.  * The HTML form submit button wrapper function
  283.  * Outputs a "submit" button in the selected language
  284.  */
  285.   function zen_image_submit($image, $alt = '', $parameters = '', $sec_class = '') {
  286.     global $template, $current_page_base, $zco_notifier;
  287.     if (strtolower(IMAGE_USE_CSS_BUTTONS) == 'yes' && strlen($alt)<30) return zenCssButton($image, $alt, 'submit', $sec_class /*, $parameters = ''*/ );
  288.     $zco_notifier->notify('PAGE_OUTPUT_IMAGE_SUBMIT');
  289.  
  290.     $image_submit = '<input type="image" src="' . zen_output_string($template->get_template_dir($image, DIR_WS_TEMPLATE, $current_page_base, 'buttons/' . $_SESSION['language'] . '/') . $image) . '" alt="' . zen_output_string($alt) . '"';
  291.  
  292.     if (zen_not_null($alt)) $image_submit .= ' title=" ' . zen_output_string($alt) . ' "';
  293.  
  294.     if (zen_not_null($parameters)) $image_submit .= ' ' . $parameters;
  295.  
  296.     $image_submit .= ' />';
  297.  
  298.     return $image_submit;
  299.   }
  300.  
  301. /*
  302.  * Output a function button in the selected language
  303.  */
  304.   function zen_image_button($image, $alt = '', $parameters = '', $sec_class = '') {
  305.     global $template, $current_page_base, $zco_notifier;
  306.  
  307.     // inject rollover class if one is defined. NOTE: This could end up with 2 "class" elements if $parameters contains "class" already.
  308.     if (defined('IMAGE_ROLLOVER_CLASS') && IMAGE_ROLLOVER_CLASS != '') {
  309.       $parameters .= (zen_not_null($parameters) ? ' ' : '') . 'class="rollover"';
  310.     }
  311.  
  312.     $zco_notifier->notify('PAGE_OUTPUT_IMAGE_BUTTON');
  313.     if (strtolower(IMAGE_USE_CSS_BUTTONS) == 'yes') return zenCssButton($image, $alt, 'button', $sec_class, $parameters = '');
  314.     return zen_image($template->get_template_dir($image, DIR_WS_TEMPLATE, $current_page_base, 'buttons/' . $_SESSION['language'] . '/') . $image, $alt, '', '', $parameters);
  315.   }
  316.  
  317.  
  318. /**
  319.  * generate CSS buttons in the current language
  320.  * concept from contributions by Seb Rouleau and paulm, subsequently adapted to Zen Cart
  321.  * note: any hard-coded buttons will not be able to use this function
  322. **/
  323.   function zenCssButton($image = '', $text, $type, $sec_class = '', $parameters = '') {
  324.  
  325.     // automatic width setting depending on the number of characters
  326.     $min_width = 80; // this is the minimum button width, change the value as you like
  327.     $character_width = 6.5; // change this value depending on font size!
  328.     // end settings
  329.     // added html_entity_decode function to prevent html special chars to be counted as multiple characters (like &amp;)
  330.     $width = strlen(html_entity_decode($text)) * $character_width;
  331.     $width = (int)$width;
  332.     if ($width < $min_width) $width = $min_width;
  333.     $style = ' style="width: ' . $width . 'px;"';
  334.     // if no secondary class is set use the image name for the sec_class
  335.     if (empty($sec_class)) $sec_class = basename($image, '.gif');
  336.     if(!empty($sec_class))$sec_class = ' ' . $sec_class;
  337.     if(!empty($parameters))$parameters = ' ' . $parameters;
  338.     $mouse_out_class  = 'cssButton' . $sec_class;
  339.     $mouse_over_class = 'cssButtonHover' . $sec_class . $sec_class . 'Hover';
  340.     // javascript to set different classes on mouseover and mouseout: enables hover effect on the buttons
  341.     // (pure css hovers on non link elements do work work in every browser)
  342.     $css_button_js .=  'onmouseover="this.className=\''. $mouse_over_class . '\'" onmouseout="this.className=\'' . $mouse_out_class . '\'"';
  343.  
  344.     if ($type == 'submit'){
  345. // form input button
  346.    $css_button = '<input class="' . $mouse_out_class . '" ' . $css_button_js . ' type="submit" value="' .$text . '"' . $parameters . $style . ' />';
  347.     }
  348.  
  349.     if ($type=='button'){
  350. // link button
  351.    $css_button = '<span class="' . $mouse_out_class . '" ' . $css_button_js . $style . ' >&nbsp;' . $text . '&nbsp;</span>'; // add $parameters ???
  352.     }
  353.     return $css_button;
  354.   }
  355.  
  356.  
  357. /*
  358.  *  Output a separator either through whitespace, or with an image
  359.  */
  360.   function zen_draw_separator($image = 'true', $width = '100%', $height = '1') {
  361.  
  362.     // set default to use from template - zen_image will translate if not found in current template
  363.     if ($image == 'true') {
  364.       $image = DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_BLACK_SEPARATOR;
  365.     } else {
  366.       if (!strstr($image, DIR_WS_TEMPLATE_IMAGES)) {
  367.         $image = DIR_WS_TEMPLATE_IMAGES . $image;
  368.       }
  369.     }
  370.     return zen_image($image, '', $width, $height);
  371.   }
  372.  
  373. /*
  374.  *  Output a form
  375.  */
  376.   function zen_draw_form($name, $action, $method = 'post', $parameters = '') {
  377.     $form = '<form name="' . zen_output_string($name) . '" action="' . zen_output_string($action) . '" method="' . zen_output_string($method) . '"';
  378.  
  379.     if (zen_not_null($parameters)) $form .= ' ' . $parameters;
  380.  
  381.     $form .= '>';
  382.     if (strtolower($method) == 'post') $form .= '<input type="hidden" name="securityToken" value="' . $_SESSION['securityToken'] . '" />';
  383.     return $form;
  384.   }
  385.  
  386. /*
  387.  *  Output a form input field
  388.  */
  389.   function zen_draw_input_field($name, $value = '', $parameters = '', $type = 'text', $reinsert_value = true) {
  390.     $field = '<input type="' . zen_output_string($type) . '" name="' . zen_sanitize_string(zen_output_string($name)) . '"';
  391.     if ( (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) && ($reinsert_value == true) ) {
  392.       $field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
  393.     } elseif (zen_not_null($value)) {
  394.       $field .= ' value="' . zen_output_string($value) . '"';
  395.     }
  396.  
  397.     if (zen_not_null($parameters)) $field .= ' ' . $parameters;
  398.  
  399.     $field .= ' />';
  400.  
  401.     return $field;
  402.   }
  403.  
  404. /*
  405.  *  Output a form password field
  406.  */
  407.   function zen_draw_password_field($name, $value = '', $parameters = 'maxlength="40"') {
  408.     return zen_draw_input_field($name, $value, $parameters, 'password', true);
  409.   }
  410.  
  411. /*
  412.  *  Output a selection field - alias function for zen_draw_checkbox_field() and zen_draw_radio_field()
  413.  */
  414.   function zen_draw_selection_field($name, $type, $value = '', $checked = false, $parameters = '') {
  415.     $selection = '<input type="' . zen_output_string($type) . '" name="' . zen_output_string($name) . '"';
  416.  
  417.     if (zen_not_null($value)) $selection .= ' value="' . zen_output_string($value) . '"';
  418.  
  419.     if ( ($checked == true) || ( isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ( ($GLOBALS[$name] == 'on') || (isset($value) && (stripslashes($GLOBALS[$name]) == $value)) ) ) ) {
  420.       $selection .= ' checked="checked"';
  421.     }
  422.  
  423.     if (zen_not_null($parameters)) $selection .= ' ' . $parameters;
  424.  
  425.     $selection .= ' />';
  426.  
  427.     return $selection;
  428.   }
  429.  
  430. /*
  431.  *  Output a form checkbox field
  432.  */
  433.   function zen_draw_checkbox_field($name, $value = '', $checked = false, $parameters = '') {
  434.     return zen_draw_selection_field($name, 'checkbox', $value, $checked, $parameters);
  435.   }
  436.  
  437. /*
  438.  * Output a form radio field
  439.  */
  440.   function zen_draw_radio_field($name, $value = '', $checked = false, $parameters = '') {
  441.     return zen_draw_selection_field($name, 'radio', $value, $checked, $parameters);
  442.   }
  443.  
  444. /*
  445.  *  Output a form textarea field
  446.  */
  447.   function zen_draw_textarea_field($name, $width, $height, $text = '~*~*#', $parameters = '', $reinsert_value = true) {
  448.     $field = '<textarea name="' . zen_output_string($name) . '" cols="' . zen_output_string($width) . '" rows="' . zen_output_string($height) . '"';
  449.  
  450.     if (zen_not_null($parameters)) $field .= ' ' . $parameters;
  451.  
  452.     $field .= '>';
  453.  
  454.     if ($text == '~*~*#' && (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) && ($reinsert_value == true) ) {
  455.       $field .= stripslashes($GLOBALS[$name]);
  456.     } elseif ($text != '~*~*#' && zen_not_null($text)) {
  457.       $field .= $text;
  458.     }
  459.  
  460.     $field .= '</textarea>';
  461.  
  462.     return $field;
  463.   }
  464.  
  465. /*
  466.  *  Output a form hidden field
  467.  */
  468.   function zen_draw_hidden_field($name, $value = '', $parameters = '') {
  469.     $field = '<input type="hidden" name="' . zen_sanitize_string(zen_output_string($name)) . '"';
  470.  
  471.     if (zen_not_null($value)) {
  472.       $field .= ' value="' . zen_output_string($value) . '"';
  473.     } elseif (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) {
  474.       $field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
  475.     }
  476.  
  477.     if (zen_not_null($parameters)) $field .= ' ' . $parameters;
  478.  
  479.     $field .= ' />';
  480.  
  481.     return $field;
  482.   }
  483.  
  484. /*
  485.  * Output a form file-field
  486.  */
  487.   function zen_draw_file_field($name, $required = false) {
  488.     $field = zen_draw_input_field($name, '', ' size="50" ', 'file');
  489.  
  490.     return $field;
  491.   }
  492.  
  493.  
  494. /*
  495.  *  Hide form elements while including session id info
  496.  *  IMPORTANT: This should be used in every FORM that has an OnSubmit() function tied to it, to prevent unexpected logouts
  497.  */
  498.   function zen_hide_session_id() {
  499.     global $session_started;
  500.  
  501.     if ( ($session_started == true) && defined('SID') && zen_not_null(SID) ) {
  502.       return zen_draw_hidden_field(zen_session_name(), zen_session_id());
  503.     }
  504.   }
  505.  
  506. /*
  507.  *  Output a form pull down menu
  508.  *  Pulls values from a passed array, with the indicated option pre-selected
  509.  */
  510.   function zen_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
  511.     $field = '<select name="' . zen_output_string($name) . '"';
  512.  
  513.     if (zen_not_null($parameters)) $field .= ' ' . $parameters;
  514.  
  515.     $field .= '>' . "\n";
  516.  
  517.     if (empty($default) && isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) ) $default = stripslashes($GLOBALS[$name]);
  518.  
  519.     for ($i=0, $n=sizeof($values); $i<$n; $i++) {
  520.       $field .= '  <option value="' . zen_output_string($values[$i]['id']) . '"';
  521.       if ($default == $values[$i]['id']) {
  522.         $field .= ' selected="selected"';
  523.       }
  524.  
  525.       $field .= '>' . zen_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => '&#039;', '<' => '&lt;', '>' => '&gt;')) . '</option>' . "\n";
  526.     }
  527.     $field .= '</select>' . "\n";
  528.  
  529.     if ($required == true) $field .= TEXT_FIELD_REQUIRED;
  530.  
  531.     return $field;
  532.   }
  533.  
  534. /*
  535.  * Creates a pull-down list of countries
  536.  */
  537.   function zen_get_country_list($name, $selected = '', $parameters = '') {
  538.     $countriesAtTopOfList = array();
  539.     $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
  540.     $countries = zen_get_countries();
  541.  
  542.     // Set some default entries at top of list:
  543.     if (STORE_COUNTRY != SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY) $countriesAtTopOfList[] = SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY;
  544.     $countriesAtTopOfList[] = STORE_COUNTRY;
  545.     // IF YOU WANT TO ADD MORE DEFAULTS TO THE TOP OF THIS LIST, SIMPLY ENTER THEIR NUMBERS HERE.
  546.     // Duplicate more lines as needed
  547.     // Example: Canada is 108, so use 108 as shown:
  548.     //$countriesAtTopOfList[] = 108;
  549.  
  550.     //process array of top-of-list entries:
  551.     foreach ($countriesAtTopOfList as $key=>$val) {
  552.       $countries_array[] = array('id' => $val, 'text' => zen_get_country_name($val));
  553.     }
  554.     // now add anything not in the defaults list:
  555.     for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
  556.       $alreadyInList = FALSE;
  557.       foreach($countriesAtTopOfList as $key=>$val) {
  558.         if ($countries[$i]['countries_id'] == $val)
  559.         {
  560.           // If you don't want to exclude entries already at the top of the list, comment out this next line:
  561.           $alreadyInList = TRUE;
  562.           continue;
  563.         }
  564.       }
  565.       if (!$alreadyInList) $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);
  566.     }
  567.  
  568.     return zen_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
  569.   }
  570. /*
  571.  * Assesses suitability for additional parameters such as rel=nofollow etc
  572.  */
  573.   function zen_href_params($page = '', $parameters = '') {
  574.     global $current_page_base;
  575.     $addparms = '';
  576.     // if nofollow has already been set, ignore this function
  577.     if (stristr($parameters, 'nofollow')) return $parameters;
  578.     // if list of skippable pages has been set in meta_tags.php lang file (is by default), use that to add rel=nofollow params
  579.     if (defined('ROBOTS_PAGES_TO_SKIP') && in_array($page, explode(",", constant('ROBOTS_PAGES_TO_SKIP')))
  580.         || $current_page_base=='down_for_maintenance') $addparms = 'rel="nofollow"';
  581.     return ($parameters == '' ? $addparms : $parameters . ' ' . $addparms);
  582.   }
  583. ?>