--- loncom/xml/londefdef.pm	2011/10/01 03:19:06	1.434
+++ loncom/xml/londefdef.pm	2013/06/04 22:20:20	1.444
@@ -1,8 +1,7 @@
-
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.434 2011/10/01 03:19:06 raeburn Exp $
+# $Id: londefdef.pm,v 1.444 2013/06/04 22:20:20 raeburn Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -56,7 +55,7 @@ use LONCAPA();
 
 BEGIN {
 
-    &Apache::lonxml::register('Apache::londefdef',('a','abbr','acronym','accessrule','address','allow','applet','area','b','base','basefont','bgo','bgsound','big','blink','blockquote','blankspace','body','br','button','caption','center','cite','code','col','colgroup','dd','del','dfn','dir','div','dl','dt','em','embed','externallink','fieldset','font','form','frame','frameset','h1','h2','h3','h4','h5','h6','head','hr','html','i','iframe','img','input','ins','insert','isindex','kbd','keygen','label','layer','legend','li','link','m','map','marquee','menu','meta','multicol','nobr','noembed','noframes','nolayer','noscript','object','ol','optgroup','option','output','p','param','pre','q','s','samp','select','server','small','spacer','span','strike','strong','sub','sup','table','tbody','td','textarea','tfoot','th','thead','title','tr','tt','tthoption','u','ul','var','wbr','hideweboutput'));
+    &Apache::lonxml::register('Apache::londefdef',('a','abbr','acronym','accessrule','address','allow','applet','area','b','base','basefont','bgo','bgsound','big','blink','blockquote','blankspace','body','br','button','caption','center','cite','code','col','colgroup','dd','del','dfn','dir','div','dl','dt','em','embed','externallink','fieldset','font','form','frame','frameset','h1','h2','h3','h4','h5','h6','head','hr','html','i','iframe','img','input','ins','insert','isindex','kbd','keygen','label','layer','legend','li','link','m','map','marquee','menu','meta','multicol','nobr','noembed','noframes','nolayer','noscript','object','ol','optgroup','option','output','p','param','pre','q','s','samp','select','server','small','spacer','span','strike','strong','style','sub','sup','table','tbody','td','textarea','tfoot','th','thead','title','tr','tt','tthoption','u','ul','var','wbr','hideweboutput'));
 
 }
 
@@ -459,6 +458,32 @@ sub insert_meta {
     <meta />';
 }
 
