includes/render.php
changeset 1003 28e2f75d66fd
parent 971 bc8f3ab74e5e
child 1027 98c052fc3337
--- 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(