]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Settings/Channels.php
Merge branch 'friendica:2023.09-rc' into Leftovers-from-PR-#13339
[friendica.git] / src / Module / Settings / Channels.php
index 4e2c8f5f154fe4428a678646194a571318197b61..112f06492265d07fc41033365ff3b2275af52ebd 100644 (file)
@@ -22,8 +22,8 @@
 namespace Friendica\Module\Settings;
 
 use Friendica\App;
-use Friendica\Content\Conversation\Factory\Timeline;
-use Friendica\Content\Conversation\Repository\Channel;
+use Friendica\Content\Conversation\Factory;
+use Friendica\Content\Conversation\Repository\UserDefinedChannel;
 use Friendica\Core\L10n;
 use Friendica\Core\Renderer;
 use Friendica\Core\Session\Capability\IHandleUserSessions;
@@ -36,17 +36,17 @@ use Psr\Log\LoggerInterface;
 
 class Channels extends BaseSettings
 {
-       /** @var Channel */
+       /** @var UserDefinedChannel */
        private $channel;
-       /** @var Timeline */
-       private $timeline;
+       /** @var Factory\UserDefinedChannel */
+       private $userDefinedChannel;
 
-       public function __construct(Timeline $timeline, Channel $channel, App\Page $page, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+       public function __construct(Factory\UserDefinedChannel $userDefinedChannel, UserDefinedChannel $channel, App\Page $page, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
        {
                parent::__construct($session, $page, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
 
-               $this->timeline = $timeline;
-               $this->channel  = $channel;
+               $this->userDefinedChannel = $userDefinedChannel;
+               $this->channel            = $channel;
        }
 
        protected function post(array $request = [])
@@ -63,7 +63,7 @@ class Channels extends BaseSettings
                self::checkFormSecurityTokenRedirectOnError('/settings/channels', 'settings_channels');
 
                if (!empty($request['add_channel'])) {
-                       $channel = $this->timeline->createFromTableRow([
+                       $channel = $this->userDefinedChannel->createFromTableRow([
                                'label'            => $request['new_label'],
                                'description'      => $request['new_description'],
                                'access-key'       => substr(mb_strtolower($request['new_access_key']), 0, 1),
@@ -71,7 +71,7 @@ class Channels extends BaseSettings
                                'circle'           => (int)$request['new_circle'],
                                'include-tags'     => $this->cleanTags($request['new_include_tags']),
                                'exclude-tags'     => $this->cleanTags($request['new_exclude_tags']),
-                               'full-text-search' => $this->cleanTags($request['new_text_search']),
+                               'full-text-search' => $request['new_text_search'],
                                'media-type'       => ($request['new_image'] ? 1 : 0) | ($request['new_video'] ? 2 : 0) | ($request['new_audio'] ? 4 : 0),
                        ]);
                        $saved = $this->channel->save($channel);
@@ -86,7 +86,7 @@ class Channels extends BaseSettings
                                continue;
                        }
 
-                       $channel = $this->timeline->createFromTableRow([
+                       $channel = $this->userDefinedChannel->createFromTableRow([
                                'id'               => $id,
                                'label'            => $request['label'][$id],
                                'description'      => $request['description'][$id],
@@ -95,7 +95,7 @@ class Channels extends BaseSettings
                                'circle'           => (int)$request['circle'][$id],
                                'include-tags'     => $this->cleanTags($request['include_tags'][$id]),
                                'exclude-tags'     => $this->cleanTags($request['exclude_tags'][$id]),
-                               'full-text-search' => $this->cleanTags($request['text_search'][$id]),
+                               'full-text-search' => $request['text_search'][$id],
                                'media-type'       => ($request['image'][$id] ? 1 : 0) | ($request['video'][$id] ? 2 : 0) | ($request['audio'][$id] ? 4 : 0),
                        ]);
                        $saved = $this->channel->save($channel);
@@ -120,7 +120,7 @@ class Channels extends BaseSettings
                        -2 => $this->l10n->t('Followers'),
                ];
 
-               foreach (Circle::getByUID($uid) as $circle) {
+               foreach (Circle::getByUserId($uid) as $circle) {
                        $circles[$circle['id']] = $circle['name'];
                }
 
@@ -131,8 +131,8 @@ class Channels extends BaseSettings
                                'description'  => ["description[$channel->code]", $this->t("Description"), $channel->description],
                                'access_key'   => ["access_key[$channel->code]", $this->t("Access Key"), $channel->accessKey],
                                'circle'       => ["circle[$channel->code]", $this->t('Circle/Channel'), $channel->circle, '', $circles],
-                               'include_tags' => ["include_tags[$channel->code]", $this->t("Include Tags"), $channel->includeTags],
-                               'exclude_tags' => ["exclude_tags[$channel->code]", $this->t("Exclude Tags"), $channel->excludeTags],
+                               'include_tags' => ["include_tags[$channel->code]", $this->t("Include Tags"), str_replace(',', ', ', $channel->includeTags)],
+                               'exclude_tags' => ["exclude_tags[$channel->code]", $this->t("Exclude Tags"), str_replace(',', ', ', $channel->excludeTags)],
                                'text_search'  => ["text_search[$channel->code]", $this->t("Full Text Search"), $channel->fullTextSearch],
                                'image'        => ["image[$channel->code]", $this->t("Images"), $channel->mediaType & 1],
                                'video'        => ["video[$channel->code]", $this->t("Videos"), $channel->mediaType & 2],
@@ -180,7 +180,7 @@ class Channels extends BaseSettings
                foreach ($tagitems as $tag) {
                        $tag = trim($tag, '# ');
                        if (!empty($tag)) {
-                               $tags[] = $tag;
+                               $tags[] = preg_replace('#\s#u', '', $tag);
                        }
                }
                return implode(',', $tags);