/** * Get template from session and/or user config * * @author Anika Henke <*****@*****.**> */ private function _getTplPerUser() { // get all available templates $helper = $this->loadHelper('loadskin', true); $tpls = $helper->getTemplates(); $mobileSwitch = $this->getConf('mobileSwitch'); $user = $_SERVER['REMOTE_USER']; $tplRequest = $_REQUEST['tpl']; $actSelect = $_REQUEST['act'] && $_REQUEST['act'] == 'select'; // if template switcher was used if ($tplRequest && $actSelect && (in_array($tplRequest, $tpls) || $tplRequest == '*')) { // hidden way of deleting the cookie and config values if ($tplRequest == '*') { $tplRequest = false; } // not backwards-compatible, will only work with core PR #1129 // store in cookie set_doku_pref('loadskinTpl', $tplRequest); // if registered user, store also in conf file (not for mobile switcher) if ($user && !$mobileSwitch) { $this->_tplUserConfig('set', $user, $tplRequest); } return $tplRequest; } $tplUser = $this->_tplUserConfig('get', $user); // from user conf file $tplCookie = get_doku_pref('loadskinTpl', ''); // if logged in and user is in conf (not for mobile) if ($user && $tplUser && in_array($tplUser, $tpls) && !$mobileSwitch) { if ($tplCookie && $tplCookie == $tplUser) { return $tplCookie; } // store in cookie set_doku_pref('loadskinTpl', $tplUser); return $tplUser; } // if template is stored in cookie if ($tplCookie && in_array($tplCookie, $tpls)) { return $tplCookie; } // if viewed on a mobile and mobile switcher is used, set mobile template as default global $INFO; $mobileTpl = $this->getConf('mobileTemplate'); if ($mobileTpl && $INFO['ismobile']) { set_doku_pref('loadskinTpl', $mobileTpl); return $mobileTpl; } return false; }
/** * Return (and set via cookie) the current Bootswatch theme * * @author Giuseppe Di Terlizzi <*****@*****.**> * * @return string */ function bootstrap3_bootswatch_theme() { global $INPUT; $bootswatch_theme = bootstrap3_conf('bootswatchTheme'); if (bootstrap3_conf('showThemeSwitcher')) { if (get_doku_pref('bootswatchTheme', null) !== null && get_doku_pref('bootswatchTheme', null) !== '') { $bootswatch_theme = get_doku_pref('bootswatchTheme', null); } if ($INPUT->str('bootswatch-theme')) { $bootswatch_theme = $INPUT->str('bootswatch-theme'); set_doku_pref('bootswatchTheme', $bootswatch_theme); } } return $bootswatch_theme; }
function logOff() { set_doku_pref('adfs_autologin', 0); }
if ($fluidContainerBtn) { $fluidContainer = bootstrap3_fluid_container_button(); } // Display a landing page (set the pageOnPanel and showSidebar config to "off") if ($showLandingPage && (bool) preg_match_all(bootstrap3_conf('landingPages'), $ID)) { $showSidebar = false; $pageOnPanel = false; } if ($showThemeSwitcher && $bootstrapTheme == 'bootswatch') { if (get_doku_pref('bootswatchTheme', null) !== null && get_doku_pref('bootswatchTheme', null) !== '') { $bootswatchTheme = get_doku_pref('bootswatchTheme', null); } global $INPUT; if ($INPUT->str('bootswatchTheme')) { $bootswatchTheme = $INPUT->str('bootswatchTheme'); set_doku_pref('bootswatchTheme', $bootswatchTheme); } } switch ($bootstrapTheme) { case 'optional': $bootstrapStyles[] = DOKU_TPL . 'assets/bootstrap/css/bootstrap.min.css'; $bootstrapStyles[] = DOKU_TPL . 'assets/bootstrap/css/bootstrap-theme.min.css'; break; case 'custom': $bootstrapStyles[] = $customTheme; break; case 'bootswatch': $url = $useLocalBootswatch ? DOKU_TPL . 'assets/bootswatch' : '//maxcdn.bootstrapcdn.com/bootswatch/3.3.6'; $bootstrapStyles[] = "{$url}/{$bootswatchTheme}/bootstrap.min.css"; break; case 'default':
/** * 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() }
/** * Hook Callback. Change the UI language in foreign language namespaces */ function translation_hook(&$event, $args) { global $ID; global $lang; global $conf; global $ACT; // try to load language from session/cookie - stick to language selected by the user previously if (!empty($_SESSION[DOKU_COOKIE]['translationlc'])) { $lc = $_SESSION[DOKU_COOKIE]['translationlc']; } else { if (!empty(get_doku_pref('plugin_translation_lc', null))) { $lc = get_doku_pref('plugin_translation_lc', null); } } // redirect away from start page? if (empty($lc) && $this->conf['redirectstart'] && $ID == $conf['start'] && $ACT == 'show') { $lc = $this->helper->getBrowserLang($conf['lang']); if (!$lc) { $lc = $conf['lang']; } if ($lc != $conf['lang']) { $_SESSION[DOKU_COOKIE]['translationlc'] = $lc; set_doku_pref('plugin_translation_lc', $lc); header('Location: ' . wl($lc . ':' . $conf['start'], '', true, '&')); exit; } } // check if we are in a foreign language namespace $newLc = $this->helper->getLangPart($ID); if (empty($newLc)) { $lc = $conf['lang']; } else { if ($newLc != $lc) { $lc = $newLc; } } // store language in session (for page related views only) if (in_array($ACT, array('show', 'recent', 'diff', 'edit', 'preview', 'source', 'subscribe'))) { $_SESSION[DOKU_COOKIE]['translationlc'] = $lc; set_doku_pref('plugin_translation_lc', $lc); } // stop. no effort is needed if ($lc == $conf['lang']) { return; } // adjust environment to the selected language $this->locale = $lc; if (!$this->getConf('translateui')) { return true; } if (file_exists(DOKU_INC . 'inc/lang/' . $lc . '/lang.php')) { require DOKU_INC . 'inc/lang/' . $lc . '/lang.php'; } $conf['lang_before_translation'] = $conf['lang']; //store for later access in syntax plugin $conf['lang'] = $lc; return true; }