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


PHP WikiPage::get_raw_body方法代码示例

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


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

示例1: filter_antispam

function filter_antispam($formatter, $value, $options)
{
    global $Config;
    $blacklist_pages = array('BadContent', 'LocalBadContent');
    $whitelist_pages = array('GoodContent', 'LocalGoodContent');
    if (!in_array($formatter->page->name, $blacklist_pages) and !in_array($formatter->page->name, $whitelist_pages)) {
        $badcontents_file = !empty($options['.badcontents']) ? $options['.badcontents'] : $Config['badcontents'];
        if (!file_exists($badcontents_file)) {
            return $value;
        }
        $badcontent = file_get_contents($badcontents_file);
        foreach ($blacklist_pages as $list) {
            $p = new WikiPage($list);
            if ($p->exists()) {
                $badcontent .= $p->get_raw_body();
            }
        }
        if (!$badcontent) {
            return $value;
        }
        $badcontents = explode("\n", $badcontent);
        $pattern[0] = '';
        $i = 0;
        foreach ($badcontents as $line) {
            if (isset($line[0]) and $line[0] == '#') {
                continue;
            }
            $line = preg_replace('/[ ]*#.*$/', '', $line);
            $test = @preg_match("/{$line}/i", "");
            if ($test === false) {
                $line = preg_quote($line, '/');
            }
            if ($line) {
                $pattern[$i] .= $line . '|';
            }
            if (strlen($pattern[$i]) > 4000) {
                $i++;
                $pattern[$i] = '';
            }
        }
        for ($k = 0; $k <= $i; $k++) {
            $pattern[$k] = '/(' . substr($pattern[$k], 0, -1) . ')/i';
        }
        #foreach ($whitelist_pages as $list) {
        #    $p=new WikiPage($list);
        #    if ($p->exists()) $goodcontent.=$p->get_raw_body();
        #}
        #$goodcontents=explode("\n",$goodcontent);
        return preg_replace($pattern, "''''''[[HTML(<span class='blocked'>)]]\\1[[HTML(</span>)]]''''''", $value);
    }
    return $value;
}
开发者ID:ahastudio,项目名称:moniwiki,代码行数:52,代码来源:antispam.php

示例2: macro_Edit


