More blank-urlname bugfixes, this time involving internal links
authorDan
Sat, 26 Sep 2009 15:21:51 -0400
changeset 1123 777f32ac6b7c
parent 1122 e1606c85e937
child 1124 1e956881d362
More blank-urlname bugfixes, this time involving internal links
includes/functions.php
includes/paths.php
includes/render.php
--- a/includes/functions.php	Sat Sep 26 15:14:15 2009 -0400
+++ b/includes/functions.php	Sat Sep 26 15:21:51 2009 -0400
@@ -293,7 +293,16 @@
   
   return ( $sanitize ) ? sanitize_page_id($title) : $title;
 }
- 
+
+/**
+ * Returns true if we are allowed to have a page with a fully blank URL string. This page magically exists when you set the main page to blank.
+ * @return bool
+ */
+
+function have_blank_urlname_page()
+{
+  return getConfig('main_page', 'Main_Page') == '' || getConfig('main_page', getConfig('main_page', 'Main_Page')) == '';
+}
 
 /**
  * Enano replacement for date(). Accounts for individual users' timezone preferences.
--- a/includes/paths.php	Sat Sep 26 15:14:15 2009 -0400
+++ b/includes/paths.php	Sat Sep 26 15:21:51 2009 -0400
@@ -135,7 +135,7 @@
       if ( empty($title) )
         $title = get_title();
       
-      if ( empty($title) && getConfig('main_page', 'Main_Page') != '' && getConfig('main_page', getConfig('main_page', 'Main_Page')) != '' )
+      if ( empty($title) && !have_blank_urlname_page() )
       {
         $this->main_page();
       }
--- a/includes/render.php	Sat Sep 26 15:14:15 2009 -0400
+++ b/includes/render.php	Sat Sep 26 15:21:51 2009 -0400
@@ -664,8 +664,11 @@
   
     $parser = is_string($tplcode) ? $template->makeParserText($tplcode) : false;
     
+    // allow blank urlname?
+    $repeater = have_blank_urlname_page() ? '*' : '+';
+    
     // stage 1 - links with alternate text
-    preg_match_all('/\[\[([^\[\]<>\{\}\|]+)\|(.+?)\]\]/', $text, $matches);
+    preg_match_all('/\[\[([^\[\]<>\{\}\|]' . $repeater . ')\|(.+?)\]\]/', $text, $matches);
     foreach ( $matches[0] as $i => $match )
     {
       list($page_id, $namespace) = RenderMan::strToPageID($matches[1][$i]);
@@ -674,7 +677,7 @@
     }
     
     // stage 2 - links with no alternate text
-    preg_match_all('/\[\[([^\[\]<>\{\}\|]+)\]\]/', $text, $matches);
+    preg_match_all('/\[\[([^\[\]<>\{\}\|]' . $repeater . ')\]\]/', $text, $matches);
     foreach ( $matches[0] as $i => $match )
     {
       list($page_id, $namespace) = RenderMan::strToPageID($matches[1][$i]);