/**
  * Process a diff for one setting
  *
  * @param $name String: setting name
  * @patam $old Mixed: old value
  * @param $new Mixed: new value
  * @param $type String: setting type
  * @return String: XHTML
  */
 function processDiffSetting($name, $old, $new, $type)
 {
     $msg = $this->msg('configure-setting-' . $name);
     $rawVal = Xml::element('tt', null, "\${$name}");
     if ($msg->exists()) {
         $msgVal = $msg->parse() . " ({$rawVal})";
     } else {
         $msgVal = $rawVal;
     }
     $oldSet = $this->getSettingAsArray(WebConfiguration::filterVar($old), $name, $type);
     $newSet = $this->getSettingAsArray(WebConfiguration::filterVar($new), $name, $type);
     $diffs = new Diff($oldSet, $newSet);
     $formatter = new TableDiffFormatter();
     return "<tr><td class=\"diff-lineno configure-setting\" colspan=\"4\">{$msgVal}</td></tr>\n" . $formatter->format($diffs);
 }
 /**
  * Really build the content of the form
  *
  * @param $settings array
  * @param $params array
  * @return xhtml
  */
 protected function buildSettings($settings, $param = array())
 {
     global $wgConf;
     $defaults = $wgConf->getDefaultsForWiki($this->mWiki);
     $ret = '';
     $perms = array();
     $notEditableSet = $this->getUneditableSettings();
     foreach ($settings as $title => $groups) {
         $res = true;
         if (!isset($param['restrict'])) {
             $res = true;
         } elseif (is_array($param['restrict'])) {
             if (isset($param['restrict'][$title])) {
                 $res = $param['restrict'][$title];
             } elseif (isset($param['restrict']['_default'])) {
                 $res = $param['restrict']['_default'];
             } else {
                 $res = true;
             }
         } else {
             $res = (bool) $param['restrict'];
         }
         foreach ($groups as $name => $sect) {
             foreach ($sect as $setting => $unused) {
                 if (in_array($setting, $notEditableSet)) {
                     unset($groups[$name][$setting]);
                     continue;
                 }
                 $read = $this->userCanRead($setting);
                 $edit = $this->userCanEdit($setting);
                 if ($this->mCanEdit ? $edit : $read) {
                     $res = false;
                 }
                 $perms[$setting] = array('read' => $read, 'edit' => $edit);
             }
             if (!count($groups[$name])) {
                 unset($groups[$name]);
             }
         }
         $thisSection = '';
         if (!$res) {
             if (!isset($param['showlink'])) {
                 $showlink = true;
             } elseif (is_array($param['showlink'])) {
                 if (isset($param['showlink'][$title])) {
                     $showlink = $param['showlink'][$title];
                 } elseif (isset($param['showlink']['_default'])) {
                     $showlink = $param['showlink']['_default'];
                 } else {
                     $showlink = true;
                 }
             } else {
                 $showlink = (bool) $param['showlink'];
             }
             foreach ($groups as $group => $settings) {
                 $thisGroup = '';
                 foreach ($settings as $setting => $type) {
                     $params = $perms[$setting] + array('type' => $type, 'value' => $this->getSettingValue($setting), 'link' => $showlink);
                     $customised = !array_key_exists($setting, $defaults);
                     $customised = $customised || WebConfiguration::filterVar($defaults[$setting]) != WebConfiguration::filterVar($params['value']);
                     $params['customised'] = $customised;
                     $show = $this->mCanEdit ? isset($params['edit']) ? $params['edit'] : $this->userCanEdit($setting) : (isset($params['read']) ? $params['read'] : $this->userCanRead($setting));
                     $show = $show && $this->isSettingAvailable($setting);
                     if ($show) {
                         $thisGroup .= $this->buildTableRow($setting, $params);
                     } else {
                         ## Don't even show it.
                     }
                 }
                 if ($thisGroup) {
                     $thisSection .= $this->buildTableHeading($group) . $thisGroup . Html::closeElement('table');
                 }
             }
             if ($thisSection) {
                 $thisSection = Html::rawElement('legend', null, $this->msg("configure-section-{$title}")->parse()) . $thisSection;
                 $ret .= Html::rawElement('fieldset', null, $thisSection);
             }
         }
     }
     return $ret;
 }