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

📄 tag.php

📁 FP2 CRM code+Mysql DB
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php/* vim: set expandtab tabstop=4 shiftwidth=4: */// +----------------------------------------------------------------------+// | PHP Version 4                                                        |// +----------------------------------------------------------------------+// | Copyright (c) 1997-2002 The PHP Group                                |// +----------------------------------------------------------------------+// | This source file is subject to version 2.02 of the PHP license,      |// | that is bundled with this package in the file LICENSE, and is        |// | available at through the world-wide-web at                           |// | http://www.php.net/license/2_02.txt.                                 |// | If you did not receive a copy of the PHP license and are unable to   |// | obtain it through the world-wide-web, please send a note to          |// | license@php.net so we can mail you a copy immediately.               |// +----------------------------------------------------------------------+// | Authors:  Alan Knowles <alan@akbkhome>                               |// +----------------------------------------------------------------------+//// $Id: Tag.php,v 1.23 2005/10/10 05:01:19 alan_k Exp $/* FC/BC compatibility with php5 */if ( (substr(phpversion(),0,1) < 5) && !function_exists('clone')) {    eval('function clone($t) { return $t; }');}/*** Compiler That deals with standard HTML Tag output.* Since it's pretty complex it has it's own class.* I guess this class should deal with the main namespace* and the parent (standard compiler can redirect other namespaces to other classes.** one instance of these exists for each namespace.*** @version    $Id: Tag.php,v 1.23 2005/10/10 05:01:19 alan_k Exp $*/class HTML_Template_Flexy_Compiler_Flexy_Tag {            /**    * Parent Compiler for     *    * @var  object  HTML_Template_Flexy_Compiler      *     * @access public    */    var $compiler;    /**    *       * Factory method to create Tag Handlers    *    * $type = namespace eg. <flexy:toJavascript loads Flexy.php    * the default is this... (eg. Tag)    *     *     * @param   string    Namespace handler for element.    * @param   object   HTML_Template_Flexy_Compiler      *     *    * @return    object    tag compiler    * @access   public    */        function &factory($type,&$compiler) {        if (!$type) {            $type = 'Tag';        }                $class = 'HTML_Template_Flexy_Compiler_Flexy_' . $type;        if (class_exists($class)) {            $ret = new $class;            $ret->compiler = &$compiler;            return $ret;            }                $filename = 'HTML/Template/Flexy/Compiler/Flexy/' . ucfirst(strtolower($type)) . '.php';        if (!HTML_Template_Flexy_Compiler_Flexy_Tag::fileExistsInPath($filename)) {            $ret = HTML_Template_Flexy_Compiler_Flexy_Tag::factory('Tag',$compiler);            return $ret;         }        // if we dont have a handler - just use the basic handler.        if (!file_exists(dirname(__FILE__) . '/'. ucfirst(strtolower($type)) . '.php')) {            $type = 'Tag';        }                    include_once 'HTML/Template/Flexy/Compiler/Flexy/' . ucfirst(strtolower($type)) . '.php';                $class = 'HTML_Template_Flexy_Compiler_Flexy_' . $type;        if (!class_exists($class)) {            $ret = false;            return $ret;        }        $ret = HTML_Template_Flexy_Compiler_Flexy_Tag::factory($type,$compiler);        return $ret;    }    /**    *       * Check that a file exists in the "include_path"    *    * @param   string    Filename    *    * @return    boolean  true if it is in there.    * @access   public    */    function fileExistsInPath($filename) {        if (isset($GLOBALS['_'.__CLASS__]['cache'][$filename])) {            return $GLOBALS['_'.__CLASS__]['cache'][$filename];        }        $bits = explode(PATH_SEPARATOR,ini_get('include_path'));        foreach($bits as $b) {            if (file_exists("$b/$filename")) {                return $GLOBALS['_'.__CLASS__]['cache'][$filename] = true;            }        }        return $GLOBALS['_'.__CLASS__]['cache'][$filename] = false;    }                        /**    * The current element to parse..    *    * @var object    * @access public    */        var $element;        /**    * Flag to indicate has attribute flexy:foreach (so you cant mix it with flexy:if!)    *    * @var boolean    * @access public    */        var $hasForeach = false;         /**    * toString - display tag, attributes, postfix and any code in attributes.    * Note first thing it does is call any parseTag Method that exists..    *    *     * @see parent::toString()    */    function toString($element)     {                global $_HTML_TEMPLATE_FLEXY_TOKEN;        global $_HTML_TEMPLATE_FLEXY;                 // store the element in a variable        $this->element = $element;       // echo "toString: Line {$this->element->line} &lt;{$this->element->tag}&gt;\n";                 // if the FLEXYSTARTCHILDREN flag was set, only do children        // normally set in BODY tag.        // this will probably be superseeded by the Class compiler.                 if (isset($element->ucAttributes['FLEXY:STARTCHILDREN'])) {                        return $element->compileChildren($this->compiler);        }        // look for flexy:ignore..        $flexyignore = $this->parseAttributeIgnore();                // rewriting should be done with a tag.../flag.                $this->reWriteURL("HREF");        $this->reWriteURL("SRC");                // handle elements        if (($ret =$this->_parseTags()) !== false) {            return $ret;        }        // these add to the close tag..                $ret  = $this->parseAttributeForeach();        $ret .= $this->parseAttributeIf();                // spit ou the tag and attributes.                if ($element->oTag{0} == '?') {            $ret .= '<?php echo "<"; ?>';        } else {             $ret .= "<";        }        $ret .= $element->oTag;        //echo '<PRE>'.print_r($element->attributes,true);        foreach ($element->attributes as $k=>$v) {            // if it's a flexy tag ignore it.                                    if (strtoupper($k) == 'FLEXY:RAW') {                if (!is_array($v) || !isset($v[1]) || !is_object($v[1])) {                    return HTML_Template_Flexy::raiseError(                        'flexy:raw only accepts a variable or method call as an argument, eg.'.                        ' flexy:raw="{somevalue}" you provided something else.' .                        " Error on Line {$this->element->line} &lt;{$this->element->tag}&gt;",                         null,   HTML_TEMPLATE_FLEXY_ERROR_DIE);                }                $add = $v[1]->compile($this->compiler);                if (is_a($add,'PEAR_Error')) {                    return $add;                }                $ret .= ' ' . $add;                continue;                        }                        if (strtoupper(substr($k,0,6)) == 'FLEXY:') {                continue;            }            // true == an attribute without a ="xxx"            if ($v === true) {                $ret .= " $k";                continue;            }                        // if it's a string just dump it.            if (is_string($v)) {                $v = str_replace(array('{_(',')_}'),array('',''),$v);                $ret .=  " {$k}={$v}";                continue;            }                        // normally the value is an array of string, however            // if it is an object - then it's a conditional key.            // eg.  if (something) echo ' SELECTED';            // the object is responsible for adding it's space..                        if (is_object($v)) {                $add = $v->compile($this->compiler);                if (is_a($add,'PEAR_Error')) {                    return $add;                }                            $ret .= $add;                continue;            }                        // otherwise its a key="sometext{andsomevars}"                        $ret .=  " {$k}=";                      foreach($v as $item) {                                if (is_string($item)) {                    // skip translation strings in tags.                    $item = str_replace(array('{_(',')_}'),array('',''),$item);                    $ret .= $item;                    continue;                }                $add = $item->compile($this->compiler);                if (is_a($add,'PEAR_Error')) {                    return $add;                }                $ret .= $add;            }        }        $ret .= ">";                // post stuff this is probably in the wrong place...                if ($element->postfix) {            foreach ($element->postfix as $e) {                $add = $e->compile($this->compiler);                if (is_a($add,'PEAR_Error')) {                    return $add;                }                $ret .= $add;            }        } else if ($this->element->postfix) { // if postfixed by self..            foreach ($this->element->postfix as $e) {                $add = $e->compile($this->compiler);                if (is_a($add,'PEAR_Error')) {                    return $add;                }                            $ret .= $add;            }        }        // dump contents of script raw - to prevent gettext additions..        //  print_r($element);        if ($element->tag == 'SCRIPT') {            foreach($element->children as $c) {                //print_R($c);                if (!$c) {                    continue;                }                if ($c->token == 'Text') {                    $ret .= $c->value;                    continue;                }                // techically we shouldnt have anything else inside of script tags.                // as the tokeinzer is supposted to ignore it..            }        } else {            $add = $element->compileChildren($this->compiler);            if (is_a($add,'PEAR_Error')) {                return $add;            }            $ret .= $add;        }                                // output the closing tag.                if ($element->close) {            $add = $element->close->compile($this->compiler);            if (is_a($add,'PEAR_Error')) {                return $add;            }            $ret .= $add;        }                // reset flexyignore                $_HTML_TEMPLATE_FLEXY_TOKEN['flexyIgnore'] = $flexyignore;                if (isset($_HTML_TEMPLATE_FLEXY['currentOptions']['output.block']) &&             ($_HTML_TEMPLATE_FLEXY['currentOptions']['output.block'] == $element->getAttribute('ID'))) {                           // echo $_HTML_TEMPLATE_FLEXY['compiledTemplate'];                        $fh = fopen($_HTML_TEMPLATE_FLEXY['compiledTemplate'],'w');            fwrite($fh,$ret);            fclose($fh);                      }                                    return $ret;    }    /**    * Reads an flexy:foreach attribute -     *    *    * @return   string to add to output.    * @access   public    */        function parseAttributeIgnore()     {            global $_HTML_TEMPLATE_FLEXY_TOKEN;                $flexyignore = $_HTML_TEMPLATE_FLEXY_TOKEN['flexyIgnore'];                if ($this->element->getAttribute('FLEXY:IGNORE') !== false) {            $_HTML_TEMPLATE_FLEXY_TOKEN['flexyIgnore'] = true;            $this->element->clearAttribute('FLEXY:IGNORE');        }        return $flexyignore;    }        /**    * Reads an flexy:foreach attribute -     *    *    * @return   string to add to output.    * @access   public    */        function parseAttributeForeach()     {        global  $_HTML_TEMPLATE_FLEXY;        $foreach = $this->element->getAttribute('FLEXY:FOREACH');        if ($foreach === false) {            return '';        }        //var_dump($foreach);                $this->element->hasForeach = true;        // create a foreach element to wrap this with.                $foreachObj =  $this->element->factory('Foreach',                explode(',',$foreach),                $this->element->line);        // failed = probably not enough variables..                            if ($foreachObj === false) {            

⌨️ 快捷键说明

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