/** * Gets search options * * @return array */ public function getSearchOptions() { $savedOptions = unserialize($this->searchOptions); // Merge with default options to be sure that we have correct value for any new options which are not saved in the profile. $defaultOptions = array(); if (class_exists('Editor_Forms_SearchOptions')) { $defaultOptions = Editor_Forms_SearchOptions::getDefaultSearchOptions(); } return array_merge($defaultOptions, $savedOptions); }
/** * Gets an array of the default search options. * */ public static function getDefaultSearchOptions() { $dummyForm = new Editor_Forms_SearchOptions(); return self::formValues2Options($dummyForm->getValues(true)); }
/** * Gets a list of concepts matching the search options. * * @param array $searchOptions * @return array An array with the labels of the schemes */ public function searchConcepts($searchOptions) { $editorOptions = OpenSKOS_Application_BootstrapAccess::getOption('editor'); $availableOptions = Editor_Forms_SearchOptions::getAvailableSearchOptions(); $availableOptions['conceptSchemes'] = $this->getAllConceptSchemeUriTitlesMap(); $query = OpenSKOS_Solr_Queryparser_Editor::factory()->parse($searchOptions, $editorOptions['languages'], $availableOptions, $this->_getCurrentTenant()); // Pagination $queryParams = array(); if (isset($searchOptions['start']) && !empty($searchOptions['start'])) { $queryParams['start'] = $searchOptions['start']; } if (isset($searchOptions['rows']) && !empty($searchOptions['rows'])) { $queryParams['rows'] = $searchOptions['rows']; } //@TODO: implement language specific sort by using prefLabelSort@... Solr fields $queryParams['sort'] = 'prefLabelSort asc'; $response = Api_Models_Concepts::factory()->setQueryParams($queryParams)->getConcepts($query); $response = $response['response']; $result = array(); $result['numFound'] = $response['numFound']; $result['data'] = array(); if (isset($response['start'])) { $result['start'] = $response['start']; } if ($response['numFound'] > 0) { foreach ($response['docs'] as &$record) { $result['data'][] = new Api_Models_Concept($record); } } return $result; }
private function _switchUserToSearchProfile(OpenSKOS_Db_Table_Row_User $user, $profileId) { //!TODO Consider movin inside the user object. if ($user->isAllowedToUseSearchProfile($profileId)) { $profilesModel = new OpenSKOS_Db_Table_SearchProfiles(); $profile = $profilesModel->find($profileId)->current(); if (null !== $profile) { $detailedSearchOptions = $profile->getSearchOptions(); } else { $detailedSearchOptions = Editor_Forms_SearchOptions::getDefaultSearchOptions(); } $detailedSearchOptions['searchProfileId'] = $profileId; $user->setSearchOptions($detailedSearchOptions); } }