Skip to content

Commit

Permalink
Исправил вывод имени вместо логина на форуме
Browse files Browse the repository at this point in the history
  • Loading branch information
visavi committed May 27, 2018
1 parent facf6b9 commit c6260c2
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 19 deletions.
13 changes: 9 additions & 4 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -1525,11 +1525,12 @@ function counterString($file)
/**
* Возвращает ссылку на профиль пользователя
*
* @param User $user объект пользователя
* @param string $color цвет логина
* @param User $user объект пользователя
* @param string $color цвет логина
* @param boolean $link выводить как ссылку
* @return string путь к профилю
*/
function profile(User $user, $color = null)
function profile(User $user, $color = null, $link = true)
{
if ($user->id) {
$name = empty($user->name) ? $user->login : $user->name;
Expand All @@ -1538,7 +1539,11 @@ function profile(User $user, $color = null)
$name = '<span style="color:' . $color . '">' . $name . '</span>';
}

return '<a class="author" href="/users/' . $user->login . '" data-login="' . $user->login . '">' . $name . '</a>';
if ($link) {
return '<a class="author" href="/users/' . $user->login . '" data-login="' . $user->login . '">' . $name . '</a>';
}

return '<span class="author" data-login="' . $user->login . '">' . $name . '</span>';
}

return '<span class="author" data-login="' . setting('guestsuser') . '">' . setting('guestsuser') . '</span>';
Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/forums/forum.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div>
@if ($topic->lastPost)
{!! $topic->pagination('/admin/topics') !!}
Сообщение: {{ $topic->lastPost->user->login }} ({{ dateFixed($topic->lastPost->created_at) }})
Сообщение: {!! profile($topic->lastPost->user, null, false) !!} ({{ dateFixed($topic->lastPost->created_at) }})
@endif
</div>
@endforeach
Expand Down
2 changes: 1 addition & 1 deletion resources/views/admin/forums/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
@if ($forum->lastTopic->lastPost->id)
Тема: <a href="/admin/topics/end/{{ $forum->lastTopic->id }}">{{ $forum->lastTopic->title }}</a>
<br/>
Сообщение: {{ $forum->lastTopic->lastPost->user->login }} ({{ dateFixed($forum->lastTopic->lastPost->created_at) }})
Сообщение: {!! profile($forum->lastTopic->lastPost->user, null, false) !!} ({{ dateFixed($forum->lastTopic->lastPost->created_at) }})
@else
Темы еще не созданы!
@endif
Expand Down
6 changes: 3 additions & 3 deletions resources/views/blogs/tags_search.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<h3>Поиск запроса &quot;{{ $tag }}&quot; в метках</h3>
Найдено совпадений: <b>{{ $page->total }}</b><br>

<?php foreach($blogs as $data): ?>
@foreach($blogs as $data)

<div class="b">
<i class="fa fa-pencil-alt"></i>
Expand All @@ -30,9 +30,9 @@
Категория: <a href="/blogs/{{ $data->category_id }}">{{ $data->name }}</a><br>
Просмотров: {{ $data->visits }}<br>
Метки: {{ $data->tags }}<br>
Автор: <?= profile($data->user) ?> (<?=dateFixed($data->created_at)?>)
Автор: {!! profile($data->user) !!} ({{ dateFixed($data->created_at) }})
</div>
<?php endforeach; ?>
@endforeach

{!! pagination($page) !!}
@stop
2 changes: 1 addition & 1 deletion resources/views/forums/active_topics.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<div>
{!! $data->pagination() !!}
Форум: <a href="/forums/{{ $data->forum->id }}">{{ $data->forum->title }}</a><br>
Автор: {{ $data->user->login }} / Посл.: {{ $data->lastPost->user->login }} ({{ dateFixed($data->lastPost->created_at) }})
Автор: {!! profile($data->user, null, false) !!} / Посл.: {!! profile($data->lastPost->user, null, false) !!} ({{ dateFixed($data->lastPost->created_at) }})
</div>
@endforeach

