r24741 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24740‎ | r24741 | r24742 >
Date:09:41, 13 August 2007
Author:proes
Status:old
Tags:
Comment:
Refactored RecordListEditor a bit
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/Editor.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php
@@ -1341,70 +1341,91 @@
13421342 return $result;
13431343 }
13441344
1345 - public function view(IdStack $idPath, $value) {
 1345+ protected function viewEditors(IdStack $idPath, $value, $editors, $htmlTag) {
13461346 $result = '';
13471347
1348 - foreach ($this->getEditors() as $editor) {
 1348+ foreach ($editors as $editor) {
13491349 $attribute = $editor->getAttribute();
13501350 $idPath->pushAttribute($attribute);
13511351 $class = $idPath->getClass();
13521352 $attributeId = $idPath->getId();
1353 - $attributeValue = $value->getAttributeValue($attribute);
 1353+ $attributeValue = $value->getAttributeValue($attribute);
 1354+
13541355 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 . '>';
13591361
13601362 $idPath->popAttribute();
13611363 }
 1364+
13621365 return $result;
13631366 }
13641367
 1368+ public function view(IdStack $idPath, $value) {
 1369+ return $this->viewEditors($idPath, $value, $this->getEditors(), $this->htmlTag);
 1370+ }
 1371+
13651372 public function showEditField(IdStack $idPath) {
13661373 return true;
13671374 }
13681375
1369 - public function edit(IdStack $idPath, $value) {
 1376+ protected function editEditors(IdStack $idPath, $value, $editors, $htmlTag) {
13701377 $result = '';
1371 - foreach ($this->getEditors() as $editor) {
 1378+
 1379+ foreach ($editors as $editor) {
13721380 $attribute = $editor->getAttribute();
13731381 $idPath->pushAttribute($attribute);
13741382
1375 - if($editor->showEditField($idPath)) {
 1383+ if ($editor->showEditField($idPath)) {
13761384 $class = $idPath->getClass();
13771385 $attributeId = $idPath->getId();
13781386
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 . '>';
13831392 }
13841393 $idPath->popAttribute();
13851394 }
 1395+
13861396 return $result;
13871397 }
 1398+
 1399+ public function edit(IdStack $idPath, $value) {
 1400+ return $this->editEditors($idPath, $value, $this->getEditors(), $this->htmlTag);
 1401+ }
13881402
1389 - public function add(IdStack $idPath) {
 1403+ protected function addEditors(IdStack $idPath, $editors, $htmlTag) {
13901404 $result = '';
1391 - foreach($this->getEditors() as $editor) {
 1405+
 1406+ foreach($editors as $editor) {
13921407 if ($attribute = $editor->getAddAttribute()) {
13931408 $idPath->pushAttribute($attribute);
13941409 $class = $idPath->getClass();
13951410 $attributeId = $idPath->getId();
13961411
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 . '>';
14011417
14021418 $editor->add($idPath);
14031419 $idPath->popAttribute();
14041420 }
14051421 }
 1422+
14061423 return $result;
14071424 }
14081425
 1426+ public function add(IdStack $idPath) {
 1427+ return $this->addEditors($idPath, $this->getEditors(), $this->htmlTag);
 1428+ }
 1429+
14091430 protected function childHeader(Editor $editor, Attribute $attribute, $class, $attributeId){
14101431 $expansionPrefix = $this->getExpansionPrefix($class, $attributeId);
14111432 $this->setExpansionByEditor($editor, $class);

Status & tagging log