forked from gengo/gengo-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.php
More file actions
77 lines (69 loc) · 2.36 KB
/
Copy pathinit.php
File metadata and controls
77 lines (69 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* Gengo API Client
*
* LICENSE
*
* This source file is subject to the new BSD license that came
* with this package in the file LICENSE.txt. It is also available
* through the world-wide-web at this URL:
* http://gengo.com/services/api/dev-docs/gengo-code-license
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to contact@gengo.com so we can send you a copy immediately.
*
* @category Gengo
* @package API Client Library
* @copyright Copyright (c) 2009-2012 Gengo, Inc. (http://gengo.com)
* @license http://gengo.com/services/api/dev-docs/gengo-code-license New BSD License
*/
define('GENGO_BASE', dirname(__FILE__));
class Init
{
public function __construct()
{
// We have created an error handler for convenience.
// If you wish to use it, uncomment the following line.
// set_error_handler(array($this, 'error_handler'));
// include this api classpath
$include_path = get_include_path() . PATH_SEPARATOR;
$include_path .= GENGO_BASE .'/libs';
set_include_path($include_path);
// set our own class autoloader if one doesn't already exist
if (false === spl_autoload_functions())
{
if (function_exists('__autoload')) {
spl_autoload_register('__autoload');
}
}
spl_autoload_register(array('Init', 'autoload'));
// set:
// - internal character encoding
// - timezone
mb_internal_encoding('UTF-8');
if (function_exists('date_default_timezone_set'))
{
date_default_timezone_set(Gengo_Config::getInstance()->get('timezone', 'Asia/Tokyo'));
}
}
public function error_handler($errno, $errstr, $errfile = '', $errline = -1, $errctx = null)
{
$ex = new Gengo_Exception($errstr, $errno);
$ex->setFile($errfile);
$ex->setLine($errline);
throw $ex;
}
/**
* We use our own autoloader, but restricted to Gengo classes
**/
public static function autoload($classname)
{
if (false !== strpos($classname, 'Gengo') ||
false !== strpos($classname, 'Zend_'))
{
$classpath = str_replace('_', '/', $classname) . '.php';
require_once $classpath;
}
}
}
new Init();