PageRenderTime 54ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 1ms

/app/code/core/Mage/XmlConnect/Helper/Iphone.php

https://bitbucket.org/andrewjleavitt/magestudy
PHP | 791 lines | 600 code | 38 blank | 153 comment | 39 complexity | a5ff327b796c6cc4fc31df21591890cd MD5 | raw file
Possible License(s): CC-BY-SA-3.0, LGPL-2.1, GPL-2.0, WTFPL
  1. <?php
  2. /**
  3. * Magento
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@magentocommerce.com so we can send you a copy immediately.
  14. *
  15. * DISCLAIMER
  16. *
  17. * Do not edit or add to this file if you wish to upgrade Magento to newer
  18. * versions in the future. If you wish to customize Magento for your
  19. * needs please refer to http://www.magentocommerce.com for more information.
  20. *
  21. * @category Mage
  22. * @package Mage_XmlConnect
  23. * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26. /**
  27. * XmlConnect device helper for iPhone
  28. *
  29. * @category Mage
  30. * @package Mage_XmlConnect
  31. * @author Magento Core Team <core@magentocommerce.com>
  32. */
  33. class Mage_XmlConnect_Helper_Iphone extends Mage_Core_Helper_Abstract
  34. {
  35. /**
  36. * Submission title length
  37. *
  38. * @var int
  39. */
  40. const SUBMISSION_TITLE_LENGTH = 12;
  41. /**
  42. * Submission description length
  43. *
  44. * @var int
  45. */
  46. const SUBMISSION_DESCRIPTION_LENGTH = 500;
  47. /**
  48. * Country renderer for submission page
  49. *
  50. * @var string
  51. */
  52. const SUBMISSION_COUNTRY_RENDERER = 'istore';
  53. /**
  54. * Country columns for submission page
  55. *
  56. * @var int
  57. */
  58. const SUBMISSION_COUNTRY_COLUMNS = 4;
  59. /**
  60. * Submit images that are stored in "params" field of history table
  61. *
  62. * @var array
  63. */
  64. protected $_imageIds = array(
  65. 'icon',
  66. 'loader_image',
  67. 'loader_image_i4',
  68. 'logo',
  69. 'logo_i4',
  70. 'big_logo',
  71. 'big_logo_i4'
  72. );
  73. /**
  74. * List of coutries that allowed in Ituens by Apple Store
  75. *
  76. * array(
  77. * 'country name' => 'country id at directory model'
  78. * )
  79. *
  80. * @var array
  81. */
  82. protected $_allowedCountries = array(
  83. 'Argentina' => 'AR',
  84. 'Armenia' => 'AM',
  85. 'Australia' => 'AU',
  86. 'Austria' => 'AT',
  87. 'Belgium' => 'BE',
  88. 'Botswana' => 'BW',
  89. 'Brazil' =>'BR',
  90. 'Bulgaria' => 'BG',
  91. 'Canada' => 'CA',
  92. 'Chile' => 'CL',
  93. 'China' => 'CN',
  94. 'Colombia' => 'CO',
  95. 'Costa Rica' => 'CR',
  96. 'Croatia' => 'HR',
  97. 'Czech Republic' => 'CZ',
  98. 'Denmark' => 'DK',
  99. 'Dominican Republic' => 'DO',
  100. 'Ecuador' => 'EC',
  101. 'Egypt' => 'EG',
  102. 'El Salvador' => 'SV',
  103. 'Estonia' => 'EE',
  104. 'Finland' => 'FI',
  105. 'France' => 'FR',
  106. 'Germany' => 'DE',
  107. 'Greece' => 'GR',
  108. 'Guatemala' => 'GT',
  109. 'Honduras' => 'HN',
  110. 'Hong Kong SAR China' => 'HK',
  111. 'Hungary' => 'HU',
  112. 'India' => 'IN',
  113. 'Indonesia' => 'ID',
  114. 'Ireland' => 'IE',
  115. 'Israel' => 'IL',
  116. 'Italy' => 'IT',
  117. 'Jamaica' => 'JM',
  118. 'Japan' => 'JP',
  119. 'Jordan' => 'JO',
  120. 'Kazakstan' => 'KZ',
  121. 'Kenya' => 'KE',
  122. 'South Korea' => 'KR',
  123. 'Kuwait' => 'KW',
  124. 'Latvia' => 'LV',
  125. 'Lebanon' => 'LB',
  126. 'Lithuania' => 'LT',
  127. 'Luxembourg' => 'LU',
  128. 'Macau SAR China' => 'MO',
  129. 'Macedonia' => 'MK',
  130. 'Madagascar' => 'MG',
  131. 'Malaysia' => 'MY',
  132. 'Mali' => 'ML',
  133. 'Malta' => 'MT',
  134. 'Mauritius' => 'MU',
  135. 'Mexico' => 'MX',
  136. 'Moldova' => 'MD',
  137. 'Netherlands' => 'NL',
  138. 'New Zealand' => 'NZ',
  139. 'Nicaragua' => 'NI',
  140. 'Niger' => 'NE',
  141. 'Norway' => 'NO',
  142. 'Pakistan' => 'PK',
  143. 'Panama' => 'PA',
  144. 'Paraguay' => 'PY',
  145. 'Peru'=> 'PE',
  146. 'Philippines' => 'PH',
  147. 'Poland' => 'PL',
  148. 'Portugal' => 'PT',
  149. 'Qatar' => 'QA',
  150. 'Romania' => 'RO',
  151. 'Russia' => 'RU',
  152. 'Saudi Arabia' => 'SA',
  153. 'Senegal' => 'SN',
  154. 'Singapore' => 'SG',
  155. 'Slovakia' => 'SK',
  156. 'Slovenia' => 'SI',
  157. 'South Africa' => 'ZA',
  158. 'Spain' => 'ES',
  159. 'Sri Lanka' => 'LK',
  160. 'Sweden' => 'SE',
  161. 'Switzerland' => 'CH',
  162. 'Taiwan' => 'TW',
  163. 'Thailand' => 'TH',
  164. 'Tunisia' => 'TN',
  165. 'Turkey' => 'TR',
  166. 'Uganda' => 'UG',
  167. 'United Arab Emirates' => 'AE',
  168. 'United Kingdom' => 'GB',
  169. 'United States' => 'US',
  170. 'Uruguay' => 'UY',
  171. 'Venezuela' => 'VE',
  172. 'Vietnam' => 'VN',
  173. );
  174. /**
  175. * Country field renderer
  176. *
  177. * @var Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Renderer_Country_Istore
  178. */
  179. protected $_countryRenderer = null;
  180. /**
  181. * Get submit images that are required for application submit
  182. *
  183. * @return array
  184. */
  185. public function getSubmitImages()
  186. {
  187. return $this->_imageIds;
  188. }
  189. /**
  190. * Get default application tabs
  191. *
  192. * @param string
  193. * @return array
  194. */
  195. public function getDefaultDesignTabs()
  196. {
  197. if (!isset($this->_tabs)) {
  198. $this->_tabs = array(
  199. array(
  200. 'label' => Mage::helper('xmlconnect')->__('Home'),
  201. 'image' => 'tab_home.png',
  202. 'action' => 'Home',
  203. ),
  204. array(
  205. 'label' => Mage::helper('xmlconnect')->__('Shop'),
  206. 'image' => 'tab_shop.png',
  207. 'action' => 'Shop',
  208. ),
  209. array(
  210. 'label' => Mage::helper('xmlconnect')->__('Search'),
  211. 'image' => 'tab_search.png',
  212. 'action' => 'Search',
  213. ),
  214. array(
  215. 'label' => Mage::helper('xmlconnect')->__('Cart'),
  216. 'image' => 'tab_cart.png',
  217. 'action' => 'Cart',
  218. ),
  219. array(
  220. 'label' => Mage::helper('xmlconnect')->__('More'),
  221. 'image' => 'tab_more.png',
  222. 'action' => 'More',
  223. ),
  224. array(
  225. 'label' => Mage::helper('xmlconnect')->__('Account'),
  226. 'image' => 'tab_account.png',
  227. 'action' => 'Account',
  228. ),
  229. array(
  230. 'label' => Mage::helper('xmlconnect')->__('More Info'),
  231. 'image' => 'tab_page.png',
  232. 'action' => 'AboutUs',
  233. ),
  234. );
  235. }
  236. return $this->_tabs;
  237. }
  238. /**
  239. * Default application configuration
  240. *
  241. * @return array
  242. */
  243. public function getDefaultConfiguration()
  244. {
  245. return array(
  246. 'native' => array(
  247. 'body' => array(
  248. 'backgroundColor' => '#ABABAB',
  249. 'scrollBackgroundColor' => '#EDEDED',
  250. ),
  251. 'itemActions' => array(
  252. 'relatedProductBackgroundColor' => '#404040',
  253. ),
  254. 'fonts' => array(
  255. 'Title1' => array(
  256. 'name' => 'HelveticaNeue-Bold',
  257. 'size' => '14',
  258. 'color' => '#FEFEFE',
  259. ),
  260. 'Title2' => array(
  261. 'name' => 'HelveticaNeue-Bold',
  262. 'size' => '12',
  263. 'color' => '#222222',
  264. ),
  265. 'Title3' => array(
  266. 'name' => 'HelveticaNeue',
  267. 'size' => '13',
  268. 'color' => '#000000',
  269. ),
  270. 'Title4' => array(
  271. 'name' => 'HelveticaNeue',
  272. 'size' => '12',
  273. 'color' => '#FFFFFF',
  274. ),
  275. 'Title5' => array(
  276. 'name' => 'HelveticaNeue-Bold',
  277. 'size' => '13',
  278. 'color' => '#dc5f02',
  279. ),
  280. 'Title6' => array(
  281. 'name' => 'HelveticaNeue-Bold',
  282. 'size' => '16',
  283. 'color' => '#222222',
  284. ),
  285. 'Title7' => array(
  286. 'name' => 'HelveticaNeue-Bold',
  287. 'size' => '13',
  288. 'color' => '#000000',
  289. ),
  290. 'Title8' => array(
  291. 'name' => 'HelveticaNeue-Bold',
  292. 'size' => '11',
  293. 'color' => '#FFFFFF',
  294. ),
  295. 'Title9' => array(
  296. 'name' => 'HelveticaNeue-Bold',
  297. 'size' => '12',
  298. 'color' => '#FFFFFF',
  299. ),
  300. 'Text1' => array(
  301. 'name' => 'HelveticaNeue-Bold',
  302. 'size' => '12',
  303. 'color' => '#777777',
  304. ),
  305. 'Text2' => array(
  306. 'name' => 'HelveticaNeue',
  307. 'size' => '10',
  308. 'color' => '#555555',
  309. ),
  310. ),
  311. ),
  312. );
  313. }
  314. /**
  315. * List of allowed fonts for iPhone application
  316. *
  317. * @return array
  318. */
  319. public function getFontList()
  320. {
  321. return array(
  322. array(
  323. 'value' => 'HiraKakuProN-W3',
  324. 'label' => 'HiraKakuProN-W3',
  325. ),
  326. array(
  327. 'value' => 'Courier',
  328. 'label' => 'Courier',
  329. ),
  330. array(
  331. 'value' => 'Courier-BoldOblique',
  332. 'label' => 'Courier-BoldOblique',
  333. ),
  334. array(
  335. 'value' => 'Courier-Oblique',
  336. 'label' => 'Courier-Oblique',
  337. ),
  338. array(
  339. 'value' => 'Courier-Bold',
  340. 'label' => 'Courier-Bold',
  341. ),
  342. array(
  343. 'value' => 'ArialMT',
  344. 'label' => 'ArialMT',
  345. ),
  346. array(
  347. 'value' => 'Arial-BoldMT',
  348. 'label' => 'Arial-BoldMT',
  349. ),
  350. array(
  351. 'value' => 'Arial-BoldItalicMT',
  352. 'label' => 'Arial-BoldItalicMT',
  353. ),
  354. array(
  355. 'value' => 'Arial-ItalicMT',
  356. 'label' => 'Arial-ItalicMT',
  357. ),
  358. array(
  359. 'value' => 'STHeitiTC-Light',
  360. 'label' => 'STHeitiTC-Light',
  361. ),
  362. array(
  363. 'value' => 'STHeitiTC-Medium',
  364. 'label' => 'STHeitiTC-Medium',
  365. ),
  366. array(
  367. 'value' => 'AppleGothic',
  368. 'label' => 'AppleGothic',
  369. ),
  370. array(
  371. 'value' => 'CourierNewPS-BoldMT',
  372. 'label' => 'CourierNewPS-BoldMT',
  373. ),
  374. array(
  375. 'value' => 'CourierNewPS-ItalicMT',
  376. 'label' => 'CourierNewPS-ItalicMT',
  377. ),
  378. array(
  379. 'value' => 'CourierNewPS-BoldItalicMT',
  380. 'label' => 'CourierNewPS-BoldItalicMT',
  381. ),
  382. array(
  383. 'value' => 'CourierNewPSMT',
  384. 'label' => 'CourierNewPSMT',
  385. ),
  386. array(
  387. 'value' => 'Zapfino',
  388. 'label' => 'Zapfino',
  389. ),
  390. array(
  391. 'value' => 'HiraKakuProN-W6',
  392. 'label' => 'HiraKakuProN-W6',
  393. ),
  394. array(
  395. 'value' => 'ArialUnicodeMS',
  396. 'label' => 'ArialUnicodeMS',
  397. ),
  398. array(
  399. 'value' => 'STHeitiSC-Medium',
  400. 'label' => 'STHeitiSC-Medium',
  401. ),
  402. array(
  403. 'value' => 'STHeitiSC-Light',
  404. 'label' => 'STHeitiSC-Light',
  405. ),
  406. array(
  407. 'value' => 'AmericanTypewriter',
  408. 'label' => 'AmericanTypewriter',
  409. ),
  410. array(
  411. 'value' => 'AmericanTypewriter-Bold',
  412. 'label' => 'AmericanTypewriter-Bold',
  413. ),
  414. array(
  415. 'value' => 'Helvetica-Oblique',
  416. 'label' => 'Helvetica-Oblique',
  417. ),
  418. array(
  419. 'value' => 'Helvetica-BoldOblique',
  420. 'label' => 'Helvetica-BoldOblique',
  421. ),
  422. array(
  423. 'value' => 'Helvetica',
  424. 'label' => 'Helvetica',
  425. ),
  426. array(
  427. 'value' => 'Helvetica-Bold',
  428. 'label' => 'Helvetica-Bold',
  429. ),
  430. array(
  431. 'value' => 'MarkerFelt-Thin',
  432. 'label' => 'MarkerFelt-Thin',
  433. ),
  434. array(
  435. 'value' => 'HelveticaNeue',
  436. 'label' => 'HelveticaNeue',
  437. ),
  438. array(
  439. 'value' => 'HelveticaNeue-Bold',
  440. 'label' => 'HelveticaNeue-Bold',
  441. ),
  442. array(
  443. 'value' => 'DBLCDTempBlack',
  444. 'label' => 'DBLCDTempBlack',
  445. ),
  446. array(
  447. 'value' => 'Verdana-Bold',
  448. 'label' => 'Verdana-Bold',
  449. ),
  450. array(
  451. 'value' => 'Verdana-BoldItalic',
  452. 'label' => 'Verdana-BoldItalic',
  453. ),
  454. array(
  455. 'value' => 'Verdana',
  456. 'label' => 'Verdana',
  457. ),
  458. array(
  459. 'value' => 'Verdana-Italic',
  460. 'label' => 'Verdana-Italic',
  461. ),
  462. array(
  463. 'value' => 'TimesNewRomanPSMT',
  464. 'label' => 'TimesNewRomanPSMT',
  465. ),
  466. array(
  467. 'value' => 'TimesNewRomanPS-BoldMT',
  468. 'label' => 'TimesNewRomanPS-BoldMT',
  469. ),
  470. array(
  471. 'value' => 'TimesNewRomanPS-BoldItalicMT',
  472. 'label' => 'TimesNewRomanPS-BoldItalicMT',
  473. ),
  474. array(
  475. 'value' => 'TimesNewRomanPS-ItalicMT',
  476. 'label' => 'TimesNewRomanPS-ItalicMT',
  477. ),
  478. array(
  479. 'value' => 'Georgia-Bold',
  480. 'label' => 'Georgia-Bold',
  481. ),
  482. array(
  483. 'value' => 'Georgia',
  484. 'label' => 'Georgia',
  485. ),
  486. array(
  487. 'value' => 'Georgia-BoldItalic',
  488. 'label' => 'Georgia-BoldItalic',
  489. ),
  490. array(
  491. 'value' => 'Georgia-Italic',
  492. 'label' => 'Georgia-Italic',
  493. ),
  494. array(
  495. 'value' => 'STHeitiJ-Medium',
  496. 'label' => 'STHeitiJ-Medium',
  497. ),
  498. array(
  499. 'value' => 'STHeitiJ-Light',
  500. 'label' => 'STHeitiJ-Light',
  501. ),
  502. array(
  503. 'value' => 'ArialRoundedMTBold',
  504. 'label' => 'ArialRoundedMTBold',
  505. ),
  506. array(
  507. 'value' => 'TrebuchetMS-Italic',
  508. 'label' => 'TrebuchetMS-Italic',
  509. ),
  510. array(
  511. 'value' => 'TrebuchetMS',
  512. 'label' => 'TrebuchetMS',
  513. ),
  514. array(
  515. 'value' => 'Trebuchet-BoldItalic',
  516. 'label' => 'Trebuchet-BoldItalic',
  517. ),
  518. array(
  519. 'value' => 'TrebuchetMS-Bold',
  520. 'label' => 'TrebuchetMS-Bold',
  521. ),
  522. array(
  523. 'value' => 'STHeitiK-Medium',
  524. 'label' => 'STHeitiK-Medium',
  525. ),
  526. array(
  527. 'value' => 'STHeitiK-Light',
  528. 'label' => 'STHeitiK-Light',
  529. ),
  530. );
  531. }
  532. /**
  533. * List of allowed font sizes for iPhone application
  534. *
  535. * @return array
  536. */
  537. public function getFontSizes()
  538. {
  539. $result = array( );
  540. for ($i = 6; $i < 32; $i++) {
  541. $result[] = array(
  542. 'value' => $i,
  543. 'label' => $i . ' pt',
  544. );
  545. }
  546. return $result;
  547. }
  548. /**
  549. * Get list of countries that allowed in Itunes by Apple Store for Iphone
  550. *
  551. * @return array
  552. */
  553. public function getItunesCountriesArray()
  554. {
  555. return $this->_allowedCountries;
  556. }
  557. /**
  558. * Validate submit application data
  559. *
  560. * @param array $params
  561. * @return array
  562. */
  563. public function validateSubmit($params)
  564. {
  565. $errors = array();
  566. if (!Zend_Validate::is(isset($params['title']) ? $params['title'] : null, 'NotEmpty')) {
  567. $errors[] = Mage::helper('xmlconnect')->__('Please enter the Title.');
  568. }
  569. if (isset($params['title'])) {
  570. $titleLength = self::SUBMISSION_TITLE_LENGTH;
  571. $strRules = array('min' => '1', 'max' => $titleLength);
  572. if (!Zend_Validate::is($params['title'], 'StringLength', $strRules)) {
  573. $errors[] = Mage::helper('xmlconnect')->__('"Title" is more than %d characters long', $strRules['max']);
  574. }
  575. }
  576. if (!Zend_Validate::is(isset($params['description']) ? $params['description'] : null, 'NotEmpty')) {
  577. $errors[] = Mage::helper('xmlconnect')->__('Please enter the Description.');
  578. }
  579. if (isset($params['description'])) {
  580. $descriptionLength = self::SUBMISSION_DESCRIPTION_LENGTH;
  581. $strRules = array('min' => '1', 'max' => $descriptionLength);
  582. if (!Zend_Validate::is($params['title'], 'StringLength', $strRules)) {
  583. $errors[] = Mage::helper('xmlconnect')->__('"Description" is more than %d characters long', $strRules['max']);
  584. }
  585. }
  586. if (!Zend_Validate::is(isset($params['copyright']) ? $params['copyright'] : null, 'NotEmpty')) {
  587. $errors[] = Mage::helper('xmlconnect')->__('Please enter the Copyright.');
  588. }
  589. if (empty($params['price_free'])) {
  590. if (!Zend_Validate::is(isset($params['price']) ? $params['price'] : null, 'NotEmpty')) {
  591. $errors[] = Mage::helper('xmlconnect')->__('Please enter the Price.');
  592. }
  593. }
  594. if (!Zend_Validate::is(isset($params['country']) ? $params['country'] : null, 'NotEmpty')) {
  595. $errors[] = Mage::helper('xmlconnect')->__('Please select at least one country.');
  596. }
  597. $keyLenght = Mage_XmlConnect_Model_Application::APP_MAX_KEY_LENGTH;
  598. if (Mage::helper('xmlconnect')->getApplication()->getIsResubmitAction()) {
  599. if (isset($params['resubmission_activation_key'])) {
  600. $resubmissionKey = $params['resubmission_activation_key'];
  601. } else {
  602. $resubmissionKey = null;
  603. }
  604. if (!Zend_Validate::is($resubmissionKey, 'NotEmpty')) {
  605. $errors[] = Mage::helper('xmlconnect')->__('Please enter the Resubmission Key.');
  606. } else if (!Zend_Validate::is($resubmissionKey, 'StringLength', array(1, $keyLenght))) {
  607. $errors[] = Mage::helper('xmlconnect')->__('Submit App failure. Invalid activation key provided');
  608. }
  609. } else {
  610. $key = isset($params['key']) ? $params['key'] : null;
  611. if (!Zend_Validate::is($key, 'NotEmpty')) {
  612. $errors[] = Mage::helper('xmlconnect')->__('Please enter the Activation Key.');
  613. } else if (!Zend_Validate::is($key, 'StringLength', array(1, $keyLenght))) {
  614. $errors[] = Mage::helper('xmlconnect')->__('Submit App failure. Invalid activation key provided');
  615. }
  616. }
  617. return $errors;
  618. }
  619. /**
  620. * Check config for valid values
  621. *
  622. * @param array $native
  623. * @return array
  624. */
  625. public function validateConfig($native)
  626. {
  627. $errors = array();
  628. if ( ($native === false)
  629. || (!isset($native['navigationBar']) || !is_array($native['navigationBar'])
  630. || !isset($native['navigationBar']['icon'])
  631. || !Zend_Validate::is($native['navigationBar']['icon'], 'NotEmpty'))) {
  632. $errors[] = Mage::helper('xmlconnect')->__('Please upload an image for "Logo in Header" field from Design Tab.');
  633. }
  634. if (!Mage::helper('xmlconnect')->validateConfFieldNotEmpty('bannerImage', $native)) {
  635. $errors[] = Mage::helper('xmlconnect')->__('Please upload an image for "Banner on Home Screen" field from Design Tab.');
  636. }
  637. if (!Mage::helper('xmlconnect')->validateConfFieldNotEmpty('backgroundImage', $native)) {
  638. $errors[] = Mage::helper('xmlconnect')->__('Please upload an image for "App Background" field from Design Tab.');
  639. }
  640. return $errors;
  641. }
  642. /**
  643. * Get renderer for submission country
  644. *
  645. * @return Mage_XmlConnect_Block_Adminhtml_Mobile_Submission_Renderer_Country_Istore
  646. */
  647. public function getCountryRenderer()
  648. {
  649. if (empty($this->_countryRenderer)) {
  650. $renderer = 'xmlconnect/adminhtml_mobile_submission_renderer_country_'
  651. . self::SUBMISSION_COUNTRY_RENDERER;
  652. $this->_countryRenderer = Mage::app()->getLayout()->createBlock($renderer);
  653. }
  654. return $this->_countryRenderer;
  655. }
  656. /**
  657. * Get label for submission country
  658. *
  659. * @return string
  660. */
  661. public function getCountryLabel()
  662. {
  663. return Mage::helper('xmlconnect')->__('App Stores');
  664. }
  665. /**
  666. * Get columns for submission country
  667. *
  668. * @return int
  669. */
  670. public function getCountryColumns()
  671. {
  672. return self::SUBMISSION_COUNTRY_COLUMNS;
  673. }
  674. /**
  675. * Get placement of Country Names for submission country
  676. *
  677. * @return bool
  678. */
  679. public function isCountryNamePlaceLeft()
  680. {
  681. return true;
  682. }
  683. /**
  684. * Get class name for submission country
  685. *
  686. * @return string
  687. */
  688. public function getCountryClass()
  689. {
  690. return self::SUBMISSION_COUNTRY_RENDERER . ' stripy';
  691. }
  692. /**
  693. * Check image fields
  694. *
  695. * We set empty value for image field if file was missed in some reason
  696. *
  697. * @param array $data
  698. * @return array
  699. */
  700. public function checkImages(array $data)
  701. {
  702. if (isset($data['conf']['native']['navigationBar']['icon']) &&
  703. !file_exists($data['conf']['native']['navigationBar']['icon'])
  704. ) {
  705. $data['conf']['native']['navigationBar']['icon'] = '';
  706. }
  707. if (isset($data['conf']['native']['body']['bannerImage']) &&
  708. !file_exists($data['conf']['native']['body']['bannerImage'])
  709. ) {
  710. $data['conf']['native']['body']['bannerImage'] = '';
  711. }
  712. if (isset($data['conf']['native']['body']['backgroundImage']) &&
  713. !file_exists($data['conf']['native']['body']['backgroundImage'])
  714. ) {
  715. $data['conf']['native']['body']['backgroundImage'] = '';
  716. }
  717. return $data;
  718. }
  719. /**
  720. * Check required fields of a config for a front-end
  721. *
  722. * @throws Mage_Core_Exception
  723. * @param array $data
  724. * @return void
  725. */
  726. public function checkRequiredConfigFields($data)
  727. {
  728. if (!is_array($data)) {
  729. return;
  730. }
  731. if (isset($data['navigationBar']['icon'])
  732. && empty($data['navigationBar']['icon'])
  733. ) {
  734. Mage::throwException(
  735. Mage::helper('xmlconnect')->__('Logo in Header image missing.')
  736. );
  737. }
  738. if (isset($data['body']['bannerImage']) &&
  739. empty($data['body']['bannerImage'])
  740. ) {
  741. Mage::throwException(
  742. Mage::helper('xmlconnect')->__('Banner on Home Screen image missing.')
  743. );
  744. }
  745. if (isset($data['body']['backgroundImage'])
  746. && empty($data['body']['backgroundImage'])
  747. ) {
  748. Mage::throwException(
  749. Mage::helper('xmlconnect')->__('App Background image missing.')
  750. );
  751. }
  752. }
  753. }