/** * 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; } }
<?php require '../../includes/prepend.inc.php'; $objWikiImage = WikiImage::LoadByWikiVersionId(QApplication::PathInfo(0)); header('Content-Type: ' . ImageFileType::$ContentTypeArray[$objWikiImage->ImageFileTypeId]); header('Content-Length: ' . filesize($objWikiImage->GetPath())); print file_get_contents($objWikiImage->GetPath());
/** * 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 WikiImageMetaControl * @param integer $intWikiVersionId primary key value * @param QMetaControlCreateType $intCreateType rules governing WikiImage object creation - defaults to CreateOrEdit * @return WikiImageMetaControl */ public static function Create($objParentObject, $intWikiVersionId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intWikiVersionId)) { $objWikiImage = WikiImage::Load($intWikiVersionId); // WikiImage was found -- return it! if ($objWikiImage) { return new WikiImageMetaControl($objParentObject, $objWikiImage); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a WikiImage 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 WikiImageMetaControl($objParentObject, new WikiImage()); }
/** * Action * * @author Greg Meiste <*****@*****.**> */ function action() { Layout::addStyle('wiki'); if (!PHPWS_Settings::get('wiki', 'allow_anon_view') && !Current_User::isLogged()) { Current_User::requireLogin(); return; } if (isset($_REQUEST['page_id']) && is_numeric($_REQUEST['page_id'])) { PHPWS_Core::initModClass('wiki', 'WikiPage.php'); $wikipage = new WikiPage($_REQUEST['page_id']); } else { if (isset($_REQUEST['page']) && is_string($_REQUEST['page'])) { PHPWS_Core::initModClass('wiki', 'WikiPage.php'); $wikipage = new WikiPage($_REQUEST['page']); } } if (!isset($_REQUEST['op']) && !isset($_REQUEST['page_op'])) { // phpWebSite 1.5.0 and later mod_rewrite method if (isset($_GET['var1'])) { $_REQUEST['id'] = $_GET['id'] = $_GET['var1']; } if (isset($_REQUEST['id']) && is_string($_REQUEST['id'])) { PHPWS_Core::initModClass('wiki', 'WikiPage.php'); $wikipage = new WikiPage($_REQUEST['id']); } $_REQUEST['page_op'] = 'view'; } WikiManager::addToMiniAdmin(); if (isset($_REQUEST['page_op']) && isset($wikipage)) { $wikipage->action(); return; } switch (@$_REQUEST['op']) { case 'admin': case 'savesettings': PHPWS_Core::initModClass('wiki', 'WikiSettings.php'); WikiSettings::admin(); break; case 'doimagedelete': case 'doimageupload': case 'imageupload': WikiManager::imageUpload(); break; case 'imagedelete': PHPWS_Core::initModClass('wiki', 'WikiImage.php'); $delImage = new WikiImage($_REQUEST['id']); $template['TITLE'] = dgettext('wiki', 'Wiki Images'); $template['CONTENT'] = $delImage->delete(); Layout::add(PHPWS_Template::process($template, 'wiki', 'box.tpl'), 'wiki', 'wiki_mod', TRUE); break; case 'imagecopy': PHPWS_Core::initModClass('wiki', 'WikiImage.php'); $image = new WikiImage($_REQUEST['id']); Clipboard::copy($image->getFilename(), $image->getTag()); PHPWS_Core::goBack(); break; case 'recentchanges': $template['TITLE'] = dgettext('wiki', 'Recent changes'); $template['CONTENT'] = WikiManager::recentChanges(); Layout::add(PHPWS_Template::process($template, 'wiki', 'box.tpl'), 'wiki', 'wiki_mod', TRUE); break; case 'random': WikiManager::random(); break; case 'interwikisetup': case 'addinterwiki': PHPWS_Core::initModClass('wiki', 'InterWiki.php'); $interwiki = new InterWiki(); $interwiki->setup(); break; case 'editinterwiki': case 'saveinterwiki': case 'deleteinterwiki': case 'dodeleteinterwiki': PHPWS_Core::initModClass('wiki', 'InterWiki.php'); $interwiki = new InterWiki($_REQUEST['id']); $interwiki->setup(); break; case 'copyinterwiki': PHPWS_Core::initModClass('wiki', 'InterWiki.php'); $interwiki = new InterWiki($_REQUEST['id']); Clipboard::copy($interwiki->getLabel(), $interwiki->getLabel() . ':PageName'); PHPWS_Core::goBack(); break; default: $_REQUEST['page'] = PHPWS_Settings::get('wiki', 'default_page'); WikiManager::action(); } }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, WikiImage::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * 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; } } }
function convertImage($image) { PHPWS_Core::initModClass('wiki', 'WikiImage.php'); $newimage = new WikiImage(); $newimage->setOwnerId(Current_User::getId()); $newimage->setCreated($image['created']); $newimage->setFilename($image['filename']); $newimage->setSize($image['size']); $newimage->setType($image['type']); $newimage->setSummary($image['summary']); $db = new PHPWS_DB('wiki_images'); $result = $db->saveObject($newimage); if (PEAR::isError($result)) { PHPWS_Error::log($result); return FALSE; } if (OLD_WIKI_IMAGES . $image['filename'] != PHPWS_HOME_DIR . 'images/wiki/' . $newimage->getFilename()) { if (!@copy(OLD_WIKI_IMAGES . $image['filename'], PHPWS_HOME_DIR . 'images/wiki/' . $newimage->getFilename())) { return FALSE; } } return TRUE; }
/** * 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 = WikiImage::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 WikiImage, given the clauses above $this->DataSource = WikiImage::QueryArray($objCondition, $objClauses); }
/** * 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 = WikiImage::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 WikiImage, given the clauses above $this->DataSource = WikiImage::LoadAll($objClauses); }