From 5fc6f52e0a12f737afab24869c01076585fdcc69 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Mon, 4 May 2015 19:30:30 +0100 Subject: cache JavaScript per template --- inc/template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index 88b6b14b8..d6436e416 100644 --- a/inc/template.php +++ b/inc/template.php @@ -417,7 +417,7 @@ function tpl_metaheaders($alt = true) { // load external javascript $head['script'][] = array( 'type'=> 'text/javascript', 'charset'=> 'utf-8', '_data'=> '', - 'src' => DOKU_BASE.'lib/exe/js.php'.'?tseed='.$tseed + 'src' => DOKU_BASE.'lib/exe/js.php'.'?t='.$conf['template'].'&tseed='.$tseed ); // trigger event here -- cgit v1.2.3 From e283bd6c307c6538f4d5447a938266b5e414c159 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Fri, 8 May 2015 11:32:48 +0100 Subject: urlencode t param value in css and js calls --- inc/template.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index d6436e416..3859065bc 100644 --- a/inc/template.php +++ b/inc/template.php @@ -402,7 +402,7 @@ function tpl_metaheaders($alt = true) { // load stylesheets $head['link'][] = array( 'rel' => 'stylesheet', 'type'=> 'text/css', - 'href'=> DOKU_BASE.'lib/exe/css.php?t='.$conf['template'].'&tseed='.$tseed + 'href'=> DOKU_BASE.'lib/exe/css.php?t='.rawurlencode($conf['template']).'&tseed='.$tseed ); // make $INFO and other vars available to JavaScripts @@ -417,7 +417,7 @@ function tpl_metaheaders($alt = true) { // load external javascript $head['script'][] = array( 'type'=> 'text/javascript', 'charset'=> 'utf-8', '_data'=> '', - 'src' => DOKU_BASE.'lib/exe/js.php'.'?t='.$conf['template'].'&tseed='.$tseed + 'src' => DOKU_BASE.'lib/exe/js.php'.'?t='.rawurlencode($conf['template']).'&tseed='.$tseed ); // trigger event here -- cgit v1.2.3 From c2fbf98617ceed35a8d735fbc917627e001f225b Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 15 May 2015 17:00:23 +0200 Subject: Show a relevant page title for other actions See Issue #1149 - Show 'admin' or the admin plugin name for admin functions - Show action name for user & site actions, e.g. login, sitemape - Show page name + action for page actions, e.g. changes, backlinks - Show a utf8 pen glyph when editing - Otherwise show the page name (as previously) --- inc/template.php | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 4 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index 3859065bc..fd8bff11a 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1035,6 +1035,8 @@ function tpl_pageinfo($ret = false) { * @return bool|string */ function tpl_pagetitle($id = null, $ret = false) { + global $ACT, $INPUT, $lang; + if(is_null($id)) { global $ID; $id = $ID; @@ -1042,14 +1044,67 @@ function tpl_pagetitle($id = null, $ret = false) { $name = $id; if(useHeading('navigation')) { - $title = p_get_first_heading($id); - if($title) $name = $title; + $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 + // retrieve admin plugin name from $_REQUEST['page'] + if (($page = $INPUT->str('page', '', true)) != '') { + $pluginlist = plugin_list('admin'); + if (in_array($page, $pluginlist)) { + // attempt to load the plugin + + if (($plugin = plugin_load('admin',$page)) !== null){ + $plugin_title = $plugin->getMenuText(); + $page_title = $plugin_title ? $plugin_title : $page; + } + } + } + break; + + // user functions + case 'login' : + case 'profile' : + case 'register' : + case 'resendpwd' : + $page_title = $lang['btn_'.$ACT]; + break; + + // wiki functions + case 'search' : + case 'index' : + $page_title = $lang['btn_'.$ACT]; + break; + + // 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($name); + return hsc($page_title); } else { - print hsc($name); + print hsc($page_title); return true; } } -- cgit v1.2.3 From 11aaacbee50790c2d5a2c10e97307da213d6320d Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 15 May 2015 17:05:23 +0200 Subject: Revert "Show a relevant page title for other actions" This reverts commit c2fbf98617ceed35a8d735fbc917627e001f225b. --- inc/template.php | 63 ++++---------------------------------------------------- 1 file changed, 4 insertions(+), 59 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index fd8bff11a..3859065bc 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1035,8 +1035,6 @@ function tpl_pageinfo($ret = false) { * @return bool|string */ function tpl_pagetitle($id = null, $ret = false) { - global $ACT, $INPUT, $lang; - if(is_null($id)) { global $ID; $id = $ID; @@ -1044,67 +1042,14 @@ function tpl_pagetitle($id = null, $ret = false) { $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 - // retrieve admin plugin name from $_REQUEST['page'] - if (($page = $INPUT->str('page', '', true)) != '') { - $pluginlist = plugin_list('admin'); - if (in_array($page, $pluginlist)) { - // attempt to load the plugin - - if (($plugin = plugin_load('admin',$page)) !== null){ - $plugin_title = $plugin->getMenuText(); - $page_title = $plugin_title ? $plugin_title : $page; - } - } - } - break; - - // user functions - case 'login' : - case 'profile' : - case 'register' : - case 'resendpwd' : - $page_title = $lang['btn_'.$ACT]; - break; - - // wiki functions - case 'search' : - case 'index' : - $page_title = $lang['btn_'.$ACT]; - break; - - // 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; + $title = p_get_first_heading($id); + if($title) $name = $title; } if($ret) { - return hsc($page_title); + return hsc($name); } else { - print hsc($page_title); + print hsc($name); return true; } } -- cgit v1.2.3 From fffeeafeb2530d99ec4baaec915722482dc92e84 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Fri, 15 May 2015 17:11:22 +0200 Subject: Show a relevant page title for other actions See Issue #1149 - Show 'admin' or the admin plugin name for admin functions - Show action name for user & site actions, e.g. login, sitemape - Show page name + action for page actions, e.g. changes, backlinks - Show a utf8 pen glyph when editing - Otherwise show the page name (as previously) --- inc/template.php | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 4 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index 3859065bc..fd8bff11a 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1035,6 +1035,8 @@ function tpl_pageinfo($ret = false) { * @return bool|string */ function tpl_pagetitle($id = null, $ret = false) { + global $ACT, $INPUT, $lang; + if(is_null($id)) { global $ID; $id = $ID; @@ -1042,14 +1044,67 @@ function tpl_pagetitle($id = null, $ret = false) { $name = $id; if(useHeading('navigation')) { - $title = p_get_first_heading($id); - if($title) $name = $title; + $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 + // retrieve admin plugin name from $_REQUEST['page'] + if (($page = $INPUT->str('page', '', true)) != '') { + $pluginlist = plugin_list('admin'); + if (in_array($page, $pluginlist)) { + // attempt to load the plugin + + if (($plugin = plugin_load('admin',$page)) !== null){ + $plugin_title = $plugin->getMenuText(); + $page_title = $plugin_title ? $plugin_title : $page; + } + } + } + break; + + // user functions + case 'login' : + case 'profile' : + case 'register' : + case 'resendpwd' : + $page_title = $lang['btn_'.$ACT]; + break; + + // wiki functions + case 'search' : + case 'index' : + $page_title = $lang['btn_'.$ACT]; + break; + + // 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($name); + return hsc($page_title); } else { - print hsc($name); + print hsc($page_title); return true; } } -- cgit v1.2.3 From c248bda1dcbef2068071904057b8410aa1eb0200 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sat, 16 May 2015 17:40:33 +0200 Subject: fix missing language code parameter for admin plugin titles add unit test coverage --- inc/template.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index fd8bff11a..39d06e895 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1035,7 +1035,7 @@ function tpl_pageinfo($ret = false) { * @return bool|string */ function tpl_pagetitle($id = null, $ret = false) { - global $ACT, $INPUT, $lang; + global $ACT, $INPUT, $conf, $lang; if(is_null($id)) { global $ID; @@ -1061,7 +1061,7 @@ function tpl_pagetitle($id = null, $ret = false) { // attempt to load the plugin if (($plugin = plugin_load('admin',$page)) !== null){ - $plugin_title = $plugin->getMenuText(); + $plugin_title = $plugin->getMenuText($conf['lang']); $page_title = $plugin_title ? $plugin_title : $page; } } -- cgit v1.2.3 From a61966c55d9d0ac4b800d65cfc6ee1aea44899b5 Mon Sep 17 00:00:00 2001 From: Christopher Smith Date: Sat, 16 May 2015 19:07:23 +0200 Subject: Provide a function to return admin plugin for the page request. This was previously carried out in three separate places. Refactor that code to use the new function. Update tpl_pageTitle test to use a manager level admin plugin. --- inc/template.php | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index 39d06e895..95dc52deb 100644 --- a/inc/template.php +++ b/inc/template.php @@ -218,18 +218,9 @@ function tpl_toc($return = false) { $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']) ) { + // try to load admin plugin TOC + /** @var $plugin DokuWiki_Admin_Plugin */ + if ($plugin = plugin_getRequestAdminPlugin()) { $toc = $plugin->getTOC(); $TOC = $toc; // avoid later rebuild } @@ -1054,17 +1045,10 @@ function tpl_pagetitle($id = null, $ret = false) { case 'admin' : $page_title = $lang['btn_admin']; // try to get the plugin name - // retrieve admin plugin name from $_REQUEST['page'] - if (($page = $INPUT->str('page', '', true)) != '') { - $pluginlist = plugin_list('admin'); - if (in_array($page, $pluginlist)) { - // attempt to load the plugin - - if (($plugin = plugin_load('admin',$page)) !== null){ - $plugin_title = $plugin->getMenuText($conf['lang']); - $page_title = $plugin_title ? $plugin_title : $page; - } - } + /** @var $plugin DokuWiki_Admin_Plugin */ + if ($plugin = plugin_getRequestAdminPlugin()){ + $plugin_title = $plugin->getMenuText($conf['lang']); + $page_title = $plugin_title ? $plugin_title : $plugin->getPluginName(); } break; -- cgit v1.2.3