]> git.mxchange.org Git - friendica.git/blobdiff - mod/fbrowser.php
*much* more usage of App::get_baseurl() instead of $a->get_baseurl() (coding conventi...
[friendica.git] / mod / fbrowser.php
index c4c62afa7b6055a478e980db1614a62bbcfcb727..6af97368fb9fa5097cff2bc62381c3b168f56335 100644 (file)
@@ -10,6 +10,7 @@ require_once('include/Photo.php');
 /**
  * @param App $a
  */
+/// @TODO & is missing or App ?
 function fbrowser_content($a){
 
        if (!local_user())
@@ -40,9 +41,9 @@ function fbrowser_content($a){
                                        dbesc('Contact Photos'),
                                        dbesc( t('Contact Photos'))
                                );
-                               // anon functions only from 5.3.0... meglio tardi che mai..
-                               $folder1 = function($el) use ($mode) {return array(bin2hex($el['album']),$el['album']);};
-                               $albums = array_map( $folder1 , $albums);
+
+                               function _map_folder1($el){return array(bin2hex($el['album']),$el['album']);};
+                               $albums = array_map( "_map_folder1" , $albums);
 
                        }
 
@@ -62,8 +63,8 @@ function fbrowser_content($a){
                                dbesc( t('Contact Photos'))
                        );
 
-                       function files1($rr){
-                               global $a;
+                       function _map_files1($rr){
+                               $a = get_app();
                                $types = Photo::supportedTypes();
                                $ext = $types[$rr['type']];
 
@@ -74,19 +75,27 @@ function fbrowser_content($a){
                                        $filename_e = $rr['filename'];
                                }
 
+                               // Take the largest picture that is smaller or equal 640 pixels
+                               $p = q("SELECT `scale` FROM `photo` WHERE `resource-id` = '%s' AND `height` <= 640 AND `width` <= 640 ORDER BY `resource-id`, `scale` LIMIT 1",
+                                       dbesc($rr['resource-id']));
+                               if ($p)
+                                       $scale = $p[0]["scale"];
+                               else
+                                       $scale = $rr['loq'];
+
                                return array(
-                                       $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '.' .$ext,
+                                       App::get_baseurl() . '/photos/' . $a->user['nickname'] . '/image/' . $rr['resource-id'],
                                        $filename_e,
-                                       $a->get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $rr['loq'] . '.'. $ext
+                                       App::get_baseurl() . '/photo/' . $rr['resource-id'] . '-' . $scale . '.'. $ext
                                );
                        }
-                       $files = array_map("files1", $r);
+                       $files = array_map("_map_files1", $r);
 
                        $tpl = get_markup_template($template_file);
 
                        $o =  replace_macros($tpl, array(
                                '$type' => 'image',
-                               '$baseurl' => $a->get_baseurl(),
+                               '$baseurl' => App::get_baseurl(),
                                '$path' => $path,
                                '$folders' => $albums,
                                '$files' =>$files,
@@ -102,7 +111,8 @@ function fbrowser_content($a){
                                        intval(local_user())
                                );
 
-                               function files2($rr){ global $a;
+                               function _map_files2($rr){
+                                       $a = get_app();
                                        list($m1,$m2) = explode("/",$rr['filetype']);
                                        $filetype = ( (file_exists("images/icons/$m1.png"))?$m1:"zip");
 
@@ -113,16 +123,15 @@ function fbrowser_content($a){
                                                $filename_e = $rr['filename'];
                                        }
 
-                                       return array( $a->get_baseurl() . '/attach/' . $rr['id'], $filename_e, $a->get_baseurl() . '/images/icons/16/' . $filetype . '.png');
+                                       return array( App::get_baseurl() . '/attach/' . $rr['id'], $filename_e, App::get_baseurl() . '/images/icons/16/' . $filetype . '.png');
                                }
-                               $files = array_map("files2", $files);
-                               //echo "<pre>"; var_dump($files); killme();
+                               $files = array_map("_map_files2", $files);
 
 
                                $tpl = get_markup_template($template_file);
                                $o = replace_macros($tpl, array(
                                        '$type' => 'file',
-                                       '$baseurl' => $a->get_baseurl(),
+                                       '$baseurl' => App::get_baseurl(),
                                        '$path' => array( array( "", t("Files")) ),
                                        '$folders' => false,
                                        '$files' =>$files,