+ $default_upload = '
';
-
+ $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
+ intval($a->data['user']['uid'])
+ );
+
+
+ $limit = service_class_fetch($a->data['user']['uid'],'photo_upload_limit');
+ if($limit !== false) {
+ $usage_message = sprintf( t("You have used %1$.2f Mbytes of %2$.2f Mbytes photo storage."), $r[0]['total'] / 1024000, $limit / 1024000 );
+ }
+ else {
+ $usage_message = sprintf( t('You have used %1$.2f Mbytes of photo storage.'), $r[0]['total'] / 1024000 );
+ }
+
$tpl = get_markup_template('photos_upload.tpl');
$o .= replace_macros($tpl,array(
'$pagename' => t('Upload Photos'),
'$sessid' => session_id(),
+ '$usage' => $usage_message,
'$nickname' => $a->data['user']['nickname'],
'$newalbum' => t('New album name: '),
'$existalbumtext' => t('or existing album name: '),
@@ -1002,8 +1076,13 @@ function photos_content(&$a) {
$a->set_pager_itemspage(20);
}
+ if($_GET['order'] === 'posted')
+ $order = 'ASC';
+ else
+ $order = 'DESC';
+
$r = q("SELECT `resource-id`, `id`, `filename`, type, max(`scale`) AS `scale`, `desc` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
- AND `scale` <= 4 $sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
+ AND `scale` <= 4 $sql_extra GROUP BY `resource-id` ORDER BY `created` $order LIMIT %d , %d",
intval($owner_uid),
dbesc($album),
intval($a->pager['start']),
@@ -1037,10 +1116,17 @@ function photos_content(&$a) {
}
}
+ if($_GET['order'] === 'posted')
+ $o .= '
';
+ else
+ $o .= '
';
+
+
if($can_post) {
$o .= '
';
}
+
$tpl = get_markup_template('photo_album.tpl');
if(count($r))
$twist = 'rotright';
@@ -1055,7 +1141,8 @@ function photos_content(&$a) {
$o .= replace_macros($tpl,array(
'$id' => $rr['id'],
'$twist' => ' ' . $twist . rand(2,4),
- '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id'],
+ '$photolink' => $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $rr['resource-id']
+ . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''),
'$phototitle' => t('View Photo'),
'$imgsrc' => $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext,
'$imgalt' => template_escape($rr['filename']),
@@ -1100,8 +1187,14 @@ function photos_content(&$a) {
$prevlink = '';
$nextlink = '';
+ if($_GET['order'] === 'posted')
+ $order = 'ASC';
+ else
+ $order = 'DESC';
+
+
$prvnxt = q("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
- $sql_extra ORDER BY `created` DESC ",
+ $sql_extra ORDER BY `created` $order ",
dbesc($ph[0]['album']),
intval($owner_uid)
);
@@ -1119,8 +1212,8 @@ function photos_content(&$a) {
}
}
$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;
+ $prevlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
+ $nextlink = $a->get_baseurl() . '/photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
}
@@ -1156,15 +1249,12 @@ function photos_content(&$a) {
}
- if(! $cmd !== 'edit') {
- $a->page['htmlhead'] .= '';
+ if( $cmd === 'edit') {
+ $tpl = get_markup_template('photo_edit_head.tpl');
+ $a->page['htmlhead'] .= replace_macros($tpl,array(
+ '$prevlink' => $prevlink,
+ '$nextlink' => $nextlink
+ ));
}
if($prevlink)
@@ -1182,6 +1272,12 @@ function photos_content(&$a) {
// Do we have an item for this photo?
+ // FIXME! - replace following code to display the conversation with our normal
+ // conversation functions so that it works correctly and tracks changes
+ // in the evolving conversation code.
+ // The difference is that we won't be displaying the conversation head item
+ // as a "post" but displaying instead the photo it is linked to
+
$linked_items = q("SELECT * FROM `item` WHERE `resource-id` = '%s' $sql_extra LIMIT 1",
dbesc($datum)
);
@@ -1309,7 +1405,9 @@ function photos_content(&$a) {
'$comment' => t('Comment'),
'$submit' => t('Submit'),
'$preview' => t('Preview'),
- '$ww' => ''
+ '$sourceapp' => t($a->sourcename),
+ '$ww' => '',
+ '$rand_num' => random_digits(12)
));
}
}
@@ -1321,6 +1419,8 @@ function photos_content(&$a) {
$like = '';
$dislike = '';
+
+
// display comments
if(count($r)) {
@@ -1348,7 +1448,10 @@ function photos_content(&$a) {
'$myphoto' => $contact['thumb'],
'$comment' => t('Comment'),
'$submit' => t('Submit'),
- '$ww' => ''
+ '$preview' => t('Preview'),
+ '$sourceapp' => t($a->sourcename),
+ '$ww' => '',
+ '$rand_num' => random_digits(12)
));
}
}
@@ -1364,26 +1467,6 @@ function photos_content(&$a) {
$redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
- if($can_post || can_write_wall($a,$owner_uid)) {
-
- if($item['last-child']) {
- $comments .= replace_macros($cmnt_tpl,array(
- '$return_path' => '',
- '$jsreload' => $return_url,
- '$type' => 'wall-comment',
- '$id' => $item['item_id'],
- '$parent' => $item['parent'],
- '$profile_uid' => $owner_uid,
- '$mylink' => $contact['url'],
- '$mytitle' => t('This is you'),
- '$myphoto' => $contact['thumb'],
- '$comment' => t('Comment'),
- '$submit' => t('Submit'),
- '$ww' => ''
- ));
- }
- }
-
if(local_user() && ($item['contact-uid'] == local_user())
&& ($item['network'] == 'dfrn') && (! $item['self'] )) {
@@ -1404,7 +1487,7 @@ function photos_content(&$a) {
$drop = '';
- if(($item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
+ if(($item['contact-id'] == $contact_id) || ($item['uid'] == local_user()))
$drop = replace_macros(get_markup_template('photo_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
@@ -1421,6 +1504,29 @@ function photos_content(&$a) {
'$drop' => $drop,
'$comment' => $comment
));
+
+ if($can_post || can_write_wall($a,$owner_uid)) {
+
+ if($item['last-child']) {
+ $comments .= replace_macros($cmnt_tpl,array(
+ '$return_path' => '',
+ '$jsreload' => $return_url,
+ '$type' => 'wall-comment',
+ '$id' => $item['item_id'],
+ '$parent' => $item['parent'],
+ '$profile_uid' => $owner_uid,
+ '$mylink' => $contact['url'],
+ '$mytitle' => t('This is you'),
+ '$myphoto' => $contact['thumb'],
+ '$comment' => t('Comment'),
+ '$submit' => t('Submit'),
+ '$preview' => t('Preview'),
+ '$sourceapp' => t($a->sourcename),
+ '$ww' => '',
+ '$rand_num' => random_digits(12)
+ ));
+ }
+ }
}
}