Reader.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Feed_Reader
  17. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. * @version $Id$
  20. */
  21. /**
  22. * @see Zend_Feed
  23. */
  24. require_once 'Zend/Feed.php';
  25. /**
  26. * @see Zend_Feed_Reader_Feed_Rss
  27. */
  28. require_once 'Zend/Feed/Reader/Feed/Rss.php';
  29. /**
  30. * @see Zend_Feed_Reader_Feed_Atom
  31. */
  32. require_once 'Zend/Feed/Reader/Feed/Atom.php';
  33. /**
  34. * @see Zend_Feed_Reader_FeedSet
  35. */
  36. require_once 'Zend/Feed/Reader/FeedSet.php';
  37. /**
  38. * @category Zend
  39. * @package Zend_Feed_Reader
  40. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  41. * @license http://framework.zend.com/license/new-bsd New BSD License
  42. */
  43. class Zend_Feed_Reader
  44. {
  45. /**
  46. * Namespace constants
  47. */
  48. const NAMESPACE_ATOM_03 = 'http://purl.org/atom/ns#';
  49. const NAMESPACE_ATOM_10 = 'http://www.w3.org/2005/Atom';
  50. const NAMESPACE_RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';
  51. const NAMESPACE_RSS_090 = 'http://my.netscape.com/rdf/simple/0.9/';
  52. const NAMESPACE_RSS_10 = 'http://purl.org/rss/1.0/';
  53. /**
  54. * Feed type constants
  55. */
  56. const TYPE_ANY = 'any';
  57. const TYPE_ATOM_03 = 'atom-03';
  58. const TYPE_ATOM_10 = 'atom-10';
  59. const TYPE_ATOM_10_ENTRY = 'atom-10-entry';
  60. const TYPE_ATOM_ANY = 'atom';
  61. const TYPE_RSS_090 = 'rss-090';
  62. const TYPE_RSS_091 = 'rss-091';
  63. const TYPE_RSS_091_NETSCAPE = 'rss-091n';
  64. const TYPE_RSS_091_USERLAND = 'rss-091u';
  65. const TYPE_RSS_092 = 'rss-092';
  66. const TYPE_RSS_093 = 'rss-093';
  67. const TYPE_RSS_094 = 'rss-094';
  68. const TYPE_RSS_10 = 'rss-10';
  69. const TYPE_RSS_20 = 'rss-20';
  70. const TYPE_RSS_ANY = 'rss';
  71. /**
  72. * Cache instance
  73. *
  74. * @var Zend_Cache_Core
  75. */
  76. protected static $_cache = null;
  77. /**
  78. * HTTP client object to use for retrieving feeds
  79. *
  80. * @var Zend_Http_Client
  81. */
  82. protected static $_httpClient = null;
  83. /**
  84. * Override HTTP PUT and DELETE request methods?
  85. *
  86. * @var boolean
  87. */
  88. protected static $_httpMethodOverride = false;
  89. protected static $_httpConditionalGet = false;
  90. protected static $_pluginLoader = null;
  91. protected static $_prefixPaths = array();
  92. protected static $_extensions = array(
  93. 'feed' => array(
  94. 'DublinCore_Feed',
  95. 'Atom_Feed'
  96. ),
  97. 'entry' => array(
  98. 'Content_Entry',
  99. 'DublinCore_Entry',
  100. 'Atom_Entry'
  101. ),
  102. 'core' => array(
  103. 'DublinCore_Feed',
  104. 'Atom_Feed',
  105. 'Content_Entry',
  106. 'DublinCore_Entry',
  107. 'Atom_Entry'
  108. )
  109. );
  110. /**
  111. * Get the Feed cache
  112. *
  113. * @return Zend_Cache_Core
  114. */
  115. public static function getCache()
  116. {
  117. return self::$_cache;
  118. }
  119. /**
  120. * Set the feed cache
  121. *
  122. * @param Zend_Cache_Core $cache
  123. * @return void
  124. */
  125. public static function setCache(Zend_Cache_Core $cache)
  126. {
  127. self::$_cache = $cache;
  128. }
  129. /**
  130. * Set the HTTP client instance
  131. *
  132. * Sets the HTTP client object to use for retrieving the feeds.
  133. *
  134. * @param Zend_Http_Client $httpClient
  135. * @return void
  136. */
  137. public static function setHttpClient(Zend_Http_Client $httpClient)
  138. {
  139. self::$_httpClient = $httpClient;
  140. }
  141. /**
  142. * Gets the HTTP client object. If none is set, a new Zend_Http_Client will be used.
  143. *
  144. * @return Zend_Http_Client_Abstract
  145. */
  146. public static function getHttpClient()
  147. {
  148. if (!self::$_httpClient instanceof Zend_Http_Client) {
  149. /**
  150. * @see Zend_Http_Client
  151. */
  152. require_once 'Zend/Http/Client.php';
  153. self::$_httpClient = new Zend_Http_Client();
  154. }
  155. return self::$_httpClient;
  156. }
  157. /**
  158. * Toggle using POST instead of PUT and DELETE HTTP methods
  159. *
  160. * Some feed implementations do not accept PUT and DELETE HTTP
  161. * methods, or they can't be used because of proxies or other
  162. * measures. This allows turning on using POST where PUT and
  163. * DELETE would normally be used; in addition, an
  164. * X-Method-Override header will be sent with a value of PUT or
  165. * DELETE as appropriate.
  166. *
  167. * @param boolean $override Whether to override PUT and DELETE.
  168. * @return void
  169. */
  170. public static function setHttpMethodOverride($override = true)
  171. {
  172. self::$_httpMethodOverride = $override;
  173. }
  174. /**
  175. * Get the HTTP override state
  176. *
  177. * @return boolean
  178. */
  179. public static function getHttpMethodOverride()
  180. {
  181. return self::$_httpMethodOverride;
  182. }
  183. /**
  184. * Set the flag indicating whether or not to use HTTP conditional GET
  185. *
  186. * @param bool $bool
  187. * @return void
  188. */
  189. public static function useHttpConditionalGet($bool = true)
  190. {
  191. self::$_httpConditionalGet = $bool;
  192. }
  193. /**
  194. * Import a feed by providing a URL
  195. *
  196. * @param string $url The URL to the feed
  197. * @param string $etag OPTIONAL Last received ETag for this resource
  198. * @param string $lastModified OPTIONAL Last-Modified value for this resource
  199. * @return Zend_Feed_Reader_FeedInterface
  200. */
  201. public static function import($uri, $etag = null, $lastModified = null)
  202. {
  203. $cache = self::getCache();
  204. $feed = null;
  205. $responseXml = '';
  206. $client = self::getHttpClient();
  207. $client->resetParameters();
  208. $client->setHeaders('If-None-Match', null);
  209. $client->setHeaders('If-Modified-Since', null);
  210. $client->setUri($uri);
  211. $cacheId = 'Zend_Feed_Reader_' . md5($uri);
  212. if (self::$_httpConditionalGet && $cache) {
  213. $data = $cache->load($cacheId);
  214. if ($data) {
  215. if (is_null($etag)) {
  216. $etag = $cache->load($cacheId.'_etag');
  217. }
  218. if (is_null($lastModified)) {
  219. $lastModified = $cache->load($cacheId.'_lastmodified');;
  220. }
  221. if ($etag) {
  222. $client->setHeaders('If-None-Match', $etag);
  223. }
  224. if ($lastModified) {
  225. $client->setHeaders('If-Modified-Since', $lastModified);
  226. }
  227. }
  228. $response = $client->request('GET');
  229. if ($response->getStatus() !== 200 && $response->getStatus() !== 304) {
  230. require_once 'Zend/Feed/Exception.php';
  231. throw new Zend_Feed_Exception('Feed failed to load, got response code ' . $response->getStatus());
  232. }
  233. if ($response->getStatus() == 304) {
  234. $responseXml = $data;
  235. } else {
  236. $responseXml = $response->getBody();
  237. $cache->save($responseXml, $cacheId);
  238. if ($response->getHeader('ETag')) {
  239. $cache->save($response->getHeader('ETag'), $cacheId.'_etag');
  240. }
  241. if ($response->getHeader('Last-Modified')) {
  242. $cache->save($response->getHeader('Last-Modified'), $cacheId.'_lastmodified');
  243. }
  244. }
  245. return self::importString($responseXml);
  246. } elseif ($cache) {
  247. $data = $cache->load($cacheId);
  248. if ($data !== false) {
  249. return self::importString($data);
  250. }
  251. $response = $client->request('GET');
  252. if ($response->getStatus() !== 200) {
  253. require_once 'Zend/Feed/Exception.php';
  254. throw new Zend_Feed_Exception('Feed failed to load, got response code ' . $response->getStatus());
  255. }
  256. $responseXml = $response->getBody();
  257. $cache->save($responseXml, $cacheId);
  258. return self::importString($responseXml);
  259. } else {
  260. $response = $client->request('GET');
  261. if ($response->getStatus() !== 200) {
  262. require_once 'Zend/Feed/Exception.php';
  263. throw new Zend_Feed_Exception('Feed failed to load, got response code ' . $response->getStatus());
  264. }
  265. return self::importString($response->getBody());
  266. }
  267. }
  268. /**
  269. * Import a feed by providing a Zend_Feed_Abstract object
  270. *
  271. * @param Zend_Feed_Abstract $feed A fully instantiated Zend_Feed object
  272. * @return Zend_Feed_Reader_FeedInterface
  273. */
  274. public static function importFeed(Zend_Feed_Abstract $feed)
  275. {
  276. $dom = $feed->getDOM()->ownerDocument;
  277. $type = self::detectType($dom);
  278. self::_registerCoreExtensions();
  279. if (substr($type, 0, 3) == 'rss') {
  280. $reader = new Zend_Feed_Reader_Feed_Rss($dom, $type);
  281. } else {
  282. $reader = new Zend_Feed_Reader_Feed_Atom($dom, $type);
  283. }
  284. return $reader;
  285. }
  286. /**
  287. * Import a feed froma string
  288. *
  289. * @param string $string
  290. * @return Zend_Feed_Reader_FeedInterface
  291. */
  292. public static function importString($string)
  293. {
  294. $libxml_errflag = libxml_use_internal_errors(true);
  295. $dom = new DOMDocument;
  296. $status = $dom->loadXML($string);
  297. libxml_use_internal_errors($libxml_errflag);
  298. if (!$status) {
  299. // Build error message
  300. $error = libxml_get_last_error();
  301. if ($error && $error->message) {
  302. $errormsg = "DOMDocument cannot parse XML: {$error->message}";
  303. } else {
  304. $errormsg = "DOMDocument cannot parse XML: Please check the XML document's validity";
  305. }
  306. require_once 'Zend/Feed/Exception.php';
  307. throw new Zend_Feed_Exception($errormsg);
  308. }
  309. $type = self::detectType($dom);
  310. self::_registerCoreExtensions();
  311. if (substr($type, 0, 3) == 'rss') {
  312. $reader = new Zend_Feed_Reader_Feed_Rss($dom, $type);
  313. } elseif (substr($type, 8, 5) == 'entry') {
  314. $reader = new Zend_Feed_Reader_Entry_Atom($dom->documentElement, 0, Zend_Feed_Reader::TYPE_ATOM_10);
  315. } elseif (substr($type, 0, 4) == 'atom') {
  316. $reader = new Zend_Feed_Reader_Feed_Atom($dom, $type);
  317. } else {
  318. require_once 'Zend/Feed/Exception.php';
  319. throw new Zend_Feed_Exception('The URI used does not point to a '
  320. . 'valid Atom, RSS or RDF feed that Zend_Feed_Reader can parse.');
  321. }
  322. return $reader;
  323. }
  324. /**
  325. * Imports a feed from a file located at $filename.
  326. *
  327. * @param string $filename
  328. * @throws Zend_Feed_Exception
  329. * @return Zend_Feed_Reader_FeedInterface
  330. */
  331. public static function importFile($filename)
  332. {
  333. @ini_set('track_errors', 1);
  334. $feed = @file_get_contents($filename);
  335. @ini_restore('track_errors');
  336. if ($feed === false) {
  337. /**
  338. * @see Zend_Feed_Exception
  339. */
  340. require_once 'Zend/Feed/Exception.php';
  341. throw new Zend_Feed_Exception("File could not be loaded: $php_errormsg");
  342. }
  343. return self::importString($feed);
  344. }
  345. public static function findFeedLinks($uri)
  346. {
  347. // Get the HTTP response from $uri and save the contents
  348. $client = self::getHttpClient();
  349. $client->setUri($uri);
  350. $response = $client->request();
  351. if ($response->getStatus() !== 200) {
  352. /**
  353. * @see Zend_Feed_Exception
  354. */
  355. require_once 'Zend/Feed/Exception.php';
  356. throw new Zend_Feed_Exception("Failed to access $uri, got response code " . $response->getStatus());
  357. }
  358. $responseHtml = $response->getBody();
  359. $libxml_errflag = libxml_use_internal_errors(true);
  360. $dom = new DOMDocument;
  361. $status = $dom->loadHTML($responseHtml);
  362. libxml_use_internal_errors($libxml_errflag);
  363. if (!$status) {
  364. // Build error message
  365. $error = libxml_get_last_error();
  366. if ($error && $error->message) {
  367. $errormsg = "DOMDocument cannot parse HTML: {$error->message}";
  368. } else {
  369. $errormsg = "DOMDocument cannot parse HTML: Please check the XML document's validity";
  370. }
  371. require_once 'Zend/Feed/Exception.php';
  372. throw new Zend_Feed_Exception($errormsg);
  373. }
  374. $feedSet = new Zend_Feed_Reader_FeedSet;
  375. $links = $dom->getElementsByTagName('link');
  376. $feedSet->addLinks($links, $uri);
  377. return $feedSet;
  378. }
  379. /**
  380. * Detect the feed type of the provided feed
  381. *
  382. * @param Zend_Feed_Abstract|DOMDocument|string $feed
  383. * @return string
  384. */
  385. public static function detectType($feed, $specOnly = false)
  386. {
  387. if ($feed instanceof Zend_Feed_Reader_FeedInterface) {
  388. $dom = $feed->getDomDocument();
  389. } elseif($feed instanceof DOMDocument) {
  390. $dom = $feed;
  391. } elseif(is_string($feed) && !empty($feed)) {
  392. @ini_set('track_errors', 1);
  393. $dom = new DOMDocument;
  394. $status = @$doc->loadXML($string);
  395. @ini_restore('track_errors');
  396. if (!$status) {
  397. if (!isset($php_errormsg)) {
  398. if (function_exists('xdebug_is_enabled')) {
  399. $php_errormsg = '(error message not available, when XDebug is running)';
  400. } else {
  401. $php_errormsg = '(error message not available)';
  402. }
  403. }
  404. require_once 'Zend/Feed/Exception.php';
  405. throw new Zend_Feed_Exception("DOMDocument cannot parse XML: $php_errormsg");
  406. }
  407. } else {
  408. require_once 'Zend/Feed/Exception.php';
  409. throw new Zend_Feed_Exception('Invalid object/scalar provided: must'
  410. . ' be of type Zend_Feed_Reader_FeedInterface, DomDocument or string');
  411. }
  412. $xpath = new DOMXPath($dom);
  413. if ($xpath->query('/rss')->length) {
  414. $type = self::TYPE_RSS_ANY;
  415. $version = $xpath->evaluate('string(/rss/@version)');
  416. if (strlen($version) > 0) {
  417. switch($version) {
  418. case '2.0':
  419. $type = self::TYPE_RSS_20;
  420. break;
  421. case '0.94':
  422. $type = self::TYPE_RSS_094;
  423. break;
  424. case '0.93':
  425. $type = self::TYPE_RSS_093;
  426. break;
  427. case '0.92':
  428. $type = self::TYPE_RSS_092;
  429. break;
  430. case '0.91':
  431. $type = self::TYPE_RSS_091;
  432. break;
  433. }
  434. }
  435. return $type;
  436. }
  437. $xpath->registerNamespace('rdf', self::NAMESPACE_RDF);
  438. if ($xpath->query('/rdf:RDF')->length) {
  439. $xpath->registerNamespace('rss', self::NAMESPACE_RSS_10);
  440. if ($xpath->query('/rdf:RDF/rss:channel')->length
  441. || $xpath->query('/rdf:RDF/rss:image')->length
  442. || $xpath->query('/rdf:RDF/rss:item')->length
  443. || $xpath->query('/rdf:RDF/rss:textinput')->length
  444. ) {
  445. return self::TYPE_RSS_10;
  446. }
  447. $xpath->registerNamespace('rss', self::NAMESPACE_RSS_090);
  448. if ($xpath->query('/rdf:RDF/rss:channel')->length
  449. || $xpath->query('/rdf:RDF/rss:image')->length
  450. || $xpath->query('/rdf:RDF/rss:item')->length
  451. || $xpath->query('/rdf:RDF/rss:textinput')->length
  452. ) {
  453. return self::TYPE_RSS_090;
  454. }
  455. }
  456. $type = self::TYPE_ATOM_ANY;
  457. $xpath->registerNamespace('atom', self::NAMESPACE_ATOM_10);
  458. if ($xpath->query('//atom:feed')->length) {
  459. return self::TYPE_ATOM_10;
  460. }
  461. if ($xpath->query('//atom:entry')->length) {
  462. if ($specOnly == true) {
  463. return self::TYPE_ATOM_10;
  464. } else {
  465. return self::TYPE_ATOM_10_ENTRY;
  466. }
  467. }
  468. $xpath->registerNamespace('atom', self::NAMESPACE_ATOM_03);
  469. if ($xpath->query('//atom:feed')->length) {
  470. return self::TYPE_ATOM_03;
  471. }
  472. return self::TYPE_ANY;
  473. }
  474. /**
  475. * Set plugin loader for use with Extensions
  476. *
  477. * @param Zend_Loader_PluginLoader_Interface $loader
  478. */
  479. public static function setPluginLoader(Zend_Loader_PluginLoader_Interface $loader)
  480. {
  481. self::$_pluginLoader = $loader;
  482. }
  483. /**
  484. * Get plugin loader for use with Extensions
  485. *
  486. * @return Zend_Loader_PluginLoader_Interface $loader
  487. */
  488. public static function getPluginLoader()
  489. {
  490. if (!isset(self::$_pluginLoader)) {
  491. require_once 'Zend/Loader/PluginLoader.php';
  492. self::$_pluginLoader = new Zend_Loader_PluginLoader(array(
  493. 'Zend_Feed_Reader_Extension_' => 'Zend/Feed/Reader/Extension/',
  494. ));
  495. }
  496. return self::$_pluginLoader;
  497. }
  498. /**
  499. * Add prefix path for loading Extensions
  500. *
  501. * @param string $prefix
  502. * @param string $path
  503. * @return void
  504. */
  505. public static function addPrefixPath($prefix, $path)
  506. {
  507. $prefix = rtrim($prefix, '_');
  508. $path = rtrim($path, DIRECTORY_SEPARATOR);
  509. self::getPluginLoader()->addPrefixPath($prefix, $path);
  510. }
  511. /**
  512. * Add multiple Extension prefix paths at once
  513. *
  514. * @param array $spec
  515. * @return void
  516. */
  517. public static function addPrefixPaths(array $spec)
  518. {
  519. if (isset($spec['prefix']) && isset($spec['path'])) {
  520. self::addPrefixPath($spec['prefix'], $spec['path']);
  521. }
  522. foreach ($spec as $prefixPath) {
  523. if (isset($prefixPath['prefix']) && isset($prefixPath['path'])) {
  524. self::addPrefixPath($prefixPath['prefix'], $prefixPath['path']);
  525. }
  526. }
  527. }
  528. /**
  529. * Register an Extension by name
  530. *
  531. * @param string $name
  532. * @return void
  533. * @throws Zend_Feed_Exception if unable to resolve Extension class
  534. */
  535. public static function registerExtension($name)
  536. {
  537. $feedName = $name . '_Feed';
  538. $entryName = $name . '_Entry';
  539. if (self::isRegistered($name)) {
  540. if (self::getPluginLoader()->isLoaded($feedName) ||
  541. self::getPluginLoader()->isLoaded($entryName)) {
  542. return;
  543. }
  544. }
  545. try {
  546. self::getPluginLoader()->load($feedName);
  547. self::$_extensions['feed'][] = $feedName;
  548. } catch (Zend_Loader_PluginLoader_Exception $e) {
  549. }
  550. try {
  551. self::getPluginLoader()->load($entryName);
  552. self::$_extensions['entry'][] = $entryName;
  553. } catch (Zend_Loader_PluginLoader_Exception $e) {
  554. }
  555. if (!self::getPluginLoader()->isLoaded($feedName)
  556. && !self::getPluginLoader()->isLoaded($entryName)
  557. ) {
  558. require_once 'Zend/Feed/Exception.php';
  559. throw new Zend_Feed_Exception('Could not load extension: ' . $name
  560. . 'using Plugin Loader. Check prefix paths are configured and extension exists.');
  561. }
  562. }
  563. /**
  564. * Is a given named Extension registered?
  565. *
  566. * @param string $extensionName
  567. * @return boolean
  568. */
  569. public static function isRegistered($extensionName)
  570. {
  571. $feedName = $extensionName . '_Feed';
  572. $entryName = $extensionName . '_Entry';
  573. if (in_array($feedName, self::$_extensions['feed'])
  574. || in_array($entryName, self::$_extensions['entry'])
  575. ) {
  576. return true;
  577. }
  578. return false;
  579. }
  580. /**
  581. * Get a list of extensions
  582. *
  583. * @return array
  584. */
  585. public static function getExtensions()
  586. {
  587. return self::$_extensions;
  588. }
  589. /**
  590. * Reset class state to defaults
  591. *
  592. * @return void
  593. */
  594. public static function reset()
  595. {
  596. self::$_cache = null;
  597. self::$_httpClient = null;
  598. self::$_httpMethodOverride = false;
  599. self::$_httpConditionalGet = false;
  600. self::$_pluginLoader = null;
  601. self::$_prefixPaths = array();
  602. self::$_extensions = array(
  603. 'feed' => array(
  604. 'DublinCore_Feed',
  605. 'Atom_Feed'
  606. ),
  607. 'entry' => array(
  608. 'Content_Entry',
  609. 'DublinCore_Entry',
  610. 'Atom_Entry'
  611. ),
  612. 'core' => array(
  613. 'DublinCore_Feed',
  614. 'Atom_Feed',
  615. 'Content_Entry',
  616. 'DublinCore_Entry',
  617. 'Atom_Entry'
  618. )
  619. );
  620. }
  621. /**
  622. * Register core (default) extensions
  623. *
  624. * @return void
  625. */
  626. protected static function _registerCoreExtensions()
  627. {
  628. self::registerExtension('DublinCore');
  629. self::registerExtension('Content');
  630. self::registerExtension('Atom');
  631. self::registerExtension('Slash');
  632. self::registerExtension('WellFormedWeb');
  633. self::registerExtension('Thread');
  634. self::registerExtension('Podcast');
  635. }
  636. /**
  637. * Utility method to apply array_unique operation to a multidimensional
  638. * array.
  639. *
  640. * @param array
  641. * @return array
  642. */
  643. public static function arrayUnique(array $array)
  644. {
  645. foreach ($array as &$value) {
  646. $value = serialize($value);
  647. }
  648. $array = array_unique($array);
  649. foreach ($array as &$value) {
  650. $value = unserialize($value);
  651. }
  652. return $array;
  653. }
  654. }