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-07 08:38 am

[dw-free] Migrate navigation strip options to /manage/settings

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

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

More fail, forgot this file.

Patch by [personal profile] afuna.

Files modified:
  • cgi-bin/LJ/Setting/NavStrip.pm
--------------------------------------------------------------------------------
diff -r 8c3ab6001259 -r c62abe1e6709 cgi-bin/LJ/Setting/NavStrip.pm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/LJ/Setting/NavStrip.pm	Sat Mar 07 08:38:21 2009 +0000
@@ -0,0 +1,112 @@
+#!/usr/bin/perl
+#
+# LJ::Setting::NavStrip - Settings for navigation strip display
+#
+# Authors:
+#      Afuna <coder.dw@afunamatata.com>
+#
+# Copyright (c) 2009 by Dreamwidth Studios, LLC.
+#
+# This program is free software; you may redistribute it and/or modify it under
+# the same terms as Perl itself. For a copy of the license, please reference
+# 'perldoc perlartistic' or 'perldoc perlgpl'.
+
+package LJ::Setting::NavStrip;
+use base 'LJ::Setting';
+use strict;
+use warnings;
+
+=head1 NAME
+
+LJ::Setting::NavStrip - Settings for navigation strip display
+
+=head1 SYNOPSIS
+
+  Add it to the proper category under /manage/settings/index.bml
+
+=cut
+
+sub should_render {
+    my ( $class, $u ) = @_;
+
+    return $u ? 1 : 0;
+}
+
+sub helpurl {
+    return "navstrip";
+}
+
+sub label {
+    my $class = shift;
+
+    return $class->ml( 'setting.navstrip.label' );
+}
+
+sub option {
+    my ( $class, $u, $errs, $args ) = @_;
+    my $key = $class->pkgkey;
+
+    my @pageoptions = LJ::run_hook( 'page_control_strip_options' );
+    return undef unless @pageoptions;
+    
+    my %pagemask = map { $pageoptions[$_] => 1 << $_ } 0..$#pageoptions;
+
+    # choose where to display/see it
+
+    my $val = $class->get_arg( $args, "navstrip" );
+    my $navstrip;
+    $navstrip |= $_+0 foreach split( /\0/, $val );
+    $navstrip ||= 'none';
+
+    my $display = $navstrip || u->control_strip_display;
+
+    my $ret = $class->ml( 'setting.navstrip.option' );
+    foreach my $pageoption ( @pageoptions ) {
+        my $for_html = $pageoption;
+        $for_html =~ tr/\./_/;
+
+        $ret .= LJ::html_check({
+            name => "${key}navstrip",
+            id => "${key}navstrip_${for_html}",
+            selected => $display & $pagemask{$pageoption} ? 1 : 0,
+            value => $pagemask{$pageoption},
+        });
+        
+        $ret .= " <label for='${key}navstrip_${for_html}'>" . $class->ml( "setting.navstrip.option.$pageoption" ) . "</label>";
+   }
+
+    return $ret;
+}
+
+sub save {
+    my ( $class, $u, $args ) = @_;
+
+    my $val = $class->get_arg( $args, "navstrip" );
+
+    my $navstrip;
+    $navstrip |= $_+0 foreach split( /\0/, $val );
+    $navstrip ||= 'none';
+
+    $u->set_prop( control_strip_display => $navstrip );
+
+    return 1;
+}
+
+=head1 BUGS
+
+=head1 AUTHORS
+
+Afuna <coder.dw@afunamatata.com>
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (c) 2009 by Dreamwidth Studios, LLC.
+
+This program is free software; you may redistribute it and/or modify it under
+the same terms as Perl itself. For a copy of the license, please reference
+'perldoc perlartistic' or 'perldoc perlgpl'.
+
+=cut
+
+1;
+
--------------------------------------------------------------------------------