1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27:
28: 29: 30: 31: 32: 33: 34:
35: class Mage_Catalog_Model_Product_Media_Config implements Mage_Media_Model_Image_Config_Interface
36: {
37: 38: 39: 40: 41: 42:
43: public function getBaseMediaPathAddition()
44: {
45: return 'catalog' . DS . 'product';
46: }
47:
48: 49: 50: 51: 52: 53:
54: public function getBaseMediaUrlAddition()
55: {
56: return 'catalog/product';
57: }
58:
59: 60: 61: 62: 63: 64:
65: public function getBaseTmpMediaPathAddition()
66: {
67: return 'tmp' . DS . $this->getBaseMediaPathAddition();
68: }
69:
70: 71: 72: 73: 74: 75:
76: public function getBaseTmpMediaUrlAddition()
77: {
78: return 'tmp/' . $this->getBaseMediaUrlAddition();
79: }
80:
81: public function getBaseMediaPath()
82: {
83: return Mage::getBaseDir('media') . DS . 'catalog' . DS . 'product';
84: }
85:
86: public function getBaseMediaUrl()
87: {
88: return Mage::getBaseUrl('media') . 'catalog/product';
89: }
90:
91: public function getBaseTmpMediaPath()
92: {
93: return Mage::getBaseDir('media') . DS . $this->getBaseTmpMediaPathAddition();
94: }
95:
96: public function getBaseTmpMediaUrl()
97: {
98: return Mage::getBaseUrl('media') . $this->getBaseTmpMediaUrlAddition();
99: }
100:
101: public function getMediaUrl($file)
102: {
103: $file = $this->_prepareFileForUrl($file);
104:
105: if(substr($file, 0, 1) == '/') {
106: return $this->getBaseMediaUrl() . $file;
107: }
108:
109: return $this->getBaseMediaUrl() . '/' . $file;
110: }
111:
112: public function getMediaPath($file)
113: {
114: $file = $this->_prepareFileForPath($file);
115:
116: if(substr($file, 0, 1) == DS) {
117: return $this->getBaseMediaPath() . DS . substr($file, 1);
118: }
119:
120: return $this->getBaseMediaPath() . DS . $file;
121: }
122:
123: public function getTmpMediaUrl($file)
124: {
125: $file = $this->_prepareFileForUrl($file);
126:
127: if(substr($file, 0, 1) == '/') {
128: $file = substr($file, 1);
129: }
130:
131: return $this->getBaseTmpMediaUrl() . '/' . $file;
132: }
133:
134: 135: 136: 137: 138: 139:
140: public function getTmpMediaShortUrl($file)
141: {
142: $file = $this->_prepareFileForUrl($file);
143:
144: if(substr($file, 0, 1) == '/') {
145: $file = substr($file, 1);
146: }
147:
148: return $this->getBaseTmpMediaUrlAddition() . '/' . $file;
149: }
150:
151: 152: 153: 154: 155:
156: public function getMediaShortUrl($file)
157: {
158: $file = $this->_prepareFileForUrl($file);
159:
160: if(substr($file, 0, 1) == '/') {
161: $file = substr($file, 1);
162: }
163:
164: return $this->getBaseMediaUrlAddition() . '/' . $file;
165: }
166:
167: public function getTmpMediaPath($file)
168: {
169: $file = $this->_prepareFileForPath($file);
170:
171: if(substr($file, 0, 1) == DS) {
172: return $this->getBaseTmpMediaPath() . DS . substr($file, 1);
173: }
174:
175: return $this->getBaseTmpMediaPath() . DS . $file;
176: }
177:
178: protected function _prepareFileForUrl($file)
179: {
180: return str_replace(DS, '/', $file);
181: }
182:
183: protected function _prepareFileForPath($file)
184: {
185: return str_replace('/', DS, $file);
186: }
187: }
188: