]> git.mxchange.org Git - friendica.git/commitdiff
Make variables non static
authorMichael <heluecht@pirati.ca>
Sat, 9 Sep 2023 12:48:51 +0000 (12:48 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 9 Sep 2023 12:48:51 +0000 (12:48 +0000)
src/Module/Conversation/Channel.php
src/Module/Conversation/Community.php
src/Module/Conversation/Network.php
src/Module/Conversation/Timeline.php
src/Module/Update/Channel.php
src/Module/Update/Network.php

index d32d9708c09e5e8efc9b90f1e8c94e45c2861224..ae570ba1deb42686f5fa3ae03cb445cf58fa517c 100644 (file)
@@ -95,21 +95,21 @@ class Channel extends Timeline
 
                        Nav::setSelected('channel');
 
-                       $this->page['aside'] .= Widget::accountTypes('channel/' . self::$selectedTab, self::$accountTypeString);
+                       $this->page['aside'] .= Widget::accountTypes('channel/' . $this->selectedTab, $this->accountTypeString);
 
-                       if (!in_array(self::$selectedTab, [TimelineEntity::FOLLOWERS, TimelineEntity::FORYOU]) && $this->config->get('system', 'community_no_sharer')) {
+                       if (!in_array($this->selectedTab, [TimelineEntity::FOLLOWERS, TimelineEntity::FORYOU]) && $this->config->get('system', 'community_no_sharer')) {
                                $this->page['aside'] .= $this->getNoSharerWidget('channel');
                        }
 
                        if (Feature::isEnabled($this->session->getLocalUserId(), 'trending_tags')) {
-                               $this->page['aside'] .= TrendingTags::getHTML(self::$selectedTab);
+                               $this->page['aside'] .= TrendingTags::getHTML($this->selectedTab);
                        }
 
                        // We need the editor here to be able to reshare an item.
                        $o .= $this->conversation->statusEditor([], 0, true);
                }
 
-               if ($this->timeline->isChannel(self::$selectedTab)) {
+               if ($this->timeline->isChannel($this->selectedTab)) {
                        $items = $this->getChannelItems();
                        $order = 'created';
                } else {
@@ -129,7 +129,7 @@ class Channel extends Timeline
                        $this->args->getQueryString(),
                        $items[0][$order],
                        $items[count($items) - 1][$order],
-                       self::$itemsPerPage
+                       $this->itemsPerPage
                );
 
                if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'infinite_scroll')) {
@@ -151,14 +151,14 @@ class Channel extends Timeline
        {
                parent::parseRequest($request);
 
-               if (!self::$selectedTab) {
-                       self::$selectedTab = TimelineEntity::FORYOU;
+               if (!$this->selectedTab) {
+                       $this->selectedTab = TimelineEntity::FORYOU;
                }
 
-               if (!$this->timeline->isChannel(self::$selectedTab) && !$this->timeline->isCommunity(self::$selectedTab)) {
+               if (!$this->timeline->isChannel($this->selectedTab) && !$this->timeline->isCommunity($this->selectedTab)) {
                        throw new HTTPException\BadRequestException($this->l10n->t('Channel not available.'));
                }
 
-               self::$max_id = $request['last_created'] ?? self::$max_id;
+               $this->max_id = $request['last_created'] ?? $this->max_id;
        }
 }
index e5ec2bd659039cc2c9d141eface044d3c1f53ebf..adaf5bc111588f6fb91bb5c6e89318e7b113d798 100644 (file)
@@ -58,7 +58,7 @@ class Community extends Timeline
        const GLOBAL           = 1;
        const LOCAL_AND_GLOBAL = 2;
 
-       protected static $page_style;
+       protected $pageStyle;
 
        /** @var TimelineFactory */
        protected $timeline;
@@ -87,7 +87,7 @@ class Community extends Timeline
                $o = Renderer::replaceMacros($t, [
                        '$content' => '',
                        '$header' => '',
-                       '$show_global_community_hint' => (self::$selectedTab == TimelineEntity::GLOBAL) && $this->config->get('system', 'show_global_community_hint'),
+                       '$show_global_community_hint' => ($this->selectedTab == TimelineEntity::GLOBAL) && $this->config->get('system', 'show_global_community_hint'),
                        '$global_community_hint' => $this->l10n->t("This community stream shows all public posts received by this node. They may not reflect the opinions of this node’s users.")
                ]);
 
@@ -103,14 +103,14 @@ class Community extends Timeline
 
                        Nav::setSelected('community');
 
-                       $this->page['aside'] .= Widget::accountTypes('community/' . self::$selectedTab, self::$accountTypeString);
+                       $this->page['aside'] .= Widget::accountTypes('community/' . $this->selectedTab, $this->accountTypeString);
 
                        if ($this->session->getLocalUserId() && $this->config->get('system', 'community_no_sharer')) {
                                $this->page['aside'] .= $this->getNoSharerWidget('community');
                        }
 
                        if (Feature::isEnabled($this->session->getLocalUserId(), 'trending_tags')) {
-                               $this->page['aside'] .= TrendingTags::getHTML(self::$selectedTab);
+                               $this->page['aside'] .= TrendingTags::getHTML($this->selectedTab);
                        }
 
                        // We need the editor here to be able to reshare an item.
@@ -133,7 +133,7 @@ class Community extends Timeline
                        $this->args->getQueryString(),
                        $items[0]['commented'],
                        $items[count($items) - 1]['commented'],
-                       self::$itemsPerPage
+                       $this->itemsPerPage
                );
 
                if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'infinite_scroll')) {
@@ -159,36 +159,36 @@ class Community extends Timeline
                        throw new HTTPException\ForbiddenException($this->l10n->t('Public access denied.'));
                }
 
