From 56d5b96fc08fe69e3991b7909798b1db0ea5097b Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Mon, 15 Jun 2015 20:42:41 -0400 Subject: Remove truncate helper and use css instead --- app/Helper/Text.php | 19 ------------------- app/Template/user/last.php | 10 +++++----- app/Template/user/sessions.php | 12 ++++++------ 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 @@ -41,25 +41,6 @@ class Text extends \Core\Base return round(pow(1024, $base - floor($base)), $precision).$suffixes[(int)floor($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 * 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 @@

- +
- - - + + + @@ -17,7 +17,7 @@ - +
e($login['auth_type']) ?> e($login['ip']) ?>e($this->text->truncate($login['user_agent'])) ?>e($login['user_agent']) ?>
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 @@

- +
- - - + + + - + - + 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); -- cgit v1.2.3
e($session['ip']) ?>e($this->text->truncate($session['user_agent'])) ?>e($session['user_agent']) ?> url->link(t('Remove'), 'user', 'removeSession', array('user_id' => $user['id'], 'id' => $session['id']), true) ?>