Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
7e9e8871 | 4 | | CiviCRM version 4.7 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
0f03f337 | 6 | | Copyright CiviCRM LLC (c) 2004-2017 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
0f03f337 | 31 | * @copyright CiviCRM LLC (c) 2004-2017 |
6a488035 TO |
32 | */ |
33 | class CRM_Campaign_StateMachine_Search extends CRM_Core_StateMachine { | |
34 | ||
35 | /** | |
fe482240 | 36 | * The task that the wizard is currently processing. |
6a488035 TO |
37 | * |
38 | * @var string | |
6a488035 TO |
39 | */ |
40 | protected $_task; | |
41 | ||
42 | /** | |
fe482240 | 43 | * Class constructor. |
cde2037d EM |
44 | * |
45 | * @param object $controller | |
46 | * @param \const|int $action | |
95ea96be | 47 | */ |
e7483cbe | 48 | public function __construct($controller, $action = CRM_Core_Action::NONE) { |
6a488035 TO |
49 | parent::__construct($controller, $action); |
50 | ||
51 | $this->_pages = array(); | |
52 | ||
53 | $this->_pages['CRM_Campaign_Form_Search'] = NULL; | |
54 | list($task, $result) = $this->taskName($controller, 'Search'); | |
55 | $this->_task = $task; | |
56 | if (is_array($task)) { | |
57 | foreach ($task as $t) { | |
58 | $this->_pages[$t] = NULL; | |
59 | } | |
60 | } | |
61 | else { | |
62 | $this->_pages[$task] = NULL; | |
63 | } | |
64 | if ($result) { | |
65 | $this->_pages['CRM_Campaign_Form_Task_Result'] = NULL; | |
66 | } | |
67 | ||
68 | $this->addSequentialPages($this->_pages, $action); | |
69 | } | |
70 | ||
71 | /** | |
72 | * Determine the form name based on the action. This allows us | |
73 | * to avoid using conditional state machine, much more efficient | |
74 | * and simpler | |
75 | * | |
7aaf6db0 TO |
76 | * @param CRM_Core_Controller $controller |
77 | * The controller object. | |
6a488035 | 78 | * |
77b97be7 EM |
79 | * @param string $formName |
80 | * | |
a6c01b45 CW |
81 | * @return string |
82 | * the name of the form that will handle the task | |
6a488035 | 83 | */ |
00be9182 | 84 | public function taskName($controller, $formName = 'Search') { |
6a488035 | 85 | // total hack, check POST vars and then session to determine stuff |
45008844 | 86 | $value = CRM_Utils_Array::value('task', $_POST); |
6a488035 TO |
87 | if (!isset($value)) { |
88 | $value = $this->_controller->get('task'); | |
89 | } | |
90 | $this->_controller->set('task', $value); | |
91 | ||
92 | return CRM_Campaign_Task::getTask($value); | |
93 | } | |
94 | ||
95 | /** | |
fe482240 | 96 | * Return the form name of the task. |
6a488035 TO |
97 | * |
98 | * @return string | |
6a488035 | 99 | */ |
00be9182 | 100 | public function getTaskFormName() { |
6a488035 TO |
101 | return CRM_Utils_String::getClassName($this->_task); |
102 | } | |
96025800 | 103 | |
6a488035 | 104 | } |