Location: PHPKode > projects > KvCMS Content Management System > kvframework/kvframework/ext/struct.class.php
<?php
abstract class struct {

  protected $FIELDS = array();
  protected $VARS = array();
  protected $DATA = array();

  public function __construct(array $new_defaults = array()){
    if(!is_array($this->FIELDS)){$this->FIELDS = array();}
    $this->FIELDS = array_merge($this->FIELDS, array_intersect_key($new_defaults, $this->FIELDS));
    foreach($this->FIELDS as $f => $d){
      $this->DATA[$f] = $d;
    }
  }

  public function __get($m){
    return(($this->var_allowed($m)) ? $this->DATA[$m] : null);
  }

  public function __set($m, $v){
    if($this->var_allowed($m) && gettype($v) == gettype($this->$m)){
      $this->DATA[$m] = $v;
    }
  }

  public function __call($m, $a){
    return null;
  }

  public function __unset($m){

  }

  protected function var_allowed($m){
    return((in_array($m, array_keys($this->FIELDS)) || in_array($m, $this->VARS)) ? true : false );
  }

}
?>
Return current item: KvCMS Content Management System