Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion module/VuFind/src/VuFind/Controller/ConfirmController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function confirmAction()
$flash = (true === is_array($message))
? [
'msg' => $message['msg'],
'tokens' => $message['tokens']
'tokens' => $message['tokens'] ?? []
]
: $message;
$this->flashMessenger()->addMessage($flash, 'info');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,18 @@ protected function getConfirmDeleteMessages($count)
$user = $this->getTable('user')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like an explicit null check for getParam return value for each type. Currently, in the unlikely case that the object selected gets deleted before the form is submitted, the current code results in "All", which is not right. I think the code should first check getParam(), and if it's set, either fetch the data or set the message to '' or something.

Later on, when adding the 'tag_delete_filter' message, I'd rather check for message strings other than 'All' rather than comparing them with false.

->select(['id' => $this->getParam('user_id')])
->current();
$userMsg = (false !== $user)
$userMsg = is_object($user)
? $user->username . " (" . $user->id . ")" : "All";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"All" here doesn't have a leading space while the others do. Any reason for that?


$tag = $this->getTable('tags')
->select(['id' => $this->getParam('tag_id')])
->current();
$tagMsg = (false !== $tag) ? $tag->tag . " (" . $tag->id . ")" : " All";
$tagMsg = is_object($tag) ? $tag->tag . " (" . $tag->id . ")" : " All";

$resource = $this->getTable('resource')
->select(['id' => $this->getParam('resource_id')])
->current();
$resourceMsg = (false !== $resource)
$resourceMsg = is_object($resource)
? $resource->title . " (" . $resource->id . ")" : " All";

$messages[] = [
Expand Down
8 changes: 4 additions & 4 deletions themes/bootstrap3/templates/admin/tags/list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<select name="user_id" id="user_id" class="form-control">
<option value="ALL"><?=$this->translate('All')?></option>
<?php foreach($this->uniqueUsers as $user):?>
<option value="<?=$this->escapeHtmlAttr($user['user_id'])?>"<?php if ($user['user_id'] == $this->params['user_id'] ?? null): ?> selected="selected"<?php endif;?>>
<option value="<?=$this->escapeHtmlAttr($user['user_id'])?>"<?php if ($user['user_id'] == ($this->params['user_id'] ?? null)): ?> selected="selected"<?php endif;?>>
<?=$this->escapeHtml($user['username']) ?>
</option>
<?php endforeach;?>
Expand All @@ -30,7 +30,7 @@
<select name="tag_id" id="tag_id" class="form-control">
<option value="ALL"><?=$this->translate('All')?></option>
<?php foreach($this->uniqueTags as $tag):?>
<option value="<?=$this->escapeHtmlAttr($tag['tag_id'])?>"<?php if ($tag['tag_id'] == $this->params['tag_id'] ?? null): ?> selected="selected"<?php endif;?>>
<option value="<?=$this->escapeHtmlAttr($tag['tag_id'])?>"<?php if ($tag['tag_id'] == ($this->params['tag_id'] ?? null)): ?> selected="selected"<?php endif;?>>
<?=$this->escapeHtml($tag['tag']) ?>
</option>
<?php endforeach;?>
Expand All @@ -41,15 +41,15 @@
<select name="resource_id" id="resource_id" class="form-control">
<option value="ALL"><?=$this->translate('All')?></option>
<?php foreach($this->uniqueResources as $resource):?>
<option value="<?=$this->escapeHtmlAttr($resource['resource_id'])?>" title="<?=$this->escapeHtmlAttr($resource['title']) ?>"<?php if ($resource['resource_id'] == $this->params['resource_id'] ?? null): ?> selected="selected"<?php endif;?>>
<option value="<?=$this->escapeHtmlAttr($resource['resource_id'])?>" title="<?=$this->escapeHtmlAttr($resource['title']) ?>"<?php if ($resource['resource_id'] == ($this->params['resource_id'] ?? null)): ?> selected="selected"<?php endif;?>>
<?=$this->escapeHtml($this->truncate($resource['title'], 80)) ?> (<?=$this->escapeHtml($resource['resource_id']) ?>)
</option>
<?php endforeach;?>
</select>
</label>
<label for="taglistsubmit">
<input type="submit" id="taglistsubmit" value="<?=$this->transEscAttr('Filter')?>" class="btn btn-primary">
<?php if ((null !== $this->params['user_id'] ?? null) || (null !== $this->params['tag_id'] ?? null) || (null !== $this->params['resource_id'] ?? null)):?>
<?php if ((null !== ($this->params['user_id'] ?? null)) || (null !== ($this->params['tag_id'] ?? null)) || (null !== ($this->params['resource_id'] ?? null))):?>
<a href="<?= $this->url('admin/tags', ['action' => 'List']); ?>"><?=$this->translate('clear_tag_filter')?></a>
<?php endif;?>
</label>
Expand Down