1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
<script type="text/javascript">
function quickmenu(path) {
<?php
$clipboard = $ps->getPage("/.clipboard");
if ($clipboard->childCount() == 0)
echo "var clipboard = false;";
else
echo "var clipboard = true;";
?>
var html;
html = '<a href="' + path + '/?a=edit&ea=info&clip=cut&quick=1">Cut</a>';
html += '<a href="' + path + '/?a=edit&ea=info&clip=copy&quick=1">Copy</a>';
html += '<a href="' + path + '/?a=edit&ea=info&clip=delete&quick=1">Delete</a>';
html += "<hr>";
if (clipboard) {
html += '<a href="' + path + '/?a=edit&ea=info&clip=paste&quick=1&where=before">Paste before</a>';
html += '<a href="' + path + '/?a=edit&ea=info&clip=paste&quick=1&where=into">Paste into</a>';
html += '<a href="' + path + '/?a=edit&ea=info&clip=paste&quick=1&where=after">Paste after</a>';
}
else {
html+="<div>Paste before</div><div>Paste into</div><div>Paste after</div>";
}
html += "<hr>";
html += '<a href="' + path + '/?a=edit&ea=info&clip=new&quick=1&where=before">New page before</a>';
html += '<a href="' + path + '/?a=edit&ea=info&clip=new&quick=1&where=into">New page into</a>';
html += '<a href="' + path + '/?a=edit&ea=info&clip=new&quick=1&where=after">New page after</a>';
return html;
}
var delayhide;
function delayhidemenu(){
clearTimeout(delayhide);
delayhide=setTimeout("hidemenu()",800);
}
function cancelhidemenu() {
clearTimeout(delayhide);
}
function hidemenu(){
document.getElementById("dropmenu").style.visibility="hidden";
}
function dropdownmenu(obj, e, contents){
cancelhidemenu();
menu=document.getElementById("dropmenu");
menu.innerHTML=contents;
dim = getdim(obj);
curx = dim.x + obj.offsetWidth + "px";
cury = dim.y + "px";
if (menu.style.visibility=="hidden") {
menu.style.visibility = "visible";
}
else if (menu.style.top == cury) {
menu.style.visibility="hidden";
}
menu.style.left = curx;
menu.style.top = cury;
}
function getdim(el){
for (var lx=0,ly=0; el!=null; lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
return {x:lx,y:ly}
}
</script>
<div id="dropmenu" style="visibility:hidden; position:absolute;" onMouseover="cancelhidemenu()" onMouseout="delayhidemenu()"></div>
<?php
$GLOBALS['linkaction'] = &$linkaction;
$ea = get('eaction',get('ea','edit'));
if ($ea == 'newedit')
$linkaction = "?a=edit&ea=info";
elseif ($ea == 'saveedit')
$linkaction = "?a=edit&ea=edit";
else
$linkaction = "?a=edit&ea=$ea";
if (!isset($path))
$path = $ps->getPathInfo($page);
$level = dohome();
if ($page->path == '' || $page->path{1} != ".") {
echo "<div class=thinhr> </div>\n";
dotree($level);
}
echo "<hr style='width:100%'/>\n";
doclipboard();
if (preg_match("'^/.clipboard'", $page->path)) {
echo "<div class=thinhr> </div>\n";
dotree(1);
}
echo "<hr style='width:100%'/>\n";
dotrash();
if (preg_match("'^/.trash'", $page->path)) {
echo "<div class=thinhr> </div>\n";
dotree(1);
}
return;
function dohome() {
global $page, $path, $linkaction;
$branchdepth = 2; // how much of the tree to show
if (preg_match("'.*/$'",$page->path))
$branchdepth--;
$depth = count($path);
echo("<div id=navroot>");
$link = alink('/'. $linkaction ,"<u>H</u>ome","class='type-home browser' accesskey=h");
if ($page->path=='') $link = "<strong>$link</strong>";
echo "$link\n";
if ($depth > $branchdepth) {
$startlevel = $depth-$branchdepth;
$path = array_reverse($path);
while(count($path) > $branchdepth) {
$pathpart = array_pop($path);
echo(alink($pathpart['path'] . '/' . $linkaction,$pathpart['title'],"class='type-dir browser'") . "\n");
}
}
else {
$startlevel = 0;
}
echo("</div>\n");
return $startlevel;
}
function dotree($startlevel=0) {
global $nav, $ps, $page, $path, $linkaction;
$tree = $nav->getTree($page,$startlevel,true);
#debug($page->path);
foreach($tree as $entry) {
echo (str_repeat(' ', $entry['level']+1));
if (is_int($entry['level'])) {
$p = $ps->getPage($entry['path']);
if ($entry['dir'] == true)
$class = 'type-dir';
elseif ($entry['type'] == 'mod')
$class = 'type-mod';
else
$class = 'type-file';
$class .= " browser";
$link = alink($entry['path'] . '/' . $linkaction , $entry['title'], "class=\"$class\"");
if ($entry['selected']) $link = "<strong>$link</strong>";
$style = "margin-left: " . (($entry['level']*16)) . "px";
$menu = '<a class="quick" onClick="dropdownmenu(this, event, quickmenu(\'' . $entry['absolutepath'] . '\'))" onMouseout="delayhidemenu()" href="javascript:void(0)"> » </a>';
echo "<div style=\"$style\">$link$menu</div>\n";
}
}
if (count($tree) == 0)
echo "<div class='browser'>empty</div>";
}
function doclipboard() {
global $page,$linkaction,$ps;
if ($page->path=='/.clipboard') $selected = true;
else $selected = false;
$p = $ps->getPage("/.clipboard");
echo("<div>");
$link = alink('/.clipboard/'. $linkaction ,"C<u>l</u>ipboard","class='type-clip browser' accesskey='l'");
if ($selected)
$link = "<strong>$link</strong>";
echo "$link</div>\n";
}
function dotrash() {
global $page, $path, $linkaction, $ps;
if ($page->path=='/.trash') $selected = true;
else $selected = false;
$p = $ps->getPage("/.trash");
echo("<div>");
$link = alink('/.trash/'. $linkaction ,"<u>T</u>rash","class='type-trash browser' accesskey='t'");
if ($selected)
$link = "<strong>$link</strong>";
echo "$link</div>\n";
}
return;
?>
|