本文整理汇总了PHP中WikiFactory::setPublicStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory::setPublicStatus方法的具体用法?PHP WikiFactory::setPublicStatus怎么用?PHP WikiFactory::setPublicStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiFactory
的用法示例。
在下文中一共展示了WikiFactory::setPublicStatus方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
function execute($params = null)
{
global $IP;
$this->mData = $params;
echo "Hi! its " . __METHOD__ . "\n";
$this->mParams = unserialize($this->mData->task_arguments);
#--- set task id for future use (logs, for example)
$this->mTaskID = $this->mData->task_id;
if ($this->mParams["export"] == 1) {
$oWikiMover = WikiMover::newFromIDs($this->mParams["source_wikia_id"], $this->mParams["target_wikia_id"]);
$oWikiMover->load();
$oWikiMover->move();
#--- redirect to target database
$oWikiMover->redirect();
#--- get log from WikiMover and write into database
foreach ($oWikiMover->getLog(true) as $log) {
$this->addLog($log["info"], $log["timestamp"]);
}
} else {
#--- redirect to notreal.wikia.com
if (!empty($this->mParams['source_wikia_id'])) {
WikiFactory::setPublicStatus(0, $this->mParams['source_wikia_id']);
}
}
#--- dump database to xml
$this->dumpXML();
#--- dump database to sql
//$this->dumpSQL();
#--- close mailling list
#--- pack images to tar.gz file
$this->packImages();
return true;
}
示例2: markWikiAsClosed
/**
* Mark given wiki as queued for removal
*
* @param $wikiId integer city ID
* @return bool
*/
private function markWikiAsClosed($wikiId)
{
WikiFactory::setFlags($wikiId, WikiFactory::FLAG_FREE_WIKI_URL | WikiFactory::FLAG_DELETE_DB_IMAGES);
$res = WikiFactory::setPublicStatus(WikiFactory::CLOSE_ACTION, $wikiId, self::REASON);
WikiFactory::clearCache($wikiId);
return $res !== false;
}
示例3: index
/**
* The main method handling the Special:SpamWikis behaviour.
*/
public function index()
{
// access control
if (!$this->wg->User->isAllowed('specialspamwikis')) {
$this->displayRestrictionError();
return false;
}
// init some basic data
$this->wg->Out->setPageTitle(wfMsg('specialspamwikis-pagetitle'));
$this->mTitle = Title::makeTitle(NS_SPECIAL, $this->getName());
$this->mAction = htmlspecialchars($this->mTitle->getLocalURL());
// placeholder for the actual data
$this->mData = new StdClass();
// required for HTML links
$link = new Linker();
// the code below implements the behaviour of the stats subpage
// TODO: find a better method to check for subpages
if ("{$this->mTitle->getPrefixedText()}/stats" == $this->wg->request->getVal('title')) {
// fetch the data
$data = new SpecialSpamWikisData();
$this->mData->stats = $data->getStats();
// render the output
$this->response->getView()->setTemplate('SpecialSpamWikisSpecialPageController', 'stats');
return null;
}
// the code below implements the behaviour after form submission
if (F::app()->wg->request->wasPosted()) {
// which wikis to close?
$this->mData->close = array();
$this->mData->summary = array();
$data = $this->request->getVal('close');
if (!empty($data)) {
// DB handle
$tmpDb = F::app()->wf->getDb(DB_MASTER, array(), 'stats');
foreach ($data as $k => $v) {
// get some info about the wiki
$city = WikiFactory::getWikiByID($k);
// set the public status to "spam"
$status = WikiFactory::setPublicStatus(-2, $k, 'SpecialSpamWikis');
// clear the cached settings for the wiki
WikiFactory::clearCache($k);
// prepare the output data
$this->mData->close[] = array('city' => $link->makeExternalLink($city->city_url, $city->city_title), 'status' => -2 == $status);
// update the summary
if (-2 == $status) {
if (!isset($this->mData->summary[$city->city_founding_user])) {
$this->mData->summary[$city->city_founding_user] = 1;
} else {
$this->mData->summary[$city->city_founding_user]++;
}
}
// remove from the noreptemp.spamwikis
$tmpDb->delete('noreptemp.spamwikis', array('city_id' => $k), __METHOD__);
}
// clear the interwiki links for ALL languages in memcached.
WikiFactory::clearInterwikiCache();
unset($tmpDb);
}
// calculate and pre-format data for StaffLog entry
$summary = array('sum' => array_sum($this->mData->summary), 'count' => count($this->mData->summary), 'avg' => 0);
if (0 != $summary['count']) {
$summary['avg'] = sprintf('%1.2f', $summary['sum'] / $summary['count']);
}
// pass the calculated summary to the output (yes, overwrite the previous value)
$this->mData->summary = $summary;
// make a StaffLog entry
StaffLogger::log('spamwiki', 'mark', $this->wg->User->getID(), $this->wg->User->getName(), 0, '', wfMsgExt('specialspamwikis-stafflog-summary', array('parsemag'), $summary['sum'], $summary['count'], $summary['avg']));
// render the output
$this->response->getView()->setTemplate('SpecialSpamWikisSpecialPageController', 'close');
return null;
}
// the code below handles the default behaviour: displays the form
$this->response->addAsset('resources/wikia/libraries/jquery/datatables/jquery.dataTables.min.js');
$this->response->addAsset('extensions/wikia/SpecialSpamWikis/css/table.scss');
$data = new SpecialSpamWikisData();
$this->mData->criteria = $data->getCriteria();
}
示例4: doUpdateDomains
/**
* doUpdateDomains
*
* Store changes connected with domains
*
* @access private
* @author eloy@wikia
*
* @return mixed info when change, null when not changed
*/
private function doUpdateDomains(&$request)
{
$action = $request->getText("wpAction", null);
$reason = $request->getText("wpReason", wfMsg('wikifactory-public-status-change-default-reason'));
$message = "";
switch ($action) {
case "status":
$status = $request->getVal("wpWikiStatus", 0);
WikiFactory::setPublicStatus($status, $this->mWiki->city_id, $reason);
$this->mWiki->city_public = $status;
WikiFactory::clearCache($this->mWiki->city_id);
$message = "Status of this wiki was changed to " . $this->mStatuses[$status];
case "protect":
$protect = $request->getCheck("wpProtected", false);
if ($protect) {
$message = "Wiki protected";
WikiFactory::setFlags($this->mWiki->city_id, WikiFactory::FLAG_PROTECTED, false, $reason);
} else {
$message = "Wiki un-protected";
WikiFactory::resetFlags($this->mWiki->city_id, WikiFactory::FLAG_PROTECTED, false, $reason);
}
break;
}
return Wikia::successmsg($message);
}
示例5: doDisableWiki
protected function doDisableWiki($wikiId, $flags, $reason = '')
{
// TOOD: copied from WikiFactory::disableWiki since it's not released yet
WikiFactory::setFlags($wikiId, $flags);
$res = WikiFactory::setPublicStatus(WikiFactory::CLOSE_ACTION, $wikiId, $reason);
if ($this->debug) {
var_dump("setPublicStatus", $wikiId, $res);
}
WikiFactory::clearCache($wikiId);
return $res !== false;
}
示例6: processWikis
protected function processWikis()
{
$flags = $this->getFlags();
$status = $flags & WikiFactory::FLAG_HIDE_DB_IMAGES ? WikiFactory::HIDE_ACTION : WikiFactory::CLOSE_ACTION;
$reason = $this->reason;
foreach ($this->wikiIds as $wikiId) {
// skip wikis with id lesser than "start"
if ($this->start && $this->start > $wikiId) {
continue;
}
// echo "status: memory = ".memory_get_usage(true)."\n";
// check memory usage
if (!$this->checkMemoryLimit(1)) {
echo "error: memory limit exceeded (1G), please restart the script\n";
return;
}
$city = WikiFactory::getWikiByID($wikiId);
if (!$city) {
echo "{$wikiId}: error: city could not be found\n";
continue;
}
$city_name = $city->city_dbname;
if (!$city->city_public) {
echo "{$wikiId}: error: ({$city_name}) city is already non-public\n";
continue;
}
$evaluator = new DeadWikiEvaluator($wikiId);
if (!$evaluator->getStatus()) {
echo "{$wikiId}: error: ({$city_name}) city does not meet requirements to be closed: " . $evaluator->getMessage() . "\n";
continue;
}
echo "{$wikiId}: ({$city_name}) marking as closed... ";
if (!$this->dryRun) {
WikiFactory::setFlags($wikiId, $flags);
$res = WikiFactory::setPublicStatus($status, $wikiId, $reason);
WikiFactory::clearCache($wikiId);
echo "OK\n";
} else {
echo "OK (dry run)\n";
}
}
}
示例7: doUpdateDomains
/**
* doUpdateDomains
*
* Store changes connected with domains
*
* @access private
* @author eloy@wikia
*
* @return mixed info when change, null when not changed
*/
private function doUpdateDomains(&$request)
{
$action = $request->getText("wpAction", null);
$reason = $request->getText("wpReason", wfMsg('wikifactory-public-status-change-default-reason'));
$message = "";
switch ($action) {
case "status":
$status = $request->getVal("wpWikiStatus", 0);
WikiFactory::setPublicStatus($status, $this->mWiki->city_id, $reason);
$this->mWiki->city_public = $status;
WikiFactory::clearCache($this->mWiki->city_id);
$message = "Status of this wiki was changed to " . $this->mStatuses[$status];
break;
}
return Wikia::successmsg($message);
}
示例8: execute
public function execute()
{
global $wgExternalSharedDB;
// options
if ($this->hasOption('debug')) {
$this->debug = true;
}
if ($this->hasOption('list')) {
$this->listMode = true;
}
if ($this->hasOption('days')) {
$this->days = (int) $this->getOption('days');
}
if ($this->hasOption('wikia')) {
$this->wikiaID = (int) $this->getOption('wikia');
}
if ($this->hasOption('tables')) {
$this->tables = explode(",", $this->getOption('tables'));
}
if ($this->hasOption('fix')) {
$this->fix = true;
}
if (empty($this->tables)) {
echo "There is no tables to check\n";
exit(1);
}
if ($this->listMode || $this->fix) {
$this->output("Run script with --list option ... \n");
$startDate = date('Y-m-d 00:00:00', strtotime("-{$this->days} days"));
$dbr = wfGetDB(DB_SLAVE, array(), $wgExternalSharedDB);
$oRes = $dbr->select(array("city_list"), array("city_id, city_dbname, city_created"), array(sprintf("city_created between '%s' and now()", $startDate), $this->wikiaID > 0 ? "city_id = {$this->wikiaID}" : "city_id > 0"), __METHOD__);
$wikisToFix = array();
while ($oRow = $dbr->fetchObject($oRes)) {
if ($this->debug) {
echo "Check {$oRow->city_dbname} ... \n";
}
if ($this->runCmd($oRow->city_id, $oRow->city_dbname, array('--tables=' . $this->getOption('tables')))) {
if ($this->fix) {
# fix wikia
$this->fixWikia($oRow->city_id);
}
$wikisToFix[$oRow->city_id] = array($oRow->city_dbname, $oRow->city_created);
}
}
if ($this->fix) {
echo "List of Wikis fixed: \n";
} else {
echo "List of Wikis to fix: \n";
}
echo print_r($wikisToFix, true);
echo "Number of Wikis to fix: " . count($wikisToFix) . "\n";
} elseif ($this->wikiaID > 0) {
$dbr = wfGetDB(DB_SLAVE);
$tables_to_fix = array();
/* check if page table exists */
if (!$dbr->tableExists('page', __METHOD__)) {
/* wiki to close */
if ($this->fix) {
WikiFactory::setPublicStatus(WikiFactory::CLOSE_ACTION, $this->wikiaID, 'No SQL tables');
}
} else {
if (!empty($this->tables)) {
foreach ($this->tables as $table) {
if (!$dbr->tableExists($table, __METHOD__)) {
$tables_to_fix[] = $table;
}
}
}
}
echo implode(",", $tables_to_fix);
}
}
示例9: doClose
/**
* close Wiki(s)
* @access private
*/
private function doClose($newWiki = "")
{
global $wgRequest, $wgOut;
wfProfileIn(__METHOD__);
$WFTitle = Title::makeTitle(NS_SPECIAL, 'WikiFactory');
#---
$output = "";
if (!empty($this->mWikis)) {
$output = Xml::openElement('ul', null);
foreach ($this->mWikis as $wiki) {
Wikia::log(__METHOD__, "Closing: {$wiki->city_title} (url: {$wiki->city_url}) (id: {$wiki->city_id}) (dbname: {$wiki->city_dbname}) ");
#-- move to archive
$message = wfMsgExt('closewiki-wiki-closed', array('parse'), $wiki->city_title, $wiki->city_url);
if (!empty($newWiki)) {
Wikia::log(__METHOD__, " ... and redirecting to: {$this->mRedirect} (id: {$newWiki})");
$this->moveOldDomains($wiki->city_id, $newWiki);
#-- add "old" prefix to main domain and set is as primary
$prefixedDomain = $this->prefixMainDomain($wiki->city_id);
Wikia::log(__METHOD__, " ... primary domain set to: {$prefixedDomain}");
#-- set new city ID in city_domains (except for just created "old" domain)
$isMoved = WikiFactory::redirectDomains($wiki->city_id, $newWiki, !empty($prefixedDomain) ? array($prefixedDomain) : array());
#---
$message = wfMsgExt('closewiki-wiki-closed_redirect', array('parse'), $wiki->city_title, $wiki->city_url, sprintf("%s%s", "http://", $this->mRedirect));
}
#-- set public to 0
$status = isset($this->mFlags[WikiFactory::FLAG_HIDE_DB_IMAGES]) ? WikiFactory::HIDE_ACTION : WikiFactory::CLOSE_ACTION;
#-- set flags as a number
if (!empty($this->mFlags)) {
$city_flags = 0;
foreach ($this->mFlags as $flag) {
$city_flags |= $flag;
}
WikiFactory::setFlags($wiki->city_id, $city_flags);
}
// Let's request the XML dump if needed
if (isset($this->mFlags[WikiFactory::FLAG_CREATE_DB_DUMP])) {
DumpsOnDemand::queueDump($wiki->city_id, isset($this->mFlags[WikiFactory::FLAG_HIDE_DB_IMAGES]), true);
}
if (empty($this->mReason)) {
$this->mReason = "-";
}
$res = WikiFactory::setPublicStatus($status, $wiki->city_id, $this->mReason);
if ($res === $status) {
$output .= Xml::tags('li', array('style' => 'padding:4px;'), $message);
WikiFactory::clearCache($wiki->city_id);
if (!empty($newWiki)) {
WikiFactory::clearCache($newWiki);
}
}
}
$output .= Xml::closeElement('ul');
}
$output .= Xml::element('input', array('name' => 'wiki-return', 'type' => 'button', 'value' => wfMsg('closewiki-return', wfMsg('wikifactory')), 'onclick' => "window.location='{$WFTitle->getFullURL()}'"));
$wgOut->addHtml($output);
$aHookParams = ['city_id' => $wiki->city_id];
wfRunHooks('WikiFactoryWikiClosed', array($aHookParams));
wfProfileOut(__METHOD__);
}