Exemplo n.º 1
0
 public function separateChildren()
 {
     if (!($sSource = parent::source()) or !$this->count()) {
         return;
     }
     $arrNewChildren = array();
     $nIdx = $this->position();
     foreach ($this->iterator() as $aChild) {
         $nLen = $aChild->position() - $nIdx;
         if ($nLen) {
             $arrNewChildren[] = new Text($nIdx, $nIdx + $nLen - 1, $this->line(), substr($sSource, $nIdx - $this->position(), $nLen));
         }
         $arrNewChildren[] = $aChild;
         $nIdx = $aChild->endPosition() + 1;
         $this->remove($aChild);
     }
     if ($this->endPosition() >= $nIdx) {
         $arrNewChildren[] = new Text($nIdx, $this->endPosition(), $this->line(), substr($sSource, $nIdx - $this->position()));
     }
     foreach ($arrNewChildren as $aChild) {
         $this->add($aChild);
     }
     $this->setSource('');
 }