[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文件
文件大小: 21.98 KiB
MD5: 5c4dbb9164e340d6831066e88435d7f6

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