From 8ffdc4859baa9f2ae9567a4c443dfbb227919167 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 5 May 2016 00:45:38 -0700 Subject: replace app tagcloud with more traditional categories widget. One can always change this in the PDL --- include/contact_widgets.php | 2 ++ include/widgets.php | 42 ++++++++++++++++++++++++++++++++++++++++++ view/pdl/mod_apps.pdl | 2 +- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/include/contact_widgets.php b/include/contact_widgets.php index ba1241fcb..e62d57aa2 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -79,12 +79,14 @@ function categories_widget($baseurl,$selected = '') { where item.uid = %d and term.uid = item.uid and term.type = %d + and term.otype = %d and item.owner_xchan = '%s' and item.item_wall = 1 $item_normal order by term.term asc", intval(App::$profile['profile_uid']), intval(TERM_CATEGORY), + intval(TERM_OBJ_POST), dbesc(App::$profile['channel_hash']) ); if($r && count($r)) { diff --git a/include/widgets.php b/include/widgets.php index 7384aa399..2641a718e 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -400,6 +400,48 @@ function widget_categories($arr) { } +function widget_appcategories($arr) { + + if(! local_channel()) + return ''; + + $cat = ((x($_REQUEST,'cat')) ? htmlspecialchars($_REQUEST['cat'],ENT_COMPAT,'UTF-8') : ''); + $srchurl = App::$query_string; + $srchurl = rtrim(preg_replace('/cat\=[^\&].*?(\&|$)/is','',$srchurl),'&'); + $srchurl = str_replace(array('?f=','&f='),array('',''),$srchurl); + + $terms = array(); + + $r = q("select distinct(term.term) + from term join app on term.oid = app.id + where app_channel = %d + and term.uid = app_channel + and term.otype = %d + order by term.term asc", + intval(local_channel()), + intval(TERM_OBJ_APP) + ); + if($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' => $srchurl, + + )); + } + + + +} + + + function widget_appcloud($arr) { if(! local_channel()) return ''; diff --git a/view/pdl/mod_apps.pdl b/view/pdl/mod_apps.pdl index 4cc036fa5..32fef28e9 100644 --- a/view/pdl/mod_apps.pdl +++ b/view/pdl/mod_apps.pdl @@ -1,4 +1,4 @@ [region=aside] [widget=appselect][/widget] -[widget=appcloud][/widget] +[widget=appcategories][/widget] [/region] -- cgit v1.2.3