//.........这里部分代码省略.........
        $preview_anchor = '#preview';
    } else {
        $preview_anchor = '';
    }
    if (isset($options['page'][0])) {
        $previewurl = $formatter->link_url(_rawurlencode($options['page']), $preview_anchor);
    } else {
        $previewurl = $formatter->link_url($formatter->page->urlname, $preview_anchor);
    }
    $menu = '';
    $sep = '';
    if (empty($DBInfo->use_resizer) and (empty($options['noresizer']) or !$use_js)) {
        $sep = ' | ';
        $menu = $formatter->link_to("?action=edit&amp;rows=" . ($rows - 3), _("ReduceEditor"));
        $menu .= $sep . $formatter->link_to("?action=edit&amp;rows=" . ($rows + 3), _("EnlargeEditor"));
    }
    if (empty($options['nomenu'])) {
        $menu .= $sep . $formatter->link_tag('InterWiki', "", _("InterWiki"));
        $sep = ' | ';
        $menu .= $sep . $formatter->link_tag('HelpOnEditing', "", _("HelpOnEditing"));
    }
    $form .= $menu;
    $ajax = '';
    $js = '';
    if (!empty($options['action_mode']) and $options['action_mode'] == 'ajax') {
        $ajax = " onsubmit='savePage(this);return false'";
    }
    $formh = sprintf('<form id="editform" method="post" action="%s"' . $ajax . '>', $previewurl);
    if ($text) {
        $raw_body = preg_replace("/\r\n|\r/", "\n", $text);
    } else {
        if (!empty($options['template'])) {
            $p = new WikiPage($options['template']);
            $raw_body = preg_replace("/\r\n|\r/", "\n", $p->get_raw_body());
        } else {
            if (isset($formatter->_raw_body)) {
                # low level XXX
                $raw_body = preg_replace("/\r\n|\r/", "\n", $formatter->_raw_body);
            } else {
                if ($options['mode'] != 'edit' and $formatter->page->exists()) {
                    $raw_body = preg_replace("/\r\n|\r/", "\n", $formatter->page->_get_raw_body());
                    if (isset($options['section'])) {
                        $sections = _get_sections($raw_body);
                        if ($sections[$options['section']]) {
                            $raw_body = $sections[$options['section']];
                        }
                        #else ignore
                    }
                } else {
                    $raw_body = '';
                    if (!empty($options['orig_pagename'])) {
                        $raw_body = "#title {$options['orig_pagename']}\n";
                    }
                    if (strpos($options['page'], ' ') > 0) {
                        #$raw_body="#title $options[page]\n";
                        $options['page'] = '["' . $options['page'] . '"]';
                    }
                    $guide = sprintf(_("Describe %s here"), $options['page']);
                    if (empty($DBInfo->use_edit_placeholder)) {
                        $raw_body .= $guide;
                        $guide = '';
                    } else {
                        $guide = ' placeholder="' . _html_escape($guide) . '"';
                    }
                    $js = <<<EOF
<script type="text/javascript">
开发者ID:reviforks,项目名称:moniwiki,代码行数:67,代码来源:wikilib.php

示例3: processor_bts

function processor_bts($formatter, $value = '', $options = '')
{
    global $DBInfo;
    $rating_script =& $GLOBALS['rating_script'];
    $script = <<<SCRIPT
<script type="text/javascript">
/*<![CDATA[*/
/* from bugzilla script with small fix */
  /* Outputs a link to call replyToComment(); used to reduce HTML output */
  function addReplyLink(id) {
    /* XXX this should really be updated to use the DOM Core's
     * createElement, but finding a container isn't trivial */
    document.write('[<a href="#add_comment" onclick="replyToComment(' + 
        id + ');">reply<' + '/a>]');
  }

  /* Adds the reply text to the `comment' textarea */
  function replyToComment(id) {
    /* pre id="comment_name_N" */
    var text_elem = document.getElementById('comment_text_'+id);
    var text = getText(text_elem);

    /* make sure we split on all newlines -- IE or Moz use \\r and \\n
     * respectively */
    text = text.split(/\\r|\\n/);

    var replytext = "";
    for (var i=0; i < text.length; i++) {
        replytext += "> " + text[i] + "\\n"; 
    }

    replytext = "(In reply to comment #" + id + ")\\n" + replytext + "\\n";

    /* <textarea name="savetext"> */
    var textarea = document.getElementsByTagName('textarea');
    textarea[0].value += replytext;

    textarea[0].focus();
  }

  if (!Node) {
    /* MSIE doesn't define Node, so provide a compatibility array */
    var Node = {
        TEXT_NODE: 3,
        ENTITY_REFERENCE_NODE: 5
    };
  }

  /* Concatenates all text from element's childNodes. This is used
   * instead of innerHTML because we want the actual text (and
   * innerText is non-standard) */
  function getText(element) {
    var child, text = "";
    for (var i=0; i < element.childNodes.length; i++) {
        child = element.childNodes[i];
        var type = child.nodeType;
        if (type == Node.TEXT_NODE || type == Node.ENTITY_REFERENCE_NODE) {
            text += child.nodeValue;
        } else {
            /* recurse into nodes of other types */
            text += getText(child);
        }
    }
    return text;
  }
/*]]>*/
</script>
SCRIPT;
    if ($value[0] == '#' and $value[1] == '!') {
        list($arg, $value) = explode("\n", $value, 2);
    }
    if (!empty($arg)) {
        # get parameters
        list($tag, $user, $date, $title) = explode(" ", $line, 4);
        if (preg_match('/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/', $user)) {
            $user = "Anonymous[{$user}]";
        }
        if ($date && $date[10] == 'T') {
            $date[10] = ' ';
            $time = strtotime($date . ' GMT');
            $date = '@ ' . date('Y-m-d [h:i a]', $time);
        }
    }
    $bts_conf = 'BugTrack/Config';
    if ($DBInfo->hasPage($bts_conf)) {
        $p = new WikiPage($bts_conf);
        $config_raw = $p->get_raw_body();
        $confs = _get_btsConfig($config_raw);
        #print_r($confs);
    }
    $body = $value;
    # parse metadata
    $meta = '';
    while (true) {
        list($line, $body) = explode("\n", $body, 2);
        if (isset($line[0]) and $line[0] == '#') {
            continue;
        }
        if (strpos($line, ':') === false or !trim($line)) {
            break;
//.........这里部分代码省略.........
开发者ID:ahastudio,项目名称:moniwiki,代码行数:101,代码来源:bts.php

示例4: macro_ISBN

function macro_ISBN($formatter, $value = "")
{
    global $DBInfo;
    // http://www.isbn-international.org/en/identifiers/allidentifiers.html
    $default_map = array('89' => 'Aladdin');
    $ISBN_MAP = "IsbnMap";
    $DEFAULT = <<<EOS
Amazon http://www.amazon.com/exec/obidos/ISBN= http://images.amazon.com/images/P/\$ISBN.01.MZZZZZZZ.gif
Aladdin http://www.aladdin.co.kr/shop/wproduct.aspx?ISBN= http://image.aladdin.co.kr/cover/cover/\$ISBN_1.gif @(http://image\\..*/cover/(?:[^\\s_/]*\$ISBN_\\d\\.(?:jpe?g|gif)))@
Gang http://kangcom.com/common/qsearch/search.asp?s_flag=T&s_text= http://kangcom.com/l_pic/\$ISBN.jpg @bookinfo\\.asp\\?sku=(\\d+)"@

EOS;
    $DEFAULT_ISBN = "Amazon";
    $re_isbn = "/^([0-9\\-]+[xX]?)(?:,\\s*)?(([A-Z][A-Za-z]*)?(?:,)?(.*))?/x";
    if ($value != '') {
        $test = preg_match($re_isbn, $value, $match);
        if ($test === false) {
            return "<p><strong class=\"error\">Invalid ISBN \"%value\"</strong></p>";
        }
    }
    $list = $DEFAULT;
    $map = new WikiPage($ISBN_MAP);
    if ($map->exists()) {
        $list .= $map->get_raw_body();
    }
    $lists = explode("\n", $list);
    $ISBN_list = array();
    foreach ($lists as $line) {
        if (!$line or !preg_match("/^[A-Z]/", $line[0])) {
            continue;
        }
        $dum = explode(" ", rtrim($line));
        $re = '';
        $sz = sizeof($dum);
        if (!preg_match('/^(http|ftp)/', $dum[1])) {
            continue;
        }
        if ($sz == 2) {
            $dum[] = $ISBN_list[$DEFAULT_ISBN][1];
        } else {
            if ($sz != 3) {
                if ($sz == 4) {
                    if (($p = strpos(substr($dum[3], 1), $dum[3][0])) !== false) {
                        $retest = substr($dum[3], 0, $p + 2);
                    } else {
                        $retest = $dum[3];
                    }
                    if (preg_match($retest, '') !== false) {
                        $re = $dum[3];
                    }
                } else {
                    continue;
                }
            }
        }
        $ISBN_list[$dum[0]] = array($dum[1], $dum[2], $re);
    }
    if ($value == '') {
        $out = "<ul>";
        foreach ($ISBN_list as $interwiki => $v) {
            $href = $ISBN_list[$interwiki][0];
            if (strpos($href, '$ISBN') === false) {
                $url = $href . '0738206679';
            } else {
                $url = str_replace('$ISBN', '0738206679', $href);
            }
            $icon = $DBInfo->imgs_url_interwiki . strtolower($interwiki) . '-16.png';
            $sx = 16;
            $sy = 16;
            if ($DBInfo->intericon[$interwiki]) {
                $icon = $DBInfo->intericon[$interwiki][2];
                $sx = $DBInfo->intericon[$interwiki][0];
                $sy = $DBInfo->intericon[$interwiki][1];
            }
            $out .= "<li><img src='{$icon}' width='{$sx}' height='{$sy}' " . "align='middle' alt='{$interwiki}:' /><a href='{$url}'>{$interwiki}</a>: " . "<tt class='link'>{$href}</tt></li>";
        }
        $out .= "</ul>\n";
        return $out;
    }
    $isbn2 = $match[1];
    $isbn = str_replace('-', '', $isbn2);
    #print_r($match);
    if ($match[3]) {
        if (strtolower($match[2][0]) == 'k') {
            $lang = 'Aladdin';
        } else {
            $lang = $match[3];
        }
    } else {
        $cl = strlen($isbn);
        if ($cl == 13) {
            $lang_code = substr($isbn, 3, 2);
        } else {
            $lang_code = substr($isbn, 0, 2);
        }
        // 89
        if (!empty($default_map[$lang_code])) {
            $lang = $default_map[$lang_code];
        } else {
            $lang = $DEFAULT_ISBN;
//.........这里部分代码省略.........
开发者ID:ahastudio,项目名称:moniwiki,代码行数:101,代码来源:ISBN.php

示例5: do_bts

function do_bts($formatter, $options)
{
    global $DBInfo;
    $fields = array('Type', 'Priority', 'Product', 'Severity', 'Summary', 'Keywords', 'Submit');
    $basic = <<<EOF
 * Type: Bug,Enhancement,Task,Support
EOF;
    #    if ($DBInfo->hasPage($options['page'])) {
    #        $p=new WikiPage($options['page']);
    #        $bts_raw=$p->get_raw_body();
    #        $meta=_get_btsConfig($bts_raw);
    #    }
    $bts_conf = 'BugTrack/Config';
    if ($DBInfo->hasPage($bts_conf)) {
        $p = new WikiPage($bts_conf);
        $config_raw = $p->get_raw_body();
        if (substr($basic, -1, 1) != "\n") {
            $basic .= "\n";
        }
        $confs = _get_btsConfig($basic . $config_raw);
        #print_r($confs);
    }
    $myform = '';
    foreach ($fields as $field) {
        if (isset($confs[$field])) {
            $myform .= ':' . $field . ':' . $confs[$field] . "\n";
        } else {
            if ($field == 'Submit') {
                $myform .= "hidden:action:bts\n";
                $myform .= "hidden:mode:write\n";
                $myform .= 'submit::' . $field . "\n";
            } else {
                $myform .= 'input:' . $field . "\n";
            }
        }
    }
    #header("Content-Type:text/plain");
    #print '<pre>';
    #print $myform;
    #print '</pre>';
    $formatter->send_header('', $options);
    $formatter->send_title('', '', $options);
    print $formatter->processor_repl('form', $myform, $options);
    #    # parse metadata
    #    $meta='';
    #    while(true) {
    #        list($line,$body)=explode("\n",$body,2);
    #        if ($line[0]=='#') continue;
    #        if (strpos($line,':')===false or !trim($line)) break;
    #        $meta.=$line."\n";
    #    }
    #    print "<pre>";
    #    print_r($options);
    #    print "</pre>";
    #
    #
    #    foreach ($meta as $k=>$v) {
    #        if (!empty($options[$k])) $meta[$k]=$options[$k];
    #    }
    #    print "<pre>";
    #    print_r($meta);
    #    print "</pre>";
    $formatter->send_footer('', $options);
    return;
}
开发者ID:ahastudio,项目名称:moniwiki,代码行数:65,代码来源:bts.php

示例6: macro_Cite

function macro_Cite($formatter = "", $value = "")
{
    $CITE_MAP = "CiteMap";
    $DEFAULT = <<<EOS
JCP,J.Chem.Phys. http://jcp.aip.org/jcp/top.jsp?vol=\$VOL&amp;pg=\$PAGE
JACS,J.Am.Chem.Soc. http://pubs.acs.org/journals/query/subscriberResults.jsp?Research=true&amp;yearrange1=ASAP&amp;yearrange3=current&amp;cit_qjrn=jacsat&styear=YYYY&endyear=YYYY&vol=\$VOL&spn=\$PAGE
JPC,J.Phys.Chem. http://pubs.acs.org/journals/query/subscriberResults.jsp?Research=true&amp;yearrange1=ASAP&amp;yearrange3=current&amp;cit_qjrn=jpchax&styear=YYYY&endyear=YYYY&vol=\$VOL&spn=\$PAGE
JPCA,J.Phys.Chem.A http://pubs.acs.org/journals/query/subscriberResults.jsp?Research=true&amp;yearrange1=ASAP&amp;yearrange3=current&amp;cit_qjrn=jpcafh&styear=YYYY&endyear=YYYY&vol=\$VOL&spn=\$PAGE
ChemRev,Chem.Rev. http://pubs.acs.org/journals/query/subscriberResults.jsp?Research=true&amp;yearrange1=ASAP&amp;yearrange3=current&amp;cit_qjrn=chreay&styear=YYYY&endyear=YYYY&vol=\$VOL&spn=\$PAGE
RMP,Rev.Mod.Phys. http://link.aps.org/volpage?journal=RMP&volume=\$VOL&id=\$PAGE
PR,Phys.Rev. http://link.aps.org/volpage?journal=PR&volume=\$VOL&id=\$PAGE
PRL,Phys.Rev.Lett. http://link.aps.org/doi/10.1103/PhysRevLett.\$VOL.\$PAGE
CPL,Chem.Phys.Lett. http://www.sciencedirect.com/science/journal/00092614

EOS;
    $CITE_list = array('JCP' => array('http://jcp.aip.org/jcp/top.jsp?vol=$VOL&amp;pg=$PAGE', '', 'J.Chem.Phys.'));
    $DEFAULT_CITE = "JCP";
    $re_cite = "/([A-Z][A-Za-z]*)?\\s*([0-9\\-]+\\s*,\\s*[0-9]+)/x";
    $test = preg_match($re_cite, $value, $match);
    if ($test === false) {
        return "<p><strong class=\"error\">Invalid CITE \"%value\"</strong></p>";
    }
    list($vol, $page) = explode(',', preg_replace('/ /', '', $match[2]));
    if (!empty($match[1])) {
        if (strtolower($match[1][0]) == "k") {
            $cite = "JKCS";
        } else {
            $cite = $match[1];
        }
    } else {
        $cite = $DEFAULT_CITE;
    }
    $attr = '';
    if (!empty($match[3])) {
        $args = explode(",", $match[3]);
        foreach ($args as $arg) {
            if ($arg == "noimg") {
                $noimg = 1;
            } else {
                $name = strtok($arg, '=');
                $val = strtok(' ');
                $attr .= $name . '="' . $val . '" ';
                if ($name == 'align') {
                    $attr .= 'class="img' . ucfirst($val) . '" ';
                }
            }
        }
    }
    $list = $DEFAULT;
    $map = new WikiPage($CITE_MAP);
    if ($map->exists()) {
        $list .= $map->get_raw_body();
    }
    $lists = explode("\n", $list);
    foreach ($lists as $line) {
        if (empty($line) or !preg_match("/^[A-Z]/", $line[0])) {
            continue;
        }
        $dum = explode(" ", rtrim($line));
        if (sizeof($dum) == 2) {
            $dum[] = $CITE_list[$DEFAULT_CITE][1];
        } else {
            if (sizeof($dum) != 3) {
                continue;
            }
        }
        list($dum[0], $name) = explode(',', $dum[0]);
        $CITE_list[$dum[0]] = array($dum[1], $dum[2], $name);
    }
    if (!empty($CITE_list[$cite])) {
        $citelink = $CITE_list[$cite][0];
        $imglink = $CITE_list[$cite][1];
        $citename = $CITE_list[$cite][2];
        if ($citename) {
            $cite = str_replace('.', '. ', $citename);
        }
    } else {
        $citelink = $CITE_list[$DEFAULT_CITE][0];
        $imglink = $CITE_list[$DEFAULT_CITE][1];
    }
    $citelink = str_replace('$VOL', $vol, $citelink);
    $citelink = str_replace('$PAGE', $page, $citelink);
    return $formatter->icon['www'] . '<a href=' . "'{$citelink}'>" . $cite . ' <strong>' . $vol . '</strong>, ' . $page . '</a> ';
}
开发者ID:ahastudio,项目名称:moniwiki,代码行数:84,代码来源:Cite.php


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