Skip to content

Commit

Permalink
Used the view plugin "translate" as function in views.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-KM committed Aug 26, 2018
1 parent cd8876f commit 29cc959
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 67 deletions.
15 changes: 8 additions & 7 deletions application/view/common/advanced-search/users.phtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
$translate = $this->plugin('translate');
// Prepare the user queries
$ids = isset($query['user_id']) ? $query['user_id'] : [];
if (!is_array($ids)) {
Expand All @@ -13,23 +14,23 @@ $sitePermissionSiteId = isset($query['site_permission_site_id']) ? $query['site_
?>
<div class="field">
<div class="field-meta">
<label for="email"><?php echo $this->translate('Search by email'); ?></label>
<label for="email"><?php echo $translate('Search by email'); ?></label>
</div>
<div class="inputs">
<input name="email" value="" type="text">
</div>
</div>
<div class="field">
<div class="field-meta">
<label for="name"><?php echo $this->translate('Search by name'); ?></label>
<label for="name"><?php echo $translate('Search by name'); ?></label>
</div>
<div class="inputs">
<input name="name" value="" type="text">
</div>
</div>
<div class="field">
<div class="field-meta">
<label for="role"><?php echo $this->translate('Search by role'); ?></label>
<label for="role"><?php echo $translate('Search by role'); ?></label>
</div>
<div class="inputs">
<?php echo $this->roleSelect([
Expand All @@ -40,16 +41,16 @@ $sitePermissionSiteId = isset($query['site_permission_site_id']) ? $query['site_
</div>
<div class="field">
<div class="field-meta">
<label for="is_active"><?php echo $this->translate('Search by activity'); ?></label>
<label for="is_active"><?php echo $translate('Search by activity'); ?></label>
</div>
<div class="inputs">
<label><input name="is_active" value="1" type="radio"><?php echo $this->translate('Active'); ?></label>
<label><input name="is_active" value="0" type="radio"><?php echo $this->translate('Not active'); ?></label>
<label><input name="is_active" value="1" type="radio"><?php echo $translate('Active'); ?></label>
<label><input name="is_active" value="0" type="radio"><?php echo $translate('Not active'); ?></label>
</div>
</div>
<div class="field">
<div class="field-meta">
<label for="site_permission_site_id"><?php echo $this->translate('Has permission in site'); ?></label>
<label for="site_permission_site_id"><?php echo $translate('Has permission in site'); ?></label>
</div>
<div class="inputs">
<?php echo $this->siteSelect([
Expand Down
13 changes: 7 additions & 6 deletions application/view/omeka/admin/user/batch-edit.phtml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?php
$translate = $this->plugin('translate');
$escape = $this->plugin('escapeHtml');
$form->prepare();
$this->htmlElement('body')->appendAttribute('class', 'batch-edit users');
$escape = $this->plugin('escapeHtml');
?>
<?php echo $this->pageTitle($this->translate('Batch edit users')); ?>
<?php echo $this->pageTitle($translate('Batch edit users')); ?>

<?php $this->trigger('view.batch_edit.before'); ?>

Expand All @@ -15,23 +16,23 @@ $escape = $this->plugin('escapeHtml');
<input type="hidden" name="query" value="<?php echo $this->escapeHtml(json_encode($query)); ?>">

<div id="page-actions">
<input type="submit" name="batch_update" value="<?php echo $this->escapeHtml($this->translate('Save')); ?>">
<input type="submit" name="batch_update" value="<?php echo $this->escapeHtml($translate('Save')); ?>">
</div>

<?php echo $this->formCollection($form, false); ?>
<?php echo $this->form()->closeTag(); ?>

<div class="sidebar always-open">
<h3><?php echo $this->translate('Affected users'); ?></h3>
<h3><?php echo $translate('Affected users'); ?></h3>
<?php if ($resources): ?>
<p><?php echo sprintf($this->translate('You are editing the following %s users:'), count($resources)); ?></p>
<p><?php echo sprintf($translate('You are editing the following %s users:'), count($resources)); ?></p>
<ul class="batch-selected">
<?php foreach ($resources as $resource): ?>
<li><?php echo $resource->link($resource->email(), null, ['target' => '_blank']); ?></li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p><?php echo sprintf($this->translate('You are editing %s users (except yourself).'), $this->hyperlink(number_format($count), $this->url(null, ['action' => 'browse'], ['query' => $query], true), ['target' => '_blank'])); ?></p>
<p><?php echo sprintf($translate('You are editing %s users (except yourself).'), $this->hyperlink(number_format($count), $this->url(null, ['action' => 'browse'], ['query' => $query], true), ['target' => '_blank'])); ?></p>
<?php endif; ?>
</div>

Expand Down
79 changes: 40 additions & 39 deletions application/view/omeka/admin/user/browse.phtml
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
<?php
$translate = $this->plugin('translate');
$escape = $this->plugin('escapeHtml');
$this->htmlElement('body')->appendAttribute('class', 'users browse');
$currentUserId = $this->identity()->getId();
$userIsAllowedBatchUpdate = $this->userIsAllowed('Omeka\Api\Adapter\UserAdapter', 'batch_update');
$userIsAllowedBatchDelete = $this->userIsAllowed('Omeka\Api\Adapter\UserAdapter', 'batch_delete');
$escape = $this->plugin('escapeHtml');
$sortHeadings = [
[
'label' => $this->translate('Email'),
'label' => $translate('Email'),
'value' => 'email'
],
[
'label' => $this->translate('Role'),
'label' => $translate('Role'),
'value' => 'role'
],
[
'label' => $this->translate('Created'),
'label' => $translate('Created'),
'value' => 'created'
]
]
?>

<?php echo $this->pageTitle($this->translate('Users')); ?>
<?php echo $this->pageTitle($translate('Users')); ?>

<?php echo $this->searchUserFilters(); ?>

<div class="browse-controls">
<?php echo $this->pagination(); ?>
<?php echo $this->hyperlink($this->translate('Advanced search'), $this->url(null, ['action' => 'search'], ['query' => $this->params()->fromQuery()], true), ['class' => 'advanced-search']); ?>
<?php echo $this->hyperlink($translate('Advanced search'), $this->url(null, ['action' => 'search'], ['query' => $this->params()->fromQuery()], true), ['class' => 'advanced-search']); ?>
<?php echo $this->sortSelector($sortHeadings); ?>
</div>


<div id="page-actions">
<?php if ($this->userIsAllowed('Omeka\Api\Adapter\UserAdapter', 'create')): ?>
<?php echo $this->hyperlink($this->translate('Add new user'), $this->url(null, ['action' => 'add'], true), ['class' => 'button']); ?>
<?php echo $this->hyperlink($translate('Add new user'), $this->url(null, ['action' => 'add'], true), ['class' => 'button']); ?>
<?php endif; ?>
</div>

Expand All @@ -42,27 +43,27 @@ $sortHeadings = [
<form method="post" id="batch-form" class="disable-unsaved-warning">
<?php if ($userIsAllowedBatchUpdate || $userIsAllowedBatchDelete): ?>
<div class="batch-inputs">
<select class="batch-actions-select" name="batch_action" aria-label="<?php echo $this->translate('Batch actions'); ?>">
<option value="default"><?php echo $this->translate('Batch actions'); ?></option>
<select class="batch-actions-select" name="batch_action" aria-label="<?php echo $translate('Batch actions'); ?>">
<option value="default"><?php echo $translate('Batch actions'); ?></option>
<?php if ($userIsAllowedBatchUpdate): ?>
<option value="update-selected" class="batch-selected" disabled><?php echo $this->translate('Edit selected'); ?></option>
<option value="update-all"><?php echo $this->translate('Edit all'); ?></option>
<option value="update-selected" class="batch-selected" disabled><?php echo $translate('Edit selected'); ?></option>
<option value="update-all"><?php echo $translate('Edit all'); ?></option>
<?php endif; ?>
<?php if ($userIsAllowedBatchDelete): ?>
<option value="delete-selected" class="batch-selected" disabled><?php echo $this->translate('Delete selected'); ?></option>
<option value="delete-all"><?php echo $this->translate('Delete all'); ?></option>
<option value="delete-selected" class="batch-selected" disabled><?php echo $translate('Delete selected'); ?></option>
<option value="delete-all"><?php echo $translate('Delete all'); ?></option>
<?php endif; ?>
</select>
<div class="batch-actions">
<button type="button" class="default active" disabled><?php echo $this->translate('Go'); ?></button>
<button type="button" class="default active" disabled><?php echo $translate('Go'); ?></button>
<?php if ($userIsAllowedBatchUpdate): ?>
<input type="submit" class="update-selected" value="<?php echo $this->translate('Go'); ?>" formaction="<?php echo $escape($this->url(null, ['action' => 'batch-edit'], true)); ?>">
<input type="submit" class="update-all" value="<?php echo $this->translate('Go'); ?>" formaction="<?php echo $escape($this->url(null, ['action' => 'batch-edit-all'], true)); ?>">
<input type="submit" class="update-selected" value="<?php echo $translate('Go'); ?>" formaction="<?php echo $escape($this->url(null, ['action' => 'batch-edit'], true)); ?>">
<input type="submit" class="update-all" value="<?php echo $translate('Go'); ?>" formaction="<?php echo $escape($this->url(null, ['action' => 'batch-edit-all'], true)); ?>">
<?php endif; ?>
<input type="hidden" name="query" class="batch-query" value="<?php echo $escape(json_encode($this->params()->fromQuery())); ?>">
<?php if ($userIsAllowedBatchDelete): ?>
<a class="delete button sidebar-content delete-selected" data-sidebar-selector="#sidebar-delete-selected"><?php echo $this->translate('Go'); ?></a>
<a class="delete button sidebar-content delete-all" data-sidebar-selector="#sidebar-delete-all"><?php echo $this->translate('Go'); ?></a>
<a class="delete button sidebar-content delete-selected" data-sidebar-selector="#sidebar-delete-selected"><?php echo $translate('Go'); ?></a>
<a class="delete button sidebar-content delete-all" data-sidebar-selector="#sidebar-delete-all"><?php echo $translate('Go'); ?></a>
<?php endif; ?>
</div>
</div>
Expand All @@ -75,10 +76,10 @@ $sortHeadings = [
<?php if ($userIsAllowedBatchUpdate || $userIsAllowedBatchDelete): ?>
<input type="checkbox" class="select-all">
<?php endif; ?>
<?php echo $this->translate('Email'); ?>
<?php echo $translate('Email'); ?>
</th>
<th><?php echo $this->translate('Role'); ?></th>
<th><?php echo $this->translate('Created'); ?></th>
<th><?php echo $translate('Role'); ?></th>
<th><?php echo $translate('Created'); ?></th>
</tr>
</thead>
<tbody>
Expand All @@ -92,30 +93,30 @@ $sortHeadings = [
<?php endif; ?>
<?php echo $user->link($user->email() . ' (' . $user->name() . ')'); ?>
<?php if (!$user->isActive()): ?>
<span class="o-icon-user-inactive" aria-label="<?php echo $this->translate('Inactive'); ?>"></span>
<span class="o-icon-user-inactive" aria-label="<?php echo $translate('Inactive'); ?>"></span>
<?php endif; ?>
<ul class="actions">
<?php if ($userIsAllowedUpdate): ?>
<li><?php echo $user->link('', 'edit', [
'class' => 'o-icon-edit',
'title' => $this->translate('Edit'),
'title' => $translate('Edit'),
]) ?></li>
<?php endif; ?>
<?php if ($userIsAllowedDelete): ?>
<li><?php echo $this->hyperlink('', '#', [
'data-sidebar-content-url' => $user->url('delete-confirm'),
'class' => 'o-icon-delete sidebar-content',
'title' => $this->translate('Delete'),
'title' => $translate('Delete'),
]); ?></li>
<?php endif; ?>
<li><?php echo $this->hyperlink('', '#', [
'data-sidebar-content-url' => $user->url('show-details'),
'class' => 'o-icon-more sidebar-content',
'title' => $this->translate('Details'),
'title' => $translate('Details'),
]); ?></li>
</ul>
</td>
<td><?php echo $escape($this->translate($user->displayRole())); ?></td>
<td><?php echo $escape($translate($user->displayRole())); ?></td>
<td><?php echo $escape($this->i18n()->dateFormat($user->created())); ?></td>
</tr>
<?php endforeach; ?>
Expand All @@ -132,7 +133,7 @@ $sortHeadings = [
<div id="sidebar" class="sidebar">
<?php echo $this->hyperlink('', '#', [
'class' => 'sidebar-close o-icon-close',
'title' => $this->translate('Close'),
'title' => $translate('Close'),
]); ?>
<div class="sidebar-content"></div>
</div>
Expand All @@ -141,15 +142,15 @@ $sortHeadings = [
<div id="sidebar-delete-selected" class="sidebar">
<?php echo $this->hyperlink('', '#', [
'class' => 'sidebar-close o-icon-close',
'title' => $this->translate('Close'),
'title' => $translate('Close'),
]); ?>
<div class="sidebar-content">
<div id="sidebar-confirm">
<h3><?php echo $this->translate('Delete users'); ?></h3>
<p><?php echo $this->translate('Are you sure you would like to delete the selected users?'); ?></p>
<h3><?php echo $translate('Delete users'); ?></h3>
<p><?php echo $translate('Are you sure you would like to delete the selected users?'); ?></p>
<p class="error"><?php echo sprintf(
$this->translate('%s: this action will permanently delete %s users and cannot be undone.'),
sprintf('<strong>%s</strong>', $this->translate('Warning')),
$translate('%s: this action will permanently delete %s users and cannot be undone.'),
sprintf('<strong>%s</strong>', $translate('Warning')),
'<strong><span id="delete-selected-count"></span></strong>'
); ?></p>
<?php echo $this->form($this->formDeleteSelected); ?>
Expand All @@ -159,18 +160,18 @@ $sortHeadings = [
<div id="sidebar-delete-all" class="sidebar">
<?php echo $this->hyperlink('', '#', [
'class' => 'sidebar-close o-icon-close',
'title' => $this->translate('Close'),
'title' => $translate('Close'),
]); ?>
<div class="sidebar-content">
<div id="sidebar-confirm">
<h3><?php echo $this->translate('Delete users'); ?></h3>
<p><?php echo $this->translate('Are you sure you would like to delete all users (except yourself) on all pages of this result?'); ?></p>
<h3><?php echo $translate('Delete users'); ?></h3>
<p><?php echo $translate('Are you sure you would like to delete all users (except yourself) on all pages of this result?'); ?></p>
<p class="error"><?php echo sprintf(
$this->translate('%s: this action will permanently delete %s users (except yourself) and cannot be undone.'),
sprintf('<strong>%s</strong>', $this->translate('Warning')),
$translate('%s: this action will permanently delete %s users (except yourself) and cannot be undone.'),
sprintf('<strong>%s</strong>', $translate('Warning')),
sprintf('<strong>%s</strong>', number_format($this->pagination()->getPaginator()->getTotalCount()))
); ?></p>
<label><input type="checkbox" name="confirm-delete-all-check"> <?php echo $this->translate('Are you sure?'); ?></label>
<label><input type="checkbox" name="confirm-delete-all-check"> <?php echo $translate('Are you sure?'); ?></label>
<?php echo $this->form($this->formDeleteAll); ?>
</div>
</div>
Expand Down Expand Up @@ -205,7 +206,7 @@ $('#sidebar-delete-all').on('click', 'input[name="confirm-delete-all-check"]', f
<?php else: ?>

<div class="no-resources">
<p><?php echo $this->translate('Omeka could not find any users.'); ?></p>
<p><?php echo $translate('Omeka could not find any users.'); ?></p>
</div>

<?php endif; ?>
5 changes: 3 additions & 2 deletions application/view/omeka/admin/user/search.phtml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php
$translate = $this->plugin('translate');
$this->htmlElement('body')->appendAttribute('class', 'users search');
?>
<?php echo $this->pageTitle($this->translate('Advanced search'), 1, $this->translate('Users')); ?>
<?php echo $this->pageTitle($translate('Advanced search'), 1, $translate('Users')); ?>
<form id="advanced-search" method="get" action="<?php echo $this->escapeHtml($this->url(null, ['action' => 'browse'], true)); ?>">
<?php echo $this->partial(
'common/advanced-search-users',
['query' => $this->params()->fromQuery(), 'resourceType' => 'user']
); ?>
<div id="page-actions">
<input type="submit" name="submit" value="<?php echo $this->escapeHtml($this->translate('Search')); ?>">
<input type="submit" name="submit" value="<?php echo $this->escapeHtml($translate('Search')); ?>">
</div>
</form>
9 changes: 6 additions & 3 deletions application/view/omeka/admin/user/show-details.phtml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<?php
$translate = $this->plugin('translate');
?>
<h3>
<a href="<?php echo $this->escapeHtml($resource->url()); ?>"><?php echo $this->escapeHtml($resource->name()); ?></a>
<?php if (!$resource->isActive()): ?>
<span class="user-inactive"><?php echo $this->translate('(inactive)'); ?></span>
<span class="user-inactive"><?php echo $translate('(inactive)'); ?></span>
<?php endif; ?>
</h3>

<div class="meta-group">
<h4><?php echo $this->translate('Items'); ?></h4>
<h4><?php echo $translate('Items'); ?></h4>
<div class="value"><?php echo $this->hyperlink($resource->itemCount(), $this->url('admin/default', ['controller' => 'item', 'action' => 'browse'], ['query' => ['owner_id' => $resource->id()]])); ?></div>
</div>

<div class="meta-group">
<h4><?php echo $this->translate('Item sets'); ?></h4>
<h4><?php echo $translate('Item sets'); ?></h4>
<div class="value"><?php echo $this->hyperlink($resource->itemSetCount(), $this->url('admin/default', ['controller' => 'item-set', 'action' => 'browse'], ['query' => ['owner_id' => $resource->id()]])); ?></div>
</div>
<?php $this->trigger('view.details', array('entity' => $resource)); ?>
Loading

0 comments on commit 29cc959

Please sign in to comment.