Skip to content

Commit

Permalink
Removing limit of image, js and css in plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
phpnut committed Nov 25, 2009
1 parent c942fa7 commit 0977029
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 31 deletions.
42 changes: 14 additions & 28 deletions cake/dispatcher.php
Expand Up @@ -600,41 +600,27 @@ function getUrl($uri = null, $base = null) {
* @access public
*/
function cached($url) {
if (strpos($url, '.ico') !== false || strpos($url, 'css/') !== false || strpos($url, 'js/') !== false || strpos($url, 'img/') !== false) {
if (strpos($url, '.')) {
if (strpos($url, 'ccss/') === 0) {
include WWW_ROOT . DS . Configure::read('Asset.filter.css');
$this->_stop();
} elseif (strpos($url, 'cjs/') === 0) {
include WWW_ROOT . DS . Configure::read('Asset.filter.js');
$this->_stop();
}
$isAsset = false;
$assets = array(
'js' => 'text/javascript',
'css' => 'text/css',
'gif' => 'image/gif',
'jpg' => 'image/jpeg',
'png' => 'image/png',
'ico' => 'image/vnd.microsoft.icon'
);
App::import('View', 'Media', false);
$Media = new MediaView();
$ext = array_pop(explode('.', $url));

foreach ($assets as $type => $contentType) {
if ($type === $ext) {
$parts = explode('/', $url);
if ($parts[0] === 'css' || $parts[0] === 'js' || $parts[0] === 'img') {
$pos = 0;
} elseif ($parts[0] === 'theme') {
$pos = strlen($parts[0] . $parts[1]) + 1;
} elseif (count($parts) > 2) {
$pos = strlen($parts[0]);
}
$isAsset = true;
break;

if (isset($Media->mimeType[$ext])) {
$parts = explode('/', $url);
if ($parts[0] === 'css' || $parts[0] === 'js' || $parts[0] === 'img') {
$pos = 0;
} elseif ($parts[0] === 'theme') {
$pos = strlen($parts[0] . $parts[1]) + 1;
} elseif (count($parts) > 2) {
$pos = strlen($parts[0]);
}
}

if ($isAsset === true) {
$ob = @ini_get("zlib.output_compression") !== '1' && extension_loaded("zlib") && (strpos(env('HTTP_ACCEPT_ENCODING'), 'gzip') !== false);

if ($ob && Configure::read('Asset.compress')) {
Expand Down Expand Up @@ -680,11 +666,11 @@ function cached($url) {
if ($assetFile !== null) {
$fileModified = filemtime($assetFile);
header("Date: " . date("D, j M Y G:i:s ", $fileModified) . 'GMT');
header('Content-type: ' . $assets[$type]);
header('Content-type: ' . $Media->mimeType[$ext]);
header("Expires: " . gmdate("D, j M Y H:i:s", time() + DAY) . " GMT");
header("Cache-Control: cache");
header("Pragma: cache");
if ($type === 'css' || $type === 'js') {
if ($ext === 'css' || $ext === 'js') {
include($assetFile);
} else {
readfile($assetFile);
Expand Down
5 changes: 2 additions & 3 deletions cake/libs/view/media.php
Expand Up @@ -17,7 +17,7 @@
* @since CakePHP(tm) v 1.2.0.5714
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
class MediaView extends View {
class MediaView {

/**
* Holds known mime type mappings
Expand Down Expand Up @@ -90,8 +90,7 @@ class MediaView extends View {
*
* @param object $controller
*/
function __construct(&$controller) {
parent::__construct($controller);
function __construct($controller = null) {
}

/**
Expand Down

0 comments on commit 0977029

Please sign in to comment.