Changeset 11994

Show
Ignore:
Timestamp:
05/19/08 22:13:23 (6 months ago)
Author:
ha1t
Message:

smartyを2.6.19に

Location:
websites/events.php.gr.jp/trunk/lib/Smarty
Files:
15 modified

Legend:

Unmodified
Added
Removed
  • websites/events.php.gr.jp/trunk/lib/Smarty/Config_File.class.php

    r9806 r11994  
    1919 * 
    2020 * @link http://smarty.php.net/ 
    21  * @version 2.6.14 
     21 * @version 2.6.19 
    2222 * @copyright Copyright: 2001-2005 New Digital Group, Inc. 
    2323 * @author Andrei Zmievski <andrei@php.net> 
     
    2626 */ 
    2727 
    28 /* $Id: Config_File.class.php 129 2006-08-10 08:16:02Z halt $ */ 
     28/* $Id: Config_File.class.php 2702 2007-03-08 19:11:22Z mohrt $ */ 
    2929 
    3030/** 
  • websites/events.php.gr.jp/trunk/lib/Smarty/Smarty.class.php

    r9806 r11994  
    2828 * @author Andrei Zmievski <andrei@php.net> 
    2929 * @package Smarty 
    30  * @version 2.6.14 
     30 * @version 2.6.19 
    3131 */ 
    3232 
    33 /* $Id: Smarty.class.php 129 2006-08-10 08:16:02Z halt $ */ 
     33/* $Id: Smarty.class.php 2722 2007-06-18 14:29:00Z danilo $ */ 
    3434 
    3535/** 
     
    465465     * @var string 
    466466     */ 
    467     var $_version              = '2.6.14'; 
     467    var $_version              = '2.6.19'; 
    468468 
    469469    /** 
     
    839839     * to a template before compiling 
    840840     * 
    841      * @param string $function name of PHP function to register 
     841     * @param callback $function 
    842842     */ 
    843843    function register_prefilter($function) 
    844844    { 
    845     $_name = (is_array($function)) ? $function[1] : $function; 
    846         $this->_plugins['prefilter'][$_name] 
     845        $this->_plugins['prefilter'][$this->_get_filter_name($function)] 
    847846            = array($function, null, null, false); 
    848847    } 
     
    851850     * Unregisters a prefilter function 
    852851     * 
    853      * @param string $function name of PHP function 
     852     * @param callback $function 
    854853     */ 
    855854    function unregister_prefilter($function) 
    856855    { 
    857         unset($this->_plugins['prefilter'][$function]); 
     856        unset($this->_plugins['prefilter'][$this->_get_filter_name($function)]); 
    858857    } 
    859858 
     
    862861     * to a compiled template after compilation 
    863862     * 
    864      * @param string $function name of PHP function to register 
     863     * @param callback $function 
    865864     */ 
    866865    function register_postfilter($function) 
    867866    { 
    868     $_name = (is_array($function)) ? $function[1] : $function; 
    869         $this->_plugins['postfilter'][$_name] 
     867        $this->_plugins['postfilter'][$this->_get_filter_name($function)] 
    870868            = array($function, null, null, false); 
    871869    } 
     
    874872     * Unregisters a postfilter function 
    875873     * 
    876      * @param string $function name of PHP function 
     874     * @param callback $function 
    877875     */ 
    878876    function unregister_postfilter($function) 
    879877    { 
    880         unset($this->_plugins['postfilter'][$function]); 
     878        unset($this->_plugins['postfilter'][$this->_get_filter_name($function)]); 
    881879    } 
    882880 
     
    885883     * to a template output 
    886884     * 
    887      * @param string $function name of PHP function 
     885     * @param callback $function 
    888886     */ 
    889887    function register_outputfilter($function) 
    890888    { 
    891     $_name = (is_array($function)) ? $function[1] : $function; 
    892         $this->_plugins['outputfilter'][$_name] 
     889        $this->_plugins['outputfilter'][$this->_get_filter_name($function)] 
    893890            = array($function, null, null, false); 
    894891    } 
     
    897894     * Unregisters an outputfilter function 
    898895     * 
    899      * @param string $function name of PHP function 
     896     * @param callback $function 
    900897     */ 
    901898    function unregister_outputfilter($function) 
    902899    { 
    903         unset($this->_plugins['outputfilter'][$function]); 
     900        unset($this->_plugins['outputfilter'][$this->_get_filter_name($function)]); 
    904901    } 
    905902 
     
    19361933        return eval($code); 
    19371934    } 
     1935     
     1936    /** 
     1937     * Extracts the filter name from the given callback 
     1938     *  
     1939     * @param callback $function 
     1940     * @return string 
     1941     */ 
     1942        function _get_filter_name($function) 
     1943        { 
     1944                if (is_array($function)) { 
     1945                        $_class_name = (is_object($function[0]) ? 
     1946                                get_class($function[0]) : $function[0]); 
     1947                        return $_class_name . '_' . $function[1]; 
     1948                } 
     1949                else { 
     1950                        return $function; 
     1951                } 
     1952        } 
     1953     
    19381954    /**#@-*/ 
    19391955 
  • websites/events.php.gr.jp/trunk/lib/Smarty/Smarty_Compiler.class.php

    r9806 r11994  
    2222 * @author Monte Ohrt <monte at ohrt dot com> 
    2323 * @author Andrei Zmievski <andrei@php.net> 
    24  * @version 2.6.14 
     24 * @version 2.6.19 
    2525 * @copyright 2001-2005 New Digital Group, Inc. 
    2626 * @package Smarty 
    2727 */ 
    2828 
    29 /* $Id: Smarty_Compiler.class.php 129 2006-08-10 08:16:02Z halt $ */ 
     29/* $Id: Smarty_Compiler.class.php 2736 2007-09-16 14:47:53Z mohrt $ */ 
    3030 
    3131/** 
     
    241241        $rdq = preg_quote($this->right_delimiter, '~'); 
    242242 
    243         /* un-hide hidden xml open tags  */ 
    244         $source_content = preg_replace("~<({$ldq}(.*?){$rdq})[?]~s", '< \\1', $source_content); 
    245  
    246243        // run template source through prefilter functions 
    247244        if (count($this->_plugins['prefilter']) > 0) { 
     
    282279        for ($curr_tb = 0, $for_max = count($text_blocks); $curr_tb < $for_max; $curr_tb++) { 
    283280            /* match anything resembling php tags */ 
    284             if (preg_match_all('~(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?php[\"\']?)~is', $text_blocks[$curr_tb], $sp_match)) { 
     281            if (preg_match_all('~(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?\s*php\s*[\"\']?)~is', $text_blocks[$curr_tb], $sp_match)) { 
    285282                /* replace tags with placeholders to prevent recursive replacements */ 
    286283                $sp_match[1] = array_unique($sp_match[1]); 
     
    308305            } 
    309306        } 
    310  
     307         
    311308        /* Compile the template tags into PHP code. */ 
    312309        $compiled_tags = array(); 
     
    353350        } 
    354351        $compiled_content = ''; 
    355  
     352         
     353        $tag_guard = '%%%SMARTYOTG' . md5(uniqid(rand(), true)) . '%%%'; 
     354         
    356355        /* Interleave the compiled contents and text blocks to get the final result. */ 
    357356        for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) { 
     
    360359                $text_blocks[$i+1] = preg_replace('~^(\r\n|\r|\n)~', '', $text_blocks[$i+1]); 
    361360            } 
    362             $compiled_content .= $text_blocks[$i].$compiled_tags[$i]; 
    363         } 
    364         $compiled_content .= $text_blocks[$i]; 
    365  
     361            // replace legit PHP tags with placeholder 
     362            $text_blocks[$i] = str_replace('<?', $tag_guard, $text_blocks[$i]); 
     363            $compiled_tags[$i] = str_replace('<?', $tag_guard, $compiled_tags[$i]); 
     364             
     365            $compiled_content .= $text_blocks[$i] . $compiled_tags[$i]; 
     366        } 
     367        $compiled_content .= str_replace('<?', $tag_guard, $text_blocks[$i]); 
     368 
     369        // escape php tags created by interleaving 
     370        $compiled_content = str_replace('<?', "<?php echo '<?' ?>\n", $compiled_content); 
     371        $compiled_content = preg_replace("~(?<!')language\s*=\s*[\"\']?\s*php\s*[\"\']?~", "<?php echo 'language=php' ?>\n", $compiled_content); 
     372 
     373        // recover legit tags 
     374        $compiled_content = str_replace($tag_guard, '<?', $compiled_content);  
     375         
    366376        // remove \n from the end of the file, if any 
    367377        if (strlen($compiled_content) && (substr($compiled_content, -1) == "\n") ) { 
     
    372382            $compiled_content = "<?php \$this->_cache_serials['".$this->_cache_include."'] = '".$this->_cache_serial."'; ?>" . $compiled_content; 
    373383        } 
    374  
    375         // remove unnecessary close/open tags 
    376         $compiled_content = preg_replace('~\?>\n?<\?php~', '', $compiled_content); 
    377384 
    378385        // run compiled template through postfilter functions 
     
    863870            $args = implode(',', array_values($attrs)); 
    864871            if (empty($args)) { 
    865                 $args = 'null'; 
     872                $args = ''; 
    866873            } 
    867874        } 
     
    928935 
    929936        if (empty($name)) { 
    930             $this->_syntax_error("missing insert name", E_USER_ERROR, __FILE__, __LINE__); 
     937            return $this->_syntax_error("missing insert name", E_USER_ERROR, __FILE__, __LINE__); 
     938        } 
     939         
     940        if (!preg_match('~^\w+$~', $name)) { 
     941            return $this->_syntax_error("'insert: 'name' must be an insert function name", E_USER_ERROR, __FILE__, __LINE__); 
    931942        } 
    932943 
     
    11611172        $item = $this->_dequote($attrs['item']); 
    11621173        if (!preg_match('~^\w+$~', $item)) { 
    1163             return $this->_syntax_error("'foreach: item' must be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__); 
     1174            return $this->_syntax_error("foreach: 'item' must be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__); 
    11641175        } 
    11651176 
     
    12121223 
    12131224        if ($start) { 
    1214             if (isset($attrs['name'])) 
    1215                 $buffer = $attrs['name']; 
    1216             else 
    1217                 $buffer = "'default'"; 
    1218  
    1219             if (isset($attrs['assign'])) 
    1220                 $assign = $attrs['assign']; 
    1221             else 
    1222                 $assign = null; 
     1225            $buffer = isset($attrs['name']) ? $attrs['name'] : "'default'"; 
     1226            $assign = isset($attrs['assign']) ? $attrs['assign'] : null; 
     1227            $append = isset($attrs['append']) ? $attrs['append'] : null; 
     1228             
    12231229            $output = "<?php ob_start(); ?>"; 
    1224             $this->_capture_stack[] = array($buffer, $assign); 
     1230            $this->_capture_stack[] = array($buffer, $assign, $append); 
    12251231        } else { 
    1226             list($buffer, $assign) = array_pop($this->_capture_stack); 
     1232            list($buffer, $assign, $append) = array_pop($this->_capture_stack); 
    12271233            $output = "<?php \$this->_smarty_vars['capture'][$buffer] = ob_get_contents(); "; 
    12281234            if (isset($assign)) { 
    12291235                $output .= " \$this->assign($assign, ob_get_contents());"; 
     1236            } 
     1237            if (isset($append)) { 
     1238                $output .= " \$this->append($append, ob_get_contents());"; 
    12301239            } 
    12311240            $output .= "ob_end_clean(); ?>"; 
     
    16721681        if(preg_match_all('~(?:\`(?<!\\\\)\$' . $this->_dvar_guts_regexp . '(?:' . $this->_obj_ext_regexp . ')*\`)|(?:(?<!\\\\)\$\w+(\[[a-zA-Z0-9]+\])*)~', $var_expr, $_match)) { 
    16731682            $_match = $_match[0]; 
    1674             rsort($_match); 
    1675             reset($_match); 
     1683            $_replace = array(); 
    16761684            foreach($_match as $_var) { 
    1677                 $var_expr = str_replace ($_var, '".(' . $this->_parse_var(str_replace('`','',$_var)) . ')."', $var_expr); 
    1678             } 
     1685                $_replace[$_var] = '".(' . $this->_parse_var(str_replace('`','',$_var)) . ')."'; 
     1686            } 
     1687            $var_expr = strtr($var_expr, $_replace); 
    16791688            $_return = preg_replace('~\.""|(?<!\\\\)""\.~', '', $var_expr); 
    16801689        } else { 
     
    22202229            || 0<$this->_cacheable_state++) return ''; 
    22212230        if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid('Smarty')); 
    2222         $_ret = 'if ($this->caching && !$this->_cache_including) { echo \'{nocache:' 
     2231        $_ret = 'if ($this->caching && !$this->_cache_including): echo \'{nocache:' 
    22232232            . $this->_cache_serial . '#' . $this->_nocache_count 
    2224             . '}\'; };'; 
     2233            . '}\'; endif;'; 
    22252234        return $_ret; 
    22262235    } 
     
    22372246        if ($_cacheable 
    22382247            || --$this->_cacheable_state>0) return ''; 
    2239         return 'if ($this->caching && !$this->_cache_including) { echo \'{/nocache:' 
     2248        return 'if ($this->caching && !$this->_cache_including): echo \'{/nocache:' 
    22402249            . $this->_cache_serial . '#' . ($this->_nocache_count++) 
    2241             . '}\'; };'; 
     2250            . '}\'; endif;'; 
    22422251    } 
    22432252 
  • websites/events.php.gr.jp/trunk/lib/Smarty/internals/core.write_compiled_include.php

    r9806 r11994  
    1616function smarty_core_write_compiled_include($params, &$smarty) 
    1717{ 
    18     $_tag_start = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\'; \};'; 
    19     $_tag_end   = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\'; \};'; 
     18    $_tag_start = 'if \(\$this->caching && \!\$this->_cache_including\)\: echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\'; endif;'; 
     19    $_tag_end   = 'if \(\$this->caching && \!\$this->_cache_including\)\: echo \'\{/nocache\:(\\2)#(\\3)\}\'; endif;'; 
    2020 
    2121    preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us', 
    2222                   $params['compiled_content'], $_match_source, PREG_SET_ORDER); 
    23  
     23     
    2424    // no nocache-parts found: done 
    2525    if (count($_match_source)==0) return; 
  • websites/events.php.gr.jp/trunk/lib/Smarty/internals/core.write_file.php

    r9806 r11994  
    2424    } 
    2525 
    26     // write to tmp file, then rename it to avoid 
    27     // file locking race condition 
     26    // write to tmp file, then rename it to avoid file locking race condition 
    2827    $_tmp_file = tempnam($_dirname, 'wrt'); 
    2928 
     
    3938    fclose($fd); 
    4039 
    41     // Delete the file if it allready exists (this is needed on Win, 
    42     // because it cannot overwrite files with rename() 
    43     if (file_exists($params['filename'])) { 
     40    if (DIRECTORY_SEPARATOR == '\\' || !@rename($_tmp_file, $params['filename'])) { 
     41        // On platforms and filesystems that cannot overwrite with rename()  
     42        // delete the file before renaming it -- because windows always suffers 
     43        // this, it is short-circuited to avoid the initial rename() attempt 
    4444        @unlink($params['filename']); 
     45        @rename($_tmp_file, $params['filename']); 
    4546    } 
    46     @rename($_tmp_file, $params['filename']); 
    4747    @chmod($params['filename'], $smarty->_file_perms); 
    4848 
  • websites/events.php.gr.jp/trunk/lib/Smarty/plugins/compiler.assign.php

    r9806 r11994  
    1515 *       (Smarty online manual) 
    1616 * @author Monte Ohrt <monte at ohrt dot com> (initial author) 
    17  * @auther messju mohr <messju at lammfellpuschen dot de> (conversion to compiler function) 
     17 * @author messju mohr <messju at lammfellpuschen dot de> (conversion to compiler function) 
    1818 * @param string containing var-attribute and value-attribute 
    1919 * @param Smarty_Compiler 
  • websites/events.php.gr.jp/trunk/lib/Smarty/plugins/function.html_select_date.php

    r9806 r11994  
    2525 *           - 1.3.2 support negative timestamps, force year 
    2626 *             dropdown to include given date unless explicitly set (Monte) 
     27 *           - 1.3.4 fix behaviour of 0000-00-00 00:00:00 dates to match that 
     28 *             of 0000-00-00 dates (cybot, boots) 
    2729 * @link http://smarty.php.net/manual/en/language.function.html.select.date.php {html_select_date} 
    2830 *      (Smarty online manual) 
    29  * @version 1.3.2 
     31 * @version 1.3.4 
    3032 * @author Andrei Zmievski 
    3133 * @author Monte Ohrt <monte at ohrt dot com> 
     
    132134    } 
    133135 
    134     if(preg_match('!^-\d+$!',$time)) { 
     136    if (preg_match('!^-\d+$!', $time)) { 
    135137        // negative timestamp, use date() 
    136         $time = date('Y-m-d',$time); 
     138        $time = date('Y-m-d', $time); 
    137139    } 
    138140    // If $time is not in format yyyy-mm-dd 
    139     if (!preg_match('/^\d{0,4}-\d{0,2}-\d{0,2}$/', $time)) { 
     141    if (preg_match('/^(\d{0,4}-\d{0,2}-\d{0,2})/', $time, $found)) { 
     142        $time = $found[1]; 
     143    } else { 
    140144        // use smarty_make_timestamp to get an unix timestamp and 
    141145        // strftime to make yyyy-mm-dd 
     
    144148    // Now split this in pieces, which later can be used to set the select 
    145149    $time = explode("-", $time); 
    146      
     150 
    147151    // make syntax "+N" or "-N" work with start_year and end_year 
    148152    if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) { 
     
    160164        } 
    161165    } 
    162     if (strlen($time[0]) > 0) {  
     166    if (strlen($time[0]) > 0) { 
    163167        if ($start_year > $time[0] && !isset($params['start_year'])) { 
    164168            // force start year to include given date if not explicitly set 
     
    175179    $html_result = $month_result = $day_result = $year_result = ""; 
    176180 
     181    $field_separator_count = -1; 
    177182    if ($display_months) { 
     183        $field_separator_count++; 
    178184        $month_names = array(); 
    179185        $month_values = array(); 
     
    213219 
    214220    if ($display_days) { 
     221        $field_separator_count++; 
    215222        $days = array(); 
    216223        if (isset($day_empty)) { 
     
    248255 
    249256    if ($display_years) { 
     257        $field_separator_count++; 
    250258        if (null !== $field_array){ 
    251259            $year_name = $field_array . '[' . $prefix . 'Year]'; 
     
    311319        } 
    312320        // Add the field seperator 
    313         if($i != 2) { 
     321        if($i < $field_separator_count) { 
    314322            $html_result .= $field_separator; 
    315323        } 
  • websites/events.php.gr.jp/trunk/lib/Smarty/plugins/function.html_table.php

    r9806 r11994  
    1616 * Input:<br> 
    1717 *         - loop = array to loop through 
    18  *         - cols = number of columns 
     18 *         - cols = number of columns, comma separated list of column names 
     19 *                  or array of column names 
    1920 *         - rows = number of rows 
    2021 *         - table_attr = table attributes 
     22 *         - th_attr = table heading attributes (arrays are cycled) 
    2123 *         - tr_attr = table row attributes (arrays are cycled) 
    2224 *         - td_attr = table cell attributes (arrays are cycled) 
    2325 *         - trailpad = value to pad trailing cells with 
     26 *         - caption = text for caption element  
    2427 *         - vdir = vertical direction (default: "down", means top-to-bottom) 
    2528 *         - hdir = horizontal direction (default: "right", means left-to-right) 
     
    3235 * {table loop=$data} 
    3336 * {table loop=$data cols=4 tr_attr='"bgcolor=red"'} 
    34  * {table loop=$data cols=4 tr_attr=$colors} 
     37 * {table loop=$data cols="first,second,third" tr_attr=$colors} 
    3538 * </pre> 
    3639 * @author   Monte Ohrt <monte at ohrt dot com> 
    37  * @version  1.0 
     40 * @author credit to Messju Mohr <messju at lammfellpuschen dot de> 
     41 * @author credit to boots <boots dot smarty at yahoo dot com> 
     42 * @version  1.1 
    3843 * @link http://smarty.php.net/manual/en/language.function.html.table.php {html_table} 
    3944 *          (Smarty online manual) 
     
    4651    $table_attr = 'border="1"'; 
    4752    $tr_attr = ''; 
     53    $th_attr = ''; 
    4854    $td_attr = ''; 
    49     $cols = 3; 
     55    $cols = $cols_count = 3; 
    5056    $rows = 3; 
    5157    $trailpad = '&nbsp;'; 
     
    5359    $hdir = 'right'; 
    5460    $inner = 'cols'; 
     61    $caption = ''; 
    5562 
    5663    if (!isset($params['loop'])) { 
     
    6673 
    6774            case 'cols': 
     75                if (is_array($_value) && !empty($_value)) { 
     76                    $cols = $_value; 
     77                    $cols_count = count($_value); 
     78                } elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) { 
     79                    $cols = explode(',', $_value); 
     80                    $cols_count = count($cols); 
     81                } elseif (!empty($_value)) { 
     82                    $cols_count = (int)$_value; 
     83                } else { 
     84                    $cols_count = $cols; 
     85                } 
     86                break; 
     87 
    6888            case 'rows': 
    6989                $$_key = (int)$_value; 
     
    7595            case 'vdir': 
    7696            case 'inner': 
     97            case 'caption': 
    7798                $$_key = (string)$_value; 
    7899                break; 
     
    80101            case 'tr_attr': 
    81102            case 'td_attr': 
     103            case 'th_attr': 
    82104                $$_key = $_value; 
    83105                break; 
     
    88110    if (empty($params['rows'])) { 
    89111        /* no rows specified */