当前位置: 首页>>代码示例>>PHP>>正文


PHP PPRE函数代码示例

本文整理汇总了PHP中PPRE函数的典型用法代码示例。如果您正苦于以下问题:PHP PPRE函数的具体用法?PHP PPRE怎么用?PHP PPRE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PPRE函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: CondText2

function CondText2($pagename, $text, $code = '')
{
    global $Conditions, $CondTextPattern, $CondTextReplacement;
    $if = "if{$code}";
    $repl = str_replace('$pagename', "'{$pagename}'", $CondTextReplacement);
    $parts = preg_split("/\\(:(?:{$if}end|{$if}|else *{$if}|else{$code})\\b\\s*(.*?)\\s*:\\)/", $text, -1, PREG_SPLIT_DELIM_CAPTURE);
    $x = array_shift($parts);
    while ($parts) {
        list($condspec, $condtext) = array_splice($parts, 0, 2);
        if (!preg_match("/^\\s*(!?)\\s*(\\S*)\\s*(.*?)\\s*\$/", $condspec, $match)) {
            continue;
        }
        list($x, $not, $condname, $condparm) = $match;
        if (!isset($Conditions[$condname])) {
            return PPRE($CondTextPattern, $repl, $condtext);
        }
        $tf = @eval("return ({$Conditions[$condname]});");
        if ($tf xor $not) {
            return PPRE($CondTextPattern, $repl, $condtext);
        }
    }
    return '';
}
开发者ID:BMLP,项目名称:memoryhole-ansible,代码行数:23,代码来源:stdmarkup.php

示例2: MarkupRestore

