コード例 #1
0
ファイル: blockquote.php プロジェクト: axelmdev/ecommerce
 /**
  * Handle a node
  *
  * Handle / transform a given node, and return the result of the
  * conversion.
  *
  * @param ezcDocumentElementVisitorConverter $converter
  * @param DOMElement $node
  * @param mixed $root
  * @return mixed
  */
 public function handle(ezcDocumentElementVisitorConverter $converter, DOMElement $node, $root)
 {
     // Locate optional attribution elements, and transform them below the
     // recursive quote visiting.
     $xpath = new DOMXPath($node->ownerDocument);
     $attributionNodes = $xpath->query('*[local-name() = "attribution"]', $node);
     $attributions = array();
     foreach ($attributionNodes as $attribution) {
         $attributions[] = $attribution->cloneNode(true);
         $attribution->parentNode->removeChild($attribution);
     }
     // Recursively decorate blockquote, after all attribution nodes are
     // removed
     ezcDocumentDocbookToRstConverter::$indentation += 4;
     $root = $converter->visitChildren($node, $root);
     // Append attribution nodes, if any
     foreach ($attributions as $attribution) {
         $converter->setSkipPostDecoration(true);
         $attributionLine = '-- ' . trim($converter->visitChildren($attribution, ''));
         $converter->setSkipPostDecoration(false);
         $root .= ezcDocumentDocbookToRstConverter::wordWrap($attributionLine) . "\n\n";
     }
     ezcDocumentDocbookToRstConverter::$indentation -= 4;
     return $root;
 }
コード例 #2
0
ファイル: section.php プロジェクト: bmdevel/ezc
 /**
  * Handle a node
  *
  * Handle / transform a given node, and return the result of the
  * conversion.
  *
  * @param ezcDocumentElementVisitorConverter $converter
  * @param DOMElement $node
  * @param mixed $root
  * @return mixed
  */
 public function handle(ezcDocumentElementVisitorConverter $converter, DOMElement $node, $root)
 {
     if (ezcDocumentDocbookToRstConverter::$indentation > 0) {
         $converter->triggerError(E_WARNING, "Indented section found, cannot be represented in RST.");
     }
     // Reset indenteation level, ever we reach a new section
     ezcDocumentDocbookToRstConverter::$indentation = 0;
     if ($node->tagName === 'title') {
         // Get actual title string by recursing into the title node
         $converter->setSkipPostDecoration(true);
         $title = trim($converter->visitChildren($node, ''));
         $converter->setSkipPostDecoration(false);
         // Get RST title decoration characters
         if (!isset($converter->options->headerTypes[$this->level])) {
             $converter->triggerError(E_ERROR, "No characters for title of level {$this->level} defined.");
             return $root . $title;
         }
         if (strlen($marker = $converter->options->headerTypes[$this->level]) > 1) {
             return $root . sprintf("\n%s\n%s\n%s\n\n", $marker = str_repeat($marker[0], strlen($title)), $title, $marker);
         } else {
             return $root . sprintf("\n%s\n%s\n\n", $title, str_repeat($marker, strlen($title)));
         }
     } else {
         ++$this->level;
         // Set internal cross reference target if section has an ID assigned
         if ($node->hasAttribute('ID')) {
             $root .= '.. _' . $node->getAttribute('ID') . ":\n\n";
         }
         // Recurse
         $root = $converter->visitChildren($node, $root);
         // Reduce header level back to original state after recursion
         --$this->level;
     }
     return $root;
 }
コード例 #3
0
ファイル: comment.php プロジェクト: axelmdev/ecommerce
 /**
  * Handle a node
  *
  * Handle / transform a given node, and return the result of the
  * conversion.
  *
  * @param ezcDocumentElementVisitorConverter $converter
  * @param DOMElement $node
  * @param mixed $root
  * @return mixed
  */
 public function handle(ezcDocumentElementVisitorConverter $converter, DOMElement $node, $root)
 {
     $converter->setSkipPostDecoration(true);
     $comment = $converter->visitChildren($node, '');
     $converter->setSkipPostDecoration(false);
     $root .= '.. ' . trim(ezcDocumentDocbookToRstConverter::wordWrap($comment, 3)) . "\n\n";
     return $root;
 }
コード例 #4
0
ファイル: citation.php プロジェクト: bmdevel/ezc
 /**
  * Handle a node
  *
  * Handle / transform a given node, and return the result of the
  * conversion.
  *
  * @param ezcDocumentElementVisitorConverter $converter
  * @param DOMElement $node
  * @param mixed $root
  * @return mixed
  */
 public function handle(ezcDocumentElementVisitorConverter $converter, DOMElement $node, $root)
 {
     $converter->setSkipPostDecoration(true);
     $citationContent = trim($converter->visitChildren($node, ''));
     $converter->setSkipPostDecoration(false);
     $number = $converter->appendCitation($citationContent);
     // Add autonumbered citation reference
     $root .= sprintf('[CIT%03d]_ ', $number);
     return $root;
 }
コード例 #5
0
ファイル: footnote.php プロジェクト: axelmdev/ecommerce
 /**
  * Handle a node
  *
  * Handle / transform a given node, and return the result of the
  * conversion.
  *
  * @param ezcDocumentElementVisitorConverter $converter
  * @param DOMElement $node
  * @param mixed $root
  * @return mixed
  */
 public function handle(ezcDocumentElementVisitorConverter $converter, DOMElement $node, $root)
 {
     $converter->setSkipPostDecoration(true);
     $footnoteContent = trim($converter->visitChildren($node, ''));
     $converter->setSkipPostDecoration(false);
     $number = $converter->appendFootnote($footnoteContent);
     // Add autonumbered footnote reference
     $root .= '[#]_ ';
     return $root;
 }