Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
MetadataView.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 MetadataView extends View
42  {
43  protected $editableDesignerMetadata = false;
44 
45  protected $disableFloatOnToolbar = false;
46 
47  protected $modelId;
48 
53  public static function getMetadata()
54  {
55  $className = get_called_class();
56  return $className::getDefaultMetadata();
57  }
58 
62  public static function getDefaultMetadata()
63  {
64  return array();
65  }
66 
71  protected function resolveAndWrapDockableViewToolbarContent($content)
72  {
73  assert('is_string($content)');
74  if ($this->disableFloatOnToolbar)
75  {
76  $disableFloatContent = ' disable-float-bar';
77  }
78  else
79  {
80  $disableFloatContent = null;
81  }
82  $content = ZurmoHtml::tag('div', array('class' => 'form-toolbar'), $content);
83  $content = ZurmoHtml::tag('div', array('class' => 'view-toolbar-container clearfix dock' .
84  $disableFloatContent), $content);
85  $content = ZurmoHtml::tag('div', array('class' => 'float-bar'), $content);
86  return $content;
87  }
88 
93  protected function renderViewToolBar($renderInForm = true)
94  {
95  if ( $renderInForm == true )
96  {
97  $actionContent = $this->renderActionElementBar($renderInForm);
98  if ($actionContent != null)
99  {
100  $content = '<div class="view-toolbar-container clearfix"><div class="portlet-toolbar">';
101  $content .= $actionContent;
102  $content .= '</div></div>';
103  return $content;
104  }
105  }
106  return null;
107  }
108 
116  protected function renderActionElementBar($renderedInForm)
117  {
118  return $this->renderElementBar($renderedInForm, 'toolbar');
119  }
120 
128  protected function renderSecondActionElementBar($renderedInForm)
129  {
130  return $this->renderElementBar($renderedInForm, 'secondToolbar');
131  }
132 
139  protected function renderElementBar($renderedInForm, $barType)
140  {
141  assert('$barType == "toolbar" || $barType == "secondToolbar"');
142  $metadata = $this::getMetadata();
143  $content = null;
144  $first = true;
145  $dropDownId = null;
146  $dropDownItems = array();
147  $dropDownItemHtmlOptions = array('prompt' => ''); // we need this so we have a default one to select at the end of operation.
148  if (isset($metadata['global'][$barType]) && is_array($metadata['global'][$barType]['elements']))
149  {
150  foreach ($metadata['global'][$barType]['elements'] as $elementInformation)
151  {
152  $renderedContent = null;
153  $this->resolveActionElementInformationDuringRender($elementInformation);
154  Yii::app()->custom->resolveActionElementInformationDuringRender($this, $elementInformation);
155  array_walk($elementInformation, array($this, 'resolveEvaluateSubString'));
156  $params = array_slice($elementInformation, 1);
157  $elementClassName = $elementInformation['type'] . 'ActionElement';
158  $element = new $elementClassName($this->controllerId, $this->moduleId, $this->modelId, $params);
159  if (!$this->shouldRenderToolBarElement($element, $elementInformation))
160  {
161  continue;
162  }
163  if (!$renderedInForm && $element->isFormRequiredToUse())
164  {
165  throw new NotSupportedException();
166  }
167  $continueRendering = $this->resolveMassActionLinkActionElementDuringRender($elementClassName,
168  $element,
169  $dropDownItems,
170  $dropDownItemHtmlOptions
171  );
172  if ($continueRendering)
173  {
174  $renderedContent = $element->render();
175  }
176  else
177  {
178  if (! $dropDownId)
179  {
180  $dropDownId = $elementClassName::getDropdownId();
181  }
182  }
183  if (!$first && !empty($renderedContent))
184  {
185  // $content .= '&#160;|&#160;';
186  }
187  $first = false;
188  $content .= $renderedContent;
189  }
190  }
191  return $content;
192  }
193 
202  protected function resolveMassActionLinkActionElementDuringRender($elementClassName, & $element, & $dropDownItems, & $dropDownItemHtmlOptions)
203  {
204  $class = new ReflectionClass($elementClassName);
205  if ($class->implementsInterface('SupportsRenderingDropDownInterface') &&
206  $elementClassName::shouldRenderAsDropDownWhenRequired() &&
207  Yii::app()->userInterface->isMobile())
208  {
209  if (empty($dropDownItems))
210  {
211  $element->registerDropDownScripts();
212  }
213  $items = $element->getOptions();
214  if (array_key_exists('label', $items))
215  {
216  $items = array($items);
217  }
218  foreach ($items as $item)
219  {
220  if ($element::useItemUrlAsElementValue())
221  {
222  $value = $item['url'];
223  }
224  else
225  {
226  $value = $element->getElementValue();
227  }
228 
229  if (!$value)
230  {
231  $value = $element->getActionNameForCurrentElement() . '_' . $item['label'];
232  }
233  $optGroup = $element->getOptGroup();
234  if ($optGroup)
235  {
236  $dropDownItems[$optGroup][$value] = $item['label'];
237  }
238  else
239  {
240  $dropDownItems[$value] = $item['label'];
241  }
242  $dropDownItemHtmlOptions['options'][$value] = array();
243  if (isset($item['itemOptions']))
244  {
245  $dropDownItemHtmlOptions['options'][$value] = $item['itemOptions'];
246  }
247  }
248  return false;
249  }
250  return true;
251  }
252 
257  protected function resolveActionElementInformationDuringRender(& $elementInformation)
258  {
259  }
260 
267  public function resolveEvaluateSubString(& $element, $key)
268  {
269  if (is_array($element))
270  {
271  array_walk($element, array($this, 'resolveEvaluateSubString'));
272  return;
273  }
274  if (strpos($element, 'eval:') !== 0)
275  {
276  return;
277  }
278  $stringToEvaluate = substr($element, 5);
279  eval("\$element = $stringToEvaluate;");
280  }
281 
288  public static function getDesignerRulesType()
289  {
290  return null;
291  }
292 
299  public static function getModelForMetadataClassName()
300  {
301  return null;
302  }
303 
304  protected function shouldRenderToolBarElement($element, $elementInformation)
305  {
306  assert('$element instanceof ActionElement');
307  assert('is_array($elementInformation)');
308  return true;
309  }
310 
311  protected function renderWrapperAndActionElementMenu($title = null, $toolbar = 'toolbar')
312  {
313  assert('is_string($title) || $title === null');
314  assert('is_string($toolbar)');
315  $content = null;
316  $actionElementContent = $this->renderActionElementMenu($title, $toolbar);
317  if ($actionElementContent != null)
318  {
319  $content .= '<div class="view-toolbar-container toolbar-mbmenu clearfix"><div class="view-toolbar">';
320  $content .= $actionElementContent;
321  $content .= '</div></div>';
322  }
323  return $content;
324  }
325 
334  protected function renderActionElementMenu($title = null, $toolbar = 'toolbar')
335  {
336  assert('is_string($toolbar)');
337  if ($title == null)
338  {
339  $title = Zurmo::t('Core', 'Options');
340  }
341  $metadata = $this::getMetadata();
342  $menuItems = array('label' => $title, 'items' => array());
343  if (isset($metadata['global'][$toolbar]) && is_array($metadata['global'][$toolbar]['elements']))
344  {
345  foreach ($metadata['global'][$toolbar]['elements'] as $elementInformation)
346  {
347  $elementClassName = $elementInformation['type'] . 'ActionElement';
348  $params = array_slice($elementInformation, 1);
349  array_walk($params, array($this, 'resolveEvaluateSubString'));
350  $element = new $elementClassName($this->controllerId, $this->moduleId, $this->modelId, $params);
351  if (!$this->shouldRenderToolBarElement($element, $elementInformation))
352  {
353  continue;
354  }
355  if ($element->isFormRequiredToUse())
356  {
357  throw new NotSupportedException();
358  }
359  $menuItems['items'][] = $element->renderMenuItem();
360  }
361  }
362  if (count($menuItems['items']) > 0)
363  {
364  $cClipWidget = new CClipWidget();
365  $cClipWidget->beginClip("OptionMenu");
366  $cClipWidget->widget('application.core.widgets.MbMenu', array(
367  'htmlOptions' => array('class' => static::getOptionsMenuCssClass()),
368  'items' => array($menuItems),
369  ));
370  $cClipWidget->endClip();
371  return $cClipWidget->getController()->clips['OptionMenu'];
372  }
373  }
374 
379  protected static function getOptionsMenuCssClass()
380  {
381  return 'options-menu';
382  }
383  }
384 ?>
renderSecondActionElementBar($renderedInForm)
static getMetadata()
static getDefaultMetadata()
static getDesignerRulesType()
resolveActionElementInformationDuringRender(&$elementInformation)
resolveMassActionLinkActionElementDuringRender($elementClassName, &$element, &$dropDownItems, &$dropDownItemHtmlOptions)
renderElementBar($renderedInForm, $barType)
static getModelForMetadataClassName()
renderActionElementMenu($title=null, $toolbar= 'toolbar')
Definition: View.php:43
resolveAndWrapDockableViewToolbarContent($content)
renderViewToolBar($renderInForm=true)
static getOptionsMenuCssClass()
resolveEvaluateSubString(&$element, $key)
renderActionElementBar($renderedInForm)
Generated on Tue Jul 7 2020 07:10:30
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.