本文整理汇总了PHP中ezcDocumentElementVisitorConverter::triggerError方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcDocumentElementVisitorConverter::triggerError方法的具体用法?PHP ezcDocumentElementVisitorConverter::triggerError怎么用?PHP ezcDocumentElementVisitorConverter::triggerError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcDocumentElementVisitorConverter
的用法示例。
在下文中一共展示了ezcDocumentElementVisitorConverter::triggerError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* 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;
}
示例2: handle
/**
* 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;
}
示例3: handle
/**
* 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;
}
示例4: handle
/**
* 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 (!isset($this->mapping[$node->tagName])) {
$converter->triggerError(E_WARNING, "Mapping handler used for element '{$node->tagName}', not known by the mapping handler.");
return $root;
}
$element = $root->ownerDocument->createElement($this->mapping[$node->tagName]);
$root->appendChild($element);
// Recurse
$converter->visitChildren($node, $element);
return $root;
}