<?php
    
class attr {

	var $attr_name;
	var $obj;
	var $DBType = "varchar(255)";
	var $sql_where;

    function getDBType() {
    	return "varchar(255)";
    }

    function __construct( $attr_name, $obj ) {
           $this->attr_name = $attr_name;
           $this->obj = $obj;
    }
    
    
    function lPost() {
    	if ( ini_get('magic_quotes_gpc') ) {
        	$this->obj->set($this->attr_name,stripslashes($_POST[$this->attr_name]));
        } else {
        	$this->obj->set($this->attr_name,$_POST[$this->attr_name]);
        }
    }  
    
    function getCurVal() {
    	return $this->obj->get(	$this->attr_name );
    }
    
    function getAttrTempl() {
    	return str_replace("]","}",str_replace("[","{",$this->obj->attrs[$this->attr_name]['templ']));
    }

    function getAttrSetting($setting='') {
    	return $this->obj->attrs[$this->attr_name][$setting];
    }

    function presave() {
		if (!is_array($this->getCurVal())) 
			$this->obj->set($this->attr_name, htmlspecialchars(  html_entity_decode( $this->getCurVal() ) ) );
    }  
    
    function validate() {

    }
    
    function render_input() {
		return '<input id="' . $this->attr_name . '" type="text" name="' . $this->attr_name . '" value="' .$this->getCurVal() . '">';    	
    }

    function render_text( $crop ) {
    	return $this->getCurVal();
    }
    
    function setSqlWhere( $sql_where ) {
    	$this->sql_where = 	$sql_where;
    }
    
    function getFilter( $sql_where = '' ) {
    	
    	$html = "<input name='".$this->obj->obj_name.'_'.$this->attr_name."'>";
    	
    	
    	return array('html'=> '', 'sql'=>'');
    }
    
    
    
    
    
}

?>