コード例 #1
0
 /**
  * Init fieldset for input data
  */
 protected function initFieldsetForInputData()
 {
     $this->FieldsetInput = new FormularFieldset(__('Input'));
     foreach ($this->InfoLines as $InfoMessage) {
         $this->FieldsetInput->addInfo($InfoMessage);
     }
     $FieldModel = new FormularSelectBox('model', __('Model'));
     $FieldModel->addOption('jack-daniels', 'Jack Daniels (VDOT)');
     $FieldModel->addOption('robert-bock', 'Robert Bock (CPP)');
     $FieldModel->addOption('herbert-steffny', 'Herbert Steffny');
     $FieldModel->addOption('david-cameron', 'David Cameron');
     $FieldModel->addAttribute('onchange', '$(\'#prognosis-calculator .only-\'+$(this).val()).closest(\'div\').show();$(\'#prognosis-calculator .hide-on-model-change:not(.only-\'+$(this).val()+\')\').closest(\'div\').hide();');
     $FieldModel->setLayout(FormularFieldset::$LAYOUT_FIELD_W50_AS_W100);
     $FieldDistances = new FormularInput('distances', __('Distances'));
     $FieldDistances->setLayout(FormularFieldset::$LAYOUT_FIELD_W50_AS_W100);
     $FieldDistances->setSize(FormularInput::$SIZE_FULL_INLINE);
     $this->FieldsetInput->addField($FieldModel);
     $this->FieldsetInput->addField($FieldDistances);
     $this->addFieldsForJackDaniels();
     $this->addFieldsForBockAndSteffny();
 }
コード例 #2
0
    /**
     * Display export form 
     */
    protected function displayExport()
    {
        $Select = new FormularSelectBox('export-type', __('File format'));
        $Select->addOption('json', __('Portable backup') . ' (*.json.gz)');
        $Select->addOption('sql', __('Database backup') . ' (*.sql.gz)');
        $Fieldset = new FormularFieldset(__('Export your data'));
        $Fieldset->addField($Select);
        $Fieldset->addField(new FormularSubmit(__('Create file'), ''));
        $Fieldset->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W50);
        $Fieldset->addInfo('<strong>' . __('JSON-format') . ' (*.json.gz)</strong><br>
			<small>' . __('Portable backup of your configuration and data -' . 'This file can be imported into any other installation, using this plugin.<br />' . 'This way you can transfer your data from to local to an online installation and back.') . '
			</small>');
        $Fieldset->addInfo('<strong>' . __('SQL-format') . ' (*.sql.gz)</strong><br>
			<small>' . __('Backup of the complete database -' . 'This file can be imported manually with e.g. PHPMyAdmin into any database.<br />' . 'This is recommended to create a backup copy or to import your data into a new installation.') . '
			</small>');
        if ($this->importIsOnProgress) {
            $Fieldset->setCollapsed();
        }
        $Formular = new Formular($_SERVER['SCRIPT_NAME'] . '?id=' . $this->id());
        $Formular->setId('database-backup');
        $Formular->addCSSclass('ajax');
        $Formular->addCSSclass('no-automatic-reload');
        $Formular->addFieldset($Fieldset);
        $Formular->addHiddenValue('backup', 'true');
        $Formular->display();
    }
コード例 #3
0
 /**
  * Display fieldset: Equipment
  */
 protected function initEquipmentFieldset()
 {
     $isCreateForm = $this->submitMode == StandardFormular::$SUBMIT_MODE_CREATE;
     $Factory = new Factory(SessionAccountHandler::getId());
     $AllEquipment = $Factory->allEquipments();
     $RelatedEquipment = $isCreateForm ? array() : $Factory->equipmentForActivity($this->dataObject->id(), true);
     $Fieldset = new FormularFieldset(__('Equipment'));
     $Fieldset->addField(new FormularInputHidden('equipment_old', '', implode(',', $RelatedEquipment)));
     if (isset($_POST['equipment'])) {
         $RelatedEquipment = self::readEquipmentFromPost();
     }
     foreach ($Factory->allEquipmentTypes() as $EquipmentType) {
         $options = array();
         $values = array();
         $attributes = array();
         foreach ($AllEquipment as $Equipment) {
             if ($Equipment->typeid() == $EquipmentType->id() && (!$isCreateForm || $Equipment->isInUse())) {
                 $options[$Equipment->id()] = $Equipment->name();
                 $attributes[$Equipment->id()] = array('data-start' => $Equipment->startDate(), 'data-end' => $Equipment->endDate());
                 if (in_array($Equipment->id(), $RelatedEquipment)) {
                     $values[$Equipment->id()] = 'on';
                 }
             }
         }
         if (empty($options)) {
             continue;
         }
         if ($EquipmentType->allowsMultipleValues()) {
             $Field = new FormularCheckboxes('equipment[' . $EquipmentType->id() . ']', $EquipmentType->name(), $values);
             foreach ($options as $key => $label) {
                 $Field->addCheckbox($key, $label, $attributes[$key]);
             }
         } else {
             $selected = !empty($values) ? array_keys($values) : array(0);
             $Field = new FormularSelectBox('equipment[' . $EquipmentType->id() . ']', $EquipmentType->name(), $selected[0]);
             $Field->addOption(0, '');
             foreach ($options as $key => $label) {
                 $Field->addOption($key, $label, $attributes[$key]);
             }
         }
         $SportClasses = 'only-specific-sports';
         foreach ($Factory->sportForEquipmentType($EquipmentType->id(), true) as $id) {
             $SportClasses .= ' only-sport-' . $id;
         }
         $Field->setLayout(FormularFieldset::$LAYOUT_FIELD_W100_IN_W50);
         $Field->addLayoutClass($SportClasses . ' depends-on-date');
         $Field->addAttribute('class', FormularInput::$SIZE_FULL_INLINE);
         $Fieldset->addField($Field);
     }
     $this->addFieldset($Fieldset);
 }
コード例 #4
0
 /**
  * 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);
 }