43 $blGeneratedImagesOnly = !$blDeleteMasterPicture;
45 $sAbsDynImageDir =
$myConfig->getPictureDir(
false);
46 $sMasterImage = basename( $oObject->{
"oxarticles__oxpic".$iIndex}->value );
47 if ( !$sMasterImage || $sMasterImage ==
"nopic.jpg" ) {
51 $aPic = array(
"sField" =>
"oxpic".$iIndex,
52 "sDir" => $oUtilsFile->getImageDirByType(
"M".$iIndex, $blGeneratedImagesOnly ),
53 "sFileName" => $sMasterImage);
55 $blDeleted = $myUtilsPic->safePictureDelete( $aPic[
"sFileName"], $sAbsDynImageDir . $aPic[
"sDir"],
"oxarticles", $aPic[
"sField"] );
63 if ( $this->
getMainIconName( $sMasterImage ) != basename($oObject->oxarticles__oxicon->value) ) {
64 $aDelPics[] = array(
"sField" =>
"oxpic1",
65 "sDir" => $oUtilsFile->getImageDirByType(
"ICO", $blGeneratedImagesOnly ),
71 if ( $this->
getThumbName( $sMasterImage ) != basename($oObject->oxarticles__oxthumb->value) ) {
72 $aDelPics[] = array(
"sField" =>
"oxpic1",
73 "sDir" => $oUtilsFile->getImageDirByType(
"TH", $blGeneratedImagesOnly ),
78 foreach ( $aDelPics as $aPic ) {
79 $myUtilsPic->safePictureDelete( $aPic[
"sFileName"], $sAbsDynImageDir . $aPic[
"sDir"],
"oxarticles", $aPic[
"sField"] );
84 if ( $oObject->{
"oxarticles__oxzoom".$iIndex}->value ) {
85 if ( basename($oObject->{
"oxarticles__oxzoom".$iIndex}->value) !==
"nopic.jpg" ) {
87 $this->deleteZoomPicture( $oObject, $iIndex );
100 public function deleteMainIcon( $oObject )
102 if ( ( $sMainIcon = $oObject->oxarticles__oxicon->value ) ) {
103 $sPath = $this->getConfig()->getPictureDir(
false ) .
oxRegistry::get(
"oxUtilsFile")->getImageDirByType(
"ICO" );
104 oxRegistry::get(
"oxUtilsPic")->safePictureDelete( $sMainIcon, $sPath,
"oxarticles",
"oxicon" );
115 public function deleteThumbnail( $oObject )
117 if ( ( $sThumb = $oObject->oxarticles__oxthumb->value ) ) {
119 $sPath = $this->getConfig()->getPictureDir(
false ) .
oxRegistry::get(
"oxUtilsFile")->getImageDirByType(
"TH" );
120 oxRegistry::get(
"oxUtilsPic")->safePictureDelete( $sThumb, $sPath,
"oxarticles",
"oxthumb" );
132 public function deleteZoomPicture( $oObject, $iIndex )
135 $oDbHandler =
oxNew(
"oxDbMetaDataHandler" );
136 $iZoomPicCount = (int) $this->getConfig()->getConfigParam(
'iZoomPicCount' );
138 if ( $iIndex > $iZoomPicCount || !$oDbHandler->fieldExists(
"oxzoom".$iIndex,
"oxarticles" ) ) {
139 if ( $sZoomPicName = $this->getZoomName( $oObject->{
"oxarticles__oxpic".$iIndex}->value, $iIndex ) ) {
140 $sFieldToCheck =
"oxpic".$iIndex;
145 $sZoomPicName = basename( $oObject->{
"oxarticles__oxzoom".$iIndex}->value );
146 $sFieldToCheck =
"oxzoom".$iIndex;
149 if ( $sZoomPicName && $sZoomPicName !=
"nopic.jpg" ) {
151 $sPath = $this->getConfig()->getPictureDir(
false ) .
oxRegistry::get(
"oxUtilsFile")->getImageDirByType(
"Z" . $iIndex );
152 oxRegistry::get(
"oxUtilsPic")->safePictureDelete( $sZoomPicName, $sPath,
"oxarticles", $sFieldToCheck );
163 public function getIconName( $sFilename )
175 public function getMainIconName( $sMasterImageFile )
177 return $this->_getBaseMasterImageFileName( $sMasterImageFile );
187 public function getThumbName( $sMasterImageFile )
189 return basename( $sMasterImageFile );
200 public function getZoomName( $sMasterImageFile, $iIndex )
202 return basename( $sMasterImageFile );
212 protected function _getBaseMasterImageFileName( $sMasterImageFile )
214 return basename( $sMasterImageFile );
225 public function getImageSize($aImgSizes, $sIndex = null)
227 if (isset($sIndex) && is_array($aImgSizes) && isset($aImgSizes[$sIndex])) {
228 $aSize = explode(
'*', $aImgSizes[$sIndex]);
229 } elseif (is_string ($aImgSizes)) {
230 $aSize = explode(
'*', $aImgSizes);
232 if (2 == count($aSize)) {
254 protected function _getPictureInfo( $sFilePath, $sFile, $blAdmin =
false, $blSSL = null, $iLang = null, $iShopId = null )
257 if ( $sAltUrl = $this->getAltImageUrl($sFilePath, $sFile, $blSSL) ) {
258 return array(
'path' =>
false,
'url'=> $sAltUrl );
261 $oConfig = $this->getConfig();
262 $sPath = $oConfig->getPicturePath( $sFilePath . $sFile, $blAdmin, $iLang, $iShopId );
264 return array(
'path'=>
false,
'url' =>
false );
267 $sDirPrefix = $oConfig->getOutDir();
268 $sUrlPrefix = $oConfig->getOutUrl( $blSSL, $blAdmin, $oConfig->getConfigParam(
'blNativeImages' ) );
270 return array(
'path' => $sPath,
'url'=> str_replace( $sDirPrefix, $sUrlPrefix, $sPath ) );
282 public function getAltImageUrl($sFilePath, $sFile, $blSSL = null)
284 $oConfig = $this->getConfig();
286 $sAltUrl = $oConfig->getConfigParam(
'sAltImageUrl');
288 $sAltUrl = $oConfig->getConfigParam(
'sAltImageDir');
292 if ( (is_null($blSSL) && $oConfig->isSsl()) || $blSSL) {
294 $sSslAltUrl = $oConfig->getConfigParam(
'sSSLAltImageUrl');
295 if ( !$sSslAltUrl ) {
296 $sSslAltUrl = $oConfig->getConfigParam(
'sSSLAltImageDir');
300 $sAltUrl = $sSslAltUrl;
304 if ( !is_null( $sFile ) ) {
305 $sAltUrl .=
'/'.$sFilePath.$sFile;
324 public function getPicUrl( $sPath, $sFile, $sSize, $sIndex = null, $sAltPath =
false, $bSsl = null )
327 if ( $sPath && $sFile && ( $aSize = $this->getImageSize( $sSize, $sIndex ) ) ) {
329 $aPicInfo = $this->_getPictureInfo(
"master/" . ( $sAltPath ? $sAltPath : $sPath ), $sFile, $this->
isAdmin(), $bSsl );
330 if ( $aPicInfo[
'url'] && $aSize[0] && $aSize[1] ) {
331 $sDirName =
"{$aSize[0]}_{$aSize[1]}_" . $this->getConfig()->getConfigParam(
'sDefaultImageQuality' );
332 $sUrl = str_replace(
"/master/" . ( $sAltPath ? $sAltPath : $sPath ),
"/generated/{$sPath}{$sDirName}/", $aPicInfo[
'url'] );
349 public function getProductPicUrl( $sPath, $sFile, $sSize, $sIndex = null, $bSsl = null )
352 if ( !$sFile || !( $sUrl = $this->getPicUrl( $sPath, $sFile, $sSize, $sIndex,
false, $bSsl ) ) ) {
353 $sUrl = $this->getPicUrl( $sPath,
"nopic.jpg", $sSize, $sIndex,
"/", $bSsl );