-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(discussions): More compact listing of lastest discussions
Removes several features to make the listing cleaner/more compact: * All the actions/controls (like, mark-as-spam, remove-ad, etc.) * The preview text (people need to write better titles anyways) * Which group it was posted in (usually don't care) Refs #18
- Loading branch information
Showing
3 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
.actions { | ||
align-items: center; | ||
display: flex; | ||
flex-direction: row; | ||
white-space: nowrap; | ||
} | ||
|
||
.header { | ||
display: flex; | ||
flex-direction: row; | ||
padding: 0 12px; | ||
} | ||
|
||
.listItem { | ||
align-items: center; | ||
display: flex; | ||
flex-direction: row; | ||
padding-left: 12px; | ||
} | ||
|
||
.listItem:not(:last-child) { | ||
border-bottom: 1px solid #ccc; | ||
} | ||
|
||
.listItem--unread { | ||
font-weight: bold; | ||
} | ||
|
||
.listItem-author { | ||
display: block; | ||
|
||
/* If we don't set this explicit, the div grows to be 46px???? */ | ||
height: 40px; | ||
} | ||
|
||
.listItem-body { | ||
flex: 100%; | ||
|
||
} | ||
|
||
.listItem-metadata { | ||
padding: 0 12px 8px; | ||
} | ||
|
||
.listItem-title { | ||
display: block; | ||
font-size: larger; | ||
padding: 8px 12px; | ||
} | ||
|
||
.pagination { | ||
display: flex; | ||
padding: 8px 12px; | ||
} | ||
|
||
.pagination > * { | ||
flex: 1; | ||
text-align: center; | ||
} | ||
|
||
.title { | ||
flex: 100%; | ||
padding: .5em 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?php | ||
|
||
$offset = get_input('offset', 0); | ||
$limit = max(50, elgg_get_config('default_limit')); | ||
|
||
$recentlyActive = elgg_get_entities([ | ||
'type' => 'object', | ||
'subtype' => 'discussion', | ||
'order_by' => 'e.last_action desc', | ||
'limit' => $limit, | ||
'offset' => $offset, | ||
'preload_owners' => true, | ||
'preload_containers' => true, | ||
]); | ||
|
||
$discussions = (object)[ | ||
'length' => elgg_get_entities([ | ||
'type' => 'object', | ||
'subtype' => 'discussion', | ||
'count' => true, | ||
]), | ||
'fields' => (object)[ | ||
'title' => (object)['label' => 'Title'], | ||
'replies_length' => (object)['label' => 'Replies'], | ||
'last_action' => (object)['label' => 'Last activity'], | ||
], | ||
'recently_active' => (object)[ | ||
'label' => 'Latest discussion', | ||
'next' => 'Older »', | ||
'prev' => '« Newer', | ||
'actions' => [ | ||
(object)[ | ||
'icon' => (object)[ | ||
'16x16' => '', | ||
], | ||
'label' => 'Start new discussion', | ||
'href' => elgg_get_site_url() . 'discussion/new', | ||
], | ||
], | ||
'items' => array_map(function($discussion) { | ||
$owner = $discussion->getOwnerEntity(); | ||
|
||
return (object)[ | ||
'author' => (object)[ | ||
'name' => $owner->name, | ||
'url' => $owner->getUrl(), | ||
'avatar' => (object)[ | ||
'preview' => (new ElggUser())->getIconUrl('small'), | ||
'40x40' => $owner->getIconUrl('small'), | ||
'100x100' => $owner->getIconUrl('medium'), | ||
], | ||
], | ||
'is_unread' => false, | ||
'last_action' => $discussion->last_action, | ||
'title' => $discussion->title, | ||
'url' => $discussion->getUrl(), | ||
'replies_length' => elgg_get_entities(array( | ||
'type' => 'object', | ||
'subtype' => 'discussion_reply', | ||
'container_guid' => $discussion->getGUID(), | ||
'count' => true, | ||
'distinct' => false, | ||
)), | ||
]; | ||
}, $recentlyActive), | ||
], | ||
]; | ||
|
||
|
||
elgg_register_css('resources/discussion/index', elgg_get_simplecache_url('resources/discussion/index.css')); | ||
elgg_load_css('resources/discussion/index'); | ||
?> | ||
|
||
<?php ob_start(); ?> | ||
<main> | ||
<header class="header"> | ||
<h1 class="title"> | ||
<?=$discussions->recently_active->label; ?> | ||
</h1> | ||
<ul class="actions"> | ||
<?php foreach ($discussions->recently_active->actions as $action): ?> | ||
<li> | ||
<a href="<?=$action->href?>" class="elgg-button elgg-button-special"> | ||
<?=$action->label;?> | ||
</a> | ||
</li> | ||
<?php endforeach; ?> | ||
</ul> | ||
</header> | ||
<ol class="list"> | ||
<?php foreach ($discussions->recently_active->items as $discussion): ?> | ||
<li class="listItem <?=$discussion->is_unread ? 'listItem--unread' : ''?>"> | ||
<div class="listItem-author"> | ||
<?php $avatar = $discussion->author->avatar; ?> | ||
<img src="<?=$avatar->preview?>" width="40" height="40" | ||
srcset="<?=$avatar->{'40x40'}?> 1x, <?=$avatar->{'100x100'}?> 2.5x" | ||
alt="<?=$discussion->author->name?>"> | ||
</div> | ||
<div class="listItem-body"> | ||
<a class="listItem-title" | ||
href="<?=$discussion->url;?>"> | ||
<?=$discussion->title;?> | ||
</a> | ||
<div class="listItem-metadata"> | ||
<a href="<?=$discussion->author->url?>"> | ||
<?=$discussion->author->name?> | ||
</a> | ||
· | ||
<?=elgg_view('output/friendlytime', ['time' => $discussion->last_action]);?> | ||
· | ||
<?=$discussion->replies_length . ' ' . elgg_echo('discussion:replies')?> | ||
</div> | ||
</div> | ||
</li> | ||
<?php endforeach; ?> | ||
</ol> | ||
<nav class="pagination"> | ||
<?php if ($offset > 0): ?> | ||
<a href="?offset=<?=max(0, $offset - $limit)?>" rel="prev" | ||
class="elgg-button elgg-button-action"> | ||
<?=$discussions->recently_active->prev?> | ||
</a> | ||
<?php endif; ?> | ||
|
||
<?php if ($offset + $limit < $discussions->length): ?> | ||
<a href="?offset=<?=$limit+$offset?>" rel="next" | ||
class="elgg-button elgg-button-action"> | ||
<?=$discussions->recently_active->next?> | ||
</a> | ||
<?php endif; ?> | ||
</nav> | ||
</main> | ||
<?php $body = ob_get_clean(); ?> | ||
|
||
<?php | ||
|
||
echo elgg_view_page($title, $body); |