/** * @param \DOMNode|\DOMElement $node * @param int $menuId */ private function getEditXML($node, $menuId) { $menu = \Difra\Plugins\CMS\Menu::get($menuId); $node->setAttribute('depth', $menu->getDepth()); $parentsNode = $node->appendChild($this->xml->createElement('parents')); \Difra\Plugins\CMS::getInstance()->getMenuItemsXML($parentsNode, $menu->getId()); }
/** * * @param DOMElement $dom * @return array */ private function handleImages($dom, $url) { $images = array(); $parts = parse_url($url); $savedImages = array(); $imgElements = $dom->getElementsByTagName('img'); foreach ($imgElements as $img) { $src = $img->getAttribute("src"); $is_root = false; if (substr($src, 0, 1) == "/") { $is_root = true; } $parsed = parse_url($src); if (!isset($parsed["host"])) { if ($is_root) { $src = http_build_url($url, $parsed, HTTP_URL_REPLACE); } else { $src = http_build_url($url, $parsed, HTTP_URL_JOIN_PATH); } } $img->setAttribute("src", ""); if (isset($savedImages[$src])) { $img->setAttribute("recindex", $savedImages[$src]); } else { $image = ImageHandler::DownloadImage($src); if ($image !== false) { $images[$this->imgCounter] = new FileRecord(new Record($image)); $img->setAttribute("recindex", $this->imgCounter); $savedImages[$src] = $this->imgCounter; $this->imgCounter++; } } } return $images; }
/** * serialize * * @param Sabre_DAV_Server $server * @param DOMElement $prop * @return void */ public function serialize(Sabre_DAV_Server $server, DOMElement $prop) { $doc = $prop->ownerDocument; $prop->setAttribute('xmlns:b', 'urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/'); $prop->setAttribute('b:dt', 'dateTime.rfc1123'); $prop->nodeValue = Sabre_HTTP_Util::toHTTPDate($this->time); }
/** * @see CultureFeed_Cdb_IElement::appendToDOM() */ public function appendToDOM(DOMElement $element) { $dom = $element->ownerDocument; $virtualElement = $dom->createElement('virtual'); $virtualElement->appendChild($dom->createElement('title', $this->title)); $element->appendChild($virtualElement); }
/** * serialize * * @param DAV\Server $server * @param \DOMElement $dom * @return void */ public function serialize(DAV\Server $server, \DOMElement $dom) { $document = $dom->ownerDocument; $properties = $this->responseProperties; $xresponse = $document->createElement('d:response'); $dom->appendChild($xresponse); $uri = DAV\URLUtil::encodePath($this->href); // Adding the baseurl to the beginning of the url $uri = $server->getBaseUri() . $uri; $xresponse->appendChild($document->createElement('d:href', $uri)); // The properties variable is an array containing properties, grouped by // HTTP status foreach ($properties as $httpStatus => $propertyGroup) { // The 'href' is also in this array, and it's special cased. // We will ignore it if ($httpStatus == 'href') { continue; } // If there are no properties in this group, we can also just carry on if (!count($propertyGroup)) { continue; } $xpropstat = $document->createElement('d:propstat'); $xresponse->appendChild($xpropstat); $xprop = $document->createElement('d:prop'); $xpropstat->appendChild($xprop); $nsList = $server->xmlNamespaces; foreach ($propertyGroup as $propertyName => $propertyValue) { $propName = null; preg_match('/^{([^}]*)}(.*)$/', $propertyName, $propName); // special case for empty namespaces if ($propName[1] == '') { $currentProperty = $document->createElement($propName[2]); $xprop->appendChild($currentProperty); $currentProperty->setAttribute('xmlns', ''); } else { if (!isset($nsList[$propName[1]])) { $nsList[$propName[1]] = 'x' . count($nsList); } // If the namespace was defined in the top-level xml namespaces, it means // there was already a namespace declaration, and we don't have to worry about it. if (isset($server->xmlNamespaces[$propName[1]])) { $currentProperty = $document->createElement($nsList[$propName[1]] . ':' . $propName[2]); } else { $currentProperty = $document->createElementNS($propName[1], $nsList[$propName[1]] . ':' . $propName[2]); } $xprop->appendChild($currentProperty); } if (is_scalar($propertyValue)) { $text = $document->createTextNode($propertyValue); $currentProperty->appendChild($text); } elseif ($propertyValue instanceof DAV\PropertyInterface) { $propertyValue->serialize($server, $currentProperty); } elseif (!is_null($propertyValue)) { throw new DAV\Exception('Unknown property value type: ' . gettype($propertyValue) . ' for property: ' . $propertyName); } } $xpropstat->appendChild($document->createElement('d:status', $server->httpResponse->getStatusMessage($httpStatus))); } }
/** * serialize * * @param DOMElement $prop * @return void */ public function serialize(Sabre_DAV_Server $server, DOMElement $prop) { $doc = $prop->ownerDocument; if (!$this->supportsLocks) { return null; } $lockEntry1 = $doc->createElementNS('DAV:', 'd:lockentry'); $lockEntry2 = $doc->createElementNS('DAV:', 'd:lockentry'); $prop->appendChild($lockEntry1); $prop->appendChild($lockEntry2); $lockScope1 = $doc->createElementNS('DAV:', 'd:lockscope'); $lockScope2 = $doc->createElementNS('DAV:', 'd:lockscope'); $lockType1 = $doc->createElementNS('DAV:', 'd:locktype'); $lockType2 = $doc->createElementNS('DAV:', 'd:locktype'); $lockEntry1->appendChild($lockScope1); $lockEntry1->appendChild($lockType1); $lockEntry2->appendChild($lockScope2); $lockEntry2->appendChild($lockType2); $lockScope1->appendChild($doc->createElementNS('DAV:', 'd:exclusive')); $lockScope2->appendChild($doc->createElementNS('DAV:', 'd:shared')); $lockType1->appendChild($doc->createElementNS('DAV:', 'd:write')); $lockType2->appendChild($doc->createElementNS('DAV:', 'd:write')); //$frag->appendXML('<d:lockentry><d:lockscope><d:exclusive /></d:lockscope><d:locktype><d:write /></d:locktype></d:lockentry>'); //$frag->appendXML('<d:lockentry><d:lockscope><d:shared /></d:lockscope><d:locktype><d:write /></d:locktype></d:lockentry>'); }
/** * serialize * * @param DAV\Server $server * @param \DOMElement $prop * @return void */ public function serialize(DAV\Server $server, \DOMElement $prop) { $doc = $prop->ownerDocument; foreach ($this->locks as $lock) { $activeLock = $doc->createElementNS('DAV:', 'd:activelock'); $prop->appendChild($activeLock); $lockScope = $doc->createElementNS('DAV:', 'd:lockscope'); $activeLock->appendChild($lockScope); $lockScope->appendChild($doc->createElementNS('DAV:', 'd:' . ($lock->scope == DAV\Locks\LockInfo::EXCLUSIVE ? 'exclusive' : 'shared'))); $lockType = $doc->createElementNS('DAV:', 'd:locktype'); $activeLock->appendChild($lockType); $lockType->appendChild($doc->createElementNS('DAV:', 'd:write')); /* {DAV:}lockroot */ if (!self::$hideLockRoot) { $lockRoot = $doc->createElementNS('DAV:', 'd:lockroot'); $activeLock->appendChild($lockRoot); $href = $doc->createElementNS('DAV:', 'd:href'); $href->appendChild($doc->createTextNode($server->getBaseUri() . $lock->uri)); $lockRoot->appendChild($href); } $activeLock->appendChild($doc->createElementNS('DAV:', 'd:depth', $lock->depth == DAV\Server::DEPTH_INFINITY ? 'infinity' : $lock->depth)); $activeLock->appendChild($doc->createElementNS('DAV:', 'd:timeout', 'Second-' . $lock->timeout)); if ($this->revealLockToken) { $lockToken = $doc->createElementNS('DAV:', 'd:locktoken'); $activeLock->appendChild($lockToken); $lockToken->appendChild($doc->createElementNS('DAV:', 'd:href', 'opaquelocktoken:' . $lock->token)); } $activeLock->appendChild($doc->createElementNS('DAV:', 'd:owner', $lock->owner)); } }
/** * Converts the 'font-size' CSS style. * * This method receives a $targetProperty DOMElement and converts the given * style with $styleName and $styleValue to attributes on this * $targetProperty. * * @param DOMElement $targetProperty * @param string $styleName * @param ezcDocumentPcssStyleValue $styleValue */ public function convert(DOMElement $targetProperty, $styleName, ezcDocumentPcssStyleValue $styleValue) { $mmValue = sprintf('%smm', $styleValue->value); $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_FO, "fo:{$styleName}", $mmValue); $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, "style:{$styleName}-asian", $mmValue); $targetProperty->setAttributeNS(ezcDocumentOdt::NS_ODT_STYLE, "style:{$styleName}-complex", $mmValue); }
/** * * @param \DOMElement $items * @param \AppShed\Remote\XML\DOMDocument $xml * @param \AppShed\Remote\HTML\Settings $settings * @param \AppShed\Remote\Style\CSSDocument $css * @param array $javascripts * * @return \AppShed\Remote\Element\Item\Item[] of header items */ protected function addHTMLChildren($items, $xml, $settings, $css, &$javascripts) { $items->appendChild($itemsInner = $xml->createElement('div', 'items-inner')); $itemsInner->appendChild($table = $xml->createElement('table')); $table->appendChild($row = $xml->createElement('tr')); $settings->pushCurrentScreen($this->getId()); $i = 0; $headButtons = []; foreach ($this->children as $child) { if ($child->getHeaderItem()) { $headButtons[] = $child; } else { $childNode = $child->getHTMLNode($xml, $settings); if ($childNode) { if ($i == $this->columns) { $table->appendChild($row = $xml->createElement('tr')); $i = 0; } $i++; $row->appendChild($childNode); } $child->getCSS($css, $settings); $child->getJavascript($javascripts, $settings); } } while ($i < $this->columns) { $row->appendChild($xml->createElement('td')); $i++; } $settings->popCurrentScreen(); return $headButtons; }
/** * Unserialize contentclass attribute * * @param eZContentClassAttribute $classAttribute * @param DOMElement $attributeNode * @param DOMElement $attributeParametersNode */ function unserializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode) { $defaultZoneLayoutItem = $attributeParametersNode->getElementsByTagName('default-layout')->item(0); if ($defaultZoneLayoutItem !== null && $defaultZoneLayoutItem->textContent !== false) { $classAttribute->setAttribute(self::DEFAULT_ZONE_LAYOUT_FIELD, $defaultZoneLayoutItem->textContent); } }
/** * Export this interface definition to the given parent DOMElement. * * @param \DOMElement $parent Element to augment. * @param InterfaceReflector $interface Element to log export. * @param \DOMElement $child if supplied this element will be * augmented instead of freshly added. * * @return void */ public function export(\DOMElement $parent, $interface, \DOMElement $child = null) { if ($child === null) { $child = new \DOMElement('interface'); $parent->appendChild($child); } $child->setAttribute('namespace', $interface->getNamespace()); $child->setAttribute('line', $interface->getLineNumber()); $short_name = method_exists($interface, 'getShortName') ? $interface->getShortName() : $interface->getName(); $child->appendChild(new \DOMElement('name', $short_name)); $child->appendChild(new \DOMElement('full_name', $interface->getName())); foreach ($interface->getParentInterfaces() as $parent_interface) { $child->appendChild(new \DOMElement('extends', $parent_interface)); } $object = new DocBlockExporter(); $object->export($child, $interface); foreach ($interface->getConstants() as $constant) { $object = new ConstantExporter(); $constant->setDefaultPackageName($interface->getDefaultPackageName()); $object->export($child, $constant); } foreach ($interface->getProperties() as $property) { $object = new PropertyExporter(); $property->setDefaultPackageName($interface->getDefaultPackageName()); $object->export($child, $property); } foreach ($interface->getMethods() as $method) { $object = new MethodExporter(); $method->setDefaultPackageName($interface->getDefaultPackageName()); $object->export($child, $method); } }
/** * 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; }
function parseParagraph(DOMDocument $slide_xml, DOMElement $paragraph) { $runs = array(); if ($paragraph->hasChildNodes()) { $paragraph_nodes = $paragraph->childNodes; //DOMNodeList $i = 0; // running through the runs here foreach ($paragraph_nodes as $paragraph_node) { if ($paragraph_node->nodeName == "a:fld") { $runs[$i]['content'] = $this->parseNodeField($slide_xml, $paragraph_node); } if ($paragraph_node->nodeName == "a:pPr") { $runs['properties'] = $this->parseNodeProperties($paragraph_node); continue; } if ($paragraph_node->nodeName == 'a:r') { list($string, $run_parameters) = $this->parseNodeRun($slide_xml, $paragraph_node); $runs[$i]['content'] = $string; foreach ($run_parameters as $parameter_name => $parameter_value) { $runs[$i][$parameter_name] = $parameter_value; } } // remove empty runs if (empty($runs[$i]['content'])) { unset($runs[$i]); } if (empty($runs['properties']['bullet_type'])) { unset($runs['properties']['bullet_type']); } $i++; } } return $runs; }
/** * Parse node values from xml nodes * * @param \DOMElement $childNode * @return array */ protected function parseNodes($childNode) { $output = []; switch ($childNode->nodeName) { case 'vars': $moduleName = $childNode->getAttribute('module'); $output[$childNode->tagName][$moduleName] = $this->parseVarElement($childNode); break; case 'exclude': /** @var $itemNode \DOMElement */ foreach ($childNode->getElementsByTagName('item') as $itemNode) { $itemType = $itemNode->getAttribute('type'); $output[$childNode->tagName][$itemType][] = $itemNode->nodeValue; } break; case 'media': foreach ($childNode->childNodes as $mediaNode) { if ($mediaNode instanceof \DOMElement) { $mediaNodesArray = $this->extractorPool->nodeProcessor($mediaNode->tagName)->process($mediaNode, $childNode->tagName); $output = array_merge_recursive($output, $mediaNodesArray); } } break; } return $output; }
/** * Get some configuration variables as XML node attributes * @param \DOMElement|\DOMNode $node */ public static function getStateXML($node) { $config = self::getState(); foreach ($config as $k => $v) { $node->setAttribute($k, $v); } }
/** * html::a(array('id'=>1,'class'=>'selected')); * @var array $attributes * * @return DOMElement */ public static function createElement($tagname, $attributes = array()) { $e = new DOMElement($tagname); foreach ($attributes as $k => $v) { $e->setAttribute($k, $v); } }
/** * * @param DOMElement $items * @param DOMDocument $xml * @param array $data */ protected function addHTMLChildren($items, $xml, &$data, $css, &$javascripts) { $items->appendChild($itemsInner = $xml->createElement('div', 'items-inner')); $itemsInner->appendChild($table = $xml->createElement('table')); $table->appendChild($row = $xml->createElement('tr')); $s = isset($data['settings']['currentscreen']) ? $data['settings']['currentscreen'] : null; $data['settings']['currentscreen'] = $this->getId(); $i = 0; $cols = $this->getStyle('cols'); if (!$cols) { $cols = 3; } foreach ($this->children as $child) { $c = $child->getHTMLNode($xml, $data); if ($c) { if ($i == $cols) { $table->appendChild($row = $xml->createElement('tr')); $i = 0; } $i++; $row->appendChild($c); } $child->getCSS($css, $data); $child->getJavascript($javascripts); } while ($i < $cols) { $row->appendChild($xml->createElement('td')); $i++; } $data['settings']['currentscreen'] = $s; }
public static function parse(Ezer_Step $step, DOMElement $element) { $step->setName($element->getAttribute('name')); for ($i = 0; $i < $element->childNodes->length; $i++) { $childElement = $element->childNodes->item($i); if ($childElement->parentNode !== $element) { continue; } if ($childElement instanceof DOMComment || $childElement instanceof DOMText) { continue; } switch ($childElement->nodeName) { case 'args': // ignore, relevant for activity step only break; case 'copy': // ignore, relevant for assign step only break; case 'targets': self::parseTargets($step, $childElement); break; case 'sources': self::parseSources($step, $childElement); break; default: throw new Ezer_XmlPersistanceElementNotMappedException($childElement->nodeName); } } }
/** * Serializes this property. * * It will additionally prepend the href property with the server's base uri. * * @param Sabre_DAV_Server $server * @param DOMElement $dom * @return void */ public function serialize(Sabre_DAV_Server $server, DOMElement $dom) { $prefix = $server->xmlNamespaces['DAV:']; $elem = $dom->ownerDocument->createElement($prefix . ':href'); $elem->nodeValue = ($this->autoPrefix ? $server->getBaseUri() : '') . $this->href; $dom->appendChild($elem); }
/** * Create a new button element from the DOM tree element * * @param DOMElement $root pointer to the DOM tree element corresponding to the button. * * @return ButtonBox new button element */ function &create(&$root, &$pipeline) { /** * Button text is defined by its 'value' attrubute; * if this attribute is not specified, we should provide some * appropriate defaults depending on the exact button type: * reset, submit or generic button. * * Default button text values are specified in config file config.inc.php. * * @see config.inc.php * @see DEFAULT_SUBMIT_TEXT * @see DEFAULT_RESET_TEXT * @see DEFAULT_BUTTON_TEXT */ if ($root->has_attribute("value")) { $text = $root->get_attribute("value"); } else { $text = DEFAULT_BUTTON_TEXT; } $box =& new ButtonBox(); $box->readCSS($pipeline->getCurrentCSSState()); /** * If button width is not constrained, then we'll add some space around the button text */ $text = " " . $text . " "; $box->_setup($text, $pipeline); return $box; }
private function addChildFromArray($array, DOMDocument $xml, DOMElement $element) { foreach ($array as $key => $value) { $node = $xml->createElement($key, $value); $element->appendChild($node); } }
/** * Filter a single element. * * @param DOMElement $element * @return void */ public function filterElement(DOMElement $element) { $currentLevel = $element->getAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'outline-level'); $parent = $element->parentNode; $siblings = $parent->childNodes; $section = new ezcDocumentPropertyContainerDomElement('section', null, ezcDocumentOdt::NS_EZC); $parent->replaceChild($section, $element); $section->setProperty('type', 'section'); $section->setProperty('level', $currentLevel); $section->appendChild($element); $element->setProperty('type', 'title'); for ($i = 0; $i < $siblings->length; ++$i) { if ($siblings->item($i)->isSameNode($section)) { break; } } ++$i; while (($sibling = $siblings->item($i)) !== null) { if ($sibling->nodeType === XML_ELEMENT_NODE && $sibling->namespaceURI === ezcDocumentOdt::NS_EZC && $sibling->getProperty('level') <= $currentLevel) { // Reached next higher or same level section break; } $section->appendChild($sibling->cloneNode(true)); $parent->removeChild($sibling); } }
public function appendNode(DOMElement $changeset_node, $tracker_id, $artifact_id, array $row) { $field_node = $this->getNode(self::TV5_TYPE, $row); $field_node->setAttribute('bind', self::TV5_BIND); $field_node->appendChild($this->getNodeValue($this->getValueLabel($tracker_id, $artifact_id, $row['field_name'], $row['new_value']))); $changeset_node->appendChild($field_node); }
public function match(GoogleDom $dom, \DOMElement $node) { if ($node->getAttribute('class') == 'ads-ad') { return self::RULE_MATCH_MATCHED; } return self::RULE_MATCH_NOMATCH; }
/** * Parse given Flickr Image element * * @param DOMElement $image * @return void */ public function __construct(DOMElement $image) { $this->uri = (string) $image->getAttribute('source'); $this->clickUri = (string) $image->getAttribute('url'); $this->height = (int) $image->getAttribute('height'); $this->width = (int) $image->getAttribute('width'); }
/** * Get the html node for this element * * @param \DOMElement $node * @param \AppShed\Remote\XML\DOMDocument $xml * @param \AppShed\Remote\HTML\Settings $settings */ protected function getHTMLNodeInner($node, $xml, $settings) { $node->appendChild($inner = $xml->createElement('div', 'item-icon-inner')); $inner->appendChild($xml->createImgElement($this->icon->getUrl(), 'image', $this->icon->getSize())); $inner->appendChild($xml->createElement('div', ['class' => 'title', 'text' => $this->title])); $this->applyLinkToNode($xml, $node, $settings); }
/** * Filter a single element * * @param DOMElement $element * @return void */ public function filterElement(DOMElement $element) { // We need to create invalid markup here, as there is no surrounding // element allowed for groups of dt and dd elements. $entry = new ezcDocumentXhtmlDomElement('div'); $term = $element->cloneNode(true); $parent = $element->parentNode; // Replace header with new section node $parent->replaceChild($entry, $element); $entry->setProperty('type', 'varlistentry'); $entry->appendChild($term); // Skip all preceeding child elements, until we reach the current node. $children = $parent->childNodes; $childCount = $children->length; for ($i = 0; $i < $childCount; ++$i) { if ($entry->isSameNode($children->item($i))) { break; } } ++$i; while (($node = $children->item($i)) !== null) { if ($node->nodeType === XML_ELEMENT_NODE && ($node->tagName === 'dt' || $node->tagName === 'dd')) { $new = $node->cloneNode(true); $entry->appendChild($new); $parent->removeChild($node); } else { ++$i; } } }
/** * @param DOMElement $element * @param mixed $data */ protected function buildXml($element, $data) { if (is_object($data)) { $child = new \DOMElement(get_class($data)); $element->appendChild($child); if ($data instanceof \Arrayable) { $this->buildXml($child, $data->toArray()); } else { $array = array(); foreach ($data as $name => $value) { $array[$name] = $value; } $this->buildXml($child, $array); } } elseif (is_array($data)) { foreach ($data as $name => $value) { if (is_int($name) && is_object($value)) { $this->buildXml($element, $value); } elseif (is_array($value) || is_object($value)) { $child = new \DOMElement(is_int($name) ? $this->itemTag : $name); $element->appendChild($child); $this->buildXml($child, $value); } else { $child = new \DOMElement(is_int($name) ? $this->itemTag : $name); $element->appendChild($child); $child->appendChild(new \DOMText((string) $value)); } } } else { $element->appendChild(new \DOMText((string) $data)); } }
/** * 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); }
public function parse(DOMElement $element) { $this->class = $element->getAttribute('class'); if ($element->hasAttribute('args')) { $this->args[] = $element->getAttribute('args'); } for ($i = 0; $i < $element->childNodes->length; $i++) { $childElement = $element->childNodes->item($i); if ($childElement->parentNode !== $element) { continue; } if ($childElement instanceof DOMComment || $childElement instanceof DOMText) { continue; } switch ($childElement->nodeName) { case 'args': $this->parseArgs($childElement); break; case 'targets': case 'sources': // already handled by Ezer_XmlStepUtil break; default: throw new Ezer_XmlPersistanceElementNotMappedException($childElement->nodeName); } } }