$errtext
$end_page
ENDSMPHEAD
}
# ----------------------------------------------------------------- No such dir
sub nodir {
my ($r,$dir)=@_;
$dir=~s{^/home/$LONCAPA::username_re/public_html}{};
$r->print(&Apache::loncommon::start_page(undef,undef,
{'only_body' => 1,
'bgcolor' => '#FFFFFF',}).
"No such directory: $dir
".
&Apache::loncommon::end_page());
}
# ---------------------------------------------------------------- View Handler
sub viewmap {
my ($r,$url,$adv,$errtext)=@_;
$r->print(
&Apache::loncommon::start_page('Edit Content of a Map').
&Apache::loncommon::help_open_menu('','',6,'RAT').
&buttons($adv));
if ($errtext) {
$r->print(''
.$errtext
.'
'
.'
'
);
}
my $idx=0;
$r->print(''.$url.'
');
if ($adv) {
$r->print(''
.&mt('Map contents are not shown in order.')
.'
'
);
}
$r->print(&Apache::loncommon::start_data_table()
.&Apache::loncommon::start_data_table_header_row()
.''.&mt('Type').' | '
.''.&mt('Title in map').' | '
.''.&mt('Filename of resource').' | '
.''.&mt('Link to published resource').' | '
.''.&mt('Link to resource in Construction Space').' | '
.&Apache::loncommon::end_data_table_header_row()
);
foreach (&LONCAPA::map::attemptread(&Apache::lonnet::filelocation('',$url))) {
if (defined($_)) {
$idx++;
my ($title,$url,$cond)=split(/\:/,$_);
if ($cond eq 'cond') { next; }
$title= &LONCAPA::map::qtescape($title);
$url = &LONCAPA::map::qtescape($url);
unless ($title) { $title=(split(/\//,$url))[-1] };
unless ($title) { $title=''.&mt('Empty').''; }
my $resurl = $url;
my $resfilepath = $Apache::lonnet::perlvar{'lonDocRoot'}.$resurl;
my $filename;
if ($resurl =~ m#/([^/]+)$#) {
$filename = $1;
}
my $cstrurl = $resurl;
$cstrurl =~ s#^/res/[^/]+/([^/]+)/#/priv/$1/#;
$r->print(&Apache::loncommon::start_data_table_row()
.''
.''
.' | '
.''
.&HTML::Entities::encode(&LONCAPA::map::qtescape($title))
.' | '
.''.$filename.' | '
.''
);
if ($url) {
$r->print(''.&mt('Resource space').'');
} else {
$r->print(' ');
}
$r->print(' | ');
if ($url) {
$r->print(''.
&mt('Construction space').'');
} else {
$r->print(' ');
}
$r->print(' | '
.&Apache::loncommon::end_data_table_row()
);
}
}
$r->print(&Apache::loncommon::end_data_table());
$r->print(&Apache::loncommon::end_page());
}
# ================================================================ Main Handler
sub handler {
my $r=shift;
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
return OK if $r->header_only;
my $target = $env{'form.grade_target'};
if ($target eq 'meta') {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
return OK;
}
my $url=$r->uri;
my $fn=&Apache::lonnet::filelocation('',$url);
my ($dir)=($fn=~/^(.+)\/[^\/]+$/);
unless (-e $dir) {
&nodir($r,$dir);
return OK;
}
# ------------------------------------------- Determine which tools can be used
my $adv=0;
unless ($env{'form.forcesmp'}) {
if ($env{'form.forceadv'}) {
$adv=1;
} elsif (my $fh=Apache::File->new($fn)) {
my $allmap=join('',<$fh>);
$adv=($allmap=~/\