Annotation of loncom/interface/lontemplate.pm, revision 1.42
1.2 neumanie 1: # The LearningOnline Network
2: # "Template" Functions to generate html output
3: #
1.42 ! faziophi 4: # $Id: lontemplate.pm,v 1.41 2009/12/03 02:13:28 www 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.42 ! faziophi 46: use constant {
! 47: RICH_TEXT_ALWAYS_ON => 'LC_richAlwaysOn',
! 48: RICH_TEXT_ALWAYS_OFF => 'LC_richAlwaysOff',
! 49: RICH_TEXT_DEFAULT_ON => 'LC_richDefaultOn',
! 50: RICH_TEXT_DETECT_HTML => 'LC_richDetectHtml',
! 51: RICH_TEXT_DEFAULT_OFF => 'LC_richDefaultOff'
! 52: };
1.7 ehlerst 53:
1.33 bisitz 54: sub start_columnSection {
1.7 ehlerst 55: my ($r) = @_;
1.13 harmsja 56: $r->print('<div class="LC_columnSection">');
1.7 ehlerst 57: }
58:
1.33 bisitz 59: sub end_columnSection {
1.7 ehlerst 60: my ($r) = @_;
61: $r->print('</div>');
62: }
63:
1.33 bisitz 64: sub print_aboutme_content_template {
1.5 ehlerst 65: my ($r,$allowed,$target,$syllabusfields_ref,$syllabus_ref) = @_;
66: my %syllabusfields = %{$syllabusfields_ref};
67: my %syllabus = %{$syllabus_ref};
1.28 bisitz 68:
1.5 ehlerst 69: foreach my $field (sort(keys(%syllabusfields))) {
70: if (($syllabus{$field}) || ($allowed)) {
71: my $message=$syllabus{$field};
1.40 faziophi 72: if (!&Apache::lonfeedback::contains_block_html($message)) {
73: &Apache::lonfeedback::newline_to_br(\$message);
74: }
1.41 www 75: $message=&Apache::lonhtmlcommon::raw_href_to_link($message);
1.5 ehlerst 76: if ($allowed) {
77: $message=&Apache::lonspeller::markeduptext($message);
78: }
79: $message=&Apache::lontexconvert::msgtexconverted($message);
80: if ($target ne 'tex') {
1.15 neumanie 81: if($field eq 'aaa_contactinfo') {
1.16 neumanie 82: $r->print('<div class="LC_Clear_AboutMe_Image" > </div>');
1.36 bisitz 83: &print_template($r,$syllabusfields{$field},$message,$allowed,'LC_Box');
1.33 bisitz 84: } else {
1.36 bisitz 85: &print_template($r,$syllabusfields{$field},$message,$allowed,'LC_Box');
1.15 neumanie 86: }
1.38 amueller 87: if($allowed) {
88: &print_editbox_template($r,$syllabus{$field},$field);
89: }
1.31 bisitz 90:
1.5 ehlerst 91: } else {
92: $r->print('\\\\\textbf{'.$syllabusfields{$field}.'}\\\\'.
93: &Apache::lonxml::xmlparse($r,'tex',$message).'\\\\');
94: }
95: }
96: }
1.28 bisitz 97:
1.5 ehlerst 98: }
1.1 amueller 99:
1.33 bisitz 100: sub send_message {
1.8 ehlerst 101: my ($r,$cnum,$cdom) = @_;
1.39 raeburn 102: my $linktext = &mt('Send message to [_1]',
103: &Apache::loncommon::plainname($cnum,$cdom));
1.38 amueller 104: 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 105: return &Apache::loncommon::messagewrapper($image,$cnum,$cdom).' '.&Apache::loncommon::messagewrapper($linktext,$cnum,$cdom);
1.8 ehlerst 106: }
1.7 ehlerst 107:
1.35 bisitz 108: sub print_template {
1.28 bisitz 109: my ($r,$topic,$content, $allowed,$boxclass) = @_;
110: $r->print('<div class="'.$boxclass.'">');
1.13 harmsja 111: $r->print('<h4 class="LC_hcell">'.$topic.'</h4>');
1.35 bisitz 112: $r->print($content);
1.1 amueller 113: $r->print('</div>');
114: }
1.33 bisitz 115:
1.35 bisitz 116: sub print_start_template {
1.20 neumanie 117: my ($r,$topic,$boxclass) = @_;
1.28 bisitz 118: $r->print('<div class="'.$boxclass.'">');
1.20 neumanie 119: $r->print('<h4 class="LC_hcell">'.$topic.'</h4>');
120: }
1.33 bisitz 121:
1.35 bisitz 122: sub print_end_template {
1.20 neumanie 123: my ($r) = @_;
124: $r->print('</div>');
125: }
1.33 bisitz 126:
1.35 bisitz 127: sub print_editbox_template {
1.1 amueller 128: my ($r,$content,$field) = @_;
1.10 ehlerst 129: $r->print('<textarea cols="81" rows="6" name="'.$field.'">'.
1.1 amueller 130: &HTML::Entities::encode($content,'"&<>').
1.15 neumanie 131: '</textarea><br /><input type="submit" name="storesyl" value="'.
1.4 bisitz 132: &mt('Save All').'" />');
1.1 amueller 133: }
1.27 bisitz 134:
1.42 ! faziophi 135: sub print_textarea_template {
! 136: my ($r, $content, $field, $wysiwyg) = @_;
! 137: $r->print('<textarea cols="81" rows="6" class="'.$wysiwyg.'" id="'.$field.'" name="'.$field.'">'.
! 138: &HTML::Entities::encode($content, '"&<>').
! 139: '</textarea><br />');
! 140: }
! 141:
! 142: sub print_saveall_template {
! 143: my ($r) = @_;
! 144: $r->print('<input type="submit" name="storesyl" value="'.&mt('Save All').'" />');
! 145: }
! 146:
1.1 amueller 147: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>