diff --git a/data/config.ini b/data/config.ini index cd9da656..a4178091 100644 --- a/data/config.ini +++ b/data/config.ini @@ -59,22 +59,11 @@ confirmationEmailEnabled = 1 confirmationEmailSenderName = "{host} mailing system" confirmationEmailSenderEmail = "noreply@{host}" confirmationEmailSubject = "{host} - account activation" -confirmationEmailBody = "Hello, - -You received this e-mail because someone registered a user with this e-mail address at {host}. If it's you, visit {link} to finish registration process, otherwise you may ignore and delete this e-mail. - -Kind regards, -{host} mailing system" - +confirmationEmailBody = "Hello,{nl}{nl}You received this e-mail because someone registered a user with this e-mail address at {host}. If it's you, visit {link} to finish registration process, otherwise you may ignore and delete this e-mail.{nl}{nl}Kind regards,{nl}{host} mailing system" passwordResetEmailSenderName = "{host} mailing system" passwordResetEmailSenderEmail = "noreply@{host}" passwordResetEmailSubject = "{host} - password reset" -passwordResetEmailBody = "Hello, - -You received this e-mail because someone requested a password reset for user with this e-mail address at {host}. If it's you, visit {link} to finish password reset process, otherwise you may ignore and delete this e-mail. - -Kind regards, -{host} mailing system" +passwordResetEmailBody = "Hello,{nl}{nl}You received this e-mail because someone requested a password reset for user with this e-mail address at {host}. If it's you, visit {link} to finish password reset process, otherwise you may ignore and delete this e-mail.{nl}{nl}Kind regards,{nl}{host} mailing system" [privileges] uploadPost=registered diff --git a/lib/chibi-core b/lib/chibi-core index 60992522..971fba5c 160000 --- a/lib/chibi-core +++ b/lib/chibi-core @@ -1 +1 @@ -Subproject commit 60992522338fb56a3d869fc5ecfc1e77a4e14a22 +Subproject commit 971fba5cb9398f7521c2d8ae33e6bc6a1dbf3400 diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php index 56ae870b..4d039508 100644 --- a/src/Controllers/PostController.php +++ b/src/Controllers/PostController.php @@ -107,7 +107,7 @@ class PostController list($posts, $postCount) = Model_Post::getEntitiesWithCount($query, $postsPerPage, $page); $pageCount = ceil($postCount / $postsPerPage); $page = min($pageCount, $page); - R::preload($posts, 'sharedTag|tag'); + Model_Post::attachTags($posts); $this->context->transport->paginator = new StdClass; $this->context->transport->paginator->page = $page; diff --git a/src/Controllers/UserController.php b/src/Controllers/UserController.php index 7f6420b8..8ac9857a 100644 --- a/src/Controllers/UserController.php +++ b/src/Controllers/UserController.php @@ -38,6 +38,7 @@ class UserController $tokens = []; $tokens['host'] = $_SERVER['HTTP_HOST']; $tokens['token'] = $tokenText; + $tokens['nl'] = PHP_EOL; if ($linkActionName !== null) $tokens['link'] = \Chibi\UrlHelper::route('user', $linkActionName, ['token' => $tokenText]); @@ -440,7 +441,7 @@ class UserController $page = max(1, $page); list ($posts, $postCount) = Model_Post::getEntitiesWithCount($query, $postsPerPage, $page); $pageCount = ceil($postCount / $postsPerPage); - R::preload($posts, 'sharedTag|tag'); + Model_Post::attachTags($posts); $this->context->transport->tab = $tab; $this->context->transport->lastSearchQuery = $query; diff --git a/src/Models/Model_Post.php b/src/Models/Model_Post.php index 6a2dd4ba..f39fca47 100644 --- a/src/Models/Model_Post.php +++ b/src/Models/Model_Post.php @@ -146,6 +146,26 @@ class Model_Post extends AbstractModel return TextHelper::absolutePath(self::$config->main->filesPath . DS . $name); } + public static function attachTags($posts) + { + //slow!!! + //R::preload($posts, 'sharedTag|tag'); + $ids = array_map(function($x) { return $x->id; }, $posts); + $sql = 'SELECT post_tag.post_id, tag.* FROM tag INNER JOIN post_tag ON post_tag.tag_id = tag.id WHERE post_id IN (' . R::genSlots($ids) . ')'; + $rows = R::getAll($sql, $ids); + $postMap = array_fill_keys($ids, []); + foreach ($rows as $row) + { + $postMap[$row['post_id']] []= $row; + } + foreach ($posts as $post) + { + $tagRows = $postMap[$post->id]; + $tags = self::convertRows($tagRows, 'tag', true); + $post->setProperty('sharedTag', $tags, true, true); + } + } + public function isTaggedWith($tagName) { $tagName = trim(strtolower($tagName)); diff --git a/src/core.php b/src/core.php index 1d2d320d..a14cf184 100644 --- a/src/core.php +++ b/src/core.php @@ -43,7 +43,6 @@ $context->rootDir = $rootDir; //load database R::setup($config->main->dbDriver . ':' . TextHelper::absolutePath($config->main->dbLocation), $config->main->dbUser, $config->main->dbPass); R::freeze(true); -R::dependencies(['tag' => ['post'], 'favoritee' => ['post', 'user'], 'comment' => ['post', 'user']]); //wire models foreach (\Chibi\AutoLoader::getAllIncludablePaths() as $path)