本文整理汇总了PHP中CalcRange函数的典型用法代码示例。如果您正苦于以下问题:PHP CalcRange函数的具体用法?PHP CalcRange怎么用?PHP CalcRange使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CalcRange函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FPLTemplateSliceList
function FPLTemplateSliceList($pagename, &$matches, $opt){
if (@$opt['count']) {
list($r0, $r1) = CalcRange($opt['count'], count($matches));
if ($r1 < $r0)
$matches = array_reverse(array_slice($matches, $r1-1, $r0-$r1+1));
else
$matches = array_slice($matches, $r0-1, $r1-$r0+1);
}
}
示例2: FPLTemplate
function FPLTemplate($pagename, &$matches, $opt)
{
global $Cursor, $FPLTemplatePageFmt, $RASPageName, $PageListArgPattern;
SDV($FPLTemplatePageFmt, array('{$FullName}', '{$SiteGroup}.LocalTemplates', '{$SiteGroup}.PageListTemplates'));
StopWatch("FPLTemplate begin");
$template = @$opt['template'];
if (!$template) {
$template = @$opt['fmt'];
}
$ttext = RetrieveAuthSection($pagename, $template, $FPLTemplatePageFmt);
$ttext = PVSE(Qualify($RASPageName, $ttext));
## save any escapes
$ttext = MarkupEscape($ttext);
## remove any anchor markups to avoid duplications
$ttext = preg_replace('/\\[\\[#[A-Za-z][-.:\\w]*\\]\\]/', '', $ttext);
## extract portions of template
$tparts = preg_split('/\\(:(template)\\s+(\\w+)\\s*(.*?):\\)/i', $ttext, -1, PREG_SPLIT_DELIM_CAPTURE);
## handle (:template defaults:)
$i = 0;
while ($i < count($tparts)) {
if ($tparts[$i] != 'template') {
$i++;
continue;
}
if ($tparts[$i + 1] != 'defaults' && $tparts[$i + 1] != 'default') {
$i += 4;
continue;
}
$opt = array_merge(ParseArgs($tparts[$i + 2], $PageListArgPattern), $opt);
array_splice($tparts, $i, 3);
}
SDVA($opt, array('class' => 'fpltemplate', 'wrap' => 'div'));
## get the list of pages
$matches = array_values(MakePageList($pagename, $opt, 0));
## extract page subset according to 'count=' parameter
if (@$opt['count']) {
list($r0, $r1) = CalcRange($opt['count'], count($matches));
if ($r1 < $r0) {
$matches = array_reverse(array_slice($matches, $r1 - 1, $r0 - $r1 + 1));
} else {
$matches = array_slice($matches, $r0 - 1, $r1 - $r0 + 1);
}
}
$savecursor = $Cursor;
$pagecount = 0;
$groupcount = 0;
$grouppagecount = 0;
$pseudovars = array('{$$PageCount}' => &$pagecount, '{$$GroupCount}' => &$groupcount, '{$$GroupPageCount}' => &$grouppagecount);
foreach (preg_grep('/^[\\w$]/', array_keys($opt)) as $k) {
if (!is_array($opt[$k])) {
$pseudovars["{\$\${$k}}"] = htmlspecialchars($opt[$k], ENT_NOQUOTES);
}
}
$vk = array_keys($pseudovars);
$vv = array_values($pseudovars);
$lgroup = '';
$out = '';
foreach ($matches as $i => $pn) {
$group = PageVar($pn, '$Group');
if ($group != $lgroup) {
$groupcount++;
$grouppagecount = 0;
$lgroup = $group;
}
$grouppagecount++;
$pagecount++;
$t = 0;
while ($t < count($tparts)) {
if ($tparts[$t] != 'template') {
$item = $tparts[$t];
$t++;
} else {
list($when, $control, $item) = array_slice($tparts, $t + 1, 3);
$t += 4;
if (!$control) {
if ($when == 'first' && $i != 0) {
continue;
}
if ($when == 'last' && $i != count($matches) - 1) {
continue;
}
} else {
if ($when == 'first' || !isset($last[$t])) {
$Cursor['<'] = $Cursor['<'] = (string) @$matches[$i - 1];
$Cursor['='] = $pn;
$Cursor['>'] = $Cursor['>'] = (string) @$matches[$i + 1];
$curr = str_replace($vk, $vv, $control);
$curr = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $curr);
if ($when == 'first' && $i > 0 && $last[$t] == $curr) {
continue;
}
$last[$t] = $curr;
}
if ($when == 'last') {
$Cursor['<'] = $Cursor['<'] = $pn;
$Cursor['='] = (string) @$matches[$i + 1];
$Cursor['>'] = $Cursor['>'] = (string) @$matches[$i + 2];
$next = str_replace($vk, $vv, $control);
$next = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $next);
if ($next == $last[$t] && $i != count($matches) - 1) {
//.........这里部分代码省略.........
示例3: TESliceList
function TESliceList(&$list, $opt)
{
list($r0, $r1) = CalcRange($opt['count'], count($list));
if ($r1 < $r0) {
$list = array_reverse(array_slice($list, $r1 - 1, $r0 - $r1 + 1));
} else {
$list = array_slice($list, $r0 - 1, $r1 - $r0 + 1);
}
}
示例4: FPLTrailTrail
function FPLTrailTrail($pagename, &$matches, $opt)
{
if (!@$opt['link']) {
$opt['link'] = $pagename;
}
$matches = MakePageList($pagename, $opt, 0);
// deal with count
if (@$opt['count']) {
list($r0, $r1) = CalcRange($opt['count'], count($matches));
if ($r1 < $r0) {
$matches = array_reverse(array_slice($matches, $r1 - 1, $r0 - $r1 + 1));
} else {
$matches = array_slice($matches, $r0 - 1, $r1 - $r0 + 1);
}
}
if (!@$opt['label']) {
$opt['label'] = '{$Title}';
}
$topt = array();
$topt['fmt'] = 'fauxtrail';
$topt['label'] = $opt['label'];
$out = '';
$tmatches = array();
foreach ($matches as $m) {
$topt['trail'] = $m;
$topt['trailpage'] = $m;
$out .= FPLFauxTrail($pagename, $tmatches, $topt);
}
return $out;
}
示例5: FPLSimpleText
function FPLSimpleText($pagename, &$matches, $opt)
{
$matches = MakePageList($pagename, $opt, 0);
## extract page subset according to 'count=' parameter
if (@$opt['count']) {
list($r0, $r1) = CalcRange($opt['count'], count($matches));
if ($r1 < $r0) {
$matches = array_reverse(array_slice($matches, $r1 - 1, $r0 - $r1 + 1));
} else {
$matches = array_slice($matches, $r0 - 1, $r1 - $r0 + 1);
}
}
$opt['sep'] = @$opt['sep'] ? $opt['sep'] : ",";
$opt['sep'] = str_replace('\\n', "\n", $opt['sep']);
if ($opt['sep'] == 'LF') {
$opt['sep'] = "\n";
}
return Keep(implode($opt['sep'], $matches), 'P');
}