]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
More generalized method for calculating Atom rel="self" links
authorZach Copley <zach@status.net>
Fri, 12 Mar 2010 01:40:52 +0000 (01:40 +0000)
committerZach Copley <zach@status.net>
Fri, 12 Mar 2010 01:40:52 +0000 (01:40 +0000)
actions/apitimelinegroup.php
actions/apitimelineuser.php
lib/apiaction.php

index c4f8cbc653b4556b27b543bb78a53d293b74295d..da816c40a9063141a8b567270ab0872e1e82898b 100644 (file)
@@ -107,13 +107,7 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
         // We'll pull common formatting out of this for other formats
         $atom = new AtomGroupNoticeFeed($this->group);
 
-        // Calculate self link
-        $id = $this->arg('id');
-        $aargs = array('format' => $this->format);
-        if (!empty($id)) {
-            $aargs['id'] = $id;
-        }
-        $self = $this->getSelfUri('ApiTimelineGroup', $aargs);
+        $self = $this->getSelfUri();
 
         switch($this->format) {
         case 'xml':
index 5c4bcace47862d1c780ca2d5af1a88098f72526c..11431a82ca9231658ccf0ea8d82ec693905354e3 100644 (file)
@@ -122,13 +122,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
             array('nickname' => $this->user->nickname)
         );
 
-        // Calculate self link
-        $id = $this->arg('id');
-        $aargs = array('format' => $this->format);
-        if (!empty($id)) {
-            $aargs['id'] = $id;
-        }
-        $self = $this->getSelfUri('ApiTimelineUser', $aargs);
+        $self = $this->getSelfUri();
 
         // FriendFeed's SUP protocol
         // Also added RSS and Atom feeds
index cef5d1c1e8e47a8af12ecdcd0a8c8d688bd13e92..a01809ed98b4fa490c455798430da2863fa218f8 100644 (file)
@@ -1358,8 +1358,22 @@ class ApiAction extends Action
         }
     }
 
-    function getSelfUri($action, $aargs)
+    /**
+     * Calculate the complete URI that called up this action.  Used for
+     * Atom rel="self" links.  Warning: this is funky.
+     *
+     * @return string URL    a URL suitable for rel="self" Atom links
+     */
+    function getSelfUri()
     {
+        $action = mb_substr(get_class($this), 0, -6); // remove 'Action'
+
+        $id = $this->arg('id');
+        $aargs = array('format' => $this->format);
+        if (!empty($id)) {
+            $aargs['id'] = $id;
+        }
+
         parse_str($_SERVER['QUERY_STRING'], $params);
         $pstring = '';
         if (!empty($params)) {