Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27484
Modified Files:
Tag: branch-smarty
compat.php serendipity_admin_upgrader.inc.php NEWS
Log Message:
- Entrust the handling of version comparison fully to version_compare() - this also allows the use of our new version syntax
- Updated upgrader to use MySQL as fallback when looking for appropriate database updates, and none was found
- Rewrite some parts of the upgrader to make it easier to add and maintain calling functions
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.214.2.9
retrieving revision 1.214.2.10
diff -u -d -r1.214.2.9 -r1.214.2.10
--- NEWS 16 Sep 2004 13:54:02 -0000 1.214.2.9
+++ NEWS 16 Sep 2004 18:07:44 -0000 1.214.2.10
@@ -6,7 +6,11 @@
* RSS Feed export will not contain rewritten URLs using event
plugins (garvinhicking)
- * Added support for SMARTY templating. (garvinhicking, tomsommer)
+ * Updated upgrader to use MySQL as fallback when looking for
+ appropriate database updates and none was found for the selected
+ database type (tomsommer)
+
+ * Added support for Smarty Templating. (garvinhicking, tomsommer)
Version 0.7-beta3 (September 16h, 2004)
------------------------------------------------------------------------
Index: serendipity_admin_upgrader.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_upgrader.inc.php,v
retrieving revision 1.21
retrieving revision 1.21.2.1
diff -u -d -r1.21 -r1.21.2.1
--- serendipity_admin_upgrader.inc.php 31 Aug 2004 10:58:20 -0000 1.21
+++ serendipity_admin_upgrader.inc.php 16 Sep 2004 18:07:44 -0000 1.21.2.1
@@ -11,31 +11,52 @@
$upgradeLoc = $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[action]=upgrade';
/* Functions which needs to be run if installed version is equal or lower */
-$tasks = array('0.5.1' => 'serendipity_syncThumbs',
- '0.6.5' => 'serendipity_rebuildCategoryTree',
- '0.6.8' => 'serendipity_installFiles',
- '0.6.10' => 'serendipity_installFiles',
- '0.6.12' => 'serendipity_installFiles',
+$tasks = array('0.5.1' => array('function' => 'serendipity_syncThumbs',
+ 'title' => 'Image Sync',
+ 'desc' => 'Version 0.5.1 introduces image sync with the database'. "\n" .
+ 'With your permission I would like to perform the image sync'),
+
+ '0.6.5' => array('function' => 'serendipity_rebuildCategoryTree',
+ 'title' => 'Nested subcategories, post to multiple categories',
+ 'desc' => 'This update will update the categories table of your database and update the relations from entries to categories.'. "\n" .
+ 'This is a possibly dangerous task to perform, so <strong style="color: red">make sure you have a backup of your database!</strong>'),
+
+ '0.6.8' => array('function' => 'serendipity_installFiles',
+ 'title' => 'Update of .htaccess file',
+ 'desc' => 'Changes were made to the .htaccess file, you need to regenerate it'),
+
+ '0.6.10' => array('functon' => 'serendipity_installFiles',
+ 'title' => 'Update of .htaccess file',
+ 'desc' => 'Changes were made to the .htaccess file, you need to regenerate it'),
+
+ '0.6.12' => array('function' => 'serendipity_installFiles',
+ 'title' => 'Update of .htaccess file',
+ 'desc' => 'Changes were made to the .htaccess file, you need to regenerate it'),
);
/* Fetch SQL files which needs to be run */
$dir = opendir(S9Y_INCLUDE_PATH . 'sql/');
-$dbType = $serendipity['dbType'] == 'mysqli' ? 'mysql' : $serendipity['dbType'];
-$sqlfiles = array();
+$tmpfiles = array();
while (($file = readdir($dir)) !== false ) {
- if (preg_match('@db_update_(.*)_(.*)_'. $dbType .'.sql@', $file, $res)) {
- if (version_compare($res[1], serendipity_version($serendipity['versionInstalled'])) >= 0) {
- // Create a usable float as key index for our array to make it sortable
- $numbers = explode('.', $res[1]);
- $first = $numbers[0];
- unset($numbers[0]);
- $sqlfiles[$first . '.' . @implode('', $numbers)] = $file;
+ if (preg_match('@db_update_(.*)_(.*)_(.*).sql@', $file, $res)) {
+ list(, $verFrom, $verTo, $dbType) = $res;
+ if (version_compare($verFrom, serendipity_version($serendipity['versionInstalled'])) >= 0) {
+ $tmpFiles[$verFrom][$dbType] = $file;
}
}
}
-@ksort($sqlfiles);
+$sqlfiles = array();
+foreach ( $tmpFiles as $version => $db ) {
+ if ( array_key_exists($serendipity['dbType'], $db) === false ) {
+ $sqlfiles[$version] = $db['mysql'];
+ } else {
+ $sqlfiles[$version] = $db[$serendipity['dbType']];
+ }
+}
+
+@uksort($sqlfiles, "strnatcasecmp");
if ($serendipity['GET']['action'] == 'ignore') {
/* Todo: Don't know what to put here? */
@@ -57,18 +78,19 @@
/* Call functions */
- foreach ($tasks as $version => $function) {
+ $errors = array();
+ foreach ($tasks as $version => $task) {
if (version_compare(serendipity_version($serendipity['versionInstalled']), $version, '<') ) {
- if (is_callable($function)) {
- echo 'Calling ' . $function . '...<br />';
- call_user_func($function);
+ if (is_callable($task['function'])) {
+ echo 'Calling ' . $task['function'] . '...<br />';
+ call_user_func($task['function']);
} else {
- $errors[] = 'Unable to call '. $function;
+ $errors[] = 'Unable to call '. $task['function'];
}
}
}
- if (is_array($errors)) {
+ if (sizeof($errors)) {
echo DIAGNOSTIC_ERROR . '<br /><br />';
echo '<span class="serendipity_msg_important">- ' . implode('<br />', $errors) . '</span><br /><br />';
}
@@ -111,93 +133,26 @@
?>
<br />
<h3><?php printf(SERENDIPITY_UPGRADER_DATABASE_UPDATES, $serendipity['dbType']) ?>:</h3>
-<?php echo SERENDIPITY_UPGRADER_FOUND_SQL_FILES ?>:
-<br />
+<?php echo SERENDIPITY_UPGRADER_FOUND_SQL_FILES ?>:<br />
<?php
foreach ($sqlfiles as $sqlfile) {
- echo '<strong>- '. $sqlfile .'</strong><br />';
+ echo '<div style="padding-left: 5px"><strong>'. $sqlfile .'</strong></div>';
}
-?>
-<?php
}
?>
<br />
-
<h3><?php echo SERENDIPITY_UPGRADER_VERSION_SPECIFIC ?>:</h3>
<?php
$taskCount = 0;
- if (version_compare(serendipity_version($serendipity['versionInstalled']), '0.5.1', '<')) {
- echo '<br /><strong>0.5.1 - Image sync</strong>';
- echo '<br />Version 0.5.1 introduces image sync with the database.';
- echo '<br />With your permission I would like to perform the image sync.<br />';
- $taskCount++;
- }
-
- if (version_compare(serendipity_version($serendipity['versionInstalled']), '0.6', '<')) {
- echo '<br /><strong>0.6 - Move images</strong>';
- echo '<br />[INFO] Smilies and XML-Buttons were moved from pixel/ to template/default/img<br />';
-
- echo '<br /><strong>0.6 - Template/CSS changes</strong>';
- echo '<br />[INFO] A home-link has been added to the page headers. For that, two new CSS classes have been introduced: #homelink1 (header), homelink2 (subheader).<br />';
- echo 'If you have a custom template, you need to adapt to those changes. To make themlook like your header previously has, insert this in your style.css:<br /><br />';
-
- echo '<pre>a.homelink1,
- a.homelink1:hover,
- a.homelink1:link,
- a.homelink1:visited,
- #serendipity_banner h1 {
- ... your css-definitions ...
- text-decoration: none;
- }
-
- a.homelink2,
- a.homelink2:hover,
- a.homelink2:link,
- a.homelink2:visited,
- #serendipity_banner h2 {
- ... your css-definitions ...
- text-decoration: none;
- }</pre><br />';
- }
-
- if (version_compare(serendipity_version($serendipity['versionInstalled']), '0.6.5', '<')) {
- echo '<br /><strong>0.6.5 - Nested subcategories, post to multiple categories</strong>';
- echo '<br />[<strong style="color: red">INFO</strong>] This update will update the categories table of your database and update the relations from entries to categories. This is a possibly dangerous task to perform, so <strong style="color: red">make sure you have a backup of your database!</strong><br />';
- $taskCount++;
- }
-
- if (version_compare(serendipity_version($serendipity['versionInstalled']), '0.6.8', '<')) {
- echo '<br /><strong>0.6.8 - .htaccess</strong>';
- echo '<br />[INFO] The Plugin API now allows external plugins to generate individual content. Your .htaccess file needs to be updated for this to occur. This will happen automatically, if you continue. If you made individual changes to your .htaccess file, backup that file now.<br />';
- $taskCount++;
- }
-
- if (version_compare(serendipity_version($serendipity['versionInstalled']), '0.6.10', '<')) {
- echo '<br /><strong>0.6.10 - .htaccess</strong>';
- echo '<br />[INFO] Your .htaccess file needs to be updated for this to occur. This will happen automatically, if you continue. If you made individual changes to your .htaccess file, backup that file now.<br />';
- $taskCount++;
- }
-
- if (version_compare(serendipity_version($serendipity['versionInstalled']), '0.6.12', '<')) {
- echo '<br /><strong>0.6.12 - .htaccess</strong>';
- echo '<br />[INFO] Your .htaccess file needs to be updated for this to occur. This will happen automatically, if you continue. If you made individual changes to your .htaccess file, backup that file now.<br />';
- $taskCount++;
- }
-
-
-
- /*
-
- Add more versions here using:
-
- if ([version_compare]) {
- [Desc]
+ foreach ( $tasks as $version => $task ) {
+ if (version_compare(serendipity_version($serendipity['versionInstalled']), $version, '<')) {
+ echo '<div><strong>'. $version .' - '. $task['title'] .'</strong></div>';
+ echo '<div style="padding-left: 5px">'. nl2br($task['desc']) .'</div><br />';
$taskCount++;
}
-
- */
+ }
if ($taskCount == 0) {
echo SERENDIPITY_UPGRADER_NO_VERSION_SPECIFIC;
@@ -208,7 +163,7 @@
<hr noshade="noshade">
<?php if ($taskCount > 0 || sizeof($sqlfiles) > 0) { ?>
<strong><?php echo SERENDIPITY_UPGRADER_PROCEED_QUESTION ?></strong>
- <br /><?php if ($showAbort) { ?><input type="button" value="<?php echo SERENDIPITY_UPGRADER_PROCEED_ABORT ?>" onclick="location.href='<?php echo $abortLoc ?>'"> <?php } ?><input type="button" value="<?php echo SERENDIPITY_UPGRADER_PROCEED_DOIT ?>" onclick="location.href='<?php echo $upgradeLoc ?>'">
+ <br /><input type="button" value="<?php echo SERENDIPITY_UPGRADER_PROCEED_DOIT ?>" onclick="location.href='<?php echo $upgradeLoc ?>'"> <?php if ($showAbort) { ?><input type="button" value="<?php echo SERENDIPITY_UPGRADER_PROCEED_ABORT ?>" onclick="location.href='<?php echo $abortLoc ?>'"> <?php } ?>
<?php } else { ?>
<strong><?php echo SERENDIPITY_UPGRADER_NO_UPGRADES ?></strong>
<br /><input type="button" value="<?php echo SERENDIPITY_UPGRADER_CONSIDER_DONE ?>" onclick="location.href='<?php echo $abortLoc ?>'">
Index: compat.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/compat.php,v
retrieving revision 1.18
retrieving revision 1.18.2.1
diff -u -d -r1.18 -r1.18.2.1
--- compat.php 25 May 2004 11:02:19 -0000 1.18
+++ compat.php 16 Sep 2004 18:07:44 -0000 1.18.2.1
@@ -115,7 +115,7 @@
}
function serendipity_version($version) {
- return preg_replace('@\-.+$@', '', $version);
+ return $version;
}
/*
|