X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=membersince%2Fmembersince.php;h=635a0158dddd4ea12a7ef5450eeb26b976c980f8;hb=05d2707d501b7b1cdd98b0802121e69a6df7d05d;hp=25d1207c2ff8dfcd8ec2f1df26c8f9cc5d1b7b8d;hpb=391f57fa395a3ea79e76c1df9e1d66766136ca0f;p=friendica-addons.git diff --git a/membersince/membersince.php b/membersince/membersince.php old mode 100755 new mode 100644 index 25d1207c..635a0158 --- a/membersince/membersince.php +++ b/membersince/membersince.php @@ -1,17 +1,54 @@ - * + * Status: Unsupported */ -require_once('include/datetime.php'); +use Friendica\Core\Hook; +use Friendica\DI; +use Friendica\Util\DateTimeFormat; + +function membersince_install() +{ + Hook::register('profile_advanced', 'addon/membersince/membersince.php', 'membersince_display'); +} + +function membersince_display(Friendica\App $a, &$b) +{ + if ($a->getCurrentTheme() == 'frio') { + // Works in Frio. + $doc = new DOMDocument(); + $doc->loadHTML(mb_convert_encoding($b, 'HTML-ENTITIES', 'UTF-8')); + + $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. + $label = $doc->createElement('div', DI::l10n()->t('Member since:')); + $label->setAttribute('class', 'col-lg-4 col-md-4 col-sm-4 col-xs-12 profile-label-name text-muted'); -function membersince_install(){ register_hook('profile_advanced','addon/membersince/membersince.php','membersince_display'); } + // 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'); -function membersince_uninstall(){ unregister_hook('profile_advanced','addon/membersince/membersince.php','membersince_display'); } + $div->appendChild($hr); + $div->appendChild($label); + $div->appendChild($entry); + $elm->parentNode->insertBefore($div, $elm->nextSibling); -function membersince_display(&$a,&$b) { $b = str_replace('' . "\n" . '
',sprintf( t(' - Member since: %s') . EOL, datetime_convert('UTC',date_default_timezone_get(),$a->profile['register_date'])) . '' . "\n" . '',$b); } \ No newline at end of file + $b = $doc->saveHTML(); + } else { + // Works in Vier. + $b = preg_replace('/<\/dl>/', "\n\n\n