[LON-CAPA-cvs] cvs: loncom / lonenc.pm /xml londefdef.pm

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 22 Mar 2006 19:37:47 -0000


albertel		Wed Mar 22 14:37:47 2006 EDT

  Modified files:              
    /loncom	lonenc.pm 
    /loncom/xml	londefdef.pm 
  Log:
  - ading 'encyrturl' as an option to the <img> BUG#4712
  
  
Index: loncom/lonenc.pm
diff -u loncom/lonenc.pm:1.11 loncom/lonenc.pm:1.12
--- loncom/lonenc.pm:1.11	Thu Apr  7 02:56:20 2005
+++ loncom/lonenc.pm	Wed Mar 22 14:37:44 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # URL translation for encrypted filenames
 #
-# $Id: lonenc.pm,v 1.11 2005/04/07 06:56:20 albertel Exp $
+# $Id: lonenc.pm,v 1.12 2006/03/22 19:37:44 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -110,8 +110,8 @@
 }
 
 sub encrypted {
-    my $uri=shift;
-    if ($env{'request.role.adv'}) { return($uri); }
+    my ($uri,$force_enc) = @_;
+    if (!$force_enc && $env{'request.role.adv'}) { return($uri); }
     my $seed=&encryptseed();
     unless ($seed) {
 	return $uri;
@@ -147,15 +147,19 @@
 }
 
 sub encrypt_ref {
-    my ($token,$elements)=@_;
+    my ($token,$elements,$force_enc)=@_;
     my $html;
-    if ($env{'request.enc'}) {
+    &Apache::lonnet::logthis("hrrm $force_enc");
+    if ($force_enc || $env{'request.enc'}) {
 	while (my ($name,$value)= each(%{ $elements })) {
 	    if (!$value) { next; }
 	    my $href=&Apache::lonnet::hreflocation($Apache::lonxml::pwd[-1],$value);
-	    if ($href !~ /^http:/) { $href=&Apache::lonenc::encrypted($href); }
+	    if ($href !~ /^http:/) {
+		$href = &Apache::lonenc::encrypted($href,$force_enc);
+	    }
 	    $token->[2]->{$name}=$href;
 	}
+	delete($token->[2]->{'encrypturl'});
 	$html = &Apache::edit::rebuild_tag($token);
     } else {
 	$html = $token->[4];
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.321 loncom/xml/londefdef.pm:1.322
--- loncom/xml/londefdef.pm:1.321	Tue Feb 21 05:27:43 2006
+++ loncom/xml/londefdef.pm	Wed Mar 22 14:37:44 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.321 2006/02/21 10:27:43 foxr Exp $
+# $Id: londefdef.pm,v 1.322 2006/03/22 19:37:44 albertel Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -2770,13 +2770,17 @@
 
     if ($target eq 'web') {
 	if ($env{'browser.imagesuppress'} ne 'on') {
-	    $currentstring.=&Apache::lonenc::encrypt_ref($token,{'src'=>$src});
+	    my $enc = ('yes' eq 
+		       lc(&Apache::lonxml::get_param('encrypturl',$parstack,
+						     $safeeval)));
+	    $currentstring.=&Apache::lonenc::encrypt_ref($token,{'src'=>$src},
+							 $enc);
 	} else {
-	    my $alttag= &Apache::lonxml::get_param
-		('alt',$parstack,$safeeval,undef,1);
-	    unless ($alttag) {
-		$alttag=&Apache::lonmeta::alttag
-		    ($Apache::lonxml::pwd[-1],$src);
+	    my $alttag = &Apache::lonxml::get_param('alt',$parstack,$safeeval,
+						    undef,1);
+	    if (!$alttag) {
+		$alttag = &Apache::lonmeta::alttag($Apache::lonxml::pwd[-1],
+						   $src);
 	    }
 	    $currentstring.='[IMAGE: '.$alttag.']';
 	}
@@ -2902,6 +2906,8 @@
 						   ['','bottom','middle','top','left','right'],$token,5);
 	$currentstring .=&Apache::edit::select_arg('TeXwrap:', 'TeXwrap',
 						   ['', 'parbox', 'parpic'], $token, 2);
+	$currentstring .=&Apache::edit::select_arg('Encyrpt URL:','encrypturl',
+						   ['no','yes'], $token, 2);
 	$currentstring .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
 	my $src=    &Apache::lonxml::get_param('src',$parstack,$safeeval);
 	my $alt=    &Apache::lonxml::get_param('alt',$parstack,$safeeval);
@@ -2919,7 +2925,7 @@
 	my $ctag=&Apache::edit::get_new_args($token,$parstack,
 					     $safeeval,'src','alt','align',
 					     'TeXwidth','TeXheight', 'TeXwrap',
-					     'width','height');
+					     'width','height','encrypturl');
 	my ($nsrc,$nwidth,$nheight)=
 	    ($token->[2]{'src'},$token->[2]{'width'},$token->[2]{'height'});
 	my $loc=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$nsrc);