Esempio n. 1
0
 /**
  * Prepare for display
  */
 protected function prepareForDisplayInSublcass()
 {
     parent::prepareForDisplayInSublcass();
     $this->initTagFieldset();
     $this->addAdditionalHiddenFields();
     $this->initEquipmentFieldset();
     if ($this->submitMode == StandardFormular::$SUBMIT_MODE_EDIT) {
         $this->addOldObjectData();
         $this->initElevationCorrectionFieldset();
         $this->initFieldsetToRemoveDataSeries();
         $this->initDeleteFieldset();
         if (Request::param('mode') == 'multi') {
             $this->addHiddenValue('mode', 'multi');
             $this->submitButtons['submit'] = __('Save and continue');
         }
     } else {
         if (is_numeric($this->dataObject->get('activity_id'))) {
             $isDuplicate = (new DuplicateFinder(DB::getInstance(), SessionAccountHandler::getId()))->checkForDuplicate($this->dataObject->get('activity_id'));
             if ($isDuplicate) {
                 echo HTML::warning(__('It seems that you already have imported this activity'));
             }
         }
     }
     $this->appendJavaScript();
 }
 /**
  * Display long description 
  */
 protected function displayLongDescription()
 {
     echo HTML::p(__('This plugin lists all your races. It shows you a summary of all your races and ' . 'your personal bests (over all distances with at least two results).'));
     echo HTML::p(__('In addition, it plots the trend of your results over a specific distance.' . 'If you run a race just for fun, you can mark it as a \'fun race\' to ignore it in the plot.'));
     echo HTML::info(__('You can define the activity type for races in your configuration.'));
     echo HTML::warning(__('Make sure that your activities hold the correct distance.' . 'Only races with exactly 10.00 km will be considered as a race over 10 kilometers.'));
 }
    /**
     * Get fieldset block
     * @return string
     */
    private function getFieldsetBlock()
    {
        $String = '';
        foreach ($this->TrainingObjects as $i => $TrainingObject) {
            $activityIDs[] = $TrainingObject->getActivityId();
        }
        $duplicates = (new DuplicateFinder(DB::getInstance(), SessionAccountHandler::getId()))->checkForDuplicates($activityIDs);
        $countDuplicates = count(array_filter($duplicates));
        $String .= HTML::info(sprintf(__('Found %s activities.'), count($this->TrainingObjects)));
        if ($countDuplicates > 0) {
            $String .= HTML::warning(_n('Found <strong>one</strong> duplicate activity.', 'Found duplicate activities.', $countDuplicates));
        }
        $String .= '<table class="fullwidth multi-import-table zebra-style c" id="multi-import-table">';
        $String .= '<thead><tr><th>' . __('Import') . '</th><th>' . __('Date') . '</th><th>' . __('Duration') . '</th><th>' . __('Distance') . '</th><th colspan="4"></th></tr></thead>';
        $String .= '<tbody>';
        foreach ($this->TrainingObjects as $i => $TrainingObject) {
            $String .= '<tr>' . $this->getTableRowFor($TrainingObject, $i, $duplicates[$TrainingObject->getActivityId()]) . '</tr>';
        }
        $String .= '</tbody>';
        $String .= '</table>';
        $String .= Ajax::wrapJSforDocumentReady('
			$("#multi-import-table td").click(function(e){
				if ($(e.target).closest(\'input[type="checkbox"]\').length == 0)
					$(this).parent().find(\'input:checkbox\').attr(\'checked\', !$(this).parent().find(\'input:checkbox\').attr(\'checked\'));
			});
		');
        return $String;
    }
 /**
  * Add info link
  */
 protected function addInfoLink()
 {
     if (!Request::isOnSharedPage()) {
         $Linker = new Linker($this->Context->activity());
         $InfoLink = Ajax::window('<a href="' . $Linker->urlToElevationInfo() . '">' . __('More about elevation') . '</a>', 'normal');
         $this->Footer = HTML::info($InfoLink);
     } else {
         $this->Footer = '';
     }
     if ($this->Context->route()->hasCorrectedElevations()) {
         $this->Footer .= HTML::info(__('Elevation data were corrected.'));
     } elseif ($this->Context->route()->hasOriginalElevations() && Configuration::ActivityForm()->correctElevation()) {
         $this->Footer .= HTML::warning(__('Elevation data are not corrected.'));
     }
     // TODO: Add link to correct them now!
 }
 /**
  * Display long description 
  */
 protected function displayLongDescription()
 {
     echo HTML::p(__('This plugin allows you to edit multiple activities one after another.'));
     echo HTML::warning(__('At the moment it\'s not possible to edit multiple activities with only one form.'));
 }
 /**
  * Display the content
  * @see PluginStat::displayContent()
  */
 protected function displayContent()
 {
     $this->displayExtremeTrainings();
     $this->displayMonthTable();
     $this->displayClothesTable();
     if (!$this->Configuration()->value('for_weather') && !$this->Configuration()->value('for_clothes')) {
         echo HTML::warning(__('You have to activate some statistics in the plugin configuration.'));
     }
 }
    /**
     * 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();
    }
 /**
  * Display the content
  * @see PluginPanel::displayContent()
  */
 protected function displayContent()
 {
     $Factory = new Model\Factory(SessionAccountHandler::getId());
     $EquipmentType = $Factory->equipmentType((int) $this->Configuration()->value('type'));
     if ($EquipmentType->isEmpty()) {
         echo HTML::warning(__('Please choose an equipment type in the plugin configuration.'));
         return;
     }
     echo $this->getStyle();
     echo '<div id="equipment">';
     $inuse = true;
     $this->showListFor($EquipmentType, $inuse);
     echo '</div>';
     if (!$inuse) {
         echo Ajax::toggle('<a class="right" href="#equipment" name="equipment">' . __('Show unused equipment') . '</a>', 'hiddenequipment');
     }
     echo HTML::clearBreak();
 }
 /**
  * Finish result table
  */
 protected function finishResultTable()
 {
     $this->ResultTable .= '</tbody></table>';
     if ($_POST['model'] == 'robert-bock' && $this->PrognosisStrategies['robert-bock'] instanceof Prognosis\Bock) {
         $K = $this->PrognosisStrategies['robert-bock']->getK();
         $e = $this->PrognosisStrategies['robert-bock']->getE();
         $this->ResultTable .= HTML::info(sprintf(__('The results give the constants K = %f and e = %f.'), $K, $e)) . '<br>';
         if (!$this->PrognosisObject->isValid()) {
             $this->ResultTable .= HTML::warning(sprintf(__('K must be between %u and %u, e between %f and %f.'), Prognosis\Bock::K_LOWER_BOUND, Prognosis\Bock::K_UPPER_BOUND, Prognosis\Bock::E_LOWER_BOUND, Prognosis\Bock::E_UPPER_BOUND));
         }
     }
 }
 /**
  * Display the content
  * @see PluginPanel::displayContent()
  */
 protected function displayContent()
 {
     if ($this->Configuration()->value('use_old_design')) {
         $this->displayContentInOldDesign();
     } else {
         $this->displayContentInNewDesign();
     }
     if (!$this->Configuration()->value('use_weight') && !$this->Configuration()->value('use_pulse') && !$this->Configuration()->value('use_body_fat')) {
         echo HTML::warning(__('You have to specify which values to record. (see configuration)'));
     }
 }
Esempio n. 11
0
<?php

Form::macro('error', function ($name) {
    $errors = Session::get('errors');
    if ($errors) {
        $data = array('errors' => $errors, 'name' => $name);
        return View::make('modules.field-error')->with($data);
    }
});
Form::macro('errors', function ($message = null) {
    $errors = Session::get('errors');
    if ($errors) {
        return HTML::warning($message ?: trans('messages.formErrors'));
    }
});
HTML::macro('success', function ($content) {
    return HTML::message('success', $content);
});
HTML::macro('warning', function ($content) {
    return HTML::message('warning', $content);
});
HTML::macro('error', function ($content) {
    return HTML::message('error', $content);
});
HTML::macro('message', function ($type, $content) {
    $data = array('type' => $type, 'content' => $content);
    return View::make('modules/message')->with($data);
});
 /**
  * Display the content
  * @see PluginPanel::displayContent()
  */
 protected function displayContent()
 {
     $this->lookupPersonalBests();
     $this->prepareForPrognosis();
     foreach ($this->getDistances() as $km) {
         $this->showPrognosis($km);
     }
     if (!$this->Prognosis->isValid()) {
         echo HTML::warning(__('Prognoses can\'t be calculated.'));
     }
     if ($this->thereAreNotEnoughCompetitions()) {
         echo HTML::info(__('There are not enough results for good predictions.'));
     }
 }