/**
  * TARGET : createDetailLanguagePage
  * Scenario1 :
  * For this test, we know (@see setUp()) that :
  * 		-Default Language : 'en'
  * 		-Other Available language : 'fr', 'de'
  * 		-We know that User 1 has the right to change language
  * 
  * Page A is in 'en'
  * Page B is in 'en'
  * Page C is in 'fr'
  * A is translated by C
  * B
  * 
  */
 public function testCreateDetailLanguagePage_scenario1_ndl()
 {
     global $wgUser;
     $controller = new MultiLanguageManager_controller();
     $display = new MultiLanguageManager_displaytest();
     $controller->setDisplay($display);
     MultiLanguageManager_controller::setUILanguage($this->notDefaultLanguage);
     //Datas initialization
     $this->dbw->safeQuery("INSERT INTO ! (page_id, lang) VALUES (?, ?)", $this->db_page_language, $this->pageswithoutlanguage[2], 'fr');
     $this->assertEquals($this->dbw->affectedRows(), 1);
     $this->dbw->safeQuery("INSERT INTO ! (source, translate) VALUES (?, ?)", $this->db_page_translation, $this->pageswithoutlanguage[0], $this->pageswithoutlanguage[2]);
     $this->assertEquals($this->dbw->affectedRows(), 1);
     $pageA = Title::newFromID($this->pageswithoutlanguage[0]);
     $pageB = Title::newFromID($this->pageswithoutlanguage[1]);
     $pageC = Title::newFromID($this->pageswithoutlanguage[2]);
     //Scenario1 ready
     $this->assertEquals($controller->createDetailLanguagePage($pageA->getText()), "displayLanguagePolicy()displayChooseLanguage(en," . $this->pageswithoutlanguage[0] . ",FALSE,TRUE)displayItIsTranslatedBy(result," . $this->pageswithoutlanguage[0] . ",FALSE)");
     $this->assertEquals($controller->createDetailLanguagePage($pageB->getText()), "displayLanguagePolicy()displayChooseLanguage(en," . $this->pageswithoutlanguage[1] . ",FALSE,FALSE)displayItIsTranslatedBy(result," . $this->pageswithoutlanguage[1] . ",FALSE)");
     $this->assertEquals($controller->createDetailLanguagePage($pageC->getText()), "displayLanguagePolicy()displayChooseLanguage(fr," . $this->pageswithoutlanguage[2] . ",FALSE,TRUE)displayItTranslates(result," . $this->pageswithoutlanguage[2] . ",FALSE)");
     $oldUser = $wgUser;
     $wgUser = User::newFromName($this->user_name);
     $this->assertEquals($controller->createDetailLanguagePage($pageA->getText()), "displayLanguagePolicy()displayChooseLanguage(en," . $this->pageswithoutlanguage[0] . ",TRUE,TRUE)displayItIsTranslatedBy(result," . $this->pageswithoutlanguage[0] . ",TRUE)");
     $this->assertEquals($controller->createDetailLanguagePage($pageB->getText()), "displayLanguagePolicy()displayChooseLanguage(en," . $this->pageswithoutlanguage[1] . ",TRUE,FALSE)displayItIsTranslatedBy(result," . $this->pageswithoutlanguage[1] . ",TRUE)");
     $this->assertEquals($controller->createDetailLanguagePage($pageC->getText()), "displayLanguagePolicy()displayChooseLanguage(fr," . $this->pageswithoutlanguage[2] . ",TRUE,TRUE)displayItTranslates(result," . $this->pageswithoutlanguage[2] . ",TRUE)");
     $wgUser = $oldUser;
 }
 /**
  * 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')));
 }