File:
[LON-CAPA] /
loncom /
interface /
lontemplate.pm
Revision
1.40:
download - view:
text,
annotated -
select for diffs
Thu Nov 26 05:21:43 2009 UTC (14 years, 8 months ago) by
faziophi
Branches:
MAIN
CVS tags:
HEAD
Adds check before calling lonfeedback::newline_to_br to see if
the text contains block-level HTML elements (such as <table> or <p> or <br />).
If HTML is detected, newlines will no longer be automatically converted
to <br /> tags -- this resolves bugs such as 5550, where for
example, inserting a table using the WYSIWYG editor causes
erroneous break tags to be created.
1: # The LearningOnline Network
2: # "Template" Functions to generate html output
3: #
4: # $Id: lontemplate.pm,v 1.40 2009/11/26 05:21:43 faziophi Exp $
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:
30: package Apache::lontemplate;
31:
32:
33: use strict;
34: use Apache::Constants qw(:common);
35: use Apache::loncommon;
36: use Apache::lonnet;
37: use Apache::lonxml;
38: use Apache::lonspeller;
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:
46:
47: sub start_columnSection {
48: my ($r) = @_;
49: $r->print('<div class="LC_columnSection">');
50: }
51:
52: sub end_columnSection {
53: my ($r) = @_;
54: $r->print('</div>');
55: }
56:
57: sub print_aboutme_content_template {
58: my ($r,$allowed,$target,$syllabusfields_ref,$syllabus_ref) = @_;
59: my %syllabusfields = %{$syllabusfields_ref};
60: my %syllabus = %{$syllabus_ref};
61:
62: foreach my $field (sort(keys(%syllabusfields))) {
63: if (($syllabus{$field}) || ($allowed)) {
64: my $message=$syllabus{$field};
65: if (!&Apache::lonfeedback::contains_block_html($message)) {
66: &Apache::lonfeedback::newline_to_br(\$message);
67: }
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: if($field eq 'aaa_contactinfo') {
76: $r->print('<div class="LC_Clear_AboutMe_Image" > </div>');
77: &print_template($r,$syllabusfields{$field},$message,$allowed,'LC_Box');
78: } else {
79: &print_template($r,$syllabusfields{$field},$message,$allowed,'LC_Box');
80: }
81: if($allowed) {
82: &print_editbox_template($r,$syllabus{$field},$field);
83: }
84:
85: } else {
86: $r->print('\\\\\textbf{'.$syllabusfields{$field}.'}\\\\'.
87: &Apache::lonxml::xmlparse($r,'tex',$message).'\\\\');
88: }
89: }
90: }
91:
92: }
93:
94: sub send_message {
95: my ($r,$cnum,$cdom) = @_;
96: my $linktext = &mt('Send message to [_1]',
97: &Apache::loncommon::plainname($cnum,$cdom));
98: my $image = qq{<img name="Send_message" alt="Send message symbol" src="/res/adm/pages/mail-message-new.png" border="none" align="middle" />};
99: return &Apache::loncommon::messagewrapper($image,$cnum,$cdom).' '.&Apache::loncommon::messagewrapper($linktext,$cnum,$cdom);
100: }
101:
102: sub print_template {
103: my ($r,$topic,$content, $allowed,$boxclass) = @_;
104: $r->print('<div class="'.$boxclass.'">');
105: $r->print('<h4 class="LC_hcell">'.$topic.'</h4>');
106: $r->print($content);
107: $r->print('</div>');
108: }
109:
110: sub print_start_template {
111: my ($r,$topic,$boxclass) = @_;
112: $r->print('<div class="'.$boxclass.'">');
113: $r->print('<h4 class="LC_hcell">'.$topic.'</h4>');
114: }
115:
116: sub print_end_template {
117: my ($r) = @_;
118: $r->print('</div>');
119: }
120:
121: sub print_editbox_template {
122: my ($r,$content,$field) = @_;
123: $r->print('<textarea cols="81" rows="6" name="'.$field.'">'.
124: &HTML::Entities::encode($content,'"&<>').
125: '</textarea><br /><input type="submit" name="storesyl" value="'.
126: &mt('Save All').'" />');
127: }
128:
129: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>