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


PHP wfUrlProtocols函数代码示例

本文整理汇总了PHP中wfUrlProtocols函数的典型用法代码示例。如果您正苦于以下问题:PHP wfUrlProtocols函数的具体用法?PHP wfUrlProtocols怎么用?PHP wfUrlProtocols使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: getConfigSettings

 /**
  * @param ResourceLoaderContext $context
  * @return array
  */
 protected function getConfigSettings($context)
 {
     $hash = $context->getHash();
     if (isset($this->configVars[$hash])) {
         return $this->configVars[$hash];
     }
     global $wgContLang;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     $conf = $this->getConfig();
     // Build list of variables
     $vars = array('wgLoadScript' => wfScript('load'), 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $conf->get('StylePath'), 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $conf->get('ArticlePath'), 'wgScriptPath' => $conf->get('ScriptPath'), 'wgScriptExtension' => '.php', 'wgScript' => wfScript(), 'wgSearchType' => $conf->get('SearchType'), 'wgVariantArticlePath' => $conf->get('VariantArticlePath'), 'wgActionPaths' => (object) $conf->get('ActionPaths'), 'wgServer' => $conf->get('Server'), 'wgServerName' => $conf->get('ServerName'), 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgTranslateNumerals' => $conf->get('TranslateNumerals'), 'wgVersion' => $conf->get('Version'), 'wgEnableAPI' => $conf->get('EnableAPI'), 'wgEnableWriteAPI' => $conf->get('EnableWriteAPI'), 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $conf->get('Sitename'), 'wgDBname' => $conf->get('DBname'), 'wgExtraSignatureNamespaces' => $conf->get('ExtraSignatureNamespaces'), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $conf->get('ExtensionAssetsPath'), 'wgCookiePrefix' => $conf->get('CookiePrefix'), 'wgCookieDomain' => $conf->get('CookieDomain'), 'wgCookiePath' => $conf->get('CookiePath'), 'wgCookieExpiration' => $conf->get('CookieExpiration'), 'wgResourceLoaderMaxQueryLength' => $conf->get('ResourceLoaderMaxQueryLength'), 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgResourceLoaderStorageVersion' => $conf->get('ResourceLoaderStorageVersion'), 'wgResourceLoaderStorageEnabled' => $conf->get('ResourceLoaderStorageEnabled'), 'wgResourceLoaderLegacyModules' => self::getLegacyModules(), 'wgForeignUploadTargets' => $conf->get('ForeignUploadTargets'), 'wgEnableUploads' => $conf->get('EnableUploads'));
     Hooks::run('ResourceLoaderGetConfigVars', array(&$vars));
     $this->configVars[$hash] = $vars;
     return $this->configVars[$hash];
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:32,代码来源:ResourceLoaderStartUpModule.php

示例2: getConfig

 /**
  * @param ResourceLoaderContext $context
  * @return array
  */
 protected function getConfig($context)
 {
     $hash = $context->getHash();
     if (isset($this->configVars[$hash])) {
         return $this->configVars[$hash];
     }
     global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength, $wgResourceLoaderStorageEnabled, $wgResourceLoaderStorageVersion, $wgSearchType;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     // Build list of variables
     $vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgSearchType' => $wgSearchType, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values(array_unique($wgFileExtensions)), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgResourceLoaderStorageVersion' => $wgResourceLoaderStorageVersion, 'wgResourceLoaderStorageEnabled' => $wgResourceLoaderStorageEnabled);
     wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
     $this->configVars[$hash] = $vars;
     return $this->configVars[$hash];
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:31,代码来源:ResourceLoaderStartUpModule.php

示例3: getConfig

 /**
  * @param $context ResourceLoaderContext
  * @return array
  */
 protected function getConfig($context)
 {
     global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     // Build list of variables
     $vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgDefaultDateFormat' => $wgContLang->getDefaultDateFormat(), 'wgMonthNames' => $wgContLang->getMonthNamesArray(), 'wgMonthNamesShort' => $wgContLang->getMonthAbbreviationsArray(), 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values($wgFileExtensions), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgSassParams' => SassUtil::getSassSettings());
     if ($wgUseAjax && $wgEnableMWSuggest) {
         $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
     }
     wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
     return $vars;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:29,代码来源:ResourceLoaderStartUpModule.php

示例4: _stripMarkup

 /**
  * Strip markup to show plaintext
  * @param string $text
  * @return string
  * @access private
  */
 function _stripMarkup($text)
 {
     global $wgContLang;
     $text = substr($text, 0, 4096);
     // don't bother with long text...
     $text = str_replace("'''", "", $text);
     $text = str_replace("''", "", $text);
     $text = preg_replace('#__[a-z0-9_]+__#i', '', $text);
     // magic words
     $cleanChar = "[^|\\[\\]]";
     $subLink = "\\[\\[{$cleanChar}*(?:\\|{$cleanChar}*)*\\]\\]";
     $pipeContents = "(?:{$cleanChar}|{$subLink})*";
     $text = preg_replace_callback("#\n\t\t\t\\[\\[\n\t\t\t\t({$cleanChar}*)\n\t\t\t\t(?:\\|({$pipeContents}))?\n\t\t\t\t(?:\\|{$pipeContents})*\n\t\t\t\\]\\]\n\t\t\t#six", array($this, '_stripLink'), $text);
     $protocols = wfUrlProtocols();
     $text = preg_replace('#\\[(?:$protocols).*? (.*?)\\]#s', '$1', $text);
     // URL links
     $text = preg_replace('#</?[a-z0-9]+.*?>#s', '', $text);
     // HTML-style tags
     $text = preg_replace('#\\{\\|.*?\\|\\}#s', '', $text);
     // tables
     $text = preg_replace('#^:.*$#m', '', $text);
     // indented lines near start are usually disambigs or notices
     $text = Sanitizer::decodeCharReferences($text);
     return trim($text);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:31,代码来源:IndexAbstracts.php

示例5: imageLink

 /**
  * Outputs the internal image wrapped in a link
  * @param Parser $parser Instance of running Parser.
  * @param String $image Name of image to display.
  * @param String $url External URL to which to link
  * @param String $alt Alternate text for image and link (optional)
  * @return String A parser strip flag which will be later replaced with raw html.
  */
 function imageLink($parser, $image = null, $url = null, $alt = '')
 {
     # Short-circuit if requried params are missing
     if ($image === null || $url === null) {
         return $this->error('missing-params');
     }
     # Prepare incomming params
     $image = trim($image);
     $url = trim($url);
     $alt = trim($alt);
     # Check for bad URLs
     if (!preg_match('/^(' . wfUrlProtocols() . ')/', $url) || preg_match('/\'"/', $url)) {
         $t = Title::newFromText($url);
         if (!$t) {
             return $this->error('bad-url', $url);
         }
         $url = $t->getFullURL();
     }
     # Check to see that the selected image exists
     $imageObj = Image::newFromName($image);
     if (!$imageObj->exists()) {
         return $this->error('no-such-image', $image);
     }
     # Finally, since all checks passed, display it!
     return $parser->insertStripItem($this->msg('embed-clause', htmlentities($url, ENT_COMPAT), $imageObj->getURL(), htmlentities($alt, ENT_COMPAT)), $parser->mStripState);
 }
开发者ID:mediawiki-extensions,项目名称:mahalo-parserfunctions,代码行数:34,代码来源:mhoImageLink.php

示例6: getImageHtml

 /**
  * Constructs HTML for the tutorial (laboriously), including an imagemap for the clickable "Help desk" button.
  *
  * @param MediaTransformOutput $thumb
  * @param String|null $campaign Upload Wizard campaign for which the tutorial should be displayed.
  *
  * @return String HTML representing the image, with clickable helpdesk button
  */
 public static function getImageHtml(MediaTransformOutput $thumb, $campaign = null)
 {
     $helpDeskUrl = wfMessage('mwe-upwiz-help-desk-url')->text();
     // Per convention, we may be either using an absolute URL or a wiki page title in this UI message
     if (preg_match('/^(?:' . wfUrlProtocols() . ')/', $helpDeskUrl)) {
         $helpDeskHref = $helpDeskUrl;
     } else {
         $helpDeskTitle = Title::newFromText($helpDeskUrl);
         $helpDeskHref = $helpDeskTitle ? $helpDeskTitle->getLocalURL() : '#';
     }
     $buttonCoords = UploadWizardConfig::getSetting('tutorialHelpdeskCoords', $campaign);
     $useMap = $buttonCoords !== false && trim($buttonCoords) != '';
     $imgAttributes = array('src' => $thumb->getUrl(), 'width' => $thumb->getWidth(), 'height' => $thumb->getHeight());
     if ($useMap) {
         $imgAttributes['usemap'] = '#' . self::IMAGEMAP_ID;
     }
     // here we use the not-yet-forgotten HTML imagemap to add a clickable area to the tutorial image.
     // we could do more special effects with hovers and images and such, not to mention SVG scripting,
     // but we aren't sure what we want yet...
     $imgHtml = Html::element('img', $imgAttributes);
     if ($useMap) {
         $areaAltText = wfMessage('mwe-upwiz-help-desk')->text();
         $area = Html::element('area', array('shape' => 'rect', 'coords' => $buttonCoords, 'href' => $helpDeskHref, 'alt' => $areaAltText, 'title' => $areaAltText));
         $imgHtml = Html::rawElement('map', array('id' => self::IMAGEMAP_ID, 'name' => self::IMAGEMAP_ID), $area) . $imgHtml;
     }
     return $imgHtml;
 }
开发者ID:JeroenDeDauw,项目名称:UploadWizard,代码行数:35,代码来源:UploadWizardTutorial.php

示例7: parseNext

	public function parseNext( $text, WikiObjectModelCollection $parentObj, $offset = 0 ) {
		$text = substr( $text, $offset );

		$r = preg_match( '/^\[\[([^\|\]]+)(\|([^\]]+))?\]\]/', $text, $m );
		if ( $r && !preg_match( '/^(?:' . wfUrlProtocols() . ')/', $m[1] ) ) {
			return array( 'len' => strlen( $m[0] ), 'obj' => new WOMLinkModel( $m[1], isset( $m[3] ) ? $m[3] : '' ) );
		}
		$r = preg_match( '/^\[((?:' . wfUrlProtocols() . ')[^ \]]+)(\s+([^\]]+))?\]/', $text, $m );
		if ( $r ) {
			return array( 'len' => strlen( $m[0] ), 'obj' => new WOMLinkModel( $m[1], isset( $m[3] ) ? $m[3] : '' ) );
		}
		// includes/Parser.php Parser->doMagicLinks
		$r = preg_match( '/^(?:' . wfUrlProtocols() . ')[^][<>"|}{\\x00-\\x20\\x7F]+/', $text, $m );
		if ( $r ) {
			return array( 'len' => strlen( $m[0] ), 'obj' => new WOMLinkModel( $m[0] ) );
		}

		return null;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:19,代码来源:WOMLinkParser.php

示例8: getConfig

 protected function getConfig($context)
 {
     global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgResourceLoaderMaxQueryLength;
     // Pre-process information
     $separatorTransTable = $wgContLang->separatorTransformTable();
     $separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
     $compactSeparatorTransTable = array(implode("\t", array_keys($separatorTransTable)), implode("\t", $separatorTransTable));
     $digitTransTable = $wgContLang->digitTransformTable();
     $digitTransTable = $digitTransTable ? $digitTransTable : array();
     $compactDigitTransTable = array(implode("\t", array_keys($digitTransTable)), implode("\t", $digitTransTable));
     $mainPage = Title::newMainPage();
     // Build list of variables
     $vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgSeparatorTransformTable' => $compactSeparatorTransTable, 'wgDigitTransformTable' => $compactDigitTransTable, 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $wgContLang->getNamespaceIds(), 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values($wgFileExtensions), 'wgDBname' => $wgDBname, 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength);
     if ($wgContLang->hasVariants()) {
         $vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
     }
     if ($wgUseAjax && $wgEnableMWSuggest) {
         $vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
     }
     wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
     return $vars;
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:22,代码来源:ResourceLoaderStartUpModule.php

示例9: addToSidebarPlain

 /**
  * Add content from plain text
  * @since 1.17
  * @param $bar array
  * @param $text string
  * @return Array
  */
 function addToSidebarPlain(&$bar, $text)
 {
     $lines = explode("\n", $text);
     $heading = '';
     foreach ($lines as $line) {
         if (strpos($line, '*') !== 0) {
             continue;
         }
         $line = rtrim($line, "\r");
         // for Windows compat
         if (strpos($line, '**') !== 0) {
             $heading = trim($line, '* ');
             if (!array_key_exists($heading, $bar)) {
                 $bar[$heading] = array();
             }
         } else {
             $line = trim($line, '* ');
             if (strpos($line, '|') !== false) {
                 // sanity check
                 $line = MessageCache::singleton()->transform($line, false, null, $this->getTitle());
                 $line = array_map('trim', explode('|', $line, 2));
                 if (count($line) !== 2) {
                     // Second sanity check, could be hit by people doing
                     // funky stuff with parserfuncs... (bug 33321)
                     continue;
                 }
                 $extraAttribs = array();
                 $msgLink = $this->msg($line[0])->inContentLanguage();
                 if ($msgLink->exists()) {
                     $link = $msgLink->text();
                     if ($link == '-') {
                         continue;
                     }
                 } else {
                     $link = $line[0];
                 }
                 $msgText = $this->msg($line[1]);
                 if ($msgText->exists()) {
                     $text = $msgText->text();
                 } else {
                     $text = $line[1];
                 }
                 if (preg_match('/^(?i:' . wfUrlProtocols() . ')/', $link)) {
                     $href = $link;
                     // Parser::getExternalLinkAttribs won't work here because of the Namespace things
                     global $wgNoFollowLinks, $wgNoFollowDomainExceptions;
                     if ($wgNoFollowLinks && !wfMatchesDomainList($href, $wgNoFollowDomainExceptions)) {
                         $extraAttribs['rel'] = 'nofollow';
                     }
                     global $wgExternalLinkTarget;
                     if ($wgExternalLinkTarget) {
                         $extraAttribs['target'] = $wgExternalLinkTarget;
                     }
                 } else {
                     $title = Title::newFromText($link);
                     if ($title) {
                         $title = $title->fixSpecialName();
                         $href = $title->getLinkURL();
                     } else {
                         $href = 'INVALID-TITLE';
                     }
                 }
                 $bar[$heading][] = array_merge(array('text' => $text, 'href' => $href, 'id' => 'n-' . Sanitizer::escapeId(strtr($line[1], ' ', '-'), 'noninitial'), 'active' => false), $extraAttribs);
             } else {
                 continue;
             }
         }
     }
     return $bar;
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:77,代码来源:Skin.php

示例10: getUrlProtocols

 private static function getUrlProtocols()
 {
     static $regex = false;
     if ($regex === false) {
         $regex = wfUrlProtocols();
         RTE::log(__METHOD__, $regex);
     }
     return $regex;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:9,代码来源:RTEReverseParser.class.php

示例11: fnCustomSidebarProcess

function fnCustomSidebarProcess($NewSideBar)
{
    global $wgParser, $wgUser, $wgArticle, $wgTitle;
    $NewSideBar = fnCustomSidebarPreProcess($NewSideBar);
    // custom loader
    if ($NewSideBar !== false) {
        if (strpos(trim($NewSideBar), '*') === 0) {
            $text = $NewSideBar;
        } else {
            $text = $NewSideBar;
            do {
                $oldtext = $text;
                if ($titleFromText = Title::newFromText($text)) {
                    $article = new Article($titleFromText, 0);
                    $text = $article->getContent();
                    $text = preg_replace('%\\<noinclude\\s*\\>(.*)\\</noinclude\\s*\\>%isU', '', $text);
                    $text = fnCustomSidebarPreProcess($text);
                }
            } while ($text !== $oldtext);
        }
        $lines = explode("\n", $text);
    } else {
        return array();
    }
    $new_bar = array();
    $heading = '';
    // taken directly from MediaWiki source v1.14.0
    foreach ($lines as $line) {
        if (strpos($line, '*') !== 0) {
            continue;
        }
        if (strpos($line, '**') !== 0) {
            $line = trim($line, '* ');
            $heading = $line;
            if (!array_key_exists($heading, $new_bar)) {
                $new_bar[$heading] = array();
            }
        } else {
            if (strpos($line, '|') !== false) {
                // sanity check
                $line = array_map('trim', explode('|', trim($line, '* '), 2));
                $link = wfMsgForContent($line[0]);
                if ($link == '-') {
                    continue;
                }
                $text = wfMsgExt($line[1], 'parsemag');
                if (wfEmptyMsg($line[1], $text)) {
                    $text = $line[1];
                }
                if (wfEmptyMsg($line[0], $link)) {
                    $link = $line[0];
                }
                if (preg_match('/^(?:' . wfUrlProtocols() . ')/', $link)) {
                    $href = $link;
                } else {
                    $title = Title::newFromText($link);
                    if ($title) {
                        $title = $title->fixSpecialName();
                        $href = $title->getLocalURL();
                    } else {
                        $href = 'INVALID-TITLE';
                    }
                }
                $new_bar[$heading][] = array('text' => $text, 'href' => $href, 'id' => 'n-' . strtr($line[1], ' ', '-'), 'active' => false);
            } else {
                continue;
            }
        }
    }
    // End Mediawiki source
    if (count($new_bar) > 0) {
        return $new_bar;
    } else {
        return array();
    }
}
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:76,代码来源:CustomSidebar.php

示例12: parseItem

/**
 * Parse one line from MediaWiki message to array with indexes 'text' and 'href'
 *
 * @return array
 * @author Inez Korczynski <inez@wikia.com>
 */
function parseItem($line)
{
    wfProfileIn(__METHOD__);
    $href = $specialCanonicalName = false;
    $line_temp = explode('|', trim($line, '* '), 3);
    $line_temp[0] = trim($line_temp[0], '[]');
    if (count($line_temp) >= 2 && $line_temp[1] != '') {
        $line = trim($line_temp[1]);
        $link = trim(wfMsgForContent($line_temp[0]));
    } else {
        $line = trim($line_temp[0]);
        $link = trim($line_temp[0]);
    }
    $descText = null;
    if (count($line_temp) > 2 && $line_temp[2] != '') {
        $desc = $line_temp[2];
        if (wfEmptyMsg($desc, $descText = wfMsg($desc))) {
            $descText = $desc;
        }
    }
    if (wfEmptyMsg($line, $text = wfMsg($line))) {
        $text = $line;
    }
    if ($link != null) {
        if (wfEmptyMsg($line_temp[0], $link)) {
            $link = $line_temp[0];
        }
        if (preg_match('/^(?:' . wfUrlProtocols() . ')/', $link)) {
            $href = $link;
        } else {
            $title = Title::newFromText($link);
            if ($title) {
                if ($title->getNamespace() == NS_SPECIAL) {
                    $dbkey = $title->getDBkey();
                    $specialCanonicalName = array_shift(SpecialPageFactory::resolveAlias($dbkey));
                    if (!$specialCanonicalName) {
                        $specialCanonicalName = $dbkey;
                    }
                }
                $title = $title->fixSpecialName();
                $href = $title->getLocalURL();
            } else {
                $href = '#';
            }
        }
    }
    wfProfileOut(__METHOD__);
    return array('text' => $text, 'href' => $href, 'org' => $line_temp[0], 'desc' => $descText, 'specialCanonicalName' => $specialCanonicalName);
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:55,代码来源:GlobalFunctions.php

示例13: parseOneLine

 /**
  * @author: Inez Korczyński
  */
 public function parseOneLine($line)
 {
     wfProfileIn(__METHOD__);
     // trim spaces and asterisks from line and then split it to maximum two chunks
     $lineArr = explode('|', trim($line, '* '), 3);
     if (isset($lineArr[2])) {
         $specialParam = trim(addslashes($lineArr[2]));
         unset($lineArr[2]);
     } else {
         $specialParam = null;
     }
     // trim [ and ] from line to have just http://www.wikia.com instrad of [http://www.wikia.com] for external links
     $lineArr[0] = trim($lineArr[0], '[]');
     if (count($lineArr) == 2 && $lineArr[1] != '') {
         // * Foo|Bar - links with label
         $link = trim(wfMsgForContent($lineArr[0]));
         $desc = trim($lineArr[1]);
     } else {
         // * Foo
         $link = $desc = trim($lineArr[0]);
         // handle __NOLINK__ magic words (BugId:15189)
         if (substr($link, 0, 10) == self::NOLINK) {
             $link = $desc = substr($link, 10);
             $doNotLink = true;
         }
     }
     $text = null;
     if ($this->getShouldTranslateContent()) {
         $text = $this->forContent ? wfMsgForContent($desc) : wfMsg($desc);
     }
     if (empty($text) || wfEmptyMsg($desc, $text)) {
         $text = $desc;
     }
     if (wfEmptyMsg($lineArr[0], $link)) {
         $link = $lineArr[0];
     }
     if (empty($doNotLink)) {
         if (preg_match('/^(?:' . wfUrlProtocols() . ')/', $link)) {
             $href = $link;
         } else {
             if (empty($link)) {
                 $href = '#';
             } else {
                 if ($link[0] == '#') {
                     $href = '#';
                 } else {
                     //BugId:51034 - URL-encoded article titles break inter-wiki links
                     //in global Nav (but work correctly in the article body)
                     $title = Title::newFromText(urldecode($link));
                     if ($title instanceof Title) {
                         $href = $title->fixSpecialName()->getLocalURL();
                         $pos = strpos($link, '#');
                         if ($pos !== false) {
                             $sectionUrl = substr($link, $pos + 1);
                             if ($sectionUrl !== '') {
                                 $href .= '#' . $sectionUrl;
                             }
                         }
                     } else {
                         $href = '#';
                     }
                 }
             }
         }
     } else {
         $href = '#';
     }
     wfProfileOut(__METHOD__);
     return array(self::ORIGINAL => $lineArr[0], self::TEXT => $text, self::HREF => $href, self::SPECIAL => $specialParam);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:73,代码来源:NavigationModel.class.php

示例14: __construct

 /**
  * Constructor
  *
  * @param $conf array
  */
 public function __construct($conf = array())
 {
     $this->mConf = $conf;
     $this->mUrlProtocols = wfUrlProtocols();
     $this->mExtLinkBracketedRegex = '/\\[(((?i)' . $this->mUrlProtocols . ')' . self::EXT_LINK_URL_CLASS . '+)\\p{Zs}*([^\\]\\x00-\\x08\\x0a-\\x1F]*?)\\]/Su';
     if (isset($conf['preprocessorClass'])) {
         $this->mPreprocessorClass = $conf['preprocessorClass'];
     } elseif (defined('HPHP_VERSION')) {
         # Preprocessor_Hash is much faster than Preprocessor_DOM under HipHop
         $this->mPreprocessorClass = 'Preprocessor_Hash';
     } elseif (extension_loaded('domxml')) {
         # PECL extension that conflicts with the core DOM extension (bug 13770)
         wfDebug("Warning: you have the obsolete domxml extension for PHP. Please remove it!\n");
         $this->mPreprocessorClass = 'Preprocessor_Hash';
     } elseif (extension_loaded('dom')) {
         $this->mPreprocessorClass = 'Preprocessor_DOM';
     } else {
         $this->mPreprocessorClass = 'Preprocessor_Hash';
     }
     wfDebug(__CLASS__ . ": using preprocessor: {$this->mPreprocessorClass}\n");
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:26,代码来源:Parser.php

示例15: wfUrlProtocolsWithoutProtRel

/**
 * Like wfUrlProtocols(), but excludes '//' from the protocol list. Use this if
 * you need a regex that matches all URL protocols but does not match protocol-
 * relative URLs
 * @return string
 */
function wfUrlProtocolsWithoutProtRel()
{
    return wfUrlProtocols(false);
}
开发者ID:D66Ha,项目名称:mediawiki,代码行数:10,代码来源:GlobalFunctions.php


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