コード例 #1
0
 protected function Form_Create()
 {
     parent::Form_Create();
     $this->strSanitizedPath = WikiItem::SanitizeForPath(QApplication::$PathInfo, $intWikiItemTypeId);
     if ($this->intWikiItemTypeId != $intWikiItemTypeId) {
         throw new Exception('WikiItemTypeId Mismatch');
     }
     $this->objWikiItem = WikiItem::LoadByPathWikiItemTypeId($this->strSanitizedPath, $this->intWikiItemTypeId);
     $strWikiType = WikiItemType::$TokenArray[$this->intWikiItemTypeId];
     $strWikiClassName = 'Wiki' . $strWikiType;
     // See if we're editing or creating new
     if (!$this->objWikiItem) {
         $this->objWikiItem = new WikiItem();
         $objWikiVersion = new WikiVersion();
         $objWikiObject = new $strWikiClassName();
         $this->blnEditMode = false;
         $this->strPageTitle = 'Create New Wiki ' . $strWikiType;
         $this->strHeadline = 'Create a New Wiki ' . $strWikiType;
     } else {
         // Make sure this person is allowed to edit it
         if (!$this->objWikiItem->IsEditableForPerson(QApplication::$Person)) {
             QApplication::Redirect($this->objWikiItem->UrlPath);
         }
         // Get the Wiki Version object based on the $_GET variables, or use CurrentWikiVersion if none passed in
         $arrGetKeys = array_keys($_GET);
         $objWikiVersion = null;
         if (count($arrGetKeys) == 1) {
             $objWikiVersion = WikiVersion::LoadByWikiItemIdVersionNumber($this->objWikiItem->Id, $arrGetKeys[0]);
         }
         if (!$objWikiVersion) {
             $objWikiVersion = $this->objWikiItem->CurrentWikiVersion;
         }
         if (!$objWikiVersion->IsCurrentVersion()) {
             $this->intVersionNumber = $objWikiVersion->VersionNumber;
         }
         $objWikiObject = $objWikiVersion->__get($strWikiClassName);
         $this->blnEditMode = true;
         $this->strPageTitle .= $objWikiVersion->Name;
         $this->strHeadline = 'Edit Wiki ' . $strWikiType;
     }
     $this->CreateControlsForWikiVersionAndObject($objWikiVersion, $objWikiObject);
     $this->btnOkay = new QButton($this);
     $this->btnOkay->CausesValidation = true;
     $this->btnOkay->Text = $this->blnEditMode ? 'Update Wiki ' : 'Save New Wiki ';
     $this->btnOkay->Text .= $strWikiType;
     $this->btnCancel = new QLinkButton($this);
     $this->btnCancel->Text = 'Cancel';
     $this->btnOkay->AddAction(new QClickEvent(), new QToggleEnableAction($this->btnOkay));
     $this->btnOkay->AddAction(new QClickEvent(), new QServerAction('btnOkay_Click'));
     $this->btnCancel->AddAction(new QClickEvent(), new QServerAction('btnCancel_Click'));
     $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction());
     $this->txtTitle->Focus();
 }
