* @param null $op
* @param null $objectName
* @param int $objectId
+ * @param string $iconMode
+ * - `text`: even if `icon` is set for a link, display the `name`
+ * - `icon`: display only the `icon` for each link if it's available, and
+ * don't tuck anything under "more >"
+ * - `both`: if `icon` is available, display it next to the `name` for each
+ * link
*
* @return string
* the html string
$enclosedAllInSingleUL = FALSE,
$op = NULL,
$objectName = NULL,
- $objectId = NULL
+ $objectId = NULL,
+ $iconMode = 'text'
) {
if (empty($links)) {
return NULL;
if (strpos($urlPath, '/delete') || strpos($urlPath, 'action=delete')) {
$classes .= " small-popup";
}
+
+ $linkContent = $link['name'];
+ if (!empty($link['icon'])) {
+ if ($iconMode == 'icon') {
+ $linkContent = CRM_Core_Page::crmIcon($link['icon'], $link['name'], TRUE, ['title' => '']);
+ }
+ elseif ($iconMode == 'both') {
+ $linkContent = CRM_Core_Page::crmIcon($link['icon']) . ' ' . $linkContent;
+ }
+ }
+
$url[] = sprintf('<a href="%s" class="%s" %s' . $extra . '>%s</a>',
$urlPath,
$classes,
!empty($link['title']) ? "title='{$link['title']}' " : '',
- empty($link['icon']) ? $link['name'] : CRM_Core_Page::crmIcon($link['icon'], $link['name'], TRUE, ['title' => ''])
+ $linkContent
);
}
}
}
else {
$extra = '';
- $extraLinks = array_splice($url, 2);
- if (count($extraLinks) > 1) {
- $mainLinks = array_slice($url, 0, 2);
- CRM_Utils_String::append($extra, '</li><li>', $extraLinks);
- $extra = "{$extraULName}<ul class='panel'><li>{$extra}</li></ul>";
+ if ($iconMode != 'icon') {
+ $extraLinks = array_splice($url, 2);
+ if (count($extraLinks) > 1) {
+ $mainLinks = array_slice($url, 0, 2);
+ CRM_Utils_String::append($extra, '</li><li>', $extraLinks);
+ $extra = "{$extraULName}<ul class='panel'><li>{$extra}</li></ul>";
+ }
}
$resultLinks = '';
CRM_Utils_String::append($resultLinks, '', $mainLinks);