/** * Display the content * @see PluginPanel::displayContent() */ protected function displayContent() { $this->initData(); $MultiEditor = new MultiEditor($this->IDs); $MultiEditor->display(); echo Ajax::wrapJS('$("#ajax").addClass("small-window");'); }
<?php echo Ajax::wrapJS(' function resizeMap() { var $m = $(".map"), w = $(window).innerHeight(), d = $("body").outerHeight(); $m.height(w - d + $m.height() - 20); } $(document).ready(function(){ $(window).resize(function() { resizeMap(); }); resizeMap(); }); ');
/** * Get code for * @param string $PluginType * @return string */ private function getCodeFor($PluginType) { $Factory = new PluginFactory(); $Plugins = $Factory->completeData($PluginType); usort($Plugins, $this->pluginOrderFunction()); if (empty($Plugins)) { return HTML::info(__('No plugins available.')); } $Code = ' <table class="zebra-style fullwidth more-padding"> <thead> <tr class="top b"> <th colspan="3">' . PluginType::readableString($PluginType) . '</th> <th>' . __('Mode') . '</th> <th>' . __('Order') . '</th> <th></th> </tr> </thead> <tbody>'; foreach ($Plugins as $pos => $Data) { $Plugin = $Factory->newInstance($Data['key']); if ($Plugin === false) { $Code .= ' <tr class="unimportant"> <td>' . PluginInstaller::uninstallLink($Plugin->key()) . '</td> <td class="b">' . $Plugin->key() . '</td> <td colspan="4">' . __('The plugin cannot be found.') . '</td> </tr>'; } else { $Code .= ' <tr id="' . $Plugin->id() . '_tr" class="a' . ($Plugin->isInActive() ? ' unimportant' : '') . '"> <td>' . $Plugin->getConfigLink() . '</td> <td class="b">' . $Plugin->name() . '</td> <td>' . $Plugin->description() . '</td> <td><select name="plugin_modus_' . $Plugin->id() . '"> <option value="' . Plugin::ACTIVE . '"' . HTML::Selected($Plugin->isActive()) . '>' . __('enabled') . '</option> <option value="' . Plugin::ACTIVE_VARIOUS . '"' . HTML::Selected($Plugin->isHidden()) . '>' . __('hidden*') . '</option> <option value="' . Plugin::ACTIVE_NOT . '"' . HTML::Selected($Plugin->isInActive()) . '>' . __('not enabled') . '</option> </select></td> <td style="white-space:nowrap;"> <input class="plugin-position" type="text" name="plugin_order_' . $Plugin->id() . '" size="3" value="' . ($pos + 1) . '"> <span class="link" onclick="pluginMove(' . $Plugin->id() . ', \'up\')">' . Icon::$UP . '</span> <span class="link" onclick="pluginMove(' . $Plugin->id() . ', \'down\')">' . Icon::$DOWN . '</span> </td> <td>' . PluginInstaller::uninstallLink($Plugin->key()) . '</td> </tr>'; } } $Code .= ' </tbody> </table>'; $Code .= Ajax::wrapJS(' function pluginMove(id, way) { var pos = parseInt($("input[name=\'plugin_order_"+id+"\']").val()), tr = $("#"+id+"_tr"); if (way == "up" && pos > 1) { $("#"+id+"_tr .plugin-position").val(pos-1); tr.prev().find(".plugin-position").val(pos); tr.prev().toggleClass("swapped"); tr.prev().before(tr); } else if (way == "down" && tr.next().find(".plugin-position").val() > 0) { $("#"+id+"_tr .plugin-position").val(pos+1); tr.next().find(".plugin-position").val(pos); tr.next().toggleClass("swapped"); tr.next().after(tr); } tr.toggleClass("swapped"); } '); switch ($PluginType) { case 'panel': $Code .= HTML::info(__('* Hidden plugins only show their headings.')); break; case 'stat': $Code .= HTML::info(__('* Hidden plugins are grouped as \'Miscellaneous\'.')); break; case 'tool': default: $Code .= ''; } return $Code; }
/** * Send results to Multi Editor */ protected function sendResultsToMultiEditor() { $IDs = array(); foreach ($this->Trainings as $data) { $IDs[] = $data['id']; } $_POST['ids'] = implode(',', $IDs); $Factory = new PluginFactory(); $MultiEditor = $Factory->newInstance('RunalyzePluginTool_MultiEditor'); if ($MultiEditor) { $MultiEditor->display(); } else { echo HTML::error(__('The multi editor could not be located.')); } echo Ajax::wrapJS('$("#search").remove();$("#ajax").removeClass("big-window");'); }
/** * Output JavaScript * @param boolean $removeOldPlot */ public function outputJavaScript($removeOldPlot = false) { if ($removeOldPlot) { echo Ajax::wrapJS('RunalyzePlot.remove("' . $this->cssID . '");'); } $this->convertData(); $bindedCode = strlen($this->ErrorString) > 0 ? $this->getJSForError() : $this->getMainJS(); echo Ajax::wrapJS('RunalyzePlot.preparePlot("' . $this->cssID . '","' . $this->width . '","' . $this->height . '",function(){' . $bindedCode . '});'); }
/** * Display editor * * This function will just load the standard editor in the overlay */ protected function displayEditor() { echo Ajax::wrapJS('Runalyze.Overlay.load(\'' . Linker::EDITOR_URL . '?mode=multi&id=' . self::$IDs[0] . '\');'); }
/** * Display after submit */ protected function displayAfterSubmit() { if ($this->submitMode == StandardFormular::$SUBMIT_MODE_CREATE) { $this->displayHeader(); echo HTML::okay(__('The activity has been successfully created.')); echo Ajax::closeOverlay(); if (Configuration::ActivityForm()->showActivity()) { echo Ajax::wrapJS('Runalyze.Training.load(' . $this->dataObject->id() . ');'); } } else { if (Request::param('mode') == 'multi') { echo Ajax::wrapJS('Runalyze.goToNextMultiEditor();'); } else { parent::displayAfterSubmit(); } } }
</td> <?php } ?> <?php } ?> </tr> <?php } ?> </tbody> </table> <?php echo Ajax::wrapJS('$("#jd-tables-prognosis td.b").each(function(){ if ($(this).text() == \'' . round(Configuration::Data()->vdot()) . '\') $(this).parent().addClass("highlight"); });'); ?> <p class="info"> <?php _e('This table is computed by some formulas, derived from the tables in Jack Daniels\' Running formula.'); ?> <?php _e('These values do not fit the original table one hundred percent.'); ?> </p> <p class="info"> <?php _e('This table does <strong>not</strong> use a correction based on your current basic endurance.'); ?>
/** * @return string */ protected function getJS() { return Ajax::wrapJS(' function datasetMove(id, way) { var pos = parseInt($("input[name=\'"+id+"_position\']").val()), tr = $("#"+id+"_tr"); if (way == "up" && pos > 1) { $("#"+id+"_tr .dataset-position").val(pos-1); tr.prev().find(".dataset-position").val(pos); tr.prev().toggleClass("swapped"); tr.prev().before(tr); } else if (way == "down" && tr.next().find(".dataset-position").val() > 0) { $("#"+id+"_tr .dataset-position").val(pos+1); tr.next().find(".dataset-position").val(pos); tr.next().toggleClass("swapped"); tr.next().after(tr); } tr.toggleClass("swapped"); } '); }
use Runalyze\View\Activity\Linker; use Runalyze\Data\Elevation\Correction\NoValidStrategyException; $Frontend = new Frontend(); $Factory = Context::Factory(); $Activity = $Factory->activity(Request::sendId()); $ActivityOld = clone $Activity; $Route = $Factory->route($Activity->get(Activity\Object::ROUTEID)); $RouteOld = clone $Route; try { $Calculator = new Calculator($Route); $result = $Calculator->tryToCorrectElevation(Request::param('strategy')); } catch (NoValidStrategyException $Exception) { $result = false; } if ($result) { $Calculator->calculateElevation(); $Activity->set(Activity\Object::ELEVATION, $Route->elevation()); $UpdaterRoute = new Route\Updater(DB::getInstance(), $Route, $RouteOld); $UpdaterRoute->setAccountID(SessionAccountHandler::getId()); $UpdaterRoute->update(); $UpdaterActivity = new Activity\Updater(DB::getInstance(), $Activity, $ActivityOld); $UpdaterActivity->setAccountID(SessionAccountHandler::getId()); $UpdaterActivity->update(); echo __('Elevation data has been corrected.'); Ajax::setReloadFlag(Ajax::$RELOAD_DATABROWSER_AND_TRAINING); echo Ajax::getReloadCommand(); echo Ajax::wrapJS('if($("#ajax").is(":visible") && $("#training").length)Runalyze.Overlay.load(\'' . Linker::EDITOR_URL . '?id=' . Request::sendId() . '\')'); echo Ajax::wrapJS('if($("#ajax").is(":visible") && $("#gps-results").length)Runalyze.Overlay.load(\'' . Linker::ELEVATION_INFO_URL . '?id=' . Request::sendId() . '\')'); } else { echo __('Elevation data could not be retrieved.'); }
/** * Parse all post values */ public function parsePostData() { if ($_POST['name'] != SessionAccountHandler::getName()) { DB::getInstance()->update('account', SessionAccountHandler::getId(), 'name', $_POST['name']); } if ($_POST['allow_mails'] != SessionAccountHandler::getAllowMails()) { DB::getInstance()->update('account', SessionAccountHandler::getId(), 'allow_mails', $_POST['allow_mails']); } if ($_POST['language'] != SessionAccountHandler::getLanguage()) { DB::getInstance()->update('account', SessionAccountHandler::getId(), 'language', $_POST['language']); Language::setLanguage($_POST['language']); echo Ajax::wrapJS('document.cookie = "lang=" + encodeURIComponent("' . addslashes($_POST['language']) . '");'); Ajax::setReloadFlag(Ajax::$RELOAD_PAGE); } if ($_POST['new_pw'] != '') { $this->tryToChangePassword(); } }
/** * Get code * @return string */ private function getCode() { $Code = ' <table class="c fullwidth zebra-style" id="conf-tab-dataset"> <thead> <tr> <th> </th> <th>' . Ajax::tooltip(__('Display'), __('The information will be shown directly in the row.')) . '</th> <th colspan="2">' . Ajax::tooltip(__('Summary'), __('The value will be summarized for the sport.')) . '</th> <th>' . Ajax::tooltip(__('Order'), __('Indicates the order of appearance.')) . '</th> <th>' . Ajax::tooltip(__('CSS-Class'), __('\'c\': centered<br>\'l\': left-aligned<br>\'small\': small<br>\'b\': bold')) . '</th> <th>' . Ajax::tooltip(__('CSS-Style'), __('any CSS-Code')) . '</th> <th>' . __('Example') . '</th> </tr> </thead> <tbody>'; $Labels = new DatasetLabels(); $DatasetObject = new Dataset(); $DatasetObject->setActivityData($this->getExampleTraining()); $Dataset = DB::getInstance()->query('SELECT *, (`position` = 0) as `hidden` FROM `' . PREFIX . 'dataset` WHERE accountid = ' . SessionAccountHandler::getId() . ' ORDER BY (`position` > 0) DESC, `position` ASC')->fetchAll(); foreach ($Dataset as $pos => $Data) { $disabled = $Data['modus'] == 3 ? ' disabled' : ''; $checked_2 = $Data['modus'] >= 2 ? ' checked' : ''; $checked = $Data['summary'] == 1 ? ' checked' : ''; $SummarySign = ''; switch ($Data['summary_mode']) { case 'YES': case 'NO': $checked .= ' disabled'; break; case 'AVG': $SummarySign = 'Ø'; break; case 'SUM': $SummarySign = '∑'; break; case 'MAX': $SummarySign = 'max'; break; } $Example = $DatasetObject->getDataset($Data['name']); $Code .= ' <tr class="r" id="' . $Data['id'] . '_tr"> <td class="l b">' . $Labels->get($Data['name']) . '</td> <td class="c"> <input type="hidden" name="' . $Data['id'] . '_modus_3" value="' . $Data['modus'] . '"> <input type="checkbox" name="' . $Data['id'] . '_modus"' . $checked_2 . $disabled . '> </td> <td class="c"><input type="checkbox" name="' . $Data['id'] . '_summary"' . $checked . '></td> <td class="c small">' . $SummarySign . '</td> <td class="c"> <input class="dataset-position" type="text" name="' . $Data['id'] . '_position" value="' . ($pos + 1) . '" size="2"> <span class="link" onclick="datasetMove(' . $Data['id'] . ', \'up\')">' . Icon::$UP . '</span> <span class="link" onclick="datasetMove(' . $Data['id'] . ', \'down\')">' . Icon::$DOWN . '</span> </td> <td class="c"><input type="text" name="' . $Data['id'] . '_class" value="' . $Data['class'] . '" size="7"></td> <td class="c"><input type="text" name="' . $Data['id'] . '_style" value="' . $Data['style'] . '" size="15"></td> <td class="' . $Data['class'] . '" style="' . $Data['style'] . '">' . $Example . '</td> </tr>'; } $Code .= ' </tbody> </table>'; $Code .= Ajax::wrapJS(' function datasetMove(id, way) { var pos = parseInt($("input[name=\'"+id+"_position\']").val()), tr = $("#"+id+"_tr"); if (way == "up" && pos > 1) { $("#"+id+"_tr .dataset-position").val(pos-1); tr.prev().find(".dataset-position").val(pos); tr.prev().toggleClass("swapped"); tr.prev().before(tr); } else if (way == "down" && tr.next().find(".dataset-position").val() > 0) { $("#"+id+"_tr .dataset-position").val(pos+1); tr.next().find(".dataset-position").val(pos); tr.next().toggleClass("swapped"); tr.next().after(tr); } tr.toggleClass("swapped"); } '); return $Code; }
* Call: call/call.Training.elevationCorrection.php?id= */ require '../inc/class.Frontend.php'; use Runalyze\Context; use Runalyze\Model\Activity; use Runalyze\Model\Route; use Runalyze\Calculation\Route\Calculator; use Runalyze\View\Activity\Linker; $Frontend = new Frontend(); $Factory = Context::Factory(); $Activity = $Factory->activity(Request::sendId()); $ActivityOld = clone $Activity; $Route = $Factory->route($Activity->get(Activity\Object::ROUTEID)); $RouteOld = clone $Route; $Calculator = new Calculator($Route); if ($Calculator->tryToCorrectElevation()) { $Calculator->calculateElevation(); $Activity->set(Activity\Object::ELEVATION, $Route->elevation()); $UpdaterRoute = new Route\Updater(DB::getInstance(), $Route, $RouteOld); $UpdaterRoute->setAccountID(SessionAccountHandler::getId()); $UpdaterRoute->update(); $UpdaterActivity = new Activity\Updater(DB::getInstance(), $Activity, $ActivityOld); $UpdaterActivity->setAccountID(SessionAccountHandler::getId()); $UpdaterActivity->update(); echo __('Elevation data has been corrected.'); Ajax::setReloadFlag(Ajax::$RELOAD_DATABROWSER_AND_TRAINING); echo Ajax::getReloadCommand(); echo Ajax::wrapJS('if($("#ajax").is(":visible") && $("#training").length)Runalyze.Overlay.load(\'' . Linker::EDITOR_URL . '?id=' . Request::sendId() . '\')'); } else { echo __('Elevation data could not be retrieved.'); }
$Factory = Context::Factory(); $Activity = $Factory->activity(Request::sendId()); $ActivityOld = clone $Activity; $Route = $Factory->route($Activity->get(Activity\Entity::ROUTEID)); $RouteOld = clone $Route; try { $Calculator = new Calculator($Route); $result = $Calculator->tryToCorrectElevation(Request::param('strategy')); } catch (NoValidStrategyException $Exception) { $result = false; } if ($result) { $Calculator->calculateElevation(); $Activity->set(Activity\Entity::ELEVATION, $Route->elevation()); $UpdaterRoute = new Route\Updater(DB::getInstance(), $Route, $RouteOld); $UpdaterRoute->setAccountID(SessionAccountHandler::getId()); $UpdaterRoute->update(); $UpdaterActivity = new Activity\Updater(DB::getInstance(), $Activity, $ActivityOld); $UpdaterActivity->setAccountID(SessionAccountHandler::getId()); $UpdaterActivity->update(); if (Request::param('strategy') == 'none') { echo __('Corrected elevation data has been removed.'); } else { echo __('Elevation data has been corrected.'); } Ajax::setReloadFlag(Ajax::$RELOAD_DATABROWSER_AND_TRAINING); echo Ajax::getReloadCommand(); echo Ajax::wrapJS('if ($("#ajax").is(":visible") && $("#training").length) {' . 'Runalyze.Overlay.load(\'' . Linker::EDITOR_URL . '?id=' . Request::sendId() . '\');' . '} else if ($("#ajax").is(":visible") && $("#gps-results").length) {' . 'Runalyze.Overlay.load(\'' . Linker::ELEVATION_INFO_URL . '?id=' . Request::sendId() . '\');' . '}'); } else { echo __('Elevation data could not be retrieved.'); }