File:  [LON-CAPA] / loncom / interface / lontemplate.pm
Revision 1.8: download - view: text, annotated - select for diffs
Wed Dec 10 15:58:36 2008 UTC (15 years, 5 months ago) by ehlerst
Branches: MAIN
CVS tags: HEAD
removed an unnecessary function in lontemplate.pm and added a function for sending a message. layout changes in lonaboutme.pm.

    1: # The LearningOnline Network
    2: # "Template" Functions to generate html output
    3: #
    4: # $Id: lontemplate.pm,v 1.8 2008/12/10 15:58:36 ehlerst 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="columnSection">');
   50: }
   51: 
   52: sub end_columnSection{
   53: 	my ($r) = @_;
   54: 	 $r->print('</div>');
   55: }
   56: 
   57: sub print_content_template{
   58: 	my ($r,$allowed,$target,$syllabusfields_ref,$syllabus_ref) = @_;
   59: 	my %syllabusfields = %{$syllabusfields_ref};
   60: 	my %syllabus = %{$syllabus_ref};
   61: 	$r->print('<div class="ContentBox">');
   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') {
   73:                                 
   74:                &print_template($r,$syllabusfields{$field},$message);
   75:                                 
   76:                                 
   77:                                 
   78:               } else {
   79:                      $r->print('\\\\\textbf{'.$syllabusfields{$field}.'}\\\\'.
   80:                                &Apache::lonxml::xmlparse($r,'tex',$message).'\\\\');
   81:               }
   82:               if ($allowed) {
   83:                &print_editbox_template($r,$syllabus{$field},$field);
   84:               }
   85:           }
   86:        }
   87: 		$r->print('</div>');
   88: }
   89: 
   90: sub start_ContentBox{
   91: 	my ($r) = @_;
   92: 	$r->print('<div class="ContentBox">');
   93: }
   94: 
   95: sub end_ContentBox{
   96: 	my ($r) = @_;
   97: 	$r->print('</div>');
   98: }
   99: 
  100: sub send_message{
  101: 	my ($r,$cnum,$cdom) = @_;
  102: 	$r->print('<div class="ContentBoxSpecial">');
  103: 	$r->print('<h4 class="hcell">'.&mt('Contact').'</h4>');
  104:         $r->print('<blockquote>'.(&Apache::loncommon::messagewrapper(&mt('Send me a message'),$cnum,$cdom)).'</blockquote>');
  105:         $r->print('</div>');
  106: }
  107: 
  108: sub print_template
  109: {	
  110: 	my ($r,$topic,$content) = @_;
  111: 	$r->print('<div class="ContentBoxSpecial">');
  112: 	$r->print('<h4 class="hcell">'.$topic.'</h4>');
  113: 	$r->print('<blockquote>'.$content.'</blockquote>');
  114: 	$r->print('</div>');
  115: }
  116: 
  117: sub print_editbox_template
  118: {
  119: 	my ($r,$content,$field) = @_;
  120: 	$r->print('<br /><textarea cols="53" rows="6" name="'.$field.'">'.
  121:                            &HTML::Entities::encode($content,'"&<>').
  122:            '</textarea><input type="submit" name="storesyl" value="'.
  123:                            &mt('Save All').'" />');
  124: }
  125: 
  126: 1;

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