<?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("min", array("required"));
		$this->addElement("max", array("required"));
		$this->addElement("y_name", array("required"));
		$this->addElement("x_name", array("required"));
		$this->addElement("show_type", array("required"));
		$this->addElement("show_type_rotate", array("required"));
		$this->addElement("background", array("required"));
		$this->addElement("background_name", array("required"));
		$this->addElement("hide_button", array("required"));
	}

	public function startData($currentData) {
		$data = array();
		
		$data["config"] = array(
			"image" => "",
			"image_name" => "",
			"description" => "",
			"min" => "1",
			"max" => "5",
			"y_name" => "",
			"x_name" => "",
			"show_type" => "1",
			"show_type_rotate" => "0",
			"background" => "",
			"background_name" => "",
			"hide_button" => "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();
		$min = $this->getElement("min")->getValue();
		$max = $this->getElement("max")->getValue();
		$y_name = $this->getElement("y_name")->getValue();
		$x_name = $this->getElement("x_name")->getValue();
		$show_type = $this->getElement("show_type")->getValue();
		$show_type_rotate = $this->getElement("show_type_rotate")->getValue();
		$background = $this->getElement("background")->getValue();
		$background_name = $this->getElement("background_name")->getValue();
		$hide_button = $this->getElement("hide_button")->getValue();

		if($hide_button != "1") {
			$hide_button = "0";
		}
		
		$config = array(
			"image" => $image,
			"image_name" => $image_name,
			"description" => $description,
			"min" => $min,
			"max" => $max,
			"y_name" => $y_name,
			"x_name" => $x_name,
			"show_type" => $show_type,
			"show_type_rotate" => $show_type_rotate,
			"background" => $background,
			"background_name" => $background_name,
			"hide_button" => $hide_button
		);

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