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
35: extends Mage_Adminhtml_Block_Widget_Form_Container
36: {
37: 38: 39:
40: public function __construct()
41: {
42: $this->_objectId = 'application_id';
43: $this->_controller = 'adminhtml_mobile';
44: $this->_blockGroup = 'xmlconnect';
45: $this->_mode = 'submission';
46: parent::__construct();
47:
48: $this->removeButton('delete');
49: $this->removeButton('save');
50: $this->removeButton('reset');
51:
52: $app = Mage::helper('xmlconnect')->getApplication();
53: if ($app && $app->getIsResubmitAction()) {
54: $label = $this->__('Resubmit App');
55: } else {
56: $label = $this->__('Submit App');
57: }
58:
59: $this->_addButton('submission_post', array(
60: 'class' => 'save',
61: 'label' => $label,
62: 'onclick' => "submitApplication()",
63: ));
64:
65: $this->_updateButton('back', 'label', $this->__('Back to App Edit'));
66: $this->_updateButton(
67: 'back',
68: 'onclick',
69: 'setLocation(\'' . $this->getUrl('*/*/edit', array('application_id' => $app->getId())) . '\')'
70: );
71: }
72:
73: 74: 75: 76: 77: 78:
79: protected function _prepareLayout()
80: {
81: $this->getLayout()->getBlock('head')->addJs('jscolor/jscolor.js');
82: $this->getLayout()->getBlock('head')->addJs('scriptaculous/scriptaculous.js');
83:
84:
85: $deviceType = Mage::helper('xmlconnect')->getDeviceType();
86: switch ($deviceType) {
87: case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPHONE:
88: $this->getLayout()->getBlock('head')->addItem('skin_css', 'xmlconnect/mobile-home.css');
89: $this->getLayout()->getBlock('head')->addItem('skin_css', 'xmlconnect/mobile-catalog.css');
90: break;
91: case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_IPAD:
92: $this->getLayout()->getBlock('head')->addItem('skin_css', 'xmlconnect/mobile-ipad-home.css');
93: $this->getLayout()->getBlock('head')->addItem('skin_css', 'xmlconnect/mobile-ipad-catalog.css');
94: break;
95: case Mage_XmlConnect_Helper_Data::DEVICE_TYPE_ANDROID:
96: $this->getLayout()->getBlock('head')->addItem('skin_css', 'xmlconnect/mobile-android.css');
97: break;
98: default:
99: Mage::throwException(
100: $this->__('Device doesn\'t recognized: "%s". Unable to load preview model.', $deviceType)
101: );
102: break;
103: }
104:
105: return parent::_prepareLayout();
106: }
107:
108: 109: 110: 111: 112:
113: public function ()
114: {
115: $app = Mage::helper('xmlconnect')->getApplication();
116: if ($app && $app->getId()) {
117: return $this->__('Submit App "%s"', $this->escapeHtml($app->getName()));
118: }
119: return '';
120: }
121: }
122: