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

1.2       neumanie    1: # The LearningOnline Network
                      2: # "Template" Functions to generate html output
                      3: #
1.33    ! bisitz      4: # $Id: lontemplate.pm,v 1.32 2009/05/07 11:12:47 bisitz 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};
                     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.33    ! bisitz     73: 		     if ($allowed) {
1.10      ehlerst    74: 			$r->print('<p>');
1.31      bisitz     75: 		     }
1.28      bisitz     76: 
1.15      neumanie   77: 		    if($field eq 'aaa_contactinfo') {
1.16      neumanie   78: 				$r->print('<div class="LC_Clear_AboutMe_Image" >&nbsp;</div>');
1.25      amueller   79: 				&print_template($r,$syllabusfields{$field},$message,$allowed,'LC_ContentBoxSpecial');
1.33    ! bisitz     80: 		    } else {
1.15      neumanie   81: 			  &print_template($r,$syllabusfields{$field},$message,$allowed,'LC_ContentBoxSpecial');
                     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:               if ($allowed) {
                     89:                &print_editbox_template($r,$syllabus{$field},$field);
1.33    ! bisitz     90: 		if ($target ne 'tex') {
1.10      ehlerst    91: 			$r->print('</p>');
                     92: 		}
1.5       ehlerst    93:               }
                     94:           }
                     95:        }
1.28      bisitz     96: 
1.5       ehlerst    97: }
1.1       amueller   98: 
1.33    ! bisitz     99: sub start_ContentBox {
1.28      bisitz    100: 	my ($r,$allowed) = @_;
1.15      neumanie  101: 	$r->print('<div class="LC_ContentBox">');
1.28      bisitz    102: 
1.8       ehlerst   103: }
                    104: 
1.33    ! bisitz    105: sub end_ContentBox {
1.8       ehlerst   106: 	my ($r) = @_;
1.7       ehlerst   107: 	$r->print('</div>');
1.8       ehlerst   108: }
                    109: 
1.33    ! bisitz    110: sub send_message {
1.8       ehlerst   111: 	my ($r,$cnum,$cdom) = @_;
1.17      neumanie  112: 	my $s;
1.32      bisitz    113: 	my $image = qq{<img name="Send message" src="/res/adm/pages/mail-message-new.png" border="none" align="middle" />};
1.28      bisitz    114: 	$s=&Apache::loncommon::messagewrapper($image,$cnum,$cdom).' '.&Apache::loncommon::messagewrapper(&mt('Send me a message'),$cnum,$cdom);
                    115: 	return $s;
1.8       ehlerst   116: }
1.7       ehlerst   117: 
1.1       amueller  118: sub print_template
1.28      bisitz    119: {
                    120: 	my ($r,$topic,$content, $allowed,$boxclass) = @_;
                    121: 	$r->print('<div class="'.$boxclass.'">');
1.13      harmsja   122: 	$r->print('<h4 class="LC_hcell">'.$topic.'</h4>');
1.30      neumanie  123: 	$r->print('<div class="LC_BoxPadding">' .$content . '</div>');
1.1       amueller  124: 	$r->print('</div>');
                    125: }
1.33    ! bisitz    126: 
1.20      neumanie  127: sub print_start_template
                    128: {
                    129: 	my ($r,$topic,$boxclass) = @_;
1.28      bisitz    130: 	$r->print('<div class="'.$boxclass.'">');
1.20      neumanie  131: 	$r->print('<h4 class="LC_hcell">'.$topic.'</h4>');
1.30      neumanie  132: 	$r->print('<div class="LC_BoxPadding">' );
1.20      neumanie  133: }
1.33    ! bisitz    134: 
1.20      neumanie  135: sub print_end_template
                    136: {
                    137: 	my ($r) = @_;
                    138: 	$r->print('</div>');
1.30      neumanie  139: 	$r->print('</div>');
1.20      neumanie  140: }
1.33    ! bisitz    141: 
1.1       amueller  142: sub print_editbox_template
                    143: {
                    144: 	my ($r,$content,$field) = @_;
1.10      ehlerst   145: 	$r->print('<textarea cols="81" rows="6" name="'.$field.'">'.
1.1       amueller  146:                            &HTML::Entities::encode($content,'"&<>').
1.15      neumanie  147:            '</textarea><br /><input type="submit" name="storesyl" value="'.
1.4       bisitz    148:                            &mt('Save All').'" />');
1.1       amueller  149: }
1.27      bisitz    150: 
                    151: # Functionslist: List of functions
                    152: # Typically used to display a list of available functions at top of page
                    153: sub start_functionslist {
1.29      bisitz    154:     my($legendtext)=@_;
                    155:     $legendtext=&mt('Functions') if !$legendtext;
                    156:     return '<fieldset><legend>'.$legendtext.'</legend>'
                    157:           .'<ul class="LC_functionslist">';
1.17      neumanie  158: }
1.27      bisitz    159: 
                    160: sub item_functionslist {
1.29      bisitz    161:     my($content) = @_;
                    162:     return '<li>'.$content.'</li>';
1.17      neumanie  163: }
1.27      bisitz    164: 
                    165: sub end_functionslist {
1.29      bisitz    166:     my($r)=@_;
                    167:     return '</ul></fieldset>';
1.17      neumanie  168: }
1.27      bisitz    169: 
1.1       amueller  170: 1;

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