本文整理汇总了PHP中WikiFactory::addDomain方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory::addDomain方法的具体用法?PHP WikiFactory::addDomain怎么用?PHP WikiFactory::addDomain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiFactory
的用法示例。
在下文中一共展示了WikiFactory::addDomain方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: axWFactoryDomainCRUD
function axWFactoryDomainCRUD($type = "add")
{
global $wgRequest, $wgUser, $wgExternalSharedDB, $wgOut;
$sDomain = $wgRequest->getVal("domain");
$city_id = $wgRequest->getVal("cityid");
if (!$wgUser->isAllowed('wikifactory')) {
$wgOut->readOnlyPage();
#--- later change to something reasonable
return;
}
if (empty($city_id)) {
$wgOut->readOnlyPage();
#--- later change to something reasonable
return;
}
$dbw = wfGetDB(DB_MASTER, array(), $wgExternalSharedDB);
$aDomains = array();
$aResponse = array();
$sInfo = "";
switch ($type) {
case "add":
if (!preg_match("/^[\\w\\.\\-]+\$/", $sDomain)) {
/**
* check if domain is valid (a im sure that there is function
* somewhere for such purpose
*/
$sInfo .= "Error: Domain <em>{$sDomain}</em> is invalid (or empty) so it's not added.";
} else {
$added = WikiFactory::addDomain($city_id, $sDomain);
if ($added) {
$sInfo .= "Success: Domain <em>{$sDomain}</em> added.";
} else {
$sInfo .= "Error: Domain <em>{$sDomain}</em> is already used so it's not added.";
}
}
break;
case "change":
$sNewDomain = $wgRequest->getVal("newdomain");
#--- first, check if domain is not used
$oRes = $dbw->select("city_domains", "count(*) as count", array("city_domain" => $sNewDomain), __METHOD__);
$oRow = $dbw->fetchObject($oRes);
$dbw->freeResult($oRes);
if ($oRow->count > 0) {
#--- domain is used already
$sInfo .= "<strong>Error: Domain <em>{$sNewDomain}</em> is already used so no change was done.</strong>";
} elseif (!preg_match("/^[\\w\\.\\-]+\$/", $sNewDomain)) {
#--- check if domain is valid (a im sure that there is function
#--- somewhere for such purpose
$sInfo .= "<strong>Error: Domain <em>{$sNewDomain}</em> is invalid so no change was done..</strong>";
} else {
#--- reall change domain
$dbw->update("city_domains", array("city_domain" => strtolower($sNewDomain)), array("city_id" => $city_id, "city_domain" => strtolower($sDomain)));
$dbw->commit();
$sInfo .= "Success: Domain <em>{$sDomain}</em> changed to <em>{$sNewDomain}</em>.";
}
break;
case "remove":
$removed = WikiFactory::removeDomain($city_id, $sDomain);
if ($removed) {
$sInfo .= "Success: Domain <em>{$sDomain}</em> removed.";
} else {
$sInfo .= "Failed: Domain <em>{$sDomain}</em> was not removed.";
}
break;
case "status":
$iNewStatus = $wgRequest->getVal("status");
if (in_array($iNewStatus, array(0, 1, 2))) {
#--- updatec city_list table
$dbw->update("city_list", array("city_public" => $iNewStatus), array("city_id" => $city_id));
$dbw->commit();
switch ($iNewStatus) {
case 0:
$aResponse["div-body"] = "<strong>changed to disabled</strong>";
break;
case 1:
$aResponse["div-body"] = "<strong>changed to enabled</strong>";
break;
case 2:
$aResponse["div-body"] = "<strong>changed to redirected</strong>";
break;
}
} else {
$aResponse["div-body"] = "wrong status number";
}
$aResponse["div-name"] = "wf-domain-span";
break;
case "cancel":
$sInfo .= "<em>Action cancelled</em>";
break;
case "setmain":
$setmain = WikiFactory::setmainDomain($city_id, $sDomain);
if ($setmain) {
$sInfo .= "Success: Domain <em>{$sDomain}</em> set as main.";
} else {
$sInfo .= "Failed: Domain <em>{$sDomain}</em> was not set as main.";
}
break;
}
#--- get actuall domain list
$aDomains = WikiFactory::getDomains($city_id, true);
//.........这里部分代码省略.........
示例2: prefixMainDomain
private function prefixMainDomain($cityId)
{
$mainDomain = substr(WikiFactory::getVarValueByName("wgServer", $cityId), 7);
if (!empty($mainDomain)) {
$index = null;
do {
$prefixedDomain = self::CLOSED_WIKI_DOMAIN_PREFIX . (!empty($index) ? $index : '') . "." . $mainDomain;
$exists = WikiFactory::DomainToID($prefixedDomain);
$index = is_null($index) ? 1 : $index + 1;
} while (!empty($exists));
WikiFactory::addDomain($cityId, $prefixedDomain);
WikiFactory::setmainDomain($cityId, $prefixedDomain);
return $prefixedDomain;
}
return null;
}