');
}
/**
* Prints the central column in full-screen media manager
* Depending on the opened tab this may be a list of
* files in a namespace, upload form or search form
*
* @author Kate Arzamastseva
*/
function tpl_mediaFileList() {
global $AUTH;
global $NS;
global $JUMPTO;
global $lang;
/** @var Input $INPUT */
global $INPUT;
$opened_tab = $INPUT->str('tab_files');
if(!$opened_tab || !in_array($opened_tab, array('files', 'upload', 'search'))) $opened_tab = 'files';
if($INPUT->str('mediado') == 'update') $opened_tab = 'upload';
echo '
'.NL;
}
/**
* prints the namespace tree in the mediamanager popup
*
* Only allowed in mediamanager.php
*
* @author Andreas Gohr
*/
function tpl_mediaTree() {
global $NS;
ptln('
');
media_nstree($NS);
ptln('
');
}
/**
* Print a dropdown menu with all DokuWiki actions
*
* Note: this will not use any pretty URLs
*
* @author Andreas Gohr
*
* @param string $empty empty option label
* @param string $button submit button label
* @deprecated 2017-09-01 see devel:menus
*/
function tpl_actiondropdown($empty = '', $button = '>') {
dbg_deprecated('see devel:menus');
$menu = new \dokuwiki\Menu\MobileMenu();
echo $menu->getDropdown($empty, $button);
}
/**
* Print a informational line about the used license
*
* @author Andreas Gohr
* @param string $img print image? (|button|badge)
* @param bool $imgonly skip the textual description?
* @param bool $return when true don't print, but return HTML
* @param bool $wrap wrap in div with class="license"?
* @return string
*/
function tpl_license($img = 'badge', $imgonly = false, $return = false, $wrap = true) {
global $license;
global $conf;
global $lang;
if(!$conf['license']) return '';
if(!is_array($license[$conf['license']])) return '';
$lic = $license[$conf['license']];
$target = ($conf['target']['extern']) ? ' target="'.$conf['target']['extern'].'"' : '';
$out = '';
if($wrap) $out .= '
';
if($return) return $out;
echo $out;
return '';
}
/**
* Includes the rendered HTML of a given page
*
* This function is useful to populate sidebars or similar features in a
* template
*
* @param string $pageid The page name you want to include
* @param bool $print Should the content be printed or returned only
* @param bool $propagate Search higher namespaces, too?
* @param bool $useacl Include the page only if the ACLs check out?
* @return bool|null|string
*/
function tpl_include_page($pageid, $print = true, $propagate = false, $useacl = true) {
if($propagate) {
$pageid = page_findnearest($pageid, $useacl);
} elseif($useacl && auth_quickaclcheck($pageid) == AUTH_NONE) {
return false;
}
if(!$pageid) return false;
global $TOC;
$oldtoc = $TOC;
$html = p_wiki_xhtml($pageid, '', false);
$TOC = $oldtoc;
if($print) echo $html;
return $html;
}
/**
* Display the subscribe form
*
* @author Adrian Lang
*/
function tpl_subscribe() {
global $INFO;
global $ID;
global $lang;
global $conf;
$stime_days = $conf['subscribe_time'] / 60 / 60 / 24;
echo p_locale_xhtml('subscr_form');
echo '
';
}
/**
* Tries to send already created content right to the browser
*
* Wraps around ob_flush() and flush()
*
* @author Andreas Gohr
*/
function tpl_flush() {
if( ob_get_level() > 0 ) ob_flush();
flush();
}
/**
* Tries to find a ressource file in the given locations.
*
* If a given location starts with a colon it is assumed to be a media
* file, otherwise it is assumed to be relative to the current template
*
* @param string[] $search locations to look at
* @param bool $abs if to use absolute URL
* @param array &$imginfo filled with getimagesize()
* @param bool $fallback use fallback image if target isn't found or return 'false' if potential
* false result is required
* @return string
*
* @author Andreas Gohr
*/
function tpl_getMediaFile($search, $abs = false, &$imginfo = null, $fallback = true) {
$img = '';
$file = '';
$ismedia = false;
// loop through candidates until a match was found:
foreach($search as $img) {
if(substr($img, 0, 1) == ':') {
$file = mediaFN($img);
$ismedia = true;
} else {
$file = tpl_incdir().$img;
$ismedia = false;
}
if(file_exists($file)) break;
}
// manage non existing target
if (!file_exists($file)) {
// give result for fallback image
if ($fallback === true) {
$file = DOKU_INC . 'lib/images/blank.gif';
// stop process if false result is required (if $fallback is false)
} else {
return false;
}
}
// fetch image data if requested
if(!is_null($imginfo)) {
$imginfo = getimagesize($file);
}
// build URL
if($ismedia) {
$url = ml($img, '', true, '', $abs);
} else {
$url = tpl_basedir().$img;
if($abs) $url = DOKU_URL.substr($url, strlen(DOKU_REL));
}
return $url;
}
/**
* PHP include a file
*
* either from the conf directory if it exists, otherwise use
* file in the template's root directory.
*
* The function honours config cascade settings and looks for the given
* file next to the ´main´ config files, in the order protected, local,
* default.
*
* Note: no escaping or sanity checking is done here. Never pass user input
* to this function!
*
* @author Anika Henke
* @author Andreas Gohr
*
* @param string $file
*/
function tpl_includeFile($file) {
global $config_cascade;
foreach(array('protected', 'local', 'default') as $config_group) {
if(empty($config_cascade['main'][$config_group])) continue;
foreach($config_cascade['main'][$config_group] as $conf_file) {
$dir = dirname($conf_file);
if(file_exists("$dir/$file")) {
include("$dir/$file");
return;
}
}
}
// still here? try the template dir
$file = tpl_incdir().$file;
if(file_exists($file)) {
include($file);
}
}
/**
* Returns tag for various icon types (favicon|mobile|generic)
*
* @author Anika Henke
*
* @param array $types - list of icon types to display (favicon|mobile|generic)
* @return string
*/
function tpl_favicon($types = array('favicon')) {
$return = '';
foreach($types as $type) {
switch($type) {
case 'favicon':
$look = array(':wiki:favicon.ico', ':favicon.ico', 'images/favicon.ico');
$return .= ''.NL;
break;
case 'mobile':
$look = array(':wiki:apple-touch-icon.png', ':apple-touch-icon.png', 'images/apple-touch-icon.png');
$return .= ''.NL;
break;
case 'generic':
// ideal world solution, which doesn't work in any browser yet
$look = array(':wiki:favicon.svg', ':favicon.svg', 'images/favicon.svg');
$return .= ''.NL;
break;
}
}
return $return;
}
/**
* Prints full-screen media manager
*
* @author Kate Arzamastseva
*/
function tpl_media() {
global $NS, $IMG, $JUMPTO, $REV, $lang, $fullscreen, $INPUT;
$fullscreen = true;
require_once DOKU_INC.'lib/exe/mediamanager.php';
$rev = '';
$image = cleanID($INPUT->str('image'));
if(isset($IMG)) $image = $IMG;
if(isset($JUMPTO)) $image = $JUMPTO;
if(isset($REV) && !$JUMPTO) $rev = $REV;
echo '