<?php
/**
@file
@brief ステータス入力フォーム（管理用）
@version $Id: AdminStatusEditForm.php,v 1.1 2004/07/26 10:29:01 minahito Exp $
*/

require_once "exForm/Form.php";
require_once "exComponent/Input.php";
require_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";

class AdminStatusEditForm extends exAbstractActionForm {
	function load()
	{
		$handler = bxParty::getHandler('status');

		$id=$this->getPositive($_REQUEST['id']);

		// 探す
		if($id>0) {
			$this->data_ = $handler->get($id);
			if(!is_object($this->data_))
				$this->data_=$handler->create();
		}
		else
			$this->data_=$handler->create();
	}

	function doGet($data)
	{
		$this->load();
	}
	
	function doPost($data) {
		global $xoopsUser;

		// ロードさせる
		$this->load();

		$this->data_->setVar('name',$_POST['name']);
		if(!$this->validateMaxLength($_POST['ex'],255))
			$this->msg_[]="説明は255文字以内で入力して下さい";
		else
			$this->data_->setVar('ex',$_POST['ex']);

		$this->data_->setVar('priority',$this->getPositive($_POST['priority']));
		$type=$this->getPositive($_POST['type']);
		$this->data_->setVar('type',$type);
		
		if($type>_BXPARTY_STATUS_ENTRY)
			$this->msg_[]="TYPE 値が不正です";

		if(!$this->data_->cleanVars()) {
			$this->msg_=array_merge($this->msg_,$this->data_->getErrors());
		}
	}
}

class AdminStatusInputComponentRender extends exInputComponentRender {
	function render() {
		$form = new XoopsThemeForm('STATUS','status',$_SERVER['SCRIPT_NAME'],'POST');

		$form->addElement(new XoopsFormHidden("id",$this->component_->form_->data_->getVar("id")));
		$form->addElement(new XoopsFormText("NAME","name",60,60,$this->component_->form_->data_->getVar("name","e")));
		$form->addElement(new XoopsFormDhtmlTextArea("EX","ex",$this->component_->form_->data_->getVar("ex","e")));
		$form->addElement(new XoopsFormText("PRIORITY","priority",2,2,$this->component_->form_->data_->getVar("priority")));

		$type=new XoopsFormSelect("TYPE","type",$this->component_->form_->data_->getVar("type"));
		$type->addOption(_BXPARTY_STATUS_BOTH,_MD_A_BXPARTY_LANG_TYPE_BOTH);
		$type->addOption(_BXPARTY_STATUS_PARTY,_MD_A_BXPARTY_LANG_TYPE_PARTY);
		$type->addOption(_BXPARTY_STATUS_ENTRY,_MD_A_BXPARTY_LANG_TYPE_ENTRY);

		$form->addElement($type);

		$form->addElement(new XoopsFormButton('','submit',_MD_A_BXPARTY_LANG_REGIST,'submit'));

		$form->display();
	}
}

?>