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: class Mage_XmlConnect_Model_Preview_Ipad extends Mage_XmlConnect_Model_Preview_Abstract
35: {
36: 37: 38: 39: 40:
41: protected $_orientation = 'unknown';
42:
43: 44: 45: 46: 47: 48:
49: public function setOrientation($orientation)
50: {
51: $this->_orientation = $orientation;
52: return $this;
53: }
54:
55: 56: 57: 58: 59:
60: public function getOrientation()
61: {
62: return $this->_orientation;
63: }
64:
65: 66: 67: 68: 69:
70: public function getBannerImage()
71: {
72: $orientation = $this->getOrientation();
73: switch ($orientation) {
74: case Mage_XmlConnect_Helper_Ipad::ORIENTATION_LANDSCAPE:
75: $configPath = 'conf/body/bannerIpadLandscapeImage';
76: $imageUrlOrig = $this->getData($configPath);
77: if ($imageUrlOrig) {
78: $width = Mage_XmlConnect_Helper_Ipad::PREVIEW_LANDSCAPE_BANNER_WIDTH;
79: $height = Mage_XmlConnect_Helper_Ipad::PREVIEW_LANDSCAPE_BANNER_HEIGHT;
80: $bannerImage = Mage::helper('xmlconnect/image')
81: ->getCustomSizeImageUrl($imageUrlOrig, $width, $height);
82: } else {
83: $bannerImage = $this->getPreviewImagesUrl('ipad/banner_image_l.png');
84: }
85: break;
86: case Mage_XmlConnect_Helper_Ipad::ORIENTATION_PORTRAIT:
87: $configPath = 'conf/body/bannerIpadImage';
88: $imageUrlOrig = $this->getData($configPath);
89: if ($imageUrlOrig) {
90: $width = Mage_XmlConnect_Helper_Ipad::PREVIEW_PORTRAIT_BANNER_WIDTH;
91: $height = Mage_XmlConnect_Helper_Ipad::PREVIEW_PORTRAIT_BANNER_HEIGHT;
92: $bannerImage = Mage::helper('xmlconnect/image')
93: ->getCustomSizeImageUrl($imageUrlOrig, $width, $height);
94: } else {
95: $bannerImage = $this->getPreviewImagesUrl('ipad/banner_image.png');
96: }
97: break;
98: }
99: return $bannerImage;
100: }
101:
102: 103: 104: 105: 106: 107:
108: public function getBackgroundImage()
109: {
110: $orientation = $this->getOrientation();
111: $backgroundImage = '';
112:
113: $helperImage = Mage::helper('xmlconnect/image');
114:
115: switch ($orientation) {
116: case Mage_XmlConnect_Helper_Ipad::ORIENTATION_LANDSCAPE:
117: $configPath = 'conf/body/backgroundIpadLandscapeImage';
118: $imageUrlOrig = $this->getData($configPath);
119: if ($imageUrlOrig) {
120: $width = Mage_XmlConnect_Helper_Ipad::PREVIEW_LANDSCAPE_BACKGROUND_WIDTH;
121: $height = Mage_XmlConnect_Helper_Ipad::PREVIEW_LANDSCAPE_BACKGROUND_HEIGHT;
122: $backgroundImage = $helperImage->getCustomSizeImageUrl($imageUrlOrig, $width, $height);
123: } else {
124: $backgroundImage = $this->getPreviewImagesUrl('ipad/background_home_landscape.jpg');
125: }
126: break;
127: case Mage_XmlConnect_Helper_Ipad::ORIENTATION_PORTRAIT:
128: $configPath = 'conf/body/backgroundIpadPortraitImage';
129: $imageUrlOrig = $this->getData($configPath);
130: if ($imageUrlOrig) {
131: $width = Mage_XmlConnect_Helper_Ipad::PREVIEW_PORTRAIT_BACKGROUND_WIDTH;
132: $height = Mage_XmlConnect_Helper_Ipad::PREVIEW_PORTRAIT_BACKGROUND_HEIGHT;
133: $backgroundImage = $helperImage->getCustomSizeImageUrl($imageUrlOrig, $width, $height);
134: } else {
135: $backgroundImage = $this->getPreviewImagesUrl('ipad/background_portrait.jpg');
136: }
137: break;
138: default:
139: Mage::throwException(
140: Mage::helper('xmlconnect')->__('Wrong Ipad background image orientation has been specified: "%s".', $orientation)
141: );
142: break;
143: }
144: return $backgroundImage;
145: }
146: }
147: