From cb946508cf98d7e66219fb012d77142d9d4f5c71 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Fri, 22 Jul 2016 11:07:50 +1200 Subject: [PATCH 1/3] Move CMS classes and templates to namespaced locations --- code/{batchactions => BatchActions}/CMSBatchActions.php | 0 code/{controllers => Controllers}/AssetAdmin.php | 0 code/{controllers => Controllers}/CMSMain.php | 0 code/{controllers => Controllers}/CMSPageAddController.php | 0 code/{controllers => Controllers}/CMSPageEditController.php | 0 .../CMSPageHistoryController.php | 0 .../CMSPageSettingsController.php | 0 code/{controllers => Controllers}/CMSPagesController.php | 0 code/{controllers => Controllers}/CMSSettingsController.php | 0 code/{controllers => Controllers}/CMSSiteTreeFilter.php | 0 code/{controllers => Controllers}/ContentController.php | 0 .../ErrorPageControllerExtension.php | 0 .../{controllers => Controllers}/ErrorPageFileExtension.php | 0 .../LeftAndMainPageIconsExtension.php | 0 code/{controllers => Controllers}/ModelAsController.php | 0 code/{controllers => Controllers}/OldPageRedirector.php | 0 code/{controllers => Controllers}/RootURLController.php | 0 code/{controllers => Controllers}/SilverStripeNavigator.php | 0 code/{forms => Forms}/SiteTreeURLSegmentField.php | 0 code/{logging => Logging}/ErrorPageErrorFormatter.php | 0 code/{model => Model}/CurrentPageIdentifier.php | 0 code/{model => Model}/ErrorPage.php | 0 code/{model => Model}/RedirectorPage.php | 0 code/{model => Model}/SiteTree.php | 0 code/{model => Model}/SiteTreeExtension.php | 0 code/{model => Model}/SiteTreeFileExtension.php | 0 code/{model => Model}/SiteTreeFolderExtension.php | 0 code/{model => Model}/SiteTreeLinkTracking.php | 0 code/{model => Model}/VirtualPage.php | 0 code/{reports => Reports}/BrokenFilesReport.php | 0 code/{reports => Reports}/BrokenLinksReport.php | 0 code/{reports => Reports}/BrokenRedirectorPagesReport.php | 0 code/{reports => Reports}/BrokenVirtualPagesReport.php | 0 code/{reports => Reports}/EmptyPagesReport.php | 0 code/{reports => Reports}/RecentlyEditedReport.php | 0 .../{search => Search}/ContentControllerSearchExtension.php | 0 code/{search => Search}/SearchForm.php | 0 {tasks => code/Tasks}/MigrateSiteTreeLinkingTask.php | 0 {tasks => code/Tasks}/RemoveOrphanedPagesTask.php | 0 {tasks => code/Tasks}/SiteTreeMaintenanceTask.php | 0 .../CMS/Controllers}/AssetAdmin_Content.ss | 0 .../CMS/Controllers}/AssetAdmin_EditForm.ss | 0 .../CMS/Controllers}/AssetAdmin_Tools.ss | 0 .../CMS/Controllers}/AssetAdmin_UploadContent.ss | 0 .../CMS/Controllers}/CMSMain_Content.ss | 0 .../CMS/Controllers}/CMSMain_EditForm.ss | 0 .../CMS/Controllers}/CMSMain_ListView.ss | 4 ++-- .../CMS/Controllers}/CMSMain_Tools.ss | 0 .../CMS/Controllers}/CMSMain_TreeView.ss | 2 +- .../CMS/Controllers}/CMSPageAddController_Content.ss | 0 .../CMS/Controllers}/CMSPageHistoryController_Tools.ss | 0 .../CMS/Controllers}/CMSPageHistoryController_versions.ss | 0 .../CMS/Controllers}/CMSPagesController_Content.ss | 0 .../CMS/Controllers}/CMSPagesController_Tools.ss | 0 .../Includes/CMSPagesController_ContentToolActions.ss | 0 .../{ => SilverStripe/CMS/Forms}/SiteTreeURLSegmentField.ss | 6 +++--- 56 files changed, 6 insertions(+), 6 deletions(-) rename code/{batchactions => BatchActions}/CMSBatchActions.php (100%) rename code/{controllers => Controllers}/AssetAdmin.php (100%) rename code/{controllers => Controllers}/CMSMain.php (100%) rename code/{controllers => Controllers}/CMSPageAddController.php (100%) rename code/{controllers => Controllers}/CMSPageEditController.php (100%) rename code/{controllers => Controllers}/CMSPageHistoryController.php (100%) rename code/{controllers => Controllers}/CMSPageSettingsController.php (100%) rename code/{controllers => Controllers}/CMSPagesController.php (100%) rename code/{controllers => Controllers}/CMSSettingsController.php (100%) rename code/{controllers => Controllers}/CMSSiteTreeFilter.php (100%) rename code/{controllers => Controllers}/ContentController.php (100%) rename code/{controllers => Controllers}/ErrorPageControllerExtension.php (100%) rename code/{controllers => Controllers}/ErrorPageFileExtension.php (100%) rename code/{controllers => Controllers}/LeftAndMainPageIconsExtension.php (100%) rename code/{controllers => Controllers}/ModelAsController.php (100%) rename code/{controllers => Controllers}/OldPageRedirector.php (100%) rename code/{controllers => Controllers}/RootURLController.php (100%) rename code/{controllers => Controllers}/SilverStripeNavigator.php (100%) rename code/{forms => Forms}/SiteTreeURLSegmentField.php (100%) rename code/{logging => Logging}/ErrorPageErrorFormatter.php (100%) rename code/{model => Model}/CurrentPageIdentifier.php (100%) rename code/{model => Model}/ErrorPage.php (100%) rename code/{model => Model}/RedirectorPage.php (100%) rename code/{model => Model}/SiteTree.php (100%) rename code/{model => Model}/SiteTreeExtension.php (100%) rename code/{model => Model}/SiteTreeFileExtension.php (100%) rename code/{model => Model}/SiteTreeFolderExtension.php (100%) rename code/{model => Model}/SiteTreeLinkTracking.php (100%) rename code/{model => Model}/VirtualPage.php (100%) rename code/{reports => Reports}/BrokenFilesReport.php (100%) rename code/{reports => Reports}/BrokenLinksReport.php (100%) rename code/{reports => Reports}/BrokenRedirectorPagesReport.php (100%) rename code/{reports => Reports}/BrokenVirtualPagesReport.php (100%) rename code/{reports => Reports}/EmptyPagesReport.php (100%) rename code/{reports => Reports}/RecentlyEditedReport.php (100%) rename code/{search => Search}/ContentControllerSearchExtension.php (100%) rename code/{search => Search}/SearchForm.php (100%) rename {tasks => code/Tasks}/MigrateSiteTreeLinkingTask.php (100%) rename {tasks => code/Tasks}/RemoveOrphanedPagesTask.php (100%) rename {tasks => code/Tasks}/SiteTreeMaintenanceTask.php (100%) rename templates/{Includes => SilverStripe/CMS/Controllers}/AssetAdmin_Content.ss (100%) rename templates/{Includes => SilverStripe/CMS/Controllers}/AssetAdmin_EditForm.ss (100%) rename templates/{Includes => SilverStripe/CMS/Controllers}/AssetAdmin_Tools.ss (100%) rename templates/{Includes => SilverStripe/CMS/Controllers}/AssetAdmin_UploadContent.ss (100%) rename templates/{Includes => SilverStripe/CMS/Controllers}/CMSMain_Content.ss (100%) rename templates/{Includes => SilverStripe/CMS/Controllers}/CMSMain_EditForm.ss (100%) rename templates/{Includes => SilverStripe/CMS/Controllers}/CMSMain_ListView.ss (88%) rename templates/{Includes => SilverStripe/CMS/Controllers}/CMSMain_Tools.ss (100%) rename templates/{Includes => SilverStripe/CMS/Controllers}/CMSMain_TreeView.ss (95%) rename templates/{Includes => SilverStripe/CMS/Controllers}/CMSPageAddController_Content.ss (100%) rename templates/{Includes => SilverStripe/CMS/Controllers}/CMSPageHistoryController_Tools.ss (100%) rename templates/{ => SilverStripe/CMS/Controllers}/CMSPageHistoryController_versions.ss (100%) rename templates/{Includes => SilverStripe/CMS/Controllers}/CMSPagesController_Content.ss (100%) rename templates/{Includes => SilverStripe/CMS/Controllers}/CMSPagesController_Tools.ss (100%) rename templates/{ => SilverStripe/CMS/Controllers}/Includes/CMSPagesController_ContentToolActions.ss (100%) rename templates/forms/{ => SilverStripe/CMS/Forms}/SiteTreeURLSegmentField.ss (57%) diff --git a/code/batchactions/CMSBatchActions.php b/code/BatchActions/CMSBatchActions.php similarity index 100% rename from code/batchactions/CMSBatchActions.php rename to code/BatchActions/CMSBatchActions.php diff --git a/code/controllers/AssetAdmin.php b/code/Controllers/AssetAdmin.php similarity index 100% rename from code/controllers/AssetAdmin.php rename to code/Controllers/AssetAdmin.php diff --git a/code/controllers/CMSMain.php b/code/Controllers/CMSMain.php similarity index 100% rename from code/controllers/CMSMain.php rename to code/Controllers/CMSMain.php diff --git a/code/controllers/CMSPageAddController.php b/code/Controllers/CMSPageAddController.php similarity index 100% rename from code/controllers/CMSPageAddController.php rename to code/Controllers/CMSPageAddController.php diff --git a/code/controllers/CMSPageEditController.php b/code/Controllers/CMSPageEditController.php similarity index 100% rename from code/controllers/CMSPageEditController.php rename to code/Controllers/CMSPageEditController.php diff --git a/code/controllers/CMSPageHistoryController.php b/code/Controllers/CMSPageHistoryController.php similarity index 100% rename from code/controllers/CMSPageHistoryController.php rename to code/Controllers/CMSPageHistoryController.php diff --git a/code/controllers/CMSPageSettingsController.php b/code/Controllers/CMSPageSettingsController.php similarity index 100% rename from code/controllers/CMSPageSettingsController.php rename to code/Controllers/CMSPageSettingsController.php diff --git a/code/controllers/CMSPagesController.php b/code/Controllers/CMSPagesController.php similarity index 100% rename from code/controllers/CMSPagesController.php rename to code/Controllers/CMSPagesController.php diff --git a/code/controllers/CMSSettingsController.php b/code/Controllers/CMSSettingsController.php similarity index 100% rename from code/controllers/CMSSettingsController.php rename to code/Controllers/CMSSettingsController.php diff --git a/code/controllers/CMSSiteTreeFilter.php b/code/Controllers/CMSSiteTreeFilter.php similarity index 100% rename from code/controllers/CMSSiteTreeFilter.php rename to code/Controllers/CMSSiteTreeFilter.php diff --git a/code/controllers/ContentController.php b/code/Controllers/ContentController.php similarity index 100% rename from code/controllers/ContentController.php rename to code/Controllers/ContentController.php diff --git a/code/controllers/ErrorPageControllerExtension.php b/code/Controllers/ErrorPageControllerExtension.php similarity index 100% rename from code/controllers/ErrorPageControllerExtension.php rename to code/Controllers/ErrorPageControllerExtension.php diff --git a/code/controllers/ErrorPageFileExtension.php b/code/Controllers/ErrorPageFileExtension.php similarity index 100% rename from code/controllers/ErrorPageFileExtension.php rename to code/Controllers/ErrorPageFileExtension.php diff --git a/code/controllers/LeftAndMainPageIconsExtension.php b/code/Controllers/LeftAndMainPageIconsExtension.php similarity index 100% rename from code/controllers/LeftAndMainPageIconsExtension.php rename to code/Controllers/LeftAndMainPageIconsExtension.php diff --git a/code/controllers/ModelAsController.php b/code/Controllers/ModelAsController.php similarity index 100% rename from code/controllers/ModelAsController.php rename to code/Controllers/ModelAsController.php diff --git a/code/controllers/OldPageRedirector.php b/code/Controllers/OldPageRedirector.php similarity index 100% rename from code/controllers/OldPageRedirector.php rename to code/Controllers/OldPageRedirector.php diff --git a/code/controllers/RootURLController.php b/code/Controllers/RootURLController.php similarity index 100% rename from code/controllers/RootURLController.php rename to code/Controllers/RootURLController.php diff --git a/code/controllers/SilverStripeNavigator.php b/code/Controllers/SilverStripeNavigator.php similarity index 100% rename from code/controllers/SilverStripeNavigator.php rename to code/Controllers/SilverStripeNavigator.php diff --git a/code/forms/SiteTreeURLSegmentField.php b/code/Forms/SiteTreeURLSegmentField.php similarity index 100% rename from code/forms/SiteTreeURLSegmentField.php rename to code/Forms/SiteTreeURLSegmentField.php diff --git a/code/logging/ErrorPageErrorFormatter.php b/code/Logging/ErrorPageErrorFormatter.php similarity index 100% rename from code/logging/ErrorPageErrorFormatter.php rename to code/Logging/ErrorPageErrorFormatter.php diff --git a/code/model/CurrentPageIdentifier.php b/code/Model/CurrentPageIdentifier.php similarity index 100% rename from code/model/CurrentPageIdentifier.php rename to code/Model/CurrentPageIdentifier.php diff --git a/code/model/ErrorPage.php b/code/Model/ErrorPage.php similarity index 100% rename from code/model/ErrorPage.php rename to code/Model/ErrorPage.php diff --git a/code/model/RedirectorPage.php b/code/Model/RedirectorPage.php similarity index 100% rename from code/model/RedirectorPage.php rename to code/Model/RedirectorPage.php diff --git a/code/model/SiteTree.php b/code/Model/SiteTree.php similarity index 100% rename from code/model/SiteTree.php rename to code/Model/SiteTree.php diff --git a/code/model/SiteTreeExtension.php b/code/Model/SiteTreeExtension.php similarity index 100% rename from code/model/SiteTreeExtension.php rename to code/Model/SiteTreeExtension.php diff --git a/code/model/SiteTreeFileExtension.php b/code/Model/SiteTreeFileExtension.php similarity index 100% rename from code/model/SiteTreeFileExtension.php rename to code/Model/SiteTreeFileExtension.php diff --git a/code/model/SiteTreeFolderExtension.php b/code/Model/SiteTreeFolderExtension.php similarity index 100% rename from code/model/SiteTreeFolderExtension.php rename to code/Model/SiteTreeFolderExtension.php diff --git a/code/model/SiteTreeLinkTracking.php b/code/Model/SiteTreeLinkTracking.php similarity index 100% rename from code/model/SiteTreeLinkTracking.php rename to code/Model/SiteTreeLinkTracking.php diff --git a/code/model/VirtualPage.php b/code/Model/VirtualPage.php similarity index 100% rename from code/model/VirtualPage.php rename to code/Model/VirtualPage.php diff --git a/code/reports/BrokenFilesReport.php b/code/Reports/BrokenFilesReport.php similarity index 100% rename from code/reports/BrokenFilesReport.php rename to code/Reports/BrokenFilesReport.php diff --git a/code/reports/BrokenLinksReport.php b/code/Reports/BrokenLinksReport.php similarity index 100% rename from code/reports/BrokenLinksReport.php rename to code/Reports/BrokenLinksReport.php diff --git a/code/reports/BrokenRedirectorPagesReport.php b/code/Reports/BrokenRedirectorPagesReport.php similarity index 100% rename from code/reports/BrokenRedirectorPagesReport.php rename to code/Reports/BrokenRedirectorPagesReport.php diff --git a/code/reports/BrokenVirtualPagesReport.php b/code/Reports/BrokenVirtualPagesReport.php similarity index 100% rename from code/reports/BrokenVirtualPagesReport.php rename to code/Reports/BrokenVirtualPagesReport.php diff --git a/code/reports/EmptyPagesReport.php b/code/Reports/EmptyPagesReport.php similarity index 100% rename from code/reports/EmptyPagesReport.php rename to code/Reports/EmptyPagesReport.php diff --git a/code/reports/RecentlyEditedReport.php b/code/Reports/RecentlyEditedReport.php similarity index 100% rename from code/reports/RecentlyEditedReport.php rename to code/Reports/RecentlyEditedReport.php diff --git a/code/search/ContentControllerSearchExtension.php b/code/Search/ContentControllerSearchExtension.php similarity index 100% rename from code/search/ContentControllerSearchExtension.php rename to code/Search/ContentControllerSearchExtension.php diff --git a/code/search/SearchForm.php b/code/Search/SearchForm.php similarity index 100% rename from code/search/SearchForm.php rename to code/Search/SearchForm.php diff --git a/tasks/MigrateSiteTreeLinkingTask.php b/code/Tasks/MigrateSiteTreeLinkingTask.php similarity index 100% rename from tasks/MigrateSiteTreeLinkingTask.php rename to code/Tasks/MigrateSiteTreeLinkingTask.php diff --git a/tasks/RemoveOrphanedPagesTask.php b/code/Tasks/RemoveOrphanedPagesTask.php similarity index 100% rename from tasks/RemoveOrphanedPagesTask.php rename to code/Tasks/RemoveOrphanedPagesTask.php diff --git a/tasks/SiteTreeMaintenanceTask.php b/code/Tasks/SiteTreeMaintenanceTask.php similarity index 100% rename from tasks/SiteTreeMaintenanceTask.php rename to code/Tasks/SiteTreeMaintenanceTask.php diff --git a/templates/Includes/AssetAdmin_Content.ss b/templates/SilverStripe/CMS/Controllers/AssetAdmin_Content.ss similarity index 100% rename from templates/Includes/AssetAdmin_Content.ss rename to templates/SilverStripe/CMS/Controllers/AssetAdmin_Content.ss diff --git a/templates/Includes/AssetAdmin_EditForm.ss b/templates/SilverStripe/CMS/Controllers/AssetAdmin_EditForm.ss similarity index 100% rename from templates/Includes/AssetAdmin_EditForm.ss rename to templates/SilverStripe/CMS/Controllers/AssetAdmin_EditForm.ss diff --git a/templates/Includes/AssetAdmin_Tools.ss b/templates/SilverStripe/CMS/Controllers/AssetAdmin_Tools.ss similarity index 100% rename from templates/Includes/AssetAdmin_Tools.ss rename to templates/SilverStripe/CMS/Controllers/AssetAdmin_Tools.ss diff --git a/templates/Includes/AssetAdmin_UploadContent.ss b/templates/SilverStripe/CMS/Controllers/AssetAdmin_UploadContent.ss similarity index 100% rename from templates/Includes/AssetAdmin_UploadContent.ss rename to templates/SilverStripe/CMS/Controllers/AssetAdmin_UploadContent.ss diff --git a/templates/Includes/CMSMain_Content.ss b/templates/SilverStripe/CMS/Controllers/CMSMain_Content.ss similarity index 100% rename from templates/Includes/CMSMain_Content.ss rename to templates/SilverStripe/CMS/Controllers/CMSMain_Content.ss diff --git a/templates/Includes/CMSMain_EditForm.ss b/templates/SilverStripe/CMS/Controllers/CMSMain_EditForm.ss similarity index 100% rename from templates/Includes/CMSMain_EditForm.ss rename to templates/SilverStripe/CMS/Controllers/CMSMain_EditForm.ss diff --git a/templates/Includes/CMSMain_ListView.ss b/templates/SilverStripe/CMS/Controllers/CMSMain_ListView.ss similarity index 88% rename from templates/Includes/CMSMain_ListView.ss rename to templates/SilverStripe/CMS/Controllers/CMSMain_ListView.ss index 94ca14f8..e9c6f3a7 100644 --- a/templates/Includes/CMSMain_ListView.ss +++ b/templates/SilverStripe/CMS/Controllers/CMSMain_ListView.ss @@ -1,4 +1,4 @@ -<% include CMSPagesController_ContentToolActions %> +<% include SilverStripe\CMS\Controllers\CMSPagesController_ContentToolActions %>
$AddForm @@ -14,7 +14,7 @@
$ListViewForm -
+
<% else %> diff --git a/templates/Includes/CMSMain_Tools.ss b/templates/SilverStripe/CMS/Controllers/CMSMain_Tools.ss similarity index 100% rename from templates/Includes/CMSMain_Tools.ss rename to templates/SilverStripe/CMS/Controllers/CMSMain_Tools.ss diff --git a/templates/Includes/CMSMain_TreeView.ss b/templates/SilverStripe/CMS/Controllers/CMSMain_TreeView.ss similarity index 95% rename from templates/Includes/CMSMain_TreeView.ss rename to templates/SilverStripe/CMS/Controllers/CMSMain_TreeView.ss index 17a3bb4c..c9eca6dd 100644 --- a/templates/Includes/CMSMain_TreeView.ss +++ b/templates/SilverStripe/CMS/Controllers/CMSMain_TreeView.ss @@ -1,4 +1,4 @@ -<% include CMSPagesController_ContentToolActions View='Tree' %> +<% include SilverStripe\CMS\Controllers\CMSPagesController_ContentToolActions View='Tree' %>
$AddForm diff --git a/templates/Includes/CMSPageAddController_Content.ss b/templates/SilverStripe/CMS/Controllers/CMSPageAddController_Content.ss similarity index 100% rename from templates/Includes/CMSPageAddController_Content.ss rename to templates/SilverStripe/CMS/Controllers/CMSPageAddController_Content.ss diff --git a/templates/Includes/CMSPageHistoryController_Tools.ss b/templates/SilverStripe/CMS/Controllers/CMSPageHistoryController_Tools.ss similarity index 100% rename from templates/Includes/CMSPageHistoryController_Tools.ss rename to templates/SilverStripe/CMS/Controllers/CMSPageHistoryController_Tools.ss diff --git a/templates/CMSPageHistoryController_versions.ss b/templates/SilverStripe/CMS/Controllers/CMSPageHistoryController_versions.ss similarity index 100% rename from templates/CMSPageHistoryController_versions.ss rename to templates/SilverStripe/CMS/Controllers/CMSPageHistoryController_versions.ss diff --git a/templates/Includes/CMSPagesController_Content.ss b/templates/SilverStripe/CMS/Controllers/CMSPagesController_Content.ss similarity index 100% rename from templates/Includes/CMSPagesController_Content.ss rename to templates/SilverStripe/CMS/Controllers/CMSPagesController_Content.ss diff --git a/templates/Includes/CMSPagesController_Tools.ss b/templates/SilverStripe/CMS/Controllers/CMSPagesController_Tools.ss similarity index 100% rename from templates/Includes/CMSPagesController_Tools.ss rename to templates/SilverStripe/CMS/Controllers/CMSPagesController_Tools.ss diff --git a/templates/Includes/CMSPagesController_ContentToolActions.ss b/templates/SilverStripe/CMS/Controllers/Includes/CMSPagesController_ContentToolActions.ss similarity index 100% rename from templates/Includes/CMSPagesController_ContentToolActions.ss rename to templates/SilverStripe/CMS/Controllers/Includes/CMSPagesController_ContentToolActions.ss diff --git a/templates/forms/SiteTreeURLSegmentField.ss b/templates/forms/SilverStripe/CMS/Forms/SiteTreeURLSegmentField.ss similarity index 57% rename from templates/forms/SiteTreeURLSegmentField.ss rename to templates/forms/SilverStripe/CMS/Forms/SiteTreeURLSegmentField.ss index a88afe11..26eba8b1 100644 --- a/templates/forms/SiteTreeURLSegmentField.ss +++ b/templates/forms/SilverStripe/CMS/Forms/SiteTreeURLSegmentField.ss @@ -3,17 +3,17 @@ $URL <% if not $IsReadonly %> - <% end_if %>
- - <% if $HelpText %>

