mirror of
https://github.com/silverstripe/silverstripe-installer
synced 2024-10-22 17:05:33 +02:00
Update code formatting for the SS3 PHPCS ruleset, separate Page_Controller to new file
This commit is contained in:
parent
451e7961d2
commit
9acd97791a
@ -8,7 +8,7 @@ root = true
|
|||||||
charset = utf-8
|
charset = utf-8
|
||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
indent_style = tab
|
indent_style = space
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
56
index.php
56
index.php
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// This is the URL of the script that everything must be viewed with.
|
// 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']);
|
$ruLen = strlen($_SERVER['REQUEST_URI']);
|
||||||
$snLen = strlen($_SERVER['SCRIPT_NAME']);
|
$snLen = strlen($_SERVER['SCRIPT_NAME']);
|
||||||
@ -23,26 +23,28 @@ $snLen = strlen($_SERVER['SCRIPT_NAME']);
|
|||||||
$isIIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false);
|
$isIIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false);
|
||||||
|
|
||||||
// IIS will populate server variables using one of these two ways
|
// IIS will populate server variables using one of these two ways
|
||||||
if($isIIS) {
|
if ($isIIS) {
|
||||||
if($_SERVER['REQUEST_URI'] == $_SERVER['SCRIPT_NAME']) {
|
if ($_SERVER['REQUEST_URI'] == $_SERVER['SCRIPT_NAME']) {
|
||||||
$url = "";
|
$url = "";
|
||||||
} else if($ruLen > $snLen && substr($_SERVER['REQUEST_URI'],0,$snLen+1) == ($_SERVER['SCRIPT_NAME'] . '/')) {
|
} elseif ($ruLen > $snLen && substr($_SERVER['REQUEST_URI'], 0, $snLen + 1) == ($_SERVER['SCRIPT_NAME'] . '/')) {
|
||||||
$url = substr($_SERVER['REQUEST_URI'],$snLen+1);
|
$url = substr($_SERVER['REQUEST_URI'], $snLen+1);
|
||||||
$url = strtok($url, '?');
|
$url = strtok($url, '?');
|
||||||
} else {
|
} else {
|
||||||
$url = $_SERVER['REQUEST_URI'];
|
$url = $_SERVER['REQUEST_URI'];
|
||||||
if($url[0] == '/') $url = substr($url,1);
|
if ($url[0] == '/') {
|
||||||
$url = strtok($url, '?');
|
$url = substr($url, 1);
|
||||||
}
|
}
|
||||||
|
$url = strtok($url, '?');
|
||||||
|
}
|
||||||
|
|
||||||
// Apache will populate the server variables this way
|
// Apache will populate the server variables this way
|
||||||
} else {
|
} else {
|
||||||
if($ruLen > $snLen && substr($_SERVER['REQUEST_URI'],0,$snLen+1) == ($_SERVER['SCRIPT_NAME'] . '/')) {
|
if ($ruLen > $snLen && substr($_SERVER['REQUEST_URI'], 0, $snLen+1) == ($_SERVER['SCRIPT_NAME'] . '/')) {
|
||||||
$url = substr($_SERVER['REQUEST_URI'],$snLen+1);
|
$url = substr($_SERVER['REQUEST_URI'], $snLen+1);
|
||||||
$url = strtok($url, '?');
|
$url = strtok($url, '?');
|
||||||
} else {
|
} else {
|
||||||
$url = "";
|
$url = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$_GET['url'] = $_REQUEST['url'] = $url;
|
$_GET['url'] = $_REQUEST['url'] = $url;
|
||||||
@ -53,14 +55,14 @@ $fileName = dirname($_SERVER['SCRIPT_FILENAME']) . '/' . $url;
|
|||||||
* This code is a very simple wrapper for sending files
|
* This code is a very simple wrapper for sending files
|
||||||
* Very quickly pass through references to files
|
* Very quickly pass through references to files
|
||||||
*/
|
*/
|
||||||
if($url && file_exists($fileName)) {
|
if ($url && file_exists($fileName)) {
|
||||||
$fileURL = (dirname($_SERVER['SCRIPT_NAME'])=='/'?'':dirname($_SERVER['SCRIPT_NAME'])) . '/' . $url;
|
$fileURL = (dirname($_SERVER['SCRIPT_NAME'])=='/'?'':dirname($_SERVER['SCRIPT_NAME'])) . '/' . $url;
|
||||||
if(isset($_SERVER['QUERY_STRING'])) {
|
if (isset($_SERVER['QUERY_STRING'])) {
|
||||||
$fileURL .= '?' . $_SERVER['QUERY_STRING'];
|
$fileURL .= '?' . $_SERVER['QUERY_STRING'];
|
||||||
}
|
}
|
||||||
header($_SERVER['SERVER_PROTOCOL'] . ' 301 Moved Permanently');
|
header($_SERVER['SERVER_PROTOCOL'] . ' 301 Moved Permanently');
|
||||||
header("Location: $fileURL");
|
header("Location: $fileURL");
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once('framework/main.php');
|
require_once 'framework/main.php';
|
||||||
|
@ -9,5 +9,8 @@
|
|||||||
************************************************************************************
|
************************************************************************************
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
if (!file_exists('framework') || !file_exists('framework/_config.php')) include "install-frameworkmissing.html";
|
if (!file_exists('framework') || !file_exists('framework/_config.php')) {
|
||||||
else include('./framework/dev/install/install.php');
|
include 'install-frameworkmissing.html';
|
||||||
|
} else {
|
||||||
|
include './framework/dev/install/install.php';
|
||||||
|
}
|
||||||
|
@ -6,7 +6,7 @@ $project = 'mysite';
|
|||||||
global $database;
|
global $database;
|
||||||
$database = '';
|
$database = '';
|
||||||
|
|
||||||
require_once('conf/ConfigureFromEnv.php');
|
require_once 'conf/ConfigureFromEnv.php';
|
||||||
|
|
||||||
// Set the site locale
|
// Set the site locale
|
||||||
i18n::set_locale('en_US');
|
i18n::set_locale('en_US');
|
||||||
|
@ -1,37 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
class Page extends SiteTree {
|
|
||||||
|
|
||||||
private static $db = array(
|
class Page extends SiteTree
|
||||||
);
|
{
|
||||||
|
private static $db = array(
|
||||||
private static $has_one = array(
|
);
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
class Page_Controller extends ContentController {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An array of actions that can be accessed via a request. Each array element should be an action name, and the
|
|
||||||
* permissions or conditions required to allow the user to access it.
|
|
||||||
*
|
|
||||||
* <code>
|
|
||||||
* array (
|
|
||||||
* 'action', // anyone can access this action
|
|
||||||
* 'action' => true, // same as above
|
|
||||||
* 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
|
|
||||||
* 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
|
|
||||||
* );
|
|
||||||
* </code>
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private static $allowed_actions = array (
|
|
||||||
);
|
|
||||||
|
|
||||||
public function init() {
|
|
||||||
parent::init();
|
|
||||||
// You can include any CSS or JS required by your project here.
|
|
||||||
// See: http://doc.silverstripe.org/framework/en/reference/requirements
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private static $has_one = array(
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
29
mysite/code/Page_Controller.php
Normal file
29
mysite/code/Page_Controller.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class Page_Controller extends ContentController
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* An array of actions that can be accessed via a request. Each array element should be an action name, and the
|
||||||
|
* permissions or conditions required to allow the user to access it.
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* array (
|
||||||
|
* 'action', // anyone can access this action
|
||||||
|
* 'action' => true, // same as above
|
||||||
|
* 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
|
||||||
|
* 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
|
||||||
|
* );
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
private static $allowed_actions = array(
|
||||||
|
);
|
||||||
|
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
parent::init();
|
||||||
|
// You can include any CSS or JS required by your project here.
|
||||||
|
// See: http://doc.silverstripe.org/framework/en/reference/requirements
|
||||||
|
}
|
||||||
|
}
|
@ -1,25 +1,24 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<ruleset name="SS3">
|
<ruleset name="SS3">
|
||||||
<description>Coding standard for SilverStripe 3.x</description>
|
<description>Coding standard for SilverStripe 3.x</description>
|
||||||
|
|
||||||
<!-- Don't sniff third party libraries -->
|
<!-- Don't sniff third party libraries -->
|
||||||
<exclude-pattern>*/vendor/*</exclude-pattern>
|
<exclude-pattern>*/vendor/*</exclude-pattern>
|
||||||
<exclude-pattern>*/thirdparty/*</exclude-pattern>
|
<exclude-pattern>*/thirdparty/*</exclude-pattern>
|
||||||
<exclude-pattern type="relative">^index.php</exclude-pattern>
|
|
||||||
|
|
||||||
<!-- Show progress and output sniff names on violation, and add colours -->
|
<!-- Show progress and output sniff names on violation, and add colours -->
|
||||||
<arg value="sp"/>
|
<arg value="sp"/>
|
||||||
<arg name="colors"/>
|
<arg name="colors"/>
|
||||||
|
|
||||||
<!-- Use PSR-2 as a base standard -->
|
<!-- Use PSR-2 as a base standard -->
|
||||||
<rule ref="PSR2">
|
<rule ref="PSR2">
|
||||||
<!-- Allow classes to not declare a namespace -->
|
<!-- Allow classes to not declare a namespace -->
|
||||||
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
|
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
|
||||||
|
|
||||||
<!-- Allow underscores in class names -->
|
<!-- Allow underscores in class names -->
|
||||||
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
|
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
|
||||||
|
|
||||||
<!-- Allow non camel cased method names -->
|
<!-- Allow non camel cased method names -->
|
||||||
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
|
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
|
||||||
</rule>
|
</rule>
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
Loading…
Reference in New Issue
Block a user