本文整理汇总了PHP中Backend\Core\Engine\Language::err方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::err方法的具体用法?PHP Language::err怎么用?PHP Language::err使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Backend\Core\Engine\Language
的用法示例。
在下文中一共展示了Language::err方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateForm
/**
* Validate the form
*
* @return void
*/
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 fields
$this->frm->getField('title')->isFilled(BL::err('TitleIsRequired'));
// validate meta
$this->meta->validate();
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item['title'] = $this->frm->getField('title')->getValue();
$item['language'] = BL::getWorkingLanguage();
$item['meta_id'] = $this->meta->save();
$item['sequence'] = BackendSlideshowModel::getMaximumCategorySequence() + 1;
// insert the item
$item['id'] = BackendSlideshowModel::insertCategory($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_category', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('Categories') . '&report=added-category&var=' . urlencode($item['title']) . '&highlight=' . $item['id']);
}
}
}
示例2: validateForm
/**
* Validate the form
*/
protected function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// validation
$fields = $this->frm->getFields();
$fields['title']->isFilled(BL::err('FieldIsRequired'));
if ($this->frm->isCorrect()) {
$item['title'] = $fields['title']->getValue();
$item['id'] = BackendMailengineModel::insertGroup($item);
//--Check if there are users
if (isset($fields["users"])) {
//--Get all the users
$users = $fields["users"]->getValue();
foreach ($users as $key => $value) {
$userGroup = array();
$userGroup["group_id"] = $item['id'];
$userGroup["user_id"] = $value;
//--Add user to the group
BackendMailengineModel::insertUserToGroup($userGroup);
}
}
BackendModel::triggerEvent($this->getModule(), 'after_add_group', $item);
$this->redirect(BackendModel::createURLForAction('groups') . '&report=added&highlight=row-' . $item['id']);
}
}
}
示例3: execute
/**
* Execute the action
*/
public function execute()
{
parent::execute();
// get parameters
$id = \SpoonFilter::getPostValue('id', null, '', 'int');
$name = trim(\SpoonFilter::getPostValue('value', null, '', 'string'));
// validate
if ($name == '') {
$this->output(self::BAD_REQUEST, null, 'no name provided');
} else {
// get existing id
$existingId = BackendMailmotorModel::getCampaignId($name);
// validate
if ($existingId !== 0 && $id !== $existingId) {
$this->output(self::ERROR, array('id' => $existingId, 'error' => true), BL::err('CampaignExists', $this->getModule()));
} else {
// build array
$item = array();
$item['id'] = $id;
$item['name'] = $name;
$item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
// get page
$rows = BackendMailmotorModel::updateCampaign($item);
// trigger event
BackendModel::triggerEvent($this->getModule(), 'edited_campaign', array('item' => $item));
// output
if ($rows !== 0) {
$this->output(self::OK, array('id' => $id), BL::msg('CampaignEdited', $this->getModule()));
} else {
$this->output(self::ERROR, null, BL::err('CampaignNotEdited', $this->getModule()));
}
}
}
}
示例4: 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();
// shorten fields
$txtName = $this->frm->getField('name');
$rbtDefaultForLanguage = $this->frm->getField('default');
// validate fields
if ($txtName->isFilled(BL::err('NameIsRequired'))) {
// check if the group exists by name
if (BackendMailmotorModel::existsGroupByName($txtName->getValue())) {
$txtName->addError(BL::err('GroupAlreadyExists'));
}
}
// no errors?
if ($this->frm->isCorrect()) {
// build item
$item['name'] = $txtName->getValue();
$item['created_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
$item['language'] = $rbtDefaultForLanguage->getValue() === '0' ? null : $rbtDefaultForLanguage->getValue();
$item['is_default'] = $rbtDefaultForLanguage->getChecked() ? 'Y' : 'N';
// insert the item
$item['id'] = BackendMailmotorCMHelper::insertGroup($item);
// check if all default groups were set
BackendMailmotorModel::checkDefaultGroups();
// trigger event
BackendModel::triggerEvent($this->getModule(), 'after_add_group', array('item' => $item));
// everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('Groups') . '&report=added&var=' . urlencode($item['name']) . '&highlight=id-' . $item['id']);
}
}
}
示例5: validateForm
/**
* Validate the form
*/
protected function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// validation
$fields = $this->frm->getFields();
$fields['title']->isFilled(Language::err('TitleIsRequired'));
$fields['description']->isFilled(Language::err('FieldIsRequired'));
$fields['author_name']->isFilled(Language::err('FieldIsRequired'));
$fields['author_url']->isFilled(Language::err('FieldIsRequired'));
$fields['author_email']->isFilled(Language::err('FieldIsRequired'));
// cleanup the modulename
$title = preg_replace('/[^A-Za-z ]/', '', $fields['title']->getValue());
// check if there is already a module with this name
if (BackendExtensionsModel::existsModule($title)) {
$fields['title']->addError(Language::err('DuplicateModuleName'));
}
if ($this->frm->isCorrect()) {
$this->record['title'] = $title;
$this->record['description'] = trim($fields['description']->getValue());
$this->record['author_name'] = $fields['author_name']->getValue();
$this->record['author_url'] = $fields['author_url']->getValue();
$this->record['author_email'] = $fields['author_email']->getValue();
$this->record['camel_case_name'] = BackendModuleMakerHelper::buildCamelCasedName($title);
$this->record['underscored_name'] = BackendModuleMakerHelper::buildUnderscoredName($title);
\SpoonSession::set('module', $this->record);
$this->redirect(Model::createURLForAction('AddStep2'));
}
}
}
示例6: 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=' . urlencode($item['term']) . '&highlight=row-' . $id);
}
}
}
示例7: 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'])));
}
}
示例8: 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':
header('HTTP/1.1 403 Forbidden');
break;
case 'not-found':
header('HTTP/1.1 404 Not Found');
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]) {
// set correct headers
header('HTTP/1.1 404 Not Found');
// give a nice error, so we can detect which file is missing
echo 'Requested file (' . htmlspecialchars($this->getParameter('querystring')) . ') not found.';
// stop script execution
exit;
}
}
// assign the correct message into the template
$this->tpl->assign('message', BL::err(\SpoonFilter::toCamelCase(htmlspecialchars($errorType), '-')));
}
示例9: validateForm
private function validateForm()
{
if ($this->frm->isSubmitted()) {
$fields = $this->frm->getFields();
$fields['title']->isFilled(BL::err('TitleIsRequired'));
if ($this->frm->isCorrect()) {
$item = [];
$item['title'] = $fields['title']->getValue();
$item['capacity'] = $fields['capacity']->getValue();
$item['price'] = $fields['price']->getValue();
$item['count'] = $fields['count']->getValue();
$item['image'] = null;
$item['hotel_id'] = $this->id;
if ($fields['image']->isFilled()) {
// the image path
$imagePath = FRONTEND_FILES_PATH . '/rooms/images';
// create folders if needed
$fs = new Filesystem();
$fs->mkdir(array($imagePath . '/source', $imagePath . '/128x128'));
$item['image'] = $fields['image']->getFileName(false) . '.' . $fields['image']->getExtension();
$i = 2;
while ($fs->exists($imagePath . '/source/' . $item['image'])) {
$item['image'] = $fields['image']->getFileName(false) . '(' . $i . ')' . '.' . $fields['image']->getExtension();
$i++;
}
// upload the image & generate thumbnails
$fields['image']->generateThumbnails($imagePath, $item['image']);
}
$item['id'] = BackendHotelsModel::insertRecord('hotels_rooms', $item);
$this->redirect(BackendModel::createURLForAction('Rooms') . '&id=' . $this->id . '&report=added&var=' . urlencode($item['title']) . '&highlight=row-' . $item['id']);
}
}
}
示例10: 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);
}
}
}
示例11: validateForm
private function validateForm()
{
if ($this->form->isSubmitted()) {
$fields = $this->form->getFields();
if (!$fields['start_date']->isFilled(Language::err('FieldIsRequired')) || !$fields['end_date']->isFilled(Language::err('FieldIsRequired'))) {
return;
}
if (!$fields['start_date']->isValid(Language::err('DateIsInvalid')) || !$fields['end_date']->isValid(Language::err('DateIsInvalid'))) {
return;
}
$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(BL::err('DateRangeIsInvalid'));
}
// enddate cannot be in the future
if ($newEndDate > time()) {
$fields['start_date']->setError(BL::err('DateRangeIsInvalid'));
}
// enddate cannot be before the startdate
if ($newStartDate > $newEndDate) {
$fields['start_date']->setError(BL::err('DateRangeIsInvalid'));
}
if ($this->form->isCorrect()) {
$this->startDate = $newStartDate;
$this->endDate = $newEndDate;
}
}
}
示例12: validateForm
/**
* Validate the form
*/
protected function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
// validation
$fields = $this->frm->getFields();
$fields['name']->isFilled(BL::err('FieldIsRequired'));
$fields['email']->isFilled(BL::err('FieldIsRequired'));
$fields['email']->isEmail(BL::err('EmailIsInvalid'));
if ($this->frm->isCorrect()) {
$item['name'] = $fields['name']->getValue();
$item['email'] = $fields['email']->getValue();
$item['language'] = BL::getWorkingLanguage();
$item['id'] = BackendMailengineModel::insertUser($item);
//--Check if there are groups
if (isset($fields['groups'])) {
//--Get all the groups
$groups = $fields["groups"]->getValue();
foreach ($groups as $key => $value) {
$groupUser = array();
$groupUser["user_id"] = $item['id'];
$groupUser["group_id"] = $value;
//--Add user to the group
BackendMailengineModel::insertUserToGroup($groupUser);
}
}
BackendModel::triggerEvent($this->getModule(), 'after_add_user', $item);
$this->redirect(BackendModel::createURLForAction('users') . '&report=added&highlight=row-' . $item['id']);
}
}
}
示例13: validateForm
/**
* Validate the form
*/
protected function validateForm()
{
if ($this->frm->isSubmitted()) {
$this->frm->cleanupFields();
$fields = $this->frm->getFields();
$fields['email']->isFilled(BL::err('FieldIsRequired'));
if ($this->frm->isCorrect()) {
//--Get the mail
$mailing = BackendMailengineModel::get($this->id);
//--Get the template
$template = BackendMailengineModel::getTemplate($mailing['template_id']);
//--Create basic mail
$text = BackendMailengineModel::createMail($mailing, $template);
$mailing['from_email'] = $template['from_email'];
$mailing['from_name'] = html_entity_decode($template['from_name']);
$mailing['reply_email'] = $template['reply_email'];
$mailing['reply_name'] = html_entity_decode($template['reply_name']);
$emails = explode(',', $fields['email']->getValue());
if (!empty($emails)) {
foreach ($emails as $email) {
$email = trim($email);
if (\SpoonFilter::isEmail($email)) {
//--Send test mailing
BackendMailengineModel::sendMail(html_entity_decode($mailing['subject']), $text, $email, 'Test Recepient', $mailing);
}
}
}
//--Redirect
\SpoonHTTP::redirect(BackendModel::createURLForAction('index', $this->module) . "&id=" . $this->id . "&report=TestEmailSend");
}
}
$this->frm->parse($this->tpl);
}
示例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()
{
// 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->fs->remove(FRONTEND_FILES_PATH . '/wordpress.xml');
// Everything is saved, so redirect to the overview
$this->redirect(BackendModel::createURLForAction('index') . '&report=imported');
}
}
}