forked from scaphare/QGoogleVisualizationAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.inc.php
62 lines (51 loc) · 1.29 KB
/
config.inc.php
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
<?php
if(!defined('DS'))
{
define("DS", DIRECTORY_SEPARATOR);
}
if(!defined('CLASSESDIR'))
{
define("CLASSESDIR", dirname(__FILE__).DIRECTORY_SEPARATOR."classes");
}
if(!function_exists('js_replace'))
{
function js_replace($search, $replacePairs) {
return preg_replace(array_keys($replacePairs), array_values($replacePairs), $search);
}
}
if(!function_exists('includeFile'))
{
function includeFile($classFile)
{
if(is_file($classFile)) {
include $classFile;
return true;
} else {
return false;
}
}
}
function googleAutoload($class) {
$hasIncluded = false;
$hasIncluded2 = false;
$strClassPath = $class;
// [className].php in basedir
$hasIncluded = includeFile(dirname(__FILE__).DIRECTORY_SEPARATOR.$class.".php");
if (empty($hasIncluded) and substr($strClassPath, 0, strlen("Google")) === 'Google')
{
$classFile = CLASSESDIR
. DIRECTORY_SEPARATOR
. str_replace("_",DIRECTORY_SEPARATOR,$strClassPath)
. '.php';
$hasIncluded = includeFile($classFile);
if($hasIncluded)
{
$hasIncluded2 = true;
}
}
if(empty($hasIncluded))
{
throw new InvalidArgumentException("autoloading of class $class impossible. Namespace syntax for classes seems to be wrong.");
}
}
spl_autoload_register('googleAutoload');