本文整理汇总了PHP中ft_snippet函数的典型用法代码示例。如果您正苦于以下问题:PHP ft_snippet函数的具体用法?PHP ft_snippet怎么用?PHP ft_snippet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ft_snippet函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: html_search
/**
* Run a search and display the result
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_search()
{
global $conf;
global $QUERY;
global $ID;
global $lang;
$intro = p_locale_xhtml('searchpage');
// allow use of placeholder in search intro
$intro = str_replace(array('@QUERY@', '@SEARCH@'), array(hsc(rawurlencode($QUERY)), hsc($QUERY)), $intro);
echo $intro;
flush();
//show progressbar
print '<div class="centeralign" id="dw__loading">' . NL;
print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--' . NL;
print 'showLoadBar();' . NL;
print '//--><!]]></script>' . NL;
print '<br /></div>' . NL;
flush();
//do quick pagesearch
$data = array();
$data = ft_pageLookup($QUERY, true, useHeading('navigation'));
if (count($data)) {
print '<div class="search_quickresult">';
print '<h3>' . $lang['quickhits'] . ':</h3>';
print '<ul class="search_quickhits">';
foreach ($data as $id => $title) {
print '<li> ';
if (useHeading('navigation')) {
$name = $title;
} else {
$ns = getNS($id);
if ($ns) {
$name = shorten(noNS($id), ' (' . $ns . ')', 30);
} else {
$name = $id;
}
}
print html_wikilink(':' . $id, $name);
print '</li> ';
}
print '</ul> ';
//clear float (see http://www.complexspiral.com/publications/containing-floats/)
print '<div class="clearer"></div>';
print '</div>';
}
flush();
//do fulltext search
$data = ft_pageSearch($QUERY, $regex);
if (count($data)) {
$num = 1;
foreach ($data as $id => $cnt) {
print '<div class="search_result">';
print html_wikilink(':' . $id, useHeading('navigation') ? null : $id, $regex);
if ($cnt !== 0) {
print ': <span class="search_cnt">' . $cnt . ' ' . $lang['hits'] . '</span><br />';
if ($num < FT_SNIPPET_NUMBER) {
// create snippets for the first number of matches only
print '<div class="search_snippet">' . ft_snippet($id, $regex) . '</div>';
}
$num++;
}
print '</div>';
flush();
}
} else {
print '<div class="nothing">' . $lang['nothingfound'] . '</div>';
}
//hide progressbar
print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--' . NL;
print 'hideLoadBar("dw__loading");' . NL;
print '//--><!]]></script>' . NL;
flush();
}
示例2: search
/**
* List all pages in the given namespace (and below)
*/
function search($query)
{
require_once DOKU_INC . 'inc/fulltext.php';
$regex = '';
$data = ft_pageSearch($query, $regex);
$pages = array();
// prepare additional data
$idx = 0;
foreach ($data as $id => $score) {
$file = wikiFN($id);
if ($idx < FT_SNIPPET_NUMBER) {
$snippet = ft_snippet($id, $regex);
$idx++;
} else {
$snippet = '';
}
$pages[] = array('id' => $id, 'score' => $score, 'rev' => filemtime($file), 'mtime' => filemtime($file), 'size' => filesize($file), 'snippet' => $snippet);
}
return $pages;
}
示例3: search
/**
* List all pages in the given namespace (and below)
*/
function search($query)
{
$regex = '';
$data = ft_pageSearch($query, $regex);
$pages = array();
// prepare additional data
$idx = 0;
foreach ($data as $id => $score) {
$file = wikiFN($id);
if ($idx < FT_SNIPPET_NUMBER) {
$snippet = ft_snippet($id, $regex);
$idx++;
} else {
$snippet = '';
}
$pages[] = array('id' => $id, 'score' => intval($score), 'rev' => filemtime($file), 'mtime' => filemtime($file), 'size' => filesize($file), 'snippet' => $snippet, 'title' => useHeading('navigation') ? p_get_first_heading($id) : $id);
}
return $pages;
}
示例4: html_search
/**
* Run a search and display the result
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function html_search()
{
require_once DOKU_INC . 'inc/search.php';
require_once DOKU_INC . 'inc/fulltext.php';
global $conf;
global $QUERY;
global $ID;
global $lang;
print p_locale_xhtml('searchpage');
flush();
//check if search is restricted to namespace
if (preg_match('/([^@]*)@([^@]*)/', $QUERY, $match)) {
$id = cleanID($match[1]);
if (empty($id)) {
print '<div class="nothing">' . $lang['nothingfound'] . '</div>';
flush();
return;
}
} else {
$id = cleanID($QUERY);
}
//show progressbar
print '<div class="centeralign" id="dw__loading">' . NL;
print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--' . NL;
print 'showLoadBar();' . NL;
print '//--><!]]></script>' . NL;
print '<br /></div>' . NL;
flush();
//do quick pagesearch
$data = array();
$data = ft_pageLookup($id);
if (count($data)) {
print '<div class="search_quickresult">';
print '<h3>' . $lang['quickhits'] . ':</h3>';
print '<ul class="search_quickhits">';
foreach ($data as $id) {
print '<li> ';
$ns = getNS($id);
if ($ns) {
$name = shorten(noNS($id), ' (' . $ns . ')', 30);
} else {
$name = $id;
}
print html_wikilink(':' . $id, $name);
print '</li> ';
}
print '</ul> ';
//clear float (see http://www.complexspiral.com/publications/containing-floats/)
print '<div class="clearer"> </div>';
print '</div>';
}
flush();
//do fulltext search
$data = ft_pageSearch($QUERY, $regex);
if (count($data)) {
$num = 1;
foreach ($data as $id => $cnt) {
print '<div class="search_result">';
print html_wikilink(':' . $id, useHeading('navigation') ? NULL : $id, $regex);
print ': <span class="search_cnt">' . $cnt . ' ' . $lang['hits'] . '</span><br />';
if ($num < 15) {
// create snippets for the first number of matches only #FIXME add to conf ?
print '<div class="search_snippet">' . ft_snippet($id, $regex) . '</div>';
}
print '</div>';
flush();
$num++;
}
} else {
print '<div class="nothing">' . $lang['nothingfound'] . '</div>';
}
//hide progressbar
print '<script type="text/javascript" charset="utf-8"><!--//--><![CDATA[//><!--' . NL;
print 'hideLoadBar("dw__loading");' . NL;
print '//--><!]]></script>' . NL;
flush();
}