本文整理汇总了PHP中Wikia::getAnswersDomains方法的典型用法代码示例。如果您正苦于以下问题:PHP Wikia::getAnswersDomains方法的具体用法?PHP Wikia::getAnswersDomains怎么用?PHP Wikia::getAnswersDomains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wikia
的用法示例。
在下文中一共展示了Wikia::getAnswersDomains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDomainsLikeOrExact
/**
* getDomainsLikeOrExact
*
* check if name is similar or the same, using sql like queries
*
* @access public
* @author Krzysztof Krzyżaniak <eloy@wikia-inc.com>
*
* @param string $name: name to check
* @param string $language default null - choosen language
* @param mixed $type type of domain, default false = wikia.com
*
* @return array with matches
*/
public static function getDomainsLikeOrExact($name, $language = null, $type = false)
{
global $wgExternalSharedDB;
$dbr = wfGetDB(DB_SLAVE, array(), $wgExternalSharedDB);
$domains = array();
$unique = array();
$name = self::deleteCommonPostfix($name);
$condition = $conditionSimilar = "";
/**
* don't check short names
*/
if (strlen($name) > 3) {
$names = explode(" ", $name);
$skip = false;
$tmp_array = array();
if (is_array($names)) {
foreach ($names as $n) {
if (!preg_match("/^[\\w\\.]+\$/", $n)) {
continue;
}
$sDomain = Wikia::fixDomainName($n, $language, $type);
$tmp_array['exact'][] = "city_domain = '{$sDomain}'";
$n = strtr($n, '0123456789-', '%%%%%%%%%%%%');
if (empty($type)) {
$tmp_array['similar'][] = "city_domain like '%{$n}%'";
} else {
switch ($type) {
case "answers":
$__domains = Wikia::getAnswersDomains();
if ($__domains && $language && isset($__domains[$language])) {
$likeName = $__domains[$language];
} elseif ($__domains && isset($__domains["default"])) {
$likeName = $__domains["default"];
}
if ($likeName) {
$tmp_array['similar'][] = "city_domain like '%{$n}.{$likeName}%'";
}
$tmp_array['similar'][] = "city_domain like '%{$n}.{$type}%'";
break;
default:
$tmp_array['similar'][] = "city_domain like '%{$n}.{$type}%'";
}
}
}
if (sizeof($tmp_array)) {
$condition = implode(" or ", $tmp_array['exact']);
$conditionSimilar = implode(" or ", $tmp_array['similar']);
} else {
$skip = true;
}
} else {
$sDomain = Wikia::fixDomainName($name, $language, $type);
$condition = "city_domain = '{$sDomain}'";
$conditionSimilar = empty($type) ? "city_domain like '%{$name}%'" : "city_domain like '%{$name}.{$type}%'";
}
$conditionLanguage = "";
if ($skip === false) {
#--- exact (but with language prefixes)
list($city_domains, $city_list) = array("city_domains", "city_list");
$oRes = $dbr->select(array($city_domains, $city_list), array("*"), array($condition, "{$city_domains}.city_id = {$city_list}.city_id"), __METHOD__, array("LIMIT" => 20));
while ($oRow = $dbr->fetchObject($oRes)) {
if (preg_match("/^www\\./", strtolower($oRow->city_domain))) {
continue;
}
if ($oRow->city_public == 1) {
$unique[strtolower($oRow->city_domain)] = 1;
$domains["exact"][] = $oRow;
} else {
$domains["closed"][] = $oRow;
}
}
$dbr->freeResult($oRes);
if (!is_null($language)) {
$conditionLanguage = "city_lang = '{$language}'";
}
#--
# Similar domains
$oRes = $dbr->select(array($city_domains, $city_list), array("*"), array($conditionSimilar, "{$city_domains}.city_id = {$city_list}.city_id", $conditionLanguage), __METHOD__, array("LIMIT" => 20));
while ($oRow = $dbr->fetchObject($oRes)) {
if (preg_match("/^www\\./", strtolower($oRow->city_domain))) {
continue;
}
if ($oRow->city_public == 1) {
if (array_key_exists(strtolower($oRow->city_domain), $unique) && $unique[strtolower($oRow->city_domain)] == 1) {
continue;
}
//.........这里部分代码省略.........
示例2: fixSubdomains
/**
* set subdomain name
*
* @access private
* @author Piotr Molski (moli)
* @author Krzysztof Krzyżaniak (eloy)
*
* @return
*/
private function fixSubdomains($lang)
{
global $wgContLang;
wfProfileIn(__METHOD__);
switch ($this->mType) {
case "answers":
$this->mDomains = Wikia::getAnswersDomains();
print_r($this->mDomains);
$this->mSitenames = Wikia::getAnswersSitenames();
if (isset($this->mDomains[$lang]) && !empty($this->mDomains[$lang])) {
$this->mDefSubdomain = sprintf("%s.%s", $this->mDomains[$lang], self::DEFAULT_DOMAIN);
$this->mLangSubdomain = false;
} else {
$this->mDefSubdomain = sprintf("%s.%s", $this->mDomains["default"], self::DEFAULT_DOMAIN);
$this->mLangSubdomain = true;
}
if (isset($this->mSitenames[$lang])) {
$this->mDefSitename = $this->mSitenames[$lang];
} elseif (isset($this->mDomains[$lang]) && !empty($this->mDomains[$lang])) {
$this->mDefSitename = $wgContLang->ucfirst($this->mDomains[$lang]);
} else {
$this->mDefSitename = $wgContLang->ucfirst($this->mDomains['default']);
}
break;
default:
$this->mDefSubdomain = self::DEFAULT_DOMAIN;
$this->mDefSitename = self::DEFAULT_NAME;
$this->mDomains = array('default' => '');
$this->mSitenames = array();
$this->mLangSubdomain = true;
}
wfProfileOut(__METHOD__);
}