1<?php 2/** 3 * Function for DokuWiki template Typo 4 * 5 * @author Michael Klier <chi@chimeric.de> 6 */ 7 8/** 9 * Prints the navigation 10 * 11 * @author Michael Klier <chi@chimeric.de> 12 */ 13function tpl_navigation() { 14 global $ID; 15 global $conf; 16 $navpage = tpl_getConf('navigation_page'); 17 list($ns, $chunk) = explode(':', $ID, 2); 18 $navpage = (page_exists($ns.':'.$navpage)) ? $ns.':'.$navpage : $navpage; 19 20 print '<div class="navigation">' . DOKU_LF; 21 if(!page_exists($navpage)) { 22 if(@file_exists(DOKU_TPLINC.'lang/'. $conf['lang'].'/nonavigation.txt')) { 23 $out = p_render('xhtml', p_get_instructions(io_readFile(DOKU_TPLINC.'lang/'.$conf['lang'].'/nonavigation.txt')), $info); 24 } else { 25 $out = p_render('xhtml', p_get_instructions(io_readFile(DOKU_TPLINC.'lang/en/nonavigation.txt')), $info); 26 } 27 $link = '<a href="' . wl($navpage) . '" class="wikilink2">' . $navpage . '</a>' . DOKU_LF; 28 print str_replace('LINK', $link, $out); 29 } else { 30 print p_wiki_xhtml($navpage); 31 } 32 print '</div>'; 33} 34 35/** 36 * Prints the actions links 37 * 38 * @author Michael Klier <chi@chimeric.de> 39 */ 40function tpl_actions() { 41 $actions = array('admin', 'revert', 'edit', 'history', 'recent', 'backlink', 'subscription', 'index', 'login', 'profile'); 42 43 print '<div class="sidebar_box">' . DOKU_LF; 44 print ' <ul>' . DOKU_LF; 45 46 foreach($actions as $action) { 47 if(!actionOK($action)) continue; 48 // start output buffering 49 if($action == 'edit') { 50 // check if new page button plugin is available 51 if(!plugin_isdisabled('npd') && ($npd =& plugin_load('helper', 'npd'))) { 52 $npb = $npd->html_new_page_button(true); 53 if($npb) { 54 print ' <li><div class="li">'; 55 print $npb; 56 print '</div></li>' . DOKU_LF; 57 } 58 } 59 } 60 ob_start(); 61 print ' <li><div class="li">'; 62 if(tpl_actionlink($action)) { 63 print '</div></li>' . DOKU_LF; 64 ob_end_flush(); 65 } else { 66 ob_end_clean(); 67 } 68 } 69 print ' </ul>' . DOKU_LF; 70 print '</div>' . DOKU_LF; 71} 72 73/** 74 * Print the search form 75 * 76 * If the first parameter is given a div with the ID 'qsearch_out' will 77 * be added which instructs the ajax pagequicksearch to kick in and place 78 * its output into this div. The second parameter controls the propritary 79 * attribute autocomplete. If set to false this attribute will be set with an 80 * value of "off" to instruct the browser to disable it's own built in 81 * autocompletion feature (MSIE and Firefox) 82 * 83 * @author Andreas Gohr <andi@splitbrain.org> 84 * 85 * @param bool $ajax 86 * @param bool $autocomplete 87 * @return bool 88 */ 89 90function tpl_searchform2($ajax = true, $autocomplete = true) { 91 global $lang; 92 global $ACT; 93 global $QUERY; 94 global $ID; 95 96 // don't print the search form if search action has been disabled 97 if(!actionOK('search')) return false; 98 99 $searchForm = new dokuwiki\Form\Form([ 100 'action' => wl(), 101 'method' => 'get', 102 'role' => 'search', 103 'class' => 'search', 104 'id' => 'dw__search', 105 ], true); 106 $searchForm->addTagOpen('div')->addClass('no'); 107 $searchForm->setHiddenField('do', 'search'); 108 $searchForm->setHiddenField('id', $ID); 109 $searchForm->addTextInput('q') 110 ->addClass('edit') 111 ->attrs([ 112 'title' => '[F]', 113 'accesskey' => 'f', 114 'placeholder' => $lang['btn_search'], 115 'autocomplete' => $autocomplete ? 'on' : 'off', 116 ]) 117 ->id('qsearch__in') 118 ->val($ACT === 'search' ? $QUERY : '') 119 ->useInput(false) 120 ; 121 $searchForm->addButton('', $lang['btn_search'])->attrs([ 122 'type' => 'submit', 123 'class' => 'button', 124 'title' => $lang['btn_search'], 125 ]); 126 if ($ajax) { 127 $searchForm->addTagOpen('div')->id('qsearch__out')->addClass('ajax_qsearch JSpopup'); 128 $searchForm->addTagClose('div'); 129 } 130 $searchForm->addTagClose('div'); 131 trigger_event('FORM_QUICKSEARCH_OUTPUT', $searchForm); 132 133 echo $searchForm->toHTML(); 134 135 return true; 136} 137 138// vim:ts=4:sw=4:et:enc=utf-8: 139