* * Get familiar with "How_to_run_maintenance_script" article on internal to figure out how to run it. */ ini_set("include_path", dirname(__FILE__) . "/../"); require_once "commandLine.inc"; function enableVEUI($id) { WikiFactory::setVarByName('wgEnableVisualEditorUI', $id, true); WikiFactory::clearCache($id); } function isVEenabled($id) { $out = WikiFactory::getVarByName('wgEnableVisualEditorExt', $id); return $out ? unserialize($out->cv_value) : false; } $varid = WikiFactory::getVarIdByName('wgEnableVisualEditorExt', true); $list = WikiFactory::getListOfWikisWithVar($varid, 'bool', '=', true); foreach ($list as $id => $val) { echo "Wiki id: {$id}\n"; $isVEenabled = isVEenabled($id); if ($isVEenabled) { // IMPORTANT! Uncomment line below if you really want it to work. //enableVEUI( $id ); echo "Enabled VEUI\n"; } else { echo "Not enabled VEUI because VE not enabled\n"; } echo "########################################\n"; } WikiFactory::clearInterwikiCache();
/** * clear wiki cache */ function axWFactoryClearCache() { global $wgRequest, $wgUser, $wgOut, $wgWikiFactoryMessages; $city_id = $wgRequest->getVal("cityid"); $iError = 0; $sError = ""; if (!$wgUser->isAllowed('wikifactory')) { #--- no permission, do nothing $iError++; $sError = "no permission for removing"; } if (empty($city_id)) { #--- no permission, do nothing $iError++; $sError = "city id missing"; } if (empty($iError)) { WikiFactory::clearCache($city_id); WikiFactory::clearInterwikiCache(); #--- send response $aResponse = array("div-body" => wfMsg("wikifactory_removeconfirm"), "div-name" => "wf-clear-cache"); } else { $aResponse = array("div-body" => $sError, "div-name" => "wf-clear-cache"); } return json_encode($aResponse); }
/** * 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(); }