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


PHP OutputPage::redirect方法代码示例

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


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

示例1: onEditConflict

 /**
  * @since 1.1
  *
  * @param EditPage $editor
  * @param OutputPage &$out
  *
  * @return true
  */
 public function onEditConflict(EditPage &$editor, OutputPage &$out)
 {
     $conctext = $editor->textbox1;
     $actualtext = $editor->textbox2;
     $initialtext = $editor->getBaseRevision()->mText;
     // TODO: WTF?!
     $editor->mArticle->doEdit($actualtext, $editor->summary, $editor->minoredit ? EDIT_MINOR : 0);
     $query = Title::newFromRedirect($actualtext) === null ? '' : 'redirect=no';
     $out->redirect($editor->mTitle->getFullURL($query));
     return true;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:19,代码来源:DSMW.hooks.php

示例2: SharedHelpHook

/**
 * @param OutputPage $out
 * @param $text
 * @return bool
 */
function SharedHelpHook(&$out, &$text)
{
    global $wgTitle, $wgMemc, $wgSharedDB, $wgCityId, $wgHelpWikiId, $wgContLang, $wgLanguageCode, $wgArticlePath;
    /* Insurance that hook will be called only once #BugId:  */
    static $wasCalled = false;
    if ($wasCalled == true) {
        return true;
    }
    $wasCalled = true;
    if (empty($wgHelpWikiId) || $wgCityId == $wgHelpWikiId) {
        # Do not proceed if we don't have a help wiki or are on it
        return true;
    }
    if (!$out->isArticle()) {
        # Do not process for pages other then articles
        return true;
    }
    wfProfileIn(__METHOD__);
    # Do not process if explicitly told not to
    $mw = MagicWord::get('MAG_NOSHAREDHELP');
    if ($mw->match($text) || strpos($text, NOSHAREDHELP_MARKER) !== false) {
        wfProfileOut(__METHOD__);
        return true;
    }
    if ($wgTitle->getNamespace() == NS_HELP) {
        # Initialize shared and local variables
        # Canonical namespace is added here in case we ever want to share other namespaces (e.g. Advice)
        $sharedArticleKey = $wgSharedDB . ':sharedArticles:' . $wgHelpWikiId . ':' . MWNamespace::getCanonicalName($wgTitle->getNamespace()) . ':' . $wgTitle->getDBkey() . ':' . SHAREDHELP_CACHE_VERSION;
        $sharedArticle = $wgMemc->get($sharedArticleKey);
        $sharedServer = WikiFactory::getVarValueByName('wgServer', $wgHelpWikiId);
        $sharedScript = WikiFactory::getVarValueByName('wgScript', $wgHelpWikiId);
        $sharedArticlePath = WikiFactory::getVarValueByName('wgArticlePath', $wgHelpWikiId);
        // get defaults
        // in case anybody's curious: no, we can't use $wgScript cause that may be overridden locally :/
        // @TODO pull this from somewhere instead of hardcoding
        if (empty($sharedArticlePath)) {
            $sharedArticlePath = '/wiki/$1';
        }
        if (empty($sharedScript)) {
            $sharedScript = '/index.php';
        }
        $sharedArticlePathClean = str_replace('$1', '', $sharedArticlePath);
        $localArticlePathClean = str_replace('$1', '', $wgArticlePath);
        # Try to get content from memcache
        if (!empty($sharedArticle['timestamp'])) {
            if (wfTimestamp() - (int) $sharedArticle['timestamp'] < 600) {
                if (isset($sharedArticle['exists']) && $sharedArticle['exists'] == 0) {
                    wfProfileOut(__METHOD__);
                    return true;
                } else {
                    if (!empty($sharedArticle['cachekey'])) {
                        wfDebug("SharedHelp: trying parser cache {$sharedArticle['cachekey']}\n");
                        $key1 = str_replace('-1!', '-0!', $sharedArticle['cachekey']);
                        $key2 = str_replace('-0!', '-1!', $sharedArticle['cachekey']);
                        $parser = $wgMemc->get($key1);
                        if (!empty($parser) && is_object($parser)) {
                            $content = $parser->mText;
                        } else {
                            $parser = $wgMemc->get($key2);
                            if (!empty($parser) && is_object($parser)) {
                                $content = $parser->mText;
                            }
                        }
                    }
                }
            }
        }
        # If getting content from memcache failed (invalidate) then just download it via HTTP
        if (empty($content)) {
            $urlTemplate = $sharedServer . $sharedScript . "?title=Help:%s&action=render";
            $articleUrl = sprintf($urlTemplate, urlencode($wgTitle->getDBkey()));
            list($content, $c) = SharedHttp::get($articleUrl);
            # if we had redirect, then store it somewhere
            if (curl_getinfo($c, CURLINFO_HTTP_CODE) == 301) {
                if (preg_match("/^Location: ([^\n]+)/m", $content, $dest_url)) {
                    $destinationUrl = $dest_url[1];
                }
            }
            global $wgServer, $wgArticlePath, $wgRequest, $wgTitle;
            $helpNs = $wgContLang->getNsText(NS_HELP);
            $sk = RequestContext::getMain()->getSkin();
            if (!empty($_SESSION['SH_redirected'])) {
                $from_link = Title::newfromText($helpNs . ":" . $_SESSION['SH_redirected']);
                $redir = $sk->makeKnownLinkObj($from_link, '', 'redirect=no', '', '', 'rel="nofollow"');
                $s = wfMsg('redirectedfrom', $redir);
                $out->setSubtitle($s);
                $_SESSION['SH_redirected'] = '';
            }
            if (isset($destinationUrl)) {
                $destinationPageIndex = strpos($destinationUrl, "{$helpNs}:");
                # if $helpNs was not found, assume we're on help.wikia.com and try again
                if ($destinationPageIndex === false) {
                    $destinationPageIndex = strpos($destinationUrl, MWNamespace::getCanonicalName(NS_HELP) . ":");
                }
                $destinationPage = substr($destinationUrl, $destinationPageIndex);
//.........这里部分代码省略.........
开发者ID:schwarer2006,项目名称:wikia,代码行数:101,代码来源:SharedHelp.php

示例3: showArticle

 /**
  * After we've either updated or inserted the article, update
  * the link tables and redirect to the new page.
  */
 function showArticle($text, $subtitle, $sectionanchor = '')
 {
     global $wgUseDumbLinkUpdate, $wgAntiLockFlags, $wgOut, $wgUser, $wgLinkCache, $wgEnotif;
     global $wgUseEnotif;
     $fname = 'Article::showArticle';
     wfProfileIn($fname);
     $wgLinkCache = new LinkCache();
     if (!$wgUseDumbLinkUpdate) {
         # Preload links to reduce lock time
         if ($wgAntiLockFlags & ALF_PRELOAD_LINKS) {
             $wgLinkCache->preFill($this->mTitle);
             $wgLinkCache->clear();
         }
     }
     # Parse the text and replace links with placeholders
     $wgOut = new OutputPage();
     # Pass the current title along in case we're creating a wiki page
     # which is different than the currently displayed one (e.g. image
     # pages created on file uploads); otherwise, link updates will
     # go wrong.
     $wgOut->addWikiTextWithTitle($text, $this->mTitle);
     if (!$wgUseDumbLinkUpdate) {
         # Move the current links back to the second register
         $wgLinkCache->swapRegisters();
         # Get old version of link table to allow incremental link updates
         # Lock this data now since it is needed for an update
         $wgLinkCache->forUpdate(true);
         $wgLinkCache->preFill($this->mTitle);
         # Swap this old version back into its rightful place
         $wgLinkCache->swapRegisters();
     }
     if ($this->isRedirect($text)) {
         $r = 'redirect=no';
     } else {
         $r = '';
     }
     $wgOut->redirect($this->mTitle->getFullURL($r) . $sectionanchor);
     wfProfileOut($fname);
 }
开发者ID:BackupTheBerlios,项目名称:enotifwiki,代码行数:43,代码来源:Article.php

示例4: redirectToOriginalImage

 private function redirectToOriginalImage(OutputPage $out)
 {
     $paths = $this->paths;
     if (!$paths->originalImagesFullPathIsConstructableFromScan()) {
         return true;
     }
     $web_link_initial_upload_path = $paths->getWebLinkOriginalImagesPath();
     return $out->redirect($web_link_initial_upload_path);
 }
开发者ID:akvankorlaar,项目名称:manuscriptdesk,代码行数:9,代码来源:NewManuscript.hooks.php

示例5: showSettings

	protected function showSettings( $step ) {
		global $wgRequest, $wgLang;

		$header = new HtmlTag( 'h2' );
		$step_message = 'translate-fs-settings-title';
		$header->style( 'opacity', 0.4 )->content( wfMsg( $step_message ) );

		if ( $step ) {
			$this->out->addHtml( $header );
			return $step;
		}

		if ( $wgRequest->wasPosted() &&
			$this->user->matchEditToken( $wgRequest->getVal( 'token' ) ) &&
			$wgRequest->getText( 'step' ) === 'settings' )
		{
			$this->user->setOption( 'language', $wgRequest->getVal( 'primary-language' ) );
			$this->user->setOption( 'translate-firststeps', '1' );

			$assistant = array();
			for ( $i = 0; $i < 10; $i++ ) {
				$language = $wgRequest->getText( "assistant-language-$i", '-' );
				if ( $language === '-' ) continue;
				$assistant[] = $language;
			}

			if ( count( $assistant ) ) {
				$this->user->setOption( 'translate-editlangs', implode( ',', $assistant ) );
			}
			$this->user->saveSettings();
			// Reload the page if language changed, just in case and this is the easieast way
			$this->out->redirect( $this->getTitle()->getLocalUrl() );
		}

		if ( $this->user->getOption( 'translate-firststeps' ) === '1' ) {
			$header->content( $header->content . wfMsg( 'translate-fs-pagetitle-done' ) );
			$this->out->addHtml( $header );
			return $step;
		}

		$this->out->addHtml( $header->style( 'opacity', false ) );

		$code = $wgLang->getCode();

		$languages = $this->languages( $code );
		$selector = new XmlSelect();
		$selector->addOptions( $languages );
		$selector->setDefault( $code );

		$output = Html::openElement( 'form', array( 'method' => 'post' ) );
		$output .= Html::hidden( 'step', 'settings' );
		$output .= Html::hidden( 'token', $this->user->editToken() );
		$output .= Html::hidden( 'title', $this->getTitle() );
		$output .= Html::openElement( 'table' );

		$name = $id = 'primary-language';
		$selector->setAttribute( 'id', $id );
		$selector->setAttribute( 'name', $name );
		$text = wfMessage( 'translate-fs-settings-planguage' )->text();
		$row  = self::wrap( 'td', Xml::label( $text, $id ) );
		$row .= self::wrap( 'td', $selector->getHtml() );
		$output .= self::wrap( 'tr', $row );

		$row = Html::rawElement( 'td', array( 'colspan' => 2 ), wfMessage( 'translate-fs-settings-planguage-desc' )->parse() );
		$output .= self::wrap( 'tr', $row );

		$helpers = $this->getHelpers( $this->user, $code );

		$selector = new XmlSelect();
		$selector->addOption( wfMessage( 'translate-fs-selectlanguage' )->text(), '-' );
		$selector->addOptions( $languages );

		$num = max( 2, count( $helpers ) );
		for ( $i = 0; $i < $num; $i++ ) {
			$id = $name = "assistant-language-$i";
			$text = wfMessage( 'translate-fs-settings-slanguage' )->numParams( $i + 1 )->text();
			$selector->setDefault( isset( $helpers[$i] ) ? $helpers[$i] : false );
			$selector->setAttribute( 'id', $id );
			$selector->setAttribute( 'name', $name );

			$row  = self::wrap( 'td', Xml::label( $text, $id ) );
			$row .= self::wrap( 'td', $selector->getHtml() );
			$output .= self::wrap( 'tr', $row );
		}

		$output .= Html::openElement( 'tr' );
		$output .= Html::rawElement( 'td', array( 'colspan' => 2 ), wfMessage( 'translate-fs-settings-slanguage-desc' )->parse() );
		$output .= Html::closeElement( 'tr' );
		$output .= Html::openElement( 'tr' );
		$output .= Html::rawElement( 'td', array( 'colspan' => 2 ), Xml::submitButton( wfMsg( 'translate-fs-settings-submit' ) ) );
		$output .= Html::closeElement( 'tr' );
		$output .= Html::closeElement( 'table' );
		$output .= Html::closeElement( 'form' );

		$this->out->addHtml( $output );

		return $step_message;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:98,代码来源:SpecialFirstSteps.php


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