Enabling global loading of JavaScript and CSS files thru vendors folder

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3128 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2006-06-18 05:16:23 +00:00
parent 1cca718150
commit 3d4b5ebc09

View file

@ -34,7 +34,7 @@
require APP_PATH . 'config' . DS . 'core.php'; require APP_PATH . 'config' . DS . 'core.php';
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php'; require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
} }
$TIME_START=getMicrotime(); $TIME_START = getMicrotime();
require LIBS . 'object.php'; require LIBS . 'object.php';
require LIBS . 'session.php'; require LIBS . 'session.php';
require LIBS . 'security.php'; require LIBS . 'security.php';
@ -54,7 +54,7 @@
} else { } else {
if (strpos($uri, 'index.php') !== false) { if (strpos($uri, 'index.php') !== false) {
$uri = r('?', '', $uri); $uri = r('?', '', $uri);
$elements=explode('/index.php', $uri); $elements = explode('/index.php', $uri);
} else { } else {
$elements = explode('/?', $uri); $elements = explode('/?', $uri);
} }
@ -77,7 +77,18 @@
if (strpos($url, 'ccss/') === 0) { if (strpos($url, 'ccss/') === 0) {
include WWW_ROOT . DS . 'css.php'; include WWW_ROOT . DS . 'css.php';
die(); exit();
}
$folders = array('js' => 'text/javascript', 'css' => 'text/css');
$requestPath = explode('/', $url);
if (in_array($requestPath[0], array_keys($folders))) {
if (file_exists(VENDORS . join(DS, $requestPath))) {
header('Content-type: ' . $folders[$requestPath[0]]);
e(file_get_contents(VENDORS . join(DS, $requestPath)));
exit();
}
} }
if (DEBUG) { if (DEBUG) {
@ -89,6 +100,7 @@
} else { } else {
error_reporting(0); error_reporting(0);
} }
require CAKE . 'dispatcher.php'; require CAKE . 'dispatcher.php';
require LIBS . 'model' . DS . 'connection_manager.php'; require LIBS . 'model' . DS . 'connection_manager.php';
config('database'); config('database');
@ -101,7 +113,7 @@
if (empty($uri)) { if (empty($uri)) {
$uri = setUri(); $uri = setUri();
} }
$filename=CACHE . 'views' . DS . convertSlash($uri) . '.php'; $filename = CACHE . 'views' . DS . convertSlash($uri) . '.php';
if (file_exists($filename)) { if (file_exists($filename)) {
uses(DS . 'controller' . DS . 'component', DS . 'view' . DS . 'view'); uses(DS . 'controller' . DS . 'component', DS . 'view' . DS . 'view');