mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #275 from halkyon/e_strict_support
First round of fixes for E_STRICT compliance
This commit is contained in:
commit
f0ee711f52
@ -322,7 +322,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
||||
SSViewer::set_theme(null);
|
||||
}
|
||||
|
||||
function handleRequest($request, DataModel $model) {
|
||||
function handleRequest(SS_HTTPRequest $request, DataModel $model = null) {
|
||||
$title = $this->Title();
|
||||
|
||||
$response = parent::handleRequest($request, $model);
|
||||
|
@ -113,7 +113,7 @@ abstract class ModelAdmin extends LeftAndMain {
|
||||
Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/ModelAdmin.js');
|
||||
}
|
||||
|
||||
function getEditForm($id = null) {
|
||||
function getEditForm($id = null, $fields = null) {
|
||||
$list = $this->getList();
|
||||
$exportButton = new GridFieldExportButton();
|
||||
$exportButton->setExportColumns($this->getExportFields());
|
||||
|
@ -319,7 +319,7 @@ class File extends DataObject {
|
||||
* Returns the fields to power the edit screen of files in the CMS
|
||||
* @return FieldList
|
||||
*/
|
||||
function getCMSFields() {
|
||||
function getCMSFields($params = null) {
|
||||
// Preview
|
||||
if($this instanceof Image) {
|
||||
$formattedImage = $this->getFormattedImage('SetWidth', Image::$asset_preview_width);
|
||||
@ -816,8 +816,8 @@ class File extends DataObject {
|
||||
}
|
||||
}
|
||||
|
||||
public function flushCache() {
|
||||
parent::flushCache();
|
||||
public function flushCache($persistant = true) {
|
||||
parent::flushCache($persistant);
|
||||
|
||||
self::$cache_file_fields = null;
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ class Folder extends File {
|
||||
* You can modify this FieldList by subclassing folder, or by creating a {@link DataExtension}
|
||||
* and implemeting updateCMSFields(FieldList $fields) on that extension.
|
||||
*/
|
||||
function getCMSFields() {
|
||||
function getCMSFields($param = null) {
|
||||
// Hide field on root level, which can't be renamed
|
||||
if(!$this->ID || $this->ID === "root") {
|
||||
$titleField = new HiddenField("Name");
|
||||
|
@ -343,7 +343,7 @@ class TreeDropdownField extends FormField {
|
||||
class TreeDropdownField_Readonly extends TreeDropdownField {
|
||||
protected $readonly = true;
|
||||
|
||||
function Field() {
|
||||
function Field($properties = array()) {
|
||||
$fieldName = $this->labelField;
|
||||
if($this->value) {
|
||||
$keyObj = $this->objectForKey($this->value);
|
||||
|
@ -90,7 +90,7 @@ class Aggregate extends ViewableData {
|
||||
* This gets the aggregate function
|
||||
*
|
||||
*/
|
||||
public function XML_val($name, $args) {
|
||||
public function XML_val($name, $args = null, $cache = false) {
|
||||
$func = strtoupper( strpos($name, 'get') === 0 ? substr($name, 3) : $name );
|
||||
$attribute = $args ? $args[0] : 'ID';
|
||||
|
||||
|
@ -675,11 +675,11 @@ class Hierarchy extends DataExtension {
|
||||
self::$treeOpened = array();
|
||||
}
|
||||
|
||||
function reset() {
|
||||
public static function reset() {
|
||||
self::$marked = array();
|
||||
self::$expanded = array();
|
||||
self::$treeOpened = array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,8 +73,8 @@ class Image extends File {
|
||||
parent::defineMethods();
|
||||
}
|
||||
|
||||
function getCMSFields() {
|
||||
$fields = parent::getCMSFields();
|
||||
function getCMSFields($params = null) {
|
||||
$fields = parent::getCMSFields($params);
|
||||
|
||||
$urlLink = "<div class='field readonly'>";
|
||||
$urlLink .= "<label class='left'>"._t('AssetTableField.URL','URL')."</label>";
|
||||
|
@ -132,7 +132,7 @@ class Versioned extends DataExtension {
|
||||
* Augment the the SQLQuery that is created by the DataQuery
|
||||
* @todo Should this all go into VersionedDataQuery?
|
||||
*/
|
||||
function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery) {
|
||||
function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null) {
|
||||
$baseTable = ClassInfo::baseDataClass($dataQuery->dataClass());
|
||||
|
||||
switch($dataQuery->getQueryParam('Versioned.mode')) {
|
||||
|
@ -41,7 +41,7 @@ class Currency extends Decimal {
|
||||
else return $val;
|
||||
}
|
||||
|
||||
function setValue($value) {
|
||||
function setValue($value, $record = null) {
|
||||
$matches = null;
|
||||
if(is_numeric($value)) {
|
||||
$this->value = $value;
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
class Date extends DBField {
|
||||
|
||||
function setValue($value) {
|
||||
function setValue($value, $record = null) {
|
||||
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
|
||||
// don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be saved as NULL in database
|
||||
$this->value = null;
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
class SS_Datetime extends Date {
|
||||
|
||||
function setValue($value) {
|
||||
function setValue($value, $record = null) {
|
||||
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
|
||||
// don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be saved as NULL in database
|
||||
$this->value = null;
|
||||
|
@ -136,7 +136,7 @@ class HTMLText extends Text {
|
||||
return new HtmlEditorField($this->name, $title);
|
||||
}
|
||||
|
||||
public function scaffoldSearchField($title = null) {
|
||||
public function scaffoldSearchField($title = null, $params = null) {
|
||||
return new TextField($this->name, $title);
|
||||
}
|
||||
|
||||
|
@ -37,9 +37,8 @@ abstract class Authenticator extends Object {
|
||||
* @return bool|Member Returns FALSE if authentication fails, otherwise
|
||||
* the member object
|
||||
*/
|
||||
public abstract static function authenticate($RAW_data,
|
||||
Form $form = null);
|
||||
|
||||
public static function authenticate($RAW_data, Form $form = null) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that creates the login form for this authentication method
|
||||
@ -49,7 +48,8 @@ abstract class Authenticator extends Object {
|
||||
* @return Form Returns the login form to use with this authentication
|
||||
* method
|
||||
*/
|
||||
public abstract static function get_login_form(Controller $controller);
|
||||
public static function get_login_form(Controller $controller) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -57,7 +57,8 @@ abstract class Authenticator extends Object {
|
||||
*
|
||||
* @return string Returns the name of the authentication method.
|
||||
*/
|
||||
public abstract static function get_name();
|
||||
public static function get_name() {
|
||||
}
|
||||
|
||||
public static function register($authenticator) {
|
||||
self::register_authenticator($authenticator);
|
||||
|
@ -59,7 +59,7 @@ class Group extends DataObject {
|
||||
*
|
||||
* @return FieldList
|
||||
*/
|
||||
public function getCMSFields() {
|
||||
public function getCMSFields($params = null) {
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
|
||||
|
||||
$fields = new FieldList(
|
||||
|
@ -1084,7 +1084,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
||||
* @return FieldList Return a FieldList of fields that would appropriate for
|
||||
* editing this member.
|
||||
*/
|
||||
public function getCMSFields() {
|
||||
public function getCMSFields($params = null) {
|
||||
require_once('Zend/Date.php');
|
||||
|
||||
$fields = parent::getCMSFields();
|
||||
|
@ -33,8 +33,8 @@ class PermissionRole extends DataObject {
|
||||
|
||||
static $plural_name = 'Roles';
|
||||
|
||||
function getCMSFields() {
|
||||
$fields = parent::getCMSFields();
|
||||
function getCMSFields($params = null) {
|
||||
$fields = parent::getCMSFields($params);
|
||||
|
||||
$fields->removeFieldFromTab('Root', 'Codes');
|
||||
$fields->removeFieldFromTab('Root', 'Groups');
|
||||
|
@ -329,7 +329,7 @@ class RequestHandlingTest_Controller extends Controller implements TestOnly {
|
||||
$this->httpError(404, 'This page does not exist.');
|
||||
}
|
||||
|
||||
public function getViewer(){
|
||||
public function getViewer($action) {
|
||||
return new SSViewer('BlankPage');
|
||||
}
|
||||
}
|
||||
@ -384,7 +384,7 @@ class RequestHandlingTest_FormActionController extends Controller {
|
||||
return 'formactionInAllowedActions';
|
||||
}
|
||||
|
||||
public function getViewer(){
|
||||
public function getViewer($action = null) {
|
||||
return new SSViewer('BlankPage');
|
||||
}
|
||||
|
||||
|
@ -128,11 +128,13 @@ class FormScaffolderTest_ArticleExtension extends DataExtension implements TestO
|
||||
static $db = array(
|
||||
'ExtendedField' => 'Varchar'
|
||||
);
|
||||
function updateCMSFields(&$fields) {
|
||||
|
||||
function updateCMSFields(FieldList $fields) {
|
||||
$fields->addFieldToTab('Root.Main',
|
||||
new TextField('AddedExtensionField')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DataObject::add_extension('FormScaffolderTest_Article', 'FormScaffolderTest_ArticleExtension');
|
||||
|
@ -468,7 +468,7 @@ class FormTest_Controller extends Controller implements TestOnly {
|
||||
return $this->redirectBack();
|
||||
}
|
||||
|
||||
function getViewer(){
|
||||
function getViewer($action = null) {
|
||||
return new SSViewer('BlankPage');
|
||||
}
|
||||
|
||||
@ -505,7 +505,7 @@ class FormTest_ControllerWithSecurityToken extends Controller implements TestOnl
|
||||
return $this->redirectBack();
|
||||
}
|
||||
|
||||
function getViewer(){
|
||||
function getViewer($action = null) {
|
||||
return new SSViewer('BlankPage');
|
||||
}
|
||||
}
|
||||
|
@ -140,8 +140,8 @@ class GridFieldDetailFormTest_Person extends DataObject implements TestOnly {
|
||||
'Categories' => 'GridFieldDetailFormTest_Category'
|
||||
);
|
||||
|
||||
function getCMSFields() {
|
||||
$fields = parent::getCMSFields();
|
||||
function getCMSFields($params = null) {
|
||||
$fields = parent::getCMSFields($params);
|
||||
// TODO No longer necessary once FormScaffolder uses GridField
|
||||
$fields->replaceField('Categories',
|
||||
Object::create('GridField', 'Categories', 'Categories',
|
||||
@ -162,8 +162,8 @@ class GridFieldDetailFormTest_PeopleGroup extends DataObject implements TestOnly
|
||||
'People' => 'GridFieldDetailFormTest_Person'
|
||||
);
|
||||
|
||||
function getCMSFields() {
|
||||
$fields = parent::getCMSFields();
|
||||
function getCMSFields($params = null) {
|
||||
$fields = parent::getCMSFields($params);
|
||||
// TODO No longer necessary once FormScaffolder uses GridField
|
||||
$fields->replaceField('People',
|
||||
Object::create('GridField', 'People', 'People',
|
||||
@ -184,8 +184,8 @@ class GridFieldDetailFormTest_Category extends DataObject implements TestOnly {
|
||||
'People' => 'GridFieldDetailFormTest_Person'
|
||||
);
|
||||
|
||||
function getCMSFields() {
|
||||
$fields = parent::getCMSFields();
|
||||
function getCMSFields($params = null) {
|
||||
$fields = parent::getCMSFields($params);
|
||||
// TODO No longer necessary once FormScaffolder uses GridField
|
||||
$fields->replaceField('People',
|
||||
Object::create('GridField', 'People', 'People',
|
||||
|
@ -567,21 +567,21 @@ static $many_many = array(
|
||||
|
||||
class UploadFieldTest_FileExtension extends DataExtension implements TestOnly {
|
||||
|
||||
function extraStatics() {
|
||||
function extraStatics($class = null, $extension = null) {
|
||||
return array(
|
||||
'has_one' => array('Record' => 'UploadFieldTest_Record')
|
||||
);
|
||||
}
|
||||
|
||||
function canDelete() {
|
||||
function canDelete($member = null) {
|
||||
if($this->owner->Name == 'nodelete.txt') return false;
|
||||
}
|
||||
|
||||
function canEdit() {
|
||||
function canEdit($member = null) {
|
||||
if($this->owner->Name == 'noedit.txt') return false;
|
||||
}
|
||||
|
||||
function canView() {
|
||||
function canView($member = null) {
|
||||
if($this->owner->Name == 'noview.txt') return false;
|
||||
}
|
||||
}
|
||||
|
@ -73,13 +73,15 @@ class AggregateTest extends SapphireTest {
|
||||
* Test basic aggregation on a passed type
|
||||
*/
|
||||
function testTypeSpecifiedAggregate() {
|
||||
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
|
||||
|
||||
// Template style access
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->XML_val('Max', array('Foo')), 9);
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->XML_val('Max', array('Fab')), 3);
|
||||
$this->assertEquals($foo->Aggregate('AggregateTest_Foo')->XML_val('Max', array('Foo')), 9);
|
||||
$this->assertEquals($foo->Aggregate('AggregateTest_Fab')->XML_val('Max', array('Fab')), 3);
|
||||
|
||||
// PHP style access
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Fab'), 3);
|
||||
$this->assertEquals($foo->Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
|
||||
$this->assertEquals($foo->Aggregate('AggregateTest_Fab')->Max('Fab'), 3);
|
||||
}
|
||||
/* */
|
||||
|
||||
@ -106,13 +108,15 @@ class AggregateTest extends SapphireTest {
|
||||
* @return unknown_type
|
||||
*/
|
||||
function testBaseFieldAggregate() {
|
||||
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
|
||||
|
||||
$this->assertEquals(
|
||||
$this->formatDate(DataObject::Aggregate('AggregateTest_Foo')->Max('LastEdited')),
|
||||
$this->formatDate($foo->Aggregate('AggregateTest_Foo')->Max('LastEdited')),
|
||||
$this->formatDate(DataObject::get_one('AggregateTest_Foo', '', '', '"LastEdited" DESC')->LastEdited)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$this->formatDate(DataObject::Aggregate('AggregateTest_Foo')->Max('Created')),
|
||||
$this->formatDate($foo->Aggregate('AggregateTest_Foo')->Max('Created')),
|
||||
$this->formatDate(DataObject::get_one('AggregateTest_Foo', '', '', '"Created" DESC')->Created)
|
||||
);
|
||||
}
|
||||
@ -122,13 +126,14 @@ class AggregateTest extends SapphireTest {
|
||||
* Test aggregation takes place on the passed type & it's children only
|
||||
*/
|
||||
function testChildAggregate() {
|
||||
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
|
||||
|
||||
// For base classes, aggregate is calculcated on it and all children classes
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
|
||||
$this->assertEquals($foo->Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
|
||||
|
||||
// For subclasses, aggregate is calculated for that subclass and it's children only
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
||||
$this->assertEquals($foo->Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
|
||||
$this->assertEquals($foo->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
||||
|
||||
}
|
||||
/* */
|
||||
@ -145,35 +150,35 @@ class AggregateTest extends SapphireTest {
|
||||
* Test cache is correctly flushed on write
|
||||
*/
|
||||
function testCacheFlushing() {
|
||||
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
|
||||
$fab = $this->objFromFixture('AggregateTest_Fab', 'fab1');
|
||||
|
||||
// For base classes, aggregate is calculcated on it and all children classes
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
|
||||
$this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 9);
|
||||
|
||||
// For subclasses, aggregate is calculated for that subclass and it's children only
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
||||
$this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
|
||||
$this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
||||
|
||||
$foo = $this->objFromFixture('AggregateTest_Foo', 'foo1');
|
||||
$foo->Foo = 12;
|
||||
$foo->write();
|
||||
|
||||
// For base classes, aggregate is calculcated on it and all children classes
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 12);
|
||||
$this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 12);
|
||||
|
||||
// For subclasses, aggregate is calculated for that subclass and it's children only
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
||||
$this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 9);
|
||||
$this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
||||
|
||||
$fab = $this->objFromFixture('AggregateTest_Fab', 'fab1');
|
||||
$fab->Foo = 15;
|
||||
$fab->write();
|
||||
|
||||
// For base classes, aggregate is calculcated on it and all children classes
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 15);
|
||||
$this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 15);
|
||||
|
||||
// For subclasses, aggregate is calculated for that subclass and it's children only
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 15);
|
||||
$this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
||||
$this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 15);
|
||||
$this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6);
|
||||
}
|
||||
/* */
|
||||
|
||||
|
@ -62,8 +62,8 @@ class DataDifferencerTest_Object extends DataObject implements TestOnly {
|
||||
'HasOneRelation' => 'DataDifferencerTest_HasOneRelationObject'
|
||||
);
|
||||
|
||||
function getCMSFields() {
|
||||
$fields = parent::getCMSFields();
|
||||
function getCMSFields($params = null) {
|
||||
$fields = parent::getCMSFields($params);
|
||||
$choices = array(
|
||||
'a' => 'a',
|
||||
'b' => 'b',
|
||||
|
@ -132,7 +132,7 @@ class GroupTest extends FunctionalTest {
|
||||
|
||||
class GroupTest_Member extends Member implements TestOnly {
|
||||
|
||||
function getCMSFields() {
|
||||
function getCMSFields($params = null) {
|
||||
$groups = DataObject::get('Group');
|
||||
$groupsMap = ($groups) ? $groups->map() : false;
|
||||
$fields = new FieldList(
|
||||
|
@ -591,29 +591,29 @@ class MemberTest extends FunctionalTest {
|
||||
}
|
||||
class MemberTest_ViewingAllowedExtension extends DataExtension implements TestOnly {
|
||||
|
||||
public function canView() {
|
||||
public function canView($member = null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
class MemberTest_ViewingDeniedExtension extends DataExtension implements TestOnly {
|
||||
|
||||
public function canView() {
|
||||
public function canView($member = null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
class MemberTest_EditingAllowedDeletingDeniedExtension extends DataExtension implements TestOnly {
|
||||
|
||||
public function canView() {
|
||||
public function canView($member = null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canEdit() {
|
||||
public function canEdit($member = null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function canDelete() {
|
||||
public function canDelete($member = null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -930,7 +930,7 @@ class SSViewerTestFixture extends ViewableData {
|
||||
}
|
||||
|
||||
|
||||
function XML_val($fieldName, $arguments = null) {
|
||||
function XML_val($fieldName, $arguments = null, $cache = false) {
|
||||
if(preg_match('/NotSet/i', $fieldName)) {
|
||||
return '';
|
||||
} else if(preg_match('/Raw/i', $fieldName)) {
|
||||
@ -940,7 +940,7 @@ class SSViewerTestFixture extends ViewableData {
|
||||
}
|
||||
}
|
||||
|
||||
function hasValue($fieldName, $arguments = null) {
|
||||
function hasValue($fieldName, $arguments = null, $cache = true) {
|
||||
return (bool)$this->XML_val($fieldName, $arguments);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user