function rollBackTransactions( $recordSet ) {

	$o = OmegaWikiAttributes::getInstance();
	global
		$wgRequest, $wgUser;
		
	$summary = $wgRequest->getText( 'summary' );
	startNewTransaction( $wgUser->getID(), wfGetIP(), $summary );
		
	$idStack = new IdStack( 'transaction' );
	$transactionKeyStructure = $recordSet->getKey();
	
	for ( $i = 0; $i < $recordSet->getRecordCount(); $i++ ) {
		$transactionRecord = $recordSet->getRecord( $i );

		$transactionId = $transactionRecord->transactionId;
		$idStack->pushKey( simpleRecord( $transactionKeyStructure, array( $transactionId ) ) );

		$updatesInTransaction = $transactionRecord->updatesInTransaction;
		$idStack->pushAttribute( $o->updatesInTransaction );

		$updatedDefinitions = $updatesInTransaction->updatedDefinition;
		$idStack->pushAttribute( $o->updatedDefinition );
		rollBackDefinitions( $idStack, $updatedDefinitions );
		$idStack->popAttribute();

		$updatedRelations = $updatesInTransaction->updatedRelations;
		$idStack->pushAttribute( $o->updatedRelations );
		rollBackRelations( $idStack, $updatedRelations );
		$idStack->popAttribute();
		
		$updatedClassMemberships = $updatesInTransaction->updatedClassMembership;
		$idStack->pushAttribute( $o->updatedClassMembership );
		rollBackClassMemberships( $idStack, $updatedClassMemberships );
		$idStack->popAttribute();
		
		$updatedClassAttributes = $updatesInTransaction->updatedClassAttributes;
		$idStack->pushAttribute( $o->updatedClassAttributes );
		rollBackClassAttributes( $idStack, $updatedClassAttributes );
		$idStack->popAttribute();
		
		$updatedTranslatedTexts = $updatesInTransaction->updatedTranslatedText;
		$idStack->pushAttribute( $o->updatedTranslatedText );
		rollBackTranslatedTexts( $idStack, $updatedTranslatedTexts );
		$idStack->popAttribute();

		$updatedTranslatedTextProperties = $updatesInTransaction->updatedTranslatedTextProperty;
		$idStack->pushAttribute( $o->updatedTranslatedTextProperty );
		rollBackTranslatedTextProperties( $idStack, $updatedTranslatedTextProperties );
		$idStack->popAttribute();

		$o->updatedLinks = $updatesInTransaction->updatedLink;
		$idStack->pushAttribute( $o->updatedLink );
		rollBackLinkAttributes( $idStack, $o->updatedLinks );
		$idStack->popAttribute();

		$o->updatedTexts = $updatesInTransaction->updatedText;
		$idStack->pushAttribute( $o->updatedText );
		rollBackTextAttributes( $idStack, $o->updatedTexts );
		$idStack->popAttribute();

		$updatedSyntranses = $updatesInTransaction->updatedSyntranses;
		$idStack->pushAttribute( $o->updatedSyntranses );
		rollBackSyntranses( $idStack, $updatedSyntranses );
		$idStack->popAttribute();

		$updatedAlternativeDefinitionTexts = $updatesInTransaction->updatedAlternativeDefinitionText;
		$idStack->pushAttribute( $o->updatedAlternativeDefinitionText );
		rollBackAlternativeDefinitionTexts( $idStack, $updatedAlternativeDefinitionTexts );
		$idStack->popAttribute();

		$updatedAlternativeDefinitions = $updatesInTransaction->updatedAlternativeDefinitions;
		$idStack->pushAttribute( $o->updatedAlternativeDefinitions );
		rollBackAlternativeDefinitions( $idStack, $updatedAlternativeDefinitions );
		$idStack->popAttribute();

		$updatedCollectionMemberships = $updatesInTransaction->updatedCollectionMembership;
		$idStack->pushAttribute( $o->updatedCollectionMembership );
		rollBackCollectionMemberships( $idStack, $updatedCollectionMemberships );
		$idStack->popAttribute();

		$idStack->popAttribute();
		$idStack->popKey();
	}
}
Ejemplo n.º 2
0
function getRecordAsEditTableCells( IdStack $idPath, Editor $editor, Structure $visibleStructure, Record $record, &$startColumn = 0 ) {
	$result = '';
	$childEditorMap = $editor->getAttributeEditorMap();
	
	foreach ( $visibleStructure->getAttributes() as $visibleAttribute ) {
		$childEditor = $childEditorMap->getEditorForAttribute( $visibleAttribute );
		
		if ( $childEditor != null ) {
			$attribute = $childEditor->getAttribute();
			$type = $attribute->type;
			$value = $record->getAttributeValue( $attribute );
			$idPath->pushAttribute( $attribute );
				
			if ( $childEditor instanceof RecordTableCellEditor ) {
				$result .= getRecordAsEditTableCells( $idPath, $childEditor, $visibleAttribute->type, $value, $startColumn );
			} else {
				if ( $childEditor->showEditField( $idPath ) ) {
					$displayValue = $childEditor->edit( $idPath, $value );
				} else {
					$displayValue = "";
				}
				$result .= '<td class="' . getHTMLClassForType( $type, $attribute ) . ' column-' . parityClass( $startColumn ) . '">' . $displayValue . '</td>';
					
				$startColumn++;
			}
			
			$idPath->popAttribute();
		}
		else {
			$result .= "<td/>";
		}
	}
	return $result;
}
Ejemplo n.º 3
0
	public function add( IdStack $idPath ) {
		$attribute = $this->subRecordEditor->getAttribute();
		$idPath->pushAttribute( $attribute );
		$result = $this->subRecordEditor->add( $idPath );
		$idPath->popAttribute();
		
		return $result;
	}