Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
archery
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
archery
Commits
97f03895
Commit
97f03895
authored
Nov 12, 2014
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added link to othe user's matches to admin view
parent
21d75827
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
9 deletions
+35
-9
app.php
app.php
+5
-2
locale/nl_NL/LC_MESSAGES/archery.po
locale/nl_NL/LC_MESSAGES/archery.po
+6
-0
routes/match.php
routes/match.php
+13
-6
routes/user.php
routes/user.php
+4
-0
templates/match/list.latte
templates/match/list.latte
+5
-1
templates/user/list.latte
templates/user/list.latte
+2
-0
No files found.
app.php
View file @
97f03895
...
...
@@ -45,8 +45,11 @@ $view = new Slim\Latte\LatteView(array(
'cache'
=>
__DIR__
.
'/.cache/latte'
,
'configure_engine'
=>
function
(
$engine
)
{
// support for {_'...'} syntax in latte templates
$engine
->
addFilter
(
'translate'
,
function
(
$s
)
{
return
gettext
(
$s
);
$engine
->
addFilter
(
'translate'
,
function
()
{
$args
=
func_get_args
();
assert
(
count
(
$args
)
>
0
);
$fmt
=
gettext
(
array_shift
(
$args
));
return
strpos
(
$fmt
,
'%s'
)
!==
false
?
vsprintf
(
$fmt
,
$args
)
:
$fmt
;
});
// install {form} macro's from Bootstrap form renderer
...
...
locale/nl_NL/LC_MESSAGES/archery.po
View file @
97f03895
...
...
@@ -216,6 +216,12 @@ msgstr "administrator"
msgid "member"
msgstr "gebruiker"
msgid "View matches"
msgstr "Bekijk scores"
msgid "%s's matches"
msgstr "Scores van %s"
msgid ""
"Responsive (mobile and desktop) website for saving archery scores, e.g. from "
"training or competitions."
...
...
routes/match.php
View file @
97f03895
...
...
@@ -10,7 +10,7 @@ function render_match_action($action) {
};
}
function
filter_form
(
$matches
)
{
function
filter_form
(
$matches
,
$user_id
=
null
)
{
global
$db
;
$match_ids
=
array_unique
(
$matches
->
fetchPairs
(
null
,
'id'
));
...
...
@@ -26,7 +26,7 @@ function filter_form($matches) {
$form
=
new
Form
;
$form
->
setRenderer
(
new
BootstrapRenderer
);
$form
->
setAction
(
'matches#results'
);
$form
->
setAction
(
(
$user_id
?
'user/'
.
$user_id
.
'/'
:
''
)
.
'matches#results'
);
$form
->
setMethod
(
'get'
);
$form
->
addSelect
(
'distance'
,
_
(
'Distance'
),
$distances
)
...
...
@@ -129,12 +129,14 @@ function create_tag($match, $tagname) {
}
catch
(
PDOException
$e
)
{}
}
$app
->
get
(
'/matches'
,
function
(
$filter
=
null
)
use
(
$app
,
$db
,
$user
)
{
function
user_matches
(
$user_id
,
$admin_view
)
{
global
$app
,
$db
;
$matches
=
$db
->
table
(
'match'
)
->
where
(
array
(
'user_id'
=>
$user
->
getId
()
))
->
where
(
array
(
'user_id'
=>
$user
_id
))
->
order
(
'created_at DESC'
);
$filter_form
=
filter_form
(
$matches
);
$filter_form
=
filter_form
(
$matches
,
$admin_view
?
$user_id
:
null
);
if
(
$filter_form
->
isSubmitted
())
{
$values
=
$filter_form
->
getValues
();
...
...
@@ -151,7 +153,12 @@ $app->get('/matches', function ($filter=null) use ($app, $db, $user) {
$matches
->
where
(
'name LIKE ?'
,
"%
$values->name
%"
);
}
$app
->
render
(
'match/list'
,
compact
(
'matches'
,
'filter_form'
));
$dbuser
=
$admin_view
?
find_user
(
$user_id
)
:
null
;
$app
->
render
(
'match/list'
,
compact
(
'matches'
,
'filter_form'
,
'dbuser'
));
}
$app
->
get
(
'/matches'
,
function
()
use
(
$user
)
{
return
user_matches
(
$user
->
getId
(),
false
);
});
$app
->
get
(
'/match/:id'
,
render_match_action
(
'view'
));
$app
->
get
(
'/match/:id/scores'
,
render_match_action
(
'scores'
));
...
...
routes/user.php
View file @
97f03895
...
...
@@ -45,6 +45,10 @@ $app->get('/user/:id', function ($id) use ($app, $db) {
$app
->
render
(
'user/view'
,
array
(
'dbuser'
=>
find_user
(
$id
)));
});
$app
->
get
(
'/user/:id/matches'
,
function
(
$id
)
{
return
user_matches
(
$id
,
true
);
});
$app
->
get
(
'/user/:id/edit'
,
function
(
$id
)
use
(
$app
)
{
$dbuser
=
find_user
(
$id
);
$form
=
edit_user_form
(
$dbuser
);
...
...
templates/match/list.latte
View file @
97f03895
...
...
@@ -2,7 +2,11 @@
{block content}
<h2 class="page-header">
{_'Matches'}
{if $dbuser}
{_'%s\'s matches', $dbuser->username}
{else}
{_'Matches'}
{/if}
<div class="btn-group">
<a href="match" class="btn btn-sm btn-default" title="{_'Add new match'}">
<span class="glyphicon glyphicon-plus"></span>
...
...
templates/user/list.latte
View file @
97f03895
...
...
@@ -10,6 +10,7 @@
<th>{_'Username'}</th>
<th>{_'Role'}</th>
<th>{_'Matches'}</th>
<th></th>
</tr>
</thead>
<tbody>
...
...
@@ -19,6 +20,7 @@
<td>{$user->username}</td>
<td>{_$user->role}</td>
<td>{$h->numberOfMatches()}</td>
<td><a href="user/{$user->id}/matches">{_'View matches'}</a></td>
</tr>
</tbody>
</table>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment