/** * 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 $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 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><input type="text" name="plugin_order_' . $Plugin->id() . '" size="3" value="' . $Plugin->order() . '"></td> <td>' . PluginInstaller::uninstallLink($Plugin->key()) . '</td> </tr>'; } } $Code .= ' </tbody> </table>'; 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; }
/** * Uninstall * @return bool */ public function uninstall() { $Factory = new PluginFactory(); $Plugin = $Factory->newInstance($this->Key); DB::getInstance()->deleteByID('plugin', $Plugin->id()); PluginFactory::clearCache(); return true; }
/** * Uninstall * @return bool */ public function uninstall() { $Factory = new PluginFactory(); $Plugin = $Factory->newInstance($this->Key); DB::getInstance()->deleteByID('plugin', $Plugin->id()); DB::getInstance()->query('DELETE FROM `' . PREFIX . 'plugin_conf` WHERE `pluginid`=' . $Plugin->id() . ' AND accountid = ' . SessionAccountHandler::getId()); PluginFactory::clearCache(); return true; }
/** * Init DatabaseScheme */ protected function initDatabaseScheme() { $this->DatabaseScheme = DatabaseSchemePool::get('training/schemes/scheme.UserData.php'); $Factory = new PluginFactory(); if ($Factory->isInstalled('RunalyzePluginPanel_Sportler')) { $Plugin = $Factory->newInstance('RunalyzePluginPanel_Sportler'); if (!$Plugin->Configuration()->value('use_body_fat')) { $this->DatabaseScheme->hideFieldset('analyse'); } if (!$Plugin->Configuration()->value('use_pulse')) { $this->DatabaseScheme->hideField('pulse_rest'); } } }
/** * Add tab for comparison of years */ protected function addTabForComparisonOfYears() { $Content = ''; $Factory = new PluginFactory(); if ($Factory->isInstalled('RunalyzePluginStat_Statistiken')) { $Plugin = $Factory->newInstance('RunalyzePluginStat_Statistiken'); $Content .= $Plugin->getYearComparisonTable(); } if ($Factory->isInstalled('RunalyzePluginStat_Wettkampf')) { if ($Content != '') { $Content .= '<tbody><tr class="no-zebra no-border"><td colspan="' . (date("Y") - START_YEAR + 2) . '"> </td></tr></tbody>'; } $Plugin = $Factory->newInstance('RunalyzePluginStat_Wettkampf'); $Content .= $Plugin->getYearComparisonTable(); } if ($Content != '') { $this->StatisticTabs->addTab(__('Year on year') . ' (' . __('Running') . ')', 'statistics-years', $Content); } }
/** * Set default values */ protected function setDefaultValues() { $Strategy = new Prognosis\Bock(); $TopResults = $Strategy->getTopResults(2); $CurrentShape = Configuration::Data()->vdotShape(); if (empty($_POST)) { $Factory = new PluginFactory(); $Plugin = $Factory->newInstance('RunalyzePluginPanel_Prognose'); $_POST['model'] = 'jack-daniels'; $_POST['distances'] = implode(', ', $Plugin->getDistances()); $_POST['vdot'] = $CurrentShape; $_POST['endurance'] = true; $_POST['endurance-value'] = BasicEndurance::getConst(); $_POST['best-result-km'] = !empty($TopResults) ? $TopResults[0]['distance'] : '5.0'; $_POST['best-result-time'] = !empty($TopResults) ? Duration::format($TopResults[0]['s']) : '0:26:00'; $_POST['second-best-result-km'] = !empty($TopResults) ? $TopResults[1]['distance'] : '10.0'; $_POST['second-best-result-time'] = !empty($TopResults) ? Duration::format($TopResults[1]['s']) : '1:00:00'; } $this->InfoLines['jack-daniels'] = __('Your current VDOT:') . ' ' . $CurrentShape . '. '; $this->InfoLines['jack-daniels'] .= __('Your current basic endurance:') . ' ' . BasicEndurance::getConst() . '.'; $ResultLine = empty($TopResults) ? __('none') : sprintf(__('%s in %s <small>(%s)</small> and %s in %s <small>(%s)</small>'), Distance::format($TopResults[0]['distance']), Duration::format($TopResults[0]['s']), date('d.m.Y', $TopResults[0]['time']), Distance::format($TopResults[1]['distance']), Duration::format($TopResults[1]['s']), date('d.m.Y', $TopResults[1]['time'])); $this->InfoLines['robert-bock'] = __('Your two best results:') . ' ' . $ResultLine; $this->setupJackDanielsStrategy(); $this->setupBockStrategy(); $this->setupSteffnyStrategy(); $this->setupCameronStrategy(); }
/** * Display surrounding div and default content for all tools */ public static function displayToolsContent() { echo '<div id="' . self::$TOOLS_DIV_ID . '">'; echo '<div class="panel-heading">'; echo '<h1>' . __('Tools') . '</h1>'; echo '</div>'; echo '<div class="panel-content">'; echo __('Complex tools can analyze or process the complete database and will open in an overlay.') . '<br><br>'; echo '<table class="fullwidth zebra-style more-padding">'; echo '<thead><tr><th colspan="3">' . __('Installed tools') . ':</th></tr></thead>'; echo '<tbody class="top-and-bottom-border">'; $Factory = new PluginFactory(); $tools = $Factory->activePlugins(PluginType::Tool); if (empty($tools)) { echo '<tr><td colspan="3"><em>' . __('No tools installed.') . '.</em></td></tr>'; } foreach ($tools as $key) { $Factory = new PluginFactory(); $Plugin = $Factory->newInstance($key); echo '<tr> <td>' . $Plugin->getConfigLink() . '</td> <td class="b">' . self::getLinkFor($Plugin->id(), $Plugin->name()) . '</td> <td>' . $Plugin->description() . '</td> </tr>'; } echo '</tbody>'; echo '</table>'; echo '</div>'; echo '</div>'; }
/** * Window: explanations for calculations * @package Runalyze\Plugins\Panels */ require '../../inc/class.Frontend.php'; $Frontend = new Frontend(); ?> <div class="panel-heading"> <h1><?php _e('Explanation: How are these experimental values calculated?'); ?> </h1> </div> <div class="panel-content"> <?php $Factory = new PluginFactory(); $Plugin = $Factory->newInstance('RunalyzePluginPanel_Rechenspiele'); $Formular = new Formular(); $Formular->setId('rechenspiele-calculator'); $Formular->addCSSclass('ajax'); $Formular->addCSSclass('no-automatic-reload'); $Formular->addFieldset($Plugin->getFieldsetTRIMP(), false); $Formular->addFieldset($Plugin->getFieldsetVDOT(), false); $Formular->addFieldset($Plugin->getFieldsetBasicEndurance()); $Formular->addFieldset($Plugin->getFieldsetPaces(), false); $Formular->allowOnlyOneOpenedFieldset(); $Formular->display(); ?> </div>
<div id="data-browser" class="panel"> <div id="data-browser-inner"> <?php $DataBrowser = new DataBrowser(); $DataBrowser->display(); ?> </div> </div> <div id="statistics" class="panel"> <ul id="statistics-nav"> <?php $Factory = new PluginFactory(); $Stats = $Factory->activePlugins(PluginType::STAT); foreach ($Stats as $i => $key) { $Plugin = $Factory->newInstance($key); if ($Plugin !== false) { echo '<li' . ($i == 0 ? ' class="active"' : '') . '>' . $Plugin->getLink() . '</li>'; } } if (PluginStat::hasVariousStats()) { echo '<li class="with-submenu">'; echo '<a href="#">' . __('Miscellaneous') . '</a>'; echo '<ul class="submenu">'; $VariousStats = $Factory->variousPlugins(); foreach ($VariousStats as $key) { $Plugin = $Factory->newInstance($key); if ($Plugin !== false) { echo '<li>' . $Plugin->getLink() . '</li>'; } }
/** * 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; }
/** * 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') . ' »</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); }
<?php /** * Draw prognosis as function of time * Call: include Plot.form.php * @package Runalyze\Plugins\Panels */ use Runalyze\Calculation\JD; use Runalyze\Calculation\Prognosis; use Runalyze\Configuration; use Runalyze\Activity\Distance; if (is_dir(FRONTEND_PATH . '../plugin/RunalyzePluginStat_Wettkampf')) { $Factory = new PluginFactory(); $WKplugin = $Factory->newInstance('RunalyzePluginStat_Wettkampf'); } if (!isset($distance)) { $distance = 10; } $DataFailed = false; $Prognosis = array(); $Results = array(); $Strategy = new Prognosis\Daniels(); $Strategy->adjustVDOT(false); $PrognosisObj = new Prognosis\Prognosis(); $PrognosisObj->setStrategy($Strategy); if (START_TIME != time()) { $Data = Cache::get('prognosePlotData'); if (is_null($Data)) { $withElevation = Configuration::Vdot()->useElevationCorrection(); $Data = DB::getInstance()->query(' SELECT
<?php /** * Window: prognosis plot * @package Runalyze\Plugins\Panels */ use Runalyze\Activity\Distance; require '../../inc/class.Frontend.php'; $Frontend = new Frontend(); $Factory = new PluginFactory(); $Plugin = $Factory->newInstance('RunalyzePluginPanel_Prognose'); $distances = $Plugin->getDistances(); if (!isset($_GET['distance'])) { $distance = in_array(10, $distances) ? 10 : trim($distances[0]); } else { $distance = (double) $_GET['distance']; } $Submenu = ''; foreach ($distances as $km) { $km = trim($km); $link = 'plugin/RunalyzePluginPanel_Prognose/window.plot.php?distance=' . $km; $Submenu .= '<li' . ($km == $distance ? ' class="active"' : '') . '>' . Ajax::window('<a href="' . $link . '">' . (new Distance($km))->stringAuto() . '</a>') . '</li>'; } ?> <div class="panel-heading"> <div class="panel-menu"> <ul> <li class="with-submenu"><span class="link"><?php _e('Choose distance'); ?> </span><ul class="submenu"><?php
<?php /** * File for installing plugins. * Call: call.Plugin.install.php?key= */ require '../inc/class.Frontend.php'; $Pluginkey = filter_input(INPUT_GET, 'key'); $Frontend = new Frontend(); $Installer = new PluginInstaller($Pluginkey); echo '<h1>' . __('Install') . ' ' . $Pluginkey . '</h1>'; if ($Installer->install()) { $Factory = new PluginFactory(); $Plugin = $Factory->newInstance($Pluginkey); echo HTML::okay(__('The plugin has been successfully installed.')); echo '<ul class="blocklist">'; echo '<li>'; echo $Plugin->getConfigLink(Icon::$CONF . ' ' . __('Configuration')); echo '</li>'; echo '</ul>'; Ajax::setReloadFlag(Ajax::$RELOAD_ALL); echo Ajax::getReloadCommand(); } else { echo HTML::error(__('There was a problem, the plugin could not be installed.')); } echo '<ul class="blocklist">'; echo '<li>'; echo Ajax::window('<a href="' . ConfigTabPlugins::getExternalUrl() . '">' . Icon::$TABLE . ' ' . __('back to list') . '</a>'); echo '</li>'; echo '</ul>';
$Mode = StandardFormular::$SUBMIT_MODE_EDIT; $Shoe = new Shoe(Request::sendId()); } $Formular = new StandardFormular($Shoe, $Mode); if ($Formular->submitSucceeded()) { header('Location: window.schuhe.table.php'); ShoeFactory::clearCache(); exit; } if (Request::sendId() > 0) { $DeleteText = '<strong>' . __('Delete shoe') . ' »</strong>'; $DeleteUrl = $_SERVER['SCRIPT_NAME'] . '?delete=true&id=' . $Shoe->id(); $DeleteLink = Ajax::link($DeleteText, 'ajax', $DeleteUrl); if ($Shoe->getKm() != $Shoe->getAdditionalKm()) { $DeleteLink = __('The shoe cannot be deleted as long it is used for some activity.'); } $DeleteFieldset = new FormularFieldset(__('Delete shoe')); $DeleteFieldset->addWarning($DeleteLink); $Formular->addFieldset($DeleteFieldset); } $Factory = new PluginFactory(); $Plugin = $Factory->newInstance('RunalyzePluginPanel_Schuhe'); echo '<div class="panel-heading">'; echo '<div class="panel-menu"><ul><li>' . $Plugin->tableLink() . '</li></ul></div>'; echo '<h1>' . $Header . '</h1>'; echo '</div>'; echo '<div class="panel-content">'; $Formular->setId('shoe'); $Formular->setLayoutForFields(FormularFieldset::$LAYOUT_FIELD_W33); $Formular->display(); echo '</div>';
/** * Get the link for first various statistic * @return string */ public static function getLinkForVariousStats() { $Factory = new PluginFactory(); $array = $Factory->variousPlugins(); return $Factory->newInstance($array[0])->getLink(); }
/** * 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");'); }
/** * Display panels */ public function displayPanels() { $Factory = new PluginFactory(); $Panels = $Factory->enabledPanels(); foreach ($Panels as $key) { $Panel = $Factory->newInstance($key); $Panel->display(); } }
<?php /** * Window: user table * @package Runalyze\Plugins\Panels */ require '../../inc/class.Frontend.php'; use Runalyze\Activity\Duration; use Runalyze\Activity\Weight; $Frontend = new Frontend(); $Factory = new PluginFactory(); $Plugin = $Factory->newInstance('RunalyzePluginPanel_Sportler'); $Fields = array('time' => 'date', 'weight' => '', 'sleep_duration' => ' <small>h</small>'); $FieldsPulse = array('pulse_rest' => ' <small>bpm</small>', 'pulse_max' => ' <small>bpm</small>'); $FieldsFat = array('fat' => ' %', 'water' => ' %', 'muscles' => ' %'); $Data = array_reverse(UserData::getFullArray()); if (Request::param('reload') == 'true') { Ajax::setReloadFlag(Ajax::$RELOAD_ALL); echo Ajax::getReloadCommand(); } ?> <div class="panel-heading"> <div class="panel-menu"><ul><li><?php echo $Plugin->addLink(); ?> </li></ul></div> <h1><?php _e('Body values'); ?> </h1> </div>
<?php /** * Window: equipment table * @package Runalyze\Plugins\Panels */ require '../../inc/class.Frontend.php'; $Frontend = new Frontend(); $Factory = new PluginFactory(); $Plugin = $Factory->newInstance('RunalyzePluginPanel_Equipment'); echo '<div class="panel-heading">'; echo '<h1>' . __('Your equipment') . '</h1>'; echo '</div>'; echo '<div class="panel-content">'; $Plugin->displayTable(); echo '</div>';