Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Feed / Reader / Extension / DublinCore / Entry.php
blob7ec5304e953c83de628c1341a07f9dc34c1e3113
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Feed\Reader\Extension\DublinCore;
12 use DateTime;
13 use Zend\Feed\Reader;
14 use Zend\Feed\Reader\Collection;
15 use Zend\Feed\Reader\Extension;
17 class Entry extends Extension\AbstractEntry
19 /**
20 * Get an author entry
22 * @param int $index
23 * @return string
25 public function getAuthor($index = 0)
27 $authors = $this->getAuthors();
29 if (isset($authors[$index])) {
30 return $authors[$index];
33 return null;
36 /**
37 * Get an array with feed authors
39 * @return array
41 public function getAuthors()
43 if (array_key_exists('authors', $this->data)) {
44 return $this->data['authors'];
47 $authors = array();
48 $list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc11:creator');
50 if (!$list->length) {
51 $list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc10:creator');
53 if (!$list->length) {
54 $list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc11:publisher');
56 if (!$list->length) {
57 $list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc10:publisher');
61 if ($list->length) {
62 foreach ($list as $author) {
63 $authors[] = array(
64 'name' => $author->nodeValue
67 $authors = new Collection\Author(
68 Reader\Reader::arrayUnique($authors)
70 } else {
71 $authors = null;
74 $this->data['authors'] = $authors;
76 return $this->data['authors'];
79 /**
80 * Get categories (subjects under DC)
82 * @return Collection\Category
84 public function getCategories()
86 if (array_key_exists('categories', $this->data)) {
87 return $this->data['categories'];
90 $list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc11:subject');
92 if (!$list->length) {
93 $list = $this->getXpath()->evaluate($this->getXpathPrefix() . '//dc10:subject');
96 if ($list->length) {
97 $categoryCollection = new Collection\Category;
98 foreach ($list as $category) {
99 $categoryCollection[] = array(
100 'term' => $category->nodeValue,
101 'scheme' => null,
102 'label' => $category->nodeValue,
105 } else {
106 $categoryCollection = new Collection\Category;
109 $this->data['categories'] = $categoryCollection;
110 return $this->data['categories'];
115 * Get the entry content
117 * @return string
119 public function getContent()
121 return $this->getDescription();
125 * Get the entry description
127 * @return string
129 public function getDescription()
131 if (array_key_exists('description', $this->data)) {
132 return $this->data['description'];
135 $description = null;
136 $description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:description)');
138 if (!$description) {
139 $description = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:description)');
142 if (!$description) {
143 $description = null;
146 $this->data['description'] = $description;
148 return $this->data['description'];
152 * Get the entry ID
154 * @return string
156 public function getId()
158 if (array_key_exists('id', $this->data)) {
159 return $this->data['id'];
162 $id = null;
163 $id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:identifier)');
165 if (!$id) {
166 $id = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:identifier)');
169 $this->data['id'] = $id;
171 return $this->data['id'];
175 * Get the entry title
177 * @return string
179 public function getTitle()
181 if (array_key_exists('title', $this->data)) {
182 return $this->data['title'];
185 $title = null;
186 $title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:title)');
188 if (!$title) {
189 $title = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:title)');
192 if (!$title) {
193 $title = null;
196 $this->data['title'] = $title;
198 return $this->data['title'];
204 * @return DateTime|null
206 public function getDate()
208 if (array_key_exists('date', $this->data)) {
209 return $this->data['date'];
212 $d = null;
213 $date = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc11:date)');
215 if (!$date) {
216 $date = $this->getXpath()->evaluate('string(' . $this->getXpathPrefix() . '/dc10:date)');
219 if ($date) {
220 $d = new DateTime($date);
223 $this->data['date'] = $d;
225 return $this->data['date'];
229 * Register DC namespaces
231 * @return void
233 protected function registerNamespaces()
235 $this->getXpath()->registerNamespace('dc10', 'http://purl.org/dc/elements/1.0/');
236 $this->getXpath()->registerNamespace('dc11', 'http://purl.org/dc/elements/1.1/');