Ejemplo n.º 1
0
 /**
  * Display this galley in some manner.
  *
  * @param $publishedMonograph PublishedMonograph
  * @param $submissionFile SubmissionFile
  */
 function displaySubmissionFile($publishedMonograph, $publicationFormat, $submissionFile)
 {
     $templateMgr = TemplateManager::getManager($this->getRequest());
     $templateFilename = $this->getTemplateFilename();
     if ($templateFilename === null) {
         return '';
     }
     // Set up the viewable file template variables.
     $submissionKeywordDao = DAORegistry::getDAO('SubmissionKeywordDAO');
     $chapterDao = DAORegistry::getDAO('ChapterDAO');
     $genreDao = DAORegistry::getDAO('GenreDAO');
     // Find a good candidate for a publication date
     $publicationDateDao = DAORegistry::getDAO('PublicationDateDAO');
     $publicationDates = $publicationDateDao->getByPublicationFormatId($publicationFormat->getId());
     $bestPublicationDate = null;
     while ($publicationDate = $publicationDates->next()) {
         // 11: Date of first publication; 01: Publication date
         if ($publicationDate->getRole() != '11' && $publicationDate->getRole() != '01') {
             continue;
         }
         if ($bestPublicationDate) {
             $bestPublicationDate = min($bestPublicationDate, $publicationDate->getUnixTime());
         } else {
             $bestPublicationDate = $publicationDate->getUnixTime();
         }
     }
     $templateMgr->assign(array('submissionKeywords' => $submissionKeywordDao->getKeywords($publishedMonograph->getId(), array_merge(array(AppLocale::getLocale()), array_keys(AppLocale::getSupportedLocales()))), 'publishedMonograph' => $publishedMonograph, 'publicationFormat' => $publicationFormat, 'submissionFile' => $submissionFile, 'chapter' => $chapterDao->getChapter($submissionFile->getData('chapterId')), 'genre' => $genreDao->getById($submissionFile->getGenreId()), 'bestPublicationDate' => $bestPublicationDate));
     // Fetch the viewable file template render.
     $templateMgr->assign('viewableFileContent', $templateMgr->fetch($this->getTemplatePath() . $templateFilename));
     // Show the front-end.
     $templateMgr->display('frontend/pages/viewFile.tpl');
 }
 /**
  * Iterate through the localized params for a notification's locale key.
  *  For each parameter, return (in preferred order) a value for the user's current locale,
  *  a param for the journal's default locale, or the first value (in case the value
  *  is not localized)
  * @param $params array
  * @return array
  */
 public function getParamsForCurrentLocale($params)
 {
     $locale = AppLocale::getLocale();
     $primaryLocale = AppLocale::getPrimaryLocale();
     $localizedParams = array();
     foreach ($params as $name => $value) {
         if (!is_array($value)) {
             // Non-localized text
             $localizedParams[$name] = $value;
         } elseif (isset($value[$locale])) {
             // Check if the parameter is in the user's current locale
             $localizedParams[$name] = $value[$locale];
         } elseif (isset($value[$primaryLocale])) {
             // Check if the parameter is in the default site locale
             $localizedParams[$name] = $value[$primaryLocale];
         } else {
             // Otherwise, iterate over all supported locales and return the first match
             $locales = AppLocale::getSupportedLocales();
             foreach ($locales as $localeKey) {
                 if (isset($value[$localeKey])) {
                     $localizedParams[$name] = $value[$localeKey];
                 }
             }
         }
     }
     return $localizedParams;
 }
Ejemplo n.º 3
0
 /**
  * @copydoc Form::initData()
  */
 function initData($request)
 {
     $site = $request->getSite();
     $fileSettingName = $this->getFileSettingName();
     $image = $site->getSetting($fileSettingName);
     $imageAltText = array();
     $supportedLocales = AppLocale::getSupportedLocales();
     foreach ($supportedLocales as $key => $locale) {
         $imageAltText[$key] = $image[$key]['altText'];
     }
     $this->setData('imageAltText', $imageAltText);
 }