$HelpText

<% end_if %> From 5bf364bedb351582344d9c13966bd9e5a77ae19e Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Fri, 22 Jul 2016 11:32:32 +1200 Subject: [PATCH 2/3] Apply SilverStripe\CMS namespace --- .upgrade.yml | 67 ++++++++++ _config.php | 14 +- _config/cmslogging.yml | 2 +- code/BatchActions/CMSBatchActions.php | 7 +- code/Controllers/AssetAdmin.php | 51 +++++++- code/Controllers/CMSMain.php | 122 ++++++++++++------ code/Controllers/CMSPageAddController.php | 26 +++- code/Controllers/CMSPageEditController.php | 4 +- code/Controllers/CMSPageHistoryController.php | 18 ++- .../Controllers/CMSPageSettingsController.php | 4 +- code/Controllers/CMSPagesController.php | 11 +- code/Controllers/CMSSettingsController.php | 4 + code/Controllers/CMSSiteTreeFilter.php | 26 ++-- code/Controllers/ContentController.php | 28 +++- .../ErrorPageControllerExtension.php | 9 ++ code/Controllers/ErrorPageFileExtension.php | 5 + .../LeftAndMainPageIconsExtension.php | 10 +- code/Controllers/ModelAsController.php | 33 +++-- code/Controllers/OldPageRedirector.php | 11 ++ code/Controllers/RootURLController.php | 23 +++- code/Controllers/SilverStripeNavigator.php | 15 ++- code/Forms/SiteTreeURLSegmentField.php | 8 +- code/Logging/ErrorPageErrorFormatter.php | 6 +- code/Model/CurrentPageIdentifier.php | 2 + code/Model/ErrorPage.php | 16 ++- code/Model/RedirectorPage.php | 17 ++- code/Model/SiteTree.php | 116 +++++++++++------ code/Model/SiteTreeExtension.php | 3 + code/Model/SiteTreeFileExtension.php | 8 +- code/Model/SiteTreeFolderExtension.php | 5 +- code/Model/SiteTreeLinkTracking.php | 11 +- code/Model/VirtualPage.php | 24 +++- code/Reports/BrokenFilesReport.php | 23 ++-- code/Reports/BrokenLinksReport.php | 28 ++-- code/Reports/BrokenRedirectorPagesReport.php | 21 ++- code/Reports/BrokenVirtualPagesReport.php | 20 ++- code/Reports/EmptyPagesReport.php | 16 +-- code/Reports/RecentlyEditedReport.php | 15 +-- .../ContentControllerSearchExtension.php | 9 +- code/Search/SearchForm.php | 23 +++- code/Tasks/MigrateSiteTreeLinkingTask.php | 4 +- code/Tasks/RemoveOrphanedPagesTask.php | 6 +- code/Tasks/SiteTreeMaintenanceTask.php | 2 +- .../features/bootstrap/FeatureContext.php | 2 +- .../Cms/Test/Behaviour/FixtureContext.php | 2 +- tests/controller/AssetAdminTest.php | 2 + tests/controller/CMSBatchActionsTest.php | 74 ++++++----- tests/controller/CMSMainTest.php | 23 ++-- .../CMSPageHistoryControllerTest.php | 2 + tests/controller/CMSSiteTreeFilterTest.php | 15 ++- .../ContentControllerSearchExtensionTest.php | 4 +- tests/controller/ContentControllerTest.php | 10 +- tests/controller/ModelAsControllerTest.php | 8 +- tests/controller/RootURLControllerTest.php | 5 +- .../controller/SilverStripeNavigatorTest.php | 5 +- tests/model/ErrorPageFileExtensionTest.php | 4 +- tests/model/ErrorPageTest.php | 14 +- tests/model/FileLinkTrackingTest.php | 6 +- tests/model/RedirectorPageTest.php | 21 +-- tests/model/SiteTreeActionsTest.php | 8 +- tests/model/SiteTreeBrokenLinksTest.php | 47 +++---- tests/model/SiteTreeHTMLEditorFieldTest.php | 14 +- tests/model/SiteTreeLinkTrackingTest.php | 2 + tests/model/SiteTreePermissionsTest.php | 8 +- tests/model/SiteTreeTest.php | 93 ++++++------- tests/model/VirtualPageTest.php | 58 +++++---- tests/reports/CmsReportsTest.php | 16 ++- tests/search/CMSMainSearchFormTest.php | 2 +- tests/search/SearchFormTest.php | 43 +++--- .../tasks/MigrateSiteTreeLinkingTaskTest.php | 20 +-- 70 files changed, 922 insertions(+), 459 deletions(-) create mode 100644 .upgrade.yml diff --git a/.upgrade.yml b/.upgrade.yml new file mode 100644 index 00000000..c021018b --- /dev/null +++ b/.upgrade.yml @@ -0,0 +1,67 @@ +mappings: + CMSBatchAction_Publish: SilverStripe\CMS\BatchActions\CMSBatchAction_Publish + CMSBatchAction_Unpublish: SilverStripe\CMS\BatchActions\CMSBatchAction_Unpublish + CMSBatchAction_Archive: SilverStripe\CMS\BatchActions\CMSBatchAction_Archive + CMSBatchAction_Restore: SilverStripe\CMS\BatchActions\CMSBatchAction_Restore + CMSBatchAction_Delete: SilverStripe\CMS\BatchActions\CMSBatchAction_Delete + AssetAdmin: SilverStripe\CMS\Controllers\AssetAdmin + AssetAdmin_DeleteBatchAction: SilverStripe\CMS\Controllers\AssetAdmin_DeleteBatchAction + CMSMain: SilverStripe\CMS\Controllers\CMSMain + CMSPageAddController: SilverStripe\CMS\Controllers\CMSPageAddController + CMSPageEditController: SilverStripe\CMS\Controllers\CMSPageEditController + CMSPageHistoryController: SilverStripe\CMS\Controllers\CMSPageHistoryController + CMSPagesController: SilverStripe\CMS\Controllers\CMSPagesController + CMSPageSettingsController: SilverStripe\CMS\Controllers\CMSPageSettingsController + CMSSettingsController: SilverStripe\CMS\Controllers\CMSSettingsController + CMSSiteTreeFilter: SilverStripe\CMS\Controllers\CMSSiteTreeFilter + CMSSiteTreeFilter_PublishedPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_PublishedPages + CMSSiteTreeFilter_DeletedPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_DeletedPages + CMSSiteTreeFilter_ChangedPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_ChangedPages + CMSSiteTreeFilter_StatusRemovedFromDraftPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusRemovedFromDraftPages + CMSSiteTreeFilter_StatusDraftPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusDraftPages + CMSSiteTreeFilter_StatusDeletedPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusDeletedPages + CMSSiteTreeFilter_Search: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_Search + ContentController: SilverStripe\CMS\Controllers\ContentController + ErrorPageControllerExtension: SilverStripe\CMS\Controllers\ErrorPageControllerExtension + ErrorPageFileExtension: SilverStripe\CMS\Controllers\ErrorPageFileExtension + LeftAndMainPageIconsExtension: SilverStripe\CMS\Controllers\LeftAndMainPageIconsExtension + ModelAsController: SilverStripe\CMS\Controllers\ModelAsController + NestedController: SilverStripe\CMS\Controllers\NestedController + OldPageRedirector: SilverStripe\CMS\Controllers\OldPageRedirector + RootURLController: SilverStripe\CMS\Controllers\RootURLController + SilverStripeNavigator: SilverStripe\CMS\Controllers\SilverStripeNavigator + SilverStripeNavigatorItem: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem + SilverStripeNavigatorItem_CMSLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_CMSLink + SilverStripeNavigatorItem_StageLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_StageLink + SilverStripeNavigatorItem_LiveLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_LiveLink + SilverStripeNavigatorItem_ArchiveLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_ArchiveLink + Folder_UnusedAssetsField: SilverStripe\CMS\Forms\Folder_UnusedAssetsField + SiteTreeURLSegmentField: SilverStripe\CMS\Forms\SiteTreeURLSegmentField + SiteTreeURLSegmentField_Readonly: SilverStripe\CMS\Forms\SiteTreeURLSegmentField_Readonly + CurrentPageIdentifier: SilverStripe\CMS\Model\CurrentPageIdentifier + ErrorPage: SilverStripe\CMS\Model\ErrorPage + ErrorPage_Controller: SilverStripe\CMS\Model\ErrorPage_Controller + RedirectorPage: SilverStripe\CMS\Model\RedirectorPage + RedirectorPage_Controller: SilverStripe\CMS\Model\RedirectorPage_Controller + SiteTree: SilverStripe\CMS\Model\SiteTree + SiteTreeExtension: SilverStripe\CMS\Model\SiteTreeExtension + SiteTreeFileExtension: SilverStripe\CMS\Model\SiteTreeFileExtension + SiteTreeFolderExtension: SilverStripe\CMS\Model\SiteTreeFolderExtension + SiteTreeLinkTracking: SilverStripe\CMS\Model\SiteTreeLinkTracking + SiteTreeLinkTracking_Parser: SilverStripe\CMS\Model\SiteTreeLinkTracking_Parser + VirtualPage: SilverStripe\CMS\Model\VirtualPage + VirtualPage_Controller: SilverStripe\CMS\Model\VirtualPage_Controller + BrokenFilesReport: SilverStripe\CMS\Reports\BrokenFilesReport + SideReport_BrokenFiles: SilverStripe\CMS\Reports\SideReport_BrokenFiles + BrokenLinksReport: SilverStripe\CMS\Reports\BrokenLinksReport + SideReport_BrokenLinks: SilverStripe\CMS\Reports\SideReport_BrokenLinks + BrokenRedirectorPagesReport: SilverStripe\CMS\Reports\BrokenRedirectorPagesReport + SideReport_BrokenRedirectorPages: SilverStripe\CMS\Reports\SideReport_BrokenRedirectorPages + BrokenVirtualPagesReport: SilverStripe\CMS\Reports\BrokenVirtualPagesReport + SideReport_BrokenVirtualPages: SilverStripe\CMS\Reports\SideReport_BrokenVirtualPages + EmptyPagesReport: SilverStripe\CMS\Reports\EmptyPagesReport + SideReport_EmptyPages: SilverStripe\CMS\Reports\SideReport_EmptyPages + RecentlyEditedReport: SilverStripe\CMS\Reports\RecentlyEditedReport + SideReport_RecentlyEdited: SilverStripe\CMS\Reports\SideReport_RecentlyEdited + ContentControllerSearchExtension: SilverStripe\CMS\Search\ContentControllerSearchExtension + SearchForm: SilverStripe\CMS\Search\SearchForm diff --git a/_config.php b/_config.php index e5201d8a..23521d22 100644 --- a/_config.php +++ b/_config.php @@ -10,16 +10,16 @@ define('CMS_PATH', BASE_PATH . '/' . CMS_DIR); /** * Register the default internal shortcodes. */ -ShortcodeParser::get('default')->register('sitetree_link', array('SiteTree', 'link_shortcode_handler')); +ShortcodeParser::get('default')->register('sitetree_link', array('SilverStripe\\CMS\\Model\\SiteTree', 'link_shortcode_handler')); -File::add_extension('SiteTreeFileExtension'); +File::add_extension('SilverStripe\\CMS\\Model\\SiteTreeFileExtension'); // TODO Remove once we can configure CMSMenu through static, nested configuration files -CMSMenu::remove_menu_item('CMSMain'); -CMSMenu::remove_menu_item('CMSPageEditController'); -CMSMenu::remove_menu_item('CMSPageSettingsController'); -CMSMenu::remove_menu_item('CMSPageHistoryController'); +CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSMain'); +CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSPageEditController'); +CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSPageSettingsController'); +CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController'); CMSMenu::remove_menu_item('CMSPageReportsController'); -CMSMenu::remove_menu_item('CMSPageAddController'); +CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSPageAddController'); CMSMenu::remove_menu_item("SiteConfigLeftAndMain"); diff --git a/_config/cmslogging.yml b/_config/cmslogging.yml index 958f17f6..2e9ef01a 100644 --- a/_config/cmslogging.yml +++ b/_config/cmslogging.yml @@ -6,4 +6,4 @@ Except: --- Injector: FriendlyErrorFormatter: - class: SilverStripe\Cms\Logging\ErrorPageErrorFormatter + class: SilverStripe\CMS\Logging\ErrorPageErrorFormatter diff --git a/code/BatchActions/CMSBatchActions.php b/code/BatchActions/CMSBatchActions.php index 1ae73625..5dba652f 100644 --- a/code/BatchActions/CMSBatchActions.php +++ b/code/BatchActions/CMSBatchActions.php @@ -1,9 +1,14 @@ $id )); if($liveRecord) { diff --git a/code/Controllers/AssetAdmin.php b/code/Controllers/AssetAdmin.php index adee40ff..6720c1f2 100644 --- a/code/Controllers/AssetAdmin.php +++ b/code/Controllers/AssetAdmin.php @@ -1,5 +1,7 @@ removeExtraClass('cms-previewable'); - $form->Fields()->removeByName('SilverStripeNavigator'); + $form->Fields()->removeByName('SilverStripe\\CMS\\Controllers\\SilverStripeNavigator'); // File listing $gridFieldConfig = GridFieldConfig::create()->addComponents( @@ -588,7 +633,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{ // The root element should explicitly point to the root node. // Uses session state for current record otherwise. - $items[0]->Link = Controller::join_links(singleton('AssetAdmin')->Link('show'), 0); + $items[0]->Link = Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\AssetAdmin')->Link('show'), 0); // If a search is in progress, don't show the path if($this->getRequest()->requestVar('q')) { diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php index 801a25e3..b40a8f1b 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -1,5 +1,7 @@ getRequest()->isAjax()) { - Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SiteTree'))); + Translatable::choose_site_locale(array_keys(Translatable::get_existing_content_languages('SilverStripe\\CMS\\Model\\SiteTree'))); } parent::init(); @@ -109,11 +157,11 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr ] ]); - CMSBatchActionHandler::register('publish', 'CMSBatchAction_Publish'); - CMSBatchActionHandler::register('unpublish', 'CMSBatchAction_Unpublish'); - CMSBatchActionHandler::register('delete', 'CMSBatchAction_Delete'); - CMSBatchActionHandler::register('archive', 'CMSBatchAction_Archive'); - CMSBatchActionHandler::register('restore', 'CMSBatchAction_Restore'); + CMSBatchActionHandler::register('publish', 'SilverStripe\\CMS\\BatchActions\\CMSBatchAction_Publish'); + CMSBatchActionHandler::register('unpublish', 'SilverStripe\\CMS\\BatchActions\\CMSBatchAction_Unpublish'); + CMSBatchActionHandler::register('delete', 'SilverStripe\\CMS\\BatchActions\\CMSBatchAction_Delete'); + CMSBatchActionHandler::register('archive', 'SilverStripe\\CMS\\BatchActions\\CMSBatchAction_Archive'); + CMSBatchActionHandler::register('restore', 'SilverStripe\\CMS\\BatchActions\\CMSBatchAction_Restore'); } public function index($request) { @@ -182,7 +230,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } public function LinkPages() { - return singleton('CMSPagesController')->Link(); + return singleton('SilverStripe\\CMS\\Controllers\\CMSPagesController')->Link(); } public function LinkPagesWithSearch() { @@ -190,28 +238,28 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } public function LinkTreeView() { - return $this->LinkWithSearch(singleton('CMSMain')->Link('treeview')); + return $this->LinkWithSearch(singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->Link('treeview')); } public function LinkListView() { - return $this->LinkWithSearch(singleton('CMSMain')->Link('listview')); + return $this->LinkWithSearch(singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->Link('listview')); } public function LinkGalleryView() { - return $this->LinkWithSearch(singleton('CMSMain')->Link('galleryview')); + return $this->LinkWithSearch(singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->Link('galleryview')); } public function LinkPageEdit($id = null) { if(!$id) $id = $this->currentPageID(); return $this->LinkWithSearch( - Controller::join_links(singleton('CMSPageEditController')->Link('show'), $id) + Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'), $id) ); } public function LinkPageSettings() { if($id = $this->currentPageID()) { return $this->LinkWithSearch( - Controller::join_links(singleton('CMSPageSettingsController')->Link('show'), $id) + Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageSettingsController')->Link('show'), $id) ); } } @@ -219,7 +267,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr public function LinkPageHistory() { if($id = $this->currentPageID()) { return $this->LinkWithSearch( - Controller::join_links(singleton('CMSPageHistoryController')->Link('show'), $id) + Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController')->Link('show'), $id) ); } } @@ -239,7 +287,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } public function LinkPageAdd($extra = null, $placeholders = null) { - $link = singleton("CMSPageAddController")->Link(); + $link = singleton("SilverStripe\\CMS\\Controllers\\CMSPageAddController")->Link(); $this->extend('updateLinkPageAdd', $link); if($extra) { @@ -276,8 +324,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr */ public function SiteTreeAsUL() { // Pre-cache sitetree version numbers for querying efficiency - Versioned::prepopulate_versionnumber_cache("SiteTree", "Stage"); - Versioned::prepopulate_versionnumber_cache("SiteTree", "Live"); + Versioned::prepopulate_versionnumber_cache("SilverStripe\\CMS\\Model\\SiteTree", "Stage"); + Versioned::prepopulate_versionnumber_cache("SilverStripe\\CMS\\Model\\SiteTree", "Live"); $html = $this->getSiteTreeFor($this->stat('tree_class')); $this->extend('updateSiteTreeAsUL', $html); @@ -291,7 +339,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr public function TreeIsFiltered() { $query = $this->getRequest()->getVar('q'); - if (!$query || (count($query) === 1 && isset($query['FilterClass']) && $query['FilterClass'] === 'CMSSiteTreeFilter_Search')) { + if (!$query || (count($query) === 1 && isset($query['FilterClass']) && $query['FilterClass'] === 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter_Search')) { return false; } @@ -364,7 +412,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } // Create the form - $form = Form::create($this, 'SearchForm', $fields, $actions) + $form = Form::create($this, 'SilverStripe\\CMS\\Search\\SearchForm', $fields, $actions) ->addExtraClass('cms-search-form') ->setFormMethod('GET') ->setFormAction($this->Link()) @@ -504,14 +552,14 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr $addAction = $instance->i18n_singular_name(); // Get description (convert 'Page' to 'SiteTree' for correct localization lookups) - $description = _t((($class == 'Page') ? 'SiteTree' : $class) . '.DESCRIPTION'); + $description = _t((($class == 'Page') ? 'SilverStripe\\CMS\\Model\\SiteTree' : $class) . '.DESCRIPTION'); if(!$description) { $description = $instance->uninherited('description'); } if($class == 'Page' && !$description) { - $description = singleton('SiteTree')->uninherited('description'); + $description = singleton('SilverStripe\\CMS\\Model\\SiteTree')->uninherited('description'); } $result->push(new ArrayData(array( @@ -626,8 +674,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } // Added in-line to the form, but plucked into different view by LeftAndMain.Preview.js upon load - if($record instanceof CMSPreviewable && !$fields->fieldByName('SilverStripeNavigator')) { - $navField = new LiteralField('SilverStripeNavigator', $this->getSilverStripeNavigator()); + if($record instanceof CMSPreviewable && !$fields->fieldByName('SilverStripe\\CMS\\Controllers\\SilverStripeNavigator')) { + $navField = new LiteralField('SilverStripe\\CMS\\Controllers\\SilverStripeNavigator', $this->getSilverStripeNavigator()); $navField->setAllowHTML(true); $fields->push($navField); } @@ -747,7 +795,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr protected function getQueryFilter($params) { if(empty($params['FilterClass'])) return null; $filterClass = $params['FilterClass']; - if(!is_subclass_of($filterClass, 'CMSSiteTreeFilter')) { + if(!is_subclass_of($filterClass, 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter')) { throw new InvalidArgumentException("Invalid filter class passed: {$filterClass}"); } return $filterClass::create($params); @@ -830,7 +878,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr return sprintf( '%s', Controller::join_links( - singleton('CMSPageEditController')->Link('show'), + singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'), (int)$item->ID ), $item->TreeTitle // returns HTML, does its own escaping @@ -1039,13 +1087,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } $id = (int) $data['ID']; - $restoredPage = Versioned::get_latest_version("SiteTree", $id); + $restoredPage = Versioned::get_latest_version("SilverStripe\\CMS\\Model\\SiteTree", $id); if(!$restoredPage) { throw new SS_HTTPResponse_Exception("SiteTree #$id not found", 400); } /** @var SiteTree $record */ - $record = Versioned::get_one_by_stage('SiteTree', 'Live', array( + $record = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', array( '"SiteTree_Live"."ID"' => $id )); @@ -1085,7 +1133,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr */ public function delete($data, $form) { $id = $data['ID']; - $record = DataObject::get_by_id("SiteTree", $id); + $record = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $id); if($record && !$record->canDelete()) { return Security::permissionFailure(); } @@ -1116,7 +1164,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr public function archive($data, $form) { $id = $data['ID']; /** @var SiteTree $record */ - $record = DataObject::get_by_id("SiteTree", $id); + $record = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $id); if(!$record || !$record->exists()) { throw new SS_HTTPResponse_Exception("Bad record ID #$id", 404); } @@ -1212,7 +1260,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr // Can be used in different contexts: In normal page edit view, in which case the redirect won't have any effect. // Or in history view, in which case a revert causes the CMS to re-load the edit view. // The X-Pjax header forces a "full" content refresh on redirect. - $url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $record->ID); + $url = Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'), $record->ID); $this->getResponse()->addHeader('X-ControllerURL', $url); $this->getRequest()->addHeader('X-Pjax', 'Content'); $this->getResponse()->addHeader('X-Pjax', 'Content'); @@ -1279,7 +1327,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr if(!SecurityToken::inst()->checkRequest($request)) return $this->httpError(400); $start = 0; - $pages = DataObject::get("SiteTree", "", "", "", "$start,30"); + $pages = DataObject::get("SilverStripe\\CMS\\Model\\SiteTree", "", "", "", "$start,30"); $count = 0; while($pages) { foreach($pages as $page) { @@ -1295,7 +1343,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } if($pages->Count() > 29) { $start += 30; - $pages = DataObject::get("SiteTree", "", "", "", "$start,30"); + $pages = DataObject::get("SilverStripe\\CMS\\Model\\SiteTree", "", "", "", "$start,30"); } else { break; } @@ -1331,7 +1379,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } $id = (int)$data['ID']; - $restoredPage = Versioned::get_latest_version("SiteTree", $id); + $restoredPage = Versioned::get_latest_version("SilverStripe\\CMS\\Model\\SiteTree", $id); if(!$restoredPage) return new SS_HTTPResponse("SiteTree #$id not found", 400); $restoredPage = $restoredPage->doRestoreToStage(); @@ -1353,7 +1401,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr if(!SecurityToken::inst()->checkRequest($request)) return $this->httpError(400); if(($id = $this->urlParams['ID']) && is_numeric($id)) { - $page = DataObject::get_by_id("SiteTree", $id); + $page = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $id); if($page && (!$page->canEdit() || !$page->canCreate(null, array('Parent' => $page->Parent())))) { return Security::permissionFailure($this); } @@ -1375,7 +1423,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr array('title' => $newPage->Title) )) ); - $url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $newPage->ID); + $url = Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'), $newPage->ID); $this->getResponse()->addHeader('X-ControllerURL', $url); $this->getRequest()->addHeader('X-Pjax', 'Content'); $this->getResponse()->addHeader('X-Pjax', 'Content'); @@ -1391,7 +1439,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr if(!SecurityToken::inst()->checkRequest($request)) return $this->httpError(400); increase_time_limit_to(); if(($id = $this->urlParams['ID']) && is_numeric($id)) { - $page = DataObject::get_by_id("SiteTree", $id); + $page = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $id); if($page && (!$page->canEdit() || !$page->canCreate(null, array('Parent' => $page->Parent())))) { return Security::permissionFailure($this); } @@ -1407,7 +1455,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr array('title' => $newPage->Title) )) ); - $url = Controller::join_links(singleton('CMSPageEditController')->Link('show'), $newPage->ID); + $url = Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'), $newPage->ID); $this->getResponse()->addHeader('X-ControllerURL', $url); $this->getRequest()->addHeader('X-Pjax', 'Content'); $this->getResponse()->addHeader('X-Pjax', 'Content'); diff --git a/code/Controllers/CMSPageAddController.php b/code/Controllers/CMSPageAddController.php index 31d6d037..6248aa8c 100644 --- a/code/Controllers/CMSPageAddController.php +++ b/code/Controllers/CMSPageAddController.php @@ -1,10 +1,26 @@ ID; } - if(is_numeric($parentID) && $parentID > 0) $parentObj = DataObject::get_by_id("SiteTree", $parentID); + if(is_numeric($parentID) && $parentID > 0) $parentObj = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $parentID); else $parentObj = null; if(!$parentObj || !$parentObj->ID) $parentID = 0; @@ -181,7 +197,7 @@ class CMSPageAddController extends CMSPageEditController { return $this->getResponseNegotiator()->respond($this->getRequest()); } - $editController = singleton('CMSPageEditController'); + $editController = singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController'); $editController->setCurrentPageID($record->ID); Session::set( @@ -190,11 +206,11 @@ class CMSPageAddController extends CMSPageEditController { ); Session::set("FormInfo.Form_EditForm.formError.type", 'good'); - return $this->redirect(Controller::join_links(singleton('CMSPageEditController')->Link('show'), $record->ID)); + return $this->redirect(Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'), $record->ID)); } public function doCancel($data, $form) { - return $this->redirect(singleton('CMSMain')->Link()); + return $this->redirect(singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->Link()); } } diff --git a/code/Controllers/CMSPageEditController.php b/code/Controllers/CMSPageEditController.php index 1bbf826a..822ce56d 100644 --- a/code/Controllers/CMSPageEditController.php +++ b/code/Controllers/CMSPageEditController.php @@ -1,5 +1,7 @@ currentPageID(); - $page = DataObject::get_by_id("SiteTree", $id); + $page = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $id); if($page && $page->exists()) { if(!$page->canView()) { @@ -388,8 +398,8 @@ class CMSPageHistoryController extends CMSMain { $record = $page->compareVersions($fromVersion, $toVersion); } - $fromVersionRecord = Versioned::get_version('SiteTree', $id, $fromVersion); - $toVersionRecord = Versioned::get_version('SiteTree', $id, $toVersion); + $fromVersionRecord = Versioned::get_version('SilverStripe\\CMS\\Model\\SiteTree', $id, $fromVersion); + $toVersionRecord = Versioned::get_version('SilverStripe\\CMS\\Model\\SiteTree', $id, $toVersion); if(!$fromVersionRecord) { user_error("Can't find version $fromVersion of page $id", E_USER_ERROR); diff --git a/code/Controllers/CMSPageSettingsController.php b/code/Controllers/CMSPageSettingsController.php index fbbe0b33..c53c78e6 100644 --- a/code/Controllers/CMSPageSettingsController.php +++ b/code/Controllers/CMSPageSettingsController.php @@ -1,5 +1,7 @@ getRecord($id ?: $this->currentPageID()); diff --git a/code/Controllers/CMSPagesController.php b/code/Controllers/CMSPagesController.php index 2e7c29d8..2eba81ad 100644 --- a/code/Controllers/CMSPagesController.php +++ b/code/Controllers/CMSPagesController.php @@ -1,6 +1,11 @@ getRequest()->getVar('ParentID')) { - $page = DataObject::get_by_id('SiteTree', $parentID); + $page = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $parentID); //build a reversed list of the parent tree $pages = array(); @@ -50,7 +55,7 @@ class CMSPagesController extends CMSMain { )); foreach($pages as $page) { $params['ParentID'] = $page->ID; - $item = new StdClass(); + $item = new stdClass(); $item->Title = $page->Title; $item->Link = Controller::join_links($this->Link(), '?' . http_build_query($params)); $items->push(new ArrayData($item)); diff --git a/code/Controllers/CMSSettingsController.php b/code/Controllers/CMSSettingsController.php index 1ef33a72..9b6886a7 100644 --- a/code/Controllers/CMSSettingsController.php +++ b/code/Controllers/CMSSettingsController.php @@ -1,5 +1,9 @@ map('ID', 'ParentID'); $parents = array(); foreach($list as $id => $parentID) { @@ -171,7 +177,7 @@ abstract class CMSSiteTreeFilter extends Object implements LeftAndMain_SearchFil * @return DataList Filtered query */ protected function applyDefaultFilters($query) { - $sng = singleton('SiteTree'); + $sng = singleton('SilverStripe\\CMS\\Model\\SiteTree'); foreach($this->params as $name => $val) { if(empty($val)) continue; @@ -262,7 +268,7 @@ class CMSSiteTreeFilter_PublishedPages extends CMSSiteTreeFilter { * @return SS_List */ public function getFilteredPages() { - $pages = Versioned::get_including_deleted('SiteTree'); + $pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree'); $pages = $this->applyDefaultFilters($pages); $pages = $pages->filterByCallback(function($page) { return $page->getExistsOnLive(); @@ -296,7 +302,7 @@ class CMSSiteTreeFilter_DeletedPages extends CMSSiteTreeFilter { } public function getFilteredPages() { - $pages = Versioned::get_including_deleted('SiteTree'); + $pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree'); $pages = $this->applyDefaultFilters($pages); return $pages; } @@ -315,7 +321,7 @@ class CMSSiteTreeFilter_ChangedPages extends CMSSiteTreeFilter { } public function getFilteredPages() { - $pages = Versioned::get_by_stage('SiteTree', 'Stage'); + $pages = Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Stage'); $pages = $this->applyDefaultFilters($pages) ->leftJoin('SiteTree_Live', '"SiteTree_Live"."ID" = "SiteTree"."ID"') ->where('"SiteTree"."Version" <> "SiteTree_Live"."Version"'); @@ -341,7 +347,7 @@ class CMSSiteTreeFilter_StatusRemovedFromDraftPages extends CMSSiteTreeFilter { * @return SS_List */ public function getFilteredPages() { - $pages = Versioned::get_including_deleted('SiteTree'); + $pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree'); $pages = $this->applyDefaultFilters($pages); $pages = $pages->filterByCallback(function($page) { // If page is removed from stage but not live @@ -370,7 +376,7 @@ class CMSSiteTreeFilter_StatusDraftPages extends CMSSiteTreeFilter { * @return SS_List */ public function getFilteredPages() { - $pages = Versioned::get_by_stage('SiteTree', 'Stage'); + $pages = Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Stage'); $pages = $this->applyDefaultFilters($pages); $pages = $pages->filterByCallback(function($page) { // If page exists on stage but not on live @@ -409,7 +415,7 @@ class CMSSiteTreeFilter_StatusDeletedPages extends CMSSiteTreeFilter { * @return SS_List */ public function getFilteredPages() { - $pages = Versioned::get_including_deleted('SiteTree'); + $pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree'); $pages = $this->applyDefaultFilters($pages); $pages = $pages->filterByCallback(function($page) { @@ -438,7 +444,7 @@ class CMSSiteTreeFilter_Search extends CMSSiteTreeFilter { */ public function getFilteredPages() { // Filter default records - $pages = Versioned::get_by_stage('SiteTree', 'Stage'); + $pages = Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Stage'); $pages = $this->applyDefaultFilters($pages); return $pages; } diff --git a/code/Controllers/ContentController.php b/code/Controllers/ContentController.php index bb264021..d2a778bc 100755 --- a/code/Controllers/ContentController.php +++ b/code/Controllers/ContentController.php @@ -1,5 +1,7 @@ Children(); @@ -119,7 +137,7 @@ class ContentController extends Controller { } if($this->dataRecord) $this->dataRecord->extend('contentcontrollerInit', $this); - else singleton('SiteTree')->extend('contentcontrollerInit', $this); + else singleton('SilverStripe\\CMS\\Model\\SiteTree')->extend('contentcontrollerInit', $this); if($this->redirectedTo()) return; @@ -382,11 +400,11 @@ HTML; $templates = array_merge( // Find templates by dataRecord - SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SiteTree"), + SSViewer::get_templates_by_class(get_class($this->dataRecord), $action, "SilverStripe\\CMS\\Model\\SiteTree"), // Next, we need to add templates for all controllers SSViewer::get_templates_by_class(get_class($this), $action, "Controller"), // Fail-over to the same for the "index" action - SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SiteTree"), + SSViewer::get_templates_by_class(get_class($this->dataRecord), "", "SilverStripe\\CMS\\Model\\SiteTree"), SSViewer::get_templates_by_class(get_class($this), "", "Controller") ); diff --git a/code/Controllers/ErrorPageControllerExtension.php b/code/Controllers/ErrorPageControllerExtension.php index a82ba780..437cf9cd 100644 --- a/code/Controllers/ErrorPageControllerExtension.php +++ b/code/Controllers/ErrorPageControllerExtension.php @@ -1,5 +1,14 @@ stat('icon'); diff --git a/code/Controllers/ModelAsController.php b/code/Controllers/ModelAsController.php index 9bc0740e..342113a9 100644 --- a/code/Controllers/ModelAsController.php +++ b/code/Controllers/ModelAsController.php @@ -1,8 +1,25 @@ class == 'SiteTree') { - $controller = "ContentController"; + if ($sitetree->class == 'SilverStripe\\CMS\\Model\\SiteTree') { + $controller = "SilverStripe\\CMS\\Controllers\\ContentController"; } else { $ancestry = ClassInfo::ancestry($sitetree->class); while ($class = array_pop($ancestry)) { if (class_exists($class . "_Controller")) break; } - $controller = ($class !== null) ? "{$class}_Controller" : "ContentController"; + $controller = ($class !== null) ? "{$class}_Controller" : "SilverStripe\\CMS\\Controllers\\ContentController"; } if($action && class_exists($controller . '_' . ucfirst($action))) { @@ -41,14 +58,14 @@ class ModelAsController extends Controller implements NestedController { } public function init() { - singleton('SiteTree')->extend('modelascontrollerInit', $this); + singleton('SilverStripe\\CMS\\Model\\SiteTree')->extend('modelascontrollerInit', $this); parent::init(); } protected function beforeHandleRequest(SS_HTTPRequest $request, DataModel $model) { parent::beforeHandleRequest($request, $model); // If the database has not yet been created, redirect to the build page. - if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) { + if(!DB::is_active() || !ClassInfo::hasTable('SilverStripe\\CMS\\Model\\SiteTree')) { $this->getResponse()->redirect(Controller::join_links( Director::absoluteBaseURL(), 'dev/build', @@ -75,7 +92,7 @@ class ModelAsController extends Controller implements NestedController { } // If the database has not yet been created, redirect to the build page. - if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) { + if(!DB::is_active() || !ClassInfo::hasTable('SilverStripe\\CMS\\Model\\SiteTree')) { $this->getResponse()->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null)); $this->popCurrent(); @@ -118,7 +135,7 @@ class ModelAsController extends Controller implements NestedController { if(SiteTree::config()->nested_urls) { $conditions[] = array('"SiteTree"."ParentID"' => 0); } - $sitetree = DataObject::get_one('SiteTree', $conditions); + $sitetree = DataObject::get_one('SilverStripe\\CMS\\Model\\SiteTree', $conditions); // Check translation module // @todo Refactor out module specific code diff --git a/code/Controllers/OldPageRedirector.php b/code/Controllers/OldPageRedirector.php index 0cb17528..0fc2dac3 100644 --- a/code/Controllers/OldPageRedirector.php +++ b/code/Controllers/OldPageRedirector.php @@ -1,6 +1,17 @@ get('RootURLController', 'default_homepage_link'); + self::$cached_homepage_link = Config::inst()->get('SilverStripe\\CMS\\Controllers\\RootURLController', 'default_homepage_link'); } } } @@ -72,7 +85,7 @@ class RootURLController extends Controller { */ static public function set_default_homepage_link($urlsegment = "home") { Deprecation::notice('4.0', 'Use the "RootURLController.default_homepage_link" config setting instead'); - Config::inst()->update('RootURLController', 'default_homepage_link', $urlsegment); + Config::inst()->update('SilverStripe\\CMS\\Controllers\\RootURLController', 'default_homepage_link', $urlsegment); } /** @@ -83,7 +96,7 @@ class RootURLController extends Controller { */ static public function get_default_homepage_link() { Deprecation::notice('4.0', 'Use the "RootURLController.default_homepage_link" config setting instead'); - return Config::inst()->get('RootURLController', 'default_homepage_link'); + return Config::inst()->get('SilverStripe\\CMS\\Controllers\\RootURLController', 'default_homepage_link'); } /** @@ -115,7 +128,7 @@ class RootURLController extends Controller { self::$is_at_root = true; - if(!DB::is_active() || !ClassInfo::hasTable('SiteTree')) { + if(!DB::is_active() || !ClassInfo::hasTable('SilverStripe\\CMS\\Model\\SiteTree')) { $this->getResponse()->redirect(Controller::join_links( Director::absoluteBaseURL(), 'dev/build', @@ -136,7 +149,7 @@ class RootURLController extends Controller { $this->beforeHandleRequest($request, $model); if (!$this->getResponse()->isFinished()) { - if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) { + if (!DB::is_active() || !ClassInfo::hasTable('SilverStripe\\CMS\\Model\\SiteTree')) { $this->getResponse()->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null)); return $this->getResponse(); } diff --git a/code/Controllers/SilverStripeNavigator.php b/code/Controllers/SilverStripeNavigator.php index 04d5b383..0be5fec3 100644 --- a/code/Controllers/SilverStripeNavigator.php +++ b/code/Controllers/SilverStripeNavigator.php @@ -1,10 +1,21 @@ URLSegment property, and suggest input based on the serverside rules @@ -69,7 +75,7 @@ class SiteTreeURLSegmentField extends TextField { */ public function getPage() { $idField = $this->getForm()->Fields()->dataFieldByName('ID'); - return ($idField && $idField->Value()) ? DataObject::get_by_id('SiteTree', $idField->Value()) : singleton('SiteTree'); + return ($idField && $idField->Value()) ? DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $idField->Value()) : singleton('SilverStripe\\CMS\\Model\\SiteTree'); } /** diff --git a/code/Logging/ErrorPageErrorFormatter.php b/code/Logging/ErrorPageErrorFormatter.php index 0a85b001..81c2ee99 100644 --- a/code/Logging/ErrorPageErrorFormatter.php +++ b/code/Logging/ErrorPageErrorFormatter.php @@ -1,9 +1,11 @@ class === 'ErrorPage' && SiteTree::config()->create_default_pages) { + if ($this->class === 'SilverStripe\\CMS\\Model\\ErrorPage' && SiteTree::config()->create_default_pages) { $defaultPages = $this->getDefaultRecords(); diff --git a/code/Model/RedirectorPage.php b/code/Model/RedirectorPage.php index 7ef147a7..389fdbd3 100644 --- a/code/Model/RedirectorPage.php +++ b/code/Model/RedirectorPage.php @@ -1,6 +1,15 @@ "SiteTree", + "LinkTo" => "SilverStripe\\CMS\\Model\\SiteTree", ); private static $many_many = array( @@ -80,7 +89,7 @@ class RedirectorPage extends Page { } } else { - $linkTo = $this->LinkToID ? DataObject::get_by_id("SiteTree", $this->LinkToID) : null; + $linkTo = $this->LinkToID ? DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $this->LinkToID) : null; if($linkTo) { // We shouldn't point to ourselves - that would create an infinite loop! Return null since we have a @@ -105,7 +114,7 @@ class RedirectorPage extends Page { public function syncLinkTracking() { if ($this->RedirectionType == 'Internal') { if($this->LinkToID) { - $this->HasBrokenLink = DataObject::get_by_id('SiteTree', $this->LinkToID) ? false : true; + $this->HasBrokenLink = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $this->LinkToID) ? false : true; } else { // An incomplete redirector page definitely has a broken link $this->HasBrokenLink = true; @@ -153,7 +162,7 @@ class RedirectorPage extends Page { new TreeDropdownField( "LinkToID", _t('RedirectorPage.YOURPAGE', "Page on your website"), - "SiteTree" + "SilverStripe\\CMS\\Model\\SiteTree" ), new TextField("ExternalURL", _t('RedirectorPage.OTHERURL', "Other website URL")) ) diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index d5308ba8..49ec1e5e 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -1,5 +1,7 @@ nested_urls) { $conditions[] = array('"SiteTree"."ParentID"' => 0); } - $sitetree = DataObject::get_one('SiteTree', $conditions, $cache); + $sitetree = DataObject::get_one('SilverStripe\\CMS\\Model\\SiteTree', $conditions, $cache); /// Fall back on a unique URLSegment for b/c. if( !$sitetree && self::config()->nested_urls - && $page = DataObject::get_one('SiteTree', array( + && $page = DataObject::get_one('SilverStripe\\CMS\\Model\\SiteTree', array( '"SiteTree"."URLSegment"' => $URLSegment ), $cache) ) { @@ -302,7 +342,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid if(!$sitetree) { $parentID = self::config()->nested_urls ? 0 : null; - if($alternatives = singleton('SiteTree')->extend('alternateGetByLink', $URLSegment, $parentID)) { + if($alternatives = singleton('SilverStripe\\CMS\\Model\\SiteTree')->extend('alternateGetByLink', $URLSegment, $parentID)) { foreach($alternatives as $alternative) if($alternative) $sitetree = $alternative; } @@ -314,7 +354,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid // Traverse down the remaining URL segments and grab the relevant SiteTree objects. foreach($parts as $segment) { - $next = DataObject::get_one('SiteTree', array( + $next = DataObject::get_one('SilverStripe\\CMS\\Model\\SiteTree', array( '"SiteTree"."URLSegment"' => $segment, '"SiteTree"."ParentID"' => $sitetree->ID ), @@ -324,7 +364,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid if(!$next) { $parentID = (int) $sitetree->ID; - if($alternatives = singleton('SiteTree')->extend('alternateGetByLink', $segment, $parentID)) { + if($alternatives = singleton('SilverStripe\\CMS\\Model\\SiteTree')->extend('alternateGetByLink', $segment, $parentID)) { foreach($alternatives as $alternative) if($alternative) $next = $alternative; } @@ -346,7 +386,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid public static function page_type_classes() { $classes = ClassInfo::getValidSubClasses(); - $baseClassIndex = array_search('SiteTree', $classes); + $baseClassIndex = array_search('SilverStripe\\CMS\\Model\\SiteTree', $classes); if($baseClassIndex !== FALSE) unset($classes[$baseClassIndex]); $kill_ancestors = array(); @@ -390,8 +430,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid if(!isset($arguments['id']) || !is_numeric($arguments['id'])) return; if ( - !($page = DataObject::get_by_id('SiteTree', $arguments['id'])) // Get the current page by ID. - && !($page = Versioned::get_latest_version('SiteTree', $arguments['id'])) // Attempt link to old version. + !($page = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $arguments['id'])) // Get the current page by ID. + && !($page = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $arguments['id'])) // Attempt link to old version. ) { return null; // There were no suitable matches at all. } @@ -471,7 +511,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $parent = $this->Parent(); // If page is removed select parent from version history (for archive page view) if((!$parent || !$parent->exists()) && $this->IsDeletedFromStage) { - $parent = Versioned::get_latest_version('SiteTree', $this->ParentID); + $parent = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $this->ParentID); } $base = $parent->RelativeLink($this->URLSegment); } elseif(!$action && $this->URLSegment == RootURLController::get_homepage_link()) { @@ -501,7 +541,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid public function getAbsoluteLiveLink($includeStageEqualsLive = true) { $oldReadingMode = Versioned::get_reading_mode(); Versioned::set_stage(Versioned::LIVE); - $live = Versioned::get_one_by_stage('SiteTree', Versioned::LIVE, array( + $live = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::LIVE, array( '"SiteTree"."ID"' => $this->ID )); if($live) { @@ -524,7 +564,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid */ public function CMSEditLink() { $link = Controller::join_links( - singleton('CMSPageEditController')->Link('show'), + singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'), $this->ID ); return Director::absoluteURL($link); @@ -742,7 +782,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid */ public function getParent() { if ($parentID = $this->getField("ParentID")) { - return DataObject::get_by_id("SiteTree", $parentID); + return DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $parentID); } } @@ -1171,7 +1211,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid foreach(array(Versioned::DRAFT, Versioned::LIVE) as $stage) { // Start by filling the array with the pages that actually exist - $table = ($stage=='Stage') ? "SiteTree" : "SiteTree_$stage"; + $table = ($stage=='Stage') ? "SilverStripe\\CMS\\Model\\SiteTree" : "SiteTree_$stage"; if($ids) { $idQuery = "SELECT \"ID\" FROM \"$table\" WHERE \"ID\" IN ($idPlaceholders)"; @@ -1182,7 +1222,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $result = array_fill_keys($stageIds, false); // Get the uninherited permissions - $uninheritedPermissions = Versioned::get_by_stage("SiteTree", $stage) + $uninheritedPermissions = Versioned::get_by_stage("SilverStripe\\CMS\\Model\\SiteTree", $stage) ->where(array( "(\"$typeField\" = 'LoggedInUsers' OR (\"$typeField\" = 'OnlyTheseUsers' AND \"$groupJoinTable\".\"SiteTreeID\" IS NOT NULL)) @@ -1198,7 +1238,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid // Get permissions that are inherited $potentiallyInherited = Versioned::get_by_stage( - "SiteTree", + "SilverStripe\\CMS\\Model\\SiteTree", $stage, array("\"$typeField\" = 'Inherit' AND \"SiteTree\".\"ID\" IN ($idPlaceholders)" => $ids) ); @@ -1364,7 +1404,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $tags[] = FormField::create_tag('title', array(), $this->obj('Title')->forTemplate()); } - $generator = trim(Config::inst()->get('SiteTree', 'meta_generator')); + $generator = trim(Config::inst()->get('SilverStripe\\CMS\\Model\\SiteTree', 'meta_generator')); if (!empty($generator)) { $tags[] = FormField::create_tag('meta', array( 'name' => 'generator', @@ -1431,12 +1471,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid parent::requireDefaultRecords(); // default pages - if($this->class == 'SiteTree' && $this->config()->create_default_pages) { - if(!SiteTree::get_by_link(Config::inst()->get('RootURLController', 'default_homepage_link'))) { + if($this->class == 'SilverStripe\\CMS\\Model\\SiteTree' && $this->config()->create_default_pages) { + if(!SiteTree::get_by_link(Config::inst()->get('SilverStripe\\CMS\\Controllers\\RootURLController', 'default_homepage_link'))) { $homepage = new Page(); $homepage->Title = _t('SiteTree.DEFAULTHOMETITLE', 'Home'); $homepage->Content = _t('SiteTree.DEFAULTHOMECONTENT', '

