[pLog-svn] r6973 - in plog/branches/lifetype-1.2: class/action/admin templates/admin

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Sat Jan 30 13:10:42 EST 2010


Author: jondaley
Date: 2010-01-30 13:10:42 -0500 (Sat, 30 Jan 2010)
New Revision: 6973

Modified:
   plog/branches/lifetype-1.2/class/action/admin/adminupdateglobalsettingsaction.class.php
   plog/branches/lifetype-1.2/templates/admin/globalsettings_url.template
Log:
we've never done validation on the global settings before, so there were a couple bugs related to that.  We now validate the custom url formats, to try to help people write good formats - we could probably do a better job of helping them with specific formats - maybe suggesting the default value?  maybe if it is empty, fill the default value back in?

Modified: plog/branches/lifetype-1.2/class/action/admin/adminupdateglobalsettingsaction.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/action/admin/adminupdateglobalsettingsaction.class.php	2010-01-30 05:14:45 UTC (rev 6972)
+++ plog/branches/lifetype-1.2/class/action/admin/adminupdateglobalsettingsaction.class.php	2010-01-30 18:10:42 UTC (rev 6973)
@@ -26,9 +26,11 @@
 			$this->registerFieldValidator( "blogId", new IntegerValidator(), true);
 			$this->registerFieldValidator( "show", new StringValidator(), true);
                 // TODO: how do we validate the data inside the array?
+                // except for the allowed_comment_html tags, we could do a regular StringValidator
+                // if we changed that field to be non-html, we'd be all set.  TODO in 2.0
 			$this->registerFieldValidator( "config", new ArrayValidator() );
 
-            $view = new AdminGlobalSettingsListView( $this->_blogInfo,  "");
+            $view = new AdminGlobalSettingsListView( $this->_blogInfo);
             $view->setErrorMessage( $this->_locale->tr("error_saving_site_config"));
             $this->setValidationErrorView( $view );
         }
@@ -38,10 +40,8 @@
             $valid = parent::validate();
 
             if($this->_form->isFieldValid("show")){
-                    // 'show' has now been validated,
-                    // so we can set our error view to a better page
-                $view = new AdminGlobalSettingsListView( $this->_blogInfo,
-                                                         $this->_request->getValue("show"));
+                $view = new AdminGlobalSettingsListView($this->_blogInfo,
+                                                        $this->_request->getValue( "show"));
                 $view->setErrorMessage( $this->_locale->tr("error_saving_site_config"));
                 $this->setValidationErrorView( $view );
             }
@@ -52,10 +52,6 @@
                 return false;
             }
 
-            $view = new AdminGlobalSettingsListView( $this->_blogInfo, "" );
-            $view->setErrorMessage( $this->_locale->tr("error_saving_site_config"));
-        	$this->setValidationErrorView( $view );
-
 	    	// all the settings come from a very nice array from the html form
             $this->_newConfigOpts = Array();
             $this->_newConfigOpts = $this->_request->getValue( "config" );
@@ -85,11 +81,24 @@
                 "resource_link_format",
                 "page_suffix_format");
 
+            if(!$this->_newConfigOpts["blog_link_format"] || $this->_newConfigOpts["blog_link_format"] == "/")
+                $this->_newConfigOpts["blog_link_format"] = "/$";
+
             foreach($customUrlFormats as $format){
                 if(isset($this->_newConfigOpts[$format])){
                     $val = $this->_newConfigOpts[$format];
                     $val = str_replace("\\", "/", $val);
                     $this->_newConfigOpts[$format] = $val;
+                    if(!$val){
+                        $this->_form->setFieldValidationStatus( "config[$format]", false );
+                        $valid = false;
+                    }
+                    else{
+                            // whenever we have an array validator, we need to manually set
+                            // the fieldValidationStatus, otherwise, they'll all be marked
+                            // as invalid, whenever any one of them is invalid
+                        $this->_form->setFieldValidationStatus( "config[$format]", true );
+                    }
                 }
             }
 
@@ -98,6 +107,11 @@
             if($blogId)
                 $this->_newConfigOpts["default_blog_id"] = $blogId;
 
+            if(!$valid){
+                $this->validationErrorProcessing();
+                return false;
+            }
+
             return true;
         }
 

Modified: plog/branches/lifetype-1.2/templates/admin/globalsettings_url.template
===================================================================
--- plog/branches/lifetype-1.2/templates/admin/globalsettings_url.template	2010-01-30 05:14:45 UTC (rev 6972)
+++ plog/branches/lifetype-1.2/templates/admin/globalsettings_url.template	2010-01-30 18:10:42 UTC (rev 6973)
@@ -28,72 +28,84 @@
     <label for="config[permalink_format]">permalink_format</label>
     <div class="formHelp">{$locale->tr("help_permalink_format")}</div>    
     <input style="width:100%" type="text" id="config[permalink_format]" name="config[permalink_format]" value="{$permalink_format}"/>
+    {include file="$admintemplatepath/validate.template" field="config[permalink_format]" message=$locale->tr("error_empty_text")}
    </div>
    <!-- category_link_format -->
    <div class="field">
     <label for="config[category_link_format]">category_link_format</label>
     <div class="formHelp">{$locale->tr("help_category_link_format")}</div>    
     <input style="width:100%" type="text" id="config[category_link_format]" name="config[category_link_format]" value="{$category_link_format}" />
