* 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;
//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;
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,
);
}
$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 ++) {
}
$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);
<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}}
<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}}
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;
margin-bottom: 10px;\r
}\r
\r
-.group-selected, .nets-selected, .fileas-selected, .categories-selected {\r
+.group-selected, .nets-selected, .fileas-selected, .categories-selected, .forum-selected {\r
padding: 3px;\r
-moz-border-radius: 3px;\r
-webkit-border-radius: 3px;\r
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;
--- /dev/null
+<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>
/* color: #000; */
}
-.group-selected, .nets-selected, .fileas-selected {
+.group-selected, .nets-selected, .fileas-selected, .forum-selected {
font-weight: bold;
}
{{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}}
require_once('include/forums.php');
+ if(x($_GET['cid']) && intval($_GET['cid']) != 0)
+ $cid = $_GET['cid'];
+
//sort by last updated item
$lastitem = true;
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,
);