Ejemplo n.º 1
0
 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_file = "custom/Authentication/{$name}.php";
     if (file_exists($local_file)) {
         require_once $local_file;
         $class_name = 'Local\\Authentication' . '\\' . ucfirst($name);
         if (!class_exists($class_name)) {
             throw new \Exception("the custom authentication scheme '{$name}' should have a class called '{$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 Authentication");
     }
     return $authentication;
 }
Ejemplo n.º 2
0
 /**
  * Create UserOptions object saving Request with session data
  * @param Request $request
  */
 public function __construct(Request $request)
 {
     $this->container = $request->getContainer('pazpar2options');
     if ($request->getParam('sourcetype') != '') {
         $this->setSessionData('source_type', $request->getParam('sourcetype'));
         // if changing sourcetype, clear all old target selections
         $this->unsetSessionData('selectedby');
     } else {
         if (!$this->existsInSessionData('source_type')) {
             $config = Config::getInstance();
             $this->setSessionData('source_type', $config->getDefaultSourceType());
         }
     }
     // if this is a submit, change the session values as required
     if ($request->getParam('changetargets') != '') {
         $selectedby = $request->getParam('selectedby');
         if ($selectedby == 'names') {
             $targets = $request->getParam('target', null, true);
             $this->setSessionData('names', $targets);
             $this->setSessionData('selectedby', $selectedby);
         } else {
             if ($selectedby == 'subjects') {
                 $subjects = $request->getParam('subject', null, true);
                 $this->setSessionData('subjects', $subjects);
                 $this->setSessionData('selectedby', $selectedby);
             } else {
                 if ($selectedby == 'entitlements') {
                     $entitlements = $request->getParam('entitlement', null, true);
                     $this->setSessionData('entitlements', $entitlements);
                     $this->setSessionData('selectedby', $selectedby);
                 }
             }
         }
     }
     // retrieve the session values
     // set the actual targets to use
     if ($this->existsInSessionData('selectedby')) {
         $key = $this->getSessionData('selectedby');
     } else {
         $this->setSessionData('selectedby', 'names');
         $this->setSessionData('names', array('all'));
         $key = 'names';
     }
     $this->calculateTargets($key, $this->getSessionData($key), $this->getSessionData('source_type'));
 }
Ejemplo n.º 3
0
 /**
  * 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, array $params = array())
 {
     $registry = Registry::getInstance();
     $import_array = array();
     // the xsl lives here
     $distro_xsl_dir = $this->_script_path . "/";
     $local_xsl_dir = realpath(getcwd()) . "/views/";
     // language file
     $request = new Request();
     $language = $request->getParam("lang");
     if ($language == "") {
         $language = $registry->defaultLanguage();
     }
     // english file is included by default (as a fallback)
     array_push($import_array, "labels/eng.xsl");
     // 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, $this->format, $params, $import_array);
 }