<?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("show_type", array("required"), array("1", "2", "3"));
		$this->addElement("show_percent", array("required"), array("0", "1"));
		$this->addElement("more_options", array("required"));
	}

	public function startData($currentData) {
		$data = array();
		
		$data["config"] = array(
			"image" => "",
			"image_name" => "",
			"description" => "",
			"show_type" => "1",
			"show_percent" => "0",
			"more_options" => "1"
		);
		$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();
		$show_type = $this->getElement("show_type")->getValue();
		$show_percent = $this->getElement("show_percent")->getValue();
		$more_options = (int)$this->getElement("more_options")->getValue();

		if($show_percent != "1") {
			$show_percent = "0";
		}
		
		$config = array(
			"image" => $image,
			"image_name" => $image_name,
			"description" => $description,
			"show_type" => $show_type,
			"show_percent" => $show_percent,
			"more_options" => $more_options
		);

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