[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZTextInputParser class 4 // 5 // Created on: <17-Jul-2002 13:02:32 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 /*! 30 \class eZTextInputParser eztextinputparser.php 31 32 */ 33 34 define( "EZ_INPUT_CHUNK_TEXT", 1 ); 35 define( "EZ_INPUT_CHUNK_TAG", 2 ); 36 37 class eZTextInputParser 38 { 39 /*! 40 41 */ 42 function eZTextInputParser() 43 { 44 45 } 46 47 /*! 48 Will parse the input text and create an array of the input. 49 False will be returned if the parsing 50 */ 51 function &parseText( &$text ) 52 { 53 $returnArray = array(); 54 $pos = 0; 55 56 while ( $pos < strlen( $text ) ) 57 { 58 // find the next tag 59 $tagStart = strpos( $text, "<", $pos ); 60 61 if ( $tagStart !== false ) 62 { 63 if ( ( $tagStart - $pos ) >= 1 ) 64 { 65 $textChunk = substr( $text, $pos, $tagStart - $pos ); 66 $pos += $tagStart - $pos; 67 68 69 if ( strlen( trim( $textChunk ) ) != 0 ) 70 { 71 $returnArray[] = array( "Type" => EZ_INPUT_CHUNK_TEXT, 72 "Text" => $textChunk, 73 "TagName" => "#text" ); 74 75 eZDebug::writeNotice( $textChunk, "New text chunk in input" ); 76 } 77 } 78 // get the tag 79 $tagEnd = strpos( $text, ">", $pos ); 80 $tagChunk = substr( $text, $pos, $tagEnd - $pos + 1 ); 81 $tagName = preg_replace( "#^\<(.+)?(\s.*|\>)#m", "\\1", $tagChunk ); 82 83 // check for end tag 84 if ( $tagName[0] == "/" ) 85 { 86 print( "endtag" ); 87 } 88 89 $returnArray[] = array( "Type" => EZ_INPUT_CHUNK_TAG, 90 "TagName" => $tagName, 91 "Text" => $tagChunk, 92 ); 93 94 $pos += $tagEnd - $pos; 95 eZDebug::writeNotice( $tagChunk, "New tag chunk in input" ); 96 } 97 else 98 { 99 100 // just plain text in the rest 101 $textChunk = substr( $text, $pos, strlen( $text ) ); 102 eZDebug::writeNotice( $textChunk, "New text chunk in input" ); 103 104 if ( strlen( trim( $textChunk ) ) != 0 ) 105 { 106 $returnArray[] = array( "Type" => EZ_INPUT_CHUNK_TEXT, 107 "Text" => $textChunk, 108 "TagName" => "#text" ); 109 } 110 111 $pos = strlen( $text ); 112 } 113 114 115 // eZDebug::writeNotice( $pos, "Current pos" ); 116 117 $pos++; 118 } 119 return $returnArray; 120 } 121 122 /// Contains the tags found 123 var $TagStack = array(); 124 125 /// The tags that don't break the text 126 var $InlineTags = array( "emphasize", "strong" ); 127 128 /// The tags that break the paragraph 129 var $BreakTags = array(); 130 } 131 132 ?>
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 |