Skip to content

Commit cdb7dde

Browse files
committed
More updates to the forum views.
1 parent e24e495 commit cdb7dde

File tree

15 files changed

+264
-185
lines changed

15 files changed

+264
-185
lines changed

public/less/master_mixins.less

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,11 @@ input[type="color"]:focus,
590590
div.labels {
591591
margin-left: 25px;
592592
display: block;
593+
border-bottom: 1px solid lighten(@grey, 10%);
593594
div {
594595
display: block;
595596
&.subject {
596-
width: 70%;
597+
width: 60%;
597598
display: block;
598599
float: left;
599600
}
@@ -602,7 +603,7 @@ div.labels {
602603
float: left;
603604
}
604605
&.lastPost {
605-
width: 15%;
606+
width: 25%;
606607
float: left;
607608
}
608609
}
@@ -631,7 +632,7 @@ ul.forum {
631632
&:hover {
632633
background: rgba(red(@grey), green(@grey), blue(@grey), .4);
633634
}
634-
&.announcement:before {
635+
&.announcement:before, &.wontFix:before {
635636
content: '';
636637
background: saturate(lighten(@errorColor, 15%), 40%) !important;
637638
position: absolute;
@@ -641,7 +642,7 @@ ul.forum {
641642
height: 100%;
642643
box-shadow: 0 0 40px saturate(lighten(@errorColor, 15%), 40%) !important;
643644
}
644-
&.sticky:before {
645+
&.sticky:before, &.inProgress:before {
645646
content: '';
646647
background: saturate(lighten(@warningColor, 15%), 40%) !important;
647648
position: absolute;
@@ -651,7 +652,7 @@ ul.forum {
651652
height: 100%;
652653
box-shadow: 0 0 40px saturate(lighten(@warningColor, 15%), 40%) !important;
653654
}
654-
&.application:before {
655+
&.application:before, &.open:before {
655656
content: '';
656657
background: saturate(lighten(@infoColor, 15%), 40%) !important;
657658
position: absolute;
@@ -661,6 +662,16 @@ ul.forum {
661662
height: 100%;
662663
box-shadow: 0 0 40px saturate(lighten(@infoColor, 15%), 40%) !important;
663664
}
665+
&.resolved:before {
666+
content: '';
667+
background: saturate(lighten(@successColor, 15%), 40%) !important;
668+
position: absolute;
669+
top: 0;
670+
left: -6px;
671+
width: 6px;
672+
height: 100%;
673+
box-shadow: 0 0 40px saturate(lighten(@successColor, 15%), 40%) !important;
674+
}
664675
&.unread:before, &:hover:before {
665676
content: '';
666677
background: saturate(lighten(@primaryColor, 15%), 40%);
@@ -673,23 +684,28 @@ ul.forum {
673684
}
674685
div {
675686
display: block;
687+
div:first-of-type {
688+
border-top: 0;
689+
}
676690
&.post {
677691
padding: 13px 0 13px 20px;
678692
width: 100%;
679693
height: auto!important;
680694
border-top: 1px solid lighten(@grey, 10%);
681695
}
682696
&.subject {
683-
width: 70%;
697+
width: 60%;
684698
display: block;
685699
float: left;
700+
vertical-align: middle;
701+
height: 100%;
686702
}
687703
&.replies {
688704
width: 15%;
689705
float: left;
690706
}
691707
&.lastPost {
692-
width: 15%;
708+
width: 25%;
693709
float: left;
694710
}
695711
}

src/controllers/Core_ForumController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ public function getSearch()
4646
'Forum_Reply' => 'Reply'
4747
];
4848

49-
$users = User::orderByNameAsc()->get();
50-
$users = $this->arrayToSelect($users, 'id', 'username', 'Select a user');
49+
$users = User::orderByNameAsc()->get()->toSelectArray('Select a user', 'id', 'username');
50+
$statuses = Forum_Support_Status::all()->toSelectArray('Select a status');
5151

5252
$this->setViewData('typesArray', $typesArray);
5353
$this->setViewData('users', $users);
54+
$this->setViewData('statuses', $statuses);
5455
}
5556

5657
public function postSearch()

src/controllers/Forum/Core_BoardController.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ class Core_Forum_BoardController extends BaseController {
55
public function getView($boardId)
66
{
77
// Get the information
8-
$board = Forum_Board::find($boardId);
8+
$board = Forum_Board::with('children')->find($boardId);
99

10-
$openIssues = Forum_Post_Status::where('forum_support_status_id', '=', Forum_Support_Status::TYPE_OPEN)->count();
11-
$inProgressIssues = Forum_Post_Status::where('forum_support_status_id', '=', Forum_Support_Status::TYPE_IN_PROGRESS)->count();
12-
$resolvedIssues = Forum_Post_Status::where('forum_support_status_id', '=', Forum_Support_Status::TYPE_RESOLVED)->count();
10+
$openIssues = Forum_Post_Status::where('forum_support_status_id', Forum_Support_Status::TYPE_OPEN)->count();
11+
$inProgressIssues = Forum_Post_Status::where('forum_support_status_id', Forum_Support_Status::TYPE_IN_PROGRESS)->count();
12+
$resolvedIssues = Forum_Post_Status::where('forum_support_status_id', Forum_Support_Status::TYPE_RESOLVED)->count();
1313
$announcements = Forum_Post::with('author')->where('forum_board_id', $board->id)->where('forum_post_type_id', Forum_Post::TYPE_ANNOUNCEMENT)->orderBy('modified_at', 'desc')->get();
1414
$posts = Forum_Post::with('author')->where('forum_board_id', $board->id)->where('forum_post_type_id', '!=', Forum_Post::TYPE_ANNOUNCEMENT)->orderBy('modified_at', 'desc')->paginate(30);
1515

@@ -27,15 +27,15 @@ public function getView($boardId)
2727
$this->setViewData('resolvedIssues', $resolvedIssues);
2828
}
2929

30-
public function getAdd($categorySlug = null)
30+
public function getAdd($categoryId = null)
3131
{
3232
// Make sure they can access this whole area
3333
$this->checkPermission('FORUM_ADMIN');
3434

3535
// Get the information
3636
$category = null;
37-
if ($categorySlug != null) {
38-
$category = Forum_Category::where('uniqueId', '=', $categorySlug)->first();
37+
if ($categoryId != null) {
38+
$category = Forum_Category::find($categoryId);
3939
}
4040
$boards = $this->arrayToSelect(Forum_Board::orderBy('name', 'asc')->get(), 'id', 'name', 'Select a parent board');
4141
$categories = $this->arrayToSelect(Forum_Category::orderBy('position', 'asc')->get(), 'id', 'name', 'Select Category');

src/models/Forum.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ public function recentSupportPosts()
7474
{
7575
// Get all non-support categories
7676
return Forum_Category::with('boards.posts')
77-
->where('forum_category_type_id', '=', Forum_Category::TYPE_SUPPORT)
77+
->where('forum_category_type_id', Forum_Category::TYPE_SUPPORT)
7878
->get()
7979
->boards
8080
->posts
81-
->take(5);
81+
->take(3);
8282
}
8383

8484
/**

src/models/Forum/Board.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,6 @@ public function getLastUpdatePageAttribute()
166166
return 1;
167167
}
168168

169-
/**
170-
* Get child boards
171-
*
172-
* @return int
173-
*/
174-
public function getChildrenAttribute()
175-
{
176-
return $this->children()->get();
177-
}
178-
179169
/**
180170
* Get child board links and format them as needed
181171
*
@@ -197,9 +187,9 @@ public function getChildLinksAttribute()
197187
});
198188

199189
if (count($posts) > 0) {
200-
$links[] = '<b>' . HTML::linkIcon('forum/board/view/'. $child->id, 'fa fa-asterisk', $child->name) . '</b>';
190+
$links[] = '<strong>' . HTML::link('forum/board/view/'. $child->id, $child->name) . '</strong>';
201191
} else {
202-
$links[] = HTML::link('forum/board/view/'. $child->id, $child->name, array('style' => 'font-weight: normal;'));
192+
$links[] = HTML::link('forum/board/view/'. $child->id, $child->name, array('style' => 'font-weight: normal;', 'class' => 'text-disabled'));
203193
}
204194
}
205195
return implode(', ', $links);

src/models/Forum/View.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ class Forum_View extends Forum
4646
/********************************************************************
4747
* Scopes
4848
*******************************************************************/
49+
public function scopeStatus($query, $statusId)
50+
{
51+
return $query->join('forum_post_status', 'forum_post_status.forum_post_id', '=', 'forum_view.uniqueId')->where('forum_post_status.forum_support_status_id', $statusId);
52+
}
4953

5054
/********************************************************************
5155
* Model events
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php namespace Syntax\Core;
2+
3+
class Forum_BoardPresenter extends CorePresenter {
4+
5+
public function classes()
6+
{
7+
if (\CoreView::getActiveUser()->checkUnreadBoard($this->resource->id)) {
8+
return 'unread';
9+
}
10+
11+
return null;
12+
}
13+
14+
public function link()
15+
{
16+
if (\CoreView::getActiveUser()->checkUnreadBoard($this->resource->id)) {
17+
$link = '<strong class="boardLink">'. \HTML::link('forum/board/view/'. $this->resource->id, $this->resource->name) .'</strong>';
18+
} else {
19+
$link = '<span class="boardLink">'. \HTML::link('/forum/board/view/'. $this->resource->id, $this->resource->name, array('class' => 'text-disabled')) .'</span>';
20+
}
21+
22+
if ($this->resource->children->count() > 0) {
23+
$link .= '<br />
24+
<small style="margin-left: 15px;"><small>'. $this->resource->childLinks .'</small></small>';
25+
}
26+
27+
return $link;
28+
}
29+
30+
public function repliesBlock()
31+
{
32+
return $this->resource->postsCount .' '. \Str::plural('Post', $this->resource->postsCount) .'
33+
<br />
34+
'. $this->resource->repliesCount .' '. \Str::plural('Reply', $this->resource->repliesCount);
35+
}
36+
37+
public function lastPostBlock()
38+
{
39+
if ($this->resource->lastUpdate !== false) {
40+
$lastUpdateType = $this->resource->lastUpdate->type->keyName;
41+
$lastUpdateUser = ($this->resource->lastUpdate->morph_id == null || $lastUpdateType == 'application'
42+
? $this->resource->lastUpdate->author : $this->resource->lastUpdate->morph);
43+
$lastUpdateName = ($lastUpdateUser instanceof \UserPresenter || $lastUpdateUser instanceof \User ? $lastUpdateUser->username : $lastUpdateUser->name);
44+
45+
return '<small>
46+
Last Post by '. \HTML::link('/user/view/'. $this->resource->lastUpdate->author->id, $lastUpdateName) .'
47+
<br />
48+
in '. \HTML::link('forum/post/view/'. $this->resource->lastPost->id .'#reply:'. $this->resource->lastUpdate->id, $this->resource->lastUpdate->name) .'
49+
<br />
50+
on '. $this->resource->lastUpdate->created_at .'
51+
</small>';
52+
} else {
53+
return '<small>
54+
No posts.
55+
</small>';
56+
}
57+
}
58+
}

src/presenters/Forum/PostPresenter.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ public function classes()
1313
} elseif ($this->resource->forum_post_type_id == \Forum_Post::TYPE_APPLICATION) {
1414
$classes[] = 'application';
1515
}
16+
17+
if ($this->resource->board->category->forum_category_type_id == \Forum_Category::TYPE_SUPPORT) {
18+
if ($this->resource->status->forum_support_status_id == \Forum_Support_Status::TYPE_OPEN) {
19+
$classes[] = 'open';
20+
} elseif ($this->resource->status->forum_support_status_id == \Forum_Support_Status::TYPE_IN_PROGRESS) {
21+
$classes[] = 'inProgress';
22+
} elseif ($this->resource->status->forum_support_status_id == \Forum_Support_Status::TYPE_RESOLVED) {
23+
$classes[] = 'resolved';
24+
} elseif ($this->resource->status->forum_support_status_id == \Forum_Support_Status::TYPE_WONT_FIX) {
25+
$classes[] = 'wontFix';
26+
}
27+
}
28+
1629
if ($this->resource->checkUserViewed(\CoreView::getActiveUser()->id)) {
1730
$classes[] = 'unread';
1831
}
@@ -66,7 +79,7 @@ public function lastPostBlock()
6679
$lastUpdateType = $this->resource->lastUpdate->type->keyName;
6780
$lastUpdateUser = ($this->resource->lastUpdate->morph_id == null || $lastUpdateType == 'application'
6881
? $this->resource->lastUpdate->author : $this->resource->lastUpdate->morph);
69-
$lastUpdateName = ($lastUpdateUser instanceof \UserPresenter ? $lastUpdateUser->username : $lastUpdateUser->name);
82+
$lastUpdateName = ($lastUpdateUser instanceof \UserPresenter || $lastUpdateUser instanceof \User ? $lastUpdateUser->username : $lastUpdateUser->name);
7083

7184
return '<small>
7285
'. $this->resource->lastUpdate->created_at .'
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<small>
2+
<ul class="breadcrumb">
3+
<li>{{ HTML::link('forum', 'Forums') }}</li>
4+
<li>{{ HTML::link('forum/category/view/'. $board->category->id, $board->category->name) }}</li>
5+
<li class="active">
6+
{{ $board->name }}
7+
@if ($posts->getTotal() > 30)
8+
<?php
9+
if (isset($_GET['page'])) {
10+
$page = $_GET['page'];
11+
} else {
12+
$page = 1;
13+
}
14+
?>
15+
: Page {{ $posts->getCurrentPage() }}
16+
@endif
17+
</li>
18+
<li class="pull-right">
19+
{{ HTML::link('/forum/post/add/'. $board->id, 'Add Post') }}
20+
</li>
21+
</ul>
22+
</small>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<li class="{{ $post->classes }}">
2+
<div class="post">
3+
<div class="subject">
4+
{{ $post->link }}
5+
<br />
6+
{{ $post->startedBy }}
7+
</div>
8+
<div class="replies">
9+
{{ $post->repliesBlock }}
10+
</div>
11+
<div class="lastPost">
12+
{{ $post->lastPostBlock }}
13+
</div>
14+
<div class="clearfix"></div>
15+
</div>
16+
</li>

0 commit comments

Comments
 (0)