⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 savant.php

📁 FP2 CRM code+Mysql DB
💻 PHP
📖 第 1 页 / 共 2 页
字号:
            $alt = basename($src);        }                $alt = ' alt="' . htmlentities($alt) . '"';                        // build the border tag        $border = ' border="' . htmlentities($border) . '"';                // get the width and height of the image        if (is_null($width) && is_null($height)) {                    if (substr(strtolower($src), 0, 7) == 'http://' ||                substr(strtolower($src), 0, 8) == 'https://') {                                // the image is not on the local filesystem                $root = '';                        } else {                            // we need to set a base root path so we can find images on the                // local file system                $root = isset($GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT'])                    ? $GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT'] . '/'                    : '';            }                        $info = @getimagesize($root . $src);                        $width = (is_null($width)) ? $info[0] : $width;            $height = (is_null($height)) ? $info[1] : $height;                        unset($info);        }                // build the width tag        if ($width > 0) {            $size .= ' width="' . htmlentities($width) . '"';        }                // build the height tag        if ($height > 0) {            $size .= ' height="' . htmlentities($height) . '"';        }                // done!        return '<img src="' . $src . '"' .            $alt .            $border .            $size .            ' />';    }         /**    *     * Output a single <input> element.    *      * @license http://www.gnu.org/copyleft/lesser.html LGPL    *     * @author Paul M. Jones <pmjones@ciaweb.net>    *     * @package Savant    *     * @version $Id: Savant.php,v 1.7 2005/05/14 03:39:11 alan_k Exp $    *     * @access public    *     * @param string $type The HTML "type=" value (e.g., 'text',    * 'hidden', 'password').    *     * @param string $name The HTML "name=" value.    *     * @param mixed $value The initial value of the input element.    *     * @param string $extra Any "extra" HTML code to place within the    * checkbox element.    *     * @return string    *     */        function input($type, $name, $value = '', $extra = '')    {        $output = "<input type=\"$type\" name=\"$name\" ";        $output .= "value=\"$value\" $extra />";        return $output;    }         /**    *     * Output a <script></script> link to a JavaScript file.    *     *     * @license http://www.gnu.org/copyleft/lesser.html LGPL    *     * @author Paul M. Jones <pmjones@ciaweb.net>    *     * @package Savant    *     * @version $Id: Savant.php,v 1.7 2005/05/14 03:39:11 alan_k Exp $    *     * @access public    *     * @param string $href The HREF leading to the JavaScript source    * file.    *     * @return string    *     */    function javascript($href)    {        return '<script language="javascript" type="text/javascript" src="' .            $href . '"></script>';    }     /**    *     * Output a value using echo after processing with optional modifier    * functions.    *     * Allows you to pass a space-separated list of value-manipulation    * functions so that the value is "massaged" before output. For    * example, if you want to strip slashes, force to lower case, and    * convert to HTML entities (as for an input text box), you might do    * this:    *     * $this->modify($value, 'stripslashes strtolower htmlentities');    *     * @license http://www.gnu.org/copyleft/lesser.html LGPL    *     * @author Paul M. Jones <pmjones@ciaweb.net>    *     * @package Savant    *     * @version $Id: Savant.php,v 1.7 2005/05/14 03:39:11 alan_k Exp $    *     * @access public    *     * @param string $value The value to be printed.    *     * @param string $functions A space-separated list of    * single-parameter functions to be applied to the $value before    * printing.    *     * @return string    *     */     function modify($value, $functions = null)    {        // is there a space-delimited function list?        if (is_string($functions)) {                        // yes.  split into an array of the            // functions to be called.            $list = explode(' ', $functions);                        // loop through the function list and            // apply to the output in sequence.            foreach ($list as $func) {                if (!function_exists($func)) {                    continue;                }                // extend this..                if (!in_array($func, array('htmlspecialchars','nl2br','urlencode'))) {                    continue;                }                $value = $func($value);                            }        }                return $value;    }             /**    *     * Output a series of HTML <option>s based on an associative array    * where the key is the option value and the value is the option    * label. You can pass a "selected" value as well to tell the    * function which option value(s) should be marked as seleted.    *     *     * @author Paul M. Jones <pmjones@ciaweb.net>    *     * @package Savant    *     * @version $Id: Savant.php,v 1.7 2005/05/14 03:39:11 alan_k Exp $    *     * @access public    *     * @param array $options An associative array of key-value pairs; the    * key is the option value, the value is the option lable.    *     * @param mixed $selected A string or array that matches one or more    * option values, to tell the function what options should be marked    * as selected.  Defaults to an empty array.    *     * @return string    *     */    function options( $options, $selected = array(), $extra = null)    {        $html = '';                // force $selected to be an array.  this allows multi-selects to        // have multiple selected options.        settype($selected, 'array');                // is $options an array?        if (is_array($options)) {                        // loop through the options array            foreach ($options as $value => $label) {                                $html .= '<option value="' . $value . '"';                $html .= ' label="' . $label . '"';                                if (in_array($value, $selected)) {                    $html .= ' selected="selected"';                }                                if (! is_null($extra)) {                    $html .= ' ' . $extra;                }                                $html .= ">$label</option>\n";            }        }                return $html;    }     /**    *     * Output a set of radio <input>s with the same name.    *     *     * @author Paul M. Jones <pmjones@ciaweb.net>    *     * @package Savant    *     * @version $Id: Savant.php,v 1.7 2005/05/14 03:39:11 alan_k Exp $    *     * @access public    *     * @param string $name The HTML "name=" value of all the radio <input>s.    *     * @param array $options An array of key-value pairs where the key is the    * radio button value and the value is the radio button label.    *     * $options = array (    * 	0 => 'zero',    *	1 => 'one',    *	2 => 'two'    * );    *     * @param string $checked A comparison string; if any of the $option    * element values and $checked are the same, that radio button will    * be marked as "checked" (otherwise not).    *     * @param string $extra Any "extra" HTML code to place within the    * <input /> element.    *     * @param string $sep The HTML text to place between every radio    * button in the set.    *     * @return string    *     */     function radios(        $name,        $options,        $checked = null,        $set_unchecked = null,        $sep = "<br />\n",        $extra = null)    {        $html = '';                if (is_array($options)) {                        if (! is_null($set_unchecked)) {                // this sets the unchecked value of the                // radio button set.                $html .= "<input type=\"hidden\" ";                $html .= "name=\"$name\" ";                $html .= "value=\"$set_unchecked\" />\n";            }                        foreach ($options as $value => $label) {                $html .= "<input type=\"radio\" ";                $html .= "name=\"$name\" ";                $html .= "value=\"$value\"";                                if ($value == $checked) {                    $html .= " checked=\"checked\"";                }                $html .= " $extra />$label$sep";            }        }                return $html;    }         /**    *     * Output a <link ... /> to a CSS stylesheet.    *     *     * @author Paul M. Jones <pmjones@ciaweb.net>    *     * @package Savant    *     * @version $Id: Savant.php,v 1.7 2005/05/14 03:39:11 alan_k Exp $    *     * @access public    *     * @param string $href The HREF leading to the stylesheet file.    *     * @return string    *     */     function stylesheet($href)    {        return '<link rel="stylesheet" type="text/css" href="' .            $href . '" />';    }                  /**    *     * Output a single <textarea> element.    *     * @license http://www.gnu.org/copyleft/lesser.html LGPL    *     * @author Paul M. Jones <pmjones@ciaweb.net>    *     * @package Savant    *     * @version $Id: Savant.php,v 1.7 2005/05/14 03:39:11 alan_k Exp $    *     * @access public    *     * @param string $name The HTML "name=" value.    *     * @param string $text The initial value of the textarea element.    *     * @param int $tall How many rows tall should the area be?    *     * @param mixed $wide The many columns wide should the area be?    *     * @param string $extra Any "extra" HTML code to place within the    * checkbox element.    *     * @return string    *     */        function textarea($name, $text, $tall = 24, $wide = 80, $extra = '')    {        $output = "<textarea name=\"$name\" rows=\"$tall\" ";        $output .= "cols=\"$wide\" $extra>$text</textarea>";        return $output;    }}

⌨️ 快捷键说明

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