diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..2f0465af --- /dev/null +++ b/.editorconfig @@ -0,0 +1,24 @@ +# For more information about the properties used in +# this file, please see the EditorConfig documentation: +# http://editorconfig.org/ + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = tab +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.yml] +indent_size = 2 +indent_style = space + +# Don't perform any clean-up on thirdparty files + +[thirdparty/**] +trim_trailing_whitespace = false +insert_final_newline = false diff --git a/.travis.yml b/.travis.yml index 21c0d86b..a489b206 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,7 +41,7 @@ before_script: - php ~/travis-support/travis_setup_selenium.php --if-env BEHAT_TEST - php ~/travis-support/travis_setup_php54_webserver.php --if-env BEHAT_TEST -script: +script: - "if [ \"$BEHAT_TEST\" = \"\" ]; then vendor/bin/phpunit cms/tests; fi" - "if [ \"$BEHAT_TEST\" = \"1\" ]; then vendor/bin/behat @cms; fi" diff --git a/_config.php b/_config.php index d12d80b7..e5201d8a 100644 --- a/_config.php +++ b/_config.php @@ -22,4 +22,4 @@ CMSMenu::remove_menu_item('CMSPageHistoryController'); CMSMenu::remove_menu_item('CMSPageReportsController'); CMSMenu::remove_menu_item('CMSPageAddController'); -CMSMenu::remove_menu_item("SiteConfigLeftAndMain"); \ No newline at end of file +CMSMenu::remove_menu_item("SiteConfigLeftAndMain"); diff --git a/code/batchactions/CMSBatchActions.php b/code/batchactions/CMSBatchActions.php index df185a5d..9f10e2b6 100644 --- a/code/batchactions/CMSBatchActions.php +++ b/code/batchactions/CMSBatchActions.php @@ -1,7 +1,7 @@ canDelete()) $page->delete(); else $status['error'][$page->ID] = true; - // check to see if the record exists on the live site, + // check to see if the record exists on the live site, // if it doesn't remove the tree node $liveRecord = Versioned::get_one_by_stage( 'SiteTree', 'Live', array( '"SiteTree"."ID"' => $id @@ -166,7 +166,7 @@ class CMSBatchAction_Delete extends CMSBatchAction { /** * Unpublish (delete from live site) items batch action. - * + * * @package cms * @subpackage batchaction * @deprecated since version 4.0 diff --git a/code/controllers/CMSPageAddController.php b/code/controllers/CMSPageAddController.php index 2e0e3f9a..1beb6276 100644 --- a/code/controllers/CMSPageAddController.php +++ b/code/controllers/CMSPageAddController.php @@ -50,7 +50,7 @@ class CMSPageAddController extends CMSPageEditController { new SelectionGroup_Item( 'child', $parentField = new TreeDropdownField( - "ParentID", + "ParentID", "", 'SiteTree', 'ID', @@ -61,8 +61,8 @@ class CMSPageAddController extends CMSPageEditController { ) ), $typeField = new OptionsetField( - "PageType", - sprintf($numericLabelTmpl, 2, _t('CMSMain.ChoosePageType', 'Choose page type')), + "PageType", + sprintf($numericLabelTmpl, 2, _t('CMSMain.ChoosePageType', 'Choose page type')), $pageTypes, 'Page' ), @@ -71,7 +71,7 @@ class CMSPageAddController extends CMSPageEditController { sprintf( '

%s

', _t( - 'CMSMain.AddPageRestriction', + 'CMSMain.AddPageRestriction', 'Note: Some page types are not allowed for this selection' ) ) @@ -79,7 +79,7 @@ class CMSPageAddController extends CMSPageEditController { ); $parentField->setSearchFunction(function ($sourceObject, $labelField, $search) { return DataObject::get( - $sourceObject, + $sourceObject, sprintf( "\"MenuTitle\" LIKE '%%%s%%' OR \"Title\" LIKE '%%%s%%'", Convert::raw2sql($search), @@ -88,10 +88,10 @@ class CMSPageAddController extends CMSPageEditController { ); }); - // TODO Re-enable search once it allows for HTML title display, + // TODO Re-enable search once it allows for HTML title display, // see http://open.silverstripe.org/ticket/7455 // $parentField->setShowSearch(true); - + $parentModeField->addExtraClass('parent-mode'); // CMSMain->currentPageID() automatically sets the homepage, @@ -102,7 +102,7 @@ class CMSPageAddController extends CMSPageEditController { } else { $parentModeField->setValue('top'); } - + $actions = new FieldList( FormAction::create("doAdd", _t('CMSMain.Create',"Create")) ->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept') @@ -111,10 +111,10 @@ class CMSPageAddController extends CMSPageEditController { ->addExtraClass('ss-ui-action-destructive ss-ui-action-cancel') ->setUseButtonTag(true) ); - + $this->extend('updatePageOptions', $fields); - - $form = CMSForm::create( + + $form = CMSForm::create( $this, "AddForm", $fields, $actions )->setHTMLID('Form_AddForm'); $form->setAttribute('data-hints', $this->SiteTreeHints()); @@ -140,7 +140,7 @@ class CMSPageAddController extends CMSPageEditController { if(is_numeric($parentID) && $parentID > 0) $parentObj = DataObject::get_by_id("SiteTree", $parentID); else $parentObj = null; - + if(!$parentObj || !$parentObj->ID) $parentID = 0; if(!singleton($className)->canCreate(Member::currentUser(), array('Parent' => $parentObj))) { @@ -163,11 +163,11 @@ class CMSPageAddController extends CMSPageEditController { $editController->setCurrentPageID($record->ID); Session::set( - "FormInfo.Form_EditForm.formError.message", + "FormInfo.Form_EditForm.formError.message", _t('CMSMain.PageAdded', 'Successfully created page') ); Session::set("FormInfo.Form_EditForm.formError.type", 'good'); - + return $this->redirect(Controller::join_links(singleton('CMSPageEditController')->Link('show'), $record->ID)); } diff --git a/code/controllers/CMSPageHistoryController.php b/code/controllers/CMSPageHistoryController.php index e854f2ac..eb03eadc 100644 --- a/code/controllers/CMSPageHistoryController.php +++ b/code/controllers/CMSPageHistoryController.php @@ -12,14 +12,14 @@ class CMSPageHistoryController extends CMSMain { private static $menu_title = 'History'; private static $required_permission_codes = 'CMS_ACCESS_CMSMain'; private static $session_namespace = 'CMSMain'; - + private static $allowed_actions = array( 'VersionsForm', 'CompareVersionsForm', 'show', 'compare' ); - + private static $url_handlers = array( '$Action/$ID/$VersionID/$OtherVersionID' => 'handleAction' ); @@ -37,14 +37,14 @@ class CMSPageHistoryController extends CMSMain { }); return $negotiator; } - + /** * @param SS_HTTPRequest $request * @return array */ public function show($request) { $form = $this->ShowVersionForm($request->param('VersionID')); - + $negotiator = $this->getResponseNegotiator(); $controller = $this; $negotiator->setCallback('CurrentForm', function() use(&$controller, &$form) { @@ -56,14 +56,14 @@ class CMSPageHistoryController extends CMSMain { return $negotiator->respond($request); } - + /** * @param SS_HTTPRequest $request * @return array */ public function compare($request) { $form = $this->CompareVersionsForm( - $request->param('VersionID'), + $request->param('VersionID'), $request->param('OtherVersionID') ); @@ -88,13 +88,13 @@ class CMSPageHistoryController extends CMSMain { return false; } } - + /** - * Returns the read only version of the edit form. Detaches all {@link FormAction} + * Returns the read only version of the edit form. Detaches all {@link FormAction} * instances attached since only action relates to revert. * * Permission checking is done at the {@link CMSMain::getEditForm()} level. - * + * * @param int $id ID of the record to show * @param array $fields optional * @param int $versionID @@ -104,10 +104,10 @@ class CMSPageHistoryController extends CMSMain { */ public function getEditForm($id = null, $fields = null, $versionID = null, $compareID = null) { if(!$id) $id = $this->currentPageID(); - + $record = $this->getRecord($id, $versionID); $versionID = ($record) ? $record->Version : $versionID; - + $form = parent::getEditForm($record, ($record) ? $record->getCMSFields() : null); // Respect permission failures from parent implementation if(!($form instanceof Form)) return $form; @@ -118,14 +118,14 @@ class CMSPageHistoryController extends CMSMain { $form->setActions(new FieldList( $revert = FormAction::create('doRollback', _t('CMSPageHistoryController.REVERTTOTHISVERSION', 'Revert to this version'))->setUseButtonTag(true) )); - + $fields = $form->Fields(); $fields->removeByName("Status"); $fields->push(new HiddenField("ID")); $fields->push(new HiddenField("Version")); - - $fields = $fields->makeReadonly(); - + + $fields = $fields->makeReadonly(); + if($compareID) { $link = Controller::join_links( $this->Link('show'), @@ -133,7 +133,7 @@ class CMSPageHistoryController extends CMSMain { ); $view = _t('CMSPageHistoryController.VIEW',"view"); - + $message = _t( 'CMSPageHistoryController.COMPARINGVERSION', "Comparing versions {version1} and {version2}.", @@ -142,7 +142,7 @@ class CMSPageHistoryController extends CMSMain { 'version2' => sprintf('%s (%s)', $compareID, Controller::join_links($link, $compareID), $view) ) ); - + $revert->setReadonly(true); } else { if($record->isLatestVersion()) { @@ -155,8 +155,8 @@ class CMSPageHistoryController extends CMSMain { ); } } - - $fields->addFieldToTab('Root.Main', + + $fields->addFieldToTab('Root.Main', new LiteralField('CurrentlyViewingMessage', $this->customise(array( 'Content' => $message, 'Classes' => 'notice' @@ -169,23 +169,23 @@ class CMSPageHistoryController extends CMSMain { "ID" => $id, "Version" => $versionID, )); - + if(($record && $record->isLatestVersion())) { $revert->setReadonly(true); } - + $form->removeExtraClass('cms-content'); return $form; } - - + + /** - * Version select form. Main interface between selecting versions to view + * Version select form. Main interface between selecting versions to view * and comparing multiple versions. - * + * * Because we can reload the page directly to a compare view (history/compare/1/2/3) - * this form has to adapt to those parameters as well. + * this form has to adapt to those parameters as well. * * @return Form */ @@ -197,7 +197,7 @@ class CMSPageHistoryController extends CMSMain { $action = $this->getRequest()->param('Action'); $versionID = $this->getRequest()->param('VersionID'); $otherVersionID = $this->getRequest()->param('OtherVersionID'); - + $showUnpublishedChecked = 0; $compareModeChecked = ($action == "compare"); @@ -208,19 +208,19 @@ class CMSPageHistoryController extends CMSMain { if($versions) { foreach($versions as $k => $version) { $active = false; - + if($version->Version == $versionID || $version->Version == $otherVersionID) { $active = true; - + if(!$version->WasPublished) $showUnpublishedChecked = 1; } $version->Active = ($active); } } - + $vd = new ViewableData(); - + $versionsHtml = $vd->customise(array( 'Versions' => $versions ))->renderWith('CMSPageHistoryController_versions'); @@ -246,14 +246,14 @@ class CMSPageHistoryController extends CMSMain { 'doCompare', _t('CMSPageHistoryController.COMPAREVERSIONS','Compare Versions') ), new FormAction( - 'doShowVersion', _t('CMSPageHistoryController.SHOWVERSION','Show Version') + 'doShowVersion', _t('CMSPageHistoryController.SHOWVERSION','Show Version') ) ); // Use <% if $HelpText %>

$HelpText

<% end_if %> - \ No newline at end of file + diff --git a/tests/behat/behat.yml b/tests/behat/behat.yml index 9f3f6c9a..a5f11a82 100644 --- a/tests/behat/behat.yml +++ b/tests/behat/behat.yml @@ -30,4 +30,4 @@ saucelabs: capabilities: platform: "Windows 2008" browser: "firefox" - version: "15" \ No newline at end of file + version: "15" diff --git a/tests/behat/features/bootstrap/FeatureContext.php b/tests/behat/features/bootstrap/FeatureContext.php index 41a22526..83bae940 100644 --- a/tests/behat/features/bootstrap/FeatureContext.php +++ b/tests/behat/features/bootstrap/FeatureContext.php @@ -47,7 +47,7 @@ class FeatureContext extends \SilverStripe\Framework\Test\Behaviour\FeatureConte $obj->publish('Stage', 'Live'); }); $factory->define($class, $blueprint); - } + } } } diff --git a/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/FixtureContext.php b/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/FixtureContext.php index bd816ae7..55c9e0cb 100644 --- a/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/FixtureContext.php +++ b/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/FixtureContext.php @@ -23,8 +23,8 @@ class FixtureContext extends \SilverStripe\BehatExtension\Context\FixtureContext /** * Find or create a redirector page and link to another existing page. - * Example: Given a "page" "My Redirect" which redirects to a "page" "Page 1" - * + * Example: Given a "page" "My Redirect" which redirects to a "page" "Page 1" + * * @Given /^(?:(an|a|the) )"(?[^"]+)" "(?[^"]+)" (:?which )?redirects to (?:(an|a|the) )"(?[^"]+)" "(?[^"]+)"$/ */ public function stepCreateRedirectorPage($type, $id, $targetType, $targetId) { @@ -46,17 +46,17 @@ class FixtureContext extends \SilverStripe\BehatExtension\Context\FixtureContext } /** - * + * * Check if the user can edit a page - * - * Example: Then pages should be editable by "Admin" + * + * Example: Then pages should be editable by "Admin" * Then pages should not be editable by "Admin" - * + * * @Then /^pages should( not? |\s*)be editable by "([^"]*)"$/ */ - public function pagesShouldBeEditableBy($negative, $member){ + public function pagesShouldBeEditableBy($negative, $member){ $page = \Page::get()->First(); - + return array( new Step\Given('I am not logged in'), new Step\Given('I am logged in with "' . $member . '" permissions'), diff --git a/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/ThemeContext.php b/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/ThemeContext.php index 004586a7..a034954e 100644 --- a/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/ThemeContext.php +++ b/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/ThemeContext.php @@ -26,7 +26,7 @@ class ThemeContext extends BehatContext { /** * Create a test theme - * + * * @Given /^a theme "(?[^"]+)"/ */ public function stepCreateTheme($theme) { @@ -39,7 +39,7 @@ class ThemeContext extends BehatContext { /** * Create a template within a test theme - * + * * @Given /^a template "(?