Skip to content
This repository was archived by the owner on Sep 19, 2022. It is now read-only.

Commit 1939f00

Browse files
Pavel Vyskočilvyskocilpavel
authored andcommitted
Move duplicate code for timeRange to separate file
1 parent 7eb98c6 commit 1939f00

File tree

7 files changed

+36
-131
lines changed

7 files changed

+36
-131
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
1717
- Using 'fetch_all' instead of 'fetch_asoc' to get data from DB
1818
- Set default values for some option in 'DatabaseConnector.php'
1919
- Remove duplicate code from 'DatabaseConnector.php'
20+
- Move duplicate code for timeRange to separate file
2021

2122
#### Fixed
2223
- Fixed the syntax of CHANGELOG

templates/identityProviders-tpl.php

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,11 @@
77
* @author Dominik Baránek <[email protected]>
88
*/
99

10-
$lastDays = $this->data['lastDays'];
10+
?>
1111

12+
<?php
13+
require 'timeRange.include.php';
1214
?>
13-
<div class="timeRange">
14-
<h4><?php echo $this->t('{proxystatistics:Proxystatistics:templates_time_range}'); ?></h4>
15-
<form id="dateSelector" method="post">
16-
<input name="tab" value="1" type="hidden">
17-
<label>
18-
<input id="1" type="radio" name="lastDays" value=0
19-
<?php echo ($lastDays == 0) ? "checked=true" : "" ?>>
20-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_all}'); ?>
21-
</label>
22-
<label>
23-
<input id="2" type="radio" name="lastDays" value=7
24-
<?php echo ($lastDays == 7) ? "checked=true" : "" ?>>
25-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_week}'); ?>
26-
</label>
27-
<label>
28-
<input id="3" type="radio" name="lastDays" value=30
29-
<?php echo ($lastDays == 30) ? "checked=true" : "" ?>>
30-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_month}'); ?>
31-
</label>
32-
<label>
33-
<input id="4" type="radio" name="lastDays" value=365
34-
<?php echo ($lastDays == 365) ? "checked=true" : "" ?>>
35-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_year}'); ?>
36-
</label>
37-
</form>
38-
</div>
3915

4016
<h2><?php echo $this->t('{proxystatistics:Proxystatistics:templates/graphs_id_providers}'); ?></h2>
4117
<div class="legend">

templates/idpDetail-tpl.php

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,9 @@
5656
</a>
5757
</div>
5858

59-
<div class="timeRange">
60-
<h4><?php echo $this->t('{proxystatistics:Proxystatistics:templates_time_range}'); ?></h4>
61-
<form id="dateSelector" method="post">
62-
<label>
63-
<input id="1" type="radio" name="lastDays" value=0
64-
onclick="this.form.submit()" <?php echo ($lastDays == 0) ? "checked=true" : "" ?>>
65-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_all}'); ?>
66-
</label>
67-
<label>
68-
<input id="2" type="radio" name="lastDays" value=7
69-
onclick="this.form.submit()" <?php echo ($lastDays == 7) ? "checked=true" : "" ?>>
70-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_week}'); ?>
71-
</label>
72-
<label>
73-
<input id="3" type="radio" name="lastDays" value=30
74-
onclick="this.form.submit()" <?php echo ($lastDays == 30) ? "checked=true" : "" ?>>
75-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_month}'); ?>
76-
</label>
77-
<label>
78-
<input id="4" type="radio" name="lastDays" value=365
79-
onclick="this.form.submit()" <?php echo ($lastDays == 365) ? "checked=true" : "" ?>>
80-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_year}'); ?>
81-
</label>
82-
</form>
83-
</div>
59+
<?php
60+
require 'timeRange.include.php';
61+
?>
8462

8563
<h3><?php echo $this->t('{proxystatistics:Proxystatistics:templates/idpDetail_dashboard_header}'); ?></h3>
8664

templates/serviceProviders-tpl.php

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,11 @@
66
* @author Dominik Baránek <[email protected]>
77
*/
88

9-
$lastDays = $this->data['lastDays'];
9+
?>
1010

11+
<?php
12+
require 'timeRange.include.php';
1113
?>
12-
<div class="timeRange">
13-
<h4><?php echo $this->t('{proxystatistics:Proxystatistics:templates_time_range}'); ?></h4>
14-
<form id="dateSelector" method="post">
15-
<input name="tab" value="2" type="hidden">
16-
<label>
17-
<input id="1" type="radio" name="lastDays" value=0
18-
<?php echo ($lastDays == 0) ? "checked=true" : "" ?>>
19-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_all}'); ?>
20-
</label>
21-
<label>
22-
<input id="2" type="radio" name="lastDays" value=7
23-
<?php echo ($lastDays == 7) ? "checked=true" : "" ?>>
24-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_week}'); ?>
25-
</label>
26-
<label>
27-
<input id="3" type="radio" name="lastDays" value=30
28-
<?php echo ($lastDays == 30) ? "checked=true" : "" ?>>
29-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_month}'); ?>
30-
</label>
31-
<label>
32-
<input id="4" type="radio" name="lastDays" value=365
33-
<?php echo ($lastDays == 365) ? "checked=true" : "" ?>>
34-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_year}'); ?>
35-
</label>
36-
</form>
37-
</div>
3814

