[LON-CAPA-cvs] cvs: loncom /interface lonaboutme.pm lonsimplepage.pm lonsyllabus.pm lontemplate.pm

bisitz bisitz@source.lon-capa.org
Fri, 27 Mar 2009 15:46:38 -0000


This is a MIME encoded message

--bisitz1238168798
Content-Type: text/plain

bisitz		Fri Mar 27 15:46:38 2009 EDT

  Modified files:              
    /loncom/interface	lontemplate.pm lonaboutme.pm lonsimplepage.pm 
                     	lonsyllabus.pm 
  Log:
  Functionslist Optimizations:
  - Changed sub routines to allow collection of output data instead of being forced to directly print.
     This allows a much wider range of usage in other moduls
    (Now return the output data instead of direct printing)
  - Replaced hardcoded fieldset legend text by customized text (new parameter).
    Default text "Functions" if no parameter text provided.
  
  Adjusted related scripts (lonaboutme.pm, lonsimplepage.pm, lonsyllabus.pm) accordingly.
  - Added some line breaks for better code readability
  - Removed some " " (-> CSS)
  
  
--bisitz1238168798
Content-Type: text/plain
Content-Disposition: attachment; filename="bisitz-20090327154638.txt"

Index: loncom/interface/lontemplate.pm
diff -u loncom/interface/lontemplate.pm:1.28 loncom/interface/lontemplate.pm:1.29
--- loncom/interface/lontemplate.pm:1.28	Fri Mar 27 14:10:43 2009
+++ loncom/interface/lontemplate.pm	Fri Mar 27 15:46:38 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # "Template" Functions to generate html output
 #
-# $Id: lontemplate.pm,v 1.28 2009/03/27 14:10:43 bisitz Exp $
+# $Id: lontemplate.pm,v 1.29 2009/03/27 15:46:38 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -147,19 +147,20 @@
 # Functionslist: List of functions
 # Typically used to display a list of available functions at top of page
 sub start_functionslist {
-	my($r)=@_;
-	$r->print('<fieldset><legend>'. &mt('Functions') . '</legend>');
-	$r->print('<ul class="LC_functionslist">');
+    my($legendtext)=@_;
+    $legendtext=&mt('Functions') if !$legendtext;
+    return '<fieldset><legend>'.$legendtext.'</legend>'
+          .'<ul class="LC_functionslist">';
 }
 
 sub item_functionslist {
-	my($r,$content) = @_;
-	$r->print('<li>'.$content.'</li>');
+    my($content) = @_;
+    return '<li>'.$content.'</li>';
 }
 
 sub end_functionslist {
-	my($r)=@_;
-	$r->print('</ul></fieldset>');
+    my($r)=@_;
+    return '</ul></fieldset>';
 }
 
 1;
Index: loncom/interface/lonaboutme.pm
diff -u loncom/interface/lonaboutme.pm:1.118 loncom/interface/lonaboutme.pm:1.119
--- loncom/interface/lonaboutme.pm:1.118	Fri Mar 27 13:50:36 2009
+++ loncom/interface/lonaboutme.pm	Fri Mar 27 15:46:38 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Personal Information Page
 #
