Index: trunk/extensions/Wikidata/util/copy.php |
— | — | @@ -230,84 +230,93 @@ |
231 | 231 | return $id; |
232 | 232 | } |
233 | 233 | |
| 234 | +function read_meaning_relations($dc1, $dmid) { |
| 235 | + return getrows($dc1,"meaning_relations","where meaning1_mid=$dmid"); |
| 236 | +} |
234 | 237 | |
235 | | -$start=stopwatch(); |
| 238 | +function write_meaning_relation($dc1, $dc2, $new_dmid, $relation) { |
| 239 | + $relation["relation_id"]=dupobject($relation["relation_id"]); |
| 240 | + $relation["meaning1_mid"]=$new_dmid; |
| 241 | + $relation["meaning2_mid"]=dup_defined_meaning($relation["meaning2_mid"],$dc1, $dc2); |
| 242 | +} |
236 | 243 | |
237 | | -$dmid=$_REQUEST['dmid']; |
238 | | -$dc1=$_REQUEST['dc1']; |
239 | | -$dc2=$_REQUEST['dc2']; |
| 244 | +function read_defined_meaning($dc1,$dmid) { |
| 245 | + return getrow($dc1,"defined_meaning","where defined_meaning_id=$dmid"); |
| 246 | +} |
240 | 247 | |
241 | 248 | |
242 | | -# dm |
243 | | -$dmid_esc=mysql_real_escape_string($dmid); |
| 249 | +function dup_defined_meaning ($dmid, $dc1, $dc2){ |
244 | 250 | |
245 | | -echo $dmid_esc; |
246 | | -$defined_meaning=mysql_real_escape_string("${dc1}_defined_meaning"); |
| 251 | + $defined_meaning=read_defined_meaning($dc1, $dmid); |
247 | 252 | |
248 | | -$query= |
249 | | -"SELECT * |
250 | | -FROM $defined_meaning |
251 | | -WHERE defined_meaning_id=$dmid_esc"; |
252 | | -echo $query; |
| 253 | + # bit of exp here too (defnitely need to tidy) |
| 254 | + $defining_expression=expression($defined_meaning["expression_id"], $dc1); |
| 255 | + var_dump($defining_expression); |
253 | 256 | |
254 | | -$result = mysql_query($query)or die ("error ".mysql_error()); |
255 | | -$defined_meaning=mysql_fetch_assoc($result); |
256 | | -var_dump($defined_meaning); |
| 257 | + $dm_target_table=mysql_real_escape_string("${dc2}_defined_meaning"); |
| 258 | + $target_dmid=dupobject($defined_meaning["defined_meaning_id"], $dm_target_table, $dc1, $dc2); |
| 259 | + var_dump($target_dmid); |
| 260 | + $save_meaning=$defined_meaning; |
| 261 | + $save_meaning["defined_meaning_id"]=$target_dmid; |
257 | 262 | |
258 | | -# bit of exp here too (defnitely need to tidy) |
259 | | -$defining_expression=expression($defined_meaning["expression_id"], $dc1); |
260 | | -var_dump($defining_expression); |
| 263 | + # exp |
| 264 | + $target_table=mysql_real_escape_string("${dc2}_expression_ns"); |
| 265 | + $target_expid1=dupobject($defining_expression["expression_id"], $target_table, $dc1, $dc2); |
| 266 | + var_dump($target_expid1); |
| 267 | + $save_expression=$defining_expression; |
| 268 | + $save_expression["expression_id"]=$target_expid1; |
| 269 | + mysql_insert_assoc($target_table,$save_expression); |
| 270 | + # and insert that info into the dm |
| 271 | + $save_meaning["expression_id"]=$target_expid1; |
| 272 | + $save_meaning["meaning_text_tcid"]=dup_translated_content($dc1, $dc2, $defined_meaning["meaning_text_tcid"]); |
261 | 273 | |
262 | | -$dm_target_table=mysql_real_escape_string("${dc2}_defined_meaning"); |
263 | | -$target_dmid=dupobject($defined_meaning["defined_meaning_id"], $dm_target_table, $dc1, $dc2); |
264 | | -var_dump($target_dmid); |
265 | | -$save_meaning=$defined_meaning; |
266 | | -$save_meaning["defined_meaning_id"]=$target_dmid; |
| 274 | + mysql_insert_assoc($dm_target_table, $save_meaning); |
267 | 275 | |
268 | | -# exp |
269 | | -$target_table=mysql_real_escape_string("${dc2}_expression_ns"); |
270 | | -$target_expid1=dupobject($defining_expression["expression_id"], $target_table, $dc1, $dc2); |
271 | | -var_dump($target_expid1); |
272 | | -$save_expression=$defining_expression; |
273 | | -$save_expression["expression_id"]=$target_expid1; |
274 | | -mysql_insert_assoc($target_table,$save_expression); |
275 | | -# and insert that info into the dm |
276 | | -$save_meaning["expression_id"]=$target_expid1; |
277 | | -$save_meaning["meaning_text_tcid"]=dup_translated_content($dc1, $dc2, $defined_meaning["meaning_text_tcid"]); |
| 276 | + # the defining expression is also in syntrans, |
| 277 | + # so this might be redundant. |
| 278 | + dupsyntrans( |
| 279 | + $dc1, |
| 280 | + $dc2, |
| 281 | + $defined_meaning["defined_meaning_id"], |
| 282 | + $defining_expression["expression_id"], |
| 283 | + $save_meaning["defined_meaning_id"], |
| 284 | + $save_expression["expression_id"] |
| 285 | + ); |
278 | 286 | |
279 | | -mysql_insert_assoc($dm_target_table, $save_meaning); |
| 287 | + $title_name=$defining_expression["spelling"]; |
| 288 | + $title_number=$target_dmid; |
| 289 | + $title=str_replace(" ","_",$title_name)."_(".$title_number.")"; |
| 290 | + $pagedata=array("page_namespace"=>24, "page_title"=>$title); |
| 291 | + mysql_insert_assoc("page",$pagedata); |
280 | 292 | |
281 | | -# the defining expression is also in syntrans, |
282 | | -# so this might be redundant. |
283 | | -dupsyntrans( |
284 | | - $dc1, |
285 | | - $dc2, |
286 | | - $defined_meaning["defined_meaning_id"], |
287 | | - $defining_expression["expression_id"], |
288 | | - $save_meaning["defined_meaning_id"], |
289 | | - $save_expression["expression_id"] |
290 | | -); |
| 293 | + $concepts=array( |
| 294 | + $dc1 => $defined_meaning["defined_meaning_id"], |
| 295 | + $dc2 => $save_meaning["defined_meaning_id"] |
| 296 | + ); |
| 297 | + createConceptMapping($concepts); |
291 | 298 | |
292 | | -$title_name=$defining_expression["spelling"]; |
293 | | -$title_number=$target_dmid; |
294 | | -$title=str_replace(" ","_",$title_name)."_(".$title_number.")"; |
295 | | -$pagedata=array("page_namespace"=>24, "page_title"=>$title); |
296 | | -mysql_insert_assoc("page",$pagedata); |
| 299 | + dup_syntranses( |
| 300 | + $defined_meaning["defined_meaning_id"], |
| 301 | + $save_meaning["defined_meaning_id"], |
| 302 | + $dc1, |
| 303 | + $dc2 |
| 304 | + ); |
297 | 305 | |
298 | | -$concepts=array( |
299 | | - $dc1 => $defined_meaning["defined_meaning_id"], |
300 | | - $dc2 => $save_meaning["defined_meaning_id"] |
301 | | -); |
302 | | -createConceptMapping($concepts); |
| 306 | +} |
303 | 307 | |
304 | | -dup_syntranses( |
305 | | - $defined_meaning["defined_meaning_id"], |
306 | | - $save_meaning["defined_meaning_id"], |
307 | | - $dc1, |
308 | | - $dc2 |
309 | | -); |
310 | 308 | |
| 309 | +$start=stopwatch(); |
311 | 310 | |
| 311 | +$dmid_dirty=$_REQUEST['dmid']; |
| 312 | +$dc1_dirty=$_REQUEST['dc1']; |
| 313 | +$dc2_dirty=$_REQUEST['dc2']; |
| 314 | + |
| 315 | +$dmid=mysql_real_escape_string($dmid_dirty); |
| 316 | +$dc1=mysql_real_escape_string($dc1_dirty); |
| 317 | +$dc2=mysql_real_escape_string($dc2_dirty); |
| 318 | + |
| 319 | +dup_defined_meaning($dmid, $dc1, $dc2); |
| 320 | + |
312 | 321 | echo" |
313 | 322 | <hr> |
314 | 323 | <div align=\"right\"> |