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

Commit 0694154

Browse files
Dev absolute url (#46)
* Use absolute Url on all places in Templates.php * Use simplified class name
1 parent 5affed4 commit 0694154

File tree

2 files changed

+34
-17
lines changed

2 files changed

+34
-17
lines changed

lib/Templates.php

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace SimpleSAML\Module\proxystatistics;
99

10+
use SimpleSAML\Auth\Simple;
1011
use SimpleSAML\Configuration;
1112
use SimpleSAML\Logger;
1213
use SimpleSAML\Module;
@@ -92,7 +93,7 @@ public static function showDetail($side)
9293
$t->data['header'] = $t->t('{proxystatistics:stats:' . $side . 'Detail_header_name}') . $name;
9394

9495
$t->data['htmlinject']['htmlContentPost'][]
95-
= '<script type="text/javascript" src="' . Module::getModuleUrl('proxystatistics/index.js') . '"></script>';
96+
= '<script type="text/javascript" src="' . self::getFullUrl('index.js') . '"></script>';
9697

9798
$t->data['side'] = $side;
9899
$t->data['other_side'] = Utils::theOther(Config::SIDES, $side);
@@ -106,7 +107,7 @@ public static function showIndex()
106107

107108
$authSource = $config->getRequiredAuthSource();
108109
if ($authSource) {
109-
$as = new \SimpleSAML\Auth\Simple($authSource);
110+
$as = new Simple($authSource);
110111
$as->requireAuth();
111112
}
112113

@@ -121,9 +122,9 @@ public static function showIndex()
121122
); // indexed from 0
122123

123124
$t->data['tabsAttributes'] = [
124-
'PROXY' => 'id="tab-1" href="summary.php?lastDays=' . $lastDays . '"',
125-
'IDP' => 'id="tab-2" href="identityProviders.php?lastDays=' . $lastDays . '"',
126-
'SP' => 'id="tab-3" href="serviceProviders.php?lastDays=' . $lastDays . '"',
125+
'PROXY' => 'id="tab-1" href="' . self::getFullUrl('summary.php') . '?lastDays=' . $lastDays . '"',
126+
'IDP' => 'id="tab-2" href="' . self::getFullUrl('identityProviders.php') . '?lastDays=' . $lastDays . '"',
127+
'SP' => 'id="tab-3" href="' . self::getFullUrl('serviceProviders.php') . '?lastDays=' . $lastDays . '"',
127128
];
128129
$mode = $config->getMode();
129130
if ($mode !== Config::MODE_PROXY) {
@@ -233,24 +234,34 @@ private static function headIncludes($t)
233234
$t->data['jquery'] = ['core' => true, 'ui' => true, 'css' => true];
234235
$t->data['head'] = '';
235236
$t->data['head'] .= '<link rel="stylesheet" media="screen" type="text/css" href="' .
236-
Module::getModuleUrl('proxystatistics/assets/css/bootstrap.min.css') . '" />';
237+
self::getFullUrl('assets/css/bootstrap.min.css') . '" />';
237238
$t->data['head'] .= '<link rel="stylesheet" media="screen" type="text/css" href="' .
238-
Module::getModuleUrl('proxystatistics/assets/css/statisticsproxy.css') . '" />';
239+
self::getFullUrl('assets/css/statisticsproxy.css') . '" />';
239240
$t->data['head'] .= '<link rel="stylesheet" type="text/css" href="' .
240-
Module::getModuleUrl('proxystatistics/assets/css/Chart.min.css') . '">';
241+
self::getFullUrl('assets/css/Chart.min.css') . '">';
241242
$t->data['head'] .= '<script type="text/javascript" src="' .
242-
Module::getModuleUrl('proxystatistics/assets/js/moment.min.js') . '"></script>';
243+
self::getFullUrl('assets/js/moment.min.js') . '"></script>';
243244
if ($t->getLanguage() === 'cs') {
244245
$t->data['head'] .= '<script type="text/javascript" src="' .
245-
Module::getModuleUrl('proxystatistics/assets/js/moment.cs.min.js') . '"></script>';
246+
self::getFullUrl('assets/js/moment.cs.min.js') . '"></script>';
246247
}
247248
$t->data['head'] .= '<script type="text/javascript" src="' .
248-
Module::getModuleUrl('proxystatistics/assets/js/Chart.min.js') . '"></script>';
249+
self::getFullUrl('assets/js/Chart.min.js') . '"></script>';
249250
$t->data['head'] .= '<script type="text/javascript" src="' .
250-
Module::getModuleUrl('proxystatistics/assets/js/hammer.min.js') . '"></script>';
251+
self::getFullUrl('assets/js/hammer.min.js') . '"></script>';
251252
$t->data['head'] .= '<script type="text/javascript" src="' .
252-
Module::getModuleUrl('proxystatistics/assets/js/chartjs-plugin-zoom.min.js') . '"></script>';
253+
self::getFullUrl('assets/js/chartjs-plugin-zoom.min.js') . '"></script>';
253254
$t->data['head'] .= '<script type="text/javascript" src="' .
254-
Module::getModuleUrl('proxystatistics/assets/js/index.js') . '"></script>';
255+
self::getFullUrl('assets/js/index.js') . '"></script>';
256+
257+
$t->data['head'] .= Utils::metaData(
258+
'module_url_base',
259+
self::getFullUrl()
260+
);
261+
}
262+
263+
private static function getFullUrl($path = ''): string
264+
{
265+
return Module::getModuleUrl('proxystatistics/') . $path;
255266
}
256267
}

www/assets/js/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,12 @@ function drawPieChart(dataName, viewCols, url, getEl) {
278278
}
279279

280280
function getDrawChart(side) {
281-
return drawPieChart.bind(null, 'loginCountPer' + side, [0, 2], 'detail.php?side=' + side + '&id=');
281+
return drawPieChart.bind(
282+
null,
283+
'loginCountPer' + side,
284+
[0, 2],
285+
getStatisticsData('module_url_base') + 'detail.php?side=' + side + '&id='
286+
);
282287
}
283288

284289
function drawCountTable(cols, dataCol, countCol, dataName, allowHTML, url, getEl) {
@@ -338,8 +343,9 @@ function drawCountTable(cols, dataCol, countCol, dataName, allowHTML, url, getEl
338343
}
339344

340345
function getDrawTable(side) {
341-
return drawCountTable.bind(null, ['tables_' + side, 'count'], 0, 2, 'loginCountPer' + side, false,
342-
'detail.php?side=' + side + '&id=');
346+
return drawCountTable.bind(null,
347+
['tables_' + side, 'count'], 0, 2, 'loginCountPer' + side, false,
348+
getStatisticsData('module_url_base') + 'detail.php?side=' + side + '&id=');
343349
}
344350

345351
function getDrawCountTable(side) {

0 commit comments

Comments
 (0)