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_Edit_Tab_Social
35: extends Mage_XmlConnect_Block_Adminhtml_Mobile_Widget_Form
36: implements Mage_Adminhtml_Block_Widget_Tab_Interface
37: {
38: 39: 40: 41: 42: 43:
44: protected function _prepareForm()
45: {
46: $form = new Varien_Data_Form();
47:
48: $this->setForm($form);
49:
50: $data = Mage::helper('xmlconnect')->getApplication()->getFormData();
51:
52: $yesNoValues = Mage::getModel('adminhtml/system_config_source_yesno')->toOptionArray();
53:
54: 55: 56:
57: $twitterStatus = $facebookStatus = $linkedinStatus = 0;
58: $noteText = $this->__('Please <a href="%s" target="_blank">click here</a> to see how to setup and retrieve API credentials.');
59:
60: 61: 62:
63: $fieldsetTwitter = $form->addFieldset('twitter', array(
64: 'legend' => $this->__('Twitter API')
65: ));
66:
67: if (isset($data['conf[native][socialNetworking][twitter][isActive]'])) {
68: $twitterStatus = (int)$data['conf[native][socialNetworking][twitter][isActive]'];
69: }
70:
71: $twitterActiveField = $fieldsetTwitter->addField(
72: 'conf/native/socialNetworking/twitter/isActive',
73: 'select',
74: array(
75: 'label' => $this->__('Enable Twitter'),
76: 'name' => 'conf[native][socialNetworking][twitter][isActive]',
77: 'values' => $yesNoValues,
78: 'value' => $twitterStatus,
79: )
80: );
81:
82: if (isset($data['conf[native][socialNetworking][twitter][apiKey]'])) {
83: $twitterApiKey = $data['conf[native][socialNetworking][twitter][apiKey]'];
84: } else {
85: $twitterApiKey = '';
86: }
87:
88: $twitterApiKeyField = $fieldsetTwitter->addField(
89: 'conf/native/socialNetworking/twitter/apiKey',
90: 'text',
91: array(
92: 'label' => $this->__('Twitter API Key'),
93: 'name' => 'conf[native][socialNetworking][twitter][apiKey]',
94: 'required' => true,
95: 'value' => $twitterApiKey
96: )
97: );
98:
99: if (isset($data['conf[native][socialNetworking][twitter][secretKey]'])) {
100: $twitterSecretKey = $data['conf[native][socialNetworking][twitter][secretKey]'];
101: } else {
102: $twitterSecretKey = '';
103: }
104:
105: $twitterSecretKeyField = $fieldsetTwitter->addField(
106: 'conf/native/socialNetworking/twitter/secretKey',
107: 'text',
108: array(
109: 'label' => $this->__('Twitter Secret Key'),
110: 'name' => 'conf[native][socialNetworking][twitter][secretKey]',
111: 'required' => true,
112: 'value' => $twitterSecretKey
113: )
114: );
115:
116: $fieldsetTwitter->addField(
117: 'twitterNote',
118: 'note',
119: array(
120: 'text' => sprintf(
121: $noteText,
122: Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_HOWTO_TWITTER_URL)
123: ),
124: )
125: );
126:
127: 128: 129:
130: $fieldsetFacebook = $form->addFieldset('facebook', array(
131: 'legend' => $this->__('Facebook API'),
132: ));
133:
134: if (isset($data['conf[native][socialNetworking][facebook][isActive]'])) {
135: $facebookStatus = (int)$data['conf[native][socialNetworking][facebook][isActive]'];
136: }
137:
138: $facebookActiveField = $fieldsetFacebook->addField(
139: 'conf/native/socialNetworking/facebook/isActive',
140: 'select',
141: array(
142: 'label' => $this->__('Enable Facebook'),
143: 'name' => 'conf[native][socialNetworking][facebook][isActive]',
144: 'values' => $yesNoValues,
145: 'value' => $facebookStatus,
146: )
147: );
148:
149: if (isset($data['conf[native][socialNetworking][facebook][appID]'])) {
150: $facebookAppID = $data['conf[native][socialNetworking][facebook][appID]'];
151: } else {
152: $facebookAppID = '';
153: }
154:
155: $facebookAppIDField = $fieldsetFacebook->addField(
156: 'conf/native/socialNetworking/facebook/appID',
157: 'text',
158: array(
159: 'label' => $this->__('Facebook Application ID'),
160: 'name' => 'conf[native][socialNetworking][facebook][appID]',
161: 'required' => true,
162: 'value' => $facebookAppID
163: )
164: );
165:
166: $fieldsetFacebook->addField(
167: 'facebookNote',
168: 'note',
169: array(
170: 'text' => sprintf(
171: $noteText,
172: Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_HOWTO_FACEBOOK_URL)
173: ),
174: )
175: );
176:
177: 178: 179:
180: $fieldsetLinkedin = $form->addFieldset('linkedin', array(
181: 'legend' => $this->__('LinkedIn API'),
182: ));
183:
184: if (isset($data['conf[native][socialNetworking][linkedin][isActive]'])) {
185: $linkedinStatus = (int)$data['conf[native][socialNetworking][linkedin][isActive]'];
186: }
187:
188: $linkedinActiveField = $fieldsetLinkedin->addField(
189: 'conf/native/socialNetworking/linkedin/isActive',
190: 'select',
191: array(
192: 'label' => $this->__('Enable LinkedIn'),
193: 'name' => 'conf[native][socialNetworking][linkedin][isActive]',
194: 'values' => $yesNoValues,
195: 'value' => $linkedinStatus,
196: )
197: );
198:
199: if (isset($data['conf[native][socialNetworking][linkedin][apiKey]'])) {
200: $linkedinApiKey = $data['conf[native][socialNetworking][linkedin][apiKey]'];
201: } else {
202: $linkedinApiKey = '';
203: }
204:
205: $linkedinApiKeyField = $fieldsetLinkedin->addField(
206: 'conf/native/socialNetworking/linkedin/apiKey',
207: 'text',
208: array(
209: 'label' => $this->__('LinkedIn API Key'),
210: 'name' => 'conf[native][socialNetworking][linkedin][apiKey]',
211: 'required' => true,
212: 'value' => $linkedinApiKey
213: )
214: );
215:
216: if (isset($data['conf[native][socialNetworking][linkedin][secretKey]'])) {
217: $linkedinSecretKey = $data['conf[native][socialNetworking][linkedin][secretKey]'];
218: } else {
219: $linkedinSecretKey = '';
220: }
221:
222: $linkedinSecretKeyField = $fieldsetLinkedin->addField(
223: 'conf/native/socialNetworking/linkedin/secretKey',
224: 'text',
225: array(
226: 'label' => $this->__('LinkedIn Secret Key'),
227: 'name' => 'conf[native][socialNetworking][linkedin][secretKey]',
228: 'required' => true,
229: 'value' => $linkedinSecretKey
230: )
231: );
232:
233: $fieldsetLinkedin->addField(
234: 'linkedinNote',
235: 'note',
236: array(
237: 'text' => sprintf(
238: $noteText,
239: Mage::getStoreConfig(Mage_XmlConnect_Model_Application::XML_PATH_HOWTO_LINKEDIN_URL)
240: ),
241: )
242: );
243:
244: 245: 246:
247: $this->setChild('form_after', $this->getLayout()
248: ->createBlock('adminhtml/widget_form_element_dependence')
249: 250: 251:
252: ->addFieldMap($facebookActiveField->getHtmlId(), $facebookActiveField->getName())
253: ->addFieldMap($facebookAppIDField->getHtmlId(), $facebookAppIDField->getName())
254: ->addFieldDependence(
255: $facebookAppIDField->getName(),
256: $facebookActiveField->getName(),
257: 1)
258: 259: 260:
261: ->addFieldMap($twitterApiKeyField->getHtmlId(), $twitterApiKeyField->getName())
262: ->addFieldMap($twitterActiveField->getHtmlId(), $twitterActiveField->getName())
263: ->addFieldMap($twitterSecretKeyField->getHtmlId(), $twitterSecretKeyField->getName())
264: ->addFieldDependence(
265: $twitterApiKeyField->getName(),
266: $twitterActiveField->getName(),
267: 1)
268: ->addFieldDependence(
269: $twitterSecretKeyField->getName(),
270: $twitterActiveField->getName(),
271: 1)
272: 273: 274:
275: ->addFieldMap($linkedinApiKeyField->getHtmlId(), $linkedinApiKeyField->getName())
276: ->addFieldMap($linkedinActiveField->getHtmlId(), $linkedinActiveField->getName())
277: ->addFieldMap($linkedinSecretKeyField->getHtmlId(), $linkedinSecretKeyField->getName())
278: ->addFieldDependence(
279: $linkedinApiKeyField->getName(),
280: $linkedinActiveField->getName(),
281: 1)
282: ->addFieldDependence(
283: $linkedinSecretKeyField->getName(),
284: $linkedinActiveField->getName(),
285: 1)
286: );
287:
288: return parent::_prepareForm();
289: }
290:
291: 292: 293: 294: 295:
296: public function getTabLabel()
297: {
298: return $this->__('Social Networking');
299: }
300:
301: 302: 303: 304: 305:
306: public function getTabTitle()
307: {
308: return $this->__('Social Networking');
309: }
310:
311: 312: 313: 314: 315:
316: public function canShowTab()
317: {
318: return (bool) !Mage::getSingleton('adminhtml/session')->getNewApplication();
319: }
320:
321: 322: 323: 324: 325:
326: public function isHidden()
327: {
328: return false;
329: }
330: }
331: