| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZSimpleTagsOperator class 4 // 5 // Created on: <07-Feb-2003 09:39:55 bf> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 class eZSimpleTagsOperator 30 { 31 /*! 32 */ 33 function eZSimpleTagsOperator( $name = 'simpletags' ) 34 { 35 $this->Operators = array( $name ); 36 } 37 38 /*! 39 Returns the operators in this class. 40 */ 41 function &operatorList() 42 { 43 return $this->Operators; 44 } 45 46 /*! 47 See eZTemplateOperator::namedParameterList() 48 */ 49 function namedParameterList() 50 { 51 return array( 'listname' => array( 'type' => 'string', 52 'required' => false, 53 'default' => false ) ); 54 } 55 56 /*! 57 \private 58 59 Makes sure extra includes are loaded (include_once) so extra functions can be used. 60 \note This function will only run one time, if called multiple times it will simple return 61 */ 62 function initializeIncludes() 63 { 64 $init =& $GLOBALS['eZSimpleTagsInit']; 65 // If we have this global variable we shouldn't do any processing 66 if ( isset( $init ) and $init ) 67 return; 68 69 $init = true; 70 $ini =& eZINI::instance( 'template.ini' ); 71 $extensions = $ini->variable( 'SimpleTagsOperator', 'Extensions' ); 72 include_once ( 'lib/ezutils/classes/ezextension.php' ); 73 $pathList = eZExtension::expandedPathList( $extensions, 'simpletags' ); 74 $includeList = $ini->variable( 'SimpleTagsOperator', 'IncludeList' ); 75 76 foreach ( $includeList as $includeFile ) 77 { 78 foreach ( $pathList as $path ) 79 { 80 $file = $path . '/' . $includeFile; 81 if ( file_exists( $file ) ) 82 { 83 include_once( $file ); 84 } 85 } 86 } 87 } 88 89 /*! 90 \reimp 91 */ 92 function modify( &$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters ) 93 { 94 $elements = preg_split( "#(</?[a-zA-Z0-9_-]+>)#", 95 $operatorValue, 96 false, 97 PREG_SPLIT_DELIM_CAPTURE ); 98 $newElements = array(); 99 $i = 0; 100 foreach ( $elements as $element ) 101 { 102 if ( ( $i % 2 ) == 1 ) 103 { 104 $tagText = $element; 105 if ( preg_match( "#<(/?)([a-zA-Z0-9_-]+)>#", $tagText, $matches ) ) 106 { 107 $isEndTag = false; 108 if ( $matches[1] ) 109 $isEndTag = true; 110 $tag = $matches[2]; 111 $element = array( $tag, $isEndTag, $tagText ); 112 } 113 } 114 $newElements[] = $element; 115 ++$i; 116 } 117 118 $tagListName = 'TagList'; 119 if ( $namedParameters['listname'] ) 120 $tagListName .= '_' . $namedParameters['listname']; 121 122 $this->initializeIncludes(); 123 124 $tagMap = array(); 125 $ini =& eZINI::instance( 'template.ini' ); 126 $tagList = $ini->variable( 'SimpleTagsOperator', $tagListName ); 127 foreach ( $tagList as $tag => $tagItem ) 128 { 129 $elements = explode( ';', $tagItem ); 130 $pre = $elements[0]; 131 $post = $elements[1]; 132 $phpFunctions = array(); 133 if ( isset( $elements[2] ) ) 134 { 135 $phpFunctionList = explode( ',', $elements[2] ); 136 $phpFunctions = array(); 137 foreach ( $phpFunctionList as $phpFunction ) 138 { 139 if ( function_exists( $phpFunction ) ) 140 $phpFunctions[] = $phpFunction; 141 } 142 } 143 $tagMap[$tag] = array( 'pre' => $pre, 144 'post' => $post, 145 'phpfunctions' => $phpFunctions ); 146 } 147 148 $textPHPFunctions = array( 'htmlspecialchars' ); 149 $textPre = false; 150 $textPost = false; 151 if ( isset( $tagMap['text']['pre'] ) ) 152 $textPre = $tagMap['text']['pre']; 153 if ( isset( $tagMap['text']['post'] ) ) 154 $textPost = $tagMap['text']['post']; 155 if ( isset( $tagMap['text']['phpfunctions'] ) ) 156 $textPHPFunctions = $tagMap['text']['phpfunctions']; 157 $textElements = array(); 158 for ( $i = 0; $i < count( $newElements ); ++$i ) 159 { 160 $element = $newElements[$i]; 161 if ( is_string( $element ) ) 162 { 163 $text = $element; 164 foreach ( $textPHPFunctions as $textPHPFunction ) 165 { 166 $text = $textPHPFunction( $text ); 167 } 168 $textElements[] = $textPre . $text . $textPost; 169 } 170 else if ( is_array( $element ) ) 171 { 172 $tag = $element[0]; 173 $isEndTag = $element[1]; 174 $originalText = $element[2]; 175 if ( isset( $tagMap[$tag] ) ) 176 { 177 $tagOptions = $tagMap[$tag]; 178 $phpFunctions = $tagOptions['phpfunctions']; 179 if ( !$isEndTag ) 180 { 181 $tagElements = array(); 182 for ( $j = $i + 1; $j < count( $newElements ); ++$j ) 183 { 184 $tagElement = $newElements[$j]; 185 if ( is_string( $tagElement ) ) 186 { 187 $tagElements[] = $tagElement; 188 } 189 else if ( is_array( $tagElement ) ) 190 { 191 if ( $tagElement[0] == $tag and 192 $tagElement[1] ) 193 { 194 break; 195 } 196 $text = $tagElement[2]; 197 $tagElements[] = $text; 198 } 199 } 200 $i = $j; 201 $textElements[] = $tagOptions['pre']; 202 $text = implode( '', $tagElements ); 203 foreach ( $phpFunctions as $phpFunction ) 204 { 205 $text = $phpFunction( $text ); 206 } 207 $textElements[] = $text; 208 $textElements[] = $tagOptions['post']; 209 } 210 } 211 else 212 { 213 $text = $originalText; 214 foreach ( $textPHPFunctions as $textPHPFunction ) 215 { 216 $text = $textPHPFunction( $text ); 217 } 218 $textElements[] = $textPre . $text . $textPost; 219 } 220 } 221 } 222 223 $operatorValue = implode( '', $textElements ); 224 } 225 226 /// \privatesection 227 var $Operators; 228 }; 229 230 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |