/**
     * Add a decimal hash in the image path (to force browser cache expiry)
     * DO NOT USE ON BANNER !
     * ie: "/esibuild/images/cluster_uk/header_logo_fr" => "/esibuild/images/cluster_uk/header_logo_fr/header_logo_fr.15251848.png"
     * @param string $imagePath
     * @return string
     */
    public static function imageDecHash( $imagePath )
    {
        if ( !empty($imagePath) )
        {
            $ini = eZINI::instance();
            if ( $ini->hasVariable('DesignSettings', 'DynamicImageSuffix') && ( $ini->variable('DesignSettings', 'DynamicImageSuffix') == 'enabled' ) )
            {
                $clusterIdentifier = ClusterTool::clusterIdentifier();
                $imageType = basename($imagePath);
                $staticFilePath = ImagePathTool::getStaticPath( $clusterIdentifier, $imageType );

                $fileHandler = eZClusterFileHandler::instance( $staticFilePath );
                if ( $fileHandler instanceof eZDFSFileHandler )
                {
                    $dfsRoot = eZINI::instance('file.ini')->variable( 'eZDFSClusteringSettings', 'MountPointPath' );
                    if ( file_exists( $dfsRoot.'/'.$staticFilePath ) )
                    {
                        $staticFilePath = $dfsRoot.'/'.$staticFilePath;
                    }
                }

                // Add a "fake" filename to the image path if it's missing
                // ie: "/esibuild/images/cluster_uk/header_logo_fr" => "/esibuild/images/cluster_uk/header_logo_fr/header_logo_fr.png"
                $imageInfo = explode('.', $imagePath);
                if ( !isset($imageInfo[1]) )
                {
                    $imagePath .= '/'.basename($imagePath).'.png';
                }

                return self::addDecHash($imagePath, $staticFilePath);
            }
        }

        return $imagePath;
    }
示例#2
0
<?php

/* @type $Params string[] */

$imageType = $Params['ImageType'];
$clusterIdentifier = isset( $Params['ClusterIdentifier'] ) ? $Params['ClusterIdentifier'] : ClusterTool::clusterIdentifier();

if( !ImagePathTool::supports($imageType) )
{
    eZDebug::writeError( "Requested image '{$imageType}' does not exists" );
    header( 'HTTP/1.0 404 Not Found' );
    eZExecution::cleanExit();
}
$oldImagePath = ImagePathTool::getOldPath($clusterIdentifier, $imageType);
$outputFile = ImagePathTool::getStaticPath($clusterIdentifier,$imageType);

$fileUtils = eZClusterFileHandler::instance( $outputFile );
if( !$fileUtils->fileExists( $outputFile ) )
{
    if( !file_exists( $oldImagePath ) )
    {
        $found = false;
        if( $fileUtils instanceof eZDFSFileHandler )
        {
            $dfsRoot = eZINI::instance('file.ini')->variable( 'eZDFSClusteringSettings', 'MountPointPath' );
            if( file_exists( $dfsRoot.'/'.$outputFile ) )
            {
                $oldImagePath = $dfsRoot.'/'.$outputFile;
                $found = true;
            }
        }