/app/code/core/Mage/Install/Block/Locale.php

https://bitbucket.org/jokusafet/magento2 · PHP · 167 lines · 83 code · 12 blank · 72 comment · 4 complexity · 4ae458c5d3daeb2381b60b55e3c8fda9 MD5 · raw file

  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_Install
  23. * @copyright Copyright (c) 2012 X.commerce, Inc. (http://www.magentocommerce.com)
  24. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  25. */
  26. /**
  27. * Install localization block
  28. *
  29. * @category Mage
  30. * @package Mage_Install
  31. * @author Magento Core Team <core@magentocommerce.com>
  32. */
  33. class Mage_Install_Block_Locale extends Mage_Install_Block_Abstract
  34. {
  35. protected $_template = 'locale.phtml';
  36. /**
  37. * Retrieve locale object
  38. *
  39. * @return Zend_Locale
  40. */
  41. public function getLocale()
  42. {
  43. $locale = $this->getData('locale');
  44. if (is_null($locale)) {
  45. $locale = Mage::app()->getLocale()->getLocale();
  46. $this->setData('locale', $locale);
  47. }
  48. return $locale;
  49. }
  50. /**
  51. * Retrieve locale data post url
  52. *
  53. * @return string
  54. */
  55. public function getPostUrl()
  56. {
  57. return $this->getCurrentStep()->getNextUrl();
  58. //return $this->getUrl('*/*/localePost');
  59. }
  60. /**
  61. * Retrieve locale change url
  62. *
  63. * @return string
  64. */
  65. public function getChangeUrl()
  66. {
  67. return $this->getUrl('*/*/localeChange');
  68. }
  69. /**
  70. * Retrieve locale dropdown HTML
  71. *
  72. * @return string
  73. */
  74. public function getLocaleSelect()
  75. {
  76. $html = $this->getLayout()->createBlock('Mage_Core_Block_Html_Select')
  77. ->setName('config[locale]')
  78. ->setId('locale')
  79. ->setTitle(Mage::helper('Mage_Install_Helper_Data')->__('Locale'))
  80. ->setClass('required-entry')
  81. ->setValue($this->getLocale()->__toString())
  82. ->setOptions(Mage::app()->getLocale()->getTranslatedOptionLocales())
  83. ->getHtml();
  84. return $html;
  85. }
  86. /**
  87. * Retrieve timezone dropdown HTML
  88. *
  89. * @return string
  90. */
  91. public function getTimezoneSelect()
  92. {
  93. $html = $this->getLayout()->createBlock('Mage_Core_Block_Html_Select')
  94. ->setName('config[timezone]')
  95. ->setId('timezone')
  96. ->setTitle(Mage::helper('Mage_Install_Helper_Data')->__('Time Zone'))
  97. ->setClass('required-entry')
  98. ->setValue($this->getTimezone())
  99. ->setOptions(Mage::app()->getLocale()->getOptionTimezones())
  100. ->getHtml();
  101. return $html;
  102. }
  103. /**
  104. * Retrieve timezone
  105. *
  106. * @return string
  107. */
  108. public function getTimezone()
  109. {
  110. $timezone = Mage::getSingleton('Mage_Install_Model_Session')->getTimezone()
  111. ? Mage::getSingleton('Mage_Install_Model_Session')->getTimezone()
  112. : Mage::app()->getLocale()->getTimezone();
  113. if ($timezone == Mage_Core_Model_Locale::DEFAULT_TIMEZONE) {
  114. $timezone = 'America/Los_Angeles';
  115. }
  116. return $timezone;
  117. }
  118. /**
  119. * Retrieve currency dropdown html
  120. *
  121. * @return string
  122. */
  123. public function getCurrencySelect()
  124. {
  125. $html = $this->getLayout()->createBlock('Mage_Core_Block_Html_Select')
  126. ->setName('config[currency]')
  127. ->setId('currency')
  128. ->setTitle(Mage::helper('Mage_Install_Helper_Data')->__('Default Currency'))
  129. ->setClass('required-entry')
  130. ->setValue($this->getCurrency())
  131. ->setOptions(Mage::app()->getLocale()->getOptionCurrencies())
  132. ->getHtml();
  133. return $html;
  134. }
  135. /**
  136. * Retrieve currency
  137. *
  138. * @return string
  139. */
  140. public function getCurrency()
  141. {
  142. return Mage::getSingleton('Mage_Install_Model_Session')->getCurrency()
  143. ? Mage::getSingleton('Mage_Install_Model_Session')->getCurrency()
  144. : Mage::app()->getLocale()->getCurrency();
  145. }
  146. public function getFormData()
  147. {
  148. $data = $this->getData('form_data');
  149. if (is_null($data)) {
  150. $data = new Varien_Object();
  151. $this->setData('form_data', $data);
  152. }
  153. return $data;
  154. }
  155. }