html_output.php

来自「this the oscommerce 3.0 aplha 4」· PHP 代码 · 共 695 行 · 第 1/2 页

PHP
695
字号
<?php/*  $Id: html_output.php 1498 2007-03-29 14:04:50Z hpdl $  osCommerce, Open Source E-Commerce Solutions  http://www.oscommerce.com  Copyright (c) 2006 osCommerce  This program is free software; you can redistribute it and/or modify  it under the terms of the GNU General Public License v2 (1991)  as published by the Free Software Foundation.*//** * Generate an internal URL address for the catalog side * * @param string $page The page to link to * @param string $parameters The parameters to pass to the page (in the GET scope) * @param string $connection The connection type for the page (NONSSL, SSL, AUTO) * @param boolean $add_session_id Conditionally add the session ID to the URL * @param boolean $search_engine_friendly Convert the URL to be search engine friendly * @param boolean $use_full_address Add the full server address to the URL * @access public */  function osc_href_link($page = null, $parameters = null, $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true, $use_full_address = false) {    global $request_type, $osC_Session, $osC_Services;    if (!in_array($connection, array('NONSSL', 'SSL', 'AUTO'))) {      $connection = 'NONSSL';    }    if (!is_bool($add_session_id)) {      $add_session_id = true;    }    if (!is_bool($search_engine_safe)) {      $search_engine_safe = true;    }    if (!is_bool($use_full_address)) {      $use_full_address = false;    }    if (($search_engine_safe === true) && ($use_full_address === false) && isset($osC_Services) && $osC_Services->isStarted('sefu')) {      $use_full_address = true;    }    if ($connection == 'AUTO') {      if ( ($request_type == 'SSL') && (ENABLE_SSL === true) ) {        $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;      } else {        $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;      }    } elseif ( ($connection == 'SSL') && (ENABLE_SSL === true) ) {      if ($request_type == 'SSL') {        $link = ($use_full_address === false) ? '' : HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;      } else {        $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;      }    } else {      if ($request_type == 'NONSSL') {        $link = ($use_full_address === false) ? '' : HTTP_SERVER . DIR_WS_HTTP_CATALOG;      } else {        $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;      }    }    $link .= $page;    if (!empty($parameters)) {      $link .= '?' . osc_output_string($parameters);      $separator = '&';    } else {      $separator = '?';    }    while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) {      $link = substr($link, 0, -1);    }// Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined    if ( ($add_session_id === true) && $osC_Session->hasStarted() && (SERVICE_SESSION_FORCE_COOKIE_USAGE == '-1') ) {      if (!osc_empty(SID)) {        $_sid = SID;      } elseif ( (($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL === true)) || (($request_type == 'SSL') && ($connection != 'SSL')) ) {        if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {          $_sid = $osC_Session->getName() . '=' . $osC_Session->getID();        }      }    }    if (isset($_sid)) {      $link .= $separator . osc_output_string($_sid);    }    while (strstr($link, '&&')) {      $link = str_replace('&&', '&', $link);    }    if ( ($search_engine_safe === true) && isset($osC_Services) && $osC_Services->isStarted('sefu')) {        $link = str_replace(array('?', '&', '='), array('/', '/', ','), $link);    } else {      if (strpos($link, '&') !== false) {        $link = str_replace('&', '&amp;', $link);      }    }    return $link;  }/** * Links an object with a URL address * * @param string $link The URL address to link the object to * @param string $object The object to set the link on * @param string $parameters Additional parameters for the link * @access public */  function osc_link_object($link, $object, $parameters = null) {    return '<a href="' . $link . '"' . (!empty($parameters) ? ' ' . $parameters : '') . '>' . $object . '</a>';  }/** * Outputs an image * * @param string $image The image filename to display * @param string $title The title of the image button * @param int $width The width of the image * @param int $height The height of the image * @param string $parameters Additional parameters for the image * @access public */  function osc_image($image, $title = null, $width = 0, $height = 0, $parameters = null) {    if ( (empty($image) || ($image == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == '-1') ) {      return false;    }    if (!is_numeric($width)) {      $width = 0;    }    if (!is_numeric($height)) {      $height = 0;    }    $image = '<img src="' . osc_output_string($image) . '" border="0" alt="' . osc_output_string($title) . '"';    if (!empty($title)) {      $image .= ' title="' . osc_output_string($title) . '"';    }    if ($width > 0) {      $image .= ' width="' . (int)$width . '"';    }    if ($height > 0) {      $image .= ' height="' . (int)$height . '"';    }    if (!empty($parameters)) {      $image .= ' ' . $parameters;    }    $image .= ' />';    return $image;  }/** * Outputs an image submit button * * @param string $image The image filename to display * @param string $title The title of the image button * @param string $parameters Additional parameters for the image submit button * @access public */  function osc_draw_image_submit_button($image, $title = null, $parameters = null) {    global $osC_Language;    $image_submit = '<input type="image" src="' . osc_output_string('includes/languages/' . $osC_Language->getCode() . '/images/buttons/' . $image) . '"';    if (!empty($title)) {      $image_submit .= ' alt="' . osc_output_string($title) . '" title="' . osc_output_string($title) . '"';    }    if (!empty($parameters)) {      $image_submit .= ' ' . $parameters;    }    $image_submit .= ' />';    return $image_submit;  }/** * Outputs an image button * * @param string $image The image filename to display * @param string $title The title of the image button * @param string $parameters Additional parameters for the image button * @access public */  function osc_draw_image_button($image, $title = null, $parameters = null) {    global $osC_Language;    return osc_image('includes/languages/' . $osC_Language->getCode() . '/images/buttons/' . $image, $title, null, null, $parameters);  }/** * Outputs a form input field (text/password) * * @param string $name The name and ID of the input field * @param string $value The default value for the input field * @param string $parameters Additional parameters for the input field * @param boolean $override Override the default value with the value found in the GET or POST scope * @param string $type The type of input field to use (text/password/file) * @access public */  function osc_draw_input_field($name, $value = null, $parameters = null, $override = true, $type = 'text') {    if (!is_bool($override)) {      $override = true;    }    if ($override === true) {      if ( strpos($name, '[') !== false ) {        $name_string = substr($name, 0, strpos($name, '['));        $name_key = substr($name, strpos($name, '[') + 1, strlen($name) - (strpos($name, '[') + 2));        if ( isset($_GET[$name_string][$name_key]) ) {          $value = $_GET[$name_string][$name_key];        } elseif ( isset($_POST[$name_string][$name_key]) ) {          $value = $_POST[$name_string][$name_key];        }      } else {        if ( isset($_GET[$name]) ) {          $value = $_GET[$name];        } elseif ( isset($_POST[$name]) ) {          $value = $_POST[$name];        }      }    }    if (!in_array($type, array('text', 'password', 'file'))) {      $type = 'text';    }    $field = '<input type="' . osc_output_string($type) . '" name="' . osc_output_string($name) . '"';    if (strpos($parameters, 'id=') === false) {      $field .= ' id="' . osc_output_string($name) . '"';    }    if (trim($value) != '') {      $field .= ' value="' . osc_output_string($value) . '"';    }    if (!empty($parameters)) {      $field .= ' ' . $parameters;    }    $field .= ' />';    return $field;  }/** * Outputs a form password field * * @param string $name The name and ID of the password field * @param string $parameters Additional parameters for the password field * @access public */  function osc_draw_password_field($name, $parameters = null) {    return osc_draw_input_field($name, null, $parameters, false, 'password');  }/** * Outputs a form file upload field * * @param string $name The name and ID of the file upload field * @param boolean $show_max_size Show the maximum file upload size beside the field * @access public */  function osc_draw_file_field($name, $show_max_size = false) {    global $osC_Language;    static $upload_max_filesize;    if (!is_bool($show_max_size)) {      $show_max_size = false;    }    $field = osc_draw_input_field($name, null, null, false, 'file');    if ($show_max_size === true) {      if (!isset($upload_max_filesize)) {        $upload_max_filesize = @ini_get('upload_max_filesize');      }      if (!empty($upload_max_filesize)) {        $field .= '&nbsp;' . sprintf($osC_Language->get('maximum_file_upload_size'), osc_output_string($upload_max_filesize));      }    }    return $field;  }/** * Outputs a form selection field (checkbox/radio) * * @param string $name The name and indexed ID of the selection field * @param string $type The type of the selection field (checkbox/radio) * @param mixed $values The value of, or an array of values for, the selection field * @param string $default The default value for the selection field * @param string $parameters Additional parameters for the selection field * @param string $separator The separator to use between multiple options for the selection field * @access public */  function osc_draw_selection_field($name, $type, $values, $default = null, $parameters = null, $separator = '&nbsp;&nbsp;') {    if (!is_array($values)) {      $values = array($values);    }    if ( strpos($name, '[') !== false ) {      $name_string = substr($name, 0, strpos($name, '['));      if ( isset($_GET[$name_string]) ) {        $default = $_GET[$name_string];      } elseif ( isset($_POST[$name_string]) ) {        $default = $_POST[$name_string];      }    } else {      if ( isset($_GET[$name]) ) {        $default = $_GET[$name];      } elseif ( isset($_POST[$name]) ) {        $default = $_POST[$name];      }    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?