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

www lon-capa-cvs@mail.lon-capa.org
Tue, 08 Jun 2004 01:32:02 -0000


This is a MIME encoded message

--www1086658322
Content-Type: text/plain

www		Mon Jun  7 21:32:02 2004 EDT

  Modified files:              
    /loncom/homework	edit.pm 
    /loncom/interface	lonhtmlcommon.pm lonpreferences.pm 
  Log:
  Preferences to switch HTMLarea on/off. Could not test because Mozilla keeps
  crashing when HTMLarea enabled :-(
  
  
--www1086658322
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20040607213202.txt"

Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.83 loncom/homework/edit.pm:1.84
--- loncom/homework/edit.pm:1.83	Fri Jun  4 12:05:47 2004
+++ loncom/homework/edit.pm	Mon Jun  7 21:32:01 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # edit mode helpers
 #
-# $Id: edit.pm,v 1.83 2004/06/04 16:05:47 www Exp $
+# $Id: edit.pm,v 1.84 2004/06/08 01:32:01 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -487,7 +487,11 @@
     my ($tag,$data,$description,$minwidth,$minheight,$usehtmlarea)=@_;
 
     my ($rows,$cols)=&textarea_sizes(\$data);
-    $rows+=5; # make room for HTMLarea
+    if (&Apache::lonhtmlcommon::htmlareabrowser() &&
+	!&Apache::lonhtmlcommon::htmlareablocked()) {
+	$rows+=7;      # make room for HTMLarea
+	$minheight+=7; # make room for HTMLarea
+    }
     if ($cols > 80) { $cols = 80; }
     if ($cols < $minwidth ) { $cols = $minwidth; }
     if ($rows < $minheight) { $rows = $minheight; }
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.75 loncom/interface/lonhtmlcommon.pm:1.76
--- loncom/interface/lonhtmlcommon.pm:1.75	Sat Jun  5 10:46:12 2004
+++ loncom/interface/lonhtmlcommon.pm	Mon Jun  7 21:32:02 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.75 2004/06/05 14:46:12 www Exp $
+# $Id: lonhtmlcommon.pm,v 1.76 2004/06/08 01:32:02 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -869,6 +869,7 @@
 
 sub htmlareaheaders {
     if (&htmlareablocked()) { return ''; }
+    unless (&htmlareabrowser()) { return ''; }
     my $lang='en';
     if (&mt('htmlarea_lang') ne 'htmlarea_lang') {
 	$lang=&mt('htmlarea_lang');
@@ -886,6 +887,7 @@
 
 sub htmlareaaddbuttons {
     if (&htmlareablocked()) { return ''; }
+    unless (&htmlareabrowser()) { return ''; }
     return (<<ENDADDBUTTON);
     var config=new HTMLArea.Config();
     config.registerButton('ed_math','LaTeX Inline',
@@ -904,16 +906,30 @@
     config.toolbar.push(['ed_math','ed_math_eqn']);
 ENDADDBUTTON
 }
+
+# ----------------------------------------------------------------- Preferences
+
+sub disablelink {
+    return '<a href="/adm/preferences?action=set_wysiwyg&wysiwyg=off&returnurl='.&Apache::lonnet::escape($ENV{'REQUEST_URI'}).'">'.&mt('Disable WYSIWYG Editor').'</a>';
+}
+
+sub enablelink {
+    return '<a href="/adm/preferences?action=set_wysiwyg&wysiwyg=on&returnurl='.&Apache::lonnet::escape($ENV{'REQUEST_URI'}).'">'.&mt('Enable WYSIWYG Editor').'</a>';
+}
+
 # ---------------------------------------------------------- Script to activate
 
 sub htmlareaactive {
-    if (&htmlareablocked()) { return ''; }
+    unless (&htmlareabrowser()) { return ''; }
+    if (&htmlareablocked()) { return '<br />'.&enablelink(); }
     my $addbuttons=&htmlareaaddbuttons();
+    my $disable=&disablelink();
     return (<<ENDSCRIPT);
 <script type="text/javascript" defer="1">
     $addbuttons
     HTMLArea.replaceAll(config);
-</script>
+</script><br />
+$disable
 ENDSCRIPT
 }
 
@@ -921,20 +937,22 @@
 
 sub htmlareaselectactive {
     my @fields=@_;
-    if (&htmlareablocked()) { return ''; }
+    unless (&htmlareabrowser()) { return ''; }
+    if (&htmlareablocked()) { return '<br />'.&enablelink(); }
     my $output='<script type="text/javascript" defer="1">'.
 	&htmlareaaddbuttons();
     foreach(@fields) {
 	$output.="\nHTMLArea.replace('$_',config);";
     }
-    $output.="\nwindow.status='Activated Editfields';\n</script>";
+    $output.="\nwindow.status='Activated Editfields';\n</script><br />".
+	&disablelink();
     return $output;
 }
 
 # --------------------------------------------------------------------- Blocked
 
 sub htmlareablocked {
-    unless (&htmlareabrowser()) { return 1; }
+    unless ($ENV{'environment.wysiwygeditor'} eq 'on') { return 1; }
     return 0;
 }
 
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.43 loncom/interface/lonpreferences.pm:1.44
--- loncom/interface/lonpreferences.pm:1.43	Tue May 25 18:00:21 2004
+++ loncom/interface/lonpreferences.pm	Mon Jun  7 21:32:02 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.43 2004/05/25 22:00:21 raeburn Exp $
+# $Id: lonpreferences.pm,v 1.44 2004/06/08 01:32:02 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -92,6 +92,41 @@
 ################################################################
 #         Language Change Subroutines                          #
 ################################################################
+
+sub wysiwygchanger {
+    my $r = shift;
+    my %userenv = &Apache::lonnet::get
+        ('environment',['wysiwygeditor']);
+    my $offselect='';
+    my $onselect='checked="1"';
+    if ($userenv{'wysiwygeditor'}) {
+	$onselect='';
+	$offselect='checked="1"';
+    }
+    my $switchoff=&mt('Disable WYSIWYG editor');
+    my $switchon=&mt('Enable WYSIWYG editor');
+    $r->print(<<ENDLSCREEN);
+<form name="server" action="/adm/preferences" method="post">
+<input type="hidden" name="action" value="set_wysiwyg" />
+<br />
+<input type="radio" name="wysiwyg" value="off" $onselect /> $switchoff<br />
+<input type="radio" name="wysiwyg" value="on" $offselect /> $switchon
+ENDLSCREEN
+    $r->print('<br /><input type="submit" value="'.&mt('Change').'" />');
+}
+
+
+sub verify_and_change_wysiwyg {
+    my $r = shift;
+    my $newsetting=$ENV{'form.wysiwyg'};
+    &Apache::lonnet::put('environment',{'wysiwygeditor' => $newsetting});
+    &Apache::lonnet::appenv('environment.wysiwygeditor' => $newsetting);
+    $r->print('<p>'.&mt('Setting WYSIWYG editor to:').' '.&mt($newsetting).'</p>');
+}
+
+################################################################
+#         Language Change Subroutines                          #
+################################################################
 sub languagechanger {
     my $r = shift;
     my $user       = $ENV{'user.name'};
@@ -787,7 +822,7 @@
     return OK if $r->header_only;
     #
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
-                                            ['action']);
+                                            ['action','wysiwyg','returnurl']);
     #
     &Apache::lonhtmlcommon::clear_breadcrumbs();
     &Apache::lonhtmlcommon::add_breadcrumb
@@ -885,6 +920,21 @@
                       printmenu => 'yes',
                       subroutine=>\&verify_and_change_languages, }
                     ));
