tag that can be rendered synchronously * or as a piece of Javascript/JQuery/Ajax that will get its content from another page (ajax.render.php). */ class DisplayBlock { /** * @var string * @since 3.1.0 */ public const ENUM_STYLE_COUNT = 'count'; /** * @var string * @since 3.1.0 */ public const ENUM_STYLE_JOIN = 'join'; /** * @var string For regular list (objects or static data) * @since 3.1.0 */ public const ENUM_STYLE_LIST = 'list'; /** * @var string For search results * @since 3.1.0 */ public const ENUM_STYLE_LIST_SEARCH = 'list_search'; /** * @var string For objects list in other objects (direct / indirect linksets) * @since 3.1.0 */ public const ENUM_STYLE_LIST_IN_OBJECT = 'listInObject'; /** * @var string * @since 3.1.0 */ public const ENUM_STYLE_ACTIONS = 'actions'; /** * @var string * @since 3.1.0 */ public const ENUM_STYLE_SUMMARY = 'summary'; /** * @var string * @since 3.1.0 */ public const ENUM_STYLE_CSV = 'csv'; /** * @var string * @since 3.1.0 */ public const ENUM_STYLE_SEARCH = 'search'; /** * @var string * @since 3.1.0 */ public const ENUM_STYLE_CHART = 'chart'; /** * @var string * @since 3.1.0 */ public const ENUM_STYLE_CHART_AJAX = 'chart_ajax'; const TAG_BLOCK = 'itopblock'; /** @var \DBSearch */ protected $m_oFilter; protected $m_aConditions; // Conditions added to the filter -> avoid duplicate conditions protected $m_sStyle; protected $m_bAsynchronous; protected $m_aParams; /** @var \DBObjectSet|null */ protected $m_oSet; protected $m_bShowObsoleteData = null; /** * @param \DBSearch $oFilter list of cmdbObjects to be displayed into the block * @param string $sStyle one of : * * @param bool $bAsynchronous * @param array $aParams * @param \DBObjectSet $oSet * * @throws \ApplicationException */ public function __construct(DBSearch $oFilter, $sStyle = self::ENUM_STYLE_LIST, $bAsynchronous = false, $aParams = array(), $oSet = null) { $this->m_oFilter = $oFilter->DeepClone(); $this->m_aConditions = array(); $this->m_sStyle = $sStyle; $this->m_bAsynchronous = $bAsynchronous; $this->m_aParams = $aParams; $this->m_oSet = $oSet; if (array_key_exists('show_obsolete_data', $aParams)) { $this->m_bShowObsoleteData = $aParams['show_obsolete_data']; } if ($this->m_bShowObsoleteData === null) { // User defined $this->m_bShowObsoleteData = utils::ShowObsoleteData(); } } /** * @param string $sStyle * * @return string[] */ protected function GetAllowedParams(string $sStyle): array { $aAllowedParams = [ static::ENUM_STYLE_ACTIONS => [ 'context_filter', /** int if != 0 filter with user context */ 'display_limit', /** for dashlet*/ ], static::ENUM_STYLE_CHART => [ 'chart_type', /** string 'pie' or 'bars' */ 'group_by', /** string group by att code */ 'group_by_expr', /** string group by expression */ 'group_by_label', /** string aggregation column name */ 'aggregation_function', /** string aggregation function ('count', 'sum', 'avg', 'min', 'max', ...) */ 'aggregation_attribute', /** string att code used for aggregation */ 'limit', /** int limit the chart results */ 'order_by', /** string either 'attribute' group_by attcode or 'function' aggregation_function value */ 'order_direction', /** string order direction 'asc' or 'desc' */ 'chart_title', /** string title */ 'display_limit', ], static::ENUM_STYLE_CHART_AJAX => [ 'chart_type', /** string 'pie' or 'bars' */ 'group_by', /** string group by att code */ 'group_by_expr', /** string group by expression */ 'group_by_label', /** string aggregation column name */ 'aggregation_function', /** string aggregation function ('count', 'sum', 'avg', 'min', 'max', ...) */ 'aggregation_attribute', /** string att code used for aggregation */ 'limit', /** int limit the chart results */ 'order_by', /** string either 'attribute' group_by attcode or 'function' aggregation_function value */ 'order_direction', /** string order direction 'asc' or 'desc' */ ], static::ENUM_STYLE_COUNT => [ 'group_by', /** string group by att code */ 'group_by_expr', /** string group by expression */ 'group_by_label', /** string aggregation column name */ 'aggregation_function', /** string aggregation function ('count', 'sum', 'avg', 'min', 'max', ...) */ 'aggregation_attribute', /** string att code used for aggregation */ 'limit', /** int limit the chart results */ 'order_by', /** string either 'attribute' group_by attcode or 'function' aggregation_function value */ 'order_direction', /** string order direction 'asc' or 'desc' */ 'display_limit', ], static::ENUM_STYLE_CSV => [], static::ENUM_STYLE_JOIN => array_merge([ 'display_aliases', /** string comma separated list of class aliases to display */ 'group_by', /** string group by att code */ ], DataTableUIBlockFactory::GetAllowedParams()), 'links' => DataTableUIBlockFactory::GetAllowedParams(), static::ENUM_STYLE_LIST => array_merge([ 'update_history', /** bool add breadcrumb entry */ 'default', /** array of default attribute values */ 'menu_actions_target', /** string html link target */ 'toolkit_menu', /** bool add toolkit menu */ 'selectionMode', /**positive or negative*/ 'max_height', /** string Max. height of the list, if not specified will occupy all the available height no matter the pagination */ 'localize_values', /** param for export.php */ 'refresh_action', /**to add refresh button in datatable*/ ], DataTableUIBlockFactory::GetAllowedParams()), static::ENUM_STYLE_LIST_IN_OBJECT => array_merge([ 'update_history', /** bool add breadcrumb entry */ 'default', /** array of default attribute values */ 'menu_actions_target', /** string html link target */ 'toolkit_menu', /** bool add toolkit menu */ 'selectionMode', /**positive or negative*/ 'max_height', /** string Max. height of the list, if not specified will occupy all the available height no matter the pagination */ 'localize_values', /** param for export.php */ 'refresh_action', /**to add refresh button in datatable*/ 'object_count', /** int number of objects in list */ ], DataTableUIBlockFactory::GetAllowedParams()), static::ENUM_STYLE_LIST_SEARCH => array_merge([ 'update_history', /** bool add breadcrumb entry */ 'result_list_outer_selector', /** string js selector of the search result display */ 'table_inner_id', /** string html id of the results table */ 'json', /** string */ 'hidden_criteria', /** string search criteria not visible */ 'baseClass', /** string base class */ 'action', /** string */ 'open', /** bool open by default the search */ 'submit_on_load', /** bool submit the search on loading page */ 'class', /** class name */ 'search_header_force_dropdown', /** Html for