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

bisitz bisitz@source.lon-capa.org
Tue, 16 Jun 2009 16:49:12 -0000


bisitz		Tue Jun 16 16:49:12 2009 EDT

  Modified files:              
    /loncom/interface	lonmsgdisplay.pm 
  Log:
  - Replaced texts for message page button by commonly used icon-like texts
  - Corrected unbalanced tags (added missing </a>)
  - XHTML:
      - Properly exclude javascript code from being interpreted as HTML code
      - Properly escape parameters in <a href="URL" ...>
      - lower case "onclick", "onchange"
  
  
Index: loncom/interface/lonmsgdisplay.pm
diff -u loncom/interface/lonmsgdisplay.pm:1.126 loncom/interface/lonmsgdisplay.pm:1.127
--- loncom/interface/lonmsgdisplay.pm:1.126	Thu Jun 11 16:48:33 2009
+++ loncom/interface/lonmsgdisplay.pm	Tue Jun 16 16:49:11 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging display
 #
-# $Id: lonmsgdisplay.pm,v 1.126 2009/06/11 16:48:33 bisitz Exp $
+# $Id: lonmsgdisplay.pm,v 1.127 2009/06/16 16:49:11 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -173,6 +173,7 @@
 
     $formhash{'select_form_order'} = ['','critical',@userorder,'sent','trash'];
     my $output = qq|<script type="text/javascript">
+// <![CDATA[
 function folder_choice(targetform,caller) {
     var permfolders_keys = new Array('$permlistkeys');
     var permfolders_vals = new Array('$permlistvals');
@@ -214,6 +215,7 @@
         }
     }
 }
+// ]]>
 </script>|;
     my %show = ('select_form_order' => [10,20,50,100,200],
 		map {$_=>$_} (10,20,50,100,200));
@@ -239,7 +241,7 @@
      <td align="center"><b>'.$lt{'actn'}.'</b><br />'.
          &Apache::loncommon::select_form('view','folderaction',%actions).'
      </td><td><br />'.
-    '<input type="button" value="'.$lt{'go'}.'" onClick="javascript:folder_choice(this.form,'."'change'".');" />
+    '<input type="button" value="'.$lt{'go'}.'" onclick="javascript:folder_choice(this.form,'."'change'".');" />
      </td>
     </tr>
    </table>
@@ -247,7 +249,7 @@
   <td align="right">
    <table><tr><td><br />
     <input type="button" value="'.&mt('New Folder').
-    '" onClick="javascript:folder_choice(this.form,'."'new'".');" /></td>'.
+    '" onclick="javascript:folder_choice(this.form,'."'new'".');" /></td>'.
     '<td align="center"><b>'.&mt('Name').'</b><br />'.
     '<input type="text" size="15" name="newfolder" value="" />
     </td></tr></table>
@@ -295,11 +297,11 @@
     }
     return
    '<b>'.&mt('Page').'</b>: '. 
-   '<input type="submit" name="firstview" value="'.&mt('First').'" />'.
-   '<input type="submit" name="prevview" value="'.&mt('Previous').'" />'.
-   '<input type="text" size="5" name="startdis" value="'.$start.'" onChange="this.form.submit()" /> of '.$maxdis.
-   '<input type="submit" name="nextview" value="'.&mt('Next').'" />'.
-   '<input type="submit" name="lastview" value="'.&mt('Last').'" /><br />'.
+   '<input type="submit" name="firstview" value="|&lt;" />'.
+   '<input type="submit" name="prevview" value="&lt;" />'.
+   ' <input type="text" size="5" name="startdis" value="'.$start.'" onchange="this.form.submit()" /> / '.$maxdis.' '.
+   '<input type="submit" name="nextview" value="&gt;" />'.
+   '<input type="submit" name="lastview" value="&gt;|" /><br />'.
    &mt('<b>[_1] messages</b>: showing messages [_2] through [_3] of [_4].',$status,$first,$finish,$total).'</form>';
 }
 # =============================================================== Status Change
