Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php |
— | — | @@ -1341,70 +1341,91 @@ |
1342 | 1342 | return $result; |
1343 | 1343 | } |
1344 | 1344 | |
1345 | | - public function view(IdStack $idPath, $value) { |
| 1345 | + protected function viewEditors(IdStack $idPath, $value, $editors, $htmlTag) { |
1346 | 1346 | $result = ''; |
1347 | 1347 | |
1348 | | - foreach ($this->getEditors() as $editor) { |
| 1348 | + foreach ($editors as $editor) { |
1349 | 1349 | $attribute = $editor->getAttribute(); |
1350 | 1350 | $idPath->pushAttribute($attribute); |
1351 | 1351 | $class = $idPath->getClass(); |
1352 | 1352 | $attributeId = $idPath->getId(); |
1353 | | - $attributeValue = $value->getAttributeValue($attribute); |
| 1353 | + $attributeValue = $value->getAttributeValue($attribute); |
| 1354 | + |
1354 | 1355 | if ($editor->showsData($attributeValue)) |
1355 | | - $result .= '<' . $this->htmlTag . '>' . |
1356 | | - $this->childHeader($editor, $attribute, $class, $attributeId) . |
1357 | | - $this->viewChild($editor, $idPath, $value, $attribute, $class, $attributeId) . |
1358 | | - '</' . $this->htmlTag . '>'; |
| 1356 | + $result .= |
| 1357 | + '<' . $htmlTag . '>' . |
| 1358 | + $this->childHeader($editor, $attribute, $class, $attributeId) . |
| 1359 | + $this->viewChild($editor, $idPath, $value, $attribute, $class, $attributeId) . |
| 1360 | + '</' . $htmlTag . '>'; |
1359 | 1361 | |
1360 | 1362 | $idPath->popAttribute(); |
1361 | 1363 | } |
| 1364 | + |
1362 | 1365 | return $result; |
1363 | 1366 | } |
1364 | 1367 | |
| 1368 | + public function view(IdStack $idPath, $value) { |
| 1369 | + return $this->viewEditors($idPath, $value, $this->getEditors(), $this->htmlTag); |
| 1370 | + } |
| 1371 | + |
1365 | 1372 | public function showEditField(IdStack $idPath) { |
1366 | 1373 | return true; |
1367 | 1374 | } |
1368 | 1375 | |
1369 | | - public function edit(IdStack $idPath, $value) { |
| 1376 | + protected function editEditors(IdStack $idPath, $value, $editors, $htmlTag) { |
1370 | 1377 | $result = ''; |
1371 | | - foreach ($this->getEditors() as $editor) { |
| 1378 | + |
| 1379 | + foreach ($editors as $editor) { |
1372 | 1380 | $attribute = $editor->getAttribute(); |
1373 | 1381 | $idPath->pushAttribute($attribute); |
1374 | 1382 | |
1375 | | - if($editor->showEditField($idPath)) { |
| 1383 | + if ($editor->showEditField($idPath)) { |
1376 | 1384 | $class = $idPath->getClass(); |
1377 | 1385 | $attributeId = $idPath->getId(); |
1378 | 1386 | |
1379 | | - $result .= '<' . $this->htmlTag . '>'. |
1380 | | - $this->childHeader($editor, $attribute, $class, $attributeId) . |
1381 | | - $this->editChild($editor, $idPath, $value, $attribute, $class, $attributeId) . |
1382 | | - '</' . $this->htmlTag . '>'; |
| 1387 | + $result .= |
| 1388 | + '<' . $htmlTag . '>'. |
| 1389 | + $this->childHeader($editor, $attribute, $class, $attributeId) . |
| 1390 | + $this->editChild($editor, $idPath, $value, $attribute, $class, $attributeId) . |
| 1391 | + '</' . $htmlTag . '>'; |
1383 | 1392 | } |
1384 | 1393 | $idPath->popAttribute(); |
1385 | 1394 | } |
| 1395 | + |
1386 | 1396 | return $result; |
1387 | 1397 | } |
| 1398 | + |
| 1399 | + public function edit(IdStack $idPath, $value) { |
| 1400 | + return $this->editEditors($idPath, $value, $this->getEditors(), $this->htmlTag); |
| 1401 | + } |
1388 | 1402 | |
1389 | | - public function add(IdStack $idPath) { |
| 1403 | + protected function addEditors(IdStack $idPath, $editors, $htmlTag) { |
1390 | 1404 | $result = ''; |
1391 | | - foreach($this->getEditors() as $editor) { |
| 1405 | + |
| 1406 | + foreach($editors as $editor) { |
1392 | 1407 | if ($attribute = $editor->getAddAttribute()) { |
1393 | 1408 | $idPath->pushAttribute($attribute); |
1394 | 1409 | $class = $idPath->getClass(); |
1395 | 1410 | $attributeId = $idPath->getId(); |
1396 | 1411 | |
1397 | | - $result .= '<' . $this->htmlTag . '>'. |
1398 | | - $this->childHeader($editor, $attribute, $class, $attributeId) . |
1399 | | - $this->addChild($editor, $idPath, $attribute, $class, $attributeId) . |
1400 | | - '</' . $this->htmlTag . '>'; |
| 1412 | + $result .= |
| 1413 | + '<' . $htmlTag . '>'. |
| 1414 | + $this->childHeader($editor, $attribute, $class, $attributeId) . |
| 1415 | + $this->addChild($editor, $idPath, $attribute, $class, $attributeId) . |
| 1416 | + '</' . $htmlTag . '>'; |
1401 | 1417 | |
1402 | 1418 | $editor->add($idPath); |
1403 | 1419 | $idPath->popAttribute(); |
1404 | 1420 | } |
1405 | 1421 | } |
| 1422 | + |
1406 | 1423 | return $result; |
1407 | 1424 | } |
1408 | 1425 | |
| 1426 | + public function add(IdStack $idPath) { |
| 1427 | + return $this->addEditors($idPath, $this->getEditors(), $this->htmlTag); |
| 1428 | + } |
| 1429 | + |
1409 | 1430 | protected function childHeader(Editor $editor, Attribute $attribute, $class, $attributeId){ |
1410 | 1431 | $expansionPrefix = $this->getExpansionPrefix($class, $attributeId); |
1411 | 1432 | $this->setExpansionByEditor($editor, $class); |