]> git.mxchange.org Git - friendica.git/blobdiff - mod/photos.php
added spaces (space-time!) and TODO that x() is maybe proper way?
[friendica.git] / mod / photos.php
index a54aff326ad7848b24d38aa0f078218e92e32f6e..0f021d55a8bc1be337e5632046e26c1198e2da40 100644 (file)
@@ -1,14 +1,14 @@
 <?php
-require_once('include/Photo.php');
-require_once('include/photos.php');
-require_once('include/items.php');
-require_once('include/acl_selectors.php');
-require_once('include/bbcode.php');
-require_once('include/security.php');
-require_once('include/redir.php');
-require_once('include/tags.php');
-require_once('include/threads.php');
-require_once('include/Probe.php');
+require_once 'include/Photo.php';
+require_once 'include/photos.php';
+require_once 'include/items.php';
+require_once 'include/acl_selectors.php';
+require_once 'include/bbcode.php';
+require_once 'include/security.php';
+require_once 'include/redir.php';
+require_once 'include/tags.php';
+require_once 'include/threads.php';
+require_once 'include/Probe.php';
 
 use \Friendica\Core\Config;
 
@@ -18,7 +18,7 @@ function photos_init(App $a) {
                auto_redir($a, $a->argv[1]);
        }
 
-       if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+       if ((get_config('system', 'block_public')) && (! local_user()) && (! remote_user())) {
                return;
        }
 
