]> git.mxchange.org Git - friendica-addons.git/blob - membersince/membersince.php
Merge pull request 'translation updates' (#1448) from tobias/friendica-addons:2023121...
[friendica-addons.git] / membersince / membersince.php
1 <?php
2 /**
3  * Name: MemberSince
4  * Description: Display membership date in profile
5  * Version: 1.1
6  * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
7  * Status: Unsupported
8  */
9
10 use Friendica\App;
11 use Friendica\Core\Hook;
12 use Friendica\DI;
13 use Friendica\Util\DateTimeFormat;
14
15 function membersince_install()
16 {
17         Hook::register('profile_advanced', 'addon/membersince/membersince.php', 'membersince_display');
18 }
19
20 function membersince_display(array &$b)
21 {
22         if (DI::app()->getCurrentTheme() == 'frio') {
23                 // Works in Frio.
24                 $doc = new DOMDocument();
25                 $doc->loadHTML(mb_convert_encoding($b, 'HTML-ENTITIES', 'UTF-8'));
26
27                 $elm = $doc->getElementById('aprofile-fullname');
28
29                 $div = $doc->createElement('div');
30                 $div->setAttribute('id','aprofile-membersince');
31                 $div->setAttribute('class','col-lg-12 col-md-12 col-sm-12 col-xs-12 aprofile');
32
33                 // The seperator line.
34                 $hr = $doc->createElement('hr','');
35                 $hr->setAttribute('class','profile-separator');
36
37                 // The label div.
38                 $label = $doc->createElement('div', DI::l10n()->t('Member since:'));
39                 $label->setAttribute('class', 'col-lg-4 col-md-4 col-sm-4 col-xs-12 profile-label-name text-muted');
40
41                 // The div for the register date of the profile owner.
42                 $entry = $doc->createElement('div', DateTimeFormat::local(DI::app()->profile['register_date']));
43                 $entry->setAttribute('class', 'col-lg-8 col-md-8 col-sm-8 col-xs-12 profile-entry');
44
45                 $div->appendChild($hr);
46                 $div->appendChild($label);
47                 $div->appendChild($entry);
48                 $elm->parentNode->insertBefore($div, $elm->nextSibling);
49
50                 $b = $doc->saveHTML();
51         } else {
52                 // Works in Vier.
53                 $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(DI::app()->profile['register_date']) . "</dd>\n</dl>", $b, 1);
54         }
55 }