version 1.2, 2010/08/16 08:58:39
|
version 1.3, 2010/08/16 13:37:41
|
Line 189 sub setNewTitle {
|
Line 189 sub setNewTitle {
|
} |
} |
|
|
|
|
|
# Set a new path for an entry |
|
sub setNewPath { |
|
my ($nodeindex, $newPath) = @_; |
|
&getNodesToArray(\@childrenRt); |
|
my $found = &Tree::getNodeByIndex($nodeindex, \@allNodes); |
|
if ($found->value()->path()) { |
|
$found->value()->path($newPath); |
|
return 1; |
|
} |
|
@allNodes = (); |
|
return 0; |
|
} |
|
|
|
|
# Set a new note for an entry |
# Set a new note for an entry |
sub setNewNote { |
sub setNewNote { |
my ($nodeindex, $newNote) = @_; |
my ($nodeindex, $newNote) = @_; |
Line 352 sub JSforWishlist {
|
Line 366 sub JSforWishlist {
|
$inPageNewLink =~ s/\n//g; |
$inPageNewLink =~ s/\n//g; |
$inPageNewFolder =~ 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. |
|
# to find out if a path (not starting with /res/...) links to course-contents, the same filter as in lonwrapper is used, |
|
# 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 $warningLink = &mt('You must insert a title and a path!'); |
my $warningLink = &mt('You must insert a title and a path!'); |
my $warningFolder = &mt('You must insert a title!'); |
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 $warningDelete = &mt('Are you sure you want to delete the selected entries? Deleting a folder also deletes all entries within this folder!'); |
Line 370 sub JSforWishlist {
|
Line 395 sub JSforWishlist {
|
+'if (!path || !title) {' |
+'if (!path || !title) {' |
+'alert("$warningLink");' |
+'alert("$warningLink");' |
+'return false;}' |
+'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 {' |
+'else {' |
+'window.close();' |
+'window.close();' |
+'return true;}}' |
+'return true;}}' |
Line 409 sub JSforWishlist {
|
Line 443 sub JSforWishlist {
|
if (d) { |
if (d) { |
if (!confirm('$warningSave')) { |
if (!confirm('$warningSave')) { |
setAction('noSave'); |
setAction('noSave'); |
|
r = true; |
|
} |
|
else { |
|
r = linksOK(); |
} |
} |
} |
} |
r = true; |
} |
|
else if (action == 'saveOK') { |
|
r = linksOK(); |
} |
} |
document.getElementsByName('list')[0].setAttribute("action", "/adm/wishlist?mode="+mode); |
document.getElementsByName('list')[0].setAttribute("action", "/adm/wishlist?mode="+mode); |
if (r) { |
if (r) { |
Line 433 sub JSforWishlist {
|
Line 473 sub JSforWishlist {
|
return true; |
return true; |
} |
} |
} |
} |
|
var newpath = document.getElementsByName('newpath'); |
|
var i = 0; |
|
for (i=0;i<newpath.length;i++) { |
|
var newp = newpath[i].value; |
|
var oldp = newpath[i].alt; |
|
if (newp != oldp) { |
|
return true; |
|
} |
|
} |
var newnote = document.getElementsByName('newnote'); |
var newnote = document.getElementsByName('newnote'); |
var i = 0; |
var i = 0; |
for (i=0;i<newnote.length;i++) { |
for (i=0;i<newnote.length;i++) { |
Line 445 sub JSforWishlist {
|
Line 494 sub JSforWishlist {
|
return false; |
return false; |
} |
} |
|
|
|
function linksOK() { |
|
var newpath = document.getElementsByName('newpath'); |
|
var i = 0; |
|
for (i=0;i<newpath.length;i++) { |
|
var path = newpath[i].value; |
|
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 $warningLinkNotAllowed2"+path); |
|
return false; |
|
} |
|
} |
|
return true; |
|
} |
|
|
function onLoadAction(mode) { |
function onLoadAction(mode) { |
window.name = 'wishlist'; |
window.name = 'wishlist'; |
if (mode == "edit") { |
if (mode == "edit") { |
Line 801 sub JSforWishlist {
|
Line 869 sub JSforWishlist {
|
} |
} |
|
|
function preview(url) { |
function preview(url) { |
var newWin = window.open(url+'?inhibitmenu=yes','preview','width=560,height=350,scrollbars=yes'); |
var newWin; |
|
if (!(url.match(/^http:\\/\\//) || url.match(/^https:\\/\\//))) { |
|
newWin = window.open(url+'?inhibitmenu=yes','preview','width=560,height=350,scrollbars=yes'); |
|
} |
|
else { |
|
newWin = window.open(url,'preview','width=560,height=350,scrollbars=yes'); |
|
} |
newWin.focus(); |
newWin.focus(); |
} |
} |
|
|
Line 945 sub wishlistEdit {
|
Line 1019 sub wishlistEdit {
|
'<td id="padd'.$index.'" style="padding-left:'.(($indent-$indentConst)<0?0:($indent-$indentConst)).'px;">'. |
'<td id="padd'.$index.'" style="padding-left:'.(($indent-$indentConst)<0?0:($indent-$indentConst)).'px;">'. |
'<a href="javascript:;" onclick="folderAction('."'row".$index."'".')" style="vertical-align:top" >'. |
'<a href="javascript:;" onclick="folderAction('."'row".$index."'".')" style="vertical-align:top" >'. |
'<img src="/adm/lonIcons/arrow.closed.gif" id="img'.$index.'" alt = "" class="LC_icon"/>'. |
'<img src="/adm/lonIcons/arrow.closed.gif" id="img'.$index.'" alt = "" class="LC_icon"/>'. |
'<img src="/adm/lonIcons/navmap.folder.closed.gif" id="imgFolder'.$index.'" alt="folder"/></a>'; |
'<img src="/adm/lonIcons/navmap.folder.closed.gif" id="imgFolder'.$index.'" alt="folder"/></a>'. |
|
'<input type="text" name="newtitle" value="'.$n->value()->title().'" alt = "'.$n->value()->title().'"/>'. |
|
'</td><td></td>'; |
|
|
} |
} |
# entry is a link |
# entry is a link |
Line 953 sub wishlistEdit {
|
Line 1029 sub wishlistEdit {
|
$wishlistHTMLedit .= '<td><select class="LC_hidden" name="sel" id="sel'.$index.'" onchange="submitSelect();">'. |
$wishlistHTMLedit .= '<td><select class="LC_hidden" name="sel" id="sel'.$index.'" onchange="submitSelect();">'. |
$options.'</select></td>'. |
$options.'</select></td>'. |
'<td id="padd'.$index.'" style="padding-left:'.(($indent-$indentConst)<=0?$indentConst:$indent).'px;">'. |
'<td id="padd'.$index.'" style="padding-left:'.(($indent-$indentConst)<=0?$indentConst:$indent).'px;">'. |
'<img src="/res/adm/pages/wishlist-link.png" id="img'.$index.'" alt="link"/>'; |
'<img src="/res/adm/pages/wishlist-link.png" id="img'.$index.'" alt="link"/>'. |
|
'<input type="text" name="newtitle" value="'.$n->value()->title().'" alt = "'.$n->value()->title().'"/></td>'. |
|
'<td><input type="text" name="newpath" value="'.$n->value()->path().'" alt = "'.$n->value()->path().'"/></td>'; |
} |
} |
|
|
# input-field for title |
|
$wishlistHTMLedit .= '<input type="text" name="newtitle" value="'.$n->value()->title().'" alt = "'.$n->value()->title().'"/></td>'; |
|
|
|
# note-icon, different icons for an entries with note and those without |
# note-icon, different icons for an entries with note and those without |
my $noteIMG = 'anot.png'; |
my $noteIMG = 'anot.png'; |
|
|
Line 974 sub wishlistEdit {
|
Line 1049 sub wishlistEdit {
|
|
|
# start row containing the textarea for the note |
# start row containing the textarea for the note |
$wishlistHTMLedit .= &Apache::loncommon::continue_data_table_row('LC_hidden','note'.$index). |
$wishlistHTMLedit .= &Apache::loncommon::continue_data_table_row('LC_hidden','note'.$index). |
'<td></td><td></td><td>'. |
'<td></td><td></td><td colspan="2">'. |
'<textarea id="noteText'.$index.'" cols="25" rows="3" style="width:100%" '. |
'<textarea id="noteText'.$index.'" cols="25" rows="3" style="width:100%" '. |
'name="newnote">'. |
'name="newnote">'. |
$n->value()->note().'</textarea></td><td></td>'; |
$n->value()->note().'</textarea></td><td></td>'; |
Line 1192 sub makePage {
|
Line 1267 sub makePage {
|
# icon for edit-mode, display when in view-mode |
# icon for edit-mode, display when in view-mode |
if ($mode eq 'view') { |
if ($mode eq 'view') { |
$functions .= &Apache::lonhtmlcommon::add_item_funclist('<a href="javascript:;" '. |
$functions .= &Apache::lonhtmlcommon::add_item_funclist('<a href="javascript:;" '. |
'onclick="setFormAction('."'save','edit'".'); list.submit();" class="LC_menubuttons_link">'. |
'onclick="setFormAction('."'save','edit'".');" class="LC_menubuttons_link">'. |
'<img src="/res/adm/pages/edit-mode-22x22.png" alt="'.$lt{'ed'}.'" '. |
'<img src="/res/adm/pages/edit-mode-22x22.png" alt="'.$lt{'ed'}.'" '. |
'title="'.$lt{'ed'}.'" class="LC_icon"/> '. |
'title="'.$lt{'ed'}.'" class="LC_icon"/> '. |
'<span class="LC_menubuttons_inline_text">'.$lt{'ed'}.'</span></a>'); |
'<span class="LC_menubuttons_inline_text">'.$lt{'ed'}.'</span></a>'); |
Line 1200 sub makePage {
|
Line 1275 sub makePage {
|
# icon for view-mode, display when in edit-mode |
# icon for view-mode, display when in edit-mode |
else { |
else { |
$functions .= &Apache::lonhtmlcommon::add_item_funclist('<a href="javascript:;" '. |
$functions .= &Apache::lonhtmlcommon::add_item_funclist('<a href="javascript:;" '. |
'onclick="setFormAction('."'save','view'".'); list.submit();" class="LC_menubuttons_link">'. |
'onclick="setFormAction('."'save','view'".');" class="LC_menubuttons_link">'. |
'<img src="/res/adm/pages/view-mode-22x22.png" alt="'.$lt{'vw'}.'" '. |
'<img src="/res/adm/pages/view-mode-22x22.png" alt="'.$lt{'vw'}.'" '. |
'title="'.$lt{'vw'}.'" class="LC_icon"/> '. |
'title="'.$lt{'vw'}.'" class="LC_icon"/> '. |
'<span class="LC_menubuttons_inline_text">'.$lt{'vw'}.'</span></a>'); |
'<span class="LC_menubuttons_inline_text">'.$lt{'vw'}.'</span></a>'); |
Line 1236 sub makePage {
|
Line 1311 sub makePage {
|
|
|
# icon for saving changes |
# icon for saving changes |
$functions .= &Apache::lonhtmlcommon::add_item_funclist('<a href="javascript:;" '. |
$functions .= &Apache::lonhtmlcommon::add_item_funclist('<a href="javascript:;" '. |
'onclick="setFormAction('."'','".$mode."'".'); " class="LC_menubuttons_link">'. |
'onclick="setFormAction('."'saveOK','".$mode."'".'); " class="LC_menubuttons_link">'. |
'<img src="/res/adm/pages/save-22x22.png" alt="'.$lt{'sv'}.'" '. |
'<img src="/res/adm/pages/save-22x22.png" alt="'.$lt{'sv'}.'" '. |
'title="'.$lt{'sv'}.'" class="LC_icon" />'. |
'title="'.$lt{'sv'}.'" class="LC_icon" />'. |
'<span class="LC_menubuttons_inline_text">'.$lt{'sv'}.'</span></a>'); |
'<span class="LC_menubuttons_inline_text">'.$lt{'sv'}.'</span></a>'); |
Line 1479 sub handler {
|
Line 1554 sub handler {
|
# only save, if user wants to save changes |
# only save, if user wants to save changes |
# do not save, when current action is 'delete' or 'sort' or 'move' |
# do not save, when current action is 'delete' or 'sort' or 'move' |
my @newTitles = (); |
my @newTitles = (); |
|
my @newPaths = (); |
my @newNotes = (); |
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'); |
@newTitles = &Apache::loncommon::get_env_multiple('form.newtitle'); |
|
@newPaths = &Apache::loncommon::get_env_multiple('form.newpath'); |
@newNotes = &Apache::loncommon::get_env_multiple('form.newnote'); |
@newNotes = &Apache::loncommon::get_env_multiple('form.newnote'); |
my $node = 0; |
my $node = 0; |
foreach my $t (@newTitles) { |
foreach my $t (@newTitles) { |
Line 1489 sub handler {
|
Line 1567 sub handler {
|
$node++; |
$node++; |
} |
} |
$node = 0; |
$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) { |
foreach my $n (@newNotes) { |
&setNewNote($node, $n); |
&setNewNote($node, $n); |
$node++; |
$node++; |