Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Install_Block_Abstract
  • Mage_Install_Block_Admin
  • Mage_Install_Block_Begin
  • Mage_Install_Block_Config
  • Mage_Install_Block_Db_Main
  • Mage_Install_Block_Db_Type
  • Mage_Install_Block_Db_Type_Mysql4
  • Mage_Install_Block_Download
  • Mage_Install_Block_End
  • Mage_Install_Block_Locale
  • Mage_Install_Block_State
  • Mage_Install_Controller_Action
  • Mage_Install_Helper_Data
  • Mage_Install_IndexController
  • Mage_Install_Model_Config
  • Mage_Install_Model_Installer
  • Mage_Install_Model_Installer_Abstract
  • Mage_Install_Model_Installer_Config
  • Mage_Install_Model_Installer_Console
  • Mage_Install_Model_Installer_Data
  • Mage_Install_Model_Installer_Db
  • Mage_Install_Model_Installer_Db_Abstract
  • Mage_Install_Model_Installer_Db_Mysql4
  • Mage_Install_Model_Installer_Env
  • Mage_Install_Model_Installer_Filesystem
  • Mage_Install_Model_Installer_Pear
  • Mage_Install_Model_Observer
  • Mage_Install_Model_Session
  • Mage_Install_Model_Wizard
  • Mage_Install_WizardController
  • Overview
  • Package
  • Class
  • Tree
  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:  * Installation wizard controller
 29:  */
 30: class Mage_Install_WizardController extends Mage_Install_Controller_Action
 31: {
 32:     public function preDispatch()
 33:     {
 34:         if (Mage::isInstalled()) {
 35:             $this->setFlag('', self::FLAG_NO_DISPATCH, true);
 36:             $this->_redirect('/');
 37:             return;
 38:         }
 39:         $this->setFlag('', self::FLAG_NO_CHECK_INSTALLATION, true);
 40:         return parent::preDispatch();
 41:     }
 42: 
 43:     /**
 44:      * Retrieve installer object
 45:      *
 46:      * @return Mage_Install_Model_Installer
 47:      */
 48:     protected function _getInstaller()
 49:     {
 50:         return Mage::getSingleton('install/installer');
 51:     }
 52: 
 53:     /**
 54:      * Retrieve wizard
 55:      *
 56:      * @return Mage_Install_Model_Wizard
 57:      */
 58:     protected function _getWizard()
 59:     {
 60:         return Mage::getSingleton('install/wizard');
 61:     }
 62: 
 63:     /**
 64:      * Prepare layout
 65:      *
 66:      * @return unknown
 67:      */
 68:     protected function _prepareLayout()
 69:     {
 70:         $this->loadLayout('install_wizard');
 71:         $step = $this->_getWizard()->getStepByRequest($this->getRequest());
 72:         if ($step) {
 73:             $step->setActive(true);
 74:         }
 75: 
 76:         $leftBlock = $this->getLayout()->createBlock('install/state', 'install.state');
 77:         $this->getLayout()->getBlock('left')->append($leftBlock);
 78:         return $this;
 79:     }
 80: 
 81:     /**
 82:      * Checking installation status
 83:      *
 84:      * @return unknown
 85:      */
 86:     protected function _checkIfInstalled()
 87:     {
 88:         if ($this->_getInstaller()->isApplicationInstalled()) {
 89:             $this->getResponse()->setRedirect(Mage::getBaseUrl())->sendResponse();
 90:             exit;
 91:         }
 92:         return true;
 93:     }
 94: 
 95:     /**
 96:      * Index action
 97:      */
 98:     public function indexAction()
 99:     {
100:         $this->_forward('begin');
101:     }
102: 
103:     /**
104:      * Begin installation action
105:      */
106:     public function beginAction()
107:     {
108:         $this->_checkIfInstalled();
109: 
110:         $this->setFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT, true);
111:         $this->setFlag('', self::FLAG_NO_POST_DISPATCH, true);
112: 
113:         $this->_prepareLayout();
114:         $this->_initLayoutMessages('install/session');
115: 
116:         $this->getLayout()->getBlock('content')->append(
117:             $this->getLayout()->createBlock('install/begin', 'install.begin')
118:         );
119: 
120:         $this->renderLayout();
121:     }
122: 
123:     /**
124:      * Process begin step POST data
125:      */
126:     public function beginPostAction()
127:     {
128:         $this->_checkIfInstalled();
129: 
130:         $agree = $this->getRequest()->getPost('agree');
131:         if ($agree && $step = $this->_getWizard()->getStepByName('begin')) {
132:             $this->getResponse()->setRedirect($step->getNextUrl());
133:         }
134:         else {
135:             $this->_redirect('install');
136:         }
137:     }
138: 
139:     /**
140:      * Localization settings
141:      */
142:     public function localeAction()
143:     {
144:         $this->_checkIfInstalled();
145:         $this->setFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT, true);
146:         $this->setFlag('', self::FLAG_NO_POST_DISPATCH, true);
147: 
148:         $this->_prepareLayout();
149:         $this->_initLayoutMessages('install/session');
150:         $this->getLayout()->getBlock('content')->append(
151:             $this->getLayout()->createBlock('install/locale', 'install.locale')
152:         );
153: 
154:         $this->renderLayout();
155:     }
156: 
157:     /**
158:      * Change current locale
159:      */
160:     public function localeChangeAction()
161:     {
162:         $this->_checkIfInstalled();
163: 
164:         $locale = $this->getRequest()->getParam('locale');
165:         $timezone = $this->getRequest()->getParam('timezone');
166:         $currency = $this->getRequest()->getParam('currency');
167:         if ($locale) {
168:             Mage::getSingleton('install/session')->setLocale($locale);
169:             Mage::getSingleton('install/session')->setTimezone($timezone);
170:             Mage::getSingleton('install/session')->setCurrency($currency);
171:         }
172: 
173:         $this->_redirect('*/*/locale');
174:     }
175: 
176:     /**
177:      * Saving localization settings
178:      */
179:     public function localePostAction()
180:     {
181:         $this->_checkIfInstalled();
182:         $step = $this->_getWizard()->getStepByName('locale');
183: 
184:         if ($data = $this->getRequest()->getPost('config')) {
185:             Mage::getSingleton('install/session')->setLocaleData($data);
186:         }
187: 
188:         $this->getResponse()->setRedirect($step->getNextUrl());
189:     }
190: 
191:     public function downloadAction()
192:     {
193:         $this->_checkIfInstalled();
194:         $this->setFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT, true);
195:         $this->setFlag('', self::FLAG_NO_POST_DISPATCH, true);
196: 
197:         $this->_prepareLayout();
198:         $this->_initLayoutMessages('install/session');
199:         $this->getLayout()->getBlock('content')->append(
200:             $this->getLayout()->createBlock('install/download', 'install.download')
201:         );
202: 
203:         $this->renderLayout();
204:     }
205: 
206:     public function downloadPostAction()
207:     {
208:         $this->_checkIfInstalled();
209:         switch ($this->getRequest()->getPost('continue')) {
210:             case 'auto':
211:                 $this->_forward('downloadAuto');
212:                 break;
213: 
214:             case 'manual':
215:                 $this->_forward('downloadManual');
216:                 break;
217: 
218:             case 'svn':
219:                 $step = $this->_getWizard()->getStepByName('download');
220:                 $this->getResponse()->setRedirect($step->getNextUrl());
221:                 break;
222: 
223:             default:
224:                 $this->_redirect('*/*/download');
225:         }
226:     }
227: 
228:     public function downloadAutoAction()
229:     {
230:         $step = $this->_getWizard()->getStepByName('download');
231:         $this->getResponse()->setRedirect($step->getNextUrl());
232:     }
233: 
234:     public function installAction()
235:     {
236:         $pear = Varien_Pear::getInstance();
237:         $params = array('comment'=>Mage::helper('install')->__("Downloading and installing Magento, please wait...") . "\r\n\r\n");
238:         if ($this->getRequest()->getParam('do')) {
239:             if ($state = $this->getRequest()->getParam('state', 'beta')) {
240:                 $result = $pear->runHtmlConsole(array(
241:                 'comment'   => Mage::helper('install')->__("Setting preferred state to: %s", $state) . "\r\n\r\n",
242:                 'command'   => 'config-set',
243:                 'params'    => array('preferred_state', $state)
244:                 ));
245:                 if ($result instanceof PEAR_Error) {
246:                     $this->installFailureCallback();
247:                     exit;
248:                 }
249:             }
250:             $params['command'] = 'install';
251:             $params['options'] = array('onlyreqdeps'=>1);
252:             $params['params'] = Mage::getModel('install/installer_pear')->getPackages();
253:             $params['success_callback'] = array($this, 'installSuccessCallback');
254:             $params['failure_callback'] = array($this, 'installFailureCallback');
255:         }
256:         $pear->runHtmlConsole($params);
257:         Mage::app()->getFrontController()->getResponse()->clearAllHeaders();
258:     }
259: 
260:     public function installSuccessCallback()
261:     {
262:         echo 'parent.installSuccess()';
263:     }
264: 
265:     public function installFailureCallback()
266:     {
267:         echo 'parent.installFailure()';
268:     }
269: 
270:     public function downloadManualAction()
271:     {
272:         $step = $this->_getWizard()->getStepByName('download');
273:         #if (!$this->_getInstaller()->checkDownloads()) {
274:         #    $this->getResponse()->setRedirect($step->getUrl());
275:         #} else {
276:         $this->getResponse()->setRedirect($step->getNextUrl());
277:         #}
278:     }
279: 
280:     /**
281:      * Configuration data installation
282:      */
283:     public function configAction()
284:     {
285:         $this->_checkIfInstalled();
286:         $this->_getInstaller()->checkServer();
287: 
288:         $this->setFlag('', self::FLAG_NO_DISPATCH_BLOCK_EVENT, true);
289:         $this->setFlag('', self::FLAG_NO_POST_DISPATCH, true);
290: 
291:         if ($data = $this->getRequest()->getQuery('config')) {
292:             Mage::getSingleton('install/session')->setLocaleData($data);
293:         }
294: 
295:         $this->_prepareLayout();
296:         $this->_initLayoutMessages('install/session');
297:         $this->getLayout()->getBlock('content')->append(
298:             $this->getLayout()->createBlock('install/config', 'install.config')
299:         );
300: 
301:         $this->renderLayout();
302:     }
303: 
304:     /**
305:      * Process configuration POST data
306:      */
307:     public function configPostAction()
308:     {
309:         $this->_checkIfInstalled();
310:         $step = $this->_getWizard()->getStepByName('config');
311: 
312:         $config             = $this->getRequest()->getPost('config');
313:         $connectionConfig   = $this->getRequest()->getPost('connection');
314: 
315:         if ($config && $connectionConfig && isset($connectionConfig[$config['db_model']])) {
316: 
317:             $data = array_merge($config, $connectionConfig[$config['db_model']]);
318: 
319:             Mage::getSingleton('install/session')
320:                 ->setConfigData($data)
321:                 ->setSkipUrlValidation($this->getRequest()->getPost('skip_url_validation'))
322:                 ->setSkipBaseUrlValidation($this->getRequest()->getPost('skip_base_url_validation'));
323:             try {
324:                 $this->_getInstaller()->installConfig($data);
325:                 $this->_redirect('*/*/installDb');
326:                 return $this;
327:             }
328:             catch (Exception $e){
329:                 Mage::getSingleton('install/session')->addError($e->getMessage());
330:                 $this->getResponse()->setRedirect($step->getUrl());
331:             }
332:         }
333:         $this->getResponse()->setRedirect($step->getUrl());
334:     }
335: 
336:     /**
337:      * Install DB
338:      */
339:     public function installDbAction()
340:     {
341:         $this->_checkIfInstalled();
342:         $step = $this->_getWizard()->getStepByName('config');
343:         try {
344:             $this->_getInstaller()->installDb();
345:             /**
346:              * Clear session config data
347:              */
348:             Mage::getSingleton('install/session')->getConfigData(true);
349: 
350:             Mage::app()->getStore()->resetConfig();
351: 
352:             $this->getResponse()->setRedirect(Mage::getUrl($step->getNextUrlPath()));
353:         }
354:         catch (Exception $e){
355:             Mage::getSingleton('install/session')->addError($e->getMessage());
356:             $this->getResponse()->setRedirect($step->getUrl());
357:         }
358:     }
359: 
360:     /**
361:      * Install administrator account
362:      */
363:     public function administratorAction()
364:     {
365:         $this->_checkIfInstalled();
366: 
367:         $this->_prepareLayout();
368:         $this->_initLayoutMessages('install/session');
369: 
370:         $this->getLayout()->getBlock('content')->append(
371:             $this->getLayout()->createBlock('install/admin', 'install.administrator')
372:         );
373:         $this->renderLayout();
374:     }
375: 
376:     /**
377:      * Process administrator instalation POST data
378:      */
379:     public function administratorPostAction()
380:     {
381:         $this->_checkIfInstalled();
382: 
383:         $step = Mage::getSingleton('install/wizard')->getStepByName('administrator');
384:         $adminData      = $this->getRequest()->getPost('admin');
385:         $encryptionKey  = $this->getRequest()->getPost('encryption_key');
386: 
387:         $errors = array();
388: 
389:         //preparing admin user model with data and validate it
390:         $user = $this->_getInstaller()->validateAndPrepareAdministrator($adminData);
391:         if (is_array($user)) {
392:             $errors = $user;
393:         }
394: 
395:         //checking if valid encryption key was entered
396:         $result = $this->_getInstaller()->validateEncryptionKey($encryptionKey);
397:         if (is_array($result)) {
398:             $errors = array_merge($errors, $result);
399:         }
400: 
401:         if (!empty($errors)) {
402:             Mage::getSingleton('install/session')->setAdminData($adminData);
403:             $this->getResponse()->setRedirect($step->getUrl());
404:             return false;
405:         }
406: 
407:         try {
408:             $this->_getInstaller()->createAdministrator($user);
409:             $this->_getInstaller()->installEnryptionKey($encryptionKey);
410:         } catch (Exception $e){
411:             Mage::getSingleton('install/session')
412:                 ->setAdminData($adminData)
413:                 ->addError($e->getMessage());
414:             $this->getResponse()->setRedirect($step->getUrl());
415:             return false;
416:         }
417:         $this->getResponse()->setRedirect($step->getNextUrl());
418:     }
419: 
420:     /**
421:      * End installation
422:      */
423:     public function endAction()
424:     {
425:         $this->_checkIfInstalled();
426: 
427:         $date = (string)Mage::getConfig()->getNode('global/install/date');
428:         if ($date !== Mage_Install_Model_Installer_Config::TMP_INSTALL_DATE_VALUE) {
429:             $this->_redirect('*/*');
430:             return;
431:         }
432: 
433:         $this->_getInstaller()->finish();
434: 
435:         Mage_AdminNotification_Model_Survey::saveSurveyViewed(true);
436: 
437:         $this->_prepareLayout();
438:         $this->_initLayoutMessages('install/session');
439: 
440:         $this->getLayout()->getBlock('content')->append(
441:             $this->getLayout()->createBlock('install/end', 'install.end')
442:         );
443:         $this->renderLayout();
444:         Mage::getSingleton('install/session')->clear();
445:     }
446: 
447:     /**
448:      * Host validation response
449:      */
450:     public function checkHostAction()
451:     {
452:         $this->getResponse()->setHeader('Transfer-encoding', '', true);
453:         $this->getResponse()->setBody(Mage_Install_Model_Installer::INSTALLER_HOST_RESPONSE);
454:     }
455: 
456:     /**
457:      * Host validation response
458:      */
459:     public function checkSecureHostAction()
460:     {
461:         $this->getResponse()->setHeader('Transfer-encoding', '', true);
462:         $this->getResponse()->setBody(Mage_Install_Model_Installer::INSTALLER_HOST_RESPONSE);
463:     }
464: }
465: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0