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.'); 106b13307fSandi 116b13307fSandi/** 125a892029SAndreas Gohr * Returns the path to the given template, uses 13524be65dSBen Coburn * default one if the custom version doesn't exist. 145a892029SAndreas Gohr * 155a892029SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 165a892029SAndreas Gohr */ 175a892029SAndreas Gohrfunction template($tpl){ 185a892029SAndreas Gohr global $conf; 195a892029SAndreas Gohr 205a892029SAndreas Gohr if(@is_readable(DOKU_INC.'lib/tpl/'.$conf['template'].'/'.$tpl)) 215a892029SAndreas Gohr return DOKU_INC.'lib/tpl/'.$conf['template'].'/'.$tpl; 225a892029SAndreas Gohr 235a892029SAndreas Gohr return DOKU_INC.'lib/tpl/default/'.$tpl; 245a892029SAndreas Gohr} 255a892029SAndreas Gohr 265a892029SAndreas Gohr/** 276b13307fSandi * Print the content 286b13307fSandi * 296b13307fSandi * This function is used for printing all the usual content 306b13307fSandi * (defined by the global $ACT var) by calling the appropriate 316b13307fSandi * outputfunction(s) from html.php 326b13307fSandi * 33ee4c4a1bSAndreas Gohr * Everything that doesn't use the main template file isn't 34ee4c4a1bSAndreas Gohr * handled by this function. ACL stuff is not done here either. 356b13307fSandi * 366b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 376b13307fSandi */ 38b8595a66SAndreas Gohrfunction tpl_content($prependTOC=true) { 397ea0913cSchris global $ACT; 40b8595a66SAndreas Gohr global $INFO; 41b8595a66SAndreas Gohr $INFO['prependTOC'] = $prependTOC; 427ea0913cSchris 437ea0913cSchris ob_start(); 44746855cfSBen Coburn trigger_event('TPL_ACT_RENDER',$ACT,'tpl_content_core'); 457ea0913cSchris $html_output = ob_get_clean(); 46746855cfSBen Coburn trigger_event('TPL_CONTENT_DISPLAY',$html_output,'ptln'); 4754e95700STom N Harris 4854e95700STom N Harris return !empty($html_output); 497ea0913cSchris} 507ea0913cSchris 517ea0913cSchrisfunction tpl_content_core(){ 526b13307fSandi global $ACT; 536b13307fSandi global $TEXT; 546b13307fSandi global $PRE; 556b13307fSandi global $SUF; 566b13307fSandi global $SUM; 576b13307fSandi global $IDX; 586b13307fSandi 596b13307fSandi switch($ACT){ 606b13307fSandi case 'show': 616b13307fSandi html_show(); 626b13307fSandi break; 63ea67f144Sandi case 'preview': 646b13307fSandi html_edit($TEXT); 656b13307fSandi html_show($TEXT); 666b13307fSandi break; 67ee4c4a1bSAndreas Gohr case 'recover': 68ee4c4a1bSAndreas Gohr html_edit($TEXT); 69ee4c4a1bSAndreas Gohr break; 706b13307fSandi case 'edit': 716b13307fSandi html_edit(); 726b13307fSandi break; 73ee4c4a1bSAndreas Gohr case 'draft': 74ee4c4a1bSAndreas Gohr html_draft(); 75ee4c4a1bSAndreas Gohr break; 766b13307fSandi case 'wordblock': 776b13307fSandi html_edit($TEXT,'wordblock'); 786b13307fSandi break; 796b13307fSandi case 'search': 806b13307fSandi html_search(); 816b13307fSandi break; 826b13307fSandi case 'revisions': 8371726d78SBen Coburn $first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0; 8471726d78SBen Coburn html_revisions($first); 856b13307fSandi break; 866b13307fSandi case 'diff': 876b13307fSandi html_diff(); 886b13307fSandi break; 896b13307fSandi case 'recent': 90abdcc39fSmichael if (is_array($_REQUEST['first'])) { 91abdcc39fSmichael $_REQUEST['first'] = array_keys($_REQUEST['first']); 92abdcc39fSmichael $_REQUEST['first'] = $_REQUEST['first'][0]; 93abdcc39fSmichael } 945749f1ceSmatthiasgrimm $first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0; 95a39955b0Smatthiasgrimm html_recent($first); 966b13307fSandi break; 976b13307fSandi case 'index': 986b13307fSandi html_index($IDX); #FIXME can this be pulled from globals? is it sanitized correctly? 996b13307fSandi break; 1006b13307fSandi case 'backlink': 1016b13307fSandi html_backlinks(); 1026b13307fSandi break; 1036b13307fSandi case 'conflict': 1046b13307fSandi html_conflict(con($PRE,$TEXT,$SUF),$SUM); 1056b13307fSandi html_diff(con($PRE,$TEXT,$SUF),false); 1066b13307fSandi break; 1076b13307fSandi case 'locked': 108ee20e7d1Sandi html_locked(); 10927eb9321SAnika Henke html_edit(); 1106b13307fSandi break; 1116b13307fSandi case 'login': 1126b13307fSandi html_login(); 1136b13307fSandi break; 1146b13307fSandi case 'register': 1156b13307fSandi html_register(); 1166b13307fSandi break; 1178b06d178Schris case 'resendpwd': 1188b06d178Schris html_resendpwd(); 1198b06d178Schris break; 120820fa24bSandi case 'denied': 1215e991bd8Sandi print p_locale_xhtml('denied'); 122820fa24bSandi break; 1238b06d178Schris case 'profile' : 1248b06d178Schris html_updateprofile(); 1258b06d178Schris break; 126c19fe9c0Sandi case 'admin': 127c19fe9c0Sandi tpl_admin(); 128c19fe9c0Sandi break; 1296b13307fSandi default: 13024bb549bSchris $evt = new Doku_Event('TPL_ACT_UNKNOWN',$ACT); 13124bb549bSchris if ($evt->advise_before()) 132ea67f144Sandi msg("Failed to handle command: ".hsc($ACT),-1); 13324bb549bSchris $evt->advise_after(); 13424bb549bSchris unset($evt); 13554e95700STom N Harris return false; 1366b13307fSandi } 13754e95700STom N Harris return true; 1386b13307fSandi} 1396b13307fSandi 140c19fe9c0Sandi/** 141b8595a66SAndreas Gohr * Places the TOC where the function is called 142b8595a66SAndreas Gohr * 143b8595a66SAndreas Gohr * If you use this you most probably want to call tpl_content with 144b8595a66SAndreas Gohr * a false argument 145b8595a66SAndreas Gohr * 146b8595a66SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 147b8595a66SAndreas Gohr */ 148b8595a66SAndreas Gohrfunction tpl_toc($return=false){ 149b8595a66SAndreas Gohr global $TOC; 150b8595a66SAndreas Gohr global $ACT; 151b8595a66SAndreas Gohr global $ID; 152b8595a66SAndreas Gohr global $REV; 153b8595a66SAndreas Gohr global $INFO; 154851f2e89SAnika Henke global $conf; 155b8595a66SAndreas Gohr $toc = array(); 156b8595a66SAndreas Gohr 157b8595a66SAndreas Gohr if(is_array($TOC)){ 158b8595a66SAndreas Gohr // if a TOC was prepared in global scope, always use it 159b8595a66SAndreas Gohr $toc = $TOC; 1603c86d7c9SAndreas Gohr }elseif(($ACT == 'show' || substr($ACT,0,6) == 'export') && !$REV && $INFO['exists']){ 161b8595a66SAndreas Gohr // get TOC from metadata, render if neccessary 162b8595a66SAndreas Gohr $meta = p_get_metadata($ID, false, true); 163b8595a66SAndreas Gohr if(isset($meta['internal']['toc'])){ 164b8595a66SAndreas Gohr $tocok = $meta['internal']['toc']; 165b8595a66SAndreas Gohr }else{ 1662bb0d541Schris $tocok = true; 167b8595a66SAndreas Gohr } 168b8595a66SAndreas Gohr $toc = $meta['description']['tableofcontents']; 169851f2e89SAnika Henke if(!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']){ 170b8595a66SAndreas Gohr $toc = array(); 171b8595a66SAndreas Gohr } 172b8595a66SAndreas Gohr }elseif($ACT == 'admin'){ 173b8595a66SAndreas Gohr // try to load admin plugin TOC FIXME: duplicates code from tpl_admin 174b8595a66SAndreas Gohr $plugin = null; 175b8595a66SAndreas Gohr if (!empty($_REQUEST['page'])) { 176b8595a66SAndreas Gohr $pluginlist = plugin_list('admin'); 177b8595a66SAndreas Gohr if (in_array($_REQUEST['page'], $pluginlist)) { 178b8595a66SAndreas Gohr // attempt to load the plugin 179b8595a66SAndreas Gohr $plugin =& plugin_load('admin',$_REQUEST['page']); 180b8595a66SAndreas Gohr } 181b8595a66SAndreas Gohr } 182b8595a66SAndreas Gohr if ( ($plugin !== null) && 183b8595a66SAndreas Gohr (!$plugin->forAdminOnly() || $INFO['isadmin']) ){ 184b8595a66SAndreas Gohr $toc = $plugin->getTOC(); 185b8595a66SAndreas Gohr $TOC = $toc; // avoid later rebuild 186b8595a66SAndreas Gohr } 187b8595a66SAndreas Gohr } 188b8595a66SAndreas Gohr 1897dee3468SGina Haeussge trigger_event('TPL_TOC_RENDER', $toc, NULL, false); 190b8595a66SAndreas Gohr $html = html_TOC($toc); 191b8595a66SAndreas Gohr if($return) return $html; 192b8595a66SAndreas Gohr echo $html; 193b8595a66SAndreas Gohr} 194b8595a66SAndreas Gohr 195b8595a66SAndreas Gohr/** 196c19fe9c0Sandi * Handle the admin page contents 197c19fe9c0Sandi * 198c19fe9c0Sandi * @author Andreas Gohr <andi@splitbrain.org> 199c19fe9c0Sandi */ 200c19fe9c0Sandifunction tpl_admin(){ 201f8cc712eSAndreas Gohr global $INFO; 202b8595a66SAndreas Gohr global $TOC; 20311e2ce22Schris 204b8595a66SAndreas Gohr $plugin = null; 205bb4866bdSchris if (!empty($_REQUEST['page'])) { 20611e2ce22Schris $pluginlist = plugin_list('admin'); 20711e2ce22Schris 20811e2ce22Schris if (in_array($_REQUEST['page'], $pluginlist)) { 20911e2ce22Schris 21011e2ce22Schris // attempt to load the plugin 21111e2ce22Schris $plugin =& plugin_load('admin',$_REQUEST['page']); 21211e2ce22Schris } 21311e2ce22Schris } 21411e2ce22Schris 215b8595a66SAndreas Gohr if ($plugin !== null){ 216f8cc712eSAndreas Gohr if($plugin->forAdminOnly() && !$INFO['isadmin']){ 217f8cc712eSAndreas Gohr msg('For admins only',-1); 21811e2ce22Schris html_admin(); 219f8cc712eSAndreas Gohr }else{ 220b8595a66SAndreas Gohr if(!is_array($TOC)) $TOC = $plugin->getTOC(); //if TOC wasn't requested yet 221b8595a66SAndreas Gohr if($INFO['prependTOC']) tpl_toc(); 222f8cc712eSAndreas Gohr $plugin->html(); 223f8cc712eSAndreas Gohr } 224f8cc712eSAndreas Gohr }else{ 225f8cc712eSAndreas Gohr html_admin(); 226f8cc712eSAndreas Gohr } 22754e95700STom N Harris return true; 228c19fe9c0Sandi} 2296b13307fSandi 2306b13307fSandi/** 2316b13307fSandi * Print the correct HTML meta headers 2326b13307fSandi * 2336b13307fSandi * This has to go into the head section of your template. 2346b13307fSandi * 235016b6153SAndreas Gohr * @triggers TPL_METAHEADER_OUTPUT 236f96fa415SAndreas Gohr * @param boolean $alt Should feeds and alternative format links be added? 2376b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 2386b13307fSandi */ 239f96fa415SAndreas Gohrfunction tpl_metaheaders($alt=true){ 2406b13307fSandi global $ID; 241d98d4540SBen Coburn global $REV; 2426b13307fSandi global $INFO; 2436b13307fSandi global $ACT; 2444bb1b5aeSAndreas Gohr global $QUERY; 2456b13307fSandi global $lang; 246dc57ef04Sandi global $conf; 2476b13307fSandi $it=2; 2486b13307fSandi 2497bff22c0SAndreas Gohr // prepare the head array 2507bff22c0SAndreas Gohr $head = array(); 2517bff22c0SAndreas Gohr 2527bff22c0SAndreas Gohr 2536b13307fSandi // the usual stuff 2547bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'generator', 'content'=>'DokuWiki '.getVersion() ); 255da96af35SAndreas Gohr $head['link'][] = array( 'rel'=>'search', 'type'=>'application/opensearchdescription+xml', 256da96af35SAndreas Gohr 'href'=>DOKU_BASE.'lib/exe/opensearch.php', 'title'=>$conf['title'] ); 257f4f47358SBen Coburn $head['link'][] = array( 'rel'=>'start', 'href'=>DOKU_BASE ); 2587aedde2eSGina Haeussge if(actionOK('index')){ 2597bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'contents', 'href'=> wl($ID,'do=index',false,'&'), 260bb4866bdSchris 'title'=>$lang['btn_index'] ); 2617aedde2eSGina Haeussge } 262f96fa415SAndreas Gohr 263f96fa415SAndreas Gohr if($alt){ 2647bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 2657bff22c0SAndreas Gohr 'title'=>'Recent Changes', 'href'=>DOKU_BASE.'feed.php'); 2667bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 2677bff22c0SAndreas Gohr 'title'=>'Current Namespace', 2687bff22c0SAndreas Gohr 'href'=>DOKU_BASE.'feed.php?mode=list&ns='.$INFO['namespace']); 269c35f3875SAndreas Gohr if(($ACT == 'show' || $ACT == 'search') && $INFO['writable']){ 270a2c734d5SAndreas Gohr $head['link'][] = array( 'rel'=>'edit', 271715bdf1fSAndreas Gohr 'title'=>$lang['btn_edit'], 272c35f3875SAndreas Gohr 'href'=> wl($ID,'do=edit',false,'&')); 273c35f3875SAndreas Gohr } 274c35f3875SAndreas Gohr 2754bb1b5aeSAndreas Gohr if($ACT == 'search'){ 2764bb1b5aeSAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 2774bb1b5aeSAndreas Gohr 'title'=>'Search Result', 2784bb1b5aeSAndreas Gohr 'href'=>DOKU_BASE.'feed.php?mode=search&q='.$QUERY); 2794bb1b5aeSAndreas Gohr } 280bae36d94SAndreas Gohr 281bae36d94SAndreas Gohr if(actionOK('export_xhtml')){ 2827bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'text/html', 'title'=>'Plain HTML', 2837bff22c0SAndreas Gohr 'href'=>exportlink($ID, 'xhtml', '', false, '&')); 284bae36d94SAndreas Gohr } 285bae36d94SAndreas Gohr 286bae36d94SAndreas Gohr if(actionOK('export_raw')){ 2877bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'text/plain', 'title'=>'Wiki Markup', 2887bff22c0SAndreas Gohr 'href'=>exportlink($ID, 'raw', '', false, '&')); 289f96fa415SAndreas Gohr } 290bae36d94SAndreas Gohr } 2916b13307fSandi 2926b13307fSandi // setup robot tags apropriate for different modes 2934f2e0004STim Weber if( ($ACT=='show' || $ACT=='export_xhtml') && !$REV){ 2946b13307fSandi if($INFO['exists']){ 2956b13307fSandi //delay indexing: 2966b13307fSandi if((time() - $INFO['lastmod']) >= $conf['indexdelay']){ 2977bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'index,follow'); 2986b13307fSandi }else{ 2997bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,nofollow'); 3006b13307fSandi } 3016b13307fSandi }else{ 3027bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,follow'); 3036b13307fSandi } 3047a24876fSAndreas Gohr }elseif(defined('DOKU_MEDIADETAIL')){ 3057bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'index,follow'); 3066b13307fSandi }else{ 3077bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,nofollow'); 3086b13307fSandi } 3096b13307fSandi 310831800b8SAndreas Gohr // set metadata 311831800b8SAndreas Gohr if($ACT == 'show' || $ACT=='export_xhtml'){ 312831800b8SAndreas Gohr // date of modification 313831800b8SAndreas Gohr if($REV){ 3147bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'date', 'content'=>date('Y-m-d\TH:i:sO',$REV)); 315831800b8SAndreas Gohr }else{ 3167bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'date', 'content'=>date('Y-m-d\TH:i:sO',$INFO['lastmod'])); 317831800b8SAndreas Gohr } 318831800b8SAndreas Gohr 319831800b8SAndreas Gohr // keywords (explicit or implicit) 320bb4866bdSchris if(!empty($INFO['meta']['subject'])){ 3217bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'keywords', 'content'=>join(',',$INFO['meta']['subject'])); 322831800b8SAndreas Gohr }else{ 3237bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'keywords', 'content'=>str_replace(':',',',$ID)); 324831800b8SAndreas Gohr } 325831800b8SAndreas Gohr } 326831800b8SAndreas Gohr 32778a6aeb1SAndreas Gohr // load stylesheets 3287aaa4c46Smartin.tschofen $head['link'][] = array('rel'=>'stylesheet', 'media'=>'all', 'type'=>'text/css', 329124af657SAndreas Gohr 'href'=>DOKU_BASE.'lib/exe/css.php?s=all&t='.$conf['template']); 3307bff22c0SAndreas Gohr $head['link'][] = array('rel'=>'stylesheet', 'media'=>'screen', 'type'=>'text/css', 331124af657SAndreas Gohr 'href'=>DOKU_BASE.'lib/exe/css.php?t='.$conf['template']); 3327bff22c0SAndreas Gohr $head['link'][] = array('rel'=>'stylesheet', 'media'=>'print', 'type'=>'text/css', 333124af657SAndreas Gohr 'href'=>DOKU_BASE.'lib/exe/css.php?s=print&t='.$conf['template']); 334bad31ae9SAndreas Gohr 33578a6aeb1SAndreas Gohr // load javascript 336041d1964SAndreas Gohr $js_edit = ($ACT=='edit' || $ACT=='preview' || $ACT=='recover' || $ACT=='wordblock' ) ? 1 : 0; 337bad31ae9SAndreas Gohr $js_write = ($INFO['writable']) ? 1 : 0; 3383df72098SAndreas Gohr if(defined('DOKU_MEDIAMANAGER')){ 3393df72098SAndreas Gohr $js_edit = 1; 3403df72098SAndreas Gohr $js_write = 0; 3413df72098SAndreas Gohr } 3423df72098SAndreas Gohr if(($js_edit && $js_write) || defined('DOKU_MEDIAMANAGER')){ 3437bff22c0SAndreas Gohr $script = "NS='".$INFO['namespace']."';"; 344c591aabeSAndreas Gohr if($conf['useacl'] && $_SERVER['REMOTE_USER']){ 345aeaccbf9SAndreas Gohr require_once(DOKU_INC.'inc/toolbar.php'); 3467bff22c0SAndreas Gohr $script .= "SIG='".toolbar_signature()."';"; 347c591aabeSAndreas Gohr } 3487bff22c0SAndreas Gohr $head['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', 3497bff22c0SAndreas Gohr '_data'=> $script); 350c591aabeSAndreas Gohr } 3517bff22c0SAndreas Gohr $head['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', '_data'=>'', 3527bff22c0SAndreas Gohr 'src'=>DOKU_BASE.'lib/exe/js.php?edit='.$js_edit.'&write='.$js_write); 3537bff22c0SAndreas Gohr 3547bff22c0SAndreas Gohr // trigger event here 355016b6153SAndreas Gohr trigger_event('TPL_METAHEADER_OUTPUT',$head,'_tpl_metaheaders_action',true); 35654e95700STom N Harris return true; 3577bff22c0SAndreas Gohr} 3587bff22c0SAndreas Gohr 3597bff22c0SAndreas Gohr/** 3607bff22c0SAndreas Gohr * prints the array build by tpl_metaheaders 3617bff22c0SAndreas Gohr * 3627bff22c0SAndreas Gohr * $data is an array of different header tags. Each tag can have multiple 3637bff22c0SAndreas Gohr * instances. Attributes are given as key value pairs. Values will be HTML 3647bff22c0SAndreas Gohr * encoded automatically so they should be provided as is in the $data array. 3657bff22c0SAndreas Gohr * 3667bff22c0SAndreas Gohr * For tags having a body attribute specify the the body data in the special 3671304d1dbSAndreas Gohr * attribute '_data'. This field will NOT BE ESCAPED automatically. 3687bff22c0SAndreas Gohr * 3697bff22c0SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 3707bff22c0SAndreas Gohr */ 3717bff22c0SAndreas Gohrfunction _tpl_metaheaders_action($data){ 3727bff22c0SAndreas Gohr foreach($data as $tag => $inst){ 3737bff22c0SAndreas Gohr foreach($inst as $attr){ 3747bff22c0SAndreas Gohr echo '<',$tag,' ',buildAttributes($attr); 37526afa874SMikhail I. Izmestev if(isset($attr['_data']) || $tag == 'script'){ 376e226efe1SAndreas Gohr if($tag == 'script' && $attr['_data']) 377e226efe1SAndreas Gohr $attr['_data'] = "<!--//--><![CDATA[//><!--\n". 378e226efe1SAndreas Gohr $attr['_data']. 379e226efe1SAndreas Gohr "\n//--><!]]>"; 380e226efe1SAndreas Gohr 3811304d1dbSAndreas Gohr echo '>',$attr['_data'],'</',$tag,'>'; 3827bff22c0SAndreas Gohr }else{ 3837bff22c0SAndreas Gohr echo '/>'; 3847bff22c0SAndreas Gohr } 3857bff22c0SAndreas Gohr echo "\n"; 3867bff22c0SAndreas Gohr } 3877bff22c0SAndreas Gohr } 3886b13307fSandi} 3896b13307fSandi 3906b13307fSandi/** 3916b13307fSandi * Print a link 3926b13307fSandi * 3935e163278SAndreas Gohr * Just builds a link. 3946b13307fSandi * 3956b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 3966b13307fSandi */ 397*1af98a77SAnika Henkefunction tpl_link($url,$name,$more='',$return=false){ 398*1af98a77SAnika Henke $out = ''; 399*1af98a77SAnika Henke $out .= '<a href="'.$url.'" '; 400*1af98a77SAnika Henke if ($more) $out .= ' '.$more; 401*1af98a77SAnika Henke $out .= ">$name</a>"; 402*1af98a77SAnika Henke if ($return) return $out; 403*1af98a77SAnika Henke print $out; 40454e95700STom N Harris return true; 4056b13307fSandi} 4066b13307fSandi 4076b13307fSandi/** 40855efc227SAndreas Gohr * Prints a link to a WikiPage 40955efc227SAndreas Gohr * 41055efc227SAndreas Gohr * Wrapper around html_wikilink 41155efc227SAndreas Gohr * 41255efc227SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 41355efc227SAndreas Gohr */ 41455efc227SAndreas Gohrfunction tpl_pagelink($id,$name=NULL){ 41555efc227SAndreas Gohr print html_wikilink($id,$name); 41654e95700STom N Harris return true; 41755efc227SAndreas Gohr} 41855efc227SAndreas Gohr 41955efc227SAndreas Gohr/** 420a3ec5f4aSmatthiasgrimm * get the parent page 421a3ec5f4aSmatthiasgrimm * 422a3ec5f4aSmatthiasgrimm * Tries to find out which page is parent. 423a3ec5f4aSmatthiasgrimm * returns false if none is available 424a3ec5f4aSmatthiasgrimm * 425377f9e97SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 426a3ec5f4aSmatthiasgrimm */ 427377f9e97SAndreas Gohrfunction tpl_getparent($id){ 428a3ec5f4aSmatthiasgrimm global $conf; 429377f9e97SAndreas Gohr $parent = getNS($id).':'; 430377f9e97SAndreas Gohr resolve_pageid('',$parent,$exists); 431a197105eSmatthiasgrimm if($parent == $id) { 432a197105eSmatthiasgrimm $pos = strrpos (getNS($id),':'); 433a197105eSmatthiasgrimm $parent = substr($parent,0,$pos).':'; 434a197105eSmatthiasgrimm resolve_pageid('',$parent,$exists); 435377f9e97SAndreas Gohr if($parent == $id) return false; 436a197105eSmatthiasgrimm } 437377f9e97SAndreas Gohr return $parent; 438a3ec5f4aSmatthiasgrimm} 439a3ec5f4aSmatthiasgrimm 440a3ec5f4aSmatthiasgrimm/** 4416b13307fSandi * Print one of the buttons 4426b13307fSandi * 4436b13307fSandi * Available Buttons are 4446b13307fSandi * 445ee4c4a1bSAndreas Gohr * edit - edit/create/show/draft button 4466b13307fSandi * history - old revisions 4476b13307fSandi * recent - recent changes 4486b13307fSandi * login - login/logout button - if ACL enabled 449d449b912SDenis Simakov * profile - user profile button (if logged in) 4506b13307fSandi * index - The index 451c19fe9c0Sandi * admin - admin page - if enough rights 4526b13307fSandi * top - a back to top button 453a3ec5f4aSmatthiasgrimm * back - a back to parent button - if available 454bbd37938SAndreas Gohr * backlink - links to the list of backlinks 455d449b912SDenis Simakov * subscription- subscribe/unsubscribe button 4566b13307fSandi * 4576b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 458a3ec5f4aSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 4596b13307fSandi */ 460*1af98a77SAnika Henkefunction tpl_button($type,$return=false){ 461b158d625SSteven Danz global $ACT; 4626b13307fSandi global $ID; 463d98d4540SBen Coburn global $REV; 464d67ca2c0Smatthiasgrimm global $NS; 465c19fe9c0Sandi global $INFO; 4666b13307fSandi global $conf; 467cd52f92dSchris global $auth; 4686b13307fSandi 46975e487e9SAndreas Gohr // check disabled actions and fix the badly named ones 47075e487e9SAndreas Gohr $ctype = $type; 47175e487e9SAndreas Gohr if($type == 'history') $ctype='revisions'; 47254e95700STom N Harris if(!actionOK($ctype)) return false; 473409d7af7SAndreas Gohr 474*1af98a77SAnika Henke $out = ''; 4756b13307fSandi switch($type){ 4766b13307fSandi case 'edit': 477409d7af7SAndreas Gohr #most complicated type - we need to decide on current action 478409d7af7SAndreas Gohr if($ACT == 'show' || $ACT == 'search'){ 479409d7af7SAndreas Gohr if($INFO['writable']){ 480bb4866bdSchris if(!empty($INFO['draft'])){ 481*1af98a77SAnika Henke $out .= html_btn('draft',$ID,'e',array('do' => 'draft'),'post'); 482409d7af7SAndreas Gohr }else{ 483409d7af7SAndreas Gohr if($INFO['exists']){ 484*1af98a77SAnika Henke $out .= html_btn('edit',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 485409d7af7SAndreas Gohr }else{ 486*1af98a77SAnika Henke $out .= html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 487409d7af7SAndreas Gohr } 488409d7af7SAndreas Gohr } 489409d7af7SAndreas Gohr }else{ 490409d7af7SAndreas Gohr if(!actionOK('source')) return false; //pseudo action 491*1af98a77SAnika Henke $out .= html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post'); 492409d7af7SAndreas Gohr } 493409d7af7SAndreas Gohr }else{ 494*1af98a77SAnika Henke $out .= html_btn('show',$ID,'v',array('do' => 'show')); 495409d7af7SAndreas Gohr } 496*1af98a77SAnika Henke break; 4976b13307fSandi case 'history': 498*1af98a77SAnika Henke if(actionOK('revisions')) 499*1af98a77SAnika Henke $out .= html_btn('revs',$ID,'o',array('do' => 'revisions')); 500*1af98a77SAnika Henke break; 5016b13307fSandi case 'recent': 502*1af98a77SAnika Henke if(actionOK('recent')) 503*1af98a77SAnika Henke $out .= html_btn('recent',$ID,'r',array('do' => 'recent')); 504*1af98a77SAnika Henke break; 5056b13307fSandi case 'index': 506*1af98a77SAnika Henke if(actionOK('index')) 507*1af98a77SAnika Henke $out .= html_btn('index',$ID,'x',array('do' => 'index')); 508*1af98a77SAnika Henke break; 509a3ec5f4aSmatthiasgrimm case 'back': 5106222040cSmatthiasgrimm if ($parent = tpl_getparent($ID)) { 511*1af98a77SAnika Henke $out .= html_btn('back',$parent,'b',array('do' => 'show')); 512a3ec5f4aSmatthiasgrimm } 513*1af98a77SAnika Henke break; 5146b13307fSandi case 'top': 515*1af98a77SAnika Henke $out .= html_topbtn(); 516*1af98a77SAnika Henke break; 5176b13307fSandi case 'login': 5186957b2eaSAndreas Gohr if($conf['useacl'] && $auth){ 5196b13307fSandi if($_SERVER['REMOTE_USER']){ 520*1af98a77SAnika Henke $out .= html_btn('logout',$ID,'',array('do' => 'logout', 'sectok' => getSecurityToken())); 5216b13307fSandi }else{ 522*1af98a77SAnika Henke $out .= html_btn('login',$ID,'',array('do' => 'login', 'sectok' => getSecurityToken())); 5236b13307fSandi } 5246b13307fSandi } 525*1af98a77SAnika Henke break; 526c19fe9c0Sandi case 'admin': 52754e95700STom N Harris if($INFO['ismanager']){ 528*1af98a77SAnika Henke $out .= html_btn('admin',$ID,'',array('do' => 'admin')); 52954e95700STom N Harris } 530*1af98a77SAnika Henke break; 531582c5bfeSAndreas Gohr case 'subscribe': 5321380fc45SAndreas Gohr case 'subscription': 5336957b2eaSAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 534b158d625SSteven Danz if($_SERVER['REMOTE_USER']){ 5351380fc45SAndreas Gohr if($INFO['subscribed']){ 536*1af98a77SAnika Henke if(actionOK('unsubscribe')) 537*1af98a77SAnika Henke $out .= html_btn('unsubscribe',$ID,'',array('do' => 'unsubscribe',)); 538b158d625SSteven Danz } else { 539*1af98a77SAnika Henke if(actionOK('subscribe')) 540*1af98a77SAnika Henke $out .= html_btn('subscribe',$ID,'',array('do' => 'subscribe',)); 541582c5bfeSAndreas Gohr } 542582c5bfeSAndreas Gohr } 543*1af98a77SAnika Henke } 544*1af98a77SAnika Henke if($type == 'subscribe') break; 545*1af98a77SAnika Henke // else: fall through for backward compatibility 546582c5bfeSAndreas Gohr case 'subscribens': 547582c5bfeSAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 548582c5bfeSAndreas Gohr if($_SERVER['REMOTE_USER']){ 54952b0dd67SGuy Brand if($INFO['subscribedns']){ 550*1af98a77SAnika Henke if(actionOK('unsubscribens')) 551*1af98a77SAnika Henke $out .= html_btn('unsubscribens',$ID,'',array('do' => 'unsubscribens',)); 55252b0dd67SGuy Brand } else { 553*1af98a77SAnika Henke if(actionOK('subscribens')) 554*1af98a77SAnika Henke $out .= html_btn('subscribens',$ID,'',array('do' => 'subscribens',)); 555b158d625SSteven Danz } 556b158d625SSteven Danz } 557*1af98a77SAnika Henke } 558*1af98a77SAnika Henke break; 559f00151b4Schris case 'backlink': 560*1af98a77SAnika Henke if(actionOK('backlink')) 561*1af98a77SAnika Henke $out .= html_btn('backlink',$ID,'',array('do' => 'backlink')); 5628b06d178Schris case 'profile': 5636957b2eaSAndreas Gohr if($conf['useacl'] && $_SERVER['REMOTE_USER'] && $auth && 56436223ba7SAndreas Gohr $auth->canDo('Profile') && ($ACT!='profile')){ 565*1af98a77SAnika Henke $out .= html_btn('profile',$ID,'',array('do' => 'profile')); 5668b06d178Schris } 567*1af98a77SAnika Henke break; 568c19fe9c0Sandi default: 569*1af98a77SAnika Henke $out .= '[unknown button type]'; 570*1af98a77SAnika Henke break; 5716b13307fSandi } 572*1af98a77SAnika Henke if ($return) return $out; 573*1af98a77SAnika Henke print $out; 574*1af98a77SAnika Henke return $out ? true : false; 5756b13307fSandi} 5766b13307fSandi 5776b13307fSandi/** 578ed630903Sandi * Like the action buttons but links 579ed630903Sandi * 580ed630903Sandi * Available links are 581ed630903Sandi * 582d449b912SDenis Simakov * edit - edit/create/show link 583ed630903Sandi * history - old revisions 584ed630903Sandi * recent - recent changes 585d449b912SDenis Simakov * login - login/logout link - if ACL enabled 586d449b912SDenis Simakov * profile - user profile link (if logged in) 587ed630903Sandi * index - The index 588ed630903Sandi * admin - admin page - if enough rights 589d449b912SDenis Simakov * top - a back to top link 590d449b912SDenis Simakov * back - a back to parent link - if available 591bbd37938SAndreas Gohr * backlink - links to the list of backlinks 592d449b912SDenis Simakov * subscribe/subscription - subscribe/unsubscribe link 593ed630903Sandi * 594ed630903Sandi * @author Andreas Gohr <andi@splitbrain.org> 595a3ec5f4aSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 596ed630903Sandi * @see tpl_button 597ed630903Sandi */ 598*1af98a77SAnika Henkefunction tpl_actionlink($type,$pre='',$suf='',$inner='',$return=false){ 599ed630903Sandi global $ID; 600ed630903Sandi global $INFO; 601ed630903Sandi global $REV; 602ed630903Sandi global $ACT; 603ed630903Sandi global $conf; 604ed630903Sandi global $lang; 605cd52f92dSchris global $auth; 606ed630903Sandi 60775e487e9SAndreas Gohr // check disabled actions and fix the badly named ones 60875e487e9SAndreas Gohr $ctype = $type; 60975e487e9SAndreas Gohr if($type == 'history') $ctype='revisions'; 61054e95700STom N Harris if(!actionOK($ctype)) return false; 611409d7af7SAndreas Gohr 612*1af98a77SAnika Henke $out = ''; 613ed630903Sandi switch($type){ 614ed630903Sandi case 'edit': 615ed630903Sandi #most complicated type - we need to decide on current action 616ed630903Sandi if($ACT == 'show' || $ACT == 'search'){ 617ed630903Sandi if($INFO['writable']){ 618b8a111f5SMichael Klier if(!empty($INFO['draft'])) { 619*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=draft'), 620c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_draft']).$suf, 621*1af98a77SAnika Henke 'class="action edit" accesskey="e" rel="nofollow"',1); 622b8a111f5SMichael Klier } else { 623ed630903Sandi if($INFO['exists']){ 624*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=edit&rev='.$REV), 625c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_edit']).$suf, 626*1af98a77SAnika Henke 'class="action edit" accesskey="e" rel="nofollow"',1); 627ed630903Sandi }else{ 628*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=edit&rev='.$REV), 629c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_create']).$suf, 630*1af98a77SAnika Henke 'class="action create" accesskey="e" rel="nofollow"',1); 631ed630903Sandi } 632b8a111f5SMichael Klier } 633ed630903Sandi }else{ 634*1af98a77SAnika Henke if(actionOK('source')) //pseudo action 635*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=edit&rev='.$REV), 636c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_source']).$suf, 637*1af98a77SAnika Henke 'class="action source" accesskey="v" rel="nofollow"',1); 638ed630903Sandi } 639ed630903Sandi }else{ 640*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=show'), 641c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_show']).$suf, 642*1af98a77SAnika Henke 'class="action show" accesskey="v" rel="nofollow"',1); 643ed630903Sandi } 644*1af98a77SAnika Henke break; 645ed630903Sandi case 'history': 646*1af98a77SAnika Henke if(actionOK('revisions')) 647*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=revisions'), 648c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_revs']).$suf, 649*1af98a77SAnika Henke 'class="action revisions" accesskey="o" rel="nofollow"',1); 650*1af98a77SAnika Henke break; 651ed630903Sandi case 'recent': 652*1af98a77SAnika Henke if(actionOK('recent')) 653*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=recent'), 654c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_recent']).$suf, 655*1af98a77SAnika Henke 'class="action recent" accesskey="r" rel="nofollow"',1); 656*1af98a77SAnika Henke break; 657ed630903Sandi case 'index': 658*1af98a77SAnika Henke if(actionOK('index')) 659*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=index'), 660c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_index']).$suf, 661*1af98a77SAnika Henke 'class="action index" accesskey="x" rel="nofollow"',1); 662*1af98a77SAnika Henke break; 663ed630903Sandi case 'top': 664*1af98a77SAnika Henke $out .= '<a href="#dokuwiki__top" class="action top" accesskey="x">'. 665c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_top']).$suf.'</a>'; 666*1af98a77SAnika Henke break; 667a3ec5f4aSmatthiasgrimm case 'back': 668f7569b7bSAndreas Gohr if ($parent = tpl_getparent($ID)) { 669*1af98a77SAnika Henke $out .= tpl_link(wl($parent,'do=show'), 670c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_back']).$suf, 671*1af98a77SAnika Henke 'class="action back" accesskey="b" rel="nofollow"',1); 672a3ec5f4aSmatthiasgrimm } 673*1af98a77SAnika Henke break; 674ed630903Sandi case 'login': 6756957b2eaSAndreas Gohr if($conf['useacl'] && $auth){ 676ed630903Sandi if($_SERVER['REMOTE_USER']){ 677*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=logout&sectok='.getSecurityToken()), 678c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_logout']).$suf, 679*1af98a77SAnika Henke 'class="action logout" rel="nofollow"',1); 680ed630903Sandi }else{ 681*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=login&sectok='.getSecurityToken()), 682c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_login']).$suf, 683*1af98a77SAnika Henke 'class="action login" rel="nofollow"',1); 684ed630903Sandi } 685ed630903Sandi } 686*1af98a77SAnika Henke break; 687ed630903Sandi case 'admin': 688f8cc712eSAndreas Gohr if($INFO['ismanager']){ 689*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=admin'), 690c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_admin']).$suf, 691*1af98a77SAnika Henke 'class="action admin" rel="nofollow"',1); 692c059e1a6SAndreas Gohr } 693*1af98a77SAnika Henke break; 694f9eb5648Ssteven-danz case 'subscribe': 695075f000fSChristopher Arndt case 'subscription': 6966957b2eaSAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 697b158d625SSteven Danz if($_SERVER['REMOTE_USER']){ 698075f000fSChristopher Arndt if($INFO['subscribed']) { 699*1af98a77SAnika Henke if(actionOK('unsubscribe')) 700*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=unsubscribe'), 701c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_unsubscribe']).$suf, 702*1af98a77SAnika Henke 'class="action unsubscribe" rel="nofollow"',1); 703b158d625SSteven Danz } else { 704*1af98a77SAnika Henke if(actionOK('subscribe')) 705*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=subscribe'), 706c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_subscribe']).$suf, 707*1af98a77SAnika Henke 'class="action subscribe" rel="nofollow"',1); 708b158d625SSteven Danz } 709b158d625SSteven Danz } 710*1af98a77SAnika Henke } 711*1af98a77SAnika Henke if($type == 'subscribe') break; 712*1af98a77SAnika Henke // else: fall through for backward compatibility 713280f11b7SMichael Klier case 'subscribens': 714280f11b7SMichael Klier if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 715280f11b7SMichael Klier if($_SERVER['REMOTE_USER']){ 716280f11b7SMichael Klier if($INFO['subscribedns']) { 717*1af98a77SAnika Henke if(actionOK('unsubscribens')) 718*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=unsubscribens'), 719280f11b7SMichael Klier $pre.(($inner)?$inner:$lang['btn_unsubscribens']).$suf, 720*1af98a77SAnika Henke 'class="action unsubscribens" rel="nofollow"',1); 721280f11b7SMichael Klier } else { 722*1af98a77SAnika Henke if(actionOK('subscribens')) 723*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=subscribens'), 724280f11b7SMichael Klier $pre.(($inner)?$inner:$lang['btn_subscribens']).$suf, 725*1af98a77SAnika Henke 'class="action subscribens" rel="nofollow"',1); 726280f11b7SMichael Klier } 727280f11b7SMichael Klier } 728*1af98a77SAnika Henke } 729*1af98a77SAnika Henke break; 730f00151b4Schris case 'backlink': 731*1af98a77SAnika Henke if(actionOK('backlink')) 732*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=backlink'), 733c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_backlink']).$suf, 734*1af98a77SAnika Henke 'class="action backlink" rel="nofollow"',1); 735*1af98a77SAnika Henke break; 7368b06d178Schris case 'profile': 7376957b2eaSAndreas Gohr if($conf['useacl'] && $auth && $_SERVER['REMOTE_USER'] && 73836223ba7SAndreas Gohr $auth->canDo('Profile') && ($ACT!='profile')){ 739*1af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=profile'), 740c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_profile']).$suf, 741*1af98a77SAnika Henke 'class="action profile" rel="nofollow"',1); 7428b06d178Schris } 743*1af98a77SAnika Henke break; 744ed630903Sandi default: 745*1af98a77SAnika Henke $out .= '[unknown link type]'; 746*1af98a77SAnika Henke break; 747ed630903Sandi } 748*1af98a77SAnika Henke if ($return) return $out; 749*1af98a77SAnika Henke print $out; 750*1af98a77SAnika Henke return $out ? true : false; 751ed630903Sandi} 752ed630903Sandi 753ed630903Sandi/** 7546b13307fSandi * Print the search form 7556b13307fSandi * 75672645b75SAndreas Gohr * If the first parameter is given a div with the ID 'qsearch_out' will 75772645b75SAndreas Gohr * be added which instructs the ajax pagequicksearch to kick in and place 75872645b75SAndreas Gohr * its output into this div. The second parameter controls the propritary 75972645b75SAndreas Gohr * attribute autocomplete. If set to false this attribute will be set with an 76072645b75SAndreas Gohr * value of "off" to instruct the browser to disable it's own built in 76172645b75SAndreas Gohr * autocompletion feature (MSIE and Firefox) 76272645b75SAndreas Gohr * 7636b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 7646b13307fSandi */ 76572645b75SAndreas Gohrfunction tpl_searchform($ajax=true,$autocomplete=true){ 7666b13307fSandi global $lang; 767c1e3b7d9Smatthiasgrimm global $ACT; 768c1e3b7d9Smatthiasgrimm 769670ff54eSchris // don't print the search form if search action has been disabled 77054e95700STom N Harris if (!actionOk('search')) return false; 771670ff54eSchris 7721dd0c202SAnika Henke print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search"><div class="no">'; 7736b13307fSandi print '<input type="hidden" name="do" value="search" />'; 774c1e3b7d9Smatthiasgrimm print '<input type="text" '; 775bad31ae9SAndreas Gohr if($ACT == 'search') print 'value="'.htmlspecialchars($_REQUEST['id']).'" '; 77672645b75SAndreas Gohr if(!$autocomplete) print 'autocomplete="off" '; 77707493d05SAnika Henke print 'id="qsearch__in" accesskey="f" name="id" class="edit" title="[F]" />'; 77811ea018fSAndreas Gohr print '<input type="submit" value="'.$lang['btn_search'].'" class="button" title="'.$lang['btn_search'].'" />'; 77924a33b42SAndreas Gohr if($ajax) print '<div id="qsearch__out" class="ajax_qsearch JSpopup"></div>'; 7804beabca9SAnika Henke print '</div></form>'; 78154e95700STom N Harris return true; 7826b13307fSandi} 7836b13307fSandi 7846b13307fSandi/** 7856b13307fSandi * Print the breadcrumbs trace 7866b13307fSandi * 7876b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 7886b13307fSandi */ 78954e95700STom N Harrisfunction tpl_breadcrumbs($sep='»'){ 7906b13307fSandi global $lang; 7916b13307fSandi global $conf; 7926b13307fSandi 7936b13307fSandi //check if enabled 79454e95700STom N Harris if(!$conf['breadcrumbs']) return false; 7956b13307fSandi 7966b13307fSandi $crumbs = breadcrumbs(); //setup crumb trace 797265e3787Sandi 7982979a10bSKatriel Traum //reverse crumborder in right-to-left mode, add RLM character to fix heb/eng display mixups 7992979a10bSKatriel Traum if($lang['direction'] == 'rtl') { 8002979a10bSKatriel Traum $crumbs = array_reverse($crumbs,true); 8012979a10bSKatriel Traum $crumbs_sep = ' ‏<span class="bcsep">'.$sep.'</span>‏ '; 8022979a10bSKatriel Traum } else { 8032979a10bSKatriel Traum $crumbs_sep = ' <span class="bcsep">'.$sep.'</span> '; 8042979a10bSKatriel Traum } 805265e3787Sandi 80640eb54bbSjan //render crumbs, highlight the last one 8071b6f3a44SAndreas Gohr print '<span class="bchead">'.$lang['breadcrumb'].':</span>'; 80840eb54bbSjan $last = count($crumbs); 80940eb54bbSjan $i = 0; 810a77f5846Sjan foreach ($crumbs as $id => $name){ 81140eb54bbSjan $i++; 8122979a10bSKatriel Traum echo $crumbs_sep; 81392795d04Sandi if ($i == $last) print '<span class="curid">'; 814e26fd1eeSAndreas Gohr tpl_link(wl($id),hsc($name),'class="breadcrumbs" title="'.$id.'"'); 81592795d04Sandi if ($i == $last) print '</span>'; 8166b13307fSandi } 81754e95700STom N Harris return true; 8186b13307fSandi} 8196b13307fSandi 8206b13307fSandi/** 8211734437eSandi * Hierarchical breadcrumbs 8221734437eSandi * 82331e187f8SSean Coates * This code was suggested as replacement for the usual breadcrumbs. 8241734437eSandi * It only makes sense with a deep site structure. 8251734437eSandi * 8261734437eSandi * @author Andreas Gohr <andi@splitbrain.org> 8276bd812dfSNigel McNie * @author Nigel McNie <oracle.shinoda@gmail.com> 82831e187f8SSean Coates * @author Sean Coates <sean@caedmon.net> 829f46c9e83SAnika Henke * @author <fredrik@averpil.com> 8306bd812dfSNigel McNie * @todo May behave strangely in RTL languages 8311734437eSandi */ 832796bafb3SAndreas Gohrfunction tpl_youarehere($sep=' » '){ 8331734437eSandi global $conf; 8341734437eSandi global $ID; 8351734437eSandi global $lang; 8361734437eSandi 83731e187f8SSean Coates // check if enabled 83854e95700STom N Harris if(!$conf['youarehere']) return false; 8391734437eSandi 8401734437eSandi $parts = explode(':', $ID); 841796bafb3SAndreas Gohr $count = count($parts); 8421734437eSandi 8431b6f3a44SAndreas Gohr echo '<span class="bchead">'.$lang['youarehere'].': </span>'; 8441734437eSandi 8451734437eSandi // always print the startpage 846fe9ec250SChris Smith $title = useHeading('navigation') ? p_get_first_heading($conf['start']) : $conf['start']; 847796bafb3SAndreas Gohr if(!$title) $title = $conf['start']; 848e26fd1eeSAndreas Gohr tpl_link(wl($conf['start']),hsc($title),'title="'.$conf['start'].'"'); 849796bafb3SAndreas Gohr 850796bafb3SAndreas Gohr // print intermediate namespace links 851796bafb3SAndreas Gohr $part = ''; 852796bafb3SAndreas Gohr for($i=0; $i<$count - 1; $i++){ 853796bafb3SAndreas Gohr $part .= $parts[$i].':'; 854796bafb3SAndreas Gohr $page = $part; 855796bafb3SAndreas Gohr resolve_pageid('',$page,$exists); 856796bafb3SAndreas Gohr if ($page == $conf['start']) continue; // Skip startpage 857796bafb3SAndreas Gohr 858796bafb3SAndreas Gohr // output 859796bafb3SAndreas Gohr echo $sep; 860796bafb3SAndreas Gohr if($exists){ 861af03da1aSAndreas Gohr $title = useHeading('navigation') ? p_get_first_heading($page) : $parts[$i]; 862e26fd1eeSAndreas Gohr tpl_link(wl($page),hsc($title),'title="'.$page.'"'); 86331e187f8SSean Coates }else{ 86478cbfcb6SAndreas Gohr tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2" rel="nofollow"'); 86531e187f8SSean Coates } 86631e187f8SSean Coates } 8671734437eSandi 868796bafb3SAndreas Gohr // print current page, skipping start page, skipping for namespace index 869d98d4540SBen Coburn if(isset($page) && $page==$part.$parts[$i]) return; 870796bafb3SAndreas Gohr $page = $part.$parts[$i]; 871796bafb3SAndreas Gohr if($page == $conf['start']) return; 872796bafb3SAndreas Gohr echo $sep; 873103c256aSChris Smith if(page_exists($page)){ 874af03da1aSAndreas Gohr $title = useHeading('navigation') ? p_get_first_heading($page) : $parts[$i]; 875e26fd1eeSAndreas Gohr tpl_link(wl($page),hsc($title),'title="'.$page.'"'); 87631e187f8SSean Coates }else{ 87778cbfcb6SAndreas Gohr tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2" rel="nofollow"'); 8781734437eSandi } 87954e95700STom N Harris return true; 8801734437eSandi} 8811734437eSandi 8821734437eSandi/** 8836b13307fSandi * Print info if the user is logged in 884a2488c3cSMatthias Grimm * and show full name in that case 8856b13307fSandi * 8866b13307fSandi * Could be enhanced with a profile link in future? 8876b13307fSandi * 8886b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 8896b13307fSandi */ 8906b13307fSandifunction tpl_userinfo(){ 8916b13307fSandi global $lang; 8923e63b73bSMichael Klier global $INFO; 89354e95700STom N Harris if($_SERVER['REMOTE_USER']){ 8943e63b73bSMichael Klier print $lang['loggedinas'].': '.$INFO['userinfo']['name'].' ('.$_SERVER['REMOTE_USER'].')'; 89554e95700STom N Harris return true; 89654e95700STom N Harris } 89754e95700STom N Harris return false; 8986b13307fSandi} 8996b13307fSandi 9006b13307fSandi/** 9016b13307fSandi * Print some info about the current page 9026b13307fSandi * 9036b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 9046b13307fSandi */ 9054b0d3916SAndreas Gohrfunction tpl_pageinfo($ret=false){ 9066b13307fSandi global $conf; 9076b13307fSandi global $lang; 9086b13307fSandi global $INFO; 9096b13307fSandi global $REV; 910c6e92a3cSDavid Lorentsen global $ID; 911c6e92a3cSDavid Lorentsen 912c6e92a3cSDavid Lorentsen // return if we are not allowed to view the page 9134b0d3916SAndreas Gohr if (!auth_quickaclcheck($ID)) { return false; } 9146b13307fSandi 9156b13307fSandi // prepare date and path 9166b13307fSandi $fn = $INFO['filepath']; 9176b13307fSandi if(!$conf['fullpath']){ 9186b13307fSandi if($REV){ 91950fbebceSGina Haeussge $fn = str_replace(fullpath($conf['olddir']).'/','',$fn); 9206b13307fSandi }else{ 92150fbebceSGina Haeussge $fn = str_replace(fullpath($conf['datadir']).'/','',$fn); 9226b13307fSandi } 9236b13307fSandi } 924bee6dc82Sandi $fn = utf8_decodeFN($fn); 925e656dcd4SAndreas Gohr $date = strftime($conf['dformat'],$INFO['lastmod']); 9266b13307fSandi 927faecdfdfSAndreas Gohr // print it 928faecdfdfSAndreas Gohr if($INFO['exists']){ 9294b0d3916SAndreas Gohr $out = ''; 9304b0d3916SAndreas Gohr $out .= $fn; 9314b0d3916SAndreas Gohr $out .= ' · '; 9324b0d3916SAndreas Gohr $out .= $lang['lastmod']; 9334b0d3916SAndreas Gohr $out .= ': '; 9344b0d3916SAndreas Gohr $out .= $date; 9356b13307fSandi if($INFO['editor']){ 9364b0d3916SAndreas Gohr $out .= ' '.$lang['by'].' '; 937dc58b6f4SAndy Webber $out .= editorinfo($INFO['editor']); 9385aa52fafSBen Coburn }else{ 9394b0d3916SAndreas Gohr $out .= ' ('.$lang['external_edit'].')'; 9406b13307fSandi } 9416b13307fSandi if($INFO['locked']){ 9424b0d3916SAndreas Gohr $out .= ' · '; 9434b0d3916SAndreas Gohr $out .= $lang['lockedby']; 9444b0d3916SAndreas Gohr $out .= ': '; 945dc58b6f4SAndy Webber $out .= editorinfo($INFO['locked']); 9466b13307fSandi } 9474b0d3916SAndreas Gohr if($ret){ 9484b0d3916SAndreas Gohr return $out; 9494b0d3916SAndreas Gohr }else{ 9504b0d3916SAndreas Gohr echo $out; 95154e95700STom N Harris return true; 9526b13307fSandi } 9534b0d3916SAndreas Gohr } 95454e95700STom N Harris return false; 9556b13307fSandi} 9566b13307fSandi 957820fa24bSandi/** 958a6598f23SBen Coburn * Prints or returns the name of the given page (current one if none given). 95987c434ceSAndreas Gohr * 96087c434ceSAndreas Gohr * If useheading is enabled this will use the first headline else 961a6598f23SBen Coburn * the given ID is used. 96287c434ceSAndreas Gohr * 96387c434ceSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 96487c434ceSAndreas Gohr */ 965a6598f23SBen Coburnfunction tpl_pagetitle($id=null, $ret=false){ 96687c434ceSAndreas Gohr global $conf; 96787c434ceSAndreas Gohr if(is_null($id)){ 96887c434ceSAndreas Gohr global $ID; 96987c434ceSAndreas Gohr $id = $ID; 97087c434ceSAndreas Gohr } 97187c434ceSAndreas Gohr 97287c434ceSAndreas Gohr $name = $id; 973fe9ec250SChris Smith if (useHeading('navigation')) { 97487c434ceSAndreas Gohr $title = p_get_first_heading($id); 97587c434ceSAndreas Gohr if ($title) $name = $title; 97687c434ceSAndreas Gohr } 977a6598f23SBen Coburn 978a6598f23SBen Coburn if ($ret) { 979a6598f23SBen Coburn return hsc($name); 980a6598f23SBen Coburn } else { 98187c434ceSAndreas Gohr print hsc($name); 98254e95700STom N Harris return true; 98387c434ceSAndreas Gohr } 984a6598f23SBen Coburn} 985340756e4Sandi 98655efc227SAndreas Gohr/** 98755efc227SAndreas Gohr * Returns the requested EXIF/IPTC tag from the current image 98855efc227SAndreas Gohr * 98955efc227SAndreas Gohr * If $tags is an array all given tags are tried until a 99055efc227SAndreas Gohr * value is found. If no value is found $alt is returned. 99155efc227SAndreas Gohr * 99255efc227SAndreas Gohr * Which texts are known is defined in the functions _exifTagNames 99355efc227SAndreas Gohr * and _iptcTagNames() in inc/jpeg.php (You need to prepend IPTC 99455efc227SAndreas Gohr * to the names of the latter one) 99555efc227SAndreas Gohr * 9963df72098SAndreas Gohr * Only allowed in: detail.php 99755efc227SAndreas Gohr * 99855efc227SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 99955efc227SAndreas Gohr */ 10003df72098SAndreas Gohrfunction tpl_img_getTag($tags,$alt='',$src=null){ 100155efc227SAndreas Gohr // Init Exif Reader 100255efc227SAndreas Gohr global $SRC; 10033df72098SAndreas Gohr 10043df72098SAndreas Gohr if(is_null($src)) $src = $SRC; 10053df72098SAndreas Gohr 100655efc227SAndreas Gohr static $meta = null; 10073df72098SAndreas Gohr if(is_null($meta)) $meta = new JpegMeta($src); 100855efc227SAndreas Gohr if($meta === false) return $alt; 100955efc227SAndreas Gohr $info = $meta->getField($tags); 101055efc227SAndreas Gohr if($info == false) return $alt; 101155efc227SAndreas Gohr return $info; 101255efc227SAndreas Gohr} 101355efc227SAndreas Gohr 101455efc227SAndreas Gohr/** 101555efc227SAndreas Gohr * Prints the image with a link to the full sized version 101655efc227SAndreas Gohr * 101755efc227SAndreas Gohr * Only allowed in: detail.php 101855efc227SAndreas Gohr */ 1019f8925855Sjoe.lappfunction tpl_img($maxwidth=0,$maxheight=0){ 102055efc227SAndreas Gohr global $IMG; 102155efc227SAndreas Gohr $w = tpl_img_getTag('File.Width'); 102255efc227SAndreas Gohr $h = tpl_img_getTag('File.Height'); 102355efc227SAndreas Gohr 102455efc227SAndreas Gohr //resize to given max values 102523a34783SAndreas Gohr $ratio = 1; 102623a34783SAndreas Gohr if($w >= $h){ 1027f8925855Sjoe.lapp if($maxwidth && $w >= $maxwidth){ 102855efc227SAndreas Gohr $ratio = $maxwidth/$w; 1029f8925855Sjoe.lapp }elseif($maxheight && $h > $maxheight){ 103055efc227SAndreas Gohr $ratio = $maxheight/$h; 103155efc227SAndreas Gohr } 103255efc227SAndreas Gohr }else{ 1033f8925855Sjoe.lapp if($maxheight && $h >= $maxheight){ 103455efc227SAndreas Gohr $ratio = $maxheight/$h; 1035f8925855Sjoe.lapp }elseif($maxwidth && $w > $maxwidth){ 103655efc227SAndreas Gohr $ratio = $maxwidth/$w; 103755efc227SAndreas Gohr } 103855efc227SAndreas Gohr } 103955efc227SAndreas Gohr if($ratio){ 104055efc227SAndreas Gohr $w = floor($ratio*$w); 104155efc227SAndreas Gohr $h = floor($ratio*$h); 104255efc227SAndreas Gohr } 104355efc227SAndreas Gohr 10446de3759aSAndreas Gohr //prepare URLs 10456de3759aSAndreas Gohr $url=ml($IMG,array('cache'=>$_REQUEST['cache'])); 10466de3759aSAndreas Gohr $src=ml($IMG,array('cache'=>$_REQUEST['cache'],'w'=>$w,'h'=>$h)); 104755efc227SAndreas Gohr 10482684e50aSAndreas Gohr //prepare attributes 104955efc227SAndreas Gohr $alt=tpl_img_getTag('Simple.Title'); 10502684e50aSAndreas Gohr $p = array(); 10512684e50aSAndreas Gohr if($w) $p['width'] = $w; 10522684e50aSAndreas Gohr if($h) $p['height'] = $h; 10532684e50aSAndreas Gohr $p['class'] = 'img_detail'; 10542684e50aSAndreas Gohr if($alt){ 10552684e50aSAndreas Gohr $p['alt'] = $alt; 10562684e50aSAndreas Gohr $p['title'] = $alt; 10572684e50aSAndreas Gohr }else{ 10582684e50aSAndreas Gohr $p['alt'] = ''; 10592684e50aSAndreas Gohr } 10602684e50aSAndreas Gohr $p = buildAttributes($p); 106155efc227SAndreas Gohr 106255efc227SAndreas Gohr print '<a href="'.$url.'">'; 10636de3759aSAndreas Gohr print '<img src="'.$src.'" '.$p.'/>'; 106455efc227SAndreas Gohr print '</a>'; 106554e95700STom N Harris return true; 106655efc227SAndreas Gohr} 106755efc227SAndreas Gohr 10687367b368SAndreas Gohr/** 10697367b368SAndreas Gohr * This function inserts a 1x1 pixel gif which in reality 10707367b368SAndreas Gohr * is the inexer function. 10717367b368SAndreas Gohr * 10727367b368SAndreas Gohr * Should be called somewhere at the very end of the main.php 10737367b368SAndreas Gohr * template 10747367b368SAndreas Gohr */ 10757367b368SAndreas Gohrfunction tpl_indexerWebBug(){ 10767367b368SAndreas Gohr global $ID; 10771dad36f5SAndreas Gohr global $INFO; 107854e95700STom N Harris if(!$INFO['exists']) return false; 10791dad36f5SAndreas Gohr 108054e95700STom N Harris if(isHiddenPage($ID)) return false; //no need to index hidden pages 10810dc92c6fSAndreas Gohr 10827367b368SAndreas Gohr $p = array(); 1083b6c6979fSAndreas Gohr $p['src'] = DOKU_BASE.'lib/exe/indexer.php?id='.rawurlencode($ID). 1084e68c51baSAndreas Gohr '&'.time(); 10857367b368SAndreas Gohr $p['width'] = 1; 10867367b368SAndreas Gohr $p['height'] = 1; 10877367b368SAndreas Gohr $p['alt'] = ''; 10887367b368SAndreas Gohr $att = buildAttributes($p); 10897367b368SAndreas Gohr print "<img $att />"; 109054e95700STom N Harris return true; 10917367b368SAndreas Gohr} 10927367b368SAndreas Gohr 109378d4e784SEsther Brunner// configuration methods 109478d4e784SEsther Brunner/** 109578d4e784SEsther Brunner * tpl_getConf($id) 109678d4e784SEsther Brunner * 109778d4e784SEsther Brunner * use this function to access template configuration variables 109878d4e784SEsther Brunner */ 109978d4e784SEsther Brunnerfunction tpl_getConf($id){ 110078d4e784SEsther Brunner global $conf; 110178d4e784SEsther Brunner global $tpl_configloaded; 110278d4e784SEsther Brunner 110378d4e784SEsther Brunner $tpl = $conf['template']; 110478d4e784SEsther Brunner 110578d4e784SEsther Brunner if (!$tpl_configloaded){ 110678d4e784SEsther Brunner $tconf = tpl_loadConfig(); 110778d4e784SEsther Brunner if ($tconf !== false){ 110878d4e784SEsther Brunner foreach ($tconf as $key => $value){ 110978d4e784SEsther Brunner if (isset($conf['tpl'][$tpl][$key])) continue; 111078d4e784SEsther Brunner $conf['tpl'][$tpl][$key] = $value; 111178d4e784SEsther Brunner } 111278d4e784SEsther Brunner $tpl_configloaded = true; 111378d4e784SEsther Brunner } 111478d4e784SEsther Brunner } 111578d4e784SEsther Brunner 111678d4e784SEsther Brunner return $conf['tpl'][$tpl][$id]; 111778d4e784SEsther Brunner} 111878d4e784SEsther Brunner 111978d4e784SEsther Brunner/** 112078d4e784SEsther Brunner * tpl_loadConfig() 112178d4e784SEsther Brunner * reads all template configuration variables 112278d4e784SEsther Brunner * this function is automatically called by tpl_getConf() 112378d4e784SEsther Brunner */ 112478d4e784SEsther Brunnerfunction tpl_loadConfig(){ 112578d4e784SEsther Brunner 112678d4e784SEsther Brunner $file = DOKU_TPLINC.'/conf/default.php'; 112778d4e784SEsther Brunner $conf = array(); 112878d4e784SEsther Brunner 112978d4e784SEsther Brunner if (!@file_exists($file)) return false; 113078d4e784SEsther Brunner 113178d4e784SEsther Brunner // load default config file 113278d4e784SEsther Brunner include($file); 113378d4e784SEsther Brunner 113478d4e784SEsther Brunner return $conf; 113578d4e784SEsther Brunner} 113678d4e784SEsther Brunner 11373df72098SAndreas Gohr/** 11383df72098SAndreas Gohr * prints the "main content" in the mediamanger popup 11393df72098SAndreas Gohr * 11403df72098SAndreas Gohr * Depending on the user's actions this may be a list of 11413df72098SAndreas Gohr * files in a namespace, the meta editing dialog or 11423df72098SAndreas Gohr * a message of referencing pages 11433df72098SAndreas Gohr * 11443df72098SAndreas Gohr * Only allowed in mediamanager.php 11453df72098SAndreas Gohr * 11463df72098SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 11473df72098SAndreas Gohr */ 11483df72098SAndreas Gohrfunction tpl_mediaContent(){ 11493df72098SAndreas Gohr global $IMG; 11503df72098SAndreas Gohr global $AUTH; 11513df72098SAndreas Gohr global $INUSE; 11523df72098SAndreas Gohr global $NS; 11533df72098SAndreas Gohr global $JUMPTO; 11543df72098SAndreas Gohr 11553df72098SAndreas Gohr ptln('<div id="media__content">'); 11563df72098SAndreas Gohr if($_REQUEST['edit']){ 11573df72098SAndreas Gohr media_metaform($IMG,$AUTH); 11587b877f51SAndreas Gohr }elseif(is_array($INUSE)){ 11593df72098SAndreas Gohr media_filesinuse($INUSE,$IMG); 11603df72098SAndreas Gohr }else{ 11613df72098SAndreas Gohr media_filelist($NS,$AUTH,$JUMPTO); 11623df72098SAndreas Gohr } 11633df72098SAndreas Gohr ptln('</div>'); 11643df72098SAndreas Gohr} 11653df72098SAndreas Gohr 11663df72098SAndreas Gohr/** 11673df72098SAndreas Gohr * prints the namespace tree in the mediamanger popup 11683df72098SAndreas Gohr * 11693df72098SAndreas Gohr * Only allowed in mediamanager.php 11703df72098SAndreas Gohr * 11713df72098SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 11723df72098SAndreas Gohr */ 11733df72098SAndreas Gohrfunction tpl_mediaTree(){ 11743df72098SAndreas Gohr global $NS; 11753df72098SAndreas Gohr 11763df72098SAndreas Gohr ptln('<div id="media__tree">'); 11773df72098SAndreas Gohr media_nstree($NS); 11783df72098SAndreas Gohr ptln('</div>'); 11793df72098SAndreas Gohr} 11803df72098SAndreas Gohr 1181a00de5b5SAndreas Gohr 1182a00de5b5SAndreas Gohr/** 1183a00de5b5SAndreas Gohr * Print a dropdown menu with all DokuWiki actions 1184a00de5b5SAndreas Gohr * 1185a00de5b5SAndreas Gohr * Note: this will not use any pretty URLs 1186a00de5b5SAndreas Gohr * 1187a00de5b5SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1188a00de5b5SAndreas Gohr */ 1189a00de5b5SAndreas Gohrfunction tpl_actiondropdown($empty='',$button='>'){ 1190a00de5b5SAndreas Gohr global $ID; 1191a00de5b5SAndreas Gohr global $INFO; 1192a00de5b5SAndreas Gohr global $REV; 1193a00de5b5SAndreas Gohr global $ACT; 1194a00de5b5SAndreas Gohr global $conf; 1195a00de5b5SAndreas Gohr global $lang; 1196a00de5b5SAndreas Gohr global $auth; 1197a00de5b5SAndreas Gohr 1198a00de5b5SAndreas Gohr 1199a00de5b5SAndreas Gohr echo '<form method="post" accept-charset="utf-8">'; #FIXME action 1200a00de5b5SAndreas Gohr echo '<input type="hidden" name="id" value="'.$ID.'" />'; 1201a00de5b5SAndreas Gohr if($REV) echo '<input type="hidden" name="rev" value="'.$REV.'" />'; 1202a00de5b5SAndreas Gohr echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'; 1203a00de5b5SAndreas Gohr 1204a00de5b5SAndreas Gohr echo '<select name="do" id="action__selector" class="edit">'; 1205a00de5b5SAndreas Gohr echo '<option value="">'.$empty.'</option>'; 1206a00de5b5SAndreas Gohr 1207a00de5b5SAndreas Gohr echo '<optgroup label=" — ">'; 1208a00de5b5SAndreas Gohr // 'edit' - most complicated type, we need to decide on current action 1209a00de5b5SAndreas Gohr if($ACT == 'show' || $ACT == 'search'){ 1210a00de5b5SAndreas Gohr if($INFO['writable']){ 1211a00de5b5SAndreas Gohr if(!empty($INFO['draft'])) { 1212a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_draft'].'</option>'; 1213a00de5b5SAndreas Gohr } else { 1214a00de5b5SAndreas Gohr if($INFO['exists']){ 1215a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_edit'].'</option>'; 1216a00de5b5SAndreas Gohr }else{ 1217a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_create'].'</option>'; 1218a00de5b5SAndreas Gohr } 1219a00de5b5SAndreas Gohr } 1220a00de5b5SAndreas Gohr }else if(actionOK('source')) { //pseudo action 1221a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_source'].'</option>'; 1222a00de5b5SAndreas Gohr } 1223a00de5b5SAndreas Gohr }else{ 1224a00de5b5SAndreas Gohr echo '<option value="show">'.$lang['btn_show'].'</option>'; 1225a00de5b5SAndreas Gohr } 1226a00de5b5SAndreas Gohr 1227a00de5b5SAndreas Gohr echo '<option value="revisions">'.$lang['btn_revs'].'</option>'; 1228a00de5b5SAndreas Gohr echo '<option value="backlink">'.$lang['btn_backlink'].'</option>'; 1229a00de5b5SAndreas Gohr echo '</optgroup>'; 1230a00de5b5SAndreas Gohr 1231a00de5b5SAndreas Gohr echo '<optgroup label=" — ">'; 1232a00de5b5SAndreas Gohr echo '<option value="recent">'.$lang['btn_recent'].'</option>'; 1233a00de5b5SAndreas Gohr echo '<option value="index">'.$lang['btn_index'].'</option>'; 1234a00de5b5SAndreas Gohr echo '</optgroup>'; 1235a00de5b5SAndreas Gohr 1236a00de5b5SAndreas Gohr echo '<optgroup label=" — ">'; 1237a00de5b5SAndreas Gohr if($conf['useacl'] && $auth){ 1238a00de5b5SAndreas Gohr if($_SERVER['REMOTE_USER']){ 1239a00de5b5SAndreas Gohr echo '<option value="logout">'.$lang['btn_logout'].'</option>'; 1240a00de5b5SAndreas Gohr }else{ 1241a00de5b5SAndreas Gohr echo '<option value="login">'.$lang['btn_login'].'</option>'; 1242a00de5b5SAndreas Gohr } 1243a00de5b5SAndreas Gohr } 1244a00de5b5SAndreas Gohr 1245a00de5b5SAndreas Gohr if($conf['useacl'] && $auth && $_SERVER['REMOTE_USER'] && 1246a00de5b5SAndreas Gohr $auth->canDo('Profile') && ($ACT!='profile')){ 1247a00de5b5SAndreas Gohr echo '<option value="profile">'.$lang['btn_profile'].'</option>'; 1248a00de5b5SAndreas Gohr } 1249a00de5b5SAndreas Gohr 1250a00de5b5SAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 1251a00de5b5SAndreas Gohr if($_SERVER['REMOTE_USER']){ 1252a00de5b5SAndreas Gohr if($INFO['subscribed']) { 1253a00de5b5SAndreas Gohr echo '<option value="unsubscribe">'.$lang['btn_unsubscribe'].'</option>'; 1254a00de5b5SAndreas Gohr } else { 1255a00de5b5SAndreas Gohr echo '<option value="subscribe">'.$lang['btn_subscribe'].'</option>'; 1256a00de5b5SAndreas Gohr } 1257a00de5b5SAndreas Gohr } 1258a00de5b5SAndreas Gohr } 1259a00de5b5SAndreas Gohr 1260a00de5b5SAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 1261a00de5b5SAndreas Gohr if($_SERVER['REMOTE_USER']){ 1262a00de5b5SAndreas Gohr if($INFO['subscribedns']) { 1263a00de5b5SAndreas Gohr echo '<option value="unsubscribens">'.$lang['btn_unsubscribens'].'</option>'; 1264a00de5b5SAndreas Gohr } else { 1265a00de5b5SAndreas Gohr echo '<option value="subscribens">'.$lang['btn_subscribens'].'</option>'; 1266a00de5b5SAndreas Gohr } 1267a00de5b5SAndreas Gohr } 1268a00de5b5SAndreas Gohr } 1269a00de5b5SAndreas Gohr 1270a00de5b5SAndreas Gohr if($INFO['ismanager']){ 1271a00de5b5SAndreas Gohr echo '<option value="admin">'.$lang['btn_admin'].'</option>'; 1272a00de5b5SAndreas Gohr } 1273a00de5b5SAndreas Gohr echo '</optgroup>'; 1274a00de5b5SAndreas Gohr 1275a00de5b5SAndreas Gohr echo '</select>'; 1276a00de5b5SAndreas Gohr echo '<input type="submit" value="'.$button.'" id="action__selectorbtn" />'; 1277a00de5b5SAndreas Gohr echo '</form>'; 1278a00de5b5SAndreas Gohr} 1279a00de5b5SAndreas Gohr 1280066fee30SAndreas Gohr/** 1281066fee30SAndreas Gohr * Print a informational line about the used license 1282066fee30SAndreas Gohr * 1283066fee30SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1284066fee30SAndreas Gohr * @param string $img - print image? (|button|badge) 1285066fee30SAndreas Gohr * @param bool $return - when true don't print, but return HTML 1286066fee30SAndreas Gohr */ 12874cefd216SMichael Klierfunction tpl_license($img='badge',$imgonly=false,$return=false){ 1288066fee30SAndreas Gohr global $license; 1289066fee30SAndreas Gohr global $conf; 1290066fee30SAndreas Gohr global $lang; 1291066fee30SAndreas Gohr if(!$conf['license']) return ''; 1292066fee30SAndreas Gohr if(!is_array($license[$conf['license']])) return ''; 1293066fee30SAndreas Gohr $lic = $license[$conf['license']]; 1294066fee30SAndreas Gohr 12954cefd216SMichael Klier $out = '<div class="license">'; 1296066fee30SAndreas Gohr if($img){ 1297066fee30SAndreas Gohr $src = license_img($img); 1298066fee30SAndreas Gohr if($src){ 1299066fee30SAndreas Gohr $out .= '<a href="'.$lic['url'].'" rel="license"'; 1300066fee30SAndreas Gohr if($conf['target']['external']) $out .= ' target="'.$conf['target']['external'].'"'; 1301a57c7cafSAnika Henke $out .= '><img src="'.DOKU_BASE.$src.'" class="medialeft lic'.$img.'" alt="'.$lic['name'].'" /></a> '; 1302066fee30SAndreas Gohr } 1303066fee30SAndreas Gohr } 13044cefd216SMichael Klier if(!$imgonly) { 1305066fee30SAndreas Gohr $out .= $lang['license']; 1306066fee30SAndreas Gohr $out .= '<a href="'.$lic['url'].'" rel="license" class="urlextern"'; 1307066fee30SAndreas Gohr if($conf['target']['external']) $out .= ' target="'.$conf['target']['external'].'"'; 1308066fee30SAndreas Gohr $out .= '>'.$lic['name'].'</a>'; 13094cefd216SMichael Klier $out .= '</div>'; 13104cefd216SMichael Klier } 1311066fee30SAndreas Gohr 1312066fee30SAndreas Gohr if($return) return $out; 1313066fee30SAndreas Gohr echo $out; 1314066fee30SAndreas Gohr} 1315066fee30SAndreas Gohr 1316b8595a66SAndreas Gohr//Setup VIM: ex: et ts=4 enc=utf-8 : 1317a00de5b5SAndreas Gohr 1318