Ejemplo n.º 4
0
 /**
  * Return the key name of the user's currently selected locale (default
  * is "en_US" for U.S. English).
  * @return string
  */
 static function getLocale()
 {
     static $currentLocale;
     if (!isset($currentLocale)) {
         if (defined('SESSION_DISABLE_INIT') || !Config::getVar('general', 'installed')) {
             // If the locale is specified in the URL, allow
             // it to override. (Necessary when locale is
             // being set, as cookie will not yet be re-set)
             $locale = self::$request->getUserVar('setLocale');
             if (empty($locale) || !in_array($locale, array_keys(AppLocale::getSupportedLocales()))) {
                 $locale = self::$request->getCookieVar('currentLocale');
             }
         } else {
             $sessionManager = SessionManager::getManager();
             $session = $sessionManager->getUserSession();
             $locale = self::$request->getUserVar('uiLocale');
             $press = self::$request->getPress();
             $site = self::$request->getSite();
             if (!isset($locale)) {
                 $locale = $session->getSessionVar('currentLocale');
             }
             if (!isset($locale)) {
                 $locale = self::$request->getCookieVar('currentLocale');
             }
             if (isset($locale)) {
                 // Check if user-specified locale is supported
                 if ($press != null) {
                     $locales = $press->getSupportedLocaleNames();
                 } else {
                     $locales = $site->getSupportedLocaleNames();
                 }
                 if (!in_array($locale, array_keys($locales))) {
                     unset($locale);
                 }
             }
             if (!isset($locale)) {
                 // Use press/site default
                 if ($press != null) {
                     $locale = $press->getPrimaryLocale();
                 }
                 if (!isset($locale)) {
                     $locale = $site->getPrimaryLocale();
                 }
             }
         }
         if (!AppLocale::isLocaleValid($locale)) {
             $locale = LOCALE_DEFAULT;
         }
         $currentLocale = $locale;
     }
     return $currentLocale;
 }
 /**
  * @copydoc Form::initData()
  */
 function initData($request)
 {
     $context = $request->getContext();
     $fileSettingName = $this->getFileSettingName();
     $image = $context->getSetting($fileSettingName);
     $imageAltText = array();
     $supportedLocales = AppLocale::getSupportedLocales();
     foreach ($supportedLocales as $key => $locale) {
         if (!isset($image[$key]['altText'])) {
             continue;
         }
         $imageAltText[$key] = $image[$key]['altText'];
     }
     $this->setData('imageAltText', $imageAltText);
 }
Ejemplo n.º 6
0
 /**
  * Delete a book for review by book ID.
  * @param $bookId int
  */
 function deleteBookForReviewById($bookId)
 {
     $book =& $this->getBookForReview($bookId);
     if ($book) {
         // Delete authors
         $this->bookForReviewAuthorDao->deleteAuthorsByBookForReview($bookId);
         // Delete cover image files (for all locales) from the filesystem
         import('classes.file.PublicFileManager');
         $publicFileManager = new PublicFileManager();
         $locales = AppLocale::getSupportedLocales();
         foreach ($locales as $locale) {
             $publicFileManager->removeJournalFile($book->getJournalId(), $book->getFileName($locale));
         }
         // Delete settings
         $this->update('DELETE FROM books_for_review_settings WHERE book_id = ?', $bookId);
         // Delete book
         $this->update('DELETE FROM books_for_review WHERE book_id = ?', $bookId);
     }
 }
 /**
  * Translate an ISO639-3 compatible 3-letter string
  * into the PKP locale identifier.
  *
  * This can be ambiguous if several locales are defined
  * for the same language. In this case we'll use the
  * primary locale to disambiguate.
  *
  * If that still doesn't determine a unique locale then
  * we'll choose the first locale found.
  *
  * @param $iso3 string
  * @return string
  */
 function getLocaleFromIso3($iso3)
 {
     assert(strlen($iso3) == 3);
     $primaryLocale = AppLocale::getPrimaryLocale();
     $localeCandidates = array();
     $locales =& AppLocale::_getAllLocalesCacheContent();
     foreach ($locales as $locale => $localeData) {
         assert(isset($localeData['iso639-3']));
         if ($localeData['iso639-3'] == $iso3) {
             if ($locale == $primaryLocale) {
                 // In case of ambiguity the primary locale
                 // overrides all other options so we're done.
                 return $primaryLocale;
             }
             $localeCandidates[] = $locale;
         }
     }
     // Return null if we found no candidate locale.
     if (empty($localeCandidates)) {
         return null;
     }
     if (count($localeCandidates) > 1) {
         // Check whether one of the candidate locales
         // is a supported locale. If so choose the first
         // supported locale.
         $supportedLocales = AppLocale::getSupportedLocales();
         foreach ($supportedLocales as $supportedLocale => $localeName) {
             if (in_array($supportedLocale, $localeCandidates)) {
                 return $supportedLocale;
             }
         }
     }
     // If there is only one candidate (or if we were
     // unable to disambiguate) then return the unique
     // (first) candidate found.
     return array_shift($localeCandidates);
 }
 /**
  * Save checklist entry.
  */
 function execute($args, $request)
 {
     $router = $request->getRouter();
     $context = $router->getContext($request);
     $submissionChecklistAll = $context->getSetting('submissionChecklist');
     $locale = AppLocale::getPrimaryLocale();
     //FIXME: a bit of kludge to get unique submissionChecklist id's
     $this->submissionChecklistId = $this->submissionChecklistId != null ? $this->submissionChecklistId : max(array_keys($submissionChecklistAll[$locale])) + 1;
     $order = 0;
     foreach ($submissionChecklistAll[$locale] as $checklistItem) {
         if ($checklistItem['order'] > $order) {
             $order = $checklistItem['order'];
         }
     }
     $order++;
     $checklistItem = $this->getData('checklistItem');
     foreach (AppLocale::getSupportedLocales() as $locale => $name) {
         if (isset($checklistItem[$locale])) {
             $submissionChecklistAll[$locale][$this->submissionChecklistId]['content'] = $checklistItem[$locale];
             $submissionChecklistAll[$locale][$this->submissionChecklistId]['order'] = $order;
         }
     }
     $context->updateSetting('submissionChecklist', $submissionChecklistAll, 'object', true);
     return true;
 }
