protected function Form_Create() { parent::Form_Create(); if (!QApplication::HasPermissionForThisLang('Can export project', $this->objProject->ProjectId)) { QApplication::Redirect(NarroLink::ProjectList()); } $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::Project($this->objProject->ProjectId, t('Overview')); if ($this->objProject instanceof NarroProject && QApplication::HasPermissionForThisLang('Can edit project', $this->objProject->ProjectId)) { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectEdit($this->objProject->ProjectId, t('Edit')); } $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::Translate($this->objProject->ProjectId, '', 0, '', 0, 0, 10, 0, 0, t('Translate')); $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::Review($this->objProject->ProjectId, '', NarroReviewPanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Review')); $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectFileList($this->objProject->ProjectId, '', '', t('Files')); $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectLanguages($this->objProject->ProjectId, t('Languages')); if (QApplication::HasPermissionForThisLang('Can import project', $this->objProject->ProjectId)) { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectImport($this->objProject->ProjectId, t('Import')); } if (QApplication::HasPermissionForThisLang('Can export project', $this->objProject->ProjectId)) { $this->pnlSelectedTab = new NarroProjectExportPanel($this->objProject, $this->pnlMainTab); $arrHeaders[] = t('Export'); $this->pnlMainTab->Selected = count($arrHeaders) - 1; } $this->pnlMainTab->Headers = $arrHeaders; }
protected function Form_Create() { parent::Form_Create(); if (QApplication::QueryString('p') == 0) { $this->pnlMainTab = new QTabs($this); $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectList(t('Projects')); $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::Translate(0, '', NarroTranslatePanel::SHOW_NOT_APPROVED, '', 0, 0, 10, 0, 0, t('Translate')); $this->pnlReview = new NarroTranslatePanel($this->pnlMainTab); $arrHeaders[] = t('Review'); $this->pnlMainTab->Selected = count($arrHeaders) - 1; if (NarroLanguage::CountAllActive() > 2 || QApplication::HasPermission('Administrator')) { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::LanguageList(t('Languages')); } $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::UserList('', t('Users')); $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::RoleList(0, '', t('Roles')); if (QApplication::HasPermissionForThisLang('Administrator')) { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::Log('', t('Application Log')); } $this->pnlMainTab->Headers = $arrHeaders; } else { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::Project($this->objProject->ProjectId, t('Overview')); if ($this->objProject instanceof NarroProject && QApplication::HasPermissionForThisLang('Can edit project', $this->objProject->ProjectId)) { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectEdit($this->objProject->ProjectId, t('Edit')); } $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::Translate($this->objProject->ProjectId, '', NarroTranslatePanel::SHOW_NOT_TRANSLATED, '', 0, 0, 10, 0, 0, t('Translate')); $this->pnlReview = new NarroTranslatePanel($this->pnlMainTab); $arrHeaders[] = t('Review'); $this->pnlMainTab->Selected = count($arrHeaders) - 1; $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectFileList($this->objProject->ProjectId, '', '', t('Files')); $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectLanguages($this->objProject->ProjectId, t('Languages')); if (QApplication::HasPermissionForThisLang('Can import project', $this->objProject->ProjectId)) { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectImport($this->objProject->ProjectId, t('Import')); } if (QApplication::HasPermissionForThisLang('Can export project', $this->objProject->ProjectId)) { $pnlDummy = new QPanel($this->pnlMainTab); $arrHeaders[] = NarroLink::ProjectExport($this->objProject->ProjectId, t('Export')); } $this->pnlMainTab->Headers = $arrHeaders; } }
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.'); }