]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/SubMirror/actions/addmirror.php
Merge remote-tracking branch 'evan/blogplugin' into newblogplugin
[quix0rs-gnu-social.git] / plugins / SubMirror / actions / addmirror.php
index 8c3a9740f3cd3528dd051ae596c621b362717070..0031cf1bf4735b17833c620b743bd52a873f5bae 100644 (file)
@@ -59,17 +59,35 @@ class AddMirrorAction extends BaseMirrorAction
     function prepare($args)
     {
         parent::prepare($args);
-        $this->feedurl = $this->validateFeedUrl($this->trimmed('feedurl'));
+        $feedurl = $this->getFeedUrl();
+        $this->feedurl = $this->validateFeedUrl($feedurl);
         $this->profile = $this->profileForFeed($this->feedurl);
         return true;
     }
 
+    function getFeedUrl()
+    {
+        $provider = $this->trimmed('provider');
+        switch ($provider) {
+        case 'feed':
+            return $this->trimmed('feedurl');
+        case 'twitter':
+            $screenie = $this->trimmed('screen_name');
+            $base = 'http://api.twitter.com/1/statuses/user_timeline.atom?screen_name=';
+            return $base . urlencode($screenie);
+        default:
+            // TRANS: Exception thrown when a feed provider could not be recognised.
+            throw new Exception(_m('Internal form error: Unrecognized feed provider.'));
+        }
+    }
+
     function saveMirror()
     {
         if ($this->oprofile->subscribe()) {
             SubMirror::saveMirror($this->user, $this->profile);
         } else {
-            $this->serverError(_m("Could not subscribe to feed."));
+            // TRANS: Exception thrown when a subscribing to a feed fails.
+            $this->serverError(_m('Could not subscribe to feed.'));
         }
     }
 }