Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ModalConfigEditView.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  abstract class ModalConfigEditView extends EditView
42  {
43  protected $params;
44 
45  public function __construct(ConfigurableMetadataModel $model, $params)
46  {
47  $this->model = $model;
48  $this->modelClassName = get_class($model);
49  $this->modelId = null;
50  $this->params = $params;
51  }
52 
53  protected function renderContent()
54  {
55  assert('isset($this->params["controllerId"])');
56  assert('isset($this->params["moduleId"])');
57  assert('isset($this->params["modalConfigSaveAction"])');
58  assert('isset($this->params["uniquePortletPageId"])');
59 
60  $formName = $this->getFormId();
61  $afterValidateAjax = $this->renderConfigSaveAjax(
62  $formName,
63  $this->params['moduleId'],
64  $this->params['controllerId'],
65  $this->params['modalConfigSaveAction'],
66  $this->params['uniquePortletPageId']
67  );
68  $content = '<div class="wide form">';
69  $clipWidget = new ClipWidget();
70  list($form, $formStart) = $clipWidget->renderBeginWidget(
71  $this->getActiveFormClassName(),
72  array(
73  'id' => $formName,
74  'enableAjaxValidation' => true,
75  'clientOptions' => array(
76  'validateOnSubmit' => true,
77  'validateOnChange' => false,
78  'beforeValidate' => 'js:$(this).beforeValidateAction',
79  'afterValidate' => 'js:$(this).afterValidateAjaxAction',
80  'afterValidateAjax' => $afterValidateAjax,
81  ),
82  )
83  );
84 
85  $cs = Yii::app()->getClientScript();
86  $cs->registerScriptFile(
87  Yii::app()->getAssetManager()->publish(
88  Yii::getPathOfAlias('application.core.elements.assets')
89  ) . '/Modal.js',
90  CClientScript::POS_END
91  );
92  $content .= $formStart;
93  $content .= $this->renderFormLayout($form);
94  $content .= $this->renderAfterFormLayout($form);
95  $actionElementContent = $this->renderActionElementBar(true);
96  if ($actionElementContent != null)
97  {
98  $content .= '<div class="view-toolbar-container clearfix"><div class="modal-view-toolbar">';
99  $content .= $actionElementContent;
100  $content .= '</div></div>';
101  }
102  $formEnd = $clipWidget->renderEndWidget();
103  $content .= $formEnd;
104  $content .= $this->renderModalContainer();
105  $content .= '</div>';
106  return $content;
107  }
108 
109  protected function renderConfigSaveAjax($formName, $moduleId, $controllerId, $actionSave, $uniquePortletPageId)
110  {
111  return ZurmoHtml::ajax(array(
112  'type' => 'POST',
113  'data' => 'js:$("#' . $formName . '").serialize()',
114  'url' => Yii::app()->createUrl($moduleId . '/' . $controllerId . '/' . $actionSave, $_GET),
115  'complete' => 'function(XMLHttpRequest, textStatus){$("#modalContainer").dialog("close");
116  juiPortlets.refresh();}',
117  'update' => '#' . $uniquePortletPageId,
118  ));
119  }
120 
121  public function isUniqueToAPage()
122  {
123  return true;
124  }
125 
126  public function getPostArrayName()
127  {
128  return get_class($this->model);
129  }
130 
131  public function setMetadataFromPost($postArray)
132  {
133  $this->model->setAttributes($postArray);
134  }
135 
136  public function validate()
137  {
138  echo ZurmoActiveForm::validate($this->model);
139  }
140 
141  public function getViewMetadata()
142  {
143  return $this->model->getAttributes();
144  }
145 
146  protected static function getActiveFormClassName()
147  {
148  return 'ZurmoActiveForm';
149  }
150 
151  protected static function getFormId()
152  {
153  return 'modal-edit-form';
154  }
155  }
156 ?>
renderFormLayout($form=null)
renderActionElementBar($renderedInForm)
Generated on Wed Jul 1 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.