コード例 #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
ファイル: mediaobject.php プロジェクト: axelmdev/ecommerce
 /**
  * Extract directive parameters
  *
  * Extract the image directive parameters from a media object or inline
  * media object node in the Docbook document. Returns an array with
  * named keys containing the directive parameters.
  *
  * @param ezcDocumentElementVisitorConverter $converter
  * @param DOMElement $node
  * @return array
  */
 protected function getDirectiveParameters(ezcDocumentElementVisitorConverter $converter, DOMElement $node)
 {
     // Get image resource
     $resource = $node->getElementsBytagName('imagedata')->item(0);
     $parameter = $resource->getAttribute('fileref');
     $options = array();
     $content = null;
     // Transform attributes
     $attributes = array('width' => 'width', 'depth' => 'height');
     foreach ($attributes as $src => $dst) {
         if ($resource->hasAttribute($src)) {
             $options[$dst] = $resource->getAttribute($src);
         }
     }
     // Check if the image has a description
     if (($textobject = $node->getElementsBytagName('textobject')) && $textobject->length > 0) {
         $options['alt'] = trim($textobject->item(0)->textContent);
     }
     // Check if the image has additional description assigned. In such a
     // case we wrap the image and the text inside another block.
     if (($textobject = $node->getElementsBytagName('caption')) && $textobject->length > 0) {
         $textobject = $textobject->item(0);
         // Decorate the childs of the caption node recursively, as it might
         // contain additional markup.
         $content = $converter->visitChildren($textobject, '');
     }
     // If the directive has explicit content, we render it as a figure
     // instead of an image.
     $type = $content !== null ? 'figure' : 'image';
     return array('type' => $type, 'parameter' => $parameter, 'options' => $options, 'content' => $content);
 }
コード例 #3
0
ファイル: mediaobject.php プロジェクト: axelmdev/ecommerce
 /**
  * Extract image parameters
  *
  * Extract the image parameters from a media object or inline media object
  * node in the Docbook document. Returns an array with named keys
  * containing the directive parameters.
  *
  * @param ezcDocumentElementVisitorConverter $converter
  * @param DOMElement $node
  * @return array
  */
 protected function getImageParameters(ezcDocumentElementVisitorConverter $converter, DOMElement $node)
 {
     $resource = $node->getElementsBytagName('imagedata')->item(0);
     $options = array('resource' => $resource->getAttribute('fileref'));
     // Get image resource
     // Transform attributes
     $attributes = array('width' => 'width', 'depth' => 'height');
     foreach ($attributes as $src => $dst) {
         if ($resource->hasAttribute($src)) {
             $options[$dst] = $resource->getAttribute($src);
         }
     }
     // Check if the image has a description
     if (($textobject = $node->getElementsBytagName('textobject')) && $textobject->length > 0) {
         $options['alt'] = trim($textobject->item(0)->textContent);
     }
     // Check if the image has additional description assigned. In such a
     // case we wrap the image and the text inside another block.
     if (($textobject = $node->getElementsBytagName('caption')) && $textobject->length > 0) {
         $textobject = $textobject->item(0);
         // Decorate the childs of the caption node recursively, as it might
         // contain additional markup.
         $options['text'] = preg_replace('(\\s+)', ' ', $converter->visitChildren($textobject, ''));
     }
     return $options;
 }
コード例 #4
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)
 {
     $quote = $root->ownerDocument->createElement('blockquote');
     // 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
     $quote = $converter->visitChildren($node, $quote);
     $root->appendChild($quote);
     // Append attribution nodes, if any
     foreach ($attributions as $attribution) {
         $div = $root->ownerDocument->createElement('div');
         $div->setAttribute('class', 'attribution');
         $quote->appendChild($div);
         $cite = $root->ownerDocument->createElement('cite', htmlspecialchars($attribution->textContent));
         $div->appendChild($cite);
     }
     return $root;
 }
コード例 #5
0
 /**
  * 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)
 {
     $drawingId = ++$this->counter;
     if (($imageData = $this->extractImageData($node)) === false) {
         $converter->triggerError(E_PARSE, 'Missing information in <meadiaobject /> or <inlinemediaobject />.');
         return $root;
     }
     $frame = $root->appendChild($root->ownerDocument->createElementNS(ezcDocumentOdt::NS_ODT_DRAWING, 'draw:frame'));
     $frame->setAttributeNS(ezcDocumentOdt::NS_ODT_DRAWING, 'draw:name', 'graphics' . $drawingId);
     $this->styler->applyStyles($node, $frame);
     $anchorType = $this->detectAnchorTye($node);
     $frame->setAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'text:anchor-type', $anchorType);
     if ($imageData->hasAttribute('width')) {
         $frame->setAttributeNS(ezcDocumentOdt::NS_ODT_SVG, 'svg:width', $this->correctLengthMeasure($converter, $imageData->getAttribute('width')));
     }
     if ($imageData->hasAttribute('depth')) {
         $frame->setAttributeNS(ezcDocumentOdt::NS_ODT_SVG, 'svg:height', $this->correctLengthMeasure($converter, $imageData->getAttribute('depth')));
     }
     $image = $frame->appendChild($root->ownerDocument->createElementNS(ezcDocumentOdt::NS_ODT_DRAWING, 'draw:image'));
     $imgPath = $converter->getImageLocator()->locateImage($imgFile = $imageData->getAttribute('fileref'));
     if ($imgPath === false) {
         $converter->triggerError(E_WARNING, "Could not find image '{$imgFile}'.");
         return $root;
     }
     if (!is_readable($imgPath)) {
         $converter->triggerError(E_WARNING, "Image not readable '{$imgFile}'.");
         return $root;
     }
     $binaryData = $image->appendChild($root->ownerDocument->createElementNS(ezcDocumentOdt::NS_ODT_OFFICE, 'office:binary-data', base64_encode(file_get_contents($imgPath))));
     return $root;
 }
コード例 #6
0
ファイル: line.php プロジェクト: jordanmanning/ezpublish
 /**
  * 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)
 {
     $element = $root->ownerDocument->createElement('literallayout');
     $element->setAttribute('class', 'normal');
     $root->parentNode->appendChild($element);
     // Recurse
     $converter->visitChildren($node, $element);
     // Aggregate additional line block elements
     if ($node->nextSibling && ($node->nextSibling->nodeType === XML_ELEMENT_NODE && $node->nextSibling->tagName === 'line' || $node->nextSibling->nodeType === XML_TEXT_NODE && trim($node->nextSibling->data) === '')) {
         do {
             if ($node->nextSibling->nodeType === XML_ELEMENT_NODE) {
                 $element->appendChild(new DOMText("\n"));
                 $converter->visitChildren($node->nextSibling, $element);
             }
             $node->parentNode->removeChild($node->nextSibling);
         } while ($node->nextSibling && ($node->nextSibling->nodeType === XML_ELEMENT_NODE && $node->nextSibling->tagName === 'line' || $node->nextSibling->nodeType === XML_TEXT_NODE && trim($node->nextSibling->data) === ''));
     }
     // If there are any siblings, put them into a new paragraph node,
     // "below" the list node.
     if ($node->nextSibling) {
         $newParagraph = $node->ownerDocument->createElement('paragraph');
         do {
             $newParagraph->appendChild($node->nextSibling->cloneNode(true));
             $node->parentNode->removeChild($node->nextSibling);
         } while ($node->nextSibling);
         $node->parentNode->parentNode->appendChild($newParagraph);
     }
     return $root;
 }
コード例 #7
0
ファイル: link.php プロジェクト: jordanmanning/ezpublish
 /**
  * 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 ($node->hasAttribute('anchor_name')) {
         // This is an internal reference
         $link = $root->ownerDocument->createElement('link');
         $link->setAttribute('linked', $node->getAttribute('anchor_name'));
         $root->appendChild($link);
     } else {
         switch (true) {
             case $node->hasAttribute('url_id'):
                 $method = 'fetchUrlById';
                 $value = $node->getAttribute('url_id');
                 break;
             case $node->hasAttribute('node_id'):
                 $method = 'fetchUrlByNodeId';
                 $value = $node->getAttribute('node_id');
                 break;
             case $node->hasAttribute('object_id'):
                 $method = 'fetchUrlByObjectId';
                 $value = $node->getAttribute('object_id');
                 break;
             default:
                 $converter->triggerError(E_WARNING, 'Unhandled link type.');
                 return $root;
         }
         $link = $root->ownerDocument->createElement('ulink');
         $link->setAttribute('url', $converter->options->linkProvider->{$method}($value, $node->hasAttribute('view') ? $node->getAttribute('view') : null, $node->hasAttribute('show_path') ? $node->getAttribute('show_path') : null));
         $root->appendChild($link);
     }
     $converter->visitChildren($node, $link);
     return $root;
 }
コード例 #8
0
 /**
  * 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)
 {
     $type = $this->types[$node->tagName];
     $content = $converter->visitChildren($node, '');
     $root .= $this->renderDirective($type, '', array(), $content);
     return $root;
 }
コード例 #9
0
 /**
  * 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)
 {
     // Get image resource
     $resource = $node->getElementsBytagName('imagedata')->item(0);
     $image = $root->ownerDocument->createElement('img');
     // Transform attributes
     $attributes = array('width' => 'width', 'depth' => 'height', 'fileref' => 'src');
     foreach ($attributes as $src => $dst) {
         if ($resource->hasAttribute($src)) {
             $image->setAttribute($dst, htmlspecialchars($resource->getAttribute($src)));
         }
     }
     // Check if the image has a description
     if (($textobject = $node->getElementsBytagName('textobject')) && $textobject->length > 0) {
         $image->setAttribute('alt', htmlspecialchars(trim($textobject->item(0)->textContent)));
     } else {
         // Always set some alt value, as this is required by XHtml
         $image->setAttribute('alt', htmlspecialchars($resource->getAttribute('src')));
     }
     // Check if the image has additional description assigned. In such a
     // case we wrap the image and the text inside another block.
     if (($textobject = $node->getElementsBytagName('caption')) && $textobject->length > 0) {
         $textobject = $textobject->item(0);
         $wrapper = $root->ownerDocument->createElement('div');
         $wrapper->setAttribute('class', 'image');
         $wrapper->appendChild($image);
         // Decorate the childs of the caption node recursively, as it might
         // contain additional markup.
         $textobject = $converter->visitChildren($textobject, $wrapper);
         $image = $wrapper;
     }
     $root->appendChild($image);
     return $root;
 }
コード例 #10
0
ファイル: section.php プロジェクト: jordanmanning/ezpublish
 /**
  * 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 ($node->tagName === 'title') {
         // Also set the document title from the first heading
         if ($this->level === 1) {
             $head = $this->getHead($root);
             $title = $root->ownerDocument->createElement('title', htmlspecialchars(trim($node->textContent)));
             $head->appendChild($title);
         }
         // Create common HTML headers
         $header = $root->ownerDocument->createElement('h' . min(6, $this->level));
         if ($this->level >= 6) {
             $header->setAttribute('class', 'h' . $this->level);
         }
         $root->appendChild($header);
         // Recurse
         $converter->visitChildren($node, $header);
     } else {
         ++$this->level;
         // Set internal cross reference target if section has an ID assigned
         if ($node->hasAttribute('ID')) {
             $target = $root->ownerDocument->createElement('a');
             $target->setAttribute('name', $node->getAttribute('ID'));
             $root->appendChild($target);
         }
         // Recurse
         $converter->visitChildren($node, $root);
         // Reduce header level back to original state after recursion
         --$this->level;
     }
     return $root;
 }
コード例 #11
0
ファイル: ignore.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)
 {
     if (!$this->deepIgnore) {
         return $converter->visitChildren($node, $root);
     }
     return $root;
 }
コード例 #12
0
ファイル: paragraph.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)
 {
     $p = $root->appendChild($root->ownerDocument->createElementNS(ezcDocumentOdt::NS_ODT_TEXT, 'text:p'));
     $this->styler->applyStyles($node, $p);
     $converter->visitChildren($node, $p);
     return $root;
 }
コード例 #13
0
ファイル: section.php プロジェクト: jackalope/jr_cr_demo
 /**
  * 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)
 {
     // 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
         $title = trim($converter->visitChildren($node, ''));
         // 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;
 }
コード例 #14
0
ファイル: footnote.php プロジェクト: jackalope/jr_cr_demo
 /**
  * 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)
 {
     $footnoteContent = trim($converter->visitChildren($node, ''));
     $number = $converter->appendFootnote($footnoteContent);
     // Add autonumbered footnote reference
     $root .= '[#]_ ';
     return $root;
 }
コード例 #15
0
ファイル: anchor.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)
 {
     $anchor = $root->ownerDocument->createElement('anchor');
     $anchor->setAttribute('ID', $node->getAttribute('name'));
     $root->appendChild($anchor);
     $converter->visitChildren($node, $anchor);
     return $root;
 }
コード例 #16
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;
 }
コード例 #17
0
 /**
  * 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)
 {
     $link = $root->ownerDocument->createElement('a');
     $link->setAttribute('href', '#' . $node->getAttribute('linked'));
     $root->appendChild($link);
     $converter->visitChildren($node, $link);
     return $root;
 }
コード例 #18
0
ファイル: citation.php プロジェクト: jackalope/jr_cr_demo
 /**
  * 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)
 {
     $citationContent = trim($converter->visitChildren($node, ''));
     $number = $converter->appendCitation($citationContent);
     // Add autonumbered citation reference
     $root .= sprintf('[CIT%03d]_ ', $number);
     return $root;
 }
コード例 #19
0
ファイル: table.php プロジェクト: jackalope/jr_cr_demo
 /**
  * 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)
 {
     $paragraph = $root->ownerDocument->createElement('paragraph');
     $root->appendChild($paragraph);
     $table = $root->ownerDocument->createElement('table');
     $paragraph->appendChild($table);
     $converter->visitChildren($node, $table);
     return $root;
 }
コード例 #20
0
ファイル: emphasis.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 ($node->hasAttribute('Role') && $node->getAttribute('Role') === 'strong') {
         $marker = '**';
     } else {
         $marker = '*';
     }
     return $root . ' ' . $marker . $converter->visitChildren($node, '') . $marker;
 }
コード例 #21
0
ファイル: footnote.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)
 {
     $number = $converter->appendFootnote($node->cloneNode(true));
     $footnoteReference = $root->ownerDocument->createElement('a', $number);
     $footnoteReference->setAttribute('class', 'footnote');
     $footnoteReference->setAttribute('href', '#__footnote_' . $number);
     $root->appendChild($footnoteReference);
     return $root;
 }
コード例 #22
0
ファイル: paragraph.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)
 {
     // Visit paragraph contents
     $contents = $converter->visitChildren($node, '');
     // Remove all line breaks inside the paragraph.
     $contents = trim(preg_replace('(\\s+)', ' ', $contents));
     $root .= ezcDocumentDocbookToWikiConverter::wordWrap($contents) . "\n\n";
     return $root;
 }
コード例 #23
0
ファイル: special_paragraph.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)
 {
     $type = $this->types[$node->tagName];
     $paragraph = $root->ownerDocument->createElement('p');
     $paragraph->setAttribute('class', $type);
     $root->appendChild($paragraph);
     $converter->visitChildren($node, $paragraph);
     return $root;
 }
コード例 #24
0
ファイル: ulink.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)
 {
     $a = $root->appendChild($root->ownerDocument->createElementNS(ezcDocumentOdt::NS_ODT_TEXT, 'text:a'));
     $a->setAttributeNS(ezcDocumentOdt::NS_XLINK, 'xlink:type', 'simple');
     $a->setAttributeNS(ezcDocumentOdt::NS_XLINK, 'xlink:href', $node->getAttribute('url'));
     $this->styler->applyStyles($node, $a);
     $converter->visitChildren($node, $a);
     return $root;
 }
コード例 #25
0
ファイル: table.php プロジェクト: jackalope/jr_cr_demo
 /**
  * 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)
 {
     $element = $root->ownerDocument->createElement('table');
     $root->appendChild($element);
     // Handle attributes
     // Recurse
     $converter->visitChildren($node, $element);
     return $root;
 }
コード例 #26
0
 /**
  * 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)
 {
     $cell = $root->ownerDocument->createElement('td');
     if ($node->hasAttribute('morerows')) {
         $cell->setAttribute('rowspan', $node->getAttribute('morerows') + 1);
     }
     $root->appendChild($cell);
     $converter->visitChildren($node, $cell);
     return $root;
 }
コード例 #27
0
ファイル: title.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)
 {
     $header = $root->ownerDocument->createElement('header');
     $root->appendChild($header);
     if ($node->hasAttribute('ID')) {
         $header->setAttribute('anchor_name', $node->getAttribute('ID'));
     }
     $converter->visitChildren($node, $header);
     return $root;
 }
コード例 #28
0
ファイル: header.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)
 {
     $element = $root->ownerDocument->createElement('title');
     $root->appendChild($element);
     if ($node->hasAttribute('anchor_name')) {
         $element->setAttribute('ID', $node->getAttribute('anchor_name'));
     }
     // Recurse
     $converter->visitChildren($node, $element);
     return $root;
 }
コード例 #29
0
ファイル: itemized_list.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)
 {
     ezcDocumentDocbookToRstConverter::$indentation += 2;
     foreach ($node->childNodes as $child) {
         if ($child->nodeType === XML_ELEMENT_NODE && $child->tagName === 'listitem') {
             $root .= str_repeat(' ', max(0, ezcDocumentDocbookToRstConverter::$indentation - 2)) . $converter->options->itemListCharacter . ' ' . trim($converter->visitChildren($child, '')) . "\n\n";
         }
     }
     ezcDocumentDocbookToRstConverter::$indentation = max(0, ezcDocumentDocbookToRstConverter::$indentation - 2);
     return $root;
 }
コード例 #30
0
ファイル: emphasis.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 ($node->hasAttribute('Role') && $node->getAttribute('Role') === 'strong') {
         $emphasis = $root->ownerDocument->createElement('strong');
     } else {
         $emphasis = $root->ownerDocument->createElement('emphasize');
     }
     $root->appendChild($emphasis);
     $converter->visitChildren($node, $emphasis);
     return $root;
 }