Index: trunk/kernel/units/general/cat_dbitem_export.php =================================================================== diff -u -r3813 -r4043 --- trunk/kernel/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 3813) +++ trunk/kernel/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 4043) @@ -22,20 +22,6 @@ var $exportOptions = Array(); /** - * If we have custom fields in export - * - * @var unknown_type - */ - var $hasCustomFields = false; - - /** - * Custom field values for last item beeing exported - * - * @var Array - */ - var $customValues = Array(); - - /** * Item beeing currenly exported * * @var kCatDBItem @@ -394,11 +380,8 @@ $this->writeRecord($data_array); } $this->exportOptions['total_records'] = $this->Conn->GetOne( $this->getExportSQL(true) ); - $this->exportOptions['has_custom_fields'] = $this->scanCustomFields(); } - $this->hasCustomFields = $this->exportOptions['has_custom_fields']; - // 2. export data $records = $this->Conn->Query( $this->getExportSQL() ); $records_exported = 0; @@ -407,11 +390,7 @@ $this->curItem->SetDBFieldsFromHash($record_info); $this->setCurrentID(); $this->curItem->raiseEvent('OnAfterItemLoad', $this->curItem->GetID() ); - if ($this->hasCustomFields) - { - $this->loadItemCustomFields(); - } - + $data_array = Array(); foreach ($this->exportFields as $export_field) { @@ -501,7 +480,6 @@ fseek($this->filePointer, $this->exportOptions['start_from']); while (($bytes_imported < IMPORT_CHUNK) && !feof($this->filePointer)) { - $this->customValues = Array(); $data = $this->readRecord(); if ($data) { if ($this->exportOptions['ReplaceDuplicates']) { @@ -541,8 +519,8 @@ } if (substr($field_name, 0, 7) == 'Custom_') { - $field_name = substr($field_name, 7); - $this->customValues[$field_name] = $value; + $field_name = 'cust_'.substr($field_name, 7); + $this->curItem->SetField($field_name, $value); } elseif ($field_name == 'CategoryPath') { $this->curItem->CategoryPath = $value ? explode($this->exportOptions['CategorySeparator'], $value) : Array(); @@ -706,12 +684,6 @@ $this->addToCache('new_ids', $where_clause, $this->curItem->GetID() ); } - // set custom fields - foreach ($this->customValues as $custom_field => $custom_value) { - if (($save_method == 'Create') && !$custom_value) continue; - $this->curItem->SetCustomField($custom_field, $custom_value); - } - // assign item to categories $this->curItem->assignToCategory($category_id, false); @@ -738,15 +710,6 @@ return $parent_path; } - function loadItemCustomFields() - { - $sql = 'SELECT meta_data.Value, cf.FieldName - FROM '.TABLE_PREFIX.'CustomMetaData meta_data - LEFT JOIN '.TABLE_PREFIX.'CustomField cf ON cf.CustomFieldId = meta_data.CustomFieldId - WHERE meta_data.ResourceId = '.$this->curItem->GetDBField('ResourceId'); - $this->customValues = $this->Conn->GetCol($sql, 'FieldName'); - } - function getFileExtension() { return $this->exportOptions['ExportFormat'] == 1 ? 'csv' : 'xml'; @@ -757,21 +720,6 @@ return $this->exportOptions[$option] == 1 ? "\r\n" : "\n"; } - function scanCustomFields() - { - $ret = false; - $export_fields = $this->exportOptions['ExportColumns']; - foreach ($export_fields as $field) - { - if (substr($field, 0, 10) == '__CUSTOM__') - { - $ret = true; - break; - } - } - return $ret; - } - /** * Returns field caption for any exported field * @@ -808,8 +756,8 @@ function getFieldValue($field) { if (substr($field, 0, 10) == '__CUSTOM__') { - $field = substr($field, 10, strlen($field) ); - $ret = isset($this->customValues[$field]) ? $this->customValues[$field] : ''; + $field = 'cust_'.substr($field, 10, strlen($field)); + $ret = $this->curItem->GetField($field); } elseif (substr($field, 0, 12) == '__CATEGORY__') { return $this->getCategoryPath();