Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
Site.inc.php
1 <?php
2 
23 class Site extends DataObject {
27  function Site() {
28  parent::DataObject();
29  }
30 
37  $supportedLocales =& Registry::get('siteSupportedLocales', true, null);
38 
39  if ($supportedLocales === null) {
40  $supportedLocales = array();
41  $localeNames =& AppLocale::getAllLocales();
42 
43  $locales = $this->getSupportedLocales();
44  foreach ($locales as $localeKey) {
45  $supportedLocales[$localeKey] = $localeNames[$localeKey];
46  }
47 
48  asort($supportedLocales);
49  }
50 
51  return $supportedLocales;
52  }
53 
54  //
55  // Get/set methods
56  //
57 
61  function getLocalizedTitle() {
62  return $this->getLocalizedSetting('title');
63  }
64 
70  $typeArray = $this->getSetting('pageHeaderTitleType');
71  $imageArray = $this->getSetting('pageHeaderTitleImage');
72  $titleArray = $this->getSetting('title');
73 
74  $title = null;
75 
76  foreach (array(AppLocale::getLocale(), AppLocale::getPrimaryLocale()) as $locale) {
77  if (isset($typeArray[$locale]) && $typeArray[$locale]) {
78  if (isset($imageArray[$locale])) $title = $imageArray[$locale];
79  }
80  if (empty($title) && isset($titleArray[$locale])) $title = $titleArray[$locale];
81  if (!empty($title)) return $title;
82  }
83  return null;
84  }
85 
91  return $this->getLocalizedData('pageHeaderTitleType');
92  }
93 
99  return $this->getData('originalStyleFilename');
100  }
101 
106  function setOriginalStyleFilename($originalStyleFilename) {
107  return $this->setData('originalStyleFilename', $originalStyleFilename);
108  }
109 
113  function getLocalizedIntro() {
114  return $this->getLocalizedSetting('intro');
115  }
116 
121  function getRedirect() {
122  return $this->getData('redirect');
123  }
124 
129  function setRedirect($redirect) {
130  return $this->setData('redirect', (int)$redirect);
131  }
132 
136  function getLocalizedAbout() {
137  return $this->getLocalizedSetting('about');
138  }
139 
144  return $this->getLocalizedSetting('contactName');
145  }
146 
151  return $this->getLocalizedSetting('contactEmail');
152  }
153 
158  function getMinPasswordLength() {
159  return $this->getData('minPasswordLength');
160  }
161 
166  function setMinPasswordLength($minPasswordLength) {
167  return $this->setData('minPasswordLength', $minPasswordLength);
168  }
169 
174  function getPrimaryLocale() {
175  return $this->getData('primaryLocale');
176  }
177 
182  function setPrimaryLocale($primaryLocale) {
183  return $this->setData('primaryLocale', $primaryLocale);
184  }
185 
190  function getInstalledLocales() {
191  $locales = $this->getData('installedLocales');
192  return isset($locales) ? $locales : array();
193  }
194 
199  function setInstalledLocales($installedLocales) {
200  return $this->setData('installedLocales', $installedLocales);
201  }
202 
207  function getSupportedLocales() {
208  $locales = $this->getData('supportedLocales');
209  return isset($locales) ? $locales : array();
210  }
211 
216  function setSupportedLocales($supportedLocales) {
217  return $this->setData('supportedLocales', $supportedLocales);
218  }
219 
224  function getSiteStyleFilename() {
225  return 'sitestyle.css';
226  }
227 
234  function &getSetting($name, $locale = null) {
235  $siteSettingsDao = DAORegistry::getDAO('SiteSettingsDAO');
236  $setting =& $siteSettingsDao->getSetting($name, $locale);
237  return $setting;
238  }
239 
240  function getLocalizedSetting($name) {
241  $returner = $this->getSetting($name, AppLocale::getLocale());
242  // If setting is defined for current locale, use it.
243  if ($returner !== null) return $returner;
244  // Alternately, fall back on primary locale.
245  return $this->getSetting($name, AppLocale::getPrimaryLocale());
246  }
247 
255  function updateSetting($name, $value, $type = null, $isLocalized = false) {
256  $siteSettingsDao = DAORegistry::getDAO('SiteSettingsDAO');
257  return $siteSettingsDao->updateSetting($name, $value, $type, $isLocalized);
258  }
259 }
260 
261 ?>
getOriginalStyleFilename()
Definition: Site.inc.php:98
static & getDAO($name, $dbconn=null)
updateSetting($name, $value, $type=null, $isLocalized=false)
Definition: Site.inc.php:255
& getSupportedLocaleNames()
Definition: Site.inc.php:36
static getPrimaryLocale()
& getSetting($name, $locale=null)
Definition: Site.inc.php:234
& getLocalizedData($key)
getInstalledLocales()
Definition: Site.inc.php:190
setInstalledLocales($installedLocales)
Definition: Site.inc.php:199
setOriginalStyleFilename($originalStyleFilename)
Definition: Site.inc.php:106
getLocalizedIntro()
Definition: Site.inc.php:113
getLocalizedPageHeaderTitleType()
Definition: Site.inc.php:90
static & getAllLocales()
& getData($key, $locale=null)
static getLocale()
getLocalizedContactEmail()
Definition: Site.inc.php:150
getLocalizedAbout()
Definition: Site.inc.php:136
setPrimaryLocale($primaryLocale)
Definition: Site.inc.php:182
getLocalizedTitle()
Definition: Site.inc.php:61
getPrimaryLocale()
Definition: Site.inc.php:174
setSupportedLocales($supportedLocales)
Definition: Site.inc.php:216
getRedirect()
Definition: Site.inc.php:121
setRedirect($redirect)
Definition: Site.inc.php:129
getMinPasswordLength()
Definition: Site.inc.php:158
Any class with an associated DAO should extend this class.
setData($key, $value, $locale=null)
static & get($key, $createIfEmpty=false, $createWithDefault=null)
Describes system-wide site properties.
Definition: Site.inc.php:23
Site()
Definition: Site.inc.php:27
getLocalizedPageHeaderTitle()
Definition: Site.inc.php:69
getLocalizedContactName()
Definition: Site.inc.php:143
setMinPasswordLength($minPasswordLength)
Definition: Site.inc.php:166
getSupportedLocales()
Definition: Site.inc.php:207
getSiteStyleFilename()
Definition: Site.inc.php:224