/** * 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); } }
/** * loadInstanceData * @param string $strType * @param array $arrTypeProperties * @author Thomas Schedler <*****@*****.**> * @version 1.0 */ protected final function loadInstanceData($strType, $arrTypeProperties) { try { /** * generic form instance fields */ if (count($this->setup->InstanceFields()) > 0) { $objGenTable = $this->getModelGenericData()->getGenericTable($strType . '-' . $this->setup->getFormId() . '-' . $this->setup->getFormVersion() . '-Instances'); $objSelect = $objGenTable->select(); $arrSelectFields = array(); /** * for each instance field, add to select array data array */ foreach ($this->setup->InstanceFields() as $strField => $objField) { $arrSelectFields[] = $strField; } $objSelect->from($objGenTable->info(Zend_Db_Table_Abstract::NAME), $arrSelectFields); $objSelect->where($strType . 'Id = ?', $arrTypeProperties['Id']); $objSelect->where('version = ?', $arrTypeProperties['Version']); $objSelect->where('idLanguages = ?', $this->Setup()->getLanguageId()); $arrGenFormsData = $objGenTable->fetchAll($objSelect)->toArray(); if (count($arrGenFormsData) > 0) { $this->blnHasLoadedInstanceData = true; foreach ($arrGenFormsData as $arrRowGenFormData) { foreach ($arrRowGenFormData as $column => $value) { if (is_array(json_decode($value))) { $this->setup->getInstanceField($column)->setValue(json_decode($value)); } else { $this->setup->getInstanceField($column)->setValue($value); } } } } } } catch (Exception $exc) { $this->core->logger->err($exc); } }