aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Embedphotos.php
diff options
context:
space:
mode:
authorKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2016-10-02 00:41:25 +0200
committerKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2016-10-13 11:27:23 +0200
commit7b41839ea8f2aad020444c42f2cba89040ca28b8 (patch)
treeacf1495c556a0ce82823e47ebcdfa21377f92b61 /Zotlabs/Module/Embedphotos.php
parent6532972e61a2aa5e8517ebcca3113adb3c8f336d (diff)
downloadvolse-hubzilla-7b41839ea8f2aad020444c42f2cba89040ca28b8.tar.gz
volse-hubzilla-7b41839ea8f2aad020444c42f2cba89040ca28b8.tar.bz2
volse-hubzilla-7b41839ea8f2aad020444c42f2cba89040ca28b8.zip
[TASK] Update Doxyfile and fix Doxygen errors.
Updated Doxyfile to include new folders. Add a list for @hooks tags. Fixed some parsing problems for Doxygen.
Diffstat (limited to 'Zotlabs/Module/Embedphotos.php')
-rw-r--r--Zotlabs/Module/Embedphotos.php218
1 files changed, 107 insertions, 111 deletions
diff --git a/Zotlabs/Module/Embedphotos.php b/Zotlabs/Module/Embedphotos.php
index 0dac873c5..48667795c 100644
--- a/Zotlabs/Module/Embedphotos.php
+++ b/Zotlabs/Module/Embedphotos.php
@@ -1,97 +1,96 @@
<?php
+
namespace Zotlabs\Module;
/**
+ * @brief
*
- * This is the POST destination for the embedphotos button
- *
- */
-
-
+ */
class Embedphotos extends \Zotlabs\Web\Controller {
function get() {
-
+
}
+ /**
+ *
+ * This is the POST destination for the embedphotos button
+ *
+ */
function post() {
-
- if (argc() > 1 && argv(1) === 'album') {
- // API: /embedphotos/album
- $name = (x($_POST,'name') ? $_POST['name'] : null );
- if (!$name) {
- json_return_and_die(array('errormsg' => 'Error retrieving album', 'status' => false));
- }
- $album = $this->embedphotos_widget_album(array('channel' => \App::get_channel(), 'album' => $name));
- json_return_and_die(array('status' => true, 'content' => $album));
-
- }
- if (argc() > 1 && argv(1) === 'albumlist') {
- // API: /embedphotos/albumlist
- $album_list = $this->embedphotos_album_list($a);
- json_return_and_die(array('status' => true, 'albumlist' => $album_list));
-
- }
- if (argc() > 1 && argv(1) === 'photolink') {
- // API: /embedphotos/photolink
- $href = (x($_POST,'href') ? $_POST['href'] : null );
- if (!$href) {
- json_return_and_die(array('errormsg' => 'Error retrieving link ' . $href, 'status' => false));
- }
- $resource_id = array_pop(explode("/", $href));
- $r = q("SELECT obj from item where resource_type = 'photo' and resource_id = '%s' limit 1",
- dbesc($resource_id)
- );
- if(!$r) {
- json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false));
- }
- $obj = json_decode($r[0]['obj'], true);
- if(x($obj,'body')) {
- $photolink = $obj['body'];
- } elseif (x($obj,'bbcode')) {
- $photolink = $obj['bbcode'];
- } else {
- json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false));
- }
- json_return_and_die(array('status' => true, 'photolink' => $photolink));
-
- }
+ if (argc() > 1 && argv(1) === 'album') {
+ // API: /embedphotos/album
+ $name = (x($_POST,'name') ? $_POST['name'] : null );
+ if(!$name) {
+ json_return_and_die(array('errormsg' => 'Error retrieving album', 'status' => false));
+ }
+ $album = $this->embedphotos_widget_album(array('channel' => \App::get_channel(), 'album' => $name));
+ json_return_and_die(array('status' => true, 'content' => $album));
+ }
+ if(argc() > 1 && argv(1) === 'albumlist') {
+ // API: /embedphotos/albumlist
+ $album_list = $this->embedphotos_album_list($a);
+ json_return_and_die(array('status' => true, 'albumlist' => $album_list));
+ }
+ if(argc() > 1 && argv(1) === 'photolink') {
+ // API: /embedphotos/photolink
+ $href = (x($_POST,'href') ? $_POST['href'] : null );
+ if(!$href) {
+ json_return_and_die(array('errormsg' => 'Error retrieving link ' . $href, 'status' => false));
+ }
+ $resource_id = array_pop(explode("/", $href));
+ $r = q("SELECT obj from item where resource_type = 'photo' and resource_id = '%s' limit 1",
+ dbesc($resource_id)
+ );
+ if(!$r) {
+ json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false));
+ }
+ $obj = json_decode($r[0]['obj'], true);
+ if(x($obj,'body')) {
+ $photolink = $obj['body'];
+ } elseif (x($obj,'bbcode')) {
+ $photolink = $obj['bbcode'];
+ } else {
+ json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false));
+ }
+ json_return_and_die(array('status' => true, 'photolink' => $photolink));
+ }
}
-
-
-/**
- * Copied from include/widgets.php::widget_album() with a modification to get the profile_uid from
- * the input array as in widget_item()
- * @param type $name
- * @return string
- */
-function embedphotos_widget_album($args) {
-
- $channel_id = 0;
- if(array_key_exists('channel',$args))
- $channel = $args['channel'];
- $channel_id = intval($channel['channel_id']);
- if(! $channel_id)
- $channel_id = \App::$profile_uid;
- if(! $channel_id)
- return '';
+
+ /**
+ * Copied from include/widgets.php::widget_album() with a modification to get the profile_uid from
+ * the input array as in widget_item()
+ *
+ * @param array $args
+ * @return string with HTML
+ */
+ function embedphotos_widget_album($args) {
+
+ $channel_id = 0;
+ if(array_key_exists('channel', $args))
+ $channel = $args['channel'];
+ $channel_id = intval($channel['channel_id']);
+ if(! $channel_id)
+ $channel_id = \App::$profile_uid;
+ if(! $channel_id)
+ return '';
+
$owner_uid = $channel_id;
- require_once('include/security.php');
- $sql_extra = permissions_sql($channel_id);
+ require_once('include/security.php');
+ $sql_extra = permissions_sql($channel_id);
- if(! perm_is_allowed($channel_id,get_observer_hash(),'view_storage'))
- return '';
+ if(! perm_is_allowed($channel_id,get_observer_hash(),'view_storage'))
+ return '';
- if($args['album'])
- $album = $args['album'];
- if($args['title'])
- $title = $args['title'];
+ if($args['album'])
+ $album = $args['album'];
+ if($args['title'])
+ $title = $args['title'];
- /**
+ /**
* This may return incorrect permissions if you have multiple directories of the same name.
* It is a limitation of the photo table using a name for a photo album instead of a folder hash
*/
-
if($album) {
$x = q("select hash from attach where filename = '%s' and uid = %d limit 1",
dbesc($album),
@@ -107,34 +106,33 @@ function embedphotos_widget_album($args) {
$order = 'DESC';
$r = q("SELECT p.resource_id, p.id, p.filename, p.mimetype, p.imgscale, p.description, p.created FROM photo p INNER JOIN
- (SELECT resource_id, max(imgscale) imgscale FROM photo WHERE uid = %d AND album = '%s' AND imgscale <= 4 AND photo_usage IN ( %d, %d ) $sql_extra GROUP BY resource_id) ph
+ (SELECT resource_id, max(imgscale) imgscale FROM photo WHERE uid = %d AND album = '%s' AND imgscale <= 4 AND photo_usage IN ( %d, %d ) $sql_extra GROUP BY resource_id) ph
ON (p.resource_id = ph.resource_id AND p.imgscale = ph.imgscale)
- ORDER BY created $order",
- intval($owner_uid),
- dbesc($album),
- intval(PHOTO_NORMAL),
- intval(PHOTO_PROFILE)
+ ORDER BY created $order",
+ intval($owner_uid),
+ dbesc($album),
+ intval(PHOTO_NORMAL),
+ intval(PHOTO_PROFILE)
);
$photos = array();
- if(count($r)) {
- $twist = 'rotright';
- foreach($r as $rr) {
-
- if($twist == 'rotright')
- $twist = 'rotleft';
- else
- $twist = 'rotright';
-
- $ext = $phototypes[$rr['mimetype']];
-
- $imgalt_e = $rr['filename'];
- $desc_e = $rr['description'];
-
- $imagelink = (z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $rr['resource_id']
+ if(count($r)) {
+ $twist = 'rotright';
+ foreach($r as $rr) {
+ if($twist == 'rotright')
+ $twist = 'rotleft';
+ else
+ $twist = 'rotright';
+
+ $ext = $phototypes[$rr['mimetype']];
+
+ $imgalt_e = $rr['filename'];
+ $desc_e = $rr['description'];
+
+ $imagelink = (z_root() . '/photos/' . \App::$data['channel']['channel_address'] . '/image/' . $rr['resource_id']
. (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''));
-
- $photos[] = array(
+
+ $photos[] = array(
'id' => $rr['id'],
'twist' => ' ' . $twist . rand(2,4),
'link' => $imagelink,
@@ -146,8 +144,8 @@ function embedphotos_widget_album($args) {
'hash'=> $rr['resource_id'],
'unknown' => t('Unknown')
);
- }
}
+ }
$tpl = get_markup_template('photo_album.tpl');
$o .= replace_macros($tpl, array(
@@ -163,18 +161,16 @@ function embedphotos_widget_album($args) {
));
return $o;
-}
-
+ }
-function embedphotos_album_list($a) {
- $o = '';
- require_once('include/photos.php');
- $p = photos_albums_list(\App::get_channel(), \App::get_observer());
- if ($p['success']) {
- return $p['albums'];
- } else {
- return null;
- }
-}
+ function embedphotos_album_list($a) {
+ require_once('include/photos.php');
+ $p = photos_albums_list(\App::get_channel(), \App::get_observer());
+ if($p['success']) {
+ return $p['albums'];
+ } else {
+ return null;
+ }
+ }
}