public function checkOptionnalMediaGroupNode(\DOMNode $node, FeedItem $entry_item) { $fields = ['title' => ['dc_field' => \databox_Field_DCESAbstract::Title, 'media_field' => ['name' => 'media:title', 'attributes' => ['type' => 'plain']], 'separator' => ' '], 'description' => ['dc_field' => \databox_Field_DCESAbstract::Description, 'media_field' => ['name' => 'media:description', 'attributes' => []], 'separator' => ' '], 'contributor' => ['dc_field' => \databox_Field_DCESAbstract::Contributor, 'media_field' => ['name' => 'media:credit', 'attributes' => ['role' => 'contributor', 'scheme' => 'urn:ebu']], 'separator' => ' '], 'director' => ['dc_field' => \databox_Field_DCESAbstract::Creator, 'media_field' => ['name' => 'media:credit', 'attributes' => ['role' => 'director', 'scheme' => 'urn:ebu']], 'separator' => ' '], 'publisher' => ['dc_field' => \databox_Field_DCESAbstract::Publisher, 'media_field' => ['name' => 'media:credit', 'attributes' => ['role' => 'publisher', 'scheme' => 'urn:ebu']], 'separator' => ' '], 'rights' => ['dc_field' => \databox_Field_DCESAbstract::Rights, 'media_field' => ['name' => 'media:copyright', 'attributes' => []], 'separator' => ' '], 'keywords' => ['dc_field' => \databox_Field_DCESAbstract::Subject, 'media_field' => ['name' => 'media:keywords', 'attributes' => []], 'separator' => ', ']]; foreach ($fields as $key_field => $field) { $role = true; if (isset($field["media_field"]['attributes']['role'])) { $role = false; foreach ($node->attributes as $attr) { if ($attr->name == 'role') { $role = $attr->value == $field["media_field"]['attributes']['role']; break; } } } if ($field["media_field"]["name"] == $node->nodeName && $role != false) { if ($p4field = $entry_item->getRecord(self::$DI['app'])->get_caption()->get_dc_field($field["dc_field"])) { $this->assertEquals($p4field->get_serialized_values($field["separator"]), $node->nodeValue, sprintf('Asserting good value for DC %s', $field["dc_field"])); if (sizeof($field["media_field"]["attributes"]) > 0) { foreach ($node->attributes as $attribute) { $this->assertTrue(array_key_exists($attribute->name, $field["media_field"]["attributes"]), "Checkin attribute " . $attribute->name . " for " . $field['media_field']['name']); $this->assertEquals($attribute->value, $field["media_field"]["attributes"][$attribute->name], "Checkin attribute " . $attribute->name . " for " . $field['media_field']['name']); } } } else { $this->fail("Missing media:entry"); } break; } } }
protected function addContent(Application $app, \DOMDocument $document, \DOMNode $node, FeedItem $content) { $preview_sd = $content->getRecord($app)->get_subdef('preview'); $preview_permalink = $preview_sd->get_permalink(); $thumbnail_sd = $content->getRecord($app)->get_thumbnail(); $thumbnail_permalink = $thumbnail_sd->get_permalink(); $medium = strtolower($content->getRecord($app)->get_type()); if (!in_array($medium, ['image', 'audio', 'video'])) { return $this; } if (null === $preview_permalink || null === $thumbnail_permalink) { return $this; } //add item node to channel node $item = $this->addTag($document, $node, 'item'); $caption = $content->getRecord($app)->get_caption(); $title_field = $caption->get_dc_field(\databox_Field_DCESAbstract::Title); if (null !== $title_field) { $str_title = $title_field->get_serialized_values(' '); } else { $str_title = $content->getRecord($app)->get_title(); } //attach tile node to item node $title = $this->addTag($document, $item, 'title', $str_title); $desc_field = $caption->get_dc_field(\databox_Field_DCESAbstract::Description); if (null !== $desc_field) { $str_desc = $desc_field->get_serialized_values(' '); } else { $str_desc = ''; } //attach desc node to item node $desc = $this->addTag($document, $item, 'description', $str_desc); $duration = $content->getRecord($app)->get_duration(); if (null !== $preview_permalink) { $preview = $this->addTag($document, $item, 'media:content'); $preview->setAttribute('url', (string) $preview_permalink->get_url()); $preview->setAttribute('fileSize', $preview_sd->get_size()); $preview->setAttribute('type', $preview_sd->get_mime()); $preview->setAttribute('medium', $medium); $preview->setAttribute('expression', 'full'); $preview->setAttribute('isDefault', 'true'); if (null !== $preview_sd->get_width()) { $preview->setAttribute('width', $preview_sd->get_width()); } if (null !== $preview_sd->get_height()) { $preview->setAttribute('height', $preview_sd->get_height()); } if (null !== $duration) { $preview->setAttribute('duration', $duration); } } if (null !== $thumbnail_permalink) { $thumbnail = $this->addTag($document, $item, 'media:thumbnail'); $thumbnail->setAttribute('url', (string) $thumbnail_permalink->get_url()); if (null !== $thumbnail_sd->get_width()) { $thumbnail->setAttribute('width', $thumbnail_sd->get_width()); } if (null !== $thumbnail_sd->get_height()) { $thumbnail->setAttribute('height', $thumbnail_sd->get_height()); } $thumbnail = $this->addTag($document, $item, 'media:content'); $thumbnail->setAttribute('url', (string) $thumbnail_permalink->get_url()); $thumbnail->setAttribute('fileSize', $thumbnail_sd->get_size()); $thumbnail->setAttribute('type', $thumbnail_sd->get_mime()); $thumbnail->setAttribute('medium', $medium); $thumbnail->setAttribute('isDefault', 'false'); if (null !== $thumbnail_sd->get_width()) { $thumbnail->setAttribute('width', $thumbnail_sd->get_width()); } if (null !== $thumbnail_sd->get_height()) { $thumbnail->setAttribute('height', $thumbnail_sd->get_height()); } if (null !== $duration) { $thumbnail->setAttribute('duration', $duration); } } return $this; }
/** * @param Application $app * @param \DOMDocument $document * @param \DOMNode $item * @param FeedItem $content * @return $this */ protected function addContent(Application $app, \DOMDocument $document, \DOMNode $item, FeedItem $content) { $preview_sd = $content->getRecord($app)->get_subdef('preview'); $preview_permalink = $preview_sd->get_permalink(); $thumbnail_sd = $content->getRecord($app)->get_thumbnail(); $thumbnail_permalink = $thumbnail_sd->get_permalink(); $medium = strtolower($content->getRecord($app)->get_type()); if (!in_array($medium, ['image', 'audio', 'video'])) { return $this; } if (null === $preview_permalink || null === $thumbnail_permalink) { return $this; } $group = $this->addTag($document, $item, 'media:group'); $caption = $content->getRecord($app)->get_caption(); $title_field = $caption->get_dc_field(\databox_Field_DCESAbstract::Title); if (null !== $title_field) { $str_title = $title_field->get_serialized_values(' '); $title = $this->addTag($document, $group, 'media:title', $str_title); $title->setAttribute('type', 'plain'); } $desc_field = $caption->get_dc_field(\databox_Field_DCESAbstract::Description); if (null !== $desc_field) { $str_desc = $desc_field->get_serialized_values(' '); $desc = $this->addTag($document, $group, 'media:description', $str_desc); $desc->setAttribute('type', 'plain'); } $contrib_field = $caption->get_dc_field(\databox_Field_DCESAbstract::Contributor); if (null !== $contrib_field) { $str_contrib = $contrib_field->get_serialized_values(' '); $contrib = $this->addTag($document, $group, 'media:credit', $str_contrib); $contrib->setAttribute('role', 'contributor'); $contrib->setAttribute('scheme', 'urn:ebu'); } $director_field = $caption->get_dc_field(\databox_Field_DCESAbstract::Creator); if (null !== $director_field) { $str_director = $director_field->get_serialized_values(' '); $director = $this->addTag($document, $group, 'media:credit', $str_director); $director->setAttribute('role', 'director'); $director->setAttribute('scheme', 'urn:ebu'); } $publisher_field = $caption->get_dc_field(\databox_Field_DCESAbstract::Publisher); if (null !== $publisher_field) { $str_publisher = $publisher_field->get_serialized_values(' '); $publisher = $this->addTag($document, $group, 'media:credit', $str_publisher); $publisher->setAttribute('role', 'publisher'); $publisher->setAttribute('scheme', 'urn:ebu'); } $rights_field = $caption->get_dc_field(\databox_Field_DCESAbstract::Rights); if (null !== $rights_field) { $str_rights = $rights_field->get_serialized_values(' '); $rights = $this->addTag($document, $group, 'media:copyright', $str_rights); } $keyword_field = $caption->get_dc_field(\databox_Field_DCESAbstract::Subject); if (null !== $keyword_field) { $str_keywords = $keyword_field->get_serialized_values(', '); $keywords = $this->addTag($document, $group, 'media:keywords', $str_keywords); } $duration = $content->getRecord($app)->get_duration(); if (null !== $preview_permalink) { $preview = $this->addTag($document, $group, 'media:content'); $preview->setAttribute('url', (string) $preview_permalink->get_url()); $preview->setAttribute('fileSize', $preview_sd->get_size()); $preview->setAttribute('type', $preview_sd->get_mime()); $preview->setAttribute('medium', $medium); $preview->setAttribute('expression', 'full'); $preview->setAttribute('isDefault', 'true'); if (null !== $preview_sd->get_width()) { $preview->setAttribute('width', $preview_sd->get_width()); } if (null !== $preview_sd->get_height()) { $preview->setAttribute('height', $preview_sd->get_height()); } if (null !== $duration) { $preview->setAttribute('duration', $duration); } } if (null !== $thumbnail_permalink) { $thumbnail = $this->addTag($document, $group, 'media:thumbnail'); $thumbnail->setAttribute('url', (string) $thumbnail_permalink->get_url()); if (null !== $thumbnail_sd->get_width()) { $thumbnail->setAttribute('width', $thumbnail_sd->get_width()); } if (null !== $thumbnail_sd->get_height()) { $thumbnail->setAttribute('height', $thumbnail_sd->get_height()); } $thumbnail = $this->addTag($document, $group, 'media:content'); $thumbnail->setAttribute('url', (string) $thumbnail_permalink->get_url()); $thumbnail->setAttribute('fileSize', $thumbnail_sd->get_size()); $thumbnail->setAttribute('type', $thumbnail_sd->get_mime()); $thumbnail->setAttribute('medium', $medium); $thumbnail->setAttribute('isDefault', 'false'); if (null !== $thumbnail_sd->get_width()) { $thumbnail->setAttribute('width', $thumbnail_sd->get_width()); } if (null !== $thumbnail_sd->get_height()) { $thumbnail->setAttribute('height', $thumbnail_sd->get_height()); } if (null !== $duration) { $thumbnail->setAttribute('duration', $duration); } } return $this; }
/** * Retrieve detailled informations about one feed entry item * * @param FeedItem $item * * @return array */ private function list_publication_entry_item(Application $app, FeedItem $item) { return ['item_id' => $item->getId(), 'record' => $this->list_record($app, $item->getRecord($app))]; }
/** * Retrieve detailed information about one feed entry item * * @param Request $request * @param FeedItem $item * @return array */ private function listPublicationEntryItem(Request $request, FeedItem $item) { return ['item_id' => $item->getId(), 'record' => $this->listRecord($request, $item->getRecord($this->app))]; }
/** * Retrieve detailled informations about one feed entry item * * @param FeedItem $item * @return array */ protected function list_publication_entry_item(FeedItem $item) { $datas = ['item_id' => $item->getId(), 'record' => $this->list_record($item->getRecord($this->app))]; return $datas; }
/** * {@inheritDoc} */ public function getRecord(\Alchemy\Phrasea\Application $app) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getRecord', array($app)); return parent::getRecord($app); }