本文整理汇总了PHP中WikiFactory::DBtoID方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory::DBtoID方法的具体用法?PHP WikiFactory::DBtoID怎么用?PHP WikiFactory::DBtoID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiFactory
的用法示例。
在下文中一共展示了WikiFactory::DBtoID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPathPrefix
function getPathPrefix()
{
$wikiDbName = $this->repo->getDBName();
$wikiId = WikiFactory::DBtoID($wikiDbName);
$wikiUploadPath = WikiFactory::getVarValueByName('wgUploadPath', $wikiId);
return VignetteRequest::parsePathPrefix($wikiUploadPath);
}
示例2: getCityId
public function getCityId()
{
if (empty($this->cityId) and !empty($this->dbName)) {
$this->cityId = WikiFactory::DBtoID($this->dbName);
}
return $this->cityId;
}
示例3: setDBname
public function setDBname($dbname = '')
{
if ($dbname) {
$this->mDBname = $this->__getDBname($dbname);
$this->mWikiID = WikiFactory::DBtoID($this->mDBname);
$this->mWikia = WikiFactory::getWikiByID($this->mWikiID);
}
}
示例4: getCityIdByDbName
/**
* Get wiki ID by its db name
*
* @param $dbName string Database name
* @return int Wiki ID (or null)
*/
protected function getCityIdByDbName($dbName)
{
$id = null;
if ($dbName === 'c') {
$id = self::COMMUNITY_WIKI_ID;
}
if ($id === null) {
$id = WikiFactory::DBtoID($dbName);
}
return $id;
}
示例5: getHostByDbName
/**
* Get domain for a wiki using given database name
*
* @param string database name
* @return string HTTP domain
*/
private static function getHostByDbName($dbname)
{
global $wgDevelEnvironment, $wgDevelEnvironmentName;
if (!empty($wgDevelEnvironment)) {
$hostName = "http://{$dbname}.{$wgDevelEnvironmentName}.wikia-dev.com";
} else {
$cityId = WikiFactory::DBtoID($dbname);
$hostName = WikiFactory::getVarValueByName('wgServer', $cityId);
}
return rtrim($hostName, '/');
}
示例6: getCityIdByDbName
/**
* Get wiki ID by its db name
*
* @param $dbName string Database name
* @return int Wiki ID (or null)
*/
protected static function getCityIdByDbName($dbName)
{
wfProfileIn(__METHOD__);
$id = null;
if ($dbName === 'c') {
$id = self::COMMUNITY_WIKI_ID;
}
if ($id === null) {
$id = WikiFactory::DBtoID($dbName);
}
wfProfileOut(__METHOD__);
return $id;
}
示例7: getHostByDbName
/**
* Get domain for a wiki using given database name
*
* @param string $dbName database name
*
* @return string HTTP domain
*/
private static function getHostByDbName($dbName)
{
global $wgDevelEnvironment, $wgDevelEnvironmentName;
$cityId = WikiFactory::DBtoID($dbName);
$hostName = WikiFactory::getVarValueByName('wgServer', $cityId);
if (!empty($wgDevelEnvironment)) {
if (strpos($hostName, "wikia.com")) {
$hostName = str_replace("wikia.com", "{$wgDevelEnvironmentName}.wikia-dev.com", $hostName);
} else {
$hostName = WikiFactory::getLocalEnvURL($hostName);
}
}
return rtrim($hostName, '/');
}
示例8: getSectionForWiki
function getSectionForWiki($wiki = false)
{
global $wgDBname, $wgDBcluster, $smwgUseExternalDB;
if ($this->lastWiki === $wiki) {
return $this->lastSection;
}
list($dbName, $prefix) = $this->getDBNameAndPrefix($wiki);
/**
* actually we should not have any fallback because it will end with
* fatal anyway.
*
* But it makes PHP happy
*/
$section = 'central';
$this->isSMWClusterActive = false;
if ($smwgUseExternalDB) {
/**
* set flag, strip database name
*/
if (substr($dbName, 0, 4) == "smw+" && isset($this->sectionsByDB["smw+"])) {
$this->isSMWClusterActive = true;
$dbName = substr($dbName, 4);
wfDebugLog("connect", __METHOD__ . ": smw+ cluster is active, dbname changed to {$dbName}\n", true);
}
}
if (isset($this->sectionsByDB[$dbName])) {
// this is a db that has a cluster defined in the config file (DB.php)
$section = $this->sectionsByDB[$dbName];
} elseif ($this->isSMWClusterActive) {
// use smw+ entry
$section = $this->sectionsByDB["smw+"];
wfDebugLog("connect", __METHOD__ . "-smw: section {$section} choosen for {$wiki}\n");
} elseif ($dbName == $wgDBname) {
// this is a local db so use global variables
if (isset($wgDBcluster)) {
$section = $wgDBcluster;
}
} else {
// this is a foreign db that either has a cluster defined in WikiFactory...
$section = WikiFactory::getVarValueByName('wgDBcluster', WikiFactory::DBtoID($wiki));
if (empty($section)) {
$section = 'central';
}
}
$this->lastSection = $section;
$this->lastWiki = $wiki;
wfDebugLog("connect", __METHOD__ . ": section {$this->lastSection}, wiki {$this->lastWiki}\n");
return $section;
}
示例9: getBlogPostData
/**
* Returns given blog post data
*
* @param string $dbname database name
* @param string $title page title
* @param boolean $getSnippet include blog post snippet in the data
* @return mixed blog post data
*/
private function getBlogPostData($dbname, $title, $getSnippet = false)
{
wfProfileIn(__METHOD__);
wfDebug(__METHOD__ . ": '{$title}' ({$dbname})\n");
$cityId = WikiFactory::DBtoID($dbname);
// get blog info
$data = ApiService::foreignCall($dbname, array('action' => 'query', 'prop' => 'revisions', 'titles' => $title, 'rvprop' => 'timestamp|user|content'));
$blogPostData = reset($data['query']['pages']);
$revisionData = array_shift($blogPostData['revisions']);
// page ID
$pageId = intval($blogPostData['pageid']);
// parse blog post wikitext and get summary
if ($getSnippet === true) {
$data = ApiService::foreignCall($dbname, array('action' => 'parse', 'text' => $revisionData['*'], 'title' => $title));
$snippet = $this->getSnippet($data['parse']['text']['*']);
}
// generate full URL to blog post
$blogPostTitle = F::build('GlobalTitle', array($pageId, $cityId), 'newFromId');
if (empty($blogPostTitle)) {
wfProfileOut(__METHOD__);
return false;
}
$blogPostUrl = $blogPostTitle->getFullURL();
// get blog post title
$title = end(explode('/', $blogPostTitle->getText(), 2));
// get creator real name
$creator = F::build('User', array($revisionData['user']), 'newFromName');
if (!empty($creator)) {
$creatorName = $creator->getRealName();
if ($creatorName == '') {
$creatorName = $creator->getName();
}
} else {
$creatorName = $revisionData['user'];
}
// get creator user page URL
$blogCreatorPageTitle = F::build('GlobalTitle', array($revisionData['user'], NS_USER, $cityId), 'newFromText');
// get 220x140 image
$imageData = ApiService::foreignCall($dbname, array('action' => 'imagecrop', 'imgId' => $pageId, 'imgSize' => 220, 'imgHeight' => 140));
// data
$res = array('pageId' => $pageId, 'cityId' => $cityId, 'wikiname' => WikiFactory::getVarValueByName('wgSitename', $cityId), 'wikiUrl' => 'http://' . parse_url($blogPostUrl, PHP_URL_HOST), 'title' => $title, 'url' => $blogPostUrl, 'created' => $revisionData['timestamp'], 'creator' => $creatorName, 'creatorUrl' => $blogCreatorPageTitle->getFullURL(), 'snippet' => !empty($snippet) ? $snippet : false, 'image' => $imageData['image']['imagecrop']);
wfProfileOut(__METHOD__);
return $res;
}
示例10: __construct
/**
* constructor
* If email and password are empty, will use the default preferred account from '
*
* @access public
*/
public function __construct($email, $pass, $wiki = null)
{
global $wgGoogleWebToolsAccts;
// If email and password weren't specified, use the preferred account.
if (empty($email) && empty($pass)) {
if (is_array($wgGoogleWebToolsAccts)) {
foreach ($wgGoogleWebToolsAccts as $acctEmail => $acctData) {
if (isset($acctData['preferred']) && $acctData['preferred'] == 1) {
$email = $acctEmail;
$pass = $acctData['pass'];
break;
}
}
// If no preferred email/pass was found, just grab the first one
if (empty($email) && empty($pass) && count($wgGoogleWebToolsAccts) > 0) {
$keys = array_keys($wgGoogleWebToolsAccts);
$email = $keys[0];
$pass = isset($wgGoogleWebToolsAccts[$email]['pass']) ? $wgGoogleWebToolsAccts[$email]['pass'] : "";
}
}
}
$this->mEmail = $email;
$this->mPass = $pass;
$this->mType = 'GOOGLE';
$this->mSource = 'WIKIA';
$this->mService = 'sitemaps';
if ($wiki != null) {
if (!is_object($wiki)) {
if (is_string($wiki)) {
$wiki = WikiFactory::DBtoID($wiki);
}
$wikiId = WikiFactory::getWikiByID($wiki);
if (!$wikiId) {
throw new Exception("Could not find wiki by ID (id=" . $wiki . ").");
}
$wiki = $wikiId;
}
$this->mWiki = $wiki;
$this->mSiteURI = $this->make_site_uri();
}
$this->mAuth = $this->getAuthToken();
}
示例11: array
foreach ($dbl as $dbname) {
$DB[] = $dbname;
}
}
};
$invalidDB = array();
$loop = 0;
$flags = array(WikiFactory::FLAG_DELETE_DB_IMAGES, WikiFactory::FLAG_FREE_WIKI_URL, WikiFactory::FLAG_HIDE_DB_IMAGES);
if ( !empty($DB) ) {
$city_flags = 0;
foreach ($flags as $flag) {
$city_flags |= $flag;
}
foreach ($DB as $dbname) {
$db = wfGetDB(DB_SLAVE, array(), $dbname);
if (!$db->tableExists('revision')) {
$city_id = WikiFactory::DBtoID($dbname);
$sql = "update city_list set city_public = ". WikiFactory::HIDE_ACTION .", city_flags = {$city_flags} where city_id = {$city_id}";
if ( isset($options['dryrun'])) {
echo $sql . ";\n";
} else {
# $db_wiki->query($sql);
}
$loop++;
}
}
}
echo "Found $loop invalid wikis\n";
示例12: getStarter
/**
* get starter data for current parameters
*
* @access private
* @author Krzysztof Krzyżaniak (eloy)
*
* @return mixed -- array if there's starter, false otherwise
*/
private function getStarter()
{
wfProfileIn(__METHOD__);
$result = false;
/**
* determine database name, set default match
*/
$dbStarter = $this->mStarters["*"]["*"];
switch ($this->mType) {
case "answers":
$dbStarter = $this->mStarters["answers"]["*"];
if (isset($this->mStarters["answers"][$this->mWikiData["language"]])) {
$dbStarter = $this->mStarters["answers"][$this->mWikiData["language"]];
}
break;
default:
if (isset($this->mStarters["*"][$this->mWikiData["language"]])) {
$dbStarter = $this->mStarters["*"][$this->mWikiData["language"]];
}
}
/**
* determine if exists
*/
try {
$dbr = wfGetDB(DB_SLAVE, array(), $dbStarter);
/**
* read info about connection
*/
$result = $dbr->getLBInfo();
/**
* get UploadDirectory
*/
$result["dbStarter"] = $dbStarter;
$result["uploadDir"] = WikiFactory::getVarValueByName("wgUploadDirectory", WikiFactory::DBtoID($dbStarter));
$this->log("starter {$dbStarter} exists");
} catch (DBConnectionError $e) {
/**
* well, it means that starter doesn't exists
*/
$this->log("starter {$dbStarter} does not exists");
}
wfProfileOut(__METHOD__);
return $result;
}
示例13: getExclusionList
function getExclusionList()
{
global $wgLookupContribsExcluded;
wfProfileIn(__METHOD__);
$result = array();
/* grumble grumble _precautions_ cough */
if (!isset($wgLookupContribsExcluded) || !is_array($wgLookupContribsExcluded) || empty($wgLookupContribsExcluded)) {
wfProfileOut(__METHOD__);
return array();
}
$result[] = 0;
foreach ($wgLookupContribsExcluded as $excluded) {
$result[] = intval(WikiFactory::DBtoID($excluded));
}
wfProfileOut(__METHOD__);
return $result;
}
示例14: elseif
<?php
$to = null;
global $wgRequest;
$byid = $wgRequest->getInt('id', '');
$bydb = $wgRequest->getText('db', '');
$byurl = $wgRequest->getText('url', '');
Wikia::log('WikiFactory', 'compare', 'byid=' . $byid);
Wikia::log('WikiFactory', 'compare', 'bydb=' . $bydb);
Wikia::log('WikiFactory', 'compare', 'byurl=' . $byurl);
if (!empty($byid) && $byid > 0) {
Wikia::log('WikiFactory', 'compare', 'detected a byid, using it');
$to = (int) $byid;
} elseif (!empty($bydb)) {
Wikia::log('WikiFactory', 'compare', 'detected a bydb, using it');
$to = WikiFactory::DBtoID($bydb);
Wikia::log('WikiFactory', 'compare', 'DBtoID says:' . $to);
if ($to == false) {
Wikia::log('WikiFactory', 'compare', 'found false, failing');
$to = null;
}
} elseif (!empty($byurl)) {
Wikia::log('WikiFactory', 'compare', 'detected a byurl, using it');
if (strpos($byurl, '.') == false) {
Wikia::log('WikiFactory', 'compare', 'no . found in input, adding .wikia.com');
#no
$byurl .= '.wikia.com';
}
$to = WikiFactory::DomainToID($byurl);
Wikia::log('WikiFactory', 'compare', 'DomainToID says:' . $to);
if ($to == false) {
示例15: prepareCssUpdateData
/**
* @desc Returns an array with correct elements from given api results
*
* @param array $postData results from API call with request of posts (articles) list in a category
*
* @return array
*/
private function prepareCssUpdateData($postData)
{
$cssUpdatePost = [];
$communityWikiId = WikiFactory::DBtoID($this->getCommunityDbName());
$blogTitle = GlobalTitle::newFromText($postData['title'], NS_MAIN, $communityWikiId);
$blogTitleText = $blogTitle->getText();
$lastRevisionUser = isset($postData['revisions'][0]['user']) ? $postData['revisions'][0]['user'] : null;
$timestamp = isset($postData['revisions'][0]['timestamp']) ? $postData['revisions'][0]['timestamp'] : null;
$blogUser = $this->getUserFromTitleText($blogTitleText, $lastRevisionUser);
$userPage = GlobalTitle::newFromText($blogUser, NS_USER, $communityWikiId);
if (!is_null($lastRevisionUser) && !is_null($timestamp) && $blogTitle instanceof GlobalTitle && $userPage instanceof GlobalTitle) {
// $postData['revisions'][0]['*'] is being checked in SpecialCssModel::filterRevisionsData()
// which is called before this method
$sectionText = $postData['revisions'][0]['*'];
$cssUpdateText = $this->truncateAndParseLinks($this->getCssUpdateSection($sectionText));
$cssUpdatePost = ['title' => $this->getAfterLastSlashText($blogTitleText), 'url' => $this->appendHeadlineAnchor($blogTitle->getFullURL()), 'userAvatar' => AvatarService::renderAvatar($blogUser, 25), 'userUrl' => $userPage->getFullUrl(), 'userName' => $blogUser, 'timestamp' => $timestamp, 'text' => $cssUpdateText];
}
return $cssUpdatePost;
}