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_Block_Adminhtml_Mobile_Submission_Tab_Container_Submission
35: extends Mage_XmlConnect_Block_Adminhtml_Mobile_Widget_Form
36: implements Mage_Adminhtml_Block_Widget_Tab_Interface
37: {
38:
39: 40: 41: 42:
43: public function __construct()
44: {
45: parent::__construct();
46: $this->setShowGlobalIcon(true);
47: }
48:
49: 50: 51: 52: 53:
54: protected function _prepareLayout()
55: {
56: $block = $this->getLayout()->createBlock('adminhtml/template')
57: ->setTemplate('xmlconnect/submission/app_icons_preview.phtml')
58: ->setImages(Mage::helper('xmlconnect')->getApplication()->getImages());
59: $this->setChild('images', $block);
60: parent::_prepareLayout();
61: }
62:
63: 64: 65: 66: 67: 68: 69: 70: 71: 72:
73: public function addImage($fieldset, $fieldName, $title, $note = '', $default = '', $required = false)
74: {
75: $fieldset->addField($fieldName, 'image', array(
76: 'name' => $fieldName,
77: 'label' => $title,
78: 'note' => !empty($note) ? $note : null,
79: 'default_value' => $default,
80: 'required' => $required,
81: ));
82: }
83:
84: 85: 86: 87: 88:
89: protected function _prepareForm()
90: {
91: $deviceType = Mage::helper('xmlconnect')->getDeviceType();
92: $form = new Varien_Data_Form();
93: $this->setForm($form);
94:
95: $app = Mage::helper('xmlconnect')->getApplication();
96: $form->setAction($this->getUrl('*/mobile/submission'));
97: $isResubmit = $app->getIsResubmitAction();
98: $formData = $app->getFormData();
99:
100: $url = Mage::getStoreConfig('xmlconnect/mobile_application/activation_key_url');
101: $afterElementHtml = $this->__('In order to submit your app, you need to first purchase a <a href="%s" target="_blank">%s</a> from MagentoCommerce', $url, $this->__('Activation Key'));
102: $fieldset = $form->addFieldset('submit_keys', array('legend' => $this->__('Key')));
103: $field = $fieldset->addField('conf[submit_text][key]', 'text', array(
104: 'name' => 'conf[submit_text][key]',
105: 'label' => $this->__('Activation Key'),
106: 'value' => isset($formData['conf[submit_text][key]']) ? $formData['conf[submit_text][key]'] : null,
107: 'after_element_html' => $afterElementHtml,
108: ));
109: if (!$isResubmit) {
110: $field->setRequired(true);
111: } else {
112: $field->setDisabled('disabled');
113: $fieldset->addField('conf[submit_text][key]_hidden', 'hidden', array(
114: 'name' => 'conf[submit_text][key]',
115: 'value' => isset($formData['conf[submit_text][key]']) ? $formData['conf[submit_text][key]'] : null,
116: ));
117: }
118:
119: if ($isResubmit) {
120: $url = Mage::getStoreConfig('xmlconnect/mobile_application/resubmission_key_url');
121: $rsText = $this->__('Resubmission Key');
122: $afterElementHtml = $this->__('In order to resubmit your app, you need to first purchase a <a href="%s" target="_blank">%s</a> from MagentoCommerce', $url, $rsText);
123:
124: if (isset($formData['conf[submit_text][resubmission_activation_key]'])) {
125: $rsKeyVal = $formData['conf[submit_text][resubmission_activation_key]'];
126: } else {
127: $rsKeyVal = null;
128: }
129:
130: $fieldset->addField('conf[submit_text][resubmission_activation_key]', 'text', array(
131: 'name' => 'conf[submit_text][resubmission_activation_key]',
132: 'label' => $this->__('Resubmission Key'),
133: 'value' => $rsKeyVal,
134: 'required' => true,
135: 'after_element_html' => $afterElementHtml,
136: ));
137: }
138:
139: $fieldset = $form->addFieldset('submit_general', array('legend' => $this->__('Submission Fields')));
140:
141: $fieldset->addField('submission_action', 'hidden', array(
142: 'name' => 'submission_action',
143: 'value' => '1',
144: ));
145:
146: switch ($deviceType) {
147: case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPHONE:
148: $titleLength = Mage_XmlConnect_Helper_Iphone::SUBMISSION_TITLE_LENGTH;
149: $descriptionLength = Mage_XmlConnect_Helper_Iphone::SUBMISSION_DESCRIPTION_LENGTH;
150: $descriptionNote = $this->__('Description that appears in the iTunes App Store. %s chars maximum. ', $descriptionLength);
151: break;
152: case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPAD:
153: $titleLength = Mage_XmlConnect_Helper_Ipad::SUBMISSION_TITLE_LENGTH;
154: $descriptionLength = Mage_XmlConnect_Helper_Ipad::SUBMISSION_DESCRIPTION_LENGTH;
155: $descriptionNote = $this->__('Description that appears in the iTunes App Store. %s chars maximum. ', $descriptionLength);
156: break;
157: case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_ANDROID:
158: $titleLength = Mage_XmlConnect_Helper_Android::SUBMISSION_TITLE_LENGTH;
159: $descriptionLength = Mage_XmlConnect_Helper_Android::SUBMISSION_DESCRIPTION_LENGTH;
160: $descriptionNote = $this->__('Description that appears in Android Market. %s chars maximum. ', $descriptionLength);
161: break;
162: }
163:
164: $titleNote = $this->__('Name that appears beneath your app when users install it to their device. We recommend choosing a name that is 10-12 characters and that your customers will recognize. %s chars max.', $titleLength);
165:
166: $fieldset->addField('conf/submit_text/title', 'text', array(
167: 'name' => 'conf[submit_text][title]',
168: 'label' => $this->__('Title'),
169: 'maxlength' => $titleLength,
170: 'value' => isset($formData['conf[submit_text][title]']) ? $formData['conf[submit_text][title]'] : null,
171: 'note' => $titleNote,
172: 'required' => true,
173: ));
174:
175: if (isset($formData['conf[submit_text][description]'])) {
176: $descrVal = $formData['conf[submit_text][description]'];
177: } else {
178: $descrVal = null;
179: }
180:
181: $field = $fieldset->addField('conf/submit_text/description', 'textarea', array(
182: 'name' => 'conf[submit_text][description]',
183: 'label' => $this->__('Description'),
184: 'maxlength' => $descriptionLength,
185: 'value' => $descrVal,
186: 'note' => $descriptionNote,
187: 'required' => true,
188: ));
189: $field->setRows(15);
190:
191: $fieldset->addField('conf/submit_text/contact_email', 'text', array(
192: 'name' => 'conf[submit_text][email]',
193: 'label' => $this->__('Contact Email'),
194: 'class' => 'email',
195: 'maxlength' => '40',
196: 'value' => isset($formData['conf[submit_text][email]']) ? $formData['conf[submit_text][email]'] : null,
197: 'note' => $this->__('Administrative contact for this app and for app submission issues.'),
198: 'required' => true,
199: ));
200:
201: $fieldset->addField('conf/submit_text/price_free_label', 'label', array(
202: 'name' => 'conf[submit_text][price_free_label]',
203: 'label' => $this->__('Price'),
204: 'value' => $this->__('Free'),
205: 'maxlength' => '40',
206: 'checked' => 'checked',
207: 'note' => $this->__('Only free apps are allowed in this version.'),
208: ));
209:
210: $fieldset->addField('conf/submit_text/price_free', 'hidden', array(
211: 'name' => 'conf[submit_text][price_free]',
212: 'value' => '1',
213: ));
214:
215: if (isset($formData['conf[submit_text][country]'])) {
216: $selected = explode(',', $formData['conf[submit_text][country]']);
217: } else {
218: $selected = null;
219: }
220:
221: $deviceHelper = Mage::helper('xmlconnect')->getDeviceHelper();
222: $fieldset->addType('country', 'Mage_XmlConnect_Block_Adminhtml_Mobile_Form_Element_Country');
223: $fieldset->addField('conf/submit_text/country', 'country', array(
224: 'id' => 'submission-countries',
225: 'name' => 'conf[submit_text][country][]',
226: 'label' => $deviceHelper->getCountryLabel(),
227: 'values' => Mage::helper('xmlconnect')->getCountryOptionsArray(),
228: 'value' => $selected,
229: 'note' => $this->__('Make this app available in the following territories'),
230: 'columns' => $deviceHelper->getCountryColumns(),
231: 'place_name_left' => $deviceHelper->isCountryNamePlaceLeft(),
232: 'class' => $deviceHelper->getCountryClass(),
233: 'required' => true,
234: ))
235: ->setRenderer($deviceHelper->getCountryRenderer());
236:
237: if (isset($formData['conf[submit_text][copyright]'])) {
238: $copyVal = $formData['conf[submit_text][copyright]'];
239: } else {
240: $copyVal = null;
241: }
242:
243: $fieldset->addField('conf/submit_text/copyright', 'text', array(
244: 'name' => 'conf[submit_text][copyright]',
245: 'label' => $this->__('Copyright'),
246: 'maxlength' => '200',
247: 'value' => $copyVal,
248: 'note' => $this->__('Appears in the info section of your app (example: Copyright 2010 – Your Company, Inc.)'),
249: 'required' => true,
250: ));
251:
252: if ($deviceType !== Mage_XmlConnect_Helper_Data::DEVICE_TYPE_ANDROID) {
253: if (isset($formData['conf[submit_text][keywords]'])) {
254: $keyWordsVal = $formData['conf[submit_text][keywords]'];
255: } else {
256: $keyWordsVal = null;
257: }
258:
259: $fieldset->addField('conf/submit_text/keywords', 'text', array(
260: 'name' => 'conf[submit_text][keywords]',
261: 'label' => $this->__('Keywords'),
262: 'maxlength' => '100',
263: 'value' => $keyWordsVal,
264: 'note' => $this->__('One or more keywords that describe your app. Keywords are matched to users\' searches in the App Store and help return accurate search results. Separate multiple keywords with commas. 100 chars is maximum.'),
265: ));
266: }
267:
268: $fieldset = $form->addFieldset('submit_icons', array('legend' => $this->__('Icons')));
269:
270: switch ($deviceType) {
271: case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPHONE:
272: $this->addImage($fieldset, 'conf/submit/icon', $this->__('Large iTunes Icon'),
273: $this->__('Large icon that appears in the iTunes App Store. You do not need to apply a gradient or soft edges (this is done automatically by Apple). Required size: 512px x 512px.'), '', true);
274:
275: $this->addImage($fieldset, 'conf/submit/loader_image', $this->__('Loader Splash Screen'),
276: $this->__('Image that appears on first screen while your app is loading. Required size: 320px x 460px.'), '', true);
277:
278: $this->addImage($fieldset, 'conf/submit/loader_image_i4', $this->__('Loader Splash Screen <br />(iPhone 4 retina)'),
279: $this->__('Image that appears on first screen while your app is loading. Required size: 640px x 920px.'), '', false);
280:
281: $this->addImage($fieldset, 'conf/submit/logo', $this->__('Custom App Icon'),
282: $this->__('Icon that will appear on the user’s phone after they download your app. You do not need to apply a gradient or soft edges (this is done automatically by Apple). Recommended size: 57px x 57px at 72 dpi.'), '', true);
283:
284: $this->addImage($fieldset, 'conf/submit/logo_i4', $this->__('Custom App Icon <br />(iPhone 4 retina)'),
285: $this->__('Icon that will appear on the user\'s phone after they download your app. You do not need to apply a gradient or soft edges (this is done automatically by Apple). Recommended size: 114px x 114px.'), '', false);
286:
287: $this->addImage($fieldset, 'conf/submit/big_logo', $this->__('Copyright Page Logo'),
288: $this->__('Store logo that is displayed on copyright page of app. Preferred size: 100px x 100px.'), '', true);
289:
290: $this->addImage($fieldset, 'conf/submit/big_logo_i4', $this->__('Copyright Page Logo <br />(iPhone 4 retina)'),
291: $this->__('Store logo that is displayed on copyright page of app. Preferred size: 200px x 200px.'), '', false);
292: break;
293: case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPAD:
294: $this->addImage($fieldset, 'conf/submit/icon', $this->__('Large iTunes Icon'),
295: $this->__('Large icon that appears in the iTunes App Store. You do not need to apply a gradient or soft edges (this is done automatically by Apple). Required size: 512px x 512px.'), '', true);
296:
297: $this->addImage($fieldset, 'conf/submit/ipad_loader_portrait_image', $this->__('Loader Splash Screen <br />(portrait mode)'),
298: $this->__('Image that appears on first screen while your app is loading. Required size: 768px x 1024px.'), '', true);
299:
300: $this->addImage($fieldset, 'conf/submit/ipad_loader_landscape_image', $this->__('Loader Splash Screen <br />(landscape mode)'),
301: $this->__('Image that appears on first screen while your app is loading. Required size: 1024px x 768px.'), '', true);
302:
303: $this->addImage($fieldset, 'conf/submit/ipad_logo', $this->__('Custom App Icon'),
304: $this->__('Icon that will appear on the user\'s device after they download your app. You do not need to apply a gradient or soft edges (this is done automatically by Apple). Recommended size: 72px x 72px.'), '', true);
305:
306: $this->addImage($fieldset, 'conf/submit/big_logo', $this->__('Copyright Page Logo'),
307: $this->__('Store logo that is displayed on copyright page of app. Preferred size: 100px x 100px.'), '', true);
308: break;
309: case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_ANDROID:
310: $this->addImage($fieldset, 'conf/submit/icon', $this->__('High Resolution Application Icon'),
311: $this->__('The icon that appears in the Android Market. Recommended size: 512px x 512px. Maximum size: 1024 KB.'), '', true);
312:
313: $this->addImage($fieldset, 'conf/submit/android_loader_image', $this->__('Loader Splash Screen'),
314: $this->__('Image that appears on first screen while your app is loading. Required size: 320px x 455px.'), '', true);
315:
316: $this->addImage($fieldset, 'conf/submit/android_logo', $this->__('Custom App Icon'),
317: $this->__('Icon that will appear on the user\'s device after they download your app. Recommended size: 48px x 48px.'), '', true);
318:
319: $this->addImage($fieldset, 'conf/submit/big_logo', $this->__('Copyright Page Logo'),
320: $this->__('Store logo that is displayed on copyright page of app. Preferred size: 100px x 100px.'), '', true);
321: break;
322: }
323:
324: return parent::_prepareForm();
325: }
326:
327: 328: 329: 330: 331:
332: public function getTabLabel()
333: {
334: return $this->__('Submission');
335: }
336:
337: 338: 339: 340: 341:
342: public function getTabTitle()
343: {
344: return $this->__('Submission');
345: }
346:
347: 348: 349: 350: 351:
352: public function canShowTab()
353: {
354: return true;
355: }
356:
357: 358: 359: 360: 361:
362: public function isHidden()
363: {
364: return false;
365: }
366:
367: 368: 369: 370: 371:
372: protected function _getAdditionalElementTypes()
373: {
374: return array(
375: 'image' => Mage::getConfig()->getBlockClassName('xmlconnect/adminhtml_mobile_helper_image'),
376: );
377: }
378:
379: 380: 381: 382: 383: 384:
385: protected function _toHtml()
386: {
387: return parent::_toHtml() . $this->getChildHtml('images');
388: }
389: }
390: