Beispiel #1
0
 public function toObject(array $import, $type = 'both')
 {
     $fields = array('pff_id' => 0, 'pff_pageform_id' => 0, 'pff_key' => '', 'pff_field_type' => '', 'pff_validation' => '', 'pff_date_created' => '', 'pff_date_updated' => '', 'pff_place' => 0);
     $tslFields = array('pfft_id' => 0, 'pfft_field_id' => 0, 'pfft_name' => '', 'pfft_language' => '', 'pfft_date_created' => '', 'pfft_date_updated' => '', 'pfft_place' => 0);
     foreach ($import as $key => $value) {
         if (array_key_exists($key, $fields)) {
             $fields[$key] = $value;
         }
     }
     foreach ($import as $key => $value) {
         if (array_key_exists($key, $tslFields)) {
             $tslFields[$key] = $value;
         }
     }
     if ($type == 'both' || $type == 'item') {
         $item = new SxModule_Pageform_Field();
         $item->setId((int) $fields['pff_id'])->setpageformId((int) $fields['pff_pageform_id'])->setKey($fields['pff_key'])->setFieldType($fields['pff_field_type'])->setValidation($fields['pff_validation'])->setDateCreated($fields['pff_date_created'])->setDateUpdated($fields['pff_date_updated'])->setPlace($fields['pff_place']);
     }
     if ($type == 'both' || $type == 'tsl') {
         $tsl = new SxModule_Pageform_Field_Tsl();
         $tsl->setId((int) $tslFields['pfft_id'])->setFieldId((int) $tslFields['pfft_field_id'])->setName($tslFields['pfft_name'])->setLanguage($tslFields['pfft_language'])->setDateCreated($tslFields['pfft_date_created'])->setDateUpdated($tslFields['pfft_date_updated'])->setPlace($tslFields['pfft_place']);
         if ($type == 'both') {
             $item->setTsl($tsl);
         } else {
             $item = $tsl;
         }
     }
     return $item;
 }
 public function mapFieldsToObjects($fields, $id = 0)
 {
     $objects = array();
     $system = new Zend_Session_Namespace('System');
     $user = Zend_Auth::getInstance()->getIdentity();
     $pageform = new SxModule_Pageform();
     $pageform->setId((int) $id)->setName($this->_getParam('pf_name'))->setContent($this->_getParam('pf_content'))->setMailoption($this->_getParam('pf_mailoption'))->setMailto($this->_getParam('pf_mailto'))->setPages($this->_getParam('pages'))->setCaptcha($this->_getParam('pf_captcha') ? 1 : 0);
     $pageform_tsl = new SxModule_Pageform_Tsl();
     $pageform_tsl->setId($this->_getParam('pf_tsl_id'))->setLanguage($system->lng)->setPageformId((int) $id)->setName($this->_getParam('pf_name'))->setContent($this->_getParam('pf_content'))->setConfirm($this->_getParam('pf_confirm'))->setConfirmto($this->_getParam('pf_confirmto'))->setConfirmsubject($this->_getParam('pf_confirmsubject'))->setConfirmcontent($this->_getParam('pf_confirmcontent'))->setActive($this->_getParam('pf_active'));
     $pageform->setTsl($pageform_tsl);
     foreach ($fields as $field) {
         $object = new SxModule_Pageform_Field();
         $object->setId($field['id'])->setKey($this->toKey($field['name']))->setFieldType($field['type'])->setValidation($field['validation']);
         if (isset($field['option'])) {
             foreach ($field['option'] as $values) {
                 $meta = new SxModule_Pageform_Field_Meta();
                 $meta->setId($values['id']);
                 $meta_tsl = new SxModule_Pageform_Field_Meta_Tsl();
                 $meta_tsl->setLanguage($system->lng)->setId($values['tsl-id'])->setName($values['name'])->setValue($values['key']);
                 $meta->setTsl($meta_tsl);
                 $object->addMeta($meta);
             }
         }
         $object_tsl = new SxModule_Pageform_Field_Tsl();
         $object_tsl->setId($field['tsl-id'])->setName($field['name'])->setLanguage($system->lng);
         $object->setTsl($object_tsl);
         $pageform->addField($object);
     }
     return $pageform;
 }