/** * Display */ public function display() { $Code = str_replace(array("\r", "\n", "\t"), array("", "", ""), $this->getHTMLCode()); $CodeField = new FormularTextarea('code', __('Code'), $Code); $CodeField->addCSSclass('fullwidth'); $CodeField->addAttribute('rows', 3); $FieldsetCode = new FormularFieldset(__('HTML-Code')); if (System::isAtLocalhost()) { $FieldsetCode->addError(__('Runalyze runs on a local server. Only people in your local network will be able to see the training.')); } $FieldsetCode->addField($CodeField); $FieldsetCode->addInfo(__('Add this code to your blog/website.')); $WidthField = new FormularInputNumber('width', __('Width'), $this->width()); $WidthField->setLayout(FormularFieldset::$LAYOUT_FIELD_W50); $WidthField->setMin(200); $WidthField->setMax(600); $HeightField = new FormularInputNumber('height', __('Height'), $this->height()); $HeightField->setLayout(FormularFieldset::$LAYOUT_FIELD_W50); $HeightField->setMin(200); $HeightField->setMax(600); $SubmitField = new FormularSubmit(__('Change size'), ''); $FieldsetCode->addField($WidthField); $FieldsetCode->addField($HeightField); $FieldsetCode->addField($SubmitField); $FieldsetPreview = new FormularFieldset(__('Preview')); $FieldsetPreview->addBlock($Code); $Formular = new Formular($_SERVER['SCRIPT_NAME'] . '?type=IFrame&id=' . $this->Context->activity()->id()); $Formular->addCSSclass('ajax'); $Formular->addCSSclass('no-automatic-reload'); $Formular->addFieldset($FieldsetCode); $Formular->addFieldset($FieldsetPreview); $Formular->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W100); $Formular->display(); }
/** * Get fieldset for permissions * @return \FormularFieldset */ private function getPermissionsFieldset() { $CHMOD_FOLDERS = array(); $failures = 0; include FRONTEND_PATH . 'system/define.chmod.php'; $Fieldset = new FormularFieldset(__('Permissions')); $Fieldset->addBlock(__('The following directories do need write permissions. (And the right owner has to be set!)')); foreach ($CHMOD_FOLDERS as $folder) { $realfolder = FRONTEND_PATH . '../' . $folder; $chmod = substr(decoct(fileperms($realfolder)), 1); if (!is_writable($realfolder)) { $Fieldset->addError(sprintf(__('The directory <strong>%s</strong> is not writable.'), $folder) . ' <em>(chmod = ' . $chmod . ')</em>'); $failures++; } else { $Fieldset->addOkay(sprintf(__('The directory <strong>%s</strong> is writable.'), $folder) . ' <em>(chmod = ' . $chmod . ')</em>'); } } if ($failures == 0) { $Fieldset->setCollapsed(); } return $Fieldset; }
/** * Display import form */ protected function displayImportForm() { $Fieldset = new FormularFieldset(__('Import file')); $Formular = new Formular($_SERVER['SCRIPT_NAME'] . '?id=' . $this->id()); $Formular->setId('import-json-form'); $Formular->addCSSclass('ajax'); $Formular->addCSSclass('no-automatic-reload'); $Formular->addHiddenValue('file', $_GET['file']); if (substr($_GET['file'], -8) != '.json.gz') { $Fieldset->addError(__('You can only import *.json.gz-files.')); Filesystem::deleteFile('../data/DbBackup/import/' . $_GET['file']); } else { require_once __DIR__ . '/class.RunalyzeJsonAnalyzer.php'; $Analyzer = new RunalyzeJsonAnalyzer('../data/DbBackup/import/' . $_GET['file']); if ($Analyzer->fileIsOkay()) { $Fieldset->addField(new FormularCheckbox('overwrite_config', __('Overwrite general configuration'), true)); $Fieldset->addField(new FormularCheckbox('overwrite_dataset', __('Overwrite dataset configuration'), true)); $Fieldset->addField(new FormularCheckbox('overwrite_plugin', __('Overwrite plugins'), true)); $Fieldset->addField(new FormularCheckbox('delete_trainings', __('Delete all old activities'), false)); $Fieldset->addField(new FormularCheckbox('delete_user_data', __('Delete all old body values'), false)); $Fieldset->addFileBlock(sprintf(__('There are <strong>%s</strong> activities in this file.'), $Analyzer->count('runalyze_training'))); $Fieldset->addFileBlock(sprintf(__('There are <strong>%s</strong> body values in this file.'), $Analyzer->count('runalyze_user'))); $Fieldset->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W100); $Formular->addSubmitButton(__('Import')); } elseif (!$Analyzer->versionIsOkay()) { $Fieldset->addError(sprintf(__('Versions do not match! The backup is from %s but you are using %s.'), $Analyzer->fileVersion(), 'v' . RUNALYZE_VERSION)); } else { $Fieldset->addError(__('The file seems to be corrupted.')); foreach ($Analyzer->errors() as $Error) { $Fieldset->addError($Error); } } } $Formular->addFieldset($Fieldset); $Formular->display(); }