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
 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();
         }
     }
 }