#?SuikaWikiConfig/2.0

Plugin:
  @Name: Downgrade
  @Description:
    @@@: WikiView output partial downgrade for old clients
    @@lang:en
  @License: %%Perl%%
  @Author:
    @@Name:
      @@@@: Wakaba
      @@@lang:ja
      @@@script:Latn
    @@Mail[list]: w@suika.fam.cx
  @Date.RCS:
    $Date: 2005/03/15 08:50:05 $

PluginConst:
  @NS_XHTML1:
    http://www.w3.org/1999/xhtml

Function:
  @Name: set_downgrade_flags
  @Description:
    @@@: Setting value to downgrade flags ($wiki->{var}->{client}->{downgrade})
    @@lang:en
  @Main:
    my (undef, $wiki) = @_;
    my $flag = $wiki->{var}->{client}->{downgrade} ||= {};
    my $ua_name = $wiki->{var}->{client}->{user_agent_name};
    
    ## Gecko Mozilla
    if ($ua_name =~m#\bGecko/([0-9]+)#) {
      my $geckover = $1;
      $flag->{media_type_no_rdf_plus_xml} = 1;
      $flag->{http_no_see_other} = 1 if $geckover > 20030331;
      $flag->{html_no_table_abbr} = 1;
    
    ## Opera
    } elsif ($ua_name =~ m#\bOpera/([0-9]\.[0-9]+)#) {
      ## At least Opera/6 does not supports:
      $flag->{http_refresh_no_quoted_url} = 1;
      $flag->{http_regresh_no_semicolon_in_uri} = 1;
    
    ## Classic Mozilla
    } elsif ($ua_name =~ m#^Mozilla/([0-4]\.[0-9]+)#) {
      my $mozver = 0+$1;
      $flag->{html_no_pi} = 1;
      $flag->{html_no_id} = 1;
      $flag->{html_no_table_abbr} = 1;
      $flag->{media_type_no_xml} = 1;
      $flag->{html_no_latin1} = 1 if $mozver < 3;
        ## ISSUE: Is NN3 support latin-1 character on Japanese Windoze?
      $flag->{charset_name_with_x} = 1 if $mozver < 3;
      $flag->{http_refresh_no_semicolon_in_uri} = 1;
      if ($mozver >= 4) {
        $flag->{ua_netscape4} = 1;
        $flag->{stylesheet_non_standard} = 1;
        $flag->{html_link_no_media} = 1;
      } elsif ($mozver < 1) {
        $flag->{http_no_see_other} = 1;
        $flag->{media_type_no_parameter} = 1;
        $flag->{stylesheet_no_css} = 1;
      } else {
        $flag->{stylesheet_no_css} = 1;
      }
      
    ## IE
      if ($ua_name =~ /\bMSIE ([2-9]\.[0-9]+)/) {
        my $iever = 0+$1;
        if ($iever >= 6) {
          $flag->{media_type_no_xml} = 0;
          $flag->{media_type_no_plus_xml} = 1;
          $flag->{ua_winie60} = 1;
        } elsif ($iever >= 5) {
          $flag->{media_type_no_xml} = 0;
          $flag->{media_type_no_plus_xml} = 1;
          if ($iever >= 5.5) {
            $flag->{ua_winie55} = 1;
          } else {
            $flag->{ua_winie50} = 1;
          }
        } elsif ($iever >= 4) {
          $flag->{ua_winie40} = 1;
        } elsif ($iever >= 3) {
          $flag->{html_no_latin1} = 1;
            ## ISSUE: Does WinIE4 support latin-1 character on Japanese Windoze?
          $flag->{ua_winie30} = 1;
          $flag->{js_no_regex} = 1;
            ## ISSUE: Does WinIE4 support /regex-literal/?
        } else { # WinIE 2
          $flag->{html_no_div} = 1;
          $flag->{stylesheet_no_css} = 1;
          $flag->{http_refresh_no_quoted_url} = 1;
        }
        $flag->{media_type_no_app_js} = 1;
        $flag->{html_no_table_abbr} = 1;
        $flag->{stylesheet_non_standard} = 1 if $iever >= 3;
        $flag->{ua_netscape4} = 0;
      }
    ## WinIE 1.0
    } elsif ($ua_name =~ m#^Microsoft Internet Explorer\b#) {
      $flag->{html_no_id} = 1;
      $flag->{html_no_div} = 1;
      $flag->{html_no_table_abbr} = 1;
      $flag->{http_no_see_other} = 1;
      $flag->{stylesheet_no_css} = 1;
    } elsif ($ua_name =~ /^Infomosaic\b/) {
      $flag->{media_type_no_parameter} = 1;
      $flag->{html_no_id} = 1;
      $flag->{html_no_div} = 1;
      $flag->{html_no_table_abbr} = 1;
      $flag->{stylesheet_no_css} = 1;
    }

    if ($ua_name =~ /[Bb][Oo][Tt]/) {
      $flag->{is_robot} = 1;
    }

