]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
made the input-form switcher work, kinda
authorEvan Prodromou <evan@status.net>
Sun, 6 Mar 2011 22:27:03 +0000 (17:27 -0500)
committerEvan Prodromou <evan@status.net>
Mon, 7 Mar 2011 08:34:20 +0000 (03:34 -0500)
lib/action.php
lib/microappplugin.php
plugins/Bookmark/BookmarkPlugin.php

index 31e52dfcf26af0c713403949e89c5a5a49565bbd..a049fec97c8994423cda6b46a190aad84d876b63 100644 (file)
@@ -646,8 +646,60 @@ class Action extends HTMLOutputter // lawsuit
      */
     function showNoticeForm()
     {
-        $notice_form = new NoticeForm($this);
-        $notice_form->show();
+        $tabs = array('status' => _('Status'));
+
+        $this->elementStart('div', 'input_forms');
+
+        if (Event::handle('StartShowEntryForms', array(&$tabs))) {
+
+            $this->elementStart('ul', array('class' => 'nav',
+                                            'id' => 'input_form_nav'));
+
+            foreach ($tabs as $tag => $title) {
+
+                $attrs = array('id' => 'input_form_nav_'.$title);
+
+                if ($tag == 'status') {
+                    $attrs['class'] = 'current';
+                }
+
+                $this->elementStart('li', $attrs);
+
+                $this->element('a',
+                               array('href' => 'javascript:switchInputFormTab("'.$tag.'")'),
+                               $title);
+                $this->elementEnd('li');
+            }
+
+            $this->elementEnd('ul');
+
+            foreach ($tabs as $tag => $title) {
+
+                $attrs = array('class' => 'input_form',
+                               'id' => 'input_form_'.$tag);
+
+                if ($tag == 'status') {
+                    $attrs['class'] .= ' active';
+                } else {
+                    $attrs['class'] .= ' inactive';
+                }
+
+                $this->elementStart('div', $attrs);
+
+                $form = null;
+
+                if (Event::handle('StartMakeEntryForm', array($tag, $this, &$form))) {
+                    if ($tag == 'status') {
+                        $form = new NoticeForm($this);
+                    }
+                    Event::handle('EndMakeEntryForm', array($tag, $this, $form));
+                }
+
+                if (!empty($form)) {
+                    $form->show();
+                }
+            }
+        }
     }
 
     /**
index 1cdbe965e6c043a745a1a604cf349c9e5020f585..0b02f5da52ea1d991c16ed7ff9d46b20d464451e 100644 (file)
@@ -54,7 +54,7 @@ abstract class MicroAppPlugin extends Plugin
     abstract function appTitle();
     abstract function tag();
     abstract function types();
-    abstract function saveNoticeFromActivity($activity, $actor);
+    abstract function saveNoticeFromActivity($activity, $actor, $options);
     abstract function activityObjectFromNotice($notice);
     abstract function showNotice($notice, $out);
     abstract function entryForm($out);
@@ -157,6 +157,13 @@ abstract class MicroAppPlugin extends Plugin
                 throw new ClientException(_('Can\'t get author for activity.'));
             }
 
+            $object = $activity->objects[0];
+
+            $options = array('uri' => $object->id,
+                             'url' => $object->link,
+                             'is_local' => Notice::REMOTE_OMB,
+                             'source' => 'ostatus');
+            
             $this->saveNoticeFromActivity($activity, $actor);
 
             return false;
@@ -196,7 +203,7 @@ abstract class MicroAppPlugin extends Plugin
                 if (!in_array($uri, $activity->context->attention) &&
                     (empty($original) ||
                      $original->profile_id != $target->id)) {
-                    throw new ClientException(_("Bookmark not posted ".
+                    throw new ClientException(_("Object not posted ".
                                                 "to this user."));
                 }
             } else {
@@ -206,7 +213,14 @@ abstract class MicroAppPlugin extends Plugin
 
             $actor = Ostatus_profile::ensureActivityObjectProfile($activity->actor);
 
-            $this->saveNoticeFromActivity($activity, $actor);
+            $object = $activity->objects[0];
+
+            $options = array('uri' => $object->id,
+                             'url' => $object->link,
+                             'is_local' => Notice::REMOTE_OMB,
+                             'source' => 'ostatus');
+
+            $this->saveNoticeFromActivity($activity, $actor, $options);
 
             return false;
         }
@@ -258,8 +272,8 @@ abstract class MicroAppPlugin extends Plugin
 
             $obj = $activity->objects[0];
 
-            $options = array('uri' => $bookmark->id,
-                             'url' => $bookmark->link,
+            $options = array('uri' => $object->id,
+                             'url' => $object->link,
                              'source' => 'restore');
 
             $saved = $this->saveNoticeFromActivity($activity,
@@ -275,4 +289,22 @@ abstract class MicroAppPlugin extends Plugin
 
         return true;
     }
+
+    function onStartShowEntryForms(&$tabs)
+    {
+        $tabs[$this->tag()] = $this->appTitle();
+        return true;
+    }
+
+    function onStartMakeEntryForm($tag, $out, &$form)
+    {
+        $this->log(LOG_INFO, "onStartMakeEntryForm() called for tag '$tag'");
+
+        if ($tag == $this->tag()) {
+            $form = $this->entryForm($out);
+            return false;
+        }
+
+        return true;
+    }
 }
index c3ff17c4e9aba0713662344a9b21fd6ebfdbd3cb..1ef5f5c0e32db0eadd56dff66e166ad2700028f5 100644 (file)
@@ -372,10 +372,8 @@ class BookmarkPlugin extends MicroAppPlugin
      * @return Notice resulting notice
      */
 
-    function saveNoticeFromActivity($activity, $profile)
+    function saveNoticeFromActivity($activity, $profile, $options=array())
     {
-        $options = array();
-
         $bookmark = $activity->objects[0];
 
         $relLinkEls = ActivityUtils::getLinks($bookmark->element, 'related');
@@ -622,4 +620,13 @@ class BookmarkPlugin extends MicroAppPlugin
         return new BookmarkForm($out);
     }
 
+    function tag()
+    {
+        return 'bookmark';
+    }
+
+    function appTitle()
+    {
+        return _m('Bookmark');
+    }
 }