本文整理汇总了PHP中TextSection函数的典型用法代码示例。如果您正苦于以下问题:PHP TextSection函数的具体用法?PHP TextSection怎么用?PHP TextSection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TextSection函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: IncludeText
function IncludeText($pagename, $inclspec)
{
global $MaxIncludes, $IncludeOpt, $InclCount;
SDV($MaxIncludes, 50);
SDVA($IncludeOpt, array('self' => 1));
$npat = '[[:alpha:]][-\\w]*';
if ($InclCount++ >= $MaxIncludes) {
return Keep($inclspec);
}
$args = array_merge($IncludeOpt, ParseArgs($inclspec));
while (count($args['#']) > 0) {
$k = array_shift($args['#']);
$v = array_shift($args['#']);
if ($k == '') {
if ($v[0] != '#') {
if (isset($itext)) {
continue;
}
$iname = MakePageName($pagename, $v);
if (!$args['self'] && $iname == $pagename) {
continue;
}
$ipage = RetrieveAuthPage($iname, 'read', false, READPAGE_CURRENT);
$itext = @$ipage['text'];
}
$itext = TextSection($itext, $v, array('anchors' => 1));
continue;
}
if (preg_match('/^(?:line|para)s?$/', $k)) {
preg_match('/^(\\d*)(\\.\\.(\\d*))?$/', $v, $match);
@(list($x, $a, $dots, $b) = $match);
$upat = $k[0] == 'p' ? ".*?(\n\\s*\n|\$)" : "[^\n]*(?:\n|\$)";
if (!$dots) {
$b = $a;
$a = 0;
}
if ($a > 0) {
$a--;
}
$itext = preg_replace("/^(({$upat}){0,{$b}}).*\$/s", '$1', $itext, 1);
$itext = preg_replace("/^({$upat}){0,{$a}}/s", '', $itext, 1);
continue;
}
}
$basepage = isset($args['basepage']) ? MakePageName($pagename, $args['basepage']) : $iname;
if ($basepage) {
$itext = Qualify(@$basepage, @$itext);
}
return FmtTemplateVars(PVSE($itext), $args);
}
示例2: TETextRows
function TETextRows($pagename, $source, $opt, &$par)
{
if ($source == $pagename) {
return '';
}
$page = ReadPage($source);
if (!$page) {
return '';
}
$text = $page['text'];
//use pagename#section if present
if ($opt['section']) {
$text = TextSection($text, $source . $opt['section']);
}
//skip page if it has an exclude match
if ($opt['pat']['-'] != '') {
foreach ($opt['-'] as $pat) {
if (preg_match("({$pat})" . $par['qi'], $text)) {
return;
}
}
}
//skip page if it has no match; all inclusive elements need to match (AND condition)
foreach ($opt[''] as $pat) {
if (!preg_match("({$pat})" . $par['qi'], $text)) {
return;
}
}
$text = Qualify($source, $text);
$rows = explode("\n", rtrim($text));
//use range of lines
if ($opt['lines'] != '') {
$cnt = count($rows);
if (strstr($opt['lines'], '..')) {
preg_match_all("/\\d*/", $lines, $k);
$a = $k[0][0];
$b = $k[0][3];
$c = $k[0][2];
if ($a && $b) {
$rows = array_slice($rows, $a - 1, $b - $a + 1);
} else {
if ($a) {
$rows = array_slice($rows, $a - 1);
} else {
if ($c) {
$rows = array_slice($rows, 0, $c);
}
}
}
} else {
if ($opt['lines'][0] == '-') {
$rows = array_slice($rows, $opt['lines']);
} else {
$rows = array_slice($rows, 0, $opt['lines']);
}
}
}
//unit=para: combine rows to paragraph rows
if ($opt['unit'] == 'para') {
$paras = array();
$j = 0;
foreach ($rows as $i => $row) {
$row = rtrim($row);
if ($row == '') {
$j++;
continue;
}
$paras[$j] .= $row . "\n";
}
$rows = $paras;
}
//unit=page: combine rows to one row
if ($opt['unit'] == 'page') {
$part = implode("\n", $rows);
$rows[0] = $part;
}
return $rows;
}