' + .&mt('You are working with an unsaved version of your map.') + .'
'; + my ($errtext,$fatal)=&LONCAPA::map::mapread($tmpfn,''); } + $errtext = ''.$errtext.'
' if ($errtext); # ---------------------------------------------------------- Process form input my @importselect=&Apache::loncommon::get_env_multiple('form.importsel'); @@ -871,8 +392,8 @@ sub smpedt { &Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) { my ($name,$url)=split(/\:/,$_); if ($url) { - $importdetail.='&'.&Apache::lonnet::escape($name).'='. - &Apache::lonnet::escape($url); + $importdetail.='&'.&escape($name).'='. + &escape($url); } } @@ -891,10 +412,10 @@ sub smpedt { if (defined($targetselect[-1])) { $lastsel=$targetselect[-1]; } else { - $lastsel=$#order+1; + $lastsel=$#LONCAPA::map::order+1; } - &pastetarget($lastsel,split(/\&/,$env{'form.importdetail'})); - &storemap(&Apache::lonnet::filelocation('',$url)); + &LONCAPA::map::pastetarget($lastsel,split(/\&/,$env{'form.importdetail'})); + &LONCAPA::map::storemap(&Apache::lonnet::filelocation('',$url)); # ------------------------------------------------------------------------- Cut } elsif (($env{'form.cut'}) || ($env{'form.copy'})) { $importdetail=''; @@ -916,10 +437,10 @@ sub smpedt { } foreach (@targetselect) { - my ($name,$url)=split(/\:/,$resources[$order[$_-1]]); + my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$LONCAPA::map::order[$_-1]]); if ($url) { - $importdetail.='&'.&Apache::lonnet::escape($name).'='. - &Apache::lonnet::escape($url); + $importdetail.='&'.&escape($name).'='. + &escape($url); } } @@ -934,19 +455,19 @@ sub smpedt { if ($env{'form.cut'}) { my @neworder=(); - for (my $i=0;$i<=$#order;$i++) { + for (my $i=0;$i<=$#LONCAPA::map::order;$i++) { my $include=1; foreach (@targetselect) { if ($_-1==$i) { $include=0; } } if ($include) { - $neworder[$#neworder+1]=$order[$i]; + $neworder[$#neworder+1]=$LONCAPA::map::order[$i]; } else { - &makezombie($order[$i]); + &LONCAPA::map::makezombie($LONCAPA::map::order[$i]); } } - @order=@neworder; - &storemap(&Apache::lonnet::filelocation('',$url)); + @LONCAPA::map::order=@neworder; + &LONCAPA::map::storemap(&Apache::lonnet::filelocation('',$url)); } # ----------------------------------------------------------------------- Paste @@ -955,43 +476,43 @@ sub smpedt { if (defined($targetselect[-1])) { $lastsel=$targetselect[-1]; } else { - $lastsel=$#order+1; + $lastsel=$#LONCAPA::map::order+1; } my @newsequence; my @curimport=split(/\&/,$env{'form.curimpdetail'}); foreach (@importselect) { $newsequence[$#newsequence+1]=$curimport[$_]; } - &pastetarget($lastsel,@newsequence); - &storemap(&Apache::lonnet::filelocation('',$url)); + &LONCAPA::map::pastetarget($lastsel,@newsequence); + &LONCAPA::map::storemap(&Apache::lonnet::filelocation('',$url)); # -------------------------------------------------------------------- Move up } elsif ($env{'form.moveup'}) { foreach (sort @targetselect) { if ($_-1>0) { - my $movethis=$order[$_-1]; - $order[$_-1]=$order[$_-2]; - $order[$_-2]=$movethis; + my $movethis=$LONCAPA::map::order[$_-1]; + $LONCAPA::map::order[$_-1]=$LONCAPA::map::order[$_-2]; + $LONCAPA::map::order[$_-2]=$movethis; } } - &storemap(&Apache::lonnet::filelocation('',$url)); + &LONCAPA::map::storemap(&Apache::lonnet::filelocation('',$url)); # ------------------------------------------------------------------ Move down } elsif ($env{'form.movedown'}) { foreach (reverse sort @targetselect) { - if ($_-1<$#order) { - my $movethis=$order[$_-1]; - $order[$_-1]=$order[$_]; - $order[$_]=$movethis; + if ($_-1<$#LONCAPA::map::order) { + my $movethis=$LONCAPA::map::order[$_-1]; + $LONCAPA::map::order[$_-1]=$LONCAPA::map::order[$_]; + $LONCAPA::map::order[$_]=$movethis; } } - &storemap(&Apache::lonnet::filelocation('',$url)); + &LONCAPA::map::storemap(&Apache::lonnet::filelocation('',$url)); # --------------------------------------------------------------------- Rename } elsif ($env{'form.renameres'}) { - my $residx=$Apache::lonratedt::order[$env{'form.renameidx'}-1]; - my ($name,@resrest)=split(/\:/,$Apache::lonratedt::resources[$residx]); + my $residx=$LONCAPA::map::order[$env{'form.renameidx'}-1]; + my ($name,@resrest)=split(/\:/,$LONCAPA::map::resources[$residx]); $name=$env{'form.renametitle'}; $name=~s/\:/\&colon\;/g; - $Apache::lonratedt::resources[$residx]=$name.':'.join(':',@resrest); - &storemap(&Apache::lonnet::filelocation('',$url)); + $LONCAPA::map::resources[$residx]=$name.':'.join(':',@resrest); + &LONCAPA::map::storemap(&Apache::lonnet::filelocation('',$url)); } # ------------------------------------------------------------ Assemble windows @@ -1006,7 +527,7 @@ sub smpedt { my ($name,$url)=split(/\=/,$_); unless ($name) { $name=(split(/\//,$url))[-1]; } unless ($name) { $name='EMPTY'; } - ''; } } split(/\&/,$importdetail)); @@ -1016,24 +537,28 @@ sub smpedt { my $targetwindow= ''. join("\n",map { - my ($name,$url)=split(/\:/,$resources[$_]); + my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$_]); unless ($name) { $name=(split(/\//,$url))[-1]; } unless ($name) { $name='EMPTY'; } - $targetdetail.='&'.&Apache::lonnet::escape($name).'='. - &Apache::lonnet::escape($url); + $name = &LONCAPA::map::qtescape($name); + $url = &LONCAPA::map::qtescape($url); + $targetdetail.='&'.&escape($name).'='. + &escape($url); $idx++; - $name=~s/\:/\:/g; + $name = &HTML::Entities::encode($name,'\'"<>&'); ''; - } @order); + } @LONCAPA::map::order); # ----------------------------------------------------- Start simple RAT screen my $editscript=&editscript('simple'); my %lt=&Apache::lonlocal::texthash( + 'sm' => 'Select Map', 'sa' => 'Save', 'nt' => 'New Title', 'se' => 'Search', 'im' => 'Import', + 'wl' => 'Import from Stored Links', 'vi' => 'View', 'lm' => 'Load Map', 'ds' => 'Discard Selected', @@ -1050,16 +575,12 @@ sub smpedt { 'pas' => 'Paste after selected', 'reco' => 'Recover Deleted' ); - my $js=<' + .&mt('No such directory: [_1]',''.$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)); + + &Apache::lonhtmlcommon::clear_breadcrumbs(); + &Apache::lonhtmlcommon::add_breadcrumb({ + text => 'Authoring Space', + href => &Apache::loncommon::authorspace($url), + faq => 6, + bug => 'RAT', + help => 'Sequence_Simple_Editor_Creation',}); + &Apache::lonhtmlcommon::add_breadcrumb({ + text => 'RAT', + title => 'Resource Assembly Tool', + href => '',}); + + # Breadcrumbs are included by &start_page + $r->print(&Apache::loncommon::start_page('Edit Content of a Map') + .&Apache::loncommon::head_subbox( + &Apache::loncommon::CSTR_pageheader() + .&buttons($adv)) + ); if ($errtext) { - $r->print($errtext.''.$url.'
'); if ($adv) { - $r->print(''.&mt('Map contents are not shown in order.').'
'.&mt('Type').' | '. - ''.&mt('Title in map').' | '. - ''.&mt('Filename of resource').' | '. - ''.&mt('Link to published resource').' | '. - ''.&mt('Link to resource in Construction Space').' | '. - ''.&mt('Type').' | ' + .''.&mt('Title in map').' | ' + .''.&mt('Filename of resource').' | ' + .''.&mt('Link to published resource').' | ' + .''.&mt('Link to resource in Authoring 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=~s/\&colon\;/\:/g; - $url=~s/\&colon\;/\:/g; + $title= &LONCAPA::map::qtescape($title); + $url = &LONCAPA::map::qtescape($url); unless ($title) { $title=(split(/\//,$url))[-1] }; unless ($title) { $title=''.&mt('Empty').''; } - my $resurl = &Apache::lonratsrv::qtescape($url); + 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/#; - my $bgcol = $idx%2; - $r->print('
---|---|---|---|---|---|---|---|---|
'. - ' | '.&Apache::lonratsrv::qtescape($title). - ' | '.$filename.' | '); + $cstrurl =~ s{^/res/}{/priv/}; + $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').''); + &mt('Authoring Space').''); + } else { + $r->print(' '); } - $r->print(' |