Skip to content

Commit

Permalink
Merge pull request #2523 from WPO-Foundation/dirmenot
Browse files Browse the repository at this point in the history
Replacing `__DIR__` with constants, part 2
  • Loading branch information
stoyan authored Jan 10, 2023
2 parents 5758c7a + 934c72d commit b0f59d2
Show file tree
Hide file tree
Showing 47 changed files with 204 additions and 207 deletions.
8 changes: 4 additions & 4 deletions www/har/HttpArchiveGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

require_once __DIR__ . '/../common_lib.inc';
require_once __DIR__ . '/../object_detail.inc';
require_once __DIR__ . '/../include/TestResults.php';
require_once __DIR__ . '/../include/Browser.php';
require_once INCLUDES_PATH . '/common_lib.inc';
require_once INCLUDES_PATH . '/object_detail.inc';
require_once INCLUDES_PATH . '/include/TestResults.php';
require_once INCLUDES_PATH . '/include/Browser.php';

/**
* Creates HttpArchives from test data.
Expand Down
2 changes: 1 addition & 1 deletion www/include/ConnectionViewHtmlSnippet.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

require_once __DIR__ . '/../waterfall.inc';
require_once INCLUDES_PATH . '/waterfall.inc';

class ConnectionViewHtmlSnippet
{
Expand Down
2 changes: 1 addition & 1 deletion www/include/DomainBreakdownHtmlSnippet.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

require_once __DIR__ . '/BreakdownHtmlSnippet.php';
require_once INCLUDES_PATH . '/include/BreakdownHtmlSnippet.php';

class DomainBreakdownHtmlSnippet extends BreakdownHtmlSnippet
{
Expand Down
4 changes: 2 additions & 2 deletions www/include/MimetypeBreakdownHtmlSnippet.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

require_once __DIR__ . '/BreakdownHtmlSnippet.php';
require_once __DIR__ . '/ConnectionViewHtmlSnippet.php';
require_once INCLUDES_PATH . '/include/BreakdownHtmlSnippet.php';
require_once INCLUDES_PATH . '/include/ConnectionViewHtmlSnippet.php';

class MimetypeBreakdownHtmlSnippet extends BreakdownHtmlSnippet
{
Expand Down
2 changes: 1 addition & 1 deletion www/include/PerformanceOptimizationHtmlSnippet.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright 2020 Catchpoint Systems Inc.
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.
require_once __DIR__ . '/../optimization.inc';
require_once INCLUDES_PATH . '/optimization.inc';

class PerformanceOptimizationHtmlSnippet
{
Expand Down
10 changes: 5 additions & 5 deletions www/include/ResultProcessing.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

require_once __DIR__ . '/../common_lib.inc';
require_once __DIR__ . '/../page_data.inc';
require_once __DIR__ . '/../object_detail.inc';
require_once __DIR__ . '/../breakdown.inc';
require_once __DIR__ . '/../devtools.inc.php';
require_once INCLUDES_PATH . '/common_lib.inc';
require_once INCLUDES_PATH . '/page_data.inc';
require_once INCLUDES_PATH . '/object_detail.inc';
require_once INCLUDES_PATH . '/breakdown.inc';
require_once INCLUDES_PATH . '/devtools.inc.php';

class ResultProcessing
{
Expand Down
2 changes: 1 addition & 1 deletion www/include/RunResultHtmlTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

require_once __DIR__ . '/../common_lib.inc';
require_once INCLUDES_PATH . '/common_lib.inc';

class RunResultHtmlTable
{
Expand Down
2 changes: 1 addition & 1 deletion www/include/TestInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

require_once __DIR__ . '/../common_lib.inc'; // TODO: remove if we don't use GetTestInfo anymore
require_once INCLUDES_PATH . '/common_lib.inc'; // TODO: remove if we don't use GetTestInfo anymore

class TestInfo
{
Expand Down
8 changes: 4 additions & 4 deletions www/include/TestResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

require_once __DIR__ . '/FileHandler.php';
require_once __DIR__ . '/TestStepResult.php';
require_once __DIR__ . '/TestRunResults.php';
require_once __DIR__ . '/Browser.php';
require_once INCLUDES_PATH . '/include/FileHandler.php';
require_once INCLUDES_PATH . '/include/TestStepResult.php';
require_once INCLUDES_PATH . '/include/TestRunResults.php';
require_once INCLUDES_PATH . '/include/Browser.php';


class TestResults
Expand Down
2 changes: 1 addition & 1 deletion www/include/TestResultsHtmlTables.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

require_once __DIR__ . '/../common_lib.inc';
require_once INCLUDES_PATH . '/common_lib.inc';

class TestResultsHtmlTables
{
Expand Down
2 changes: 1 addition & 1 deletion www/include/TestRunResults.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

require_once __DIR__ . '/TestStepResult.php';
require_once INCLUDES_PATH . '/include/TestStepResult.php';

class TestRunResults
{
Expand Down
10 changes: 5 additions & 5 deletions www/include/TestStepResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

require_once __DIR__ . '/FileHandler.php';
require_once __DIR__ . '/../devtools.inc.php';
require_once __DIR__ . '/../common_lib.inc';
require_once __DIR__ . '/../breakdown.inc';
require_once __DIR__ . '/../video/visualProgress.inc.php';
require_once INCLUDES_PATH . '/include/FileHandler.php';
require_once INCLUDES_PATH . '/devtools.inc.php';
require_once INCLUDES_PATH . '/common_lib.inc';
require_once INCLUDES_PATH . '/breakdown.inc';
require_once INCLUDES_PATH . '/video/visualProgress.inc.php';

class TestStepResult
{
Expand Down
2 changes: 1 addition & 1 deletion www/include/UserTimingHtmlTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

require_once __DIR__ . '/../common_lib.inc';
require_once INCLUDES_PATH . '/common_lib.inc';

class UserTimingHtmlTable
{
Expand Down
2 changes: 1 addition & 1 deletion www/include/WaterfallViewHtmlSnippet.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

require_once __DIR__ . '/../waterfall.inc';
require_once INCLUDES_PATH . '/waterfall.inc';

class WaterfallViewHtmlSnippet
{
Expand Down
6 changes: 3 additions & 3 deletions www/include/XmlResultGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.

require_once __DIR__ . '/TestPaths.php';
require_once __DIR__ . '/UrlGenerator.php';
require_once INCLUDES_PATH . '/include/TestPaths.php';
require_once INCLUDES_PATH . '/include/UrlGenerator.php';

// TODO: get rid of this in the long run (for xml_entities)
require_once __DIR__ . '/../common_lib.inc';
require_once INCLUDES_PATH . '/common_lib.inc';

class XmlResultGenerator
{
Expand Down
12 changes: 5 additions & 7 deletions www/include/social_meta.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php

require_once __DIR__ . '/../common_lib.inc';
require_once __DIR__ . '/../common.inc';
require_once __DIR__ . '/social_meta_vars.inc';
require_once INCLUDES_PATH . '/include/social_meta_vars.inc';

global $socialImage;
global $socialTitle;
global $pageURI;
global $socialDesc;
global $socialImage;
global $socialTitle;
global $pageURI;
global $socialDesc;

?>

Expand Down
2 changes: 1 addition & 1 deletion www/learn/lightning-fast-web-performance/certificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<?php
require_once __DIR__ . '/../../common.inc';
$useScreenshot = true;
require_once __DIR__ . '/../../head.inc';
require_once INCLUDES_PATH . '/head.inc';
?>
<link rel="stylesheet" href="/learn/lightning-fast-web-performance/lfwp-assets/learn-course.css">
</head>
Expand Down
6 changes: 3 additions & 3 deletions www/learn/lightning-fast-web-performance/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

$socialTitle = 'Lightning-Fast Web Performance Online Course from WebPageTest';
$useScreenshot = true;
require_once __DIR__ . '/../../head.inc';
require_once INCLUDES_PATH . '/head.inc';
?>
<link rel="stylesheet" href="/learn/lightning-fast-web-performance/lfwp-assets/learn-course.css">
</head>
Expand All @@ -18,7 +18,7 @@

<?php
$tab = 'Resources';
require_once __DIR__ . '/../../templates/layouts/includes/wpt-header.php';
require_once WWW_PATH . '/templates/layouts/includes/wpt-header.php';



Expand Down Expand Up @@ -483,7 +483,7 @@
</div>
</div>

<?php require_once __DIR__ . '/../../footer.inc'; ?>
<?php require_once INCLUDES_PATH . '/footer.inc'; ?>

</body>
<script>
Expand Down
4 changes: 2 additions & 2 deletions www/optimization.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Copyright 2020 Catchpoint Systems Inc.
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.
require_once __DIR__ . '/include/TestPaths.php';
require_once INCLUDES_PATH . '/include/TestPaths.php';

/**
* Re-format the optimization report to make it prettier
Expand Down Expand Up @@ -53,7 +53,7 @@ function dumpOptimizationReportForStep($localPaths, &$pageData, &$requests, $tes
*/
function ReportTTFB($localPaths, $pageData, $testinfoArray, $step)
{
require_once __DIR__ . '/optimization_detail.inc.php';
require_once INCLUDES_PATH . '/optimization_detail.inc.php';
$ttfb = (int) $pageData["TTFB"];
$latency = isset($testinfoArray['latency']) ? $testinfoArray['latency'] : null;
$score = gradeTTFBForStep($ttfb, $latency, $localPaths, $target);
Expand Down
6 changes: 3 additions & 3 deletions www/optimizationChecklist.inc
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ function drawChecklist($url, &$requests, &$pageData)
imagestring($im, $font, $x, $y, $label, $black);

// load the image icons (and size them)
$checkIcon = imagecreatefrompng(__DIR__ . '/assets/images/check.png');
$warningIcon = imagecreatefrompng(__DIR__ . '/assets/images/warning.png');
$errorIcon = imagecreatefrompng(__DIR__ . '/assets/images/error.png');
$checkIcon = imagecreatefrompng(ASSETS_PATH . '/images/check.png');
$warningIcon = imagecreatefrompng(ASSETS_PATH . '/images/warning.png');
$errorIcon = imagecreatefrompng(ASSETS_PATH . '/images/error.png');

// draw the request information
$i = 0;
Expand Down
6 changes: 3 additions & 3 deletions www/optimizationChecklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
// found in the LICENSE.md file.
header("Content-type: image/png");
include __DIR__ . '/common.inc';
require_once __DIR__ . '/optimizationChecklist.inc';
require_once __DIR__ . '/include/TestInfo.php';
require_once __DIR__ . '/include/TestStepResult.php';
require_once INCLUDES_PATH . '/optimizationChecklist.inc';
require_once INCLUDES_PATH . '/include/TestInfo.php';
require_once INCLUDES_PATH . '/include/TestStepResult.php';

// not functional, but to declare what to expect from common.inc
global $testPath, $run, $cached, $step, $id, $url, $test;
Expand Down
8 changes: 4 additions & 4 deletions www/page_data.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// Copyright 2020 Catchpoint Systems Inc.
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.
require_once(__DIR__ . '/devtools.inc.php');
require_once(__DIR__ . '/include/TestPaths.php');
require_once(__DIR__ . '/video/visualProgress.inc.php');
require_once(INCLUDES_PATH . '/devtools.inc.php');
require_once(INCLUDES_PATH . '/include/TestPaths.php');
require_once(INCLUDES_PATH . '/video/visualProgress.inc.php');

/**
* Load the page results directly from the results files
Expand Down Expand Up @@ -1425,7 +1425,7 @@ function CalculateTimeToInteractive($localPaths, $startTime, $interactiveWindows
$rw = array();
if (count($iw)) {
// Find all of the request windows with 5 seconds of no more than 2 concurrent document requests
require_once(__DIR__ . '/object_detail.inc');
require_once(INCLUDES_PATH . '/object_detail.inc');
$requests = getRequestsForStep($localPaths, null, $has_secure_requests);
if (isset($requests) && is_array($requests) && count($requests)) {
// Build a list of start/end events for document requests
Expand Down
12 changes: 6 additions & 6 deletions www/pageimages.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.
include __DIR__ . '/common.inc';
require_once __DIR__ . '/object_detail.inc';
require_once __DIR__ . '/page_data.inc';
require_once __DIR__ . '/include/TestInfo.php';
require_once __DIR__ . '/include/TestPaths.php';
require_once __DIR__ . '/include/TestStepResult.php';
require_once __DIR__ . '/include/UrlGenerator.php';
require_once INCLUDES_PATH . '/object_detail.inc';
require_once INCLUDES_PATH . '/page_data.inc';
require_once INCLUDES_PATH . '/include/TestInfo.php';
require_once INCLUDES_PATH . '/include/TestPaths.php';
require_once INCLUDES_PATH . '/include/TestStepResult.php';
require_once INCLUDES_PATH . '/include/UrlGenerator.php';

global $testPath, $id, $run, $cached, $step; // defined in common.inc

Expand Down
11 changes: 5 additions & 6 deletions www/performance_optimization.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
// Use of this source code is governed by the Polyform Shield 1.0.0 license that can be
// found in the LICENSE.md file.
include __DIR__ . '/common.inc';
require_once __DIR__ . '/include/TestInfo.php';
require_once __DIR__ . '/include/TestRunResults.php';
require_once __DIR__ . '/optimization_detail.inc.php';
require_once __DIR__ . '/include/PerformanceOptimizationHtmlSnippet.php';
require_once __DIR__ . '/include/AccordionHtmlHelper.php';
require_once INCLUDES_PATH . '/include/TestInfo.php';
require_once INCLUDES_PATH . '/include/TestRunResults.php';
require_once INCLUDES_PATH . '/optimization_detail.inc.php';
require_once INCLUDES_PATH . '/include/PerformanceOptimizationHtmlSnippet.php';
require_once INCLUDES_PATH . '/include/AccordionHtmlHelper.php';

$page_keywords = array('Optimization','WebPageTest','Website Speed Test','Page Speed');
$page_description = "Website performance optimization recommendations$testLabel.";
Expand Down Expand Up @@ -124,7 +124,6 @@

<h3 class="hed_sub">Glossary</h3>
<?php
require_once __DIR__ . '/resources/view.php';
echo view('partials.glossary', []);
?>

Expand Down
4 changes: 2 additions & 2 deletions www/resources/views/pages/testhistory.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@
<script>
<?php
if ($is_logged_in) {
include __DIR__ . '/../../js/history-loggedin.js';
include ASSETS_PATH . '/js/history-loggedin.js';
} else {
// if not logged in, build a local searchable test history from the data stored in indexeddb.
include __DIR__ . '/../../js/history.js';
include ASSETS_PATH . '/js/history.js';
}
?>
</script>
Expand Down
Loading

0 comments on commit b0f59d2

Please sign in to comment.