]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Profile.php
Merge pull request #8155 from nupplaphil/task/move_notifications
[friendica.git] / src / Model / Profile.php
index 6699c828722bb487b50954732c6e6b22eee3abdc..b993562cecc76ab140266ae3e48458f49a114336 100644 (file)
@@ -11,9 +11,7 @@ use Friendica\Content\Text\BBCode;
 use Friendica\Content\Text\HTML;
 use Friendica\Content\Widget\ContactBlock;
 use Friendica\Core\Cache\Duration;
-use Friendica\Core\Config;
 use Friendica\Core\Hook;
-use Friendica\Core\L10n;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
@@ -128,13 +126,13 @@ class Profile
         *
         * @param App     $a
         * @param string  $nickname     string
-        * @param int     $profile      int
+        * @param int     $profile_id   int
         * @param array   $profiledata  array
         * @param boolean $show_connect Show connect link
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       public static function load(App $a, $nickname, $profile = 0, array $profiledata = [], $show_connect = true)
+       public static function load(App $a, $nickname, $profile_id = 0, array $profiledata = [], $show_connect = true)
        {
                $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nickname, 'account_removed' => false]);
 
@@ -157,34 +155,34 @@ class Profile
                        }
                }
 
-               $pdata = self::getByNickname($nickname, $user['uid'], $profile);
+               $profile = self::getByNickname($nickname, $user['uid'], $profile_id);
 