+    {include file="$admintemplatepath/validate.template" field="config[category_link_format]" message=$locale->tr("error_empty_text")}
    </div>
    <!-- blog_link_format -->
    <div class="field">
     <label for="config[blog_link_format]">blog_link_format</label>
     <div class="formHelp">{$locale->tr("help_blog_link_format")}</div>    
     <input style="width:100%" type="text" id="config[blog_link_format]" name="config[blog_link_format]" value="{$blog_link_format}"/>
+    {include file="$admintemplatepath/validate.template" field=config[blog_link_format] message=$locale->tr("error_empty_text")}
    </div>   
    <!-- archive_link_format -->
    <div class="field">
     <label for="config[archive_link_format]">archive_link_format</label> 
     <div class="formHelp">{$locale->tr("help_archive_link_format")}</div>	
     <input style="width:100%" type="text" id="config[archive_link_format]" name="config[archive_link_format]" value="{$archive_link_format}"/>
+    {include file="$admintemplatepath/validate.template" field=config[archive_link_format] message=$locale->tr("error_empty_text")}
    </div>
    <!-- user_posts_link_format -->
    <div class="field">
     <label for="config[user_posts_link_format]">user_posts_link_format</label>
     <div class="formHelp">{$locale->tr("help_user_posts_link_format")}</div>	
     <input style="width:100%" type="text" id="config[user_posts_link_format]" name="config[user_posts_link_format]" value="{$user_posts_link_format}"/>    
+    {include file="$admintemplatepath/validate.template" field=config[user_posts_link_format] message=$locale->tr("error_empty_text")}
    </div>       
    <!-- post_trackbacks_link_format -->
    <div class="field">
     <label for="config[post_trackbacks_link_format]">post_trackbacks_link_format</label>
     <div class="formHelp">{$locale->tr("help_post_trackbacks_link_format")}</div>	
     <input style="width:100%" type="text" id="config[post_trackbacks_link_format]" name="config[post_trackbacks_link_format]" value="{$post_trackbacks_link_format}"/>    
+    {include file="$admintemplatepath/validate.template" field=config[post_trackbacks_link_format] message=$locale->tr("error_empty_text")}
    </div>
    <!-- template_link_format -->
    <div class="field">
     <label for="config[template_link_format]">template_link_format</label>
     <div class="formHelp">{$locale->tr("help_template_link_format")}</div>	
     <input style="width:100%" type="text" id="config[template_link_format]" name="config[template_link_format]" value="{$template_link_format}"/>
+    {include file="$admintemplatepath/validate.template" field=config[template_link_format] message=$locale->tr("error_empty_text")}
    </div>   
    <!-- album_link_format -->
    <div class="field">
     <label for="config[album_link_format]">album_link_format</label>
     <div class="formHelp">{$locale->tr("help_album_link_format")}</div>	
     <input style="width:100%" type="text" id="config[album_link_format]" name="config[album_link_format]" value="{$album_link_format}"/>
+    {include file="$admintemplatepath/validate.template" field=config[album_link_format] message=$locale->tr("error_empty_text")}
    </div>
    <!-- resource_link_format -->
    <div class="field">
     <label for="config[resource_link_format]">resource_link_format</label>
     <div class="formHelp">{$locale->tr("help_resource_link_format")}</div>	
     <input style="width:100%" type="text" id="config[resource_link_format]" name="config[resource_link_format]" value="{$resource_link_format}"/>
+    {include file="$admintemplatepath/validate.template" field=config[resource_link_format] message=$locale->tr("error_empty_text")}
    </div>
 <!--   
    <div class="field">
     <label for="config[resource_preview_link_format]">resource_preview_link_format</label>
     <div class="formHelp">{$locale->tr("help_resource_preview_link_format")}</div>	
     <input disabled="disabled" style="width:100%" type="text" id="config[resource_preview_link_format]" name="config[resource_preview_link_format]" value="{$resource_preview_link_format}"/>
+    {include file="$admintemplatepath/validate.template" field=config[resource_preview_link_format] message=$locale->tr("error_empty_text")}
    </div>
 
    <div class="field">
     <label for="config[resource_medium_size_preview_link_format]">resource_medium_size_preview_link_format</label>
     <div class="formHelp">{$locale->tr("help_resource_medium_size_preview_link_format")}</div>	
     <input disabled="disabled" style="width:100%" type="text" id="config[resource_medium_size_preview_link_format]" name="config[resource_medium_size_preview_link_format]" value="{$resource_medium_size_preview_link_format}"/>    
+    {include file="$admintemplatepath/validate.template" field=config[resource_medium_size_preview_link_format] message=$locale->tr("error_empty_text")}
    </div>   
 
    <div class="field">
     <label for="config[resource_download_link_format]">resource_download_link_format</label>
     <div class="formHelp">{$locale->tr("help_resource_download_link_format")}</div>	
     <input disabled="disabled" style="width:100%" type="text" id="config[resource_download_link_format]" name="config[resource_download_link_format]" value="{$resource_download_link_format}"/>
+    {include file="$admintemplatepath/validate.template" field=config[resource_download_link_format] message=$locale->tr("error_empty_text")}
    </div>
 -->
    <!-- page_suffix_format -->
@@ -101,5 +113,6 @@
     <label for="config[page_suffix_format]">page_suffix_format</label>
     <div class="formHelp">{$locale->tr("help_page_suffix_format")}</div>	
     <input style="width:100%" type="text" id="config[page_suffix_format]" name="config[page_suffix_format]" value="{$page_suffix_format}"/>
+    {include file="$admintemplatepath/validate.template" field=config[page_suffix_format] message=$locale->tr("error_empty_text")}
    </div>   
 </div>



More information about the pLog-svn mailing list