function execute( $par ) {

		global $wgOut, $wgUser, $wgRequest;

		$wgOut->setPageTitle( 'Add Collection' );

		if ( !$wgUser->isAllowed( 'addcollection' ) ) {
			$wgOut->addHTML( 'You do not have permission to add a collection.' );
			return false;
		}

		$dbr = wfGetDB( DB_MASTER );

		if ( $wgRequest->getText( 'collection' ) ) {
			require_once( 'WikiDataAPI.php' );
			require_once( 'Transaction.php' );

			$dc = $wgRequest->getText( 'dataset' );
			$collectionName = $wgRequest->getText( 'collection' );
			startNewTransaction( $wgUser->getID(), wfGetIP(), 'Add collection ' . $collectionName );
			bootstrapCollection( $collectionName, $wgRequest->getText( 'language' ), $wgRequest->getText( 'type' ), $dc );
			$wgOut->addHTML( wfMsg( 'ow_collection_added', $collectionName ) . "<br />" );
		}
		$datasets = wdGetDatasets();
		$datasetarray[''] = wfMsgSc( "none_selected" );
		foreach ( $datasets as $datasetid => $dataset ) {
			$datasetarray[$datasetid] = $dataset->fetchName();
		}

		$wgOut->addHTML( getOptionPanel(
			array(
				'Collection name:' => getTextBox( 'collection' ),
				'Language of name:' => getSuggest( 'language', 'language' ),
				'Collection type:' => getSelect( 'type', array( '' => 'None', 'RELT' => 'RELT', 'LEVL' => 'LEVL', 'CLAS' => 'CLAS', 'MAPP' => 'MAPP' ) ),
				'Dataset:' => getSelect( 'dataset', $datasetarray )
			),
			'', array( 'create' => wfMsg( 'ow_create' ) )
		) );
	}
	private function getDefinedMeaningAttributeAsRecordSet( $queryResult ) {
		global $wgDefinedMeaningAttributes;

		$o = OmegaWikiAttributes::getInstance();

		$dbr = wfGetDB( DB_SLAVE );
	
		$definedMeaningAttributeAttribute = new Attribute( $wgDefinedMeaningAttributes, wfMsgSc( "DefinedMeaningAttributes" ), "short-text" );
		$recordSet = new ArrayRecordSet( new Structure( $o->id, $definedMeaningAttributeAttribute ), new Structure( $o->id ) );
	
		while ( $row = $dbr->fetchObject( $queryResult ) )
			$recordSet->addRecord( array( $row->attribute_mid, $row->spelling ) );

		$editor = createSuggestionsTableViewer( null );
		$editor->addEditor( createShortTextViewer( $definedMeaningAttributeAttribute ) );

		return array( $recordSet, $editor );
	}
	/** @returns user interface html for copying Defined Meanings
	 * between datasets. returns an empty string if the user
	 * actually doesn't have permission to edit.
	 */
	protected function getCopyPanel() {

		# mostly same code as in SpecialAddCollection... possibly might 
		# make a nice separate function 

		global
			$wgUser;
		if ( !$wgUser->isAllowed( 'wikidata-copy' ) ) {
			return "";
		}

		$datasets = wdGetDatasets();
		$datasetarray[''] = wfMsgSc( 'none_selected' );
		foreach ( $datasets as $datasetid => $dataset ) {
			$datasetarray[$datasetid] = $dataset->fetchName();
		}

		/* Deprecated for now
		
		$html= getOptionPanel( array (
			'Copy to' => getSelect('CopyTo', $datasetarray)
		));
		*/
		$html = $this->getCopyPanel2();
		return $html;
	}
