Open Monograph Press  3.3.0
Spotlight.inc.php
1 <?php
2 
17 // type constants for spotlights
18 define('SPOTLIGHT_TYPE_BOOK', 3);
19 define('SPOTLIGHT_TYPE_SERIES', 4);
20 define('MAX_SPOTLIGHTS_VISIBLE', 3);
21 
22 class Spotlight extends DataObject {
26  function __construct() {
27  parent::__construct();
28  }
29 
30  //
31  // Get/set methods
32  //
33 
38  function getAssocId() {
39  return $this->getData('assocId');
40  }
41 
46  function setAssocId($assocId) {
47  return $this->setData('assocId', $assocId);
48  }
49 
54  function getAssocType() {
55  return $this->getData('assocType');
56  }
57 
62  function setAssocType($assocType) {
63  return $this->setData('assocType', $assocType);
64  }
65 
70  function getPressId() {
71  return $this->getData('pressId');
72  }
73 
78  function setPressId($pressId) {
79  return $this->setData('pressId', $pressId);
80  }
81 
86  function getLocalizedTitle() {
87  return $this->getLocalizedData('title');
88  }
89 
95  function getTitle($locale) {
96  return $this->getData('title', $locale);
97  }
98 
104  function setTitle($title, $locale) {
105  return $this->setData('title', $title, $locale);
106  }
107 
113  return $this->getLocalizedData('description');
114  }
115 
121  function getDescription($locale) {
122  return $this->getData('description', $locale);
123  }
124 
130  function setDescription($description, $locale) {
131  return $this->setData('description', $description, $locale);
132  }
133 
138  function getLocalizedType() {
139  $spotlightTypes = array(
140  SPOTLIGHT_TYPE_BOOK => __('grid.content.spotlights.form.type.book'),
141  SPOTLIGHT_TYPE_SERIES => __('series.series'),
142  );
143 
144  return $spotlightTypes[$this->getAssocType()];
145  }
146 
151  function getSpotlightItem() {
152  switch ($this->getAssocType()) {
153  case SPOTLIGHT_TYPE_BOOK:
154  return Services::get('submission')->get($this->getAssocId());
155  break;
156  case SPOTLIGHT_TYPE_SERIES:
157  $seriesDao = DAORegistry::getDAO('SeriesDAO'); /* @var $seriesDao SeriesDAO */
158  return $seriesDao->getById($this->getAssocId(), $this->getPressId());
159  break;
160  default:
161  assert(false);
162  break;
163  }
164  }
165 }
166 
167 
DataObject\getData
& getData($key, $locale=null)
Definition: DataObject.inc.php:100
DataObject\getLocalizedData
getLocalizedData($key, $preferredLocale=null)
Definition: DataObject.inc.php:71
Spotlight\getSpotlightItem
getSpotlightItem()
Definition: Spotlight.inc.php:151
Spotlight\__construct
__construct()
Definition: Spotlight.inc.php:26
Spotlight\setPressId
setPressId($pressId)
Definition: Spotlight.inc.php:78
DataObject
Any class with an associated DAO should extend this class.
Definition: DataObject.inc.php:18
Spotlight\getPressId
getPressId()
Definition: Spotlight.inc.php:70
DAORegistry\getDAO
static & getDAO($name, $dbconn=null)
Definition: DAORegistry.inc.php:57
Spotlight\setDescription
setDescription($description, $locale)
Definition: Spotlight.inc.php:130
Spotlight\getDescription
getDescription($locale)
Definition: Spotlight.inc.php:121
Spotlight\getLocalizedTitle
getLocalizedTitle()
Definition: Spotlight.inc.php:86
Spotlight\setAssocType
setAssocType($assocType)
Definition: Spotlight.inc.php:62
Spotlight\getTitle
getTitle($locale)
Definition: Spotlight.inc.php:95
Spotlight\getLocalizedDescription
getLocalizedDescription()
Definition: Spotlight.inc.php:112
Spotlight
Basic class describing a spotlight.
Definition: Spotlight.inc.php:22
Spotlight\getAssocType
getAssocType()
Definition: Spotlight.inc.php:54
Spotlight\getAssocId
getAssocId()
Definition: Spotlight.inc.php:38
Spotlight\setTitle
setTitle($title, $locale)
Definition: Spotlight.inc.php:104
Spotlight\setAssocId
setAssocId($assocId)
Definition: Spotlight.inc.php:46
DataObject\setData
setData($key, $value, $locale=null)
Definition: DataObject.inc.php:132
PKPServices\get
static get($service)
Definition: PKPServices.inc.php:49
Spotlight\getLocalizedType
getLocalizedType()
Definition: Spotlight.inc.php:138