version 1.63, 2008/12/01 19:12:37
|
version 1.68.6.1, 2012/05/02 19:10:13
|
Line 86 sub update_actions_hash {
|
Line 86 sub update_actions_hash {
|
sub readfromdb { |
sub readfromdb { |
my ($r,$resources)=@_; |
my ($r,$resources)=@_; |
|
|
my $diropendb = |
my $diropendb = LONCAPA::tempdir() . |
"/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_sel_res.db"; |
"$env{'user.domain'}_$env{'user.name'}_sel_res.db"; |
|
|
# ----------------------------- diropendb is now the filename of the db to open |
# ----------------------------- diropendb is now the filename of the db to open |
if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) { |
if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) { |
Line 191 sub readfrombookmarks {
|
Line 191 sub readfrombookmarks {
|
my @bookmarks=($bookmarks{'bookmarks'}=~/\((?:\'([^\']+)\'\,\'([^\']+)\'|\"([^\"]+)\"\,\"([^\"]+)\")\)\;/g); |
my @bookmarks=($bookmarks{'bookmarks'}=~/\((?:\'([^\']+)\'\,\'([^\']+)\'|\"([^\"]+)\"\,\"([^\"]+)\")\)\;/g); |
for (my $index=0;$index<($#bookmarks+1)/2;$index++) { |
for (my $index=0;$index<($#bookmarks+1)/2;$index++) { |
if ($bookmarks[$index*2+1]) { |
if ($bookmarks[$index*2+1]) { |
my $url = $bookmarks[$index*2+1]; |
my $url = $bookmarks[$index*2+1]; |
my $name = $bookmarks[$index*2]; |
my $name = $bookmarks[$index*2]; |
$name =~ s/^LON\-CAPA\s+//; |
$name =~ s/^LON\-CAPA\s+//; |
|
|
push(@{$resources},{'url' => $url, 'title' => $name}); |
push(@{$resources},{'url' => $url, 'title' => $name}); |
} |
} |
} |
} |
} |
} |
|
|
Line 300 END
|
Line 300 END
|
if ($env{'form.readfile'}) { |
if ($env{'form.readfile'}) { |
&readfromfile($r,\@resources); |
&readfromfile($r,\@resources); |
} elsif ($env{'form.bookmarks'}) { |
} elsif ($env{'form.bookmarks'}) { |
&readfrombookmarks($r,\@resources); |
&readfrombookmarks($r,\@resources); |
} else { |
} else { |
&readfromdb($r,\@resources); |
&readfromdb($r,\@resources); |
} |
} |
|
|
my $ctr = 0; |
my $ctr = 0; |
my $clen = scalar(@resources); |
my $clen = scalar(@resources); |
|
my $title = ''; |
|
if ($env{'form.recover'}) { |
|
$title = 'Recover Removed Resources'; |
|
} else { |
|
$title = 'Sort Imported Resources'; |
|
} |
|
if ($env{'form.bookmarks'}) { |
|
$title = 'Import Resources from Bookmarks'; |
|
} |
if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) { |
if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) { |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'fin'=> 'Finalize order of resources', |
'fin'=> 'Finalize order of resources', |
Line 314 END
|
Line 323 END
|
'cs' => 'Continue Search', |
'cs' => 'Continue Search', |
'fi' => 'Finish Import', |
'fi' => 'Finish Import', |
're' => 'Recover Checked', |
're' => 'Recover Checked', |
|
'ip' => 'Import Checked', |
'ca' => 'Cancel', |
'ca' => 'Cancel', |
'co' => 'Change Order', |
'co' => 'Change Order', |
'ti' => 'Title', |
'ti' => 'Title', |
'pa' => 'Path', |
'pa' => 'Path', |
'in' => 'Include' |
'in' => 'Include' |
); |
); |
my $title = ($env{'form.recover'}) ? 'Recover Removed Resources' |
|
: 'Sort Imported Resources'; |
|
$r->print(&Apache::loncommon::start_page($title, $js)); |
$r->print(&Apache::loncommon::start_page($title, $js)); |
|
$r->print('<h1>'.&mt($title).'</h1>'); |
|
|
$r->print(<<END); |
$r->print(<<END); |
<form method='post' action='/adm/groupsort' name='groupsort' |
<form method='post' action='/adm/groupsort' name='groupsort' |
Line 338 END
|
Line 348 END
|
|
|
$r->print(&Apache::loncommon::inhibit_menu_check('input')); |
$r->print(&Apache::loncommon::inhibit_menu_check('input')); |
# --- |
# --- |
|
|
if ($env{'form.recover'}) { |
my $buttontext = $lt{'re'}; |
|
if ($env{'form.bookmarks'}) { |
|
$buttontext = $lt{'ip'} |
|
} |
|
if ($env{'form.recover'} || $env{'form.bookmarks'}) { |
$r->print(<<END); |
$r->print(<<END); |
<input type="button" name="alter" value="$lt{'re'}" |
<input type="button" name="alter" value="$buttontext" |
onClick="finish_import()" /> |
onClick="finish_import()" /> |
<input type="button" name="alter" value="$lt{'ca'}" onClick="self.close()" /> |
<input type="button" name="alter" value="$lt{'ca'}" onClick="self.close()" /> |
END |
END |
Line 363 END
|
Line 377 END
|
<br /> |
<br /> |
END |
END |
} |
} |
$r->print(&Apache::loncommon::start_data_table() |
|
.&Apache::loncommon::start_data_table_header_row()); |
# Only display header if content exists |
if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) { |
if ($clen > 0) { |
$r->print("<th>$lt{'in'}</th>\n"); |
$r->print(&Apache::loncommon::start_data_table() |
} else { |
.&Apache::loncommon::start_data_table_header_row()); |
$r->print("<th colspan='2'>$lt{'co'}</th>\n"); |
if (($env{'form.readfile'})) { |
} |
$r->print("<th>$lt{'in'}</th>\n"); |
$r->print("<th colspan='2'>$lt{'ti'}</th>\n"); |
} else { |
$r->print("<th>$lt{'pa'}</th>"); |
$r->print('<th colspan="2">'.$lt{'co'}.'</th>'."\n"); |
$r->print(&Apache::loncommon::end_data_table_header_row() |
} |
."\n"); |
$r->print('<th colspan="2">'.$lt{'ti'}.'</th>'."\n"); |
|
$r->print("<th>$lt{'pa'}</th>"); |
|
$r->print(&Apache::loncommon::end_data_table_header_row()."\n"); |
|
} else { |
|
my $errtxt = ''; |
|
if ($env{'form.recover'}) { |
|
$errtxt = 'There are no resources to recover.'; |
|
} else { |
|
$errtxt = 'There are no resources to import.'; |
|
} |
|
if ($env{'form.bookmarks'}) { |
|
$errtxt = 'There are no resources in your bookmarks to import.'; |
|
} |
|
$r->print('<p class="LC_info">'.&mt($errtxt).'</p>'); |
|
} |
} else { |
} else { |
$r->print(&Apache::loncommon::start_page(undef,$js, |
$r->print(&Apache::loncommon::start_page(undef,$js, |
{'only_body' => 1})); |
{'only_body' => 1})); |
|
# $r->print('<h1>'.&mt($title).'</h1>'); |
$r->print(<<END); |
$r->print(<<END); |
<form method='post' action='/adm/groupsort' name='groupsort' |
<form method='post' action='/adm/groupsort' name='groupsort' |
enctype='application/x-www-form-urlencoded'> |
enctype='application/x-www-form-urlencoded'> |
Line 391 END
|
Line 420 END
|
foreach my $resource (@resources) { |
foreach my $resource (@resources) { |
$ctr++; |
$ctr++; |
my $iconname=&Apache::loncommon::icon($resource->{'url'}); |
my $iconname=&Apache::loncommon::icon($resource->{'url'}); |
if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) { |
if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) { |
$r->print(&Apache::loncommon::start_data_table_row() |
$r->print(&Apache::loncommon::start_data_table_row() |
."<td>"); |
."<td>"); |
if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) { |
if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) { |
Line 419 END
|
Line 448 END
|
} |
} |
} |
} |
if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) { |
if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) { |
$r->print(&Apache::loncommon::end_data_table() |
if ($clen > 0) { |
."</form>"); |
$r->print(&Apache::loncommon::end_data_table()); |
|
} |
|
$r->print('</form>'); |
} else { |
} else { |
$r->print(<<END); |
$r->print(<<END); |
<script type="text/javascript"> |
<script type="text/javascript"> |