00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Catalog_Model_Product_Media_Config implements Mage_Media_Model_Image_Config_Interface
00036 {
00037 public function getBaseMediaPath()
00038 {
00039 return Mage::getBaseDir('media') . DS . 'catalog' . DS . 'product';
00040 }
00041
00042 public function getBaseMediaUrl()
00043 {
00044 return Mage::getBaseUrl('media') . 'catalog/product';
00045 }
00046
00047 public function getBaseTmpMediaPath()
00048 {
00049 return Mage::getBaseDir('media') . DS . 'tmp' . DS . 'catalog' . DS . 'product';
00050 }
00051
00052 public function getBaseTmpMediaUrl()
00053 {
00054 return Mage::getBaseUrl('media') . 'tmp/catalog/product';
00055 }
00056
00057 public function getMediaUrl($file)
00058 {
00059 $file = $this->_prepareFileForUrl($file);
00060
00061 if(substr($file, 0, 1) == '/') {
00062 return $this->getBaseMediaUrl() . $file;
00063 }
00064
00065 return $this->getBaseMediaUrl() . '/' . $file;
00066 }
00067
00068 public function getMediaPath($file)
00069 {
00070 $file = $this->_prepareFileForPath($file);
00071
00072 if(substr($file, 0, 1) == DS) {
00073 return $this->getBaseMediaPath() . DS . substr($file, 1);
00074 }
00075
00076 return $this->getBaseMediaPath() . DS . $file;
00077 }
00078
00079 public function getTmpMediaUrl($file)
00080 {
00081 $file = $this->_prepareFileForUrl($file);
00082
00083 if(substr($file, 0, 1) == '/') {
00084 return $this->getBaseTmpMediaUrl() . $file;
00085 }
00086
00087 return $this->getBaseTmpMediaUrl() . '/' . $file;
00088 }
00089
00090 public function getTmpMediaPath($file)
00091 {
00092 $file = $this->_prepareFileForPath($file);
00093
00094 if(substr($file, 0, 1) == DS) {
00095 return $this->getBaseTmpMediaPath() . DS . substr($file, 1);
00096 }
00097
00098 return $this->getBaseTmpMediaPath() . DS . $file;
00099 }
00100
00101 protected function _prepareFileForUrl($file)
00102 {
00103 return str_replace(DS, '/', $file);
00104 }
00105
00106 protected function _prepareFileForPath($file)
00107 {
00108 return str_replace('/', DS, $file);
00109 }
00110 }