mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-09 18:08:49 +00:00
Fix widgets crosssite ajax, make like widget works
This commit is contained in:
parent
056921b1e8
commit
255685c176
5 changed files with 68 additions and 20 deletions
|
@ -14,9 +14,49 @@ function like_widget_args(){
|
|||
function like_widget_content(&$a, $conf){
|
||||
$args = explode(",",$_GET['a']);
|
||||
|
||||
if ($args[0]!=""){
|
||||
return " #TODO like/dislike count for item with <em>" .$args[0]. "</em> # ";
|
||||
} else {
|
||||
return " #TODO# ";
|
||||
}
|
||||
|
||||
$baseq="SELECT COUNT(`item`.`id`) as `c`, `p`.`id`
|
||||
FROM `item`,
|
||||
(SELECT `i`.`id` FROM `item` as `i` WHERE
|
||||
`i`.`visible` = 1 AND `i`.`deleted` = 0
|
||||
AND (( `i`.`wall` = 1 AND `i`.`allow_cid` = ''
|
||||
AND `i`.`allow_gid` = ''
|
||||
AND `i`.`deny_cid` = ''
|
||||
AND `i`.`deny_gid` = '' )
|
||||
OR `i`.`uid` = %d )
|
||||
AND `i`.`body` LIKE '%%%s%%' LIMIT 1) as `p`
|
||||
WHERE `item`.`parent` = `p`.`id` ";
|
||||
|
||||
// count likes
|
||||
$r = q( $baseq . "AND `item`.`verb` = 'http://activitystrea.ms/schema/1.0/like'",
|
||||
intval($conf['uid']),
|
||||
dbesc($args[0])
|
||||
);
|
||||
$likes = $r[0]['c'];
|
||||
$iid = $r[0]['id'];
|
||||
|
||||
// count dislikes
|
||||
$r = q( $baseq . "AND `item`.`verb` = 'http://purl.org/macgirvin/dfrn/1.0/dislike'",
|
||||
intval($conf['uid']),
|
||||
dbesc($args[0])
|
||||
);
|
||||
$dislikes = $r[0]['c'];
|
||||
|
||||
|
||||
require_once("include/conversation.php");
|
||||
|
||||
$o = "";
|
||||
|
||||
$t = file_get_contents( dirname(__file__). "/widget_like.tpl" );
|
||||
$o .= replace_macros($t, array(
|
||||
'$like' => $likes,
|
||||
'$strlike' => sprintf( tt("%d person likes this", "%d people like this", $likes), $likes),
|
||||
|
||||
'$dislike' => $dislikes,
|
||||
'$strdislike'=> sprintf( tt("%d person doesn't like this", "%d people don't like this", $dislikes), $dislikes),
|
||||
|
||||
'$baseurl' => $a->get_baseurl(),
|
||||
));
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue