25 $blGeneratedImagesOnly = !$blDeleteMasterPicture;
27 $sAbsDynImageDir =
$myConfig->getPictureDir(
false);
28 $sMasterImage = basename($oObject->{
"oxarticles__oxpic" . $iIndex}->value);
29 if (!$sMasterImage || $sMasterImage ==
"nopic.jpg") {
33 $aPic = array(
"sField" =>
"oxpic" . $iIndex,
34 "sDir" => $oUtilsFile->getImageDirByType(
"M" . $iIndex, $blGeneratedImagesOnly),
35 "sFileName" => $sMasterImage);
37 $blDeleted = $myUtilsPic->safePictureDelete($aPic[
"sFileName"], $sAbsDynImageDir . $aPic[
"sDir"],
"oxarticles", $aPic[
"sField"]);
45 if ($this->
getMainIconName($sMasterImage) != basename($oObject->oxarticles__oxicon->value)) {
46 $aDelPics[] = array(
"sField" =>
"oxpic1",
47 "sDir" => $oUtilsFile->getImageDirByType(
"ICO", $blGeneratedImagesOnly),
53 if ($this->
getThumbName($sMasterImage) != basename($oObject->oxarticles__oxthumb->value)) {
54 $aDelPics[] = array(
"sField" =>
"oxpic1",
55 "sDir" => $oUtilsFile->getImageDirByType(
"TH", $blGeneratedImagesOnly),
60 foreach ($aDelPics as $aPic) {
61 $myUtilsPic->safePictureDelete($aPic[
"sFileName"], $sAbsDynImageDir . $aPic[
"sDir"],
"oxarticles", $aPic[
"sField"]);
66 if ($oObject->{
"oxarticles__oxzoom" . $iIndex}->value) {
67 if (basename($oObject->{
"oxarticles__oxzoom" . $iIndex}->value) !==
"nopic.jpg") {
69 $this->deleteZoomPicture($oObject, $iIndex);
80 public function deleteMainIcon($oObject)
82 if (($sMainIcon = $oObject->oxarticles__oxicon->value)) {
83 $sPath = $this->getConfig()->getPictureDir(
false) .
oxRegistry::get(
"oxUtilsFile")->getImageDirByType(
"ICO");
84 oxRegistry::get(
"oxUtilsPic")->safePictureDelete($sMainIcon, $sPath,
"oxarticles",
"oxicon");
93 public function deleteThumbnail($oObject)
95 if (($sThumb = $oObject->oxarticles__oxthumb->value)) {
97 $sPath = $this->getConfig()->getPictureDir(
false) .
oxRegistry::get(
"oxUtilsFile")->getImageDirByType(
"TH");
98 oxRegistry::get(
"oxUtilsPic")->safePictureDelete($sThumb, $sPath,
"oxarticles",
"oxthumb");
110 public function deleteZoomPicture($oObject, $iIndex)
113 $oDbHandler =
oxNew(
"oxDbMetaDataHandler");
114 $iZoomPicCount = (int) $this->getConfig()->getConfigParam(
'iZoomPicCount');
116 if ($iIndex > $iZoomPicCount || !$oDbHandler->fieldExists(
"oxzoom" . $iIndex,
"oxarticles")) {
117 if ($sZoomPicName = $this->getZoomName($oObject->{
"oxarticles__oxpic" . $iIndex}->value, $iIndex)) {
118 $sFieldToCheck =
"oxpic" . $iIndex;
123 $sZoomPicName = basename($oObject->{
"oxarticles__oxzoom" . $iIndex}->value);
124 $sFieldToCheck =
"oxzoom" . $iIndex;
127 if ($sZoomPicName && $sZoomPicName !=
"nopic.jpg") {
129 $sPath = $this->getConfig()->getPictureDir(
false) .
oxRegistry::get(
"oxUtilsFile")->getImageDirByType(
"Z" . $iIndex);
130 oxRegistry::get(
"oxUtilsPic")->safePictureDelete($sZoomPicName, $sPath,
"oxarticles", $sFieldToCheck);
141 public function getIconName($sFilename)
153 public function getMainIconName($sMasterImageFile)
155 return $this->_getBaseMasterImageFileName($sMasterImageFile);
165 public function getThumbName($sMasterImageFile)
167 return basename($sMasterImageFile);
178 public function getZoomName($sMasterImageFile, $iIndex)
180 return basename($sMasterImageFile);
190 protected function _getBaseMasterImageFileName($sMasterImageFile)
192 return basename($sMasterImageFile);
203 public function getImageSize($aImgSizes, $sIndex = null)
205 if (isset($sIndex) && is_array($aImgSizes) && isset($aImgSizes[$sIndex])) {
206 $aSize = explode(
'*', $aImgSizes[$sIndex]);
207 } elseif (is_string($aImgSizes)) {
208 $aSize = explode(
'*', $aImgSizes);
210 if (2 == count($aSize)) {
211 $x = (int) $aSize[0];
212 $y = (int) $aSize[1];
233 protected function _getPictureInfo($sFilePath, $sFile, $blAdmin =
false, $blSSL = null, $iLang = null, $iShopId = null)
236 if ($sAltUrl = $this->getAltImageUrl($sFilePath, $sFile, $blSSL)) {
237 return array(
'path' =>
false,
'url' => $sAltUrl);
240 $oConfig = $this->getConfig();
241 $sPath = $oConfig->getPicturePath($sFilePath . $sFile, $blAdmin, $iLang, $iShopId);
243 return array(
'path' =>
false,
'url' =>
false);
246 $sDirPrefix = $oConfig->getOutDir();
247 $sUrlPrefix = $oConfig->getOutUrl($blSSL, $blAdmin, $oConfig->getConfigParam(
'blNativeImages'));
249 return array(
'path' => $sPath,
'url' => str_replace($sDirPrefix, $sUrlPrefix, $sPath));
261 public function getAltImageUrl($sFilePath, $sFile, $blSSL = null)
263 $oConfig = $this->getConfig();
265 $sAltUrl = $oConfig->getConfigParam(
'sAltImageUrl');
267 $sAltUrl = $oConfig->getConfigParam(
'sAltImageDir');
271 if ((is_null($blSSL) && $oConfig->isSsl()) || $blSSL) {
273 $sSslAltUrl = $oConfig->getConfigParam(
'sSSLAltImageUrl');
275 $sSslAltUrl = $oConfig->getConfigParam(
'sSSLAltImageDir');
279 $sAltUrl = $sSslAltUrl;
283 if (!is_null($sFile)) {
303 public function getPicUrl($sPath, $sFile, $sSize, $sIndex = null, $sAltPath =
false, $bSsl = null)
306 if ($sPath && $sFile && ($aSize = $this->getImageSize($sSize, $sIndex))) {
308 $aPicInfo = $this->_getPictureInfo(
"master/" . ($sAltPath ? $sAltPath : $sPath), $sFile, $this->
isAdmin(), $bSsl);
309 if ($aPicInfo[
'url'] && $aSize[0] && $aSize[1]) {
310 $sDirName =
"{$aSize[0]}_{$aSize[1]}_" . $this->getConfig()->getConfigParam(
'sDefaultImageQuality');
311 $sUrl = str_replace(
"/master/" . ($sAltPath ? $sAltPath : $sPath),
"/generated/{$sPath}{$sDirName}/", $aPicInfo[
'url']);
329 public function getProductPicUrl($sPath, $sFile, $sSize, $sIndex = null, $bSsl = null)
332 if (!$sFile || !($sUrl = $this->getPicUrl($sPath, $sFile, $sSize, $sIndex,
false, $bSsl))) {
333 $sUrl = $this->getPicUrl($sPath,
"nopic.jpg", $sSize, $sIndex,
"/", $bSsl);