/**
  * 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();
 }
 /**
  * Add boolean field
  * @param string $key
  * @param string $label
  */
 private function addBooleanField($key, $label)
 {
     $Field = new FormularSelectBox($key, $label);
     $Field->setLayout(FormularFieldset::$LAYOUT_FIELD_W33);
     $Field->setOptions(array('' => '', '1' => __('Yes'), '0' => __('No')));
     $this->Fieldset->addField($Field);
 }
 /**
  * Add fields for robert bock and herbert steffny
  */
 protected function addFieldsForBockAndSteffny()
 {
     $BestResult = new FormularInput('best-result-km', __('Best result'));
     $BestResult->setLayout(FormularFieldset::$LAYOUT_FIELD_W50);
     $BestResult->addCSSclass('hide-on-model-change');
     $BestResult->addCSSclass('only-robert-bock');
     $BestResult->addCSSclass('only-herbert-steffny');
     $BestResult->addCSSclass('only-david-cameron');
     $BestResult->setUnit(FormularUnit::$KM);
     $BestResultTime = new FormularInput('best-result-time', __('in'));
     $BestResultTime->setLayout(FormularFieldset::$LAYOUT_FIELD_W50);
     $BestResultTime->addCSSclass('hide-on-model-change');
     $BestResultTime->addCSSclass('only-robert-bock');
     $BestResultTime->addCSSclass('only-herbert-steffny');
     $BestResultTime->addCSSclass('only-david-cameron');
     $SecondBestResult = new FormularInput('second-best-result-km', __('Second best result'));
     $SecondBestResult->setLayout(FormularFieldset::$LAYOUT_FIELD_W50);
     $SecondBestResult->addCSSclass('hide-on-model-change');
     $SecondBestResult->addCSSclass('only-robert-bock');
     $SecondBestResult->setUnit(FormularUnit::$KM);
     $SecondBestResultTime = new FormularInput('second-best-result-time', __('in'));
     $SecondBestResultTime->setLayout(FormularFieldset::$LAYOUT_FIELD_W50);
     $SecondBestResultTime->addCSSclass('hide-on-model-change');
     $SecondBestResultTime->addCSSclass('only-robert-bock');
     $this->FieldsetInput->addField($BestResult);
     $this->FieldsetInput->addField($BestResultTime);
     $this->FieldsetInput->addField($SecondBestResult);
     $this->FieldsetInput->addField($SecondBestResultTime);
 }
Beispiel #4
0
 /**
  * Activate difference
  * Add checkbox and warning for differences between handmade laps and total distance.
  */
 public function activateHandmadeDifference()
 {
     $Checkbox = new FormularCheckbox('calculate-for-splits', __('Calculate values for handmade splits although total distance does not match.'));
     $Checkbox->setLayout(FormularFieldset::$LAYOUT_FIELD_W100_CHECKBOX);
     $this->Fieldset->addField($Checkbox);
     $this->Fieldset->addWarning(__('The total distance of your handmade laps differs from the gps distance.'));
 }
 /**
  * Add all fieldsets to given fieldset
  * @param FormularFieldset $Fieldset
  * @param array $fieldKeys
  */
 public function addFields(FormularFieldset &$Fieldset, $fieldKeys)
 {
     foreach ($fieldKeys as $key) {
         if (!$this->DatabaseScheme->fieldIsHidden($key)) {
             $Fieldset->addField($this->getFieldFor($key));
         }
     }
 }
 /**
  * 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', 8);
     $FieldsetCode = new FormularFieldset(__('HTML-Code'));
     $FieldsetCode->addField($CodeField);
     $FieldsetCode->addInfo(__('Add this code to your blog/website.'));
     $FieldsetPreview = new FormularFieldset(__('Preview'));
     $FieldsetPreview->addBlock($Code);
     if (!$this->Context->activity()->isPublic()) {
         $FieldsetPreview->addWarning(__('Your training is private: There is no link included.'));
     }
     $Formular = new Formular();
     $Formular->addFieldset($FieldsetCode);
     $Formular->addFieldset($FieldsetPreview);
     $Formular->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W100);
     $Formular->display();
 }
Beispiel #7
0
 /**
  * Get fieldset for settings
  * @return \FormularFieldset
  */
 private function getSettingsFieldset()
 {
     FormularInput::setStandardSize(FormularInput::$SIZE_MIDDLE);
     $Fieldset = new FormularFieldset(__('Settings'));
     $Fieldset->addField(new FormularCheckbox('RUNALYZE_DEBUG', __('Debug mode')));
     $Fieldset->addField(new FormularCheckbox('USER_CANT_LOGIN', __('Maintenance mode')));
     $Fieldset->addField(new FormularCheckbox('USER_CAN_REGISTER', __('Users can register')));
     $Fieldset->addField(new FormularInput('GARMIN_API_KEY', Ajax::tooltip(__('Garmin API-key'), __('Needed for any online-version of the Garmin Communicator<br>see http://developer.garmin.com/web-device/garmin-communicator-plugin/get-your-site-key/'))));
     $Fieldset->addField(new FormularInput('PERL_PATH', __('Perl Path')));
     $Fieldset->addField(new FormularInput('TTBIN_PATH', __('TTBIN Converter Path')));
     $Fieldset->addField(new FormularInput('MAIL_SENDER', __('Sender e-mail')));
     $Fieldset->addField(new FormularInput('MAIL_NAME', __('Sender e-mail name')));
     $Fieldset->addField(new FormularInput('SMTP_HOST', __('SMTP: host')));
     $Fieldset->addField(new FormularInput('SMTP_PORT', __('SMTP: port')));
     $Fieldset->addField(new FormularInput('SMTP_SECURITY', __('SMTP: encryption')));
     $Fieldset->addField(new FormularInput('SMTP_USERNAME', __('SMTP: username')));
     $Fieldset->addField(new FormularInputPassword('SMTP_PASSWORD', __('SMTP: password')));
     $Fieldset->addField(new FormularInput('OPENWEATHERMAP_API_KEY', Ajax::tooltip(__('OpenWeatherMap API-Key'), __('Loading weather data requires an api key, see openweathermap.org/appid'))));
     $Fieldset->addField(new FormularInput('NOKIA_HERE_APPID', Ajax::tooltip(__('Nokia/Here App-ID'), __('Nokia maps require an app-id/-token, see developer.here.com'))));
     $Fieldset->addField(new FormularInput('NOKIA_HERE_TOKEN', Ajax::tooltip(__('Nokia/Here Token'), __('Nokia maps require an app-id/-token, see developer.here.com'))));
     $Fieldset->addField(new FormularSubmit(__('Save'), ''));
     $Fieldset->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W100);
     if (!is_writable(FRONTEND_PATH . '../data/config.php')) {
         $Fieldset->addError(__('<strong>data/config.php</strong> is not writable') . ', <em>(chmod = ' . substr(decoct(fileperms(FRONTEND_PATH . '../data/config.php')), 1) . ')</em> ' . __('Changes can\'t be saved.'));
     }
     return $Fieldset;
 }
 /**
  * Init fieldset to remove data series
  */
 protected function initFieldsetToRemoveDataSeries()
 {
     $Fields = $this->fieldOptionsForDataSeriesToRemove();
     if (!empty($Fields)) {
         $Fieldset = new FormularFieldset(__('Remove data series'));
         $Fieldset->addInfo(__('You may want to remove a data series if a sensor, e.g. your heart rate strap, produced unusable data.'));
         $Fieldset->addWarning(__('Attention: This operation cannot be undone.'));
         $Fieldset->setCollapsed();
         foreach ($Fields as $field) {
             $Fieldset->addField($field);
         }
         $Fieldset->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W100_CHECKBOX);
         $this->addFieldset($Fieldset);
     }
 }
Beispiel #9
0
 /**
  * Get fieldset for tools
  * @return \FormularFieldset
  */
 private function getToolsFieldset()
 {
     $result = '';
     if (isset($_POST['hash']) && $this->isLoggedIn && $_POST['job'] == 'tools') {
         ob_start();
         include FRONTEND_PATH . 'plugin/cli.pluginmap.php';
         $result = ob_get_contents();
         ob_end_clean();
     }
     $Fieldset = new FormularFieldset(__('Tools'));
     $Fieldset->addField(new FormularCheckbox('read_plugins', __('Look for new plugins')));
     $Fieldset->addField(new FormularSubmit(__('Go'), ''));
     $Fieldset->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W100);
     if (!empty($result)) {
         $Fieldset->addOkay($result);
     }
     if (!is_writable(FRONTEND_PATH . 'plugin/pluginmap.php')) {
         $Fieldset->addError(__('<strong>/inc/plugin/pluginmap.php</strong> is not writable') . ', <em>(chmod = ' . substr(decoct(fileperms(FRONTEND_PATH . 'plugin/pluginmap.php')), 1) . ')</em> ' . __('These tools will not work.'));
     }
     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();
 }
 /**
  * Get fieldset: values
  * @return \FormularFieldset
  */
 protected function getFieldsetForValues()
 {
     $Fieldset = new FormularFieldset(__('Configuration'));
     if ($this->Plugin->Configuration()->isEmpty()) {
         $Fieldset->addInfo(__('There are no settings.'));
     } else {
         foreach ($this->Plugin->Configuration()->objects() as $Value) {
             $Fieldset->addField($Value->getFormField());
         }
         $Fieldset->addField(new FormularSubmit(__('Save'), ''));
     }
     return $Fieldset;
 }
