Esempio n. 1
0
 public function __construct($searchObject, $params)
 {
     global $library;
     global $configArray;
     // Save the basic parameters:
     $this->searchObject = $searchObject;
     // Parse the additional parameters:
     $params = explode(':', $params);
     $section = empty($params[0]) ? 'ResultsTop' : $params[0];
     $iniFile = isset($params[1]) ? $params[1] : 'facets';
     // Load the desired facet information:
     $searchLibrary = Library::getActiveLibrary();
     $searchLocation = Location::getActiveLocation();
     $config = getExtraConfigArray($iniFile);
     if ($searchObject->getSearchType() == 'genealogy') {
         $this->mainFacets = array();
     } else {
         $searchLibrary = Library::getActiveLibrary();
         $searchLocation = Location::getActiveLocation();
         $userLocation = Location::getUserHomeLocation();
         $hasSearchLibraryFacets = $searchLibrary != null && count($searchLibrary->facets) > 0;
         $hasSearchLocationFacets = $searchLocation != null && count($searchLocation->facets) > 0;
         if ($hasSearchLocationFacets) {
             $facets = $searchLocation->facets;
         } elseif ($hasSearchLibraryFacets) {
             $facets = $searchLibrary->facets;
         } else {
             $facets = Library::getDefaultFacets();
         }
         foreach ($facets as $facet) {
             if ($facet->showAboveResults == 1) {
                 $facetName = $facet->facetName;
                 if (isset($searchLibrary)) {
                     if ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                         $facetName = 'availability_toggle_' . $searchLibrary->subdomain;
                     }
                 }
                 if (isset($userLocation)) {
                     if ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                         $facetName = 'availability_toggle_' . $userLocation->code;
                     }
                 }
                 if (isset($searchLocation)) {
                     if ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                         $facetName = 'availability_toggle_' . $searchLocation->code;
                     }
                 }
                 $this->facets[$facetName] = $facet->displayName;
                 $this->facetSettings[$facetName] = $facet;
             }
         }
     }
     // Load other relevant settings:
     $this->baseSettings = array('rows' => $config['Results_Settings']['top_rows'], 'cols' => $config['Results_Settings']['top_cols']);
 }
Esempio n. 2
0
 public function __construct($searchObject, $params)
 {
     global $configArray;
     // Save the basic parameters:
     /** @var SearchObject_Solr|SearchObject_Base searchObject */
     $this->searchObject = $searchObject;
     // Parse the additional parameters:
     $params = explode(':', $params);
     $iniFile = isset($params[1]) ? $params[1] : 'facets';
     // Load the desired facet information:
     $config = getExtraConfigArray($iniFile);
     if ($this->searchObject->getSearchType() == 'genealogy') {
         $this->mainFacets = array();
     } else {
         $searchLibrary = Library::getActiveLibrary();
         global $locationSingleton;
         $searchLocation = $locationSingleton->getActiveLocation();
         $userLocation = Location::getUserHomeLocation();
         $hasSearchLibraryFacets = $searchLibrary != null && count($searchLibrary->facets) > 0;
         $hasSearchLocationFacets = $searchLocation != null && count($searchLocation->facets) > 0;
         if ($hasSearchLocationFacets) {
             $facets = $searchLocation->facets;
         } elseif ($hasSearchLibraryFacets) {
             $facets = $searchLibrary->facets;
         } else {
             $facets = Library::getDefaultFacets();
         }
         global $solrScope;
         foreach ($facets as $facet) {
             if ($facet->showAboveResults == 1) {
                 $facetName = $facet->facetName;
                 if ($solrScope) {
                     if ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                         $facetName = 'availability_toggle_' . $solrScope;
                     } else {
                         if ($facet->facetName == 'format_category' && $configArray['Index']['enableDetailedFormats']) {
                             $facetName = 'format_category_' . $solrScope;
                         }
                     }
                 }
                 $this->facets[$facetName] = $facet->displayName;
                 $this->facetSettings[$facetName] = $facet;
                 if (!$solrScope && $facet->facetName == 'availability_toggle') {
                     //Don't do availability toggles in the global scope.
                     //TODO: Base this off the default scope (i.e. mercury/responsive).
                     unset($this->facets[$facetName]);
                     unset($this->facetSettings[$facetName]);
                 }
             }
         }
     }
     // Load other relevant settings:
     $this->baseSettings = array('rows' => $config['Results_Settings']['top_rows'], 'cols' => $config['Results_Settings']['top_cols']);
 }
