Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
EditAndDetailsView.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 EditAndDetailsView extends DetailsView
41  {
45  protected $renderType;
46 
52  protected $viewContainsFileUploadElement = false;
53 
57  public function __construct($renderType, $controllerId, $moduleId, $model)
58  {
59  assert('$model instanceof RedBeanModel || $model instanceof CFormModel || $model instanceof ModelForm');
60  assert('$renderType == "Edit" || $renderType == "Details"');
61  $this->renderType = $renderType;
62  parent::__construct($controllerId, $moduleId, $model);
63  }
64 
70  protected function renderContent()
71  {
72  if ($this->renderType == 'Details')
73  {
74  return parent::renderContent();
75  }
76  $content = '<div class="wrapper">';
77  $content .= $this->renderTitleContent();
78  $content .= $this->resolveAndRenderActionElementMenuForEdit();
79  $maxCellsPresentInAnyRow = $this->resolveMaxCellsPresentInAnyRow($this->getFormLayoutMetadata());
80  if ($maxCellsPresentInAnyRow > 1)
81  {
82  $class = "wide double-column form";
83  }
84  else
85  {
86  $class = "wide form";
87  }
88  $content .= '<div class="' . $class . '">';
89  $clipWidget = new ClipWidget();
90  list($form, $formStart) = $clipWidget->renderBeginWidget(
91  static::getFormClassName(),
92  array_merge(
93  array('id' => static::getFormId(),
94  'htmlOptions' => $this->resolveFormHtmlOptions()),
95  $this->resolveActiveFormAjaxValidationOptions()
96  )
97  );
98  $content .= $formStart;
99  if ($form != null && $this->renderRightSideFormLayoutForEdit($form) == null)
100  {
101  $class = ' full-width';
102  }
103  else
104  {
105  $class = '';
106  }
107  $formContent = $this->beforeRenderingFormLayout();
108  $formContent .= ZurmoHtml::tag('div', array('class' => 'left-column' . $class), $this->renderFormLayout($form));
109  $formContent .= $this->renderRightSideContent($form);
110  $content .= $this->renderAttributesContainerWrapperDiv($formContent);
111  $content .= $this->renderAfterFormLayout($form);
112  $actionElementContent = $this->renderActionElementBar(true);
113  if ($actionElementContent != null)
114  {
115  $content .= $this->resolveAndWrapDockableViewToolbarContent($actionElementContent);
116  }
117  $formEnd = $clipWidget->renderEndWidget();
118  $content .= $formEnd;
119  $content .= $this->renderModalContainer();
120  $content .= '</div></div>';
121  return $content;
122  }
123 
124  public function getTitle()
125  {
126  if ($this->model->id > 0)
127  {
128  return strval($this->model);
129  }
130  return $this->getNewModelTitleLabel();
131  }
132 
133  protected static function getFormClassName()
134  {
135  return 'ZurmoActiveForm';
136  }
137 
138  protected function renderRightSideContent($form = null)
139  {
140  assert('$form == null || $form instanceof ZurmoActiveForm');
141  if ($form != null)
142  {
143  $rightSideContent = $this->renderRightSideFormLayoutForEdit($form);
144  if ($rightSideContent != null)
145  {
146  $content = ZurmoHtml::tag('div', array('class' => 'right-side-edit-view-panel'), $rightSideContent);
147  $content = ZurmoHtml::tag('div', array('class' => 'right-column'), $content);
148  return $content;
149  }
150  }
151  }
152 
153  protected function renderRightSideFormLayoutForEdit($form)
154  {
155  }
156 
157  protected function renderAfterFormLayout($form)
158  {
159  DropDownUtil::registerScripts();
160  }
161 
162  protected function renderModalContainer()
163  {
164  return ZurmoHtml::tag('div', array('id' => ModelElement::MODAL_CONTAINER_PREFIX . '-' . $this->getFormId()), '');
165  }
166 
167  protected function resolveActiveFormAjaxValidationOptions()
168  {
169  return array('enableAjaxValidation' => false);
170  }
171 
172  public static function getDesignerRulesType()
173  {
174  return 'EditAndDetailsView';
175  }
176 
177  protected function shouldDisplayCell($detailViewOnly)
178  {
179  if ($this->renderType == 'Details')
180  {
181  return true;
182  }
183  return !$detailViewOnly;
184  }
185 
186  protected function shouldDisplayPanel($detailViewOnly)
187  {
188  if ($this->renderType == 'Details')
189  {
190  return true;
191  }
192  return !$detailViewOnly;
193  }
194 
195  protected function shouldRenderToolBarElement($element, $elementInformation)
196  {
197  assert('$element instanceof ActionElement');
198  assert('is_array($elementInformation)');
199  if (!parent::shouldRenderToolBarElement($element, $elementInformation))
200  {
201  return false;
202  }
203  if (!isset($elementInformation['renderType']) ||
204  (isset($elementInformation['renderType']) &&
205  $elementInformation['renderType'] == $this->renderType
206  )
207  )
208  {
209  return true;
210  }
211  return false;
212  }
213 
214  protected static function getFormId()
215  {
216  return 'edit-form';
217  }
218 
219  protected function resolveFormHtmlOptions()
220  {
221  $data = array('onSubmit' => 'js:return $(this).attachLoadingOnSubmit("' . static::getFormId() . '")');
222  if ($this->viewContainsFileUploadElement)
223  {
224  $data['enctype'] = 'multipart/form-data';
225  }
226  return $data;
227  }
228 
229  protected function getNewModelTitleLabel()
230  {
231  throw new NotImplementedException();
232  }
233 
234  protected function beforeRenderingFormLayout()
235  {
236  if ($dedupeRules = DedupeRulesFactory::createRulesByModel($this->model))
237  {
238  $dedupeViewClassName = $dedupeRules->getDedupeViewClassName();
239  $summaryView = new $dedupeViewClassName($this->controllerId,
240  $this->moduleId,
241  $this->model,
242  array());
243  return $summaryView->render();
244  }
245  else
246  {
247  return null;
248  }
249  }
250 
251  protected function resolveAndRenderActionElementMenuForEdit()
252  {
253  }
254 
255  protected function resolveElementDuringFormLayoutRender(& $element)
256  {
257  if ($dedupeRules = DedupeRulesFactory::createRulesByModel($this->model))
258  {
259  $dedupeRules->registerScriptForEditAndDetailsView($element);
260  }
261  parent::resolveElementDuringFormLayoutRender($element);
262  }
263 
264  protected function renderAttributesContainerWrapperDiv($content)
265  {
266  return ZurmoHtml::tag('div', array('class' => 'attributesContainer'), $content);
267  }
268  }
269 ?>
renderFormLayout($form=null)
resolveAndWrapDockableViewToolbarContent($content)
getFormLayoutMetadata()
__construct($renderType, $controllerId, $moduleId, $model)
resolveMaxCellsPresentInAnyRow($metadata)
renderActionElementBar($renderedInForm)
Generated on Tue Jul 14 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.