private static function applyObjID( WikiObjectModel $wom, WOMPageModel $root ) {
		$wom->setObjectID( $root->getNextId() );
		$root->addToPageObjectSet( $wom );
		if ( $wom instanceof WikiObjectModelCollection ) {
			foreach ( $wom->getObjects() as $obj ) {
				self::applyObjID( $obj, $root );
			}
		}
	}
	function updateObject( WikiObjectModel $obj, $id ) {
		$obj->setObjectID( $id );
		$obj->setParent( $this );

		$objs = array();
		foreach ( $this->m_objects as $o ) {
			if ( $id == $o->getObjectID() ) {
				$objs[] = $obj;
			} else {
				$objs[] = $o;
			}
		}
		$this->m_objects = $objs;
	}
	public function appendChildObject( WikiObjectModel $obj, $id = '' ) {
		if ( $id == '' ) {
			$p = $this;
		} else {
			$p = $this->m_page_objs[$id];
			if ( !( $p instanceof WikiObjectModelCollection ) ) {
				return;
			}
		}
		$obj->setObjectID( $this->getNextId() );
		$p->insertObject( $obj );

		$this->addToPageObjectSet( $obj );
	}
	public function __construct( $property, $label = '', $aggregation = '' ) {
		parent::__construct( WOM_TYPE_QUERYPRINTOUT );
		$this->m_property = $property;
		$this->m_label = $label;

		$this->m_aggregation = ( defined( 'SMW_AGGREGATION_VERSION' ) ? $aggregation : '' );
	}
	public function __construct( $name ) {
		parent::__construct( WOM_TYPE_CATEGORY );
		$title = Title::newFromText( $name, NS_CATEGORY );
		if ( $title == null ) {
			// no idea why, just leave it
			$this->m_name = $name;
		} else {
			$this->m_name = $title->getText();
		}
	}
	public function __construct( $property, $value, $caption = '' ) {
		parent::__construct( WOM_TYPE_PROPERTY );

		if ( !defined( 'SMW_VERSION' ) ) {
			// MW hook will catch this exception
			throw new MWException( __METHOD__ . ": Property model is invalid. Please install 'SemanticMediaWiki extension' first." );
		}

		$user_property = SMWPropertyValue::makeUserProperty( $property );
		if ( count ( $user_property->getErrors() ) > 0 ) {
			$user_property = SMWPropertyValue::makeUserProperty( '///NA///' );
		} else {
			$property = '';
		}
		$smwdatavalue = null;
		// FIXME: property should be collection object according to templates
		// if template/field used
		if ( preg_match ( '/\{\{.+\}\}/s', $value . $caption ) ) {
			$value = $value . ( $caption == '' ? '' : "|{$caption}" );
			$caption = '';
		} else {
			if ( version_compare ( SMW_VERSION, '1.6', '>=' ) ) {
				$smwdatavalue = SMWDataValueFactory::newPropertyObjectValue( $user_property->getDataItem(), $value, $caption );
			} else {
				$smwdatavalue = SMWDataValueFactory::newPropertyObjectValue( $user_property, $value, $caption );
			}
			if ( count ( $smwdatavalue->getErrors() ) > 0 ) {
				$smwdatavalue = null;
			}
		}

		$this->m_user_property = $user_property;
		$this->m_smwdatavalue = $smwdatavalue;
		$this->m_property = $property;
		$this->m_value = $value;
		$this->m_caption = $caption;
		$this->m_visible = !preg_match( '/^\s+$/', $caption );
	}
	public function __construct( $text = '' ) {
		parent::__construct( WOM_TYPE_TEXT );
		$this->m_text = $text;
	}
	public function __construct( $magicword, $doubleUnderscore = false ) {
		parent::__construct( WOM_TYPE_MAGICWORD );
		$this->m_magicword = $magicword;
		$this->m_doubleUnderscore = $doubleUnderscore;
	}
	public function __construct( $link, $caption = null ) {
		parent::__construct( WOM_TYPE_LINK );
		$this->m_link = $link;
		$this->m_caption = $caption;
	}