SimplePie_Item

Manages all item-related data.

Defined (1)

The class is defined in the following location(s).

/wp-includes/SimplePie/Item.php  
  1. class SimplePie_Item 
  2. /** 
  3. * Parent feed 
  4. * @access private 
  5. * @var SimplePie 
  6. */ 
  7. var $feed; 
  8.  
  9. /** 
  10. * Raw data 
  11. * @access private 
  12. * @var array 
  13. */ 
  14. var $data = array(); 
  15.  
  16. /** 
  17. * Registry object 
  18. * @see set_registry 
  19. * @var SimplePie_Registry 
  20. */ 
  21. protected $registry; 
  22.  
  23. /** 
  24. * Create a new item object 
  25. * This is usually used by {@see SimplePie::get_items} and 
  26. * {@see SimplePie::get_item}. Avoid creating this manually. 
  27. * @param SimplePie $feed Parent feed 
  28. * @param array $data Raw data 
  29. */ 
  30. public function __construct($feed, $data) 
  31. $this->feed = $feed; 
  32. $this->data = $data; 
  33.  
  34. /** 
  35. * Set the registry handler 
  36. * This is usually used by {@see SimplePie_Registry::create} 
  37. * @since 1.3 
  38. * @param SimplePie_Registry $registry 
  39. */ 
  40. public function set_registry(SimplePie_Registry $registry) 
  41. $this->registry = $registry; 
  42.  
  43. /** 
  44. * Get a string representation of the item 
  45. * @return string 
  46. */ 
  47. public function __toString() 
  48. return md5(serialize($this->data)); 
  49.  
  50. /** 
  51. * Remove items that link back to this before destroying this object 
  52. */ 
  53. public function __destruct() 
  54. if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) 
  55. unset($this->feed); 
  56.  
  57. /** 
  58. * Get data for an item-level element 
  59. * This method allows you to get access to ANY element/attribute that is a 
  60. * sub-element of the item/entry tag. 
  61. * See {@see SimplePie::get_feed_tags()} for a description of the return value 
  62. * @since 1.0 
  63. * @see http://simplepie.org/wiki/faq/supported_xml_namespaces 
  64. * @param string $namespace The URL of the XML namespace of the elements you're trying to access 
  65. * @param string $tag Tag name 
  66. * @return array 
  67. */ 
  68. public function get_item_tags($namespace, $tag) 
  69. if (isset($this->data['child'][$namespace][$tag])) 
  70. return $this->data['child'][$namespace][$tag]; 
  71. else 
  72. return null; 
  73.  
  74. /** 
  75. * Get the base URL value from the parent feed 
  76. * Uses `<xml:base>` 
  77. * @param array $element 
  78. * @return string 
  79. */ 
  80. public function get_base($element = array()) 
  81. return $this->feed->get_base($element); 
  82.  
  83. /** 
  84. * Sanitize feed data 
  85. * @access private 
  86. * @see SimplePie::sanitize() 
  87. * @param string $data Data to sanitize 
  88. * @param int $type One of the SIMPLEPIE_CONSTRUCT_* constants 
  89. * @param string $base Base URL to resolve URLs against 
  90. * @return string Sanitized data 
  91. */ 
  92. public function sanitize($data, $type, $base = '') 
  93. return $this->feed->sanitize($data, $type, $base); 
  94.  
  95. /** 
  96. * Get the parent feed 
  97. * Note: this may not work as you think for multifeeds! 
  98. * @link http://simplepie.org/faq/typical_multifeed_gotchas#missing_data_from_feed 
  99. * @since 1.0 
  100. * @return SimplePie 
  101. */ 
  102. public function get_feed() 
  103. return $this->feed; 
  104.  
  105. /** 
  106. * Get the unique identifier for the item 
  107. * This is usually used when writing code to check for new items in a feed. 
  108. * Uses `<atom:id>`, `<guid>`, `<dc:identifier>` or the `about` attribute 
  109. * for RDF. If none of these are supplied (or `$hash` is true), creates an 
  110. * MD5 hash based on the permalink and title. If either of those are not 
  111. * supplied, creates a hash based on the full feed data. 
  112. * @since Beta 2 
  113. * @param boolean $hash Should we force using a hash instead of the supplied ID? 
  114. * @return string 
  115. */ 
  116. public function get_id($hash = false) 
  117. if (!$hash) 
  118. if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id')) 
  119. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  120. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id')) 
  121. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  122. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) 
  123. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  124. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier')) 
  125. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  126. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier')) 
  127. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  128. elseif (isset($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'])) 
  129. return $this->sanitize($this->data['attribs'][SIMPLEPIE_NAMESPACE_RDF]['about'], SIMPLEPIE_CONSTRUCT_TEXT); 
  130. elseif (($return = $this->get_permalink()) !== null) 
  131. return $return; 
  132. elseif (($return = $this->get_title()) !== null) 
  133. return $return; 
  134. if ($this->get_permalink() !== null || $this->get_title() !== null) 
  135. return md5($this->get_permalink() . $this->get_title()); 
  136. else 
  137. return md5(serialize($this->data)); 
  138.  
  139. /** 
  140. * Get the title of the item 
  141. * Uses `<atom:title>`, `<title>` or `<dc:title>` 
  142. * @since Beta 2 (previously called `get_item_title` since 0.8) 
  143. * @return string|null 
  144. */ 
  145. public function get_title() 
  146. if (!isset($this->data['title'])) 
  147. if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) 
  148. $this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); 
  149. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) 
  150. $this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); 
  151. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) 
  152. $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 
  153. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) 
  154. $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 
  155. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) 
  156. $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 
  157. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) 
  158. $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  159. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) 
  160. $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  161. else 
  162. $this->data['title'] = null; 
  163. return $this->data['title']; 
  164.  
  165. /** 
  166. * Get the content for the item 
  167. * Prefers summaries over full content , but will return full content if a 
  168. * summary does not exist. 
  169. * To prefer full content instead, use {@see get_content} 
  170. * Uses `<atom:summary>`, `<description>`, `<dc:description>` or 
  171. * `<itunes:subtitle>` 
  172. * @since 0.8 
  173. * @param boolean $description_only Should we avoid falling back to the content? 
  174. * @return string|null 
  175. */ 
  176. public function get_description($description_only = false) 
  177. if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) 
  178. return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); 
  179. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) 
  180. return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); 
  181. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) 
  182. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); 
  183. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) 
  184. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 
  185. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) 
  186. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  187. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) 
  188. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  189. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) 
  190. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 
  191. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) 
  192. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  193. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) 
  194. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML); 
  195.  
  196. elseif (!$description_only) 
  197. return $this->get_content(true); 
  198. else 
  199. return null; 
  200.  
  201. /** 
  202. * Get the content for the item 
  203. * Prefers full content over summaries, but will return a summary if full 
  204. * content does not exist. 
  205. * To prefer summaries instead, use {@see get_description} 
  206. * Uses `<atom:content>` or `<content:encoded>` (RSS 1.0 Content Module) 
  207. * @since 1.0 
  208. * @param boolean $content_only Should we avoid falling back to the description? 
  209. * @return string|null 
  210. */ 
  211. public function get_content($content_only = false) 
  212. if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) 
  213. return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); 
  214. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) 
  215. return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); 
  216. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) 
  217. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); 
  218. elseif (!$content_only) 
  219. return $this->get_description(true); 
  220. else 
  221. return null; 
  222.  
  223. /** 
  224. * Get a category for the item 
  225. * @since Beta 3 (previously called `get_categories()` since Beta 2) 
  226. * @param int $key The category that you want to return. Remember that arrays begin with 0, not 1 
  227. * @return SimplePie_Category|null 
  228. */ 
  229. public function get_category($key = 0) 
  230. $categories = $this->get_categories(); 
  231. if (isset($categories[$key])) 
  232. return $categories[$key]; 
  233. else 
  234. return null; 
  235.  
  236. /** 
  237. * Get all categories for the item 
  238. * Uses `<atom:category>`, `<category>` or `<dc:subject>` 
  239. * @since Beta 3 
  240. * @return array|null List of {@see SimplePie_Category} objects 
  241. */ 
  242. public function get_categories() 
  243. $categories = array(); 
  244.  
  245. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) 
  246. $term = null; 
  247. $scheme = null; 
  248. $label = null; 
  249. if (isset($category['attribs']['']['term'])) 
  250. $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); 
  251. if (isset($category['attribs']['']['scheme'])) 
  252. $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  253. if (isset($category['attribs']['']['label'])) 
  254. $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 
  255. $categories[] = $this->registry->create('Category', array($term, $scheme, $label)); 
  256. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) 
  257. // This is really the label, but keep this as the term also for BC. 
  258. // Label will also work on retrieving because that falls back to term. 
  259. $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  260. if (isset($category['attribs']['']['domain'])) 
  261. $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); 
  262. else 
  263. $scheme = null; 
  264. $categories[] = $this->registry->create('Category', array($term, $scheme, null)); 
  265. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) 
  266. $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); 
  267. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) 
  268. $categories[] = $this->registry->create('Category', array($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); 
  269.  
  270. if (!empty($categories)) 
  271. return array_unique($categories); 
  272. else 
  273. return null; 
  274.  
  275. /** 
  276. * Get an author for the item 
  277. * @since Beta 2 
  278. * @param int $key The author that you want to return. Remember that arrays begin with 0, not 1 
  279. * @return SimplePie_Author|null 
  280. */ 
  281. public function get_author($key = 0) 
  282. $authors = $this->get_authors(); 
  283. if (isset($authors[$key])) 
  284. return $authors[$key]; 
  285. else 
  286. return null; 
  287.  
  288. /** 
  289. * Get a contributor for the item 
  290. * @since 1.1 
  291. * @param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1 
  292. * @return SimplePie_Author|null 
  293. */ 
  294. public function get_contributor($key = 0) 
  295. $contributors = $this->get_contributors(); 
  296. if (isset($contributors[$key])) 
  297. return $contributors[$key]; 
  298. else 
  299. return null; 
  300.  
  301. /** 
  302. * Get all contributors for the item 
  303. * Uses `<atom:contributor>` 
  304. * @since 1.1 
  305. * @return array|null List of {@see SimplePie_Author} objects 
  306. */ 
  307. public function get_contributors() 
  308. $contributors = array(); 
  309. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) 
  310. $name = null; 
  311. $uri = null; 
  312. $email = null; 
  313. if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) 
  314. $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  315. if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) 
  316. $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); 
  317. if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) 
  318. $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  319. if ($name !== null || $email !== null || $uri !== null) 
  320. $contributors[] = $this->registry->create('Author', array($name, $uri, $email)); 
  321. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) 
  322. $name = null; 
  323. $url = null; 
  324. $email = null; 
  325. if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) 
  326. $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  327. if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) 
  328. $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); 
  329. if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) 
  330. $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  331. if ($name !== null || $email !== null || $url !== null) 
  332. $contributors[] = $this->registry->create('Author', array($name, $url, $email)); 
  333.  
  334. if (!empty($contributors)) 
  335. return array_unique($contributors); 
  336. else 
  337. return null; 
  338.  
  339. /** 
  340. * Get all authors for the item 
  341. * Uses `<atom:author>`, `<author>`, `<dc:creator>` or `<itunes:author>` 
  342. * @since Beta 2 
  343. * @return array|null List of {@see SimplePie_Author} objects 
  344. */ 
  345. public function get_authors() 
  346. $authors = array(); 
  347. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) 
  348. $name = null; 
  349. $uri = null; 
  350. $email = null; 
  351. if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) 
  352. $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  353. if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) 
  354. $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); 
  355. if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) 
  356. $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  357. if ($name !== null || $email !== null || $uri !== null) 
  358. $authors[] = $this->registry->create('Author', array($name, $uri, $email)); 
  359. if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) 
  360. $name = null; 
  361. $url = null; 
  362. $email = null; 
  363. if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) 
  364. $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  365. if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) 
  366. $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); 
  367. if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) 
  368. $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  369. if ($name !== null || $email !== null || $url !== null) 
  370. $authors[] = $this->registry->create('Author', array($name, $url, $email)); 
  371. if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author')) 
  372. $authors[] = $this->registry->create('Author', array(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT))); 
  373. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) 
  374. $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); 
  375. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) 
  376. $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); 
  377. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) 
  378. $authors[] = $this->registry->create('Author', array($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null)); 
  379.  
  380. if (!empty($authors)) 
  381. return array_unique($authors); 
  382. elseif (($source = $this->get_source()) && ($authors = $source->get_authors())) 
  383. return $authors; 
  384. elseif ($authors = $this->feed->get_authors()) 
  385. return $authors; 
  386. else 
  387. return null; 
  388.  
  389. /** 
  390. * Get the copyright info for the item 
  391. * Uses `<atom:rights>` or `<dc:rights>` 
  392. * @since 1.1 
  393. * @return string 
  394. */ 
  395. public function get_copyright() 
  396. if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) 
  397. return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($return[0]['attribs'])), $this->get_base($return[0])); 
  398. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) 
  399. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  400. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) 
  401. return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  402. else 
  403. return null; 
  404.  
  405. /** 
  406. * Get the posting date/time for the item 
  407. * Uses `<atom:published>`, `<atom:updated>`, `<atom:issued>`,  
  408. * `<atom:modified>`, `<pubDate>` or `<dc:date>` 
  409. * Note: obeys PHP's timezone setting. To get a UTC date/time, use 
  410. * {@see get_gmdate} 
  411. * @since Beta 2 (previously called `get_item_date` since 0.8) 
  412. * @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data) 
  413. * @return int|string|null 
  414. */ 
  415. public function get_date($date_format = 'j F Y, g:i a') 
  416. if (!isset($this->data['date'])) 
  417. if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published')) 
  418. $this->data['date']['raw'] = $return[0]['data']; 
  419. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) 
  420. $this->data['date']['raw'] = $return[0]['data']; 
  421. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued')) 
  422. $this->data['date']['raw'] = $return[0]['data']; 
  423. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created')) 
  424. $this->data['date']['raw'] = $return[0]['data']; 
  425. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified')) 
  426. $this->data['date']['raw'] = $return[0]['data']; 
  427. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate')) 
  428. $this->data['date']['raw'] = $return[0]['data']; 
  429. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date')) 
  430. $this->data['date']['raw'] = $return[0]['data']; 
  431. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date')) 
  432. $this->data['date']['raw'] = $return[0]['data']; 
  433.  
  434. if (!empty($this->data['date']['raw'])) 
  435. $parser = $this->registry->call('Parse_Date', 'get'); 
  436. $this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']); 
  437. else 
  438. $this->data['date'] = null; 
  439. if ($this->data['date']) 
  440. $date_format = (string) $date_format; 
  441. switch ($date_format) 
  442. case '': 
  443. return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT); 
  444.  
  445. case 'U': 
  446. return $this->data['date']['parsed']; 
  447.  
  448. default: 
  449. return date($date_format, $this->data['date']['parsed']); 
  450. else 
  451. return null; 
  452.  
  453. /** 
  454. * Get the update date/time for the item 
  455. * Uses `<atom:updated>` 
  456. * Note: obeys PHP's timezone setting. To get a UTC date/time, use 
  457. * {@see get_gmdate} 
  458. * @param string $date_format Supports any PHP date format from {@see http://php.net/date} (empty for the raw data) 
  459. * @return int|string|null 
  460. */ 
  461. public function get_updated_date($date_format = 'j F Y, g:i a') 
  462. if (!isset($this->data['updated'])) 
  463. if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) 
  464. $this->data['updated']['raw'] = $return[0]['data']; 
  465.  
  466. if (!empty($this->data['updated']['raw'])) 
  467. $parser = $this->registry->call('Parse_Date', 'get'); 
  468. $this->data['updated']['parsed'] = $parser->parse($this->data['date']['raw']); 
  469. else 
  470. $this->data['updated'] = null; 
  471. if ($this->data['updated']) 
  472. $date_format = (string) $date_format; 
  473. switch ($date_format) 
  474. case '': 
  475. return $this->sanitize($this->data['updated']['raw'], SIMPLEPIE_CONSTRUCT_TEXT); 
  476.  
  477. case 'U': 
  478. return $this->data['updated']['parsed']; 
  479.  
  480. default: 
  481. return date($date_format, $this->data['updated']['parsed']); 
  482. else 
  483. return null; 
  484.  
  485. /** 
  486. * Get the localized posting date/time for the item 
  487. * Returns the date formatted in the localized language. To display in 
  488. * languages other than the server's default, you need to change the locale 
  489. * with {@link http://php.net/setlocale setlocale()}. The available 
  490. * localizations depend on which ones are installed on your web server. 
  491. * @since 1.0 
  492. * @param string $date_format Supports any PHP date format from {@see http://php.net/strftime} (empty for the raw data) 
  493. * @return int|string|null 
  494. */ 
  495. public function get_local_date($date_format = '%c') 
  496. if (!$date_format) 
  497. return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT); 
  498. elseif (($date = $this->get_date('U')) !== null && $date !== false) 
  499. return strftime($date_format, $date); 
  500. else 
  501. return null; 
  502.  
  503. /** 
  504. * Get the posting date/time for the item (UTC time) 
  505. * @see get_date 
  506. * @param string $date_format Supports any PHP date format from {@see http://php.net/date} 
  507. * @return int|string|null 
  508. */ 
  509. public function get_gmdate($date_format = 'j F Y, g:i a') 
  510. $date = $this->get_date('U'); 
  511. if ($date === null) 
  512. return null; 
  513.  
  514. return gmdate($date_format, $date); 
  515.  
  516. /** 
  517. * Get the update date/time for the item (UTC time) 
  518. * @see get_updated_date 
  519. * @param string $date_format Supports any PHP date format from {@see http://php.net/date} 
  520. * @return int|string|null 
  521. */ 
  522. public function get_updated_gmdate($date_format = 'j F Y, g:i a') 
  523. $date = $this->get_updated_date('U'); 
  524. if ($date === null) 
  525. return null; 
  526.  
  527. return gmdate($date_format, $date); 
  528.  
  529. /** 
  530. * Get the permalink for the item 
  531. * Returns the first link available with a relationship of "alternate". 
  532. * Identical to {@see get_link()} with key 0 
  533. * @see get_link 
  534. * @since 0.8 
  535. * @return string|null Permalink URL 
  536. */ 
  537. public function get_permalink() 
  538. $link = $this->get_link(); 
  539. $enclosure = $this->get_enclosure(0); 
  540. if ($link !== null) 
  541. return $link; 
  542. elseif ($enclosure !== null) 
  543. return $enclosure->get_link(); 
  544. else 
  545. return null; 
  546.  
  547. /** 
  548. * Get a single link for the item 
  549. * @since Beta 3 
  550. * @param int $key The link that you want to return. Remember that arrays begin with 0, not 1 
  551. * @param string $rel The relationship of the link to return 
  552. * @return string|null Link URL 
  553. */ 
  554. public function get_link($key = 0, $rel = 'alternate') 
  555. $links = $this->get_links($rel); 
  556. if ($links[$key] !== null) 
  557. return $links[$key]; 
  558. else 
  559. return null; 
  560.  
  561. /** 
  562. * Get all links for the item 
  563. * Uses `<atom:link>`, `<link>` or `<guid>` 
  564. * @since Beta 2 
  565. * @param string $rel The relationship of links to return 
  566. * @return array|null Links found for the item (strings) 
  567. */ 
  568. public function get_links($rel = 'alternate') 
  569. if (!isset($this->data['links'])) 
  570. $this->data['links'] = array(); 
  571. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) 
  572. if (isset($link['attribs']['']['href'])) 
  573. $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; 
  574. $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); 
  575.  
  576. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) 
  577. if (isset($link['attribs']['']['href'])) 
  578. $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; 
  579. $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); 
  580. if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) 
  581. $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); 
  582. if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) 
  583. $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); 
  584. if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) 
  585. $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); 
  586. if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) 
  587. if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true') 
  588. $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); 
  589.  
  590. $keys = array_keys($this->data['links']); 
  591. foreach ($keys as $key) 
  592. if ($this->registry->call('Misc', 'is_isegment_nz_nc', array($key))) 
  593. if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) 
  594. $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); 
  595. $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; 
  596. else 
  597. $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; 
  598. elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) 
  599. $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; 
  600. $this->data['links'][$key] = array_unique($this->data['links'][$key]); 
  601. if (isset($this->data['links'][$rel])) 
  602. return $this->data['links'][$rel]; 
  603. else 
  604. return null; 
  605.  
  606. /** 
  607. * Get an enclosure from the item 
  608. * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS. 
  609. * @since Beta 2 
  610. * @todo Add ability to prefer one type of content over another (in a media group). 
  611. * @param int $key The enclosure that you want to return. Remember that arrays begin with 0, not 1 
  612. * @return SimplePie_Enclosure|null 
  613. */ 
  614. public function get_enclosure($key = 0, $prefer = null) 
  615. $enclosures = $this->get_enclosures(); 
  616. if (isset($enclosures[$key])) 
  617. return $enclosures[$key]; 
  618. else 
  619. return null; 
  620.  
  621. /** 
  622. * Get all available enclosures (podcasts, etc.) 
  623. * Supports the <enclosure> RSS tag, as well as Media RSS and iTunes RSS. 
  624. * At this point, we're pretty much assuming that all enclosures for an item 
  625. * are the same content. Anything else is too complicated to 
  626. * properly support. 
  627. * @since Beta 2 
  628. * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4). 
  629. * @todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists). 
  630. * @return array|null List of SimplePie_Enclosure items 
  631. */ 
  632. public function get_enclosures() 
  633. if (!isset($this->data['enclosures'])) 
  634. $this->data['enclosures'] = array(); 
  635.  
  636. // Elements 
  637. $captions_parent = null; 
  638. $categories_parent = null; 
  639. $copyrights_parent = null; 
  640. $credits_parent = null; 
  641. $description_parent = null; 
  642. $duration_parent = null; 
  643. $hashes_parent = null; 
  644. $keywords_parent = null; 
  645. $player_parent = null; 
  646. $ratings_parent = null; 
  647. $restrictions_parent = null; 
  648. $thumbnails_parent = null; 
  649. $title_parent = null; 
  650.  
  651. // Let's do the channel and item-level ones first, and just re-use them if we need to. 
  652. $parent = $this->get_feed(); 
  653.  
  654. // CAPTIONS 
  655. if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) 
  656. foreach ($captions as $caption) 
  657. $caption_type = null; 
  658. $caption_lang = null; 
  659. $caption_startTime = null; 
  660. $caption_endTime = null; 
  661. $caption_text = null; 
  662. if (isset($caption['attribs']['']['type'])) 
  663. $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  664. if (isset($caption['attribs']['']['lang'])) 
  665. $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 
  666. if (isset($caption['attribs']['']['start'])) 
  667. $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); 
  668. if (isset($caption['attribs']['']['end'])) 
  669. $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); 
  670. if (isset($caption['data'])) 
  671. $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  672. $captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); 
  673. elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) 
  674. foreach ($captions as $caption) 
  675. $caption_type = null; 
  676. $caption_lang = null; 
  677. $caption_startTime = null; 
  678. $caption_endTime = null; 
  679. $caption_text = null; 
  680. if (isset($caption['attribs']['']['type'])) 
  681. $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  682. if (isset($caption['attribs']['']['lang'])) 
  683. $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 
  684. if (isset($caption['attribs']['']['start'])) 
  685. $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); 
  686. if (isset($caption['attribs']['']['end'])) 
  687. $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); 
  688. if (isset($caption['data'])) 
  689. $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  690. $captions_parent[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); 
  691. if (is_array($captions_parent)) 
  692. $captions_parent = array_values(array_unique($captions_parent)); 
  693.  
  694. // CATEGORIES 
  695. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) 
  696. $term = null; 
  697. $scheme = null; 
  698. $label = null; 
  699. if (isset($category['data'])) 
  700. $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  701. if (isset($category['attribs']['']['scheme'])) 
  702. $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  703. else 
  704. $scheme = 'http://search.yahoo.com/mrss/category_schema'; 
  705. if (isset($category['attribs']['']['label'])) 
  706. $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 
  707. $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); 
  708. foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) 
  709. $term = null; 
  710. $scheme = null; 
  711. $label = null; 
  712. if (isset($category['data'])) 
  713. $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  714. if (isset($category['attribs']['']['scheme'])) 
  715. $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  716. else 
  717. $scheme = 'http://search.yahoo.com/mrss/category_schema'; 
  718. if (isset($category['attribs']['']['label'])) 
  719. $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 
  720. $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); 
  721. foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category) 
  722. $term = null; 
  723. $scheme = 'http://www.itunes.com/dtds/podcast-1.0.dtd'; 
  724. $label = null; 
  725. if (isset($category['attribs']['']['text'])) 
  726. $label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); 
  727. $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); 
  728.  
  729. if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'])) 
  730. foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory) 
  731. if (isset($subcategory['attribs']['']['text'])) 
  732. $label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); 
  733. $categories_parent[] = $this->registry->create('Category', array($term, $scheme, $label)); 
  734. if (is_array($categories_parent)) 
  735. $categories_parent = array_values(array_unique($categories_parent)); 
  736.  
  737. // COPYRIGHT 
  738. if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) 
  739. $copyright_url = null; 
  740. $copyright_label = null; 
  741. if (isset($copyright[0]['attribs']['']['url'])) 
  742. $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); 
  743. if (isset($copyright[0]['data'])) 
  744. $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  745. $copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); 
  746. elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) 
  747. $copyright_url = null; 
  748. $copyright_label = null; 
  749. if (isset($copyright[0]['attribs']['']['url'])) 
  750. $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); 
  751. if (isset($copyright[0]['data'])) 
  752. $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  753. $copyrights_parent = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); 
  754.  
  755. // CREDITS 
  756. if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) 
  757. foreach ($credits as $credit) 
  758. $credit_role = null; 
  759. $credit_scheme = null; 
  760. $credit_name = null; 
  761. if (isset($credit['attribs']['']['role'])) 
  762. $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); 
  763. if (isset($credit['attribs']['']['scheme'])) 
  764. $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  765. else 
  766. $credit_scheme = 'urn:ebu'; 
  767. if (isset($credit['data'])) 
  768. $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  769. $credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); 
  770. elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) 
  771. foreach ($credits as $credit) 
  772. $credit_role = null; 
  773. $credit_scheme = null; 
  774. $credit_name = null; 
  775. if (isset($credit['attribs']['']['role'])) 
  776. $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); 
  777. if (isset($credit['attribs']['']['scheme'])) 
  778. $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  779. else 
  780. $credit_scheme = 'urn:ebu'; 
  781. if (isset($credit['data'])) 
  782. $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  783. $credits_parent[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); 
  784. if (is_array($credits_parent)) 
  785. $credits_parent = array_values(array_unique($credits_parent)); 
  786.  
  787. // DESCRIPTION 
  788. if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) 
  789. if (isset($description_parent[0]['data'])) 
  790. $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  791. elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) 
  792. if (isset($description_parent[0]['data'])) 
  793. $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  794.  
  795. // DURATION 
  796. if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration')) 
  797. $seconds = null; 
  798. $minutes = null; 
  799. $hours = null; 
  800. if (isset($duration_parent[0]['data'])) 
  801. $temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 
  802. if (sizeof($temp) > 0) 
  803. $seconds = (int) array_pop($temp); 
  804. if (sizeof($temp) > 0) 
  805. $minutes = (int) array_pop($temp); 
  806. $seconds += $minutes * 60; 
  807. if (sizeof($temp) > 0) 
  808. $hours = (int) array_pop($temp); 
  809. $seconds += $hours * 3600; 
  810. unset($temp); 
  811. $duration_parent = $seconds; 
  812.  
  813. // HASHES 
  814. if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) 
  815. foreach ($hashes_iterator as $hash) 
  816. $value = null; 
  817. $algo = null; 
  818. if (isset($hash['data'])) 
  819. $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  820. if (isset($hash['attribs']['']['algo'])) 
  821. $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); 
  822. else 
  823. $algo = 'md5'; 
  824. $hashes_parent[] = $algo.':'.$value; 
  825. elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) 
  826. foreach ($hashes_iterator as $hash) 
  827. $value = null; 
  828. $algo = null; 
  829. if (isset($hash['data'])) 
  830. $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  831. if (isset($hash['attribs']['']['algo'])) 
  832. $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); 
  833. else 
  834. $algo = 'md5'; 
  835. $hashes_parent[] = $algo.':'.$value; 
  836. if (is_array($hashes_parent)) 
  837. $hashes_parent = array_values(array_unique($hashes_parent)); 
  838.  
  839. // KEYWORDS 
  840. if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) 
  841. if (isset($keywords[0]['data'])) 
  842. $temp = explode(', ', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 
  843. foreach ($temp as $word) 
  844. $keywords_parent[] = trim($word); 
  845. unset($temp); 
  846. elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) 
  847. if (isset($keywords[0]['data'])) 
  848. $temp = explode(', ', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 
  849. foreach ($temp as $word) 
  850. $keywords_parent[] = trim($word); 
  851. unset($temp); 
  852. elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) 
  853. if (isset($keywords[0]['data'])) 
  854. $temp = explode(', ', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 
  855. foreach ($temp as $word) 
  856. $keywords_parent[] = trim($word); 
  857. unset($temp); 
  858. elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) 
  859. if (isset($keywords[0]['data'])) 
  860. $temp = explode(', ', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 
  861. foreach ($temp as $word) 
  862. $keywords_parent[] = trim($word); 
  863. unset($temp); 
  864. if (is_array($keywords_parent)) 
  865. $keywords_parent = array_values(array_unique($keywords_parent)); 
  866.  
  867. // PLAYER 
  868. if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) 
  869. if (isset($player_parent[0]['attribs']['']['url'])) 
  870. $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 
  871. elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) 
  872. if (isset($player_parent[0]['attribs']['']['url'])) 
  873. $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 
  874.  
  875. // RATINGS 
  876. if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) 
  877. foreach ($ratings as $rating) 
  878. $rating_scheme = null; 
  879. $rating_value = null; 
  880. if (isset($rating['attribs']['']['scheme'])) 
  881. $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  882. else 
  883. $rating_scheme = 'urn:simple'; 
  884. if (isset($rating['data'])) 
  885. $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  886. $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); 
  887. elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) 
  888. foreach ($ratings as $rating) 
  889. $rating_scheme = 'urn:itunes'; 
  890. $rating_value = null; 
  891. if (isset($rating['data'])) 
  892. $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  893. $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); 
  894. elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) 
  895. foreach ($ratings as $rating) 
  896. $rating_scheme = null; 
  897. $rating_value = null; 
  898. if (isset($rating['attribs']['']['scheme'])) 
  899. $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  900. else 
  901. $rating_scheme = 'urn:simple'; 
  902. if (isset($rating['data'])) 
  903. $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  904. $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); 
  905. elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) 
  906. foreach ($ratings as $rating) 
  907. $rating_scheme = 'urn:itunes'; 
  908. $rating_value = null; 
  909. if (isset($rating['data'])) 
  910. $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  911. $ratings_parent[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); 
  912. if (is_array($ratings_parent)) 
  913. $ratings_parent = array_values(array_unique($ratings_parent)); 
  914.  
  915. // RESTRICTIONS 
  916. if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) 
  917. foreach ($restrictions as $restriction) 
  918. $restriction_relationship = null; 
  919. $restriction_type = null; 
  920. $restriction_value = null; 
  921. if (isset($restriction['attribs']['']['relationship'])) 
  922. $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); 
  923. if (isset($restriction['attribs']['']['type'])) 
  924. $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  925. if (isset($restriction['data'])) 
  926. $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  927. $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); 
  928. elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) 
  929. foreach ($restrictions as $restriction) 
  930. $restriction_relationship = 'allow'; 
  931. $restriction_type = null; 
  932. $restriction_value = 'itunes'; 
  933. if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') 
  934. $restriction_relationship = 'deny'; 
  935. $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); 
  936. elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) 
  937. foreach ($restrictions as $restriction) 
  938. $restriction_relationship = null; 
  939. $restriction_type = null; 
  940. $restriction_value = null; 
  941. if (isset($restriction['attribs']['']['relationship'])) 
  942. $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); 
  943. if (isset($restriction['attribs']['']['type'])) 
  944. $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  945. if (isset($restriction['data'])) 
  946. $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  947. $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); 
  948. elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) 
  949. foreach ($restrictions as $restriction) 
  950. $restriction_relationship = 'allow'; 
  951. $restriction_type = null; 
  952. $restriction_value = 'itunes'; 
  953. if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') 
  954. $restriction_relationship = 'deny'; 
  955. $restrictions_parent[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); 
  956. if (is_array($restrictions_parent)) 
  957. $restrictions_parent = array_values(array_unique($restrictions_parent)); 
  958. else 
  959. $restrictions_parent = array(new SimplePie_Restriction('allow', null, 'default')); 
  960.  
  961. // THUMBNAILS 
  962. if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) 
  963. foreach ($thumbnails as $thumbnail) 
  964. if (isset($thumbnail['attribs']['']['url'])) 
  965. $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 
  966. elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) 
  967. foreach ($thumbnails as $thumbnail) 
  968. if (isset($thumbnail['attribs']['']['url'])) 
  969. $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 
  970.  
  971. // TITLES 
  972. if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) 
  973. if (isset($title_parent[0]['data'])) 
  974. $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  975. elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) 
  976. if (isset($title_parent[0]['data'])) 
  977. $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  978.  
  979. // Clear the memory 
  980. unset($parent); 
  981.  
  982. // Attributes 
  983. $bitrate = null; 
  984. $channels = null; 
  985. $duration = null; 
  986. $expression = null; 
  987. $framerate = null; 
  988. $height = null; 
  989. $javascript = null; 
  990. $lang = null; 
  991. $length = null; 
  992. $medium = null; 
  993. $samplingrate = null; 
  994. $type = null; 
  995. $url = null; 
  996. $width = null; 
  997.  
  998. // Elements 
  999. $captions = null; 
  1000. $categories = null; 
  1001. $copyrights = null; 
  1002. $credits = null; 
  1003. $description = null; 
  1004. $hashes = null; 
  1005. $keywords = null; 
  1006. $player = null; 
  1007. $ratings = null; 
  1008. $restrictions = null; 
  1009. $thumbnails = null; 
  1010. $title = null; 
  1011.  
  1012. // If we have media:group tags, loop through them. 
  1013. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group) 
  1014. if(isset($group['child']) && isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) 
  1015. // If we have media:content tags, loop through them. 
  1016. foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) 
  1017. if (isset($content['attribs']['']['url'])) 
  1018. // Attributes 
  1019. $bitrate = null; 
  1020. $channels = null; 
  1021. $duration = null; 
  1022. $expression = null; 
  1023. $framerate = null; 
  1024. $height = null; 
  1025. $javascript = null; 
  1026. $lang = null; 
  1027. $length = null; 
  1028. $medium = null; 
  1029. $samplingrate = null; 
  1030. $type = null; 
  1031. $url = null; 
  1032. $width = null; 
  1033.  
  1034. // Elements 
  1035. $captions = null; 
  1036. $categories = null; 
  1037. $copyrights = null; 
  1038. $credits = null; 
  1039. $description = null; 
  1040. $hashes = null; 
  1041. $keywords = null; 
  1042. $player = null; 
  1043. $ratings = null; 
  1044. $restrictions = null; 
  1045. $thumbnails = null; 
  1046. $title = null; 
  1047.  
  1048. // Start checking the attributes of media:content 
  1049. if (isset($content['attribs']['']['bitrate'])) 
  1050. $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1051. if (isset($content['attribs']['']['channels'])) 
  1052. $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1053. if (isset($content['attribs']['']['duration'])) 
  1054. $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1055. else 
  1056. $duration = $duration_parent; 
  1057. if (isset($content['attribs']['']['expression'])) 
  1058. $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1059. if (isset($content['attribs']['']['framerate'])) 
  1060. $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1061. if (isset($content['attribs']['']['height'])) 
  1062. $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1063. if (isset($content['attribs']['']['lang'])) 
  1064. $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1065. if (isset($content['attribs']['']['fileSize'])) 
  1066. $length = ceil($content['attribs']['']['fileSize']); 
  1067. if (isset($content['attribs']['']['medium'])) 
  1068. $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1069. if (isset($content['attribs']['']['samplingrate'])) 
  1070. $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1071. if (isset($content['attribs']['']['type'])) 
  1072. $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1073. if (isset($content['attribs']['']['width'])) 
  1074. $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1075. $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 
  1076.  
  1077. // Checking the other optional media: elements. Priority: media:content, media:group, item, channel 
  1078.  
  1079. // CAPTIONS 
  1080. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) 
  1081. foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) 
  1082. $caption_type = null; 
  1083. $caption_lang = null; 
  1084. $caption_startTime = null; 
  1085. $caption_endTime = null; 
  1086. $caption_text = null; 
  1087. if (isset($caption['attribs']['']['type'])) 
  1088. $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1089. if (isset($caption['attribs']['']['lang'])) 
  1090. $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1091. if (isset($caption['attribs']['']['start'])) 
  1092. $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1093. if (isset($caption['attribs']['']['end'])) 
  1094. $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1095. if (isset($caption['data'])) 
  1096. $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1097. $captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); 
  1098. if (is_array($captions)) 
  1099. $captions = array_values(array_unique($captions)); 
  1100. elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) 
  1101. foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) 
  1102. $caption_type = null; 
  1103. $caption_lang = null; 
  1104. $caption_startTime = null; 
  1105. $caption_endTime = null; 
  1106. $caption_text = null; 
  1107. if (isset($caption['attribs']['']['type'])) 
  1108. $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1109. if (isset($caption['attribs']['']['lang'])) 
  1110. $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1111. if (isset($caption['attribs']['']['start'])) 
  1112. $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1113. if (isset($caption['attribs']['']['end'])) 
  1114. $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1115. if (isset($caption['data'])) 
  1116. $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1117. $captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); 
  1118. if (is_array($captions)) 
  1119. $captions = array_values(array_unique($captions)); 
  1120. else 
  1121. $captions = $captions_parent; 
  1122.  
  1123. // CATEGORIES 
  1124. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) 
  1125. foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) 
  1126. $term = null; 
  1127. $scheme = null; 
  1128. $label = null; 
  1129. if (isset($category['data'])) 
  1130. $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1131. if (isset($category['attribs']['']['scheme'])) 
  1132. $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1133. else 
  1134. $scheme = 'http://search.yahoo.com/mrss/category_schema'; 
  1135. if (isset($category['attribs']['']['label'])) 
  1136. $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1137. $categories[] = $this->registry->create('Category', array($term, $scheme, $label)); 
  1138. if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) 
  1139. foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) 
  1140. $term = null; 
  1141. $scheme = null; 
  1142. $label = null; 
  1143. if (isset($category['data'])) 
  1144. $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1145. if (isset($category['attribs']['']['scheme'])) 
  1146. $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1147. else 
  1148. $scheme = 'http://search.yahoo.com/mrss/category_schema'; 
  1149. if (isset($category['attribs']['']['label'])) 
  1150. $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1151. $categories[] = $this->registry->create('Category', array($term, $scheme, $label)); 
  1152. if (is_array($categories) && is_array($categories_parent)) 
  1153. $categories = array_values(array_unique(array_merge($categories, $categories_parent))); 
  1154. elseif (is_array($categories)) 
  1155. $categories = array_values(array_unique($categories)); 
  1156. elseif (is_array($categories_parent)) 
  1157. $categories = array_values(array_unique($categories_parent)); 
  1158.  
  1159. // COPYRIGHTS 
  1160. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) 
  1161. $copyright_url = null; 
  1162. $copyright_label = null; 
  1163. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) 
  1164. $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1165. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) 
  1166. $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1167. $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); 
  1168. elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) 
  1169. $copyright_url = null; 
  1170. $copyright_label = null; 
  1171. if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) 
  1172. $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1173. if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) 
  1174. $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1175. $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); 
  1176. else 
  1177. $copyrights = $copyrights_parent; 
  1178.  
  1179. // CREDITS 
  1180. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) 
  1181. foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) 
  1182. $credit_role = null; 
  1183. $credit_scheme = null; 
  1184. $credit_name = null; 
  1185. if (isset($credit['attribs']['']['role'])) 
  1186. $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1187. if (isset($credit['attribs']['']['scheme'])) 
  1188. $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1189. else 
  1190. $credit_scheme = 'urn:ebu'; 
  1191. if (isset($credit['data'])) 
  1192. $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1193. $credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); 
  1194. if (is_array($credits)) 
  1195. $credits = array_values(array_unique($credits)); 
  1196. elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) 
  1197. foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) 
  1198. $credit_role = null; 
  1199. $credit_scheme = null; 
  1200. $credit_name = null; 
  1201. if (isset($credit['attribs']['']['role'])) 
  1202. $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1203. if (isset($credit['attribs']['']['scheme'])) 
  1204. $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1205. else 
  1206. $credit_scheme = 'urn:ebu'; 
  1207. if (isset($credit['data'])) 
  1208. $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1209. $credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); 
  1210. if (is_array($credits)) 
  1211. $credits = array_values(array_unique($credits)); 
  1212. else 
  1213. $credits = $credits_parent; 
  1214.  
  1215. // DESCRIPTION 
  1216. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) 
  1217. $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1218. elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) 
  1219. $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1220. else 
  1221. $description = $description_parent; 
  1222.  
  1223. // HASHES 
  1224. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) 
  1225. foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) 
  1226. $value = null; 
  1227. $algo = null; 
  1228. if (isset($hash['data'])) 
  1229. $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1230. if (isset($hash['attribs']['']['algo'])) 
  1231. $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1232. else 
  1233. $algo = 'md5'; 
  1234. $hashes[] = $algo.':'.$value; 
  1235. if (is_array($hashes)) 
  1236. $hashes = array_values(array_unique($hashes)); 
  1237. elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) 
  1238. foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) 
  1239. $value = null; 
  1240. $algo = null; 
  1241. if (isset($hash['data'])) 
  1242. $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1243. if (isset($hash['attribs']['']['algo'])) 
  1244. $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1245. else 
  1246. $algo = 'md5'; 
  1247. $hashes[] = $algo.':'.$value; 
  1248. if (is_array($hashes)) 
  1249. $hashes = array_values(array_unique($hashes)); 
  1250. else 
  1251. $hashes = $hashes_parent; 
  1252.  
  1253. // KEYWORDS 
  1254. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) 
  1255. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) 
  1256. $temp = explode(', ', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 
  1257. foreach ($temp as $word) 
  1258. $keywords[] = trim($word); 
  1259. unset($temp); 
  1260. if (is_array($keywords)) 
  1261. $keywords = array_values(array_unique($keywords)); 
  1262. elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) 
  1263. if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) 
  1264. $temp = explode(', ', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 
  1265. foreach ($temp as $word) 
  1266. $keywords[] = trim($word); 
  1267. unset($temp); 
  1268. if (is_array($keywords)) 
  1269. $keywords = array_values(array_unique($keywords)); 
  1270. else 
  1271. $keywords = $keywords_parent; 
  1272.  
  1273. // PLAYER 
  1274. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) 
  1275. $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 
  1276. elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) 
  1277. $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 
  1278. else 
  1279. $player = $player_parent; 
  1280.  
  1281. // RATINGS 
  1282. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) 
  1283. foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) 
  1284. $rating_scheme = null; 
  1285. $rating_value = null; 
  1286. if (isset($rating['attribs']['']['scheme'])) 
  1287. $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1288. else 
  1289. $rating_scheme = 'urn:simple'; 
  1290. if (isset($rating['data'])) 
  1291. $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1292. $ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); 
  1293. if (is_array($ratings)) 
  1294. $ratings = array_values(array_unique($ratings)); 
  1295. elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) 
  1296. foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) 
  1297. $rating_scheme = null; 
  1298. $rating_value = null; 
  1299. if (isset($rating['attribs']['']['scheme'])) 
  1300. $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1301. else 
  1302. $rating_scheme = 'urn:simple'; 
  1303. if (isset($rating['data'])) 
  1304. $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1305. $ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); 
  1306. if (is_array($ratings)) 
  1307. $ratings = array_values(array_unique($ratings)); 
  1308. else 
  1309. $ratings = $ratings_parent; 
  1310.  
  1311. // RESTRICTIONS 
  1312. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) 
  1313. foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) 
  1314. $restriction_relationship = null; 
  1315. $restriction_type = null; 
  1316. $restriction_value = null; 
  1317. if (isset($restriction['attribs']['']['relationship'])) 
  1318. $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1319. if (isset($restriction['attribs']['']['type'])) 
  1320. $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1321. if (isset($restriction['data'])) 
  1322. $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1323. $restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); 
  1324. if (is_array($restrictions)) 
  1325. $restrictions = array_values(array_unique($restrictions)); 
  1326. elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) 
  1327. foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) 
  1328. $restriction_relationship = null; 
  1329. $restriction_type = null; 
  1330. $restriction_value = null; 
  1331. if (isset($restriction['attribs']['']['relationship'])) 
  1332. $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1333. if (isset($restriction['attribs']['']['type'])) 
  1334. $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1335. if (isset($restriction['data'])) 
  1336. $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1337. $restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); 
  1338. if (is_array($restrictions)) 
  1339. $restrictions = array_values(array_unique($restrictions)); 
  1340. else 
  1341. $restrictions = $restrictions_parent; 
  1342.  
  1343. // THUMBNAILS 
  1344. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) 
  1345. foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) 
  1346. $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 
  1347. if (is_array($thumbnails)) 
  1348. $thumbnails = array_values(array_unique($thumbnails)); 
  1349. elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) 
  1350. foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) 
  1351. $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 
  1352. if (is_array($thumbnails)) 
  1353. $thumbnails = array_values(array_unique($thumbnails)); 
  1354. else 
  1355. $thumbnails = $thumbnails_parent; 
  1356.  
  1357. // TITLES 
  1358. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) 
  1359. $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1360. elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) 
  1361. $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1362. else 
  1363. $title = $title_parent; 
  1364.  
  1365. $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width)); 
  1366.  
  1367. // If we have standalone media:content tags, loop through them. 
  1368. if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) 
  1369. foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) 
  1370. if (isset($content['attribs']['']['url']) || isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) 
  1371. // Attributes 
  1372. $bitrate = null; 
  1373. $channels = null; 
  1374. $duration = null; 
  1375. $expression = null; 
  1376. $framerate = null; 
  1377. $height = null; 
  1378. $javascript = null; 
  1379. $lang = null; 
  1380. $length = null; 
  1381. $medium = null; 
  1382. $samplingrate = null; 
  1383. $type = null; 
  1384. $url = null; 
  1385. $width = null; 
  1386.  
  1387. // Elements 
  1388. $captions = null; 
  1389. $categories = null; 
  1390. $copyrights = null; 
  1391. $credits = null; 
  1392. $description = null; 
  1393. $hashes = null; 
  1394. $keywords = null; 
  1395. $player = null; 
  1396. $ratings = null; 
  1397. $restrictions = null; 
  1398. $thumbnails = null; 
  1399. $title = null; 
  1400.  
  1401. // Start checking the attributes of media:content 
  1402. if (isset($content['attribs']['']['bitrate'])) 
  1403. $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1404. if (isset($content['attribs']['']['channels'])) 
  1405. $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1406. if (isset($content['attribs']['']['duration'])) 
  1407. $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1408. else 
  1409. $duration = $duration_parent; 
  1410. if (isset($content['attribs']['']['expression'])) 
  1411. $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1412. if (isset($content['attribs']['']['framerate'])) 
  1413. $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1414. if (isset($content['attribs']['']['height'])) 
  1415. $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1416. if (isset($content['attribs']['']['lang'])) 
  1417. $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1418. if (isset($content['attribs']['']['fileSize'])) 
  1419. $length = ceil($content['attribs']['']['fileSize']); 
  1420. if (isset($content['attribs']['']['medium'])) 
  1421. $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1422. if (isset($content['attribs']['']['samplingrate'])) 
  1423. $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1424. if (isset($content['attribs']['']['type'])) 
  1425. $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1426. if (isset($content['attribs']['']['width'])) 
  1427. $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1428. if (isset($content['attribs']['']['url'])) 
  1429. $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 
  1430. // Checking the other optional media: elements. Priority: media:content, media:group, item, channel 
  1431.  
  1432. // CAPTIONS 
  1433. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) 
  1434. foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) 
  1435. $caption_type = null; 
  1436. $caption_lang = null; 
  1437. $caption_startTime = null; 
  1438. $caption_endTime = null; 
  1439. $caption_text = null; 
  1440. if (isset($caption['attribs']['']['type'])) 
  1441. $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1442. if (isset($caption['attribs']['']['lang'])) 
  1443. $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1444. if (isset($caption['attribs']['']['start'])) 
  1445. $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1446. if (isset($caption['attribs']['']['end'])) 
  1447. $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1448. if (isset($caption['data'])) 
  1449. $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1450. $captions[] = $this->registry->create('Caption', array($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text)); 
  1451. if (is_array($captions)) 
  1452. $captions = array_values(array_unique($captions)); 
  1453. else 
  1454. $captions = $captions_parent; 
  1455.  
  1456. // CATEGORIES 
  1457. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) 
  1458. foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) 
  1459. $term = null; 
  1460. $scheme = null; 
  1461. $label = null; 
  1462. if (isset($category['data'])) 
  1463. $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1464. if (isset($category['attribs']['']['scheme'])) 
  1465. $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1466. else 
  1467. $scheme = 'http://search.yahoo.com/mrss/category_schema'; 
  1468. if (isset($category['attribs']['']['label'])) 
  1469. $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1470. $categories[] = $this->registry->create('Category', array($term, $scheme, $label)); 
  1471. if (is_array($categories) && is_array($categories_parent)) 
  1472. $categories = array_values(array_unique(array_merge($categories, $categories_parent))); 
  1473. elseif (is_array($categories)) 
  1474. $categories = array_values(array_unique($categories)); 
  1475. elseif (is_array($categories_parent)) 
  1476. $categories = array_values(array_unique($categories_parent)); 
  1477. else 
  1478. $categories = null; 
  1479.  
  1480. // COPYRIGHTS 
  1481. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) 
  1482. $copyright_url = null; 
  1483. $copyright_label = null; 
  1484. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) 
  1485. $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1486. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) 
  1487. $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1488. $copyrights = $this->registry->create('Copyright', array($copyright_url, $copyright_label)); 
  1489. else 
  1490. $copyrights = $copyrights_parent; 
  1491.  
  1492. // CREDITS 
  1493. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) 
  1494. foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) 
  1495. $credit_role = null; 
  1496. $credit_scheme = null; 
  1497. $credit_name = null; 
  1498. if (isset($credit['attribs']['']['role'])) 
  1499. $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1500. if (isset($credit['attribs']['']['scheme'])) 
  1501. $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1502. else 
  1503. $credit_scheme = 'urn:ebu'; 
  1504. if (isset($credit['data'])) 
  1505. $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1506. $credits[] = $this->registry->create('Credit', array($credit_role, $credit_scheme, $credit_name)); 
  1507. if (is_array($credits)) 
  1508. $credits = array_values(array_unique($credits)); 
  1509. else 
  1510. $credits = $credits_parent; 
  1511.  
  1512. // DESCRIPTION 
  1513. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) 
  1514. $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1515. else 
  1516. $description = $description_parent; 
  1517.  
  1518. // HASHES 
  1519. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) 
  1520. foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) 
  1521. $value = null; 
  1522. $algo = null; 
  1523. if (isset($hash['data'])) 
  1524. $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1525. if (isset($hash['attribs']['']['algo'])) 
  1526. $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1527. else 
  1528. $algo = 'md5'; 
  1529. $hashes[] = $algo.':'.$value; 
  1530. if (is_array($hashes)) 
  1531. $hashes = array_values(array_unique($hashes)); 
  1532. else 
  1533. $hashes = $hashes_parent; 
  1534.  
  1535. // KEYWORDS 
  1536. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) 
  1537. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) 
  1538. $temp = explode(', ', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); 
  1539. foreach ($temp as $word) 
  1540. $keywords[] = trim($word); 
  1541. unset($temp); 
  1542. if (is_array($keywords)) 
  1543. $keywords = array_values(array_unique($keywords)); 
  1544. else 
  1545. $keywords = $keywords_parent; 
  1546.  
  1547. // PLAYER 
  1548. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) 
  1549. $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 
  1550. else 
  1551. $player = $player_parent; 
  1552.  
  1553. // RATINGS 
  1554. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) 
  1555. foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) 
  1556. $rating_scheme = null; 
  1557. $rating_value = null; 
  1558. if (isset($rating['attribs']['']['scheme'])) 
  1559. $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1560. else 
  1561. $rating_scheme = 'urn:simple'; 
  1562. if (isset($rating['data'])) 
  1563. $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1564. $ratings[] = $this->registry->create('Rating', array($rating_scheme, $rating_value)); 
  1565. if (is_array($ratings)) 
  1566. $ratings = array_values(array_unique($ratings)); 
  1567. else 
  1568. $ratings = $ratings_parent; 
  1569.  
  1570. // RESTRICTIONS 
  1571. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) 
  1572. foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) 
  1573. $restriction_relationship = null; 
  1574. $restriction_type = null; 
  1575. $restriction_value = null; 
  1576. if (isset($restriction['attribs']['']['relationship'])) 
  1577. $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1578. if (isset($restriction['attribs']['']['type'])) 
  1579. $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1580. if (isset($restriction['data'])) 
  1581. $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1582. $restrictions[] = $this->registry->create('Restriction', array($restriction_relationship, $restriction_type, $restriction_value)); 
  1583. if (is_array($restrictions)) 
  1584. $restrictions = array_values(array_unique($restrictions)); 
  1585. else 
  1586. $restrictions = $restrictions_parent; 
  1587.  
  1588. // THUMBNAILS 
  1589. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) 
  1590. foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) 
  1591. $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); 
  1592. if (is_array($thumbnails)) 
  1593. $thumbnails = array_values(array_unique($thumbnails)); 
  1594. else 
  1595. $thumbnails = $thumbnails_parent; 
  1596.  
  1597. // TITLES 
  1598. if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) 
  1599. $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1600. else 
  1601. $title = $title_parent; 
  1602.  
  1603. $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width)); 
  1604.  
  1605. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) 
  1606. if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') 
  1607. // Attributes 
  1608. $bitrate = null; 
  1609. $channels = null; 
  1610. $duration = null; 
  1611. $expression = null; 
  1612. $framerate = null; 
  1613. $height = null; 
  1614. $javascript = null; 
  1615. $lang = null; 
  1616. $length = null; 
  1617. $medium = null; 
  1618. $samplingrate = null; 
  1619. $type = null; 
  1620. $url = null; 
  1621. $width = null; 
  1622.  
  1623. $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); 
  1624. if (isset($link['attribs']['']['type'])) 
  1625. $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1626. if (isset($link['attribs']['']['length'])) 
  1627. $length = ceil($link['attribs']['']['length']); 
  1628.  
  1629. // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor 
  1630. $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); 
  1631.  
  1632. foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) 
  1633. if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') 
  1634. // Attributes 
  1635. $bitrate = null; 
  1636. $channels = null; 
  1637. $duration = null; 
  1638. $expression = null; 
  1639. $framerate = null; 
  1640. $height = null; 
  1641. $javascript = null; 
  1642. $lang = null; 
  1643. $length = null; 
  1644. $medium = null; 
  1645. $samplingrate = null; 
  1646. $type = null; 
  1647. $url = null; 
  1648. $width = null; 
  1649.  
  1650. $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); 
  1651. if (isset($link['attribs']['']['type'])) 
  1652. $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1653. if (isset($link['attribs']['']['length'])) 
  1654. $length = ceil($link['attribs']['']['length']); 
  1655.  
  1656. // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor 
  1657. $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); 
  1658.  
  1659. if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure')) 
  1660. if (isset($enclosure[0]['attribs']['']['url'])) 
  1661. // Attributes 
  1662. $bitrate = null; 
  1663. $channels = null; 
  1664. $duration = null; 
  1665. $expression = null; 
  1666. $framerate = null; 
  1667. $height = null; 
  1668. $javascript = null; 
  1669. $lang = null; 
  1670. $length = null; 
  1671. $medium = null; 
  1672. $samplingrate = null; 
  1673. $type = null; 
  1674. $url = null; 
  1675. $width = null; 
  1676.  
  1677. $url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0])); 
  1678. if (isset($enclosure[0]['attribs']['']['type'])) 
  1679. $type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); 
  1680. if (isset($enclosure[0]['attribs']['']['length'])) 
  1681. $length = ceil($enclosure[0]['attribs']['']['length']); 
  1682.  
  1683. // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor 
  1684. $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); 
  1685.  
  1686. if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) 
  1687. // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor 
  1688. $this->data['enclosures'][] = $this->registry->create('Enclosure', array($url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width)); 
  1689.  
  1690. $this->data['enclosures'] = array_values(array_unique($this->data['enclosures'])); 
  1691. if (!empty($this->data['enclosures'])) 
  1692. return $this->data['enclosures']; 
  1693. else 
  1694. return null; 
  1695.  
  1696. /** 
  1697. * Get the latitude coordinates for the item 
  1698. * Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications 
  1699. * Uses `<geo:lat>` or `<georss:point>` 
  1700. * @since 1.0 
  1701. * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo 
  1702. * @link http://www.georss.org/ GeoRSS 
  1703. * @return string|null 
  1704. */ 
  1705. public function get_latitude() 
  1706. if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) 
  1707. return (float) $return[0]['data']; 
  1708. elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) 
  1709. return (float) $match[1]; 
  1710. else 
  1711. return null; 
  1712.  
  1713. /** 
  1714. * Get the longitude coordinates for the item 
  1715. * Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications 
  1716. * Uses `<geo:long>`, `<geo:lon>` or `<georss:point>` 
  1717. * @since 1.0 
  1718. * @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo 
  1719. * @link http://www.georss.org/ GeoRSS 
  1720. * @return string|null 
  1721. */ 
  1722. public function get_longitude() 
  1723. if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) 
  1724. return (float) $return[0]['data']; 
  1725. elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) 
  1726. return (float) $return[0]['data']; 
  1727. elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) 
  1728. return (float) $match[2]; 
  1729. else 
  1730. return null; 
  1731.  
  1732. /** 
  1733. * Get the `<atom:source>` for the item 
  1734. * @since 1.1 
  1735. * @return SimplePie_Source|null 
  1736. */ 
  1737. public function get_source() 
  1738. if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source')) 
  1739. return $this->registry->create('Source', array($this, $return[0])); 
  1740. else 
  1741. return null;