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 900976812SAndreas Gohr if(!defined('DOKU_INC')) define('DOKU_INC',fullpath(dirname(__FILE__).'/../').'/'); 10e7cb32dcSAndreas Gohr require_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': 91*abdcc39fSmichael if (is_array($_REQUEST['first'])) { 92*abdcc39fSmichael $_REQUEST['first'] = array_keys($_REQUEST['first']); 93*abdcc39fSmichael $_REQUEST['first'] = $_REQUEST['first'][0]; 94*abdcc39fSmichael } 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(); 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; 154b8595a66SAndreas Gohr $toc = array(); 155b8595a66SAndreas Gohr 156b8595a66SAndreas Gohr if(is_array($TOC)){ 157b8595a66SAndreas Gohr // if a TOC was prepared in global scope, always use it 158b8595a66SAndreas Gohr $toc = $TOC; 1593c86d7c9SAndreas Gohr }elseif(($ACT == 'show' || substr($ACT,0,6) == 'export') && !$REV && $INFO['exists']){ 160b8595a66SAndreas Gohr // get TOC from metadata, render if neccessary 161b8595a66SAndreas Gohr $meta = p_get_metadata($ID, false, true); 162b8595a66SAndreas Gohr if(isset($meta['internal']['toc'])){ 163b8595a66SAndreas Gohr $tocok = $meta['internal']['toc']; 164b8595a66SAndreas Gohr }else{ 1652bb0d541Schris $tocok = true; 166b8595a66SAndreas Gohr } 167b8595a66SAndreas Gohr $toc = $meta['description']['tableofcontents']; 168b8595a66SAndreas Gohr if(!$tocok || !is_array($toc) || count($toc) < 3){ 169b8595a66SAndreas Gohr $toc = array(); 170b8595a66SAndreas Gohr } 171b8595a66SAndreas Gohr }elseif($ACT == 'admin'){ 172b8595a66SAndreas Gohr // try to load admin plugin TOC FIXME: duplicates code from tpl_admin 173b8595a66SAndreas Gohr $plugin = null; 174b8595a66SAndreas Gohr if (!empty($_REQUEST['page'])) { 175b8595a66SAndreas Gohr $pluginlist = plugin_list('admin'); 176b8595a66SAndreas Gohr if (in_array($_REQUEST['page'], $pluginlist)) { 177b8595a66SAndreas Gohr // attempt to load the plugin 178b8595a66SAndreas Gohr $plugin =& plugin_load('admin',$_REQUEST['page']); 179b8595a66SAndreas Gohr } 180b8595a66SAndreas Gohr } 181b8595a66SAndreas Gohr if ( ($plugin !== null) && 182b8595a66SAndreas Gohr (!$plugin->forAdminOnly() || $INFO['isadmin']) ){ 183b8595a66SAndreas Gohr $toc = $plugin->getTOC(); 184b8595a66SAndreas Gohr $TOC = $toc; // avoid later rebuild 185b8595a66SAndreas Gohr } 186b8595a66SAndreas Gohr } 187b8595a66SAndreas Gohr 1887dee3468SGina Haeussge trigger_event('TPL_TOC_RENDER', $toc, NULL, false); 189b8595a66SAndreas Gohr $html = html_TOC($toc); 190b8595a66SAndreas Gohr if($return) return $html; 191b8595a66SAndreas Gohr echo $html; 192b8595a66SAndreas Gohr} 193b8595a66SAndreas Gohr 194b8595a66SAndreas Gohr/** 195c19fe9c0Sandi * Handle the admin page contents 196c19fe9c0Sandi * 197c19fe9c0Sandi * @author Andreas Gohr <andi@splitbrain.org> 198c19fe9c0Sandi */ 199c19fe9c0Sandifunction tpl_admin(){ 200f8cc712eSAndreas Gohr global $INFO; 201b8595a66SAndreas Gohr global $TOC; 20211e2ce22Schris 203b8595a66SAndreas Gohr $plugin = null; 204bb4866bdSchris if (!empty($_REQUEST['page'])) { 20511e2ce22Schris $pluginlist = plugin_list('admin'); 20611e2ce22Schris 20711e2ce22Schris if (in_array($_REQUEST['page'], $pluginlist)) { 20811e2ce22Schris 20911e2ce22Schris // attempt to load the plugin 21011e2ce22Schris $plugin =& plugin_load('admin',$_REQUEST['page']); 21111e2ce22Schris } 21211e2ce22Schris } 21311e2ce22Schris 214b8595a66SAndreas Gohr if ($plugin !== null){ 215f8cc712eSAndreas Gohr if($plugin->forAdminOnly() && !$INFO['isadmin']){ 216f8cc712eSAndreas Gohr msg('For admins only',-1); 21711e2ce22Schris html_admin(); 218f8cc712eSAndreas Gohr }else{ 219b8595a66SAndreas Gohr if(!is_array($TOC)) $TOC = $plugin->getTOC(); //if TOC wasn't requested yet 220b8595a66SAndreas Gohr if($INFO['prependTOC']) tpl_toc(); 221f8cc712eSAndreas Gohr $plugin->html(); 222f8cc712eSAndreas Gohr } 223f8cc712eSAndreas Gohr }else{ 224f8cc712eSAndreas Gohr html_admin(); 225f8cc712eSAndreas Gohr } 22654e95700STom N Harris return true; 227c19fe9c0Sandi} 2286b13307fSandi 2296b13307fSandi/** 2306b13307fSandi * Print the correct HTML meta headers 2316b13307fSandi * 2326b13307fSandi * This has to go into the head section of your template. 2336b13307fSandi * 234016b6153SAndreas Gohr * @triggers TPL_METAHEADER_OUTPUT 235f96fa415SAndreas Gohr * @param boolean $alt Should feeds and alternative format links be added? 2366b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 2376b13307fSandi */ 238f96fa415SAndreas Gohrfunction tpl_metaheaders($alt=true){ 2396b13307fSandi global $ID; 240d98d4540SBen Coburn global $REV; 2416b13307fSandi global $INFO; 2426b13307fSandi global $ACT; 2434bb1b5aeSAndreas Gohr global $QUERY; 2446b13307fSandi global $lang; 245dc57ef04Sandi global $conf; 2466b13307fSandi $it=2; 2476b13307fSandi 2487bff22c0SAndreas Gohr // prepare the head array 2497bff22c0SAndreas Gohr $head = array(); 2507bff22c0SAndreas Gohr 2517bff22c0SAndreas Gohr 2526b13307fSandi // the usual stuff 2537bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'generator', 'content'=>'DokuWiki '.getVersion() ); 254da96af35SAndreas Gohr $head['link'][] = array( 'rel'=>'search', 'type'=>'application/opensearchdescription+xml', 255da96af35SAndreas Gohr 'href'=>DOKU_BASE.'lib/exe/opensearch.php', 'title'=>$conf['title'] ); 256f4f47358SBen Coburn $head['link'][] = array( 'rel'=>'start', 'href'=>DOKU_BASE ); 2577aedde2eSGina Haeussge if(actionOK('index')){ 2587bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'contents', 'href'=> wl($ID,'do=index',false,'&'), 259bb4866bdSchris 'title'=>$lang['btn_index'] ); 2607aedde2eSGina Haeussge } 261f96fa415SAndreas Gohr 262f96fa415SAndreas Gohr if($alt){ 2637bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 2647bff22c0SAndreas Gohr 'title'=>'Recent Changes', 'href'=>DOKU_BASE.'feed.php'); 2657bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 2667bff22c0SAndreas Gohr 'title'=>'Current Namespace', 2677bff22c0SAndreas Gohr 'href'=>DOKU_BASE.'feed.php?mode=list&ns='.$INFO['namespace']); 268c35f3875SAndreas Gohr if(($ACT == 'show' || $ACT == 'search') && $INFO['writable']){ 269c35f3875SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/wiki', 270715bdf1fSAndreas Gohr 'title'=>$lang['btn_edit'], 271c35f3875SAndreas Gohr 'href'=> wl($ID,'do=edit',false,'&')); 272c35f3875SAndreas Gohr } 273c35f3875SAndreas Gohr 2744bb1b5aeSAndreas Gohr if($ACT == 'search'){ 2754bb1b5aeSAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 2764bb1b5aeSAndreas Gohr 'title'=>'Search Result', 2774bb1b5aeSAndreas Gohr 'href'=>DOKU_BASE.'feed.php?mode=search&q='.$QUERY); 2784bb1b5aeSAndreas Gohr } 279bae36d94SAndreas Gohr 280bae36d94SAndreas Gohr if(actionOK('export_xhtml')){ 2817bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'text/html', 'title'=>'Plain HTML', 2827bff22c0SAndreas Gohr 'href'=>exportlink($ID, 'xhtml', '', false, '&')); 283bae36d94SAndreas Gohr } 284bae36d94SAndreas Gohr 285bae36d94SAndreas Gohr if(actionOK('export_raw')){ 2867bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'text/plain', 'title'=>'Wiki Markup', 2877bff22c0SAndreas Gohr 'href'=>exportlink($ID, 'raw', '', false, '&')); 288f96fa415SAndreas Gohr } 289bae36d94SAndreas Gohr } 2906b13307fSandi 2916b13307fSandi // setup robot tags apropriate for different modes 2924f2e0004STim Weber if( ($ACT=='show' || $ACT=='export_xhtml') && !$REV){ 2936b13307fSandi if($INFO['exists']){ 2946b13307fSandi //delay indexing: 2956b13307fSandi if((time() - $INFO['lastmod']) >= $conf['indexdelay']){ 2967bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'index,follow'); 2976b13307fSandi }else{ 2987bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,nofollow'); 2996b13307fSandi } 3006b13307fSandi }else{ 3017bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,follow'); 3026b13307fSandi } 3037a24876fSAndreas Gohr }elseif(defined('DOKU_MEDIADETAIL')){ 3047bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'index,follow'); 3056b13307fSandi }else{ 3067bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,nofollow'); 3076b13307fSandi } 3086b13307fSandi 309831800b8SAndreas Gohr // set metadata 310831800b8SAndreas Gohr if($ACT == 'show' || $ACT=='export_xhtml'){ 311831800b8SAndreas Gohr // date of modification 312831800b8SAndreas Gohr if($REV){ 3137bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'date', 'content'=>date('Y-m-d\TH:i:sO',$REV)); 314831800b8SAndreas Gohr }else{ 3157bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'date', 'content'=>date('Y-m-d\TH:i:sO',$INFO['lastmod'])); 316831800b8SAndreas Gohr } 317831800b8SAndreas Gohr 318831800b8SAndreas Gohr // keywords (explicit or implicit) 319bb4866bdSchris if(!empty($INFO['meta']['subject'])){ 3207bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'keywords', 'content'=>join(',',$INFO['meta']['subject'])); 321831800b8SAndreas Gohr }else{ 3227bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'keywords', 'content'=>str_replace(':',',',$ID)); 323831800b8SAndreas Gohr } 324831800b8SAndreas Gohr } 325831800b8SAndreas Gohr 32678a6aeb1SAndreas Gohr // load stylesheets 3277aaa4c46Smartin.tschofen $head['link'][] = array('rel'=>'stylesheet', 'media'=>'all', 'type'=>'text/css', 328124af657SAndreas Gohr 'href'=>DOKU_BASE.'lib/exe/css.php?s=all&t='.$conf['template']); 3297bff22c0SAndreas Gohr $head['link'][] = array('rel'=>'stylesheet', 'media'=>'screen', 'type'=>'text/css', 330124af657SAndreas Gohr 'href'=>DOKU_BASE.'lib/exe/css.php?t='.$conf['template']); 3317bff22c0SAndreas Gohr $head['link'][] = array('rel'=>'stylesheet', 'media'=>'print', 'type'=>'text/css', 332124af657SAndreas Gohr 'href'=>DOKU_BASE.'lib/exe/css.php?s=print&t='.$conf['template']); 333bad31ae9SAndreas Gohr 33478a6aeb1SAndreas Gohr // load javascript 335041d1964SAndreas Gohr $js_edit = ($ACT=='edit' || $ACT=='preview' || $ACT=='recover' || $ACT=='wordblock' ) ? 1 : 0; 336bad31ae9SAndreas Gohr $js_write = ($INFO['writable']) ? 1 : 0; 3373df72098SAndreas Gohr if(defined('DOKU_MEDIAMANAGER')){ 3383df72098SAndreas Gohr $js_edit = 1; 3393df72098SAndreas Gohr $js_write = 0; 3403df72098SAndreas Gohr } 3413df72098SAndreas Gohr if(($js_edit && $js_write) || defined('DOKU_MEDIAMANAGER')){ 3427bff22c0SAndreas Gohr $script = "NS='".$INFO['namespace']."';"; 343c591aabeSAndreas Gohr if($conf['useacl'] && $_SERVER['REMOTE_USER']){ 344aeaccbf9SAndreas Gohr require_once(DOKU_INC.'inc/toolbar.php'); 3457bff22c0SAndreas Gohr $script .= "SIG='".toolbar_signature()."';"; 346c591aabeSAndreas Gohr } 3477bff22c0SAndreas Gohr $head['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', 3487bff22c0SAndreas Gohr '_data'=> $script); 349c591aabeSAndreas Gohr } 3507bff22c0SAndreas Gohr $head['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', '_data'=>'', 3517bff22c0SAndreas Gohr 'src'=>DOKU_BASE.'lib/exe/js.php?edit='.$js_edit.'&write='.$js_write); 3527bff22c0SAndreas Gohr 3537bff22c0SAndreas Gohr // trigger event here 354016b6153SAndreas Gohr trigger_event('TPL_METAHEADER_OUTPUT',$head,'_tpl_metaheaders_action',true); 35554e95700STom N Harris return true; 3567bff22c0SAndreas Gohr} 3577bff22c0SAndreas Gohr 3587bff22c0SAndreas Gohr/** 3597bff22c0SAndreas Gohr * prints the array build by tpl_metaheaders 3607bff22c0SAndreas Gohr * 3617bff22c0SAndreas Gohr * $data is an array of different header tags. Each tag can have multiple 3627bff22c0SAndreas Gohr * instances. Attributes are given as key value pairs. Values will be HTML 3637bff22c0SAndreas Gohr * encoded automatically so they should be provided as is in the $data array. 3647bff22c0SAndreas Gohr * 3657bff22c0SAndreas Gohr * For tags having a body attribute specify the the body data in the special 3661304d1dbSAndreas Gohr * attribute '_data'. This field will NOT BE ESCAPED automatically. 3677bff22c0SAndreas Gohr * 3687bff22c0SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 3697bff22c0SAndreas Gohr */ 3707bff22c0SAndreas Gohrfunction _tpl_metaheaders_action($data){ 3717bff22c0SAndreas Gohr foreach($data as $tag => $inst){ 3727bff22c0SAndreas Gohr foreach($inst as $attr){ 3737bff22c0SAndreas Gohr echo '<',$tag,' ',buildAttributes($attr); 3747bff22c0SAndreas Gohr if(isset($attr['_data'])){ 375e226efe1SAndreas Gohr if($tag == 'script' && $attr['_data']) 376e226efe1SAndreas Gohr $attr['_data'] = "<!--//--><![CDATA[//><!--\n". 377e226efe1SAndreas Gohr $attr['_data']. 378e226efe1SAndreas Gohr "\n//--><!]]>"; 379e226efe1SAndreas Gohr 3801304d1dbSAndreas Gohr echo '>',$attr['_data'],'</',$tag,'>'; 3817bff22c0SAndreas Gohr }else{ 3827bff22c0SAndreas Gohr echo '/>'; 3837bff22c0SAndreas Gohr } 3847bff22c0SAndreas Gohr echo "\n"; 3857bff22c0SAndreas Gohr } 3867bff22c0SAndreas Gohr } 3876b13307fSandi} 3886b13307fSandi 3896b13307fSandi/** 3906b13307fSandi * Print a link 3916b13307fSandi * 3925e163278SAndreas Gohr * Just builds a link. 3936b13307fSandi * 3946b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 3956b13307fSandi */ 3966b13307fSandifunction tpl_link($url,$name,$more=''){ 3975e163278SAndreas Gohr print '<a href="'.$url.'" '; 3986b13307fSandi if ($more) print ' '.$more; 3996b13307fSandi print ">$name</a>"; 40054e95700STom N Harris return true; 4016b13307fSandi} 4026b13307fSandi 4036b13307fSandi/** 40455efc227SAndreas Gohr * Prints a link to a WikiPage 40555efc227SAndreas Gohr * 40655efc227SAndreas Gohr * Wrapper around html_wikilink 40755efc227SAndreas Gohr * 40855efc227SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 40955efc227SAndreas Gohr */ 41055efc227SAndreas Gohrfunction tpl_pagelink($id,$name=NULL){ 41155efc227SAndreas Gohr print html_wikilink($id,$name); 41254e95700STom N Harris return true; 41355efc227SAndreas Gohr} 41455efc227SAndreas Gohr 41555efc227SAndreas Gohr/** 416a3ec5f4aSmatthiasgrimm * get the parent page 417a3ec5f4aSmatthiasgrimm * 418a3ec5f4aSmatthiasgrimm * Tries to find out which page is parent. 419a3ec5f4aSmatthiasgrimm * returns false if none is available 420a3ec5f4aSmatthiasgrimm * 421377f9e97SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 422a3ec5f4aSmatthiasgrimm */ 423377f9e97SAndreas Gohrfunction tpl_getparent($id){ 424a3ec5f4aSmatthiasgrimm global $conf; 425377f9e97SAndreas Gohr $parent = getNS($id).':'; 426377f9e97SAndreas Gohr resolve_pageid('',$parent,$exists); 427a197105eSmatthiasgrimm if($parent == $id) { 428a197105eSmatthiasgrimm $pos = strrpos (getNS($id),':'); 429a197105eSmatthiasgrimm $parent = substr($parent,0,$pos).':'; 430a197105eSmatthiasgrimm resolve_pageid('',$parent,$exists); 431377f9e97SAndreas Gohr if($parent == $id) return false; 432a197105eSmatthiasgrimm } 433377f9e97SAndreas Gohr return $parent; 434a3ec5f4aSmatthiasgrimm} 435a3ec5f4aSmatthiasgrimm 436a3ec5f4aSmatthiasgrimm/** 4376b13307fSandi * Print one of the buttons 4386b13307fSandi * 4396b13307fSandi * Available Buttons are 4406b13307fSandi * 441ee4c4a1bSAndreas Gohr * edit - edit/create/show/draft button 4426b13307fSandi * history - old revisions 4436b13307fSandi * recent - recent changes 4446b13307fSandi * login - login/logout button - if ACL enabled 445d449b912SDenis Simakov * profile - user profile button (if logged in) 4466b13307fSandi * index - The index 447c19fe9c0Sandi * admin - admin page - if enough rights 4486b13307fSandi * top - a back to top button 449a3ec5f4aSmatthiasgrimm * back - a back to parent button - if available 450bbd37938SAndreas Gohr * backlink - links to the list of backlinks 451d449b912SDenis Simakov * subscription- subscribe/unsubscribe button 4526b13307fSandi * 4536b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 454a3ec5f4aSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 4556b13307fSandi */ 4566b13307fSandifunction tpl_button($type){ 457b158d625SSteven Danz global $ACT; 4586b13307fSandi global $ID; 459d98d4540SBen Coburn global $REV; 460d67ca2c0Smatthiasgrimm global $NS; 461c19fe9c0Sandi global $INFO; 4626b13307fSandi global $conf; 463cd52f92dSchris global $auth; 4646b13307fSandi 46575e487e9SAndreas Gohr // check disabled actions and fix the badly named ones 46675e487e9SAndreas Gohr $ctype = $type; 46775e487e9SAndreas Gohr if($type == 'history') $ctype='revisions'; 46854e95700STom N Harris if(!actionOK($ctype)) return false; 469409d7af7SAndreas Gohr 4706b13307fSandi switch($type){ 4716b13307fSandi case 'edit': 472409d7af7SAndreas Gohr #most complicated type - we need to decide on current action 473409d7af7SAndreas Gohr if($ACT == 'show' || $ACT == 'search'){ 474409d7af7SAndreas Gohr if($INFO['writable']){ 475bb4866bdSchris if(!empty($INFO['draft'])){ 476409d7af7SAndreas Gohr echo html_btn('draft',$ID,'e',array('do' => 'draft'),'post'); 477409d7af7SAndreas Gohr }else{ 478409d7af7SAndreas Gohr if($INFO['exists']){ 479409d7af7SAndreas Gohr echo html_btn('edit',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 480409d7af7SAndreas Gohr }else{ 481409d7af7SAndreas Gohr echo html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 482409d7af7SAndreas Gohr } 483409d7af7SAndreas Gohr } 484409d7af7SAndreas Gohr }else{ 485409d7af7SAndreas Gohr if(!actionOK('source')) return false; //pseudo action 486409d7af7SAndreas Gohr echo html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post'); 487409d7af7SAndreas Gohr } 488409d7af7SAndreas Gohr }else{ 489409d7af7SAndreas Gohr echo html_btn('show',$ID,'v',array('do' => 'show')); 490409d7af7SAndreas Gohr } 49154e95700STom N Harris return true; 4926b13307fSandi case 'history': 4937aedde2eSGina Haeussge if(!actionOK('revisions')) 4947aedde2eSGina Haeussge return false; 4955bc81eb9SAnders Betnér print html_btn('revs',$ID,'o',array('do' => 'revisions')); 49654e95700STom N Harris return true; 4976b13307fSandi case 'recent': 4987aedde2eSGina Haeussge if(!actionOK('recent')) 4997aedde2eSGina Haeussge return false; 500e83cef14SGina Haeussge print html_btn('recent',$ID,'r',array('do' => 'recent')); 50154e95700STom N Harris return true; 5026b13307fSandi case 'index': 5037aedde2eSGina Haeussge if(!actionOK('index')) 5047aedde2eSGina Haeussge return false; 5055bc81eb9SAnders Betnér print html_btn('index',$ID,'x',array('do' => 'index')); 50654e95700STom N Harris return true; 507a3ec5f4aSmatthiasgrimm case 'back': 5086222040cSmatthiasgrimm if ($parent = tpl_getparent($ID)) { 5096222040cSmatthiasgrimm print html_btn('back',$parent,'b',array('do' => 'show')); 51054e95700STom N Harris return true; 511a3ec5f4aSmatthiasgrimm } 51254e95700STom N Harris return false; 5136b13307fSandi case 'top': 5146b13307fSandi print html_topbtn(); 51554e95700STom N Harris return true; 5166b13307fSandi case 'login': 5176957b2eaSAndreas Gohr if($conf['useacl'] && $auth){ 5186b13307fSandi if($_SERVER['REMOTE_USER']){ 519cc670e1bSMichael Klier print html_btn('logout',$ID,'',array('do' => 'logout', 'sectok' => getSecurityToken())); 5206b13307fSandi }else{ 521cc670e1bSMichael Klier print html_btn('login',$ID,'',array('do' => 'login', 'sectok' => getSecurityToken())); 5226b13307fSandi } 52354e95700STom N Harris return true; 5246b13307fSandi } 52554e95700STom N Harris return false; 526c19fe9c0Sandi case 'admin': 52754e95700STom N Harris if($INFO['ismanager']){ 5285bc81eb9SAnders Betnér print html_btn('admin',$ID,'',array('do' => 'admin')); 52954e95700STom N Harris return true; 53054e95700STom N Harris } 53154e95700STom N Harris return false; 532582c5bfeSAndreas Gohr case 'subscribe': 5331380fc45SAndreas Gohr case 'subscription': 5346957b2eaSAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 535b158d625SSteven Danz if($_SERVER['REMOTE_USER']){ 5361380fc45SAndreas Gohr if($INFO['subscribed']){ 5377aedde2eSGina Haeussge if(!actionOK('unsubscribe')) 5387aedde2eSGina Haeussge return false; 5391380fc45SAndreas Gohr print html_btn('unsubscribe',$ID,'',array('do' => 'unsubscribe',)); 540b158d625SSteven Danz } else { 5417aedde2eSGina Haeussge if(!actionOK('subscribe')) 5427aedde2eSGina Haeussge return false; 5431380fc45SAndreas Gohr print html_btn('subscribe',$ID,'',array('do' => 'subscribe',)); 544b158d625SSteven Danz } 545582c5bfeSAndreas Gohr if($type == 'subscribe') return true; 546582c5bfeSAndreas Gohr } 547582c5bfeSAndreas Gohr } 548582c5bfeSAndreas Gohr if($type == 'subscribe') return false; 549582c5bfeSAndreas Gohr // fall through for backward compatibility 550582c5bfeSAndreas Gohr case 'subscribens': 551582c5bfeSAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 552582c5bfeSAndreas Gohr if($_SERVER['REMOTE_USER']){ 55352b0dd67SGuy Brand if($INFO['subscribedns']){ 5547aedde2eSGina Haeussge if(!actionOK('unsubscribens')) 5557aedde2eSGina Haeussge return false; 55652b0dd67SGuy Brand print html_btn('unsubscribens',$ID,'',array('do' => 'unsubscribens',)); 55752b0dd67SGuy Brand } else { 5587aedde2eSGina Haeussge if(!actionOK('subscribens')) 5597aedde2eSGina Haeussge return false; 56052b0dd67SGuy Brand print html_btn('subscribens',$ID,'',array('do' => 'subscribens',)); 56152b0dd67SGuy Brand } 56254e95700STom N Harris return true; 563b158d625SSteven Danz } 564b158d625SSteven Danz } 56554e95700STom N Harris return false; 566f00151b4Schris case 'backlink': 5677aedde2eSGina Haeussge if(!actionOK('backlink')) 5687aedde2eSGina Haeussge return false; 569f00151b4Schris print html_btn('backlink',$ID,'',array('do' => 'backlink')); 57054e95700STom N Harris return true; 5718b06d178Schris case 'profile': 5726957b2eaSAndreas Gohr if($conf['useacl'] && $_SERVER['REMOTE_USER'] && $auth && 57336223ba7SAndreas Gohr $auth->canDo('Profile') && ($ACT!='profile')){ 5748b06d178Schris print html_btn('profile',$ID,'',array('do' => 'profile')); 57554e95700STom N Harris return true; 5768b06d178Schris } 57754e95700STom N Harris return false; 578c19fe9c0Sandi default: 579c19fe9c0Sandi print '[unknown button type]'; 58054e95700STom N Harris return true; 5816b13307fSandi } 5826b13307fSandi} 5836b13307fSandi 5846b13307fSandi/** 585ed630903Sandi * Like the action buttons but links 586ed630903Sandi * 587ed630903Sandi * Available links are 588ed630903Sandi * 589d449b912SDenis Simakov * edit - edit/create/show link 590ed630903Sandi * history - old revisions 591ed630903Sandi * recent - recent changes 592d449b912SDenis Simakov * login - login/logout link - if ACL enabled 593d449b912SDenis Simakov * profile - user profile link (if logged in) 594ed630903Sandi * index - The index 595ed630903Sandi * admin - admin page - if enough rights 596d449b912SDenis Simakov * top - a back to top link 597d449b912SDenis Simakov * back - a back to parent link - if available 598bbd37938SAndreas Gohr * backlink - links to the list of backlinks 599d449b912SDenis Simakov * subscribe/subscription - subscribe/unsubscribe link 600ed630903Sandi * 601ed630903Sandi * @author Andreas Gohr <andi@splitbrain.org> 602a3ec5f4aSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 603ed630903Sandi * @see tpl_button 604ed630903Sandi */ 605c97dfb07SAndreas Gohrfunction tpl_actionlink($type,$pre='',$suf='',$inner=''){ 606ed630903Sandi global $ID; 607ed630903Sandi global $INFO; 608ed630903Sandi global $REV; 609ed630903Sandi global $ACT; 610ed630903Sandi global $conf; 611ed630903Sandi global $lang; 612cd52f92dSchris global $auth; 613ed630903Sandi 61475e487e9SAndreas Gohr // check disabled actions and fix the badly named ones 61575e487e9SAndreas Gohr $ctype = $type; 61675e487e9SAndreas Gohr if($type == 'history') $ctype='revisions'; 61754e95700STom N Harris if(!actionOK($ctype)) return false; 618409d7af7SAndreas Gohr 619ed630903Sandi switch($type){ 620ed630903Sandi case 'edit': 621ed630903Sandi #most complicated type - we need to decide on current action 622ed630903Sandi if($ACT == 'show' || $ACT == 'search'){ 623ed630903Sandi if($INFO['writable']){ 624b8a111f5SMichael Klier if(!empty($INFO['draft'])) { 625b8a111f5SMichael Klier tpl_link(wl($ID,'do=draft'), 626c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_draft']).$suf, 627f6547e5dSAndreas Gohr 'class="action edit" accesskey="e" rel="nofollow"'); 628b8a111f5SMichael Klier } else { 629ed630903Sandi if($INFO['exists']){ 630ed630903Sandi tpl_link(wl($ID,'do=edit&rev='.$REV), 631c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_edit']).$suf, 632b7af031cSsu 'class="action edit" accesskey="e" rel="nofollow"'); 633ed630903Sandi }else{ 634ed630903Sandi tpl_link(wl($ID,'do=edit&rev='.$REV), 635c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_create']).$suf, 636b7af031cSsu 'class="action create" accesskey="e" rel="nofollow"'); 637ed630903Sandi } 638b8a111f5SMichael Klier } 639ed630903Sandi }else{ 640409d7af7SAndreas Gohr if(!actionOK('source')) return false; //pseudo action 641ed630903Sandi tpl_link(wl($ID,'do=edit&rev='.$REV), 642c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_source']).$suf, 643b7af031cSsu 'class="action source" accesskey="v" rel="nofollow"'); 644ed630903Sandi } 645ed630903Sandi }else{ 646ed630903Sandi tpl_link(wl($ID,'do=show'), 647c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_show']).$suf, 648b7af031cSsu 'class="action show" accesskey="v" rel="nofollow"'); 649ed630903Sandi } 650c059e1a6SAndreas Gohr return true; 651ed630903Sandi case 'history': 6527aedde2eSGina Haeussge if(!actionOK('revisions')) 6537aedde2eSGina Haeussge return false; 654c97dfb07SAndreas Gohr tpl_link(wl($ID,'do=revisions'), 655c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_revs']).$suf, 656c97dfb07SAndreas Gohr 'class="action revisions" accesskey="o" rel="nofollow"'); 657c059e1a6SAndreas Gohr return true; 658ed630903Sandi case 'recent': 6597aedde2eSGina Haeussge if(!actionOK('recent')) 6607aedde2eSGina Haeussge return false; 661ca6b84ccSGina Haeussge tpl_link(wl($ID,'do=recent'), 662c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_recent']).$suf, 663c97dfb07SAndreas Gohr 'class="action recent" accesskey="r" rel="nofollow"'); 664c059e1a6SAndreas Gohr return true; 665ed630903Sandi case 'index': 6667aedde2eSGina Haeussge if(!actionOK('index')) 6677aedde2eSGina Haeussge return false; 668c97dfb07SAndreas Gohr tpl_link(wl($ID,'do=index'), 669c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_index']).$suf, 670c97dfb07SAndreas Gohr 'class="action index" accesskey="x" rel="nofollow"'); 671c059e1a6SAndreas Gohr return true; 672ed630903Sandi case 'top': 673c97dfb07SAndreas Gohr print '<a href="#dokuwiki__top" class="action top" accesskey="x">'. 674c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_top']).$suf.'</a>'; 675c059e1a6SAndreas Gohr return true; 676a3ec5f4aSmatthiasgrimm case 'back': 677f7569b7bSAndreas Gohr if ($parent = tpl_getparent($ID)) { 678c97dfb07SAndreas Gohr tpl_link(wl($parent,'do=show'), 679c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_back']).$suf, 680c97dfb07SAndreas Gohr 'class="action back" accesskey="b" rel="nofollow"'); 681c059e1a6SAndreas Gohr return true; 682a3ec5f4aSmatthiasgrimm } 683c059e1a6SAndreas Gohr return false; 684ed630903Sandi case 'login': 6856957b2eaSAndreas Gohr if($conf['useacl'] && $auth){ 686ed630903Sandi if($_SERVER['REMOTE_USER']){ 687cc670e1bSMichael Klier tpl_link(wl($ID,'do=logout&sectok='.getSecurityToken()), 688c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_logout']).$suf, 689c97dfb07SAndreas Gohr 'class="action logout" rel="nofollow"'); 690ed630903Sandi }else{ 691cc670e1bSMichael Klier tpl_link(wl($ID,'do=login&sectok='.getSecurityToken()), 692c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_login']).$suf, 693c97dfb07SAndreas Gohr 'class="action login" rel="nofollow"'); 694ed630903Sandi } 695c059e1a6SAndreas Gohr return true; 696ed630903Sandi } 697c059e1a6SAndreas Gohr return false; 698ed630903Sandi case 'admin': 699f8cc712eSAndreas Gohr if($INFO['ismanager']){ 700c97dfb07SAndreas Gohr tpl_link(wl($ID,'do=admin'), 701c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_admin']).$suf, 702c97dfb07SAndreas Gohr 'class="action admin" rel="nofollow"'); 703c059e1a6SAndreas Gohr return true; 704c059e1a6SAndreas Gohr } 705c059e1a6SAndreas Gohr return false; 706f9eb5648Ssteven-danz case 'subscribe': 707075f000fSChristopher Arndt case 'subscription': 7086957b2eaSAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 709b158d625SSteven Danz if($_SERVER['REMOTE_USER']){ 710075f000fSChristopher Arndt if($INFO['subscribed']) { 7117aedde2eSGina Haeussge if(!actionOK('unsubscribe')) 7127aedde2eSGina Haeussge return false; 713c97dfb07SAndreas Gohr tpl_link(wl($ID,'do=unsubscribe'), 714c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_unsubscribe']).$suf, 715c97dfb07SAndreas Gohr 'class="action unsubscribe" rel="nofollow"'); 716b158d625SSteven Danz } else { 7177aedde2eSGina Haeussge if(!actionOK('subscribe')) 7187aedde2eSGina Haeussge return false; 719c97dfb07SAndreas Gohr tpl_link(wl($ID,'do=subscribe'), 720c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_subscribe']).$suf, 721c97dfb07SAndreas Gohr 'class="action subscribe" rel="nofollow"'); 722b158d625SSteven Danz } 723c059e1a6SAndreas Gohr return true; 724b158d625SSteven Danz } 725b158d625SSteven Danz } 726c059e1a6SAndreas Gohr return false; 727280f11b7SMichael Klier case 'subscribens': 728280f11b7SMichael Klier if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 729280f11b7SMichael Klier if($_SERVER['REMOTE_USER']){ 730280f11b7SMichael Klier if($INFO['subscribedns']) { 7317aedde2eSGina Haeussge if(!actionOK('unsubscribens')) 7327aedde2eSGina Haeussge return false; 733280f11b7SMichael Klier tpl_link(wl($ID,'do=unsubscribens'), 734280f11b7SMichael Klier $pre.(($inner)?$inner:$lang['btn_unsubscribens']).$suf, 735280f11b7SMichael Klier 'class="action unsubscribens" rel="nofollow"'); 736280f11b7SMichael Klier } else { 7377aedde2eSGina Haeussge if(!actionOK('subscribens')) 7387aedde2eSGina Haeussge return false; 739280f11b7SMichael Klier tpl_link(wl($ID,'do=subscribens'), 740280f11b7SMichael Klier $pre.(($inner)?$inner:$lang['btn_subscribens']).$suf, 741280f11b7SMichael Klier 'class="action subscribens" rel="nofollow"'); 742280f11b7SMichael Klier } 743280f11b7SMichael Klier return true; 744280f11b7SMichael Klier } 745280f11b7SMichael Klier } 746280f11b7SMichael Klier return false; 747f00151b4Schris case 'backlink': 7487aedde2eSGina Haeussge if(!actionOK('backlink')) 7497aedde2eSGina Haeussge return false; 750c97dfb07SAndreas Gohr tpl_link(wl($ID,'do=backlink'), 751c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_backlink']).$suf, 752c97dfb07SAndreas Gohr 'class="action backlink" rel="nofollow"'); 753c059e1a6SAndreas Gohr return true; 7548b06d178Schris case 'profile': 7556957b2eaSAndreas Gohr if($conf['useacl'] && $auth && $_SERVER['REMOTE_USER'] && 75636223ba7SAndreas Gohr $auth->canDo('Profile') && ($ACT!='profile')){ 757c97dfb07SAndreas Gohr tpl_link(wl($ID,'do=profile'), 758c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_profile']).$suf, 759c97dfb07SAndreas Gohr 'class="action profile" rel="nofollow"'); 760c059e1a6SAndreas Gohr return true; 7618b06d178Schris } 762c059e1a6SAndreas Gohr return false; 763ed630903Sandi default: 764ed630903Sandi print '[unknown link type]'; 765c059e1a6SAndreas Gohr return true; 766ed630903Sandi } 767ed630903Sandi} 768ed630903Sandi 769ed630903Sandi/** 7706b13307fSandi * Print the search form 7716b13307fSandi * 77272645b75SAndreas Gohr * If the first parameter is given a div with the ID 'qsearch_out' will 77372645b75SAndreas Gohr * be added which instructs the ajax pagequicksearch to kick in and place 77472645b75SAndreas Gohr * its output into this div. The second parameter controls the propritary 77572645b75SAndreas Gohr * attribute autocomplete. If set to false this attribute will be set with an 77672645b75SAndreas Gohr * value of "off" to instruct the browser to disable it's own built in 77772645b75SAndreas Gohr * autocompletion feature (MSIE and Firefox) 77872645b75SAndreas Gohr * 7796b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 7806b13307fSandi */ 78172645b75SAndreas Gohrfunction tpl_searchform($ajax=true,$autocomplete=true){ 7826b13307fSandi global $lang; 783c1e3b7d9Smatthiasgrimm global $ACT; 784c1e3b7d9Smatthiasgrimm 785670ff54eSchris // don't print the search form if search action has been disabled 78654e95700STom N Harris if (!actionOk('search')) return false; 787670ff54eSchris 7881dd0c202SAnika Henke print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search"><div class="no">'; 7896b13307fSandi print '<input type="hidden" name="do" value="search" />'; 790c1e3b7d9Smatthiasgrimm print '<input type="text" '; 791bad31ae9SAndreas Gohr if($ACT == 'search') print 'value="'.htmlspecialchars($_REQUEST['id']).'" '; 79272645b75SAndreas Gohr if(!$autocomplete) print 'autocomplete="off" '; 793818d04d3SAndreas Gohr print 'id="qsearch__in" accesskey="f" name="id" class="edit" title="[ALT+F]" />'; 79411ea018fSAndreas Gohr print '<input type="submit" value="'.$lang['btn_search'].'" class="button" title="'.$lang['btn_search'].'" />'; 79524a33b42SAndreas Gohr if($ajax) print '<div id="qsearch__out" class="ajax_qsearch JSpopup"></div>'; 7964beabca9SAnika Henke print '</div></form>'; 79754e95700STom N Harris return true; 7986b13307fSandi} 7996b13307fSandi 8006b13307fSandi/** 8016b13307fSandi * Print the breadcrumbs trace 8026b13307fSandi * 8036b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 8046b13307fSandi */ 80554e95700STom N Harrisfunction tpl_breadcrumbs($sep='»'){ 8066b13307fSandi global $lang; 8076b13307fSandi global $conf; 8086b13307fSandi 8096b13307fSandi //check if enabled 81054e95700STom N Harris if(!$conf['breadcrumbs']) return false; 8116b13307fSandi 8126b13307fSandi $crumbs = breadcrumbs(); //setup crumb trace 813265e3787Sandi 8142979a10bSKatriel Traum //reverse crumborder in right-to-left mode, add RLM character to fix heb/eng display mixups 8152979a10bSKatriel Traum if($lang['direction'] == 'rtl') { 8162979a10bSKatriel Traum $crumbs = array_reverse($crumbs,true); 8172979a10bSKatriel Traum $crumbs_sep = ' ‏<span class="bcsep">'.$sep.'</span>‏ '; 8182979a10bSKatriel Traum } else { 8192979a10bSKatriel Traum $crumbs_sep = ' <span class="bcsep">'.$sep.'</span> '; 8202979a10bSKatriel Traum } 821265e3787Sandi 82240eb54bbSjan //render crumbs, highlight the last one 8231b6f3a44SAndreas Gohr print '<span class="bchead">'.$lang['breadcrumb'].':</span>'; 82440eb54bbSjan $last = count($crumbs); 82540eb54bbSjan $i = 0; 826a77f5846Sjan foreach ($crumbs as $id => $name){ 82740eb54bbSjan $i++; 8282979a10bSKatriel Traum echo $crumbs_sep; 82992795d04Sandi if ($i == $last) print '<span class="curid">'; 830e26fd1eeSAndreas Gohr tpl_link(wl($id),hsc($name),'class="breadcrumbs" title="'.$id.'"'); 83192795d04Sandi if ($i == $last) print '</span>'; 8326b13307fSandi } 83354e95700STom N Harris return true; 8346b13307fSandi} 8356b13307fSandi 8366b13307fSandi/** 8371734437eSandi * Hierarchical breadcrumbs 8381734437eSandi * 83931e187f8SSean Coates * This code was suggested as replacement for the usual breadcrumbs. 8401734437eSandi * It only makes sense with a deep site structure. 8411734437eSandi * 8421734437eSandi * @author Andreas Gohr <andi@splitbrain.org> 8436bd812dfSNigel McNie * @author Nigel McNie <oracle.shinoda@gmail.com> 84431e187f8SSean Coates * @author Sean Coates <sean@caedmon.net> 845f46c9e83SAnika Henke * @author <fredrik@averpil.com> 8466bd812dfSNigel McNie * @todo May behave strangely in RTL languages 8471734437eSandi */ 848796bafb3SAndreas Gohrfunction tpl_youarehere($sep=' » '){ 8491734437eSandi global $conf; 8501734437eSandi global $ID; 8511734437eSandi global $lang; 8521734437eSandi 85331e187f8SSean Coates // check if enabled 85454e95700STom N Harris if(!$conf['youarehere']) return false; 8551734437eSandi 8561734437eSandi $parts = explode(':', $ID); 857796bafb3SAndreas Gohr $count = count($parts); 8581734437eSandi 8591b6f3a44SAndreas Gohr echo '<span class="bchead">'.$lang['youarehere'].': </span>'; 8601734437eSandi 8611734437eSandi // always print the startpage 862796bafb3SAndreas Gohr $title = p_get_first_heading($conf['start']); 863796bafb3SAndreas Gohr if(!$title) $title = $conf['start']; 864e26fd1eeSAndreas Gohr tpl_link(wl($conf['start']),hsc($title),'title="'.$conf['start'].'"'); 865796bafb3SAndreas Gohr 866796bafb3SAndreas Gohr // print intermediate namespace links 867796bafb3SAndreas Gohr $part = ''; 868796bafb3SAndreas Gohr for($i=0; $i<$count - 1; $i++){ 869796bafb3SAndreas Gohr $part .= $parts[$i].':'; 870796bafb3SAndreas Gohr $page = $part; 871796bafb3SAndreas Gohr resolve_pageid('',$page,$exists); 872796bafb3SAndreas Gohr if ($page == $conf['start']) continue; // Skip startpage 873796bafb3SAndreas Gohr 874796bafb3SAndreas Gohr // output 875796bafb3SAndreas Gohr echo $sep; 876796bafb3SAndreas Gohr if($exists){ 877796bafb3SAndreas Gohr $title = p_get_first_heading($page); 878796bafb3SAndreas Gohr if(!$title) $title = $parts[$i]; 879e26fd1eeSAndreas Gohr tpl_link(wl($page),hsc($title),'title="'.$page.'"'); 88031e187f8SSean Coates }else{ 88178cbfcb6SAndreas Gohr tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2" rel="nofollow"'); 88231e187f8SSean Coates } 88331e187f8SSean Coates } 8841734437eSandi 885796bafb3SAndreas Gohr // print current page, skipping start page, skipping for namespace index 886d98d4540SBen Coburn if(isset($page) && $page==$part.$parts[$i]) return; 887796bafb3SAndreas Gohr $page = $part.$parts[$i]; 888796bafb3SAndreas Gohr if($page == $conf['start']) return; 889796bafb3SAndreas Gohr echo $sep; 890103c256aSChris Smith if(page_exists($page)){ 891796bafb3SAndreas Gohr $title = p_get_first_heading($page); 892796bafb3SAndreas Gohr if(!$title) $title = $parts[$i]; 893e26fd1eeSAndreas Gohr tpl_link(wl($page),hsc($title),'title="'.$page.'"'); 89431e187f8SSean Coates }else{ 89578cbfcb6SAndreas Gohr tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2" rel="nofollow"'); 8961734437eSandi } 89754e95700STom N Harris return true; 8981734437eSandi} 8991734437eSandi 9001734437eSandi/** 9016b13307fSandi * Print info if the user is logged in 902a2488c3cSMatthias Grimm * and show full name in that case 9036b13307fSandi * 9046b13307fSandi * Could be enhanced with a profile link in future? 9056b13307fSandi * 9066b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 9076b13307fSandi */ 9086b13307fSandifunction tpl_userinfo(){ 9096b13307fSandi global $lang; 9103e63b73bSMichael Klier global $INFO; 91154e95700STom N Harris if($_SERVER['REMOTE_USER']){ 9123e63b73bSMichael Klier print $lang['loggedinas'].': '.$INFO['userinfo']['name'].' ('.$_SERVER['REMOTE_USER'].')'; 91354e95700STom N Harris return true; 91454e95700STom N Harris } 91554e95700STom N Harris return false; 9166b13307fSandi} 9176b13307fSandi 9186b13307fSandi/** 9196b13307fSandi * Print some info about the current page 9206b13307fSandi * 9216b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 9226b13307fSandi */ 9234b0d3916SAndreas Gohrfunction tpl_pageinfo($ret=false){ 9246b13307fSandi global $conf; 9256b13307fSandi global $lang; 9266b13307fSandi global $INFO; 9276b13307fSandi global $REV; 928c6e92a3cSDavid Lorentsen global $ID; 929c6e92a3cSDavid Lorentsen 930c6e92a3cSDavid Lorentsen // return if we are not allowed to view the page 9314b0d3916SAndreas Gohr if (!auth_quickaclcheck($ID)) { return false; } 9326b13307fSandi 9336b13307fSandi // prepare date and path 9346b13307fSandi $fn = $INFO['filepath']; 9356b13307fSandi if(!$conf['fullpath']){ 9366b13307fSandi if($REV){ 93750fbebceSGina Haeussge $fn = str_replace(fullpath($conf['olddir']).'/','',$fn); 9386b13307fSandi }else{ 93950fbebceSGina Haeussge $fn = str_replace(fullpath($conf['datadir']).'/','',$fn); 9406b13307fSandi } 9416b13307fSandi } 942bee6dc82Sandi $fn = utf8_decodeFN($fn); 943e656dcd4SAndreas Gohr $date = strftime($conf['dformat'],$INFO['lastmod']); 9446b13307fSandi 945faecdfdfSAndreas Gohr // print it 946faecdfdfSAndreas Gohr if($INFO['exists']){ 9474b0d3916SAndreas Gohr $out = ''; 9484b0d3916SAndreas Gohr $out .= $fn; 9494b0d3916SAndreas Gohr $out .= ' · '; 9504b0d3916SAndreas Gohr $out .= $lang['lastmod']; 9514b0d3916SAndreas Gohr $out .= ': '; 9524b0d3916SAndreas Gohr $out .= $date; 9536b13307fSandi if($INFO['editor']){ 9544b0d3916SAndreas Gohr $out .= ' '.$lang['by'].' '; 955dc58b6f4SAndy Webber $out .= editorinfo($INFO['editor']); 9565aa52fafSBen Coburn }else{ 9574b0d3916SAndreas Gohr $out .= ' ('.$lang['external_edit'].')'; 9586b13307fSandi } 9596b13307fSandi if($INFO['locked']){ 9604b0d3916SAndreas Gohr $out .= ' · '; 9614b0d3916SAndreas Gohr $out .= $lang['lockedby']; 9624b0d3916SAndreas Gohr $out .= ': '; 963dc58b6f4SAndy Webber $out .= editorinfo($INFO['locked']); 9646b13307fSandi } 9654b0d3916SAndreas Gohr if($ret){ 9664b0d3916SAndreas Gohr return $out; 9674b0d3916SAndreas Gohr }else{ 9684b0d3916SAndreas Gohr echo $out; 96954e95700STom N Harris return true; 9706b13307fSandi } 9714b0d3916SAndreas Gohr } 97254e95700STom N Harris return false; 9736b13307fSandi} 9746b13307fSandi 975820fa24bSandi/** 976a6598f23SBen Coburn * Prints or returns the name of the given page (current one if none given). 97787c434ceSAndreas Gohr * 97887c434ceSAndreas Gohr * If useheading is enabled this will use the first headline else 979a6598f23SBen Coburn * the given ID is used. 98087c434ceSAndreas Gohr * 98187c434ceSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 98287c434ceSAndreas Gohr */ 983a6598f23SBen Coburnfunction tpl_pagetitle($id=null, $ret=false){ 98487c434ceSAndreas Gohr global $conf; 98587c434ceSAndreas Gohr if(is_null($id)){ 98687c434ceSAndreas Gohr global $ID; 98787c434ceSAndreas Gohr $id = $ID; 98887c434ceSAndreas Gohr } 98987c434ceSAndreas Gohr 99087c434ceSAndreas Gohr $name = $id; 99187c434ceSAndreas Gohr if ($conf['useheading']) { 99287c434ceSAndreas Gohr $title = p_get_first_heading($id); 99387c434ceSAndreas Gohr if ($title) $name = $title; 99487c434ceSAndreas Gohr } 995a6598f23SBen Coburn 996a6598f23SBen Coburn if ($ret) { 997a6598f23SBen Coburn return hsc($name); 998a6598f23SBen Coburn } else { 99987c434ceSAndreas Gohr print hsc($name); 100054e95700STom N Harris return true; 100187c434ceSAndreas Gohr } 1002a6598f23SBen Coburn} 1003340756e4Sandi 100455efc227SAndreas Gohr/** 100555efc227SAndreas Gohr * Returns the requested EXIF/IPTC tag from the current image 100655efc227SAndreas Gohr * 100755efc227SAndreas Gohr * If $tags is an array all given tags are tried until a 100855efc227SAndreas Gohr * value is found. If no value is found $alt is returned. 100955efc227SAndreas Gohr * 101055efc227SAndreas Gohr * Which texts are known is defined in the functions _exifTagNames 101155efc227SAndreas Gohr * and _iptcTagNames() in inc/jpeg.php (You need to prepend IPTC 101255efc227SAndreas Gohr * to the names of the latter one) 101355efc227SAndreas Gohr * 10143df72098SAndreas Gohr * Only allowed in: detail.php 101555efc227SAndreas Gohr * 101655efc227SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 101755efc227SAndreas Gohr */ 10183df72098SAndreas Gohrfunction tpl_img_getTag($tags,$alt='',$src=null){ 101955efc227SAndreas Gohr // Init Exif Reader 102055efc227SAndreas Gohr global $SRC; 10213df72098SAndreas Gohr 10223df72098SAndreas Gohr if(is_null($src)) $src = $SRC; 10233df72098SAndreas Gohr 102455efc227SAndreas Gohr static $meta = null; 10253df72098SAndreas Gohr if(is_null($meta)) $meta = new JpegMeta($src); 102655efc227SAndreas Gohr if($meta === false) return $alt; 102755efc227SAndreas Gohr $info = $meta->getField($tags); 102855efc227SAndreas Gohr if($info == false) return $alt; 102955efc227SAndreas Gohr return $info; 103055efc227SAndreas Gohr} 103155efc227SAndreas Gohr 103255efc227SAndreas Gohr/** 103355efc227SAndreas Gohr * Prints the image with a link to the full sized version 103455efc227SAndreas Gohr * 103555efc227SAndreas Gohr * Only allowed in: detail.php 103655efc227SAndreas Gohr */ 1037f8925855Sjoe.lappfunction tpl_img($maxwidth=0,$maxheight=0){ 103855efc227SAndreas Gohr global $IMG; 103955efc227SAndreas Gohr $w = tpl_img_getTag('File.Width'); 104055efc227SAndreas Gohr $h = tpl_img_getTag('File.Height'); 104155efc227SAndreas Gohr 104255efc227SAndreas Gohr //resize to given max values 104323a34783SAndreas Gohr $ratio = 1; 104423a34783SAndreas Gohr if($w >= $h){ 1045f8925855Sjoe.lapp if($maxwidth && $w >= $maxwidth){ 104655efc227SAndreas Gohr $ratio = $maxwidth/$w; 1047f8925855Sjoe.lapp }elseif($maxheight && $h > $maxheight){ 104855efc227SAndreas Gohr $ratio = $maxheight/$h; 104955efc227SAndreas Gohr } 105055efc227SAndreas Gohr }else{ 1051f8925855Sjoe.lapp if($maxheight && $h >= $maxheight){ 105255efc227SAndreas Gohr $ratio = $maxheight/$h; 1053f8925855Sjoe.lapp }elseif($maxwidth && $w > $maxwidth){ 105455efc227SAndreas Gohr $ratio = $maxwidth/$w; 105555efc227SAndreas Gohr } 105655efc227SAndreas Gohr } 105755efc227SAndreas Gohr if($ratio){ 105855efc227SAndreas Gohr $w = floor($ratio*$w); 105955efc227SAndreas Gohr $h = floor($ratio*$h); 106055efc227SAndreas Gohr } 106155efc227SAndreas Gohr 10626de3759aSAndreas Gohr //prepare URLs 10636de3759aSAndreas Gohr $url=ml($IMG,array('cache'=>$_REQUEST['cache'])); 10646de3759aSAndreas Gohr $src=ml($IMG,array('cache'=>$_REQUEST['cache'],'w'=>$w,'h'=>$h)); 106555efc227SAndreas Gohr 10662684e50aSAndreas Gohr //prepare attributes 106755efc227SAndreas Gohr $alt=tpl_img_getTag('Simple.Title'); 10682684e50aSAndreas Gohr $p = array(); 10692684e50aSAndreas Gohr if($w) $p['width'] = $w; 10702684e50aSAndreas Gohr if($h) $p['height'] = $h; 10712684e50aSAndreas Gohr $p['class'] = 'img_detail'; 10722684e50aSAndreas Gohr if($alt){ 10732684e50aSAndreas Gohr $p['alt'] = $alt; 10742684e50aSAndreas Gohr $p['title'] = $alt; 10752684e50aSAndreas Gohr }else{ 10762684e50aSAndreas Gohr $p['alt'] = ''; 10772684e50aSAndreas Gohr } 10782684e50aSAndreas Gohr $p = buildAttributes($p); 107955efc227SAndreas Gohr 108055efc227SAndreas Gohr print '<a href="'.$url.'">'; 10816de3759aSAndreas Gohr print '<img src="'.$src.'" '.$p.'/>'; 108255efc227SAndreas Gohr print '</a>'; 108354e95700STom N Harris return true; 108455efc227SAndreas Gohr} 108555efc227SAndreas Gohr 10867367b368SAndreas Gohr/** 10877367b368SAndreas Gohr * This function inserts a 1x1 pixel gif which in reality 10887367b368SAndreas Gohr * is the inexer function. 10897367b368SAndreas Gohr * 10907367b368SAndreas Gohr * Should be called somewhere at the very end of the main.php 10917367b368SAndreas Gohr * template 10927367b368SAndreas Gohr */ 10937367b368SAndreas Gohrfunction tpl_indexerWebBug(){ 10947367b368SAndreas Gohr global $ID; 10951dad36f5SAndreas Gohr global $INFO; 109654e95700STom N Harris if(!$INFO['exists']) return false; 10971dad36f5SAndreas Gohr 109854e95700STom N Harris if(isHiddenPage($ID)) return false; //no need to index hidden pages 10990dc92c6fSAndreas Gohr 11007367b368SAndreas Gohr $p = array(); 1101b6c6979fSAndreas Gohr $p['src'] = DOKU_BASE.'lib/exe/indexer.php?id='.rawurlencode($ID). 1102e68c51baSAndreas Gohr '&'.time(); 11037367b368SAndreas Gohr $p['width'] = 1; 11047367b368SAndreas Gohr $p['height'] = 1; 11057367b368SAndreas Gohr $p['alt'] = ''; 11067367b368SAndreas Gohr $att = buildAttributes($p); 11077367b368SAndreas Gohr print "<img $att />"; 110854e95700STom N Harris return true; 11097367b368SAndreas Gohr} 11107367b368SAndreas Gohr 111178d4e784SEsther Brunner// configuration methods 111278d4e784SEsther Brunner/** 111378d4e784SEsther Brunner * tpl_getConf($id) 111478d4e784SEsther Brunner * 111578d4e784SEsther Brunner * use this function to access template configuration variables 111678d4e784SEsther Brunner */ 111778d4e784SEsther Brunnerfunction tpl_getConf($id){ 111878d4e784SEsther Brunner global $conf; 111978d4e784SEsther Brunner global $tpl_configloaded; 112078d4e784SEsther Brunner 112178d4e784SEsther Brunner $tpl = $conf['template']; 112278d4e784SEsther Brunner 112378d4e784SEsther Brunner if (!$tpl_configloaded){ 112478d4e784SEsther Brunner $tconf = tpl_loadConfig(); 112578d4e784SEsther Brunner if ($tconf !== false){ 112678d4e784SEsther Brunner foreach ($tconf as $key => $value){ 112778d4e784SEsther Brunner if (isset($conf['tpl'][$tpl][$key])) continue; 112878d4e784SEsther Brunner $conf['tpl'][$tpl][$key] = $value; 112978d4e784SEsther Brunner } 113078d4e784SEsther Brunner $tpl_configloaded = true; 113178d4e784SEsther Brunner } 113278d4e784SEsther Brunner } 113378d4e784SEsther Brunner 113478d4e784SEsther Brunner return $conf['tpl'][$tpl][$id]; 113578d4e784SEsther Brunner} 113678d4e784SEsther Brunner 113778d4e784SEsther Brunner/** 113878d4e784SEsther Brunner * tpl_loadConfig() 113978d4e784SEsther Brunner * reads all template configuration variables 114078d4e784SEsther Brunner * this function is automatically called by tpl_getConf() 114178d4e784SEsther Brunner */ 114278d4e784SEsther Brunnerfunction tpl_loadConfig(){ 114378d4e784SEsther Brunner 114478d4e784SEsther Brunner $file = DOKU_TPLINC.'/conf/default.php'; 114578d4e784SEsther Brunner $conf = array(); 114678d4e784SEsther Brunner 114778d4e784SEsther Brunner if (!@file_exists($file)) return false; 114878d4e784SEsther Brunner 114978d4e784SEsther Brunner // load default config file 115078d4e784SEsther Brunner include($file); 115178d4e784SEsther Brunner 115278d4e784SEsther Brunner return $conf; 115378d4e784SEsther Brunner} 115478d4e784SEsther Brunner 11553df72098SAndreas Gohr/** 11563df72098SAndreas Gohr * prints the "main content" in the mediamanger popup 11573df72098SAndreas Gohr * 11583df72098SAndreas Gohr * Depending on the user's actions this may be a list of 11593df72098SAndreas Gohr * files in a namespace, the meta editing dialog or 11603df72098SAndreas Gohr * a message of referencing pages 11613df72098SAndreas Gohr * 11623df72098SAndreas Gohr * Only allowed in mediamanager.php 11633df72098SAndreas Gohr * 11643df72098SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 11653df72098SAndreas Gohr */ 11663df72098SAndreas Gohrfunction tpl_mediaContent(){ 11673df72098SAndreas Gohr global $IMG; 11683df72098SAndreas Gohr global $AUTH; 11693df72098SAndreas Gohr global $INUSE; 11703df72098SAndreas Gohr global $NS; 11713df72098SAndreas Gohr global $JUMPTO; 11723df72098SAndreas Gohr 11733df72098SAndreas Gohr ptln('<div id="media__content">'); 11743df72098SAndreas Gohr if($_REQUEST['edit']){ 11753df72098SAndreas Gohr media_metaform($IMG,$AUTH); 11767b877f51SAndreas Gohr }elseif(is_array($INUSE)){ 11773df72098SAndreas Gohr media_filesinuse($INUSE,$IMG); 11783df72098SAndreas Gohr }else{ 11793df72098SAndreas Gohr media_filelist($NS,$AUTH,$JUMPTO); 11803df72098SAndreas Gohr } 11813df72098SAndreas Gohr ptln('</div>'); 11823df72098SAndreas Gohr} 11833df72098SAndreas Gohr 11843df72098SAndreas Gohr/** 11853df72098SAndreas Gohr * prints the namespace tree in the mediamanger popup 11863df72098SAndreas Gohr * 11873df72098SAndreas Gohr * Only allowed in mediamanager.php 11883df72098SAndreas Gohr * 11893df72098SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 11903df72098SAndreas Gohr */ 11913df72098SAndreas Gohrfunction tpl_mediaTree(){ 11923df72098SAndreas Gohr global $NS; 11933df72098SAndreas Gohr 11943df72098SAndreas Gohr ptln('<div id="media__tree">'); 11953df72098SAndreas Gohr media_nstree($NS); 11963df72098SAndreas Gohr ptln('</div>'); 11973df72098SAndreas Gohr} 11983df72098SAndreas Gohr 1199a00de5b5SAndreas Gohr 1200a00de5b5SAndreas Gohr/** 1201a00de5b5SAndreas Gohr * Print a dropdown menu with all DokuWiki actions 1202a00de5b5SAndreas Gohr * 1203a00de5b5SAndreas Gohr * Note: this will not use any pretty URLs 1204a00de5b5SAndreas Gohr * 1205a00de5b5SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1206a00de5b5SAndreas Gohr */ 1207a00de5b5SAndreas Gohrfunction tpl_actiondropdown($empty='',$button='>'){ 1208a00de5b5SAndreas Gohr global $ID; 1209a00de5b5SAndreas Gohr global $INFO; 1210a00de5b5SAndreas Gohr global $REV; 1211a00de5b5SAndreas Gohr global $ACT; 1212a00de5b5SAndreas Gohr global $conf; 1213a00de5b5SAndreas Gohr global $lang; 1214a00de5b5SAndreas Gohr global $auth; 1215a00de5b5SAndreas Gohr 1216a00de5b5SAndreas Gohr 1217a00de5b5SAndreas Gohr echo '<form method="post" accept-charset="utf-8">'; #FIXME action 1218a00de5b5SAndreas Gohr echo '<input type="hidden" name="id" value="'.$ID.'" />'; 1219a00de5b5SAndreas Gohr if($REV) echo '<input type="hidden" name="rev" value="'.$REV.'" />'; 1220a00de5b5SAndreas Gohr echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'; 1221a00de5b5SAndreas Gohr 1222a00de5b5SAndreas Gohr echo '<select name="do" id="action__selector" class="edit">'; 1223a00de5b5SAndreas Gohr echo '<option value="">'.$empty.'</option>'; 1224a00de5b5SAndreas Gohr 1225a00de5b5SAndreas Gohr echo '<optgroup label=" — ">'; 1226a00de5b5SAndreas Gohr // 'edit' - most complicated type, we need to decide on current action 1227a00de5b5SAndreas Gohr if($ACT == 'show' || $ACT == 'search'){ 1228a00de5b5SAndreas Gohr if($INFO['writable']){ 1229a00de5b5SAndreas Gohr if(!empty($INFO['draft'])) { 1230a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_draft'].'</option>'; 1231a00de5b5SAndreas Gohr } else { 1232a00de5b5SAndreas Gohr if($INFO['exists']){ 1233a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_edit'].'</option>'; 1234a00de5b5SAndreas Gohr }else{ 1235a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_create'].'</option>'; 1236a00de5b5SAndreas Gohr } 1237a00de5b5SAndreas Gohr } 1238a00de5b5SAndreas Gohr }else if(actionOK('source')) { //pseudo action 1239a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_source'].'</option>'; 1240a00de5b5SAndreas Gohr } 1241a00de5b5SAndreas Gohr }else{ 1242a00de5b5SAndreas Gohr echo '<option value="show">'.$lang['btn_show'].'</option>'; 1243a00de5b5SAndreas Gohr } 1244a00de5b5SAndreas Gohr 1245a00de5b5SAndreas Gohr echo '<option value="revisions">'.$lang['btn_revs'].'</option>'; 1246a00de5b5SAndreas Gohr echo '<option value="backlink">'.$lang['btn_backlink'].'</option>'; 1247a00de5b5SAndreas Gohr echo '</optgroup>'; 1248a00de5b5SAndreas Gohr 1249a00de5b5SAndreas Gohr echo '<optgroup label=" — ">'; 1250a00de5b5SAndreas Gohr echo '<option value="recent">'.$lang['btn_recent'].'</option>'; 1251a00de5b5SAndreas Gohr echo '<option value="index">'.$lang['btn_index'].'</option>'; 1252a00de5b5SAndreas Gohr echo '</optgroup>'; 1253a00de5b5SAndreas Gohr 1254a00de5b5SAndreas Gohr echo '<optgroup label=" — ">'; 1255a00de5b5SAndreas Gohr if($conf['useacl'] && $auth){ 1256a00de5b5SAndreas Gohr if($_SERVER['REMOTE_USER']){ 1257a00de5b5SAndreas Gohr echo '<option value="logout">'.$lang['btn_logout'].'</option>'; 1258a00de5b5SAndreas Gohr }else{ 1259a00de5b5SAndreas Gohr echo '<option value="login">'.$lang['btn_login'].'</option>'; 1260a00de5b5SAndreas Gohr } 1261a00de5b5SAndreas Gohr } 1262a00de5b5SAndreas Gohr 1263a00de5b5SAndreas Gohr if($conf['useacl'] && $auth && $_SERVER['REMOTE_USER'] && 1264a00de5b5SAndreas Gohr $auth->canDo('Profile') && ($ACT!='profile')){ 1265a00de5b5SAndreas Gohr echo '<option value="profile">'.$lang['btn_profile'].'</option>'; 1266a00de5b5SAndreas Gohr } 1267a00de5b5SAndreas Gohr 1268a00de5b5SAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 1269a00de5b5SAndreas Gohr if($_SERVER['REMOTE_USER']){ 1270a00de5b5SAndreas Gohr if($INFO['subscribed']) { 1271a00de5b5SAndreas Gohr echo '<option value="unsubscribe">'.$lang['btn_unsubscribe'].'</option>'; 1272a00de5b5SAndreas Gohr } else { 1273a00de5b5SAndreas Gohr echo '<option value="subscribe">'.$lang['btn_subscribe'].'</option>'; 1274a00de5b5SAndreas Gohr } 1275a00de5b5SAndreas Gohr } 1276a00de5b5SAndreas Gohr } 1277a00de5b5SAndreas Gohr 1278a00de5b5SAndreas Gohr if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers'] == 1){ 1279a00de5b5SAndreas Gohr if($_SERVER['REMOTE_USER']){ 1280a00de5b5SAndreas Gohr if($INFO['subscribedns']) { 1281a00de5b5SAndreas Gohr echo '<option value="unsubscribens">'.$lang['btn_unsubscribens'].'</option>'; 1282a00de5b5SAndreas Gohr } else { 1283a00de5b5SAndreas Gohr echo '<option value="subscribens">'.$lang['btn_subscribens'].'</option>'; 1284a00de5b5SAndreas Gohr } 1285a00de5b5SAndreas Gohr } 1286a00de5b5SAndreas Gohr } 1287a00de5b5SAndreas Gohr 1288a00de5b5SAndreas Gohr if($INFO['ismanager']){ 1289a00de5b5SAndreas Gohr echo '<option value="admin">'.$lang['btn_admin'].'</option>'; 1290a00de5b5SAndreas Gohr } 1291a00de5b5SAndreas Gohr echo '</optgroup>'; 1292a00de5b5SAndreas Gohr 1293a00de5b5SAndreas Gohr echo '</select>'; 1294a00de5b5SAndreas Gohr echo '<input type="submit" value="'.$button.'" id="action__selectorbtn" />'; 1295a00de5b5SAndreas Gohr echo '</form>'; 1296a00de5b5SAndreas Gohr} 1297a00de5b5SAndreas Gohr 1298066fee30SAndreas Gohr/** 1299066fee30SAndreas Gohr * Print a informational line about the used license 1300066fee30SAndreas Gohr * 1301066fee30SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1302066fee30SAndreas Gohr * @param string $img - print image? (|button|badge) 1303066fee30SAndreas Gohr * @param bool $return - when true don't print, but return HTML 1304066fee30SAndreas Gohr */ 1305066fee30SAndreas Gohrfunction tpl_license($img='badge',$return=false){ 1306066fee30SAndreas Gohr global $license; 1307066fee30SAndreas Gohr global $conf; 1308066fee30SAndreas Gohr global $lang; 1309066fee30SAndreas Gohr if(!$conf['license']) return ''; 1310066fee30SAndreas Gohr if(!is_array($license[$conf['license']])) return ''; 1311066fee30SAndreas Gohr $lic = $license[$conf['license']]; 1312066fee30SAndreas Gohr 1313066fee30SAndreas Gohr $out = '<p class="license">'; 1314066fee30SAndreas Gohr if($img){ 1315066fee30SAndreas Gohr $src = license_img($img); 1316066fee30SAndreas Gohr if($src){ 1317066fee30SAndreas Gohr $out .= '<a href="'.$lic['url'].'" rel="license"'; 1318066fee30SAndreas Gohr if($conf['target']['external']) $out .= ' target="'.$conf['target']['external'].'"'; 1319066fee30SAndreas Gohr $out .= '><img src="'.DOKU_BASE.$src.'" class="lic'.$button.'" alt="'.$lic['name'].'" align="left" /></a>'; 1320066fee30SAndreas Gohr } 1321066fee30SAndreas Gohr } 1322066fee30SAndreas Gohr $out .= $lang['license']; 1323066fee30SAndreas Gohr $out .= '<a href="'.$lic['url'].'" rel="license" class="urlextern"'; 1324066fee30SAndreas Gohr if($conf['target']['external']) $out .= ' target="'.$conf['target']['external'].'"'; 1325066fee30SAndreas Gohr $out .= '> '.$lic['name'].'</a>'; 1326066fee30SAndreas Gohr $out .= '</p>'; 1327066fee30SAndreas Gohr 1328066fee30SAndreas Gohr if($return) return $out; 1329066fee30SAndreas Gohr echo $out; 1330066fee30SAndreas Gohr} 1331066fee30SAndreas Gohr 1332b8595a66SAndreas Gohr//Setup VIM: ex: et ts=4 enc=utf-8 : 1333a00de5b5SAndreas Gohr 1334