Annotation of loncom/interface/lontemplate.pm, revision 1.23

1.2       neumanie    1: # The LearningOnline Network
                      2: # "Template" Functions to generate html output
                      3: #
1.23    ! neumanie    4: # $Id: lontemplate.pm,v 1.22 2009/03/02 16:38:35 amueller Exp $
1.2       neumanie    5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
                     29: 
1.1       amueller   30: package Apache::lontemplate;
                     31: 
                     32: 
                     33: use strict;
                     34: use Apache::Constants qw(:common);
                     35: use Apache::loncommon;
                     36: use Apache::lonnet;
1.5       ehlerst    37: use Apache::lonxml;
                     38: use Apache::lonspeller;
1.1       amueller   39: use Apache::lontexconvert;
                     40: use Apache::lonfeedback;
                     41: use Apache::lonrss();
                     42: use Apache::lonlocal;
                     43: use Apache::lonmsgdisplay();
                     44: use HTML::Entities();
                     45: 
1.7       ehlerst    46: 
                     47: sub start_columnSection{
                     48: 	my ($r) = @_;
1.13      harmsja    49: 	 $r->print('<div class="LC_columnSection">');
1.7       ehlerst    50: }
                     51: 
                     52: sub end_columnSection{
                     53: 	my ($r) = @_;
                     54: 	 $r->print('</div>');
                     55: }
                     56: 
1.15      neumanie   57: sub print_aboutme_content_template{
1.5       ehlerst    58: 	my ($r,$allowed,$target,$syllabusfields_ref,$syllabus_ref) = @_;
                     59: 	my %syllabusfields = %{$syllabusfields_ref};
                     60: 	my %syllabus = %{$syllabus_ref};
1.19      neumanie   61: 	
1.5       ehlerst    62:        foreach my $field (sort(keys(%syllabusfields))) {
                     63:           if (($syllabus{$field}) || ($allowed)) {
                     64:               my $message=$syllabus{$field};
                     65:               &Apache::lonfeedback::newline_to_br(\$message);
                     66:               $message
                     67:              =~s/(http\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
                     68:               if ($allowed) {
                     69:                   $message=&Apache::lonspeller::markeduptext($message);
                     70:               }
                     71:               $message=&Apache::lontexconvert::msgtexconverted($message);
                     72:               if ($target ne 'tex') {
1.10      ehlerst    73: 		     if($allowed){
                     74: 			$r->print('<p>');
1.15      neumanie   75: 		     }	   
                     76: 			
                     77: 		    if($field eq 'aaa_contactinfo') {
                     78: 			if($allowed){
1.16      neumanie   79: 				$r->print('<div class="LC_Clear_AboutMe_Image" >&nbsp;</div>');
1.15      neumanie   80: 			}
                     81: 			&print_template($r,$syllabusfields{$field},$message,$allowed,'LC_ContentBoxSpecialContactInfo');
1.16      neumanie   82: 			$r->print('<div class="LC_Clear_AboutMe_Image" >&nbsp;</div>');
1.15      neumanie   83: 		    }
                     84:  		    else{
                     85: 			  &print_template($r,$syllabusfields{$field},$message,$allowed,'LC_ContentBoxSpecial');
                     86: 		    }
                     87: 		  
1.5       ehlerst    88:               } else {
                     89:                      $r->print('\\\\\textbf{'.$syllabusfields{$field}.'}\\\\'.
                     90:                                &Apache::lonxml::xmlparse($r,'tex',$message).'\\\\');
                     91:               }
                     92:               if ($allowed) {
                     93:                &print_editbox_template($r,$syllabus{$field},$field);
1.10      ehlerst    94: 		if($target ne 'tex'){
                     95: 			$r->print('</p>');
                     96: 		}
1.5       ehlerst    97:               }
                     98:           }
                     99:        }
1.19      neumanie  100: 	
1.5       ehlerst   101: }
1.1       amueller  102: 
1.8       ehlerst   103: sub start_ContentBox{
1.15      neumanie  104: 	my ($r,$allowed) = @_;	
                    105: 	$r->print('<div class="LC_ContentBox">');
                    106: 	
1.8       ehlerst   107: }
                    108: 
                    109: sub end_ContentBox{
                    110: 	my ($r) = @_;
1.7       ehlerst   111: 	$r->print('</div>');
1.8       ehlerst   112: }
                    113: 
                    114: sub send_message{
                    115: 	my ($r,$cnum,$cdom) = @_;
1.17      neumanie  116: 	my $s;
1.19      neumanie  117: 	my $image = qq{<img name="Send message" src="/res/adm/pages/com.png" border="none" />};	
                    118: 	$s=&Apache::loncommon::messagewrapper($image,$cnum,$cdom).' '.&Apache::loncommon::messagewrapper(&mt('Send me a message'),$cnum,$cdom);	
1.23    ! neumanie  119: 	return $s;	
1.8       ehlerst   120: }
1.7       ehlerst   121: 
1.1       amueller  122: sub print_template
                    123: {	
1.23    ! neumanie  124: 	my ($r,$topic,$content, $allowed,$boxclass) = @_;		
1.15      neumanie  125: 	$r->print('<div class="'.$boxclass.'">');	
1.13      harmsja   126: 	$r->print('<h4 class="LC_hcell">'.$topic.'</h4>');
1.18      amueller  127: 	$r->print('<p>' .$content . '</p>');
1.1       amueller  128: 	$r->print('</div>');
                    129: }
1.20      neumanie  130: sub print_start_template
                    131: {
                    132: 	my ($r,$topic,$boxclass) = @_;
                    133: 	$r->print('<div class="'.$boxclass.'">');	
                    134: 	$r->print('<h4 class="LC_hcell">'.$topic.'</h4>');
                    135: }
                    136: sub print_end_template
                    137: {
                    138: 	my ($r) = @_;
                    139: 	$r->print('</div>');
                    140: }
1.1       amueller  141: sub print_editbox_template
                    142: {
                    143: 	my ($r,$content,$field) = @_;
1.10      ehlerst   144: 	$r->print('<textarea cols="81" rows="6" name="'.$field.'">'.
1.1       amueller  145:                            &HTML::Entities::encode($content,'"&<>').
1.15      neumanie  146:            '</textarea><br /><input type="submit" name="storesyl" value="'.
1.4       bisitz    147:                            &mt('Save All').'" />');
1.1       amueller  148: }
1.17      neumanie  149: sub print_start_page_functions
                    150: {
1.19      neumanie  151: 	my($r)=@_;	
1.23    ! neumanie  152: 	$r->print('<fieldset><legend>'. &mt('Functions') . '</legend>');	
1.17      neumanie  153: }
                    154: sub print_functions_content
                    155: {
                    156: 	my($r,$content) = @_;
1.23    ! neumanie  157: 	$r->print('<span class="LC_nobreak">&bull;&nbsp;'.$content.'&nbsp;</span>');	
1.17      neumanie  158: }
                    159: sub print_end_page_functions
                    160: {
                    161: 	my($r)=@_;
                    162: 	$r->print('</fieldset>');
                    163: }
1.1       amueller  164: 1;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>