--- loncom/interface/lonwishlist.pm 2010/08/16 15:14:37 1.4
+++ loncom/interface/lonwishlist.pm 2010/08/25 12:38:45 1.8
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the wishlist
#
-# $Id: lonwishlist.pm,v 1.4 2010/08/16 15:14:37 wenzelju Exp $
+# $Id: lonwishlist.pm,v 1.8 2010/08/25 12:38:45 wenzelju Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -61,6 +61,7 @@ my %TreeToHash;
my @allFolders;
my @allNodes;
my $indentConst = 20;
+my $foldersOption;
=pod
@@ -70,7 +71,7 @@ my $indentConst = 20;
=item * &getWishlist()
- Get the wishlist-data via lonnet::dump() and returns the got data in a hash.
+ Get the wishlist-data via lonnet::getkeys() and lonnet::get() and returns the got data in a hash.
=item * &putWishlist(wishlist)
@@ -90,14 +91,18 @@ my $indentConst = 20;
# Read wishlist from user-data
sub getWishlist {
- my %wishlist = &Apache::lonnet::dump('wishlist');
+ my @keys = &Apache::lonnet::getkeys('wishlist');
+ my %wishlist = &Apache::lonnet::get('wishlist',\@keys);
foreach my $i ( keys %wishlist) {
#File not found. This appears at the first time using the wishlist
#Create file and put 'root' into it
if ($i =~m/^error:No such file/) {
&Apache::lonnet::logthis($i.'! Create file by putting in the "root" of the directory tree.');
&Apache::lonnet::put('wishlist', {'root' => ''});
- %wishlist = &Apache::lonnet::dump('wishlist');
+ my $options = '';
+ &Apache::lonnet::put('wishlist', {'folders' => $options});
+ @keys = &Apache::lonnet::getkeys('wishlist');
+ %wishlist = &Apache::lonnet::get('wishlist',\@keys);
}
elsif ($i =~ /^(con_lost|error|no_such_host)/i) {
&Apache::lonnet::logthis('ERROR while attempting to get wishlist: '.$i);
@@ -105,7 +110,7 @@ sub getWishlist {
}
}
- # if we got no keys in hash returned by dump(), return error.
+ # if we got no keys in hash returned by get(), return error.
# wishlist will not be loaded, instead the user will be asked to try again later
if ((keys %wishlist) == 0) {
&Apache::lonnet::logthis('ERROR while attempting to get wishlist: no keys retrieved!');
@@ -119,6 +124,11 @@ sub getWishlist {
# Write wishlist to user-data
sub putWishlist {
my $wishlist = shift;
+ $foldersOption = '';
+ &getFoldersForOption(\@childrenRt);
+ my $options = ''.$foldersOption;
+ $foldersOption = '';
+ $$wishlist{'folders'} = $options;
&Apache::lonnet::put('wishlist',$wishlist);
}
@@ -327,11 +337,6 @@ sub saveChanges {
Recursive call starting with all children of the root of the tree (parameter nodes is reference to an array containing the nodes of the current level).
-=item * &getfoldersOption()
-
- Returns the option-tag build by &getFoldersForOption(nodes). Use it to transfer this to other modules (e.g. lonmenu.pm).
-
-
=item * &getFoldersToArray(children)
Puts all nodes that represent folders in the wishlist into an array.
@@ -352,7 +357,6 @@ sub saveChanges {
# Return the names for all exiting folders in option-tags, so
# a new link or a new folder can be created in an existing folder
my $indent = 0;
-my $foldersOption;
sub getFoldersForOption {
my $nodes = shift;
@@ -373,22 +377,6 @@ sub getFoldersForOption {
}
-sub getfoldersOption {
- if (&getWishlist ne 'error') {
- %TreeHash = &getWishlist();
- $root = &Tree::HashToTree();
- @childrenRt = $root->children();
- &getFoldersForOption(\@childrenRt);
- my $options = ''.$foldersOption;
- $foldersOption = '';
- return $options;
- }
- else {
- return '';
- }
-}
-
-
# Put all folder-nodes to an array
sub getFoldersToArray {
my $children = shift;
@@ -637,6 +625,9 @@ sub JSforWishlist {
else if (action == 'saveOK') {
r = linksOK();
}
+ else if (action == 'move') {
+ r = selectDestinationFolder();
+ }
document.getElementsByName('list')[0].setAttribute("action", "/adm/wishlist?mode="+mode);
if (r) {
document.getElementsByName('list')[0].submit();
@@ -1063,20 +1054,6 @@ sub JSforWishlist {
newWin.focus();
}
- function finish_import() {
- opener.document.forms.simpleedit.importdetail.value='';
- for (var num = 0; num < document.forms.groupsort.fnum.value; num++) {
- if (eval("document.forms.groupsort.check"+num+".checked") && eval("document.forms.groupsort.filelink"+num+".value") != '') {
- opener.document.forms.simpleedit.importdetail.value+='&'+
- eval("document.forms.groupsort.title"+num+".value")+'='+
- eval("document.forms.groupsort.filelink"+num+".value")+'='+
- eval("document.forms.groupsort.id"+num+".value");
- }
- }
- opener.document.forms.simpleedit.submit();
- self.close();
- }
-
function checkAll() {
var checkboxes = document.getElementsByName('check');
for (var i = 0; i < checkboxes.length; i++) {
@@ -1095,6 +1072,68 @@ JAVASCRIPT
return $js;
}
+sub JSforImport{
+ my $rat = shift;
+
+ my $js;
+ if ($rat eq 'simple' || $rat eq '') {
+ $js = &Apache::lonhtmlcommon::scripttag(<
'.&mt("Please note that you can use the checkboxes corresponding to a folder to ". - "easily check all links within this folder. The folder structure itself can't be imported. ". - "All checked links will be imported into the current folder of your course.").'
'; - + if (!$rat) { + $inner .= ''.&mt("Please note that you can use the checkboxes corresponding to a folder to ". + "easily check all links within this folder. The folder structure itself can't be imported. ". + "All checked links will be imported into the current folder of your course.").'
'; + } + else { + $inner .= ''.&mt("Please note that you can use the checkboxes corresponding to a folder to ". + "easily check all links within this folder. The folder structure itself can't be imported. ") + .'
'; + } my %wishlist = &getWishlist(); my $fnum = (keys %wishlist)-1; @@ -1649,10 +1696,7 @@ sub makeErrorPage { text => 'Wishlist'}); my $startPage = &Apache::loncommon::start_page('Wishlist'); - my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Wishlist '. - ''. - ''); + my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(&mt('Wishlist').&Apache::loncommon::help_open_topic('Wishlist')); &Apache::lonhtmlcommon::clear_breadcrumbs(); # error-message @@ -1685,7 +1729,7 @@ sub handler { } # get unprocessed_cgi (i.e. marked entries, mode ...) - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','mark','markedToMove','mode','newtitle','note']); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','mark','markedToMove','mode','newtitle','note','rat']); # change the order of entries within a level, that means sorting the entries my $changeOrder = 0; @@ -1772,7 +1816,7 @@ sub handler { $page = &makePage("move", \@marked); } elsif ($env{'form.mode'} eq 'import') { - $page = &makePageImport(); + $page = &makePageImport($env{'form.rat'}); } elsif ($env{'form.mode'} eq 'set') { $page = &makePageSet(); @@ -1983,7 +2027,7 @@ sub HashToTree { if ($key eq 'root') { $root = Tree->new("root"); } - else { + elsif ($key ne 'folders') { my @attributes = @{ $TreeHash{$key} }; my $tmpNode; $tmpNode = Tree->new(Entry->new(title=>$attributes[0],