/**
  *
  * @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;
 }
 /**
  * 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;
 }
 /**
  * @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;
 }
Exemple #4
0
 /**
  * Figure out which bib IDs to load from the ILS.
  *
  * @param \VuFind\ILS\Connection                     $catalog ILS connection
  * @param \VuFind\Search\Solr\Params                 $params  Solr parameters
  * @param string                                     $range   Range setting
  * @param string                                     $dept    Department setting
  * @param \Zend\Mvc\Controller\Plugin\FlashMessenger $flash   Flash messenger
  *
  * @return array
  */
 public function getBibIDsFromCatalog($catalog, $params, $range, $dept, $flash)
 {
     // The code always pulls in enough catalog results to get a fixed number
     // of pages worth of Solr results.  Note that if the Solr index is out of
     // sync with the ILS, we may see fewer results than expected.
     $resultPages = $this->getResultPages();
     $perPage = $params->getLimit();
     $newItems = $catalog->getNewItems(1, $perPage * $resultPages, $range, $dept);
     // Build a list of unique IDs
     $bibIDs = [];
     for ($i = 0; $i < count($newItems['results']); $i++) {
         $bibIDs[] = $newItems['results'][$i]['id'];
     }
     // Truncate the list if it is too long:
     $limit = $params->getQueryIDLimit();
     if (count($bibIDs) > $limit) {
         $bibIDs = array_slice($bibIDs, 0, $limit);
         $flash->setNamespace('info')->addMessage('too_many_new_items');
     }
     return $bibIDs;
 }