/**
  * Get the standard watchlist editing form
  *
  * @return HTMLForm
  */
 protected function getNormalForm()
 {
     global $wgContLang;
     $fields = array();
     $count = 0;
     // Allow subscribers to manipulate the list of watched pages (or use it
     // to preload lots of details at once)
     $watchlistInfo = $this->getWatchlistInfo();
     Hooks::run('WatchlistEditorBeforeFormRender', array(&$watchlistInfo));
     foreach ($watchlistInfo as $namespace => $pages) {
         $options = array();
         foreach (array_keys($pages) as $dbkey) {
             $title = Title::makeTitleSafe($namespace, $dbkey);
             if ($this->checkTitle($title, $namespace, $dbkey)) {
                 $text = $this->buildRemoveLine($title);
                 $options[$text] = $title->getPrefixedText();
                 $count++;
             }
         }
         // checkTitle can filter some options out, avoid empty sections
         if (count($options) > 0) {
             $fields['TitlesNs' . $namespace] = array('class' => 'EditWatchlistCheckboxSeriesField', 'options' => $options, 'section' => "ns{$namespace}");
         }
     }
     $this->cleanupWatchlist();
     if (count($fields) > 1 && $count > 30) {
         $this->toc = Linker::tocIndent();
         $tocLength = 0;
         foreach ($fields as $data) {
             # strip out the 'ns' prefix from the section name:
             $ns = substr($data['section'], 2);
             $nsText = $ns == NS_MAIN ? $this->msg('blanknamespace')->escaped() : htmlspecialchars($wgContLang->getFormattedNsText($ns));
             $this->toc .= Linker::tocLine("editwatchlist-{$data['section']}", $nsText, $this->getLanguage()->formatNum(++$tocLength), 1) . Linker::tocLineEnd();
         }
         $this->toc = Linker::tocList($this->toc);
     } else {
         $this->toc = false;
     }
     $context = new DerivativeContext($this->getContext());
     $context->setTitle($this->getPageTitle());
     // Remove subpage
     $form = new EditWatchlistNormalHTMLForm($fields, $context);
     $form->setSubmitTextMsg('watchlistedit-normal-submit');
     $form->setSubmitDestructive();
     # Used message keys:
     # 'accesskey-watchlistedit-normal-submit', 'tooltip-watchlistedit-normal-submit'
     $form->setSubmitTooltip('watchlistedit-normal-submit');
     $form->setWrapperLegendMsg('watchlistedit-normal-legend');
     $form->addHeaderText($this->msg('watchlistedit-normal-explain')->parse());
     $form->setSubmitCallback(array($this, 'submitNormal'));
     return $form;
 }
 /**
  * Get the standard watchlist editing form
  *
  * @return HTMLForm
  */
 protected function getNormalForm()
 {
     global $wgContLang;
     $fields = array();
     $count = 0;
     foreach ($this->getWatchlistInfo() as $namespace => $pages) {
         if ($namespace >= 0) {
             $fields['TitlesNs' . $namespace] = array('class' => 'EditWatchlistCheckboxSeriesField', 'options' => array(), 'section' => "ns{$namespace}");
         }
         foreach (array_keys($pages) as $dbkey) {
             $title = Title::makeTitleSafe($namespace, $dbkey);
             if ($this->checkTitle($title, $namespace, $dbkey)) {
                 $text = $this->buildRemoveLine($title);
                 $fields['TitlesNs' . $namespace]['options'][$text] = $title->getEscapedText();
                 $count++;
             }
         }
     }
     $this->cleanupWatchlist();
     if (count($fields) > 1 && $count > 30) {
         $this->toc = Linker::tocIndent();
         $tocLength = 0;
         foreach ($fields as $key => $data) {
             # strip out the 'ns' prefix from the section name:
             $ns = substr($data['section'], 2);
             $nsText = $ns == NS_MAIN ? $this->msg('blanknamespace')->escaped() : htmlspecialchars($wgContLang->getFormattedNsText($ns));
             $this->toc .= Linker::tocLine("editwatchlist-{$data['section']}", $nsText, $this->getLanguage()->formatNum(++$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->setSubmitTextMsg('watchlistedit-normal-submit');
     # Used message keys: 'accesskey-watchlistedit-normal-submit', 'tooltip-watchlistedit-normal-submit'
     $form->setSubmitTooltip('watchlistedit-normal-submit');
     $form->setWrapperLegendMsg('watchlistedit-normal-legend');
     $form->addHeaderText($this->msg('watchlistedit-normal-explain')->parse());
     $form->setSubmitCallback(array($this, 'submitNormal'));
     return $form;
 }
 /**
  * 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;
 }