/** * Static Helper Method to Create using PK arguments * You must pass in the PK arguments on an object to load, or leave it blank to create a new one. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to * edit, or if we are also allowed to create a new one, etc. * * @param mixed $objParentObject QForm or QPanel which will be using this WikiImageMetaControl * @param integer $intWikiVersionId primary key value * @param QMetaControlCreateType $intCreateType rules governing WikiImage object creation - defaults to CreateOrEdit * @return WikiImageMetaControl */ public static function Create($objParentObject, $intWikiVersionId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intWikiVersionId)) { $objWikiImage = WikiImage::Load($intWikiVersionId); // WikiImage was found -- return it! if ($objWikiImage) { return new WikiImageMetaControl($objParentObject, $objWikiImage); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a WikiImage object with PK arguments: ' . $intWikiVersionId); } } // If EditOnly is specified, throw an exception } else { if ($intCreateType == QMetaControlCreateType::EditOnly) { throw new QCallerException('No PK arguments specified'); } } // If we are here, then we need to create a new record return new WikiImageMetaControl($objParentObject, new WikiImage()); }
/** * This will save this object's WikiVersion instance, * updating only the fields which have had a control created for it. */ public function SaveWikiVersion() { try { // Update any fields for controls that have been created if ($this->lstWikiItem) { $this->objWikiVersion->WikiItemId = $this->lstWikiItem->SelectedValue; } if ($this->txtVersionNumber) { $this->objWikiVersion->VersionNumber = $this->txtVersionNumber->Text; } if ($this->txtName) { $this->objWikiVersion->Name = $this->txtName->Text; } if ($this->lstPostedByPerson) { $this->objWikiVersion->PostedByPersonId = $this->lstPostedByPerson->SelectedValue; } if ($this->calPostDate) { $this->objWikiVersion->PostDate = $this->calPostDate->DateTime; } // Update any UniqueReverseReferences (if any) for controls that have been created for it if ($this->lstWikiFile) { $this->objWikiVersion->WikiFile = WikiFile::Load($this->lstWikiFile->SelectedValue); } if ($this->lstWikiImage) { $this->objWikiVersion->WikiImage = WikiImage::Load($this->lstWikiImage->SelectedValue); } if ($this->lstWikiItemAsCurrent) { $this->objWikiVersion->WikiItemAsCurrent = WikiItem::Load($this->lstWikiItemAsCurrent->SelectedValue); } if ($this->lstWikiPage) { $this->objWikiVersion->WikiPage = WikiPage::Load($this->lstWikiPage->SelectedValue); } // Save the WikiVersion object $this->objWikiVersion->Save(); // Finally, update any ManyToManyReferences (if any) } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } }
/** * Reload this WikiImage from the database. * @return void */ public function Reload() { // Make sure we are actually Restored from the database if (!$this->__blnRestored) { throw new QCallerException('Cannot call Reload() on a new, unsaved WikiImage object.'); } // Reload the Object $objReloaded = WikiImage::Load($this->intWikiVersionId); // Update $this's local variables to match $this->WikiVersionId = $objReloaded->WikiVersionId; $this->__intWikiVersionId = $this->intWikiVersionId; $this->ImageFileTypeId = $objReloaded->ImageFileTypeId; $this->intWidth = $objReloaded->intWidth; $this->intHeight = $objReloaded->intHeight; $this->strDescription = $objReloaded->strDescription; }