00001 <?php
00002
00020
00021
00022
00023 class Journal extends DataObject {
00027 function Journal() {
00028 parent::DataObject();
00029 }
00030
00035 function getUrl() {
00036 return Request::url($this->getPath());
00037 }
00038
00043 function getPrimaryLocale() {
00044 return $this->getData('primaryLocale');
00045 }
00046
00051 function setPrimaryLocale($primaryLocale) {
00052 return $this->setData('primaryLocale', $primaryLocale);
00053 }
00054
00060 function &getSupportedLocaleNames() {
00061 $supportedLocales =& $this->getData('supportedLocales');
00062
00063 if (!isset($supportedLocales)) {
00064 $supportedLocales = array();
00065 $localeNames = &Locale::getAllLocales();
00066
00067 $locales = $this->getSetting('supportedLocales');
00068 if (!isset($locales) || !is_array($locales)) {
00069 $locales = array();
00070 }
00071
00072 foreach ($locales as $localeKey) {
00073 $supportedLocales[$localeKey] = $localeNames[$localeKey];
00074 }
00075 }
00076
00077 return $supportedLocales;
00078 }
00079
00085 function getJournalPageHeaderTitle($home = false) {
00086 $prefix = $home ? 'home' : 'page';
00087 $typeArray = $this->getSetting($prefix . 'HeaderTitleType');
00088 $imageArray = $this->getSetting($prefix . 'HeaderTitleImage');
00089 $titleArray = $this->getSetting($prefix . 'HeaderTitle');
00090
00091 $title = null;
00092
00093 foreach (array(Locale::getLocale(), Locale::getPrimaryLocale()) as $locale) {
00094 if (isset($typeArray[$locale]) && $typeArray[$locale]) {
00095 if (isset($imageArray[$locale])) $title = $imageArray[$locale];
00096 }
00097 if (empty($title) && isset($titleArray[$locale])) $title = $titleArray[$locale];
00098 if (!empty($title)) return $title;
00099 }
00100 return null;
00101 }
00102
00108 function getJournalPageHeaderLogo($home = false) {
00109 $prefix = $home ? 'home' : 'page';
00110 $logoArray = $this->getSetting($prefix . 'HeaderLogoImage');
00111 foreach (array(Locale::getLocale(), Locale::getPrimaryLocale()) as $locale) {
00112 if (isset($logoArray[$locale])) return $logoArray[$locale];
00113 }
00114 return null;
00115 }
00116
00117
00118
00119
00120
00125 function getJournalTitle() {
00126 return $this->getLocalizedSetting('title');
00127 }
00128
00134 function getTitle($locale) {
00135 return $this->getSetting('title', $locale);
00136 }
00137
00142 function getJournalInitials() {
00143 return $this->getLocalizedSetting('initials');
00144 }
00145
00151 function getInitials($locale) {
00152 return $this->getSetting('initials', $locale);
00153 }
00154
00159 function getEnabled() {
00160 return $this->getData('enabled');
00161 }
00162
00167 function setEnabled($enabled) {
00168 return $this->setData('enabled',$enabled);
00169 }
00170
00175 function getJournalId() {
00176 return $this->getData('journalId');
00177 }
00178
00183 function setJournalId($journalId) {
00184 return $this->setData('journalId', $journalId);
00185 }
00186
00191 function getJournalDescription() {
00192 return $this->getDescription(Locale::getLocale());
00193 }
00194
00200 function getDescription($locale) {
00201 return $this->getSetting('description', $locale);
00202 }
00203
00208 function getPath() {
00209 return $this->getData('path');
00210 }
00211
00216 function setPath($path) {
00217 return $this->setData('path', $path);
00218 }
00219
00224 function getSequence() {
00225 return $this->getData('sequence');
00226 }
00227
00232 function setSequence($sequence) {
00233 return $this->setData('sequence', $sequence);
00234 }
00235
00240 function &getSettings() {
00241 $journalSettingsDao = &DAORegistry::getDAO('JournalSettingsDAO');
00242 $settings = &$journalSettingsDao->getJournalSettings($this->getData('journalId'));
00243 return $settings;
00244 }
00245
00246 function &getLocalizedSetting($name) {
00247 $returner = $this->getSetting($name, Locale::getLocale());
00248 if ($returner === null) {
00249 unset($returner);
00250 $returner = $this->getSetting($name, Locale::getPrimaryLocale());
00251 }
00252 return $returner;
00253 }
00254
00261 function &getSetting($name, $locale = null) {
00262 $journalSettingsDao = &DAORegistry::getDAO('JournalSettingsDAO');
00263 $setting = &$journalSettingsDao->getSetting($this->getData('journalId'), $name, $locale);
00264 return $setting;
00265 }
00266
00274 function updateSetting($name, $value, $type = null, $isLocalized = false) {
00275 $journalSettingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
00276 return $journalSettingsDao->updateSetting($this->getJournalId(), $name, $value, $type, $isLocalized);
00277 }
00278 }
00279
00280 ?>