All Data Structures Functions Variables Pages
InstallSettingsView.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
41  {
42  protected $controllerId;
43 
44  protected $moduleId;
45 
46  protected $model;
47 
53  public function __construct($controllerId, $moduleId, $model)
54  {
55  assert('$model instanceof CFormModel');
56  $this->controllerId = $controllerId;
57  $this->moduleId = $moduleId;
58  $this->model = $model;
59  }
60 
66  protected function renderContent()
67  {
68  $content = '<div class="wide form">';
69  $clipWidget = new ClipWidget();
70  list($form, $formStart) = $clipWidget->renderBeginWidget(
71  'ZurmoActiveForm',
72  array_merge(
73  array('id' => 'install-form'),
74  $this->resolveActiveFormAjaxValidationOptions()
75  )
76  );
77  $content .= $formStart;
78  $content .= $this->renderFormLayout($form);
79  $formEnd = $clipWidget->renderEndWidget();
80  $content .= $formEnd;
81 
82  $content .= '</div>';
83  return $content;
84  }
85 
90  protected function renderFormLayout($form = null)
91  {
92  $metadata = self::getMetadata();
93  $content = '<table>';
94  $content .= '<colgroup><col/><col/><col/></colgroup>';
95  assert('count($metadata["global"]["panels"]) == 1');
96  foreach ($metadata['global']['panels'] as $key => $panel)
97  {
98  $content .= '<tbody>';
99  foreach ($panel['rows'] as $row)
100  {
101  $content .= '<tr>';
102  foreach ($row['cells'] as $cell)
103  {
104  if (!empty($cell['elements']))
105  {
106  foreach ($cell['elements'] as $elementInformation)
107  {
108  $elementclassname = $elementInformation['type'] . 'Element';
109  $element = new $elementclassname($this->model, $elementInformation['attributeName'],
110  $form, array_slice($elementInformation, 2));
111  $element->editableTemplate = '<th nowrap="nowrap">{label}</th><td
112  colspan="{colspan}">{content}{error}</td>';
113  $content .= $element->render();
114  $content .= '<td>' . Yii::app()->format->text($elementInformation['description']) . '</td>';
115  }
116  }
117  }
118  $content .= '</tr>';
119  }
120  $content .= '</tbody>';
121  }
122  $content .= '</table>';
123  $element = new SaveButtonActionElement($this->controllerId, $this->moduleId,
124  null, array('label' => Zurmo::t('InstallModule', 'Install')));
125  $content .= '<div class="view-toolbar-container clearfix"><div class="form-toolbar">' . $element->render() . '</div></div>';
126  return $content;
127  }
128 
129  public static function getDefaultMetadata()
130  {
131  $metadata = array(
132  'global' => array(
133  'panels' => array(
134  array(
135  'rows' => array(
136  array('cells' =>
137  array(
138  array(
139  'elements' => array(
140  array('attributeName' => 'databaseHostname', 'type' => 'Text',
141  'description' => Zurmo::t('InstallModule', 'Can either be a domain ' .
142  'name or an IP address.')),
143  ),
144  ),
145  ),
146  ),
147  array('cells' =>
148  array(
149  array(
150  'elements' => array(
151  array('attributeName' => 'databasePort', 'type' => 'Text',
152  'description' => Zurmo::t('InstallModule', 'Database port.')),
153  ),
154  ),
155  ),
156  ),
157  array('cells' =>
158  array(
159  array(
160  'elements' => array(
161  array('attributeName' => 'databaseAdminUsername', 'type' => 'Text',
162  'description' => Zurmo::t('InstallModule', 'Leave this blank unless you ' .
163  'would like to create the user and database for Zurmo to run in.',
165  ),
166  ),
167  )
168  ),
169  array('cells' =>
170  array(
171  array(
172  'elements' => array(
173  array('attributeName' => 'databaseAdminPassword', 'type' => 'Password',
174  'description' => Zurmo::t('InstallModule', 'Leave this blank unless you ' .
175  'would like to create the user and database for Zurmo to run in.',
177  ),
178  ),
179  )
180  ),
181  array('cells' =>
182  array(
183  array(
184  'elements' => array(
185  array('attributeName' => 'databaseName', 'type' => 'Text',
186  'description' => Zurmo::t('InstallModule', 'The name of the database you ' .
187  'want to run Zurmo in.', LabelUtil::getZurmoLabelParam())),
188  ),
189  ),
190  )
191  ),
192  array('cells' =>
193  array(
194  array(
195  'elements' => array(
196  array('attributeName' => 'removeExistingData', 'type' => 'CheckBox',
197  'description' => Zurmo::t('InstallModule', 'WARNING! - If the database ' .
198  'already exists the data will be completely removed. ' .
199  'This must be checked if you are specifying an existing database.')),
200  ),
201  ),
202  )
203  ),
204  array('cells' =>
205  array(
206  array(
207  'elements' => array(
208  array('attributeName' => 'databaseUsername', 'type' => 'Text',
209  'description' => Zurmo::t('InstallModule', 'User who can connect ' .
210  'to the database.')),
211  ),
212  ),
213  )
214  ),
215  array('cells' =>
216  array(
217  array(
218  'elements' => array(
219  array('attributeName' => 'databasePassword', 'type' => 'Password',
220  'description' => Zurmo::t('InstallModule', 'User`s password.')),
221  ),
222  ),
223  )
224  ),
225  array('cells' =>
226  array(
227  array(
228  'elements' => array(
229  array('attributeName' => 'superUserPassword', 'type' => 'Text',
230  'description' => Zurmo::t('InstallModule', 'Zurmo administrative password. ' .
231  'The username is `super`. You can change this later.',
233  ),
234  ),
235  )
236  ),
237  array('cells' =>
238  array(
239  array(
240  'elements' => array(
241  array('attributeName' => 'memcacheHostname', 'type' => 'MemcacheText',
242  'description' => Zurmo::t('InstallModule', 'Memcache host name. Default ' .
243  'is 127.0.0.1')),
244  ),
245  ),
246  )
247  ),
248  array('cells' =>
249  array(
250  array(
251  'elements' => array(
252  array('attributeName' => 'memcachePortNumber', 'type' => 'MemcacheText',
253  'description' => Zurmo::t('InstallModule', 'Memcache port number. Default ' .
254  'is 11211')),
255  ),
256  ),
257  )
258  ),
259  array('cells' =>
260  array(
261  array(
262  'elements' => array(
263  array('attributeName' => 'installDemoData', 'type' => 'CheckBox',
264  'description' => Zurmo::t('InstallModule', 'Install demo data.')),
265  ),
266  ),
267  )
268  ),
269  array('cells' =>
270  array(
271  array(
272  'elements' => array(
273  array('attributeName' => 'hostInfo', 'type' => 'Text',
274  'description' => Zurmo::t('InstallModule', 'Host name where Zurmo will be installed.',
276  ),
277  ),
278  )
279  ),
280  array('cells' =>
281  array(
282  array(
283  'elements' => array(
284  array('attributeName' => 'scriptUrl', 'type' => 'Text',
285  'description' => Zurmo::t('InstallModule', 'The relative path where ' .
286  'Zurmo will be installed.',
288  ),
289  ),
290  )
291  ),
292  ),
293  ),
294  ),
295  ),
296  );
297  return $metadata;
298  }
299 
300  protected function resolveActiveFormAjaxValidationOptions()
301  {
302  return array('enableAjaxValidation' => true,
303  'clientOptions' => array(
304  'beforeValidate' => 'js:$(this).beforeValidateAction',
305  'afterValidate' => 'js:$(this).afterValidateAction',
306  'validateOnSubmit' => true,
307  'validateOnChange' => false,
308  'inputContainer' => 'td',
309  )
310  );
311  }
312  }
313 ?>
__construct($controllerId, $moduleId, $model)
static getZurmoLabelParam()
Definition: LabelUtil.php:97
Generated on Sat Feb 22 2020 07:10:31