'
@@ -804,7 +956,7 @@ function photos_content(&$a) {
}
}
}
- $tpl = load_view_file('view/photo_album.tpl');
+ $tpl = get_markup_template('photo_album.tpl');
if(count($r))
foreach($r as $rr) {
$o .= replace_macros($tpl,array(
@@ -812,7 +964,8 @@ function photos_content(&$a) {
'$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
'$phototitle' => t('View Photo'),
'$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.jpg',
- '$imgalt' => $rr['filename']
+ '$imgalt' => template_escape($rr['filename']),
+ '$desc'=> template_escape($rr['desc'])
));
}
@@ -826,10 +979,9 @@ function photos_content(&$a) {
if($datatype === 'image') {
- require_once('security.php');
- require_once('bbcode.php');
- $o = '' . "\r\n";
+
+ //$o = '';
// fetch image, item containing image, then comments
$ph = q("SELECT * FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
@@ -839,10 +991,45 @@ function photos_content(&$a) {
);
if(! count($ph)) {
- notice( t('Photo not available') . EOL );
+ $ph = q("SELECT `id` FROM `photo` WHERE `uid` = %d AND `resource-id` = '%s'
+ LIMIT 1",
+ intval($owner_uid),
+ dbesc($datum)
+ );
+ if(count($ph))
+ notice( t('Permission denied. Access to this item may be restricted.'));
+ else
+ notice( t('Photo not available') . EOL );
return;
}
+ $prevlink = '';
+ $nextlink = '';
+
+ $prvnxt = q("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
+ $sql_extra ORDER BY `created` DESC ",
+ dbesc($ph[0]['album']),
+ intval($owner_uid)
+ );
+
+ if(count($prvnxt)) {
+ for($z = 0; $z < count($prvnxt); $z++) {
+ if($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
+ $prv = $z - 1;
+ $nxt = $z + 1;
+ if($prv < 0)
+ $prv = count($prvnxt) - 1;
+ if($nxt >= count($prvnxt))
+ $nxt = 0;
+ break;
+ }
+ }
+ $edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : '');
+ $prevlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix;
+ $nextlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix;
+ }
+
+
if(count($ph) == 1)
$hires = $lores = $ph[0];
if(count($ph) > 1) {
@@ -856,18 +1043,36 @@ function photos_content(&$a) {
}
}
-
- $o .= '';
+ $album_link = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($ph[0]['album']);
+ $tools = Null;
+ $lock = Null;
if($can_post && ($ph[0]['uid'] == $owner_uid)) {
- $o .= '';
+ $tools = array(
+ 'edit' => array($a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $datum . (($cmd === 'edit') ? '' : '/edit'), (($cmd === 'edit') ? t('View photo') : t('Edit photo'))),
+ 'profile'=>array($a->get_baseurl() . '/profile_photo/use/'.$ph[0]['resource-id'], t('Use as profile photo')),
+ );
+
+ // lock
+ $lock = ( ( ($ph[0]['uid'] == local_user()) && (strlen($ph[0]['allow_cid']) || strlen($ph[0]['allow_gid'])
+ || strlen($ph[0]['deny_cid']) || strlen($ph[0]['deny_gid'])) )
+ ? t('Private Message')
+ : Null);
+
+
}
+ if($prevlink)
+ $prevlink = array($prevlink, '') ;
- $o .= '';
+ $photo = array(
+ 'href' => $a->get_baseurl() . '/photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.jpg',
+ 'title'=> t('View Full Size'),
+ 'src' => $a->get_baseurl() . '/photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.jpg'
+ );
+
+ if($nextlink)
+ $nextlink = array($nextlink, '
');
// Do we have an item for this photo?
@@ -919,35 +1124,40 @@ function photos_content(&$a) {
}
}
- $o .= '
' . $ph[0]['desc'] . '
';
+ $tags=Null;
if(count($linked_items) && strlen($link_item['tag'])) {
$arr = explode(',',$link_item['tag']);
- // parse tags and add links
- $o .= '
' . t('Tags: ') . '
';
- $o .= '
';
+ // parse tags and add links
$tag_str = '';
foreach($arr as $t) {
if(strlen($tag_str))
$tag_str .= ', ';
$tag_str .= bbcode($t);
}
- $o .= $tag_str . '
';
- if($cmd === 'edit')
- $o .= '
';
+ $tags = array(t('Tags: '), $tag_str);
+ if($cmd === 'edit') {
+ $tags[] = $a->get_baseurl() . '/tagrm/' . $link_item['id'];
+ $tags[] = t('[Remove any tag]');
+ }
}
+ $edit = Null;
if(($cmd === 'edit') && ($can_post)) {
- $edit_tpl = load_view_file('view/photo_edit.tpl');
- $o .= replace_macros($edit_tpl, array(
+ $edit_tpl = get_markup_template('photo_edit.tpl');
+ $edit = replace_macros($edit_tpl, array(
'$id' => $ph[0]['id'],
+ '$album' => template_escape($ph[0]['album']),
+ '$newalbum' => t('New album name'),
'$nickname' => $a->data['user']['nickname'],
'$resource_id' => $ph[0]['resource-id'],
'$capt_label' => t('Caption'),
- '$caption' => $ph[0]['desc'],
+ '$caption' => template_escape($ph[0]['desc']),
'$tag_label' => t('Add a Tag'),
'$tags' => $link_item['tag'],
+ '$permissions' => t('Permissions'),
+ '$aclselect' => template_escape(populate_acl($ph[0])),
'$help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'),
'$item_id' => ((count($linked_items)) ? $link_item['id'] : 0),
'$submit' => t('Submit'),
@@ -957,26 +1167,31 @@ function photos_content(&$a) {
if(count($linked_items)) {
- $cmnt_tpl = load_view_file('view/comment_item.tpl');
- $tpl = load_view_file('view/photo_item.tpl');
+ $cmnt_tpl = get_markup_template('comment_item.tpl');
+ $tpl = get_markup_template('photo_item.tpl');
$return_url = $a->cmd;
- $like_tpl = load_view_file('view/like.tpl');
+ $like_tpl = get_markup_template('like_noshare.tpl');
$likebuttons = '';
- if($can_post || can_write_wall($a,$owner_uid))
- $likebuttons = replace_macros($like_tpl,array('$id' => $link_item['id']));
+ if($can_post || can_write_wall($a,$owner_uid)) {
+ $likebuttons = replace_macros($like_tpl,array(
+ '$id' => $link_item['id'],
+ '$likethis' => t("I like this \x28toggle\x29"),
+ '$nolike' => t("I don't like this \x28toggle\x29"),
+ '$share' => t('Share'),
+ '$wait' => t('Please wait')
+ ));
+ }
+ $comments = '';
if(! count($r)) {
- $o .= '
';
- $o .= $likebuttons;
- $o .= '
';
-
if($can_post || can_write_wall($a,$owner_uid)) {
if($link_item['last-child']) {
- $o .= replace_macros($cmnt_tpl,array(
- '$return_path' => $return_url,
+ $comments .= replace_macros($cmnt_tpl,array(
+ '$return_path' => '',
+ '$jsreload' => $return_url,
'$type' => 'wall-comment',
'$id' => $link_item['id'],
'$parent' => $link_item['id'],
@@ -984,6 +1199,8 @@ function photos_content(&$a) {
'$mylink' => $contact['url'],
'$mytitle' => t('This is you'),
'$myphoto' => $contact['thumb'],
+ '$comment' => t('Comment'),
+ '$submit' => t('Submit'),
'$ww' => ''
));
}
@@ -992,6 +1209,9 @@ function photos_content(&$a) {
$alike = array();
$dlike = array();
+
+ $like = '';
+ $dislike = '';
// display comments
if(count($r)) {
@@ -1001,21 +1221,16 @@ function photos_content(&$a) {
like_puller($a,$item,$dlike,'dislike');
}
- $like = ((isset($alike[$link_item['id']])) ? format_like($alike[$link_item['id']],$alike[$link_item['id'] . '-l'],'like',$link_item['id']) : '');
+ $like = ((isset($alike[$link_item['id']])) ? format_like($alike[$link_item['id']],$alike[$link_item['id'] . '-l'],'like',$link_item['id']) : '');
$dislike = ((isset($dlike[$link_item['id']])) ? format_like($dlike[$link_item['id']],$dlike[$link_item['id'] . '-l'],'dislike',$link_item['id']) : '');
- $o .= '
';
- $o .= $likebuttons;
- $o .= $like;
- $o .= $dislike;
- $o .= '
';
-
if($can_post || can_write_wall($a,$owner_uid)) {
if($link_item['last-child']) {
- $o .= replace_macros($cmnt_tpl,array(
- '$return_path' => $return_url,
+ $comments .= replace_macros($cmnt_tpl,array(
+ '$return_path' => '',
+ '$jsreload' => $return_url,
'$type' => 'wall-comment',
'$id' => $link_item['id'],
'$parent' => $link_item['id'],
@@ -1023,6 +1238,8 @@ function photos_content(&$a) {
'$mylink' => $contact['url'],
'$mytitle' => t('This is you'),
'$myphoto' => $contact['thumb'],
+ '$comment' => t('Comment'),
+ '$submit' => t('Submit'),
'$ww' => ''
));
}
@@ -1042,8 +1259,9 @@ function photos_content(&$a) {
if($can_post || can_write_wall($a,$owner_uid)) {
if($item['last-child']) {
- $comment = replace_macros($cmnt_tpl,array(
- '$return_path' => $return_url,
+ $comments .= replace_macros($cmnt_tpl,array(
+ '$return_path' => '',
+ '$jsreload' => $return_url,
'$type' => 'wall-comment',
'$id' => $item['item_id'],
'$parent' => $item['parent'],
@@ -1051,6 +1269,8 @@ function photos_content(&$a) {
'$mylink' => $contact['url'],
'$mytitle' => t('This is you'),
'$myphoto' => $contact['thumb'],
+ '$comment' => t('Comment'),
+ '$submit' => t('Submit'),
'$ww' => ''
));
}
@@ -1077,17 +1297,17 @@ function photos_content(&$a) {
$drop = '';
if(($item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
- $drop = replace_macros(load_view_file('view/wall_item_drop.tpl'), array('$id' => $item['id']));
+ $drop = replace_macros(get_markup_template('photo_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
- $o .= replace_macros($template,array(
+ $comments .= replace_macros($template,array(
'$id' => $item['item_id'],
'$profile_url' => $profile_link,
- '$name' => $profile_name,
+ '$name' => template_escape($profile_name),
'$thumb' => $profile_avatar,
'$sparkle' => $sparkle,
- '$title' => $item['title'],
- '$body' => bbcode($item['body']),
+ '$title' => template_escape($item['title']),
+ '$body' => template_escape(bbcode($item['body'])),
'$ago' => relative_date($item['created']),
'$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
'$drop' => $drop,
@@ -1096,17 +1316,38 @@ function photos_content(&$a) {
}
}
- $o .= paginate($a);
+ $paginate = paginate($a);
}
+
+ $photo_tpl = get_markup_template('photo_view.tpl');
+ $o .= replace_macros($photo_tpl, array(
+ '$id' => $ph[0]['id'],
+ '$album' => array($album_link,template_escape($ph[0]['album'])),
+ '$tools' => $tools,
+ '$lock' => $lock,
+ '$photo' => $photo,
+ '$prevlink' => $prevlink,
+ '$nextlink' => $nextlink,
+ '$desc' => $ph[0]['desc'],
+ '$tags' => template_escape($tags),
+ '$edit' => $edit,
+ '$likebuttons' => $likebuttons,
+ '$like' => template_escape($like),
+ '$dislike' => template_escape($dislike),
+ '$comments' => $comments,
+ '$paginate' => $paginate,
+ ));
+
return $o;
}
// Default - show recent photos with upload link (if applicable)
- $o = '';
+ //$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' AND `album` != '%s'
$sql_extra GROUP BY `resource-id`",
intval($a->data['user']['uid']),
+ dbesc('Contact Photos'),
dbesc( t('Contact Photos'))
);
if(count($r)) {
@@ -1115,9 +1356,10 @@ function photos_content(&$a) {
}
$r = q("SELECT `resource-id`, `id`, `filename`, `album`, max(`scale`) AS `scale` FROM `photo`
- WHERE `uid` = %d AND `album` != '%s'
+ WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
$sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
intval($a->data['user']['uid']),
+ dbesc('Contact Photos'),
dbesc( t('Contact Photos')),
intval($a->pager['start']),
intval($a->pager['itemspage'])
@@ -1130,21 +1372,18 @@ function photos_content(&$a) {
. $a->data['user']['nickname'] . '/upload' . '">' . t('Upload New Photos') . '
';
}
- $tpl = load_view_file('view/photo_top.tpl');
+ $tpl = get_markup_template('photo_top.tpl');
if(count($r)) {
foreach($r as $rr) {
$o .= replace_macros($tpl,array(
- '$id' => $rr['id'],
- '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname']
- . '/image/' . $rr['resource-id'],
+ '$id' => $rr['id'],
+ '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
'$phototitle' => t('View Photo'),
- '$imgsrc' => $a->get_baseurl() . '/photo/'
- . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.jpg',
- '$albumlink' => $a->get_baseurl() . '/photos/'
- . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
- '$albumname' => $rr['album'],
- '$albumalt' => t('View Album'),
- '$imgalt' => $rr['filename']
+ '$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.jpg',
+ '$albumlink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($rr['album']),
+ '$albumname' => template_escape($rr['album']),
+ '$albumalt' => t('View Album'),
+ '$imgalt' => template_escape($rr['filename'])
));
}
@@ -1153,3 +1392,4 @@ function photos_content(&$a) {
$o .= paginate($a);
return $o;
}
+