本文整理汇总了PHP中PageIndexGrep函数的典型用法代码示例。如果您正苦于以下问题:PHP PageIndexGrep函数的具体用法?PHP PageIndexGrep怎么用?PHP PageIndexGrep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PageIndexGrep函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MakePageList
function MakePageList($pagename, $opt, $retpages = 1)
{
global $MakePageListOpt, $SearchPatterns, $EnablePageListProtect, $PCache, $FmtV;
StopWatch('MakePageList begin');
SDVA($MakePageListOpt, array('list' => 'default'));
$opt = array_merge((array) $MakePageListOpt, $opt);
$readf = @$opt['readf'];
# we have to read the page if order= is anything but name
$order = @$opt['order'];
$readf |= $order && $order != 'name' && $order != '-name';
$pats = @(array) $SearchPatterns[$opt['list']];
if (@$opt['group']) {
$pats[] = FixGlob($opt['group'], '$1$2.*');
}
if (@$opt['name']) {
$pats[] = FixGlob($opt['name'], '$1*.$2');
}
# inclp/exclp contain words to be included/excluded.
$incl = array();
$inclp = array();
$inclx = false;
$excl = array();
$exclp = '';
foreach ((array) @$opt[''] as $i) {
$incl[] = $i;
}
foreach ((array) @$opt['+'] as $i) {
$incl[] = $i;
}
foreach ((array) @$opt['-'] as $i) {
$excl[] = $i;
}
foreach ($incl as $i) {
$inclp[] = '$' . preg_quote($i) . '$i';
$inclx |= preg_match('[^\\w\\x80-\\xff]', $i);
}
if ($excl) {
$exclp = '$' . implode('|', array_map('preg_quote', $excl)) . '$i';
}
$searchterms = count($incl) + count($excl);
$readf += $searchterms;
# forced read if incl/excl
if (@$opt['trail']) {
$trail = ReadTrail($pagename, $opt['trail']);
$list = array();
foreach ($trail as $tstop) {
$pn = $tstop['pagename'];
$list[] = $pn;
$tstop['parentnames'] = array();
PCache($pn, $tstop);
}
foreach ($trail as $tstop) {
$PCache[$tstop['pagename']]['parentnames'][] = @$trail[$tstop['parent']]['pagename'];
}
} else {
$list = ListPages($pats);
}
if (IsEnabled($EnablePageListProtect, 1)) {
$readf = 1000;
}
$matches = array();
$FmtV['$MatchSearched'] = count($list);
$terms = $incl ? PageIndexTerms($incl) : array();
if (@$opt['link']) {
$link = MakePageName($pagename, $opt['link']);
$linkp = "/(^|,){$link}(,|\$)/i";
$terms[] = " {$link} ";
$readf++;
}
if ($terms) {
$xlist = PageIndexGrep($terms, true);
$a = count($list);
$list = array_diff($list, $xlist);
$a -= count($list);
StopWatch("MakePageList: PageIndex filtered {$a} pages");
}
$xlist = array();
StopWatch('MakePageList scanning ' . count($list) . " pages, readf={$readf}");
foreach ((array) $list as $pn) {
if ($readf) {
$page = $readf >= 1000 ? RetrieveAuthPage($pn, 'read', false, READPAGE_CURRENT) : ReadPage($pn, READPAGE_CURRENT);
if (!$page) {
continue;
}
if (@$linkp && !preg_match($linkp, @$page['targets'])) {
$xlist[] = $pn;
continue;
}
if ($searchterms) {
$text = $pn . "\n" . @$page['targets'] . "\n" . @$page['text'];
if ($exclp && preg_match($exclp, $text)) {
continue;
}
foreach ($inclp as $i) {
if (!preg_match($i, $text)) {
if (!$inclx) {
$xlist[] = $pn;
}
continue 2;
}
//.........这里部分代码省略.........
示例2: PageListTermsTargets
function PageListTermsTargets(&$list, &$opt, $pn, &$page) {
global $FmtV;
static $reindex = array();
$fold = $GLOBALS['StrFoldFunction'];
switch ($opt['=phase']) {
case PAGELIST_PRE:
$FmtV['$MatchSearched'] = count($list);
$incl = array(); $excl = array();
foreach((array)@$opt[''] as $i) { $incl[] = $fold($i); }
foreach((array)@$opt['+'] as $i) { $incl[] = $fold($i); }
foreach((array)@$opt['-'] as $i) { $excl[] = $fold($i); }
$indexterms = PageIndexTerms($incl);
foreach($incl as $i) {
$delim = (!preg_match('/[^\\w\\x80-\\xff]/', $i)) ? '$' : '/';
$opt['=inclp'][] = $delim . preg_quote($i,$delim) . $delim . 'i';
}
if ($excl)
$opt['=exclp'][] = '$'.implode('|', array_map('preg_quote',$excl)).'$i';
if (@$opt['link']) {
$link = MakePageName($pn, $opt['link']);
$opt['=linkp'] = "/(^|,)$link(,|$)/i";
$indexterms[] = " $link ";
}
if (@$opt['=cached']) return 0;
if ($indexterms) {
StopWatch("PageListTermsTargets begin count=".count($list));
$xlist = PageIndexGrep($indexterms, true);
$list = array_diff($list, $xlist);
StopWatch("PageListTermsTargets end count=".count($list));
}
if (@$opt['=inclp'] || @$opt['=exclp'] || @$opt['=linkp'])
return PAGELIST_ITEM|PAGELIST_POST;
return 0;
case PAGELIST_ITEM:
if (!$page) { $page = ReadPage($pn, READPAGE_CURRENT); $opt['=readc']++; }
if (!$page) return 0;
if (@$opt['=linkp'] && !preg_match($opt['=linkp'], @$page['targets']))
{ $reindex[] = $pn; return 0; }
if (@$opt['=inclp'] || @$opt['=exclp']) {
$text = $fold($pn."\n".@$page['targets']."\n".@$page['text']);
foreach((array)@$opt['=exclp'] as $i)
if (preg_match($i, $text)) return 0;
foreach((array)@$opt['=inclp'] as $i)
if (!preg_match($i, $text)) {
if ($i{0} == '$') $reindex[] = $pn;
return 0;
}
}
return 1;
case PAGELIST_POST:
if ($reindex) PageIndexQueueUpdate($reindex);
$reindex = array();
return 0;
}
}
示例3: PageListTermsTargets
function PageListTermsTargets(&$list, &$opt, $pn, &$page)
{
global $FmtV;
switch ($opt['=phase']) {
case PAGELIST_PRE:
$FmtV['$MatchSearched'] = count($list);
$incl = array();
$excl = array();
foreach ((array) @$opt[''] as $i) {
$incl[] = $i;
}
foreach ((array) @$opt['+'] as $i) {
$incl[] = $i;
}
foreach ((array) @$opt['-'] as $i) {
$excl[] = $i;
}
$indexterms = PageIndexTerms($incl);
foreach ($incl as $i) {
$delim = !preg_match('/[^\\w\\x80-\\xff]/', $i) ? '$' : '/';
$opt['=inclp'][] = $delim . preg_quote($i, $delim) . $delim . 'i';
}
if ($excl) {
$opt['=exclp'][] = '$' . implode('|', array_map('preg_quote', $excl)) . '$i';
}
if (@$opt['link']) {
$link = MakePageName($pn, $opt['link']);
$opt['=linkp'] = "/(^|,){$link}(,|\$)/i";
$indexterms[] = " {$link} ";
}
if (@$opt['=cached']) {
return 0;
}
if ($indexterms) {
StopWatch("PageListTermsTargets begin count=" . count($list));
$xlist = PageIndexGrep($indexterms, true);
$list = array_diff($list, $xlist);
StopWatch("PageListTermsTargets end count=" . count($list));
}
if (@$opt['=inclp'] || @$opt['=exclp'] || @$opt['=linkp']) {
return PAGELIST_ITEM | PAGELIST_POST;
}
return 0;
case PAGELIST_ITEM:
if (!$page) {
$page = ReadPage($pn, READPAGE_CURRENT);
$opt['=readc']++;
}
if (!$page) {
return 0;
}
if (@$opt['=linkp'] && !preg_match($opt['=linkp'], @$page['targets'])) {
$opt['=reindex'][] = $pn;
return 0;
}
if (@$opt['=inclp'] || @$opt['=exclp']) {
$text = $pn . "\n" . @$page['targets'] . "\n" . @$page['text'];
foreach ((array) @$opt['=exclp'] as $i) {
if (preg_match($i, $text)) {
return 0;
}
}
foreach ((array) @$opt['=inclp'] as $i) {
if (!preg_match($i, $text)) {
if ($i[0] == '$') {
$opt['=reindex'][] = $pn;
}
return 0;
}
}
}
return 1;
case PAGELIST_POST:
if (@$opt['=reindex']) {
register_shutdown_function('PageIndexUpdate', $opt['=reindex'], getcwd());
}
return 0;
}
}