logo       
Google Custom Search
    AddThis Social Bookmark Button

CVS: phpwiki/lib upgrade.php,1.10,1.11: msg#00172

Subject: CVS: phpwiki/lib upgrade.php,1.10,1.11
Update of /cvsroot/phpwiki/phpwiki/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12761

Modified Files:
        upgrade.php 
Log Message:
skip the HomePage, at first upgrade the ActionPages, then the database, then 
the rest

Index: upgrade.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/upgrade.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -2 -b -p -d -r1.10 -r1.11
--- upgrade.php 15 May 2004 01:19:41 -0000      1.10
+++ upgrade.php 15 May 2004 13:06:17 -0000      1.11
@@ -46,14 +46,9 @@ rcs_id('$Id$');
 require_once("lib/loadsave.php");
 
-// see loadsave.php for saving new pages.
-function CheckPgsrcUpdate(&$request) {
-    echo "<h3>",_("check for necessary pgsrc updates"),"</h3>\n";
+/**
+ * TODO: check for the pgsrc_version number, not the revision
+ */
+function doPgsrcUpdate(&$request,$pagename,$path,$filename) {
     $dbi = $request->getDbh(); 
-    $path = FindLocalizedFile(WIKI_PGSRC);
-    $pgsrc = new fileSet($path);
-    // fixme: verification, ...
-    foreach ($pgsrc->getFiles() as $filename) {
-        if (substr($filename,-1,1) == '~') continue;
-        $pagename = urldecode($filename);
         $page = $dbi->getPage($pagename);
         if ($page->exists()) {
@@ -75,12 +70,15 @@ function CheckPgsrcUpdate(&$request) {
                     $new_mtime = $stat[9];
                 if ($new_mtime > $page_mtime) {
-                    echo "$path/$pagename: newer than the existing page. 
replace ($new_mtime &gt; $page_mtime)<br />\n";
+                echo "$path/$pagename: newer than the existing page.",
+                    " replace ($new_mtime &gt; $page_mtime)<br />\n";
                     LoadAny($request,$path."/".$filename);
                     echo "<br />\n";
                 } else {
-                    echo "$path/$pagename: older than the existing page. 
skipped.<br />\n";
+                echo "$path/$pagename: older than the existing page.",
+                    " skipped.<br />\n";
                 }
             } else {
-                echo "$path/$pagename: unknown format, skipped.<br />\n";
+            echo "$path/$pagename: unknown format.",
+                " skipped.<br />\n";
             }
         } else {
@@ -89,4 +87,62 @@ function CheckPgsrcUpdate(&$request) {
             echo "<br />\n";
         }
+}
+
+/** need the english filename (required precondition: urlencode == urldecode)
+ *  returns the plugin name.
+ */ 
+function isActionPage($filename) {
+    static $special = array("DebugInfo"        => "_BackendInfo",
+                            "PhpWikiRecentChanges" => "RssFeed",
+                            "ProjectSummary"   => "RssFeed",
+                            "RecentReleases"   => "RssFeed",
+                            );
+    $base = preg_replace("/\..{1,4}$/","",basename($filename));
+    if (isset($special[$base])) return $special[$base];
+    if (FindFile("lib/plugin/".$base.".php",true)) return $base;
+    else return false;
+}
+
+function CheckActionPageUpdate(&$request) {
+    echo "<h3>",_("check for necessary ActionPage updates"),"</h3>\n";
+    $dbi = $request->getDbh(); 
+    $path = FindFile('pgsrc');
+    $pgsrc = new fileSet($path);
+    // most actionpages have the same name as the plugin
+    foreach ($pgsrc->getFiles() as $filename) {
+        if (substr($filename,-1,1) == '~') continue;
+        $pagename = urldecode($filename);
+        if (isActionPage($filename)) {
+            doPgsrcUpdate($request, $pagename, $path, $filename);
+        }
+    }
+}
+
+// see loadsave.php for saving new pages.
+function CheckPgsrcUpdate(&$request) {
+    echo "<h3>",_("check for necessary pgsrc updates"),"</h3>\n";
+    $dbi = $request->getDbh(); 
+    $path = FindLocalizedFile(WIKI_PGSRC);
+    $pgsrc = new fileSet($path);
+    // fixme: verification, ...
+    $isHomePage = false;
+    foreach ($pgsrc->getFiles() as $filename) {
+        if (substr($filename,-1,1) == '~') continue;
+        $pagename = urldecode($filename);
+        // don't ever update the HomePage
+        if (defined(HOME_PAGE))
+            if ($pagename == HOME_PAGE) $isHomePage = true;
+        else
+            if ($pagename == _("HomePage")) $isHomePage = true;
+        if ($pagename == "HomePage") $isHomePage = true;
+        if ($isHomePage) {
+            echo "$path/$pagename: always skip the HomePage.",
+                " skipped<br />\n";
+            $isHomePage = false;
+            continue;
+        }
+        if (!isActionPage($filename)) {
+            doPgsrcUpdate($request,$pagename,$path,$filename);
+        }
     }
     return;
@@ -324,4 +380,5 @@ function DoUpgrade($request) {
 
     StartLoadDump($request, _("Upgrading this PhpWiki"));
+    CheckActionPageUpdate($request);
     CheckDatabaseUpdate($request);
     CheckPgsrcUpdate($request);
@@ -333,4 +390,7 @@ function DoUpgrade($request) {
 /**
  $Log$
+ Revision 1.11  2004/05/15 13:06:17  rurban
+ skip the HomePage, at first upgrade the ActionPages, then the database, then 
the rest
+
  Revision 1.10  2004/05/15 01:19:41  rurban
  upgrade prefix fix by Kai Krakow



-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband
Sign-up now for SourceForge Broadband and get the fastest
6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click


<Prev in Thread] Current Thread [Next in Thread>