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

📄 it.php

📁 FP2 CRM code+Mysql DB
💻 PHP
📖 第 1 页 / 共 3 页
字号:
    /**     * EXPERIMENTAL! FIXME!     */    var $lastTemplatefile = "";    /**     * $_options['preserve_data'] Whether to substitute variables and remove     * empty placeholders in data passed through setVariable     * (see also bugs #20199, #21951).     * $_options['use_preg'] Whether to use preg_replace instead of     * str_replace in parse()     * (this is a backwards compatibility feature, see also bugs #21951, #20392)     */    var $_options = array(        'preserve_data' => false,        'use_preg'      => true    );    /**     * Builds some complex regular expressions and optinally sets the     * file root directory.     *     * Make sure that you call this constructor if you derive your template     * class from this one.     *     * @param    string    File root directory, prefix for all filenames     *                     given to the object.     * @see      setRoot()     */    function HTML_Template_IT($root = "", $options=null) {        if(!is_null($options)){            $this->setOptions($options);        }        $this->variablesRegExp = "@" . $this->openingDelimiter .                                 "(" . $this->variablenameRegExp . ")" .                                 $this->closingDelimiter . "@sm";        $this->removeVariablesRegExp = "@" . $this->openingDelimiter .                                       "\s*(" . $this->variablenameRegExp .                                       ")\s*" . $this->closingDelimiter ."@sm";        $this->blockRegExp = '@<!--\s+BEGIN\s+(' . $this->blocknameRegExp .                             ')\s+-->(.*)<!--\s+END\s+\1\s+-->@sm';        $this->setRoot($root);    } // end constructor    /**     * Sets the option for the template class     *     * @access public     * @param  string  option name     * @param  mixed   option value     * @return mixed   IT_OK on success, error object on failure     */    function setOption($option, $value)    {        if (isset($this->_options[$option])) {            $this->_options[$option] = $value;            return IT_OK;        }        return PEAR::raiseError(                $this->errorMessage(IT_UNKNOWN_OPTION) . ": '{$option}'",                IT_UNKNOWN_OPTION            );    }    /**     * Sets the options for the template class     *     * @access public     * @param  string  options array of options     *                 default value:     *                   'preserve_data' => false,     *                   'use_preg'      => true     * @param  mixed   option value     * @return mixed   IT_OK on success, error object on failure     * @see $options     */    function setOptions($options)    {        foreach($options as $option=>$value){            if( PEAR::isError($error=$this->setOption($option, $value)) ){                return $error;            }        }    }    /**     * Print a certain block with all replacements done.     * @brother get()     */    function show($block = "__global__") {        print $this->get($block);    } // end func show    /**     * Returns a block with all replacements done.     *     * @param    string     name of the block     * @return   string     * @throws   PEAR_Error     * @access   public     * @see      show()     */    function get($block = "__global__") {        if ("__global__" == $block && !$this->flagGlobalParsed)            $this->parse("__global__");        if (!isset($this->blocklist[$block])) {            $this->err[] = PEAR::raiseError(                            $this->errorMessage( IT_BLOCK_NOT_FOUND ) .                            '"' . $block . "'",                            IT_BLOCK_NOT_FOUND                        );            return "";        }        if (!isset($this->blockdata[$block])) {            return '';        } else {            $ret = $this->blockdata[$block];            if ($this->clearCache) {                unset($this->blockdata[$block]);            }            if ($this->_options['preserve_data']) {                $ret = str_replace(                        $this->openingDelimiter .                        '%preserved%' . $this->closingDelimiter,                        $this->openingDelimiter,                        $ret                    );            }            return $ret;        }    } // end func get()    /**     * Parses the given block.     *     * @param    string    name of the block to be parsed     * @access   public     * @see      parseCurrentBlock()     * @throws   PEAR_Error     */    function parse($block = "__global__", $flag_recursion = false)    {        static $regs, $values;        if (!isset($this->blocklist[$block])) {            return PEAR::raiseError(                $this->errorMessage( IT_BLOCK_NOT_FOUND ) . '"' . $block . "'",                        IT_BLOCK_NOT_FOUND                );        }        if ("__global__" == $block) {            $this->flagGlobalParsed = true;        }        if (!$flag_recursion) {            $regs   = array();            $values = array();        }        $outer = $this->blocklist[$block];        $empty = true;        if ($this->clearCacheOnParse) {            foreach ($this->variableCache as $name => $value) {                $regs[] = $this->openingDelimiter .                          $name . $this->closingDelimiter;                $values[] = $value;                $empty = false;            }            $this->variableCache = array();        } else {            foreach ($this->blockvariables[$block] as $allowedvar => $v) {                if (isset($this->variableCache[$allowedvar])) {                   $regs[]   = $this->openingDelimiter .                               $allowedvar . $this->closingDelimiter;                   $values[] = $this->variableCache[$allowedvar];                   unset($this->variableCache[$allowedvar]);                   $empty = false;                }            }        }        if (isset($this->blockinner[$block])) {            foreach ($this->blockinner[$block] as $k => $innerblock) {                $this->parse($innerblock, true);                if ("" != $this->blockdata[$innerblock]) {                    $empty = false;                }                $placeholder = $this->openingDelimiter . "__" .                                $innerblock . "__" . $this->closingDelimiter;                $outer = str_replace(                                    $placeholder,                                    $this->blockdata[$innerblock], $outer                        );                $this->blockdata[$innerblock] = "";            }        }        if (!$flag_recursion && 0 != count($values)) {            if ($this->_options['use_preg']) {                $regs        = array_map(array(                                    &$this, '_addPregDelimiters'),                                    $regs                                );                $funcReplace = 'preg_replace';            } else {                $funcReplace = 'str_replace';            }            if ($this->_options['preserve_data']) {                $values = array_map(                            array(&$this, '_preserveOpeningDelimiter'), $values                        );            }            $outer = $funcReplace($regs, $values, $outer);            if ($this->removeUnknownVariables) {                $outer = preg_replace($this->removeVariablesRegExp, "", $outer);            }        }        if ($empty) {            if (!$this->removeEmptyBlocks) {                $this->blockdata[$block ].= $outer;            } else {                if (isset($this->touchedBlocks[$block])) {                    $this->blockdata[$block] .= $outer;                    unset($this->touchedBlocks[$block]);                }            }        } else {            $this->blockdata[$block] .= $outer;        }        return $empty;    } // end func parse    /**     * Parses the current block     * @see      parse(), setCurrentBlock(), $currentBlock     * @access   public     */    function parseCurrentBlock() {        return $this->parse($this->currentBlock);    } // end func parseCurrentBlock    /**     * Sets a variable value.     *     * The function can be used eighter like setVariable( "varname", "value")     * or with one array $variables["varname"] = "value"     * given setVariable($variables) quite like phplib templates set_var().     *     * @param    mixed     string with the variable name or an array     *                     %variables["varname"] = "value"     * @param    string    value of the variable or empty if $variable     *                     is an array.     * @param    string    prefix for variable names     * @access   public     */    function setVariable($variable, $value = "") {        if (is_array($variable)) {            $this->variableCache = array_merge(                                            $this->variableCache, $variable                                    );        } else {            $this->variableCache[$variable] = $value;        }    } // end func setVariable    /**     * Sets the name of the current block that is the block where variables     * are added.     *     * @param    string      name of the block     * @return   boolean     false on failure, otherwise true     * @throws   PEAR_Error     * @access   public     */    function setCurrentBlock($block = "__global__") {        if (!isset($this->blocklist[$block])) {            return PEAR::raiseError(                $this->errorMessage( IT_BLOCK_NOT_FOUND ) .                '"' . $block . "'", IT_BLOCK_NOT_FOUND            );        }        $this->currentBlock = $block;        return true;    } // end func setCurrentBlock    /**     * Preserves an empty block even if removeEmptyBlocks is true.     *     * @param    string      name of the block     * @return   boolean     false on false, otherwise true     * @throws   PEAR_Error     * @access   public     * @see      $removeEmptyBlocks     */    function touchBlock($block) {        if (!isset($this->blocklist[$block])) {            return PEAR::raiseError(                $this->errorMessage( IT_BLOCK_NOT_FOUND ) .                '"' . $block . "'", IT_BLOCK_NOT_FOUND  );        }

⌨️ 快捷键说明

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