@@ -305,7 +305,7 @@ function dateUpdated($row, $wrap = null) {
305305
306306 if ($ dateUpdated ) {
307307 $ updateUser = Gdn::userModel ()->getID ($ updateUserID );
308- $ dateUpdatedFormatted = Gdn:: getContainer ()-> get (DateTimeFormatter::class)-> formatDate ( $ dateUpdated , false , DateTimeFormatter:: FORCE_FULL_FORMAT );
308+ $ dateUpdatedFormatted = formatDateCustom ( $ dateUpdated , false );
309309 if ($ updateUser && $ insertUserID != $ updateUserID ) {
310310 $ title = sprintf (t ('Edited %s by %s. ' ), $ dateUpdatedFormatted , val ('Name ' , $ updateUser ));
311311 $ link = userAnchor ($ updateUser );
@@ -339,7 +339,6 @@ function watchIcon($hasWatched = false, $title='') {
339339 if ($ hasWatched ) {
340340 $ icon = <<<EOT
341341<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>
343342 <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
344343 <g id="02-Challenge-Forums" transform="translate(-1261.000000, -328.000000)" fill="#0AB88A" fill-rule="nonzero">
345344 <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='') {
350349 } else {
351350 $ icon = <<<EOT
352351 <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>
354352 <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
355353 <g id="02-Challenge-Forums" transform="translate(-1260.000000, -594.000000)">
356354 <g id="watch-icon" transform="translate(1260.000000, 594.000000)">
@@ -375,7 +373,7 @@ function watchIcon($hasWatched = false, $title='') {
375373 * @param int $categoryID
376374 * @return string
377375 */
378- function watchButton ($ category ) {
376+ function watchButton ($ category, $ isHijackButton = true ) {
379377 $ output = ' ' ;
380378 $ userID = Gdn::session ()->UserID ;
381379 if (is_numeric ($ category )) {
@@ -388,13 +386,17 @@ function watchButton($category) {
388386 $ categoryID = val ('CategoryID ' , $ category );
389387 $ hasWatched = $ categoryModel ->hasWatched ($ categoryID , $ userID );
390388
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 ,
395397 $ 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 ' ]
398400 );
399401 }
400402 return $ output ;
@@ -460,9 +462,9 @@ function updateRolePermissions($roleType, $roles) {
460462 * @param string $label Text for the label to attach to the cont
461463 * @return string
462464 */
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 ' ) {
464466 $ links = [];
465- $ active = Gdn::session ()->getPreference (' CategorySort ' , null );
467+ $ active = Gdn::session ()->getPreference ($ preferenceKey , null );
466468 // Translate filters into links.
467469 foreach ($ filters as $ filter ) {
468470 // Make sure we have the bare minimum: a label and a URL parameter.
@@ -550,7 +552,7 @@ function categorySorts($extraClasses = '') {
550552 $ defaultUrl = $ baseUrl ;
551553 }
552554
553- return sortsDropDown (
555+ return sortsDropDown (' CategorySort ' ,
554556 $ baseUrl ,
555557 $ filters ,
556558 $ extraClasses ,
@@ -577,15 +579,22 @@ function discussionSorts($extraClasses = '') {
577579 $ transientKey = Gdn::session ()->transientKey ();
578580 $ filters = [
579581 [
580- 'name ' => t ('New ' ),
582+ 'name ' => t ('Most recent ' ),
581583 'param ' => 'sort ' ,
582584 'value ' => 'new ' ,
583585 'extra ' => ['TransientKey ' => $ transientKey , 'save ' => 1 ]
584586 ],
587+
585588 [
586- 'name ' => t ('Old ' ),
589+ 'name ' => t ('Highest views ' ),
587590 '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 ' ,
589598 'extra ' => ['TransientKey ' => $ transientKey , 'save ' => 1 ]
590599 ]
591600 ];
@@ -598,7 +607,7 @@ function discussionSorts($extraClasses = '') {
598607 $ defaultUrl = $ baseUrl ;
599608 }
600609
601- return sortsDropDown (
610+ return sortsDropDown (' DiscussionSort ' ,
602611 $ baseUrl ,
603612 $ filters ,
604613 $ extraClasses ,
@@ -978,4 +987,19 @@ function discussionUrl($discussion, $page = '', $withDomain = true) {
978987
979988 return url ($ result , $ withDomain );
980989 }
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