本文整理汇总了PHP中Backend\Core\Language\Language类的典型用法代码示例。如果您正苦于以下问题:PHP Language类的具体用法?PHP Language怎么用?PHP Language使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Language类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateForm
/**
* Validate the form
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// validate field
$this->frm->getField('synonym')->isFilled(BL::err('SynonymIsRequired'));
$this->frm->getField('term')->isFilled(BL::err('TermIsRequired'));
if (BackendSearchModel::existsSynonymByTerm($this->frm->getField('term')->getValue())) {
$this->frm->getField('term')->addError(BL::err('TermExists'));
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item = array();
$item['term'] = $this->frm->getField('term')->getValue();
$item['synonym'] = $this->frm->getField('synonym')->getValue();
$item['language'] = BL::getWorkingLanguage();
// insert the item
$id = BackendSearchModel::insertSynonym($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_synonym', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('Synonyms') . '&report=added-synonym&var=' . rawurlencode($item['term']) . '&highlight=row-' . $id);
}
}
}
示例2: isValid
/**
* @return bool
*/
private function isValid()
{
$fields = $this->form->getFields();
if (!$fields['start_date']->isFilled(Language::err('FieldIsRequired')) || !$fields['end_date']->isFilled(Language::err('FieldIsRequired'))) {
return $this->form->isCorrect();
}
if (!$fields['start_date']->isValid(Language::err('DateIsInvalid')) || !$fields['end_date']->isValid(Language::err('DateIsInvalid'))) {
return $this->form->isCorrect();
}
$newStartDate = Model::getUTCTimestamp($fields['start_date']);
$newEndDate = Model::getUTCTimestamp($fields['end_date']);
// startdate cannot be before 2005 (earliest valid google startdate)
if ($newStartDate < mktime(0, 0, 0, 1, 1, 2005)) {
$fields['start_date']->setError(Language::err('DateRangeIsInvalid'));
}
// enddate cannot be in the future
if ($newEndDate > time()) {
$fields['start_date']->setError(Language::err('DateRangeIsInvalid'));
}
// enddate cannot be before the startdate
if ($newStartDate > $newEndDate) {
$fields['start_date']->setError(Language::err('DateRangeIsInvalid'));
}
return $this->form->isCorrect();
}
示例3: execute
/**
* Execute the action
* We will build the classname, require the class and call the execute method.
*/
public function execute()
{
$this->loadConfig();
// is the requested action available? If not we redirect to the error page.
if (!$this->config->isActionAvailable($this->action)) {
// build the url
$errorUrl = '/' . NAMED_APPLICATION . '/' . $this->get('request')->getLocale() . '/error?type=action-not-allowed';
// redirect to the error page
return $this->redirect($errorUrl, 307);
}
// build action-class
$actionClass = 'Backend\\Modules\\' . $this->getModule() . '\\Actions\\' . $this->getAction();
if ($this->getModule() == 'Core') {
$actionClass = 'Backend\\Core\\Actions\\' . $this->getAction();
}
if (!class_exists($actionClass)) {
throw new Exception('The class ' . $actionClass . ' could not be found.');
}
// get working languages
$languages = BackendLanguage::getWorkingLanguages();
$workingLanguages = array();
// loop languages and build an array that we can assign
foreach ($languages as $abbreviation => $label) {
$workingLanguages[] = array('abbr' => $abbreviation, 'label' => $label, 'selected' => $abbreviation == BackendLanguage::getWorkingLanguage());
}
// assign the languages
$this->tpl->assign('workingLanguages', $workingLanguages);
// create action-object
/** @var $object BackendBaseAction */
$object = new $actionClass($this->getKernel());
$this->getContainer()->get('logger')->info("Executing backend action '{$object->getAction()}' for module '{$object->getModule()}'.");
$object->execute();
return $object->getContent();
}
示例4: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$categoryTitle = trim(\SpoonFilter::getPostValue('value', null, '', 'string'));
// validate
if ($categoryTitle === '') {
$this->output(self::BAD_REQUEST, null, BL::err('TitleIsRequired'));
} else {
// get the data
// build array
$item['title'] = \SpoonFilter::htmlspecialchars($categoryTitle);
$item['language'] = BL::getWorkingLanguage();
$meta['keywords'] = $item['title'];
$meta['keywords_overwrite'] = 'N';
$meta['description'] = $item['title'];
$meta['description_overwrite'] = 'N';
$meta['title'] = $item['title'];
$meta['title_overwrite'] = 'N';
$meta['url'] = BackendBlogModel::getURLForCategory(\SpoonFilter::urlise($item['title']));
// update
$item['id'] = BackendBlogModel::insertCategory($item, $meta);
// output
$this->output(self::OK, $item, vsprintf(BL::msg('AddedCategory'), array($item['title'])));
}
}
示例5: __construct
/**
* @param KernelInterface $kernel
*/
public function __construct(KernelInterface $kernel)
{
parent::__construct($kernel);
// store for later use throughout the application
$this->getContainer()->set('navigation', $this);
$this->URL = $this->getContainer()->get('url');
// check if navigation cache file exists
if (!is_file(self::getCacheDirectory() . 'navigation.php')) {
$this->buildCache();
}
// check if editor_link_list_LANGUAGE.js cache file exists
if (!is_file(FRONTEND_CACHE_PATH . '/Navigation/editor_link_list_' . BackendLanguage::getWorkingLanguage() . '.js')) {
BackendPagesModel::buildCache(BackendLanguage::getWorkingLanguage());
}
$navigation = array();
// require navigation-file
require self::getCacheDirectory() . 'navigation.php';
// load it
$this->navigation = (array) $navigation;
$this->navigation = $this->addActiveStateToNavigation($this->navigation);
// cleanup navigation (not needed for god user)
if (!Authentication::getUser()->isGod()) {
$this->navigation = $this->cleanup($this->navigation);
}
}
示例6: setFilter
/**
* Sets the filter based on the $_GET array.
*/
private function setFilter()
{
$this->filter['language'] = $this->getParameter('language', 'array') != '' ? $this->getParameter('language', 'array') : BL::getWorkingLanguage();
$this->filter['application'] = $this->getParameter('application');
$this->filter['module'] = $this->getParameter('module');
$this->filter['type'] = $this->getParameter('type', 'array');
$this->filter['name'] = $this->getParameter('name');
$this->filter['value'] = $this->getParameter('value');
$this->filterQuery = BackendLocaleModel::buildURLQueryByFilter($this->filter);
}
示例7: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
$isGod = BackendAuthentication::getUser()->isGod();
// get possible languages
if ($isGod) {
$possibleLanguages = array_unique(array_merge(BL::getWorkingLanguages(), BL::getInterfaceLanguages()));
} else {
$possibleLanguages = BL::getWorkingLanguages();
}
// get parameters
$language = \SpoonFilter::getPostValue('language', array_keys($possibleLanguages), null, 'string');
$module = \SpoonFilter::getPostValue('module', BackendModel::getModules(), null, 'string');
$name = \SpoonFilter::getPostValue('name', null, null, 'string');
$type = \SpoonFilter::getPostValue('type', BackendModel::getContainer()->get('database')->getEnumValues('locale', 'type'), null, 'string');
$application = \SpoonFilter::getPostValue('application', array('Backend', 'Frontend'), null, 'string');
$value = \SpoonFilter::getPostValue('value', null, null, 'string');
// validate values
if (trim($value) == '' || $language == '' || $module == '' || $type == '' || $application == '' || $application == 'Frontend' && $module != 'Core') {
$error = BL::err('InvalidValue');
}
// in case this is a 'act' type, there are special rules concerning possible values
if ($type == 'act' && !isset($error)) {
if (rawurlencode($value) != CommonUri::getUrl($value)) {
$error = BL::err('InvalidActionValue', $this->getModule());
}
}
// no error?
if (!isset($error)) {
// build item
$item['language'] = $language;
$item['module'] = $module;
$item['name'] = $name;
$item['type'] = $type;
$item['application'] = $application;
$item['value'] = $value;
$item['edited_on'] = BackendModel::getUTCDate();
$item['user_id'] = BackendAuthentication::getUser()->getUserId();
// does the translation exist?
if (BackendLocaleModel::existsByName($name, $type, $module, $language, $application)) {
// add the id to the item
$item['id'] = (int) BackendLocaleModel::getByName($name, $type, $module, $language, $application);
// update in db
BackendLocaleModel::update($item);
} else {
// insert in db
BackendLocaleModel::insert($item);
}
// output OK
$this->output(self::OK);
} else {
$this->output(self::ERROR, null, $error);
}
}
示例8: isValid
/**
* @return bool
*/
private function isValid()
{
$fileField = $this->form->getField('certificate');
$emailField = $this->form->getField('email');
if ($fileField->isFilled(Language::err('FieldIsRequired'))) {
$fileField->isAllowedExtension(['p12'], Language::err('P12Only'));
}
$emailField->isFilled(Language::err('FieldIsRequired'));
$emailField->isEmail(Language::err('EmailIsInvalid'));
return $this->form->isCorrect();
}
示例9: getErrors
/**
* This function will return the errors. It is extended so we can do file checks automatically.
*
* @return string
*/
public function getErrors()
{
// if the image is bigger then the allowed configuration it won't show up as filled but it is submitted
// the empty check is added because otherwise this error is shown like 7 times
if ($this->isSubmitted() && isset($_FILES[$this->getName()]['error']) && empty($this->errors)) {
$imageError = $_FILES[$this->getName()]['error'];
if ($imageError === UPLOAD_ERR_INI_SIZE && empty($this->errors)) {
$this->addError(SpoonFilter::ucfirst(sprintf(BackendLanguage::err('FileTooBig'), Form::getUploadMaxFileSize())));
}
}
return $this->errors;
}
示例10: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// get fields
$ddmGroup = $this->frm->getField('group');
$fileFile = $this->frm->getField('file');
$csv = array();
// validate input
$ddmGroup->isFilled(BL::getError('FieldIsRequired'));
if ($fileFile->isFilled(BL::err('FieldIsRequired'))) {
if ($fileFile->isAllowedExtension(array('csv'), sprintf(BL::getError('ExtensionNotAllowed'), 'csv'))) {
$csv = Csv::fileToArray($fileFile->getTempFileName());
if ($csv === false) {
$fileFile->addError(BL::getError('InvalidCSV'));
}
}
}
if ($this->frm->isCorrect()) {
// import the profiles
$overwrite = $this->frm->getField('overwrite_existing')->isChecked();
$statistics = BackendProfilesModel::importCsv($csv, $ddmGroup->getValue(), $overwrite);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_import', array('statistics' => $statistics));
// build redirect url with the right message
$redirectUrl = BackendModel::createURLForAction('index') . '&report=';
$redirectUrl .= $overwrite ? 'profiles-imported-and-updated' : 'profiles-imported';
$redirectUrl .= '&var[]=' . $statistics['count']['inserted'];
$redirectUrl .= '&var[]=' . $statistics['count']['exists'];
// everything is saved, so redirect to the overview
$this->redirect($redirectUrl);
}
}
}
示例11: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// redefine fields
/** @var $fileFile \SpoonFormFile */
$fileFile = $this->frm->getField('file');
$chkOverwrite = $this->frm->getField('overwrite');
// name checks
if ($fileFile->isFilled(BL::err('FieldIsRequired'))) {
// only xml files allowed
if ($fileFile->isAllowedExtension(array('xml'), sprintf(BL::getError('ExtensionNotAllowed'), 'xml'))) {
// load xml
$xml = @simplexml_load_file($fileFile->getTempFileName());
// invalid xml
if ($xml === false) {
$fileFile->addError(BL::getError('InvalidXML'));
}
}
}
if ($this->frm->isCorrect()) {
// import
$statistics = BackendLocaleModel::importXML($xml, $chkOverwrite->getValue());
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_import', array('statistics' => $statistics));
// everything is imported, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('Index') . '&report=imported&var=' . ($statistics['imported'] . '/' . $statistics['total']) . $this->filterQuery);
}
}
}
示例12: validateForm
/**
* Validate the form.
*/
private function validateForm()
{
// is the form submitted?
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// get field
/** @var $txtName \SpoonFormText */
$txtName = $this->frm->getField('name');
// name filled in?
if ($txtName->isFilled(BL::getError('NameIsRequired'))) {
// name exists?
if (BackendProfilesModel::existsGroupName($txtName->getValue())) {
// set error
$txtName->addError(BL::getError('GroupNameExists'));
}
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$values['name'] = $txtName->getValue();
// insert values
$id = BackendProfilesModel::insertGroup($values);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_group', array('item' => $values));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('Groups') . '&report=group-added&var=' . rawurlencode($values['name']) . '&highlight=row-' . $id);
}
}
}
示例13: parse
/**
* Parse the correct messages into the template
*/
protected function parse()
{
parent::parse();
// grab the error-type from the parameters
$errorType = $this->getParameter('type');
// set correct headers
switch ($errorType) {
case 'module-not-allowed':
case 'action-not-allowed':
$this->statusCode = Response::HTTP_FORBIDDEN;
break;
case 'not-found':
$this->statusCode = Response::HTTP_NOT_FOUND;
break;
default:
$this->statusCode = Response::HTTP_BAD_REQUEST;
break;
}
// querystring provided?
if ($this->getParameter('querystring') !== null) {
// split into file and parameters
$chunks = explode('?', $this->getParameter('querystring'));
// get extension
$extension = pathinfo($chunks[0], PATHINFO_EXTENSION);
// if the file has an extension it is a non-existing-file
if ($extension != '' && $extension != $chunks[0]) {
// give a nice error, so we can detect which file is missing
throw new ExitException('File not found', 'Requested file (' . htmlspecialchars($this->getParameter('querystring')) . ') not found.', Response::HTTP_NOT_FOUND);
}
}
// assign the correct message into the template
$this->tpl->assign('message', BL::err(\SpoonFilter::toCamelCase(htmlspecialchars($errorType), '-')));
}
示例14: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$id = \SpoonFilter::getPostValue('id', null, 0, 'int');
$tag = trim(\SpoonFilter::getPostValue('value', null, '', 'string'));
// validate id
if ($id === 0) {
$this->output(self::BAD_REQUEST, null, 'no id provided');
} else {
// validate tag name
if ($tag === '') {
$this->output(self::BAD_REQUEST, null, BL::err('NameIsRequired'));
} else {
// check if tag exists
if (BackendTagsModel::existsTag($tag)) {
$this->output(self::BAD_REQUEST, null, BL::err('TagAlreadyExists'));
} else {
$item['id'] = $id;
$item['tag'] = \SpoonFilter::htmlspecialchars($tag);
$item['url'] = BackendTagsModel::getURL(CommonUri::getUrl(\SpoonFilter::htmlspecialcharsDecode($item['tag'])), $id);
BackendTagsModel::update($item);
$this->output(self::OK, $item, vsprintf(BL::msg('Edited'), array($item['tag'])));
}
}
}
}
示例15: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
// cleanup the submitted fields, ignore fields that were added by hackers
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('author')->isFilled(BL::err('AuthorIsRequired'));
$this->frm->getField('email')->isEmail(BL::err('EmailIsInvalid'));
$this->frm->getField('text')->isFilled(BL::err('FieldIsRequired'));
if ($this->frm->getField('website')->isFilled()) {
$this->frm->getField('website')->isURL(BL::err('InvalidURL'));
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item['id'] = $this->id;
$item['status'] = $this->record['status'];
$item['author'] = $this->frm->getField('author')->getValue();
$item['email'] = $this->frm->getField('email')->getValue();
$item['website'] = $this->frm->getField('website')->isFilled() ? $this->frm->getField('website')->getValue() : null;
$item['text'] = $this->frm->getField('text')->getValue();
// insert the item
BackendBlogModel::updateComment($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_edit_comment', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('Comments') . '&report=edited-comment&id=' . $item['id'] . '&highlight=row-' . $item['id'] . '#tab' . \SpoonFilter::toCamelCase($item['status']));
}
}
}