/** * @param array $values */ public function getItem(array $values, flavorAsset $flavorAsset = null, thumbAsset $thumbAsset = null) { $item = $this->item->cloneNode(true); kXml::setNodeValue($this->xpath, 'guid', $values[AvnDistributionField::GUID], $item); kXml::setNodeValue($this->xpath, 'pubDate', $values[AvnDistributionField::PUB_DATE], $item); kXml::setNodeValue($this->xpath, 'title', $values[AvnDistributionField::TITLE], $item); kXml::setNodeValue($this->xpath, 'description', $values[AvnDistributionField::DESCRIPTION], $item); kXml::setNodeValue($this->xpath, 'link', $values[AvnDistributionField::LINK], $item); kXml::setNodeValue($this->xpath, 'category', $values[AvnDistributionField::CATEGORY], $item); kXml::setNodeValue($this->xpath, 'amg:passthru', $this->getPassthruJsonObj($values), $item); if ($flavorAsset) { $url = $this->getAssetUrl($flavorAsset); $type = $this->getContentTypeFromUrl($url); kXml::setNodeValue($this->xpath, 'media:content/@url', $url, $item); kXml::setNodeValue($this->xpath, 'media:content/@type', $type, $item); if ($values[AvnDistributionField::ORDER_SUB] == '1') { kXml::setNodeValue($this->xpath, 'media:content/@isDefault', 'true', $item); } else { kXml::setNodeValue($this->xpath, 'media:content/@isDefault', 'false', $item); } } if ($thumbAsset) { kXml::setNodeValue($this->xpath, 'media:thumbnail/@url', $this->getAssetUrl($thumbAsset), $item); } return $item; }
/** * @param array $values */ public function addItem(array $values, flavorAsset $flavorAsset = null, thumbAsset $thumbAsset = null) { $item = $this->item->cloneNode(true); $channelNode = $this->xpath->query('/rss/channel', $item)->item(0); $channelNode->appendChild($item); $this->setNodeValue('guid', $values[AvnDistributionField::GUID], $item); $this->setNodeValue('pubDate', $values[AvnDistributionField::PUB_DATE], $item); $this->setNodeValue('title', $values[AvnDistributionField::TITLE], $item); $this->setNodeValue('description', $values[AvnDistributionField::DESCRIPTION], $item); $this->setNodeValue('link', $values[AvnDistributionField::LINK], $item); $this->setNodeValue('category', $values[AvnDistributionField::CATEGORY], $item); $this->setNodeValue('amg:passthru', $this->getPassthruJsonObj($values), $item); if ($flavorAsset) { $url = $this->getAssetUrl($flavorAsset); $type = $this->getContentTypeFromUrl($url); $this->setNodeValue('media:content/@url', $url, $item); $this->setNodeValue('media:content/@type', $type, $item); if ($values[AvnDistributionField::ORDER_SUB] == '1') { $this->setNodeValue('media:content/@isDefault', 'true', $item); } else { $this->setNodeValue('media:content/@isDefault', 'false', $item); } } if ($thumbAsset) { $this->setNodeValue('media:thumbnail/@url', $this->getAssetUrl($thumbAsset), $item); } }
/** * 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; } } }
/** * 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; }
private function _getPlainText(DOMElement $tag) { // Work on a copy $clone = $tag->cloneNode(true); // Strip unneded tags (<small>) while (($tag = $clone->getElementsByTagName('small')) && $tag->length) { $tag->item(0)->parentNode->removeChild($tag->item(0)); } return $clone->textContent; }
/** * @param array $flavorAssets */ public function setFlavorAsset(DOMElement $item, array $flavorAssets) { $flavorAsset = $flavorAssets[0]; /* @var $flavorAsset flavorAsset */ $content = $this->content->cloneNode(true); $mediaGroup = $this->xpath->query('media:group', $item)->item(0); $mediaGroup->appendChild($content); $url = $this->getAssetUrl($flavorAsset); kXml::setNodeValue($this->xpath, '@url', $url, $content); }
public function setCuePoints(DOMElement $item, array $cuePoints) { foreach ($cuePoints as $cuePoint) { /* @var $cuePoint cuePoint */ $content = $this->cuePoint->cloneNode(true); $mediaGroup = $this->xpath->query('.', $item)->item(0); $mediaGroup->appendChild($content); kXml::setNodeValue($this->xpath, '@type', self::MILLISECONDS, $content); kXml::setNodeValue($this->xpath, '@startTime', $cuePoint->getStartTime(), $content); } }
/** * @param \DOMNode $node * @return \DOMNode|null */ public function appendTableToNode(\DOMNode $node) { if ($node->ownerDocument === null) { return null; } if ($node->ownerDocument === $this->dom) { return null; } $table = $node->ownerDocument->importNode($this->table->cloneNode(true), true); return $node->appendChild($table); }
public function addThumbAsset(DOMElement $item, asset $thumbAsset, $thumbnailCredit) { $thumbnailNode = $this->thumbnail->cloneNode(true); $item->appendChild($thumbnailNode); $url = $this->getAssetUrl($thumbAsset); $this->setNodeValue('@url', $url, $thumbnailNode); $this->setNodeValue('@width', $thumbAsset->getWidth(), $thumbnailNode); $this->setNodeValue('@height', $thumbAsset->getHeight(), $thumbnailNode); if ($thumbnailCredit) { $this->setNodeValue('@credit', $thumbnailCredit, $thumbnailNode); } }
/** * @param array $flavorAssets */ public function setThumbAssets(DOMElement $item, array $thumbAssets) { foreach ($thumbAssets as $thumbAsset) { /* @var $flavorAsset flavorAsset */ $content = $this->thumbnail->cloneNode(true); $mediaGroup = $this->xpath->query('media:group', $item)->item(0); $mediaGroup->appendChild($content); $url = $this->getAssetUrl($thumbAsset); kXml::setNodeValue($this->xpath, '@url', $url, $content); kXml::setNodeValue($this->xpath, '@width', $thumbAsset->getWidth(), $content); kXml::setNodeValue($this->xpath, '@height', $thumbAsset->getHeight(), $content); } }
public function addCategory($item, $categoryValue) { $categories = explode(',', $categoryValue); if ($categories) { foreach ($categories as $category) { if ($category) { $categoryNode = $this->category->cloneNode(true); $categoryNode->nodeValue = $category; $beforeNode = $this->xpath->query('media:copyright', $item)->item(0); $item->insertBefore($categoryNode, $beforeNode); } } } }
/** * @param int * @throws \Exception * @return DOMNode */ protected function getNextNodeTemplate($template_type) { if ($template_type == static::$TEMPLATE_TYPE_BEGRUENDUNG) { return $this->node_begruendung->cloneNode(); } if ($template_type == static::$TEMPLATE_TYPE_ANTRAG) { if ($this->node_template_1_used && $this->node_template_n) { return $this->node_template_n->cloneNode(); } else { $this->node_template_1_used = true; return $this->node_template_1->cloneNode(); } } throw new Exception("Ungültiges Template"); }
/** * @param bool $lineNumbers * * @return \DOMNode */ protected function getNextNodeTemplate($lineNumbers) { $node = $this->nodeText->cloneNode(); /** @var \DOMElement $node */ if ($lineNumbers) { if ($this->node_template_1_used) { $node->setAttribute('text:style-name', 'Antragsgrün_20_LineNumbered_20_Standard'); } else { $this->node_template_1_used = true; $node->setAttribute('text:style-name', 'Antragsgrün_20_LineNumbered_20_First'); } } else { $node->setAttribute('text:style-name', 'Antragsgrün_20_Standard'); } return $node; }
public function addItem(array $values, $categoryNode, $thumbnailFile, $flavorFile) { $item = $this->item->cloneNode(true); $categoryNode->appendChild($item); $this->setNodeValue('@title', $values[UverseClickToOrderDistributionField::ITEM_TITLE], $item); $this->setNodeValue('@content_type', $values[UverseClickToOrderDistributionField::ITEM_CONTENT_TYPE], $item); $this->setNodeValue('@file', $thumbnailFile, $item); $this->setNodeValue('@destination', $values[UverseClickToOrderDistributionField::ITEM_DESTINATION], $item); if (strtolower($values[UverseClickToOrderDistributionField::ITEM_CONTENT_TYPE]) == self::VIDFILE_CONTENT_TYPE) { $this->setNodeValue('@vidfile', $flavorFile, $item); } else { $item->removeAttribute('vidfile'); } $this->setNodeValue('@ccvidfile', $values[UverseClickToOrderDistributionField::ITEM_CCVIDFILE], $item); $this->setNodeValue('content', $values[UverseClickToOrderDistributionField::ITEM_CONTENT], $item); $this->setNodeValue('directions', $values[UverseClickToOrderDistributionField::ITEM_DIRECTIONS], $item); }
/** * @param DOMElement $item * @param array $thumbAssets * @param array $remoteThumbailFileUrls */ public function setThumbAsset($item, array $thumbAssets, $remoteThumbailFileUrls) { $node = $this->xpath->query('thumbnail', $item)->item(0); if (count($thumbAssets)) { foreach ($thumbAssets as $thumbAsset) { /* @var $thumbAsset thumbAsset */ $thumbAssetId = $thumbAsset->getId(); $url = ''; if (!is_null($remoteThumbailFileUrls)) { $url = $remoteThumbailFileUrls[$thumbAssetId]; } $thumbnailNode = $this->thumbnail->cloneNode(true); $item->insertBefore($thumbnailNode, $node); $this->setNodeValue('@url', $url, $thumbnailNode); $this->setNodeValue('@height', $thumbAsset->getHeight(), $thumbnailNode); $this->setNodeValue('@width', $thumbAsset->getWidth(), $thumbnailNode); } } $node->parentNode->removeChild($node); }
/** * @param array $values * @param array $flavorAssets * @param array $thumbAssets */ public function getItem(array $values, entry $entry, array $flavorAssets = null, array $thumbAssets = null, array $additionalAssets = null) { $item = $this->item->cloneNode(true); kXml::setNodeValue($this->xpath, 'atom:title', $values[SynacorHboDistributionField::ENTRY_TITLE], $item); kXml::setNodeValue($this->xpath, 'atom:summary', $values[SynacorHboDistributionField::ENTRY_SUMMARY], $item); $updatedTime = $this->formatSynacorHboTime($values[SynacorHboDistributionField::ENTRY_UPDATED]); kXml::setNodeValue($this->xpath, 'atom:updated', $updatedTime, $item); kXml::setNodeValue($this->xpath, 'atom:author/atom:name', $values[SynacorHboDistributionField::ENTRY_AUTHOR_NAME], $item); $categoryValue = $values[SynacorHboDistributionField::ENTRY_CATEGORY_TERM]; if (strlen($categoryValue) > 0) { kXml::setNodeValue($this->xpath, 'atom:category/@term', $categoryValue, $item); } else { $this->removeNode('atom:category', $item); } $genreValue = $values[SynacorHboDistributionField::ENTRY_GENRE_TERM]; if (strlen($genreValue) > 0) { kXml::setNodeValue($this->xpath, 'atom:genre/@term', $genreValue, $item); } else { $this->removeNode('atom:genre', $item); } kXml::setNodeValue($this->xpath, 'atom:assetType', $values[SynacorHboDistributionField::ENTRY_ASSET_TYPE], $item); kXml::setNodeValue($this->xpath, 'atom:assetId', $values[SynacorHboDistributionField::ENTRY_ASSET_ID], $item); $startTime = $this->formatSynacorHboTime($values[SynacorHboDistributionField::ENTRY_OFFERING_START]); kXml::setNodeValue($this->xpath, 'atom:offering/atom:start', $startTime, $item); $endTime = $this->formatSynacorHboTime($values[SynacorHboDistributionField::ENTRY_OFFERING_END]); kXml::setNodeValue($this->xpath, 'atom:offering/atom:end', $endTime, $item); $ratingValue = $values[SynacorHboDistributionField::ENTRY_RATING]; if (strlen($ratingValue) > 0) { kXml::setNodeValue($this->xpath, 'atom:rating', $ratingValue, $item); $ratingType = stripos($ratingValue, 'tv') === '0' ? 'tv' : 'theatrical'; kXml::setNodeValue($this->xpath, 'atom:rating/@type', $ratingType, $item); } else { $this->removeNode('atom:rating', $item); } $durationInSeconds = ceil($entry->getDuration()); $durationInMinuesRoundedUp = ceil($durationInSeconds / 60); kXml::setNodeValue($this->xpath, 'atom:runtime', $durationInMinuesRoundedUp, $item); kXml::setNodeValue($this->xpath, 'atom:runtime/@timeInSeconds', $durationInSeconds, $item); kXml::setNodeValue($this->xpath, 'go:series/go:title', $values[SynacorHboDistributionField::ENTRY_SERIES_TITLE], $item); kXml::setNodeValue($this->xpath, 'atom:brand', $values[SynacorHboDistributionField::ENTRY_BRAND], $item); if (!is_null($flavorAssets) && is_array($flavorAssets) && count($flavorAssets) > 0) { $flavorAsset = $flavorAssets[0]; /* @var $flavorAsset flavorAsset */ $flavorUrl = $this->getAssetUrl($flavorAsset); // we don't have a way to identify the mime type of the file // as there is no guarantee that the file exists in the current data center // so we will just use those hardcoded conditions $mimeType = ''; switch ($flavorAsset->getFileExt()) { case 'flv': $mimeType = 'video/x-flv'; break; case 'mp4': $mimeType = 'video/mp4'; break; case 'mpeg': case 'mpg': $mimeType = 'video/mpeg'; break; default: $mimeType = 'video/x-flv'; // default requested by synacor } kXml::setNodeValue($this->xpath, 'atom:link[@type=\'VIDEO_MIME_TYPE\']/@href', $flavorUrl, $item); kXml::setNodeValue($this->xpath, 'atom:link[@type=\'VIDEO_MIME_TYPE\']/@type', $mimeType, $item); } if (!is_null($thumbAssets) && is_array($thumbAssets) && count($thumbAssets) > 0) { $thumbAsset = $thumbAssets[0]; /* @var $thumbAssets thumbAssets */ $thumbUrl = $this->getAssetUrl($thumbAsset); kXml::setNodeValue($this->xpath, 'atom:link[@type=\'image/jpeg\']/@href', $thumbUrl, $item); } if (is_array($additionalAssets)) { foreach ($additionalAssets as $additionalAsset) { /* @var $additionalAsset asset */ $assetType = $additionalAsset->getType(); switch ($assetType) { case CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION): /* @var $captionPlugin CaptionPlugin */ $captionPlugin = KalturaPluginManager::getPluginInstance(CaptionPlugin::PLUGIN_NAME); $dummyElement = new SimpleXMLElement('<dummy/>'); $captionPlugin->contributeCaptionAssets($additionalAsset, $dummyElement); $dummyDom = dom_import_simplexml($dummyElement); $captionDom = $dummyDom->getElementsByTagName('subTitle'); $captionDom = $this->doc->importNode($captionDom->item(0), true); $captionDom = $item->appendChild($captionDom); break; case AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT): /* @var $attachmentPlugin AttachmentPlugin */ $attachmentPlugin = KalturaPluginManager::getPluginInstance(AttachmentPlugin::PLUGIN_NAME); $dummyElement = new SimpleXMLElement('<dummy/>'); $attachmentPlugin->contributeAttachmentAssets($additionalAsset, $dummyElement); $dummyDom = dom_import_simplexml($dummyElement); $attachmentDom = $dummyDom->getElementsByTagName('attachment'); $attachmentDom = $this->doc->importNode($attachmentDom->item(0), true); $attachmentDom = $item->appendChild($attachmentDom); break; } } } return $item; }
/** * Get the inner and outer wrapper nodes. Simple means that they are the * same nodes. * * @param \DOMElement $template * @param bool $simple * @return \DOMElement[] */ public function getWrapperNodes($template, &$simple) { $wrapper = $template->cloneNode(TRUE); $targets = NULL; $target = NULL; if (!$simple) { // get the first element without child elements. $targets = $this->getOwner()->xpath('.//*[count(*) = 0]', $wrapper); } if ($simple || $targets->length === 0) { $target = $wrapper; $simple = TRUE; } elseif ($targets instanceof \DOMNodeList) { $target = $targets->item(0); } return array($target, $wrapper); }
/** * Converts a DOM element into a single Markdown block. * * Handles inline elements. * * @param \DOMElement $element * The Node to transform. * * @return string * A single Markdown block string. */ protected function getBlock(\DOMElement $element) { $block = ''; /** @var \DOMNode $node */ foreach ($element->childNodes as $node) { switch ($node->nodeType) { case XML_ELEMENT_NODE: /** @var \DOMElement $node */ switch ($node->nodeName) { // Explicitly handle these elements. case 'i': case 'em': $block .= '*' . $this->getBlock($node) . '*'; break; case 'b': case 'strong': $block .= '**' . $this->getBlock($node) . '**'; break; case 'a': if ($node->hasAttribute('href')) { $block .= '[' . $this->getBlock($node) . ']' . '(' . $node->getAttribute('href') . ')'; } break; // Other inline elements. // Other inline elements. default: // Recursively handle any descendant elements we care about. $block .= $this->getBlock($node); break; } break; case XML_TEXT_NODE: /** @var \DOMText $node */ $block .= self::escape($node->textContent); break; } } // Handle white-listed elements. if (in_array($element->nodeName, $this->white_list)) { $tag = $element->cloneNode(); if (!empty($block)) { $tag->appendChild(new \DOMText($block)); } $block = $this->dom->saveXML($tag); } return $block; }
/** * Creates a failed test case * * @param DOMElement $node The context node. * @param DOMElement $parentNode The parent test suite. * @param string $build An optional build identifier. * * @return void */ protected function createErrorTestCase($node, $parentNode, $build = null) { $error = $this->log->createElement('error'); $error->setAttribute('type', 'PHPUnit_Framework_Error'); $error->appendChild($this->log->createCDATASection(sprintf("%s(%s)\nWas never executed.\n", $node->getAttribute('name'), $node->getAttribute('class')))); $test = $node->cloneNode(false); $test->setAttribute('time', '0.000000'); $test->appendChild($error); if ($build !== null) { $test->setAttribute('build', $build); } $parentNode->appendChild($test); }
/** * Kopiowanie elementu */ public function __clone() { $this->element = $this->element->cloneNode(); self::$DOM->appendChild($this->element); }
/** * @param array $values */ public function addItem(array $values, flavorAsset $flavorAsset = null, thumbAsset $thumbAsset = null, array $additionalAssets = null) { $item = $this->item->cloneNode(true); $channelNode = $this->xpath->query('/rss/channel', $item)->item(0); $channelNode->appendChild($item); $pubDate = date('c', $values[TVComDistributionField::ITEM_PUB_DATE]); $expDate = date('c', $values[TVComDistributionField::ITEM_EXP_DATE]); $node = $this->setNodeValue('guid', $values[TVComDistributionField::GUID_ID], $item); $node = $this->setNodeValue('pubDate', $pubDate, $item); $node = $this->setNodeValue('expDate', $expDate, $item); $node = $this->setNodeValue('link', $values[TVComDistributionField::ITEM_LINK], $item); $node = $this->setNodeValue('media:group/media:title', $values[TVComDistributionField::MEDIA_TITLE], $item); $node = $this->setNodeValue('media:group/media:description', $values[TVComDistributionField::MEDIA_DESCRIPTION], $item); $node = $this->setNodeValue('media:group/media:keywords', $values[TVComDistributionField::MEDIA_KEYWORDS], $item); $node = $this->setNodeValue('media:group/media:copyright', $values[TVComDistributionField::MEDIA_COPYRIGHT], $item); $node = $this->setNodeValue('media:group/media:rating', $values[TVComDistributionField::MEDIA_RATING], $item); $node = $this->setNodeValue('media:group/media:restriction/@relationship', $values[TVComDistributionField::MEDIA_RESTRICTION_TYPE], $item); $node = $this->setNodeValue('media:group/media:restriction', $values[TVComDistributionField::MEDIA_RESTRICTION_COUNTRIES], $item); $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:show-tmsid\']', $values[TVComDistributionField::MEDIA_CATEGORY_SHOW_TMSID], $item); $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:show-tmsid\']/@label', $values[TVComDistributionField::MEDIA_CATEGORY_SHOW_TMSID_LABEL], $item); $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:episode-tmsid\']', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_TMSID], $item); $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:episode-tmsid\']/@label', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_TMSID_LABEL], $item); $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:episodetype\']', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_TYPE], $item); $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:original_air_date\']', $values[TVComDistributionField::MEDIA_CATEGORY_ORIGINAL_AIR_DATE], $item); $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:video_format\']', $values[TVComDistributionField::MEDIA_CATEGORY_VIDEO_FORMAT], $item); $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:season_number\']', $values[TVComDistributionField::MEDIA_CATEGORY_SEASON_NUMBER], $item); $node = $this->setNodeValue('media:group/media:category[@scheme=\'urn:tvcom:episode_number\']', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_NUMBER], $item); $dcTerms = "start={$pubDate}; end={$expDate}; scheme=W3C-DTF"; $node = $this->setNodeValue('dcterms:valid', $dcTerms, $item); if ($flavorAsset) { $node = $this->setNodeValue('media:group/media:content/@url', $this->getAssetUrl($flavorAsset), $item); $type = ''; switch ($flavorAsset->getFileExt()) { case 'mp4': $type = 'video/mp4'; break; case 'flv': $type = 'video/x-flv'; break; } $node = $this->setNodeValue('media:group/media:content/@type', $type, $item); $node = $this->setNodeValue('media:group/media:content/@fileSize', $flavorAsset->getSize(), $item); $node = $this->setNodeValue('media:group/media:content/@expression', $values[TVComDistributionField::MEDIA_CATEGORY_EPISODE_TYPE], $item); $node = $this->setNodeValue('media:group/media:content/@duration', floor($flavorAsset->getentry()->getDuration()), $item); } if ($thumbAsset) { $node = $this->setNodeValue('media:group/media:thumbnail/@url', $this->getAssetUrl($thumbAsset), $item); $node = $this->setNodeValue('media:group/media:thumbnail/@width', $thumbAsset->getWidth(), $item); $node = $this->setNodeValue('media:group/media:thumbnail/@height', $thumbAsset->getHeight(), $item); } if (is_array($additionalAssets)) { foreach ($additionalAssets as $additionalAsset) { /* @var $additionalAsset asset */ $assetType = $additionalAsset->getType(); switch ($assetType) { case CaptionPlugin::getAssetTypeCoreValue(CaptionAssetType::CAPTION): /* @var $captionPlugin CaptionPlugin */ $captionPlugin = KalturaPluginManager::getPluginInstance(CaptionPlugin::PLUGIN_NAME); $dummyElement = new SimpleXMLElement('<dummy/>'); $captionPlugin->contributeCaptionAssets($additionalAsset, $dummyElement); $dummyDom = dom_import_simplexml($dummyElement); $captionDom = $dummyDom->getElementsByTagName('subTitle'); $captionDom = $this->doc->importNode($captionDom->item(0), true); $captionDom = $item->appendChild($captionDom); break; case AttachmentPlugin::getAssetTypeCoreValue(AttachmentAssetType::ATTACHMENT): /* @var $attachmentPlugin AttachmentPlugin */ $attachmentPlugin = KalturaPluginManager::getPluginInstance(AttachmentPlugin::PLUGIN_NAME); $dummyElement = new SimpleXMLElement('<dummy/>'); $attachmentPlugin->contributeAttachmentAssets($additionalAsset, $dummyElement); $dummyDom = dom_import_simplexml($dummyElement); $attachmentDom = $dummyDom->getElementsByTagName('attachment'); $attachmentDom = $this->doc->importNode($attachmentDom->item(0), true); $attachmentDom = $item->appendChild($attachmentDom); break; } } } }
function node_to_string(DOMElement $node) { $newdoc = new DOMDocument(); $cloned = $node->cloneNode(TRUE); $newdoc->appendChild($newdoc->importNode($cloned, TRUE)); return $newdoc->saveHTML(); }
/** * Генерирует ячейку, вставляет данные * * @param DOMElement $c Ячейка таблицы * @param DOMElement $v Данные ячейки (может быть как просто данные так и формула) * @param array $attributes Аттрибуты ячейки * @param string $value Значение ячейки * @return DOMNode */ public function createOneCell($c, $v, $attributes, $value = null) { if ($value != null) { $cell_value = $v->cloneNode(true); $cell_value->nodeValue = $value; } $cell = $c->cloneNode(true); foreach ($attributes as $name => $attr) { $cell->setAttribute($name, $attr); } if ($value != null) { $cell->appendChild($cell_value); } return $cell; }