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

1.2       neumanie    1: # The LearningOnline Network
                      2: # "Template" Functions to generate html output
                      3: #
1.7     ! ehlerst     4: # $Id: lontemplate.pm,v 1.6 2008/12/02 23:41:00 harmsja 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) = @_;
        !            49: 	 $r->print('<div class="columnSection">');
        !            50: }
        !            51: 
        !            52: sub end_columnSection{
        !            53: 	my ($r) = @_;
        !            54: 	 $r->print('</div>');
        !            55: }
        !            56: 
1.5       ehlerst    57: sub print_content_template{
                     58: 	my ($r,$allowed,$target,$syllabusfields_ref,$syllabus_ref) = @_;
                     59: 	my %syllabusfields = %{$syllabusfields_ref};
                     60: 	my %syllabus = %{$syllabus_ref};
1.7     ! ehlerst    61: #	if(!$allowed){
        !            62: 		$r->print('<div class="ContentBox">');
        !            63: #	}
1.5       ehlerst    64:        foreach my $field (sort(keys(%syllabusfields))) {
                     65:           if (($syllabus{$field}) || ($allowed)) {
                     66:               my $message=$syllabus{$field};
                     67:               &Apache::lonfeedback::newline_to_br(\$message);
                     68:               $message
                     69:              =~s/(http\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
                     70:               if ($allowed) {
                     71:                   $message=&Apache::lonspeller::markeduptext($message);
                     72:               }
                     73:               $message=&Apache::lontexconvert::msgtexconverted($message);
                     74:               if ($target ne 'tex') {
                     75:                                 
                     76:                &print_template($r,$syllabusfields{$field},$message);
                     77:                                 
                     78:                                 
                     79:                                 
                     80:               } else {
                     81:                      $r->print('\\\\\textbf{'.$syllabusfields{$field}.'}\\\\'.
                     82:                                &Apache::lonxml::xmlparse($r,'tex',$message).'\\\\');
                     83:               }
                     84:               if ($allowed) {
                     85:                &print_editbox_template($r,$syllabus{$field},$field);
                     86:               }
                     87:           }
                     88:        }
1.7     ! ehlerst    89: #	if(!$allowed){
        !            90: 		$r->print('</div>');
        !            91: #	}
1.5       ehlerst    92: }
1.1       amueller   93: 
1.7     ! ehlerst    94: sub print_image {
        !            95: 	my ($r,$image) = @_;
        !            96: 	$r->print('<div class="ContentBox">');
        !            97: 	$r->print($image);
        !            98: 	$r->print('</div>');
        !            99: }	
        !           100: 
1.1       amueller  101: sub print_template
                    102: {	
                    103: 	my ($r,$topic,$content) = @_;
1.5       ehlerst   104: 	$r->print('<div class="ContentBoxSpecial">');
1.1       amueller  105: 	$r->print('<h4 class="hcell">'.$topic.'</h4>');
1.6       harmsja   106: 	$r->print('<blockquote>'.$content.'</blockquote>');
1.1       amueller  107: 	$r->print('</div>');
                    108: }
                    109: 
                    110: sub print_editbox_template
                    111: {
                    112: 	my ($r,$content,$field) = @_;
1.7     ! ehlerst   113: 	$r->print('<br /><textarea cols="55" rows="6" name="'.$field.'">'.
1.1       amueller  114:                            &HTML::Entities::encode($content,'"&<>').
                    115:            '</textarea><input type="submit" name="storesyl" value="'.
1.4       bisitz    116:                            &mt('Save All').'" />');
1.1       amueller  117: }
                    118: 
                    119: 1;

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