Exemplo n.º 1
0
 /**
  *
  * @return string
  */
 public function __invoke()
 {
     if ($this->request->getQuery('msg', false) && $this->flashMessenger->hasMessages()) {
         $messages = $this->flashMessenger->getMessages();
         foreach ($messages as $message) {
             $this->flashMessenger->addInfoMessage($message);
         }
     }
     $messageString = '';
     foreach ($this->namespaces as $class => $ns) {
         $this->flashMessenger->setNamespace($ns);
         $messages = $this->flashMessenger->getMessages();
         if ($this->flashMessenger->hasCurrentMessages()) {
             $messages += $this->flashMessenger->getCurrentMessages();
             $this->flashMessenger->clearCurrentMessages();
         }
         if (count($messages) > 0) {
             // Twitter bootstrap message box
             $messageString .= sprintf('<div class="container-fluid">
                     <div class="alert alert-%s alert-dismissable fade in">
                         <button data-dismiss="alert" class="close" aria-hidden="true" type="button">x</button>
                         %s
                     </div>
                 </div>', $class, implode('<br />', $messages));
         }
     }
     return $messageString;
 }
 /**
  * Gets messages and removes them from storage
  *
  * @param string $type
  * @return array
  **/
 public function getMessages($type = self::MSG_ERROR)
 {
     $this->getFlashMessenger()->setNamespace($type);
     $messages = $this->_flashMessenger->getMessages();
     $currentMessages = $this->_flashMessenger->getCurrentMessages();
     $this->_flashMessenger->clearMessages();
     $this->_flashMessenger->clearCurrentMessages();
     $messages = array_merge($messages, $currentMessages);
     return $messages;
 }
Exemplo n.º 3
0
 /**
  * Generate flash message <div>'s with appropriate classes based on message type.
  *
  * @return string $html
  */
 public function __invoke()
 {
     $html = '';
     $namespaces = ['error', 'info', 'success'];
     foreach ($namespaces as $ns) {
         $this->fm->setNamespace($ns);
         $messages = array_merge($this->fm->getMessages(), $this->fm->getCurrentMessages());
         foreach (array_unique($messages, SORT_REGULAR) as $msg) {
             $html .= '<div class="' . $this->getClassForNamespace($ns) . '">';
             // Advanced form:
             if (is_array($msg)) {
                 // Use a different translate helper depending on whether
                 // or not we're in HTML mode.
                 if (!isset($msg['translate']) || $msg['translate']) {
                     $helper = isset($msg['html']) && $msg['html'] ? 'translate' : 'transEsc';
                 } else {
                     $helper = isset($msg['html']) && $msg['html'] ? false : 'escapeHtml';
                 }
                 $helper = $helper ? $this->getView()->plugin($helper) : false;
                 $tokens = isset($msg['tokens']) ? $msg['tokens'] : [];
                 $default = isset($msg['default']) ? $msg['default'] : null;
                 $html .= $helper ? $helper($msg['msg'], $tokens, $default) : $msg['msg'];
             } else {
                 // Basic default string:
                 $transEsc = $this->getView()->plugin('transEsc');
                 $html .= $transEsc($msg);
             }
             $html .= '</div>';
         }
         $this->fm->clearMessages();
         $this->fm->clearCurrentMessages();
     }
     return $html;
 }
 /**
  * Outputs message depending on flag
  *
  * @return string
  */
 public function __invoke()
 {
     // get messages
     $messages = array_unique(array_merge($this->flashMessenger->getMessages(), $this->flashMessenger->getCurrentMessages()));
     // initialize output
     $output = '';
     // loop through messages
     foreach ($messages as $message) {
         // create output
         $output .= '<div class="alert alert-success">';
         $output .= '<button class="close" data-dismiss="alert" type="button">×</button>';
         $output .= '<h2>' . $message . '</h2>';
         $output .= '</div>';
     }
     // clear messages
     $this->flashMessenger->clearMessages();
     $this->flashMessenger->clearCurrentMessages();
     // return output
     return $output . "\n";
 }
Exemplo n.º 5
0
 /**
  * @return  string
  */
 public function __invoke()
 {
     $messageString = '';
     foreach ($this->namespaces as $ns) {
         $this->flashMessenger->setNamespace($ns);
         $messages = $this->flashMessenger->getMessages();
         if ($this->flashMessenger->hasCurrentMessages()) {
             $messages += $this->flashMessenger->getCurrentMessages();
             $this->flashMessenger->clearCurrentMessages();
         }
         if (count($messages) > 0) {
             // Twitter bootstrap message box
             $messageString .= sprintf('<div class="messagebox alert-%s">
                     <a class="messagebox-closer" href="#close" style="display: inline;" title="Close"></a>
                     <div class="messagebox-text">%s</div>
                 </div>', $ns, implode('<br />', $messages));
         }
     }
     return $messageString;
 }
Exemplo n.º 6
0
 /**
  * Outputs message depending on flag
  *
  * @return string 
  */
 public function __invoke()
 {
     // get messages
     $messages = array_unique(array_merge($this->flashMessenger->getMessages(), $this->flashMessenger->getCurrentMessages()));
     $warning_messages = array_unique(array_merge($this->flashMessenger->getWarningMessages(), $this->flashMessenger->getCurrentWarningMessages()));
     $error_messages = array_unique(array_merge($this->flashMessenger->getErrorMessages(), $this->flashMessenger->getCurrentErrorMessages()));
     $success_messages = array_unique(array_merge($this->flashMessenger->getSuccessMessages(), $this->flashMessenger->getCurrentSuccessMessages()));
     $this->flashMessenger->getSuccessMessages();
     // initialize output
     $output = '';
     // loop through messages
     foreach ($messages as $message) {
         // create output
         $output .= '<div class="alert" role="alert">';
         $output .= $message;
         $output .= '</div>';
     }
     foreach ($error_messages as $error_message) {
         // create output
         $output .= '<div class="alert alert-danger" role="alert">';
         $output .= $error_message;
         $output .= '</div>';
     }
     foreach ($warning_messages as $warning_message) {
         // create output
         $output .= '<div class="alert alert-warning" role="alert">';
         $output .= $warning_message;
         $output .= '</div>';
     }
     foreach ($success_messages as $success_message) {
         // create output
         $output .= '<div class="alert alert-success" role="alert">';
         $output .= $success_message;
         $output .= '</div>';
     }
     // clear messages
     $this->flashMessenger->clearMessages();
     $this->flashMessenger->clearCurrentMessages();
     // return output
     return $output . "\n";
 }
Exemplo n.º 7
0
 /**
  * Outputs message depending on flag
  *
  * @return string 
  */
 public function __invoke()
 {
     // get messages
     $messages = array_unique(array_merge($this->flashMessenger->getMessages(), $this->flashMessenger->getCurrentMessages()));
     // initialize output
     $output = '';
     // loop through messages
     foreach ($messages as $message) {
         // split into parts to identify $class and $textDomain
         $parts = explode('_', $message);
         $class = $parts[2];
         $textDomain = $parts[0];
         // create output
         $output .= '<div class="alert alert-' . $class . '">';
         $output .= '<button class="close" data-dismiss="alert" type="button">×</button>';
         $output .= $this->getView()->translate($message, $textDomain);
         $output .= '</div>';
     }
     // clear messages
     $this->flashMessenger->clearMessages();
     $this->flashMessenger->clearCurrentMessages();
     // return output
     return $output . "\n";
 }