/** * Creat an authentication object * * @param Request $request * @return Scheme */ public function getAuthenticationObject(Request $request) { $registry = Registry::getInstance(); // if the authentication_source is set in the request, then it takes precedence $override = $request->getParam("authentication_source"); if ($override == null) { // otherwise, see if one has been set in session from a previous login $session_auth = $request->getSessionData("auth"); if ($session_auth != "") { $override = $session_auth; } } // make sure it's in our list, or if blank still, we get the default $name = $registry->getAuthenticationSource($override); // sanitize $name = preg_replace('/\\W/', '', $name); // main class $class_name = 'Application\\Model\\Authentication' . '\\' . ucfirst($name); // local custom version $local_class_name = 'Local\\Authentication' . '\\' . ucfirst($name); if (class_exists($local_class_name)) { $class_name = $local_class_name; } // make it $authentication = new $class_name($request); if (!$authentication instanceof Scheme) { throw new \Exception("class '{$class_name}' for the '{$name}' authentication scheme must extend Scheme"); } return $authentication; }
/** * Parameters to construct the url on the search redirect * * @return array */ public function searchRedirectParams() { $params['controller'] = $this->request->getParam('controller'); $params['action'] = "results"; $params['sort'] = $this->request->getParam('sort'); return $params; }
/** * Transform XML to HTML * * @param mixed $xml XML-like data * @param string $path_to_xsl * @param array $params */ protected function transform($xml, $path_to_xsl, $format, array $params = array()) { $import_array = array(); // the xsl lives here $distro_xsl_dir = $this->_view_dir; $local_xsl_dir = realpath(getcwd()) . "/views/"; // language // english file is included by default (as a fallback) array_push($import_array, "labels/eng.xsl"); $language = $this->request->getParam("lang"); $registry = Registry::getInstance(); if ($language == "") { $language = $registry->defaultLanguage(); } // if language is set to something other than english // then include that file to override the english labels if ($language != "eng" && $language != '') { array_push($import_array, "labels/{$language}.xsl"); } // make sure we've got a reference to the local includes too array_push($import_array, "includes.xsl"); // transform $xsl = new Xsl($distro_xsl_dir, $local_xsl_dir); return $xsl->transformToXml($xml, $path_to_xsl, $format, $params, $import_array); }
/** * Extract both query and limit params from the URL * @return array */ public function getAllSearchParams() { $search = $this->extractSearchParams(); $limits = array(); if ($this->request->getParam('clear-facets') != "true") { $limits = $this->extractLimitParams(); } return array_merge($search, $limits); }
/** * Create Authentication Scheme * * @param Request $request */ public function __construct(Request $request) { $this->request = $request; $this->registry = Registry::getInstance(); // get the user from the request $this->user = $this->request->getUser(); // send them back here when they are done $this->return_url = $this->request->getParam("return"); // flesh out our return url $base = $this->request->getBaseUrl(); $server = $this->request->getServerUrl(); if ($this->return_url == "") { $this->return_url = $base; // so send them home! } // @todo find out if some CAS servers are still tripping up on this $params = array('controller' => 'authenticate', 'action' => 'validate', 'return' => $this->return_url); $this->validate_url = $this->request->url_for($params, true); }
/** * @return Labels */ public function getLabels() { if (!$this->labels instanceof Labels) { $path = $this->getBootstrap()->getApplicationDir(); $this->labels = new Labels($path); // @todo need a proper language grabber // $lang = $this->registry->defaultLanguage(); $lang = $this->request->getParam("lang"); $this->labels->setLanguage($lang); } return $this->labels; }
/** * Add links for Category, Database, and Librarian * * @param mixed $object array|Category|Database * @param bool $deep whether to go deep if a Category is supplied */ public function injectDataLinks($object, $deep = true) { if ($object == null) { return null; } // array if (is_array($object) || $object instanceof \ArrayIterator) { foreach ($object as $item) { $this->injectDataLinks($item, $deep); } return null; } // not an object and not an array, so what is it? if (!is_object($object)) { throw new \DomainException('Param must be of type array, Category or Database'); } // Database if ($object instanceof Database) { // record url $params = array('controller' => $this->request->getParam('controller'), 'action' => 'database', 'id' => $object->getId()); $object->url = $this->request->url_for($params, true); // proxy url $params['action'] = 'proxy'; $object->url_proxy = $this->request->url_for($params, true); } elseif ($object instanceof Category) { // category link $params = array('controller' => 'databases', 'action' => 'subject', 'subject' => $object->getNormalized()); $object->url = $this->request->url_for($params, true); // embed link $params = array('controller' => 'embed', 'action' => 'gen-subject', 'subject' => $object->getNormalized()); $object->url_embed = $this->request->url_for($params, true); // embed link $params = array('controller' => 'embed', 'action' => 'gen-subject', 'subject' => $object->getNormalized()); $object->url_embed = $this->request->url_for($params); // only continue if we are going deep if ($deep == true) { // Librarian foreach ($object->getLibrarians() as $librarian) { $params = array('controller' => 'databases', 'action' => 'librarian', 'id' => $librarian->getId()); } // Databases foreach ($object->getSubcategories() as $subcategory) { foreach ($subcategory->getDatabases() as $database_sequence) { $this->injectDataLinks($database_sequence->getDatabase(), $deep); } } } } }