本文整理汇总了PHP中Backend\Core\Language\Language::err方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::err方法的具体用法?PHP Language::err怎么用?PHP Language::err使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Backend\Core\Language\Language
的用法示例。
在下文中一共展示了Language::err方法的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: 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);
}
}
}
示例3: 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();
// XML provided?
if ($this->frm->getField('wordpress')->isFilled()) {
$this->frm->getField('wordpress')->isAllowedExtension(array('xml'), BL::err('XMLFilesOnly'));
} else {
// No file
$this->frm->getField('wordpress')->addError(BL::err('FieldIsRequired'));
}
// No errors?
if ($this->frm->isCorrect()) {
// Move the file
$this->frm->getField('wordpress')->moveFile(FRONTEND_FILES_PATH . '/wordpress.xml');
// Process the XML
$this->processXML();
// Remove the file
$this->filesystem->remove(FRONTEND_FILES_PATH . '/wordpress.xml');
// Everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('index') . '&report=imported');
}
}
}
示例4: 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();
}
示例5: 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), '-')));
}
示例6: 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'])));
}
}
}
}
示例7: 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']));
}
}
}
示例8: 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'])));
}
}
示例9: 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);
}
}
}
示例10: validateForm
/**
* Validate the form
*/
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// validate fields
$this->frm->getField('title')->isFilled(BL::err('QuestionIsRequired'));
$this->frm->getField('answer')->isFilled(BL::err('AnswerIsRequired'));
$this->frm->getField('category_id')->isFilled(BL::err('CategoryIsRequired'));
$this->meta->validate();
if ($this->frm->isCorrect()) {
// build item
$item['meta_id'] = $this->meta->save();
$item['category_id'] = $this->frm->getField('category_id')->getValue();
$item['user_id'] = BackendAuthentication::getUser()->getUserId();
$item['language'] = BL::getWorkingLanguage();
$item['question'] = $this->frm->getField('title')->getValue();
$item['answer'] = $this->frm->getField('answer')->getValue(true);
$item['created_on'] = BackendModel::getUTCDate();
$item['hidden'] = $this->frm->getField('hidden')->getValue();
$item['sequence'] = BackendFaqModel::getMaximumSequence($this->frm->getField('category_id')->getValue()) + 1;
// save the data
$item['id'] = BackendFaqModel::insert($item);
BackendTagsModel::saveTags($item['id'], $this->frm->getField('tags')->getValue(), $this->URL->getModule());
BackendModel::triggerEvent($this->getModule(), 'after_add', array('item' => $item));
// add search index
BackendSearchModel::saveIndex($this->getModule(), $item['id'], array('title' => $item['question'], 'text' => $item['answer']));
$this->redirect(BackendModel::createURLForAction('Index') . '&report=added&var=' . rawurlencode($item['question']) . '&highlight=' . $item['id']);
}
}
}
示例11: 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();
}
示例12: 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);
}
}
示例13: 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;
}
示例14: getErrors
/**
* This function will return the errors. It is extended so we can do image checks automatically.
*
* @return string
*/
public function getErrors()
{
// do an image validation
if ($this->isFilled()) {
$this->isAllowedExtension(array('jpg', 'jpeg', 'gif', 'png'), BackendLanguage::err('JPGGIFAndPNGOnly'));
$this->isAllowedMimeType(array('image/jpeg', 'image/gif', 'image/png'), BackendLanguage::err('JPGGIFAndPNGOnly'));
}
// 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;
}
示例15: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$itemId = trim(\SpoonFilter::getPostValue('id', null, '', 'int'));
$lat = \SpoonFilter::getPostValue('lat', null, null, 'float');
$lng = \SpoonFilter::getPostValue('lng', null, null, 'float');
// validate id
if ($itemId == 0) {
$this->output(self::BAD_REQUEST, null, BL::err('NonExisting'));
} else {
//update
$updateData = array('id' => $itemId, 'lat' => $lat, 'lng' => $lng, 'language' => BL::getWorkingLanguage());
BackendLocationModel::update($updateData);
// output
$this->output(self::OK);
}
}