/** * @param string $path * @param string $quote * @param bool $skipSlash * @return string */ public static function staticFile($path, $quote, $skipSlash) { $ini = eZINI::instance(); $imgDecHash = 0; if ( $ini->variable( 'DesignSettings', 'DynamicImageSuffix' ) == 'enabled' ) { $cluster = ClusterTool::clusterIdentifier(); $filePath = StaticData::clusterFilePath($cluster, $path); if ( ! empty( $filePath ) ) { $imgHash = sha1_file( $filePath ); $imgDecHash = hexdec( substr( $imgHash, 0, 7 ) ); } } $path = StaticData::externalUrl(ClusterTool::clusterIdentifier(), $path); $path = (!$skipSlash ? '/' : '') . ltrim($path, '/'); if ( ! empty( $imgDecHash ) ) { $path = preg_replace( '/^(.*)\.([^.]+)$/i', '$1.'.$imgDecHash.'.$2', $path ); } if (! $skipSlash ) { $serverURL = eZURI::serverShardingURL( $path ); $path = $serverURL.$path; } if ($quote == 'double') $path = sprintf('"%s"', $path); elseif ($quote == "single") $path = sprintf("'%s'", $path); return $path; }
static function eZImage( $tpl, $operatorValue, $operatorName, $skipSlash = false ) { $sys = eZSys::instance(); if ( $skipSlash && strlen( $sys->wwwDir() ) != 0 ) { $skipSlash = false; } $bases = eZTemplateDesignResource::allDesignBases(); $triedFiles = array(); $fileInfo = eZTemplateDesignResource::fileMatch( $bases, 'images', $operatorValue, $triedFiles ); if ( !$fileInfo ) { $tpl->warning( $operatorName, "Image '$operatorValue' does not exist in any design" ); $tpl->warning( $operatorName, "Tried files: " . implode( ', ', $triedFiles ) ); $siteDesign = eZTemplateDesignResource::designSetting( 'site' ); $imgPath = "design/$siteDesign/images/$operatorValue"; } else { $imgPath = $fileInfo['path']; } $ini = eZINI::instance(); if ( $ini->variable( 'DesignSettings', 'DynamicImageSuffix' ) == 'enabled' ) { $imgHash = sha1_file( $imgPath ); $imgDecHash = hexdec( substr( $imgHash, 0, 7 ) ); $imgPath = preg_replace( '/^(.*)\.([^.]+)$/i', '$1.'.$imgDecHash.'.$2', $imgPath ); } $operatorValue = $skipSlash ? $imgPath : $sys->wwwDir() . '/' . $imgPath; $operatorValue = htmlspecialchars( $operatorValue ); if ( ! $skipSlash ) { $serverURL = eZURI::serverShardingURL( $operatorValue ); $operatorValue = $serverURL.$operatorValue; } return $operatorValue; }