/** * TARGET : executeSetLanguageRequest * scenario2 : * The source page is not in the default language and it is the tranlation of 2 pages * the translations will be removed from the database and the article will be put in the * new language. * No translation data will existed for this page * * $this->pageswithoutlanguage[0] will be the source page * $this->pageswithoutlanguage[1] and $this->pageswithoutlanguage[2] will be declared as translated page */ public function testExecuteSetLanguageRequest_Scenario2_ndl() { global $wgContLanguageCode; $controller = new MultiLanguageManager_controller(); $display = new MultiLanguageManager_displaytest(); $controller->setDisplay($display); MultiLanguageManager_controller::setUILanguage($this->notDefaultLanguage); $this->dbw->safeQuery("INSERT INTO ! (page_id, lang) VALUES (?, ?)", $this->db_page_language, $this->pageswithoutlanguage[0], $this->notDefaultLanguage); $this->assertEquals($this->dbw->affectedRows(), 1); $this->dbw->safeQuery("INSERT INTO ! (source, translate) VALUES (?, ?)", $this->db_page_translation, $this->pageswithoutlanguage[1], $this->pageswithoutlanguage[0]); $this->assertEquals($this->dbw->affectedRows(), 1); $this->dbw->safeQuery("INSERT INTO ! (source, translate) VALUES (?, ?)", $this->db_page_translation, $this->pageswithoutlanguage[2], $this->pageswithoutlanguage[0]); $this->assertEquals($this->dbw->affectedRows(), 1); //scenario2 : ready $this->assertEquals($controller->executeSetLanguageRequest($this->pageswithoutlanguage[0], $wgContLanguageCode), "multilanguagemanager_languageisset"); //we control the data $tbs = $this->dbw->safeQuery("SELECT lang FROM ! WHERE page_id=?", $this->db_page_language, $this->pageswithoutlanguage[0]); $this->assertEquals($this->dbw->numRows($tbs), 0); //The page is in the right language $tbs = $this->dbw->safeQuery("SELECT source FROM ! WHERE source=? or translate=?", $this->db_page_translation, $this->pageswithoutlanguage[0], $this->pageswithoutlanguage[0]); $this->assertEquals($this->dbw->numRows($tbs), 0); //No translation data available }
/** * execute the special page */ public function execute($par) { global $wgUser, $wgOut; global $wgRequest; global $mgLanguagePermisionsKey; //needed with 1.6.x version $wgOut->setArticleFlag(false); $mode = $wgRequest->getVal('mode'); $controller = new MultiLanguageManager_controller(); if ($wgUser->isAllowed($mgLanguagePermisionsKey)) { switch ($mode) { case "deleteTranslation": $source = $wgRequest->getVal('source'); $translate = $wgRequest->getVal('translate'); $wgOut->addHTML($controller->executeDeleteTranslationRequest($source, $translate)); break; case "addTranslation": $source = $wgRequest->getVal('source'); $translate = $wgRequest->getVal('translate'); $articletitle = $wgRequest->getVal('articletitle'); $wgOut->addHTML($controller->executeAddTranslationRequest($source, $translate, $articletitle)); break; case "setLanguage": $source = $wgRequest->getVal('source'); $lang = $wgRequest->getVal('lang'); $wgOut->addHTML($controller->executeSetLanguageRequest($source, $lang)); break; } } $wgOut->addHTML($controller->createDetailLanguagePage($wgRequest->getVal('cible'))); }