3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC
21 * Dynamically construct a link based on an entity-type and entity-id.
23 * @param array $params
27 * - action: string, 'VIEW' or 'UPDATE' [default: VIEW]
28 * - title: string [optionally override default title]
29 * @param CRM_Core_Smarty $smarty
33 function smarty_function_crmCrudLink($params, &$smarty) {
34 if (empty($params['action'])) {
35 $params['action'] = 'VIEW';
38 $link = CRM_Utils_System
::createDefaultCrudLink([
39 'action' => constant('CRM_Core_Action::' . $params['action']),
40 'entity_table' => $params['table'],
41 'entity_id' => $params['id'],
45 return sprintf('<a href="%s">%s</a>',
46 htmlspecialchars($link['url']),
47 htmlspecialchars(CRM_Utils_Array
::value('title', $params, $link['title']))
51 return sprintf('[%s, %s]', $params['table'], $params['id']);