1<?php 2/** 3 * DokuWiki Default Template 4 * 5 * This is the template you need to change for the overall look 6 * of DokuWiki. 7 * 8 * You should leave the doctype at the very top - It should 9 * always be the very first line of a document. 10 * 11 * @link http://wiki.splitbrain.org/wiki:tpl:templates 12 * @author Andreas Gohr <andi@splitbrain.org> 13 */ 14 15// must be run from within DokuWiki 16if (!defined('DOKU_INC')) die(); 17 18if (plugin_isdisabled('npd') || !($npd =& plugin_load('helper', 'npd'))) { 19 die(); 20} 21$conf['template'] = $conf['template_original']; 22 23?> 24<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 25 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 26<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $conf['lang']?>" 27 lang="<?php echo $conf['lang']?>" dir="<?php echo $lang['direction']?>"> 28<head> 29 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 30 <title> 31 <?php tpl_pagetitle()?> 32 [<?php echo strip_tags($conf['title'])?>] 33 </title> 34 35 <?php tpl_metaheaders()?> 36<script type="text/javascript" language="javascript" charset="utf-8"> 37//<![CDATA[ 38 39// This is variable for storing callback function 40var ae_cb = null; 41 42// this is a simple function-shortcut 43// to avoid using lengthy document.getElementById 44function ae$(a) { return document.getElementById(a); } 45 46// This is a main ae_prompt function 47// it saves function callback 48// and sets up dialog 49function ae_prompt(cb, q, a) { 50 ae_cb = cb; 51 ae$('aep_t').innerHTML = ' ';//document.domain + ' question:'; 52 ae$('aep_prompt').innerHTML = q; 53 ae$('aep_text').value = a; 54 ae$('aep_ovrl').style.display = ae$('aep_ww').style.display = ''; 55 ae$('aep_text').focus(); 56 ae$('aep_text').select(); 57} 58 59// This function is called when user presses OK(m=0) or Cancel(m=1) button 60// in the dialog. You should not call this function directly. 61function ae_clk(m) { 62 // hide dialog layers 63 ae$('aep_ovrl').style.display = ae$('aep_ww').style.display = 'none'; 64 if (!m) 65 ae_cb(null); // user pressed cancel, call callback with null 66 else 67 ae_cb(ae$('aep_text').value); // user pressed OK 68} 69 70new_folders = new Array(); 71jQuery(function() { init_index(); }); 72function firstDescendant(element) 73{ 74 element = element.firstChild; 75 while (element && element.nodeType != 1) element = element.nextSibling; 76 return element; 77} 78function getEventElement(e) 79{ 80 var node = null; 81 82 if (typeof e.srcElement != 'undefined') { 83 node = e.srcElement; 84 } else { 85 node = e.target; 86 } 87 88 if (node.nodeType == 3) { 89 node = node.parentNode(); 90 } 91 92 return node; 93} 94function npd_cancel(e) 95{ 96 stop_event(e); 97 window.close(); 98} 99function npd_save(e) 100{ 101 stop_event(e); 102 var page_name = jQuery('#npd_page_name').val(); 103 opener.location.href = "doku.php?do=edit&id=" + jQuery('#npd_ns').val() + ":" + page_name; 104 window.close(); 105} 106function npd_new_folder(e) 107{ 108 stop_event(e); 109 ae_prompt(npd_new_folder_cb, "<?php echo str_replace(array("\n", "\r"), " ", $npd->locale_xhtml('dialog_folder_name')); ?>", "Untitled"); 110} 111function npd_new_folder_cb(folder_name) 112{ 113 if (! folder_name) { 114 return; 115 } 116 folder_name = escapeHTML(folder_name).replace(/^\s*|\s*$/g,""); 117 118 var node = active.parentNode; 119 active.className = "idx_dir"; 120 121 node = node.nextSibling; 122 while (node && node.nodeType != 1) node = node.nextSibling; 123 124 if (!node) { 125 // there is no UL yet, create it 126 node = document.createElement("ul"); 127 node.className = 'idx'; 128 active.parentNode.parentNode.appendChild(node); 129 } 130 131 var npd_ns = jQuery('#npd_ns'); 132 var ns = npd_ns.val().replace(/:*$/,'') + ":" + folder_name; 133 npd_ns.val(ns); 134 135 // prepare new node 136 var folder = document.createElement('li'); 137 folder.innerHTML = '<div class="li"><a class="idx_dir active" href="'+ns+'" ref="'+ns+'"><strong>' + folder_name + '</strong></a><a class="edit">[edit]</a></div><ul class="idx"/>'; 138 folder.className = 'new'; 139 140 child = firstDescendant(node); 141 if (child) { 142 node.insertBefore(folder, child); 143 } else { 144 node.appendChild(folder); 145 } 146 active = firstDescendant(firstDescendant(folder)); 147 jQuery(active).click(new_folder_click); 148 149 var edit = active.nextSibling; 150 while (edit && edit.nodeType != 1) edit = edit.nextSibling; 151 152 new_folders.push(active); 153 154 jQuery(edit).click(edit_folder_name); 155 156} 157function edit_folder_name(e) 158{ 159 var link = getEventElement(e); 160 if ((typeof link.href) == 'undefined') { 161 // was a link clicked, or its content 162 link = link.parentNode; 163 } 164 stop_event(e); 165 folder = firstDescendant(link.parentNode); 166 text_node = firstDescendant(folder); 167 ae_prompt(edit_folder_name_cb, "<?php echo htmlspecialchars($npd->getLang('dlg_new_folder')); ?>", text_node.innerHTML); 168} 169function edit_folder_name_cb(response) 170{ 171 if (!response) { 172 return; 173 } 174 response = escapeHTML(response).replace(/^\s*|\s*$/g,"");; 175 text_node.innerHTML = response; 176 var old_ns = folder.getAttribute('ref'); 177 var new_ns = old_ns.replace(/:[^:]*$/, ":" + response); 178 179 npd_ns = jQuery('#npd_ns'); 180 var regex = new RegExp("^" + old_ns); 181 npd_ns.val(npd_ns.val().replace(regex, new_ns)); 182 var length = new_folders.length; 183 if (length > 0) { 184 while (length--) { 185 var f = new_folders[length]; 186 console.log(new_ns); 187 console.log(f.getAttribute('ref')); 188 f.setAttribute('ref', f.getAttribute('ref').replace(regex, new_ns)); 189 } 190 } 191} 192 193function new_folder_click(e) 194{ 195 var link = getEventElement(e); 196 stop_event(e); 197 if (!link.getAttribute('ref')) { 198 // was a link clicked, or its content 199 link = link.parentNode; 200 } 201 active.className = 'idx_dir'; 202 jQuery('#npd_ns').val(link.getAttribute('ref')); 203 active = link; 204 active.className = 'idx_dir active'; 205} 206function page_click(e) 207{ 208 link = getEventElement(e); 209 stop_event(e); 210 input = jQuery('#npd_page_name'); 211 input.val(link.innerHTML); 212 input.addClass('text'); 213} 214function plus_clicked(e) 215{ 216 li = getEventElement(e); 217 switch (li.nodeName.toLowerCase()) { 218 case "strong": 219 li = li.parentNode.parentNode.parentNode; 220 break; 221 case "a": 222 li = li.parentNode.parentNode; 223 break; 224 } 225 if (li.className != 'closed') { 226 return true; 227 } 228 window.location.href = firstDescendant(firstDescendant(li)).href; 229} 230function init_index() 231{ 232 var div = document.getElementById('dw_page_div'); 233 234 for (var i = 0; i<2; i++){ 235 var to_be_removed = firstDescendant(div); 236 div.removeChild(to_be_removed); 237 } 238 links = document.getElementsByTagName("a"); 239 var pattern = new RegExp("(^|\\s)idx_dir(\\s|$)"); 240 var links_length = links.length; 241 var li = ''; 242 for(i=0; i<links_length; i++) { 243 if ( pattern.test(links[i].className) ) { 244 links[i].href += '&npd=1'; 245 var a = links[i].href.replace(/.*idx=:?([^&]*).*/, "$1"); 246 a = a.replace(/%3A/g, ":"); 247 if (a == jQuery('#npd_ns').val()) { 248 links[i].className += " active"; 249 active = links[i]; 250 }; 251 li = links[i].parentNode.parentNode; 252 if (li.className == "closed") { 253 jQuery(li).click(plus_clicked); 254 } 255 } else { 256 jQuery(links[i]).click(page_click); 257 } 258 } 259 // attach events to the buttons 260 jQuery('#npd_save').click(npd_save); 261 jQuery('#npd_cancel').click(npd_cancel); 262 jQuery('#npd_new_folder').click(npd_new_folder); 263 264 // Allow enter to create new page 265 jQuery('#npd_page_name').keyup(function(e) { 266 if(e.keyCode == 13) npd_save(e); 267 }); 268 269 // add a root image 270 // prepare new node 271<?php 272$title = addcslashes($conf['title'], "'"); 273if (! $title) { 274 $title = 'Wiki'; 275} 276?> 277 var root = document.createElement('div'); 278 root.innerHTML = '<div class="li base"><a class="idx_dir" id="npd_root" href=":" ref=":"><strong><?php echo $title;?></strong></a></div>'; 279 root.className = 'base'; 280 var ul = firstDescendant(div); 281 if (ul) { 282 div.removeChild(ul); 283 } else { 284 ul = document.createElement("UL"); 285 ul.className = 'idx'; 286 } 287 var root_link = firstDescendant(firstDescendant(root)); 288 var child = firstDescendant(div); 289 if (child) { 290 div.insertBefore(root, child); 291 } else { 292 div.appendChild(root); 293 } 294 root.appendChild(ul); 295 jQuery(root_link).click(new_folder_click); 296 297 if ((typeof active) == 'undefined') { 298 // in case the namespace the popup was called from 299 // does not exist, we just make the root active 300 active = root_link; 301 active.className = "idx_dir active"; 302 jQuery('#npd_ns').val(""); 303 } 304 305 jQuery('#dw_page_div').show(); 306 jQuery('#npd_page_name').focus(); 307} 308function stop_event(e) 309{ 310 if (!!(window.attachEvent && !window.opera)){ 311 e.returnValue = false; 312 e.cancelBubble = true; 313 } else { 314 e.preventDefault(); 315 e.stopPropagation(); 316 } 317 e.stopped = true; 318} 319function escapeHTML(string) { 320 var div = document.createElement('div'); 321 var text = document.createTextNode(string); 322 div.appendChild(text); 323 return div.innerHTML; 324} 325//]]> 326</script> 327<style type="text/css"> 328#aep_ovrl { 329 background-color: black; 330 -moz-opacity: 0.7; opacity: 0.7; 331 top: 0; left: 0; position: fixed; 332 width: 100%; height:100%; z-index: 99; 333} 334#aep_ww { position: fixed; z-index: 100; top: 0; left: 0; width: 100%; height: 100%; text-align: center;} 335#aep_win { margin: 20% auto 0 auto; width: 400px; text-align: left;} 336#aep_w {background-color: white; padding: 3px; border: 1px solid black; background-color: #EEE;} 337#aep_t {color: white; margin: 0 0 2px 3px; font-family: Arial, sans-serif; font-size: 10pt;} 338#aep_text {width: 98%;} 339#aep_w span {font-family: Arial, sans-serif; font-size: 10pt;} 340#aep_w div {text-align: right; margin-top: 5px;} 341</style> 342<!-- IE specific code: --> 343<!--[if lte IE 7]> 344<style type="text/css"> 345#aep_ovrl { 346 position: absolute; 347 filter:alpha(opacity=70); 348 top: expression(eval(document.body.scrollTop)); 349 width: expression(eval(document.body.clientWidth)); 350} 351#aep_ww { 352 position: absolute; 353 top: expression(eval(document.body.scrollTop)); 354} 355</style> 356<![endif]--> 357 <link rel="shortcut icon" href="<?php echo DOKU_TPL?>images/favicon.ico" /> 358 359 <?php /*old includehook*/ @include(dirname(__FILE__).'/meta.html')?> 360</head> 361 362<body class="npd"> 363<!-- ae_prompt HTML code --> 364<div id="aep_ovrl" style="display: none;"> </div> 365<div id="aep_ww" style="display: none;"> 366<div id="aep_win"><div id="aep_t"></div> 367<div id="aep_w"><span id="aep_prompt"></span> 368<br /><input type="text" id="aep_text" onKeyPress= 369"if((event.keyCode==10)||(event.keyCode==13)) ae_clk(1); if (event.keyCode==27) ae_clk(0);"> 370<br><div><input type="button" id="aep_ok" onclick="ae_clk(1);" value="<?php echo addcslashes($npd->getLang('btn_ok'), '"'); ?>"> 371<input type="button" id="aep_cancel" onclick="ae_clk(0);" value="<?php echo addcslashes($lang['btn_cancel'], '"');?>"> 372</div></div> 373</div> 374</div> 375<!-- ae_prompt HTML code --> 376<?php /*old includehook*/ @include(dirname(__FILE__).'/topheader.html')?> 377<div class="npd"> 378 379 <?php flush()?> 380 381 <?php /*old includehook*/ @include(dirname(__FILE__).'/pageheader.html')?> 382 383 <div class="page" id="dw_page_div" style="display: none;"> 384 <!-- wikipage start --> 385 <?php tpl_content()?> 386 <!-- wikipage stop --> 387 </div> 388 <form action=''> 389 <input type="text" class="" style="display: none;" id="npd_ns" value="<?php echo trim($_REQUEST['idx'], ":"); ?>"/> 390 <input type="text" class="text default" id="npd_page_name" 391 value="<?php echo addcslashes($npd->getLang('msc_page_title'), '"'); ?>" 392 class="default" 393 onblur="if(this.value == '') { this.value = this.defaultValue; this.className = 'text default'; }" 394 onfocus="if(this.value==this.defaultValue) {this.value=''; this.className = 'text';}"/> 395 <input type="button" id="npd_save" class="text" value="<?php echo addcslashes($npd->getLang('btn_create_page'), '"');?>"/> 396 <input type="button" id="npd_cancel" class="text" value="<?php echo addcslashes($lang['btn_cancel'], '"');?>"/> 397 <input type="button" id="npd_new_folder" class="button" value="<?php echo addcslashes($npd->getLang('btn_new_folder'), '"')?>"/> 398 </form> 399 400 <div class="clearer"> </div> 401 402 <?php flush()?> 403 404<?php /*old includehook*/ @include(dirname(__FILE__).'/footer.html')?> 405 406<div class="no"><?php /* provide DokuWiki housekeeping, required in all templates */ tpl_indexerWebBug()?></div> 407</div> 408</body> 409</html> 410