瀏覽代碼

improving and create tpl for forum view - refs BT#12926

Alex Aragon 7 年之前
父節點
當前提交
686274be02
共有 3 個文件被更改,包括 227 次插入322 次删除
  1. 6 5
      app/Resources/public/css/base.css
  2. 140 317
      main/forum/index.php
  3. 81 0
      main/template/default/forum/list.tpl

+ 6 - 5
app/Resources/public/css/base.css

@@ -2899,21 +2899,22 @@ tr.forum_category_header a {
     border-bottom: 1px solid #aaa;
     border-top: 1px solid #aaa;
 }
+.forum-date{
+    font-size: 12px;
+}
 /* **** POST **** */
 .quote {
     background-color: #a0e5fc;
 }
-
+a.forum-goto{
+    font-size: 12px;
+}
 .structure {
     /*border-bottom: 1px solid #666666;*/
     font-weight: bold;
     background-color: #F7F7F7;
     height: 20px;
 }
-a.forum_group_link {
-    font-weight: lighter;
-    display:inline;
-}
 .forum_description {
     color: #000;
     font-weight: normal;

+ 140 - 317
main/forum/index.php

@@ -106,11 +106,9 @@ if ($actions === 'add') {
         'name' => get_lang('ForumCategories'),
     );
 }
-
 Display::display_header('');
-
 // Tool introduction
-Display::display_introduction_section(TOOL_FORUM);
+$introduction = Display::return_introduction_section(TOOL_FORUM);
 
 $form_count = 0;
 
@@ -129,13 +127,14 @@ if ($actions == 'notify' && isset($_GET['content']) && isset($_GET['id'])) {
         api_not_allowed();
     }
     $return_message = set_notification($_GET['content'], $_GET['id']);
-    echo Display::return_message($return_message, 'confirm', false);
+    Display::addFlash(Display::return_message($return_message, 'confirm', false));
 }
 
 get_whats_new();
 
 $whatsnew_post_info = Session::read('whatsnew_post_info');
 
+$tpl = new Template($nameTools, false, false, false, false, true, false);
 /* TRACKING */
 
 Event::event_access_tool(TOOL_FORUM);
@@ -153,7 +152,7 @@ $forumCategories = get_forum_categories();
 // display group forum in general forum tool depending to configuration option
 $setting = api_get_setting('display_groups_forum_in_general_tool');
 
-$forum_list = get_forums('', '', $setting === 'true');
+$allCourseForums = get_forums('', '', $setting === 'true');
 $user_id = api_get_user_id();
 
 /* RETRIEVING ALL GROUPS AND THOSE OF THE USER */
@@ -174,46 +173,34 @@ if (!api_is_anonymous()) {
 }
 
 /* ACTION LINKS */
-echo '<div class="actions">';
+$actionLeft = null;
 //if is called from learning path
 if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])) {
-    echo "<a href=\"../lp/lp_controller.php?"
-        . api_get_cidreq()
-        . "&gradebook=&action=add_item&type=step&lp_id=$lp_id#resource_tab-5\">"
-        . Display::return_icon(
-            'back.png',
-            get_lang("BackTo").' '.get_lang("LearningPaths"),
-            '',
-            ICON_SIZE_MEDIUM
-        )
-        . "</a>";
+    $url = "../lp/lp_controller.php?".api_get_cidreq().
+        "&gradebook=&action=add_item&type=step&lp_id='.$lp_id.'#resource_tab-5";
+    $actionLeft .= Display::url(Display::return_icon(
+                'back.png', get_lang("BackTo").' '.get_lang("LearningPaths"), null, ICON_SIZE_MEDIUM
+            ), $url);
 }
