]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Avatar.php
Restructure theme.php to define a class Theme
[quix0rs-gnu-social.git] / classes / Avatar.php
index db9d78e47fc1e8f2c137ac6eb9a67d707b2a15fb..cc7a6b64717ac5534c9aeeb9a473ad26dcf0f222 100644 (file)
@@ -55,19 +55,43 @@ class Avatar extends Memcached_DataObject
 
     static function path($filename)
     {
-        return INSTALLDIR . '/avatar/' . $filename;
+        $dir = common_config('avatar', 'dir');
+
+        if ($dir[strlen($dir)-1] != '/') {
+            $dir .= '/';
+        }
+
+        return $dir . $filename;
     }
 
     static function url($filename)
     {
-        return common_path('avatar/'.$filename);
+        $path = common_config('avatar', 'path');
+
+        if ($path[strlen($path)-1] != '/') {
+            $path .= '/';
+        }
+
+        if ($path[0] != '/') {
+            $path = '/'.$path;
+        }
+
+        $server = common_config('avatar', 'server');
+
+        if (empty($server)) {
+            $server = common_config('site', 'server');
+        }
+        common_debug('path = ' . $path);
+        // XXX: protocol
+
+        return 'http://'.$server.$path.$filename;
     }
 
     function displayUrl()
     {
         $server = common_config('avatar', 'server');
         if ($server) {
-            return 'http://'.$server.'/'.$this->filename;
+            return Avatar::url($this->filename);
         } else {
             return $this->url;
         }
@@ -78,6 +102,6 @@ class Avatar extends Memcached_DataObject
         static $sizenames = array(AVATAR_PROFILE_SIZE => 'profile',
                                   AVATAR_STREAM_SIZE => 'stream',
                                   AVATAR_MINI_SIZE => 'mini');
-        return theme_path('default-avatar-'.$sizenames[$size].'.png');
+        return Theme::path('default-avatar-'.$sizenames[$size].'.png');
     }
 }