Welcome to SilverStripe! This is the default homepage. You can edit this page by opening the CMS.

You can now access the developer documentation, or begin the SilverStripe lessons.

'); - $homepage->URLSegment = Config::inst()->get('RootURLController', 'default_homepage_link'); + $homepage->URLSegment = Config::inst()->get('SilverStripe\\CMS\\Controllers\\RootURLController', 'default_homepage_link'); $homepage->Sort = 1; $homepage->write(); $homepage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); @@ -1464,7 +1504,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid DB::alteration_message('Contact Us page created', 'created'); } } - } + } protected function onBeforeWrite() { parent::onBeforeWrite(); @@ -1632,7 +1672,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } // Check existence - $existingPage = DataObject::get_one('SiteTree', $filter); + $existingPage = DataObject::get_one('SilverStripe\\CMS\\Model\\SiteTree', $filter); if ($existingPage) return false; return !($existingPage); @@ -1668,7 +1708,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @return string */ public function getStageURLSegment() { - $stageRecord = Versioned::get_one_by_stage('SiteTree', Versioned::DRAFT, array( + $stageRecord = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::DRAFT, array( '"SiteTree"."ID"' => $this->ID )); return ($stageRecord) ? $stageRecord->URLSegment : null; @@ -1680,7 +1720,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @return string */ public function getLiveURLSegment() { - $liveRecord = Versioned::get_one_by_stage('SiteTree', Versioned::LIVE, array( + $liveRecord = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::LIVE, array( '"SiteTree"."ID"' => $this->ID )); return ($liveRecord) ? $liveRecord->URLSegment : null; @@ -1979,7 +2019,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid "root" => _t("SiteTree.PARENTTYPE_ROOT", "Top-level page"), "subpage" => _t("SiteTree.PARENTTYPE_SUBPAGE", "Sub-page underneath a parent page"), )), - $parentIDField = new TreeDropdownField("ParentID", $this->fieldLabel('ParentID'), 'SiteTree', 'ID', 'MenuTitle') + $parentIDField = new TreeDropdownField("ParentID", $this->fieldLabel('ParentID'), 'SilverStripe\\CMS\\Model\\SiteTree', 'ID', 'MenuTitle') ), $visibility = new FieldGroup( new CheckboxField("ShowInMenus", $this->fieldLabel('ShowInMenus')), @@ -2136,7 +2176,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $rootTabSet->addExtraClass('ss-ui-action-tabset action-menus noborder'); // Render page information into the "more-options" drop-up, on the top. - $live = Versioned::get_one_by_stage('SiteTree', Versioned::LIVE, array( + $live = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::LIVE, array( '"SiteTree"."ID"' => $this->ID )); $moreOptions->push( @@ -2284,7 +2324,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid public function onAfterRevertToLive() { // Use an alias to get the updates made by $this->publish /** @var SiteTree $stageSelf */ - $stageSelf = Versioned::get_by_stage('SiteTree', Versioned::DRAFT)->byID($this->ID); + $stageSelf = Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::DRAFT)->byID($this->ID); $stageSelf->writeWithoutVersion(); // Need to update pages linking to this one as no longer broken @@ -2301,7 +2341,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid */ protected function isParentArchived() { if($parentID = $this->ParentID) { - $parentPage = Versioned::get_latest_version("SiteTree", $parentID); + $parentPage = Versioned::get_latest_version("SilverStripe\\CMS\\Model\\SiteTree", $parentID); if(!$parentPage || $parentPage->IsDeletedFromStage) { return true; } @@ -2326,9 +2366,9 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid // create an empty record if(!DB::prepared_query("SELECT \"ID\" FROM \"SiteTree\" WHERE \"ID\" = ?", array($this->ID))->value()) { $conn = DB::get_conn(); - if(method_exists($conn, 'allowPrimaryKeyEditing')) $conn->allowPrimaryKeyEditing('SiteTree', true); + if(method_exists($conn, 'allowPrimaryKeyEditing')) $conn->allowPrimaryKeyEditing('SilverStripe\\CMS\\Model\\SiteTree', true); DB::prepared_query("INSERT INTO \"SiteTree\" (\"ID\") VALUES (?)", array($this->ID)); - if(method_exists($conn, 'allowPrimaryKeyEditing')) $conn->allowPrimaryKeyEditing('SiteTree', false); + if(method_exists($conn, 'allowPrimaryKeyEditing')) $conn->allowPrimaryKeyEditing('SilverStripe\\CMS\\Model\\SiteTree', false); } $oldReadingMode = Versioned::get_reading_mode(); @@ -2665,7 +2705,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid if(!$this->ID) return true; if($this->isNew()) return false; - $stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', Versioned::DRAFT, $this->ID); + $stageVersion = Versioned::get_versionnumber_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::DRAFT, $this->ID); // Return true for both completely deleted pages and for pages just deleted from stage return !($stageVersion); @@ -2690,8 +2730,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid // New unsaved pages could be never be published if($this->isNew()) return false; - $stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $this->ID); - $liveVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->ID); + $stageVersion = Versioned::get_versionnumber_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Stage', $this->ID); + $liveVersion = Versioned::get_versionnumber_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', $this->ID); $isModified = ($stageVersion && $stageVersion != $liveVersion); $this->extend('getIsModifiedOnStage', $isModified); @@ -2709,8 +2749,8 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid // New unsaved pages could be never be published if($this->isNew()) return false; - $stageVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Stage', $this->ID); - $liveVersion = Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->ID); + $stageVersion = Versioned::get_versionnumber_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Stage', $this->ID); + $liveVersion = Versioned::get_versionnumber_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', $this->ID); return ($stageVersion && !$liveVersion); } @@ -2773,7 +2813,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid */ public function i18n_singular_name() { // Convert 'Page' to 'SiteTree' for correct localization lookups - $class = ($this->class == 'Page') ? 'SiteTree' : $this->class; + $class = ($this->class == 'Page') ? 'SilverStripe\\CMS\\Model\\SiteTree' : $this->class; return _t($class.'.SINGULARNAME', $this->singular_name()); } diff --git a/code/Model/SiteTreeExtension.php b/code/Model/SiteTreeExtension.php index 45284407..bcbfec39 100644 --- a/code/Model/SiteTreeExtension.php +++ b/code/Model/SiteTreeExtension.php @@ -1,6 +1,9 @@ owner->BackLinkTracking()->column("ID"); if($brokenPageIDs) { // This will syncLinkTracking on the same stage as this file - $brokenPages = DataObject::get('SiteTree')->byIDs($brokenPageIDs); + $brokenPages = DataObject::get('SilverStripe\\CMS\\Model\\SiteTree')->byIDs($brokenPageIDs); foreach($brokenPages as $brokenPage) { $brokenPage->write(); } diff --git a/code/Model/SiteTreeFolderExtension.php b/code/Model/SiteTreeFolderExtension.php index 20647229..762ec8bf 100644 --- a/code/Model/SiteTreeFolderExtension.php +++ b/code/Model/SiteTreeFolderExtension.php @@ -1,9 +1,12 @@ numRecords() > 0) { while($nextResult = $result->next()) { diff --git a/code/Model/SiteTreeLinkTracking.php b/code/Model/SiteTreeLinkTracking.php index eb9fe005..627e4d3d 100644 --- a/code/Model/SiteTreeLinkTracking.php +++ b/code/Model/SiteTreeLinkTracking.php @@ -1,17 +1,20 @@ "SiteTree", + "LinkTracking" => "SilverStripe\\CMS\\Model\\SiteTree", "ImageTracking" => "File" // {@see SiteTreeFileExtension} ); @@ -269,7 +272,7 @@ class SiteTreeLinkTracking_Parser { // Link to a page on this site. $matches = array(); if(preg_match('/\[sitetree_link(?:\s*|%20|,)?id=(?[0-9]+)\](#(?.*))?/i', $href, $matches)) { - $page = DataObject::get_by_id('SiteTree', $matches['id']); + $page = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $matches['id']); $broken = false; if (!$page) { diff --git a/code/Model/VirtualPage.php b/code/Model/VirtualPage.php index 5694f712..d8d7fbf2 100644 --- a/code/Model/VirtualPage.php +++ b/code/Model/VirtualPage.php @@ -1,8 +1,18 @@ "SiteTree", + "CopyContentFrom" => "SilverStripe\\CMS\\Model\\SiteTree", ); private static $owns = array( @@ -96,7 +106,7 @@ class VirtualPage extends Page { public function setCopyContentFromID($val) { // Sanity check to prevent pages virtualising other virtual pages - if($val && DataObject::get_by_id('SiteTree', $val) instanceof VirtualPage) { + if($val && DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $val) instanceof VirtualPage) { $val = 0; } return $this->setField("CopyContentFromID", $val); @@ -137,7 +147,7 @@ class VirtualPage extends Page { public function syncLinkTracking() { if($this->CopyContentFromID) { - $this->HasBrokenLink = !(bool) DataObject::get_by_id('SiteTree', $this->CopyContentFromID); + $this->HasBrokenLink = !(bool) DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $this->CopyContentFromID); } else { $this->HasBrokenLink = true; } @@ -166,7 +176,7 @@ class VirtualPage extends Page { } // Unpublished source - if(!Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->CopyContentFromID)) { + if(!Versioned::get_versionnumber_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', $this->CopyContentFromID)) { return false; } @@ -184,7 +194,7 @@ class VirtualPage extends Page { $copyContentFromField = new TreeDropdownField( "CopyContentFromID", _t('VirtualPage.CHOOSE', "Linked Page"), - "SiteTree" + "SilverStripe\\CMS\\Model\\SiteTree" ); // filter doesn't let you select children of virtual pages as as source page //$copyContentFromField->setFilterFunction(create_function('$item', 'return !($item instanceof VirtualPage);')); @@ -224,7 +234,7 @@ class VirtualPage extends Page { } if( $this->CopyContentFromID - && !Versioned::get_versionnumber_by_stage('SiteTree', 'Live', $this->CopyContentFromID) + && !Versioned::get_versionnumber_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', $this->CopyContentFromID) ) { $msgs[] = _t( 'SITETREE.VIRTUALPAGEDRAFTWARNING', @@ -527,7 +537,7 @@ class VirtualPage_Controller extends Page_Controller { { // Check if we can safely call this method before passing it back // to custom methods. - if ($this->getExtraMethodConfig($method)) { + if($this->getExtraMethodConfig($method)) { return parent::__call($method, $args); } diff --git a/code/Reports/BrokenFilesReport.php b/code/Reports/BrokenFilesReport.php index 1c317530..b3c179f9 100644 --- a/code/Reports/BrokenFilesReport.php +++ b/code/Reports/BrokenFilesReport.php @@ -1,7 +1,13 @@ ClassName, ClassInfo::subclassesFor('RedirectorPage')); - $isVirtualPage = in_array($record->ClassName, ClassInfo::subclassesFor('VirtualPage')); + $isRedirectorPage = in_array($record->ClassName, ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\RedirectorPage')); + $isVirtualPage = in_array($record->ClassName, ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\VirtualPage')); if ($isVirtualPage) { if ($record->HasBrokenLink) { @@ -89,7 +96,7 @@ class BrokenLinksReport extends SS_Report { $dateTitle = _t('BrokenLinksReport.ColumnDateLastPublished', 'Date last published'); } - $linkBase = singleton('CMSPageEditController')->Link('show'); + $linkBase = singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'); $fields = array( "Title" => array( "title" => _t('BrokenLinksReport.PageName', 'Page name'), @@ -144,14 +151,3 @@ class BrokenLinksReport extends SS_Report { ); } } - - -/** - * @deprecated 3.2..4.0 - */ -class SideReport_BrokenLinks extends BrokenLinksReport { - public function __construct() { - Deprecation::notice('4.0', 'Use BrokenLinksReport instead'); - parent::__construct(); - } -} diff --git a/code/Reports/BrokenRedirectorPagesReport.php b/code/Reports/BrokenRedirectorPagesReport.php index ed9b39ec..bc6a7c34 100644 --- a/code/Reports/BrokenRedirectorPagesReport.php +++ b/code/Reports/BrokenRedirectorPagesReport.php @@ -1,7 +1,14 @@ $classes ); $stage = isset($params['OnLive']) ? 'Live' : 'Stage'; - return Versioned::get_by_stage('SiteTree', $stage, $classFilter); + return Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', $stage, $classFilter); } public function columns() { @@ -42,13 +49,3 @@ class BrokenRedirectorPagesReport extends SS_Report { ); } } - -/** - * @deprecated 3.2..4.0 - */ -class SideReport_BrokenRedirectorPages extends BrokenRedirectorPagesReport { - public function __construct() { - Deprecation::notice('4.0', 'Use BrokenRedirectorPagesReport instead'); - parent::__construct(); - } -} diff --git a/code/Reports/BrokenVirtualPagesReport.php b/code/Reports/BrokenVirtualPagesReport.php index f640c320..db11acf8 100644 --- a/code/Reports/BrokenVirtualPagesReport.php +++ b/code/Reports/BrokenVirtualPagesReport.php @@ -1,7 +1,13 @@ $classes ); $stage = isset($params['OnLive']) ? 'Live' : 'Stage'; - return Versioned::get_by_stage('SiteTree', $stage, $classFilter); + return Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', $stage, $classFilter); } public function columns() { @@ -42,13 +48,3 @@ class BrokenVirtualPagesReport extends SS_Report { ); } } - -/** - * @deprecated 3.2..4.0 - */ -class SideReport_BrokenVirtualPages extends BrokenVirtualPagesReport { - public function __construct() { - Deprecation::notice('4.0', 'Use BrokenVirtualPagesReport instead'); - parent::__construct(); - } -} diff --git a/code/Reports/EmptyPagesReport.php b/code/Reports/EmptyPagesReport.php index 4bbfc9fb..5d0c4579 100644 --- a/code/Reports/EmptyPagesReport.php +++ b/code/Reports/EmptyPagesReport.php @@ -1,5 +1,11 @@ Format('U')); - return DataObject::get("SiteTree", "\"SiteTree\".\"LastEdited\" > '".date("Y-m-d H:i:s", $threshold)."'", "\"SiteTree\".\"LastEdited\" DESC"); + return DataObject::get("SilverStripe\\CMS\\Model\\SiteTree", "\"SiteTree\".\"LastEdited\" > '".date("Y-m-d H:i:s", $threshold)."'", "\"SiteTree\".\"LastEdited\" DESC"); } public function columns() { @@ -35,13 +38,3 @@ class RecentlyEditedReport extends SS_Report { ); } } - -/** - * @deprecated 3.2..4.0 - */ -class SideReport_RecentlyEdited extends RecentlyEditedReport { - public function __construct() { - Deprecation::notice('4.0', 'Use RecentlyEditedReport instead'); - parent::__construct(); - } -} diff --git a/code/Search/ContentControllerSearchExtension.php b/code/Search/ContentControllerSearchExtension.php index 0ea13c4d..8d79486f 100644 --- a/code/Search/ContentControllerSearchExtension.php +++ b/code/Search/ContentControllerSearchExtension.php @@ -1,6 +1,13 @@ owner, 'SearchForm', $fields, $actions); + $form = SearchForm::create($this->owner, 'SilverStripe\\CMS\\Search\\SearchForm', $fields, $actions); $form->classesToSearch(FulltextSearchable::get_searchable_classes()); return $form; } diff --git a/code/Search/SearchForm.php b/code/Search/SearchForm.php index 810adcdd..ac5f7477 100644 --- a/code/Search/SearchForm.php +++ b/code/Search/SearchForm.php @@ -1,7 +1,16 @@ hasExtension('Translatable')) { + if(class_exists('Translatable') && singleton('SilverStripe\\CMS\\Model\\SiteTree')->hasExtension('Translatable')) { $fields->push(new HiddenField('searchlocale', 'searchlocale', Translatable::get_current_locale())); } @@ -77,7 +86,7 @@ class SearchForm extends Form { public function forTemplate() { $return = $this->renderWith(array_merge( (array)$this->getTemplate(), - array('SearchForm', 'Form') + array('SilverStripe\\CMS\\Search\\SearchForm', 'Form') )); // Now that we're rendered, clear message @@ -91,11 +100,11 @@ class SearchForm extends Form { * Currently you can only choose from "SiteTree" and "File", but a future version might improve this. */ public function classesToSearch($classes) { - $illegalClasses = array_diff($classes, array('SiteTree', 'File')); + $illegalClasses = array_diff($classes, array('SilverStripe\\CMS\\Model\\SiteTree', 'File')); if($illegalClasses) { user_error("SearchForm::classesToSearch() passed illegal classes '" . implode("', '", $illegalClasses) . "'. At this stage, only File and SiteTree are allowed", E_USER_WARNING); } - $legalClasses = array_intersect($classes, array('SiteTree', 'File')); + $legalClasses = array_intersect($classes, array('SilverStripe\\CMS\\Model\\SiteTree', 'File')); $this->classesToSearch = $legalClasses; } @@ -122,7 +131,7 @@ class SearchForm extends Form { // set language (if present) if(class_exists('Translatable')) { - if(singleton('SiteTree')->hasExtension('Translatable') && isset($data['searchlocale'])) { + if(singleton('SilverStripe\\CMS\\Model\\SiteTree')->hasExtension('Translatable') && isset($data['searchlocale'])) { if($data['searchlocale'] == "ALL") { Translatable::disable_locale_filter(); } else { @@ -165,7 +174,7 @@ class SearchForm extends Form { // reset locale if(class_exists('Translatable')) { - if(singleton('SiteTree')->hasExtension('Translatable') && isset($data['searchlocale'])) { + if(singleton('SilverStripe\\CMS\\Model\\SiteTree')->hasExtension('Translatable') && isset($data['searchlocale'])) { if($data['searchlocale'] == "ALL") { Translatable::enable_locale_filter(); } else { diff --git a/code/Tasks/MigrateSiteTreeLinkingTask.php b/code/Tasks/MigrateSiteTreeLinkingTask.php index 6a33b807..61142fed 100644 --- a/code/Tasks/MigrateSiteTreeLinkingTask.php +++ b/code/Tasks/MigrateSiteTreeLinkingTask.php @@ -20,7 +20,7 @@ class MigrateSiteTreeLinkingTask extends BuildTask { $pages = 0; $links = 0; - $linkedPages = new DataList('SiteTree'); + $linkedPages = new DataList('SilverStripe\\CMS\\Model\\SiteTree'); $linkedPages = $linkedPages->innerJoin('SiteTree_LinkTracking', '"SiteTree_LinkTracking"."SiteTreeID" = "SiteTree"."ID"'); if($linkedPages) foreach($linkedPages as $page) { $tracking = DB::prepared_query( @@ -29,7 +29,7 @@ class MigrateSiteTreeLinkingTask extends BuildTask { )->map(); foreach($tracking as $childID => $fieldName) { - $linked = DataObject::get_by_id('SiteTree', $childID); + $linked = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $childID); // TOOD: Replace in all HTMLText fields $page->Content = preg_replace ( diff --git a/code/Tasks/RemoveOrphanedPagesTask.php b/code/Tasks/RemoveOrphanedPagesTask.php index 902cbaff..918c4e21 100644 --- a/code/Tasks/RemoveOrphanedPagesTask.php +++ b/code/Tasks/RemoveOrphanedPagesTask.php @@ -5,6 +5,8 @@ use SilverStripe\ORM\DataObject; use SilverStripe\ORM\ArrayList; use SilverStripe\Security\Permission; use SilverStripe\Security\Security; +use SilverStripe\CMS\Model\SiteTree; + @@ -55,7 +57,7 @@ in the other stage:

"; - protected $orphanedSearchClass = 'SiteTree'; + protected $orphanedSearchClass = 'SilverStripe\\CMS\\Model\\SiteTree'; public function init() { parent::init(); @@ -309,7 +311,7 @@ in the other stage:
* @param int|array $limit * @return SS_List */ - public function getOrphanedPages($class = 'SiteTree', $filter = array(), $sort = null, $join = null, $limit = null) { + public function getOrphanedPages($class = 'SilverStripe\\CMS\\Model\\SiteTree', $filter = array(), $sort = null, $join = null, $limit = null) { // Alter condition if(empty($filter)) $where = array(); elseif(is_array($filter)) $where = $filter; diff --git a/code/Tasks/SiteTreeMaintenanceTask.php b/code/Tasks/SiteTreeMaintenanceTask.php index 2616edee..681c7b05 100644 --- a/code/Tasks/SiteTreeMaintenanceTask.php +++ b/code/Tasks/SiteTreeMaintenanceTask.php @@ -14,7 +14,7 @@ class SiteTreeMaintenanceTask extends Controller { public function makelinksunique() { $badURLs = "'" . implode("', '", DB::query("SELECT URLSegment, count(*) FROM SiteTree GROUP BY URLSegment HAVING count(*) > 1")->column()) . "'"; - $pages = DataObject::get("SiteTree", "\"SiteTree\".\"URLSegment\" IN ($badURLs)"); + $pages = DataObject::get("SilverStripe\\CMS\\Model\\SiteTree", "\"SiteTree\".\"URLSegment\" IN ($badURLs)"); foreach($pages as $page) { echo "
  • $page->Title: "; diff --git a/tests/behat/features/bootstrap/FeatureContext.php b/tests/behat/features/bootstrap/FeatureContext.php index 4b4d986e..6f404ad2 100644 --- a/tests/behat/features/bootstrap/FeatureContext.php +++ b/tests/behat/features/bootstrap/FeatureContext.php @@ -39,7 +39,7 @@ class FeatureContext extends \SilverStripe\Framework\Test\Behaviour\FeatureConte // Use blueprints which auto-publish all subclasses of SiteTree $factory = $fixtureContext->getFixtureFactory(); - foreach(\ClassInfo::subclassesFor('SiteTree') as $id => $class) { + foreach(\ClassInfo::subclassesFor('SilverStripe\\CMS\\Model\\SiteTree') as $id => $class) { $blueprint = \Injector::inst()->create('FixtureBlueprint', $class); $blueprint->addCallback('afterCreate', function($obj, $identifier, &$data, &$fixtures) { /** @var \SiteTree $obj */ 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 38e8f586..b8aebdea 100644 --- a/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/FixtureContext.php +++ b/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/FixtureContext.php @@ -26,7 +26,7 @@ class FixtureContext extends \SilverStripe\BehatExtension\Context\FixtureContext * @Given /^(?:(an|a|the) )"(?[^"]+)" "(?[^"]+)" (:?which )?redirects to (?:(an|a|the) )"(?[^"]+)" "(?[^"]+)"$/ */ public function stepCreateRedirectorPage($type, $id, $targetType, $targetId) { - $class = 'RedirectorPage'; + $class = 'SilverStripe\\CMS\\Model\\RedirectorPage'; $targetClass = $this->convertTypeToClass($targetType); $targetObj = $this->fixtureFactory->get($targetClass, $targetId); diff --git a/tests/controller/AssetAdminTest.php b/tests/controller/AssetAdminTest.php index 16587c8a..2d1c8194 100644 --- a/tests/controller/AssetAdminTest.php +++ b/tests/controller/AssetAdminTest.php @@ -2,6 +2,8 @@ use SilverStripe\ORM\DataObject; use SilverStripe\ORM\SS_List; +use SilverStripe\CMS\Controllers\AssetAdmin; + /** * Tests {@see AssetAdmin} diff --git a/tests/controller/CMSBatchActionsTest.php b/tests/controller/CMSBatchActionsTest.php index fe8f6795..3efa9de2 100644 --- a/tests/controller/CMSBatchActionsTest.php +++ b/tests/controller/CMSBatchActionsTest.php @@ -1,6 +1,12 @@ logInWithPermission('ADMIN'); // published page - $published = $this->objFromFixture('SiteTree', 'published'); + $published = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'published'); $published->publishSingle(); // Deleted / archived page - $archived = $this->objFromFixture('SiteTree', 'archived'); + $archived = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archived'); $archived->doArchive(); // should archive all children // Unpublished - $unpublished = $this->objFromFixture('SiteTree', 'unpublished'); + $unpublished = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'unpublished'); $unpublished->publishSingle(); $unpublished->doUnpublish(); // Modified - $modified = $this->objFromFixture('SiteTree', 'modified'); + $modified = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'modified'); $modified->publishSingle(); $modified->Title = 'modified2'; $modified->write(); @@ -39,18 +45,18 @@ class CMSBatchActionsTest extends SapphireTest { */ public function testBatchPublishApplicable() { $this->logInWithPermission('ADMIN'); - $pages = Versioned::get_including_deleted('SiteTree'); + $pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree'); $ids = $pages->column('ID'); $action = new CMSBatchAction_Publish(); // Test applicable pages $applicable = $action->applicablePages($ids); - $this->assertContains($this->idFromFixture('SiteTree', 'published'), $applicable); - $this->assertNotContains($this->idFromFixture('SiteTree', 'archived'), $applicable); - $this->assertNotContains($this->idFromFixture('SiteTree', 'archivedx'), $applicable); - $this->assertNotContains($this->idFromFixture('SiteTree', 'archivedy'), $applicable); - $this->assertContains($this->idFromFixture('SiteTree', 'unpublished'), $applicable); - $this->assertContains($this->idFromFixture('SiteTree', 'modified'), $applicable); + $this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'published'), $applicable); + $this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archived'), $applicable); + $this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedx'), $applicable); + $this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedy'), $applicable); + $this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'unpublished'), $applicable); + $this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'modified'), $applicable); } @@ -59,18 +65,18 @@ class CMSBatchActionsTest extends SapphireTest { */ public function testBatchUnpublishApplicable() { $this->logInWithPermission('ADMIN'); - $pages = Versioned::get_including_deleted('SiteTree'); + $pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree'); $ids = $pages->column('ID'); $action = new CMSBatchAction_Unpublish(); // Test applicable page $applicable = $action->applicablePages($ids); - $this->assertContains($this->idFromFixture('SiteTree', 'published'), $applicable); - $this->assertNotContains($this->idFromFixture('SiteTree', 'archived'), $applicable); - $this->assertNotContains($this->idFromFixture('SiteTree', 'archivedx'), $applicable); - $this->assertNotContains($this->idFromFixture('SiteTree', 'archivedy'), $applicable); - $this->assertNotContains($this->idFromFixture('SiteTree', 'unpublished'), $applicable); - $this->assertContains($this->idFromFixture('SiteTree', 'modified'), $applicable); + $this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'published'), $applicable); + $this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archived'), $applicable); + $this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedx'), $applicable); + $this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedy'), $applicable); + $this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'unpublished'), $applicable); + $this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'modified'), $applicable); } /** @@ -78,16 +84,16 @@ class CMSBatchActionsTest extends SapphireTest { */ public function testBatchArchiveApplicable() { $this->logInWithPermission('ADMIN'); - $pages = Versioned::get_including_deleted('SiteTree'); + $pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree'); $ids = $pages->column('ID'); $action = new CMSBatchAction_Archive(); // Test applicable pages $applicable = $action->applicablePages($ids); - $this->assertContains($this->idFromFixture('SiteTree', 'published'), $applicable); - $this->assertNotContains($this->idFromFixture('SiteTree', 'archived'), $applicable); - $this->assertContains($this->idFromFixture('SiteTree', 'unpublished'), $applicable); - $this->assertContains($this->idFromFixture('SiteTree', 'modified'), $applicable); + $this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'published'), $applicable); + $this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archived'), $applicable); + $this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'unpublished'), $applicable); + $this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'modified'), $applicable); } /** @@ -95,27 +101,27 @@ class CMSBatchActionsTest extends SapphireTest { */ public function testBatchRestoreApplicable() { $this->logInWithPermission('ADMIN'); - $pages = Versioned::get_including_deleted('SiteTree'); + $pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree'); $ids = $pages->column('ID'); $action = new CMSBatchAction_Restore(); // Test applicable pages $applicable = $action->applicablePages($ids); - $this->assertNotContains($this->idFromFixture('SiteTree', 'published'), $applicable); - $this->assertContains($this->idFromFixture('SiteTree', 'archived'), $applicable); - $this->assertContains($this->idFromFixture('SiteTree', 'archivedx'), $applicable); - $this->assertContains($this->idFromFixture('SiteTree', 'archivedy'), $applicable); - $this->assertNotContains($this->idFromFixture('SiteTree', 'unpublished'), $applicable); - $this->assertNotContains($this->idFromFixture('SiteTree', 'modified'), $applicable); + $this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'published'), $applicable); + $this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archived'), $applicable); + $this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedx'), $applicable); + $this->assertContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedy'), $applicable); + $this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'unpublished'), $applicable); + $this->assertNotContains($this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'modified'), $applicable); } public function testBatchRestore() { $this->logInWithPermission('ADMIN'); - $pages = Versioned::get_including_deleted('SiteTree'); + $pages = Versioned::get_including_deleted('SilverStripe\\CMS\\Model\\SiteTree'); $action = new CMSBatchAction_Restore(); - $archivedID = $this->idFromFixture('SiteTree', 'archived'); - $archivedxID = $this->idFromFixture('SiteTree', 'archivedx'); - $archivedyID = $this->idFromFixture('SiteTree', 'archivedy'); + $archivedID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archived'); + $archivedxID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedx'); + $archivedyID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'archivedy'); // Just restore one child $list = $pages->filter('RecordID', $archivedxID); diff --git a/tests/controller/CMSMainTest.php b/tests/controller/CMSMainTest.php index 44b9ec99..2b66ce47 100644 --- a/tests/controller/CMSMainTest.php +++ b/tests/controller/CMSMainTest.php @@ -4,6 +4,9 @@ use SilverStripe\ORM\DB; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\Versioning\Versioned; use SilverStripe\ORM\HiddenClass; +use SilverStripe\CMS\Controllers\CMSMain; +use SilverStripe\CMS\Model\SiteTree; + /** * @package cms @@ -34,7 +37,7 @@ class CMSMainTest extends FunctionalTest { $user->logIn(); $cache->clean(Zend_Cache::CLEANING_MODE_ALL); - $rawHints = singleton('CMSMain')->SiteTreeHints(); + $rawHints = singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->SiteTreeHints(); $this->assertNotNull($rawHints); $rawHints = preg_replace('/^"(.*)"$/', '$1', Convert::xml2raw($rawHints)); @@ -125,7 +128,7 @@ class CMSMainTest extends FunctionalTest { } // Get the latest version of the redirector page - $pageID = $this->idFromFixture('RedirectorPage', 'page5'); + $pageID = $this->idFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage', 'page5'); $latestID = DB::prepared_query('select max("Version") from "RedirectorPage_versions" where "RecordID" = ?', array($pageID))->value(); $dsCount = DB::prepared_query('select count("Version") from "RedirectorPage_versions" where "RecordID" = ? and "Version"= ?', array($pageID, $latestID))->value(); $this->assertEquals(1, $dsCount, "Published page has no duplicate version records: it has " . $dsCount . " for version " . $latestID); @@ -175,7 +178,7 @@ class CMSMainTest extends FunctionalTest { * Mostly, this is just checking that the method doesn't return an error */ public function testThatGetCMSFieldsWorksOnEveryPageType() { - $classes = ClassInfo::subclassesFor("SiteTree"); + $classes = ClassInfo::subclassesFor("SilverStripe\\CMS\\Model\\SiteTree"); array_shift($classes); foreach ($classes as $class) { @@ -186,7 +189,7 @@ class CMSMainTest extends FunctionalTest { $page->Title = "Test $class page"; $page->write(); $page->flushCache(); - $page = DataObject::get_by_id("SiteTree", $page->ID); + $page = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $page->ID); $this->assertTrue($page->getCMSFields() instanceof FieldList); } @@ -195,7 +198,7 @@ class CMSMainTest extends FunctionalTest { public function testCanPublishPageWithUnpublishedParentWithStrictHierarchyOff() { $this->logInWithPermission('ADMIN'); - Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', true); $parentPage = $this->objFromFixture('Page', 'page3'); $childPage = $this->objFromFixture('Page', 'page1'); @@ -208,7 +211,7 @@ class CMSMainTest extends FunctionalTest { $actions, 'Can publish a page with an unpublished parent with strict hierarchy off' ); - Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', false); } /** @@ -225,10 +228,10 @@ class CMSMainTest extends FunctionalTest { $response = $this->get('admin/pages/edit/show/' . $pageID); - $livePage = Versioned::get_one_by_stage("SiteTree", "Live", array( + $livePage = Versioned::get_one_by_stage("SilverStripe\\CMS\\Model\\SiteTree", "Live", array( '"SiteTree"."ID"' => $pageID )); - $this->assertInstanceOf('SiteTree', $livePage); + $this->assertInstanceOf('SilverStripe\\CMS\\Model\\SiteTree', $livePage); $this->assertTrue($livePage->canDelete()); // Check that the 'restore' button exists as a simple way of checking that the correct page is returned. @@ -469,7 +472,7 @@ class CMSMainTest extends FunctionalTest { // Test deleted page filter $params = array( - 'FilterClass' => 'CMSSiteTreeFilter_StatusDeletedPages' + 'FilterClass' => 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter_StatusDeletedPages' ); $pages = $controller->getList($params); $this->assertEquals(1, $pages->count()); @@ -480,7 +483,7 @@ class CMSMainTest extends FunctionalTest { // Test live, but not on draft filter $params = array( - 'FilterClass' => 'CMSSiteTreeFilter_StatusRemovedFromDraftPages' + 'FilterClass' => 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter_StatusRemovedFromDraftPages' ); $pages = $controller->getList($params); $this->assertEquals(1, $pages->count()); diff --git a/tests/controller/CMSPageHistoryControllerTest.php b/tests/controller/CMSPageHistoryControllerTest.php index 80875ee8..f00867b9 100755 --- a/tests/controller/CMSPageHistoryControllerTest.php +++ b/tests/controller/CMSPageHistoryControllerTest.php @@ -1,6 +1,8 @@ ID; $deletedPage->delete(); $deletedPage = Versioned::get_one_by_stage( - 'SiteTree', + 'SilverStripe\\CMS\\Model\\SiteTree', 'Live', array('"SiteTree_Live"."ID"' => $deletedPageID) ); @@ -110,7 +117,7 @@ class CMSSiteTreeFilterTest extends SapphireTest { public function testStatusDraftPagesFilter() { $draftPage = $this->objFromFixture('Page', 'page4'); $draftPage = Versioned::get_one_by_stage( - 'SiteTree', + 'SilverStripe\\CMS\\Model\\SiteTree', 'Stage', sprintf('"SiteTree"."ID" = %d', $draftPage->ID) ); @@ -146,7 +153,7 @@ class CMSSiteTreeFilterTest extends SapphireTest { $removedDraftPage->publishRecursive(); $removedDraftPage->deleteFromStage('Stage'); $removedDraftPage = Versioned::get_one_by_stage( - 'SiteTree', + 'SilverStripe\\CMS\\Model\\SiteTree', 'Live', sprintf('"SiteTree"."ID" = %d', $removedDraftPage->ID) ); @@ -173,7 +180,7 @@ class CMSSiteTreeFilterTest extends SapphireTest { // Can't use straight $blah->delete() as that blows it away completely and test fails $deletedPage->deleteFromStage(Versioned::LIVE); $deletedPage->deleteFromStage(Versioned::DRAFT); - $checkParentExists = Versioned::get_latest_version('SiteTree', $deletedPageID); + $checkParentExists = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $deletedPageID); // Check deleted page is included $f = new CMSSiteTreeFilter_StatusDeletedPages(array('Title' => 'Page')); diff --git a/tests/controller/ContentControllerSearchExtensionTest.php b/tests/controller/ContentControllerSearchExtensionTest.php index e9f39e78..1e282568 100644 --- a/tests/controller/ContentControllerSearchExtensionTest.php +++ b/tests/controller/ContentControllerSearchExtensionTest.php @@ -1,6 +1,8 @@ SearchForm(); - if (get_class($form) == 'SearchForm') $this->assertEquals(array('File'), $form->getClassesToSearch()); + if (get_class($form) == 'SilverStripe\\CMS\\Search\\SearchForm') $this->assertEquals(array('File'), $form->getClassesToSearch()); } public function setUpOnce() { diff --git a/tests/controller/ContentControllerTest.php b/tests/controller/ContentControllerTest.php index 5640efdf..b7eeda25 100755 --- a/tests/controller/ContentControllerTest.php +++ b/tests/controller/ContentControllerTest.php @@ -1,6 +1,10 @@ update('SiteTree', 'nested_urls', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true); $this->assertEquals('Home Page', $this->get('/')->getBody()); $this->assertEquals('Home Page', $this->get('/home/index/')->getBody()); @@ -56,7 +60,7 @@ class ContentControllerTest extends FunctionalTest { public function testChildrenOf() { $controller = new ContentController(); - Config::inst()->update('SiteTree', 'nested_urls', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true); $this->assertEquals(1, $controller->ChildrenOf('/')->Count()); $this->assertEquals(1, $controller->ChildrenOf('/home/')->Count()); @@ -72,7 +76,7 @@ class ContentControllerTest extends FunctionalTest { } public function testDeepNestedURLs() { - Config::inst()->update('SiteTree', 'nested_urls', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true); $page = new Page(); $page->URLSegment = 'base-page'; diff --git a/tests/controller/ModelAsControllerTest.php b/tests/controller/ModelAsControllerTest.php index cf955313..2ef8a071 100644 --- a/tests/controller/ModelAsControllerTest.php +++ b/tests/controller/ModelAsControllerTest.php @@ -1,6 +1,10 @@ orig['nested_urls'] = SiteTree::config()->nested_urls; - Config::inst()->update('SiteTree', 'nested_urls', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true); } /** @@ -299,7 +303,7 @@ class ModelAsControllerTest extends FunctionalTest { */ public function testChildOfDraft() { RootURLController::reset(); - Config::inst()->update('SiteTree', 'nested_urls', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true); $draft = new Page(); $draft->Title = 'Root Leve Draft Page'; diff --git a/tests/controller/RootURLControllerTest.php b/tests/controller/RootURLControllerTest.php index 9396f80e..d4b85221 100644 --- a/tests/controller/RootURLControllerTest.php +++ b/tests/controller/RootURLControllerTest.php @@ -1,4 +1,7 @@ nested_urls = false; $this->assertEquals('home', RootURLController::get_homepage_link()); - Config::inst()->update('SiteTree', 'nested_urls', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true); $this->assertEquals('home', RootURLController::get_homepage_link()); } diff --git a/tests/controller/SilverStripeNavigatorTest.php b/tests/controller/SilverStripeNavigatorTest.php index 233c2991..96afd96f 100644 --- a/tests/controller/SilverStripeNavigatorTest.php +++ b/tests/controller/SilverStripeNavigatorTest.php @@ -2,6 +2,9 @@ use SilverStripe\Security\Member; use SilverStripe\Security\Permission; +use SilverStripe\CMS\Controllers\SilverStripeNavigator; +use SilverStripe\CMS\Controllers\SilverStripeNavigatorItem; + /** * @package cms * @subpackage tests @@ -17,7 +20,7 @@ class SilverStripeNavigatorTest extends SapphireTest { $items = $navigator->getItems(); $classes = array_map('get_class', $items->toArray()); - $this->assertContains('SilverStripeNavigatorItem_StageLink', $classes, + $this->assertContains('SilverStripe\\CMS\\Controllers\\SilverStripeNavigatorItem_StageLink', $classes, 'Adds default classes' ); diff --git a/tests/model/ErrorPageFileExtensionTest.php b/tests/model/ErrorPageFileExtensionTest.php index 706bae20..7c3810ca 100644 --- a/tests/model/ErrorPageFileExtensionTest.php +++ b/tests/model/ErrorPageFileExtensionTest.php @@ -26,11 +26,11 @@ class ErrorPageFileExtensionTest extends SapphireTest { public function testErrorPage() { // Get and publish records - $notFoundPage = $this->objFromFixture('ErrorPage', '404'); + $notFoundPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '404'); $notFoundPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); $notFoundLink = $notFoundPage->Link(); - $disallowedPage = $this->objFromFixture('ErrorPage', '403'); + $disallowedPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '403'); $disallowedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); $disallowedLink = $disallowedPage->Link(); diff --git a/tests/model/ErrorPageTest.php b/tests/model/ErrorPageTest.php index 86164999..5f436bd8 100644 --- a/tests/model/ErrorPageTest.php +++ b/tests/model/ErrorPageTest.php @@ -1,6 +1,8 @@ update('ErrorPage', 'enable_static_file', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\ErrorPage', 'enable_static_file', true); Config::inst()->update('Director', 'environment_type', 'live'); $this->logInWithPermission('ADMIN'); } @@ -32,7 +34,7 @@ class ErrorPageTest extends FunctionalTest { } public function test404ErrorPage() { - $page = $this->objFromFixture('ErrorPage', '404'); + $page = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '404'); // ensure that the errorpage exists as a physical file $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); @@ -49,7 +51,7 @@ class ErrorPageTest extends FunctionalTest { } public function testBehaviourOfShowInMenuAndShowInSearchFlags() { - $page = $this->objFromFixture('ErrorPage', '404'); + $page = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '404'); /* Don't show the error page in the menus */ $this->assertEquals($page->ShowInMenus, 0, 'Don\'t show the error page in the menus'); @@ -59,7 +61,7 @@ class ErrorPageTest extends FunctionalTest { } public function testBehaviourOf403() { - $page = $this->objFromFixture('ErrorPage', '403'); + $page = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '403'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); $response = $this->get($page->RelativeLink()); @@ -70,7 +72,7 @@ class ErrorPageTest extends FunctionalTest { public function testSecurityError() { // Generate 404 page - $page = $this->objFromFixture('ErrorPage', '404'); + $page = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '404'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); // Test invalid action @@ -104,7 +106,7 @@ class ErrorPageTest extends FunctionalTest { * Test fallback to file generation API with enable_static_file disabled */ public function testGeneratedFile() { - Config::inst()->update('ErrorPage', 'enable_static_file', false); + Config::inst()->update('SilverStripe\\CMS\\Model\\ErrorPage', 'enable_static_file', false); $this->logInWithPermission('ADMIN'); $page = new ErrorPage(); diff --git a/tests/model/FileLinkTrackingTest.php b/tests/model/FileLinkTrackingTest.php index 79113d53..61bb21bf 100644 --- a/tests/model/FileLinkTrackingTest.php +++ b/tests/model/FileLinkTrackingTest.php @@ -2,6 +2,8 @@ use SilverStripe\ORM\Versioning\Versioned; use SilverStripe\ORM\DataObject; +use SilverStripe\CMS\Model\VirtualPage; + /** * Tests link tracking to files and images. @@ -157,8 +159,8 @@ class FileLinkTrackingTest extends SapphireTest { $file->write(); // Caching hack - Versioned::prepopulate_versionnumber_cache('SiteTree', 'Stage', array($page->ID)); - Versioned::prepopulate_versionnumber_cache('SiteTree', 'Live', array($page->ID)); + Versioned::prepopulate_versionnumber_cache('SilverStripe\\CMS\\Model\\SiteTree', 'Stage', array($page->ID)); + Versioned::prepopulate_versionnumber_cache('SilverStripe\\CMS\\Model\\SiteTree', 'Live', array($page->ID)); // Confirm that the page hasn't gone green. $this->assertFalse($page->getIsModifiedOnStage()); diff --git a/tests/model/RedirectorPageTest.php b/tests/model/RedirectorPageTest.php index bf4848cb..41ee7e54 100644 --- a/tests/model/RedirectorPageTest.php +++ b/tests/model/RedirectorPageTest.php @@ -1,5 +1,8 @@ assertEquals("http://www.google.com", $this->objFromFixture('RedirectorPage','goodexternal')->Link()); - $this->assertEquals(Director::baseURL() . "redirection-dest/", $this->objFromFixture('RedirectorPage','goodinternal')->redirectionLink()); - $this->assertEquals(Director::baseURL() . "redirection-dest/", $this->objFromFixture('RedirectorPage','goodinternal')->Link()); + $this->assertEquals("http://www.google.com", $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','goodexternal')->Link()); + $this->assertEquals(Director::baseURL() . "redirection-dest/", $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','goodinternal')->redirectionLink()); + $this->assertEquals(Director::baseURL() . "redirection-dest/", $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','goodinternal')->Link()); } public function testEmptyRedirectors() { /* If a redirector page is misconfigured, then its link method will just return the usual URLSegment-generated value */ - $page1 = $this->objFromFixture('RedirectorPage','badexternal'); + $page1 = $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','badexternal'); $this->assertEquals(Director::baseURL() . 'bad-external/', $page1->Link()); /* An error message will be shown if you visit it */ @@ -22,7 +25,7 @@ class RedirectorPageTest extends FunctionalTest { $this->assertContains('message-setupWithoutRedirect', $content); /* This also applies for internal links */ - $page2 = $this->objFromFixture('RedirectorPage','badinternal'); + $page2 = $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','badinternal'); $this->assertEquals(Director::baseURL() . 'bad-internal/', $page2->Link()); $content = $this->get(Director::makeRelative($page2->Link()))->getBody(); $this->assertContains('message-setupWithoutRedirect', $content); @@ -30,14 +33,14 @@ class RedirectorPageTest extends FunctionalTest { public function testReflexiveAndTransitiveInternalRedirectors() { /* Reflexive redirectors are those that point to themselves. They should behave the same as an empty redirector */ - $page = $this->objFromFixture('RedirectorPage','reflexive'); + $page = $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','reflexive'); $this->assertEquals(Director::baseURL() . 'reflexive/', $page->Link()); $content = $this->get(Director::makeRelative($page->Link()))->getBody(); $this->assertContains('message-setupWithoutRedirect', $content); /* Transitive redirectors are those that point to another redirector page. They should send people to the URLSegment * of the destination page - the middle-stop, so to speak. That should redirect to the final destination */ - $page = $this->objFromFixture('RedirectorPage','transitive'); + $page = $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage','transitive'); $this->assertEquals(Director::baseURL() . 'good-internal/', $page->Link()); $this->autoFollowRedirection = false; @@ -46,7 +49,7 @@ class RedirectorPageTest extends FunctionalTest { } public function testExternalURLGetsPrefixIfNotSet() { - $page = $this->objFromFixture('RedirectorPage', 'externalnoprefix'); + $page = $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage', 'externalnoprefix'); $this->assertEquals($page->ExternalURL, 'http://google.com', 'onBeforeWrite has prefixed with http'); $page->write(); $this->assertEquals($page->ExternalURL, 'http://google.com', 'onBeforeWrite will not double prefix if written again!'); @@ -70,7 +73,7 @@ class RedirectorPageTest extends FunctionalTest { * Test that we can trigger a redirection before RedirectorPage_Controller::init() is called */ public function testRedirectRespectsFinishedResponse() { - $page = $this->objFromFixture('RedirectorPage', 'goodinternal'); + $page = $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage', 'goodinternal'); RedirectorPage_Controller::add_extension('RedirectorPageTest_RedirectExtension'); $response = $this->get($page->regularLink()); diff --git a/tests/model/SiteTreeActionsTest.php b/tests/model/SiteTreeActionsTest.php index 60c404cf..12a72454 100644 --- a/tests/model/SiteTreeActionsTest.php +++ b/tests/model/SiteTreeActionsTest.php @@ -56,8 +56,8 @@ class SiteTreeActionsTest extends FunctionalTest { $page->deleteFromStage('Stage'); // Get the live version of the page - $page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID"); - $this->assertInstanceOf("SiteTree", $page); + $page = Versioned::get_one_by_stage("SilverStripe\\CMS\\Model\\SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID"); + $this->assertInstanceOf("SilverStripe\\CMS\\Model\\SiteTree", $page); // Check that someone without the right permission can't delete the page $editor = $this->objFromFixture('SilverStripe\\Security\\Member', 'cmsnodeleteeditor'); @@ -108,8 +108,8 @@ class SiteTreeActionsTest extends FunctionalTest { $page->deleteFromStage('Stage'); // Get the live version of the page - $page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID"); - $this->assertInstanceOf('SiteTree', $page); + $page = Versioned::get_one_by_stage("SilverStripe\\CMS\\Model\\SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID"); + $this->assertInstanceOf('SilverStripe\\CMS\\Model\\SiteTree', $page); $actions = $page->getCMSActions(); diff --git a/tests/model/SiteTreeBrokenLinksTest.php b/tests/model/SiteTreeBrokenLinksTest.php index 8ddfa967..d9cc8be8 100644 --- a/tests/model/SiteTreeBrokenLinksTest.php +++ b/tests/model/SiteTreeBrokenLinksTest.php @@ -3,6 +3,9 @@ use SilverStripe\ORM\Versioning\Versioned; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DB; +use SilverStripe\CMS\Model\VirtualPage; +use SilverStripe\CMS\Model\RedirectorPage; + /** * Tests {@see SiteTreeLinkTracking} broken links feature: LinkTracking @@ -94,10 +97,10 @@ class SiteTreeBrokenLinksTest extends SapphireTest { $this->assertTrue($obj->publishRecursive()); // Confirm that it isn't marked as broken to begin with $obj->flushCache(); - $obj = DataObject::get_by_id("SiteTree", $obj->ID); + $obj = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $obj->ID); $this->assertEquals(0, $obj->HasBrokenFile); - $liveObj = Versioned::get_one_by_stage("SiteTree", "Live","\"SiteTree\".\"ID\" = $obj->ID"); + $liveObj = Versioned::get_one_by_stage("SilverStripe\\CMS\\Model\\SiteTree", "Live","\"SiteTree\".\"ID\" = $obj->ID"); $this->assertEquals(0, $liveObj->HasBrokenFile); // Delete the file @@ -105,12 +108,12 @@ class SiteTreeBrokenLinksTest extends SapphireTest { // Confirm that it is marked as broken in stage $obj->flushCache(); - $obj = DataObject::get_by_id("SiteTree", $obj->ID); + $obj = DataObject::get_by_id("SilverStripe\\CMS\\Model\\SiteTree", $obj->ID); $this->assertEquals(1, $obj->HasBrokenFile); // Publishing this page marks it as broken on live too $obj->publishRecursive(); - $liveObj = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $obj->ID"); + $liveObj = Versioned::get_one_by_stage("SilverStripe\\CMS\\Model\\SiteTree", "Live", "\"SiteTree\".\"ID\" = $obj->ID"); $this->assertEquals(1, $liveObj->HasBrokenFile); } @@ -195,41 +198,41 @@ class SiteTreeBrokenLinksTest extends SapphireTest { // Unpublish the source page, confirm that the page 2 and RP has a broken link on published $p->doUnpublish(); - $p2Live = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $p2->ID); - $rpLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $rp->ID); + $p2Live = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $p2->ID); + $rpLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $rp->ID); $this->assertEquals(1, $p2Live->HasBrokenLink); $this->assertEquals(1, $rpLive->HasBrokenLink); // Delete the source page, confirm that the VP, RP and page 2 have broken links on draft $p->delete(); $vp->flushCache(); - $vp = DataObject::get_by_id('SiteTree', $vp->ID); + $vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID); $p2->flushCache(); - $p2 = DataObject::get_by_id('SiteTree', $p2->ID); + $p2 = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $p2->ID); $rp->flushCache(); - $rp = DataObject::get_by_id('SiteTree', $rp->ID); + $rp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $rp->ID); $this->assertEquals(1, $p2->HasBrokenLink); $this->assertEquals(1, $vp->HasBrokenLink); $this->assertEquals(1, $rp->HasBrokenLink); // Restore the page to stage, confirm that this fixes the links - $p = Versioned::get_latest_version('SiteTree', $pageID); + $p = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $pageID); $p->doRestoreToStage(); $p2->flushCache(); - $p2 = DataObject::get_by_id('SiteTree', $p2->ID); + $p2 = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $p2->ID); $vp->flushCache(); - $vp = DataObject::get_by_id('SiteTree', $vp->ID); + $vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID); $rp->flushCache(); - $rp = DataObject::get_by_id('SiteTree', $rp->ID); + $rp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $rp->ID); $this->assertFalse((bool)$p2->HasBrokenLink); $this->assertFalse((bool)$vp->HasBrokenLink); $this->assertFalse((bool)$rp->HasBrokenLink); // Publish and confirm that the p2 and RP broken links are fixed on published $this->assertTrue($p->publishRecursive()); - $p2Live = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $p2->ID); - $rpLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $rp->ID); + $p2Live = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $p2->ID); + $rpLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $rp->ID); $this->assertFalse((bool)$p2Live->HasBrokenLink); $this->assertFalse((bool)$rpLive->HasBrokenLink); @@ -273,25 +276,25 @@ class SiteTreeBrokenLinksTest extends SapphireTest { $p->delete(); $vp->flushCache(); - $vp = DataObject::get_by_id('SiteTree', $vp->ID); + $vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID); $p2->flushCache(); - $p2 = DataObject::get_by_id('SiteTree', $p2->ID); + $p2 = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $p2->ID); $rp->flushCache(); - $rp = DataObject::get_by_id('SiteTree', $rp->ID); + $rp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $rp->ID); $this->assertEquals(1, $p2->HasBrokenLink); $this->assertEquals(1, $vp->HasBrokenLink); $this->assertEquals(1, $rp->HasBrokenLink); // Call doRevertToLive and confirm that broken links are restored - $pLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $pID); + $pLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $pID); $pLive->doRevertToLive(); $p2->flushCache(); - $p2 = DataObject::get_by_id('SiteTree', $p2->ID); + $p2 = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $p2->ID); $vp->flushCache(); - $vp = DataObject::get_by_id('SiteTree', $vp->ID); + $vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID); $rp->flushCache(); - $rp = DataObject::get_by_id('SiteTree', $rp->ID); + $rp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $rp->ID); $this->assertFalse((bool)$p2->HasBrokenLink); $this->assertFalse((bool)$vp->HasBrokenLink); $this->assertFalse((bool)$rp->HasBrokenLink); diff --git a/tests/model/SiteTreeHTMLEditorFieldTest.php b/tests/model/SiteTreeHTMLEditorFieldTest.php index 8e0f378c..3f9ad877 100644 --- a/tests/model/SiteTreeHTMLEditorFieldTest.php +++ b/tests/model/SiteTreeHTMLEditorFieldTest.php @@ -1,4 +1,6 @@ objFromFixture('SiteTree', 'home'); + $sitetree = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home'); $editor = new HTMLEditorField('Content'); - $aboutID = $this->idFromFixture('SiteTree', 'about'); - $contactID = $this->idFromFixture('SiteTree', 'contact'); + $aboutID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'about'); + $contactID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'contact'); $editor->setValue("Example Link"); $editor->saveInto($sitetree); @@ -63,7 +65,7 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest { } public function testFileLinkTracking() { - $sitetree = $this->objFromFixture('SiteTree', 'home'); + $sitetree = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home'); $editor = new HTMLEditorField('Content'); $fileID = $this->idFromFixture('File', 'example_file'); @@ -120,7 +122,7 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest { } public function testImageTracking() { - $sitetree = $this->objFromFixture('SiteTree', 'home'); + $sitetree = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home'); $editor = new HTMLEditorField('Content'); $file = $this->objFromFixture('Image', 'example_image'); @@ -156,7 +158,7 @@ class SiteTreeHTMLEditorFieldTest extends FunctionalTest { $editor->setValue(sprintf ( '

    Working Link

    ', - $this->idFromFixture('SiteTree', 'home') + $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home') )); $sitetree->HasBrokenLink = false; $editor->saveInto($sitetree); diff --git a/tests/model/SiteTreeLinkTrackingTest.php b/tests/model/SiteTreeLinkTrackingTest.php index d53549c7..bd16291d 100644 --- a/tests/model/SiteTreeLinkTrackingTest.php +++ b/tests/model/SiteTreeLinkTrackingTest.php @@ -1,5 +1,7 @@ delete(); // Re-fetch the page from the live site - $page = Versioned::get_one_by_stage('SiteTree', 'Live', "\"SiteTree\".\"ID\" = $pageID"); + $page = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', "\"SiteTree\".\"ID\" = $pageID"); // subadmin has edit rights on that page $member = $this->objFromFixture('SilverStripe\\Security\\Member','subadmin'); @@ -124,7 +126,7 @@ class SiteTreePermissionsTest extends FunctionalTest { $page->delete(); // We'll need to resurrect the page from the version cache to test this case - $page = Versioned::get_latest_version('SiteTree', $pageID); + $page = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $pageID); // subadmin had edit rights on that page, but now it's gone $member = $this->objFromFixture('SilverStripe\\Security\\Member','subadmin'); @@ -390,7 +392,7 @@ class SiteTreePermissionsTest extends FunctionalTest { $page->deleteFromStage('Stage'); // Get the live version of the page - $page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID"); + $page = Versioned::get_one_by_stage("SilverStripe\\CMS\\Model\\SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID"); $this->assertTrue(is_object($page), 'Versioned::get_one_by_stage() is returning an object'); // subadmin users diff --git a/tests/model/SiteTreeTest.php b/tests/model/SiteTreeTest.php index 93e0ea7e..06a00e96 100644 --- a/tests/model/SiteTreeTest.php +++ b/tests/model/SiteTreeTest.php @@ -9,6 +9,9 @@ use SilverStripe\ORM\HiddenClass; use SilverStripe\Security\Member; use SilverStripe\Security\Permission; use SilverStripe\Security\Group; +use SilverStripe\CMS\Model\SiteTree; +use SilverStripe\CMS\Model\SiteTreeExtension; + /** * @package cms @@ -47,14 +50,14 @@ class SiteTreeTest extends SapphireTest { // Disable the creation SiteTree::config()->create_default_pages = false; - singleton('SiteTree')->requireDefaultRecords(); + singleton('SilverStripe\\CMS\\Model\\SiteTree')->requireDefaultRecords(); // The table should still be empty $this->assertEquals(DB::query('SELECT COUNT("ID") FROM "SiteTree"')->value(), 0); // Enable the creation SiteTree::config()->create_default_pages = true; - singleton('SiteTree')->requireDefaultRecords(); + singleton('SilverStripe\\CMS\\Model\\SiteTree')->requireDefaultRecords(); // The table should now have three rows (home, about-us, contact-us) $this->assertEquals(DB::query('SELECT COUNT("ID") FROM "SiteTree"')->value(), 3); @@ -127,7 +130,7 @@ class SiteTreeTest extends SapphireTest { $child->Title = 'Page Title'; $child->setParent($parent); - $this->assertInstanceOf("SiteTree", $child->Parent); + $this->assertInstanceOf("SilverStripe\\CMS\\Model\\SiteTree", $child->Parent); $this->assertEquals("Section Title", $child->Parent->Title); } @@ -154,7 +157,7 @@ class SiteTreeTest extends SapphireTest { $oldMode = Versioned::get_reading_mode(); Versioned::set_stage(Versioned::LIVE); - $checkSiteTree = DataObject::get_one("SiteTree", array( + $checkSiteTree = DataObject::get_one("SilverStripe\\CMS\\Model\\SiteTree", array( '"SiteTree"."URLSegment"' => 'get-one-test-page' )); $this->assertEquals("V1", $checkSiteTree->Title); @@ -257,7 +260,7 @@ class SiteTreeTest extends SapphireTest { $page->delete(); $this->assertTrue(!DataObject::get_by_id("Page", $pageID)); - $deletedPage = Versioned::get_latest_version('SiteTree', $pageID); + $deletedPage = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $pageID); $resultPage = $deletedPage->doRestoreToStage(); $requeriedPage = DataObject::get_by_id("Page", $pageID); @@ -276,7 +279,7 @@ class SiteTreeTest extends SapphireTest { // Check that if we restore while on the live site that the content still gets pushed to // stage Versioned::set_stage(Versioned::LIVE); - $deletedPage = Versioned::get_latest_version('SiteTree', $page2ID); + $deletedPage = Versioned::get_latest_version('SilverStripe\\CMS\\Model\\SiteTree', $page2ID); $deletedPage->doRestoreToStage(); $this->assertFalse((bool)Versioned::get_one_by_stage("Page", "Live", "\"SiteTree\".\"ID\" = " . $page2ID)); @@ -292,7 +295,7 @@ class SiteTreeTest extends SapphireTest { $about = $this->objFromFixture('Page', 'about'); $staff = $this->objFromFixture('Page', 'staff'); $product = $this->objFromFixture('Page', 'product1'); - $notFound = $this->objFromFixture('ErrorPage', '404'); + $notFound = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '404'); SiteTree::config()->nested_urls = false; @@ -303,7 +306,7 @@ class SiteTreeTest extends SapphireTest { $this->assertEquals($product->ID, SiteTree::get_by_link($product->Link(), false)->ID); $this->assertEquals($notFound->ID, SiteTree::get_by_link($notFound->Link(), false)->ID); - Config::inst()->update('SiteTree', 'nested_urls', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true); $this->assertEquals($home->ID, SiteTree::get_by_link('/', false)->ID); $this->assertEquals($home->ID, SiteTree::get_by_link('/home/', false)->ID); @@ -321,7 +324,7 @@ class SiteTreeTest extends SapphireTest { $about = $this->objFromFixture('Page', 'about'); $staff = $this->objFromFixture('Page', 'staff'); - Config::inst()->update('SiteTree', 'nested_urls', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true); $this->assertEquals('about-us/', $about->RelativeLink(), 'Matches URLSegment on top level without parameters'); $this->assertEquals('about-us/my-staff/', $staff->RelativeLink(), 'Matches URLSegment plus parent on second level without parameters'); @@ -340,7 +343,7 @@ class SiteTreeTest extends SapphireTest { $parent = $this->objFromFixture('Page', 'about'); $child = $this->objFromFixture('Page', 'staff'); - Config::inst()->update('SiteTree', 'nested_urls', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true); $child->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); $parent->URLSegment = 'changed-on-live'; @@ -354,7 +357,7 @@ class SiteTreeTest extends SapphireTest { } public function testDeleteFromStageOperatesRecursively() { - Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', false); $pageAbout = $this->objFromFixture('Page', 'about'); $pageStaff = $this->objFromFixture('Page', 'staff'); $pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate'); @@ -364,7 +367,7 @@ class SiteTreeTest extends SapphireTest { $this->assertFalse(DataObject::get_by_id('Page', $pageAbout->ID)); $this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page); $this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page); - Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', true); } public function testDeleteFromStageOperatesRecursivelyStrict() { @@ -388,7 +391,7 @@ class SiteTreeTest extends SapphireTest { } public function testDeleteFromLiveOperatesRecursively() { - Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', false); $this->logInWithPermission('ADMIN'); $pageAbout = $this->objFromFixture('Page', 'about'); @@ -408,11 +411,11 @@ class SiteTreeTest extends SapphireTest { $this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page); $this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page); Versioned::set_stage(Versioned::DRAFT); - Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', true); } public function testUnpublishDoesNotDeleteChildrenWithLooseHierachyOn() { - Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', false); $this->logInWithPermission('ADMIN'); $pageAbout = $this->objFromFixture('Page', 'about'); @@ -430,7 +433,7 @@ class SiteTreeTest extends SapphireTest { $this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page); $this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page); Versioned::set_stage(Versioned::DRAFT); - Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'enforce_strict_hierarchy', true); } public function testDeleteFromLiveOperatesRecursivelyStrict() { @@ -509,20 +512,20 @@ class SiteTreeTest extends SapphireTest { public function testCreatePermissions() { // Test logged out users cannot create $this->logOut(); - $this->assertFalse(singleton('SiteTree')->canCreate()); + $this->assertFalse(singleton('SilverStripe\\CMS\\Model\\SiteTree')->canCreate()); // Login with another permission $this->logInWithPermission('DUMMY'); - $this->assertFalse(singleton('SiteTree')->canCreate()); + $this->assertFalse(singleton('SilverStripe\\CMS\\Model\\SiteTree')->canCreate()); // Login with basic CMS permission $perms = SiteConfig::config()->required_permission; $this->logInWithPermission(reset($perms)); - $this->assertTrue(singleton('SiteTree')->canCreate()); + $this->assertTrue(singleton('SilverStripe\\CMS\\Model\\SiteTree')->canCreate()); // Test creation underneath a parent which this user doesn't have access to $parent = $this->objFromFixture('Page', 'about'); - $this->assertFalse(singleton('SiteTree')->canCreate(null, array('Parent' => $parent))); + $this->assertFalse(singleton('SilverStripe\\CMS\\Model\\SiteTree')->canCreate(null, array('Parent' => $parent))); // Test creation underneath a parent which doesn't allow a certain child $parentB = new SiteTreeTest_ClassB(); @@ -632,10 +635,10 @@ class SiteTreeTest extends SapphireTest { public function testLinkShortcodeHandler() { $aboutPage = $this->objFromFixture('Page', 'about'); - $redirectPage = $this->objFromFixture('RedirectorPage', 'external'); + $redirectPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\RedirectorPage', 'external'); $parser = new ShortcodeParser(); - $parser->register('sitetree_link', array('SiteTree', 'link_shortcode_handler')); + $parser->register('sitetree_link', array('SilverStripe\\CMS\\Model\\SiteTree', 'link_shortcode_handler')); $aboutShortcode = sprintf('[sitetree_link,id=%d]', $aboutPage->ID); $aboutEnclosed = sprintf('[sitetree_link,id=%d]Example Content[/sitetree_link]', $aboutPage->ID); @@ -671,7 +674,7 @@ class SiteTreeTest extends SapphireTest { public function testIsCurrent() { $aboutPage = $this->objFromFixture('Page', 'about'); - $errorPage = $this->objFromFixture('ErrorPage', '404'); + $errorPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\ErrorPage', '404'); Director::set_current_page($aboutPage); $this->assertTrue($aboutPage->isCurrent(), 'Assert that basic isSection checks works.'); @@ -683,7 +686,7 @@ class SiteTreeTest extends SapphireTest { Director::set_current_page($aboutPage); $this->assertTrue ( - DataObject::get_one('SiteTree', array( + DataObject::get_one('SilverStripe\\CMS\\Model\\SiteTree', array( '"SiteTree"."Title"' => 'About Us' ))->isCurrent(), 'Assert that isCurrent works on another instance with the same ID.' @@ -783,7 +786,7 @@ class SiteTreeTest extends SapphireTest { $sitetree->URLSegment = 'home'; $this->assertFalse($sitetree->validURLSegment(), 'Conflicts are still recognised with a ParentID value'); - Config::inst()->update('SiteTree', 'nested_urls', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true); $sitetree->ParentID = 0; $sitetree->URLSegment = 'home'; @@ -812,7 +815,7 @@ class SiteTreeTest extends SapphireTest { * @covers SiteTree::validURLSegment */ public function testValidURLSegmentControllerConflicts() { - Config::inst()->update('SiteTree', 'nested_urls', true); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'nested_urls', true); $sitetree = new SiteTree(); $sitetree->ParentID = $this->idFromFixture('SiteTreeTest_Conflicted', 'parent'); @@ -850,13 +853,13 @@ class SiteTreeTest extends SapphireTest { $sitetree->URLSegment = 'brötchen'; $sitetree->write(); - $sitetree = DataObject::get_by_id('SiteTree', $sitetree->ID, false); + $sitetree = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $sitetree->ID, false); $this->assertEquals($sitetree->URLSegment, rawurlencode('brötchen')); $sitetree->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); - $sitetree = DataObject::get_by_id('SiteTree', $sitetree->ID, false); + $sitetree = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $sitetree->ID, false); $this->assertEquals($sitetree->URLSegment, rawurlencode('brötchen')); - $sitetreeLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' .$sitetree->ID, false); + $sitetreeLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' .$sitetree->ID, false); $this->assertEquals($sitetreeLive->URLSegment, rawurlencode('brötchen')); Config::inst()->update('URLSegmentFilter', 'default_allow_multibyte', $origAllow); @@ -891,7 +894,7 @@ class SiteTreeTest extends SapphireTest { public function testPageTypeClasses() { $classes = SiteTree::page_type_classes(); - $this->assertNotContains('SiteTree', $classes, 'Page types do not include base class'); + $this->assertNotContains('SilverStripe\\CMS\\Model\\SiteTree', $classes, 'Page types do not include base class'); $this->assertContains('Page', $classes, 'Page types do contain subclasses'); // Testing what happens in an incorrect config value is set - hide_ancestor should be a string @@ -914,10 +917,10 @@ class SiteTreeTest extends SapphireTest { $allowedChildren = $page->allowedChildren(); $this->assertContains( - 'VirtualPage', + 'SilverStripe\\CMS\\Model\\VirtualPage', $allowedChildren, - 'Includes core subclasses by default' - ); + 'Includes core subclasses by default' + ); $this->assertNotContains( 'SiteTreeTest_ClassE', @@ -949,14 +952,14 @@ class SiteTreeTest extends SapphireTest { // Class name 'SiteTreeTest_ClassA', // Expected - array('SiteTreeTest_ClassB'), + array('SiteTreeTest_ClassB'), // Assertion message - 'Direct setting of allowed children' + 'Direct setting of allowed children' ), array( 'SiteTreeTest_ClassB', - array('SiteTreeTest_ClassC', 'SiteTreeTest_ClassCext'), - 'Includes subclasses' + array('SiteTreeTest_ClassC', 'SiteTreeTest_ClassCext'), + 'Includes subclasses' ), array( 'SiteTreeTest_ClassC', @@ -965,11 +968,11 @@ class SiteTreeTest extends SapphireTest { ), array( 'SiteTreeTest_ClassD', - array('SiteTreeTest_ClassC'), - 'Excludes subclasses if class is prefixed by an asterisk' + array('SiteTreeTest_ClassC'), + 'Excludes subclasses if class is prefixed by an asterisk' ) - ); - } + ); + } public function testAllowedChildrenValidation() { $page = new SiteTree(); @@ -1072,7 +1075,7 @@ class SiteTreeTest extends SapphireTest { } public function testMetaTagGeneratorDisabling() { - $generator = Config::inst()->get('SiteTree', 'meta_generator'); + $generator = Config::inst()->get('SilverStripe\\CMS\\Model\\SiteTree', 'meta_generator'); $page = new SiteTreeTest_PageNode(); @@ -1083,7 +1086,7 @@ class SiteTreeTest extends SapphireTest { 'test default functionality - uses value from Config'); // test proper escaping of quotes in attribute value - Config::inst()->update('SiteTree', 'meta_generator', 'Generator with "quotes" in it'); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'meta_generator', 'Generator with "quotes" in it'); $meta = $page->MetaTags(); $this->assertEquals( 1, @@ -1091,7 +1094,7 @@ class SiteTreeTest extends SapphireTest { 'test proper escaping of values from Config'); // test empty generator - no tag should appear at all - Config::inst()->update('SiteTree', 'meta_generator', ''); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'meta_generator', ''); $meta = $page->MetaTags(); $this->assertEquals( 0, @@ -1099,7 +1102,7 @@ class SiteTreeTest extends SapphireTest { 'test blank value means no tag generated'); // reset original value - Config::inst()->update('SiteTree', 'meta_generator', $generator); + Config::inst()->update('SilverStripe\\CMS\\Model\\SiteTree', 'meta_generator', $generator); } diff --git a/tests/model/VirtualPageTest.php b/tests/model/VirtualPageTest.php index 13caa3a3..9855d558 100644 --- a/tests/model/VirtualPageTest.php +++ b/tests/model/VirtualPageTest.php @@ -7,6 +7,10 @@ use SilverStripe\ORM\DB; use SilverStripe\ORM\ValidationException; use SilverStripe\ORM\FieldType\DBVarchar; use SilverStripe\ORM\DataExtension; +use SilverStripe\CMS\Model\VirtualPage; +use SilverStripe\CMS\Model\SiteTree; +use SilverStripe\CMS\Model\RedirectorPage; + class VirtualPageTest extends FunctionalTest { @@ -40,8 +44,8 @@ class VirtualPageTest extends FunctionalTest { $this->logInWithPermission("ADMIN"); // Add extra fields - Config::inst()->update('VirtualPage', 'initially_copied_fields', array('MyInitiallyCopiedField')); - Config::inst()->update('VirtualPage', 'non_virtual_fields', array('MyNonVirtualField', 'MySharedNonVirtualField')); + Config::inst()->update('SilverStripe\\CMS\\Model\\VirtualPage', 'initially_copied_fields', array('MyInitiallyCopiedField')); + Config::inst()->update('SilverStripe\\CMS\\Model\\VirtualPage', 'non_virtual_fields', array('MyNonVirtualField', 'MySharedNonVirtualField')); } /** @@ -55,8 +59,8 @@ class VirtualPageTest extends FunctionalTest { $master->Content = "

    New content

    "; $master->write(); - $vp1 = $this->objFromFixture('VirtualPage', 'vp1'); - $vp2 = $this->objFromFixture('VirtualPage', 'vp2'); + $vp1 = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp1'); + $vp2 = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp2'); $this->assertEquals("New title", $vp1->Title); $this->assertEquals("New title", $vp2->Title); @@ -81,16 +85,16 @@ class VirtualPageTest extends FunctionalTest { $master->Content = "

    New content

    "; $master->write(); - $vp1 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp1')); - $vp2 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp2')); + $vp1 = DataObject::get_by_id("SilverStripe\\CMS\\Model\\VirtualPage", $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp1')); + $vp2 = DataObject::get_by_id("SilverStripe\\CMS\\Model\\VirtualPage", $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp2')); $this->assertTrue($vp1->publishRecursive()); $this->assertTrue($vp2->publishRecursive()); $master->publishRecursive(); Versioned::set_stage(Versioned::LIVE); - $vp1 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp1')); - $vp2 = DataObject::get_by_id("VirtualPage", $this->idFromFixture('VirtualPage', 'vp2')); + $vp1 = DataObject::get_by_id("SilverStripe\\CMS\\Model\\VirtualPage", $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp1')); + $vp2 = DataObject::get_by_id("SilverStripe\\CMS\\Model\\VirtualPage", $this->idFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp2')); $this->assertNotNull($vp1); $this->assertNotNull($vp2); @@ -148,13 +152,13 @@ class VirtualPageTest extends FunctionalTest { // The draft content of the virtual page should say 'draft content' /** @var VirtualPage $vpDraft */ - $vpDraft = Versioned::get_by_stage("VirtualPage", Versioned::DRAFT)->byID($vp->ID); + $vpDraft = Versioned::get_by_stage("SilverStripe\\CMS\\Model\\VirtualPage", Versioned::DRAFT)->byID($vp->ID); $this->assertEquals('draft content', $vpDraft->CopyContentFrom()->Content); $this->assertEquals('draft content', $vpDraft->Content); // The published content of the virtual page should say 'published content' /** @var VirtualPage $vpLive */ - $vpLive = Versioned::get_by_stage("VirtualPage", Versioned::LIVE)->byID($vp->ID); + $vpLive = Versioned::get_by_stage("SilverStripe\\CMS\\Model\\VirtualPage", Versioned::LIVE)->byID($vp->ID); $this->assertEquals('published content', $vpLive->CopyContentFrom()->Content); $this->assertEquals('published content', $vpLive->Content); @@ -162,7 +166,7 @@ class VirtualPageTest extends FunctionalTest { $vpDraft->publishRecursive(); // Everything is published live - $vpLive = Versioned::get_by_stage("VirtualPage", Versioned::LIVE)->byID($vp->ID); + $vpLive = Versioned::get_by_stage("SilverStripe\\CMS\\Model\\VirtualPage", Versioned::LIVE)->byID($vp->ID); $this->assertEquals('draft content', $vpLive->CopyContentFrom()->Content); $this->assertEquals('draft content', $vpLive->Content); } @@ -205,7 +209,7 @@ class VirtualPageTest extends FunctionalTest { // Delete the source page semi-manually, without triggering // the cascade publish back to the virtual page. Versioned::set_stage(Versioned::LIVE); - $livePage = Versioned::get_by_stage('SiteTree', Versioned::LIVE)->byID($pID); + $livePage = Versioned::get_by_stage('SilverStripe\\CMS\\Model\\SiteTree', Versioned::LIVE)->byID($pID); $livePage->delete(); Versioned::set_stage(Versioned::DRAFT); @@ -228,7 +232,7 @@ class VirtualPageTest extends FunctionalTest { public function testCanEdit() { $parentPage = $this->objFromFixture('Page', 'master3'); - $virtualPage = $this->objFromFixture('VirtualPage', 'vp3'); + $virtualPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp3'); $bob = $this->objFromFixture('SilverStripe\\Security\\Member', 'bob'); $andrew = $this->objFromFixture('SilverStripe\\Security\\Member', 'andrew'); @@ -246,7 +250,7 @@ class VirtualPageTest extends FunctionalTest { public function testCanView() { $parentPage = $this->objFromFixture('Page', 'master3'); $parentPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); - $virtualPage = $this->objFromFixture('VirtualPage', 'vp3'); + $virtualPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\VirtualPage', 'vp3'); $virtualPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); $cindy = $this->objFromFixture('SilverStripe\\Security\\Member', 'cindy'); $alice = $this->objFromFixture('SilverStripe\\Security\\Member', 'alice'); @@ -329,16 +333,16 @@ class VirtualPageTest extends FunctionalTest { // The draft VP still has the CopyContentFromID link $vp->flushCache(); - $vp = DataObject::get_by_id('SiteTree', $vp->ID); + $vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID); $this->assertEquals($p->ID, $vp->CopyContentFromID); - $vpLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $vp->ID); + $vpLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $vp->ID); $this->assertNull($vpLive); // Delete from draft, confirm that the virtual page has a broken link on the draft site $p->delete(); $vp->flushCache(); - $vp = DataObject::get_by_id('SiteTree', $vp->ID); + $vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID); $this->assertEquals(1, $vp->HasBrokenLink); } @@ -360,19 +364,19 @@ class VirtualPageTest extends FunctionalTest { $pID = $p->ID; $p->delete(); $vp->flushCache(); - $vp = DataObject::get_by_id('SiteTree', $vp->ID); + $vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID); $this->assertEquals(1, $vp->HasBrokenLink); // Delete the source page form live, confirm that the virtual page has also been unpublished - $pLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $pID); + $pLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $pID); $this->assertTrue($pLive->doUnpublish()); - $vpLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' . $vp->ID); + $vpLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree"."ID" = ' . $vp->ID); $this->assertNull($vpLive); // Delete from draft, confirm that the virtual page has a broken link on the draft site $pLive->delete(); $vp->flushCache(); - $vp = DataObject::get_by_id('SiteTree', $vp->ID); + $vp = DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $vp->ID); $this->assertEquals(1, $vp->HasBrokenLink); } @@ -465,7 +469,7 @@ class VirtualPageTest extends FunctionalTest { $virtual->CopyContentFromID = $page->ID; $virtual->write(); - $virtual = DataObject::get_by_id('VirtualPage', $virtual->ID, false); + $virtual = DataObject::get_by_id('SilverStripe\\CMS\\Model\\VirtualPage', $virtual->ID, false); $virtual->CopyContentFromID = $notRootPage->ID; $virtual->flushCache(); @@ -505,7 +509,7 @@ class VirtualPageTest extends FunctionalTest { $nonVirtual->write(); // not publishing the page type change here // Stage record is changed to the new type and no longer acts as a virtual page - $nonVirtualStage = Versioned::get_one_by_stage('SiteTree', 'Stage', '"SiteTree"."ID" = ' . $nonVirtual->ID, false); + $nonVirtualStage = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Stage', '"SiteTree"."ID" = ' . $nonVirtual->ID, false); $this->assertNotNull($nonVirtualStage); $this->assertEquals('VirtualPageTest_ClassA', $nonVirtualStage->ClassName); $this->assertEquals('changed on new type', $nonVirtualStage->MySharedNonVirtualField); @@ -514,7 +518,7 @@ class VirtualPageTest extends FunctionalTest { ); // Virtual page on live keeps working as it should - $virtualLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree_Live"."ID" = ' . $virtual->ID, false); + $virtualLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree_Live"."ID" = ' . $virtual->ID, false); $this->assertNotNull($virtualLive); $this->assertEquals('VirtualPageTest_VirtualPageSub', $virtualLive->ClassName); $this->assertEquals('virtual published field', $virtualLive->MySharedNonVirtualField); @@ -527,7 +531,7 @@ class VirtualPageTest extends FunctionalTest { $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); // Virtual page only notices changes to virtualised fields (Title) - $virtualLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree_Live"."ID" = ' . $virtual->ID, false); + $virtualLive = Versioned::get_one_by_stage('SilverStripe\\CMS\\Model\\SiteTree', 'Live', '"SiteTree_Live"."ID" = ' . $virtual->ID, false); $this->assertEquals('virtual published field', $virtualLive->MySharedNonVirtualField); $this->assertEquals('title changed on original', $virtualLive->Title); } @@ -585,7 +589,7 @@ class VirtualPageTest extends FunctionalTest { } public function testVirtualPagePointingToRedirectorPage() { - if (!class_exists('RedirectorPage')) { + if (!class_exists('SilverStripe\\CMS\\Model\\RedirectorPage')) { $this->markTestSkipped('RedirectorPage required'); } @@ -674,6 +678,6 @@ class VirtualPageTest_PageExtension extends DataExtension implements TestOnly { class VirtualPageTest_PageWithAllowedChildren extends Page implements TestOnly { private static $allowed_children = array( 'VirtualPageTest_ClassA', - 'VirtualPage' + 'SilverStripe\\CMS\\Model\\VirtualPage' ); } diff --git a/tests/reports/CmsReportsTest.php b/tests/reports/CmsReportsTest.php index 6c851e66..98825a2c 100644 --- a/tests/reports/CmsReportsTest.php +++ b/tests/reports/CmsReportsTest.php @@ -2,6 +2,14 @@ use SilverStripe\ORM\DB; use SilverStripe\ORM\FieldType\DBDatetime; +use SilverStripe\CMS\Reports\RecentlyEditedReport; +use SilverStripe\CMS\Reports\BrokenLinksReport; +use SilverStripe\CMS\Reports\BrokenFilesReport; +use SilverStripe\CMS\Model\VirtualPage; +use SilverStripe\CMS\Reports\BrokenVirtualPagesReport; +use SilverStripe\CMS\Model\RedirectorPage; +use SilverStripe\CMS\Reports\BrokenRedirectorPagesReport; + /** * @package cms @@ -20,8 +28,8 @@ class CmsReportsTest extends SapphireTest { $afterThreshold = strtotime('-'.(self::$daysAgo-1).' days', strtotime('31-06-2009 00:00:00')); $beforeThreshold = strtotime('-'.(self::$daysAgo+1).' days', strtotime('31-06-2009 00:00:00')); - $after = $this->objFromFixture('SiteTree', 'after'); - $before = $this->objFromFixture('SiteTree', 'before'); + $after = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'after'); + $before = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'before'); DB::query("UPDATE \"SiteTree\" SET \"Created\"='2009-01-01 00:00:00', \"LastEdited\"='".date('Y-m-d H:i:s', $afterThreshold)."' WHERE \"ID\"='".$after->ID."'"); DB::query("UPDATE \"SiteTree\" SET \"Created\"='2009-01-01 00:00:00', \"LastEdited\"='".date('Y-m-d H:i:s', $beforeThreshold)."' WHERE \"ID\"='".$before->ID."'"); @@ -53,8 +61,8 @@ class CmsReportsTest extends SapphireTest { public function testRecentlyEdited() { DBDatetime::set_mock_now('31-06-2009 00:00:00'); - $after = $this->objFromFixture('SiteTree', 'after'); - $before = $this->objFromFixture('SiteTree', 'before'); + $after = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'after'); + $before = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'before'); $r = new RecentlyEditedReport(); diff --git a/tests/search/CMSMainSearchFormTest.php b/tests/search/CMSMainSearchFormTest.php index 3ab9ddc6..2d5179d1 100644 --- a/tests/search/CMSMainSearchFormTest.php +++ b/tests/search/CMSMainSearchFormTest.php @@ -11,7 +11,7 @@ class CMSMainSearchFormTest extends FunctionalTest { http_build_query(array( 'q' => array( 'Title' => 'Page 10', - 'FilterClass' => 'CMSSiteTreeFilter_Search', + 'FilterClass' => 'SilverStripe\\CMS\\Controllers\\CMSSiteTreeFilter_Search', ), 'action_doSearch' => true )) diff --git a/tests/search/SearchFormTest.php b/tests/search/SearchFormTest.php index fa9ed170..3b7e8c89 100644 --- a/tests/search/SearchFormTest.php +++ b/tests/search/SearchFormTest.php @@ -4,6 +4,9 @@ use SilverStripe\ORM\DB; use SilverStripe\ORM\Versioning\Versioned; use SilverStripe\MSSQL\MSSQLDatabase; use SilverStripe\PostgreSQL\PostgreSQLDatabase; +use SilverStripe\CMS\Controllers\ContentController; +use SilverStripe\CMS\Search\SearchForm; + /** @@ -43,7 +46,7 @@ class ZZZSearchFormTest extends FunctionalTest { public function setUp() { parent::setUp(); - $holderPage = $this->objFromFixture('SiteTree', 'searchformholder'); + $holderPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'searchformholder'); $this->mockController = new ContentController($holderPage); $this->waitUntilIndexingFinished(); @@ -66,7 +69,7 @@ class ZZZSearchFormTest extends FunctionalTest { public function testSearchFormTemplateCanBeChanged() { if(!$this->checkFulltextSupport()) return; - $sf = new SearchForm($this->mockController, 'SearchForm'); + $sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm'); $sf->setTemplate('BlankPage'); @@ -79,9 +82,9 @@ class ZZZSearchFormTest extends FunctionalTest { public function testPublishedPagesMatchedByTitle() { if(!$this->checkFulltextSupport()) return; - $sf = new SearchForm($this->mockController, 'SearchForm'); + $sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm'); - $publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage'); + $publishedPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'publicPublishedPage'); $publishedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); $this->waitUntilIndexingFinished(); @@ -96,9 +99,9 @@ class ZZZSearchFormTest extends FunctionalTest { public function testDoubleQuotesPublishedPagesMatchedByTitle() { if(!$this->checkFulltextSupport()) return; - $sf = new SearchForm($this->mockController, 'SearchForm'); + $sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm'); - $publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage'); + $publishedPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'publicPublishedPage'); $publishedPage->Title = "finding butterflies"; $publishedPage->write(); $publishedPage->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); @@ -115,10 +118,10 @@ class ZZZSearchFormTest extends FunctionalTest { public function testUnpublishedPagesNotIncluded() { if(!$this->checkFulltextSupport()) return; - $sf = new SearchForm($this->mockController, 'SearchForm'); + $sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm'); $results = $sf->getResults(null, array('Search'=>'publicUnpublishedPage')); - $unpublishedPage = $this->objFromFixture('SiteTree', 'publicUnpublishedPage'); + $unpublishedPage = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'publicUnpublishedPage'); $this->assertNotContains( $unpublishedPage->ID, $results->column('ID'), @@ -129,9 +132,9 @@ class ZZZSearchFormTest extends FunctionalTest { public function testPagesRestrictedToLoggedinUsersNotIncluded() { if(!$this->checkFulltextSupport()) return; - $sf = new SearchForm($this->mockController, 'SearchForm'); + $sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm'); - $page = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers'); + $page = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'restrictedViewLoggedInUsers'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); $results = $sf->getResults(null, array('Search'=>'restrictedViewLoggedInUsers')); $this->assertNotContains( @@ -154,9 +157,9 @@ class ZZZSearchFormTest extends FunctionalTest { public function testPagesRestrictedToSpecificGroupNotIncluded() { if(!$this->checkFulltextSupport()) return; - $sf = new SearchForm($this->mockController, 'SearchForm'); + $sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm'); - $page = $this->objFromFixture('SiteTree', 'restrictedViewOnlyWebsiteUsers'); + $page = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'restrictedViewOnlyWebsiteUsers'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); $results = $sf->getResults(null, array('Search'=>'restrictedViewOnlyWebsiteUsers')); $this->assertNotContains( @@ -187,12 +190,12 @@ class ZZZSearchFormTest extends FunctionalTest { } public function testInheritedRestrictedPagesNotIncluded() { - $sf = new SearchForm($this->mockController, 'SearchForm'); + $sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm'); - $parent = $this->objFromFixture('SiteTree', 'restrictedViewLoggedInUsers'); + $parent = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'restrictedViewLoggedInUsers'); $parent->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); - $page = $this->objFromFixture('SiteTree', 'inheritRestrictedView'); + $page = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'inheritRestrictedView'); $page->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); $results = $sf->getResults(null, array('Search'=>'inheritRestrictedView')); $this->assertNotContains( @@ -215,9 +218,9 @@ class ZZZSearchFormTest extends FunctionalTest { public function testDisabledShowInSearchFlagNotIncludedForSiteTree() { if(!$this->checkFulltextSupport()) return; - $sf = new SearchForm($this->mockController, 'SearchForm'); + $sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm'); - $page = $this->objFromFixture('SiteTree', 'dontShowInSearchPage'); + $page = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'dontShowInSearchPage'); $results = $sf->getResults(null, array('Search'=>'dontShowInSearchPage')); $this->assertNotContains( $page->ID, @@ -229,7 +232,7 @@ class ZZZSearchFormTest extends FunctionalTest { public function testDisabledShowInSearchFlagNotIncludedForFiles() { if(!$this->checkFulltextSupport()) return; - $sf = new SearchForm($this->mockController, 'SearchForm'); + $sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm'); $dontShowInSearchFile = $this->objFromFixture('File', 'dontShowInSearchFile'); $dontShowInSearchFile->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); @@ -258,9 +261,9 @@ class ZZZSearchFormTest extends FunctionalTest { $this->markTestSkipped("PostgreSQLDatabase doesn't support entity-encoded searches"); } - $sf = new SearchForm($this->mockController, 'SearchForm'); + $sf = new SearchForm($this->mockController, 'SilverStripe\\CMS\\Search\\SearchForm'); - $pageWithSpecialChars = $this->objFromFixture('SiteTree', 'pageWithSpecialChars'); + $pageWithSpecialChars = $this->objFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'pageWithSpecialChars'); $pageWithSpecialChars->copyVersionToStage(Versioned::DRAFT, Versioned::LIVE); $results = $sf->getResults(null, array('Search'=>'Brötchen')); diff --git a/tests/tasks/MigrateSiteTreeLinkingTaskTest.php b/tests/tasks/MigrateSiteTreeLinkingTaskTest.php index f0167c35..7e940940 100644 --- a/tests/tasks/MigrateSiteTreeLinkingTaskTest.php +++ b/tests/tasks/MigrateSiteTreeLinkingTaskTest.php @@ -25,11 +25,11 @@ class MigrateSiteTreeLinkingTaskTest extends SapphireTest { ); ob_end_clean(); - $homeID = $this->idFromFixture('SiteTree', 'home'); - $aboutID = $this->idFromFixture('SiteTree', 'about'); - $staffID = $this->idFromFixture('SiteTree', 'staff'); - $actionID = $this->idFromFixture('SiteTree', 'action'); - $hashID = $this->idFromFixture('SiteTree', 'hash_link'); + $homeID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'home'); + $aboutID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'about'); + $staffID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'staff'); + $actionID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'action'); + $hashID = $this->idFromFixture('SilverStripe\\CMS\\Model\\SiteTree', 'hash_link'); $homeContent = sprintf ( 'AboutStaffExternal Link', @@ -57,25 +57,25 @@ class MigrateSiteTreeLinkingTaskTest extends SapphireTest { $this->assertEquals ( $homeContent, - DataObject::get_by_id('SiteTree', $homeID)->Content, + DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $homeID)->Content, 'HTML URLSegment links are rewritten.' ); $this->assertEquals ( $aboutContent, - DataObject::get_by_id('SiteTree', $aboutID)->Content + DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $aboutID)->Content ); $this->assertEquals ( $staffContent, - DataObject::get_by_id('SiteTree', $staffID)->Content + DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $staffID)->Content ); $this->assertEquals ( $actionContent, - DataObject::get_by_id('SiteTree', $actionID)->Content, + DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $actionID)->Content, 'Links to actions on pages are rewritten correctly.' ); $this->assertEquals ( $hashLinkContent, - DataObject::get_by_id('SiteTree', $hashID)->Content, + DataObject::get_by_id('SilverStripe\\CMS\\Model\\SiteTree', $hashID)->Content, 'Hash/anchor links are correctly handled.' ); } From 4dfa4f447332432da34796b613b94b1306ca9231 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Wed, 10 Aug 2016 16:08:39 +1200 Subject: [PATCH 3/3] Resolve issues with namespacing --- .upgrade.yml | 6 +- _config.php | 16 +- _config/adminpanels.yml | 2 +- _config/config.yml | 8 +- _config/injector.yml | 6 + _config/legacy.yml | 6 + _config/routes.yml | 8 +- code/Controllers/AssetAdmin.php | 5 +- code/Controllers/CMSMain.php | 91 ++++---- code/Controllers/CMSPageAddController.php | 18 +- code/Controllers/CMSPageEditController.php | 4 +- code/Controllers/CMSPageHistoryController.php | 90 ++++---- .../Controllers/CMSPageSettingsController.php | 4 +- code/Controllers/CMSPagesController.php | 8 +- code/Controllers/CMSSettingsController.php | 20 -- code/Controllers/CMSSiteTreeFilter.php | 23 +- code/Controllers/ContentController.php | 47 +++-- .../ErrorPageControllerExtension.php | 1 - .../LeftAndMainPageIconsExtension.php | 14 +- code/Controllers/ModelAsController.php | 11 +- code/Controllers/OldPageRedirector.php | 16 +- code/Controllers/RootURLController.php | 14 +- code/Controllers/SilverStripeNavigator.php | 6 +- code/Forms/SiteTreeURLSegmentField.php | 11 +- code/Logging/ErrorPageErrorFormatter.php | 2 - code/Model/CurrentPageIdentifier.php | 1 + code/Model/ErrorPage.php | 92 ++++---- code/Model/RedirectorPage.php | 65 +++--- code/Model/SiteTree.php | 199 ++++++++++++------ code/Model/SiteTreeFileExtension.php | 13 +- code/Model/SiteTreeLinkTracking.php | 19 +- code/Model/VirtualPage.php | 4 + code/Tasks/MigrateSiteTreeLinkingTask.php | 5 + code/Tasks/RemoveOrphanedPagesTask.php | 37 +++- code/Tasks/SiteTreeMaintenanceTask.php | 10 + .../features/bootstrap/FeatureContext.php | 3 +- tests/controller/CMSBatchActionsTest.yml | 6 +- tests/controller/CMSMainTest.php | 6 +- tests/controller/CMSMainTest.yml | 2 +- tests/model/ErrorPageTest.yml | 2 +- tests/model/RedirectorPageTest.yml | 6 +- tests/model/SiteTreeBacklinksTest.php | 2 +- tests/model/SiteTreeBrokenLinksTest.yml | 2 +- tests/model/SiteTreeHTMLEditorFieldTest.yml | 2 +- tests/model/SiteTreePermissionsTest.php | 2 +- tests/model/SiteTreeTest.php | 14 +- tests/model/SiteTreeTest.yml | 4 +- tests/model/VirtualPageTest.php | 10 +- tests/model/VirtualPageTest.yml | 2 +- tests/reports/CmsReportsTest.yml | 10 +- tests/search/SearchFormTest.php | 2 +- tests/search/SearchFormTest.yml | 4 +- .../tasks/MigrateSiteTreeLinkingTaskTest.php | 2 + .../tasks/MigrateSiteTreeLinkingTaskTest.yml | 40 ++-- tests/tasks/RemoveOrphanedPagesTaskTest.php | 2 +- tests/tasks/RemoveOrphanedPagesTaskTest.yml | 62 +++--- 56 files changed, 647 insertions(+), 420 deletions(-) create mode 100644 _config/injector.yml create mode 100644 _config/legacy.yml delete mode 100644 code/Controllers/CMSSettingsController.php diff --git a/.upgrade.yml b/.upgrade.yml index c021018b..f2ffe8a6 100644 --- a/.upgrade.yml +++ b/.upgrade.yml @@ -12,7 +12,6 @@ mappings: CMSPageHistoryController: SilverStripe\CMS\Controllers\CMSPageHistoryController CMSPagesController: SilverStripe\CMS\Controllers\CMSPagesController CMSPageSettingsController: SilverStripe\CMS\Controllers\CMSPageSettingsController - CMSSettingsController: SilverStripe\CMS\Controllers\CMSSettingsController CMSSiteTreeFilter: SilverStripe\CMS\Controllers\CMSSiteTreeFilter CMSSiteTreeFilter_PublishedPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_PublishedPages CMSSiteTreeFilter_DeletedPages: SilverStripe\CMS\Controllers\CMSSiteTreeFilter_DeletedPages @@ -26,7 +25,6 @@ mappings: ErrorPageFileExtension: SilverStripe\CMS\Controllers\ErrorPageFileExtension LeftAndMainPageIconsExtension: SilverStripe\CMS\Controllers\LeftAndMainPageIconsExtension ModelAsController: SilverStripe\CMS\Controllers\ModelAsController - NestedController: SilverStripe\CMS\Controllers\NestedController OldPageRedirector: SilverStripe\CMS\Controllers\OldPageRedirector RootURLController: SilverStripe\CMS\Controllers\RootURLController SilverStripeNavigator: SilverStripe\CMS\Controllers\SilverStripeNavigator @@ -35,7 +33,6 @@ mappings: SilverStripeNavigatorItem_StageLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_StageLink SilverStripeNavigatorItem_LiveLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_LiveLink SilverStripeNavigatorItem_ArchiveLink: SilverStripe\CMS\Controllers\SilverStripeNavigatorItem_ArchiveLink - Folder_UnusedAssetsField: SilverStripe\CMS\Forms\Folder_UnusedAssetsField SiteTreeURLSegmentField: SilverStripe\CMS\Forms\SiteTreeURLSegmentField SiteTreeURLSegmentField_Readonly: SilverStripe\CMS\Forms\SiteTreeURLSegmentField_Readonly CurrentPageIdentifier: SilverStripe\CMS\Model\CurrentPageIdentifier @@ -65,3 +62,6 @@ mappings: SideReport_RecentlyEdited: SilverStripe\CMS\Reports\SideReport_RecentlyEdited ContentControllerSearchExtension: SilverStripe\CMS\Search\ContentControllerSearchExtension SearchForm: SilverStripe\CMS\Search\SearchForm + MigrateSiteTreeLinkingTask: SilverStripe\CMS\Tasks\MigrateSiteTreeLinkingTask + RemoveOrphanedPagesTask: SilverStripe\CMS\Tasks\RemoveOrphanedPagesTask + SiteTreeMaintenanceTask: SilverStripe\CMS\Tasks\SiteTreeMaintenanceTask diff --git a/_config.php b/_config.php index 23521d22..c96a49fb 100644 --- a/_config.php +++ b/_config.php @@ -10,16 +10,18 @@ define('CMS_PATH', BASE_PATH . '/' . CMS_DIR); /** * Register the default internal shortcodes. */ -ShortcodeParser::get('default')->register('sitetree_link', array('SilverStripe\\CMS\\Model\\SiteTree', 'link_shortcode_handler')); +ShortcodeParser::get('default')->register( + 'sitetree_link', + array('SilverStripe\\CMS\\Model\\SiteTree', 'link_shortcode_handler') +); File::add_extension('SilverStripe\\CMS\\Model\\SiteTreeFileExtension'); // TODO Remove once we can configure CMSMenu through static, nested configuration files -CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSMain'); -CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSPageEditController'); -CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSPageSettingsController'); -CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController'); -CMSMenu::remove_menu_item('CMSPageReportsController'); -CMSMenu::remove_menu_item('SilverStripe\\CMS\\Controllers\\CMSPageAddController'); +CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSMain'); +CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageEditController'); +CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageSettingsController'); +CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController'); +CMSMenu::remove_menu_class('SilverStripe\\CMS\\Controllers\\CMSPageAddController'); CMSMenu::remove_menu_item("SiteConfigLeftAndMain"); diff --git a/_config/adminpanels.yml b/_config/adminpanels.yml index 61f80591..e1fedb34 100644 --- a/_config/adminpanels.yml +++ b/_config/adminpanels.yml @@ -1,2 +1,2 @@ AdminRootController: - default_panel: 'CMSPagesController' + default_panel: 'SilverStripe\CMS\Controllers\CMSPagesController' diff --git a/_config/config.yml b/_config/config.yml index 03c711e4..0d85794f 100644 --- a/_config/config.yml +++ b/_config/config.yml @@ -1,12 +1,12 @@ LeftAndMain: extensions: - - LeftAndMainPageIconsExtension + - SilverStripe\CMS\Controllers\LeftAndMainPageIconsExtension Controller: extensions: - - ErrorPageControllerExtension + - SilverStripe\CMS\Controllers\ErrorPageControllerExtension Form: extensions: - - ErrorPageControllerExtension + - SilverStripe\CMS\Controllers\ErrorPageControllerExtension File: extensions: - - ErrorPageFileExtension + - SilverStripe\CMS\Controllers\ErrorPageFileExtension diff --git a/_config/injector.yml b/_config/injector.yml new file mode 100644 index 00000000..9ef9fec5 --- /dev/null +++ b/_config/injector.yml @@ -0,0 +1,6 @@ +--- +Name: cmsinjector +--- +Injector: + SiteTreeLinkTracking_Parser: + class: SilverStripe\CMS\Model\SiteTreeLinkTracking_Parser diff --git a/_config/legacy.yml b/_config/legacy.yml new file mode 100644 index 00000000..ed183c24 --- /dev/null +++ b/_config/legacy.yml @@ -0,0 +1,6 @@ +--- +Name: cmslegacy +--- +SilverStripe\ORM\DatabaseAdmin: + classname_value_remapping: + SiteTree: 'SilverStripe\CMS\Model\SiteTree' diff --git a/_config/routes.yml b/_config/routes.yml index 3e6f707f..607ae686 100644 --- a/_config/routes.yml +++ b/_config/routes.yml @@ -5,10 +5,10 @@ After: '#rootroutes' --- Director: rules: - '': 'RootURLController' - 'RemoveOrphanedPagesTask//$Action/$ID/$OtherID': 'RemoveOrphanedPagesTask' - 'SiteTreeMaintenanceTask//$Action/$ID/$OtherID': 'SiteTreeMaintenanceTask' - '$URLSegment//$Action/$ID/$OtherID': 'ModelAsController' + '': 'SilverStripe\CMS\Controllers\RootURLController' + 'RemoveOrphanedPagesTask//$Action/$ID/$OtherID': 'SilverStripe\CMS\Tasks\RemoveOrphanedPagesTask' + 'SiteTreeMaintenanceTask//$Action/$ID/$OtherID': 'SilverStripe\CMS\Tasks\SiteTreeMaintenanceTask' + '$URLSegment//$Action/$ID/$OtherID': 'SilverStripe\CMS\Controllers\ModelAsController' --- Name: legacycmsroutes After: '#adminroutes' diff --git a/code/Controllers/AssetAdmin.php b/code/Controllers/AssetAdmin.php index 6720c1f2..dcf11681 100644 --- a/code/Controllers/AssetAdmin.php +++ b/code/Controllers/AssetAdmin.php @@ -199,7 +199,8 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{ // Remove legacy previewable behaviour. $form->removeExtraClass('cms-previewable'); - $form->Fields()->removeByName('SilverStripe\\CMS\\Controllers\\SilverStripeNavigator'); + /** @skipUpgrade */ + $form->Fields()->removeByName('SilverStripeNavigator'); // File listing $gridFieldConfig = GridFieldConfig::create()->addComponents( @@ -633,7 +634,7 @@ class AssetAdmin extends LeftAndMain implements PermissionProvider{ // The root element should explicitly point to the root node. // Uses session state for current record otherwise. - $items[0]->Link = Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\AssetAdmin')->Link('show'), 0); + $items[0]->Link = Controller::join_links($this->Link('show'), 0); // If a search is in progress, don't show the path if($this->getRequest()->requestVar('q')) { diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php index b40a8f1b..e4eb4992 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -2,7 +2,9 @@ namespace SilverStripe\CMS\Controllers; +use ResetFormAction; use SilverStripe\ORM\FieldType\DBHTMLText; +use SilverStripe\ORM\SS_List; use SilverStripe\ORM\Versioning\Versioned; use SilverStripe\ORM\HiddenClass; use SilverStripe\ORM\ArrayList; @@ -17,6 +19,7 @@ use SilverStripe\Security\PermissionProvider; use LeftAndMain; +use SS_HTTPRequest; use Translatable; use Requirements; use CMSBatchActionHandler; @@ -91,6 +94,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr private static $subitem_class = "SilverStripe\\Security\\Member"; + private static $session_namespace = 'SilverStripe\\CMS\\Controllers\\CMSMain'; + /** * Amount of results showing on a single page. * @@ -230,7 +235,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } public function LinkPages() { - return singleton('SilverStripe\\CMS\\Controllers\\CMSPagesController')->Link(); + return CMSPagesController::singleton()->Link(); } public function LinkPagesWithSearch() { @@ -238,37 +243,43 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } public function LinkTreeView() { - return $this->LinkWithSearch(singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->Link('treeview')); + return $this->LinkWithSearch($this->Link('treeview')); } public function LinkListView() { - return $this->LinkWithSearch(singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->Link('listview')); + return $this->LinkWithSearch($this->Link('listview')); } public function LinkGalleryView() { - return $this->LinkWithSearch(singleton('SilverStripe\\CMS\\Controllers\\CMSMain')->Link('galleryview')); + return $this->LinkWithSearch($this->Link('galleryview')); } public function LinkPageEdit($id = null) { - if(!$id) $id = $this->currentPageID(); + if(!$id) { + $id = $this->currentPageID(); + } return $this->LinkWithSearch( - Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageEditController')->Link('show'), $id) + Controller::join_links(CMSPageEditController::singleton()->Link('show'), $id) ); } public function LinkPageSettings() { if($id = $this->currentPageID()) { return $this->LinkWithSearch( - Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageSettingsController')->Link('show'), $id) + Controller::join_links(CMSPageSettingsController::singleton()->Link('show'), $id) ); + } else { + return null; } } public function LinkPageHistory() { if($id = $this->currentPageID()) { return $this->LinkWithSearch( - Controller::join_links(singleton('SilverStripe\\CMS\\Controllers\\CMSPageHistoryController')->Link('show'), $id) + Controller::join_links(CMSPageHistoryController::singleton()->Link('show'), $id) ); + } else { + return null; } } @@ -287,7 +298,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } public function LinkPageAdd($extra = null, $placeholders = null) { - $link = singleton("SilverStripe\\CMS\\Controllers\\CMSPageAddController")->Link(); + $link = CMSPageAddController::singleton()->Link(); $this->extend('updateLinkPageAdd', $link); if($extra) { @@ -403,16 +414,18 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr $actions = new FieldList( FormAction::create('doSearch', _t('CMSMain_left_ss.APPLY_FILTER', 'Search')) ->addExtraClass('ss-ui-action-constructive'), - Object::create('ResetFormAction', 'clear', _t('CMSMain_left_ss.CLEAR_FILTER', 'Clear')) + ResetFormAction::create('clear', _t('CMSMain_left_ss.CLEAR_FILTER', 'Clear')) ); // Use