]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/actions/ostatustag.php
newnotice action always returns the notice's URL
[quix0rs-gnu-social.git] / plugins / OStatus / actions / ostatustag.php
index 85ead81ca2f8f70c0b43fed80b8a52d8d0d4dc17..fa999fe09a759b6b4d70d3fc5173e669d764bba9 100644 (file)
@@ -27,7 +27,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
 
 class OStatusTagAction extends OStatusInitAction
 {
-
     var $nickname;
     var $profile;
     var $err;
@@ -37,8 +36,8 @@ class OStatusTagAction extends OStatusInitAction
         parent::prepare($args);
 
         if (common_logged_in()) {
-            $this->clientError(_m('You can use the local tagging!'));
-            return false;
+            // TRANS: Client error displayed when trying to list a local object as if it is remote.
+            $this->clientError(_m('You can use the local list functionality!'));
         }
 
         $this->nickname = $this->trimmed('nickname');
@@ -51,8 +50,10 @@ class OStatusTagAction extends OStatusInitAction
 
     function showContent()
     {
-        $header = sprintf(_m('Tag %s'), $this->nickname);
-        $submit = _m('Go');
+        // TRANS: Header for listing a remote object. %s is a remote object's name.
+        $header = sprintf(_m('List %s'), $this->nickname);
+        // TRANS: Button text to list a remote object.
+        $submit = _m('BUTTON','Go');
         $this->elementStart('form', array('id' => 'form_ostatus_connect',
                                           'method' => 'post',
                                           'class' => 'form_settings',
@@ -63,12 +64,16 @@ class OStatusTagAction extends OStatusInitAction
 
         $this->elementStart('ul', 'form_data');
         $this->elementStart('li', array('id' => 'ostatus_nickname'));
+        // TRANS: Field label.
         $this->input('nickname', _m('User nickname'), $this->nickname,
-                     _m('Nickname of the user you want to tag'));
+                     // TRANS: Field title.
+                     _m('Nickname of the user you want to list.'));
         $this->elementEnd('li');
         $this->elementStart('li', array('id' => 'ostatus_profile'));
+        // TRANS: Field label.
         $this->input('profile', _m('Profile Account'), $this->profile,
-                     _m('Your account id (i.e. user@identi.ca)'));
+                     // TRANS: Field title.
+                     _m('Your account id (for example user@example.com).'));
         $this->elementEnd('li');
         $this->elementEnd('ul');
         $this->submit('submit', $submit);
@@ -81,21 +86,21 @@ class OStatusTagAction extends OStatusInitAction
         $target_profile = $this->targetProfile();
 
         $disco = new Discovery;
-        $result = $disco->lookup($acct);
-        if (!$result) {
-            $this->clientError(_m("Couldn't look up OStatus account profile."));
-        }
-
-        foreach ($result->links as $link) {
-            if ($link['rel'] == 'http://ostatus.org/schema/1.0/tag') {
-                // We found a URL - let's redirect!
-                $url = Discovery::applyTemplate($link['template'], $target_profile);
-                common_log(LOG_INFO, "Sending remote subscriber $acct to $url");
-                common_redirect($url, 303);
+        $xrd = $disco->lookup($acct);
+
+        $link = $xrd->get('http://ostatus.org/schema/1.0/tag');
+        if (!is_null($link)) {
+            // We found a URL - let's redirect!
+            if (!empty($link->template)) {
+                $url = Discovery::applyTemplate($link->template, $target_profile);
+            } else {
+                $url = $link->href;
             }
-
+            common_log(LOG_INFO, "Sending remote subscriber $acct to $url");
+            common_redirect($url, 303);
         }
-        $this->clientError(_m("Couldn't confirm remote profile address."));
+        // TRANS: Client error displayed when remote profile address could not be confirmed.
+        $this->clientError(_m('Could not confirm remote profile address.'));
     }
 
     function connectProfile($subscriber_profile)
@@ -112,6 +117,7 @@ class OStatusTagAction extends OStatusInitAction
 
     function title()
     {
-      return _m('OStatus people tag');  
+      // TRANS: Title for an OStatus list.
+      return _m('OStatus list');  
     }
 }