Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
WizardView.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 
40  abstract class WizardView extends View
41  {
45  protected $model;
46 
51  protected $isBeingCopied;
52 
56  abstract protected function registerClickFlowScript();
57 
62  abstract protected function renderContainingViews(WizardActiveForm $form);
63 
68  abstract protected function renderConfigSaveAjax($formName);
69 
73  public static function getFormId()
74  {
75  return 'edit-form';
76  }
77 
82  public static function getModuleId()
83  {
84  throw new NotImplementedException();
85  }
86 
91  public static function getControllerId()
92  {
93  return 'default';
94  }
95 
102  public static function renderTreeViewAjaxScriptContent($formName, $componentViewClassName, $reportType)
103  {
104  assert('is_string($formName)');
105  assert('is_string($componentViewClassName)');
106  assert('is_string($reportType)');
107  $url = Yii::app()->createUrl(static::getModuleId() . '/' . static::getControllerId() . '/relationsAndAttributesTree',
108  array_merge($_GET, array('type' => $reportType,
109  'treeType' => $componentViewClassName::getTreeType())));
110  // Begin Not Coding Standard
111  $script = "
112  $('#" . $componentViewClassName::getTreeDivId() . "').addClass('loading');
113  $(this).makeLargeLoadingSpinner('" . $componentViewClassName::getTreeDivId() . "');
114  $.ajax({
115  url : '" . $url . "',
116  type : 'POST',
117  data : $('#" . $formName . "').serialize(),
118  success : function(data)
119  {
120  $('#" . $componentViewClassName::getTreeDivId() . "').html(data);
121  },
122  error : function()
123  {
124  //todo: error call
125  }
126  });
127  ";
128  // End Not Coding Standard
129  return $script;
130  }
131 
136  public function __construct(WizardForm $model, $isBeingCopied = false)
137  {
138  assert('is_bool($isBeingCopied)');
139  $this->model = $model;
140  $this->isBeingCopied = $isBeingCopied;
141  }
142 
146  public function isUniqueToAPage()
147  {
148  return true;
149  }
150 
154  protected static function renderValidationScenarioInputContent()
155  {
156  $idInputHtmlOptions = array('id' => static::getValidationScenarioInputId());
157  $hiddenInputName = 'validationScenario';
158  return ZurmoHtml::hiddenField($hiddenInputName, static::getStartingValidationScenario(), $idInputHtmlOptions);
159  }
160 
165  protected static function getStartingValidationScenario()
166  {
167  throw new NotImplementedException();
168  }
169 
173  protected static function getValidationScenarioInputId()
174  {
175  return 'componentType';
176  }
177 
181  protected function renderContent()
182  {
183  $content = $this->renderForm();
184  $this->registerScripts();
185  $this->registerCss();
186  return $content;
187  }
188 
192  protected function renderForm()
193  {
194  $content = '<div class="wrapper">';
195  $content .= $this->renderTitleContent();
196  $content .= '<div class="wide form">';
197  $clipWidget = new ClipWidget();
198  list($form, $formStart) = $clipWidget->renderBeginWidget(
199  'WizardActiveForm',
200  array('id' => static::getFormId(),
201  'action' => $this->getFormActionUrl(),
202  'enableAjaxValidation' => true,
203  'clientOptions' => $this->getClientOptions(),
204  'modelClassNameForError' => get_class($this->model))
205  );
206  $content .= $formStart;
207  $content .= static::renderValidationScenarioInputContent();
208  $content .= $this->renderContainingViews($form);
209  $formEnd = $clipWidget->renderEndWidget();
210  $content .= $formEnd;
211  $content .= $this->renderAfterFormContent();
212  $content .= $this->renderUIOverLayBlock();
213  $content .= '</div>';
214  $content .= '</div>';
215  $content .= $this->renderModalContainer();
216  return $content;
217  }
218 
219  protected function renderUIOverLayBlock()
220  {
221  $spinner = ZurmoHtml::tag('span', array('class' => 'z-spinner'), '');
222  return ZurmoHtml::tag('div', array('class' => 'ui-overlay-block'), $spinner);
223  }
224 
225  protected function renderAfterFormContent()
226  {
227  }
228 
232  protected function getClientOptions()
233  {
234  return array(
235  'validateOnSubmit' => true,
236  'validateOnChange' => false,
237  'beforeValidate' => $this->getBeforeValidateActionScript(),
238  'afterValidate' => 'js:$(this).afterValidateAjaxAction',
239  'afterValidateAjax' => $this->renderConfigSaveAjax(static::getFormId()),
240  );
241  }
242 
248  protected function getBeforeValidateActionScript()
249  {
250  return 'js:$(this).beforeValidateAction';
251  }
252 
253  protected function registerScripts()
254  {
255  //Registered to make sure things work when debug mode is on. Otherwise this is missing.
256  Yii::app()->getClientScript()->registerCoreScript('bbq');
257  $this->registerOperatorOnLoadAndOnChangeScript();
258  }
259 
260  protected function registerCss()
261  {
262  Yii::app()->getClientScript()->registerCssFile(Yii::app()->getClientScript()->getCoreScriptUrl() .
263  '/treeview/jquery.treeview.css');
264  }
265 
269  protected function getFormActionUrl()
270  {
271  return Yii::app()->createUrl(static::getModuleId() . '/' . static::getControllerId() . '/save',
272  array('type' => $this->model->type, 'id' => $this->model->id, 'isBeingCopied' => $this->isBeingCopied));
273  }
274 
281  protected function getSaveAjaxString($formName, $redirectAfterSave = true, array $additionalAjaxOptions = array())
282  {
283  assert('is_string($formName)');
284  $ajaxArray = $this->resolveSaveAjaxArray($formName, $redirectAfterSave, $additionalAjaxOptions);
285  return ZurmoHtml::ajax($ajaxArray);
286  }
287 
294  protected function resolveSaveAjaxArray($formName, $redirectAfterSave = true, array $additionalAjaxOptions = array())
295  {
296  $ajaxArray = array('type' => 'POST',
297  'cache' => 'false',
298  'data' => 'js:$("#' . $formName . '").serialize()',
299  'url' => 'js:$("#' . $formName . '").attr("action")',
300  'dataType' => 'json',
301  );
302  if ($redirectAfterSave)
303  {
304  $ajaxArray['success'] = 'js:function(data)
305  {
306  if (data.redirectToList)
307  {
308  url = "' . $this->resolveSaveRedirectToListUrl() . '";
309  }
310  else
311  {
312  url = "' . $this->resolveSaveRedirectToDetailsUrl() . '" + "?id=" + data.id
313  }
314  window.location.href = url;
315  }';
316  }
317  $ajaxArray = CMap::mergeArray($ajaxArray, $additionalAjaxOptions);
318  return $ajaxArray;
319  }
320 
324  protected function resolveSaveRedirectToDetailsUrl()
325  {
326  return Yii::app()->createUrl(static::getModuleId() . '/' . static::getControllerId() . '/details');
327  }
328 
332  protected function resolveSaveRedirectToListUrl()
333  {
334  return Yii::app()->createUrl(static::getModuleId() . '/' . static::getControllerId() . '/list');
335  }
336 
337  protected function registerOperatorOnLoadAndOnChangeScript()
338  {
339  OperatorStaticDropDownElement::registerOnLoadAndOnChangeScript();
340  }
341 
342  protected function renderModalContainer()
343  {
344  return ZurmoHtml::tag('div', array(
345  'id' => ModelElement::MODAL_CONTAINER_PREFIX . '-' . $this->getFormId()
346  ), '');
347  }
348  }
349 ?>
static getControllerId()
Definition: WizardView.php:91
__construct(WizardForm $model, $isBeingCopied=false)
Definition: WizardView.php:136
static getModuleId()
Definition: WizardView.php:82
resolveSaveRedirectToDetailsUrl()
Definition: WizardView.php:324
static getFormId()
Definition: WizardView.php:73
resolveSaveAjaxArray($formName, $redirectAfterSave=true, array $additionalAjaxOptions=array())
Definition: WizardView.php:294
Definition: View.php:43
getBeforeValidateActionScript()
Definition: WizardView.php:248
static renderValidationScenarioInputContent()
Definition: WizardView.php:154
static getValidationScenarioInputId()
Definition: WizardView.php:173
getClientOptions()
Definition: WizardView.php:232
registerClickFlowScript()
renderConfigSaveAjax($formName)
renderContainingViews(WizardActiveForm $form)
static getStartingValidationScenario()
Definition: WizardView.php:165
resolveSaveRedirectToListUrl()
Definition: WizardView.php:332
getFormActionUrl()
Definition: WizardView.php:269
static renderTreeViewAjaxScriptContent($formName, $componentViewClassName, $reportType)
Definition: WizardView.php:102
getSaveAjaxString($formName, $redirectAfterSave=true, array $additionalAjaxOptions=array())
Definition: WizardView.php:281
Generated on Thu Mar 4 2021 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.