Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaningModel.php |
— | — | @@ -6,22 +6,38 @@ |
7 | 7 | require_once("Transaction.php"); |
8 | 8 | require_once("WikiDataAPI.php"); |
9 | 9 | |
10 | | - |
| 10 | +/** A front end for the database information/ArrayRecord and any other information |
| 11 | + * to do with defined meanings (as per MVC) |
| 12 | + * Will collect code for instantiating and loading and saving DMs here for now. |
| 13 | + */ |
11 | 14 | class DefinedMeaningModel { |
12 | 15 | |
13 | 16 | protected $record=null; |
14 | 17 | protected $definedMeaningID=null; |
15 | 18 | |
16 | | - public function __construct($definedMeaningId, $viewInformation) { |
| 19 | + /** |
| 20 | + *Construct a new DefinedMeaningModel for a particular defined meaning |
| 21 | + * will fetch the appropriate record for the provided definedMeaningId |
| 22 | + * you can't use this to construct a new DM from scratch (yet) |
| 23 | + * you can't (yet) provide a dataset-context ($dc) |
| 24 | + * @param $definedMeaningId the database ID of the DM |
| 25 | + * @param $viewInformation Specify specific ViewInformation, if needed. |
| 26 | + */ |
| 27 | + public function __construct($definedMeaningId, $viewInformation=null) { |
17 | 28 | |
18 | | - wfDebug("definedMeaningId:$definedMeaningId, filterLanguageId:$viewInformation->filterLanguageId, possiblySynonymousRelationTypeId:$viewInformation->possiblySynonymousRelationTypeId, queryTransactionInformation:$viewInformation->queryTransactionInformation\n"); |
19 | 29 | global |
20 | 30 | $definedMeaningAttribute, $definitionAttribute, $classAttributesAttribute, |
21 | 31 | $alternativeDefinitionsAttribute, $synonymsAndTranslationsAttribute, |
22 | 32 | $relationsAttribute, $reciprocalRelationsAttribute, |
23 | 33 | $classMembershipAttribute, $collectionMembershipAttribute, $definedMeaningAttributesAttribute, |
24 | 34 | $possiblySynonymousAttribute; |
| 35 | + |
| 36 | + if (is_null($viewInformation)) { |
| 37 | + $viewInformation = new ViewInformation(); |
| 38 | + $viewInformation->queryTransactionInformation= new QueryLatestTransactionInformation(); |
| 39 | + } |
25 | 40 | |
| 41 | + #wfDebug("definedMeaningId:$definedMeaningId, filterLanguageId:$viewInformation->filterLanguageId, possiblySynonymousRelationTypeId:$viewInformation->possiblySynonymousRelationTypeId, queryTransactionInformation:$viewInformation->queryTransactionInformation\n"); |
26 | 42 | $this->setDefinedMeaningID($definedMeaningId); |
27 | 43 | $record = new ArrayRecord($definedMeaningAttribute->type); |
28 | 44 | $record->setAttributeValue($definitionAttribute, getDefinedMeaningDefinitionRecord($definedMeaningId, $viewInformation)); |
Index: trunk/extensions/Wikidata/OmegaWiki/SaveDM.php |
— | — | @@ -1,6 +1,9 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | # let's see... |
| 5 | +# start out with a test skeleton, get a record from one dataset |
| 6 | +# then save it to the other. Once this works, we can wrap it up nicely, and |
| 7 | +# apply it to our actual code. |
5 | 8 | |
6 | 9 | define('MEDIAWIKI', true ); |
7 | 10 | |
— | — | @@ -18,9 +21,9 @@ |
19 | 22 | global |
20 | 23 | $wdCurrentContext; |
21 | 24 | $wdCurrentContext=$dc; |
22 | | - $viewInformation = new ViewInformation(); |
23 | | - $viewInformation->queryTransactionInformation= new QueryLatestTransactionInformation(); |
24 | | - $model=new DefinedMeaningModel($definedMeaningId, $viewInformation); |
| 25 | + #$viewInformation = new ViewInformation(); |
| 26 | + #$viewInformation->queryTransactionInformation= new QueryLatestTransactionInformation(); |
| 27 | + $model=new DefinedMeaningModel($definedMeaningId); |
25 | 28 | $record=$model->getRecord(); |
26 | 29 | #$record->finish("DefinedMeaning"); |
27 | 30 | return $model; |
— | — | @@ -44,10 +47,10 @@ |
45 | 48 | /* insert code here */ |
46 | 49 | |
47 | 50 | $model=getDM(663672,"uw"); |
48 | | -saveDM($model,"tt"); |
| 51 | +#saveDM($model,"tt"); |
49 | 52 | |
50 | | -#$record=$model->getRecord(); |
51 | | -#echo $record; |
| 53 | +$record=$model->getRecord(); |
| 54 | +echo $record; |
52 | 55 | |
53 | 56 | $endTime = time(); |
54 | 57 | echo("\n\nTime elapsed: " . durationToString($endTime - $beginTime)); |