+#-- <start> tag
+sub start_style {
+	my ($target, $token, $tagstack, $parstack, $parser, $safeeval, $style) = @_;
+	my $currentstring = '';
+
+	if ($target eq 'tex') {
+		Apache::lonxml::startredirection();
+	} else {
+		$currentstring = $token->[4];
+	}
+	
+	return $currentstring;
+}
+
+sub end_style {
+	my ($target, $token, $tagstack, $parstack, $parser, $safeeval) = @_;
+	my $currentstring = '';
+
+	if ($target eq 'tex') {
+		Apache::lonxml::endredirection();
+	} else {
+		$currentstring = $token->[2];
+	}
+	return $currentstring;
+}
+
 # accessrule
 sub start_accessrule {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
@@ -545,9 +570,10 @@ sub start_body {
     # Breadcrumbs
     &Apache::lonhtmlcommon::clear_breadcrumbs();
     if ($env{'request.state'} eq 'construct') {
+        my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});
         &Apache::lonhtmlcommon::add_breadcrumb({
-            'text'  => 'Construction Space',
-            'href'  => &Apache::loncommon::authorspace(),
+            'text'  => 'Authoring Space',
+            'href'  => &Apache::loncommon::authorspace($url),
         });
         &Apache::lonhtmlcommon::add_breadcrumb({
             'text'  => 'HTML Editor',
@@ -573,7 +599,7 @@ sub start_body {
             $header=&Apache::lonmenu::constspaceform();
         }
         if ($env{'request.state'} ne 'published') {
-            $header.=&Apache::londefdef::edit_controls();
+            $header.=&edit_controls();
         }
         if ($env{'request.state'} eq 'construct') {
             $currentstring.=&Apache::loncommon::head_subbox(
@@ -605,12 +631,39 @@ sub edit_controls {
     $result .= '
 <div><input type="submit" name="editmode" accesskey="e" value="'.&mt('Edit').'" />';
     if (($env{'request.course.id'}) && ($env{'form.forceedit'})) {
-        my $viewtext = &mt('Course View');
-        if (&Apache::loncommon::course_type() eq 'Community') {
-            $viewtext = &mt('Community View');
+        my $url=&Apache::lonnet::hreflocation('',$env{'request.filename'});
+        if ($url =~ /\.html?$/i) {
+            my ($cdom,$cnum);
+            if ($env{'request.course.id'}) {
+                $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+                $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+                if ($env{'request.filename'} =~ m{/userfiles/supplemental/default|\d+/}) {
+                    if (&Apache::lonnet::is_course_upload($env{'request.filename'},
+                                                          $cnum,$cdom)) {
+                        &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+                                                                ['folderpath','title']);
+                    }
+                }
+            }
+            my ($symb,$itemtitle,$displayfile,$caller);
+            if ($url =~ m{^/uploaded/$cdom/$cnum/portfolio/syllabus/}) {
+                $itemtitle = &mt('Syllabus');
+                $caller = "/public/$cdom/$cnum/syllabus";
+            } else {
+                $caller = $url;
+                ($symb,$itemtitle,$displayfile) =
+                    &Apache::lonxml::get_courseupload_hierarchy($url,
+                                                                $env{'form.folderpath'},
+                                                                $env{'form.title'});
+            }
+            if (($symb ne '') || ($env{'httpref.'.$url} ne '') ||
+                ($url =~ m{^/uploaded/$cdom/$cnum/portfolio/syllabus/})) {
+                  $result .= ('&nbsp;' x 3).
+                             &Apache::lonhtmlcommon::dependencies_button()."\n".
+                             &Apache::lonhtmlcommon::dependencycheck_js($symb,
+                                 $itemtitle,$url,$env{'form.folderpath'},$caller)."\n";
+            }
         }
-        $result .= ('&nbsp;' x 3).'<input type="button" value="'.
-                   $viewtext.'" onclick="javascript:location.href=currentURL" />';
     }
     $result .= '</div>
 </div>
@@ -2971,22 +3024,47 @@ sub end_embed {
 #-- <param> tag (end tag forbidden)
 sub start_param {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval) = @_;
-    if (&Apache::lonxml::get_param('name',$parstack,
-				   $safeeval,undef,1)=~/^cabbase$/i) {
+    my $name = &Apache::lonxml::get_param('name',$parstack,$safeeval,
+                                          undef,1);
+    if ($name =~/^cabbase$/i) {
 	my $value=&Apache::lonxml::get_param('value',$parstack,
 					     $safeeval,undef,1);
 	&Apache::lonxml::extlink($value);
-    } 
-  
+    } elsif ($name eq 'flashvars') {
+        if (lc(&Apache::lonxml::get_param('type',$parstack,$safeeval,-2,1))
+            eq 'application/x-shockwave-flash') {
+            my $launcher =
+                &Apache::lonxml::get_param('data',$parstack,$safeeval,-2,1);
+            if ($launcher) {
+                &Apache::lonxml::extlink($launcher);
+            }
+            my $flashvars=&Apache::lonxml::get_param('value',$parstack,
+                                                     $safeeval,undef,1);
+            if ($flashvars ne '') {
+                foreach my $item (split(/\&/,$flashvars)) {
+                    my ($key,$value)=split(/=/,$item,2);
+                    if ($key eq 'content') {
+                        if ($value ne '') {
+                            my ($dir) = ($launcher =~ m{(.+/)[^/]+$});
+                            &Apache::lonxml::extlink($dir.$value);
+                        }
+                    } elsif ($key eq 'thumb') {
+                        if ($value ne '') {
+                            &Apache::lonxml::extlink($value);
+                        }
+                    }
+                }
+            }
+        }
+    }
     my $src = &Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
-    &Apache::lonxml::extlink($src);
+    if ($src ne '') {
+        &Apache::lonxml::extlink($src);
+    }
     my $currentstring = '';
     if ($target eq 'web' || $target eq 'webgrade') {
 	my %toconvert;
-	my $src=&Apache::lonxml::get_param('src',$parstack,$safeeval,undef,1);
 	if ($src) { $toconvert{'src'}= $src; }
-	my $name=&Apache::lonxml::get_param('name',$parstack,$safeeval,
-					    undef,1);
 	if ($name=~/^cabbase$/i) {
 	    $toconvert{'value'}=&Apache::lonxml::get_param('value',$parstack,
 							   $safeeval,undef,1);
@@ -4194,7 +4272,7 @@ sub get_eps_image {
 		    close(FILE);
                 }
 		$src=~s|/home/httpd/html/res|/home/httpd/prtspool|;
-		$src=~s|/home/([^/]*)/public_html/|/home/httpd/prtspool/$1/|;
+		$src=~s|/home/httpd/html/priv/[^/]+/([^/]*)/|/home/httpd/prtspool/$1/|;
 		if ($sext ne "") {	 # Put the ext. back in to uniquify.
 		    $src =~ s/\.eps$/$sext.eps/;
 		}
@@ -4213,7 +4291,7 @@ sub get_eps_image {
 	print FILE "$src\n";
 	close FILE;
 	$src=~s|/home/httpd/html/res|/home/httpd/prtspool|;
-	$src=~s|/home/([^/]*)/public_html/|/home/httpd/prtspool/$1/|;
+	$src=~s|/home/httpd/html/priv/[^/]+/([^/]*)/|/home/httpd/prtspool/$1/|;
     }
     my ($path,$file)=($src=~m|(.*)/([^/]*)$|);
     $path =~ s/ /\_/g;
@@ -4232,7 +4310,7 @@ sub eps_generation {
     my $newsrc = $src;
     $newsrc =~ s/(\.bmp|\.gif|\.jpg|\.jpeg)$/\.eps/i;
     $newsrc=~s{/home/httpd/html/res}{};
-    $newsrc=~s{/home/($LONCAPA::username_re)/public_html/}{/$1/};
+    $newsrc=~s{/home/httpd/html/priv/[^/]+/($LONCAPA::username_re)/}{/$1/};
     $newsrc=~s{/\./}{/};
     $newsrc=~s{/([^/]+)\.(ps|eps)}{/};
     if ($newsrc=~m{/home/httpd/lonUsers/}) {
@@ -4415,7 +4493,7 @@ sub latex_header {
 	"\\usepackage{xcolor}\n".
 	'\usepackage{calc}'.
 	'\usepackage{amsmath}'.
-    '\usepackage{soul}',
+	'\usepackage{soul}'.
 	'\usepackage{amssymb}'.
 	'\usepackage{amsfonts}'.
 	'\usepackage{amsthm}'.