2011-10-18 06:36:14 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Name: MemberSince
|
|
|
|
* Description: Display membership date in profile
|
2018-02-06 17:26:34 +00:00
|
|
|
* Version: 1.1
|
2011-10-18 06:36:14 +00:00
|
|
|
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
2018-02-09 20:26:48 +00:00
|
|
|
* Status: Unsupported
|
2011-10-18 06:36:14 +00:00
|
|
|
*/
|
2018-01-25 02:29:09 +00:00
|
|
|
|
2018-12-26 07:28:16 +00:00
|
|
|
use Friendica\Core\Hook;
|
2020-01-18 21:07:06 +00:00
|
|
|
use Friendica\DI;
|
2018-01-27 02:39:02 +00:00
|
|
|
use Friendica\Util\DateTimeFormat;
|
2011-10-18 06:36:14 +00:00
|
|
|
|
2018-01-20 13:57:41 +00:00
|
|
|
function membersince_install()
|
|
|
|
{
|
2018-12-26 07:28:16 +00:00
|
|
|
Hook::register('profile_advanced', 'addon/membersince/membersince.php', 'membersince_display');
|
2018-01-20 13:57:41 +00:00
|
|
|
}
|
2011-10-18 06:36:14 +00:00
|
|
|
|
2018-01-20 13:57:41 +00:00
|
|
|
function membersince_uninstall()
|
|
|
|
{
|
2018-12-26 07:28:16 +00:00
|
|
|
Hook::unregister('profile_advanced', 'addon/membersince/membersince.php', 'membersince_display');
|
2018-01-20 13:57:41 +00:00
|
|
|
}
|
2011-10-18 06:36:14 +00:00
|
|
|
|
2018-04-28 22:39:29 +00:00
|
|
|
function membersince_display(Friendica\App $a, &$b)
|
2018-01-20 13:57:41 +00:00
|
|
|
{
|
2018-04-28 22:39:29 +00:00
|
|
|
if ($a->getCurrentTheme() == 'frio') {
|
2018-02-06 17:24:03 +00:00
|
|
|
// Works in Frio.
|
|
|
|
$doc = new DOMDocument();
|
2018-02-07 16:01:27 +00:00
|
|
|
$doc->loadHTML(mb_convert_encoding($b, 'HTML-ENTITIES', 'UTF-8'));
|
2011-10-18 06:36:14 +00:00
|
|
|
|
2018-02-06 17:24:03 +00:00
|
|
|
$elm = $doc->getElementById('aprofile-fullname');
|
|
|
|
|
|
|
|
$div = $doc->createElement('div');
|
|
|
|
$div->setAttribute('id','aprofile-membersince');
|
|
|
|
$div->setAttribute('class','col-lg-12 col-md-12 col-sm-12 col-xs-12 aprofile');
|
|
|
|
|
|
|
|
// The seperator line.
|
|
|
|
$hr = $doc->createElement('hr','');
|
|
|
|
$hr->setAttribute('class','profile-separator');
|
|
|
|
|
|
|
|
// The label div.
|
2020-01-18 19:52:33 +00:00
|
|
|
$label = $doc->createElement('div', DI::l10n()->t('Member since:'));
|
2018-02-06 17:24:03 +00:00
|
|
|
$label->setAttribute('class', 'col-lg-4 col-md-4 col-sm-4 col-xs-12 profile-label-name text-muted');
|
|
|
|
|
|
|
|
// The div for the register date of the profile owner.
|
|
|
|
$entry = $doc->createElement('div', DateTimeFormat::local($a->profile['register_date']));
|
|
|
|
$entry->setAttribute('class', 'col-lg-8 col-md-8 col-sm-8 col-xs-12 profile-entry');
|
|
|
|
|
|
|
|
$div->appendChild($hr);
|
|
|
|
$div->appendChild($label);
|
|
|
|
$div->appendChild($entry);
|
2018-02-07 13:34:30 +00:00
|
|
|
$elm->parentNode->insertBefore($div, $elm->nextSibling);
|
2018-02-06 17:24:03 +00:00
|
|
|
|
|
|
|
$b = $doc->saveHTML();
|
|
|
|
} else {
|
|
|
|
// Works in Vier.
|
2020-01-18 19:52:33 +00:00
|
|
|
$b = preg_replace('/<\/dl>/', "</dl>\n\n\n<dl id=\"aprofile-membersince\" class=\"aprofile\">\n<dt>" . DI::l10n()->t('Member since:') . "</dt>\n<dd>" . DateTimeFormat::local($a->profile['register_date']) . "</dd>\n</dl>", $b, 1);
|
2018-02-06 17:24:03 +00:00
|
|
|
}
|
2018-01-20 13:57:41 +00:00
|
|
|
}
|