-               self::$page_style = $this->config->get('system', 'community_page_style');
+               $this->pageStyle = $this->config->get('system', 'community_page_style');
 
-               if (self::$page_style == self::DISABLED) {
+               if ($this->pageStyle == self::DISABLED) {
                        throw new HTTPException\ForbiddenException($this->l10n->t('Access denied.'));
                }
 
-               if (!self::$selectedTab) {
+               if (!$this->selectedTab) {
                        if (!empty($this->config->get('system', 'singleuser'))) {
                                // On single user systems only the global page does make sense
-                               self::$selectedTab = TimelineEntity::GLOBAL;
+                               $this->selectedTab = TimelineEntity::GLOBAL;
                        } else {
                                // When only the global community is allowed, we use this as default
-                               self::$selectedTab = self::$page_style == self::GLOBAL ? TimelineEntity::GLOBAL : TimelineEntity::LOCAL;
+                               $this->selectedTab = $this->pageStyle == self::GLOBAL ? TimelineEntity::GLOBAL : TimelineEntity::LOCAL;
                        }
                }
 
-               if (!$this->timeline->isCommunity(self::$selectedTab)) {
+               if (!$this->timeline->isCommunity($this->selectedTab)) {
                        throw new HTTPException\BadRequestException($this->l10n->t('Community option not available.'));
                }
 
                // Check if we are allowed to display the content to visitors
                if (!$this->session->isAuthenticated()) {
-                       $available = self::$page_style == self::LOCAL_AND_GLOBAL;
+                       $available = $this->pageStyle == self::LOCAL_AND_GLOBAL;
 
                        if (!$available) {
-                               $available = (self::$page_style == self::LOCAL) && (self::$selectedTab == TimelineEntity::LOCAL);
+                               $available = ($this->pageStyle == self::LOCAL) && ($this->selectedTab == TimelineEntity::LOCAL);
                        }
 
                        if (!$available) {
-                               $available = (self::$page_style == self::GLOBAL) && (self::$selectedTab == TimelineEntity::GLOBAL);
+                               $available = ($this->pageStyle == self::GLOBAL) && ($this->selectedTab == TimelineEntity::GLOBAL);
                        }
 
                        if (!$available) {
@@ -196,6 +196,6 @@ class Community extends Timeline
                        }
                }
 
-               self::$max_id = $request['last_commented'] ?? self::$max_id;
+               $this->max_id = $request['last_commented'] ?? $this->max_id;
        }
 }
index cd24a7d77c5a9919e001eec9233a9a7dbe4ab50b..cbe15e3b5bd4ab0c7a84d741e7ad4e3e6798b80a 100644 (file)
@@ -116,30 +116,30 @@ class Network extends Timeline
 
                $module = 'network';
 
-               $this->page['aside'] .= Widget::accountTypes($module, self::$accountTypeString);
+               $this->page['aside'] .= Widget::accountTypes($module, $this->accountTypeString);
 
                $arr = ['query' => $this->args->getQueryString()];
                Hook::callAll('network_content_init', $arr);
 
                $o = '';
 
-               if ($this->timeline->isChannel(self::$selectedTab)) {
-                       if (!in_array(self::$selectedTab, [TimelineEntity::FOLLOWERS, TimelineEntity::FORYOU]) && $this->config->get('system', 'community_no_sharer')) {
+               if ($this->timeline->isChannel($this->selectedTab)) {
+                       if (!in_array($this->selectedTab, [TimelineEntity::FOLLOWERS, TimelineEntity::FORYOU]) && $this->config->get('system', 'community_no_sharer')) {
                                $this->page['aside'] .= $this->getNoSharerWidget($module);
                        }
 
                        if (Feature::isEnabled($this->session->getLocalUserId(), 'trending_tags')) {
-                               $this->page['aside'] .= TrendingTags::getHTML(self::$selectedTab);
+                               $this->page['aside'] .= TrendingTags::getHTML($this->selectedTab);
                        }
 
                        $items = $this->getChannelItems();
-               } elseif ($this->timeline->isCommunity(self::$selectedTab)) {
+               } elseif ($this->timeline->isCommunity($this->selectedTab)) {
                        if ($this->session->getLocalUserId() && $this->config->get('system', 'community_no_sharer')) {
                                $this->page['aside'] .= $this->getNoSharerWidget($module);
                        }
 
                        if (Feature::isEnabled($this->session->getLocalUserId(), 'trending_tags')) {
-                               $this->page['aside'] .= TrendingTags::getHTML(self::$selectedTab);
+                               $this->page['aside'] .= TrendingTags::getHTML($this->selectedTab);
                        }
 
                        $items = $this->getCommunityItems();
@@ -152,7 +152,7 @@ class Network extends Timeline
                        $this->page['aside'] .= Widget::fileAs('filed', '');
 
                        // Fetch a page full of parent items for this page
-                       $params = ['limit' => self::$itemsPerPage];
+                       $params = ['limit' => $this->itemsPerPage];
                        $table = 'network-thread-view';
 
                        $items = $this->getItems($table, $params);
@@ -260,7 +260,7 @@ class Network extends Timeline
                                $this->args->getQueryString(),
                                $items[0][self::$order] ?? null,
                                $items[count($items) - 1][self::$order] ?? null,
-                               self::$itemsPerPage
+                               $this->itemsPerPage
                        );
 
                        $o .= $pager->renderMinimal(count($items));
@@ -316,51 +316,51 @@ class Network extends Timeline
 
                self::$groupContactId = (int)($this->parameters['contact_id'] ?? 0);
 
-               if (!self::$selectedTab) {
-                       self::$selectedTab = self::getTimelineOrderBySession(DI::userSession(), $this->pConfig);
-               } elseif (!$this->timeline->isChannel(self::$selectedTab) && !$this->timeline->isCommunity(self::$selectedTab)) {
+               if (!$this->selectedTab) {
+                       $this->selectedTab = self::getTimelineOrderBySession(DI::userSession(), $this->pConfig);
+               } elseif (!$this->timeline->isChannel($this->selectedTab) && !$this->timeline->isCommunity($this->selectedTab)) {
                        throw new HTTPException\BadRequestException($this->l10n->t('Network feed not available.'));
                }
 
 
                if (!empty($request['star'])) {
-                       self::$selectedTab = TimelineEntity::STAR;
+                       $this->selectedTab = TimelineEntity::STAR;
                        self::$star = true;
                } else {
-                       self::$star = self::$selectedTab == TimelineEntity::STAR;
+                       self::$star = $this->selectedTab == TimelineEntity::STAR;
                }
 
                if (!empty($request['mention'])) {
-                       self::$selectedTab = TimelineEntity::MENTION;
+                       $this->selectedTab = TimelineEntity::MENTION;
                        self::$mention = true;
                } else {
-                       self::$mention = self::$selectedTab == TimelineEntity::MENTION;
+                       self::$mention = $this->selectedTab == TimelineEntity::MENTION;
                }
 
                if (!empty($request['order'])) {
-                       self::$selectedTab = $request['order'];
+                       $this->selectedTab = $request['order'];
                        self::$order = $request['order'];
                        self::$star = false;
                        self::$mention = false;
-               } elseif (in_array(self::$selectedTab, [TimelineEntity::RECEIVED, TimelineEntity::STAR])) {
+               } elseif (in_array($this->selectedTab, [TimelineEntity::RECEIVED, TimelineEntity::STAR])) {
                        self::$order = 'received';
-               } elseif ((self::$selectedTab == TimelineEntity::CREATED) || $this->timeline->isChannel(self::$selectedTab)) {
+               } elseif (($this->selectedTab == TimelineEntity::CREATED) || $this->timeline->isChannel($this->selectedTab)) {
                        self::$order = 'created';
                } else {
                        self::$order = 'commented';
                }
 
-               self::$selectedTab = self::$selectedTab ?? self::$order;
+               $this->selectedTab = $this->selectedTab ?? self::$order;
 
                // Prohibit combined usage of "star" and "mention"
-               if (self::$selectedTab == TimelineEntity::STAR) {
+               if ($this->selectedTab == TimelineEntity::STAR) {
                        self::$mention = false;
-               } elseif (self::$selectedTab == TimelineEntity::MENTION) {
+               } elseif ($this->selectedTab == TimelineEntity::MENTION) {
                        self::$star = false;
                }
 
-               $this->session->set('network-tab', self::$selectedTab);
-               $this->pConfig->set($this->session->getLocalUserId(), 'network.view', 'selected_tab', self::$selectedTab);
+               $this->session->set('network-tab', $this->selectedTab);
+               $this->pConfig->set($this->session->getLocalUserId(), 'network.view', 'selected_tab', $this->selectedTab);
 
                self::$network = $request['nets'] ?? '';
 
@@ -369,17 +369,17 @@ class Network extends Timeline
 
                switch (self::$order) {
                        case 'received':
-                               self::$max_id = $request['last_received'] ?? self::$max_id;
+                               $this->max_id = $request['last_received'] ?? $this->max_id;
                                break;
                        case 'created':
-                               self::$max_id = $request['last_created'] ?? self::$max_id;
+                               $this->max_id = $request['last_created'] ?? $this->max_id;
                                break;
                        case 'uriid':
-                               self::$max_id = $request['last_uriid'] ?? self::$max_id;
+                               $this->max_id = $request['last_uriid'] ?? $this->max_id;
                                break;
                        default:
                                self::$order = 'commented';
-                               self::$max_id = $request['last_commented'] ?? self::$max_id;
+                               $this->max_id = $request['last_commented'] ?? $this->max_id;
                }
        }
 
@@ -388,8 +388,8 @@ class Network extends Timeline
                $conditionFields['uid'] = $this->session->getLocalUserId();
                $conditionStrings = [];
 
-               if (!is_null(self::$accountType)) {
-                       $conditionFields['contact-type'] = self::$accountType;
+               if (!is_null($this->accountType)) {
+                       $conditionFields['contact-type'] = $this->accountType;
                }
 
                if (self::$star) {
@@ -418,45 +418,45 @@ class Network extends Timeline
                }
 
                // Currently only the order modes "received" and "commented" are in use
-               if (!empty(self::$item_uri_id)) {
-                       $conditionStrings = DBA::mergeConditions($conditionStrings, ['uri-id' => self::$item_uri_id]);
+               if (!empty($this->itemUriId)) {
+                       $conditionStrings = DBA::mergeConditions($conditionStrings, ['uri-id' => $this->itemUriId]);
                } else {
-                       if (isset(self::$max_id)) {
+                       if (isset($this->max_id)) {
                                switch (self::$order) {
                                        case 'received':
-                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` < ?", self::$max_id]);
+                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` < ?", $this->max_id]);
                                                break;
                                        case 'commented':
-                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`commented` < ?", self::$max_id]);
+                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`commented` < ?", $this->max_id]);
                                                break;
                                        case 'created':
-                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`created` < ?", self::$max_id]);
+                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`created` < ?", $this->max_id]);
                                                break;
                                        case 'uriid':
-                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`uri-id` < ?", self::$max_id]);
+                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`uri-id` < ?", $this->max_id]);
                                                break;
                                }
                        }
 
-                       if (isset(self::$min_id)) {
+                       if (isset($this->min_id)) {
                                switch (self::$order) {
                                        case 'received':
-                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` > ?", self::$min_id]);
+                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`received` > ?", $this->min_id]);
                                                break;
                                        case 'commented':
-                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`commented` > ?", self::$min_id]);
+                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`commented` > ?", $this->min_id]);
                                                break;
                                        case 'created':
-                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`created` > ?", self::$min_id]);
+                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`created` > ?", $this->min_id]);
                                                break;
                                        case 'uriid':
-                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`uri-id` > ?", self::$min_id]);
+                                               $conditionStrings = DBA::mergeConditions($conditionStrings, ["`uri-id` > ?", $this->min_id]);
                                                break;
                                }
                        }
                }
 
-               if (isset(self::$min_id) && !isset(self::$max_id)) {
+               if (isset($this->min_id) && !isset($this->max_id)) {
                        // min_id quirk: querying in reverse order with min_id gets the most recent rows, regardless of how close
                        // they are to min_id. We change the query ordering to get the expected data, and we need to reverse the
                        // order of the results.
@@ -468,7 +468,7 @@ class Network extends Timeline
                $items = DBA::selectToArray($table, [], DBA::mergeConditions($conditionFields, $conditionStrings), $params);
 
                // min_id quirk, continued
-               if (isset(self::$min_id) && !isset(self::$max_id)) {
+               if (isset($this->min_id) && !isset($this->max_id)) {
                        $items = array_reverse($items);
                }
 
index 881e974bd2379ac4287bbe3cd7b01938c80a515b..8f97a38d8db5e5a9b291822da961a529d37e1e14 100644 (file)
@@ -47,23 +47,21 @@ use Psr\Log\LoggerInterface;
 class Timeline extends BaseModule
 {
        /** @var string */
-       protected static $selectedTab;
+       protected $selectedTab;
        /** @var mixed */
-       protected static $min_id;
+       protected $min_id;
        /** @var mixed */
-       protected static $max_id;
+       protected $max_id;
        /** @var string */
-       protected static $accountTypeString;
+       protected $accountTypeString;
        /** @var int */
-       protected static $accountType;
+       protected $accountType;
        /** @var int */
-       protected static $item_id;
+       protected $itemUriId;
        /** @var int */
-       protected static $item_uri_id;
-       /** @var int */
-       protected static $itemsPerPage;
+       protected $itemsPerPage;
        /** @var bool */
-       protected static $no_sharer;
+       protected $noSharer;
 
        /** @var App\Mode $mode */
        protected $mode;
@@ -99,20 +97,20 @@ class Timeline extends BaseModule
        protected function parseRequest(array $request)
        {
                $this->logger->debug('Got request', $request);
-               self::$selectedTab = $this->parameters['content'] ?? '';
+               $this->selectedTab = $this->parameters['content'] ?? '';
 
-               self::$accountTypeString = $request['accounttype'] ?? $this->parameters['accounttype'] ?? '';
-               self::$accountType       = User::getAccountTypeByString(self::$accountTypeString);
+               $this->accountTypeString = $request['accounttype'] ?? $this->parameters['accounttype'] ?? '';
+               $this->accountType       = User::getAccountTypeByString($this->accountTypeString);
 
                if ($this->mode->isMobile()) {
-                       self::$itemsPerPage = $this->pConfig->get(
+                       $this->itemsPerPage = $this->pConfig->get(
                                $this->session->getLocalUserId(),
                                'system',
                                'itemspage_mobile_network',
                                $this->config->get('system', 'itemspage_network_mobile')
                        );
                } else {
-                       self::$itemsPerPage = $this->pConfig->get(
+                       $this->itemsPerPage = $this->pConfig->get(
                                $this->session->getLocalUserId(),
                                'system',
                                'itemspage_network',
@@ -122,32 +120,30 @@ class Timeline extends BaseModule
 
                if (!empty($request['item'])) {
                        $item = Post::selectFirst(['parent', 'parent-uri-id'], ['id' => $request['item']]);
-                       self::$item_id     = $item['parent'] ?? 0;
-                       self::$item_uri_id = $item['parent-uri-id'] ?? 0;
+                       $this->itemUriId = $item['parent-uri-id'] ?? 0;
                } else {
-                       self::$item_id     = 0;
-                       self::$item_uri_id = 0;
+                       $this->itemUriId = 0;
                }
 
-               self::$min_id = $request['min_id'] ?? null;
-               self::$max_id = $request['max_id'] ?? null;
+               $this->min_id = $request['min_id'] ?? null;
+               $this->max_id = $request['max_id'] ?? null;
 
-               self::$no_sharer = !empty($request['no_sharer']);
+               $this->noSharer = !empty($request['no_sharer']);
        }
 
        protected function getNoSharerWidget(string $base): string
        {
-               $path = self::$selectedTab;
-               if (!empty(self::$accountTypeString)) {
-                       $path .= '/' . self::$accountTypeString;
+               $path = $this->selectedTab;
+               if (!empty($this->accountTypeString)) {
+                       $path .= '/' . $this->accountTypeString;
                }
                $query_parameters = [];
 
-               if (!empty(self::$min_id)) {
-                       $query_parameters['min_id'] = self::$min_id;
+               if (!empty($this->min_id)) {
+                       $query_parameters['min_id'] = $this->min_id;
                }
-               if (!empty(self::$max_id)) {
-                       $query_parameters['max_id'] = self::$max_id;
+               if (!empty($this->max_id)) {
+                       $query_parameters['max_id'] = $this->max_id;
                }
 
                $path_all       = $path . (!empty($query_parameters) ? '?' . http_build_query($query_parameters) : '');
@@ -156,7 +152,7 @@ class Timeline extends BaseModule
                        '$title'           => $this->l10n->t('Own Contacts'),
                        '$path_all'        => $path_all,
                        '$path_no_sharer'  => $path_no_sharer,
-                       '$no_sharer'       => self::$no_sharer,
+                       '$no_sharer'       => $this->noSharer,
                        '$all'             => $this->l10n->t('Include'),
                        '$no_sharer_label' => $this->l10n->t('Hide'),
                        '$base'            => $base,
@@ -171,7 +167,7 @@ class Timeline extends BaseModule
                        $tabs[] = [
                                'label'     => $tab->label,
                                'url'       => $tab->path ?? $prefix . '/' . $tab->code,
-                               'sel'       => self::$selectedTab == $tab->code ? 'active' : '',
+                               'sel'       => $this->selectedTab == $tab->code ? 'active' : '',
                                'title'     => $tab->description,
                                'id'        => $prefix . '-' . $tab->code . '-tab',
                                'accesskey' => $tab->accessKey,
@@ -190,13 +186,13 @@ class Timeline extends BaseModule
        {
                $uid = $this->session->getLocalUserId();
 
-               if (self::$selectedTab == TimelineEntity::WHATSHOT) {
-                       if (!is_null(self::$accountType)) {
-                               $condition = ["(`comments` >= ? OR `activities` >= ?) AND `contact-type` = ?", $this->getMedianComments($uid, 4), $this->getMedianActivities($uid, 4), self::$accountType];
+               if ($this->selectedTab == TimelineEntity::WHATSHOT) {
+                       if (!is_null($this->accountType)) {
+                               $condition = ["(`comments` >= ? OR `activities` >= ?) AND `contact-type` = ?", $this->getMedianComments($uid, 4), $this->getMedianActivities($uid, 4), $this->accountType];
                        } else {
                                $condition = ["(`comments` >= ? OR `activities` >= ?) AND `contact-type` != ?", $this->getMedianComments($uid, 4), $this->getMedianActivities($uid, 4), Contact::TYPE_COMMUNITY];
                        }
-               } elseif (self::$selectedTab == TimelineEntity::FORYOU) {
+               } elseif ($this->selectedTab == TimelineEntity::FORYOU) {
                        $cid = Contact::getPublicIdByUserId($uid);
 
                        $condition = [
@@ -206,9 +202,9 @@ class Timeline extends BaseModule
                                $cid, $this->getMedianRelationThreadScore($cid, 4), $this->getMedianComments($uid, 4), $this->getMedianActivities($uid, 4), $cid,
                                $uid, Contact::FRIEND, Contact::SHARING
                        ];
-               } elseif (self::$selectedTab == TimelineEntity::FOLLOWERS) {
+               } elseif ($this->selectedTab == TimelineEntity::FOLLOWERS) {
                        $condition = ["`owner-id` IN (SELECT `pid` FROM `account-user-view` WHERE `uid` = ? AND `rel` = ?)", $uid, Contact::FOLLOWER];
-               } elseif (self::$selectedTab == TimelineEntity::SHARERSOFSHARERS) {
+               } elseif ($this->selectedTab == TimelineEntity::SHARERSOFSHARERS) {
                        $cid = Contact::getPublicIdByUserId($uid);
 
                        // @todo Suggest posts from contacts that are followed most by our followers
@@ -218,44 +214,44 @@ class Timeline extends BaseModule
                                AND NOT `cid` IN (SELECT `cid` FROM `contact-relation` WHERE `follows` AND `relation-cid` = ?))",
                                DateTimeFormat::utc('now - ' . $this->config->get('channel', 'sharer_interaction_days') . ' day'), $cid, $this->getMedianRelationThreadScore($cid, 4), $cid
                        ];
-               } elseif (self::$selectedTab == TimelineEntity::IMAGE) {
+               } elseif ($this->selectedTab == TimelineEntity::IMAGE) {
                        $condition = ["`media-type` & ?", 1];
-               } elseif (self::$selectedTab == TimelineEntity::VIDEO) {
+               } elseif ($this->selectedTab == TimelineEntity::VIDEO) {
                        $condition = ["`media-type` & ?", 2];
-               } elseif (self::$selectedTab == TimelineEntity::AUDIO) {
+               } elseif ($this->selectedTab == TimelineEntity::AUDIO) {
                        $condition = ["`media-type` & ?", 4];
-               } elseif (self::$selectedTab == TimelineEntity::LANGUAGE) {
+               } elseif ($this->selectedTab == TimelineEntity::LANGUAGE) {
                        $condition = ["JSON_EXTRACT(JSON_KEYS(language), '$[0]') = ?", $this->l10n->convertCodeForLanguageDetection(User::getLanguageCode($uid))];
                }
 
-               if (self::$selectedTab != TimelineEntity::LANGUAGE) {
+               if ($this->selectedTab != TimelineEntity::LANGUAGE) {
                        $condition = $this->addLanguageCondition($uid, $condition);
                }
 
                $condition = DBA::mergeConditions($condition, ["NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `cid` = `post-engagement`.`owner-id` AND (`ignored` OR `blocked` OR `collapsed`))", $uid]);
 
-               if ((self::$selectedTab != TimelineEntity::WHATSHOT) && !is_null(self::$accountType)) {
-                       $condition = DBA::mergeConditions($condition, ['contact-type' => self::$accountType]);
+               if (($this->selectedTab != TimelineEntity::WHATSHOT) && !is_null($this->accountType)) {
+                       $condition = DBA::mergeConditions($condition, ['contact-type' => $this->accountType]);
                }
 
-               $params = ['order' => ['created' => true], 'limit' => self::$itemsPerPage];
+               $params = ['order' => ['created' => true], 'limit' => $this->itemsPerPage];
 
-               if (!empty(self::$item_uri_id)) {
-                       $condition = DBA::mergeConditions($condition, ['uri-id' => self::$item_uri_id]);
+               if (!empty($this->itemUriId)) {
+                       $condition = DBA::mergeConditions($condition, ['uri-id' => $this->itemUriId]);
                } else {
-                       if (self::$no_sharer) {
+                       if ($this->noSharer) {
                                $condition = DBA::mergeConditions($condition, ["NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `post-user`.`uid` = ? AND `post-user`.`uri-id` = `post-engagement`.`uri-id`)", $this->session->getLocalUserId()]);
                        }
 
-                       if (isset(self::$max_id)) {
-                               $condition = DBA::mergeConditions($condition, ["`created` < ?", self::$max_id]);
+                       if (isset($this->max_id)) {
+                               $condition = DBA::mergeConditions($condition, ["`created` < ?", $this->max_id]);
                        }
 
-                       if (isset(self::$min_id)) {
-                               $condition = DBA::mergeConditions($condition, ["`created` > ?", self::$min_id]);
+                       if (isset($this->min_id)) {
+                               $condition = DBA::mergeConditions($condition, ["`created` > ?", $this->min_id]);
 
                                // Previous page case: we want the items closest to min_id but for that we need to reverse the query order
-                               if (!isset(self::$max_id)) {
+                               if (!isset($this->max_id)) {
                                        $params['order']['created'] = false;
                                }
                        }
@@ -267,7 +263,7 @@ class Timeline extends BaseModule
                }
 
                // Previous page case: once we get the relevant items closest to min_id, we need to restore the expected display order
-               if (empty(self::$item_uri_id) && isset(self::$min_id) && !isset(self::$max_id)) {
+               if (empty($this->itemUriId) && isset($this->min_id) && !isset($this->max_id)) {
                        $items = array_reverse($items);
                }
 
@@ -375,13 +371,13 @@ class Timeline extends BaseModule
                $items = $this->selectItems();
 
                $maxpostperauthor = (int) $this->config->get('system', 'max_author_posts_community_page');
-               if ($maxpostperauthor != 0 && self::$selectedTab == 'local') {
+               if ($maxpostperauthor != 0 && $this->selectedTab == 'local') {
                        $count          = 1;
                        $previousauthor = '';
                        $numposts       = 0;
                        $selected_items = [];
 
-                       while (count($selected_items) < self::$itemsPerPage && ++$count < 50 && count($items) > 0) {
+                       while (count($selected_items) < $this->itemsPerPage && ++$count < 50 && count($items) > 0) {
                                foreach ($items as $item) {
                                        if ($previousauthor == $item["author-link"]) {
                                                ++$numposts;
@@ -390,18 +386,18 @@ class Timeline extends BaseModule
                                        }
                                        $previousauthor = $item["author-link"];
 
-                                       if (($numposts < $maxpostperauthor) && (count($selected_items) < self::$itemsPerPage)) {
+                                       if (($numposts < $maxpostperauthor) && (count($selected_items) < $this->itemsPerPage)) {
                                                $selected_items[] = $item;
                                        }
                                }
 
                                // If we're looking at a "previous page", the lookup continues forward in time because the list is
                                // sorted in chronologically decreasing order
-                               if (isset(self::$min_id)) {
-                                       self::$min_id = $items[0]['commented'];
+                               if (isset($this->min_id)) {
+                                       $this->min_id = $items[0]['commented'];
                                } else {
                                        // In any other case, the lookup continues backwards in time
-                                       self::$max_id = $items[count($items) - 1]['commented'];
+                                       $this->max_id = $items[count($items) - 1]['commented'];
                                }
 
                                $items = $this->selectItems();
@@ -422,15 +418,15 @@ class Timeline extends BaseModule
         */
        private function selectItems()
        {
-               if (self::$selectedTab == 'local') {
-                       if (!is_null(self::$accountType)) {
-                               $condition = ["`wall` AND `origin` AND `private` = ? AND `owner-contact-type` = ?", Item::PUBLIC, self::$accountType];
+               if ($this->selectedTab == 'local') {
+                       if (!is_null($this->accountType)) {
+                               $condition = ["`wall` AND `origin` AND `private` = ? AND `owner-contact-type` = ?", Item::PUBLIC, $this->accountType];
                        } else {
                                $condition = ["`wall` AND `origin` AND `private` = ?", Item::PUBLIC];
                        }
-               } elseif (self::$selectedTab == 'global') {
-                       if (!is_null(self::$accountType)) {
-                               $condition = ["`uid` = ? AND `private` = ? AND `owner-contact-type` = ?", 0, Item::PUBLIC, self::$accountType];
+               } elseif ($this->selectedTab == 'global') {
+                       if (!is_null($this->accountType)) {
+                               $condition = ["`uid` = ? AND `private` = ? AND `owner-contact-type` = ?", 0, Item::PUBLIC, $this->accountType];
                        } else {
                                $condition = ["`uid` = ? AND `private` = ?", 0, Item::PUBLIC];
                        }
@@ -438,24 +434,24 @@ class Timeline extends BaseModule
                        return [];
                }
 
-               $params = ['order' => ['commented' => true], 'limit' => self::$itemsPerPage];
+               $params = ['order' => ['commented' => true], 'limit' => $this->itemsPerPage];
 
-               if (!empty(self::$item_uri_id)) {
-                       $condition = DBA::mergeConditions($condition, ['uri-id' => self::$item_uri_id]);
+               if (!empty($this->itemUriId)) {
+                       $condition = DBA::mergeConditions($condition, ['uri-id' => $this->itemUriId]);
                } else {
-                       if ($this->session->getLocalUserId() && self::$no_sharer) {
+                       if ($this->session->getLocalUserId() && $this->noSharer) {
                                $condition = DBA::mergeConditions($condition, ["NOT `uri-id` IN (SELECT `uri-id` FROM `post-user` WHERE `post-user`.`uid` = ? AND `post-user`.`uri-id` = `post-thread-user-view`.`uri-id`)", $this->session->getLocalUserId()]);
                        }
 
-                       if (isset(self::$max_id)) {
-                               $condition = DBA::mergeConditions($condition, ["`commented` < ?", self::$max_id]);
+                       if (isset($this->max_id)) {
+                               $condition = DBA::mergeConditions($condition, ["`commented` < ?", $this->max_id]);
                        }
 
-                       if (isset(self::$min_id)) {
-                               $condition = DBA::mergeConditions($condition, ["`commented` > ?", self::$min_id]);
+                       if (isset($this->min_id)) {
+                               $condition = DBA::mergeConditions($condition, ["`commented` > ?", $this->min_id]);
 
                                // Previous page case: we want the items closest to min_id but for that we need to reverse the query order
-                               if (!isset(self::$max_id)) {
+                               if (!isset($this->max_id)) {
                                        $params['order']['commented'] = false;
                                }
                        }
@@ -469,7 +465,7 @@ class Timeline extends BaseModule
                }
 
                // Previous page case: once we get the relevant items closest to min_id, we need to restore the expected display order
-               if (empty(self::$item_uri_id) && isset(self::$min_id) && !isset(self::$max_id)) {
+               if (empty($this->itemUriId) && isset($this->min_id) && !isset($this->max_id)) {
                        $items = array_reverse($items);
                }
 
index 333c63b2de754b974e3a61fe1a8e02a412b7497c..a9d7ce751f81377123e217d031e825ac74a4a023 100644 (file)
@@ -38,7 +38,7 @@ class Channel extends ChannelModule
 
                $o = '';
                if (!empty($request['force'])) {
-                       if ($this->timeline->isChannel(self::$selectedTab)) {
+                       if ($this->timeline->isChannel($this->selectedTab)) {
                                $items = $this->getChannelItems();
                        } else {
                                $items = $this->getCommunityItems();
index 1a2ad17bac1777f26c71039d442a125860fd3c37..d5d07589a88974da519cc01f2e4030b1de0048cf 100644 (file)
@@ -65,7 +65,7 @@ class Network extends NetworkModule
                        $conditionFields['unseen'] = true;
                }
 
-               $params = ['limit' => self::$itemsPerPage];
+               $params = ['limit' => $this->itemsPerPage];
                $table = 'network-thread-view';
 
                $items = $this->getItems($table, $params, $conditionFields);