function getDefinedMeaningEditor( ViewInformation $viewInformation ) {
	global
		$wdDefinedMeaningAttributesOrder,  $definedMeaningMeaningName,
		$relationMeaningName;
		
	$o = OmegaWikiAttributes::getInstance();
	
	$definitionEditor = getDefinitionEditor( $viewInformation );
	$alternativeDefinitionsEditor = getAlternativeDefinitionsEditor( $viewInformation );
	$classAttributesEditor = getClassAttributesEditor( $viewInformation );
	$synonymsAndTranslationsEditor = getSynonymsAndTranslationsEditor( $viewInformation );
	$reciprocalRelationsEditor = getDefinedMeaningReciprocalRelationsEditor( $viewInformation );
	$classMembershipEditor = getDefinedMeaningClassMembershipEditor( $viewInformation );
	$collectionMembershipEditor = getDefinedMeaningCollectionMembershipEditor( $viewInformation );
	
	$availableEditors = new AttributeEditorMap();
	$availableEditors->addEditor( $definitionEditor );
	$availableEditors->addEditor( $alternativeDefinitionsEditor );
	$availableEditors->addEditor( $classAttributesEditor );
	$availableEditors->addEditor( $synonymsAndTranslationsEditor );
	$availableEditors->addEditor( $reciprocalRelationsEditor );
	$availableEditors->addEditor( $classMembershipEditor );
	$availableEditors->addEditor( $collectionMembershipEditor );

	foreach ( createPropertyToColumnFilterEditors( $viewInformation, $o->definedMeaningId, $definedMeaningMeaningName ) as $propertyToColumnEditor )
		$availableEditors->addEditor( $propertyToColumnEditor );
	
	$availableEditors->addEditor( createObjectAttributesEditor( $viewInformation, $o->definedMeaningAttributes, wfMsgSc( "Property" ), wfMsgSc( "Value" ), $o->definedMeaningId, $definedMeaningMeaningName, $viewInformation->getLeftOverAttributeFilter() ) );

	$definedMeaningEditor = new RecordUnorderedListEditor( $o->definedMeaning, 4 );
	
	foreach ( $wdDefinedMeaningAttributesOrder as $attributeId ) {
		$editor = $availableEditors->getEditorForAttributeId( $attributeId );
		
		if ( $editor != null )
			$definedMeaningEditor->addEditor( $editor );
	}

	$definedMeaningEditor->expandEditor( $definitionEditor );
	$definedMeaningEditor->expandEditor( $synonymsAndTranslationsEditor );
	
	return new DefinedMeaningContextEditor( $definedMeaningEditor );
}
	protected function _doCopy( $dmid_dirty, $dc1_dirty, $dc2_dirty ) {
		global
			$wgCommunityEditPermission, $wgOut, $wgUser, $wgCommunity_dc;
		
		# escape parameters
		$dmid = mysql_real_escape_string( $dmid_dirty );
		$dc1 = mysql_real_escape_string( $dc1_dirty );
		$dc2 = mysql_real_escape_string( $dc2_dirty );

		# check permission
		if ( !( $wgUser->isAllowed( 'wikidata-copy' ) ) or $dc2 != $wgCommunity_dc ) {
			$wgOut->addHTML( wfMsgSc( "Permission_denied" ) );
			return false; # we didn't perform the copy.
		}

		# copy
		CopyTools::newCopyTransaction( $dc1, $dc2 );
		$dmc = new DefinedMeaningCopier( $dmid, $dc1, $dc2 );
		$dmc->dup();

		# For purposes of current "edit copy", 
		# having the dm be already_there() is ok.
		# (hence commented out)
		# if ($dmc->already_there() ) {
		#	$wgOut->addHTML(wfMsgSc("already_there"));
		#	return false;
		# }

		return true; # seems everything went ok.

	}
	protected function outputEditFooter() {
		global
			$wgOut;
		
		$wgOut->addHTML(
			'<div class="option-panel">' .
				'<table cellpadding="0" cellspacing="0"><tr>' .
					'<th>' . wfMsg( "summary" ) . '</th>' .
					'<td class="option-field">' . getTextBox( "summary" ) . '</td>' .
				'</tr></table>' .
				getSubmitButton( "save", wfMsgSc( "save" ) ) .
			'</div>'
		);
		
		$wgOut->addHTML( '</form>' );
		$wgOut->addHTML( DefaultEditor::getExpansionCss() );
		$wgOut->addHTML( "<script language='javascript'><!--\nexpandEditors();\n--></script>" );
	}
	/** Hardcoded schema for now. Later refactor to load from file or DB 
	 * 
	 * Naming: keys are previous name minus -"Attribute"
	 * 	(-"Structure" is retained, -"Attributes" is retained)
	*/
	private function hardValues( viewInformation $viewInformation ) {
	
		assert ( !is_null( $viewInformation ) );
		$t = $this; # <-keep things short to declutter

		$t->in_setup = True;
		$t->language = new Attribute( "language", wfMsgSc( "Language" ), "language" );
		$t->spelling = new Attribute( "spelling", wfMsgSc( "Spelling" ), "spelling" );
		$t->text = new Attribute( "text", wfMsgSc( "Text" ), "text" );

		global
			$wgAlternativeDefinition, $wgAlternativeDefinitions,
			$wgClassAttributes,
			$wgClassMembership,
			$wgCollectionMembership,
			$wgDefinedMeaning, $wgDefinedMeaningAttributes,
			$wgDefinition,
			$wgExpression, $wgExpressionApproximateMeanings, $wgExpressionExactMeanings, $wgExpressionMeanings,
			$wgIncomingRelations,
			$wgLinkAttribute, $wgLinkAttributeValues,
			$wgObjectAttributes,
			$wgOptionAttribute, $wgOptionAttributeOption, $wgOptionAttributeValues,
			$wgOtherDefinedMeaning,
			$wgRelations,
			$wgSynonymsAndTranslations,
			$wgTextAttributeValues,
			$wgTranslatedText;

		$t->definedMeaningAttributes = new Attribute( $wgDefinedMeaningAttributes, wfMsgSc( "DefinedMeaningAttributes" ), "will-be-specified-below" );
		$t->objectAttributes = new Attribute( $wgObjectAttributes, wfMsgSc( "Annotation" ), "will-be-specified-below" );
		$t->expressionId = new Attribute( "expression-id", "Expression Id", "expression-id" );
		$t->identicalMeaning = new Attribute( "identMeaning", wfMsgSc( "IdenticalMeaning" ), "boolean" );

		if ( $viewInformation->filterOnLanguage() )
			$t->expression = new Attribute( $wgExpression, wfMsgSc( "Spelling" ), "spelling" );
		else {
			$t->expressionStructure = new Structure( $wgExpression, $t->language, $t->spelling );
			$t->expression = new Attribute( $wgExpression, wfMsgSc( "Expression" ), $t->expressionStructure );
		}

		$t->definedMeaningId = new Attribute( "defined-meaning-id", "Defined meaning identifier", "defined-meaning-id" );
		$t->definedMeaningDefiningExpression = new Attribute( "defined-meaning-defining-expression", "Defined meaning defining expression", "short-text" );
		$t->definedMeaningCompleteDefiningExpressionStructure =
			new Structure( "defined-meaning-complete-defining-expression",
				  $t->definedMeaningDefiningExpression,
				  $t->expressionId,
				  $t->language
			);
		# try this
		$t->definedMeaningCompleteDefiningExpressionStructure->setStructureType( $wgExpression );
		$t->definedMeaningCompleteDefiningExpression = new Attribute( null, "Defining expression", $t->definedMeaningCompleteDefiningExpressionStructure );

		global $definedMeaningReferenceType;

		$t->definedMeaningLabel = new Attribute( "defined-meaning-label", "Defined meaning label", "short-text" );
		$t->definedMeaningReferenceStructure = new Structure( $wgDefinedMeaning, $t->definedMeaningId, $t->definedMeaningLabel, $t->definedMeaningDefiningExpression );
		$definedMeaningReferenceType = $t->definedMeaningReferenceStructure;
		$t->definedMeaningReference = new Attribute( null, wfMsgSc( "DefinedMeaningReference" ), $definedMeaningReferenceType );
		$t->collectionId = new Attribute( "collection", "Collection", "collection-id" );
		$t->collectionMeaning = new Attribute( "collection-meaning", wfMsgSc( "Collection" ), $t->definedMeaningReferenceStructure );
		$t->sourceIdentifier = new Attribute( "source-identifier", wfMsgSc( "SourceIdentifier" ), "short-text" );
		$t->gotoSourceStructure = new Structure( "goto-source", $t->collectionId, $t->sourceIdentifier );
		$t->gotoSource = new Attribute( null, wfMsgSc( "GotoSource" ), $t->gotoSourceStructure );

		$t->collectionMembershipStructure = new Structure( $wgCollectionMembership, $t->collectionId, $t->collectionMeaning, $t->sourceIdentifier );
		$t->collectionMembership = new Attribute( null, wfMsgSc( "CollectionMembership" ), $t->collectionMembershipStructure );

		$t->classMembershipId = new Attribute( "class-membership-id", "Class membership id", "integer" );
		$t->class = new Attribute( "class", wfMsg( 'ow_Class' ), $t->definedMeaningReferenceStructure );
		$t->classMembershipStructure = new Structure( $wgClassMembership, $t->classMembershipId, $t->class );
		$t->classMembership = new Attribute( null, wfMsgSc( "ClassMembership" ), $t->classMembershipStructure );

		global $relationTypeType;

		$t->relationId = new Attribute( "relation-id", "Relation identifier", "object-id" );
		$t->relationType = new Attribute( "relation-type", wfMsgSc( "RelationType" ), $t->definedMeaningReferenceStructure );
		$t->otherDefinedMeaning = new Attribute( $wgOtherDefinedMeaning, wfMsgSc( "OtherDefinedMeaning" ), $definedMeaningReferenceType );

		$t->relationStructure = new Structure( $wgRelations, $t->relationId, $t->relationType, $t->otherDefinedMeaning );
		$t->relations = new Attribute( $wgRelations, wfMsgSc( "Relations" ), $t->relationStructure );
		$t->reciprocalRelations = new Attribute( $wgIncomingRelations, wfMsgSc( "IncomingRelations" ), $t->relationStructure );
		$t->translatedTextId = new Attribute( "translated-text-id", "Translated text ID", "integer" );
		$t->translatedTextStructure = new Structure( $wgTranslatedText, $t->language, $t->text );

		$t->definitionId = new Attribute( "definition-id", "Definition identifier", "integer" );

		if ( $viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes() )
			$t->alternativeDefinition = new Attribute( $wgAlternativeDefinition, wfMsgSc( "AlternativeDefinition" ), "text" );
		else
			$t->alternativeDefinition = new Attribute( $wgAlternativeDefinition, wfMsgSc( "AlternativeDefinition" ), $t->translatedTextStructure );
		
		$t->source = new Attribute( "source-id", wfMsgSc( "Source" ), $definedMeaningReferenceType );
		
		$t->alternativeDefinitionsStructure =  new Structure( $wgAlternativeDefinitions, $t->definitionId, $t->alternativeDefinition, $t->source );
		$t->alternativeDefinitions = new Attribute( null, wfMsgSc( "AlternativeDefinitions" ), $t->alternativeDefinitionsStructure );
		
		if ( $viewInformation->filterOnLanguage() )
			$synonymsAndTranslationsCaption = wfMsgSc( "Synonyms" );
		else
			$synonymsAndTranslationsCaption = wfMsgSc( "SynonymsAndTranslations" );

		$t->syntransId = new Attribute( "syntrans-id", "$synonymsAndTranslationsCaption identifier", "integer" );
		$t->synonymsTranslationsStructure = new Structure( $wgSynonymsAndTranslations, $t->syntransId, $t->expression, $t->identicalMeaning );
		$t->synonymsAndTranslations = new Attribute( null, "$synonymsAndTranslationsCaption", $t->synonymsTranslationsStructure );
		$t->translatedTextAttributeId = new Attribute( "translated-text-attribute-id", "Attribute identifier", "object-id" );
		$t->translatedTextAttribute = new Attribute( "translated-text-attribute", wfMsgSc( "TranslatedTextAttribute" ), $definedMeaningReferenceType );
		$t->translatedTextValueId = new Attribute( "translated-text-value-id", "Translated text value identifier", "translated-text-value-id" );
		
		$t->attributeObjectId = new Attribute( "attributeObjectId", "Attribute object", "object-id" );

		if ( $viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes() )
			$t->translatedTextValue = new Attribute( "translated-text-value", wfMsgSc( "TranslatedTextAttributeValue" ), "text" );
		else
			$t->translatedTextValue = new Attribute( "translated-text-value", wfMsgSc( "TranslatedTextAttributeValue" ), $t->translatedTextStructure );
		
		$t->translatedTextAttributeValuesStructure = new Structure( "translated-text-attribute-values", $t->translatedTextAttributeId, $t->attributeObjectId, $t->translatedTextAttribute, $t->translatedTextValueId, $t->translatedTextValue );
		$t->translatedTextAttributeValues = new Attribute( null, wfMsgSc( "TranslatedTextAttributeValues" ), $t->translatedTextAttributeValuesStructure );
		$t->attributeObject = new Attribute( "attribute-object-id", "Attribute object", "object-id" );

		$t->textAttributeId = new Attribute( "text-attribute-id", "Attribute identifier", "object-id" );
		$t->textAttributeObject = new Attribute( "text-attribute-object-id", "Attribute object", "object-id" );
		$t->textAttribute = new Attribute( "text-attribute", wfMsgSc( "TextAttribute" ), $t->definedMeaningReferenceStructure );
		$t->textAttributeValuesStructure = new Structure( $wgTextAttributeValues, $t->textAttributeId, $t->textAttributeObject, $t->textAttribute, $t->text );
		$t->textAttributeValues = new Attribute( null, wfMsgSc( "TextAttributeValues" ), $t->textAttributeValuesStructure );
		
		$t->linkLabel = new Attribute( "label", wfMsg( 'ow_Label' ), "short-text" );
		$t->linkURL = new Attribute( "url", wfMsg( 'ow_URL' ), "url" );
		$t->link = new Attribute( "link", wfMsg( 'ow_Link' ), new Structure( $t->linkLabel, $t->linkURL ) );
		$t->linkAttributeId = new Attribute( "link-attribute-id", "Attribute identifier", "object-id" );
		$t->linkAttributeObject = new Attribute( "link-attribute-object-id", "Attribute object", "object-id" );
		$t->linkAttribute = new Attribute( $wgLinkAttribute, wfMsgSc( "LinkAttribute" ), $t->definedMeaningReferenceStructure );
		$t->linkAttributeValuesStructure = new Structure( $wgLinkAttributeValues, $t->linkAttributeId, $t->linkAttributeObject, $t->linkAttribute, $t->link );
		$t->linkAttributeValues = new Attribute( null, wfMsgSc( "LinkAttributeValues" ), $t->linkAttributeValuesStructure );
		
		$t->optionAttributeId = new Attribute( "option-attribute-id", "Attribute identifier", "object-id" );
		$t->optionAttributeObject = new Attribute( "option-attribute-object-id", "Attribute object", "object-id" );
		$t->optionAttribute = new Attribute( $wgOptionAttribute, wfMsgSc( "OptionAttribute" ), $definedMeaningReferenceType );
		$t->optionAttributeOption = new Attribute( $wgOptionAttributeOption, wfMsgSc( "OptionAttributeOption" ), $definedMeaningReferenceType );
		$t->optionAttributeValuesStructure = new Structure( $wgOptionAttributeValues, $t->optionAttributeId, $t->optionAttribute, $t->optionAttributeObject, $t->optionAttributeOption );
		$t->optionAttributeValues = new Attribute( null, wfMsgSc( "OptionAttributeValues" ), $t->optionAttributeValuesStructure );
		$t->optionAttributeOptionId = new Attribute( "option-attribute-option-id", "Option identifier", "object-id" );
		$t->optionAttributeOptionsStructure = new Structure( "option-attribute-options", $t->optionAttributeOptionId, $t->optionAttribute, $t->optionAttributeOption, $t->language );
		$t->optionAttributeOptions = new Attribute( null, wfMsgSc( "OptionAttributeOptions" ), $t->optionAttributeOptionsStructure );
		
		if ( $viewInformation->filterOnLanguage() && !$viewInformation->hasMetaDataAttributes() )
			$t->translatedText = new Attribute( $wgTranslatedText, wfMsgSc( "Text" ), "text" );
		else
			$t->translatedText = new Attribute( $wgTranslatedText, wfMsgSc( "TranslatedText" ), $t->translatedTextStructure );
			

		$t->definition = new Attribute( null, wfMsgSc( "Definition" ), new Structure( $wgDefinition, $t->translatedText ) );

		$t->classAttributeId = new Attribute( "class-attribute-id", "Class attribute identifier", "object-id" );
		$t->classAttributeAttribute = new Attribute( "class-attribute-attribute", wfMsgSc( "ClassAttributeAttribute" ), $t->definedMeaningReferenceStructure );
		$t->classAttributeLevel = new Attribute( "class-attribute-level", wfMsgSc( "ClassAttributeLevel" ), $t->definedMeaningReferenceStructure );
		$t->classAttributeType = new Attribute( "class-attribute-type", wfMsgSc( "ClassAttributeType" ), "short-text" );
		$t->classAttributesStructure = new Structure( $wgClassAttributes, $t->classAttributeId, $t->classAttributeAttribute, $t->classAttributeLevel, $t->classAttributeType, $t->optionAttributeOptions );
		$t->classAttributes = new Attribute( null, wfMsgSc( "ClassAttributes" ), $t->classAttributesStructure );

		$t->definedMeaning = new Attribute( null, wfMsgSc( "DefinedMeaning" ),
			new Structure(
				$wgDefinedMeaning,
				$t->definedMeaningId,
				$t->definedMeaningCompleteDefiningExpression,
				$t->definition,
				$t->classAttributes,
				$t->alternativeDefinitions,
				$t->synonymsAndTranslations,
				$t->reciprocalRelations,
				$t->classMembership,
				$t->collectionMembership,
				$t->definedMeaningAttributes
			)
		);

		$t->expressionMeaningStructure = new Structure( $t->definedMeaningId, $t->text, $t->definedMeaning );
		$t->expressionExactMeanings = new Attribute( $wgExpressionExactMeanings, wfMsgSc( "ExactMeanings" ), $t->expressionMeaningStructure );
		$t->expressionApproximateMeanings = new Attribute( $wgExpressionApproximateMeanings, wfMsgSc( "ApproximateMeanings" ), $t->expressionMeaningStructure );
		$t->expressionMeaningsStructure = new Structure( $wgExpressionMeanings, $t->expressionExactMeanings, $t->expressionApproximateMeanings );
		$t->expressionMeanings = new Attribute( null, wfMsgSc( "ExpressionMeanings" ), $t->expressionMeaningsStructure );
		$t->expressionsStructure = new Structure( "expressions", $t->expressionId, $t->expression, $t->expressionMeanings );
		$t->expressions = new Attribute( null, wfMsgSc( "Expressions" ), $t->expressionsStructure );
		
		$t->objectId = new Attribute( "object-id", "Object identifier", "object-id" );
		$t->objectAttributesStructure = new Structure( "object-attributes",
			$t->objectId,
			$t->relations,
			$t->textAttributeValues,
			$t->translatedTextAttributeValues,
			$t->linkAttributeValues,
			$t->optionAttributeValues
		);
		
		$t->objectAttributes->setAttributeType( $t->objectAttributesStructure );
		$t->definedMeaningAttributes->setAttributeType( $t->objectAttributesStructure );
		
		$annotatedAttributes = array(
			$t->definedMeaning,
			$t->definition,
			$t->synonymsAndTranslations,
			$t->relations,
			$t->reciprocalRelations,
			$t->textAttributeValues,
			$t->linkAttributeValues,
			$t->translatedTextAttributeValues,
			$t->optionAttributeValues
		);
		
		foreach ( $annotatedAttributes as $annotatedAttribute )
			$annotatedAttribute->type->addAttribute( $t->objectAttributes );
		
		foreach ( $viewInformation->getPropertyToColumnFilters() as $propertyToColumnFilter ) {
			$attribute = $propertyToColumnFilter->getAttribute();
			$attribute->setAttributeType( $t->objectAttributesStructure );
			
			foreach ( $annotatedAttributes as $annotatedAttribute )
				$annotatedAttribute->type->addAttribute( $attribute );
		}
		
		# transaction stuff 
		$t->transactionId = new Attribute( 'transaction-id', 'Transaction ID', 'integer' );
		$t->user = new Attribute( 'user', wfMsg( 'ow_User' ), 'user' );
		$t->userIP = new Attribute( 'user-ip', 'User IP', 'IP' );
		$t->timestamp = new Attribute( 'timestamp', wfMsg( 'ow_Time' ), 'timestamp' );
		$t->summary = new Attribute( 'summary', 'Summary', 'text' );
		$t->transactionStructure = new Structure( $t->transactionId, $t->user, $t->userIP, $t->timestamp, $t->summary );
		$t->transaction = new Attribute( 'transaction', 'Transaction', $t->transactionStructure );

		$t->addTransaction = new Attribute( 'add-transaction', wfMsg( 'ow_added' ), $t->transactionStructure );
		$t->removeTransaction = new Attribute( 'remove-transaction', wfMsg( 'ow_removed' ), $t->transactionStructure );

		$t->recordLifeSpanStructure = new Structure( $t->addTransaction, $t->removeTransaction );
		$t->recordLifeSpan = new Attribute( 'record-life-span', wfMsg( 'ow_RecordLifeSpan' ), $t->recordLifeSpanStructure );

		$t->in_setup = False;
	}
	/**
	 * FIXME - work in progress
	 */
	public function saveWithinTransaction() {
#		global
# 			$wgTitle, $wgUser, $wgRequest;

		global
			$wgUser, $wgOut;

		if ( !$wgUser->isAllowed( 'wikidata-copy' ) ) {
 			$wgOut->addWikiText( wfMsgSc( "noedit", $dc->fetchName() ) );
			$wgOut->setPageTitle( wfMsgSc( "noedit_title" ) );
 			return false;
 		}
		# $summary = $wgRequest->getText('summary');

		
		// Insert transaction information into the DB
		# startNewTransaction($wgUser->getID(), wfGetIP(), $summary);
		startNewTransaction( 0, "0.0.0.0", "copy operation" );

		// Perform regular save
		# $this->save(new QueryAtTransactionInformation($wgRequest->getInt('transaction'), false));
		$newDefinedMeaningId = $this->save();

		// Update page caches
		# Title::touchArray(array($wgTitle));

		// Add change to RC log
		# $now = wfTimestampNow();
		# RecentChange::notifyEdit($now, $wgTitle, false, $wgUser, $summary, 0, $now, false, '', 0, 0, 0);
		return $newDefinedMeaningId;
	}
	protected function list_sets() {
		global $wgOut;
		$wgOut->addWikiText( "<h2>" . wfMsgSc( "available contexts" ) . "</h2>" );
		$sets = wdGetDataSets();
		foreach ( $sets as $key => $set ) {
			$name = $set->fetchName();
			$wgOut->addWikiText( "$key => $name" );
		}
	}
