3 use Friendica\Core\L10n;
4 use Friendica\Core\Renderer;
5 use Friendica\Database\DBA;
7 function like_widget_name() {
10 function like_widget_help() {
11 return "Search first item which contains <em>KEY</em> and print like/dislike count";
14 function like_widget_args(){
18 function like_widget_size(){
19 return ['60px','20px'];
23 function like_widget_content(&$a, $conf){
24 $args = explode(",",$_GET['a']);
27 $baseq="SELECT COUNT(`item`.`id`) as `c`, `p`.`id`
29 (SELECT `i`.`id` FROM `item` as `i` WHERE
30 `i`.`visible` = 1 AND `i`.`deleted` = 0
31 AND (( `i`.`wall` = 1 AND `i`.`allow_cid` = ''
32 AND `i`.`allow_gid` = ''
33 AND `i`.`deny_cid` = ''
34 AND `i`.`deny_gid` = '' )
36 AND `i`.`body` LIKE '%%%s%%' LIMIT 1) as `p`
37 WHERE `item`.`parent` = `p`.`id` ";
40 $r = q( $baseq . "AND `item`.`verb` = 'http://activitystrea.ms/schema/1.0/like'",
48 $r = q( $baseq . "AND `item`.`verb` = 'http://purl.org/macgirvin/dfrn/1.0/dislike'",
52 $dislikes = $r[0]['c'];
57 # $t = file_get_contents( dirname(__file__). "/widget_like.tpl" );
58 $t = Renderer::getMarkupTemplate("widget_like.tpl", "addon/widgets/");
59 $o .= Renderer::replaceMacros($t, [
61 '$strlike' => L10n::tt("%d person likes this", "%d people like this", $likes),
63 '$dislike' => $dislikes,
64 '$strdislike'=> L10n::tt("%d person doesn't like this", "%d people don't like this", $dislikes),