Esempio n. 3
0
 private static function loadLibraryLocationInformation()
 {
     if (MillenniumDriver::$libraryLocationInformationLoaded == false) {
         //Get a list of all locations for the active library
         global $library;
         global $timer;
         $userLibrary = Library::getPatronHomeLibrary();
         MillenniumDriver::$libraryLocations = array();
         MillenniumDriver::$libraryLocationLabels = array();
         $libraryLocation = new Location();
         if ($userLibrary) {
             $libraryLocation->libraryId = $userLibrary->libraryId;
             $libraryLocation->find();
             while ($libraryLocation->fetch()) {
                 MillenniumDriver::$libraryLocations[] = $libraryLocation->code;
                 MillenniumDriver::$libraryLocationLabels[$libraryLocation->code] = $libraryLocation->facetLabel;
             }
         } else {
             $libraryLocation->libraryId = $library->libraryId;
             $libraryLocation->find();
             while ($libraryLocation->fetch()) {
                 MillenniumDriver::$libraryLocations[] = $libraryLocation->code;
                 MillenniumDriver::$libraryLocationLabels[$libraryLocation->code] = $libraryLocation->facetLabel;
             }
         }
         MillenniumDriver::$homeLocationCode = null;
         MillenniumDriver::$homeLocationLabel = null;
         $searchLocation = Location::getSearchLocation();
         if ($searchLocation) {
             MillenniumDriver::$homeLocationCode = $searchLocation->code;
             MillenniumDriver::$homeLocationLabel = $searchLocation->facetLabel;
         } else {
             $homeLocation = Location::getUserHomeLocation();
             if ($homeLocation) {
                 MillenniumDriver::$homeLocationCode = $homeLocation->code;
                 MillenniumDriver::$homeLocationLabel = $homeLocation->facetLabel;
             }
         }
         $timer->logTime("Finished loading location data");
         MillenniumDriver::$scopingLocationCode = '';
         $searchLibrary = Library::getSearchLibrary();
         $searchLocation = Location::getSearchLocation();
         if (isset($searchLibrary)) {
             MillenniumDriver::$scopingLocationCode = $searchLibrary->ilsCode;
         }
         if (isset($searchLocation)) {
             MillenniumDriver::$scopingLocationCode = $searchLocation->code;
         }
         MillenniumDriver::$libraryLocationInformationLoaded = true;
     }
 }
Esempio n. 4
0
 function loginUser()
 {
     //Login the user.  Must be called via Post parameters.
     global $user;
     global $interface;
     $user = UserAccount::isLoggedIn();
     if (!$user || PEAR_Singleton::isError($user)) {
         $user = UserAccount::login();
         $interface->assign('user', $user);
         if (!$user || PEAR_Singleton::isError($user)) {
             return array('success' => false, 'message' => translate("Sorry that login information was not recognized, please try again."));
         }
     }
     $patronHomeBranch = Location::getUserHomeLocation();
     //Check to see if materials request should be activated
     require_once ROOT_DIR . '/sys/MaterialsRequest.php';
     return array('success' => true, 'name' => ucwords($user->firstname . ' ' . $user->lastname), 'phone' => $user->phone, 'email' => $user->email, 'homeLocation' => isset($patronHomeBranch) ? $patronHomeBranch->code : '', 'homeLocationId' => isset($patronHomeBranch) ? $patronHomeBranch->locationId : '', 'enableMaterialsRequest' => MaterialsRequest::enableMaterialsRequest(true));
 }
 public function getItemsFast()
 {
     global $configArray;
     if ($this->fastItems == null) {
         $searchLibrary = Library::getSearchLibrary();
         if ($searchLibrary) {
             $libraryLocationCode = $searchLibrary->ilsCode;
         }
         $searchLocation = Location::getSearchLocation();
         if ($searchLocation) {
             $homeLocationCode = $searchLocation->code;
         } else {
             $homeLocation = Location::getUserHomeLocation();
             if ($homeLocation) {
                 $homeLocationCode = $homeLocation->code;
             }
         }
         $this->fastItems = array();
         if ($this->itemsFromIndex) {
             $this->fastItems = array();
             foreach ($this->itemsFromIndex as $itemData) {
                 $isLocalItem = false;
                 $isLibraryItem = false;
                 if (array_key_exists('item', $itemData)) {
                     $itemId = $itemData['item'][0];
                     $locationCode = $itemData['item'][1];
                     $shelfLocation = mapValue('shelf_location', $locationCode);
                     $sharing = $itemData['item'][3];
                     $source = $itemData['item'][4];
                     $fileOrUrl = '';
                     if (count($itemData['item']) > 5) {
                         $fileOrUrl = $itemData['item'][5];
                     }
                     if (array_key_exists('scope', $itemData)) {
                         $isLocalItem = $itemData['scope'][1] == 'true';
                         $isLibraryItem = $itemData['scope'][2] == 'true';
                     }
                 } else {
                     $itemId = $itemData[1];
                     $locationCode = $itemData[2];
                     $shelfLocation = mapValue('shelf_location', $itemData[2]);
                     $sharing = $itemData[4];
                     $source = $itemData[5];
                     $fileOrUrl = '';
                     if (count($itemData) > 6) {
                         $fileOrUrl = $itemData[6];
                     }
                     $isLocalItem = isset($libraryLocationCode) && strlen($libraryLocationCode) > 0 && strpos($locationCode, $libraryLocationCode) === 0;
                     $isLibraryItem = isset($homeLocationCode) && strlen($homeLocationCode) > 0 && strpos($locationCode, $homeLocationCode) === 0;
                 }
                 $actions = $this->getActionsForItem($itemId, $fileOrUrl, null);
                 $libraryLabelObj = new Library();
                 $libraryLabelObj->whereAdd("'{$locationCode}' LIKE CONCAT(ilsCode, '%') and ilsCode <> ''");
                 $libraryLabelObj->selectAdd();
                 $libraryLabelObj->selectAdd('displayName');
                 if ($libraryLabelObj->find(true)) {
                     $libraryLabel = $libraryLabelObj->displayName;
                 } else {
                     $libraryLabel = $locationCode . ' Online';
                 }
                 //TODO: Get the correct number of available copies
                 $totalCopies = 1;
                 $this->fastItems[] = array('itemId' => $itemId, 'location' => $locationCode, 'callnumber' => '', 'availability' => $this->isItemAvailable($itemId, $totalCopies), 'holdable' => $this->isEContentHoldable($locationCode, $itemData), 'inLibraryUseOnly' => false, 'isLocalItem' => $isLocalItem, 'isLibraryItem' => $isLibraryItem, 'locationLabel' => 'Online', 'libraryLabel' => $libraryLabel, 'shelfLocation' => $shelfLocation, 'source' => 'Online ' . $source, 'sharing' => $sharing, 'actions' => $actions);
             }
         } else {
             /** @var File_MARC_Data_Field[] $itemFields */
             $itemFields = $this->getMarcRecord()->getFields('989');
             foreach ($itemFields as $itemField) {
                 $locationCode = trim($itemField->getSubfield('d') != null ? $itemField->getSubfield('d')->getData() : '');
                 //Each item can have multiple item fields
                 /** @var File_MARC_Subfield[] $eContentFields */
                 $eContentFields = $itemField->getSubfields('w');
                 $itemId = $itemField->getSubfield('1')->getData();
                 $iType = $itemField->getSubfield($configArray['Reindex']['iTypeSubfield'])->getData();
                 foreach ($eContentFields as $eContentField) {
                     $eContentData = trim($eContentField->getData() != null ? $eContentField->getData() : '');
                     if ($eContentData && strpos($eContentData, ':') > 0) {
                         $eContentFieldData = explode(':', $eContentData);
                         $source = trim($eContentFieldData[0]);
                         $protectionType = strtolower(trim($eContentFieldData[1]));
                         $totalCopies = 1;
                         if ($this->isValidProtectionType($protectionType)) {
                             if ($this->isValidForUser($locationCode, $eContentFieldData)) {
                                 $libraryLabelObj = new Library();
                                 $libraryLabelObj->whereAdd("'{$locationCode}' LIKE CONCAT(ilsCode, '%') and ilsCode <> ''");
                                 $libraryLabelObj->selectAdd();
                                 $libraryLabelObj->selectAdd('displayName');
                                 if ($libraryLabelObj->find(true)) {
                                     $libraryLabel = $libraryLabelObj->displayName;
                                 } else {
                                     $libraryLabel = $locationCode . ' Online';
                                 }
                                 $locationLabelObj = new Location();
                                 $locationLabelObj->whereAdd("'{$locationCode}' LIKE CONCAT(code, '%') and code <> ''");
                                 if ($locationLabelObj->find(true)) {
                                     $locationLabel = $locationLabelObj->displayName;
                                 } else {
                                     $locationLabel = $locationCode . ' Online';
                                 }
                                 //Get the file or url that is related to this item.
                                 $fileOrUrl = '';
                                 $acsId = null;
                                 if ($protectionType == 'external') {
                                     $urlSubfield = $itemField->getSubfield('u');
                                     if ($urlSubfield != null) {
                                         $fileOrUrl = $urlSubfield->getData();
                                     } else {
                                         //Get from the 856 field
                                         /** @var File_MARC_Data_Field[] $linkFields */
                                         $linkFields = $this->getMarcRecord()->getFields('856');
                                         foreach ($linkFields as $link) {
                                             $urlSubfield = $link->getSubfield('u');
                                             if ($urlSubfield != null) {
                                                 $fileOrUrl = $urlSubfield->getData();
                                             }
                                         }
                                     }
                                 } else {
                                     if (count($eContentFieldData) > 3) {
                                         $fileOrUrl = trim($eContentFieldData[3]);
                                     }
                                     if (count($eContentFieldData) > 4) {
                                         $acsId = trim($eContentFieldData[4]);
                                     }
                                     if (count($eContentFieldData) > 5) {
                                         $totalCopies = trim($eContentFieldData[5]);
                                     }
                                 }
                                 $fileOrUrl = trim($fileOrUrl);
                                 $actions = $this->getActionsForItem($itemId, $fileOrUrl, $acsId);
                                 $format = $this->getEContentFormat($fileOrUrl, $iType);
                                 $sharing = $this->getSharing($locationCode, $eContentFieldData);
                                 //Add an item
                                 $item = array('itemId' => $itemId, 'location' => $locationCode, 'locationLabel' => $locationLabel, 'libraryLabel' => $libraryLabel, 'callnumber' => '', 'availability' => $this->isItemAvailable($itemId, $totalCopies), 'holdable' => $this->isEContentHoldable($locationCode, $eContentFieldData), 'isLocalItem' => $this->isLocalItem($locationCode, $eContentFieldData), 'isLibraryItem' => $this->isLibraryItem($locationCode, $eContentFieldData), 'shelfLocation' => 'Online ' . $source, 'source' => $source, 'sharing' => $sharing, 'fileOrUrl' => $fileOrUrl, 'format' => $format, 'helpText' => $this->getHelpText($fileOrUrl), 'usageNotes' => $this->getUsageRestrictions($sharing, $libraryLabel, $locationLabel), 'formatNotes' => $this->getFormatNotes($fileOrUrl), 'size' => $this->getFileSize($fileOrUrl), 'actions' => $actions);
                                 $this->fastItems[] = $item;
                             }
                         }
                     }
                 }
             }
         }
     }
     return $this->fastItems;
 }
Esempio n. 6
0
 function launch()
 {
     global $interface;
     global $configArray;
     global $user;
     //Get a list of all reports the user has access to
     $reportDir = $configArray['Site']['reportPath'];
     $allowableLocationCodes = "";
     if ($user->hasRole('opacAdmin')) {
         $allowableLocationCodes = '.*';
     } elseif ($user->hasRole('libraryAdmin')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $allowableLocationCodes = trim($homeLibrary->ilsCode) . '.*';
     } elseif ($user->hasRole('locationReports')) {
         $homeLocation = Location::getUserHomeLocation();
         $allowableLocationCodes = trim($homeLocation->code) . '.*';
     }
     $availableReports = array();
     $dh = opendir($reportDir);
     while (false !== ($filename = readdir($dh))) {
         if (is_file($reportDir . '/' . $filename)) {
             if (preg_match('/(\\w+)_school_report\\.csv/i', $filename, $matches)) {
                 $locationCode = $matches[1];
                 if (preg_match("/{$allowableLocationCodes}/", $locationCode)) {
                     $availableReports[$locationCode] = $filename;
                 }
             }
         }
     }
     ksort($availableReports);
     $interface->assign('availableReports', $availableReports);
     $selectedReport = isset($_REQUEST['selectedReport']) ? $availableReports[$_REQUEST['selectedReport']] : reset($availableReports);
     $interface->assign('selectedReport', $selectedReport);
     $showOverdueOnly = isset($_REQUEST['showOverdueOnly']) ? $_REQUEST['showOverdueOnly'] == 'overdue' : true;
     $interface->assign('showOverdueOnly', $showOverdueOnly);
     $now = time();
     $fileData = array();
     if ($selectedReport) {
         $fhnd = fopen($reportDir . '/' . $selectedReport, "r");
         if ($fhnd) {
             while (($data = fgetcsv($fhnd)) !== FALSE) {
                 $okToInclude = true;
                 if ($showOverdueOnly) {
                     $dueDate = $data[12];
                     $dueTime = strtotime($dueDate);
                     if ($dueTime >= $now) {
                         $okToInclude = false;
                     }
                 }
                 if ($okToInclude || count($fileData) == 0) {
                     $fileData[] = $data;
                 }
             }
             $interface->assign('reportData', $fileData);
         }
     }
     if (isset($_REQUEST['download'])) {
         header('Content-Type: text/csv');
         header('Content-Disposition: attachment; filename=' . $selectedReport);
         header('Content-Length:' . filesize($reportDir . '/' . $selectedReport));
         foreach ($fileData as $row) {
             foreach ($row as $index => $cell) {
                 if ($index != 0) {
                     echo ",";
                 }
                 if (strpos($cell, ',') != false) {
                     echo '"' . $cell . '"';
                 } else {
                     echo $cell;
                 }
             }
             echo "\r\n";
         }
         exit;
     }
     $interface->setPageTitle('Student Report');
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->setTemplate('studentReport.tpl');
     $interface->display('layout.tpl');
 }
Esempio n. 7
0
 public function __construct($searchObject, $params)
 {
     global $configArray;
     // Save the passed-in SearchObject:
     $this->searchObject = $searchObject;
     // Parse the additional settings:
     $params = explode(':', $params);
     $mainSection = empty($params[0]) ? 'Results' : $params[0];
     $checkboxSection = isset($params[1]) ? $params[1] : false;
     $iniName = isset($params[2]) ? $params[2] : 'facets';
     if ($searchObject->getSearchType() == 'genealogy') {
         $config = getExtraConfigArray($iniName);
         $this->mainFacets = isset($config[$mainSection]) ? $config[$mainSection] : array();
     } else {
         $searchLibrary = Library::getActiveLibrary();
         global $locationSingleton;
         $searchLocation = $locationSingleton->getActiveLocation();
         $userLocation = Location::getUserHomeLocation();
         $hasSearchLibraryFacets = $searchLibrary != null && count($searchLibrary->facets) > 0;
         $hasSearchLocationFacets = $searchLocation != null && count($searchLocation->facets) > 0;
         if ($hasSearchLocationFacets) {
             $facets = $searchLocation->facets;
         } elseif ($hasSearchLibraryFacets) {
             $facets = $searchLibrary->facets;
         } else {
             $facets = Library::getDefaultFacets();
         }
         $this->facetSettings = array();
         $this->mainFacets = array();
         foreach ($facets as $facet) {
             $facetName = $facet->facetName;
             //Adjust facet name for local scoping
             if (isset($searchLibrary)) {
                 if ($facet->facetName == 'time_since_added') {
                     $facetName = 'local_time_since_added_' . $searchLibrary->subdomain;
                 } elseif ($facet->facetName == 'itype') {
                     $facetName = 'itype_' . $searchLibrary->subdomain;
                 } elseif ($facet->facetName == 'detailed_location') {
                     $facetName = 'detailed_location_' . $searchLibrary->subdomain;
                 } elseif ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                     $facetName = 'availability_toggle_' . $searchLibrary->subdomain;
                 }
             }
             if (isset($userLocation)) {
                 if ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                     $facetName = 'availability_toggle_' . $userLocation->code;
                 }
             }
             if (isset($searchLocation)) {
                 if ($facet->facetName == 'time_since_added' && $searchLocation->restrictSearchByLocation) {
                     $facetName = 'local_time_since_added_' . $searchLocation->code;
                 } elseif ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                     $facetName = 'availability_toggle_' . $searchLocation->code;
                 }
             }
             //Figure out if the facet should be included
             if ($mainSection == 'Results') {
                 if ($facet->showInResults == 1 && $facet->showAboveResults == 0) {
                     $this->facetSettings[$facetName] = $facet;
                     $this->mainFacets[$facetName] = $facet->displayName;
                 } elseif ($facet->showInAdvancedSearch == 1 && $facet->showAboveResults == 0) {
                     $this->facetSettings[$facetName] = $facet->displayName;
                 }
             } elseif ($mainSection == 'Author') {
                 if ($facet->showInAuthorResults == 1 && $facet->showAboveResults == 0) {
                     $this->facetSettings[$facetName] = $facet;
                     $this->mainFacets[$facetName] = $facet->displayName;
                 }
             }
         }
     }
     $this->checkboxFacets = $checkboxSection && isset($config[$checkboxSection]) ? $config[$checkboxSection] : array();
 }
