[pLog-svn] r6522 - in plog/branches/lifetype-1.2: class/action/admin templates/admin
mark at devel.lifetype.net
mark at devel.lifetype.net
Mon Jun 9 03:06:40 EDT 2008
Author: mark
Date: 2008-06-09 03:06:39 -0400 (Mon, 09 Jun 2008)
New Revision: 6522
Modified:
plog/branches/lifetype-1.2/class/action/admin/adminupdatecustomfieldaction.class.php
plog/branches/lifetype-1.2/templates/admin/editcustomfield.template
plog/branches/lifetype-1.2/templates/admin/newcustomfield.template
Log:
1. fieldHidden & filedSearchable are optional
2. fieldValues only validate with array & string validator when filedType == CUSTOM_FIELD_LIST
3. fix appendList and removeSelected functions.
Modified: plog/branches/lifetype-1.2/class/action/admin/adminupdatecustomfieldaction.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/action/admin/adminupdatecustomfieldaction.class.php 2008-06-09 06:15:44 UTC (rev 6521)
+++ plog/branches/lifetype-1.2/class/action/admin/adminupdatecustomfieldaction.class.php 2008-06-09 07:06:39 UTC (rev 6522)
@@ -5,6 +5,7 @@
lt_include( PLOG_CLASS_PATH."class/dao/customfields/customfields.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" );
lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" );
+ lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" );
/**
* \ingroup Action
@@ -32,11 +33,17 @@
$this->registerFieldValidator( "fieldDescription", new StringValidator());
$this->registerFieldValidator( "fieldType", new IntegerValidator());
$this->registerFieldValidator( "fieldId", new IntegerValidator());
- // TODO: validate all of these
- $this->_form->registerField( "fieldSearchable" );
- $this->_form->registerField( "fieldHidden" );
- $this->_form->registerField( "fieldValues" );
- $this->setValidationErrorView( new AdminTemplatedView( $this->_blogInfo, "editcustomfield" ));
+ $this->registerFieldValidator( "fieldSearchable", new IntegerValidator(), true );
+ $this->registerFieldValidator( "fieldHidden", new IntegerValidator(), true );
+ $this->_fieldType = $this->_request->getValue( "fieldType" );
+ if( $this->_fieldType == CUSTOM_FIELD_LIST )
+ {
+ $this->registerFieldValidator( "fieldValues", new ArrayValidator( new StringValidator() ), true );
+ }
+
+ $view = new AdminTemplatedView( $this->_blogInfo, "editcustomfield" );
+ $view->setErrorMessage( $this->_locale->tr("error_updating_custom_field" ));
+ $this->setValidationErrorView( $view );
$this->requirePermission( "update_custom_field" );
}
@@ -50,16 +57,18 @@
$this->_fieldId = $this->_request->getValue( "fieldId" );
$this->_fieldName = Textfilter::filterAllHTML($this->_request->getValue( "fieldName" ));
$this->_fieldDescription = Textfilter::filterAllHTML($this->_request->getValue( "fieldDescription" ));
- $this->_fieldType = $this->_request->getValue( "fieldType" );
- $this->_fieldSearchable = $this->_request->getValue( "fieldSearchable" );
- $this->_fieldHidden = $this->_request->getValue( "fieldHidden" );
+ $this->_fieldSearchable = ( $this->_request->getValue( "fieldSearchable" ) != "" );
+ $this->_fieldHidden = ( $this->_request->getValue( "fieldHidden" ) != "" );
// get and pre-process the field values
if( $this->_fieldType == CUSTOM_FIELD_LIST ) {
$values = $this->_request->getValue( "fieldValues" );
$this->_fieldValues = Array();
- foreach( $values as $value ) {
- $this->_fieldValues[] = Textfilter::filterAllHTML( $value );
+ if( $values )
+ {
+ foreach( $values as $value ) {
+ $this->_fieldValues[] = Textfilter::filterAllHTML( $value );
+ }
}
}
Modified: plog/branches/lifetype-1.2/templates/admin/editcustomfield.template
===================================================================
--- plog/branches/lifetype-1.2/templates/admin/editcustomfield.template 2008-06-09 06:15:44 UTC (rev 6521)
+++ plog/branches/lifetype-1.2/templates/admin/editcustomfield.template 2008-06-09 07:06:39 UTC (rev 6522)
@@ -45,8 +45,8 @@
{/foreach}
</select>
<br />
- <input type="button" class="button" {literal}onClick="newValue=window.prompt('Enter new value for the custom field');if(newValue!=null){appendDocumentList(document,'fieldValues',newValue,newValue);}"{/literal} value="{$locale->tr("add")}" />
- <input type="button" class="button" onClick="removeSelectedItemsFromList(document.getElementById('fieldValues'))" value="{$locale->tr("remove_selected")}" />
+ <input type="button" class="button" {literal}onClick="newValue=window.prompt('Enter new value for the custom field');if(newValue!=''){appendDocumentList(document,'fieldValues',newValue,newValue);}"{/literal} value="{$locale->tr("add")}" />
+ <input type="button" class="button" onClick="Lifetype.Forms.List.removeSelected('fieldValues')" value="{$locale->tr("remove_selected")}" />
</div>
<div class="field">
@@ -60,6 +60,7 @@
</fieldset>
<div class="buttons">
+ <input type="hidden" name="fieldSearchable" value="1" />
<input type="hidden" name="op" value="updateCustomField" />
<input type="hidden" name="fieldId" value="{$fieldId}" />
<input type="reset" name="Rest" value="{$locale->tr("reset")}" />
Modified: plog/branches/lifetype-1.2/templates/admin/newcustomfield.template
===================================================================
--- plog/branches/lifetype-1.2/templates/admin/newcustomfield.template 2008-06-09 06:15:44 UTC (rev 6521)
+++ plog/branches/lifetype-1.2/templates/admin/newcustomfield.template 2008-06-09 07:06:39 UTC (rev 6522)
@@ -45,8 +45,8 @@
{/foreach}
</select>
<br />
- <input type="button" class="button" {literal}onClick="newValue=window.prompt('Enter new value for the custom field');if(newValue!=null){appendDocumentList(document,'fieldValues',newValue,newValue);}"{/literal} value="{$locale->tr("add")}" />
- <input type="button" class="button" onClick="removeSelectedItemsFromList(document.getElementById('fieldValues'))" value="{$locale->tr("remove_selected")}" />
+ <input type="button" class="button" {literal}onClick="newValue=window.prompt('Enter new value for the custom field');if(newValue!=''){appendDocumentList(document,'fieldValues',newValue,newValue);}"{/literal} value="{$locale->tr("add")}" />
+ <input type="button" class="button" onClick="Lifetype.Forms.List.removeSelected('fieldValues')" value="{$locale->tr("remove_selected")}" />
</div>
<div class="field">
More information about the pLog-svn
mailing list