<?php
/*
 * shopping/category/Form.class.php
 * 
 * CopyRight(C) 2010 Shopformer Development Team. All Right Reserved
 * URL: http://sourceforge.jp/projects/shopformer/
 * 
 * 
 * Mail: m_nakashima@users.sourceforge.jp
 * Auther: Masanori Nakashima
 * Last Update: 2010-02-12
 * 
 */
require_once( dirname(dirname(__FILE__))
.DIRECTORY_SEPARATOR.'PackageConfig.class.php' );
require_once( dirname(dirname(dirname(__FILE__)))
.DIRECTORY_SEPARATOR.'system'
.DIRECTORY_SEPARATOR.'login'
.DIRECTORY_SEPARATOR.'ModuleBase.class.php');
require_once( dirname(dirname(dirname(__FILE__)))
.DIRECTORY_SEPARATOR.'content'
.DIRECTORY_SEPARATOR.'Uploader.class.php');
require_once( dirname(dirname(__FILE__))
.DIRECTORY_SEPARATOR.'DaoShoppingCategory.class.php');
class shopping_category_Form extends system_login_ModuleBase {
	
	function shopping_category_Form(){
		array_push($this->require_module_array,'database2.Connect');
	}
	function execute( & $request ) {
		
		$dbo					= $request->getAttribute( 'dbo' );
		$shoppingCategoryNumber	= stripslashes( $_GET['shpcn'] );
		$sessionObjectName		= 'shopping.category.modify.object.'.$shoppingCategoryNumber;
		$sessionConfirmName		= 'shopping.category.modify.confirm.'.$shoppingCategoryNumber;
		$shoppingCategoryObject	= $request->getSession($sessionObjectName);
		$request->removeSession($sessionConfirmName);
		if( 'shopping_daoshoppingcategory' == strtolower(get_class($shoppingCategoryObject)) ){
			// セッションに登録済みの場合アップロードファイルがあれば削除
			if( is_object($shoppingCategoryObject->contentUploader)
				&& 'content_uploader' == strtolower(get_class($shoppingCategoryObject->contentUploader)) ) {
				$shoppingCategoryObject->contentUploader->initialize( $request );
			}
		} else {
			// セッションにないなら作成する
			$shoppingCategoryObject	= spider_Controller::createObject('shopping_DaoShoppingCategory');
			if( strlen(trim($shoppingCategoryNumber)) > 0 ) {
				// IDが指定されているなら編集のため読み込み
				if( $dbo->loadByNumber( $shoppingCategoryObject, $shoppingCategoryNumber ) ){
					
				} else {
					$request->addLocaledError('shopping.error.category.notfound',SPIDER_LOG_LEVEL_ERROR,array());
				}
			} else {
				// IDが指定されていないなら新規作成
			}
		}
		$request->setAttribute('shopping.category.category_object',		$shoppingCategoryObject);
		$request->setAttribute('shopping.category.require_columns_hash',	$GLOBALS['SHOPPING_CATEGORY_REQUIRE_COLUMNS_HASH']);
		$request->setAttribute('shopping.category.regist_permit_hash',	$GLOBALS['REGIST_PERMIT_HASH']);
	}
}
?>