Remove truncate helper and use css instead
This commit is contained in:
parent
b96e6f82c8
commit
56d5b96fc0
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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 ?>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue