public function view() {
		global
			$wgOut, $wgTitle, $wgRequest, $wdCurrentContext;

		// Split title into defining expression and ID
		$titleText = $wgTitle->getText();
		$dmInfo = DefinedMeaningModel::splitTitleText( $titleText );

		// Title doesn't have an ID in it (or ID 0)
		if ( is_null( $dmInfo ) || !$dmInfo["id"] ) {
			$wgOut->showErrorPage( 'errorpagetitle', 'ow_dm_badtitle' );
			return false;
		}
		parent::view();
		$definedMeaningModel = new DefinedMeaningModel( $dmInfo["id"], $this->viewInformation );
		$this->definedMeaningModel = $definedMeaningModel; # TODO if I wasn't so sleepy I'd make this consistent

		$copyTo = $wgRequest->getText( 'CopyTo' );
		if ( $copyTo ) {
			$definedMeaningModel->copyTo( $copyTo );
		}

		if ( !empty( $dmInfo["expression"] ) ) {
		 	$definedMeaningModel->setDefiningExpression( $dmInfo["expression"] );
		}

		// Search for this DM in all data-sets, beginning with the current one.
		// Switch dataset context if found elsewhere.
		$match = $definedMeaningModel->checkExistence( true, true );

		// The defining expression is likely incorrect for some reason. Let's just
		// try looking up the number.
		if ( is_null( $match ) && !empty( $dmInfo["expression"] ) ) {
			$definedMeaningModel->setDefiningExpression( null );
			$dmInfo["expression"] = null;
			$match = $definedMeaningModel->checkExistence( true, true );
		}

		// The defining expression is either bad or missing. Let's redirect
		// to the correct URL.
		if ( empty( $dmInfo["expression"] ) && !is_null( $match ) ) {
			$definedMeaningModel->loadRecord();
			$title = Title::newFromText( $definedMeaningModel->getWikiTitle() );
			$url = $title->getFullURL();
			$wgOut->disable();
			header( "Location: $url" );
			return false;
		}

		// Bad defining expression AND bad ID! :-(
		if ( is_null( $match ) ) {
			$wgOut->showErrorPage( 'errorpagetitle', 'ow_dm_missing' );
			return false;
		}

		$definedMeaningModel->loadRecord();
		$this->showDataSetPanel = false;

		# Raw mode
		$view_as = $wgRequest->getText( 'view_as' );
		if ( $view_as == "raw" ) {
			$wgOut->addHTML( "<pre>" . $definedMeaningModel->getRecord() . "</pre>" );
			# $wgOut->disable();
			return;
		}

		$this->outputViewHeader();
// concept panel is annoying and useless
//		$wgOut->addHTML( $this->getConceptPanel() );
		$editor = getDefinedMeaningEditor( $this->viewInformation );
		$idStack = $this->getIdStack( $definedMeaningModel->getId() );
		$html = $editor->view( $idStack, $definedMeaningModel->getRecord() );
		$wgOut->addHTML( $html );
		$this->outputViewFooter();
	}
	protected function ui() {

		global $wgOut, $wgRequest, $wgLang, $wgDefinedMeaning;
		$lang = $wgLang->getCode();
		require_once( "forms.php" );
		$wgOut->addHTML( wfMsgSc( "conceptmapping_uitext" ) );
		$sets = wdGetDataSets();
		$options = array();
		$html = "";
		$mappings = array();
		$rq = array();

		foreach ( $sets as $key => $setObject ) {
			$set = $setObject->getPrefix();
			$rq[$set] = $wgRequest->getText( "set_" . $set );
			$rq[$set] = trim( $rq[$set] );
			$rq[$set] = (int)$rq[$set];
			if ( $rq[$set] ) {
				$dmModel = new DefinedMeaningModel( $rq[$set], null, $setObject );
				$defaultSel = $dmModel->getSyntransByLanguageCode( $lang );
				$options[$setObject->fetchName()] = getSuggest( "set_$set", $wgDefinedMeaning, array(), $rq[$set], $defaultSel, array( 0 ), $setObject );
			} else {
				$options[$setObject->fetchName()] = getSuggest( "set_$set", $wgDefinedMeaning, array(), null, null, array( 0 ), $setObject );
			}

		}
		$wgOut->addHTML( getOptionPanel( $options ) );
		$noerror = $wgRequest->getText( "suppressWarnings" );

		foreach ( $sets as $key => $setObject ) {
			$set = $setObject->getPrefix();
			if ( !$rq[$set] ) {
				$wgOut->addHTML( ' <span style="color:yellow">[' . wfMsgSc( "dm_not_present" ) . ']</span>' );
			} else  {
				$dmModel = new DefinedMeaningModel( $rq[$set], null, $setObject );
				$dmModel->checkExistence();
				if ( $dmModel->exists() ) {
					$id = $dmModel->getId();
					$title = $dmModel->getTitleText();
				} else {
					$id = null;
					$title = null;
				}
				if ( !$noerror ) {
					$wgOut->addHTML( "$key: " . $rq[$set] . " ($title)" );
				}
				if ( $id != null ) {
					$mappings[$key] = $id;
					if ( !$noerror ) {
						$wgOut->addHTML( ' <span style="color:green">[' . wfMsgSc( "dm_OK" ) . ']</span>' );
					}
				} else {
					if ( !$noerror ) {
						$wgOut->addHTML( ' <span style="color:red">[' . wfMsgSc( "dm_not_found" ) . ']</span>' );
					}
				}
			}
			$wgOut->addHTML( "<br />\n" );
		}
		if ( sizeOf( $mappings ) > 1 ) {
			createConceptMapping( $mappings );
			$wgOut->addHTML( wfMsgSc( "mapping_successful" ) );
		} else {
			$wgOut->addHTML( wfMsgSc( "mapping_unsuccessful" ) );
		}

	}