Commit 0456f96d authored by Mario's avatar Mario
Browse files

add filecategories widget and use bootstrap-tagsinput for file categories

parent dc27140a
Pipeline #369561 passed with stage
in 2 minutes and 59 seconds
......@@ -84,7 +84,7 @@ class Browser extends DAV\Browser\Plugin {
// (owner_id = channel_id) is visitor owner of this directory?
$is_owner = ((local_channel() && $this->auth->owner_id == local_channel()) ? true : false);
$cat = $_REQUEST['cat'];
$cat = ((x($_REQUEST,'cat')) ? $cat : '');
if ($this->auth->getTimezone()) {
date_default_timezone_set($this->auth->getTimezone());
......@@ -223,7 +223,7 @@ class Browser extends DAV\Browser\Plugin {
$lockstate = (($data['allow_cid'] || $data['allow_gid'] || $data['deny_cid'] || $data['deny_gid']) ? 'lock' : 'unlock');
$id = $data['id'];
$terms = q("select * from term where oid = %d AND otype = %d",
$terms = q("select * from term where oid = %d AND otype = %d order by term",
intval($id),
intval(TERM_OBJ_FILE)
);
......
......@@ -21,7 +21,9 @@ class Categories {
if(($articles) && (! Apps::system_app_installed(App::$profile['profile_uid'],'Articles')))
return '';
if((! App::$profile['profile_uid'])
$files = ((array_key_exists('files',$arr) && $arr['files']) ? true : false);
if((! App::$profile['profile_uid'])
|| (! perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),(($cards || $articles) ? 'view_pages' : 'view_stream')))) {
return '';
}
......@@ -29,12 +31,14 @@ class Categories {
$cat = ((x($_REQUEST,'cat')) ? htmlspecialchars($_REQUEST['cat'],ENT_COMPAT,'UTF-8') : '');
$srchurl = (($cards) ? App::$argv[0] . '/' . App::$argv[1] : App::$query_string);
$srchurl = rtrim(preg_replace('/cat\=[^\&].*?(\&|$)/is','',$srchurl),'&');
$srchurl = str_replace(array('?f=','&f='),array('',''),$srchurl);
$srchurl = str_replace(array('?f=','&f=', '/?'),array('', '', ''),$srchurl);
if($cards)
return cardcategories_widget($srchurl, $cat);
elseif($articles)
return articlecategories_widget($srchurl, $cat);
elseif($files)
return filecategories_widget($srchurl, $cat);
else
return categories_widget($srchurl, $cat);
......
......@@ -93,7 +93,7 @@ function categories_widget($baseurl,$selected = '') {
dbesc(ACTIVITY_UPDATE)
);
}
else
else
$r = unserialize($content);
$terms = array();
......@@ -206,6 +206,41 @@ function articlecategories_widget($baseurl,$selected = '') {
return '';
}
function filecategories_widget($baseurl,$selected = '') {
hz_syslog(print_r('gothere',true));
$perms = permissions_sql(App::$profile['profile_uid']);
$terms = array();
$r = q("select distinct(term.term)
from term join attach on term.oid = attach.id
where attach.uid = %d
and term.uid = attach.uid
and term.ttype = %d
and term.otype = %d
$perms
order by term.term asc",
intval(App::$profile['profile_uid']),
intval(TERM_CATEGORY),
intval(TERM_OBJ_FILE)
);
hz_syslog(print_r($r,true));
if($r && count($r)) {
foreach($r as $rr)
$terms[] = array('name' => $rr['term'], 'selected' => (($selected == $rr['term']) ? 'selected' : ''));
return replace_macros(get_markup_template('categories_widget.tpl'),array(
'$title' => t('Categories'),
'$desc' => '',
'$sel_all' => (($selected == '') ? 'selected' : ''),
'$all' => t('Everything'),
'$terms' => $terms,
'$base' => $baseurl,
));
}
return '';
}
function common_friends_visitor_widget($profile_uid,$cnt = 25) {
......
......@@ -45,6 +45,10 @@ $(document).ready(function () {
$('.cloud-tool').hide();
$('.cloud-index').removeClass('cloud-index-active');
$('#id_categories_' + id).tagsinput({
tagClass: 'badge badge-pill badge-warning text-dark'
});
$('#cloud-tool-categories-' + id + ', #cloud-tool-submit-' + id).show();
$('#cloud-index-' + id).addClass('cloud-index-active');
});
......@@ -60,6 +64,8 @@ $(document).ready(function () {
$('.cloud-tool').hide();
$('#cloud-index-' + id).removeClass('cloud-index-active');
$('#attach_edit_form_' + id).trigger('reset');
$('#id_categories_' + id).tagsinput('destroy');
});
});
......
[region=aside]
[widget=vcard][/widget]
[widget=categories][var=files]1[/var][/widget]
[/region]
[region=right_aside]
[widget=notifications][/widget]
......
......@@ -365,7 +365,7 @@ footer {
bottom:1px;
text-align: right;
padding-bottom: 1em;
padding-right: 3em;
padding-right: 3em;
}
.birthday-today,
......@@ -484,7 +484,7 @@ footer {
.pager_next,
.pager-prev,
.pager-next,
.pager_n {
.pager_n {
border: 1px solid #ccc;
background: transparent;
padding: 4px;
......@@ -738,7 +738,7 @@ nav .acpopup {
height: auto; overflow: auto;
border-bottom: 2px solid #cccccc;
padding-bottom: 1em;
margin-bottom: 1em;
margin-bottom: 1em;
}
.oauthapp img {
float: left;
......@@ -1016,7 +1016,7 @@ th,td {
max-width: 19.4em;
overflow: hidden;
}
/* mail */
img.mail-conv-sender-photo {
......@@ -1560,12 +1560,12 @@ blockquote {
margin-top:-3px;
}
dl.bb-dl > dt {
dl.bb-dl > dt {
/* overriding the default dl style from bootstrap, as bootstrap's
style of a bold unindented line followed by a plain unindented
line is already acheivable in bbcode without dl */
font-weight: normal;
}
font-weight: normal;
}
dl.dl-terms-monospace > dt { font-family: monospace; }
dl.dl-terms-bold > dt { font-weight: bold; }
dl.dl-terms-italic > dt { font-style: italic; }
......@@ -1576,7 +1576,7 @@ dl.bb-dl:not(.dl-horizontal) > dd {
margin-left: 2em;
}
dl.bb-dl > dd > li {
/* adding some indent so bullet-list items will line up better with
/* adding some indent so bullet-list items will line up better with
dl descriptions if someone wants to be impure and combine them */
margin-left: 1em;
}
......@@ -1815,3 +1815,7 @@ dl.bb-dl > dd > li {
span.default-highlight {
background-color: yellow;
}
.bootstrap-tagsinput {
width: 100%;
}
<div id="categories-sidebar" class="widget">
<h3>{{$title}}</h3>
<div id="categories-sidebar-desc">{{$desc}}</div>
<ul class="nav nav-pills flex-column">
<li class="nav-item"><a href="{{$base}}" class="nav-link{{if $sel_all}} active{{/if}}">{{$all}}</a></li>
{{foreach $terms as $term}}
<li class="nav-item"><a href="{{$base}}?f=&cat={{$term.name|urlencode}}" class="nav-link{{if $term.selected}} active{{/if}}">{{$term.name}}</a></li>
<li class="nav-item"><a href="{{$base}}/?cat={{$term.name|urlencode}}" class="nav-link{{if $term.selected}} active{{/if}}">{{$term.name}}</a></li>
{{/foreach}}
</ul>
</div>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment