[pLog-svn] r1215 - in plog/trunk: . templates/wizard
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Sat Feb 26 17:36:19 GMT 2005
Author: oscar
Date: 2005-02-26 17:36:18 +0000 (Sat, 26 Feb 2005)
New Revision: 1215
Modified:
plog/trunk/templates/wizard/intro.template
plog/trunk/templates/wizard/step1.template
plog/trunk/templates/wizard/step2.template
plog/trunk/templates/wizard/step3.template
plog/trunk/templates/wizard/step4.template
plog/trunk/templates/wizard/step5.template
plog/trunk/templates/wizard/update1.template
plog/trunk/templates/wizard/update2.template
plog/trunk/templates/wizard/update3.template
plog/trunk/templates/wizard/update4.template
plog/trunk/wizard.php
Log:
I don't know what the hell happened to the wizard templates but suddenly all the {include } had file="$blogtemplate/..." instead of file="wizard/...". I have fixed that as well as adding the necessary changes to make the wizard convert the plog_articles table to the new version in as many different steps as needed. It still needs some polish and I will make the form commit itself (some javascript code will do) as long as there are posts left to convert. By default it will convert WIZARD_MAX_RECORDS_PER_STEP posts per step and it will only use multiple steps if we've got more than WIZARD_MAX_RECORDS_THRESHOLD posts so please play around with those constants if you've got some issues.
Modified: plog/trunk/templates/wizard/intro.template
===================================================================
--- plog/trunk/templates/wizard/intro.template 2005-02-26 17:29:51 UTC (rev 1214)
+++ plog/trunk/templates/wizard/intro.template 2005-02-26 17:36:18 UTC (rev 1215)
@@ -1,4 +1,4 @@
-{include file="$blogtemplate/header.template" title="1 Welcome!" step=1 mode=install}
+{include file="wizard/header.template" title="1 Welcome!" step=1 mode=install}
<form name="databaseInfo" action="wizard.php" method="post">
<fieldset class="inputField">
<legend>Database settings</legend>
@@ -27,7 +27,7 @@
<span class="required">*</span>
<div class="formHelp">This is the host where your database server is running.</div>
<input style="width:100%" type="text" id="dbServer" name="dbServer" value="{$dbServer}"/>
- {include file="$blogtemplate/validate.template" field=dbServer message="Database server is missing or incorrect"}
+ {include file="wizard/validate.template" field=dbServer message="Database server is missing or incorrect"}
</div>
<div class="field">
@@ -35,7 +35,7 @@
<span class="required">*</span>
<div class="formHelp">User that will be used to access the database.</div>
<input style="width:100%" type="text" id="dbUser" name="dbUser" value="{$dbUser}"/>
- {include file="$blogtemplate/validate.template" field=dbUser message="Database user is missing or incorrect"}
+ {include file="wizard/validate.template" field=dbUser message="Database user is missing or incorrect"}
</div>
<div class="field">
@@ -50,7 +50,7 @@
<span class="required">*</span>
<input style="width:100%" type="text" id="dbName" name="dbName" value="{$dbName}"/>
<div class="formHelp">Name of the database where tables will be created</div>
- {include file="$blogtemplate/validate.template" field=dbName message="Database name is missing or incorrect"}
+ {include file="wizard/validate.template" field=dbName message="Database name is missing or incorrect"}
</div>
<div class="field">
@@ -67,4 +67,4 @@
<input type="submit" name="Next" value="Next »"/>
</div>
</form>
-{include file="$blogtemplate/footer.template"}
+{include file="wizard/footer.template"}
Modified: plog/trunk/templates/wizard/step1.template
===================================================================
--- plog/trunk/templates/wizard/step1.template 2005-02-26 17:29:51 UTC (rev 1214)
+++ plog/trunk/templates/wizard/step1.template 2005-02-26 17:36:18 UTC (rev 1215)
@@ -1,4 +1,4 @@
-{include file="$blogtemplate/header.template" title="2 Confirm Information" mode=install step=2}
+{include file="wizard/header.template" title="2 Confirm Information" mode=install step=2}
<form name="formStep1" method="post">
<fieldset class="inputField">
<legend>Database Initialization</legend>
@@ -53,4 +53,4 @@
<input type="submit" name="Next »" value="Next »"/>
</div>
</form>
-{include file="$blogtemplate/footer.template"}
+{include file="wizard/footer.template"}
Modified: plog/trunk/templates/wizard/step2.template
===================================================================
--- plog/trunk/templates/wizard/step2.template 2005-02-26 17:29:51 UTC (rev 1214)
+++ plog/trunk/templates/wizard/step2.template 2005-02-26 17:36:18 UTC (rev 1215)
@@ -1,4 +1,4 @@
-{include file="$blogtemplate/header.template" title="3 Database Initialized" step=3 mode="install"}
+{include file="wizard/header.template" title="3 Database Initialized" step=3 mode="install"}
<form name="formStep2" action="wizard.php" method="post">
<fieldset class="inputField">
<legend>Database Initialization</legend>
@@ -22,4 +22,4 @@
<input type="submit" name="Next »" value="Next »"/>
</div>
</form>
-{include file="$blogtemplate/footer.template"}
+{include file="wizard/footer.template"}
Modified: plog/trunk/templates/wizard/step3.template
===================================================================
--- plog/trunk/templates/wizard/step3.template 2005-02-26 17:29:51 UTC (rev 1214)
+++ plog/trunk/templates/wizard/step3.template 2005-02-26 17:36:18 UTC (rev 1215)
@@ -1,4 +1,4 @@
-{include file="$blogtemplate/header.template" title="4 User Creation" step=4 mode=install}
+{include file="wizard/header.template" title="4 User Creation" step=4 mode=install}
<form name="newUser" action="wizard.php" method="post">
<fieldset class="inputField">
<legend>User Creation</legend>
@@ -20,7 +20,7 @@
<span class="required">*</span>
<div class="fieldHelp">Name of the first default user that will be created. This user will be given administrator privileges</div>
<input type="text" id="userName" name="userName" value="{$userName}"/>
- {include file="$blogtemplate/validate.template" field=userName message="User name is missing or incorrect"}
+ {include file="wizard/validate.template" field=userName message="User name is missing or incorrect"}
</div>
<div class="field">
<label for="userFullName">Full name</label>
@@ -33,18 +33,18 @@
<span class="required">*</span>
<div class="fieldHelp">Password assigned to this user</div>
<input type="password" name="userPassword" id="userPassword" value=""/>
- {include file="$blogtemplate/validate.template" field=userPassword message="Password is missing or too short"}
+ {include file="wizard/validate.template" field=userPassword message="Password is missing or too short"}
<br/>
<div class="fieldHelp">Please confirm the password</div>
<input type="password" name="userPasswordCheck" id="userPasswordCheck" value=""/>
- {include file="$blogtemplate/validate.template" field=userPasswordCheck message="Passwords do not match"}
+ {include file="wizard/validate.template" field=userPasswordCheck message="Passwords do not match"}
</div>
<div class="field">
<label for="userEmail">Email address</label>
<span class="required">*</span>
<div class="fieldHelp">Email address where notifications will be sent</div>
<input type="text" name="userEmail" id="userEmail" value="{$userEmail}" />
- {include file="$blogtemplate/validate.template" field=userEmail message="The email address is missing or incorrect"}
+ {include file="wizard/validate.template" field=userEmail message="The email address is missing or incorrect"}
</div>
</fieldset>
<div class="buttons">
@@ -54,4 +54,4 @@
<input type="hidden" name="nextStep" value="Step4"/></p>
</p>
-{include file="$blogtemplate/footer.template"}
+{include file="wizard/footer.template"}
Modified: plog/trunk/templates/wizard/step4.template
===================================================================
--- plog/trunk/templates/wizard/step4.template 2005-02-26 17:29:51 UTC (rev 1214)
+++ plog/trunk/templates/wizard/step4.template 2005-02-26 17:36:18 UTC (rev 1215)
@@ -1,4 +1,4 @@
-{include file="$blogtemplate/header.template" title="5 Blog Configuration" step=5 mode=install}
+{include file="wizard/header.template" title="5 Blog Configuration" step=5 mode=install}
<form name="newBlog" method="post">
<fieldset class="inputField">
<legend>Blog Creation</legend>
@@ -20,7 +20,7 @@
<span class="required">*</span>
<div class="fieldHelp">Short but descriptive name for the new blog</div>
<input type="text" style="width:100%" name="blogName" id="blogName" value="{$blogName}"/>
- {include file="$blogtemplate/validate.template" field=blogName message="Blog name is missing or incorrect"}
+ {include file="wizard/validate.template" field=blogName message="Blog name is missing or incorrect"}
</div>
<div class="field">
<label for="blogLocale">Language</label>
@@ -40,7 +40,7 @@
<img height="150" width="150" src="{$template->getScreenshotUrl()}" alt="{$template->getName()}" /><br/>
<input type="radio" class="radio" id="blogTemplate" name="blogTemplate" value="{$template->getName()}" {if $blogTemplate==$template->getName()}checked="checked"{/if} /> {$template->getName()}<br/>
{/foreach}
- {include file="$blogtemplate/validate.template" field=blogTemplate message="Please select a template for the blog"}
+ {include file="wizard/validate.template" field=blogTemplate message="Please select a template for the blog"}
</div>
</fieldset>
<div class="buttons">
@@ -51,4 +51,4 @@
<input type="hidden" name="ownerid" value="{$ownerid}"/>
</div>
</form>
-{include file="$blogtemplate/footer.template"}
+{include file="wizard/footer.template"}
Modified: plog/trunk/templates/wizard/step5.template
===================================================================
--- plog/trunk/templates/wizard/step5.template 2005-02-26 17:29:51 UTC (rev 1214)
+++ plog/trunk/templates/wizard/step5.template 2005-02-26 17:36:18 UTC (rev 1215)
@@ -1,4 +1,4 @@
-{include file="$blogtemplate/header.template" title="6 Done!" mode=install step=6}
+{include file="wizard/header.template" title="6 Done!" mode=install step=6}
<form method="post">
<fieldset class="inputField">
<div class="wizardInfo">
@@ -27,4 +27,4 @@
<input value="Go to administration interface" type="button" onClick="javascript:window.location='admin.php'" />
</div>
</form>
-{include file="$blogtemplate/footer.template"}
+{include file="wizard/footer.template"}
Modified: plog/trunk/templates/wizard/update1.template
===================================================================
--- plog/trunk/templates/wizard/update1.template 2005-02-26 17:29:51 UTC (rev 1214)
+++ plog/trunk/templates/wizard/update1.template 2005-02-26 17:36:18 UTC (rev 1215)
@@ -1,4 +1,4 @@
-{include file="$blogtemplate/header.template" title="1 Update" step=1 mode=update}
+{include file="wizard/header.template" title="1 Update" step=1 mode=update}
<form name="databaseInfo" method="post">
<fieldset class="inputField">
<legend>Database Info</legend>
@@ -49,4 +49,4 @@
<input type="submit" name="Next" value="Next »"/>
</div>
</form>
-{include file="$blogtemplate/footer.template"}
\ No newline at end of file
+{include file="wizard/footer.template"}
\ No newline at end of file
Modified: plog/trunk/templates/wizard/update2.template
===================================================================
--- plog/trunk/templates/wizard/update2.template 2005-02-26 17:29:51 UTC (rev 1214)
+++ plog/trunk/templates/wizard/update2.template 2005-02-26 17:36:18 UTC (rev 1215)
@@ -1,4 +1,4 @@
-{include file="$blogtemplate/header.template" step=2 title="2 Database Changes"}
+{include file="wizard/header.template" step=2 title="2 Database Changes"}
<form name="update2" method="post">
<fieldset class="inputField">
<legend>Database Changes</legend>
@@ -11,16 +11,28 @@
<div class="wizardInfo">
<img src="imgs/icon_info-16.png" alt="Info" class="wizardInfoIcon" />
<p class="wizardInfoText">
- All the necessary changes have been made to the database:<br/><br/>
- {$message}
- </p>
- </div>
+ {if $multipleSteps}
+ Processing {$numPosts} posts per step, out of {$totalPosts}.<br/>
+ Current step is {$curStep} out of {$numSteps}.<br/><br/>
+ Please wait... This process may take a while.
+ {else}
+ All the necessary changes have been made to the database:<br/><br/>
+ {$message}
+ {/if}
+ </p>
+ </div>
{/if}
</fieldset>
<div class="buttons">
<input type="button" name="Prev" value="« Previous" onClick="javascript:history.go(-1);" />
<input type="hidden" name="nextStep" value="Update3"/>
- <input type="submit" name="Next" value="Next »"/>
+ {if $multipleSteps}
+ <input type="submit" name="Continue" value="Continue..." />
+ <input type="hidden" name="curStep" value="{$curStep}" />
+ <input type="hidden" name="numPosts" value="{$numPosts}" />
+ {else}
+ <input type="submit" name="Next" value="Next »"/>
+ {/if}
</div>
</form>
-{include file="$blogtemplate/footer.template"}
\ No newline at end of file
+{include file="wizard/footer.template"}
\ No newline at end of file
Modified: plog/trunk/templates/wizard/update3.template
===================================================================
--- plog/trunk/templates/wizard/update3.template 2005-02-26 17:29:51 UTC (rev 1214)
+++ plog/trunk/templates/wizard/update3.template 2005-02-26 17:36:18 UTC (rev 1215)
@@ -1,4 +1,4 @@
-{include file="$blogtemplate/header.template" step=3 mode=update title="3 Data Changes"}
+{include file="wizard/header.template" step=3 mode=update title="3 Data Changes"}
<form name="update2" method="post">
<fieldset class="inputField">
<legend>Data Changes</legend>
@@ -11,7 +11,7 @@
<div class="wizardInfo">
<img src="imgs/icon_info-16.png" alt="Info" class="wizardInfoIcon" />
<p class="wizardInfoText">
- The table holding the posts has been updated successfully. In total, {$numPosts} posts have
+ The table holding the posts has been updated successfully. In total, {$totalPosts} posts have
been updated.<br/><br/>
The next step will repeat the same operation but for the rest of tables.
</p>
@@ -24,4 +24,4 @@
<input type="submit" name="Next" value="Next »"/>
</div>
</form>
-{include file="$blogtemplate/footer.template"}
\ No newline at end of file
+{include file="wizard/footer.template"}
\ No newline at end of file
Modified: plog/trunk/templates/wizard/update4.template
===================================================================
--- plog/trunk/templates/wizard/update4.template 2005-02-26 17:29:51 UTC (rev 1214)
+++ plog/trunk/templates/wizard/update4.template 2005-02-26 17:36:18 UTC (rev 1215)
@@ -1,4 +1,4 @@
-{include file="$blogtemplate/header.template" step=4 mode=upgrade title="4 Done!"}
+{include file="wizard/header.template" step=4 mode=upgrade title="4 Done!"}
<form method="post">
<fieldset class="inputField">
<legend>Upgrade Complete</legend>
@@ -30,4 +30,4 @@
<input value="Go to administration interface" type="button" onClick="javascript:window.location='admin.php'" />
</div>
</form>
-{include file="$blogtemplate/footer.template"}
+{include file="wizard/footer.template"}
Modified: plog/trunk/wizard.php
===================================================================
--- plog/trunk/wizard.php 2005-02-26 17:29:51 UTC (rev 1214)
+++ plog/trunk/wizard.php 2005-02-26 17:36:18 UTC (rev 1215)
@@ -7,7 +7,19 @@
//
// enable this for debugging purposes
//
- define( "DB_WIZARD_DEBUG", true );
+ define( "DB_WIZARD_DEBUG", false );
+
+ //
+ // in case you're having problems with time outs while upgrading (probably too
+ // many records) lower this figure
+ //
+ define( "WIZARD_MAX_RECORDS_PER_STEP", 500 );
+
+ //
+ // threshold that defines up to how many records we should not divide the
+ // transformations in more than one step
+ //
+ define( "WIZARD_MAX_RECORDS_THRESHOLD", 1000 );
// many hosts don't have this enabled and we, for the time being, need it...
ini_set("arg_seperator.output", "&");
@@ -1432,27 +1444,60 @@
*/
class UpdateStepThree extends Action
{
+ function UpdateStepThree( $actionInfo, $httpRequest )
+ {
+ $this->Action( $actionInfo, $httpRequest );
+
+ // load the current step, if any
+ $this->_curStep = $this->_request->getValue( "curStep" );
+ $this->_numPosts = $this->_request->getValue( "numPosts" );
+
+ print("cur step = ".$this->_curStep." - num posts = ".$this->_numPosts."<br/>");
+ }
- function getStatusId( $statusStr )
- {
- if( $statusStr == 'published' ) return POST_STATUS_PUBLISHED;
- if( $statusStr == 'draft' ) return POST_STATUS_DRAFT;
- if( $statusStr == 'deleted' ) return POST_STATUS_DELETED;
-
- return false;
- }
-
- function perform()
- {
+ function getStatusId( $statusStr )
+ {
+ if( $statusStr == 'published' ) return POST_STATUS_PUBLISHED;
+ if( $statusStr == 'draft' ) return POST_STATUS_DRAFT;
+ if( $statusStr == 'deleted' ) return POST_STATUS_DELETED;
+
+ return false;
+ }
+
+ function perform()
+ {
// get a connection to the db
$db = connectDb();
$dbPrefix = getDbPrefix();
+ $db->debug=false;
// no errors here
$errors = false;
+ // see how many records we have
+ $queryCount = "SELECT COUNT(*) AS total FROM {$dbPrefix}articles";
+ $result = $db->Execute( $queryCount );
+ $row = $result->FetchRow();
+ $numRecords = $row["total"];
+ $this->_totalPosts = $numRecords;
+ // check whether we should use multiple steps
+ $multipleSteps = ( $numRecords > WIZARD_MAX_RECORDS_THRESHOLD );
+ if( $multipleSteps ) {
+ // how many steps do we need?
+ $numSteps = ceil( $numRecords / WIZARD_MAX_RECORDS_PER_STEP );
+ $this->_numSteps = $numSteps;
+ print("using different steps! numSteps = $numSteps<br/>");
+ }
+
// run the query and loop through the results
$query = "SELECT * FROM {$dbPrefix}articles";
+ if( $multipleSteps ) {
+ // generate the LIMIT condition for this page
+ $query .= " LIMIT ".$this->_curStep*WIZARD_MAX_RECORDS_PER_STEP.", ".WIZARD_MAX_RECORDS_PER_STEP;
+ }
+
+ print("query = $query<br/>");
+
$result = $db->Execute( $query );
$tf = new TextFilter();
@@ -1468,7 +1513,7 @@
$mangledTopic = Db::qstr($tf->urlize( $row["topic"] ));
$status = $this->getStatusId( $row["old_status"] );
$artId = $row["id"];
- $catId = $row["category_id"];
+ $catId = $row["category_id"];
$query = "UPDATE {$dbPrefix}articles SET slug = '$mangledTopic', date = date, status = $status
WHERE id = $artId";
@@ -1485,9 +1530,12 @@
$res2 = $db->Execute( $query2 );
$res3 = $db->Execute( $query3 );
- if( !$res || !$res2 || !$res3 )
- $errors = true;
+ /*if( !$res || !$res2 || !$res3 )
+ $errors = true;*/
}
+
+ // check whether we've already done the last step or not
+ $lastStepDone = ( $this->_curStep >= $this->_numSteps );
// if error
if( $errors ) {
@@ -1497,12 +1545,23 @@
return false;
}
- $query1 = "ALTER TABLE {$dbPrefix}articles DROP COLUMN old_status, DROP COLUMN category_id";
- $db->Execute( $query1 );
+ //$query1 = "ALTER TABLE {$dbPrefix}articles DROP COLUMN old_status, DROP COLUMN category_id";
+ //$db->Execute( $query1 );
// if everyhting's fine, say so...
- $this->_view = new WizardView( "update3" );
- $this->_view->setValue( "numPosts", $numPosts );
+ if( !$multipleSteps || $lastStepDone ) {
+ $this->_view = new WizardView( "update3" );
+ $this->_view->setValue( "totalPosts", $this->_totalPosts );
+ }
+ else {
+ // if we're using multiple steps, show the same page
+ $this->_view = new WizardView( "update2" );
+ $this->_view->setValue( "numPosts", $numPosts );
+ $this->_view->setValue( "curStep", $this->_curStep+1 );
+ $this->_view->setValue( "totalPosts", $this->_totalPosts );
+ $this->_view->setValue( "numSteps", $this->_numSteps );
+ $this->_view->setValue( "multipleSteps", true );
+ }
return true;
}
More information about the pLog-svn
mailing list