@@ -562,9 +562,9 @@ function photos_post(App $a) {
                                        if (isset($profile)) {
                                                unset($profile);
                                        }
-                                       if (strpos($tag,'@') === 0) {
+                                       if (strpos($tag, '@') === 0) {
                                                $name = substr($tag,1);
-                                               if ((strpos($name,'@')) || (strpos($name,'http://'))) {
+                                               if ((strpos($name, '@')) || (strpos($name, 'http://'))) {
                                                        $newname = $name;
                                                        $links = @Probe::lrdd($name);
                                                        if (count($links)) {
@@ -573,7 +573,7 @@ function photos_post(App $a) {
                                                                                $profile = $link['@attributes']['href'];
                                                                        }
                                                                        if ($link['@attributes']['rel'] === 'salmon') {
-                                                                               $salmon = '$url:' . str_replace(',','%sc',$link['@attributes']['href']);
+                                                                               $salmon = '$url:' . str_replace(',', '%sc', $link['@attributes']['href']);
                                                                                if (strlen($inform)) {
                                                                                        $inform .= ',';
                                                                                }
@@ -581,13 +581,13 @@ function photos_post(App $a) {
                                                                        }
                                                                }
                                                        }
-                                                       $taginfo[] = array($newname,$profile,$salmon);
+                                                       $taginfo[] = array($newname, $profile, $salmon);
                                                } else {
                                                        $newname = $name;
                                                        $alias = '';
                                                        $tagcid = 0;
-                                                       if (strrpos($newname,'+')) {
-                                                               $tagcid = intval(substr($newname,strrpos($newname, '+') + 1));
+                                                       if (strrpos($newname, '+')) {
+                                                               $tagcid = intval(substr($newname, strrpos($newname, '+') + 1));
                                                        }
 
                                                        if ($tagcid) {
@@ -613,20 +613,7 @@ function photos_post(App $a) {
                                                                        );
                                                                }
                                                        }
-                                                       /// @TODO maybe old-lost code to be removed
-/*                                                     elseif (strstr($name,'_') || strstr($name,' ')) {
-                                                               $newname = str_replace('_',' ',$name);
-                                                               $r = q("SELECT * FROM `contact` WHERE `name` = '%s' AND `uid` = %d LIMIT 1",
-                                                                       dbesc($newname),
-                                                                       intval($page_owner_uid)
-                                                               );
-                                                       } else {
-                                                               $r = q("SELECT * FROM `contact` WHERE `attag` = '%s' OR `nick` = '%s' AND `uid` = %d ORDER BY `attag` DESC LIMIT 1",
-                                                                       dbesc($name),
-                                                                       dbesc($name),
-                                                                       intval($page_owner_uid)
-                                                               );
-                                                       }*/
+
                                                        if (dbm::is_result($r)) {
                                                                $newname = $r[0]['name'];
                                                                $profile = $r[0]['url'];
@@ -649,9 +636,9 @@ function photos_post(App $a) {
                                                        $profile = str_replace(',', '%2c', $profile);
                                                        $str_tags .= '@[url='.$profile.']'.$newname.'[/url]';
                                                }
-                                       } elseif (strpos($tag,'#') === 0) {
+                                       } elseif (strpos($tag, '#') === 0) {
                                                $tagname = substr($tag, 1);
-                                               $str_tags .= '#[url='.App::get_baseurl()."/search?tag=".$tagname.']'.$tagname.'[/url]';
+                                               $str_tags .= '#[url=' . App::get_baseurl() . "/search?tag=" . $tagname . ']' . $tagname . '[/url]';
                                        }
                                }
                        }
@@ -794,10 +781,10 @@ function photos_post(App $a) {
                $visible = 0;
        }
 
-       $str_group_allow   = perms2str(((is_array($_REQUEST['group_allow']))   ? $_REQUEST['group_allow']   : explode(',',$_REQUEST['group_allow'])));
-       $str_contact_allow = perms2str(((is_array($_REQUEST['contact_allow'])) ? $_REQUEST['contact_allow'] : explode(',',$_REQUEST['contact_allow'])));
-       $str_group_deny    = perms2str(((is_array($_REQUEST['group_deny']))    ? $_REQUEST['group_deny']    : explode(',',$_REQUEST['group_deny'])));
-       $str_contact_deny  = perms2str(((is_array($_REQUEST['contact_deny']))  ? $_REQUEST['contact_deny']  : explode(',',$_REQUEST['contact_deny'])));
+       $str_group_allow   = perms2str(((is_array($_REQUEST['group_allow']))   ? $_REQUEST['group_allow']   : explode(',', $_REQUEST['group_allow'])));
+       $str_contact_allow = perms2str(((is_array($_REQUEST['contact_allow'])) ? $_REQUEST['contact_allow'] : explode(',', $_REQUEST['contact_allow'])));
+       $str_group_deny    = perms2str(((is_array($_REQUEST['group_deny']))    ? $_REQUEST['group_deny']    : explode(',', $_REQUEST['group_deny'])));
+       $str_contact_deny  = perms2str(((is_array($_REQUEST['contact_deny']))  ? $_REQUEST['contact_deny']  : explode(',', $_REQUEST['contact_deny'])));
 
        $ret = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => '');
 
@@ -843,7 +830,7 @@ function photos_post(App $a) {
        $imagedata = @file_get_contents($src);
 
 
-       $limit = service_class_fetch($a->data['user']['uid'],'photo_upload_limit');
+       $limit = service_class_fetch($a->data['user']['uid'], 'photo_upload_limit');
 
        if ($limit) {
                $r = q("SELECT SUM(OCTET_LENGTH(`data`)) AS `total` FROM `photo` WHERE `uid` = %d AND `scale` = 0 AND `album` != 'Contact Photos'",
@@ -874,7 +861,7 @@ function photos_post(App $a) {
        $exif = $ph->orient($src);
        @unlink($src);
 
-       $max_length = get_config('system','max_image_length');
+       $max_length = get_config('system', 'max_image_length');
        if (! $max_length) {
                $max_length = MAX_IMAGE_LENGTH;
        }
@@ -988,7 +975,7 @@ function photos_content(App $a) {
        // photos/name/image/xxxxx/edit
 
 
-       if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
+       if ((get_config('system', 'block_public')) && (! local_user()) && (! remote_user())) {
                notice( t('Public access denied.') . EOL);
                return;
        }
@@ -1155,7 +1142,7 @@ function photos_content(App $a) {
                ));
 
                $usage_message = '';
-               $limit = service_class_fetch($a->data['user']['uid'],'photo_upload_limit');
+               $limit = service_class_fetch($a->data['user']['uid'], 'photo_upload_limit');
                if ($limit !== false) {
 
                        $r = q("SELECT SUM(`datasize`) AS `total` FROM `photo` WHERE `uid` = %d AND `scale` = 0 AND `album` != 'Contact Photos'",
@@ -1284,11 +1271,8 @@ function photos_content(App $a) {
                                }
                        }
                } else {
-                       /// @TODO merge else+if into elseif and 2 into one?
-                       if (($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos'))) {
-                               if ($can_post) {
-                                       $edit = array(t('Edit Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit');
-                               }
+                       if (($album !== t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== t('Contact Photos')) && $can_post) {
+                               $edit = array(t('Edit Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit');
                        }
                }
 
@@ -1539,7 +1523,7 @@ function photos_content(App $a) {
                $tags = null;
 
                if (count($linked_items) && strlen($link_item['tag'])) {
-                       $arr = explode(',',$link_item['tag']);
+                       $arr = explode(',', $link_item['tag']);
                        // parse tags and add links
                        $tag_str = '';
                        foreach ($arr as $t) {
@@ -1644,27 +1628,24 @@ function photos_content(App $a) {
 
                        $comments = '';
                        if (! dbm::is_result($r)) {
-                               /// @TODO merge into one if() ?
-                               if ($can_post || can_write_wall($a,$owner_uid)) {
-                                       if ($link_item['last-child']) {
-                                               $comments .= replace_macros($cmnt_tpl,array(
-                                                       '$return_path' => '',
-                                                       '$jsreload' => $return_url,
-                                                       '$type' => 'wall-comment',
-                                                       '$id' => $link_item['id'],
-                                                       '$parent' => $link_item['id'],
-                                                       '$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)
-                                               ));
-                                       }
+                               if (($can_post || can_write_wall($a,$owner_uid)) && $link_item['last-child']) {
+                                       $comments .= replace_macros($cmnt_tpl,array(
+                                               '$return_path' => '',
+                                               '$jsreload' => $return_url,
+                                               '$type' => 'wall-comment',
+                                               '$id' => $link_item['id'],
+                                               '$parent' => $link_item['id'],
+                                               '$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)
+                                       ));
                                }
                        }
 
@@ -1686,30 +1667,27 @@ function photos_content(App $a) {
                                        builtin_activity_puller($item, $conv_responses);
                                }
 
-                               $like    = ((x($conv_responses['like'],$link_item['uri'])) ? format_like($conv_responses['like'][$link_item['uri']],$conv_responses['like'][$link_item['uri'] . '-l'],'like',$link_item['id']) : '');
-                               $dislike = ((x($conv_responses['dislike'],$link_item['uri'])) ? format_like($conv_responses['dislike'][$link_item['uri']],$conv_responses['dislike'][$link_item['uri'] . '-l'],'dislike',$link_item['id']) : '');
-
-                               /// @TODO merge into one if() ?
-                               if ($can_post || can_write_wall($a,$owner_uid)) {
-                                       if ($link_item['last-child']) {
-                                               $comments .= replace_macros($cmnt_tpl,array(
-                                                       '$return_path' => '',
-                                                       '$jsreload' => $return_url,
-                                                       '$type' => 'wall-comment',
-                                                       '$id' => $link_item['id'],
-                                                       '$parent' => $link_item['id'],
-                                                       '$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)
-                                               ));
-                                       }
+                               $like    = ((x($conv_responses['like'],$link_item['uri'])) ? format_like($conv_responses['like'][$link_item['uri']],$conv_responses['like'][$link_item['uri'] . '-l'], 'like',$link_item['id']) : '');
+                               $dislike = ((x($conv_responses['dislike'],$link_item['uri'])) ? format_like($conv_responses['dislike'][$link_item['uri']],$conv_responses['dislike'][$link_item['uri'] . '-l'], 'dislike',$link_item['id']) : '');
+
+                               if (($can_post || can_write_wall($a, $owner_uid)) && $link_item['last-child']) {
+                                       $comments .= replace_macros($cmnt_tpl,array(
+                                               '$return_path' => '',
+                                               '$jsreload' => $return_url,
+                                               '$type' => 'wall-comment',
+                                               '$id' => $link_item['id'],
+                                               '$parent' => $link_item['id'],
+                                               '$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)
+                                       ));
                                }
 
 
@@ -1772,27 +1750,24 @@ function photos_content(App $a) {
                                                '$comment' => $comment
                                        ));
 
-                                       /// @TODO merge into one if() ?
-                                       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)
-                                                       ));
-                                               }
+                                       if (($can_post || can_write_wall($a, $owner_uid)) && $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)
+                                               ));
                                        }
                                }
                        }