Expand Down
4 changes: 2 additions & 2 deletions resources/views/forums/bookmark.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

<div>
{!! $topic->topic->pagination() !!}
Автор: {{ $topic->topic->user->login }} /
Посл.: {{ $topic->topic->lastPost->user->login }}
Автор: {!! profile($topic->topic->user, null, false) !!} /
Посл.: {!! profile($topic->topic->lastPost->user, null, false) !!}
({{ dateFixed($topic->topic->lastPost->created_at) }})
</div>
@endforeach
Expand Down
4 changes: 2 additions & 2 deletions resources/views/forums/forum.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<div>
Тема: <a href="/topics/end/{{ $child->lastTopic->id }}">{{ $child->lastTopic->title }}</a><br>
@if ($child->lastTopic->lastPost->id)
Сообщение: {{ $child->lastTopic->lastPost->user->login }} ({{ dateFixed($child->lastTopic->lastPost->created_at) }})
Сообщение: {!! profile($child->lastTopic->lastPost->user, null, false) !!} ({{ dateFixed($child->lastTopic->lastPost->created_at) }})
@endif
</div>
@else
Expand All @@ -64,7 +64,7 @@
<div>
@if ($topic->lastPost)
{!! $topic->pagination() !!}
Сообщение: {{ $topic->lastPost->user->login }} ({{ dateFixed($topic->lastPost->created_at) }})
Сообщение: {!! profile($topic->lastPost->user, null, false) !!} ({{ dateFixed($topic->lastPost->created_at) }})
@endif
</div>
@endforeach
Expand Down
2 changes: 1 addition & 1 deletion resources/views/forums/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
@if ($forum->lastTopic->lastPost->id)
Тема: <a href="/topics/end/{{ $forum->lastTopic->id }}">{{ $forum->lastTopic->title }}</a>
<br/>
Сообщение: {{ $forum->lastTopic->lastPost->user->login }} ({{ dateFixed($forum->lastTopic->lastPost->created_at) }})
Сообщение: {!! profile($forum->lastTopic->lastPost->user, null, false) !!} ({{ dateFixed($forum->lastTopic->lastPost->created_at) }})
@else
Темы еще не созданы!
@endif
Expand Down
2 changes: 1 addition & 1 deletion resources/views/forums/new_topics.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div>
{!! $data->pagination() !!}
Форум: <a href="/forums/{{ $data->forum->id }}">{{ $data->forum->title }}</a><br>
Автор: {{ $data->user->login }} / Посл.: {{ $data->lastPost->user->login }} ({{ dateFixed($data->created_at) }})
Автор: {!! profile($data->user, null, false) !!} / Посл.: {!! profile($data->lastPost->user, null, false) !!} ({{ dateFixed($data->created_at) }})
</div>

@endforeach
Expand Down
2 changes: 1 addition & 1 deletion resources/views/forums/search_topics.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div>
{!! $topic->pagination() !!}
Раздел: <a href="/topics/{{ $topic->forum->id }}">{{ $topic->forum->title }}</a><br>
Сообщение: {{ $topic->lastPost->user->login }} ({{ dateFixed($topic->lastPost->created_at) }})
Сообщение: {!! profile($topic->lastPost->user, null, false) !!} ({{ dateFixed($topic->lastPost->created_at) }})
</div>
@endforeach

Expand Down
4 changes: 2 additions & 2 deletions resources/views/forums/top.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
</div>
<div>
{!! $data->pagination() !!}
Автор: {{ $data->user->login }}<br>
Сообщение: {{ $data->lastPost->user->login }} ({{ dateFixed($data->lastPost->created_at) }})
Автор: {!! profile($data->user, null, false) !!}<br>
Сообщение: {!! profile($data->lastPost->user, null, false) !!} ({{ dateFixed($data->lastPost->created_at) }})
</div>
@endforeach

Expand Down

0 comments on commit c6260c2

Please sign in to comment.