3 use Friendica\Core\L10n;
4 use Friendica\Core\Renderer;
5 use Friendica\Database\DBA;
8 function like_widget_name() {
11 function like_widget_help() {
12 return "Search first item which contains <em>KEY</em> and print like/dislike count";
15 function like_widget_args(){
19 function like_widget_size(){
20 return ['60px','20px'];
24 function like_widget_content(&$a, $conf){
25 $args = explode(",",$_GET['a']);
28 $baseq="SELECT COUNT(`post-view`.`id`) as `c`, `p`.`id`
30 (SELECT `i`.`id` FROM `post-view` as `i` WHERE
31 `i`.`visible` = 1 AND `i`.`deleted` = 0
32 AND (( `i`.`wall` = 1 AND `i`.`allow_cid` = ''
33 AND `i`.`allow_gid` = ''
34 AND `i`.`deny_cid` = ''
35 AND `i`.`deny_gid` = '' )
37 AND `i`.`body` LIKE '%%%s%%' LIMIT 1) as `p`
38 WHERE `post-view`.`parent` = `p`.`id` ";
41 $r = q( $baseq . "AND `post-view`.`verb` = 'http://activitystrea.ms/schema/1.0/like'",
49 if (!DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) {
51 $r = q( $baseq . "AND `post-view`.`verb` = 'http://purl.org/macgirvin/dfrn/1.0/dislike'",
55 $dislikes = $r[0]['c'];
56 $strdislike = DI::l10n()->tt("%d person doesn't like this", "%d people don't like this", $dislikes);
62 # $t = file_get_contents( dirname(__file__). "/widget_like.tpl" );
63 $t = Renderer::getMarkupTemplate("widget_like.tpl", "addon/widgets/");
64 $o .= Renderer::replaceMacros($t, [
66 '$strlike' => DI::l10n()->tt("%d person likes this", "%d people like this", $likes),
68 '$dislike' => $dislikes,
69 '$strdislike'=> $strdislike,