Skip to content

Commit

Permalink
Merge branch 'natanfelles-absolute_paths' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-parry committed Dec 15, 2018
2 parents 0f24ac5 + a207666 commit b2140b0
Show file tree
Hide file tree
Showing 91 changed files with 255 additions and 311 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php namespace Config;

require_once BASEPATH . 'Config/AutoloadConfig.php';
require_once SYSTEMPATH . 'Config/AutoloadConfig.php';

/**
* -------------------------------------------------------------------
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
26 changes: 6 additions & 20 deletions application/Config/Paths.php → app/Config/Paths.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ class Paths
* Include the path if the folder is not in the same directory
* as this file.
*/
public $systemDirectory = 'system';
public $systemDirectory = __DIR__ . '/../../system';

/*
*---------------------------------------------------------------
* APPLICATION FOLDER NAME
*---------------------------------------------------------------
*
* If you want this front controller to use a different "application"
* If you want this front controller to use a different "app"
* folder than the default one you can set its name here. The folder
* can also be renamed or relocated anywhere on your getServer. If
* you do, use a full getServer path. For more info please see the user guide:
* http://codeigniter.com/user_guide/general/managing_apps.html
*
* NO TRAILING SLASH!
*/
public $applicationDirectory = 'application';
public $appDirectory = __DIR__ . '/../../app';

/*
* ---------------------------------------------------------------
Expand All @@ -48,7 +48,7 @@ class Paths
* for maximum security, keeping it out of the application and/or
* system directories.
*/
public $writableDirectory = 'writable';
public $writableDirectory = __DIR__ . '/../../writable';

/*
* ---------------------------------------------------------------
Expand All @@ -61,21 +61,7 @@ class Paths
* for maximum security, keeping it out of the application and/or
* system directories.
*/
public $testsDirectory = 'tests';

/*
* ---------------------------------------------------------------
* PUBLIC DIRECTORY NAME
* ---------------------------------------------------------------
*
* This variable must contain the name of the directory that
* contains the main index.php front-controller. By default,
* this is the `public` directory, but some hosts may not
* be able to map a primary domain to a sub-directory so you
* can change this to `public_html`, for example, to comply
* with your host's needs.
*/
public $publicDirectory = 'public';
public $testsDirectory = __DIR__ . '/../../tests';

/*
* ---------------------------------------------------------------
Expand All @@ -87,5 +73,5 @@ class Paths
* default this is in `application/Views`. This value
* is used when no value is provided to `Services::renderer()`.
*/
public $viewDirectory = 'application/Views';
public $viewDirectory = __DIR__ . '/../../app/Views';
}
4 changes: 2 additions & 2 deletions application/Config/Routes.php → app/Config/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

