Ejemplo n.º 1
0
 /**
  * @param DataObjectInterface $dataObject
  */
 public function changeLineType(DataObjectInterface $dataObject)
 {
     $max = $dataObject->count();
     $changeNextLine = true;
     $firstLineCompiled = false;
     $htmlTable = '';
     for ($i = $this->lineNumber; $i < $max; $i++) {
         $currentLine = $dataObject->getLine($i);
         $htmlTable .= $this->createTableRow($currentLine);
         if ($firstLineCompiled === false) {
             $firstLineCompiled = true;
             $previousLineIndex = $i - 1;
             $previousLine = $dataObject->getLine($previousLineIndex);
             if ($previousLine === null) {
                 continue;
             }
             $htmlTable = $this->createTableRow($previousLine, true) . $htmlTable;
             $this->createSkipLine($dataObject, $previousLineIndex);
             unset($previousLineIndex);
         }
         $this->createSkipLine($dataObject, $i);
         /** @var BlockInterface $nextLineObject */
         $nextLineObject = $dataObject->getLine($i + 1);
         if (!$this->isTableLineType($nextLineObject)) {
             $changeNextLine = false;
         }
         if ($changeNextLine === false) {
             break;
         }
     }
     $htmlTable = $this->parseInlineMarkup($htmlTable);
     $listContent = $this->factory->create(BlockTypes::BLOCK_UNCHANGE)->setContent($this->getStartTableTag() . $htmlTable . $this->getEndTableTag())->setLineNumber($this->lineNumber);
     $dataObject->updateLine($this->lineNumber, $listContent);
 }
Ejemplo n.º 2
0
 /**
  * @param DataObjectInterface $dataObject
  * @param array $updatedLines
  */
 protected function parseSubBlock(DataObjectInterface $dataObject, array $updatedLines)
 {
     $newCodeParsed = $this->getSubBlockParsedContent($updatedLines);
     $this->setContent($newCodeParsed);
     $newContent = $this->factory->create(BlockTypes::BLOCK_UNCHANGE)->setContent($this->parse());
     $dataObject->updateLine($this->getLineNumber(), $newContent);
 }
 /**
  * @param DataObjectInterface $dataObject
  *
  * @return BlockInterface
  */
 public function changeLineType(DataObjectInterface $dataObject)
 {
     $previousLine = $this->lineNumber - 1;
     $previousLineObject = $dataObject->getLine($previousLine);
     $previousLineNewObject = new static($this->factory);
     $previousLineNewObject->setContent($previousLineObject->getContent());
     $previousLineNewObject->setLineNumber($previousLineObject->getLineNumber());
     $dataObject->updateLine($previousLine, $previousLineNewObject);
     $changedBlockObject = $this->changeObjectType(BlockTypes::BLOCK_EMPTY);
     $dataObject->updateLine($this->getLineNumber(), $changedBlockObject);
     return $changedBlockObject;
 }
Ejemplo n.º 4
0
 /**
  * @param DataObjectInterface $dataObject
  */
 public function changeLineType(DataObjectInterface $dataObject)
 {
     $max = $dataObject->count();
     $isStart = false;
     $blockContent = [];
     $codeClass = '';
     for ($i = $this->lineNumber; $i < $max; $i++) {
         $lineObject = $dataObject->getLine($i);
         $lineContent = $lineObject->getContent();
         if (strpos($lineContent, static::BLOCK_MARKUP) === 0 && $isStart === false) {
             $isStart = true;
             $codeClass = $this->getCodeType($lineContent);
             $newObject = $this->factory->create(BlockTypes::BLOCK_SKIP)->setContent('')->setLineNumber($i);
             $dataObject->updateLine($i, $newObject);
             continue;
         }
         if (strpos($lineContent, static::BLOCK_MARKUP) === false) {
             $blockContent[] = $this->encodeContent($lineContent);
         }
         if ($i >= $max - 1 || strpos($lineContent, static::BLOCK_MARKUP) === 0 && $isStart === true) {
             $newObject = $this->factory->create(BlockTypes::BLOCK_SKIP)->setContent('')->setLineNumber($i);
             $dataObject->updateLine($i, $newObject);
             break;
         }
         $newObject = $this->factory->create(BlockTypes::BLOCK_SKIP)->setContent('')->setLineNumber($i);
         $dataObject->updateLine($i, $newObject);
     }
     $lineContent = $this->getStartTag($codeClass) . implode('', $blockContent) . $this->getEndTag();
     $currectLineObject = $this->factory->create(BlockTypes::BLOCK_UNCHANGE)->setContent($lineContent)->setLineNumber($this->lineNumber);
     $dataObject->updateLine($this->lineNumber, $currectLineObject);
 }
