Merge pull request #14928 from lcdservices/dev-core-1158
[civicrm-core.git] / CRM / Core / Smarty / plugins / modifier.crmInsert.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 * $Id$
17 *
18 */
19
20/**
21 * Replace the value of an attribute in the input string. Assume
22 * the the attribute is well formed, of the type name="value". If
23 * no replacement is mentioned the value is inserted at the end of
24 * the form element
25 *
6a0b768e
TO
26 * @param string $string
27 * The html to be tweaked with.
28 * @param string $attribute
29 * The attribute to insert.
30 * @param string $value
31 * The new attribute value.
32 * @param string $insertBefore
33 * The string before which we want this tag inserted.
6a488035 34 *
a6c01b45 35 * @return string
353ffa53 36 * the new modified html string
6a488035
TO
37 */
38function smarty_modifier_crmInsert($string, $attribute, $value, $insertBefore = '/>') {
39 return str_replace($insertBefore, ' ' . $attribute . '="' . $value . '"' . $insertBefore, $string);
40}