Files
thetool/application/ADBHausnummer/ADBHausnummer.php
2022-11-11 13:59:53 +01:00

83 lines
2.0 KiB
PHP

<?php
class ADBHausnummer extends mfBaseModel {
private $ortschaft;
private $strasse;
private $plz;
private $freigaben = [];
protected function init() {
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$this->table = "Hausnummer";
}
/*
public static function parseAddresszusatz($text) {
$zusatz = "";
$text = trim($text);
if(!$text) return $data;
$text = " ".$text;
$m = [];
if(preg_match('/((?:gesch(?:ae|ä)ft|betrieb und wohnungen|paketlogistik|cafe|pavillon|pfarrheim|[^ ]*haus|[^ ]*geb(?:ae|ä)ude|[^ ]*halle)(?:\s+[a-z0-9]+)?)/i', $text, $m)) {
$zusatz = $m[1];
$text = str_replace($m[0], "", $text);
}
$text = trim(preg_replace('/\s{2,}/', "", $text));
if($text) {
$data['zusatz'] = $text;
}
return $data;
}*/
public function getProperty($name) {
if($this->$name == null) {
if($name == "freigaben") {
$this->freigaben = explode(",", $this->freigabe);
return $this->freigaben;
}
if($name == "ortschaft") {
$this->ortschaft = new ADBOrtschaft($this->ortschaft_id);
return $this->ortschaft;
}
if($name == "strasse") {
$this->strasse = new ADBStrasse($this->strasse_id);
return $this->strasse;
}
if($name == "plz") {
$this->plz = mfValuecache::singleton()->get("adbplz-".$this->plz_id);
if($this->plz === null) {
$this->plz = new ADBPlz($this->plz_id);
if($this->plz->id) {
mfValuecache::singleton()->set("adplz-".$this->plz_id, $this->plz);
}
}
return $this->plz;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = new $classname($this->$idfield);
if($this->$name->id) {
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}