| 1 |
<?php |
| 2 |
|
| 3 |
trait TimeInsertion |
| 4 |
{ |
| 5 |
public function dynamicText(?int $mailId): ?object |
| 6 |
{ |
| 7 |
return $this->pluginDescription; |
| 8 |
} |
| 9 |
|
| 10 |
public function textPopup(): void |
| 11 |
{ |
| 12 |
$text = '<div class="acym__popup__listing text-center grid-x"> |
| 13 |
<h1 class="acym__title acym__title__secondary text-center cell">'.acym_translation('ACYM_TIME_FORMAT').'</h1>'; |
| 14 |
|
| 15 |
$others = []; |
| 16 |
$others['{date:1}'] = 'ACYM_DATE_FORMAT_LC1'; |
| 17 |
$others['{date:2}'] = 'ACYM_DATE_FORMAT_LC2'; |
| 18 |
$others['{date:3}'] = 'ACYM_DATE_FORMAT_LC3'; |
| 19 |
$others['{date:4}'] = 'ACYM_DATE_FORMAT_LC4'; |
| 20 |
$others['{date:m/d/Y}'] = 'm/d/Y'; |
| 21 |
$others['{date:d/m/y}'] = 'd/m/y'; |
| 22 |
$others['{date:l}'] = 'l'; |
| 23 |
$others['{date:W}'] = 'W'; |
| 24 |
$others['{date:F}'] = 'F'; |
| 25 |
$others['{date:Y}'] = 'Y'; |
| 26 |
|
| 27 |
|
| 28 |
$k = 0; |
| 29 |
foreach ($others as $tagname => $tag) { |
| 30 |
$text .= '<div class="grid-x medium-12 cell acym__row__no-listing acym__listing__row__popup text-left" onclick="setTag(\''.$tagname.'\', jQuery(this));" > |
| 31 |
<div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.acym_translation($tag).'</div> |
| 32 |
<div class="cell medium-6 small-12 acym__listing__title acym__listing__title__dynamics">'.acym_getDate(time(), acym_translation($tag)).'</div> |
| 33 |
</div>'; |
| 34 |
$k = 1 - $k; |
| 35 |
} |
| 36 |
|
| 37 |
$text .= '</div>'; |
| 38 |
|
| 39 |
echo $text; |
| 40 |
} |
| 41 |
|
| 42 |
public function replaceContent(object &$email): void |
| 43 |
{ |
| 44 |
$extractedTags = $this->pluginHelper->extractTags($email, 'date'); |
| 45 |
if (empty($extractedTags)) { |
| 46 |
return; |
| 47 |
} |
| 48 |
|
| 49 |
$tags = []; |
| 50 |
foreach ($extractedTags as $i => $oneTag) { |
| 51 |
if (isset($tags[$i])) { |
| 52 |
continue; |
| 53 |
} |
| 54 |
|
| 55 |
$time = time(); |
| 56 |
if (!empty($oneTag->senddate) && !empty($email->sending_date)) { |
| 57 |
$time = strtotime($email->sending_date); |
| 58 |
} |
| 59 |
if (!empty($oneTag->add)) { |
| 60 |
$time += intval($oneTag->add); |
| 61 |
} |
| 62 |
if (!empty($oneTag->remove)) { |
| 63 |
$time -= intval($oneTag->remove); |
| 64 |
} |
| 65 |
|
| 66 |
if (empty($oneTag->id) || is_numeric($oneTag->id)) { |
| 67 |
$oneTag->id = acym_translation('ACYM_DATE_FORMAT_LC'.$oneTag->id); |
| 68 |
} |
| 69 |
$oneTag->id = str_replace( |
| 70 |
['%A', '%d', '%B', '%m', '%Y', '%y', '%H', '%M', '%S', '%a', '%I', '%p', '%w'], |
| 71 |
['l', 'd', 'F', 'm', 'Y', 'y', 'H', 'i', 's', 'D', 'h', 'a', 'w'], |
| 72 |
$oneTag->id |
| 73 |
); |
| 74 |
$tags[$i] = acym_date($time, $oneTag->id, true); |
| 75 |
} |
| 76 |
|
| 77 |
$this->pluginHelper->replaceTags($email, $tags); |
| 78 |
} |
| 79 |
} |
| 80 |
|