From 116aa79e3b27369fff59ef3b01ca47930ca2b891 Mon Sep 17 00:00:00 2001 From: helpfulrobot Date: Fri, 1 Jan 2016 02:01:46 +1300 Subject: [PATCH] Converted to PSR-2 --- code/EventLocation.php | 133 +++++++++++++++-------------- code/EventLocationAdmin.php | 16 ++-- code/LocationDateTimeExtension.php | 68 +++++++-------- 3 files changed, 112 insertions(+), 105 deletions(-) diff --git a/code/EventLocation.php b/code/EventLocation.php index 0269276..2ab144d 100644 --- a/code/EventLocation.php +++ b/code/EventLocation.php @@ -5,77 +5,84 @@ * * @package silverstripe-eventlocations */ -class EventLocation extends DataObject { +class EventLocation extends DataObject +{ - private static $db = array( - 'Title' => 'Varchar(255)', - 'Capacity' => 'Int' - ); + private static $db = array( + 'Title' => 'Varchar(255)', + 'Capacity' => 'Int' + ); - private static $extensions = array( - 'Addressable' - ); + private static $extensions = array( + 'Addressable' + ); - private static $summary_fields = array( - 'Title' => 'Title', - 'Capacity' => 'Capacity', - 'FullAddress' => 'Address' - ); + private static $summary_fields = array( + 'Title' => 'Title', + 'Capacity' => 'Capacity', + 'FullAddress' => 'Address' + ); - private static $searchable_fields = array( - 'Title' - ); + private static $searchable_fields = array( + 'Title' + ); - public function getCMSFields(){ - $fields = parent::getCMSFields(); + public function getCMSFields() + { + $fields = parent::getCMSFields(); - if(!class_exists('EventRegistration')){ - $fields->removeByName('Capacity'); - } - - return $fields; - } + if (!class_exists('EventRegistration')) { + $fields->removeByName('Capacity'); + } + + return $fields; + } - public function summaryFields(){ - $fields = parent::summaryFields(); - if(!class_exists('EventRegistration')){ - unset($fields['Capacity']); - } - return $fields; - } + public function summaryFields() + { + $fields = parent::summaryFields(); + if (!class_exists('EventRegistration')) { + unset($fields['Capacity']); + } + return $fields; + } - - /** - * @param Member $member - * @return boolean - */ - public function canView($member = null) { - return Permission::check('CMS_ACCESS_EventLocationAdmin', 'any', $member); - } + + /** + * @param Member $member + * @return boolean + */ + public function canView($member = null) + { + return Permission::check('CMS_ACCESS_EventLocationAdmin', 'any', $member); + } - /** - * @param Member $member - * @return boolean - */ - public function canEdit($member = null) { - return Permission::check('CMS_ACCESS_EventLocationAdmin', 'any', $member); - } + /** + * @param Member $member + * @return boolean + */ + public function canEdit($member = null) + { + return Permission::check('CMS_ACCESS_EventLocationAdmin', 'any', $member); + } - /** - * @param Member $member - * @return boolean - */ - public function canDelete($member = null) { - return Permission::check('CMS_ACCESS_EventLocationAdmin', 'any', $member); - } + /** + * @param Member $member + * @return boolean + */ + public function canDelete($member = null) + { + return Permission::check('CMS_ACCESS_EventLocationAdmin', 'any', $member); + } - /** - * @todo Should canCreate be a static method? - * - * @param Member $member - * @return boolean - */ - public function canCreate($member = null) { - return Permission::check('CMS_ACCESS_EventLocationAdmin', 'any', $member); - } -} \ No newline at end of file + /** + * @todo Should canCreate be a static method? + * + * @param Member $member + * @return boolean + */ + public function canCreate($member = null) + { + return Permission::check('CMS_ACCESS_EventLocationAdmin', 'any', $member); + } +} diff --git a/code/EventLocationAdmin.php b/code/EventLocationAdmin.php index 5dc025c..9fa4096 100644 --- a/code/EventLocationAdmin.php +++ b/code/EventLocationAdmin.php @@ -4,13 +4,13 @@ * * @package silverstripe-eventlocations */ -class EventLocationAdmin extends ModelAdmin { +class EventLocationAdmin extends ModelAdmin +{ - private static $title = 'Event Locations'; - private static $menu_title = 'Event Locations'; - private static $url_segment = 'event-locations'; + private static $title = 'Event Locations'; + private static $menu_title = 'Event Locations'; + private static $url_segment = 'event-locations'; - private static $managed_models = 'EventLocation'; - private static $model_importers = array(); - -} \ No newline at end of file + private static $managed_models = 'EventLocation'; + private static $model_importers = array(); +} diff --git a/code/LocationDateTimeExtension.php b/code/LocationDateTimeExtension.php index 97f67d5..86c6aa1 100644 --- a/code/LocationDateTimeExtension.php +++ b/code/LocationDateTimeExtension.php @@ -4,43 +4,43 @@ * * @package silverstripe-eventlocations */ -class LocationDateTimeExtension extends DataExtension { +class LocationDateTimeExtension extends DataExtension +{ - private static $has_one = array( - 'Location' => 'EventLocation' - ); + private static $has_one = array( + 'Location' => 'EventLocation' + ); - public function updateCMSFields(FieldList $fields) { - - $locations = function(){ - return EventLocation::get()->map()->toArray(); - }; + public function updateCMSFields(FieldList $fields) + { + $locations = function () { + return EventLocation::get()->map()->toArray(); + }; - $dropdown = DropdownField::create( - 'LocationID', - _t('EventLocations.LOCATION', 'Location'), - $locations() - )->setHasEmptyDefault(true); + $dropdown = DropdownField::create( + 'LocationID', + _t('EventLocations.LOCATION', 'Location'), + $locations() + )->setHasEmptyDefault(true); - if(class_exists('QuickAddNewExtension')){ - $dropdown->useAddNew('EventLocation', $locations); - } + if (class_exists('QuickAddNewExtension')) { + $dropdown->useAddNew('EventLocation', $locations); + } - - if($this->owner->hasField('Capacity')){ - Requirements::javascript(THIRDPARTY_DIR . '/jquery-metadata/jquery.metadata.js'); - Requirements::add_i18n_javascript('eventlocations/javascript/lang'); - Requirements::javascript('eventlocations/javascript/LocationDateTimeCms.js'); + + if ($this->owner->hasField('Capacity')) { + Requirements::javascript(THIRDPARTY_DIR . '/jquery-metadata/jquery.metadata.js'); + Requirements::add_i18n_javascript('eventlocations/javascript/lang'); + Requirements::javascript('eventlocations/javascript/LocationDateTimeCms.js'); - $capacities = array(); - foreach ($locations as $location) { - if ($location->Capacity) { - $capacities[$location->ID] = (int) $location->Capacity; - } - } - $dropdown->addExtraClass('{ capacities: ' . Convert::array2json($capacities) . ' }'); - } - $fields->insertBefore($dropdown, 'StartDate'); - } - -} \ No newline at end of file + $capacities = array(); + foreach ($locations as $location) { + if ($location->Capacity) { + $capacities[$location->ID] = (int) $location->Capacity; + } + } + $dropdown->addExtraClass('{ capacities: ' . Convert::array2json($capacities) . ' }'); + } + $fields->insertBefore($dropdown, 'StartDate'); + } +}