Пример #1
0
 public function Save($blnForceInsert = false, $blnForceUpdate = false)
 {
     $mixResult = parent::Save($blnForceInsert, $blnForceUpdate);
     foreach (NarroProject::LoadAll() as $objProject) {
         $objProjectProgress = NarroProjectProgress::LoadByProjectIdLanguageId($objProject->ProjectId, $this->LanguageId);
         if (!$objProjectProgress) {
             $objProject->CountAllTextsByLanguage($this->LanguageId);
         }
     }
     return $mixResult;
 }
Пример #2
0
 /**
  * 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 'Preferences':
             return $this->arrPreferences;
         case 'ProjectProgressForCurrentLanguage':
             if (!$this->intProjectId) {
                 return false;
             }
             if (isset($this->objProjectProgressForCurrentLanguage)) {
                 return $this->objProjectProgressForCurrentLanguage;
             } else {
                 $this->objProjectProgressForCurrentLanguage = NarroProjectProgress::LoadByProjectIdLanguageId($this->intProjectId, QApplication::GetLanguageId());
                 if (!$this->objProjectProgressForCurrentLanguage instanceof NarroProjectProgress) {
                     $this->objProjectProgressForCurrentLanguage = new NarroProjectProgress();
                     $this->objProjectProgressForCurrentLanguage->LanguageId = QApplication::GetLanguageId();
                     $this->objProjectProgressForCurrentLanguage->ProjectId = $this->intProjectId;
                     $this->objProjectProgressForCurrentLanguage->TotalTextCount = 0;
                     $this->objProjectProgressForCurrentLanguage->ApprovedTextCount = 0;
                     $this->objProjectProgressForCurrentLanguage->FuzzyTextCount = 0;
                     $this->objProjectProgressForCurrentLanguage->ProgressPercent = 0;
                     $this->objProjectProgressForCurrentLanguage->LastModified = QDateTime::Now();
                     $this->objProjectProgressForCurrentLanguage->Active = $this->Active;
                     $this->objProjectProgressForCurrentLanguage->Save();
                 }
                 return $this->objProjectProgressForCurrentLanguage;
             }
         case 'DefaultTemplatePath':
             return __IMPORT_PATH__ . '/' . $this->ProjectId . '/' . NarroLanguage::SOURCE_LANGUAGE_CODE;
         case 'DefaultTranslationPath':
             return __IMPORT_PATH__ . '/' . $this->ProjectId . '/' . QApplication::$TargetLanguage->LanguageCode;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
 /**
  * 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 (($objNarroProjectProgress = NarroProjectProgress::LoadByProjectIdLanguageId($this->lstProject->SelectedValue, $this->lstLanguage->SelectedValue)) && $objNarroProjectProgress->ProjectProgressId != $this->mctNarroProjectProgress->NarroProjectProgress->ProjectProgressId) {
         $blnToReturn = false;
         $this->lstProject->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;
 }
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, NarroProjectProgress::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }
Пример #5
0
}
QFirebug::setEnabled(false);
if (array_search('--help', $argv) !== false) {
    echo sprintf("php %s [options]\n" . "--project                    project id instead of exporting all projects\n" . "--language                   language code instead of importing all languages\n" . "--disable-plugins            disable plugins during import/export\n" . "                             suggestions, optional, defaults to anonymous\n" . "--exported-suggestion        1 for approved,\n" . "                             2 - approved, then most voted,\n" . "                             3 - approved, then most recent,\n" . "                             4 - approved, most voted, most recent,\n" . "                             5 - approved, my suggestion\n" . "--skip-untranslated          skip lines that don't have translated texts\n", basename(__FILE__), NarroLanguage::SOURCE_LANGUAGE_CODE);
    exit;
}
foreach (NarroProject::LoadArrayByActive(1) as $objProject) {
    if (in_array('--project', $argv) && $objProject->ProjectId != $argv[array_search('--project', $argv) + 1]) {
        continue;
    }
    foreach (NarroLanguage::LoadAllActive() as $objLanguage) {
        if (in_array('--language', $argv) && $objLanguage->LanguageCode != $argv[array_search('--language', $argv) + 1]) {
            continue;
        }
        QApplication::$TargetLanguage = $objLanguage;
        $objProjectProgress = NarroProjectProgress::LoadByProjectIdLanguageId($objProject->ProjectId, $objLanguage->LanguageId);
        if (!$objProjectProgress || $objProjectProgress->Active) {
            try {
                $objNarroImporter = new NarroProjectImporter();
                $objNarroImporter->SkipUntranslated = (bool) array_search('--skip-untranslated', $argv);
                NarroPluginHandler::$blnEnablePlugins = !(bool) array_search('--disable-plugins', $argv);
                if (array_search('--exported-suggestion', $argv)) {
                    $objNarroImporter->ExportedSuggestion = $argv[array_search('--exported-suggestion', $argv) + 1];
                }
                $strSourceLanguage = NarroLanguage::SOURCE_LANGUAGE_CODE;
                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));
 /**
  * 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 NarroProjectProgressMetaControl
  * @param integer $intProjectProgressId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing NarroProjectProgress object creation - defaults to CreateOrEdit
  * @return NarroProjectProgressMetaControl
  */
 public static function Create($objParentObject, $intProjectProgressId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intProjectProgressId)) {
         $objNarroProjectProgress = NarroProjectProgress::Load($intProjectProgressId);
         // NarroProjectProgress was found -- return it!
         if ($objNarroProjectProgress) {
             return new NarroProjectProgressMetaControl($objParentObject, $objNarroProjectProgress);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a NarroProjectProgress object with PK arguments: ' . $intProjectProgressId);
             }
         }
         // 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 NarroProjectProgressMetaControl($objParentObject, new NarroProjectProgress());
 }
