@@ -30,6 +30,7 @@ public function __construct()
3030 */
3131 public function display ()
3232 {
33+ $ tpl = new Template (get_lang ('Dashboard ' ));
3334 $ user_id = $ this ->user_id ;
3435 $ dashboard_blocks = DashboardManager::get_enabled_dashboard_blocks ();
3536 $ user_block_data = DashboardManager::get_user_block_data ($ user_id );
@@ -44,9 +45,9 @@ public function display()
4445
4546 $ path = $ block ['path ' ];
4647 $ controller_class = $ block ['controller ' ];
47- $ filename_controller = $ path. '.class.php ' ;
48- $ dashboard_plugin_path = api_get_path (SYS_PLUGIN_PATH ). 'dashboard/ ' . $ path. '/ ' ;
49- require_once $ dashboard_plugin_path. $ filename_controller ;
48+ $ filename_controller = $ path . '.class.php ' ;
49+ $ dashboard_plugin_path = api_get_path (SYS_PLUGIN_PATH ) . 'dashboard/ ' . $ path . '/ ' ;
50+ require_once $ dashboard_plugin_path . $ filename_controller ;
5051 if (class_exists ($ controller_class )) {
5152 $ obj = new $ controller_class ($ user_id );
5253
@@ -69,77 +70,47 @@ public function display()
6970 api_block_anonymous_users ();
7071 $ link_blocks_view = $ link_list_view = null ;
7172 if ($ view == 'list ' ) {
72- $ link_blocks_view = '<a href=" ' . api_get_self (). '?view=blocks"> ' .
73- Display::return_icon ('blocks.png ' , get_lang ('DashboardBlocks ' ), '' , ICON_SIZE_MEDIUM ). '</a> ' ;
73+ $ link_blocks_view = '<a href=" ' . api_get_self () . '?view=blocks"> ' .
74+ Display::return_icon ('blocks.png ' , get_lang ('DashboardBlocks ' ), '' , ICON_SIZE_MEDIUM ) . '</a> ' ;
7475 } else {
75- $ link_list_view = '<a href=" ' . api_get_self (). '?view=list"> ' .
76- Display::return_icon ('edit.png ' , get_lang ('EditBlocks ' ), '' , ICON_SIZE_MEDIUM ). '</a> ' ;
76+ $ link_list_view = '<a href=" ' . api_get_self () . '?view=list"> ' .
77+ Display::return_icon ('edit.png ' , get_lang ('EditBlocks ' ), '' , ICON_SIZE_MEDIUM ) . '</a> ' ;
7778 }
7879
7980 $ configuration_link = null ;
8081 if (api_is_platform_admin ()) {
81- $ configuration_link = '<a href=" ' . api_get_path (WEB_CODE_PATH ). 'admin/settings.php?category=Plugins"> '
82- .Display::return_icon ('settings.png ' , get_lang ('ConfigureDashboardPlugin ' ), '' , ICON_SIZE_MEDIUM ). '</a> ' ;
82+ $ configuration_link = '<a href=" ' . api_get_path (WEB_CODE_PATH ) . 'admin/settings.php?category=Plugins"> '
83+ . Display::return_icon ('settings.png ' , get_lang ('ConfigureDashboardPlugin ' ), '' , ICON_SIZE_MEDIUM ) . '</a> ' ;
8384 }
8485
85- $ content = '<div class="actions"> ' ;
86- $ content .= $ link_blocks_view .$ link_list_view .$ configuration_link ;
87- $ content .= '</div> ' ;
86+ $ actions = Display::toolbarAction ('toolbar ' , [0 => $ link_blocks_view . $ link_list_view . $ configuration_link ]);
87+ $ tpl ->assign ('actions ' , $ actions );
8888
8989 // block dashboard view
90+ $ columns = [];
91+ $ blockList = null ;
9092 if (isset ($ view ) && $ view == 'blocks ' ) {
9193 if (isset ($ blocks ) && count ($ blocks ) > 0 ) {
92- $ columns = [];
9394 // group content html by number of column
9495 if (is_array ($ blocks )) {
9596 $ tmp_columns = [];
9697 foreach ($ blocks as $ block ) {
9798 $ tmp_columns [] = $ block ['column ' ];
9899 if (in_array ($ block ['column ' ], $ tmp_columns )) {
99- $ columns ['column_ ' .$ block ['column ' ]][] = $ block ['content_html ' ];
100- }
101- }
102- }
103-
104- $ content .= '<div id="columns" class="row"> ' ;
105- if (count ($ columns ) > 0 ) {
106- $ columns_name = array_keys ($ columns );
107- // blocks for column 1
108- if (in_array ('column_1 ' , $ columns_name )) {
109- $ content .= '<div id="column1" class="col-md-6"> ' ;
110- foreach ($ columns ['column_1 ' ] as $ data ) {
111- $ content .= $ data ;
112- }
113- $ content .= '</div> ' ;
114- } else {
115- $ content .= '<div id="column1" class="col-md-6"> ' ;
116- $ content .= ' ' ;
117- $ content .= '</div> ' ;
118- }
119- // blocks for column 2
120- if (in_array ('column_2 ' , $ columns_name )) {
121- // blocks for column 1
122- $ content .= '<div id="column2" class="col-md-6"> ' ;
123- foreach ($ columns ['column_2 ' ] as $ data ) {
124- $ content .= $ data ;
100+ $ columns ['column_ ' . $ block ['column ' ]][] = $ block ['content_html ' ];
125101 }
126- $ content .= '</div> ' ;
127- } else {
128- $ content .= '<div id="column2" class="col-md-6"> ' ;
129- $ content .= ' ' ;
130- $ content .= '</div> ' ;
131102 }
132103 }
133- $ content .= '</div> ' ;
134- } else {
135- $ content .= '<div style="margin-top:20px;"> ' .get_lang ('YouHaveNotEnabledBlocks ' ).'</div> ' ;
136104 }
137105 } else {
138106 $ user_id = api_get_user_id ();
139- $ content .= DashboardManager::display_user_dashboard_list ($ user_id );
107+ $ blockList = DashboardManager::display_user_dashboard_list ($ user_id );
108+ $ tpl ->assign ('blocklist ' , $ blockList );
140109 }
141110
142- $ tpl = new Template (get_lang ('Dashboard ' ));
111+ $ tpl ->assign ('columns ' , $ columns );
112+ $ template = $ tpl ->get_template ('dashboard/index.tpl ' );
113+ $ content = $ tpl ->fetch ($ template );
143114 $ tpl ->assign ('content ' , $ content );
144115 $ tpl ->display_one_col_template ();
145116 }
0 commit comments