from mad
authorweb <web@839d8a87-29fc-0310-9880-83ba4fa771e5>
Thu, 29 Jun 2006 18:42:39 +0000 (18:42 +0000)
committerweb <web@839d8a87-29fc-0310-9880-83ba4fa771e5>
Thu, 29 Jun 2006 18:42:39 +0000 (18:42 +0000)
make wiki_pagename return null if no page is defined (useful to clear_all_cache).

reindend code to make it readable.

git-svn-id: svn+ssh://murphy/home/svn/platal/branches/platal-0.9.10@346 839d8a87-29fc-0310-9880-83ba4fa771e5

htdocs/clear_all_cache.php
include/wiki.inc.php

index a06027b..187fad8 100644 (file)
@@ -21,6 +21,7 @@
 
 require_once("xorg.inc.php");
 require_once("wiki.inc.php");
+
 new_skinned_page('index.tpl', AUTH_COOKIE);
 $page->clear_compiled_tpl();
 wiki_clear_all_cache();
index d0a3d96..1b3f974 100644 (file)
@@ -22,6 +22,9 @@ $wikisites = array('xorg','xnet');
 
 function wiki_pagename() {
     $n = str_replace('/', '.', Env::get('n', false));
+    if (!$n) {
+        return null;
+    }
     $keywords = explode('.', $n);
     $count = count($keywords);
     if ($count == 1)
@@ -101,47 +104,46 @@ function wiki_assign_auth() {
 
 // cannot be in a function because pmwiki use all vars as if it was globals
 //function new_wiki_page() {
-    global $page, $globals;
-       // the wiki keword is given in the n var
-       if ( $n = wiki_pagename() )
-       {
+    // the wiki keword is given in the n var
+    if ( $n = wiki_pagename() )
+    {
+
+        $wiki_template = wiki_template($n);
+        $tmpfile_exists = file_exists($wiki_template);
 
-         $wiki_template = wiki_template($n);
-         $tmpfile_exists = file_exists($wiki_template);
+        // don't recreate the tpl if it already exists
+        if (Env::get('action') || !$tmpfile_exists)
+        {
+            if ($tmpfile_exists) {
+                wiki_clear_cache($n);
+            }
 
-         // don't recreate the tpl if it already exists
-         if (Env::get('action') || !$tmpfile_exists)
-         {
-           if ($tmpfile_exists) {
-              wiki_clear_cache($n);
-           }
+            // we leave pmwiki do whatever it wants and store everything
+            ob_start();
+            require_once($globals->spoolroot.'/'.$globals->wiki->wikidir.'/pmwiki.php');
 
-           // we leave pmwiki do whatever it wants and store everything
-           ob_start();
-           require_once($globals->spoolroot.'/'.$globals->wiki->wikidir.'/pmwiki.php');
+            $wikiAll = ob_get_clean();
+            // the pmwiki skin we are using (almost empty) has these keywords:
+            $i = strpos($wikiAll, "<!--/HeaderText-->");
+            $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
 
-           $wikiAll = ob_get_clean();
-           // the pmwiki skin we are using (almost empty) has these keywords:
-           $i = strpos($wikiAll, "<!--/HeaderText-->");
-           $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
-           
-         }
-         if (Env::get('action'))
-         {
-        // clean old tmp files
-        wiki_clean_tmp();
-           $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
-           // create new tmp files with editing page from wiki engine
-           $wiki_template = wiki_create_tmp(substr($wikiAll, $j));
-         } else {
-           if (!$tmpfile_exists)
-           {
-               $f = fopen($wiki_template, 'w');
-               fputs($f, substr($wikiAll, $j));
-               fclose($f);
-           }
-         } 
-       }
+        }
+        if (Env::get('action'))
+        {
+            // clean old tmp files
+            wiki_clean_tmp();
+            $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
+            // create new tmp files with editing page from wiki engine
+            $wiki_template = wiki_create_tmp(substr($wikiAll, $j));
+        } else {
+            if (!$tmpfile_exists)
+            {
+                $f = fopen($wiki_template, 'w');
+                fputs($f, substr($wikiAll, $j));
+                fclose($f);
+            }
+        } 
+    }
    //return $wiki_template;    
 //}
 ?>