Browse Source

can now keep track of likes and dislikes

master
Cerys 4 weeks ago
parent
commit
c222e3f987
  1. 6
      Localisation/en-GB.yaml
  2. 41
      Pages/profile.php
  3. 46
      Public/Static/CSS/Elements/Tabs.css
  4. 1
      Public/Static/CSS/Mapper.css
  5. 112
      Templates/Pages/profile.html.twig

6
Localisation/en-GB.yaml

@ -23,6 +23,7 @@ Confirm New Password: Confirm New Password
Confirm Password: Confirm Password
Copyright: Copyright
Create an Account: Create an Account
Created At: Created At
@ -89,6 +90,10 @@ Logout: Logout
##################################################
# M
##################################################
My Bookmarked Tunes: My Bookmarked Tunes
My Disliked Tunes: My Disliked Tunes
My Liked Tunes: My Liked Tunes
My Uploaded Tunes: My Uploaded Tunes
@ -137,6 +142,7 @@ Summary: Summary
# T
##################################################
Time Signature: Time Signature
Title: Title

41
Pages/profile.php

@ -18,10 +18,51 @@ $yourTunes = $db->RunSelect(
->bindValue(name: '__user_id__', value: SessionWrapper::Get(target: SessionElement::USER_ID))
);
$yourLikedTunes = $db->RunSelect(
queryBuilder: \App\Wrappers\SQLQueryBuilderWrapper::SELECT(
table: 'TuneRatings'
)
->cols(cols: [
'T_T.Title',
'T_T.CreatedAt',
'T_T.Copyright',
])
->join(
join: 'INNER',
spec: 'Tunes AS T_T',
cond: 'T.TuneID=T_T.ID',
)
->where(cond: 'T.CreatedBy LIKE :__user_id__')
->where(cond: 'Rating = 1')
->bindValue(name: '__user_id__', value: SessionWrapper::Get(target: SessionElement::USER_ID))
);
$yourDislikedTunes = $db->RunSelect(
queryBuilder: \App\Wrappers\SQLQueryBuilderWrapper::SELECT(
table: 'TuneRatings'
)
->cols(cols: [
'T_T.Title',
'T_T.CreatedAt',
'T_T.Copyright',
])
->join(
join: 'INNER',
spec: 'Tunes AS T_T',
cond: 'T.TuneID=T_T.ID',
)
->where(cond: 'T.CreatedBy LIKE :__user_id__')
->where(cond: 'Rating = 0')
->bindValue(name: '__user_id__', value: SessionWrapper::Get(target: SessionElement::USER_ID))
);
TwigWrapper::RenderTwig(
target: "Pages/profile.html.twig",
arguments: [
"YourTunes" => $yourTunes,
"YourDances" => [],
"YourLikedTunes"=> $yourLikedTunes,
"YourDislikedTunes"=> $yourDislikedTunes,
"YourBookmarkedTunes"=> [],
],
);

46
Public/Static/CSS/Elements/Tabs.css

@ -0,0 +1,46 @@
.Tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
.Tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 17px;
}
.Tab button:hover {
background-color: #ddd;
}
.Tab button.active {
background-color: #ccc;
}
.TabLink {
}
.TabContent {
display: none;
padding: 6px 12px;
-webkit-animation: fadeEffect 1s;
animation: TabContentFadeEffect 1s;
}
@-webkit-keyframes TabContentFadeEffect {
from {opacity: 0;}
to {opacity: 1;}
}
@keyframes TabContentFadeEffect {
from {opacity: 0;}
to {opacity: 1;}
}

1
Public/Static/CSS/Mapper.css

@ -14,4 +14,5 @@
@import "/Static/CSS/Elements/HomePage.css";
@import "/Static/CSS/Elements/NavBar.css";
@import "/Static/CSS/Elements/Rating.css";
@import "/Static/CSS/Elements/Tabs.css";

112
Templates/Pages/profile.html.twig

@ -18,34 +18,92 @@
</dl>
</div>
<h2>{{ "Your Tunes"|translate }}</h2>
<table>
<thead>
<tr>
<th>{{ "Title"|translate }}</th>
<th>{{ "Created At"|translate }}</th>
<th>{{ "Copyright"|translate }}</th>
</tr>
</thead>
<tbody>
{% for tuneDetails in YourTunes %}
<div class="Tab">
<button id="DefaultOpenTab" class="TabLink" onclick="openTuneTab(event, 'MyUploadedTunes')">{{ "My Uploaded Tunes"|translate }}</button>
<button class="TabLink" onclick="openTuneTab(event, 'MyLikedTunes')">{{ "My Liked Tunes"|translate }}</button>
<button class="TabLink" onclick="openTuneTab(event, 'MyDislikedTunes')">{{ "My Disliked Tunes"|translate }}</button>
</div>
<div id="MyUploadedTunes" class="TabContent">
<h2>{{ "My Uploaded Tunes"|translate }}</h2>
<table>
<thead>
<tr>
<th>{{ "Title"|translate }}</th>
<th>{{ "Created At"|translate }}</th>
<th>{{ "Copyright"|translate }}</th>
</tr>
</thead>
<tbody>
{% for tuneDetails in YourTunes %}
<tr>
<td><a href="/tune/{{ tuneDetails.ID }}">{{ tuneDetails.Title }}</a></td>
<td>{{ tuneDetails.CreatedAt }}</td>
<td>{{ tuneDetails.Copyright }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div id="MyLikedTunes" class="TabContent">
<h2>{{ "My Liked Tunes"|translate }}</h2>
<table>
<thead>
<tr>
<td><a href="/tune/{{ tuneDetails.ID }}">{{ tuneDetails.Title }}</a></td>
<td>{{ tuneDetails.CreatedAt }}</td>
<td>{{ tuneDetails.Copyright }}</td>
<th>{{ "Title"|translate }}</th>
<th>{{ "Created At"|translate }}</th>
<th>{{ "Copyright"|translate }}</th>
</tr>
{% endfor %}
</tbody>
</table>
<h2>{{ "Your Dances"|translate }}</h2>
<table>
<thead>
<tr>
<th>{{ "Title"|translate }}</th>
<th>{{ "Created At"|translate }}</th>
</tr>
</thead>
</table>
</thead>
<tbody>
{% for tuneDetails in YourLikedTunes %}
<tr>
<td><a href="/tune/{{ tuneDetails.ID }}">{{ tuneDetails.Title }}</a></td>
<td>{{ tuneDetails.CreatedAt }}</td>
<td>{{ tuneDetails.Copyright }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div id="MyDislikedTunes" class="TabContent">
<h2>{{ "My Disliked Tunes"|translate }}</h2>
<table>
<thead>
<tr>
<th>{{ "Title"|translate }}</th>
<th>{{ "Created At"|translate }}</th>
<th>{{ "Copyright"|translate }}</th>
</tr>
</thead>
<tbody>
{% for tuneDetails in YourDislikedTunes %}
<tr>
<td><a href="/tune/{{ tuneDetails.ID }}">{{ tuneDetails.Title }}</a></td>
<td>{{ tuneDetails.CreatedAt }}</td>
<td>{{ tuneDetails.Copyright }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<script>
document.getElementById("DefaultOpenTab").click();
function openTuneTab(evt, cityName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("TabContent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("TabLink");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}
</script>
{% endblock %}

Loading…
Cancel
Save