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


PHP Formatter::link_tag方法代码示例

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


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

示例1: do_post_rename

function do_post_rename($formatter, $options)
{
    global $DBInfo;
    $new = $options['name'];
    if ($new[0] == '~' and ($p = strpos($new, '/')) !== false) {
        // Namespace renaming
        $dummy = substr($new, 1, $p - 1);
        $dummy2 = substr($new, $p + 1);
        $options['name'] = $dummy . '~' . $dummy2;
    }
    if (isset($options['name']) and trim($options['name'])) {
        if ($DBInfo->hasPage($options['page']) && !$DBInfo->hasPage($options['name'])) {
            $title = sprintf(_("\"%s\" is renamed !"), $options['page']);
            $formatter->send_header("", $options);
            $formatter->send_title($title, "", $options);
            $new_encodedname = _rawurlencode($options['name']);
            if ($options['pagenames'] and is_array($options['pagenames'])) {
                $regex = preg_quote($options['page']);
                $options['minor'] = 1;
                foreach ($options['pagenames'] as $page) {
                    $p = new WikiPage($page);
                    if (!$p->exists()) {
                        continue;
                    }
                    $f = new Formatter($p);
                    $body = $p->_get_raw_body();
                    $body = preg_replace("/{$regex}/m", $options['name'], $body);
                    $f->page->write($body);
                    if (!$options['show_only']) {
                        $DBInfo->savePage($f->page, '', $options);
                    }
                    $msg .= sprintf(_("'%s' is changed"), $f->link_tag(_rawurlencode($page), "?action=highlight&amp;value=" . $new_encodedname)) . "<br />";
                }
            }
            print $msg;
            if (!$options['show_only']) {
                $DBInfo->renamePage($options['page'], $options['name'], $options);
            }
            print sprintf(_("'%s' is renamed as '%s' successfully."), $options['page'], $formatter->link_tag($options['name'], "?action=highlight&amp;value=" . $new_encodedname));
            $formatter->send_footer("", $options);
            return;
        } else {
            $title = sprintf(_("Fail to rename \"%s\" !"), $options['page']);
            $formatter->send_header("", $options);
            $formatter->send_title($title, "", $options);
            $formatter->send_footer("", $options);
            return;
        }
    }
    $title = sprintf(_("Rename \"%s\" ?"), $options['page']);
    $formatter->send_header("", $options);
    $formatter->send_title($title, "", $options);
    #<tr><td align='right'><input type='checkbox' name='show' checked='checked' />show only </td><td><input type='password' name='passwd'>
    $obtn = _("Old name:");
    $nbtn = _("New name:");
    print "<form method='post'>\n<table border='0'>\n<tr><td align='right'>{$obtn} </td><td><b>{$options['page']}</b></td></tr>\n<tr><td align='right'>{$nbtn} </td><td><input name='name' /></td></tr>\n";
    $rename_button = _("Rename");
    if ($options['value'] == 'check_backlinks') {
        print "<tr><td colspan='2'>\n";
        print check_backlinks($formatter, $options);
        print "</td></tr>\n";
        $rename_button = _("Rename and fix Backlinks");
    }
    if ($DBInfo->security->is_protected("rename", $options)) {
        print "<tr><td align='right'>" . _("Password") . ": </td><td><input type='password' name='passwd' /> " . _("Only WikiMaster can rename this page") . "</td></tr>\n";
    }
    print "<tr><td colspan='2'><input type='checkbox' name='history' />" . _("with revision history") . "</td></tr>\n";
    print "<tr><td colspan='2'><input type='checkbox' name='show_only' checked='checked' />" . _("show only") . "</td></tr>\n";
    print "<tr><td></td><td><input type='submit' name='button_rename' value='{$rename_button}' />";
    print " <a href='?action=rename&value=check_backlinks'>" . _("Check backlinks") . "</a>";
    print "</td></tr>\n";
    print "\n</table>\n    <input type=hidden name='action' value='rename' />\n    </form>";
    #  $formatter->send_page();
    $formatter->send_footer("", $options);
}
开发者ID:NessunKim,项目名称:MW_Skins,代码行数:75,代码来源:rename.php

示例2: do_post_fixbacklinks

