'.&mt('You have selected the red marked entries to be moved to another folder. '. + 'Now choose the new destination folder.').'
'; &wishlistMove(\@childrenRt, $marked); $inner .= ''.&mt("You haven't marked any entry to move.").'
'. ''; } } @@ -1199,7 +1602,7 @@ sub makePage { # end_page my $endPage = &Apache::loncommon::end_page(); - # put all page-elements togther + # put all page-elements together my $page = $startPage.$breadcrumbs.$js.$inner.$endPage; return $page; @@ -1223,13 +1626,68 @@ sub makePageSet { # end_page my $endPage = &Apache::loncommon::end_page(); - # put all page-elements togther + # put all page-elements together my $page = $startPage.$inner.$endPage; return $page; } +# Returns the HTML-Markup for the page, shown when links should be imported into a course +sub makePageImport { + my $rat = shift; + # start_page + my $startPage = &Apache::loncommon::start_page('Wishlist',undef, + {'only_body' => 1}); + + # get javascript-code for wishlist-interactions + my $js = &JSforWishlist(); + $js .= &JSforImport($rat); + + my $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; + + $inner .= ''; + + # end_page + my $endPage = &Apache::loncommon::end_page(); + + # put all page-elements together + my $page = $startPage.$js.$inner.$endPage; + + return $page; +} + + # Returns the HTML-Markup for error-page sub makeErrorPage { # breadcrumbs and start_page @@ -1238,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 @@ -1250,7 +1705,7 @@ sub makeErrorPage { # end_page my $endPage = &Apache::loncommon::end_page(); - # put all page-elements togther + # put all page-elements together my $page = $startPage.$breadcrumbs.$inner.$endPage; return $page; @@ -1274,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; @@ -1324,9 +1779,12 @@ sub handler { # only save, if user wants to save changes # do not save, when current action is 'delete' or 'sort' or 'move' my @newTitles = (); + my @newPaths = (); my @newNotes = (); - if ((defined $env{'form.newtitle'} || defined $env{'form.newnote'}) && ($env{'form.action'} ne 'noSave') && ($env{'form.action'} ne 'delete') && !$changeOrder) { + if ((defined $env{'form.newtitle'} || defined $env{'form.newpath'} || defined $env{'form.newnote'}) + && ($env{'form.action'} ne 'noSave') && ($env{'form.action'} ne 'delete') && !$changeOrder) { @newTitles = &Apache::loncommon::get_env_multiple('form.newtitle'); + @newPaths = &Apache::loncommon::get_env_multiple('form.newpath'); @newNotes = &Apache::loncommon::get_env_multiple('form.newnote'); my $node = 0; foreach my $t (@newTitles) { @@ -1334,6 +1792,14 @@ sub handler { $node++; } $node = 0; + my $path = 0; + for (my $i = 0; $i < ($#newTitles+1); $i++ ) { + if (&setNewPath($node, $newPaths[$path])) { + $path++; + } + $node++; + } + $node = 0; foreach my $n (@newNotes) { &setNewNote($node, $n); $node++; @@ -1349,6 +1815,9 @@ sub handler { elsif ($env{'form.mode'} eq 'move') { $page = &makePage("move", \@marked); } + elsif ($env{'form.mode'} eq 'import') { + $page = &makePageImport($env{'form.rat'}); + } elsif ($env{'form.mode'} eq 'set') { $page = &makePageSet(); } @@ -1370,6 +1839,65 @@ sub handler { # Extend CPAN-Module Tree by function like 'moveNode' or 'deleteNode' package Tree; +=pod + +=head2 Routines from package Tree + +=over 4 + +=item * &getNodeByIndex(index, nodes) + + Searches for a node, specified by the index, in nodes (reference to array) and returns it. + + +=item * &moveNode(node, at, newParent) + + Moves a given node to a new parent (if new parents is defined) or change the position from a node within its siblings (means sorting, at must be defined). + + +=item * &removeNode(node) + + Removes a node given by node from the tree. + + +=item * &TreeIndex(children) + + Sets an index for every node in the tree, beginning with 0. + Recursive call starting with all children of the root of the tree (parameter children is reference to an array containing the nodes of the current level). + + +=item * &setCountZero() + + Resets index counter. + + +=item * &RootToHash(childrenRt) + + Converts the root-node to a hash-entry: the key is root and values are just the indices of root's children. + + +=item * &TreeToHash(childrenRt) + + Converts all other nodes in the tree to hash. Each node is one hash-entry where the keys are the index of a node and the values are all other attributes (containing tile, path, note, date and indices for all direct children). + Recursive call starting with all children of the root of the tree (parameter childrenRT is reference to an array containing the nodes of the current level). + + +=item * &HashToTree() + + Converts the hash to a tree. Builds a tree-object for each entry in the hash. Afterwards call &buildTree(node, childrenIn, TreeNodes, TreeHash) to connect the tree-objects. + + +=item * &buildTree(node, childrenIn, TreeNodes, TreeHash) + + Joins the nodes to a tree. + Recursive call starting with root and all children of root (parameter childrenIn is reference to an array containing the nodes indices of the current level). + + +=back + +=cut + + # returns the node with a given index from a list of nodes sub getNodeByIndex { my $index = shift; @@ -1499,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], @@ -1518,7 +2046,7 @@ sub HashToTree { } } # if there are nodes, build up the tree-structure - if (defined $TreeHash{'root'}) { + if (defined $TreeHash{'root'} && $TreeHash{'root'} ne '') { my @childrenRtIn = @{ $TreeHash{'root'} }; &buildTree(\$root, \@childrenRtIn,\@TreeNodes,\%TreeHash); }