Commit 012faffe authored by TravisCarden's avatar TravisCarden

By TravisCarden: Removed !placeholders per #2575819.

parent d701ba28
......@@ -62,9 +62,9 @@ function drush_checklistapi_list() {
foreach ($definitions as $id => $definition) {
$checklist = checklistapi_checklist_load($id);
$row = [];
$row[] = dt('!title (!id)', [
$row[] = dt('!title (@id)', [
'!title' => strip_tags($checklist->title),
'!id' => $id,
'@id' => $id,
]);
$row[] = dt('@completed of @total (@percent%)', [
'@completed' => $checklist->getNumberCompleted(),
......@@ -72,7 +72,7 @@ function drush_checklistapi_list() {
'@percent' => round($checklist->getPercentComplete()),
]);
$row[] = $checklist->getLastUpdatedDate();
$row[] = strip_tags($checklist->getLastUpdatedUser());
$row[] = $checklist->getLastUpdatedUser();
$rows[] = $row;
}
......@@ -91,8 +91,8 @@ function drush_checklistapi_info_validate() {
// Make sure the given checklist exists.
if (!$checklist) {
drush_set_error('CHECKLISTAPI_INVALID_ARGUMENT', dt('No such checklist "!id".', [
'!id' => $id,
drush_set_error('CHECKLISTAPI_INVALID_ARGUMENT', dt('No such checklist "@id".', [
'@id' => $id,
]));
}
......@@ -113,9 +113,9 @@ function drush_checklistapi_info() {
// Print last updated and progress details.
if ($checklist->hasSavedProgress()) {
drush_print('');
drush_print(dt('Last updated @date by !user', [
drush_print(dt('Last updated @date by @user', [
'@date' => $checklist->getLastUpdatedDate(),
'!user' => strip_tags($checklist->getLastUpdatedUser()),
'@user' => $checklist->getLastUpdatedUser(),
]));
drush_print(dt('@completed of @total (@percent%) complete', [
'@completed' => $checklist->getNumberCompleted(),
......@@ -142,14 +142,14 @@ function drush_checklistapi_info() {
if ($saved_item) {
// Append completion details.
$user = User::load($saved_item['#uid']);
$title .= dt(' - Completed @time by !user', [
$title .= dt(' - Completed @time by @user', [
'@time' => format_date($saved_item['#completed'], 'short'),
'!user' => $user->getUsername(),
'@user' => $user->getUsername(),
]);
}
// Print the list item.
drush_print(dt(' [!x] !title', [
'!x' => ($saved_item) ? 'x' : ' ',
drush_print(dt(' [@x] !title', [
'@x' => ($saved_item) ? 'x' : ' ',
'!title' => $title,
]));
}
......
......@@ -193,10 +193,9 @@ function checklistapiexample_checklistapi_checklist_info() {
],
'chx_or_unconed' => [
'#title' => t(
"I'm a !chx or !UnConeD.",
[
'!chx' => \Drupal::l(t('chx'), Url::fromUri('http://drupal.org/user/9446')),
'!UnConeD' => \Drupal::l(t('UnConeD'), Url::fromUri('http://drupal.org/user/10')),
'I\'m a <a href=":chx_url">chx</a> or <a href=":unconed_url">UnConeD</a>.', [
':chx_url' => 'http://drupal.org/user/9446',
':unconed_url' => 'http://drupal.org/user/10',
]
),
],
......@@ -277,8 +276,9 @@ function checklistapiexample_checklistapi_checklist_info_alter(&$definitions) {
'#title' => t('I know every bit of core'),
'im_chx' => [
'#title' => t(
"I'm !chx.",
['!chx' => \Drupal::l(t('chx'), Url::fromUri('http://drupal.org/user/9446'))]
'I\'m <a href=":url">chx</a>.', [
':url' => 'http://drupal.org/user/9446',
]
),
],
];
......
......@@ -10,6 +10,7 @@ namespace Drupal\checklistapi;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Render\Element;
use Drupal\Core\Url;
use Drupal\user\Entity\User;
/**
* Defines the checklist class.
......@@ -162,11 +163,8 @@ class ChecklistapiChecklist {
*/
public function getLastUpdatedUser() {
if (isset($this->savedProgress['#changed_by'])) {
$username = [
'#theme' => 'username',
'#account' => user_load($this->savedProgress['#changed_by']),
];
return \Drupal::service('renderer')->render($username);
return User::load($this->savedProgress['#changed_by'])
->getUsername();
}
else {
return t('n/a');
......
......@@ -7,8 +7,6 @@
namespace Drupal\checklistapi;
use Drupal\Core\Url;
/**
* Defines a class containing permission callbacks.
*/
......@@ -30,9 +28,7 @@ class ChecklistapiPermissions {
*/
public function universalPermissions() {
$perms['view checklistapi checklists report'] = [
'title' => t('View the !name report', [
'!name' => (\Drupal::currentUser()->hasPermission('view checklistapi checklists report')) ? \Drupal::l(t('Checklists'), Url::fromRoute('checklistapi.report')) : drupal_placeholder('Checklists'),
]),
'title' => t('View the Checklists report'),
];
$perms['view any checklistapi checklist'] = [
'title' => t('View any checklist'),
......@@ -62,18 +58,13 @@ class ChecklistapiPermissions {
continue;
}
$checklist_name = drupal_placeholder($checklist->title);
// Hyperlink the checklist name if the current user has access to view it.
if (checklistapi_checklist_access($id)) {
$checklist_name = \Drupal::l($checklist->title, Url::fromRoute($checklist->getRouteName()));
}
$title = $checklist->title;
$perms["view {$id} checklistapi checklist"] = [
'title' => t('View the !name checklist', ['!name' => $checklist_name]),
'title' => t('View the @name checklist', ['@name' => $title]),
'description' => $this->viewPermissionDescription,
];
$perms["edit {$id} checklistapi checklist"] = [
'title' => t('Edit the !name checklist', ['!name' => $checklist_name]),
'title' => t('Edit the @name checklist', ['@name' => $title]),
'description' => $this->editPermissionDescription,
];
}
......
......@@ -12,6 +12,7 @@ use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Url;
use Drupal\user\Entity\User;
/**
* Provides a checklist form.
......@@ -36,9 +37,9 @@ class ChecklistapiChecklistForm implements FormInterface {
// Progress bar.
$progress_bar = [
'#theme' => 'checklistapi_progress_bar',
'#message' => ($checklist->hasSavedProgress()) ? t('Last updated @date by !user', [
'#message' => ($checklist->hasSavedProgress()) ? t('Last updated @date by @user', [
'@date' => $checklist->getLastUpdatedDate(),
'!user' => $checklist->getLastUpdatedUser(),
'@user' => $checklist->getLastUpdatedUser(),
]) : '',
'#number_complete' => $checklist->getNumberCompleted(),
'#number_of_items' => $checklist->getNumberOfItems(),
......@@ -89,17 +90,10 @@ class ChecklistapiChecklistForm implements FormInterface {
$title = Xss::filter($item['#title']);
if ($saved_item) {
// Append completion details.
$user = [
'#theme' => 'username',
'#account' => user_load($saved_item['#uid']),
];
$title .= t(
'<span class="completion-details"> - Completed @time by !user</a>',
[
'@time' => format_date($saved_item['#completed'], 'short'),
'!user' => \Drupal::service('renderer')->render($user),
]
);
$title .= t('<span class="completion-details"> - Completed @time by @user</a>', [
'@time' => format_date($saved_item['#completed'], 'short'),
'@user' => User::load($saved_item['#uid'])->getUsername(),
]);
}
// Set default value.
$default_value = FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment