Пример #1
0
 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
 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());
 }
Пример #3
0
    /**
     * Deletes all associated WikiItemsAsCurrentPostedBy
     * @return void
     */
    public function DeleteAllWikiItemsAsCurrentPostedBy()
    {
        if (is_null($this->intId)) {
            throw new QUndefinedPrimaryKeyException('Unable to call UnassociateWikiItemAsCurrentPostedBy on this unsaved Person.');
        }
        // Get the Database Object for this Class
        $objDatabase = Person::GetDatabase();
        // Journaling
        if ($objDatabase->JournalingDatabase) {
            foreach (WikiItem::LoadArrayByCurrentPostedByPersonId($this->intId) as $objWikiItem) {
                $objWikiItem->Journal('DELETE');
            }
        }
        // Perform the SQL Query
        $objDatabase->NonQuery('
				DELETE FROM
					`wiki_item`
				WHERE
					`current_posted_by_person_id` = ' . $objDatabase->SqlVariable($this->intId) . '
			');
    }
Пример #4
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->objWikiItem) {
         $objObject->objWikiItem = WikiItem::GetSoapObjectFromObject($objObject->objWikiItem, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intWikiItemId = null;
         }
     }
     if ($objObject->objPostedByPerson) {
         $objObject->objPostedByPerson = Person::GetSoapObjectFromObject($objObject->objPostedByPerson, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intPostedByPersonId = null;
         }
     }
     if ($objObject->dttPostDate) {
         $objObject->dttPostDate = $objObject->dttPostDate->__toString(QDateTime::FormatSoap);
     }
     return $objObject;
 }
Пример #5
0
 public static function GetSoapObjectFromObject($objObject, $blnBindRelatedObjects)
 {
     if ($objObject->dttLastPostDate) {
         $objObject->dttLastPostDate = $objObject->dttLastPostDate->__toString(QDateTime::FormatSoap);
     }
     if ($objObject->objForum) {
         $objObject->objForum = Forum::GetSoapObjectFromObject($objObject->objForum, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intForumId = null;
         }
     }
     if ($objObject->objIssue) {
         $objObject->objIssue = Issue::GetSoapObjectFromObject($objObject->objIssue, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intIssueId = null;
         }
     }
     if ($objObject->objWikiItem) {
         $objObject->objWikiItem = WikiItem::GetSoapObjectFromObject($objObject->objWikiItem, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intWikiItemId = null;
         }
     }
     if ($objObject->objPackage) {
         $objObject->objPackage = Package::GetSoapObjectFromObject($objObject->objPackage, false);
     } else {
         if (!$blnBindRelatedObjects) {
             $objObject->intPackageId = null;
         }
     }
     return $objObject;
 }
Пример #6
0
    public static function DisplayUploadNewLinkForPath($strPath)
    {
        $strFullPath = WikiItem::GenerateFullPath($strPath, WikiItemType::File);
        $strToReturn = sprintf('
				<div class="wikiFileLeft">
				<a href="/wiki/edit.php%s" title="Create Wiki File"><img src="/images/download_404.png"/></a>
				</div><div class="wikiFileRight">
				<a href="/wiki/edit.php%s" title="Create Wiki File" style="font-size: 18px;">Create Wiki File for <strong>%s</strong></a>
				</div><br clear="all"/>', $strFullPath, $strFullPath, $strPath);
        return $strToReturn;
    }
Пример #7
0
 protected function btnCancel_Click()
 {
     if ($this->intVersionNumber) {
         QApplication::Redirect('/wiki' . WikiItem::GenerateFullPath($this->strSanitizedPath, $this->intWikiItemTypeId) . '?' . $this->intVersionNumber);
     } else {
         QApplication::Redirect('/wiki' . WikiItem::GenerateFullPath($this->strSanitizedPath, $this->intWikiItemTypeId));
     }
 }
 /**
  * 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 = WikiItem::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 WikiItem, given the clauses above
     $this->DataSource = WikiItem::LoadAll($objClauses);
 }
Пример #9
0
 protected static function ProcessFile($strBlockContent, $strBlockIdentifier, $strStyle = null, $strOptions = null)
 {
     $strPath = WikiItem::SanitizeForPath($strBlockContent, $intWikiItemTypeId);
     return sprintf('<wikiFile path="%s"/>' . "\n\n", $strPath);
 }
Пример #10
0
 /**
  * Counts all associated WikiItemsAsCurrentPostedBy
  * @return int
  */
 public function CountWikiItemsAsCurrentPostedBy()
 {
     if (is_null($this->intId)) {
         return 0;
     }
     return WikiItem::CountByCurrentPostedByPersonId($this->intId);
 }
Пример #11
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();
         }
     }
 }
Пример #12
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;
 }
Пример #13
0
<?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'));
Пример #14
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;
 }
Пример #15
0
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, WikiItem::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
 /**
  * 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 = WikiItem::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 WikiItem, given the clauses above
     $this->DataSource = WikiItem::QueryArray($objCondition, $objClauses);
 }
Пример #17
0
 /**
  * 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;
 }
 /**
  * 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 WikiItemMetaControl
  * @param integer $intId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing WikiItem object creation - defaults to CreateOrEdit
  * @return WikiItemMetaControl
  */
 public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intId)) {
         $objWikiItem = WikiItem::Load($intId);
         // WikiItem was found -- return it!
         if ($objWikiItem) {
             return new WikiItemMetaControl($objParentObject, $objWikiItem);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a WikiItem 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 WikiItemMetaControl($objParentObject, new WikiItem());
 }
 /**
  * Refresh this MetaControl with Data from the local TopicLink object.
  * @param boolean $blnReload reload TopicLink from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objTopicLink->Reload();
     }
     if ($this->lblId) {
         if ($this->blnEditMode) {
             $this->lblId->Text = $this->objTopicLink->Id;
         }
     }
     if ($this->lstTopicLinkType) {
         $this->lstTopicLinkType->SelectedValue = $this->objTopicLink->TopicLinkTypeId;
     }
     if ($this->lblTopicLinkTypeId) {
         $this->lblTopicLinkTypeId->Text = $this->objTopicLink->TopicLinkTypeId ? TopicLinkType::$NameArray[$this->objTopicLink->TopicLinkTypeId] : null;
     }
     if ($this->txtTopicCount) {
         $this->txtTopicCount->Text = $this->objTopicLink->TopicCount;
     }
     if ($this->lblTopicCount) {
         $this->lblTopicCount->Text = $this->objTopicLink->TopicCount;
     }
     if ($this->txtMessageCount) {
         $this->txtMessageCount->Text = $this->objTopicLink->MessageCount;
     }
     if ($this->lblMessageCount) {
         $this->lblMessageCount->Text = $this->objTopicLink->MessageCount;
     }
     if ($this->calLastPostDate) {
         $this->calLastPostDate->DateTime = $this->objTopicLink->LastPostDate;
     }
     if ($this->lblLastPostDate) {
         $this->lblLastPostDate->Text = sprintf($this->objTopicLink->LastPostDate) ? $this->objTopicLink->__toString($this->strLastPostDateDateTimeFormat) : null;
     }
     if ($this->lstForum) {
         $this->lstForum->RemoveAllItems();
         $this->lstForum->AddItem(QApplication::Translate('- Select One -'), null);
         $objForumArray = Forum::LoadAll();
         if ($objForumArray) {
             foreach ($objForumArray as $objForum) {
                 $objListItem = new QListItem($objForum->__toString(), $objForum->Id);
                 if ($this->objTopicLink->Forum && $this->objTopicLink->Forum->Id == $objForum->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstForum->AddItem($objListItem);
             }
         }
     }
     if ($this->lblForumId) {
         $this->lblForumId->Text = $this->objTopicLink->Forum ? $this->objTopicLink->Forum->__toString() : null;
     }
     if ($this->lstIssue) {
         $this->lstIssue->RemoveAllItems();
         $this->lstIssue->AddItem(QApplication::Translate('- Select One -'), null);
         $objIssueArray = Issue::LoadAll();
         if ($objIssueArray) {
             foreach ($objIssueArray as $objIssue) {
                 $objListItem = new QListItem($objIssue->__toString(), $objIssue->Id);
                 if ($this->objTopicLink->Issue && $this->objTopicLink->Issue->Id == $objIssue->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstIssue->AddItem($objListItem);
             }
         }
     }
     if ($this->lblIssueId) {
         $this->lblIssueId->Text = $this->objTopicLink->Issue ? $this->objTopicLink->Issue->__toString() : null;
     }
     if ($this->lstWikiItem) {
         $this->lstWikiItem->RemoveAllItems();
         $this->lstWikiItem->AddItem(QApplication::Translate('- Select One -'), null);
         $objWikiItemArray = WikiItem::LoadAll();
         if ($objWikiItemArray) {
             foreach ($objWikiItemArray as $objWikiItem) {
                 $objListItem = new QListItem($objWikiItem->__toString(), $objWikiItem->Id);
                 if ($this->objTopicLink->WikiItem && $this->objTopicLink->WikiItem->Id == $objWikiItem->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstWikiItem->AddItem($objListItem);
             }
         }
     }
     if ($this->lblWikiItemId) {
         $this->lblWikiItemId->Text = $this->objTopicLink->WikiItem ? $this->objTopicLink->WikiItem->__toString() : null;
     }
     if ($this->lstPackage) {
         $this->lstPackage->RemoveAllItems();
         $this->lstPackage->AddItem(QApplication::Translate('- Select One -'), null);
         $objPackageArray = Package::LoadAll();
         if ($objPackageArray) {
             foreach ($objPackageArray as $objPackage) {
                 $objListItem = new QListItem($objPackage->__toString(), $objPackage->Id);
                 if ($this->objTopicLink->Package && $this->objTopicLink->Package->Id == $objPackage->Id) {
                     $objListItem->Selected = true;
                 }
                 $this->lstPackage->AddItem($objListItem);
             }
         }
     }
     if ($this->lblPackageId) {
         $this->lblPackageId->Text = $this->objTopicLink->Package ? $this->objTopicLink->Package->__toString() : null;
     }
 }
Пример #20
0
    $strName = sprintf('Downloads from Old Qcodo.com Website in "%s"', $strType);
    $strContent = sprintf('These are user-contributed downloads from the old *Qcodo.com* website in "%s", placed here for historical/archive purposes.  ', $strType);
    $strContent .= 'For new user-submitted contributions, be sure to check out the "User Contributions":http://www.qcodo.com/qpm/ section of the website.  "View All Old Downloads":wiki:/old_downloads';
    $strContent .= "\r\n\r\n";
    $objWikiItemArray = WikiItem::QueryArray(QQ::In(QQN::WikiItem()->Id, array_keys($arrDownloads[$intIndex])), QQ::OrderBy(QQN::WikiItem()->CurrentName));
    foreach ($objWikiItemArray as $objWikiItem) {
        $strContent .= sprintf('file. %s', $objWikiItem->Path);
        $strContent .= "\r\n\r\n";
    }
    $objWikiItem = WikiItem::CreateNewItem($strPath, WikiItemType::Page);
    $objWikiPage = new WikiPage();
    $objWikiPage->Content = trim($strContent);
    $objWikiPage->CompileHtml();
    $objWikiItem->CreateNewVersion($strName, $objWikiPage, 'Save', array(), Person::Load(1), null);
}
$objWikiItem = WikiItem::CreateNewItem('/old_downloads', WikiItemType::Page);
$strContent = 'These are user-contributed downloads from the old *Qcodo.com* website, placed here for historical/archive purposes.  ';
$strContent .= 'For new user-submitted contributions, be sure to check out the "User Contributions":http://www.qcodo.com/qpm/ section of the website.';
$strContent .= "\r\n\r\n";
$strContent .= 'h2. "QForm Controls":wiki:/old_downloads/qform_controls';
$strContent .= "\r\n\r\n";
$strContent .= 'Custom Qform class files are typically installed in wwwroot/includes/qform, inside qform_objects';
$strContent .= "\r\n\r\n";
$strContent .= 'h2. "Laguage Files":wiki:/old_downloads/language_files';
$strContent .= "\r\n\r\n";
$strContent .= 'A place to share language files and language file updates for Internationalized Qcodo. | These are files that should be placed within the core at /includes/qcodo/i18n.  As files are uploaded and perfected, and as authors grant permission, we will put them into the core in future releases.';
$strContent .= "\r\n\r\n";
$strContent .= 'h2. "Other":wiki:/old_downloads/other';
$strContent .= "\r\n\r\n";
$strContent .= 'For other Community-Contributed classes, utilities, and code-snippets';
$objWikiPage = 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;
     }
 }
Пример #22
0
                $objWikiObject->Description = QDataGen::GenerateContent(rand(1, 3), 10, 50);
                $strPath = QDataGen::GenerateFromArray($strRandomFilePathArray);
                $strArray = pathinfo($strPath);
                $strFileName = str_replace(' ', '', $strName) . '.' . $strArray['extension'];
                $strMethodName = 'SaveFile';
                $arrMethodParameters = array($strPath, $strFileName);
                break;
            default:
                throw new Exception('Unknown handler for WikiItemTypeId: ' . $objWikiItem->WikiItemTypeId);
        }
        $objWikiItem->CreateNewVersion($strName, $objWikiObject, $strMethodName, $arrMethodParameters, $objPerson, $dttPostDate);
    }
}
// Generate Messages for Wiki
QDataGen::DisplayForEachTaskStart($strTitle = 'Generating Messages for Wiki', WikiItem::CountAll());
foreach (WikiItem::LoadAll() as $objWikiItem) {
    QDataGen::DisplayForEachTaskNext($strTitle);
    $intCount = rand(1, GENERATE_MESSAGES_PER_WIKI_UBOUND);
    if (rand(0, 1)) {
        $intCount = round($intCount / 2);
    }
    if (rand(0, 1)) {
        $intCount = round($intCount / 2);
    }
    if (rand(0, 1)) {
        $intCount = round($intCount / 2);
    }
    if (rand(0, 1)) {
        $intCount = round($intCount / 2);
    }
    if (rand(0, 1)) {