function do_post_fixbacklinks($formatter, $options = array())
{
    global $DBInfo;
    if ($_SERVER['REQUEST_METHOD'] == 'POST' && !$DBInfo->security->writable($options)) {
        $options['title'] = _("Page is not writable");
        return do_invalid($formatter, $options);
    }
    $options['name'] = trim($options['name']);
    $new = $options['name'];
    if (!empty($DBInfo->use_namespace) and $new[0] == '~' and ($p = strpos($new, '/')) !== false) {
        // Namespace renaming ~foo/bar -> foo~bar
        $dummy = substr($new, 1, $p - 1);
        $dummy2 = substr($new, $p + 1);
        $options['name'] = $dummy . '~' . $dummy2;
    }
    if (isset($options['name'][0]) and $options['name']) {
        if ($DBInfo->hasPage($options['name'])) {
            $formatter->send_header('', $options);
            $new_encodedname = _rawurlencode($options['name']);
            $fixed = 0;
            $msg = '';
            $title = sprintf(_("backlinks of \"%s\" page are fixed !"), $options['page']);
            $comment = sprintf(_("Fixed \"%s\" to \"%s\""), $options['page'], $options['name']);
            if ($options['pagenames'] and is_array($options['pagenames'])) {
                $regex = preg_quote($options['page']);
                //$options['minor'] = 1; # disable log
                foreach ($options['pagenames'] as $page) {
                    $p = new WikiPage($page);
                    if (!$p->exists()) {
                        continue;
                    }
                    $f = new Formatter($p);
                    $body = $p->_get_raw_body();
                    $nbody = preg_replace("/{$regex}/m", $options['name'], $body);
                    // FIXME
                    if ($nbody !== false && $body != $nbody) {
                        $f->page->write($nbody);
                        if (!$options['show_only']) {
                            $DBInfo->savePage($f->page, $comment, $options);
                        }
                        $msg .= sprintf(_("'%s' is changed"), $f->link_tag(_rawurlencode($page), "?action=highlight&amp;value=" . $new_encodedname, _html_escape($page))) . "<br />";
                        $fixed++;
                    }
                }
            }
            if ($fixed == 0) {
                $title = _("No pages are fixed!");
            }
            $formatter->send_title($title, '', $options);
            if ($fixed > 0) {
                print $msg;
                print sprintf(_("'%s' links are successfully fixed as '%s'."), _html_escape($options['page']), $formatter->link_tag($new_encodedname, "?action=highlight&amp;value=" . $new_encodedname, _html_escape($options['name'])));
            }
            $formatter->send_footer('', $options);
            return;
        } else {
            $title = sprintf(_("Fail to fix backlinks of \"%s\" !"), $options['page']);
            $options['msg'] = sprintf(_("New pagename \"%s\" is not exists!"), $options['name']);
            $formatter->send_header('', $options);
            $formatter->send_title($title, '', $options);
            $formatter->send_footer('', $options);
            return;
        }
    }
    $title = sprintf(_("Fix backlinks of \"%s\" ?"), $options['page']);
    $formatter->send_header('', $options);
    $formatter->send_title($title, '', $options);
    $obtn = _("Old name:");
    $nbtn = _("New name:");
    $pgname = _html_escape($options['page']);
    print "<form method='post'>\n        <table border='0'>\n        <tr><td align='right'>{$obtn} </td><td><b>{$pgname}</b></td></tr>\n        <tr><td align='right'>{$nbtn} </td><td><input name='name' /></td></tr>\n";
    if (!empty($options['value']) and $options['value'] == 'check_backlinks') {
        $button = _("Fix backlinks");
        print "<tr><td colspan='2'>\n";
        print check_backlinks($formatter, $options);
        print "</td></tr>\n";
    } else {
        $button = _("Check backlinks");
    }
    if ($DBInfo->security->is_protected("fixbacklinks", $options)) {
        print "<tr><td align='right'>" . _("Password") . ": </td><td><input type='password' name='passwd' /> " . _("Only WikiMaster can fix backlinks of this page") . "</td></tr>\n";
    }
    if (!empty($options['value']) and $options['value'] == 'check_backlinks') {
        print "<tr><td colspan='2'><input type='checkbox' name='show_only' checked='checked' />" . _("show only") . "</td></tr>\n";
    }
    print "<tr><td></td><td><input type='submit' name='button_fixbacklinks' value='{$button}' />";
    print "<input type='hidden' name='value' value='check_backlinks' />";
    print "</td></tr>\n";
    print "\n        </table>\n        <input type='hidden' name='action' value='fixbacklinks' />\n        </form>";
    $formatter->send_footer('', $options);
}
开发者ID:ahastudio,项目名称:moniwiki,代码行数:91,代码来源:fixbacklinks.php

