Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#1899 specify display mode for action links with icons #17933

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 2 additions & 1 deletion CRM/Contribute/BAO/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,8 @@ protected static function getContributionTransactionInformation($contributionId,
FALSE,
'Payment.edit.action',
'Payment',
$resultDAO->id
$resultDAO->id,
'icon'
);
}

Expand Down
34 changes: 27 additions & 7 deletions CRM/Core/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ public static function description($mask) {
* @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
Expand All @@ -190,7 +196,8 @@ public static function formLink(
$enclosedAllInSingleUL = FALSE,
$op = NULL,
$objectName = NULL,
$objectId = NULL
$objectId = NULL,
$iconMode = 'text'
) {
if (empty($links)) {
return NULL;
Expand Down Expand Up @@ -243,11 +250,22 @@ public static function formLink(
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
);
}
}
Expand All @@ -261,11 +279,13 @@ public static function formLink(
}
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);
Expand Down