本文整理汇总了PHP中ft_pageLookup函数的典型用法代码示例。如果您正苦于以下问题:PHP ft_pageLookup函数的具体用法?PHP ft_pageLookup怎么用?PHP ft_pageLookup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ft_pageLookup函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: handleAjax
/**
* Autocompletion support for pages
*
* @return array
*/
public function handleAjax()
{
global $INPUT;
// check minimum length
$lookup = trim($INPUT->str('search'));
if (utf8_strlen($lookup) < $this->config['autocomplete']['mininput']) {
return array();
}
// results wanted?
$max = $this->config['autocomplete']['maxresult'];
if ($max <= 0) {
return array();
}
// lookup with namespace and postfix applied
$namespace = $this->config['autocomplete']['namespace'];
if ($namespace) {
// namespace may be relative, resolve in current context
$namespace .= ':foo';
// resolve expects pageID
resolve_pageid($INPUT->str('ns'), $namespace, $exists);
$namespace = getNS($namespace);
}
$postfix = $this->config['autocomplete']['postfix'];
if ($namespace) {
$lookup .= ' @' . $namespace;
}
$data = ft_pageLookup($lookup, true, $this->config['usetitles']);
if (!count($data)) {
return array();
}
// this basically duplicates what we do in ajax_qsearch()
$result = array();
$counter = 0;
foreach ($data as $id => $title) {
if ($this->config['usetitles']) {
$name = $title . ' (' . $id . ')';
} else {
$ns = getNS($id);
if ($ns) {
$name = noNS($id) . ' (' . $ns . ')';
} else {
$name = $id;
}
}
// check suffix
if ($postfix && substr($id, -1 * strlen($postfix)) != $postfix) {
continue;
// page does not end in postfix, don't suggest it
}
$result[] = array('label' => $name, 'value' => $id);
$counter++;
if ($counter > $max) {
break;
}
}
return $result;
}
开发者ID:cosmocode,项目名称:dokuwiki-plugin-struct,代码行数:62,代码来源:Page.php
示例2: html_search
/**
* Run a search and display the result
*
* @author Andreas Gohr <[email protected]>
*/
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();
}
开发者ID:nefercheprure,项目名称:dokuwiki,代码行数:78,代码来源:html.php
示例3: ajax_linkwiz
/**
* List matching namespaces and pages for the link wizard
*
* @author Andreas Gohr <[email protected]>
*/
function ajax_linkwiz()
{
global $conf;
global $lang;
$q = ltrim($_POST['q'], ':');
$id = noNS($q);
$ns = getNS($q);
$ns = cleanID($ns);
$id = cleanID($id);
$nsd = utf8_encodeFN(str_replace(':', '/', $ns));
$idd = utf8_encodeFN(str_replace(':', '/', $id));
$data = array();
if ($q && !$ns) {
// use index to lookup matching pages
$pages = array();
$pages = ft_pageLookup($id, true);
// result contains matches in pages and namespaces
// we now extract the matching namespaces to show
// them seperately
$dirs = array();
foreach ($pages as $pid => $title) {
if (strpos(noNS($pid), $id) === false) {
// match was in the namespace
$dirs[getNS($pid)] = 1;
// assoc array avoids dupes
} else {
// it is a matching page, add it to the result
$data[] = array('id' => $pid, 'title' => $title, 'type' => 'f');
}
unset($pages[$pid]);
}
foreach ($dirs as $dir => $junk) {
$data[] = array('id' => $dir, 'type' => 'd');
}
} else {
$opts = array('depth' => 1, 'listfiles' => true, 'listdirs' => true, 'pagesonly' => true, 'firsthead' => true, 'sneakyacl' => $conf['sneaky_index']);
if ($id) {
$opts['filematch'] = '^.*\\/' . $id;
}
if ($id) {
$opts['dirmatch'] = '^.*\\/' . $id;
}
search($data, $conf['datadir'], 'search_universal', $opts, $nsd);
// add back to upper
if ($ns) {
array_unshift($data, array('id' => getNS($ns), 'type' => 'u'));
}
}
// fixme sort results in a useful way ?
if (!count($data)) {
echo $lang['nothingfound'];
exit;
}
// output the found data
$even = 1;
foreach ($data as $item) {
$even *= -1;
//zebra
if (($item['type'] == 'd' || $item['type'] == 'u') && $item['id']) {
$item['id'] .= ':';
}
$link = wl($item['id']);
echo '<div class="' . ($even > 0 ? 'even' : 'odd') . ' type_' . $item['type'] . '">';
if ($item['type'] == 'u') {
$name = $lang['upperns'];
} else {
$name = htmlspecialchars($item['id']);
}
echo '<a href="' . $link . '" title="' . htmlspecialchars($item['id']) . '" class="wikilink1">' . $name . '</a>';
if ($item['title']) {
echo '<span>' . htmlspecialchars($item['title']) . '</span>';
}
echo '</div>';
}
}
开发者ID:stretchyboy,项目名称:dokuwiki,代码行数:80,代码来源:ajax.php
示例4: html_search
/**
* Run a search and display the result
*
* @author Andreas Gohr <[email protected]>
*/
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();
}
开发者ID:jalemanyf,项目名称:wsnlocalizationscala,代码行数:82,代码来源:html.php
示例5: ajax_suggestions
/**
* Support OpenSearch suggestions
*
* @link http://www.opensearch.org/Specifications/OpenSearch/Extensions/Suggestions/1.0
* @author Mike Frysinger <[email protected]>
*/
function ajax_suggestions()
{
global $conf;
global $lang;
$query = cleanID($_POST['q']);
if (empty($query)) {
$query = cleanID($_GET['q']);
}
if (empty($query)) {
return;
}
require_once DOKU_INC . 'inc/html.php';
require_once DOKU_INC . 'inc/fulltext.php';
require_once DOKU_INC . 'inc/JSON.php';
$data = array();
$data = ft_pageLookup($query);
if (!count($data)) {
return;
}
// limit results to 15 hits
$data = array_slice($data, 0, 15);
$data = array_map('trim', $data);
$data = array_map('noNS', $data);
$data = array_unique($data);
sort($data);
/* now construct a json */
$suggestions = array($query, $data, array(), array());
$json = new JSON();
header('Content-Type: application/x-suggestions+json');
print $json->encode($suggestions);
}
开发者ID:jalemanyf,项目名称:wsnlocalizationscala,代码行数:37,代码来源:ajax.php
示例6: _handle_ajax
function _handle_ajax($event)
{
if (strpos($event->data, 'data_page_') !== 0) {
return;
}
$event->preventDefault();
$type = substr($event->data, 10);
$aliases = $this->dthlp->_aliases();
if (!isset($aliases[$type])) {
echo 'Unknown type';
return;
}
if ($aliases[$type]['type'] !== 'page') {
echo 'AutoCompletion is only supported for page types';
return;
}
if (substr($aliases[$type]['postfix'], -1, 1) === ':') {
// Resolve namespace start page ID
global $conf;
$aliases[$type]['postfix'] .= $conf['start'];
}
require_once DOKU_INC . 'inc/fulltext.php';
$search = cleanID($_POST['search']);
$pages = ft_pageLookup($search, false);
$result = array();
foreach ($pages as $page) {
if ($aliases[$type]['prefix'] !== '' && stripos($page, $aliases[$type]['prefix']) !== 0 || $aliases[$type]['postfix'] !== '' && strripos($page, $aliases[$type]['postfix']) !== strlen($page) - strlen($aliases[$type]['postfix'])) {
continue;
}
$rtrim = -strlen($aliases[$type]['postfix']);
if ($rtrim === 0) {
// trimming with -0 gives the empty string, not the untrimmed
// string
$id = substr($page, strlen($aliases[$type]['prefix']));
} else {
$id = substr($page, strlen($aliases[$type]['prefix']), $rtrim);
}
if (useHeading('content')) {
$heading = p_get_first_heading($page, true);
}
if (!isset($heading) || $heading === '') {
$heading = $id;
}
if ($search !== '' && (stripos($id, $search) === false && stripos($heading, $search) === false) || strpos($id, ':') !== false) {
continue;
}
$result[hsc($id)] = hsc($heading);
}
require_once DOKU_INC . 'inc/JSON.php';
$json = new JSON();
echo '(' . $json->encode($result) . ')';
}
开发者ID:nikopp,项目名称:dokuwiki-plugin-data,代码行数:52,代码来源:action.php
示例7: _handle_ajax
/**
* @param Doku_Event $event
*/
function _handle_ajax(Doku_Event $event)
{
if ($event->data !== 'data_page') {
return;
}
$event->stopPropagation();
$event->preventDefault();
$type = substr($_REQUEST['aliastype'], 10);
$aliases = $this->dthlp->_aliases();
if (!isset($aliases[$type])) {
echo 'Unknown type';
return;
}
if ($aliases[$type]['type'] !== 'page') {
echo 'AutoCompletion is only supported for page types';
return;
}
if (substr($aliases[$type]['postfix'], -1, 1) === ':') {
// Resolve namespace start page ID
global $conf;
$aliases[$type]['postfix'] .= $conf['start'];
}
$search = $_REQUEST['search'];
$c_search = $search;
$in_ns = false;
if (!$search) {
// No search given, so we just want all pages in the prefix
$c_search = $aliases[$type]['prefix'];
$in_ns = true;
}
$pages = ft_pageLookup($c_search, $in_ns, false);
$regexp = '/^';
if ($aliases[$type]['prefix'] !== '') {
$regexp .= preg_quote($aliases[$type]['prefix'], '/');
}
$regexp .= '([^:]+)';
if ($aliases[$type]['postfix'] !== '') {
$regexp .= preg_quote($aliases[$type]['postfix'], '/');
}
$regexp .= '$/';
$result = array();
foreach ($pages as $page => $title) {
$id = array();
if (!preg_match($regexp, $page, $id)) {
// Does not satisfy the postfix and prefix criteria
continue;
}
$id = $id[1];
if ($search !== '' && stripos($id, cleanID($search)) === false && stripos($title, $search) === false) {
// Search string is not in id part or title
continue;
}
if ($title === '') {
$title = utf8_ucwords(str_replace('_', ' ', $id));
}
$result[hsc($id)] = hsc($title);
}
$json = new JSON();
header('Content-Type: application/json');
echo $json->encode($result);
}
开发者ID:RnBConsulting,项目名称:dokuwiki-plugin-data,代码行数:64,代码来源:action.php
示例8: _quick_pagesearch
/**
* Search for the page.
*/
function _quick_pagesearch($id)
{
$data = array();
if ($id) {
$data = ft_pageLookup($id);
}
if (count($data)) {
foreach ($data as $id) {
}
}
}
开发者ID:k4m1,项目名称:master-thesis,代码行数:14,代码来源:syntax.php
示例9: _handle_ajax
function _handle_ajax($event)
{
if (strpos($event->data, 'data_page_') !== 0) {
return;
}
$event->preventDefault();
$type = substr($event->data, 10);
$aliases = $this->dthlp->_aliases();
if (!isset($aliases[$type])) {
echo 'Unknown type';
return;
}
if ($aliases[$type]['type'] !== 'page') {
echo 'AutoCompletion is only supported for page types';
return;
}
if (substr($aliases[$type]['postfix'], -1, 1) === ':') {
// Resolve namespace start page ID
global $conf;
$aliases[$type]['postfix'] .= $conf['start'];
}
$search = $_POST['search'];
$pages = ft_pageLookup($search, false, false);
$regexp = '/^';
if ($aliases[$type]['prefix'] !== '') {
$regexp .= preg_quote($aliases[$type]['prefix'], '/');
}
$regexp .= '([^:]+)';
if ($aliases[$type]['postfix'] !== '') {
$regexp .= preg_quote($aliases[$type]['postfix'], '/');
}
$regexp .= '$/';
$result = array();
foreach ($pages as $page => $title) {
$id = array();
if (!preg_match($regexp, $page, $id)) {
// Does not satisfy the postfix and prefix criteria
continue;
}
$id = $id[1];
if ($search !== '' && stripos($id, cleanID($search)) === false && stripos($title, $search) === false) {
// Search string is not in id part or title
continue;
}
if ($title === '') {
$title = utf8_ucwords(str_replace('_', ' ', $id));
}
$result[hsc($id)] = hsc($title);
}
$json = new JSON();
echo '(' . $json->encode($result) . ')';
}
开发者ID:stretchyboy,项目名称:dokuwiki-plugin-data,代码行数:52,代码来源:action.php
示例10: getBestNamespace
/**
* getBestNamespace
* Return a list with 'BestNamespaceId Score'
*/
function getBestNamespace($Vl_ID)
{
global $conf;
$Vl_ListNamespaceId = array();
$Vl_ListNamespaceId = ft_pageLookup($conf['start']);
$Vl_BestNbWordFound = 0;
$Vl_BestNamespaceId = '';
$Vl_IdToExplode = str_replace('_', ':', $Vl_ID);
$Vl_WordsInId = explode(':', $Vl_IdToExplode);
foreach ($Vl_ListNamespaceId as $Vl_NamespaceId) {
$Vl_NbWordFound = 0;
foreach ($Vl_WordsInId as $Vl_Word) {
if (strlen($Vl_Word) > 2) {
$Vl_NbWordFound = $Vl_NbWordFound + substr_count($Vl_NamespaceId, $Vl_Word);
}
}
if ($Vl_NbWordFound > $Vl_BestNbWordFound) {
//Take only the smallest namespace
if (strlen($Vl_NamespaceId) < strlen($Vl_BestNamespaceId) or $Vl_NbWordFound > $Vl_BestNbWordFound) {
$Vl_BestNbWordFound = $Vl_NbWordFound;
$Vl_BestNamespaceId = $Vl_NamespaceId;
}
}
}
$Vl_WfForStartPage = $this->getConf('WeightFactorForStartPage');
$Vl_WfForSameNamespace = $this->getConf('WeightFactorForSameNamespace');
if ($Vl_BestNbWordFound > 0) {
$Vl_Score = $Vl_BestNbWordFound * $Vl_WfForSameNamespace + $Vl_WfForStartPage;
} else {
$Vl_Score = 0;
}
return $Vl_BestNamespaceId . " " . $Vl_Score;
}
开发者ID:houshuang,项目名称:folders2web,代码行数:37,代码来源:action.php
示例11: html_search
/**
* Run a search and display the result
*
* @author Andreas Gohr <[email protected]>
*/
function html_search()
{
global $conf;
global $QUERY;
global $ID;
global $lang;
print '<div class="toc">
<div class="tocheader toctoggle" id="toc__header">Table of Contents</div>
<div id="toc__inside">
<ul class="toc">
<li class="level1"><div class="li"><span class="li"><a href="#pages" class="toc">Pagenames</a></span></div></li>
<li class="level1"><div class="li"><span class="li"><a href="#authors" class="toc">Authors</a></span></div>
<li class="level1"><div class="li"><span class="li"><a href="#tools" class="toc">Tools</a></span></div></li>
<li class="level1"><div class="li"><span class="li"><a href="#articles" class="toc">Articles</a></span></div></li>
<li class="level1"><div class="li"><span class="li"><a href="#conferences" class="toc">Conferences</a></span></div></li>
<li class="level1"><div class="li"><span class="li"><a href="#other" class="toc">Other pages</a></span></div>
</ul>
</div>
</div>';
$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;
print '<h1>Search: ' . $QUERY . '</h1>';
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();
$articles = '/^(clip|kindle|notes)\\:/';
$avoid = '/((^(ref|kbib|abib|jbib|bib|t|clip|kindle|notes|skimg|conf)\\:)|^start$)/';
// add more conference namespaces at the end of $avoid and in $conferences, if you use first level namespaces
// for this, for example I have aera11: cscl11: etc.
$conferences = '/^(conf)\\:/';
$tool = '/^t\\:/';
$author = '/^a\\:/';
//do quick pagesearch
$data = array();
$data = ft_pageLookup($QUERY, true, useHeading('navigation'));
$out = '';
foreach ($data as $id => $title) {
if (!preg_match($avoid, $id) || preg_match('/^abib:/', $id)) {
$out = $out . '<li> ';
if (useHeading('navigation')) {
$name = $title;
} else {
$ns = getNS($id);
if ($ns) {
$name = shorten(noNS($id), ' (' . $ns . ')', 30);
} else {
$name = $id;
}
}
$out = $out . html_wikilink(':' . $id, $name);
$out = $out . '</li> ';
}
}
if ($out != '') {
print '<h2 name=pages id=pages>Page titles</h2>';
print '<ul class="search_quickhits">';
print $out;
print "</ul>";
print '<div class="clearer"></div>';
flush();
}
$data = ft_pageSearch($QUERY, $regexp);
///////////////////////////////////////////////////////////////////////////
// authors
$out = '';
foreach ($data as $id => $cnt) {
if (preg_match($author, $id)) {
$out = $out . '<li>' . html_wikilink(':' . $id, useHeading('navigation') ? null : $id, $regexp) . '</li>';
}
}
if ($out != '') {
print '<br><h2 name=authors id=authors>Authors</h2>';
print '<ul class="search_quickhits">';
print $out;
print "</ul>";
print '<div class="clearer"></div>';
}
///////////////////////////////////////////////////////////////////////////
// tools
$out = '';
foreach ($data as $id => $cnt) {
if (preg_match($tool, $id)) {
$out = $out . '<li>' . html_wikilink(':' . $id, useHeading('navigation') ? null : $id, $regexp) . '</li>';
}
}
if ($out != '') {
print '<br><h2 name=tools id=tools>Tool results</h2>';
//.........这里部分代码省略.........
开发者ID:houshuang,项目名称:folders2web,代码行数:101,代码来源:html.php
注:本文中的ft_pageLookup函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论