codesignd website at codesignd.com/codesignd.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

42 lines
1.0 KiB

<?php
/**
* Returns the current qdated address
* If qdated is not available, returns null
*
* @return string
*/
function qdated() {
$path = $_SERVER['HOME'] . '/.config/qdated/cddmail2/current';
if(!is_file($path)) return null;
return 'dated-' . trim(f::read($path)) . '@' . url::host();
}
/**
* Returns an HTML a mailto tag with the current qdated address
* If qdated is not available, returns an HTML error message
*
* @param mixed $text Optional text for the link
* Can also be true to use the email
* address but put a line break in it
* @return string HTML code
*/
function qdatedHtml($text = false) {
$email = qdated();
if(!$email) return '<p><strong>' . l::get('qdated.error') . '</strong></p>';
if($text === true) $text = str_replace('@', '<br>@', $email);
return str::email($email, $text);
}
/**
* qdated Kirbytag
*
* Usage: (qdated: Optional link text)
*/
kirby()->set('tag', 'qdated', [
'html' => function($tag) {
return qdatedHtml($tag->attr('qdated'));
}
]);