Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
previewblock.php
1<?php
3
6
12{
13 const JS_EVENT_ON_VIEW_SELECT = 'onSelect';
14
15 protected $widget;
22 public function __construct($key)
23 {
24 parent::__construct($key);
25 $this->setLabel('');
26 $this->setDefaultValue('linearGraph');
27 }
28
36 public function printContent()
37 {
38 $params = array(
39 'AVAILABLE_VIEWS' => $this->getAvailableViewList(),
40 'PREPARED_WIDGET' => Widget::prepareWidgetContent($this->getWidget(), true),
41 );
42 $this->includeFieldComponent('previewblock', $params);
43 }
44
48 public function getWidget()
49 {
50 return $this->widget;
51 }
52
59 public function setWidget(\Bitrix\Report\VisualConstructor\Entity\Widget $widget)
60 {
61 $this->widget = $widget;
62 $this->setDefaultValue($widget->getViewKey());
63 }
64
68 private function getAvailableViews()
69 {
70 static $views;
71 if (!$views)
72 {
73 $viewProvider = new ViewProvider();
74 $results = $viewProvider->execute()->getResults();
75 foreach ($results as $result)
76 {
77 if ($result::USE_IN_VISUAL_CONSTRUCTOR)
78 {
79 $views[$result->getKey()] = $result;
80 }
81 }
82 }
83
84 return $views;
85 }
86
90 private function getAvailableViewList()
91 {
92 $result = array();
93 $views = $this->getAvailableViews();
94 foreach ($views as $view)
95 {
96 $result[] = array(
97 'key' => $view->getKey(),
98 'label' => $view->getLabel(),
99 'logoUrl' => $view->getLogoUri(),
100 );
101 }
102 return $result;
103 }
104
105
106}
includeFieldComponent($templateName, $params=array())
Definition base.php:530
setWidget(\Bitrix\Report\VisualConstructor\Entity\Widget $widget)
static prepareWidgetContent(WidgetEntity $widget, $withCalculatedData=false)
Definition widget.php:28