/** * Display the form. */ function display() { $conference =& Request::getConference(); $schedConf =& Request::getSchedConf(); $user =& Request::getUser(); $templateMgr =& TemplateManager::getManager(); // Get tracks for this conference $trackDao = DAORegistry::getDAO('TrackDAO'); // If this user is a track director or a director, they are // allowed to submit to tracks flagged as "director-only" for // submissions. Otherwise, display only tracks they are allowed // to submit to. $roleDao = DAORegistry::getDAO('RoleDAO'); $isDirector = $roleDao->userHasRole($conference->getId(), $schedConf->getId(), $user->getId(), ROLE_ID_DIRECTOR) || $roleDao->userHasRole($conference->getId(), $schedConf->getId(), $user->getId(), ROLE_ID_TRACK_DIRECTOR) || $roleDao->userHasRole($conference->getId(), 0, $user->getId(), ROLE_ID_DIRECTOR) || $roleDao->userHasRole($conference->getId(), 0, $user->getId(), ROLE_ID_TRACK_DIRECTOR); $templateMgr->assign('trackOptions', array('0' => __('author.submit.selectTrack')) + $trackDao->getTrackTitles($schedConf->getId(), !$isDirector)); $paperTypeDao = DAORegistry::getDAO('PaperTypeDAO'); $sessionTypes = $paperTypeDao->getPaperTypes($schedConf->getId()); $templateMgr->assign('sessionTypes', $sessionTypes->toArray()); // Provide available submission languages. (Convert the array // of locale symbolic names xx_XX into an associative array // of symbolic names => readable names.) $supportedSubmissionLocales = $conference->getSetting('supportedSubmissionLocales'); if (empty($supportedSubmissionLocales)) { $supportedSubmissionLocales = array($conference->getPrimaryLocale()); } $templateMgr->assign('supportedSubmissionLocaleNames', array_flip(array_intersect(array_flip(AppLocale::getAllLocales()), $supportedSubmissionLocales))); parent::display(); }
/** * Execute the command */ function execute() { $stderr = fopen('php://stdout', 'w'); $locales = AppLocale::getAllLocales(); $dbConn = DBConnection::getConn(); foreach ($locales as $locale => $localeName) { fprintf($stderr, "Checking {$localeName}...\n"); $oldTemplatesText = $this->fetchFileVersion('ojs', "locale/{$locale}/emailTemplates.xml", $this->oldTag); $newTemplatesText = $this->fetchFileVersion('ojs', "locale/{$locale}/emailTemplates.xml", $this->newTag); if ($oldTemplatesText === false || $newTemplatesText === false) { fprintf($stderr, "Skipping {$localeName}; could not fetch.\n"); continue; } $oldEmails = $this->parseEmails($oldTemplatesText); $newEmails = $this->parseEmails($newTemplatesText); foreach ($oldEmails['email_text'] as $oi => $junk) { $key = $junk['attributes']['key']; $ni = null; foreach ($newEmails['email_text'] as $ni => $junk) { if ($key == $junk['attributes']['key']) { break; } } if ($oldEmails['subject'][$oi]['value'] != $newEmails['subject'][$ni]['value']) { echo "UPDATE email_templates_default_data SET subject='" . $dbConn->escape($newEmails['subject'][$ni]['value']) . "' WHERE key='" . $dbConn->escape($key) . "' AND locale='" . $dbConn->escape($locale) . "' AND subject='" . $dbConn->escape($oldEmails['subject'][$oi]['value']) . "';\n"; } if ($oldEmails['body'][$oi]['value'] != $newEmails['body'][$ni]['value']) { echo "UPDATE email_templates_default_data SET body='" . $dbConn->escape($newEmails['body'][$ni]['value']) . "' WHERE key='" . $dbConn->escape($key) . "' AND locale='" . $dbConn->escape($locale) . "' AND body='" . $dbConn->escape($oldEmails['body'][$oi]['value']) . "';\n"; } } } fclose($stderr); }
/** * Constructor. * @param $request PKPRequest */ function __construct($request) { parent::__construct($request, 'install/install.tpl'); // FIXME Move the below options to an external configuration file? $this->supportedLocales = AppLocale::getAllLocales(); $this->localesComplete = array(); foreach ($this->supportedLocales as $key => $name) { $this->localesComplete[$key] = AppLocale::isLocaleComplete($key); } $this->supportedClientCharsets = array('utf-8' => 'Unicode (UTF-8)', 'iso-8859-1' => 'Western (ISO-8859-1)'); $this->supportedConnectionCharsets = array('' => __('common.notApplicable'), 'utf8' => 'Unicode (UTF-8)'); $this->supportedDatabaseCharsets = array('' => __('common.notApplicable'), 'utf8' => 'Unicode (UTF-8)'); $this->supportedDatabaseDrivers = array('mysql' => array('mysql', 'MySQL'), 'mysqli' => array('mysqli', 'MySQLi'), 'postgres' => array('pgsql', 'PostgreSQL'), 'oracle' => array('oci8', 'Oracle'), 'mssql' => array('mssql', 'MS SQL Server'), 'fbsql' => array('fbsql', 'FrontBase'), 'ibase' => array('ibase', 'Interbase'), 'firebird' => array('ibase', 'Firebird'), 'informix' => array('ifx', 'Informix'), 'sybase' => array('sybase', 'Sybase'), 'odbc' => array('odbc', 'ODBC')); // Validation checks for this form $this->addCheck(new FormValidatorInSet($this, 'locale', 'required', 'installer.form.localeRequired', array_keys($this->supportedLocales))); $this->addCheck(new FormValidatorCustom($this, 'locale', 'required', 'installer.form.localeRequired', array('AppLocale', 'isLocaleValid'))); $this->addCheck(new FormValidatorInSet($this, 'clientCharset', 'required', 'installer.form.clientCharsetRequired', array_keys($this->supportedClientCharsets))); $this->addCheck(new FormValidator($this, 'filesDir', 'required', 'installer.form.filesDirRequired')); $this->addCheck(new FormValidator($this, 'adminUsername', 'required', 'installer.form.usernameRequired')); $this->addCheck(new FormValidatorUsername($this, 'adminUsername', 'required', 'installer.form.usernameAlphaNumeric')); $this->addCheck(new FormValidator($this, 'adminPassword', 'required', 'installer.form.passwordRequired')); $this->addCheck(new FormValidatorCustom($this, 'adminPassword', 'required', 'installer.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'adminPassword2\');'), array($this))); $this->addCheck(new FormValidatorEmail($this, 'adminEmail', 'required', 'installer.form.emailRequired')); $this->addCheck(new FormValidatorInSet($this, 'databaseDriver', 'required', 'installer.form.databaseDriverRequired', array_keys($this->supportedDatabaseDrivers))); $this->addCheck(new FormValidator($this, 'databaseName', 'required', 'installer.form.databaseNameRequired')); }
/** * Constructor. */ function InstallForm() { parent::Form('install/install.tpl'); // FIXME Move the below options to an external configuration file? $this->supportedLocales = AppLocale::getAllLocales(); $this->localesComplete = array(); foreach ($this->supportedLocales as $key => $name) { $this->localesComplete[$key] = AppLocale::isLocaleComplete($key); } $this->supportedClientCharsets = array('utf-8' => 'Unicode (UTF-8)', 'iso-8859-1' => 'Western (ISO-8859-1)'); $this->supportedConnectionCharsets = array('' => __('common.notApplicable'), 'utf8' => 'Unicode (UTF-8)'); $this->supportedDatabaseCharsets = array('' => __('common.notApplicable'), 'utf8' => 'Unicode (UTF-8)'); $this->supportedEncryptionAlgorithms = array('md5' => 'MD5'); if (function_exists('sha1')) { $this->supportedEncryptionAlgorithms['sha1'] = 'SHA1'; } $this->supportedDatabaseDrivers = array('mysql' => array('mysql', 'MySQL'), 'postgres' => array('pgsql', 'PostgreSQL'), 'oracle' => array('oci8', 'Oracle'), 'mssql' => array('mssql', 'MS SQL Server'), 'fbsql' => array('fbsql', 'FrontBase'), 'ibase' => array('ibase', 'Interbase'), 'firebird' => array('ibase', 'Firebird'), 'informix' => array('ifx', 'Informix'), 'sybase' => array('sybase', 'Sybase'), 'odbc' => array('odbc', 'ODBC')); // Validation checks for this form $this->addCheck(new FormValidatorInSet($this, 'locale', 'required', 'installer.form.localeRequired', array_keys($this->supportedLocales))); $this->addCheck(new FormValidatorCustom($this, 'locale', 'required', 'installer.form.localeRequired', array('AppLocale', 'isLocaleValid'))); $this->addCheck(new FormValidatorInSet($this, 'clientCharset', 'required', 'installer.form.clientCharsetRequired', array_keys($this->supportedClientCharsets))); $this->addCheck(new FormValidator($this, 'filesDir', 'required', 'installer.form.filesDirRequired')); $this->addCheck(new FormValidatorInSet($this, 'encryption', 'required', 'installer.form.encryptionRequired', array_keys($this->supportedEncryptionAlgorithms))); $this->addCheck(new FormValidator($this, 'adminUsername', 'required', 'installer.form.usernameRequired')); $this->addCheck(new FormValidatorAlphaNum($this, 'adminUsername', 'required', 'installer.form.usernameAlphaNumeric')); $this->addCheck(new FormValidatorLength($this, 'adminPassword', 'required', 'user.register.form.passwordLengthTooShort', '>=', INSTALLER_DEFAULT_MIN_PASSWORD_LENGTH)); $this->addCheck(new FormValidator($this, 'adminPassword', 'required', 'installer.form.passwordRequired')); $this->addCheck(new FormValidatorCustom($this, 'adminPassword', 'required', 'installer.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'adminPassword2\');'), array(&$this))); $this->addCheck(new FormValidatorEmail($this, 'adminEmail', 'required', 'installer.form.emailRequired')); $this->addCheck(new FormValidatorInSet($this, 'databaseDriver', 'required', 'installer.form.databaseDriverRequired', array_keys($this->supportedDatabaseDrivers))); $this->addCheck(new FormValidator($this, 'databaseName', 'required', 'installer.form.databaseNameRequired')); $this->addCheck(new FormValidatorPost($this)); }
/** * Display form to modify site language settings. * @param $args array * @param $request object */ function languages($args, &$request) { $this->validate(); $this->setupTemplate(true); $site =& $request->getSite(); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('localeNames', AppLocale::getAllLocales()); $templateMgr->assign('primaryLocale', $site->getPrimaryLocale()); $templateMgr->assign('supportedLocales', $site->getSupportedLocales()); $localesComplete = array(); foreach (AppLocale::getAllLocales() as $key => $name) { $localesComplete[$key] = AppLocale::isLocaleComplete($key); } $templateMgr->assign('localesComplete', $localesComplete); $templateMgr->assign('installedLocales', $site->getInstalledLocales()); $templateMgr->assign('uninstalledLocales', array_diff(array_keys(AppLocale::getAllLocales()), $site->getInstalledLocales())); $templateMgr->assign('helpTopicId', 'site.siteManagement'); import('classes.i18n.LanguageAction'); $languageAction = new LanguageAction(); if ($languageAction->isDownloadAvailable()) { $templateMgr->assign('downloadAvailable', true); $templateMgr->assign('downloadableLocales', $languageAction->getDownloadableLocales()); } $templateMgr->display('admin/languages.tpl'); }
/** * Get the localized value of the galley label. * @return $string */ function getGalleyLabel() { $label = $this->getLabel(); if ($this->getLocale() != AppLocale::getLocale()) { $locales = AppLocale::getAllLocales(); $label .= ' (' . $locales[$this->getLocale()] . ')'; } return $label; }
function lockss($args, $request) { $this->validate(); $this->setupTemplate(); $journal =& $request->getJournal(); $templateMgr =& TemplateManager::getManager(); if ($journal != null) { if (!$journal->getSetting('enableLockss')) { $request->redirect(null, 'index'); } $year = $request->getUserVar('year'); $issueDao =& DAORegistry::getDAO('IssueDAO'); // FIXME Should probably go in IssueDAO or a subclass if (isset($year)) { $year = (int) $year; $result =& $issueDao->retrieve('SELECT * FROM issues WHERE journal_id = ? AND year = ? AND published = 1 ORDER BY current DESC, year ASC, volume ASC, number ASC', array($journal->getId(), $year)); if ($result->RecordCount() == 0) { unset($year); } } if (!isset($year)) { $showInfo = true; $result =& $issueDao->retrieve('SELECT MAX(year) FROM issues WHERE journal_id = ? AND published = 1', $journal->getId()); list($year) = $result->fields; $result =& $issueDao->retrieve('SELECT * FROM issues WHERE journal_id = ? AND year = ? AND published = 1 ORDER BY current DESC, year ASC, volume ASC, number ASC', array($journal->getId(), $year)); } else { $showInfo = false; } $issues = new DAOResultFactory($result, $issueDao, '_returnIssueFromRow'); $prevYear = null; $nextYear = null; if (isset($year)) { $result =& $issueDao->retrieve('SELECT MAX(year) FROM issues WHERE journal_id = ? AND published = 1 AND year < ?', array($journal->getId(), $year)); list($prevYear) = $result->fields; $result =& $issueDao->retrieve('SELECT MIN(year) FROM issues WHERE journal_id = ? AND published = 1 AND year > ?', array($journal->getId(), $year)); list($nextYear) = $result->fields; } $templateMgr->assign_by_ref('journal', $journal); $templateMgr->assign_by_ref('issues', $issues); $templateMgr->assign('year', $year); $templateMgr->assign('prevYear', $prevYear); $templateMgr->assign('nextYear', $nextYear); $templateMgr->assign('showInfo', $showInfo); $locales =& $journal->getSupportedLocaleNames(); if (!isset($locales) || empty($locales)) { $localeNames =& AppLocale::getAllLocales(); $primaryLocale = AppLocale::getPrimaryLocale(); $locales = array($primaryLocale => $localeNames[$primaryLocale]); } $templateMgr->assign_by_ref('locales', $locales); } else { $journalDao =& DAORegistry::getDAO('JournalDAO'); $journals =& $journalDao->getJournals(true); $templateMgr->assign_by_ref('journals', $journals); } $templateMgr->display('gateway/lockss.tpl'); }
/** * Constructor. */ function MetadataForm($article, $journal) { $roleDao =& DAORegistry::getDAO('RoleDAO'); $signoffDao =& DAORegistry::getDAO('SignoffDAO'); $user =& Request::getUser(); $roleId = $roleDao->getRoleIdFromPath(Request::getRequestedPage()); // If the user is an editor of this article, make the entire form editable. $this->canEdit = false; $this->isEditor = false; if ($roleId != null && ($roleId == ROLE_ID_EDITOR || $roleId == ROLE_ID_SECTION_EDITOR)) { $this->canEdit = true; $this->isEditor = true; } $copyeditInitialSignoff = $signoffDao->getBySymbolic('SIGNOFF_COPYEDITING_INITIAL', ASSOC_TYPE_ARTICLE, $article->getId()); // If the user is an author and the article hasn't passed the Copyediting stage, make the form editable. if ($roleId == ROLE_ID_AUTHOR) { if ($article->getStatus() != STATUS_PUBLISHED && ($copyeditInitialSignoff == null || $copyeditInitialSignoff->getDateCompleted() == null)) { $this->canEdit = true; } } // Copy editors are also allowed to edit metadata, but only if they have // a current assignment to the article. if ($roleId != null && $roleId == ROLE_ID_COPYEDITOR) { $copyeditFinalSignoff = $signoffDao->build('SIGNOFF_COPYEDITING_FINAL', ASSOC_TYPE_ARTICLE, $article->getId()); if ($copyeditFinalSignoff != null && $article->getStatus() != STATUS_PUBLISHED) { if ($copyeditInitialSignoff->getDateNotified() != null && $copyeditFinalSignoff->getDateCompleted() == null) { $this->canEdit = true; } } } if ($this->canEdit) { $supportedSubmissionLocales = $journal->getSetting('supportedSubmissionLocales'); if (empty($supportedSubmissionLocales)) { $supportedSubmissionLocales = array($journal->getPrimaryLocale()); } parent::Form('submission/metadata/metadataEdit.tpl', true, $article->getLocale(), array_flip(array_intersect(array_flip(AppLocale::getAllLocales()), $supportedSubmissionLocales))); $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'author.submit.form.titleRequired', $this->getRequiredLocale())); $this->addCheck(new FormValidatorArray($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', array('firstName', 'lastName'))); $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', create_function('$email, $regExp', 'return String::regexp_match($regExp, $email);'), array(ValidatorEmail::getRegexp()), false, array('email'))); $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.urlInvalid', create_function('$url, $regExp', 'return empty($url) ? true : String::regexp_match($regExp, $url);'), array(ValidatorUrl::getRegexp()), false, array('url'))); // Add ORCiD validation import('lib.pkp.classes.validation.ValidatorORCID'); $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.orcidInvalid', create_function('$orcid', '$validator = new ValidatorORCID(); return empty($orcid) ? true : $validator->isValid($orcid);'), array(), false, array('orcid'))); } else { parent::Form('submission/metadata/metadataView.tpl'); } // If the user is a reviewer of this article, do not show authors. $this->canViewAuthors = true; if ($roleId != null && $roleId == ROLE_ID_REVIEWER) { $this->canViewAuthors = false; } $this->article = $article; $this->addCheck(new FormValidatorPost($this)); }
/** * Hook callback function for TemplateManager::display * @param $hookName string * @param $args array * @return boolean */ function callback($hookName, $args) { $request =& Registry::get('request'); $templateManager =& $args[0]; $allLocales = AppLocale::getAllLocales(); $localeList = array(); foreach ($allLocales as $key => $locale) { $localeList[] = String::substr($key, 0, 2); } $templateManager->assign('additionalHeadData', $templateManager->get_template_vars('additionalHeadData') . $templateManager->fetch($this->getTemplatePath() . 'header.tpl')); return false; }
/** * @copydoc Gridhandler::initialize() */ function initialize($request, $args = null) { parent::initialize($request); $this->tabsSelector = $request->getUserVar('tabsSelector'); // Set the grid details. $this->setInstructions('plugins.generic.translator.localeDescription'); $this->setGridDataElements(AppLocale::getAllLocales()); // Columns $cellProvider = new LiteralGridCellProvider(); $this->addColumn(new GridColumn('id', 'common.language', null, 'controllers/grid/gridCell.tpl', $cellProvider)); $this->addColumn(new GridColumn('name', 'common.name', null, 'controllers/grid/gridCell.tpl', $cellProvider, array('width' => 80, 'alignment' => COLUMN_ALIGNMENT_LEFT))); }
/** * Get all supported locales for the current context. * @return array */ static function getSupportedLocales() { static $supportedLocales; if (!isset($supportedLocales)) { if (defined('SESSION_DISABLE_INIT') || !Config::getVar('general', 'installed')) { $supportedLocales = AppLocale::getAllLocales(); } else { $site =& self::$request->getSite(); $supportedLocales = $site->getSupportedLocaleNames(); } } return $supportedLocales; }
/** * Hook callback function for TemplateManager::display * @param $hookName string * @param $args array * @return boolean */ function callback($hookName, $args) { // Only pages requests interest us here $request =& $this->getRequest(); if (!is_a($request->getRouter(), 'PKPPageRouter')) { return null; } $templateManager =& $args[0]; $page = $request->getRequestedPage(); $op = $request->getRequestedOp(); $baseUrl = $templateManager->get_template_vars('baseUrl'); $additionalHeadData = $templateManager->get_template_vars('additionalHeadData'); $allLocales = AppLocale::getAllLocales(); $localeList = array(); foreach ($allLocales as $key => $locale) { $localeList[] = String::substr($key, 0, 2); } $tinymceScript = ' <script src="' . $baseUrl . '/' . TINYMCE_JS_PATH . '/tiny_mce_gzip.js"></script> <script> tinyMCE_GZ.init({ relative_urls : "false", plugins : "paste,jbimages,fullscreen", themes : "advanced", languages : "' . join(',', $localeList) . '", disk_cache : true }); </script> <script> tinyMCE.init({ entity_encoding : "raw", plugins : "paste,jbimages,fullscreen", mode: "specific_textareas", editor_selector: "richContent", language : "' . String::substr(AppLocale::getLocale(), 0, 2) . '", relative_urls : false, forced_root_block : false, paste_auto_cleanup_on_paste : true, apply_source_formatting : false, theme : "advanced", theme_advanced_buttons1 : "cut,copy,paste,|,bold,italic,underline,bullist,numlist,|,link,unlink,help,code,fullscreen,jbimages", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "", init_instance_callback: $.pkp.controllers.SiteHandler.prototype.triggerTinyMCEInitialized, setup: $.pkp.controllers.SiteHandler.prototype.triggerTinyMCESetup }); </script>'; $templateManager->assign('additionalHeadData', $additionalHeadData . "\n" . $tinymceScript); return false; }
/** * Return associative array of all locales supported by the site. * These locales are used to provide a language toggle on the main site pages. * @return array */ function &getSupportedLocaleNames() { $supportedLocales =& Registry::get('siteSupportedLocales', true, null); if ($supportedLocales === null) { $supportedLocales = array(); $localeNames =& AppLocale::getAllLocales(); $locales = $this->getSupportedLocales(); foreach ($locales as $localeKey) { $supportedLocales[$localeKey] = $localeNames[$localeKey]; } asort($supportedLocales); } return $supportedLocales; }
function index($args, $request) { $this->validate(); $plugin =& $this->plugin; $this->setupTemplate($request); $rangeInfo = $this->getRangeInfo($request, 'locales'); $templateMgr = TemplateManager::getManager($request); import('lib.pkp.classes.core.ArrayItemIterator'); $templateMgr->assign('locales', new ArrayItemIterator(AppLocale::getAllLocales(), $rangeInfo->getPage(), $rangeInfo->getCount())); $templateMgr->assign('masterLocale', MASTER_LOCALE); // Test whether the tar binary is available for the export to work $tarBinary = Config::getVar('cli', 'tar'); $templateMgr->assign('tarAvailable', !empty($tarBinary) && file_exists($tarBinary)); $templateMgr->display($plugin->getTemplatePath() . 'index.tpl'); }
/** * Constructor. * @param $article object * @param $step int */ function AuthorSubmitForm(&$article, $step, &$journal) { // Provide available submission languages. (Convert the array // of locale symbolic names xx_XX into an associative array // of symbolic names => readable names.) $supportedSubmissionLocales = $journal->getSetting('supportedSubmissionLocales'); if (empty($supportedSubmissionLocales)) { $supportedSubmissionLocales = array($journal->getPrimaryLocale()); } parent::Form(sprintf('author/submit/step%d.tpl', $step), true, $article ? $article->getLocale() : AppLocale::getLocale(), array_flip(array_intersect(array_flip(AppLocale::getAllLocales()), $supportedSubmissionLocales))); $this->addCheck(new FormValidatorPost($this)); $this->step = (int) $step; $this->article = $article; $this->articleId = $article ? $article->getId() : null; }
/** * Return associative array of all locales supported by the site. * These locales are used to provide a language toggle on the main site pages. * @return array */ function &getSupportedLocaleNames() { $supportedLocales =& Registry::get('siteSupportedLocales', true, null); if ($supportedLocales === null) { $supportedLocales = array(); $localeNames =& AppLocale::getAllLocales(); $locales = $this->getSupportedLocales(); foreach ($locales as $localeKey) { $supportedLocales[$localeKey] = $localeNames[$localeKey]; } asort($supportedLocales); } import('helpers.LocaleHelper'); $supportedLocales = LocaleHelper::sortZhTwFirst($supportedLocales); return $supportedLocales; }
/** * @copydoc GridHandler::loadData() */ protected function loadData($request, $filter) { $site = $request->getSite(); $context = $request->getContext(); $allLocales = AppLocale::getAllLocales(); $supportedLocales = $site->getSupportedLocales(); $contextPrimaryLocale = $context->getPrimaryLocale(); $data = array(); foreach ($supportedLocales as $locale) { $data[$locale] = array(); $data[$locale]['name'] = $allLocales[$locale]; $data[$locale]['supported'] = true; $data[$locale]['primary'] = $locale == $contextPrimaryLocale; } $data = $this->addManagementData($request, $data); return $data; }
/** * Hook callback function for TemplateManager::display * @param $hookName string * @param $args array * @return boolean */ function callback($hookName, $args) { $templateManager =& $args[0]; $request =& $this->getRequest(); $page = $request->getRequestedPage(); $op = $request->getRequestedOp(); $baseUrl = $templateManager->get_template_vars('baseUrl'); $additionalHeadData = $templateManager->get_template_vars('additionalHeadData'); $allLocales = AppLocale::getAllLocales(); $localeList = array(); foreach ($allLocales as $key => $locale) { $localeList[] = String::substr($key, 0, 2); } $tinymceScript = ' <script language="javascript" type="text/javascript" src="' . $baseUrl . '/' . TINYMCE_JS_PATH . '/tiny_mce_gzip.js"></script> <script language="javascript" type="text/javascript"> tinyMCE_GZ.init({ relative_urls : "false", plugins : "paste,fullscreen", themes : "advanced", languages : "' . join(',', $localeList) . '", disk_cache : true }); </script> <script language="javascript" type="text/javascript"> tinyMCE.init({ entity_encoding : "raw", plugins : "paste,fullscreen", mode : "specific_textareas", editor_selector: "richContent", language : "' . String::substr(AppLocale::getLocale(), 0, 2) . '", relative_urls : false, forced_root_block : false, paste_auto_cleanup_on_paste : true, apply_source_formatting : false, theme : "advanced", theme_advanced_buttons1 : "cut,copy,paste,|,bold,italic,underline,bullist,numlist,|,link,unlink,help,code,fullscreen", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "" }); </script>'; $templateManager->assign('additionalHeadData', $additionalHeadData . "\n" . $tinymceScript); return false; }
/** * Extracts variables for a given column from a data element * so that they may be assigned to template before rendering. * @param $row GridRow * @param $column GridColumn * @return array */ function getTemplateVarsFromRowColumn($row, $column) { $issueGalley = $row->getData(); $columnId = $column->getId(); assert(is_a($issueGalley, 'IssueGalley')); assert(!empty($columnId)); switch ($columnId) { case 'label': return array('label' => $issueGalley->getLabel()); case 'locale': $allLocales = AppLocale::getAllLocales(); return array('label' => $allLocales[$issueGalley->getLocale()]); case 'publicGalleyId': return array('label' => $issueGalley->getStoredPubId('publisher-id')); default: assert(false); break; } }
/** * Constructor. * @param $article object * @param $suppFileId int (optional) */ function SuppFileForm($article, $journal, $suppFileId = null) { $supportedSubmissionLocales = $journal->getSetting('supportedSubmissionLocales'); if (empty($supportedSubmissionLocales)) { $supportedSubmissionLocales = array($journal->getPrimaryLocale()); } parent::Form('submission/suppFile/suppFile.tpl', true, $article->getLocale(), array_flip(array_intersect(array_flip(AppLocale::getAllLocales()), $supportedSubmissionLocales))); $this->article = $article; if (isset($suppFileId) && !empty($suppFileId)) { $suppFileDao =& DAORegistry::getDAO('SuppFileDAO'); $this->suppFile =& $suppFileDao->getSuppFile($suppFileId, $article->getId()); if (isset($this->suppFile)) { $this->suppFileId = $suppFileId; } } // Validation checks for this form $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'author.submit.suppFile.form.titleRequired')); $this->addCheck(new FormValidatorPost($this)); }
/** * Display the form. */ function display() { $journal =& $this->request->getJournal(); $user =& $this->request->getUser(); $templateMgr =& TemplateManager::getManager(); // Get sections for this journal $sectionDao =& DAORegistry::getDAO('SectionDAO'); // If this user is a section editor or an editor, they are // allowed to submit to sections flagged as "editor-only" for // submissions. Otherwise, display only sections they are // allowed to submit to. $roleDao =& DAORegistry::getDAO('RoleDAO'); $isEditor = $roleDao->userHasRole($journal->getId(), $user->getId(), ROLE_ID_EDITOR) || $roleDao->userHasRole($journal->getId(), $user->getId(), ROLE_ID_SECTION_EDITOR); $templateMgr->assign('sectionOptions', array('0' => __('author.submit.selectSection')) + $sectionDao->getSectionTitles($journal->getId(), !$isEditor)); // Set up required Payment Related Information import('classes.payment.ojs.OJSPaymentManager'); $paymentManager = new OJSPaymentManager($this->request); if ($paymentManager->submissionEnabled() || $paymentManager->fastTrackEnabled() || $paymentManager->publicationEnabled()) { $templateMgr->assign('authorFees', true); $completedPaymentDao =& DAORegistry::getDAO('OJSCompletedPaymentDAO'); $articleId = $this->articleId; if ($paymentManager->submissionEnabled()) { $templateMgr->assign_by_ref('submissionPayment', $completedPaymentDao->getSubmissionCompletedPayment($journal->getId(), $articleId)); } if ($paymentManager->fastTrackEnabled()) { $templateMgr->assign_by_ref('fastTrackPayment', $completedPaymentDao->getFastTrackCompletedPayment($journal->getId(), $articleId)); } } // Provide available submission languages. (Convert the array // of locale symbolic names xx_XX into an associative array // of symbolic names => readable names.) $supportedSubmissionLocales = $journal->getSetting('supportedSubmissionLocales'); if (empty($supportedSubmissionLocales)) { $supportedSubmissionLocales = array($journal->getPrimaryLocale()); } $templateMgr->assign('supportedSubmissionLocaleNames', array_flip(array_intersect(array_flip(AppLocale::getAllLocales()), $supportedSubmissionLocales))); parent::display(); }
/** * @copydoc Form::fetch() */ function fetch($request) { $site = $request->getSite(); $allLocales = AppLocale::getAllLocales(); $installedLocales = $this->getData('installedLocales'); $notInstalledLocales = array_diff(array_keys($allLocales), $installedLocales); $templateMgr = TemplateManager::getManager($request); $templateMgr->assign('allLocales', $allLocales); $templateMgr->assign('notInstalledLocales', $notInstalledLocales); import('classes.i18n.LanguageAction'); $languageAction = new LanguageAction(); if ($languageAction->isDownloadAvailable()) { $downloadableLocales = $languageAction->getDownloadableLocales(); $downloadableLocaleLinks = array(); import('lib.pkp.classes.linkAction.request.AjaxAction'); $router = $request->getRouter(); foreach ($downloadableLocales as $locale => $name) { $downloadableLocaleLinks[$locale] = new LinkAction($locale, new AjaxAction($router->url($request, null, null, 'downloadLocale', array('locale' => $locale))), $name . ' (' . $locale . ')'); } $templateMgr->assign('downloadAvailable', true); $templateMgr->assign('downloadableLocaleLinks', $downloadableLocaleLinks); } return parent::fetch($request); }
/** * Get the HTML contents for this block. */ function getContents(&$templateMgr) { $templateMgr->assign('isPostRequest', Request::isPost()); if (!defined('SESSION_DISABLE_INIT')) { $journal =& Request::getJournal(); if (isset($journal)) { $locales =& $journal->getSupportedLocaleNames(); } else { $site =& Request::getSite(); $locales =& $site->getSupportedLocaleNames(); } } else { $locales =& AppLocale::getAllLocales(); $templateMgr->assign('languageToggleNoUser', true); } if (isset($locales) && count($locales) > 1) { $templateMgr->assign('enableLanguageToggle', true); $templateMgr->assign('languageToggleLocales', $locales); } return parent::getContents($templateMgr); }
/** * Return associative array of all locales supported by the site. * These locales are used to provide a language toggle on the main site pages. * @return array */ function getSupportedLocaleNames() { $supportedLocales =& $this->getData('supportedLocaleNames'); if (!isset($supportedLocales)) { $supportedLocales = array(); $localeNames =& AppLocale::getAllLocales(); $locales = $this->getSupportedLocales(); if (!isset($locales) || !is_array($locales)) { $locales = array(); } foreach ($locales as $localeKey) { $supportedLocales[$localeKey] = $localeNames[$localeKey]; } } return $supportedLocales; }
/** * Pre-installation. * @return boolean */ function preInstall() { $this->log('pre-install'); if (!isset($this->dbconn)) { // Connect to the database. $conn =& DBConnection::getInstance(); $this->dbconn =& $conn->getDBConn(); if (!$conn->isConnected()) { $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg()); return false; } } if (!isset($this->currentVersion)) { // Retrieve the currently installed version $versionDao =& DAORegistry::getDAO('VersionDAO'); $this->currentVersion =& $versionDao->getCurrentVersion(); } if (!isset($this->locale)) { $this->locale = AppLocale::getLocale(); } if (!isset($this->installedLocales)) { $this->installedLocales = array_keys(AppLocale::getAllLocales()); } if (!isset($this->dataXMLParser)) { $this->dataXMLParser = new DBDataXMLParser(); $this->dataXMLParser->setDBConn($this->dbconn); } $result = true; HookRegistry::call('Installer::preInstall', array(&$this, &$result)); return $result; }
/** * Display a user's profile. * @param $args array first parameter is the ID or username of the user to display */ function userProfile($args) { $this->validate(); $this->setupTemplate(true); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('currentUrl', Request::url(null, null, 'people', 'all')); $templateMgr->assign('helpTopicId', 'journal.users.index'); $userDao =& DAORegistry::getDAO('UserDAO'); $userId = isset($args[0]) ? $args[0] : 0; if (is_numeric($userId)) { $userId = (int) $userId; $user = $userDao->getById($userId); } else { $user = $userDao->getUserByUsername($userId); } if ($user == null) { // Non-existent user requested $templateMgr->assign('pageTitle', 'manager.people'); $templateMgr->assign('errorMsg', 'manager.people.invalidUser'); $templateMgr->assign('backLink', Request::url(null, null, 'people', 'all')); $templateMgr->assign('backLinkLabel', 'manager.people.allUsers'); $templateMgr->display('common/error.tpl'); } else { $site =& Request::getSite(); $journal =& Request::getJournal(); $isSiteAdmin = Validation::isSiteAdmin(); $templateMgr->assign('isSiteAdmin', $isSiteAdmin); $roleDao =& DAORegistry::getDAO('RoleDAO'); $roles =& $roleDao->getRolesByUserId($user->getId(), $isSiteAdmin ? null : $journal->getId()); $templateMgr->assign_by_ref('userRoles', $roles); if ($isSiteAdmin) { // We'll be displaying all roles, so get ready to display // journal names other than the current journal. $journalDao =& DAORegistry::getDAO('JournalDAO'); $journalTitles =& $journalDao->getJournalTitles(); $templateMgr->assign_by_ref('journalTitles', $journalTitles); } $countryDao =& DAORegistry::getDAO('CountryDAO'); $country = null; if ($user->getCountry() != '') { $country = $countryDao->getCountry($user->getCountry()); } $templateMgr->assign('country', $country); $templateMgr->assign('userInterests', $user->getInterestString()); $templateMgr->assign_by_ref('user', $user); $templateMgr->assign('localeNames', AppLocale::getAllLocales()); $templateMgr->display('manager/people/userProfile.tpl'); } }
/** * Get the error message associated with a failed validation check. * @see FormValidator::getMessage() * @return string */ function getMessage() { $allLocales = AppLocale::getAllLocales(); return parent::getMessage() . ' (' . $allLocales[$this->_requiredLocale] . ')'; }
/** * @copydoc GridHandler::loadData() */ protected function loadData($request, $filter) { $site = $request->getSite(); $data = array(); $allLocales = AppLocale::getAllLocales(); $installedLocales = $site->getInstalledLocales(); $supportedLocales = $site->getSupportedLocales(); $primaryLocale = $site->getPrimaryLocale(); foreach ($installedLocales as $localeKey) { $data[$localeKey] = array(); $data[$localeKey]['name'] = $allLocales[$localeKey]; $data[$localeKey]['incomplete'] = !AppLocale::isLocaleComplete($localeKey); if (in_array($localeKey, $supportedLocales)) { $supported = true; } else { $supported = false; } $data[$localeKey]['supported'] = $supported; if ($this->_canManage($request)) { $context = $request->getContext(); $primaryLocale = $context->getPrimaryLocale(); } if ($localeKey == $primaryLocale) { $primary = true; } else { $primary = false; } $data[$localeKey]['primary'] = $primary; } if ($this->_canManage($request)) { $data = $this->addManagementData($request, $data); } return $data; }
/** * Hook callback function for TemplateManager::display * @param $hookName string * @param $args array * @return boolean */ function callback($hookName, $args) { // Only pages requests interest us here $request =& Registry::get('request'); if (!is_a($request->getRouter(), 'PKPPageRouter')) { return null; } $templateManager =& $args[0]; $page = Request::getRequestedPage(); $op = Request::getRequestedOp(); $enableFields = $this->getEnableFields($templateManager, $page, $op); if (!empty($enableFields)) { $baseUrl = $templateManager->get_template_vars('baseUrl'); $additionalHeadData = $templateManager->get_template_vars('additionalHeadData'); $enableFields = join(',', $enableFields); $allLocales = AppLocale::getAllLocales(); $localeList = array(); foreach ($allLocales as $key => $locale) { $localeList[] = String::substr($key, 0, 2); } $tinymceScript = ' <script language="javascript" type="text/javascript" src="' . $baseUrl . '/' . TINYMCE_JS_PATH . '/tiny_mce_gzip.js"></script> <script language="javascript" type="text/javascript"> tinyMCE_GZ.init({ relative_urls : "false", plugins : "paste,fullscreen,jbimages", themes : "advanced", languages : "' . join(',', $localeList) . '", disk_cache : true }); </script> <script language="javascript" type="text/javascript"> tinyMCE.init({ entity_encoding : "raw", plugins : "paste,fullscreen,jbimages", mode : "exact", language : "' . String::substr(AppLocale::getLocale(), 0, 2) . '", elements : "' . $enableFields . '", relative_urls : false, forced_root_block : false, paste_auto_cleanup_on_paste : true, apply_source_formatting : false, theme : "advanced", theme_advanced_buttons1 : "cut,copy,paste,|,bold,italic,underline,bullist,numlist,|,link,unlink,help,code,fullscreen,jbimages", theme_advanced_buttons2 : "", theme_advanced_buttons3 : "" }); </script>'; $templateManager->assign('additionalHeadData', $additionalHeadData . "\n" . $tinymceScript); } return false; }
/** * Fetch the HTML contents of the form. * @param $request PKPRequest * return string */ function fetch($request) { $submission = $this->getSubmission(); $templateMgr = TemplateManager::getManager($request); $templateMgr->assign(array('submissionId' => $submission->getId(), 'stageId' => $this->getStageId(), 'formParams' => $this->getFormParams())); // Tell the form what fields are enabled (and which of those are required) import('lib.pkp.controllers.grid.settings.metadata.MetadataGridHandler'); $context = $request->getContext(); foreach (array_keys(MetadataGridHandler::getNames()) as $field) { $templateMgr->assign(array($field . 'Enabled' => $context->getSetting($field . 'EnabledWorkflow'), $field . 'Required' => $context->getSetting($field . 'Required'))); } // Provide available submission languages. (Convert the array // of locale symbolic names xx_XX into an associative array // of symbolic names => readable names.) $supportedSubmissionLocales = $context->getSetting('supportedSubmissionLocales'); if (empty($supportedSubmissionLocales)) { $supportedSubmissionLocales = array($context->getPrimaryLocale()); } $templateMgr->assign('supportedSubmissionLocaleNames', array_flip(array_intersect(array_flip(AppLocale::getAllLocales()), $supportedSubmissionLocales))); return parent::fetch($request); }