コード例 #1
0
ファイル: directory.php プロジェクト: qcodo/qcodo-website
 public function dtgWikiItems_Bind()
 {
     $objCondition = QQ::All();
     if (trim($this->txtTitle->Text)) {
         $objCondition = QQ::AndCondition($objCondition, QQ::Like(QQN::WikiItem()->CurrentName, '%' . trim($this->txtTitle->Text) . '%'));
     }
     if ($strPath = trim($this->txtPath->Text)) {
         $strPath = WikiItem::SanitizeForPath($strPath, $intWikiItemTypeId);
         $objCondition = QQ::AndCondition($objCondition, QQ::Like(QQN::WikiItem()->Path, $strPath . '%'));
     }
     if ($intValue = $this->lstWikiItemType->SelectedValue) {
         $objCondition = QQ::AndCondition($objCondition, QQ::Equal(QQN::WikiItem()->WikiItemTypeId, $intValue));
     }
     if (trim($this->txtPostedBy->Text)) {
         $objCondition = QQ::AndCondition($objCondition, QQ::Like(QQN::WikiItem()->CurrentPostedByPerson->DisplayName, trim($this->txtPostedBy->Text) . '%'));
     }
     $this->dtgWikiItems->TotalItemCount = WikiItem::QueryCount($objCondition);
     $objClauses = array();
     if ($objClause = $this->dtgWikiItems->LimitClause) {
         $objClauses[] = $objClause;
     }
     if ($objClause = $this->dtgWikiItems->OrderByClause) {
         $objClauses[] = $objClause;
     }
     $this->dtgWikiItems->DataSource = WikiItem::QueryArray($objCondition, $objClauses);
 }
コード例 #2
0
 /**
  * Given a full path (typically from QApplication::PathInfo)
  * this will validate that it is properly sanitized.  If so, it will
  * return null.  If not, it will generate and return a sanitized version
  * of that full path.
  * @param string $strFullPath
  * @return mixed null if valid, or the sanitized full path if not
  */
 public static function ValidateOrGenerateSanitizedFullPath($strFullPath)
 {
     $strPath = WikiItem::SanitizeForPath($strFullPath, $intWikiItemTypeId);
     $strSanitizedFullPath = WikiItem::GenerateFullPath($strPath, $intWikiItemTypeId);
     if ($strFullPath == $strSanitizedFullPath) {
         return null;
     } else {
         return $strSanitizedFullPath;
     }
 }
コード例 #3
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();
 }
コード例 #4
0
ファイル: admin.php プロジェクト: qcodo/qcodo-website
 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());
 }
コード例 #5
0
ファイル: migrator.cli.php プロジェクト: qcodo/qcodo-website
         break;
     case 2:
         $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'];
コード例 #6
0
 protected static function ProcessFile($strBlockContent, $strBlockIdentifier, $strStyle = null, $strOptions = null)
 {
     $strPath = WikiItem::SanitizeForPath($strBlockContent, $intWikiItemTypeId);
     return sprintf('<wikiFile path="%s"/>' . "\n\n", $strPath);
 }
コード例 #7
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();
         }
     }
 }
コード例 #8
0
ファイル: edit.php プロジェクト: qcodo/qcodo-website
<?php

require '../../includes/prepend.inc.php';
QApplication::Authenticate();
// Sanitize the Path in the PathInfo
$strSanitizedFullPath = WikiItem::ValidateOrGenerateSanitizedFullPath(QApplication::$PathInfo);
if ($strSanitizedFullPath) {
    QApplication::Redirect('/wiki/edit.php' . $strSanitizedFullPath . QApplication::GenerateQueryString());
}
// Get the WikiItemTypeId
WikiItem::SanitizeForPath(QApplication::$PathInfo, $intWikiItemTypeId);
// Based on the requested WikiItemTypeId, figure out the EditWikiForm to use
$strWikiItemType = WikiItemType::$TokenArray[$intWikiItemTypeId];
$strEditWikiClassName = 'EditWiki' . $strWikiItemType . 'Form';
// Include the required class files
require dirname(__FILE__) . '/EditWikiForm.class.php';
require dirname(__FILE__) . '/' . $strEditWikiClassName . '.class.php';
// Make a call to the QForm::Run() for that Form
call_user_func_array(array($strEditWikiClassName, 'Run'), array($strEditWikiClassName, dirname(__FILE__) . '/' . $strEditWikiClassName . '.tpl.php'));
コード例 #9
0
 protected static function ProcessLinkLocationWikiPage($chrCurrent = null)
 {
     // Pop off LinkLocation
     $objState = self::$objStateStack->Pop();
     $strLocation = $objState->Buffer;
     // Pop off LinkProtocol
     $objState = self::$objStateStack->Pop();
     $strProtocol = $objState->Buffer;
     // Pop off End Quote
     $objState = self::$objStateStack->Pop();
     if ($objState->State != QTextStyle::StateEndQuote) {
         throw new Exception('Could not find In-LinkContent EndQuote State');
     }
     // Cancel everything through the matching start quote
     self::CancelToState(QTextStyle::StateStartQuote);
     // Pop off the Start Quote at the top of the stack
     $objState = self::$objStateStack->Pop();
     $strContent = $objState->Buffer;
     // Clean up the Location string so that it starts with one and exactly one forward slash
     $strLocation = '/' . $strLocation;
     while (strpos($strLocation, '//') === 0) {
         $strLocation = substr($strLocation, 1);
     }
     // Calculate end-of-location
     $strNeedle = '/[A-Za-z0-9\\_\\/\\:]/';
     $intValue = QString::StringReversePosition($strLocation, $strNeedle);
     // Clean Up the URL Path for a Wiki Link
     $strPath = WikiItem::SanitizeForPath(substr($strLocation, 0, $intValue + 1), $intWikiItemTypeId);
     $strSanitizedFullPath = WikiItem::GenerateFullPath($strPath, $intWikiItemTypeId);
     // Process as a URL-based link to the wiki
     $strUrlLink = sprintf('<a href="/wiki%s">%s</a>', $strSanitizedFullPath, $strContent);
     self::$objStateStack->AddToTopBuffer($strUrlLink);
     // Add any tail/unprocessed stuff back to the content stack
     QTextStyleInline::$strInlineContent = substr($strLocation, $intValue + 1) . QTextStyleInline::$strInlineContent;
 }