<?php
/*
 * content/widget/LoadList.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-08-23
 */
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.'system'
	.DIRECTORY_SEPARATOR.'DataFileWriter.class.php');
require_once( dirname(dirname(__FILE__))
	. DIRECTORY_SEPARATOR.'DaoWidget.class.php' );
require_once( dirname(dirname(__FILE__))
	. DIRECTORY_SEPARATOR.'package_define.inc.php' );
class content_widget_LoadList extends system_login_ModuleBase {
	function content_widget_LoadList() {
	}
	function execute( & $request ) {
		$widgetObjectArray	= array();
		$widgetSaveRoot		= '/content/widget';
		$rootAbsolutePath	= system_DataFileWriter::getRealAbsolutePath( $request, $widgetSaveRoot );
		if (is_dir($rootAbsolutePath)) {
			if ($dh = opendir($rootAbsolutePath)) {
				while (($fileName	= readdir($dh)) !== false) {
					if( preg_match('/^\\./',$fileName) == 0 ) {
						$absolutePath	= $rootAbsolutePath.DIRECTORY_SEPARATOR.$fileName;
						if( is_dir($absolutePath)
							&& file_exists($absolutePath.DIRECTORY_SEPARATOR.'info.txt') ) {
							$widgetObject	= new content_DaoWidget($fileName);
							if( $widgetObject->load( $request ) ) {
								$widgetObjectArray[$fileName]	= $widgetObject;
							}
						}
					}
				}
			}
		}
		ksort($widgetObjectArray);
		$request->setAttribute('content.widget.widgetObjectArray',$widgetObjectArray);
	}
}
?>