Пример #1
0
 /**
  * Construct new input field for: typeid
  * @param string $name
  * @param string $label
  * @param string $value optional, default: loading from $_POST
  */
 public function __construct($name, $label, $value = '')
 {
     parent::__construct($name, $label, $value);
     $this->addOption(0, '---- ' . __('select type'), array('data-sport' => 'all'));
     foreach (TypeFactory::AllTypes() as $id => $data) {
         $this->addOption($id, $data['name'], array('data-sport' => $data['sportid']));
     }
 }
 /**
  * Construct new input field for: weather
  * @param string $name
  * @param string $label
  * @param string $value optional, default: loading from $_POST
  */
 public function __construct($name, $label, $value = '')
 {
     parent::__construct($name, $label, $value);
     $Condition = new Condition(0);
     foreach (Condition::completeList() as $id) {
         $Condition->set($id);
         $this->addOption($id, $Condition->string());
     }
 }
 /**
  * Construct new input field for: typeid
  * @param string $name
  * @param string $label
  * @param string $value optional, default: loading from $_POST
  */
 public function __construct($name, $label, $value = '')
 {
     parent::__construct($name, $label, $value);
     $this->addLayoutClass(TrainingFormular::$ONLY_TYPES_CLASS);
     $this->addOption(0, '---- ' . __('select type'), array('data-sport' => 'all'));
     foreach (TypeFactory::AllTypes() as $id => $data) {
         $this->addOption($id, $data['name'], array('data-sport' => $data['sportid']));
     }
 }
Пример #4
0
 /**
  * Create a field
  * @param \Runalyze\Configuration\Handle $Handle
  * @param string $label
  * @return \FormularField
  */
 private function createFieldFor(Handle $Handle, $label)
 {
     $Parameter = $Handle->object();
     $Class = 'FormularInput';
     if ($Parameter instanceof SelectRow) {
         $Field = new \FormularSelectDb($Handle->key(), $label, $Handle->value());
         $Field->loadOptionsFrom($Parameter->table(), $Parameter->column());
         return $Field;
     } elseif ($Parameter instanceof Select) {
         $Field = new \FormularSelectBox($Handle->key(), $label, $Handle->value());
         $Field->setOptions($Parameter->options());
         return $Field;
     } elseif ($Parameter instanceof Boolean) {
         $Field = new \FormularCheckbox($Handle->key(), $label, $Handle->value());
         $Field->addHiddenSentValue();
         return $Field;
     }
     return new $Class($Handle->key(), $label, $Handle->object()->valueAsString());
 }
 /**
  * Display field
  * 
  * This method overwrites parent display method to include some hidden values
  */
 public function display()
 {
     parent::display();
     if (isset($_POST['s']) && isset($_POST['distance'])) {
         echo HTML::hiddenInput('s_old', $_POST['s']);
         echo HTML::hiddenInput('dist_old', $_POST['distance']);
         if ($this->value > 0) {
             echo HTML::hiddenInput('shoeid_old', $this->value);
         }
     }
 }
 /**
  * Construct new input field for: sportid
  * @param string $name
  * @param string $label
  * @param string $value optional, default: loading from $_POST
  */
 public function __construct($name, $label, $value = '')
 {
     parent::__construct($name, $label, $value);
     foreach (SportFactory::AllSports() as $id => $sport) {
         $attributes = array();
         $attributes['data-kcal'] = $sport['kcal'];
         if ($sport['id'] == Configuration::General()->runningSport()) {
             $attributes['data-running'] = 'true';
         }
         if ($sport['outside'] == 1) {
             $attributes['data-outside'] = 'true';
         }
         if ($sport['distances'] == 1) {
             $attributes['data-distances'] = 'true';
         }
         if ($sport['power'] == 1) {
             $attributes['data-power'] = 'true';
         }
         $this->addOption($id, $sport['name'], $attributes);
     }
 }
Пример #7
0
 /**
  * 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);
 }
 /**
  * Get input for active
  * @param bool $active
  * @return FormularSelectBox 
  */
 protected function getActiveInputCode($active)
 {
     $FieldActive = new FormularSelectBox('splits[active][]', '', (int) $active);
     $FieldActive->setOptions(array(__('Resting'), __('Active')));
     $FieldActive->setLayout(FormularFieldset::$LAYOUT_FIELD_INLINE);
     return $FieldActive->getCode();
 }
 /**
  * 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();
 }
Пример #10
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);
 }
    /**
     * 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();
    }
Пример #12
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);
 }
 /**
  * Display row for config form
  * @return FormularField
  */
 public function getFormField()
 {
     $Field = new FormularSelectBox($this->Key, $this->formLabel(), $this->valueAsString());
     $Field->setOptions($this->Options);
     return $Field;
 }