new_value; } else { $value = $this->old_value; } if($raw) { return $value; } $m = []; if(preg_match('/(.+)_id/', $this->key, $m)) { if(array_key_exists(1, $m)) { $object = ucfirst($m[1]); if($object == "Status") $object = "Preorderstatus"; if($object == "Partner") $object = "Address"; if($object == "Adb_hausnummer") $object = "ADBHausnummer"; if($object == "Adb_wohneinheit") $object = "ADBWohneinheit"; if(class_exists($object)) { $value = new $object($value); if(!$value->id) return null; } } } return $value; } public function getKey() { $key = $this->key; if(preg_match('/^preorderstatusflag-(\d+)-/', $key, $m)) { if(array_key_exists(1, $m)) { $id = $m[1]; $psf = new Preorderstatusflag($id); return "Status Flag ".$psf->code." - ".$psf->name; } } return $key; } public function getText($type = "new") { $value = $this->getValue($type); if($value === null) return ""; if($this->key == "attributes") { $attribs = ""; $jdec = json_decode($value); if(is_object($jdec)) { foreach(get_object_vars($jdec) as $k => $v) { $attribs .= "$k: $v
"; } return $attribs; } } if(!is_object($value)) { return $value; } if(get_class($value) == "Preorderstatus") { return $value->code." - ".$value->name; } if(get_class($value) == "Address") { return $value->getCompanyOrName(); } if(get_class($value) == "ADBHausnummer") { return $value->getAddress(); } if(get_class($value) == "ADBWohneinheit") { return $value->id." - ".(string)$value; } if(get_class($value) == "Preordercampaign") { return $value->name; } } public function getProperty($name) { if($this->$name == null) { if($name == "old" || $name == "new") { return $this->getValue($name, false); } if($name == "old_raw") { return $this->getValue("old", true); } if($name == "new_raw") { return $this->getValue("new", true); } if($name == "creator") { $this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by); if($this->creator === null) { $this->creator = new User($this->create_by); if($this->creator->id) { mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator); } } return $this->creator; } if($name == "editor") { $this->editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by); if($this->editor === null) { $this->editor = new User($this->edit_by); if($this->editor->id) { mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor); } } return $this->editor; } $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; } }