/** duplicate a basic defined meaning, translated text, and syntrans * this is relatively old code by now, and can probably be tidied/refactored * use dup_rest to duplicate everything else. * * There is/should be no risk of a stub copy leading to a runaway recursion */ public function dup_stub () { $dmid = $this->dmid; $dc1 = $this->dc1; $dc2 = $this->dc2; $this->read(); # bit of exp here too (defnitely need to tidy) $defining_expression = expression( $this->defined_meaning["expression_id"], $dc1 ); # is it already mapped? $target_dmid = $this->getMappedId(); # no? if ( !$target_dmid ) { $copier = new ObjectCopier( $this->defined_meaning["defined_meaning_id"], $dc1, $dc2 ); $target_dmid = $copier->dup(); $this->already_there = $copier->already_there(); } else { # yes? # and no, we weren't advertising merging, so you're outta luck :-P $this->already_there = true; } # test code only: # $spelling=$defining_expression["spelling"]; # echo "$spelling, "; # now something potentially useful? # echo "->$dc2:$target_dmid"; # echo". "; # end test code; $this->save_meaning = $this->defined_meaning; $this->save_meaning["defined_meaning_id"] = $target_dmid; if ( !( $this->already_there ) ) { $this->save_meaning["expression_id"] = write_expression( $defining_expression, $dmid, $target_dmid, $dc1, $dc2 ); } $this->save_meaning["meaning_text_tcid"] = dup_translated_content( $dc1, $dc2, $this->defined_meaning["meaning_text_tcid"] ); if ( !( $this->already_there ) ) { CopyTools::dc_insert_assoc( $dc2, "defined_meaning", $this->save_meaning ); $title_name = $defining_expression["spelling"]; $title_number = $target_dmid; $title = str_replace( " ", "_", $title_name ) . "_(" . $title_number . ")"; CopyTools::createPage( $title ); $concepts = array( $dc1 => $this->defined_meaning["defined_meaning_id"], $dc2 => $this->save_meaning["defined_meaning_id"] ); $uuid_data = createConceptMapping( $concepts, getUpdateTransactionId() ); DefinedMeaningCopier::finishConceptMapping( $dc1, $uuid_data[$dc1] ); DefinedMeaningCopier::finishConceptMapping( $dc2, $uuid_data[$dc2] ); } return $this->save_meaning["defined_meaning_id"]; }