###################################################
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
###################################################
public function test_getPromotion_missingPromotion_returnsNull() { $rawSearchResult = $this->getSearchResultAsSimpleXml(); unset($rawSearchResult->promotion); $searchResult = new SearchResult($rawSearchResult->asXML()); $this->assertNull($searchResult->getPromotion()); }
public function execute($body = null) { if ($body == null) { $body = $this->getBody(); } $result = $this->client->search($body); $result = new SearchResult($result, $this->params); $suggest = $result->getSuggestions(); if (!empty($suggest)) { $this->client->setSuggestions($suggest); } // reset search params after each search $this->params = null; return $result; }
public function setUp() { $jsonPath = __DIR__ . '/' . self::JSON_MOCK_FILE; $this->jsonMock = file_get_contents($jsonPath); $searchResult = SearchResult::createFromJson($this->jsonMock); $this->searchResultFromJsonMock = $searchResult; }
private function searchBySphinx($request, $response, $kw, $p) {/*{{{*/ $doctorSearchd = SphinxSearchdBase::createSearchdByType('Doctor'); $utf8Kw = mb_convert_encoding($kw, 'utf-8', 'gbk'); $res = $doctorSearchd->query($utf8Kw, ($p - 1) * 15, 15); $searchResult = SearchResult::sphinxResult2searchResult($res, 'doctor', ($p - 1) * 15, 15); $response->totalPage = ceil($searchResult->total_found/$searchResult->pageSize); $results = array(); foreach($searchResult->items as $item) {/*{{{*/ $doctor = DAL::get()->find('doctor',$item->id); if($doctor->isNull() || $doctor->deleted > 0 ) { continue; } $result = array(); $result['id'] = $doctor->id; $result['name'] = $doctor->name; $result['title'] = $doctor->title; $result['hospital'] = $doctor->hospitalfaculty->hospital->name; $result['userid'] = $doctor->getUserId(); $result['hospitalfacultyname'] = $doctor->hospitalfaculty->name ; $results[] = (object)$result; }/*}}}*/ return $results; }/*}}}*/
public function next() { if ($this->fetched || !$this->result) { return false; } $this->fetched = true; return SearchResult::newFromTitle($this->result); }
function next() { if ($this->resultSet === false) { return false; } $row = $this->resultSet->fetchObject(); if ($row === false) { return false; } return SearchResult::newFromTitle(Title::makeTitle($row->page_namespace, $row->page_title), $this); }
public function update($pa_options = null) { $this->_generateSortableValue(); // populate sort field // invalidate get() prefetch cache SearchResult::clearResultCacheForTable($this->tableName()); // Invalid entire labels-by-id cache since we can't know what entries pertain to the label we just changed LabelableBaseModelWithAttributes::$s_labels_by_id_cache = array(); // Unset label cache entry for modified label only unset(LabelableBaseModelWithAttributes::$s_label_cache[$this->getSubjectTableName()][$this->get($this->getSubjectKey())]); return parent::update($pa_options); }
public function testGets() { $o_search = caGetSearchInstance('ca_objects'); $this->assertInstanceOf('SearchEngine', $o_search); $o_res = $o_search->search('*', array('sort' => 'ca_object_labels.name')); /** @var SearchResult $o_res */ $this->assertInstanceOf('SearchResult', $o_res); $this->assertEquals(10, $o_res->numHits()); SearchResult::clearGetWithTemplatePrefetch(); // old values may be cached from previous tests $i = 0; while ($o_res->nextHit()) { $vs_label = $o_res->getWithTemplate('^ca_objects.preferred_labels'); $this->assertGreaterThan(0, strlen($vs_label)); $this->assertRegExp("/{$i}\$/", $vs_label); $i++; } }
/** * Performs a search by calling the search() method on the underlying search engine plugin * Information about all searches is logged to ca_search_log * * @param string $ps_search The search to perform; engine takes Lucene syntax query * @param SearchResult $po_result A newly instantiated sub-class of SearchResult to place search results into and return. If this is not set, then a generic SearchResults object will be returned. * @param array $pa_options Optional array of options for the search. Options include: * * sort = field or attribute to sort on in <table name>.<field or attribute name> format (eg. ca_objects.idno); default is to sort on relevance (aka. sort='_natural') * sortDirection = direction to sort results by, either 'asc' for ascending order or 'desc' for descending order; default is 'asc' * no_cache = if true, search is performed regardless of whether results for the search are already cached; default is false * limit = if set then search results will be limited to the quantity specified. If not set then all results are returned. * form_id = optional form identifier string to record in log for search * log_details = optional form description to record in log for search * search_source = optional source indicator text to record in log for search * checkAccess = optional array of access values to filter results on * showDeleted = if set to true, related items that have been deleted are returned. Default is false. * deletedOnly = if set to true, only deleted items are returned. Default is false. * limitToModifiedOn = if set returned results will be limited to rows modified within the specified date range. The value should be a date/time expression parse-able by TimeExpressionParser * sets = if value is a list of set_ids, only rows that are members of those sets will be returned * user_id = If set item level access control is performed relative to specified user_id, otherwise defaults to logged in user * dontFilterByACL = if true ACL checking is not performed on results * appendToSearch = * restrictSearchToFields = * * @return SearchResult Results packages in a SearchResult object, or sub-class of SearchResult if an instance was passed in $po_result * @uses TimeExpressionParser::parse */ public function doSearch($ps_search, $po_result = null, $pa_options = null) { $t = new Timer(); global $AUTH_CURRENT_USER_ID; if ($vs_append_to_search = isset($pa_options['appendToSearch']) ? ' ' . $pa_options['appendToSearch'] : '') { $ps_search .= $vs_append_to_search; } $ps_search = str_replace("[BLANK]", '"[BLANK]"', $ps_search); // the special [BLANK] search term, which returns records that have *no* content in a specific fields, has to be quoted in order to protect the square brackets from the parser. if (!is_array($pa_options)) { $pa_options = array(); } if (($vn_limit = caGetOption('limit', $pa_options, null, array('castTo' => 'int'))) < 0) { $vn_limit = null; } $vs_sort = caGetOption('sort', $pa_options, null); $vs_sort_direction = strtolower(caGetOption('sortDirection', $pa_options, caGetOption('sort_direction', $pa_options, null))); //print "QUERY=$ps_search<br>"; // // Note that this is *not* misplaced code that should be in the Lucene plugin! // // We are using the Lucene syntax as our query syntax regardless the of back-end search engine. // The Lucene calls below just parse the query and then rewrite access points as-needed; the result // is a Lucene-compliant query ready-to-roll that is passed to the engine plugin. Of course, the Lucene // plugin just uses the string as-is... other plugins my choose to parse it however they wish to. // // // Process suffixes list... if search conforms to regex then we append a suffix. // This is useful, for example, to allow auto-wildcarding of accession numbers: if the search looks like an accession regex-wise we can append a "*" // $va_suffixes = $this->opo_search_config->getAssoc('search_suffixes'); if (is_array($va_suffixes) && sizeof($va_suffixes) && !preg_match('!"!', $ps_search)) { // don't add suffix wildcards when quoting foreach ($va_suffixes as $vs_preg => $vs_suffix) { if (preg_match("!{$vs_preg}!", $ps_search)) { $ps_search = preg_replace("!({$vs_preg})[\\*]*!", "\$1{$vs_suffix}", $ps_search); } } } $vb_no_cache = isset($pa_options['no_cache']) ? $pa_options['no_cache'] : false; unset($pa_options['no_cache']); $vn_cache_timeout = (int) $this->opo_search_config->get('cache_timeout'); if ($vn_cache_timeout == 0) { $vb_no_cache = true; } // don't try to cache if cache timeout is 0 (0 means disabled) $t_table = $this->opo_datamodel->getInstanceByTableName($this->ops_tablename, true); $vs_cache_key = md5($ps_search . "/" . print_R($this->getTypeRestrictionList(), true)); $o_cache = new SearchCache(); $vb_from_cache = false; if (!$vb_no_cache && $o_cache->load($vs_cache_key, $this->opn_tablenum, $pa_options)) { $vn_created_on = $o_cache->getParameter('created_on'); if (time() - $vn_created_on < $vn_cache_timeout) { Debug::msg('SEARCH cache hit for ' . $vs_cache_key); $va_hits = $o_cache->getResults(); if ($vs_sort != '_natural') { $va_hits = $this->sortHits($va_hits, $this->ops_tablename, $vs_sort, $vs_sort_direction); } elseif ($vs_sort == '_natural' && $vs_sort_direction == 'desc') { $va_hits = array_reverse($va_hits); } $o_res = new WLPlugSearchEngineCachedResult($va_hits, $this->opn_tablenum); $vb_from_cache = true; } else { Debug::msg('cache expire for ' . $vs_cache_key); $o_cache->remove(); } } if (!$vb_from_cache) { Debug::msg('SEARCH cache miss for ' . $vs_cache_key); $vs_char_set = $this->opo_app_config->get('character_set'); $o_query_parser = new LuceneSyntaxParser(); $o_query_parser->setEncoding($vs_char_set); $o_query_parser->setDefaultOperator(LuceneSyntaxParser::B_AND); $ps_search = preg_replace('![\']+!', '', $ps_search); try { $o_parsed_query = $o_query_parser->parse($ps_search, $vs_char_set); } catch (Exception $e) { // Retry search with all non-alphanumeric characters removed try { $o_parsed_query = $o_query_parser->parse(preg_replace("![^A-Za-z0-9 ]+!", " ", $ps_search), $vs_char_set); } catch (Exception $e) { $o_parsed_query = $o_query_parser->parse("", $vs_char_set); } } $va_rewrite_results = $this->_rewriteQuery($o_parsed_query); $o_rewritten_query = new Zend_Search_Lucene_Search_Query_Boolean($va_rewrite_results['terms'], $va_rewrite_results['signs']); $vs_search = $this->_queryToString($o_rewritten_query); //print "<div style='background:#FFFFFF; padding: 5px; border: 1px dotted #666666;'><strong>DEBUG: </strong>".$ps_search.'/'.$vs_search."</div>"; // Filter deleted records out of final result if (isset($pa_options['deletedOnly']) && $pa_options['deletedOnly'] && $t_table->hasField('deleted')) { $this->addResultFilter($this->ops_tablename . '.deleted', '=', '1'); } else { if ((!isset($pa_options['showDeleted']) || !$pa_options['showDeleted']) && $t_table->hasField('deleted')) { $this->addResultFilter($this->ops_tablename . '.deleted', '=', '0'); } } if (isset($pa_options['checkAccess']) && (is_array($pa_options['checkAccess']) && sizeof($pa_options['checkAccess']))) { $va_access_values = $pa_options['checkAccess']; $this->addResultFilter($this->ops_tablename . '.access', 'IN', join(",", $va_access_values)); } $vb_no_types = false; if (is_array($va_type_ids = $this->getTypeRestrictionList()) && sizeof($va_type_ids) > 0) { if ($t_table->getFieldInfo('type_id', 'IS_NULL')) { $va_type_ids[] = 'NULL'; } $this->addResultFilter($this->ops_tablename . '.type_id', 'IN', join(",", $va_type_ids)); } elseif (is_array($va_type_ids) && sizeof($va_type_ids) == 0) { $vb_no_types = true; } if (!$vb_no_types) { // Filter on source if (is_array($va_source_ids = $this->getSourceRestrictionList())) { $this->addResultFilter($this->ops_tablename . '.source_id', 'IN', join(",", $va_source_ids)); } if (in_array($t_table->getHierarchyType(), array(__CA_HIER_TYPE_SIMPLE_MONO__, __CA_HIER_TYPE_MULTI_MONO__))) { $this->addResultFilter($this->ops_tablename . '.parent_id', 'IS NOT', NULL); } if (is_array($va_restrict_to_fields = caGetOption('restrictSearchToFields', $pa_options, null)) && $this->opo_engine->can('restrict_to_fields')) { $this->opo_engine->setOption('restrictSearchToFields', $va_restrict_to_fields); } $o_res = $this->opo_engine->search($this->opn_tablenum, $vs_search, $this->opa_result_filters, $o_rewritten_query); // cache the results $va_hits = $o_res->getPrimaryKeyValues($vn_limit); $o_res->seek(0); } else { $va_hits = array(); } if (isset($pa_options['sets']) && $pa_options['sets']) { $va_hits = $this->filterHitsBySets($va_hits, $pa_options['sets'], array('search' => $vs_search)); } $vn_user_id = isset($pa_options['user_id']) && (int) $pa_options['user_id'] ? (int) $pa_options['user_id'] : (int) $AUTH_CURRENT_USER_ID; if ((!isset($pa_options['dontFilterByACL']) || !$pa_options['dontFilterByACL']) && $this->opo_app_config->get('perform_item_level_access_checking') && method_exists($t_table, "supportsACL") && $t_table->supportsACL()) { $va_hits = $this->filterHitsByACL($va_hits, $this->opn_tablenum, $vn_user_id, __CA_ACL_READONLY_ACCESS__); } if ($vs_sort != '_natural') { $va_hits = $this->sortHits($va_hits, $t_table->tableName(), $pa_options['sort'], isset($pa_options['sort_direction']) ? $pa_options['sort_direction'] : null); } elseif ($vs_sort == '_natural' && $vs_sort_direction == 'desc') { $va_hits = array_reverse($va_hits); } $o_res = new WLPlugSearchEngineCachedResult($va_hits, $this->opn_tablenum); // cache for later use if (!$vb_no_cache) { $o_cache->save($vs_cache_key, $this->opn_tablenum, $va_hits, array('created_on' => time()), null, $pa_options); } // log search $o_log = new Searchlog(); $vn_search_form_id = isset($pa_options['form_id']) ? $pa_options['form_id'] : null; $vs_log_details = isset($pa_options['log_details']) ? $pa_options['log_details'] : ''; $vs_search_source = isset($pa_options['search_source']) ? $pa_options['search_source'] : ''; $vn_execution_time = $t->getTime(4); $o_log->log(array('user_id' => $vn_user_id, 'table_num' => $this->opn_tablenum, 'search_expression' => $ps_search, 'num_hits' => sizeof($va_hits), 'form_id' => $vn_search_form_id, 'ip_addr' => $_SERVER['REMOTE_ADDR'] ? $_SERVER['REMOTE_ADDR'] : null, 'details' => $vs_log_details, 'search_source' => $vs_search_source, 'execution_time' => $vn_execution_time)); } if ($po_result) { $po_result->init($o_res, $this->opa_tables, $pa_options); return $po_result; } else { return new SearchResult($o_res, $this->opa_tables); } }
function __construct($row) { parent::__construct($row); $this->score = $row->score; }
<section id="searchsection"> <div id="searchbody"> <?php $result = new SearchResult('Kilpisjärvi (Lappland)', 2); $result->show(); for ($i = 1; $i <= 5; $i++) { $result = new SearchResult('Favorisierte Wanderung ' . ($i + 1), rand(1, 3)); $result->show(); } ?> </div> </section>
} if (isset($definitions)) { $totalDefinitionsCount = count($definitions); if (!$all && $totalDefinitionsCount > PREVIEW_LIMIT) { $definitions = array_slice($definitions, 0, PREVIEW_LIMIT); SmartyWrap::assign('totalDefinitionsCount', $totalDefinitionsCount); } $searchResults = SearchResult::mapDefinitionArray($definitions); } } $conjugations = NULL; $declensions = NULL; if ($searchType == SEARCH_INFLECTED || $searchType == SEARCH_LEXEM_ID || $searchType == SEARCH_FULL_TEXT || $searchType == SEARCH_MULTIWORD) { // Filter out hidden definitions $hiddenSources = array(); SearchResult::filterHidden($searchResults, $hiddenSources); if (Config::get('global.aprilFoolsDay')) { foreach ($searchResults as $sr) { $sr->definition->htmlRep = StringUtil::iNoGrammer($sr->definition->htmlRep); } } SmartyWrap::assign('results', $searchResults); SmartyWrap::assign('hiddenSources', $hiddenSources); // Maps lexems to arrays of inflected forms (some lexems may lack inflections) // Also compute the text of the link to the paradigm div, // which can be 'conjugări', 'declinări' or both if (!empty($lexems)) { $conjugations = false; $declensions = false; foreach ($lexems as $l) { $lm = $l->getFirstLexemModel();
/** * Check user's item level access before passing delete to lower level libraries * */ public function delete($pb_delete_related = false, $pa_options = null, $pa_fields = null, $pa_table_list = null) { global $AUTH_CURRENT_USER_ID; if ($this->getAppConfig()->get('perform_item_level_access_checking')) { if ($this->checkACLAccessForUser(new ca_users($AUTH_CURRENT_USER_ID)) < __CA_ACL_EDIT_DELETE_ACCESS__) { $this->postError(2580, _t("You do not have delete access for this item"), "BundlableLabelableBaseModelWithAttributes->delete()"); return false; } } SearchResult::clearResultCacheForRow($this->tableName(), $this->getPrimaryKey()); return parent::delete($pb_delete_related, $pa_options, $pa_fields, $pa_table_list); }
<?php require_once "../../phplib/util.php"; util_assertModerator(PRIV_EDIT); util_assertNotMirror(); RecentLink::createOrUpdate('Greșeli de tipar'); $sourceClause = ''; $sourceId = 0; $sourceUrlName = util_getRequestParameter('source'); if ($sourceUrlName) { $source = $sourceUrlName ? Source::get_by_urlName($sourceUrlName) : null; $sourceId = $source ? $source->id : 0; $sourceClause = $source ? "sourceId = {$sourceId} and " : ''; SmartyWrap::assign('src_selected', $sourceId); } $defs = Model::factory('Definition')->raw_query("select * from Definition where {$sourceClause} id in (select definitionId from Typo) order by lexicon")->find_many(); SmartyWrap::assign('searchResults', SearchResult::mapDefinitionArray($defs)); SmartyWrap::assign('recentLinks', RecentLink::loadForUser()); SmartyWrap::displayAdminPage('admin/viewTypos.tpl');
$MAX_AFFECTED = 1000; $search = util_getRequestParameter('search'); $replace = util_getRequestParameter('replace'); $sourceId = util_getRequestParameter('source'); $realRun = util_getRequestParameter('realRun'); $sourceClause = $sourceId ? "and sourceId = {$sourceId}" : ''; $count = Model::factory('Definition')->where_raw("status = 0 {$sourceClause} and binary internalRep like '%{$search}%'")->count(); if ($count > $MAX_AFFECTED) { if ($realRun) { FlashMessage::add("{$count} definiții se potrivesc, numai {$MAX_AFFECTED} au fost modificate.", 'info'); } else { FlashMessage::add("{$count} definiții se potrivesc, maxim {$MAX_AFFECTED} vor fi modificate."); } } $defs = Model::factory('Definition')->where_raw("status = 0 {$sourceClause} and binary internalRep like '%{$search}%'")->order_by_asc('id')->limit($MAX_AFFECTED)->find_many(); $searchResults = SearchResult::mapDefinitionArray($defs); foreach ($defs as $def) { $def->internalRep = str_replace($search, $replace, $def->internalRep); $ambiguousMatches = array(); $def->internalRep = AdminStringUtil::internalizeDefinition($def->internalRep, $def->sourceId, $ambiguousMatches); $def->htmlRep = AdminStringUtil::htmlize($def->internalRep, $def->sourceId); // Complete or un-complete the abbreviation review if (!count($ambiguousMatches) && $def->abbrevReview == ABBREV_AMBIGUOUS) { $def->abbrevReview = ABBREV_REVIEW_COMPLETE; } else { if (count($ambiguousMatches) && $def->abbrevReview == ABBREV_REVIEW_COMPLETE) { $def->abbrevReview = ABBREV_AMBIGUOUS; } } if ($realRun) { $def->save();
$lm->regenerateParadigm(); } } } } } util_redirect("placeAccents.php"); } $chars = array(); $searchResults = array(); $lexems = Model::factory('Lexem')->raw_query("select * from Lexem where form not rlike '\\'' and not noAccent order by rand() limit 10")->find_many(); foreach ($lexems as $l) { $charArray = array(); $form = mb_strtoupper($l->form); $len = mb_strlen($form); for ($i = 0; $i < $len; $i++) { $c = StringUtil::getCharAt($form, $i); $charArray[] = ctype_space($c) ? ' ' : $c; } $chars[$l->id] = $charArray; $definitions = Definition::loadByLexemId($l->id); $searchResults[$l->id] = SearchResult::mapDefinitionArray($definitions); } RecentLink::createOrUpdate('Plasare accente'); SmartyWrap::assign('sectionTitle', 'Plasare accente'); SmartyWrap::assign('lexems', $lexems); SmartyWrap::assign('chars', $chars); SmartyWrap::assign('searchResults', $searchResults); SmartyWrap::assign("allStatuses", util_getAllStatuses()); SmartyWrap::assign('recentLinks', RecentLink::loadForUser()); SmartyWrap::displayAdminPage('admin/placeAccents.ihtml');
/** * Format a single hit result * @param SearchResult $result * @param string $terms partial regexp for highlighting terms */ function showHit($result, $terms) { $fname = 'SpecialSearch::showHit'; wfProfileIn($fname); global $wgUser, $wgContLang; $t = $result->getTitle(); if (is_null($t)) { wfProfileOut($fname); return "<!-- Broken link in search result -->\n"; } $sk =& $wgUser->getSkin(); $contextlines = $wgUser->getOption('contextlines'); if ('' == $contextlines) { $contextlines = 5; } $contextchars = $wgUser->getOption('contextchars'); if ('' == $contextchars) { $contextchars = 50; } $link = $sk->makeKnownLinkObj($t); $revision = Revision::newFromTitle($t); $text = $revision->getText(); $size = wfMsg('nbytes', strlen($text)); $lines = explode("\n", $text); $max = IntVal($contextchars) + 1; $pat1 = "/(.*)({$terms})(.{0,{$max}})/i"; $lineno = 0; $extract = ''; wfProfileIn("{$fname}-extract"); foreach ($lines as $line) { if (0 == $contextlines) { break; } ++$lineno; if (!preg_match($pat1, $line, $m)) { continue; } --$contextlines; $pre = $wgContLang->truncate($m[1], -$contextchars, '...'); if (count($m) < 3) { $post = ''; } else { $post = $wgContLang->truncate($m[3], $contextchars, '...'); } $found = $m[2]; $line = htmlspecialchars($pre . $found . $post); $pat2 = '/(' . $terms . ")/i"; $line = preg_replace($pat2, "<span class='searchmatch'>\\1</span>", $line); $extract .= "<br /><small>{$lineno}: {$line}</small>\n"; } wfProfileOut("{$fname}-extract"); wfProfileOut($fname); return "<li>{$link} ({$size}){$extract}</li>\n"; }
/** * Export set of records from a given SearchResult object to an array of strings with the individual exports, keyed by primary key. * The behavior is tailored towards the needs of the OAIPMHService. * * @param string $ps_exporter_code defines the exporter to use * @param SearchResult $po_result search result as object * @param array $pa_options * 'start' = * 'limit' = * @return array exported data */ public static function exportRecordsFromSearchResultToArray($ps_exporter_code, $po_result, $pa_options = null) { $vn_start = isset($pa_options['start']) ? (int) $pa_options['start'] : 0; $vn_limit = isset($pa_options['limit']) ? (int) $pa_options['limit'] : 0; ca_data_exporters::$s_exporter_cache = array(); ca_data_exporters::$s_exporter_item_cache = array(); require_once __CA_LIB_DIR__ . '/core/Search/SearchResult.php'; if (!$po_result instanceof SearchResult) { return false; } if (!($t_mapping = ca_data_exporters::loadExporterByCode($ps_exporter_code))) { return false; } if (sizeof(ca_data_exporters::checkMapping($ps_exporter_code)) > 0) { return false; } $t_instance = $t_mapping->getAppDatamodel()->getInstanceByTableNum($t_mapping->get('table_num')); if ($vn_start > 0 && $vn_start < $po_result->numHits()) { $po_result->seek($vn_start); } $va_return = array(); $vn_i = 0; while ($po_result->nextHit()) { if ($vn_limit && $vn_i >= $vn_limit) { break; } $vn_pk_val = $po_result->get($t_instance->primaryKey()); $va_return[$vn_pk_val] = ca_data_exporters::exportRecord($ps_exporter_code, $vn_pk_val); $vn_i++; } return $va_return; }
/** * @brief 搜索订阅医生 * @author lhl * @exampleUrl http://dev.mobile-api.haodf.com/patientapi/subscription_searchdoctor?keyword=吴鸣&pageId=1&pageSize=15&userId=581662815 * * @param $keyword 搜索字段 * @Param $pageId 当前页码 * @Param $pageSize 每页显示数 * * @return array('doctorid', 'name', 'fullGrade', 'hospitalName', 'hospitalFacultyName', 'goodVoteCount', 'specialize', 'logoUrl') */ public function searchDoctor($userId, $keyword, $pageId = 1, $pageSize = 15) {/*{{{*/ if($userId != $this->currentUserId) { $this->setErrorCode(309); return 0; } if('' == trim($keyword)) { $this->setErrorCode(450); return 0; } $doctorSearchd = SphinxSearchdBase::createSearchdByType('Doctor'); $utf8Kw = mb_convert_encoding($keyword, 'utf-8', 'gbk'); $res = $doctorSearchd->query($utf8Kw, (int)(($pageId - 1 ) * $pageSize), (int)($pageSize)); $searchResult = SearchResult::sphinxResult2searchResult($res, 'doctor', (int)(($pageId - 1 ) * $pageSize), (int)($pageSize)); $myDoctorList = SubscriptionClient::getInstance()->getMyDoctors($userId); $subscriptionDoctor = array(); foreach($myDoctorList as $myDoctor) { $subscriptionDoctor[$myDoctor->doctor->id] = $myDoctor->id; } $results = array(); foreach($searchResult->items as $item) { $doctor = DAL::get()->find('doctor',$item->id); if(false == $doctor->isNull() && $doctor->deleted == 0) { $result = $allHospitalFacultyNames = array(); $result['doctorid'] = $doctor->id; $result['name'] = $doctor->name; $result['fullGrade'] = implode(" ",array($doctor->grade,$doctor->educateGrade)); $primaryDoctors = DAL::get()->find_all_byPrimaryIds('Doctor', array($doctor->primaryId)); foreach ($primaryDoctors as $primaryDoctor) { $allHospitalFacultyNames[] = $primaryDoctor->hospitalfaculty->hospital->commonName.' '.$primaryDoctor->hospitalfaculty->name; } $result['hospitalName'] = implode("\n", $allHospitalFacultyNames); $result['hospitalFacultyName'] = ''; $result['goodVoteCount'] = $doctor->goodVoteCount; $result['specialize'] = $doctor->specialize; $result['logoUrl'] = $doctor->getHeadImageForMobile(); $result['mydoctorid'] = ''; if(isset($subscriptionDoctor[$doctor->id])) { $result['mydoctorid'] = $subscriptionDoctor[$doctor->id]; } $results[] = $result; } } $this->content = $results; $this->pageInfo = array('pages' => ceil($searchResult->total_found / $searchResult->pageSize), 'pagesize' => $pageSize, 'nowpage' => $pageId, 'total' => $searchResult->total_found); }/*}}}*/
/** * */ public function buildSearchTable() { self::put('Zoekresultaten maken'); // Personen $aPersons = Person::getAll(); $personCount = 0; $deletePersonCount = 0; foreach ($aPersons as $oPerson) { $query = "SELECT DISTINCT(Team.competition_nefub_id), Competition.id\n\t\t\t\t\t\tFROM TeamPerson\n\t\t\t\t\t\tLEFT JOIN Team ON Team.nefub_id = TeamPerson.team_nefub_id\n\t\t\t\t\t\tLEFT JOIN Competition ON Team.competition_nefub_id = Competition.nefub_id\n\t\t\t\t\t\tWHERE TeamPerson.person_nefub_id = '" . $oPerson->nefub_id . "'\n\t\t\t\t\t\tAND Competition.season_nefub_id = '" . Season::getInstance()->nefub_id . "'\n\t\t\t\t\t\tORDER BY Team.competition_nefub_id ASC"; $aCompetitions = Competition::getAllFromQuery($query); $personCompetitions = array(); foreach ($aCompetitions as $oCompetition) { if (trim($oCompetition->name)) { $personCompetitions[] = $oCompetition->name; } } if (count($personCompetitions)) { $oSearchResult = SearchResult::selectByNefubId($oPerson->nefub_id, 'person'); if (!$oSearchResult) { $oSearchResult = new SearchResult(); $oSearchResult->nefub_id = $oPerson->nefub_id; $oSearchResult->type = 'person'; $oSearchResult->url = '/persoon/' . $oPerson->nefub_id; $personCount++; } $oSearchResult->name = $oPerson->name; $oSearchResult->subtitle = implode(', ', $personCompetitions); $oSearchResult->save(); } else { $deletePersonCount += Database::delete_rows('SearchResult', array('nefub_id' => $oPerson->nefub_id, 'type' => 'person')); } } self::put($deletePersonCount . ' perso(o)n(en) verwijderd van zoekresultatenlijst'); self::put($personCount . ' perso(o)n(en) toegevoegd aan zoekresultatenlijst'); // Teams $aTeams = Team::getAll(); $teamCount = 0; $deleteTeamCount = 0; foreach ($aTeams as $oTeam) { if ($oTeam->getCompetition() && $oTeam->season_nefub_id == Season::getInstance()->nefub_id) { $oSearchResult = SearchResult::selectByNefubId($oTeam->nefub_id, 'team'); if (!$oSearchResult) { $oSearchResult = new SearchResult(); $oSearchResult->nefub_id = $oTeam->nefub_id; $oSearchResult->name = $oTeam->name; $oSearchResult->type = 'team'; $oSearchResult->url = '/team/' . $oTeam->nefub_id; $teamCount++; } $oSearchResult->subtitle = $oTeam->getCompetition()->name; $oSearchResult->save(); } else { $deleteTeamCount += Database::delete_rows('SearchResult', array('nefub_id' => $oTeam->nefub_id, 'type' => 'team')); } } self::put($deleteTeamCount . ' team(s) verwijderd van zoekresultatenlijst'); self::put($teamCount . ' team(s) toegevoegd aan zoekresultatenlijst'); }
public function seek($pn_index) { if ($this->ops_filter_field) { parent::seek(0); for ($vn_i = 0; $vn_i < $pn_index; $vn_i++) { $this->nextHit(); } return true; } else { return parent::seek($pn_index); } }
/** * Show single interwiki link * * @param SearchResult $result * @param string $lastInterwiki * @param string $query * @param array $customCaptions Interwiki prefix -> caption * * @return string */ protected function showInterwikiHit($result, $lastInterwiki, $query, $customCaptions) { if ($result->isBrokenTitle()) { return ''; } $title = $result->getTitle(); $titleSnippet = $result->getTitleSnippet(); if ($titleSnippet == '') { $titleSnippet = null; } $link = Linker::linkKnown($title, $titleSnippet); // format redirect if any $redirectTitle = $result->getRedirectTitle(); $redirectText = $result->getRedirectSnippet(); $redirect = ''; if (!is_null($redirectTitle)) { if ($redirectText == '') { $redirectText = null; } $redirect = "<span class='searchalttitle'>" . $this->msg('search-redirect')->rawParams(Linker::linkKnown($redirectTitle, $redirectText))->text() . "</span>"; } $out = ""; // display project name if (is_null($lastInterwiki) || $lastInterwiki != $title->getInterwiki()) { if (array_key_exists($title->getInterwiki(), $customCaptions)) { // captions from 'search-interwiki-custom' $caption = $customCaptions[$title->getInterwiki()]; } else { // default is to show the hostname of the other wiki which might suck // if there are many wikis on one hostname $parsed = wfParseUrl($title->getFullURL()); $caption = $this->msg('search-interwiki-default', $parsed['host'])->text(); } // "more results" link (special page stuff could be localized, but we might not know target lang) $searchTitle = Title::newFromText($title->getInterwiki() . ":Special:Search"); $searchLink = Linker::linkKnown($searchTitle, $this->msg('search-interwiki-more')->text(), array(), array('search' => $query, 'fulltext' => 'Search')); $out .= "</ul><div class='mw-search-interwiki-project'><span class='mw-search-interwiki-more'>\n\t\t\t\t{$searchLink}</span>{$caption}</div>\n<ul>"; } $out .= "<li>{$link} {$redirect}</li>\n"; return $out; }
/** * Returns extra data for specific result and store it in SearchResult object. * @param SearchResult $result * @return array|null List of data as name => value or null if none present. */ public function augmentResult(SearchResult $result) { $id = $result->getTitle()->getArticleID(); if (!$id || !isset($this->extraData[$id])) { return null; } $result->setExtensionData($this->extraData[$id]); return $this->extraData[$id]; }
function doSearch($keyword) { $results = SearchResult::search($keyword); $return = array('results' => $results); return $return; }
/** * Show single interwiki link * * @param SearchResult $result * @param string $lastInterwiki * @param array $terms * @param string $query * @param array $customCaptions iw prefix -> caption */ protected function showInterwikiHit($result, $lastInterwiki, $terms, $query, $customCaptions) { wfProfileIn(__METHOD__); global $wgContLang, $wgLang; if ($result->isBrokenTitle()) { wfProfileOut(__METHOD__); return "<!-- Broken link in search result -->\n"; } $t = $result->getTitle(); $titleSnippet = $result->getTitleSnippet($terms); if ($titleSnippet == '') { $titleSnippet = null; } $link = $this->sk->linkKnown($t, $titleSnippet); // format redirect if any $redirectTitle = $result->getRedirectTitle(); $redirectText = $result->getRedirectSnippet($terms); $redirect = ''; if (!is_null($redirectTitle)) { if ($redirectText == '') { $redirectText = null; } $redirect = "<span class='searchalttitle'>" . wfMsg('search-redirect', $this->sk->linkKnown($redirectTitle, $redirectText)) . "</span>"; } $out = ""; // display project name if (is_null($lastInterwiki) || $lastInterwiki != $t->getInterwiki()) { if (key_exists($t->getInterwiki(), $customCaptions)) { // captions from 'search-interwiki-custom' $caption = $customCaptions[$t->getInterwiki()]; } else { // default is to show the hostname of the other wiki which might suck // if there are many wikis on one hostname $parsed = parse_url($t->getFullURL()); $caption = wfMsg('search-interwiki-default', $parsed['host']); } // "more results" link (special page stuff could be localized, but we might not know target lang) $searchTitle = Title::newFromText($t->getInterwiki() . ":Special:Search"); $searchLink = $this->sk->linkKnown($searchTitle, wfMsg('search-interwiki-more'), array(), array('search' => $query, 'fulltext' => 'Search')); $out .= "</ul><div class='mw-search-interwiki-project'><span class='mw-search-interwiki-more'>\n\t\t\t\t{$searchLink}</span>{$caption}</div>\n<ul>"; } $out .= "<li>{$link} {$redirect}</li>\n"; wfProfileOut(__METHOD__); return $out; }
public function findByAlamat() { if ($this->before != null and $this->after == null) { $sql = "SELECT id_lamp as id, tanggal as tgl, nomor as nomor, hal as hal, asal as alamat, file as file, 'lampiran' as tipe FROM lampiran WHERE asal LIKE '%{$this->keyword}%' AND tanggal>='" . $this->before . "'"; $sql .= " UNION "; $sql .= "SELECT a.id_suratmasuk as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_masuk' as tipe FROM suratmasuk a LEFT JOIN alamat b ON a.asal_surat = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%' AND a.tgl_surat>='" . $this->before . "'"; $sql .= " UNION "; $sql .= "SELECT a.id_suratkeluar as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_keluar' as tipe FROM suratkeluar a LEFT JOIN alamat b ON a.tujuan = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%' AND a.tgl_surat>='" . $this->before . "'"; } elseif ($this->before == null and $this->after != null) { $sql = "SELECT id_lamp as id, tanggal as tgl, nomor as nomor, hal as hal, asal as alamat, file as file, 'lampiran' as tipe FROM lampiran WHERE asal LIKE '%{$this->keyword}%' AND tanggal<='" . $this->after . "'"; $sql .= " UNION "; $sql .= "SELECT a.id_suratmasuk as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_masuk' as tipe FROM suratmasuk a LEFT JOIN alamat b ON a.asal_surat = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%' AND a.tgl_surat<='" . $this->after . "'"; $sql .= " UNION "; $sql .= "SELECT a.id_suratkeluar as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_keluar' as tipe FROM suratkeluar a LEFT JOIN alamat b ON a.tujuan = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%' AND a.tgl_surat<='" . $this->after . "'"; } elseif ($this->before != null and $this->after != null) { $sql = "SELECT id_lamp as id, tanggal as tgl, nomor as nomor, hal as hal, asal as alamat, file as file, 'lampiran' as tipe FROM lampiran WHERE asal LIKE '%{$this->keyword}%' AND tanggal>='" . $this->before . "' AND tanggal<='" . $this->after . "'"; $sql .= " UNION "; $sql .= "SELECT a.id_suratmasuk as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_masuk' as tipe FROM suratmasuk a LEFT JOIN alamat b ON a.asal_surat = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%' AND a.tgl_surat>='" . $this->before . "' AND a.tgl_surat<='" . $this->after . "'"; $sql .= " UNION "; $sql .= "SELECT a.id_suratkeluar as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_keluar' as tipe FROM suratkeluar a LEFT JOIN alamat b ON a.tujuan = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%' AND a.tgl_surat>='" . $this->before . "' AND a.tgl_surat<='" . $this->after . "'"; } else { $sql = "SELECT id_lamp as id, tanggal as tgl, nomor as nomor, hal as hal, asal as alamat, file as file, 'lampiran' as tipe FROM lampiran WHERE asal LIKE '%{$this->keyword}%'"; $sql .= " UNION "; $sql .= "SELECT a.id_suratmasuk as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_masuk' as tipe FROM suratmasuk a LEFT JOIN alamat b ON a.asal_surat = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%'"; $sql .= " UNION "; $sql .= "SELECT a.id_suratkeluar as id, a.tgl_surat as tgl, a.no_surat as nomor, a.perihal as hal, b.nama_satker as alamat, a.file as file, 'surat_keluar' as tipe FROM suratkeluar a LEFT JOIN alamat b ON a.tujuan = b.kode_satker WHERE b.nama_satker LIKE '%{$this->keyword}%'"; } $sql .= " ORDER BY tgl DESC"; // var_dump($sql); $data = $this->select($sql); $result = array(); foreach ($data as $val) { $cari = new SearchResult(); $cari->setId($val['id']); $cari->setTanggal($val['tgl']); $cari->setNomor($val['nomor']); $cari->setPerihal($val['hal']); $cari->setTipe($val['tipe']); $cari->setFile($val['file']); $result[] = $cari; } return $result; }
$os = "-"; $unix = 1; } else { if (@eregi("^win", $os)) { $windows = 1; } else { $unix = 1; } } } if (!empty($_POST['s_dir']) && !empty($_POST['s_text']) && !empty($_POST['cmd']) && $_POST['cmd'] == "search_text") { echo $head; if (!empty($_POST['s_mask']) && !empty($_POST['m'])) { $sr = new SearchResult($_POST['s_dir'], $_POST['s_text'], $_POST['s_mask']); } else { $sr = new SearchResult($_POST['s_dir'], $_POST['s_text']); } $sr->SearchText(0, 0); $res = $sr->GetResultFiles(); $found = $sr->GetMatchesCount(); $titles = $sr->GetTitles(); $r = ""; if ($found > 0) { $r .= "<TABLE width=100%>"; foreach ($res as $file => $v) { $r .= "<TR>"; $r .= "<TD colspan=2><font face=Verdana size=-2><b>" . ws(3); $r .= $windows ? str_replace("/", "\\", $file) : $file; $r .= "</b></font></ TD>"; $r .= "</TR>"; foreach ($v as $a => $b) {
/** * */ public static function clearGetWithTemplatePrefetch() { self::$s_template_prefetch_cache = array(); }
/** * Determines if there is any data in the data set that can be visualized by this plugin using the provided settings * * @param SearchResult $po_data * @param array $pa_viz_settings Visualization settings * * @return bool True if data can be visualized */ public function canHandle($po_data, $pa_viz_settings) { $vn_cur_pos = $po_data->currentIndex(); if ($vn_cur_pos < 0) { $vn_cur_pos = 0; } $po_data->seek(0); $o_dm = Datamodel::load(); // // Make sure sources actually exist // $va_sources = $pa_viz_settings['sources']; foreach ($va_sources as $vs_source_code => $va_source_info) { $va_tmp = explode('.', $va_source_info['data']); $t_instance = $o_dm->getInstanceByTableName($va_tmp[0], true); if (!($t_instance = $o_dm->getInstanceByTableName($va_tmp[0], true))) { unset($va_sources[$vs_source_code]); continue; } if (!$t_instance->hasField($va_tmp[1]) && !$t_instance->hasElement($va_tmp[1])) { unset($va_sources[$vs_source_code]); } } $vn_c = 0; // // Only check the first 10,000 returned rows before giving up, to avoid timeouts // while ($po_data->nextHit() && $vn_c < 10000) { foreach ($va_sources as $vs_source_code => $va_source_info) { if (trim($po_data->get($va_source_info['data']))) { $po_data->seek($vn_cur_pos); return true; } } $vn_c++; } $po_data->seek($vn_cur_pos); return false; }
/** * */ private static function _evaluateCodeAttribute(SearchResult $pr_res, $po_node, array $pa_options = null) { if (!($va_codes = DisplayTemplateParser::_getCodesFromAttribute($po_node, ['includeBooleans' => true]))) { return []; } $pb_include_blanks = caGetOption('includeBlankValuesInArray', $pa_options, false); $ps_delimiter = caGetOption('delimiter', $pa_options, ';'); $pb_mode = caGetOption('mode', $pa_options, 'present'); // value 'present' or 'not_present' $pn_index = caGetOption('index', $pa_options, null); $vb_has_value = null; foreach ($va_codes as $vs_code => $vs_bool) { $va_val_list = $pr_res->get($vs_code, ['returnAsArray' => true, 'returnBlankValues' => true, 'convertCodesToDisplayText' => true, 'returnAsDecimal' => true, 'getDirectDate' => true]); if (!is_array($va_val_list)) { // no value $vb_value_present = false; } else { if (!is_null($pn_index)) { if (!isset($va_val_list[$pn_index]) || (is_numeric($va_val_list[$pn_index]) && (double) $va_val_list[$pn_index] == 0 || !strlen(trim($va_val_list[$pn_index])))) { $vb_value_present = false; // no value } else { $va_val_list = array($va_val_list[$pn_index]); if (!$pb_include_blanks) { $va_val_list = array_filter($va_val_list); } $vb_value_present = (bool) sizeof($va_val_list); } } else { if (!$pb_include_blanks) { foreach ($va_val_list as $vn_i => $vm_val) { if (is_numeric($vm_val) && (double) $vm_val == 0 || !strlen(trim($vm_val))) { unset($va_val_list[$vn_i]); } } } $vb_value_present = (bool) sizeof($va_val_list); } } if ($pb_mode !== 'present') { $vb_value_present = !$vb_value_present; } if (is_null($vb_has_value)) { $vb_has_value = $vb_value_present; } $vb_has_value = $vs_bool == 'OR' ? $vb_has_value || $vb_value_present : $vb_has_value && $vb_value_present; } return $vb_has_value; }