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


PHP Link::canAdmin方法代码示例

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


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

示例1: displayEditForm

    function displayEditForm()
    {
        global $wgOut, $wgRequest;
        $url = $wgRequest->getVal('_url');
        $title = $wgRequest->getVal('_title');
        $l = new Link();
        $link = $l->getLinkByPageID($wgRequest->getInt('id'));
        if (is_array($link)) {
            $url = htmlspecialchars($link['url'], ENT_QUOTES);
            $description = htmlspecialchars($link['description'], ENT_QUOTES);
        } else {
            $title = SpecialPage::getTitleFor('LinkSubmit');
            $wgOut->redirect($title->getFullURL());
        }
        $wgOut->setPageTitle(wfMsg('linkfilter-edit-title', $link['title']));
        $_SESSION['alreadysubmitted'] = false;
        $output = '<div class="lr-left">

			<div class="link-home-navigation">
				<a href="' . Link::getHomeLinkURL() . '">' . wfMsg('linkfilter-home-button') . '</a>';
        if (Link::canAdmin()) {
            $output .= ' <a href="' . Link::getLinkAdminURL() . '">' . wfMsg('linkfilter-approve-links') . '</a>';
        }
        $output .= '<div class="cleared"></div>
			</div>
			<form name="link" id="linksubmit" method="post" action="">
				<div class="link-submit-title">
					<label>' . wfMsg('linkfilter-url') . '</label>
				</div>
				<input tabindex="2" class="lr-input" type="text" name="lf_URL" id="lf_URL" value="' . $url . '"/>

				<div class="link-submit-title">
					<label>' . wfMsg('linkfilter-description') . '</label>
				</div>
				<div class="link-characters-left">' . wfMsg('linkfilter-description-max') . ' - ' . wfMsg('linkfilter-description-left', '<span id="desc-remaining">300</span>') . '</div>
				<textarea tabindex="3" class="lr-input" rows="4" name="lf_desc" id="lf_desc">' . $description . '</textarea>

				<div class="link-submit-title">
					<label>' . wfMsg('linkfilter-type') . '</label>
				</div>
				<select tabindex="4" name="lf_type" id="lf_type">
				<option value="">-</option>';
        $linkTypes = Link::getLinkTypes();
        foreach ($linkTypes as $id => $type) {
            $selected = '';
            if ($link['type'] == $id) {
                $selected = ' selected="selected"';
            }
            $output .= "<option value=\"{$id}\"{$selected}>{$type}</option>";
        }
        $output .= '</select>
				<div class="link-submit-button">
					<input tabindex="5" class="site-button" type="button" id="link-submit-button" value="' . wfMsg('linkfilter-submit-button') . '" />
				</div>
			</form>
		</div>';
        $output .= '<div class="lr-right">' . wfMsgExt('linkfilter-instructions', 'parse') . '</div>
		<div class="cleared"></div>';
        return $output;
    }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:60,代码来源:SpecialLinkEdit.php

示例2: wfLinkFilterStatus

