/**
  * 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 WikiFileMetaControl
  * @param integer $intWikiVersionId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing WikiFile object creation - defaults to CreateOrEdit
  * @return WikiFileMetaControl
  */
 public static function Create($objParentObject, $intWikiVersionId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intWikiVersionId)) {
         $objWikiFile = WikiFile::Load($intWikiVersionId);
         // WikiFile was found -- return it!
         if ($objWikiFile) {
             return new WikiFileMetaControl($objParentObject, $objWikiFile);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a WikiFile 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 WikiFileMetaControl($objParentObject, new WikiFile());
 }
 /**
  * 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;
     }
 }
Ejemplo n.º 3
0
 /**
  * Reload this WikiFile 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 WikiFile object.');
     }
     // Reload the Object
     $objReloaded = WikiFile::Load($this->intWikiVersionId);
     // Update $this's local variables to match
     $this->WikiVersionId = $objReloaded->WikiVersionId;
     $this->__intWikiVersionId = $this->intWikiVersionId;
     $this->strFileName = $objReloaded->strFileName;
     $this->intFileSize = $objReloaded->intFileSize;
     $this->strFileMime = $objReloaded->strFileMime;
     $this->strDescription = $objReloaded->strDescription;
     $this->intDownloadCount = $objReloaded->intDownloadCount;
 }