]> git.mxchange.org Git - friendica.git/commitdiff
Added get_cached_avatar_image to App class for shared profile image access and reduce...
authorZvi ben Yaakov (a.k.a rdc) <coderzvi@infosoc.net>
Mon, 18 Jun 2012 18:12:13 +0000 (21:12 +0300)
committerfriendica <info@friendica.com>
Tue, 19 Jun 2012 23:05:37 +0000 (16:05 -0700)
boot.php

index 94714f85abe70e7e234a9ade77c73d8c4c4ad993..ab71c7e7df950384fc66f5997e44ced0e5ea62f5 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -332,6 +332,9 @@ if(! class_exists('App')) {
                private $curl_code;
                private $curl_headers;
 
+               private $cached_profile_image;
+               private $cached_profile_picdate;
+                                                       
                function __construct() {
 
                        global $default_timezone;
@@ -543,6 +546,28 @@ if(! class_exists('App')) {
                        return $this->curl_headers;
                }
 
+               function get_cached_avatar_image($avatar_image){
+                       if($this->cached_profile_image[$avatar_image])
+                               return $this->cached_profile_image[$avatar_image];
+
+                       $path_parts = explode("/",$avatar_image);
+                       $common_filename = $path_parts[count($path_parts)-1];
+
+                       if($this->cached_profile_picdate[$common_filename]){
+                               $this->cached_profile_image[$avatar_image] = $avatar_image . $this->cached_profile_picdate[$common_filename];
+                       } else {
+                               $r = q("SELECT `contact`.`avatar-date` AS picdate FROM `contact` WHERE `contact`.`thumb` like \"%%/%s\"",
+                                       $common_filename);
+                               if(! count($r)){
+                                       $this->cached_profile_image[$avatar_image] = $avatar_image;
+                               } else {
+                                       $this->cached_profile_picdate[$common_filename] = "?rev=" . urlencode($r[0]['picdate']);
+                                       $this->cached_profile_image[$avatar_image] = $avatar_image . $this->cached_profile_picdate[$common_filename];
+                               }
+                       }
+                       return $this->cached_profile_image[$avatar_image];
+               }
+
 
        }
 }