<?php
#-*- coding: utf-8 -*-
/*---------------------------------------------------------

PHP version 5

<svn>
 * @author	Shintaro Sakata <sakata@seeds.co.jp>
 * @create	2011
 * @version	$Id: init.php 5867 2010-07-21 02:25:30Z sakata $
 * @file	tab-width:4, default-char-code:UTF-8 line-end:LF
---------------------------------------------------------*/
class Frontend
{
    public static function run()
    {
        umask(0);
        mb_language('Japanese');
        mb_regex_encoding('UTF-8');
        mb_detect_order('sjis-win,iso-2022-jp,eucjp-win,UTF-8');
        date_default_timezone_set('Asia/Tokyo');

        define('WKTK_BASE_PATH', realpath(dirname(__FILE__).'/../../'));
        define('WKTK_APPLICATION_PATH', WKTK_BASE_PATH.'/application/contents');

        set_include_path(implode(PATH_SEPARATOR, array(WKTK_BASE_PATH.'/library', WKTK_APPLICATION_PATH.'/models')));

        require_once 'Zend/Registry.php';
        require_once 'Zend/Config/Ini.php';
        $generalConfig = new Zend_Config_Ini(WKTK_BASE_PATH.'/application/general.ini');
        Zend_Registry::set('generalConfig', $generalConfig);

        define('WKTK_SERVER_DOMAIN', $generalConfig->server->domain);
        define('WKTK_SERVER_TYPE', $generalConfig->server->type);
        define('WKTK_SERVER_ENV', $generalConfig->server->env);

        $config = new Zend_Config_Ini(WKTK_BASE_PATH.'/application/config.ini', WKTK_SERVER_TYPE);
        Zend_Registry::set('config', $config);

        require_once 'Zend/Application.php';
        $application = new Zend_Application(WKTK_SERVER_TYPE, WKTK_APPLICATION_PATH.'/configs/application.ini');
        $application->bootstrap()->run();

    }
}

try {
    Frontend::run();
} catch (Exception $e) {
    echo 'システムエラーが発生しました。';
    echo $e;
}
