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 */ 957ea0913cSchrisfunction tpl_content_core() { 966b13307fSandi global $ACT; 976b13307fSandi global $TEXT; 986b13307fSandi global $PRE; 996b13307fSandi global $SUF; 1006b13307fSandi global $SUM; 1016b13307fSandi global $IDX; 102ac7a515fSAndreas Gohr global $INPUT; 1036b13307fSandi 1046b13307fSandi switch($ACT) { 1056b13307fSandi case 'show': 1066b13307fSandi html_show(); 1076b13307fSandi break; 108ac7a515fSAndreas Gohr /** @noinspection PhpMissingBreakStatementInspection */ 10945a99335SAdrian Lang case 'locked': 11045a99335SAdrian Lang html_locked(); 1116b13307fSandi case 'edit': 11245a99335SAdrian Lang case 'recover': 1136b13307fSandi html_edit(); 1146b13307fSandi break; 11545a99335SAdrian Lang case 'preview': 11645a99335SAdrian Lang html_edit(); 11745a99335SAdrian Lang html_show($TEXT); 11845a99335SAdrian Lang break; 119ee4c4a1bSAndreas Gohr case 'draft': 120ee4c4a1bSAndreas Gohr html_draft(); 121ee4c4a1bSAndreas Gohr break; 1226b13307fSandi case 'search': 1236b13307fSandi html_search(); 1246b13307fSandi break; 1256b13307fSandi case 'revisions': 126ac7a515fSAndreas Gohr html_revisions($INPUT->int('first')); 1276b13307fSandi break; 1286b13307fSandi case 'diff': 1296b13307fSandi html_diff(); 1306b13307fSandi break; 1316b13307fSandi case 'recent': 1323c94d07bSAnika Henke $show_changes = $INPUT->str('show_changes'); 1333c94d07bSAnika Henke if (empty($show_changes)) { 1343c94d07bSAnika Henke $show_changes = get_doku_pref('show_changes', $show_changes); 1353c94d07bSAnika Henke } 1363c94d07bSAnika Henke html_recent($INPUT->extract('first')->int('first'), $show_changes); 1376b13307fSandi break; 1386b13307fSandi case 'index': 1396b13307fSandi html_index($IDX); #FIXME can this be pulled from globals? is it sanitized correctly? 1406b13307fSandi break; 1416b13307fSandi case 'backlink': 1426b13307fSandi html_backlinks(); 1436b13307fSandi break; 1446b13307fSandi case 'conflict': 1456b13307fSandi html_conflict(con($PRE, $TEXT, $SUF), $SUM); 1466b13307fSandi html_diff(con($PRE, $TEXT, $SUF), false); 1476b13307fSandi break; 1486b13307fSandi case 'login': 1496b13307fSandi html_login(); 1506b13307fSandi break; 1516b13307fSandi case 'register': 1526b13307fSandi html_register(); 1536b13307fSandi break; 1548b06d178Schris case 'resendpwd': 1558b06d178Schris html_resendpwd(); 1568b06d178Schris break; 157820fa24bSandi case 'denied': 1582f2c518cSGerrit Uitslag html_denied(); 159820fa24bSandi break; 1608b06d178Schris case 'profile' : 1618b06d178Schris html_updateprofile(); 1628b06d178Schris break; 163c19fe9c0Sandi case 'admin': 164c19fe9c0Sandi tpl_admin(); 165c19fe9c0Sandi break; 1665b75cd1fSAdrian Lang case 'subscribe': 1675b75cd1fSAdrian Lang tpl_subscribe(); 1685b75cd1fSAdrian Lang break; 169d9162c6cSKate Arzamastseva case 'media': 170d9162c6cSKate Arzamastseva tpl_media(); 171d9162c6cSKate Arzamastseva break; 1726b13307fSandi default: 17324bb549bSchris $evt = new Doku_Event('TPL_ACT_UNKNOWN', $ACT); 174a85f63deSGerrit Uitslag if($evt->advise_before()) { 175ea67f144Sandi msg("Failed to handle command: ".hsc($ACT), -1); 176a85f63deSGerrit Uitslag } 17724bb549bSchris $evt->advise_after(); 17824bb549bSchris unset($evt); 17954e95700STom N Harris return false; 1806b13307fSandi } 18154e95700STom N Harris return true; 1826b13307fSandi} 1836b13307fSandi 184c19fe9c0Sandi/** 185b8595a66SAndreas Gohr * Places the TOC where the function is called 186b8595a66SAndreas Gohr * 187b8595a66SAndreas Gohr * If you use this you most probably want to call tpl_content with 188b8595a66SAndreas Gohr * a false argument 189b8595a66SAndreas Gohr * 190b8595a66SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 19142ea7f44SGerrit Uitslag * 192ac7a515fSAndreas Gohr * @param bool $return Should the TOC be returned instead to be printed? 193ac7a515fSAndreas Gohr * @return string 194b8595a66SAndreas Gohr */ 195b8595a66SAndreas Gohrfunction tpl_toc($return = false) { 196b8595a66SAndreas Gohr global $TOC; 197b8595a66SAndreas Gohr global $ACT; 198b8595a66SAndreas Gohr global $ID; 199b8595a66SAndreas Gohr global $REV; 200b8595a66SAndreas Gohr global $INFO; 201851f2e89SAnika Henke global $conf; 202ac7a515fSAndreas Gohr global $INPUT; 203b8595a66SAndreas Gohr $toc = array(); 204b8595a66SAndreas Gohr 205b8595a66SAndreas Gohr if(is_array($TOC)) { 206b8595a66SAndreas Gohr // if a TOC was prepared in global scope, always use it 207b8595a66SAndreas Gohr $toc = $TOC; 2083c86d7c9SAndreas Gohr } elseif(($ACT == 'show' || substr($ACT, 0, 6) == 'export') && !$REV && $INFO['exists']) { 209b8595a66SAndreas Gohr // get TOC from metadata, render if neccessary 210e0c26282SGerrit Uitslag $meta = p_get_metadata($ID, '', METADATA_RENDER_USING_CACHE); 211b8595a66SAndreas Gohr if(isset($meta['internal']['toc'])) { 212b8595a66SAndreas Gohr $tocok = $meta['internal']['toc']; 213b8595a66SAndreas Gohr } else { 2142bb0d541Schris $tocok = true; 215b8595a66SAndreas Gohr } 216f87b5dbbSChristopher Smith $toc = isset($meta['description']['tableofcontents']) ? $meta['description']['tableofcontents'] : null; 217851f2e89SAnika Henke if(!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']) { 218b8595a66SAndreas Gohr $toc = array(); 219b8595a66SAndreas Gohr } 220b8595a66SAndreas Gohr } elseif($ACT == 'admin') { 221b8595a66SAndreas Gohr // try to load admin plugin TOC FIXME: duplicates code from tpl_admin 222b8595a66SAndreas Gohr $plugin = null; 223ac7a515fSAndreas Gohr $class = $INPUT->str('page'); 224ac7a515fSAndreas Gohr if(!empty($class)) { 225b8595a66SAndreas Gohr $pluginlist = plugin_list('admin'); 226ac7a515fSAndreas Gohr if(in_array($class, $pluginlist)) { 227b8595a66SAndreas Gohr // attempt to load the plugin 228ac7a515fSAndreas Gohr /** @var $plugin DokuWiki_Admin_Plugin */ 229a04f2bd5SGerrit Uitslag $plugin = plugin_load('admin', $class); 230b8595a66SAndreas Gohr } 231b8595a66SAndreas Gohr } 232ac7a515fSAndreas Gohr if( ($plugin !== null) && (!$plugin->forAdminOnly() || $INFO['isadmin']) ) { 233b8595a66SAndreas Gohr $toc = $plugin->getTOC(); 234b8595a66SAndreas Gohr $TOC = $toc; // avoid later rebuild 235b8595a66SAndreas Gohr } 236b8595a66SAndreas Gohr } 237b8595a66SAndreas Gohr 2380b17fdc6SAndreas Gohr trigger_event('TPL_TOC_RENDER', $toc, null, false); 239b8595a66SAndreas Gohr $html = html_TOC($toc); 240b8595a66SAndreas Gohr if($return) return $html; 241b8595a66SAndreas Gohr echo $html; 242ac7a515fSAndreas Gohr return ''; 243b8595a66SAndreas Gohr} 244b8595a66SAndreas Gohr 245b8595a66SAndreas Gohr/** 246c19fe9c0Sandi * Handle the admin page contents 247c19fe9c0Sandi * 248c19fe9c0Sandi * @author Andreas Gohr <andi@splitbrain.org> 24942ea7f44SGerrit Uitslag * 25042ea7f44SGerrit Uitslag * @return bool 251c19fe9c0Sandi */ 252c19fe9c0Sandifunction tpl_admin() { 253f8cc712eSAndreas Gohr global $INFO; 254b8595a66SAndreas Gohr global $TOC; 255ac7a515fSAndreas Gohr global $INPUT; 25611e2ce22Schris 257b8595a66SAndreas Gohr $plugin = null; 258ac7a515fSAndreas Gohr $class = $INPUT->str('page'); 259ac7a515fSAndreas Gohr if(!empty($class)) { 26011e2ce22Schris $pluginlist = plugin_list('admin'); 26111e2ce22Schris 262ac7a515fSAndreas Gohr if(in_array($class, $pluginlist)) { 26311e2ce22Schris // attempt to load the plugin 264ac7a515fSAndreas Gohr /** @var $plugin DokuWiki_Admin_Plugin */ 265a04f2bd5SGerrit Uitslag $plugin = plugin_load('admin', $class); 26611e2ce22Schris } 26711e2ce22Schris } 26811e2ce22Schris 269b8595a66SAndreas Gohr if($plugin !== null) { 270b8595a66SAndreas Gohr if(!is_array($TOC)) $TOC = $plugin->getTOC(); //if TOC wasn't requested yet 271b8595a66SAndreas Gohr if($INFO['prependTOC']) tpl_toc(); 272f8cc712eSAndreas Gohr $plugin->html(); 273f8cc712eSAndreas Gohr } else { 274f8cc712eSAndreas Gohr html_admin(); 275f8cc712eSAndreas Gohr } 27654e95700STom N Harris return true; 277c19fe9c0Sandi} 2786b13307fSandi 2796b13307fSandi/** 2806b13307fSandi * Print the correct HTML meta headers 2816b13307fSandi * 2826b13307fSandi * This has to go into the head section of your template. 2836b13307fSandi * 2846b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 28542ea7f44SGerrit Uitslag * 286ac7a515fSAndreas Gohr * @triggers TPL_METAHEADER_OUTPUT 287ac7a515fSAndreas Gohr * @param bool $alt Should feeds and alternative format links be added? 288ac7a515fSAndreas Gohr * @return bool 2896b13307fSandi */ 290f96fa415SAndreas Gohrfunction tpl_metaheaders($alt = true) { 2916b13307fSandi global $ID; 292d98d4540SBen Coburn global $REV; 2936b13307fSandi global $INFO; 29472e0dc37SAndreas Gohr global $JSINFO; 2956b13307fSandi global $ACT; 2964bb1b5aeSAndreas Gohr global $QUERY; 2976b13307fSandi global $lang; 298dc57ef04Sandi global $conf; 2999c438d6cSMichael Hamann global $updateVersion; 300585bf44eSChristopher Smith /** @var Input $INPUT */ 301585bf44eSChristopher Smith global $INPUT; 3026b13307fSandi 3037bff22c0SAndreas Gohr // prepare the head array 3047bff22c0SAndreas Gohr $head = array(); 3057bff22c0SAndreas Gohr 306202ac28bSMichael Klier // prepare seed for js and css 307cd997f93SAndreas Gohr $tseed = $updateVersion; 308202ac28bSMichael Klier $depends = getConfigFiles('main'); 309cd997f93SAndreas Gohr foreach($depends as $f) $tseed .= @filemtime($f); 310cd997f93SAndreas Gohr $tseed = md5($tseed); 3117bff22c0SAndreas Gohr 3126b13307fSandi // the usual stuff 3133f803e5eSGina Haeussge $head['meta'][] = array('name'=> 'generator', 'content'=> 'DokuWiki'); 314ac7a515fSAndreas Gohr $head['link'][] = array( 315ac7a515fSAndreas Gohr 'rel' => 'search', 'type'=> 'application/opensearchdescription+xml', 316ac7a515fSAndreas Gohr 'href'=> DOKU_BASE.'lib/exe/opensearch.php', 'title'=> $conf['title'] 317ac7a515fSAndreas Gohr ); 318f4f47358SBen Coburn $head['link'][] = array('rel'=> 'start', 'href'=> DOKU_BASE); 3197aedde2eSGina Haeussge if(actionOK('index')) { 320ac7a515fSAndreas Gohr $head['link'][] = array( 321ac7a515fSAndreas Gohr 'rel' => 'contents', 'href'=> wl($ID, 'do=index', false, '&'), 322ac7a515fSAndreas Gohr 'title'=> $lang['btn_index'] 323ac7a515fSAndreas Gohr ); 3247aedde2eSGina Haeussge } 325f96fa415SAndreas Gohr 326f96fa415SAndreas Gohr if($alt) { 32754be1338SGerrit Uitslag if(actionOK('rss')) { 328ac7a515fSAndreas Gohr $head['link'][] = array( 329ac7a515fSAndreas Gohr 'rel' => 'alternate', 'type'=> 'application/rss+xml', 330a1288caeSGerrit Uitslag 'title'=> $lang['btn_recent'], 'href'=> DOKU_BASE.'feed.php' 331ac7a515fSAndreas Gohr ); 332ac7a515fSAndreas Gohr $head['link'][] = array( 333ac7a515fSAndreas Gohr 'rel' => 'alternate', 'type'=> 'application/rss+xml', 334a1288caeSGerrit Uitslag 'title'=> $lang['currentns'], 335ac7a515fSAndreas Gohr 'href' => DOKU_BASE.'feed.php?mode=list&ns='.$INFO['namespace'] 336ac7a515fSAndreas Gohr ); 33754be1338SGerrit Uitslag } 338c35f3875SAndreas Gohr if(($ACT == 'show' || $ACT == 'search') && $INFO['writable']) { 339ac7a515fSAndreas Gohr $head['link'][] = array( 340ac7a515fSAndreas Gohr 'rel' => 'edit', 341715bdf1fSAndreas Gohr 'title'=> $lang['btn_edit'], 342ac7a515fSAndreas Gohr 'href' => wl($ID, 'do=edit', false, '&') 343ac7a515fSAndreas Gohr ); 344c35f3875SAndreas Gohr } 345c35f3875SAndreas Gohr 34654be1338SGerrit Uitslag if(actionOK('rss') && $ACT == 'search') { 347ac7a515fSAndreas Gohr $head['link'][] = array( 348ac7a515fSAndreas Gohr 'rel' => 'alternate', 'type'=> 'application/rss+xml', 349a1288caeSGerrit Uitslag 'title'=> $lang['searchresult'], 350ac7a515fSAndreas Gohr 'href' => DOKU_BASE.'feed.php?mode=search&q='.$QUERY 351ac7a515fSAndreas Gohr ); 3524bb1b5aeSAndreas Gohr } 353bae36d94SAndreas Gohr 354bae36d94SAndreas Gohr if(actionOK('export_xhtml')) { 355ac7a515fSAndreas Gohr $head['link'][] = array( 356a1288caeSGerrit Uitslag 'rel' => 'alternate', 'type'=> 'text/html', 'title'=> $lang['plainhtml'], 357ac7a515fSAndreas Gohr 'href'=> exportlink($ID, 'xhtml', '', false, '&') 358ac7a515fSAndreas Gohr ); 359bae36d94SAndreas Gohr } 360bae36d94SAndreas Gohr 361bae36d94SAndreas Gohr if(actionOK('export_raw')) { 362ac7a515fSAndreas Gohr $head['link'][] = array( 363a1288caeSGerrit Uitslag 'rel' => 'alternate', 'type'=> 'text/plain', 'title'=> $lang['wikimarkup'], 364ac7a515fSAndreas Gohr 'href'=> exportlink($ID, 'raw', '', false, '&') 365ac7a515fSAndreas Gohr ); 366f96fa415SAndreas Gohr } 367bae36d94SAndreas Gohr } 3686b13307fSandi 3696b13307fSandi // setup robot tags apropriate for different modes 3704f2e0004STim Weber if(($ACT == 'show' || $ACT == 'export_xhtml') && !$REV) { 3716b13307fSandi if($INFO['exists']) { 3726b13307fSandi //delay indexing: 3736b13307fSandi if((time() - $INFO['lastmod']) >= $conf['indexdelay']) { 3747bff22c0SAndreas Gohr $head['meta'][] = array('name'=> 'robots', 'content'=> 'index,follow'); 3756b13307fSandi } else { 3767bff22c0SAndreas Gohr $head['meta'][] = array('name'=> 'robots', 'content'=> 'noindex,nofollow'); 3776b13307fSandi } 37801f9be51SAnika Henke $canonicalUrl = wl($ID, '', true, '&'); 37901f9be51SAnika Henke if ($ID == $conf['start']) { 38001f9be51SAnika Henke $canonicalUrl = DOKU_URL; 38101f9be51SAnika Henke } 38201f9be51SAnika Henke $head['link'][] = array('rel'=> 'canonical', 'href'=> $canonicalUrl); 3836b13307fSandi } else { 3847bff22c0SAndreas Gohr $head['meta'][] = array('name'=> 'robots', 'content'=> 'noindex,follow'); 3856b13307fSandi } 3867a24876fSAndreas Gohr } elseif(defined('DOKU_MEDIADETAIL')) { 3877bff22c0SAndreas Gohr $head['meta'][] = array('name'=> 'robots', 'content'=> 'index,follow'); 3886b13307fSandi } else { 3897bff22c0SAndreas Gohr $head['meta'][] = array('name'=> 'robots', 'content'=> 'noindex,nofollow'); 3906b13307fSandi } 3916b13307fSandi 392831800b8SAndreas Gohr // set metadata 393831800b8SAndreas Gohr if($ACT == 'show' || $ACT == 'export_xhtml') { 394831800b8SAndreas Gohr // keywords (explicit or implicit) 395bb4866bdSchris if(!empty($INFO['meta']['subject'])) { 3967bff22c0SAndreas Gohr $head['meta'][] = array('name'=> 'keywords', 'content'=> join(',', $INFO['meta']['subject'])); 397831800b8SAndreas Gohr } else { 3987bff22c0SAndreas Gohr $head['meta'][] = array('name'=> 'keywords', 'content'=> str_replace(':', ',', $ID)); 399831800b8SAndreas Gohr } 400831800b8SAndreas Gohr } 401831800b8SAndreas Gohr 40278a6aeb1SAndreas Gohr // load stylesheets 403ac7a515fSAndreas Gohr $head['link'][] = array( 404ac7a515fSAndreas Gohr 'rel' => 'stylesheet', 'type'=> 'text/css', 405e283bd6cSAnika Henke 'href'=> DOKU_BASE.'lib/exe/css.php?t='.rawurlencode($conf['template']).'&tseed='.$tseed 406ac7a515fSAndreas Gohr ); 407bad31ae9SAndreas Gohr 4088bbcb611SAndreas Gohr // make $INFO and other vars available to JavaScripts 409463d4a65SAndreas Gohr $json = new JSON(); 41072e0dc37SAndreas Gohr $script = "var NS='".$INFO['namespace']."';"; 411585bf44eSChristopher Smith if($conf['useacl'] && $INPUT->server->str('REMOTE_USER')) { 41272e0dc37SAndreas Gohr $script .= "var SIG='".toolbar_signature()."';"; 413c591aabeSAndreas Gohr } 41472e0dc37SAndreas Gohr $script .= 'var JSINFO = '.$json->encode($JSINFO).';'; 41585f81679SAdrian Lang $head['script'][] = array('type'=> 'text/javascript', '_data'=> $script); 4168bbcb611SAndreas Gohr 4178bbcb611SAndreas Gohr // load external javascript 418ac7a515fSAndreas Gohr $head['script'][] = array( 419ac7a515fSAndreas Gohr 'type'=> 'text/javascript', 'charset'=> 'utf-8', '_data'=> '', 420e283bd6cSAnika Henke 'src' => DOKU_BASE.'lib/exe/js.php'.'?t='.rawurlencode($conf['template']).'&tseed='.$tseed 421ac7a515fSAndreas Gohr ); 4227bff22c0SAndreas Gohr 4237bff22c0SAndreas Gohr // trigger event here 424016b6153SAndreas Gohr trigger_event('TPL_METAHEADER_OUTPUT', $head, '_tpl_metaheaders_action', true); 42554e95700STom N Harris return true; 4267bff22c0SAndreas Gohr} 4277bff22c0SAndreas Gohr 4287bff22c0SAndreas Gohr/** 4297bff22c0SAndreas Gohr * prints the array build by tpl_metaheaders 4307bff22c0SAndreas Gohr * 4317bff22c0SAndreas Gohr * $data is an array of different header tags. Each tag can have multiple 4327bff22c0SAndreas Gohr * instances. Attributes are given as key value pairs. Values will be HTML 4337bff22c0SAndreas Gohr * encoded automatically so they should be provided as is in the $data array. 4347bff22c0SAndreas Gohr * 43542ea7f44SGerrit Uitslag * For tags having a body attribute specify the body data in the special 4361304d1dbSAndreas Gohr * attribute '_data'. This field will NOT BE ESCAPED automatically. 4377bff22c0SAndreas Gohr * 4387bff22c0SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 43942ea7f44SGerrit Uitslag * 44042ea7f44SGerrit Uitslag * @param array $data 4417bff22c0SAndreas Gohr */ 4427bff22c0SAndreas Gohrfunction _tpl_metaheaders_action($data) { 4437bff22c0SAndreas Gohr foreach($data as $tag => $inst) { 4447bff22c0SAndreas Gohr foreach($inst as $attr) { 4457bff22c0SAndreas Gohr echo '<', $tag, ' ', buildAttributes($attr); 44626afa874SMikhail I. Izmestev if(isset($attr['_data']) || $tag == 'script') { 447e226efe1SAndreas Gohr if($tag == 'script' && $attr['_data']) 44809f791c4SDominik Eckelmann $attr['_data'] = "/*<![CDATA[*/". 449e226efe1SAndreas Gohr $attr['_data']. 45009f791c4SDominik Eckelmann "\n/*!]]>*/"; 451e226efe1SAndreas Gohr 4521304d1dbSAndreas Gohr echo '>', $attr['_data'], '</', $tag, '>'; 4537bff22c0SAndreas Gohr } else { 4547bff22c0SAndreas Gohr echo '/>'; 4557bff22c0SAndreas Gohr } 4567bff22c0SAndreas Gohr echo "\n"; 4577bff22c0SAndreas Gohr } 4587bff22c0SAndreas Gohr } 4596b13307fSandi} 4606b13307fSandi 4616b13307fSandi/** 4626b13307fSandi * Print a link 4636b13307fSandi * 4645e163278SAndreas Gohr * Just builds a link. 4656b13307fSandi * 4666b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 46742ea7f44SGerrit Uitslag * 46842ea7f44SGerrit Uitslag * @param string $url 46942ea7f44SGerrit Uitslag * @param string $name 47042ea7f44SGerrit Uitslag * @param string $more 47121d806cdSGerrit Uitslag * @param bool $return if true return the link html, otherwise print 47221d806cdSGerrit Uitslag * @return bool|string html of the link, or true if printed 4736b13307fSandi */ 4741af98a77SAnika Henkefunction tpl_link($url, $name, $more = '', $return = false) { 47501f17825SAnika Henke $out = '<a href="'.$url.'" '; 4761af98a77SAnika Henke if($more) $out .= ' '.$more; 4771af98a77SAnika Henke $out .= ">$name</a>"; 4781af98a77SAnika Henke if($return) return $out; 4791af98a77SAnika Henke print $out; 48054e95700STom N Harris return true; 4816b13307fSandi} 4826b13307fSandi 4836b13307fSandi/** 48455efc227SAndreas Gohr * Prints a link to a WikiPage 48555efc227SAndreas Gohr * 48655efc227SAndreas Gohr * Wrapper around html_wikilink 48755efc227SAndreas Gohr * 48855efc227SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 48942ea7f44SGerrit Uitslag * 49042ea7f44SGerrit Uitslag * @param string $id page id 49142ea7f44SGerrit Uitslag * @param string|null $name the name of the link 49221d806cdSGerrit Uitslag * @return bool true 49355efc227SAndreas Gohr */ 4940b17fdc6SAndreas Gohrfunction tpl_pagelink($id, $name = null) { 495d317fb5dSAnika Henke print '<bdi>'.html_wikilink($id, $name).'</bdi>'; 49654e95700STom N Harris return true; 49755efc227SAndreas Gohr} 49855efc227SAndreas Gohr 49955efc227SAndreas Gohr/** 500a3ec5f4aSmatthiasgrimm * get the parent page 501a3ec5f4aSmatthiasgrimm * 502a3ec5f4aSmatthiasgrimm * Tries to find out which page is parent. 503a3ec5f4aSmatthiasgrimm * returns false if none is available 504a3ec5f4aSmatthiasgrimm * 505377f9e97SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 50642ea7f44SGerrit Uitslag * 50742ea7f44SGerrit Uitslag * @param string $id page id 50842ea7f44SGerrit Uitslag * @return false|string 509a3ec5f4aSmatthiasgrimm */ 510377f9e97SAndreas Gohrfunction tpl_getparent($id) { 511377f9e97SAndreas Gohr $parent = getNS($id).':'; 512377f9e97SAndreas Gohr resolve_pageid('', $parent, $exists); 513a197105eSmatthiasgrimm if($parent == $id) { 514a197105eSmatthiasgrimm $pos = strrpos(getNS($id), ':'); 515a197105eSmatthiasgrimm $parent = substr($parent, 0, $pos).':'; 516a197105eSmatthiasgrimm resolve_pageid('', $parent, $exists); 517377f9e97SAndreas Gohr if($parent == $id) return false; 518a197105eSmatthiasgrimm } 519377f9e97SAndreas Gohr return $parent; 520a3ec5f4aSmatthiasgrimm} 521a3ec5f4aSmatthiasgrimm 522a3ec5f4aSmatthiasgrimm/** 5236b13307fSandi * Print one of the buttons 5246b13307fSandi * 525a453d131SAdrian Lang * @author Adrian Lang <mail@adrianlang.de> 526a453d131SAdrian Lang * @see tpl_get_action 527e0c26282SGerrit Uitslag * 528e0c26282SGerrit Uitslag * @param string $type 529e0c26282SGerrit Uitslag * @param bool $return 530e0c26282SGerrit Uitslag * @return bool|string html, or false if no data, true if printed 5316b13307fSandi */ 5321af98a77SAnika Henkefunction tpl_button($type, $return = false) { 533a453d131SAdrian Lang $data = tpl_get_action($type); 534a453d131SAdrian Lang if($data === false) { 535a453d131SAdrian Lang return false; 536a453d131SAdrian Lang } elseif(!is_array($data)) { 537a453d131SAdrian Lang $out = sprintf($data, 'button'); 538409d7af7SAndreas Gohr } else { 539ac7a515fSAndreas Gohr /** 540ac7a515fSAndreas Gohr * @var string $accesskey 541ac7a515fSAndreas Gohr * @var string $id 542ac7a515fSAndreas Gohr * @var string $method 543ac7a515fSAndreas Gohr * @var array $params 544ac7a515fSAndreas Gohr */ 545a453d131SAdrian Lang extract($data); 546a453d131SAdrian Lang if($id === '#dokuwiki__top') { 547a453d131SAdrian Lang $out = html_topbtn(); 548409d7af7SAndreas Gohr } else { 549a453d131SAdrian Lang $out = html_btn($type, $id, $accesskey, $params, $method); 550409d7af7SAndreas Gohr } 551409d7af7SAndreas Gohr } 5521af98a77SAnika Henke if($return) return $out; 553a453d131SAdrian Lang echo $out; 554a453d131SAdrian Lang return true; 5556b13307fSandi} 5566b13307fSandi 5576b13307fSandi/** 558ed630903Sandi * Like the action buttons but links 559ed630903Sandi * 560a453d131SAdrian Lang * @author Adrian Lang <mail@adrianlang.de> 561a453d131SAdrian Lang * @see tpl_get_action 562e0c26282SGerrit Uitslag * 56342ea7f44SGerrit Uitslag * @param string $type action command 564e0c26282SGerrit Uitslag * @param string $pre prefix of link 565e0c26282SGerrit Uitslag * @param string $suf suffix of link 566e0c26282SGerrit Uitslag * @param string $inner innerHML of link 56721d806cdSGerrit Uitslag * @param bool $return if true it returns html, otherwise prints 568e0c26282SGerrit Uitslag * @return bool|string html or false if no data, true if printed 569a453d131SAdrian Lang */ 570a453d131SAdrian Langfunction tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = false) { 571a453d131SAdrian Lang global $lang; 572a453d131SAdrian Lang $data = tpl_get_action($type); 573a453d131SAdrian Lang if($data === false) { 574a453d131SAdrian Lang return false; 575a453d131SAdrian Lang } elseif(!is_array($data)) { 576a453d131SAdrian Lang $out = sprintf($data, 'link'); 577a453d131SAdrian Lang } else { 578ac7a515fSAndreas Gohr /** 579ac7a515fSAndreas Gohr * @var string $accesskey 580ac7a515fSAndreas Gohr * @var string $id 581ac7a515fSAndreas Gohr * @var string $method 582b1af9014SChristopher Smith * @var bool $nofollow 583ac7a515fSAndreas Gohr * @var array $params 584becfa414SGerrit Uitslag * @var string $replacement 585ac7a515fSAndreas Gohr */ 586a453d131SAdrian Lang extract($data); 587a453d131SAdrian Lang if(strpos($id, '#') === 0) { 588a453d131SAdrian Lang $linktarget = $id; 589a453d131SAdrian Lang } else { 590a453d131SAdrian Lang $linktarget = wl($id, $params); 591a453d131SAdrian Lang } 592a453d131SAdrian Lang $caption = $lang['btn_'.$type]; 593becfa414SGerrit Uitslag if(strpos($caption, '%s')){ 594becfa414SGerrit Uitslag $caption = sprintf($caption, $replacement); 595becfa414SGerrit Uitslag } 596c7e90e3fSAnika Henke $akey = $addTitle = ''; 597c7e90e3fSAnika Henke if($accesskey) { 598c7e90e3fSAnika Henke $akey = 'accesskey="'.$accesskey.'" '; 599c7e90e3fSAnika Henke $addTitle = ' ['.strtoupper($accesskey).']'; 600c7e90e3fSAnika Henke } 601b1af9014SChristopher Smith $rel = $nofollow ? 'rel="nofollow" ' : ''; 602ac7a515fSAndreas Gohr $out = tpl_link( 603ac7a515fSAndreas Gohr $linktarget, $pre.(($inner) ? $inner : $caption).$suf, 604a453d131SAdrian Lang 'class="action '.$type.'" '. 605b1af9014SChristopher Smith $akey.$rel. 606e0c26282SGerrit Uitslag 'title="'.hsc($caption).$addTitle.'"', true 607ac7a515fSAndreas Gohr ); 608a453d131SAdrian Lang } 609a453d131SAdrian Lang if($return) return $out; 610a453d131SAdrian Lang echo $out; 611a453d131SAdrian Lang return true; 612a453d131SAdrian Lang} 613a453d131SAdrian Lang 614a453d131SAdrian Lang/** 615a453d131SAdrian Lang * Check the actions and get data for buttons and links 616ed630903Sandi * 617a453d131SAdrian Lang * Available actions are 618a453d131SAdrian Lang * 619a453d131SAdrian Lang * edit - edit/create/show/draft 620ed630903Sandi * history - old revisions 621ed630903Sandi * recent - recent changes 622a453d131SAdrian Lang * login - login/logout - if ACL enabled 623a453d131SAdrian Lang * profile - user profile (if logged in) 624ed630903Sandi * index - The index 625ed630903Sandi * admin - admin page - if enough rights 626a453d131SAdrian Lang * top - back to top 627a453d131SAdrian Lang * back - back to parent - if available 628bbd37938SAndreas Gohr * backlink - links to the list of backlinks 629a453d131SAdrian Lang * subscribe/subscription- subscribe/unsubscribe 630ed630903Sandi * 631ed630903Sandi * @author Andreas Gohr <andi@splitbrain.org> 632a3ec5f4aSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net> 633a453d131SAdrian Lang * @author Adrian Lang <mail@adrianlang.de> 634e0c26282SGerrit Uitslag * 635ac7a515fSAndreas Gohr * @param string $type 636ac7a515fSAndreas Gohr * @return array|bool|string 637ed630903Sandi */ 638a453d131SAdrian Langfunction tpl_get_action($type) { 639ed630903Sandi global $ID; 640ed630903Sandi global $INFO; 641ed630903Sandi global $REV; 642ed630903Sandi global $ACT; 643b1af9014SChristopher Smith global $conf; 644585bf44eSChristopher Smith /** @var Input $INPUT */ 645585bf44eSChristopher Smith global $INPUT; 646ed630903Sandi 64775e487e9SAndreas Gohr // check disabled actions and fix the badly named ones 648a453d131SAdrian Lang if($type == 'history') $type = 'revisions'; 6494c4b65c8SMichael Hamann if ($type == 'subscription') $type = 'subscribe'; 650a453d131SAdrian Lang if(!actionOK($type)) return false; 651409d7af7SAndreas Gohr 652a453d131SAdrian Lang $accesskey = null; 6536709e843SAdrian Lang $id = $ID; 654a453d131SAdrian Lang $method = 'get'; 655a453d131SAdrian Lang $params = array('do' => $type); 656b1af9014SChristopher Smith $nofollow = true; 657becfa414SGerrit Uitslag $replacement = ''; 658ed630903Sandi switch($type) { 659ed630903Sandi case 'edit': 6600b17fdc6SAndreas Gohr // most complicated type - we need to decide on current action 661ed630903Sandi if($ACT == 'show' || $ACT == 'search') { 662a453d131SAdrian Lang $method = 'post'; 663ed630903Sandi if($INFO['writable']) { 664a453d131SAdrian Lang $accesskey = 'e'; 665b8a111f5SMichael Klier if(!empty($INFO['draft'])) { 6666709e843SAdrian Lang $type = 'draft'; 667a453d131SAdrian Lang $params['do'] = 'draft'; 668b8a111f5SMichael Klier } else { 669a453d131SAdrian Lang $params['rev'] = $REV; 670a453d131SAdrian Lang if(!$INFO['exists']) { 6716709e843SAdrian Lang $type = 'create'; 672ed630903Sandi } 673b8a111f5SMichael Klier } 674ed630903Sandi } else { 675a453d131SAdrian Lang if(!actionOK('source')) return false; //pseudo action 676a453d131SAdrian Lang $params['rev'] = $REV; 6776709e843SAdrian Lang $type = 'source'; 678a453d131SAdrian Lang $accesskey = 'v'; 679ed630903Sandi } 680ed630903Sandi } else { 681d30d4913SChristopher Smith $params = array('do' => ''); 6826709e843SAdrian Lang $type = 'show'; 683a453d131SAdrian Lang $accesskey = 'v'; 684ed630903Sandi } 6851af98a77SAnika Henke break; 686a453d131SAdrian Lang case 'revisions': 6876709e843SAdrian Lang $type = 'revs'; 688a453d131SAdrian Lang $accesskey = 'o'; 6891af98a77SAnika Henke break; 690ed630903Sandi case 'recent': 691a453d131SAdrian Lang $accesskey = 'r'; 6921af98a77SAnika Henke break; 693ed630903Sandi case 'index': 694a453d131SAdrian Lang $accesskey = 'x'; 695b1af9014SChristopher Smith // allow searchbots to get to the sitemap from the homepage (when dokuwiki isn't providing a sitemap.xml) 696b1af9014SChristopher Smith if ($conf['start'] == $ID && !$conf['sitemap']) { 697b1af9014SChristopher Smith $nofollow = false; 698b1af9014SChristopher Smith } 6991af98a77SAnika Henke break; 700ed630903Sandi case 'top': 701076f0d72SAnika Henke $accesskey = 't'; 702d30d4913SChristopher Smith $params = array('do' => ''); 703a453d131SAdrian Lang $id = '#dokuwiki__top'; 7041af98a77SAnika Henke break; 705a3ec5f4aSmatthiasgrimm case 'back': 706a453d131SAdrian Lang $parent = tpl_getparent($ID); 707a453d131SAdrian Lang if(!$parent) { 708a453d131SAdrian Lang return false; 709a3ec5f4aSmatthiasgrimm } 710a453d131SAdrian Lang $id = $parent; 711d30d4913SChristopher Smith $params = array('do' => ''); 712a453d131SAdrian Lang $accesskey = 'b'; 7131af98a77SAnika Henke break; 714becfa414SGerrit Uitslag case 'img_backto': 715becfa414SGerrit Uitslag $params = array(); 716becfa414SGerrit Uitslag $accesskey = 'b'; 717becfa414SGerrit Uitslag $replacement = $ID; 718becfa414SGerrit Uitslag break; 719ed630903Sandi case 'login': 720a453d131SAdrian Lang $params['sectok'] = getSecurityToken(); 721585bf44eSChristopher Smith if($INPUT->server->has('REMOTE_USER')) { 7223a48618aSAnika Henke if(!actionOK('logout')) { 7232380e8a8SAdrian Lang return false; 7242380e8a8SAdrian Lang } 725a453d131SAdrian Lang $params['do'] = 'logout'; 726a453d131SAdrian Lang $type = 'logout'; 727bf413a4eSAnika Henke } 728bf413a4eSAnika Henke break; 729bf413a4eSAnika Henke case 'register': 730585bf44eSChristopher Smith if($INPUT->server->str('REMOTE_USER')) { 731bf413a4eSAnika Henke return false; 732bf413a4eSAnika Henke } 733bf413a4eSAnika Henke break; 734bf413a4eSAnika Henke case 'resendpwd': 735585bf44eSChristopher Smith if($INPUT->server->str('REMOTE_USER')) { 736bf413a4eSAnika Henke return false; 737ed630903Sandi } 7381af98a77SAnika Henke break; 739ed630903Sandi case 'admin': 740a453d131SAdrian Lang if(!$INFO['ismanager']) { 741a453d131SAdrian Lang return false; 742c059e1a6SAndreas Gohr } 7431af98a77SAnika Henke break; 7441246e016SAndreas Gohr case 'revert': 745a453d131SAdrian Lang if(!$INFO['ismanager'] || !$REV || !$INFO['writable']) { 746a453d131SAdrian Lang return false; 7471246e016SAndreas Gohr } 748a453d131SAdrian Lang $params['rev'] = $REV; 749a453d131SAdrian Lang $params['sectok'] = getSecurityToken(); 7501246e016SAndreas Gohr break; 7516709e843SAdrian Lang case 'subscribe': 752585bf44eSChristopher Smith if(!$INPUT->server->str('REMOTE_USER')) { 753a453d131SAdrian Lang return false; 754b158d625SSteven Danz } 7551af98a77SAnika Henke break; 756f00151b4Schris case 'backlink': 7571af98a77SAnika Henke break; 7588b06d178Schris case 'profile': 759585bf44eSChristopher Smith if(!$INPUT->server->has('REMOTE_USER')) { 760a453d131SAdrian Lang return false; 7618b06d178Schris } 7621af98a77SAnika Henke break; 763b9eb2e61SKate Arzamastseva case 'media': 764d08527abSAnika Henke $params['ns'] = getNS($ID); 765b9eb2e61SKate Arzamastseva break; 766becfa414SGerrit Uitslag case 'mediaManager': 767becfa414SGerrit Uitslag // View image in media manager 768becfa414SGerrit Uitslag global $IMG; 769becfa414SGerrit Uitslag $imgNS = getNS($IMG); 770becfa414SGerrit Uitslag $authNS = auth_quickaclcheck("$imgNS:*"); 771becfa414SGerrit Uitslag if ($authNS < AUTH_UPLOAD) { 772becfa414SGerrit Uitslag return false; 773becfa414SGerrit Uitslag } 774becfa414SGerrit Uitslag $params = array( 775becfa414SGerrit Uitslag 'ns' => $imgNS, 776becfa414SGerrit Uitslag 'image' => $IMG, 777becfa414SGerrit Uitslag 'do' => 'media' 778becfa414SGerrit Uitslag ); 779becfa414SGerrit Uitslag //$type = 'media'; 780becfa414SGerrit Uitslag break; 781ed630903Sandi default: 782a453d131SAdrian Lang return '[unknown %s type]'; 783ed630903Sandi } 784becfa414SGerrit Uitslag return compact('accesskey', 'type', 'id', 'method', 'params', 'nofollow', 'replacement'); 785ed630903Sandi} 786ed630903Sandi 787ed630903Sandi/** 78801f17825SAnika Henke * Wrapper around tpl_button() and tpl_actionlink() 78901f17825SAnika Henke * 79001f17825SAnika Henke * @author Anika Henke <anika@selfthinker.org> 79142ea7f44SGerrit Uitslag * 79242ea7f44SGerrit Uitslag * @param string $type action command 793ac7a515fSAndreas Gohr * @param bool $link link or form button? 794e0c26282SGerrit Uitslag * @param string|bool $wrapper HTML element wrapper 795ac7a515fSAndreas Gohr * @param bool $return return or print 796ac7a515fSAndreas Gohr * @param string $pre prefix for links 797ac7a515fSAndreas Gohr * @param string $suf suffix for links 798ac7a515fSAndreas Gohr * @param string $inner inner HTML for links 799ac7a515fSAndreas Gohr * @return bool|string 80001f17825SAnika Henke */ 801ac7a515fSAndreas Gohrfunction tpl_action($type, $link = false, $wrapper = false, $return = false, $pre = '', $suf = '', $inner = '') { 80201f17825SAnika Henke $out = ''; 803ac7a515fSAndreas Gohr if($link) { 804e0c26282SGerrit Uitslag $out .= tpl_actionlink($type, $pre, $suf, $inner, true); 805ac7a515fSAndreas Gohr } else { 806e0c26282SGerrit Uitslag $out .= tpl_button($type, true); 807ac7a515fSAndreas Gohr } 80801f17825SAnika Henke if($out && $wrapper) $out = "<$wrapper>$out</$wrapper>"; 80901f17825SAnika Henke 81001f17825SAnika Henke if($return) return $out; 81101f17825SAnika Henke print $out; 81201f17825SAnika Henke return $out ? true : false; 81301f17825SAnika Henke} 81401f17825SAnika Henke 81501f17825SAnika Henke/** 8166b13307fSandi * Print the search form 8176b13307fSandi * 81872645b75SAndreas Gohr * If the first parameter is given a div with the ID 'qsearch_out' will 81972645b75SAndreas Gohr * be added which instructs the ajax pagequicksearch to kick in and place 82072645b75SAndreas Gohr * its output into this div. The second parameter controls the propritary 82172645b75SAndreas Gohr * attribute autocomplete. If set to false this attribute will be set with an 82272645b75SAndreas Gohr * value of "off" to instruct the browser to disable it's own built in 82372645b75SAndreas Gohr * autocompletion feature (MSIE and Firefox) 82472645b75SAndreas Gohr * 8256b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 82642ea7f44SGerrit Uitslag * 827ac7a515fSAndreas Gohr * @param bool $ajax 828ac7a515fSAndreas Gohr * @param bool $autocomplete 829ac7a515fSAndreas Gohr * @return bool 8306b13307fSandi */ 83172645b75SAndreas Gohrfunction tpl_searchform($ajax = true, $autocomplete = true) { 8326b13307fSandi global $lang; 833c1e3b7d9Smatthiasgrimm global $ACT; 834ad4aaef7SAndreas Gohr global $QUERY; 835c1e3b7d9Smatthiasgrimm 836670ff54eSchris // don't print the search form if search action has been disabled 83764276bbcSarbrk1 if(!actionOK('search')) return false; 838670ff54eSchris 8399805efa0SAnika Henke print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search" method="get" role="search"><div class="no">'; 8406b13307fSandi print '<input type="hidden" name="do" value="search" />'; 841c1e3b7d9Smatthiasgrimm print '<input type="text" '; 842ad4aaef7SAndreas Gohr if($ACT == 'search') print 'value="'.htmlspecialchars($QUERY).'" '; 843001ea14eSRainbow Spike print 'placeholder="'.$lang['btn_search'].'" '; 84472645b75SAndreas Gohr if(!$autocomplete) print 'autocomplete="off" '; 84507493d05SAnika Henke print 'id="qsearch__in" accesskey="f" name="id" class="edit" title="[F]" />'; 84611ea018fSAndreas Gohr print '<input type="submit" value="'.$lang['btn_search'].'" class="button" title="'.$lang['btn_search'].'" />'; 84724a33b42SAndreas Gohr if($ajax) print '<div id="qsearch__out" class="ajax_qsearch JSpopup"></div>'; 8484beabca9SAnika Henke print '</div></form>'; 84954e95700STom N Harris return true; 8506b13307fSandi} 8516b13307fSandi 8526b13307fSandi/** 8536b13307fSandi * Print the breadcrumbs trace 8546b13307fSandi * 8556b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 85642ea7f44SGerrit Uitslag * 857ac7a515fSAndreas Gohr * @param string $sep Separator between entries 858ac7a515fSAndreas Gohr * @return bool 8596b13307fSandi */ 860e260f93bSAnika Henkefunction tpl_breadcrumbs($sep = '•') { 8616b13307fSandi global $lang; 8626b13307fSandi global $conf; 8636b13307fSandi 8646b13307fSandi //check if enabled 865359fab8bSMichael Hamann if(!$conf['breadcrumbs']) return false; 8666b13307fSandi 8676b13307fSandi $crumbs = breadcrumbs(); //setup crumb trace 868265e3787Sandi 8692979a10bSKatriel Traum $crumbs_sep = ' <span class="bcsep">'.$sep.'</span> '; 870265e3787Sandi 87140eb54bbSjan //render crumbs, highlight the last one 872fde860beSGerrit Uitslag print '<span class="bchead">'.$lang['breadcrumb'].'</span>'; 87340eb54bbSjan $last = count($crumbs); 87440eb54bbSjan $i = 0; 875a77f5846Sjan foreach($crumbs as $id => $name) { 87640eb54bbSjan $i++; 8772979a10bSKatriel Traum echo $crumbs_sep; 87892795d04Sandi if($i == $last) print '<span class="curid">'; 879d317fb5dSAnika Henke print '<bdi>'; 880e26fd1eeSAndreas Gohr tpl_link(wl($id), hsc($name), 'class="breadcrumbs" title="'.$id.'"'); 881d317fb5dSAnika Henke print '</bdi>'; 88292795d04Sandi if($i == $last) print '</span>'; 8836b13307fSandi } 88454e95700STom N Harris return true; 8856b13307fSandi} 8866b13307fSandi 8876b13307fSandi/** 8881734437eSandi * Hierarchical breadcrumbs 8891734437eSandi * 89031e187f8SSean Coates * This code was suggested as replacement for the usual breadcrumbs. 8911734437eSandi * It only makes sense with a deep site structure. 8921734437eSandi * 8931734437eSandi * @author Andreas Gohr <andi@splitbrain.org> 8946bd812dfSNigel McNie * @author Nigel McNie <oracle.shinoda@gmail.com> 89531e187f8SSean Coates * @author Sean Coates <sean@caedmon.net> 896f46c9e83SAnika Henke * @author <fredrik@averpil.com> 89708d7a575SAndreas Gohr * @todo May behave strangely in RTL languages 89842ea7f44SGerrit Uitslag * 899ac7a515fSAndreas Gohr * @param string $sep Separator between entries 900ac7a515fSAndreas Gohr * @return bool 9011734437eSandi */ 90208d7a575SAndreas Gohrfunction tpl_youarehere($sep = ' » ') { 9031734437eSandi global $conf; 9041734437eSandi global $ID; 9051734437eSandi global $lang; 9061734437eSandi 90731e187f8SSean Coates // check if enabled 90854e95700STom N Harris if(!$conf['youarehere']) return false; 9091734437eSandi 9101734437eSandi $parts = explode(':', $ID); 911796bafb3SAndreas Gohr $count = count($parts); 9121734437eSandi 91308d7a575SAndreas Gohr echo '<span class="bchead">'.$lang['youarehere'].' </span>'; 9143940c519SMark 91508d7a575SAndreas Gohr // always print the startpage 91608d7a575SAndreas Gohr echo '<span class="home">'; 91708d7a575SAndreas Gohr tpl_pagelink(':'.$conf['start']); 91808d7a575SAndreas Gohr echo '</span>'; 919796bafb3SAndreas Gohr 920796bafb3SAndreas Gohr // print intermediate namespace links 921796bafb3SAndreas Gohr $part = ''; 922796bafb3SAndreas Gohr for($i = 0; $i < $count - 1; $i++) { 923796bafb3SAndreas Gohr $part .= $parts[$i].':'; 924796bafb3SAndreas Gohr $page = $part; 925796bafb3SAndreas Gohr if($page == $conf['start']) continue; // Skip startpage 926796bafb3SAndreas Gohr 92708d7a575SAndreas Gohr // output 92808d7a575SAndreas Gohr echo $sep; 92908d7a575SAndreas Gohr tpl_pagelink($page); 93031e187f8SSean Coates } 9311734437eSandi 932796bafb3SAndreas Gohr // print current page, skipping start page, skipping for namespace index 933e013f48dSAnika Henke resolve_pageid('', $page, $exists); 93408d7a575SAndreas Gohr if(isset($page) && $page == $part.$parts[$i]) return true; 935796bafb3SAndreas Gohr $page = $part.$parts[$i]; 93608d7a575SAndreas Gohr if($page == $conf['start']) return true; 93708d7a575SAndreas Gohr echo $sep; 93808d7a575SAndreas Gohr tpl_pagelink($page); 93954e95700STom N Harris return true; 9401734437eSandi} 9411734437eSandi 9421734437eSandi/** 9436b13307fSandi * Print info if the user is logged in 944a2488c3cSMatthias Grimm * and show full name in that case 9456b13307fSandi * 9466b13307fSandi * Could be enhanced with a profile link in future? 9476b13307fSandi * 9486b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 94942ea7f44SGerrit Uitslag * 950ac7a515fSAndreas Gohr * @return bool 9516b13307fSandi */ 9526b13307fSandifunction tpl_userinfo() { 9536b13307fSandi global $lang; 954585bf44eSChristopher Smith /** @var Input $INPUT */ 955585bf44eSChristopher Smith global $INPUT; 956585bf44eSChristopher Smith 957585bf44eSChristopher Smith if($INPUT->server->str('REMOTE_USER')) { 958fde860beSGerrit Uitslag print $lang['loggedinas'].' '.userlink(); 95954e95700STom N Harris return true; 96054e95700STom N Harris } 96154e95700STom N Harris return false; 9626b13307fSandi} 9636b13307fSandi 9646b13307fSandi/** 9656b13307fSandi * Print some info about the current page 9666b13307fSandi * 9676b13307fSandi * @author Andreas Gohr <andi@splitbrain.org> 96842ea7f44SGerrit Uitslag * 969ac7a515fSAndreas Gohr * @param bool $ret return content instead of printing it 970ac7a515fSAndreas Gohr * @return bool|string 9716b13307fSandi */ 9724b0d3916SAndreas Gohrfunction tpl_pageinfo($ret = false) { 9736b13307fSandi global $conf; 9746b13307fSandi global $lang; 9756b13307fSandi global $INFO; 976c6e92a3cSDavid Lorentsen global $ID; 977c6e92a3cSDavid Lorentsen 978c6e92a3cSDavid Lorentsen // return if we are not allowed to view the page 979ac7a515fSAndreas Gohr if(!auth_quickaclcheck($ID)) { 980ac7a515fSAndreas Gohr return false; 981ac7a515fSAndreas Gohr } 9826b13307fSandi 9836b13307fSandi // prepare date and path 9846b13307fSandi $fn = $INFO['filepath']; 9856b13307fSandi if(!$conf['fullpath']) { 986613bca54SAndreas Gohr if($INFO['rev']) { 98750fbebceSGina Haeussge $fn = str_replace(fullpath($conf['olddir']).'/', '', $fn); 9886b13307fSandi } else { 98950fbebceSGina Haeussge $fn = str_replace(fullpath($conf['datadir']).'/', '', $fn); 9906b13307fSandi } 9916b13307fSandi } 992bee6dc82Sandi $fn = utf8_decodeFN($fn); 993f2263577SAndreas Gohr $date = dformat($INFO['lastmod']); 9946b13307fSandi 995faecdfdfSAndreas Gohr // print it 996faecdfdfSAndreas Gohr if($INFO['exists']) { 9974b0d3916SAndreas Gohr $out = ''; 998d317fb5dSAnika Henke $out .= '<bdi>'.$fn.'</bdi>'; 999e260f93bSAnika Henke $out .= ' · '; 10004b0d3916SAndreas Gohr $out .= $lang['lastmod']; 1001fde860beSGerrit Uitslag $out .= ' '; 10024b0d3916SAndreas Gohr $out .= $date; 10036b13307fSandi if($INFO['editor']) { 10044b0d3916SAndreas Gohr $out .= ' '.$lang['by'].' '; 1005d317fb5dSAnika Henke $out .= '<bdi>'.editorinfo($INFO['editor']).'</bdi>'; 10065aa52fafSBen Coburn } else { 10074b0d3916SAndreas Gohr $out .= ' ('.$lang['external_edit'].')'; 10086b13307fSandi } 10096b13307fSandi if($INFO['locked']) { 1010e260f93bSAnika Henke $out .= ' · '; 10114b0d3916SAndreas Gohr $out .= $lang['lockedby']; 1012fde860beSGerrit Uitslag $out .= ' '; 1013d317fb5dSAnika Henke $out .= '<bdi>'.editorinfo($INFO['locked']).'</bdi>'; 10146b13307fSandi } 10154b0d3916SAndreas Gohr if($ret) { 10164b0d3916SAndreas Gohr return $out; 10174b0d3916SAndreas Gohr } else { 10184b0d3916SAndreas Gohr echo $out; 101954e95700STom N Harris return true; 10206b13307fSandi } 10214b0d3916SAndreas Gohr } 102254e95700STom N Harris return false; 10236b13307fSandi} 10246b13307fSandi 1025820fa24bSandi/** 1026a6598f23SBen Coburn * Prints or returns the name of the given page (current one if none given). 102787c434ceSAndreas Gohr * 102887c434ceSAndreas Gohr * If useheading is enabled this will use the first headline else 1029a6598f23SBen Coburn * the given ID is used. 103087c434ceSAndreas Gohr * 103187c434ceSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 103242ea7f44SGerrit Uitslag * 1033ac7a515fSAndreas Gohr * @param string $id page id 1034ac7a515fSAndreas Gohr * @param bool $ret return content instead of printing 1035ac7a515fSAndreas Gohr * @return bool|string 103687c434ceSAndreas Gohr */ 1037a6598f23SBen Coburnfunction tpl_pagetitle($id = null, $ret = false) { 1038*c248bda1SChristopher Smith global $ACT, $INPUT, $conf, $lang; 1039fffeeafeSChristopher Smith 104087c434ceSAndreas Gohr if(is_null($id)) { 104187c434ceSAndreas Gohr global $ID; 104287c434ceSAndreas Gohr $id = $ID; 104387c434ceSAndreas Gohr } 104487c434ceSAndreas Gohr 104587c434ceSAndreas Gohr $name = $id; 1046fe9ec250SChris Smith if(useHeading('navigation')) { 1047fffeeafeSChristopher Smith $first_heading = p_get_first_heading($id); 1048fffeeafeSChristopher Smith if($first_heading) $name = $first_heading; 1049fffeeafeSChristopher Smith } 1050fffeeafeSChristopher Smith 1051fffeeafeSChristopher Smith // default page title is the page name, modify with the current action 1052fffeeafeSChristopher Smith switch ($ACT) { 1053fffeeafeSChristopher Smith // admin functions 1054fffeeafeSChristopher Smith case 'admin' : 1055fffeeafeSChristopher Smith $page_title = $lang['btn_admin']; 1056fffeeafeSChristopher Smith // try to get the plugin name 1057fffeeafeSChristopher Smith // retrieve admin plugin name from $_REQUEST['page'] 1058fffeeafeSChristopher Smith if (($page = $INPUT->str('page', '', true)) != '') { 1059fffeeafeSChristopher Smith $pluginlist = plugin_list('admin'); 1060fffeeafeSChristopher Smith if (in_array($page, $pluginlist)) { 1061fffeeafeSChristopher Smith // attempt to load the plugin 1062fffeeafeSChristopher Smith 1063fffeeafeSChristopher Smith if (($plugin = plugin_load('admin',$page)) !== null){ 1064*c248bda1SChristopher Smith $plugin_title = $plugin->getMenuText($conf['lang']); 1065fffeeafeSChristopher Smith $page_title = $plugin_title ? $plugin_title : $page; 1066fffeeafeSChristopher Smith } 1067fffeeafeSChristopher Smith } 1068fffeeafeSChristopher Smith } 1069fffeeafeSChristopher Smith break; 1070fffeeafeSChristopher Smith 1071fffeeafeSChristopher Smith // user functions 1072fffeeafeSChristopher Smith case 'login' : 1073fffeeafeSChristopher Smith case 'profile' : 1074fffeeafeSChristopher Smith case 'register' : 1075fffeeafeSChristopher Smith case 'resendpwd' : 1076fffeeafeSChristopher Smith $page_title = $lang['btn_'.$ACT]; 1077fffeeafeSChristopher Smith break; 1078fffeeafeSChristopher Smith 1079fffeeafeSChristopher Smith // wiki functions 1080fffeeafeSChristopher Smith case 'search' : 1081fffeeafeSChristopher Smith case 'index' : 1082fffeeafeSChristopher Smith $page_title = $lang['btn_'.$ACT]; 1083fffeeafeSChristopher Smith break; 1084fffeeafeSChristopher Smith 1085fffeeafeSChristopher Smith // page functions 1086fffeeafeSChristopher Smith case 'edit' : 1087fffeeafeSChristopher Smith $page_title = "✎ ".$name; 1088fffeeafeSChristopher Smith break; 1089fffeeafeSChristopher Smith 1090fffeeafeSChristopher Smith case 'revisions' : 1091fffeeafeSChristopher Smith $page_title = $name . ' - ' . $lang['btn_revs']; 1092fffeeafeSChristopher Smith break; 1093fffeeafeSChristopher Smith 1094fffeeafeSChristopher Smith case 'backlink' : 1095fffeeafeSChristopher Smith case 'recent' : 1096fffeeafeSChristopher Smith case 'subscribe' : 1097fffeeafeSChristopher Smith $page_title = $name . ' - ' . $lang['btn_'.$ACT]; 1098fffeeafeSChristopher Smith break; 1099fffeeafeSChristopher Smith 1100fffeeafeSChristopher Smith default : // SHOW and anything else not included 1101fffeeafeSChristopher Smith $page_title = $name; 110287c434ceSAndreas Gohr } 1103a6598f23SBen Coburn 1104a6598f23SBen Coburn if($ret) { 1105fffeeafeSChristopher Smith return hsc($page_title); 1106a6598f23SBen Coburn } else { 1107fffeeafeSChristopher Smith print hsc($page_title); 110854e95700STom N Harris return true; 110987c434ceSAndreas Gohr } 1110a6598f23SBen Coburn} 1111340756e4Sandi 111255efc227SAndreas Gohr/** 111355efc227SAndreas Gohr * Returns the requested EXIF/IPTC tag from the current image 111455efc227SAndreas Gohr * 111555efc227SAndreas Gohr * If $tags is an array all given tags are tried until a 111655efc227SAndreas Gohr * value is found. If no value is found $alt is returned. 111755efc227SAndreas Gohr * 111855efc227SAndreas Gohr * Which texts are known is defined in the functions _exifTagNames 111955efc227SAndreas Gohr * and _iptcTagNames() in inc/jpeg.php (You need to prepend IPTC 112055efc227SAndreas Gohr * to the names of the latter one) 112155efc227SAndreas Gohr * 11223df72098SAndreas Gohr * Only allowed in: detail.php 112355efc227SAndreas Gohr * 112455efc227SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 112542ea7f44SGerrit Uitslag * 112621d806cdSGerrit Uitslag * @param array|string $tags tag or array of tags to try 1127ac7a515fSAndreas Gohr * @param string $alt alternative output if no data was found 1128e0c26282SGerrit Uitslag * @param null|string $src the image src, uses global $SRC if not given 1129ac7a515fSAndreas Gohr * @return string 113055efc227SAndreas Gohr */ 11313df72098SAndreas Gohrfunction tpl_img_getTag($tags, $alt = '', $src = null) { 113255efc227SAndreas Gohr // Init Exif Reader 113355efc227SAndreas Gohr global $SRC; 11343df72098SAndreas Gohr 11353df72098SAndreas Gohr if(is_null($src)) $src = $SRC; 11363df72098SAndreas Gohr 113755efc227SAndreas Gohr static $meta = null; 11383df72098SAndreas Gohr if(is_null($meta)) $meta = new JpegMeta($src); 113955efc227SAndreas Gohr if($meta === false) return $alt; 114088945224SChristopher Smith $info = cleanText($meta->getField($tags)); 114155efc227SAndreas Gohr if($info == false) return $alt; 114255efc227SAndreas Gohr return $info; 114355efc227SAndreas Gohr} 114455efc227SAndreas Gohr 114555efc227SAndreas Gohr/** 1146becfa414SGerrit Uitslag * Returns a description list of the metatags of the current image 1147becfa414SGerrit Uitslag * 1148becfa414SGerrit Uitslag * @return string html of description list 1149becfa414SGerrit Uitslag */ 1150becfa414SGerrit Uitslagfunction tpl_img_meta() { 1151becfa414SGerrit Uitslag global $lang; 1152becfa414SGerrit Uitslag 1153becfa414SGerrit Uitslag $tags = tpl_get_img_meta(); 1154becfa414SGerrit Uitslag 1155becfa414SGerrit Uitslag echo '<dl>'; 1156becfa414SGerrit Uitslag foreach($tags as $tag) { 1157becfa414SGerrit Uitslag $label = $lang[$tag['langkey']]; 1158fde860beSGerrit Uitslag if(!$label) $label = $tag['langkey'] . ':'; 1159becfa414SGerrit Uitslag 1160fde860beSGerrit Uitslag echo '<dt>'.$label.'</dt><dd>'; 1161becfa414SGerrit Uitslag if ($tag['type'] == 'date') { 1162becfa414SGerrit Uitslag echo dformat($tag['value']); 1163becfa414SGerrit Uitslag } else { 1164becfa414SGerrit Uitslag echo hsc($tag['value']); 1165becfa414SGerrit Uitslag } 1166becfa414SGerrit Uitslag echo '</dd>'; 1167becfa414SGerrit Uitslag } 1168becfa414SGerrit Uitslag echo '</dl>'; 1169becfa414SGerrit Uitslag} 1170becfa414SGerrit Uitslag 1171becfa414SGerrit Uitslag/** 1172becfa414SGerrit Uitslag * Returns metadata as configured in mediameta config file, ready for creating html 1173becfa414SGerrit Uitslag * 1174becfa414SGerrit Uitslag * @return array with arrays containing the entries: 1175becfa414SGerrit Uitslag * - string langkey key to lookup in the $lang var, if not found printed as is 1176becfa414SGerrit Uitslag * - string type type of value 1177becfa414SGerrit Uitslag * - string value tag value (unescaped) 1178becfa414SGerrit Uitslag */ 1179becfa414SGerrit Uitslagfunction tpl_get_img_meta() { 1180becfa414SGerrit Uitslag 1181becfa414SGerrit Uitslag $config_files = getConfigFiles('mediameta'); 1182becfa414SGerrit Uitslag foreach ($config_files as $config_file) { 118379e79377SAndreas Gohr if(file_exists($config_file)) { 1184becfa414SGerrit Uitslag include($config_file); 1185becfa414SGerrit Uitslag } 1186becfa414SGerrit Uitslag } 1187becfa414SGerrit Uitslag /** @var array $fields the included array with metadata */ 1188becfa414SGerrit Uitslag 1189becfa414SGerrit Uitslag $tags = array(); 1190becfa414SGerrit Uitslag foreach($fields as $tag){ 1191becfa414SGerrit Uitslag $t = array(); 1192becfa414SGerrit Uitslag if (!empty($tag[0])) { 1193becfa414SGerrit Uitslag $t = array($tag[0]); 1194becfa414SGerrit Uitslag } 1195becfa414SGerrit Uitslag if(is_array($tag[3])) { 1196becfa414SGerrit Uitslag $t = array_merge($t,$tag[3]); 1197becfa414SGerrit Uitslag } 1198becfa414SGerrit Uitslag $value = tpl_img_getTag($t); 1199becfa414SGerrit Uitslag if ($value) { 1200becfa414SGerrit Uitslag $tags[] = array('langkey' => $tag[1], 'type' => $tag[2], 'value' => $value); 1201becfa414SGerrit Uitslag } 1202becfa414SGerrit Uitslag } 1203becfa414SGerrit Uitslag return $tags; 1204becfa414SGerrit Uitslag} 1205becfa414SGerrit Uitslag 1206becfa414SGerrit Uitslag/** 120755efc227SAndreas Gohr * Prints the image with a link to the full sized version 120855efc227SAndreas Gohr * 120955efc227SAndreas Gohr * Only allowed in: detail.php 1210a02d2933SAndreas Gohr * 1211ac7a515fSAndreas Gohr * @triggers TPL_IMG_DISPLAY 1212a02d2933SAndreas Gohr * @param $maxwidth int - maximal width of the image 1213a02d2933SAndreas Gohr * @param $maxheight int - maximal height of the image 1214a02d2933SAndreas Gohr * @param $link bool - link to the orginal size? 1215a02d2933SAndreas Gohr * @param $params array - additional image attributes 121642ea7f44SGerrit Uitslag * @return bool Result of TPL_IMG_DISPLAY 121755efc227SAndreas Gohr */ 1218a02d2933SAndreas Gohrfunction tpl_img($maxwidth = 0, $maxheight = 0, $link = true, $params = null) { 121955efc227SAndreas Gohr global $IMG; 1220585bf44eSChristopher Smith /** @var Input $INPUT */ 1221ac7a515fSAndreas Gohr global $INPUT; 12225c2eed9aSlisps global $REV; 122355efc227SAndreas Gohr $w = tpl_img_getTag('File.Width'); 122455efc227SAndreas Gohr $h = tpl_img_getTag('File.Height'); 122555efc227SAndreas Gohr 122655efc227SAndreas Gohr //resize to given max values 122723a34783SAndreas Gohr $ratio = 1; 122823a34783SAndreas Gohr if($w >= $h) { 1229f8925855Sjoe.lapp if($maxwidth && $w >= $maxwidth) { 123055efc227SAndreas Gohr $ratio = $maxwidth / $w; 1231f8925855Sjoe.lapp } elseif($maxheight && $h > $maxheight) { 123255efc227SAndreas Gohr $ratio = $maxheight / $h; 123355efc227SAndreas Gohr } 123455efc227SAndreas Gohr } else { 1235f8925855Sjoe.lapp if($maxheight && $h >= $maxheight) { 123655efc227SAndreas Gohr $ratio = $maxheight / $h; 1237f8925855Sjoe.lapp } elseif($maxwidth && $w > $maxwidth) { 123855efc227SAndreas Gohr $ratio = $maxwidth / $w; 123955efc227SAndreas Gohr } 124055efc227SAndreas Gohr } 124155efc227SAndreas Gohr if($ratio) { 124255efc227SAndreas Gohr $w = floor($ratio * $w); 124355efc227SAndreas Gohr $h = floor($ratio * $h); 124455efc227SAndreas Gohr } 124555efc227SAndreas Gohr 12466de3759aSAndreas Gohr //prepare URLs 12475c2eed9aSlisps $url = ml($IMG, array('cache'=> $INPUT->str('cache'),'rev'=>$REV), true, '&'); 12485c2eed9aSlisps $src = ml($IMG, array('cache'=> $INPUT->str('cache'),'rev'=>$REV, 'w'=> $w, 'h'=> $h), true, '&'); 124955efc227SAndreas Gohr 12502684e50aSAndreas Gohr //prepare attributes 125155efc227SAndreas Gohr $alt = tpl_img_getTag('Simple.Title'); 1252a02d2933SAndreas Gohr if(is_null($params)) { 12532684e50aSAndreas Gohr $p = array(); 1254a02d2933SAndreas Gohr } else { 1255a02d2933SAndreas Gohr $p = $params; 1256a02d2933SAndreas Gohr } 12572684e50aSAndreas Gohr if($w) $p['width'] = $w; 12582684e50aSAndreas Gohr if($h) $p['height'] = $h; 12592684e50aSAndreas Gohr $p['class'] = 'img_detail'; 12602684e50aSAndreas Gohr if($alt) { 12612684e50aSAndreas Gohr $p['alt'] = $alt; 12622684e50aSAndreas Gohr $p['title'] = $alt; 12632684e50aSAndreas Gohr } else { 12642684e50aSAndreas Gohr $p['alt'] = ''; 12652684e50aSAndreas Gohr } 1266a02d2933SAndreas Gohr $p['src'] = $src; 126755efc227SAndreas Gohr 1268a02d2933SAndreas Gohr $data = array('url'=> ($link ? $url : null), 'params'=> $p); 1269a02d2933SAndreas Gohr return trigger_event('TPL_IMG_DISPLAY', $data, '_tpl_img_action', true); 1270a02d2933SAndreas Gohr} 1271a02d2933SAndreas Gohr 1272a02d2933SAndreas Gohr/** 1273a02d2933SAndreas Gohr * Default action for TPL_IMG_DISPLAY 1274ac7a515fSAndreas Gohr * 1275ac7a515fSAndreas Gohr * @param array $data 1276ac7a515fSAndreas Gohr * @return bool 1277a02d2933SAndreas Gohr */ 1278ac7a515fSAndreas Gohrfunction _tpl_img_action($data) { 127959f3611bSAnika Henke global $lang; 1280a02d2933SAndreas Gohr $p = buildAttributes($data['params']); 1281a02d2933SAndreas Gohr 128259f3611bSAnika Henke if($data['url']) print '<a href="'.hsc($data['url']).'" title="'.$lang['mediaview'].'">'; 1283a02d2933SAndreas Gohr print '<img '.$p.'/>'; 1284a02d2933SAndreas Gohr if($data['url']) print '</a>'; 128554e95700STom N Harris return true; 128655efc227SAndreas Gohr} 128755efc227SAndreas Gohr 12887367b368SAndreas Gohr/** 1289881f2ee2SAndreas Haerter * This function inserts a small gif which in reality is the indexer function. 12907367b368SAndreas Gohr * 12917367b368SAndreas Gohr * Should be called somewhere at the very end of the main.php 12927367b368SAndreas Gohr * template 1293ac7a515fSAndreas Gohr * 1294ac7a515fSAndreas Gohr * @return bool 12957367b368SAndreas Gohr */ 12967367b368SAndreas Gohrfunction tpl_indexerWebBug() { 12977367b368SAndreas Gohr global $ID; 12981dad36f5SAndreas Gohr 12997367b368SAndreas Gohr $p = array(); 1300b6c6979fSAndreas Gohr $p['src'] = DOKU_BASE.'lib/exe/indexer.php?id='.rawurlencode($ID). 1301e68c51baSAndreas Gohr '&'.time(); 1302881f2ee2SAndreas Haerter $p['width'] = 2; //no more 1x1 px image because we live in times of ad blockers... 13037367b368SAndreas Gohr $p['height'] = 1; 13047367b368SAndreas Gohr $p['alt'] = ''; 13057367b368SAndreas Gohr $att = buildAttributes($p); 13067367b368SAndreas Gohr print "<img $att />"; 130754e95700STom N Harris return true; 13087367b368SAndreas Gohr} 13097367b368SAndreas Gohr 131078d4e784SEsther Brunner/** 131178d4e784SEsther Brunner * tpl_getConf($id) 131278d4e784SEsther Brunner * 131378d4e784SEsther Brunner * use this function to access template configuration variables 1314ac7a515fSAndreas Gohr * 131517448fb8SChristopher Smith * @param string $id name of the value to access 131617448fb8SChristopher Smith * @param mixed $notset what to return if the setting is not available 131717448fb8SChristopher Smith * @return mixed 131878d4e784SEsther Brunner */ 131917448fb8SChristopher Smithfunction tpl_getConf($id, $notset=false) { 132078d4e784SEsther Brunner global $conf; 132117566ac6SAdrian Lang static $tpl_configloaded = false; 132278d4e784SEsther Brunner 132378d4e784SEsther Brunner $tpl = $conf['template']; 132478d4e784SEsther Brunner 132578d4e784SEsther Brunner if(!$tpl_configloaded) { 132678d4e784SEsther Brunner $tconf = tpl_loadConfig(); 132778d4e784SEsther Brunner if($tconf !== false) { 132878d4e784SEsther Brunner foreach($tconf as $key => $value) { 132978d4e784SEsther Brunner if(isset($conf['tpl'][$tpl][$key])) continue; 133078d4e784SEsther Brunner $conf['tpl'][$tpl][$key] = $value; 133178d4e784SEsther Brunner } 133278d4e784SEsther Brunner $tpl_configloaded = true; 133378d4e784SEsther Brunner } 133478d4e784SEsther Brunner } 133578d4e784SEsther Brunner 133617448fb8SChristopher Smith if(isset($conf['tpl'][$tpl][$id])){ 133778d4e784SEsther Brunner return $conf['tpl'][$tpl][$id]; 133878d4e784SEsther Brunner } 133978d4e784SEsther Brunner 134017448fb8SChristopher Smith return $notset; 134117448fb8SChristopher Smith} 134217448fb8SChristopher Smith 134378d4e784SEsther Brunner/** 134478d4e784SEsther Brunner * tpl_loadConfig() 1345ac7a515fSAndreas Gohr * 134678d4e784SEsther Brunner * reads all template configuration variables 134778d4e784SEsther Brunner * this function is automatically called by tpl_getConf() 1348ac7a515fSAndreas Gohr * 1349ac7a515fSAndreas Gohr * @return array 135078d4e784SEsther Brunner */ 135178d4e784SEsther Brunnerfunction tpl_loadConfig() { 135278d4e784SEsther Brunner 1353c4766956SAndreas Gohr $file = tpl_incdir().'/conf/default.php'; 135478d4e784SEsther Brunner $conf = array(); 135578d4e784SEsther Brunner 135679e79377SAndreas Gohr if(!file_exists($file)) return false; 135778d4e784SEsther Brunner 135878d4e784SEsther Brunner // load default config file 135978d4e784SEsther Brunner include($file); 136078d4e784SEsther Brunner 136178d4e784SEsther Brunner return $conf; 136278d4e784SEsther Brunner} 136378d4e784SEsther Brunner 136417566ac6SAdrian Lang// language methods 136517566ac6SAdrian Lang/** 136617566ac6SAdrian Lang * tpl_getLang($id) 136717566ac6SAdrian Lang * 136817566ac6SAdrian Lang * use this function to access template language variables 136942ea7f44SGerrit Uitslag * 137042ea7f44SGerrit Uitslag * @param string $id key of language string 137142ea7f44SGerrit Uitslag * @return string 137217566ac6SAdrian Lang */ 137317566ac6SAdrian Langfunction tpl_getLang($id) { 137417566ac6SAdrian Lang static $lang = array(); 137517566ac6SAdrian Lang 137617566ac6SAdrian Lang if(count($lang) === 0) { 1377dd7a6159SGerrit Uitslag global $conf, $config_cascade; // definitely don't invoke "global $lang" 1378dd7a6159SGerrit Uitslag 1379c4766956SAndreas Gohr $path = tpl_incdir() . 'lang/'; 138017566ac6SAdrian Lang 138117566ac6SAdrian Lang $lang = array(); 138217566ac6SAdrian Lang 138317566ac6SAdrian Lang // don't include once 138417566ac6SAdrian Lang @include($path . 'en/lang.php'); 1385dd7a6159SGerrit Uitslag foreach($config_cascade['lang']['template'] as $config_file) { 138679e79377SAndreas Gohr if(file_exists($config_file . $conf['template'] . '/en/lang.php')) { 1387dd7a6159SGerrit Uitslag include($config_file . $conf['template'] . '/en/lang.php'); 1388dd7a6159SGerrit Uitslag } 138917566ac6SAdrian Lang } 139017566ac6SAdrian Lang 1391dd7a6159SGerrit Uitslag if($conf['lang'] != 'en') { 1392dd7a6159SGerrit Uitslag @include($path . $conf['lang'] . '/lang.php'); 1393dd7a6159SGerrit Uitslag foreach($config_cascade['lang']['template'] as $config_file) { 139479e79377SAndreas Gohr if(file_exists($config_file . $conf['template'] . '/' . $conf['lang'] . '/lang.php')) { 1395dd7a6159SGerrit Uitslag include($config_file . $conf['template'] . '/' . $conf['lang'] . '/lang.php'); 1396dd7a6159SGerrit Uitslag } 1397dd7a6159SGerrit Uitslag } 1398dd7a6159SGerrit Uitslag } 139917566ac6SAdrian Lang } 140017566ac6SAdrian Lang return $lang[$id]; 140117566ac6SAdrian Lang} 140217566ac6SAdrian Lang 14033df72098SAndreas Gohr/** 1404c5c17fdaSKlap-in * Retrieve a language dependent file and pass to xhtml renderer for display 1405e8ec13b9SKlap-in * template equivalent of p_locale_xhtml() 1406e8ec13b9SKlap-in * 1407e8ec13b9SKlap-in * @param string $id id of language dependent wiki page 1408e8ec13b9SKlap-in * @return string parsed contents of the wiki page in xhtml format 1409e8ec13b9SKlap-in */ 1410e8ec13b9SKlap-infunction tpl_locale_xhtml($id) { 1411c5c17fdaSKlap-in return p_cached_output(tpl_localeFN($id)); 1412e8ec13b9SKlap-in} 1413e8ec13b9SKlap-in 1414e8ec13b9SKlap-in/** 1415c5c17fdaSKlap-in * Prepends appropriate path for a language dependent filename 141642ea7f44SGerrit Uitslag * 141742ea7f44SGerrit Uitslag * @param string $id id of localized text 141842ea7f44SGerrit Uitslag * @return string wiki text 1419e8ec13b9SKlap-in */ 1420c5c17fdaSKlap-infunction tpl_localeFN($id) { 1421e8ec13b9SKlap-in $path = tpl_incdir().'lang/'; 1422e8ec13b9SKlap-in global $conf; 142338fb1fc7SGerrit Uitslag $file = DOKU_CONF.'template_lang/'.$conf['template'].'/'.$conf['lang'].'/'.$id.'.txt'; 142479e79377SAndreas Gohr if (!file_exists($file)){ 1425e8ec13b9SKlap-in $file = $path.$conf['lang'].'/'.$id.'.txt'; 142679e79377SAndreas Gohr if(!file_exists($file)){ 1427e8ec13b9SKlap-in //fall back to english 1428e8ec13b9SKlap-in $file = $path.'en/'.$id.'.txt'; 1429e8ec13b9SKlap-in } 1430e8ec13b9SKlap-in } 1431e8ec13b9SKlap-in return $file; 1432e8ec13b9SKlap-in} 1433e8ec13b9SKlap-in 1434e8ec13b9SKlap-in/** 14353df72098SAndreas Gohr * prints the "main content" in the mediamanger popup 14363df72098SAndreas Gohr * 14373df72098SAndreas Gohr * Depending on the user's actions this may be a list of 14383df72098SAndreas Gohr * files in a namespace, the meta editing dialog or 14393df72098SAndreas Gohr * a message of referencing pages 14403df72098SAndreas Gohr * 14413df72098SAndreas Gohr * Only allowed in mediamanager.php 14423df72098SAndreas Gohr * 1443c182313eSAndreas Gohr * @triggers MEDIAMANAGER_CONTENT_OUTPUT 1444c182313eSAndreas Gohr * @param bool $fromajax - set true when calling this function via ajax 144542ea7f44SGerrit Uitslag * @param string $sort 14468702de7fSGerrit Uitslag * 14473df72098SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 14483df72098SAndreas Gohr */ 144900e3e394SChristopher Smithfunction tpl_mediaContent($fromajax = false, $sort='natural') { 14503df72098SAndreas Gohr global $IMG; 14513df72098SAndreas Gohr global $AUTH; 14523df72098SAndreas Gohr global $INUSE; 14533df72098SAndreas Gohr global $NS; 14543df72098SAndreas Gohr global $JUMPTO; 1455585bf44eSChristopher Smith /** @var Input $INPUT */ 1456ac7a515fSAndreas Gohr global $INPUT; 14573df72098SAndreas Gohr 1458ac7a515fSAndreas Gohr $do = $INPUT->extract('do')->str('do'); 1459c182313eSAndreas Gohr if(in_array($do, array('save', 'cancel'))) $do = ''; 1460c182313eSAndreas Gohr 1461c182313eSAndreas Gohr if(!$do) { 1462ac7a515fSAndreas Gohr if($INPUT->bool('edit')) { 1463c182313eSAndreas Gohr $do = 'metaform'; 1464c182313eSAndreas Gohr } elseif(is_array($INUSE)) { 1465c182313eSAndreas Gohr $do = 'filesinuse'; 1466c182313eSAndreas Gohr } else { 1467c182313eSAndreas Gohr $do = 'filelist'; 1468c182313eSAndreas Gohr } 1469c182313eSAndreas Gohr } 1470c182313eSAndreas Gohr 1471c182313eSAndreas Gohr // output the content pane, wrapped in an event. 1472c182313eSAndreas Gohr if(!$fromajax) ptln('<div id="media__content">'); 1473c182313eSAndreas Gohr $data = array('do' => $do); 1474c182313eSAndreas Gohr $evt = new Doku_Event('MEDIAMANAGER_CONTENT_OUTPUT', $data); 1475c182313eSAndreas Gohr if($evt->advise_before()) { 1476c182313eSAndreas Gohr $do = $data['do']; 147730fd72fbSKate Arzamastseva if($do == 'filesinuse') { 1478c182313eSAndreas Gohr media_filesinuse($INUSE, $IMG); 1479c182313eSAndreas Gohr } elseif($do == 'filelist') { 148000e3e394SChristopher Smith media_filelist($NS, $AUTH, $JUMPTO,false,$sort); 1481c9f56829SAndreas Gohr } elseif($do == 'searchlist') { 1482ac7a515fSAndreas Gohr media_searchlist($INPUT->str('q'), $NS, $AUTH); 1483c182313eSAndreas Gohr } else { 1484c182313eSAndreas Gohr msg('Unknown action '.hsc($do), -1); 1485c182313eSAndreas Gohr } 1486c182313eSAndreas Gohr } 1487c182313eSAndreas Gohr $evt->advise_after(); 1488c182313eSAndreas Gohr unset($evt); 1489c182313eSAndreas Gohr if(!$fromajax) ptln('</div>'); 1490c182313eSAndreas Gohr 14913df72098SAndreas Gohr} 14923df72098SAndreas Gohr 14933df72098SAndreas Gohr/** 1494d9162c6cSKate Arzamastseva * Prints the central column in full-screen media manager 1495d9162c6cSKate Arzamastseva * Depending on the opened tab this may be a list of 1496d9162c6cSKate Arzamastseva * files in a namespace, upload form or search form 1497d9162c6cSKate Arzamastseva * 1498d9162c6cSKate Arzamastseva * @author Kate Arzamastseva <pshns@ukr.net> 1499d9162c6cSKate Arzamastseva */ 1500035e07f1SKate Arzamastsevafunction tpl_mediaFileList() { 1501d9162c6cSKate Arzamastseva global $AUTH; 1502d9162c6cSKate Arzamastseva global $NS; 1503d9162c6cSKate Arzamastseva global $JUMPTO; 150495b451bcSAdrian Lang global $lang; 1505585bf44eSChristopher Smith /** @var Input $INPUT */ 1506ac7a515fSAndreas Gohr global $INPUT; 1507d9162c6cSKate Arzamastseva 1508ac7a515fSAndreas Gohr $opened_tab = $INPUT->str('tab_files'); 1509e5d185e1SKate Arzamastseva if(!$opened_tab || !in_array($opened_tab, array('files', 'upload', 'search'))) $opened_tab = 'files'; 1510ac7a515fSAndreas Gohr if($INPUT->str('mediado') == 'update') $opened_tab = 'upload'; 1511d9162c6cSKate Arzamastseva 151294add303SAnika Henke echo '<h2 class="a11y">'.$lang['mediaselect'].'</h2>'.NL; 151395b451bcSAdrian Lang 1514ed69a2aeSKate Arzamastseva media_tabs_files($opened_tab); 151523846a98SKate Arzamastseva 151694add303SAnika Henke echo '<div class="panelHeader">'.NL; 151795b451bcSAdrian Lang echo '<h3>'; 1518026d14a9SAnika Henke $tabTitle = ($NS) ? $NS : '['.$lang['mediaroot'].']'; 1519c98f205eSAdrian Lang printf($lang['media_'.$opened_tab], '<strong>'.hsc($tabTitle).'</strong>'); 152094add303SAnika Henke echo '</h3>'.NL; 152195b451bcSAdrian Lang if($opened_tab === 'search' || $opened_tab === 'files') { 152295b451bcSAdrian Lang media_tab_files_options(); 152323846a98SKate Arzamastseva } 152494add303SAnika Henke echo '</div>'.NL; 1525d9162c6cSKate Arzamastseva 152694add303SAnika Henke echo '<div class="panelContent">'.NL; 152795b451bcSAdrian Lang if($opened_tab == 'files') { 152895b451bcSAdrian Lang media_tab_files($NS, $AUTH, $JUMPTO); 152995b451bcSAdrian Lang } elseif($opened_tab == 'upload') { 153095b451bcSAdrian Lang media_tab_upload($NS, $AUTH, $JUMPTO); 153195b451bcSAdrian Lang } elseif($opened_tab == 'search') { 153295b451bcSAdrian Lang media_tab_search($NS, $AUTH); 153395b451bcSAdrian Lang } 153494add303SAnika Henke echo '</div>'.NL; 1535d9162c6cSKate Arzamastseva} 1536d9162c6cSKate Arzamastseva 1537d9162c6cSKate Arzamastseva/** 1538d9162c6cSKate Arzamastseva * Prints the third column in full-screen media manager 1539d9162c6cSKate Arzamastseva * Depending on the opened tab this may be details of the 1540d9162c6cSKate Arzamastseva * selected file, the meta editing dialog or 1541d9162c6cSKate Arzamastseva * list of file revisions 1542d9162c6cSKate Arzamastseva * 1543d9162c6cSKate Arzamastseva * @author Kate Arzamastseva <pshns@ukr.net> 1544d9162c6cSKate Arzamastseva */ 1545035e07f1SKate Arzamastsevafunction tpl_mediaFileDetails($image, $rev) { 1546e8a2a143SMichael Hamann global $conf, $DEL, $lang; 1547585bf44eSChristopher Smith /** @var Input $INPUT */ 1548585bf44eSChristopher Smith global $INPUT; 1549d9162c6cSKate Arzamastseva 155092cac9a9SKate Arzamastseva $removed = (!file_exists(mediaFN($image)) && file_exists(mediaMetaFN($image, '.changes')) && $conf['mediarevisions']); 1551ac7a515fSAndreas Gohr if(!$image || (!file_exists(mediaFN($image)) && !$removed) || $DEL) return; 15526dd095f5SKate Arzamastseva if($rev && !file_exists(mediaFN($image, $rev))) $rev = false; 1553e8a2a143SMichael Hamann $ns = getNS($image); 1554ac7a515fSAndreas Gohr $do = $INPUT->str('mediado'); 15551eeeced2SKate Arzamastseva 1556ac7a515fSAndreas Gohr $opened_tab = $INPUT->str('tab_details'); 1557e5d185e1SKate Arzamastseva 1558e5d185e1SKate Arzamastseva $tab_array = array('view'); 1559ac7a515fSAndreas Gohr list(, $mime) = mimetype($image); 1560e5d185e1SKate Arzamastseva if($mime == 'image/jpeg') { 1561e5d185e1SKate Arzamastseva $tab_array[] = 'edit'; 1562e5d185e1SKate Arzamastseva } 1563e5d185e1SKate Arzamastseva if($conf['mediarevisions']) { 1564e5d185e1SKate Arzamastseva $tab_array[] = 'history'; 1565e5d185e1SKate Arzamastseva } 1566e5d185e1SKate Arzamastseva 1567e5d185e1SKate Arzamastseva if(!$opened_tab || !in_array($opened_tab, $tab_array)) $opened_tab = 'view'; 1568ac7a515fSAndreas Gohr if($INPUT->bool('edit')) $opened_tab = 'edit'; 156923846a98SKate Arzamastseva if($do == 'restore') $opened_tab = 'view'; 1570d9162c6cSKate Arzamastseva 1571ed69a2aeSKate Arzamastseva media_tabs_details($image, $opened_tab); 157223846a98SKate Arzamastseva 157359f3611bSAnika Henke echo '<div class="panelHeader"><h3>'; 1574ac7a515fSAndreas Gohr list($ext) = mimetype($image, false); 157595b451bcSAdrian Lang $class = preg_replace('/[^_\-a-z0-9]+/i', '_', $ext); 157695b451bcSAdrian Lang $class = 'select mediafile mf_'.$class; 157700c2d4a9SAnika Henke $tabTitle = '<strong><a href="'.ml($image).'" class="'.$class.'" title="'.$lang['mediaview'].'">'.$image.'</a>'.'</strong>'; 157808317413SAdrian Lang if($opened_tab === 'view' && $rev) { 157908317413SAdrian Lang printf($lang['media_viewold'], $tabTitle, dformat($rev)); 158008317413SAdrian Lang } else { 1581026d14a9SAnika Henke printf($lang['media_'.$opened_tab], $tabTitle); 158208317413SAdrian Lang } 1583b8a84c03SAndreas Gohr 158494add303SAnika Henke echo '</h3></div>'.NL; 158595b451bcSAdrian Lang 158694add303SAnika Henke echo '<div class="panelContent">'.NL; 158795b451bcSAdrian Lang 158823846a98SKate Arzamastseva if($opened_tab == 'view') { 1589e8a2a143SMichael Hamann media_tab_view($image, $ns, null, $rev); 159023846a98SKate Arzamastseva 159192cac9a9SKate Arzamastseva } elseif($opened_tab == 'edit' && !$removed) { 1592e8a2a143SMichael Hamann media_tab_edit($image, $ns); 159323846a98SKate Arzamastseva 1594e5d185e1SKate Arzamastseva } elseif($opened_tab == 'history' && $conf['mediarevisions']) { 1595e8a2a143SMichael Hamann media_tab_history($image, $ns); 159623846a98SKate Arzamastseva } 159795b451bcSAdrian Lang 159894add303SAnika Henke echo '</div>'.NL; 1599d9162c6cSKate Arzamastseva} 1600d9162c6cSKate Arzamastseva 1601d9162c6cSKate Arzamastseva/** 16023df72098SAndreas Gohr * prints the namespace tree in the mediamanger popup 16033df72098SAndreas Gohr * 16043df72098SAndreas Gohr * Only allowed in mediamanager.php 16053df72098SAndreas Gohr * 16063df72098SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 16073df72098SAndreas Gohr */ 1608fa8e5c77SKate Arzamastsevafunction tpl_mediaTree() { 16093df72098SAndreas Gohr global $NS; 161023846a98SKate Arzamastseva ptln('<div id="media__tree">'); 16113df72098SAndreas Gohr media_nstree($NS); 16123df72098SAndreas Gohr ptln('</div>'); 16133df72098SAndreas Gohr} 16143df72098SAndreas Gohr 1615a00de5b5SAndreas Gohr/** 1616a00de5b5SAndreas Gohr * Print a dropdown menu with all DokuWiki actions 1617a00de5b5SAndreas Gohr * 1618a00de5b5SAndreas Gohr * Note: this will not use any pretty URLs 1619a00de5b5SAndreas Gohr * 1620a00de5b5SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 162142ea7f44SGerrit Uitslag * 162242ea7f44SGerrit Uitslag * @param string $empty empty option label 162342ea7f44SGerrit Uitslag * @param string $button submit button label 1624a00de5b5SAndreas Gohr */ 1625a00de5b5SAndreas Gohrfunction tpl_actiondropdown($empty = '', $button = '>') { 1626a00de5b5SAndreas Gohr global $ID; 1627a00de5b5SAndreas Gohr global $REV; 1628a00de5b5SAndreas Gohr global $lang; 1629585bf44eSChristopher Smith /** @var Input $INPUT */ 1630585bf44eSChristopher Smith global $INPUT; 1631a00de5b5SAndreas Gohr 1632e63eccffSAndreas Gohr echo '<form action="'.script().'" method="get" accept-charset="utf-8">'; 16333b9a3b55SAnika Henke echo '<div class="no">'; 1634a00de5b5SAndreas Gohr echo '<input type="hidden" name="id" value="'.$ID.'" />'; 1635a00de5b5SAndreas Gohr if($REV) echo '<input type="hidden" name="rev" value="'.$REV.'" />'; 1636585bf44eSChristopher Smith if ($INPUT->server->str('REMOTE_USER')) { 1637a00de5b5SAndreas Gohr echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'; 163861efcda1SChristopher Smith } 1639a00de5b5SAndreas Gohr 16405f17c394SAnika Henke echo '<select name="do" class="edit quickselect" title="'.$lang['tools'].'">'; 1641a00de5b5SAndreas Gohr echo '<option value="">'.$empty.'</option>'; 1642a00de5b5SAndreas Gohr 164361917024SAnika Henke echo '<optgroup label="'.$lang['page_tools'].'">'; 1644396c218fSAndreas Gohr $act = tpl_get_action('edit'); 1645396c218fSAndreas Gohr if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>'; 1646a00de5b5SAndreas Gohr 1647396c218fSAndreas Gohr $act = tpl_get_action('revert'); 1648396c218fSAndreas Gohr if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>'; 1649396c218fSAndreas Gohr 16503b9a3b55SAnika Henke $act = tpl_get_action('revisions'); 16513b9a3b55SAnika Henke if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>'; 16523b9a3b55SAnika Henke 1653396c218fSAndreas Gohr $act = tpl_get_action('backlink'); 1654396c218fSAndreas Gohr if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>'; 16553b9a3b55SAnika Henke 16563b9a3b55SAnika Henke $act = tpl_get_action('subscribe'); 16573b9a3b55SAnika Henke if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>'; 1658a00de5b5SAndreas Gohr echo '</optgroup>'; 1659a00de5b5SAndreas Gohr 166061917024SAnika Henke echo '<optgroup label="'.$lang['site_tools'].'">'; 1661396c218fSAndreas Gohr $act = tpl_get_action('recent'); 1662396c218fSAndreas Gohr if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>'; 1663396c218fSAndreas Gohr 16643b9a3b55SAnika Henke $act = tpl_get_action('media'); 16653b9a3b55SAnika Henke if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>'; 16663b9a3b55SAnika Henke 1667396c218fSAndreas Gohr $act = tpl_get_action('index'); 1668396c218fSAndreas Gohr if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>'; 1669a00de5b5SAndreas Gohr echo '</optgroup>'; 1670a00de5b5SAndreas Gohr 167161917024SAnika Henke echo '<optgroup label="'.$lang['user_tools'].'">'; 1672396c218fSAndreas Gohr $act = tpl_get_action('login'); 1673396c218fSAndreas Gohr if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>'; 1674a00de5b5SAndreas Gohr 16753b9a3b55SAnika Henke $act = tpl_get_action('register'); 1676396c218fSAndreas Gohr if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>'; 1677a00de5b5SAndreas Gohr 16783b9a3b55SAnika Henke $act = tpl_get_action('profile'); 1679396c218fSAndreas Gohr if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>'; 1680a00de5b5SAndreas Gohr 1681396c218fSAndreas Gohr $act = tpl_get_action('admin'); 1682396c218fSAndreas Gohr if($act) echo '<option value="'.$act['params']['do'].'">'.$lang['btn_'.$act['type']].'</option>'; 1683a00de5b5SAndreas Gohr echo '</optgroup>'; 1684a00de5b5SAndreas Gohr 1685a00de5b5SAndreas Gohr echo '</select>'; 1686f22c1964SAndreas Gohr echo '<input type="submit" value="'.$button.'" />'; 16873b9a3b55SAnika Henke echo '</div>'; 1688a00de5b5SAndreas Gohr echo '</form>'; 1689a00de5b5SAndreas Gohr} 1690a00de5b5SAndreas Gohr 1691066fee30SAndreas Gohr/** 1692066fee30SAndreas Gohr * Print a informational line about the used license 1693066fee30SAndreas Gohr * 1694066fee30SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1695ac7a515fSAndreas Gohr * @param string $img print image? (|button|badge) 1696ac7a515fSAndreas Gohr * @param bool $imgonly skip the textual description? 1697ac7a515fSAndreas Gohr * @param bool $return when true don't print, but return HTML 1698ac7a515fSAndreas Gohr * @param bool $wrap wrap in div with class="license"? 1699ac7a515fSAndreas Gohr * @return string 1700066fee30SAndreas Gohr */ 170180083a41SAndreas Gohrfunction tpl_license($img = 'badge', $imgonly = false, $return = false, $wrap = true) { 1702066fee30SAndreas Gohr global $license; 1703066fee30SAndreas Gohr global $conf; 1704066fee30SAndreas Gohr global $lang; 1705066fee30SAndreas Gohr if(!$conf['license']) return ''; 1706066fee30SAndreas Gohr if(!is_array($license[$conf['license']])) return ''; 1707066fee30SAndreas Gohr $lic = $license[$conf['license']]; 170853e15c8bSAnika Henke $target = ($conf['target']['extern']) ? ' target="'.$conf['target']['extern'].'"' : ''; 1709066fee30SAndreas Gohr 171080083a41SAndreas Gohr $out = ''; 171180083a41SAndreas Gohr if($wrap) $out .= '<div class="license">'; 1712066fee30SAndreas Gohr if($img) { 1713066fee30SAndreas Gohr $src = license_img($img); 1714066fee30SAndreas Gohr if($src) { 171553e15c8bSAnika Henke $out .= '<a href="'.$lic['url'].'" rel="license"'.$target; 171653e15c8bSAnika Henke $out .= '><img src="'.DOKU_BASE.$src.'" alt="'.$lic['name'].'" /></a>'; 171753e15c8bSAnika Henke if(!$imgonly) $out .= ' '; 1718066fee30SAndreas Gohr } 1719066fee30SAndreas Gohr } 17204cefd216SMichael Klier if(!$imgonly) { 172153e15c8bSAnika Henke $out .= $lang['license'].' '; 1722d317fb5dSAnika Henke $out .= '<bdi><a href="'.$lic['url'].'" rel="license" class="urlextern"'.$target; 1723d317fb5dSAnika Henke $out .= '>'.$lic['name'].'</a></bdi>'; 17244cefd216SMichael Klier } 172580083a41SAndreas Gohr if($wrap) $out .= '</div>'; 1726066fee30SAndreas Gohr 1727066fee30SAndreas Gohr if($return) return $out; 1728066fee30SAndreas Gohr echo $out; 1729ac7a515fSAndreas Gohr return ''; 1730066fee30SAndreas Gohr} 1731066fee30SAndreas Gohr 1732a81910eeSAndreas Gohr/** 1733835dfcaeSAnika Henke * Includes the rendered HTML of a given page 1734a81910eeSAndreas Gohr * 1735a81910eeSAndreas Gohr * This function is useful to populate sidebars or similar features in a 1736a81910eeSAndreas Gohr * template 1737e0c26282SGerrit Uitslag * 1738e0c26282SGerrit Uitslag * @param string $pageid 1739e0c26282SGerrit Uitslag * @param bool $print 1740e0c26282SGerrit Uitslag * @param bool $propagate 1741e0c26282SGerrit Uitslag * @return bool|null|string 1742a81910eeSAndreas Gohr */ 1743835dfcaeSAnika Henkefunction tpl_include_page($pageid, $print = true, $propagate = false) { 1744c786a1b6SAnika Henke if (!$pageid) return false; 1745835dfcaeSAnika Henke if ($propagate) $pageid = page_findnearest($pageid); 1746835dfcaeSAnika Henke 1747c786a1b6SAnika Henke global $TOC; 17489a2e250aSAndreas Gohr $oldtoc = $TOC; 1749a81910eeSAndreas Gohr $html = p_wiki_xhtml($pageid, '', false); 17509a2e250aSAndreas Gohr $TOC = $oldtoc; 1751a81910eeSAndreas Gohr 1752a81910eeSAndreas Gohr if(!$print) return $html; 1753a81910eeSAndreas Gohr echo $html; 1754e66d3e6dSAndreas Gohr return $html; 1755e66d3e6dSAndreas Gohr} 1756e66d3e6dSAndreas Gohr 1757e66d3e6dSAndreas Gohr/** 17585b75cd1fSAdrian Lang * Display the subscribe form 17595b75cd1fSAdrian Lang * 17605b75cd1fSAdrian Lang * @author Adrian Lang <lang@cosmocode.de> 17615b75cd1fSAdrian Lang */ 17625b75cd1fSAdrian Langfunction tpl_subscribe() { 17635b75cd1fSAdrian Lang global $INFO; 17645b75cd1fSAdrian Lang global $ID; 17655b75cd1fSAdrian Lang global $lang; 17666b8f02cfSAdrian Lang global $conf; 176740c347dbSAdrian Lang $stime_days = $conf['subscribe_time'] / 60 / 60 / 24; 17685b75cd1fSAdrian Lang 17695b75cd1fSAdrian Lang echo p_locale_xhtml('subscr_form'); 17705b75cd1fSAdrian Lang echo '<h2>'.$lang['subscr_m_current_header'].'</h2>'; 177115741132SAndreas Gohr echo '<div class="level2">'; 17725b75cd1fSAdrian Lang if($INFO['subscribed'] === false) { 17735b75cd1fSAdrian Lang echo '<p>'.$lang['subscr_m_not_subscribed'].'</p>'; 17745b75cd1fSAdrian Lang } else { 17755b75cd1fSAdrian Lang echo '<ul>'; 17765b75cd1fSAdrian Lang foreach($INFO['subscribed'] as $sub) { 1777056c2049SAndreas Gohr echo '<li><div class="li">'; 17785b75cd1fSAdrian Lang if($sub['target'] !== $ID) { 1779056c2049SAndreas Gohr echo '<code class="ns">'.hsc(prettyprint_id($sub['target'])).'</code>'; 17805b75cd1fSAdrian Lang } else { 1781056c2049SAndreas Gohr echo '<code class="page">'.hsc(prettyprint_id($sub['target'])).'</code>'; 17825b75cd1fSAdrian Lang } 178340c347dbSAdrian Lang $sstl = sprintf($lang['subscr_style_'.$sub['style']], $stime_days); 178415741132SAndreas Gohr if(!$sstl) $sstl = hsc($sub['style']); 1785056c2049SAndreas Gohr echo ' ('.$sstl.') '; 178615741132SAndreas Gohr 1787ac7a515fSAndreas Gohr echo '<a href="'.wl( 1788ac7a515fSAndreas Gohr $ID, 1789ac7a515fSAndreas Gohr array( 1790ac7a515fSAndreas Gohr 'do' => 'subscribe', 179166d2bed9SAdrian Lang 'sub_target'=> $sub['target'], 179266d2bed9SAdrian Lang 'sub_style' => $sub['style'], 179366d2bed9SAdrian Lang 'sub_action'=> 'unsubscribe', 1794ac7a515fSAndreas Gohr 'sectok' => getSecurityToken() 1795ac7a515fSAndreas Gohr ) 1796ac7a515fSAndreas Gohr ). 179766d2bed9SAdrian Lang '" class="unsubscribe">'.$lang['subscr_m_unsubscribe']. 179866d2bed9SAdrian Lang '</a></div></li>'; 17995b75cd1fSAdrian Lang } 18005b75cd1fSAdrian Lang echo '</ul>'; 18015b75cd1fSAdrian Lang } 180215741132SAndreas Gohr echo '</div>'; 18035b75cd1fSAdrian Lang 180415741132SAndreas Gohr // Add new subscription form 18055b75cd1fSAdrian Lang echo '<h2>'.$lang['subscr_m_new_header'].'</h2>'; 180615741132SAndreas Gohr echo '<div class="level2">'; 18075b75cd1fSAdrian Lang $ns = getNS($ID).':'; 180815741132SAndreas Gohr $targets = array( 180915741132SAndreas Gohr $ID => '<code class="page">'.prettyprint_id($ID).'</code>', 181015741132SAndreas Gohr $ns => '<code class="ns">'.prettyprint_id($ns).'</code>', 181115741132SAndreas Gohr ); 181215741132SAndreas Gohr $styles = array( 181315741132SAndreas Gohr 'every' => $lang['subscr_style_every'], 18146b8f02cfSAdrian Lang 'digest' => sprintf($lang['subscr_style_digest'], $stime_days), 18156b8f02cfSAdrian Lang 'list' => sprintf($lang['subscr_style_list'], $stime_days), 181615741132SAndreas Gohr ); 181715741132SAndreas Gohr 1818056c2049SAndreas Gohr $form = new Doku_Form(array('id' => 'subscribe__form')); 1819056c2049SAndreas Gohr $form->startFieldset($lang['subscr_m_subscribe']); 1820056c2049SAndreas Gohr $form->addRadioSet('sub_target', $targets); 1821056c2049SAndreas Gohr $form->startFieldset($lang['subscr_m_receive']); 1822056c2049SAndreas Gohr $form->addRadioSet('sub_style', $styles); 1823056c2049SAndreas Gohr $form->addHidden('sub_action', 'subscribe'); 1824056c2049SAndreas Gohr $form->addHidden('do', 'subscribe'); 1825056c2049SAndreas Gohr $form->addHidden('id', $ID); 1826056c2049SAndreas Gohr $form->endFieldset(); 18275b75cd1fSAdrian Lang $form->addElement(form_makeButton('submit', 'subscribe', $lang['subscr_m_subscribe'])); 18285b75cd1fSAdrian Lang html_form('SUBSCRIBE', $form); 182915741132SAndreas Gohr echo '</div>'; 18305b75cd1fSAdrian Lang} 18315b75cd1fSAdrian Lang 1832d059ba9bSAndreas Gohr/** 1833d059ba9bSAndreas Gohr * Tries to send already created content right to the browser 1834d059ba9bSAndreas Gohr * 1835d059ba9bSAndreas Gohr * Wraps around ob_flush() and flush() 1836d059ba9bSAndreas Gohr * 1837d059ba9bSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1838d059ba9bSAndreas Gohr */ 1839d059ba9bSAndreas Gohrfunction tpl_flush() { 1840d059ba9bSAndreas Gohr ob_flush(); 1841d059ba9bSAndreas Gohr flush(); 1842d059ba9bSAndreas Gohr} 1843d059ba9bSAndreas Gohr 1844afca7e7eSAnika Henke/** 1845378325f9SAndreas Gohr * Tries to find a ressource file in the given locations. 1846afca7e7eSAnika Henke * 1847378325f9SAndreas Gohr * If a given location starts with a colon it is assumed to be a media 1848378325f9SAndreas Gohr * file, otherwise it is assumed to be relative to the current template 1849378325f9SAndreas Gohr * 185042ea7f44SGerrit Uitslag * @param string[] $search locations to look at 1851378325f9SAndreas Gohr * @param bool $abs if to use absolute URL 1852ac7a515fSAndreas Gohr * @param array &$imginfo filled with getimagesize() 1853ac7a515fSAndreas Gohr * @return string 185442ea7f44SGerrit Uitslag * 1855378325f9SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1856afca7e7eSAnika Henke */ 1857378325f9SAndreas Gohrfunction tpl_getMediaFile($search, $abs = false, &$imginfo = null) { 1858ac7a515fSAndreas Gohr $img = ''; 1859ac7a515fSAndreas Gohr $file = ''; 1860ac7a515fSAndreas Gohr $ismedia = false; 1861378325f9SAndreas Gohr // loop through candidates until a match was found: 1862378325f9SAndreas Gohr foreach($search as $img) { 1863378325f9SAndreas Gohr if(substr($img, 0, 1) == ':') { 1864378325f9SAndreas Gohr $file = mediaFN($img); 1865378325f9SAndreas Gohr $ismedia = true; 1866378325f9SAndreas Gohr } else { 1867c4766956SAndreas Gohr $file = tpl_incdir().$img; 1868378325f9SAndreas Gohr $ismedia = false; 18691f13e33dSAnika Henke } 18700f747863Slupo49 1871378325f9SAndreas Gohr if(file_exists($file)) break; 1872872a6d29SAnika Henke } 1873378325f9SAndreas Gohr 1874378325f9SAndreas Gohr // fetch image data if requested 1875378325f9SAndreas Gohr if(!is_null($imginfo)) { 1876378325f9SAndreas Gohr $imginfo = getimagesize($file); 1877378325f9SAndreas Gohr } 1878378325f9SAndreas Gohr 1879378325f9SAndreas Gohr // build URL 1880378325f9SAndreas Gohr if($ismedia) { 1881378325f9SAndreas Gohr $url = ml($img, '', true, '', $abs); 1882378325f9SAndreas Gohr } else { 1883c4766956SAndreas Gohr $url = tpl_basedir().$img; 1884378325f9SAndreas Gohr if($abs) $url = DOKU_URL.substr($url, strlen(DOKU_REL)); 1885378325f9SAndreas Gohr } 1886378325f9SAndreas Gohr 1887378325f9SAndreas Gohr return $url; 1888a7e5f74cSlupo49} 18891f13e33dSAnika Henke 1890872a6d29SAnika Henke/** 1891e5d4768dSAndreas Gohr * PHP include a file 1892e5d4768dSAndreas Gohr * 1893e5d4768dSAndreas Gohr * either from the conf directory if it exists, otherwise use 1894e5d4768dSAndreas Gohr * file in the template's root directory. 1895e5d4768dSAndreas Gohr * 1896e5d4768dSAndreas Gohr * The function honours config cascade settings and looks for the given 1897e5d4768dSAndreas Gohr * file next to the ´main´ config files, in the order protected, local, 1898e5d4768dSAndreas Gohr * default. 1899e5d4768dSAndreas Gohr * 1900e5d4768dSAndreas Gohr * Note: no escaping or sanity checking is done here. Never pass user input 1901e5d4768dSAndreas Gohr * to this function! 1902e5d4768dSAndreas Gohr * 1903e5d4768dSAndreas Gohr * @author Anika Henke <anika@selfthinker.org> 1904e5d4768dSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 190542ea7f44SGerrit Uitslag * 190642ea7f44SGerrit Uitslag * @param string $file 1907e5d4768dSAndreas Gohr */ 1908e5d4768dSAndreas Gohrfunction tpl_includeFile($file) { 1909e5d4768dSAndreas Gohr global $config_cascade; 1910e5d4768dSAndreas Gohr foreach(array('protected', 'local', 'default') as $config_group) { 1911e5d4768dSAndreas Gohr if(empty($config_cascade['main'][$config_group])) continue; 1912e5d4768dSAndreas Gohr foreach($config_cascade['main'][$config_group] as $conf_file) { 1913e5d4768dSAndreas Gohr $dir = dirname($conf_file); 1914e5d4768dSAndreas Gohr if(file_exists("$dir/$file")) { 1915f3a1225fSAnika Henke include("$dir/$file"); 1916e5d4768dSAndreas Gohr return; 1917e5d4768dSAndreas Gohr } 1918e5d4768dSAndreas Gohr } 1919e5d4768dSAndreas Gohr } 1920e5d4768dSAndreas Gohr 1921e5d4768dSAndreas Gohr // still here? try the template dir 1922e5d4768dSAndreas Gohr $file = tpl_incdir().$file; 1923e5d4768dSAndreas Gohr if(file_exists($file)) { 1924f3a1225fSAnika Henke include($file); 1925e5d4768dSAndreas Gohr } 1926e5d4768dSAndreas Gohr} 1927e5d4768dSAndreas Gohr 1928e5d4768dSAndreas Gohr/** 1929872a6d29SAnika Henke * Returns <link> tag for various icon types (favicon|mobile|generic) 1930872a6d29SAnika Henke * 1931872a6d29SAnika Henke * @author Anika Henke <anika@selfthinker.org> 193242ea7f44SGerrit Uitslag * 1933ac7a515fSAndreas Gohr * @param array $types - list of icon types to display (favicon|mobile|generic) 1934ac7a515fSAndreas Gohr * @return string 1935872a6d29SAnika Henke */ 1936872a6d29SAnika Henkefunction tpl_favicon($types = array('favicon')) { 1937872a6d29SAnika Henke 1938872a6d29SAnika Henke $return = ''; 1939872a6d29SAnika Henke 1940872a6d29SAnika Henke foreach($types as $type) { 1941872a6d29SAnika Henke switch($type) { 1942872a6d29SAnika Henke case 'favicon': 1943378325f9SAndreas Gohr $look = array(':wiki:favicon.ico', ':favicon.ico', 'images/favicon.ico'); 1944378325f9SAndreas Gohr $return .= '<link rel="shortcut icon" href="'.tpl_getMediaFile($look).'" />'.NL; 1945872a6d29SAnika Henke break; 1946872a6d29SAnika Henke case 'mobile': 1947cab75975SAnika Henke $look = array(':wiki:apple-touch-icon.png', ':apple-touch-icon.png', 'images/apple-touch-icon.png'); 1948378325f9SAndreas Gohr $return .= '<link rel="apple-touch-icon" href="'.tpl_getMediaFile($look).'" />'.NL; 1949872a6d29SAnika Henke break; 1950872a6d29SAnika Henke case 'generic': 1951872a6d29SAnika Henke // ideal world solution, which doesn't work in any browser yet 1952378325f9SAndreas Gohr $look = array(':wiki:favicon.svg', ':favicon.svg', 'images/favicon.svg'); 1953378325f9SAndreas Gohr $return .= '<link rel="icon" href="'.tpl_getMediaFile($look).'" type="image/svg+xml" />'.NL; 1954872a6d29SAnika Henke break; 1955872a6d29SAnika Henke } 1956872a6d29SAnika Henke } 1957872a6d29SAnika Henke 1958872a6d29SAnika Henke return $return; 1959afca7e7eSAnika Henke} 1960afca7e7eSAnika Henke 1961d9162c6cSKate Arzamastseva/** 1962d9162c6cSKate Arzamastseva * Prints full-screen media manager 1963d9162c6cSKate Arzamastseva * 1964d9162c6cSKate Arzamastseva * @author Kate Arzamastseva <pshns@ukr.net> 1965d9162c6cSKate Arzamastseva */ 1966d9162c6cSKate Arzamastsevafunction tpl_media() { 1967ac7a515fSAndreas Gohr global $NS, $IMG, $JUMPTO, $REV, $lang, $fullscreen, $INPUT; 196888a71175SKate Arzamastseva $fullscreen = true; 196995b451bcSAdrian Lang require_once DOKU_INC.'lib/exe/mediamanager.php'; 1970d9162c6cSKate Arzamastseva 1971ac7a515fSAndreas Gohr $rev = ''; 1972ac7a515fSAndreas Gohr $image = cleanID($INPUT->str('image')); 197398f03b57SKate Arzamastseva if(isset($IMG)) $image = $IMG; 197498f03b57SKate Arzamastseva if(isset($JUMPTO)) $image = $JUMPTO; 19759c1bd4bcSKate Arzamastseva if(isset($REV) && !$JUMPTO) $rev = $REV; 197698f03b57SKate Arzamastseva 197794add303SAnika Henke echo '<div id="mediamanager__page">'.NL; 1978bc314c58SAnika Henke echo '<h1>'.$lang['btn_media'].'</h1>'.NL; 1979d9162c6cSKate Arzamastseva html_msgarea(); 198094add303SAnika Henke 198194add303SAnika Henke echo '<div class="panel namespaces">'.NL; 198294add303SAnika Henke echo '<h2>'.$lang['namespaces'].'</h2>'.NL; 198395b451bcSAdrian Lang echo '<div class="panelHeader">'; 1984ba340a70SAnika Henke echo $lang['media_namespaces']; 198594add303SAnika Henke echo '</div>'.NL; 198695b451bcSAdrian Lang 198794add303SAnika Henke echo '<div class="panelContent" id="media__tree">'.NL; 198895b451bcSAdrian Lang media_nstree($NS); 198994add303SAnika Henke echo '</div>'.NL; 199094add303SAnika Henke echo '</div>'.NL; 1991fa8e5c77SKate Arzamastseva 199294add303SAnika Henke echo '<div class="panel filelist">'.NL; 1993035e07f1SKate Arzamastseva tpl_mediaFileList(); 199494add303SAnika Henke echo '</div>'.NL; 1995fa8e5c77SKate Arzamastseva 199694add303SAnika Henke echo '<div class="panel file">'.NL; 199794add303SAnika Henke echo '<h2 class="a11y">'.$lang['media_file'].'</h2>'.NL; 1998035e07f1SKate Arzamastseva tpl_mediaFileDetails($image, $rev); 199994add303SAnika Henke echo '</div>'.NL; 2000ba340a70SAnika Henke 200194add303SAnika Henke echo '</div>'.NL; 2002d9162c6cSKate Arzamastseva} 2003afca7e7eSAnika Henke 2004c71db656SAnika Henke/** 2005c71db656SAnika Henke * Return useful layout classes 2006c71db656SAnika Henke * 2007c71db656SAnika Henke * @author Anika Henke <anika@selfthinker.org> 200842ea7f44SGerrit Uitslag * 200942ea7f44SGerrit Uitslag * @return string 2010c71db656SAnika Henke */ 2011c71db656SAnika Henkefunction tpl_classes() { 2012c71db656SAnika Henke global $ACT, $conf, $ID, $INFO; 2013585bf44eSChristopher Smith /** @var Input $INPUT */ 2014585bf44eSChristopher Smith global $INPUT; 2015585bf44eSChristopher Smith 2016c71db656SAnika Henke $classes = array( 2017c71db656SAnika Henke 'dokuwiki', 2018c71db656SAnika Henke 'mode_'.$ACT, 2019c71db656SAnika Henke 'tpl_'.$conf['template'], 2020585bf44eSChristopher Smith $INPUT->server->bool('REMOTE_USER') ? 'loggedIn' : '', 202139f00629SAnika Henke $INFO['exists'] ? '' : 'notFound', 2022c71db656SAnika Henke ($ID == $conf['start']) ? 'home' : '', 2023c71db656SAnika Henke ); 2024c71db656SAnika Henke return join(' ', $classes); 2025c71db656SAnika Henke} 2026c71db656SAnika Henke 2027e3776c06SMichael Hamann//Setup VIM: ex: et ts=4 : 2028a00de5b5SAndreas Gohr 2029