Index: trunk/extensions/Wikidata/OmegaWiki/GetDM.php |
— | — | @@ -1,5 +1,11 @@ |
2 | 2 | <?php |
3 | 3 | |
| 4 | +# let's see... |
| 5 | +# start out with a test skeleton, get a record from one dataset |
| 6 | +# and print it out |
| 7 | +# This is just saveDM with the actual save call removed :-P |
| 8 | +# (it's simply too handy not to do ;-)) |
| 9 | + |
4 | 10 | define('MEDIAWIKI', true ); |
5 | 11 | |
6 | 12 | # do we seriously need ALL of these? |
— | — | @@ -11,7 +17,27 @@ |
12 | 18 | require_once("DefinedMeaningModel.php"); |
13 | 19 | require_once("Transaction.php"); |
14 | 20 | |
| 21 | +/** Just get a defined meaning */ |
| 22 | +function getDM($definedMeaningId,$dc="uw") { |
| 23 | + global |
| 24 | + $wdCurrentContext; |
| 25 | + $wdCurrentContext=$dc; |
| 26 | + #$viewInformation = new ViewInformation(); |
| 27 | + #$viewInformation->queryTransactionInformation= new QueryLatestTransactionInformation(); |
| 28 | + $model=new DefinedMeaningModel($definedMeaningId); |
| 29 | + $record=$model->getRecord(); |
| 30 | + #$record->finish("DefinedMeaning"); |
| 31 | + return $model; |
| 32 | +} |
15 | 33 | |
| 34 | +function saveDM($model,$dc="uw") { |
| 35 | + global |
| 36 | + $wdCurrentContext; |
| 37 | + $wdCurrentContext=$dc; |
| 38 | + #echo $model->getRecord(); |
| 39 | + $model->saveWithinTransaction(); |
| 40 | +} |
| 41 | + |
16 | 42 | global |
17 | 43 | $beginTime, $wgCommandLineMode, $dc; |
18 | 44 | |
— | — | @@ -20,17 +46,22 @@ |
21 | 47 | # $dc = "uw"; < can't modify from here |
22 | 48 | |
23 | 49 | /* insert code here */ |
24 | | -$definedMeaningId=663665; # UnitTest |
25 | 50 | |
26 | | -$viewInformation = new ViewInformation(); |
27 | | -$viewInformation->queryTransactionInformation = new QueryLatestTransactionInformation(); |
| 51 | +$model=getDM(663674,"tt"); |
28 | 52 | |
29 | | -$model=new DefinedMeaningModel($definedMeaningId, $viewInformation); |
30 | 53 | $record=$model->getRecord(); |
31 | | -$record->finish("DefinedMeaning"); |
32 | 54 | echo $record; |
| 55 | +$defexp=$record->getValue("defined-meaning-full-defining-expression"); |
| 56 | +echo $defexp."\n"; |
| 57 | +#$expid=$record->getAttributeValue(new Attribute("expression-id")); |
| 58 | +$id=$defexp->getValue("expression-id"); |
| 59 | +$spelling=$defexp->getValue("defined-meaning-defining-expression"); |
| 60 | +$language=$defexp->getValue("language"); |
33 | 61 | |
| 62 | +echo "id: $id, spelling:$spelling, language:$language"; |
34 | 63 | |
| 64 | +#saveDM($model,"uw"); |
| 65 | + |
35 | 66 | $endTime = time(); |
36 | 67 | echo("\n\nTime elapsed: " . durationToString($endTime - $beginTime)); |
37 | 68 | |