/**
  * updateFileData
  * @param array $arrTypeProperties
  * @author Cornelius Hansjakob <*****@*****.**>
  * @version 1.0
  */
 protected final function updateFileData($strType, $arrTypeProperties)
 {
     if (count($this->setup->FileFields()) > 0) {
         $objGenTable = $this->getModelGenericData()->getGenericTable($strType . '-' . $this->setup->getFormId() . '-' . $this->setup->getFormVersion() . '-InstanceFiles');
         if (isset($arrTypeProperties['Version'])) {
             $strWhere = $objGenTable->getAdapter()->quoteInto($strType . 'Id = ?', $arrTypeProperties['Id']);
             $strWhere .= $objGenTable->getAdapter()->quoteInto(' AND version = ?', $arrTypeProperties['Version']);
             $strWhere .= $objGenTable->getAdapter()->quoteInto(' AND idLanguages = ?', $this->setup->getLanguageId());
         } else {
             $strWhere = $objGenTable->getAdapter()->quoteInto('id' . (substr($strType, strlen($strType) - 1) == 'y' ? ucfirst(rtrim($strType, 'y')) . 'ies' : ucfirst($strType) . 's') . ' = ?', $arrTypeProperties['Id']);
         }
         $objGenTable->delete($strWhere);
         /**
          * update the file instances table
          */
         foreach ($this->setup->FileFields() as $strField => $objField) {
             $intFieldId = $objField->id;
             $strTmpFileIds = trim($objField->getValue(), '[]');
             $arrFileIds = array();
             $arrFileIds = split('\\]\\[', $strTmpFileIds);
             if (count($arrFileIds) > 0) {
                 foreach ($arrFileIds as $intFileId) {
                     if ($intFileId != '') {
                         if (isset($arrTypeProperties['Version'])) {
                             $arrFileData = array($strType . 'id' => $arrTypeProperties['Id'], 'version' => $arrTypeProperties['Version'], 'idLanguages' => $this->setup->getLanguageId(), 'idFiles' => $intFileId, 'idFields' => $intFieldId);
                         } else {
                             $arrFileData = array('id' . (substr($strType, strlen($strType) - 1) == 'y' ? ucfirst(rtrim($strType, 'y')) . 'ies' : ucfirst($strType) . 's') => $arrTypeProperties['Id'], 'idFiles' => $intFileId, 'idFields' => $intFieldId);
                         }
                         $objGenTable->insert($arrFileData);
                     }
                 }
             }
         }
     }
 }
 /**
  * loadFileData
  * @param string $strType
  * @param array $arrTypeProperties
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 protected final function loadFileData($strType, $arrTypeProperties)
 {
     try {
         /**
          * generic form file fields
          */
         if (count($this->setup->FileFields()) > 0) {
             $objGenTable = $this->getModelGenericData()->getGenericTable($strType . '-' . $this->setup->getFormId() . '-' . $this->setup->getFormVersion() . '-InstanceFiles');
             $strTableName = $objGenTable->info(Zend_Db_Table_Abstract::NAME);
             $objSelect = $objGenTable->select();
             $objSelect->setIntegrityCheck(false);
             $objSelect->from($objGenTable->info(Zend_Db_Table_Abstract::NAME), array('idFiles', 'sortPosition'));
             $objSelect->join('fields', 'fields.id = `' . $objGenTable->info(Zend_Db_Table_Abstract::NAME) . '`.idFields', array('name'));
             $objSelect->where($strType . 'Id = ?', $arrTypeProperties['Id']);
             $objSelect->where('version = ?', $arrTypeProperties['Version']);
             $objSelect->where('idLanguages = ?', $this->Setup()->getLanguageId());
             $objSelect->order(array('sortPosition ASC'));
             $arrGenFormsData = $objGenTable->fetchAll($objSelect)->toArray();
             if (count($arrGenFormsData) > 0) {
                 $this->blnHasLoadedFileData = true;
                 foreach ($arrGenFormsData as $arrGenRowFormsData) {
                     if ($this->setup->getFileField($arrGenRowFormsData['name']) !== null) {
                         $strFileIds = $this->setup->getFileField($arrGenRowFormsData['name'])->getValue() . '[' . $arrGenRowFormsData['idFiles'] . ']';
                         $this->setup->getFileField($arrGenRowFormsData['name'])->setValue($strFileIds);
                     }
                 }
             }
         }
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
 /**
  * compareGenericFieldValues
  * @author Thomas Schedler <*****@*****.**>
  * @version 1.0
  */
 public function compareGenericFieldValues(GenericSetup &$objGenericSetup)
 {
     $this->core->logger->debug('massiveart->generic->data->GenericData->compareGenericFieldValues()');
     try {
         if (count($objGenericSetup->CoreFields()) > 0) {
             /**
              * for each core field, try to get the "old" value
              */
             foreach ($objGenericSetup->CoreFields() as $strField => $objField) {
                 if (!is_null($this->setup->getCoreField($strField))) {
                     $objField->setValue($this->setup->getCoreField($strField)->getValue());
                 }
             }
         }
         if (count($objGenericSetup->FileFields()) > 0) {
             /**
              * for each file field, try to get the "old" value
              */
             foreach ($objGenericSetup->FileFields() as $strField => $objField) {
                 if (!is_null($this->setup->getFileField($strField))) {
                     $objField->setValue($this->setup->getFileField($strField)->getValue());
                 }
             }
         }
         if (count($objGenericSetup->InstanceFields()) > 0) {
             /**
              * for each instance field, try to get the "old" values
              */
             foreach ($objGenericSetup->InstanceFields() as $strField => $objField) {
                 if (!is_null($this->setup->getInstanceField($strField))) {
                     $objField->setValue($this->setup->getInstanceField($strField)->getValue());
                 }
             }
         }
         // TODO : compare special fields
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }