protected function SetupNarroProject($intProjectId) { // Lookup Object PK information from Query String (if applicable) if ($intProjectId) { $this->objProject = NarroProject::Load($intProjectId); $this->pnlBreadcrumb->setElements(NarroLink::ProjectList(t('Projects')), $this->objProject->ProjectName); } else { $this->pnlBreadcrumb->setElements(NarroLink::ProjectList(t('Projects')), t('Add project')); } }
protected function SetupNarroProject($intProjectId) { $this->objProject = NarroProject::Load($intProjectId); if (!$this->objProject) { QApplication::Redirect(NarroLink::ProjectList()); return false; } else { $this->pnlBreadcrumb->setElements(NarroLink::ProjectList(t('Projects')), $this->objProject->ProjectName); return true; } }
$strTargetLanguage = $argv[array_search('--translation-lang', $argv) + 1]; } if (array_search('--user', $argv) !== false) { $intUserId = $argv[array_search('--user', $argv) + 1]; } $objUser = NarroUser::LoadByUserId($intUserId); if (!$objUser instanceof NarroUser) { NarroLogger::LogInfo(sprintf('User id=%s does not exist in the database, will try to use the anonymous user.', $intUserId)); $objUser = NarroUser::LoadAnonymousUser(); if (!$objUser instanceof NarroUser) { NarroLogger::LogInfo(sprintf('The anonymous user id=%s does not exist in the database.', $intUserId)); return false; } } QApplication::$User = $objUser; $objProject = NarroProject::Load($intProjectId); if (!$objProject instanceof NarroProject) { NarroLogger::LogInfo(sprintf('Project with id=%s does not exist in the database.', $intProjectId)); return false; } $objLanguage = NarroLanguage::LoadByLanguageCode($strTargetLanguage); if (!$objLanguage instanceof NarroLanguage) { NarroLogger::LogInfo(sprintf('Language %s does not exist in the database.', $strTargetLanguage)); return false; } QApplication::$TargetLanguage = $objLanguage; $objNarroImporter->TargetLanguage = $objLanguage; NarroLogger::LogInfo(sprintf('Target language is %s', $objNarroImporter->TargetLanguage->LanguageName)); $objNarroImporter->SourceLanguage = NarroLanguage::LoadByLanguageCode($strSourceLanguage); if (!$objNarroImporter->SourceLanguage instanceof NarroLanguage) { NarroLogger::LogInfo(sprintf('Language %s does not exist in the database.', $strSourceLanguage));
/** * 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 'ContextId': /** * Gets the value for intContextId (Read-Only PK) * @return integer */ return $this->intContextId; case 'TextId': /** * Gets the value for intTextId (Not Null) * @return integer */ return $this->intTextId; case 'TextAccessKey': /** * Gets the value for strTextAccessKey * @return string */ return $this->strTextAccessKey; case 'TextCommandKey': /** * Gets the value for strTextCommandKey * @return string */ return $this->strTextCommandKey; case 'ProjectId': /** * Gets the value for intProjectId (Not Null) * @return integer */ return $this->intProjectId; case 'Context': /** * Gets the value for strContext (Not Null) * @return string */ return $this->strContext; case 'ContextMd5': /** * Gets the value for strContextMd5 (Not Null) * @return string */ return $this->strContextMd5; case 'Comment': /** * Gets the value for strComment * @return string */ return $this->strComment; case 'CommentMd5': /** * Gets the value for strCommentMd5 * @return string */ return $this->strCommentMd5; case 'FileId': /** * Gets the value for intFileId (Not Null) * @return integer */ return $this->intFileId; case 'Created': /** * Gets the value for dttCreated (Not Null) * @return QDateTime */ return $this->dttCreated; case 'Modified': /** * Gets the value for dttModified * @return QDateTime */ return $this->dttModified; case 'Active': /** * Gets the value for blnActive (Not Null) * @return boolean */ return $this->blnActive; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'Text': /** * Gets the value for the NarroText object referenced by intTextId (Not Null) * @return NarroText */ try { if (!$this->objText && !is_null($this->intTextId)) { $this->objText = NarroText::Load($this->intTextId); } return $this->objText; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Project': /** * Gets the value for the NarroProject object referenced by intProjectId (Not Null) * @return NarroProject */ try { if (!$this->objProject && !is_null($this->intProjectId)) { $this->objProject = NarroProject::Load($this->intProjectId); } return $this->objProject; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'File': /** * Gets the value for the NarroFile object referenced by intFileId (Not Null) * @return NarroFile */ try { if (!$this->objFile && !is_null($this->intFileId)) { $this->objFile = NarroFile::Load($this->intFileId); } return $this->objFile; } 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 '_NarroContextInfoAsContext': /** * Gets the value for the private _objNarroContextInfoAsContext (Read-Only) * if set due to an expansion on the narro_context_info.context_id reverse relationship * @return NarroContextInfo */ return $this->_objNarroContextInfoAsContext; case '_NarroContextInfoAsContextArray': /** * Gets the value for the private _objNarroContextInfoAsContextArray (Read-Only) * if set due to an ExpandAsArray on the narro_context_info.context_id reverse relationship * @return NarroContextInfo[] */ return $this->_objNarroContextInfoAsContextArray; case '_NarroSuggestionVoteAsContext': /** * Gets the value for the private _objNarroSuggestionVoteAsContext (Read-Only) * if set due to an expansion on the narro_suggestion_vote.context_id reverse relationship * @return NarroSuggestionVote */ return $this->_objNarroSuggestionVoteAsContext; case '_NarroSuggestionVoteAsContextArray': /** * Gets the value for the private _objNarroSuggestionVoteAsContextArray (Read-Only) * if set due to an ExpandAsArray on the narro_suggestion_vote.context_id reverse relationship * @return NarroSuggestionVote[] */ return $this->_objNarroSuggestionVoteAsContextArray; case '__Restored': return $this->__blnRestored; default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
/** * 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 'LogId': /** * Gets the value for intLogId (Read-Only PK) * @return integer */ return $this->intLogId; case 'LanguageId': /** * Gets the value for intLanguageId * @return integer */ return $this->intLanguageId; case 'ProjectId': /** * Gets the value for intProjectId * @return integer */ return $this->intProjectId; case 'UserId': /** * Gets the value for intUserId * @return integer */ return $this->intUserId; case 'Message': /** * Gets the value for strMessage (Not Null) * @return string */ return $this->strMessage; case 'Priority': /** * Gets the value for intPriority (Not Null) * @return integer */ return $this->intPriority; case 'Date': /** * Gets the value for dttDate (Not Null) * @return QDateTime */ return $this->dttDate; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'Language': /** * Gets the value for the NarroLanguage object referenced by intLanguageId * @return NarroLanguage */ try { if (!$this->objLanguage && !is_null($this->intLanguageId)) { $this->objLanguage = NarroLanguage::Load($this->intLanguageId); } return $this->objLanguage; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Project': /** * Gets the value for the NarroProject object referenced by intProjectId * @return NarroProject */ try { if (!$this->objProject && !is_null($this->intProjectId)) { $this->objProject = NarroProject::Load($this->intProjectId); } return $this->objProject; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'User': /** * Gets the value for the NarroUser object referenced by intUserId * @return NarroUser */ try { if (!$this->objUser && !is_null($this->intUserId)) { $this->objUser = NarroUser::Load($this->intUserId); } return $this->objUser; } 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; } } }
/** * 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 NarroProjectMetaControl * @param integer $intProjectId primary key value * @param QMetaControlCreateType $intCreateType rules governing NarroProject object creation - defaults to CreateOrEdit * @return NarroProjectMetaControl */ public static function Create($objParentObject, $intProjectId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intProjectId)) { $objNarroProject = NarroProject::Load($intProjectId); // NarroProject was found -- return it! if ($objNarroProject) { return new NarroProjectMetaControl($objParentObject, $objNarroProject); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a NarroProject object with PK arguments: ' . $intProjectId); } } // 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 NarroProjectMetaControl($objParentObject, new NarroProject()); }
/** * 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 'ProjectProgressId': /** * Gets the value for intProjectProgressId (Read-Only PK) * @return integer */ return $this->intProjectProgressId; case 'ProjectId': /** * Gets the value for intProjectId (Not Null) * @return integer */ return $this->intProjectId; case 'LanguageId': /** * Gets the value for intLanguageId (Not Null) * @return integer */ return $this->intLanguageId; case 'Active': /** * Gets the value for blnActive * @return boolean */ return $this->blnActive; case 'LastModified': /** * Gets the value for dttLastModified (Not Null) * @return QDateTime */ return $this->dttLastModified; case 'TotalTextCount': /** * Gets the value for intTotalTextCount (Not Null) * @return integer */ return $this->intTotalTextCount; case 'FuzzyTextCount': /** * Gets the value for intFuzzyTextCount (Not Null) * @return integer */ return $this->intFuzzyTextCount; case 'ApprovedTextCount': /** * Gets the value for intApprovedTextCount (Not Null) * @return integer */ return $this->intApprovedTextCount; case 'ProgressPercent': /** * Gets the value for intProgressPercent (Not Null) * @return integer */ return $this->intProgressPercent; case 'Data': /** * Gets the value for strData * @return string */ return $this->strData; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'Project': /** * Gets the value for the NarroProject object referenced by intProjectId (Not Null) * @return NarroProject */ try { if (!$this->objProject && !is_null($this->intProjectId)) { $this->objProject = NarroProject::Load($this->intProjectId); } return $this->objProject; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Language': /** * Gets the value for the NarroLanguage object referenced by intLanguageId (Not Null) * @return NarroLanguage */ try { if (!$this->objLanguage && !is_null($this->intLanguageId)) { $this->objLanguage = NarroLanguage::Load($this->intLanguageId); } return $this->objLanguage; } 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; } } }
/** * 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 'FileId': /** * Gets the value for intFileId (Read-Only PK) * @return integer */ return $this->intFileId; case 'FileName': /** * Gets the value for strFileName (Not Null) * @return string */ return $this->strFileName; case 'FilePath': /** * Gets the value for strFilePath (Not Null) * @return string */ return $this->strFilePath; case 'FileMd5': /** * Gets the value for strFileMd5 * @return string */ return $this->strFileMd5; case 'ParentId': /** * Gets the value for intParentId * @return integer */ return $this->intParentId; case 'TypeId': /** * Gets the value for intTypeId (Not Null) * @return integer */ return $this->intTypeId; case 'ProjectId': /** * Gets the value for intProjectId (Not Null) * @return integer */ return $this->intProjectId; case 'Active': /** * Gets the value for blnActive (Not Null) * @return boolean */ return $this->blnActive; case 'Created': /** * Gets the value for dttCreated (Not Null) * @return QDateTime */ return $this->dttCreated; case 'Modified': /** * Gets the value for dttModified * @return QDateTime */ return $this->dttModified; case 'Header': /** * Gets the value for strHeader * @return string */ return $this->strHeader; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'Parent': /** * Gets the value for the NarroFile object referenced by intParentId * @return NarroFile */ try { if (!$this->objParent && !is_null($this->intParentId)) { $this->objParent = NarroFile::Load($this->intParentId); } return $this->objParent; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'Project': /** * Gets the value for the NarroProject object referenced by intProjectId (Not Null) * @return NarroProject */ try { if (!$this->objProject && !is_null($this->intProjectId)) { $this->objProject = NarroProject::Load($this->intProjectId); } return $this->objProject; } 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 '_NarroContextAsFile': /** * Gets the value for the private _objNarroContextAsFile (Read-Only) * if set due to an expansion on the narro_context.file_id reverse relationship * @return NarroContext */ return $this->_objNarroContextAsFile; case '_NarroContextAsFileArray': /** * Gets the value for the private _objNarroContextAsFileArray (Read-Only) * if set due to an ExpandAsArray on the narro_context.file_id reverse relationship * @return NarroContext[] */ return $this->_objNarroContextAsFileArray; case '_ChildNarroFile': /** * Gets the value for the private _objChildNarroFile (Read-Only) * if set due to an expansion on the narro_file.parent_id reverse relationship * @return NarroFile */ return $this->_objChildNarroFile; case '_ChildNarroFileArray': /** * Gets the value for the private _objChildNarroFileArray (Read-Only) * if set due to an ExpandAsArray on the narro_file.parent_id reverse relationship * @return NarroFile[] */ return $this->_objChildNarroFileArray; case '_NarroFileProgressAsFile': /** * Gets the value for the private _objNarroFileProgressAsFile (Read-Only) * if set due to an expansion on the narro_file_progress.file_id reverse relationship * @return NarroFileProgress */ return $this->_objNarroFileProgressAsFile; case '_NarroFileProgressAsFileArray': /** * Gets the value for the private _objNarroFileProgressAsFileArray (Read-Only) * if set due to an ExpandAsArray on the narro_file_progress.file_id reverse relationship * @return NarroFileProgress[] */ return $this->_objNarroFileProgressAsFileArray; case '__Restored': return $this->__blnRestored; default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
public function btnSave_Click($strFormId, $strControlId, $strParameter) { foreach ($this->arrControls as $strName => $objControl) { switch (NarroProject::$AvailablePreferences[$strName]['type']) { case 'number': $this->objProject->SetPreferenceValueByName($strName, $objControl->Text); break; case 'text': $this->objProject->SetPreferenceValueByName($strName, $objControl->Text); break; case 'option': $this->objProject->SetPreferenceValueByName($strName, $objControl->SelectedValue); break; } } try { $this->objProject->Save(); $this->objProject = NarroProject::Load($this->objProject->ProjectId); $this->objProjectProgress = NarroProjectProgress::LoadByProjectIdLanguageId($this->objProject->ProjectId, QApplication::GetLanguageId()); $this->lblMessage->Text = t('Your preferences were saved successfuly.'); $this->lblMessage->ForeColor = 'green'; } catch (Exception $objEx) { $this->lblMessage->Text = t('An error occurred while trying to save your preferences.'); $this->lblMessage->ForeColor = 'red'; } }
* * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ require_once dirname(__FILE__) . '/configuration/prepend.inc.php'; QApplication::$TargetLanguage = NarroLanguage::Load(QApplication::QueryString('l')); if (QApplication::QueryString('p')) { $objProject = NarroProject::Load(QApplication::QueryString('p')); } switch (QApplication::QueryString('t')) { case 'suggestion': if (isset($objProject) && $objProject instanceof NarroProject) { $strCacheId = sprintf('rssfeed_suggestion_%d_%d', $objProject->ProjectId, QApplication::QueryString('l')); } else { $strCacheId = sprintf('rssfeed_suggestion_%d', QApplication::QueryString('l')); } if (!($objRssFeed = QApplication::$Cache->load($strCacheId))) { if (isset($objProject) && $objProject instanceof NarroProject) { $objRssFeed = new QRssFeed(sprintf(t('Translations for %s'), $objProject->ProjectName), __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__, sprintf(t('Get the latest translation suggestions in %s for %s'), t(QApplication::$TargetLanguage->LanguageName), $objProject->ProjectName)); } else { $objRssFeed = new QRssFeed(sprintf(t('Translations for all projects'), t(QApplication::$TargetLanguage->LanguageName)), __HTTP_URL__ . __VIRTUAL_DIRECTORY__ . __SUBDIRECTORY__, sprintf(t('Get the latest translation suggestions in %s'), t(QApplication::$TargetLanguage->LanguageName))); } if (isset($objProject) && $objProject instanceof NarroProject) {
/** * Reload this NarroProject from the database. * @return void */ public function Reload() { // Make sure we are actually Restored from the database if (!$this->__blnRestored) { throw new QCallerException('Cannot call Reload() on a new, unsaved NarroProject object.'); } $this->DeleteCache(); // Reload the Object $objReloaded = NarroProject::Load($this->intProjectId); // Update $this's local variables to match $this->ProjectCategoryId = $objReloaded->ProjectCategoryId; $this->strProjectName = $objReloaded->strProjectName; $this->ProjectType = $objReloaded->ProjectType; $this->strProjectDescription = $objReloaded->strProjectDescription; $this->strData = $objReloaded->strData; $this->intActive = $objReloaded->intActive; }