예제 #1
0
 /**
  * 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__);
 }