no cóż klas jest dosyć dużo...
Autor:
<?php
require_once 'class.Osoba.php';
/**
* Description of osoba
*
* @author daniel
*/
class Autor extends Osoba{
public function __construct($id=null) {
if(!$id){
parent::__construct(null);
} else {
$arData=DataManager::getData($id,'autor');
parent::__construct($arData);
}
$this->propertyTable['idautor']='idautor';
$this->idtyposoba=DataManager::getIdForTypOsoby('autor');
}
public function __toString() {
return (string)$this->nazwa;
}
public function save(){
parent::save();
$newData['idosoba']=$this->idosoba;
$this->idautor=DataManager::saveNewField('autor',$newData);
}
public function update(){
parent::update();
$newData['idosoba']=$this->idosoba;
DataManager::saveField('autor',$newData,$this->idautor);
}
public function del(){
parent::del();
}
}
?>
Osoba:
<?php
require_once 'class.Jednostka.php';
require_once 'class.TypOsoby.php';
/**
* Description of osoba
*
* @author daniel
*/
abstract class Osoba extends Jednostka{
public function __construct($arData) {
if(!$arData){
parent::__construct(null);
} else {
$arData2=DataManager::getData($arData['idosoba'],'osoba');
parent::__construct($arData);
}
$this->propertyTable['pesel']='pesel';
$this->propertyTable['nrdowodu']='nrdowodu';
$this->propertyTable['idosoba']='idosoba';
$this->propertyTable['idfirma']='idfirma';
$this->propertyTable['idtyposoba']='idtyposoba';
}
public function save(){
parent::save();
$newData['pesel']=$this->pesel;
$newData['nrdowodu']=$this->nrdowodu;
$newData['idfirma']=null;
$newData['idtyposoba']=$this->idtyposoba;
$newData['idjednostka']=$this->idjednostka;
$this->idosoba=DataManager::saveNewField('osoba',$newData);
}
public function update(){
parent::update();
$newData['pesel']=$this->pesel;
$newData['nrdowodu']=$this->nrdowodu;
$newData['idfirma']=null;
$newData['idtyposoba']=$this->idtyposoba;
$newData['idjednostka']=$this->idjednostka;
DataManager::saveField('osoba',$newData,$this->idosoba);
}
public function del(){
parent::del();
}
}
?>
Jednostka:
<?php
require_once 'class.PropertyObject.php';
require_once 'class.Collection.php';
require_once 'class.Telefon.php';
require_once 'class.Adres.php';
require_once 'class.Email.php';
require_once 'class.Organizator.php';
require_once 'class.Firma.php';
require_once 'class.TypOsoby.php';
/**
* Description of classJednostka
*
* @author daniel
*/
abstract class Jednostka extends PropertyObject
{
public $telephones = array(); public $emails = array(); public $adresses = array(); //public $typjednostka;
//public $nazwa;
//public $idjednostka;
// public $nip;
public function __construct($arData) {
if(!$arData){
parent::__construct(null);
$this->telephones= new Collection();
$this->emails= new Collection();
$this->adresses= new Collection();
} else {
$arData2=DataManager::getData($arData['idjednostka'],'jednostka');
parent::__construct($arData);
$this->telephones= new Collection();
$this->telephones->setLoadCallback('_loadTelephones',$this);
$this->emails= new Collection();
$this->emails->setLoadCallback('_loadEmails',$this);
$this->adresses= new Collection();
$this->adresses->setLoadCallback('_loadAdresses',$this);
}
$this->propertyTable['nazwa']='name';
$this->propertyTable['idjednostka']='idjednostka';
$this->propertyTable['nip']='nip';
}
public function _loadTelephones(Collection $col) {
$this->telephones=DataManager::getColectionObjectsForEntity($this->idjednostka, $col, 'telefon');
} // end of member function
public function _loadEmails(Collection $col) {
$this->emails=DataManager::getColectionObjectsForEntity($this->idjednostka, $col, 'email');
} // end of member function
public function _loadAdresses(Collection $col) {
$this->adresses=DataManager::getColectionObjectsForEntity($this->idjednostka, $col, 'adres');
} // end of member function
public function addAdres(Adres $adresses){
$this->adresses->addItem($adresses);
}
public function addEmail(Email $email){
$this->emails->addItem($email);
}
public function addTelefon(Telefon $telefon){
$this->telephones->addItem($telefon);
}
public function save(){
$newData['name']=$this->nazwa;
$newData['nip']=$this->nip;
$this->idjednostka=DataManager::saveNewField('jednostka',$newData);
}
public function update(){
$newData['name']=$this->nazwa;
$newData['nip']=$this->nip;
DataManager::saveField('jednostka',$newData,$this->idjednostka);
}
public function del(){
DataManager::delField($this->idjednostka,'jednostka');
}
}
?>
Adres:
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
require_once 'class.PropertyObject.php';
/**
* Description of classAddress
*
* @author daniel
*/
class Adres extends PropertyObject
{
public function __construct($id=null) {
if(!$id){
}else{
$arData=DataManager::getData($id,'adres');
parent::__construct($arData);
}
$this->propertyTable['miejscowosc']='miejscowosc';
$this->propertyTable['nrlokalu']='nrlokalu';
$this->propertyTable['nrdomu']='nrdomu';
$this->propertyTable['kod']='kod';
$this->propertyTable['ulica']='ulica';
$this->propertyTable['kraj']='kraj';
$this->propertyTable['idadres']='idadres';
$this->propertyTable['idjednostka']='idjednostka';
}
public function __toString() {
return (string)($this->ulica." ".$this->nrdomu." ".$this->nrlokalu." ".$this->miejscowosc." ".$this->kod." ".$this->kraj." ");
}
public function save($idjednostka){
$newData['miejscowosc']=$this->miejscowosc;
$newData['nrlokalu']=$this->nrlokalu;
$newData['nrdomu']=$this->nrdomu;
$newData['kod']=$this->kod;
$newData['ulica']=$this->ulica;
$newData['kraj']=$this->kraj;
$newData['idjednostka']=$idjednostka;
$this->idadres=DataManager::saveNewField('adres',$newData);
}
public function update(){
$newData['miejscowosc']=$this->miejscowosc;
$newData['nrlokalu']=$this->nrlokalu;
$newData['nrdomu']=$this->nrdomu;
$newData['kod']=$this->kod;
$newData['ulica']=$this->ulica;
$newData['kraj']=$this->kraj;
$newData['idjednostka']=$this->idjednostka;
DataManager::saveField('adres',$newData,$this->idadres);
}
}
?>
Property:
<?
require_once 'interface.Validate.php';
/**
* class PropertyObject
*
*/
abstract class PropertyObject implements Validate
{
/** Aggregations: */
/** Compositions: */
/*** Attributes: ***/
/**
*
* @access protected
*/
protected
$propertyTable =array (); protected
$changedProperties= array(); protected $data;
protected
$errors = array();
public function __construct($arData){
$this->data=$arData;
}
function __get($propertyName){
throw new Exception("Błędna własność \"$propertyName\"! ");
if(method_exists($this, 'get'.$propertyName)){
return call_user_func
(array($this, 'get'.$propertyName)); } else {
return $this->data[$this->propertyTable[$propertyName]];
}
}
function __set($propertyName, $value){
throw new Exception("Błędna własność \"$propertyName\" ");
if(method_exists($this, 'set'.$propertyName)){
return call_user_func(
array($this,'set'.$propertyName), $value
);
} else {
//jeżeli wartość własności uległa zmianie i nie ma jej
//jeszcze w tabeli chengedProperties, zostanie do niej dołączona
if($this->propertyTable[$propertyName]!=$value &&
!in_array($propertyName,$this->changedProperties)){ $this->changedProperties[]=$propertyName;
}
$this->data[$this->propertyTable[$propertyName]] = $value;
}
}
/**
*
*
* @return
* @access public
*/
function validate( ) {
} // end of member function validate
function errormsg(){
foreach ($this->errors as $value) {
print ('!!!!'.$value.'!!!!'); }
}
} // end of PropertyObject
?>