Exemplo n.º 1
0
 /**
  * Given a record driver, get a URL for that record.
  *
  * @param \VuFind\RecordDriver\AbstractBase|string $driver Record driver
  * representing record to link to, or source|id pipe-delimited string
  * @param string                                   $tab    Optional record
  * tab to access
  *
  * @return string
  */
 public function getTabUrl($driver, $tab = null)
 {
     // Build the URL:
     $urlHelper = $this->getView()->plugin('url');
     $details = $this->router->getTabRouteDetails($driver, $tab);
     return $urlHelper($details['route'], $details['params']);
 }
Exemplo n.º 2
0
 /**
  * Home action -- call standard results action
  *
  * @return mixed
  */
 public function homeAction()
 {
     // If there is exactly one record, send the user directly there:
     $ids = $this->params()->fromQuery('id', array());
     if (count($ids) == 1) {
         $details = RecordRouter::getTabRouteDetails($ids[0]);
         $target = $this->url()->fromRoute($details['route'], $details['params']);
         // forward print param, if necessary:
         $print = $this->params()->fromQuery('print');
         $params = empty($print) ? '' : '?print=' . urlencode($print);
         return $this->redirect()->toUrl($target . $params);
     }
     // Not exactly one record -- show search results:
     return $this->resultsAction();
 }
Exemplo n.º 3
0
 /**
  * Process the "edit list" submission.
  *
  * @param \VuFind\Db\Row\User     $user Logged in user
  * @param \VuFind\Db\Row\UserList $list List being created/edited
  *
  * @return object|bool                  Response object if redirect is
  * needed, false if form needs to be redisplayed.
  */
 protected function processEditList($user, $list)
 {
     // Process form within a try..catch so we can handle errors appropriately:
     try {
         $finalId = $list->updateFromRequest($user, $this->getRequest()->getPost());
         // If the user is in the process of saving a record, send them back
         // to the save screen; otherwise, send them back to the list they
         // just edited.
         $recordId = $this->params()->fromQuery('recordId');
         $recordSource = $this->params()->fromQuery('recordSource', 'VuFind');
         if (!empty($recordId)) {
             $details = RecordRouter::getActionRouteDetails($recordSource . '|' . $recordId, 'Save');
             return $this->redirect()->toRoute($details['route'], $details['params']);
         }
         // Similarly, if the user is in the process of bulk-saving records,
         // send them back to the appropriate place in the cart.
         $bulkIds = $this->params()->fromPost('ids', array());
         if (!empty($bulkIds)) {
             $params = array();
             foreach ($bulkIds as $id) {
                 $params[] = urlencode('ids[]') . '=' . urlencode($id);
             }
             $saveUrl = $this->url()->forRoute('cart-save');
             return $this->redirect()->toUrl($saveUrl . '?' . implode('&', $params));
         }
         return $this->redirect()->toRoute('userList', array('id' => $finalId));
     } catch (\Exception $e) {
         switch (get_class($e)) {
             case 'VuFind\\Exception\\ListPermission':
             case 'VuFind\\Exception\\MissingField':
                 $this->flashMessenger()->setNamespace('error')->addMessage($e->getMessage());
                 return false;
             case 'VuFind\\Exception\\LoginRequired':
                 return $this->forceLogin();
             default:
                 throw $e;
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Redirect the user to the main record view.
  *
  * @param string $params Parameters to append to record URL.
  * @param string $tab    Record tab to display (null for default).
  *
  * @return mixed
  */
 protected function redirectToRecord($params = '', $tab = null)
 {
     $details = RecordRouter::getTabRouteDetails($this->loadRecord(), $tab);
     $target = $this->url()->fromRoute($details['route'], $details['params']);
     return $this->redirect()->toUrl($target . $params);
 }