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


PHP WikiFactory::DomainToDB方法代码示例

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


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

示例1: getCorpDestImageName

	protected function getCorpDestImageName($wikiUrl, $origImageName, $index = false) {
		wfProfileIn(__METHOD__);

		if( $this->options->supressFileNames ) {
			$wikiDomain = trim( str_replace('http://', '', $wikiUrl), '/');
			$wikiDb = WikiFactory::DomainToDB($wikiDomain);
		}

		if( $this->options->supressFileNames && !empty($wikiDb) ) {
			if( $index === false ) {
				$resultName = UploadVisualizationImageFromFile::VISUALIZATION_MAIN_IMAGE_NAME;
				$resultNameArr = explode('.', $resultName);
				$resultName = $resultNameArr[0].','.$wikiDb.UploadVisualizationImageFromFile::VISUALIZATION_ADDITIONAL_IMAGES_EXT;
			} else {
				$resultName = UploadVisualizationImageFromFile::VISUALIZATION_ADDITIONAL_IMAGES_BASE_NAME.'-'.$index.','.$wikiDb.UploadVisualizationImageFromFile::VISUALIZATION_ADDITIONAL_IMAGES_EXT;
			}
		} else {
			$resultName = $origImageName;
		}

		wfProfileOut(__METHOD__);
		return $resultName;
	}
开发者ID:schwarer2006,项目名称:wikia,代码行数:23,代码来源:WikiaComWikisList.php

示例2: wfDevBoxForceWiki

/**
 * Hooks into WikiFactory to force use of the wiki which the developer
 * has explicitly set using this panel (if applicable).
 *
 * @return boolean true to allow the WikiFactoryLoader to do its other necessary initalization.
 */
