16b13307fSandi<?php 26b13307fSandi/** 36b13307fSandi * DokuWiki template functions 46b13307fSandi * 56b13307fSandi * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 66b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 76b13307fSandi */ 86b13307fSandi 9fa8adffeSAndreas Gohrif(!defined('DOKU_INC')) die('meh.'); 10e7cb32dcSAndreas Gohrrequire_once(DOKU_CONF.'dokuwiki.php'); 116b13307fSandi 126b13307fSandi/** 135a892029SAndreas Gohr * Returns the path to the given template, uses 14524be65dSBen Coburn * default one if the custom version doesn't exist. 155a892029SAndreas Gohr * 165a892029SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 175a892029SAndreas Gohr */ 185a892029SAndreas Gohrfunction template($tpl){ 195a892029SAndreas Gohr global $conf; 205a892029SAndreas Gohr 215a892029SAndreas Gohr if(@is_readable(DOKU_INC.'lib/tpl/'.$conf['template'].'/'.$tpl)) 225a892029SAndreas Gohr return DOKU_INC.'lib/tpl/'.$conf['template'].'/'.$tpl; 235a892029SAndreas Gohr 245a892029SAndreas Gohr return DOKU_INC.'lib/tpl/default/'.$tpl; 255a892029SAndreas Gohr} 265a892029SAndreas Gohr 275a892029SAndreas Gohr/** 286b13307fSandi * Print the content 296b13307fSandi * 306b13307fSandi * This function is used for printing all the usual content 316b13307fSandi * (defined by the global $ACT var) by calling the appropriate 326b13307fSandi * outputfunction(s) from html.php 336b13307fSandi * 34ee4c4a1bSAndreas Gohr * Everything that doesn't use the main template file isn't 35ee4c4a1bSAndreas Gohr * handled by this function. ACL stuff is not done here either. 366b13307fSandi * 376b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 386b13307fSandi */ 39b8595a66SAndreas Gohrfunction tpl_content($prependTOC=true) { 407ea0913cSchris global $ACT; 41b8595a66SAndreas Gohr global $INFO; 42b8595a66SAndreas Gohr $INFO['prependTOC'] = $prependTOC; 437ea0913cSchris 447ea0913cSchris ob_start(); 45746855cfSBen Coburn trigger_event('TPL_ACT_RENDER',$ACT,'tpl_content_core'); 467ea0913cSchris $html_output = ob_get_clean(); 47746855cfSBen Coburn trigger_event('TPL_CONTENT_DISPLAY',$html_output,'ptln'); 4854e95700STom N Harris 4954e95700STom N Harris return !empty($html_output); 507ea0913cSchris} 517ea0913cSchris 527ea0913cSchrisfunction tpl_content_core(){ 536b13307fSandi global $ACT; 546b13307fSandi global $TEXT; 556b13307fSandi global $PRE; 566b13307fSandi global $SUF; 576b13307fSandi global $SUM; 586b13307fSandi global $IDX; 596b13307fSandi 606b13307fSandi switch($ACT){ 616b13307fSandi case 'show': 626b13307fSandi html_show(); 636b13307fSandi break; 64ea67f144Sandi case 'preview': 656b13307fSandi html_edit($TEXT); 666b13307fSandi html_show($TEXT); 676b13307fSandi break; 68ee4c4a1bSAndreas Gohr case 'recover': 69ee4c4a1bSAndreas Gohr html_edit($TEXT); 70ee4c4a1bSAndreas Gohr break; 716b13307fSandi case 'edit': 726b13307fSandi html_edit(); 736b13307fSandi break; 74ee4c4a1bSAndreas Gohr case 'draft': 75ee4c4a1bSAndreas Gohr html_draft(); 76ee4c4a1bSAndreas Gohr break; 776b13307fSandi case 'wordblock': 786b13307fSandi html_edit($TEXT,'wordblock'); 796b13307fSandi break; 806b13307fSandi case 'search': 816b13307fSandi html_search(); 826b13307fSandi break; 836b13307fSandi case 'revisions': 8471726d78SBen Coburn $first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0; 8571726d78SBen Coburn html_revisions($first); 866b13307fSandi break; 876b13307fSandi case 'diff': 886b13307fSandi html_diff(); 896b13307fSandi break; 906b13307fSandi case 'recent': 91abdcc39fSmichael if (is_array($_REQUEST['first'])) { 92abdcc39fSmichael $_REQUEST['first'] = array_keys($_REQUEST['first']); 93abdcc39fSmichael $_REQUEST['first'] = $_REQUEST['first'][0]; 94abdcc39fSmichael } 955749f1ceSmatthiasgrimm $first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0; 96a39955b0Smatthiasgrimm html_recent($first); 976b13307fSandi break; 986b13307fSandi case 'index': 996b13307fSandi html_index($IDX); #FIXME can this be pulled from globals? is it sanitized correctly? 1006b13307fSandi break; 1016b13307fSandi case 'backlink': 1026b13307fSandi html_backlinks(); 1036b13307fSandi break; 1046b13307fSandi case 'conflict': 1056b13307fSandi html_conflict(con($PRE,$TEXT,$SUF),$SUM); 1066b13307fSandi html_diff(con($PRE,$TEXT,$SUF),false); 1076b13307fSandi break; 1086b13307fSandi case 'locked': 109ee20e7d1Sandi html_locked(); 11027eb9321SAnika Henke html_edit(); 1116b13307fSandi break; 1126b13307fSandi case 'login': 1136b13307fSandi html_login(); 1146b13307fSandi break; 1156b13307fSandi case 'register': 1166b13307fSandi html_register(); 1176b13307fSandi break; 1188b06d178Schris case 'resendpwd': 1198b06d178Schris html_resendpwd(); 1208b06d178Schris break; 121820fa24bSandi case 'denied': 1225e991bd8Sandi print p_locale_xhtml('denied'); 123820fa24bSandi break; 1248b06d178Schris case 'profile' : 1258b06d178Schris html_updateprofile(); 1268b06d178Schris break; 127c19fe9c0Sandi case 'admin': 128c19fe9c0Sandi tpl_admin(); 129c19fe9c0Sandi break; 1306b13307fSandi default: 13124bb549bSchris $evt = new Doku_Event('TPL_ACT_UNKNOWN',$ACT); 13224bb549bSchris if ($evt->advise_before()) 133ea67f144Sandi msg("Failed to handle command: ".hsc($ACT),-1); 13424bb549bSchris $evt->advise_after(); 13524bb549bSchris unset($evt); 13654e95700STom N Harris return false; 1376b13307fSandi } 13854e95700STom N Harris return true; 1396b13307fSandi} 1406b13307fSandi 141c19fe9c0Sandi/** 142b8595a66SAndreas Gohr * Places the TOC where the function is called 143b8595a66SAndreas Gohr * 144b8595a66SAndreas Gohr * If you use this you most probably want to call tpl_content with 145b8595a66SAndreas Gohr * a false argument 146b8595a66SAndreas Gohr * 147b8595a66SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 148b8595a66SAndreas Gohr */ 149b8595a66SAndreas Gohrfunction tpl_toc($return=false){ 150b8595a66SAndreas Gohr global $TOC; 151b8595a66SAndreas Gohr global $ACT; 152b8595a66SAndreas Gohr global $ID; 153b8595a66SAndreas Gohr global $REV; 154b8595a66SAndreas Gohr global $INFO; 155851f2e89SAnika Henke global $conf; 156b8595a66SAndreas Gohr $toc = array(); 157b8595a66SAndreas Gohr 158b8595a66SAndreas Gohr if(is_array($TOC)){ 159b8595a66SAndreas Gohr // if a TOC was prepared in global scope, always use it 160b8595a66SAndreas Gohr $toc = $TOC; 1613c86d7c9SAndreas Gohr }elseif(($ACT == 'show' || substr($ACT,0,6) == 'export') && !$REV && $INFO['exists']){ 162b8595a66SAndreas Gohr // get TOC from metadata, render if neccessary 163b8595a66SAndreas Gohr $meta = p_get_metadata($ID, false, true); 164b8595a66SAndreas Gohr if(isset($meta['internal']['toc'])){ 165b8595a66SAndreas Gohr $tocok = $meta['internal']['toc']; 166b8595a66SAndreas Gohr }else{ 1672bb0d541Schris $tocok = true; 168b8595a66SAndreas Gohr } 169b8595a66SAndreas Gohr $toc = $meta['description']['tableofcontents']; 170851f2e89SAnika Henke if(!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']){ 171b8595a66SAndreas Gohr $toc = array(); 172b8595a66SAndreas Gohr } 173b8595a66SAndreas Gohr }elseif($ACT == 'admin'){ 174b8595a66SAndreas Gohr // try to load admin plugin TOC FIXME: duplicates code from tpl_admin 175b8595a66SAndreas Gohr $plugin = null; 176b8595a66SAndreas Gohr if (!empty($_REQUEST['page'])) { 177b8595a66SAndreas Gohr $pluginlist = plugin_list('admin'); 178b8595a66SAndreas Gohr if (in_array($_REQUEST['page'], $pluginlist)) { 179b8595a66SAndreas Gohr // attempt to load the plugin 180b8595a66SAndreas Gohr $plugin =& plugin_load('admin',$_REQUEST['page']); 181b8595a66SAndreas Gohr } 182b8595a66SAndreas Gohr } 183b8595a66SAndreas Gohr if ( ($plugin !== null) && 184b8595a66SAndreas Gohr (!$plugin->forAdminOnly() || $INFO['isadmin']) ){ 185b8595a66SAndreas Gohr $toc = $plugin->getTOC(); 186b8595a66SAndreas Gohr $TOC = $toc; // avoid later rebuild 187b8595a66SAndreas Gohr } 188b8595a66SAndreas Gohr } 189b8595a66SAndreas Gohr 1907dee3468SGina Haeussge trigger_event('TPL_TOC_RENDER', $toc, NULL, false); 191b8595a66SAndreas Gohr $html = html_TOC($toc); 192b8595a66SAndreas Gohr if($return) return $html; 193b8595a66SAndreas Gohr echo $html; 194b8595a66SAndreas Gohr} 195b8595a66SAndreas Gohr 196b8595a66SAndreas Gohr/** 197c19fe9c0Sandi * Handle the admin page contents 198c19fe9c0Sandi * 199c19fe9c0Sandi * @author Andreas Gohr <andi@splitbrain.org> 200c19fe9c0Sandi */ 201c19fe9c0Sandifunction tpl_admin(){ 202f8cc712eSAndreas Gohr global $INFO; 203b8595a66SAndreas Gohr global $TOC; 20411e2ce22Schris 205b8595a66SAndreas Gohr $plugin = null; 206bb4866bdSchris if (!empty($_REQUEST['page'])) { 20711e2ce22Schris $pluginlist = plugin_list('admin'); 20811e2ce22Schris 20911e2ce22Schris if (in_array($_REQUEST['page'], $pluginlist)) { 21011e2ce22Schris 21111e2ce22Schris // attempt to load the plugin 21211e2ce22Schris $plugin =& plugin_load('admin',$_REQUEST['page']); 21311e2ce22Schris } 21411e2ce22Schris } 21511e2ce22Schris 216b8595a66SAndreas Gohr if ($plugin !== null){ 217f8cc712eSAndreas Gohr if($plugin->forAdminOnly() && !$INFO['isadmin']){ 218f8cc712eSAndreas Gohr msg('For admins only',-1); 21911e2ce22Schris html_admin(); 220f8cc712eSAndreas Gohr }else{ 221b8595a66SAndreas Gohr if(!is_array($TOC)) $TOC = $plugin->getTOC(); //if TOC wasn't requested yet 222b8595a66SAndreas Gohr if($INFO['prependTOC']) tpl_toc(); 223f8cc712eSAndreas Gohr $plugin->html(); 224f8cc712eSAndreas Gohr } 225f8cc712eSAndreas Gohr }else{ 226f8cc712eSAndreas Gohr html_admin(); 227f8cc712eSAndreas Gohr } 22854e95700STom N Harris return true; 229c19fe9c0Sandi} 2306b13307fSandi 2316b13307fSandi/** 2326b13307fSandi * Print the correct HTML meta headers 2336b13307fSandi * 2346b13307fSandi * This has to go into the head section of your template. 2356b13307fSandi * 236016b6153SAndreas Gohr * @triggers TPL_METAHEADER_OUTPUT 237f96fa415SAndreas Gohr * @param boolean $alt Should feeds and alternative format links be added? 2386b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 2396b13307fSandi */ 240f96fa415SAndreas Gohrfunction tpl_metaheaders($alt=true){ 2416b13307fSandi global $ID; 242d98d4540SBen Coburn global $REV; 2436b13307fSandi global $INFO; 2446b13307fSandi global $ACT; 2454bb1b5aeSAndreas Gohr global $QUERY; 2466b13307fSandi global $lang; 247dc57ef04Sandi global $conf; 2486b13307fSandi $it=2; 2496b13307fSandi 2507bff22c0SAndreas Gohr // prepare the head array 2517bff22c0SAndreas Gohr $head = array(); 2527bff22c0SAndreas Gohr 2537bff22c0SAndreas Gohr 2546b13307fSandi // the usual stuff 2557bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'generator', 'content'=>'DokuWiki '.getVersion() ); 256da96af35SAndreas Gohr $head['link'][] = array( 'rel'=>'search', 'type'=>'application/opensearchdescription+xml', 257da96af35SAndreas Gohr 'href'=>DOKU_BASE.'lib/exe/opensearch.php', 'title'=>$conf['title'] ); 258f4f47358SBen Coburn $head['link'][] = array( 'rel'=>'start', 'href'=>DOKU_BASE ); 2597aedde2eSGina Haeussge if(actionOK('index')){ 2607bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'contents', 'href'=> wl($ID,'do=index',false,'&'), 261bb4866bdSchris 'title'=>$lang['btn_index'] ); 2627aedde2eSGina Haeussge } 263f96fa415SAndreas Gohr 264f96fa415SAndreas Gohr if($alt){ 2657bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 2667bff22c0SAndreas Gohr 'title'=>'Recent Changes', 'href'=>DOKU_BASE.'feed.php'); 2677bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 2687bff22c0SAndreas Gohr 'title'=>'Current Namespace', 2697bff22c0SAndreas Gohr 'href'=>DOKU_BASE.'feed.php?mode=list&ns='.$INFO['namespace']); 270c35f3875SAndreas Gohr if(($ACT == 'show' || $ACT == 'search') && $INFO['writable']){ 271c35f3875SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/wiki', 272715bdf1fSAndreas Gohr 'title'=>$lang['btn_edit'], 273c35f3875SAndreas Gohr 'href'=> wl($ID,'do=edit',false,'&')); 274c35f3875SAndreas Gohr } 275c35f3875SAndreas Gohr 2764bb1b5aeSAndreas Gohr if($ACT == 'search'){ 2774bb1b5aeSAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 2784bb1b5aeSAndreas Gohr 'title'=>'Search Result', 2794bb1b5aeSAndreas Gohr 'href'=>DOKU_BASE.'feed.php?mode=search&q='.$QUERY); 2804bb1b5aeSAndreas Gohr } 281bae36d94SAndreas Gohr 282bae36d94SAndreas Gohr if(actionOK('export_xhtml')){ 2837bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'text/html', 'title'=>'Plain HTML', 2847bff22c0SAndreas Gohr 'href'=>exportlink($ID, 'xhtml', '', false, '&')); 285bae36d94SAndreas Gohr } 286bae36d94SAndreas Gohr 287bae36d94SAndreas Gohr if(actionOK('export_raw')){ 2887bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'text/plain', 'title'=>'Wiki Markup', 2897bff22c0SAndreas Gohr 'href'=>exportlink($ID, 'raw', '', false, '&')); 290f96fa415SAndreas Gohr } 291bae36d94SAndreas Gohr } 2926b13307fSandi 2936b13307fSandi // setup robot tags apropriate for different modes 2944f2e0004STim Weber if( ($ACT=='show' || $ACT=='export_xhtml') && !$REV){ 2956b13307fSandi if($INFO['exists']){ 2966b13307fSandi //delay indexing: 2976b13307fSandi if((time() - $INFO['lastmod']) >= $conf['indexdelay']){ 2987bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'index,follow'); 2996b13307fSandi }else{ 3007bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,nofollow'); 3016b13307fSandi } 3026b13307fSandi }else{ 3037bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,follow'); 3046b13307fSandi } 3057a24876fSAndreas Gohr }elseif(defined('DOKU_MEDIADETAIL')){ 3067bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'index,follow'); 3076b13307fSandi }else{ 3087bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,nofollow'); 3096b13307fSandi } 3106b13307fSandi 311831800b8SAndreas Gohr // set metadata 312831800b8SAndreas Gohr if($ACT == 'show' || $ACT=='export_xhtml'){ 313831800b8SAndreas Gohr // date of modification 314831800b8SAndreas Gohr if($REV){ 3157bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'date', 'content'=>date('Y-m-d\TH:i:sO',$REV)); 316831800b8SAndreas Gohr }else{ 3177bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'date', 'content'=>date('Y-m-d\TH:i:sO',$INFO['lastmod'])); 318831800b8SAndreas Gohr } 319831800b8SAndreas Gohr 320831800b8SAndreas Gohr // keywords (explicit or implicit) 321bb4866bdSchris if(!empty($INFO['meta']['subject'])){ 3227bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'keywords', 'content'=>join(',',$INFO['meta']['subject'])); 323831800b8SAndreas Gohr }else{ 3247bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'keywords', 'content'=>str_replace(':',',',$ID)); 325831800b8SAndreas Gohr } 326831800b8SAndreas Gohr } 327831800b8SAndreas Gohr 32878a6aeb1SAndreas Gohr // load stylesheets 3297aaa4c46Smartin.tschofen $head['link'][] = array('rel'=>'stylesheet', 'media'=>'all', 'type'=>'text/css', 330124af657SAndreas Gohr 'href'=>DOKU_BASE.'lib/exe/css.php?s=all&t='.$conf['template']); 3317bff22c0SAndreas Gohr $head['link'][] = array('rel'=>'stylesheet', 'media'=>'screen', 'type'=>'text/css', 332124af657SAndreas Gohr 'href'=>DOKU_BASE.'lib/exe/css.php?t='.$conf['template']); 3337bff22c0SAndreas Gohr $head['link'][] = array('rel'=>'stylesheet', 'media'=>'print', 'type'=>'text/css', 334124af657SAndreas Gohr 'href'=>DOKU_BASE.'lib/exe/css.php?s=print&t='.$conf['template']); 335bad31ae9SAndreas Gohr 33678a6aeb1SAndreas Gohr // load javascript 337041d1964SAndreas Gohr $js_edit = ($ACT=='edit' || $ACT=='preview' || $ACT=='recover' || $ACT=='wordblock' ) ? 1 : 0; 338bad31ae9SAndreas Gohr $js_write = ($INFO['writable']) ? 1 : 0; 3393df72098SAndreas Gohr if(defined('DOKU_MEDIAMANAGER')){ 3403df72098SAndreas Gohr $js_edit = 1; 3413df72098SAndreas Gohr $js_write = 0; 3423df72098SAndreas Gohr } 3433df72098SAndreas Gohr if(($js_edit && $js_write) || defined('DOKU_MEDIAMANAGER')){ 3447bff22c0SAndreas Gohr $script = "NS='".$INFO['namespace']."';"; 345c591aabeSAndreas Gohr if($conf['useacl'] && $_SERVER['REMOTE_USER']){ 346aeaccbf9SAndreas Gohr require_once(DOKU_INC.'inc/toolbar.php'); 3477bff22c0SAndreas Gohr $script .= "SIG='".toolbar_signature()."';"; 348c591aabeSAndreas Gohr } 3497bff22c0SAndreas Gohr $head['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', 3507bff22c0SAndreas Gohr '_data'=> $script); 351c591aabeSAndreas Gohr } 3527bff22c0SAndreas Gohr $head['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', '_data'=>'', 3537bff22c0SAndreas Gohr 'src'=>DOKU_BASE.'lib/exe/js.php?edit='.$js_edit.'&write='.$js_write); 3547bff22c0SAndreas Gohr 3557bff22c0SAndreas Gohr // trigger event here 356016b6153SAndreas Gohr trigger_event('TPL_METAHEADER_OUTPUT',$head,'_tpl_metaheaders_action',true); 35754e95700STom N Harris return true; 3587bff22c0SAndreas Gohr} 3597bff22c0SAndreas Gohr 3607bff22c0SAndreas Gohr/** 3617bff22c0SAndreas Gohr * prints the array build by tpl_metaheaders 3627bff22c0SAndreas Gohr * 3637bff22c0SAndreas Gohr * $data is an array of different header tags. Each tag can have multiple 3647bff22c0SAndreas Gohr * instances. Attributes are given as key value pairs. Values will be HTML 3657bff22c0SAndreas Gohr * encoded automatically so they should be provided as is in the $data array. 3667bff22c0SAndreas Gohr * 3677bff22c0SAndreas Gohr * For tags having a body attribute specify the the body data in the special 3681304d1dbSAndreas Gohr * attribute '_data'. This field will NOT BE ESCAPED automatically. 3697bff22c0SAndreas Gohr * 3707bff22c0SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 3717bff22c0SAndreas Gohr */ 3727bff22c0SAndreas Gohrfunction _tpl_metaheaders_action($data){ 3737bff22c0SAndreas Gohr foreach($data as $tag => $inst){ 3747bff22c0SAndreas Gohr foreach($inst as $attr){ 3757bff22c0SAndreas Gohr echo '<',$tag,' ',buildAttributes($attr); 3767bff22c0SAndreas Gohr if(isset($attr['_data'])){ 377e226efe1SAndreas Gohr if($tag == 'script' && $attr['_data']) 378e226efe1SAndreas Gohr $attr['_data'] = "<!--//--><![CDATA[//><!--\n". 379e226efe1SAndreas Gohr $attr['_data']. 380e226efe1SAndreas Gohr "\n//--><!]]>"; 381e226efe1SAndreas Gohr 3821304d1dbSAndreas Gohr echo '>',$attr['_data'],'</',$tag,'>'; 3837bff22c0SAndreas Gohr }else{ 3847bff22c0SAndreas Gohr echo '/>'; 3857bff22c0SAndreas Gohr } 3867bff22c0SAndreas Gohr echo "\n"; 3877bff22c0SAndreas Gohr } 3887bff22c0SAndreas Gohr } 3896b13307fSandi} 3906b13307fSandi 3916b13307fSandi/** 3926b13307fSandi * Print a link 3936b13307fSandi * 3945e163278SAndreas Gohr * Just builds a link. 3956b13307fSandi * 3966b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 3976b13307fSandi */ 3986b13307fSandifunction tpl_link($url,$name,$more=''){ 3995e163278SAndreas Gohr print '<a href="'.$url.'" '; 4006b13307fSandi if ($more) print ' '.$more; 4016b13307fSandi print ">$name</a>"; 40254e95700STom N Harris return true; 4036b13307fSandi} 4046b13307fSandi 4056b13307fSandi/** 40655efc227SAndreas Gohr * Prints a link to a WikiPage 40755efc227SAndreas Gohr * 40855efc227SAndreas Gohr * Wrapper around html_wikilink 40955efc227SAndreas Gohr * 41055efc227SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 41155efc227SAndreas Gohr */ 41255efc227SAndreas Gohrfunction tpl_pagelink($id,$name=NULL){ 41355efc227SAndreas Gohr print html_wikilink($id,$name); 41454e95700STom N Harris return true; 41555efc227SAndreas Gohr} 41655efc227SAndreas Gohr 41755efc227SAndreas Gohr/** 418a3ec5f4aSmatthiasgrimm * get the parent page 419a3ec5f4aSmatthiasgrimm * 420a3ec5f4aSmatthiasgrimm * Tries to find out which page is parent. 421a3ec5f4aSmatthiasgrimm * returns false if none is available 422a3ec5f4aSmatthiasgrimm * 423377f9e97SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 424a3ec5f4aSmatthiasgrimm */ 425377f9e97SAndreas Gohrfunction tpl_getparent($id){ 426a3ec5f4aSmatthiasgrimm global $conf; 427377f9e97SAndreas Gohr $parent = getNS($id).':'; 428377f9e97SAndreas Gohr resolve_pageid('',$parent,$exists); 429a197105eSmatthiasgrimm if($parent == $id) { 430a197105eSmatthiasgrimm $pos = strrpos (getNS($id),':'); 431a197105eSmatthiasgrimm $parent = substr($parent,0,$pos).':'; 432a197105eSmatthiasgrimm resolve_pageid('',$parent,$exists); 433377f9e97SAndreas Gohr if($parent == $id) return false; 434a197105eSmatthiasgrimm } 435377f9e97SAndreas Gohr return $parent; 436a3ec5f4aSmatthiasgrimm} 437a3ec5f4aSmatthiasgrimm 438a3ec5f4aSmatthiasgrimm/** 4396b13307fSandi * Print one of the buttons 4406b13307fSandi * 4416b13307fSandi * Available Buttons are 4426b13307fSandi * 443ee4c4a1bSAndreas Gohr * edit - edit/create/show/draft button 4446b13307fSandi * history - old revisions 4456b13307fSandi * recent - recent changes 4466b13307fSandi * login - login/logout button - if ACL enabled 447d449b912SDenis Simakov * profile - user profile button (if logged in) 4486b13307fSandi * index - The index 449c19fe9c0Sandi * admin - admin page - if enough rights 4506b13307fSandi * top - a back to top button 451a3ec5f4aSmatthiasgrimm * back - a back to parent button - if available 452bbd37938SAndreas Gohr * backlink - links to the list of backlinks 453d449b912SDenis Simakov * subscription- subscribe/unsubscribe button 4546b13307fSandi * 4556b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 456a3ec5f4aSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 4576b13307fSandi */ 4586b13307fSandifunction tpl_button($type){ 459b158d625SSteven Danz global $ACT; 4606b13307fSandi global $ID; 461d98d4540SBen Coburn global $REV; 462d67ca2c0Smatthiasgrimm global $NS; 463c19fe9c0Sandi global $INFO; 4646b13307fSandi global $conf; 465cd52f92dSchris global $auth; 4666b13307fSandi 46775e487e9SAndreas Gohr // check disabled actions and fix the badly named ones 46875e487e9SAndreas Gohr $ctype = $type; 46975e487e9SAndreas Gohr if($type == 'history') $ctype='revisions'; 47054e95700STom N Harris if(!actionOK($ctype)) return false; 471409d7af7SAndreas Gohr 4726b13307fSandi switch($type){ 4736b13307fSandi case 'edit': 474409d7af7SAndreas Gohr #most complicated type - we need to decide on current action 475409d7af7SAndreas Gohr if($ACT == 'show' || $ACT == 'search'){ 476409d7af7SAndreas Gohr if($INFO['writable']){ 477bb4866bdSchris if(!empty($INFO['draft'])){ 478409d7af7SAndreas Gohr echo html_btn('draft',$ID,'e',array('do' => 'draft'),'post'); 479409d7af7SAndreas Gohr }else{ 480409d7af7SAndreas Gohr if($INFO['exists']){ 481409d7af7SAndreas Gohr echo html_btn('edit',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 482409d7af7SAndreas Gohr }else{ 483409d7af7SAndreas Gohr echo html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 484409d7af7SAndreas Gohr } 485409d7af7SAndreas Gohr } 486409d7af7SAndreas Gohr }else{ 487409d7af7SAndreas Gohr if(!actionOK('source')) return false; //pseudo action 488409d7af7SAndreas Gohr echo html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post'); 489409d7af7SAndreas Gohr } 490409d7af7SAndreas Gohr }else{ 491409d7af7SAndreas Gohr echo html_btn('show',$ID,'v',array('do' => 'show')); 492409d7af7SAndreas Gohr } 49354e95700STom N Harris return true; 4946b13307fSandi case 'history': 4957aedde2eSGina Haeussge if(!actionOK('revisions')) 4967aedde2eSGina Haeussge return false; 4975bc81eb9SAnders Betnér print html_btn('revs',$ID,'o',array('do' => 'revisions')); 49854e95700STom N Harris return true; 4996b13307fSandi case 'recent': 5007aedde2eSGina Haeussge if(!actionOK('recent')) 5017aedde2eSGina Haeussge return false; 502e83cef14SGina Haeussge print html_btn('recent',$ID,'r',array('do' => 'recent')); 50354e95700STom N Harris return true; 5046b13307fSandi case 'index': 5057aedde2eSGina Haeussge if(!actionOK('index')) 5067aedde2eSGina Haeussge return false; 5075bc81eb9SAnders Betnér print html_btn('index',$ID,'x',array('do' => 'index')); 50854e95700STom N Harris return true; 509a3ec5f4aSmatthiasgrimm case 'back': 5106222040cSmatthiasgrimm if ($parent = tpl_getparent($ID)) { 5116222040cSmatthiasgrimm print html_btn('back',$parent,'b',array('do' => 'show')); 51254e95700STom N Harris return true; 513a3ec5f4aSmatthiasgrimm } 51454e95700STom N Harris return false; 5156b13307fSandi case 'top': 5166b13307fSandi print html_topbtn(); 51754e95700STom N Harris return true; 5186b13307fSandi case 'login': 5196957b2eaSAndreas Gohr if($conf['useacl'] && $auth){ 5206b13307fSandi if($_SERVER['REMOTE_USER']){ 521cc670e1bSMichael Klier print html_btn('logout',$ID,'',array('do' => 'logout', 'sectok' => getSecurityToken())); 5226b13307fSandi }else{ 523cc670e1bSMichael Klier print html_btn('login',$ID,'',array('do' => 'login', 'sectok' => getSecurityToken())); 5246b13307fSandi } 52554e95700STom N Harris return true; 5266b13307fSandi } 52754e95700STom N Harris return false; 528c19fe9c0Sandi case 'admin': 52954e95700STom N Harris if($INFO['ismanager']){ 5305bc81eb9SAnders Betnér print html_btn('admin',$ID,'',array('do' => 'admin')); 53154e95700STom N Harris return true; 53254e95700STom N Harris } 53354e95700STom N Harris return false; 534582c5bfeSAndreas Gohr case 'subscribe': 5351380fc45SAndreas Gohr case 'subscription': 5366957b2eaSAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 537b158d625SSteven Danz if($_SERVER['REMOTE_USER']){ 5381380fc45SAndreas Gohr if($INFO['subscribed']){ 5397aedde2eSGina Haeussge if(!actionOK('unsubscribe')) 5407aedde2eSGina Haeussge return false; 5411380fc45SAndreas Gohr print html_btn('unsubscribe',$ID,'',array('do' => 'unsubscribe',)); 542b158d625SSteven Danz } else { 5437aedde2eSGina Haeussge if(!actionOK('subscribe')) 5447aedde2eSGina Haeussge return false; 5451380fc45SAndreas Gohr print html_btn('subscribe',$ID,'',array('do' => 'subscribe',)); 546b158d625SSteven Danz } 547582c5bfeSAndreas Gohr if($type == 'subscribe') return true; 548582c5bfeSAndreas Gohr } 549582c5bfeSAndreas Gohr } 550582c5bfeSAndreas Gohr if($type == 'subscribe') return false; 551582c5bfeSAndreas Gohr // fall through for backward compatibility 552582c5bfeSAndreas Gohr case 'subscribens': 553582c5bfeSAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 554582c5bfeSAndreas Gohr if($_SERVER['REMOTE_USER']){ 55552b0dd67SGuy Brand if($INFO['subscribedns']){ 5567aedde2eSGina Haeussge if(!actionOK('unsubscribens')) 5577aedde2eSGina Haeussge return false; 55852b0dd67SGuy Brand print html_btn('unsubscribens',$ID,'',array('do' => 'unsubscribens',)); 55952b0dd67SGuy Brand } else { 5607aedde2eSGina Haeussge if(!actionOK('subscribens')) 5617aedde2eSGina Haeussge return false; 56252b0dd67SGuy Brand print html_btn('subscribens',$ID,'',array('do' => 'subscribens',)); 56352b0dd67SGuy Brand } 56454e95700STom N Harris return true; 565b158d625SSteven Danz } 566b158d625SSteven Danz } 56754e95700STom N Harris return false; 568f00151b4Schris case 'backlink': 5697aedde2eSGina Haeussge if(!actionOK('backlink')) 5707aedde2eSGina Haeussge return false; 571f00151b4Schris print html_btn('backlink',$ID,'',array('do' => 'backlink')); 57254e95700STom N Harris return true; 5738b06d178Schris case 'profile': 5746957b2eaSAndreas Gohr if($conf['useacl'] && $_SERVER['REMOTE_USER'] && $auth && 57536223ba7SAndreas Gohr $auth->canDo('Profile') && ($ACT!='profile')){ 5768b06d178Schris print html_btn('profile',$ID,'',array('do' => 'profile')); 57754e95700STom N Harris return true; 5788b06d178Schris } 57954e95700STom N Harris return false; 580c19fe9c0Sandi default: 581c19fe9c0Sandi print '[unknown button type]'; 58254e95700STom N Harris return true; 5836b13307fSandi } 5846b13307fSandi} 5856b13307fSandi 5866b13307fSandi/** 587ed630903Sandi * Like the action buttons but links 588ed630903Sandi * 589ed630903Sandi * Available links are 590ed630903Sandi * 591d449b912SDenis Simakov * edit - edit/create/show link 592ed630903Sandi * history - old revisions 593ed630903Sandi * recent - recent changes 594d449b912SDenis Simakov * login - login/logout link - if ACL enabled 595d449b912SDenis Simakov * profile - user profile link (if logged in) 596ed630903Sandi * index - The index 597ed630903Sandi * admin - admin page - if enough rights 598d449b912SDenis Simakov * top - a back to top link 599d449b912SDenis Simakov * back - a back to parent link - if available 600bbd37938SAndreas Gohr * backlink - links to the list of backlinks 601d449b912SDenis Simakov * subscribe/subscription - subscribe/unsubscribe link 602ed630903Sandi * 603ed630903Sandi * @author Andreas Gohr <andi@splitbrain.org> 604a3ec5f4aSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 605ed630903Sandi * @see tpl_button 606ed630903Sandi */ 607c97dfb07SAndreas Gohrfunction tpl_actionlink($type,$pre='',$suf='',$inner=''){ 608ed630903Sandi global $ID; 609ed630903Sandi global $INFO; 610ed630903Sandi global $REV; 611ed630903Sandi global $ACT; 612ed630903Sandi global $conf; 613ed630903Sandi global $lang; 614cd52f92dSchris global $auth; 615ed630903Sandi 61675e487e9SAndreas Gohr // check disabled actions and fix the badly named ones 61775e487e9SAndreas Gohr $ctype = $type; 61875e487e9SAndreas Gohr if($type == 'history') $ctype='revisions'; 61954e95700STom N Harris if(!actionOK($ctype)) return false; 620409d7af7SAndreas Gohr 621ed630903Sandi switch($type){ 622ed630903Sandi case 'edit': 623ed630903Sandi #most complicated type - we need to decide on current action 624ed630903Sandi if($ACT == 'show' || $ACT == 'search'){ 625ed630903Sandi if($INFO['writable']){ 626b8a111f5SMichael Klier if(!empty($INFO['draft'])) { 627b8a111f5SMichael Klier tpl_link(wl($ID,'do=draft'), 628c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_draft']).$suf, 629f6547e5dSAndreas Gohr 'class="action edit" accesskey="e" rel="nofollow"'); 630b8a111f5SMichael Klier } else { 631ed630903Sandi if($INFO['exists']){ 632ed630903Sandi tpl_link(wl($ID,'do=edit&rev='.$REV), 633c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_edit']).$suf, 634b7af031cSsu 'class="action edit" accesskey="e" rel="nofollow"'); 635ed630903Sandi }else{ 636ed630903Sandi tpl_link(wl($ID,'do=edit&rev='.$REV), 637c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_create']).$suf, 638b7af031cSsu 'class="action create" accesskey="e" rel="nofollow"'); 639ed630903Sandi } 640b8a111f5SMichael Klier } 641ed630903Sandi }else{ 642409d7af7SAndreas Gohr if(!actionOK('source')) return false; //pseudo action 643ed630903Sandi tpl_link(wl($ID,'do=edit&rev='.$REV), 644c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_source']).$suf, 645b7af031cSsu 'class="action source" accesskey="v" rel="nofollow"'); 646ed630903Sandi } 647ed630903Sandi }else{ 648ed630903Sandi tpl_link(wl($ID,'do=show'), 649c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_show']).$suf, 650b7af031cSsu 'class="action show" accesskey="v" rel="nofollow"'); 651ed630903Sandi } 652c059e1a6SAndreas Gohr return true; 653ed630903Sandi case 'history': 6547aedde2eSGina Haeussge if(!actionOK('revisions')) 6557aedde2eSGina Haeussge return false; 656c97dfb07SAndreas Gohr tpl_link(wl($ID,'do=revisions'), 657c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_revs']).$suf, 658c97dfb07SAndreas Gohr 'class="action revisions" accesskey="o" rel="nofollow"'); 659c059e1a6SAndreas Gohr return true; 660ed630903Sandi case 'recent': 6617aedde2eSGina Haeussge if(!actionOK('recent')) 6627aedde2eSGina Haeussge return false; 663ca6b84ccSGina Haeussge tpl_link(wl($ID,'do=recent'), 664c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_recent']).$suf, 665c97dfb07SAndreas Gohr 'class="action recent" accesskey="r" rel="nofollow"'); 666c059e1a6SAndreas Gohr return true; 667ed630903Sandi case 'index': 6687aedde2eSGina Haeussge if(!actionOK('index')) 6697aedde2eSGina Haeussge return false; 670c97dfb07SAndreas Gohr tpl_link(wl($ID,'do=index'), 671c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_index']).$suf, 672c97dfb07SAndreas Gohr 'class="action index" accesskey="x" rel="nofollow"'); 673c059e1a6SAndreas Gohr return true; 674ed630903Sandi case 'top': 675c97dfb07SAndreas Gohr print '<a href="#dokuwiki__top" class="action top" accesskey="x">'. 676c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_top']).$suf.'</a>'; 677c059e1a6SAndreas Gohr return true; 678a3ec5f4aSmatthiasgrimm case 'back': 679f7569b7bSAndreas Gohr if ($parent = tpl_getparent($ID)) { 680c97dfb07SAndreas Gohr tpl_link(wl($parent,'do=show'), 681c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_back']).$suf, 682c97dfb07SAndreas Gohr 'class="action back" accesskey="b" rel="nofollow"'); 683c059e1a6SAndreas Gohr return true; 684a3ec5f4aSmatthiasgrimm } 685c059e1a6SAndreas Gohr return false; 686ed630903Sandi case 'login': 6876957b2eaSAndreas Gohr if($conf['useacl'] && $auth){ 688ed630903Sandi if($_SERVER['REMOTE_USER']){ 689cc670e1bSMichael Klier tpl_link(wl($ID,'do=logout&sectok='.getSecurityToken()), 690c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_logout']).$suf, 691c97dfb07SAndreas Gohr 'class="action logout" rel="nofollow"'); 692ed630903Sandi }else{ 693cc670e1bSMichael Klier tpl_link(wl($ID,'do=login&sectok='.getSecurityToken()), 694c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_login']).$suf, 695c97dfb07SAndreas Gohr 'class="action login" rel="nofollow"'); 696ed630903Sandi } 697c059e1a6SAndreas Gohr return true; 698ed630903Sandi } 699c059e1a6SAndreas Gohr return false; 700ed630903Sandi case 'admin': 701f8cc712eSAndreas Gohr if($INFO['ismanager']){ 702c97dfb07SAndreas Gohr tpl_link(wl($ID,'do=admin'), 703c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_admin']).$suf, 704c97dfb07SAndreas Gohr 'class="action admin" rel="nofollow"'); 705c059e1a6SAndreas Gohr return true; 706c059e1a6SAndreas Gohr } 707c059e1a6SAndreas Gohr return false; 708f9eb5648Ssteven-danz case 'subscribe': 709075f000fSChristopher Arndt case 'subscription': 7106957b2eaSAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 711b158d625SSteven Danz if($_SERVER['REMOTE_USER']){ 712075f000fSChristopher Arndt if($INFO['subscribed']) { 7137aedde2eSGina Haeussge if(!actionOK('unsubscribe')) 7147aedde2eSGina Haeussge return false; 715c97dfb07SAndreas Gohr tpl_link(wl($ID,'do=unsubscribe'), 716c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_unsubscribe']).$suf, 717c97dfb07SAndreas Gohr 'class="action unsubscribe" rel="nofollow"'); 718b158d625SSteven Danz } else { 7197aedde2eSGina Haeussge if(!actionOK('subscribe')) 7207aedde2eSGina Haeussge return false; 721c97dfb07SAndreas Gohr tpl_link(wl($ID,'do=subscribe'), 722c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_subscribe']).$suf, 723c97dfb07SAndreas Gohr 'class="action subscribe" rel="nofollow"'); 724b158d625SSteven Danz } 725c059e1a6SAndreas Gohr return true; 726b158d625SSteven Danz } 727b158d625SSteven Danz } 728c059e1a6SAndreas Gohr return false; 729280f11b7SMichael Klier case 'subscribens': 730280f11b7SMichael Klier if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 731280f11b7SMichael Klier if($_SERVER['REMOTE_USER']){ 732280f11b7SMichael Klier if($INFO['subscribedns']) { 7337aedde2eSGina Haeussge if(!actionOK('unsubscribens')) 7347aedde2eSGina Haeussge return false; 735280f11b7SMichael Klier tpl_link(wl($ID,'do=unsubscribens'), 736280f11b7SMichael Klier $pre.(($inner)?$inner:$lang['btn_unsubscribens']).$suf, 737280f11b7SMichael Klier 'class="action unsubscribens" rel="nofollow"'); 738280f11b7SMichael Klier } else { 7397aedde2eSGina Haeussge if(!actionOK('subscribens')) 7407aedde2eSGina Haeussge return false; 741280f11b7SMichael Klier tpl_link(wl($ID,'do=subscribens'), 742280f11b7SMichael Klier $pre.(($inner)?$inner:$lang['btn_subscribens']).$suf, 743280f11b7SMichael Klier 'class="action subscribens" rel="nofollow"'); 744280f11b7SMichael Klier } 745280f11b7SMichael Klier return true; 746280f11b7SMichael Klier } 747280f11b7SMichael Klier } 748280f11b7SMichael Klier return false; 749f00151b4Schris case 'backlink': 7507aedde2eSGina Haeussge if(!actionOK('backlink')) 7517aedde2eSGina Haeussge return false; 752c97dfb07SAndreas Gohr tpl_link(wl($ID,'do=backlink'), 753c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_backlink']).$suf, 754c97dfb07SAndreas Gohr 'class="action backlink" rel="nofollow"'); 755c059e1a6SAndreas Gohr return true; 7568b06d178Schris case 'profile': 7576957b2eaSAndreas Gohr if($conf['useacl'] && $auth && $_SERVER['REMOTE_USER'] && 75836223ba7SAndreas Gohr $auth->canDo('Profile') && ($ACT!='profile')){ 759c97dfb07SAndreas Gohr tpl_link(wl($ID,'do=profile'), 760c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_profile']).$suf, 761c97dfb07SAndreas Gohr 'class="action profile" rel="nofollow"'); 762c059e1a6SAndreas Gohr return true; 7638b06d178Schris } 764c059e1a6SAndreas Gohr return false; 765ed630903Sandi default: 766ed630903Sandi print '[unknown link type]'; 767c059e1a6SAndreas Gohr return true; 768ed630903Sandi } 769ed630903Sandi} 770ed630903Sandi 771ed630903Sandi/** 7726b13307fSandi * Print the search form 7736b13307fSandi * 77472645b75SAndreas Gohr * If the first parameter is given a div with the ID 'qsearch_out' will 77572645b75SAndreas Gohr * be added which instructs the ajax pagequicksearch to kick in and place 77672645b75SAndreas Gohr * its output into this div. The second parameter controls the propritary 77772645b75SAndreas Gohr * attribute autocomplete. If set to false this attribute will be set with an 77872645b75SAndreas Gohr * value of "off" to instruct the browser to disable it's own built in 77972645b75SAndreas Gohr * autocompletion feature (MSIE and Firefox) 78072645b75SAndreas Gohr * 7816b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 7826b13307fSandi */ 78372645b75SAndreas Gohrfunction tpl_searchform($ajax=true,$autocomplete=true){ 7846b13307fSandi global $lang; 785c1e3b7d9Smatthiasgrimm global $ACT; 786c1e3b7d9Smatthiasgrimm 787670ff54eSchris // don't print the search form if search action has been disabled 78854e95700STom N Harris if (!actionOk('search')) return false; 789670ff54eSchris 7901dd0c202SAnika Henke print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search"><div class="no">'; 7916b13307fSandi print '<input type="hidden" name="do" value="search" />'; 792c1e3b7d9Smatthiasgrimm print '<input type="text" '; 793bad31ae9SAndreas Gohr if($ACT == 'search') print 'value="'.htmlspecialchars($_REQUEST['id']).'" '; 79472645b75SAndreas Gohr if(!$autocomplete) print 'autocomplete="off" '; 79507493d05SAnika Henke print 'id="qsearch__in" accesskey="f" name="id" class="edit" title="[F]" />'; 79611ea018fSAndreas Gohr print '<input type="submit" value="'.$lang['btn_search'].'" class="button" title="'.$lang['btn_search'].'" />'; 79724a33b42SAndreas Gohr if($ajax) print '<div id="qsearch__out" class="ajax_qsearch JSpopup"></div>'; 7984beabca9SAnika Henke print '</div></form>'; 79954e95700STom N Harris return true; 8006b13307fSandi} 8016b13307fSandi 8026b13307fSandi/** 8036b13307fSandi * Print the breadcrumbs trace 8046b13307fSandi * 8056b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 8066b13307fSandi */ 80754e95700STom N Harrisfunction tpl_breadcrumbs($sep='»'){ 8086b13307fSandi global $lang; 8096b13307fSandi global $conf; 8106b13307fSandi 8116b13307fSandi //check if enabled 81254e95700STom N Harris if(!$conf['breadcrumbs']) return false; 8136b13307fSandi 8146b13307fSandi $crumbs = breadcrumbs(); //setup crumb trace 815265e3787Sandi 8162979a10bSKatriel Traum //reverse crumborder in right-to-left mode, add RLM character to fix heb/eng display mixups 8172979a10bSKatriel Traum if($lang['direction'] == 'rtl') { 8182979a10bSKatriel Traum $crumbs = array_reverse($crumbs,true); 8192979a10bSKatriel Traum $crumbs_sep = ' ‏<span class="bcsep">'.$sep.'</span>‏ '; 8202979a10bSKatriel Traum } else { 8212979a10bSKatriel Traum $crumbs_sep = ' <span class="bcsep">'.$sep.'</span> '; 8222979a10bSKatriel Traum } 823265e3787Sandi 82440eb54bbSjan //render crumbs, highlight the last one 8251b6f3a44SAndreas Gohr print '<span class="bchead">'.$lang['breadcrumb'].':</span>'; 82640eb54bbSjan $last = count($crumbs); 82740eb54bbSjan $i = 0; 828a77f5846Sjan foreach ($crumbs as $id => $name){ 82940eb54bbSjan $i++; 8302979a10bSKatriel Traum echo $crumbs_sep; 83192795d04Sandi if ($i == $last) print '<span class="curid">'; 832e26fd1eeSAndreas Gohr tpl_link(wl($id),hsc($name),'class="breadcrumbs" title="'.$id.'"'); 83392795d04Sandi if ($i == $last) print '</span>'; 8346b13307fSandi } 83554e95700STom N Harris return true; 8366b13307fSandi} 8376b13307fSandi 8386b13307fSandi/** 8391734437eSandi * Hierarchical breadcrumbs 8401734437eSandi * 84131e187f8SSean Coates * This code was suggested as replacement for the usual breadcrumbs. 8421734437eSandi * It only makes sense with a deep site structure. 8431734437eSandi * 8441734437eSandi * @author Andreas Gohr <andi@splitbrain.org> 8456bd812dfSNigel McNie * @author Nigel McNie <oracle.shinoda@gmail.com> 84631e187f8SSean Coates * @author Sean Coates <sean@caedmon.net> 847f46c9e83SAnika Henke * @author <fredrik@averpil.com> 8486bd812dfSNigel McNie * @todo May behave strangely in RTL languages 8491734437eSandi */ 850796bafb3SAndreas Gohrfunction tpl_youarehere($sep=' » '){ 8511734437eSandi global $conf; 8521734437eSandi global $ID; 8531734437eSandi global $lang; 8541734437eSandi 85531e187f8SSean Coates // check if enabled 85654e95700STom N Harris if(!$conf['youarehere']) return false; 8571734437eSandi 8581734437eSandi $parts = explode(':', $ID); 859796bafb3SAndreas Gohr $count = count($parts); 8601734437eSandi 8611b6f3a44SAndreas Gohr echo '<span class="bchead">'.$lang['youarehere'].': </span>'; 8621734437eSandi 8631734437eSandi // always print the startpage 864fe9ec250SChris Smith $title = useHeading('navigation') ? p_get_first_heading($conf['start']) : $conf['start']; 865796bafb3SAndreas Gohr if(!$title) $title = $conf['start']; 866e26fd1eeSAndreas Gohr tpl_link(wl($conf['start']),hsc($title),'title="'.$conf['start'].'"'); 867796bafb3SAndreas Gohr 868796bafb3SAndreas Gohr // print intermediate namespace links 869796bafb3SAndreas Gohr $part = ''; 870796bafb3SAndreas Gohr for($i=0; $i<$count - 1; $i++){ 871796bafb3SAndreas Gohr $part .= $parts[$i].':'; 872796bafb3SAndreas Gohr $page = $part; 873796bafb3SAndreas Gohr resolve_pageid('',$page,$exists); 874796bafb3SAndreas Gohr if ($page == $conf['start']) continue; // Skip startpage 875796bafb3SAndreas Gohr 876796bafb3SAndreas Gohr // output 877796bafb3SAndreas Gohr echo $sep; 878796bafb3SAndreas Gohr if($exists){ 8796df2a685SAndreas Gohr $title = useHeading('navigation') ? p_get_first_heading($page) : $page; 880796bafb3SAndreas Gohr if(!$title) $title = $parts[$i]; 881e26fd1eeSAndreas Gohr tpl_link(wl($page),hsc($title),'title="'.$page.'"'); 88231e187f8SSean Coates }else{ 88378cbfcb6SAndreas Gohr tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2" rel="nofollow"'); 88431e187f8SSean Coates } 88531e187f8SSean Coates } 8861734437eSandi 887796bafb3SAndreas Gohr // print current page, skipping start page, skipping for namespace index 888d98d4540SBen Coburn if(isset($page) && $page==$part.$parts[$i]) return; 889796bafb3SAndreas Gohr $page = $part.$parts[$i]; 890796bafb3SAndreas Gohr if($page == $conf['start']) return; 891796bafb3SAndreas Gohr echo $sep; 892103c256aSChris Smith if(page_exists($page)){ 8936df2a685SAndreas Gohr $title = useHeading('navigation') ? p_get_first_heading($page) : $page; 894796bafb3SAndreas Gohr if(!$title) $title = $parts[$i]; 895e26fd1eeSAndreas Gohr tpl_link(wl($page),hsc($title),'title="'.$page.'"'); 89631e187f8SSean Coates }else{ 89778cbfcb6SAndreas Gohr tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2" rel="nofollow"'); 8981734437eSandi } 89954e95700STom N Harris return true; 9001734437eSandi} 9011734437eSandi 9021734437eSandi/** 9036b13307fSandi * Print info if the user is logged in 904a2488c3cSMatthias Grimm * and show full name in that case 9056b13307fSandi * 9066b13307fSandi * Could be enhanced with a profile link in future? 9076b13307fSandi * 9086b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 9096b13307fSandi */ 9106b13307fSandifunction tpl_userinfo(){ 9116b13307fSandi global $lang; 9123e63b73bSMichael Klier global $INFO; 91354e95700STom N Harris if($_SERVER['REMOTE_USER']){ 9143e63b73bSMichael Klier print $lang['loggedinas'].': '.$INFO['userinfo']['name'].' ('.$_SERVER['REMOTE_USER'].')'; 91554e95700STom N Harris return true; 91654e95700STom N Harris } 91754e95700STom N Harris return false; 9186b13307fSandi} 9196b13307fSandi 9206b13307fSandi/** 9216b13307fSandi * Print some info about the current page 9226b13307fSandi * 9236b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 9246b13307fSandi */ 9254b0d3916SAndreas Gohrfunction tpl_pageinfo($ret=false){ 9266b13307fSandi global $conf; 9276b13307fSandi global $lang; 9286b13307fSandi global $INFO; 9296b13307fSandi global $REV; 930c6e92a3cSDavid Lorentsen global $ID; 931c6e92a3cSDavid Lorentsen 932c6e92a3cSDavid Lorentsen // return if we are not allowed to view the page 9334b0d3916SAndreas Gohr if (!auth_quickaclcheck($ID)) { return false; } 9346b13307fSandi 9356b13307fSandi // prepare date and path 9366b13307fSandi $fn = $INFO['filepath']; 9376b13307fSandi if(!$conf['fullpath']){ 9386b13307fSandi if($REV){ 93950fbebceSGina Haeussge $fn = str_replace(fullpath($conf['olddir']).'/','',$fn); 9406b13307fSandi }else{ 94150fbebceSGina Haeussge $fn = str_replace(fullpath($conf['datadir']).'/','',$fn); 9426b13307fSandi } 9436b13307fSandi } 944bee6dc82Sandi $fn = utf8_decodeFN($fn); 945e656dcd4SAndreas Gohr $date = strftime($conf['dformat'],$INFO['lastmod']); 9466b13307fSandi 947faecdfdfSAndreas Gohr // print it 948faecdfdfSAndreas Gohr if($INFO['exists']){ 9494b0d3916SAndreas Gohr $out = ''; 9504b0d3916SAndreas Gohr $out .= $fn; 9514b0d3916SAndreas Gohr $out .= ' · '; 9524b0d3916SAndreas Gohr $out .= $lang['lastmod']; 9534b0d3916SAndreas Gohr $out .= ': '; 9544b0d3916SAndreas Gohr $out .= $date; 9556b13307fSandi if($INFO['editor']){ 9564b0d3916SAndreas Gohr $out .= ' '.$lang['by'].' '; 957dc58b6f4SAndy Webber $out .= editorinfo($INFO['editor']); 9585aa52fafSBen Coburn }else{ 9594b0d3916SAndreas Gohr $out .= ' ('.$lang['external_edit'].')'; 9606b13307fSandi } 9616b13307fSandi if($INFO['locked']){ 9624b0d3916SAndreas Gohr $out .= ' · '; 9634b0d3916SAndreas Gohr $out .= $lang['lockedby']; 9644b0d3916SAndreas Gohr $out .= ': '; 965dc58b6f4SAndy Webber $out .= editorinfo($INFO['locked']); 9666b13307fSandi } 9674b0d3916SAndreas Gohr if($ret){ 9684b0d3916SAndreas Gohr return $out; 9694b0d3916SAndreas Gohr }else{ 9704b0d3916SAndreas Gohr echo $out; 97154e95700STom N Harris return true; 9726b13307fSandi } 9734b0d3916SAndreas Gohr } 97454e95700STom N Harris return false; 9756b13307fSandi} 9766b13307fSandi 977820fa24bSandi/** 978a6598f23SBen Coburn * Prints or returns the name of the given page (current one if none given). 97987c434ceSAndreas Gohr * 98087c434ceSAndreas Gohr * If useheading is enabled this will use the first headline else 981a6598f23SBen Coburn * the given ID is used. 98287c434ceSAndreas Gohr * 98387c434ceSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 98487c434ceSAndreas Gohr */ 985a6598f23SBen Coburnfunction tpl_pagetitle($id=null, $ret=false){ 98687c434ceSAndreas Gohr global $conf; 98787c434ceSAndreas Gohr if(is_null($id)){ 98887c434ceSAndreas Gohr global $ID; 98987c434ceSAndreas Gohr $id = $ID; 99087c434ceSAndreas Gohr } 99187c434ceSAndreas Gohr 99287c434ceSAndreas Gohr $name = $id; 993fe9ec250SChris Smith if (useHeading('navigation')) { 99487c434ceSAndreas Gohr $title = p_get_first_heading($id); 99587c434ceSAndreas Gohr if ($title) $name = $title; 99687c434ceSAndreas Gohr } 997a6598f23SBen Coburn 998a6598f23SBen Coburn if ($ret) { 999a6598f23SBen Coburn return hsc($name); 1000a6598f23SBen Coburn } else { 100187c434ceSAndreas Gohr print hsc($name); 100254e95700STom N Harris return true; 100387c434ceSAndreas Gohr } 1004a6598f23SBen Coburn} 1005340756e4Sandi 100655efc227SAndreas Gohr/** 100755efc227SAndreas Gohr * Returns the requested EXIF/IPTC tag from the current image 100855efc227SAndreas Gohr * 100955efc227SAndreas Gohr * If $tags is an array all given tags are tried until a 101055efc227SAndreas Gohr * value is found. If no value is found $alt is returned. 101155efc227SAndreas Gohr * 101255efc227SAndreas Gohr * Which texts are known is defined in the functions _exifTagNames 101355efc227SAndreas Gohr * and _iptcTagNames() in inc/jpeg.php (You need to prepend IPTC 101455efc227SAndreas Gohr * to the names of the latter one) 101555efc227SAndreas Gohr * 10163df72098SAndreas Gohr * Only allowed in: detail.php 101755efc227SAndreas Gohr * 101855efc227SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 101955efc227SAndreas Gohr */ 10203df72098SAndreas Gohrfunction tpl_img_getTag($tags,$alt='',$src=null){ 102155efc227SAndreas Gohr // Init Exif Reader 102255efc227SAndreas Gohr global $SRC; 10233df72098SAndreas Gohr 10243df72098SAndreas Gohr if(is_null($src)) $src = $SRC; 10253df72098SAndreas Gohr 102655efc227SAndreas Gohr static $meta = null; 10273df72098SAndreas Gohr if(is_null($meta)) $meta = new JpegMeta($src); 102855efc227SAndreas Gohr if($meta === false) return $alt; 102955efc227SAndreas Gohr $info = $meta->getField($tags); 103055efc227SAndreas Gohr if($info == false) return $alt; 103155efc227SAndreas Gohr return $info; 103255efc227SAndreas Gohr} 103355efc227SAndreas Gohr 103455efc227SAndreas Gohr/** 103555efc227SAndreas Gohr * Prints the image with a link to the full sized version 103655efc227SAndreas Gohr * 103755efc227SAndreas Gohr * Only allowed in: detail.php 103855efc227SAndreas Gohr */ 1039f8925855Sjoe.lappfunction tpl_img($maxwidth=0,$maxheight=0){ 104055efc227SAndreas Gohr global $IMG; 104155efc227SAndreas Gohr $w = tpl_img_getTag('File.Width'); 104255efc227SAndreas Gohr $h = tpl_img_getTag('File.Height'); 104355efc227SAndreas Gohr 104455efc227SAndreas Gohr //resize to given max values 104523a34783SAndreas Gohr $ratio = 1; 104623a34783SAndreas Gohr if($w >= $h){ 1047f8925855Sjoe.lapp if($maxwidth && $w >= $maxwidth){ 104855efc227SAndreas Gohr $ratio = $maxwidth/$w; 1049f8925855Sjoe.lapp }elseif($maxheight && $h > $maxheight){ 105055efc227SAndreas Gohr $ratio = $maxheight/$h; 105155efc227SAndreas Gohr } 105255efc227SAndreas Gohr }else{ 1053f8925855Sjoe.lapp if($maxheight && $h >= $maxheight){ 105455efc227SAndreas Gohr $ratio = $maxheight/$h; 1055f8925855Sjoe.lapp }elseif($maxwidth && $w > $maxwidth){ 105655efc227SAndreas Gohr $ratio = $maxwidth/$w; 105755efc227SAndreas Gohr } 105855efc227SAndreas Gohr } 105955efc227SAndreas Gohr if($ratio){ 106055efc227SAndreas Gohr $w = floor($ratio*$w); 106155efc227SAndreas Gohr $h = floor($ratio*$h); 106255efc227SAndreas Gohr } 106355efc227SAndreas Gohr 10646de3759aSAndreas Gohr //prepare URLs 10656de3759aSAndreas Gohr $url=ml($IMG,array('cache'=>$_REQUEST['cache'])); 10666de3759aSAndreas Gohr $src=ml($IMG,array('cache'=>$_REQUEST['cache'],'w'=>$w,'h'=>$h)); 106755efc227SAndreas Gohr 10682684e50aSAndreas Gohr //prepare attributes 106955efc227SAndreas Gohr $alt=tpl_img_getTag('Simple.Title'); 10702684e50aSAndreas Gohr $p = array(); 10712684e50aSAndreas Gohr if($w) $p['width'] = $w; 10722684e50aSAndreas Gohr if($h) $p['height'] = $h; 10732684e50aSAndreas Gohr $p['class'] = 'img_detail'; 10742684e50aSAndreas Gohr if($alt){ 10752684e50aSAndreas Gohr $p['alt'] = $alt; 10762684e50aSAndreas Gohr $p['title'] = $alt; 10772684e50aSAndreas Gohr }else{ 10782684e50aSAndreas Gohr $p['alt'] = ''; 10792684e50aSAndreas Gohr } 10802684e50aSAndreas Gohr $p = buildAttributes($p); 108155efc227SAndreas Gohr 108255efc227SAndreas Gohr print '<a href="'.$url.'">'; 10836de3759aSAndreas Gohr print '<img src="'.$src.'" '.$p.'/>'; 108455efc227SAndreas Gohr print '</a>'; 108554e95700STom N Harris return true; 108655efc227SAndreas Gohr} 108755efc227SAndreas Gohr 10887367b368SAndreas Gohr/** 10897367b368SAndreas Gohr * This function inserts a 1x1 pixel gif which in reality 10907367b368SAndreas Gohr * is the inexer function. 10917367b368SAndreas Gohr * 10927367b368SAndreas Gohr * Should be called somewhere at the very end of the main.php 10937367b368SAndreas Gohr * template 10947367b368SAndreas Gohr */ 10957367b368SAndreas Gohrfunction tpl_indexerWebBug(){ 10967367b368SAndreas Gohr global $ID; 10971dad36f5SAndreas Gohr global $INFO; 109854e95700STom N Harris if(!$INFO['exists']) return false; 10991dad36f5SAndreas Gohr 110054e95700STom N Harris if(isHiddenPage($ID)) return false; //no need to index hidden pages 11010dc92c6fSAndreas Gohr 11027367b368SAndreas Gohr $p = array(); 1103b6c6979fSAndreas Gohr $p['src'] = DOKU_BASE.'lib/exe/indexer.php?id='.rawurlencode($ID). 1104e68c51baSAndreas Gohr '&'.time(); 11057367b368SAndreas Gohr $p['width'] = 1; 11067367b368SAndreas Gohr $p['height'] = 1; 11077367b368SAndreas Gohr $p['alt'] = ''; 11087367b368SAndreas Gohr $att = buildAttributes($p); 11097367b368SAndreas Gohr print "<img $att />"; 111054e95700STom N Harris return true; 11117367b368SAndreas Gohr} 11127367b368SAndreas Gohr 111378d4e784SEsther Brunner// configuration methods 111478d4e784SEsther Brunner/** 111578d4e784SEsther Brunner * tpl_getConf($id) 111678d4e784SEsther Brunner * 111778d4e784SEsther Brunner * use this function to access template configuration variables 111878d4e784SEsther Brunner */ 111978d4e784SEsther Brunnerfunction tpl_getConf($id){ 112078d4e784SEsther Brunner global $conf; 112178d4e784SEsther Brunner global $tpl_configloaded; 112278d4e784SEsther Brunner 112378d4e784SEsther Brunner $tpl = $conf['template']; 112478d4e784SEsther Brunner 112578d4e784SEsther Brunner if (!$tpl_configloaded){ 112678d4e784SEsther Brunner $tconf = tpl_loadConfig(); 112778d4e784SEsther Brunner if ($tconf !== false){ 112878d4e784SEsther Brunner foreach ($tconf as $key => $value){ 112978d4e784SEsther Brunner if (isset($conf['tpl'][$tpl][$key])) continue; 113078d4e784SEsther Brunner $conf['tpl'][$tpl][$key] = $value; 113178d4e784SEsther Brunner } 113278d4e784SEsther Brunner $tpl_configloaded = true; 113378d4e784SEsther Brunner } 113478d4e784SEsther Brunner } 113578d4e784SEsther Brunner 113678d4e784SEsther Brunner return $conf['tpl'][$tpl][$id]; 113778d4e784SEsther Brunner} 113878d4e784SEsther Brunner 113978d4e784SEsther Brunner/** 114078d4e784SEsther Brunner * tpl_loadConfig() 114178d4e784SEsther Brunner * reads all template configuration variables 114278d4e784SEsther Brunner * this function is automatically called by tpl_getConf() 114378d4e784SEsther Brunner */ 114478d4e784SEsther Brunnerfunction tpl_loadConfig(){ 114578d4e784SEsther Brunner 114678d4e784SEsther Brunner $file = DOKU_TPLINC.'/conf/default.php'; 114778d4e784SEsther Brunner $conf = array(); 114878d4e784SEsther Brunner 114978d4e784SEsther Brunner if (!@file_exists($file)) return false; 115078d4e784SEsther Brunner 115178d4e784SEsther Brunner // load default config file 115278d4e784SEsther Brunner include($file); 115378d4e784SEsther Brunner 115478d4e784SEsther Brunner return $conf; 115578d4e784SEsther Brunner} 115678d4e784SEsther Brunner 11573df72098SAndreas Gohr/** 11583df72098SAndreas Gohr * prints the "main content" in the mediamanger popup 11593df72098SAndreas Gohr * 11603df72098SAndreas Gohr * Depending on the user's actions this may be a list of 11613df72098SAndreas Gohr * files in a namespace, the meta editing dialog or 11623df72098SAndreas Gohr * a message of referencing pages 11633df72098SAndreas Gohr * 11643df72098SAndreas Gohr * Only allowed in mediamanager.php 11653df72098SAndreas Gohr * 11663df72098SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 11673df72098SAndreas Gohr */ 11683df72098SAndreas Gohrfunction tpl_mediaContent(){ 11693df72098SAndreas Gohr global $IMG; 11703df72098SAndreas Gohr global $AUTH; 11713df72098SAndreas Gohr global $INUSE; 11723df72098SAndreas Gohr global $NS; 11733df72098SAndreas Gohr global $JUMPTO; 11743df72098SAndreas Gohr 11753df72098SAndreas Gohr ptln('<div id="media__content">'); 11763df72098SAndreas Gohr if($_REQUEST['edit']){ 11773df72098SAndreas Gohr media_metaform($IMG,$AUTH); 11787b877f51SAndreas Gohr }elseif(is_array($INUSE)){ 11793df72098SAndreas Gohr media_filesinuse($INUSE,$IMG); 11803df72098SAndreas Gohr }else{ 11813df72098SAndreas Gohr media_filelist($NS,$AUTH,$JUMPTO); 11823df72098SAndreas Gohr } 11833df72098SAndreas Gohr ptln('</div>'); 11843df72098SAndreas Gohr} 11853df72098SAndreas Gohr 11863df72098SAndreas Gohr/** 11873df72098SAndreas Gohr * prints the namespace tree in the mediamanger popup 11883df72098SAndreas Gohr * 11893df72098SAndreas Gohr * Only allowed in mediamanager.php 11903df72098SAndreas Gohr * 11913df72098SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 11923df72098SAndreas Gohr */ 11933df72098SAndreas Gohrfunction tpl_mediaTree(){ 11943df72098SAndreas Gohr global $NS; 11953df72098SAndreas Gohr 11963df72098SAndreas Gohr ptln('<div id="media__tree">'); 11973df72098SAndreas Gohr media_nstree($NS); 11983df72098SAndreas Gohr ptln('</div>'); 11993df72098SAndreas Gohr} 12003df72098SAndreas Gohr 1201a00de5b5SAndreas Gohr 1202a00de5b5SAndreas Gohr/** 1203a00de5b5SAndreas Gohr * Print a dropdown menu with all DokuWiki actions 1204a00de5b5SAndreas Gohr * 1205a00de5b5SAndreas Gohr * Note: this will not use any pretty URLs 1206a00de5b5SAndreas Gohr * 1207a00de5b5SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1208a00de5b5SAndreas Gohr */ 1209a00de5b5SAndreas Gohrfunction tpl_actiondropdown($empty='',$button='>'){ 1210a00de5b5SAndreas Gohr global $ID; 1211a00de5b5SAndreas Gohr global $INFO; 1212a00de5b5SAndreas Gohr global $REV; 1213a00de5b5SAndreas Gohr global $ACT; 1214a00de5b5SAndreas Gohr global $conf; 1215a00de5b5SAndreas Gohr global $lang; 1216a00de5b5SAndreas Gohr global $auth; 1217a00de5b5SAndreas Gohr 1218a00de5b5SAndreas Gohr 1219a00de5b5SAndreas Gohr echo '<form method="post" accept-charset="utf-8">'; #FIXME action 1220a00de5b5SAndreas Gohr echo '<input type="hidden" name="id" value="'.$ID.'" />'; 1221a00de5b5SAndreas Gohr if($REV) echo '<input type="hidden" name="rev" value="'.$REV.'" />'; 1222a00de5b5SAndreas Gohr echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'; 1223a00de5b5SAndreas Gohr 1224a00de5b5SAndreas Gohr echo '<select name="do" id="action__selector" class="edit">'; 1225a00de5b5SAndreas Gohr echo '<option value="">'.$empty.'</option>'; 1226a00de5b5SAndreas Gohr 1227a00de5b5SAndreas Gohr echo '<optgroup label=" — ">'; 1228a00de5b5SAndreas Gohr // 'edit' - most complicated type, we need to decide on current action 1229a00de5b5SAndreas Gohr if($ACT == 'show' || $ACT == 'search'){ 1230a00de5b5SAndreas Gohr if($INFO['writable']){ 1231a00de5b5SAndreas Gohr if(!empty($INFO['draft'])) { 1232a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_draft'].'</option>'; 1233a00de5b5SAndreas Gohr } else { 1234a00de5b5SAndreas Gohr if($INFO['exists']){ 1235a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_edit'].'</option>'; 1236a00de5b5SAndreas Gohr }else{ 1237a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_create'].'</option>'; 1238a00de5b5SAndreas Gohr } 1239a00de5b5SAndreas Gohr } 1240a00de5b5SAndreas Gohr }else if(actionOK('source')) { //pseudo action 1241a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_source'].'</option>'; 1242a00de5b5SAndreas Gohr } 1243a00de5b5SAndreas Gohr }else{ 1244a00de5b5SAndreas Gohr echo '<option value="show">'.$lang['btn_show'].'</option>'; 1245a00de5b5SAndreas Gohr } 1246a00de5b5SAndreas Gohr 1247a00de5b5SAndreas Gohr echo '<option value="revisions">'.$lang['btn_revs'].'</option>'; 1248a00de5b5SAndreas Gohr echo '<option value="backlink">'.$lang['btn_backlink'].'</option>'; 1249a00de5b5SAndreas Gohr echo '</optgroup>'; 1250a00de5b5SAndreas Gohr 1251a00de5b5SAndreas Gohr echo '<optgroup label=" — ">'; 1252a00de5b5SAndreas Gohr echo '<option value="recent">'.$lang['btn_recent'].'</option>'; 1253a00de5b5SAndreas Gohr echo '<option value="index">'.$lang['btn_index'].'</option>'; 1254a00de5b5SAndreas Gohr echo '</optgroup>'; 1255a00de5b5SAndreas Gohr 1256a00de5b5SAndreas Gohr echo '<optgroup label=" — ">'; 1257a00de5b5SAndreas Gohr if($conf['useacl'] && $auth){ 1258a00de5b5SAndreas Gohr if($_SERVER['REMOTE_USER']){ 1259a00de5b5SAndreas Gohr echo '<option value="logout">'.$lang['btn_logout'].'</option>'; 1260a00de5b5SAndreas Gohr }else{ 1261a00de5b5SAndreas Gohr echo '<option value="login">'.$lang['btn_login'].'</option>'; 1262a00de5b5SAndreas Gohr } 1263a00de5b5SAndreas Gohr } 1264a00de5b5SAndreas Gohr 1265a00de5b5SAndreas Gohr if($conf['useacl'] && $auth && $_SERVER['REMOTE_USER'] && 1266a00de5b5SAndreas Gohr $auth->canDo('Profile') && ($ACT!='profile')){ 1267a00de5b5SAndreas Gohr echo '<option value="profile">'.$lang['btn_profile'].'</option>'; 1268a00de5b5SAndreas Gohr } 1269a00de5b5SAndreas Gohr 1270a00de5b5SAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 1271a00de5b5SAndreas Gohr if($_SERVER['REMOTE_USER']){ 1272a00de5b5SAndreas Gohr if($INFO['subscribed']) { 1273a00de5b5SAndreas Gohr echo '<option value="unsubscribe">'.$lang['btn_unsubscribe'].'</option>'; 1274a00de5b5SAndreas Gohr } else { 1275a00de5b5SAndreas Gohr echo '<option value="subscribe">'.$lang['btn_subscribe'].'</option>'; 1276a00de5b5SAndreas Gohr } 1277a00de5b5SAndreas Gohr } 1278a00de5b5SAndreas Gohr } 1279a00de5b5SAndreas Gohr 1280a00de5b5SAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 1281a00de5b5SAndreas Gohr if($_SERVER['REMOTE_USER']){ 1282a00de5b5SAndreas Gohr if($INFO['subscribedns']) { 1283a00de5b5SAndreas Gohr echo '<option value="unsubscribens">'.$lang['btn_unsubscribens'].'</option>'; 1284a00de5b5SAndreas Gohr } else { 1285a00de5b5SAndreas Gohr echo '<option value="subscribens">'.$lang['btn_subscribens'].'</option>'; 1286a00de5b5SAndreas Gohr } 1287a00de5b5SAndreas Gohr } 1288a00de5b5SAndreas Gohr } 1289a00de5b5SAndreas Gohr 1290a00de5b5SAndreas Gohr if($INFO['ismanager']){ 1291a00de5b5SAndreas Gohr echo '<option value="admin">'.$lang['btn_admin'].'</option>'; 1292a00de5b5SAndreas Gohr } 1293a00de5b5SAndreas Gohr echo '</optgroup>'; 1294a00de5b5SAndreas Gohr 1295a00de5b5SAndreas Gohr echo '</select>'; 1296a00de5b5SAndreas Gohr echo '<input type="submit" value="'.$button.'" id="action__selectorbtn" />'; 1297a00de5b5SAndreas Gohr echo '</form>'; 1298a00de5b5SAndreas Gohr} 1299a00de5b5SAndreas Gohr 1300066fee30SAndreas Gohr/** 1301066fee30SAndreas Gohr * Print a informational line about the used license 1302066fee30SAndreas Gohr * 1303066fee30SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1304066fee30SAndreas Gohr * @param string $img - print image? (|button|badge) 1305066fee30SAndreas Gohr * @param bool $return - when true don't print, but return HTML 1306066fee30SAndreas Gohr */ 1307066fee30SAndreas Gohrfunction tpl_license($img='badge',$return=false){ 1308066fee30SAndreas Gohr global $license; 1309066fee30SAndreas Gohr global $conf; 1310066fee30SAndreas Gohr global $lang; 1311066fee30SAndreas Gohr if(!$conf['license']) return ''; 1312066fee30SAndreas Gohr if(!is_array($license[$conf['license']])) return ''; 1313066fee30SAndreas Gohr $lic = $license[$conf['license']]; 1314066fee30SAndreas Gohr 1315066fee30SAndreas Gohr $out = '<p class="license">'; 1316066fee30SAndreas Gohr if($img){ 1317066fee30SAndreas Gohr $src = license_img($img); 1318066fee30SAndreas Gohr if($src){ 1319066fee30SAndreas Gohr $out .= '<a href="'.$lic['url'].'" rel="license"'; 1320066fee30SAndreas Gohr if($conf['target']['external']) $out .= ' target="'.$conf['target']['external'].'"'; 1321*a57c7cafSAnika Henke $out .= '><img src="'.DOKU_BASE.$src.'" class="medialeft lic'.$img.'" alt="'.$lic['name'].'" /></a> '; 1322066fee30SAndreas Gohr } 1323066fee30SAndreas Gohr } 1324066fee30SAndreas Gohr $out .= $lang['license']; 1325066fee30SAndreas Gohr $out .= '<a href="'.$lic['url'].'" rel="license" class="urlextern"'; 1326066fee30SAndreas Gohr if($conf['target']['external']) $out .= ' target="'.$conf['target']['external'].'"'; 1327066fee30SAndreas Gohr $out .= '>'.$lic['name'].'</a>'; 1328066fee30SAndreas Gohr $out .= '</p>'; 1329066fee30SAndreas Gohr 1330066fee30SAndreas Gohr if($return) return $out; 1331066fee30SAndreas Gohr echo $out; 1332066fee30SAndreas Gohr} 1333066fee30SAndreas Gohr 1334b8595a66SAndreas Gohr//Setup VIM: ex: et ts=4 enc=utf-8 : 1335a00de5b5SAndreas Gohr 1336