// Load the system's routing file first, so that the app and ENVIRONMENT
// can override as needed.
if (file_exists(BASEPATH . 'Config/Routes.php'))
if (file_exists(SYSTEMPATH . 'Config/Routes.php'))
{
require BASEPATH . 'Config/Routes.php';
require SYSTEMPATH . 'Config/Routes.php';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use CodeIgniter\Config\Services as CoreServices;
use CodeIgniter\Config\BaseConfig;

require_once BASEPATH . 'Config/Services.php';
require_once SYSTEMPATH . 'Config/Services.php';

/**
* Services Configuration file.
Expand Down
2 changes: 1 addition & 1 deletion application/Config/Toolbar.php → app/Config/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ class Toolbar extends BaseConfig
\CodeIgniter\Debug\Toolbar\Collectors\Events::class,
];
public $maxHistory = 20;
public $viewsPath = BASEPATH . 'Debug/Toolbar/Views/';
public $viewsPath = SYSTEMPATH . 'Debug/Toolbar/Views/';
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
Filename: <?= $exception->getFile(), "\n"; ?>
Line Number: <?= $exception->getLine(); ?>

<?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE === TRUE): ?>
<?php if (defined('SHOW_DEBUG_BACKTRACE') && SHOW_DEBUG_BACKTRACE === true): ?>

Backtrace:
<?php foreach ($exception->getTrace() as $error): ?>
<?php if (isset($error['file'])): ?>
<?= trim('-'. $error['line'] .' - '. $error['file'] .'::'. $error['function']) ."\n" ?>
<?= trim('-' . $error['line'] . ' - ' . $error['file'] . '::' . $error['function']) . "\n" ?>
<?php endif ?>
<?php endforeach ?>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

// On the CLI, we still want errors in productions
// so just use the exception template.
include __DIR__.'/error_exception.php';
include __DIR__ . '/error_exception.php';
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<h1>404 - File Not Found</h1>

<p>
<?php if (! empty($message) && $message != '(null)') : ?>
<?php if (! empty($message) && $message !== '(null)') : ?>
<?= esc($message) ?>
<?php else : ?>
Sorry! Cannot seem to find the page you were looking for.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@

<title><?= htmlspecialchars($title, ENT_SUBSTITUTE, 'UTF-8') ?></title>
<style type="text/css">
<?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'debug.css')) ?>
<?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.css')) ?>
</style>

<script type="text/javascript">
<?= file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'debug.js') ?>
<?= file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.js') ?>
</script>
</head>
<body onload="init()">

<!-- Header -->
<div class="header">
<div class="container">
<h1><?= htmlspecialchars($title, ENT_SUBSTITUTE, 'UTF-8'), ($exception->getCode() ? ' #'.$exception->getCode() : '') ?></h1>
<h1><?= htmlspecialchars($title, ENT_SUBSTITUTE, 'UTF-8'), ($exception->getCode() ? ' #' . $exception->getCode() : '') ?></h1>
<p>
<?= $exception->getMessage() ?>
<a href="https://www.google.com/search?q=<?= urlencode($title.' '.preg_replace('#\'.*\'|".*"#Us', '', $exception->getMessage())) ?>"
<a href="https://www.google.com/search?q=<?= urlencode($title . ' ' . preg_replace('#\'.*\'|".*"#Us', '', $exception->getMessage())) ?>"
rel="noreferrer" target="_blank">search &rarr;</a>
</p>
</div>
Expand Down Expand Up @@ -64,39 +64,39 @@
<!-- Trace info -->
<?php if (isset($row['file']) && is_file($row['file'])) :?>
<?php
if (isset($row['function']) && in_array($row['function'], ['include', 'include_once', 'require', 'require_once']))
if (isset($row['function']) && in_array($row['function'], ['include', 'include_once', 'require', 'require_once']))
{
echo $row['function'].' '. static::cleanPath($row['file']);
}
else
echo $row['function'] . ' ' . static::cleanPath($row['file']);
}
else
{
echo static::cleanPath($row['file']).' : '.$row['line'];
}
echo static::cleanPath($row['file']) . ' : ' . $row['line'];
}
?>
<?php else : ?>
{PHP internal code}
<?php endif; ?>

<!-- Class/Method -->
<?php if (isset($row['class'])) : ?>
&nbsp;&nbsp;&mdash;&nbsp;&nbsp;<?= $row['class'].$row['type'].$row['function'] ?>
&nbsp;&nbsp;&mdash;&nbsp;&nbsp;<?= $row['class'] . $row['type'] . $row['function'] ?>
<?php if (! empty($row['args'])) : ?>
<?php $args_id = $error_id.'args'.$index ?>
<?php $args_id = $error_id . 'args' . $index ?>
( <a href="#" onclick="return toggle('<?= $args_id ?>');">arguments</a> )
<div class="args" id="<?= $args_id ?>">
<table cellspacing="0">

<?php
$params = null;
// Reflection by name is not available for closure function
if( substr( $row['function'], -1 ) !== '}' )
if (substr( $row['function'], -1 ) !== '}')
{
$mirror = isset( $row['class'] ) ? new \ReflectionMethod( $row['class'], $row['function'] ) : new \ReflectionFunction( $row['function'] );
$params = $mirror->getParameters();
}
foreach ($row['args'] as $key => $value) : ?>
<tr>
<td><code><?= htmlspecialchars(isset($params[$key]) ? '$'.$params[$key]->name : "#$key", ENT_SUBSTITUTE, 'UTF-8') ?></code></td>
<td><code><?= htmlspecialchars(isset($params[$key]) ? '$' . $params[$key]->name : "#$key", ENT_SUBSTITUTE, 'UTF-8') ?></code></td>
<td><pre><?= print_r($value, true) ?></pre></td>
</tr>
<?php endforeach ?>
Expand Down Expand Up @@ -129,7 +129,10 @@
<!-- Server -->
<div class="content" id="server">
<?php foreach (['_SERVER', '_SESSION'] as $var) : ?>
<?php if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var])) continue; ?>
<?php if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var]))
{
continue;
} ?>

<h3>$<?= $var ?></h3>

Expand All @@ -148,7 +151,7 @@
<?php if (is_string($value)) : ?>
<?= htmlspecialchars($value, ENT_SUBSTITUTE, 'UTF-8') ?>
<?php else: ?>
<?= '<pre>'.print_r($value, true) ?>
<?= '<pre>' . print_r($value, true) ?>
<?php endif; ?>
</td>
</tr>
Expand All @@ -175,10 +178,10 @@
<tr>
<td><?= htmlspecialchars($key, ENT_IGNORE, 'UTF-8') ?></td>
<td>
<?php if (!is_array($value) && ! is_object($value)) : ?>
<?php if (! is_array($value) && ! is_object($value)) : ?>
<?= htmlspecialchars($value, ENT_SUBSTITUTE, 'UTF-8') ?>
<?php else: ?>
<?= '<pre>'.print_r($value, true) ?>
<?= '<pre>' . print_r($value, true) ?>
<?php endif; ?>
</td>
</tr>
Expand Down Expand Up @@ -229,7 +232,10 @@

<?php $empty = true; ?>
<?php foreach (['_GET', '_POST', '_COOKIE'] as $var) : ?>
<?php if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var])) continue; ?>
<?php if (empty($GLOBALS[$var]) || ! is_array($GLOBALS[$var]))
{
continue;
} ?>

<?php $empty = false; ?>

Expand All @@ -247,10 +253,10 @@
<tr>
<td><?= htmlspecialchars($key, ENT_IGNORE, 'UTF-8') ?></td>
<td>
<?php if (!is_array($value) && ! is_object($value)) : ?>
<?php if (! is_array($value) && ! is_object($value)) : ?>
<?= htmlspecialchars($value, ENT_SUBSTITUTE, 'UTF-8') ?>
<?php else: ?>
<?= '<pre>'.print_r($value, true) ?>
<?= '<pre>' . print_r($value, true) ?>
<?php endif; ?>
</td>
</tr>
Expand Down Expand Up @@ -282,8 +288,14 @@
</thead>
<tbody>
<?php foreach ($headers as $name => $value) : ?>
<?php if (empty($value)) continue; ?>
<?php if (! is_array($value)) { $value = [$value]; } ?>
<?php if (empty($value))
{
continue;
} ?>
<?php if (! is_array($value))
{
$value = [$value];
} ?>
<?php foreach ($value as $h) : ?>
<tr>
<td><?= esc($h->getName(), 'html') ?></td>
Expand All @@ -306,7 +318,7 @@
<table>
<tr>
<td style="width: 15em">Response Status</td>
<td><?= $response->getStatusCode().' - '.$response->getReason() ?></td>
<td><?= $response->getStatusCode() . ' - ' . $response->getReason() ?></td>
</tr>
</table>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Whoops!</title>

<style type="text/css">
<?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'debug.css')) ?>
<?= preg_replace('#[\r\n\t ]+#', ' ', file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'debug.css')) ?>
</style>
</head>
<body>
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

// Location of the Paths config file.
// This is the line that might need to be changed, depending on your folder structure.
$pathsPath = FCPATH . '../application/Config/Paths.php';
$pathsPath = FCPATH . '../app/Config/Paths.php';

/*
*---------------------------------------------------------------
Expand All @@ -32,7 +32,7 @@
$paths = new Config\Paths();

// Location of the framework bootstrap file.
$app = require FCPATH . '../' . rtrim($paths->systemDirectory, '/ ') . '/bootstrap.php';
$app = require rtrim($paths->systemDirectory, '/ ') . '/bootstrap.php';

/*
*---------------------------------------------------------------
Expand Down
14 changes: 5 additions & 9 deletions spark
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,16 @@ if (substr(php_sapi_name(), 0, 3) === 'cgi')
die("The cli tool is not supported when running php-cgi. It needs php-cli to function!\n\n");
}

// Location to the Paths config file.
$pathsPath = 'application/Config/Paths.php';
// Path to the front controller
define('FCPATH', __DIR__ . '/public' . DIRECTORY_SEPARATOR);

// Load our paths config file
require $pathsPath;
$paths = new Config\Paths();

$public = trim($paths->publicDirectory, '/');
require 'app/Config/Paths.php';

// Path to the front controller
define('FCPATH', realpath($public) . DIRECTORY_SEPARATOR);
$paths = new Config\Paths();

// Ensure the current directory is pointing to the front controller's directory
chdir($public);
chdir(FCPATH);

$app = require rtrim($paths->systemDirectory, '/ ') . '/bootstrap.php';

Expand Down
2 changes: 1 addition & 1 deletion system/Autoloader/FileLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ protected function legacyLocate(string $file, string $folder = null)
{
$paths = [
APPPATH,
BASEPATH,
SYSTEMPATH,
];

foreach ($paths as $path)
Expand Down
2 changes: 1 addition & 1 deletion system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function initialize()

if (CI_DEBUG)
{
require_once BASEPATH . 'ThirdParty/Kint/kint.php';
require_once SYSTEMPATH . 'ThirdParty/Kint/kint.php';
}
}

Expand Down
2 changes: 1 addition & 1 deletion system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ function helper($filenames)
$appHelper = $path;
// @codeCoverageIgnoreEnd
}
elseif (strpos($path, BASEPATH) === 0)
elseif (strpos($path, SYSTEMPATH) === 0)
{
$systemHelper = $path;
}
Expand Down
Loading

0 comments on commit b2140b0

Please sign in to comment.