public function execute()
 {
     $params = $this->extractRequestParams();
     // In MW 1.17 and above ApiBase::PARAM_REQUIRED can be used, this is for b/c with 1.16.
     foreach (array('from', 'to', 'words') as $requiredParam) {
         if (!isset($params[$requiredParam])) {
             $this->dieUsageMsg(array('missingparam', $requiredParam));
         }
     }
     $dbr = wfGetDB(DB_SLAVE);
     foreach (array_unique($params['words']) as $word) {
         $source = $dbr->selectRow('live_translate', array('word_id'), array('word_language' => $params['from'], 'word_translation' => $word));
         $toggledWord = false;
         if (!$source) {
             $toggledWord = LiveTranslateFunctions::getToggledCase($word);
             if ($toggledWord) {
                 $source = $dbr->selectRow('live_translate', array('word_id'), array('word_language' => $params['from'], 'word_translation' => $toggledWord));
             }
         }
         if ($source) {
             $destination = $dbr->selectRow('live_translate', array('word_translation'), array('word_language' => $params['to'], 'word_id' => $source->word_id, 'word_primary' => 1));
             if ($destination) {
                 if ($toggledWord) {
                     $translation = LiveTranslateFunctions::getToggledCase($destination->word_translation);
                     if ($translation) {
                         $destination->word_translation = $translation;
                     }
                 }
                 $this->getResult()->addValue('translations', $word, $destination->word_translation);
             }
         }
     }
 }
 /**
  * Retrieve the specil words from the database.
  */
 public function execute()
 {
     // Get the requests parameters.
     $params = $this->extractRequestParams();
     if (!isset($params['language'])) {
         $this->dieUsageMsg(array('missingparam', 'language'));
     }
     $this->addTables('live_translate');
     $this->addFields(array('word_id', 'word_translation'));
     $this->addWhere(array('word_language' => $params['language']));
     if (!is_null($params['continue'])) {
         $dbr = wfGetDB(DB_SLAVE);
         $this->addWhere('word_id >= ' . $dbr->addQuotes($params['continue']));
     }
     $this->addOption('LIMIT', $params['limit'] + 1);
     $this->addOption('ORDER BY', 'word_id ASC');
     $words = $this->select(__METHOD__);
     $specialWords = array();
     $count = 0;
     while ($word = $words->fetchObject()) {
         if (++$count > $params['limit']) {
             // We've reached the one extra which shows that
             // there are additional pages to be had. Stop here...
             $this->setContinueEnumParameter('continue', $word->word_id);
             break;
         }
         $specialWords[] = $word->word_translation;
     }
     $toggeledSpecials = array();
     foreach ($specialWords as $word) {
         $toggledWord = LiveTranslateFunctions::getToggledCase($word);
         if ($toggledWord) {
             $toggeledSpecials[] = $toggledWord;
         }
     }
     foreach (array_unique(array_merge($specialWords, $toggeledSpecials)) as $word) {
         $this->getResult()->addValue('words', null, $word);
     }
 }