File:  [LON-CAPA] / loncom / interface / lontemplate.pm
Revision 1.27: download - view: text, annotated - select for diffs
Fri Mar 27 13:50:36 2009 UTC (15 years, 2 months ago) by bisitz
Branches: MAIN
CVS tags: HEAD
Optimized names for sub routines which create functionslists:
- Standarized/more consistent compared to exisiting routine names (e.g., start_data_table)
- Betting fitting with regard to routine's functionality
- No misunderstood connection to start_page routine anymore

    1: # The LearningOnline Network
    2: # "Template" Functions to generate html output
    3: #
    4: # $Id: lontemplate.pm,v 1.27 2009/03/27 13:50:36 bisitz 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:               &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: 		     if($allowed){
   74: 			$r->print('<p>');
   75: 		     }	   
   76: 			
   77: 		    if($field eq 'aaa_contactinfo') {
   78: 				$r->print('<div class="LC_Clear_AboutMe_Image" >&nbsp;</div>');
   79: 				&print_template($r,$syllabusfields{$field},$message,$allowed,'LC_ContentBoxSpecial');
   80: 		    }
   81:  		    else{
   82: 			  &print_template($r,$syllabusfields{$field},$message,$allowed,'LC_ContentBoxSpecial');
   83: 		    }
   84: 		  
   85:               } else {
   86:                      $r->print('\\\\\textbf{'.$syllabusfields{$field}.'}\\\\'.
   87:                                &Apache::lonxml::xmlparse($r,'tex',$message).'\\\\');
   88:               }
   89:               if ($allowed) {
   90:                &print_editbox_template($r,$syllabus{$field},$field);
   91: 		if($target ne 'tex'){
   92: 			$r->print('</p>');
   93: 		}
   94:               }
   95:           }
   96:        }
   97: 	
   98: }
   99: 
  100: sub start_ContentBox{
  101: 	my ($r,$allowed) = @_;	
  102: 	$r->print('<div class="LC_ContentBox">');
  103: 	
  104: }
  105: 
  106: sub end_ContentBox{
  107: 	my ($r) = @_;
  108: 	$r->print('</div>');
  109: }
  110: 
  111: sub send_message{
  112: 	my ($r,$cnum,$cdom) = @_;
  113: 	my $s;
  114: 	my $image = qq{<img name="Send message" src="/res/adm/pages/com.png" border="none" align="middle" />};	
  115: 	$s=&Apache::loncommon::messagewrapper($image,$cnum,$cdom).' '.&Apache::loncommon::messagewrapper(&mt('Send me a message'),$cnum,$cdom);	
  116: 	return $s;	
  117: }
  118: 
  119: sub print_template
  120: {	
  121: 	my ($r,$topic,$content, $allowed,$boxclass) = @_;		
  122: 	$r->print('<div class="'.$boxclass.'">');	
  123: 	$r->print('<h4 class="LC_hcell">'.$topic.'</h4>');
  124: 	$r->print('<p>' .$content . '</p>');
  125: 	$r->print('</div>');
  126: }
  127: sub print_start_template
  128: {
  129: 	my ($r,$topic,$boxclass) = @_;
  130: 	$r->print('<div class="'.$boxclass.'">');	
  131: 	$r->print('<h4 class="LC_hcell">'.$topic.'</h4>');
  132: }
  133: sub print_end_template
  134: {
  135: 	my ($r) = @_;
  136: 	$r->print('</div>');
  137: }
  138: sub print_editbox_template
  139: {
  140: 	my ($r,$content,$field) = @_;
  141: 	$r->print('<textarea cols="81" rows="6" name="'.$field.'">'.
  142:                            &HTML::Entities::encode($content,'"&<>').
  143:            '</textarea><br /><input type="submit" name="storesyl" value="'.
  144:                            &mt('Save All').'" />');
  145: }
  146: 
  147: # Functionslist: List of functions
  148: # Typically used to display a list of available functions at top of page
  149: sub start_functionslist {
  150: 	my($r)=@_;	
  151: 	$r->print('<fieldset><legend>'. &mt('Functions') . '</legend>');	
  152: 	$r->print('<ul class="LC_functionslist">');	
  153: }
  154: 
  155: sub item_functionslist {
  156: 	my($r,$content) = @_;
  157: 	$r->print('<li>'.$content.'</li>');	
  158: }
  159: 
  160: sub end_functionslist {
  161: 	my($r)=@_;
  162: 	$r->print('</ul></fieldset>');
  163: }
  164: 
  165: 1;

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