forked from i-stos/GFactory-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.php
58 lines (46 loc) · 1.55 KB
/
config.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
<?php
// NOTE: Remove error reporting when in production
// error_reporting(E_ALL);
// ini_set('display_errors', 1);
// Define the super path constant
define("GAL_PATH", 'my_galleries');
// Splits camelCased words - Regex on stackoverflow:
// stackoverflow.com/questions/4519739/split-camelcase-word-into-words-with-php-preg-match-regular-expression
function fixCamelCase($file_name) {
$name = "";
$re = '/(?<=[a-z])(?=[A-Z])/x';
$w_array = preg_split($re, $file_name);
$w_count = count($w_array);
if ($w_count > 1) {
for ($i = 0; $i < $w_count; ++$i) {
$name .= $w_array[$i]. " ";
}
// trim on return because an extra space is attached on the concat above
return trim($name);
} else {
return $file_name;
}
}
// Gets a friendly name from an already extracted filename
function fixFileName($file_name) {
$name = str_replace('-', ' ', $file_name);
$name = str_replace('_', ' ', $name);
// Split camelCased words if necessary
$name = fixCamelCase($name);
return ucwords($name);
}
// Gets a friendly name from the file path
function fixFilePath($file_path) {
// Retrieve file name by retrieving the basename and by removing the extension
$name = strstr(basename($file_path), '.', true);
// Remove dash and/or underscore
$name = fixFileName($name);
return ucwords($name);
}
// Autoload function that runs every time we instaniate a class that hasn't been loaded yet and includes it
function __autoload($class) {
$class_path = 'classes/class.'.strtolower($class).'.php';
if (file_exists($class_path)) {
include_once($class_path);
}
}