show like/dislike when no comments yet, bit of lint

This commit is contained in:
Friendika 2010-11-03 19:47:07 -07:00
parent a90e5f438b
commit b3856a797b
4 changed files with 80 additions and 49 deletions

View File

@ -548,6 +548,8 @@ function item_store($arr) {
dbesc_array($arr); dbesc_array($arr);
logger('item_store: ' . print_r($arr,true), LOGGER_DATA);
$r = q("INSERT INTO `item` (`" $r = q("INSERT INTO `item` (`"
. implode("`, `", array_keys($arr)) . implode("`, `", array_keys($arr))
. "`) VALUES ('" . "`) VALUES ('"
@ -576,13 +578,17 @@ function item_store($arr) {
$arr['uri'], // already dbesc'd $arr['uri'], // already dbesc'd
intval($arr['uid']) intval($arr['uid'])
); );
if(count($r)) if(count($r)) {
$current_post = $r[0]['id']; $current_post = $r[0]['id'];
logger('item_store: created item ' . $current_post);
}
else else
return 0; return 0;
if($parent_missing) { if($parent_missing) {
logger('item_store: item parent was not found - ignoring item');
// perhaps the parent was deleted, but in any case, this thread is dead // perhaps the parent was deleted, but in any case, this thread is dead
// and unfortunately our brand new item now has to be destroyed // and unfortunately our brand new item now has to be destroyed

View File

@ -128,8 +128,13 @@ function display_content(&$a) {
} }
foreach($r as $item) { foreach($r as $item) {
$comment = '';
$template = $tpl; $template = $tpl;
$comment = '';
$owner_url = '';
$owner_photo = '';
$owner_name = '';
$redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
@ -215,8 +220,9 @@ function display_content(&$a) {
else else
$drop = replace_macros(load_view_file('view/wall_fake_drop.tpl'), array('$id' => $item['id'])); $drop = replace_macros(load_view_file('view/wall_fake_drop.tpl'), array('$id' => $item['id']));
$like = (($alike[$item['id']]) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : ''); $like = ((isset($alike[$item['id']])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
$dislike = (($dlike[$item['id']]) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : ''); $dislike = ((isset($dlike[$item['id']])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
$location = (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : ''); $location = (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
$coord = (($item['coord']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : ''); $coord = (($item['coord']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
if($coord) { if($coord) {

View File

@ -7,6 +7,8 @@ require_once('include/bbcode.php');
function photos_init(&$a) { function photos_init(&$a) {
$o = '';
if($a->argc > 1) { if($a->argc > 1) {
$nick = $a->argv[1]; $nick = $a->argv[1];
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1", $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
@ -36,6 +38,9 @@ function photos_init(&$a) {
} }
$o .= '</ul>'; $o .= '</ul>';
} }
if(! x($a->page,'aside'))
$a->page['aside'] = '';
$a->page['aside'] .= $o; $a->page['aside'] .= $o;
} }
return; return;
@ -213,23 +218,26 @@ function photos_post(&$a) {
$arr = array(); $arr = array();
$arr['uid'] = local_user(); $arr['uid'] = local_user();
$arr['uri'] = $uri; $arr['uri'] = $uri;
$arr['parent-uri'] = $uri; $arr['parent-uri'] = $uri;
$arr['type'] = 'photo'; $arr['type'] = 'photo';
$arr['wall'] = 1; $arr['wall'] = 1;
$arr['resource-id'] = $p[0]['resource-id']; $arr['resource-id'] = $p[0]['resource-id'];
$arr['contact-id'] = $contact_record['id']; $arr['contact-id'] = $contact_record['id'];
$arr['owner-name'] = $contact_record['name']; $arr['owner-name'] = $contact_record['name'];
$arr['owner-link'] = $contact_record['url']; $arr['owner-link'] = $contact_record['url'];
$arr['owner-avatar'] = $contact_record['thumb']; $arr['owner-avatar'] = $contact_record['thumb'];
$arr['title'] = $title; $arr['author-name'] = $contact_record['name'];
$arr['allow_cid'] = $p[0]['allow_cid']; $arr['author-link'] = $contact_record['url'];
$arr['allow_gid'] = $p[0]['allow_gid']; $arr['author-avatar'] = $contact_record['thumb'];
$arr['deny_cid'] = $p[0]['deny_cid']; $arr['title'] = $title;
$arr['deny_gid'] = $p[0]['deny_gid']; $arr['allow_cid'] = $p[0]['allow_cid'];
$arr['last-child'] = 1; $arr['allow_gid'] = $p[0]['allow_gid'];
$arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']' $arr['deny_cid'] = $p[0]['deny_cid'];
$arr['deny_gid'] = $p[0]['deny_gid'];
$arr['last-child'] = 1;
$arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $p[0]['resource-id'] . ']'
. '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]' . '[img]' . $a->get_baseurl() . '/photo/' . $p[0]['resource-id'] . '-' . $p[0]['scale'] . '.jpg' . '[/img]'
. '[/url]'; . '[/url]';
@ -391,7 +399,7 @@ function photos_post(&$a) {
if((! count($r)) || ($album == t('Profile Photos'))) if((! count($r)) || ($album == t('Profile Photos')))
$visible = 1; $visible = 1;
else else
$visibile = 0; $visible = 0;
$str_group_allow = perms2str($_POST['group_allow']); $str_group_allow = perms2str($_POST['group_allow']);
@ -448,24 +456,27 @@ function photos_post(&$a) {
$arr = array(); $arr = array();
$arr['uid'] = local_user(); $arr['uid'] = local_user();
$arr['uri'] = $uri; $arr['uri'] = $uri;
$arr['parent-uri'] = $uri; $arr['parent-uri'] = $uri;
$arr['type'] = 'photo'; $arr['type'] = 'photo';
$arr['wall'] = 1; $arr['wall'] = 1;
$arr['resource-id'] = $photo_hash; $arr['resource-id'] = $photo_hash;
$arr['contact-id'] = $contact_record['id']; $arr['contact-id'] = $contact_record['id'];
$arr['owner-name'] = $contact_record['name']; $arr['owner-name'] = $contact_record['name'];
$arr['owner-link'] = $contact_record['url']; $arr['owner-link'] = $contact_record['url'];
$arr['owner-avatar'] = $contact_record['thumb']; $arr['owner-avatar'] = $contact_record['thumb'];
$arr['title'] = $title; $arr['author-name'] = $contact_record['name'];
$arr['allow_cid'] = $str_contact_allow; $arr['author-link'] = $contact_record['url'];
$arr['allow_gid'] = $str_group_allow; $arr['author-avatar'] = $contact_record['thumb'];
$arr['deny_cid'] = $str_contact_deny; $arr['title'] = '';
$arr['deny_gid'] = $str_group_deny; $arr['allow_cid'] = $str_contact_allow;
$arr['last-child'] = 1; $arr['allow_gid'] = $str_group_allow;
$arr['visible'] = $visible; $arr['deny_cid'] = $str_contact_deny;
$arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $contact_record['nickname'] . '/image/' . $photo_hash . ']' $arr['deny_gid'] = $str_group_deny;
$arr['last-child'] = 1;
$arr['visible'] = $visible;
$arr['body'] = '[url=' . $a->get_baseurl() . '/photos/' . $contact_record['nickname'] . '/image/' . $photo_hash . ']'
. '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.jpg" . '[/img]' . '[img]' . $a->get_baseurl() . "/photo/{$photo_hash}-{$smallest}.jpg" . '[/img]'
. '[/url]'; . '[/url]';
@ -637,7 +648,7 @@ function photos_content(&$a) {
$a->set_pager_total(count($r)); $a->set_pager_total(count($r));
$r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s' $r = q("SELECT `resource-id`, `id`, `filename`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
$sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d", $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
intval($a->data['user']['uid']), intval($a->data['user']['uid']),
dbesc($album), dbesc($album),
@ -817,6 +828,17 @@ function photos_content(&$a) {
$like_tpl = load_view_file('view/like.tpl'); $like_tpl = load_view_file('view/like.tpl');
$likebuttons = '';
if(can_write_wall($a,$a->data['user']['uid']))
$likebuttons = replace_macros($like_tpl,array('$id' => $i1[0]['id']));
if(! count($r)) {
$o .= '<div id="photo-like-div">';
$o .= $likebuttons;
$o .= '</div>';
}
if(can_write_wall($a,$a->data['user']['uid'])) { if(can_write_wall($a,$a->data['user']['uid'])) {
if($i1[0]['last-child']) { if($i1[0]['last-child']) {
$o .= replace_macros($cmnt_tpl,array( $o .= replace_macros($cmnt_tpl,array(
@ -844,11 +866,6 @@ function photos_content(&$a) {
like_puller($a,$item,$dlike,'dislike'); like_puller($a,$item,$dlike,'dislike');
} }
$likebuttons = '';
if(can_write_wall($a,$a->data['user']['uid']))
$likebuttons = replace_macros($like_tpl,array('$id' => $i1[0]['id']));
$like = ((isset($alike[$i1[0]['id']])) ? format_like($alike[$i1[0]['id']],$alike[$i1[0]['id'] . '-l'],'like',$i1[0]['id']) : ''); $like = ((isset($alike[$i1[0]['id']])) ? format_like($alike[$i1[0]['id']],$alike[$i1[0]['id'] . '-l'],'like',$i1[0]['id']) : '');
$dislike = ((isset($dlike[$i1[0]['id']])) ? format_like($dlike[$i1[0]['id']],$dlike[$i1[0]['id'] . '-l'],'dislike',$i1[0]['id']) : ''); $dislike = ((isset($dlike[$i1[0]['id']])) ? format_like($dlike[$i1[0]['id']],$dlike[$i1[0]['id'] . '-l'],'dislike',$i1[0]['id']) : '');
@ -929,6 +946,7 @@ function photos_content(&$a) {
} }
// Default - show recent photos with upload link (if applicable) // Default - show recent photos with upload link (if applicable)
$o = '';
$r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' $r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s'
$sql_extra GROUP BY `resource-id`", $sql_extra GROUP BY `resource-id`",
@ -939,7 +957,8 @@ function photos_content(&$a) {
$a->set_pager_total(count($r)); $a->set_pager_total(count($r));
$r = q("SELECT `resource-id`, `album`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' $r = q("SELECT `resource-id`, `id`, `filename`, `album`, max(`scale`) AS `scale` FROM `photo`
WHERE `uid` = %d AND `album` != '%s'
$sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d", $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
intval($a->data['user']['uid']), intval($a->data['user']['uid']),
dbesc( t('Contact Photos')), dbesc( t('Contact Photos')),
@ -964,7 +983,7 @@ function photos_content(&$a) {
'$phototitle' => t('View Photo'), '$phototitle' => t('View Photo'),
'$imgsrc' => $a->get_baseurl() . '/photo/' '$imgsrc' => $a->get_baseurl() . '/photo/'
. $rr['resource-id'] . '-' . $rr['scale'] . '.jpg', . $rr['resource-id'] . '-' . $rr['scale'] . '.jpg',
'$albumlink' => $a->get_baseurl . '/photos/' '$albumlink' => $a->get_baseurl() . '/photos/'
. $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']), . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
'$albumname' => $rr['album'], '$albumname' => $rr['album'],
'$albumalt' => t('View Album'), '$albumalt' => t('View Album'),

View File

@ -87,7 +87,7 @@ function pubsub_post(&$a) {
$xml = file_get_contents('php://input'); $xml = file_get_contents('php://input');
logger('pubsub: feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $a->cmd ); logger('pubsub: feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $a->cmd );
logger('pubsub: data: ' . $xml, $LOGGER_DATA); logger('pubsub: data: ' . $xml, LOGGER_DATA);
$nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : ''); $nick = (($a->argc > 1) ? notags(trim($a->argv[1])) : '');
$contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0); $contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);