/** * Places the TOC where the function is called * * If you use this you most probably want to call tpl_content with * a false argument * * @author Andreas Gohr <*****@*****.**> * * @param bool $return Should the TOC be returned instead to be printed? * @return string */ function tpl_toc($return = false) { global $TOC; global $ACT; global $ID; global $REV; global $INFO; global $conf; global $INPUT; $toc = array(); if (is_array($TOC)) { // if a TOC was prepared in global scope, always use it $toc = $TOC; } elseif (($ACT == 'show' || substr($ACT, 0, 6) == 'export') && !$REV && $INFO['exists']) { // get TOC from metadata, render if neccessary $meta = p_get_metadata($ID, '', METADATA_RENDER_USING_CACHE); if (isset($meta['internal']['toc'])) { $tocok = $meta['internal']['toc']; } else { $tocok = true; } $toc = isset($meta['description']['tableofcontents']) ? $meta['description']['tableofcontents'] : null; if (!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']) { $toc = array(); } } elseif ($ACT == 'admin') { // try to load admin plugin TOC /** @var $plugin DokuWiki_Admin_Plugin */ if ($plugin = plugin_getRequestAdminPlugin()) { $toc = $plugin->getTOC(); $TOC = $toc; // avoid later rebuild } } trigger_event('TPL_TOC_RENDER', $toc, null, false); $html = html_TOC($toc); if ($return) { return $html; } echo $html; return ''; }
/** * Places the TOC where the function is called * * If you use this you most probably want to call tpl_content with * a false argument * * @author Andreas Gohr <*****@*****.**> * @param bool $return Should the TOC be returned instead to be printed? * @return string */ function tpl_toc($return = false) { global $TOC; global $ACT; global $ID; global $REV; global $INFO; global $conf; global $INPUT; $toc = array(); if (is_array($TOC)) { // if a TOC was prepared in global scope, always use it $toc = $TOC; } elseif (($ACT == 'show' || substr($ACT, 0, 6) == 'export') && !$REV && $INFO['exists']) { // get TOC from metadata, render if neccessary $meta = p_get_metadata($ID, false, METADATA_RENDER_USING_CACHE); if (isset($meta['internal']['toc'])) { $tocok = $meta['internal']['toc']; } else { $tocok = true; } $toc = $meta['description']['tableofcontents']; if (!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']) { $toc = array(); } } elseif ($ACT == 'admin') { // try to load admin plugin TOC FIXME: duplicates code from tpl_admin $plugin = null; $class = $INPUT->str('page'); if (!empty($class)) { $pluginlist = plugin_list('admin'); if (in_array($class, $pluginlist)) { // attempt to load the plugin /** @var $plugin DokuWiki_Admin_Plugin */ $plugin =& plugin_load('admin', $class); } } if ($plugin !== null && (!$plugin->forAdminOnly() || $INFO['isadmin'])) { $toc = $plugin->getTOC(); $TOC = $toc; // avoid later rebuild } } trigger_event('TPL_TOC_RENDER', $toc, null, false); $html = html_TOC($toc); if ($return) { return $html; } echo $html; return ''; }
/** * Places the TOC where the function is called * * If you use this you most probably want to call tpl_content with * a false argument * * @author Andreas Gohr <*****@*****.**> */ function tpl_toc($return = false) { global $TOC; global $ACT; global $ID; global $REV; global $INFO; $toc = array(); if (is_array($TOC)) { // if a TOC was prepared in global scope, always use it $toc = $TOC; } elseif (($ACT == 'show' || substr($ACT, 0, 6) == 'export') && !$REV && $INFO['exists']) { // get TOC from metadata, render if neccessary $meta = p_get_metadata($ID, false, true); if (isset($meta['internal']['toc'])) { $tocok = $meta['internal']['toc']; } else { $tocok = true; } $toc = $meta['description']['tableofcontents']; if (!$tocok || !is_array($toc) || count($toc) < 3) { $toc = array(); } } elseif ($ACT == 'admin') { // try to load admin plugin TOC FIXME: duplicates code from tpl_admin $plugin = null; if (!empty($_REQUEST['page'])) { $pluginlist = plugin_list('admin'); if (in_array($_REQUEST['page'], $pluginlist)) { // attempt to load the plugin $plugin =& plugin_load('admin', $_REQUEST['page']); } } if ($plugin !== null && (!$plugin->forAdminOnly() || $INFO['isadmin'])) { $toc = $plugin->getTOC(); $TOC = $toc; // avoid later rebuild } } $html = html_TOC($toc); if ($return) { return $html; } echo $html; }