<?php
/**
 * ryusSetIphoneTheme
 * @author Mika UMOTO http://ryus.co.jp/
 */
class ryusSetIphoneTheme extends XCube_ActionFilter
{
    var $iphone_theme = 'aipon4s'; // iPhone theme name.

	function preBlockFilter()
	{
         $this->mController->mSetupUser->add(array(&$this, 'setIphoneTheme'));
	}
	
	function setIphoneTheme()
	{
		global $xoopsConfig ;
		if(array_key_exists("iphone_to_pc", $_GET)) {
			$_SESSION['iphone_to_pc']=$_GET['iphone_to_pc'];
		}
		if (array_key_exists("iphone_to_pc", $_SESSION)) {
			if($_SESSION['iphone_to_pc']=="pc"){
				$this->mRoot->mContext->setThemeName($xoopsConfig['theme_set']);
				$_SESSION['iphone_to_pc']="pc";
				return;
			}elseif($_SESSION['iphone_to_pc']=="iphone"){
				$this->mRoot->mContext->setThemeName($this->iphone_theme);
				$_SESSION['iphone_to_pc']="iphone";
				return;
			}
		}
		$is_iphone=false;
		$is_ipod=false;
		$is_pc=false;
		if(strpos($_SERVER['HTTP_USER_AGENT'],"iPhone")){
			$is_iphone=true;
		} elseif(strpos($_SERVER['HTTP_USER_AGENT'],"Android")){
			$is_ipod=true;
		} elseif(strpos($_SERVER['HTTP_USER_AGENT'],"iPod")){
			$is_ipod=true;
		} else {
			$is_pc=true;
		}
		if(($is_iphone==true) or ($is_ipod==true)){
			$this->mRoot->mContext->setThemeName($this->iphone_theme);
		} else {
			$this->mRoot->mContext->setThemeName($xoopsConfig['theme_set']);
		}
	}

}

?>