/** * 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 <*****@*****.**> * @author Giuseppe Di Terlizzi <*****@*****.**> * * @param bool $return Should the TOC be returned instead to be printed? * @return string */ function bootstrap3_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); if ($ACT == 'admin' && $INPUT->str('page') == 'config') { $bootstrap3_sections = array('theme', 'sidebar', 'navbar', 'semantic', 'layout', 'toc', 'discussion', 'cookie_law', 'google_analytics', 'browser_title', 'page'); foreach ($bootstrap3_sections as $id) { $toc[] = array('link' => "#bootstrap3__{$id}", 'title' => tpl_getLang("config_{$id}"), 'type' => 'ul', 'level' => 3); } } $html = bootstrap3_html_toc($toc); if ($return) { return $html; } echo $html; return ''; }
/** * Prints or returns the name of the given page (current one if none given). * * If useheading is enabled this will use the first headline else * the given ID is used. * * @author Andreas Gohr <*****@*****.**> * * @param string $id page id * @param bool $ret return content instead of printing * @return bool|string */ function tpl_pagetitle($id = null, $ret = false) { global $ACT, $INPUT, $conf, $lang; if (is_null($id)) { global $ID; $id = $ID; } $name = $id; if (useHeading('navigation')) { $first_heading = p_get_first_heading($id); if ($first_heading) { $name = $first_heading; } } // default page title is the page name, modify with the current action switch ($ACT) { // admin functions case 'admin': $page_title = $lang['btn_admin']; // try to get the plugin name /** @var $plugin DokuWiki_Admin_Plugin */ if ($plugin = plugin_getRequestAdminPlugin()) { $plugin_title = $plugin->getMenuText($conf['lang']); $page_title = $plugin_title ? $plugin_title : $plugin->getPluginName(); } break; // user functions // user functions case 'login': case 'profile': case 'register': case 'resendpwd': $page_title = $lang['btn_' . $ACT]; break; // wiki functions // wiki functions case 'search': case 'index': $page_title = $lang['btn_' . $ACT]; break; // page functions // page functions case 'edit': $page_title = "✎ " . $name; break; case 'revisions': $page_title = $name . ' - ' . $lang['btn_revs']; break; case 'backlink': case 'recent': case 'subscribe': $page_title = $name . ' - ' . $lang['btn_' . $ACT]; break; default: // SHOW and anything else not included $page_title = $name; } if ($ret) { return hsc($page_title); } else { print hsc($page_title); return true; } }
/** * Call the needed action handlers * * @author Andreas Gohr <*****@*****.**> * @triggers ACTION_ACT_PREPROCESS * @triggers ACTION_HEADERS_SEND */ function act_dispatch() { global $ACT; global $ID; global $INFO; global $QUERY; /* @var Input $INPUT */ global $INPUT; global $lang; global $conf; $preact = $ACT; // give plugins an opportunity to process the action $evt = new Doku_Event('ACTION_ACT_PREPROCESS', $ACT); $headers = array(); if ($evt->advise_before()) { //sanitize $ACT $ACT = act_validate($ACT); //check if searchword was given - else just show $s = cleanID($QUERY); if ($ACT == 'search' && empty($s)) { $ACT = 'show'; } //login stuff if (in_array($ACT, array('login', 'logout'))) { $ACT = act_auth($ACT); } //check if user is asking to (un)subscribe a page if ($ACT == 'subscribe') { try { $ACT = act_subscription($ACT); } catch (Exception $e) { msg($e->getMessage(), -1); } } //display some info if ($ACT == 'check') { check(); $ACT = 'show'; } //check permissions $ACT = act_permcheck($ACT); //sitemap if ($ACT == 'sitemap') { act_sitemap($ACT); } //recent changes if ($ACT == 'recent') { $show_changes = $INPUT->str('show_changes'); if (!empty($show_changes)) { set_doku_pref('show_changes', $show_changes); } } //diff if ($ACT == 'diff') { $difftype = $INPUT->str('difftype'); if (!empty($difftype)) { set_doku_pref('difftype', $difftype); } } //register if ($ACT == 'register' && $INPUT->post->bool('save') && register()) { $ACT = 'login'; } if ($ACT == 'resendpwd' && act_resendpwd()) { $ACT = 'login'; } // user profile changes if (in_array($ACT, array('profile', 'profile_delete'))) { if (!$INPUT->server->str('REMOTE_USER')) { $ACT = 'login'; } else { switch ($ACT) { case 'profile': if (updateprofile()) { msg($lang['profchanged'], 1); $ACT = 'show'; } break; case 'profile_delete': if (auth_deleteprofile()) { msg($lang['profdeleted'], 1); $ACT = 'show'; } else { $ACT = 'profile'; } break; } } } //revert if ($ACT == 'revert') { if (checkSecurityToken()) { $ACT = act_revert($ACT); } else { $ACT = 'show'; } } //save if ($ACT == 'save') { if (checkSecurityToken()) { $ACT = act_save($ACT); } else { $ACT = 'preview'; } } //cancel conflicting edit if ($ACT == 'cancel') { $ACT = 'show'; } //draft deletion if ($ACT == 'draftdel') { $ACT = act_draftdel($ACT); } //draft saving on preview if ($ACT == 'preview') { $headers[] = "X-XSS-Protection: 0"; $ACT = act_draftsave($ACT); } //edit if (in_array($ACT, array('edit', 'preview', 'recover'))) { $ACT = act_edit($ACT); } else { unlock($ID); //try to unlock } //handle export if (substr($ACT, 0, 7) == 'export_') { $ACT = act_export($ACT); } //handle admin tasks if ($ACT == 'admin') { // retrieve admin plugin name from $_REQUEST['page'] if (($page = $INPUT->str('page', '', true)) != '') { /** @var $plugin DokuWiki_Admin_Plugin */ if ($plugin = plugin_getRequestAdminPlugin()) { $plugin->handle(); } } } // check permissions again - the action may have changed $ACT = act_permcheck($ACT); } // end event ACTION_ACT_PREPROCESS default action $evt->advise_after(); // Make sure plugs can handle 'denied' if ($conf['send404'] && $ACT == 'denied') { http_status(403); } unset($evt); // when action 'show', the intial not 'show' and POST, do a redirect if ($ACT == 'show' && $preact != 'show' && strtolower($INPUT->server->str('REQUEST_METHOD')) == 'post') { act_redirect($ID, $preact); } global $INFO; global $conf; global $license; //call template FIXME: all needed vars available? $headers[] = 'Content-Type: text/html; charset=utf-8'; trigger_event('ACTION_HEADERS_SEND', $headers, 'act_sendheaders'); include template('main.php'); // output for the commands is now handled in inc/templates.php // in function tpl_content() }