コード例 #2
0
 /**
  * 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 WikiVersionMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing WikiVersion object creation - defaults to CreateOrEdit
  * @return WikiVersionMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objWikiVersion = WikiVersion::Load($intId);
         // WikiVersion was found -- return it!
         if ($objWikiVersion) {
             return new WikiVersionMetaControl($objParentObject, $objWikiVersion);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a WikiVersion object with PK arguments: ' . $intId);
             }
         }
         // 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 WikiVersionMetaControl($objParentObject, new WikiVersion());
 }
コード例 #3
0
 /**
  * Refresh this MetaControl with Data from the local WikiFile object.
  * @param boolean $blnReload reload WikiFile from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objWikiFile->Reload();
     }
     if ($this->lstWikiVersion) {
         $this->lstWikiVersion->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstWikiVersion->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objWikiVersionArray = WikiVersion::LoadAll();
         if ($objWikiVersionArray) {
             foreach ($objWikiVersionArray as $objWikiVersion) {
                 $objListItem = new QListItem($objWikiVersion->__toString(), $objWikiVersion->Id);
                 if ($this->objWikiFile->WikiVersion && $this->objWikiFile->WikiVersion->Id == $objWikiVersion->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstWikiVersion->AddItem($objListItem);
             }
         }
     }
     if ($this->lblWikiVersionId) {
         $this->lblWikiVersionId->Text = $this->objWikiFile->WikiVersion ? $this->objWikiFile->WikiVersion->__toString() : null;
     }
     if ($this->txtFileName) {
         $this->txtFileName->Text = $this->objWikiFile->FileName;
     }
     if ($this->lblFileName) {
         $this->lblFileName->Text = $this->objWikiFile->FileName;
     }
     if ($this->txtFileSize) {
         $this->txtFileSize->Text = $this->objWikiFile->FileSize;
     }
     if ($this->lblFileSize) {
         $this->lblFileSize->Text = $this->objWikiFile->FileSize;
     }
     if ($this->txtFileMime) {
         $this->txtFileMime->Text = $this->objWikiFile->FileMime;
     }
     if ($this->lblFileMime) {
         $this->lblFileMime->Text = $this->objWikiFile->FileMime;
     }
     if ($this->txtDescription) {
         $this->txtDescription->Text = $this->objWikiFile->Description;
     }
     if ($this->lblDescription) {
         $this->lblDescription->Text = $this->objWikiFile->Description;
     }
     if ($this->txtDownloadCount) {
         $this->txtDownloadCount->Text = $this->objWikiFile->DownloadCount;
     }
     if ($this->lblDownloadCount) {
         $this->lblDownloadCount->Text = $this->objWikiFile->DownloadCount;
     }
 }
コード例 #4
0
 /**
  * Refresh this MetaControl with Data from the local WikiImage object.
  * @param boolean $blnReload reload WikiImage from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objWikiImage->Reload();
     }
     if ($this->lstWikiVersion) {
         $this->lstWikiVersion->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstWikiVersion->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objWikiVersionArray = WikiVersion::LoadAll();
         if ($objWikiVersionArray) {
             foreach ($objWikiVersionArray as $objWikiVersion) {
                 $objListItem = new QListItem($objWikiVersion->__toString(), $objWikiVersion->Id);
                 if ($this->objWikiImage->WikiVersion && $this->objWikiImage->WikiVersion->Id == $objWikiVersion->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstWikiVersion->AddItem($objListItem);
             }
         }
     }
     if ($this->lblWikiVersionId) {
         $this->lblWikiVersionId->Text = $this->objWikiImage->WikiVersion ? $this->objWikiImage->WikiVersion->__toString() : null;
     }
     if ($this->lstImageFileType) {
         $this->lstImageFileType->SelectedValue = $this->objWikiImage->ImageFileTypeId;
     }
     if ($this->lblImageFileTypeId) {
         $this->lblImageFileTypeId->Text = $this->objWikiImage->ImageFileTypeId ? ImageFileType::$NameArray[$this->objWikiImage->ImageFileTypeId] : null;
     }
     if ($this->txtWidth) {
         $this->txtWidth->Text = $this->objWikiImage->Width;
     }
     if ($this->lblWidth) {
         $this->lblWidth->Text = $this->objWikiImage->Width;
     }
     if ($this->txtHeight) {
         $this->txtHeight->Text = $this->objWikiImage->Height;
     }
     if ($this->lblHeight) {
         $this->lblHeight->Text = $this->objWikiImage->Height;
     }
     if ($this->txtDescription) {
         $this->txtDescription->Text = $this->objWikiImage->Description;
     }
     if ($this->lblDescription) {
         $this->lblDescription->Text = $this->objWikiImage->Description;
     }
 }
コード例 #5
0
 /**
  * Default / simple DataBinder for this Meta DataGrid.  This can easily be overridden
  * by calling SetDataBinder() on this DataGrid with another DataBinder of your choice.
  *
  * If a paginator is set on this DataBinder, it will use it.  If not, then no pagination will be used.
  * It will also perform any sorting (if applicable).
  */
 public function MetaDataBinder()
 {
     // Remember!  We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     if ($this->Paginator) {
         $this->TotalItemCount = WikiVersion::CountAll();
     }
     // Setup the $objClauses Array
     $objClauses = array();
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be a Query result from WikiVersion, given the clauses above
     $this->DataSource = WikiVersion::LoadAll($objClauses);
 }
コード例 #6
0
 /**
  * Main utility method to aid with data binding.  It is used by the default BindAllRows() databinder but
  * could and should be used by any custom databind methods that would be used for instances of this
  * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. 
  *
  * If a paginator is set on this DataBinder, it will use it.  If not, then no pagination will be used.
  * It will also perform any sorting (if applicable).
  *
  * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself
  * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query		 
  * @return void
  */
 public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null)
 {
     // Setup input parameters to default values if none passed in
     if (!$objCondition) {
         $objCondition = QQ::All();
     }
     $objClauses = $objOptionalClauses ? $objOptionalClauses : array();
     // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     if ($this->Paginator) {
         $this->TotalItemCount = WikiVersion::QueryCount($objCondition, $objClauses);
     }
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be a Query result from WikiVersion, given the clauses above
     $this->DataSource = WikiVersion::QueryArray($objCondition, $objClauses);
 }