示例3: do_trackback

function do_trackback($formatter, $options)
{
    global $DBInfo, $_release;
    $entry = '';
    if (!$formatter->page->exists()) {
        $pos = strrpos($formatter->page->name, '/');
        if ($pos > 0) {
            $entry = substr($formatter->page->name, $pos + 1);
            $pagename = substr($formatter->page->name, 0, $pos);
            $page = new WikiPage($pagename);
            $formatter = new Formatter($page, $options);
            $options['page'] = $pagename;
        } else {
            $options['msg'] = _("Error: Page Not found !");
            send_error(1, $options['msg']);
        }
    }
    if (empty($options['url'])) {
        $anchor = '';
        if ($options['value']) {
            $anchor = '/' . $options['value'];
        }
        $formatter->send_header("", $options);
        if ($DBInfo->use_trackback) {
            $ping_url = qualifiedUrl($formatter->link_url($formatter->page->urlname . $anchor, "?action=trackback"));
        } else {
            $ping_url = _("TrackBack is not activated !");
        }
        $sendping_action = $formatter->link_tag($formatter->page->urlname, "?action=sendping&amp;value={$options['value']}", _("send ping"));
        $tb_cache = new Cache_text('trackback');
        if ($tb_cache->exists($options['page'])) {
            $formatter->send_title(sprintf(_("TrackBack list of %s"), $options['page']), "", $options);
            $trackbacks = explode("\n", $tb_cache->fetch($options['page']));
            unset($trackbacks[sizeof($trackbacks) - 1]);
            # trim the last empty line
            print "<div class='trackback-hint'><b>" . _("TrackBack URL for this page:") . "</b><br />\n{$ping_url}<br /><br />\n";
            print "<b>" . _("Send TrackBack Ping to another Blog:") . "</b> {$sendping_action}</div>\n<br />";
            foreach ($trackbacks as $trackback) {
                list($dummy, $entry, $url, $date, $sitename, $title, $excerpt) = explode("\t", $trackback);
                if ($anchor and '/' . $entry != $anchor) {
                    continue;
                }
                $date[10] = " ";
                # 2003-07-11T12:08:33+09:00
                # $time=strtotime($date);
                $time = strtotime($date);
                $date = date("@ m-d [h:i a]", $time);
                print "<div class='blog'>\n";
                print "<div class='blog-title'><a href='{$url}'>{$title}</a></div>\n";
                print "<div class='blog-user'>Submitted by <a href='{$url}'>{$sitename}</a> {$date}</div>\n";
                print "<div class='blog-comment'>{$excerpt}</div>\n</div><br />\n";
            }
        } else {
            $formatter->send_title(sprintf(_("No TrackBack entry found for %s"), $options['page']), "", $options);
            print "<div class='trackback-hint'><b>" . _("TrackBack URL for this page:") . "</b><br />\n{$ping_url}<br /><br />\n";
            print "<b>" . _("Send TrackBack Ping to another Blog:") . "</b> {$sendping_action}</div>\n";
        }
        $formatter->send_footer("", $options);
        return;
    }
    if (!$DBInfo->use_trackback) {
        send_error(1, "TrackBack is not enabled");
    }
    if (empty($options['title']) or empty($options['excerpt']) or empty($options['blog_name']) or empty($options['url'])) {
        send_error(1, "Invalid TrackBack Ping");
    }
    # receivie Trackback ping
    # strip \n
    $title = strtr(_stripslashes($options['title']), "\t\n", " \r");
    $excerpt = strtr(_stripslashes($options['excerpt']), "\t\n", " \r");
    $blog_name = strtr(_stripslashes($options['blog_name']), "\t\n", " \r");
    $url = strtr(_stripslashes($options['url']), "\t\n", " \r");
    $timestamp = time();
    $date = gmdate("Y-m-d\\TH:i:s", $timestamp);
    $receive = $timestamp . "\t" . $entry . "\t" . $url . "\t" . $date . "\t" . $blog_name . "\t" . $title . "\t" . $excerpt . "\n";
    $tb_cache = new Cache_text('trackback');
    $old = $tb_cache->fetch($options['page']);
    $ret = $tb_cache->update($options['page'], $old . $receive, time());
    if ($ret === false) {
        send_error(0, "Can't update Trackback list. Please try again");
    }
    send_error(0, 'Successfully added');
}
开发者ID:ahastudio,项目名称:moniwiki,代码行数:83,代码来源:trackback.php


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