Open Monograph Press  3.3.0
Chapter.inc.php
1 <?php
2 
17 class Chapter extends DataObject {
21  function __construct() {
22  parent::__construct();
23  }
24 
25  //
26  // Get/set methods
27  //
28 
44  public function getLocalizedData($key, $preferredLocale = null) {
45  // 1. Preferred locale
46  if ($preferredLocale && $this->getData($key, $preferredLocale)) {
47  return $this->getData($key, $preferredLocale);
48  }
49  // 2. User's current locale
50  if (!empty($this->getData($key, AppLocale::getLocale()))) {
51  return $this->getData($key, AppLocale::getLocale());
52  }
53  // 3. The first locale we can find data for
54  $data = $this->getData($key, null);
55  foreach ((array) $data as $value) {
56  if (!empty($value)) {
57  return $value;
58  }
59  }
60 
61  return null;
62  }
63 
68  function getLocalizedFullTitle() {
69 
70  $fullTitle = $this->getLocalizedTitle();
71 
72  if ($subtitle = $this->getLocalizedSubtitle()) {
73  $fullTitle = PKPString::concatTitleFields(array($fullTitle, $subtitle));
74  }
75 
76  return $fullTitle;
77  }
78 
82  function getLocalizedTitle() {
83  return $this->getLocalizedData('title');
84  }
85 
91  function getTitle($locale = null) {
92  return $this->getData('title', $locale);
93  }
94 
100  function setTitle($title, $locale = null) {
101  return $this->setData('title', $title, $locale);
102  }
103 
107  function getLocalizedSubtitle() {
108  return $this->getLocalizedData('subtitle');
109  }
110 
116  function getSubtitle($locale = null) {
117  return $this->getData('subtitle', $locale);
118  }
119 
125  function setSubtitle($subtitle, $locale = null) {
126  return $this->setData('subtitle', $subtitle, $locale);
127  }
128 
133  function getSequence() {
134  return $this->getData('sequence');
135  }
136 
141  function setSequence($sequence) {
142  return $this->setData('sequence', $sequence);
143  }
144 
149  function getAuthors() {
150  $chapterAuthorDao = DAORegistry::getDAO('ChapterAuthorDAO'); /* @var $chapterAuthorDao ChapterAuthorDAO */
151  return $chapterAuthorDao->getAuthors($this->getData('publicationId'), $this->getId());
152  }
153 
159  function getAuthorNamesAsString($preferred = true) {
160  $authorNames = array();
161  $authors = $this->getAuthors();
162  while ($author = $authors->next()) {
163  $authorNames[] = $author->getFullName($preferred);
164  }
165  return join(', ', $authorNames);
166  }
167 
175  function getStoredPubId($pubIdType) {
176  return $this->getData('pub-id::'.$pubIdType);
177  }
178 
186  function setStoredPubId($pubIdType, $pubId) {
187  $this->setData('pub-id::'.$pubIdType, $pubId);
188  }
189 
193  function getDAO() {
194  return DAORegistry::getDAO('ChapterDAO');
195  }
196 
202  function getAbstract($locale = null) {
203  return $this->getData('abstract', $locale);
204  }
205 
211  function setAbstract($abstract, $locale = null) {
212  return $this->setData('abstract', $abstract, $locale);
213  }
217  function getLocalizedAbstract() {
218  return $this->getLocalizedData('abstract');
219  }
220 
225  function getDatePublished() {
226  return $this->getData('datePublished');
227  }
228 
233  function setDatePublished($datePublished) {
234  return $this->setData('datePublished', $datePublished);
235  }
236 
241  function getPages() {
242  return $this->getData('pages');
243  }
244 
249  function setPages($pages) {
250  $this->setData('pages', $pages);
251  }
252 }
253 
254 
DataObject\getData
& getData($key, $locale=null)
Definition: DataObject.inc.php:100
DataObject
Any class with an associated DAO should extend this class.
Definition: DataObject.inc.php:18
Chapter\setSubtitle
setSubtitle($subtitle, $locale=null)
Definition: Chapter.inc.php:125
DAORegistry\getDAO
static & getDAO($name, $dbconn=null)
Definition: DAORegistry.inc.php:57
Chapter\setSequence
setSequence($sequence)
Definition: Chapter.inc.php:141
Chapter\setTitle
setTitle($title, $locale=null)
Definition: Chapter.inc.php:100
Chapter\getSequence
getSequence()
Definition: Chapter.inc.php:133
Chapter\setDatePublished
setDatePublished($datePublished)
Definition: Chapter.inc.php:233
Chapter\setStoredPubId
setStoredPubId($pubIdType, $pubId)
Definition: Chapter.inc.php:186
Chapter\getLocalizedTitle
getLocalizedTitle()
Definition: Chapter.inc.php:82
Chapter\getAuthorNamesAsString
getAuthorNamesAsString($preferred=true)
Definition: Chapter.inc.php:159
Chapter\getPages
getPages()
Definition: Chapter.inc.php:241
Chapter\getAuthors
getAuthors()
Definition: Chapter.inc.php:149
PKPString\concatTitleFields
static concatTitleFields($fields)
Definition: PKPString.inc.php:410
Chapter\getLocalizedSubtitle
getLocalizedSubtitle()
Definition: Chapter.inc.php:107
Chapter\getTitle
getTitle($locale=null)
Definition: Chapter.inc.php:91
Chapter\getLocalizedFullTitle
getLocalizedFullTitle()
Definition: Chapter.inc.php:68
Chapter\setAbstract
setAbstract($abstract, $locale=null)
Definition: Chapter.inc.php:211
Chapter\getLocalizedData
getLocalizedData($key, $preferredLocale=null)
Definition: Chapter.inc.php:44
Chapter\getAbstract
getAbstract($locale=null)
Definition: Chapter.inc.php:202
Chapter\__construct
__construct()
Definition: Chapter.inc.php:21
Chapter
Describes a monograph chapter (or section)
Definition: Chapter.inc.php:17
DataObject\getId
getId()
Definition: DataObject.inc.php:206
Chapter\getLocalizedAbstract
getLocalizedAbstract()
Definition: Chapter.inc.php:217
Chapter\getDatePublished
getDatePublished()
Definition: Chapter.inc.php:225
AppLocale\getLocale
static getLocale()
Definition: env1/MockAppLocale.inc.php:40
Chapter\getDAO
getDAO()
Definition: Chapter.inc.php:193
Chapter\getSubtitle
getSubtitle($locale=null)
Definition: Chapter.inc.php:116
DataObject\setData
setData($key, $value, $locale=null)
Definition: DataObject.inc.php:132
Chapter\getStoredPubId
getStoredPubId($pubIdType)
Definition: Chapter.inc.php:175
Chapter\setPages
setPages($pages)
Definition: Chapter.inc.php:249