/**
  * Display form for testing spell checking feature
  */
 function spellCheckingForm($languages)
 {
     $fields = array('text' => array('class' => 'HTMLTextField', 'label-message' => 'spellchecker-info-spellcheck-text'), 'lang' => array('class' => 'HTMLSelectField', 'label-message' => 'spellchecker-info-spellcheck-languages', 'options' => array_combine($languages, $languages)));
     $form = new HTMLForm($fields);
     $form->setTitle($this->title);
     $form->setSubmitText($this->app->runFunction('wfMsg', 'spellchecker-info-spellcheck-submit'));
     $form->loadData();
     $form->displayForm('');
     // page was POSTed, perform spell cheking
     if ($this->request->wasPosted()) {
         $text = $this->request->getText('wptext');
         $langCode = $this->request->getText('wplang');
         // create spell checking service
         $service = new SpellCheckerService($langCode);
         $info = $service->getInfo();
         // check the spelling (returns true or array of spelling suggestions)
         $data = $service->checkWord($text);
         // print out results
         if ($data === true) {
             $result = $this->app->runFunction('wfMsg', 'spellchecker-info-spellcheck-is-correct', $text);
         } else {
             $result = $this->app->runFunction('wfMsg', 'spellchecker-info-spellcheck-suggestions', $text, implode(', ', $data));
         }
         $this->out->addHtml("<p>{$result}</p>");
         $this->out->addHtml("<p><small>{$info['desc']} / {$info['lang']}</small></p>");
     }
 }
 static function checkWords()
 {
     wfProfileIn(__METHOD__);
     $app = F::app();
     $request = $app->getGlobal('wgRequest');
     // get request params
     $lang = $request->getVal('lang', false);
     $words = explode(',', $request->getVal('words', ''));
     // benchmark
     $time = wfTime();
     $service = new SpellCheckerService($lang);
     $ret = $service->checkWords($words);
     // BugId:2570 - log statistics
     $wordsCount = count($words);
     $suggestionsCount = count($ret['suggestions']);
     // finish the benchmark
     $time = round(wfTime() - $time, 4);
     if (!empty($ret)) {
         $ret['info']['time'] = $time;
     }
     Wikia::log(__METHOD__, __LINE__, "{$wordsCount} words checked / {$suggestionsCount} suggestions / done in {$time} sec.", true);
     wfProfileOut(__METHOD__);
     return $ret;
 }