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


PHP Formatter::get_pagelinks方法代码示例

本文整理汇总了PHP中Formatter::get_pagelinks方法的典型用法代码示例。如果您正苦于以下问题:PHP Formatter::get_pagelinks方法的具体用法?PHP Formatter::get_pagelinks怎么用?PHP Formatter::get_pagelinks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Formatter的用法示例。


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

示例1: macro_WantedPages

function macro_WantedPages($formatter, $value = '')
{
    global $DBInfo;
    $pages = $DBInfo->getPageLists();
    $pagelinks = $formatter->pagelinks;
    // save
    $save = $formatter->sister_on;
    $formatter->sister_on = 0;
    $cache = new Cache_text("pagelinks");
    foreach ($pages as $page) {
        $dum = '';
        $p = new WikiPage($page);
        $f = new Formatter($p);
        $pi = $f->page->get_instructions($dum);
        if (in_array($pi['#format'], array('wiki', 'monimarkup'))) {
            continue;
        }
        $links = $f->get_pagelinks();
        if ($links) {
            $lns =& $links;
            foreach ($lns as $link) {
                if (!$link or $DBInfo->hasPage($link)) {
                    continue;
                }
                if ($link and !$wants[$link]) {
                    $wants[$link] = "[\"{$page}\"]";
                } else {
                    $wants[$link] .= " [\"" . $page . "\"]";
                }
            }
        }
    }
    $formatter->pagelinks = $pagelinks;
    // save
    $formatter->sister_on = $save;
    if (!count($wants)) {
        return '';
    }
    $pagelinks = $formatter->pagelinks;
    // save
    $formatter->sister_on = 0;
    asort($wants);
    $out = "<ul>\n";
    while (list($name, $owns) = each($wants)) {
        $owns = str_replace('<', '&lt;', $owns);
        $nowns = preg_replace_callback("/(" . $formatter->wordrule . ")/", array(&$formatter, 'link_repl'), $owns);
        $out .= "<li>" . $formatter->link_repl($name, htmlspecialchars($name)) . ": {$nowns}</li>";
    }
    $out .= "</ul>\n";
    $formatter->sister_on = $save;
    $formatter->pagelinks = $pagelinks;
    // save
    return $out;
}
开发者ID:NessunKim,项目名称:MW_Skins,代码行数:54,代码来源:WantedPages.php

示例2: macro_WantedPages

function macro_WantedPages($formatter, $value = '', $params = array())
{
    global $DBInfo;
    // set as dynamic macro
    if ($formatter->_macrocache and empty($params['call'])) {
        return $formatter->macro_cache_repl('WantedPages', $value);
    }
    // set default page_limit
    if (empty($params['limit'])) {
        $params['limit'] = 100;
    }
    $offset = 0;
    if (!empty($params['offset'])) {
        if (is_numeric($params['offset']) and $params['offset'] > 0) {
            $offset = $params['offset'];
        }
    }
    $param = array();
    if (!empty($offset)) {
        $param['offset'] = $offset;
    }
    $param['limit'] = $params['limit'];
    $pages = $DBInfo->getPageLists($param);
    $pagelinks = $formatter->pagelinks;
    // save
    $save = $formatter->sister_on;
    $formatter->sister_on = 0;
    $cache = new Cache_text('pagelinks');
    $j = 0;
    foreach ($pages as $page) {
        $dum = '';
        $p = new WikiPage($page);
        $f = new Formatter($p);
        $pi = $f->page->get_instructions($dum);
        if (!in_array($pi['#format'], array('wiki', 'monimarkup'))) {
            continue;
        }
        $links = $f->get_pagelinks();
        if ($links) {
            $lns =& $links;
            foreach ($lns as $link) {
                if (empty($link) or $DBInfo->hasPage($link)) {
                    continue;
                }
                if (empty($wants[$link])) {
                    $wants[$link] = array('[["' . $page . '"]]');
                } else {
                    $wants[$link][] = '[["' . $page . '"]]';
                }
            }
        }
        $j++;
    }
    if (!count($wants)) {
        return '';
    }
    $pagelinks = $formatter->pagelinks;
    // save
    $formatter->sister_on = 0;
    asort($wants);
    $out = "<ul>\n";
    $old_owns = null;
    foreach ($wants as $name => $owns) {
        if ($old_owns != $owns) {
            $olinks = array_map(array($formatter, 'link_repl'), $owns);
            $olink = implode(', ', $olinks);
            if ($old_owns) {
                $out .= "</ul>\n</li>\n";
            }
            $out .= "<li>\n" . $olink . '<ul>';
            $old_owns = $owns;
        }
        $out .= '<li>' . $formatter->link_repl($name, _html_escape($name)) . '</li>' . "\n";
    }
    $out .= "</ul>\n</li>\n</ul>\n";
    $out .= $formatter->link_to("?action=wantedpages&amp;offset={$j}", _("Show next page"));
    $formatter->sister_on = $save;
    $formatter->pagelinks = $pagelinks;
    // restore
    return $out;
}
开发者ID:ahastudio,项目名称:moniwiki,代码行数:81,代码来源:WantedPages.php


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