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

1.2       neumanie    1: # The LearningOnline Network
                      2: # "Template" Functions to generate html output
                      3: #
1.41    ! www         4: # $Id: lontemplate.pm,v 1.40 2009/11/26 05:21:43 faziophi 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: 
1.33      bisitz     47: sub start_columnSection {
1.7       ehlerst    48: 	my ($r) = @_;
1.13      harmsja    49: 	 $r->print('<div class="LC_columnSection">');
1.7       ehlerst    50: }
                     51: 
1.33      bisitz     52: sub end_columnSection {
1.7       ehlerst    53: 	my ($r) = @_;
                     54: 	 $r->print('</div>');
                     55: }
                     56: 
1.33      bisitz     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.28      bisitz     61: 
1.5       ehlerst    62:        foreach my $field (sort(keys(%syllabusfields))) {
                     63:           if (($syllabus{$field}) || ($allowed)) {
                     64:               my $message=$syllabus{$field};
1.40      faziophi   65:               if (!&Apache::lonfeedback::contains_block_html($message)) {
                     66:               	&Apache::lonfeedback::newline_to_br(\$message);
                     67:               }
1.41    ! www        68:               $message=&Apache::lonhtmlcommon::raw_href_to_link($message);
1.5       ehlerst    69:               if ($allowed) {
                     70:                   $message=&Apache::lonspeller::markeduptext($message);
                     71:               }
                     72:               $message=&Apache::lontexconvert::msgtexconverted($message);
                     73:               if ($target ne 'tex') {
1.15      neumanie   74: 		    if($field eq 'aaa_contactinfo') {
1.16      neumanie   75: 				$r->print('<div class="LC_Clear_AboutMe_Image" >&nbsp;</div>');
1.36      bisitz     76: 				&print_template($r,$syllabusfields{$field},$message,$allowed,'LC_Box');
1.33      bisitz     77: 		    } else {
1.36      bisitz     78: 			  &print_template($r,$syllabusfields{$field},$message,$allowed,'LC_Box');
1.15      neumanie   79: 		    }
1.38      amueller   80: 			if($allowed) {
                     81:                &print_editbox_template($r,$syllabus{$field},$field);
                     82: 			}
1.31      bisitz     83: 
1.5       ehlerst    84:               } else {
                     85:                      $r->print('\\\\\textbf{'.$syllabusfields{$field}.'}\\\\'.
                     86:                                &Apache::lonxml::xmlparse($r,'tex',$message).'\\\\');
                     87:               }
                     88:           }
                     89:        }
1.28      bisitz     90: 
1.5       ehlerst    91: }
1.1       amueller   92: 
1.33      bisitz     93: sub send_message {
1.8       ehlerst    94: 	my ($r,$cnum,$cdom) = @_;
1.39      raeburn    95: 	my $linktext = &mt('Send message to [_1]',
                     96: 			   &Apache::loncommon::plainname($cnum,$cdom));
1.38      amueller   97: 	my $image = qq{<img name="Send_message" alt="Send message symbol" src="/res/adm/pages/mail-message-new.png" border="none" align="middle" />};
1.39      raeburn    98: 	return &Apache::loncommon::messagewrapper($image,$cnum,$cdom).' '.&Apache::loncommon::messagewrapper($linktext,$cnum,$cdom);
1.8       ehlerst    99: }
1.7       ehlerst   100: 
1.35      bisitz    101: sub print_template {
1.28      bisitz    102: 	my ($r,$topic,$content, $allowed,$boxclass) = @_;
                    103: 	$r->print('<div class="'.$boxclass.'">');
1.13      harmsja   104: 	$r->print('<h4 class="LC_hcell">'.$topic.'</h4>');
1.35      bisitz    105: 	$r->print($content);
1.1       amueller  106: 	$r->print('</div>');
                    107: }
1.33      bisitz    108: 
1.35      bisitz    109: sub print_start_template {
1.20      neumanie  110: 	my ($r,$topic,$boxclass) = @_;
1.28      bisitz    111: 	$r->print('<div class="'.$boxclass.'">');
1.20      neumanie  112: 	$r->print('<h4 class="LC_hcell">'.$topic.'</h4>');
                    113: }
1.33      bisitz    114: 
1.35      bisitz    115: sub print_end_template {
1.20      neumanie  116: 	my ($r) = @_;
                    117: 	$r->print('</div>');
                    118: }
1.33      bisitz    119: 
1.35      bisitz    120: sub print_editbox_template {
1.1       amueller  121: 	my ($r,$content,$field) = @_;
1.10      ehlerst   122: 	$r->print('<textarea cols="81" rows="6" name="'.$field.'">'.
1.1       amueller  123:                            &HTML::Entities::encode($content,'"&<>').
1.15      neumanie  124:            '</textarea><br /><input type="submit" name="storesyl" value="'.
1.4       bisitz    125:                            &mt('Save All').'" />');
1.1       amueller  126: }
1.27      bisitz    127: 
1.1       amueller  128: 1;

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