[LON-CAPA-cvs] cvs: loncom /interface lonpreferences.pm

raeburn raeburn@source.lon-capa.org
Mon, 16 May 2011 00:55:53 -0000


raeburn		Mon May 16 00:55:53 2011 EDT

  Modified files:              
    /loncom/interface	lonpreferences.pm 
  Log:
  - Reverse part of changes in 1.187.
    - Reinstate "Menu Display" in "Page Display Settings".
      - Icon modes can be set to either icons + text (default) or icons only.
      - Warning that "classic" (i.e., buttons + text) is deprecated.
  - Preview of two modes (icons + text vs. icons only).
  
  
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.191 loncom/interface/lonpreferences.pm:1.192
--- loncom/interface/lonpreferences.pm:1.191	Fri Aug 20 12:32:21 2010
+++ loncom/interface/lonpreferences.pm	Mon May 16 00:55:53 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.191 2010/08/20 12:32:21 riegler Exp $
+# $Id: lonpreferences.pm,v 1.192 2011/05/16 00:55:53 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -591,6 +591,106 @@
 }
 
 ################################################################
+#                     Icon Subroutines                         #
+################################################################
+sub iconchanger {
+    my $r = shift;
+    &Apache::lonhtmlcommon::add_breadcrumb(
+            {   href => '/adm/preferences?action=changeicons',
+                text => 'Change Menu Display'});
+    $r->print(Apache::loncommon::start_page('Page Display Settings'));
+    $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Menu Display'));
+
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
+    my %userenv = &Apache::lonnet::get('environment',['icons']);
+    my $iconic='checked="checked"';
+    my ($classic,$onlyicon,$iconic_preview,$iconsonly_preview);
+    if ($userenv{'icons'} eq 'classic') {
+        $iconic='';
+        $classic='<div class="LC_info">'.
+                 &mt('Your current selection: "Use buttons and text" is deprecated - it is recommended that you change this to "Use icons and text".').'</div>';
+    }
+    if ($userenv{'icons'} eq 'iconsonly') {
+       $onlyicon='checked="checked"';
+       $iconic='';
+    }
+    my $change=&mt('Save');
+    my %lt = &icon_options();
+    my ($inlinetools,$toolsorder) = &icon_previews();
+    if ((ref($inlinetools) eq 'HASH') && (ref($toolsorder) eq 'ARRAY')) {
+        foreach my $tool (@{$toolsorder}) {
+            my ($command,$row,$col,$img,$top,$bot,$act,$desc) = 
+                split(/\&/,$inlinetools->{$tool});
+            $iconic_preview .= '<li><a title="'.$desc.'" class="LC_menubuttons_link" href=""><img alt="'.$desc.'" src="/res/adm/pages/'.$img.'"  class="LC_icon" /><span class="LC_menubuttons_inline_text">'.$top.('&nbsp;' x 2).'</span></a></li>';
+            $iconsonly_preview .= '<li><a title="'.$desc.'" class="LC_menubuttons_link" href=""><img alt="'.$desc.'" src="/res/adm/pages/'.$img.'"  class="LC_icon" />&nbsp;</a></li>';
+        }
+    }
+    $iconsonly_preview = '<ul class="LC_breadcrumb_tools_outerlist"><li>'.
+                         '<ul>'.
+                         $iconsonly_preview.
+                         '</ul></li></ul>';
+    $iconic_preview = '<ul class="LC_breadcrumb_tools_outerlist"><li>'.
+                      '<ul>'.
+                      $iconic_preview.
+                      '</ul></li></ul>'; 
+    $r->print(<<ENDSCREEN);
+$classic
+<form name="prefs" action="/adm/preferences" method="post">
+<input type="hidden" name="action" value="verify_and_change_icons" />
+<label><input type="radio" name="menumode" value="iconic" $iconic /> $lt{'iconic'}</label>$iconic_preview<br />
+<label><input type="radio" name="menumode" value="iconsonly" $onlyicon /> $lt{'iconsonly'}</label>$iconsonly_preview<br />
+<input type="submit" value="$change" />
+</form>
+ENDSCREEN
+}
+
+sub verify_and_change_icons {
+    my $r = shift;
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
+    my $newicons   = $env{'form.menumode'};
+    my %lt = &icon_options();
+    my $newchoice = $newicons;
+    if ($lt{$newicons}) {
+        $newchoice = $lt{$newicons};
+    }
+    &Apache::lonnet::put('environment',{'icons' => $newicons});
+    &Apache::lonnet::appenv({'environment.icons' => $newicons});
+    my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.&mt('Menu Display').'</i>','<tt>'.$newchoice.'</tt>'));
+    $message=&Apache::loncommon::confirmwrapper($message);
+    &print_main_menu($r, $message);
+}
+
+sub icon_options {
+    return &Apache::lonlocal::texthash(
+                                        iconic    => 'Use icons and text',
+                                        iconsonly => 'Use icons only',
+                                      );
+}
+
+sub icon_previews {
+     my %icon_text = (
+                      annotate => 'Notes',
+                      wishlist => 'Wishlist',
+                      catalog  => 'Info',
+                      evaluate => 'Evaluate',
+                      feedback => 'Communicate',
+                      printout => 'Print',
+                     );
+    my %inlinetools = (
+        printout => "s&8&3&prt.png&$icon_text{'printout'}&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document",
+        wishlist => "s&9&1&wishlist-link.png&$icon_text{'wishlist'}&wishlistlink[_2]&set_wishlistlink()&Set a link for this resource to wishlist",
+        evaluate => "s&8&1&eval.png&$icon_text{'evaluate'}&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource",
+        feedback => "s&8&2&fdbk.png&$icon_text{'feedback'}&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource",
+        annotate => "s&9&3&anot.png&$icon_text{'annotate'}&tations[_1]&annotate()&Make notes and annotations about this resource",
+        catalog  => "s&6&3&catalog.png&$icon_text{'catalog'}&info[_1]&catalog_info()&Show Metadata",
+    );
+    my @toolsorder = qw(annotate wishlist evaluate feedback printout catalog);
+    return (\%inlinetools,\@toolsorder);
+}
+
+################################################################
 #                     Clicker Subroutines                      #
 ################################################################
 
@@ -1944,6 +2044,13 @@
 		icon => 'preferences-desktop-theme.png',
 		linktitle => 'Change LON-CAPA default colors.'
 	    },
+            {   linktext => 'Menu Display',
+                url => '/adm/preferences?action=changeicons',
+                permission => 'F',
+                #help => '',
+                icon => 'preferences-system-windows.png',
+                linktitle => 'Change whether the menus are displayed with icons or icons and text.'
+            }
 		]
     },
     {	categorytitle=>'Messages &amp; Notifications',
@@ -2104,6 +2211,10 @@
         &texenginechanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_texengine'){
         &verify_and_change_texengine($r);
+    }elsif($env{'form.action'} eq 'changeicons'){
+        &iconchanger($r);
+    }elsif($env{'form.action'} eq 'verify_and_change_icons'){
+        &verify_and_change_icons($r);
     }elsif($env{'form.action'} eq 'changeclicker'){
         &clickerchanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_clicker'){