Changeset 3087
- Timestamp:
- 08/09/08 17:12:42 (3 months ago)
- Files:
-
- trunk/project/modules/devel/webtools/tracwikicomponents/classes/traccomponentheader.class.php (modified) (2 diffs)
- trunk/project/modules/devel/webtools/tracwikicomponents/classes/traccomponentlink.class.php (modified) (1 diff)
- trunk/project/modules/devel/webtools/tracwikicomponents/classes/traccomponentparagraphe.class.php (modified) (2 diffs)
- trunk/project/modules/devel/webtools/tracwikicomponents/classes/traccomponentulli.class.php (modified) (2 diffs)
- trunk/project/modules/devel/webtools/wikirenderer/actiongroups/default.actiongroup.php (modified) (2 diffs)
- trunk/project/modules/devel/webtools/wikirenderer/classes/abstracttokenizercomponent.class.php (modified) (3 diffs)
- trunk/project/modules/devel/webtools/wikirenderer/classes/itokenizercomponent.class.php (modified) (2 diffs)
- trunk/project/modules/devel/webtools/wikirenderer/classes/renderer.class.php (modified) (1 diff)
- trunk/project/modules/devel/webtools/wikirenderer/classes/tokenizer.class.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/project/modules/devel/webtools/tracwikicomponents/classes/traccomponentheader.class.php
r2671 r3087 29 29 } 30 30 31 public function getStartTagsPos ($pString) {31 public function getStartTagsPosition ($pString) { 32 32 preg_match_all ('%(=+)\ %', $pString, $matches, PREG_OFFSET_CAPTURE); 33 33 $arPos = array (); … … 40 40 } 41 41 42 public function startWithEndTag ($pString, $pToken) {42 public function getEndingTag ($pString, $pToken) { 43 43 if ($pToken == null) { 44 44 return false; trunk/project/modules/devel/webtools/tracwikicomponents/classes/traccomponentlink.class.php
r2622 r3087 15 15 protected $_endTag = ']'; 16 16 protected $_mustBeParse = false; 17 17 18 public function render ($pText, $pToken) { 18 19 $data = explode (' ', $pText,2); trunk/project/modules/devel/webtools/tracwikicomponents/classes/traccomponentparagraphe.class.php
r2670 r3087 21 21 protected $_isContainerComponent = false; 22 22 23 public function getStartTagsPosition ($pString) { 24 return false; 25 } 23 26 24 public function startWithStartTag ($pString) {27 public function getStartingTag ($pString) { 25 28 $nl = chr(13).chr(10).chr(13).chr(10); 26 27 29 if (!strcmp (substr ($pString, 0, 4),$nl)) { 28 30 return $nl; … … 33 35 34 36 public function render ($pText, $pToken) { 35 return '</p> <p>';37 return '</p>-------------<p>'; 36 38 } 37 39 } trunk/project/modules/devel/webtools/tracwikicomponents/classes/traccomponentulli.class.php
r2679 r3087 29 29 } 30 30 31 public function getStartTagsPos ($pString) {31 public function getStartTagsPosition ($pString) { 32 32 preg_match_all ('%\ +\*%', $pString, $matches, PREG_OFFSET_CAPTURE); 33 33 $arPos = array (); … … 40 40 } 41 41 42 public function startWithEndTag ($pString, $pToken) {42 public function getEndingTag ($pString, $pToken) { 43 43 if (!strcmp(substr ($pString, 0, 2), chr(13).chr(10)) || substr ($pString, 0, 1) == "\n") { 44 44 $start = $pToken->getStartTag(); trunk/project/modules/devel/webtools/wikirenderer/actiongroups/default.actiongroup.php
r2650 r3087 29 29 $timer->start(); 30 30 $tokenizer = _class ('wikirenderer|tokenizer'); 31 $tokens = $tokenizer-> tokenize($text, $components);31 $tokens = $tokenizer->getTokens ($text, $components); 32 32 33 33 $tokenTime = $timer->stop(); … … 53 53 $timer->start(); 54 54 $tokenizer = _class ('wikirenderer|tokenizer'); 55 $tokens = $tokenizer-> tokenize ($text, $components);55 $tokens = $tokenizer->getTokens ($text, $components, false); 56 56 57 57 $tokenTime = $timer->stop(); trunk/project/modules/devel/webtools/wikirenderer/classes/abstracttokenizercomponent.class.php
r2668 r3087 31 31 } 32 32 33 public function getStartTagsPos ($pString) {33 public function getStartTagsPosition ($pString) { 34 34 if ($this->_startTag != null) { 35 35 $arPos = array (); … … 65 65 66 66 public function getLength () { 67 if ($this->_startTag != null) { 68 return $this->_startLen; 69 } 70 return null; 67 return $this->getStartTagLength(); 71 68 } 72 69 73 public function startWithStartTag ($pString) {70 public function getStartingTag ($pString) { 74 71 if (isset ($this->_lineTag) && $this->_lineTag) { 75 72 if (strcmp ($pString, $this->_startTag) > 1) { … … 85 82 } 86 83 87 public function startWithEndTag ($pString, $pToken) {84 public function getEndingTag ($pString, $pToken) { 88 85 return $this->startWithTag($pString, $this->_endTag); 89 86 } trunk/project/modules/devel/webtools/wikirenderer/classes/itokenizercomponent.class.php
r2625 r3087 44 44 * @return mixed false ou le tag ouvrant 45 45 */ 46 public function startWithStartTag ($pString);46 public function getStartingTag ($pString); 47 47 48 48 … … 53 53 * @return mixed false ou le tag fermant 54 54 */ 55 public function startWithEndTag ($pString, $pToken);55 public function getEndingTag ($pString, $pToken); 56 56 57 57 /** trunk/project/modules/devel/webtools/wikirenderer/classes/renderer.class.php
r2651 r3087 37 37 $timer = new CopixTimer (); 38 38 $components = ComponentParseHandler::getInstallComponents(); 39 $tokens = $tokenizer-> tokenize($pText, $components);39 $tokens = $tokenizer->getTokens ($pText, $components); 40 40 $this->_errors = $tokenizer->getErrors(); 41 41 return _ioClass('wikirenderer|tokenrenderer')->render($tokens, $pType); trunk/project/modules/devel/webtools/wikirenderer/classes/tokenizer.class.php
r2668 r3087 63 63 * @return Token l'arbre de token 64 64 */ 65 public function tokenize ($pString, $arComponents) {66 if (CopixCache::exists(array ($pString, $arComponents)) ) {65 public function getTokens ($pString, $arComponents, $pUseCache = true) { 66 if (CopixCache::exists(array ($pString, $arComponents)) && $pUseCache) { 67 67 if (CopixCache::exists(array ($pString, $arComponents, 'errors'))) { 68 68 $this->_errors = CopixCache::read(array ($pString, $arComponents, 'errors')); … … 79 79 $this->_arPos = array (); 80 80 81 //On crée un tableau qui contiendra les démarrages de composants si ils possédait un getStartTagsPosition 81 82 foreach ($this->_components as $component) { 82 if (($arPos = $component->getStartTagsPos ($this->_string)) !== false) {83 if (($arPos = $component->getStartTagsPosition ($this->_string)) !== false) { 83 84 foreach ($arPos as $pos=>$tag) { 84 85 if (!isset ($this->_arPos[$pos]) || strlen ($tag) > strlen ($this->_arPos[$pos]->tag)) { … … 108 109 //Fermeture de token ? 109 110 if ($this->_findEndTag()) { 110 //La recherche a mise a jour _ stringpour continuer le parsing111 //La recherche a mise a jour _position pour continuer le parsing 111 112 continue; 112 113 } … … 114 115 //Ouverture de token ? 115 116 if ($this->_findStartTag()) { 116 //La recherche a mise a jour _ stringpour continuer le parsing117 //La recherche a mise a jour _position pour continuer le parsing 117 118 continue; 118 119 } … … 124 125 //On mets la fin du buffer a la fin du noeud courant 125 126 $this->_bufferFlush(); 127 //Ecriture des caches 126 128 CopixCache::write (array ($pString, $arComponents), $document); 127 129 CopixCache::write (array ($pString, $arComponents, 'errors'), $this->_errors); … … 146 148 //*/ 147 149 while ($this->_position < $this->_length) { 148 if (($data = $this->_currentToken->getComponent()-> startWithEndTag (substr ($this->_string,$this->_position), $this->_currentToken)) !== false) {150 if (($data = $this->_currentToken->getComponent()->getEndingTag (substr ($this->_string,$this->_position), $this->_currentToken)) !== false) { 149 151 $this->_bufferFlush(); 150 152 $this->_currentToken->setEndTag ($data); … … 173 175 //Si c'est le bon tag on voit pour le fermer 174 176 if (($openTagParsing->getComponent() != null 175 && ($data = $openTagParsing->getComponent()-> startWithEndTag ($string, $openTagParsing)) !== false)) {177 && ($data = $openTagParsing->getComponent()->getEndingTag ($string, $openTagParsing)) !== false)) { 176 178 $this->_bufferFlush(); 177 179 … … 181 183 $name = get_class($openTagParsing->getComponent()); 182 184 $this->_currentToken = $openTagParsing->getParent (); 185 //On parcours les tags non fermé (en erreur) 183 186 foreach (array_reverse ($arTemp) as $tag) { 184 187 $childName = get_class($tag->getComponent()); … … 192 195 //Ce n'est pas le bon on test le précédent 193 196 } else { 197 //On stock les tags qui auraient du etre fermé 194 198 $arTemp [] = $openTagParsing; 195 199 $openTagParsing = $openTagParsing->getParent(); … … 201 205 202 206 207 private function _putStartTag ($pData, $pComponent) { 208 $this->_bufferFlush(); 209 $this->_position += $pComponent->getStartTagLength ($pData); 210 $this->_bPosition = $this->_position; 211 $start = TokenFactory::create ($this->_currentToken, $pComponent); 212 $start->setStartTag ($pData); 213 214 $this->_currentToken->addChild ($start); 215 216 if ($pComponent->isEscapeComponent ()) { 217 return $this->_tryToEscape ($start); 218 } 219 220 if (!$pComponent->isContainerComponent()) { 221 return true; 222 } 223 224 $this->_currentToken = $start; 225 if (!$pComponent->contentMustBeParse()) { 226 $this->_waitForCloseTag (); 227 return true; 228 } 229 return true; 230 } 231 203 232 /** 204 233 * Méthode qui cherche si la chaine courante commence par un tag d'ouverture … … 208 237 private function _findStartTag () { 209 238 //Boucle pour tester les ouvertures 239 //Si cette position est marqué comme une position de départ deja trouvé 210 240 if (isset ($this->_arPos[$this->_position])) { 211 241 $component = $this->_arPos[$this->_position]->component; 212 242 $data = $this->_arPos[$this->_position]->tag; 213 $this->_bufferFlush(); 214 $this->_position += $component->getStartTagLength ($data); 215 $this->_bPosition = $this->_position; 216 $start = TokenFactory::create ($this->_currentToken, $component); 217 $start->setStartTag ($data); 218 219 $this->_currentToken->addChild ($start); 220 221 if ($component->isEscapeComponent ()) { 222 return $this->_tryToEscape ($start); 223 } 224 225 if (!$component->isContainerComponent()) { 226 return true; 227 } 228 229 $this->_currentToken = $start; 230 if (!$component->contentMustBeParse()) { 231 $this->_waitForCloseTag (); 232 return true; 233 } 234 return true; 243 return $this->_putStartTag ($data, $component); 235 244 } 236 245 237 246 $string = substr ($this->_string, $this->_position); 238 247 foreach ($this->_componentsToParse as $component) { 239 if (($data = $component->startWithStartTag ($string)) != false) { 240 $this->_bufferFlush(); 241 $this->_position += $component->getStartTagLength ($data); 242 $this->_bPosition = $this->_position; 243 $start = TokenFactory::create ($this->_currentToken, $component); 244 $start->setStartTag ($data); 245 246 $this->_currentToken->addChild ($start); 247 248 if ($component->isEscapeComponent ()) { 249 return $this->_tryToEscape ($start); 250 } 251 252 if (!$component->isContainerComponent()) { 253 return true; 254 } 255 256 $this->_currentToken = $start; 257 if (!$component->contentMustBeParse()) { 258 $this->_waitForCloseTag (); 259 return true; 260 } 261 return true; 248 if (($data = $component->getStartingTag ($string)) != false) { 249 $this->_putStartTag ($data, $component); 250 return $this->_putStartTag ($data, $component); 262 251 } 263 252 } … … 279 268 $string = substr ($this->_string, $this->_position); 280 269 foreach ($this->_components as $componentToEscape) { 281 if (($data = $componentToEscape-> startWithStartTag ($string)) !== false) {270 if (($data = $componentToEscape->getStartingTag ($string)) !== false) { 282 271 $this->_currentToken->addChild (TokenFactory::create ($this->_currentToken, 'text', $data)); 283 272 $this->_position += $componentToEscape->getEndTagLength ($data); 284 273 return true; 285 } else if ($componentToEscape->isContainerComponent() && ($data = $componentToEscape-> startWithEndTag ($string, null)) !== false) {274 } else if ($componentToEscape->isContainerComponent() && ($data = $componentToEscape->getEndingTag ($string, null)) !== false) { 286 275 $this->_currentToken->addChild (TokenFactory::create ($this->_currentToken, 'text', $data)); 287 276 $this->_position += $componentToEscape->getEndTagLength ($data);
