예제 #1
0
 protected function _chunkHtmlHandling()
 {
     $iLastKey = ArrayHelper::lastKey($this->_aTagTexts['texts']);
     if ($this->_bIdentical) {
         return self::identical($this->_sEndExpression, $this->_aTagTexts['texts'][$iLastKey], $this->_oString->getEncoding());
     }
     return self::equals($this->_sEndExpression, $this->_aTagTexts['texts'][$iLastKey], $this->_oString->getEncoding());
 }
예제 #2
0
 protected function _process()
 {
     $this->_initializePositionAnalyzer();
     $sString = $this->_oString->get();
     // S'il y a des URLs
     if ($this->_aPositionStats['index']['matching_regex_elem']) {
         // On récupère leur position de début et de fin
         $aTagsToInsert = array();
         // Pour chacune d'elles
         foreach ($this->_aPositionStats['index']['matching_regex_elem'] as $aUrl) {
             $aUrlIndexes = array('tag_text_pos' => array('start' => $aUrl['tag_text_pos'][0], 'end' => $aUrl['tag_text_pos'][ArrayHelper::lastKey($aUrl['tag_text_pos'])]), 'regex_pos' => $aUrl['regex_pos']);
             // Si le tag précédent n'est pas une balise <a>
             if ($aUrlIndexes['tag_text_pos']['start'] === 0 || !$this->_alreadyLinked($aUrlIndexes['tag_text_pos']['start'])) {
                 // On ajoute la balise <a> dans le texte
                 $sUrl = $this->_aUrlPositions[$aUrlIndexes['regex_pos']]['element'];
                 $iStartPos = $this->_aUrlPositions[$aUrlIndexes['regex_pos']]['pos']['string'][0]['start'];
                 $iEndPos = $this->_aUrlPositions[$aUrlIndexes['regex_pos']]['pos']['string'][ArrayHelper::lastKey($this->_aUrlPositions[$aUrlIndexes['regex_pos']]['pos']['string'])]['end'];
                 $aTagsToInsert[$iStartPos] = $this->_buildLinkOpenTag($sUrl);
                 $aTagsToInsert[$iEndPos] = '</a>';
             }
         }
         $aSlices = array();
         $aBreakingPositions = array_keys($aTagsToInsert);
         $iNbBreakingPos = count($aBreakingPositions);
         for ($i = 0; $i < $iNbBreakingPos; $i++) {
             $aSlice = array_slice($aBreakingPositions, $i, 2);
             if (!isset($aSlice[1])) {
                 $aSlice[1] = mb_strlen($this->_oString->get(), $this->_oString->getEncoding());
             }
             $aSlices[] = $aSlice;
         }
         if ($aSlices) {
             // Si la première tranche ne commence pas au début de la chaîne
             if ($aSlices[0][0] !== 0) {
                 // On ajoute une tranche
                 array_unshift($aSlices, array(0, $aSlices[0][0]));
             }
             $aParts = array();
             foreach ($aSlices as $aSlice) {
                 $sSlice = mb_substr($this->_oString->get(), $aSlice[0], $aSlice[1] - $aSlice[0], $this->_oString->getEncoding());
                 // FAIRE MODIF ICI !!!! NE PAS FAIRE DE TEST STRIP_TAGS
                 if ($this->_oRegex->test(strip_tags($sSlice))) {
                     $sSlice = array_shift($aTagsToInsert) . $sSlice . array_shift($aTagsToInsert);
                 }
                 $aParts[] = $sSlice;
             }
             $sString = implode('', $aParts);
         }
     }
     return $this->_oString->setString($sString);
 }
예제 #3
0
 protected function _htmlHandling()
 {
     $aTagTexts = $this->_splitTagText($this->_oString->get(), true, true);
     if ($aTagTexts['texts']) {
         $iLastKey = ArrayHelper::lastKey($aTagTexts['texts']);
         if ($this->_sCharList !== null) {
             $aTagTexts['texts'][$iLastKey] = rtrim($aTagTexts['texts'][$iLastKey], $this->_sCharList);
         } else {
             $aTagTexts['texts'][$iLastKey] = rtrim($aTagTexts['texts'][$iLastKey]);
         }
         $this->_oString->setString(implode('', self::_coordinatingMerge($aTagTexts['tags'], $aTagTexts['texts'])));
     }
     return $this->_oString;
 }
예제 #4
0
 protected function _chunkHtmlHandling()
 {
     if ($this->_aTagTexts['texts']) {
         $iLastKey = ArrayHelper::lastKey($this->_aTagTexts['texts']);
         if (mb_strrpos($this->_aTagTexts['texts'][$iLastKey], $this->_mEndValue, -1, $this->_oString->getEncoding()) !== mb_strlen($this->_aTagTexts['texts'][$iLastKey], $this->_oString->getEncoding()) - mb_strlen($this->_mEndValue, $this->_oString->getEncoding())) {
             self::_appendInLastElement($this->_aTagTexts['texts'], $this->_mEndValue);
         }
     } else {
         if ($this->_aTagTexts['tags']) {
             self::_appendInLastElement($this->_aTagTexts['tags'], $this->_mEndValue);
         } else {
             return $this->_oString->setString($this->_mEndValue);
         }
     }
     return $this->_oString->setString(self::_getMergedTagTexts(true));
 }