function migrate_insert_meta($collectionid, $baseid, $fields, &$db, $db_prefix, &$db2) { $name = preg_replace("/([kK]\\.[[:space:]]*[aA])\\.?/", "", trim(stripslashes($fields['name']))); if (strlen($name) > 0 and strlen($fields['vorname']) > 0) { $artistname = $name . ", " . trim(stripslashes($fields['vorname'])); } else { $artistname = ''; } $sql = "REPLACE INTO `{$db_prefix}meta` (`collectionid`" . ", `imageid`" . ", `type`" . ", `status`" . ", `addition`" . ", `title`" . ", `dating`" . ", `material`" . ", `technique`" . ", `format`" . ", `institution`" . ", `literature`" . ", `page`" . ", `figure`" . ", `table`" . ", `isbn`" . ", `keyword`" . ", `insert_date`" . ", `modify_date`" . ", `name1id`" . ", `name2id`" . ", `locationid`" . ", `exp_prometheus`" . ", `exp_sid`" . ", `exp_unimedia`" . ", `metacreator`" . ", `name1`" . ", `location`" . ", `locationsounds`" . " ) VALUES (" . $db->qstr(trim(stripslashes($collectionid))) . ", " . $fields['bildid'] . ", 'image'" . ", 'new'" . ", " . $db->qstr(trim(stripslashes($fields['zusatz']))) . ", " . $db->qstr(trim(stripslashes($fields['titel']))) . ", " . $db->qstr(trim(stripslashes($fields['datierung']))) . ", " . $db->qstr(trim(stripslashes($fields['material']))) . ", " . $db->qstr(trim(stripslashes($fields['technik']))) . ", " . $db->qstr(trim(stripslashes($fields['format']))) . ", " . $db->qstr(trim(stripslashes($fields['institution']))) . ", " . $db->qstr(trim(stripslashes($fields['literatur']))) . ", " . $db->qstr(trim(stripslashes($fields['seite']))) . ", " . $db->qstr(trim(stripslashes($fields['abbildung']))) . ", " . $db->qstr(trim(stripslashes($fields['tafel']))) . ", " . $db->qstr(trim(stripslashes($fields['isbn']))) . ", " . $db->qstr(trim(stripslashes($fields['stichworte']))) . ", " . $db->qstr(trim(stripslashes($fields['insert_date']))) . ", " . $db->qstr(trim(stripslashes($fields['modify_date']))) . ", 1, 0, 1" . ", 0, 0, 0" . ", 'dilps-import'" . ", " . $db->qstr($artistname) . ", " . $db->qstr(trim(stripslashes($fields['stadt']))) . ", " . $db->qstr('.' . soundex2($db->qstr(trim(stripslashes($fields['stadt'])))) . '.') . ");"; echo "{$sql}\n<br>\n"; $db->Execute($sql); dating($db, stripslashes($fields['datierung']), $datelist); if (count($datelist)) { foreach ($datelist as $date) { $sql = "INSERT INTO {$db_prefix}dating(collectionid,imageid,`from`,`to`) VALUES(4,{$fields['bildid']},{$date['from']},{$date['to']})"; echo "{$sql}\n"; $db->Execute($sql); } } migrate_insert_img($collectionid, $baseid, $fields['bildid'], $db, $db_prefix, $db2); }
function migrate_insert_meta($collectionid, $baseid, $fields, &$db, $db_prefix, &$db2) { $name = preg_replace("/([kK]\\.[[:space:]]*[aA])\\.?/", "", trim(stripslashes($fields['name']))); // print_r($fields); if (strlen($name) > 0 and strlen($fields['vorname']) > 0) { $artistname = $name . ", " . trim(stripslashes($fields['vorname'])); } else { $artistname = ''; } $artistid = false; if ($artistname != '') { $artistid = migrate_get_or_set_artistid($artistname, $db, $db_prefix); } // echo ("Name: $artistname, ID: $artistid \n<br>\n"); $locationid = false; $locationname = trim(stripslashes($fields['stadt'])); if ($locationname != '') { $locationid = migrate_get_or_set_locationid($locationname, $collectionid . ':' . $fields['bildid'], $db, $db_prefix); } // echo ("Ort: $locationname, ID: $locationid \n<br>\n"); $sql = "INSERT INTO `{$db_prefix}meta` " . "(`collectionid`" . ", `imageid`" . ", `type`" . ", `status`" . ", `addition`" . ", `title`" . ", `dating`" . ", `material`" . ", `technique`" . ", `format`" . ", `institution`" . ", `literature`" . ", `page`" . ", `figure`" . ", `table`" . ", `isbn`" . ", `keyword`" . ", `insert_date`" . ", `modify_date`" . ($artistid !== false ? ", `name1id`" : '') . ($locationid !== false ? ", `locationid`" : '') . ", `exp_prometheus`" . ", `exp_sid`" . ", `exp_unimedia`" . ", `metacreator`" . ", `metaeditor`" . ", `name1`" . ", `location`" . ($locationname != '' && $locationid !== false ? ", `locationsounds`" : '') . ($artistname != '' && $artistid !== false ? ", `name1sounds`" : '') . " ) VALUES (" . intval($collectionid) . ", " . $fields['bildid'] . ", 'image'" . ", 'new'" . ", " . $db->qstr(trim(stripslashes($fields['zusatz']))) . ", " . $db->qstr(trim(stripslashes($fields['titel']))) . ", " . $db->qstr(trim(stripslashes($fields['datierung']))) . ", " . $db->qstr(trim(stripslashes($fields['material']))) . ", " . $db->qstr(trim(stripslashes($fields['technik']))) . ", " . $db->qstr(trim(stripslashes($fields['format']))) . ", " . $db->qstr(trim(stripslashes($fields['institution']))) . ", " . $db->qstr(trim(stripslashes($fields['literatur']))) . ", " . $db->qstr(trim(stripslashes($fields['seite']))) . ", " . $db->qstr(trim(stripslashes($fields['abbildung']))) . ", " . $db->qstr(trim(stripslashes($fields['tafel']))) . ", " . $db->qstr(trim(stripslashes($fields['isbn']))) . ", " . $db->qstr(trim(stripslashes($fields['stichworte']))) . ", " . $db->qstr(trim(stripslashes($fields['insert_date']))) . ", " . $db->qstr(trim(stripslashes($fields['modify_date']))) . ($artistid !== false ? ", " . intval($artistid) : '') . ($locationid !== false ? ", " . intval($locationid) : '') . ", 0, 0, 0" . ", 'dilps-import'" . ", 'dilps-import'" . ", " . $db->qstr($artistname) . ", " . $db->qstr($locationname) . ($locationname != '' && $locationid !== false ? ", " . $db->qstr(migrate_get_sounds_string($locationname)) : '') . ($artistname != '' && $artistid !== false ? ", " . $db->qstr(migrate_get_sounds_string($artistname)) : '') . ");"; // echo "$sql\n<br>\n"; $rs = $db->Execute($sql); echo "Inserting meta data: "; if ($rs) { echo "OK\n<br>\n"; } else { echo "<b>Failed</b>\n<br>\n"; echo "SQL: {$sql}\n<br>\n"; echo "\n<br>\n"; } // clear old dating information $sql = "DELETE FROM {$db_prefix}dating WHERE collectionid={$collectionid} AND imageid={$fields['bildid']}"; // echo "$sql\n"; $rs = $db->Execute($sql); echo "Clearing old dating information: "; if ($rs) { echo "OK\n<br>\n"; } else { echo "<b>Failed</b>\n<br>\n"; echo "SQL: {$sql}\n<br>\n"; echo "\n<br>\n"; } dating($db, stripslashes($fields['datierung']), $datelist); $rs2 = true; if (count($datelist)) { foreach ($datelist as $date) { $sql = "INSERT INTO {$db_prefix}dating(`collectionid`, `imageid`, `from`, `to`) " . "VALUES({$collectionid},{$fields['bildid']},{$date['from']},{$date['to']})"; $rs = $db->Execute($sql); } $rs2 = $rs2 && $rs; } echo "Inserting new dating information: "; if ($rs2) { echo "OK\n<br>\n"; } else { echo "<b>Failed</b>\n<br>\n"; echo "SQL: {$sql}\n<br>\n"; echo "\n<br>\n"; } migrate_insert_img($collectionid, $baseid, $fields['bildid'], $db, $db_prefix, $db2); }