<?php 

class MojPlugin
{
    private $table = "_plugin_single_respons_with_image";
    
    private $database = DB_WARPIT_WEBCATI_BASE;
    
    private $data;
    
    private $db;
    
    public function __construct($db)
    {
        $this->db = $db;
    }
    
    public function load($idProject, $idQuestion)
    {
        $sql = "SELECT * FROM " . $this->database . "." . $this->table . "
            		WHERE id_question = " . $idQuestion . " AND id_project = " . $idProject . " AND deleted = 0";
         $res= $this->db->SQLexecute($sql);
         $this->data = $this->db->fetchAssoc($res);
    }
    
    public function getImage()
    {
        return $this->data['image'];
    }
    
    public function getButtonBackgroundNormal()
    { 
        if($this->data['button_image_normal'] != '') {
            return '"background-image": "url(' . $this->data['button_image_normal'] . ')",';}
        else 
            return '"background-color": "' . $this->data['button_color_normal'] .'",';
    }
    
    public function getButtonBackgroundSelected()
    {
        if($this->data['button_image_normal'] != '')
            return '"background-image": "url(' . $this->data['button_image_normal'] . ')",';
        else 
            return '"background-color": "' . $this->data['button_color_selected'] .'",';
    }
    
    public function getButtonSize()
    {
        if($this->data['button_width'] != '0' && $this->data['button_height'] != '0')
            return '"width" : "' . $this->data['button_width'] . '", "height" : "' . $this->data['button_height'] . '",';
        else 
            return '';
    }
    
    public function getTextBoxSize()
    {
        //defaul values
        $width = 230;
        $height = 50;
        
        if($this->data['text_box_width'] != 0)
        {
            $width = $this->data['text_box_width'];
        }
        if($this->data['text_box_height'] != 0)
        {
            $height  = $this->data['text_box_height'];
        }
        
        return 'width :' . $width . "px; height : " . $height . ";";
    }
    
    
    
    public function getButtonBackgroundColor()
    {
    }
}

?>