[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 3 /** 4 * Project: Smarty: the PHP compiling template engine 5 * File: Smarty_Compiler.class.php 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * 21 * @link http://smarty.php.net/ 22 * @author Monte Ohrt <monte at ohrt dot com> 23 * @author Andrei Zmievski <andrei@php.net> 24 * @version 2.6.10 25 * @copyright 2001-2005 New Digital Group, Inc. 26 * @package Smarty 27 */ 28 29 /* $Id: Smarty_Compiler.class.php 2312 2005-12-08 03:08:53Z wishy $ */ 30 31 /** 32 * Template compiling class 33 * @package Smarty 34 */ 35 36 include_once(dirname(__FILE__) . '/Smarty_Compiler.class.php'); 37 38 class CMS_Compiler extends Smarty_Compiler { 39 40 /** 41 * compile custom function tag 42 * 43 * @param string $tag_command 44 * @param string $tag_args 45 * @param string $tag_modifier 46 * @return string 47 */ 48 function _compile_custom_tag($tag_command, $tag_args, $tag_modifier, &$output) 49 { 50 $found = false; 51 $have_function = true; 52 53 /* 54 * First we check if the custom function has already been registered 55 * or loaded from a plugin file. 56 */ 57 if (isset($this->_plugins['function'][$tag_command])) { 58 $found = true; 59 $plugin_func = $this->_plugins['function'][$tag_command][0]; 60 if (!is_callable($plugin_func)) { 61 $message = "custom function '$tag_command' is not implemented"; 62 $have_function = false; 63 } 64 } 65 /* 66 * Otherwise we need to load plugin file and look for the function 67 * inside it. 68 */ 69 else if ($plugin_file = $this->_get_plugin_filepath('function', $tag_command)) { 70 $found = true; 71 72 include_once $plugin_file; 73 74 $plugin_func = 'smarty_cms_function_' . $tag_command; 75 if (!function_exists($plugin_func)) { 76 $message = "plugin function $plugin_func() not found in $plugin_file\n"; 77 $have_function = false; 78 } else { 79 $this->_plugins['function'][$tag_command] = array($plugin_func, null, null, null, true); 80 81 } 82 } 83 84 if (!$found) { 85 return parent::_compile_custom_tag($tag_command, $tag_args, $tag_modifier, $output); 86 } else if (!$have_function) { 87 #$this->_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__); 88 #return true; 89 return parent::_compile_custom_tag($tag_command, $tag_args, $tag_modifier, $output); 90 } 91 92 /* declare plugin to be loaded on display of the template that 93 we compile right now */ 94 $this->_add_plugin('function', $tag_command); 95 96 $this->_plugins['function'][$tag_command][4] = false; 97 $this->_plugins['function'][$tag_command][5] = array(); 98 99 $_cacheable_state = $this->_push_cacheable_state('function', $tag_command); 100 $attrs = $this->_parse_attrs($tag_args); 101 $arg_list = $this->_compile_arg_list('function', $tag_command, $attrs, $_cache_attrs=''); 102 103 $output = $this->_compile_plugin_call('function', $tag_command).'(array('.implode(',', $arg_list)."), \$this)"; 104 if($tag_modifier != '') { 105 $this->_parse_modifiers($output, $tag_modifier); 106 } 107 108 if($output != '') { 109 $output = '<?php ' . $_cacheable_state . $_cache_attrs . 'echo ' . $output . ';' 110 . $this->_pop_cacheable_state('function', $tag_command) . "?>" . $this->_additional_newline; 111 } 112 113 #var_dump($output); 114 115 return true; 116 } 117 118 /** 119 * display Smarty syntax error 120 * 121 * @param string $error_msg 122 * @param integer $error_type 123 * @param string $file 124 * @param integer $line 125 */ 126 function _syntax_error($error_msg, $error_type = E_USER_ERROR, $file=null, $line=null) 127 { 128 $this->_trigger_fatal_error("syntax error: $error_msg", $this->_current_file, $this->_current_line_no, $file, $line, $error_type); 129 } 130 131 function trigger_error($error_msg, $error_type = E_USER_WARNING) 132 { 133 var_dump("Smarty error: $error_msg"); 134 } 135 } 136 137 /* vim: set et: */ 138 139 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |