Source
* @throws InvalidArgumentException if an element of $other_buttons contain something other than CButtonInterface
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
function italic($str) {
if (is_array($str)) {
foreach ($str as $key => $val) {
if (is_string($val)) {
$em = new CTag('em', true);
$em->addItem($val);
$str[$key] = $em;
}
}
}
elseif (is_string($str)) {
$em = new CTag('em', true, '');
$em->addItem($str);
$str = $em;
}
return $str;
}
function bold($str) {
if (is_array($str)) {
foreach ($str as $key => $val) {
if (is_string($val)) {
$str[$key] = new CTag('b', true, $val);
}
}
return $str;
}
return new CTag('b', true, $str);
}
function make_decoration($haystack, $needle, $class = null) {
$result = $haystack;
$tmpHaystack = mb_strtolower($haystack);
$tmpNeedle = mb_strtolower($needle);
$pos = mb_strpos($tmpHaystack, $tmpNeedle);
if ($pos !== false) {
$start = mb_substr($haystack, 0, $pos);
$end = mb_substr($haystack, $pos + mb_strlen($needle));
$found = mb_substr($haystack, $pos, mb_strlen($needle));
if (is_null($class)) {
$result = [$start, bold($found), $end];
}