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 model
29: *
30: * @category Mage
31: * @package Mage_Install
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Install_Model_Wizard
35: {
36: /**
37: * Wizard configuration
38: *
39: * @var array
40: */
41: protected $_steps = array();
42:
43: public function __construct()
44: {
45: $this->_steps = Mage::getSingleton('install/config')->getWizardSteps();
46:
47: foreach ($this->_steps as $index => $step) {
48: $this->_steps[$index]->setUrl(
49: $this->_getUrl($this->_steps[$index]->getController(), $this->_steps[$index]->getAction())
50: );
51:
52: if (isset($this->_steps[$index + 1])) {
53: $this->_steps[$index]->setNextUrl(
54: $this->_getUrl($this->_steps[$index + 1]->getController(), $this->_steps[$index + 1]->getAction())
55: );
56: $this->_steps[$index]->setNextUrlPath(
57: $this->_getUrlPath($this->_steps[$index + 1]->getController(), $this->_steps[$index + 1]->getAction())
58: );
59: }
60: if (isset($this->_steps[$index - 1])) {
61: $this->_steps[$index]->setPrevUrl(
62: $this->_getUrl($this->_steps[$index - 1]->getController(), $this->_steps[$index - 1]->getAction())
63: );
64: $this->_steps[$index]->setPrevUrlPath(
65: $this->_getUrlPath($this->_steps[$index - 1]->getController(), $this->_steps[$index - 1]->getAction())
66: );
67: }
68: }
69: }
70:
71: /**
72: * Get wizard step by request
73: *
74: * @param Mage_Core_Controller_Zend_Request $request
75: * @return Varien_Object || false
76: */
77: public function getStepByRequest(Zend_Controller_Request_Abstract $request)
78: {
79: foreach ($this->_steps as $step) {
80: if ($step->getController() == $request->getControllerName()
81: && $step->getAction() == $request->getActionName()) {
82: return $step;
83: }
84: }
85: return false;
86: }
87:
88: /**
89: * Get wizard step by name
90: *
91: * @param string $name
92: * @return Varien_Object || false
93: */
94: public function getStepByName($name)
95: {
96: foreach ($this->_steps as $step) {
97: if ($step->getName() == $name) {
98: return $step;
99: }
100: }
101: return false;
102: }
103:
104: /**
105: * Get all wizard steps
106: *
107: * @return array
108: */
109: public function getSteps()
110: {
111: return $this->_steps;
112: }
113:
114: protected function _getUrl($controller, $action)
115: {
116: return Mage::getUrl($this->_getUrlPath($controller, $action));
117: }
118:
119: /**
120: * Retrieve Url Path
121: *
122: * @param string $controller
123: * @param string $action
124: * @return string
125: */
126: protected function _getUrlPath($controller, $action)
127: {
128: return 'install/' . $controller . '/' . $action;
129: }
130: }
131: