Exemple #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']);
 }
Exemple #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']);
 }
Exemple #3
0
 function resetFacetsToDefault()
 {
     $library = new Library();
     $libraryId = $_REQUEST['id'];
     $library->libraryId = $libraryId;
     if ($library->find(true)) {
         $library->clearFacets();
         $defaultFacets = Library::getDefaultFacets($libraryId);
         $library->facets = $defaultFacets;
         $library->update();
         $_REQUEST['objectAction'] = 'edit';
     }
     $structure = $this->getObjectStructure();
     header("Location: /Admin/Libraries?objectAction=edit&id=" . $libraryId);
 }
 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();
 }
Exemple #5
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;
 }