Skip to content

Commit b7198b8

Browse files
committed
Issues-386: design tweaks
1 parent 7525419 commit b7198b8

File tree

19 files changed

+2992
-66
lines changed

19 files changed

+2992
-66
lines changed

vanilla/applications/dashboard/controllers/class.searchcontroller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ public function initialize() {
5858
$this->addCssFile('style.css');
5959
$this->addCssFile('vanillicon.css', 'static');
6060
$this->addModule('GuestModule');
61-
$this->addModule('NewDiscussionModule');
61+
//$this->addModule('NewDiscussionModule');
6262
$this->addModule('DiscussionFilterModule');
63-
$this->addModule('CategoriesModule');
63+
//$this->addModule('CategoriesModule');
6464
$this->addModule('BookmarkedModule');
6565
parent::initialize();
6666
$this->setData('Breadcrumbs', [['Name' => t('Search'), 'Url' => '/search']]);
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
/**
3+
* Guest module.
4+
*
5+
* @copyright 2009-2019 Vanilla Forums Inc.
6+
* @license GPL-2.0-only
7+
* @package Dashboard
8+
* @since 2.0
9+
*/
10+
11+
/**
12+
* Renders the "You should register or sign in" panel box.
13+
*/
14+
class GuestModule extends Gdn_Module {
15+
16+
/** @var string */
17+
public $MessageCode = 'GuestModule.Message';
18+
19+
/** @var string */
20+
public $MessageDefault = "Looks like you are new or aren't currently signed in.";
21+
22+
/**
23+
*
24+
*
25+
* @param string $sender
26+
* @param bool $applicationFolder
27+
*/
28+
public function __construct($sender = '', $applicationFolder = false) {
29+
if (!$applicationFolder) {
30+
$applicationFolder = 'Dashboard';
31+
}
32+
parent::__construct($sender, $applicationFolder);
33+
34+
$this->Visible = c('Garden.Modules.ShowGuestModule');
35+
}
36+
37+
/**
38+
*
39+
*
40+
* @return string
41+
*/
42+
public function assetTarget() {
43+
return 'Panel';
44+
}
45+
46+
/**
47+
* Render.
48+
*
49+
* @return string
50+
*/
51+
public function toString() {
52+
if (!Gdn::session()->isValid()) {
53+
return parent::toString();
54+
}
55+
56+
return '';
57+
}
58+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php if (!defined('APPLICATION')) exit(); ?>
2+
<div class="Box GuestBox">
3+
<h4><?php echo t('Welcome to Topcoder!'); ?></h4>
4+
5+
<p><?php echo t($this->MessageCode, $this->MessageDefault); ?></p>
6+
7+
<p><?php $this->fireEvent('BeforeSignInButton'); ?></p>
8+
9+
<?php
10+
$signInUrl = signInUrl($this->_Sender->SelfUrl);
11+
12+
if ($signInUrl) {
13+
echo '<div class="P">';
14+
15+
echo anchor(t('Login'), signInUrl($this->_Sender->SelfUrl), 'Button Primary SignIn BigButton'.(signInPopup() ? ' SignInPopup' : ''), ['rel' => 'nofollow']);
16+
// $Url = registerUrl($this->_Sender->SelfUrl);
17+
// if (!empty($Url)) {
18+
// echo ' '.anchor(t('Register', t('Apply for Membership', 'Register')), $Url, 'Button ApplyButton', ['rel' => 'nofollow']);
19+
// }
20+
21+
echo '</div>';
22+
}
23+
?>
24+
<?php $this->fireEvent('AfterSignInButton'); ?>
25+
</div>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php if (!defined('APPLICATION')) exit(); ?>
2+
<h1 class="H HomepageTitle">Search</h1>
3+
<div class="SearchForm">
4+
<?php
5+
$Form = $this->Form;
6+
echo $Form->open(['action' => url('/search'), 'method' => 'get']),
7+
'<div class="SiteSearch InputAndButton">',
8+
$Form->textBox('Search', ['aria-label' => t('Enter your search term.'), 'title' => t('Enter your search term.') ]),
9+
$Form->button('Search', ['aria-label' => t('Search'), 'Name' => '']),
10+
'</div>',
11+
$Form->errors(),
12+
$Form->close();
13+
?>
14+
</div>
15+
<?php
16+
$ViewLocation = $this->fetchViewLocation('results');
17+
include($ViewLocation);

vanilla/applications/vanilla/controllers/class.categoriescontroller.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class CategoriesController extends VanillaController {
3434
const SORT_LAST_POST = 'new';
3535
const SORT_OLDEST_POST = 'old';
3636

37+
const ROOT_CATEGORY = ['Name' => 'Roundtables', 'Url'=>'/'];
3738
/**
3839
* @var \Closure $categoriesCompatibilityCallback A backwards-compatible callback to get `$this->data('Categories')`.
3940
*/
@@ -332,7 +333,11 @@ public function index($categoryIdentifier = '', $page = '0') {
332333
}
333334

334335
// Load the breadcrumbs.
335-
$this->setData('Breadcrumbs', CategoryModel::getAncestors(val('CategoryID', $category)));
336+
337+
$ancestors = CategoryModel::getAncestors(val('CategoryID', $category));
338+
array_unshift ( $ancestors , self::ROOT_CATEGORY);
339+
$this->setData('Breadcrumbs', $ancestors);
340+
336341

337342
$this->setData('Category', $category, true);
338343
// Set CategoryID
@@ -406,7 +411,7 @@ public function index($categoryIdentifier = '', $page = '0') {
406411
// Add modules
407412
$this->addModule('NewDiscussionModule');
408413
$this->addModule('DiscussionFilterModule');
409-
$this->addModule('CategoriesModule');
414+
// $this->addModule('CategoriesModule');
410415
$this->addModule('BookmarkedModule');
411416
$this->addModule('TagModule');
412417

@@ -535,7 +540,7 @@ public function all($Category = '', $displayAs = '') {
535540
if ($Title) {
536541
$this->title($Title, '');
537542
} else {
538-
$this->title(t('All Categories'));
543+
$this->title(t('Roundtables'));
539544
}
540545
}
541546
Gdn_Theme::section('CategoryList');
@@ -544,7 +549,10 @@ public function all($Category = '', $displayAs = '') {
544549
$this->description(c('Garden.Description', null));
545550
}
546551

547-
$this->setData('Breadcrumbs', CategoryModel::getAncestors(val('CategoryID', $this->data('Category'))));
552+
$ancestors = CategoryModel::getAncestors(val('CategoryID', $this->data('Category')));
553+
array_unshift ( $ancestors , self::ROOT_CATEGORY);
554+
$this->setData('Breadcrumbs', $ancestors);
555+
548556

549557
// Set the category follow toggle before we load category data so that it affects the category query appropriately.
550558
$CategoryFollowToggleModule = new CategoryFollowToggleModule($this);
@@ -630,10 +638,12 @@ public function all($Category = '', $displayAs = '') {
630638
$this->setData('CategoryTree', $categoryTree);
631639

632640
// Add modules
633-
$this->addModule('NewDiscussionModule');
641+
if($Category) {
642+
$this->addModule('NewDiscussionModule');
643+
}
634644
$this->addModule('DiscussionFilterModule');
635645
$this->addModule('BookmarkedModule');
636-
$this->addModule('CategoriesModule');
646+
// $this->addModule('CategoriesModule');
637647
$this->addModule($CategoryFollowToggleModule);
638648
$this->addModule('TagModule');
639649

@@ -669,7 +679,7 @@ public function discussions($Category = '') {
669679
if ($Title) {
670680
$this->title($Title, '');
671681
} else {
672-
$this->title(t('All Categories'));
682+
$this->title(t('Roundtables'));
673683
}
674684
}
675685

@@ -725,7 +735,7 @@ public function discussions($Category = '') {
725735
// Add modules
726736
$this->addModule('NewDiscussionModule');
727737
$this->addModule('DiscussionFilterModule');
728-
$this->addModule('CategoriesModule');
738+
// $this->addModule('CategoriesModule');
729739
$this->addModule('BookmarkedModule');
730740
$this->addModule($CategoryFollowToggleModule);
731741

vanilla/applications/vanilla/controllers/class.discussioncontroller.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ public function index($DiscussionID = '', $DiscussionStub = '', $Page = '') {
125125
Gdn_Theme::section($CategoryCssClass);
126126
}
127127

128-
$this->setData('Breadcrumbs', CategoryModel::getAncestors($this->CategoryID));
128+
$ancestors = CategoryModel::getAncestors($this->CategoryID);
129+
array_unshift ( $ancestors , CategoriesController::ROOT_CATEGORY);
130+
$this->setData('Breadcrumbs', $ancestors);
129131

130132
// Setup
131133
$this->title($this->Discussion->Name);
@@ -294,7 +296,7 @@ public function index($DiscussionID = '', $DiscussionStub = '', $Page = '') {
294296
// Add modules
295297
$this->addModule('DiscussionFilterModule');
296298
$this->addModule('NewDiscussionModule');
297-
$this->addModule('CategoriesModule');
299+
// $this->addModule('CategoriesModule');
298300
$this->addModule('BookmarkedModule');
299301

300302
$this->CanEditComments = Gdn::session()->checkPermission('Vanilla.Comments.Edit', true, 'Category', 'any') && c('Vanilla.AdminCheckboxes.Use');

vanilla/applications/vanilla/controllers/class.discussionscontroller.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function index($Page = false) {
116116
// Add modules
117117
$this->addModule('DiscussionFilterModule');
118118
$this->addModule('NewDiscussionModule');
119-
$this->addModule('CategoriesModule');
119+
// $this->addModule('CategoriesModule');
120120
$this->addModule('BookmarkedModule');
121121
$this->addModule('TagModule');
122122

@@ -282,7 +282,7 @@ public function unread($page = '0') {
282282
// Add modules
283283
$this->addModule('DiscussionFilterModule');
284284
$this->addModule('NewDiscussionModule');
285-
$this->addModule('CategoriesModule');
285+
// $this->addModule('CategoriesModule');
286286
$this->addModule('BookmarkedModule');
287287
$this->addModule('TagModule');
288288

@@ -459,7 +459,7 @@ public function bookmarked($page = '0') {
459459
// Add modules
460460
$this->addModule('DiscussionFilterModule');
461461
$this->addModule('NewDiscussionModule');
462-
$this->addModule('CategoriesModule');
462+
// $this->addModule('CategoriesModule');
463463
$this->addModule('TagModule');
464464

465465
// Render default view (discussions/bookmarked.php)
@@ -560,7 +560,7 @@ public function mine($page = 'p1') {
560560
// Add modules
561561
$this->addModule('DiscussionFilterModule');
562562
$this->addModule('NewDiscussionModule');
563-
$this->addModule('CategoriesModule');
563+
// $this->addModule('CategoriesModule');
564564
$this->addModule('BookmarkedModule');
565565
$this->addModule('TagModule');
566566

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?php
2+
/**
3+
* Drafts controller
4+
*
5+
* @copyright 2009-2019 Vanilla Forums Inc.
6+
* @license GPL-2.0-only
7+
* @package Vanilla
8+
* @since 2.0
9+
*/
10+
11+
/**
12+
* Handles displaying saved drafts of unposted comments via /drafts endpoint.
13+
*/
14+
class DraftsController extends VanillaController {
15+
16+
/** @var array Models to include. */
17+
public $Uses = ['Database', 'DraftModel'];
18+
19+
/**
20+
* Default all drafts view: chronological by time saved.
21+
*
22+
* @since 2.0.0
23+
* @access public
24+
*
25+
* @param int $offset Number of drafts to skip.
26+
*/
27+
public function index($offset = '0') {
28+
Gdn_Theme::section('DiscussionList');
29+
30+
// Setup head
31+
$this->permission('Garden.SignIn.Allow');
32+
$this->addJsFile('jquery.gardenmorepager.js');
33+
$this->addJsFile('discussions.js');
34+
$this->title(t('My Drafts'));
35+
36+
// Validate $Offset
37+
if (!is_numeric($offset) || $offset < 0) {
38+
$offset = 0;
39+
}
40+
41+
// Set criteria & get drafts data
42+
$limit = Gdn::config('Vanilla.Discussions.PerPage', 30);
43+
$session = Gdn::session();
44+
$wheres = ['d.InsertUserID' => $session->UserID];
45+
$this->DraftData = $this->DraftModel->getByUser($session->UserID, $offset, $limit);
46+
$countDrafts = $this->DraftModel->getCountByUser($session->UserID);
47+
48+
// Build a pager
49+
$pagerFactory = new Gdn_PagerFactory();
50+
$this->Pager = $pagerFactory->getPager('MorePager', $this);
51+
$this->Pager->MoreCode = 'More drafts';
52+
$this->Pager->LessCode = 'Newer drafts';
53+
$this->Pager->ClientID = 'Pager';
54+
$this->Pager->configure(
55+
$offset,
56+
$limit,
57+
$countDrafts,
58+
'drafts/%1$s'
59+
);
60+
61+
// Deliver JSON data if necessary
62+
if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
63+
$this->setJson('LessRow', $this->Pager->toString('less'));
64+
$this->setJson('MoreRow', $this->Pager->toString('more'));
65+
$this->View = 'drafts';
66+
}
67+
68+
// Add modules
69+
$this->addModule('DiscussionFilterModule');
70+
//$this->addModule('NewDiscussionModule');
71+
//$this->addModule('CategoriesModule');
72+
$this->addModule('BookmarkedModule');
73+
74+
// Render default view (drafts/index.php)
75+
$this->render();
76+
}
77+
78+
/**
79+
* Delete a single draft.
80+
*
81+
* Redirects user back to Index unless DeliveryType is set.
82+
*
83+
* @since 2.0.0
84+
* @access public
85+
*
86+
* @param int $draftID Unique ID of draft to be deleted.
87+
* @param string $transientKey Single-use hash to prove intent.
88+
*/
89+
public function delete($draftID = '', $transientKey = '') {
90+
$form = Gdn::factory('Form');
91+
$session = Gdn::session();
92+
if (is_numeric($draftID) && $draftID > 0) {
93+
$draft = $this->DraftModel->getID($draftID);
94+
}
95+
if ($draft) {
96+
if ($session->validateTransientKey($transientKey)
97+
&& ((val('InsertUserID', $draft) == $session->UserID) || checkPermission('Garden.Community.Manage'))
98+
) {
99+
// Delete the draft
100+
if (!$this->DraftModel->deleteID($draftID)) {
101+
$form->addError('Failed to delete draft');
102+
}
103+
} else {
104+
throw permissionException('Garden.Community.Manage');
105+
}
106+
} else {
107+
throw notFoundException('Draft');
108+
}
109+
110+
// Redirect
111+
if ($this->_DeliveryType === DELIVERY_TYPE_ALL) {
112+
$target = getIncomingValue('Target', '/drafts');
113+
redirectTo($target);
114+
}
115+
116+
// Return any errors
117+
if ($form->errorCount() > 0) {
118+
$this->setJson('ErrorMessage', $form->errors());
119+
}
120+
121+
// Render default view
122+
$this->render();
123+
}
124+
}

vanilla/applications/vanilla/controllers/class.postcontroller.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ public function discussion($categoryUrlCode = '') {
419419
'Url' => val('AddUrl', val($this->data('Type'), DiscussionModel::discussionTypes()), '/post/discussion')
420420
];
421421

422+
array_unshift ( $breadcrumbs , CategoriesController::ROOT_CATEGORY);
422423
$this->setData('Breadcrumbs', $breadcrumbs);
423424

424425
// FIX: Hide Announce options
@@ -1022,7 +1023,7 @@ public function initialize() {
10221023
// Add modules
10231024
$this->addModule('NewDiscussionModule');
10241025
$this->addModule('DiscussionFilterModule');
1025-
$this->addModule('CategoriesModule');
1026+
// $this->addModule('CategoriesModule');
10261027
$this->addModule('BookmarkedModule');
10271028

10281029
parent::initialize();

0 commit comments

Comments
 (0)