/** * Constructor */ public function __construct() { $this->cache = new Cache(); // application config $this->registry = Registry::getInstance(); // local config $this->config = $this->getConfig(); // cache results based on local config or registry, default true $this->should_cache_results = $this->config->getConfig('CACHE_RESULTS', false, $this->registry->getConfig('CACHE_RESULTS', false, true)); }
/** * Individual record */ public function recordAction() { $id = $this->request->getParam('id'); // get the record $results = $this->engine->getRecord($id); if ($this->request->getParam('original') != null || $this->config->getConfig('INCLUDE_ORIGINAL_RECORD', false)) { $results->getRecord(0)->includeOriginalRecord(); } // set lables and links $this->helper->addResultsLabels($results); $this->helper->addRecordLinks($results); // add to response $this->response->setVariable('results', $results); // view template $this->response->setView($this->id . '/record.xsl'); return $this->response; }
/** * Fetch item and holding records from an ILS for this record */ public function fetchHoldings() { $xerxes_record = $this->getXerxesRecord(); $id = $xerxes_record->getRecordID(); // id from the record $type = $this->config->getConfig("LOOKUP"); // availability look-up type // mark that we've checked holdings either way $this->holdings->checked = true; // no holdings source defined or somehow id's are blank if ($xerxes_record->hasPhysicalHoldings() == false || $type == "" || $id == "") { return $this; } // get the data $availabilty_factory = new AvailabilityFactory(); $availability = $availabilty_factory->getAvailabilityObject($type); $this->holdings = $availability->getHoldings($id); $this->holdings->checked = true; // items not to cache $no_cache = $this->config->getConfig('LOCATIONS_NO_CACHE', false); if ($no_cache != '' && $no_cache instanceof \SimpleXMLElement) { $locations = array(); foreach ($no_cache->location as $location) { $locations[] = (string) $location; } foreach ($this->holdings->getItems() as $item) { if (in_array($item->location, $locations)) { return $this; } } } // cache it for the future $cache = new Cache(); $expiry = $this->config->getConfig("HOLDINGS_CACHE_EXPIRY", false, 30 * 60); // expiry set for 30 mins $expiry += time(); $cache->set($this->getCacheId(), $this->holdings, $expiry); return $this; }
/** * Create a Search Query * * @param Request $request * @param Config $config */ public function __construct(Request $request = null, Config $config = null) { // registry $this->registry = Registry::getInstance(); if ($config != null) { // config $this->config = $config; // defaults set in config(s) $this->max = $this->registry->getConfig("RECORDS_PER_PAGE", false, $this->max); $this->max = $this->config->getConfig("RECORDS_PER_PAGE", false, $this->max); $this->max_allowed = $this->registry->getConfig("MAX_RECORDS_PER_PAGE", false, $this->max_allowed); $this->max_allowed = $this->config->getConfig("MAX_RECORDS_PER_PAGE", false, $this->max_allowed); $this->sort = $this->registry->getConfig("SORT_ORDER", false, $this->sort); $this->sort = $this->config->getConfig("SORT_ORDER", false, $this->sort); } // xerxes request if ($request != null) { // make these available $this->request = $request; // populate it with the 'search' related params out of the url foreach ($this->extractSearchGroupings() as $term) { $this->addTerm($term["id"], $term["boolean"], $term["field"], $term["relation"], $term["query"]); } // also limits foreach ($this->extractLimitGroupings() as $limit) { $this->addLimit($limit["boolean"], $limit["field"], $limit["relation"], $limit["value"]); } // start, max, sort $this->start = $this->request->getParam('start', 1); $this->max = $this->request->getParam('max', $this->max); $this->sort = $this->request->getParam('sort', $this->sort); // store the original (public) sort as the sort_id, // we'll take sort as the (internal) sort $this->sort_id = $this->sort; // swap for internal if ($this->config != null) { $this->sort = $this->config->swapForInternalSort($this->sort); } // make sure records per page does not exceed upper bound if ($this->max > $this->max_allowed) { $this->max = $this->max_allowed; } } }