function wfLinkFilterStatus($id, $status)
{
    // Check permissions
    if (!Link::canAdmin()) {
        return '';
    }
    $dbw = wfGetDB(DB_MASTER);
    $dbw->update('link', array('link_status' => intval($status)), array('link_id' => intval($id)), __METHOD__);
    $dbw->commit();
    if ($status == 1) {
        $l = new Link();
        $l->approveLink($id);
    }
    return 'ok';
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:15,代码来源:LinkFilter_AjaxFunctions.php

示例3: displayAddForm

    /**
     * Display the form for submitting a new link.
     * @return String: HTML
     */
    function displayAddForm()
    {
        global $wgRequest;
        $url = $wgRequest->getVal('_url');
        $title = $wgRequest->getVal('_title');
        if (!$url) {
            $url = 'http://';
        }
        if (!$title) {
            $titleFromRequest = $wgRequest->getVal('lf_title');
            if (isset($titleFromRequest)) {
                $title = $titleFromRequest;
            }
        }
        $_SESSION['alreadysubmitted'] = false;
        $descFromRequest = $wgRequest->getVal('lf_desc');
        $lf_desc = isset($descFromRequest) ? $descFromRequest : '';
        $output = '<div class="lr-left">

			<div class="link-home-navigation">
				<a href="' . Link::getHomeLinkURL() . '">' . wfMsg('linkfilter-home-button') . '</a>';
        // Show a link to the LinkAdmin page for privileged users
        if (Link::canAdmin()) {
            $output .= ' <a href="' . Link::getLinkAdminURL() . '">' . wfMsg('linkfilter-approve-links') . '</a>';
        }
        $output .= '<div class="cleared"></div>
			</div>
			<form name="link" id="linksubmit" method="post" action="">
				<div class="link-submit-title">
					<label>' . wfMsg('linkfilter-title') . '</label>
				</div>
				<input tabindex="1" class="lr-input" type="text" name="lf_title" id="lf_title" value="' . $title . '" maxlength="150" />
				<div class="link-submit-title">
					<label>' . wfMsg('linkfilter-url') . '</label>
				</div>
				<input tabindex="2" class="lr-input" type="text" name="lf_URL" id="lf_URL" value="' . $url . '"/>

				<div class="link-submit-title">
					<label>' . wfMsg('linkfilter-description') . '</label>
				</div>
				<div class="link-characters-left">' . wfMsg('linkfilter-description-max') . ' - ' . wfMsg('linkfilter-description-left', '<span id="desc-remaining">300</span>') . '</div>
				<textarea tabindex="3" class="lr-input" rows="4" name="lf_desc" id="lf_desc" value="' . $lf_desc . '"></textarea>

				<div class="link-submit-title">
					<label>' . wfMsg('linkfilter-type') . '</label>
				</div>
				<select tabindex="4" name="lf_type" id="lf_type">
				<option value="">-</option>';
        $linkTypes = Link::getLinkTypes();
        foreach ($linkTypes as $id => $type) {
            $output .= "<option value=\"{$id}\">{$type}</option>";
        }
        $output .= '</select>
				<div class="link-submit-button">
					<input tabindex="5" class="site-button" type="button" id="link-submit-button" value="' . wfMsg('linkfilter-submit-button') . '" />
				</div>
			</form>
		</div>';
        $output .= '<div class="lr-right">' . wfMessage('linkfilter-instructions')->inContentLanguage()->parse() . '</div>
		<div class="cleared"></div>';
        return $output;
    }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:66,代码来源:SpecialLinkSubmit.php

示例4: renderLinkFilterHook

    /**
     * Callback function for registerLinkFilterHook.
     */
    public static function renderLinkFilterHook($input, $args, $parser)
    {
        global $wgMemc, $wgOut;
        $parser->disableCache();
        // Add CSS (ParserOutput class only has addModules(), not
        // addModuleStyles() or addModuleScripts()...strange)
        $wgOut->addModuleStyles('ext.linkFilter');
        if (isset($args['count'])) {
            $count = intval($args['count']);
        } else {
            $count = 10;
        }
        $key = wfMemcKey('linkfilter', $count);
        $data = $wgMemc->get($key);
        if ($data) {
            wfDebugLog('LinkFilter', "Loaded linkfilter hook from cache\n");
            $links = $data;
        } else {
            wfDebugLog('LinkFilter', "Loaded linkfilter hook from DB\n");
            $l = new LinkList();
            $links = $l->getLinkList(LINK_APPROVED_STATUS, '', $count, 1, 'link_approved_date');
            $wgMemc->set($key, $links, 60 * 5);
        }
        $link_submit = SpecialPage::getTitleFor('LinkSubmit');
        $link_all = SpecialPage::getTitleFor('LinksHome');
        $output = '<div>

				<div class="linkfilter-links">
					<a href="' . $link_submit->escapeFullURL() . '">' . wfMsg('linkfilter-submit') . '</a> / <a href="' . $link_all->escapeFullURL() . '">' . wfMsg('linkfilter-all') . '</a>';
        // Show a link to the link administration panel for privileged users
        if (Link::canAdmin()) {
            $output .= ' / <a href="' . Link::getLinkAdminURL() . '">' . wfMsg('linkfilter-approve-links') . '</a>';
        }
        $output .= '</div>
				<div class="cleared"></div>';
        foreach ($links as $link) {
            $output .= '<div class="link-item-hook">
			<span class="link-item-hook-type">' . $link['type_name'] . '</span>
			<span class="link-item-hook-url">
				<a href="' . $link['wiki_page'] . '" rel="nofollow">' . $link['title'] . '</a>
			</span>
			<span class="link-item-hook-page">
				<a href="' . $link['wiki_page'] . '">(' . wfMsgExt('linkfilter-comments', 'parsemag', $link['comments']) . ')</a>
			</span>
		</div>';
        }
        $output .= '</div>';
        return $output;
    }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:52,代码来源:LinkFilterHooks.php

示例5: execute

    /**
     * Show the special page
     *
     * @param $par Mixed: parameter passed to the page or null
     */
    public function execute($par)
    {
        global $wgOut, $wgRequest, $wgSupressPageTitle;
        $wgSupressPageTitle = true;
        // Add CSS & JS
        $wgOut->addModules('ext.linkFilter');
        $per_page = 20;
        $page = $wgRequest->getInt('page', 1);
        $link_type = $wgRequest->getInt('link_type');
        if ($link_type) {
            $type_name = Link::$link_types[$link_type];
            $pageTitle = wfMsg('linkfilter-home-title', $type_name);
        } else {
            $type_name = 'All';
            $pageTitle = wfMsg('linkfilter-home-title-all');
        }
        $wgOut->setPageTitle($pageTitle);
        $output = '<div class="links-home-left">' . "\n\t";
        $output .= '<h1 class="page-title">' . $pageTitle . '</h1>' . "\n\t";
        $output .= '<div class="link-home-navigation">
		<a href="' . Link::getSubmitLinkURL() . '">' . wfMsg('linkfilter-submit-title') . '</a>' . "\n";
        if (Link::canAdmin()) {
            $output .= "\t\t" . '<a href="' . Link::getLinkAdminURL() . '">' . wfMsg('linkfilter-approve-links') . '</a>' . "\n";
        }
        $output .= "\t\t" . '<div class="cleared"></div>
		</div>' . "\n";
        $l = new LinkList();
        $type = 0;
        // FIXME lazy hack --Jack on July 2, 2009
        $total = $l->getLinkListCount(LINK_APPROVED_STATUS, $type);
        $links = $l->getLinkList(LINK_APPROVED_STATUS, $type, $per_page, $page, 'link_approved_date');
        $linkRedirect = SpecialPage::getTitleFor('LinkRedirect');
        $output .= '<div class="links-home-container">';
        $link_count = count($links);
        $x = 1;
        // No links at all? Oh dear...show a message to the user about that!
        if ($link_count <= 0) {
            $wgOut->addWikiMsg('linkfilter-no-links-at-all');
        }
        // Create RSS feed icon for special page
        $wgOut->setSyndicated(true);
        // Make feed (RSS/Atom) if requested
        $feedType = $wgRequest->getVal('feed');
        if ($feedType != '') {
            return $this->makeFeed($feedType, $links);
        }
        foreach ($links as $link) {
            $border_fix = '';
            if ($link_count == $x) {
                $border_fix = 'border-fix';
            }
            $border_fix2 = '';
            wfSuppressWarnings();
            $date = date('l, F j, Y', $link['approved_timestamp']);
            if ($date != $last_date) {
                $border_fix2 = ' border-top-fix';
                $output .= "<div class=\"links-home-date\">{$date}</div>";
                #global $wgLang;
                #$unix = wfTimestamp( TS_MW, $link['approved_timestamp'] );
                #$weekday = $wgLang->getWeekdayName( gmdate( 'w', $unix ) + 1 );
                #$output .= '<div class="links-home-date">' . $weekday .
                #	wfMsg( 'word-separator' ) . $wgLang->date( $unix, true ) .
                #	'</div>';
            }
            wfRestoreWarnings();
            // okay, so suppressing E_NOTICEs is kinda bad practise, but... -Jack, January 21, 2010
            $last_date = $date;
            $output .= "<div class=\"link-item-container{$border_fix2}\">\n\t\t\t\t\t<div class=\"link-item-type\">\n\t\t\t\t\t\t{$link['type_name']}\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"link-item\">\n\t\t\t\t\t\t<div class=\"link-item-url\">\n\t\t\t\t\t\t\t<a href=\"" . $linkRedirect->escapeFullURL(array('link' => 'true', 'url' => $link['url'])) . '" target="new">' . $link['title'] . '</a>
						</div>
						<div class="link-item-desc">' . $link['description'] . '</div>
					</div>
					<div class="link-item-page">
						<a href="' . $link['wiki_page'] . '">(' . wfMsgExt('linkfilter-comments', 'parsemag', $link['comments']) . ')</a>
					</div>
					<div class="cleared"></div>';
            $output .= '</div>';
            $x++;
        }
        $output .= '</div>';
        /**
         * Build next/prev nav
         */
        $numofpages = $total / $per_page;
        $pageLink = $this->getTitle();
        if ($numofpages > 1) {
            $output .= '<div class="page-nav">';
            if ($page > 1) {
                $output .= '<a href="' . $pageLink->escapeFullURL('page=' . ($page - 1)) . '">' . wfMsg('linkfilter-previous') . '</a> ';
            }
            if ($total % $per_page != 0) {
                $numofpages++;
            }
            if ($numofpages >= 9 && $page < $total) {
                $numofpages = 9 + $page;
            }
//.........这里部分代码省略.........
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:101,代码来源:SpecialLinksHome.php


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