Esempio n. 8
0
 function validateTextId()
 {
     //Setup validation return array
     $validationResults = array('validatedOk' => true, 'errors' => array());
     if (!$this->textId || strlen($this->textId) == 0) {
         $this->textId = $this->label . ' ' . $this->sharing;
         if ($this->sharing == 'private') {
             $this->textId .= '_' . $this->userId;
         } elseif ($this->sharing == 'location') {
             $location = Location::getUserHomeLocation();
             $this->textId .= '_' . $location->code;
         } elseif ($this->sharing == 'library') {
             global $library;
             $this->textId .= '_' . $library->getPatronHomeLibrary()->subdomain;
         }
     }
     //First convert the text id to all lower case
     $this->textId = strtolower($this->textId);
     //Next convert any non word characters to an underscore
     $this->textId = preg_replace('/\\W/', '_', $this->textId);
     //Make sure the length is less than 50 characters
     if (strlen($this->textId) > 50) {
         $this->textId = substr($this->textId, 0, 50);
     }
     return $validationResults;
 }
Esempio n. 9
0
 /**
  * Initialise the object for retrieving advanced
  *   search screen facet data from inside solr.
  *
  * @access  public
  * @return  boolean
  */
 public function initAdvancedFacets()
 {
     global $configArray;
     global $locationSingleton;
     // Call the standard initialization routine in the parent:
     parent::init();
     $searchLibrary = Library::getActiveLibrary();
     $searchLocation = $locationSingleton->getActiveLocation();
     /** @var Location $userLocation */
     $userLocation = Location::getUserHomeLocation();
     $hasSearchLibraryFacets = $searchLibrary != null && count($searchLibrary->facets) > 0;
     $hasSearchLocationFacets = $searchLocation != null && count($searchLocation->facets) > 0;
     if ($hasSearchLocationFacets) {
         $facets = $searchLocation->facets;
     } elseif ($hasSearchLibraryFacets) {
         $facets = $searchLibrary->facets;
     } else {
         $facets = Library::getDefaultFacets();
     }
     $this->facetConfig = array();
     foreach ($facets as $facet) {
         $facetName = $facet->facetName;
         //Adjust facet name for local scoping
         if (isset($searchLibrary)) {
             if ($facet->facetName == 'time_since_added') {
                 $facetName = 'local_time_since_added_' . $searchLibrary->subdomain;
             } elseif ($facet->facetName == 'itype') {
                 $facetName = 'itype_' . $searchLibrary->subdomain;
             } elseif ($facet->facetName == 'detailed_location') {
                 $facetName = 'detailed_location_' . $searchLibrary->subdomain;
             } elseif ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                 $facetName = 'availability_toggle_' . $searchLibrary->subdomain;
             }
         }
         if (isset($userLocation)) {
             if ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                 $facetName = 'availability_toggle_' . $userLocation->code;
             }
         }
         if (isset($searchLocation)) {
             if ($facet->facetName == 'time_since_added' && $searchLocation->restrictSearchByLocation) {
                 $facetName = 'local_time_since_added_' . $searchLocation->code;
             } elseif ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                 $facetName = 'availability_toggle_' . $searchLocation->code;
             }
         }
         if ($facet->showInAdvancedSearch) {
             $this->facetConfig[$facetName] = $facet->displayName;
         }
     }
     //********************
     $facetLimit = $this->getFacetSetting('Advanced_Settings', 'facet_limit');
     if (is_numeric($facetLimit)) {
         $this->facetLimit = $facetLimit;
     }
     // Spellcheck is not needed for facet data!
     $this->spellcheck = false;
     //********************
     // Basic Search logic
     $this->searchTerms[] = array('index' => $this->defaultIndex, 'lookfor' => "");
     return true;
 }
