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


PHP GlobToPCRE函数代码示例

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


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

示例1: MatchPageNames

function MatchPageNames($pagelist, $pat) {
  global $Charset, $EnableRangeMatchUTF8;
  # allow range matches in utf8; doesn't work on pmwiki.org and possibly elsewhere
  $pcre8 = (IsEnabled($EnableRangeMatchUTF8,0) && $Charset=='UTF-8')? 'u' : '';
  $pagelist = (array)$pagelist;
  foreach((array)$pat as $p) {
    if (count($pagelist) < 1) break;
    if (!$p) continue;
    switch ($p{0}) {
      case '/': 
        $pagelist = preg_grep($p, $pagelist); 
        continue;
      case '!':
        $pagelist = array_diff($pagelist, preg_grep($p, $pagelist)); 
        continue;
      default:
        list($inclp, $exclp) = GlobToPCRE(str_replace('/', '.', $p));
        if ($exclp) 
          $pagelist = array_diff($pagelist, preg_grep("/$exclp/i$pcre8", $pagelist));
        if ($inclp)
          $pagelist = preg_grep("/$inclp/i$pcre8", $pagelist);
    }
  }
  return $pagelist;
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:25,代码来源:pmwiki.php

示例2: PageListVariables

function PageListVariables(&$list, &$opt, $pn, &$page) {
  switch ($opt['=phase']) {
    case PAGELIST_PRE:
      $varlist = preg_grep('/^\\$/', array_keys($opt));
      if (!$varlist) return 0;
      foreach($varlist as $v) {
        list($inclp, $exclp) = GlobToPCRE($opt[$v]);
        if ($inclp) $opt['=varinclp'][$v] = "/$inclp/i";
        if ($exclp) $opt['=varexclp'][$v] = "/$exclp/i";
      }
      return PAGELIST_ITEM;

    case PAGELIST_ITEM:
      if (@$opt['=varinclp'])
        foreach($opt['=varinclp'] as $v => $pat) 
          if (!preg_match($pat, PageVar($pn, $v))) return 0;
      if (@$opt['=varexclp'])
        foreach($opt['=varexclp'] as $v => $pat) 
           if (preg_match($pat, PageVar($pn, $v))) return 0;
      return 1;
  }
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:22,代码来源:pagelist.php

示例3: PmFormUpdateText

function PmFormUpdateText($pagename, &$text, $msgtext, $opt, $safe_opt)
{
    if (preg_match('/^\\s*([^\\s,]+)/', @$opt['where'], $w)) {
        $where = $w[1];
    } else {
        $where = 'new';
    }
    if (@$opt['where'] != @$safe_opt['where']) {
        list($inclp, $exclp) = GlobToPCRE(@$safe_opt['where']);
        if (!preg_match("/{$inclp}/", $where) || preg_match("/{$exclp}/", $where)) {
            return "\$[Invalid 'where' option] 1";
        }
    }
    if ($where == 'new') {
        if (!isset($text)) {
            $text = $msgtext;
        }
        return NULL;
    }
    $mark = @$safe_opt['=mark'];
    switch ($where) {
        case 'top':
            $ipos = 0;
            $ilen = 0;
            break;
        case 'bottom':
            $ipos = strlen($text);
            $ilen = 0;
            break;
        case 'above':
            $ipos = strpos($text, $mark);
            $ilen = 0;
            break;
        case 'below':
            $ipos = strpos($text, $mark) + strlen($mark);
            $ilen = 0;
            break;
        default:
            return "\$[Invalid 'where' option] 2";
    }
    $text = substr_replace($text, $msgtext, $ipos, $ilen);
    return NULL;
}
开发者ID:jefmud,项目名称:pmwiki-kit-bootstrap-compass,代码行数:43,代码来源:pmform.php

示例4: MxMakePList

function MxMakePList($pagename, $args, $opt = '')
{
    if ($args[0] == '' && $opt == '') {
        return $pagename;
    }
    StopWatch('plist start');
    $grp = PageVar($pagename, '$Group');
    $exlist = array();
    $inlist = array();
    $plist = array();
    if (isset($opt['groups'])) {
        $grps = explode(",", $opt['groups']);
        foreach ($grps as $g) {
            $args[] = "{$g}.*";
        }
        $opt['fmt'] = 'groups';
    }
    if (isset($opt['group'])) {
        $gp = explode(",", $opt['group']);
        foreach ($gp as $g) {
            $args[] = "{$g}.*";
        }
    }
    if (isset($opt['name'])) {
        $ns = explode(",", $opt['name']);
        foreach ($ns as $n) {
            $args[] = "*.{$n}";
        }
    }
    foreach ($args as $src) {
        $pgs = preg_split("/[\\s,|]+/", $src, -1, PREG_SPLIT_NO_EMPTY);
        $plist = array_merge($plist, $pgs);
    }
    foreach ((array) $plist as $pn) {
        //check for exclusions
        if ($pn[0] == '-') {
            $pn = substr($pn, 1);
            //check for group.name pattern
            if (strstr($pn, '.')) {
                $pgpat = $pn;
            } else {
                $pgpat = $grp . "." . $pn;
            }
            //make preg pattern from wildcard pattern
            $prpat = GlobToPCRE(FixGlob($pgpat));
            //make list from preg name pattern
            $exlist = array_merge($exlist, ListPages("/{$prpat['0']}/"));
        } elseif (strstr($pn, '#')) {
            $inlist[] = $pn;
        } else {
            //check for group.name pattern
            if (strstr($pn, '.')) {
                $pgpat = $pn;
            } else {
                $pgpat = $grp . "." . $pn;
            }
            //make preg pattern from wildcard pattern
            $prpat = GlobToPCRE(FixGlob($pgpat));
            //make list from preg name pattern
            $inlist = array_merge($inlist, ListPages("/{$prpat['0']}/"));
        }
    }
    $plist = array_diff($inlist, $exlist);
    sort($plist);
    if ($opt['fmt'] == 'groups') {
        $glist = array();
        foreach ($plist as $p) {
            $pp = explode('.', $p);
            if (in_array($pp[0], $glist)) {
                continue;
            }
            $glist[] = $pp[0];
        }
        $plist = $glist;
    }
    $sep = @$opt['sep'] ? $opt['sep'] : ",";
    $sep = str_replace('\\n', "\n", $sep);
    if ($sep == 'LF') {
        $sep = "\n";
    }
    foreach ($plist as $i => $p) {
        $plist[$i] = @$opt['pre'] . $p . @$opt['suf'];
    }
    StopWatch('plist end');
    return implode($sep, $plist);
}
开发者ID:jefmud,项目名称:pmwiki-kit-bootstrap-compass,代码行数:86,代码来源:powertools.php


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