/**
  *
  * @param \MUtil_Batch_BatchAbstract $batch
  * @param string $title
  * @param \Gems_AccessLog $accessLog
  */
 public function direct(\MUtil_Batch_BatchAbstract $batch, $title, $accessLog = null)
 {
     if ($batch->isConsole()) {
         $batch->runContinuous();
         $messages = array_values($batch->getMessages(true));
         echo implode("\n", $messages) . "\n";
         $echo = array_filter(array_map('trim', preg_split('/<[^>]+>/', \MUtil_Echo::out())));
         if ($echo) {
             echo "\n\n================================================================\nECHO OUTPUT:\n\n";
             echo implode("\n", $echo);
         }
         if ($accessLog instanceof \Gems_AccessLog) {
             $accessLog->logChange($this->getRequest(), $messages, $echo);
         }
         exit;
     } elseif ($batch->run($this->getRequest())) {
         exit;
     } else {
         $controller = $this->getActionController();
         $batchContainer = $controller->html->div(array('class' => 'batch-container'));
         $batchContainer->h3($title);
         if ($batch->isFinished()) {
             $controller->addMessage($batch->getMessages(true), 'info');
             $batchContainer->pInfo($batch->getRestartButton($controller->_('Prepare recheck'), array('class' => 'actionlink')));
             if ($accessLog instanceof \Gems_AccessLog) {
                 $echo = array_filter(array_map('trim', preg_split('/<[^>]+>/', \MUtil_Echo::getOutput())));
                 $accessLog->logChange($this->getRequest(), null, $echo);
             }
         } else {
             if ($batch->count()) {
                 $batchContainer->pInfo($batch->getStartButton(sprintf($controller->_('Start %s jobs'), $batch->count())));
                 $batchContainer->append($batch->getPanel($controller->view, $batch->getProgressPercentage() . '%'));
             } else {
                 $batchContainer->pInfo($controller->_('Nothing to do.'));
             }
         }
     }
 }
 public function autofilterAction()
 {
     // Make sure all links are generated as if the current request was index.
     $this->aliasAction('index');
     // \MUtil_Model::$verbose = true;
     // We do not need to return the layout, just the above table
     $this->disableLayout();
     $this->html[] = $this->_createTable();
     $this->html->raw(\MUtil_Echo::out());
 }
 /**
  * Action that switches the maintenance lock on or off.
  */
 public function maintenanceAction()
 {
     // Switch lock
     if ($this->util->getMonitor()->reverseMaintenanceMonitor()) {
         $this->accesslog->logChange($this->getRequest(), $this->_('Maintenance mode set ON'));
     } else {
         $this->accesslog->logChange($this->getRequest(), $this->_('Maintenance mode set OFF'));
         // Dump the existing maintenance mode messages.
         $this->escort->getMessenger()->clearCurrentMessages();
         $this->escort->getMessenger()->clearMessages();
         \MUtil_Echo::out();
     }
     // Redirect
     $request = $this->getRequest();
     $this->_reroute(array($request->getActionKey() => 'index'));
 }
 /**
  * Action that switches the maintenance lock on or off.
  */
 public function maintenanceAction()
 {
     // Switch lock
     $this->util->getMaintenanceLock()->reverse();
     // Dump the existing maintenance mode messages.
     $this->escort->getMessenger()->clearCurrentMessages();
     $this->escort->getMessenger()->clearMessages();
     \MUtil_Echo::out();
     // Redirect
     $request = $this->getRequest();
     $this->_reroute(array($request->getActionKey() => 'index'));
 }