r21328 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21327‎ | r21328 | r21329 >
Date:16:05, 17 April 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Enable value retrieval for test store
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_TestStore.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_TestStore.php
@@ -65,10 +65,38 @@
6666 }
6767 }
6868
69 -
7069 function getAttributeValues(Title $subject, Title $attribute, $requestoptions = NULL) {
71 - // TODO
72 - return array();
 70+ $type = $this->getSpecialValues($attribute,SMW_SP_HAS_TYPE);
 71+ $th = SMWTypeHandlerFactory::getTypeHandlerByLabel($type[0]);
 72+ $valarray = array();
 73+ switch ($th->getID()) {
 74+ case 'int':
 75+ $valarray = array('10', '5000000000000','0','-1234','12','17','42');
 76+ break;
 77+ case 'float':
 78+ $valarray = array('1.23', '5.234e+30','-0.000001','4','12.1','17.1','42.1');
 79+ break;
 80+ case 'datetime':
 81+ $valarray = array('2007-04-01', '2007-12-31T18:25:21');
 82+ break;
 83+ case 'enum':
 84+ $valarray = array('enum_val1', 'enum_val3', 'enum_val2');
 85+ break;
 86+ case 'geocoords':
 87+ $valarray = array('38°1′12″ N, 122°1′1.2″ W');
 88+ break;
 89+ case 'string':
 90+ $valarray = array('Test', 'Some longer string','Üničode','Some [[markup]]','<b>Bug if bold!</b>');
 91+ break;
 92+ }
 93+ $result = Array();
 94+ foreach ($valarray as $val) {
 95+ $dv = SMWDataValue::newTypedValue($th);
 96+ $dv->setAttribute($attribute->getText());
 97+ $dv->setXSDValue($val,'');
 98+ $result[] = $dv;
 99+ }
 100+ return $result;
73101 }
74102
75103 function getAttributeSubjects(Title $attribute, SMWDataValue $value, $requestoptions = NULL) {
@@ -175,20 +203,32 @@
176204 * but adhere to the given options (limit, sorting)
177205 */
178206 private function getTestTitles($requestoptions, $namespace = -1) {
179 - $result = array();
 207+ $result = Array();
 208+ $initarray = Array();
 209+ if ($namespace == SMW_NS_ATTRIBUTE) {
 210+ $initarray = array( 'Teststring','Testint','Testfloat','Testcoords','Testdate','Testenum');
 211+ }
180212 for ($i=0; $i<300; $i++) {
181213 global $wgContLang;
182 - $firstchar = chr(65+($i*17)%25);
183214 if ($namespace < 0) {
184215 $ns = (($i%5)*2);
185216 } else {
186217 $ns = $namespace;
187218 }
188 - if ($ns == 0) {
189 - $result[$firstchar . $i] = Title::newFromText($firstchar . $i . '_(Test)', $ns);
 219+
 220+ if ($i < count($initarray)) {
 221+ $text = $initarray[$i];
 222+ $key = $initarray[$i];
190223 } else {
191 - $result[$firstchar . $i] = Title::newFromText($firstchar . $i . '_(Test' . $wgContLang->getNsText($ns) . ')', $ns);
 224+ $firstchar = chr(65+($i*17)%25);
 225+ $key = $firstchar . $i;
 226+ if ($ns == 0) {
 227+ $text = $firstchar . $i . '_(Test)';
 228+ } else {
 229+ $text = $firstchar . $i . '_(Test' . $wgContLang->getNsText($ns) . ')';
 230+ }
192231 }
 232+ $result[$key] = Title::newFromText($text, $ns);
193233 }
194234 // the order of applying the following is crucial:
195235 if ($requestoptions !== NULL) {

Status & tagging log