/**
  * @param User $user
  * @param array $flags, selected flags
  * @param bool $disabled, form disabled
  * @param bool $reviewed, rev already reviewed
  * @return string
  * Generates a main tag inputs (checkboxes/radios/selects) for review form
  */
 protected static function ratingInputs($user, $flags, $disabled, $reviewed)
 {
     # Get all available tags for this page/user
     list($labels, $minLevels) = self::ratingFormTags($user, $flags);
     if ($labels === false) {
         $disabled = true;
         // a tag is unsettable
     }
     # If there are no tags, make one checkbox to approve/unapprove
     if (FlaggedRevs::binaryFlagging()) {
         return '';
     }
     $items = array();
     # Build rating form...
     if ($disabled) {
         // Display the value for each tag as text
         foreach (FlaggedRevs::getTags() as $quality) {
             $selected = isset($flags[$quality]) ? $flags[$quality] : 0;
             $items[] = FlaggedRevs::getTagMsg($quality) . ": " . FlaggedRevs::getTagValueMsg($quality, $selected);
         }
     } else {
         $size = count($labels, 1) - count($labels);
         foreach ($labels as $quality => $levels) {
             $item = '';
             $numLevels = count($levels);
             $minLevel = $minLevels[$quality];
             # Determine the level selected by default
             if (!empty($flags[$quality]) && isset($levels[$flags[$quality]])) {
                 $selected = $flags[$quality];
                 // valid non-zero value
             } else {
                 $selected = $minLevel;
             }
             # Show label as needed
             if (!FlaggedRevs::binaryFlagging()) {
                 $item .= Xml::tags('label', array('for' => "wp{$quality}"), FlaggedRevs::getTagMsg($quality)) . ":\n";
             }
             # If the sum of qualities of all flags is above 6, use drop down boxes.
             # 6 is an arbitrary value choosen according to screen space and usability.
             if ($size > 6) {
                 $attribs = array('name' => "wp{$quality}", 'id' => "wp{$quality}");
                 $item .= Xml::openElement('select', $attribs) . "\n";
                 foreach ($levels as $i => $name) {
                     $optionClass = array('class' => "fr-rating-option-{$i}");
                     $item .= Xml::option(FlaggedRevs::getTagMsg($name), $i, $i == $selected, $optionClass) . "\n";
                 }
                 $item .= Xml::closeElement('select') . "\n";
                 # If there are more than two levels, current user gets radio buttons
             } elseif ($numLevels > 2) {
                 foreach ($levels as $i => $name) {
                     $attribs = array('class' => "fr-rating-option-{$i}");
                     $item .= Xml::radioLabel(FlaggedRevs::getTagMsg($name), "wp{$quality}", $i, "wp{$quality}" . $i, $i == $selected, $attribs) . "\n";
                 }
                 # Otherwise make checkboxes (two levels available for current user)
             } elseif ($numLevels == 2) {
                 $i = $minLevel;
                 $attribs = array('class' => "fr-rating-option-{$i}");
                 $attribs = $attribs + array('value' => $i);
                 $item .= Xml::checkLabel(wfMessage('revreview-' . $levels[$i])->text(), "wp{$quality}", "wp{$quality}", $selected == $i, $attribs) . "\n";
             }
             $items[] = $item;
         }
     }
     return implode('   ', $items);
 }