@@ -680,6 +682,7 @@
 sub group_check_uncheck {
     my $output = qq|
 <script type="text/javascript">
+// <![CDATA[
 function toggleAll(form,action) {
     if (typeof(form.selectedusers_forminput.length)=="undefined") {
          if (action == 'check') {
@@ -697,6 +700,7 @@
         }
     }
 }
+// ]]>
 </script>
     |;
 }
@@ -991,6 +995,7 @@
     my $jscript = &Apache::loncommon::check_uncheck_jscript();
     $r->print(<<ENDDISHEADER);
 <script type="text/javascript">
+// <![CDATA[
     $jscript
 
     function validate_checkedaction() {
@@ -1019,11 +1024,11 @@
         }
         document.disall.submit();
     }
-
+// ]]>
 </script>
 ENDDISHEADER
 
-    my $fsqs='&folder='.$folder;
+    my $fsqs='&amp;folder='.$folder;
     my @temp=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder,$msgstatus);
     my $totalnumber=$#temp+1;
     if ($totalnumber < 1) {
@@ -1137,7 +1142,7 @@
             foreach my $item ($localsenttime,$dis_name,$dis_domain,$shortsubj) {
                 $r->print('<td>'.(($status eq 'new')?'<b>':'').
                           '<a href="/adm/email?display='.$origID.$sqs.'">'.
-                          $item.(($status eq 'new')?'</b>':'').'</td>');
+                          $item.(($status eq 'new')?'</b>':'').'</a></td>');
             }
             my $showstatus;
             my %statushash = &get_msgstatus_types();
@@ -1356,6 +1361,7 @@
             $sendmode = '<input type="hidden" name="sendmode" value="group" />'."\n";
             $broadcast_js = qq|
 <script type="text/javascript">
+// <![CDATA[
 function courseRecipients() {
 |;
         foreach my $type (keys(%access_status)) {
@@ -1382,6 +1388,7 @@
         $broadcast_js .= qq|
     return;
 }
+// ]]>
 </script>
 
 |;
@@ -1425,7 +1432,9 @@
         my $jscript = &Apache::loncommon::check_uncheck_jscript();
         $r->print(<<"ENDREPSCRIPT");
 <script type="text/javascript">
+// <![CDATA[
 $jscript
+// ]]>
 </script>
 ENDREPSCRIPT
     }
@@ -2738,6 +2747,7 @@
             $body =~ s{\n}{}g;
             $r->print(<<ENDJS);
 <script type="text/javascript">
+// <![CDATA[
 function showBroadcastList() {
     var caller = this;
     var newWindow = null;
@@ -2760,7 +2770,7 @@
     caller.document.close();
     caller.focus();
 }
-
+// ]]>
 </script>
 
 ENDJS
@@ -3219,7 +3229,7 @@
          'recordftf','sortedby','block','folder','startdis','interdis',
 	 'showcommentbaseurl','dismode','group','subject','text','ref',
          'msgstatus']);
-    $sqs='&sortedby='.$env{'form.sortedby'};
+    $sqs='&amp;sortedby='.$env{'form.sortedby'};
 
 # ------------------------------------------------------ They checked for email
     unless ($env{'form.block'}) {
@@ -3240,7 +3250,7 @@
     unless ($folder) { 
 	$folder=''; 
     } else {
-	$sqs.='&folder='.&escape($folder);
+	$sqs.='&amp;folder='.&escape($folder);
     }
 # ------------------------------------------------------------ Get Display Mode
 
@@ -3272,7 +3282,7 @@
 	$startdis++;
     }
     my $postedstartdis=$startdis+1;
-    $sqs.='&startdis='.$postedstartdis;
+    $sqs.='&amp;startdis='.$postedstartdis;
 
 # --------------------------------------------------------------- Render Output