本文整理汇总了PHP中Messages::addError方法的典型用法代码示例。如果您正苦于以下问题:PHP Messages::addError方法的具体用法?PHP Messages::addError怎么用?PHP Messages::addError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Messages
的用法示例。
在下文中一共展示了Messages::addError方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _setRequiredError
/**
* Method to check if a field is required and set an error where appropriate
*
* @param Field $field field the error should be set to
* @param string $data submitted data
*
* @return Validatot $this for chainability
*/
protected function _setRequiredError($field, $data)
{
if ($field->requiredError) {
$this->_messages->addError($field->name, $field->requiredError);
} else {
$this->_messages->addError($field->name, sprintf('%s is a required field', $field->readableName));
}
return $this;
}
示例2: unset
}
if (isset($_SESSION['todo']) && $_SESSION['todo'] == 'edit') {
$append .= "&todo=edit";
unset($_SESSION['todo']);
}
$error_nr = 0;
if (!isset($_POST['c_name']) || $_POST['c_name'] == '') {
Messages::addError('Name required!');
$error_nr++;
}
if (!isset($_POST['c_code']) || $_POST['c_code'] == '') {
Messages::addError('Probability required!');
$error_nr++;
}
if (!isset($_POST['c_probability']) || $_POST['c_probability'] == '') {
Messages::addError('Code required!');
$error_nr++;
}
if ($error_nr > 0) {
$_SESSION['post'] = $_POST;
jump("index.php?page=noscripts&action=add_edit" . $append);
}
if (isset($_GET['id']) && $_GET['id'] != '') {
//edit
$c = new Noscripts($_GET['id']);
Messages::addNotice('Code edited!');
} else {
//add
$c = new Noscripts();
Messages::addNotice('Code added!');
}
示例3: isset
<?php
$todo = isset($_GET['todo']) ? $_GET['todo'] : null;
switch ($todo) {
case 'delete':
$exampleCat = new ExampleCategories($_GET['id']);
if ($exampleCat->id) {
$players = ExamplePlayers::getAllFromCat($_GET['id']);
foreach ($players as $player) {
$player->delete();
}
$exampleCat->delete();
Messages::addNotice('Category successfully deleted');
} else {
Messages::addError('Delete Failed');
}
break;
case 'up':
$c = new ExampleCategories($_GET['id']);
$c->moveUp();
break;
case 'down':
$c = new ExampleCategories($_GET['id']);
$c->moveDown();
break;
}
$ec = new ExampleCategories();
$smarty->assign('c_list', $ec->getAll(' ORDER BY `display_order` ASC'));
示例4: getimagesize
}
$c->title = $_POST['c_title'];
$c->url = $_POST['c_url'];
$c->seo_title = $_POST['c_seo_title'];
$c->height = $_POST['height'];
$c->seo_description = $_POST['c_seo_description'];
$c->seo_keywords = $_POST['c_seo_keywords'];
$c->short_description = $_POST['c_sdesc'];
$c->description = $_POST['c_desc'];
$c->more_description = $_POST['c_mdesc'];
$c->save('display_order');
if (!empty($_FILES['background']['name'])) {
$finfo = getimagesize($_FILES['background']['tmp_name']);
if (!isset($finfo['mime'])) {
Messages::addError('Background image file: Invalid file type');
} else {
$result = S3::putObjectFile($_FILES['background']['tmp_name'], $config->amazon->S3Bucket, $config->amazon->folders['site']['examples']['backgrounds'] . '/' . $c->id, S3::ACL_PUBLIC_READ, array(), $finfo['mime']);
if (!$result) {
Messages::addError('Amazon image upload failed');
jump('?page=examples');
}
}
}
jump('?page=examples');
}
if (isset($_GET['todo']) && $_GET['todo'] == 'edit') {
$c = new ExampleCategories(isset($_GET['id']) ? $_GET['id'] : null);
$smarty->assign('c', $c);
$smarty->assign('edit', 1);
$smarty->assign('backgroundImage', $c->getBackgroundLink());
}
示例5: md5
default:
$smarty->assign('administrators', $adm->getAll());
$smarty->assign('CONTENT', 'administrators/list.tpl');
break;
case 'add':
case 'edit':
if ($config->isPOST()) {
$adm->email = $_POST['email'];
if (!empty($_POST['password']) && $_POST['password'] == $_POST['password2']) {
$adm->password = md5($_POST['password']);
} else {
Messages::addError('Password not changed');
}
$adm->access = isset($_POST['access']) ? array_sum($_POST['access']) : 0;
if (empty($adm->id) && empty($adm->password)) {
Messages::addError('Password can\'t be empty');
jump('?page=administrators&action=add');
} else {
$adm->save();
if ($adm->id == Admin::getLogged()->id) {
Admin::setLoggedUser($adm);
}
Messages::addNotice('Saved');
jump('?page=administrators&action=edit&id=' . $adm->id);
}
}
$smarty->assign('accessData', Admin::getAccessData());
$smarty->assign('adm', $adm);
$smarty->assign('CONTENT', 'administrators/add_edit.tpl');
break;
case 'remove':
示例6: jump
Messages::addError($err);
}
}
if (!empty($_FILES['background']['name'])) {
if (!$template->uploadBgImageOnAmazon($_FILES['background']['tmp_name'], $err)) {
Messages::addError($err);
}
}
if (!empty($_FILES['xml']['name'])) {
if (!$template->uploadXmlOnAmazon($_FILES['xml']['tmp_name'], $err)) {
Messages::addError($err);
}
}
if (!empty($_FILES['swf']['name'])) {
if (!$template->uploadSwfOnAmazon($_FILES['swf']['tmp_name'], $err)) {
Messages::addError($err);
}
}
Messages::addNotice('Saved');
jump('?page=templates');
}
$smarty->assign('template', $template);
break;
case 'up':
if (!isset($_GET['id'])) {
jump('index.php?page=templates');
}
$template = new Templates((int) $_GET['id']);
$template->moveUp();
jump('index.php?page=templates');
break;
示例7: reloadPage
case 'add_edit':
if ($config->isPOST()) {
$language->lang = $_POST['lang'];
if (empty($language->id)) {
$language->lang_short = $_POST['lang_short'];
}
if ($language->alreadyExists()) {
Messages::addError('This language already exists in database');
reloadPage();
}
if (!empty($_FILES['xml']['name']) && !Messages::areErrors()) {
if (!$language->uploadXmlOnAmazon($_FILES['xml']['tmp_name'], $err)) {
Messages::addError($err);
}
} elseif (empty($language->id)) {
Messages::addError('Select xml file');
}
if (!Messages::areErrors()) {
$language->save('display_order');
Messages::addNotice('Saved');
}
jump('?page=language&action=add_edit&id=' . $language->id);
}
$smarty->assign('CONTENT', 'language/add_edit.tpl');
break;
case 'move_up':
case 'move_down':
if ($action == 'move_up') {
$language->moveUp();
} else {
$language->moveDown();
示例8: Validation
$_SESSION['loggedin'] = false;
include './classes/Validation.class.php';
include './classes/Database.class.php';
include './classes/Messages.class.php';
include './classes/Util.class.php';
$validate = new Validation();
$database = new Database();
$messages = new Messages();
$util = new Util();
$email = filter_input(INPUT_POST, 'email');
$password1 = filter_input(INPUT_POST, 'password1');
$password2 = filter_input(INPUT_POST, 'password2');
$passwordhint = filter_input(INPUT_POST, 'passwordhint');
if ($util->isPost()) {
if ($validate->fieldIsEmpty($email)) {
$messages->addError('Email is a required field.');
} else {
if (!$validate->emailIsValid($email)) {
$messages->addError('Email formatting is invalid.');
} else {
if ($validate->doesEmailExist($email)) {
$messages->addError('Email already exists in our database!');
}
}
}
if ($validate->fieldIsEmpty($password1)) {
$messages->addError('Password is a required field.');
} else {
if (!$validate->checkFieldLength($password1, 8)) {
$messages->addError('Password must be eight characters or greater.');
} else {
示例9: Validation
$validate = new Validation();
$database = new Database();
$messages = new Messages();
$util = new Util();
$first_name = filter_input(INPUT_POST, 'first_name');
$last_name = filter_input(INPUT_POST, 'last_name');
$gender = filter_input(INPUT_POST, 'gender');
$dob_day = filter_input(INPUT_POST, 'dob_day');
$dob_month = filter_input(INPUT_POST, 'dob_month');
$dob_year = filter_input(INPUT_POST, 'dob_year');
$location_state = filter_input(INPUT_POST, 'location_state');
$location_zip = filter_input(INPUT_POST, 'location_zip');
$location_city = filter_input(INPUT_POST, 'location_city');
if ($util->isPost()) {
if ($validate->fieldIsEmpty($first_name)) {
$messages->addError('First Name is a required field.');
}
if ($validate->fieldIsEmpty($last_name)) {
$messages->addError('Last Name is a required field.');
}
if ($messages->hasErrors()) {
$messages->displayErrorMsgs();
include 'profileform.php';
exit;
}
}
if ($database->insertUserProfile($first_name, $last_name, $gender, $dob_day, $dob_month, $dob_year, $location_state, $location_zip, $location_city)) {
echo "Profile Update Successful!";
} else {
echo "Profile Update Failed.";
}
示例10: Messages
$messages = new Messages();
$util = new Util();
$dateOfPurchase = filter_input(INPUT_POST, 'dateOfPurchase');
$selectedYear = filter_input(INPUT_POST, 'selectedYear');
$selectedMonth = filter_input(INPUT_POST, 'selectedMonth');
$selectedDay = filter_input(INPUT_POST, 'selectedDay');
$pricePerGallon = filter_input(INPUT_POST, 'pricePerGallon');
$numberOfGallons = filter_input(INPUT_POST, 'numberOfGallons');
$gasStationName = filter_input(INPUT_POST, 'gasStationName');
$gasStationStreet = filter_input(INPUT_POST, 'gasStationStreet');
$gasStationZip = filter_input(INPUT_POST, 'gasStationZip');
$gasStationCity = filter_input(INPUT_POST, 'gasStationCity');
$gasStationState = filter_input(INPUT_POST, 'gasStationState');
if ($util->isPost()) {
if (!$validate->fieldIsNotEmpty($dateOfPurchase)) {
$messages->addError('Date of purchase field is a required field.');
}
if (!$validate->fieldIsNotEmpty($pricePerGallon)) {
$messages->addError('Price per Gallon field is a required field.');
}
if (!$validate->fieldIsNotEmpty($numberOfGallons)) {
$messages->addError('Number of Gallons field is a required field.');
}
if (!$validate->fieldIsNotEmpty($gasStationZip)) {
$messages->addError('Gas Station Zip Code field is a required field.');
}
if ($messages->hasErrors()) {
$messages->displayErrorMsgs();
include './fuelreceiptform.php';
exit;
}
示例11: jump
Messages::addNotice('The thumbnail changed succesfully!');
}
if ($_POST['b_hash'] != $b->hash) {
$b->hash = $_POST['b_hash'];
$b->update();
}
Messages::addNotice('The changes were saved!');
jump('index.php?page=examples&action=manage_players&c_id=' . $_GET['c_id']);
} else {
Messages::addError('No changes!');
jump('index.php?page=examples&action=manage_players&c_id=' . $_GET['c_id']);
}
} else {
//add
if ($_FILES['b_thumbnail']['name'] == '') {
Messages::addError('You have to fill all fields!');
$smarty->assign('post', $_POST);
} else {
$eb = new ExamplePlayers();
$eb->cat_id = $_GET['c_id'];
//deg($_GET,$_POST);
$eb->hash = $_POST['b_hash'];
$eb->save();
$finfo = getimagesize($_FILES['b_thumbnail']['tmp_name']);
$result = S3::putObjectFile($_FILES['b_thumbnail']['tmp_name'], $config->amazon->S3Bucket, $config->amazon->folders['site']['examples']['thumbs'] . '/' . $eb->id, S3::ACL_PUBLIC_READ, array(), $finfo['mime']);
Messages::addNotice('The notification was added succesfully!');
jump('index.php?page=examples&action=manage_players&c_id=' . $_GET['c_id']);
}
}
}
if (isset($_GET['todo']) && $_GET['todo'] == 'edit') {
示例12: Validation
session_start();
$_SESSION['loggedin'] = false;
include './classes/Validation.class.php';
include './classes/Database.class.php';
include './classes/Messages.class.php';
include './classes/Util.class.php';
$validate = new Validation();
$database = new Database();
$messages = new Messages();
$util = new Util();
$email = filter_input(INPUT_POST, 'email');
$password = filter_input(INPUT_POST, 'password');
if ($util->isPost()) {
if ($validate->fieldIsEmpty($email)) {
$messages->addError('Email is a required field.');
} else {
if (!$validate->emailIsValid($email)) {
$messages->addError('Email formatting is invalid.');
}
}
if ($validate->fieldIsEmpty($password)) {
$messages->addError('Password is a required field.');
}
if ($messages->hasErrors()) {
$messages->displayErrorMsgs();
include './login.php';
exit;
}
}
if ($database->checkUserLogin($email, $password)) {