[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/view/admin/admincustomfieldslistview.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/dao/customfields/customfields.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" ); 8 9 /** 10 * \ingroup Action 11 * @private 12 * 13 * updates a custom field 14 */ 15 class AdminUpdateCustomFieldAction extends AdminAction 16 { 17 18 var $_fieldName; 19 var $_fieldDescription; 20 var $_fieldType; 21 var $_fieldSearchable; 22 var $_fieldId; 23 var $_fieldHidden; 24 var $_fieldValues; 25 26 function AdminUpdateCustomFieldAction( $actionInfo, $request ) 27 { 28 $this->AdminAction( $actionInfo, $request ); 29 30 // data validation 31 $this->registerFieldValidator( "fieldName", new StringValidator()); 32 $this->registerFieldValidator( "fieldDescription", new StringValidator()); 33 $this->registerFieldValidator( "fieldType", new IntegerValidator()); 34 $this->registerFieldValidator( "fieldId", new IntegerValidator()); 35 $this->_form->registerField( "fieldSearchable" ); 36 $this->_form->registerField( "fieldHidden" ); 37 $this->_form->registerField( "fieldValues" ); 38 $this->setValidationErrorView( new AdminTemplatedView( $this->_blogInfo, "editcustomfield" )); 39 40 $this->requirePermission( "update_custom_field" ); 41 } 42 43 /** 44 * Carries out the specified action 45 */ 46 function perform() 47 { 48 // fetch the fields from the request 49 $this->_fieldId = $this->_request->getValue( "fieldId" ); 50 $this->_fieldName = Textfilter::filterAllHTML($this->_request->getValue( "fieldName" )); 51 $this->_fieldDescription = Textfilter::filterAllHTML($this->_request->getValue( "fieldDescription" )); 52 $this->_fieldType = $this->_request->getValue( "fieldType" ); 53 $this->_fieldSearchable = $this->_request->getValue( "fieldSearchable" ); 54 $this->_fieldHidden = $this->_request->getValue( "fieldHidden" ); 55 56 // get and pre-process the field values 57 if( $this->_fieldType == CUSTOM_FIELD_LIST ) { 58 $values = $this->_request->getValue( "fieldValues" ); 59 $this->_fieldValues = Array(); 60 foreach( $values as $value ) { 61 $this->_fieldValues[] = Textfilter::filterAllHTML( $value ); 62 } 63 } 64 65 // and start to update the field 66 $fields = new CustomFields(); 67 $field = $fields->getCustomField( $this->_fieldId ); 68 69 // view that we're going to use for all different flows... 70 $this->_view = new AdminCustomFieldsListView( $this->_blogInfo ); 71 72 // field couldn't be loaded... 73 if( !$field ) { 74 $this->_view->setErrorMessage( $this->_locale->tr("error_updating_custom_field" )); 75 return false; 76 } 77 78 // ...update its information... 79 $field->setName( $this->_fieldName ); 80 $field->setDescription( $this->_fieldDescription ); 81 $field->setType( $this->_fieldType ); 82 $field->setHidden( $this->_fieldHidden ); 83 84 // save the values if this field is a list 85 if( $this->_fieldType == CUSTOM_FIELD_LIST ) 86 $field->setFieldValues( $this->_fieldValues ); 87 88 // fire the pre-event 89 $this->notifyEvent( EVENT_PRE_CUSTOM_FIELD_UPDATE, Array( "field" => &$field )); 90 91 // ...and finally the data in the database 92 $result = $fields->updateCustomField( $field ); 93 94 // check the result 95 96 if( !$result ) { 97 $this->_view->setErrorMessage( $this->_locale->tr("error_updating_custom_field" )); 98 } 99 else { 100 $this->_view->setSuccessMessage( $this->_locale->pr( "custom_field_updated_ok", $field->getName())); 101 // fire the post-event 102 $this->notifyEvent( EVENT_POST_CUSTOM_FIELD_UPDATE, Array( "field" => &$field )); 103 } 104 105 $this->setCommonData(); 106 107 return true; 108 } 109 } 110 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |