4 * Description: Display membership date in profile
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
10 use Friendica\Core\Hook;
12 use Friendica\Util\DateTimeFormat;
14 function membersince_install()
16 Hook::register('profile_advanced', 'addon/membersince/membersince.php', 'membersince_display');
19 function membersince_uninstall()
21 Hook::unregister('profile_advanced', 'addon/membersince/membersince.php', 'membersince_display');
24 function membersince_display(Friendica\App $a, &$b)
26 if ($a->getCurrentTheme() == 'frio') {
28 $doc = new DOMDocument();
29 $doc->loadHTML(mb_convert_encoding($b, 'HTML-ENTITIES', 'UTF-8'));
31 $elm = $doc->getElementById('aprofile-fullname');
33 $div = $doc->createElement('div');
34 $div->setAttribute('id','aprofile-membersince');
35 $div->setAttribute('class','col-lg-12 col-md-12 col-sm-12 col-xs-12 aprofile');
37 // The seperator line.
38 $hr = $doc->createElement('hr','');
39 $hr->setAttribute('class','profile-separator');
42 $label = $doc->createElement('div', DI::l10n()->t('Member since:'));
43 $label->setAttribute('class', 'col-lg-4 col-md-4 col-sm-4 col-xs-12 profile-label-name text-muted');
45 // The div for the register date of the profile owner.
46 $entry = $doc->createElement('div', DateTimeFormat::local($a->profile['register_date']));
47 $entry->setAttribute('class', 'col-lg-8 col-md-8 col-sm-8 col-xs-12 profile-entry');
49 $div->appendChild($hr);
50 $div->appendChild($label);
51 $div->appendChild($entry);
52 $elm->parentNode->insertBefore($div, $elm->nextSibling);
54 $b = $doc->saveHTML();
57 $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);