示例#1
0
 /**
  * Constructor
  * 
  */
 public function __construct($pz2_key)
 {
     // full set of Libraries for this institution from configuration file
     $this->config = Config::getInstance();
     $xml = $this->config->getXml();
     $query = "//config[@name='targets']/target[@pz2_key='{$pz2_key}']/library";
     $libraries = $xml->xpath($query);
     $lib_arr = array();
     foreach ($libraries as $config_library) {
         $arr = array();
         $description = (string) $config_library;
         $arr['description'] = $description;
         foreach ($config_library->attributes() as $k => $v) {
             $arr[$k] = (string) $v;
         }
         $library = new Library();
         $arr['pz2_key'] = $pz2_key;
         $library->load($arr);
         $lib_arr[] = $library;
     }
     usort($lib_arr, function ($a, $b) {
         return strcmp($a->name, $b->name);
     });
     $this->libraries = $lib_arr;
 }
示例#2
0
 /**
  * Constructor
  * 
  */
 public function __construct($pz2_key)
 {
     // full set of Libraries for this institution from Search25 API
     $this->config = Config::getInstance();
     $url = $this->config->getConfig("apiurl");
     $command = "/institutions/{$pz2_key}/libraries.json?active=true";
     $this->client = Factory::getHttpClient();
     $this->client->setUri($url . $command);
     $api_libraries = $this->client->send()->getBody();
     $api_libraries = json_decode($api_libraries, true);
     $api_libraries = array_pop($api_libraries);
     $arr = array();
     foreach ($api_libraries as $api_library) {
         $library = new Library();
         $api_library['pz2_key'] = $pz2_key;
         $library->load($api_library);
         $arr[] = $library;
     }
     usort($arr, array($this, 'alphasort'));
     $this->libraries = $arr;
 }