Optimalizations
This commit is contained in:
parent
c7c5cde2b6
commit
5b25250209
6 changed files with 26 additions and 17 deletions
|
@ -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
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 60992522338fb56a3d869fc5ecfc1e77a4e14a22
|
||||
Subproject commit 971fba5cb9398f7521c2d8ae33e6bc6a1dbf3400
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue