3 use Friendica\Core\L10n;
4 use Friendica\Database\DBA;
6 function like_widget_name() {
9 function like_widget_help() {
10 return "Search first item which contains <em>KEY</em> and print like/dislike count";
13 function like_widget_args(){
17 function like_widget_size(){
18 return ['60px','20px'];
22 function like_widget_content(&$a, $conf){
23 $args = explode(",",$_GET['a']);
26 $baseq="SELECT COUNT(`item`.`id`) as `c`, `p`.`id`
28 (SELECT `i`.`id` FROM `item` as `i` WHERE
29 `i`.`visible` = 1 AND `i`.`deleted` = 0
30 AND (( `i`.`wall` = 1 AND `i`.`allow_cid` = ''
31 AND `i`.`allow_gid` = ''
32 AND `i`.`deny_cid` = ''
33 AND `i`.`deny_gid` = '' )
35 AND `i`.`body` LIKE '%%%s%%' LIMIT 1) as `p`
36 WHERE `item`.`parent` = `p`.`id` ";
39 $r = q( $baseq . "AND `item`.`verb` = 'http://activitystrea.ms/schema/1.0/like'",
47 $r = q( $baseq . "AND `item`.`verb` = 'http://purl.org/macgirvin/dfrn/1.0/dislike'",
51 $dislikes = $r[0]['c'];
54 require_once("include/conversation.php");
58 # $t = file_get_contents( dirname(__file__). "/widget_like.tpl" );
59 $t = get_markup_template("widget_like.tpl", "addon/widgets/");
60 $o .= replace_macros($t, [
62 '$strlike' => L10n::tt("%d person likes this", "%d people like this", $likes),
64 '$dislike' => $dislikes,
65 '$strdislike'=> L10n::tt("%d person doesn't like this", "%d people don't like this", $dislikes),
67 '$baseurl' => $a->get_baseurl(),