Open Journal Systems  3.3.0
PKPAuthor.inc.php
1 <?php
2 
17 import('lib.pkp.classes.identity.Identity');
18 
19 class PKPAuthor extends Identity {
20 
28  function &getLocalizedData($key, $preferredLocale = null) {
29  if (is_null($preferredLocale)) $preferredLocale = AppLocale::getLocale();
30  $localePrecedence = array($preferredLocale);
31  // the submission locale is the default locale
32  if (!in_array($this->getSubmissionLocale(), $localePrecedence)) $localePrecedence[] = $this->getSubmissionLocale();
33  // for settings other than givenName, familyName and affiliation (that are required)
34  // consider also the application primary locale
35  if (!in_array(AppLocale::getPrimaryLocale(), $localePrecedence)) $localePrecedence[] = AppLocale::getPrimaryLocale();
36  foreach ($localePrecedence as $locale) {
37  if (empty($locale)) continue;
38  $value =& $this->getData($key, $locale);
39  if (!empty($value)) return $value;
40  unset($value);
41  }
42 
43  // Fallback: Get the first available piece of data.
44  $data =& $this->getData($key, null);
45  foreach ((array) $data as $dataValue) {
46  if (!empty($dataValue)) return $dataValue;
47  }
48 
49  // No data available; return null.
50  unset($data);
51  $data = null;
52  return $data;
53  }
54 
58  function getLocalizedGivenName($defaultLocale = null) {
59  if (!isset($defaultLocale)) $defaultLocale = $this->getSubmissionLocale();
60 
61  return parent::getLocalizedGivenName($defaultLocale);
62  }
63 
67  function getLocalizedFamilyName($defaultLocale = null) {
68  if (!isset($defaultLocale)) $defaultLocale = $this->getSubmissionLocale();
69 
70  return parent::getLocalizedFamilyName($defaultLocale);
71  }
72 
76  function getFullName($preferred = true, $familyFirst = false, $defaultLocale = null) {
77  if (!isset($defaultLocale)) $defaultLocale = $this->getSubmissionLocale();
78  return parent::getFullName($preferred, $familyFirst, $defaultLocale);
79  }
80 
81  //
82  // Get/set methods
83  //
84 
89  function getSubmissionId() {
90  return $this->getData('submissionId');
91  }
92 
97  function setSubmissionId($submissionId) {
98  $this->setData('submissionId', $submissionId);
99  }
100 
105  function getSubmissionLocale() {
106  return $this->getData('submissionLocale');
107  }
108 
113  function setSubmissionLocale($submissionLocale) {
114  return $this->setData('submissionLocale', $submissionLocale);
115  }
116 
121  function setUserGroupId($userGroupId) {
122  $this->setData('userGroupId', $userGroupId);
123  }
124 
129  function getUserGroupId() {
130  return $this->getData('userGroupId');
131  }
132 
137  function setIncludeInBrowse($include) {
138  $this->setData('includeInBrowse', $include);
139  }
140 
145  function getIncludeInBrowse() {
146  return $this->getData('includeInBrowse');
147  }
148 
155  function getShowTitle() {
156  return $this->getData('showTitle');
157  }
158 
164  function _setShowTitle($showTitle) {
165  $this->setData('showTitle', $showTitle);
166  }
167 
172  function getPrimaryContact() {
173  return $this->getData('primaryContact');
174  }
175 
180  function setPrimaryContact($primaryContact) {
181  $this->setData('primaryContact', $primaryContact);
182  }
183 
188  function getSequence() {
189  return $this->getData('seq');
190  }
191 
196  function setSequence($sequence) {
197  $this->setData('seq', $sequence);
198  }
199 
203  function getUserGroup() {
204  //FIXME: should this be queried when fetching Author from DB? - see #5231.
205  static $userGroup; // Frequently we'll fetch the same one repeatedly
206  if (!$userGroup || $this->getUserGroupId() != $userGroup->getId()) {
207  $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */
208  $userGroup = $userGroupDao->getById($this->getUserGroupId());
209  }
210  return $userGroup;
211  }
212 
218  $userGroup = $this->getUserGroup();
219  return $userGroup->getLocalizedName();
220  }
221 }
222 
223 
DataObject\getData
& getData($key, $locale=null)
Definition: DataObject.inc.php:100
PKPAuthor\getLocalizedData
& getLocalizedData($key, $preferredLocale=null)
Definition: PKPAuthor.inc.php:28
PKPAuthor\getSequence
getSequence()
Definition: PKPAuthor.inc.php:188
PKPAuthor\getLocalizedUserGroupName
getLocalizedUserGroupName()
Definition: PKPAuthor.inc.php:217
DAORegistry\getDAO
static & getDAO($name, $dbconn=null)
Definition: DAORegistry.inc.php:57
PKPAuthor\setSequence
setSequence($sequence)
Definition: PKPAuthor.inc.php:196
PKPAuthor\setSubmissionId
setSubmissionId($submissionId)
Definition: PKPAuthor.inc.php:97
AppLocale\getPrimaryLocale
static getPrimaryLocale()
Definition: env1/MockAppLocale.inc.php:95
PKPAuthor\_setShowTitle
_setShowTitle($showTitle)
Definition: PKPAuthor.inc.php:164
PKPAuthor\getLocalizedFamilyName
getLocalizedFamilyName($defaultLocale=null)
Definition: PKPAuthor.inc.php:67
PKPAuthor\setPrimaryContact
setPrimaryContact($primaryContact)
Definition: PKPAuthor.inc.php:180
PKPAuthor\getUserGroupId
getUserGroupId()
Definition: PKPAuthor.inc.php:129
PKPAuthor\getIncludeInBrowse
getIncludeInBrowse()
Definition: PKPAuthor.inc.php:145
PKPAuthor\getShowTitle
getShowTitle()
Definition: PKPAuthor.inc.php:155
PKPAuthor\getSubmissionId
getSubmissionId()
Definition: PKPAuthor.inc.php:89
PKPAuthor\getSubmissionLocale
getSubmissionLocale()
Definition: PKPAuthor.inc.php:105
PKPAuthor\setUserGroupId
setUserGroupId($userGroupId)
Definition: PKPAuthor.inc.php:121
PKPAuthor\getLocalizedGivenName
getLocalizedGivenName($defaultLocale=null)
Definition: PKPAuthor.inc.php:58
Identity
Basic class providing common functionality for users and authors in the system.
Definition: Identity.inc.php:25
PKPAuthor\getFullName
getFullName($preferred=true, $familyFirst=false, $defaultLocale=null)
Definition: PKPAuthor.inc.php:76
PKPAuthor\setIncludeInBrowse
setIncludeInBrowse($include)
Definition: PKPAuthor.inc.php:137
AppLocale\getLocale
static getLocale()
Definition: env1/MockAppLocale.inc.php:40
PKPAuthor\setSubmissionLocale
setSubmissionLocale($submissionLocale)
Definition: PKPAuthor.inc.php:113
PKPAuthor\getPrimaryContact
getPrimaryContact()
Definition: PKPAuthor.inc.php:172
PKPAuthor\getUserGroup
getUserGroup()
Definition: PKPAuthor.inc.php:203
DataObject\setData
setData($key, $value, $locale=null)
Definition: DataObject.inc.php:132
PKPAuthor
Author metadata class.
Definition: PKPAuthor.inc.php:19