Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
MetadataViewEditView.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 
37  class MetadataViewEditView extends View
38  {
39  protected $controllerId;
40  protected $moduleId;
41  protected $editableMetadata;
42  protected $metadataDisplayName;
43  protected $metadataViewClassName;
44  protected $designerRules;
45  protected $attributeCollection;
46  protected $designerLayoutAttributes;
47  protected $title;
48 
49  public function __construct($controllerId,
50  $moduleId,
51  $moduleClassName,
52  $metadataViewClassName,
53  $editableMetadata,
54  DesignerRules $designerRules,
55  $attributeCollection,
56  DesignerLayoutAttributes $designerLayoutAttributes,
57  $title
58  )
59  {
60  assert('is_array($editableMetadata)');
61  assert('is_array($attributeCollection)');
62  $this->controllerId = $controllerId;
63  $this->moduleId = $moduleId;
64  $this->moduleClassName = $moduleClassName;
65  $this->metadataViewClassName = $metadataViewClassName;
66  $this->editableMetadata = $editableMetadata;
67  $this->designerRules = $designerRules;
68  $this->attributeCollection = $attributeCollection;
69  $this->designerLayoutAttributes = $designerLayoutAttributes;
70  $this->title = $title;
71  }
72 
73  public function isUniqueToAPage()
74  {
75  return true;
76  }
77 
78  protected function renderContent()
79  {
80  $content = $this->renderForm();
81  $this->renderStickyAnchorScript();
82  return $content;
83  }
84 
85  protected function renderForm()
86  {
87  $content = '<div class="wrapper">';
88  $content .= $this->renderTitleContent();
89  $content .= '<div class="wide form">';
90  $content .= '<div class="left-column full-width">';
91  $clipWidget = new ClipWidget();
92  list($form, $formStart) = $clipWidget->renderBeginWidget(
93  'ZurmoActiveForm',
94  array_merge(
95  array('id' => 'edit-form'),
96  array('enableAjaxValidation' => false)
97  )
98  );
99  $content .= $formStart;
100  $content .= '<div class="designer-toolbar">';
101  if ($this->designerRules->canConfigureLayoutPanelsType())
102  {
103  $content .= $this->renderLayoutPanelsType($form);
104  }
105  $content .= '</div>';
106  $content .= $this->renderDesignerLayoutEditorWidget();
107  $content .= '<div class="view-toolbar-container clearfix"><div class="form-toolbar">';
108  $content .= $this->renderSaveLayoutButton('FlashMessageBar');
109  $content .= $this->renderCancelLink();
110  $content .= '</div></div>';
111 
112  $formEnd = $clipWidget->renderEndWidget();
113  $content .= $formEnd;
114  $content .= '</div></div></div>';
115  return $content;
116  }
117 
118  protected function renderSaveLayoutButton($notificationBarId)
119  {
120  Yii::app()->clientScript->registerScriptFile(
121  Yii::app()->getAssetManager()->publish(
122  Yii::getPathOfAlias('application.core.views.assets')
123  ) . '/FormUtils.js',
124  CClientScript::POS_END
125  );
126  $htmlOptions = array();
127  $htmlOptions['id'] = 'saveLayout';
128  $htmlOptions['name'] = 'saveLayout';
129  $htmlOptions['class'] = 'attachLoading z-button';
130  $aContent = ZurmoHtml::wrapLink(Zurmo::t('DesignerModule', 'Save Layout'));
131  return ZurmoHtml::ajaxLink($aContent, '', array(
132  'data' => 'js:designer.prepareSaveLayout("edit-form")',
133  'dataType' => 'json',
134  'type' => 'POST',
135  'beforeSend' => 'js:function(){$(this).attachLoadingOnSubmit("edit-form");}',
136  'complete' => 'js:function(){$(this).detachLoadingOnSubmit("edit-form");}',
137  'success' => 'function(data){designer.updateFlashBarAfterSaveLayout(data, "' . $notificationBarId . '")}', // Not Coding Standard
138  'error' => 'function(data){ ' . // Not Coding Standard
139  'var data = {' . // Not Coding Standard
140  ' "message" : "' . Zurmo::t('Core', 'There was an error processing your request'). '",
141  "type" : "error"
142  };
143  designer.updateFlashBarAfterSaveLayout(data, "' . $notificationBarId . '")
144  }',
145  ), $htmlOptions);
146  }
147 
148  protected function renderCancelLink()
149  {
150  $route = Yii::app()->createUrl($this->moduleId . '/' . $this->controllerId . '/moduleLayoutsList/',
151  array('moduleClassName' => $this->moduleClassName));
152  return ZurmoHtml::link(ZurmoHtml::wrapLabel(Zurmo::t('Core', 'Cancel')), $route, array('class' => 'cancel-button'));
153  }
154 
158  protected function renderLayoutPanelsType($form)
159  {
160  $formModel = PanelsDisplayTypeLayoutMetadataUtil::makeFormFromEditableMetadata($this->editableMetadata);
161  //$this->editableMetadata populate if it exists.
162  $content = null;
163  $element = new LayoutPanelsTypeStaticDropDownElement($formModel, 'type', $form);
164  $element->editableTemplate = '{content}';
165  $content .= $element->render();
166  DropDownUtil::registerScripts();
167  return $content;
168  }
169 
170  protected function renderDesignerLayoutEditorWidget()
171  {
172  $cClipWidget = new CClipWidget();
173  $cClipWidget->beginClip("designerLayoutEditor");
174  $cClipWidget->widget('application.core.widgets.DesignerLayoutEditor', array(
175  'designerLayoutAttributes' => $this->designerLayoutAttributes,
176  'canAddRows' => $this->designerRules->canAddRows(),
177  'canMoveRows' => $this->designerRules->canMoveRows(),
178  'canRemoveRows' => $this->designerRules->canRemoveRows(),
179  'canAddPanels' => $this->designerRules->canAddPanels(),
180  'canModifyPanelSettings' => $this->designerRules->canModifyPanelSettings(),
181  'canRemovePanels' => $this->designerRules->canRemovePanels(),
182  'canMovePanels' => $this->designerRules->canMovePanels(),
183  'canModifyCellSettings' => $this->designerRules->canModifyCellSettings(),
184  'canMergeAndSplitCells' => $this->designerRules->canMergeAndSplitCells(),
185  'maxCellsPerRow' => $this->designerRules->maxCellsPerRow(),
186  'viewMetadata' => $this->designerRules->formatEditableMetadataForLayoutParsing($this->editableMetadata),
187  'mergeRowAndAttributePlacement' => $this->designerRules->mergeRowAndAttributePlacement(),
188  'showRequiredAttributeSpan' => $this->designerRules->requireAllRequiredFieldsInLayout(),
189  ));
190  $cClipWidget->endClip();
191  return $cClipWidget->getController()->clips['designerLayoutEditor'];
192  }
193 
194  protected function renderStickyAnchorScript()
195  {
196  Yii::app()->getClientScript()->registerScriptFile(
197  Yii::app()->getAssetManager()->publish(
198  Yii::getPathOfAlias('application.core.views.assets') . '/StickyUtils.jquery.js'
199  ),
200  CClientScript::POS_END
201  );
202 $script = <<<EOD
203  $(function()
204  {
205  $(window).scroll({canvasId:'MetadataViewEditView'}, sticky_relocate);
206  sticky_relocate({data: { canvasId : 'MetadataViewEditView'}});
207  }
208  );
209 EOD;
210  Yii::app()->getClientScript()->registerScript('DesignerCanvasScript', $script);
211  }
212  }
213 ?>
static wrapLabel($label, $class= 'z-label')
Definition: ZurmoHtml.php:656
static ajaxLink($text, $url, $ajaxOptions=array(), $htmlOptions=array())
Definition: ZurmoHtml.php:328
Definition: View.php:43
static wrapLink($label)
Definition: ZurmoHtml.php:666
Generated on Mon Nov 30 2020 07:10:42
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.