| 1 |
<?php |
|---|
| 2 |
function __autoload($class) |
|---|
| 3 |
{ |
|---|
| 4 |
$dirs = array('exceptions', |
|---|
| 5 |
'base', |
|---|
| 6 |
'container', |
|---|
| 7 |
'gradients', |
|---|
| 8 |
'elements', |
|---|
| 9 |
'importer', |
|---|
| 10 |
'document', |
|---|
| 11 |
'interfaces'); |
|---|
| 12 |
$pwd = dirname(__FILE__); |
|---|
| 13 |
foreach ($dirs as $dir) |
|---|
| 14 |
{ |
|---|
| 15 |
foreach (array('class', 'interface') as $type) |
|---|
| 16 |
{ |
|---|
| 17 |
$class_file = sprintf('%s%s%s%s%s.%s.php', |
|---|
| 18 |
$pwd, DIRECTORY_SEPARATOR, |
|---|
| 19 |
$dir, DIRECTORY_SEPARATOR, $class, |
|---|
| 20 |
$type); |
|---|
| 21 |
if (file_exists($class_file)) |
|---|
| 22 |
{ |
|---|
| 23 |
if ($type == 'interface') |
|---|
| 24 |
{ |
|---|
| 25 |
interface_exists($class) or require($class_file); |
|---|
| 26 |
} |
|---|
| 27 |
else |
|---|
| 28 |
{ |
|---|
| 29 |
class_exists($class) or require($class_file); |
|---|
| 30 |
} |
|---|
| 31 |
} |
|---|
| 32 |
} |
|---|
| 33 |
} |
|---|
| 34 |
} |
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
function cs_error_handler($code, $message, $file, $line) |
|---|
| 48 |
{ |
|---|
| 49 |
switch ($code) |
|---|
| 50 |
{ |
|---|
| 51 |
case E_USER_ERROR: |
|---|
| 52 |
$type = 'Error'; |
|---|
| 53 |
$exception = 'csException'; |
|---|
| 54 |
break; |
|---|
| 55 |
case E_USER_WARNING: |
|---|
| 56 |
$type = 'Warning'; |
|---|
| 57 |
$exception = 'csException'; |
|---|
| 58 |
break; |
|---|
| 59 |
case E_USER_NOTICE: |
|---|
| 60 |
$type = 'Notice'; |
|---|
| 61 |
$exception = 'csException'; |
|---|
| 62 |
break; |
|---|
| 63 |
default: |
|---|
| 64 |
$type = 'Unknown error'; |
|---|
| 65 |
$exception = 'csException'; |
|---|
| 66 |
break; |
|---|
| 67 |
} |
|---|
| 68 |
$message = sprintf('%s "%s" in %s line %d', |
|---|
| 69 |
$type, $message, $file, $line); |
|---|
| 70 |
throw new $exception($message, $code); |
|---|
| 71 |
} |
|---|
| 72 |
set_error_handler('cs_error_handler'); |
|---|