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


PHP Interwiki类代码示例

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


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

示例1: wfGlobalInterwikis

function wfGlobalInterwikis($prefix, &$iwData)
{
    global $wgInterwikiCentralDB;
    // docs/hooks.txt says: Return true without providing an interwiki to continue interwiki search.
    if ($wgInterwikiCentralDB === null || $wgInterwikiCentralDB === wfWikiId()) {
        // No global set or this is global, nothing to add
        return true;
    }
    if (!Language::fetchLanguageName($prefix)) {
        // Check if prefix exists locally and skip
        foreach (Interwiki::getAllPrefixes(null) as $id => $localPrefixInfo) {
            if ($prefix === $localPrefixInfo['iw_prefix']) {
                return true;
            }
        }
        $dbr = wfGetDB(DB_SLAVE, array(), $wgInterwikiCentralDB);
        $res = $dbr->selectRow('interwiki', '*', array('iw_prefix' => $prefix), __METHOD__);
        if (!$res) {
            return true;
        }
        // Excplicitly make this an array since it's expected to be one
        $iwData = (array) $res;
        // At this point, we can safely return false because we know that we have something
        return false;
    }
    return true;
}
开发者ID:whysasse,项目名称:kmwiki,代码行数:27,代码来源:Interwiki.php

示例2: run

 /**
  * Execute the job
  *
  * @return bool
  */
 public function run()
 {
     //sleep() could be added here to reduce unnecessary use
     $ill = $this->params['ill'];
     foreach ($ill as $lang => $pages) {
         $iw = Interwiki::fetch($lang);
         if (!$iw) {
             continue;
         }
         $apiUrl = $iw->getAPI();
         if (!$apiUrl) {
             continue;
         }
         $apiUrl .= '?' . wfArrayToCGI(array('action' => 'purge', 'format' => 'json', 'titles' => implode('|', array_keys($pages))));
         Http::post($apiUrl);
         //TODO: error handling
     }
     return true;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:24,代码来源:InterlanguageCentralExtensionPurgeJob.php

示例3: load

 /**
  * Load the interwiki, trying first memcached then the DB
  *
  * @param string $prefix The interwiki prefix
  * @return Interwiki|bool Interwiki if $prefix is valid, otherwise false
  */
 protected static function load($prefix)
 {
     global $wgInterwikiExpiry;
     $iwData = array();
     if (!Hooks::run('InterwikiLoadPrefix', array($prefix, &$iwData))) {
         return Interwiki::loadFromArray($iwData);
     }
     $cache = ObjectCache::getMainWANInstance();
     if (!$iwData) {
         $key = wfMemcKey('interwiki', $prefix);
         $iwData = $cache->get($key);
         if ($iwData === '!NONEXISTENT') {
             // negative cache hit
             return false;
         }
     }
     // is_array is hack for old keys
     if ($iwData && is_array($iwData)) {
         $iw = Interwiki::loadFromArray($iwData);
         if ($iw) {
             return $iw;
         }
     }
     $db = wfGetDB(DB_SLAVE);
     $row = $db->fetchRow($db->select('interwiki', self::selectFields(), array('iw_prefix' => $prefix), __METHOD__));
     $iw = Interwiki::loadFromArray($row);
     if ($iw) {
         $mc = array('iw_url' => $iw->mURL, 'iw_api' => $iw->mAPI, 'iw_local' => $iw->mLocal, 'iw_trans' => $iw->mTrans);
         $cache->set($key, $mc, $wgInterwikiExpiry);
         return $iw;
     }
     // negative cache hit
     $cache->set($key, '!NONEXISTENT', $wgInterwikiExpiry);
     return false;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:41,代码来源:Interwiki.php

示例4: splitTitleString

 /**
  * Normalizes and splits a title string.
  *
  * This function removes illegal characters, splits off the interwiki and
  * namespace prefixes, sets the other forms, and canonicalizes
  * everything.
  *
  * @todo this method is only exposed as a temporary measure to ease refactoring.
  * It was copied with minimal changes from Title::secureAndSplit().
  *
  * @todo This method should be split up and an appropriate interface
  * defined for use by the Title class.
  *
  * @param string $text
  * @param int $defaultNamespace
  *
  * @throws MalformedTitleException If $text is not a valid title string.
  * @return array A mapp with the fields 'interwiki', 'fragment', 'namespace',
  *         'user_case_dbkey', and 'dbkey'.
  */
 public function splitTitleString($text, $defaultNamespace = NS_MAIN)
 {
     $dbkey = str_replace(' ', '_', $text);
     # Initialisation
     $parts = array('interwiki' => '', 'local_interwiki' => false, 'fragment' => '', 'namespace' => $defaultNamespace, 'dbkey' => $dbkey, 'user_case_dbkey' => $dbkey);
     # Strip Unicode bidi override characters.
     # Sometimes they slip into cut-n-pasted page titles, where the
     # override chars get included in list displays.
     $dbkey = preg_replace('/\\xE2\\x80[\\x8E\\x8F\\xAA-\\xAE]/S', '', $dbkey);
     # Clean up whitespace
     # Note: use of the /u option on preg_replace here will cause
     # input with invalid UTF-8 sequences to be nullified out in PHP 5.2.x,
     # conveniently disabling them.
     $dbkey = preg_replace('/[ _\\xA0\\x{1680}\\x{180E}\\x{2000}-\\x{200A}\\x{2028}\\x{2029}\\x{202F}\\x{205F}\\x{3000}]+/u', '_', $dbkey);
     $dbkey = trim($dbkey, '_');
     if (strpos($dbkey, UtfNormal\Constants::UTF8_REPLACEMENT) !== false) {
         # Contained illegal UTF-8 sequences or forbidden Unicode chars.
         throw new MalformedTitleException('title-invalid-utf8', $text);
     }
     $parts['dbkey'] = $dbkey;
     # Initial colon indicates main namespace rather than specified default
     # but should not create invalid {ns,title} pairs such as {0,Project:Foo}
     if ($dbkey !== '' && ':' == $dbkey[0]) {
         $parts['namespace'] = NS_MAIN;
         $dbkey = substr($dbkey, 1);
         # remove the colon but continue processing
         $dbkey = trim($dbkey, '_');
         # remove any subsequent whitespace
     }
     if ($dbkey == '') {
         throw new MalformedTitleException('title-invalid-empty', $text);
     }
     # Namespace or interwiki prefix
     $prefixRegexp = "/^(.+?)_*:_*(.*)\$/S";
     do {
         $m = array();
         if (preg_match($prefixRegexp, $dbkey, $m)) {
             $p = $m[1];
             if (($ns = $this->language->getNsIndex($p)) !== false) {
                 # Ordinary namespace
                 $dbkey = $m[2];
                 $parts['namespace'] = $ns;
                 # For Talk:X pages, check if X has a "namespace" prefix
                 if ($ns == NS_TALK && preg_match($prefixRegexp, $dbkey, $x)) {
                     if ($this->language->getNsIndex($x[1])) {
                         # Disallow Talk:File:x type titles...
                         throw new MalformedTitleException('title-invalid-talk-namespace', $text);
                     } elseif (Interwiki::isValidInterwiki($x[1])) {
                         // TODO: get rid of global state!
                         # Disallow Talk:Interwiki:x type titles...
                         throw new MalformedTitleException('title-invalid-talk-namespace', $text);
                     }
                 }
             } elseif (Interwiki::isValidInterwiki($p)) {
                 # Interwiki link
                 $dbkey = $m[2];
                 $parts['interwiki'] = $this->language->lc($p);
                 # Redundant interwiki prefix to the local wiki
                 foreach ($this->localInterwikis as $localIW) {
                     if (0 == strcasecmp($parts['interwiki'], $localIW)) {
                         if ($dbkey == '') {
                             # Empty self-links should point to the Main Page, to ensure
                             # compatibility with cross-wiki transclusions and the like.
                             $mainPage = Title::newMainPage();
                             return array('interwiki' => $mainPage->getInterwiki(), 'local_interwiki' => true, 'fragment' => $mainPage->getFragment(), 'namespace' => $mainPage->getNamespace(), 'dbkey' => $mainPage->getDBkey(), 'user_case_dbkey' => $mainPage->getUserCaseDBKey());
                         }
                         $parts['interwiki'] = '';
                         # local interwikis should behave like initial-colon links
                         $parts['local_interwiki'] = true;
                         # Do another namespace split...
                         continue 2;
                     }
                 }
                 # If there's an initial colon after the interwiki, that also
                 # resets the default namespace
                 if ($dbkey !== '' && $dbkey[0] == ':') {
                     $parts['namespace'] = NS_MAIN;
                     $dbkey = substr($dbkey, 1);
                 }
             }
//.........这里部分代码省略.........
开发者ID:ngertrudiz,项目名称:mediawiki,代码行数:101,代码来源:MediaWikiTitleCodec.php

示例5: showList

 function showList()
 {
     global $wgInterwikiCentralDB, $wgInterwikiViewOnly;
     $canModify = $this->canModify();
     // Build lists
     if (!method_exists('Interwiki', 'getAllPrefixes')) {
         // version 2.0 is not backwards compatible (but will still display a nice error)
         $this->error('interwiki_error');
         return;
     }
     $iwPrefixes = Interwiki::getAllPrefixes(null);
     $iwGlobalPrefixes = array();
     if ($wgInterwikiCentralDB !== null && $wgInterwikiCentralDB !== wfWikiId()) {
         // Fetch list from global table
         $dbrCentralDB = wfGetDB(DB_SLAVE, array(), $wgInterwikiCentralDB);
         $res = $dbrCentralDB->select('interwiki', '*', false, __METHOD__);
         $retval = array();
         foreach ($res as $row) {
             $row = (array) $row;
             if (!Language::fetchLanguageName($row['iw_prefix'])) {
                 $retval[] = $row;
             }
         }
         $iwGlobalPrefixes = $retval;
     }
     // Split out language links
     $iwLocalPrefixes = array();
     $iwLanguagePrefixes = array();
     foreach ($iwPrefixes as $iwPrefix) {
         if (Language::fetchLanguageName($iwPrefix['iw_prefix'])) {
             $iwLanguagePrefixes[] = $iwPrefix;
         } else {
             $iwLocalPrefixes[] = $iwPrefix;
         }
     }
     // Page intro content
     $this->getOutput()->addWikiMsg('interwiki_intro');
     // Add 'view log' link when possible
     if ($wgInterwikiViewOnly === false) {
         $logLink = Linker::link(SpecialPage::getTitleFor('Log', 'interwiki'), $this->msg('interwiki-logtext')->escaped());
         $this->getOutput()->addHTML('<p class="mw-interwiki-log">' . $logLink . '</p>');
     }
     // Add 'add' link
     if ($canModify) {
         if (count($iwGlobalPrefixes) !== 0) {
             $addtext = $this->msg('interwiki-addtext-local')->escaped();
         } else {
             $addtext = $this->msg('interwiki_addtext')->escaped();
         }
         $addlink = Linker::linkKnown($this->getPageTitle('add'), $addtext);
         $this->getOutput()->addHTML('<p class="mw-interwiki-addlink">' . $addlink . '</p>');
     }
     $this->getOutput()->addWikiMsg('interwiki-legend');
     if (!is_array($iwPrefixes) || count($iwPrefixes) === 0) {
         if (!is_array($iwGlobalPrefixes) || count($iwGlobalPrefixes) === 0) {
             // If the interwiki table(s) are empty, display an error message
             $this->error('interwiki_error');
             return;
         }
     }
     // Add the global table
     if (count($iwGlobalPrefixes) !== 0) {
         $this->getOutput()->addHTML('<h2 id="interwikitable-global">' . $this->msg('interwiki-global-links')->parse() . '</h2>');
         $this->getOutput()->addWikiMsg('interwiki-global-description');
         // $canModify is false here because this is just a display of remote data
         $this->makeTable(false, $iwGlobalPrefixes);
     }
     // Add the local table
     if (count($iwLocalPrefixes) !== 0) {
         if (count($iwGlobalPrefixes) !== 0) {
             $this->getOutput()->addHTML('<h2 id="interwikitable-local">' . $this->msg('interwiki-local-links')->parse() . '</h2>');
             $this->getOutput()->addWikiMsg('interwiki-local-description');
         } else {
             $this->getOutput()->addHTML('<h2 id="interwikitable-local">' . $this->msg('interwiki-links')->parse() . '</h2>');
             $this->getOutput()->addWikiMsg('interwiki-description');
         }
         $this->makeTable($canModify, $iwLocalPrefixes);
     }
     // Add the language table
     if (count($iwLanguagePrefixes) !== 0) {
         $this->getOutput()->addHTML('<h2 id="interwikitable-language">' . $this->msg('interwiki-language-links')->parse() . '</h2>');
         $this->getOutput()->addWikiMsg('interwiki-language-description');
         $this->makeTable($canModify, $iwLanguagePrefixes);
     }
 }
开发者ID:odorsey,项目名称:mediawiki-heroku,代码行数:85,代码来源:Interwiki_body.php

示例6: appendInterwikiMap

 protected function appendInterwikiMap($property, $filter)
 {
     $local = null;
     if ($filter === 'local') {
         $local = 1;
     } elseif ($filter === '!local') {
         $local = 0;
     } elseif ($filter) {
         ApiBase::dieDebug(__METHOD__, "Unknown filter={$filter}");
     }
     $params = $this->extractRequestParams();
     $langCode = isset($params['inlanguagecode']) ? $params['inlanguagecode'] : '';
     $langNames = Language::fetchLanguageNames($langCode);
     $getPrefixes = Interwiki::getAllPrefixes($local);
     $extraLangPrefixes = $this->getConfig()->get('ExtraInterlanguageLinkPrefixes');
     $localInterwikis = $this->getConfig()->get('LocalInterwikis');
     $data = array();
     foreach ($getPrefixes as $row) {
         $prefix = $row['iw_prefix'];
         $val = array();
         $val['prefix'] = $prefix;
         if (isset($row['iw_local']) && $row['iw_local'] == '1') {
             $val['local'] = '';
         }
         if ($row['iw_trans'] == '1') {
             $val['trans'] = '';
         }
         if (isset($langNames[$prefix])) {
             $val['language'] = $langNames[$prefix];
         }
         if (in_array($prefix, $localInterwikis)) {
             $val['localinterwiki'] = '';
         }
         if (in_array($prefix, $extraLangPrefixes)) {
             $val['extralanglink'] = '';
             $linktext = wfMessage("interlanguage-link-{$prefix}");
             if (!$linktext->isDisabled()) {
                 $val['linktext'] = $linktext->text();
             }
             $sitename = wfMessage("interlanguage-link-sitename-{$prefix}");
             if (!$sitename->isDisabled()) {
                 $val['sitename'] = $sitename->text();
             }
         }
         $val['url'] = wfExpandUrl($row['iw_url'], PROTO_CURRENT);
         if (substr($row['iw_url'], 0, 2) == '//') {
             $val['protorel'] = '';
         }
         if (isset($row['iw_wikiid'])) {
             $val['wikiid'] = $row['iw_wikiid'];
         }
         if (isset($row['iw_api'])) {
             $val['api'] = $row['iw_api'];
         }
         $data[] = $val;
     }
     $this->getResult()->setIndexedTagName($data, 'iw');
     return $this->getResult()->addValue('query', $property, $data);
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:59,代码来源:ApiQuerySiteinfo.php

示例7: secureAndSplit

 /**
  * Secure and split - main initialisation function for this object
  *
  * Assumes that mDbkeyform has been set, and is urldecoded
  * and uses underscores, but not otherwise munged.  This function
  * removes illegal characters, splits off the interwiki and
  * namespace prefixes, sets the other forms, and canonicalizes
  * everything.
  * @return \type{\bool} true on success
  */
 private function secureAndSplit()
 {
     global $wgContLang, $wgLocalInterwiki, $wgCapitalLinks;
     # Initialisation
     static $rxTc = false;
     if (!$rxTc) {
         # Matching titles will be held as illegal.
         $rxTc = '/' . '[^' . Title::legalChars() . ']' . '|%[0-9A-Fa-f]{2}' . '|&[A-Za-z0-9\\x80-\\xff]+;' . '|&#[0-9]+;' . '|&#x[0-9A-Fa-f]+;' . '/S';
     }
     $this->mInterwiki = $this->mFragment = '';
     $this->mNamespace = $this->mDefaultNamespace;
     # Usually NS_MAIN
     $dbkey = $this->mDbkeyform;
     # Strip Unicode bidi override characters.
     # Sometimes they slip into cut-n-pasted page titles, where the
     # override chars get included in list displays.
     $dbkey = preg_replace('/\\xE2\\x80[\\x8E\\x8F\\xAA-\\xAE]/S', '', $dbkey);
     # Clean up whitespace
     #
     $dbkey = preg_replace('/[ _]+/', '_', $dbkey);
     $dbkey = trim($dbkey, '_');
     if ('' == $dbkey) {
         return false;
     }
     if (false !== strpos($dbkey, UTF8_REPLACEMENT)) {
         # Contained illegal UTF-8 sequences or forbidden Unicode chars.
         return false;
     }
     $this->mDbkeyform = $dbkey;
     # Initial colon indicates main namespace rather than specified default
     # but should not create invalid {ns,title} pairs such as {0,Project:Foo}
     if (':' == $dbkey[0]) {
         $this->mNamespace = NS_MAIN;
         $dbkey = substr($dbkey, 1);
         # remove the colon but continue processing
         $dbkey = trim($dbkey, '_');
         # remove any subsequent whitespace
     }
     # Namespace or interwiki prefix
     $firstPass = true;
     do {
         $m = array();
         if (preg_match("/^(.+?)_*:_*(.*)\$/S", $dbkey, $m)) {
             $p = $m[1];
             if ($ns = $wgContLang->getNsIndex($p)) {
                 # Ordinary namespace
                 $dbkey = $m[2];
                 $this->mNamespace = $ns;
             } elseif (Interwiki::isValidInterwiki($p)) {
                 if (!$firstPass) {
                     # Can't make a local interwiki link to an interwiki link.
                     # That's just crazy!
                     return false;
                 }
                 # Interwiki link
                 $dbkey = $m[2];
                 $this->mInterwiki = $wgContLang->lc($p);
                 # Redundant interwiki prefix to the local wiki
                 if (0 == strcasecmp($this->mInterwiki, $wgLocalInterwiki)) {
                     if ($dbkey == '') {
                         # Can't have an empty self-link
                         return false;
                     }
                     $this->mInterwiki = '';
                     $firstPass = false;
                     # Do another namespace split...
                     continue;
                 }
                 # If there's an initial colon after the interwiki, that also
                 # resets the default namespace
                 if ($dbkey !== '' && $dbkey[0] == ':') {
                     $this->mNamespace = NS_MAIN;
                     $dbkey = substr($dbkey, 1);
                 }
             }
             # If there's no recognized interwiki or namespace,
             # then let the colon expression be part of the title.
         }
         break;
     } while (true);
     # We already know that some pages won't be in the database!
     #
     if ('' != $this->mInterwiki || NS_SPECIAL == $this->mNamespace) {
         $this->mArticleID = 0;
     }
     $fragment = strstr($dbkey, '#');
     if (false !== $fragment) {
         $this->setFragment($fragment);
         $dbkey = substr($dbkey, 0, strlen($dbkey) - strlen($fragment));
         # remove whitespace again: prevents "Foo_bar_#"
//.........这里部分代码省略.........
开发者ID:amjadtbssm,项目名称:website,代码行数:101,代码来源:Title.php

示例8: getLocalURL

 /**
  * Get a URL with no fragment or server name (relative URL) from a Title object.
  * If this page is generated with action=render, however,
  * $wgServer is prepended to make an absolute URL.
  *
  * @see self::getFullURL to always get an absolute URL.
  * @see self::getLinkURL to always get a URL that's the simplest URL that will be
  *  valid to link, locally, to the current Title.
  * @see self::newFromText to produce a Title object.
  *
  * @param string|array $query An optional query string,
  *   not used for interwiki links. Can be specified as an associative array as well,
  *   e.g., array( 'action' => 'edit' ) (keys and values will be URL-escaped).
  *   Some query patterns will trigger various shorturl path replacements.
  * @param array $query2 An optional secondary query array. This one MUST
  *   be an array. If a string is passed it will be interpreted as a deprecated
  *   variant argument and urlencoded into a variant= argument.
  *   This second query argument will be added to the $query
  *   The second parameter is deprecated since 1.19. Pass it as a key,value
  *   pair in the first parameter array instead.
  *
  * @return string String of the URL.
  */
 public function getLocalURL($query = '', $query2 = false)
 {
     global $wgArticlePath, $wgScript, $wgServer, $wgRequest;
     $query = self::fixUrlQueryArgs($query, $query2);
     $interwiki = Interwiki::fetch($this->mInterwiki);
     if ($interwiki) {
         $namespace = $this->getNsText();
         if ($namespace != '') {
             # Can this actually happen? Interwikis shouldn't be parsed.
             # Yes! It can in interwiki transclusion. But... it probably shouldn't.
             $namespace .= ':';
         }
         $url = $interwiki->getURL($namespace . $this->getDBkey());
         $url = wfAppendQuery($url, $query);
     } else {
         $dbkey = wfUrlencode($this->getPrefixedDBkey());
         if ($query == '') {
             $url = str_replace('$1', $dbkey, $wgArticlePath);
             Hooks::run('GetLocalURL::Article', array(&$this, &$url));
         } else {
             global $wgVariantArticlePath, $wgActionPaths, $wgContLang;
             $url = false;
             $matches = array();
             if (!empty($wgActionPaths) && preg_match('/^(.*&|)action=([^&]*)(&(.*)|)$/', $query, $matches)) {
                 $action = urldecode($matches[2]);
                 if (isset($wgActionPaths[$action])) {
                     $query = $matches[1];
                     if (isset($matches[4])) {
                         $query .= $matches[4];
                     }
                     $url = str_replace('$1', $dbkey, $wgActionPaths[$action]);
                     if ($query != '') {
                         $url = wfAppendQuery($url, $query);
                     }
                 }
             }
             if ($url === false && $wgVariantArticlePath && $wgContLang->getCode() === $this->getPageLanguage()->getCode() && $this->getPageLanguage()->hasVariants() && preg_match('/^variant=([^&]*)$/', $query, $matches)) {
                 $variant = urldecode($matches[1]);
                 if ($this->getPageLanguage()->hasVariant($variant)) {
                     // Only do the variant replacement if the given variant is a valid
                     // variant for the page's language.
                     $url = str_replace('$2', urlencode($variant), $wgVariantArticlePath);
                     $url = str_replace('$1', $dbkey, $url);
                 }
             }
             if ($url === false) {
                 if ($query == '-') {
                     $query = '';
                 }
                 $url = "{$wgScript}?title={$dbkey}&{$query}";
             }
         }
         Hooks::run('GetLocalURL::Internal', array(&$this, &$url, $query));
         // @todo FIXME: This causes breakage in various places when we
         // actually expected a local URL and end up with dupe prefixes.
         if ($wgRequest->getVal('action') == 'render') {
             $url = $wgServer . $url;
         }
     }
     Hooks::run('GetLocalURL', array(&$this, &$url, $query));
     return $url;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:85,代码来源:Title.php

示例9: appendInterwikiMap

 protected function appendInterwikiMap($property, $filter)
 {
     $local = null;
     if ($filter === 'local') {
         $local = 1;
     } elseif ($filter === '!local') {
         $local = 0;
     } elseif ($filter) {
         ApiBase::dieDebug(__METHOD__, "Unknown filter={$filter}");
     }
     $params = $this->extractRequestParams();
     $langCode = isset($params['inlanguagecode']) ? $params['inlanguagecode'] : '';
     if ($langCode) {
         $langNames = Language::getTranslatedLanguageNames($langCode);
     } else {
         $langNames = Language::getLanguageNames();
     }
     $getPrefixes = Interwiki::getAllPrefixes($local);
     $data = array();
     foreach ($getPrefixes as $row) {
         $prefix = $row['iw_prefix'];
         $val = array();
         $val['prefix'] = $prefix;
         if ($row['iw_local'] == '1') {
             $val['local'] = '';
         }
         // $val['trans'] = intval( $row['iw_trans'] ); // should this be exposed?
         if (isset($langNames[$prefix])) {
             $val['language'] = $langNames[$prefix];
         }
         $val['url'] = wfExpandUrl($row['iw_url'], PROTO_CURRENT);
         if (isset($row['iw_wikiid'])) {
             $val['wikiid'] = $row['iw_wikiid'];
         }
         if (isset($row['iw_api'])) {
             $val['api'] = $row['iw_api'];
         }
         $data[] = $val;
     }
     $this->getResult()->setIndexedTagName($data, 'iw');
     return $this->getResult()->addValue('query', $property, $data);
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:42,代码来源:ApiQuerySiteinfo.php

示例10: load

 /**
  * Load the interwiki, trying first memcached then the DB
  *
  * @param string $prefix The interwiki prefix
  * @return Interwiki|bool Interwiki if $prefix is valid, otherwise false
  */
 protected static function load($prefix)
 {
     global $wgInterwikiExpiry;
     $iwData = array();
     if (!Hooks::run('InterwikiLoadPrefix', array($prefix, &$iwData))) {
         return Interwiki::loadFromArray($iwData);
     }
     if (is_array($iwData)) {
         $iw = Interwiki::loadFromArray($iwData);
         if ($iw) {
             return $iw;
             // handled by hook
         }
     }
     $iwData = ObjectCache::getMainWANInstance()->getWithSetCallback(wfMemcKey('interwiki', $prefix), $wgInterwikiExpiry, function ($oldValue, &$ttl, array &$setOpts) use($prefix) {
         $dbr = wfGetDB(DB_SLAVE);
         $setOpts += Database::getCacheSetOptions($dbr);
         $row = $dbr->selectRow('interwiki', Interwiki::selectFields(), array('iw_prefix' => $prefix), __METHOD__);
         return $row ? (array) $row : '!NONEXISTENT';
     });
     if (is_array($iwData)) {
         return Interwiki::loadFromArray($iwData) ?: false;
     }
     return false;
 }
开发者ID:xiebinyi,项目名称:mediawiki,代码行数:31,代码来源:Interwiki.php

示例11: testArrayStorage

 public function testArrayStorage()
 {
     $dewiki = ['iw_prefix' => 'de', 'iw_url' => 'http://de.wikipedia.org/wiki/', 'iw_local' => 1];
     $zzwiki = ['iw_prefix' => 'zz', 'iw_url' => 'http://zzwiki.org/wiki/', 'iw_local' => 0];
     $cdbData = $this->populateHash('en', [$dewiki], [$zzwiki]);
     $this->setWgInterwikiCache($cdbData);
     $this->assertEquals([$dewiki, $zzwiki], Interwiki::getAllPrefixes(), 'getAllPrefixes()');
     $this->assertTrue(Interwiki::isValidInterwiki('de'), 'known prefix is valid');
     $this->assertTrue(Interwiki::isValidInterwiki('zz'), 'known prefix is valid');
     $interwiki = Interwiki::fetch('de');
     $this->assertInstanceOf('Interwiki', $interwiki);
     $this->assertSame('http://de.wikipedia.org/wiki/', $interwiki->getURL(), 'getURL');
     $this->assertSame(true, $interwiki->isLocal(), 'isLocal');
     $interwiki = Interwiki::fetch('zz');
     $this->assertInstanceOf('Interwiki', $interwiki);
     $this->assertSame('http://zzwiki.org/wiki/', $interwiki->getURL(), 'getURL');
     $this->assertSame(false, $interwiki->isLocal(), 'isLocal');
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:18,代码来源:InterwikiTest.php

示例12: getButtonHrefByObjectReference

 /**
  * Generate the URL out of the object reference
  *
  * @param string $objRef
  * @return bool|string
  */
 private function getButtonHrefByObjectReference($objRef)
 {
     $arrObjRef = explode('|', $objRef);
     if (count($arrObjRef) > 1) {
         list($wiki, $title) = $arrObjRef;
         if (Interwiki::isValidInterwiki($wiki)) {
             return str_replace('$1', $title, Interwiki::fetch($wiki)->getURL());
         }
     }
     return false;
 }
开发者ID:robksawyer,项目名称:lathe.tools,代码行数:17,代码来源:UploadWizardCampaign.php

示例13: interwikiMap

 public function interwikiMap($filter = null)
 {
     global $wgLocalInterwikis, $wgExtraInterlanguageLinkPrefixes;
     $this->checkTypeOptional('interwikiMap', 1, $filter, 'string', null);
     $local = null;
     if ($filter === 'local') {
         $local = 1;
     } elseif ($filter === '!local') {
         $local = 0;
     } elseif ($filter !== null) {
         throw new Scribunto_LuaError("bad argument #1 to 'interwikiMap' (unknown filter '{$filter}')");
     }
     $cacheKey = $filter === null ? 'null' : $filter;
     if (!isset(self::$interwikiMapCache[$cacheKey])) {
         // Not expensive because we can have a max of three cache misses in the
         // entire page parse.
         $interwikiMap = array();
         $prefixes = Interwiki::getAllPrefixes($local);
         foreach ($prefixes as $row) {
             $prefix = $row['iw_prefix'];
             $val = array('prefix' => $prefix, 'url' => wfExpandUrl($row['iw_url'], PROTO_RELATIVE), 'isProtocolRelative' => substr($row['iw_url'], 0, 2) === '//', 'isLocal' => isset($row['iw_local']) && $row['iw_local'] == '1', 'isTranscludable' => isset($row['iw_trans']) && $row['iw_trans'] == '1', 'isCurrentWiki' => in_array($prefix, $wgLocalInterwikis), 'isExtraLanguageLink' => in_array($prefix, $wgExtraInterlanguageLinkPrefixes));
             if ($val['isExtraLanguageLink']) {
                 $displayText = wfMessage("interlanguage-link-{$prefix}");
                 if (!$displayText->isDisabled()) {
                     $val['displayText'] = $displayText->text();
                 }
                 $tooltip = wfMessage("interlanguage-link-sitename-{$prefix}");
                 if (!$tooltip->isDisabled()) {
                     $val['tooltip'] = $tooltip->text();
                 }
             }
             $interwikiMap[$prefix] = $val;
         }
         self::$interwikiMapCache[$cacheKey] = $interwikiMap;
     }
     return array(self::$interwikiMapCache[$cacheKey]);
 }
开发者ID:sammykumar,项目名称:TheVRForums,代码行数:37,代码来源:SiteLibrary.php

示例14: load

 /**
  * Load the interwiki, trying first memcached then the DB
  *
  * @param $prefix The interwiki prefix
  * @return bool The prefix is valid
  * @static
  *
  */
 protected static function load($prefix)
 {
     global $wgMemc, $wgInterwikiExpiry;
     global $wgLanguageNames;
     $key = wfMemcKey('interwiki', $prefix);
     $mc = $wgMemc->get($key);
     $iw = false;
     if ($mc && is_array($mc)) {
         // is_array is hack for old keys
         $iw = Interwiki::loadFromArray($mc);
         if ($iw) {
             return $iw;
         }
     }
     # $$$ Sean: This is a hack to get the interwiki links working
     # but only accept a prefix that is a valid language
     if (isset($prefix, $wgLanguageNames[$prefix]) && '' != $wgLanguageNames[$prefix]) {
         $iw = new Interwiki();
         $iw->mURL = $prefix . '.wiki';
         $iw->mLocal = 0;
         $iw->mTrans = 0;
     } else {
         $iw = false;
     }
     /*
     $db = wfGetDB( DB_SLAVE );
     
     $row = $db->fetchRow( $db->select( 'interwiki', '*', array( 'iw_prefix' => $prefix ),
     	__METHOD__ ) );
     $iw = Interwiki::loadFromArray( $row );
     */
     # $$$ end of hack
     if ($iw) {
         $mc = array('iw_url' => $iw->mURL, 'iw_local' => $iw->mLocal, 'iw_trans' => $iw->mTrans);
         $wgMemc->add($key, $mc, $wgInterwikiExpiry);
         return $iw;
     }
     return false;
 }
开发者ID:nzmichaelh,项目名称:wrdk,代码行数:47,代码来源:Interwiki.php

示例15: load

 /**
  * Load the interwiki, trying first memcached then the DB
  *
  * @param $prefix string The interwiki prefix
  * @return Boolean: the prefix is valid
  */
 protected static function load($prefix)
 {
     global $wgMemc, $wgInterwikiExpiry;
     $iwData = false;
     if (!wfRunHooks('InterwikiLoadPrefix', array($prefix, &$iwData))) {
         return Interwiki::loadFromArray($iwData);
     }
     if (!$iwData) {
         $key = wfMemcKey('interwiki', md5($prefix));
         $iwData = $wgMemc->get($key);
         if ($iwData === '!NONEXISTENT') {
             return false;
             // negative cache hit
         }
     }
     if ($iwData && is_array($iwData)) {
         // is_array is hack for old keys
         $iw = Interwiki::loadFromArray($iwData);
         if ($iw) {
             return $iw;
         }
     }
     $db = wfGetDB(DB_SLAVE);
     $row = $db->fetchRow($db->select('interwiki', '*', array('iw_prefix' => $prefix), __METHOD__));
     $iw = Interwiki::loadFromArray($row);
     if ($iw) {
         $mc = array('iw_url' => $iw->mURL, 'iw_api' => $iw->mAPI, 'iw_local' => $iw->mLocal, 'iw_trans' => $iw->mTrans);
         $wgMemc->add($key, $mc, $wgInterwikiExpiry);
         return $iw;
     } else {
         $wgMemc->add($key, '!NONEXISTENT', $wgInterwikiExpiry);
         // negative cache hit
     }
     return false;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:41,代码来源:Interwiki.php


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