xref: /dokuwiki/inc/template.php (revision 377f9e9776677a6d3963718bfd48bba361571dfb)
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
96b13307fSandi  if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
10e7cb32dcSAndreas Gohr  require_once(DOKU_CONF.'dokuwiki.php');
116b13307fSandi
126b13307fSandi/**
135a892029SAndreas Gohr * Returns the path to the given template, uses
14524be65dSBen Coburn * default one if the custom version doesn't exist.
15524be65dSBen Coburn * Also enables gzip compression if configured.
165a892029SAndreas Gohr *
175a892029SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
185a892029SAndreas Gohr */
195a892029SAndreas Gohrfunction template($tpl){
205a892029SAndreas Gohr  global $conf;
215a892029SAndreas Gohr
225a892029SAndreas Gohr  if(@is_readable(DOKU_INC.'lib/tpl/'.$conf['template'].'/'.$tpl))
235a892029SAndreas Gohr    return DOKU_INC.'lib/tpl/'.$conf['template'].'/'.$tpl;
245a892029SAndreas Gohr
255a892029SAndreas Gohr  return DOKU_INC.'lib/tpl/default/'.$tpl;
265a892029SAndreas Gohr}
275a892029SAndreas Gohr
285a892029SAndreas Gohr/**
296b13307fSandi * Print the content
306b13307fSandi *
316b13307fSandi * This function is used for printing all the usual content
326b13307fSandi * (defined by the global $ACT var) by calling the appropriate
336b13307fSandi * outputfunction(s) from html.php
346b13307fSandi *
35ee4c4a1bSAndreas Gohr * Everything that doesn't use the main template file isn't
36ee4c4a1bSAndreas Gohr * handled by this function. ACL stuff is not done here either.
376b13307fSandi *
386b13307fSandi * @author Andreas Gohr <andi@splitbrain.org>
396b13307fSandi */
406b13307fSandifunction tpl_content() {
417ea0913cSchris  global $ACT;
427ea0913cSchris
437ea0913cSchris  ob_start();
447ea0913cSchris
4524bb549bSchris  trigger_event('TPL_ACT_RENDER',$ACT,tpl_content_core);
467ea0913cSchris
477ea0913cSchris  $html_output = ob_get_clean();
487ea0913cSchris
4924bb549bSchris  trigger_event('TPL_CONTENT_DISPLAY',$html_output,ptln);
507ea0913cSchris}
517ea0913cSchris
527ea0913cSchrisfunction tpl_content_core(){
536b13307fSandi  global $ACT;
546b13307fSandi  global $TEXT;
556b13307fSandi  global $PRE;
566b13307fSandi  global $SUF;
576b13307fSandi  global $SUM;
586b13307fSandi  global $IDX;
596b13307fSandi
606b13307fSandi  switch($ACT){
616b13307fSandi    case 'show':
626b13307fSandi      html_show();
636b13307fSandi      break;
64ea67f144Sandi    case 'preview':
656b13307fSandi      html_edit($TEXT);
666b13307fSandi      html_show($TEXT);
676b13307fSandi      break;
68ee4c4a1bSAndreas Gohr    case 'recover':
69ee4c4a1bSAndreas Gohr      html_edit($TEXT);
70ee4c4a1bSAndreas Gohr      break;
716b13307fSandi    case 'edit':
726b13307fSandi      html_edit();
736b13307fSandi      break;
74ee4c4a1bSAndreas Gohr    case 'draft':
75ee4c4a1bSAndreas Gohr      html_draft();
76ee4c4a1bSAndreas Gohr      break;
776b13307fSandi    case 'wordblock':
786b13307fSandi      html_edit($TEXT,'wordblock');
796b13307fSandi      break;
806b13307fSandi    case 'search':
816b13307fSandi      html_search();
826b13307fSandi      break;
836b13307fSandi    case 'revisions':
846b13307fSandi      html_revisions();
856b13307fSandi      break;
866b13307fSandi    case 'diff':
876b13307fSandi      html_diff();
886b13307fSandi      break;
896b13307fSandi    case 'recent':
905749f1ceSmatthiasgrimm      $first = is_numeric($_REQUEST['first']) ? intval($_REQUEST['first']) : 0;
91a39955b0Smatthiasgrimm      html_recent($first);
926b13307fSandi      break;
936b13307fSandi    case 'index':
946b13307fSandi      html_index($IDX); #FIXME can this be pulled from globals? is it sanitized correctly?
956b13307fSandi      break;
966b13307fSandi    case 'backlink':
976b13307fSandi      html_backlinks();
986b13307fSandi      break;
996b13307fSandi    case 'conflict':
1006b13307fSandi      html_conflict(con($PRE,$TEXT,$SUF),$SUM);
1016b13307fSandi      html_diff(con($PRE,$TEXT,$SUF),false);
1026b13307fSandi      break;
1036b13307fSandi    case 'locked':
104ee20e7d1Sandi      html_locked();
1056b13307fSandi      break;
1066b13307fSandi    case 'login':
1076b13307fSandi      html_login();
1086b13307fSandi      break;
1096b13307fSandi    case 'register':
1106b13307fSandi      html_register();
1116b13307fSandi      break;
1128b06d178Schris    case 'resendpwd':
1138b06d178Schris      html_resendpwd();
1148b06d178Schris      break;
115820fa24bSandi    case 'denied':
1165e991bd8Sandi      print p_locale_xhtml('denied');
117820fa24bSandi      break;
1188b06d178Schris    case 'profile' :
1198b06d178Schris      html_updateprofile();
1208b06d178Schris      break;
121c19fe9c0Sandi    case 'admin':
122c19fe9c0Sandi      tpl_admin();
123c19fe9c0Sandi      break;
1246b13307fSandi    default:
12524bb549bSchris      $evt = new Doku_Event('TPL_ACT_UNKNOWN',$ACT);
12624bb549bSchris      if ($evt->advise_before())
127ea67f144Sandi        msg("Failed to handle command: ".hsc($ACT),-1);
12824bb549bSchris      $evt->advise_after();
12924bb549bSchris      unset($evt);
1306b13307fSandi  }
1316b13307fSandi}
1326b13307fSandi
133c19fe9c0Sandi/**
134c19fe9c0Sandi * Handle the admin page contents
135c19fe9c0Sandi *
136c19fe9c0Sandi * @author Andreas Gohr <andi@splitbrain.org>
137c19fe9c0Sandi */
138c19fe9c0Sandifunction tpl_admin(){
13911e2ce22Schris
14011e2ce22Schris    $plugin = NULL;
14111e2ce22Schris    if ($_REQUEST['page']) {
14211e2ce22Schris        $pluginlist = plugin_list('admin');
14311e2ce22Schris
14411e2ce22Schris        if (in_array($_REQUEST['page'], $pluginlist)) {
14511e2ce22Schris
14611e2ce22Schris          // attempt to load the plugin
14711e2ce22Schris          $plugin =& plugin_load('admin',$_REQUEST['page']);
14811e2ce22Schris        }
14911e2ce22Schris    }
15011e2ce22Schris
15111e2ce22Schris    if ($plugin !== NULL)
15211e2ce22Schris        $plugin->html();
15311e2ce22Schris    else
15411e2ce22Schris        html_admin();
155c19fe9c0Sandi}
1566b13307fSandi
1576b13307fSandi/**
1586b13307fSandi * Print the correct HTML meta headers
1596b13307fSandi *
1606b13307fSandi * This has to go into the head section of your template.
1616b13307fSandi *
162f96fa415SAndreas Gohr * @param  boolean $alt Should feeds and alternative format links be added?
1636b13307fSandi * @author Andreas Gohr <andi@splitbrain.org>
1646b13307fSandi */
165f96fa415SAndreas Gohrfunction tpl_metaheaders($alt=true){
1666b13307fSandi  global $ID;
1676b13307fSandi  global $INFO;
1686b13307fSandi  global $ACT;
1696b13307fSandi  global $lang;
170dc57ef04Sandi  global $conf;
1716b13307fSandi  $it=2;
1726b13307fSandi
1736b13307fSandi  // the usual stuff
1746b13307fSandi  ptln('<meta name="generator" content="DokuWiki '.getVersion().'" />',$it);
1756b13307fSandi  ptln('<link rel="start" href="'.DOKU_BASE.'" />',$it);
1766b13307fSandi  ptln('<link rel="contents" href="'.wl($ID,'do=index').'" title="'.$lang['index'].'" />',$it);
177f96fa415SAndreas Gohr
178f96fa415SAndreas Gohr  if($alt){
1796b13307fSandi    ptln('<link rel="alternate" type="application/rss+xml" title="Recent Changes" href="'.DOKU_BASE.'feed.php" />',$it);
1806b13307fSandi    ptln('<link rel="alternate" type="application/rss+xml" title="Current Namespace" href="'.DOKU_BASE.'feed.php?mode=list&amp;ns='.$INFO['namespace'].'" />',$it);
181f5c2808fSBen Coburn    ptln('<link rel="alternate" type="text/html" title="Plain HTML" href="'.exportlink($ID, 'xhtml').'" />',$it);
182f5c2808fSBen Coburn    ptln('<link rel="alternate" type="text/plain" title="Wiki Markup" href="'.exportlink($ID, 'raw').'" />',$it);
183f96fa415SAndreas Gohr  }
1846b13307fSandi
1856b13307fSandi  // setup robot tags apropriate for different modes
1864f2e0004STim Weber  if( ($ACT=='show' || $ACT=='export_xhtml') && !$REV){
1876b13307fSandi    if($INFO['exists']){
1886b13307fSandi      ptln('<meta name="date" content="'.date('Y-m-d\TH:i:sO',$INFO['lastmod']).'" />',$it);
1896b13307fSandi      //delay indexing:
1906b13307fSandi      if((time() - $INFO['lastmod']) >= $conf['indexdelay']){
1916b13307fSandi        ptln('<meta name="robots" content="index,follow" />',$it);
1926b13307fSandi      }else{
1936b13307fSandi        ptln('<meta name="robots" content="noindex,nofollow" />',$it);
1946b13307fSandi      }
1956b13307fSandi    }else{
1966b13307fSandi      ptln('<meta name="robots" content="noindex,follow" />',$it);
1976b13307fSandi    }
1986b13307fSandi  }else{
1996b13307fSandi    ptln('<meta name="robots" content="noindex,nofollow" />',$it);
2006b13307fSandi  }
2016b13307fSandi
20278a6aeb1SAndreas Gohr  // load stylesheets
20378a6aeb1SAndreas Gohr  ptln('<link rel="stylesheet" media="screen" type="text/css" href="'.DOKU_BASE.'lib/exe/css.php" />',$it);
20478a6aeb1SAndreas Gohr  ptln('<link rel="stylesheet" media="print" type="text/css" href="'.DOKU_BASE.'lib/exe/css.php?print=1" />',$it);
205bad31ae9SAndreas Gohr
20678a6aeb1SAndreas Gohr  // load javascript
207ee4c4a1bSAndreas Gohr  $js_edit  = ($ACT=='edit' || $ACT=='preview' || $ACT=='recover') ? 1 : 0;
208bad31ae9SAndreas Gohr  $js_write = ($INFO['writable']) ? 1 : 0;
2093df72098SAndreas Gohr  if(defined('DOKU_MEDIAMANAGER')){
2103df72098SAndreas Gohr    $js_edit  = 1;
2113df72098SAndreas Gohr    $js_write = 0;
2123df72098SAndreas Gohr  }
2133df72098SAndreas Gohr  if(($js_edit && $js_write) || defined('DOKU_MEDIAMANAGER')){
2144beabca9SAnika Henke    ptln('<script type="text/javascript" charset="utf-8">',$it);
215c591aabeSAndreas Gohr    ptln("NS='".$INFO['namespace']."';",$it+2);
216c591aabeSAndreas Gohr    if($conf['useacl'] && $_SERVER['REMOTE_USER']){
217aeaccbf9SAndreas Gohr      require_once(DOKU_INC.'inc/toolbar.php');
218c591aabeSAndreas Gohr      ptln("SIG='".toolbar_signature()."';",$it+2);
219c591aabeSAndreas Gohr    }
220c591aabeSAndreas Gohr    ptln('</script>',$it);
221c591aabeSAndreas Gohr  }
2224beabca9SAnika Henke  ptln('<script type="text/javascript" charset="utf-8" src="'.
223c591aabeSAndreas Gohr       DOKU_BASE.'lib/exe/js.php?edit='.$js_edit.'&amp;write='.$js_write.'"></script>',$it);
2246b13307fSandi}
2256b13307fSandi
2266b13307fSandi/**
2276b13307fSandi * Print a link
2286b13307fSandi *
2295e163278SAndreas Gohr * Just builds a link.
2306b13307fSandi *
2316b13307fSandi * @author Andreas Gohr <andi@splitbrain.org>
2326b13307fSandi */
2336b13307fSandifunction tpl_link($url,$name,$more=''){
2345e163278SAndreas Gohr  print '<a href="'.$url.'" ';
2356b13307fSandi  if ($more) print ' '.$more;
2366b13307fSandi  print ">$name</a>";
2376b13307fSandi}
2386b13307fSandi
2396b13307fSandi/**
24055efc227SAndreas Gohr * Prints a link to a WikiPage
24155efc227SAndreas Gohr *
24255efc227SAndreas Gohr * Wrapper around html_wikilink
24355efc227SAndreas Gohr *
24455efc227SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
24555efc227SAndreas Gohr */
24655efc227SAndreas Gohrfunction tpl_pagelink($id,$name=NULL){
24755efc227SAndreas Gohr  print html_wikilink($id,$name);
24855efc227SAndreas Gohr}
24955efc227SAndreas Gohr
25055efc227SAndreas Gohr/**
251a3ec5f4aSmatthiasgrimm * get the parent page
252a3ec5f4aSmatthiasgrimm *
253a3ec5f4aSmatthiasgrimm * Tries to find out which page is parent.
254a3ec5f4aSmatthiasgrimm * returns false if none is available
255a3ec5f4aSmatthiasgrimm *
256*377f9e97SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
257a3ec5f4aSmatthiasgrimm */
258*377f9e97SAndreas Gohrfunction tpl_getparent($id){
259a3ec5f4aSmatthiasgrimm  global $conf;
260*377f9e97SAndreas Gohr  $parent = getNS($id).':';
261*377f9e97SAndreas Gohr  resolve_pageid('',$parent,$exists);
262*377f9e97SAndreas Gohr  if($parent == $id) return false;
263*377f9e97SAndreas Gohr  return $parent;
264a3ec5f4aSmatthiasgrimm}
265a3ec5f4aSmatthiasgrimm
266a3ec5f4aSmatthiasgrimm/**
2676b13307fSandi * Print one of the buttons
2686b13307fSandi *
2696b13307fSandi * Available Buttons are
2706b13307fSandi *
271ee4c4a1bSAndreas Gohr *  edit        - edit/create/show/draft button
2726b13307fSandi *  history     - old revisions
2736b13307fSandi *  recent      - recent changes
2746b13307fSandi *  login       - login/logout button - if ACL enabled
2756b13307fSandi *  index       - The index
276c19fe9c0Sandi *  admin       - admin page - if enough rights
2776b13307fSandi *  top         - a back to top button
278a3ec5f4aSmatthiasgrimm *  back        - a back to parent button - if available
279d67ca2c0Smatthiasgrimm *  backtomedia - returns to the mediafile upload dialog
280d67ca2c0Smatthiasgrimm *                after references have been displayed
281bbd37938SAndreas Gohr *  backlink    - links to the list of backlinks
2826b13307fSandi *
2836b13307fSandi * @author Andreas Gohr <andi@splitbrain.org>
284a3ec5f4aSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
2856b13307fSandi */
2866b13307fSandifunction tpl_button($type){
287b158d625SSteven Danz  global $ACT;
2886b13307fSandi  global $ID;
289d67ca2c0Smatthiasgrimm  global $NS;
290c19fe9c0Sandi  global $INFO;
2916b13307fSandi  global $conf;
292cd52f92dSchris  global $auth;
2936b13307fSandi
2946b13307fSandi  switch($type){
2956b13307fSandi    case 'edit':
2966b13307fSandi      print html_editbutton();
2976b13307fSandi      break;
2986b13307fSandi    case 'history':
2995bc81eb9SAnders Betnér      print html_btn('revs',$ID,'o',array('do' => 'revisions'));
3006b13307fSandi      break;
3016b13307fSandi    case 'recent':
3025bc81eb9SAnders Betnér      print html_btn('recent','','r',array('do' => 'recent'));
3036b13307fSandi      break;
3046b13307fSandi    case 'index':
3055bc81eb9SAnders Betnér      print html_btn('index',$ID,'x',array('do' => 'index'));
3066b13307fSandi      break;
307a3ec5f4aSmatthiasgrimm    case 'back':
3086222040cSmatthiasgrimm      if ($parent = tpl_getparent($ID)) {
3096222040cSmatthiasgrimm        print html_btn('back',$parent,'b',array('do' => 'show'));
310a3ec5f4aSmatthiasgrimm      }
311a3ec5f4aSmatthiasgrimm      break;
3126b13307fSandi    case 'top':
3136b13307fSandi      print html_topbtn();
3146b13307fSandi      break;
3156b13307fSandi    case 'login':
3166b13307fSandi      if($conf['useacl']){
3176b13307fSandi        if($_SERVER['REMOTE_USER']){
3186b13307fSandi          print html_btn('logout',$ID,'',array('do' => 'logout',));
3196b13307fSandi        }else{
3206b13307fSandi          print html_btn('login',$ID,'',array('do' => 'login'));
3216b13307fSandi        }
3226b13307fSandi      }
3236b13307fSandi      break;
324c19fe9c0Sandi    case 'admin':
325c19fe9c0Sandi      if($INFO['perm'] == AUTH_ADMIN)
3265bc81eb9SAnders Betnér        print html_btn('admin',$ID,'',array('do' => 'admin'));
327c19fe9c0Sandi      break;
328d67ca2c0Smatthiasgrimm    case 'backtomedia':
329d67ca2c0Smatthiasgrimm      print html_backtomedia_button(array('ns' => $NS),'b');
330d67ca2c0Smatthiasgrimm      break;
3311380fc45SAndreas Gohr    case 'subscription':
332f9eb5648Ssteven-danz      if($conf['useacl'] && $ACT == 'show' && $conf['subscribers'] == 1){
333b158d625SSteven Danz        if($_SERVER['REMOTE_USER']){
3341380fc45SAndreas Gohr          if($INFO['subscribed']){
3351380fc45SAndreas Gohr            print html_btn('unsubscribe',$ID,'',array('do' => 'unsubscribe',));
336b158d625SSteven Danz          } else {
3371380fc45SAndreas Gohr            print html_btn('subscribe',$ID,'',array('do' => 'subscribe',));
338b158d625SSteven Danz          }
339b158d625SSteven Danz        }
340b158d625SSteven Danz      }
341b158d625SSteven Danz      break;
342f00151b4Schris    case 'backlink':
343f00151b4Schris      print html_btn('backlink',$ID,'',array('do' => 'backlink'));
344f00151b4Schris      break;
3458b06d178Schris    case 'profile':
34636223ba7SAndreas Gohr      if($conf['useacl'] && $_SERVER['REMOTE_USER'] &&
34736223ba7SAndreas Gohr         $auth->canDo('Profile') && ($ACT!='profile')){
3488b06d178Schris        print html_btn('profile',$ID,'',array('do' => 'profile'));
3498b06d178Schris      }
3508b06d178Schris      break;
351c19fe9c0Sandi    default:
352c19fe9c0Sandi      print '[unknown button type]';
3536b13307fSandi  }
3546b13307fSandi}
3556b13307fSandi
3566b13307fSandi/**
357ed630903Sandi * Like the action buttons but links
358ed630903Sandi *
359ed630903Sandi * Available links are
360ed630903Sandi *
361ed630903Sandi *  edit    - edit/create/show button
362ed630903Sandi *  history - old revisions
363ed630903Sandi *  recent  - recent changes
364ed630903Sandi *  login   - login/logout button - if ACL enabled
365ed630903Sandi *  index   - The index
366ed630903Sandi *  admin   - admin page - if enough rights
367ed630903Sandi *  top     - a back to top button
368a3ec5f4aSmatthiasgrimm *  back    - a back to parent button - if available
369bbd37938SAndreas Gohr * backlink - links to the list of backlinks
370ed630903Sandi *
371ed630903Sandi * @author Andreas Gohr <andi@splitbrain.org>
372a3ec5f4aSmatthiasgrimm * @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
373ed630903Sandi * @see    tpl_button
374ed630903Sandi */
375ed630903Sandifunction tpl_actionlink($type,$pre='',$suf=''){
376ed630903Sandi  global $ID;
377ed630903Sandi  global $INFO;
378ed630903Sandi  global $REV;
379ed630903Sandi  global $ACT;
380ed630903Sandi  global $conf;
381ed630903Sandi  global $lang;
382cd52f92dSchris  global $auth;
383ed630903Sandi
384ed630903Sandi  switch($type){
385ed630903Sandi    case 'edit':
386ed630903Sandi      #most complicated type - we need to decide on current action
387ed630903Sandi      if($ACT == 'show' || $ACT == 'search'){
388ed630903Sandi        if($INFO['writable']){
389ed630903Sandi          if($INFO['exists']){
390ed630903Sandi            tpl_link(wl($ID,'do=edit&amp;rev='.$REV),
391ed630903Sandi                     $pre.$lang['btn_edit'].$suf,
392b7af031cSsu                     'class="action edit" accesskey="e" rel="nofollow"');
393ed630903Sandi          }else{
394ed630903Sandi            tpl_link(wl($ID,'do=edit&amp;rev='.$REV),
395ed630903Sandi                     $pre.$lang['btn_create'].$suf,
396b7af031cSsu                     'class="action create" accesskey="e" rel="nofollow"');
397ed630903Sandi          }
398ed630903Sandi        }else{
399ed630903Sandi          tpl_link(wl($ID,'do=edit&amp;rev='.$REV),
400ed630903Sandi                   $pre.$lang['btn_source'].$suf,
401b7af031cSsu                   'class="action source" accesskey="v" rel="nofollow"');
402ed630903Sandi        }
403ed630903Sandi      }else{
404ed630903Sandi          tpl_link(wl($ID,'do=show'),
405ed630903Sandi                   $pre.$lang['btn_show'].$suf,
406b7af031cSsu                   'class="action show" accesskey="v" rel="nofollow"');
407ed630903Sandi      }
408c059e1a6SAndreas Gohr      return true;
409ed630903Sandi    case 'history':
410b7af031cSsu      tpl_link(wl($ID,'do=revisions'),$pre.$lang['btn_revs'].$suf,'class="action revisions" accesskey="o"');
411c059e1a6SAndreas Gohr      return true;
412ed630903Sandi    case 'recent':
413b7af031cSsu      tpl_link(wl($ID,'do=recent'),$pre.$lang['btn_recent'].$suf,'class="action recent" accesskey="r"');
414c059e1a6SAndreas Gohr      return true;
415ed630903Sandi    case 'index':
416b7af031cSsu      tpl_link(wl($ID,'do=index'),$pre.$lang['btn_index'].$suf,'class="action index" accesskey="x"');
417c059e1a6SAndreas Gohr      return true;
418ed630903Sandi    case 'top':
41921a15207SAnika Henke      print '<a href="#dokuwiki__top" class="action top" accesskey="x">'.$pre.$lang['btn_top'].$suf.'</a>';
420c059e1a6SAndreas Gohr      return true;
421a3ec5f4aSmatthiasgrimm    case 'back':
422a3ec5f4aSmatthiasgrimm      if ($ID = tpl_getparent($ID)) {
423b7af031cSsu        tpl_link(wl($ID,'do=show'),$pre.$lang['btn_back'].$suf,'class="action back" accesskey="b"');
424c059e1a6SAndreas Gohr        return true;
425a3ec5f4aSmatthiasgrimm      }
426c059e1a6SAndreas Gohr      return false;
427ed630903Sandi    case 'login':
428ed630903Sandi      if($conf['useacl']){
429ed630903Sandi        if($_SERVER['REMOTE_USER']){
430b7af031cSsu          tpl_link(wl($ID,'do=logout'),$pre.$lang['btn_logout'].$suf,'class="action logout"');
431ed630903Sandi        }else{
432b7af031cSsu          tpl_link(wl($ID,'do=login'),$pre.$lang['btn_login'].$suf,'class="action logout"');
433ed630903Sandi        }
434c059e1a6SAndreas Gohr        return true;
435ed630903Sandi      }
436c059e1a6SAndreas Gohr      return false;
437ed630903Sandi    case 'admin':
438c059e1a6SAndreas Gohr      if($INFO['perm'] == AUTH_ADMIN){
439b7af031cSsu        tpl_link(wl($ID,'do=admin'),$pre.$lang['btn_admin'].$suf,'class="action admin"');
440c059e1a6SAndreas Gohr        return true;
441c059e1a6SAndreas Gohr      }
442c059e1a6SAndreas Gohr      return false;
443f9eb5648Ssteven-danz   case 'subscribe':
444075f000fSChristopher Arndt   case 'subscription':
445f9eb5648Ssteven-danz      if($conf['useacl'] && $ACT == 'show' && $conf['subscribers'] == 1){
446b158d625SSteven Danz        if($_SERVER['REMOTE_USER']){
447075f000fSChristopher Arndt          if($INFO['subscribed']) {
448b7af031cSsu            tpl_link(wl($ID,'do=unsubscribe'),$pre.$lang['btn_unsubscribe'].$suf,'class="action unsubscribe"');
449b158d625SSteven Danz          } else {
450b7af031cSsu            tpl_link(wl($ID,'do=subscribe'),$pre.$lang['btn_subscribe'].$suf,'class="action subscribe"');
451b158d625SSteven Danz          }
452c059e1a6SAndreas Gohr          return true;
453b158d625SSteven Danz        }
454b158d625SSteven Danz      }
455c059e1a6SAndreas Gohr      return false;
456f00151b4Schris    case 'backlink':
457b7af031cSsu      tpl_link(wl($ID,'do=backlink'),$pre.$lang['btn_backlink'].$suf, 'class="action backlink"');
458c059e1a6SAndreas Gohr      return true;
4598b06d178Schris    case 'profile':
46036223ba7SAndreas Gohr      if($conf['useacl'] && $_SERVER['REMOTE_USER'] &&
46136223ba7SAndreas Gohr         $auth->canDo('Profile') && ($ACT!='profile')){
4628b06d178Schris        tpl_link(wl($ID,'do=profile'),$pre.$lang['btn_profile'].$suf, 'class="action profile"');
463c059e1a6SAndreas Gohr        return true;
4648b06d178Schris      }
465c059e1a6SAndreas Gohr      return false;
466ed630903Sandi    default:
467ed630903Sandi      print '[unknown link type]';
468c059e1a6SAndreas Gohr      return true;
469ed630903Sandi  }
470ed630903Sandi}
471ed630903Sandi
472ed630903Sandi/**
4736b13307fSandi * Print the search form
4746b13307fSandi *
47572645b75SAndreas Gohr * If the first parameter is given a div with the ID 'qsearch_out' will
47672645b75SAndreas Gohr * be added which instructs the ajax pagequicksearch to kick in and place
47772645b75SAndreas Gohr * its output into this div. The second parameter controls the propritary
47872645b75SAndreas Gohr * attribute autocomplete. If set to false this attribute will be set with an
47972645b75SAndreas Gohr * value of "off" to instruct the browser to disable it's own built in
48072645b75SAndreas Gohr * autocompletion feature (MSIE and Firefox)
48172645b75SAndreas Gohr *
4826b13307fSandi * @author Andreas Gohr <andi@splitbrain.org>
4836b13307fSandi */
48472645b75SAndreas Gohrfunction tpl_searchform($ajax=true,$autocomplete=true){
4856b13307fSandi  global $lang;
486c1e3b7d9Smatthiasgrimm  global $ACT;
487c1e3b7d9Smatthiasgrimm
4881dd0c202SAnika Henke  print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search"><div class="no">';
4896b13307fSandi  print '<input type="hidden" name="do" value="search" />';
490c1e3b7d9Smatthiasgrimm  print '<input type="text" ';
491bad31ae9SAndreas Gohr  if($ACT == 'search') print 'value="'.htmlspecialchars($_REQUEST['id']).'" ';
49272645b75SAndreas Gohr  if(!$autocomplete) print 'autocomplete="off" ';
49324a33b42SAndreas Gohr  print 'id="qsearch__in" accesskey="f" name="id" class="edit" />';
4946b13307fSandi  print '<input type="submit" value="'.$lang['btn_search'].'" class="button" />';
49524a33b42SAndreas Gohr  if($ajax) print '<div id="qsearch__out" class="ajax_qsearch JSpopup"></div>';
4964beabca9SAnika Henke  print '</div></form>';
4976b13307fSandi}
4986b13307fSandi
4996b13307fSandi/**
5006b13307fSandi * Print the breadcrumbs trace
5016b13307fSandi *
5026b13307fSandi * @author Andreas Gohr <andi@splitbrain.org>
5036b13307fSandi */
5046b13307fSandifunction tpl_breadcrumbs(){
5056b13307fSandi  global $lang;
5066b13307fSandi  global $conf;
5076b13307fSandi
5086b13307fSandi  //check if enabled
5096b13307fSandi  if(!$conf['breadcrumbs']) return;
5106b13307fSandi
5116b13307fSandi  $crumbs = breadcrumbs(); //setup crumb trace
512265e3787Sandi
513265e3787Sandi  //reverse crumborder in right-to-left mode
514265e3787Sandi  if($lang['direction'] == 'rtl') $crumbs = array_reverse($crumbs,true);
515265e3787Sandi
51640eb54bbSjan  //render crumbs, highlight the last one
5176b13307fSandi  print $lang['breadcrumb'].':';
51840eb54bbSjan  $last = count($crumbs);
51940eb54bbSjan  $i = 0;
520a77f5846Sjan  foreach ($crumbs as $id => $name){
52140eb54bbSjan    $i++;
522265e3787Sandi    print ' <span class="bcsep">&raquo;</span> ';
52392795d04Sandi    if ($i == $last) print '<span class="curid">';
524a77f5846Sjan    tpl_link(wl($id),$name,'class="breadcrumbs" title="'.$id.'"');
52592795d04Sandi    if ($i == $last) print '</span>';
5266b13307fSandi  }
5276b13307fSandi}
5286b13307fSandi
5296b13307fSandi/**
5301734437eSandi * Hierarchical breadcrumbs
5311734437eSandi *
53231e187f8SSean Coates * This code was suggested as replacement for the usual breadcrumbs.
5331734437eSandi * It only makes sense with a deep site structure.
5341734437eSandi *
5351734437eSandi * @author Andreas Gohr <andi@splitbrain.org>
5366bd812dfSNigel McNie * @author Nigel McNie <oracle.shinoda@gmail.com>
53731e187f8SSean Coates * @author Sean Coates <sean@caedmon.net>
5381734437eSandi * @link   http://wiki.splitbrain.org/wiki:tipsandtricks:hierarchicalbreadcrumbs
5396bd812dfSNigel McNie * @todo   May behave strangely in RTL languages
5401734437eSandi */
541796bafb3SAndreas Gohrfunction tpl_youarehere($sep=' &raquo; '){
5421734437eSandi  global $conf;
5431734437eSandi  global $ID;
5441734437eSandi  global $lang;
5451734437eSandi
54631e187f8SSean Coates  // check if enabled
54731e187f8SSean Coates  if(!$conf['youarehere']) return;
5481734437eSandi
5491734437eSandi  $parts = explode(':', $ID);
550796bafb3SAndreas Gohr  $count = count($parts);
5511734437eSandi
552796bafb3SAndreas Gohr  echo $lang['youarehere'].': ';
5531734437eSandi
5541734437eSandi  // always print the startpage
555796bafb3SAndreas Gohr  $title = p_get_first_heading($conf['start']);
556796bafb3SAndreas Gohr  if(!$title) $title = $conf['start'];
557796bafb3SAndreas Gohr  tpl_link(wl($conf['start']),$title,'title="'.$conf['start'].'"');
558796bafb3SAndreas Gohr
559796bafb3SAndreas Gohr  // print intermediate namespace links
560796bafb3SAndreas Gohr  $part = '';
561796bafb3SAndreas Gohr  for($i=0; $i<$count - 1; $i++){
562796bafb3SAndreas Gohr    $part .= $parts[$i].':';
563796bafb3SAndreas Gohr    $page = $part;
564796bafb3SAndreas Gohr    resolve_pageid('',$page,$exists);
565796bafb3SAndreas Gohr    if ($page == $conf['start']) continue; // Skip startpage
566796bafb3SAndreas Gohr
567796bafb3SAndreas Gohr    // output
568796bafb3SAndreas Gohr    echo $sep;
569796bafb3SAndreas Gohr    if($exists){
570796bafb3SAndreas Gohr      $title = p_get_first_heading($page);
571796bafb3SAndreas Gohr      if(!$title) $title = $parts[$i];
572796bafb3SAndreas Gohr      tpl_link(wl($page),$title,'title="'.$page.'"');
57331e187f8SSean Coates    }else{
574796bafb3SAndreas Gohr      tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2"');
57531e187f8SSean Coates    }
57631e187f8SSean Coates  }
5771734437eSandi
578796bafb3SAndreas Gohr  // print current page, skipping start page, skipping for namespace index
579796bafb3SAndreas Gohr  if($page == $part.$parts[$i]) return;
580796bafb3SAndreas Gohr  $page = $part.$parts[$i];
581796bafb3SAndreas Gohr  if($page == $conf['start']) return;
582796bafb3SAndreas Gohr  echo $sep;
5831734437eSandi  if(file_exists(wikiFN($page))){
584796bafb3SAndreas Gohr    $title = p_get_first_heading($page);
585796bafb3SAndreas Gohr    if(!$title) $title = $parts[$i];
586796bafb3SAndreas Gohr    tpl_link(wl($page),$title,'title="'.$page.'"');
58731e187f8SSean Coates  }else{
588796bafb3SAndreas Gohr    tpl_link(wl($page),$parts[$i],'title="'.$page.'" class="wikilink2"');
5891734437eSandi  }
5901734437eSandi}
5911734437eSandi
5921734437eSandi/**
5936b13307fSandi * Print info if the user is logged in
594a2488c3cSMatthias Grimm * and show full name in that case
5956b13307fSandi *
5966b13307fSandi * Could be enhanced with a profile link in future?
5976b13307fSandi *
5986b13307fSandi * @author Andreas Gohr <andi@splitbrain.org>
5996b13307fSandi */
6006b13307fSandifunction tpl_userinfo(){
6016b13307fSandi  global $lang;
602a2488c3cSMatthias Grimm  global $INFO;
6036b13307fSandi  if($_SERVER['REMOTE_USER'])
604a2488c3cSMatthias Grimm    print $lang['loggedinas'].': '.$INFO['userinfo']['name'];
6056b13307fSandi}
6066b13307fSandi
6076b13307fSandi/**
6086b13307fSandi * Print some info about the current page
6096b13307fSandi *
6106b13307fSandi * @author Andreas Gohr <andi@splitbrain.org>
6116b13307fSandi */
6126b13307fSandifunction tpl_pageinfo(){
6136b13307fSandi  global $conf;
6146b13307fSandi  global $lang;
6156b13307fSandi  global $INFO;
6166b13307fSandi  global $REV;
6176b13307fSandi
6186b13307fSandi  // prepare date and path
6196b13307fSandi  $fn = $INFO['filepath'];
6206b13307fSandi  if(!$conf['fullpath']){
6216b13307fSandi    if($REV){
6226b13307fSandi      $fn = str_replace(realpath($conf['olddir']).DIRECTORY_SEPARATOR,'',$fn);
6236b13307fSandi    }else{
6246b13307fSandi      $fn = str_replace(realpath($conf['datadir']).DIRECTORY_SEPARATOR,'',$fn);
6256b13307fSandi    }
6266b13307fSandi  }
627bee6dc82Sandi  $fn = utf8_decodeFN($fn);
6286b13307fSandi  $date = date($conf['dformat'],$INFO['lastmod']);
6296b13307fSandi
6306b13307fSandi  // print it
6316b13307fSandi  if($INFO['exists']){
6326b13307fSandi    print $fn;
6336b13307fSandi    print ' &middot; ';
6346b13307fSandi    print $lang['lastmod'];
6356b13307fSandi    print ': ';
6366b13307fSandi    print $date;
6376b13307fSandi    if($INFO['editor']){
6386b13307fSandi      print ' '.$lang['by'].' ';
6396b13307fSandi      print $INFO['editor'];
6406b13307fSandi    }
6416b13307fSandi    if($INFO['locked']){
6426b13307fSandi      print ' &middot; ';
6436b13307fSandi      print $lang['lockedby'];
6446b13307fSandi      print ': ';
6456b13307fSandi      print $INFO['locked'];
6466b13307fSandi    }
6476b13307fSandi  }
6486b13307fSandi}
6496b13307fSandi
650820fa24bSandi/**
651a6598f23SBen Coburn * Prints or returns the name of the given page (current one if none given).
65287c434ceSAndreas Gohr *
65387c434ceSAndreas Gohr * If useheading is enabled this will use the first headline else
654a6598f23SBen Coburn * the given ID is used.
65587c434ceSAndreas Gohr *
65687c434ceSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
65787c434ceSAndreas Gohr */
658a6598f23SBen Coburnfunction tpl_pagetitle($id=null, $ret=false){
65987c434ceSAndreas Gohr  global $conf;
66087c434ceSAndreas Gohr  if(is_null($id)){
66187c434ceSAndreas Gohr    global $ID;
66287c434ceSAndreas Gohr    $id = $ID;
66387c434ceSAndreas Gohr  }
66487c434ceSAndreas Gohr
66587c434ceSAndreas Gohr  $name = $id;
66687c434ceSAndreas Gohr  if ($conf['useheading']) {
66787c434ceSAndreas Gohr    $title = p_get_first_heading($id);
66887c434ceSAndreas Gohr    if ($title) $name = $title;
66987c434ceSAndreas Gohr  }
670a6598f23SBen Coburn
671a6598f23SBen Coburn  if ($ret) {
672a6598f23SBen Coburn      return hsc($name);
673a6598f23SBen Coburn  } else {
67487c434ceSAndreas Gohr      print hsc($name);
67587c434ceSAndreas Gohr  }
676a6598f23SBen Coburn}
677340756e4Sandi
67855efc227SAndreas Gohr/**
67955efc227SAndreas Gohr * Returns the requested EXIF/IPTC tag from the current image
68055efc227SAndreas Gohr *
68155efc227SAndreas Gohr * If $tags is an array all given tags are tried until a
68255efc227SAndreas Gohr * value is found. If no value is found $alt is returned.
68355efc227SAndreas Gohr *
68455efc227SAndreas Gohr * Which texts are known is defined in the functions _exifTagNames
68555efc227SAndreas Gohr * and _iptcTagNames() in inc/jpeg.php (You need to prepend IPTC
68655efc227SAndreas Gohr * to the names of the latter one)
68755efc227SAndreas Gohr *
6883df72098SAndreas Gohr * Only allowed in: detail.php
68955efc227SAndreas Gohr *
69055efc227SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
69155efc227SAndreas Gohr */
6923df72098SAndreas Gohrfunction tpl_img_getTag($tags,$alt='',$src=null){
69355efc227SAndreas Gohr  // Init Exif Reader
69455efc227SAndreas Gohr  global $SRC;
6953df72098SAndreas Gohr
6963df72098SAndreas Gohr  if(is_null($src)) $src = $SRC;
6973df72098SAndreas Gohr
69855efc227SAndreas Gohr  static $meta = null;
6993df72098SAndreas Gohr  if(is_null($meta)) $meta = new JpegMeta($src);
70055efc227SAndreas Gohr  if($meta === false) return $alt;
70155efc227SAndreas Gohr  $info = $meta->getField($tags);
70255efc227SAndreas Gohr  if($info == false) return $alt;
70355efc227SAndreas Gohr  return $info;
70455efc227SAndreas Gohr}
70555efc227SAndreas Gohr
70655efc227SAndreas Gohr/**
70755efc227SAndreas Gohr * Prints the image with a link to the full sized version
70855efc227SAndreas Gohr *
70955efc227SAndreas Gohr * Only allowed in: detail.php
71055efc227SAndreas Gohr */
711f8925855Sjoe.lappfunction tpl_img($maxwidth=0,$maxheight=0){
71255efc227SAndreas Gohr  global $IMG;
71355efc227SAndreas Gohr  $w = tpl_img_getTag('File.Width');
71455efc227SAndreas Gohr  $h = tpl_img_getTag('File.Height');
71555efc227SAndreas Gohr
71655efc227SAndreas Gohr  //resize to given max values
71723a34783SAndreas Gohr  $ratio = 1;
71823a34783SAndreas Gohr  if($w >= $h){
719f8925855Sjoe.lapp    if($maxwidth && $w >= $maxwidth){
72055efc227SAndreas Gohr      $ratio = $maxwidth/$w;
721f8925855Sjoe.lapp    }elseif($maxheight && $h > $maxheight){
72255efc227SAndreas Gohr      $ratio = $maxheight/$h;
72355efc227SAndreas Gohr    }
72455efc227SAndreas Gohr  }else{
725f8925855Sjoe.lapp    if($maxheight && $h >= $maxheight){
72655efc227SAndreas Gohr      $ratio = $maxheight/$h;
727f8925855Sjoe.lapp    }elseif($maxwidth && $w > $maxwidth){
72855efc227SAndreas Gohr      $ratio = $maxwidth/$w;
72955efc227SAndreas Gohr    }
73055efc227SAndreas Gohr  }
73155efc227SAndreas Gohr  if($ratio){
73255efc227SAndreas Gohr    $w = floor($ratio*$w);
73355efc227SAndreas Gohr    $h = floor($ratio*$h);
73455efc227SAndreas Gohr  }
73555efc227SAndreas Gohr
7366de3759aSAndreas Gohr  //prepare URLs
7376de3759aSAndreas Gohr  $url=ml($IMG,array('cache'=>$_REQUEST['cache']));
7386de3759aSAndreas Gohr  $src=ml($IMG,array('cache'=>$_REQUEST['cache'],'w'=>$w,'h'=>$h));
73955efc227SAndreas Gohr
7402684e50aSAndreas Gohr  //prepare attributes
74155efc227SAndreas Gohr  $alt=tpl_img_getTag('Simple.Title');
7422684e50aSAndreas Gohr  $p = array();
7432684e50aSAndreas Gohr  if($w) $p['width']  = $w;
7442684e50aSAndreas Gohr  if($h) $p['height'] = $h;
7452684e50aSAndreas Gohr         $p['class']  = 'img_detail';
7462684e50aSAndreas Gohr  if($alt){
7472684e50aSAndreas Gohr    $p['alt']   = $alt;
7482684e50aSAndreas Gohr    $p['title'] = $alt;
7492684e50aSAndreas Gohr  }else{
7502684e50aSAndreas Gohr    $p['alt'] = '';
7512684e50aSAndreas Gohr  }
7522684e50aSAndreas Gohr  $p = buildAttributes($p);
75355efc227SAndreas Gohr
75455efc227SAndreas Gohr  print '<a href="'.$url.'">';
7556de3759aSAndreas Gohr  print '<img src="'.$src.'" '.$p.'/>';
75655efc227SAndreas Gohr  print '</a>';
75755efc227SAndreas Gohr}
75855efc227SAndreas Gohr
7597367b368SAndreas Gohr/**
7607367b368SAndreas Gohr * This function inserts a 1x1 pixel gif which in reality
7617367b368SAndreas Gohr * is the inexer function.
7627367b368SAndreas Gohr *
7637367b368SAndreas Gohr * Should be called somewhere at the very end of the main.php
7647367b368SAndreas Gohr * template
7657367b368SAndreas Gohr */
7667367b368SAndreas Gohrfunction tpl_indexerWebBug(){
7677367b368SAndreas Gohr  global $ID;
7681dad36f5SAndreas Gohr  global $INFO;
7691dad36f5SAndreas Gohr  if(!$INFO['exists']) return;
7701dad36f5SAndreas Gohr
7710dc92c6fSAndreas Gohr  if(isHiddenPage($ID)) return; //no need to index hidden pages
7720dc92c6fSAndreas Gohr
7737367b368SAndreas Gohr  $p = array();
774b6c6979fSAndreas Gohr  $p['src']    = DOKU_BASE.'lib/exe/indexer.php?id='.rawurlencode($ID).
775e68c51baSAndreas Gohr                 '&'.time();
7767367b368SAndreas Gohr  $p['width']  = 1;
7777367b368SAndreas Gohr  $p['height'] = 1;
7787367b368SAndreas Gohr  $p['alt']    = '';
7797367b368SAndreas Gohr  $att = buildAttributes($p);
7807367b368SAndreas Gohr  print "<img $att />";
7817367b368SAndreas Gohr}
7827367b368SAndreas Gohr
78378d4e784SEsther Brunner// configuration methods
78478d4e784SEsther Brunner/**
78578d4e784SEsther Brunner * tpl_getConf($id)
78678d4e784SEsther Brunner *
78778d4e784SEsther Brunner * use this function to access template configuration variables
78878d4e784SEsther Brunner */
78978d4e784SEsther Brunnerfunction tpl_getConf($id){
79078d4e784SEsther Brunner  global $conf;
79178d4e784SEsther Brunner  global $tpl_configloaded;
79278d4e784SEsther Brunner
79378d4e784SEsther Brunner  $tpl = $conf['template'];
79478d4e784SEsther Brunner
79578d4e784SEsther Brunner  if (!$tpl_configloaded){
79678d4e784SEsther Brunner    $tconf = tpl_loadConfig();
79778d4e784SEsther Brunner    if ($tconf !== false){
79878d4e784SEsther Brunner      foreach ($tconf as $key => $value){
79978d4e784SEsther Brunner        if (isset($conf['tpl'][$tpl][$key])) continue;
80078d4e784SEsther Brunner        $conf['tpl'][$tpl][$key] = $value;
80178d4e784SEsther Brunner      }
80278d4e784SEsther Brunner      $tpl_configloaded = true;
80378d4e784SEsther Brunner    }
80478d4e784SEsther Brunner  }
80578d4e784SEsther Brunner
80678d4e784SEsther Brunner  return $conf['tpl'][$tpl][$id];
80778d4e784SEsther Brunner}
80878d4e784SEsther Brunner
80978d4e784SEsther Brunner/**
81078d4e784SEsther Brunner * tpl_loadConfig()
81178d4e784SEsther Brunner * reads all template configuration variables
81278d4e784SEsther Brunner * this function is automatically called by tpl_getConf()
81378d4e784SEsther Brunner */
81478d4e784SEsther Brunnerfunction tpl_loadConfig(){
81578d4e784SEsther Brunner
81678d4e784SEsther Brunner  $file = DOKU_TPLINC.'/conf/default.php';
81778d4e784SEsther Brunner  $conf = array();
81878d4e784SEsther Brunner
81978d4e784SEsther Brunner  if (!@file_exists($file)) return false;
82078d4e784SEsther Brunner
82178d4e784SEsther Brunner  // load default config file
82278d4e784SEsther Brunner  include($file);
82378d4e784SEsther Brunner
82478d4e784SEsther Brunner  return $conf;
82578d4e784SEsther Brunner}
82678d4e784SEsther Brunner
8273df72098SAndreas Gohr/**
8283df72098SAndreas Gohr * prints the "main content" in the mediamanger popup
8293df72098SAndreas Gohr *
8303df72098SAndreas Gohr * Depending on the user's actions this may be a list of
8313df72098SAndreas Gohr * files in a namespace, the meta editing dialog or
8323df72098SAndreas Gohr * a message of referencing pages
8333df72098SAndreas Gohr *
8343df72098SAndreas Gohr * Only allowed in mediamanager.php
8353df72098SAndreas Gohr *
8363df72098SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
8373df72098SAndreas Gohr */
8383df72098SAndreas Gohrfunction tpl_mediaContent(){
8393df72098SAndreas Gohr  global $IMG;
8403df72098SAndreas Gohr  global $AUTH;
8413df72098SAndreas Gohr  global $INUSE;
8423df72098SAndreas Gohr  global $NS;
8433df72098SAndreas Gohr  global $JUMPTO;
8443df72098SAndreas Gohr
8453df72098SAndreas Gohr  ptln('<div id="media__content">');
8463df72098SAndreas Gohr  if($_REQUEST['edit']){
8473df72098SAndreas Gohr    media_metaform($IMG,$AUTH);
8487b877f51SAndreas Gohr  }elseif(is_array($INUSE)){
8493df72098SAndreas Gohr    media_filesinuse($INUSE,$IMG);
8503df72098SAndreas Gohr  }else{
8513df72098SAndreas Gohr    media_filelist($NS,$AUTH,$JUMPTO);
8523df72098SAndreas Gohr  }
8533df72098SAndreas Gohr  ptln('</div>');
8543df72098SAndreas Gohr}
8553df72098SAndreas Gohr
8563df72098SAndreas Gohr/**
8573df72098SAndreas Gohr * prints the namespace tree in the mediamanger popup
8583df72098SAndreas Gohr *
8593df72098SAndreas Gohr * Only allowed in mediamanager.php
8603df72098SAndreas Gohr *
8613df72098SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
8623df72098SAndreas Gohr */
8633df72098SAndreas Gohrfunction tpl_mediaTree(){
8643df72098SAndreas Gohr  global $NS;
8653df72098SAndreas Gohr
8663df72098SAndreas Gohr  ptln('<div id="media__tree">');
8673df72098SAndreas Gohr  media_nstree($NS);
8683df72098SAndreas Gohr  ptln('</div>');
8693df72098SAndreas Gohr}
8703df72098SAndreas Gohr
871340756e4Sandi//Setup VIM: ex: et ts=2 enc=utf-8 :
872