Skip to content

Commit

Permalink
feat: add rf-year to formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Oct 15, 2023
1 parent dd8e926 commit 2d84485
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions TextformatterRockFrontend.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,21 @@ public static function getModuleInfo()

public function format(&$str)
{
if (strpos($str, "[rf-consent=") === false) return;
$str = preg_replace_callback("/\[rf-consent=(.*?)\](.*?)\[\/rf-consent\]/", function ($matches) {
$name = $matches[1];
$str = $matches[2];
return "<label>
<input type='checkbox' class='rf-consent-checkbox {$this->checkboxclass}' data-name='$name'>
$str
</label>";
}, $str);
}
// replace consent checkboxes
if (strpos($str, "[rf-consent=") !== false) {
$str = preg_replace_callback("/\[rf-consent=(.*?)\](.*?)\[\/rf-consent\]/", function ($matches) {
$name = $matches[1];
$str = $matches[2];
return "<label>
<input type='checkbox' class='rf-consent-checkbox {$this->checkboxclass}' data-name='$name'>
$str
</label>";
}, $str);
}

// replace [[year]] with current year
$str = str_replace("[rf-year]", date("Y"), $str);
}

/**
* Config inputfields
Expand Down

0 comments on commit 2d84485

Please sign in to comment.