Example #1
0
 /**
  * @param  array to wrap
  * @throws InvalidArgumentException
  */
 public function __construct($arr = NULL, $flags = self::READONLY)
 {
     parent::__construct($arr);
     if ($arr !== NULL) {
         if ($flags & self::EXPAND) {
             $this->expand();
         }
         if ($flags & self::READONLY) {
             $this->setReadOnly();
         }
     }
 }
Example #2
0
 /**
  * Creates a modifiable clone of the object.
  * @return void
  */
 public function __clone()
 {
     parent::__clone();
     $data = $this->getArrayCopy();
     foreach ($data as $key => $val) {
         if ($val instanceof self) {
             $data[$key] = clone $val;
         }
     }
     $this->setArray($data);
 }
Example #3
0
 public function getAlleMeineFaecher()
 {
     if ($this->isLoggedIn()) {
         if ($this->conn->isConnected()) {
             $s = "SELECT f.Kennzahl, f.Teilkennziffer, f.Name, f.WS_SS, f.Status, f.SWS, f.CP, f.Herkunft, f.AnzLeistungen, f.AnzahlDozenten, a.PAnFachID, a.Anfang, a.Text, a.AnteilLeistung, a.MaxTeilnehmer, a.Anmeldefrist, a.Pruefungstermin, a.NurPruefung FROM fach f RIGHT JOIN angebotenesfach a ON (a.Kennzahl=f.Kennzahl and a.Teilkennziffer=f.Teilkennziffer) WHERE a.PDozentID=" . $this->id . " ORDER BY f.Kennzahl";
             $q = new DBQuery($s);
             if ($res = $this->conn->executeQuery($q)) {
                 $arr = array();
                 // Array für die Fächer
                 $i = 0;
                 $ht = new Hashtable();
                 while ($r = $res->getNextRow()) {
                     $ht->setValue('nurPruefung', $r[17]);
                     $arr[$i] = AngebotenesFach::create2($this->conn, $r[0], $r[1], $r[2], $r[3], $r[4], $r[5], $r[6], $r[7], $r[8], $r[9], $r[10], $r[11], $r[12], $r[13], $r[14], $r[15], $r[16], $ht);
                     $i++;
                 }
                 return $arr;
             } else {
                 $this->last_error = "Die Fächer konnten nicht ausgelesen werden. " . $this->conn->getLastError();
                 return false;
             }
         } else {
             $this->last_error = "Keine Verbindung zur Datenbank.";
             return false;
         }
     } else {
         $this->last_error = "Sie sind nicht eingeloggt.";
         return false;
     }
 }
Example #4
0
    $person->sayHi();
}
// List::__construct()
$arr = array('a' => $jack, 'b' => $mary, 'c' => $foo);
try {
    echo "Construct from array\n";
    $hashtable2 = new Hashtable($arr, 'Person');
} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
echo "Construct from array II.\n";
$hashtable2 = new Hashtable($arr);
Debug::dump($hashtable2);
// readonly collection
echo "Construct as readonly\n";
$hashtable2 = new Hashtable($hashtable);
$hashtable2->freeze();
Debug::dump($hashtable2->isFrozen());
try {
    echo "Adding Jack using []\n";
    $hashtable2['new'] = $jack;
} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
try {
    echo "Adding Jack using add\n";
    $hashtable2->add('new', $jack);
} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
try {
Example #5
0
 function loadFromFile()
 {
     $configname = new StringBuffer();
     $buffers = new StringBuffer();
     $conf = NULL;
     $key = '';
     $value = '';
     $skipline = 0;
     $c = '';
     if ($this->reader->ready()) {
         while (($c = $this->reader->read()) != '') {
             if ($c == CONFIG_END_KEY) {
                 if (isset($conf) && $buffers->length() > 0) {
                     $buffers = $buffers->trimAll();
                     if (!$buffers->startsWith(CONFIG_COMMENT)) {
                         $key_separator_pos = $buffers->indexOf('=');
                         if ($buffers->startsWith(MULTICONFIG_START) && $buffers->endsWith(MULTICONFIG_END)) {
                             if ($conf->size() > 0) {
                                 $this->put($configname->toString(), $conf);
                             }
                             $i = $buffers->indexOf(':') + 1;
                             $configname = $buffers->substring($i, $buffers->length() - 1);
                             $conf = new Hashtable();
                         } else {
                             if ($key_separator_pos > 0) {
                                 $key = $buffers->substring(0, $key_separator_pos);
                                 $key = $key->trimAll();
                                 $value = $buffers->substring($key_separator_pos + 1);
                                 $value = $value->trimAll();
                                 if ($key->length() > 0 && $value->length() > 0) {
                                     $str = $conf->get($key->toString()) . $value->toString();
                                     $conf->put($key->toString(), $str);
                                 }
                             }
                         }
                     }
                 } else {
                     $buffers = $buffers->trimAll();
                     if ($buffers->startsWith(MULTICONFIG_START) && $buffers->endsWith(MULTICONFIG_END)) {
                         $i = $buffers->indexOf(':') + 1;
                         $configname = $buffers->substring($i, $buffers->length() - 1);
                         $conf = new Hashtable();
                     }
                 }
                 $buffers = new StringBuffer();
             } else {
                 $buffers->append($c);
             }
         }
         if ($buffers->length() > 0) {
             $key_separator_pos = $buffers->indexOf('=');
             if ($key_separator_pos > 0) {
                 $key = $buffers->substring(0, $key_separator_pos);
                 $key = $key->trimAll();
                 $value = $buffers->substring($key_separator_pos + 1);
                 $value = $value->trimAll();
                 if ($key->length() > 0 && $value->length() > 0) {
                     $conf->put($key->toString(), $value->toString());
                 }
             }
         }
         if (isset($conf) && $conf->size() > 0) {
             $this->put($configname, $conf);
         }
     }
 }