--- loncom/interface/lonwishlist.pm 2011/01/27 14:38:44 1.9
+++ loncom/interface/lonwishlist.pm 2014/02/17 16:40:22 1.20
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility-routines for wishlist
#
-# $Id: lonwishlist.pm,v 1.9 2011/01/27 14:38:44 wenzelju Exp $
+# $Id: lonwishlist.pm,v 1.20 2014/02/17 16:40:22 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -50,7 +50,7 @@ use Apache::lonnet;
use Apache::loncommon();
use Apache::lonhtmlcommon;
use Apache::lonlocal;
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
use Tree;
@@ -466,11 +466,13 @@ sub getNodesToArray {
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 * &wishlistImport(nodes)
+=item * &wishlistImport(nodes, numskipped)
Returns the table-HTML-markup for the wishlist in mode "import".
- 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).
+ Side effect: increments the scalar ref: numskipped with a count of items in
+ Stored Links unavailable for selection, (e.g., now marked obsolete or
+ inaccessible in Community context).
=item * &makePage(mode, marked)
@@ -478,6 +480,16 @@ sub getNodesToArray {
Calls &wishlistView(nodes), &wishlistEdit(nodes) or &wishlistMove(nodes, marked).
+=item * &makePopUpNewLink(title, path)
+
+ Returns the HTML-markup for the pop-up-window 'Add Link'. If this is called up from a browsed resource, the input-fields titel and path are pre-filled with the resources' meta-data-title and it's path.
+
+
+=item * &makePopUpNewFolder()
+
+ Returns the HTML-markup for the pop-up-window 'Add Folder'.
+
+
=item * &makePageSet()
Returns the HTML-Markup for the page shown when a link was set by using the icon when viewing a resource.
@@ -501,7 +513,7 @@ sub getNodesToArray {
# Return a script-tag containing Javascript-function
# needed for wishlist actions like 'new link' ect.
sub JSforWishlist {
- my $startPagePopup = &Apache::loncommon::start_page('Wishlist',undef,
+ my $startPagePopup = &Apache::loncommon::start_page('Stored Links',undef,
{'only_body' => 1,
'js_ready' => 1,
'bgcolor' => '#FFFFFF',});
@@ -511,65 +523,6 @@ sub JSforWishlist {
&getFoldersToArray(\@childrenRt);
&getFoldersForOption(\@childrenRt);
- # texthash
- my %lt = &Apache::lonlocal::texthash(
- 'nl' => 'New Link',
- 'nf' => 'New Folder',
- 'lt' => 'Link Title',
- 'ft' => 'Folder Title',
- 'pa' => 'Path',
- 'nt' => 'Note',
- 'si' => 'Save in',
- 'cl' => 'Cancel');
-
-
- my $inPageNewLink = '
'.$lt{'nl'}.'
'.
- '';
-
- my $inPageNewFolder = '
'.$lt{'nf'}.'
'.
- '';
-
- # Remove all \n for inserting on javascript document.write
- $inPageNewLink =~ s/\n//g;
- $inPageNewFolder =~ s/\n//g;
-
# it is checked, wether a path links to a LON-CAPA-resource or an external website. links to course-contents are not allowed
# because they probably will return a kind of 'no access' (unless the user is already in the course, the path links to).
# also importing these kind of links into a course does not make much sense.
@@ -577,63 +530,27 @@ sub JSforWishlist {
# that means that it is checked wether a path contains .problem, .quiz, .exam etc.
# this is good for most cases but crashes as soon as a real external website contains one of this pattern in its URL.
# so maybe there's a better way to find out wether a given URL belongs to a LON-CAPA-server or not ...?
- my $warningLinkNotAllowed1 = &mt('You can only insert links to LON-CAPA resources from the resource-pool '.
- 'or to external websites. Paths to LON-CAPA resources must be of the form /res/dom/usr... . '.
- 'Paths to external websites must contain the network protocol (e.g. http://...).');
- my $warningLinkNotAllowed2 = &mt('The following link is not allowed: ');
+ my $warningLinkNotAllowed1 =
+ &mt('You can only insert links to LON-CAPA resources from the resource-pool'.
+ ' or to external websites.'.
+ ' Paths to LON-CAPA resources must be of the form /res/domain/user/...'.
+ ' Paths to external websites must contain the network protocol, e.g. http://...');
+ my $warningLinkNotAllowed2 = &mt('The following link is not allowed:').' ';
my $warningLink = &mt('You must insert a title and a path!');
my $warningFolder = &mt('You must insert a title!');
my $warningDelete = &mt('Are you sure you want to delete the selected entries? Deleting a folder also deletes all entries within this folder!');
- my $warningSave = &mt('You have unsaved changes. You can either save these changes now by clicking "ok" or click "cancel" if you do not want to save your changes.');
+ my $warningSave = &mt('You have unsaved changes. You can either save these changes now by clicking "OK" or click "Cancel" if you do not want to save your changes.');
my $warningMoveS = &mt('You must select at minimum one entry to move!');
my $warningMoveD = &mt('You must select a destination folder!');
$foldersOption = '';
my $js = &Apache::lonhtmlcommon::scripttag(<'
- +'function newlinksubmit(){'
- +'var path = document.getElementsByName("path")[0].value;'
- +'var title = document.getElementsByName("title")[0].value;'
- +'if (!path || !title) {'
- +'alert("$warningLink");'
- +'return false;}'
- +'var linkOK = (path.match(/^http:(\\\\/\\\\/)/) || path.match(/^https:(\\\\/\\\\/)/))'
- +'&& !(path.match(/\\.problem/) || path.match(/\\.exam/)'
- +'|| path.match(/\\.quiz/) || path.match(/\\.assess/)'
- +'|| path.match(/\\.survey/) || path.match(/\\.form/)'
- +'|| path.match(/\\.library/) || path.match(/\\.page/)'
- +'|| path.match(/\\.sequence/));'
- +'if (!path.match(/^(\\\\/res\\\\/)/) && !linkOK) {'
- +'alert("$warningLinkNotAllowed1");'
- +'return false;}'
- +'else {'
- +'window.close();'
- +'return true;}}'
- +'<\/scr'+'ipt>'
- +'$inPageNewLink'
- +'$endPagePopup');
- newlinkWin.document.close();
+ newlinkWin=window.open('/adm/wishlist?mode=newLink','newlinkWin','width=580,height=350, scrollbars=yes');
}
function newFolder() {
- newfolderWin=window.open('','newfolderWin','width=580,height=270, scrollbars=yes');
- newfolderWin.document.write('$startPagePopup'
- +'