Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_TestStore.php |
— | — | @@ -65,10 +65,38 @@ |
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | | - |
70 | 69 | 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; |
73 | 101 | } |
74 | 102 | |
75 | 103 | function getAttributeSubjects(Title $attribute, SMWDataValue $value, $requestoptions = NULL) { |
— | — | @@ -175,20 +203,32 @@ |
176 | 204 | * but adhere to the given options (limit, sorting) |
177 | 205 | */ |
178 | 206 | 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 | + } |
180 | 212 | for ($i=0; $i<300; $i++) { |
181 | 213 | global $wgContLang; |
182 | | - $firstchar = chr(65+($i*17)%25); |
183 | 214 | if ($namespace < 0) { |
184 | 215 | $ns = (($i%5)*2); |
185 | 216 | } else { |
186 | 217 | $ns = $namespace; |
187 | 218 | } |
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]; |
190 | 223 | } 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 | + } |
192 | 231 | } |
| 232 | + $result[$key] = Title::newFromText($text, $ns); |
193 | 233 | } |
194 | 234 | // the order of applying the following is crucial: |
195 | 235 | if ($requestoptions !== NULL) { |