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