$path = $this->replaceTokens($link['path'], $data, 'url', $index);
if ($path) {
$link['url'] = $this->getUrl($path);
- $keys = ['url', 'text', 'title', 'target', 'style'];
+ $keys = ['url', 'text', 'title', 'target', 'icon', 'style'];
}
else {
- $keys = ['task', 'text', 'title', 'style'];
+ $keys = ['task', 'text', 'title', 'icon', 'style'];
}
$link = array_intersect_key($link, array_flip($keys));
- return array_filter($link);
+ return array_filter($link, function($value) {
+ // "0" is a valid title
+ return $value || (is_string($value) && strlen($value));
+ });
}
/**
}
}
elseif (!empty($task['apiBatch']) || !empty($task['uiDialog'])) {
- $link['title'] = $link['title'] ?: $task['title'];
+ if (!strlen($link['title'])) {
+ $link['title'] = $task['title'];
+ }
// Fill in the api action if known, for the sake of $this->checkLinkAccess
$link['action'] = $task['apiBatch']['action'] ?? NULL;
}
],
[
'entity' => 'Contribution',
+ 'title' => 'Delete',
'action' => 'delete',
- 'icon' => 'fa-pencil',
+ 'icon' => 'fa-trash',
'target' => 'crm-popup',
],
],
// 1st link is to a quickform-based search task (CRM_Contribute_Task::PDF_RECEIPT)
$this->assertArrayNotHasKey('task', $result[0]['columns'][1]['links'][0]);
$this->assertStringContainsString('id=' . $contributions[0]['id'] . '&qfKey=', $result[0]['columns'][1]['links'][0]['url']);
+ $this->assertEquals('fa-external-link', $result[0]['columns'][1]['links'][0]['icon']);
// 2nd link is to the native SK bulk-update task
$this->assertArrayNotHasKey('url', $result[0]['columns'][1]['links'][1]);
$this->assertEquals('update', $result[0]['columns'][1]['links'][1]['task']);
+ $this->assertEquals('fa-pencil', $result[0]['columns'][1]['links'][1]['icon']);
// 3rd link is a popup link to the delete contribution quickform
$this->assertStringContainsString('action=delete&id=' . $contributions[0]['id'], $result[0]['columns'][1]['links'][2]['url']);
$this->assertEquals('crm-popup', $result[0]['columns'][1]['links'][2]['target']);
+ $this->assertEquals('fa-trash', $result[0]['columns'][1]['links'][2]['icon']);
+ $this->assertEquals('Delete', $result[0]['columns'][1]['links'][2]['title']);
}
public function testRelationshipCacheLinks():void {
'icon' => 'fa-external-link',
],
[
+ 'title' => '0',
'entity' => 'Relationship',
'task' => 'delete',
'icon' => 'fa-trash',
// 2nd link is to the native SK bulk-delete task
$this->assertArrayNotHasKey('url', $result[0]['columns'][1]['links'][1]);
$this->assertEquals('delete', $result[0]['columns'][1]['links'][1]['task']);
+ $this->assertEquals('fa-trash', $result[0]['columns'][1]['links'][1]['icon']);
+ // Ensure "empty" titles are still returned
+ $this->assertEquals('0', $result[0]['columns'][1]['links'][1]['title']);
// 3rd link is the disable task for active relationships or the enable task for inactive ones
$this->assertEquals('disable', $result[0]['columns'][1]['links'][2]['task']);
$this->assertEquals('disable', $result[1]['columns'][1]['links'][2]['task']);
$this->assertEquals('enable', $result[2]['columns'][1]['links'][2]['task']);
$this->assertEquals('enable', $result[3]['columns'][1]['links'][2]['task']);
+ $this->assertStringContainsString('Enable', $result[3]['columns'][1]['links'][2]['title']);
}
/**