/**
  * 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 NarroFileProgressMetaControl
  * @param integer $intFileProgressId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing NarroFileProgress object creation - defaults to CreateOrEdit
  * @return NarroFileProgressMetaControl
  */
 public static function Create($objParentObject, $intFileProgressId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intFileProgressId)) {
         $objNarroFileProgress = NarroFileProgress::Load($intFileProgressId);
         // NarroFileProgress was found -- return it!
         if ($objNarroFileProgress) {
             return new NarroFileProgressMetaControl($objParentObject, $objNarroFileProgress);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a NarroFileProgress object with PK arguments: ' . $intFileProgressId);
             }
         }
         // 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 NarroFileProgressMetaControl($objParentObject, new NarroFileProgress());
 }
 /**
  * This Form_Validate event handler allows you to specify any custom Form Validation rules.
  * It will also Blink() on all invalid controls, as well as Focus() on the top-most invalid control.
  */
 protected function Form_Validate()
 {
     // By default, we report the result of validation from the parent
     $blnToReturn = parent::Form_Validate();
     // Custom Validation Rules
     // TODO: Be sure to set $blnToReturn to false if any custom validation fails!
     // Check for records that may violate Unique Clauses
     if (($objNarroFileProgress = NarroFileProgress::LoadByFileIdLanguageId($this->lstFile->SelectedValue, $this->lstLanguage->SelectedValue)) && $objNarroFileProgress->FileProgressId != $this->mctNarroFileProgress->NarroFileProgress->FileProgressId) {
         $blnToReturn = false;
         $this->lstFile->Warning = QApplication::Translate("Already in Use");
         $this->lstLanguage->Warning = QApplication::Translate("Already in Use");
     }
     $blnFocused = false;
     foreach ($this->GetErrorControls() as $objControl) {
         // Set Focus to the top-most invalid control
         if (!$blnFocused) {
             $objControl->Focus();
             $blnFocused = true;
         }
         // Blink on ALL invalid controls
         $objControl->Blink();
     }
     return $blnToReturn;
 }
Example #3
0
 /**
  * Counts all associated NarroFileProgressesAsFile
  * @return int
  */
 public function CountNarroFileProgressesAsFile()
 {
     if (is_null($this->intFileId)) {
         return 0;
     }
     return NarroFileProgress::CountByFileId($this->intFileId);
 }
 public function ExportFile($objFile, $strTemplateFile, $strTranslatedFile)
 {
     if (!$objFile instanceof NarroFile) {
         NarroLogger::LogWarn(sprintf('Failed to find a corresponding file in the database for %s', $strTemplateFile));
         return false;
     }
     if (NarroFileProgress::CountByFileIdLanguageIdExport($objFile->FileId, $this->objTargetLanguage->LanguageId, 0)) {
         NarroLogger::LogWarn(sprintf('Not exporting %s based on the file settings.', $strTemplateFile));
         return false;
     }
     $objFileImporter = NarroFileType::GetFileImporter($objFile->TypeId, $this);
     // NarroLogger::LogDebug( sprintf( t('Starting to export "%s"'), str_replace($this->objProject->DefaultTranslationPath, '', $strTranslatedFile) ) );
     $objFileImporter->File = $objFile;
     QApplication::$PluginHandler->BeforeExportFile($objFile, $strTemplateFile, $strTranslatedFile);
     $blnMixResult = $objFileImporter->ExportFile($strTemplateFile, $strTranslatedFile);
     if (file_exists($strTranslatedFile)) {
         QApplication::$PluginHandler->AfterExportFile($objFile, $strTemplateFile, $strTranslatedFile);
     }
     $this->arrFileId[$objFile->FileId] = 1;
     return $blnMixResult;
 }
 public function chkExport_Click($strFormId, $strControlId, $intFileId)
 {
     $chkExport = $this->dtgFile->GetChildControl($strControlId);
     $objFileProgress = NarroFileProgress::LoadByFileIdLanguageId($intFileId, QApplication::GetLanguageId());
     if ($objFileProgress) {
         $objFileProgress->Export = !$objFileProgress->Export;
         $objFileProgress->Save();
     }
 }
 /**
  * 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()
 {
     $objConditions = $this->Conditions;
     if (null !== $this->conAdditionalConditions) {
         $objConditions = QQ::AndCondition($this->conAdditionalConditions, $objConditions);
     }
     // Setup the $objClauses Array
     $objClauses = array();
     if (null !== $this->clsAdditionalClauses) {
         $objClauses = $this->clsAdditionalClauses;
     }
     // Remember!  We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     if ($this->Paginator) {
         $this->TotalItemCount = NarroFileProgress::QueryCount($objConditions);
     }
     // 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 NarroFileProgress, given the clauses above
     $this->DataSource = NarroFileProgress::QueryArray($objConditions, $objClauses);
 }
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, NarroFileProgress::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }