本文整理汇总了PHP中search::find方法的典型用法代码示例。如果您正苦于以下问题:PHP search::find方法的具体用法?PHP search::find怎么用?PHP search::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类search
的用法示例。
在下文中一共展示了search::find方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find
<?php
require_once './vendor/autoload.php';
use Symfony\Component\Finder\Finder;
$searcher = new search();
echo $searcher->find();
// --------
class Search
{
private $results = array();
private $titles = array();
private $items = array();
public function find()
{
// Set $q
if (isset($_GET['q'])) {
$q = $_GET['q'];
} else {
$q = "";
}
// Split on words.
$q = preg_split("/(?<=\\w)\\b\\s*/", $q);
foreach ($q as $atom) {
$this->searchWord($atom);
}
arsort($this->results);
// \Dumper::dump($this->results);
foreach ($this->results as $page => $score) {
$this->items[] = array('id' => $page, 'text' => $this->titles[$page]);
}
return json_encode(array("items" => $this->items));
示例2: delete
/**
* delete item in module
*/
function delete()
{
$modelname = $this->basemodel_name;
if (empty($this->params['id'])) {
flash('error', gt('Missing id for the') . ' ' . $modelname . ' ' . gt('you would like to delete'));
expHistory::back();
}
$obj = new $modelname($this->params['id']);
$rows = $obj->delete();
// if this module is searchable lets delete spidered content
if ($this->isSearchable()) {
$search = new search();
$content = $search->find('first', 'original_id=' . $this->params['id'] . " AND ref_module='" . $this->classname . "'");
if (!empty($content->id)) {
$content->delete();
}
}
expHistory::back();
}
示例3: header
<?php
if (!defined('PROPER_START')) {
header("HTTP/1.0 403 Forbidden");
exit;
}
require_once 'on/doc/menu.php';
if ($_GET['keyword']) {
$search = new search(__DIR__);
$results = $search->find($_GET['keyword']);
}
$content = "\n\t\t<div class=\"head-light\">\n\t\t\t<div class=\"container\">\n\t\t\t\t<h1 class=\"dark\" style=\"float: left;\">{$lang['title']}</h1>\n\t\t\t\t<form id=\"searchform\" action=\"/doc/search\" method=\"get\"><input type=\"submit\" style=\"display: none;\" /><input name=\"keyword\" class=\"auto\" style=\"width: 380px; font-size: 15px; float: right;\" type=\"text\" id=\"search\" value=\"{$GLOBALS['lang']['search']}\" onfocus=\"this.value = this.value=='{$GLOBALS['lang']['search']}' ? '' : this.value; this.style.color='#4c4c4c';\" onfocusout=\"this.value = this.value == '' ? this.value = '{$GLOBALS['lang']['search']}' : this.value; this.value=='{$GLOBALS['lang']['search']}' ? this.style.color='#cccccc' : this.style.color='#4c4c4c'\" /></form>\n\t\t\t\t<div class=\"clear\"></div>\n\t\t\t</div>\n\t\t</div>\t\n\t\t<div class=\"content\">\t\t\n\t\t\t<div class=\"left small\">\n\t\t\t\t<div class=\"sidemenu\">\n\t\t\t\t\t{$menu}\n\t\t\t\t</div>\t\t\t\t\t\n\t\t\t</div>\n\t\t\t<div class=\"right big\">\t\n\t\t\t\t<h3>{$lang['result']} \"" . security::encode($_GET['keyword']) . "\"</h3>\n\t\t\t\t<br />\n\t\t\t\t\n";
if (count($results) > 0) {
$content .= "<ul class=\"search\">";
foreach ($results as $key => $value) {
$content .= "\n\t\t\t\t\t<li>\n\t\t\t\t\t\t<h2 class=\"dark\" style=\"margin-bottom: 5px;\">{$value['title']}</h2>\n\t\t\t\t\t\t<a href=\"/doc/{$key}\">https://www.olympe.in/doc/{$key}</a><br />\n\t\t\t\t\t\t<p>{$value['content']}</p>\n\t\t\t\t\t</li>\n\t\t";
}
$content .= "</ul>";
} else {
$content .= "<span style=\"font-size: 16px;\">{$lang['noresult']}</span>";
}
$content .= "\n\t\t\t</div>\n\t\t\t<div class=\"clear\">/div><br /><br />\n\t\t</div>\n";
/* ========================== OUTPUT PAGE ========================== */
$template->output($content);