コード例 #7
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objCurrentWikiVersion) {
         $objObject->objCurrentWikiVersion = WikiVersion::GetSoapObjectFromObject($objObject->objCurrentWikiVersion, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intCurrentWikiVersionId = null;
         }
     }
     if ($objObject->objCurrentPostedByPerson) {
         $objObject->objCurrentPostedByPerson = Person::GetSoapObjectFromObject($objObject->objCurrentPostedByPerson, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intCurrentPostedByPersonId = null;
         }
     }
     if ($objObject->dttCurrentPostDate) {
         $objObject->dttCurrentPostDate = $objObject->dttCurrentPostDate->__toString(QDateTime::FormatSoap);
     }
     return $objObject;
 }
コード例 #8
0
    /**
     * Deletes all associated WikiVersionsAsPostedBy
     * @return void
     */
    public function DeleteAllWikiVersionsAsPostedBy()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateWikiVersionAsPostedBy on this unsaved Person.');
        }
        // Get the Database Object for this Class
        $objDatabase = Person::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (WikiVersion::LoadArrayByPostedByPersonId($this->intId) as $objWikiVersion) {
                $objWikiVersion->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`wiki_version`
				WHERE
					`posted_by_person_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }
コード例 #9
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objWikiVersion) {
         $objObject->objWikiVersion = WikiVersion::GetSoapObjectFromObject($objObject->objWikiVersion, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intWikiVersionId = null;
         }
     }
     return $objObject;
 }
コード例 #10
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, WikiVersion::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
コード例 #11
0
 /**
  * Refresh this MetaControl with Data from the local WikiItem object.
  * @param boolean $blnReload reload WikiItem from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objWikiItem->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objWikiItem->Id;
         }
     }
     if ($this->txtPath) {
         $this->txtPath->Text = $this->objWikiItem->Path;
     }
     if ($this->lblPath) {
         $this->lblPath->Text = $this->objWikiItem->Path;
     }
     if ($this->lstWikiItemType) {
         $this->lstWikiItemType->SelectedValue = $this->objWikiItem->WikiItemTypeId;
     }
     if ($this->lblWikiItemTypeId) {
         $this->lblWikiItemTypeId->Text = $this->objWikiItem->WikiItemTypeId ? WikiItemType::$NameArray[$this->objWikiItem->WikiItemTypeId] : null;
     }
     if ($this->lstEditorMinimumPersonType) {
         $this->lstEditorMinimumPersonType->SelectedValue = $this->objWikiItem->EditorMinimumPersonTypeId;
     }
     if ($this->lblEditorMinimumPersonTypeId) {
         $this->lblEditorMinimumPersonTypeId->Text = $this->objWikiItem->EditorMinimumPersonTypeId ? PersonType::$NameArray[$this->objWikiItem->EditorMinimumPersonTypeId] : null;
     }
     if ($this->txtOverrideNavbarIndex) {
         $this->txtOverrideNavbarIndex->Text = $this->objWikiItem->OverrideNavbarIndex;
     }
     if ($this->lblOverrideNavbarIndex) {
         $this->lblOverrideNavbarIndex->Text = $this->objWikiItem->OverrideNavbarIndex;
     }
     if ($this->txtOverrideSubnavIndex) {
         $this->txtOverrideSubnavIndex->Text = $this->objWikiItem->OverrideSubnavIndex;
     }
     if ($this->lblOverrideSubnavIndex) {
         $this->lblOverrideSubnavIndex->Text = $this->objWikiItem->OverrideSubnavIndex;
     }
     if ($this->lstCurrentWikiVersion) {
         $this->lstCurrentWikiVersion->RemoveAllItems();
         $this->lstCurrentWikiVersion->AddItem(QApplication::Translate('- Select One -'), null);
         $objCurrentWikiVersionArray = WikiVersion::LoadAll();
         if ($objCurrentWikiVersionArray) {
             foreach ($objCurrentWikiVersionArray as $objCurrentWikiVersion) {
                 $objListItem = new QListItem($objCurrentWikiVersion->__toString(), $objCurrentWikiVersion->Id);
                 if ($this->objWikiItem->CurrentWikiVersion && $this->objWikiItem->CurrentWikiVersion->Id == $objCurrentWikiVersion->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstCurrentWikiVersion->AddItem($objListItem);
             }
         }
     }
     if ($this->lblCurrentWikiVersionId) {
         $this->lblCurrentWikiVersionId->Text = $this->objWikiItem->CurrentWikiVersion ? $this->objWikiItem->CurrentWikiVersion->__toString() : null;
     }
     if ($this->txtCurrentName) {
         $this->txtCurrentName->Text = $this->objWikiItem->CurrentName;
     }
     if ($this->lblCurrentName) {
         $this->lblCurrentName->Text = $this->objWikiItem->CurrentName;
     }
     if ($this->lstCurrentPostedByPerson) {
         $this->lstCurrentPostedByPerson->RemoveAllItems();
         $this->lstCurrentPostedByPerson->AddItem(QApplication::Translate('- Select One -'), null);
         $objCurrentPostedByPersonArray = Person::LoadAll();
         if ($objCurrentPostedByPersonArray) {
             foreach ($objCurrentPostedByPersonArray as $objCurrentPostedByPerson) {
                 $objListItem = new QListItem($objCurrentPostedByPerson->__toString(), $objCurrentPostedByPerson->Id);
                 if ($this->objWikiItem->CurrentPostedByPerson && $this->objWikiItem->CurrentPostedByPerson->Id == $objCurrentPostedByPerson->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstCurrentPostedByPerson->AddItem($objListItem);
             }
         }
     }
     if ($this->lblCurrentPostedByPersonId) {
         $this->lblCurrentPostedByPersonId->Text = $this->objWikiItem->CurrentPostedByPerson ? $this->objWikiItem->CurrentPostedByPerson->__toString() : null;
     }
     if ($this->calCurrentPostDate) {
         $this->calCurrentPostDate->DateTime = $this->objWikiItem->CurrentPostDate;
     }
     if ($this->lblCurrentPostDate) {
         $this->lblCurrentPostDate->Text = sprintf($this->objWikiItem->CurrentPostDate) ? $this->objWikiItem->__toString($this->strCurrentPostDateDateTimeFormat) : null;
     }
     if ($this->lstTopicLink) {
         $this->lstTopicLink->RemoveAllItems();
         $this->lstTopicLink->AddItem(QApplication::Translate('- Select One -'), null);
         $objTopicLinkArray = TopicLink::LoadAll();
         if ($objTopicLinkArray) {
             foreach ($objTopicLinkArray as $objTopicLink) {
                 $objListItem = new QListItem($objTopicLink->__toString(), $objTopicLink->Id);
                 if ($objTopicLink->WikiItemId == $this->objWikiItem->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstTopicLink->AddItem($objListItem);
             }
         }
     }
     if ($this->lblTopicLink) {
         $this->lblTopicLink->Text = $this->objWikiItem->TopicLink ? $this->objWikiItem->TopicLink->__toString() : null;
     }
 }
コード例 #12
0
 /**
  * Refresh this MetaControl with Data from the local WikiPage object.
  * @param boolean $blnReload reload WikiPage from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objWikiPage->Reload();
     }
     if ($this->lstWikiVersion) {
         $this->lstWikiVersion->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstWikiVersion->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objWikiVersionArray = WikiVersion::LoadAll();
         if ($objWikiVersionArray) {
             foreach ($objWikiVersionArray as $objWikiVersion) {
                 $objListItem = new QListItem($objWikiVersion->__toString(), $objWikiVersion->Id);
                 if ($this->objWikiPage->WikiVersion && $this->objWikiPage->WikiVersion->Id == $objWikiVersion->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstWikiVersion->AddItem($objListItem);
             }
         }
     }
     if ($this->lblWikiVersionId) {
         $this->lblWikiVersionId->Text = $this->objWikiPage->WikiVersion ? $this->objWikiPage->WikiVersion->__toString() : null;
     }
     if ($this->txtContent) {
         $this->txtContent->Text = $this->objWikiPage->Content;
     }
     if ($this->lblContent) {
         $this->lblContent->Text = $this->objWikiPage->Content;
     }
     if ($this->txtCompiledHtml) {
         $this->txtCompiledHtml->Text = $this->objWikiPage->CompiledHtml;
     }
     if ($this->lblCompiledHtml) {
         $this->lblCompiledHtml->Text = $this->objWikiPage->CompiledHtml;
     }
     if ($this->txtViewCount) {
         $this->txtViewCount->Text = $this->objWikiPage->ViewCount;
     }
     if ($this->lblViewCount) {
         $this->lblViewCount->Text = $this->objWikiPage->ViewCount;
     }
 }
コード例 #13
0
 /**
  * Counts all associated WikiVersionsAsPostedBy
  * @return int
  */
 public function CountWikiVersionsAsPostedBy()
 {
     if (is_null($this->intId)) {
         return 0;
     }
     return WikiVersion::CountByPostedByPersonId($this->intId);
 }
コード例 #14
0
ファイル: index.php プロジェクト: qcodo/qcodo-website
 protected function Form_Create()
 {
     $this->strSanitizedPath = WikiItem::SanitizeForPath(QApplication::$PathInfo, $this->intWikiItemTypeId);
     $this->objWikiItem = WikiItem::LoadByPathWikiItemTypeId($this->strSanitizedPath, $this->intWikiItemTypeId);
     $this->strPageTitle .= sprintf(' %s - ', WikiItemType::$NameArray[$this->intWikiItemTypeId]);
     // If Doesn't Exist, Show the 404 page
     if (!$this->objWikiItem) {
         parent::Form_Create();
         $this->strHtmlIncludeFilePath = dirname(__FILE__) . '/index_404.tpl.php';
         $this->strPageTitle .= QApplication::$PathInfo;
         return;
     }
     // cleanup any dangling versions (if applicable)
     if (!$this->objWikiItem->CurrentWikiVersion) {
         if ($this->objWikiItem->CleanupOrphans()) {
             parent::Form_Create();
             $this->strHtmlIncludeFilePath = dirname(__FILE__) . '/index_404.tpl.php';
             $this->strPageTitle .= QApplication::$PathInfo;
             return;
         }
     }
     // Get the Wiki Version object based on the $_GET variables, or use CurrentWikiVersion if none passed in
     $arrGetKeys = array_keys($_GET);
     if (count($arrGetKeys) == 1) {
         $this->objWikiVersion = WikiVersion::LoadByWikiItemIdVersionNumber($this->objWikiItem->Id, $arrGetKeys[0]);
     }
     if (!$this->objWikiVersion) {
         $this->objWikiVersion = $this->objWikiItem->CurrentWikiVersion;
     }
     // Setup NavBar and SubNav stuff (if applicable) and setup PageTitle
     if (!is_null($this->objWikiItem->OverrideNavbarIndex)) {
         $this->intNavBarIndex = $this->objWikiItem->OverrideNavbarIndex;
         $this->intSubNavIndex = $this->objWikiItem->OverrideSubnavIndex;
         $this->strPageTitle = $this->objWikiVersion->Name;
     } else {
         $this->strPageTitle .= $this->objWikiVersion->Name;
     }
     // Create Controls for Page
     parent::Form_Create();
     if ($this->objWikiItem->IsEditableForPerson(QApplication::$Person)) {
         $this->btnSetAsCurrentVersion = new QLinkButton($this);
         $this->btnSetAsCurrentVersion->Text = 'Set as Current';
         $this->btnSetAsCurrentVersion->AddAction(new QClickEvent(), new QAjaxAction('btnSetAsCurrentVersion_Click'));
         $this->btnSetAsCurrentVersion->AddAction(new QClickEvent(), new QTerminateAction());
     }
     // Setup the Main Content Area
     $this->pnlContent = new QPanel($this);
     $this->pnlContent->CssClass = 'wiki';
     $this->pnlContentHeadline = new QPanel($this->pnlContent);
     $this->pnlContentHeadline->Template = 'pnlContentHeadline.tpl.php';
     $this->btnEdit = new RoundedLinkButton($this->pnlContentHeadline);
     $this->btnEdit->AddAction(new QClickEvent(), new QAjaxAction('btnEdit_Click'));
     $this->btnEdit->AddAction(new QClickEvent(), new QTerminateAction());
     $this->btnEdit->AddCssClass('roundedLinkGray');
     $this->btnToggleVersions = new RoundedLinkButton($this->pnlContentHeadline);
     $this->btnToggleVersions->AddAction(new QClickEvent(), new QAjaxAction('btnToggleVersions_Click'));
     $this->btnToggleVersions->AddAction(new QClickEvent(), new QTerminateAction());
     $this->btnToggleMessages = new RoundedLinkButton($this->pnlContentHeadline);
     $this->btnToggleMessages->AddAction(new QClickEvent(), new QAjaxAction('btnToggleMessages_Click'));
     $this->btnToggleMessages->AddAction(new QClickEvent(), new QTerminateAction());
     if ($this->objWikiItem->IsAdminableForPerson(QApplication::$Person)) {
         $this->btnAdmin = new RoundedLinkButton($this->pnlContentHeadline);
         $this->btnAdmin->AddAction(new QClickEvent(), new QAjaxAction('btnAdmin_Click'));
         $this->btnAdmin->AddAction(new QClickEvent(), new QTerminateAction());
         $this->btnAdmin->AddCssClass('roundedLinkGray');
         $this->btnAdmin->Text = 'Admin This Wiki';
     }
     $this->pnlVersions = new WikiVersionsPanel($this->objWikiItem, $this, 'wikiVersionsPanel');
     if (count($arrGetKeys) && is_numeric($arrGetKeys[0])) {
         $this->pnlVersions_Show();
     } else {
         $this->pnlVersions_Hide();
     }
     // Set the template path baed on the wiki item type
     $this->SetTemplatePath();
     // Setup DateTime of Post
     $dttLocalize = QApplication::LocalizeDateTime($this->objWikiVersion->PostDate);
     $this->strPostStartedLinkText = strtolower($dttLocalize->__toString('DDDD, MMMM D, YYYY, h:mm z ')) . strtolower(QApplication::DisplayTimezoneLink($dttLocalize, false));
     // Setup messages panel
     $this->pnlMessages = new MessagesPanel($this);
     $this->pnlMessages->SelectTopic($this->objWikiItem->TopicLink->GetTopic());
     $this->pnlMessages->lblTopicInfo_SetTemplate(__INCLUDES__ . '/messages/lblTopicInfoForWiki.tpl.php');
     $this->pnlMessages->btnRespond1->Text = 'Post Comment';
     $this->pnlMessages->btnRespond2->Text = 'Post Comment';
     $this->pnlMessages->strAdditionalCssClass = 'topicForWiki';
     if (array_key_exists('lastpage', $_GET)) {
         $this->pnlMessages->SetPageNumber(QPaginatedControl::LastPage);
         $this->pnlMessages_Show();
     } else {
         if (QApplication::IsWikiViewComments()) {
             $this->pnlMessages_Show();
         } else {
             $this->pnlMessages_Hide();
         }
     }
 }
コード例 #15
0
 /**
  * Given a Wiki object for this WikiItem, this will post it as a new version.
  * 
  * The passed in WikiObject will be saved to the database 
  * @param string $strName the name of this WikiItem
  * @param object $objWikiObject the linked Wiki object (e.g. WikiPage or WikiImage) that is not yet saved or assigned
  * @param string $strSaveMethod the name of the Save method to call on the WikiObject
  * @param array $arrSaveParameters an array of parameters to pass in to the Save method on the WikiObject
  * @param Person $objPerson the Person who posted it
  * @param QDateTime $dttPostDate the optional datetime of the post (will use NOW if none passed)
  * @return WikiVersion
  */
 public function CreateNewVersion($strName, $objWikiObject, $strSaveMethod, $arrSaveParameters, Person $objPerson, QDateTime $dttPostDate = null)
 {
     // Ensure the WikiObject is not yet saved or assigned
     if ($objWikiObject->WikiVersionId) {
         throw new QCallerException('WikiObject is already saved or has already been assigned to a version');
     }
     // Ensure the WikiObject is the right type
     if (WikiItemType::$ClassNameArray[$this->intWikiItemTypeId] != get_class($objWikiObject)) {
         throw new QCallerException('WikiObject class does not match this wiki item type');
     }
     // Create and Save the WikiVersion
     $objWikiVersion = new WikiVersion();
     $objWikiVersion->WikiItem = $this;
     $objWikiVersion->VersionNumber = $this->CountWikiVersions() + 1;
     $objWikiVersion->Name = trim($strName);
     $objWikiVersion->PostedByPerson = $objPerson;
     $objWikiVersion->PostDate = $dttPostDate ? $dttPostDate : QDateTime::Now();
     $objWikiVersion->Save();
     // Assign the WikiObject
     $objWikiObject->WikiVersion = $objWikiVersion;
     // Save the WikiObject using the MethodName and MethodParameters passed in
     if (is_null($arrSaveParameters)) {
         $arrSaveParameters = array();
     }
     call_user_func_array(array($objWikiObject, $strSaveMethod), $arrSaveParameters);
     // Update my metadata
     $this->SetCurrentVersion($objWikiVersion);
     // Return
     return $objWikiVersion;
 }