]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Allow easy fetching of rel="me" values
authorMikael Nordfeldth <mmn@hethane.se>
Wed, 24 Feb 2016 15:42:54 +0000 (16:42 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Wed, 24 Feb 2016 15:42:54 +0000 (16:42 +0100)
classes/Profile.php

index 7aae98fb5f171e698ac73cb0dba13c8eab51e99d..a5e0d092dc473e56d671c0734ffc1efc1db3e135 100644 (file)
@@ -900,6 +900,31 @@ class Profile extends Managed_DataObject
         return parent::update($dataObject);
     }
 
+    public function getRelSelf()
+    {
+        return ['href' => $this->getUrl(),
+                'text' => common_config('site', 'name'),
+                'image' => Avatar::urlByProfile($this)];
+    }
+
+    // All the known rel="me", used for the IndieWeb audience
+    public function getRelMes()
+    {
+        $relMes = array();
+        try {
+            $relMes[] = $this->getRelSelf();
+        } catch (InvalidUrlException $e) {
+            // no valid profile URL available
+        }
+        if (common_valid_http_url($this->getHomepage())) {
+            $relMes[] = ['href' => $this->getHomepage(),
+                         'text' => _('Homepage'),
+                         'image' => null];
+        }
+        Event::handle('OtherAccountProfiles', array($this, &$relMes));
+        return $relMes;
+    }
+
     function delete($useWhere=false)
     {
         // just in case it hadn't been done before... (usually set before adding deluser to queue handling!)