* @link https://regularlabs.com * @copyright Copyright © 2024 Regular Labs All Rights Reserved * @license GNU General Public License version 2 or later */ namespace RegularLabs\Library; defined('_JEXEC') or die; use Joomla\CMS\Access\Access as JAccess; class Protect { static $html_safe_end = '___/RL_PROTECTED___'; static $html_safe_start = '___RL_PROTECTED___'; static $html_safe_tags_end = '___/RL_PROTECTED_TAGS___'; static $html_safe_tags_start = '___RL_PROTECTED_TAGS___'; static $protect_end = '___RL_PROTECTED___ -->'; static $protect_start = ''; static $protect_tags_start = ''; } /** * Get the html start comment tags */ public static function getCommentStartTag(string $name = ''): string { return ''; } /** * Get the html comment tags */ public static function getCommentTags(string $name = ''): array { return [self::getCommentStartTag($name), self::getCommentEndTag($name)]; } /** * Return the Regular Expressions string to match: * The edit form */ public static function getFormRegex(array|string $form_classes = []): string { $form_classes = \RegularLabs\Library\ArrayHelper::toArray($form_classes); return '(
')) { return; } // Protect entire form if (empty($tags)) { $form_parts = explode('', $string, 2); $form_parts[0] = self::protectString($form_parts[0] . ''); $string = implode('', $form_parts); return; } $regex_tags = \RegularLabs\Library\RegEx::quote($tags); if (!\RegularLabs\Library\RegEx::match($regex_tags, $string)) { return; } $form_parts = explode('', $string, 2); // protect tags only inside form fields \RegularLabs\Library\RegEx::matchAll('(?: