Index: trunk/extensions/Wikidata/OmegaWiki/CopyDM.php |
— | — | @@ -0,0 +1,46 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +# testing what we learned in SaveDM |
| 5 | +# (possibly files like this should go in a subdir |
| 6 | +# and/or be replaced by proper unit testing) |
| 7 | + |
| 8 | +define('MEDIAWIKI', true ); |
| 9 | + |
| 10 | +# do we seriously need ALL of these? |
| 11 | +require_once("../../../StartProfiler.php"); |
| 12 | +require_once("../../../LocalSettings.php"); |
| 13 | +require_once("../php-tools/ProgressBar.php"); |
| 14 | +#require_once("DatabaseUtilities.php"); |
| 15 | +require_once("Setup.php"); |
| 16 | +require_once("DefinedMeaningModel.php"); |
| 17 | +require_once("Transaction.php"); |
| 18 | + |
| 19 | +/** Just get a defined meaning */ |
| 20 | +function getDM($definedMeaningId,$dc="uw") { |
| 21 | + global |
| 22 | + $wdCurrentContext; |
| 23 | + $wdCurrentContext=$dc; |
| 24 | + $model=new DefinedMeaningModel($definedMeaningId); |
| 25 | + return $model; |
| 26 | +} |
| 27 | + |
| 28 | +global |
| 29 | +$beginTime, $wgCommandLineMode, $dc; |
| 30 | + |
| 31 | +$beginTime = time(); |
| 32 | +$wgCommandLineMode = true; |
| 33 | +# $dc = "uw"; < can't modify from here |
| 34 | + |
| 35 | +/* insert code here */ |
| 36 | + |
| 37 | +$model=getDM(663678,"tt"); |
| 38 | + |
| 39 | +$record=$model->getRecord(); |
| 40 | +echo $record; |
| 41 | + |
| 42 | +$model->copyTo("uw"); |
| 43 | + |
| 44 | +$endTime = time(); |
| 45 | +echo("\n\nTime elapsed: " . durationToString($endTime - $beginTime)); |
| 46 | + |
| 47 | + |
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
— | — | @@ -169,10 +169,23 @@ |
170 | 170 | /** Copy this defined meaning to specified dataset-context |
171 | 171 | * Warning: This is somewhat new code, which still needs |
172 | 172 | * shoring up. |
173 | | - * @param $dc dataset-context to copy to. |
| 173 | + * @param $dataset dataset to copy to. |
| 174 | + * @returns defined meaning id in the new dataset |
174 | 175 | */ |
175 | | - public function copyTo($dc) { |
176 | | - |
| 176 | + public function copyTo($dataset) { |
| 177 | + $definedMeaningID=$this->getDefinedMeaningID(); |
| 178 | + #$from_dc=$this->getDataset(); |
| 179 | + $to_dc=$dataset; |
| 180 | + # TODO We should actually thoroughly check that everything |
| 181 | + # is present before proceding, and throw some exceptions |
| 182 | + # if not. |
| 183 | + |
| 184 | + global |
| 185 | + $wdCurrentContext; |
| 186 | + $wdCurrentContext=$to_dc; # set global override (DIRTY!) |
| 187 | + $this->saveWithinTransaction(); |
| 188 | + $wdCurrentContext=null; # unset override, we probably should |
| 189 | + # use proper OO for this. |
177 | 190 | } |
178 | 191 | |
179 | 192 | } |