Merge pull request #177 from nfauchelle/psr-2-adjustments

Update the PHP files to PSR-2 spec
This commit is contained in:
Damian Mooyman 2017-05-15 09:15:09 +12:00 committed by GitHub
commit d9f28b2017
4 changed files with 62 additions and 55 deletions

View File

@ -15,7 +15,7 @@
*/
// This is the URL of the script that everything must be viewed with.
define('BASE_SCRIPT_URL','index.php/');
define('BASE_SCRIPT_URL', 'index.php/');
$ruLen = strlen($_SERVER['REQUEST_URI']);
$snLen = strlen($_SERVER['SCRIPT_NAME']);
@ -23,22 +23,26 @@ $snLen = strlen($_SERVER['SCRIPT_NAME']);
$isIIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false);
// IIS will populate server variables using one of these two ways
if($isIIS) {
if($_SERVER['REQUEST_URI'] == $_SERVER['SCRIPT_NAME']) {
if ($isIIS) {
if ($_SERVER['REQUEST_URI'] == $_SERVER['SCRIPT_NAME']) {
$url = "";
} else if($ruLen > $snLen && substr($_SERVER['REQUEST_URI'],0,$snLen+1) == ($_SERVER['SCRIPT_NAME'] . '/')) {
$url = substr($_SERVER['REQUEST_URI'],$snLen+1);
} else {
if ($ruLen > $snLen && substr($_SERVER['REQUEST_URI'], 0, $snLen + 1) == ($_SERVER['SCRIPT_NAME'] . '/')) {
$url = substr($_SERVER['REQUEST_URI'], $snLen + 1);
$url = strtok($url, '?');
} else {
$url = $_SERVER['REQUEST_URI'];
if($url[0] == '/') $url = substr($url,1);
if ($url[0] == '/') {
$url = substr($url, 1);
}
$url = strtok($url, '?');
}
}
// Apache will populate the server variables this way
} else {
if($ruLen > $snLen && substr($_SERVER['REQUEST_URI'],0,$snLen+1) == ($_SERVER['SCRIPT_NAME'] . '/')) {
$url = substr($_SERVER['REQUEST_URI'],$snLen+1);
if ($ruLen > $snLen && substr($_SERVER['REQUEST_URI'], 0, $snLen + 1) == ($_SERVER['SCRIPT_NAME'] . '/')) {
$url = substr($_SERVER['REQUEST_URI'], $snLen + 1);
$url = strtok($url, '?');
} else {
$url = "";
@ -53,9 +57,9 @@ $fileName = dirname($_SERVER['SCRIPT_FILENAME']) . '/' . $url;
* This code is a very simple wrapper for sending files
* Very quickly pass through references to files
*/
if($url && file_exists($fileName)) {
$fileURL = (dirname($_SERVER['SCRIPT_NAME'])=='/'?'':dirname($_SERVER['SCRIPT_NAME'])) . '/' . $url;
if(isset($_SERVER['QUERY_STRING'])) {
if ($url && file_exists($fileName)) {
$fileURL = (dirname($_SERVER['SCRIPT_NAME']) == '/' ? '' : dirname($_SERVER['SCRIPT_NAME'])) . '/' . $url;
if (isset($_SERVER['QUERY_STRING'])) {
$fileURL .= '?' . $_SERVER['QUERY_STRING'];
}
header($_SERVER['SERVER_PROTOCOL'] . ' 301 Moved Permanently');

View File

@ -5,8 +5,10 @@ use SilverStripe\CMS\Model\SiteTree;
class Page extends SiteTree
{
private static $db = array(
);
private static $has_one = array(
);
}

View File

@ -20,6 +20,7 @@ class PageController extends ContentController
* @var array
*/
private static $allowed_actions = array(
);
protected function init()