public function __construct($robotId = null, $creatorId = null) { $this->robotId = $robotId; $this->creatorId = $creatorId; Messages::reset(); $this->initialize(); }
public function __construct($userDataId = null, $skillId = null) { $this->userDataId = $userDataId; $this->skillId = $skillId; Messages::reset(); $this->initialize(); }
public function __construct($formInput = null, $login) { $this->formInput = $formInput; Messages::reset(); if ($login === True) { $this->initializeLogin(); } else { $this->initializeSignUp(); } }
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; }
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(); }
public function __construct($formInput = null) { $this->formInput = $formInput; Messages::reset(); $this->initialize(); }
/** * 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; }
?> <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>
/** * 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()); } } }
public static function setLocale($locale) { self::$locale = $locale; Messages::reset(); }
public function __construct($args = null) { $this->arguments = $args; Messages::reset(); $this->initialize(); }
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()); }
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'))); } }
/** * 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', '')); } } } if (isset($item_image)) { $insert['alt_text'] = isset($item_image['alt_text']) ? $item_image['alt_text'] : NULL; $insert['image'] = isset($item_image['image']) ? $item_image['image'] : $hotspot->image; } } else { // Delete uploaded images if there is product saving error if (isset($this->_infotab_image_data)) { foreach ($this->_infotab_image_data as $image_data) { $this->delete_infotab_image($image_data['saved_as']); } } } /** END OF IMAGES **/ /** VIDEOS **/ $item_video['video_title'] = \Input::post('video_title', false) ? \Input::post('video_title', false) : NULL; $item_video['video'] = \Input::post('video_url', false) ? \Input::post('video_url', false) : NULL; if (!is_null($item_video['video'])) { // Check video $youtube = \App\Youtube::forge(); $video = $youtube->parse($item_video['video'])->get(); if (!$video) { \Messages::error('"' . $item_video['video'] . '" is invalid video URL. Video not updated.'); // Revert to old values $item_video['video_title'] = $hotspot->video_title; $item_video['video'] = $hotspot->video; } } if (isset($item_video)) { $insert['video'] = isset($item_video['video']) ? $item_video['video'] : NULL; $insert['video_title'] = isset($item_video['video_title']) ? $item_video['video_title'] : NULL; // Unset video title is there is no video if (is_null($insert['video'])) { $insert['video_title'] = NULL; } } /** END OF: VIDEOS **/ $hotspot->set($insert); try { $hotspot->save(); \Messages::success('Hotspot sucessfully updated.'); } catch (\Database_Exception $e) { // show validation errors \Messages::error('There was an error while trying to update hotspot.'); \Messages::error('Please try again.'); // Uncomment lines below to show database errors $errors = $e->getMessage(); \Messages::error($errors); // Delete uploaded images if there is product saving error if (isset($this->_infotab_image_data)) { foreach ($this->_infotab_image_data as $image_data) { $this->delete_infotab_image($image_data['saved_as']); } } } if (\Input::is_ajax()) { echo \Messages::display(); exit; } } } } \Response::redirect(\Uri::create('admin/product/infotab_edit/' . $product->id . '/' . $item->unique_id . (isset($hotspot) ? '/' . $hotspot->id : ''))); }
public function testHasNoMessage() { Messages::reset(); $errorMessage = Messages::getError("GIANTS_ARE_HERE"); $this->assertTrue(empty($errorMessage), 'It should not have an error messages for giants'); }
/** * Delete content image * * @param $content_id = Content ID */ public function action_delete_image($id = false) { if (is_numeric($id)) { // Get news item to edit if ($item = Model_Product_To_Infotabs::find_by_pk($id)) { // Delete hotspot images if (!empty($item->images)) { foreach ($item->images as $image) { \Request::forge('admin/product/delete_infotab_image/' . $image->id . '/' . $image->infotab_id)->execute()->response(); } } // Delete item try { $this->delete_image($item->image); $item->image = NULL; $item->alt_text = NULL; // Make infotab inactive as it cant show without image $item->active = 0; $item->save(); \Messages::success('Info Tab image successfully deleted.'); } catch (\Database_Exception $e) { // show validation errors \Messages::error('<strong>There was an error while trying to delete info tab image</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/product/infotab/list'))); } }