Ejemplo n.º 9
0
 /**
  * Return an instance of the template manager.
  * @param $request PKPRequest FIXME: is optional for backwards compatibility only - make mandatory
  * @return TemplateManager the template manager object
  */
 function &getManager($request = null)
 {
     $instance =& Registry::get('templateManager', true, null);
     if ($instance === null) {
         $instance = new TemplateManager($request);
     }
     $supportedLocales = AppLocale::getSupportedLocales();
     $instance->assign('supportedLocales', $supportedLocales);
     $instance->assign('localePrecedence', AppLocale::getLocalePrecedence());
     $instance->assign('requestedPage', Request::getRequestedPage());
     $instance->assign('requestedOp', Request::getRequestedOp());
     $conference =& Request::getConference();
     if (isset($conference)) {
         $instance->assign('conferenceId', $conference->getId());
         $instance->assign('isConferenceManager', Validation::isConferenceManager($conference->getId()));
         $instance->assign('analyticsTrackingID', $conference->getSetting('analyticsTrackingID'));
         $schedConf =& Request::getSchedConf();
         if (isset($schedConf)) {
             $instance->assign('isDirector', Validation::isDirector($conference->getId(), $schedConf->getId()));
             $instance->assign('isTrackDirector', Validation::isTrackDirector($conference->getId(), $schedConf->getId()));
             $instance->assign('isAuthor', Validation::isAuthor($conference->getId(), $schedConf->getId()));
             $registrationDao =& DAORegistry::getDAO('RegistrationDAO');
             $user = Request::getUser();
             if (isset($user)) {
                 $instance->assign('isRegistrationUser', $registrationDao->isValidRegistrationByUser($user->getUserId(), $schedConf->getId()));
             }
         }
     }
     AppLocale::requireComponents(array(LOCALE_COMPONENT_OCS_MANAGER, LOCALE_COMPONENT_OCS_ADMIN, LOCALE_COMPONENT_OCS_DIRECTOR, LOCALE_COMPONENT_PKP_MANAGER, LOCALE_COMPONENT_PKP_SUBMISSION));
     // FIXME: For timeline constants
     return $instance;
 }
 /**
  * Delete a submissionChecklist
  * @param $args array
  * @param $request PKPRequest
  * @return JSONMessage JSON object
  */
 function deleteItem($args, $request)
 {
     if (!$request->checkCSRF()) {
         return new JSONMessage(false);
     }
     $rowId = $request->getUserVar('rowId');
     $router = $request->getRouter();
     $context = $router->getContext($request);
     // get all of the submissionChecklists
     $submissionChecklistAll = $context->getSetting('submissionChecklist');
     foreach (AppLocale::getSupportedLocales() as $locale => $name) {
         if (isset($submissionChecklistAll[$locale][$rowId])) {
             unset($submissionChecklistAll[$locale][$rowId]);
         } else {
             // only fail if the currently displayed locale was not set
             // (this is the one that needs to be removed from the currently displayed grid)
             if ($locale == AppLocale::getLocale()) {
                 return new JSONMessage(false, __('manager.setup.errorDeletingSubmissionChecklist'));
             }
         }
     }
     $context->updateSetting('submissionChecklist', $submissionChecklistAll, 'object', true);
     return DAO::getDataChangedEvent($rowId);
 }
Ejemplo n.º 11
0
 function smartyFBVElementMultilingual($params, &$smarty, $content = null)
 {
     if (!isset($params['value']) || !is_array($params['value'])) {
         $smarty->trigger_error('FBV: value parameter must be an array for multilingual elements');
     }
     if (!isset($params['name'])) {
         $smarty->trigger_error('FBV: parameter must be set');
     }
     $required = isset($params['required']) ? $params['required'] : false;
     $returner = '';
     $values = $params['value'];
     $name = $params['name'];
     foreach (AppLocale::getSupportedLocales() as $locale => $localeName) {
         // if the field is required, only set the main locale as required and others optional
         if ($locale == AppLocale::getPrimaryLocale()) {
             $params['required'] = $required;
         } else {
             $params['required'] = false;
         }
         $params['name'] = $name . "[{$locale}]";
         $params['value'] = $values[$locale];
         $returner .= $localeName . ' ' . $this->smartyFBVElement($params, $smarty, $content) . '<br />';
     }
     return $returner;
 }