Beispiel #12
0
 /**
  * Get fieldset
  * @return FormularFieldset
  * @codeCoverageIgnore
  */
 public function getFieldset()
 {
     $Fieldset = new FormularFieldset(__('Laps'));
     $Fieldset->addField(new TrainingInputSplits());
     $Fieldset->addCSSclass(TrainingFormular::$ONLY_DISTANCES_CLASS);
     if ($this->areEmpty()) {
         $Fieldset->setCollapsed();
     }
     return $Fieldset;
 }
 /**
  * Set all fieldsets and fields
  */
 public function setFieldsetsAndFields()
 {
     $Data = AccountHandler::getDataForId(SessionAccountHandler::getId());
     FormularInput::setStandardSize(FormularInput::$SIZE_MIDDLE);
     $UsernameField = new FormularInput('name', __('Username'), $Data['username']);
     $UsernameField->setDisabled();
     $MailField = new FormularInput('name', __('Email address'), $Data['mail']);
     $MailField->setDisabled();
     $NameField = new FormularInput('name', __('Name'), $Data['name']);
     $LanguageField = new FormularSelectBox('language', __('Language'), $Data['language']);
     foreach (Language::availableLanguages() as $klang => $lang) {
         $LanguageField->addOption($klang, $lang[0]);
     }
     $SinceField = new FormularInput('name', __('Registered since'), date('d.m.Y H:i', $Data['registerdate']));
     $SinceField->setDisabled();
     $LastLoginField = new FormularInput('name', __('Last Login'), date('d.m.Y H:i', $Data['lastlogin']));
     $LastLoginField->setDisabled();
     $Account = new FormularFieldset(__('Your account'));
     $Account->addField($UsernameField);
     $Account->addField($MailField);
     $Account->addField($NameField);
     $Account->addField($LanguageField);
     $Account->addField($SinceField);
     $Account->addField($LastLoginField);
     $AllowMailsField = new FormularSelectBox('allow_mails', __('Email me'), $Data['allow_mails']);
     $AllowMailsField->addOption('1', __('Yes'));
     $AllowMailsField->addOption('0', __('No'));
     $Notifications = new FormularFieldset(__('Notifications'));
     $Notifications->addInfo(__('At irregular intervals we are sending mails to you. We will never send you spam or advertisement.'));
     $Notifications->addField($AllowMailsField);
     $Password = new FormularFieldset(__('Change your password'));
     if (empty($_POST['old_pw']) && empty($_POST['new_pw']) && empty($_POST['new_pw_repeat'])) {
         $Password->setCollapsed();
     } else {
         // Don't show passwords as 'value="..."'
         $_POST['old_pw'] = '';
         $_POST['new_pw'] = '';
         $_POST['new_pw_repeat'] = '';
     }
     $Password->addField(new FormularInputPassword('old_pw', __('Old password')));
     $Password->addField(new FormularInputPassword('new_pw', __('New password')));
     $Password->addField(new FormularInputPassword('new_pw_repeat', __('Repeat new password')));
     $Backup = new FormularFieldset(__('Backup your data'));
     $Backup->setCollapsed();
     $Factory = new PluginFactory();
     if ($Factory->isInstalled('RunalyzePluginTool_DbBackup')) {
         $Plugin = $Factory->newInstance('RunalyzePluginTool_DbBackup');
         $Backup->addInfo(__('Please use the plugin') . ' \'<strong>' . $Plugin->getWindowLink() . '</strong>\'.');
     } else {
         $Backup->addInfo(__('The backup of all your data is not manually possible yet.<br>' . 'In important individual cases write us an e-mail to mail@runalyze.de and and we will take care of it right away!'));
     }
     $DeleteLink = Ajax::window('<a href="call/window.delete.php"><strong>' . __('Delete your account') . ' &raquo;</strong></a>') . '<br><br>' . __('You\'ll receive an email with a link to confirm the deletion.<br>' . 'The deletion is permanent and cannot be reversed. ' . 'Therefore, you should backup your data.');
     $Delete = new FormularFieldset(__('Delete your account'));
     $Delete->setCollapsed();
     $Delete->addWarning($DeleteLink);
     $this->Formular->addFieldset($Account);
     $this->Formular->addFieldset($Notifications);
     $this->Formular->addFieldset($Password);
     $this->Formular->addFieldset($Backup);
     $this->Formular->addFieldset($Delete);
     $this->Formular->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W100);
 }
<div class="w50" id="login-window">
<?php 
FormularInput::setStandardSize(FormularInput::$SIZE_MIDDLE);
$Fieldset = new FormularFieldset(__('Administration'));
$Fieldset->addField(new FormularInput('user', __('Account'), 'admin'));
$Fieldset->addField(new FormularInputPassword('password', __('Password')));
$Fieldset->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W100);
$Formular = new Formular();
$Formular->setId('admin-login');
$Formular->addFieldset($Fieldset);
$Formular->addSubmitButton(__('Login'));
$Formular->setSubmitButtonsCentered();
$Formular->display();
?>
</div>