-               if (empty($pdata) && empty($profiledata)) {
+               if (empty($profile) && empty($profiledata)) {
                        Logger::log('profile error: ' . DI::args()->getQueryString(), Logger::DEBUG);
                        return;
                }
 
-               if (empty($pdata)) {
-                       $pdata = ['uid' => 0, 'profile_uid' => 0, 'is-default' => false,'name' => $nickname];
+               if (empty($profile)) {
+                       $profile = ['uid' => 0, 'is-default' => false,'name' => $nickname];
                }
 
                // fetch user tags if this isn't the default profile
 
-               if (!$pdata['is-default']) {
-                       $condition = ['uid' => $pdata['profile_uid'], 'is-default' => true];
-                       $profile = DBA::selectFirst('profile', ['pub_keywords'], $condition);
-                       if (DBA::isResult($profile)) {
-                               $pdata['pub_keywords'] = $profile['pub_keywords'];
+               if (!$profile['is-default']) {
+                       $condition = ['uid' => $profile['uid'], 'is-default' => true];
+                       $profile_id = DBA::selectFirst('profile', ['pub_keywords'], $condition);
+                       if (DBA::isResult($profile_id)) {
+                               $profile['pub_keywords'] = $profile_id['pub_keywords'];
                        }
                }
 
-               $a->profile = $pdata;
-               $a->profile_uid = $pdata['profile_uid'];
+               $a->profile = $profile;
+               $a->profile_uid = $profile['uid'];
 
-               $a->profile['mobile-theme'] = DI::pConfig()->get($a->profile['profile_uid'], 'system', 'mobile_theme');
+               $a->profile['mobile-theme'] = DI::pConfig()->get($a->profile['uid'], 'system', 'mobile_theme');
                $a->profile['network'] = Protocol::DFRN;
 
-               DI::page()['title'] = $a->profile['name'] . ' @ ' . Config::get('config', 'sitename');
+               DI::page()['title'] = $a->profile['name'] . ' @ ' . DI::config()->get('config', 'sitename');
 
                if (!$profiledata && !DI::pConfig()->get(local_user(), 'system', 'always_my_theme')) {
                        $a->setCurrentTheme($a->profile['theme']);
@@ -212,7 +210,7 @@ class Profile
                        );
                }
 
-               $block = ((Config::get('system', 'block_public') && !Session::isAuthenticated()) ? true : false);
+               $block = ((DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) ? true : false);
 
                /**
                 * @todo
@@ -257,7 +255,7 @@ class Profile
                        $profile = DBA::fetchFirst(
                                "SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` AS `contact_photo`,
                                        `contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
-                                       `profile`.`uid` AS `profile_uid`, `profile`.*,
+                                       `profile`.*,
                                        `contact`.`avatar-date` AS picdate, `contact`.`addr`, `contact`.`url`, `user`.*
                                FROM `profile`
                                INNER JOIN `contact` on `contact`.`uid` = `profile`.`uid` AND `contact`.`self`
@@ -271,7 +269,7 @@ class Profile
                        $profile = DBA::fetchFirst(
                                "SELECT `contact`.`id` AS `contact_id`, `contact`.`photo` as `contact_photo`,
                                        `contact`.`thumb` AS `contact_thumb`, `contact`.`micro` AS `contact_micro`,
-                                       `profile`.`uid` AS `profile_uid`, `profile`.*,
+                                       `profile`.*,
                                        `contact`.`avatar-date` AS picdate, `contact`.`addr`, `contact`.`url`, `user`.*
                                FROM `profile`
                                INNER JOIN `contact` ON `contact`.`uid` = `profile`.`uid` AND `contact`.`self`
@@ -352,7 +350,7 @@ class Profile
 
                $profile_is_dfrn = $profile['network'] == Protocol::DFRN;
                $profile_is_native = in_array($profile['network'], Protocol::NATIVE_SUPPORT);
-               $local_user_is_self = local_user() && local_user() == ($profile['profile_uid'] ?? 0);
+               $local_user_is_self = local_user() && local_user() == ($profile['uid'] ?? 0);
                $visitor_is_authenticated = (bool)self::getMyURL();
                $visitor_is_following =
                        in_array($visitor_contact['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND])
@@ -529,7 +527,7 @@ class Profile
 
                $p['url'] = Contact::magicLink(($p['url'] ?? '') ?: $profile_url);
 
-               $tpl = Renderer::getMarkupTemplate('profile_vcard.tpl');
+               $tpl = Renderer::getMarkupTemplate('profile/vcard.tpl');
                $o .= Renderer::replaceMacros($tpl, [
                        '$profile' => $p,
                        '$xmpp' => $xmpp,
@@ -640,7 +638,7 @@ class Profile
 
                                        $rr['link'] = Contact::magicLink($rr['url']);
                                        $rr['title'] = $rr['name'];
-                                       $rr['date'] = L10n::getDay(DateTimeFormat::convert($rr['start'], $a->timezone, 'UTC', $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . DI::l10n()->t('[today]') : '');
+                                       $rr['date'] = DI::l10n()->getDay(DateTimeFormat::convert($rr['start'], $a->timezone, 'UTC', $rr['adjust'] ? $bd_format : $bd_short)) . (($today) ? ' ' . DI::l10n()->t('[today]') : '');
                                        $rr['startime'] = null;
                                        $rr['today'] = $today;
                                }
@@ -725,7 +723,7 @@ class Profile
 
                                $rr['title'] = $title;
                                $rr['description'] = $description;
-                               $rr['date'] = L10n::getDay(DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->timezone : 'UTC', 'UTC', $bd_format)) . (($today) ? ' ' . DI::l10n()->t('[today]') : '');
+                               $rr['date'] = DI::l10n()->getDay(DateTimeFormat::convert($rr['start'], $rr['adjust'] ? $a->timezone : 'UTC', 'UTC', $bd_format)) . (($today) ? ' ' . DI::l10n()->t('[today]') : '');
                                $rr['startime'] = $strt;
                                $rr['today'] = $today;
 
@@ -749,8 +747,6 @@ class Profile
                $uid = intval($a->profile['uid']);
 
                if ($a->profile['name']) {
-                       $tpl = Renderer::getMarkupTemplate('profile_advanced.tpl');
-
                        $profile = [];
 
                        $profile['fullname'] = [DI::l10n()->t('Full Name:'), $a->profile['name']];
@@ -767,7 +763,7 @@ class Profile
                                $year_bd_format = DI::l10n()->t('j F, Y');
                                $short_bd_format = DI::l10n()->t('j F');
 
-                               $val = L10n::getDay(
+                               $val = DI::l10n()->getDay(
                                        intval($a->profile['dob']) ?
                                                DateTimeFormat::utc($a->profile['dob'] . ' 00:00 +00:00', $year_bd_format)
                                                : DateTimeFormat::utc('2001-' . substr($a->profile['dob'], 5) . ' 00:00 +00:00', $short_bd_format)
@@ -778,9 +774,9 @@ class Profile
 
                        if (!empty($a->profile['dob'])
                                && $a->profile['dob'] > DBA::NULL_DATE
-                               && $age = Temporal::getAgeByTimezone($a->profile['dob'], $a->profile['timezone'], '')
+                               && $age = Temporal::getAgeByTimezone($a->profile['dob'], $a->profile['timezone'])
                        ) {
-                               $profile['age'] = [DI::l10n()->t('Age:'), $age];
+                               $profile['age'] = [DI::l10n()->t('Age: ') , DI::l10n()->tt('%d year old', '%d years old', $age)];
                        }
 
                        if ($a->profile['marital']) {
@@ -877,6 +873,7 @@ class Profile
                                $profile['edit'] = [DI::baseUrl() . '/profiles/' . $a->profile['id'], DI::l10n()->t('Edit profile'), '', DI::l10n()->t('Edit profile')];
                        }
 
+                       $tpl = Renderer::getMarkupTemplate('profile/advanced.tpl');
                        return Renderer::replaceMacros($tpl, [
                                '$title' => DI::l10n()->t('Profile'),
                                '$basic' => DI::l10n()->t('Basic'),
@@ -1232,7 +1229,7 @@ class Profile
         */
        public static function searchProfiles($start = 0, $count = 100, $search = null)
        {
-               $publish = (Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 ");
+               $publish = (DI::config()->get('system', 'publish_all') ? '' : " AND `publish` = 1 ");
                $total = 0;
 
                if (!empty($search)) {