Пример #7
0
 public function btnSave_Click($strFormId, $strControlId, $strParameter)
 {
     $this->UpdateNarroProjectFields();
     try {
         $this->objProject->Save();
         if ($this->pnlPreferences) {
             $this->pnlPreferences->btnSave_Click($strFormId, $strControlId, $strParameter);
         }
     } catch (Exception $objEx) {
         $this->lblMessage->Text = $objEx->getMessage();
         return false;
     }
     $objProjectProgress = NarroProjectProgress::LoadByProjectIdLanguageId($this->objProject->ProjectId, QApplication::GetLanguageId());
     $objProjectProgress->Active = $this->txtActive->Checked;
     $objProjectProgress->Save();
     if ($this->strTitleVerb == t('Add')) {
         /**
          * If a new project is added, the project directory and source and target are created
          * Also sample export.sh and import.sh are written in the project directory, ready for use
          */
         $strProjectDir = realpath(__IMPORT_PATH__ . '/' . $this->objProject->ProjectId);
         if (!file_exists($strProjectDir)) {
             mkdir($strProjectDir, 0777);
             chmod($strProjectDir, 0777);
             file_put_contents($strProjectDir . '/export.sh', "#!/bin/bash\n" . "#\n" . "PROJECT_DIR=\$(readlink -f \$0)\n" . "PROJECT_DIR=`dirname {$PROJECT_DIR}`\n" . "PARENT_DIR=`dirname {$PROJECT_DIR}`\n" . "PROJECT_ID=`basename {$PROJECT_DIR}`\n" . "\n" . "cd {$PROJECT_DIR}\n" . "\n" . "# \$1 - language code\n" . "# \$2 - language id\n" . "# \$3 - project name\n" . "# \$4 - project id\n" . "# \$5 - user id\n" . "\n" . sprintf("echo \"You can run commands before import or after export by editing export.sh and import.sh from '%s'\"\n", $strProjectDir) . "export retVal=\$?\n" . "# the script will exit with the echo command exit code, 0 = successful run\n" . "exit \$retVal");
             copy($strProjectDir . '/export.sh', $strProjectDir . '/import.sh');
             chmod($strProjectDir . '/export.sh', 0666);
             chmod($strProjectDir . '/import.sh', 0666);
             if (!file_exists($strProjectDir . '/' . NarroLanguage::SOURCE_LANGUAGE_CODE)) {
                 mkdir($strProjectDir . '/' . NarroLanguage::SOURCE_LANGUAGE_CODE, 0777);
             }
             if (!file_exists($strProjectDir . '/' . QApplication::GetLanguageId())) {
                 mkdir($strProjectDir . '/' . QApplication::GetLanguageId(), 0777);
             }
         }
         QApplication::Redirect(NarroLink::ProjectImport($this->objProject->ProjectId));
     }
     if ($this->pnlTextsSource) {
         $this->pnlTextsSource->Directory;
     }
     $this->lblMessage->Text = t('Project saved sucessfully.');
 }
 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';
     }
 }
Пример #9
0
 /**
  * Counts all associated NarroProjectProgressesAsLanguage
  * @return int
  */
 public function CountNarroProjectProgressesAsLanguage()
 {
     if (is_null($this->intLanguageId)) {
         return 0;
     }
     return NarroProjectProgress::CountByLanguageId($this->intLanguageId);
 }
 /**
  * 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 = NarroProjectProgress::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 NarroProjectProgress, given the clauses above
     $this->DataSource = NarroProjectProgress::QueryArray($objConditions, $objClauses);
 }
Пример #11
0
 /**
  * Counts all associated NarroProjectProgressesAsProject
  * @return int
  */
 public function CountNarroProjectProgressesAsProject()
 {
     if (is_null($this->intProjectId)) {
         return 0;
     }
     return NarroProjectProgress::CountByProjectId($this->intProjectId);
 }