]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Separating classes into files and stronger typing
authorMikael Nordfeldth <mmn@hethane.se>
Wed, 6 Jan 2016 00:30:12 +0000 (01:30 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Wed, 6 Jan 2016 00:30:12 +0000 (01:30 +0100)
actions/subscriptions.php
lib/subscriptionlist.php
lib/subscriptionlistitem.php [new file with mode: 0644]
lib/subscriptionslist.php [new file with mode: 0644]
lib/subscriptionslistitem.php [new file with mode: 0644]

index b5734b3747ee38900339a480fc2858b25190a1c7..6e9e163d332afce567aa394ff1a45b044aa15b3a 100644 (file)
@@ -154,71 +154,3 @@ class SubscriptionsAction extends GalleryAction
                                       $this->target->getNickname())));
     }
 }
-
-// XXX SubscriptionsList and SubscriptionList are dangerously close
-
-class SubscriptionsList extends SubscriptionList
-{
-    function newListItem($profile)
-    {
-        return new SubscriptionsListItem($profile, $this->owner, $this->action);
-    }
-}
-
-class SubscriptionsListItem extends SubscriptionListItem
-{
-    function showOwnerControls()
-    {
-        $sub = Subscription::pkeyGet(array('subscriber' => $this->owner->id,
-                                           'subscribed' => $this->profile->id));
-        if (!$sub) {
-            return;
-        }
-
-        $transports = array();
-        Event::handle('GetImTransports', array(&$transports));
-        if (!$transports && !common_config('sms', 'enabled')) {
-            return;
-        }
-
-        $this->out->elementStart('form', array('id' => 'subedit-' . $this->profile->id,
-                                          'method' => 'post',
-                                          'class' => 'form_subscription_edit',
-                                          'action' => common_local_url('subedit')));
-        $this->out->hidden('token', common_session_token());
-        $this->out->hidden('profile', $this->profile->id);
-        if ($transports) {
-            $attrs = array('name' => 'jabber',
-                           'type' => 'checkbox',
-                           'class' => 'checkbox',
-                           'id' => 'jabber-'.$this->profile->id);
-            if ($sub->jabber) {
-                $attrs['checked'] = 'checked';
-            }
-
-            $this->out->element('input', $attrs);
-            // TRANS: Checkbox label for enabling IM messages for a profile in a subscriptions list.
-            $this->out->element('label', array('for' => 'jabber-'.$this->profile->id), _m('LABEL','IM'));
-        } else {
-            $this->out->hidden('jabber', $sub->jabber);
-        }
-        if (common_config('sms', 'enabled')) {
-            $attrs = array('name' => 'sms',
-                           'type' => 'checkbox',
-                           'class' => 'checkbox',
-                           'id' => 'sms-'.$this->profile->id);
-            if ($sub->sms) {
-                $attrs['checked'] = 'checked';
-            }
-
-            $this->out->element('input', $attrs);
-            // TRANS: Checkbox label for enabling SMS messages for a profile in a subscriptions list.
-            $this->out->element('label', array('for' => 'sms-'.$this->profile->id), _('SMS'));
-        } else {
-            $this->out->hidden('sms', $sub->sms);
-        }
-        // TRANS: Save button for settings for a profile in a subscriptions list.
-        $this->out->submit('save', _m('BUTTON','Save'));
-        $this->out->elementEnd('form');
-    }
-}
index aad1f1230b1bdf296bca339821c8233dec45d746..cc12d7efe3c15448a27a940e5a1a0435a241a3db 100644 (file)
@@ -56,44 +56,3 @@ class SubscriptionList extends ProfileList
         return new SubscriptionListItem($profile, $this->owner, $this->action);
     }
 }
-
-class SubscriptionListItem extends ProfileListItem
-{
-    /** Owner of this list */
-    var $owner = null;
-
-    function __construct($profile, $owner, $action)
-    {
-        parent::__construct($profile, $action);
-
-        $this->owner = $owner;
-    }
-
-    function showProfile()
-    {
-        $this->startProfile();
-        $this->showAvatar($this->profile);
-        $this->showNickname();
-        $this->showFullName();
-        $this->showLocation();
-        $this->showHomepage();
-        $this->showBio();
-        // Relevant portion!
-        $this->showTags();
-        if ($this->isOwn()) {
-            $this->showOwnerControls();
-        }
-        $this->endProfile();
-    }
-
-    function showOwnerControls()
-    {
-        // pass
-    }
-
-    function isOwn()
-    {
-        $user = common_current_user();
-        return (!empty($user) && ($this->owner->id == $user->id));
-    }
-}
diff --git a/lib/subscriptionlistitem.php b/lib/subscriptionlistitem.php
new file mode 100644 (file)
index 0000000..e5f832a
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+
+if (!defined('GNUSOCIAL')) { exit(1); }
+
+class SubscriptionListItem extends ProfileListItem
+{
+    /** Owner of this list */
+    var $owner = null;
+
+    function __construct(Profile $profile, $owner, $action)
+    {
+        parent::__construct($profile, $action);
+
+        $this->owner = $owner;
+    }
+
+    function showProfile()
+    {
+        $this->startProfile();
+        $this->showAvatar($this->profile);
+        $this->showNickname();
+        $this->showFullName();
+        $this->showLocation();
+        $this->showHomepage();
+        $this->showBio();
+        // Relevant portion!
+        $this->showTags();
+        if ($this->isOwn()) {
+            $this->showOwnerControls();
+        }
+        $this->endProfile();
+    }
+
+    function showOwnerControls()
+    {
+        // pass
+    }
+
+    function isOwn()
+    {
+        $user = common_current_user();
+        return (!empty($user) && ($this->owner->id == $user->id));
+    }
+}
diff --git a/lib/subscriptionslist.php b/lib/subscriptionslist.php
new file mode 100644 (file)
index 0000000..46de52b
--- /dev/null
@@ -0,0 +1,13 @@
+<?php
+
+if (!defined('GNUSOCIAL')) { exit(1); }
+
+// XXX SubscriptionsList and SubscriptionList are dangerously close
+
+class SubscriptionsList extends SubscriptionList
+{
+    function newListItem(Profile $profile)
+    {
+        return new SubscriptionsListItem($profile, $this->owner, $this->action);
+    }
+}
diff --git a/lib/subscriptionslistitem.php b/lib/subscriptionslistitem.php
new file mode 100644 (file)
index 0000000..584b731
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+
+if (!defined('GNUSOCIAL')) { exit(1); }
+
+class SubscriptionsListItem extends SubscriptionListItem
+{
+    function showOwnerControls()
+    {
+        $sub = Subscription::pkeyGet(array('subscriber' => $this->owner->id,
+                                           'subscribed' => $this->profile->id));
+        if (!$sub) {
+            return;
+        }
+
+        $transports = array();
+        Event::handle('GetImTransports', array(&$transports));
+        if (!$transports && !common_config('sms', 'enabled')) {
+            return;
+        }
+
+        $this->out->elementStart('form', array('id' => 'subedit-' . $this->profile->id,
+                                          'method' => 'post',
+                                          'class' => 'form_subscription_edit',
+                                          'action' => common_local_url('subedit')));
+        $this->out->hidden('token', common_session_token());
+        $this->out->hidden('profile', $this->profile->id);
+        if ($transports) {
+            $attrs = array('name' => 'jabber',
+                           'type' => 'checkbox',
+                           'class' => 'checkbox',
+                           'id' => 'jabber-'.$this->profile->id);
+            if ($sub->jabber) {
+                $attrs['checked'] = 'checked';
+            }
+
+            $this->out->element('input', $attrs);
+            // TRANS: Checkbox label for enabling IM messages for a profile in a subscriptions list.
+            $this->out->element('label', array('for' => 'jabber-'.$this->profile->id), _m('LABEL','IM'));
+        } else {
+            $this->out->hidden('jabber', $sub->jabber);
+        }
+        if (common_config('sms', 'enabled')) {
+            $attrs = array('name' => 'sms',
+                           'type' => 'checkbox',
+                           'class' => 'checkbox',
+                           'id' => 'sms-'.$this->profile->id);
+            if ($sub->sms) {
+                $attrs['checked'] = 'checked';
+            }
+
+            $this->out->element('input', $attrs);
+            // TRANS: Checkbox label for enabling SMS messages for a profile in a subscriptions list.
+            $this->out->element('label', array('for' => 'sms-'.$this->profile->id), _('SMS'));
+        } else {
+            $this->out->hidden('sms', $sub->sms);
+        }
+        // TRANS: Save button for settings for a profile in a subscriptions list.
+        $this->out->submit('save', _m('BUTTON','Save'));
+        $this->out->elementEnd('form');
+    }
+}