<?php
/*
 * content/widget/html/Load.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(dirname(__FILE__))))
	.DIRECTORY_SEPARATOR.'system'
	.DIRECTORY_SEPARATOR.'login'
	.DIRECTORY_SEPARATOR.'ModuleBase.class.php');
require_once( dirname(dirname(dirname(__FILE__)))
	.DIRECTORY_SEPARATOR.'DaoWidget.class.php');
require_once( dirname(dirname(dirname(__FILE__)))
	.DIRECTORY_SEPARATOR.'Variable.class.php');
class content_widget_html_Load extends system_login_ModuleBase {
	function content_widget_html_Load() {
		array_push($this->require_module_array,'content.widget.setting.Load');
	}
	function execute( & $request ) {
		if( !$request->isError() ) {
			$agent			= strtolower(trim(stripslashes($_GET['agent'])));
			$widgetObject	= $request->getAttribute('content.widget.widgetObject' );
			$isExistAgent	= false;
			$bodyStrings	= '';
			foreach( $GLOBALS['SPIDER_USER_AGENT_CLASS_HASH'] as $agentType => $agentName ) {
				if( $agentType == $agent ) {
					$bodyStrings	= $widgetObject->getBody( $request, $agent );
					$isExistAgent	= true;
					break;
				}
			}
			if( !$isExistAgent ) {
				$agent			= 'default';
				$bodyStrings	= $widgetObject->getBody( $request, $agent );
			}
			$request->setAttribute('content.widget.html.agent',$agent);
			$request->setAttribute('content.widget.html.body', $bodyStrings );
		}
	}
}
?>