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': 83c66972f2SAdrian Lang $first = isset($_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; 1295b75cd1fSAdrian Lang case 'subscribe': 1305b75cd1fSAdrian Lang tpl_subscribe(); 1315b75cd1fSAdrian Lang break; 1326b13307fSandi default: 13324bb549bSchris $evt = new Doku_Event('TPL_ACT_UNKNOWN',$ACT); 13424bb549bSchris if ($evt->advise_before()) 135ea67f144Sandi msg("Failed to handle command: ".hsc($ACT),-1); 13624bb549bSchris $evt->advise_after(); 13724bb549bSchris unset($evt); 13854e95700STom N Harris return false; 1396b13307fSandi } 14054e95700STom N Harris return true; 1416b13307fSandi} 1426b13307fSandi 143c19fe9c0Sandi/** 144b8595a66SAndreas Gohr * Places the TOC where the function is called 145b8595a66SAndreas Gohr * 146b8595a66SAndreas Gohr * If you use this you most probably want to call tpl_content with 147b8595a66SAndreas Gohr * a false argument 148b8595a66SAndreas Gohr * 149b8595a66SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 150b8595a66SAndreas Gohr */ 151b8595a66SAndreas Gohrfunction tpl_toc($return=false){ 152b8595a66SAndreas Gohr global $TOC; 153b8595a66SAndreas Gohr global $ACT; 154b8595a66SAndreas Gohr global $ID; 155b8595a66SAndreas Gohr global $REV; 156b8595a66SAndreas Gohr global $INFO; 157851f2e89SAnika Henke global $conf; 158b8595a66SAndreas Gohr $toc = array(); 159b8595a66SAndreas Gohr 160b8595a66SAndreas Gohr if(is_array($TOC)){ 161b8595a66SAndreas Gohr // if a TOC was prepared in global scope, always use it 162b8595a66SAndreas Gohr $toc = $TOC; 1633c86d7c9SAndreas Gohr }elseif(($ACT == 'show' || substr($ACT,0,6) == 'export') && !$REV && $INFO['exists']){ 164b8595a66SAndreas Gohr // get TOC from metadata, render if neccessary 165b8595a66SAndreas Gohr $meta = p_get_metadata($ID, false, true); 166b8595a66SAndreas Gohr if(isset($meta['internal']['toc'])){ 167b8595a66SAndreas Gohr $tocok = $meta['internal']['toc']; 168b8595a66SAndreas Gohr }else{ 1692bb0d541Schris $tocok = true; 170b8595a66SAndreas Gohr } 171b8595a66SAndreas Gohr $toc = $meta['description']['tableofcontents']; 172851f2e89SAnika Henke if(!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']){ 173b8595a66SAndreas Gohr $toc = array(); 174b8595a66SAndreas Gohr } 175b8595a66SAndreas Gohr }elseif($ACT == 'admin'){ 176b8595a66SAndreas Gohr // try to load admin plugin TOC FIXME: duplicates code from tpl_admin 177b8595a66SAndreas Gohr $plugin = null; 178b8595a66SAndreas Gohr if (!empty($_REQUEST['page'])) { 179b8595a66SAndreas Gohr $pluginlist = plugin_list('admin'); 180b8595a66SAndreas Gohr if (in_array($_REQUEST['page'], $pluginlist)) { 181b8595a66SAndreas Gohr // attempt to load the plugin 182b8595a66SAndreas Gohr $plugin =& plugin_load('admin',$_REQUEST['page']); 183b8595a66SAndreas Gohr } 184b8595a66SAndreas Gohr } 185b8595a66SAndreas Gohr if ( ($plugin !== null) && 186b8595a66SAndreas Gohr (!$plugin->forAdminOnly() || $INFO['isadmin']) ){ 187b8595a66SAndreas Gohr $toc = $plugin->getTOC(); 188b8595a66SAndreas Gohr $TOC = $toc; // avoid later rebuild 189b8595a66SAndreas Gohr } 190b8595a66SAndreas Gohr } 191b8595a66SAndreas Gohr 1927dee3468SGina Haeussge trigger_event('TPL_TOC_RENDER', $toc, NULL, false); 193b8595a66SAndreas Gohr $html = html_TOC($toc); 194b8595a66SAndreas Gohr if($return) return $html; 195b8595a66SAndreas Gohr echo $html; 196b8595a66SAndreas Gohr} 197b8595a66SAndreas Gohr 198b8595a66SAndreas Gohr/** 199c19fe9c0Sandi * Handle the admin page contents 200c19fe9c0Sandi * 201c19fe9c0Sandi * @author Andreas Gohr <andi@splitbrain.org> 202c19fe9c0Sandi */ 203c19fe9c0Sandifunction tpl_admin(){ 204f8cc712eSAndreas Gohr global $INFO; 205b8595a66SAndreas Gohr global $TOC; 20611e2ce22Schris 207b8595a66SAndreas Gohr $plugin = null; 208bb4866bdSchris if (!empty($_REQUEST['page'])) { 20911e2ce22Schris $pluginlist = plugin_list('admin'); 21011e2ce22Schris 21111e2ce22Schris if (in_array($_REQUEST['page'], $pluginlist)) { 21211e2ce22Schris 21311e2ce22Schris // attempt to load the plugin 21411e2ce22Schris $plugin =& plugin_load('admin',$_REQUEST['page']); 21511e2ce22Schris } 21611e2ce22Schris } 21711e2ce22Schris 218b8595a66SAndreas Gohr if ($plugin !== null){ 219f8cc712eSAndreas Gohr if($plugin->forAdminOnly() && !$INFO['isadmin']){ 220f8cc712eSAndreas Gohr msg('For admins only',-1); 22111e2ce22Schris html_admin(); 222f8cc712eSAndreas Gohr }else{ 223b8595a66SAndreas Gohr if(!is_array($TOC)) $TOC = $plugin->getTOC(); //if TOC wasn't requested yet 224b8595a66SAndreas Gohr if($INFO['prependTOC']) tpl_toc(); 225f8cc712eSAndreas Gohr $plugin->html(); 226f8cc712eSAndreas Gohr } 227f8cc712eSAndreas Gohr }else{ 228f8cc712eSAndreas Gohr html_admin(); 229f8cc712eSAndreas Gohr } 23054e95700STom N Harris return true; 231c19fe9c0Sandi} 2326b13307fSandi 2336b13307fSandi/** 2346b13307fSandi * Print the correct HTML meta headers 2356b13307fSandi * 2366b13307fSandi * This has to go into the head section of your template. 2376b13307fSandi * 238016b6153SAndreas Gohr * @triggers TPL_METAHEADER_OUTPUT 239f96fa415SAndreas Gohr * @param boolean $alt Should feeds and alternative format links be added? 2406b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 2416b13307fSandi */ 242f96fa415SAndreas Gohrfunction tpl_metaheaders($alt=true){ 2436b13307fSandi global $ID; 244d98d4540SBen Coburn global $REV; 2456b13307fSandi global $INFO; 24672e0dc37SAndreas Gohr global $JSINFO; 2476b13307fSandi global $ACT; 2484bb1b5aeSAndreas Gohr global $QUERY; 2496b13307fSandi global $lang; 250dc57ef04Sandi global $conf; 2516b13307fSandi $it=2; 2526b13307fSandi 2537bff22c0SAndreas Gohr // prepare the head array 2547bff22c0SAndreas Gohr $head = array(); 2557bff22c0SAndreas Gohr 256202ac28bSMichael Klier // prepare seed for js and css 257202ac28bSMichael Klier $tseed = 0; 258202ac28bSMichael Klier $depends = getConfigFiles('main'); 259202ac28bSMichael Klier foreach($depends as $f) { 260202ac28bSMichael Klier $time = @filemtime($f); 261202ac28bSMichael Klier if($time > $tseed) $tseed = $time; 262202ac28bSMichael Klier } 2637bff22c0SAndreas Gohr 2646b13307fSandi // the usual stuff 2657bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'generator', 'content'=>'DokuWiki '.getVersion() ); 266da96af35SAndreas Gohr $head['link'][] = array( 'rel'=>'search', 'type'=>'application/opensearchdescription+xml', 267da96af35SAndreas Gohr 'href'=>DOKU_BASE.'lib/exe/opensearch.php', 'title'=>$conf['title'] ); 268f4f47358SBen Coburn $head['link'][] = array( 'rel'=>'start', 'href'=>DOKU_BASE ); 2697aedde2eSGina Haeussge if(actionOK('index')){ 2707bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'contents', 'href'=> wl($ID,'do=index',false,'&'), 271bb4866bdSchris 'title'=>$lang['btn_index'] ); 2727aedde2eSGina Haeussge } 273f96fa415SAndreas Gohr 274f96fa415SAndreas Gohr if($alt){ 2757bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 2767bff22c0SAndreas Gohr 'title'=>'Recent Changes', 'href'=>DOKU_BASE.'feed.php'); 2777bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 2787bff22c0SAndreas Gohr 'title'=>'Current Namespace', 2797bff22c0SAndreas Gohr 'href'=>DOKU_BASE.'feed.php?mode=list&ns='.$INFO['namespace']); 280c35f3875SAndreas Gohr if(($ACT == 'show' || $ACT == 'search') && $INFO['writable']){ 281a2c734d5SAndreas Gohr $head['link'][] = array( 'rel'=>'edit', 282715bdf1fSAndreas Gohr 'title'=>$lang['btn_edit'], 283c35f3875SAndreas Gohr 'href'=> wl($ID,'do=edit',false,'&')); 284c35f3875SAndreas Gohr } 285c35f3875SAndreas Gohr 2864bb1b5aeSAndreas Gohr if($ACT == 'search'){ 2874bb1b5aeSAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'application/rss+xml', 2884bb1b5aeSAndreas Gohr 'title'=>'Search Result', 2894bb1b5aeSAndreas Gohr 'href'=>DOKU_BASE.'feed.php?mode=search&q='.$QUERY); 2904bb1b5aeSAndreas Gohr } 291bae36d94SAndreas Gohr 292bae36d94SAndreas Gohr if(actionOK('export_xhtml')){ 2937bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'text/html', 'title'=>'Plain HTML', 2947bff22c0SAndreas Gohr 'href'=>exportlink($ID, 'xhtml', '', false, '&')); 295bae36d94SAndreas Gohr } 296bae36d94SAndreas Gohr 297bae36d94SAndreas Gohr if(actionOK('export_raw')){ 2987bff22c0SAndreas Gohr $head['link'][] = array( 'rel'=>'alternate', 'type'=>'text/plain', 'title'=>'Wiki Markup', 2997bff22c0SAndreas Gohr 'href'=>exportlink($ID, 'raw', '', false, '&')); 300f96fa415SAndreas Gohr } 301bae36d94SAndreas Gohr } 3026b13307fSandi 3036b13307fSandi // setup robot tags apropriate for different modes 3044f2e0004STim Weber if( ($ACT=='show' || $ACT=='export_xhtml') && !$REV){ 3056b13307fSandi if($INFO['exists']){ 3066b13307fSandi //delay indexing: 3076b13307fSandi if((time() - $INFO['lastmod']) >= $conf['indexdelay']){ 3087bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'index,follow'); 3096b13307fSandi }else{ 3107bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,nofollow'); 3116b13307fSandi } 31269db0cafSAndreas Gohr $head['link'][] = array( 'rel'=>'canonical', 'href'=>wl($ID,'',true,'&') ); 3136b13307fSandi }else{ 3147bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,follow'); 3156b13307fSandi } 3167a24876fSAndreas Gohr }elseif(defined('DOKU_MEDIADETAIL')){ 3177bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'index,follow'); 3186b13307fSandi }else{ 3197bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'robots', 'content'=>'noindex,nofollow'); 3206b13307fSandi } 3216b13307fSandi 322831800b8SAndreas Gohr // set metadata 323831800b8SAndreas Gohr if($ACT == 'show' || $ACT=='export_xhtml'){ 324831800b8SAndreas Gohr // date of modification 325831800b8SAndreas Gohr if($REV){ 3267bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'date', 'content'=>date('Y-m-d\TH:i:sO',$REV)); 327831800b8SAndreas Gohr }else{ 3287bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'date', 'content'=>date('Y-m-d\TH:i:sO',$INFO['lastmod'])); 329831800b8SAndreas Gohr } 330831800b8SAndreas Gohr 331831800b8SAndreas Gohr // keywords (explicit or implicit) 332bb4866bdSchris if(!empty($INFO['meta']['subject'])){ 3337bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'keywords', 'content'=>join(',',$INFO['meta']['subject'])); 334831800b8SAndreas Gohr }else{ 3357bff22c0SAndreas Gohr $head['meta'][] = array( 'name'=>'keywords', 'content'=>str_replace(':',',',$ID)); 336831800b8SAndreas Gohr } 337831800b8SAndreas Gohr } 338831800b8SAndreas Gohr 33978a6aeb1SAndreas Gohr // load stylesheets 3407bff22c0SAndreas Gohr $head['link'][] = array('rel'=>'stylesheet', 'media'=>'screen', 'type'=>'text/css', 341202ac28bSMichael Klier 'href'=>DOKU_BASE.'lib/exe/css.php?t='.$conf['template'].'&tseed='.$tseed); 342d61e1b3eSMike Frysinger $head['link'][] = array('rel'=>'stylesheet', 'media'=>'all', 'type'=>'text/css', 343d61e1b3eSMike Frysinger 'href'=>DOKU_BASE.'lib/exe/css.php?s=all&t='.$conf['template'].'&tseed='.$tseed); 3447bff22c0SAndreas Gohr $head['link'][] = array('rel'=>'stylesheet', 'media'=>'print', 'type'=>'text/css', 345202ac28bSMichael Klier 'href'=>DOKU_BASE.'lib/exe/css.php?s=print&t='.$conf['template'].'&tseed='.$tseed); 346bad31ae9SAndreas Gohr 3478bbcb611SAndreas Gohr // make $INFO and other vars available to JavaScripts 348463d4a65SAndreas Gohr require_once(DOKU_INC.'inc/JSON.php'); 349463d4a65SAndreas Gohr $json = new JSON(); 35072e0dc37SAndreas Gohr $script = "var NS='".$INFO['namespace']."';"; 351c591aabeSAndreas Gohr if($conf['useacl'] && $_SERVER['REMOTE_USER']){ 352aeaccbf9SAndreas Gohr require_once(DOKU_INC.'inc/toolbar.php'); 35372e0dc37SAndreas Gohr $script .= "var SIG='".toolbar_signature()."';"; 354c591aabeSAndreas Gohr } 35572e0dc37SAndreas Gohr $script .= 'var JSINFO = '.$json->encode($JSINFO).';'; 3567bff22c0SAndreas Gohr $head['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', 3577bff22c0SAndreas Gohr '_data'=> $script); 3588bbcb611SAndreas Gohr 3598bbcb611SAndreas Gohr // load external javascript 3607bff22c0SAndreas Gohr $head['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', '_data'=>'', 361202ac28bSMichael Klier 'src'=>DOKU_BASE.'lib/exe/js.php'.'?tseed='.$tseed); 3627bff22c0SAndreas Gohr 36383a482b6SAndreas Gohr 3647bff22c0SAndreas Gohr // trigger event here 365016b6153SAndreas Gohr trigger_event('TPL_METAHEADER_OUTPUT',$head,'_tpl_metaheaders_action',true); 36654e95700STom N Harris return true; 3677bff22c0SAndreas Gohr} 3687bff22c0SAndreas Gohr 3697bff22c0SAndreas Gohr/** 3707bff22c0SAndreas Gohr * prints the array build by tpl_metaheaders 3717bff22c0SAndreas Gohr * 3727bff22c0SAndreas Gohr * $data is an array of different header tags. Each tag can have multiple 3737bff22c0SAndreas Gohr * instances. Attributes are given as key value pairs. Values will be HTML 3747bff22c0SAndreas Gohr * encoded automatically so they should be provided as is in the $data array. 3757bff22c0SAndreas Gohr * 3767bff22c0SAndreas Gohr * For tags having a body attribute specify the the body data in the special 3771304d1dbSAndreas Gohr * attribute '_data'. This field will NOT BE ESCAPED automatically. 3787bff22c0SAndreas Gohr * 3797bff22c0SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 3807bff22c0SAndreas Gohr */ 3817bff22c0SAndreas Gohrfunction _tpl_metaheaders_action($data){ 3827bff22c0SAndreas Gohr foreach($data as $tag => $inst){ 3837bff22c0SAndreas Gohr foreach($inst as $attr){ 3847bff22c0SAndreas Gohr echo '<',$tag,' ',buildAttributes($attr); 38526afa874SMikhail I. Izmestev if(isset($attr['_data']) || $tag == 'script'){ 386e226efe1SAndreas Gohr if($tag == 'script' && $attr['_data']) 387e226efe1SAndreas Gohr $attr['_data'] = "<!--//--><![CDATA[//><!--\n". 388e226efe1SAndreas Gohr $attr['_data']. 389e226efe1SAndreas Gohr "\n//--><!]]>"; 390e226efe1SAndreas Gohr 3911304d1dbSAndreas Gohr echo '>',$attr['_data'],'</',$tag,'>'; 3927bff22c0SAndreas Gohr }else{ 3937bff22c0SAndreas Gohr echo '/>'; 3947bff22c0SAndreas Gohr } 3957bff22c0SAndreas Gohr echo "\n"; 3967bff22c0SAndreas Gohr } 3977bff22c0SAndreas Gohr } 3986b13307fSandi} 3996b13307fSandi 4006b13307fSandi/** 4016b13307fSandi * Print a link 4026b13307fSandi * 4035e163278SAndreas Gohr * Just builds a link. 4046b13307fSandi * 4056b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 4066b13307fSandi */ 4071af98a77SAnika Henkefunction tpl_link($url,$name,$more='',$return=false){ 40801f17825SAnika Henke $out = '<a href="'.$url.'" '; 4091af98a77SAnika Henke if ($more) $out .= ' '.$more; 4101af98a77SAnika Henke $out .= ">$name</a>"; 4111af98a77SAnika Henke if ($return) return $out; 4121af98a77SAnika Henke print $out; 41354e95700STom N Harris return true; 4146b13307fSandi} 4156b13307fSandi 4166b13307fSandi/** 41755efc227SAndreas Gohr * Prints a link to a WikiPage 41855efc227SAndreas Gohr * 41955efc227SAndreas Gohr * Wrapper around html_wikilink 42055efc227SAndreas Gohr * 42155efc227SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 42255efc227SAndreas Gohr */ 42355efc227SAndreas Gohrfunction tpl_pagelink($id,$name=NULL){ 42455efc227SAndreas Gohr print html_wikilink($id,$name); 42554e95700STom N Harris return true; 42655efc227SAndreas Gohr} 42755efc227SAndreas Gohr 42855efc227SAndreas Gohr/** 429a3ec5f4aSmatthiasgrimm * get the parent page 430a3ec5f4aSmatthiasgrimm * 431a3ec5f4aSmatthiasgrimm * Tries to find out which page is parent. 432a3ec5f4aSmatthiasgrimm * returns false if none is available 433a3ec5f4aSmatthiasgrimm * 434377f9e97SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 435a3ec5f4aSmatthiasgrimm */ 436377f9e97SAndreas Gohrfunction tpl_getparent($id){ 437a3ec5f4aSmatthiasgrimm global $conf; 438377f9e97SAndreas Gohr $parent = getNS($id).':'; 439377f9e97SAndreas Gohr resolve_pageid('',$parent,$exists); 440a197105eSmatthiasgrimm if($parent == $id) { 441a197105eSmatthiasgrimm $pos = strrpos (getNS($id),':'); 442a197105eSmatthiasgrimm $parent = substr($parent,0,$pos).':'; 443a197105eSmatthiasgrimm resolve_pageid('',$parent,$exists); 444377f9e97SAndreas Gohr if($parent == $id) return false; 445a197105eSmatthiasgrimm } 446377f9e97SAndreas Gohr return $parent; 447a3ec5f4aSmatthiasgrimm} 448a3ec5f4aSmatthiasgrimm 449a3ec5f4aSmatthiasgrimm/** 4506b13307fSandi * Print one of the buttons 4516b13307fSandi * 4526b13307fSandi * Available Buttons are 4536b13307fSandi * 454ee4c4a1bSAndreas Gohr * edit - edit/create/show/draft button 4556b13307fSandi * history - old revisions 4566b13307fSandi * recent - recent changes 4576b13307fSandi * login - login/logout button - if ACL enabled 458d449b912SDenis Simakov * profile - user profile button (if logged in) 4596b13307fSandi * index - The index 460c19fe9c0Sandi * admin - admin page - if enough rights 4616b13307fSandi * top - a back to top button 462a3ec5f4aSmatthiasgrimm * back - a back to parent button - if available 463bbd37938SAndreas Gohr * backlink - links to the list of backlinks 464d449b912SDenis Simakov * subscription- subscribe/unsubscribe button 4656b13307fSandi * 4666b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 467a3ec5f4aSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 4686b13307fSandi */ 4691af98a77SAnika Henkefunction tpl_button($type,$return=false){ 470b158d625SSteven Danz global $ACT; 4716b13307fSandi global $ID; 472d98d4540SBen Coburn global $REV; 473d67ca2c0Smatthiasgrimm global $NS; 474c19fe9c0Sandi global $INFO; 4756b13307fSandi global $conf; 476cd52f92dSchris global $auth; 4776b13307fSandi 47875e487e9SAndreas Gohr // check disabled actions and fix the badly named ones 47975e487e9SAndreas Gohr $ctype = $type; 48075e487e9SAndreas Gohr if($type == 'history') $ctype='revisions'; 48154e95700STom N Harris if(!actionOK($ctype)) return false; 482409d7af7SAndreas Gohr 4831af98a77SAnika Henke $out = ''; 4846b13307fSandi switch($type){ 4856b13307fSandi case 'edit': 486409d7af7SAndreas Gohr #most complicated type - we need to decide on current action 487409d7af7SAndreas Gohr if($ACT == 'show' || $ACT == 'search'){ 488409d7af7SAndreas Gohr if($INFO['writable']){ 489bb4866bdSchris if(!empty($INFO['draft'])){ 4901af98a77SAnika Henke $out .= html_btn('draft',$ID,'e',array('do' => 'draft'),'post'); 491409d7af7SAndreas Gohr }else{ 492409d7af7SAndreas Gohr if($INFO['exists']){ 4931af98a77SAnika Henke $out .= html_btn('edit',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 494409d7af7SAndreas Gohr }else{ 4951af98a77SAnika Henke $out .= html_btn('create',$ID,'e',array('do' => 'edit','rev' => $REV),'post'); 496409d7af7SAndreas Gohr } 497409d7af7SAndreas Gohr } 498409d7af7SAndreas Gohr }else{ 499409d7af7SAndreas Gohr if(!actionOK('source')) return false; //pseudo action 5001af98a77SAnika Henke $out .= html_btn('source',$ID,'v',array('do' => 'edit','rev' => $REV),'post'); 501409d7af7SAndreas Gohr } 502409d7af7SAndreas Gohr }else{ 5031af98a77SAnika Henke $out .= html_btn('show',$ID,'v',array('do' => 'show')); 504409d7af7SAndreas Gohr } 5051af98a77SAnika Henke break; 5066b13307fSandi case 'history': 5071af98a77SAnika Henke if(actionOK('revisions')) 5081af98a77SAnika Henke $out .= html_btn('revs',$ID,'o',array('do' => 'revisions')); 5091af98a77SAnika Henke break; 5106b13307fSandi case 'recent': 5111af98a77SAnika Henke if(actionOK('recent')) 5121af98a77SAnika Henke $out .= html_btn('recent',$ID,'r',array('do' => 'recent')); 5131af98a77SAnika Henke break; 5146b13307fSandi case 'index': 5151af98a77SAnika Henke if(actionOK('index')) 5161af98a77SAnika Henke $out .= html_btn('index',$ID,'x',array('do' => 'index')); 5171af98a77SAnika Henke break; 518a3ec5f4aSmatthiasgrimm case 'back': 5196222040cSmatthiasgrimm if ($parent = tpl_getparent($ID)) { 5201af98a77SAnika Henke $out .= html_btn('back',$parent,'b',array('do' => 'show')); 521a3ec5f4aSmatthiasgrimm } 5221af98a77SAnika Henke break; 5236b13307fSandi case 'top': 5241af98a77SAnika Henke $out .= html_topbtn(); 5251af98a77SAnika Henke break; 5266b13307fSandi case 'login': 5276957b2eaSAndreas Gohr if($conf['useacl'] && $auth){ 528c66972f2SAdrian Lang if(isset($_SERVER['REMOTE_USER'])){ 5291af98a77SAnika Henke $out .= html_btn('logout',$ID,'',array('do' => 'logout', 'sectok' => getSecurityToken())); 5306b13307fSandi }else{ 5311af98a77SAnika Henke $out .= html_btn('login',$ID,'',array('do' => 'login', 'sectok' => getSecurityToken())); 5326b13307fSandi } 5336b13307fSandi } 5341af98a77SAnika Henke break; 535c19fe9c0Sandi case 'admin': 53654e95700STom N Harris if($INFO['ismanager']){ 5371af98a77SAnika Henke $out .= html_btn('admin',$ID,'',array('do' => 'admin')); 53854e95700STom N Harris } 5391af98a77SAnika Henke break; 5401246e016SAndreas Gohr case 'revert': 5411246e016SAndreas Gohr if($INFO['ismanager'] && $REV && $INFO['writable'] && actionOK('revert')){ 5421246e016SAndreas Gohr $out .= html_btn('revert',$ID,'',array('do' => 'revert', 'rev' => $REV, 'sectok' => getSecurityToken())); 5431246e016SAndreas Gohr } 5441246e016SAndreas Gohr break; 545582c5bfeSAndreas Gohr case 'subscribe': 5465b75cd1fSAdrian Lang if ($conf['useacl'] && $auth && $ACT == 'show' && 5475b75cd1fSAdrian Lang $conf['subscribers'] && isset($_SERVER['REMOTE_USER']) && 5485b75cd1fSAdrian Lang actionOK('subscribe')) { 5491af98a77SAnika Henke $out .= html_btn('subscribe',$ID,'',array('do' => 'subscribe',)); 550582c5bfeSAndreas Gohr } 5511af98a77SAnika Henke break; 552f00151b4Schris case 'backlink': 5531af98a77SAnika Henke if(actionOK('backlink')) 5541af98a77SAnika Henke $out .= html_btn('backlink',$ID,'',array('do' => 'backlink')); 5554c30ec5fSAndreas Gohr break; 5568b06d178Schris case 'profile': 557c66972f2SAdrian Lang if($conf['useacl'] && isset($_SERVER['REMOTE_USER']) && $auth && 55836223ba7SAndreas Gohr $auth->canDo('Profile') && ($ACT!='profile')){ 5591af98a77SAnika Henke $out .= html_btn('profile',$ID,'',array('do' => 'profile')); 5608b06d178Schris } 5611af98a77SAnika Henke break; 562c19fe9c0Sandi default: 5631af98a77SAnika Henke $out .= '[unknown button type]'; 5641af98a77SAnika Henke break; 5656b13307fSandi } 5661af98a77SAnika Henke if ($return) return $out; 5671af98a77SAnika Henke print $out; 5681af98a77SAnika Henke return $out ? true : false; 5696b13307fSandi} 5706b13307fSandi 5716b13307fSandi/** 572ed630903Sandi * Like the action buttons but links 573ed630903Sandi * 574ed630903Sandi * Available links are 575ed630903Sandi * 576d449b912SDenis Simakov * edit - edit/create/show link 577ed630903Sandi * history - old revisions 578ed630903Sandi * recent - recent changes 579d449b912SDenis Simakov * login - login/logout link - if ACL enabled 580d449b912SDenis Simakov * profile - user profile link (if logged in) 581ed630903Sandi * index - The index 582ed630903Sandi * admin - admin page - if enough rights 583d449b912SDenis Simakov * top - a back to top link 584d449b912SDenis Simakov * back - a back to parent link - if available 585bbd37938SAndreas Gohr * backlink - links to the list of backlinks 586d449b912SDenis Simakov * subscribe/subscription - subscribe/unsubscribe link 587ed630903Sandi * 588ed630903Sandi * @author Andreas Gohr <andi@splitbrain.org> 589a3ec5f4aSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 590ed630903Sandi * @see tpl_button 591ed630903Sandi */ 5921af98a77SAnika Henkefunction tpl_actionlink($type,$pre='',$suf='',$inner='',$return=false){ 593ed630903Sandi global $ID; 594ed630903Sandi global $INFO; 595ed630903Sandi global $REV; 596ed630903Sandi global $ACT; 597ed630903Sandi global $conf; 598ed630903Sandi global $lang; 599cd52f92dSchris global $auth; 600ed630903Sandi 60175e487e9SAndreas Gohr // check disabled actions and fix the badly named ones 60275e487e9SAndreas Gohr $ctype = $type; 60375e487e9SAndreas Gohr if($type == 'history') $ctype='revisions'; 60454e95700STom N Harris if(!actionOK($ctype)) return false; 605409d7af7SAndreas Gohr 6061af98a77SAnika Henke $out = ''; 607ed630903Sandi switch($type){ 608ed630903Sandi case 'edit': 609ed630903Sandi #most complicated type - we need to decide on current action 610ed630903Sandi if($ACT == 'show' || $ACT == 'search'){ 611ed630903Sandi if($INFO['writable']){ 612b8a111f5SMichael Klier if(!empty($INFO['draft'])) { 6131af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=draft'), 614c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_draft']).$suf, 6151af98a77SAnika Henke 'class="action edit" accesskey="e" rel="nofollow"',1); 616b8a111f5SMichael Klier } else { 617ed630903Sandi if($INFO['exists']){ 6181af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=edit&rev='.$REV), 619c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_edit']).$suf, 6201af98a77SAnika Henke 'class="action edit" accesskey="e" rel="nofollow"',1); 621ed630903Sandi }else{ 6221af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=edit&rev='.$REV), 623c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_create']).$suf, 6241af98a77SAnika Henke 'class="action create" accesskey="e" rel="nofollow"',1); 625ed630903Sandi } 626b8a111f5SMichael Klier } 627ed630903Sandi }else{ 6281af98a77SAnika Henke if(actionOK('source')) //pseudo action 6291af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=edit&rev='.$REV), 630c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_source']).$suf, 6311af98a77SAnika Henke 'class="action source" accesskey="v" rel="nofollow"',1); 632ed630903Sandi } 633ed630903Sandi }else{ 6341af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=show'), 635c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_show']).$suf, 6361af98a77SAnika Henke 'class="action show" accesskey="v" rel="nofollow"',1); 637ed630903Sandi } 6381af98a77SAnika Henke break; 639ed630903Sandi case 'history': 6401af98a77SAnika Henke if(actionOK('revisions')) 6411af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=revisions'), 642c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_revs']).$suf, 6431af98a77SAnika Henke 'class="action revisions" accesskey="o" rel="nofollow"',1); 6441af98a77SAnika Henke break; 645ed630903Sandi case 'recent': 6461af98a77SAnika Henke if(actionOK('recent')) 6471af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=recent'), 648c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_recent']).$suf, 6491af98a77SAnika Henke 'class="action recent" accesskey="r" rel="nofollow"',1); 6501af98a77SAnika Henke break; 651ed630903Sandi case 'index': 6521af98a77SAnika Henke if(actionOK('index')) 6531af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=index'), 654c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_index']).$suf, 6551af98a77SAnika Henke 'class="action index" accesskey="x" rel="nofollow"',1); 6561af98a77SAnika Henke break; 657ed630903Sandi case 'top': 6581af98a77SAnika Henke $out .= '<a href="#dokuwiki__top" class="action top" accesskey="x">'. 659c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_top']).$suf.'</a>'; 6601af98a77SAnika Henke break; 661a3ec5f4aSmatthiasgrimm case 'back': 662f7569b7bSAndreas Gohr if ($parent = tpl_getparent($ID)) { 6631af98a77SAnika Henke $out .= tpl_link(wl($parent,'do=show'), 664c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_back']).$suf, 6651af98a77SAnika Henke 'class="action back" accesskey="b" rel="nofollow"',1); 666a3ec5f4aSmatthiasgrimm } 6671af98a77SAnika Henke break; 668ed630903Sandi case 'login': 6696957b2eaSAndreas Gohr if($conf['useacl'] && $auth){ 670ed630903Sandi if($_SERVER['REMOTE_USER']){ 6711af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=logout&sectok='.getSecurityToken()), 672c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_logout']).$suf, 6731af98a77SAnika Henke 'class="action logout" rel="nofollow"',1); 674ed630903Sandi }else{ 6751af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=login&sectok='.getSecurityToken()), 676c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_login']).$suf, 6771af98a77SAnika Henke 'class="action login" rel="nofollow"',1); 678ed630903Sandi } 679ed630903Sandi } 6801af98a77SAnika Henke break; 681ed630903Sandi case 'admin': 682f8cc712eSAndreas Gohr if($INFO['ismanager']){ 6831af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=admin'), 684c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_admin']).$suf, 6851af98a77SAnika Henke 'class="action admin" rel="nofollow"',1); 686c059e1a6SAndreas Gohr } 6871af98a77SAnika Henke break; 6881246e016SAndreas Gohr case 'revert': 6891246e016SAndreas Gohr if($INFO['ismanager'] && $REV && $INFO['writable'] && actionOK('revert')){ 6901246e016SAndreas Gohr $out .= tpl_link(wl($ID,array('do' => 'revert', 'rev' => $REV, 'sectok' => getSecurityToken())), 6911246e016SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_revert']).$suf, 6921246e016SAndreas Gohr 'class="action revert" rel="nofollow"',1); 6931246e016SAndreas Gohr } 6941246e016SAndreas Gohr break; 695f9eb5648Ssteven-danz case 'subscribe': 696075f000fSChristopher Arndt case 'subscription': 6975b75cd1fSAdrian Lang if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers']) { 698b158d625SSteven Danz if($_SERVER['REMOTE_USER']){ 6991af98a77SAnika Henke if(actionOK('subscribe')) 7001af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=subscribe'), 701c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_subscribe']).$suf, 7021af98a77SAnika Henke 'class="action subscribe" rel="nofollow"',1); 703b158d625SSteven Danz } 704b158d625SSteven Danz } 7051af98a77SAnika Henke break; 706f00151b4Schris case 'backlink': 7071af98a77SAnika Henke if(actionOK('backlink')) 7081af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=backlink'), 709c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_backlink']).$suf, 7101af98a77SAnika Henke 'class="action backlink" rel="nofollow"',1); 7111af98a77SAnika Henke break; 7128b06d178Schris case 'profile': 7136957b2eaSAndreas Gohr if($conf['useacl'] && $auth && $_SERVER['REMOTE_USER'] && 71436223ba7SAndreas Gohr $auth->canDo('Profile') && ($ACT!='profile')){ 7151af98a77SAnika Henke $out .= tpl_link(wl($ID,'do=profile'), 716c97dfb07SAndreas Gohr $pre.(($inner)?$inner:$lang['btn_profile']).$suf, 7171af98a77SAnika Henke 'class="action profile" rel="nofollow"',1); 7188b06d178Schris } 7191af98a77SAnika Henke break; 720ed630903Sandi default: 7211af98a77SAnika Henke $out .= '[unknown link type]'; 7221af98a77SAnika Henke break; 723ed630903Sandi } 7241af98a77SAnika Henke if ($return) return $out; 7251af98a77SAnika Henke print $out; 7261af98a77SAnika Henke return $out ? true : false; 727ed630903Sandi} 728ed630903Sandi 729ed630903Sandi/** 73001f17825SAnika Henke * Wrapper around tpl_button() and tpl_actionlink() 73101f17825SAnika Henke * 73201f17825SAnika Henke * @author Anika Henke <anika@selfthinker.org> 73301f17825SAnika Henke */ 73401f17825SAnika Henkefunction tpl_action($type,$link=0,$wrapper=false,$return=false,$pre='',$suf='',$inner='') { 73501f17825SAnika Henke $out = ''; 73601f17825SAnika Henke if ($link) $out .= tpl_actionlink($type,$pre,$suf,$inner,1); 73701f17825SAnika Henke else $out .= tpl_button($type,1); 73801f17825SAnika Henke if ($out && $wrapper) $out = "<$wrapper>$out</$wrapper>"; 73901f17825SAnika Henke 74001f17825SAnika Henke if ($return) return $out; 74101f17825SAnika Henke print $out; 74201f17825SAnika Henke return $out ? true : false; 74301f17825SAnika Henke} 74401f17825SAnika Henke 74501f17825SAnika Henke/** 7466b13307fSandi * Print the search form 7476b13307fSandi * 74872645b75SAndreas Gohr * If the first parameter is given a div with the ID 'qsearch_out' will 74972645b75SAndreas Gohr * be added which instructs the ajax pagequicksearch to kick in and place 75072645b75SAndreas Gohr * its output into this div. The second parameter controls the propritary 75172645b75SAndreas Gohr * attribute autocomplete. If set to false this attribute will be set with an 75272645b75SAndreas Gohr * value of "off" to instruct the browser to disable it's own built in 75372645b75SAndreas Gohr * autocompletion feature (MSIE and Firefox) 75472645b75SAndreas Gohr * 7556b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 7566b13307fSandi */ 75772645b75SAndreas Gohrfunction tpl_searchform($ajax=true,$autocomplete=true){ 7586b13307fSandi global $lang; 759c1e3b7d9Smatthiasgrimm global $ACT; 760ad4aaef7SAndreas Gohr global $QUERY; 761c1e3b7d9Smatthiasgrimm 762670ff54eSchris // don't print the search form if search action has been disabled 76354e95700STom N Harris if (!actionOk('search')) return false; 764670ff54eSchris 7651dd0c202SAnika Henke print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search"><div class="no">'; 7666b13307fSandi print '<input type="hidden" name="do" value="search" />'; 767c1e3b7d9Smatthiasgrimm print '<input type="text" '; 768ad4aaef7SAndreas Gohr if($ACT == 'search') print 'value="'.htmlspecialchars($QUERY).'" '; 76972645b75SAndreas Gohr if(!$autocomplete) print 'autocomplete="off" '; 77007493d05SAnika Henke print 'id="qsearch__in" accesskey="f" name="id" class="edit" title="[F]" />'; 77111ea018fSAndreas Gohr print '<input type="submit" value="'.$lang['btn_search'].'" class="button" title="'.$lang['btn_search'].'" />'; 77224a33b42SAndreas Gohr if($ajax) print '<div id="qsearch__out" class="ajax_qsearch JSpopup"></div>'; 7734beabca9SAnika Henke print '</div></form>'; 77454e95700STom N Harris return true; 7756b13307fSandi} 7766b13307fSandi 7776b13307fSandi/** 7786b13307fSandi * Print the breadcrumbs trace 7796b13307fSandi * 7806b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 7816b13307fSandi */ 78254e95700STom N Harrisfunction tpl_breadcrumbs($sep='»'){ 7836b13307fSandi global $lang; 7846b13307fSandi global $conf; 7856b13307fSandi 7866b13307fSandi //check if enabled 78754e95700STom N Harris if(!$conf['breadcrumbs']) return false; 7886b13307fSandi 7896b13307fSandi $crumbs = breadcrumbs(); //setup crumb trace 790265e3787Sandi 7912979a10bSKatriel Traum //reverse crumborder in right-to-left mode, add RLM character to fix heb/eng display mixups 7922979a10bSKatriel Traum if($lang['direction'] == 'rtl') { 7932979a10bSKatriel Traum $crumbs = array_reverse($crumbs,true); 7942979a10bSKatriel Traum $crumbs_sep = ' ‏<span class="bcsep">'.$sep.'</span>‏ '; 7952979a10bSKatriel Traum } else { 7962979a10bSKatriel Traum $crumbs_sep = ' <span class="bcsep">'.$sep.'</span> '; 7972979a10bSKatriel Traum } 798265e3787Sandi 79940eb54bbSjan //render crumbs, highlight the last one 8001b6f3a44SAndreas Gohr print '<span class="bchead">'.$lang['breadcrumb'].':</span>'; 80140eb54bbSjan $last = count($crumbs); 80240eb54bbSjan $i = 0; 803a77f5846Sjan foreach ($crumbs as $id => $name){ 80440eb54bbSjan $i++; 8052979a10bSKatriel Traum echo $crumbs_sep; 80692795d04Sandi if ($i == $last) print '<span class="curid">'; 807e26fd1eeSAndreas Gohr tpl_link(wl($id),hsc($name),'class="breadcrumbs" title="'.$id.'"'); 80892795d04Sandi if ($i == $last) print '</span>'; 8096b13307fSandi } 81054e95700STom N Harris return true; 8116b13307fSandi} 8126b13307fSandi 8136b13307fSandi/** 8141734437eSandi * Hierarchical breadcrumbs 8151734437eSandi * 81631e187f8SSean Coates * This code was suggested as replacement for the usual breadcrumbs. 8171734437eSandi * It only makes sense with a deep site structure. 8181734437eSandi * 8191734437eSandi * @author Andreas Gohr <andi@splitbrain.org> 8206bd812dfSNigel McNie * @author Nigel McNie <oracle.shinoda@gmail.com> 82131e187f8SSean Coates * @author Sean Coates <sean@caedmon.net> 822f46c9e83SAnika Henke * @author <fredrik@averpil.com> 8236bd812dfSNigel McNie * @todo May behave strangely in RTL languages 8241734437eSandi */ 825796bafb3SAndreas Gohrfunction tpl_youarehere($sep=' » '){ 8261734437eSandi global $conf; 8271734437eSandi global $ID; 8281734437eSandi global $lang; 8291734437eSandi 83031e187f8SSean Coates // check if enabled 83154e95700STom N Harris if(!$conf['youarehere']) return false; 8321734437eSandi 8331734437eSandi $parts = explode(':', $ID); 834796bafb3SAndreas Gohr $count = count($parts); 8351734437eSandi 8363b437163SAlexey Torkhov if($GLOBALS['ACT'] == 'search') 8373b437163SAlexey Torkhov { 8383b437163SAlexey Torkhov $parts = array($conf['start']); 8393b437163SAlexey Torkhov $count = 1; 8403b437163SAlexey Torkhov } 8413b437163SAlexey Torkhov 8421b6f3a44SAndreas Gohr echo '<span class="bchead">'.$lang['youarehere'].': </span>'; 8431734437eSandi 8441734437eSandi // always print the startpage 845fe9ec250SChris Smith $title = useHeading('navigation') ? p_get_first_heading($conf['start']) : $conf['start']; 846796bafb3SAndreas Gohr if(!$title) $title = $conf['start']; 847e26fd1eeSAndreas Gohr tpl_link(wl($conf['start']),hsc($title),'title="'.$conf['start'].'"'); 848796bafb3SAndreas Gohr 849796bafb3SAndreas Gohr // print intermediate namespace links 850796bafb3SAndreas Gohr $part = ''; 851796bafb3SAndreas Gohr for($i=0; $i<$count - 1; $i++){ 852796bafb3SAndreas Gohr $part .= $parts[$i].':'; 853796bafb3SAndreas Gohr $page = $part; 854796bafb3SAndreas Gohr resolve_pageid('',$page,$exists); 855796bafb3SAndreas Gohr if ($page == $conf['start']) continue; // Skip startpage 856796bafb3SAndreas Gohr 857796bafb3SAndreas Gohr // output 858796bafb3SAndreas Gohr echo $sep; 859796bafb3SAndreas Gohr if($exists){ 860af03da1aSAndreas Gohr $title = useHeading('navigation') ? p_get_first_heading($page) : $parts[$i]; 861e26fd1eeSAndreas Gohr tpl_link(wl($page),hsc($title),'title="'.$page.'"'); 86231e187f8SSean Coates }else{ 86378cbfcb6SAndreas Gohr tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2" rel="nofollow"'); 86431e187f8SSean Coates } 86531e187f8SSean Coates } 8661734437eSandi 867796bafb3SAndreas Gohr // print current page, skipping start page, skipping for namespace index 868d98d4540SBen Coburn if(isset($page) && $page==$part.$parts[$i]) return; 869796bafb3SAndreas Gohr $page = $part.$parts[$i]; 870796bafb3SAndreas Gohr if($page == $conf['start']) return; 871796bafb3SAndreas Gohr echo $sep; 872103c256aSChris Smith if(page_exists($page)){ 873af03da1aSAndreas Gohr $title = useHeading('navigation') ? p_get_first_heading($page) : $parts[$i]; 874e26fd1eeSAndreas Gohr tpl_link(wl($page),hsc($title),'title="'.$page.'"'); 87531e187f8SSean Coates }else{ 87678cbfcb6SAndreas Gohr tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2" rel="nofollow"'); 8771734437eSandi } 87854e95700STom N Harris return true; 8791734437eSandi} 8801734437eSandi 8811734437eSandi/** 8826b13307fSandi * Print info if the user is logged in 883a2488c3cSMatthias Grimm * and show full name in that case 8846b13307fSandi * 8856b13307fSandi * Could be enhanced with a profile link in future? 8866b13307fSandi * 8876b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 8886b13307fSandi */ 8896b13307fSandifunction tpl_userinfo(){ 8906b13307fSandi global $lang; 8913e63b73bSMichael Klier global $INFO; 892c66972f2SAdrian Lang if(isset($_SERVER['REMOTE_USER'])){ 8933e63b73bSMichael Klier print $lang['loggedinas'].': '.$INFO['userinfo']['name'].' ('.$_SERVER['REMOTE_USER'].')'; 89454e95700STom N Harris return true; 89554e95700STom N Harris } 89654e95700STom N Harris return false; 8976b13307fSandi} 8986b13307fSandi 8996b13307fSandi/** 9006b13307fSandi * Print some info about the current page 9016b13307fSandi * 9026b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 9036b13307fSandi */ 9044b0d3916SAndreas Gohrfunction tpl_pageinfo($ret=false){ 9056b13307fSandi global $conf; 9066b13307fSandi global $lang; 9076b13307fSandi global $INFO; 908c6e92a3cSDavid Lorentsen global $ID; 909c6e92a3cSDavid Lorentsen 910c6e92a3cSDavid Lorentsen // return if we are not allowed to view the page 9114b0d3916SAndreas Gohr if (!auth_quickaclcheck($ID)) { return false; } 9126b13307fSandi 9136b13307fSandi // prepare date and path 9146b13307fSandi $fn = $INFO['filepath']; 9156b13307fSandi if(!$conf['fullpath']){ 916613bca54SAndreas Gohr if($INFO['rev']){ 91750fbebceSGina Haeussge $fn = str_replace(fullpath($conf['olddir']).'/','',$fn); 9186b13307fSandi }else{ 91950fbebceSGina Haeussge $fn = str_replace(fullpath($conf['datadir']).'/','',$fn); 9206b13307fSandi } 9216b13307fSandi } 922bee6dc82Sandi $fn = utf8_decodeFN($fn); 923f2263577SAndreas Gohr $date = dformat($INFO['lastmod']); 9246b13307fSandi 925faecdfdfSAndreas Gohr // print it 926faecdfdfSAndreas Gohr if($INFO['exists']){ 9274b0d3916SAndreas Gohr $out = ''; 9284b0d3916SAndreas Gohr $out .= $fn; 9294b0d3916SAndreas Gohr $out .= ' · '; 9304b0d3916SAndreas Gohr $out .= $lang['lastmod']; 9314b0d3916SAndreas Gohr $out .= ': '; 9324b0d3916SAndreas Gohr $out .= $date; 9336b13307fSandi if($INFO['editor']){ 9344b0d3916SAndreas Gohr $out .= ' '.$lang['by'].' '; 935dc58b6f4SAndy Webber $out .= editorinfo($INFO['editor']); 9365aa52fafSBen Coburn }else{ 9374b0d3916SAndreas Gohr $out .= ' ('.$lang['external_edit'].')'; 9386b13307fSandi } 9396b13307fSandi if($INFO['locked']){ 9404b0d3916SAndreas Gohr $out .= ' · '; 9414b0d3916SAndreas Gohr $out .= $lang['lockedby']; 9424b0d3916SAndreas Gohr $out .= ': '; 943dc58b6f4SAndy Webber $out .= editorinfo($INFO['locked']); 9446b13307fSandi } 9454b0d3916SAndreas Gohr if($ret){ 9464b0d3916SAndreas Gohr return $out; 9474b0d3916SAndreas Gohr }else{ 9484b0d3916SAndreas Gohr echo $out; 94954e95700STom N Harris return true; 9506b13307fSandi } 9514b0d3916SAndreas Gohr } 95254e95700STom N Harris return false; 9536b13307fSandi} 9546b13307fSandi 955820fa24bSandi/** 956a6598f23SBen Coburn * Prints or returns the name of the given page (current one if none given). 95787c434ceSAndreas Gohr * 95887c434ceSAndreas Gohr * If useheading is enabled this will use the first headline else 959a6598f23SBen Coburn * the given ID is used. 96087c434ceSAndreas Gohr * 96187c434ceSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 96287c434ceSAndreas Gohr */ 963a6598f23SBen Coburnfunction tpl_pagetitle($id=null, $ret=false){ 96487c434ceSAndreas Gohr global $conf; 96587c434ceSAndreas Gohr if(is_null($id)){ 96687c434ceSAndreas Gohr global $ID; 96787c434ceSAndreas Gohr $id = $ID; 96887c434ceSAndreas Gohr } 96987c434ceSAndreas Gohr 97087c434ceSAndreas Gohr $name = $id; 971fe9ec250SChris Smith if (useHeading('navigation')) { 97287c434ceSAndreas Gohr $title = p_get_first_heading($id); 97387c434ceSAndreas Gohr if ($title) $name = $title; 97487c434ceSAndreas Gohr } 975a6598f23SBen Coburn 976a6598f23SBen Coburn if ($ret) { 977a6598f23SBen Coburn return hsc($name); 978a6598f23SBen Coburn } else { 97987c434ceSAndreas Gohr print hsc($name); 98054e95700STom N Harris return true; 98187c434ceSAndreas Gohr } 982a6598f23SBen Coburn} 983340756e4Sandi 98455efc227SAndreas Gohr/** 98555efc227SAndreas Gohr * Returns the requested EXIF/IPTC tag from the current image 98655efc227SAndreas Gohr * 98755efc227SAndreas Gohr * If $tags is an array all given tags are tried until a 98855efc227SAndreas Gohr * value is found. If no value is found $alt is returned. 98955efc227SAndreas Gohr * 99055efc227SAndreas Gohr * Which texts are known is defined in the functions _exifTagNames 99155efc227SAndreas Gohr * and _iptcTagNames() in inc/jpeg.php (You need to prepend IPTC 99255efc227SAndreas Gohr * to the names of the latter one) 99355efc227SAndreas Gohr * 9943df72098SAndreas Gohr * Only allowed in: detail.php 99555efc227SAndreas Gohr * 99655efc227SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 99755efc227SAndreas Gohr */ 9983df72098SAndreas Gohrfunction tpl_img_getTag($tags,$alt='',$src=null){ 99955efc227SAndreas Gohr // Init Exif Reader 100055efc227SAndreas Gohr global $SRC; 10013df72098SAndreas Gohr 10023df72098SAndreas Gohr if(is_null($src)) $src = $SRC; 10033df72098SAndreas Gohr 100455efc227SAndreas Gohr static $meta = null; 10053df72098SAndreas Gohr if(is_null($meta)) $meta = new JpegMeta($src); 100655efc227SAndreas Gohr if($meta === false) return $alt; 100755efc227SAndreas Gohr $info = $meta->getField($tags); 100855efc227SAndreas Gohr if($info == false) return $alt; 100955efc227SAndreas Gohr return $info; 101055efc227SAndreas Gohr} 101155efc227SAndreas Gohr 101255efc227SAndreas Gohr/** 101355efc227SAndreas Gohr * Prints the image with a link to the full sized version 101455efc227SAndreas Gohr * 101555efc227SAndreas Gohr * Only allowed in: detail.php 101655efc227SAndreas Gohr */ 1017f8925855Sjoe.lappfunction tpl_img($maxwidth=0,$maxheight=0){ 101855efc227SAndreas Gohr global $IMG; 101955efc227SAndreas Gohr $w = tpl_img_getTag('File.Width'); 102055efc227SAndreas Gohr $h = tpl_img_getTag('File.Height'); 102155efc227SAndreas Gohr 102255efc227SAndreas Gohr //resize to given max values 102323a34783SAndreas Gohr $ratio = 1; 102423a34783SAndreas Gohr if($w >= $h){ 1025f8925855Sjoe.lapp if($maxwidth && $w >= $maxwidth){ 102655efc227SAndreas Gohr $ratio = $maxwidth/$w; 1027f8925855Sjoe.lapp }elseif($maxheight && $h > $maxheight){ 102855efc227SAndreas Gohr $ratio = $maxheight/$h; 102955efc227SAndreas Gohr } 103055efc227SAndreas Gohr }else{ 1031f8925855Sjoe.lapp if($maxheight && $h >= $maxheight){ 103255efc227SAndreas Gohr $ratio = $maxheight/$h; 1033f8925855Sjoe.lapp }elseif($maxwidth && $w > $maxwidth){ 103455efc227SAndreas Gohr $ratio = $maxwidth/$w; 103555efc227SAndreas Gohr } 103655efc227SAndreas Gohr } 103755efc227SAndreas Gohr if($ratio){ 103855efc227SAndreas Gohr $w = floor($ratio*$w); 103955efc227SAndreas Gohr $h = floor($ratio*$h); 104055efc227SAndreas Gohr } 104155efc227SAndreas Gohr 10426de3759aSAndreas Gohr //prepare URLs 10436de3759aSAndreas Gohr $url=ml($IMG,array('cache'=>$_REQUEST['cache'])); 10446de3759aSAndreas Gohr $src=ml($IMG,array('cache'=>$_REQUEST['cache'],'w'=>$w,'h'=>$h)); 104555efc227SAndreas Gohr 10462684e50aSAndreas Gohr //prepare attributes 104755efc227SAndreas Gohr $alt=tpl_img_getTag('Simple.Title'); 10482684e50aSAndreas Gohr $p = array(); 10492684e50aSAndreas Gohr if($w) $p['width'] = $w; 10502684e50aSAndreas Gohr if($h) $p['height'] = $h; 10512684e50aSAndreas Gohr $p['class'] = 'img_detail'; 10522684e50aSAndreas Gohr if($alt){ 10532684e50aSAndreas Gohr $p['alt'] = $alt; 10542684e50aSAndreas Gohr $p['title'] = $alt; 10552684e50aSAndreas Gohr }else{ 10562684e50aSAndreas Gohr $p['alt'] = ''; 10572684e50aSAndreas Gohr } 10582684e50aSAndreas Gohr $p = buildAttributes($p); 105955efc227SAndreas Gohr 106055efc227SAndreas Gohr print '<a href="'.$url.'">'; 10616de3759aSAndreas Gohr print '<img src="'.$src.'" '.$p.'/>'; 106255efc227SAndreas Gohr print '</a>'; 106354e95700STom N Harris return true; 106455efc227SAndreas Gohr} 106555efc227SAndreas Gohr 10667367b368SAndreas Gohr/** 10677367b368SAndreas Gohr * This function inserts a 1x1 pixel gif which in reality 1068c66972f2SAdrian Lang * is the indexer function. 10697367b368SAndreas Gohr * 10707367b368SAndreas Gohr * Should be called somewhere at the very end of the main.php 10717367b368SAndreas Gohr * template 10727367b368SAndreas Gohr */ 10737367b368SAndreas Gohrfunction tpl_indexerWebBug(){ 10747367b368SAndreas Gohr global $ID; 10751dad36f5SAndreas Gohr global $INFO; 107654e95700STom N Harris if(!$INFO['exists']) return false; 10771dad36f5SAndreas Gohr 107854e95700STom N Harris if(isHiddenPage($ID)) return false; //no need to index hidden pages 10790dc92c6fSAndreas Gohr 10807367b368SAndreas Gohr $p = array(); 1081b6c6979fSAndreas Gohr $p['src'] = DOKU_BASE.'lib/exe/indexer.php?id='.rawurlencode($ID). 1082e68c51baSAndreas Gohr '&'.time(); 10837367b368SAndreas Gohr $p['width'] = 1; 10847367b368SAndreas Gohr $p['height'] = 1; 10857367b368SAndreas Gohr $p['alt'] = ''; 10867367b368SAndreas Gohr $att = buildAttributes($p); 10877367b368SAndreas Gohr print "<img $att />"; 108854e95700STom N Harris return true; 10897367b368SAndreas Gohr} 10907367b368SAndreas Gohr 109178d4e784SEsther Brunner// configuration methods 109278d4e784SEsther Brunner/** 109378d4e784SEsther Brunner * tpl_getConf($id) 109478d4e784SEsther Brunner * 109578d4e784SEsther Brunner * use this function to access template configuration variables 109678d4e784SEsther Brunner */ 109778d4e784SEsther Brunnerfunction tpl_getConf($id){ 109878d4e784SEsther Brunner global $conf; 109978d4e784SEsther Brunner global $tpl_configloaded; 110078d4e784SEsther Brunner 110178d4e784SEsther Brunner $tpl = $conf['template']; 110278d4e784SEsther Brunner 110378d4e784SEsther Brunner if (!$tpl_configloaded){ 110478d4e784SEsther Brunner $tconf = tpl_loadConfig(); 110578d4e784SEsther Brunner if ($tconf !== false){ 110678d4e784SEsther Brunner foreach ($tconf as $key => $value){ 110778d4e784SEsther Brunner if (isset($conf['tpl'][$tpl][$key])) continue; 110878d4e784SEsther Brunner $conf['tpl'][$tpl][$key] = $value; 110978d4e784SEsther Brunner } 111078d4e784SEsther Brunner $tpl_configloaded = true; 111178d4e784SEsther Brunner } 111278d4e784SEsther Brunner } 111378d4e784SEsther Brunner 111478d4e784SEsther Brunner return $conf['tpl'][$tpl][$id]; 111578d4e784SEsther Brunner} 111678d4e784SEsther Brunner 111778d4e784SEsther Brunner/** 111878d4e784SEsther Brunner * tpl_loadConfig() 111978d4e784SEsther Brunner * reads all template configuration variables 112078d4e784SEsther Brunner * this function is automatically called by tpl_getConf() 112178d4e784SEsther Brunner */ 112278d4e784SEsther Brunnerfunction tpl_loadConfig(){ 112378d4e784SEsther Brunner 112478d4e784SEsther Brunner $file = DOKU_TPLINC.'/conf/default.php'; 112578d4e784SEsther Brunner $conf = array(); 112678d4e784SEsther Brunner 112778d4e784SEsther Brunner if (!@file_exists($file)) return false; 112878d4e784SEsther Brunner 112978d4e784SEsther Brunner // load default config file 113078d4e784SEsther Brunner include($file); 113178d4e784SEsther Brunner 113278d4e784SEsther Brunner return $conf; 113378d4e784SEsther Brunner} 113478d4e784SEsther Brunner 11353df72098SAndreas Gohr/** 11363df72098SAndreas Gohr * prints the "main content" in the mediamanger popup 11373df72098SAndreas Gohr * 11383df72098SAndreas Gohr * Depending on the user's actions this may be a list of 11393df72098SAndreas Gohr * files in a namespace, the meta editing dialog or 11403df72098SAndreas Gohr * a message of referencing pages 11413df72098SAndreas Gohr * 11423df72098SAndreas Gohr * Only allowed in mediamanager.php 11433df72098SAndreas Gohr * 1144c182313eSAndreas Gohr * @triggers MEDIAMANAGER_CONTENT_OUTPUT 1145c182313eSAndreas Gohr * @param bool $fromajax - set true when calling this function via ajax 11463df72098SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 11473df72098SAndreas Gohr */ 1148c182313eSAndreas Gohrfunction tpl_mediaContent($fromajax=false){ 11493df72098SAndreas Gohr global $IMG; 11503df72098SAndreas Gohr global $AUTH; 11513df72098SAndreas Gohr global $INUSE; 11523df72098SAndreas Gohr global $NS; 11533df72098SAndreas Gohr global $JUMPTO; 11543df72098SAndreas Gohr 1155c9f56829SAndreas Gohr if(is_array($_REQUEST['do'])){ 1156c9f56829SAndreas Gohr $do = array_shift(array_keys($_REQUEST['do'])); 11573df72098SAndreas Gohr }else{ 1158c182313eSAndreas Gohr $do = $_REQUEST['do']; 11593df72098SAndreas Gohr } 1160c182313eSAndreas Gohr if(in_array($do,array('save','cancel'))) $do = ''; 1161c182313eSAndreas Gohr 1162c182313eSAndreas Gohr if(!$do){ 1163c182313eSAndreas Gohr if($_REQUEST['edit']){ 1164c182313eSAndreas Gohr $do = 'metaform'; 1165c182313eSAndreas Gohr }elseif(is_array($INUSE)){ 1166c182313eSAndreas Gohr $do = 'filesinuse'; 1167c182313eSAndreas Gohr }else{ 1168c182313eSAndreas Gohr $do = 'filelist'; 1169c182313eSAndreas Gohr } 1170c182313eSAndreas Gohr } 1171c182313eSAndreas Gohr 1172c182313eSAndreas Gohr // output the content pane, wrapped in an event. 1173c182313eSAndreas Gohr if(!$fromajax) ptln('<div id="media__content">'); 1174c182313eSAndreas Gohr $data = array( 'do' => $do); 1175c182313eSAndreas Gohr $evt = new Doku_Event('MEDIAMANAGER_CONTENT_OUTPUT', $data); 1176c182313eSAndreas Gohr if ($evt->advise_before()) { 1177c182313eSAndreas Gohr $do = $data['do']; 1178c182313eSAndreas Gohr if($do == 'metaform'){ 1179c182313eSAndreas Gohr media_metaform($IMG,$AUTH); 1180c182313eSAndreas Gohr }elseif($do == 'filesinuse'){ 1181c182313eSAndreas Gohr media_filesinuse($INUSE,$IMG); 1182c182313eSAndreas Gohr }elseif($do == 'filelist'){ 1183c182313eSAndreas Gohr media_filelist($NS,$AUTH,$JUMPTO); 1184c9f56829SAndreas Gohr }elseif($do == 'searchlist'){ 1185c9f56829SAndreas Gohr media_searchlist($_REQUEST['q'],$NS,$AUTH); 1186c182313eSAndreas Gohr }else{ 1187c182313eSAndreas Gohr msg('Unknown action '.hsc($do),-1); 1188c182313eSAndreas Gohr } 1189c182313eSAndreas Gohr } 1190c182313eSAndreas Gohr $evt->advise_after(); 1191c182313eSAndreas Gohr unset($evt); 1192c182313eSAndreas Gohr if(!$fromajax) ptln('</div>'); 1193c182313eSAndreas Gohr 11943df72098SAndreas Gohr} 11953df72098SAndreas Gohr 11963df72098SAndreas Gohr/** 11973df72098SAndreas Gohr * prints the namespace tree in the mediamanger popup 11983df72098SAndreas Gohr * 11993df72098SAndreas Gohr * Only allowed in mediamanager.php 12003df72098SAndreas Gohr * 12013df72098SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 12023df72098SAndreas Gohr */ 12033df72098SAndreas Gohrfunction tpl_mediaTree(){ 12043df72098SAndreas Gohr global $NS; 12053df72098SAndreas Gohr 12063df72098SAndreas Gohr ptln('<div id="media__tree">'); 12073df72098SAndreas Gohr media_nstree($NS); 12083df72098SAndreas Gohr ptln('</div>'); 12093df72098SAndreas Gohr} 12103df72098SAndreas Gohr 1211a00de5b5SAndreas Gohr 1212a00de5b5SAndreas Gohr/** 1213a00de5b5SAndreas Gohr * Print a dropdown menu with all DokuWiki actions 1214a00de5b5SAndreas Gohr * 1215a00de5b5SAndreas Gohr * Note: this will not use any pretty URLs 1216a00de5b5SAndreas Gohr * 1217a00de5b5SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1218a00de5b5SAndreas Gohr */ 1219a00de5b5SAndreas Gohrfunction tpl_actiondropdown($empty='',$button='>'){ 1220a00de5b5SAndreas Gohr global $ID; 1221a00de5b5SAndreas Gohr global $INFO; 1222a00de5b5SAndreas Gohr global $REV; 1223a00de5b5SAndreas Gohr global $ACT; 1224a00de5b5SAndreas Gohr global $conf; 1225a00de5b5SAndreas Gohr global $lang; 1226a00de5b5SAndreas Gohr global $auth; 1227a00de5b5SAndreas Gohr 1228a00de5b5SAndreas Gohr 1229a00de5b5SAndreas Gohr echo '<form method="post" accept-charset="utf-8">'; #FIXME action 1230a00de5b5SAndreas Gohr echo '<input type="hidden" name="id" value="'.$ID.'" />'; 1231a00de5b5SAndreas Gohr if($REV) echo '<input type="hidden" name="rev" value="'.$REV.'" />'; 1232a00de5b5SAndreas Gohr echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'; 1233a00de5b5SAndreas Gohr 1234a00de5b5SAndreas Gohr echo '<select name="do" id="action__selector" class="edit">'; 1235a00de5b5SAndreas Gohr echo '<option value="">'.$empty.'</option>'; 1236a00de5b5SAndreas Gohr 1237a00de5b5SAndreas Gohr echo '<optgroup label=" — ">'; 1238a00de5b5SAndreas Gohr // 'edit' - most complicated type, we need to decide on current action 1239a00de5b5SAndreas Gohr if($ACT == 'show' || $ACT == 'search'){ 1240a00de5b5SAndreas Gohr if($INFO['writable']){ 1241a00de5b5SAndreas Gohr if(!empty($INFO['draft'])) { 1242a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_draft'].'</option>'; 1243a00de5b5SAndreas Gohr } else { 1244a00de5b5SAndreas Gohr if($INFO['exists']){ 1245a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_edit'].'</option>'; 1246a00de5b5SAndreas Gohr }else{ 1247a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_create'].'</option>'; 1248a00de5b5SAndreas Gohr } 1249a00de5b5SAndreas Gohr } 1250a00de5b5SAndreas Gohr }else if(actionOK('source')) { //pseudo action 1251a00de5b5SAndreas Gohr echo '<option value="edit">'.$lang['btn_source'].'</option>'; 1252a00de5b5SAndreas Gohr } 1253a00de5b5SAndreas Gohr }else{ 1254a00de5b5SAndreas Gohr echo '<option value="show">'.$lang['btn_show'].'</option>'; 1255a00de5b5SAndreas Gohr } 1256a00de5b5SAndreas Gohr 1257a00de5b5SAndreas Gohr echo '<option value="revisions">'.$lang['btn_revs'].'</option>'; 12581246e016SAndreas Gohr if($INFO['ismanager'] && $REV && $INFO['writable'] && actionOK('revert')){ 12591246e016SAndreas Gohr echo '<option value="revert">'.$lang['btn_revert'].'</option>'; 12601246e016SAndreas Gohr } 1261a00de5b5SAndreas Gohr echo '<option value="backlink">'.$lang['btn_backlink'].'</option>'; 1262a00de5b5SAndreas Gohr echo '</optgroup>'; 1263a00de5b5SAndreas Gohr 1264a00de5b5SAndreas Gohr echo '<optgroup label=" — ">'; 1265a00de5b5SAndreas Gohr echo '<option value="recent">'.$lang['btn_recent'].'</option>'; 1266a00de5b5SAndreas Gohr echo '<option value="index">'.$lang['btn_index'].'</option>'; 1267a00de5b5SAndreas Gohr echo '</optgroup>'; 1268a00de5b5SAndreas Gohr 1269a00de5b5SAndreas Gohr echo '<optgroup label=" — ">'; 1270a00de5b5SAndreas Gohr if($conf['useacl'] && $auth){ 1271a00de5b5SAndreas Gohr if($_SERVER['REMOTE_USER']){ 1272a00de5b5SAndreas Gohr echo '<option value="logout">'.$lang['btn_logout'].'</option>'; 1273a00de5b5SAndreas Gohr }else{ 1274a00de5b5SAndreas Gohr echo '<option value="login">'.$lang['btn_login'].'</option>'; 1275a00de5b5SAndreas Gohr } 1276a00de5b5SAndreas Gohr } 1277a00de5b5SAndreas Gohr 1278a00de5b5SAndreas Gohr if($conf['useacl'] && $auth && $_SERVER['REMOTE_USER'] && 1279a00de5b5SAndreas Gohr $auth->canDo('Profile') && ($ACT!='profile')){ 1280a00de5b5SAndreas Gohr echo '<option value="profile">'.$lang['btn_profile'].'</option>'; 1281a00de5b5SAndreas Gohr } 1282a00de5b5SAndreas Gohr 12835b75cd1fSAdrian Lang if($conf['useacl'] && $auth && $ACT == 'show' && $conf['subscribers']){ 1284a00de5b5SAndreas Gohr if($_SERVER['REMOTE_USER']){ 1285a00de5b5SAndreas Gohr echo '<option value="subscribe">'.$lang['btn_subscribe'].'</option>'; 1286a00de5b5SAndreas Gohr } 1287a00de5b5SAndreas Gohr } 1288a00de5b5SAndreas Gohr 1289a00de5b5SAndreas Gohr if($INFO['ismanager']){ 1290a00de5b5SAndreas Gohr echo '<option value="admin">'.$lang['btn_admin'].'</option>'; 1291a00de5b5SAndreas Gohr } 1292a00de5b5SAndreas Gohr echo '</optgroup>'; 1293a00de5b5SAndreas Gohr 1294a00de5b5SAndreas Gohr echo '</select>'; 1295a00de5b5SAndreas Gohr echo '<input type="submit" value="'.$button.'" id="action__selectorbtn" />'; 1296a00de5b5SAndreas Gohr echo '</form>'; 1297a00de5b5SAndreas Gohr} 1298a00de5b5SAndreas Gohr 1299066fee30SAndreas Gohr/** 1300066fee30SAndreas Gohr * Print a informational line about the used license 1301066fee30SAndreas Gohr * 1302066fee30SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1303066fee30SAndreas Gohr * @param string $img - print image? (|button|badge) 1304066fee30SAndreas Gohr * @param bool $return - when true don't print, but return HTML 1305066fee30SAndreas Gohr */ 13064cefd216SMichael Klierfunction tpl_license($img='badge',$imgonly=false,$return=false){ 1307066fee30SAndreas Gohr global $license; 1308066fee30SAndreas Gohr global $conf; 1309066fee30SAndreas Gohr global $lang; 1310066fee30SAndreas Gohr if(!$conf['license']) return ''; 1311066fee30SAndreas Gohr if(!is_array($license[$conf['license']])) return ''; 1312066fee30SAndreas Gohr $lic = $license[$conf['license']]; 1313066fee30SAndreas Gohr 13144cefd216SMichael Klier $out = '<div class="license">'; 1315066fee30SAndreas Gohr if($img){ 1316066fee30SAndreas Gohr $src = license_img($img); 1317066fee30SAndreas Gohr if($src){ 1318066fee30SAndreas Gohr $out .= '<a href="'.$lic['url'].'" rel="license"'; 1319066fee30SAndreas Gohr if($conf['target']['external']) $out .= ' target="'.$conf['target']['external'].'"'; 1320a57c7cafSAnika Henke $out .= '><img src="'.DOKU_BASE.$src.'" class="medialeft lic'.$img.'" alt="'.$lic['name'].'" /></a> '; 1321066fee30SAndreas Gohr } 1322066fee30SAndreas Gohr } 13234cefd216SMichael Klier if(!$imgonly) { 1324066fee30SAndreas Gohr $out .= $lang['license']; 1325066fee30SAndreas Gohr $out .= '<a href="'.$lic['url'].'" rel="license" class="urlextern"'; 1326c66972f2SAdrian Lang if(isset($conf['target']['external'])) $out .= ' target="'.$conf['target']['external'].'"'; 1327066fee30SAndreas Gohr $out .= '>'.$lic['name'].'</a>'; 13284cefd216SMichael Klier } 1329c2a66484SKazutaka Miyasaka $out .= '</div>'; 1330066fee30SAndreas Gohr 1331066fee30SAndreas Gohr if($return) return $out; 1332066fee30SAndreas Gohr echo $out; 1333066fee30SAndreas Gohr} 1334066fee30SAndreas Gohr 1335a81910eeSAndreas Gohr 1336a81910eeSAndreas Gohr/** 1337a81910eeSAndreas Gohr * Includes the rendered XHTML of a given page 1338a81910eeSAndreas Gohr * 1339a81910eeSAndreas Gohr * This function is useful to populate sidebars or similar features in a 1340a81910eeSAndreas Gohr * template 1341a81910eeSAndreas Gohr */ 1342a81910eeSAndreas Gohrfunction tpl_include_page($pageid,$print=true){ 1343a81910eeSAndreas Gohr global $ID; 1344a81910eeSAndreas Gohr $oldid = $ID; 1345a81910eeSAndreas Gohr $html = p_wiki_xhtml($pageid,'',false); 1346a81910eeSAndreas Gohr $ID = $oldid; 1347a81910eeSAndreas Gohr 1348a81910eeSAndreas Gohr if(!$print) return $html; 1349a81910eeSAndreas Gohr echo $html; 1350a81910eeSAndreas Gohr} 1351a81910eeSAndreas Gohr 13525b75cd1fSAdrian Lang/** 13535b75cd1fSAdrian Lang * Display the subscribe form 13545b75cd1fSAdrian Lang * 13555b75cd1fSAdrian Lang * @author Adrian Lang <lang@cosmocode.de> 13565b75cd1fSAdrian Lang */ 13575b75cd1fSAdrian Langfunction tpl_subscribe() { 13585b75cd1fSAdrian Lang global $INFO; 13595b75cd1fSAdrian Lang global $ID; 13605b75cd1fSAdrian Lang global $lang; 13615b75cd1fSAdrian Lang 13625b75cd1fSAdrian Lang echo p_locale_xhtml('subscr_form'); 13635b75cd1fSAdrian Lang echo '<h2>' . $lang['subscr_m_current_header'] . '</h2>'; 136415741132SAndreas Gohr echo '<div class="level2">'; 13655b75cd1fSAdrian Lang if ($INFO['subscribed'] === false) { 13665b75cd1fSAdrian Lang echo '<p>' . $lang['subscr_m_not_subscribed'] . '</p>'; 13675b75cd1fSAdrian Lang } else { 13685b75cd1fSAdrian Lang echo '<ul>'; 13695b75cd1fSAdrian Lang foreach($INFO['subscribed'] as $sub) { 1370*056c2049SAndreas Gohr echo '<li><div class="li">'; 13715b75cd1fSAdrian Lang if ($sub['target'] !== $ID) { 1372*056c2049SAndreas Gohr echo '<code class="ns">'.hsc(prettyprint_id($sub['target'])).'</code>'; 13735b75cd1fSAdrian Lang } else { 1374*056c2049SAndreas Gohr echo '<code class="page">'.hsc(prettyprint_id($sub['target'])).'</code>'; 13755b75cd1fSAdrian Lang } 137615741132SAndreas Gohr $sstl = $lang['subscr_style_'.$sub['style']]; 137715741132SAndreas Gohr if(!$sstl) $sstl = hsc($sub['style']); 1378*056c2049SAndreas Gohr echo ' ('.$sstl.') '; 137915741132SAndreas Gohr 1380*056c2049SAndreas Gohr echo '<a href="'.wl($ID,array('do'=>'subscribe','sub_target'=>$sub['target'],'sub_style'=>$sub['style'],'sub_action'=>'unsubscribe')).'" class="unsubscribe">'.$lang['subscr_m_unsubscribe'].'</a>'; 1381*056c2049SAndreas Gohr 1382*056c2049SAndreas Gohr 1383*056c2049SAndreas Gohr echo '</div></li>'; 13845b75cd1fSAdrian Lang } 13855b75cd1fSAdrian Lang echo '</ul>'; 13865b75cd1fSAdrian Lang } 138715741132SAndreas Gohr echo '</div>'; 13885b75cd1fSAdrian Lang 138915741132SAndreas Gohr // Add new subscription form 13905b75cd1fSAdrian Lang echo '<h2>' . $lang['subscr_m_new_header'] . '</h2>'; 139115741132SAndreas Gohr echo '<div class="level2">'; 13925b75cd1fSAdrian Lang $ns = getNS($ID).':'; 139315741132SAndreas Gohr $targets = array( 139415741132SAndreas Gohr $ID => '<code class="page">'.prettyprint_id($ID).'</code>', 139515741132SAndreas Gohr $ns => '<code class="ns">'.prettyprint_id($ns).'</code>', 139615741132SAndreas Gohr ); 139715741132SAndreas Gohr $styles = array( 139815741132SAndreas Gohr 'every' => $lang['subscr_style_every'], 139915741132SAndreas Gohr 'digest' => $lang['subscr_style_digest'], 140015741132SAndreas Gohr 'list' => $lang['subscr_style_list'], 140115741132SAndreas Gohr ); 140215741132SAndreas Gohr 1403*056c2049SAndreas Gohr $form = new Doku_Form(array('id' => 'subscribe__form')); 1404*056c2049SAndreas Gohr $form->startFieldset($lang['subscr_m_subscribe']); 1405*056c2049SAndreas Gohr $form->addRadioSet('sub_target', $targets); 1406*056c2049SAndreas Gohr $form->startFieldset($lang['subscr_m_receive']); 1407*056c2049SAndreas Gohr $form->addRadioSet('sub_style', $styles); 1408*056c2049SAndreas Gohr $form->addHidden('sub_action', 'subscribe'); 1409*056c2049SAndreas Gohr $form->addHidden('do', 'subscribe'); 1410*056c2049SAndreas Gohr $form->addHidden('id', $ID); 1411*056c2049SAndreas Gohr $form->endFieldset(); 14125b75cd1fSAdrian Lang $form->addElement(form_makeButton('submit', 'subscribe', $lang['subscr_m_subscribe'])); 14135b75cd1fSAdrian Lang html_form('SUBSCRIBE', $form); 141415741132SAndreas Gohr echo '</div>'; 14155b75cd1fSAdrian Lang} 14165b75cd1fSAdrian Lang 1417b8595a66SAndreas Gohr//Setup VIM: ex: et ts=4 enc=utf-8 : 1418a00de5b5SAndreas Gohr 1419