[ 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/data/validator/stringvalidator.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 lt_include( PLOG_CLASS_PATH."class/view/admin/admintemplatedview.class.php" ); 9 lt_include( PLOG_CLASS_PATH."class/view/admin/admincustomfieldslistview.class.php" ); 10 11 /** 12 * \ingroup Action 13 * @private 14 * 15 * adds a custom field to the blog 16 */ 17 class AdminAddCustomFieldAction extends AdminAction 18 { 19 20 var $_fieldName; 21 var $_fieldDescription; 22 var $_fieldType; 23 var $_fieldSearchable; 24 var $_fieldHidden; 25 26 function AdminAddCustomFieldAction( $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->_form->registerField( "fieldSearchable" ); 35 $this->_form->registerField( "fieldHidden" ); 36 $this->_form->registerField( "fieldId" ); 37 $this->_form->registerField( "fieldValues" ); 38 $view = new AdminTemplatedView( $this->_blogInfo, "newcustomfield" ); 39 $view->setErrorMessage( $this->_locale->tr("error_adding_custom_field")); 40 $this->setValidationErrorView( $view ); 41 42 $this->requirePermission( "add_custom_field" ); 43 } 44 45 /** 46 * Carries out the specified action 47 */ 48 function perform() 49 { 50 // fetch the data 51 $this->_fieldName = Textfilter::filterAllHTML($this->_request->getValue( "fieldName" )); 52 $this->_fieldDescription = Textfilter::filterAllHTML($this->_request->getValue( "fieldDescription" )); 53 $this->_fieldType = $this->_request->getValue( "fieldType" ); 54 $this->_fieldSearchable = (int)($this->_request->getValue( "fieldSearchable" ) != "" ); 55 $this->_fieldHidden = (int)($this->_request->getValue( "fieldHidden" ) != "" ); 56 57 // get and pre-process the field values 58 if( $this->_fieldType == CUSTOM_FIELD_LIST ) { 59 $values = $this->_request->getValue( "fieldValues" ); 60 $this->_fieldValues = Array(); 61 foreach( $values as $value ) { 62 $this->_fieldValues[] = Textfilter::filterAllHTML( $value ); 63 } 64 } 65 66 $fields = new CustomFields(); 67 68 // build the new custom field 69 $customField = new CustomField( $this->_fieldName, 70 $this->_fieldDescription, 71 $this->_fieldType, 72 $this->_blogInfo->getId(), 73 $this->_fieldHidden, 74 $this->_fieldSearchable ); 75 // save the values if this field is a list 76 if( $this->_fieldType == CUSTOM_FIELD_LIST ) 77 $customField->setFieldValues( $this->_fieldValues ); 78 79 // throw the pre-event 80 $this->notifyEvent( EVENT_PRE_CUSTOM_FIELD_ADD, Array( "field" => &$customField )); 81 82 $result = $fields->addCustomField( $customField ); 83 84 if( $this->userHasPermission( "view_custom_fields" )) 85 $this->_view = new AdminCustomFieldsListView( $this->_blogInfo ); 86 else 87 $this->_view = new AdminTemplatedView( $this->_blogInfo, "newcustomfield" ); 88 89 if( !$result ) { 90 $this->_view->setErrorMessage( $this->_locale->tr("error_adding_custom_field" )); 91 } 92 else { 93 $this->_view->setSuccessMessage( $this->_locale->pr( "custom_field_added_ok", $customField->getName())); 94 95 // throw the post-event if all went fine 96 $this->notifyEvent( EVENT_POST_CUSTOM_FIELD_ADD, Array( "field" => &$customField )); 97 } 98 99 $this->setCommonData(); 100 101 return true; 102 } 103 } 104 ?>
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 |
![]() |