Merge pull request #2114 from rabuzarus/28.11_forumlist

forumlist - mark selected forum as selected
This commit is contained in:
Tobias Diekershoff 2015-11-29 08:21:37 +01:00
commit 78858cb57d
10 changed files with 77 additions and 18 deletions

View File

@ -60,10 +60,12 @@ function get_forumlist($uid, $showhidden = true, $lastitem, $showprivate = false
* Sidebar widget to show subcribed friendica forums. If activated
* in the settings, it appears at the notwork page sidebar
*
* @param App $a
* @param int $uid
* @param int $cid
* The contact id which is used to mark a forum as "selected"
* @return string
*/
function widget_forumlist($a) {
function widget_forumlist($uid,$cid = 0) {
if(! intval(feature_enabled(local_user(),'forumlist_widget')))
return;
@ -73,7 +75,7 @@ function widget_forumlist($a) {
//sort by last updated item
$lastitem = true;
$contacts = get_forumlist($a->user['uid'],true,$lastitem, true);
$contacts = get_forumlist($uid,true,$lastitem, true);
$total = count($contacts);
$visible_forums = 10;
@ -83,11 +85,14 @@ function widget_forumlist($a) {
foreach($contacts as $contact) {
$selected = (($cid == $contact['id']) ? ' forum-selected' : '');
$entry = array(
'url' => $a->get_baseurl() . '/network?f=&cid=' . $contact['id'],
'external_url' => $a->get_baseurl() . '/redir/' . $contact['id'],
'url' => z_root() . '/network?f=&cid=' . $contact['id'],
'external_url' => z_root() . '/redir/' . $contact['id'],
'name' => $contact['name'],
'cid' => $contact['id'],
'selected' => $selected,
'micro' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
'id' => ++$id,
);

View File

@ -6,6 +6,8 @@ function network_init(&$a) {
}
$is_a_date_query = false;
if(x($_GET['cid']) && intval($_GET['cid']) != 0)
$cid = $_GET['cid'];
if($a->argc > 1) {
for($x = 1; $x < $a->argc; $x ++) {
@ -146,7 +148,7 @@ function network_init(&$a) {
}
$a->page['aside'] .= (feature_enabled(local_user(),'groups') ? group_side('network/0','network','standard',$group_id) : '');
$a->page['aside'] .= (feature_enabled(local_user(),'forumlist_widget') ? widget_forumlist($a) : '');
$a->page['aside'] .= (feature_enabled(local_user(),'forumlist_widget') ? widget_forumlist(local_user(),$cid) : '');
$a->page['aside'] .= posted_date_widget($a->get_baseurl() . '/network',local_user(),false);
$a->page['aside'] .= networks_widget($a->get_baseurl(true) . '/network',(x($_GET, 'nets') ? $_GET['nets'] : ''));
$a->page['aside'] .= saved_searches($search);

View File

@ -24,7 +24,7 @@ function showHideForumlist() {
<a href="{{$forum.external_url}}" title="{{$forum.link_desc}}" class="label sparkle" target="_blank">
<img class="forumlist-img" src="{{$forum.micro}}" alt="{{$forum.link_desc}}" />
</a>
<a class="forum-widget-link" id="forum-widget-link-{{$forum.id}}" href="{{$forum.url}}" >{{$forum.name}}</a>
<a class="forum-widget-link {{if $forum.selected}}forum-selected{{/if}}" id="forum-widget-link-{{$forum.id}}" href="{{$forum.url}}" >{{$forum.name}}</a>
</li>
{{/if}}
@ -34,7 +34,7 @@ function showHideForumlist() {
<a href="{{$forum.external_url}}" title="{{$forum.link_desc}}" class="label sparkle" target="_blank">
<img class="forumlist-img" src="{{$forum.micro}}" alt="{{$forum.link_desc}}" />
</a>
<a class="forum-widget-link" id="forum-widget-link-{{$forum.id}}" href="{{$forum.url}}" >{{$forum.name}}</a>
<a class="forum-widget-link {{if $forum.selected}}forum-selected{{/if}}" id="forum-widget-link-{{$forum.id}}" href="{{$forum.url}}" >{{$forum.name}}</a>
</li>
{{/if}}
{{/foreach}}

View File

@ -340,7 +340,7 @@ div.wall-item-content-wrapper.shiny {
margin-bottom: 10px;
}
.group-selected, .nets-selected, .fileas-selected, .categories-selected {
.group-selected, .nets-selected, .fileas-selected, .categories-selected, .forum-selected {
padding: 3px;
-moz-border-radius: 3px;
border-radius: 3px;

View File

@ -511,7 +511,7 @@ footer {
margin-bottom: 10px;
}
.group-selected, .nets-selected, .fileas-selected, .categories-selected {
.group-selected, .nets-selected, .fileas-selected, .categories-selected, .forum-selected {
padding: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;

View File

@ -489,7 +489,7 @@ div.wall-item-content-wrapper.shiny {
margin-bottom: 10px;
}
.group-selected, .nets-selected, .fileas-selected, .categories-selected {
.group-selected, .nets-selected, .fileas-selected, .categories-selected, .forum-selected {
padding: 3px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;

View File

@ -0,0 +1,46 @@
<script>
function showHideForumlist() {
if( $("li[id^='forum-widget-entry-extended-']").is(':visible')) {
$("li[id^='forum-widget-entry-extended-']").hide();
$("li#forum-widget-collapse").html(window.showMore);
}
else {
$("li[id^='forum-widget-entry-extended-']").show();
$("li#forum-widget-collapse").html(window.showFewer);
}
}
</script>
<div id="forumlist-sidebar" class="widget">
<h3 id="forumlist">{{$title}}</h3>
<ul id="forumlist-sidbar-ul" role="menu">
{{foreach $forums as $forum}}
{{if $forum.id <= $visible_forums}}
<li class="forum-widget-entry forum-{{$forum.cid}} tool {{if $forum.selected}}selected{{/if}}" id="forum-widget-entry-{{$forum.id}}" role="menuitem">
<span class="notify badge pull-right"></span>
<a href="{{$forum.external_url}}" title="{{$forum.link_desc}}" class="label sparkle" target="_blank">
<img class="forumlist-img" src="{{$forum.micro}}" alt="{{$forum.link_desc}}" />
</a>
<a class="forum-widget-link" id="forum-widget-link-{{$forum.id}}" href="{{$forum.url}}" >{{$forum.name}}</a>
</li>
{{/if}}
{{if $forum.id > $visible_forums}}
<li class="forum-widget-entry forum-{{$forum.cid}} tool {{if $forum.selected}}selected{{/if}}" id="forum-widget-entry-extended-{{$forum.id}}" role="menuitem" style="display: none;">
<span class="notify badge pull-right"></span>
<a href="{{$forum.external_url}}" title="{{$forum.link_desc}}" class="label sparkle" target="_blank">
<img class="forumlist-img" src="{{$forum.micro}}" alt="{{$forum.link_desc}}" />
</a>
<a class="forum-widget-link" id="forum-widget-link-{{$forum.id}}" href="{{$forum.url}}" >{{$forum.name}}</a>
</li>
{{/if}}
{{/foreach}}
{{if $total > $visible_forums }}
<li onclick="showHideForumlist(); return false;" id="forum-widget-collapse" class="forum-widget-link fakelink tool">{{$showmore}}</li>
{{/if}}
</ul>
</div>

View File

@ -435,7 +435,7 @@ code {
/* color: #000; */
}
.group-selected, .nets-selected, .fileas-selected {
.group-selected, .nets-selected, .fileas-selected, .forum-selected {
font-weight: bold;
}

View File

@ -20,21 +20,21 @@ function showHideForumlist() {
{{foreach $forums as $forum}}
{{if $forum.id <= $visible_forums}}
<li class="forum-widget-entry forum-{{$forum.cid}}" id="forum-widget-entry-{{$forum.id}}" role="menuitem">
<span class="notify badge pull-right"></span>
<a href="{{$forum.external_url}}" title="{{$forum.link_desc}}" class="label sparkle" target="_blank">
<img class="forumlist-img" src="{{$forum.micro}}" alt="{{$forum.link_desc}}" />
</a>
<a class="forum-widget-link" id="forum-widget-link-{{$forum.id}}" href="{{$forum.url}}" >{{$forum.name}}</a>
<span class="notify badge pull-right"></span>
<a class="forum-widget-link {{if $forum.selected}}forum-selected{{/if}}" id="forum-widget-link-{{$forum.id}}" href="{{$forum.url}}" >{{$forum.name}}</a>
</li>
{{/if}}
{{if $forum.id > $visible_forums}}
<li class="forum-widget-entry forum-{{$forum.cid}}" id="forum-widget-entry-extended-{{$forum.id}}" role="menuitem" style="display: none;">
<span class="notify padge pull-right"></span>
<a href="{{$forum.external_url}}" title="{{$forum.link_desc}}" class="label sparkle" target="_blank">
<img class="forumlist-img" src="{{$forum.micro}}" alt="{{$forum.link_desc}}" />
</a>
<a class="forum-widget-link" id="forum-widget-link-{{$forum.id}}" href="{{$forum.url}}" >{{$forum.name}}</a>
<span class="notify padge pull-right"></span>
<a class="forum-widget-link {{if $forum.selected}}forum-selected{{/if}}" id="forum-widget-link-{{$forum.id}}" href="{{$forum.url}}" >{{$forum.name}}</a>
</li>
{{/if}}
{{/foreach}}

View File

@ -222,6 +222,9 @@ function vier_community_info() {
require_once('include/forums.php');
if(x($_GET['cid']) && intval($_GET['cid']) != 0)
$cid = $_GET['cid'];
//sort by last updated item
$lastitem = true;
@ -235,11 +238,14 @@ function vier_community_info() {
foreach($contacts as $contact) {
$selected = (($cid == $contact['id']) ? ' forum-selected' : '');
$entry = array(
'url' => $a->get_baseurl() . '/network?f=&cid=' . $contact['id'],
'external_url' => $a->get_baseurl() . '/redir/' . $contact['id'],
'url' => z_root() . '/network?f=&cid=' . $contact['id'],
'external_url' => z_root() . '/redir/' . $contact['id'],
'name' => $contact['name'],
'cid' => $contact['id'],
'selected' => $selected,
'micro' => proxy_url($contact['micro'], false, PROXY_SIZE_MICRO),
'id' => ++$id,
);