本文整理汇总了PHP中Messages::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP Messages::reset方法的具体用法?PHP Messages::reset怎么用?PHP Messages::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Messages
的用法示例。
在下文中一共展示了Messages::reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($robotId = null, $creatorId = null)
{
$this->robotId = $robotId;
$this->creatorId = $creatorId;
Messages::reset();
$this->initialize();
}
示例2: __construct
public function __construct($userDataId = null, $skillId = null)
{
$this->userDataId = $userDataId;
$this->skillId = $skillId;
Messages::reset();
$this->initialize();
}
示例3: __construct
public function __construct($formInput = null, $login)
{
$this->formInput = $formInput;
Messages::reset();
if ($login === True) {
$this->initializeLogin();
} else {
$this->initializeSignUp();
}
}
示例4: render
public function render($types = array('error', 'warning', 'success', 'info'))
{
$res = '';
if (\Messages::any()) {
$res .= '<br/>';
}
foreach ($types as $type) {
foreach (\Messages::instance()->get($type) as $message) {
$res .= '<div class="alert alert-' . $message['type'] . '">' . $message['body'] . '</div>' . "\n";
}
}
\Messages::reset();
return $res;
}
示例5: __construct
public function __construct($formInput = null)
{
Messages::reset();
$this->formInput = $formInput;
$this->iD = -1;
$this->firstName = "";
$this->lastName = "";
$this->email = "";
$this->handle = "";
$this->about = "";
$this->password = "";
$this->errors = array();
$this->hasErrors = false;
$this->initialize();
}
示例6: __construct
public function __construct($formInput = null)
{
$this->formInput = $formInput;
Messages::reset();
$this->initialize();
}
示例7: display_front
/**
* Get all messages in HTML form
* Reset messages after that
*
* @return array
*/
public static function display_front($align = 'left')
{
$output = '';
foreach (array('error', 'warning', 'success', 'info') as $type) {
$messages = \Messages::instance()->get($type);
if (!empty($messages)) {
// Open message container before first message
$output === '' and $output = '<div class="message_container" style="display: none;">' . "\n";
$output .= '<div class="popup" id="signUp">' . "\n";
$output .= '<div class="legend">' . "\n";
if ($type == 'error') {
$type = 'Oops!';
}
if ($type == 'success') {
$welcome_message = 'Thanks for registering with Evan Evans. We have sent an email to your nominated address with a link to activate your account. Sometimes inboxes can be a little overprotective so you may need to check your junk or spam folders.';
$activate_message = 'You have been sent an email to activate you new password.';
$newsletter_message = 'Thanks for signing up for our newsletter!';
foreach ($messages as $message) {
if ($message['body'] === $welcome_message) {
$type = 'Welcome!';
} else {
if ($message['body'] === $activate_message) {
$type = 'Just one more step';
} else {
if ($message['body'] === $newsletter_message) {
$type = 'We`ll be in touch';
}
}
}
}
}
$output .= '<h2>' . ucfirst($type) . '</h2>' . "\n";
$output .= '</div>' . "\n";
$output .= '<div class="container_12">' . "\n";
$output .= '<div class="grid_12">' . "\n";
foreach ($messages as $message) {
$output .= "\t\t" . '' . $message['body'] . '<br />' . "\n";
}
$output .= '</div>' . "\n";
$output .= '</div>' . "\n";
$output .= '<div class="clear"></div>' . "\n";
$output .= '</div>' . "\n";
}
}
\Messages::reset();
// Close message container after last message
$output !== '' and $output .= '</div>' . "\n";
return $output;
}
示例8: empty
?>
<h2>It should set errors from a file</h2>
<?php
Messages::setErrors("../resources/errors_English.txt");
echo "LAST_NAME_TOO_SHORT: " . Messages::getError("LAST_NAME_TOO_SHORT") . "<br>";
echo "EMAIL_INVALID: " . Messages::getError("EMAIL_INVALID") . "<br>";
echo "LAST_NAME_INVALID: " . Messages::getError("LAST_NAME_HAS_INVALID_CHARS") . "<br>";
echo empty(Messages::getError("LAST_NAME_TOO_SHORT")) ? "Failed: it did not set LAST_NAME_TOO_SHORT from file" : "";
?>
<h2>It should allow reset</h2>
<?php
Messages::reset();
echo "LAST_NAME_TOO_SHORT: " . Messages::getError("LAST_NAME_TOO_SHORT") . "<br>";
echo "EMAIL_INVALID: " . Messages::getError("EMAIL_INVALID") . "<br>";
echo "LAST_NAME_HAS_INVALID_CHARS: " . Messages::getError("LAST_NAME_HAS_INVALID_CHARS") . "<br>";
?>
<h2>It should allow change of locale</h2>
<?php
Messages::$locale = 'Spanish';
Messages::reset();
echo "LAST_NAME_TOO_SHORT: " . Messages::getError("LAST_NAME_TOO_SHORT") . "<br>";
echo "EMAIL_INVALID: " . Messages::getError("EMAIL_INVALID") . "<br>";
echo "LAST_NAME_HAS_INVALID_CHARS: " . Messages::getError("LAST_NAME_HAS_INVALID_CHARS") . "<br>";
?>
</body>
</html>
示例9: action_delete_infotab_image
/**
* Delete content image
*
* @param $image_id = Image ID
* @param $content_id = Content ID
* @param $type = Type of content (infotab or hotspot)
* @param $delete = If type is "hotspot" we can either delete image or video
*/
public function action_delete_infotab_image($image_id = false, $content_id = false, $type = 'infotab', $delete = 'image')
{
if ($image_id && $content_id) {
$images = Model_Application_Image::find(array('where' => array('application_id' => $content_id), 'order_by' => array('sort' => 'asc')), 'id');
if ($images) {
if (isset($images[$image_id])) {
$image = $images[$image_id];
if (strtolower($type) == 'hotspot') {
// Delete only part of hotspot, either image or video
if ($delete == 'image') {
// Delete only image but not whole hotspot
$this->delete_infotab_image($image->image);
$image->set(array('image' => null, 'alt_text' => null));
} else {
// Delete only video but not whole hotspot
$image->set(array('video' => null, 'video_title' => null));
}
$image->save();
\Messages::success(ucfirst($type) . ' ' . strtolower($delete) . ' was successfully deleted.');
} else {
// If there is only one image and image is required
if (count($images) == 1) {
if (\Config::get('infotab.image.required', false) && !\Request::is_hmvc()) {
\Messages::error('You can\'t delete all images. Please add new image in order to delete this one.');
} else {
// Reset sort fields
\DB::update(Model_Application_Image::get_protected('_table_name'))->value('sort', \DB::expr('sort - 1'))->where('sort', '>', $image->sort)->execute();
// Delete image
$this->delete_infotab_image($image->image);
$image->delete();
\Messages::success(ucfirst($type) . ' image was successfully deleted.');
}
} else {
if ($image->cover == 1 && !\Request::is_hmvc()) {
\Messages::error('You can\'t delete cover image. Set different image as cover in order to delete this one.');
} else {
// Reset sort fields
\DB::update(Model_Application_Image::get_protected('_table_name'))->value('sort', \DB::expr('sort - 1'))->where('sort', '>', $image->sort)->execute();
// Delete image
$this->delete_infotab_image($image->image);
$image->delete();
\Messages::success(ucfirst($type) . ' image was successfully deleted.');
}
}
}
} else {
\Messages::error(ucfirst($type) . ' image you are trying to delete don\'t exists. Check your url and try again.');
}
} else {
\Messages::error(ucfirst($type) . ' image you are trying to delete don\'t exists. Check your url and try again.');
}
}
if (\Input::is_ajax()) {
\Messages::reset();
\Messages::success('Hotspot was successfully deleted.');
echo \Messages::display();
} else {
if (\Request::is_hmvc()) {
\Messages::reset();
} else {
\Response::redirect(\Input::referrer());
}
}
}
示例10: setLocale
public static function setLocale($locale)
{
self::$locale = $locale;
Messages::reset();
}
示例11: __construct
public function __construct($args = null)
{
$this->arguments = $args;
Messages::reset();
$this->initialize();
}
示例12: action_delete
public function action_delete($id = false)
{
if (is_numeric($id)) {
// Get news item to edit
if ($item = Model_Accordion::find_one_by_id($id)) {
// Delete other content data like images, files, etc.
if (!empty($item->images)) {
foreach ($item->images as $image) {
$this->delete_image($image->image);
$image->delete();
}
}
try {
$item->delete();
\Messages::success('Accordion successfully deleted.');
} catch (\Database_Exception $e) {
// show validation errors
\Messages::error('<strong>There was an error while trying to delete accordion</strong>');
// Uncomment lines below to show database errors
//$errors = $e->getMessage();
//\Messages::error($errors);
}
}
}
// If its a HMVC request than reset messages and do nothing
\Request::is_hmvc() ? \Messages::reset() : \Response::redirect(\Input::referrer());
}
示例13: action_delete
public function action_delete($id = false)
{
if (is_numeric($id)) {
// Get news item to edit
if ($item = Model_Attribute_Option::find_one_by_id($id)) {
// Delete item
try {
$item->delete();
// NRB-Gem: remove from product_attributes and product_attribute_price
$a_attr = \Product\Model_Attribute::find_by(array(array('attributes', 'like', '%"' . $item->attribute_id . '":"' . $id . '"%')));
$a_attr_id = array();
foreach ($a_attr as $o_attr) {
$a_attr_id[] = $o_attr->id;
}
if (count($a_attr_id)) {
$s_ids = '(' . implode(',', $a_attr_id) . ')';
\DB::delete('product_attributes')->where('id', 'IN', \DB::expr($s_ids))->execute();
\DB::delete('product_attribute_price')->where('product_attribute_id', 'IN', \DB::expr($s_ids))->execute();
}
\Messages::success('Attribute option successfully deleted.');
} catch (\Database_Exception $e) {
// show validation errors
\Messages::error('<strong>There was an error while trying to delete attribute option</strong>');
// Uncomment lines below to show database errors
//$errors = $e->getMessage();
//\Messages::error($errors);
}
}
}
if (\Request::is_hmvc()) {
\Messages::reset();
} else {
\Response::redirect(\Input::referrer(\Uri::create('admin/attribute/list')));
}
}
示例14: action_infotab_hotspot
/**
* Edit product hotspot position
*
* @param $product_id = Product ID
* @param $infotab_id = Infotab ID
*
*/
public function action_infotab_hotspot($produt_id = false, $infotab_id = false, $hotspot_id = false)
{
// Check for product
if (!is_numeric($produt_id)) {
\Response::redirect('admin/product/list');
}
// Get news item to edit
if (!($product = Model_Product::find_one_by_id($produt_id))) {
\Response::redirect('admin/product/list');
}
// Check for infotab
if (!is_numeric($infotab_id)) {
\Response::redirect('admin/product/list');
}
// Get news item to edit
if (!($item = Model_Product_To_Infotabs::find_by_pk($infotab_id))) {
\Response::redirect('admin/product/list');
}
// Get hotspot is exist
if (is_numeric($hotspot_id)) {
if (!($hotspot = Model_Infotab_Image::find_by_pk($hotspot_id))) {
unset($hotspot);
}
}
if (\Input::post()) {
$insert = \Input::post();
if (!\Input::is_ajax()) {
$val = Model_Infotab_Image::validate('create');
if (!$val->run()) {
if ($val->error() != array()) {
// show validation errors
\Messages::error('<strong>There was an error while trying to create hotspot</strong>');
foreach ($val->error() as $e) {
\Messages::error($e->get_message());
}
}
\Response::redirect(\Uri::create('admin/product/infotab_edit/' . $product->id . '/' . $item->unique_id . (isset($hotspot) ? '/' . $hotspot->id : '')));
}
$insert['title'] = trim($insert['title']) != '' ? $insert['title'] : NULL;
$insert['description'] = trim($insert['description']) != '' ? $insert['description'] : NULL;
}
$insert['infotab_id'] = $infotab_id;
if (\Input::post('create', false)) {
$hotspot = Model_Infotab_Image::forge($insert);
try {
$hotspot->save();
if (\Input::is_ajax()) {
$return['hotspot_id'] = $hotspot->id;
echo json_encode($return);
exit;
}
} catch (\Database_Exception $e) {
// show validation errors
\Messages::error('<strong>There was an error while trying to create hotspot</strong>');
// Uncomment lines below to show database errors
$errors = $e->getMessage();
\Messages::error($errors);
if (\Input::is_ajax()) {
$return['message'] = \Messages::display();
$return['hotspot_id'] = false;
echo json_encode($return);
exit;
}
}
}
if (\Input::post('update', false)) {
if (isset($hotspot)) {
/** IMAGES **/
// Upload image and display errors if there are any
$image = $this->upload_infotab_image();
if (!$image['exists'] && \Config::get('infotab.image.required', false) && empty($hotspot->image)) {
// No previous images and image is not selected and it is required
\Messages::error('<strong>There was an error while trying to upload hotspot image</strong>');
\Messages::error('You have to select image');
} elseif ($image['errors']) {
\Messages::error('<strong>There was an error while trying to upload hotspot image</strong>');
foreach ($image['errors'] as $error) {
\Messages::error($error);
}
}
if ($image['is_valid'] && !(!$image['exists'] && \Config::get('infotab.image.required', false) && empty($hotspot->image)) || \Input::post('use_cover_image', false)) {
// Clear previous messages if exists
\Messages::reset();
$item_image['alt_text'] = \Input::post('alt_text', false) ? \Input::post('alt_text', false) : NULL;
// Save images if new files are submitted
if (isset($this->_infotab_image_data)) {
foreach ($this->_infotab_image_data as $image_data) {
$item_image['image'] = $image_data['saved_as'];
// Delete old infotab image
if (\Input::post('image_db', false)) {
$this->delete_infotab_image(\Input::post('image_db', ''));
}
}
//.........这里部分代码省略.........
示例15: testHasNoMessage
public function testHasNoMessage()
{
Messages::reset();
$errorMessage = Messages::getError("GIANTS_ARE_HERE");
$this->assertTrue(empty($errorMessage), 'It should not have an error messages for giants');
}