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

faziophi faziophi@source.lon-capa.org
Tue, 22 Dec 2009 06:32:05 -0000


faziophi		Tue Dec 22 06:32:05 2009 EDT

  Modified files:              
    /loncom/interface	lonbulletin.pm 
  Log:
  -- Upgrading bulletin boards to use new CKEditor
  -- Move textareas and save buttons within the LC_Box templates
  -- Use rich text editor if HTML is detected, else allow user to 
     enable on demand
  
  
Index: loncom/interface/lonbulletin.pm
diff -u loncom/interface/lonbulletin.pm:1.56 loncom/interface/lonbulletin.pm:1.57
--- loncom/interface/lonbulletin.pm:1.56	Mon Dec 14 13:42:33 2009
+++ loncom/interface/lonbulletin.pm	Tue Dec 22 06:32:04 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Bulletin Board Handler
 #
-# $Id: lonbulletin.pm,v 1.56 2009/12/14 13:42:33 wenzelju Exp $
+# $Id: lonbulletin.pm,v 1.57 2009/12/22 06:32:04 faziophi Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -237,7 +237,7 @@
 # ---------------------------------------------------------------- Get discussion board
     if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
         #Print Topic as Heading
-        my $titletext=$syllabus{'aaa_title'};
+        my $titletext=&HTML::Entities::encode($syllabus{'aaa_title'},'<>&"');;
         if ($target ne 'tex') {
             $r->print('<h2>'.$titletext.'</h2>');
         } else {
@@ -246,21 +246,32 @@
         #Outputbox and Inputbox for Topic
         if ($allowed) {
             $r->print('<form method="post" action="" enctype="multipart/form-data">');
-            &Apache::lontemplate::print_template($r, &mt('Title'), $titletext,$allowed,'LC_Box');
-            &Apache::lontemplate::print_editbox_template($r, $syllabus{'aaa_title'},'aaa_title');
+            &Apache::lontemplate::print_start_template($r,&mt('Title'),'LC_Box');
+            $r->print($titletext);
+			$r->print("<br /><div>");
+			&Apache::lontemplate::print_textarea_template($r, $syllabus{'aaa_title'},
+				'aaa_title', Apache::lontemplate->RICH_TEXT_ALWAYS_OFF);
+			&Apache::lontemplate::print_saveall_template($r);
+			$r->print("</div>");
+			&Apache::lontemplate::print_end_template($r);
         }
         if ($syllabus{'uploaded.photourl'}) {
             &Apache::lonnet::allowuploaded('/adm/syllabus',
                                            $syllabus{'uploaded.photourl'});
         }
+        my @htmlids=();
         #Outputbox and Inputbox for Image upload
         if ($allowed) {
-            &Apache::lontemplate::print_template($r, &mt('Upload a Photo'), '<img src="'.$syllabus{'uploaded.photourl'}.'" alt="'.&mt('Image').'"/>',$allowed,'LC_Box');
+        	my $message = '<img src="'.$syllabus{'uploaded.photourl'}.'" alt="'.&mt('Image').'"/>';
+        	&Apache::lontemplate::print_start_template($r, &mt('Upload a Photo'),'LC_Box');
+            $r->print($message);
+            $r->print("<br /><br />");
             $r->print(
                 '<input type="hidden" name="forceedit" value="edit" />'.
                 '<input type="file" name="uploaddoc" size="50" />'.
                 '<input type="submit" name="storeupl" value="'.&mt('Upload').'" />'.
                 '<input type="hidden" name="forceedit" value="edit" />');
+            &Apache::lontemplate::print_end_template($r);
         }
         #Image in Student view.
         elsif($syllabus{'uploaded.photourl'} && $target ne 'tex'){
@@ -271,28 +282,37 @@
                 my $message=$syllabus{$field};
                 if (!&Apache::lonfeedback::contains_block_html($message)) {
                 	&Apache::lonfeedback::newline_to_br(\$message);
-                }
+                } else {
+                    $message = &Apache::lonfeedback::tidy_html($message);
+				}
                 $message=&Apache::lonhtmlcommon::raw_href_to_link($message);
                 if ($allowed) {
                     $message=&Apache::lonspeller::markeduptext($message);
                 }
                 $message=&Apache::lontexconvert::msgtexconverted($message);
                 unless ($field eq 'aaa_title') {
-                    #Outputbox
                     if ($target ne 'tex') {
-                        &Apache::lontemplate::print_template($r, $syllabusfields{$field}, $message,$allowed,'LC_Box');
+						#output of syllabusfields will be generated here. 
+						&Apache::lontemplate::print_start_template($r,$syllabusfields{$field},'LC_Box');
+                        $r->print($message);
+                        if ($allowed) {
+                            $r->print("<br /><div>");
+                            &Apache::lontemplate::print_textarea_template($r, $syllabus{$field},
+                            	$field, Apache::lontemplate->RICH_TEXT_DETECT_HTML);
+                            &Apache::lontemplate::print_saveall_template($r);
+							$r->print("</div>");
+						} 
+                    	&Apache::lontemplate::print_end_template($r);
+                    	push(@htmlids,$field);
                     } else {
                         $r->print('\\\\\textbf{'.$syllabusfields{$field}.'}\\\\'.&Apache::lonxml::xmlparse($r,'tex',$message));
                     }
-                    #Inputbox
-                    if ($allowed) {
-                         &Apache::lontemplate::print_editbox_template($r, $syllabus{$field}, $field);
-                    }
                 }   
             }
         }
         if ($allowed) {
-            $r->print('</form>');
+            $r->print('</form>'.
+            &Apache::lonhtmlcommon::htmlareaselectactive(@htmlids));
         }
         if ($target ne 'tex'){
             $r->print('<br/><br/><hr/><br/>');