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();
 }
Example #2
0
 protected function Form_Create()
 {
     parent::Form_Create();
     // Get the Wiki Item and confirm that it exists and that he is authorized to admin
     $this->strSanitizedPath = WikiItem::SanitizeForPath(QApplication::$PathInfo, $this->intWikiItemTypeId);
     $this->objWikiItem = WikiItem::LoadByPathWikiItemTypeId($this->strSanitizedPath, $this->intWikiItemTypeId);
     if (!$this->objWikiItem) {
         QApplication::Redirect('/');
     }
     if (!$this->objWikiItem->IsAdminableForPerson(QApplication::$Person)) {
         QApplication::RedirectToLogin();
     }
     $this->strPageTitle .= $this->objWikiItem->CurrentName;
     $this->lstEditorMinimum = new QListBox($this);
     foreach (PersonType::$NameArray as $intTypeId => $strName) {
         $this->lstEditorMinimum->AddItem($strName, $intTypeId, $intTypeId == $this->objWikiItem->EditorMinimumPersonTypeId);
     }
     $this->lstNavItem = new QListBox($this);
     $this->lstNavItem->AddItem('- Default -', null);
     foreach (QApplication::$NavBarArray as $intIndex => $arrItems) {
         $this->lstNavItem->AddItem($arrItems[0], $intIndex, !is_null($this->objWikiItem->OverrideNavbarIndex) && $this->objWikiItem->OverrideNavbarIndex == $intIndex);
     }
     if (is_null($this->lstNavItem->SelectedValue)) {
         $this->lstNavItem->SelectedIndex = 0;
     }
     $this->lstNavItem->AddAction(new QChangeEvent(), new QAjaxAction('lstNavItem_Change'));
     $this->lstSubNavItem = new QListBox($this);
     $this->lstNavItem_Change(null, null, null);
     $this->btnOkay = new QButton($this);
     $this->btnOkay->CausesValidation = true;
     $this->btnOkay->Text = 'Update';
     $this->btnCancel = new QLinkButton($this);
     $this->btnCancel->Text = 'Cancel';
     $this->btnOkay->AddAction(new QClickEvent(), new QToggleEnableAction($this->btnOkay));
     $this->btnOkay->AddAction(new QClickEvent(), new QAjaxAction('btnOkay_Click'));
     $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click'));
     $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction());
 }
 /**
  * Given QTextStyle-generated HTML content, this will return the same content, with any wiki-based links
  * reconciled against actual data in the wiki database.
  * @param string $strContent
  * @return string
  */
 public static function DisplayWithWikiLinks($strContent)
 {
     // Fix up for images
     $intCount = preg_match_all('/<wikiImage position="(Left|Right)" path="([a-z0-9\\_\\/]*)"\\/>/', $strContent, $arrMatches);
     for ($intMatch = 0; $intMatch < $intCount; $intMatch++) {
         $strTagToReplace = $arrMatches[0][$intMatch];
         $strPosition = $arrMatches[1][$intMatch];
         $strPath = $arrMatches[2][$intMatch];
         $objWikiItem = WikiItem::LoadByPathWikiItemTypeId($strPath, WikiItemType::Image);
         if ($objWikiItem && $objWikiItem->CurrentWikiVersion && $objWikiItem->CurrentWikiVersion->WikiImage) {
             $strReplacement = sprintf('<div class="wikiThumb wikiThumb%s"><a href="/wiki/image:%s" title="View This Image"><img src="%s"/></a></div>', $strPosition, substr($strPath, 1), $objWikiItem->CurrentWikiVersion->WikiImage->GetThumbPath());
         } else {
             if ($objWikiItem) {
                 $strReplacement = sprintf('<div class="wikiThumb wikiThumb%s"><a href="/wiki/image:%s" title="Create This Image"><img src="/images/no_image.png"/></a></div>', $strPosition, substr($strPath, 1));
             } else {
                 $strReplacement = sprintf('<div class="wikiThumb wikiThumb%s"><a href="/wiki/edit.php/image:%s" title="Create This Image"><img src="/images/no_image.png"/></a></div>', $strPosition, substr($strPath, 1));
             }
         }
         $strContent = str_replace($strTagToReplace, $strReplacement, $strContent);
     }
     // Fix up for files
     $intCount = preg_match_all('/<wikiFile path="([a-z0-9\\_\\/]*)"\\/>/', $strContent, $arrMatches);
     for ($intMatch = 0; $intMatch < $intCount; $intMatch++) {
         $strTagToReplace = $arrMatches[0][$intMatch];
         $strPath = $arrMatches[1][$intMatch];
         $objWikiItem = WikiItem::LoadByPathWikiItemTypeId($strPath, WikiItemType::File);
         if ($objWikiItem && $objWikiItem->CurrentWikiVersion && $objWikiItem->CurrentWikiVersion->WikiFile) {
             $strContent = str_replace($strTagToReplace, $objWikiItem->CurrentWikiVersion->WikiFile->DisplayDownloadLink(true), $strContent);
         } else {
             $strContent = str_replace($strTagToReplace, WikiFile::DisplayUploadNewLinkForPath($strPath), $strContent);
         }
     }
     return $strContent;
 }
