/** * TARGET : executeDeleteTranslationRequest * scenario1 : * Page B is the tranlation of A and C * Page D is the translation of A and C * We remove the translation data for A et B * * Page B still the translation of page C * Page D still the translation of A and C * * A : $this->pageswithoutlanguage[0] * B : $this->pageswithoutlanguage[1] * C : $this->pageswithoutlanguage[2] * D : $this->pageswithoutlanguage[3] */ public function testExecuteDeleteTranslationRequest_Scenario1_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[1], $this->notDefaultLanguage); $this->assertEquals($this->dbw->affectedRows(), 1); $this->dbw->safeQuery("INSERT INTO ! (page_id, lang) VALUES (?, ?)", $this->db_page_language, $this->pageswithoutlanguage[3], $this->notDefaultLanguage); $this->assertEquals($this->dbw->affectedRows(), 1); $this->dbw->safeQuery("INSERT INTO ! (source, translate) VALUES (?, ?)", $this->db_page_translation, $this->pageswithoutlanguage[0], $this->pageswithoutlanguage[1]); $this->assertEquals($this->dbw->affectedRows(), 1); $this->dbw->safeQuery("INSERT INTO ! (source, translate) VALUES (?, ?)", $this->db_page_translation, $this->pageswithoutlanguage[0], $this->pageswithoutlanguage[3]); $this->assertEquals($this->dbw->affectedRows(), 1); $this->dbw->safeQuery("INSERT INTO ! (source, translate) VALUES (?, ?)", $this->db_page_translation, $this->pageswithoutlanguage[2], $this->pageswithoutlanguage[1]); $this->assertEquals($this->dbw->affectedRows(), 1); $this->dbw->safeQuery("INSERT INTO ! (source, translate) VALUES (?, ?)", $this->db_page_translation, $this->pageswithoutlanguage[2], $this->pageswithoutlanguage[3]); $this->assertEquals($this->dbw->affectedRows(), 1); //scenario1 : ready $this->assertEquals($controller->executeDeleteTranslationRequest($this->pageswithoutlanguage[0], $this->pageswithoutlanguage[1]), "multilanguagemanager_translationdeleted"); //We check data $tbs = $this->dbw->safeQuery("SELECT * FROM ! WHERE page_id=? and lang=?", $this->db_page_language, $this->pageswithoutlanguage[1], $this->notDefaultLanguage); $this->assertEquals($this->dbw->numRows($tbs), 1); $tbs = $this->dbw->safeQuery("SELECT * FROM ! WHERE page_id=? and lang=?", $this->db_page_language, $this->pageswithoutlanguage[3], $this->notDefaultLanguage); $this->assertEquals($this->dbw->numRows($tbs), 1); $tbs = $this->dbw->safeQuery("SELECT * FROM ! WHERE source=? and translate=?", $this->db_page_translation, $this->pageswithoutlanguage[2], $this->pageswithoutlanguage[1]); $this->assertEquals($this->dbw->numRows($tbs), 1); $tbs = $this->dbw->safeQuery("SELECT * FROM ! WHERE source=? and translate=?", $this->db_page_translation, $this->pageswithoutlanguage[0], $this->pageswithoutlanguage[3]); $this->assertEquals($this->dbw->numRows($tbs), 1); $tbs = $this->dbw->safeQuery("SELECT * FROM ! WHERE source=? and translate=?", $this->db_page_translation, $this->pageswithoutlanguage[2], $this->pageswithoutlanguage[3]); $this->assertEquals($this->dbw->numRows($tbs), 1); }
/** * 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'))); }