Example #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']);
 }
 /**
  * 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();
 }
Example #3
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);
 }