Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
BuilderButtonElement.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  {
42  protected $inlineStylesToKeepOnATag = array('color', 'font-size', 'font-family', 'font-weight');
43 
44  public static function isUIAccessible()
45  {
46  return true;
47  }
48 
49  protected static function resolveLabel()
50  {
51  return Zurmo::t('EmailTemplatesModule', 'Button');
52  }
53 
54  protected function resolveDefaultProperties()
55  {
56  $properties = array(
57  'backend' => array(
58  'sizeClass' => 'button',
59  'text' => Zurmo::t('Core', 'Click Here'),
60  'width' => '100%',
61  ),
62  'frontend' => array(
63  'href' => Yii::app()->createAbsoluteUrl('/'),
64  'target' => '_blank',
65  'inlineStyles' => array(
66  'color' => '#ffffff',
67  ),
68  )
69  );
70  return $properties;
71  }
72 
73  protected function renderControlContentNonEditable()
74  {
75  $target = null;
76  $href = null;
77  extract($this->properties['frontend']);
78  $label = $this->properties['backend']['text'];
79  $frontendOptions = $this->resolveFrontendPropertiesNonEditable();
80  $htmlOptions = $this->resolveDefaultHtmlOptionsForLink();
81  $options = CMap::mergeArray($htmlOptions, $frontendOptions);
82  $content = ZurmoHtml::link($label, $href, $options);
83  return $content;
84  }
85 
86  protected function resolveFrontendPropertiesNonEditable()
87  {
88  $properties = array();
89  $frontendProperties = ArrayUtil::getArrayValue($this->properties, 'frontend');
90  if ($frontendProperties)
91  {
92  $properties = $frontendProperties;
93  }
94  $this->resolveInlineStylePropertiesForFrontendNonEditable($properties);
95  return $properties;
96  }
97 
98  protected function resolveInlineStylePropertiesForFrontendNonEditable(array & $mergedProperties)
99  {
100  $mergedProperties['style'] = '';
101  $inlineStyles = $this->resolveInlineStylesForNonEditable($mergedProperties);
102  if ($inlineStyles)
103  {
104  $usableInlineStyles = array();
105  foreach ($this->inlineStylesToKeepOnATag as $style)
106  {
107  if (isset($inlineStyles[$style]))
108  {
109  $usableInlineStyles[$style] = $inlineStyles[$style];
110  unset($mergedProperties['inlineStyles'][$style]);
111  }
112  }
113  unset($mergedProperties['inlineStyles']);
114  if ($usableInlineStyles)
115  {
116  $mergedProperties['style'] = $this->stringifyProperties($usableInlineStyles, null, null, ':', ';');
117  }
118  }
119  }
120 
121  protected function resolveFrontendPropertiesForWrappingTdNonEditable()
122  {
123  $properties = array();
124  $frontendProperties = ArrayUtil::getArrayValue($this->properties, 'frontend');
125  if ($frontendProperties)
126  {
127  $properties = $frontendProperties;
128  }
129  foreach ($this->inlineStylesToKeepOnATag as $style)
130  {
131  if (isset($properties['inlineStyles']) && isset($properties['inlineStyles'][$style]) && $style != 'color')
132  {
133  unset($properties['inlineStyles'][$style]);
134  }
135  }
136  if (isset($properties['target']))
137  {
138  unset($properties['target']);
139  }
140  if (isset($properties['href']))
141  {
142  unset($properties['href']);
143  }
144  $this->resolveInlineStylePropertiesNonEditable($properties);
145  if (isset($properties['inlineStyles']))
146  {
147  unset($properties['inlineStyles']);
148  }
149  return $properties;
150  }
151 
156  protected function resolveInlineStylesForNonEditable(array & $mergedProperties)
157  {
158  return ArrayUtil::getArrayValue($mergedProperties, 'inlineStyles');
159  }
160 
161  protected function renderSettingsTab(ZurmoActiveForm $form)
162  {
163  $propertiesForm = BuilderButtonElementPropertiesEditableElementsUtil::render($this->model, $form);
164  $propertiesForm .= BuilderElementBackgroundPropertiesEditableElementsUtil::render($this->model, $form);
165  $propertiesForm .= BuilderElementTextPropertiesEditableElementsUtil::render($this->model, $form, array('line-height', 'text-align'));
166  $propertiesForm .= BuilderElementBorderPropertiesEditableElementsUtil::render($this->model, $form);
167  return $propertiesForm;
168  }
169 
170  protected function renderContentTab(ZurmoActiveForm $form)
171  {
172  return null;
173  }
174 
175  protected function resolveDefaultHtmlOptionsForLink()
176  {
177  return array();
178  }
179 
186  protected function resolveWrapperTableNonEditableByContentAndHtmlOptions($content, array $customDataAttributes)
187  {
188  $backendHtmlOptions = $this->resolveBackendPropertiesForWrapperTableNonEditable();
189  $defaultHtmlOptions = $this->resolveNonEditableWrapperOptions($customDataAttributes);
190  $options = CMap::mergeArray($backendHtmlOptions, $defaultHtmlOptions);
191  $htmlOptions = CMap::mergeArray($options, $customDataAttributes);
192  $content = ZurmoHtml::tag('table', $htmlOptions, $content);
193  return $content;
194  }
195 
201  {
202  $properties = array();
203  $backendProperties = ArrayUtil::getArrayValue($this->properties, 'backend');
204  if ($backendProperties)
205  {
206  $properties = array();
207  $width = ArrayUtil::getNestedValue($this->properties, "backend['width']");
208  if ($width)
209  {
210  $properties['inlineStyles']['width'] = $width;
211  }
212  }
213  $this->resolveInlineStylePropertiesNonEditable($properties);
214  return $properties;
215  }
216 
217  protected function resolveNonEditableWrapperHtmlOptions()
218  {
219  $htmlOptions = parent::resolveNonEditableWrapperHtmlOptions();
220  $htmlOptions['class'] .= ' ' . $this->properties['backend']['sizeClass'];
221  $htmlOptions['align'] = ArrayUtil::getArrayValue($this->properties['backend'], 'align');
222  $width = ArrayUtil::getNestedValue($this->properties, "backend['width']");
223  if ($width)
224  {
225  $htmlOptions['width'] = $width;
226  }
227  return $htmlOptions;
228  }
229 
235  {
236  $frontendOptions = $this->resolveFrontendPropertiesNonEditable();
237  if (isset($frontendOptions['href']))
238  {
239  unset($frontendOptions['href']);
240  }
241  if (isset($frontendOptions['target']))
242  {
243  unset($frontendOptions['target']);
244  }
245  $htmlOptions = $this->resolveNonEditableContentWrappingTdHtmlOptions();
246  $options = CMap::mergeArray($htmlOptions, $frontendOptions);
247  return $options;
248  }
249 
250  protected function resolveWrapperTdNonEditableByContent($content)
251  {
252  $options = $this->resolveNonEditableContentWrappingTdOptions();
253  $options = CMap::mergeArray($options, array('class' => 'button-td'));
254  $content = ZurmoHtml::tag('td', $options, $content);
255  return $content;
256  }
257  }
258 ?>
resolveInlineStylePropertiesNonEditable(array &$mergedProperties)
resolveInlineStylesForNonEditable(array &$mergedProperties)
resolveWrapperTableNonEditableByContentAndHtmlOptions($content, array $customDataAttributes)
static getArrayValue($array, $element, $defaultValue=null)
Definition: ArrayUtil.php:45
static getNestedValue(array $array, $key)
Definition: ArrayUtil.php:275
stringifyProperties(array $properties, $keyPrefix=null, $keySuffix=null, $valuePrefix=null, $valueSuffix=null)
Generated on Sun Oct 25 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.