From e2988a025388c5ea023a9e3d42b7cc40fa93f780 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 27 Oct 2013 16:30:55 -0700 Subject: put comanche widgets in their own file. Added a category tagcloud widget - but the entries aren't going to link to anything until we have a webpage search ability. But this will be a way to exercise and test widget arguments. --- include/comanche.php | 7 +------ include/taxonomy.php | 10 ++++++---- include/widgets.php | 34 ++++++++++++++++++++++++++++++++++ version.inc | 2 +- 4 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 include/widgets.php diff --git a/include/comanche.php b/include/comanche.php index 4c6ea2f54..4b8a1d170 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -2,6 +2,7 @@ require_once('include/security.php'); require_once('include/menu.php'); +require_once('include/widgets.php'); // When editing a webpage - a dropdown is needed to select a page layout // On submit, the pdl_select value (which is the mid of an item with item_restrict = ITEM_PDL) is stored in @@ -171,9 +172,3 @@ function comanche_region(&$a,$s) { return $s; } - -function widget_profile($args) { - $a = get_app(); - $block = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false); - return profile_sidebar($a->profile, $block, true); -} diff --git a/include/taxonomy.php b/include/taxonomy.php index 85396a51d..5159dad02 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -96,13 +96,14 @@ function format_term_for_display($term) { // Tag cloud functions - need to be adpated to this database format -function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $type = TERM_HASHTAG) { +function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $type = TERM_HASHTAG) { $sql_options = ''; $count = intval($count); if($flags) $sql_options .= " and ((item_flags & " . intval($flags) . ") = " . intval($flags) . ") "; + if($authors) { if(! is_array($authors)) $authors = array($authors); @@ -113,12 +114,13 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $type = TERM_HAS // Fetch tags $r = q("select term, count(term) as total from term left join item on term.oid = item.id where term.uid = %d and term.type = %d - and otype = %d and item_restrict = 0 and item_private = 0 + and otype = %d and item_restrict = %d and item_private = 0 $sql_options group by term order by total desc %s", intval($uid), intval($type), intval(TERM_OBJ_POST), + intval($restrict), ((intval($count)) ? "limit $count" : '') ); @@ -199,10 +201,10 @@ function dir_tagadelic($count = 0) { } -function tagblock($link,$uid,$count = 0,$authors = '',$flags = 0,$type = TERM_HASHTAG) { +function tagblock($link,$uid,$count = 0,$authors = '',$flags = 0,$restrict = 0,$type = TERM_HASHTAG) { $o = ''; $tab = 0; - $r = tagadelic($uid,$count,$authors,$flags,$type); + $r = tagadelic($uid,$count,$authors,$flags,$restrict,$type); if($r) { $o = '

' . t('Tags') . '

'; diff --git a/include/widgets.php b/include/widgets.php new file mode 100644 index 000000000..87941f40f --- /dev/null +++ b/include/widgets.php @@ -0,0 +1,34 @@ +profile, $block, true); +} + +// FIXME The problem with the next widget is that we don't have a search function for webpages that we can send the links to. +// Then we should also provide an option to search webpages and conversations. + +function widget_tagcloud($args) { + + $o = ''; + $tab = 0; + $a = get_app(); + $uid = $a->profile_uid; + $count = ((x($args,'count')) ? intval($args['count']) : 24); + $flags = 0; + $type = TERM_CATEGORY; + + $r = tagadelic($uid,$count,$authors,$flags,ITEM_WEBPAGE,$type); + + if($r) { + $o = '

' . t('Categories') . '

'; + foreach($r as $rr) { + $o .= ''.$rr[0].' ' . "\r\n"; + } + $o .= '
'; + } + return $o; +} + diff --git a/version.inc b/version.inc index 8b7f5f86a..661d30ec4 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2013-10-26.478 +2013-10-27.479 -- cgit v1.2.3