diff --git a/main/dashboard/dashboard_controller.php b/main/dashboard/dashboard_controller.php index fa2cc94a64..ce46d2280b 100755 --- a/main/dashboard/dashboard_controller.php +++ b/main/dashboard/dashboard_controller.php @@ -30,6 +30,7 @@ class DashboardController */ public function display() { + $tpl = new Template(get_lang('Dashboard')); $user_id = $this->user_id; $dashboard_blocks = DashboardManager::get_enabled_dashboard_blocks(); $user_block_data = DashboardManager::get_user_block_data($user_id); @@ -44,9 +45,9 @@ class DashboardController $path = $block['path']; $controller_class = $block['controller']; - $filename_controller = $path.'.class.php'; - $dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/'; - require_once $dashboard_plugin_path.$filename_controller; + $filename_controller = $path . '.class.php'; + $dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH) . 'dashboard/' . $path . '/'; + require_once $dashboard_plugin_path . $filename_controller; if (class_exists($controller_class)) { $obj = new $controller_class($user_id); @@ -69,77 +70,47 @@ class DashboardController api_block_anonymous_users(); $link_blocks_view = $link_list_view = null; if ($view == 'list') { - $link_blocks_view = ''. - Display::return_icon('blocks.png', get_lang('DashboardBlocks'), '', ICON_SIZE_MEDIUM).''; + $link_blocks_view = '' . + Display::return_icon('blocks.png', get_lang('DashboardBlocks'), '', ICON_SIZE_MEDIUM) . ''; } else { - $link_list_view = ''. - Display::return_icon('edit.png', get_lang('EditBlocks'), '', ICON_SIZE_MEDIUM).''; + $link_list_view = '' . + Display::return_icon('edit.png', get_lang('EditBlocks'), '', ICON_SIZE_MEDIUM) . ''; } $configuration_link = null; if (api_is_platform_admin()) { - $configuration_link = '' - .Display::return_icon('settings.png', get_lang('ConfigureDashboardPlugin'), '', ICON_SIZE_MEDIUM).''; + $configuration_link = '' + . Display::return_icon('settings.png', get_lang('ConfigureDashboardPlugin'), '', ICON_SIZE_MEDIUM) . ''; } - $content = '
'; - $content .= $link_blocks_view.$link_list_view.$configuration_link; - $content .= '
'; + $actions = Display::toolbarAction('toolbar', [0 => $link_blocks_view . $link_list_view . $configuration_link]); + $tpl->assign('actions', $actions); // block dashboard view + $columns = []; + $blockList = null; if (isset($view) && $view == 'blocks') { if (isset($blocks) && count($blocks) > 0) { - $columns = []; // group content html by number of column if (is_array($blocks)) { $tmp_columns = []; foreach ($blocks as $block) { $tmp_columns[] = $block['column']; if (in_array($block['column'], $tmp_columns)) { - $columns['column_'.$block['column']][] = $block['content_html']; - } - } - } - - $content .= '
'; - if (count($columns) > 0) { - $columns_name = array_keys($columns); - // blocks for column 1 - if (in_array('column_1', $columns_name)) { - $content .= '
'; - foreach ($columns['column_1'] as $data) { - $content .= $data; - } - $content .= '
'; - } else { - $content .= '
'; - $content .= ' '; - $content .= '
'; - } - // blocks for column 2 - if (in_array('column_2', $columns_name)) { - // blocks for column 1 - $content .= '
'; - foreach ($columns['column_2'] as $data) { - $content .= $data; + $columns['column_' . $block['column']][] = $block['content_html']; } - $content .= '
'; - } else { - $content .= '
'; - $content .= ' '; - $content .= '
'; } } - $content .= '
'; - } else { - $content .= '
'.get_lang('YouHaveNotEnabledBlocks').'
'; } } else { $user_id = api_get_user_id(); - $content .= DashboardManager::display_user_dashboard_list($user_id); + $blockList = DashboardManager::display_user_dashboard_list($user_id); + $tpl->assign('blocklist', $blockList); } - $tpl = new Template(get_lang('Dashboard')); + $tpl->assign('columns', $columns); + $template = $tpl->get_template('dashboard/index.tpl'); + $content = $tpl->fetch($template); $tpl->assign('content', $content); $tpl->display_one_col_template(); } diff --git a/main/template/default/dashboard/index.tpl b/main/template/default/dashboard/index.tpl new file mode 100644 index 0000000000..14d4864417 --- /dev/null +++ b/main/template/default/dashboard/index.tpl @@ -0,0 +1,21 @@ +{% if blocklist == '' %} +
+
+ {% if columns|length > 0 %} + {% for key, column in columns %} +
+ {% for item in column %} + {{ item }} + {% endfor %} +
+ {% endfor %} + {% else %} + + {% endif %} +
+
+{% else %} + {{ blocklist }} +{% endif %} \ No newline at end of file