Merge pull request #21945 from masetto/profile-data-attribute
[civicrm-core.git] / CRM / Core / Smarty / plugins / modifier.crmDelete.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
19 * Replace the value of an attribute in the input string. Assume
20 * the the attribute is well formed, of the type name="value". If
21 * no replacement is mentioned the value is inserted at the end of
22 * the form element
23 *
6a0b768e
TO
24 * @param string $string
25 * The html to be tweaked with.
26 * @param string $attribute
27 * The attribute to modify.
6a488035 28 *
a6c01b45 29 * @return string
353ffa53 30 * the new modified html string
6a488035
TO
31 */
32function smarty_modifier_crmDelete($string, $attribute) {
33 static $endOfElement = '/>';
34
35 // if we know what attribute we need to replace
36 // we need to search and replace the string: $attribute=XXX or $attribute="XXX"
37 // and replace it with an empty string
38 $pattern = '/' . $attribute . '="([^"]+?)"/';
39 return preg_replace($pattern, '', $string);
40}