@@ -305,7 +305,7 @@ function dateUpdated($row, $wrap = null) {
305
305
306
306
if ($ dateUpdated ) {
307
307
$ updateUser = Gdn::userModel ()->getID ($ updateUserID );
308
- $ dateUpdatedFormatted = Gdn:: getContainer ()-> get (DateTimeFormatter::class)-> formatDate ( $ dateUpdated , false , DateTimeFormatter:: FORCE_FULL_FORMAT );
308
+ $ dateUpdatedFormatted = formatDateCustom ( $ dateUpdated , false );
309
309
if ($ updateUser && $ insertUserID != $ updateUserID ) {
310
310
$ title = sprintf (t ('Edited %s by %s. ' ), $ dateUpdatedFormatted , val ('Name ' , $ updateUser ));
311
311
$ link = userAnchor ($ updateUser );
@@ -339,7 +339,6 @@ function watchIcon($hasWatched = false, $title='') {
339
339
if ($ hasWatched ) {
340
340
$ icon = <<<EOT
341
341
<svg width="21px" height="14px" viewBox="0 0 21 14" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
342
- <title> $ title</title>
343
342
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
344
343
<g id="02-Challenge-Forums" transform="translate(-1261.000000, -328.000000)" fill="#0AB88A" fill-rule="nonzero">
345
344
<path d="M1271.08333,328 C1266.5,328 1262.58583,330.850833 1261,334.875 C1262.58583,338.899167 1266.5,341.75 1271.08333,341.75 C1275.66667,341.75 1279.58083,338.899167 1281.16667,334.875 C1279.58083,330.850833 1275.66667,328 1271.08333,328 Z M1271.08333,339.458333 C1268.55333,339.458333 1266.5,337.405 1266.5,334.875 C1266.5,332.345 1268.55333,330.291667 1271.08333,330.291667 C1273.61333,330.291667 1275.66667,332.345 1275.66667,334.875 C1275.66667,337.405 1273.61333,339.458333 1271.08333,339.458333 Z M1271.08333,332.125 C1269.56167,332.125 1268.33333,333.353333 1268.33333,334.875 C1268.33333,336.396667 1269.56167,337.625 1271.08333,337.625 C1272.605,337.625 1273.83333,336.396667 1273.83333,334.875 C1273.83333,333.353333 1272.605,332.125 1271.08333,332.125 Z" id="Shape"></path>
@@ -350,7 +349,6 @@ function watchIcon($hasWatched = false, $title='') {
350
349
} else {
351
350
$ icon = <<<EOT
352
351
<svg width="22px" height="22px" viewBox="0 0 22 22" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
353
- <title> $ title</title>
354
352
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
355
353
<g id="02-Challenge-Forums" transform="translate(-1260.000000, -594.000000)">
356
354
<g id="watch-icon" transform="translate(1260.000000, 594.000000)">
@@ -375,7 +373,7 @@ function watchIcon($hasWatched = false, $title='') {
375
373
* @param int $categoryID
376
374
* @return string
377
375
*/
378
- function watchButton ($ category ) {
376
+ function watchButton ($ category, $ isHijackButton = true ) {
379
377
$ output = ' ' ;
380
378
$ userID = Gdn::session ()->UserID ;
381
379
if (is_numeric ($ category )) {
@@ -388,13 +386,17 @@ function watchButton($category) {
388
386
$ categoryID = val ('CategoryID ' , $ category );
389
387
$ hasWatched = $ categoryModel ->hasWatched ($ categoryID , $ userID );
390
388
391
- $ text = $ hasWatched ? t ('Stop watching the category ' ) : t ('Watch the category ' );
392
- $ icon = watchIcon ($ hasWatched , $ text );
393
- $ output .= anchor (
394
- $ icon ,
389
+ $ text = $ hasWatched ? t ('Stop watching forum ' ) : t ('Watch forum ' );
390
+ $ icon = '<span class="tooltiptext"> ' .$ text .'</span> ' . watchIcon ($ hasWatched );
391
+ $ cssClasses = 'watchButton ' . ($ hasWatched ? ' isWatching tooltip ' : 'tooltip ' );
392
+ if ($ isHijackButton ) {
393
+ $ cssClasses = 'Hijack ' .$ cssClasses ;
394
+ }
395
+
396
+ $ output .= anchor ($ icon ,
395
397
$ hasWatched ? "/category/watched/ {$ categoryID }/ " . Gdn::session ()->transientKey () : "/category/watch/ {$ categoryID }/ " . Gdn::session ()->transientKey (),
396
- ' Hijack watchButton ' . ( $ hasWatched ? ' isWatching ' : '' ) ,
397
- [' title ' => $ text , 'aria-pressed ' => $ hasWatched ? 'true ' : 'false ' , 'role ' => 'button ' , 'tabindex ' => '0 ' ]
398
+ $ cssClasses ,
399
+ [ 'aria-pressed ' => $ hasWatched ? 'true ' : 'false ' , 'role ' => 'button ' , 'tabindex ' => '0 ' ]
398
400
);
399
401
}
400
402
return $ output ;
@@ -460,9 +462,9 @@ function updateRolePermissions($roleType, $roles) {
460
462
* @param string $label Text for the label to attach to the cont
461
463
* @return string
462
464
*/
463
- function sortsDropDown ($ baseUrl , array $ filters = [], $ extraClasses = '' , $ default = null , $ defaultUrl = null , $ label = 'Sort ' ) {
465
+ function sortsDropDown ($ preferenceKey , $ baseUrl , array $ filters = [], $ extraClasses = '' , $ default = null , $ defaultUrl = null , $ label = 'Sort ' ) {
464
466
$ links = [];
465
- $ active = Gdn::session ()->getPreference (' CategorySort ' , null );
467
+ $ active = Gdn::session ()->getPreference ($ preferenceKey , null );
466
468
// Translate filters into links.
467
469
foreach ($ filters as $ filter ) {
468
470
// Make sure we have the bare minimum: a label and a URL parameter.
@@ -550,7 +552,7 @@ function categorySorts($extraClasses = '') {
550
552
$ defaultUrl = $ baseUrl ;
551
553
}
552
554
553
- return sortsDropDown (
555
+ return sortsDropDown (' CategorySort ' ,
554
556
$ baseUrl ,
555
557
$ filters ,
556
558
$ extraClasses ,
@@ -577,15 +579,22 @@ function discussionSorts($extraClasses = '') {
577
579
$ transientKey = Gdn::session ()->transientKey ();
578
580
$ filters = [
579
581
[
580
- 'name ' => t ('New ' ),
582
+ 'name ' => t ('Most recent ' ),
581
583
'param ' => 'sort ' ,
582
584
'value ' => 'new ' ,
583
585
'extra ' => ['TransientKey ' => $ transientKey , 'save ' => 1 ]
584
586
],
587
+
585
588
[
586
- 'name ' => t ('Old ' ),
589
+ 'name ' => t ('Highest views ' ),
587
590
'param ' => 'sort ' ,
588
- 'value ' => 'old ' ,
591
+ 'value ' => 'views ' ,
592
+ 'extra ' => ['TransientKey ' => $ transientKey , 'save ' => 1 ]
593
+ ],
594
+ [
595
+ 'name ' => t ('Highest responses ' ),
596
+ 'param ' => 'sort ' ,
597
+ 'value ' => 'comments ' ,
589
598
'extra ' => ['TransientKey ' => $ transientKey , 'save ' => 1 ]
590
599
]
591
600
];
@@ -598,7 +607,7 @@ function discussionSorts($extraClasses = '') {
598
607
$ defaultUrl = $ baseUrl ;
599
608
}
600
609
601
- return sortsDropDown (
610
+ return sortsDropDown (' DiscussionSort ' ,
602
611
$ baseUrl ,
603
612
$ filters ,
604
613
$ extraClasses ,
@@ -978,4 +987,19 @@ function discussionUrl($discussion, $page = '', $withDomain = true) {
978
987
979
988
return url ($ result , $ withDomain );
980
989
}
981
- }
990
+ }
991
+
992
+ if (!function_exists ('formatDateCustom ' )) {
993
+ function formatDateCustom ($ timestamp , $ showDayOfWeek =true ) {
994
+ $ dateFormat = $ showDayOfWeek ? '%a, %b %e, %Y ' : '%b %e, %Y ' ;
995
+ $ dateFormatted = Gdn::getContainer ()->get (DateTimeFormatter::class)->formatDate ($ timestamp , false , $ dateFormat );
996
+ $ timeFormatted = Gdn::getContainer ()->get (DateTimeFormatter::class)->formatDate ($ timestamp , false , '%I:%M %p ' );
997
+ return sprintf ('%1$s at %2$s ' , $ dateFormatted , $ timeFormatted );
998
+ }
999
+ }
1000
+ if (!function_exists ('authorProfileStats ' )) {
1001
+ function authorProfileStats ($ user ) {
1002
+ $ totalCount = ($ user ->CountDiscussions ?$ user ->CountDiscussions : 0 ) + ($ user ->CountComments ?$ user ->CountComments :0 );
1003
+ return '<span class="MItem AuthorProfileStats AuthorProfileStats_ ' .$ user ->UserID .'"> ' .sprintf ('%1s posts ' , $ totalCount ).'</span> ' ;
1004
+ }
1005
+ }
0 commit comments