Пример #1
0
 /**
  * Init dataset
  */
 protected function initDataset()
 {
     $this->AccountID = SessionAccountHandler::getId();
     $this->DB = DB::getInstance();
     $this->DatasetConfig = new \Runalyze\Dataset\Configuration($this->DB, $this->AccountID);
     $this->DatasetQuery = new \Runalyze\Dataset\Query($this->DatasetConfig, $this->DB, $this->AccountID);
     $this->DatasetConfig->activateAllKeys();
     $this->Colspan = 2 + count($this->DatasetConfig->allKeys());
 }
Пример #2
0
 /**
  * Parse all post values 
  */
 public function parsePostData()
 {
     $AccountID = SessionAccountHandler::getId();
     $UpdateStatement = DB::getInstance()->prepare('UPDATE `' . PREFIX . 'dataset` ' . 'SET `active`=:active, `style`=:style, `position`=:position ' . 'WHERE `accountid`=:accountid AND `keyid`=:keyid');
     $InsertStatement = DB::getInstance()->prepare('INSERT INTO `' . PREFIX . 'dataset` ' . '(`keyid`, `active`, `style`, `position`, `accountid`) ' . 'VALUES (:keyid, :active, :style, :position, :accountid)');
     foreach (Dataset\Keys::getEnum() as $keyid) {
         $active = Dataset\Keys::get($keyid)->mustBeShown() || isset($_POST[$keyid . '_active']) && $_POST[$keyid . '_active'];
         $data = array(':active' => $active ? 1 : 0, ':style' => isset($_POST[$keyid . '_style']) ? htmlentities($_POST[$keyid . '_style']) : '', ':position' => isset($_POST[$keyid . '_position']) ? (int) $_POST[$keyid . '_position'] : 99, ':accountid' => $AccountID, ':keyid' => $keyid);
         if (!$this->ConfigurationIsNew && $this->Configuration->exists($keyid)) {
             $UpdateStatement->execute($data);
         } else {
             $InsertStatement->execute($data);
         }
     }
     Ajax::setReloadFlag(Ajax::$RELOAD_DATABROWSER);
     Cache::delete(Dataset\Configuration::CACHE_KEY);
     $this->loadConfiguration();
 }
Пример #3
0
 /**
  * @param \Runalyze\Dataset\Context $context
  * @return string
  */
 public function codeForColumns(Context $context, array $hiddenKeys = array())
 {
     $Code = '';
     if ($this->AutomaticDistanceComparison) {
         $context->setData(Keys\Distance::KEY_DISTANCE_COMPARISON, $this->LastDistance);
         $this->LastDistance = $context->activity()->distance();
     }
     foreach ($this->ActiveKeys as $keyid) {
         if (in_array($keyid, $hiddenKeys)) {
             $Code .= '<td></td>';
         } else {
             $Key = Keys::get($keyid);
             $class = $Key->cssClass() != '' ? ' class="' . $Key->cssClass() . '"' : '';
             $style = $this->Configuration->getStyle($keyid) != '' ? ' style="' . $this->Configuration->getStyle($keyid) . '"' : '';
             $Code .= '<td' . $class . $style . '>' . $Key->stringFor($context) . '</td>';
         }
     }
     return $Code;
 }
Пример #4
0
 /**
  * Query to select active keys
  * Hint: You must use "... FROM `'.PREFIX.'training` AS `t` ..."
  * @return string
  */
 public function queryToSelectActiveKeys()
 {
     return $this->queryToSelectKeys($this->collectColumnsForKeys($this->Configuration->activeKeys()));
 }