3915
<h2><?php echo $this->t('{proxystatistics:Proxystatistics:templates/graphs_service_providers}'); ?></h2>
4016
<div class="legend">

templates/spDetail-tpl.php

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,9 @@
5656
</a>
5757
</div>
5858

59-
<div class="timeRange">
60-
<h4><?php echo $this->t('{proxystatistics:Proxystatistics:templates_time_range}'); ?></h4>
61-
<form id="dateSelector" method="post">
62-
<label>
63-
<input id="1" type="radio" name="lastDays" value=0
64-
<?php echo ($lastDays == 0) ? "checked=true" : "" ?>>
65-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_all}'); ?>
66-
</label>
67-
<label>
68-
<input id="2" type="radio" name="lastDays" value=7
69-
<?php echo ($lastDays == 7) ? "checked=true" : "" ?>>
70-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_week}'); ?>
71-
</label>
72-
<label>
73-
<input id="3" type="radio" name="lastDays" value=30
74-
<?php echo ($lastDays == 30) ? "checked=true" : "" ?>>
75-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_month}'); ?>
76-
</label>
77-
<label>
78-
<input id="4" type="radio" name="lastDays" value=365
79-
<?php echo ($lastDays == 365) ? "checked=true" : "" ?>>
80-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_year}'); ?>
81-
</label>
82-
</form>
83-
</div>
59+
<?php
60+
require 'timeRange.include.php';
61+
?>
8462

8563
<h3><?php echo $this->t('{proxystatistics:Proxystatistics:templates/spDetail_dashboard_header}'); ?></h3>
8664

templates/summary-tpl.php

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,11 @@
77
* @author Dominik Baránek <[email protected]>
88
*/
99

10-
$lastDays = $this->data['lastDays'];
10+
?>
1111

12+
<?php
13+
require 'timeRange.include.php';
1214
?>
13-
<div class="timeRange">
14-
<h4><?php echo $this->t('{proxystatistics:Proxystatistics:templates_time_range}'); ?></h4>
15-
<form id="dateSelector" method="post">
16-
<input name="tab" value="0" type="hidden">
17-
<label>
18-
<input id="1" type="radio" name="lastDays" value=0
19-
<?php echo ($lastDays == 0) ? "checked=true" : "" ?>>
20-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_all}'); ?>
21-
</label>
22-
<label>
23-
<input id="2" type="radio" name="lastDays" value=7
24-
<?php echo ($lastDays == 7) ? "checked=true" : "" ?>>
25-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_week}'); ?>
26-
</label>
27-
<label>
28-
<input id="3" type="radio" name="lastDays" value=30
29-
<?php echo ($lastDays == 30) ? "checked=true" : "" ?>>
30-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_month}'); ?>
31-
</label>
32-
<label>
33-
<input id="4" type="radio" name="lastDays" value=365
34-
<?php echo ($lastDays == 365) ? "checked=true" : "" ?>>
35-
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_year}'); ?>
36-
</label>
37-
</form>
38-
</div>
3915

4016
<h2><?php echo $this->t('{proxystatistics:Proxystatistics:templates/graphs_logins}'); ?></h2>
4117
<div class="legend-logins">

templates/timeRange.include.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<div class="timeRange">
2+
<h4><?php echo $this->t('{proxystatistics:Proxystatistics:templates_time_range}'); ?></h4>
3+
<form id="dateSelector" method="post">
4+
<?php if (isset($this->data['tab'])) : ?>
5+
<input name="tab" value="<?php echo $this->data['tab'];?>" type="hidden">
6+
<?php endif; ?>
7+
<?php
8+
$values = [0=>'all', 7=>'week', 30=>'month', 365=>'year'];
9+
$i = 0;
10+
?>
11+
<?php foreach ($values as $value => $str) : ?>
12+
<label>
13+
<input id="<?php echo $i;?>" type="radio" name="lastDays" value="<?php echo $value;?>"
14+
<?php echo ($this->data['lastDays'] == $value) ? "checked=true" : "" ?>>
15+
<?php echo $this->t('{proxystatistics:Proxystatistics:templates/statistics-tpl_'.$str.'}'); ?>
16+
</label>
17+
<?php $i++; ?>
18+
<?php endforeach; ?>
19+
</form>
20+
</div>

0 commit comments

Comments
 (0)