Index: branches/unlabeled/unlabeled-1.14.2/kernel/units/general/cat_dbitem_export.php =================================================================== diff -u -r4066 -r4152 --- branches/unlabeled/unlabeled-1.14.2/kernel/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 4066) +++ branches/unlabeled/unlabeled-1.14.2/kernel/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 4152) @@ -1,7 +1,7 @@ cacheTable = TABLE_PREFIX.'ImportCache'; } - + /** * Returns value from cache if found or false otherwise * @@ -103,7 +103,7 @@ function storeCache($cache_types) { $cache_types = explode(',', $cache_types); - + $values_sql = ''; foreach ($cache_types as $cache_type) { $sql_mask = '('.$this->Conn->qstr($cache_type).',%s,%s),'; @@ -119,20 +119,20 @@ $sql = 'INSERT INTO '.$this->cacheTable.'(`CacheName`,`VarName`,`VarValue`) VALUES '.$values_sql; $this->Conn->Query($sql); } - + } - + function loadCache() { $sql = 'SELECT * FROM '.$this->cacheTable; $records = $this->Conn->Query($sql); - + $this->cache = Array(); foreach ($records as $record) { $this->addToCache($record['CacheName'], $record['VarName'], $record['VarValue'], false); } } - + /** * Fill required fields with dummy values * @@ -546,7 +546,7 @@ else { $this->loadCache(); } - + $this->exportFields = $this->exportOptions['ExportColumns']; $this->addToCache('category_parent_path', $this->Application->GetVar('m_cat_id'), $this->exportOptions['ImportCategoryPath']); @@ -573,13 +573,13 @@ $this->exportOptions['start_from'] += $bytes_imported; $this->storeCache('new_ids'); - + $this->saveOptions($event); - + if ($this->exportOptions['start_from'] == $this->exportOptions['total_records']) { $this->Conn->Query('TRUNCATE TABLE '.$this->cacheTable); } - + return $this->exportOptions; } @@ -653,14 +653,14 @@ $this->setCurrentID(); } - + function getItemCategory() { $backup_category_id = $this->Application->GetVar('m_cat_id'); foreach ($this->curItem->CategoryPath as $category_index => $category_name) { if (!$category_name) continue; $category_key = crc32( implode(':', array_slice($this->curItem->CategoryPath, 0, $category_index + 1) ) ); - + $category_id = $this->getFromCache('category_names', $category_key); if ($category_id === false) { // get parent category path to search only in it @@ -697,10 +697,10 @@ if (!$this->curItem->CategoryPath) { $category_id = $backup_category_id; } - + return $category_id; } - + /** * Enter description here... * @@ -710,10 +710,10 @@ { $save_method = 'Create'; $load_keys = Array(); - + // create/update categories $backup_category_id = $this->Application->GetVar('m_cat_id'); - + // perform replace duplicates code if ($this->exportOptions['ReplaceDuplicates']) { // get replace keys first, then reset current item to empty one @@ -763,7 +763,7 @@ $this->resetImportObject($event, IMPORT_LIVE, $record_data); $category_id = $this->getItemCategory(); } - + // create main record if ($save_method == 'Create') { $this->fillRequiredFields($this->false, $this->curItem, true); @@ -775,7 +775,7 @@ } // $sql_end = getmicrotime(); // $this->saveLog('SQL ['.$save_method.'] Time: '.($sql_end - $sql_start).'s'); - + if ($load_keys && ($save_method == 'Create') && $this->exportOptions['ReplaceDuplicates']) { // map new id to old id $this->addToCache('new_ids', crc32($where_clause), $this->curItem->GetID() ); @@ -793,14 +793,14 @@ $this->Application->SetVar('m_cat_id', $backup_category_id); return true; } - + /*function saveLog($msg) { $fp = fopen(FULL_PATH.'/sqls.log', 'a'); fwrite($fp, $msg."\n"); fclose($fp); }*/ - + /** * Returns category parent path, if possible, then from cache * @@ -1044,15 +1044,15 @@ { return fgetcsv($this->filePointer, 10000, $this->exportOptions['FieldsSeparatedBy'], $this->exportOptions['FieldsEnclosedBy']); } - + function saveOptions(&$event, $options = null) { if (!isset($options)) { $options = $this->exportOptions; } $this->Application->StoreVar($event->getPrefixSpecial().'_options', serialize($options) ); } - + function loadOptions(&$event) { return unserialize($this->Application->RecallVar($event->getPrefixSpecial().'_options'));