Index: trunk/core/units/general/cat_dbitem_export.php =================================================================== diff -u -N -r6583 -r7391 --- trunk/core/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 6583) +++ trunk/core/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 7391) @@ -1,6 +1,7 @@ SetDBField($field_name, isset($sample_value) && $sample_value ? $sample_value : 'no value'); + $object->SetField($field_name, isset($sample_value) && $sample_value ? $sample_value : 'no value'); } + $object->UpdateFormattersSubFields(); if ($set_status && $has_empty) { $object->SetDBField('Status', 0); @@ -374,49 +376,35 @@ } function getPlainExportSQL($count_only = false) { - if ($count_only && isset($this->exportOptions['ForceCountSQL'])) return $this->exportOptions['ForceCountSQL']; - if (!$count_only && isset($this->exportOptions['ForceSelectSQL'])) return $this->exportOptions['ForceSelectSQL']; + if ($count_only && isset($this->exportOptions['ForceCountSQL'])) { + $sql = $this->exportOptions['ForceCountSQL']; + } + elseif (!$count_only && isset($this->exportOptions['ForceSelectSQL'])) { + $sql = $this->exportOptions['ForceSelectSQL']; + } + else { + $items_list =& $this->Application->recallObject($this->curItem->Prefix.'.export-items-list', $this->curItem->Prefix.'_List'); + $items_list->SetPerPage(-1); - $items_list =& $this->Application->recallObject($this->curItem->Prefix.'.export-items-list', $this->curItem->Prefix.'_List'); - $items_list->SetPerPage(-1); - return $items_list->GetSelectSQL($count_only); - - - if ($this->exportOptions['export_ids'] === false) - { - // get links from current category & all it's subcategories - $join_clauses = Array(); - - $custom_sql = $this->getCustomSQL(); - if ($custom_sql) { - $custom_table = $this->Application->getUnitOption($this->curItem->Prefix.'-cdata', 'TableName'); - $join_clauses[$custom_table.' custom_data'] = 'custom_data.ResourceId = item_table.ResourceId'; + if ($options['export_ids'] != '') { + $items_list->AddFilter('export_ids', $items_list->TableName.'.'.$items_list->IDField.' IN ('.implode(',',$options['export_ids']).')'); } - $sql = 'SELECT item_table.*'.($custom_sql ? ', '.$custom_sql : '').' - FROM '.$this->curItem->TableName.' item_table'; - - foreach ($join_clauses as $table_name => $join_expression) { - $sql .= ' LEFT JOIN '.$table_name.' ON '.$join_expression; + if ($count_only) { + $sql = $items_list->getCountSQL( $items_list->GetSelectSQL(true,false) ); } - $sql .= ' WHERE 1'; - - $sql .= ' ORDER BY item_table.'.$this->curItem->IDField.' ASC'; // NEW + else { + $sql = $items_list->GetSelectSQL(); + } } - else { - // get only selected links - $sql = 'SELECT item_table.* - FROM '.$this->curItem->TableName.' item_table - WHERE '.$this->curItem->IDField.' IN ('.implode(',', $this->exportOptions['export_ids']).')'; - } if (!$count_only) { $sql .= ' LIMIT '.$this->exportOptions['start_from'].','.EXPORT_STEP; } - else { - $sql = preg_replace("/^.*SELECT(.*?)FROM(?!_)/is", "SELECT COUNT(*) AS count FROM ", $sql); - } +// else { +// $sql = preg_replace("/^.*SELECT(.*?)FROM(?!_)/is", "SELECT COUNT(*) AS count FROM ", $sql); +// } return $sql; } @@ -617,7 +605,8 @@ $this->dummyCategory =& $this->Application->recallObject('c.-tmpitem', 'c', Array('skip_autoload' => true)); fseek($this->filePointer, $this->exportOptions['start_from']); - while (($bytes_imported < IMPORT_CHUNK) && !feof($this->filePointer)) { + $items_processed = 0; + while (($bytes_imported < IMPORT_CHUNK && $items_processed < IMPORT_STEP) && !feof($this->filePointer)) { $data = $this->readRecord(); if ($data) { if ($this->exportOptions['ReplaceDuplicates']) { @@ -628,6 +617,7 @@ $this->processCurrentItem($event, $data); } $bytes_imported = ftell($this->filePointer) - $this->exportOptions['start_from']; + $items_processed++; } $this->closeFile(); @@ -860,6 +850,7 @@ // $sql_start = getmicrotime(); if (!$this->curItem->$save_method()) { + $this->Application->SetVar('m_cat_id', $backup_category_id); return false; } // $sql_end = getmicrotime(); @@ -961,7 +952,7 @@ } elseif (substr($field, 0, 11) == '__VIRTUAL__') { $field = substr($field, 11); - return $this->curItem->GetField($field); + $ret = $this->curItem->GetField($field); } else {