All properties pertain to the current revision of the file.
Author: Robert McLeod & Frans P. de Vries
 /**
  * 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;
     }
 }
 /**
  * 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 WikiFileMetaControl
  * @param integer $intWikiVersionId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing WikiFile object creation - defaults to CreateOrEdit
  * @return WikiFileMetaControl
  */
 public static function Create($objParentObject, $intWikiVersionId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intWikiVersionId)) {
         $objWikiFile = WikiFile::Load($intWikiVersionId);
         // WikiFile was found -- return it!
         if ($objWikiFile) {
             return new WikiFileMetaControl($objParentObject, $objWikiFile);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a WikiFile object with PK arguments: ' . $intWikiVersionId);
             }
         }
         // 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 WikiFileMetaControl($objParentObject, new WikiFile());
 }
 /**
  * Override method to perform a property "Get"
  * This will get the value of $strName
  *
  * @param string $strName Name of the property to get
  * @return mixed
  */
 public function __get($strName)
 {
     switch ($strName) {
         ///////////////////
         // Member Variables
         ///////////////////
         case 'Id':
             // Gets the value for intId (Read-Only PK)
             // @return integer
             return $this->intId;
         case 'WikiItemId':
             // Gets the value for intWikiItemId (Not Null)
             // @return integer
             return $this->intWikiItemId;
         case 'VersionNumber':
             // Gets the value for intVersionNumber (Not Null)
             // @return integer
             return $this->intVersionNumber;
         case 'Name':
             // Gets the value for strName
             // @return string
             return $this->strName;
         case 'PostedByPersonId':
             // Gets the value for intPostedByPersonId (Not Null)
             // @return integer
             return $this->intPostedByPersonId;
         case 'PostDate':
             // Gets the value for dttPostDate (Not Null)
             // @return QDateTime
             return $this->dttPostDate;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'WikiItem':
             // Gets the value for the WikiItem object referenced by intWikiItemId (Not Null)
             // @return WikiItem
             try {
                 if (!$this->objWikiItem && !is_null($this->intWikiItemId)) {
                     $this->objWikiItem = WikiItem::Load($this->intWikiItemId);
                 }
                 return $this->objWikiItem;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'PostedByPerson':
             // Gets the value for the Person object referenced by intPostedByPersonId (Not Null)
             // @return Person
             try {
                 if (!$this->objPostedByPerson && !is_null($this->intPostedByPersonId)) {
                     $this->objPostedByPerson = Person::Load($this->intPostedByPersonId);
                 }
                 return $this->objPostedByPerson;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'WikiFile':
             // Gets the value for the WikiFile object that uniquely references this WikiVersion
             // by objWikiFile (Unique)
             // @return WikiFile
             try {
                 if ($this->objWikiFile === false) {
                     // We've attempted early binding -- and the reverse reference object does not exist
                     return null;
                 }
                 if (!$this->objWikiFile) {
                     $this->objWikiFile = WikiFile::LoadByWikiVersionId($this->intId);
                 }
                 return $this->objWikiFile;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'WikiImage':
             // Gets the value for the WikiImage object that uniquely references this WikiVersion
             // by objWikiImage (Unique)
             // @return WikiImage
             try {
                 if ($this->objWikiImage === false) {
                     // We've attempted early binding -- and the reverse reference object does not exist
                     return null;
                 }
                 if (!$this->objWikiImage) {
                     $this->objWikiImage = WikiImage::LoadByWikiVersionId($this->intId);
                 }
                 return $this->objWikiImage;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'WikiItemAsCurrent':
             // Gets the value for the WikiItem object that uniquely references this WikiVersion
             // by objWikiItemAsCurrent (Unique)
             // @return WikiItem
             try {
                 if ($this->objWikiItemAsCurrent === false) {
                     // We've attempted early binding -- and the reverse reference object does not exist
                     return null;
                 }
                 if (!$this->objWikiItemAsCurrent) {
                     $this->objWikiItemAsCurrent = WikiItem::LoadByCurrentWikiVersionId($this->intId);
                 }
                 return $this->objWikiItemAsCurrent;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'WikiPage':
             // Gets the value for the WikiPage object that uniquely references this WikiVersion
             // by objWikiPage (Unique)
             // @return WikiPage
             try {
                 if ($this->objWikiPage === false) {
                     // We've attempted early binding -- and the reverse reference object does not exist
                     return null;
                 }
                 if (!$this->objWikiPage) {
                     $this->objWikiPage = WikiPage::LoadByWikiVersionId($this->intId);
                 }
                 return $this->objWikiPage;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             ////////////////////////////
             // Virtual Object References (Many to Many and Reverse References)
             // (If restored via a "Many-to" expansion)
             ////////////////////////////
         ////////////////////////////
         // Virtual Object References (Many to Many and Reverse References)
         // (If restored via a "Many-to" expansion)
         ////////////////////////////
         case '__Restored':
             return $this->__blnRestored;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, WikiFile::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 = WikiFile::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 WikiFile, given the clauses above
     $this->DataSource = WikiFile::QueryArray($objCondition, $objClauses);
 }
Beispiel #7
0
<?php

require '../../includes/prepend.inc.php';
$objWikiFile = WikiFile::LoadByWikiVersionId(QApplication::PathInfo(0));
if ($objWikiFile->FileName != QApplication::PathInfo(1)) {
    QApplication::Redirect($objWikiFile->WikiVersion->WikiItem->UrlPath);
}
$objWikiFile->DownloadCount++;
$objWikiFile->Save();
header('Content-Type: ' . $objWikiFile->FileMime);
header('Content-Length: ' . filesize($objWikiFile->GetPath()));
header('Content-Disposition: attachment; filename="' . $objWikiFile->FileName . '"');
print file_get_contents($objWikiFile->GetPath());
 /**
  * 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 = WikiFile::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 WikiFile, given the clauses above
     $this->DataSource = WikiFile::LoadAll($objClauses);
 }