aboutsummaryrefslogtreecommitdiffhomepage
path: root/templates/actor_profile_page.php
blob: dbeb86abe52ffd91001d7ae42ff641b1ec149e75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

use Digitigrade\Model\Note;
use Digitigrade\Model\UserAccount;

call_template('skeleton', [
    'pageTitle' => "$actor->displayName - @" . $actor->getFullHandle(),
    'renderTitleHeading' => false,
    'ogTitle' => $actor->displayName,
    'ogDesc' => $actor->bio,
    'ogImage' => $actor->avatar ?? path_to_uri('/static/default-avatar.png'),
    'ogType' => 'profile',
    'ogHandle' => '@' . $actor->getFullHandle(true)
], function () {
    global $actor;
    $user = UserAccount::findByCurrentSession();

    call_template('actor_profile', ['actor' => $actor]);
    echo '<hr>';
    $notes = Note::findAllWithAuthor($actor, 20);
    if (count($notes) == 0) {
        call_template('placeholder_text', ['message' => __('user.notes.placeholder')]);
    } elseif ($user != null && $user->actor->blocks($actor)) {
        call_template('placeholder_text', ['message' => __('user.profile.notesHidden')]);
    } else {
        foreach ($notes as $n) {
            if ($n->isViewableBy($user))
                call_template('note', ['note' => $n]);
        }
        $countNotShown = Note::countWithAuthor($actor) - count($notes);
        if ($countNotShown >= 0) {
            call_template('placeholder_text', ['count' => $countNotShown]);
        }
    }
});