Example #1
0
 /**
  * Create a field
  * @param \Runalyze\Configuration\Handle $Handle
  * @param string $label
  * @return \FormularField
  */
 private function createFieldFor(Handle $Handle, $label)
 {
     $Parameter = $Handle->object();
     $Class = 'FormularInput';
     if ($Parameter instanceof SelectRow) {
         $Field = new \FormularSelectDb($Handle->key(), $label, $Handle->value());
         $Field->loadOptionsFrom($Parameter->table(), $Parameter->column());
         return $Field;
     } elseif ($Parameter instanceof Select) {
         $Field = new \FormularSelectBox($Handle->key(), $label, $Handle->value());
         $Field->setOptions($Parameter->options());
         return $Field;
     } elseif ($Parameter instanceof Boolean) {
         $Field = new \FormularCheckbox($Handle->key(), $label, $Handle->value());
         $Field->addHiddenSentValue();
         return $Field;
     }
     return new $Class($Handle->key(), $label, $Handle->object()->valueAsString());
 }
 /**
  * Correct references in configuration
  */
 private function correctConfigReferences()
 {
     if (isset($_POST['overwrite_config'])) {
         $ConfigValues = Configuration\Handle::tableHandles();
         foreach ($ConfigValues as $key => $table) {
             $table = 'runalyze_' . $table;
             if (isset($this->ReplaceIDs[$table])) {
                 $OldValue = $this->DB->query('SELECT `value` FROM `' . PREFIX . 'conf` WHERE `key`="' . $key . '" LIMIT 1')->fetchColumn();
                 $NewValue = $this->correctID($table, $OldValue);
                 if ($NewValue != 0) {
                     $this->DB->updateWhere('conf', '`key`="' . $key . '"', 'value', $NewValue);
                 }
             }
         }
     }
 }
Example #3
0
 public function testValue()
 {
     $this->assertEquals(42, $this->object->value());
 }
Example #4
0
 /**
  * Update value from post
  * @param \Runalyze\Configuration\Handle $Handle
  */
 private function updateValueFromPost(Handle $Handle)
 {
     $key = $Handle->key();
     if (isset($_POST[$key]) || isset($_POST[$key . '_sent'])) {
         $value = $Handle->value();
         if ($Handle->object() instanceof Parameter\Bool) {
             $Handle->object()->set(isset($_POST[$key]));
         } else {
             $Handle->object()->setFromString($_POST[$key]);
         }
         if ($value != $Handle->value()) {
             $this->updateValue($Handle);
             $Handle->processOnchangeEvents();
         }
     }
 }