/**
  * 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 WikiPageMetaControl
  * @param integer $intWikiVersionId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing WikiPage object creation - defaults to CreateOrEdit
  * @return WikiPageMetaControl
  */
 public static function Create($objParentObject, $intWikiVersionId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intWikiVersionId)) {
         $objWikiPage = WikiPage::Load($intWikiVersionId);
         // WikiPage was found -- return it!
         if ($objWikiPage) {
             return new WikiPageMetaControl($objParentObject, $objWikiPage);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a WikiPage 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 WikiPageMetaControl($objParentObject, new WikiPage());
 }
 /**
  * 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;
     }
 }
示例#3
0
 /**
  * Reload this WikiPage 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 WikiPage object.');
     }
     // Reload the Object
     $objReloaded = WikiPage::Load($this->intWikiVersionId);
     // Update $this's local variables to match
     $this->WikiVersionId = $objReloaded->WikiVersionId;
     $this->__intWikiVersionId = $this->intWikiVersionId;
     $this->strContent = $objReloaded->strContent;
     $this->strCompiledHtml = $objReloaded->strCompiledHtml;
     $this->intViewCount = $objReloaded->intViewCount;
 }