Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
InlineEditView.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 InlineEditView extends EditView
41  {
46  protected $saveActionId;
47 
52  protected $urlParameters;
53 
58  protected $uniquePageId;
59 
60  public function __construct(RedBeanModel $model, $controllerId, $moduleId, $saveActionId, $urlParameters, $uniquePageId)
61  {
62  assert('is_string($controllerId)');
63  assert('is_string($moduleId)');
64  assert('is_string($saveActionId)');
65  assert('is_array($urlParameters)');
66  assert('is_string($uniquePageId) || $uniquePageId == null');
67  $this->model = $model;
68  $this->modelClassName = get_class($model);
69  $this->controllerId = $controllerId;
70  $this->moduleId = $moduleId;
71  $this->saveActionId = $saveActionId;
72  $this->urlParameters = $urlParameters;
73  $this->uniquePageId = $uniquePageId;
74  }
75 
76  protected function renderContent()
77  {
78  $this->registerScripts();
79  $formName = $this->getFormName();
80  $afterValidateAjax = $this->renderConfigSaveAjax($formName);
81  $content = $this->renderContentStartFormDiv();
82  $clipWidget = new ClipWidget();
83  list($form, $formStart) = $clipWidget->renderBeginWidget(
84  'ZurmoActiveForm',
85  array(
86  'id' => $formName,
87  'action' => $this->getValidateAndSaveUrl(),
88  'enableAjaxValidation' => true,
89  'clientOptions' => array(
90  'validateOnSubmit' => true,
91  'validateOnChange' => false,
92  'beforeValidate' => 'js:$(this).beforeValidateAction',
93  'afterValidate' => 'js:$(this).afterValidateAjaxAction',
94  'afterValidateAjax' => $afterValidateAjax,
95  ),
96  )
97  );
98  $content .= $formStart;
99  $formContent = $this->renderFormLayout($form) . $this->renderAfterFormLayout($form);
100  $content .= $this->wrapFormLayoutContent($formContent);
101  $actionElementContent = $this->renderActionElementBar(true);
102  if ($actionElementContent != null)
103  {
104  $content .= '<div class="view-toolbar-container clearfix"><div class="form-toolbar clearfix">';
105  $content .= $actionElementContent;
106  $content .= '</div></div>';
107  }
108  $formEnd = $clipWidget->renderEndWidget();
109  $content .= $formEnd;
110  $content .= $this->renderModalContainer();
111  $content .= $this->renderContentEndFormDiv();
112  return $content;
113  }
114 
115  protected function renderContentStartFormDiv()
116  {
117  return ZurmoHtml::openTag('div', array('class' => 'wide form'));
118  }
119 
120  protected function renderContentEndFormDiv()
121  {
122  return ZurmoHtml::closeTag('div');
123  }
124 
125  protected function registerScripts()
126  {
127  $cs = Yii::app()->getClientScript();
128  $cs->registerScriptFile(
129  Yii::app()->getAssetManager()->publish(
130  Yii::getPathOfAlias('application.core.elements.assets')
131  ) . '/Modal.js',
132  CClientScript::POS_END
133  );
134  }
135 
136  protected function wrapFormLayoutContent($content)
137  {
138  return ZurmoHtml::tag('div', array('class' => 'left-column full-width'), $content);
139  }
140 
141  public function getFormName()
142  {
143  return self::getFormId();
144  }
145 
146  protected static function getFormId()
147  {
148  return "inline-edit-form";
149  }
150 
151  protected function renderModalContainer()
152  {
153  return ZurmoHtml::tag('div', array(
154  'id' => ModelElement::MODAL_CONTAINER_PREFIX . '-' . $this->getFormName()
155  ), '');
156  }
157 
158  protected function renderConfigSaveAjax($formName)
159  {
160  return ZurmoHtml::ajax(array(
161  'type' => 'POST',
162  'data' => 'js:$("#' . $formName . '").serialize()',
163  'url' => $this->getValidateAndSaveUrl(),
164  'update' => '#' . $this->uniquePageId,
165  ));
166  }
167 
168  protected function getValidateAndSaveUrl()
169  {
170  return Yii::app()->createUrl($this->moduleId . '/' . $this->controllerId . '/' . $this->saveActionId, $this->urlParameters);
171  }
172 
173  public function isUniqueToAPage()
174  {
175  return false;
176  }
177 
178  public function getPostArrayName()
179  {
180  return get_class($this->model);
181  }
182 
183  public function setMetadataFromPost($postArray)
184  {
185  $this->model->setAttributes($postArray);
186  }
187 
188  public function validate()
189  {
190  echo ZurmoActiveForm::validate($this->model);
191  }
192 
193  public static function getDesignerRulesType()
194  {
195  return 'InlineEditView';
196  }
197 
198  public function getViewMetadata()
199  {
200  return $this->model->getAttributes();
201  }
202 
203  protected function getMorePanelsLinkLabel()
204  {
205  return Zurmo::t('Core', 'More Options');
206  }
207 
208  protected function getLessPanelsLinkLabel()
209  {
210  return Zurmo::t('Core', 'Fewer Options');
211  }
212 
213  public static function getDisplayDescription()
214  {
215  return null;
216  }
217  }
218 ?>
renderFormLayout($form=null)
renderActionElementBar($renderedInForm)
Generated on Fri Jul 10 2020 07:10:28
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.