mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 05:53:13 +00:00
V 3.5 RC 1
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Class Minify_Controller_Files
|
||||
* Class Minify_Controller_Files
|
||||
* @package Minify
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ require_once 'Minify/Controller/Base.php';
|
||||
|
||||
/**
|
||||
* Controller class for minifying a set of files
|
||||
*
|
||||
*
|
||||
* E.g. the following would serve the minified Javascript for a site
|
||||
* <code>
|
||||
* Minify::serve('Files', array(
|
||||
@@ -19,7 +19,7 @@ require_once 'Minify/Controller/Base.php';
|
||||
* )
|
||||
* ));
|
||||
* </code>
|
||||
*
|
||||
*
|
||||
* As a shortcut, the controller will replace "//" at the beginning
|
||||
* of a filename with $_SERVER['DOCUMENT_ROOT'] . '/'.
|
||||
*
|
||||
@@ -27,22 +27,29 @@ require_once 'Minify/Controller/Base.php';
|
||||
* @author Stephen Clay <steve@mrclay.org>
|
||||
*/
|
||||
class Minify_Controller_Files extends Minify_Controller_Base {
|
||||
|
||||
|
||||
/**
|
||||
* Set up file sources
|
||||
*
|
||||
*
|
||||
* @param array $options controller and Minify options
|
||||
* @return array Minify options
|
||||
*
|
||||
*
|
||||
* Controller options:
|
||||
*
|
||||
*
|
||||
* 'files': (required) array of complete file paths, or a single path
|
||||
*/
|
||||
public function setupSources($options) {
|
||||
// strip controller options
|
||||
$files = (array)$options['files'];
|
||||
|
||||
$files = $options['files'];
|
||||
// if $files is a single object, casting will break it
|
||||
if (is_object($files)) {
|
||||
$files = array($files);
|
||||
} elseif (! is_array($files)) {
|
||||
$files = (array)$files;
|
||||
}
|
||||
unset($options['files']);
|
||||
|
||||
|
||||
$sources = array();
|
||||
foreach ($files as $file) {
|
||||
if ($file instanceof Minify_Source) {
|
||||
@@ -52,19 +59,21 @@ class Minify_Controller_Files extends Minify_Controller_Base {
|
||||
if (0 === strpos($file, '//')) {
|
||||
$file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1);
|
||||
}
|
||||
$file = realpath($file);
|
||||
if (file_exists($file)) {
|
||||
$realPath = realpath($file);
|
||||
if (is_file($realPath)) {
|
||||
$sources[] = new Minify_Source(array(
|
||||
'filepath' => $file
|
||||
));
|
||||
'filepath' => $realPath
|
||||
));
|
||||
} else {
|
||||
// file not found
|
||||
$this->log("The path \"{$file}\" could not be found (or was not a file)");
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
if ($sources) {
|
||||
$this->sources = $sources;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user