[pLog-svn] r5211 - in plog/branches/lifetype-1.2: . templates/wizard

Mark Wu markplace at gmail.com
Wed Mar 28 14:23:21 EDT 2007


Hi Oscar:

I just add a new tab in update wizard to let user choose which resources
naming rule he wants to use. I also fixed the resource name converting bug.

But, I still need 1 or 2 days to finish the "fix 1.2.0 resource naming"
function.

Hi All:

If you encounter the resource naming problem, please use this revision to
test it works for your installation or not. And please kindly report any
problems. Thanks.

Mark

> -----Original Message-----
> From: plog-svn-bounces at devel.lifetype.net 
> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of 
> mark at devel.lifetype.net
> Sent: Thursday, March 29, 2007 2:19 AM
> To: plog-svn at devel.lifetype.net
> Subject: [pLog-svn] r5211 - in plog/branches/lifetype-1.2: . 
> templates/wizard
> 
> Author: mark
> Date: 2007-03-28 14:18:43 -0400 (Wed, 28 Mar 2007) New Revision: 5211
> 
> Removed:
>    plog/branches/lifetype-1.2/templates/wizard/update111.template
> Modified:
>    plog/branches/lifetype-1.2/templates/wizard/checks.template
>    plog/branches/lifetype-1.2/templates/wizard/header.template
>    plog/branches/lifetype-1.2/templates/wizard/update1.template
>    plog/branches/lifetype-1.2/templates/wizard/update2.template
>    plog/branches/lifetype-1.2/templates/wizard/update3.template
>    plog/branches/lifetype-1.2/wizard.php
> Log:
> 1. Add a new tab "options" into update wizard. User now can 
> choose which resource naming rule he want when upgrade 
> lifetype from 1.1 to 1.2
> 
> 2. Some cosmetic changes.
> 
> 3. Remove update111.template, I think we don't need it in 1.2 
> installation wizard
> 
> Modified: plog/branches/lifetype-1.2/templates/wizard/checks.template
> ===================================================================
> --- 
> plog/branches/lifetype-1.2/templates/wizard/checks.template	
> 2007-03-28 16:50:56 UTC (rev 5210)
> +++ 
> plog/branches/lifetype-1.2/templates/wizard/checks.template	
> 2007-03-28 18:18:43 UTC (rev 5211)
> @@ -1,4 +1,4 @@
> -{include file="wizard/header.template" title="1 
> Preinstallation Checks" step=1 mode=$mode}
> +{include file="wizard/header.template" 
> title="Preinstallation Checks" 
> +step=1 mode=$mode}
>   <form name="databaseInfo" action="wizard.php" method="post">
>    <fieldset class="inputField">
>     <legend>Requirements Checking</legend>  
> 
> Modified: plog/branches/lifetype-1.2/templates/wizard/header.template
> ===================================================================
> --- 
> plog/branches/lifetype-1.2/templates/wizard/header.template	
> 2007-03-28 16:50:56 UTC (rev 5210)
> +++ 
> plog/branches/lifetype-1.2/templates/wizard/header.template	
> 2007-03-28 18:18:43 UTC (rev 5211)
> @@ -39,9 +39,10 @@
>            {else}
>            <ul>
>  	       <li {if $step==1}class="currentStep"{/if}>1 Checks</li>
> -           <li {if $step==2}class="currentStep"{/if}>&raquo; 
> 2 Update</li>
> -           <li {if $step==3}class="currentStep"{/if}>&raquo; 
> 3 Database Changes</li>
> -           <li {if $step==5}class="currentStep"{/if}>&raquo; 
> 4 Done!</li>
> +           <li {if $step==2}class="currentStep"{/if}>&raquo; 
> 2 Configuration</li>
> +           <li {if $step==3}class="currentStep"{/if}>&raquo; 
> 3 Options</li>
> +           <li {if $step==4}class="currentStep"{/if}>&raquo; 
> 4 Database Changes</li>
> +           <li {if $step==5}class="currentStep"{/if}>&raquo; 5 
> + Done!</li>
>            </ul>
>            {/if}
>            <br style="clear:both;"/>
> 
> Modified: plog/branches/lifetype-1.2/templates/wizard/update1.template
> ===================================================================
> --- 
> plog/branches/lifetype-1.2/templates/wizard/update1.template	
> 2007-03-28 16:50:56 UTC (rev 5210)
> +++ 
> plog/branches/lifetype-1.2/templates/wizard/update1.template	
> 2007-03-28 18:18:43 UTC (rev 5211)
> @@ -1,4 +1,4 @@
> -{include file="wizard/header.template" title="Update" step=2 
> mode=update}
> +{include file="wizard/header.template" title="Configuration" step=2 
> +mode=update}
>  <form name="databaseInfo" method="post">  <fieldset 
> class="inputField">  <legend>Database Info</legend>
> 
> Deleted: 
> plog/branches/lifetype-1.2/templates/wizard/update111.template
> ===================================================================
> --- 
> plog/branches/lifetype-1.2/templates/wizard/update111.t
> emplate	2007-03-28 16:50:56 UTC (rev 5210)
> +++ 
> plog/branches/lifetype-1.2/templates/wizard/update111.t
> emplate	2007-03-28 18:18:43 UTC (rev 5211)
> @@ -1,45 +0,0 @@
> -{include file="wizard/header.template" step=4 mode=update 
> title="Changes in Resources"} -<form name="update3" 
> method="post" id="update3"> -<fieldset class="inputField"> 
> -<legend>Data Changes</legend> -{if $viewIsError}
> -    <div class="wizardError">
> -     <img src="imgs/admin/icon_error-16.png" alt="Error" 
> class="wizardInfoIcon" />
> -     <p style="color:red;margin-left:20px;">{$viewErrorMessage}</p>
> -     <p>You may choose to ignore this error and continue 
> with the data update process by
> -     clicking the "Continue" button below.
> -    </div>
> -{else}
> -   <div class="wizardInfo">
> -    <img src="imgs/admin/icon_info-16.png" alt="Info" 
> class="wizardInfoIcon" />
> -    <p class="wizardInfoText">
> -    {$message}
> -    </p>
> -   </div> 
> -{/if}
> -</fieldset>
> -<div class="buttons">
> -   {if !$complete}
> -   <input type="hidden" name="nextStep" value="Fix111"/>
> -   {else}
> -   {if !$viewIsError}
> -   <input type="hidden" name="nextStep" value="Update4"/>   
> -   <input type="submit" name="Prev" value="&laquo; Previous"/>   
> -   <input type="submit" name="Next" value="Next &raquo;"/>   
> -   {/if}
> -   {/if}
> -   {if $viewIsError}
> -     <input type="hidden" name="nextStep" value="Fix111"/>   
> -     <input type="submit" name="continue" value="Continue" />
> -   {/if}   
> -   <input type="hidden" name="page" value="{$nextStep}" />
> -   <input type="hidden" name="transformerId" 
> value="{$transformerId}" />
> -</div>
> -</form>
> -{if !$complete  && !$viewIsError}
> - <!-- let's make the document submit itself -->
> - <script type="text/javascript">
> -  document.update3.submit();
> - </script>
> -{/if}
> -{include file="wizard/footer.template"} \ No newline at end of file
> 
> Modified: plog/branches/lifetype-1.2/templates/wizard/update2.template
> ===================================================================
> --- 
> plog/branches/lifetype-1.2/templates/wizard/update2.template	
> 2007-03-28 16:50:56 UTC (rev 5210)
> +++ 
> plog/branches/lifetype-1.2/templates/wizard/update2.template	
> 2007-03-28 18:18:43 UTC (rev 5211)
> @@ -1,26 +1,33 @@
> -{include file="wizard/header.template" step=3 
> title="Database Changes"} -<form name="update2" id="update2" 
> method="post">
> +{include file="wizard/header.template" title="Options" step=3 
> +mode=update} <form name="options" method="post">
>  <fieldset class="inputField">
> -<legend>Database Changes</legend>
> +<legend>Options</legend>
>  {if $viewIsError}
> -    <div class="wizardError">
> +     <div class="wizardError">
>       <img src="imgs/admin/icon_error-16.png" alt="Error" 
> class="wizardInfoIcon" />
>       <p style="color:red;margin-left:20px;">{$viewErrorMessage}</p>
> -    </div>
> +    </div>
>  {else}
> -   <div class="wizardInfo">
> -    <img src="imgs/admin/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>      
> + <div class="wizardInfo">
> +  <img src="imgs/admin/icon_info-16.png" alt="Info" 
> class="wizardInfoIcon" />
> +   <p class="wizardInfoText">
> +  The following options will control the behavior of 
> database changing 
> + process. Please make sure  the options are correct and 
> press "Next" to 
> + move to the next step. The database changing process  is 
> inreversible, 
> + please backup your database if you have any concerns of the 
> changing 
> + process.</p>  </div>
>  {/if}
> -</fieldset>
> -<div class="buttons">
> -	<input type="button" name="Prev" value="&laquo; 
> Previous" onClick="javascript:history.go(-1);" />
> -   <input type="hidden" name="nextStep" value="Update3"/>
> -       <input type="submit" name="Next" value="Next &raquo;"/>
> -</div>
> -</form>
> -{include file="wizard/footer.template"} \ No newline at end of file
> +   <div class="field">
> +    <label for="resourcesNamingRule">Resource Naming Rules</label>
> +    <div class="formHelp">The file naming rules for uploaded 
> resources. 'Original File Name' use original file for 
> uploaded resources. 'Encoded File Name' use the encoded file 
> name for uploaded resources, the naming rule is 
> [BlogId]-[ResourceId].[Ext] as we implemented in LifeType 
> 1.1. <strong>Please use 'Encoded File Name' if you install 
> LifeType under Multi-Byte Microsoft Windows 
> environment.</strong></div>	
> +     <select name="resourcesNamingRule">
> +      <option value="original_file_name" {if 
> $resourcesNamingRule == "original_file_name"} 
> selected="selected" {/if} />Original File Name</option>
> +      <option value="encoded_file_name" {if 
> $resourcesNamingRule == "encoded_file_name"} 
> selected="selected" {/if} />Encoded File Name</option>
> +     </select>
> +   </div>
> +   </fieldset>
> +   <div class="buttons"> 
> +    <input type="hidden" name="nextStep" value="Update3"/>
> +    <input type="submit" name="Next" value="Next &raquo;"/>
> +   </div>
> + </form>
> +{include file="wizard/footer.template"}
> 
> Modified: plog/branches/lifetype-1.2/templates/wizard/update3.template
> ===================================================================
> --- 
> plog/branches/lifetype-1.2/templates/wizard/update3.template	
> 2007-03-28 16:50:56 UTC (rev 5210)
> +++ 
> plog/branches/lifetype-1.2/templates/wizard/update3.template	
> 2007-03-28 18:18:43 UTC (rev 5211)
> @@ -1,4 +1,4 @@
> -{include file="wizard/header.template" step=4 mode=update 
> title="Data Changes"}
> +{include file="wizard/header.template" step=4 mode=update 
> +title="Database Changes"}
>  <form name="update3" method="post" id="update3">  <fieldset 
> class="inputField">  <legend>Data Changes</legend> @@ -20,7 
> +20,7 @@  </fieldset>  <div class="buttons">
>     {if !$complete}
> -   <input type="hidden" name="nextStep" value="Update2"/>
> +   <input type="hidden" name="nextStep" value="Update3"/>
>     {else}
>     {if !$viewIsError}
>     <input type="hidden" name="nextStep" value="Update4"/>   
> @@ -29,15 +29,16 @@
>     {/if}
>     {/if}
>     {if $viewIsError}
> -     <input type="hidden" name="nextStep" value="Update2"/>   
> +     <input type="hidden" name="nextStep" value="Update3"/>   
>       <input type="submit" name="continue" value="Continue" />
>     {/if}   
>     <input type="hidden" name="page" value="{$nextStep}" />
>     <input type="hidden" name="transformerId" 
> value="{$transformerId}" />
> +   <input type="hidden" name="resourcesNamingRule" 
> + value="{$resourcesNamingRule}" />
>  </div>
>  
>  <!-- for debugging purposes only
> -  <input type="hidden" name="nextStep" value="Update3"/>   
> +  <input type="hidden" name="nextStep" value="Update4"/>
>    <input type="submit" name="continue" value="Continue" />
>    <input type="hidden" name="page" value="{$nextStep}" />
>    <input type="hidden" name="transformerId" 
> value="{$transformerId}" />
> 
> Modified: plog/branches/lifetype-1.2/wizard.php
> ===================================================================
> --- plog/branches/lifetype-1.2/wizard.php	2007-03-28 
> 16:50:56 UTC (rev 5210)
> +++ plog/branches/lifetype-1.2/wizard.php	2007-03-28 
> 18:18:43 UTC (rev 5211)
> @@ -89,6 +89,7 @@
>      $_actionMap["Step5"] = "WizardStepFive";
>      $_actionMap["Update1"] = "UpdateStepOne";
>      $_actionMap["Update2"] = "UpdateStepTwo";
> +    $_actionMap["Update3"] = "UpdateStepThree";
>  
>  
>      /**
> @@ -1312,6 +1313,20 @@
>              $this->setCommonData();
>          }
>      }
> +
> +    class UpdateStepTwo extends WizardAction
> +    {
> +        function perform()
> +        {
> +			include_once( 
> PLOG_CLASS_PATH."class/config/config.class.php" );
> +			$config =& Config::getConfig();
> +			$resourcesNamingRule = 
> $config->getValue( "resources_naming_rule", 
> +"original_file_name" );
> +			
> +            $this->_view = new WizardView( "update2" );
> +            $this->_view->setValue( "resourcesNamingRule", 
> $resourcesNamingRule );
> +            $this->setCommonData();
> +        }
> +    }
>      
>      /**
>       * Generic class that performs data updates on the 
> database @@ -1434,7 +1449,7 @@
>              $dict = NewPDbDataDictionary( $db );
>              $errors = false;
>  
> -			$this->message = "Performing changes to 
> the dabase schema, please wait (step 1 of 6)<br/>";
> +			$this->message = "Performing changes to 
> the dabase schema, please 
> +wait (step %s of %s)<br/>";
>  
>  			$errorMessage = "";
>  			$table_errors = false;
> @@ -1486,7 +1501,7 @@
>      
>          function perform()
>          {
> -            $this->message = "<b>Updating user permissions 
> (step 4 of 6)</b><br/><br/>";        
> +            $this->message = "Updating user permissions 
> (step %s of %s)<br/>";        
>          
>              $query3 = "SELECT * FROM 
> ".Db::getPrefix()."tmp_users_permissions";
>              $res3 = $this->Execute( $query3, $this->page, 
> $this->itemsPerPage ); @@ -1542,7 +1557,7 @@
>  		function perform()
>  		{
>  			// initial message, no errors yet
> -            $this->message = "<b>Loading new permissions 
> (step 2 of 6)</b><br/><br/>";			
> +            $this->message = "Loading new permissions (step 
> %s of %s)<br/>";			
>  			$errors = false;
>  			
>  			// load the core permissions
> @@ -1597,7 +1612,7 @@
>  		{
>  		    global $Inserts;	
>  			
> -            $this->message = "<b>Adding new configuration 
> parameters (step 4 of 6)</b><br/><br/>";
> +            $this->message = "Adding new configuration 
> parameters (step 
> + %s of %s)<br/>";
>  			$errors = false;
>  			
>              // Find some of the tools we are going to need 
> (last one is for os x, with fink installed), this will be 
> needed later on @@ -1678,7 +1693,7 @@
>              }			
>  
>  			if( !$errors ) {
> -				$this->message = "Configuration 
> settings updated successfully";
> +				$this->message .= 
> "Configuration settings updated successfully";
>  			}
>  			
>  			return( !$errors );
> @@ -1697,7 +1712,7 @@
>      
>          function perform()
>          {
> -            $this->message = "<b>Updating admin user 
> permissions (step 3 of 6)</b><br/><br/>";        
> +            $this->message = "Updating admin user 
> permissions (step %s of %s)<br/>";        
>          
>              // load each one of the categories and update them
>              // list of categories
> @@ -1730,7 +1745,7 @@
>  				$this->updatedRecords++;
>              }
>          
> -            $this->message .= "{$this->updatedRecords} users 
> updated (".$this->getPercentProcessed()."%)<br/>";
> +            $this->message .= "{$this->updatedRecords} users updated 
> + (".$this->getPercentProcessed()."%%)<br/>";
>              return true;        
>          }
>      }
> @@ -1747,7 +1762,7 @@
>      
>          function perform()
>          {
> -            $this->message = "<b>Updating resource files 
> (step 6 of 6)</b><br/><br/>";        
> +            $this->message = "Updating resource files (step 
> %s of %s)<br/>";        
>          
>              $query1 = "SELECT id, owner_id, file_name, 
> resource_type, thumbnail_format FROM 
> ".$this->dbPrefix."gallery_resources";
>  
> @@ -1861,31 +1876,51 @@
>       * the methods DatabaseDataTransformer::perform() and 
> DatabaseDataTransformer::getNumSteps(). The
>       * first does the data processing while the second one 
> returns the number of needed steps to the
>       * class running the transformer.
> -     * - Add the name of the transformer class to the the 
> UpdateStepTwo::transformers array,
> +     * - Add the name of the transformer class to the the 
> + UpdateStepThree::transformers array,
>       * and the class will take care of everything else. 
>       */
> -    class UpdateStepTwo extends WizardPagedAction
> +    class UpdateStepThree extends WizardPagedAction
>      {
> -        var $message;    
> +        var $resourcesNamingRule;
> +        var $message;
>          var $currentTransformerId;
> +        var $totalTransformers;
>      
> -        function UpdateStepTwo( $actionInfo, $httpRequest )
> +        function UpdateStepThree( $actionInfo, $httpRequest )
>          {
>              $this->WizardPagedAction( $actionInfo, $httpRequest );
> +            // data validation
> +            $this->registerFieldValidator( 
> "resourcesNamingRule", new StringValidator());
> +			$errorView = new WizardView( "update2" );
> +            $errorView->setErrorMessage( "Some data was 
> incorrect or missing." );
> +            $this->setValidationErrorView( $errorView );
>              
>              /**
>               * array with the data transformers that will be run
>               */
> -            $this->transformers = Array(
> -				"DatabaseSchemaDataTransformer",
> -				"PermissionLoader",
> -				"AdminUserPermissionsDataTransformer",
> -				"UserPermissionsDataTransformer",
> -				"ConfigDataTransformer",
> -				"ResourcesDataTransformer"
> -            );
> -            
> +			$this->resourcesNamingRule = 
> $this->_request->getValue( "resourcesNamingRule" );
> +			if( $this->resourcesNamingRule == 
> 'encoded_file_name' ) {
> +	            $this->transformers = Array(
> +					"DatabaseSchemaDataTransformer",
> +					"PermissionLoader",
> +					
> "AdminUserPermissionsDataTransformer",
> +					
> "UserPermissionsDataTransformer",
> +					"ConfigDataTransformer",
> +	            );
> +	        }
> +	        else {
> +	            $this->transformers = Array(
> +					"DatabaseSchemaDataTransformer",
> +					"PermissionLoader",
> +					
> "AdminUserPermissionsDataTransformer",
> +					
> "UserPermissionsDataTransformer",
> +					"ConfigDataTransformer",
> +					"ResourcesDataTransformer"
> +	            );
> +	    	}
> +
>              $this->currentTransformerId = 
> $this->getTransformerIdFromRequest();
> +            $this->totalTransformers = count( $this->transformers );
>          }
>          
>          /**
> @@ -1909,11 +1944,12 @@
>              $step = $this->getPageFromRequest();
>              
>              // get the current transformer class so that we 
> can continue where we left
> -            $transformerClass = 
> $this->transformers[$this->currentTransformerId];             
>                  
> +            $transformerClass = 
> + $this->transformers[$this->currentTransformerId];
>              $transformer = new $transformerClass( $step );
>              $result = $transformer->perform();
>              $complete = $transformer->isComplete();
>              $message = $transformer->message;
> +            $message = sprintf( $message, 
> $this->currentTransformerId + 
> + 1, $this->totalTransformers );
>              
>              //print("transformer = $transformerClass<br/>");
>               
> @@ -1922,6 +1958,7 @@
>              if( !$result && $transformer->failOnError ) {
>                  //print("Error in step = $step<br/>");
>                  $this->_view = new WizardView( "update3" );
> +                $this->_view->setValue( "resourcesNamingRule", 
> + $this->resourcesNamingRule );
>                  // current and next step
>                  $this->_view->setValue( "currentStep", $step );
>                  $this->_view->setValue( "nextStep", $step+1 
> );                
> @@ -1940,6 +1977,7 @@
>                  if( !$complete ) {
>                      //print("it's not complete! step = $step<br/>");
>                      $this->_view = new WizardView( "update3" );
> +                    $this->_view->setValue( "resourcesNamingRule", 
> + $this->resourcesNamingRule );
>                      // current and next step
>                      $this->_view->setValue( "currentStep", $step );
>                      $this->_view->setValue( "nextStep", 
> $step+1 );                
> @@ -1955,6 +1993,7 @@
>                      if( $moreTransformers ) {
>                          //print("Starting new transformer!<br/>");
>                          $this->_view = new WizardView( "update3" );
> +                        $this->_view->setValue( 
> "resourcesNamingRule", 
> + $this->resourcesNamingRule );
>                          // current and next step
>                          $this->_view->setValue( "currentStep", 0 );
>                          $this->_view->setValue( "nextStep", 
> 1 ); @@ -1970,6 +2009,9 @@
>  						$config =& 
> Config::getConfig();
>  						$tmpFolder = 
> $config->getValue( "temp_folder", TEMP_FOLDER );
>                          WizardTools::cleanTmpFolder();
> +                        
> +                        // save the resources naming rule to 
> config table
> +						
> $config->saveValue( "resources_naming_rule", 
> +$this->resourcesNamingRule );
>  
>                          $this->_view = new WizardView( "update4" );
>                      }
> 
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn



More information about the pLog-svn mailing list