-# $Id: lonaboutme.pm,v 1.118 2009/03/27 13:50:36 bisitz Exp $
+# $Id: lonaboutme.pm,v 1.119 2009/03/27 15:46:38 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -239,31 +239,36 @@
 
 #----------------Print Functions
 	if( $target ne 'tex'){
-		 &Apache::lontemplate::start_functionslist($r);
+		 $r->print(&Apache::lontemplate::start_functionslist());
       		if($allowed){
 			 my $query_string = &build_query_string({'forcestudent' => '1','popup' => $env{'form.popup'}});		
-			&Apache::lontemplate::item_functionslist($r,'<a href="'.$r->uri.$query_string.'">'.&mt('Show Public View').'</a>'.&Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView'));
+                        $r->print(&Apache::lontemplate::item_functionslist(
+                            '<a href="'.$r->uri.$query_string.'">'.&mt('Show Public View').'</a>'
+                           .&Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView')));
     		}elsif($privleged){
 			my $query_string = &build_query_string({'forceedit' => '1','popup' => $env{'form.popup'}});
-			 &Apache::lontemplate::item_functionslist($r,'<a href="'.$r->uri.$query_string.'">'. &mt('Edit').'</a>');
+                        $r->print(&Apache::lontemplate::item_functionslist(
+                            '<a href="'.$r->uri.$query_string.'">'. &mt('Edit').'</a>'));
 		}
-		&Apache::lontemplate::item_functionslist($r,&Apache::lontemplate::send_message($r,$cnum,$cdom));
+                $r->print(&Apache::lontemplate::item_functionslist(
+                    &Apache::lontemplate::send_message($r,$cnum,$cdom)));
 
-		if ($env{'request.course.id'} && &Apache::lonnet::allowed('srm',$env{'request.course.id'})	&& &in_course($cdom,$cnum)) {
+		if ($env{'request.course.id'} && &Apache::lonnet::allowed('srm',$env{'request.course.id'}) && &in_course($cdom,$cnum)) {
 			if (&Apache::lonnet::allowed('vsa', $env{'request.course.id'}) || &Apache::lonnet::allowed('vsa', $env{'request.course.id'}.'/'.
 					 $env{'request.course.sec'})) {
-				&Apache::lontemplate::item_functionslist($r,&Apache::loncommon::track_student_link('View recent activity by this student',
-			  	 	$cnum,$cdom).('&nbsp;'x2));
+                            $r->print(&Apache::lontemplate::item_functionslist(
+                                &Apache::loncommon::track_student_link('View recent activity by this student',$cnum,$cdom)));
 	    		}
                         if (&Apache::lonnet::allowed('vgr', $env{'request.course.id'}) || 
                             &Apache::lonnet::allowed('vgr', $env{'request.course.id'}.'/'.
                                                      $env{'request.course.sec'})) {
-                            &Apache::lontemplate::item_functionslist($r,&Apache::loncommon::slot_reservations_link('Slot reservation history',
-                                        $cnum,$cdom).('&nbsp;'x2));
+                            $r->print(&Apache::lontemplate::item_functionslist(
+                                &Apache::loncommon::slot_reservations_link('Slot reservation history',$cnum,$cdom)));
                         }
-	    		&Apache::lontemplate::item_functionslist($r,&Apache::loncommon::noteswrapper(&mt('Add Records'),$cnum,$cdom));
+                        $r->print(&Apache::lontemplate::item_functionslist(
+                            &Apache::loncommon::noteswrapper(&mt('Add Records'),$cnum,$cdom)));
 		}
-	&Apache::lontemplate::end_functionslist($r);
+        $r->print(&Apache::lontemplate::end_functionslist());
 	}  
 #------Print Headtitle
  if ($target ne 'tex') {
Index: loncom/interface/lonsimplepage.pm
diff -u loncom/interface/lonsimplepage.pm:1.76 loncom/interface/lonsimplepage.pm:1.77
--- loncom/interface/lonsimplepage.pm:1.76	Fri Mar 27 13:50:36 2009
+++ loncom/interface/lonsimplepage.pm	Fri Mar 27 15:46:38 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Simple Page Editor
 #
-# $Id: lonsimplepage.pm,v 1.76 2009/03/27 13:50:36 bisitz Exp $
+# $Id: lonsimplepage.pm,v 1.77 2009/03/27 15:46:38 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -262,25 +262,28 @@
 #---Print Function
 	if ($target ne 'tex') {
 		if($allowed || $privileged){
-			&Apache::lontemplate::start_functionslist($r);
+                        $r->print(&Apache::lontemplate::start_functionslist());
 			if($allowed){
-				&Apache::lontemplate::item_functionslist($r,'<a href="'.$r->uri.'?forcestudent=1">'.&mt('Show Student View').'</a>'.&Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView'));	      		
+                                $r->print(&Apache::lontemplate::item_functionslist(
+                                    '<a href="'.$r->uri.'?forcestudent=1">'.&mt('Show Student View').'</a>'
+                                   .&Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView')));
 			}elsif($privileged){
 				my $edittext = &mt('Edit');
        		 		if ($group ne '') {
             				$edittext = &mt('Edit Group Homepage');
         			}
-				&Apache::lontemplate::item_functionslist($r,'<a href="'.$r->uri.'?forceedit=edit'.$refarg.'">'.$edittext.'</a>');
+                                $r->print(&Apache::lontemplate::item_functionslist(
+                                    '<a href="'.$r->uri.'?forceedit=edit'.$refarg.'">'.$edittext.'</a>'));
         			if ($group ne '') {
             				if ($group_edit_perm) {
-               				 	&Apache::lontemplate::item_functionslist($r,'&nbsp;&nbsp;&nbsp;'.
-               					'<a href="/adm/coursegroups?action=modify&amp;refpage=grouplist'.
-               					'&amp;state=pick_task&amp;groupname='.$group.'">'.
-               					&mt('Edit Group Settings').'</a>');
+                                                $r->print(&Apache::lontemplate::item_functionslist(
+                                                    '<a href="/adm/coursegroups?action=modify&amp;refpage=grouplist'
+                                                   .'&amp;state=pick_task&amp;groupname='.$group.'">'
+                                                   .&mt('Edit Group Settings').'</a>'));
            				}
-      	 	 		}		    
+      	 	 		}
 			}
-			&Apache::lontemplate::end_functionslist($r);
+                        $r->print(&Apache::lontemplate::end_functionslist());
 		}
 	  }	
 
Index: loncom/interface/lonsyllabus.pm
diff -u loncom/interface/lonsyllabus.pm:1.83 loncom/interface/lonsyllabus.pm:1.84
--- loncom/interface/lonsyllabus.pm:1.83	Fri Mar 27 13:50:36 2009
+++ loncom/interface/lonsyllabus.pm	Fri Mar 27 15:46:38 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Syllabus
 #
-# $Id: lonsyllabus.pm,v 1.83 2009/03/27 13:50:36 bisitz Exp $
+# $Id: lonsyllabus.pm,v 1.84 2009/03/27 15:46:38 bisitz Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -238,13 +238,16 @@
 #--------Functions
 if ($target ne 'tex') {
 		if($allowed || $privileged){		
-		&Apache::lontemplate::start_functionslist($r);
+                $r->print(&Apache::lontemplate::start_functionslist());
 		if($allowed){ 		
-			&Apache::lontemplate::item_functionslist($r,'<a href="'.$r->uri.'?forcestudent=1">'.&mt('Show Public View').'</a>'.&Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView'));	      		
+                    $r->print(&Apache::lontemplate::item_functionslist(
+                        '<a href="'.$r->uri.'?forcestudent=1">'.&mt('Show Public View').'</a>'
+                       .&Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView')));
 		}elsif($privileged){
-			&Apache::lontemplate::item_functionslist($r,'<a href="'.$r->uri.'?forceedit=1">'.&mt('Edit').'</a>'); 
+                    $r->print(&Apache::lontemplate::item_functionslist(
+                        '<a href="'.$r->uri.'?forceedit=1">'.&mt('Edit').'</a>'));
 		}
-		&Apache::lontemplate::end_functionslist($r);
+                $r->print(&Apache::lontemplate::end_functionslist());
 		}
  }
 #----------------------------Print Headtitle

--bisitz1238168798--