/**
  * @param $rules String
  * @param $textName String
  * @param $addResultDiv Boolean
  * @param $canEdit Boolean
  * @return string
  */
 static function buildEditBox($rules, $textName = 'wpFilterRules', $addResultDiv = true, $canEdit = true)
 {
     global $wgOut;
     $textareaAttrib = array('dir' => 'ltr');
     # Rules are in English
     if (!$canEdit) {
         $textareaAttrib['readonly'] = 'readonly';
     }
     global $wgUser;
     $noTestAttrib = array();
     if (!$wgUser->isAllowed('abusefilter-modify')) {
         $noTestAttrib['disabled'] = 'disabled';
         $addResultDiv = false;
     }
     $rules = rtrim($rules) . "\n";
     $rules = Xml::textarea($textName, $rules, 40, 15, $textareaAttrib);
     if ($canEdit) {
         $dropDown = self::getBuilderValues();
         // Generate builder drop-down
         $builder = '';
         $builder .= Xml::option(wfMessage('abusefilter-edit-builder-select')->text());
         foreach ($dropDown as $group => $values) {
             // Give grep a chance to find the usages:
             // abusefilter-edit-builder-group-op-arithmetic, abusefilter-edit-builder-group-op-comparison,
             // abusefilter-edit-builder-group-op-bool, abusefilter-edit-builder-group-misc,
             // abusefilter-edit-builder-group-funcs, abusefilter-edit-builder-group-vars
             $builder .= Xml::openElement('optgroup', array('label' => wfMessage("abusefilter-edit-builder-group-{$group}")->text())) . "\n";
             foreach ($values as $content => $name) {
                 $builder .= Xml::option(wfMessage("abusefilter-edit-builder-{$group}-{$name}")->text(), $content) . "\n";
             }
             $builder .= Xml::closeElement('optgroup') . "\n";
         }
         $rules .= Xml::tags('select', array('id' => 'wpFilterBuilder'), $builder) . ' ';
         // Add syntax checking
         $rules .= Xml::element('input', array('type' => 'button', 'value' => wfMessage('abusefilter-edit-check')->text(), 'id' => 'mw-abusefilter-syntaxcheck') + $noTestAttrib);
     }
     if ($addResultDiv) {
         $rules .= Xml::element('div', array('id' => 'mw-abusefilter-syntaxresult', 'style' => 'display: none;'), ' ');
     }
     // Add script
     $wgOut->addModules('ext.abuseFilter.edit');
     self::$editboxName = $textName;
     return $rules;
 }