API Marked statics private, use Config API instead (#8317)

See "Static configuration properties are now immutable, you must use Config API." in the 3.1 change log for details.
This commit is contained in:
Ingo Schommer 2013-03-18 11:47:15 +01:00
parent 1f14654649
commit 51c8e8639e
55 changed files with 414 additions and 338 deletions

View File

@ -8,21 +8,22 @@
*/ */
class AssetAdmin extends LeftAndMain implements PermissionProvider{ 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 * @see Upload->allowedMaxFileSize
* @var int * @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', 'addfolder',
'delete', 'delete',
'AddForm', 'AddForm',
@ -121,8 +122,8 @@ JS
// Category filter // Category filter
if(isset($params['AppCategory'])) { if(isset($params['AppCategory'])) {
if(isset(File::$app_categories[$params['AppCategory']])) { if(isset(File::config()->app_categories[$params['AppCategory']])) {
$exts = File::$app_categories[$params['AppCategory']]; $exts = File::config()->app_categories[$params['AppCategory']];
} else { } else {
$exts = array(); $exts = array();
} }
@ -470,7 +471,7 @@ JS
$record->write(); $record->write();
mkdir($record->FullPath); mkdir($record->FullPath);
chmod($record->FullPath, Filesystem::$file_create_mask); chmod($record->FullPath, Filesystem::config()->file_create_mask);
if($parentRecord) { if($parentRecord) {
return $this->redirect(Controller::join_links($this->Link('show'), $parentRecord->ID)); return $this->redirect(Controller::join_links($this->Link('show'), $parentRecord->ID));

View File

@ -1,11 +1,11 @@
<?php <?php
class CMSFileAddController extends LeftAndMain { class CMSFileAddController extends LeftAndMain {
static $url_segment = 'assets/add'; private static $url_segment = 'assets/add';
static $url_priority = 60; private static $url_priority = 60;
static $required_permission_codes = 'CMS_ACCESS_AssetAdmin'; private static $required_permission_codes = 'CMS_ACCESS_AssetAdmin';
static $menu_title = 'Files'; private static $menu_title = 'Files';
public static $tree_class = 'Folder'; private static $tree_class = 'Folder';
// public function upload($request) { // public function upload($request) {
// $formHtml = $this->renderWith(array('AssetAdmin_UploadContent')); // $formHtml = $this->renderWith(array('AssetAdmin_UploadContent'));

View File

@ -11,23 +11,23 @@
*/ */
class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionProvider { 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 // Maintain a lower priority than other administration sections
// so that Director does not think they are actions of CMSMain // 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', 'buildbrokenlinks',
'deleteitems', 'deleteitems',
'DeleteItemsForm', 'DeleteItemsForm',
@ -1125,7 +1125,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
} }
public function BatchActionParameters() { public function BatchActionParameters() {
$batchActions = CMSBatchActionHandler::$batch_actions; $batchActions = CMSBatchActionHandler::config()->batch_actions;
$forms = array(); $forms = array();
foreach($batchActions as $urlSegment => $batchAction) { foreach($batchActions as $urlSegment => $batchAction) {

View File

@ -1,13 +1,13 @@
<?php <?php
class CMSPageAddController extends CMSPageEditController { class CMSPageAddController extends CMSPageEditController {
static $url_segment = 'pages/add'; private static $url_segment = 'pages/add';
static $url_rule = '/$Action/$ID/$OtherID'; private static $url_rule = '/$Action/$ID/$OtherID';
static $url_priority = 42; private static $url_priority = 42;
static $menu_title = 'Add page'; private static $menu_title = 'Add page';
static $required_permission_codes = 'CMS_ACCESS_CMSMain'; private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
static $allowed_actions = array( private static $allowed_actions = array(
'AddForm', 'AddForm',
'doAdd', 'doAdd',
); );

View File

@ -5,11 +5,11 @@
*/ */
class CMSPageEditController extends CMSMain { class CMSPageEditController extends CMSMain {
static $url_segment = 'pages/edit'; private static $url_segment = 'pages/edit';
static $url_rule = '/$Action/$ID/$OtherID'; private static $url_rule = '/$Action/$ID/$OtherID';
static $url_priority = 41; private static $url_priority = 41;
static $required_permission_codes = 'CMS_ACCESS_CMSMain'; private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
static $session_namespace = 'CMSMain'; private static $session_namespace = 'CMSMain';
public function Breadcrumbs($unlinked = false) { public function Breadcrumbs($unlinked = false) {
$crumbs = parent::Breadcrumbs($unlinked); $crumbs = parent::Breadcrumbs($unlinked);

View File

@ -6,21 +6,21 @@
*/ */
class CMSPageHistoryController extends CMSMain { class CMSPageHistoryController extends CMSMain {
static $url_segment = 'pages/history'; private static $url_segment = 'pages/history';
static $url_rule = '/$Action/$ID/$VersionID/$OtherVersionID'; private static $url_rule = '/$Action/$ID/$VersionID/$OtherVersionID';
static $url_priority = 42; private static $url_priority = 42;
static $menu_title = 'History'; private static $menu_title = 'History';
static $required_permission_codes = 'CMS_ACCESS_CMSMain'; private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
static $session_namespace = 'CMSMain'; private static $session_namespace = 'CMSMain';
static $allowed_actions = array( private static $allowed_actions = array(
'VersionsForm', 'VersionsForm',
'CompareVersionsForm', 'CompareVersionsForm',
'show', 'show',
'compare' 'compare'
); );
public static $url_handlers = array( private static $url_handlers = array(
'$Action/$ID/$VersionID/$OtherVersionID' => 'handleAction' '$Action/$ID/$VersionID/$OtherVersionID' => 'handleAction'
); );

View File

@ -5,11 +5,11 @@
*/ */
class CMSPageSettingsController extends CMSMain { class CMSPageSettingsController extends CMSMain {
static $url_segment = 'pages/settings'; private static $url_segment = 'pages/settings';
static $url_rule = '/$Action/$ID/$OtherID'; private static $url_rule = '/$Action/$ID/$OtherID';
static $url_priority = 42; private static $url_priority = 42;
static $required_permission_codes = 'CMS_ACCESS_CMSMain'; private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
static $session_namespace = 'CMSMain'; private static $session_namespace = 'CMSMain';
public function getEditForm($id = null, $fields = null) { public function getEditForm($id = null, $fields = null) {
$record = $this->getRecord($id ? $id : $this->currentPageID()); $record = $this->getRecord($id ? $id : $this->currentPageID());

View File

@ -5,12 +5,12 @@
*/ */
class CMSPagesController extends CMSMain { class CMSPagesController extends CMSMain {
static $url_segment = 'pages'; private static $url_segment = 'pages';
static $url_rule = '/$Action/$ID/$OtherID'; private static $url_rule = '/$Action/$ID/$OtherID';
static $url_priority = 40; private static $url_priority = 40;
static $menu_title = 'Pages'; private static $menu_title = 'Pages';
static $required_permission_codes = 'CMS_ACCESS_CMSMain'; private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
static $session_namespace = 'CMSMain'; private static $session_namespace = 'CMSMain';
public function LinkPreview() { public function LinkPreview() {
return false; return false;

View File

@ -1,12 +1,12 @@
<?php <?php
class CMSSettingsController extends LeftAndMain { class CMSSettingsController extends LeftAndMain {
static $url_segment = 'settings'; private static $url_segment = 'settings';
static $url_rule = '/$Action/$ID/$OtherID'; private static $url_rule = '/$Action/$ID/$OtherID';
static $menu_priority = -1; private static $menu_priority = -1;
static $menu_title = 'Settings'; private static $menu_title = 'Settings';
static $tree_class = 'SiteConfig'; private static $tree_class = 'SiteConfig';
static $required_permission_codes = array('EDIT_SITECONFIG'); private static $required_permission_codes = array('EDIT_SITECONFIG');
public function init() { public function init() {
parent::init(); parent::init();

View File

@ -22,7 +22,7 @@ class ContentController extends Controller {
protected $dataRecord; protected $dataRecord;
public static $allowed_actions = array( private static $allowed_actions = array(
'successfullyinstalled', 'successfullyinstalled',
'deleteinstallfiles' // secured through custom code 'deleteinstallfiles' // secured through custom code
); );
@ -119,7 +119,7 @@ class ContentController extends Controller {
// Use theme from the site config // Use theme from the site config
if(($config = SiteConfig::current_site_config()) && $config->Theme) { if(($config = SiteConfig::current_site_config()) && $config->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 // 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 // control to a child controller. This allows for the creation of chains of controllers which correspond to a
// nested URL. // 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 // See ModelAdController->getNestedController() for similar logic
if(class_exists('Translatable')) Translatable::disable_locale_filter(); if(class_exists('Translatable')) Translatable::disable_locale_filter();
// look for a page with this URLSegment // look for a page with this URLSegment

View File

@ -95,7 +95,7 @@ class ModelAsController extends Controller implements NestedController {
sprintf( sprintf(
'"URLSegment" = \'%s\' %s', '"URLSegment" = \'%s\' %s',
Convert::raw2sql(rawurlencode($URLSegment)), 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(); 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) { static public function find_old_page($URLSegment,$parentID = 0, $ignoreNestedURLs = false) {
$URLSegment = Convert::raw2sql(rawurlencode($URLSegment)); $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. // 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( $pages = DataObject::get(
'SiteTree', 'SiteTree',
"\"URLSegment\" = '$URLSegment'" . ($useParentIDFilter ? ' AND "ParentID" = ' . (int)$parentID : '') "\"URLSegment\" = '$URLSegment'" . ($useParentIDFilter ? ' AND "ParentID" = ' . (int)$parentID : '')

View File

@ -13,17 +13,15 @@
*/ */
class ReportAdmin extends LeftAndMain implements PermissionProvider { 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 private static $tree_class = 'SS_Report';
static $tree_class = 'SS_Report';
public static $url_handlers = array( private static $url_handlers = array(
'$ReportClass/$Action' => 'handleAction' '$ReportClass/$Action' => 'handleAction'
); );

View File

@ -11,9 +11,10 @@ class RootURLController extends Controller {
protected static $is_at_root = false; protected static $is_at_root = false;
/** /**
* @config
* @var string * @var string
*/ */
protected static $default_homepage_link = 'home'; private static $default_homepage_link = 'home';
/** /**
* @var string * @var string
@ -49,7 +50,7 @@ class RootURLController extends Controller {
) { ) {
self::$cached_homepage_link = $link; self::$cached_homepage_link = $link;
} else { } 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. * 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". * 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 * @param string $urlsegment the URL segment for your home page
*/ */
static public function set_default_homepage_link($urlsegment = "home") { 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. * 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 * @return string
*/ */
static public function get_default_homepage_link() { 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');
} }
/** /**

View File

@ -219,7 +219,8 @@ class SilverStripeNavigatorItem extends ViewableData {
* @subpackage content * @subpackage content
*/ */
class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem { class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem {
static $priority = 10; /** @config */
private static $priority = 10;
public function getHTML() { public function getHTML() {
return sprintf( return sprintf(
@ -257,7 +258,8 @@ class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem {
* @subpackage content * @subpackage content
*/ */
class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem { class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem {
static $priority = 20; /** @config */
private static $priority = 20;
public function getHTML() { public function getHTML() {
$draftPage = $this->getDraftPage(); $draftPage = $this->getDraftPage();
@ -316,7 +318,8 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem {
* @subpackage content * @subpackage content
*/ */
class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem { class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem {
static $priority = 30; /** @config */
private static $priority = 30;
public function getHTML() { public function getHTML() {
$livePage = $this->getLivePage(); $livePage = $this->getLivePage();
@ -369,7 +372,8 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem {
* @subpackage content * @subpackage content
*/ */
class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem { class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
static $priority = 40; /** @config */
private static $priority = 40;
public function getHTML() { public function getHTML() {
$this->recordLink = $this->record->AbsoluteLink(); $this->recordLink = $this->record->AbsoluteLink();

View File

@ -22,7 +22,7 @@
*/ */
class StaticExporter extends Controller { class StaticExporter extends Controller {
static $allowed_actions = array( private static $allowed_actions = array(
'index', 'index',
'export', 'export',
); );
@ -58,7 +58,7 @@ class StaticExporter extends Controller {
if(isset($_REQUEST['baseurl'])) { if(isset($_REQUEST['baseurl'])) {
$base = $_REQUEST['baseurl']; $base = $_REQUEST['baseurl'];
if(substr($base,-1) != '/') $base .= '/'; if(substr($base,-1) != '/') $base .= '/';
Director::setBaseURL($base); Config::inst()->update('Director', 'alternate_base_url', $base);
} }
// setup temporary folders // setup temporary folders

View File

@ -17,7 +17,7 @@ class SiteTreeURLSegmentField extends TextField {
*/ */
protected $helpText, $urlPrefix, $urlSuffix; protected $helpText, $urlPrefix, $urlSuffix;
static $allowed_actions = array( private static $allowed_actions = array(
'suggest' 'suggest'
); );

View File

@ -13,20 +13,21 @@
*/ */
class ErrorPage extends Page { class ErrorPage extends Page {
static $db = array( private static $db = array(
"ErrorCode" => "Int", "ErrorCode" => "Int",
); );
static $defaults = array( private static $defaults = array(
"ShowInMenus" => 0, "ShowInMenus" => 0,
"ShowInSearch" => 0 "ShowInSearch" => 0
); );
static $allowed_children = array(); private static $allowed_children = array();
static $description = 'Custom content for different error cases (e.g. "Page not found")';
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; } public function canAddChildren($member = null) { return false; }
@ -204,10 +205,10 @@ class ErrorPage extends Page {
parent::doPublish(); parent::doPublish();
// Run the page (reset the theme, it might've been disabled by LeftAndMain::init()) // Run the page (reset the theme, it might've been disabled by LeftAndMain::init())
$oldTheme = SSViewer::current_theme(); $oldTheme = Config::inst()->get('SSViewer', 'theme');
SSViewer::set_theme(SSViewer::current_custom_theme()); Config::inst()->update('SSViewer', 'theme', Config::inst()->get('SSViewer', 'custom_theme'));
$response = Director::test(Director::makeRelative($this->Link())); $response = Director::test(Director::makeRelative($this->Link()));
SSViewer::set_theme($oldTheme); Config::inst()->update('SSViewer', 'theme', $oldTheme);
$errorContent = $response->getBody(); $errorContent = $response->getBody();
@ -262,27 +263,31 @@ class ErrorPage extends Page {
return singleton('ErrorPage')-> alternateFilepathForErrorcode($statusCode, $locale); return singleton('ErrorPage')-> alternateFilepathForErrorcode($statusCode, $locale);
} }
if(class_exists('Translatable') && singleton('SiteTree')->hasExtension('Translatable') && $locale && $locale != Translatable::default_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 { } 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()}. * Set the path where static error files are saved through {@link publish()}.
* Defaults to /assets. * Defaults to /assets.
* *
* @deprecated 3.2 Use "ErrorPage.static_file_path" instead
* @param string $path * @param string $path
*/ */
static public function set_static_filepath($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 * @return string
*/ */
static public function get_static_filepath() { 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;
} }
} }

View File

@ -6,23 +6,22 @@
* @subpackage content * @subpackage content
*/ */
class RedirectorPage extends Page { class RedirectorPage extends Page {
private static $description = 'Redirects to a different internal page';
static $description = 'Redirects to a different internal page';
static $db = array( private static $db = array(
"RedirectionType" => "Enum('Internal,External','Internal')", "RedirectionType" => "Enum('Internal,External','Internal')",
"ExternalURL" => "Varchar(2083)" // 2083 is the maximum length of a URL in Internet Explorer. "ExternalURL" => "Varchar(2083)" // 2083 is the maximum length of a URL in Internet Explorer.
); );
static $defaults = array( private static $defaults = array(
"RedirectionType" => "Internal" "RedirectionType" => "Internal"
); );
static $has_one = array( private static $has_one = array(
"LinkTo" => "SiteTree", "LinkTo" => "SiteTree",
); );
static $many_many = array( private static $many_many = array(
); );
/** /**

View File

@ -7,7 +7,7 @@
* @package cms * @package cms
*/ */
class SiteConfig extends DataObject implements PermissionProvider { class SiteConfig extends DataObject implements PermissionProvider {
static $db = array( private static $db = array(
"Title" => "Varchar(255)", "Title" => "Varchar(255)",
"Tagline" => "Varchar(255)", "Tagline" => "Varchar(255)",
"Theme" => "Varchar(255)", "Theme" => "Varchar(255)",
@ -16,16 +16,24 @@ class SiteConfig extends DataObject implements PermissionProvider {
"CanCreateTopLevelType" => "Enum('LoggedInUsers, OnlyTheseUsers', 'LoggedInUsers')", "CanCreateTopLevelType" => "Enum('LoggedInUsers, OnlyTheseUsers', 'LoggedInUsers')",
); );
static $many_many = array( private static $many_many = array(
"ViewerGroups" => "Group", "ViewerGroups" => "Group",
"EditorGroups" => "Group", "EditorGroups" => "Group",
"CreateTopLevelGroups" => "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) { 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() public function populateDefaults()
@ -132,7 +140,8 @@ class SiteConfig extends DataObject implements PermissionProvider {
*/ */
public function getAvailableThemes($baseDir = null) { public function getAvailableThemes($baseDir = null) {
$themes = SSViewer::get_themes($baseDir); $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]); if(isset($themes[$theme])) unset($themes[$theme]);
} }
return $themes; return $themes;

View File

@ -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. * Note that this setting is cached when used in the CMS, use the "flush" query parameter to clear it.
* *
* @config
* @var array * @var array
*/ */
static $allowed_children = array("SiteTree"); private static $allowed_children = array("SiteTree");
/** /**
* The default child class for this page. * The default child class for this page.
* Note: Value might be cached, see {@link $allowed_chilren}. * Note: Value might be cached, see {@link $allowed_chilren}.
* *
* @config
* @var string * @var string
*/ */
static $default_child = "Page"; private static $default_child = "Page";
/** /**
* The default parent class for this page. * The default parent class for this page.
* Note: Value might be cached, see {@link $allowed_chilren}. * Note: Value might be cached, see {@link $allowed_chilren}.
* *
* @config
* @var string * @var string
*/ */
static $default_parent = null; private static $default_parent = null;
/** /**
* Controls whether a page can be in the root of the site tree. * Controls whether a page can be in the root of the site tree.
* Note: Value might be cached, see {@link $allowed_chilren}. * Note: Value might be cached, see {@link $allowed_chilren}.
* *
* @config
* @var bool * @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. * 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}. * Note: Value might be cached, see {@link $allowed_chilren}.
* *
* @config
* @var array * @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 * 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 * 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. * to make ImprovedProduct, then you would set $hide_ancestor to Product.
* *
* @config
* @var string * @var string
*/ */
static $hide_ancestor = null; private static $hide_ancestor = null;
static $db = array( private static $db = array(
"URLSegment" => "Varchar(255)", "URLSegment" => "Varchar(255)",
"Title" => "Varchar(255)", "Title" => "Varchar(255)",
"MenuTitle" => "Varchar(100)", "MenuTitle" => "Varchar(100)",
@ -88,27 +94,27 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
"CanEditType" => "Enum('LoggedInUsers, OnlyTheseUsers, Inherit', 'Inherit')", "CanEditType" => "Enum('LoggedInUsers, OnlyTheseUsers, Inherit', 'Inherit')",
); );
static $indexes = array( private static $indexes = array(
"URLSegment" => true, "URLSegment" => true,
); );
static $many_many = array( private static $many_many = array(
"LinkTracking" => "SiteTree", "LinkTracking" => "SiteTree",
"ImageTracking" => "File", "ImageTracking" => "File",
"ViewerGroups" => "Group", "ViewerGroups" => "Group",
"EditorGroups" => "Group", "EditorGroups" => "Group",
); );
static $belongs_many_many = array( private static $belongs_many_many = array(
"BackLinkTracking" => "SiteTree" "BackLinkTracking" => "SiteTree"
); );
static $many_many_extraFields = array( private static $many_many_extraFields = array(
"LinkTracking" => array("FieldName" => "Varchar"), "LinkTracking" => array("FieldName" => "Varchar"),
"ImageTracking" => array("FieldName" => "Varchar") "ImageTracking" => array("FieldName" => "Varchar")
); );
static $casting = array( private static $casting = array(
"Breadcrumbs" => "HTMLText", "Breadcrumbs" => "HTMLText",
"LastEdited" => "SS_Datetime", "LastEdited" => "SS_Datetime",
"Created" => "SS_Datetime", "Created" => "SS_Datetime",
@ -117,67 +123,64 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
'AbsoluteLink' => 'Text', 'AbsoluteLink' => 'Text',
); );
static $defaults = array( private static $defaults = array(
"ShowInMenus" => 1, "ShowInMenus" => 1,
"ShowInSearch" => 1, "ShowInSearch" => 1,
"CanViewType" => "Inherit", "CanViewType" => "Inherit",
"CanEditType" => "Inherit" "CanEditType" => "Inherit"
); );
static $versioning = array( private static $versioning = array(
"Stage", "Live" "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. * If this is false, the class cannot be created in the CMS by regular content authors, only by ADMINs.
* @var boolean * @var boolean
* @config
*/ */
static $can_create = true; private static $can_create = true;
/**
* @see CMSMain::generateTreeStylingCSS()
*/
static $page_states = array('readonly');
/** /**
* Icon to use in the CMS page tree. This should be the full filename, relative to the webroot. * 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). * Also supports custom CSS rule contents (applied to the correct selector for the tree UI implementation).
* *
* @see CMSMain::generateTreeStylingCSS() * @see CMSMain::generateTreeStylingCSS()
* * @config
* @var string * @var string
*/ */
static $icon = null; private static $icon = null;
/** /**
* @config
* @var String Description of the class functionality, typically shown to a user * @var String Description of the class functionality, typically shown to a user
* when selecting which page type to create. Translated through {@link provideI18nEntities()}. * 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", "Hierarchy",
"Versioned('Stage', 'Live')", "Versioned('Stage', 'Live')",
); );
static $searchable_fields = array( private static $searchable_fields = array(
'Title', 'Title',
'Content', 'Content',
); );
static $field_labels = array( private static $field_labels = array(
'URLSegment' => 'URL' 'URLSegment' => 'URL'
); );
/** /**
* @see SiteTree::nested_urls() * @config
*/ */
private static $nested_urls = true; private static $nested_urls = true;
/** /**
* @see SiteTree::set_create_default_pages() * @config
*/ */
private static $create_default_pages = true; 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). * of IDs mapped to their boolean permission ability (true=allow, false=deny).
* See {@link batch_permission_check()} for details. * See {@link batch_permission_check()} for details.
*/ */
public static $cache_permissions = array(); private static $cache_permissions = array();
/** /**
* @config
* @var boolean * @var boolean
*/ */
protected static $enforce_strict_hierarchy = true; private static $enforce_strict_hierarchy = true;
protected $_cache_statusFlags = null; protected $_cache_statusFlags = null;
@ -205,59 +209,77 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
* Determines if the system should avoid orphaned pages * Determines if the system should avoid orphaned pages
* by deleting all children when the their parent is deleted (TRUE), * 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). * 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 * @param boolean
*/ */
static public function set_enforce_strict_hierarchy($to) { 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 * @return boolean
*/ */
static public function get_enforce_strict_hierarchy() { 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. * 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 * @return bool
*/ */
static public function nested_urls() { 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() { 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() { 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 * 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 * @param bool $option
*/ */
static public function set_create_default_pages($option = true) { 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. * 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 * @return bool
*/ */
static public function get_create_default_pages() { 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. * 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. * "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 * 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. // Grab the initial root level page to traverse down from.
$URLSegment = array_shift($parts); $URLSegment = array_shift($parts);
$sitetree = DataObject::get_one ( $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. /// 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; return $page;
} }
// Attempt to grab an alternative page from extensions. // Attempt to grab an alternative page from extensions.
if(!$sitetree) { if(!$sitetree) {
$parentID = self::nested_urls() ? 0 : null; $parentID = self::config()->nested_urls ? 0 : null;
if($alternatives = singleton('SiteTree')->extend('alternateGetByLink', $URLSegment, $parentID)) { if($alternatives = singleton('SiteTree')->extend('alternateGetByLink', $URLSegment, $parentID)) {
foreach($alternatives as $alternative) if($alternative) $sitetree = $alternative; 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. // 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. // Traverse down the remaining URL segments and grab the relevant SiteTree objects.
foreach($parts as $segment) { foreach($parts as $segment) {
@ -438,7 +460,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
* @return string * @return string
*/ */
public function RelativeLink($action = null) { public function RelativeLink($action = null) {
if($this->ParentID && self::nested_urls()) { if($this->ParentID && self::config()->nested_urls) {
$base = $this->Parent()->RelativeLink($this->URLSegment); $base = $this->Parent()->RelativeLink($this->URLSegment);
} else { } else {
$base = $this->URLSegment; $base = $this->URLSegment;
@ -1275,7 +1297,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
$tags .= "<meta name=\"generator\" content=\"SilverStripe - http://silverstripe.org\" />\n"; $tags .= "<meta name=\"generator\" content=\"SilverStripe - http://silverstripe.org\" />\n";
$charset = ContentNegotiator::get_encoding(); $charset = Config::inst()->get('ContentNegotiator', 'encoding');
$tags .= "<meta http-equiv=\"Content-type\" content=\"text/html; charset=$charset\" />\n"; $tags .= "<meta http-equiv=\"Content-type\" content=\"text/html; charset=$charset\" />\n";
if($this->MetaDescription) { if($this->MetaDescription) {
$tags .= "<meta name=\"description\" content=\"" . Convert::raw2att($this->MetaDescription) . "\" />\n"; $tags .= "<meta name=\"description\" content=\"" . Convert::raw2att($this->MetaDescription) . "\" />\n";
@ -1322,12 +1344,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
parent::requireDefaultRecords(); parent::requireDefaultRecords();
// default pages // default pages
if($this->class == 'SiteTree' && self::get_create_default_pages()) { if($this->class == 'SiteTree' && $this->config()->create_default_pages) {
if(!SiteTree::get_by_link(RootURLController::get_default_homepage_link())) { if(!SiteTree::get_by_link(Config::inst()->get('RootURLController', 'default_homepage_link'))) {
$homepage = new Page(); $homepage = new Page();
$homepage->Title = _t('SiteTree.DEFAULTHOMETITLE', 'Home'); $homepage->Title = _t('SiteTree.DEFAULTHOMETITLE', 'Home');
$homepage->Content = _t('SiteTree.DEFAULTHOMECONTENT', '<p>Welcome to SilverStripe! This is the default homepage. You can edit this page by opening <a href="admin/">the CMS</a>. You can now access the <a href="http://doc.silverstripe.org">developer documentation</a>, or begin <a href="http://doc.silverstripe.org/doku.php?id=tutorials">the tutorials.</a></p>'); $homepage->Content = _t('SiteTree.DEFAULTHOMECONTENT', '<p>Welcome to SilverStripe! This is the default homepage. You can edit this page by opening <a href="admin/">the CMS</a>. You can now access the <a href="http://doc.silverstripe.org">developer documentation</a>, or begin <a href="http://doc.silverstripe.org/doku.php?id=tutorials">the tutorials.</a></p>');
$homepage->URLSegment = RootURLController::get_default_homepage_link(); $homepage->URLSegment = Config::inst()->get('RootURLController', 'default_homepage_link');
$homepage->Sort = 1; $homepage->Sort = 1;
$homepage->write(); $homepage->write();
$homepage->publish('Stage', 'Live'); $homepage->publish('Stage', 'Live');
@ -1467,7 +1489,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
parent::onBeforeDelete(); parent::onBeforeDelete();
// If deleting this page, delete all its children. // 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) { foreach($children as $child) {
$child->delete(); $child->delete();
} }
@ -1542,20 +1564,20 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
* @return bool * @return bool
*/ */
public function validURLSegment() { 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 = ModelAsController::controller_for($parent)) {
if($controller instanceof Controller && $controller->hasAction($this->URLSegment)) return false; 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; if(class_exists($this->URLSegment) && is_subclass_of($this->URLSegment, 'RequestHandler')) return false;
} }
$IDFilter = ($this->ID) ? "AND \"SiteTree\".\"ID\" <> $this->ID" : null; $IDFilter = ($this->ID) ? "AND \"SiteTree\".\"ID\" <> $this->ID" : null;
$parentFilter = null; $parentFilter = null;
if(self::nested_urls()) { if(self::config()->nested_urls) {
if($this->ParentID) { if($this->ParentID) {
$parentFilter = " AND \"SiteTree\".\"ParentID\" = $this->ParentID"; $parentFilter = " AND \"SiteTree\".\"ParentID\" = $this->ParentID";
} else { } else {
@ -1826,13 +1848,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
$baseLink = Controller::join_links ( $baseLink = Controller::join_links (
Director::absoluteBaseURL(), 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 = new SiteTreeURLSegmentField("URLSegment", $this->fieldLabel('URLSegment'));
$urlsegment->setURLPrefix($baseLink); $urlsegment->setURLPrefix($baseLink);
$helpText = (self::nested_urls() && count($this->Children())) ? $this->fieldLabel('LinkChangeNote') : ''; $helpText = (self::config()->nested_urls && count($this->Children())) ? $this->fieldLabel('LinkChangeNote') : '';
if(!URLSegmentFilter::$default_allow_multibyte) { if(!Config::inst()->get('URLSegmentFilter', 'default_allow_multibyte')) {
$helpText .= $helpText ? '<br />' : ''; $helpText .= $helpText ? '<br />' : '';
$helpText .= _t('SiteTreeURLSegmentField.HelpChars', ' Special characters are automatically converted or removed.'); $helpText .= _t('SiteTreeURLSegmentField.HelpChars', ' Special characters are automatically converted or removed.');
} }

View File

@ -5,7 +5,7 @@
*/ */
class SiteTreeFileExtension extends DataExtension { class SiteTreeFileExtension extends DataExtension {
public static $belongs_many_many = array( private static $belongs_many_many = array(
'BackLinkTracking' => 'SiteTree' 'BackLinkTracking' => 'SiteTree'
); );

View File

@ -7,15 +7,15 @@
*/ */
class VirtualPage extends Page { class VirtualPage extends Page {
static $description = 'Displays the content of another page'; private static $description = 'Displays the content of another page';
public static $virtualFields; public static $virtualFields;
/** /**
* @var Array Define fields that are not virtual - the virtual page must define these fields themselves. * @var Array Define fields that are not virtual - the virtual page must define these fields themselves.
* Note that anything in {@link self::$initially_copied_fields} is implicitly included in this list. * Note that anything in {@link self::config()->initially_copied_fields} is implicitly included in this list.
*/ */
public static $non_virtual_fields = array( private static $non_virtual_fields = array(
"SecurityTypeID", "SecurityTypeID",
"OwnerID", "OwnerID",
"URLSegment", "URLSegment",
@ -32,17 +32,17 @@ class VirtualPage extends Page {
/** /**
* @var Array Define fields that are initially copied to virtual pages but left modifiable after that. * @var Array Define fields that are initially copied to virtual pages but left modifiable after that.
*/ */
public static $initially_copied_fields = array( private static $initially_copied_fields = array(
'ShowInMenus', 'ShowInMenus',
'ShowInSearch', 'ShowInSearch',
'URLSegment', 'URLSegment',
); );
static $has_one = array( private static $has_one = array(
"CopyContentFrom" => "SiteTree", "CopyContentFrom" => "SiteTree",
); );
static $db = array( private static $db = array(
"VersionID" => "Int", "VersionID" => "Int",
); );
@ -50,7 +50,7 @@ class VirtualPage extends Page {
* Generates the array of fields required for the page type. * Generates the array of fields required for the page type.
*/ */
public function getVirtualFields() { public function getVirtualFields() {
$nonVirtualFields = array_merge(self::$non_virtual_fields, self::$initially_copied_fields); $nonVirtualFields = array_merge(self::config()->non_virtual_fields, self::config()->initially_copied_fields);
$record = $this->CopyContentFrom(); $record = $this->CopyContentFrom();
$allFields = $record->db(); $allFields = $record->db();
@ -323,7 +323,7 @@ class VirtualPage extends Page {
// We also want to copy certain, but only if we're copying the source page for the first // We also want to copy certain, but only if we're copying the source page for the first
// time. After this point, the user is free to customise these for the virtual page themselves. // time. After this point, the user is free to customise these for the virtual page themselves.
if($this->isChanged('CopyContentFromID', 2) && $this->CopyContentFromID != 0) { if($this->isChanged('CopyContentFromID', 2) && $this->CopyContentFromID != 0) {
foreach(self::$initially_copied_fields as $fieldName) { foreach(self::config()->initially_copied_fields as $fieldName) {
$this->$fieldName = $source->$fieldName; $this->$fieldName = $source->$fieldName;
} }
} }
@ -405,7 +405,7 @@ class VirtualPage extends Page {
*/ */
class VirtualPage_Controller extends Page_Controller { class VirtualPage_Controller extends Page_Controller {
static $allowed_actions = array( private static $allowed_actions = array(
'loadcontentall' => 'ADMIN', 'loadcontentall' => 'ADMIN',
); );

View File

@ -63,8 +63,9 @@ class SS_Report extends ViewableData {
/** /**
* Reports which should not be collected and returned in get_reports * Reports which should not be collected and returned in get_reports
* @var array * @var array
* @config
*/ */
public static $excluded_reports = array( private static $excluded_reports = array(
'SS_Report', 'SS_Report',
'SS_ReportWrapper', 'SS_ReportWrapper',
'SideReportWrapper' 'SideReportWrapper'
@ -143,11 +144,11 @@ class SS_Report extends ViewableData {
*/ */
static public function add_excluded_reports($reportClass) { static public function add_excluded_reports($reportClass) {
if (is_array($reportClass)) { if (is_array($reportClass)) {
self::$excluded_reports = array_merge(self::$excluded_reports, $reportClass); self::config()->excluded_reports = array_merge(self::config()->excluded_reports, $reportClass);
} else { } else {
if (is_string($reportClass)) { if (is_string($reportClass)) {
//add to the excluded reports, so this report doesn't get used //add to the excluded reports, so this report doesn't get used
self::$excluded_reports[] = $reportClass; self::config()->excluded_reports = array($reportClass);
} }
} }
} }
@ -155,10 +156,13 @@ class SS_Report extends ViewableData {
/** /**
* Return an array of excluded reports. That is, reports that will not be included in * Return an array of excluded reports. That is, reports that will not be included in
* the list of reports in report admin in the CMS. * the list of reports in report admin in the CMS.
*
* @deprecated 3.2 Use the "Report.excluded_reports" config setting instead
* @return array * @return array
*/ */
static public function get_excluded_reports() { static public function get_excluded_reports() {
return self::$excluded_reports; Deprecation::notice('3.2', 'Use the "Report.excluded_reports" config setting instead');
return self::config()->excluded_reports;
} }
/** /**
@ -172,7 +176,7 @@ class SS_Report extends ViewableData {
if ($reports && count($reports) > 0) { if ($reports && count($reports) > 0) {
//collect reports into array with an attribute for 'sort' //collect reports into array with an attribute for 'sort'
foreach($reports as $report) { foreach($reports as $report) {
if (in_array($report, self::$excluded_reports)) continue; //don't use the SS_Report superclass if (in_array($report, self::config()->excluded_reports)) continue; //don't use the SS_Report superclass
$reflectionClass = new ReflectionClass($report); $reflectionClass = new ReflectionClass($report);
if ($reflectionClass->isAbstract()) continue; //don't use abstract classes if ($reflectionClass->isAbstract()) continue; //don't use abstract classes

View File

@ -6,7 +6,7 @@
* @subpackage search * @subpackage search
*/ */
class ContentControllerSearchExtension extends Extension { class ContentControllerSearchExtension extends Extension {
static $allowed_actions = array( private static $allowed_actions = array(
'SearchForm', 'SearchForm',
'results', 'results',
); );

View File

@ -28,24 +28,29 @@ class FilesystemPublisher extends StaticPublisher {
protected $fileExtension = 'html'; protected $fileExtension = 'html';
/** /**
* @config
* @var String * @var String
*/ */
protected static $static_base_url = null; private static $static_base_url = null;
/** /**
* @config
* @var Boolean Use domain based cacheing (put cache files into a domain subfolder) * @var Boolean Use domain based cacheing (put cache files into a domain subfolder)
* This must be true if you are using this with the "subsites" module. * This must be true if you are using this with the "subsites" module.
* Please note that this form of caching requires all URLs to be provided absolute * Please note that this form of caching requires all URLs to be provided absolute
* (not relative to the webroot) via {@link SiteTree->AbsoluteLink()}. * (not relative to the webroot) via {@link SiteTree->AbsoluteLink()}.
*/ */
public static $domain_based_caching = false; private static $domain_based_caching = false;
/** /**
* Set a different base URL for the static copy of the site. * Set a different base URL for the static copy of the site.
* This can be useful if you are running the CMS on a different domain from the website. * This can be useful if you are running the CMS on a different domain from the website.
*
* @deprecated 3.2 Use the "FilesystemPublisher.static_base_url" config setting instead
*/ */
static public function set_static_base_url($url) { static public function set_static_base_url($url) {
self::$static_base_url = $url; Deprecation::notice('3.2', 'Use the "FilesystemPublisher.static_base_url" config setting instead');
Config::inst()->update('FilesystemPublisher', 'static_base_url', $url);
} }
/** /**
@ -112,7 +117,7 @@ class FilesystemPublisher extends StaticPublisher {
$filename = $urlSegment ? "$urlSegment.$this->fileExtension" : "index.$this->fileExtension"; $filename = $urlSegment ? "$urlSegment.$this->fileExtension" : "index.$this->fileExtension";
if (self::$domain_based_caching) { if (Config::inst()->get('FilesystemPublisher', 'domain_based_caching')) {
if (!$urlParts) continue; // seriously malformed url here... if (!$urlParts) continue; // seriously malformed url here...
$filename = $urlParts['host'] . '/' . $filename; $filename = $urlParts['host'] . '/' . $filename;
} }
@ -167,15 +172,21 @@ class FilesystemPublisher extends StaticPublisher {
// Set the appropriate theme for this publication batch. // Set the appropriate theme for this publication batch.
// This may have been set explicitly via StaticPublisher::static_publisher_theme, // This may have been set explicitly via StaticPublisher::static_publisher_theme,
// or we can use the last non-null theme. // or we can use the last non-null theme.
if(!StaticPublisher::static_publisher_theme()) $customTheme = Config::inst()->get('StaticPublisher', 'static_publisher_theme');
SSViewer::set_theme(SSViewer::current_custom_theme()); if(!$customTheme)
Config::inst()->update('SSViewer', 'theme', Config::inst()->get('SSViewer', 'custom_theme'));
else else
SSViewer::set_theme(StaticPublisher::static_publisher_theme()); Config::inst()->update('SSViewer', 'theme', $customTheme);
$currentBaseURL = Director::baseURL(); $currentBaseURL = Director::baseURL();
if(self::$static_base_url) Director::setBaseURL(self::$static_base_url); $staticBaseUrl = Config::inst()->get('FilesystemPublisher', 'static_base_url');
if($this->fileExtension == 'php') SSViewer::setOption('rewriteHashlinks', 'php'); if($staticBaseUrl) Config::inst()->update('Director', 'alternate_base_url', $staticBaseUrl);
if(StaticPublisher::echo_progress()) echo $this->class.": Publishing to " . self::$static_base_url . "\n"; if($this->fileExtension == 'php') {
Config::inst()->update('SSViewer', 'rewrite_hash_links', 'php');
}
if(Config::inst()->get('StaticPublisher', 'echo_progress')) {
echo $this->class.": Publishing to " . $staticBaseUrl . "\n";
}
$files = array(); $files = array();
$i = 0; $i = 0;
$totalURLs = sizeof($urls); $totalURLs = sizeof($urls);
@ -183,7 +194,7 @@ class FilesystemPublisher extends StaticPublisher {
$origUrl = $url; $origUrl = $url;
$result[$origUrl] = array('statuscode' => null, 'redirect' => null, 'path' => null); $result[$origUrl] = array('statuscode' => null, 'redirect' => null, 'path' => null);
if(self::$static_base_url) Director::setBaseURL(self::$static_base_url); if($staticBaseUrl) Config::inst()->update('Director', 'alternate_base_url', $staticBaseUrl);
$i++; $i++;
if($url && !is_string($url)) { if($url && !is_string($url)) {
@ -191,7 +202,7 @@ class FilesystemPublisher extends StaticPublisher {
continue; continue;
} }
if(StaticPublisher::echo_progress()) { if(Config::inst()->get('StaticPublisher', 'echo_progress')) {
echo " * Publishing page $i/$totalURLs: $url\n"; echo " * Publishing page $i/$totalURLs: $url\n";
flush(); flush();
} }
@ -241,7 +252,7 @@ class FilesystemPublisher extends StaticPublisher {
} }
} }
if(StaticPublisher::$include_caching_metadata) { if(Config::inst()->get('StaticPublisher', 'include_caching_metadata')) {
$content = str_replace( $content = str_replace(
'</html>', '</html>',
sprintf("</html>\n\n<!-- %s -->", implode(" ", $this->getMetadata($url))), sprintf("</html>\n\n<!-- %s -->", implode(" ", $this->getMetadata($url))),
@ -282,8 +293,10 @@ class FilesystemPublisher extends StaticPublisher {
}*/ }*/
} }
if(self::$static_base_url) Director::setBaseURL($currentBaseURL); if(Config::inst()->get('FilesystemPublisher', 'static_base_url')) Config::inst()->update('Director', 'alternate_base_url', $currentBaseURL);
if($this->fileExtension == 'php') SSViewer::setOption('rewriteHashlinks', true); if($this->fileExtension == 'php') {
Config::inst()->update('SSViewer', 'rewrite_hash_links', true);
}
$base = BASE_PATH . "/$this->destFolder"; $base = BASE_PATH . "/$this->destFolder";
foreach($files as $origUrl => $file) { foreach($files as $origUrl => $file) {

View File

@ -11,29 +11,39 @@
*/ */
class RsyncMultiHostPublisher extends FilesystemPublisher { class RsyncMultiHostPublisher extends FilesystemPublisher {
/** /**
* @config
* Array of rsync targets to publish to. These can either be local file names, or scp-style targets, in the form "user@server:path" * Array of rsync targets to publish to. These can either be local file names, or scp-style targets, in the form "user@server:path"
*/ */
protected static $targets = array(); private static $targets = array();
protected static $excluded_folders = array(); /**
* @config
* @var array
*/
private static $excluded_folders = array();
/** /**
* Set the targets to publish to. * Set the targets to publish to.
* If target is an scp-style remote path, no password is accepted - we assume key-based authentication to be set up on the application server * If target is an scp-style remote path, no password is accepted - we assume key-based authentication to be set up on the application server
* initiating the publication. * initiating the publication.
* *
* @deprecated 3.2 Use the "RsyncMultiHostPublisher.targets" config setting instead
* @param $targets An array of targets to publish to. These can either be local file names, or scp-style targets, in the form "user@server:path" * @param $targets An array of targets to publish to. These can either be local file names, or scp-style targets, in the form "user@server:path"
*/ */
static public function set_targets($targets) { static public function set_targets($targets) {
self::$targets = $targets; Deprecation::notice('3.2', 'Use the "RsyncMultiHostPublisher.targets" config setting instead');
Config::inst()->update('RsyncMultiHostPublisher', 'targets', $targets);
} }
/** /**
* Specify folders to exclude from the rsync * Specify folders to exclude from the rsync
* For example, you could exclude assets. * For example, you could exclude assets.
*
* @deprecated 3.2 Use the "RsyncMultiHostPublisher.excluded_folders" config setting instead
*/ */
static public function set_excluded_folders($folders) { static public function set_excluded_folders($folders) {
self::$excluded_folders = $folders; Deprecation::notice('3.2', 'Use the "RsyncMultiHostPublisher.excluded_folders" config setting instead');
Config::inst()->update('RsyncMultiHostPublisher', 'excluded_folders', $folders);
} }
public function publishPages($urls) { public function publishPages($urls) {
@ -45,18 +55,18 @@ class RsyncMultiHostPublisher extends FilesystemPublisher {
if(isset($_GET['norsync']) && $_GET['norsync']) return; if(isset($_GET['norsync']) && $_GET['norsync']) return;
$extraArg = ""; $extraArg = "";
if(self::$excluded_folders) foreach(self::$excluded_folders as $folder) { if($this->config()->excluded_folders) foreach($this->config()->excluded_folders as $folder) {
$extraArg .= " --exclude " . escapeshellarg($folder); $extraArg .= " --exclude " . escapeshellarg($folder);
} }
foreach(self::$targets as $target) { foreach((array)$this->config()->targets as $target) {
// Transfer non-PHP content from everything to the target; that will ensure that we have all the JS/CSS/etc // Transfer non-PHP content from everything to the target; that will ensure that we have all the JS/CSS/etc
$rsyncOutput = `cd $base; rsync -av -e ssh --exclude /.htaccess --exclude /web.config --exclude '*.php' --exclude '*.svn' --exclude '*.git' --exclude '*~' $extraArg --delete . $target`; $rsyncOutput = `cd $base; rsync -av -e ssh --exclude /.htaccess --exclude /web.config --exclude '*.php' --exclude '*.svn' --exclude '*.git' --exclude '*~' $extraArg --delete . $target`;
// Then transfer "safe" PHP from the cache/ directory // Then transfer "safe" PHP from the cache/ directory
$rsyncOutput .= `cd $base; rsync -av -e ssh --exclude '*.svn' --exclude '*~' $extraArg --delete cache $target`; $rsyncOutput .= `cd $base; rsync -av -e ssh --exclude '*.svn' --exclude '*~' $extraArg --delete cache $target`;
// Transfer framework/static-main.php to the target // Transfer framework/static-main.php to the target
$rsyncOutput .= `cd $base; rsync -av -e ssh --delete $framework/static-main.php $target/$framework`; $rsyncOutput .= `cd $base; rsync -av -e ssh --delete $framework/static-main.php $target/$framework`;
if(StaticPublisher::echo_progress()) echo $rsyncOutput; if(Config::inst()->get('StaticPublisher', 'echo_progress')) echo $rsyncOutput;
} }
} }

View File

@ -5,52 +5,71 @@
*/ */
abstract class StaticPublisher extends DataExtension { abstract class StaticPublisher extends DataExtension {
/** /**
* Defines whether to output information about publishing or not. By * @config
* @var boolean Defines whether to output information about publishing or not. By
* default, this is off, and should be turned on when you want debugging * default, this is off, and should be turned on when you want debugging
* (for example, in a cron task) * (for example, in a cron task)
*/ */
static $echo_progress = false; private static $echo_progress = false;
/** /**
* Realtime static publishing... the second a page * @config
* is saved, it is written to the cache * @var boolean Realtime static publishing... the second a page
* is saved, it is written to the cache
*/ */
static $disable_realtime = false; private static $disable_realtime = false;
/* /*
* This is the current static publishing theme, which can be set at any point * @config
* If it's not set, then the last non-null theme, set via SSViewer::set_theme() is used * @var boolean This is the current static publishing theme, which can be set at any point
* If it's not set, then the last non-null theme, set via Config::inst()->update('SSViewer', 'theme', ) is used
* The obvious place to set this is in _config.php * The obvious place to set this is in _config.php
*/ */
static $static_publisher_theme=false; private static $static_publisher_theme=false;
abstract public function publishPages($pages); abstract public function publishPages($pages);
abstract public function unpublishPages($pages); abstract public function unpublishPages($pages);
/**
* @deprecated 3.2 Use the "StaticPublisher.static_publisher_theme" config setting instead
* @param [type] $theme [description]
*/
static public function set_static_publisher_theme($theme){ static public function set_static_publisher_theme($theme){
self::$static_publisher_theme=$theme; Deprecation::notice('3.2', 'Use the "StaticPublisher.static_publisher_theme" config setting instead');
Config::inst()->update('StaticPublisher', 'static_publisher_theme', $theme);
} }
/** /**
* @config
* @var boolean Includes a timestamp at the bottom of the generated HTML of each file, * @var boolean Includes a timestamp at the bottom of the generated HTML of each file,
* which can be useful for debugging issues with stale caches etc. * which can be useful for debugging issues with stale caches etc.
*/ */
static $include_caching_metadata = false; private static $include_caching_metadata = false;
/**
* @deprecated 3.2 Use the "StaticPublisher.static_publisher_theme" config setting instead
*/
static public function static_publisher_theme(){ static public function static_publisher_theme(){
return self::$static_publisher_theme; Deprecation::notice('3.2', 'Use the "StaticPublisher.static_publisher_theme" config setting instead');
return Config::inst()->get('StaticPublisher', 'static_publisher_theme');
} }
/**
* @deprecated 3.2 Use the "StaticPublisher.echo_progress" config setting instead
*/
static public function echo_progress() { static public function echo_progress() {
return (boolean)self::$echo_progress; Deprecation::notice('3.2', 'Use the "StaticPublisher.echo_progress" config setting instead');
return Config::inst()->get('StaticPublisher', 'echo_progress');
} }
/** /**
* Either turns on (boolean true) or off (boolean false) the progress indicators. * Either turns on (boolean true) or off (boolean false) the progress indicators.
* @deprecated 3.2 Use the "StaticPublisher.echo_progress" config setting instead
* @see StaticPublisher::$echo_progress * @see StaticPublisher::$echo_progress
*/ */
static public function set_echo_progress($progress) { static public function set_echo_progress($progress) {
self::$echo_progress = (boolean)$progress; Deprecation::notice('3.2', 'Use the "StaticPublisher.echo_progress" config setting instead');
Config::inst()->update('StaticPublisher', 'echo_progress', $progress);
} }
/** /**
@ -71,7 +90,7 @@ abstract class StaticPublisher extends DataExtension {
} }
public function republish($original) { public function republish($original) {
if (self::$disable_realtime) return; if (Config::inst()->get('StaticPublisher', 'disable_realtime')) return;
$urls = array(); $urls = array();
@ -109,7 +128,7 @@ abstract class StaticPublisher extends DataExtension {
* functionality * functionality
*/ */
public function onAfterUnpublish($page) { public function onAfterUnpublish($page) {
if (self::$disable_realtime) return; if (Config::inst()->get('StaticPublisher', 'disable_realtime')) return;
// Get the affected URLs // Get the affected URLs
if($this->owner->hasMethod('pagesAffectedByUnpublishing')) { if($this->owner->hasMethod('pagesAffectedByUnpublishing')) {

View File

@ -7,7 +7,7 @@
*/ */
class RebuildStaticCacheTask extends Controller { class RebuildStaticCacheTask extends Controller {
static $allowed_actions = array( private static $allowed_actions = array(
'index', 'index',
); );
@ -21,7 +21,7 @@ class RebuildStaticCacheTask extends Controller {
} }
public function index() { public function index() {
StaticPublisher::set_echo_progress(true); Config::inst()->update('StaticPublisher', 'echo_progress', true);
$page = singleton('Page'); $page = singleton('Page');
if(!$page->hasMethod('allPagesToCache')) { if(!$page->hasMethod('allPagesToCache')) {
@ -92,7 +92,7 @@ class RebuildStaticCacheTask extends Controller {
if($removeAll && !isset($_GET['urls']) && $start == 0 && file_exists("../cache")) { if($removeAll && !isset($_GET['urls']) && $start == 0 && file_exists("../cache")) {
echo "Removing stale cache files... \n"; echo "Removing stale cache files... \n";
flush(); flush();
if (FilesystemPublisher::$domain_based_caching) { if (Config::inst()->get('FilesystemPublisher', 'domain_based_caching')) {
// Glob each dir, then glob each one of those // Glob each dir, then glob each one of those
foreach(glob(BASE_PATH . '/cache/*', GLOB_ONLYDIR) as $cacheDir) { foreach(glob(BASE_PATH . '/cache/*', GLOB_ONLYDIR) as $cacheDir) {
foreach(glob($cacheDir.'/*') as $cacheFile) { foreach(glob($cacheDir.'/*') as $cacheFile) {

View File

@ -23,7 +23,7 @@
//class RemoveOrphanedPagesTask extends BuildTask { //class RemoveOrphanedPagesTask extends BuildTask {
class RemoveOrphanedPagesTask extends Controller { class RemoveOrphanedPagesTask extends Controller {
static $allowed_actions = array( private static $allowed_actions = array(
'index' => 'ADMIN', 'index' => 'ADMIN',
'Form' => 'ADMIN', 'Form' => 'ADMIN',
'run' => 'ADMIN', 'run' => 'ADMIN',

View File

@ -4,7 +4,7 @@
* @subpackage tasks * @subpackage tasks
*/ */
class SiteTreeMaintenanceTask extends Controller { class SiteTreeMaintenanceTask extends Controller {
static $allowed_actions = array( private static $allowed_actions = array(
'*' => 'ADMIN' '*' => 'ADMIN'
); );

View File

@ -4,7 +4,8 @@
* @subpackage tasks * @subpackage tasks
*/ */
class UpgradeSiteTreePermissionSchemaTask extends BuildTask { class UpgradeSiteTreePermissionSchemaTask extends BuildTask {
static $allowed_actions = array(
private static $allowed_actions = array(
'*' => 'ADMIN' '*' => 'ADMIN'
); );

View File

@ -5,7 +5,7 @@
*/ */
class CMSMainTest extends FunctionalTest { class CMSMainTest extends FunctionalTest {
static $fixture_file = 'CMSMainTest.yml'; protected static $fixture_file = 'CMSMainTest.yml';
static protected $orig = array(); static protected $orig = array();
@ -78,6 +78,8 @@ class CMSMainTest extends FunctionalTest {
'Done: Published 30 pages', 'Done: Published 30 pages',
$response->getBody() $response->getBody()
); );
$actions = CMSBatchActionHandler::config()->batch_actions;
// Some modules (e.g., cmsworkflow) will remove this action // Some modules (e.g., cmsworkflow) will remove this action
$actions = CMSBatchActionHandler::config()->batch_actions; $actions = CMSBatchActionHandler::config()->batch_actions;
@ -159,7 +161,7 @@ class CMSMainTest extends FunctionalTest {
public function testCanPublishPageWithUnpublishedParentWithStrictHierarchyOff() { public function testCanPublishPageWithUnpublishedParentWithStrictHierarchyOff() {
$this->logInWithPermission('ADMIN'); $this->logInWithPermission('ADMIN');
SiteTree::set_enforce_strict_hierarchy(true); Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true);
$parentPage = $this->objFromFixture('Page','page3'); $parentPage = $this->objFromFixture('Page','page3');
$childPage = $this->objFromFixture('Page','page1'); $childPage = $this->objFromFixture('Page','page1');
@ -172,7 +174,7 @@ class CMSMainTest extends FunctionalTest {
$actions, $actions,
'Can publish a page with an unpublished parent with strict hierarchy off' 'Can publish a page with an unpublished parent with strict hierarchy off'
); );
SiteTree::set_enforce_strict_hierarchy(false); Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false);
} }
/** /**
@ -329,7 +331,7 @@ class CMSMainTest extends FunctionalTest {
} }
class CMSMainTest_ClassA extends Page implements TestOnly { class CMSMainTest_ClassA extends Page implements TestOnly {
static $allowed_children = array('CMSMainTest_ClassB'); private static $allowed_children = array('CMSMainTest_ClassB');
} }
class CMSMainTest_ClassB extends Page implements TestOnly { class CMSMainTest_ClassB extends Page implements TestOnly {
@ -337,7 +339,7 @@ class CMSMainTest_ClassB extends Page implements TestOnly {
} }
class CMSMainTest_NotRoot extends Page implements TestOnly { class CMSMainTest_NotRoot extends Page implements TestOnly {
static $can_be_root = false; private static $can_be_root = false;
} }
class CMSMainTest_HiddenClass extends Page implements TestOnly, HiddenClass { class CMSMainTest_HiddenClass extends Page implements TestOnly, HiddenClass {

View File

@ -7,7 +7,7 @@
class CMSPageHistoryControllerTest extends FunctionalTest { class CMSPageHistoryControllerTest extends FunctionalTest {
static $fixture_file = 'CMSPageHistoryControllerTest.yml'; protected static $fixture_file = 'CMSPageHistoryControllerTest.yml';
private $versionUnpublishedCheck, $versionPublishCheck, $versionUnpublishedCheck2; private $versionUnpublishedCheck, $versionPublishCheck, $versionUnpublishedCheck2;
private $page; private $page;

View File

@ -1,7 +1,7 @@
<?php <?php
class CMSSiteTreeFilterTest extends SapphireTest { class CMSSiteTreeFilterTest extends SapphireTest {
static $fixture_file = 'CMSSiteTreeFilterTest.yml'; protected static $fixture_file = 'CMSSiteTreeFilterTest.yml';
public function testSearchFilterEmpty() { public function testSearchFilterEmpty() {
$page1 = $this->objFromFixture('Page', 'page1'); $page1 = $this->objFromFixture('Page', 'page1');

View File

@ -5,9 +5,9 @@
*/ */
class ContentControllerTest extends FunctionalTest { class ContentControllerTest extends FunctionalTest {
public static $fixture_file = 'ContentControllerTest.yml'; protected static $fixture_file = 'ContentControllerTest.yml';
public static $use_draft_site = true; protected static $use_draft_site = true;
/** /**
* Test that nested pages, basic actions, and nested/non-nested URL switching works properly * Test that nested pages, basic actions, and nested/non-nested URL switching works properly
@ -15,7 +15,7 @@ class ContentControllerTest extends FunctionalTest {
public function testNestedPages() { public function testNestedPages() {
RootURLController::reset(); RootURLController::reset();
SiteTree::enable_nested_urls(); Config::inst()->update('SiteTree', 'nested_urls', true);
$this->assertEquals('Home Page', $this->get('/')->getBody()); $this->assertEquals('Home Page', $this->get('/')->getBody());
$this->assertEquals('Home Page', $this->get('/home/index/')->getBody()); $this->assertEquals('Home Page', $this->get('/home/index/')->getBody());
@ -30,7 +30,7 @@ class ContentControllerTest extends FunctionalTest {
$this->assertEquals('Third Level Page', $this->get('/home/second-level/third-level/second-index/')->getBody()); $this->assertEquals('Third Level Page', $this->get('/home/second-level/third-level/second-index/')->getBody());
RootURLController::reset(); RootURLController::reset();
SiteTree::disable_nested_urls(); SiteTree::config()->nested_urls = false;
$this->assertEquals('Home Page', $this->get('/')->getBody()); $this->assertEquals('Home Page', $this->get('/')->getBody());
$this->assertEquals('Home Page', $this->get('/home/')->getBody()); $this->assertEquals('Home Page', $this->get('/home/')->getBody());
@ -51,14 +51,14 @@ class ContentControllerTest extends FunctionalTest {
public function testChildrenOf() { public function testChildrenOf() {
$controller = new ContentController(); $controller = new ContentController();
SiteTree::enable_nested_urls(); Config::inst()->update('SiteTree', 'nested_urls', true);
$this->assertEquals(1, $controller->ChildrenOf('/')->Count()); $this->assertEquals(1, $controller->ChildrenOf('/')->Count());
$this->assertEquals(1, $controller->ChildrenOf('/home/')->Count()); $this->assertEquals(1, $controller->ChildrenOf('/home/')->Count());
$this->assertEquals(2, $controller->ChildrenOf('/home/second-level/')->Count()); $this->assertEquals(2, $controller->ChildrenOf('/home/second-level/')->Count());
$this->assertEquals(0, $controller->ChildrenOf('/home/second-level/third-level/')->Count()); $this->assertEquals(0, $controller->ChildrenOf('/home/second-level/third-level/')->Count());
SiteTree::disable_nested_urls(); SiteTree::config()->nested_urls = false;
$this->assertEquals(1, $controller->ChildrenOf('/')->Count()); $this->assertEquals(1, $controller->ChildrenOf('/')->Count());
$this->assertEquals(1, $controller->ChildrenOf('/home/')->Count()); $this->assertEquals(1, $controller->ChildrenOf('/home/')->Count());
@ -67,7 +67,7 @@ class ContentControllerTest extends FunctionalTest {
} }
public function testDeepNestedURLs() { public function testDeepNestedURLs() {
SiteTree::enable_nested_urls(); Config::inst()->update('SiteTree', 'nested_urls', true);
$page = new Page(); $page = new Page();
$page->URLSegment = 'base-page'; $page->URLSegment = 'base-page';
@ -87,7 +87,7 @@ class ContentControllerTest extends FunctionalTest {
} }
SiteTree::disable_nested_urls(); SiteTree::config()->nested_urls = false;
} }
public function testViewDraft(){ public function testViewDraft(){
@ -129,7 +129,7 @@ class ContentControllerTest_Page extends Page { }
class ContentControllerTest_Page_Controller extends Page_Controller { class ContentControllerTest_Page_Controller extends Page_Controller {
public static $allowed_actions = array ( private static $allowed_actions = array (
'second_index' 'second_index'
); );

View File

@ -7,7 +7,7 @@ class ModelAsControllerTest extends FunctionalTest {
protected $usesDatabase = true; protected $usesDatabase = true;
static $fixture_file = 'ModelAsControllerTest.yml'; protected static $fixture_file = 'ModelAsControllerTest.yml';
protected $autoFollowRedirection = false; protected $autoFollowRedirection = false;
@ -22,8 +22,8 @@ class ModelAsControllerTest extends FunctionalTest {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->orig['nested_urls'] = SiteTree::nested_urls(); $this->orig['nested_urls'] = SiteTree::config()->nested_urls;
SiteTree::enable_nested_urls(); Config::inst()->update('SiteTree', 'nested_urls', true);
} }
/** /**
@ -35,7 +35,7 @@ class ModelAsControllerTest extends FunctionalTest {
public function tearDown() { public function tearDown() {
if (isset($this->orig['nested_urls']) && !$this->orig['nested_urls']) { if (isset($this->orig['nested_urls']) && !$this->orig['nested_urls']) {
SiteTree::disable_nested_urls(); SiteTree::config()->nested_urls = false;
} }
parent::tearDown(); parent::tearDown();
} }
@ -241,7 +241,7 @@ class ModelAsControllerTest extends FunctionalTest {
*/ */
public function testChildOfDraft() { public function testChildOfDraft() {
RootURLController::reset(); RootURLController::reset();
SiteTree::enable_nested_urls(); Config::inst()->update('SiteTree', 'nested_urls', true);
$draft = new Page(); $draft = new Page();
$draft->Title = 'Root Leve Draft Page'; $draft->Title = 'Root Leve Draft Page';

View File

@ -4,14 +4,14 @@
* @subpackage tests * @subpackage tests
*/ */
class RootURLControllerTest extends SapphireTest { class RootURLControllerTest extends SapphireTest {
static $fixture_file = 'RootURLControllerTest.yml'; protected static $fixture_file = 'RootURLControllerTest.yml';
public function testGetHomepageLink() { public function testGetHomepageLink() {
$default = $this->objFromFixture('Page', 'home'); $default = $this->objFromFixture('Page', 'home');
SiteTree::disable_nested_urls(); SiteTree::config()->nested_urls = false;
$this->assertEquals('home', RootURLController::get_homepage_link()); $this->assertEquals('home', RootURLController::get_homepage_link());
SiteTree::enable_nested_urls(); Config::inst()->update('SiteTree', 'nested_urls', true);
$this->assertEquals('home', RootURLController::get_homepage_link()); $this->assertEquals('home', RootURLController::get_homepage_link());
} }

View File

@ -6,7 +6,7 @@
class SilverStripeNavigatorTest extends SapphireTest { class SilverStripeNavigatorTest extends SapphireTest {
static $fixture_file = 'cms/tests/controller/CMSMainTest.yml'; protected static $fixture_file = 'cms/tests/controller/CMSMainTest.yml';
public function testGetItems() { public function testGetItems() {
$page = $this->objFromFixture('Page', 'page1'); $page = $this->objFromFixture('Page', 'page1');

View File

@ -5,7 +5,7 @@
*/ */
class ErrorPageTest extends FunctionalTest { class ErrorPageTest extends FunctionalTest {
static $fixture_file = 'ErrorPageTest.yml'; protected static $fixture_file = 'ErrorPageTest.yml';
protected $orig = array(); protected $orig = array();
@ -14,20 +14,18 @@ class ErrorPageTest extends FunctionalTest {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->orig['ErrorPage_staticfilepath'] = ErrorPage::get_static_filepath(); $this->orig['ErrorPage_staticfilepath'] = ErrorPage::config()->static_filepath;
$this->tmpAssetsPath = sprintf('%s/_tmp_assets_%s', TEMP_FOLDER, rand()); $this->tmpAssetsPath = sprintf('%s/_tmp_assets_%s', TEMP_FOLDER, rand());
Filesystem::makeFolder($this->tmpAssetsPath . '/ErrorPageTest'); Filesystem::makeFolder($this->tmpAssetsPath . '/ErrorPageTest');
ErrorPage::set_static_filepath($this->tmpAssetsPath . '/ErrorPageTest'); ErrorPage::config()->static_filepath = $this->tmpAssetsPath . '/ErrorPageTest';
$this->orig['Director_environmenttype'] = Director::get_environment_type(); Config::inst()->update('Director', 'environment_type', 'live');
Director::set_environment_type('live');
} }
public function tearDown() { public function tearDown() {
parent::tearDown(); parent::tearDown();
ErrorPage::set_static_filepath($this->orig['ErrorPage_staticfilepath']); ErrorPage::config()->static_filepath = $this->orig['ErrorPage_staticfilepath'];
Director::set_environment_type($this->orig['Director_environmenttype']);
Filesystem::removeFolder($this->tmpAssetsPath . '/ErrorPageTest'); Filesystem::removeFolder($this->tmpAssetsPath . '/ErrorPageTest');
Filesystem::removeFolder($this->tmpAssetsPath); Filesystem::removeFolder($this->tmpAssetsPath);

View File

@ -4,7 +4,7 @@
* Tests link tracking to files and images. * Tests link tracking to files and images.
*/ */
class FileLinkTrackingTest extends SapphireTest { class FileLinkTrackingTest extends SapphireTest {
static $fixture_file = "FileLinkTrackingTest.yml"; protected static $fixture_file = "FileLinkTrackingTest.yml";
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();

View File

@ -1,8 +1,8 @@
<?php <?php
class RedirectorPageTest extends FunctionalTest { class RedirectorPageTest extends FunctionalTest {
static $fixture_file = 'RedirectorPageTest.yml'; protected static $fixture_file = 'RedirectorPageTest.yml';
static $use_draft_site = true; protected static $use_draft_site = true;
public function testGoodRedirectors() { public function testGoodRedirectors() {
/* For good redirectors, the final destination URL will be returned */ /* For good redirectors, the final destination URL will be returned */

View File

@ -28,7 +28,7 @@ class SiteConfigTest extends SapphireTest {
$this->assertContains('blackcandy', $themes, 'Test themes contain blackcandy theme'); $this->assertContains('blackcandy', $themes, 'Test themes contain blackcandy theme');
$this->assertContains('darkshades', $themes, 'Test themes contain darkshades theme'); $this->assertContains('darkshades', $themes, 'Test themes contain darkshades theme');
SiteConfig::disable_theme('darkshades'); SiteConfig::config()->disabled_themes = array('darkshades');
$themes = $config->getAvailableThemes($testThemeBaseDir); $themes = $config->getAvailableThemes($testThemeBaseDir);
$this->assertFalse(in_array('darkshades', $themes), 'Darkshades was disabled - it is no longer available'); $this->assertFalse(in_array('darkshades', $themes), 'Darkshades was disabled - it is no longer available');

View File

@ -14,7 +14,7 @@
*/ */
class SiteTreeActionsTest extends FunctionalTest { class SiteTreeActionsTest extends FunctionalTest {
static $fixture_file = 'SiteTreeActionsTest.yml'; protected static $fixture_file = 'SiteTreeActionsTest.yml';
public function testActionsReadonly() { public function testActionsReadonly() {
if(class_exists('SiteTreeCMSWorkflow')) return true; if(class_exists('SiteTreeCMSWorkflow')) return true;

View File

@ -1,7 +1,7 @@
<?php <?php
class SiteTreeBacklinksTest extends SapphireTest { class SiteTreeBacklinksTest extends SapphireTest {
static $fixture_file = "SiteTreeBacklinksTest.yml"; protected static $fixture_file = "SiteTreeBacklinksTest.yml";
protected $requiredExtensions = array( protected $requiredExtensions = array(
'SiteTree' => array('SiteTreeBacklinksTest_DOD'), 'SiteTree' => array('SiteTreeBacklinksTest_DOD'),
@ -232,7 +232,7 @@ class SiteTreeBacklinksTest extends SapphireTest {
class SiteTreeBacklinksTest_DOD extends DataExtension implements TestOnly { class SiteTreeBacklinksTest_DOD extends DataExtension implements TestOnly {
static $db = array( private static $db = array(
'ExtraContent' => 'HTMLText', 'ExtraContent' => 'HTMLText',
); );

View File

@ -4,7 +4,7 @@
* @subpackage tests * @subpackage tests
*/ */
class SiteTreeBrokenLinksTest extends SapphireTest { class SiteTreeBrokenLinksTest extends SapphireTest {
static $fixture_file = 'SiteTreeBrokenLinksTest.yml'; protected static $fixture_file = 'SiteTreeBrokenLinksTest.yml';
public function testBrokenLinksBetweenPages() { public function testBrokenLinksBetweenPages() {
$obj = $this->objFromFixture('Page','content'); $obj = $this->objFromFixture('Page','content');

View File

@ -1,8 +1,8 @@
<?php <?php
class SiteTreeHtmlEditorFieldTest extends FunctionalTest { class SiteTreeHtmlEditorFieldTest extends FunctionalTest {
public static $fixture_file = 'SiteTreeHtmlEditorFieldTest.yml'; protected static $fixture_file = 'SiteTreeHtmlEditorFieldTest.yml';
public static $use_draft_site = true; protected static $use_draft_site = true;
public function testLinkTracking() { public function testLinkTracking() {
$sitetree = $this->objFromFixture('SiteTree', 'home'); $sitetree = $this->objFromFixture('SiteTree', 'home');

View File

@ -7,7 +7,7 @@
* @todo Test canCreate() * @todo Test canCreate()
*/ */
class SiteTreePermissionsTest extends FunctionalTest { class SiteTreePermissionsTest extends FunctionalTest {
static $fixture_file = "SiteTreePermissionsTest.yml"; protected static $fixture_file = "SiteTreePermissionsTest.yml";
protected $illegalExtensions = array( protected $illegalExtensions = array(
'SiteTree' => array('SiteTreeSubsites') 'SiteTree' => array('SiteTreeSubsites')

View File

@ -4,7 +4,7 @@
* @subpackage tests * @subpackage tests
*/ */
class SiteTreeTest extends SapphireTest { class SiteTreeTest extends SapphireTest {
static $fixture_file = 'SiteTreeTest.yml'; protected static $fixture_file = 'SiteTreeTest.yml';
protected $illegalExtensions = array( protected $illegalExtensions = array(
'SiteTree' => array('SiteTreeSubsites') 'SiteTree' => array('SiteTreeSubsites')
@ -27,14 +27,14 @@ class SiteTreeTest extends SapphireTest {
$this->assertEquals(DB::query('SELECT COUNT("ID") FROM "SiteTree"')->value(), 0); $this->assertEquals(DB::query('SELECT COUNT("ID") FROM "SiteTree"')->value(), 0);
// Disable the creation // Disable the creation
SiteTree::set_create_default_pages(false); SiteTree::config()->create_default_pages = false;
singleton('SiteTree')->requireDefaultRecords(); singleton('SiteTree')->requireDefaultRecords();
// The table should still be empty // The table should still be empty
$this->assertEquals(DB::query('SELECT COUNT("ID") FROM "SiteTree"')->value(), 0); $this->assertEquals(DB::query('SELECT COUNT("ID") FROM "SiteTree"')->value(), 0);
// Enable the creation // Enable the creation
SiteTree::set_create_default_pages(true); SiteTree::config()->create_default_pages = true;
singleton('SiteTree')->requireDefaultRecords(); singleton('SiteTree')->requireDefaultRecords();
// The table should now have three rows (home, about-us, contact-us) // The table should now have three rows (home, about-us, contact-us)
@ -273,7 +273,7 @@ class SiteTreeTest extends SapphireTest {
$product = $this->objFromFixture('Page', 'product1'); $product = $this->objFromFixture('Page', 'product1');
$notFound = $this->objFromFixture('ErrorPage', '404'); $notFound = $this->objFromFixture('ErrorPage', '404');
SiteTree::disable_nested_urls(); SiteTree::config()->nested_urls = false;
$this->assertEquals($home->ID, SiteTree::get_by_link('/', false)->ID); $this->assertEquals($home->ID, SiteTree::get_by_link('/', false)->ID);
$this->assertEquals($home->ID, SiteTree::get_by_link('/home/', false)->ID); $this->assertEquals($home->ID, SiteTree::get_by_link('/home/', false)->ID);
@ -282,7 +282,7 @@ class SiteTreeTest extends SapphireTest {
$this->assertEquals($product->ID, SiteTree::get_by_link($product->Link(), false)->ID); $this->assertEquals($product->ID, SiteTree::get_by_link($product->Link(), false)->ID);
$this->assertEquals($notFound->ID, SiteTree::get_by_link($notFound->Link(), false)->ID); $this->assertEquals($notFound->ID, SiteTree::get_by_link($notFound->Link(), false)->ID);
SiteTree::enable_nested_urls(); Config::inst()->update('SiteTree', 'nested_urls', true);
$this->assertEquals($home->ID, SiteTree::get_by_link('/', false)->ID); $this->assertEquals($home->ID, SiteTree::get_by_link('/', false)->ID);
$this->assertEquals($home->ID, SiteTree::get_by_link('/home/', false)->ID); $this->assertEquals($home->ID, SiteTree::get_by_link('/home/', false)->ID);
@ -300,7 +300,7 @@ class SiteTreeTest extends SapphireTest {
$about = $this->objFromFixture('Page', 'about'); $about = $this->objFromFixture('Page', 'about');
$staff = $this->objFromFixture('Page', 'staff'); $staff = $this->objFromFixture('Page', 'staff');
SiteTree::enable_nested_urls(); Config::inst()->update('SiteTree', 'nested_urls', true);
$this->assertEquals('about-us/', $about->RelativeLink(), 'Matches URLSegment on top level without parameters'); $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'); $this->assertEquals('about-us/my-staff/', $staff->RelativeLink(), 'Matches URLSegment plus parent on second level without parameters');
@ -312,7 +312,7 @@ class SiteTreeTest extends SapphireTest {
$parent = $this->objFromFixture('Page', 'about'); $parent = $this->objFromFixture('Page', 'about');
$child = $this->objFromFixture('Page', 'staff'); $child = $this->objFromFixture('Page', 'staff');
SiteTree::enable_nested_urls(); Config::inst()->update('SiteTree', 'nested_urls', true);
$child->publish('Stage', 'Live'); $child->publish('Stage', 'Live');
$parent->URLSegment = 'changed-on-live'; $parent->URLSegment = 'changed-on-live';
@ -326,7 +326,7 @@ class SiteTreeTest extends SapphireTest {
} }
public function testDeleteFromStageOperatesRecursively() { public function testDeleteFromStageOperatesRecursively() {
SiteTree::set_enforce_strict_hierarchy(false); Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false);
$pageAbout = $this->objFromFixture('Page', 'about'); $pageAbout = $this->objFromFixture('Page', 'about');
$pageStaff = $this->objFromFixture('Page', 'staff'); $pageStaff = $this->objFromFixture('Page', 'staff');
$pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate'); $pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate');
@ -336,7 +336,7 @@ class SiteTreeTest extends SapphireTest {
$this->assertFalse(DataObject::get_by_id('Page', $pageAbout->ID)); $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', $pageStaff->ID) instanceof Page);
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page); $this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
SiteTree::set_enforce_strict_hierarchy(true); Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true);
} }
public function testDeleteFromStageOperatesRecursivelyStrict() { public function testDeleteFromStageOperatesRecursivelyStrict() {
@ -352,7 +352,7 @@ class SiteTreeTest extends SapphireTest {
} }
public function testDeleteFromLiveOperatesRecursively() { public function testDeleteFromLiveOperatesRecursively() {
SiteTree::set_enforce_strict_hierarchy(false); Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false);
$this->logInWithPermission('ADMIN'); $this->logInWithPermission('ADMIN');
$pageAbout = $this->objFromFixture('Page', 'about'); $pageAbout = $this->objFromFixture('Page', 'about');
@ -372,11 +372,11 @@ class SiteTreeTest extends SapphireTest {
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page); $this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page); $this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
Versioned::reading_stage('Stage'); Versioned::reading_stage('Stage');
SiteTree::set_enforce_strict_hierarchy(true); Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true);
} }
public function testUnpublishDoesNotDeleteChildrenWithLooseHierachyOn() { public function testUnpublishDoesNotDeleteChildrenWithLooseHierachyOn() {
SiteTree::set_enforce_strict_hierarchy(false); Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false);
$this->logInWithPermission('ADMIN'); $this->logInWithPermission('ADMIN');
$pageAbout = $this->objFromFixture('Page', 'about'); $pageAbout = $this->objFromFixture('Page', 'about');
@ -394,7 +394,7 @@ class SiteTreeTest extends SapphireTest {
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page); $this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page); $this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
Versioned::reading_stage('Stage'); Versioned::reading_stage('Stage');
SiteTree::set_enforce_strict_hierarchy(true); Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true);
} }
@ -634,7 +634,7 @@ class SiteTreeTest extends SapphireTest {
*/ */
public function testValidURLSegmentURLSegmentConflicts() { public function testValidURLSegmentURLSegmentConflicts() {
$sitetree = new SiteTree(); $sitetree = new SiteTree();
SiteTree::disable_nested_urls(); SiteTree::config()->nested_urls = false;
$sitetree->URLSegment = 'home'; $sitetree->URLSegment = 'home';
$this->assertFalse($sitetree->validURLSegment(), 'URLSegment conflicts are recognised'); $this->assertFalse($sitetree->validURLSegment(), 'URLSegment conflicts are recognised');
@ -645,7 +645,7 @@ class SiteTreeTest extends SapphireTest {
$sitetree->URLSegment = 'home'; $sitetree->URLSegment = 'home';
$this->assertFalse($sitetree->validURLSegment(), 'Conflicts are still recognised with a ParentID value'); $this->assertFalse($sitetree->validURLSegment(), 'Conflicts are still recognised with a ParentID value');
SiteTree::enable_nested_urls(); Config::inst()->update('SiteTree', 'nested_urls', true);
$sitetree->ParentID = 0; $sitetree->ParentID = 0;
$sitetree->URLSegment = 'home'; $sitetree->URLSegment = 'home';
@ -674,7 +674,7 @@ class SiteTreeTest extends SapphireTest {
* @covers SiteTree::validURLSegment * @covers SiteTree::validURLSegment
*/ */
public function testValidURLSegmentControllerConflicts() { public function testValidURLSegmentControllerConflicts() {
SiteTree::enable_nested_urls(); Config::inst()->update('SiteTree', 'nested_urls', true);
$sitetree = new SiteTree(); $sitetree = new SiteTree();
$sitetree->ParentID = $this->idFromFixture('SiteTreeTest_Conflicted', 'parent'); $sitetree->ParentID = $this->idFromFixture('SiteTreeTest_Conflicted', 'parent');
@ -693,8 +693,8 @@ class SiteTreeTest extends SapphireTest {
} }
public function testURLSegmentMultiByte() { public function testURLSegmentMultiByte() {
$origAllow = URLSegmentFilter::$default_allow_multibyte; $origAllow = Config::inst()->get('URLSegmentFilter', 'default_allow_multibyte');
URLSegmentFilter::$default_allow_multibyte = true; Config::inst()->update('URLSegmentFilter', 'default_allow_multibyte', true);
$sitetree = new SiteTree(); $sitetree = new SiteTree();
$sitetree->write(); $sitetree->write();
@ -709,7 +709,7 @@ class SiteTreeTest extends SapphireTest {
$sitetreeLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' .$sitetree->ID, false); $sitetreeLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' .$sitetree->ID, false);
$this->assertEquals($sitetreeLive->URLSegment, rawurlencode('brötchen')); $this->assertEquals($sitetreeLive->URLSegment, rawurlencode('brötchen'));
URLSegmentFilter::$default_allow_multibyte = $origAllow; Config::inst()->update('URLSegmentFilter', 'default_allow_multibyte', $origAllow);
} }
public function testVersionsAreCreated() { public function testVersionsAreCreated() {
@ -895,7 +895,7 @@ class SiteTreeTest_PageNode_Controller extends Page_Controller implements TestOn
class SiteTreeTest_Conflicted extends Page implements TestOnly { } class SiteTreeTest_Conflicted extends Page implements TestOnly { }
class SiteTreeTest_Conflicted_Controller extends Page_Controller implements TestOnly { class SiteTreeTest_Conflicted_Controller extends Page_Controller implements TestOnly {
public static $allowed_actions = array ( private static $allowed_actions = array (
'conflicted-action' 'conflicted-action'
); );
@ -917,32 +917,32 @@ class SiteTreeTest_NullHtmlCleaner extends HTMLCleaner {
class SiteTreeTest_ClassA extends Page implements TestOnly { class SiteTreeTest_ClassA extends Page implements TestOnly {
static $need_permission = array('ADMIN', 'CMS_ACCESS_CMSMain'); private static $need_permission = array('ADMIN', 'CMS_ACCESS_CMSMain');
static $allowed_children = array('SiteTreeTest_ClassB'); private static $allowed_children = array('SiteTreeTest_ClassB');
} }
class SiteTreeTest_ClassB extends Page implements TestOnly { class SiteTreeTest_ClassB extends Page implements TestOnly {
// Also allowed subclasses // Also allowed subclasses
static $allowed_children = array('SiteTreeTest_ClassC'); private static $allowed_children = array('SiteTreeTest_ClassC');
} }
class SiteTreeTest_ClassC extends Page implements TestOnly { class SiteTreeTest_ClassC extends Page implements TestOnly {
static $allowed_children = array(); private static $allowed_children = array();
} }
class SiteTreeTest_ClassD extends Page implements TestOnly { class SiteTreeTest_ClassD extends Page implements TestOnly {
// Only allows this class, no children classes // Only allows this class, no children classes
static $allowed_children = array('*SiteTreeTest_ClassC'); private static $allowed_children = array('*SiteTreeTest_ClassC');
} }
class SiteTreeTest_ClassCext extends SiteTreeTest_ClassC implements TestOnly { class SiteTreeTest_ClassCext extends SiteTreeTest_ClassC implements TestOnly {
// Override SiteTreeTest_ClassC definitions // Override SiteTreeTest_ClassC definitions
static $allowed_children = array('SiteTreeTest_ClassB'); private static $allowed_children = array('SiteTreeTest_ClassB');
} }
class SiteTreeTest_NotRoot extends Page implements TestOnly { class SiteTreeTest_NotRoot extends Page implements TestOnly {
static $can_be_root = false; private static $can_be_root = false;
} }
class SiteTreeTest_StageStatusInherit extends SiteTree implements TestOnly { class SiteTreeTest_StageStatusInherit extends SiteTree implements TestOnly {

View File

@ -1,7 +1,7 @@
<?php <?php
class VirtualPageTest extends SapphireTest { class VirtualPageTest extends SapphireTest {
static $fixture_file = 'VirtualPageTest.yml'; protected static $fixture_file = 'VirtualPageTest.yml';
protected $extraDataObjects = array( protected $extraDataObjects = array(
'VirtualPageTest_ClassA', 'VirtualPageTest_ClassA',
@ -16,18 +16,18 @@ class VirtualPageTest extends SapphireTest {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->origInitiallyCopiedFields = VirtualPage::$initially_copied_fields; $this->origInitiallyCopiedFields = VirtualPage::config()->initially_copied_fields;
VirtualPage::$initially_copied_fields[] = 'MyInitiallyCopiedField'; VirtualPage::config()->initially_copied_fields = array('MyInitiallyCopiedField');
$this->origNonVirtualField = VirtualPage::$non_virtual_fields; $this->origNonVirtualField = VirtualPage::config()->non_virtual_fields;
VirtualPage::$non_virtual_fields[] = 'MyNonVirtualField'; $nonVirtual = VirtualPage::config()->non_virtual_fields;
VirtualPage::$non_virtual_fields[] = 'MySharedNonVirtualField'; VirtualPage::config()->non_virtual_fields = array('MyNonVirtualField', 'MySharedNonVirtualField');
} }
public function tearDown() { public function tearDown() {
parent::tearDown(); parent::tearDown();
VirtualPage::$initially_copied_fields = $this->origInitiallyCopiedFields; VirtualPage::config()->initially_copied_fields = $this->origInitiallyCopiedFields;
VirtualPage::$non_virtual_fields = $this->origNonVirtualField; VirtualPage::config()->non_virtual_fields = $this->origNonVirtualField;
} }
/** /**
@ -579,36 +579,36 @@ class VirtualPageTest extends SapphireTest {
class VirtualPageTest_ClassA extends Page implements TestOnly { class VirtualPageTest_ClassA extends Page implements TestOnly {
static $db = array( private static $db = array(
'MyInitiallyCopiedField' => 'Text', 'MyInitiallyCopiedField' => 'Text',
'MyVirtualField' => 'Text', 'MyVirtualField' => 'Text',
'MyNonVirtualField' => 'Text', 'MyNonVirtualField' => 'Text',
); );
static $allowed_children = array('VirtualPageTest_ClassB'); private static $allowed_children = array('VirtualPageTest_ClassB');
} }
class VirtualPageTest_ClassB extends Page implements TestOnly { class VirtualPageTest_ClassB extends Page implements TestOnly {
static $allowed_children = array('VirtualPageTest_ClassC'); private static $allowed_children = array('VirtualPageTest_ClassC');
} }
class VirtualPageTest_ClassC extends Page implements TestOnly { class VirtualPageTest_ClassC extends Page implements TestOnly {
static $allowed_children = array(); private static $allowed_children = array();
} }
class VirtualPageTest_NotRoot extends Page implements TestOnly { class VirtualPageTest_NotRoot extends Page implements TestOnly {
static $can_be_root = false; private static $can_be_root = false;
} }
class VirtualPageTest_VirtualPageSub extends VirtualPage implements TestOnly { class VirtualPageTest_VirtualPageSub extends VirtualPage implements TestOnly {
static $db = array( private static $db = array(
'MyProperty' => 'Varchar', 'MyProperty' => 'Varchar',
); );
} }
class VirtualPageTest_PageExtension extends DataExtension implements TestOnly { class VirtualPageTest_PageExtension extends DataExtension implements TestOnly {
static $db = array( private static $db = array(
// These fields are just on an extension to simulate shared properties between Page and VirtualPage. // These fields are just on an extension to simulate shared properties between Page and VirtualPage.
// Not possible through direct $db definitions due to VirtualPage inheriting from Page, and Page being defined elsewhere. // Not possible through direct $db definitions due to VirtualPage inheriting from Page, and Page being defined elsewhere.
'MySharedVirtualField' => 'Text', 'MySharedVirtualField' => 'Text',

View File

@ -6,9 +6,9 @@
class SideReportTest extends SapphireTest { class SideReportTest extends SapphireTest {
static $fixture_file = 'SideReportTest.yml'; protected static $fixture_file = 'SideReportTest.yml';
static $daysAgo = 14; private static $daysAgo = 14;
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();

View File

@ -1,7 +1,7 @@
<?php <?php
class CMSMainSearchFormTest extends FunctionalTest { class CMSMainSearchFormTest extends FunctionalTest {
static $fixture_file = '../controller/CMSMainTest.yml'; protected static $fixture_file = '../controller/CMSMainTest.yml';
protected $autoFollowRedirection = false; protected $autoFollowRedirection = false;

View File

@ -10,7 +10,7 @@
*/ */
class ZZZSearchFormTest extends FunctionalTest { class ZZZSearchFormTest extends FunctionalTest {
static $fixture_file = 'SearchFormTest.yml'; protected static $fixture_file = 'SearchFormTest.yml';
protected $mockController; protected $mockController;

View File

@ -11,15 +11,14 @@ class FilesystemPublisherTest extends SapphireTest {
protected $orig = array(); protected $orig = array();
static $fixture_file = 'cms/tests/staticpublisher/FilesystemPublisherTest.yml'; protected static $fixture_file = 'cms/tests/staticpublisher/FilesystemPublisherTest.yml';
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
SiteTree::add_extension("FilesystemPublisher('assets/FilesystemPublisherTest-static-folder/')"); SiteTree::add_extension("FilesystemPublisher('assets/FilesystemPublisherTest-static-folder/')");
$this->orig['domain_based_caching'] = FilesystemPublisher::$domain_based_caching; Config::inst()->update('FilesystemPublisher', 'domain_based_caching', false);
FilesystemPublisher::$domain_based_caching = false;
} }
public function tearDown() { public function tearDown() {
@ -27,8 +26,6 @@ class FilesystemPublisherTest extends SapphireTest {
SiteTree::remove_extension("FilesystemPublisher('assets/FilesystemPublisherTest-static-folder/')"); SiteTree::remove_extension("FilesystemPublisher('assets/FilesystemPublisherTest-static-folder/')");
FilesystemPublisher::$domain_based_caching = $this->orig['domain_based_caching'];
if(file_exists(BASE_PATH . '/assets/FilesystemPublisherTest-static-folder')) { if(file_exists(BASE_PATH . '/assets/FilesystemPublisherTest-static-folder')) {
Filesystem::removeFolder(BASE_PATH . '/assets/FilesystemPublisherTest-static-folder'); Filesystem::removeFolder(BASE_PATH . '/assets/FilesystemPublisherTest-static-folder');
} }
@ -82,8 +79,7 @@ class FilesystemPublisherTest extends SapphireTest {
} }
public function testUrlsToPathsWithDomainBasedCaching() { public function testUrlsToPathsWithDomainBasedCaching() {
$origDomainBasedCaching = FilesystemPublisher::$domain_based_caching; Config::inst()->update('FilesystemPublisher', 'domain_based_caching', true);
FilesystemPublisher::$domain_based_caching = true;
$fsp = new FilesystemPublisher('.', 'html'); $fsp = new FilesystemPublisher('.', 'html');
@ -107,8 +103,6 @@ class FilesystemPublisherTest extends SapphireTest {
array($url => 'domain2.com/parent/child.html'), array($url => 'domain2.com/parent/child.html'),
'Nested URLsegment path mapping' 'Nested URLsegment path mapping'
); );
FilesystemPublisher::$domain_based_caching = $origDomainBasedCaching;
} }
/** /**
@ -134,7 +128,7 @@ class FilesystemPublisherTest extends SapphireTest {
public function testStaticPublisherTheme(){ public function testStaticPublisherTheme(){
//This will be the name of the default theme of this particular project //This will be the name of the default theme of this particular project
$default_theme=SSViewer::current_theme(); $default_theme= Config::inst()->get('SSViewer', 'theme');
$p1 = new Page(); $p1 = new Page();
$p1->URLSegment = strtolower(__CLASS__).'-page-1'; $p1->URLSegment = strtolower(__CLASS__).'-page-1';
@ -142,21 +136,13 @@ class FilesystemPublisherTest extends SapphireTest {
$p1->write(); $p1->write();
$p1->doPublish(); $p1->doPublish();
$current_theme=SSViewer::current_custom_theme(); $current_theme=Config::inst()->get('SSViewer', 'custom_theme');
$this->assertEquals($current_theme, $default_theme, 'After a standard publication, the theme is correct'); $this->assertEquals($current_theme, $default_theme, 'After a standard publication, the theme is correct');
//The CMS sometimes sets the theme to null. Check that the $current_custom_theme is still the default //The CMS sometimes sets the theme to null. Check that the $current_custom_theme is still the default
SSViewer::set_theme(null); Config::inst()->update('SSViewer', 'theme', null);
$current_theme=SSViewer::current_custom_theme(); $current_theme=Config::inst()->get('SSViewer', 'custom_theme');
$this->assertEquals($current_theme, $default_theme, 'After a setting the theme to null, the default theme is correct'); $this->assertEquals($current_theme, $default_theme, 'After a setting the theme to null, the default theme is correct');
//We can set the static_publishing theme to something completely different:
//Static publishing will use this one instead of the current_custom_theme if it is not false
StaticPublisher::set_static_publisher_theme('otherTheme');
$current_theme=StaticPublisher::static_publisher_theme();
$this->assertNotEquals($current_theme, $default_theme, 'The static publisher theme overrides the custom theme');
} }
function testPublishPages() { function testPublishPages() {

View File

@ -5,9 +5,9 @@
*/ */
class MigrateSiteTreeLinkingTaskTest extends SapphireTest { class MigrateSiteTreeLinkingTaskTest extends SapphireTest {
public static $fixture_file = 'MigrateSiteTreeLinkingTaskTest.yml'; protected static $fixture_file = 'MigrateSiteTreeLinkingTaskTest.yml';
public static $use_draft_site = true; protected static $use_draft_site = true;
public function testLinkingMigration() { public function testLinkingMigration() {
ob_start(); ob_start();

View File

@ -32,9 +32,9 @@
*/ */
class RemoveOrphanedPagesTaskTest extends FunctionalTest { class RemoveOrphanedPagesTaskTest extends FunctionalTest {
static $fixture_file = 'RemoveOrphanedPagesTaskTest.yml'; protected static $fixture_file = 'RemoveOrphanedPagesTaskTest.yml';
static $use_draft_site = false; protected static $use_draft_site = false;
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();