43 protected $editableDesignerMetadata =
false;
45 protected $disableFloatOnToolbar =
false;
55 $className = get_called_class();
56 return $className::getDefaultMetadata();
73 assert(
'is_string($content)');
74 if ($this->disableFloatOnToolbar)
76 $disableFloatContent =
' disable-float-bar';
80 $disableFloatContent = null;
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);
95 if ( $renderInForm ==
true )
98 if ($actionContent != null)
100 $content =
'<div class="view-toolbar-container clearfix"><div class="portlet-toolbar">';
101 $content .= $actionContent;
102 $content .=
'</div></div>';
141 assert(
'$barType == "toolbar" || $barType == "secondToolbar"');
142 $metadata = $this::getMetadata();
146 $dropDownItems = array();
147 $dropDownItemHtmlOptions = array(
'prompt' =>
'');
148 if (isset($metadata[
'global'][$barType]) && is_array($metadata[
'global'][$barType][
'elements']))
150 foreach ($metadata[
'global'][$barType][
'elements'] as $elementInformation)
152 $renderedContent = null;
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))
163 if (!$renderedInForm && $element->isFormRequiredToUse())
170 $dropDownItemHtmlOptions
172 if ($continueRendering)
174 $renderedContent = $element->render();
180 $dropDownId = $elementClassName::getDropdownId();
183 if (!$first && !empty($renderedContent))
188 $content .= $renderedContent;
204 $class =
new ReflectionClass($elementClassName);
205 if ($class->implementsInterface(
'SupportsRenderingDropDownInterface') &&
206 $elementClassName::shouldRenderAsDropDownWhenRequired() &&
207 Yii::app()->userInterface->isMobile())
209 if (empty($dropDownItems))
211 $element->registerDropDownScripts();
213 $items = $element->getOptions();
214 if (array_key_exists(
'label', $items))
216 $items = array($items);
218 foreach ($items as $item)
220 if ($element::useItemUrlAsElementValue())
222 $value = $item[
'url'];
226 $value = $element->getElementValue();
231 $value = $element->getActionNameForCurrentElement() .
'_' . $item[
'label'];
233 $optGroup = $element->getOptGroup();
236 $dropDownItems[$optGroup][$value] = $item[
'label'];
240 $dropDownItems[$value] = $item[
'label'];
242 $dropDownItemHtmlOptions[
'options'][$value] = array();
243 if (isset($item[
'itemOptions']))
245 $dropDownItemHtmlOptions[
'options'][$value] = $item[
'itemOptions'];
269 if (is_array($element))
271 array_walk($element, array($this,
'resolveEvaluateSubString'));
274 if (strpos($element,
'eval:') !== 0)
278 $stringToEvaluate = substr($element, 5);
279 eval(
"\$element = $stringToEvaluate;");
304 protected function shouldRenderToolBarElement($element, $elementInformation)
306 assert(
'$element instanceof ActionElement');
307 assert(
'is_array($elementInformation)');
311 protected function renderWrapperAndActionElementMenu($title = null, $toolbar =
'toolbar')
313 assert(
'is_string($title) || $title === null');
314 assert(
'is_string($toolbar)');
317 if ($actionElementContent != null)
319 $content .=
'<div class="view-toolbar-container toolbar-mbmenu clearfix"><div class="view-toolbar">';
320 $content .= $actionElementContent;
321 $content .=
'</div></div>';
336 assert(
'is_string($toolbar)');
339 $title = Zurmo::t(
'Core',
'Options');
341 $metadata = $this::getMetadata();
342 $menuItems = array(
'label' => $title,
'items' => array());
343 if (isset($metadata[
'global'][$toolbar]) && is_array($metadata[
'global'][$toolbar][
'elements']))
345 foreach ($metadata[
'global'][$toolbar][
'elements'] as $elementInformation)
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))
355 if ($element->isFormRequiredToUse())
359 $menuItems[
'items'][] = $element->renderMenuItem();
362 if (count($menuItems[
'items']) > 0)
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),
370 $cClipWidget->endClip();
371 return $cClipWidget->getController()->clips[
'OptionMenu'];
381 return 'options-menu';