<?php
/**
 * class presentation_edit_form
 *
 * Description for class presentation_edit_form
 *
 * @author:
*/
namespace form;

use form\slide_form;

class slide_extend_form extends slide_form {
	public function init() {
		$this->addElement("name", array("required"));
		$this->addElement("image", array("required"));
		$this->addElement("image_name", array("required"));
		$this->addElement("description", array("required"));
		$this->addElement("options", array("required"));
		$this->addElement("max_label", array("required"));
		$this->addElement("max_value", array("required"));
		$this->addElement("min_label", array("required"));
		$this->addElement("min_value", array("required"));
		$this->addElement("show_avg", array("required"));
	}

	public function startData($currentData) {
		$data = array();
		
		$data["config"] = array(
			"image" => "",
			"image_name" => "",
			"description" => "",
			"max_label" => "",
			"max_value" => "5",
			"min_label" => "",
			"min_value" => "1",
			"show_avg" => "0"
			);
		$data["options"] = false;

		return $data;
	}

	public function save($board_id) {
		$name = $this->getElement("name")->getValue();
		$image = $this->getElement("image")->getValue();
		$image_name = $this->getElement("image_name")->getValue();
		$description = $this->getElement("description")->getValue();
		$options = $this->getElement("options")->getValue();
		$max_label = $this->getElement("max_label")->getValue();
		$max_value = $this->getElement("max_value")->getValue();
		$min_label = $this->getElement("min_label")->getValue();
		$min_value = $this->getElement("min_value")->getValue();
		$show_avg = $this->getElement("show_avg")->getValue();

		if($show_avg != "1") {
			$show_avg = "0";
		}

		$config = array(
			"image" => $image,
			"image_name" => $image_name,
			"description" => $description,
			"max_label" => $max_label,
			"max_value" => $max_value,
			"min_label" => $min_label,
			"min_value" => $min_value,
			"show_avg" => $show_avg
			);

		return $this->__save($board_id, $name, "", "", $config, array(), $options);
	}
}