File:  [LON-CAPA] / loncom / interface / lonsyllabus.pm
Revision 1.106.2.5: download - view: text, annotated - select for diffs
Wed Feb 17 18:42:38 2010 UTC (14 years, 4 months ago) by faziophi
Branches: bz6209
Diff to branchpoint 1.106: preferred, unified
Work-in-progress commit on bug 6209.

--> New (still non-functional) contextual section bar and section title bar
--> Disable "Enable/Disable WYSIWYG" link
--> Hide unnecessary fields in .LC_Box'es temporarily for display purposes
--> No longer preview content above edit box
    --> This will eventually be replaced by a "Preview" button which
        will generate a processed copy of the field via an AJAX request.
--> No longer print "Save all", "Delete", etc. fields beneath edit box,
    because I am masochistic and wanted to get rid of the only part
    of the interface that actually works as advertised right now.

STILL NOT TOUCHED:
-- same as last commit

New pretty screenshot attached on Bugzilla.

    1: # The LearningOnline Network
    2: # Syllabus
    3: #
    4: # $Id: lonsyllabus.pm,v 1.106.2.5 2010/02/17 18:42:38 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: package Apache::lonsyllabus;
   30: 
   31: use strict;
   32: use Apache::lontemplate;
   33: use Apache::Constants qw(:common);
   34: use Apache::loncommon;
   35: use Apache::lonnet;
   36: use Apache::lontexconvert;
   37: use Apache::lonfeedback;
   38: use Apache::lonannounce;
   39: use Apache::lonlocal;
   40: use Apache::lonhtmlcommon;
   41: use Apache::lonspeller();
   42: use HTML::Entities();
   43: use Digest::MD5 qw(md5_hex);
   44: use Storable qw(freeze thaw);
   45: 
   46: # These are strings representing types of fields
   47: # that will used to parse/display a field correctly
   48: use constant {
   49: 	TYPE_TEXT_HTML => 'html',  #<-- default
   50: 	TYPE_TEXT_PLAIN => 'text',
   51: 	TYPE_URL_INCLUDE => 'include-url',
   52: };
   53: 
   54: sub handler {
   55:     my $r = shift;
   56:     &Apache::loncommon::content_type($r,'text/html');
   57:     $r->send_http_header;
   58:     return OK if $r->header_only;
   59: 
   60:     my $target=$env{'form.grade_target'};
   61: # --------------------------------------------------- Get course info from URL
   62:     my (undef,undef,$cdom,$cnum)=split(/\//,$r->uri);
   63: # ------------------------------------------------------------ Get query string
   64:     &Apache::loncommon::get_unprocessed_cgi
   65:                         ($ENV{'QUERY_STRING'},['delete', 'rename', 'field', 'forcestudent','register','forceedit','forceflush','wrapperdisplay']);
   66: # ----------------------------------------------------- Is this even a course?
   67:     my $homeserver=&Apache::lonnet::homeserver($cnum,$cdom);
   68:     if ($homeserver eq 'no_host') {
   69:         &Apache::loncommon::content_type($r,'text/html');
   70:         $r->send_http_header;
   71:         &Apache::loncommon::simple_error_page($r,'No syllabus available',
   72:                           'No syllabus available');
   73:         return OK;
   74:     }
   75: # ------------------------------------- There is such a course, get environment
   76:     my %courseenv=&Apache::lonnet::dump('environment',$cdom,$cnum);
   77: 
   78: # ------------------------------------------------------------ Print the screen
   79:     if ($target eq 'tex') {
   80:         $r->print(&Apache::lonprintout::print_latex_header($env{'form.latex_type'}));
   81:     }
   82:     
   83: # -------------------------------------------------- Let's see who handles this
   84:     my $externalsyllabus=$courseenv{'externalsyllabus'};
   85:     if ($externalsyllabus=~/\w/) {
   86:        if ($env{'form.wrapperdisplay'} eq 'menu') {
   87:            $r->print(&Apache::lonwrapper::simple_menu());
   88:        } else {
   89:            $r->print(&Apache::lonwrapper::wrapper("/public/$cdom/$cnum/syllabus?wrapperdisplay=menu",
   90:                            $externalsyllabus));
   91:        }
   92:        return OK;
   93:     }
   94: 
   95: # --------------------------------------------------------- The old syllabus fields
   96:     my %syllabusfields=&Apache::lonlocal::texthash(
   97:        'aaa_instructorinfo' => 'Instructor Information',
   98:        'bbb_description'    => 'Course Description',
   99:        'ccc_prereq'         => 'Prerequisites',
  100:        'cdc_classhours'     => 'Class Hours',
  101:        'ddd_officehours'    => 'Office Hours',
  102:        'eee_helproom'       => 'Helproom Hours',
  103:        'efe_projectinfo'    => 'Project Information',
  104:        'fff_examinfo'       => 'Exam Information',
  105:        'fgf_deadlines'      => 'Deadlines',
  106:        'ggg_grading'        => 'Grading Information',
  107:        'hhh_readings'       => 'Readings',
  108:        'iii_coursepack'     => 'Coursepack',
  109:        'jjj_weblinks'       => 'Web Links',
  110:        'kkk_textbook'       => 'Textbook',
  111:        'lll_includeurl'     => 'URLs To Include in Syllabus');
  112:        
  113: # --------------------------------------------------------------- Force Student
  114:     my $forcestudent='';
  115:     if ($env{'form.forcestudent'}) { $forcestudent='student'; };
  116:     my $forceedit='';
  117:     if ($env{'form.forceedit'}) { $forceedit='edit'; }
  118: 
  119: # ----------------------------------------------------------------- Make header
  120:     if ($target ne 'tex') {
  121:         my $rss_link = &Apache::lonrss::rss_link($cnum,$cdom);
  122:         my $js;
  123:         if ($env{'form.backto'} eq 'coursecatalog') {
  124:             $js .= <<"ENDSCRIPT";
  125: 
  126: <script type="text/javascript">
  127: function ToCatalog(caller) {
  128:     numidx = getIndexByName('coursenum');
  129:         if (numidx > -1) {
  130:             if (caller != 'details') {
  131:                 document.backtocat.elements[numidx].value = '';
  132:             }
  133:         }
  134:     document.backtocat.submit();
  135: }
  136: 
  137: function getIndexByName(item) {
  138:     for (var i=0;i<document.backtocat.elements.length;i++) {
  139:         if (document.backtocat.elements[i].name == item) {
  140:             return i;
  141:         }
  142:     }
  143:     return -1;
  144: }
  145: 
  146: </script>
  147: 
  148: ENDSCRIPT
  149:         }
  150:         $js .= <<'ENDSCRIPT';
  151: 
  152: <style type="text/css">
  153: 	.LC_Sortable ul { list-style-type: none; margin: 0px; padding: 0px}
  154: 	.LC_Sortable li { list-style-type: none; cursor: pointer; margin: 0px 5px 5px 5px; padding: 5px; padding-left: 1.5em; width: 200px; font-size:90% }
  155: 	.LC_Sortable li span.left { float: left; cursor: move; margin-left: -1.5em; }
  156: 	.LC_Sortable li span.right { float: right; cursor: auto; margin-right: 0em }
  157: 	.LC_EllipseOverflow { overflow: hidden; text-overflow: ellipsis; -o-text-overflow: ellipsis; white-space: nowrap; }
  158: 	.LC_ActivityBarButton-IconLeft { padding-left: 20px }
  159: 	.LC_ActivityBarButton-IconLeft .ui-icon { float:left; margin-left: -18px; }
  160: 	#scrollable-fields-container {float:left; background-color: white; width: 235px; border: 1px solid grey; margin: 0px; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px;}
  161: 	#syllabus-fields-actions {text-align: center}
  162: 	#syllabus-content {-moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; margin: -6px 0 0 239px; position: relative; z-index: 2; padding: 9px 5px 5px 5px; background-color: #fafafa; border:solid 1px grey}
  163: 	#activity-bar {-moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; border: solid 1px grey; background-color: #dddddd; padding: 0px 0px;margin: 5px 0 2px 0;}	
  164: 	#activity-bar button { font-size: 100%; vertical-align: middle }
  165: 	#context-bar {z-index: 4; position: relative; -moz-border-bottom-left-radius: 4px; -webkit-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; -moz-border-bottom-right-radius: 4px; -webkit-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; border: solid 1px grey; background-color: #eeeeee; padding: 0px 0px;margin:-1px 0 0px 239px;}
  166: 	#title-bar {-moz-border-top-left-radius: 4px; -webkit-border-top-left-radius: 4px; border-top-left-radius: 4px; -moz-border-top-right-radius: 4px; -webkit-border-top-right-radius: 4px; border-top-right-radius: 4px; border: solid 1px grey; background-color: #eaeaea; padding: 0px 0px;margin: 2px 0 0 239px}
  167: 	#title-bar img {vertical-align: middle} 
  168: 	#title-bar button {vertical-align: middle}
  169: 	#title-bar h4 {padding:0px}
  170: 	#section-type-button {padding: 2px;margin-left:2px;}
  171: </style>
  172: 
  173: <script type="text/javascript">
  174: 	// public domain code to emulate text-overflow:ellipsis in Firefox using jQuery
  175: 	(function($) {
  176: 		$.fn.ellipsis = function(enableUpdating){
  177: 			var s = document.documentElement.style;
  178: 			if (!('textOverflow' in s || 'OTextOverflow' in s)) {
  179: 				return this.each(function(){
  180: 					var el = $(this);
  181: 					if(el.css("overflow") == "hidden"){
  182: 						var originalText = el.html();
  183: 						var w = el.width();
  184: 						
  185: 						var t = $(this.cloneNode(true)).hide().css({
  186: 							'position': 'absolute',
  187: 							'width': 'auto',
  188: 							'overflow': 'visible',
  189: 							'max-width': 'inherit'
  190: 						});
  191: 						el.after(t);
  192: 						
  193: 						var text = originalText;
  194: 						while(text.length > 0 && t.width() > el.width()){
  195: 							text = text.substr(0, text.length - 1);
  196: 							t.html(text + "...");
  197: 						}
  198: 						el.html(t.html());
  199: 						
  200: 						t.remove();
  201: 						
  202: 						if(enableUpdating == true){
  203: 							var oldW = el.width();
  204: 							setInterval(function(){
  205: 								if(el.width() != oldW){
  206: 									oldW = el.width();
  207: 									el.html(originalText);
  208: 									el.ellipsis();
  209: 								}
  210: 							}, 200);
  211: 						}
  212: 					}
  213: 				});
  214: 			} else return this;
  215: 		};
  216: 	})(jQuery);
  217: 	
  218: 	var changesMade = false;
  219: 	var changesBreakVersion = false;
  220: 	
  221: 	jQuery(document).ready(function() {
  222: 		jQuery('.LC_EllipseOverflow').ellipsis();
  223: 		jQuery('#syllabus-fields li').click(function() {
  224: 			jQuery(this).parent().children('li').removeClass('ui-state-highlight');
  225: 			jQuery(this).addClass('ui-state-highlight');
  226: 			var id = /title-([0-9_]+)/i.exec(jQuery(this).attr('id'));
  227: 			jQuery('#syllabus-form .LC_Box').hide();
  228: 			jQuery('#box-'+id[1]).show();
  229: 			// START TEMPORARY CODE FOR DEMO'S SAKE
  230: 			jQuery('#syllabus-form .LC_hcell').hide();
  231: 			jQuery('#section-title-text').html(
  232: 				jQuery('#box-'+id[1]).find('.LC_hcell').html()
  233: 			); 
  234: 			// END TEMPORARY CODE
  235: 		});
  236: 		jQuery('#syllabus-fields').sortable({
  237: 			revert: true,
  238: 			axis: 'y',
  239: 			cursor: 'move',
  240: 			placeholder: 'ui-state-highlight',
  241: 			handle: 'span.ui-icon-arrowthick-2-n-s',
  242: 			forcePlaceholderSize: true,
  243: 			start: function(event, ui) {
  244: 				jQuery(ui.item).css('font-style', 'italic');
  245: 			},
  246: 			stop: function(event, ui) {
  247: 				var order = [];
  248: 				jQuery(ui.item).parent().children('li').each(function() {
  249: 					var id = /title-([0-9_]+)/i.exec(jQuery(this).attr('id'));
  250: 					order.push(id[1]);
  251: 				});
  252: 				if (!changesMade) {
  253: 					changesMade = true;
  254: 					$('#save-button').addClass('ui-state-highlight');
  255: 					$('#save-button').removeClass('ui-state-disabled');
  256: 				}
  257: 			}
  258: 		});
  259: 		jQuery('#syllabus-fields li').disableSelection();
  260: 		jQuery('.RemoveSection').hide();
  261: 		jQuery('#syllabus-fields li').hover(
  262: 			function(){
  263: 				jQuery(this).find('.RemoveSection').toggle();
  264: 			},
  265: 			function(){
  266: 				jQuery(this).find('.RemoveSection').toggle();
  267: 			}
  268: 		);
  269: 		jQuery('#syllabus-fields li span.right').hover(
  270: 			function(){
  271: 				jQuery(this).css('background-image', 'url("/adm/jQuery/css/smoothness/images/ui-icons_2e83ff_256x240.png")');
  272: 			},
  273: 			function(){
  274: 				jQuery(this).css('background-image', 'url("/adm/jQuery/css/smoothness/images/ui-icons_454545_256x240.png")');
  275: 			}
  276: 		);
  277: 		jQuery('#syllabus-form .LC_Box').hide();
  278: 		jQuery('.LC_ActivityBarButton').hover(
  279: 			function(){ 
  280: 				$(this).addClass("ui-state-hover"); 
  281: 			},
  282: 			function(){ 
  283: 				$(this).removeClass("ui-state-hover"); 
  284: 			}
  285: 		);
  286: 	});
  287: </script>
  288: ENDSCRIPT
  289:         my $start_page =
  290:          &Apache::loncommon::start_page("Syllabus", $rss_link.$js,
  291:                        {'function'       => undef,
  292:                         'domain'         => $cdom,
  293:                         'force_register' =>
  294:                         $env{'form.register'},});
  295: 
  296:         $r->print($start_page);
  297:         if ($env{'form.backto'} eq 'coursecatalog') {
  298:             &Apache::lonhtmlcommon::clear_breadcrumbs();
  299:             &Apache::lonhtmlcommon::add_breadcrumb
  300:                 ({href=>"javascript:ToCatalog()",
  301:                 text=>"Course/Community Catalog"});
  302:             if ($env{'form.coursenum'} ne '') {
  303:                 &Apache::lonhtmlcommon::add_breadcrumb
  304:                     ({href=>"javascript:ToCatalog('details')",
  305:                     text=>"Course details"});
  306:             }
  307:             &Apache::lonhtmlcommon::add_breadcrumb
  308:                 ({href=>$r->uri,
  309:                 text=>"Course syllabus"});
  310:             $r->print(&Apache::lonhtmlcommon::breadcrumbs());
  311:         }
  312:     }
  313: # ---------------------------------------------------------- Load syllabus info
  314:     my %syllabus=&Apache::lonnet::dump('syllabus',$cdom,$cnum);  # load db
  315:     my $allowed=0;  # can we edit this page?
  316:     my $privileged=0;
  317:     my %data;
  318:     if ($env{'form.forceflush'}) {
  319:     	delete $syllabus{'data.fields'};
  320:     	&Apache::lonnet::del('syllabus', ['data.fields'], $cdom, $cnum);
  321:     	delete $syllabus{'properties.v2_conflict'};
  322:     	&Apache::lonnet::del('syllabus', ['properties.v2_conflict'], $cdom, $cnum);
  323:     	delete $syllabus{'properties.v2_conflict_fail'};
  324:     	&Apache::lonnet::del('syllabus', ['properties.v2_conflict_fail'], $cdom, $cnum);
  325:     	delete $syllabus{'properties.last_modified'};
  326:     	&Apache::lonnet::del('syllabus', ['properties.last_modified'], $cdom, $cnum);
  327:     	delete $syllabus{'properties.v2_converted'};
  328:     	&Apache::lonnet::del('syllabus', ['properties.v2_converted'], $cdom, $cnum);
  329:     	delete $syllabus{'data.old_new_map'};
  330:     	&Apache::lonnet::del('syllabus', ['data.old_new_map'], $cdom, $cnum);
  331:     	delete $syllabus{'data.deleted_fields'};
  332:     	&Apache::lonnet::del('syllabus', ['data.deleted_fields'], $cdom, $cnum);
  333: 		%syllabus=&Apache::lonnet::dump('syllabus',$cdom,$cnum);  # load db
  334:     	$r->print("Flushed syllabus DB file.<br />");
  335:     	$r->print("Syllabus conflict: ".$syllabus{'properties.v2_conflict'}."<br />");
  336:    	}
  337:    	#$r->print("Existing fields: ".$syllabus{'data.fields'}."<br />");
  338:    	#$r->print("Old-new map: ".$syllabus{'data.old_new_map'}."<br />");
  339:    	#$r->print("Deleted fields: ".$syllabus{'data.deleted_fields'}."<br />");
  340:     if (!exists($syllabus{'data.fields'})) {
  341:     	# convert existing 2.x data to new DB fields
  342:     	# which become new primary data source for document
  343: 		%data = %{convert_from_v2($r, \%syllabus, \%syllabusfields, 0)};
  344: 		#$r->print("New fields order: ".$data{'data.fields'}."<br />");
  345: 		&Apache::lonnet::put('syllabus',\%data,$cdom,$cnum);
  346:     } elsif (  !exists($syllabus{'properties.v2_converted'}) && 
  347:     		   exists($syllabus{'uploaded.lastmodified'}) &&
  348:     		   exists($syllabus{'properties.last_modified'}) &&
  349:     		   ($syllabus{'uploaded.lastmodified'} !=
  350:     		   $syllabus{'properties.last_modified'})) {
  351:     	# if the document has been saved in 3.x and later edited in 
  352:     	# 2.x, reconvert the existing document, with extra warning
  353:     	%data = %{convert_from_v2($r, \%syllabus, \%syllabusfields, 1)};
  354:     	delete $data{'properties.v2_converted'};
  355:     	&Apache::lonnet::del('syllabus', ['properties.v2_converted'], $cdom, $cnum);
  356:     	$data{'properties.v2_conflict'} = 1;
  357: 		&Apache::lonnet::put('syllabus',\%data,$cdom,$cnum);    	
  358:     } else {
  359:     	%data = %syllabus;
  360:     	
  361:     }
  362: 
  363: # ----------------------------------------------------- Only if not public call
  364:     if ($env{'user.environment'}) { # does this user have privileges to post, etc?
  365:         if ($env{'request.course.id'}
  366:         && $cdom eq $env{'course.'.$env{'request.course.id'}.'.domain'}
  367:         && $cnum eq $env{'course.'.$env{'request.course.id'}.'.num'}) {
  368:             $allowed=&Apache::lonnet::allowed('mdc',$env{'request.course.id'});
  369:             $privileged=$allowed;
  370:             if (($data{'uploaded.lastmodified'}) && (!$forceedit)) {
  371:                 $forcestudent='student';
  372:             }
  373:             if ($forcestudent or $target eq 'tex') { $allowed=0; }
  374:         }
  375: 		#store what the user typed in
  376: 		my @fields = @{thaw($data{'data.fields'})};
  377: 		if (($allowed) && ($env{'form.delete'})) {
  378: 			my $field = $env{'form.delete'};
  379: 			chomp($field);
  380: 			#allow only numbers, underscores
  381: 			$field=~s/[^0-9_]//g;
  382: 			#check if the field exists
  383: 			#do not delete if file in v2 conversion mode
  384: 			if (exists($data{'data.field.'.$field}) &&
  385: 				!exists($data{'properties.v2_converted'})) {
  386: 				#$r->print("Field '$field' can be deleted.<br />");
  387: 				# linearly parse "data.fields" and remove it
  388: 				for (my $i = 0; $i < length(@fields); $i++) {
  389: 					if ($fields[$i] eq $field) {
  390: 						splice(@fields, $i, 1);
  391: 						#$r->print("Removed entry $i from 'data.fields'<br />");
  392: 					}
  393: 				}
  394: 				# if "data.deleted" does not exist, create it
  395: 				my @deleted;
  396: 				if (!exists($data{'data.deleted_fields'})) {
  397: 					@deleted = [];
  398: 				} else {
  399: 					@deleted = @{thaw($data{'data.deleted_fields'})};
  400: 				}
  401: 				# only if deleted does not exist in 'data.deleted', push it
  402: 				my $push = 1;
  403: 				for (my $i = 0; $i < length(@deleted); $i++) {
  404: 					if ($deleted[$i] eq $field) {
  405: 						$push = 0;
  406: 						last;
  407: 					}
  408: 				}
  409: 				unless (!$push) {
  410: 					push(@deleted, $field);
  411: 				}
  412: 				$data{'data.fields'} = freeze(\@fields);
  413: 				$data{'data.deleted_fields'} = freeze(\@deleted);
  414: 				
  415: 				&Apache::lonnet::put('syllabus',\%data,$cdom,$cnum);
  416: 			}
  417: 		}
  418: 		if (($allowed) && ($env{'form.rename'})) {
  419: 			my $field = $env{'form.rename'};
  420: 			my $new_title = "Hello, World!";
  421: 			chomp($field);
  422: 			$field=~s/[^0-9_]//g;
  423: 			#check if the field exists
  424: 			#do not delete if file in v2 conversion mode
  425: 			if (exists($data{'data.field.'.$field}) &&
  426: 				!exists($data{'properties.v2_converted'})) {
  427: 				#sanitize HTML content
  428: 				#$r->print("Rename -- field found.<br />");
  429: 				my %db_entry = %{thaw($data{'data.field.'.$field})};
  430: 				$new_title = &Apache::lonfeedback::clear_out_html($new_title, 1);
  431: 				$db_entry{title} = $new_title;
  432: 				$data{'data.field.'.$field} = freeze(\%db_entry);
  433: 				&Apache::lonnet::put('syllabus',\%data,$cdom,$cnum);
  434: 			}
  435: 		}
  436:         if (($allowed) && ($env{'form.storesyl'})) {
  437:             foreach my $syl_field (@fields) {
  438:                 my $field=$env{'form.'.$syl_field};
  439:                 my $type;
  440:                 my %field_hash;
  441:                 # only update a field if it already exists!
  442:                 if (exists($data{'data.field.'.$syl_field})) {
  443:                 	#$r->print("Creating/updated field ".$syl_field."<br />");
  444:                 	%field_hash = exists($data{'data.field.'.$syl_field}) ?
  445:                 						%{thaw($data{'data.field.'.$syl_field})} : ();
  446:                 	$type = exists($field_hash{type}) ? $field_hash{type} : TYPE_TEXT_HTML;
  447: 					chomp($field);
  448: 					$field=~s/\s+$//s;
  449: 					$field=~s/^\s+//s;
  450: 					$field=~s/\<br\s*\/*\>$//s;
  451: 					$field=&Apache::lonfeedback::clear_out_html($field,1);
  452: 					$field_hash{content}=$field;
  453: 					if ($type eq TYPE_URL_INCLUDE) { # clean up included URLs
  454: 						my $field='';
  455: 						foreach my $value (split(/\n/,$field_hash{content})) {
  456: 							my $url=$value;
  457: 							# get rid of leading and trailing spaces
  458: 							$url=~s/^\s+//;
  459: 							$url=~s/\s+$//;
  460: 							if ($url=~m|^https?\://([^/]+)/(.+)$|) {
  461: 								my $host = $1;
  462: 								my $remainder=$2;
  463: 								# remove the hostname from internal URLs
  464: 								my $hostname = &Apache::lonnet::hostname($host);
  465: 								my %all_hostnames = &Apache::lonnet::all_hostnames();
  466: 								foreach my $possible_host (keys(%all_hostnames)) {
  467: 									if ($possible_host =~ /\Q$hostname\E/i) {
  468: 										$url=$remainder;
  469: 									}
  470: 								}
  471: 							}
  472: 							# norm internal URLs
  473: 							unless ($url=~/^https?\:/) {
  474: 								$url=&Apache::lonnet::clutter($url);
  475: 							}
  476: 							# re-assemble field
  477: 							if ($url) {
  478: 								$field.=$url."\n";
  479: 							}
  480: 						}
  481: 	    	               $field_hash{content}=$field;
  482: 		                   $field_hash{type}=TYPE_URL_INCLUDE;
  483: 					}
  484: 					$data{'data.field.'.$syl_field} = freeze(\%field_hash);
  485: 				} 
  486:             }
  487:             $data{'uploaded.domain'}=$env{'user.domain'};
  488:             $data{'uploaded.name'}=$env{'user.name'};
  489:             my $time = $^T;
  490:             $data{'uploaded.lastmodified'}=$time;
  491:             $data{'properties.last_modified'}=$time;
  492:             delete $data{'properties.v2_converted'};
  493:             delete $data{'properties.v2_conflict'};
  494:             delete $data{'properties.v2_conflict_fail'};
  495:             &Apache::lonnet::del('syllabus', ['properties.v2_converted', 
  496:             	'properties.v2_conflict', 'properties.v2_conflict_fail'], $cdom, $cnum);
  497:             	
  498:             #2.x compatibility: write to old fields with new mapped fields
  499:             my %old_new_map = %{thaw($data{'data.old_new_map'})};
  500:             foreach my $old_field (keys(%old_new_map)) {
  501:             	#$r->print("Looking for: ".$old_field." at ".$old_new_map{$old_field}."<br />");
  502:             	if (exists($data{'data.field.'.$old_new_map{$old_field}})) {
  503:             		#$r->print("updating old field ".$old_field."<br />");
  504:             		my %new_field = %{thaw($data{'data.field.'.$old_new_map{$old_field}})};
  505:             		$data{$old_field} = $new_field{content};
  506:             	}
  507:             }
  508:               
  509:             &Apache::lonnet::put('syllabus',\%data,$cdom,$cnum);
  510:         }
  511:     }
  512: 
  513: #--------Functions
  514:     if( ($allowed || $privileged) && $target ne 'tex') {
  515:         my $functions=&Apache::lonhtmlcommon::start_funclist();
  516:         if ($allowed) {
  517: 			#if you have the register flag, keep it
  518: 			if($env{'form.register'} == 1) {
  519:             	$functions.=&Apache::lonhtmlcommon::add_item_funclist(
  520:                           '<a href="'.$r->uri.'?forcestudent=1&amp;register=1">'
  521:                            .&mt('Show Public View').'</a>'
  522:                            .&Apache::loncommon::help_open_topic(
  523:                                 'Uploaded_Templates_PublicView'));
  524: 			} else {
  525:             	$functions.=&Apache::lonhtmlcommon::add_item_funclist(
  526:                           '<a href="'.$r->uri.'?forcestudent=1">'
  527:                            .&mt('Show Public View').'</a>'
  528:                            .&Apache::loncommon::help_open_topic(
  529:                                 'Uploaded_Templates_PublicView'));
  530: 			}
  531:         } elsif ($privileged) {
  532: 			if($env{'form.register'} == 1) {
  533: 	            $functions.=&Apache::lonhtmlcommon::add_item_funclist(
  534:                            '<a href="'.$r->uri.'?forceedit=1&amp;register=1">'
  535:                             .&mt('Edit').'</a>');
  536: 			} else {
  537: 	            $functions.=&Apache::lonhtmlcommon::add_item_funclist(
  538:                            '<a href="'.$r->uri.'?forceedit=1">'
  539:                             .&mt('Edit').'</a>');
  540: 			}
  541:         }
  542: 
  543:         $functions.=&Apache::lonhtmlcommon::end_funclist();
  544:         $r->print(&Apache::loncommon::head_subbox($functions));
  545:     }
  546: 
  547: #---------------------Print External URL Syllabus Info and Help Text
  548:     if( ($allowed) && ($target ne 'tex') ) {
  549:         my $protocol = $Apache::lonnet::protocol{$homeserver};
  550:           $protocol = 'http' if ($protocol ne 'https');
  551:         $r->print('<p class="LC_info">'
  552:                  .&mt('This syllabus can be publicly viewed at [_1]'
  553:                      ,'<tt>'.$protocol.'://'.&Apache::lonnet::hostname($homeserver).$r->uri.'</tt>')
  554:                  .'&nbsp;'.&Apache::loncommon::help_open_topic('Syllabus_ExtLink')
  555:                  .'</p>'
  556:                  .'<p class="LC_info">'
  557:                  .&mt('Instead of using this template you can specify an external URL as Syllabus in the [_1]Course Configuration[_2].'
  558:                      ,'<a href="/adm/courseprefs?actions=courseinfo&amp;phase=display">','</a>')
  559:                  .'</p>'
  560:         );
  561:         #-Print Help Text
  562:         $r->print(&Apache::loncommon::help_open_topic( 
  563:                         'Uploaded_Templates_TextBoxes',
  564:                         &mt('Help with filling in text boxes')));
  565:     }
  566: 
  567: #----------Print last update
  568:     my $lastmod=$syllabus{'uploaded.lastmodified'};
  569:     $lastmod=($lastmod?&Apache::lonlocal::locallocaltime($lastmod):&mt('never'));
  570:     my $who = &Apache::loncommon::aboutmewrapper(
  571:         &Apache::loncommon::plainname($syllabus{'uploaded.name'},
  572:         $syllabus{'uploaded.domain'}),$syllabus{'uploaded.name'},
  573:         $syllabus{'uploaded.domain'});
  574:     if ($target ne 'tex') {
  575:         $r->print('<div class="LC_info">'.&mt('Last updated').': '.
  576:             $lastmod . ' '.
  577:             ($who ? &mt('by').' '.$who
  578:                            : '' ) .
  579:              '</div>' );
  580: 
  581:     } else {
  582:         $r->print('\\\\ '.&mt('Last updated').': '.$lastmod.' '.
  583:             ($who? &mt('by').'\\\\ '.
  584:                     &Apache::loncommon::plainname($syllabus{'uploaded.name'},$syllabus{'uploaded.domain'})
  585:                   :'')
  586:              .'\\\\');
  587:     }
  588:     if ($allowed && $data{'properties.v2_converted'} == 1) {
  589:     	$r->print("<em>This document was created with LON-CAPA 2.x.  Modifying it may cause it to not display correctly on older servers.</em><br/>");
  590: 	}
  591: 	if ($allowed && $data{'properties.v2_conflict'} == 1) {
  592: 		$r->print("<em>This document was saved with LON-CAPA 3.x, then further edited in LON-CAPA 2.x.</em><br/>");
  593: 		if ($data{'properties.v2_conflict_fail'} == 1) {
  594: 			$r->print("<em>Some fields in LON-CAPA 2.x no longer have an equivalent in LON-CAPA 3.x.  These fields were appended; some fields may be duplicated or not match.</em><br />");
  595: 		} else {
  596: 			$r->print("<em>These changes were automatically transferred to LON-CAPA 3.x</em>");
  597: 		}
  598: 	}
  599: 
  600: #----------------------------Print Headtitle
  601:     if ($target ne 'tex') {
  602:         $r->print('<h1>'.$courseenv{'description'}.'</h1>');
  603:         $r->print('<h3>'.  &Apache::lonnet::domain($cdom,'description').'</h3>');
  604:     } else {
  605:         $r->print('\noindent{\large\textbf{'.$courseenv{'description'}.'}}\\\\\\\\\textbf{'.
  606:         &Apache::lonnet::domain($cdom,'description').'}\\\\');
  607:     }
  608: 
  609: # -------------------------------------------------------- Get course personnel
  610:     my %coursepersonnel=&Apache::lonnet::get_course_adv_roles($cdom.'/'.$cnum);
  611:     if ($target ne 'tex') {
  612:         $r->print(&Apache::lonhtmlcommon::start_pick_box());
  613:     } else {
  614:         $r->print('\begin{tabular}{|p{0.45\textwidth}|p{0.45\textwidth}|}\hline');
  615:     }
  616:     my @personnel=sort(keys(%coursepersonnel));
  617:     my $lastpers=$personnel[$#personnel];
  618:     foreach my $element (@personnel) {
  619:         if ($target ne 'tex') {
  620:             $r->print(&Apache::lonhtmlcommon::row_title($element));
  621:         } else {
  622:             $r->print(' '.&Apache::lonxml::xmlparse($r,'tex',$element).' & ');
  623:         }
  624:         foreach (split(/\,/,$coursepersonnel{$element})) {
  625:             my ($puname,$pudom)=split(/\:/,$_);
  626:             if ($target ne 'tex') {
  627:                 my $courseperson = &Apache::loncommon::plainname($puname,$pudom);
  628:                 if (($env{'user.name'} eq '') || ($env{'user.name'} eq 'public') ||
  629:                     ($env{'user.domain'} eq '') || ($env{'user.domain'} eq 'public')) {
  630:                     $r->print(' '.$courseperson);
  631:                 } else {
  632:                     $r->print(' '.&Apache::loncommon::aboutmewrapper($courseperson,
  633:                               $puname,$pudom));
  634:                 }
  635:             } else {
  636:                 $r->print(' '.&Apache::loncommon::plainname($puname,
  637:                               $pudom).' ');
  638:             }
  639:         }
  640:         if ($target ne 'tex') {
  641:             my $lastclose=$element eq $lastpers?1:0;
  642:             $r->print(&Apache::lonhtmlcommon::row_closure($lastclose));
  643:         } else {
  644:             $r->print('\\\\ \hline');
  645:         }
  646:     }
  647:     if ($target ne 'tex') {
  648:         $r->print(&Apache::lonhtmlcommon::end_pick_box());
  649:     } else {
  650:         $r->print('\end{tabular}\\\\');
  651:     }
  652: # -------------------------------------------------------------- Announcements?
  653:     my $day = &Apache::lonannounce::showday(time,2,
  654:              &Apache::lonannounce::readcalendar($cdom.'_'.$cnum));
  655:     if ($target ne 'tex') {
  656:     	if ($allowed) {
  657:     		&print_activity_bar($r, \%data, $target, $allowed, Apache::lontemplate->RICH_TEXT_DETECT_HTML);
  658:     		&print_field_sortable($r, \%data, $target, $allowed, Apache::lontemplate->RICH_TEXT_DETECT_HTML);
  659:         	&print_title_bar($r, \%data, $target, $allowed, Apache::lontemplate->RICH_TEXT_DETECT_HTML);
  660:         	&print_context_bar($r, \%data, $target, $allowed, Apache::lontemplate->RICH_TEXT_DETECT_HTML);
  661:         }
  662:         $r->print("<div id='syllabus-content'>\n");
  663: 
  664:     } else {
  665:         $r->print(&Apache::lonxml::xmlparse($r,'tex',$day));
  666:     }
  667:     
  668: # ---------------------------------------------------------------- Get syllabus
  669:     if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
  670:         if ($allowed) {
  671:             $r->print('<form id="syllabus-form" method="post" action="">'.
  672:             '<input type="hidden" name="forceedit" value="edit" />');
  673:         }
  674:         my @htmlids=();
  675: 		my $url_include_handler = sub {
  676: 			my ($r, $field, $json_ref, $group, $target, $allowed) = @_;
  677: 			my $message = $json_ref->{items}{$field}{content};
  678: 			my $title = $json_ref->{items}{$field}{title};
  679: 			my $urls = $message;
  680: 			foreach my $filelink (split(/\n/,$urls)) {
  681: 				my $output='';
  682: 			   # embed style?
  683: 				my ($curfext)=($filelink=~/\.([^\.]+)$/);
  684: 				my $embstyle=&Apache::loncommon::fileembstyle($curfext);
  685: 				if (($embstyle eq 'ssi') || ($curfext=~/\/$/)) {# make ssi call and remove everything but the body contents
  686: 					$output=&Apache::lonnet::ssi_body($filelink);
  687: 				} elsif ($embstyle eq 'img') {# embed as an image
  688: 					$output='<img src="'.$filelink.'" />';
  689: 				}
  690: 				if ($output ne '') {
  691: 					   $message='';
  692: 					   if ($target ne 'tex') {
  693: 						   $message.='<p>'.$output.'</p>';
  694: 					   } else {
  695: 						   $message.=' '.&Apache::lonxml::xmlparse($r,'tex','<p>'.$output.'</p>').' ';
  696: 					   }
  697: 				}
  698: 			}
  699: 			if ($allowed) {
  700: 				 &Apache::lonfeedback::newline_to_br(\$urls);
  701: 				 &Apache::lontemplate::print_start_template($r,$title.
  702: 						  &Apache::loncommon::help_open_topic('Syllabus_URLs'),'LC_Box');
  703: 				 $r->print($urls);
  704: 				 $r->print("<br /><div>");
  705: 				 &Apache::lontemplate::print_textarea_template($r, $message,
  706: 					$field, Apache::lontemplate->RICH_TEXT_ALWAYS_OFF);
  707: 				 &Apache::lontemplate::print_saveall_template($r);                         
  708: 				 $r->print("</div>");
  709: 				 &Apache::lontemplate::print_end_template($r);
  710: 
  711: 			} else {
  712: 				$r->print($message);
  713: 			}
  714: 		};
  715: 		my %custom_hash = ( TYPE_URL_INCLUDE() => $url_include_handler );
  716:  		@htmlids = &print_template_new_fields($r, \%data, 
  717:  			$target, $allowed, Apache::lontemplate->RICH_TEXT_DETECT_HTML, \%custom_hash);
  718:         if ($allowed) {
  719:             $r->print('</form>');
  720:             $r->print(&Apache::lonhtmlcommon::htmlareaselectactive(@htmlids));
  721:         }
  722:         if ($target ne 'tex') {$r->print('</div><p style="clear:both">&nbsp;</p>');}
  723:         if ($allowed) {
  724:             &Apache::lontemplate::print_start_template($r,'RSS Feeds and Blogs','LC_Box');
  725:             $r->print(&Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit));
  726:             my $editurl= &Apache::lonnet::absolute_url().'/adm/'.$cdom.'/'.$cnum.'/_rss.html';
  727:             $r->print( '<a href="'.$editurl.'">'.&mt('New RSS Feed or Blog').'</a>');
  728:             &Apache::lontemplate::print_end_template($r);
  729:         } elsif (&Apache::lonrss::advertisefeeds($cnum,$cdom) ne '') {
  730:             &Apache::lontemplate::print_start_template($r,'RSS Feeds and Blogs','LC_Box');
  731:             $r->print(&Apache::lonrss::advertisefeeds($cnum,$cdom,$forceedit));
  732:             &Apache::lontemplate::print_end_template($r);
  733:         }
  734:     } else {
  735:         if ($target ne 'tex') {$r->print('<p>');} else {$r->print('\par ');}
  736:         $r->print(&mt('No syllabus information provided.'));
  737:         if ($target ne 'tex') {$r->print('</p>');}
  738:     }
  739:     if ($target ne 'tex') {
  740:         if ($env{'form.backto'} eq 'coursecatalog') {
  741:             $r->print('<form name="backtocat" method="post" action="/adm/coursecatalog">'.
  742:                       &Apache::lonhtmlcommon::echo_form_input(['backto','courseid']).
  743:                       '</form>');
  744:         }
  745:         $r->print(&Apache::loncommon::end_page());
  746:     } else {
  747:         $r->print('\end{document}');
  748:     }
  749:     return OK;
  750: }
  751: 
  752: sub print_activity_bar {
  753: 	my ($r, $data_ref, $target, $allowed, $default_rich_text, $group) = @_;
  754: 	$r->print("<div id='activity-bar'>
  755: <button id='save-button' type='button' class='LC_ActivityBarButton LC_ActivityBarButton-IconLeft ui-state-default ui-priority-primary ui-corner-all'>
  756: 	<span class='ui-icon ui-icon-disk'></span><a href='#'>Save</a>
  757: </button>
  758: 
  759: </div>");
  760: }
  761: 
  762: sub print_title_bar {
  763: 	my ($r, $data_ref, $target, $allowed, $default_rich_text, $group) = @_;
  764: 	$r->print("<div id='title-bar'><h4>
  765: <button id='section-type-button' type='button' class='LC_ActivityBarButton ui-helper-reset ui-state-default ui-corner-all'>
  766: 	<img src='/adm/lonIcons/text-rich.png' title='Rich Text Section'/>
  767: </button>
  768: <span id='section-title-text'>Title Goes Here</span>
  769: </h4>
  770: </div>");
  771: }	
  772: 
  773: sub print_context_bar {
  774: 	my ($r, $data_ref, $target, $allowed, $default_rich_text, $group) = @_;
  775: 	$r->print("<div id='context-bar'>
  776: <button id='add-section-button' type='button' class='LC_ActivityBarButton LC_ActivityBarButton-IconLeft ui-state-default ui-corner-all'>
  777: 	<span class='ui-icon ui-icon-triangle-1-n'></span><a href='#'>Move&nbsp;Up</a>
  778: </button>
  779: <button id='add-section-button' type='button' class='LC_ActivityBarButton LC_ActivityBarButton-IconLeft ui-state-default ui-corner-all'>
  780: 	<span class='ui-icon ui-icon-triangle-1-s'></span><a href='#'>Move&nbsp;Down</a>
  781: </button>
  782: <button id='add-section-button' type='button' class='LC_ActivityBarButton LC_ActivityBarButton-IconLeft ui-state-default ui-corner-all'>
  783: 	<span class='ui-icon ui-icon-pencil'></span><a href='#'>Rename</a>
  784: </button>
  785: <button id='add-section-button' type='button' class='LC_ActivityBarButton LC_ActivityBarButton-IconLeft ui-state-default ui-corner-all'>
  786: 	<span class='ui-icon ui-icon-closethick'></span><a href='#'>Delete</a>
  787: </button>
  788: </div>");
  789: }
  790: 
  791: sub print_field_sortable {
  792: 	my ($r, $data_ref, $target, $allowed, $default_rich_text, $group) = @_;
  793: 	my %data = %{$data_ref};
  794: 	my @fields = @{thaw($data{'data.fields'})};
  795: 	$r->print("<div id='scrollable-fields-container'>
  796: <div id='syllabus-fields-container'>
  797: <ui id='syllabus-fields' class='LC_Sortable LC_SyllabusFields'>\n");
  798: 	foreach my $key (@fields) {
  799: 		my %field = %{thaw($data{'data.field.'.$key})};
  800: 		$r->print("<li id='title-$key' class='ui-state-default LC_EllipseOverflow' title='$field{title}'><span class='ui-icon ui-icon-arrowthick-2-n-s left'></span><span id='remove-$key' class='RemoveSection right ui-icon ui-icon-closethick' title='Delete'></span>$field{title}</li>\n");
  801: 	}
  802: 	$r->print("
  803: </ui>
  804: </div>
  805: <div id='syllabus-fields-actions'>
  806: <button id='add-section-button' type='button' class='LC_ActivityBarButton LC_ActivityBarButton-IconLeft ui-state-default ui-corner-all'>
  807: 	<span class='ui-icon ui-icon-circle-plus'></span><a href='#'>Add&nbsp;Section</a>
  808: </button>
  809: <button id='revert-order-button' type='button' class='LC_ActivityBarButton LC_ActivityBarButton-IconLeft ui-state-default ui-corner-all'>
  810: 	<span class='ui-icon ui-icon-arrowreturnthick-1-w'></span><a href='#'>Revert&nbsp;Order</a>
  811: </button>
  812: </div>
  813: </div>\n");
  814: }	
  815: 
  816: sub print_template_new_fields {
  817: 	my ($r, $data_ref, $target, $allowed, $default_rich_text, $custom_handlers_ref, $group) = @_;
  818: 	my @html_ids = ();
  819: 	my %data = %{$data_ref};
  820: 	my @fields = @{thaw($data{'data.fields'})};
  821: 	my %custom_handlers = %{$custom_handlers_ref};
  822: 
  823: 	foreach my $key (@fields) {
  824: 		my %field = %{thaw($data{'data.field.'.$key})};
  825: 		my $title = $field{title};
  826: 		my $raw_message = $field{content};
  827: 		my $type = $field{type};
  828: 		my $message = $raw_message if (($raw_message=~/\w/) || ($allowed));
  829: 		if ((%custom_handlers) && exists($custom_handlers{$type})) {
  830: 			#$custom_handlers{$type}->($r, $field, $json_ref, $group, $target, $allowed);
  831: 		} else {
  832: 			if (($raw_message=~/\w/) || ($allowed)) {
  833: 				if (!&Apache::lonfeedback::contains_block_html($message)) {
  834: 					&Apache::lonfeedback::newline_to_br(\$message);
  835: 				} else {
  836: 					$message = &Apache::lonfeedback::tidy_html($message);
  837: 				}
  838: 				$message=&Apache::lonhtmlcommon::raw_href_to_link($message);
  839: 				if ($allowed) {
  840: 					$message=&Apache::lonspeller::markeduptext($message);
  841: 				}
  842: 				$message=&Apache::lontexconvert::msgtexconverted($message);
  843: 				if ($target ne 'tex') {
  844: 					#output of syllabusfields will be generated here. 
  845: 					&Apache::lontemplate::print_start_template($r,$title,'LC_Box', 'box-'.$key);
  846: 					#$r->print($message);
  847: 					if ($allowed) {
  848: 						$r->print("<div>");
  849: 						&Apache::lontemplate::print_textarea_template($r, $raw_message,
  850: 							$key, $default_rich_text);
  851: # 						&Apache::lontemplate::print_saveall_template($r);
  852: # 						if (!exists($data{'properties.v2_converted'})) {
  853: # 							$r->print("<a href='?delete=$key&forceedit=1'>Delete</a> ");
  854: # 							$r->print("<a href='?rename=$key&forceedit=1'>Rename to \"Hello, World!\"</a>");
  855: # 						}
  856: 						$r->print("</div>");
  857: 					} 
  858: 					&Apache::lontemplate::print_end_template($r);
  859: 				} else {
  860: 				    my $safeinit;
  861:                     $r->print(&Apache::lonxml::xmlparse($r,'tex','<h3>'.$title.'</h3>'));
  862:                     $r->print(&Apache::lonxml::xmlparse($r,'tex',$message));
  863: 				}
  864: 				push(@html_ids,"hello");
  865: 			}
  866: 		} 
  867: 	}
  868: 	
  869: 	return @html_ids;	
  870: }
  871: 
  872: sub convert_from_v2 {
  873: 	my ($r, $data_ref, $fields_ref, $conflict) = @_;
  874: 	my %data = %{$data_ref};
  875: 	my %fields = %{$fields_ref};
  876: 	my @fields_order = (!$conflict) ? () : @{thaw($data{'data.fields'})};
  877: 	my %old_new_map = (!$conflict) ? () : %{thaw($data{'data.old_new_map'})};
  878: 	my $repeat_int = 0;  #ensure fields with created timestamp are unique
  879: 	foreach my $element (sort(keys(%fields))) {
  880: 		my %new_element = ();
  881: 		my $title = $fields{$element};
  882: 		my $title_hash = time."_".$$;
  883: 		if (exists($data{'data.field.'.$title_hash})) {
  884: 			$title_hash .= "_".$repeat_int++;
  885: 		}
  886: 		my $content = $data{$element};
  887: 		$new_element{title} = $title;
  888: 		$new_element{content} = $content;
  889: 		if ($element eq 'lll_includeurl') {
  890: 			$new_element{type} = TYPE_URL_INCLUDE;
  891: 		} else {
  892: 			$new_element{type} = TYPE_TEXT_HTML;
  893: 		}
  894: 		if (!$conflict) {
  895: 			$r->print("Creating new field with ID: ".$title_hash."<br />");
  896: 			$data{'data.field.'.$title_hash} = freeze(\%new_element);
  897: 			$old_new_map{$element} = $title_hash;
  898: 			push(@fields_order, $title_hash);
  899: 		} else {
  900: 			if (exists($old_new_map{$element})) {
  901: 				$r->print("Transferring old field ".$element." to new ID: ".$old_new_map{$element}."<br />");
  902: 				if (exists($data{'data.field.'.$old_new_map{$element}})) {
  903: 					my %new_field = %{thaw($data{'data.field.'.$old_new_map{$element}})};
  904: 					$new_field{content} = $content;
  905: 					$data{'data.field.'.$old_new_map{$element}} = freeze(\%new_field);
  906: 				}
  907: 			} else {
  908: 				$data{'data.field.'.$title_hash} = freeze(\%new_element);
  909: 				$old_new_map{$element} = $title_hash;
  910: 				$data{'properties.v2_conflict_fail'} = 1;
  911: 				push(@fields_order, $title_hash);
  912: 			}
  913: 		}
  914: 	}
  915: 	$data{'data.fields'} = freeze(\@fields_order);
  916: 	$data{'data.old_new_map'} = freeze(\%old_new_map);
  917: 	$data{'properties.last_modified'} = time;
  918: 	$data{'properties.v2_converted'} = 1;
  919: 	$data{'properties.type'} = 'syllabus';
  920: 	
  921: 	return \%data;
  922: }
  923: 
  924: 1;
  925: __END__

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