2008-05-30 11:40:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2011-10-18 17:06:29 +00:00
|
|
|
* Dispatcher takes the URL information, parses it for parameters and
|
2008-05-30 11:40:08 +00:00
|
|
|
* tells the involved controllers what to do.
|
|
|
|
*
|
|
|
|
* This is the heart of Cake's operation.
|
|
|
|
*
|
2010-10-03 16:38:58 +00:00
|
|
|
* PHP 5
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2009-11-06 06:46:59 +00:00
|
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
2011-05-29 21:31:39 +00:00
|
|
|
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2011-05-29 21:31:39 +00:00
|
|
|
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2009-11-06 06:00:11 +00:00
|
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Routing
|
2008-10-30 17:30:26 +00:00
|
|
|
* @since CakePHP(tm) v 0.2.9
|
2009-11-06 06:51:51 +00:00
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2010-12-04 01:23:47 +00:00
|
|
|
App::uses('Router', 'Routing');
|
|
|
|
App::uses('CakeRequest', 'Network');
|
|
|
|
App::uses('CakeResponse', 'Network');
|
2010-12-03 21:24:50 +00:00
|
|
|
App::uses('Controller', 'Controller');
|
2010-12-03 22:38:52 +00:00
|
|
|
App::uses('Scaffold', 'Controller');
|
2010-12-03 21:24:50 +00:00
|
|
|
App::uses('View', 'View');
|
2010-12-04 07:04:30 +00:00
|
|
|
App::uses('Debugger', 'Utility');
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2010-11-14 23:37:27 +00:00
|
|
|
* Dispatcher converts Requests into controller actions. It uses the dispatched Request
|
2011-04-17 11:13:02 +00:00
|
|
|
* to locate and load the correct controller. If found, the requested action is called on
|
2010-11-14 23:37:27 +00:00
|
|
|
* the controller.
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Routing
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2010-06-29 04:13:24 +00:00
|
|
|
class Dispatcher {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Constructor.
|
2011-07-28 17:10:40 +00:00
|
|
|
*
|
|
|
|
* @param string $base The base directory for the application. Writes `App.base` to Configure.
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-07-28 17:10:40 +00:00
|
|
|
public function __construct($base = false) {
|
2008-05-30 11:40:08 +00:00
|
|
|
if ($base !== false) {
|
|
|
|
Configure::write('App.base', $base);
|
|
|
|
}
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2010-11-14 23:37:27 +00:00
|
|
|
* Dispatches and invokes given Request, handing over control to the involved controller. If the controller is set
|
|
|
|
* to autoRender, via Controller::$autoRender, then Dispatcher will render the view.
|
|
|
|
*
|
|
|
|
* Actions in CakePHP can be any public method on a controller, that is not declared in Controller. If you
|
2011-12-02 05:58:09 +00:00
|
|
|
* want controller methods to be public and in-accessible by URL, then prefix them with a `_`.
|
2010-11-14 23:37:27 +00:00
|
|
|
* For example `public function _loadPosts() { }` would not be accessible via URL. Private and protected methods
|
|
|
|
* are also not accessible via URL.
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-11-14 23:37:27 +00:00
|
|
|
* If no controller of given name can be found, invoke() will throw an exception.
|
|
|
|
* If the controller is found, and the action is not found an exception will be thrown.
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-11-14 05:06:01 +00:00
|
|
|
* @param CakeRequest $request Request object to dispatch.
|
2011-07-03 18:16:27 +00:00
|
|
|
* @param CakeResponse $response Response object to put the results of the dispatch into.
|
2008-05-30 11:40:08 +00:00
|
|
|
* @param array $additionalParams Settings array ("bare", "return") which is melded with the GET and POST params
|
|
|
|
* @return boolean Success
|
2010-08-28 03:04:09 +00:00
|
|
|
* @throws MissingControllerException, MissingActionException, PrivateActionException if any of those error states
|
|
|
|
* are encountered.
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-07-03 18:16:27 +00:00
|
|
|
public function dispatch(CakeRequest $request, CakeResponse $response, $additionalParams = array()) {
|
|
|
|
if ($this->asset($request->url, $response) || $this->cached($request->here)) {
|
2010-08-05 03:44:48 +00:00
|
|
|
return;
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2010-05-02 03:19:47 +00:00
|
|
|
|
2011-03-11 03:04:46 +00:00
|
|
|
Router::setRequestInfo($request);
|
2011-10-22 22:48:31 +00:00
|
|
|
$request = $this->parseParams($request, $additionalParams);
|
2011-07-03 18:16:27 +00:00
|
|
|
$controller = $this->_getController($request, $response);
|
2008-05-30 11:40:08 +00:00
|
|
|
|
2011-03-11 03:04:46 +00:00
|
|
|
if (!($controller instanceof Controller)) {
|
2010-08-30 01:37:25 +00:00
|
|
|
throw new MissingControllerException(array(
|
2011-10-16 11:40:36 +00:00
|
|
|
'class' => Inflector::camelize($request->params['controller']) . 'Controller',
|
2011-10-16 11:42:50 +00:00
|
|
|
'plugin' => empty($request->params['plugin']) ? null : Inflector::camelize($request->params['plugin'])
|
2010-08-30 01:37:25 +00:00
|
|
|
));
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2010-11-14 23:38:10 +00:00
|
|
|
|
2011-07-03 18:16:27 +00:00
|
|
|
return $this->_invoke($controller, $request, $response);
|
2010-11-14 23:37:27 +00:00
|
|
|
}
|
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2010-03-28 15:28:03 +00:00
|
|
|
* Initializes the components and models a controller will be using.
|
|
|
|
* Triggers the controller action, and invokes the rendering if Controller::$autoRender is true and echo's the output.
|
|
|
|
* Otherwise the return value of the controller action are returned.
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-11-14 06:05:42 +00:00
|
|
|
* @param Controller $controller Controller to invoke
|
|
|
|
* @param CakeRequest $request The request object to invoke the controller for.
|
2011-07-30 21:02:25 +00:00
|
|
|
* @param CakeResponse $response The response object to receive the output
|
|
|
|
* @return void
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-07-03 18:16:27 +00:00
|
|
|
protected function _invoke(Controller $controller, CakeRequest $request, CakeResponse $response) {
|
2008-07-26 20:09:20 +00:00
|
|
|
$controller->constructClasses();
|
2010-02-28 03:01:08 +00:00
|
|
|
$controller->startupProcess();
|
2008-07-26 20:09:20 +00:00
|
|
|
|
2011-07-09 18:21:32 +00:00
|
|
|
$render = true;
|
2011-07-09 17:56:51 +00:00
|
|
|
$result = $controller->invokeAction($request);
|
2011-07-07 00:41:38 +00:00
|
|
|
if ($result instanceof CakeResponse) {
|
2011-07-09 18:21:32 +00:00
|
|
|
$render = false;
|
2011-07-07 00:41:38 +00:00
|
|
|
$response = $result;
|
|
|
|
}
|
2011-08-16 03:55:08 +00:00
|
|
|
|
2011-07-09 18:21:32 +00:00
|
|
|
if ($render && $controller->autoRender) {
|
2011-07-07 00:41:38 +00:00
|
|
|
$response = $controller->render();
|
2010-08-22 16:40:06 +00:00
|
|
|
} elseif ($response->body() === null) {
|
|
|
|
$response->body($result);
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2010-02-28 03:01:08 +00:00
|
|
|
$controller->shutdownProcess();
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2010-05-01 05:43:06 +00:00
|
|
|
if (isset($request->params['return'])) {
|
2010-08-22 16:40:06 +00:00
|
|
|
return $response->body();
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2010-08-22 16:40:06 +00:00
|
|
|
$response->send();
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2010-11-14 23:43:46 +00:00
|
|
|
* Applies Routing and additionalParameters to the request to be dispatched.
|
2011-06-20 00:28:40 +00:00
|
|
|
* If Routes have not been loaded they will be loaded, and app/Config/routes.php will be run.
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-11-14 23:43:46 +00:00
|
|
|
* @param CakeRequest $request CakeRequest object to mine for parameter information.
|
|
|
|
* @param array $additionalParams An array of additional parameters to set to the request.
|
|
|
|
* Useful when Object::requestAction() is involved
|
|
|
|
* @return CakeRequest The request object with routing params set.
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2010-05-01 14:48:30 +00:00
|
|
|
public function parseParams(CakeRequest $request, $additionalParams = array()) {
|
2010-12-23 04:19:04 +00:00
|
|
|
if (count(Router::$routes) == 0) {
|
2010-11-14 06:12:39 +00:00
|
|
|
$namedExpressions = Router::getNamedExpressions();
|
|
|
|
extract($namedExpressions);
|
2010-12-24 17:54:04 +00:00
|
|
|
$this->_loadRoutes();
|
2010-11-14 06:12:39 +00:00
|
|
|
}
|
2008-05-30 11:40:08 +00:00
|
|
|
|
2010-05-02 04:29:35 +00:00
|
|
|
$params = Router::parse($request->url);
|
|
|
|
$request->addParams($params);
|
2008-05-30 11:40:08 +00:00
|
|
|
|
2010-05-01 05:43:06 +00:00
|
|
|
if (!empty($additionalParams)) {
|
2010-05-02 04:29:35 +00:00
|
|
|
$request->addParams($additionalParams);
|
2009-11-27 06:49:20 +00:00
|
|
|
}
|
2010-05-01 05:43:06 +00:00
|
|
|
return $request;
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
|
|
|
* Get controller to use, either plugin controller or application controller
|
|
|
|
*
|
2011-07-03 18:16:27 +00:00
|
|
|
* @param CakeRequest $request Request object
|
|
|
|
* @param CakeResponse $response Response for the controller.
|
2008-05-30 11:40:08 +00:00
|
|
|
* @return mixed name of controller if not loaded, or object if loaded
|
|
|
|
*/
|
2011-07-03 18:16:27 +00:00
|
|
|
protected function _getController($request, $response) {
|
2010-11-14 06:08:13 +00:00
|
|
|
$ctrlClass = $this->_loadController($request);
|
2009-02-16 00:18:59 +00:00
|
|
|
if (!$ctrlClass) {
|
2010-11-14 23:43:46 +00:00
|
|
|
return false;
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2011-10-01 02:40:30 +00:00
|
|
|
$reflection = new ReflectionClass($ctrlClass);
|
|
|
|
if ($reflection->isAbstract() || $reflection->isInterface()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return $reflection->newInstance($request, $response);
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2010-03-28 15:28:03 +00:00
|
|
|
* Load controller and return controller classname
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2011-07-30 21:02:25 +00:00
|
|
|
* @param CakeRequest $request
|
2008-05-30 11:40:08 +00:00
|
|
|
* @return string|bool Name of controller class name
|
|
|
|
*/
|
2010-11-14 06:08:13 +00:00
|
|
|
protected function _loadController($request) {
|
2008-05-30 11:40:08 +00:00
|
|
|
$pluginName = $pluginPath = $controller = null;
|
2010-05-07 03:18:50 +00:00
|
|
|
if (!empty($request->params['plugin'])) {
|
|
|
|
$pluginName = $controller = Inflector::camelize($request->params['plugin']);
|
2008-05-30 11:40:08 +00:00
|
|
|
$pluginPath = $pluginName . '.';
|
|
|
|
}
|
2010-05-07 03:18:50 +00:00
|
|
|
if (!empty($request->params['controller'])) {
|
|
|
|
$controller = Inflector::camelize($request->params['controller']);
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
if ($pluginPath . $controller) {
|
2010-12-05 15:24:42 +00:00
|
|
|
$class = $controller . 'Controller';
|
|
|
|
App::uses('AppController', 'Controller');
|
2011-02-22 05:14:33 +00:00
|
|
|
App::uses($pluginName . 'AppController', $pluginPath . 'Controller');
|
2010-12-05 15:24:42 +00:00
|
|
|
App::uses($class, $pluginPath . 'Controller');
|
|
|
|
if (class_exists($class)) {
|
|
|
|
return $class;
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2010-12-15 03:58:27 +00:00
|
|
|
/**
|
|
|
|
* Loads route configuration
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2010-12-24 17:54:04 +00:00
|
|
|
protected function _loadRoutes() {
|
2011-04-17 11:13:02 +00:00
|
|
|
include APP . 'Config' . DS . 'routes.php';
|
2010-12-15 03:58:27 +00:00
|
|
|
}
|
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2009-12-16 23:32:20 +00:00
|
|
|
* Outputs cached dispatch view cache
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2011-03-03 02:52:25 +00:00
|
|
|
* @param string $path Requested URL path
|
2011-07-30 21:02:25 +00:00
|
|
|
* @return string|boolean False if is not cached or output
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2011-03-03 02:52:25 +00:00
|
|
|
public function cached($path) {
|
2008-05-30 11:40:08 +00:00
|
|
|
if (Configure::read('Cache.check') === true) {
|
2011-03-03 02:52:25 +00:00
|
|
|
if ($path == '/') {
|
2008-06-12 18:36:08 +00:00
|
|
|
$path = 'home';
|
|
|
|
}
|
2008-12-22 19:01:17 +00:00
|
|
|
$path = strtolower(Inflector::slug($path));
|
2008-06-12 18:36:08 +00:00
|
|
|
|
|
|
|
$filename = CACHE . 'views' . DS . $path . '.php';
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
if (!file_exists($filename)) {
|
2008-06-12 18:36:08 +00:00
|
|
|
$filename = CACHE . 'views' . DS . $path . '_index.php';
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2008-06-10 22:38:05 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
if (file_exists($filename)) {
|
2011-09-17 17:19:43 +00:00
|
|
|
App::uses('ThemeView', 'View');
|
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$controller = null;
|
2011-09-17 17:19:43 +00:00
|
|
|
$view = new ThemeView($controller);
|
2010-08-28 04:19:09 +00:00
|
|
|
return $view->renderCache($filename, microtime(true));
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2009-12-16 23:32:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if a requested asset exists and sends it to the browser
|
|
|
|
*
|
2011-07-03 18:16:27 +00:00
|
|
|
* @param string $url Requested URL
|
|
|
|
* @param CakeResponse $response The response object to put the file contents in.
|
2009-12-16 23:32:20 +00:00
|
|
|
* @return boolean True on success if the asset file was found and sent
|
|
|
|
*/
|
2011-07-03 18:16:27 +00:00
|
|
|
public function asset($url, CakeResponse $response) {
|
2009-12-16 23:32:20 +00:00
|
|
|
if (strpos($url, '..') !== false || strpos($url, '.') === false) {
|
|
|
|
return false;
|
|
|
|
}
|
2010-02-07 20:19:47 +00:00
|
|
|
$filters = Configure::read('Asset.filter');
|
2010-05-02 20:48:35 +00:00
|
|
|
$isCss = (
|
2011-04-17 11:13:02 +00:00
|
|
|
strpos($url, 'ccss/') === 0 ||
|
2010-05-02 20:48:35 +00:00
|
|
|
preg_match('#^(theme/([^/]+)/ccss/)|(([^/]+)(?<!css)/ccss)/#i', $url)
|
|
|
|
);
|
|
|
|
$isJs = (
|
|
|
|
strpos($url, 'cjs/') === 0 ||
|
|
|
|
preg_match('#^/((theme/[^/]+)/cjs/)|(([^/]+)(?<!js)/cjs)/#i', $url)
|
|
|
|
);
|
2010-02-07 20:19:47 +00:00
|
|
|
if (($isCss && empty($filters['css'])) || ($isJs && empty($filters['js']))) {
|
2011-07-03 18:16:27 +00:00
|
|
|
$response->statusCode(404);
|
|
|
|
$response->send();
|
2011-03-10 03:27:19 +00:00
|
|
|
return true;
|
2010-02-07 20:19:47 +00:00
|
|
|
} elseif ($isCss) {
|
2010-03-05 03:04:50 +00:00
|
|
|
include WWW_ROOT . DS . $filters['css'];
|
2011-03-10 03:27:19 +00:00
|
|
|
return true;
|
2010-02-07 20:19:47 +00:00
|
|
|
} elseif ($isJs) {
|
|
|
|
include WWW_ROOT . DS . $filters['js'];
|
2011-03-10 03:27:19 +00:00
|
|
|
return true;
|
2009-12-16 23:32:20 +00:00
|
|
|
}
|
2010-12-13 02:02:42 +00:00
|
|
|
$pathSegments = explode('.', $url);
|
|
|
|
$ext = array_pop($pathSegments);
|
2009-12-16 23:32:20 +00:00
|
|
|
$parts = explode('/', $url);
|
|
|
|
$assetFile = null;
|
|
|
|
|
2010-02-17 04:31:54 +00:00
|
|
|
if ($parts[0] === 'theme') {
|
|
|
|
$themeName = $parts[1];
|
|
|
|
unset($parts[0], $parts[1]);
|
2011-12-01 23:15:46 +00:00
|
|
|
$fileFragment = urldecode(implode(DS, $parts));
|
2010-07-01 00:23:04 +00:00
|
|
|
$path = App::themePath($themeName) . 'webroot' . DS;
|
|
|
|
if (file_exists($path . $fileFragment)) {
|
|
|
|
$assetFile = $path . $fileFragment;
|
2009-12-16 23:32:20 +00:00
|
|
|
}
|
2010-02-17 04:31:54 +00:00
|
|
|
} else {
|
2011-05-09 03:55:32 +00:00
|
|
|
$plugin = Inflector::camelize($parts[0]);
|
|
|
|
if (CakePlugin::loaded($plugin)) {
|
|
|
|
unset($parts[0]);
|
2011-12-01 23:15:46 +00:00
|
|
|
$fileFragment = urldecode(implode(DS, $parts));
|
2011-05-09 03:55:32 +00:00
|
|
|
$pluginWebroot = CakePlugin::path($plugin) . 'webroot' . DS;
|
|
|
|
if (file_exists($pluginWebroot . $fileFragment)) {
|
|
|
|
$assetFile = $pluginWebroot . $fileFragment;
|
|
|
|
}
|
2010-02-17 04:31:54 +00:00
|
|
|
}
|
2009-12-16 23:32:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($assetFile !== null) {
|
2011-07-03 18:16:27 +00:00
|
|
|
$this->_deliverAsset($response, $assetFile, $ext);
|
2009-12-16 23:32:20 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends an asset file to the client
|
|
|
|
*
|
2011-07-03 18:16:27 +00:00
|
|
|
* @param CakeResponse $response The response object to use.
|
2009-12-16 23:32:20 +00:00
|
|
|
* @param string $assetFile Path to the asset file in the file system
|
|
|
|
* @param string $ext The extension of the file to determine its mime type
|
|
|
|
* @return void
|
|
|
|
*/
|
2011-07-03 18:16:27 +00:00
|
|
|
protected function _deliverAsset(CakeResponse $response, $assetFile, $ext) {
|
2010-08-01 01:20:57 +00:00
|
|
|
ob_start();
|
2011-07-03 18:16:27 +00:00
|
|
|
$compressionEnabled = Configure::read('Asset.compress') && $response->compress();
|
|
|
|
if ($response->type($ext) == $ext) {
|
2009-12-16 23:32:20 +00:00
|
|
|
$contentType = 'application/octet-stream';
|
|
|
|
$agent = env('HTTP_USER_AGENT');
|
|
|
|
if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent) || preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {
|
|
|
|
$contentType = 'application/octetstream';
|
|
|
|
}
|
2011-07-03 18:16:27 +00:00
|
|
|
$response->type($contentType);
|
2009-12-16 23:32:20 +00:00
|
|
|
}
|
2011-10-29 04:15:31 +00:00
|
|
|
if (!$compressionEnabled) {
|
|
|
|
$response->header('Content-Length', filesize($assetFile));
|
|
|
|
}
|
2011-07-03 18:16:27 +00:00
|
|
|
$response->cache(filemtime($assetFile));
|
|
|
|
$response->send();
|
2010-08-01 01:20:57 +00:00
|
|
|
ob_clean();
|
2009-12-16 23:32:20 +00:00
|
|
|
if ($ext === 'css' || $ext === 'js') {
|
|
|
|
include($assetFile);
|
|
|
|
} else {
|
|
|
|
readfile($assetFile);
|
|
|
|
}
|
|
|
|
|
2010-07-03 21:21:02 +00:00
|
|
|
if ($compressionEnabled) {
|
2009-12-16 23:32:20 +00:00
|
|
|
ob_end_flush();
|
|
|
|
}
|
|
|
|
}
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|