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/** 12ac7a515fSAndreas Gohr * Access a template file 13ac7a515fSAndreas Gohr * 14ac7a515fSAndreas Gohr * Returns the path to the given file inside the current template, uses 15ac7a515fSAndreas Gohr * default template if the custom version doesn't exist. 165a892029SAndreas Gohr * 175a892029SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 18ac7a515fSAndreas Gohr * @param string $file 19ac7a515fSAndreas Gohr * @return string 205a892029SAndreas Gohr */ 21ac7a515fSAndreas Gohrfunction template($file) { 225a892029SAndreas Gohr global $conf; 235a892029SAndreas Gohr 24ac7a515fSAndreas Gohr if(@is_readable(DOKU_INC.'lib/tpl/'.$conf['template'].'/'.$file)) 25ac7a515fSAndreas Gohr return DOKU_INC.'lib/tpl/'.$conf['template'].'/'.$file; 265a892029SAndreas Gohr 27ac7a515fSAndreas Gohr return DOKU_INC.'lib/tpl/dokuwiki/'.$file; 285a892029SAndreas Gohr} 295a892029SAndreas Gohr 30c4766956SAndreas Gohr/** 31c4766956SAndreas Gohr * Convenience function to access template dir from local FS 32c4766956SAndreas Gohr * 33c4766956SAndreas Gohr * This replaces the deprecated DOKU_TPLINC constant 34c4766956SAndreas Gohr * 35c4766956SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 36afb2c082SAndreas Gohr * @param string $tpl The template to use, default to current one 37ac7a515fSAndreas Gohr * @return string 38c4766956SAndreas Gohr */ 39afb2c082SAndreas Gohrfunction tpl_incdir($tpl='') { 4075b14482SAndreas Gohr global $conf; 41afb2c082SAndreas Gohr if(!$tpl) $tpl = $conf['template']; 42afb2c082SAndreas Gohr return DOKU_INC.'lib/tpl/'.$tpl.'/'; 43c4766956SAndreas Gohr} 44c4766956SAndreas Gohr 45c4766956SAndreas Gohr/** 46c4766956SAndreas Gohr * Convenience function to access template dir from web 47c4766956SAndreas Gohr * 48c4766956SAndreas Gohr * This replaces the deprecated DOKU_TPL constant 49c4766956SAndreas Gohr * 50c4766956SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 51afb2c082SAndreas Gohr * @param string $tpl The template to use, default to current one 52ac7a515fSAndreas Gohr * @return string 53c4766956SAndreas Gohr */ 5499dca513SAndreas Gohrfunction tpl_basedir($tpl='') { 5575b14482SAndreas Gohr global $conf; 56afb2c082SAndreas Gohr if(!$tpl) $tpl = $conf['template']; 57dcd4911eSMichael Hamann return DOKU_BASE.'lib/tpl/'.$tpl.'/'; 58c4766956SAndreas Gohr} 59c4766956SAndreas Gohr 605a892029SAndreas Gohr/** 616b13307fSandi * Print the content 626b13307fSandi * 636b13307fSandi * This function is used for printing all the usual content 646b13307fSandi * (defined by the global $ACT var) by calling the appropriate 656b13307fSandi * outputfunction(s) from html.php 666b13307fSandi * 67ee4c4a1bSAndreas Gohr * Everything that doesn't use the main template file isn't 68ee4c4a1bSAndreas Gohr * handled by this function. ACL stuff is not done here either. 696b13307fSandi * 706b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 7142ea7f44SGerrit Uitslag * 72ac7a515fSAndreas Gohr * @triggers TPL_ACT_RENDER 73ac7a515fSAndreas Gohr * @triggers TPL_CONTENT_DISPLAY 74ac7a515fSAndreas Gohr * @param bool $prependTOC should the TOC be displayed here? 75ac7a515fSAndreas Gohr * @return bool true if any output 766b13307fSandi */ 77b8595a66SAndreas Gohrfunction tpl_content($prependTOC = true) { 787ea0913cSchris global $ACT; 79b8595a66SAndreas Gohr global $INFO; 80b8595a66SAndreas Gohr $INFO['prependTOC'] = $prependTOC; 817ea0913cSchris 827ea0913cSchris ob_start(); 83746855cfSBen Coburn trigger_event('TPL_ACT_RENDER', $ACT, 'tpl_content_core'); 847ea0913cSchris $html_output = ob_get_clean(); 85746855cfSBen Coburn trigger_event('TPL_CONTENT_DISPLAY', $html_output, 'ptln'); 8654e95700STom N Harris 8754e95700STom N Harris return !empty($html_output); 887ea0913cSchris} 897ea0913cSchris 90ac7a515fSAndreas Gohr/** 91ac7a515fSAndreas Gohr * Default Action of TPL_ACT_RENDER 92ac7a515fSAndreas Gohr * 93ac7a515fSAndreas Gohr * @return bool 94ac7a515fSAndreas Gohr */ 95*952acff9SAndreas Gohrfunction tpl_content_core() { 96*952acff9SAndreas Gohr $router = \dokuwiki\ActionRouter::getInstance(); 97*952acff9SAndreas Gohr try { 98*952acff9SAndreas Gohr $router->getAction()->tplContent(); 99*952acff9SAndreas Gohr } catch(\dokuwiki\Action\Exception\FatalException $e) { 100*952acff9SAndreas Gohr // there was no content for the action 101*952acff9SAndreas Gohr msg(hsc($e->getMessage()), -1); 10254e95700STom N Harris return false; 1036b13307fSandi } 10454e95700STom N Harris return true; 1056b13307fSandi} 1066b13307fSandi 107c19fe9c0Sandi/** 108b8595a66SAndreas Gohr * Places the TOC where the function is called 109b8595a66SAndreas Gohr * 110b8595a66SAndreas Gohr * If you use this you most probably want to call tpl_content with 111b8595a66SAndreas Gohr * a false argument 112b8595a66SAndreas Gohr * 113b8595a66SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 11442ea7f44SGerrit Uitslag * 115ac7a515fSAndreas Gohr * @param bool $return Should the TOC be returned instead to be printed? 116ac7a515fSAndreas Gohr * @return string 117b8595a66SAndreas Gohr */ 118b8595a66SAndreas Gohrfunction tpl_toc($return = false) { 119b8595a66SAndreas Gohr global $TOC; 120b8595a66SAndreas Gohr global $ACT; 121b8595a66SAndreas Gohr global $ID; 122b8595a66SAndreas Gohr global $REV; 123b8595a66SAndreas Gohr global $INFO; 124851f2e89SAnika Henke global $conf; 125ac7a515fSAndreas Gohr global $INPUT; 126b8595a66SAndreas Gohr $toc = array(); 127b8595a66SAndreas Gohr 128b8595a66SAndreas Gohr if(is_array($TOC)) { 129b8595a66SAndreas Gohr // if a TOC was prepared in global scope, always use it 130b8595a66SAndreas Gohr $toc = $TOC; 1313c86d7c9SAndreas Gohr } elseif(($ACT == 'show' || substr($ACT, 0, 6) == 'export') && !$REV && $INFO['exists']) { 132b8595a66SAndreas Gohr // get TOC from metadata, render if neccessary 133e0c26282SGerrit Uitslag $meta = p_get_metadata($ID, '', METADATA_RENDER_USING_CACHE); 134b8595a66SAndreas Gohr if(isset($meta['internal']['toc'])) { 135b8595a66SAndreas Gohr $tocok = $meta['internal']['toc']; 136b8595a66SAndreas Gohr } else { 1372bb0d541Schris $tocok = true; 138b8595a66SAndreas Gohr } 139f87b5dbbSChristopher Smith $toc = isset($meta['description']['tableofcontents']) ? $meta['description']['tableofcontents'] : null; 140851f2e89SAnika Henke if(!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']) { 141b8595a66SAndreas Gohr $toc = array(); 142b8595a66SAndreas Gohr } 143b8595a66SAndreas Gohr } elseif($ACT == 'admin') { 144a61966c5SChristopher Smith // try to load admin plugin TOC 145ac7a515fSAndreas Gohr /** @var $plugin DokuWiki_Admin_Plugin */ 146a61966c5SChristopher Smith if ($plugin = plugin_getRequestAdminPlugin()) { 147b8595a66SAndreas Gohr $toc = $plugin->getTOC(); 148b8595a66SAndreas Gohr $TOC = $toc; // avoid later rebuild 149b8595a66SAndreas Gohr } 150b8595a66SAndreas Gohr } 151b8595a66SAndreas Gohr 1520b17fdc6SAndreas Gohr trigger_event('TPL_TOC_RENDER', $toc, null, false); 153b8595a66SAndreas Gohr $html = html_TOC($toc); 154b8595a66SAndreas Gohr if($return) return $html; 155b8595a66SAndreas Gohr echo $html; 156ac7a515fSAndreas Gohr return ''; 157b8595a66SAndreas Gohr} 158b8595a66SAndreas Gohr 159b8595a66SAndreas Gohr/** 160c19fe9c0Sandi * Handle the admin page contents 161c19fe9c0Sandi * 162c19fe9c0Sandi * @author Andreas Gohr <andi@splitbrain.org> 16342ea7f44SGerrit Uitslag * 16442ea7f44SGerrit Uitslag * @return bool 165c19fe9c0Sandi */ 166c19fe9c0Sandifunction tpl_admin() { 167f8cc712eSAndreas Gohr global $INFO; 168b8595a66SAndreas Gohr global $TOC; 169ac7a515fSAndreas Gohr global $INPUT; 17011e2ce22Schris 171b8595a66SAndreas Gohr $plugin = null; 172ac7a515fSAndreas Gohr $class = $INPUT->str('page'); 173ac7a515fSAndreas Gohr if(!empty($class)) { 17411e2ce22Schris $pluginlist = plugin_list('admin'); 17511e2ce22Schris 176ac7a515fSAndreas Gohr if(in_array($class, $pluginlist)) { 17711e2ce22Schris // attempt to load the plugin 178ac7a515fSAndreas Gohr /** @var $plugin DokuWiki_Admin_Plugin */ 179a04f2bd5SGerrit Uitslag $plugin = plugin_load('admin', $class); 18011e2ce22Schris } 18111e2ce22Schris } 18211e2ce22Schris 183b8595a66SAndreas Gohr if($plugin !== null) { 184b8595a66SAndreas Gohr if(!is_array($TOC)) $TOC = $plugin->getTOC(); //if TOC wasn't requested yet 185b8595a66SAndreas Gohr if($INFO['prependTOC']) tpl_toc(); 186f8cc712eSAndreas Gohr $plugin->html(); 187f8cc712eSAndreas Gohr } else { 1880470c28fSAndreas Gohr $admin = new dokuwiki\Ui\Admin(); 1890470c28fSAndreas Gohr $admin->show(); 190f8cc712eSAndreas Gohr } 19154e95700STom N Harris return true; 192c19fe9c0Sandi} 1936b13307fSandi 1946b13307fSandi/** 1956b13307fSandi * Print the correct HTML meta headers 1966b13307fSandi * 1976b13307fSandi * This has to go into the head section of your template. 1986b13307fSandi * 1996b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 20042ea7f44SGerrit Uitslag * 201ac7a515fSAndreas Gohr * @triggers TPL_METAHEADER_OUTPUT 202ac7a515fSAndreas Gohr * @param bool $alt Should feeds and alternative format links be added? 203ac7a515fSAndreas Gohr * @return bool 2046b13307fSandi */ 205f96fa415SAndreas Gohrfunction tpl_metaheaders($alt = true) { 2066b13307fSandi global $ID; 207d98d4540SBen Coburn global $REV; 2086b13307fSandi global $INFO; 20972e0dc37SAndreas Gohr global $JSINFO; 2106b13307fSandi global $ACT; 2114bb1b5aeSAndreas Gohr global $QUERY; 2126b13307fSandi global $lang; 213dc57ef04Sandi global $conf; 2149c438d6cSMichael Hamann global $updateVersion; 215585bf44eSChristopher Smith /** @var Input $INPUT */ 216585bf44eSChristopher Smith global $INPUT; 2176b13307fSandi 2187bff22c0SAndreas Gohr // prepare the head array 2197bff22c0SAndreas Gohr $head = array(); 2207bff22c0SAndreas Gohr 221202ac28bSMichael Klier // prepare seed for js and css 222cd997f93SAndreas Gohr $tseed = $updateVersion; 223202ac28bSMichael Klier $depends = getConfigFiles('main'); 22484e76a7eSAndreas Gohr $depends[] = DOKU_CONF."tpl/".$conf['template']."/style.ini"; 225cd997f93SAndreas Gohr foreach($depends as $f) $tseed .= @filemtime($f); 226cd997f93SAndreas Gohr $tseed = md5($tseed); 2277bff22c0SAndreas Gohr 2286b13307fSandi // the usual stuff 2293f803e5eSGina Haeussge $head['meta'][] = array('name'=> 'generator', 'content'=> 'DokuWiki'); 23063cf4192Ssarehag if(actionOK('search')) { 231ac7a515fSAndreas Gohr $head['link'][] = array( 232ac7a515fSAndreas Gohr 'rel' => 'search', 'type'=> 'application/opensearchdescription+xml', 233ac7a515fSAndreas Gohr 'href'=> DOKU_BASE.'lib/exe/opensearch.php', 'title'=> $conf['title'] 234ac7a515fSAndreas Gohr ); 23563cf4192Ssarehag } 23663cf4192Ssarehag 237f4f47358SBen Coburn $head['link'][] = array('rel'=> 'start', 'href'=> DOKU_BASE); 2387aedde2eSGina Haeussge if(actionOK('index')) { 239ac7a515fSAndreas Gohr $head['link'][] = array( 240ac7a515fSAndreas Gohr 'rel' => 'contents', 'href'=> wl($ID, 'do=index', false, '&'), 241ac7a515fSAndreas Gohr 'title'=> $lang['btn_index'] 242ac7a515fSAndreas Gohr ); 2437aedde2eSGina Haeussge } 244f96fa415SAndreas Gohr 245f96fa415SAndreas Gohr if($alt) { 24654be1338SGerrit Uitslag if(actionOK('rss')) { 247ac7a515fSAndreas Gohr $head['link'][] = array( 248ac7a515fSAndreas Gohr 'rel' => 'alternate', 'type'=> 'application/rss+xml', 249a1288caeSGerrit Uitslag 'title'=> $lang['btn_recent'], 'href'=> DOKU_BASE.'feed.php' 250ac7a515fSAndreas Gohr ); 251ac7a515fSAndreas Gohr $head['link'][] = array( 252ac7a515fSAndreas Gohr 'rel' => 'alternate', 'type'=> 'application/rss+xml', 253a1288caeSGerrit Uitslag 'title'=> $lang['currentns'], 254ac7a515fSAndreas Gohr 'href' => DOKU_BASE.'feed.php?mode=list&ns='.$INFO['namespace'] 255ac7a515fSAndreas Gohr ); 25654be1338SGerrit Uitslag } 257c35f3875SAndreas Gohr if(($ACT == 'show' || $ACT == 'search') && $INFO['writable']) { 258ac7a515fSAndreas Gohr $head['link'][] = array( 259ac7a515fSAndreas Gohr 'rel' => 'edit', 260715bdf1fSAndreas Gohr 'title'=> $lang['btn_edit'], 261ac7a515fSAndreas Gohr 'href' => wl($ID, 'do=edit', false, '&') 262ac7a515fSAndreas Gohr ); 263c35f3875SAndreas Gohr } 264c35f3875SAndreas Gohr 26554be1338SGerrit Uitslag if(actionOK('rss') && $ACT == 'search') { 266ac7a515fSAndreas Gohr $head['link'][] = array( 267ac7a515fSAndreas Gohr 'rel' => 'alternate', 'type'=> 'application/rss+xml', 268a1288caeSGerrit Uitslag 'title'=> $lang['searchresult'], 269ac7a515fSAndreas Gohr 'href' => DOKU_BASE.'feed.php?mode=search&q='.$QUERY 270ac7a515fSAndreas Gohr ); 2714bb1b5aeSAndreas Gohr } 272bae36d94SAndreas Gohr 273bae36d94SAndreas Gohr if(actionOK('export_xhtml')) { 274ac7a515fSAndreas Gohr $head['link'][] = array( 275a1288caeSGerrit Uitslag 'rel' => 'alternate', 'type'=> 'text/html', 'title'=> $lang['plainhtml'], 276ac7a515fSAndreas Gohr 'href'=> exportlink($ID, 'xhtml', '', false, '&') 277ac7a515fSAndreas Gohr ); 278bae36d94SAndreas Gohr } 279bae36d94SAndreas Gohr 280bae36d94SAndreas Gohr if(actionOK('export_raw')) { 281ac7a515fSAndreas Gohr $head['link'][] = array( 282a1288caeSGerrit Uitslag 'rel' => 'alternate', 'type'=> 'text/plain', 'title'=> $lang['wikimarkup'], 283ac7a515fSAndreas Gohr 'href'=> exportlink($ID, 'raw', '', false, '&') 284ac7a515fSAndreas Gohr ); 285f96fa415SAndreas Gohr } 286bae36d94SAndreas Gohr } 2876b13307fSandi 2886b13307fSandi // setup robot tags apropriate for different modes 2894f2e0004STim Weber if(($ACT == 'show' || $ACT == 'export_xhtml') && !$REV) { 2906b13307fSandi if($INFO['exists']) { 2916b13307fSandi //delay indexing: 29296cbfd74SAndreas Gohr if(!isHiddenPage($ID) && (time() - $INFO['lastmod']) >= $conf['indexdelay']) { 2937bff22c0SAndreas Gohr $head['meta'][] = array('name'=> 'robots', 'content'=> 'index,follow'); 2946b13307fSandi } else { 2957bff22c0SAndreas Gohr $head['meta'][] = array('name'=> 'robots', 'content'=> 'noindex,nofollow'); 2966b13307fSandi } 29701f9be51SAnika Henke $canonicalUrl = wl($ID, '', true, '&'); 29801f9be51SAnika Henke if ($ID == $conf['start']) { 29901f9be51SAnika Henke $canonicalUrl = DOKU_URL; 30001f9be51SAnika Henke } 30101f9be51SAnika Henke $head['link'][] = array('rel'=> 'canonical', 'href'=> $canonicalUrl); 3026b13307fSandi } else { 3037bff22c0SAndreas Gohr $head['meta'][] = array('name'=> 'robots', 'content'=> 'noindex,follow'); 3046b13307fSandi } 3057a24876fSAndreas Gohr } elseif(defined('DOKU_MEDIADETAIL')) { 3067bff22c0SAndreas Gohr $head['meta'][] = array('name'=> 'robots', 'content'=> 'index,follow'); 3076b13307fSandi } else { 3087bff22c0SAndreas Gohr $head['meta'][] = array('name'=> 'robots', 'content'=> 'noindex,nofollow'); 3096b13307fSandi } 3106b13307fSandi 311831800b8SAndreas Gohr // set metadata 312831800b8SAndreas Gohr if($ACT == 'show' || $ACT == 'export_xhtml') { 313831800b8SAndreas Gohr // keywords (explicit or implicit) 314bb4866bdSchris if(!empty($INFO['meta']['subject'])) { 3157bff22c0SAndreas Gohr $head['meta'][] = array('name'=> 'keywords', 'content'=> join(',', $INFO['meta']['subject'])); 316831800b8SAndreas Gohr } else { 3177bff22c0SAndreas Gohr $head['meta'][] = array('name'=> 'keywords', 'content'=> str_replace(':', ',', $ID)); 318831800b8SAndreas Gohr } 319831800b8SAndreas Gohr } 320831800b8SAndreas Gohr 32178a6aeb1SAndreas Gohr // load stylesheets 322ac7a515fSAndreas Gohr $head['link'][] = array( 323ac7a515fSAndreas Gohr 'rel' => 'stylesheet', 'type'=> 'text/css', 324e283bd6cSAnika Henke 'href'=> DOKU_BASE.'lib/exe/css.php?t='.rawurlencode($conf['template']).'&tseed='.$tseed 325ac7a515fSAndreas Gohr ); 326bad31ae9SAndreas Gohr 3278bbcb611SAndreas Gohr // make $INFO and other vars available to JavaScripts 328463d4a65SAndreas Gohr $json = new JSON(); 32972e0dc37SAndreas Gohr $script = "var NS='".$INFO['namespace']."';"; 330585bf44eSChristopher Smith if($conf['useacl'] && $INPUT->server->str('REMOTE_USER')) { 33172e0dc37SAndreas Gohr $script .= "var SIG='".toolbar_signature()."';"; 332c591aabeSAndreas Gohr } 33372e0dc37SAndreas Gohr $script .= 'var JSINFO = '.$json->encode($JSINFO).';'; 33485f81679SAdrian Lang $head['script'][] = array('type'=> 'text/javascript', '_data'=> $script); 3358bbcb611SAndreas Gohr 33661537d47SAndreas Gohr // load jquery 337fa078663SAndreas Gohr $jquery = getCdnUrls(); 338fa078663SAndreas Gohr foreach($jquery as $src) { 33961537d47SAndreas Gohr $head['script'][] = array( 340fa078663SAndreas Gohr 'type' => 'text/javascript', 'charset' => 'utf-8', '_data' => '', 'src' => $src 34161537d47SAndreas Gohr ); 34261537d47SAndreas Gohr } 34361537d47SAndreas Gohr 34461537d47SAndreas Gohr // load our javascript dispatcher 345ac7a515fSAndreas Gohr $head['script'][] = array( 346ac7a515fSAndreas Gohr 'type'=> 'text/javascript', 'charset'=> 'utf-8', '_data'=> '', 347e283bd6cSAnika Henke 'src' => DOKU_BASE.'lib/exe/js.php'.'?t='.rawurlencode($conf['template']).'&tseed='.$tseed 348ac7a515fSAndreas Gohr ); 3497bff22c0SAndreas Gohr 3507bff22c0SAndreas Gohr // trigger event here 351016b6153SAndreas Gohr trigger_event('TPL_METAHEADER_OUTPUT', $head, '_tpl_metaheaders_action', true); 35254e95700STom N Harris return true; 3537bff22c0SAndreas Gohr} 3547bff22c0SAndreas Gohr 3557bff22c0SAndreas Gohr/** 3567bff22c0SAndreas Gohr * prints the array build by tpl_metaheaders 3577bff22c0SAndreas Gohr * 3587bff22c0SAndreas Gohr * $data is an array of different header tags. Each tag can have multiple 3597bff22c0SAndreas Gohr * instances. Attributes are given as key value pairs. Values will be HTML 3607bff22c0SAndreas Gohr * encoded automatically so they should be provided as is in the $data array. 3617bff22c0SAndreas Gohr * 36242ea7f44SGerrit Uitslag * For tags having a body attribute specify the body data in the special 3631304d1dbSAndreas Gohr * attribute '_data'. This field will NOT BE ESCAPED automatically. 3647bff22c0SAndreas Gohr * 3657bff22c0SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 36642ea7f44SGerrit Uitslag * 36742ea7f44SGerrit Uitslag * @param array $data 3687bff22c0SAndreas Gohr */ 3697bff22c0SAndreas Gohrfunction _tpl_metaheaders_action($data) { 3707bff22c0SAndreas Gohr foreach($data as $tag => $inst) { 371427bf9a2SAndreas Gohr if($tag == 'script') { 372427bf9a2SAndreas Gohr echo "<!--[if gte IE 9]><!-->\n"; // no scripts for old IE 373427bf9a2SAndreas Gohr } 3747bff22c0SAndreas Gohr foreach($inst as $attr) { 3759b48e6a1SGerry Weißbach if ( empty($attr) ) { continue; } 3767bff22c0SAndreas Gohr echo '<', $tag, ' ', buildAttributes($attr); 37726afa874SMikhail I. Izmestev if(isset($attr['_data']) || $tag == 'script') { 378e226efe1SAndreas Gohr if($tag == 'script' && $attr['_data']) 37909f791c4SDominik Eckelmann $attr['_data'] = "/*<![CDATA[*/". 380e226efe1SAndreas Gohr $attr['_data']. 38109f791c4SDominik Eckelmann "\n/*!]]>*/"; 382e226efe1SAndreas Gohr 3831304d1dbSAndreas Gohr echo '>', $attr['_data'], '</', $tag, '>'; 3847bff22c0SAndreas Gohr } else { 3857bff22c0SAndreas Gohr echo '/>'; 3867bff22c0SAndreas Gohr } 3877bff22c0SAndreas Gohr echo "\n"; 3887bff22c0SAndreas Gohr } 389427bf9a2SAndreas Gohr if($tag == 'script') { 390427bf9a2SAndreas Gohr echo "<!--<![endif]-->\n"; 391427bf9a2SAndreas Gohr } 3927bff22c0SAndreas Gohr } 3936b13307fSandi} 3946b13307fSandi 3956b13307fSandi/** 3966b13307fSandi * Print a link 3976b13307fSandi * 3985e163278SAndreas Gohr * Just builds a link. 3996b13307fSandi * 4006b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 40142ea7f44SGerrit Uitslag * 40242ea7f44SGerrit Uitslag * @param string $url 40342ea7f44SGerrit Uitslag * @param string $name 40442ea7f44SGerrit Uitslag * @param string $more 40521d806cdSGerrit Uitslag * @param bool $return if true return the link html, otherwise print 40621d806cdSGerrit Uitslag * @return bool|string html of the link, or true if printed 4076b13307fSandi */ 4081af98a77SAnika Henkefunction tpl_link($url, $name, $more = '', $return = false) { 40901f17825SAnika Henke $out = '<a href="'.$url.'" '; 4101af98a77SAnika Henke if($more) $out .= ' '.$more; 4111af98a77SAnika Henke $out .= ">$name</a>"; 4121af98a77SAnika Henke if($return) return $out; 4131af98a77SAnika Henke print $out; 41454e95700STom N Harris return true; 4156b13307fSandi} 4166b13307fSandi 4176b13307fSandi/** 41855efc227SAndreas Gohr * Prints a link to a WikiPage 41955efc227SAndreas Gohr * 42055efc227SAndreas Gohr * Wrapper around html_wikilink 42155efc227SAndreas Gohr * 42255efc227SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 42342ea7f44SGerrit Uitslag * 42442ea7f44SGerrit Uitslag * @param string $id page id 42542ea7f44SGerrit Uitslag * @param string|null $name the name of the link 42621d806cdSGerrit Uitslag * @return bool true 42755efc227SAndreas Gohr */ 4280b17fdc6SAndreas Gohrfunction tpl_pagelink($id, $name = null) { 429d317fb5dSAnika Henke print '<bdi>'.html_wikilink($id, $name).'</bdi>'; 43054e95700STom N Harris return true; 43155efc227SAndreas Gohr} 43255efc227SAndreas Gohr 43355efc227SAndreas Gohr/** 434a3ec5f4aSmatthiasgrimm * get the parent page 435a3ec5f4aSmatthiasgrimm * 436a3ec5f4aSmatthiasgrimm * Tries to find out which page is parent. 437a3ec5f4aSmatthiasgrimm * returns false if none is available 438a3ec5f4aSmatthiasgrimm * 439377f9e97SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 44042ea7f44SGerrit Uitslag * 44142ea7f44SGerrit Uitslag * @param string $id page id 44242ea7f44SGerrit Uitslag * @return false|string 443a3ec5f4aSmatthiasgrimm */ 444377f9e97SAndreas Gohrfunction tpl_getparent($id) { 445377f9e97SAndreas Gohr $parent = getNS($id).':'; 446377f9e97SAndreas Gohr resolve_pageid('', $parent, $exists); 447a197105eSmatthiasgrimm if($parent == $id) { 448a197105eSmatthiasgrimm $pos = strrpos(getNS($id), ':'); 449a197105eSmatthiasgrimm $parent = substr($parent, 0, $pos).':'; 450a197105eSmatthiasgrimm resolve_pageid('', $parent, $exists); 451377f9e97SAndreas Gohr if($parent == $id) return false; 452a197105eSmatthiasgrimm } 453377f9e97SAndreas Gohr return $parent; 454a3ec5f4aSmatthiasgrimm} 455a3ec5f4aSmatthiasgrimm 456a3ec5f4aSmatthiasgrimm/** 4576b13307fSandi * Print one of the buttons 4586b13307fSandi * 459a453d131SAdrian Lang * @author Adrian Lang <mail@adrianlang.de> 460a453d131SAdrian Lang * @see tpl_get_action 461e0c26282SGerrit Uitslag * 462e0c26282SGerrit Uitslag * @param string $type 463e0c26282SGerrit Uitslag * @param bool $return 464e0c26282SGerrit Uitslag * @return bool|string html, or false if no data, true if printed 4656b13307fSandi */ 4661af98a77SAnika Henkefunction tpl_button($type, $return = false) { 467a453d131SAdrian Lang $data = tpl_get_action($type); 468a453d131SAdrian Lang if($data === false) { 469a453d131SAdrian Lang return false; 470a453d131SAdrian Lang } elseif(!is_array($data)) { 471a453d131SAdrian Lang $out = sprintf($data, 'button'); 472409d7af7SAndreas Gohr } else { 473ac7a515fSAndreas Gohr /** 474ac7a515fSAndreas Gohr * @var string $accesskey 475ac7a515fSAndreas Gohr * @var string $id 476ac7a515fSAndreas Gohr * @var string $method 477ac7a515fSAndreas Gohr * @var array $params 478ac7a515fSAndreas Gohr */ 479a453d131SAdrian Lang extract($data); 480a453d131SAdrian Lang if($id === '#dokuwiki__top') { 481a453d131SAdrian Lang $out = html_topbtn(); 482409d7af7SAndreas Gohr } else { 483a453d131SAdrian Lang $out = html_btn($type, $id, $accesskey, $params, $method); 484409d7af7SAndreas Gohr } 485409d7af7SAndreas Gohr } 4861af98a77SAnika Henke if($return) return $out; 487a453d131SAdrian Lang echo $out; 488a453d131SAdrian Lang return true; 4896b13307fSandi} 4906b13307fSandi 4916b13307fSandi/** 492ed630903Sandi * Like the action buttons but links 493ed630903Sandi * 494a453d131SAdrian Lang * @author Adrian Lang <mail@adrianlang.de> 495a453d131SAdrian Lang * @see tpl_get_action 496e0c26282SGerrit Uitslag * 49742ea7f44SGerrit Uitslag * @param string $type action command 498e0c26282SGerrit Uitslag * @param string $pre prefix of link 499e0c26282SGerrit Uitslag * @param string $suf suffix of link 500e0c26282SGerrit Uitslag * @param string $inner innerHML of link 50121d806cdSGerrit Uitslag * @param bool $return if true it returns html, otherwise prints 502e0c26282SGerrit Uitslag * @return bool|string html or false if no data, true if printed 503a453d131SAdrian Lang */ 504a453d131SAdrian Langfunction tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = false) { 505a453d131SAdrian Lang global $lang; 506a453d131SAdrian Lang $data = tpl_get_action($type); 507a453d131SAdrian Lang if($data === false) { 508a453d131SAdrian Lang return false; 509a453d131SAdrian Lang } elseif(!is_array($data)) { 510a453d131SAdrian Lang $out = sprintf($data, 'link'); 511a453d131SAdrian Lang } else { 512ac7a515fSAndreas Gohr /** 513ac7a515fSAndreas Gohr * @var string $accesskey 514ac7a515fSAndreas Gohr * @var string $id 515ac7a515fSAndreas Gohr * @var string $method 516b1af9014SChristopher Smith * @var bool $nofollow 517ac7a515fSAndreas Gohr * @var array $params 518becfa414SGerrit Uitslag * @var string $replacement 519ac7a515fSAndreas Gohr */ 520a453d131SAdrian Lang extract($data); 521a453d131SAdrian Lang if(strpos($id, '#') === 0) { 522a453d131SAdrian Lang $linktarget = $id; 523a453d131SAdrian Lang } else { 524a453d131SAdrian Lang $linktarget = wl($id, $params); 525a453d131SAdrian Lang } 526a453d131SAdrian Lang $caption = $lang['btn_'.$type]; 527becfa414SGerrit Uitslag if(strpos($caption, '%s')){ 528becfa414SGerrit Uitslag $caption = sprintf($caption, $replacement); 529becfa414SGerrit Uitslag } 530c7e90e3fSAnika Henke $akey = $addTitle = ''; 531c7e90e3fSAnika Henke if($accesskey) { 532c7e90e3fSAnika Henke $akey = 'accesskey="'.$accesskey.'" '; 533c7e90e3fSAnika Henke $addTitle = ' ['.strtoupper($accesskey).']'; 534c7e90e3fSAnika Henke } 535b1af9014SChristopher Smith $rel = $nofollow ? 'rel="nofollow" ' : ''; 536ac7a515fSAndreas Gohr $out = tpl_link( 537ac7a515fSAndreas Gohr $linktarget, $pre.(($inner) ? $inner : $caption).$suf, 538a453d131SAdrian Lang 'class="action '.$type.'" '. 539b1af9014SChristopher Smith $akey.$rel. 540e0c26282SGerrit Uitslag 'title="'.hsc($caption).$addTitle.'"', true 541ac7a515fSAndreas Gohr ); 542a453d131SAdrian Lang } 543a453d131SAdrian Lang if($return) return $out; 544a453d131SAdrian Lang echo $out; 545a453d131SAdrian Lang return true; 546a453d131SAdrian Lang} 547a453d131SAdrian Lang 548a453d131SAdrian Lang/** 549a453d131SAdrian Lang * Check the actions and get data for buttons and links 550ed630903Sandi * 551a453d131SAdrian Lang * Available actions are 552a453d131SAdrian Lang * 553a453d131SAdrian Lang * edit - edit/create/show/draft 554ed630903Sandi * history - old revisions 555ed630903Sandi * recent - recent changes 556a453d131SAdrian Lang * login - login/logout - if ACL enabled 557a453d131SAdrian Lang * profile - user profile (if logged in) 558ed630903Sandi * index - The index 559ed630903Sandi * admin - admin page - if enough rights 560a453d131SAdrian Lang * top - back to top 561a453d131SAdrian Lang * back - back to parent - if available 562bbd37938SAndreas Gohr * backlink - links to the list of backlinks 563a453d131SAdrian Lang * subscribe/subscription- subscribe/unsubscribe 564ed630903Sandi * 565ed630903Sandi * @author Andreas Gohr <andi@splitbrain.org> 566a3ec5f4aSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 567a453d131SAdrian Lang * @author Adrian Lang <mail@adrianlang.de> 568e0c26282SGerrit Uitslag * 569ac7a515fSAndreas Gohr * @param string $type 570ac7a515fSAndreas Gohr * @return array|bool|string 571ed630903Sandi */ 572a453d131SAdrian Langfunction tpl_get_action($type) { 573ed630903Sandi global $ID; 574ed630903Sandi global $INFO; 575ed630903Sandi global $REV; 576ed630903Sandi global $ACT; 577b1af9014SChristopher Smith global $conf; 578585bf44eSChristopher Smith /** @var Input $INPUT */ 579585bf44eSChristopher Smith global $INPUT; 580ed630903Sandi 58175e487e9SAndreas Gohr // check disabled actions and fix the badly named ones 582a453d131SAdrian Lang if($type == 'history') $type = 'revisions'; 5834c4b65c8SMichael Hamann if ($type == 'subscription') $type = 'subscribe'; 584a453d131SAdrian Lang if(!actionOK($type)) return false; 585409d7af7SAndreas Gohr 586a453d131SAdrian Lang $accesskey = null; 5876709e843SAdrian Lang $id = $ID; 588a453d131SAdrian Lang $method = 'get'; 589a453d131SAdrian Lang $params = array('do' => $type); 590b1af9014SChristopher Smith $nofollow = true; 591becfa414SGerrit Uitslag $replacement = ''; 5927b4365a7SGerrit Uitslag 5937b4365a7SGerrit Uitslag $unknown = false; 594ed630903Sandi switch($type) { 595ed630903Sandi case 'edit': 5960b17fdc6SAndreas Gohr // most complicated type - we need to decide on current action 597ed630903Sandi if($ACT == 'show' || $ACT == 'search') { 598a453d131SAdrian Lang $method = 'post'; 599ed630903Sandi if($INFO['writable']) { 600a453d131SAdrian Lang $accesskey = 'e'; 601b8a111f5SMichael Klier if(!empty($INFO['draft'])) { 6026709e843SAdrian Lang $type = 'draft'; 603a453d131SAdrian Lang $params['do'] = 'draft'; 604b8a111f5SMichael Klier } else { 605a453d131SAdrian Lang $params['rev'] = $REV; 606a453d131SAdrian Lang if(!$INFO['exists']) { 6076709e843SAdrian Lang $type = 'create'; 608ed630903Sandi } 609b8a111f5SMichael Klier } 610ed630903Sandi } else { 611a453d131SAdrian Lang if(!actionOK('source')) return false; //pseudo action 612a453d131SAdrian Lang $params['rev'] = $REV; 6136709e843SAdrian Lang $type = 'source'; 614a453d131SAdrian Lang $accesskey = 'v'; 615ed630903Sandi } 616ed630903Sandi } else { 617d30d4913SChristopher Smith $params = array('do' => ''); 6186709e843SAdrian Lang $type = 'show'; 619a453d131SAdrian Lang $accesskey = 'v'; 620ed630903Sandi } 6211af98a77SAnika Henke break; 622a453d131SAdrian Lang case 'revisions': 6236709e843SAdrian Lang $type = 'revs'; 624a453d131SAdrian Lang $accesskey = 'o'; 6251af98a77SAnika Henke break; 626ed630903Sandi case 'recent': 627a453d131SAdrian Lang $accesskey = 'r'; 6281af98a77SAnika Henke break; 629ed630903Sandi case 'index': 630a453d131SAdrian Lang $accesskey = 'x'; 631b1af9014SChristopher Smith // allow searchbots to get to the sitemap from the homepage (when dokuwiki isn't providing a sitemap.xml) 632b1af9014SChristopher Smith if ($conf['start'] == $ID && !$conf['sitemap']) { 633b1af9014SChristopher Smith $nofollow = false; 634b1af9014SChristopher Smith } 6351af98a77SAnika Henke break; 636ed630903Sandi case 'top': 637076f0d72SAnika Henke $accesskey = 't'; 638d30d4913SChristopher Smith $params = array('do' => ''); 639a453d131SAdrian Lang $id = '#dokuwiki__top'; 6401af98a77SAnika Henke break; 641a3ec5f4aSmatthiasgrimm case 'back': 642a453d131SAdrian Lang $parent = tpl_getparent($ID); 643a453d131SAdrian Lang if(!$parent) { 644a453d131SAdrian Lang return false; 645a3ec5f4aSmatthiasgrimm } 646a453d131SAdrian Lang $id = $parent; 647d30d4913SChristopher Smith $params = array('do' => ''); 648a453d131SAdrian Lang $accesskey = 'b'; 6491af98a77SAnika Henke break; 650becfa414SGerrit Uitslag case 'img_backto': 651becfa414SGerrit Uitslag $params = array(); 652becfa414SGerrit Uitslag $accesskey = 'b'; 653becfa414SGerrit Uitslag $replacement = $ID; 654becfa414SGerrit Uitslag break; 655ed630903Sandi case 'login': 656a453d131SAdrian Lang $params['sectok'] = getSecurityToken(); 657585bf44eSChristopher Smith if($INPUT->server->has('REMOTE_USER')) { 6583a48618aSAnika Henke if(!actionOK('logout')) { 6592380e8a8SAdrian Lang return false; 6602380e8a8SAdrian Lang } 661a453d131SAdrian Lang $params['do'] = 'logout'; 662a453d131SAdrian Lang $type = 'logout'; 663bf413a4eSAnika Henke } 664bf413a4eSAnika Henke break; 665bf413a4eSAnika Henke case 'register': 666585bf44eSChristopher Smith if($INPUT->server->str('REMOTE_USER')) { 667bf413a4eSAnika Henke return false; 668bf413a4eSAnika Henke } 669bf413a4eSAnika Henke break; 670bf413a4eSAnika Henke case 'resendpwd': 671585bf44eSChristopher Smith if($INPUT->server->str('REMOTE_USER')) { 672bf413a4eSAnika Henke return false; 673ed630903Sandi } 6741af98a77SAnika Henke break; 675ed630903Sandi case 'admin': 676a453d131SAdrian Lang if(!$INFO['ismanager']) { 677a453d131SAdrian Lang return false; 678c059e1a6SAndreas Gohr } 6791af98a77SAnika Henke break; 6801246e016SAndreas Gohr case 'revert': 681a453d131SAdrian Lang if(!$INFO['ismanager'] || !$REV || !$INFO['writable']) { 682a453d131SAdrian Lang return false; 6831246e016SAndreas Gohr } 684a453d131SAdrian Lang $params['rev'] = $REV; 685a453d131SAdrian Lang $params['sectok'] = getSecurityToken(); 6861246e016SAndreas Gohr break; 6876709e843SAdrian Lang case 'subscribe': 688585bf44eSChristopher Smith if(!$INPUT->server->str('REMOTE_USER')) { 689a453d131SAdrian Lang return false; 690b158d625SSteven Danz } 6911af98a77SAnika Henke break; 692f00151b4Schris case 'backlink': 6931af98a77SAnika Henke break; 6948b06d178Schris case 'profile': 695585bf44eSChristopher Smith if(!$INPUT->server->has('REMOTE_USER')) { 696a453d131SAdrian Lang return false; 6978b06d178Schris } 6981af98a77SAnika Henke break; 699b9eb2e61SKate Arzamastseva case 'media': 700d08527abSAnika Henke $params['ns'] = getNS($ID); 701b9eb2e61SKate Arzamastseva break; 702becfa414SGerrit Uitslag case 'mediaManager': 703becfa414SGerrit Uitslag // View image in media manager 704becfa414SGerrit Uitslag global $IMG; 705becfa414SGerrit Uitslag $imgNS = getNS($IMG); 706becfa414SGerrit Uitslag $authNS = auth_quickaclcheck("$imgNS:*"); 707becfa414SGerrit Uitslag if ($authNS < AUTH_UPLOAD) { 708becfa414SGerrit Uitslag return false; 709becfa414SGerrit Uitslag } 710becfa414SGerrit Uitslag $params = array( 711becfa414SGerrit Uitslag 'ns' => $imgNS, 712becfa414SGerrit Uitslag 'image' => $IMG, 713becfa414SGerrit Uitslag 'do' => 'media' 714becfa414SGerrit Uitslag ); 715becfa414SGerrit Uitslag //$type = 'media'; 716becfa414SGerrit Uitslag break; 717ed630903Sandi default: 7187b4365a7SGerrit Uitslag //unknown type 7197b4365a7SGerrit Uitslag $unknown = true; 720ed630903Sandi } 7217b4365a7SGerrit Uitslag 7227b4365a7SGerrit Uitslag $data = compact('accesskey', 'type', 'id', 'method', 'params', 'nofollow', 'replacement'); 7237b4365a7SGerrit Uitslag 7243131073dSGerrit Uitslag $evt = new Doku_Event('TPL_ACTION_GET', $data); 7257b4365a7SGerrit Uitslag if($evt->advise_before()) { 7267b4365a7SGerrit Uitslag //handle unknown types 7277b4365a7SGerrit Uitslag if($unknown) { 72838d2ca46SGerrit Uitslag $data = '[unknown %s type]'; 7297b4365a7SGerrit Uitslag } 7307b4365a7SGerrit Uitslag } 7317b4365a7SGerrit Uitslag $evt->advise_after(); 7327b4365a7SGerrit Uitslag unset($evt); 7337b4365a7SGerrit Uitslag 7347b4365a7SGerrit Uitslag return $data; 735ed630903Sandi} 736ed630903Sandi 737ed630903Sandi/** 73801f17825SAnika Henke * Wrapper around tpl_button() and tpl_actionlink() 73901f17825SAnika Henke * 74001f17825SAnika Henke * @author Anika Henke <anika@selfthinker.org> 74142ea7f44SGerrit Uitslag * 74242ea7f44SGerrit Uitslag * @param string $type action command 743ac7a515fSAndreas Gohr * @param bool $link link or form button? 744e0c26282SGerrit Uitslag * @param string|bool $wrapper HTML element wrapper 745ac7a515fSAndreas Gohr * @param bool $return return or print 746ac7a515fSAndreas Gohr * @param string $pre prefix for links 747ac7a515fSAndreas Gohr * @param string $suf suffix for links 748ac7a515fSAndreas Gohr * @param string $inner inner HTML for links 749ac7a515fSAndreas Gohr * @return bool|string 75001f17825SAnika Henke */ 751ac7a515fSAndreas Gohrfunction tpl_action($type, $link = false, $wrapper = false, $return = false, $pre = '', $suf = '', $inner = '') { 75201f17825SAnika Henke $out = ''; 753ac7a515fSAndreas Gohr if($link) { 754e0c26282SGerrit Uitslag $out .= tpl_actionlink($type, $pre, $suf, $inner, true); 755ac7a515fSAndreas Gohr } else { 756e0c26282SGerrit Uitslag $out .= tpl_button($type, true); 757ac7a515fSAndreas Gohr } 75801f17825SAnika Henke if($out && $wrapper) $out = "<$wrapper>$out</$wrapper>"; 75901f17825SAnika Henke 76001f17825SAnika Henke if($return) return $out; 76101f17825SAnika Henke print $out; 76201f17825SAnika Henke return $out ? true : false; 76301f17825SAnika Henke} 76401f17825SAnika Henke 76501f17825SAnika Henke/** 7666b13307fSandi * Print the search form 7676b13307fSandi * 76872645b75SAndreas Gohr * If the first parameter is given a div with the ID 'qsearch_out' will 76972645b75SAndreas Gohr * be added which instructs the ajax pagequicksearch to kick in and place 77072645b75SAndreas Gohr * its output into this div. The second parameter controls the propritary 77172645b75SAndreas Gohr * attribute autocomplete. If set to false this attribute will be set with an 77272645b75SAndreas Gohr * value of "off" to instruct the browser to disable it's own built in 77372645b75SAndreas Gohr * autocompletion feature (MSIE and Firefox) 77472645b75SAndreas Gohr * 7756b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 77642ea7f44SGerrit Uitslag * 777ac7a515fSAndreas Gohr * @param bool $ajax 778ac7a515fSAndreas Gohr * @param bool $autocomplete 779ac7a515fSAndreas Gohr * @return bool 7806b13307fSandi */ 78172645b75SAndreas Gohrfunction tpl_searchform($ajax = true, $autocomplete = true) { 7826b13307fSandi global $lang; 783c1e3b7d9Smatthiasgrimm global $ACT; 784ad4aaef7SAndreas Gohr global $QUERY; 785c1e3b7d9Smatthiasgrimm 786670ff54eSchris // don't print the search form if search action has been disabled 78764276bbcSarbrk1 if(!actionOK('search')) return false; 788670ff54eSchris 7899805efa0SAnika Henke print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search" method="get" role="search"><div class="no">'; 7906b13307fSandi print '<input type="hidden" name="do" value="search" />'; 791c1e3b7d9Smatthiasgrimm print '<input type="text" '; 79265cc1598SPhy if($ACT == 'search') print 'value="'.hsc($QUERY).'" '; 793001ea14eSRainbow Spike print 'placeholder="'.$lang['btn_search'].'" '; 79472645b75SAndreas Gohr if(!$autocomplete) print 'autocomplete="off" '; 79507493d05SAnika Henke print 'id="qsearch__in" accesskey="f" name="id" class="edit" title="[F]" />'; 796ae614416SAnika Henke print '<button type="submit" title="'.$lang['btn_search'].'">'.$lang['btn_search'].'</button>'; 79724a33b42SAndreas Gohr if($ajax) print '<div id="qsearch__out" class="ajax_qsearch JSpopup"></div>'; 7984beabca9SAnika Henke print '</div></form>'; 79954e95700STom N Harris return true; 8006b13307fSandi} 8016b13307fSandi 8026b13307fSandi/** 8036b13307fSandi * Print the breadcrumbs trace 8046b13307fSandi * 8056b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 80642ea7f44SGerrit Uitslag * 807ac7a515fSAndreas Gohr * @param string $sep Separator between entries 808ac7a515fSAndreas Gohr * @return bool 8096b13307fSandi */ 810e260f93bSAnika Henkefunction tpl_breadcrumbs($sep = '•') { 8116b13307fSandi global $lang; 8126b13307fSandi global $conf; 8136b13307fSandi 8146b13307fSandi //check if enabled 815359fab8bSMichael Hamann if(!$conf['breadcrumbs']) return false; 8166b13307fSandi 8176b13307fSandi $crumbs = breadcrumbs(); //setup crumb trace 818265e3787Sandi 8192979a10bSKatriel Traum $crumbs_sep = ' <span class="bcsep">'.$sep.'</span> '; 820265e3787Sandi 82140eb54bbSjan //render crumbs, highlight the last one 822fde860beSGerrit Uitslag print '<span class="bchead">'.$lang['breadcrumb'].'</span>'; 82340eb54bbSjan $last = count($crumbs); 82440eb54bbSjan $i = 0; 825a77f5846Sjan foreach($crumbs as $id => $name) { 82640eb54bbSjan $i++; 8272979a10bSKatriel Traum echo $crumbs_sep; 82892795d04Sandi if($i == $last) print '<span class="curid">'; 829d317fb5dSAnika Henke print '<bdi>'; 830e26fd1eeSAndreas Gohr tpl_link(wl($id), hsc($name), 'class="breadcrumbs" title="'.$id.'"'); 831d317fb5dSAnika Henke print '</bdi>'; 83292795d04Sandi if($i == $last) print '</span>'; 8336b13307fSandi } 83454e95700STom N Harris return true; 8356b13307fSandi} 8366b13307fSandi 8376b13307fSandi/** 8381734437eSandi * Hierarchical breadcrumbs 8391734437eSandi * 84031e187f8SSean Coates * This code was suggested as replacement for the usual breadcrumbs. 8411734437eSandi * It only makes sense with a deep site structure. 8421734437eSandi * 8431734437eSandi * @author Andreas Gohr <andi@splitbrain.org> 8446bd812dfSNigel McNie * @author Nigel McNie <oracle.shinoda@gmail.com> 84531e187f8SSean Coates * @author Sean Coates <sean@caedmon.net> 846f46c9e83SAnika Henke * @author <fredrik@averpil.com> 84708d7a575SAndreas Gohr * @todo May behave strangely in RTL languages 84842ea7f44SGerrit Uitslag * 849ac7a515fSAndreas Gohr * @param string $sep Separator between entries 850ac7a515fSAndreas Gohr * @return bool 8511734437eSandi */ 85208d7a575SAndreas Gohrfunction tpl_youarehere($sep = ' » ') { 8531734437eSandi global $conf; 8541734437eSandi global $ID; 8551734437eSandi global $lang; 8561734437eSandi 85731e187f8SSean Coates // check if enabled 85854e95700STom N Harris if(!$conf['youarehere']) return false; 8591734437eSandi 8601734437eSandi $parts = explode(':', $ID); 861796bafb3SAndreas Gohr $count = count($parts); 8621734437eSandi 86308d7a575SAndreas Gohr echo '<span class="bchead">'.$lang['youarehere'].' </span>'; 8643940c519SMark 86508d7a575SAndreas Gohr // always print the startpage 86608d7a575SAndreas Gohr echo '<span class="home">'; 86708d7a575SAndreas Gohr tpl_pagelink(':'.$conf['start']); 86808d7a575SAndreas Gohr echo '</span>'; 869796bafb3SAndreas Gohr 870796bafb3SAndreas Gohr // print intermediate namespace links 871796bafb3SAndreas Gohr $part = ''; 872796bafb3SAndreas Gohr for($i = 0; $i < $count - 1; $i++) { 873796bafb3SAndreas Gohr $part .= $parts[$i].':'; 874796bafb3SAndreas Gohr $page = $part; 875796bafb3SAndreas Gohr if($page == $conf['start']) continue; // Skip startpage 876796bafb3SAndreas Gohr 87708d7a575SAndreas Gohr // output 87808d7a575SAndreas Gohr echo $sep; 87908d7a575SAndreas Gohr tpl_pagelink($page); 88031e187f8SSean Coates } 8811734437eSandi 882796bafb3SAndreas Gohr // print current page, skipping start page, skipping for namespace index 883e013f48dSAnika Henke resolve_pageid('', $page, $exists); 88408d7a575SAndreas Gohr if(isset($page) && $page == $part.$parts[$i]) return true; 885796bafb3SAndreas Gohr $page = $part.$parts[$i]; 88608d7a575SAndreas Gohr if($page == $conf['start']) return true; 88708d7a575SAndreas Gohr echo $sep; 88808d7a575SAndreas Gohr tpl_pagelink($page); 88954e95700STom N Harris return true; 8901734437eSandi} 8911734437eSandi 8921734437eSandi/** 8936b13307fSandi * Print info if the user is logged in 894a2488c3cSMatthias Grimm * and show full name in that case 8956b13307fSandi * 8966b13307fSandi * Could be enhanced with a profile link in future? 8976b13307fSandi * 8986b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 89942ea7f44SGerrit Uitslag * 900ac7a515fSAndreas Gohr * @return bool 9016b13307fSandi */ 9026b13307fSandifunction tpl_userinfo() { 9036b13307fSandi global $lang; 904585bf44eSChristopher Smith /** @var Input $INPUT */ 905585bf44eSChristopher Smith global $INPUT; 906585bf44eSChristopher Smith 907585bf44eSChristopher Smith if($INPUT->server->str('REMOTE_USER')) { 908fde860beSGerrit Uitslag print $lang['loggedinas'].' '.userlink(); 90954e95700STom N Harris return true; 91054e95700STom N Harris } 91154e95700STom N Harris return false; 9126b13307fSandi} 9136b13307fSandi 9146b13307fSandi/** 9156b13307fSandi * Print some info about the current page 9166b13307fSandi * 9176b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 91842ea7f44SGerrit Uitslag * 919ac7a515fSAndreas Gohr * @param bool $ret return content instead of printing it 920ac7a515fSAndreas Gohr * @return bool|string 9216b13307fSandi */ 9224b0d3916SAndreas Gohrfunction tpl_pageinfo($ret = false) { 9236b13307fSandi global $conf; 9246b13307fSandi global $lang; 9256b13307fSandi global $INFO; 926c6e92a3cSDavid Lorentsen global $ID; 927c6e92a3cSDavid Lorentsen 928c6e92a3cSDavid Lorentsen // return if we are not allowed to view the page 929ac7a515fSAndreas Gohr if(!auth_quickaclcheck($ID)) { 930ac7a515fSAndreas Gohr return false; 931ac7a515fSAndreas Gohr } 9326b13307fSandi 9336b13307fSandi // prepare date and path 9346b13307fSandi $fn = $INFO['filepath']; 9356b13307fSandi if(!$conf['fullpath']) { 936613bca54SAndreas Gohr if($INFO['rev']) { 937c83f69baSSatoshi Sahara $fn = str_replace($conf['olddir'].'/', '', $fn); 9386b13307fSandi } else { 939c83f69baSSatoshi Sahara $fn = str_replace($conf['datadir'].'/', '', $fn); 9406b13307fSandi } 9416b13307fSandi } 942bee6dc82Sandi $fn = utf8_decodeFN($fn); 943f2263577SAndreas Gohr $date = dformat($INFO['lastmod']); 9446b13307fSandi 945faecdfdfSAndreas Gohr // print it 946faecdfdfSAndreas Gohr if($INFO['exists']) { 9474b0d3916SAndreas Gohr $out = ''; 948d317fb5dSAnika Henke $out .= '<bdi>'.$fn.'</bdi>'; 949e260f93bSAnika Henke $out .= ' · '; 9504b0d3916SAndreas Gohr $out .= $lang['lastmod']; 951fde860beSGerrit Uitslag $out .= ' '; 9524b0d3916SAndreas Gohr $out .= $date; 9536b13307fSandi if($INFO['editor']) { 9544b0d3916SAndreas Gohr $out .= ' '.$lang['by'].' '; 955d317fb5dSAnika Henke $out .= '<bdi>'.editorinfo($INFO['editor']).'</bdi>'; 9565aa52fafSBen Coburn } else { 9574b0d3916SAndreas Gohr $out .= ' ('.$lang['external_edit'].')'; 9586b13307fSandi } 9596b13307fSandi if($INFO['locked']) { 960e260f93bSAnika Henke $out .= ' · '; 9614b0d3916SAndreas Gohr $out .= $lang['lockedby']; 962fde860beSGerrit Uitslag $out .= ' '; 963d317fb5dSAnika Henke $out .= '<bdi>'.editorinfo($INFO['locked']).'</bdi>'; 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> 98242ea7f44SGerrit Uitslag * 983ac7a515fSAndreas Gohr * @param string $id page id 984ac7a515fSAndreas Gohr * @param bool $ret return content instead of printing 985ac7a515fSAndreas Gohr * @return bool|string 98687c434ceSAndreas Gohr */ 987a6598f23SBen Coburnfunction tpl_pagetitle($id = null, $ret = false) { 988c248bda1SChristopher Smith global $ACT, $INPUT, $conf, $lang; 989fffeeafeSChristopher Smith 99087c434ceSAndreas Gohr if(is_null($id)) { 99187c434ceSAndreas Gohr global $ID; 99287c434ceSAndreas Gohr $id = $ID; 99387c434ceSAndreas Gohr } 99487c434ceSAndreas Gohr 99587c434ceSAndreas Gohr $name = $id; 996fe9ec250SChris Smith if(useHeading('navigation')) { 997fffeeafeSChristopher Smith $first_heading = p_get_first_heading($id); 998fffeeafeSChristopher Smith if($first_heading) $name = $first_heading; 999fffeeafeSChristopher Smith } 1000fffeeafeSChristopher Smith 1001fffeeafeSChristopher Smith // default page title is the page name, modify with the current action 1002fffeeafeSChristopher Smith switch ($ACT) { 1003fffeeafeSChristopher Smith // admin functions 1004fffeeafeSChristopher Smith case 'admin' : 1005fffeeafeSChristopher Smith $page_title = $lang['btn_admin']; 1006fffeeafeSChristopher Smith // try to get the plugin name 1007a61966c5SChristopher Smith /** @var $plugin DokuWiki_Admin_Plugin */ 1008a61966c5SChristopher Smith if ($plugin = plugin_getRequestAdminPlugin()){ 1009c248bda1SChristopher Smith $plugin_title = $plugin->getMenuText($conf['lang']); 1010a61966c5SChristopher Smith $page_title = $plugin_title ? $plugin_title : $plugin->getPluginName(); 1011fffeeafeSChristopher Smith } 1012fffeeafeSChristopher Smith break; 1013fffeeafeSChristopher Smith 1014fffeeafeSChristopher Smith // user functions 1015fffeeafeSChristopher Smith case 'login' : 1016fffeeafeSChristopher Smith case 'profile' : 1017fffeeafeSChristopher Smith case 'register' : 1018fffeeafeSChristopher Smith case 'resendpwd' : 1019fffeeafeSChristopher Smith $page_title = $lang['btn_'.$ACT]; 1020fffeeafeSChristopher Smith break; 1021fffeeafeSChristopher Smith 1022fffeeafeSChristopher Smith // wiki functions 1023fffeeafeSChristopher Smith case 'search' : 1024fffeeafeSChristopher Smith case 'index' : 1025fffeeafeSChristopher Smith $page_title = $lang['btn_'.$ACT]; 1026fffeeafeSChristopher Smith break; 1027fffeeafeSChristopher Smith 1028fffeeafeSChristopher Smith // page functions 1029fffeeafeSChristopher Smith case 'edit' : 1030fffeeafeSChristopher Smith $page_title = "✎ ".$name; 1031fffeeafeSChristopher Smith break; 1032fffeeafeSChristopher Smith 1033fffeeafeSChristopher Smith case 'revisions' : 1034fffeeafeSChristopher Smith $page_title = $name . ' - ' . $lang['btn_revs']; 1035fffeeafeSChristopher Smith break; 1036fffeeafeSChristopher Smith 1037fffeeafeSChristopher Smith case 'backlink' : 1038fffeeafeSChristopher Smith case 'recent' : 1039fffeeafeSChristopher Smith case 'subscribe' : 1040fffeeafeSChristopher Smith $page_title = $name . ' - ' . $lang['btn_'.$ACT]; 1041fffeeafeSChristopher Smith break; 1042fffeeafeSChristopher Smith 1043fffeeafeSChristopher Smith default : // SHOW and anything else not included 1044fffeeafeSChristopher Smith $page_title = $name; 104587c434ceSAndreas Gohr } 1046a6598f23SBen Coburn 1047a6598f23SBen Coburn if($ret) { 1048fffeeafeSChristopher Smith return hsc($page_title); 1049a6598f23SBen Coburn } else { 1050fffeeafeSChristopher Smith print hsc($page_title); 105154e95700STom N Harris return true; 105287c434ceSAndreas Gohr } 1053a6598f23SBen Coburn} 1054340756e4Sandi 105555efc227SAndreas Gohr/** 105655efc227SAndreas Gohr * Returns the requested EXIF/IPTC tag from the current image 105755efc227SAndreas Gohr * 105855efc227SAndreas Gohr * If $tags is an array all given tags are tried until a 105955efc227SAndreas Gohr * value is found. If no value is found $alt is returned. 106055efc227SAndreas Gohr * 106155efc227SAndreas Gohr * Which texts are known is defined in the functions _exifTagNames 106255efc227SAndreas Gohr * and _iptcTagNames() in inc/jpeg.php (You need to prepend IPTC 106355efc227SAndreas Gohr * to the names of the latter one) 106455efc227SAndreas Gohr * 10653df72098SAndreas Gohr * Only allowed in: detail.php 106655efc227SAndreas Gohr * 106755efc227SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 106842ea7f44SGerrit Uitslag * 106921d806cdSGerrit Uitslag * @param array|string $tags tag or array of tags to try 1070ac7a515fSAndreas Gohr * @param string $alt alternative output if no data was found 1071e0c26282SGerrit Uitslag * @param null|string $src the image src, uses global $SRC if not given 1072ac7a515fSAndreas Gohr * @return string 107355efc227SAndreas Gohr */ 10743df72098SAndreas Gohrfunction tpl_img_getTag($tags, $alt = '', $src = null) { 107555efc227SAndreas Gohr // Init Exif Reader 107655efc227SAndreas Gohr global $SRC; 10773df72098SAndreas Gohr 10783df72098SAndreas Gohr if(is_null($src)) $src = $SRC; 10793df72098SAndreas Gohr 108055efc227SAndreas Gohr static $meta = null; 10813df72098SAndreas Gohr if(is_null($meta)) $meta = new JpegMeta($src); 108255efc227SAndreas Gohr if($meta === false) return $alt; 108388945224SChristopher Smith $info = cleanText($meta->getField($tags)); 108455efc227SAndreas Gohr if($info == false) return $alt; 108555efc227SAndreas Gohr return $info; 108655efc227SAndreas Gohr} 108755efc227SAndreas Gohr 108855efc227SAndreas Gohr/** 1089becfa414SGerrit Uitslag * Returns a description list of the metatags of the current image 1090becfa414SGerrit Uitslag * 1091becfa414SGerrit Uitslag * @return string html of description list 1092becfa414SGerrit Uitslag */ 1093becfa414SGerrit Uitslagfunction tpl_img_meta() { 1094becfa414SGerrit Uitslag global $lang; 1095becfa414SGerrit Uitslag 1096becfa414SGerrit Uitslag $tags = tpl_get_img_meta(); 1097becfa414SGerrit Uitslag 1098becfa414SGerrit Uitslag echo '<dl>'; 1099becfa414SGerrit Uitslag foreach($tags as $tag) { 1100becfa414SGerrit Uitslag $label = $lang[$tag['langkey']]; 1101fde860beSGerrit Uitslag if(!$label) $label = $tag['langkey'] . ':'; 1102becfa414SGerrit Uitslag 1103fde860beSGerrit Uitslag echo '<dt>'.$label.'</dt><dd>'; 1104becfa414SGerrit Uitslag if ($tag['type'] == 'date') { 1105becfa414SGerrit Uitslag echo dformat($tag['value']); 1106becfa414SGerrit Uitslag } else { 1107becfa414SGerrit Uitslag echo hsc($tag['value']); 1108becfa414SGerrit Uitslag } 1109becfa414SGerrit Uitslag echo '</dd>'; 1110becfa414SGerrit Uitslag } 1111becfa414SGerrit Uitslag echo '</dl>'; 1112becfa414SGerrit Uitslag} 1113becfa414SGerrit Uitslag 1114becfa414SGerrit Uitslag/** 1115becfa414SGerrit Uitslag * Returns metadata as configured in mediameta config file, ready for creating html 1116becfa414SGerrit Uitslag * 1117becfa414SGerrit Uitslag * @return array with arrays containing the entries: 1118becfa414SGerrit Uitslag * - string langkey key to lookup in the $lang var, if not found printed as is 1119becfa414SGerrit Uitslag * - string type type of value 1120becfa414SGerrit Uitslag * - string value tag value (unescaped) 1121becfa414SGerrit Uitslag */ 1122becfa414SGerrit Uitslagfunction tpl_get_img_meta() { 1123becfa414SGerrit Uitslag 1124becfa414SGerrit Uitslag $config_files = getConfigFiles('mediameta'); 1125becfa414SGerrit Uitslag foreach ($config_files as $config_file) { 112679e79377SAndreas Gohr if(file_exists($config_file)) { 1127becfa414SGerrit Uitslag include($config_file); 1128becfa414SGerrit Uitslag } 1129becfa414SGerrit Uitslag } 1130becfa414SGerrit Uitslag /** @var array $fields the included array with metadata */ 1131becfa414SGerrit Uitslag 1132becfa414SGerrit Uitslag $tags = array(); 1133becfa414SGerrit Uitslag foreach($fields as $tag){ 1134becfa414SGerrit Uitslag $t = array(); 1135becfa414SGerrit Uitslag if (!empty($tag[0])) { 1136becfa414SGerrit Uitslag $t = array($tag[0]); 1137becfa414SGerrit Uitslag } 1138becfa414SGerrit Uitslag if(is_array($tag[3])) { 1139becfa414SGerrit Uitslag $t = array_merge($t,$tag[3]); 1140becfa414SGerrit Uitslag } 1141becfa414SGerrit Uitslag $value = tpl_img_getTag($t); 1142becfa414SGerrit Uitslag if ($value) { 1143becfa414SGerrit Uitslag $tags[] = array('langkey' => $tag[1], 'type' => $tag[2], 'value' => $value); 1144becfa414SGerrit Uitslag } 1145becfa414SGerrit Uitslag } 1146becfa414SGerrit Uitslag return $tags; 1147becfa414SGerrit Uitslag} 1148becfa414SGerrit Uitslag 1149becfa414SGerrit Uitslag/** 115055efc227SAndreas Gohr * Prints the image with a link to the full sized version 115155efc227SAndreas Gohr * 115255efc227SAndreas Gohr * Only allowed in: detail.php 1153a02d2933SAndreas Gohr * 1154ac7a515fSAndreas Gohr * @triggers TPL_IMG_DISPLAY 1155a02d2933SAndreas Gohr * @param $maxwidth int - maximal width of the image 1156a02d2933SAndreas Gohr * @param $maxheight int - maximal height of the image 1157a02d2933SAndreas Gohr * @param $link bool - link to the orginal size? 1158a02d2933SAndreas Gohr * @param $params array - additional image attributes 115942ea7f44SGerrit Uitslag * @return bool Result of TPL_IMG_DISPLAY 116055efc227SAndreas Gohr */ 1161a02d2933SAndreas Gohrfunction tpl_img($maxwidth = 0, $maxheight = 0, $link = true, $params = null) { 116255efc227SAndreas Gohr global $IMG; 1163585bf44eSChristopher Smith /** @var Input $INPUT */ 1164ac7a515fSAndreas Gohr global $INPUT; 11655c2eed9aSlisps global $REV; 116665d3a5dbSAndreas Gohr $w = (int) tpl_img_getTag('File.Width'); 116765d3a5dbSAndreas Gohr $h = (int) tpl_img_getTag('File.Height'); 116855efc227SAndreas Gohr 116955efc227SAndreas Gohr //resize to given max values 117023a34783SAndreas Gohr $ratio = 1; 117123a34783SAndreas Gohr if($w >= $h) { 1172f8925855Sjoe.lapp if($maxwidth && $w >= $maxwidth) { 117355efc227SAndreas Gohr $ratio = $maxwidth / $w; 1174f8925855Sjoe.lapp } elseif($maxheight && $h > $maxheight) { 117555efc227SAndreas Gohr $ratio = $maxheight / $h; 117655efc227SAndreas Gohr } 117755efc227SAndreas Gohr } else { 1178f8925855Sjoe.lapp if($maxheight && $h >= $maxheight) { 117955efc227SAndreas Gohr $ratio = $maxheight / $h; 1180f8925855Sjoe.lapp } elseif($maxwidth && $w > $maxwidth) { 118155efc227SAndreas Gohr $ratio = $maxwidth / $w; 118255efc227SAndreas Gohr } 118355efc227SAndreas Gohr } 118455efc227SAndreas Gohr if($ratio) { 118555efc227SAndreas Gohr $w = floor($ratio * $w); 118655efc227SAndreas Gohr $h = floor($ratio * $h); 118755efc227SAndreas Gohr } 118855efc227SAndreas Gohr 11896de3759aSAndreas Gohr //prepare URLs 11905c2eed9aSlisps $url = ml($IMG, array('cache'=> $INPUT->str('cache'),'rev'=>$REV), true, '&'); 11915c2eed9aSlisps $src = ml($IMG, array('cache'=> $INPUT->str('cache'),'rev'=>$REV, 'w'=> $w, 'h'=> $h), true, '&'); 119255efc227SAndreas Gohr 11932684e50aSAndreas Gohr //prepare attributes 119455efc227SAndreas Gohr $alt = tpl_img_getTag('Simple.Title'); 1195a02d2933SAndreas Gohr if(is_null($params)) { 11962684e50aSAndreas Gohr $p = array(); 1197a02d2933SAndreas Gohr } else { 1198a02d2933SAndreas Gohr $p = $params; 1199a02d2933SAndreas Gohr } 12002684e50aSAndreas Gohr if($w) $p['width'] = $w; 12012684e50aSAndreas Gohr if($h) $p['height'] = $h; 12022684e50aSAndreas Gohr $p['class'] = 'img_detail'; 12032684e50aSAndreas Gohr if($alt) { 12042684e50aSAndreas Gohr $p['alt'] = $alt; 12052684e50aSAndreas Gohr $p['title'] = $alt; 12062684e50aSAndreas Gohr } else { 12072684e50aSAndreas Gohr $p['alt'] = ''; 12082684e50aSAndreas Gohr } 1209a02d2933SAndreas Gohr $p['src'] = $src; 121055efc227SAndreas Gohr 1211a02d2933SAndreas Gohr $data = array('url'=> ($link ? $url : null), 'params'=> $p); 1212a02d2933SAndreas Gohr return trigger_event('TPL_IMG_DISPLAY', $data, '_tpl_img_action', true); 1213a02d2933SAndreas Gohr} 1214a02d2933SAndreas Gohr 1215a02d2933SAndreas Gohr/** 1216a02d2933SAndreas Gohr * Default action for TPL_IMG_DISPLAY 1217ac7a515fSAndreas Gohr * 1218ac7a515fSAndreas Gohr * @param array $data 1219ac7a515fSAndreas Gohr * @return bool 1220a02d2933SAndreas Gohr */ 1221ac7a515fSAndreas Gohrfunction _tpl_img_action($data) { 122259f3611bSAnika Henke global $lang; 1223a02d2933SAndreas Gohr $p = buildAttributes($data['params']); 1224a02d2933SAndreas Gohr 122559f3611bSAnika Henke if($data['url']) print '<a href="'.hsc($data['url']).'" title="'.$lang['mediaview'].'">'; 1226a02d2933SAndreas Gohr print '<img '.$p.'/>'; 1227a02d2933SAndreas Gohr if($data['url']) print '</a>'; 122854e95700STom N Harris return true; 122955efc227SAndreas Gohr} 123055efc227SAndreas Gohr 12317367b368SAndreas Gohr/** 1232881f2ee2SAndreas Haerter * This function inserts a small gif which in reality is the indexer function. 12337367b368SAndreas Gohr * 12347367b368SAndreas Gohr * Should be called somewhere at the very end of the main.php 12357367b368SAndreas Gohr * template 1236ac7a515fSAndreas Gohr * 1237ac7a515fSAndreas Gohr * @return bool 12387367b368SAndreas Gohr */ 12397367b368SAndreas Gohrfunction tpl_indexerWebBug() { 12407367b368SAndreas Gohr global $ID; 12411dad36f5SAndreas Gohr 12427367b368SAndreas Gohr $p = array(); 1243b6c6979fSAndreas Gohr $p['src'] = DOKU_BASE.'lib/exe/indexer.php?id='.rawurlencode($ID). 1244e68c51baSAndreas Gohr '&'.time(); 1245881f2ee2SAndreas Haerter $p['width'] = 2; //no more 1x1 px image because we live in times of ad blockers... 12467367b368SAndreas Gohr $p['height'] = 1; 12477367b368SAndreas Gohr $p['alt'] = ''; 12487367b368SAndreas Gohr $att = buildAttributes($p); 12497367b368SAndreas Gohr print "<img $att />"; 125054e95700STom N Harris return true; 12517367b368SAndreas Gohr} 12527367b368SAndreas Gohr 125378d4e784SEsther Brunner/** 125478d4e784SEsther Brunner * tpl_getConf($id) 125578d4e784SEsther Brunner * 125678d4e784SEsther Brunner * use this function to access template configuration variables 1257ac7a515fSAndreas Gohr * 125817448fb8SChristopher Smith * @param string $id name of the value to access 125917448fb8SChristopher Smith * @param mixed $notset what to return if the setting is not available 126017448fb8SChristopher Smith * @return mixed 126178d4e784SEsther Brunner */ 126217448fb8SChristopher Smithfunction tpl_getConf($id, $notset=false) { 126378d4e784SEsther Brunner global $conf; 126417566ac6SAdrian Lang static $tpl_configloaded = false; 126578d4e784SEsther Brunner 126678d4e784SEsther Brunner $tpl = $conf['template']; 126778d4e784SEsther Brunner 126878d4e784SEsther Brunner if(!$tpl_configloaded) { 126978d4e784SEsther Brunner $tconf = tpl_loadConfig(); 127078d4e784SEsther Brunner if($tconf !== false) { 127178d4e784SEsther Brunner foreach($tconf as $key => $value) { 127278d4e784SEsther Brunner if(isset($conf['tpl'][$tpl][$key])) continue; 127378d4e784SEsther Brunner $conf['tpl'][$tpl][$key] = $value; 127478d4e784SEsther Brunner } 127578d4e784SEsther Brunner $tpl_configloaded = true; 127678d4e784SEsther Brunner } 127778d4e784SEsther Brunner } 127878d4e784SEsther Brunner 127917448fb8SChristopher Smith if(isset($conf['tpl'][$tpl][$id])){ 128078d4e784SEsther Brunner return $conf['tpl'][$tpl][$id]; 128178d4e784SEsther Brunner } 128278d4e784SEsther Brunner 128317448fb8SChristopher Smith return $notset; 128417448fb8SChristopher Smith} 128517448fb8SChristopher Smith 128678d4e784SEsther Brunner/** 128778d4e784SEsther Brunner * tpl_loadConfig() 1288ac7a515fSAndreas Gohr * 128978d4e784SEsther Brunner * reads all template configuration variables 129078d4e784SEsther Brunner * this function is automatically called by tpl_getConf() 1291ac7a515fSAndreas Gohr * 1292ac7a515fSAndreas Gohr * @return array 129378d4e784SEsther Brunner */ 129478d4e784SEsther Brunnerfunction tpl_loadConfig() { 129578d4e784SEsther Brunner 1296c4766956SAndreas Gohr $file = tpl_incdir().'/conf/default.php'; 129778d4e784SEsther Brunner $conf = array(); 129878d4e784SEsther Brunner 129979e79377SAndreas Gohr if(!file_exists($file)) return false; 130078d4e784SEsther Brunner 130178d4e784SEsther Brunner // load default config file 130278d4e784SEsther Brunner include($file); 130378d4e784SEsther Brunner 130478d4e784SEsther Brunner return $conf; 130578d4e784SEsther Brunner} 130678d4e784SEsther Brunner 130717566ac6SAdrian Lang// language methods 130817566ac6SAdrian Lang/** 130917566ac6SAdrian Lang * tpl_getLang($id) 131017566ac6SAdrian Lang * 131117566ac6SAdrian Lang * use this function to access template language variables 131242ea7f44SGerrit Uitslag * 131342ea7f44SGerrit Uitslag * @param string $id key of language string 131442ea7f44SGerrit Uitslag * @return string 131517566ac6SAdrian Lang */ 131617566ac6SAdrian Langfunction tpl_getLang($id) { 131717566ac6SAdrian Lang static $lang = array(); 131817566ac6SAdrian Lang 131917566ac6SAdrian Lang if(count($lang) === 0) { 1320dd7a6159SGerrit Uitslag global $conf, $config_cascade; // definitely don't invoke "global $lang" 1321dd7a6159SGerrit Uitslag 1322c4766956SAndreas Gohr $path = tpl_incdir() . 'lang/'; 132317566ac6SAdrian Lang 132417566ac6SAdrian Lang $lang = array(); 132517566ac6SAdrian Lang 132617566ac6SAdrian Lang // don't include once 132717566ac6SAdrian Lang @include($path . 'en/lang.php'); 1328dd7a6159SGerrit Uitslag foreach($config_cascade['lang']['template'] as $config_file) { 132979e79377SAndreas Gohr if(file_exists($config_file . $conf['template'] . '/en/lang.php')) { 1330dd7a6159SGerrit Uitslag include($config_file . $conf['template'] . '/en/lang.php'); 1331dd7a6159SGerrit Uitslag } 133217566ac6SAdrian Lang } 133317566ac6SAdrian Lang 1334dd7a6159SGerrit Uitslag if($conf['lang'] != 'en') { 1335dd7a6159SGerrit Uitslag @include($path . $conf['lang'] . '/lang.php'); 1336dd7a6159SGerrit Uitslag foreach($config_cascade['lang']['template'] as $config_file) { 133779e79377SAndreas Gohr if(file_exists($config_file . $conf['template'] . '/' . $conf['lang'] . '/lang.php')) { 1338dd7a6159SGerrit Uitslag include($config_file . $conf['template'] . '/' . $conf['lang'] . '/lang.php'); 1339dd7a6159SGerrit Uitslag } 1340dd7a6159SGerrit Uitslag } 1341dd7a6159SGerrit Uitslag } 134217566ac6SAdrian Lang } 134317566ac6SAdrian Lang return $lang[$id]; 134417566ac6SAdrian Lang} 134517566ac6SAdrian Lang 13463df72098SAndreas Gohr/** 1347c5c17fdaSKlap-in * Retrieve a language dependent file and pass to xhtml renderer for display 1348e8ec13b9SKlap-in * template equivalent of p_locale_xhtml() 1349e8ec13b9SKlap-in * 1350e8ec13b9SKlap-in * @param string $id id of language dependent wiki page 1351e8ec13b9SKlap-in * @return string parsed contents of the wiki page in xhtml format 1352e8ec13b9SKlap-in */ 1353e8ec13b9SKlap-infunction tpl_locale_xhtml($id) { 1354c5c17fdaSKlap-in return p_cached_output(tpl_localeFN($id)); 1355e8ec13b9SKlap-in} 1356e8ec13b9SKlap-in 1357e8ec13b9SKlap-in/** 1358c5c17fdaSKlap-in * Prepends appropriate path for a language dependent filename 135942ea7f44SGerrit Uitslag * 136042ea7f44SGerrit Uitslag * @param string $id id of localized text 136142ea7f44SGerrit Uitslag * @return string wiki text 1362e8ec13b9SKlap-in */ 1363c5c17fdaSKlap-infunction tpl_localeFN($id) { 1364e8ec13b9SKlap-in $path = tpl_incdir().'lang/'; 1365e8ec13b9SKlap-in global $conf; 136638fb1fc7SGerrit Uitslag $file = DOKU_CONF.'template_lang/'.$conf['template'].'/'.$conf['lang'].'/'.$id.'.txt'; 136779e79377SAndreas Gohr if (!file_exists($file)){ 1368e8ec13b9SKlap-in $file = $path.$conf['lang'].'/'.$id.'.txt'; 136979e79377SAndreas Gohr if(!file_exists($file)){ 1370e8ec13b9SKlap-in //fall back to english 1371e8ec13b9SKlap-in $file = $path.'en/'.$id.'.txt'; 1372e8ec13b9SKlap-in } 1373e8ec13b9SKlap-in } 1374e8ec13b9SKlap-in return $file; 1375e8ec13b9SKlap-in} 1376e8ec13b9SKlap-in 1377e8ec13b9SKlap-in/** 13787abc270fSGerrit Uitslag * prints the "main content" in the mediamanager popup 13793df72098SAndreas Gohr * 13803df72098SAndreas Gohr * Depending on the user's actions this may be a list of 13813df72098SAndreas Gohr * files in a namespace, the meta editing dialog or 13823df72098SAndreas Gohr * a message of referencing pages 13833df72098SAndreas Gohr * 13843df72098SAndreas Gohr * Only allowed in mediamanager.php 13853df72098SAndreas Gohr * 1386c182313eSAndreas Gohr * @triggers MEDIAMANAGER_CONTENT_OUTPUT 1387c182313eSAndreas Gohr * @param bool $fromajax - set true when calling this function via ajax 138842ea7f44SGerrit Uitslag * @param string $sort 13898702de7fSGerrit Uitslag * 13903df72098SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 13913df72098SAndreas Gohr */ 139200e3e394SChristopher Smithfunction tpl_mediaContent($fromajax = false, $sort='natural') { 13933df72098SAndreas Gohr global $IMG; 13943df72098SAndreas Gohr global $AUTH; 13953df72098SAndreas Gohr global $INUSE; 13963df72098SAndreas Gohr global $NS; 13973df72098SAndreas Gohr global $JUMPTO; 1398585bf44eSChristopher Smith /** @var Input $INPUT */ 1399ac7a515fSAndreas Gohr global $INPUT; 14003df72098SAndreas Gohr 1401ac7a515fSAndreas Gohr $do = $INPUT->extract('do')->str('do'); 1402c182313eSAndreas Gohr if(in_array($do, array('save', 'cancel'))) $do = ''; 1403c182313eSAndreas Gohr 1404c182313eSAndreas Gohr if(!$do) { 1405ac7a515fSAndreas Gohr if($INPUT->bool('edit')) { 1406c182313eSAndreas Gohr $do = 'metaform'; 1407c182313eSAndreas Gohr } elseif(is_array($INUSE)) { 1408c182313eSAndreas Gohr $do = 'filesinuse'; 1409c182313eSAndreas Gohr } else { 1410c182313eSAndreas Gohr $do = 'filelist'; 1411c182313eSAndreas Gohr } 1412c182313eSAndreas Gohr } 1413c182313eSAndreas Gohr 1414c182313eSAndreas Gohr // output the content pane, wrapped in an event. 1415c182313eSAndreas Gohr if(!$fromajax) ptln('<div id="media__content">'); 1416c182313eSAndreas Gohr $data = array('do' => $do); 1417c182313eSAndreas Gohr $evt = new Doku_Event('MEDIAMANAGER_CONTENT_OUTPUT', $data); 1418c182313eSAndreas Gohr if($evt->advise_before()) { 1419c182313eSAndreas Gohr $do = $data['do']; 142030fd72fbSKate Arzamastseva if($do == 'filesinuse') { 1421c182313eSAndreas Gohr media_filesinuse($INUSE, $IMG); 1422c182313eSAndreas Gohr } elseif($do == 'filelist') { 142300e3e394SChristopher Smith media_filelist($NS, $AUTH, $JUMPTO,false,$sort); 1424c9f56829SAndreas Gohr } elseif($do == 'searchlist') { 1425ac7a515fSAndreas Gohr media_searchlist($INPUT->str('q'), $NS, $AUTH); 1426c182313eSAndreas Gohr } else { 1427c182313eSAndreas Gohr msg('Unknown action '.hsc($do), -1); 1428c182313eSAndreas Gohr } 1429c182313eSAndreas Gohr } 1430c182313eSAndreas Gohr $evt->advise_after(); 1431c182313eSAndreas Gohr unset($evt); 1432c182313eSAndreas Gohr if(!$fromajax) ptln('</div>'); 1433c182313eSAndreas Gohr 14343df72098SAndreas Gohr} 14353df72098SAndreas Gohr 14363df72098SAndreas Gohr/** 1437d9162c6cSKate Arzamastseva * Prints the central column in full-screen media manager 1438d9162c6cSKate Arzamastseva * Depending on the opened tab this may be a list of 1439d9162c6cSKate Arzamastseva * files in a namespace, upload form or search form 1440d9162c6cSKate Arzamastseva * 1441d9162c6cSKate Arzamastseva * @author Kate Arzamastseva <pshns@ukr.net> 1442d9162c6cSKate Arzamastseva */ 1443035e07f1SKate Arzamastsevafunction tpl_mediaFileList() { 1444d9162c6cSKate Arzamastseva global $AUTH; 1445d9162c6cSKate Arzamastseva global $NS; 1446d9162c6cSKate Arzamastseva global $JUMPTO; 144795b451bcSAdrian Lang global $lang; 1448585bf44eSChristopher Smith /** @var Input $INPUT */ 1449ac7a515fSAndreas Gohr global $INPUT; 1450d9162c6cSKate Arzamastseva 1451ac7a515fSAndreas Gohr $opened_tab = $INPUT->str('tab_files'); 1452e5d185e1SKate Arzamastseva if(!$opened_tab || !in_array($opened_tab, array('files', 'upload', 'search'))) $opened_tab = 'files'; 1453ac7a515fSAndreas Gohr if($INPUT->str('mediado') == 'update') $opened_tab = 'upload'; 1454d9162c6cSKate Arzamastseva 145594add303SAnika Henke echo '<h2 class="a11y">'.$lang['mediaselect'].'</h2>'.NL; 145695b451bcSAdrian Lang 1457ed69a2aeSKate Arzamastseva media_tabs_files($opened_tab); 145823846a98SKate Arzamastseva 145994add303SAnika Henke echo '<div class="panelHeader">'.NL; 146095b451bcSAdrian Lang echo '<h3>'; 1461026d14a9SAnika Henke $tabTitle = ($NS) ? $NS : '['.$lang['mediaroot'].']'; 1462c98f205eSAdrian Lang printf($lang['media_'.$opened_tab], '<strong>'.hsc($tabTitle).'</strong>'); 146394add303SAnika Henke echo '</h3>'.NL; 146495b451bcSAdrian Lang if($opened_tab === 'search' || $opened_tab === 'files') { 146595b451bcSAdrian Lang media_tab_files_options(); 146623846a98SKate Arzamastseva } 146794add303SAnika Henke echo '</div>'.NL; 1468d9162c6cSKate Arzamastseva 146994add303SAnika Henke echo '<div class="panelContent">'.NL; 147095b451bcSAdrian Lang if($opened_tab == 'files') { 147195b451bcSAdrian Lang media_tab_files($NS, $AUTH, $JUMPTO); 147295b451bcSAdrian Lang } elseif($opened_tab == 'upload') { 147395b451bcSAdrian Lang media_tab_upload($NS, $AUTH, $JUMPTO); 147495b451bcSAdrian Lang } elseif($opened_tab == 'search') { 147595b451bcSAdrian Lang media_tab_search($NS, $AUTH); 147695b451bcSAdrian Lang } 147794add303SAnika Henke echo '</div>'.NL; 1478d9162c6cSKate Arzamastseva} 1479d9162c6cSKate Arzamastseva 1480d9162c6cSKate Arzamastseva/** 1481d9162c6cSKate Arzamastseva * Prints the third column in full-screen media manager 1482d9162c6cSKate Arzamastseva * Depending on the opened tab this may be details of the 1483d9162c6cSKate Arzamastseva * selected file, the meta editing dialog or 1484d9162c6cSKate Arzamastseva * list of file revisions 1485d9162c6cSKate Arzamastseva * 1486d9162c6cSKate Arzamastseva * @author Kate Arzamastseva <pshns@ukr.net> 1487f50a239bSTakamura * 1488f50a239bSTakamura * @param string $image 1489f50a239bSTakamura * @param boolean $rev 1490d9162c6cSKate Arzamastseva */ 1491035e07f1SKate Arzamastsevafunction tpl_mediaFileDetails($image, $rev) { 1492e8a2a143SMichael Hamann global $conf, $DEL, $lang; 1493585bf44eSChristopher Smith /** @var Input $INPUT */ 1494585bf44eSChristopher Smith global $INPUT; 1495d9162c6cSKate Arzamastseva 149692cac9a9SKate Arzamastseva $removed = (!file_exists(mediaFN($image)) && file_exists(mediaMetaFN($image, '.changes')) && $conf['mediarevisions']); 1497ac7a515fSAndreas Gohr if(!$image || (!file_exists(mediaFN($image)) && !$removed) || $DEL) return; 14986dd095f5SKate Arzamastseva if($rev && !file_exists(mediaFN($image, $rev))) $rev = false; 1499e8a2a143SMichael Hamann $ns = getNS($image); 1500ac7a515fSAndreas Gohr $do = $INPUT->str('mediado'); 15011eeeced2SKate Arzamastseva 1502ac7a515fSAndreas Gohr $opened_tab = $INPUT->str('tab_details'); 1503e5d185e1SKate Arzamastseva 1504e5d185e1SKate Arzamastseva $tab_array = array('view'); 1505ac7a515fSAndreas Gohr list(, $mime) = mimetype($image); 1506e5d185e1SKate Arzamastseva if($mime == 'image/jpeg') { 1507e5d185e1SKate Arzamastseva $tab_array[] = 'edit'; 1508e5d185e1SKate Arzamastseva } 1509e5d185e1SKate Arzamastseva if($conf['mediarevisions']) { 1510e5d185e1SKate Arzamastseva $tab_array[] = 'history'; 1511e5d185e1SKate Arzamastseva } 1512e5d185e1SKate Arzamastseva 1513e5d185e1SKate Arzamastseva if(!$opened_tab || !in_array($opened_tab, $tab_array)) $opened_tab = 'view'; 1514ac7a515fSAndreas Gohr if($INPUT->bool('edit')) $opened_tab = 'edit'; 151523846a98SKate Arzamastseva if($do == 'restore') $opened_tab = 'view'; 1516d9162c6cSKate Arzamastseva 1517ed69a2aeSKate Arzamastseva media_tabs_details($image, $opened_tab); 151823846a98SKate Arzamastseva 151959f3611bSAnika Henke echo '<div class="panelHeader"><h3>'; 1520ac7a515fSAndreas Gohr list($ext) = mimetype($image, false); 152195b451bcSAdrian Lang $class = preg_replace('/[^_\-a-z0-9]+/i', '_', $ext); 152295b451bcSAdrian Lang $class = 'select mediafile mf_'.$class; 152300c2d4a9SAnika Henke $tabTitle = '<strong><a href="'.ml($image).'" class="'.$class.'" title="'.$lang['mediaview'].'">'.$image.'</a>'.'</strong>'; 152408317413SAdrian Lang if($opened_tab === 'view' && $rev) { 152508317413SAdrian Lang printf($lang['media_viewold'], $tabTitle, dformat($rev)); 152608317413SAdrian Lang } else { 1527026d14a9SAnika Henke printf($lang['media_'.$opened_tab], $tabTitle); 152808317413SAdrian Lang } 1529b8a84c03SAndreas Gohr 153094add303SAnika Henke echo '</h3></div>'.NL; 153195b451bcSAdrian Lang 153294add303SAnika Henke echo '<div class="panelContent">'.NL; 153395b451bcSAdrian Lang 153423846a98SKate Arzamastseva if($opened_tab == 'view') { 1535e8a2a143SMichael Hamann media_tab_view($image, $ns, null, $rev); 153623846a98SKate Arzamastseva 153792cac9a9SKate Arzamastseva } elseif($opened_tab == 'edit' && !$removed) { 1538e8a2a143SMichael Hamann media_tab_edit($image, $ns); 153923846a98SKate Arzamastseva 1540e5d185e1SKate Arzamastseva } elseif($opened_tab == 'history' && $conf['mediarevisions']) { 1541e8a2a143SMichael Hamann media_tab_history($image, $ns); 154223846a98SKate Arzamastseva } 154395b451bcSAdrian Lang 154494add303SAnika Henke echo '</div>'.NL; 1545d9162c6cSKate Arzamastseva} 1546d9162c6cSKate Arzamastseva 1547d9162c6cSKate Arzamastseva/** 15487abc270fSGerrit Uitslag * prints the namespace tree in the mediamanager popup 15493df72098SAndreas Gohr * 15503df72098SAndreas Gohr * Only allowed in mediamanager.php 15513df72098SAndreas Gohr * 15523df72098SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 15533df72098SAndreas Gohr */ 1554fa8e5c77SKate Arzamastsevafunction tpl_mediaTree() { 15553df72098SAndreas Gohr global $NS; 155623846a98SKate Arzamastseva ptln('<div id="media__tree">'); 15573df72098SAndreas Gohr media_nstree($NS); 15583df72098SAndreas Gohr ptln('</div>'); 15593df72098SAndreas Gohr} 15603df72098SAndreas Gohr 1561a00de5b5SAndreas Gohr/** 1562a00de5b5SAndreas Gohr * Print a dropdown menu with all DokuWiki actions 1563a00de5b5SAndreas Gohr * 1564a00de5b5SAndreas Gohr * Note: this will not use any pretty URLs 1565a00de5b5SAndreas Gohr * 1566a00de5b5SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 156742ea7f44SGerrit Uitslag * 156842ea7f44SGerrit Uitslag * @param string $empty empty option label 156942ea7f44SGerrit Uitslag * @param string $button submit button label 1570a00de5b5SAndreas Gohr */ 157196d5526dSMichael Großefunction tpl_actiondropdown($empty = ' ', $button = '>') { 1572a00de5b5SAndreas Gohr global $ID; 1573a00de5b5SAndreas Gohr global $REV; 1574a00de5b5SAndreas Gohr global $lang; 1575585bf44eSChristopher Smith /** @var Input $INPUT */ 1576585bf44eSChristopher Smith global $INPUT; 1577a00de5b5SAndreas Gohr 1578768d1852SAnika Henke $action_structure = array( 1579768d1852SAnika Henke 'page_tools' => array('edit', 'revert', 'revisions', 'backlink', 'subscribe'), 1580768d1852SAnika Henke 'site_tools' => array('recent', 'media', 'index'), 1581768d1852SAnika Henke 'user_tools' => array('login', 'register', 'profile', 'admin'), 1582768d1852SAnika Henke ); 1583768d1852SAnika Henke 1584e63eccffSAndreas Gohr echo '<form action="'.script().'" method="get" accept-charset="utf-8">'; 15853b9a3b55SAnika Henke echo '<div class="no">'; 1586a00de5b5SAndreas Gohr echo '<input type="hidden" name="id" value="'.$ID.'" />'; 1587a00de5b5SAndreas Gohr if($REV) echo '<input type="hidden" name="rev" value="'.$REV.'" />'; 1588585bf44eSChristopher Smith if ($INPUT->server->str('REMOTE_USER')) { 1589a00de5b5SAndreas Gohr echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'; 159061efcda1SChristopher Smith } 1591a00de5b5SAndreas Gohr 15925f17c394SAnika Henke echo '<select name="do" class="edit quickselect" title="'.$lang['tools'].'">'; 1593a00de5b5SAndreas Gohr echo '<option value="">'.$empty.'</option>'; 1594a00de5b5SAndreas Gohr 1595768d1852SAnika Henke foreach($action_structure as $tools => $actions) { 1596768d1852SAnika Henke echo '<optgroup label="'.$lang[$tools].'">'; 1597768d1852SAnika Henke foreach($actions as $action) { 1598768d1852SAnika Henke $act = tpl_get_action($action); 1599396c218fSAndreas Gohr if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>'; 1600768d1852SAnika Henke } 1601a00de5b5SAndreas Gohr echo '</optgroup>'; 1602768d1852SAnika Henke } 1603a00de5b5SAndreas Gohr 1604a00de5b5SAndreas Gohr echo '</select>'; 1605ae614416SAnika Henke echo '<button type="submit">'.$button.'</button>'; 16063b9a3b55SAnika Henke echo '</div>'; 1607a00de5b5SAndreas Gohr echo '</form>'; 1608a00de5b5SAndreas Gohr} 1609a00de5b5SAndreas Gohr 1610066fee30SAndreas Gohr/** 1611066fee30SAndreas Gohr * Print a informational line about the used license 1612066fee30SAndreas Gohr * 1613066fee30SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1614ac7a515fSAndreas Gohr * @param string $img print image? (|button|badge) 1615ac7a515fSAndreas Gohr * @param bool $imgonly skip the textual description? 1616ac7a515fSAndreas Gohr * @param bool $return when true don't print, but return HTML 1617ac7a515fSAndreas Gohr * @param bool $wrap wrap in div with class="license"? 1618ac7a515fSAndreas Gohr * @return string 1619066fee30SAndreas Gohr */ 162080083a41SAndreas Gohrfunction tpl_license($img = 'badge', $imgonly = false, $return = false, $wrap = true) { 1621066fee30SAndreas Gohr global $license; 1622066fee30SAndreas Gohr global $conf; 1623066fee30SAndreas Gohr global $lang; 1624066fee30SAndreas Gohr if(!$conf['license']) return ''; 1625066fee30SAndreas Gohr if(!is_array($license[$conf['license']])) return ''; 1626066fee30SAndreas Gohr $lic = $license[$conf['license']]; 162753e15c8bSAnika Henke $target = ($conf['target']['extern']) ? ' target="'.$conf['target']['extern'].'"' : ''; 1628066fee30SAndreas Gohr 162980083a41SAndreas Gohr $out = ''; 163080083a41SAndreas Gohr if($wrap) $out .= '<div class="license">'; 1631066fee30SAndreas Gohr if($img) { 1632066fee30SAndreas Gohr $src = license_img($img); 1633066fee30SAndreas Gohr if($src) { 163453e15c8bSAnika Henke $out .= '<a href="'.$lic['url'].'" rel="license"'.$target; 163553e15c8bSAnika Henke $out .= '><img src="'.DOKU_BASE.$src.'" alt="'.$lic['name'].'" /></a>'; 163653e15c8bSAnika Henke if(!$imgonly) $out .= ' '; 1637066fee30SAndreas Gohr } 1638066fee30SAndreas Gohr } 16394cefd216SMichael Klier if(!$imgonly) { 164053e15c8bSAnika Henke $out .= $lang['license'].' '; 1641d317fb5dSAnika Henke $out .= '<bdi><a href="'.$lic['url'].'" rel="license" class="urlextern"'.$target; 1642d317fb5dSAnika Henke $out .= '>'.$lic['name'].'</a></bdi>'; 16434cefd216SMichael Klier } 164480083a41SAndreas Gohr if($wrap) $out .= '</div>'; 1645066fee30SAndreas Gohr 1646066fee30SAndreas Gohr if($return) return $out; 1647066fee30SAndreas Gohr echo $out; 1648ac7a515fSAndreas Gohr return ''; 1649066fee30SAndreas Gohr} 1650066fee30SAndreas Gohr 1651a81910eeSAndreas Gohr/** 1652835dfcaeSAnika Henke * Includes the rendered HTML of a given page 1653a81910eeSAndreas Gohr * 1654a81910eeSAndreas Gohr * This function is useful to populate sidebars or similar features in a 1655a81910eeSAndreas Gohr * template 1656e0c26282SGerrit Uitslag * 16577a112df5SAndreas Gohr * @param string $pageid The page name you want to include 16587a112df5SAndreas Gohr * @param bool $print Should the content be printed or returned only 16597a112df5SAndreas Gohr * @param bool $propagate Search higher namespaces, too? 16607c3e4a67SAndreas Gohr * @param bool $useacl Include the page only if the ACLs check out? 1661e0c26282SGerrit Uitslag * @return bool|null|string 1662a81910eeSAndreas Gohr */ 16637c3e4a67SAndreas Gohrfunction tpl_include_page($pageid, $print = true, $propagate = false, $useacl = true) { 16647a112df5SAndreas Gohr if($propagate) { 16657c3e4a67SAndreas Gohr $pageid = page_findnearest($pageid, $useacl); 16667c3e4a67SAndreas Gohr } elseif($useacl && auth_quickaclcheck($pageid) == AUTH_NONE) { 16677a112df5SAndreas Gohr return false; 16687a112df5SAndreas Gohr } 1669c786a1b6SAnika Henke if(!$pageid) return false; 1670835dfcaeSAnika Henke 1671c786a1b6SAnika Henke global $TOC; 16729a2e250aSAndreas Gohr $oldtoc = $TOC; 1673a81910eeSAndreas Gohr $html = p_wiki_xhtml($pageid, '', false); 16749a2e250aSAndreas Gohr $TOC = $oldtoc; 1675a81910eeSAndreas Gohr 1676a2e03c82SAndreas Gohr if($print) echo $html; 1677e66d3e6dSAndreas Gohr return $html; 1678e66d3e6dSAndreas Gohr} 1679e66d3e6dSAndreas Gohr 1680e66d3e6dSAndreas Gohr/** 16815b75cd1fSAdrian Lang * Display the subscribe form 16825b75cd1fSAdrian Lang * 16835b75cd1fSAdrian Lang * @author Adrian Lang <lang@cosmocode.de> 16845b75cd1fSAdrian Lang */ 16855b75cd1fSAdrian Langfunction tpl_subscribe() { 16865b75cd1fSAdrian Lang global $INFO; 16875b75cd1fSAdrian Lang global $ID; 16885b75cd1fSAdrian Lang global $lang; 16896b8f02cfSAdrian Lang global $conf; 169040c347dbSAdrian Lang $stime_days = $conf['subscribe_time'] / 60 / 60 / 24; 16915b75cd1fSAdrian Lang 16925b75cd1fSAdrian Lang echo p_locale_xhtml('subscr_form'); 16935b75cd1fSAdrian Lang echo '<h2>'.$lang['subscr_m_current_header'].'</h2>'; 169415741132SAndreas Gohr echo '<div class="level2">'; 16955b75cd1fSAdrian Lang if($INFO['subscribed'] === false) { 16965b75cd1fSAdrian Lang echo '<p>'.$lang['subscr_m_not_subscribed'].'</p>'; 16975b75cd1fSAdrian Lang } else { 16985b75cd1fSAdrian Lang echo '<ul>'; 16995b75cd1fSAdrian Lang foreach($INFO['subscribed'] as $sub) { 1700056c2049SAndreas Gohr echo '<li><div class="li">'; 17015b75cd1fSAdrian Lang if($sub['target'] !== $ID) { 1702056c2049SAndreas Gohr echo '<code class="ns">'.hsc(prettyprint_id($sub['target'])).'</code>'; 17035b75cd1fSAdrian Lang } else { 1704056c2049SAndreas Gohr echo '<code class="page">'.hsc(prettyprint_id($sub['target'])).'</code>'; 17055b75cd1fSAdrian Lang } 170640c347dbSAdrian Lang $sstl = sprintf($lang['subscr_style_'.$sub['style']], $stime_days); 170715741132SAndreas Gohr if(!$sstl) $sstl = hsc($sub['style']); 1708056c2049SAndreas Gohr echo ' ('.$sstl.') '; 170915741132SAndreas Gohr 1710ac7a515fSAndreas Gohr echo '<a href="'.wl( 1711ac7a515fSAndreas Gohr $ID, 1712ac7a515fSAndreas Gohr array( 1713ac7a515fSAndreas Gohr 'do' => 'subscribe', 171466d2bed9SAdrian Lang 'sub_target'=> $sub['target'], 171566d2bed9SAdrian Lang 'sub_style' => $sub['style'], 171666d2bed9SAdrian Lang 'sub_action'=> 'unsubscribe', 1717ac7a515fSAndreas Gohr 'sectok' => getSecurityToken() 1718ac7a515fSAndreas Gohr ) 1719ac7a515fSAndreas Gohr ). 172066d2bed9SAdrian Lang '" class="unsubscribe">'.$lang['subscr_m_unsubscribe']. 172166d2bed9SAdrian Lang '</a></div></li>'; 17225b75cd1fSAdrian Lang } 17235b75cd1fSAdrian Lang echo '</ul>'; 17245b75cd1fSAdrian Lang } 172515741132SAndreas Gohr echo '</div>'; 17265b75cd1fSAdrian Lang 172715741132SAndreas Gohr // Add new subscription form 17285b75cd1fSAdrian Lang echo '<h2>'.$lang['subscr_m_new_header'].'</h2>'; 172915741132SAndreas Gohr echo '<div class="level2">'; 17305b75cd1fSAdrian Lang $ns = getNS($ID).':'; 173115741132SAndreas Gohr $targets = array( 173215741132SAndreas Gohr $ID => '<code class="page">'.prettyprint_id($ID).'</code>', 173315741132SAndreas Gohr $ns => '<code class="ns">'.prettyprint_id($ns).'</code>', 173415741132SAndreas Gohr ); 173515741132SAndreas Gohr $styles = array( 173615741132SAndreas Gohr 'every' => $lang['subscr_style_every'], 17376b8f02cfSAdrian Lang 'digest' => sprintf($lang['subscr_style_digest'], $stime_days), 17386b8f02cfSAdrian Lang 'list' => sprintf($lang['subscr_style_list'], $stime_days), 173915741132SAndreas Gohr ); 174015741132SAndreas Gohr 1741056c2049SAndreas Gohr $form = new Doku_Form(array('id' => 'subscribe__form')); 1742056c2049SAndreas Gohr $form->startFieldset($lang['subscr_m_subscribe']); 1743056c2049SAndreas Gohr $form->addRadioSet('sub_target', $targets); 1744056c2049SAndreas Gohr $form->startFieldset($lang['subscr_m_receive']); 1745056c2049SAndreas Gohr $form->addRadioSet('sub_style', $styles); 1746056c2049SAndreas Gohr $form->addHidden('sub_action', 'subscribe'); 1747056c2049SAndreas Gohr $form->addHidden('do', 'subscribe'); 1748056c2049SAndreas Gohr $form->addHidden('id', $ID); 1749056c2049SAndreas Gohr $form->endFieldset(); 17505b75cd1fSAdrian Lang $form->addElement(form_makeButton('submit', 'subscribe', $lang['subscr_m_subscribe'])); 17515b75cd1fSAdrian Lang html_form('SUBSCRIBE', $form); 175215741132SAndreas Gohr echo '</div>'; 17535b75cd1fSAdrian Lang} 17545b75cd1fSAdrian Lang 1755d059ba9bSAndreas Gohr/** 1756d059ba9bSAndreas Gohr * Tries to send already created content right to the browser 1757d059ba9bSAndreas Gohr * 1758d059ba9bSAndreas Gohr * Wraps around ob_flush() and flush() 1759d059ba9bSAndreas Gohr * 1760d059ba9bSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1761d059ba9bSAndreas Gohr */ 1762d059ba9bSAndreas Gohrfunction tpl_flush() { 1763d059ba9bSAndreas Gohr ob_flush(); 1764d059ba9bSAndreas Gohr flush(); 1765d059ba9bSAndreas Gohr} 1766d059ba9bSAndreas Gohr 1767afca7e7eSAnika Henke/** 1768378325f9SAndreas Gohr * Tries to find a ressource file in the given locations. 1769afca7e7eSAnika Henke * 1770378325f9SAndreas Gohr * If a given location starts with a colon it is assumed to be a media 1771378325f9SAndreas Gohr * file, otherwise it is assumed to be relative to the current template 1772378325f9SAndreas Gohr * 177342ea7f44SGerrit Uitslag * @param string[] $search locations to look at 1774378325f9SAndreas Gohr * @param bool $abs if to use absolute URL 1775ac7a515fSAndreas Gohr * @param array &$imginfo filled with getimagesize() 1776ac7a515fSAndreas Gohr * @return string 177742ea7f44SGerrit Uitslag * 1778378325f9SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1779afca7e7eSAnika Henke */ 1780378325f9SAndreas Gohrfunction tpl_getMediaFile($search, $abs = false, &$imginfo = null) { 1781ac7a515fSAndreas Gohr $img = ''; 1782ac7a515fSAndreas Gohr $file = ''; 1783ac7a515fSAndreas Gohr $ismedia = false; 1784378325f9SAndreas Gohr // loop through candidates until a match was found: 1785378325f9SAndreas Gohr foreach($search as $img) { 1786378325f9SAndreas Gohr if(substr($img, 0, 1) == ':') { 1787378325f9SAndreas Gohr $file = mediaFN($img); 1788378325f9SAndreas Gohr $ismedia = true; 1789378325f9SAndreas Gohr } else { 1790c4766956SAndreas Gohr $file = tpl_incdir().$img; 1791378325f9SAndreas Gohr $ismedia = false; 17921f13e33dSAnika Henke } 17930f747863Slupo49 1794378325f9SAndreas Gohr if(file_exists($file)) break; 1795872a6d29SAnika Henke } 1796378325f9SAndreas Gohr 1797378325f9SAndreas Gohr // fetch image data if requested 1798378325f9SAndreas Gohr if(!is_null($imginfo)) { 1799378325f9SAndreas Gohr $imginfo = getimagesize($file); 1800378325f9SAndreas Gohr } 1801378325f9SAndreas Gohr 1802378325f9SAndreas Gohr // build URL 1803378325f9SAndreas Gohr if($ismedia) { 1804378325f9SAndreas Gohr $url = ml($img, '', true, '', $abs); 1805378325f9SAndreas Gohr } else { 1806c4766956SAndreas Gohr $url = tpl_basedir().$img; 1807378325f9SAndreas Gohr if($abs) $url = DOKU_URL.substr($url, strlen(DOKU_REL)); 1808378325f9SAndreas Gohr } 1809378325f9SAndreas Gohr 1810378325f9SAndreas Gohr return $url; 1811a7e5f74cSlupo49} 18121f13e33dSAnika Henke 1813872a6d29SAnika Henke/** 1814e5d4768dSAndreas Gohr * PHP include a file 1815e5d4768dSAndreas Gohr * 1816e5d4768dSAndreas Gohr * either from the conf directory if it exists, otherwise use 1817e5d4768dSAndreas Gohr * file in the template's root directory. 1818e5d4768dSAndreas Gohr * 1819e5d4768dSAndreas Gohr * The function honours config cascade settings and looks for the given 1820e5d4768dSAndreas Gohr * file next to the ´main´ config files, in the order protected, local, 1821e5d4768dSAndreas Gohr * default. 1822e5d4768dSAndreas Gohr * 1823e5d4768dSAndreas Gohr * Note: no escaping or sanity checking is done here. Never pass user input 1824e5d4768dSAndreas Gohr * to this function! 1825e5d4768dSAndreas Gohr * 1826e5d4768dSAndreas Gohr * @author Anika Henke <anika@selfthinker.org> 1827e5d4768dSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 182842ea7f44SGerrit Uitslag * 182942ea7f44SGerrit Uitslag * @param string $file 1830e5d4768dSAndreas Gohr */ 1831e5d4768dSAndreas Gohrfunction tpl_includeFile($file) { 1832e5d4768dSAndreas Gohr global $config_cascade; 1833e5d4768dSAndreas Gohr foreach(array('protected', 'local', 'default') as $config_group) { 1834e5d4768dSAndreas Gohr if(empty($config_cascade['main'][$config_group])) continue; 1835e5d4768dSAndreas Gohr foreach($config_cascade['main'][$config_group] as $conf_file) { 1836e5d4768dSAndreas Gohr $dir = dirname($conf_file); 1837e5d4768dSAndreas Gohr if(file_exists("$dir/$file")) { 1838f3a1225fSAnika Henke include("$dir/$file"); 1839e5d4768dSAndreas Gohr return; 1840e5d4768dSAndreas Gohr } 1841e5d4768dSAndreas Gohr } 1842e5d4768dSAndreas Gohr } 1843e5d4768dSAndreas Gohr 1844e5d4768dSAndreas Gohr // still here? try the template dir 1845e5d4768dSAndreas Gohr $file = tpl_incdir().$file; 1846e5d4768dSAndreas Gohr if(file_exists($file)) { 1847f3a1225fSAnika Henke include($file); 1848e5d4768dSAndreas Gohr } 1849e5d4768dSAndreas Gohr} 1850e5d4768dSAndreas Gohr 1851e5d4768dSAndreas Gohr/** 1852872a6d29SAnika Henke * Returns <link> tag for various icon types (favicon|mobile|generic) 1853872a6d29SAnika Henke * 1854872a6d29SAnika Henke * @author Anika Henke <anika@selfthinker.org> 185542ea7f44SGerrit Uitslag * 1856ac7a515fSAndreas Gohr * @param array $types - list of icon types to display (favicon|mobile|generic) 1857ac7a515fSAndreas Gohr * @return string 1858872a6d29SAnika Henke */ 1859872a6d29SAnika Henkefunction tpl_favicon($types = array('favicon')) { 1860872a6d29SAnika Henke 1861872a6d29SAnika Henke $return = ''; 1862872a6d29SAnika Henke 1863872a6d29SAnika Henke foreach($types as $type) { 1864872a6d29SAnika Henke switch($type) { 1865872a6d29SAnika Henke case 'favicon': 1866378325f9SAndreas Gohr $look = array(':wiki:favicon.ico', ':favicon.ico', 'images/favicon.ico'); 1867378325f9SAndreas Gohr $return .= '<link rel="shortcut icon" href="'.tpl_getMediaFile($look).'" />'.NL; 1868872a6d29SAnika Henke break; 1869872a6d29SAnika Henke case 'mobile': 1870cab75975SAnika Henke $look = array(':wiki:apple-touch-icon.png', ':apple-touch-icon.png', 'images/apple-touch-icon.png'); 1871378325f9SAndreas Gohr $return .= '<link rel="apple-touch-icon" href="'.tpl_getMediaFile($look).'" />'.NL; 1872872a6d29SAnika Henke break; 1873872a6d29SAnika Henke case 'generic': 1874872a6d29SAnika Henke // ideal world solution, which doesn't work in any browser yet 1875378325f9SAndreas Gohr $look = array(':wiki:favicon.svg', ':favicon.svg', 'images/favicon.svg'); 1876378325f9SAndreas Gohr $return .= '<link rel="icon" href="'.tpl_getMediaFile($look).'" type="image/svg+xml" />'.NL; 1877872a6d29SAnika Henke break; 1878872a6d29SAnika Henke } 1879872a6d29SAnika Henke } 1880872a6d29SAnika Henke 1881872a6d29SAnika Henke return $return; 1882afca7e7eSAnika Henke} 1883afca7e7eSAnika Henke 1884d9162c6cSKate Arzamastseva/** 1885d9162c6cSKate Arzamastseva * Prints full-screen media manager 1886d9162c6cSKate Arzamastseva * 1887d9162c6cSKate Arzamastseva * @author Kate Arzamastseva <pshns@ukr.net> 1888d9162c6cSKate Arzamastseva */ 1889d9162c6cSKate Arzamastsevafunction tpl_media() { 1890ac7a515fSAndreas Gohr global $NS, $IMG, $JUMPTO, $REV, $lang, $fullscreen, $INPUT; 189188a71175SKate Arzamastseva $fullscreen = true; 189295b451bcSAdrian Lang require_once DOKU_INC.'lib/exe/mediamanager.php'; 1893d9162c6cSKate Arzamastseva 1894ac7a515fSAndreas Gohr $rev = ''; 1895ac7a515fSAndreas Gohr $image = cleanID($INPUT->str('image')); 189698f03b57SKate Arzamastseva if(isset($IMG)) $image = $IMG; 189798f03b57SKate Arzamastseva if(isset($JUMPTO)) $image = $JUMPTO; 18989c1bd4bcSKate Arzamastseva if(isset($REV) && !$JUMPTO) $rev = $REV; 189998f03b57SKate Arzamastseva 190094add303SAnika Henke echo '<div id="mediamanager__page">'.NL; 1901bc314c58SAnika Henke echo '<h1>'.$lang['btn_media'].'</h1>'.NL; 1902d9162c6cSKate Arzamastseva html_msgarea(); 190394add303SAnika Henke 190494add303SAnika Henke echo '<div class="panel namespaces">'.NL; 190594add303SAnika Henke echo '<h2>'.$lang['namespaces'].'</h2>'.NL; 190695b451bcSAdrian Lang echo '<div class="panelHeader">'; 1907ba340a70SAnika Henke echo $lang['media_namespaces']; 190894add303SAnika Henke echo '</div>'.NL; 190995b451bcSAdrian Lang 191094add303SAnika Henke echo '<div class="panelContent" id="media__tree">'.NL; 191195b451bcSAdrian Lang media_nstree($NS); 191294add303SAnika Henke echo '</div>'.NL; 191394add303SAnika Henke echo '</div>'.NL; 1914fa8e5c77SKate Arzamastseva 191594add303SAnika Henke echo '<div class="panel filelist">'.NL; 1916035e07f1SKate Arzamastseva tpl_mediaFileList(); 191794add303SAnika Henke echo '</div>'.NL; 1918fa8e5c77SKate Arzamastseva 191994add303SAnika Henke echo '<div class="panel file">'.NL; 192094add303SAnika Henke echo '<h2 class="a11y">'.$lang['media_file'].'</h2>'.NL; 1921035e07f1SKate Arzamastseva tpl_mediaFileDetails($image, $rev); 192294add303SAnika Henke echo '</div>'.NL; 1923ba340a70SAnika Henke 192494add303SAnika Henke echo '</div>'.NL; 1925d9162c6cSKate Arzamastseva} 1926afca7e7eSAnika Henke 1927c71db656SAnika Henke/** 1928c71db656SAnika Henke * Return useful layout classes 1929c71db656SAnika Henke * 1930c71db656SAnika Henke * @author Anika Henke <anika@selfthinker.org> 193142ea7f44SGerrit Uitslag * 193242ea7f44SGerrit Uitslag * @return string 1933c71db656SAnika Henke */ 1934c71db656SAnika Henkefunction tpl_classes() { 1935c71db656SAnika Henke global $ACT, $conf, $ID, $INFO; 1936585bf44eSChristopher Smith /** @var Input $INPUT */ 1937585bf44eSChristopher Smith global $INPUT; 1938585bf44eSChristopher Smith 1939c71db656SAnika Henke $classes = array( 1940c71db656SAnika Henke 'dokuwiki', 1941c71db656SAnika Henke 'mode_'.$ACT, 1942c71db656SAnika Henke 'tpl_'.$conf['template'], 1943585bf44eSChristopher Smith $INPUT->server->bool('REMOTE_USER') ? 'loggedIn' : '', 194439f00629SAnika Henke $INFO['exists'] ? '' : 'notFound', 1945c71db656SAnika Henke ($ID == $conf['start']) ? 'home' : '', 1946c71db656SAnika Henke ); 1947c71db656SAnika Henke return join(' ', $classes); 1948c71db656SAnika Henke} 1949c71db656SAnika Henke 195084dd2b1aSGerrit Uitslag/** 195184dd2b1aSGerrit Uitslag * Create event for tools menues 195284dd2b1aSGerrit Uitslag * 195384dd2b1aSGerrit Uitslag * @author Anika Henke <anika@selfthinker.org> 195484dd2b1aSGerrit Uitslag * @param string $toolsname name of menu 195584dd2b1aSGerrit Uitslag * @param array $items 195684dd2b1aSGerrit Uitslag * @param string $view e.g. 'main', 'detail', ... 195784dd2b1aSGerrit Uitslag */ 195884dd2b1aSGerrit Uitslagfunction tpl_toolsevent($toolsname, $items, $view = 'main') { 195984dd2b1aSGerrit Uitslag $data = array( 196084dd2b1aSGerrit Uitslag 'view' => $view, 196184dd2b1aSGerrit Uitslag 'items' => $items 196284dd2b1aSGerrit Uitslag ); 196384dd2b1aSGerrit Uitslag 196484dd2b1aSGerrit Uitslag $hook = 'TEMPLATE_' . strtoupper($toolsname) . '_DISPLAY'; 196584dd2b1aSGerrit Uitslag $evt = new Doku_Event($hook, $data); 196684dd2b1aSGerrit Uitslag if($evt->advise_before()) { 196784dd2b1aSGerrit Uitslag foreach($evt->data['items'] as $k => $html) echo $html; 196884dd2b1aSGerrit Uitslag } 196984dd2b1aSGerrit Uitslag $evt->advise_after(); 197084dd2b1aSGerrit Uitslag} 197184dd2b1aSGerrit Uitslag 1972e3776c06SMichael Hamann//Setup VIM: ex: et ts=4 : 1973a00de5b5SAndreas Gohr 1974