Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic sharing for achievements #663

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ajax/game_mark_shown.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
if (!$user_id)
throw new UnexpectedValueException();

$badge_id = $_POST['badge_id'];
$am = new AchievementsManager($user_id);
$am->set_all_seen();

Expand Down
12 changes: 12 additions & 0 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1628,3 +1628,15 @@ tr.valign-top td {
.ner-entity-text {
height: 26px;
}

.single-achievement-wrap {
text-align: center;
}

.single-achievement-wrap .achievement-wrap {
margin-top: 30px;
}

.slim-header {
font-weight: 400;
}
Binary file added assets/img/badges/share/aist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/badges/share/bobr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/badges/share/chameleon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/badges/share/dog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/badges/share/fish.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/badges/share/wantmore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,24 @@
$smarty->assign('manager', $am);
$smarty->display('achievements/all_achievements.tpl');
break;
case 'achievement':
if (!empty($_GET['uid']) && !empty($_GET['type'])) {
$uid = (int)$_GET['uid'];
$type = $_GET['type'];

$am = new AchievementsManager($uid);
$smarty->assign('user', get_user_info($uid));
$smarty->assign('user_id', $uid);

$all = $am->pull_all();

if (!empty($all[$type]) && $all[$type]->given) {

$smarty->assign('achievement', $all[$type]);
$smarty->display('achievements/one_achievement.tpl');
break;
}
}
default:
header("Location:index.php");
break;
Expand Down
14 changes: 14 additions & 0 deletions templates/achievements/one_achievement.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{extends file='common.tpl'}
{block name='content'}
<div class="single-achievement-wrap">
<h2 class="slim-header">Бейдж пользователя
<a href="{$web_prefix}/user.php?id={$user_id}">{$user['shown_name']}</a></h2>

{$a = $achievement}
<div class="achievement-wrap achievement-{$a->css_class} achievement-medium">
{if $a->level}
<div class="achievement-{$a->css_class}-level achievement-level">{$a->level}</div>
{/if}
</div>
</div>
{/block}
18 changes: 17 additions & 1 deletion templates/qa/user_splash.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{nocache}
{$titles = $achievements_titles}
{if $achievements_unseen}
<script type="text/javascript" src="//yastatic.net/share/share.js" charset="utf-8"></script>
<link rel="stylesheet" href="/assets/css/animate.min.css">
{assign var="single" value=count($achievements_unseen)==1}
<div class="modal hide fade a-modal {if $single}a-modal-square{/if}">
Expand All @@ -26,6 +27,20 @@
{$randomindex=$titles.global.cheers|@array_rand}
{$titles.global.cheers.$randomindex}
{/if}

{$desc = "Я получил(а) бейдж"}
{if $a->level > 1}
{$desc = "`$desc` `$a->level`-го уровня"}
{/if}
{$desc = "`$desc`!"}
<div class="yashare-auto-init"
data-yashareL10n="ru"
data-yashareType="none"
data-yashareQuickServices="vkontakte,facebook,twitter"
data-yashareTitle="{$desc}"
data-yashareDescription="На тебя тоже хватит!"
data-yashareImage="http://opencorpora.org/assets/img/badges/share/{$a->css_class}.png"
data-yashareLink="http://opencorpora.org/?page=achievement&uid={$smarty.session.user_id}&type={$a->css_class}"></div>
</div>
</div>
{/foreach}
Expand All @@ -39,8 +54,9 @@

<script>
$('.a-modal').on('shown', function() {
$.post("/ajax/game_mark_shown.php");

$(this).find('.bouncy').addClass("animated bounceIn");
// $.post("/ajax/game_mark_shown.php");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А это зачем?

});

$('.a-modal').modal('show');
Expand Down