/**
  * 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();
 }
 /**
  * Init for given objects
  */
 protected function initForObjects()
 {
     $Fieldset = new FormularFieldset(__('Choose activities'));
     $Fieldset->addBlock($this->getFieldsetBlock());
     $Fieldset->setHtmlCode($this->getConfigCode());
     $this->addFieldset($Fieldset);
     $this->addSubmitButton(__('Import selected activities'));
     $this->addHiddenValue('number-of-trainings', count($this->TrainingObjects));
 }
 /**
  * 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();
 }
Exemple #4
0
 /**
  * Get fieldset for files
  * @return \FormularFieldset
  */
 private function getFilesFieldset()
 {
     $Fieldset = new FormularFieldset(__('Unused files'));
     $Fieldset->addFileBlock($this->getBlockForFiles('../data/import/'));
     $Fieldset->addFileBlock($this->getBlockForFiles('../data/log/'));
     $Fieldset->addFileBlock($this->getBlockForFiles('../data/backup-tool/backup/'));
     $Fieldset->addFileBlock($this->getBlockForFiles('../data/backup-tool/import/'));
     $Fieldset->addBlock('<input type="submit" value="' . __('Clear directories') . '">');
     $Fieldset->setCollapsed();
     return $Fieldset;
 }
 /**
  * Init fieldset for results
  */
 protected function initFieldsetForResults()
 {
     $this->FieldsetResult = new FormularFieldset(__('Prognosis'));
     $this->FieldsetResult->addBlock($this->ResultTable);
 }
Exemple #6
0
 /**
  * Get fieldset for files
  * @return \FormularFieldset
  */
 private function getFilesFieldset()
 {
     $Fieldset = new FormularFieldset(__('Unused files'));
     $Fieldset->addFileBlock($this->getBlockForFiles('/import/files/'));
     $Fieldset->addFileBlock($this->getBlockForFiles('/export/files/'));
     $Fieldset->addFileBlock($this->getBlockForFiles('../log/'));
     $Fieldset->addFileBlock($this->getBlockForFiles('../plugin/RunalyzePluginTool_DbBackup/backup/'));
     $Fieldset->addFileBlock($this->getBlockForFiles('../plugin/RunalyzePluginTool_DbBackup/import/'));
     $Fieldset->addBlock('<input type="submit" value="' . __('Clear directories') . '">');
     $Fieldset->setCollapsed();
     return $Fieldset;
 }
    /**
     * Get fieldset for paces
     * @return \FormularFieldset
     */
    public function getFieldsetPaces()
    {
        $Table = '<table class="fullwidth zebra-style">
				<thead>
					<tr>
						<th>' . __('Name') . '</th>
						<th class="small">' . __('Pace') . '</th>
						<th class="small">' . __('Description') . '</th>
					</tr>
				</thead>
				<tbody>';
        $VDOT = new VDOT(Configuration::Data()->vdot());
        foreach ($this->getArrayForPaces() as $Pace) {
            $Table .= '<tr>
						<td class="b">' . $Pace['short'] . '</td>
						<td class=""><em>' . Duration::format($VDOT->paceAt($Pace['limit-low'] / 100)) . '</em>&nbsp;-&nbsp;<em>' . Duration::format($VDOT->paceAt($Pace['limit-high'] / 100)) . '</em>/km</td>
						<td class="">' . $Pace['description'] . '</td>
					</tr>';
        }
        $Table .= '
				</tbody>
			</table>';
        $Fieldset = new FormularFieldset(__('Training paces'));
        $Fieldset->addBlock($Table);
        $Fieldset->addInfo(__('These paces are based on Jack Daniels\' recommendation.'));
        return $Fieldset;
    }
    /**
     * Display uploader 
     */
    protected function displayImportUploader()
    {
        $JScode = '
			new qq.FineUploaderBasic({
				button: $("#file-upload")[0],
				request: {
					endpoint: \'' . $_SERVER['SCRIPT_NAME'] . '?hideHtmlHeader=true&id=' . $this->id() . '&json=true\'
				},
				callbacks: {
					onError: function(id, name, errorReason, xhr) {
						$("#upload-container").append(\'<p class="error appended-by-uploader">\'+errorReason+\'</p>\').removeClass("loading");
					},
					onSubmit: function(id, fileName) {
						$("#upload-container").addClass("loading");
					},
					onComplete: function(id, fileName, responseJSON) {
						$(".appended-by-uploader").remove();
						$("#pluginTool").loadDiv(\'' . $_SERVER['SCRIPT_NAME'] . '?id=' . $this->id() . '&file=\'+encodeURIComponent(fileName));

						if (!responseJSON.success) {
							if (responseJSON.error == "")
								responseJSON.error = \'An unknown error occured.\';
							$("#pluginTool").append(\'<p class="error appended-by-uploader">\'+fileName+\': \'+responseJSON.error+\'</p>\');
							$("#upload-container").removeClass("loading");
						}
					}
				}
			});';
        $Text = '<div id="upload-container" style="margin-bottom:5px;"><div class="c button" id="file-upload">' . __('Upload file') . '</div></div>';
        $Text .= Ajax::wrapJSasFunction($JScode);
        $Text .= HTML::info(__('Allowed file extension: *.json.gz'));
        $Text .= HTML::warning(__('All shared links will be invalid if you (re-)import activities and overwrite all existing activities!'));
        $Text .= HTML::warning(__('The file has to be created with the same version of Runalyze!<br>' . 'You won\'t be able to import a file from an older version.'));
        $Text .= HTML::warning(__('The importer will not change existing data for equipment, sport types or activity types.<br>' . 'You have to make these changes by hand or delete the existing data in advance.'));
        $Fieldset = new FormularFieldset(__('Import data'));
        $Fieldset->setCollapsed();
        $Fieldset->addBlock($Text);
        $Formular = new Formular();
        $Formular->setId('backup-import');
        $Formular->addFieldset($Fieldset);
        $Formular->display();
    }
    /**
     * Get fieldset for paces
     * @return \FormularFieldset
     */
    public function getFieldsetPaces()
    {
        $Table = '<table class="fullwidth zebra-style">
				<thead>
					<tr>
						<th>' . __('Name') . '</th>
						<th class="small">' . __('Pace') . '</th>
						<th class="small">' . __('Description') . '</th>
					</tr>
				</thead>
				<tbody>';
        $VDOT = new VDOT(Configuration::Data()->vdot());
        $PaceObject = new Runalyze\Activity\Pace(0, 1, SportFactory::getSpeedUnitFor(Configuration::General()->runningSport()));
        foreach ($this->getArrayForPaces() as $Pace) {
            $Table .= '<tr>
						<td class="b">' . $Pace['short'] . '</td>
						<td class=""><em>' . $PaceObject->setTime($VDOT->paceAt($Pace['limit-high'] / 100))->value() . '</em> - <em>' . $PaceObject->setTime($VDOT->paceAt($Pace['limit-low'] / 100))->value() . '</em>' . $PaceObject->appendix() . '</td>
						<td class="">' . $Pace['description'] . '</td>
					</tr>';
        }
        $Table .= '
				</tbody>
			</table>';
        $Fieldset = new FormularFieldset(__('Training paces'));
        $Fieldset->addBlock($Table);
        $Fieldset->addInfo(__('These paces are based on Jack Daniels\' recommendation.'));
        return $Fieldset;
    }