Esempio n. 10
0
 /**
  * Take a filter string and add it into the protected
  *   array checking for duplicates.
  *
  * @access  public
  * @param   string  $newFilter   A filter string from url : "field:value"
  */
 public function addFilter($newFilter)
 {
     global $configArray;
     // Extract field and value from URL string:
     list($field, $value) = $this->parseFilter($newFilter);
     $searchLibrary = Library::getActiveLibrary();
     global $locationSingleton;
     $searchLocation = $locationSingleton->getActiveLocation();
     $userLocation = Location::getUserHomeLocation();
     global $solrScope;
     // Check for duplicates -- if it's not in the array, we can add it
     if (!$this->hasFilter($newFilter)) {
         if ($field == 'literary-form') {
             $field = 'literary_form';
         } else {
             if ($field == 'literary-form-full') {
                 $field = 'literary_form_full';
             } else {
                 if ($field == 'target-audience') {
                     $field = 'target_audience';
                 } else {
                     if ($field == 'target-audience-full') {
                         $field = 'target_audience_full';
                     }
                 }
             }
         }
         //See if the filter should be localized
         if (isset($searchLibrary)) {
             if ($field == 'time_since_added') {
                 $field = 'local_time_since_added_' . $searchLibrary->subdomain;
             } elseif ($field == 'itype') {
                 $field = 'itype_' . $searchLibrary->subdomain;
             } elseif ($field == 'detailed_location') {
                 $field = 'detailed_location_' . $searchLibrary->subdomain;
             }
         }
         if ($solrScope) {
             if ($field == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                 $field = 'availability_toggle_' . $solrScope;
             } elseif ($field == 'format' && $configArray['Index']['enableDetailedFormats']) {
                 $field = 'format_' . $solrScope;
             } elseif ($field == 'format_category' && $configArray['Index']['enableDetailedFormats']) {
                 $field = 'format_category_' . $solrScope;
             } elseif ($field == 'econtent_source' && $configArray['Index']['enableDetailedEContentSources']) {
                 $field = 'econtent_source_' . $solrScope;
             } elseif ($field == 'econtent_protection_type' && $configArray['Index']['enableDetailedEContentSources']) {
                 $field = 'econtent_protection_type_' . $solrScope;
             }
         }
         if (isset($userLocation)) {
             if ($field == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                 $field = 'availability_toggle_' . $userLocation->code;
             }
         }
         if (isset($searchLocation)) {
             if ($field == 'time_since_added' && $searchLocation->restrictSearchByLocation) {
                 $field = 'local_time_since_added_' . $searchLocation->code;
             } elseif ($field == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                 $field = 'availability_toggle_' . $searchLocation->code;
             }
         }
         $this->filterList[$field][] = $value;
     }
 }