Class "currentpage" is now added to all internal links, including sidebar buttons, if the link points to the current page.
--- a/includes/render.php Wed May 27 09:12:59 2009 -0400
+++ b/includes/render.php Wed May 27 09:44:07 2009 -0400
@@ -574,10 +574,12 @@
* @param string Text to process
* @param string Optional. If included will be used as a template instead of using the default syntax.
* @param bool If false, does not add wikilink-nonexistent or check for exsistence of pages. Can reduce DB queries; defualts to true.
+ * @param string Page ID. If specified, class="currentpage" will be added to links if they match the given page ID and namespace
+ * @param string Namespace. If specified, class="currentpage" will be added to links if they match the given page ID and namespace
* @return string
*/
- public static function parse_internal_links($text, $tplcode = false, $do_exist_check = true)
+ public static function parse_internal_links($text, $tplcode = false, $do_exist_check = true, $match_page_id = false, $match_namespace = false)
{
global $db, $session, $paths, $template, $plugins; // Common objects
@@ -607,6 +609,9 @@
$quot = '"';
$exists = ( ($do_exist_check && isPage($pid_clean)) || !$do_exist_check ) ? '' : ' class="wikilink-nonexistent"';
+ if ( $match_page_id && $match_namespace && $pid_clean === $paths->get_pathskey($match_page_id, $match_namespace) )
+ $exists .= ' class="currentpage"';
+
if ( $tplcode )
{
$parser->assign_vars(array(
@@ -637,6 +642,9 @@
$quot = '"';
$exists = ( ($do_exist_check && isPage($pid_clean)) || !$do_exist_check ) ? '' : ' class="wikilink-nonexistent"';
+ if ( $match_page_id && $match_namespace && $pid_clean === $paths->get_pathskey($match_page_id, $match_namespace) )
+ $exists .= ' class="currentpage"';
+
if ( $tplcode )
{
$parser->assign_vars(array(
--- a/includes/template.php Wed May 27 09:12:59 2009 -0400
+++ b/includes/template.php Wed May 27 09:44:07 2009 -0400
@@ -1090,7 +1090,7 @@
$parser->assign_vars(Array(
'HREF'=>makeUrlNS('Special', 'Login/' . $local_page),
- 'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { ajaxStartLogin(); return false; }"',
+ 'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { ajaxStartLogin(); return false; }"' . ( $local_page_id == 'Login' && $local_namespace == 'Special' ? ' class="currentpage"' : '' ),
'TEXT'=>$lang->get('sidebar_btn_login'),
));
@@ -1098,7 +1098,7 @@
$parser->assign_vars(Array(
'HREF'=>makeUrlNS('Special', 'ChangeStyle/'.$local_page),
- 'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { ajaxChangeStyle(); return false; }"',
+ 'FLAGS'=>'onclick="if ( !KILL_SWITCH ) { ajaxChangeStyle(); return false; }"' . ( $local_page_id == 'ChangeStyle' && $local_namespace == 'Special' ? ' class="currentpage"' : '' ),
'TEXT'=>$lang->get('sidebar_btn_changestyle'),
));
@@ -1826,7 +1826,7 @@
$message = RenderMan::process_imgtags_stage2($message, $taglist);
// Internal links
- $message = RenderMan::parse_internal_links($message, $tplvars['sidebar_button'], false);
+ $message = RenderMan::parse_internal_links($message, $tplvars['sidebar_button'], false, $this->page_id, $this->namespace);
// External links