本文整理汇总了PHP中AppLocale::getPrimaryLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP AppLocale::getPrimaryLocale方法的具体用法?PHP AppLocale::getPrimaryLocale怎么用?PHP AppLocale::getPrimaryLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppLocale
的用法示例。
在下文中一共展示了AppLocale::getPrimaryLocale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSubscriptionTypeName
/**
* Retrieve subscription type name by ID.
* @param $typeId int
* @return string
*/
function getSubscriptionTypeName($typeId)
{
$result = $this->retrieve('SELECT COALESCE(l.setting_value, p.setting_value) FROM subscription_type_settings l LEFT JOIN subscription_type_settings p ON (p.type_id = ? AND p.setting_name = ? AND p.locale = ?) WHERE l.type_id = ? AND l.setting_name = ? AND l.locale = ?', array($typeId, 'name', AppLocale::getLocale(), $typeId, 'name', AppLocale::getPrimaryLocale()));
$returner = isset($result->fields[0]) ? $result->fields[0] : false;
$result->Close();
return $returner;
}
示例2: Form
/**
* Constructor.
* @param $template string the path to the form template file
*/
function Form($template = null, $callHooks = true, $requiredLocale = null, $supportedLocales = null)
{
if ($requiredLocale === null) {
$requiredLocale = AppLocale::getPrimaryLocale();
}
$this->requiredLocale = $requiredLocale;
if ($supportedLocales === null) {
$supportedLocales = AppLocale::getSupportedFormLocales();
}
$this->supportedLocales = $supportedLocales;
$this->_template = $template;
$this->_data = array();
$this->_checks = array();
$this->_errors = array();
$this->errorsArray = array();
$this->errorFields = array();
$this->formSectionErrors = array();
$this->fbvStyles = array('size' => array('SMALL' => 'SMALL', 'MEDIUM' => 'MEDIUM', 'LARGE' => 'LARGE'), 'float' => array('RIGHT' => 'RIGHT', 'LEFT' => 'LEFT'), 'align' => array('RIGHT' => 'RIGHT', 'LEFT' => 'LEFT'), 'measure' => array('1OF1' => '1OF1', '1OF2' => '1OF2', '1OF3' => '1OF3', '2OF3' => '2OF3', '1OF4' => '1OF4', '3OF4' => '3OF4', '1OF5' => '1OF5', '2OF5' => '2OF5', '3OF5' => '3OF5', '4OF5' => '4OF5', '1OF10' => '1OF10', '8OF10' => '8OF10'), 'layout' => array('THREE_COLUMNS' => 'THREE_COLUMNS', 'TWO_COLUMNS' => 'TWO_COLUMNS', 'ONE_COLUMN' => 'ONE_COLUMN'));
if ($callHooks === true) {
// Call hooks based on the calling entity, assuming
// this method is only called by a subclass. Results
// in hook calls named e.g. "papergalleyform::Constructor"
// Note that class names are always lower case.
HookRegistry::call(strtolower(get_class($this)) . '::Constructor', array(&$this, &$template));
}
}
示例3: __construct
/**
* Constructor.
* @param $template string the path to the form template file
*/
function __construct($template = null, $callHooks = true, $requiredLocale = null, $supportedLocales = null)
{
if ($requiredLocale === null) {
$requiredLocale = AppLocale::getPrimaryLocale();
}
$this->requiredLocale = $requiredLocale;
if ($supportedLocales === null) {
$supportedLocales = AppLocale::getSupportedFormLocales();
}
$this->supportedLocales = $supportedLocales;
$this->_template = $template;
$this->_data = array();
$this->_checks = array();
$this->_errors = array();
$this->errorsArray = array();
$this->errorFields = array();
$this->formSectionErrors = array();
if ($callHooks === true) {
// Call hooks based on the calling entity, assuming
// this method is only called by a subclass. Results
// in hook calls named e.g. "papergalleyform::Constructor"
// Note that class names are always lower case.
HookRegistry::call(strtolower_codesafe(get_class($this)) . '::Constructor', array($this, &$template));
}
}
示例4: insertObject
/**
* Insert a new submission file.
* @param $submissionFile SubmissionFile
* @param $sourceFile string The place where the physical file
* resides right now or the file name in the case of an upload.
* The file will be copied to its canonical target location.
* @param $isUpload boolean set to true if the file has just been
* uploaded.
* @return SubmissionFile the inserted file
*/
function insertObject($submissionFile, $sourceFile, $isUpload = false)
{
$fileId = $submissionFile->getFileId();
if (!is_numeric($submissionFile->getRevision())) {
// Set the initial revision.
$submissionFile->setRevision(1);
}
if (!is_bool($submissionFile->getViewable())) {
// Set the viewable default.
$submissionFile->setViewable(false);
}
$params = array((int) $submissionFile->getRevision(), (int) $submissionFile->getSubmissionId(), is_null($submissionFile->getSourceFileId()) ? null : (int) $submissionFile->getSourceFileId(), is_null($submissionFile->getSourceRevision()) ? null : (int) $submissionFile->getSourceRevision(), $submissionFile->getFileType(), (int) $submissionFile->getFileSize(), $submissionFile->getOriginalFileName(), (int) $submissionFile->getFileStage(), (bool) $submissionFile->getViewable() ? 1 : 0, is_null($submissionFile->getUploaderUserId()) ? null : (int) $submissionFile->getUploaderUserId(), is_null($submissionFile->getUserGroupId()) ? null : (int) $submissionFile->getUserGroupId(), is_null($submissionFile->getAssocType()) ? null : (int) $submissionFile->getAssocType(), is_null($submissionFile->getAssocId()) ? null : (int) $submissionFile->getAssocId(), is_null($submissionFile->getGenreId()) ? null : (int) $submissionFile->getGenreId(), $submissionFile->getDirectSalesPrice(), $submissionFile->getSalesType());
if ($fileId) {
array_unshift($params, (int) $fileId);
}
$this->update(sprintf('INSERT INTO submission_files
(' . ($fileId ? 'file_id, ' : '') . 'revision, submission_id, source_file_id, source_revision, file_type, file_size, original_file_name, file_stage, date_uploaded, date_modified, viewable, uploader_user_id, user_group_id, assoc_type, assoc_id, genre_id, direct_sales_price, sales_type)
VALUES
(' . ($fileId ? '?, ' : '') . '?, ?, ?, ?, ?, ?, ?, ?, %s, %s, ?, ?, ?, ?, ?, ?, ?, ?)', $this->datetimeToDB($submissionFile->getDateUploaded()), $this->datetimeToDB($submissionFile->getDateModified())), $params);
if (!$fileId) {
$submissionFile->setFileId($this->_getInsertId('submission_files', 'file_id'));
}
$reviewStage = in_array($submissionFile->getFileStage(), array(SUBMISSION_FILE_REVIEW_FILE, SUBMISSION_FILE_REVIEW_ATTACHMENT, SUBMISSION_FILE_REVIEW_REVISION));
if (!$submissionFile->getName(AppLocale::getPrimaryLocale())) {
if ($reviewStage) {
$submissionFile->setName($submissionFile->_generateName(true), AppLocale::getPrimaryLocale());
} else {
$submissionFile->setName($submissionFile->_generateName(), AppLocale::getPrimaryLocale());
}
} else {
if ($reviewStage && $submissionFile->getName(AppLocale::getPrimaryLocale()) == $submissionFile->_generateName()) {
$submissionFile->setName($submissionFile->_generateName(true), AppLocale::getPrimaryLocale());
}
}
$this->updateLocaleFields($submissionFile);
// Determine the final destination of the file (requires
// the file id we just generated).
$targetFilePath = $submissionFile->getFilePath();
// Only copy the file if it is not yet in the target position.
if ($isUpload || $sourceFile != $targetFilePath) {
// Copy the file from its current location to the target destination.
import('lib.pkp.classes.file.FileManager');
$fileManager = new FileManager();
if ($isUpload) {
$success = $fileManager->uploadFile($sourceFile, $targetFilePath);
} else {
assert(is_readable($sourceFile));
$success = $fileManager->copyFile($sourceFile, $targetFilePath);
}
if (!$success) {
// If the copy/upload operation fails then remove
// the already inserted meta-data.
$this->deleteObject($submissionFile);
$nullVar = null;
return $nullVar;
}
}
assert(is_readable($targetFilePath));
return $submissionFile;
}
示例5: getAnnouncementTypeName
/**
* Retrieve announcement type name by ID.
* @param $typeId int
* @return string
*/
function getAnnouncementTypeName($typeId)
{
$result = $this->retrieve('SELECT COALESCE(l.setting_value, p.setting_value) FROM announcement_type_settings p LEFT JOIN announcement_type_settings l ON (l.type_id = ? AND l.setting_name = ? AND l.locale = ?) WHERE p.type_id = ? AND p.setting_name = ? AND p.locale = ?', array((int) $typeId, 'name', AppLocale::getLocale(), (int) $typeId, 'name', AppLocale::getPrimaryLocale()));
$returner = isset($result->fields[0]) ? $result->fields[0] : false;
$result->Close();
return $returner;
}
示例6: getParamsForCurrentLocale
/**
* 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;
}
示例7: validate
/**
* Check to make sure form conditions are met
*/
function validate()
{
// Ensure all submission types have names in the primary locale
// as well as numeric word limits (optional)
$primaryLocale = AppLocale::getPrimaryLocale();
if (isset($this->_data['paperTypes'])) {
$paperTypes =& $this->_data['paperTypes'];
if (!is_array($paperTypes)) {
return false;
}
foreach ($paperTypes as $paperTypeId => $paperType) {
if (!isset($paperType['name'][$primaryLocale]) || empty($paperType['name'][$primaryLocale])) {
$fieldName = 'paperTypeName-' . $paperTypeId;
$this->addError($fieldName, __('manager.schedConfSetup.submissions.typeOfSubmission.nameMissing', array('primaryLocale' => $primaryLocale)));
$this->addErrorField($fieldName);
}
if (isset($paperType['abstractLength']) && !empty($paperType['abstractLength']) && (!is_numeric($paperType['abstractLength']) || $paperType['abstractLength'] <= 0)) {
$fieldName = 'paperTypeAbstractLength-' . $paperTypeId;
$this->addError($fieldName, __('manager.schedConfSetup.submissions.typeOfSubmission.abstractLengthInvalid'));
$this->addErrorField($fieldName);
}
}
}
return parent::validate();
}
示例8: __construct
/**
* Constructor.
* @param $form Form the associated form
* @param $field string the name of the associated field
* @param $type string the type of check, either "required" or "optional"
* @param $message string the error message for validation failures (i18n key)
* @param $validator Validator the validator used to validate this form field (optional)
* @param $requiredLocale The name of the required locale, i.e. en_US
*/
function __construct(&$form, $field, $type, $message, $requiredLocale = null, $validator = null)
{
parent::__construct($form, $field, $type, $message, $validator);
if ($requiredLocale === null) {
$requiredLocale = AppLocale::getPrimaryLocale();
}
$this->_requiredLocale = $requiredLocale;
}
示例9: getRegistrationOptionName
/**
* Retrieve registration option name by ID.
* @param $optionId int
* @return string
*/
function getRegistrationOptionName($optionId)
{
$result =& $this->retrieve('SELECT COALESCE(l.setting_value, p.setting_value) FROM registration_option_settings l LEFT JOIN registration_option_settings p ON (p.option_id = ? AND p.setting_name = ? AND p.locale = ?) WHERE l.option_id = ? AND l.setting_name = ? AND l.locale = ?', array($optionId, 'name', AppLocale::getLocale(), $optionId, 'name', AppLocale::getPrimaryLocale()));
$returner = isset($result->fields[0]) ? $result->fields[0] : false;
$result->Close();
unset($result);
return $returner;
}
示例10: lockss
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');
}
示例11: getLocalizedFavicon
/**
* Get localized favicon
* @return string
*/
function getLocalizedFavicon()
{
$faviconArray = $this->getSetting('journalFavicon');
foreach (array(AppLocale::getLocale(), AppLocale::getPrimaryLocale()) as $locale) {
if (isset($faviconArray[$locale])) {
return $faviconArray[$locale];
}
}
return null;
}
示例12: getPageHeaderLogo
/**
* Get "localized" press page logo (if applicable).
* @return string
*/
function getPageHeaderLogo()
{
$logoArray = $this->getSetting('pageHeaderLogoImage');
foreach (array(AppLocale::getLocale(), AppLocale::getPrimaryLocale()) as $locale) {
if (isset($logoArray[$locale])) {
return $logoArray[$locale];
}
}
return null;
}
示例13: getLocalizedLocation
/**
* Get the localized location for citations in this journal
* @param $journal Journal
* @return string
*/
function getLocalizedLocation($journal)
{
$settings = $this->getSetting($journal->getId(), 'location');
if ($settings === null) {
return null;
}
$location = $settings[AppLocale::getLocale()];
if (empty($location)) {
$location = $settings[AppLocale::getPrimaryLocale()];
}
return $location;
}
示例14: getRegistrantReport
/**
* Get the registrant report data.
* @param $conferenceId int
* @param $schedConfId int
* @return array
*/
function getRegistrantReport($conferenceId, $schedConfId)
{
$primaryLocale = AppLocale::getPrimaryLocale();
$locale = AppLocale::getLocale();
$result =& $this->retrieve('SELECT
r.registration_id AS registration_id,
r.user_id AS userid,
u.username AS uname,
u.first_name AS fname,
u.middle_name AS mname,
u.last_name AS lname,
u.affiliation AS affiliation,
u.url AS url,
u.email AS email,
u.phone AS phone,
u.fax AS fax,
u.mailing_address AS address,
u.country AS country,
COALESCE(rtsl.setting_value, rtspl.setting_value) AS type,
r.date_registered AS regdate,
r.date_paid AS paiddate,
r.special_requests AS specialreq
FROM
registrations r
LEFT JOIN users u ON r.user_id=u.user_id
LEFT JOIN registration_type_settings rtsl ON (r.type_id=rtsl.type_id AND rtsl.locale=? AND rtsl.setting_name=?)
LEFT JOIN registration_type_settings rtspl ON (r.type_id=rtspl.type_id AND rtsl.locale=? AND rtspl.setting_name=?)
WHERE
r.sched_conf_id = ?
ORDER BY
lname', array($locale, 'name', $primaryLocale, 'name', (int) $schedConfId));
// prepare an iterator of all the registration information
$registrationReturner = new DBRowIterator($result);
$result =& $this->retrieve('SELECT
r.registration_id as registration_id,
roa.option_id as option_id
FROM
registrations r
LEFT JOIN registration_option_assoc roa ON (r.registration_id = roa.registration_id)
WHERE
r.sched_conf_id = ?', (int) $schedConfId);
// Prepare an array of registration Options by registration Id
$registrationOptionDAO =& DAORegistry::getDAO('RegistrationOptionDAO');
$iterator = new DBRowIterator($result);
$registrationOptionReturner = array();
while ($row =& $iterator->next()) {
$registrationId = $row['registration_id'];
$registrationOptionReturner[$registrationId] =& $registrationOptionDAO->getRegistrationOptions($registrationId);
}
return array($registrationReturner, $registrationOptionReturner);
}
示例15: getFieldValue
/**
* @see FormValidator::getFieldValue()
* @return mixed
*/
function getFieldValue()
{
$form =& $this->getForm();
$data = $form->getData($this->getField());
$primaryLocale = AppLocale::getPrimaryLocale();
$fieldValue = '';
if (is_array($data) && isset($data[$primaryLocale])) {
$fieldValue = $data[$primaryLocale];
if (is_scalar($fieldValue)) {
$fieldValue = trim((string) $fieldValue);
}
}
return $fieldValue;
}