+    push (@Options,({ action => 'changewysiwyg',
+                      linktext => 'Change WYSIWYG Editor Preferences',
+                      href => '/adm/preferences',
+                      breadcrumb => 
+                            { href => '/adm/preferences?action=changewysiwyg',
+                              text => 'Change WYSIWYG Preferences'},
+                      subroutine => \&wysiwygchanger,
+                  },
+                    { action => 'set_wysiwyg',
+                      breadcrumb =>
+                          { href => '/adm/preferences?action=changewysiwyg',
+                            text => 'Change WYSIWYG Preferences'},
+                      printmenu => 'yes',
+                      subroutine => \&verify_and_change_wysiwyg, }
+                    ));
     push (@Options,({ action => 'changediscussions',
                       linktext => 'Change Discussion Display Preferences',
                       href => '/adm/preferences',
@@ -931,7 +981,7 @@
     if (defined($call)) {
         $call->($r);
     }
-    if ($printmenu eq 'yes') {
+    if (($printmenu eq 'yes') && (!$ENV{'form.returnurl'})) {
         my $optionlist = '<table cellpadding="5">';
         if ($ENV{'user.name'} =~ 
                          /^(albertel|kortemey|korte|hallmat3|turtle)$/
@@ -971,6 +1021,9 @@
         }
         $optionlist .= '</table>';
         $r->print($optionlist);
+    } elsif ($ENV{'form.returnurl'}) {
+	$r->print('<br /><a href="'.$ENV{'form.returnurl'}.'"><font size="+1">'.
+		  &mt('Return').'</font></a>');
     }
     $r->print(<<ENDFOOTER);
 </body>

--www1086658322--