function wfDevBoxForceWiki(WikiFactoryLoader $wikiFactoryLoader)
{
    global $wgDevelEnvironment, $wgExternalSharedDB, $wgCommandLineMode, $wgDevboxDefaultWikiDomain;
    if ($wgDevelEnvironment) {
        $forcedWikiDomain = getForcedWikiValue();
        $cityId = WikiFactory::DomainToID($forcedWikiDomain);
        if (!$cityId) {
            // If the overridden name doesn't exist AT ALL, use a default just to let the panel run.
            $forcedWikiDomain = $wgDevboxDefaultWikiDomain;
            $cityId = WikiFactory::DomainToID($forcedWikiDomain);
            wfDebug(__METHOD__ . ": domain forced to {$forcedWikiDomain}\n");
        }
        if ($wgCommandLineMode) {
            $cityId = getenv("SERVER_ID");
            if (is_numeric($cityId)) {
                $wikiFactoryLoader->mCityID = $cityId;
                $wikiFactoryLoader->mWikiID = $cityId;
            } else {
                $dbName = getenv("SERVER_DBNAME");
                /**
                 * find city_id by database name
                 */
                $dbr = WikiFactory::db(DB_SLAVE);
                $cityId = $dbr->selectField("city_list", array("city_id"), array("city_dbname" => $dbName), __METHOD__);
                if (is_numeric($cityId)) {
                    $wikiFactoryLoader->mCityID = $cityId;
                    $wikiFactoryLoader->mWikiID = $cityId;
                }
            }
        }
        if ($cityId) {
            $wikiFactoryLoader->mServerName = $forcedWikiDomain;
            // Need to set both in order to get our desired effects.
            $wikiFactoryLoader->mCityID = $cityId;
            $wikiFactoryLoader->mWikiID = $cityId;
        }
        // This section allows us to use c1 or c2 as a source for wiki databases
        // Be aware that this means the database has to be loaded in the right cluster according to wikicities!
        $db = WikiFactory::db(DB_SLAVE);
        $cluster = $db->selectField('city_list', 'city_cluster', ['city_id' => $cityId], __METHOD__);
        $wikiFactoryLoader->mVariables["wgDBcluster"] = $cluster;
        // Final sanity check to make sure our database exists
        if ($forcedWikiDomain != $wgDevboxDefaultWikiDomain) {
            // check if the wiki exist on a cluster
            wfDebug(__METHOD__ . ": checking if wiki #{$cityId} exists on {$cluster} cluster...\n");
            $dbname = WikiFactory::DomainToDB($forcedWikiDomain);
            $db = wfGetDB(DB_MASTER, [], $wgExternalSharedDB . '_' . $cluster);
            // force master - @see PLATFORM-528
            $res = $db->query('SHOW DATABASES ' . $db->buildLike($dbname), __METHOD__);
            // SHOW DATABASES LIKE 'muppet'
            if ($res->numRows() === 0) {
                header('HTTP/1.1 503');
                header('X-Error: missing database');
                header('Content-Type: text/plain');
                die("No local copy of database [{$dbname}] was found on {$cluster} cluster [using {$db->getServer()} DB].");
            }
        }
    }
    return true;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:66,代码来源:Special_DevBoxPanel.php

示例3: wfDevBoxForceWiki

/**
 * Hooks into WikiFactory to force use of the wiki which the developer
 * has explicitly set using this panel (if applicable).
 *
 * @return true to allow the WikiFactoryLoader to do its other necessary initalization.
 */
function wfDevBoxForceWiki(&$wikiFactoryLoader)
{
    global $wgDevelEnvironment, $wgWikiFactoryDB, $wgCommandLineMode;
    if ($wgDevelEnvironment) {
        $forcedWikiDomain = getForcedWikiValue();
        $cityId = WikiFactory::DomainToID($forcedWikiDomain);
        if (!$cityId) {
            // If the overridden name doesn't exist AT ALL, use a default just to let the panel run.
            $forcedWikiDomain = DEVBOX_DEFAULT_WIKI_DOMAIN;
            $cityId = WikiFactory::DomainToID($forcedWikiDomain);
        }
        if ($wgCommandLineMode) {
            $cityId = getenv("SERVER_ID");
            $wikiFactoryLoader->mCityID = $cityId;
            $wikiFactoryLoader->mWikiID = $cityId;
        }
        if ($cityId) {
            $wikiFactoryLoader->mServerName = $forcedWikiDomain;
            // Need to set both in order to get our desired effects.
            $wikiFactoryLoader->mCityID = $cityId;
            $wikiFactoryLoader->mWikiID = $cityId;
        }
        // This section allows us to use c1 or c2 as a source for wiki databases
        // Be aware that this means the database has to be loaded in the right cluster according to wikicities!
        $db = wfGetDB(DB_SLAVE, "dump", $wgWikiFactoryDB);
        $sql = 'SELECT city_cluster from city_list where city_id = ' . $cityId;
        $result = $db->query($sql, __METHOD__);
        $row = $result->fetchRow();
        $wikiFactoryLoader->mVariables["wgDBcluster"] = $row['city_cluster'];
        // Final sanity check to make sure our database exists
        if ($forcedWikiDomain != DEVBOX_DEFAULT_WIKI_DOMAIN) {
            $dbname = WikiFactory::DomainToDB($forcedWikiDomain);
            $db1 = wfGetDB(DB_SLAVE, "dump", $wgWikiFactoryDB . '_c1');
            $db2 = wfGetDB(DB_SLAVE, "dump", $wgWikiFactoryDB . '_c2');
            // lame
            $devbox_dbs = array_merge(getDevBoxOverrideDatabases($db1), getDevBoxOverrideDatabases($db2));
            if (array_search($dbname, $devbox_dbs) === false) {
                echo "<pre>Fatal Error: No local copy of database [{$dbname}] was found.</pre>";
                exit;
                // fatal error
            }
        }
        // TODO: move this into the config file
        global $wgReadOnly;
        $wgReadOnly = false;
    }
    return true;
}
开发者ID:schwarer2006,项目名称:wikia,代码行数:54,代码来源:Special_DevBoxPanel.php


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