ocs  2.3.6
About: OCS (Open Conference System) is a Web publishing tool that will create a complete Web presence for your scholarly conference.
  Fossies Dox: ocs-2.3.6.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

AppLocale.inc.php
Go to the documentation of this file.
1 <?php
2 
16 // $Id$
17 
18 
19 import('i18n.PKPLocale');
20 
21 define('LOCALE_COMPONENT_APPLICATION_COMMON', 0x00000101);
22 define('LOCALE_COMPONENT_OCS_AUTHOR', 0x00000102);
23 define('LOCALE_COMPONENT_OCS_DIRECTOR', 0x00000103);
24 define('LOCALE_COMPONENT_OCS_MANAGER', 0x00000104);
25 define('LOCALE_COMPONENT_OCS_ADMIN', 0x00000105);
26 define('LOCALE_COMPONENT_OCS_DEFAULT', 0x00000106);
27 
28 class AppLocale extends PKPLocale {
33  function getSupportedLocales() {
34  static $supportedLocales;
35  if (!isset($supportedLocales)) {
36  if (defined('SESSION_DISABLE_INIT') || !Config::getVar('general', 'installed')) {
37  $supportedLocales = AppLocale::getAllLocales();
38  } elseif (($conference =& Request::getConference())) {
39  $supportedLocales = $conference->getSupportedLocaleNames();
40  } else {
41  $site =& Request::getSite();
42  $supportedLocales = $site->getSupportedLocaleNames();
43  }
44  }
45  return $supportedLocales;
46  }
47 
53  static $supportedFormLocales;
54  if (!isset($supportedFormLocales)) {
55  if (defined('SESSION_DISABLE_INIT') || !Config::getVar('general', 'installed')) {
56  $supportedFormLocales = AppLocale::getAllLocales();
57  } elseif (($conference =& Request::getConference())) {
58  $supportedFormLocales = $conference->getSupportedFormLocaleNames();
59  } else {
60  $site =& Request::getSite();
61  $supportedFormLocales = $site->getSupportedLocaleNames();
62  }
63  }
64  return $supportedFormLocales;
65  }
66 
72  function getLocale() {
73  static $currentLocale;
74  if (!isset($currentLocale)) {
75  if (defined('SESSION_DISABLE_INIT') || !Config::getVar('general', 'installed')) {
76  // If the locale is specified in the URL, allow
77  // it to override. (Necessary when locale is
78  // being set, as cookie will not yet be re-set)
79  $locale = Request::getUserVar('setLocale');
80  if (empty($locale) || !in_array($locale, array_keys(AppLocale::getSupportedLocales()))) $locale = Request::getCookieVar('currentLocale');
81  } else {
82  $sessionManager =& SessionManager::getManager();
83  $session =& $sessionManager->getUserSession();
84  $locale = $session->getSessionVar('currentLocale');
85 
86  $conference =& Request::getConference();
87  $site =& Request::getSite();
88 
89  if (!isset($locale)) {
90  $locale = Request::getCookieVar('currentLocale');
91  }
92 
93  if (isset($locale)) {
94  // Check if user-specified locale is supported
95  if ($conference != null) {
96  $locales =& $conference->getSupportedLocaleNames();
97  } else {
98  $locales =& $site->getSupportedLocaleNames();
99  }
100 
101  if (!in_array($locale, array_keys($locales))) {
102  unset($locale);
103  }
104  }
105 
106  if (!isset($locale)) {
107  // Use conference/site default
108  if ($conference != null) {
109  $locale = $conference->getPrimaryLocale();
110  }
111 
112  if (!isset($locale)) {
113  $locale = $site->getPrimaryLocale();
114  }
115  }
116  }
117 
118  if (!AppLocale::isLocaleValid($locale)) {
119  $locale = LOCALE_DEFAULT;
120  }
121 
122  $currentLocale = $locale;
123  }
124  return $currentLocale;
125  }
126 
131  function getLocalePrecedence() {
132  static $localePrecedence;
133  if (!isset($localePrecedence)) {
134  $localePrecedence = array(AppLocale::getLocale());
135 
136  $conference =& Request::getConference();
137  if ($conference && !in_array($conference->getPrimaryLocale(), $localePrecedence)) $localePrecedence[] = $conference->getPrimaryLocale();
138 
139  $site =& Request::getSite();
140  if ($site && !in_array($site->getPrimaryLocale(), $localePrecedence)) $localePrecedence[] = $site->getPrimaryLocale();
141  }
142  return $localePrecedence;
143  }
144 
149  function getPrimaryLocale() {
150  $conference =& Request::getConference();
151 
152  if (isset($conference)) {
153  $locale = $conference->getPrimaryLocale();
154  }
155 
156  if (!isset($locale)) {
157  $site =& Request::getSite();
158  $locale = $site->getPrimaryLocale();
159  }
160 
161  if (!isset($locale) || !AppLocale::isLocaleValid($locale)) {
162  $locale = LOCALE_DEFAULT;
163  }
164 
165  return $locale;
166  }
167 
173  function makeComponentMap($locale) {
174  $componentMap = parent::makeComponentMap($locale);
175  $baseDir = "locale/$locale/";
176  $componentMap[LOCALE_COMPONENT_APPLICATION_COMMON] = $baseDir . 'locale.xml';
177  $componentMap[LOCALE_COMPONENT_OCS_AUTHOR] = $baseDir . 'author.xml';
178  $componentMap[LOCALE_COMPONENT_OCS_DIRECTOR] = $baseDir . 'director.xml';
179  $componentMap[LOCALE_COMPONENT_OCS_MANAGER] = $baseDir . 'manager.xml';
180  $componentMap[LOCALE_COMPONENT_OCS_ADMIN] = $baseDir . 'admin.xml';
181  $componentMap[LOCALE_COMPONENT_OCS_DEFAULT] = $baseDir . 'default.xml';
182  return $componentMap;
183  }
184 }
185 
186 if (!class_exists('Locale')) {
187  class Locale extends AppLocale {
188  // This is used for backwards compatibility (bug #5240)
189  }
190 }
191 
192 ?>
LOCALE_DEFAULT
const LOCALE_DEFAULT
Definition: PKPLocale.inc.php:25
AppLocale\makeComponentMap
makeComponentMap($locale)
Definition: AppLocale.inc.php:173
AppLocale\getLocale
getLocale()
Definition: AppLocale.inc.php:72
SessionManager\getManager
& getManager()
Definition: SessionManager.inc.php:111
Locale
Provides methods for loading locale data and translating strings identified by unique keys.
PKPRequest\getSite
& getSite()
Definition: PKPRequest.inc.php:439
PKPLocale\getAllLocales
& getAllLocales()
Definition: PKPLocale.inc.php:271
LOCALE_COMPONENT_OCS_AUTHOR
const LOCALE_COMPONENT_OCS_AUTHOR
Definition: AppLocale.inc.php:22
AppLocale\getPrimaryLocale
getPrimaryLocale()
Definition: AppLocale.inc.php:149
PKPLocale
Definition: PKPLocale.inc.php:52
AppLocale\getSupportedFormLocales
getSupportedFormLocales()
Definition: AppLocale.inc.php:52
PKPLocale\isLocaleValid
isLocaleValid($locale)
Definition: PKPLocale.inc.php:204
PKPRequest\getUserVar
getUserVar($key)
Definition: PKPRequest.inc.php:491
Config\getVar
getVar($section, $key, $default=null)
Definition: Config.inc.php:35
PKPRequest\getCookieVar
getCookieVar($key)
Definition: PKPRequest.inc.php:586
LOCALE_COMPONENT_OCS_ADMIN
const LOCALE_COMPONENT_OCS_ADMIN
Definition: AppLocale.inc.php:25
Request\getConference
& getConference()
Definition: Request.inc.php:81
LOCALE_COMPONENT_APPLICATION_COMMON
const LOCALE_COMPONENT_APPLICATION_COMMON
Definition: AppLocale.inc.php:21
AppLocale\getSupportedLocales
getSupportedLocales()
Definition: AppLocale.inc.php:33
php
config TEMPLATE inc php
Definition: config.inc.php:4
LOCALE_COMPONENT_OCS_MANAGER
const LOCALE_COMPONENT_OCS_MANAGER
Definition: AppLocale.inc.php:24
LOCALE_COMPONENT_OCS_DIRECTOR
const LOCALE_COMPONENT_OCS_DIRECTOR
Definition: AppLocale.inc.php:23
AppLocale\getLocalePrecedence
getLocalePrecedence()
Definition: AppLocale.inc.php:131
AppLocale
Definition: AppLocale.inc.php:28
LOCALE_COMPONENT_OCS_DEFAULT
const LOCALE_COMPONENT_OCS_DEFAULT
Definition: AppLocale.inc.php:26