includes/render.php
changeset 971 bc8f3ab74e5e
parent 953 323c4cd1aa37
child 1003 28e2f75d66fd
equal deleted inserted replaced
970:d894086f38cc 971:bc8f3ab74e5e
   571   
   571   
   572   /**
   572   /**
   573    * Parses internal links (wikilinks) in a block of text.
   573    * Parses internal links (wikilinks) in a block of text.
   574    * @param string Text to process
   574    * @param string Text to process
   575    * @param string Optional. If included will be used as a template instead of using the default syntax.
   575    * @param string Optional. If included will be used as a template instead of using the default syntax.
       
   576    * @param bool If false, does not add wikilink-nonexistent or check for exsistence of pages. Can reduce DB queries; defualts to true.
   576    * @return string
   577    * @return string
   577    */
   578    */
   578   
   579   
   579   public static function parse_internal_links($text, $tplcode = false)
   580   public static function parse_internal_links($text, $tplcode = false, $do_exist_check = true)
   580   {
   581   {
   581     global $db, $session, $paths, $template, $plugins; // Common objects
   582     global $db, $session, $paths, $template, $plugins; // Common objects
   582     
   583     
   583     if ( is_string($tplcode) )
   584     if ( is_string($tplcode) )
   584     {
   585     {
   602       $pid_clean = $paths->nslist[$namespace] . sanitize_page_id($page_id);
   603       $pid_clean = $paths->nslist[$namespace] . sanitize_page_id($page_id);
   603       
   604       
   604       $url = makeUrl($pid_clean, false, true) . $hash;
   605       $url = makeUrl($pid_clean, false, true) . $hash;
   605       $inner_text = $matches[2][$i];
   606       $inner_text = $matches[2][$i];
   606       $quot = '"';
   607       $quot = '"';
   607       $exists = ( isPage($pid_clean) ) ? '' : ' class="wikilink-nonexistent"';
   608       $exists = ( ($do_exist_check && isPage($pid_clean)) || !$do_exist_check ) ? '' : ' class="wikilink-nonexistent"';
   608       
   609       
   609       if ( $tplcode )
   610       if ( $tplcode )
   610       {
   611       {
   611         $parser->assign_vars(array(
   612         $parser->assign_vars(array(
   612             'HREF' => $url,
   613             'HREF' => $url,
   632       $pid_clean = $paths->nslist[$namespace] . sanitize_page_id($page_id);
   633       $pid_clean = $paths->nslist[$namespace] . sanitize_page_id($page_id);
   633       
   634       
   634       $url = makeUrl($pid_clean, false, true);
   635       $url = makeUrl($pid_clean, false, true);
   635       $inner_text = ( isPage($pid_clean) ) ? htmlspecialchars(get_page_title($pid_clean)) : htmlspecialchars($matches[1][$i]);
   636       $inner_text = ( isPage($pid_clean) ) ? htmlspecialchars(get_page_title($pid_clean)) : htmlspecialchars($matches[1][$i]);
   636       $quot = '"';
   637       $quot = '"';
   637       $exists = ( isPage($pid_clean) ) ? '' : ' class="wikilink-nonexistent"';
   638       $exists = ( ($do_exist_check && isPage($pid_clean)) || !$do_exist_check ) ? '' : ' class="wikilink-nonexistent"';
   638       
   639       
   639       if ( $tplcode )
   640       if ( $tplcode )
   640       {
   641       {
   641         $parser->assign_vars(array(
   642         $parser->assign_vars(array(
   642             'HREF' => $url,
   643             'HREF' => $url,