version 1.61, 2003/10/22 16:10:56
|
version 1.63, 2003/10/23 21:01:54
|
Line 76 sub versiontrack {
|
Line 76 sub versiontrack {
|
if ($uri=~/\.(\d+)\.\w+$/) { |
if ($uri=~/\.(\d+)\.\w+$/) { |
my $version=$1; |
my $version=$1; |
$uri=~s/\.\d+\.(\w+)$/\.$1/; |
$uri=~s/\.\d+\.(\w+)$/\.$1/; |
$hash{'version_'.$uri}=$version; |
unless ($hash{'version_'.$uri}) { |
|
$hash{'version_'.$uri}=$version; |
|
} |
} |
} |
return $uri; |
return $uri; |
} |
} |
Line 87 sub putinversion {
|
Line 89 sub putinversion {
|
my $uri=shift; |
my $uri=shift; |
if ($hash{'version_'.$uri}) { |
if ($hash{'version_'.$uri}) { |
my $version=$hash{'version_'.$uri}; |
my $version=$hash{'version_'.$uri}; |
|
if ($version eq 'current') { return $uri; } |
$uri=~s/\.(\w+)$/\.$version\.$1/; |
$uri=~s/\.(\w+)$/\.$version\.$1/; |
} |
} |
return $uri; |
return $uri; |
Line 101 sub processversionfile {
|
Line 104 sub processversionfile {
|
$cenv{'num'}); |
$cenv{'num'}); |
foreach (keys %versions) { |
foreach (keys %versions) { |
if ($_=~/^error\:/) { return; } |
if ($_=~/^error\:/) { return; } |
if ($versions{$_} eq 'current') { |
$hash{'version_'.$_}=$versions{$_}; |
delete $hash{'version_'.$_}; |
|
} else { |
|
$hash{'version_'.$_}=$versions{$_}; |
|
} |
|
} |
} |
} |
} |
|
|
Line 121 sub loadmap {
|
Line 120 sub loadmap {
|
$hash{'map_id_'.$lpc}=$uri; |
$hash{'map_id_'.$lpc}=$uri; |
|
|
# Determine and check filename |
# Determine and check filename |
my $fn=&Apache::lonnet::filelocation('',$uri); |
my $fn=&Apache::lonnet::filelocation('',&putinversion($uri)); |
|
|
my $ispage=($fn=~/\.page$/); |
my $ispage=($fn=~/\.page$/); |
|
|
Line 155 sub loadmap {
|
Line 154 sub loadmap {
|
|
|
$hash{'kind_'.$rid}='res'; |
$hash{'kind_'.$rid}='res'; |
$hash{'title_'.$rid}=$token->[2]->{'title'}; |
$hash{'title_'.$rid}=$token->[2]->{'title'}; |
# Rip out the version and store it separately |
|
my $turi=&versiontrack($token->[2]->{'src'}); |
my $turi=&versiontrack($token->[2]->{'src'}); |
# If there is an explicit version parameter, use that one |
|
if ($token->[2]->{'version'}) { |
if ($token->[2]->{'version'}) { |
$hash{'version_'.$turi}=$1; |
unless ($hash{'version_'.$turi}) { |
|
$hash{'version_'.$turi}=$1; |
|
} |
} |
} |
&Apache::lonnet::do_cache(\%Apache::lonnet::titlecache, |
&Apache::lonnet::do_cache(\%Apache::lonnet::titlecache, |
&Apache::lonnet::symbclean( |
&Apache::lonnet::encode_symb($uri,$token->[2]->{'id'}, |
&Apache::lonnet::declutter($uri).'___'. |
$turi), |
$token->[2]->{'id'}.'___'. |
$token->[2]->{'title'},'title'); |
&Apache::lonnet::declutter($turi)), |
|
$token->[2]->{'title'}); |
|
unless ($ispage) { |
unless ($ispage) { |
$turi=~/\.(\w+)$/; |
$turi=~/\.(\w+)$/; |
my $embstyle=&Apache::loncommon::fileembstyle($1); |
my $embstyle=&Apache::loncommon::fileembstyle($1); |
Line 268 sub loadmap {
|
Line 265 sub loadmap {
|
# ------------------------------------------------------------------- Parameter |
# ------------------------------------------------------------------- Parameter |
|
|
my $referid=$lpc.'.'.$token->[2]->{'to'}; |
my $referid=$lpc.'.'.$token->[2]->{'to'}; |
my $part=$token->[2]->{'part'}; |
my $name=$token->[2]->{'name'}; |
unless ($part) { $part=0; } |
my $part; |
|
if ($name=~/^parameter_(.*)_/) { |
|
$part=$1; |
|
} else { |
|
$part=0; |
|
} |
|
$name=~s/^.*_([^_]*)$/$1/; |
my $newparam= |
my $newparam= |
&Apache::lonnet::escape($token->[2]->{'type'}).':'. |
&Apache::lonnet::escape($token->[2]->{'type'}).':'. |
&Apache::lonnet::escape($part.'.'. |
&Apache::lonnet::escape($part.'.'.$name).'='. |
$token->[2]->{'name'}).'='. |
|
&Apache::lonnet::escape($token->[2]->{'value'}); |
&Apache::lonnet::escape($token->[2]->{'value'}); |
if (defined($hash{'param_'.$referid})) { |
if (defined($hash{'param_'.$referid})) { |
$hash{'param_'.$referid}.='&'.$newparam; |
$hash{'param_'.$referid}.='&'.$newparam; |
Line 534 sub readmap {
|
Line 536 sub readmap {
|
%parmhash=(); |
%parmhash=(); |
$errtext=''; |
$errtext=''; |
$pc=0; |
$pc=0; |
|
&processversionfile(%cenv); |
my $furi=&Apache::lonnet::clutter($uri); |
my $furi=&Apache::lonnet::clutter($uri); |
$hash{'src_0.0'}=&versiontrack($furi); |
$hash{'src_0.0'}=&versiontrack($furi); |
$hash{'title_0.0'}=&Apache::lonnet::metadata($uri,'title'); |
$hash{'title_0.0'}=&Apache::lonnet::metadata($uri,'title'); |
Line 545 sub readmap {
|
Line 548 sub readmap {
|
&accinit($uri,$short,$fn); |
&accinit($uri,$short,$fn); |
&pickrandom(); |
&pickrandom(); |
} |
} |
# ------------------------------------------------------------ Version tracking |
# ------------------------------------------------------- Put versions into src |
&processversionfile(%cenv); |
|
foreach (keys %hash) { |
foreach (keys %hash) { |
if ($_=~/^src\_/) { |
if ($_=~/^src\_/) { |
$hash{$_}=&putinversion($hash{$_}); |
$hash{$_}=&putinversion($hash{$_}); |