Ejemplo n.º 5
0
 /**
  * @param DataObjectInterface $dataObject
  */
 public function changeLineType(DataObjectInterface $dataObject)
 {
     $max = $dataObject->count();
     $builder = $this->createBuilder();
     $lastItem = null;
     for ($i = $this->lineNumber; $i < $max; $i++) {
         $currentLineObject = $dataObject->getLine($i);
         if ($this->lineIsObjectOf($currentLineObject, BlockTypes::BLOCK_EMPTY, true)) {
             continue;
         }
         $changedContent = $this->factory->create(BlockTypes::BLOCK_SKIP);
         $dataObject->updateLine($i, $changedContent);
         /** @var BlockInterface $nextLineObject */
         $nextLineObject = $dataObject->getLine($i + 1);
         /* @var BlockInterface $nextLineObject */
         $secondLineObject = $dataObject->getLine($i + 2);
         if ($this->lineIsObjectOf($currentLineObject, BlockTypes::BLOCK_CONTINUE)) {
             $lastItem->appendContent($currentLineObject->getContent());
         } else {
             $lastItem = $builder->addItem($currentLineObject);
         }
         if (!$this->lineIsObjectOf($nextLineObject, static::class) && !$this->lineIsObjectOf($secondLineObject, static::class)) {
             break;
         }
     }
     unset($lastItem);
     $listHtmlContent = $this->parseInlineMarkup($builder->getTreeStructure()->parse());
     $listContent = $this->factory->create(BlockTypes::BLOCK_UNCHANGE)->setContent($listHtmlContent)->setLineNumber($this->lineNumber);
     $dataObject->updateLine($this->lineNumber, $listContent);
 }
Ejemplo n.º 6
0
 /**
  * @param DataObjectInterface $dataObject
  */
 public function changeLineType(DataObjectInterface $dataObject)
 {
     $blockContent = [];
     $max = $dataObject->count();
     for ($i = $this->lineNumber; $i < $max; $i++) {
         $lineObject = $dataObject->getLine($i);
         $lineContent = $lineObject->getContent();
         $blockContent[] = $this->encodeContent($lineContent);
         $this->createSkipLine($dataObject, $i);
         /** @var BlockInterface $nextLineObject */
         $nextLineObject = $dataObject->getLine($i + 1);
         /* @var BlockInterface $nextLineObject */
         $secondLineObject = $dataObject->getLine($i + 2);
         if (!$this->lineIsObjectOf($nextLineObject, BlockTypes::BLOCK_SPACES_CODE) && !$this->lineIsObjectOf($secondLineObject, BlockTypes::BLOCK_SPACES_CODE)) {
             break;
         }
     }
     $lineContent = $this->getStartTag() . implode('', $blockContent) . $this->getEndTag();
     $currectLineObject = $this->factory->create(BlockTypes::BLOCK_UNCHANGE)->setContent($lineContent)->setLineNumber($this->lineNumber);
     $dataObject->updateLine($this->lineNumber, $currectLineObject);
 }
Ejemplo n.º 7
0
 /**
  * @param DataObjectInterface $dataObject
  *
  * @return $this
  */
 public function changeLineType(DataObjectInterface $dataObject)
 {
     $nextLineNumber = $this->lineNumber + 1;
     if (!$dataObject->hasLine($nextLineNumber)) {
         return $this;
     }
     $max = $dataObject->count();
     $changeNextLine = true;
     $htmlCotent = [];
     for ($i = $this->lineNumber; $i < $max; $i++) {
         $currentLineObject = $dataObject->getLine($i);
         $htmlCotent[] = $currentLineObject->getContent();
         $nextLineObject = $dataObject->getLine($i + 1);
         if (!$this->lineIsObjectOf($nextLineObject, BlockTypes::BLOCK_PARAGRAPH)) {
             $changeNextLine = false;
         }
         $this->createSkipLine($dataObject, $i);
         if ($changeNextLine === false) {
             break;
         }
     }
     $newLineObject = $this->factory->create(BlockTypes::BLOCK_PARAGRAPH);
     $newLineObject->setContent(implode(' ', $htmlCotent))->setLineNumber($this->lineNumber);
     $dataObject->updateLine($this->lineNumber, $newLineObject);
     return $this;
 }
 /**
  * @param DataObjectInterface $dataObject
  *
  * @throws \Exception
  */
 public function changeLineType(DataObjectInterface $dataObject)
 {
     $max = $dataObject->count();
     $delimiterFound = 0;
     $blockContent = [];
     for ($i = $this->lineNumber; $i < $max; $i++) {
         $currentLine = $dataObject->getLine($i);
         $lineContent = $currentLine->getContent();
         $this->createSkipLine($dataObject, $i);
         if ($this->isBlockDelimiterLine($lineContent)) {
             $this->setContentBlockKeyByContent($lineContent);
             $delimiterFound++;
             continue;
         }
         if ($delimiterFound > 1) {
             break;
         }
         $blockContent[] = $lineContent;
     }
     $content = $this->getSubBlockParsedContent($blockContent);
     $dataObject->saveAvailableBlock($this->contentBlockKey, $content);
 }