Ejemplo n.º 1
0
 /**
  * Get the standard watchlist editing form
  *
  * @return HTMLForm
  */
 protected function getNormalForm()
 {
     global $wgContLang;
     $fields = array();
     $count = 0;
     $haveInvalidNamespaces = false;
     foreach ($this->getWatchlistInfo() as $namespace => $pages) {
         if ($namespace < 0) {
             $haveInvalidNamespaces = true;
             continue;
         }
         $fields['TitlesNs' . $namespace] = array('class' => 'EditWatchlistCheckboxSeriesField', 'options' => array(), 'section' => "ns{$namespace}");
         foreach ($pages as $dbkey => $redirect) {
             $title = Title::makeTitleSafe($namespace, $dbkey);
             $text = $this->buildRemoveLine($title, $redirect);
             $fields['TitlesNs' . $namespace]['options'][$text] = $title->getEscapedText();
             $count++;
         }
     }
     if ($haveInvalidNamespaces) {
         wfDebug("User {$this->getContext()->getUser()->getId()} has invalid watchlist entries, clening up...\n");
         $this->getContext()->getUser()->cleanupWatchlist();
     }
     if (count($fields) > 1 && $count > 30) {
         $this->toc = Linker::tocIndent();
         $tocLength = 0;
         foreach ($fields as $key => $data) {
             $ns = substr($data['section'], 2);
             $nsText = $ns == NS_MAIN ? wfMsgHtml('blanknamespace') : htmlspecialchars($wgContLang->getFormattedNsText($ns));
             $this->toc .= Linker::tocLine("editwatchlist-{$data['section']}", $nsText, ++$tocLength, 1) . Linker::tocLineEnd();
         }
         $this->toc = Linker::tocList($this->toc);
     } else {
         $this->toc = false;
     }
     $form = new EditWatchlistNormalHTMLForm($fields, $this->getContext());
     $form->setTitle($this->getTitle());
     $form->setSubmitText(wfMessage('watchlistedit-normal-submit')->text());
     $form->setWrapperLegend(wfMessage('watchlistedit-normal-legend')->text());
     $form->addHeaderText(wfMessage('watchlistedit-normal-explain')->parse());
     $form->setSubmitCallback(array($this, 'submitNormal'));
     return $form;
 }