public function __get($strName) { switch ($strName) { case "Directory": if ($this->chkCopyFilesToDefaultDirectory->Checked && __IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode != $this->txtDirectory->Text) { if (file_exists(__IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode)) { NarroUtils::RecursiveDelete(__IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode . '/*'); } else { mkdir(__IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode, 0777); } NarroUtils::RecursiveCopy($this->txtDirectory->Text, __IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode); NarroUtils::RecursiveChmod(__IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode); } return $this->txtDirectory->Text; default: try { return parent::__get($strName); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
protected function GetWorkingDirectory() { if (!file_exists($this->fileSource->File)) { throw new Exception('You have to upload a file'); } $this->strWorkingDirectory = sprintf('%s/upload-u_%d-l_%s-p_%d', __TMP_PATH__, QApplication::GetUserId(), $this->objLanguage->LanguageCode, $this->objProject->ProjectId); $this->CleanWorkingDirectory(); mkdir($this->strWorkingDirectory); chmod($this->strWorkingDirectory, 0777); switch (strtolower(pathinfo($this->fileSource->File, PATHINFO_EXTENSION))) { case 'zip': case 'xpi': NarroLogger::LogInfo(sprintf('Trying to uncompress %s', $this->fileSource->FileName)); $objZipFile = new ZipArchive(); $intErrCode = $objZipFile->open($this->fileSource->File); if ($intErrCode === TRUE) { $objZipFile->extractTo($this->strWorkingDirectory); $objZipFile->close(); NarroLogger::LogInfo(sprintf('Sucessfully uncompressed %s.', $this->fileSource->FileName)); } else { switch ($intErrCode) { case ZIPARCHIVE::ER_NOZIP: $strError = 'Not a zip archive'; break; default: $strError = 'Error code: ' . $intErrCode; } $this->fileSource->File = ''; throw new Exception(sprintf('Failed to uncompress %s: %s', $this->fileSource->File, $strError)); } break; case 'dtd': case 'properties': case 'ini': case 'inc': case 'po': case 'sdf': case 'svg': case 'dpo': case 'srt': case 'php': copy($this->fileSource->File, $this->strWorkingDirectory . '/' . $this->fileSource->FileName); chmod($this->strWorkingDirectory . '/' . $this->fileSource->FileName, 0666); NarroLogger::LogInfo(sprintf('Single file uploaded, copied %s to %s', $this->fileSource->FileName, $this->strWorkingDirectory)); break; default: throw new Exception(sprintf('Unsupported file type uploaded')); } if (file_exists($this->fileSource->File)) { unlink($this->fileSource->File); } $this->fileSource->btnDelete_Click(); $arrSearchResult = NarroUtils::SearchDirectoryByName($this->strWorkingDirectory, $this->objLanguage->LanguageCode); if ($arrSearchResult == false) { $arrSearchResult = NarroUtils::SearchDirectoryByName($this->strWorkingDirectory, $this->objLanguage->LanguageCode . '-' . $this->objLanguage->CountryCode); } if ($arrSearchResult == false) { $arrSearchResult = NarroUtils::SearchDirectoryByName($this->strWorkingDirectory, $this->objLanguage->LanguageCode . '_' . $this->objLanguage->CountryCode); } NarroUtils::RecursiveChmod($this->strWorkingDirectory); if (is_array($arrSearchResult) && count($arrSearchResult) == 1) { NarroLogger::LogWarn(sprintf('Path changed from "%s" to "%s" because a directory named "%s" was found deeper in the given path.', $this->strWorkingDirectory, $arrSearchResult[0], $this->objLanguage->LanguageCode)); $this->strWorkingDirectory = $arrSearchResult[0]; } if ($this->chkCopyFilesToDefaultDirectory->Checked) { if (file_exists(__IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode)) { NarroUtils::RecursiveDelete(__IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode . '/*'); } else { mkdir(__IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode, 0777); } NarroUtils::RecursiveCopy($this->strWorkingDirectory, __IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode); NarroUtils::RecursiveChmod(__IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode); } return $this->strWorkingDirectory; }
protected function GetWorkingDirectory($strCheckoutCommand = null) { $this->strWorkingDirectory = sprintf('%s/upload-u_%d-l_%s-p_%d', __TMP_PATH__, QApplication::GetUserId(), $this->objLanguage->LanguageCode, $this->objProject->ProjectId); $this->CleanWorkingDirectory(); if (!$this instanceof NarroMercurialSourcePanel) { mkdir($this->strWorkingDirectory); } $strCommand = sprintf($strCheckoutCommand, escapeshellarg($this->txtRepository->Text), escapeshellarg($this->strWorkingDirectory)); NarroLogger::LogInfo(sprintf('Running "%s"', $strCommand)); $strProcLogFile = __TMP_PATH__ . '/' . $this->objProject->ProjectId . '-' . $this->objLanguage->LanguageCode . '-vcs.log'; if (file_exists($strProcLogFile) && is_writable($strProcLogFile)) { unlink($strProcLogFile); } chdir(__TMP_PATH__); $mixProcess = proc_open("{$strCommand}", array(1 => array("file", $strProcLogFile, 'a'), 2 => array("file", $strProcLogFile, 'a')), $foo); $status = proc_get_status($mixProcess); while ($status['running']) { $status = proc_get_status($mixProcess); } proc_close($mixProcess); if (!file_exists($this->strWorkingDirectory)) { throw new Exception(sprintf('The working directory "%s" does not exist, probably the checkout command failed', $this->strWorkingDirectory)); } chmod($this->strWorkingDirectory, 0777); if (file_exists($strProcLogFile)) { NarroLogger::LogInfo(file_get_contents($strProcLogFile)); } NarroUtils::RecursiveDelete($this->strWorkingDirectory . '/.hg'); foreach (NarroUtils::SearchDirectoryByName($this->strWorkingDirectory, '.svn') as $strSvnDir) { NarroUtils::RecursiveDelete($strSvnDir); } $arrSearchResult = NarroUtils::SearchDirectoryByName($this->strWorkingDirectory, $this->objLanguage->LanguageCode); if ($arrSearchResult == false) { $arrSearchResult = NarroUtils::SearchDirectoryByName($this->strWorkingDirectory, $this->objLanguage->LanguageCode . '-' . $this->objLanguage->CountryCode); } if ($arrSearchResult == false) { $arrSearchResult = NarroUtils::SearchDirectoryByName($this->strWorkingDirectory, $this->objLanguage->LanguageCode . '_' . $this->objLanguage->CountryCode); } NarroUtils::RecursiveChmod($this->strWorkingDirectory); if (is_array($arrSearchResult) && count($arrSearchResult) == 1) { NarroLogger::LogWarn(sprintf('Path changed from "%s" to "%s" because a directory named "%s" was found deeper in the given path.', $this->strWorkingDirectory, $arrSearchResult[0], $this->objLanguage->LanguageCode)); $this->strWorkingDirectory = $arrSearchResult[0]; } if ($this->chkCopyFilesToDefaultDirectory->Checked) { if (file_exists(__IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode)) { NarroUtils::RecursiveDelete(__IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode . '/*'); } else { mkdir(__IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode, 0777, true); } NarroUtils::RecursiveCopy($this->strWorkingDirectory, __IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode); NarroUtils::RecursiveChmod(__IMPORT_PATH__ . '/' . $this->objProject->ProjectId . '/' . $this->objLanguage->LanguageCode); } return $this->strWorkingDirectory; }
public function btnTest_Click() { NarroProject::RegisterPreference('Mercurial commit path', false, 0, 'text', 'The url to commit this project to mercurial.', ''); NarroProject::RegisterPreference('Username for Mercurial', false, 0, 'text', '', ''); $this->objProject->SetPreferenceValueByName('Mercurial commit path', $this->txtRepositoryUrl->Text); $this->objProject->SetPreferenceValueByName('Username for Mercurial', $this->txtUsername->Text); $this->objProject->Save(); $strSSHKey = sprintf('%s/mercurial_%d_%s_%d', __TMP_PATH__, QApplication::$User->UserId, QApplication::$TargetLanguage->LanguageCode, $this->objProject->ProjectId); $strProcLogFile = __TMP_PATH__ . '/' . $this->objProject->ProjectId . '-' . QApplication::$TargetLanguage->LanguageCode . '-mercurial.log'; copy($this->fileSSHPrivateKey->File, $strSSHKey); chmod($strSSHKey, 0600); file_put_contents($strSSHKey . '_hgrc', sprintf("[paths]\n" . "default = %s\n" . "\n" . "[ui]\n" . "ssh = ssh -i %s -o StrictHostKeyChecking=no -l %s\n" . "username = %s\n", $this->txtRepositoryUrl->Text, $strSSHKey, $this->txtUsername->Text, $this->txtCommitUsername->Text)); $mixProcess = exec(sprintf('export HOME=%s;export HGRCPATH=%s; hg clone %s %s_mercurial;cd %s_mercurial; cp -f -R %s/* .; hg addremove; hg diff -w --nodates > %s_diff; hg commit -m "%s" %s; hg outgoing', __TMP_PATH__, $strSSHKey . '_hgrc', escapeshellarg($this->txtRepositoryUrl->Text), $strSSHKey, $strSSHKey, escapeshellarg($this->objProject->DefaultTranslationPath), $strSSHKey, escapeshellarg($this->txtCommitMessage->Text), $this->pnlPatchViewer && count($this->pnlPatchViewer->SelectedFiles) ? join(" ", $this->pnlPatchViewer->SelectedFiles) : ""), $arrOutput); $this->lblOutput->Text = join("\n", $arrOutput); $this->Form->RemoveControl($this->pnlPatchViewer->ControlId); $this->pnlPatchViewer = new NarroPatchViewerPanel($strSSHKey . '_diff', $this); unlink($strSSHKey); unlink($strSSHKey . '_hgrc'); unlink($strSSHKey . '_diff'); NarroUtils::RecursiveDelete($strSSHKey . '_mercurial'); $this->btnCommit->Display = true; $this->chkForce->Display = true; }
public static function Reset() { NarroUtils::RecursiveDelete(__CACHE__ . '/*'); }
public function btnDelete_Click($strFormId, $strControlId, $strParameter) { if (!QApplication::HasPermission('Can delete project', $this->objProject->ProjectId)) { QApplication::Redirect(NarroLink::ProjectList()); } $objDatabase = QApplication::$Database[1]; try { $strQuery = sprintf("DELETE FROM narro_context_info USING narro_context_info LEFT JOIN narro_context ON narro_context_info.context_id=narro_context.context_id WHERE narro_context_info.language_id=%d AND narro_context.project_id=%d", QApplication::GetLanguageId(), $this->objProject->ProjectId); $objDatabase->NonQuery($strQuery); $strQuery = sprintf("DELETE FROM `narro_context` WHERE project_id = %d", $this->objProject->ProjectId); $objDatabase->NonQuery($strQuery); $strQuery = sprintf("DELETE FROM `narro_file` WHERE project_id = %d", $this->objProject->ProjectId); $objDatabase->NonQuery($strQuery); $strQuery = sprintf("DELETE FROM `narro_user_role` WHERE project_id = %d", $this->objProject->ProjectId); $objDatabase->NonQuery($strQuery); $intProjectId = $this->objProject->ProjectId; $this->objProject->Delete(); NarroUtils::RecursiveDelete(__IMPORT_PATH__ . '/' . $intProjectId); NarroUtils::RecursiveDelete(sprintf('%s/project-%d-hg', __NARRO_DATA__ . '/mozilla-build', $intProjectId)); NarroUtils::RecursiveDelete(sprintf('%s/project-%d-obj', __NARRO_DATA__ . '/mozilla-build', $intProjectId)); } catch (Exception $objEx) { $this->lblMessage->Text = $objEx->getMessage(); return false; } QApplication::Redirect(NarroLink::ProjectList()); }
public function ExportToXpi($strXpiFilePath) { $strArchive = $this->strTranslationPath . '/' . basename($strXpiFilePath); if (file_exists($strArchive)) { unlink($strArchive); } $strWorkingDir = $strXpiFilePath . '_extract'; mkdir($strWorkingDir, 0777); NarroLogger::LogInfo(sprintf('Trying to uncompress %s', $strXpiFilePath)); $objZipFile = new ZipArchive(); $intErrCode = $objZipFile->open($strXpiFilePath); if ($intErrCode === TRUE) { $objZipFile->extractTo($strWorkingDir); $objZipFile->close(); NarroLogger::LogInfo(sprintf('Sucessfully uncompressed %s.', $strXpiFilePath)); } else { switch ($intErrCode) { case ZIPARCHIVE::ER_NOZIP: $strError = 'Not a zip archive'; break; default: $strError = 'Error code: ' . $intErrCode; } throw new Exception(sprintf('Failed to uncompress %s: %s', $strXpiFilePath, $strError)); } NarroUtils::RecursiveChmod($strWorkingDir); // Search source directory $arrSearchResult = NarroUtils::SearchDirectoryByName($strWorkingDir, $this->objSourceLanguage->LanguageCode); if ($arrSearchResult == false) { $arrSearchResult = NarroUtils::SearchDirectoryByName($strWorkingDir, $this->objSourceLanguage->LanguageCode . '-' . $this->objSourceLanguage->CountryCode); } if ($arrSearchResult == false) { $arrSearchResult = NarroUtils::SearchDirectoryByName($strWorkingDir, $this->objSourceLanguage->LanguageCode . '_' . $this->objSourceLanguage->CountryCode); } if (is_array($arrSearchResult) && count($arrSearchResult) == 1) { NarroLogger::LogWarn(sprintf('Path changed from "%s" to "%s" because a directory named "%s" was found deeper in the given path.', $strWorkingDir, $arrSearchResult[0], $this->objSourceLanguage->LanguageCode)); $strTemplatePath = $arrSearchResult[0]; } // Search target directory $arrSearchResult = NarroUtils::SearchDirectoryByName($strWorkingDir, $this->objTargetLanguage->LanguageCode); if ($arrSearchResult == false) { $arrSearchResult = NarroUtils::SearchDirectoryByName($strWorkingDir, $this->objTargetLanguage->LanguageCode . '-' . $this->objTargetLanguage->CountryCode); } if ($arrSearchResult == false) { $arrSearchResult = NarroUtils::SearchDirectoryByName($strWorkingDir, $this->objTargetLanguage->LanguageCode . '_' . $this->objTargetLanguage->CountryCode); } if (is_array($arrSearchResult) && count($arrSearchResult) == 1) { NarroLogger::LogWarn(sprintf('Path changed from "%s" to "%s" because a directory named "%s" was found deeper in the given path.', $strWorkingDir, $arrSearchResult[0], $this->objTargetLanguage->LanguageCode)); $strTranslationPath = $arrSearchResult[0]; } if (isset($strTemplatePath)) { $strOldTemplatePath = $this->strTemplatePath; $this->strTemplatePath = $strTemplatePath; if (isset($strTranslationPath)) { $this->strTranslationPath = $strTranslationPath; } $this->ExportFromDirectory(); $arrFiles = NarroUtils::ListDirectory($strWorkingDir, null, null, null, true); $objZipFile = new ZipArchive(); if ($objZipFile->open($strArchive, ZipArchive::OVERWRITE) === TRUE) { foreach ($arrFiles as $strFileName) { if (basename($strFileName) == 'chrome.manifest') { $strManifest = file_get_contents($strFileName); preg_match_all('/^locale\\s+([^\\s]+)\\s+([^\\s]+)\\s+([^\\s]+)\\s+/m', $strManifest, $arrMatches); if (isset($arrMatches[2]) && in_array($this->objTargetLanguage->LanguageCode, $arrMatches[2])) { // locale already in the manifest NarroLogger::LogInfo('Locale already in the manifest'); } else { $strLastLocaleCode = $arrMatches[2][count($arrMatches[2]) - 1]; $strLastLocaleLine = $arrMatches[0][count($arrMatches[2]) - 1]; $strLastLocalePath = $arrMatches[3][count($arrMatches[2]) - 1]; $strManifest = str_replace($strLastLocaleLine, $strLastLocaleLine . "\n" . sprintf('locale %s %s %s', $arrMatches[1][count($arrMatches[2]) - 1], $this->objTargetLanguage->LanguageCode, preg_replace('/\\/[^\\/]+\\/\\s*$/m', '/' . $this->objTargetLanguage->LanguageCode . '/', $strLastLocalePath)), $strManifest); } } if ($strWorkingDir == $strFileName) { continue; } if (is_dir($strFileName)) { $objZipFile->addEmptyDir(str_replace($strWorkingDir . '/', '', $strFileName)); } elseif (is_file($strFileName)) { $objZipFile->addFile($strFileName, str_replace($strWorkingDir . '/', '', $strFileName)); } } $objZipFile->close(); if (file_exists($strArchive)) { chmod($strArchive, 0666); } else { NarroLogger::LogError(sprintf('Failed to create an archive %s', $strArchive)); NarroUtils::RecursiveDelete($strWorkingDir); return false; } } else { NarroLogger::LogError(sprintf('Failed to create a new archive %s', $strArchive)); NarroUtils::RecursiveDelete($strWorkingDir); return false; } } NarroUtils::RecursiveDelete($strWorkingDir); return true; }
public function btnTest_Click() { if ($this->RepositorySetup() == 0) { $mixProcess = NarroUtils::Exec(sprintf('svn diff > %s_diff', $this->strSSHKey), $arrOutput, $arrError, $intRetVal, false, array('SVN_SSH' => sprintf('ssh -o StrictHostKeyChecking=no -l %s -p 22 -i %s', escapeshellarg($this->txtUsername->Text), $this->strSSHKey), 'HOME' => __TMP_PATH__), $this->strSSHKey . '_svn', true); } else { $this->lblOutput->Text = join("\n", $arrOutput); } $this->Form->RemoveControl($this->pnlPatchViewer->ControlId); NarroPatchViewerPanel::$strFileExpression = '/^\\-\\-\\-\\s([^\\(]+).*$/'; $this->pnlPatchViewer = new NarroPatchViewerPanel($this->strSSHKey . '_diff', $this); unlink($this->strSSHKey); unlink($this->strSSHKey . '_diff'); NarroUtils::RecursiveDelete($this->strSSHKey . '_svn'); $this->btnCommit->Display = true; }
public function btnExport_Click($strFormId, $strControlId, $strParameter) { if (!QApplication::HasPermissionForThisLang('Can export project', $this->objProject->ProjectId)) { return false; } $strProcLogFile = __TMP_PATH__ . '/' . $this->objProject->ProjectId . '-' . QApplication::$TargetLanguage->LanguageCode . '-export-process.log'; if ($strParameter == 1) { if (NarroUtils::IsProcessRunning('export', $this->objProject->ProjectId)) { $this->objExportProgress->Translated = NarroProgress::GetProgress($this->objProject->ProjectId, 'export'); $this->objExportProgress->MarkAsModified(); } else { $this->lblExport->Text = t('Export finished.'); if (QApplication::$UseAjax) { QApplication::ExecuteJavaScript('if (typeof lastExportId != \'undefined\') clearInterval(lastExportId)'); } if (file_exists($strProcLogFile) && filesize($strProcLogFile)) { NarroLogger::LogInfo(sprintf('There are messages from the background process: %s', file_get_contents($strProcLogFile))); } $this->lblExport->Visible = true; $this->btnExport->Visible = true; $this->btnKillProcess->Visible = false; $this->objExportProgress->Translated = 0; $this->objExportProgress->Visible = false; QApplication::$PluginHandler->DisplayExportMessage($this->objProject); if (is_array(QApplication::$PluginHandler->PluginReturnValues)) { foreach (QApplication::$PluginHandler->PluginReturnValues as $strPluginName => $mixReturnValue) { if (count($mixReturnValue) == 2 && $mixReturnValue[0] instanceof NarroProject && is_string($mixReturnValue[1]) && $mixReturnValue[1] != '') { $this->lblExport->Text .= sprintf('<br /><span class="info"><b>%s</b>: %s</span>', $strPluginName, nl2br($mixReturnValue[1])); } } } } $this->pnlLogViewer->MarkAsModified(); } elseif ($strParameter == 2) { $this->pnlLogViewer->DateStart = QDateTime::Now(); $this->pnlLogViewer->ProjectId = $this->objProject->ProjectId; $this->pnlLogViewer->LanguageId = QApplication::GetLanguageId(); NarroProgress::ClearProgressFileName($this->objProject->ProjectId, 'import'); set_time_limit(0); if ($this->chkCleanDirectory->Checked) { NarroUtils::RecursiveDelete($this->objProject->DefaultTranslationPath . '/*'); } $objNarroImporter = new NarroProjectImporter(); /** * Get boolean options */ $objNarroImporter->ExportedSuggestion = $this->lstExportSuggestionType->SelectedValue; $objNarroImporter->Project = $this->objProject; $objNarroImporter->ExportAuthorList = $this->txtAuthor->Text; $objNarroImporter->User = QApplication::$User; $objNarroImporter->TargetLanguage = QApplication::$TargetLanguage; $objNarroImporter->SourceLanguage = NarroLanguage::LoadByLanguageCode(NarroLanguage::SOURCE_LANGUAGE_CODE); try { $objNarroImporter->TranslationPath = $this->objProject->DefaultTranslationPath; $objNarroImporter->TemplatePath = $this->objProject->DefaultTemplatePath; } catch (Exception $objEx) { NarroLogger::LogError(sprintf('An error occurred during export: %s', $objEx->getMessage())); $this->lblExport->Text = t('Export failed.'); } try { $objNarroImporter->ExportProject(); } catch (Exception $objEx) { NarroLogger::LogError(sprintf('An error occurred during export: %s', $objEx->getMessage())); $this->lblExport->Text = t('Export failed.'); } $this->lblExport->Visible = true; $this->btnExport->Visible = true; $this->btnKillProcess->Visible = false; $this->objExportProgress->Visible = false; $this->pnlLogViewer->MarkAsModified(); } else { $this->pnlLogViewer->DateStart = QDateTime::Now(); $this->pnlLogViewer->ProjectId = $this->objProject->ProjectId; $this->pnlLogViewer->LanguageId = QApplication::GetLanguageId(); if ($this->chkCleanDirectory->Checked) { NarroUtils::RecursiveDelete($this->objProject->DefaultTranslationPath . '/*'); } $this->btnExport->Visible = false; $this->btnKillProcess->Visible = $this->btnKillProcess->Visible = QApplication::HasPermission('Administrator', $this->objProject, QApplication::$TargetLanguage->LanguageCode); $this->objExportProgress->Visible = true; $this->objExportProgress->Translated = 0; $this->lblExport->Text = ''; try { $strCommand = sprintf('%s %s --export --project %d --user %d --template-lang %s --translation-lang %s --template-directory %s --translation-directory %s --exported-suggestion %d --export-author-list %s', __PHP_CLI_PATH__, escapeshellarg(sprintf('%s/includes/narro/importer/narro-cli.php', __DOCROOT__ . __SUBDIRECTORY__)), (int) $this->objProject->ProjectId, (int) QApplication::$User->UserId, escapeshellarg(NarroLanguage::SOURCE_LANGUAGE_CODE), escapeshellarg(QApplication::$TargetLanguage->LanguageCode), escapeshellarg($this->objProject->DefaultTemplatePath), escapeshellarg($this->objProject->DefaultTranslationPath), (int) $this->lstExportSuggestionType->SelectedValue, escapeshellarg($this->txtAuthor->Text)); } catch (Exception $objEx) { NarroLogger::LogError(sprintf('An error occurred during export: %s', $objEx->getMessage())); $this->lblExport->Text = t('Export failed.'); $this->lblExport->Visible = true; $this->btnExport->Visible = true; $this->btnKillProcess->Visible = false; $this->objExportProgress->Translated = 0; $this->objExportProgress->Visible = false; $this->pnlLogViewer->MarkAsModified(); return false; } if (file_exists($strProcLogFile) && is_writable($strProcLogFile)) { unlink($strProcLogFile); } $mixProcess = proc_open("{$strCommand} &", array(2 => array("file", $strProcLogFile, 'a')), $foo); if ($mixProcess) { if (QApplication::$UseAjax) { QApplication::ExecuteJavaScript(sprintf('lastExportId = setInterval("qc.pA(\'%s\', \'%s\', \'QClickEvent\', \'1\')", %d);', $strFormId, $strControlId, 2000)); } else { $this->btnExport_Click($strFormId, $strControlId, 1); } } else { $this->objExportProgress->Visible = false; NarroLogger::LogError('Failed to launch a background process, there will be no progress displayed, and it might take a while, please wait for more messages'); $this->pnlLogViewer->MarkAsModified(); /** * try exporting without launching a background process */ if (QApplication::$UseAjax) { QApplication::ExecuteJavaScript(sprintf('lastExportId = setTimeout("qc.pA(\'%s\', \'%s\', \'QClickEvent\', \'2\')", %d);', $strFormId, $strControlId, 2000)); } else { $this->btnExport_Click($strFormId, $strControlId, 2); } } } }