public function searchAction() { if ($_GET['type'] == 'name') { return $this->redirect('/name/' . urlencode($_GET['q'])); } if ($_GET['type'] == 'fund') { return $this->redirect('/fund/' . urlencode($_GET['q'])); } if (preg_match('#\\d{8}#', $_GET['q'])) { return $this->redirect('/id/' . $_GET['q']); } $page = intval($_GET['page']) ?: 1; if (preg_match('#^address:(.*)$#', $_GET['q'], $matches)) { $ret = SearchLib::searchCompaniesByAddress($matches[1], $page); } else { $ret = SearchLib::searchCompaniesByName($_GET['q'], $page); } if ($ret->hits->total == 1) { return $this->redirect('/id/' . urlencode($ret->hits->hits[0]->_id)); } $this->view->page = $page; $this->view->max_page = ceil($ret->hits->total / 10); $this->view->search_word = $_GET['q']; $this->view->search_result = $ret; }
public function nameAction() { $page = intval($_GET['page']) ?: 1; $search_ret = SearchLib::searchCompaniesByPerson($_GET['q'], $page); $ret = new StdClass(); $data = array(); foreach ($search_ret->hits->hits as $hit) { $hit->_source->{'統一編號'} = $hit->_id; $data[] = $hit->_source; } $ret->data = $data; $ret->found = $search_ret->hits->total; return $this->jsonp($ret, strval($_GET['callback'])); }
<?php include __DIR__ . '/../init.inc.php'; $fp = fopen(__DIR__ . '/../maps/rare-word.csv', 'r'); $words = array(); while ($rows = fgetcsv($fp)) { list($old, $new) = $rows; $words[$old] = $new; for ($i = 0; true; $i++) { $ret = SearchLib::searchCompaniesByName($old, $i + 1); foreach ($ret->hits->hits as $hit) { Unit::find($hit->_id)->updateSearch(); } $total = $ret->hits->total; if ($i * 10 >= $total) { break; } } } fclose($fp);
<?php /** * $Header$ * @copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. * All Rights Reserved. See below for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details. * * @package search */ /** * Initialization */ require_once '../kernel/setup_inc.php'; require_once SEARCH_PKG_PATH . '/search_lib.php'; $searchlib = new SearchLib(); $gBitSystem->verifyPackage('search'); // contentType list created in mod_package_search.php at present // but this is left in case a different search option is used if (empty($contentTypes)) { $contentTypes = array('' => tra('All Content')); foreach ($gLibertySystem->mContentTypes as $cType) { $contentTypes[$cType['content_type_guid']] = $gLibertySystem->getContentTypeName($cType['content_type_guid']); } } asort($contentTypes); $gBitSmarty->assign('contentTypes', $contentTypes); if (!empty($_REQUEST["highlight"])) { $_REQUEST["words"] = $_REQUEST["highlight"]; } else { // a nice big, groovy search will be cool to have one day...
'date' => 'digits', 'maxRecords' => 'digits', 'highlight' => 'xss', 'where' => 'word', 'find' => 'xss', 'words' =>'xss', 'boolean' =>'word', ) ) ); $section = 'search'; require_once ('tiki-setup.php'); require_once ('lib/search/searchlib-mysql.php'); $auto_query_args = array('highlight', 'where', 'initial', 'maxRecords', 'sort_mode', 'find', 'searchLang', 'words', 'boolean', 'categId' ); $searchlib = new SearchLib; $access->check_feature('feature_search_fulltext'); $access->check_permission('tiki_p_search'); if (!empty($_REQUEST["highlight"])) { $_REQUEST["words"] = $_REQUEST["highlight"]; } else if (!empty($_REQUEST['find'])) { $_REQUEST['words'] = $_REQUEST['find']; } if ($prefs['feature_search_stats'] == 'y') { $searchlib->register_search(isset($_REQUEST["words"]) ? $_REQUEST["words"] : ''); } if (empty($_REQUEST["where"])) { $where = 'pages'; } else { $where = $_REQUEST["where"];
<?php /** * $Header$ * * Copyright (c) 2004 bitweaver.org * Copyright (c) 2003 tikwiki.org * Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. * All Rights Reserved. See below for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details * * $Id$ * @author Luis Argerich (lrargerich@yahoo.com) * @package search * @subpackage modules */ /** * Initialization */ global $gLibertySystem; require_once SEARCH_PKG_PATH . "search_lib.php"; if (empty($contentTypes)) { $contentTypes = array('' => tra('All Content')); foreach ($gLibertySystem->mContentTypes as $cType) { if (SearchLib::has_permission($cType["content_type_guid"]) and !$gBitSystem->getConfig('search_restrict_types') || $gBitSystem->getConfig('search_pkg_' . $cType["content_type_guid"])) { $contentTypes[$cType['content_type_guid']] = $gLibertySystem->getContentTypeName($cType['content_type_guid']); } } } $_template->tpl_vars['contentTypes'] = new Smarty_variable($contentTypes);