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


PHP PCache函数代码示例

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


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

示例1: HandleUpload

function HandleUpload($pagename)
{
    global $FmtV, $UploadExtMax, $HandleUploadFmt, $PageStartFmt, $PageEndFmt, $PageUploadFmt;
    $page = RetrieveAuthPage($pagename, 'upload');
    if (!$page) {
        Abort("?cannot upload to {$pagename}");
    }
    PCache($pagename, $page);
    $FmtV['$UploadName'] = MakeUploadName($pagename, @$_REQUEST['upname']);
    $upresult = @$_REQUEST['upresult'];
    $FmtV['$upext'] = @$_REQUEST['upext'];
    $FmtV['$upmax'] = @$_REQUEST['upmax'];
    $FmtV['$UploadResult'] = $upresult ? FmtPageName("<i>\$UploadName</i>: \$[UL{$upresult}]", $pagename) : '';
    SDV($HandleUploadFmt, array(&$PageStartFmt, &$PageUploadFmt, &$PageEndFmt));
    PrintFmt($pagename, $HandleUploadFmt);
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:16,代码来源:upload.php

示例2: WikiGalleryThumbnail

function WikiGalleryThumbnail($pagename, $auth = "read")
{
    global $WikiGallery_UseAuthorization, $WikiGalleryThumbProviders, $WikiGallery_DefaultGroup;
    // get filename
    if (!isset($_GET["image"])) {
        Abort('no image given');
    }
    if (!isset($_GET["group"])) {
        $group = $WikiGallery_DefaultGroup;
    } else {
        $group = $_GET["group"];
    }
    $path = WikiGallerySecurePath(urldecode($_GET["image"]));
    // group exists?
    if (!isset($WikiGalleryThumbProviders[$group])) {
        Abort("Invalid gallery group \"{$group}\" given");
    }
    $provider =& $WikiGalleryThumbProviders[$group];
    // get size
    $width = intval(@$_GET["width"]);
    $height = intval(@$_GET["height"]);
    if ($width < 0 || $width > 1600) {
        $width = 0;
    }
    if ($height < 0 || $height > 1200) {
        $height = 0;
    }
    $resizeMode = urldecode(@$_GET["mode"]);
    // check authorization
    $pagename = fileNameToPageName($path);
    if ($WikiGallery_UseAuthorization) {
        $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
        if (!$page) {
            Abort('?cannot read $pagename');
        }
        PCache($pagename, $page);
    }
    // get image
    $provider->thumb($path, $width, $height, $resizeMode);
    exit;
}
开发者ID:gregorklaric,项目名称:wikigallery,代码行数:41,代码来源:thumb.php

示例3: HandleAttr

function HandleAttr($pagename)
{
    global $PageAttrFmt, $PageStartFmt, $PageEndFmt;
    $page = RetrieveAuthPage($pagename, 'attr');
    if (!$page) {
        Abort("?unable to read {$pagename}");
    }
    PCache($pagename, $page);
    SDV($PageAttrFmt, "<h1 class='wikiaction'>\$[\$FullName Attributes]</h1>\n    <p>Enter new attributes for this page below.  Leaving a field blank\n    will leave the attribute unchanged.  To clear an attribute, enter\n    'clear'.</p>");
    SDV($HandleAttrFmt, array(&$PageStartFmt, &$PageAttrFmt, 'function:PrintAttrForm', &$PageEndFmt));
    PrintFmt($pagename, $HandleAttrFmt);
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:12,代码来源:pmwiki.php

示例4: HandleFeed

function HandleFeed($pagename, $auth = 'read')
{
    global $FeedFmt, $action, $PCache, $FmtV, $ISOTimeFmt, $RSSTimeFmt, $FeedOpt, $FeedDescPatterns, $CategoryGroup, $EntitiesTable;
    SDV($ISOTimeFmt, '%Y-%m-%dT%H:%M:%SZ');
    SDV($RSSTimeFmt, 'D, d M Y H:i:s \\G\\M\\T');
    SDV($FeedDescPatterns, array('/<[^>]*$/' => ' ', '/\\w+$/' => '', '/<[^>]+>/' => ''));
    SDVA($FeedCategoryOpt, array('link' => $pagename, 'readf' => 1));
    SDVA($FeedTrailOpt, array('trail' => $pagename, 'count' => 10, 'readf' => 1));
    $f = $FeedFmt[$action];
    $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
    if (!$page) {
        Abort("?cannot generate feed");
    }
    $feedtime = $page['time'];
    # determine list of pages to display
    if (@($_REQUEST['trail'] || $_REQUEST['group'] || $_REQUEST['link'])) {
        $opt['readf'] = 1;
    } else {
        if ($action == 'dc') {
            $opt = array();
        } else {
            if (preg_match("/^{$CategoryGroup}\\./", $pagename)) {
                $opt = $FeedCategoryOpt;
            } else {
                $opt = $FeedTrailOpt;
            }
        }
    }
    if (!$opt) {
        PCache($pagename, $page);
        $pagelist = array(&$PCache[$pagename]);
    } else {
        $opt = array_merge($opt, @$_REQUEST);
        $pagelist = MakePageList($pagename, $opt);
    }
    # process list of pages in feed
    $rdfseq = '';
    foreach ($pagelist as $page) {
        $pn = $page['name'];
        if (!PageExists($pn)) {
            continue;
        }
        $pl[] = $pn;
        if (@$opt['count'] && count($pl) >= $opt['count']) {
            break;
        }
        $rdfseq .= FmtPageName("<rdf:li resource=\"\$PageUrl\" />\n", $pn);
        if ($page['time'] > $feedtime) {
            $feedtime = $page['time'];
        }
    }
    $pagelist = $pl;
    $FmtV['$FeedRDFSeq'] = $rdfseq;
    $FmtV['$FeedISOTime'] = gmstrftime($ISOTimeFmt, $feedtime);
    $FmtV['$FeedRSSTime'] = gmdate($RSSTimeFmt, $feedtime);
    # format start of feed
    $out = FmtPageName($f['feed']['_start'], $pagename);
    # format feed elements
    foreach ($f['feed'] as $k => $v) {
        if ($k[0] == '_' || !$v) {
            continue;
        }
        $x = FmtPageName($v, $pagename);
        if (!$x) {
            continue;
        }
        $out .= $v[0] == '<' ? $x : "<{$k}>{$x}</{$k}>\n";
    }
    # format items in feed
    if (@$f['feed']['_items']) {
        $out .= FmtPageName($f['feed']['_items'], $pagename);
    }
    foreach ($pagelist as $pn) {
        $page =& $PCache[$pn];
        $FmtV['$ItemDesc'] = @$page['description'] ? $page['description'] : trim(preg_replace(array_keys($FeedDescPatterns), array_values($FeedDescPatterns), @$page['excerpt']));
        $FmtV['$ItemISOTime'] = gmstrftime($ISOTimeFmt, $page['time']);
        $out .= FmtPageName($f['item']['_start'], $pn);
        foreach ((array) @$f['item'] as $k => $v) {
            if ($k[0] == '_' || !$v) {
                continue;
            }
            if (is_callable($v)) {
                $out .= $v($pn, $page, $k);
                continue;
            }
            if (strpos($v, '$LastModifiedBy') !== false && !@$page['author']) {
                continue;
            }
            if (strpos($v, '$Category') !== false) {
                if (preg_match_all("/(?<=^|,){$CategoryGroup}\\.([^,]+)/", @$page['targets'], $match)) {
                    foreach ($match[1] as $c) {
                        $FmtV['$Category'] = $c;
                        $out .= FmtPageName($v, $pn);
                    }
                }
                continue;
            }
            $x = FmtPageName($v, $pn);
            if (!$x) {
                continue;
//.........这里部分代码省略.........
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:101,代码来源:feeds.php

示例5: write

 function write($pagename, $page)
 {
     global $Now, $Version, $Newline;
     $page['name'] = $pagename;
     $page['time'] = $Now;
     $page['host'] = $_SERVER['REMOTE_ADDR'];
     $page['agent'] = @$_SERVER['HTTP_USER_AGENT'];
     $page['rev'] = @$page['rev'] + 1;
     unset($page['version']);
     unset($page['newline']);
     uksort($page, 'CmpPageAttr');
     $s = false;
     $pagefile = $this->pagefile($pagename);
     $dir = dirname($pagefile);
     mkdirp($dir);
     if (!file_exists("{$dir}/.htaccess") && ($fp = @fopen("{$dir}/.htaccess", "w"))) {
         fwrite($fp, "Order Deny,Allow\nDeny from all\n");
         fclose($fp);
     }
     if ($pagefile && ($fp = fopen("{$pagefile},new", "w"))) {
         $s = true && fputs($fp, "version={$Version} ordered=1\nnewline={$Newline}\n");
         foreach ($page as $k => $v) {
             if ($k > '' && $k[0] != '=') {
                 $s = $s && fputs($fp, str_replace("\n", $Newline, "{$k}={$v}") . "\n");
             }
         }
         $s = fclose($fp) && $s;
         if (file_exists($pagefile)) {
             $s = $s && unlink($pagefile);
         }
         $s = $s && rename("{$pagefile},new", $pagefile);
     }
     $s && fixperms($pagefile);
     if (!$s) {
         Abort("Cannot write page to {$pagename} ({$pagefile})...changes not saved");
     }
     PCache($pagename, $page);
 }
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:38,代码来源:pmwiki.php

示例6: HandleDiff

function HandleDiff($pagename, $auth = 'read')
{
    global $HandleDiffFmt, $PageStartFmt, $PageDiffFmt, $PageEndFmt;
    $page = RetrieveAuthPage($pagename, $auth, true);
    if (!$page) {
        Abort("?cannot diff {$pagename}");
    }
    PCache($pagename, $page);
    SDV($HandleDiffFmt, array(&$PageStartFmt, &$PageDiffFmt, "<div id='wikidiff'>", 'function:PrintDiff', '</div>', &$PageEndFmt));
    PrintFmt($pagename, $HandleDiffFmt);
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:11,代码来源:pagerev.php

示例7: HandleSearchA

function HandleSearchA($pagename, $level = 'read') {
  global $PageSearchForm, $FmtV, $HandleSearchFmt, 
    $PageStartFmt, $PageEndFmt;
  SDV($HandleSearchFmt,array(&$PageStartFmt, '$PageText', &$PageEndFmt));
  SDV($PageSearchForm, '$[{$SiteGroup}/Search]');
  $form = RetrieveAuthPage($pagename, $level, true, READPAGE_CURRENT);
  if (!$form) Abort("?unable to read $pagename");
  PCache($pagename, $form);
  $text = preg_replace('/\\[([=@])(.*?)\\1\\]/s', ' ', @$form['text']);
  if (!preg_match('/\\(:searchresults(\\s.*?)?:\\)/', $text))
    foreach((array)$PageSearchForm as $formfmt) {
      $form = ReadPage(FmtPageName($formfmt, $pagename), READPAGE_CURRENT);
      if ($form['text']) break;
    }
  $text = @$form['text'];
  if (!$text) $text = '(:searchresults:)';
  $FmtV['$PageText'] = MarkupToHTML($pagename,$text);
  PrintFmt($pagename, $HandleSearchFmt);
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:19,代码来源:pagelist.php

示例8: ListPageLinks

function ListPageLinks($pagename, $list)
{
    global $GroupPattern, $WikiWordPattern;
    $g = FmtPageName('$Group', $pagename);
    $dummy = 'AB101BA';
    $r = array();
    $page = RetrieveAuthPage($pagename, $list == 'all' ? 'read' : 'edit');
    if ($page) {
        $text = $page['text'];
    } else {
        Abort("cannot rename '{$pagename}'");
    }
    PCache($pagename, $page);
    preg_match_all("/(\\[[=@].*?[=@]\\])|(\\[\\[([^#].*?)\\]\\])|([`:\\/\$])?\\b(({$GroupPattern}([\\/.]))?{$WikiWordPattern})/", $text, $m);
    for ($i = 0; $i < count($m[0]); $i++) {
        $p = QualifyUnqualifiedLinks($g, $dummy, preg_replace("/\\{(\\\$.*?)\\}/e", "FmtPageName('\$1',\$pagename)", $m[0][$i]));
        if (strstr($p, $dummy)) {
            $p = str_replace("{$dummy}/", "{$g}.", $p);
            $r[] = $m[0][$i][0] == '[' ? MakePageName($pagename, FLRef($p)) : $p;
        } elseif ($list == 'all') {
            if (preg_match("/^({$GroupPattern}([\\/.]){$WikiWordPattern})/", $p, $w)) {
                $r[] = str_replace('/', '.', $w[1]);
            } elseif (preg_match("/^\\[\\[(.*?)\\]\\]/", $p, $f)) {
                $l = FLRef($f[1]);
                if (preg_match("/^[^~!:.\\/]+([.\\/][^.\\/]+)?\$/", $l, $fl)) {
                    $r[] = MakePageName($pagename, $l);
                }
            }
        }
    }
    return $r;
}
开发者ID:jefmud,项目名称:pmwiki-kit-bootstrap-compass,代码行数:32,代码来源:rename.php

示例9: HandleSearchA

function HandleSearchA($pagename, $level = 'read')
{
    global $PageSearchForm, $FmtV, $HandleSearchFmt, $PageStartFmt, $PageEndFmt;
    SDV($HandleSearchFmt, array(&$PageStartFmt, '$PageText', &$PageEndFmt));
    SDV($PageSearchForm, '$[$SiteGroup/Search]');
    PCache($pagename, RetrieveAuthPage($pagename, 'read'));
    $form = ReadPage(FmtPageName($PageSearchForm, $pagename), READPAGE_CURRENT);
    $text = @$form['text'];
    if (!$text) {
        $text = '(:searchresults:)';
    }
    $FmtV['$PageText'] = MarkupToHTML($pagename, $text);
    PrintFmt($pagename, $HandleSearchFmt);
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:14,代码来源:pagelist.php

示例10: HandleRefCount

function HandleRefCount($pagename, $auth='read') {
  global $HandleRefCountFmt,$PageStartFmt,$PageEndFmt;
  $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
  if (!$page) Abort('?unauthorized');
  PCache($pagename, $page);
  SDV($HandleRefCountFmt,array(&$PageStartFmt,
    'function:PrintRefCount',&$PageEndFmt));
  PrintFmt($pagename,$HandleRefCountFmt);
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:9,代码来源:refcount.php

示例11: HandleSearchA

function HandleSearchA($pagename, $level = 'read')
{
    global $PageSearchForm, $FmtV, $HandleSearchFmt, $PageStartFmt, $PageEndFmt;
    SDV($HandleSearchFmt, array(&$PageStartFmt, '$PageText', &$PageEndFmt));
    SDV($PageSearchForm, '$[$SiteGroup/Search]');
    $form = RetrieveAuthPage($pagename, 'read', true, READPAGE_CURRENT);
    PCache($pagename, $form);
    if (!preg_match('/\\(:searchresults(\\s.*?)?:\\)/', $form['text'])) {
        foreach ((array) $PageSearchForm as $formfmt) {
            $form = ReadPage(FmtPageName($formfmt, $pagename), READPAGE_CURRENT);
            if ($form['text']) {
                break;
            }
        }
    }
    $text = @$form['text'];
    if (!$text) {
        $text = '(:searchresults:)';
    }
    $FmtV['$PageText'] = MarkupToHTML($pagename, $text);
    PrintFmt($pagename, $HandleSearchFmt);
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:22,代码来源:pagelist.php

示例12: write_xml

 function write_xml($pagename, $page)
 {
     global $Now, $Version, $Charset;
     $page['name'] = $pagename;
     $page['time'] = $Now;
     $page['host'] = $_SERVER['REMOTE_ADDR'];
     $page['agent'] = @$_SERVER['HTTP_USER_AGENT'];
     $page['rev'] = @$page['rev'] + 1;
     unset($page['version']);
     unset($page['newline']);
     uksort($page, 'CmpPageAttr');
     $s = false;
     $pagefile = $this->pagefile($pagename);
     $dir = dirname($pagefile);
     mkdirp($dir);
     if ($pagefile && ($fp = fopen("{$pagefile},new", "w"))) {
         $x = "<?xml version=\"1.0\" encoding=\"{$Charset}\"?>\n<page xmlns=\"http://www.pmwiki.org/cookbook/xmlpage\" version=\"{$Version}\">\n";
         $s = true && fputs($fp, $x);
         $sz = strlen($x);
         foreach ($page as $k => $v) {
             if ($k > '' && $k[0] != '=') {
                 $v = htmlspecialchars($v, ENT_NOQUOTES, $Charset);
                 if (preg_match("/^([a-z]+)(?::(\\d+))(?::(\\d+):)?\$/", $k, $m)) {
                     $p = empty($m[3]) ? "" : " prev=\"{$m[3]}\"";
                     $x = "<{$m[1]} time=\"{$m[2]}\"{$p}>{$v}</{$m[1]}>\n";
                 } else {
                     $x = "<{$k}>{$v}</{$k}>\n";
                 }
                 $s = $s && fputs($fp, $x);
                 $sz += strlen($x);
             }
         }
         $x = "</page>\n";
         $s = $s && fputs($fp, $x);
         $sz += strlen($x);
         $s = fclose($fp) && $s;
         $s = $s && filesize("{$pagefile},new") > $sz * 0.95;
         if (file_exists($pagefile)) {
             $s = $s && unlink($pagefile);
         }
         $s = $s && rename("{$pagefile},new", $pagefile);
     }
     $s && fixperms($pagefile);
     if (!$s) {
         Abort("Cannot write page to {$pagename} ({$pagefile})...changes not saved");
     }
     PCache($pagename, $page);
 }
开发者ID:anomen-s,项目名称:pmwiki-recipes,代码行数:48,代码来源:XMLPageStore.php

示例13: HandleFastCacheBrowse

function HandleFastCacheBrowse($pagename, $auth = 'read')
{
    # handle display of a page
    global $DefaultPageTextFmt, $PageNotFoundHeaderFmt, $HTTPHeaders, $EnableHTMLCache, $NoHTMLCache, $PageCacheFile, $LastModTime, $IsHTMLCached, $FmtV, $HandleBrowseFmt, $PageStartFmt, $PageEndFmt, $PageRedirectFmt;
    ## begin added
    global $FastCachePage, $FastCacheDir, $FastCacheValid, $FastCacheSuffix;
    if (!$FastCacheValid || !$FastCacheDir) {
        HandleBrowse($pagename, $auth);
        return;
    }
    SDV($FastCacheSuffix, '.html');
    $fcfile = "{$FastCacheDir}/{$pagename}{$FastCacheSuffix}";
    if (@filemtime($fcfile) > $LastModTime) {
        if ($FastCachePage = file_get_contents($fcfile)) {
            StopWatch("HandleFastCacheBrowse: using FastCached copy of {$pagename}");
            echo $FastCachePage;
        } else {
            $FastCacheValid = FALSE;
            StopWatch("HandleFastCacheBrowse: read error on {$fcfile}");
            HandleBrowse($pagename, $auth);
        }
        return;
    }
    ## end added
    $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
    if (!$page) {
        Abort("?cannot read {$pagename}");
    }
    PCache($pagename, $page);
    if (PageExists($pagename)) {
        $text = @$page['text'];
    } else {
        $FastCacheValid = FALSE;
        ## added
        SDV($DefaultPageTextFmt, '(:include $[{$SiteGroup}.PageNotFound]:)');
        $text = FmtPageName($DefaultPageTextFmt, $pagename);
        SDV($PageNotFoundHeaderFmt, 'HTTP/1.1 404 Not Found');
        SDV($HTTPHeaders['status'], $PageNotFoundHeaderFmt);
    }
    $opt = array();
    SDV($PageRedirectFmt, "<p><i>(\$[redirected from] <a rel='nofollow'\n    href='{\$PageUrl}?action=edit'>{\$FullName}</a>)</i></p>\$HTMLVSpace\n");
    if (@(!$_GET['from'])) {
        $opt['redirect'] = 1;
        $PageRedirectFmt = '';
    } else {
        $PageRedirectFmt = FmtPageName($PageRedirectFmt, $_GET['from']);
    }
    if (@$EnableHTMLCache && !$NoHTMLCache && $PageCacheFile && @filemtime($PageCacheFile) > $LastModTime) {
        list($ctext) = unserialize(file_get_contents($PageCacheFile));
        $FmtV['$PageText'] = "<!--cached-->{$ctext}";
        $IsHTMLCached = 1;
        StopWatch("HandleFastCacheBrowse: using HTMLCached copy");
        ## modified
    } else {
        $IsHTMLCached = 0;
        $text = '(:groupheader:)' . @$text . '(:groupfooter:)';
        $t1 = time();
        $FmtV['$PageText'] = MarkupToHTML($pagename, $text, $opt);
        if (@$EnableHTMLCache > 0 && !$NoHTMLCache && $PageCacheFile && time() - $t1 + 1 >= $EnableHTMLCache) {
            $fp = @fopen("{$PageCacheFile},new", "x");
            if ($fp) {
                StopWatch("HandleFastCacheBrowse: HTMLCaching page");
                ## modified
                fwrite($fp, serialize(array($FmtV['$PageText'])));
                fclose($fp);
                rename("{$PageCacheFile},new", $PageCacheFile);
            }
        }
    }
    SDV($HandleBrowseFmt, array(&$PageStartFmt, &$PageRedirectFmt, '$PageText', &$PageEndFmt));
    ## begin modified
    if ($FastCacheValid) {
        ob_start();
        PrintFmt($pagename, $HandleBrowseFmt);
        $FastCachePage = ob_get_contents();
        ob_end_flush();
        mkdirp(dirname($fcfile));
        if ($FastCacheValid && ($fc = fopen("{$fcfile},new", 'x'))) {
            StopWatch("HandleFastCacheBrowse: FastCaching {$pagename}");
            fwrite($fc, $FastCachePage);
            fclose($fc);
            rename("{$fcfile},new", $fcfile);
        } else {
            StopWatch("HandleFastCacheBrowse: error writing cache to {$fcfile},new");
        }
    } else {
        PrintFmt($pagename, $HandleBrowseFmt);
    }
    ## end modified
}
开发者ID:jefmud,项目名称:pmwiki-kit-bootstrap-compass,代码行数:90,代码来源:fastcache.php

示例14: RenderSidePart

function RenderSidePart($pagename, $params)
{
    $pagelist = preg_split('/\\s+/', $params, -1, PREG_SPLIT_NO_EMPTY);
    $class_title = array_shift($pagelist);
    $class = array_shift($pagelist);
    $id = array_shift($pagelist);
    list($text, $title) = RetrievePageMarkup($pagelist);
    if (!isset($text)) {
        return;
    }
    $orig_page_title = PageVar($pagename, '$Title');
    print "<div class='{$class_title}'>{$title}</div><div class='{$class}' id='{$id}'>";
    print MarkupToHTML($pagename, $text);
    print "</div><!-- id='{$id}' -->";
    PCache($pagename, array('title' => SetProperty($pagename, 'title', $orig_page_title)));
}
开发者ID:anomen-s,项目名称:pmwiki-recipes,代码行数:16,代码来源:monobook.php

示例15: HandleFeed

function HandleFeed($pagename, $auth = 'read') {
  global $FeedFmt, $action, $PCache, $FmtV, $TimeISOZFmt, $RSSTimeFmt,
    $FeedPageListOpt, $FeedCategoryOpt, $FeedTrailOpt,
    $FeedDescPatterns, $CategoryGroup, $EntitiesTable;
  SDV($RSSTimeFmt, 'D, d M Y H:i:s \G\M\T');
  SDV($FeedDescPatterns, 
    array('/<[^>]*$/' => ' ', '/\\w+$/' => '', '/<[^>]+>/' => ''));
  $FeedPageListOpt = (array)@$FeedPageListOpt;
  SDVA($FeedCategoryOpt, array('link' => $pagename));
  SDVA($FeedTrailOpt, array('trail' => $pagename, 'count' => 10));

  $f = $FeedFmt[$action];
  $page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
  if (!$page) Abort("?cannot generate feed");
  $feedtime = $page['time'];

  # determine list of pages to display
  if (@($_REQUEST['trail'] || $_REQUEST['group'] || $_REQUEST['link'] 
        || $_REQUEST['name'])) 
    $opt = $FeedPageListOpt;
  else if (preg_match("/^$CategoryGroup\\./", $pagename)) 
    $opt = $FeedCategoryOpt;
  else if ($action != 'dc') $opt = $FeedTrailOpt;
  else { 
    PCache($pagename, $page); 
    $pagelist = array($pagename); 
  }
  if (!@$pagelist) {
    $opt = array_merge($opt, @$_REQUEST);
    $pagelist = MakePageList($pagename, $opt, 0);
  }

  # process list of pages in feed
  $rdfseq = '';
  $pl = array();
  foreach($pagelist as $pn) {
    if (!PageExists($pn)) continue;
    if (!isset($PCache[$pn]['time'])) 
      { $page = ReadPage($pn, READPAGE_CURRENT); PCache($pn, $page); }
    $pc = & $PCache[$pn];
    $pl[] = $pn;
    $rdfseq .= FmtPageName("<rdf:li resource=\"{\$PageUrl}\" />\n", $pn);
    if ($pc['time'] > $feedtime) $feedtime = $pc['time'];
    if (@$opt['count'] && count($pl) >= $opt['count']) break;
  }
  $pagelist = $pl;

  $FmtV['$FeedRDFSeq'] = $rdfseq;
  $FmtV['$FeedISOTime'] = gmstrftime($TimeISOZFmt, $feedtime);
  $FmtV['$FeedRSSTime'] = gmdate($RSSTimeFmt, $feedtime);
  # format start of feed
  $out = FmtPageName($f['feed']['_start'], $pagename);

  # format feed elements
  foreach($f['feed'] as $k => $v) {
    if ($k{0} == '_' || !$v) continue;
    $x = FmtPageName($v, $pagename);
    if (!$x) continue;
    $out .= ($v{0} == '<') ? $x : "<$k>$x</$k>\n";
  }

  # format items in feed
  if (@$f['feed']['_items']) 
    $out .= FmtPageName($f['feed']['_items'], $pagename);
  foreach($pagelist as $pn) {
    $page = &$PCache[$pn];
    $FmtV['$ItemDesc'] = @$page['description'];
    $FmtV['$ItemISOTime'] = gmstrftime($TimeISOZFmt, $page['time']);
    $FmtV['$ItemRSSTime'] = gmdate($RSSTimeFmt, $page['time']);

    $out .= FmtPageName($f['item']['_start'], $pn);
    foreach((array)@$f['item'] as $k => $v) {
      if ($k{0} == '_' || !$v) continue;
      if (is_callable($v)) { $out .= $v($pn, $page, $k); continue; }
      if (strpos($v, '$LastModifiedBy') !== false && !@$page['author']) 
        continue;
      if (strpos($v, '$Category') !== false) {
        if (preg_match_all("/(?<=^|,)$CategoryGroup\\.([^,]+)/", 
                           @$page['targets'], $match)) {
          foreach($match[1] as $c) {
            $FmtV['$Category'] = $c;
            $out .= FmtPageName($v, $pn);
          }
        }
        continue;
      }
      $x = FmtPageName($v, $pn);
      if (!$x) continue;
      $out .= ($v{0} == '<') ? $x : "<$k>$x</$k>\n";
    }
    $out .= FmtPageName($f['item']['_end'], $pn);
  } 
  $out .= FmtPageName($f['feed']['_end'], $pagename);
  foreach((array)@$f['feed']['_header'] as $fmt)
    header(FmtPageName($fmt, $pagename));
  print str_replace(array_keys($EntitiesTable),
                    array_values($EntitiesTable), $out);
}
开发者ID:BogusCurry,项目名称:pmwiki,代码行数:98,代码来源:feeds.php


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