Example #4
0
         $strPath = '/old_downloads/qform_controls/';
         break;
     case 3:
         $strPath = '/old_downloads/other/';
         break;
     case 4:
         $strPath = '/old_downloads/language_files/';
         break;
     default:
         throw new Exception('HERE');
 }
 if ($strPath && file_exists($strFilePath)) {
     $strPath .= $objRow['name'];
     $strPath = WikiItem::SanitizeForPath($strPath, $intWikiItemTypeId);
     // See if the download exists
     $objWikiItem = WikiItem::LoadByPathWikiItemTypeId($strPath, WikiItemType::File);
     if (!$objWikiItem) {
         $objWikiItem = WikiItem::CreateNewItem($strPath, WikiItemType::File);
     }
     // Create the Parameters for Save
     $objWikiFile = new WikiFile();
     if ($objRow['parent_download_id']) {
         $objParentResult = $objDb->query('SELECT * FROM download WHERE id=' . $objRow['parent_download_id']);
         $objParentRow = $objParentResult->fetch_array();
         $objWikiFile->Description = trim($objParentRow['description']);
     } else {
         $objWikiFile->Description = trim($objRow['description']);
     }
     $objWikiFile->DownloadCount = $objRow['download_count'];
     $arrMethodParameters = array($strFilePath, $objRow['filename']);
     $objWikiVersion = $objWikiItem->CreateNewVersion(trim($objRow['name']), $objWikiFile, 'SaveFile', $arrMethodParameters, Person::Load($objRow['person_id']), new QDateTime($objRow['post_date']));
Example #5
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();
         }
     }
 }
Example #6
0
 /**
  * Creates a new WikiItem for a given path and type.  If path already exists, return null.
  * Otherwise, return the new WikiItem.
  * @param string $strPath
  * @param integer $intWikiItemTypeId
  * @return WikiItem
  */
 public static function CreateNewItem($strPath, $intWikiItemTypeId)
 {
     // Make sure the path doesn't yet exist
     $strPath = self::SanitizeForPath($strPath, $intId);
     if (WikiItem::LoadByPathWikiItemTypeId($strPath, $intWikiItemTypeId)) {
         return null;
     }
     $objWikiItem = new WikiItem();
     $objWikiItem->Path = $strPath;
     $objWikiItem->WikiItemTypeId = $intWikiItemTypeId;
     $objWikiItem->EditorMinimumPersonTypeId = PersonType::RegisteredUser;
     $objWikiItem->Save();
     $objWikiItem->CreateTopicAndTopicLink();
     return $objWikiItem;
 }