aboutsummaryrefslogtreecommitdiffstats
path: root/mod/photos.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/photos.php')
-rw-r--r--mod/photos.php138
1 files changed, 69 insertions, 69 deletions
diff --git a/mod/photos.php b/mod/photos.php
index ddacc38a3..0adbf752a 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -29,16 +29,16 @@ function photos_init(&$a) {
if(! $channelx)
return;
- $a->data['channel'] = $channelx;
+ App::$data['channel'] = $channelx;
- $observer = $a->get_observer();
- $a->data['observer'] = $observer;
+ $observer = App::get_observer();
+ App::$data['observer'] = $observer;
$observer_xchan = (($observer) ? $observer['xchan_hash'] : '');
- head_set_icon($a->data['channel']['xchan_photo_s']);
+ head_set_icon(App::$data['channel']['xchan_photo_s']);
- $a->page['htmlhead'] .= "<script> var ispublic = '" . t('everybody') . "'; var profile_uid = " . (($a->data['channel']) ? $a->data['channel']['channel_id'] : 0) . "; </script>" ;
+ App::$page['htmlhead'] .= "<script> var ispublic = '" . t('everybody') . "'; var profile_uid = " . ((App::$data['channel']) ? App::$data['channel']['channel_id'] : 0) . "; </script>" ;
}
@@ -61,7 +61,7 @@ function photos_post(&$a) {
$can_post = false;
- $page_owner_uid = $a->data['channel']['channel_id'];
+ $page_owner_uid = App::$data['channel']['channel_id'];
if(perm_is_allowed($page_owner_uid,get_observer_hash(),'write_storage'))
$can_post = true;
@@ -85,7 +85,7 @@ function photos_post(&$a) {
$owner_record = $s[0];
- $acl = new Zotlabs\Access\AccessList($a->data['channel']);
+ $acl = new Zotlabs\Access\AccessList(App::$data['channel']);
if((argc() > 3) && (argv(2) === 'album')) {
@@ -165,7 +165,7 @@ function photos_post(&$a) {
}
- goaway(z_root() . '/photos/' . $a->data['channel']['channel_address']);
+ goaway(z_root() . '/photos/' . App::$data['channel']['channel_address']);
}
if((argc() > 2) && (x($_REQUEST,'delete')) && ($_REQUEST['delete'] === t('Delete Photo'))) {
@@ -179,7 +179,7 @@ function photos_post(&$a) {
$r = q("SELECT `id`, `resource_id` FROM `photo` WHERE ( xchan = '%s' or `uid` = %d ) AND `resource_id` = '%s' LIMIT 1",
dbesc($ob_hash),
intval(local_channel()),
- dbesc($a->argv[2])
+ dbesc(App::$argv[2])
);
if($r) {
@@ -202,11 +202,11 @@ function photos_post(&$a) {
*/
}
- goaway(z_root() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . $_SESSION['album_return']);
+ goaway(z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/album/' . $_SESSION['album_return']);
}
- if(($a->argc > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false)) || (x($_POST,'albname') !== false)) {
+ if((App::$argc > 2) && ((x($_POST,'desc') !== false) || (x($_POST,'newtag') !== false)) || (x($_POST,'albname') !== false)) {
$desc = ((x($_POST,'desc')) ? notags(trim($_POST['desc'])) : '');
@@ -218,7 +218,7 @@ function photos_post(&$a) {
$acl->set_from_array($_POST);
$perm = $acl->get();
- $resource_id = $a->argv[2];
+ $resource_id = App::$argv[2];
if(! strlen($albname))
$albname = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y');
@@ -349,7 +349,7 @@ function photos_post(&$a) {
$visibility = 1;
if(! $item_id) {
- $item_id = photos_create_item($a->data['channel'],get_observer_hash(),$p[0],$visibility);
+ $item_id = photos_create_item(App::$data['channel'],get_observer_hash(),$p[0],$visibility);
}
@@ -401,7 +401,7 @@ function photos_post(&$a) {
$rawtags = '@' . $rawtags;
require_once('include/text.php');
- $profile_uid = $a->profile['profile_uid'];
+ $profile_uid = App::$profile['profile_uid'];
$results = linkify_tags($a, $rawtags, (local_channel()) ? local_channel() : $profile_uid);
@@ -450,8 +450,8 @@ function photos_post(&$a) {
* default post action - upload a photo
*/
- $channel = $a->data['channel'];
- $observer = $a->data['observer'];
+ $channel = App::$data['channel'];
+ $observer = App::$data['observer'];
$_REQUEST['source'] = 'photos';
require_once('include/attach.php');
@@ -470,9 +470,9 @@ function photos_post(&$a) {
}
if($_REQUEST['newalbum'])
- goaway(z_root() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($_REQUEST['newalbum']));
+ goaway(z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/album/' . bin2hex($_REQUEST['newalbum']));
else
- goaway(z_root() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex(datetime_convert('UTC',date_default_timezone_get(),'now', 'Y')));
+ goaway(z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/album/' . bin2hex(datetime_convert('UTC',date_default_timezone_get(),'now', 'Y')));
}
@@ -497,7 +497,7 @@ function photos_content(&$a) {
require_once('include/security.php');
require_once('include/conversation.php');
- if(! x($a->data,'channel')) {
+ if(! x(App::$data,'channel')) {
notice( t('No photos selected') . EOL );
return;
}
@@ -505,13 +505,13 @@ function photos_content(&$a) {
$ph = photo_factory('');
$phototypes = $ph->supportedTypes();
- $_SESSION['photo_return'] = $a->cmd;
+ $_SESSION['photo_return'] = App::$cmd;
//
// Parse arguments
//
- $can_comment = perm_is_allowed($a->profile['profile_uid'],get_observer_hash(),'post_comments');
+ $can_comment = perm_is_allowed(App::$profile['profile_uid'],get_observer_hash(),'post_comments');
if(argc() > 3) {
$datatype = argv(2);
@@ -538,10 +538,10 @@ function photos_content(&$a) {
$visitor = 0;
- $owner_uid = $a->data['channel']['channel_id'];
- $owner_aid = $a->data['channel']['channel_account_id'];
+ $owner_uid = App::$data['channel']['channel_id'];
+ $owner_aid = App::$data['channel']['channel_account_id'];
- $observer = $a->get_observer();
+ $observer = App::get_observer();
$can_post = perm_is_allowed($owner_uid,$observer['xchan_hash'],'write_storage');
$can_view = perm_is_allowed($owner_uid,$observer['xchan_hash'],'view_storage');
@@ -555,13 +555,13 @@ function photos_content(&$a) {
$o = "";
- $o .= "<script> var profile_uid = " . $a->profile['profile_uid']
- . "; var netargs = '?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
+ $o .= "<script> var profile_uid = " . App::$profile['profile_uid']
+ . "; var netargs = '?f='; var profile_page = " . App::$pager['page'] . "; </script>\r\n";
// tabs
$_is_owner = (local_channel() && (local_channel() == $owner_uid));
- $o .= profile_tabs($a,$_is_owner, $a->data['channel']['channel_address']);
+ $o .= profile_tabs($a,$_is_owner, App::$data['channel']['channel_address']);
/**
* Display upload form
@@ -571,7 +571,7 @@ function photos_content(&$a) {
$uploader = '';
- $ret = array('post_url' => z_root() . '/photos/' . $a->data['channel']['channel_address'],
+ $ret = array('post_url' => z_root() . '/photos/' . App::$data['channel']['channel_address'],
'addon_text' => $uploader,
'default_upload' => true);
@@ -580,11 +580,11 @@ function photos_content(&$a) {
/* Show space usage */
$r = q("select sum(size) as total from photo where aid = %d and scale = 0 ",
- intval($a->data['channel']['channel_account_id'])
+ intval(App::$data['channel']['channel_account_id'])
);
- $limit = service_class_fetch($a->data['channel']['channel_id'],'photo_upload_limit');
+ $limit = service_class_fetch(App::$data['channel']['channel_id'],'photo_upload_limit');
if($limit !== false) {
$usage_message = sprintf( t("%1$.2f MB of %2$.2f MB photo storage used."), $r[0]['total'] / 1024000, $limit / 1024000 );
}
@@ -593,7 +593,7 @@ function photos_content(&$a) {
}
if($_is_owner) {
- $channel = $a->get_channel();
+ $channel = App::get_channel();
$acl = new Zotlabs\Access\AccessList($channel);
$channel_acl = $acl->get();
@@ -613,10 +613,10 @@ function photos_content(&$a) {
$selname = (($datum) ? hex2bin($datum) : '');
- $albums = ((array_key_exists('albums', $a->data)) ? $a->data['albums'] : photos_albums_list($a->data['channel'],$a->data['observer']));
+ $albums = ((array_key_exists('albums', App::$data)) ? App::$data['albums'] : photos_albums_list(App::$data['channel'],App::$data['observer']));
if(! $selname) {
- $def_album = get_pconfig($a->data['channel']['channel_id'],'system','photo_path');
+ $def_album = get_pconfig(App::$data['channel']['channel_id'],'system','photo_path');
if($def_album) {
$selname = filepath_macro($def_album);
$albums['album'][] = array('text' => $selname);
@@ -628,7 +628,7 @@ function photos_content(&$a) {
'$pagename' => t('Upload Photos'),
'$sessid' => session_id(),
'$usage' => $usage_message,
- '$nickname' => $a->data['channel']['channel_address'],
+ '$nickname' => App::$data['channel']['channel_address'],
'$newalbum_label' => t('Enter an album name'),
'$newalbum_placeholder' => t('or select an existing album (doubleclick)'),
'$visible' => array('visible', t('Create a status post for this upload'), 0,'', array(t('No'), t('Yes')), 'onclick="showHideBodyTextarea();"'),
@@ -669,7 +669,7 @@ function photos_content(&$a) {
$album = (($datum) ? hex2bin($datum) : '');
- $a->page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . $a->cmd) . '" title="oembed" />' . "\r\n";
+ App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . App::$cmd) . '" title="oembed" />' . "\r\n";
$r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
@@ -681,10 +681,10 @@ function photos_content(&$a) {
intval($unsafe)
);
if(count($r)) {
- $a->set_pager_total(count($r));
- $a->set_pager_itemspage(60);
+ App::set_pager_total(count($r));
+ App::set_pager_itemspage(60);
} else {
- goaway(z_root() . '/photos/' . $a->data['channel']['channel_address']);
+ goaway(z_root() . '/photos/' . App::$data['channel']['channel_address']);
}
if($_GET['order'] === 'posted')
@@ -702,8 +702,8 @@ function photos_content(&$a) {
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE),
intval($unsafe),
- intval($a->pager['itemspage']),
- intval($a->pager['start'])
+ intval(App::$pager['itemspage']),
+ intval(App::$pager['start'])
);
//edit album name
@@ -711,7 +711,7 @@ function photos_content(&$a) {
if(($album !== t('Profile Photos')) && ($album !== 'Profile Photos') && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
if($can_post) {
$album_e = $album;
- $albums = ((array_key_exists('albums', $a->data)) ? $a->data['albums'] : photos_albums_list($a->data['channel'],$a->data['observer']));
+ $albums = ((array_key_exists('albums', App::$data)) ? App::$data['albums'] : photos_albums_list(App::$data['channel'],App::$data['observer']));
// @fixme - syncronise actions with DAV
@@ -719,7 +719,7 @@ function photos_content(&$a) {
// $album_edit = replace_macros($edit_tpl,array(
// '$nametext' => t('Enter a new album name'),
// '$name_placeholder' => t('or select an existing one (doubleclick)'),
-// '$nickname' => $a->data['channel']['channel_address'],
+// '$nickname' => App::$data['channel']['channel_address'],
// '$album' => $album_e,
// '$albums' => $albums['albums'],
// '$hexalbum' => bin2hex($album),
@@ -731,9 +731,9 @@ function photos_content(&$a) {
}
if($_GET['order'] === 'posted')
- $order = array(t('Show Newest First'), z_root() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album));
+ $order = array(t('Show Newest First'), z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/album/' . bin2hex($album));
else
- $order = array(t('Show Oldest First'), z_root() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($album) . '?f=&order=posted');
+ $order = array(t('Show Oldest First'), z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/album/' . bin2hex($album) . '?f=&order=posted');
$photos = array();
if(count($r)) {
@@ -750,7 +750,7 @@ function photos_content(&$a) {
$imgalt_e = $rr['filename'];
$desc_e = $rr['description'];
- $imagelink = (z_root() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $rr['resource_id']
+ $imagelink = (z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/image/' . $rr['resource_id']
. (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''));
$photos[] = array(
@@ -790,7 +790,7 @@ function photos_content(&$a) {
'$album_id' => bin2hex($album),
'$album_edit' => array(t('Edit Album'), $album_edit),
'$can_post' => $can_post,
- '$upload' => array(t('Upload'), z_root() . '/photos/' . $a->data['channel']['channel_address'] . '/upload/' . bin2hex($album)),
+ '$upload' => array(t('Upload'), z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/upload/' . bin2hex($album)),
'$order' => $order,
'$upload_form' => $upload_form,
'$usage' => $usage_message
@@ -816,7 +816,7 @@ function photos_content(&$a) {
if($datatype === 'image') {
- $a->page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . $a->cmd) . '" title="oembed" />' . "\r\n";
+ App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . App::$cmd) . '" title="oembed" />' . "\r\n";
// fetch image, item containing image, then comments
@@ -871,8 +871,8 @@ function photos_content(&$a) {
}
}
- $prevlink = z_root() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
- $nextlink = z_root() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
+ $prevlink = z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/image/' . $prvnxt[$prv]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
+ $nextlink = z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/image/' . $prvnxt[$nxt]['resource_id'] . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
}
@@ -889,7 +889,7 @@ function photos_content(&$a) {
}
}
- $album_link = z_root() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($ph[0]['album']);
+ $album_link = z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/album/' . bin2hex($ph[0]['album']);
$tools = Null;
$lock = Null;
@@ -906,12 +906,12 @@ function photos_content(&$a) {
? array('lock', t('Private Photo'))
: array('unlock', Null));
- $a->page['htmlhead'] .= '<script>$(document).keydown(function(event) {' . "\n";
+ App::$page['htmlhead'] .= '<script>$(document).keydown(function(event) {' . "\n";
if($prevlink)
- $a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 37) { event.preventDefault(); window.location.href = \'' . $prevlink . '\'; }' . "\n";
+ App::$page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 37) { event.preventDefault(); window.location.href = \'' . $prevlink . '\'; }' . "\n";
if($nextlink)
- $a->page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 39) { event.preventDefault(); window.location.href = \'' . $nextlink . '\'; }' . "\n";
- $a->page['htmlhead'] .= '});</script>';
+ App::$page['htmlhead'] .= 'if(event.ctrlKey && event.keyCode == 39) { event.preventDefault(); window.location.href = \'' . $nextlink . '\'; }' . "\n";
+ App::$page['htmlhead'] .= '});</script>';
if($prevlink)
$prevlink = array($prevlink, t('Previous'));
@@ -992,7 +992,7 @@ function photos_content(&$a) {
$album_e = $ph[0]['album'];
$caption_e = $ph[0]['description'];
$aclselect_e = (($_is_owner) ? populate_acl($ph[0]) : '');
- $albums = ((array_key_exists('albums', $a->data)) ? $a->data['albums'] : photos_albums_list($a->data['channel'],$a->data['observer']));
+ $albums = ((array_key_exists('albums', App::$data)) ? App::$data['albums'] : photos_albums_list(App::$data['channel'],App::$data['observer']));
$_SESSION['album_return'] = bin2hex($ph[0]['album']);
@@ -1005,7 +1005,7 @@ function photos_content(&$a) {
'album' => $album_e,
'newalbum_label' => t('Enter a new album name'),
'newalbum_placeholder' => t('or select an existing one (doubleclick)'),
- 'nickname' => $a->data['channel']['channel_address'],
+ 'nickname' => App::$data['channel']['channel_address'],
'resource_id' => $ph[0]['resource_id'],
'capt_label' => t('Caption'),
'caption' => $caption_e,
@@ -1026,7 +1026,7 @@ function photos_content(&$a) {
$cmnt_tpl = get_markup_template('comment_item.tpl');
$tpl = get_markup_template('photo_item.tpl');
- $return_url = $a->cmd;
+ $return_url = App::$cmd;
$like_tpl = get_markup_template('like_noshare.tpl');
@@ -1233,7 +1233,7 @@ function photos_content(&$a) {
'$paginate' => $paginate,
));
- $a->data['photo_html'] = $o;
+ App::$data['photo_html'] = $o;
return $o;
}
@@ -1241,12 +1241,12 @@ function photos_content(&$a) {
// Default - show recent photos with upload link (if applicable)
//$o = '';
- $a->page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . $a->cmd) . '" title="oembed" />' . "\r\n";
+ App::$page['htmlhead'] .= "\r\n" . '<link rel="alternate" type="application/json+oembed" href="' . z_root() . '/oep?f=&url=' . urlencode(z_root() . '/' . App::$cmd) . '" title="oembed" />' . "\r\n";
$r = q("SELECT `resource_id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
and photo_usage in ( %d, %d ) and is_nsfw = %d $sql_extra GROUP BY `resource_id`",
- intval($a->data['channel']['channel_id']),
+ intval(App::$data['channel']['channel_id']),
dbesc('Contact Photos'),
dbesc( t('Contact Photos')),
intval(PHOTO_NORMAL),
@@ -1254,8 +1254,8 @@ function photos_content(&$a) {
intval($unsafe)
);
if(count($r)) {
- $a->set_pager_total(count($r));
- $a->set_pager_itemspage(60);
+ App::set_pager_total(count($r));
+ App::set_pager_itemspage(60);
}
$r = q("SELECT p.resource_id, p.id, p.filename, p.type, p.album, p.scale, p.created FROM photo p INNER JOIN
@@ -1263,14 +1263,14 @@ function photos_content(&$a) {
WHERE uid=%d AND album != '%s' AND album != '%s'
AND photo_usage IN ( %d, %d ) and is_nsfw = %d $sql_extra group by resource_id) ph
ON (p.resource_id = ph.resource_id and p.scale = ph.scale) ORDER by p.created DESC LIMIT %d OFFSET %d",
- intval($a->data['channel']['channel_id']),
+ intval(App::$data['channel']['channel_id']),
dbesc('Contact Photos'),
dbesc( t('Contact Photos')),
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE),
intval($unsafe),
- intval($a->pager['itemspage']),
- intval($a->pager['start'])
+ intval(App::$pager['itemspage']),
+ intval(App::$pager['start'])
);
@@ -1285,7 +1285,7 @@ function photos_content(&$a) {
$twist = 'rotright';
$ext = $phototypes[$rr['type']];
- if($a->get_template_engine() === 'internal') {
+ if(App::get_template_engine() === 'internal') {
$alt_e = template_escape($rr['filename']);
$name_e = template_escape($rr['album']);
}
@@ -1297,12 +1297,12 @@ function photos_content(&$a) {
$photos[] = array(
'id' => $rr['id'],
'twist' => ' ' . $twist . rand(2,4),
- 'link' => z_root() . '/photos/' . $a->data['channel']['channel_address'] . '/image/' . $rr['resource_id'],
+ 'link' => z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/image/' . $rr['resource_id'],
'title' => t('View Photo'),
'src' => z_root() . '/photo/' . $rr['resource_id'] . '-' . ((($rr['scale']) == 6) ? 4 : $rr['scale']) . '.' . $ext,
'alt' => $alt_e,
'album' => array(
- 'link' => z_root() . '/photos/' . $a->data['channel']['channel_address'] . '/album/' . bin2hex($rr['album']),
+ 'link' => z_root() . '/photos/' . App::$data['channel']['channel_address'] . '/album/' . bin2hex($rr['album']),
'name' => $name_e,
'alt' => t('View Album'),
),
@@ -1331,7 +1331,7 @@ function photos_content(&$a) {
'$title' => t('Recent Photos'),
'$album_id' => bin2hex(t('Recent Photos')),
'$can_post' => $can_post,
- '$upload' => array(t('Upload'), z_root().'/photos/'.$a->data['channel']['channel_address'].'/upload'),
+ '$upload' => array(t('Upload'), z_root().'/photos/'.App::$data['channel']['channel_address'].'/upload'),
'$photos' => $photos,
'$upload_form' => $upload_form,
'$usage' => $usage_message