use Galette\DynamicFields\DynamicField;
use Analog\Analog;
use NumberFormatter;
+use PHPMailer\PHPMailer\PHPMailer;
use Slim\Routing\RouteParser;
+use DI\Attribute\Inject;
/**
* Replacements feature
private $patterns = [];
private $replaces = [];
private $dynamic_patterns = [];
+ private ?PHPMailer $mail = null;
/**
* @var Db
'login_uri' => [
'title' => _T("Galette's login URI"),
'pattern' => '/{LOGIN_URI}/'
+ ],
+ 'asso_footer' => [
+ 'title' => trim(trim(_T("Footer text:"), ':')),
+ 'pattern' => '/{ASSO_FOOTER}/'
]
];
}
return $c_patterns + $dynamic_patterns;
}
+ /**
+ * Set mail instance
+ *
+ * @param PHPMailer $mail PHPMailer instance
+ *
+ * @return self
+ */
+ public function setMail(PHPMailer $mail): self
+ {
+ $this->mail = $mail;
+ return $this;
+ }
+
/**
* Set main replacements
*
}
$logo = new Logo();
- $logo_elt = '<img' .
- ' src="' . $this->preferences->getURL() . $this->routeparser->urlFor('logo') . '"' .
- ' width="' . $logo->getOptimalWidth() . '"' .
- ' height="' . $logo->getOptimalHeight() . '"' .
- '/>';
+ if ($this->mail !== null) {
+ $logo_content = $this->preferences->getURL() . $this->routeparser->urlFor('logo');
+ } else {
+ $logo_content = '@' . base64_encode(file_get_contents($logo->getPath()));
+ }
+ $logo_elt = sprintf(
+ '<img src="%1$s" width="%2$s" height="%3$s" alt="" />',
+ $logo_content,
+ $logo->getOptimalWidth(),
+ $logo->getOptimalHeight()
+ );
$this->setReplacements(
array(
//TRANS: see https://www.php.net/manual/datetime.format.php
'date_now' => date(_T('Y-m-d')),
'login_uri' => $this->preferences->getURL() . $this->routeparser->urlFor('login'),
+ 'asso_footer' => $this->preferences->pref_footer
)
);
*/
protected function proceedReplacements(string $source): string
{
- $replaced = $source;
-
//handle translations
$callback = static function ($matches) {
return _T($matches[1]);
$replaced
);
- return $replaced;
+ return trim($replaced);
}
/**