| Server IP : 54.36.91.62 / Your IP : 216.73.217.111 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/libraries/compojoom/shrink/ |
Upload File : |
<?php
/**
* @package Lib_Compojoom
* @author DanielDimitrov <daniel@compojoom.com>
* @date 20.08.14
*
* @copyright Copyright (C) 2008 - 2013 compojoom.com . All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('_JEXEC') or die('Restricted access');
/**
* Class CompojoomShrink
*
* @since 4.0
*/
class CompojoomShrink
{
/**
* Function that will merge & minify the provided files
*
* @param array $files - array with relative paths to js files
* @param string $cachePath - where to save the new merged & minified file
*
* @return string
*/
public static function shrink(array $files, $cachePath)
{
$times = array();
$md5 = md5(json_encode($files));
$url = $cachePath . '/' . $md5 . '.min.js';
$minFile = JPATH_ROOT . '/' . $url;
// Lets read the times of the files we need to merge
foreach ($files as $file)
{
if (file_exists(JPATH_ROOT . '/' . $file))
{
$times[] = filemtime(JPATH_ROOT . '/' . $file);
}
}
if (!count($times))
{
return $url;
}
// If the minFile doesn't exist or the minFile time is older than any of the times, let's do our job!
if (!file_exists($minFile) || max($times) > filemtime($minFile))
{
$js = array();
foreach ($files as $file)
{
if (file_exists(JPATH_ROOT . '/' . $file))
{
$js[] = file_get_contents(JPATH_ROOT . '/' . $file);
}
}
// Do the actual minifying
$minJs = CompojoomMinifier::minify(implode($js));
JFile::write($minFile, $minJs);
}
return $url;
}
}