PageRenderTime 53ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

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

https://github.com/chrisroseuk/magento19_dev
PHP | 171 lines | 87 code | 12 blank | 72 comment | 4 complexity | d2d2d4a2da52480f6529a30e66e33eca MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  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) 2014 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. * 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. public function __construct()
  36. {
  37. parent::__construct();
  38. $this->setTemplate('install/locale.phtml');
  39. }
  40. /**
  41. * Retrieve locale object
  42. *
  43. * @return Zend_Locale
  44. */
  45. public function getLocale()
  46. {
  47. $locale = $this->getData('locale');
  48. if (is_null($locale)) {
  49. $locale = Mage::app()->getLocale()->getLocale();
  50. $this->setData('locale', $locale);
  51. }
  52. return $locale;
  53. }
  54. /**
  55. * Retrieve locale data post url
  56. *
  57. * @return string
  58. */
  59. public function getPostUrl()
  60. {
  61. return $this->getCurrentStep()->getNextUrl();
  62. //return $this->getUrl('*/*/localePost');
  63. }
  64. /**
  65. * Retrieve locale change url
  66. *
  67. * @return string
  68. */
  69. public function getChangeUrl()
  70. {
  71. return $this->getUrl('*/*/localeChange');
  72. }
  73. /**
  74. * Retrieve locale dropdown HTML
  75. *
  76. * @return string
  77. */
  78. public function getLocaleSelect()
  79. {
  80. $html = $this->getLayout()->createBlock('core/html_select')
  81. ->setName('config[locale]')
  82. ->setId('locale')
  83. ->setTitle(Mage::helper('install')->__('Locale'))
  84. ->setClass('required-entry')
  85. ->setValue($this->getLocale()->__toString())
  86. ->setOptions(Mage::app()->getLocale()->getTranslatedOptionLocales())
  87. ->getHtml();
  88. return $html;
  89. }
  90. /**
  91. * Retrieve timezone dropdown HTML
  92. *
  93. * @return string
  94. */
  95. public function getTimezoneSelect()
  96. {
  97. $html = $this->getLayout()->createBlock('core/html_select')
  98. ->setName('config[timezone]')
  99. ->setId('timezone')
  100. ->setTitle(Mage::helper('install')->__('Time Zone'))
  101. ->setClass('required-entry')
  102. ->setValue($this->getTimezone())
  103. ->setOptions(Mage::app()->getLocale()->getOptionTimezones())
  104. ->getHtml();
  105. return $html;
  106. }
  107. /**
  108. * Retrieve timezone
  109. *
  110. * @return string
  111. */
  112. public function getTimezone()
  113. {
  114. $timezone = Mage::getSingleton('install/session')->getTimezone()
  115. ? Mage::getSingleton('install/session')->getTimezone()
  116. : Mage::app()->getLocale()->getTimezone();
  117. if ($timezone == Mage_Core_Model_Locale::DEFAULT_TIMEZONE) {
  118. $timezone = 'America/Los_Angeles';
  119. }
  120. return $timezone;
  121. }
  122. /**
  123. * Retrieve currency dropdown html
  124. *
  125. * @return string
  126. */
  127. public function getCurrencySelect()
  128. {
  129. $html = $this->getLayout()->createBlock('core/html_select')
  130. ->setName('config[currency]')
  131. ->setId('currency')
  132. ->setTitle(Mage::helper('install')->__('Default Currency'))
  133. ->setClass('required-entry')
  134. ->setValue($this->getCurrency())
  135. ->setOptions(Mage::app()->getLocale()->getOptionCurrencies())
  136. ->getHtml();
  137. return $html;
  138. }
  139. /**
  140. * Retrieve currency
  141. *
  142. * @return string
  143. */
  144. public function getCurrency()
  145. {
  146. return Mage::getSingleton('install/session')->getCurrency()
  147. ? Mage::getSingleton('install/session')->getCurrency()
  148. : Mage::app()->getLocale()->getCurrency();
  149. }
  150. public function getFormData()
  151. {
  152. $data = $this->getData('form_data');
  153. if (is_null($data)) {
  154. $data = new Varien_Object();
  155. $this->setData('form_data', $data);
  156. }
  157. return $data;
  158. }
  159. }