diff --git a/code/controllers/AssetAdmin.php b/code/controllers/AssetAdmin.php index a1884162..3626982a 100644 --- a/code/controllers/AssetAdmin.php +++ b/code/controllers/AssetAdmin.php @@ -8,21 +8,22 @@ */ class AssetAdmin extends LeftAndMain implements PermissionProvider{ - static $url_segment = 'assets'; + private static $url_segment = 'assets'; - static $url_rule = '/$Action/$ID'; + private static $url_rule = '/$Action/$ID'; - static $menu_title = 'Files'; + private static $menu_title = 'Files'; - public static $tree_class = 'Folder'; + private static $tree_class = 'Folder'; /** + * @config * @see Upload->allowedMaxFileSize * @var int */ - public static $allowed_max_file_size; + private static $allowed_max_file_size; - public static $allowed_actions = array( + private static $allowed_actions = array( 'addfolder', 'delete', 'AddForm', @@ -121,8 +122,8 @@ JS // Category filter if(isset($params['AppCategory'])) { - if(isset(File::$app_categories[$params['AppCategory']])) { - $exts = File::$app_categories[$params['AppCategory']]; + if(isset(File::config()->app_categories[$params['AppCategory']])) { + $exts = File::config()->app_categories[$params['AppCategory']]; } else { $exts = array(); } @@ -470,7 +471,7 @@ JS $record->write(); mkdir($record->FullPath); - chmod($record->FullPath, Filesystem::$file_create_mask); + chmod($record->FullPath, Filesystem::config()->file_create_mask); if($parentRecord) { return $this->redirect(Controller::join_links($this->Link('show'), $parentRecord->ID)); diff --git a/code/controllers/CMSFileAddController.php b/code/controllers/CMSFileAddController.php index bcdfe58d..6c41820a 100644 --- a/code/controllers/CMSFileAddController.php +++ b/code/controllers/CMSFileAddController.php @@ -1,11 +1,11 @@ renderWith(array('AssetAdmin_UploadContent')); diff --git a/code/controllers/CMSMain.php b/code/controllers/CMSMain.php index 8efe5e6d..fbe29135 100644 --- a/code/controllers/CMSMain.php +++ b/code/controllers/CMSMain.php @@ -11,23 +11,23 @@ */ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionProvider { - static $url_segment = 'pages'; + private static $url_segment = 'pages'; - static $url_rule = '/$Action/$ID/$OtherID'; + private static $url_rule = '/$Action/$ID/$OtherID'; // Maintain a lower priority than other administration sections // so that Director does not think they are actions of CMSMain - static $url_priority = 39; + private static $url_priority = 39; - static $menu_title = 'Edit Page'; + private static $menu_title = 'Edit Page'; - static $menu_priority = 10; + private static $menu_priority = 10; - static $tree_class = "SiteTree"; + private static $tree_class = "SiteTree"; - static $subitem_class = "Member"; + private static $subitem_class = "Member"; - static $allowed_actions = array( + private static $allowed_actions = array( 'buildbrokenlinks', 'deleteitems', 'DeleteItemsForm', @@ -1125,7 +1125,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } public function BatchActionParameters() { - $batchActions = CMSBatchActionHandler::$batch_actions; + $batchActions = CMSBatchActionHandler::config()->batch_actions; $forms = array(); foreach($batchActions as $urlSegment => $batchAction) { diff --git a/code/controllers/CMSPageAddController.php b/code/controllers/CMSPageAddController.php index 7e392536..3824b661 100644 --- a/code/controllers/CMSPageAddController.php +++ b/code/controllers/CMSPageAddController.php @@ -1,13 +1,13 @@ 'handleAction' ); diff --git a/code/controllers/CMSPageSettingsController.php b/code/controllers/CMSPageSettingsController.php index 9c7c4548..1bae5d9e 100644 --- a/code/controllers/CMSPageSettingsController.php +++ b/code/controllers/CMSPageSettingsController.php @@ -5,11 +5,11 @@ */ class CMSPageSettingsController extends CMSMain { - static $url_segment = 'pages/settings'; - static $url_rule = '/$Action/$ID/$OtherID'; - static $url_priority = 42; - static $required_permission_codes = 'CMS_ACCESS_CMSMain'; - static $session_namespace = 'CMSMain'; + private static $url_segment = 'pages/settings'; + private static $url_rule = '/$Action/$ID/$OtherID'; + private static $url_priority = 42; + private static $required_permission_codes = 'CMS_ACCESS_CMSMain'; + private static $session_namespace = 'CMSMain'; public function getEditForm($id = null, $fields = null) { $record = $this->getRecord($id ? $id : $this->currentPageID()); diff --git a/code/controllers/CMSPagesController.php b/code/controllers/CMSPagesController.php index 1df20395..fa940fa8 100644 --- a/code/controllers/CMSPagesController.php +++ b/code/controllers/CMSPagesController.php @@ -5,12 +5,12 @@ */ class CMSPagesController extends CMSMain { - static $url_segment = 'pages'; - static $url_rule = '/$Action/$ID/$OtherID'; - static $url_priority = 40; - static $menu_title = 'Pages'; - static $required_permission_codes = 'CMS_ACCESS_CMSMain'; - static $session_namespace = 'CMSMain'; + private static $url_segment = 'pages'; + private static $url_rule = '/$Action/$ID/$OtherID'; + private static $url_priority = 40; + private static $menu_title = 'Pages'; + private static $required_permission_codes = 'CMS_ACCESS_CMSMain'; + private static $session_namespace = 'CMSMain'; public function LinkPreview() { return false; diff --git a/code/controllers/CMSSettingsController.php b/code/controllers/CMSSettingsController.php index 338e1bf0..b9ec945c 100644 --- a/code/controllers/CMSSettingsController.php +++ b/code/controllers/CMSSettingsController.php @@ -1,12 +1,12 @@ Theme) { - SSViewer::set_theme($config->Theme); + Config::inst()->update('SSViewer', 'theme', $config->Theme); } } @@ -137,7 +137,7 @@ class ContentController extends Controller { // If nested URLs are enabled, and there is no action handler for the current request then attempt to pass // control to a child controller. This allows for the creation of chains of controllers which correspond to a // nested URL. - if($action && SiteTree::nested_urls() && !$this->hasAction($action)) { + if($action && SiteTree::config()->nested_urls && !$this->hasAction($action)) { // See ModelAdController->getNestedController() for similar logic if(class_exists('Translatable')) Translatable::disable_locale_filter(); // look for a page with this URLSegment diff --git a/code/controllers/ModelAsController.php b/code/controllers/ModelAsController.php index 5aeefc1f..90fa2081 100644 --- a/code/controllers/ModelAsController.php +++ b/code/controllers/ModelAsController.php @@ -95,7 +95,7 @@ class ModelAsController extends Controller implements NestedController { sprintf( '"URLSegment" = \'%s\' %s', Convert::raw2sql(rawurlencode($URLSegment)), - (SiteTree::nested_urls() ? 'AND "ParentID" = 0' : null) + (SiteTree::config()->nested_urls ? 'AND "ParentID" = 0' : null) ) ); if(class_exists('Translatable')) Translatable::enable_locale_filter(); @@ -148,10 +148,10 @@ class ModelAsController extends Controller implements NestedController { static public function find_old_page($URLSegment,$parentID = 0, $ignoreNestedURLs = false) { $URLSegment = Convert::raw2sql(rawurlencode($URLSegment)); - $useParentIDFilter = SiteTree::nested_urls() && $parentID; + $useParentIDFilter = SiteTree::config()->nested_urls && $parentID; // First look for a non-nested page that has a unique URLSegment and can be redirected to. - if(SiteTree::nested_urls()) { + if(SiteTree::config()->nested_urls) { $pages = DataObject::get( 'SiteTree', "\"URLSegment\" = '$URLSegment'" . ($useParentIDFilter ? ' AND "ParentID" = ' . (int)$parentID : '') diff --git a/code/controllers/ReportAdmin.php b/code/controllers/ReportAdmin.php index 21067b78..f1f41808 100644 --- a/code/controllers/ReportAdmin.php +++ b/code/controllers/ReportAdmin.php @@ -13,17 +13,15 @@ */ class ReportAdmin extends LeftAndMain implements PermissionProvider { - static $url_segment = 'reports'; + private static $url_segment = 'reports'; - static $url_rule = '/$ReportClass/$Action'; + private static $url_rule = '/$ReportClass/$Action'; - static $menu_title = 'Reports'; + private static $menu_title = 'Reports'; - static $template_path = null; // defaults to (project)/templates/email - - static $tree_class = 'SS_Report'; + private static $tree_class = 'SS_Report'; - public static $url_handlers = array( + private static $url_handlers = array( '$ReportClass/$Action' => 'handleAction' ); diff --git a/code/controllers/RootURLController.php b/code/controllers/RootURLController.php index e13e419f..d6d70766 100644 --- a/code/controllers/RootURLController.php +++ b/code/controllers/RootURLController.php @@ -11,9 +11,10 @@ class RootURLController extends Controller { protected static $is_at_root = false; /** + * @config * @var string */ - protected static $default_homepage_link = 'home'; + private static $default_homepage_link = 'home'; /** * @var string @@ -49,7 +50,7 @@ class RootURLController extends Controller { ) { self::$cached_homepage_link = $link; } else { - self::$cached_homepage_link = self::get_default_homepage_link(); + self::$cached_homepage_link = Config::inst()->get('RootURLController', 'default_homepage_link'); } } } @@ -61,19 +62,23 @@ class RootURLController extends Controller { * Set the URL Segment used for your homepage when it is created by dev/build. * This allows you to use home page URLs other than the default "home". * + * @deprecated 3.2 Use the "RootURLController.default_homepage_link" config setting instead * @param string $urlsegment the URL segment for your home page */ static public function set_default_homepage_link($urlsegment = "home") { - self::$default_homepage_link = $urlsegment; + Deprecation::notice('3.2', 'Use the "RootURLController.default_homepage_link" config setting instead'); + Config::inst()->update('RootURLController', 'default_homepage_link', $urlsegment); } /** * Gets the link that denotes the homepage if there is not one explicitly defined for this HTTP_HOST value. * + * @deprecated 3.2 Use the "RootURLController.default_homepage_link" config setting instead * @return string */ static public function get_default_homepage_link() { - return self::$default_homepage_link; + Deprecation::notice('3.2', 'Use the "RootURLController.default_homepage_link" config setting instead'); + return Config::inst()->get('RootURLController', 'default_homepage_link'); } /** diff --git a/code/controllers/SilverStripeNavigator.php b/code/controllers/SilverStripeNavigator.php index ae3dabe8..3aff0f0c 100644 --- a/code/controllers/SilverStripeNavigator.php +++ b/code/controllers/SilverStripeNavigator.php @@ -219,7 +219,8 @@ class SilverStripeNavigatorItem extends ViewableData { * @subpackage content */ class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem { - static $priority = 10; + /** @config */ + private static $priority = 10; public function getHTML() { return sprintf( @@ -257,7 +258,8 @@ class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem { * @subpackage content */ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem { - static $priority = 20; + /** @config */ + private static $priority = 20; public function getHTML() { $draftPage = $this->getDraftPage(); @@ -316,7 +318,8 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem { * @subpackage content */ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem { - static $priority = 30; + /** @config */ + private static $priority = 30; public function getHTML() { $livePage = $this->getLivePage(); @@ -369,7 +372,8 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem { * @subpackage content */ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem { - static $priority = 40; + /** @config */ + private static $priority = 40; public function getHTML() { $this->recordLink = $this->record->AbsoluteLink(); diff --git a/code/controllers/StaticExporter.php b/code/controllers/StaticExporter.php index 5462a78a..613f2e76 100644 --- a/code/controllers/StaticExporter.php +++ b/code/controllers/StaticExporter.php @@ -22,7 +22,7 @@ */ class StaticExporter extends Controller { - static $allowed_actions = array( + private static $allowed_actions = array( 'index', 'export', ); @@ -58,7 +58,7 @@ class StaticExporter extends Controller { if(isset($_REQUEST['baseurl'])) { $base = $_REQUEST['baseurl']; if(substr($base,-1) != '/') $base .= '/'; - Director::setBaseURL($base); + Config::inst()->update('Director', 'alternate_base_url', $base); } // setup temporary folders diff --git a/code/forms/SiteTreeURLSegmentField.php b/code/forms/SiteTreeURLSegmentField.php index 0cac40d2..3ff94b1d 100644 --- a/code/forms/SiteTreeURLSegmentField.php +++ b/code/forms/SiteTreeURLSegmentField.php @@ -17,7 +17,7 @@ class SiteTreeURLSegmentField extends TextField { */ protected $helpText, $urlPrefix, $urlSuffix; - static $allowed_actions = array( + private static $allowed_actions = array( 'suggest' ); diff --git a/code/model/ErrorPage.php b/code/model/ErrorPage.php index e40b4e5e..e5603b21 100644 --- a/code/model/ErrorPage.php +++ b/code/model/ErrorPage.php @@ -13,20 +13,21 @@ */ class ErrorPage extends Page { - static $db = array( + private static $db = array( "ErrorCode" => "Int", ); - static $defaults = array( + private static $defaults = array( "ShowInMenus" => 0, "ShowInSearch" => 0 ); - static $allowed_children = array(); - - static $description = 'Custom content for different error cases (e.g. "Page not found")'; + private static $allowed_children = array(); - protected static $static_filepath = ASSETS_PATH; + private static $description = 'Custom content for different error cases (e.g. "Page not found")'; + + /** @config */ + private static $static_filepath = ASSETS_PATH; public function canAddChildren($member = null) { return false; } @@ -204,10 +205,10 @@ class ErrorPage extends Page { parent::doPublish(); // Run the page (reset the theme, it might've been disabled by LeftAndMain::init()) - $oldTheme = SSViewer::current_theme(); - SSViewer::set_theme(SSViewer::current_custom_theme()); + $oldTheme = Config::inst()->get('SSViewer', 'theme'); + Config::inst()->update('SSViewer', 'theme', Config::inst()->get('SSViewer', 'custom_theme')); $response = Director::test(Director::makeRelative($this->Link())); - SSViewer::set_theme($oldTheme); + Config::inst()->update('SSViewer', 'theme', $oldTheme); $errorContent = $response->getBody(); @@ -262,27 +263,31 @@ class ErrorPage extends Page { return singleton('ErrorPage')-> alternateFilepathForErrorcode($statusCode, $locale); } if(class_exists('Translatable') && singleton('SiteTree')->hasExtension('Translatable') && $locale && $locale != Translatable::default_locale()) { - return self::$static_filepath . "/error-{$statusCode}-{$locale}.html"; + return self::config()->static_filepath . "/error-{$statusCode}-{$locale}.html"; } else { - return self::$static_filepath . "/error-{$statusCode}.html"; + return self::config()->static_filepath . "/error-{$statusCode}.html"; } } /** * Set the path where static error files are saved through {@link publish()}. * Defaults to /assets. - * + * + * @deprecated 3.2 Use "ErrorPage.static_file_path" instead * @param string $path */ static public function set_static_filepath($path) { - self::$static_filepath = $path; + Deprecation::notice('3.2', 'Use "ErrorPage.static_file_path" instead'); + self::config()->static_filepath = $path; } /** + * @deprecated 3.2 Use "ErrorPage.static_file_path" instead * @return string */ static public function get_static_filepath() { - return self::$static_filepath; + Deprecation::notice('3.2', 'Use "ErrorPage.static_file_path" instead'); + return self::config()->static_filepath; } } diff --git a/code/model/RedirectorPage.php b/code/model/RedirectorPage.php index 28c201f5..55021b23 100644 --- a/code/model/RedirectorPage.php +++ b/code/model/RedirectorPage.php @@ -6,23 +6,22 @@ * @subpackage content */ class RedirectorPage extends Page { - - static $description = 'Redirects to a different internal page'; + private static $description = 'Redirects to a different internal page'; - static $db = array( + private static $db = array( "RedirectionType" => "Enum('Internal,External','Internal')", "ExternalURL" => "Varchar(2083)" // 2083 is the maximum length of a URL in Internet Explorer. ); - static $defaults = array( + private static $defaults = array( "RedirectionType" => "Internal" ); - static $has_one = array( + private static $has_one = array( "LinkTo" => "SiteTree", ); - static $many_many = array( + private static $many_many = array( ); /** diff --git a/code/model/SiteConfig.php b/code/model/SiteConfig.php index c5e3d89e..c80539de 100644 --- a/code/model/SiteConfig.php +++ b/code/model/SiteConfig.php @@ -7,7 +7,7 @@ * @package cms */ class SiteConfig extends DataObject implements PermissionProvider { - static $db = array( + private static $db = array( "Title" => "Varchar(255)", "Tagline" => "Varchar(255)", "Theme" => "Varchar(255)", @@ -16,16 +16,24 @@ class SiteConfig extends DataObject implements PermissionProvider { "CanCreateTopLevelType" => "Enum('LoggedInUsers, OnlyTheseUsers', 'LoggedInUsers')", ); - static $many_many = array( + private static $many_many = array( "ViewerGroups" => "Group", "EditorGroups" => "Group", "CreateTopLevelGroups" => "Group" ); - protected static $disabled_themes = array(); + /** + * @config + * @var array + */ + private static $disabled_themes = array(); + /** + * @deprecated 3.2 Use the "SiteConfig.disabled_themes" config setting instead + */ static public function disable_theme($theme) { - self::$disabled_themes[$theme] = $theme; + Deprecation::notice('3.2', 'Use the "SiteConfig.disabled_themes" config setting instead'); + Config::inst()->update('SiteConfig', 'disabled_themes', array($theme)); } public function populateDefaults() @@ -132,7 +140,8 @@ class SiteConfig extends DataObject implements PermissionProvider { */ public function getAvailableThemes($baseDir = null) { $themes = SSViewer::get_themes($baseDir); - foreach(self::$disabled_themes as $theme) { + $disabled = (array)$this->config()->disabled_themes; + foreach($disabled as $theme) { if(isset($themes[$theme])) unset($themes[$theme]); } return $themes; diff --git a/code/model/SiteTree.php b/code/model/SiteTree.php index 770f2110..50b5052b 100644 --- a/code/model/SiteTree.php +++ b/code/model/SiteTree.php @@ -26,52 +26,58 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * * Note that this setting is cached when used in the CMS, use the "flush" query parameter to clear it. * + * @config * @var array */ - static $allowed_children = array("SiteTree"); + private static $allowed_children = array("SiteTree"); /** * The default child class for this page. * Note: Value might be cached, see {@link $allowed_chilren}. * + * @config * @var string */ - static $default_child = "Page"; + private static $default_child = "Page"; /** * The default parent class for this page. * Note: Value might be cached, see {@link $allowed_chilren}. * + * @config * @var string */ - static $default_parent = null; + private static $default_parent = null; /** * Controls whether a page can be in the root of the site tree. * Note: Value might be cached, see {@link $allowed_chilren}. * + * @config * @var bool */ - static $can_be_root = true; + private static $can_be_root = true; /** * List of permission codes a user can have to allow a user to create a page of this type. * Note: Value might be cached, see {@link $allowed_chilren}. * + * @config * @var array */ - static $need_permission = null; + private static $need_permission = null; /** * If you extend a class, and don't want to be able to select the old class * in the cms, set this to the old class name. Eg, if you extended Product * to make ImprovedProduct, then you would set $hide_ancestor to Product. * + * @config * @var string */ - static $hide_ancestor = null; + private static $hide_ancestor = null; - static $db = array( + private static $db = array( "URLSegment" => "Varchar(255)", "Title" => "Varchar(255)", "MenuTitle" => "Varchar(100)", @@ -88,27 +94,27 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid "CanEditType" => "Enum('LoggedInUsers, OnlyTheseUsers, Inherit', 'Inherit')", ); - static $indexes = array( + private static $indexes = array( "URLSegment" => true, ); - static $many_many = array( + private static $many_many = array( "LinkTracking" => "SiteTree", "ImageTracking" => "File", "ViewerGroups" => "Group", "EditorGroups" => "Group", ); - static $belongs_many_many = array( + private static $belongs_many_many = array( "BackLinkTracking" => "SiteTree" ); - static $many_many_extraFields = array( + private static $many_many_extraFields = array( "LinkTracking" => array("FieldName" => "Varchar"), "ImageTracking" => array("FieldName" => "Varchar") ); - static $casting = array( + private static $casting = array( "Breadcrumbs" => "HTMLText", "LastEdited" => "SS_Datetime", "Created" => "SS_Datetime", @@ -117,67 +123,64 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid 'AbsoluteLink' => 'Text', ); - static $defaults = array( + private static $defaults = array( "ShowInMenus" => 1, "ShowInSearch" => 1, "CanViewType" => "Inherit", "CanEditType" => "Inherit" ); - static $versioning = array( + private static $versioning = array( "Stage", "Live" ); - static $default_sort = "\"Sort\""; + private static $default_sort = "\"Sort\""; /** * If this is false, the class cannot be created in the CMS by regular content authors, only by ADMINs. * @var boolean + * @config */ - static $can_create = true; - - /** - * @see CMSMain::generateTreeStylingCSS() - */ - static $page_states = array('readonly'); + private static $can_create = true; /** * Icon to use in the CMS page tree. This should be the full filename, relative to the webroot. * Also supports custom CSS rule contents (applied to the correct selector for the tree UI implementation). * * @see CMSMain::generateTreeStylingCSS() - * + * @config * @var string */ - static $icon = null; + private static $icon = null; /** + * @config * @var String Description of the class functionality, typically shown to a user * when selecting which page type to create. Translated through {@link provideI18nEntities()}. */ - static $description = 'Generic content page'; + private static $description = 'Generic content page'; - static $extensions = array( + private static $extensions = array( "Hierarchy", "Versioned('Stage', 'Live')", ); - static $searchable_fields = array( + private static $searchable_fields = array( 'Title', 'Content', ); - static $field_labels = array( + private static $field_labels = array( 'URLSegment' => 'URL' ); /** - * @see SiteTree::nested_urls() + * @config */ private static $nested_urls = true; /** - * @see SiteTree::set_create_default_pages() + * @config */ private static $create_default_pages = true; @@ -192,12 +195,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * of IDs mapped to their boolean permission ability (true=allow, false=deny). * See {@link batch_permission_check()} for details. */ - public static $cache_permissions = array(); + private static $cache_permissions = array(); /** + * @config * @var boolean */ - protected static $enforce_strict_hierarchy = true; + private static $enforce_strict_hierarchy = true; protected $_cache_statusFlags = null; @@ -205,59 +209,77 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * Determines if the system should avoid orphaned pages * by deleting all children when the their parent is deleted (TRUE), * or rather preserve this data even if its not reachable through any navigation path (FALSE). - * + * + * @deprecated 3.2 Use the "SiteTree.enforce_strict_hierarchy" config setting instead * @param boolean */ static public function set_enforce_strict_hierarchy($to) { - self::$enforce_strict_hierarchy = $to; + Deprecation::notice('3.2', 'Use the "SiteTree.enforce_strict_hierarchy" config setting instead'); + Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', $to); } /** + * @deprecated 3.2 Use the "SiteTree.enforce_strict_hierarchy" config setting instead * @return boolean */ static public function get_enforce_strict_hierarchy() { - return self::$enforce_strict_hierarchy; + Deprecation::notice('3.2', 'Use the "SiteTree.enforce_strict_hierarchy" config setting instead'); + return Config::inst()->get('SiteTree', 'enforce_strict_hierarchy'); } /** * Returns TRUE if nested URLs (e.g. page/sub-page/) are currently enabled on this site. * + * @deprecated 3.2 Use the "SiteTree.nested_urls" config setting instead * @return bool */ static public function nested_urls() { - return self::$nested_urls; + Deprecation::notice('3.2', 'Use the "SiteTree.nested_urls" config setting instead'); + return Config::inst()->get('SiteTree', 'nested_urls'); } + /** + * @deprecated 3.2 Use the "SiteTree.nested_urls" config setting instead + */ static public function enable_nested_urls() { - self::$nested_urls = true; + Deprecation::notice('3.2', 'Use the "SiteTree.nested_urls" config setting instead'); + Config::inst()->update('SiteTree', 'nested_urls', true); } + /** + * @deprecated 3.2 Use the "SiteTree.nested_urls" config setting instead + */ static public function disable_nested_urls() { - self::$nested_urls = false; + Deprecation::notice('3.2', 'Use the "SiteTree.nested_urls" config setting instead'); + Config::inst()->update('SiteTree', 'nested_urls', false); } /** * Set the (re)creation of default pages on /dev/build * + * @deprecated 3.2 Use the "SiteTree.create_default_pages" config setting instead * @param bool $option */ static public function set_create_default_pages($option = true) { - self::$create_default_pages = $option; + Deprecation::notice('3.2', 'Use the "SiteTree.create_default_pages" config setting instead'); + Config::inst()->update('SiteTree', 'create_default_pages', $option); } /** * Return true if default pages should be created on /dev/build. * + * @deprecated 3.2 Use the "SiteTree.create_default_pages" config setting instead * @return bool */ static public function get_create_default_pages() { - return self::$create_default_pages; + Deprecation::notice('3.2', 'Use the "SiteTree.create_default_pages" config setting instead'); + return Config::inst()->get('SiteTree', 'create_default_pages'); } /** * Fetches the {@link SiteTree} object that maps to a link. * - * If you have enabled {@link SiteTree::nested_urls()} on this site, then you can use a nested link such as + * If you have enabled {@link SiteTree::config()->nested_urls} on this site, then you can use a nested link such as * "about-us/staff/", and this function will traverse down the URL chain and grab the appropriate link. * * Note that if no model can be found, this method will fall over to a extended alternateGetByLink method provided @@ -279,17 +301,17 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid // Grab the initial root level page to traverse down from. $URLSegment = array_shift($parts); $sitetree = DataObject::get_one ( - 'SiteTree', "\"URLSegment\" = '$URLSegment'" . (self::nested_urls() ? ' AND "ParentID" = 0' : ''), $cache + 'SiteTree', "\"URLSegment\" = '$URLSegment'" . (self::config()->nested_urls ? ' AND "ParentID" = 0' : ''), $cache ); /// Fall back on a unique URLSegment for b/c. - if(!$sitetree && self::nested_urls() && $page = DataObject::get('SiteTree', "\"URLSegment\" = '$URLSegment'")->First()) { + if(!$sitetree && self::config()->nested_urls && $page = DataObject::get('SiteTree', "\"URLSegment\" = '$URLSegment'")->First()) { return $page; } // Attempt to grab an alternative page from extensions. if(!$sitetree) { - $parentID = self::nested_urls() ? 0 : null; + $parentID = self::config()->nested_urls ? 0 : null; if($alternatives = singleton('SiteTree')->extend('alternateGetByLink', $URLSegment, $parentID)) { foreach($alternatives as $alternative) if($alternative) $sitetree = $alternative; @@ -299,7 +321,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid } // Check if we have any more URL parts to parse. - if(!self::nested_urls() || !count($parts)) return $sitetree; + if(!self::config()->nested_urls || !count($parts)) return $sitetree; // Traverse down the remaining URL segments and grab the relevant SiteTree objects. foreach($parts as $segment) { @@ -438,7 +460,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @return string */ public function RelativeLink($action = null) { - if($this->ParentID && self::nested_urls()) { + if($this->ParentID && self::config()->nested_urls) { $base = $this->Parent()->RelativeLink($this->URLSegment); } else { $base = $this->URLSegment; @@ -1275,7 +1297,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $tags .= "\n"; - $charset = ContentNegotiator::get_encoding(); + $charset = Config::inst()->get('ContentNegotiator', 'encoding'); $tags .= "\n"; if($this->MetaDescription) { $tags .= "MetaDescription) . "\" />\n"; @@ -1322,12 +1344,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid parent::requireDefaultRecords(); // default pages - if($this->class == 'SiteTree' && self::get_create_default_pages()) { - if(!SiteTree::get_by_link(RootURLController::get_default_homepage_link())) { + if($this->class == 'SiteTree' && $this->config()->create_default_pages) { + if(!SiteTree::get_by_link(Config::inst()->get('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 tutorials.
'); - $homepage->URLSegment = RootURLController::get_default_homepage_link(); + $homepage->URLSegment = Config::inst()->get('RootURLController', 'default_homepage_link'); $homepage->Sort = 1; $homepage->write(); $homepage->publish('Stage', 'Live'); @@ -1467,7 +1489,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid parent::onBeforeDelete(); // If deleting this page, delete all its children. - if(SiteTree::get_enforce_strict_hierarchy() && $children = $this->Children()) { + if(SiteTree::config()->enforce_strict_hierarchy && $children = $this->Children()) { foreach($children as $child) { $child->delete(); } @@ -1542,20 +1564,20 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid * @return bool */ public function validURLSegment() { - if(self::nested_urls() && $parent = $this->Parent()) { + if(self::config()->nested_urls && $parent = $this->Parent()) { if($controller = ModelAsController::controller_for($parent)) { if($controller instanceof Controller && $controller->hasAction($this->URLSegment)) return false; } } - if(!self::nested_urls() || !$this->ParentID) { + if(!self::config()->nested_urls || !$this->ParentID) { if(class_exists($this->URLSegment) && is_subclass_of($this->URLSegment, 'RequestHandler')) return false; } $IDFilter = ($this->ID) ? "AND \"SiteTree\".\"ID\" <> $this->ID" : null; $parentFilter = null; - if(self::nested_urls()) { + if(self::config()->nested_urls) { if($this->ParentID) { $parentFilter = " AND \"SiteTree\".\"ParentID\" = $this->ParentID"; } else { @@ -1826,13 +1848,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid $baseLink = Controller::join_links ( Director::absoluteBaseURL(), - (self::nested_urls() && $this->ParentID ? $this->Parent()->RelativeLink(true) : null) + (self::config()->nested_urls && $this->ParentID ? $this->Parent()->RelativeLink(true) : null) ); $urlsegment = new SiteTreeURLSegmentField("URLSegment", $this->fieldLabel('URLSegment')); $urlsegment->setURLPrefix($baseLink); - $helpText = (self::nested_urls() && count($this->Children())) ? $this->fieldLabel('LinkChangeNote') : ''; - if(!URLSegmentFilter::$default_allow_multibyte) { + $helpText = (self::config()->nested_urls && count($this->Children())) ? $this->fieldLabel('LinkChangeNote') : ''; + if(!Config::inst()->get('URLSegmentFilter', 'default_allow_multibyte')) { $helpText .= $helpText ? '