function getStaticSuggest( $name, $suggestions, $idColumns = 1, $value = 0, $label = '', $displayLabelColumns = array( 0 ) ) {
	if ( $label == "" )
		$label = '&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;';

	$result =
		'<span class="suggest">' .
//			'<input type="hidden" id="'. $name .'-suggest-query" value="'. $query .'"/>' .
			'<input type="hidden" id="' . $name . '-suggest-label-columns" value="' . implode( ', ', $displayLabelColumns ) . '"/>' .
			'<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . $value . '"/>';

	if ( $idColumns > 1 )
		$result .= '<input type="hidden" id="' . $name . '-suggest-id-columns" value="' . $idColumns . '"/>';

	$result .=
			'<a id="' . $name . '-suggest-link" class="suggest-link" onclick="suggestLinkClicked(event, this);" title="' . wfMsgSc( "SuggestHint" ) . '">' . $label . '</a>' .
		'</span>' .
        '<div class="suggest-drop-down" style="position: relative"><div id="' . $name . '-suggest-div" style="position: absolute; left: 0px; top: 0px; border: 1px solid #000000; display: none; background-color: white; padding: 4px">' .
        	'<div><table><tr><td>' .
//        	'<input type="text" id="'. $name .'-suggest-text" autocomplete="off" onkeyup="suggestTextChanged(this)" style="width: 300px"></input>' .
        	'</td><td><a id="' . $name . '-suggest-clear" href="javascript:void(0)" onclick="suggestClearClicked(event, this)">' . wfMsg( 'ow_suggest_clear' ) . '</a></td><td><a id="' . $name . '-suggest-close" href="#' . $name . '-suggest-link" onclick="suggestCloseClicked(event, this)">[X]</a></td></tr></table></div>' .
        	'<div>' . $suggestions .
        	// <table id="'. $name .'-suggest-table"><tr><td></td></tr></table>
        	'</div>' .
        '</div></div>';
	
	return $result;
}
	function getAddRowAsHTML( IdStack $idPath, $repeatInput, $allowRemove ) {
		global
			$wgScriptPath;
		
		if ( $repeatInput )
			$rowClass = 'repeat';
		else
			$rowClass = '';

		$result = '<tr id="add-' . $idPath->getId() . '" class="' . $rowClass . '">';
		
		# + is add new Fo o(but grep this file for Add.png for more)
		if ( $allowRemove ) {
			$result .= '<td class="add"><img src="' . $wgScriptPath . '/extensions/Wikidata/Images/Add.png" title="' . wfMsgSc( "AddHint" ) . '" alt="Add" onclick="addEmptyRow(this.parentNode.parentNode.id);"/></td>' . EOL;
		}

		$result .= $this->getStructureAsAddCells( $idPath, $this );

		if ( $repeatInput )
			$result .= '<td class="input-rows"/>' .  EOL;

		return $result . '</tr>' . EOL;
	}