function MarkupRestore($text) {
  global $KeepToken, $KPV;
  return PPRE("/$KeepToken(\\d.*?)$KeepToken/", "\$GLOBALS['KPV'][\$m[1]]", $text);
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:4,代码来源:pmwiki.php

示例3: MarkupExpression

function MarkupExpression($pagename, $expr) {
  global $KeepToken, $KPV, $MarkupExpr;
  $rpat = "/$KeepToken(\\d+P)$KeepToken/";
  $rrep = '$GLOBALS["KPV"][$m[1]]';
  $expr = PPRE('/([\'"])(.*?)\\1/', "Keep(\$m[2],'P')", $expr);
  $expr = PPRE('/\\(\\W/', "Keep(\$m[0],'P')", $expr);
  while (preg_match('/\\((\\w+)(\\s[^()]*)?\\)/', $expr, $match)) {
    list($repl, $func, $params) = $match;
    $code = @$MarkupExpr[$func];
    ##  if not a valid function, save this string as-is and exit
    if (!$code) break;
    ##  if the code uses '$params', we just evaluate directly
    if (strpos($code, '$params') !== false) {
      $out = eval("return ({$code});");
      if ($expr == $repl) { $expr = $out; break; }
      $expr = str_replace($repl, $out, $expr);
      continue;
    }
    ##  otherwise, we parse arguments into $args before evaluating
    $argp = ParseArgs($params);
    $x = $argp['#']; $args = array();
    while ($x) {
      list($k, $v) = array_splice($x, 0, 2);
      if ($k == '' || $k == '+' || $k == '-') 
        $args[] = $k.PPRE($rpat, $rrep, $v);
    }
    ##  fix any quoted arguments
    foreach ($argp as $k => $v)
      if (!is_array($v)) $argp[$k] = PPRE($rpat, $rrep, $v);
    $out = eval("return ({$code});");
    if ($expr == $repl) { $expr = $out; break; }
    $expr = str_replace($repl, Keep($out, 'P'), $expr);
  }
  return PPRE($rpat, $rrep, $expr);
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:35,代码来源:markupexpr.php

示例4: ApplyStyles

function ApplyStyles($x)
{
    global $UrlExcludeChars, $WikiStylePattern, $WikiStyleRepl, $WikiStyle, $WikiStyleAttr, $WikiStyleCSS, $WikiStyleApply, $BlockPattern, $WikiStyleTag, $imgTag, $aTag, $spanTag, $WikiStyleAttrPrefix;
    $wt = @$WikiStyleTag;
    $ns = $WikiStyleAttrPrefix;
    $ws = '';
    $x = PPRE("/\\b(href|src)=(['\"]?)[^{$UrlExcludeChars}]+\\2/", "Keep(\$m[0])", $x);
    $x = PPRE("/\\bhttps?:[^{$UrlExcludeChars}]+/", "Keep(\$m[0])", $x);
    $parts = preg_split("/({$WikiStylePattern})/", $x, -1, PREG_SPLIT_DELIM_CAPTURE);
    $parts[] = NULL;
    $out = '';
    $style = array();
    $wikicsspat = '/^(' . implode('|', (array) $WikiStyleCSS) . ')$/';
    while ($parts) {
        $p = array_shift($parts);
        if (preg_match("/^{$WikiStylePattern}\$/", $p)) {
            $WikiStyle['curr'] = $style;
            $style = array();
            foreach ((array) $WikiStyleRepl as $pat => $rep) {
                $p = preg_replace($pat, $rep, $p);
            }
            preg_match_all('/\\b([a-zA-Z][-\\w]*)([:=]([-#,\\w.()%]+|([\'"]).*?\\4))?/', $p, $match, PREG_SET_ORDER);
            while ($match) {
                $m = array_shift($match);
                if (@$m[2]) {
                    $style[$m[1]] = preg_replace('/^([\'"])(.*?)\\1$/', '$2', $m[3]);
                } else {
                    if (!isset($WikiStyle[$m[1]])) {
                        @($style['class'] .= ' ' . $m[1]);
                    } else {
                        $c = @$style['class'];
                        $style = array_merge($style, (array) $WikiStyle[$m[1]]);
                        if ($c && !preg_match("/(^| ){$c}( |\$)/", $style['class'])) {
                            $style['class'] = $c . ' ' . $style['class'];
                        }
                    }
                }
            }
            if (@$style['define']) {
                $d = $style['define'];
                unset($style['define']);
                $WikiStyle[$d] = $style;
            }
            if (@$WikiStyleApply[$style['apply']]) {
                $apply[$style['apply']] = array_merge((array) @$apply[$style['apply']], $style);
                $style = array();
            }
            continue;
        }
        if (is_null($p)) {
            $alist = @$apply;
            unset($alist['']);
            $p = $out;
            $out = '';
        } elseif ($p == '') {
            continue;
        } else {
            $alist = array('' => $style);
        }
        foreach ((array) $alist as $a => $s) {
            $spanattr = '';
            $stylev = array();
            $id = '';
            foreach ((array) $s as $k => $v) {
                $v = trim($v);
                if ($wt) {
                    $ws = str_replace('$1', "{$ns}{$k}='{$v}'", $wt);
                }
                if ($k == 'class' && $v) {
                    $spanattr = "{$ns}class='{$v}'";
                } elseif ($k == 'id') {
                    $id = preg_replace('/[^-A-Za-z0-9:_.]+/', '_', $v);
                } elseif (($k == 'width' || $k == 'height') && !@$WikiStyleApply[$a] && preg_match("/\\s*<{$imgTag}\\b/", $p)) {
                    $p = preg_replace("/<({$imgTag})\\b(?![^>]*\\s{$k}=)/", "{$ws}<\$1 {$ns}{$k}='{$v}'", $p);
                } elseif (@$WikiStyleAttr[$k]) {
                    $p = preg_replace("/<({$WikiStyleAttr[$k]}(?![^>]*\\s(?:{$ns})?{$k}=))([^>]*)>/s", "{$ws}<\$1 {$ns}{$k}='{$v}' \$2>", $p);
                } elseif (preg_match($wikicsspat, $k)) {
                    $stylev[] = "{$k}: {$v};";
                }
            }
            if ($stylev) {
                $spanattr .= " {$ns}style='" . implode(' ', $stylev) . "'";
            }
            if ($id) {
                $spanattr .= " {$ns}id='{$id}'";
            }
            if ($spanattr) {
                if ($wt) {
                    $ws = str_replace('$1', $spanattr, $wt);
                }
                if (!@$WikiStyleApply[$a]) {
                    $p = preg_replace("!^(.*?)(\$|</?({$BlockPattern}))!s", "{$ws}<{$spanTag} {$spanattr}>\$1</{$spanTag}>\$2", $p, 1);
                } elseif (!preg_match('/^(\\s*<[^>]+>)*$/s', $p) || preg_match("/<{$imgTag}\\b/", $p)) {
                    $p = preg_replace("/<({$WikiStyleApply[$a]})\\b/", "{$ws}<\$1 {$spanattr}", $p);
                }
            }
            if (@$s['color']) {
                $colorattr = "{$ns}style='color: {$s['color']}'";
                if ($wt) {
                    $ws = str_replace('$1', $colorattr, $wt);
//.........这里部分代码省略.........
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:101,代码来源:wikistyles.php

示例5: DiffHTML

function DiffHTML($pagename, $diff) {
  if (@$_REQUEST['nodiff']>'') return '';
  global $FmtV, $DiffShow, $DiffAddFmt, $DiffDelFmt, $DiffEndDelAddFmt,
  $DiffRenderSourceFunction;
  SDV($DiffRenderSourceFunction, 'DiffRenderSource');
  $difflines = explode("\n",$diff."\n");
  $in=array(); $out=array(); $dtype=''; $html = '';
  foreach($difflines as $d) {
    if ($d>'') {
      if ($d[0]=='-' || $d[0]=='\\') continue;
      if ($d[0]=='<') { $out[]=substr($d,2); continue; }
      if ($d[0]=='>') { $in[]=substr($d,2); continue; }
    }
    if (preg_match("/^(\\d+)(,(\\d+))?([adc])(\\d+)(,(\\d+))?/",
        $dtype,$match)) {
      if (@$match[7]>'') {
        $lines='lines';
        $count=$match[1].'-'.($match[1]+$match[7]-$match[5]);
      } elseif ($match[3]>'') {
        $lines='lines'; $count=$match[1].'-'.$match[3];
      } else { $lines='line'; $count=$match[1]; }
      if ($match[4]=='a' || $match[4]=='c') {
        $txt = str_replace('line',$lines,$DiffDelFmt[$match[4]]);
        $FmtV['$DiffLines'] = $count;
        $html .= FmtPageName($txt,$pagename);
        if ($DiffShow['source']=='y') 
          $html .= "<div class='diffmarkup'>"
            .$DiffRenderSourceFunction($in, $out, 0)
            ."</div>";
        else $html .= MarkupToHTML($pagename,
          PPRE('/\\(:.*?:\\)/',"Keep(PHSC(\$m[0]))", join("\n",$in)));
      }
      if ($match[4]=='d' || $match[4]=='c') {
        $txt = str_replace('line',$lines,$DiffAddFmt[$match[4]]);
        $FmtV['$DiffLines'] = $count;
        $html .= FmtPageName($txt,$pagename);
        if ($DiffShow['source']=='y') 
          $html .= "<div class='diffmarkup'>"
            .$DiffRenderSourceFunction($in, $out, 1)
            ."</div>";
        else $html .= MarkupToHTML($pagename,
          PPRE('/\\(:.*?:\\)/',"Keep(PHSC(\$m[0]))",join("\n",$out)));
      }
      $html .= FmtPageName($DiffEndDelAddFmt,$pagename);
    }
    $in=array(); $out=array(); $dtype=$d;
  }
  return $html;
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:49,代码来源:pagerev.php

示例6: FPLExpandItemVars

function FPLExpandItemVars($item, $matches, $idx, $psvars) {
  global $Cursor, $EnableUndefinedTemplateVars;
  $Cursor['<'] = $Cursor['&lt;'] = (string)@$matches[$idx-1];
  $Cursor['='] = $pn = (string)@$matches[$idx];
  $Cursor['>'] = $Cursor['&gt;'] = (string)@$matches[$idx+1];
  $item = str_replace(array_keys($psvars), array_values($psvars), $item);
  $item = PPRE('/\\{(=|&[lg]t;)(\\$:?\\w[-\\w]*)\\}/',
              "PVSE(PageVar('$pn',  \$m[2], \$m[1]))", $item);
  if(! IsEnabled($EnableUndefinedTemplateVars, 0))
    $item = preg_replace("/\\{\\$\\$\\w+\\}/", '', $item);
  return $item;
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:12,代码来源:pagelist.php

示例7: utf8string

function utf8string($str, $start = false, $len = false)
{
    # strlen+substr++ combo for UTF-8
    global $CaseConversions;
    static $lower;
    if (!@$lower) {
        $lower = implode('|', array_keys($CaseConversions));
    }
    $ascii = preg_match('/[\\x80-\\xFF]/', $str) ? 0 : 1;
    switch ((string) $start) {
        case 'ucfirst':
            return $ascii ? ucfirst($str) : PPRE("/^({$lower})/", '$GLOBALS["CaseConversions"][$m[1]]', $str);
        case 'ucwords':
            return $ascii ? ucwords($str) : PPRE("/(^|\\s+)({$lower})/", '$m[1].$GLOBALS["CaseConversions"][$m[2]]', $str);
        case 'tolower':
            return $ascii ? strtolower($str) : utf8fold($str);
        case 'toupper':
            return $ascii ? strtoupper($str) : utf8toupper($str);
    }
    if ($ascii) {
        if ($start === 'strlen') {
            return strlen($str);
        }
        if ($len === false) {
            return substr($str, $start);
        }
        return substr($str, $start, $len);
    }
    $letters = preg_split("/([\\x00-\\x7f]|[\\xc2-\\xdf].|[\\xe0-\\xef]..|[\\xf0-\\xf4]...)/", $str, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
    if ($start === 'strlen') {
        return count($letters);
    }
    if ($len === false) {
        return implode('', array_slice($letters, $start));
    }
    return implode('', array_slice($letters, $start, $len));
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:37,代码来源:xlpage-utf-8.php

示例8: CondText2

function CondText2($pagename, $text, $code = '') {
  global $Conditions, $CondTextPattern, $CondTextReplacement;
  $if = "if$code";
  
  $parts = preg_split("/\\(:(?:{$if}end|$if|else *$if|else$code)\\b\\s*(.*?)\\s*:\\)/", 
                      $text, -1, PREG_SPLIT_DELIM_CAPTURE);
  $x = array_shift($parts);
  while ($parts) {
    list($condspec, $condtext) = array_splice($parts, 0, 2);
    if (!preg_match("/^\\s*(!?)\\s*(\\S*)\\s*(.*?)\\s*$/", $condspec, $match)) continue;
    list($x, $not, $condname, $condparm) = $match;
    if (!isset($Conditions[$condname])) 
      return PPRE($CondTextPattern, $CondTextReplacement, $condtext);
    $tf = @eval("return ({$Conditions[$condname]});");
    if ($tf xor $not)
      return PPRE($CondTextPattern, $CondTextReplacement, $condtext);
  }
  return '';
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:19,代码来源:stdmarkup.php


注:本文中的PPRE函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。