<?php
    
class attr_redactor_html extends attr {
    function getDBType() {
    	return "text";
    }

    function render_input() {
		return '<textarea class="textarea" id="' . $this->attr_name.'" name="' . $this->attr_name.'">' .html_entity_decode($this->getCurVal()) . '</textarea>
            <script>$("#' . $this->attr_name.'").redactor( { imageUpload: "img_uploader.php", fileUpload: "file_uploader.php" } );</script>
        ';    	
    }
    
    function render_text( $crop = false ) {
    	$val = $this->getCurVal();
    	if ( $crop ) {
	    	$val = mb_substr(strip_tags(html_entity_decode($val)),0, 100,'UTF-8');
    	}
    	return html_entity_decode($val);
    }


    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 presave() {
		$data = htmlspecialchars(  html_entity_decode( $this->getCurVal(), NULL, 'UTF-8' ), NULL, 'UTF-8' );
		$this->obj->set($this->attr_name, $data );
    }  

}

?>