diff options
-rw-r--r-- | app/Helper/Text.php | 19 | ||||
-rw-r--r-- | app/Template/user/last.php | 10 | ||||
-rw-r--r-- | app/Template/user/sessions.php | 12 | ||||
-rw-r--r-- | tests/units/TextHelperTest.php | 10 |
4 files changed, 11 insertions, 40 deletions
diff --git a/app/Helper/Text.php b/app/Helper/Text.php index 790fc411..4b8e99bd 100644 --- a/app/Helper/Text.php +++ b/app/Helper/Text.php @@ -42,25 +42,6 @@ class Text extends \Core\Base } /** - * Truncate a long text - * - * @param string $value Text - * @param integer $max_length Max Length - * @param string $end Text end - * @return string - */ - public function truncate($value, $max_length = 85, $end = '[...]') - { - $length = mb_strlen($value); - - if ($length > $max_length) { - return mb_substr($value, 0, $max_length).' '.$end; - } - - return $value; - } - - /** * Return true if needle is contained in the haystack * * @param string $haystack Haystack diff --git a/app/Template/user/last.php b/app/Template/user/last.php index ab25f79b..8097d6f1 100644 --- a/app/Template/user/last.php +++ b/app/Template/user/last.php @@ -5,11 +5,11 @@ <?php if (empty($last_logins)): ?> <p class="alert"><?= t('Never connected.') ?></p> <?php else: ?> - <table class="table-small"> + <table class="table-small table-fixed"> <tr> - <th><?= t('Login date') ?></th> - <th><?= t('Authentication method') ?></th> - <th><?= t('IP address') ?></th> + <th class="column-20"><?= t('Login date') ?></th> + <th class="column-15"><?= t('Authentication method') ?></th> + <th class="column-15"><?= t('IP address') ?></th> <th><?= t('User agent') ?></th> </tr> <?php foreach($last_logins as $login): ?> @@ -17,7 +17,7 @@ <td><?= dt('%B %e, %Y at %k:%M %p', $login['date_creation']) ?></td> <td><?= $this->e($login['auth_type']) ?></td> <td><?= $this->e($login['ip']) ?></td> - <td><?= $this->e($this->text->truncate($login['user_agent'])) ?></td> + <td><?= $this->e($login['user_agent']) ?></td> </tr> <?php endforeach ?> </table> diff --git a/app/Template/user/sessions.php b/app/Template/user/sessions.php index a7504a7a..67b2c8cd 100644 --- a/app/Template/user/sessions.php +++ b/app/Template/user/sessions.php @@ -5,20 +5,20 @@ <?php if (empty($sessions)): ?> <p class="alert"><?= t('No session.') ?></p> <?php else: ?> - <table class="table-small"> + <table class="table-small table-fixed"> <tr> - <th><?= t('Creation date') ?></th> - <th><?= t('Expiration date') ?></th> - <th><?= t('IP address') ?></th> + <th class="column-20"><?= t('Creation date') ?></th> + <th class="column-20"><?= t('Expiration date') ?></th> + <th class="column-15"><?= t('IP address') ?></th> <th><?= t('User agent') ?></th> - <th><?= t('Action') ?></th> + <th class="column-10"><?= t('Action') ?></th> </tr> <?php foreach($sessions as $session): ?> <tr> <td><?= dt('%B %e, %Y at %k:%M %p', $session['date_creation']) ?></td> <td><?= dt('%B %e, %Y at %k:%M %p', $session['expiration']) ?></td> <td><?= $this->e($session['ip']) ?></td> - <td><?= $this->e($this->text->truncate($session['user_agent'])) ?></td> + <td><?= $this->e($session['user_agent']) ?></td> <td><?= $this->url->link(t('Remove'), 'user', 'removeSession', array('user_id' => $user['id'], 'id' => $session['id']), true) ?></td> </tr> <?php endforeach ?> diff --git a/tests/units/TextHelperTest.php b/tests/units/TextHelperTest.php index 01652d5c..95c83e57 100644 --- a/tests/units/TextHelperTest.php +++ b/tests/units/TextHelperTest.php @@ -39,16 +39,6 @@ class TextHelperTest extends Base $this->assertEquals('33.71k', $h->bytes(34520)); } - public function testTruncate() - { - $h = new Text($this->container); - - $this->assertEquals('abc', $h->truncate('abc')); - $this->assertEquals(str_repeat('a', 85).' [...]', $h->truncate(str_repeat('a', 200))); - - $this->assertEquals('Настольная рекл [...]', $h->truncate('Настольная реклама в фудкорте ГЧ', 15)); - } - public function testContains() { $h = new Text($this->container); |