Removed TextHelper hacks

This commit is contained in:
Marcin Kurczewski 2013-11-18 15:41:16 +01:00
parent 17bd7a7572
commit bf0e40683c
3 changed files with 13 additions and 16 deletions

View file

@ -20,7 +20,7 @@ class UserController
$senderName,
$senderEmail,
$recipientEmail,
$tokens)
$linkActionName)
{
//prepare unique user token
do
@ -36,8 +36,11 @@ class UserController
R::store($token);
\Chibi\Registry::getContext()->mailSent = true;
$tokens = [];
$tokens['host'] = $_SERVER['HTTP_HOST'];
$tokens['token'] = $tokenText;
if ($linkActionName !== null)
$tokens['link'] = \Chibi\UrlHelper::route('user', $linkActionName, ['token' => $tokenText]);
$body = wordwrap(TextHelper::replaceTokens($body, $tokens), 70);
$subject = TextHelper::replaceTokens($subject, $tokens);
@ -75,9 +78,6 @@ class UserController
return;
}
$tokens = [];
$tokens['link'] = \Chibi\UrlHelper::route('user', 'activation', ['token' => '{token}']);
return self::sendTokenizedEmail(
$user,
$regConfig->confirmationEmailBody,
@ -85,16 +85,13 @@ class UserController
$regConfig->confirmationEmailSenderName,
$regConfig->confirmationEmailSenderEmail,
$user->email_unconfirmed,
$tokens);
'activation');
}
private static function sendPasswordResetConfirmation($user)
{
$regConfig = \Chibi\Registry::getConfig()->registration;
$tokens = [];
$tokens['link'] = \Chibi\UrlHelper::route('user', 'password-reset', ['token' => '{token}']);
return self::sendTokenizedEmail(
$user,
$regConfig->passwordResetEmailBody,
@ -102,7 +99,7 @@ class UserController
$regConfig->passwordResetEmailSenderName,
$regConfig->passwordResetEmailSenderEmail,
$user->email_confirmed,
$tokens);
'password-reset');
}

View file

@ -77,12 +77,12 @@
<?php if (PrivilegesHelper::confirm(Privilege::ScorePost)): ?>
&nbsp;[
<?php $scoreLink = \Chibi\UrlHelper::route('post', 'score', ['id' => $this->context->transport->post->id, 'score' => '{score}']) ?>
<?php $scoreLink = function($score) { return \Chibi\UrlHelper::route('post', 'score', ['id' => $this->context->transport->post->id, 'score' => $score]); } ?>
<?php if ($this->context->score === 1): ?>
<a class="simple-action selected" href="<?php echo TextHelper::replaceTokens($scoreLink, ['score' => 0]) ?>">
<a class="simple-action selected" href="<?php echo $scoreLink(0) ?>">
<?php else: ?>
<a class="simple-action" href="<?php echo TextHelper::replaceTokens($scoreLink, ['score' => 1]) ?>">
<a class="simple-action" href="<?php echo $scoreLink(1) ?>">
<?php endif ?>
vote up
</a>
@ -90,9 +90,9 @@
,&nbsp;
<?php if ($this->context->score === -1): ?>
<a class="simple-action selected" href="<?php echo TextHelper::replaceTokens($scoreLink, ['score' => 0]) ?>">
<a class="simple-action selected" href="<?php echo $scoreLink(0) ?>">
<?php else: ?>
<a class="simple-action" href="<?php echo TextHelper::replaceTokens($scoreLink, ['score' => -1]) ?>">
<a class="simple-action" href="<?php echo $scoreLink(-1) ?>">
<?php endif ?>
down
</a>]

View file

@ -1,14 +1,14 @@
<?php $max = max([0]+array_map(function($x) { return $x['post_count']; }, $this->context->transport->tags)); ?>
<?php $add = 0.25 ?>
<?php $mul = 0.75 / max(1, log(max(1, $max))) ?>
<?php $url = \Chibi\UrlHelper::route('post', 'list', ['query' => '{query}']) ?>
<?php $url = \Chibi\UrlHelper::route('post', 'list', ['query' => '_query_']) ?>
<div class="tags">
<ul>
<?php foreach ($this->context->transport->tags as $tag): ?>
<?php $name = $tag['name'] ?>
<?php $count = $tag['post_count'] ?>
<li class="tag" title="<?php echo $name ?> (<?php echo $count ?>)">
<a href="<?php echo TextHelper::replaceTokens($url, ['query' => $name]) ?>" style="opacity: <?php printf('%.02f', $add + $mul * log($count)) ?>">
<a href="<?php echo str_replace('_query_', $name, $url) ?>" style="opacity: <?php printf('%.02f', $add + $mul * log($count)) ?>">
<?php echo $name . ' (' . $count . ')' ?>
</a>
</li>