Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ContactExternalEditAndDetailsView.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 
38  {
39  public $externalViewMetadata;
40 
41  protected $hashIndexHiddenField;
42 
43  const GOOGLE_WEB_TRACKING_ID_FIELD = 'googleWebTrackingId';
44 
45  public function __construct($renderType, $controllerId, $moduleId, $model, $metadata)
46  {
47  parent::__construct($renderType, $controllerId, $moduleId, $model);
48  $this->externalViewMetadata = $metadata;
49  $this->hashIndexHiddenField = ContactWebFormEntry::HASH_INDEX_HIDDEN_FIELD;
50  }
51 
52  public static function getDesignerRulesType()
53  {
54  return null;
55  }
56 
57  public static function getDefaultMetadata()
58  {
59  $metadata = array(
60  'global' => array(
61  'toolbar' => array(
62  'elements' => array(
63  array('type' => 'SaveButton', 'renderType' => 'Edit', 'label' => 'Save'),
64  ),
65  ),
66  'derivedAttributeTypes' => array(
67  'TitleFullName',
68  'ContactStateDropDown',
69  ),
70  'nonPlaceableAttributeNames' => array(
71  'owner',
72  'state',
73  ),
74  'panelsDisplayType' => FormLayout::PANELS_DISPLAY_TYPE_ALL,
75  'panels' => array(),
76  ),
77  );
78  return $metadata;
79  }
80 
81  protected function getFormLayoutMetadata()
82  {
83  return $this->externalViewMetadata;
84  }
85 
86  protected function resolveActiveFormAjaxValidationOptions()
87  {
88  $ajaxValidationOptions = array('enableAjaxValidation' => true,
89  'clientOptions' => array(
90  'validateOnSubmit' => true,
91  'validateOnChange' => false,
92  'beforeValidate' => 'js:$(this).beforeValidateAction',
93  'afterValidate' => 'js:$(this).afterValidateAjaxAction',
94  'afterValidateAjax' => $this->renderConfigSaveAjax()));
95  return array_merge($ajaxValidationOptions,
96  array('action' => $this->getValidateAndSaveUrl()));
97  }
98 
99  protected function renderConfigSaveAjax()
100  {
101  $formId = $this->getFormId();
102  return ZurmoHtml::ajax(array(
103  'type' => 'POST',
104  'data' => 'js:$("#' . $formId . '").serialize()',
105  'url' => $this->getValidateAndSaveUrl(),
106  'success' => 'js: function(data)
107  {
108  if (typeof data.redirectUrl !== \'undefined\' &&
109  $(this).isValidUrl(data.redirectUrl))
110  {
111  window.location.href = data.redirectUrl;
112  }
113  }'
114  ));
115  }
116 
117  protected function getValidateAndSaveUrl()
118  {
119  return Yii::app()->createAbsoluteUrl($this->moduleId . '/' . $this->controllerId . '/form',
120  array('id' => Yii::app()->getRequest()->getQuery('id')));
121  }
122 
123  protected function renderRightSideFormLayoutForEdit($form)
124  {
125  return null;
126  }
127 
128  protected function getNewModelTitleLabel()
129  {
130  return Zurmo::t('ContactsModule', 'Create ContactsModuleSingularLabel',
132  }
133 
134  protected function resolveActionElementInformationDuringRender(& $elementInformation)
135  {
136  parent::resolveActionElementInformationDuringRender($elementInformation);
137  if ($elementInformation['type'] == 'SaveButton')
138  {
139  $metadata = $this->externalViewMetadata;
140  $elementInformation['label'] = $metadata['global']['toolbar']['elements'][0]['label'];
141  }
142  }
143 
144  protected function resolveFormHtmlOptions()
145  {
146  $data = array('onSubmit' => 'js:jQQ.isolate(function($) { return $(this).attachLoadingOnSubmit("' . static::getFormId() . '") });');
147  if ($this->viewContainsFileUploadElement)
148  {
149  $data['enctype'] = 'multipart/form-data';
150  }
151  return $data;
152  }
153 
154  protected function renderAfterFormLayout($form)
155  {
156  $content = "<div id='reCaptcha'></div>";
157  $content .= ZurmoHtml::hiddenField('captchaHash');
158  $content .= ZurmoHtml::hiddenField('reCaptchaPublicKey',
159  ZurmoConfigurationUtil::getByModuleName('ZurmoModule', 'reCaptchaPublicKey'));
160  $content .= ZurmoHtml::hiddenField($this->hashIndexHiddenField, md5('ContactWebFormEntry'.time()));
161  $content .= ZurmoHtml::hiddenField(ZurmoHttpRequest::EXTERNAL_REQUEST_TOKEN, ZURMO_TOKEN);
162  $content .= ZurmoHtml::hiddenField(self::GOOGLE_WEB_TRACKING_ID_FIELD);
163  return $content;
164  }
165 
166  protected function renderTitleContent()
167  {
168  return null;
169  }
170  }
171 ?>
static getTranslationParamsForAllModules()
Definition: LabelUtil.php:75
static getByModuleName($moduleName, $key, $cache=true)
Generated on Sun Jan 17 2021 07:10:21
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.