<?php
/*
 * content/LoadFolder.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-06-18
 */
require_once( dirname(dirname(__FILE__))
	.DIRECTORY_SEPARATOR.'system'
	.DIRECTORY_SEPARATOR.'login'
	.DIRECTORY_SEPARATOR.'ModuleBase.class.php');
require_once( dirname(dirname(__FILE__))
	.DIRECTORY_SEPARATOR.'system'
	.DIRECTORY_SEPARATOR.'DataFileWriter.class.php');
require_once( dirname(__FILE__)
	. DIRECTORY_SEPARATOR . 'package_define.inc.php' );
class content_LoadFolder extends system_login_ModuleBase {
	
	function content_LoadFolder() {
	}
	function execute( & $request ) {

		$targetFolder		= mb_convert_kana( trim( stripslashes( $_GET['ccurf'] ) ), 'KVas' );
		if( strlen($targetFolder) == 0 ) {
			$targetFolder		= '/';
		}
		// ディレクトリ一覧の作成
		$folderNameArray	= array();
		$targetRealPath	= system_DataFileWriter::getRealAbsolutePath($request,$targetFolder,'public');
		if ($dh = opendir($targetRealPath)) {
			while (($fileName	= readdir($dh)) !== false) {
				if( preg_match('/^\\./',$fileName) == 0 && 'tmp' != $fileName ) {
					$absolutePath	= $targetRealPath.DIRECTORY_SEPARATOR.$fileName;
					if( is_dir($absolutePath) ) {
						array_push($folderNameArray,$fileName);
					}
				}
			}
			closedir($dh);
		}		
		$request->setAttribute('content.targetFolder',$targetFolder);
		$request->setAttribute('content.folderNameArray',$folderNameArray);
	}
}
?>