Ok, a quick stab... quick and dirty. Well, that turned out to be simpler then I thought.
Here’s a replacement for tree.php
All I had to do is add an extra few lines in frames/tree.php - shown below from line 493: See the lines with my comments...
<script type="text/javascript">
// Context menu stuff
function menuHandler(action) {
switch (action) {
case 1 :
top.main.document.location.href="index.php?a=3&id=" + itemToChange;
break
case 2 :
top.main.document.location.href="index.php?a=27&id=" + itemToChange;
break
case 3 :
top.main.document.location.href="index.php?a=4&pid=" + itemToChange;
break
case 4 :
if(selectedObjectDeleted==0) {
if(confirm("'" + selectedObjectName + "'\n\n<?php echo $_lang['confirm_delete_document']; ?>")==true) {
top.main.document.location.href="index.php?a=6&id=" + itemToChange;
}
} else {
alert("'" + selectedObjectName + "' <?php echo $_lang['already_deleted']; ?>");
}
break
case 5 :
top.main.document.location.href="index.php?a=51&id=" + itemToChange;
break
case 6 :
top.main.document.location.href="index.php?a=72&pid=" + itemToChange;
break
case 7 : // Ryan: duplicate document
if(confirm("<?php echo $_lang['confirm_duplicate_document'] ?>")==true) {
top.main.document.location.href="index.php?a=94&id=" + itemToChange;
}
break
case 8 :
if(selectedObjectDeleted==0) {
alert("'" + selectedObjectName + "' <?php echo $_lang['not_deleted']; ?>");
} else {
if(confirm("'" + selectedObjectName + "' <?php echo $_lang['confirm_undelete']; ?>")==true) {
top.main.document.location.href="index.php?a=63&id=" + itemToChange;
}
}
break
case 9 :
if(confirm("'" + selectedObjectName + "' <?php echo $_lang['confirm_publish']; ?>")==true) {
top.main.document.location.href="index.php?a=61&id=" + itemToChange;
}
break
case 10 :
if (itemToChange != <?php echo $modx->config['site_start']?>) {
if(confirm("'" + selectedObjectName + "' <?php echo $_lang['confirm_unpublish']; ?>")==true) {
top.main.document.location.href="index.php?a=62&id=" + itemToChange;
}
} else {
alert('Document is linked to site_start variable and cannot be unpublished!');
}
break
//case 11 : //Raymond: create folder (currently removed)
// top.main.document.location.href="index.php?a=85&pid=" + itemToChange;
// break
// mod by TobyL: added preview document in manager
// comment/uncomment if you want preview in new window
case 12 :
//window.open("../index.php?id=" + itemToChange,'previeWin'); //re-use 'new' window
//window.open("../index.php?id=" + itemToChange); //open in new window each time
top.main.document.location.href="../index.php?id=" + itemToChange; //open in manager
break
default :
alert('Unknown operation command.');
}
}
</script>
<!-- Contextual Menu Popup Code -->
<div id="mx_contextmenu" onselectstart="return false;">
<div id="nameHolder"> </div>
<?php
constructLink(1, "context_view", $_lang["view_document"], 1,$theme);
//mod by TobyL: added preview document menu item - requires extra language setting!!
constructLink(12, "context_view", $_lang["preview_document"], 1,$theme);
constructLink(2, "save", $_lang["edit_document"], $modx->hasPermission('edit_document'),$theme);
constructLink(5, "cancel", $_lang["move_document"], $modx->hasPermission('save_document'),$theme);
constructLink(7, "copy", $_lang["duplicate_document"], $modx->hasPermission('new_document'),$theme);
// constructLink(11, "folder", $_lang["create_folder_here"], $modx->hasPermission('new_document'),$theme);
constructLink(3, "newdoc", $_lang["create_document_here"], $modx->hasPermission('new_document'),$theme);
constructLink(6, "weblink", $_lang["create_weblink_here"], $modx->hasPermission('new_document'),$theme);
?>
<div class="seperator"></div>
<?php
constructLink(4, "delete", $_lang["delete_document"], $modx->hasPermission('delete_document'),$theme);
constructLink(8, "b092", $_lang["undelete_document"], $modx->hasPermission('delete_document'),$theme);
?>
<div class="seperator"></div>
<?php
constructLink(9, "date", $_lang["publish_document"], $modx->hasPermission('publish_document'),$theme);
constructLink(10, "date", $_lang["unpublish_document"], $modx->hasPermission('publish_document'),$theme);
?>
, add a new entry in the language file (manager/includes/lang/english.inc.php in my case):
$_lang["preview_document"] = 'Preview document';
That’s all. As it is the preview will open in the manager, but that is easily changed if you want to open it in a new window. Just comment out // uncomment the appropriate line in the menuHandler javascript function.
Well actually I did do a bit more on my local copy. I created a new icon for the "view Document" (as I used the old one for the new preview) and renamed "View document" to "Document Data" in the language file. If you want to do the same then adjust the view document entry in tree.php as follows. The icon I used is in the zip file but it may not fit in with the manager style you’re using... build your own in that case
<?php
// existing
//constructLink(1, "context_view", $_lang["view_document"], 1,$theme);
// new
constructLink(1, "context_properties", $_lang["view_document"], 1,$theme);
?>
Have fun!
Oh and before I forget... the icon is a combo of a few icons from the excellent silk set from Mark James
http://www.famfamfam.com/lab/icons/silk/
EDIT Updated.. zip and code above. I forgot the ../ in the path which meant the manager itself opened instead of teh preview. Corrected!