[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.73 KiB
MD5: 7df446ef3847fa89552ed1c83a8ec648

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-2009 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 16306 2010-05-21 21:24:03Z wilt $
  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;
  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.     }
  190.  
  191.     // Convert width/height to int for proper validation.
  192.     // intval() used to support compatibility with plugins like image-handler
  193.     $width = empty($width) ? $width : intval($width);
  194.     $height = empty($height) ? $height : intval($height);
  195.  
  196. // alt is added to the img tag even if it is null to prevent browsers from outputting
  197. // the image filename as default
  198.     $image = '<img src="' . zen_output_string($src) . '" alt="' . zen_output_string($alt) . '"';
  199.  
  200.     if (zen_not_null($alt)) {
  201.       $image .= ' title=" ' . zen_output_string($alt) . ' "';
  202.     }
  203.  
  204.     if ( ((CONFIG_CALCULATE_IMAGE_SIZE == 'true') && (empty($width) || empty($height))) ) {
  205.       if ($image_size = @getimagesize($src)) {
  206.         if (empty($width) && zen_not_null($height)) {
  207.           $ratio = $height / $image_size[1];
  208.           $width = $image_size[0] * $ratio;
  209.         } elseif (zen_not_null($width) && empty($height)) {
  210.           $ratio = $width / $image_size[0];
  211.           $height = $image_size[1] * $ratio;
  212.         } elseif (empty($width) && empty($height)) {
  213.           $width = $image_size[0];
  214.           $height = $image_size[1];
  215.         }
  216.       } elseif (IMAGE_REQUIRED == 'false') {
  217.         return false;
  218.       }
  219.     }
  220.  
  221.  
  222.     if (zen_not_null($width) && zen_not_null($height) and file_exists($src)) {
  223. //      $image .= ' width="' . zen_output_string($width) . '" height="' . zen_output_string($height) . '"';
  224. // proportional images
  225.       $image_size = @getimagesize($src);
  226.       // fix division by zero error
  227.       $ratio = ($image_size[0] != 0 ? $width / $image_size[0] : 1);
  228.       if ($image_size[1]*$ratio > $height) {
  229.         $ratio = $height / $image_size[1];
  230.         $width = $image_size[0] * $ratio;
  231.       } else {
  232.         $height = $image_size[1] * $ratio;
  233.       }
  234. // only use proportional image when image is larger than proportional size
  235.       if ($image_size[0] < $width and $image_size[1] < $height) {
  236.         $image .= ' width="' . $image_size[0] . '" height="' . intval($image_size[1]) . '"';
  237.       } else {
  238.         $image .= ' width="' . round($width) . '" height="' . round($height) . '"';
  239.       }
  240.     } else {
  241.        // override on missing image to allow for proportional and required/not required
  242.       if (IMAGE_REQUIRED == 'false') {
  243.         return false;
  244.       } else {
  245.         $image .= ' width="' . intval(SMALL_IMAGE_WIDTH) . '" height="' . intval(SMALL_IMAGE_HEIGHT) . '"';
  246.       }
  247.     }
  248.  
  249.     // inject rollover class if one is defined. NOTE: This could end up with 2 "class" elements if $parameters contains "class" already.
  250.     if (defined('IMAGE_ROLLOVER_CLASS') && IMAGE_ROLLOVER_CLASS != '') {
  251.         $parameters .= (zen_not_null($parameters) ? ' ' : '') . 'class="rollover"';
  252.     }
  253.     // add $parameters to the tag output
  254.     if (zen_not_null($parameters)) $image .= ' ' . $parameters;
  255.  
  256.     $image .= ' />';
  257.  
  258.     return $image;
  259.   }
  260.  
  261. /*
  262.  * The HTML form submit button wrapper function
  263.  * Outputs a "submit" button in the selected language
  264.  */
  265.   function zen_image_submit($image, $alt = '', $parameters = '', $sec_class = '') {
  266.     global $template, $current_page_base, $zco_notifier;
  267.     if (strtolower(IMAGE_USE_CSS_BUTTONS) == 'yes' && strlen($alt)<30) return zenCssButton($image, $alt, 'submit', $sec_class /*, $parameters = ''*/ );
  268.     $zco_notifier->notify('PAGE_OUTPUT_IMAGE_SUBMIT');
  269.  
  270.     $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) . '"';
  271.  
  272.     if (zen_not_null($alt)) $image_submit .= ' title=" ' . zen_output_string($alt) . ' "';
  273.  
  274.     if (zen_not_null($parameters)) $image_submit .= ' ' . $parameters;
  275.  
  276.     $image_submit .= ' />';
  277.  
  278.     return $image_submit;
  279.   }
  280.  
  281. /*
  282.  * Output a function button in the selected language
  283.  */
  284.   function zen_image_button($image, $alt = '', $parameters = '', $sec_class = '') {
  285.     global $template, $current_page_base, $zco_notifier;
  286.  
  287.     // inject rollover class if one is defined. NOTE: This could end up with 2 "class" elements if $parameters contains "class" already.
  288.     if (defined('IMAGE_ROLLOVER_CLASS') && IMAGE_ROLLOVER_CLASS != '') {
  289.         $parameters .= (zen_not_null($parameters) ? ' ' : '') . 'class="rollover"';
  290.     }
  291.  
  292.     $zco_notifier->notify('PAGE_OUTPUT_IMAGE_BUTTON');
  293.     if (strtolower(IMAGE_USE_CSS_BUTTONS) == 'yes') return zenCssButton($image, $alt, 'button', $sec_class, $parameters = '');
  294.     return zen_image($template->get_template_dir($image, DIR_WS_TEMPLATE, $current_page_base, 'buttons/' . $_SESSION['language'] . '/') . $image, $alt, '', '', $parameters);
  295.   }
  296.  
  297.  
  298. /**
  299.  * generate CSS buttons in the current language
  300.  * concept from contributions by Seb Rouleau and paulm, subsequently adapted to Zen Cart
  301.  * note: any hard-coded buttons will not be able to use this function
  302. **/
  303.   function zenCssButton($image = '', $text, $type, $sec_class = '', $parameters = '') {
  304.  
  305.     // automatic width setting depending on the number of characters
  306.     $min_width = 80; // this is the minimum button width, change the value as you like
  307.     $character_width = 6.5; // change this value depending on font size!
  308.     // end settings
  309.     // added html_entity_decode function to prevent html special chars to be counted as multiple characters (like &amp;)
  310.     $width = strlen(html_entity_decode($text)) * $character_width;
  311.     $width = (int)$width;
  312.     if ($width < $min_width) $width = $min_width;
  313.     $style = ' style="width: ' . $width . 'px;"';
  314.     // if no secondary class is set use the image name for the sec_class
  315.     if (empty($sec_class)) $sec_class = basename($image, '.gif');
  316.     if(!empty($sec_class))$sec_class = ' ' . $sec_class;
  317.     if(!empty($parameters))$parameters = ' ' . $parameters;
  318.     $mouse_out_class  = 'cssButton' . $sec_class;
  319.     $mouse_over_class = 'cssButtonHover' . $sec_class . $sec_class . 'Hover';
  320.     // javascript to set different classes on mouseover and mouseout: enables hover effect on the buttons
  321.     // (pure css hovers on non link elements do work work in every browser)
  322.     $css_button_js .=  'onmouseover="this.className=\''. $mouse_over_class . '\'" onmouseout="this.className=\'' . $mouse_out_class . '\'"';
  323.  
  324.     if ($type == 'submit'){
  325. // form input button
  326.    $css_button = '<input class="' . $mouse_out_class . '" ' . $css_button_js . ' type="submit" value="' .$text . '"' . $parameters . $style . ' />';
  327.     }
  328.  
  329.     if ($type=='button'){
  330. // link button
  331.    $css_button = '<span class="' . $mouse_out_class . '" ' . $css_button_js . $style . ' >&nbsp;' . $text . '&nbsp;</span>'; // add $parameters ???
  332.     }
  333.     return $css_button;
  334.   }
  335.  
  336.  
  337. /*
  338.  *  Output a separator either through whitespace, or with an image
  339.  */
  340.   function zen_draw_separator($image = 'true', $width = '100%', $height = '1') {
  341.  
  342.     // set default to use from template - zen_image will translate if not found in current template
  343.     if ($image == 'true') {
  344.       $image = DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_BLACK_SEPARATOR;
  345.     } else {
  346.       if (!strstr($image, DIR_WS_TEMPLATE_IMAGES)) {
  347.         $image = DIR_WS_TEMPLATE_IMAGES . $image;
  348.       }
  349.     }
  350.     return zen_image($image, '', $width, $height);
  351.   }
  352.  
  353. /*
  354.  *  Output a form
  355.  */
  356.   function zen_draw_form($name, $action, $method = 'post', $parameters = '') {
  357.     $form = '<form name="' . zen_output_string($name) . '" action="' . zen_output_string($action) . '" method="' . zen_output_string($method) . '"';
  358.  
  359.     if (zen_not_null($parameters)) $form .= ' ' . $parameters;
  360.  
  361.     $form .= '>';
  362.  
  363.     return $form;
  364.   }
  365.  
  366. /*
  367.  *  Output a form input field
  368.  */
  369.   function zen_draw_input_field($name, $value = '', $parameters = '', $type = 'text', $reinsert_value = true) {
  370.     $field = '<input type="' . zen_output_string($type) . '" name="' . zen_sanitize_string(zen_output_string($name)) . '"';
  371.     if ( (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) && ($reinsert_value == true) ) {
  372.       $field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
  373.     } elseif (zen_not_null($value)) {
  374.       $field .= ' value="' . zen_output_string($value) . '"';
  375.     }
  376.  
  377.     if (zen_not_null($parameters)) $field .= ' ' . $parameters;
  378.  
  379.     $field .= ' />';
  380.  
  381.     return $field;
  382.   }
  383.  
  384. /*
  385.  *  Output a form password field
  386.  */
  387.   function zen_draw_password_field($name, $value = '', $parameters = 'maxlength="40"') {
  388.     return zen_draw_input_field($name, $value, $parameters, 'password', true);
  389.   }
  390.  
  391. /*
  392.  *  Output a selection field - alias function for zen_draw_checkbox_field() and zen_draw_radio_field()
  393.  */
  394.   function zen_draw_selection_field($name, $type, $value = '', $checked = false, $parameters = '') {
  395.     $selection = '<input type="' . zen_output_string($type) . '" name="' . zen_output_string($name) . '"';
  396.  
  397.     if (zen_not_null($value)) $selection .= ' value="' . zen_output_string($value) . '"';
  398.  
  399.     if ( ($checked == true) || ( isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) && ( ($GLOBALS[$name] == 'on') || (isset($value) && (stripslashes($GLOBALS[$name]) == $value)) ) ) ) {
  400.       $selection .= ' checked="checked"';
  401.     }
  402.  
  403.     if (zen_not_null($parameters)) $selection .= ' ' . $parameters;
  404.  
  405.     $selection .= ' />';
  406.  
  407.     return $selection;
  408.   }
  409.  
  410. /*
  411.  *  Output a form checkbox field
  412.  */
  413.   function zen_draw_checkbox_field($name, $value = '', $checked = false, $parameters = '') {
  414.     return zen_draw_selection_field($name, 'checkbox', $value, $checked, $parameters);
  415.   }
  416.  
  417. /*
  418.  * Output a form radio field
  419.  */
  420.   function zen_draw_radio_field($name, $value = '', $checked = false, $parameters = '') {
  421.     return zen_draw_selection_field($name, 'radio', $value, $checked, $parameters);
  422.   }
  423.  
  424. /*
  425.  *  Output a form textarea field
  426.  */
  427.   function zen_draw_textarea_field($name, $width, $height, $text = '~*~*#', $parameters = '', $reinsert_value = true) {
  428.     $field = '<textarea name="' . zen_output_string($name) . '" cols="' . zen_output_string($width) . '" rows="' . zen_output_string($height) . '"';
  429.  
  430.     if (zen_not_null($parameters)) $field .= ' ' . $parameters;
  431.  
  432.     $field .= '>';
  433.  
  434.     if ($text == '~*~*#' && (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) && ($reinsert_value == true) ) {
  435.       $field .= stripslashes($GLOBALS[$name]);
  436.     } elseif ($text != '~*~*#' && zen_not_null($text)) {
  437.       $field .= $text;
  438.     }
  439.  
  440.     $field .= '</textarea>';
  441.  
  442.     return $field;
  443.   }
  444.  
  445. /*
  446.  *  Output a form hidden field
  447.  */
  448.   function zen_draw_hidden_field($name, $value = '', $parameters = '') {
  449.     $field = '<input type="hidden" name="' . zen_sanitize_string(zen_output_string($name)) . '"';
  450.  
  451.     if (zen_not_null($value)) {
  452.       $field .= ' value="' . zen_output_string($value) . '"';
  453.     } elseif (isset($GLOBALS[$name]) && is_string($GLOBALS[$name])) {
  454.       $field .= ' value="' . zen_output_string(stripslashes($GLOBALS[$name])) . '"';
  455.     }
  456.  
  457.     if (zen_not_null($parameters)) $field .= ' ' . $parameters;
  458.  
  459.     $field .= ' />';
  460.  
  461.     return $field;
  462.   }
  463.  
  464. /*
  465.  * Output a form file-field
  466.  */
  467.   function zen_draw_file_field($name, $required = false) {
  468.     $field = zen_draw_input_field($name, '', ' size="50" ', 'file');
  469.  
  470.     return $field;
  471.   }
  472.  
  473.  
  474. /*
  475.  *  Hide form elements while including session id info
  476.  *  IMPORTANT: This should be used in every FORM that has an OnSubmit() function tied to it, to prevent unexpected logouts
  477.  */
  478.   function zen_hide_session_id() {
  479.     global $session_started;
  480.  
  481.     if ( ($session_started == true) && defined('SID') && zen_not_null(SID) ) {
  482.       return zen_draw_hidden_field(zen_session_name(), zen_session_id());
  483.     }
  484.   }
  485.  
  486. /*
  487.  *  Output a form pull down menu
  488.  *  Pulls values from a passed array, with the indicated option pre-selected
  489.  */
  490.   function zen_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
  491.     $field = '<select name="' . zen_output_string($name) . '"';
  492.  
  493.     if (zen_not_null($parameters)) $field .= ' ' . $parameters;
  494.  
  495.     $field .= '>' . "\n";
  496.  
  497.     if (empty($default) && isset($GLOBALS[$name]) && is_string($GLOBALS[$name]) ) $default = stripslashes($GLOBALS[$name]);
  498.  
  499.     for ($i=0, $n=sizeof($values); $i<$n; $i++) {
  500.       $field .= '  <option value="' . zen_output_string($values[$i]['id']) . '"';
  501.       if ($default == $values[$i]['id']) {
  502.         $field .= ' selected="selected"';
  503.       }
  504.  
  505.       $field .= '>' . zen_output_string($values[$i]['text'], array('"' => '&quot;', '\'' => '&#039;', '<' => '&lt;', '>' => '&gt;')) . '</option>' . "\n";
  506.     }
  507.     $field .= '</select>' . "\n";
  508.  
  509.     if ($required == true) $field .= TEXT_FIELD_REQUIRED;
  510.  
  511.     return $field;
  512.   }
  513.  
  514. /*
  515.  * Creates a pull-down list of countries
  516.  */
  517.   function zen_get_country_list($name, $selected = '', $parameters = '') {
  518.     $countriesAtTopOfList = array();
  519.     $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
  520.     $countries = zen_get_countries();
  521.  
  522.     // Set some default entries at top of list:
  523.     if (STORE_COUNTRY != SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY) $countriesAtTopOfList[] = SHOW_CREATE_ACCOUNT_DEFAULT_COUNTRY;
  524.     $countriesAtTopOfList[] = STORE_COUNTRY;
  525.     // IF YOU WANT TO ADD MORE DEFAULTS TO THE TOP OF THIS LIST, SIMPLY ENTER THEIR NUMBERS HERE.
  526.     // Duplicate more lines as needed
  527.     // Example: Canada is 108, so use 108 as shown:
  528.     //$countriesAtTopOfList[] = 108;
  529.  
  530.     //process array of top-of-list entries:
  531.     foreach ($countriesAtTopOfList as $key=>$val) {
  532.       $countries_array[] = array('id' => $val, 'text' => zen_get_country_name($val));
  533.     }
  534.     // now add anything not in the defaults list:
  535.     for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
  536.       $alreadyInList = FALSE;
  537.       foreach($countriesAtTopOfList as $key=>$val) {
  538.         if ($countries[$i]['countries_id'] == $val)
  539.         {
  540.           // If you don't want to exclude entries already at the top of the list, comment out this next line:
  541.           $alreadyInList = TRUE;
  542.           continue;
  543.         }
  544.       }
  545.       if (!$alreadyInList) $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);
  546.     }
  547.  
  548.     return zen_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
  549.   }
  550. /*
  551.  * Assesses suitability for additional parameters such as rel=nofollow etc
  552.  */
  553.   function zen_href_params($page = '', $parameters = '') {
  554.     global $current_page_base;
  555.     $addparms = '';
  556.     // if nofollow has already been set, ignore this function
  557.     if (stristr($parameters, 'nofollow')) return $parameters;
  558.     // if list of skippable pages has been set in meta_tags.php lang file (is by default), use that to add rel=nofollow params
  559.     if (defined('ROBOTS_PAGES_TO_SKIP') && in_array($page, explode(",", constant('ROBOTS_PAGES_TO_SKIP')))
  560.         || $current_page_base=='down_for_maintenance') $addparms = 'rel="nofollow"';
  561.     return ($parameters == '' ? $addparms : $parameters . ' ' . $addparms);
  562.   }
  563. ?>