version 1.4, 2010/08/16 15:14:37
|
version 1.8, 2010/08/25 12:38:45
|
Line 61 my %TreeToHash;
|
Line 61 my %TreeToHash;
|
my @allFolders; |
my @allFolders; |
my @allNodes; |
my @allNodes; |
my $indentConst = 20; |
my $indentConst = 20; |
|
my $foldersOption; |
|
|
=pod |
=pod |
|
|
Line 70 my $indentConst = 20;
|
Line 71 my $indentConst = 20;
|
|
|
=item * &getWishlist() |
=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) |
=item * &putWishlist(wishlist) |
Line 90 my $indentConst = 20;
|
Line 91 my $indentConst = 20;
|
|
|
# Read wishlist from user-data |
# Read wishlist from user-data |
sub getWishlist { |
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) { |
foreach my $i ( keys %wishlist) { |
#File not found. This appears at the first time using the wishlist |
#File not found. This appears at the first time using the wishlist |
#Create file and put 'root' into it |
#Create file and put 'root' into it |
if ($i =~m/^error:No such file/) { |
if ($i =~m/^error:No such file/) { |
&Apache::lonnet::logthis($i.'! Create file by putting in the "root" of the directory tree.'); |
&Apache::lonnet::logthis($i.'! Create file by putting in the "root" of the directory tree.'); |
&Apache::lonnet::put('wishlist', {'root' => ''}); |
&Apache::lonnet::put('wishlist', {'root' => ''}); |
%wishlist = &Apache::lonnet::dump('wishlist'); |
my $options = '<option value="" selected="selected">('.&mt('Top level').')</option>'; |
|
&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) { |
elsif ($i =~ /^(con_lost|error|no_such_host)/i) { |
&Apache::lonnet::logthis('ERROR while attempting to get wishlist: '.$i); |
&Apache::lonnet::logthis('ERROR while attempting to get wishlist: '.$i); |
Line 105 sub getWishlist {
|
Line 110 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 |
# wishlist will not be loaded, instead the user will be asked to try again later |
if ((keys %wishlist) == 0) { |
if ((keys %wishlist) == 0) { |
&Apache::lonnet::logthis('ERROR while attempting to get wishlist: no keys retrieved!'); |
&Apache::lonnet::logthis('ERROR while attempting to get wishlist: no keys retrieved!'); |
Line 119 sub getWishlist {
|
Line 124 sub getWishlist {
|
# Write wishlist to user-data |
# Write wishlist to user-data |
sub putWishlist { |
sub putWishlist { |
my $wishlist = shift; |
my $wishlist = shift; |
|
$foldersOption = ''; |
|
&getFoldersForOption(\@childrenRt); |
|
my $options = '<option value="" selected="selected">('.&mt('Top level').')</option>'.$foldersOption; |
|
$foldersOption = ''; |
|
$$wishlist{'folders'} = $options; |
&Apache::lonnet::put('wishlist',$wishlist); |
&Apache::lonnet::put('wishlist',$wishlist); |
} |
} |
|
|
Line 327 sub saveChanges {
|
Line 337 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). |
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) |
=item * &getFoldersToArray(children) |
|
|
Puts all nodes that represent folders in the wishlist into an array. |
Puts all nodes that represent folders in the wishlist into an array. |
Line 352 sub saveChanges {
|
Line 357 sub saveChanges {
|
# Return the names for all exiting folders in option-tags, so |
# 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 |
# a new link or a new folder can be created in an existing folder |
my $indent = 0; |
my $indent = 0; |
my $foldersOption; |
|
sub getFoldersForOption { |
sub getFoldersForOption { |
my $nodes = shift; |
my $nodes = shift; |
|
|
Line 373 sub getFoldersForOption {
|
Line 377 sub getFoldersForOption {
|
} |
} |
|
|
|
|
sub getfoldersOption { |
|
if (&getWishlist ne 'error') { |
|
%TreeHash = &getWishlist(); |
|
$root = &Tree::HashToTree(); |
|
@childrenRt = $root->children(); |
|
&getFoldersForOption(\@childrenRt); |
|
my $options = '<option value="" selected="selected">('.&mt('Top level').')</option>'.$foldersOption; |
|
$foldersOption = ''; |
|
return $options; |
|
} |
|
else { |
|
return ''; |
|
} |
|
} |
|
|
|
|
|
# Put all folder-nodes to an array |
# Put all folder-nodes to an array |
sub getFoldersToArray { |
sub getFoldersToArray { |
my $children = shift; |
my $children = shift; |
Line 637 sub JSforWishlist {
|
Line 625 sub JSforWishlist {
|
else if (action == 'saveOK') { |
else if (action == 'saveOK') { |
r = linksOK(); |
r = linksOK(); |
} |
} |
|
else if (action == 'move') { |
|
r = selectDestinationFolder(); |
|
} |
document.getElementsByName('list')[0].setAttribute("action", "/adm/wishlist?mode="+mode); |
document.getElementsByName('list')[0].setAttribute("action", "/adm/wishlist?mode="+mode); |
if (r) { |
if (r) { |
document.getElementsByName('list')[0].submit(); |
document.getElementsByName('list')[0].submit(); |
Line 1063 sub JSforWishlist {
|
Line 1054 sub JSforWishlist {
|
newWin.focus(); |
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() { |
function checkAll() { |
var checkboxes = document.getElementsByName('check'); |
var checkboxes = document.getElementsByName('check'); |
for (var i = 0; i < checkboxes.length; i++) { |
for (var i = 0; i < checkboxes.length; i++) { |
Line 1095 JAVASCRIPT
|
Line 1072 JAVASCRIPT
|
return $js; |
return $js; |
} |
} |
|
|
|
sub JSforImport{ |
|
my $rat = shift; |
|
|
|
my $js; |
|
if ($rat eq 'simple' || $rat eq '') { |
|
$js = &Apache::lonhtmlcommon::scripttag(<<JAVASCRIPT); |
|
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(); |
|
} |
|
JAVASCRIPT |
|
} |
|
else { |
|
$js = &Apache::lonhtmlcommon::scripttag(<<JAVASCRIPT); |
|
function finish_import() { |
|
var linkflag=false; |
|
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") != '') { |
|
insertRowInLastRow(); |
|
placeResourceInLastRow( |
|
eval("document.forms.groupsort.title"+num+".value"), |
|
eval("document.forms.groupsort.filelink"+num+".value"), |
|
eval("document.forms.groupsort.id"+num+".value"), |
|
linkflag |
|
); |
|
linkflag=true; |
|
} |
|
} |
|
opener.editmode=0; |
|
opener.notclear=0; |
|
opener.linkmode=0; |
|
opener.draw(); |
|
self.close(); |
|
} |
|
|
|
function insertRowInLastRow() { |
|
opener.insertrow(opener.maxrow); |
|
opener.addobj(opener.maxrow,'e&2'); |
|
} |
|
|
|
function placeResourceInLastRow (title,url,id,linkflag) { |
|
opener.mostrecent=opener.newresource(opener.maxrow,2,opener.unescape(title), |
|
opener.unescape(url),'false','normal',id); |
|
opener.save(); |
|
if (linkflag) { |
|
opener.joinres(opener.linkmode,opener.mostrecent,0); |
|
} |
|
opener.linkmode=opener.mostrecent; |
|
} |
|
JAVASCRIPT |
|
} |
|
return $js; |
|
} |
|
|
# HTML-Markup for table if in view-mode |
# HTML-Markup for table if in view-mode |
my $wishlistHTMLview; |
my $wishlistHTMLview; |
Line 1427 sub makePage {
|
Line 1466 sub makePage {
|
'onload' => 'javascript:onLoadAction('."'".$mode."'".');', |
'onload' => 'javascript:onLoadAction('."'".$mode."'".');', |
'onunload' => 'javascript:window.name = '."'loncapaclient'"}}); |
'onunload' => 'javascript:window.name = '."'loncapaclient'"}}); |
|
|
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Wishlist '.&Apache::loncommon::help_open_topic('Wishlist')); |
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(&mt('Wishlist').&Apache::loncommon::help_open_topic('Wishlist')); |
|
|
# get javascript-code for wishlist-interactions |
# get javascript-code for wishlist-interactions |
my $js = &JSforWishlist(); |
my $js = &JSforWishlist(); |
Line 1545 sub makePage {
|
Line 1584 sub makePage {
|
'Now choose the new destination folder.').'</span></p>'; |
'Now choose the new destination folder.').'</span></p>'; |
&wishlistMove(\@childrenRt, $marked); |
&wishlistMove(\@childrenRt, $marked); |
$inner .= '<table class="LC_data_table LC_tableOfContent">'.$wishlistHTMLmove.'</table><br/><br/>'; |
$inner .= '<table class="LC_data_table LC_tableOfContent">'.$wishlistHTMLmove.'</table><br/><br/>'; |
$inner .= '<input type="button" value="'.&mt('Move').'" onclick="setFormAction('."'','view'".'); selectDestinationFolder()"/>'. |
$inner .= '<input type="button" value="'.&mt('Move').'" onclick="setFormAction('."'move','view'".');"/>'. |
'<input type="button" value="'.&mt('Cancel').'" onclick="go('."'/adm/wishlist'".')"/>'; |
'<input type="button" value="'.&mt('Cancel').'" onclick="go('."'/adm/wishlist'".')"/>'; |
|
|
$wishlistHTMLmove ='<tr id="root" class="LC_odd_row"><td><input type="radio" name="mark" id="radioRoot" value="root" /></td>'. |
$wishlistHTMLmove ='<tr id="root" class="LC_odd_row"><td><input type="radio" name="mark" id="radioRoot" value="root" /></td>'. |
Line 1596 sub makePageSet {
|
Line 1635 sub makePageSet {
|
|
|
# Returns the HTML-Markup for the page, shown when links should be imported into a course |
# Returns the HTML-Markup for the page, shown when links should be imported into a course |
sub makePageImport { |
sub makePageImport { |
|
my $rat = shift; |
# start_page |
# start_page |
my $startPage = &Apache::loncommon::start_page('Wishlist',undef, |
my $startPage = &Apache::loncommon::start_page('Wishlist',undef, |
{'only_body' => 1}); |
{'only_body' => 1}); |
|
|
# get javascript-code for wishlist-interactions |
# get javascript-code for wishlist-interactions |
my $js = &JSforWishlist(); |
my $js = &JSforWishlist(); |
|
$js .= &JSforImport($rat); |
|
|
my $inner = '<h1>'.&mt('Import Resources from Wishlist').'</h1>'; |
my $inner = '<h1>'.&mt('Import Resources from Wishlist').'</h1>'; |
$inner .= '<p><span class="LC_info">'.&mt("Please note that you can use the checkboxes corresponding to a folder to ". |
if (!$rat) { |
"easily check all links within this folder. The folder structure itself can't be imported. ". |
$inner .= '<p><span class="LC_info">'.&mt("Please note that you can use the checkboxes corresponding to a folder to ". |
"All checked links will be imported into the current folder of your course.").'</span></p>'; |
"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.").'</span></p>'; |
|
} |
|
else { |
|
$inner .= '<p><span class="LC_info">'.&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. ") |
|
.'</span></p>'; |
|
} |
my %wishlist = &getWishlist(); |
my %wishlist = &getWishlist(); |
my $fnum = (keys %wishlist)-1; |
my $fnum = (keys %wishlist)-1; |
|
|
Line 1649 sub makeErrorPage {
|
Line 1696 sub makeErrorPage {
|
text => 'Wishlist'}); |
text => 'Wishlist'}); |
my $startPage = &Apache::loncommon::start_page('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')); |
'<a title="Online-Hilfe" href="/adm/help/Wishlist.hlp" target="_top">'. |
|
'<img src="/adm/help/help.png" alt="'.&mt('Help').'" '. |
|
'title="'.&mt('Help').'" class="LC_icon" /></a>'); |
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
|
|
# error-message |
# error-message |
Line 1685 sub handler {
|
Line 1729 sub handler {
|
} |
} |
|
|
# get unprocessed_cgi (i.e. marked entries, mode ...) |
# 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 |
# change the order of entries within a level, that means sorting the entries |
my $changeOrder = 0; |
my $changeOrder = 0; |
Line 1772 sub handler {
|
Line 1816 sub handler {
|
$page = &makePage("move", \@marked); |
$page = &makePage("move", \@marked); |
} |
} |
elsif ($env{'form.mode'} eq 'import') { |
elsif ($env{'form.mode'} eq 'import') { |
$page = &makePageImport(); |
$page = &makePageImport($env{'form.rat'}); |
} |
} |
elsif ($env{'form.mode'} eq 'set') { |
elsif ($env{'form.mode'} eq 'set') { |
$page = &makePageSet(); |
$page = &makePageSet(); |
Line 1983 sub HashToTree {
|
Line 2027 sub HashToTree {
|
if ($key eq 'root') { |
if ($key eq 'root') { |
$root = Tree->new("root"); |
$root = Tree->new("root"); |
} |
} |
else { |
elsif ($key ne 'folders') { |
my @attributes = @{ $TreeHash{$key} }; |
my @attributes = @{ $TreeHash{$key} }; |
my $tmpNode; |
my $tmpNode; |
$tmpNode = Tree->new(Entry->new(title=>$attributes[0], |
$tmpNode = Tree->new(Entry->new(title=>$attributes[0], |