-if (!empty($forum_list)) {
-    echo search_link();
+if (!empty($allCourseForums)) {
+    $actionLeft .= search_link();
 }
 
 if (api_is_allowed_to_edit(false, true)) {
-    echo '<a href="'
-        . api_get_self().'?'.api_get_cidreq()
-        . '&action=add&content=forumcategory&lp_id='.$lp_id.'"> '.
-        Display::return_icon(
-            'new_folder.png', get_lang('AddForumCategory'), '', ICON_SIZE_MEDIUM
-        )
-        . '</a>';
+    $actionLeft .= Display::url(
+            Display::return_icon(
+                'new_folder.png', get_lang('AddForumCategory'), null, ICON_SIZE_MEDIUM
+            ), api_get_self().'?'.api_get_cidreq().'&action=add&content=forumcategory&lp_id='.$lp_id);
 
     if (is_array($forumCategories) && !empty($forumCategories)) {
-        echo '<a href="'.api_get_self().'?'.api_get_cidreq(
-            ).'&action=add&content=forum&lp_id='.$lp_id.'"> '.
-            Display::return_icon(
-                'new_forum.png',
-                get_lang('AddForum'),
-                '',
-                ICON_SIZE_MEDIUM
-            ).'</a>';
+        $actionLeft .= Display::url(
+                Display::return_icon(
+                    'new_forum.png', get_lang('AddForum'), '', ICON_SIZE_MEDIUM
+                ), api_get_self().'?'.api_get_cidreq().'&action=add&content=forum&lp_id='.$lp_id);
     }
 }
 
-echo '</div>';
+$actions = Display::toolbarAction('toolbar-forum', array(0 => $actionLeft));
 
 // Fixes error if there forums with no category.
 $forumsInNoCategory = get_forums_in_category(0);
@@ -233,41 +220,37 @@ if (!empty($forumsInNoCategory)) {
 
 /* Display Forum Categories and the Forums in it */
 // Step 3: We display the forum_categories first.
+$listForumCategory = array();
+$dataForum = array();
+
 if (is_array($forumCategories)) {
     foreach ($forumCategories as $forumCategory) {
-        // The forums in this category.
-        $forumsInCategory = get_forums_in_category($forumCategory['cat_id']);
+        $dataForum['id'] = $forumCategory['cat_id'];
+        if (empty($forumCategory['cat_title'])) {
+            $dataForum['title'] = get_lang('WithoutCategory');
+        } else {
+            $dataForum['title'] = $forumCategory['cat_title'];
+        }
+        $dataForum['session_start'] = api_get_session_image(
+            $forumCategory['session_id'], $_user['status']
+        );
 
         // Validation when belongs to a session.
-        $session_img = api_get_session_image(
-            $forumCategory['session_id'],
-            $_user['status']
+        $sessionImg = api_get_session_image(
+            $forumCategory['session_id'], $_user['status']
         );
+        $dataForum['icon_session'] = $sessionImg;
+        $dataForum['description'] = $forumCategory['cat_comment'];
 
         if (empty($sessionId) && !empty($forumCategory['session_name'])) {
-            $session_displayed = ' ('.Security::remove_XSS($forumCategory['session_name']).')';
+            $forumCategory['session_display'] = ' ('.Security::remove_XSS($forumCategory['session_name']).')';
         } else {
-            $session_displayed = '';
+            $forumCategory['session_display'] = null;
         }
 
-        if (empty($forumCategory['cat_title'])) {
-            $forumCategory['cat_title'] = get_lang('WithoutCategory');
-        }
-
-        $html = '';
-        $iconsEdit = '';
+        $tools = null;
         $idCategory = $forumCategory['cat_id'];
-        $urlCategory = 'viewforumcategory.php?'.api_get_cidreq().'&forumcategory='.intval($idCategory);
-        $titleCategory = Display::tag(
-            'a',
-            $forumCategory['cat_title'],
-            array(
-                'href' => $urlCategory,
-                'class' => empty($forumCategory['visibility']) ? 'text-muted' : null
-            )
-        );
-
-        $descriptionCategory = $forumCategory['cat_comment'];
+        $dataForum['url'] = 'viewforumcategory.php?'.api_get_cidreq().'&forumcategory='.intval($idCategory);
 
         if (!empty($idCategory)) {
             if (
@@ -275,79 +258,45 @@ if (is_array($forumCategories)) {
                 !($forumCategory['session_id'] == 0 &&
                 intval($sessionId) != 0)
             ) {
-                $iconsEdit .= '<a href="'.api_get_self().'?'.api_get_cidreq()
-                    . '&action=edit&content=forumcategory&id='.intval($idCategory)
-                    . '">'.Display::return_icon(
-                        'edit.png',
-                        get_lang('Edit'),
-                        array(),
-                        ICON_SIZE_SMALL
+                $tools .= '<a href="'.api_get_self().'?'.api_get_cidreq()
+                    .'&action=edit&content=forumcategory&id='.intval($idCategory)
+                    .'">'.Display::return_icon(
+                        'edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL
                     )
-                    . '</a>';
-
-                $iconsEdit .= '<a href="'.api_get_self().'?'.api_get_cidreq()
-                    . '&action=delete&content=forumcategory&id='.intval($idCategory)
-                    . "\" onclick=\"javascript:if(!confirm('"
-                    . addslashes(api_htmlentities(
-                        get_lang('DeleteForumCategory'),
-                        ENT_QUOTES
+                    .'</a>';
+
+                $tools .= '<a href="'.api_get_self().'?'.api_get_cidreq()
+                    .'&action=delete&content=forumcategory&id='.intval($idCategory)
+                    ."\" onclick=\"javascript:if(!confirm('"
+                    .addslashes(api_htmlentities(
+                            get_lang('DeleteForumCategory'), ENT_QUOTES
                     ))
-                    . "')) return false;\">"
-                    . Display::return_icon(
-                        'delete.png',
-                        get_lang('Delete'),
-                        array(),
-                        ICON_SIZE_SMALL
+                    ."')) return false;\">"
+                    .Display::return_icon(
+                        'delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL
                     )
-                    . '</a>';
-                $iconsEdit .= return_visible_invisible_icon(
-                    'forumcategory',
-                    strval(intval($idCategory)),
-                    strval(intval($forumCategory['visibility']))
+                    .'</a>';
+                $tools .= return_visible_invisible_icon(
+                    'forumcategory', strval(intval($idCategory)), strval(intval($forumCategory['visibility']))
                 );
-                $iconsEdit .= return_lock_unlock_icon(
-                    'forumcategory',
-                    strval(intval($idCategory)),
-                    strval(intval($forumCategory['locked']))
+                $tools .= return_lock_unlock_icon(
+                    'forumcategory', strval(intval($idCategory)), strval(intval($forumCategory['locked']))
                 );
-                $iconsEdit .= return_up_down_icon(
-                    'forumcategory',
-                    strval(intval($idCategory)),
-                    $forumCategories
+                $tools .= return_up_down_icon(
+                    'forumcategory', strval(intval($idCategory)), $forumCategories
                 );
             }
         }
+        $dataForum['tools'] = $tools;
+        $dataForum['forums'] = [];
+        // The forums in this category.
+        $forumInfo = array();
+        $forumsInCategory = get_forums_in_category($forumCategory['cat_id']);
 
-        $html .= '<div class="category-forum">';
-        $html .= Display::tag(
-            'div',
-            $iconsEdit,
-            array(
-                'class' => 'pull-right'
-            )
-        );
-        $icoCategory = Display::return_icon(
-            'forum_blue.png',
-            get_lang(
-                $forumCategory['cat_title']
-            ),
-            array(),
-            ICON_SIZE_MEDIUM
-        );
-        $html .= '<h3>'.$icoCategory.$titleCategory.'</h3>';
-
-        if ($descriptionCategory != '' && trim($descriptionCategory) != '&nbsp;') {
-            $html .= '<div class="forum-description">'.$descriptionCategory.'</div>';
-        }
-
-        $html .= '</div>';
-        echo $html;
-
-        echo '<div class="forum_display">';
         if (!empty($forumsInCategory)) {
+            $forumsDetailsList = null;
             // We display all the forums in this category.
-            foreach ($forum_list as $forum) {
-                $html = '';
+            foreach ($allCourseForums as $forum) {
                 // Here we clean the whatnew_post_info array a little bit because to display the icon we
                 // test if $whatsnew_post_info[$forum['forum_id']] is empty or not.
                 if (isset($forum['forum_id'])) {
@@ -366,14 +315,11 @@ if (is_array($forumCategories)) {
                     }
                 }
 
-                // Note: This can be speed up if we transform the $forum_list
+                // Note: This can be speed up if we transform the $allCourseForums
                 // to an array that uses the forum_category as the key.
-                if (
-                    isset($forum['forum_category']) &&
-                    $forum['forum_category'] == $forumCategory['cat_id']
-                ) {
-                    $show_forum = false;
+                if (isset($forum['forum_category']) && $forum['forum_category'] == $forumCategory['cat_id']) {
 
+                    $show_forum = false;
                     // SHOULD WE SHOW THIS PARTICULAR FORUM
                     // you are teacher => show forum
                     if (api_is_allowed_to_edit(false, true)) {
@@ -386,9 +332,7 @@ if (is_array($forumCategories)) {
                             $show_forum = true;
                         } else {
                             $show_forum = GroupManager::user_has_access(
-                                $user_id,
-                                $forum['forum_of_group'],
-                                GroupManager::GROUP_TOOL_FORUM
+                                    $user_id, $forum['forum_of_group'], GroupManager::GROUP_TOOL_FORUM
                             );
                         }
                     }
@@ -397,104 +341,44 @@ if (is_array($forumCategories)) {
                         $form_count++;
                         $mywhatsnew_post_info = isset($whatsnew_post_info[$forum['forum_id']]) ?
                             $whatsnew_post_info[$forum['forum_id']] : null;
-
-                        $html = '<div class="panel panel-default forum">';
-                        $html .= '<div class="panel-body">';
-
-                        $forum_image = '';
-                        $imgForum = '';
+                        $forumInfo['id'] = $forum['forum_id'];
+                        $forumInfo['forum_of_group'] = $forum['forum_of_group'];
+                        $forumInfo['title'] = $forum['forum_title'];
+                        $forumInfo['forum_image'] = null;
                         // Showing the image
                         if (!empty($forum['forum_image'])) {
                             $image_path = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/upload/forum/images/'.$forum['forum_image'];
                             $image_size = api_getimagesize($image_path);
                             $img_attributes = '';
                             if (!empty($image_size)) {
-                                //limit display width and height to 100px
-                                $img_attributes = ' style="width:80px" height="80px"';
-                                $imgForum = "<img src=\"$image_path\" $img_attributes>";
-                            } else {
-                                $imgForum = '';
-                            }
-
-                            $forum_image = $imgForum;
-                        } else {
-                            if ($forum['forum_of_group'] == '0') {
-                                $forum_image = Display::return_icon(
-                                    'forum_group.png',
-                                    get_lang('GroupForum'),
-                                    null,
-                                    ICON_SIZE_LARGE
-                                );
-                            } else {
-                                $forum_image = Display::return_icon(
-                                    'forum.png',
-                                    get_lang('Forum'),
-                                    null,
-                                    ICON_SIZE_LARGE
-                                );
+                                $forumInfo['forum_image'] = $image_path;
                             }
                         }
-
                         // Validation when belongs to a session
-                        $session_img = api_get_session_image(
-                            $forum['session_id'],
-                            $_user['status']
+                        $sessionImg = api_get_session_image(
+                            $forum['session_id'], $_user['status']
                         );
 
+                        $forumInfo['icon_session'] = $sessionImg;
+
                         if ($forum['forum_of_group'] != '0') {
                             $my_all_groups_forum_name = isset($all_groups[$forum['forum_of_group']]['name']) ?
                                 $all_groups[$forum['forum_of_group']]['name'] : null;
                             $my_all_groups_forum_id = isset($all_groups[$forum['forum_of_group']]['id']) ?
                                 $all_groups[$forum['forum_of_group']]['id'] : null;
                             $group_title = api_substr(
-                                $my_all_groups_forum_name,
-                                0,
-                                30
+                                $my_all_groups_forum_name, 0, 30
                             );
-                            $forum_title_group_addition = ' (<a href="../group/group_space.php?'
-                                . api_get_cidreq().'&gidReq='.$forum['forum_of_group']
-                                . '" class="forum_group_link">'.get_lang('GoTo').' '.$group_title.'</a>)'
-                                . $session_img;
-                        } else {
-                            $forum_title_group_addition = '';
+                            $forumInfo['forum_group_title'] = $group_title;
                         }
 
-                        if (empty($sessionId) && !empty($forum['session_name'])) {
-                            $session_displayed = ' ('.$forum['session_name'].')';
-                        } else {
-                            $session_displayed = '';
-                        }
                         $forum['forum_of_group'] == 0 ? $groupid = '' : $groupid = $forum['forum_of_group'];
-
-                        $number_threads = isset($forum['number_of_threads']) ? (int) $forum['number_of_threads'] : 0;
-                        $number_posts = isset($forum['number_of_posts']) ? $forum['number_of_posts'] : 0;
+                        $forumInfo['visibility'] = $forum['visibility'];
+                        $forumInfo['number_threads'] = isset($forum['number_of_threads']) ? (int) $forum['number_of_threads'] : 0;
+                        //$number_posts = isset($forum['number_of_posts']) ? $forum['number_of_posts'] : 0;
 
                         $linkForum = api_get_path(WEB_CODE_PATH).'forum/viewforum.php?'.api_get_cidreq().'&gidReq='.$groupid.'&forum='.$forum['forum_id'];
-
-                        $html .= '<div class="row">';
-                        $html .= '<div class="col-md-6">';
-                        $html .= '<div class="col-md-3">';
-                        $html .= '<div class="number-post">'.Display::url($forum_image, $linkForum);
-                        $html .= '<p>'.$number_threads.' '.get_lang('ForumThreads').'</p>'
-                            . '</div>';
-                        $html .= '</div>';
-
-                        $html .= '<div class="col-md-9">';
-                        $iconForum = Display::return_icon(
-                            'forum_yellow.png',
-                            get_lang($forumCategory['cat_title']),
-                            null,
-                            ICON_SIZE_MEDIUM
-                        );
-
-                        $linkForum = Display::tag(
-                            'a',
-                            $forum['forum_title'],
-                            [
-                                'href' => $linkForum,
-                                'class' => empty($forum['visibility']) ? 'text-muted' : null
-                            ]
-                        );
+                        $forumInfo['url'] = $linkForum;
 
                         if (!empty($forum['start_time']) && !empty($forum['end_time'])) {
                             $res = api_is_date_in_date_range($forum['start_time'], $forum['end_time']);
@@ -503,65 +387,34 @@ if (is_array($forumCategories)) {
                             }
                         }
 
-                        $html .= '<h3 class="title">'.$iconForum.$linkForum.'</h3>';
-                        $html .= Display::tag(
-                            'p',
-                            Security::remove_XSS($forum['forum_comment']),
-                            [
-                                'class'=>'description'
-                            ]
-                        );
+                        $forumInfo['description'] = Security::remove_XSS($forum['forum_comment']);
 
                         if ($forum['moderated'] == 1 && api_is_allowed_to_edit(false, true)) {
                             $waitingCount = getCountPostsWithStatus(
-                                CForumPost::STATUS_WAITING_MODERATION,
-                                $forum
+                                CForumPost::STATUS_WAITING_MODERATION, $forum
                             );
                             if (!empty($waitingCount)) {
-                                $html .= Display::label(
-                                    get_lang('PostsPendingModeration').': '.$waitingCount,
-                                    'warning'
-                                );
+                                $forumInfo['moderation'] = $waitingCount;
                             }
                         }
 
-                        $html .= '</div>';
-                        $html .= '</div>';
-
-                        $iconEmpty = '';
-
+                        $toolActions = null;
+                        $forumInfo['alert'] = null;
                         // The number of topics and posts.
                         if ($forum['forum_of_group'] !== '0') {
-                            $newPost = '';
                             if (is_array($mywhatsnew_post_info) && !empty($mywhatsnew_post_info)) {
-                                $newPost = ' '.Display::return_icon(
-                                    'alert.png',
-                                    get_lang('Forum'),
-                                    null,
-                                    ICON_SIZE_SMALL
+                                $forumInfo['alert'] = ' '.Display::return_icon(
+                                        'alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL
                                 );
-                            } else {
-                                $newPost = $iconEmpty;
                             }
                         } else {
                             if (is_array($mywhatsnew_post_info) && !empty($mywhatsnew_post_info)) {
-                                $newPost = ' '.Display::return_icon(
-                                    'alert.png',
-                                    get_lang('Forum'),
-                                    null,
-                                    ICON_SIZE_SMALL
+                                $forumInfo['alert'] = ' '.Display::return_icon(
+                                        'alert.png', get_lang('Forum'), null, ICON_SIZE_SMALL
                                 );
-                            } else {
-                                $newPost = $iconEmpty;
                             }
                         }
-
-                        $html .= '<div class="col-md-6">';
-                        $html .= '<div class="row">';
-                        $html .= '<div class="col-md-2">';
-                        $html .= $newPost.'</div>';
-                        $html .= '<div class="col-md-6">';
-
+                        $poster_id = null;
                         // The last post in the forum.
                         if (isset($forum['last_poster_name']) && $forum['last_poster_name'] != '') {
                             $name = $forum['last_poster_name'];
@@ -570,112 +423,82 @@ if (is_array($forumCategories)) {
                         } else {
                             if (isset($forum['last_poster_firstname'])) {
                                 $name = api_get_person_name(
-                                    $forum['last_poster_firstname'],
-                                    $forum['last_poster_lastname']
+                                    $forum['last_poster_firstname'], $forum['last_poster_lastname']
                                 );
                                 $poster_id = $forum['last_poster_id'];
                                 $userinfo = api_get_user_info($poster_id);
                                 $username = sprintf(
-                                    get_lang('LoginX'),
-                                    $userinfo['username']
+                                    get_lang('LoginX'), $userinfo['username']
                                 );
                             }
                         }
-
+                        $forumInfo['last_post_id'] = $poster_id;
+                        
                         if (!empty($forum['last_post_id'])) {
-                            $html .= Display::return_icon(
-                                    'post-item.png',
-                                    null,
-                                    null,
-                                    ICON_SIZE_TINY
-                                )
-                                . ' '.
-                                api_convert_and_format_date($forum['last_post_date'])
-                                . '<br /> '.get_lang('By').' '.
-                                display_user_link(
-                                    $poster_id,
-                                    $name,
-                                    '',
-                                    $username
-                                );
+                            $forumInfo['last_post_date'] = api_convert_and_format_date($forum['last_post_date']);
+                            $forumInfo['last_post_user'] = display_user_link($poster_id, $name, null, $username);
                         }
-                        $html .= '</div>';
-                        $html .= '<div class="col-md-4">';
 
                         if (api_is_allowed_to_edit(false, true) &&
                             !($forum['session_id'] == 0 && intval($sessionId) != 0)
                         ) {
-                            $html .= '<a href="'.api_get_self().'?'.api_get_cidreq()
-                                . '&action=edit&content=forum&id='.$forum['forum_id'].'">'
-                                . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL)
-                                . '</a>';
-                            $html .= '<a href="'.api_get_self().'?'.api_get_cidreq()
-                                . '&action=delete&content=forum&id='.$forum['forum_id']
-                                . "\" onclick=\"javascript:if(!confirm('".addslashes(
+                            $toolActions .= '<a href="'.api_get_self().'?'.api_get_cidreq()
+                                .'&action=edit&content=forum&id='.$forum['forum_id'].'">'
+                                .Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL)
+                                .'</a>';
+                            $toolActions .= '<a href="'.api_get_self().'?'.api_get_cidreq()
+                                .'&action=delete&content=forum&id='.$forum['forum_id']
+                                ."\" onclick=\"javascript:if(!confirm('".addslashes(
                                     api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES)
                                 )
-                                . "')) return false;\">"
-                                . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL)
-                                . '</a>';
-
-                            $html .= return_visible_invisible_icon(
-                                'forum',
-                                $forum['forum_id'],
-                                $forum['visibility']
+                                ."')) return false;\">"
+                                .Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL)
+                                .'</a>';
+
+                            $toolActions .= return_visible_invisible_icon(
+                                'forum', $forum['forum_id'], $forum['visibility']
                             );
 
-                            $html .= return_lock_unlock_icon(
-                                'forum',
-                                $forum['forum_id'],
-                                $forum['locked']
+                            $toolActions .= return_lock_unlock_icon(
+                                'forum', $forum['forum_id'], $forum['locked']
                             );
 
-                            $html .= return_up_down_icon(
-                                'forum',
-                                $forum['forum_id'],
-                                $forumsInCategory
+                            $toolActions .= return_up_down_icon(
+                                'forum', $forum['forum_id'], $forumsInCategory
                             );
                         }
+
                         $iconnotify = 'notification_mail_na.png';
                         $session_forum_notification = isset($_SESSION['forum_notification']['forum']) ?
-                            $_SESSION['forum_notification']['forum'] : false;
+                        $_SESSION['forum_notification']['forum'] : false;
                         if (is_array($session_forum_notification)) {
                             if (in_array(
-                                $forum['forum_id'],
-                                $session_forum_notification
-                            )) {
+                                    $forum['forum_id'], $session_forum_notification
+                                )) {
                                 $iconnotify = 'notification_mail.png';
                             }
                         }
 
-                        if (
-                            !api_is_anonymous() &&
-                            api_is_allowed_to_session_edit(false, true)
-                        ) {
-                            $html .= '<a href="'.api_get_self().'?'.api_get_cidreq()
-                                . '&action=notify&content=forum&id='.$forum['forum_id'].'">'
-                                . Display::return_icon($iconnotify, get_lang('NotifyMe'), null, ICON_SIZE_SMALL)
-                                . '</a>';
+                        if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
+                            $toolActions .= '<a href="'.api_get_self().'?'.api_get_cidreq()
+                                .'&action=notify&content=forum&id='.$forum['forum_id'].'">'
+                                .Display::return_icon($iconnotify, get_lang('NotifyMe'), null, ICON_SIZE_SMALL)
+                                .'</a>';
                         }
-
-                        $html .= '</div>';
-                        $html .= '</div>';
-                        $html .= '</div>';
-
-                        $html .= '</div>';
-                        $html .= '</div>';
-                        $html .= '</div>';
+                        $forumInfo['tools'] = $toolActions;
+                        $forumsDetailsList[] = $forumInfo;
                     }
-                    echo $html;
                 }
             }
-        } else {
-            echo '<div class="alert alert-warning">'.get_lang('NoForumInThisCategory').'</div>'
-                . (api_is_allowed_to_edit(false, true) ? '<div>' : '</div>')
-                . '</div>';
+            $dataForum['forums'] =  $forumsDetailsList;
         }
-
-        echo '</div>';
+        $listForumCategory[] = $dataForum;
     }
 }
+
+$tpl->assign('introduction_section', $introduction);
+$tpl->assign('actions', $actions);
+$tpl->assign('data', $listForumCategory);
+$layout = $tpl->get_template('forum/list.tpl');
+$tpl->display($layout);
 Display:: display_footer();

+ 81 - 0
main/template/default/forum/list.tpl

@@ -0,0 +1,81 @@
+{{ introduction_section }}
+{% if data is not empty %}
+{% for item in data %}
+    <div class="category-forum" id="category_{{ item.id }}">
+        <div class="pull-right">
+            {{ item.tools }}
+        </div>
+        <h3>
+            {{ 'forum_blue.png'|img(32) }}
+            <a href="{{ item.url }}" title="{{ item.title }}">{{ item.title }}{{ item.icon_session }}</a>
+        </h3>
+        <div class="forum-description">
+            {{ item.description }}
+        </div>
+    </div>
+        {% for subitem in item.forums %}
+            <div class="forum_display">
+                <div class="panel panel-default forum">
+                    <div class="panel-body">
+                        <div class="row">
+                            <div class="col-md-3">
+                                <div class="number-post">
+                                    <a href="{{ forum.url }}" title="{{forum.title}}">
+                                    {% if subitem.forum_image is not empty %}
+                                        <img src="{{ subitem.forum_image }}" width="48px">
+                                    {% else %}
+                                        {% if subitem.forum_of_group == 0 %}
+                                            {{ 'forum_group.png'|img(48) }}
+                                        {% else %}
+                                            {{ 'forum.png'|img(48) }}
+                                        {% endif %}
+                                    {% endif %}
+                                    </a>
+                                    <p>{{ 'ForumThreads'| get_lang }}: {{ subitem.number_threads }} </p>
+                                </div>
+                            </div>
+                            <div class="col-md-9">
+                                <div class="pull-right">
+                                    <div class="toolbar">
+                                        {{ subitem.tools }}
+                                    </div>
+                                </div>
+                                <h3 class="title">
+                                {{ 'forum_yellow.png'|img(32) }}
+                                <a href="{{ subitem.url }}" title="{{ subitem.title }}" class="{{ subitem.visibility != '1' ? 'text-muted': '' }}">{{ subitem.title }}</a>
+                                {% if subitem.forum_of_group != 0 %}
+                                    <a class="forum-goto" href="../group/group_space.php?{{ _p.web_cid_query }}&gidReq={{ subitem.forum_of_group }}">
+                                        {{ "forum.png"|img(22) }} {{ "GoTo"|get_lang }} {{ subitem.forum_group_title }}
+                                    </a>
+                                {% endif %}
+                                {{ subitem.icon_session }}
+                                </h3>
+                                {% if subitem.last_post_id is not empty %}
+                                    <div class="forum-date">
+                                        <i class="fa fa-comments" aria-hidden="true"></i> 
+                                        {{ subitem.last_post_date }} 
+                                        {{ "By"|get_lang }} 
+                                        {{ subitem.last_post_user }}
+                                    </div>
+                                {% endif %}
+                                <div class="description">
+                                    {{ subitem.description }}
+                                </div>
+                                {{ subitem.alert }}
+                                {% if subitem.moderation is not empty %}
+                                    <span class="label label-warning">
+                                        {{ "PostsPendingModeration"|get_lang }}: {{ subitem.moderation }}
+                                    </span>
+                                {% endif %}
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        {% endfor %}
+{% endfor %}
+{% else %}
+    <div class="alert alert-warning">
+        {{ 'NoForumInThisCategory'|get_lang }}
+    </div>
+{% endif %}