mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-03-21 11:06 pm

[dw-free] Slight glitch on /customize/advanced/styles before any data is saved.

[commit: http://hg.dwscoalition.org/dw-free/rev/580fdd809f33]

http://bugs.dwscoalition.org/show_bug.cgi?id=531

Support core2 on customize advanced styles.

Patch by [personal profile] exor674.

Files modified:
  • htdocs/customize/advanced/styles.bml
--------------------------------------------------------------------------------
diff -r 4a890b60b27c -r 580fdd809f33 htdocs/customize/advanced/styles.bml
--- a/htdocs/customize/advanced/styles.bml	Sat Mar 21 23:03:45 2009 +0000
+++ b/htdocs/customize/advanced/styles.bml	Sat Mar 21 23:06:32 2009 +0000
@@ -128,15 +128,18 @@
         }
 
         # core lid (can't use user core layer)
-        $POST{'core'} ||= $POST{'core_hidden'};
-        $core = defined $POST{'core'} ? $POST{'core'} : $style->{'layer'}->{'core'};
-        unless ($core) { # default to highest numbered core
-            map { $core = $_ if $pub->{$_}->{'type'} eq 'core' && /^\d+$/ && 
-                                $pub->{$_}->{'majorversion'} > $pub->{$core}->{'majorversion'} } keys %$pub;
+        $POST{core} ||= $POST{core_hidden};
+        $core = defined $POST{core} ? $POST{core} : $style->{layer}->{core};
+        my $highest_core;
+        map { $core = $_ if $pub->{$_}->{type} eq 'core' && /^\d+$/ && 
+                $pub->{$_}->{majorversion} > $pub->{$highest_core}->{majorversion} } keys %$pub;
+        unless ( $core ) {
+            $core = $highest_core;
 
             # update in POST to keep things in sync
-            $POST{'core'} = $core;
+            $POST{core} = $highest_core;
         }
+        $style->{layer}->{core} = $highest_core unless $style->{layer}->{core}; 
 
         # layout lid
         $layout = $POST{'action:change'} ? $eff_layer{'layout'} : $style->{'layer'}->{'layout'};
@@ -197,7 +200,7 @@
                     return $err->(BML::ml('.error.layernotpublic', {'layer' => $_})) unless $other_info{$_}->{'is_public'};
                 }
             }
-            
+
             # error check layer modifications
             my $get_layername = sub {
                 my $lid = shift;
@@ -300,7 +303,7 @@
                 $body .= LJ::html_submit('action:edit', $ML{'.btn.edit'}) . " ";
 
                 my $confirm_msg = LJ::ejs(BML::ml('.delete.confirm', {'id' => $styleid}));
-                
+
                 $body .= LJ::html_submit('action:delete', $ML{'.btn.delete'}, 
                                          { 'onclick' => "return confirm('$confirm_msg')", disabled => $noactions }) . " ";
                 $body .= LJ::html_submit('action:usestyle', $ML{'.btn.use'}, { 'disabled' => $styleid == $u->{'s2_style'} || $noactions }),
@@ -334,7 +337,7 @@
 
     # if no id to edit, we're finished
     $body .= "</form>\n", return unless $id;
-# from here on we have $pub, $ulay, and $style filled in
+    # from here on we have $pub, $ulay, and $style filled in
 
     # sub to take a layer type, core, and parent layout
     # and return a list of options to feed to LJ::html_select()
@@ -368,7 +371,7 @@
                         /^\d+$/
                     } keys %$ref;
         };
-        
+
         # public layers
         my $name = $type eq 'core' ? 'majorversion' : 'name';
         push @opts, map { $_, $pub->{$_}->{$name} } $greplist->($pub);
@@ -496,5 +499,4 @@ head<=
 <=head
 body=><?_code return $body; _code?>
 bodyopts=>onLoad="pageload();"
-page?>
-    
+page?>
\ No newline at end of file
--------------------------------------------------------------------------------