Merge remote-tracking branch 'origin/3.1'

Conflicts:
	code/controllers/ReportAdmin.php
	code/reports/Report.php
	tests/reports/CmsReportsTest.php
This commit is contained in:
Ingo Schommer 2013-03-26 01:21:36 +01:00
commit 8eb3840325
60 changed files with 439 additions and 361 deletions

View File

@ -8,21 +8,22 @@
*/
class AssetAdmin extends LeftAndMain implements PermissionProvider{
static $url_segment = 'assets';
private static $url_segment = 'assets';
static $url_rule = '/$Action/$ID';
private static $url_rule = '/$Action/$ID';
static $menu_title = 'Files';
private static $menu_title = 'Files';
public static $tree_class = 'Folder';
private static $tree_class = 'Folder';
/**
* @config
* @see Upload->allowedMaxFileSize
* @var int
*/
public static $allowed_max_file_size;
private static $allowed_max_file_size;
public static $allowed_actions = array(
private static $allowed_actions = array(
'addfolder',
'delete',
'AddForm',
@ -121,8 +122,8 @@ JS
// Category filter
if(isset($params['AppCategory'])) {
if(isset(File::$app_categories[$params['AppCategory']])) {
$exts = File::$app_categories[$params['AppCategory']];
if(isset(File::config()->app_categories[$params['AppCategory']])) {
$exts = File::config()->app_categories[$params['AppCategory']];
} else {
$exts = array();
}
@ -470,7 +471,7 @@ JS
$record->write();
mkdir($record->FullPath);
chmod($record->FullPath, Filesystem::$file_create_mask);
chmod($record->FullPath, Filesystem::config()->file_create_mask);
if($parentRecord) {
return $this->redirect(Controller::join_links($this->Link('show'), $parentRecord->ID));

View File

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

View File

@ -11,23 +11,23 @@
*/
class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionProvider {
static $url_segment = 'pages';
private static $url_segment = 'pages';
static $url_rule = '/$Action/$ID/$OtherID';
private static $url_rule = '/$Action/$ID/$OtherID';
// Maintain a lower priority than other administration sections
// so that Director does not think they are actions of CMSMain
static $url_priority = 39;
private static $url_priority = 39;
static $menu_title = 'Edit Page';
private static $menu_title = 'Edit Page';
static $menu_priority = 10;
private static $menu_priority = 10;
static $tree_class = "SiteTree";
private static $tree_class = "SiteTree";
static $subitem_class = "Member";
private static $subitem_class = "Member";
static $allowed_actions = array(
private static $allowed_actions = array(
'buildbrokenlinks',
'deleteitems',
'DeleteItemsForm',
@ -188,7 +188,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
}
}
protected function LinkWithSearch($link) {
public function LinkWithSearch($link) {
// Whitelist to avoid side effects
$params = array(
'q' => (array)$this->request->getVar('q'),
@ -422,7 +422,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
// then add the ones which are globally disallowed.
$disallowed = array_diff($classes, (array)$allowed);
$disallowed = array_unique(array_merge($disallowed, $globalDisallowed));
if($disallowed) $def[$class]['disallowedChildren'] = $disallowed;
// Re-index the array for JSON non sequential key issue
if($disallowed) $def[$class]['disallowedChildren'] = array_values($disallowed);
$defaultChild = $obj->defaultChild();
if($defaultChild != 'Page' && $defaultChild != null) {
@ -1124,7 +1125,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
}
public function BatchActionParameters() {
$batchActions = CMSBatchActionHandler::$batch_actions;
$batchActions = CMSBatchActionHandler::config()->batch_actions;
$forms = array();
foreach($batchActions as $urlSegment => $batchAction) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -95,7 +95,7 @@ class ModelAsController extends Controller implements NestedController {
sprintf(
'"URLSegment" = \'%s\' %s',
Convert::raw2sql(rawurlencode($URLSegment)),
(SiteTree::nested_urls() ? 'AND "ParentID" = 0' : null)
(SiteTree::config()->nested_urls ? 'AND "ParentID" = 0' : null)
)
);
if(class_exists('Translatable')) Translatable::enable_locale_filter();
@ -148,10 +148,10 @@ class ModelAsController extends Controller implements NestedController {
static public function find_old_page($URLSegment,$parentID = 0, $ignoreNestedURLs = false) {
$URLSegment = Convert::raw2sql(rawurlencode($URLSegment));
$useParentIDFilter = SiteTree::nested_urls() && $parentID;
$useParentIDFilter = SiteTree::config()->nested_urls && $parentID;
// First look for a non-nested page that has a unique URLSegment and can be redirected to.
if(SiteTree::nested_urls()) {
if(SiteTree::config()->nested_urls) {
$pages = DataObject::get(
'SiteTree',
"\"URLSegment\" = '$URLSegment'" . ($useParentIDFilter ? ' AND "ParentID" = ' . (int)$parentID : '')

View File

@ -11,9 +11,10 @@ class RootURLController extends Controller {
protected static $is_at_root = false;
/**
* @config
* @var string
*/
protected static $default_homepage_link = 'home';
private static $default_homepage_link = 'home';
/**
* @var string
@ -49,7 +50,7 @@ class RootURLController extends Controller {
) {
self::$cached_homepage_link = $link;
} else {
self::$cached_homepage_link = self::get_default_homepage_link();
self::$cached_homepage_link = Config::inst()->get('RootURLController', 'default_homepage_link');
}
}
}
@ -61,19 +62,23 @@ class RootURLController extends Controller {
* Set the URL Segment used for your homepage when it is created by dev/build.
* This allows you to use home page URLs other than the default "home".
*
* @deprecated 3.2 Use the "RootURLController.default_homepage_link" config setting instead
* @param string $urlsegment the URL segment for your home page
*/
static public function set_default_homepage_link($urlsegment = "home") {
self::$default_homepage_link = $urlsegment;
Deprecation::notice('3.2', 'Use the "RootURLController.default_homepage_link" config setting instead');
Config::inst()->update('RootURLController', 'default_homepage_link', $urlsegment);
}
/**
* Gets the link that denotes the homepage if there is not one explicitly defined for this HTTP_HOST value.
*
* @deprecated 3.2 Use the "RootURLController.default_homepage_link" config setting instead
* @return string
*/
static public function get_default_homepage_link() {
return self::$default_homepage_link;
Deprecation::notice('3.2', 'Use the "RootURLController.default_homepage_link" config setting instead');
return Config::inst()->get('RootURLController', 'default_homepage_link');
}
/**

View File

@ -83,7 +83,7 @@ class SilverStripeNavigator extends ViewableData {
$text = $item->getHTML();
if($text) $html .= $text;
$newMessage = $item->getMessage();
if($newMessage) $message = $newMessage;
if($newMessage && $item->isActive()) $message = $newMessage;
}
return array(
@ -219,7 +219,8 @@ class SilverStripeNavigatorItem extends ViewableData {
* @subpackage content
*/
class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem {
static $priority = 10;
/** @config */
private static $priority = 10;
public function getHTML() {
return sprintf(
@ -257,13 +258,14 @@ class SilverStripeNavigatorItem_CMSLink extends SilverStripeNavigatorItem {
* @subpackage content
*/
class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem {
static $priority = 20;
/** @config */
private static $priority = 20;
public function getHTML() {
$draftPage = $this->getDraftPage();
if($draftPage) {
$this->recordLink = Controller::join_links($draftPage->AbsoluteLink(), "?stage=Stage");
return "<a href=\"$this->recordLink\">". _t('ContentController.DRAFTSITE', 'Draft Site') ."</a>";
return "<a ". ($this->isActive() ? 'class="current" ' : '') ."href=\"$this->recordLink\">". _t('ContentController.DRAFTSITE', 'Draft Site') ."</a>";
}
}
@ -316,13 +318,14 @@ class SilverStripeNavigatorItem_StageLink extends SilverStripeNavigatorItem {
* @subpackage content
*/
class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem {
static $priority = 30;
/** @config */
private static $priority = 30;
public function getHTML() {
$livePage = $this->getLivePage();
if($livePage) {
$this->recordLink = Controller::join_links($livePage->AbsoluteLink(), "?stage=Live");
return "<a href=\"$this->recordLink\">". _t('ContentController.PUBLISHEDSITE', 'Published Site') ."</a>";
return "<a ". ($this->isActive() ? 'class="current" ' : '') ."href=\"$this->recordLink\">". _t('ContentController.PUBLISHEDSITE', 'Published Site') ."</a>";
}
}
@ -369,11 +372,12 @@ class SilverStripeNavigatorItem_LiveLink extends SilverStripeNavigatorItem {
* @subpackage content
*/
class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
static $priority = 40;
/** @config */
private static $priority = 40;
public function getHTML() {
$this->recordLink = $this->record->PreviewLink();
return "<a class=\"ss-ui-button\" href=\"$this->recordLink?archiveDate={$this->record->LastEdited}\" target=\"_blank\">". _t('ContentController.ARCHIVEDSITE', 'Preview version') ."</a>";
$this->recordLink = $this->record->AbsoluteLink();
return "<a class=\"ss-ui-button". ($this->isActive() ? ' current' : '') ."\" href=\"$this->recordLink?archiveDate={$this->record->LastEdited}\" target=\"_blank\">". _t('ContentController.ARCHIVEDSITE', 'Preview version') ."</a>";
}
public function getTitle() {
@ -382,8 +386,7 @@ class SilverStripeNavigatorItem_ArchiveLink extends SilverStripeNavigatorItem {
public function getMessage() {
if($date = Versioned::current_archived_date()) {
$dateObj = Datetime::create();
$dateObj->setValue($date);
$dateObj = DBField::create_field('Datetime', $date);
return "<div id=\"SilverStripeNavigatorMessage\" title=\"". _t('ContentControl.NOTEWONTBESHOWN', 'Note: this message will not be shown to your visitors') ."\">". _t('ContentController.ARCHIVEDSITEFROM', 'Archived site from') ."<br>" . $dateObj->Nice() . "</div>";
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@
* @package cms
*/
class SiteConfig extends DataObject implements PermissionProvider {
static $db = array(
private static $db = array(
"Title" => "Varchar(255)",
"Tagline" => "Varchar(255)",
"Theme" => "Varchar(255)",
@ -16,16 +16,24 @@ class SiteConfig extends DataObject implements PermissionProvider {
"CanCreateTopLevelType" => "Enum('LoggedInUsers, OnlyTheseUsers', 'LoggedInUsers')",
);
static $many_many = array(
private static $many_many = array(
"ViewerGroups" => "Group",
"EditorGroups" => "Group",
"CreateTopLevelGroups" => "Group"
);
protected static $disabled_themes = array();
/**
* @config
* @var array
*/
private static $disabled_themes = array();
/**
* @deprecated 3.2 Use the "SiteConfig.disabled_themes" config setting instead
*/
static public function disable_theme($theme) {
self::$disabled_themes[$theme] = $theme;
Deprecation::notice('3.2', 'Use the "SiteConfig.disabled_themes" config setting instead');
Config::inst()->update('SiteConfig', 'disabled_themes', array($theme));
}
public function populateDefaults()
@ -132,7 +140,8 @@ class SiteConfig extends DataObject implements PermissionProvider {
*/
public function getAvailableThemes($baseDir = null) {
$themes = SSViewer::get_themes($baseDir);
foreach(self::$disabled_themes as $theme) {
$disabled = (array)$this->config()->disabled_themes;
foreach($disabled as $theme) {
if(isset($themes[$theme])) unset($themes[$theme]);
}
return $themes;

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.
*
* @config
* @var array
*/
static $allowed_children = array("SiteTree");
private static $allowed_children = array("SiteTree");
/**
* The default child class for this page.
* Note: Value might be cached, see {@link $allowed_chilren}.
*
* @config
* @var string
*/
static $default_child = "Page";
private static $default_child = "Page";
/**
* The default parent class for this page.
* Note: Value might be cached, see {@link $allowed_chilren}.
*
* @config
* @var string
*/
static $default_parent = null;
private static $default_parent = null;
/**
* Controls whether a page can be in the root of the site tree.
* Note: Value might be cached, see {@link $allowed_chilren}.
*
* @config
* @var bool
*/
static $can_be_root = true;
private static $can_be_root = true;
/**
* List of permission codes a user can have to allow a user to create a page of this type.
* Note: Value might be cached, see {@link $allowed_chilren}.
*
* @config
* @var array
*/
static $need_permission = null;
private static $need_permission = null;
/**
* If you extend a class, and don't want to be able to select the old class
* in the cms, set this to the old class name. Eg, if you extended Product
* to make ImprovedProduct, then you would set $hide_ancestor to Product.
*
* @config
* @var string
*/
static $hide_ancestor = null;
private static $hide_ancestor = null;
static $db = array(
private static $db = array(
"URLSegment" => "Varchar(255)",
"Title" => "Varchar(255)",
"MenuTitle" => "Varchar(100)",
@ -88,27 +94,27 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
"CanEditType" => "Enum('LoggedInUsers, OnlyTheseUsers, Inherit', 'Inherit')",
);
static $indexes = array(
private static $indexes = array(
"URLSegment" => true,
);
static $many_many = array(
private static $many_many = array(
"LinkTracking" => "SiteTree",
"ImageTracking" => "File",
"ViewerGroups" => "Group",
"EditorGroups" => "Group",
);
static $belongs_many_many = array(
private static $belongs_many_many = array(
"BackLinkTracking" => "SiteTree"
);
static $many_many_extraFields = array(
private static $many_many_extraFields = array(
"LinkTracking" => array("FieldName" => "Varchar"),
"ImageTracking" => array("FieldName" => "Varchar")
);
static $casting = array(
private static $casting = array(
"Breadcrumbs" => "HTMLText",
"LastEdited" => "SS_Datetime",
"Created" => "SS_Datetime",
@ -117,67 +123,64 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
'AbsoluteLink' => 'Text',
);
static $defaults = array(
private static $defaults = array(
"ShowInMenus" => 1,
"ShowInSearch" => 1,
"CanViewType" => "Inherit",
"CanEditType" => "Inherit"
);
static $versioning = array(
private static $versioning = array(
"Stage", "Live"
);
static $default_sort = "\"Sort\"";
private static $default_sort = "\"Sort\"";
/**
* If this is false, the class cannot be created in the CMS by regular content authors, only by ADMINs.
* @var boolean
* @config
*/
static $can_create = true;
/**
* @see CMSMain::generateTreeStylingCSS()
*/
static $page_states = array('readonly');
private static $can_create = true;
/**
* Icon to use in the CMS page tree. This should be the full filename, relative to the webroot.
* Also supports custom CSS rule contents (applied to the correct selector for the tree UI implementation).
*
* @see CMSMain::generateTreeStylingCSS()
*
* @config
* @var string
*/
static $icon = null;
private static $icon = null;
/**
* @config
* @var String Description of the class functionality, typically shown to a user
* when selecting which page type to create. Translated through {@link provideI18nEntities()}.
*/
static $description = 'Generic content page';
private static $description = 'Generic content page';
static $extensions = array(
private static $extensions = array(
"Hierarchy",
"Versioned('Stage', 'Live')",
);
static $searchable_fields = array(
private static $searchable_fields = array(
'Title',
'Content',
);
static $field_labels = array(
private static $field_labels = array(
'URLSegment' => 'URL'
);
/**
* @see SiteTree::nested_urls()
* @config
*/
private static $nested_urls = true;
/**
* @see SiteTree::set_create_default_pages()
* @config
*/
private static $create_default_pages = true;
@ -192,12 +195,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
* of IDs mapped to their boolean permission ability (true=allow, false=deny).
* See {@link batch_permission_check()} for details.
*/
public static $cache_permissions = array();
private static $cache_permissions = array();
/**
* @config
* @var boolean
*/
protected static $enforce_strict_hierarchy = true;
private static $enforce_strict_hierarchy = true;
protected $_cache_statusFlags = null;
@ -205,59 +209,77 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
* Determines if the system should avoid orphaned pages
* by deleting all children when the their parent is deleted (TRUE),
* or rather preserve this data even if its not reachable through any navigation path (FALSE).
*
*
* @deprecated 3.2 Use the "SiteTree.enforce_strict_hierarchy" config setting instead
* @param boolean
*/
static public function set_enforce_strict_hierarchy($to) {
self::$enforce_strict_hierarchy = $to;
Deprecation::notice('3.2', 'Use the "SiteTree.enforce_strict_hierarchy" config setting instead');
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', $to);
}
/**
* @deprecated 3.2 Use the "SiteTree.enforce_strict_hierarchy" config setting instead
* @return boolean
*/
static public function get_enforce_strict_hierarchy() {
return self::$enforce_strict_hierarchy;
Deprecation::notice('3.2', 'Use the "SiteTree.enforce_strict_hierarchy" config setting instead');
return Config::inst()->get('SiteTree', 'enforce_strict_hierarchy');
}
/**
* Returns TRUE if nested URLs (e.g. page/sub-page/) are currently enabled on this site.
*
* @deprecated 3.2 Use the "SiteTree.nested_urls" config setting instead
* @return bool
*/
static public function nested_urls() {
return self::$nested_urls;
Deprecation::notice('3.2', 'Use the "SiteTree.nested_urls" config setting instead');
return Config::inst()->get('SiteTree', 'nested_urls');
}
/**
* @deprecated 3.2 Use the "SiteTree.nested_urls" config setting instead
*/
static public function enable_nested_urls() {
self::$nested_urls = true;
Deprecation::notice('3.2', 'Use the "SiteTree.nested_urls" config setting instead');
Config::inst()->update('SiteTree', 'nested_urls', true);
}
/**
* @deprecated 3.2 Use the "SiteTree.nested_urls" config setting instead
*/
static public function disable_nested_urls() {
self::$nested_urls = false;
Deprecation::notice('3.2', 'Use the "SiteTree.nested_urls" config setting instead');
Config::inst()->update('SiteTree', 'nested_urls', false);
}
/**
* Set the (re)creation of default pages on /dev/build
*
* @deprecated 3.2 Use the "SiteTree.create_default_pages" config setting instead
* @param bool $option
*/
static public function set_create_default_pages($option = true) {
self::$create_default_pages = $option;
Deprecation::notice('3.2', 'Use the "SiteTree.create_default_pages" config setting instead');
Config::inst()->update('SiteTree', 'create_default_pages', $option);
}
/**
* Return true if default pages should be created on /dev/build.
*
* @deprecated 3.2 Use the "SiteTree.create_default_pages" config setting instead
* @return bool
*/
static public function get_create_default_pages() {
return self::$create_default_pages;
Deprecation::notice('3.2', 'Use the "SiteTree.create_default_pages" config setting instead');
return Config::inst()->get('SiteTree', 'create_default_pages');
}
/**
* Fetches the {@link SiteTree} object that maps to a link.
*
* If you have enabled {@link SiteTree::nested_urls()} on this site, then you can use a nested link such as
* If you have enabled {@link SiteTree::config()->nested_urls} on this site, then you can use a nested link such as
* "about-us/staff/", and this function will traverse down the URL chain and grab the appropriate link.
*
* Note that if no model can be found, this method will fall over to a extended alternateGetByLink method provided
@ -279,17 +301,17 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
// Grab the initial root level page to traverse down from.
$URLSegment = array_shift($parts);
$sitetree = DataObject::get_one (
'SiteTree', "\"URLSegment\" = '$URLSegment'" . (self::nested_urls() ? ' AND "ParentID" = 0' : ''), $cache
'SiteTree', "\"URLSegment\" = '$URLSegment'" . (self::config()->nested_urls ? ' AND "ParentID" = 0' : ''), $cache
);
/// Fall back on a unique URLSegment for b/c.
if(!$sitetree && self::nested_urls() && $page = DataObject::get('SiteTree', "\"URLSegment\" = '$URLSegment'")->First()) {
if(!$sitetree && self::config()->nested_urls && $page = DataObject::get('SiteTree', "\"URLSegment\" = '$URLSegment'")->First()) {
return $page;
}
// Attempt to grab an alternative page from extensions.
if(!$sitetree) {
$parentID = self::nested_urls() ? 0 : null;
$parentID = self::config()->nested_urls ? 0 : null;
if($alternatives = singleton('SiteTree')->extend('alternateGetByLink', $URLSegment, $parentID)) {
foreach($alternatives as $alternative) if($alternative) $sitetree = $alternative;
@ -299,7 +321,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
}
// Check if we have any more URL parts to parse.
if(!self::nested_urls() || !count($parts)) return $sitetree;
if(!self::config()->nested_urls || !count($parts)) return $sitetree;
// Traverse down the remaining URL segments and grab the relevant SiteTree objects.
foreach($parts as $segment) {
@ -438,7 +460,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
* @return string
*/
public function RelativeLink($action = null) {
if($this->ParentID && self::nested_urls()) {
if($this->ParentID && self::config()->nested_urls) {
$base = $this->Parent()->RelativeLink($this->URLSegment);
} else {
$base = $this->URLSegment;
@ -1275,7 +1297,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
$tags .= "<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";
if($this->MetaDescription) {
$tags .= "<meta name=\"description\" content=\"" . Convert::raw2att($this->MetaDescription) . "\" />\n";
@ -1322,12 +1344,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
parent::requireDefaultRecords();
// default pages
if($this->class == 'SiteTree' && self::get_create_default_pages()) {
if(!SiteTree::get_by_link(RootURLController::get_default_homepage_link())) {
if($this->class == 'SiteTree' && $this->config()->create_default_pages) {
if(!SiteTree::get_by_link(Config::inst()->get('RootURLController', 'default_homepage_link'))) {
$homepage = new Page();
$homepage->Title = _t('SiteTree.DEFAULTHOMETITLE', 'Home');
$homepage->Content = _t('SiteTree.DEFAULTHOMECONTENT', '<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->write();
$homepage->publish('Stage', 'Live');
@ -1467,7 +1489,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
parent::onBeforeDelete();
// If deleting this page, delete all its children.
if(SiteTree::get_enforce_strict_hierarchy() && $children = $this->Children()) {
if(SiteTree::config()->enforce_strict_hierarchy && $children = $this->Children()) {
foreach($children as $child) {
$child->delete();
}
@ -1542,20 +1564,20 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
* @return bool
*/
public function validURLSegment() {
if(self::nested_urls() && $parent = $this->Parent()) {
if(self::config()->nested_urls && $parent = $this->Parent()) {
if($controller = ModelAsController::controller_for($parent)) {
if($controller instanceof Controller && $controller->hasAction($this->URLSegment)) return false;
}
}
if(!self::nested_urls() || !$this->ParentID) {
if(!self::config()->nested_urls || !$this->ParentID) {
if(class_exists($this->URLSegment) && is_subclass_of($this->URLSegment, 'RequestHandler')) return false;
}
$IDFilter = ($this->ID) ? "AND \"SiteTree\".\"ID\" <> $this->ID" : null;
$parentFilter = null;
if(self::nested_urls()) {
if(self::config()->nested_urls) {
if($this->ParentID) {
$parentFilter = " AND \"SiteTree\".\"ParentID\" = $this->ParentID";
} else {
@ -1826,13 +1848,13 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
$baseLink = Controller::join_links (
Director::absoluteBaseURL(),
(self::nested_urls() && $this->ParentID ? $this->Parent()->RelativeLink(true) : null)
(self::config()->nested_urls && $this->ParentID ? $this->Parent()->RelativeLink(true) : null)
);
$urlsegment = new SiteTreeURLSegmentField("URLSegment", $this->fieldLabel('URLSegment'));
$urlsegment->setURLPrefix($baseLink);
$helpText = (self::nested_urls() && count($this->Children())) ? $this->fieldLabel('LinkChangeNote') : '';
if(!URLSegmentFilter::$default_allow_multibyte) {
$helpText = (self::config()->nested_urls && count($this->Children())) ? $this->fieldLabel('LinkChangeNote') : '';
if(!Config::inst()->get('URLSegmentFilter', 'default_allow_multibyte')) {
$helpText .= $helpText ? '<br />' : '';
$helpText .= _t('SiteTreeURLSegmentField.HelpChars', ' Special characters are automatically converted or removed.');
}

View File

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

View File

@ -7,15 +7,15 @@
*/
class VirtualPage extends Page {
static $description = 'Displays the content of another page';
private static $description = 'Displays the content of another page';
public static $virtualFields;
/**
* @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",
"OwnerID",
"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.
*/
public static $initially_copied_fields = array(
private static $initially_copied_fields = array(
'ShowInMenus',
'ShowInSearch',
'URLSegment',
);
static $has_one = array(
private static $has_one = array(
"CopyContentFrom" => "SiteTree",
);
static $db = array(
private static $db = array(
"VersionID" => "Int",
);
@ -50,7 +50,7 @@ class VirtualPage extends Page {
* Generates the array of fields required for the page type.
*/
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();
$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
// time. After this point, the user is free to customise these for the virtual page themselves.
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;
}
}
@ -405,7 +405,7 @@ class VirtualPage extends Page {
*/
class VirtualPage_Controller extends Page_Controller {
static $allowed_actions = array(
private static $allowed_actions = array(
'loadcontentall' => 'ADMIN',
);

View File

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

View File

@ -28,24 +28,29 @@ class FilesystemPublisher extends StaticPublisher {
protected $fileExtension = 'html';
/**
* @config
* @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)
* 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
* (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.
* 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) {
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";
if (self::$domain_based_caching) {
if (Config::inst()->get('FilesystemPublisher', 'domain_based_caching')) {
if (!$urlParts) continue; // seriously malformed url here...
$filename = $urlParts['host'] . '/' . $filename;
}
@ -167,15 +172,21 @@ class FilesystemPublisher extends StaticPublisher {
// Set the appropriate theme for this publication batch.
// This may have been set explicitly via StaticPublisher::static_publisher_theme,
// or we can use the last non-null theme.
if(!StaticPublisher::static_publisher_theme())
SSViewer::set_theme(SSViewer::current_custom_theme());
$customTheme = Config::inst()->get('StaticPublisher', 'static_publisher_theme');
if(!$customTheme)
Config::inst()->update('SSViewer', 'theme', Config::inst()->get('SSViewer', 'custom_theme'));
else
SSViewer::set_theme(StaticPublisher::static_publisher_theme());
Config::inst()->update('SSViewer', 'theme', $customTheme);
$currentBaseURL = Director::baseURL();
if(self::$static_base_url) Director::setBaseURL(self::$static_base_url);
if($this->fileExtension == 'php') SSViewer::setOption('rewriteHashlinks', 'php');
if(StaticPublisher::echo_progress()) echo $this->class.": Publishing to " . self::$static_base_url . "\n";
$staticBaseUrl = Config::inst()->get('FilesystemPublisher', 'static_base_url');
if($staticBaseUrl) Config::inst()->update('Director', 'alternate_base_url', $staticBaseUrl);
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();
$i = 0;
$totalURLs = sizeof($urls);
@ -183,7 +194,7 @@ class FilesystemPublisher extends StaticPublisher {
$origUrl = $url;
$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++;
if($url && !is_string($url)) {
@ -191,7 +202,7 @@ class FilesystemPublisher extends StaticPublisher {
continue;
}
if(StaticPublisher::echo_progress()) {
if(Config::inst()->get('StaticPublisher', 'echo_progress')) {
echo " * Publishing page $i/$totalURLs: $url\n";
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(
'</html>',
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($this->fileExtension == 'php') SSViewer::setOption('rewriteHashlinks', true);
if(Config::inst()->get('FilesystemPublisher', 'static_base_url')) Config::inst()->update('Director', 'alternate_base_url', $currentBaseURL);
if($this->fileExtension == 'php') {
Config::inst()->update('SSViewer', 'rewrite_hash_links', true);
}
$base = BASE_PATH . "/$this->destFolder";
foreach($files as $origUrl => $file) {

View File

@ -11,29 +11,39 @@
*/
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"
*/
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.
* 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.
*
*
* @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"
*/
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
* For example, you could exclude assets.
*
* @deprecated 3.2 Use the "RsyncMultiHostPublisher.excluded_folders" config setting instead
*/
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) {
@ -45,18 +55,18 @@ class RsyncMultiHostPublisher extends FilesystemPublisher {
if(isset($_GET['norsync']) && $_GET['norsync']) return;
$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);
}
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
$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
$rsyncOutput .= `cd $base; rsync -av -e ssh --exclude '*.svn' --exclude '*~' $extraArg --delete cache $target`;
// Transfer framework/static-main.php to the target
$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 {
/**
* 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
* (for example, in a cron task)
*/
static $echo_progress = false;
private static $echo_progress = false;
/**
* Realtime static publishing... the second a page
* is saved, it is written to the cache
* @config
* @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
* If it's not set, then the last non-null theme, set via SSViewer::set_theme() is used
* @config
* @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
*/
static $static_publisher_theme=false;
private static $static_publisher_theme=false;
abstract public function publishPages($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){
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,
* 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(){
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() {
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.
* @deprecated 3.2 Use the "StaticPublisher.echo_progress" config setting instead
* @see StaticPublisher::$echo_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) {
if (self::$disable_realtime) return;
if (Config::inst()->get('StaticPublisher', 'disable_realtime')) return;
$urls = array();
@ -109,7 +128,7 @@ abstract class StaticPublisher extends DataExtension {
* functionality
*/
public function onAfterUnpublish($page) {
if (self::$disable_realtime) return;
if (Config::inst()->get('StaticPublisher', 'disable_realtime')) return;
// Get the affected URLs
if($this->owner->hasMethod('pagesAffectedByUnpublishing')) {

View File

@ -16,7 +16,7 @@
#SilverStripeNavigator .bottomTabs a.current { font-weight: bold; text-decoration: none; }
#SilverStripeNavigatorMessage { font-family: 'Lucida Grande', Verdana, Arial, 'sans-serif'; position: absolute; right: 20px; top: 40px; padding: 10px; border-color: #c99; color: #fff; background-color: #c00; border: 1px solid #000; }
#SilverStripeNavigatorMessage { font-family: 'Lucida Grande', Verdana, Arial, 'sans-serif'; position: fixed; z-index: 1000; right: 20px; top: 40px; padding: 10px; border-color: #c99; color: #fff; background-color: #c00; border: 1px solid #000; }
#SilverStripeNavigatorLinkPopup { display: none; position: absolute; top: -60px; height: 50px; width: 350px; left: 200px; background-color: white; border: 1px solid black; z-index: 100; color: black; padding: 5px; }

View File

@ -12,12 +12,27 @@
'edit': {
'label': ss.i18n._t('Tree.EditPage'),
'action': function(obj) {
$('.cms-container').entwine('.ss').loadPanel(ss.i18n.sprintf(
$('.cms-container').entwine('.ss').loadPanel(ss.i18n.sprintf(
self.data('urlEditpage'), obj.data('id')
));
}
}
};
// Add "show as list"
if(!node.hasClass('nochildren')) {
menuitems['showaslist'] = {
'label': ss.i18n._t('Tree.ShowAsList'),
'action': function(obj) {
$('.cms-container').entwine('.ss').loadPanel(
self.data('urlListview') + '&ParentID=' + obj.data('id'),
null,
// Default to list view tab
{tabState: {'pages-controller-cms-content': {'tabSelector': '.content-listview'}}}
);
}
};
}
// Build a list for allowed children as submenu entries
var pagetype = node.data('pagetype'),

View File

@ -33,6 +33,7 @@ if(typeof(ss) == 'undefined' || typeof(ss.i18n) == 'undefined') {
'Tree.EditPage': 'Edit',
'Tree.ThisPageOnly': 'This page only',
'Tree.ThisPageAndSubpages': 'This page and subpages',
'Tree.ShowAsList': 'Show children as list',
'CMSMain.ConfirmRestoreFromLive': "Do you really want to copy the published content to the draft site?",
'CMSMain.RollbackToVersion': "Do you really want to roll back to version #%s of this page?",
'URLSEGMENT.Edit': 'Edit',

View File

@ -1,4 +1,3 @@
#SilverStripeNavigator {
position: fixed;
bottom: 0;
@ -51,7 +50,8 @@
#SilverStripeNavigatorMessage {
font-family: 'Lucida Grande', Verdana, Arial, 'sans-serif';
position: absolute;
position: fixed;
z-index: 1000;
right: 20px;
top: 40px;
padding: 10px;

View File

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

View File

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

View File

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

View File

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

View File

@ -7,4 +7,8 @@
<div class="cms-panel-content-collapsed">
<h3 class="cms-panel-header">$SiteConfig.Title</h3>
</div>
</div>
<div class="cms-panel-toggle south">
<a class="toggle-expand" href="#"><span>&raquo;</span></a>
<a class="toggle-collapse" href="#"><span>&laquo;</span></a>
</div>
</div>

View File

@ -19,7 +19,7 @@ $ExtraTreeTools
</div>
<% end_if %>
<div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-url-updatetreenodes="$Link(updatetreenodes)" data-url-addpage="{$LinkPageAdd('AddForm/?action_doAdd=1')}&amp;ParentID=%s&amp;PageType=%s&amp;SecurityID=$SecurityID" data-url-editpage="$LinkPageEdit('%s')" data-url-duplicate="{$Link('duplicate/%s')}?SecurityID=$SecurityID" data-url-duplicatewithchildren="{$Link('duplicatewithchildren/%s')}?SecurityID=$SecurityID" data-hints="$SiteTreeHints.XML">
<div class="cms-tree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" data-url-updatetreenodes="$Link(updatetreenodes)" data-url-addpage="{$LinkPageAdd('AddForm/?action_doAdd=1')}&amp;ParentID=%s&amp;PageType=%s&amp;SecurityID=$SecurityID" data-url-editpage="$LinkPageEdit('%s')" data-url-duplicate="{$Link('duplicate/%s')}?SecurityID=$SecurityID" data-url-duplicatewithchildren="{$Link('duplicatewithchildren/%s')}?SecurityID=$SecurityID" data-url-listview="{$Link('?view=list')}" data-hints="$SiteTreeHints.XML">
$SiteTreeAsUL
</div>
</div>

View File

@ -7,10 +7,10 @@
<div class="cms-content-header-tabs">
<ul class="cms-tabset-nav-primary">
<li class="content-treeview<% if ViewState == tree %> ui-tabs-active<% end_if %> cms-tabset-icon tree">
<li class="content-treeview<% if ViewState == tree %> ui-tabs-active ss-tabs-force-active<% end_if %> cms-tabset-icon tree">
<a href="#cms-content-treeview" class="cms-panel-link" data-href="$LinkTreeView"><% _t('CMSPagesController.TreeView', 'Tree View') %></a>
</li>
<li class="content-listview<% if ViewState == list %> ui-tabs-active<% end_if %> cms-tabset-icon list">
<li class="content-listview<% if ViewState == list %> ui-tabs-active ss-tabs-force-active<% end_if %> cms-tabset-icon list">
<a href="#cms-content-listview" class="cms-panel-link" data-href="$LinkListView"><% _t('CMSPagesController.ListView', 'List View') %></a>
</li>
<!--

View File

@ -5,27 +5,10 @@
*/
class CMSMainTest extends FunctionalTest {
static $fixture_file = 'CMSMainTest.yml';
protected static $fixture_file = 'CMSMainTest.yml';
static protected $orig = array();
public function setUpOnce() {
self::$orig['CMSBatchActionHandler_batch_actions'] = CMSBatchActionHandler::$batch_actions;
CMSBatchActionHandler::$batch_actions = array(
'publish' => 'CMSBatchAction_Publish',
'delete' => 'CMSBatchAction_Delete',
'deletefromlive' => 'CMSBatchAction_DeleteFromLive',
);
parent::setUpOnce();
}
public function tearDownOnce() {
CMSBatchActionHandler::$batch_actions = self::$orig['CMSBatchActionHandler_batch_actions'];
parent::tearDownOnce();
}
function testSiteTreeHints() {
$cache = SS_Cache::factory('CMSMain_SiteTreeHints');
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);
@ -95,9 +78,12 @@ class CMSMainTest extends FunctionalTest {
'Done: Published 30 pages',
$response->getBody()
);
$actions = CMSBatchActionHandler::config()->batch_actions;
// Some modules (e.g., cmsworkflow) will remove this action
if(isset(CMSBatchActionHandler::$batch_actions['publish'])) {
$actions = CMSBatchActionHandler::config()->batch_actions;
if(isset($actions['publish'])) {
$response = $this->get('admin/pages/batchactions/publish?ajax=1&csvIDs=' . implode(',', array($page1->ID, $page2->ID)));
$responseData = Convert::json2array($response->getBody());
$this->assertArrayHasKey($page1->ID, $responseData['modified']);
@ -175,7 +161,7 @@ class CMSMainTest extends FunctionalTest {
public function testCanPublishPageWithUnpublishedParentWithStrictHierarchyOff() {
$this->logInWithPermission('ADMIN');
SiteTree::set_enforce_strict_hierarchy(true);
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true);
$parentPage = $this->objFromFixture('Page','page3');
$childPage = $this->objFromFixture('Page','page1');
@ -188,7 +174,7 @@ class CMSMainTest extends FunctionalTest {
$actions,
'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);
}
/**
@ -345,7 +331,7 @@ class CMSMainTest extends FunctionalTest {
}
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 {
@ -353,7 +339,7 @@ class CMSMainTest_ClassB 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 {

View File

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

View File

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

View File

@ -5,9 +5,9 @@
*/
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
@ -15,7 +15,7 @@ class ContentControllerTest extends FunctionalTest {
public function testNestedPages() {
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('/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());
RootURLController::reset();
SiteTree::disable_nested_urls();
SiteTree::config()->nested_urls = false;
$this->assertEquals('Home Page', $this->get('/')->getBody());
$this->assertEquals('Home Page', $this->get('/home/')->getBody());
@ -51,14 +51,14 @@ class ContentControllerTest extends FunctionalTest {
public function testChildrenOf() {
$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('/home/')->Count());
$this->assertEquals(2, $controller->ChildrenOf('/home/second-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('/home/')->Count());
@ -67,7 +67,7 @@ class ContentControllerTest extends FunctionalTest {
}
public function testDeepNestedURLs() {
SiteTree::enable_nested_urls();
Config::inst()->update('SiteTree', 'nested_urls', true);
$page = new 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(){
@ -129,7 +129,7 @@ class ContentControllerTest_Page extends Page { }
class ContentControllerTest_Page_Controller extends Page_Controller {
public static $allowed_actions = array (
private static $allowed_actions = array (
'second_index'
);

View File

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

View File

@ -4,14 +4,14 @@
* @subpackage tests
*/
class RootURLControllerTest extends SapphireTest {
static $fixture_file = 'RootURLControllerTest.yml';
protected static $fixture_file = 'RootURLControllerTest.yml';
public function testGetHomepageLink() {
$default = $this->objFromFixture('Page', 'home');
SiteTree::disable_nested_urls();
SiteTree::config()->nested_urls = false;
$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());
}

View File

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

View File

@ -5,7 +5,7 @@
*/
class ErrorPageTest extends FunctionalTest {
static $fixture_file = 'ErrorPageTest.yml';
protected static $fixture_file = 'ErrorPageTest.yml';
protected $orig = array();
@ -14,20 +14,18 @@ class ErrorPageTest extends FunctionalTest {
public function 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());
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();
Director::set_environment_type('live');
Config::inst()->update('Director', 'environment_type', 'live');
}
public function tearDown() {
parent::tearDown();
ErrorPage::set_static_filepath($this->orig['ErrorPage_staticfilepath']);
Director::set_environment_type($this->orig['Director_environmenttype']);
ErrorPage::config()->static_filepath = $this->orig['ErrorPage_staticfilepath'];
Filesystem::removeFolder($this->tmpAssetsPath . '/ErrorPageTest');
Filesystem::removeFolder($this->tmpAssetsPath);

View File

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

View File

@ -1,8 +1,8 @@
<?php
class RedirectorPageTest extends FunctionalTest {
static $fixture_file = 'RedirectorPageTest.yml';
static $use_draft_site = true;
protected static $fixture_file = 'RedirectorPageTest.yml';
protected static $use_draft_site = true;
public function testGoodRedirectors() {
/* 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('darkshades', $themes, 'Test themes contain darkshades theme');
SiteConfig::disable_theme('darkshades');
SiteConfig::config()->disabled_themes = array('darkshades');
$themes = $config->getAvailableThemes($testThemeBaseDir);
$this->assertFalse(in_array('darkshades', $themes), 'Darkshades was disabled - it is no longer available');

View File

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

View File

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

View File

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

View File

@ -1,8 +1,8 @@
<?php
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() {
$sitetree = $this->objFromFixture('SiteTree', 'home');

View File

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

View File

@ -4,7 +4,7 @@
* @subpackage tests
*/
class SiteTreeTest extends SapphireTest {
static $fixture_file = 'SiteTreeTest.yml';
protected static $fixture_file = 'SiteTreeTest.yml';
protected $illegalExtensions = array(
'SiteTree' => array('SiteTreeSubsites')
@ -27,14 +27,14 @@ class SiteTreeTest extends SapphireTest {
$this->assertEquals(DB::query('SELECT COUNT("ID") FROM "SiteTree"')->value(), 0);
// Disable the creation
SiteTree::set_create_default_pages(false);
SiteTree::config()->create_default_pages = false;
singleton('SiteTree')->requireDefaultRecords();
// The table should still be empty
$this->assertEquals(DB::query('SELECT COUNT("ID") FROM "SiteTree"')->value(), 0);
// Enable the creation
SiteTree::set_create_default_pages(true);
SiteTree::config()->create_default_pages = true;
singleton('SiteTree')->requireDefaultRecords();
// 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');
$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('/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($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('/home/', false)->ID);
@ -300,7 +300,7 @@ class SiteTreeTest extends SapphireTest {
$about = $this->objFromFixture('Page', 'about');
$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/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');
$child = $this->objFromFixture('Page', 'staff');
SiteTree::enable_nested_urls();
Config::inst()->update('SiteTree', 'nested_urls', true);
$child->publish('Stage', 'Live');
$parent->URLSegment = 'changed-on-live';
@ -326,7 +326,7 @@ class SiteTreeTest extends SapphireTest {
}
public function testDeleteFromStageOperatesRecursively() {
SiteTree::set_enforce_strict_hierarchy(false);
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false);
$pageAbout = $this->objFromFixture('Page', 'about');
$pageStaff = $this->objFromFixture('Page', 'staff');
$pageStaffDuplicate = $this->objFromFixture('Page', 'staffduplicate');
@ -336,7 +336,7 @@ class SiteTreeTest extends SapphireTest {
$this->assertFalse(DataObject::get_by_id('Page', $pageAbout->ID));
$this->assertTrue(DataObject::get_by_id('Page', $pageStaff->ID) instanceof Page);
$this->assertTrue(DataObject::get_by_id('Page', $pageStaffDuplicate->ID) instanceof Page);
SiteTree::set_enforce_strict_hierarchy(true);
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true);
}
public function testDeleteFromStageOperatesRecursivelyStrict() {
@ -352,7 +352,7 @@ class SiteTreeTest extends SapphireTest {
}
public function testDeleteFromLiveOperatesRecursively() {
SiteTree::set_enforce_strict_hierarchy(false);
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false);
$this->logInWithPermission('ADMIN');
$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', $pageStaffDuplicate->ID) instanceof Page);
Versioned::reading_stage('Stage');
SiteTree::set_enforce_strict_hierarchy(true);
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true);
}
public function testUnpublishDoesNotDeleteChildrenWithLooseHierachyOn() {
SiteTree::set_enforce_strict_hierarchy(false);
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', false);
$this->logInWithPermission('ADMIN');
$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', $pageStaffDuplicate->ID) instanceof Page);
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() {
$sitetree = new SiteTree();
SiteTree::disable_nested_urls();
SiteTree::config()->nested_urls = false;
$sitetree->URLSegment = 'home';
$this->assertFalse($sitetree->validURLSegment(), 'URLSegment conflicts are recognised');
@ -645,7 +645,7 @@ class SiteTreeTest extends SapphireTest {
$sitetree->URLSegment = 'home';
$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->URLSegment = 'home';
@ -674,7 +674,7 @@ class SiteTreeTest extends SapphireTest {
* @covers SiteTree::validURLSegment
*/
public function testValidURLSegmentControllerConflicts() {
SiteTree::enable_nested_urls();
Config::inst()->update('SiteTree', 'nested_urls', true);
$sitetree = new SiteTree();
$sitetree->ParentID = $this->idFromFixture('SiteTreeTest_Conflicted', 'parent');
@ -693,8 +693,8 @@ class SiteTreeTest extends SapphireTest {
}
public function testURLSegmentMultiByte() {
$origAllow = URLSegmentFilter::$default_allow_multibyte;
URLSegmentFilter::$default_allow_multibyte = true;
$origAllow = Config::inst()->get('URLSegmentFilter', 'default_allow_multibyte');
Config::inst()->update('URLSegmentFilter', 'default_allow_multibyte', true);
$sitetree = new SiteTree();
$sitetree->write();
@ -709,7 +709,7 @@ class SiteTreeTest extends SapphireTest {
$sitetreeLive = Versioned::get_one_by_stage('SiteTree', 'Live', '"SiteTree"."ID" = ' .$sitetree->ID, false);
$this->assertEquals($sitetreeLive->URLSegment, rawurlencode('brötchen'));
URLSegmentFilter::$default_allow_multibyte = $origAllow;
Config::inst()->update('URLSegmentFilter', 'default_allow_multibyte', $origAllow);
}
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_Controller extends Page_Controller implements TestOnly {
public static $allowed_actions = array (
private static $allowed_actions = array (
'conflicted-action'
);
@ -917,32 +917,32 @@ class SiteTreeTest_NullHtmlCleaner extends HTMLCleaner {
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 {
// Also allowed subclasses
static $allowed_children = array('SiteTreeTest_ClassC');
private static $allowed_children = array('SiteTreeTest_ClassC');
}
class SiteTreeTest_ClassC extends Page implements TestOnly {
static $allowed_children = array();
private static $allowed_children = array();
}
class SiteTreeTest_ClassD extends Page implements TestOnly {
// 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 {
// Override SiteTreeTest_ClassC definitions
static $allowed_children = array('SiteTreeTest_ClassB');
private static $allowed_children = array('SiteTreeTest_ClassB');
}
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 {

View File

@ -1,7 +1,7 @@
<?php
class VirtualPageTest extends SapphireTest {
static $fixture_file = 'VirtualPageTest.yml';
protected static $fixture_file = 'VirtualPageTest.yml';
protected $extraDataObjects = array(
'VirtualPageTest_ClassA',
@ -16,18 +16,18 @@ class VirtualPageTest extends SapphireTest {
public function setUp() {
parent::setUp();
$this->origInitiallyCopiedFields = VirtualPage::$initially_copied_fields;
VirtualPage::$initially_copied_fields[] = 'MyInitiallyCopiedField';
$this->origNonVirtualField = VirtualPage::$non_virtual_fields;
VirtualPage::$non_virtual_fields[] = 'MyNonVirtualField';
VirtualPage::$non_virtual_fields[] = 'MySharedNonVirtualField';
$this->origInitiallyCopiedFields = VirtualPage::config()->initially_copied_fields;
VirtualPage::config()->initially_copied_fields = array('MyInitiallyCopiedField');
$this->origNonVirtualField = VirtualPage::config()->non_virtual_fields;
$nonVirtual = VirtualPage::config()->non_virtual_fields;
VirtualPage::config()->non_virtual_fields = array('MyNonVirtualField', 'MySharedNonVirtualField');
}
public function tearDown() {
parent::tearDown();
VirtualPage::$initially_copied_fields = $this->origInitiallyCopiedFields;
VirtualPage::$non_virtual_fields = $this->origNonVirtualField;
VirtualPage::config()->initially_copied_fields = $this->origInitiallyCopiedFields;
VirtualPage::config()->non_virtual_fields = $this->origNonVirtualField;
}
/**
@ -579,36 +579,36 @@ class VirtualPageTest extends SapphireTest {
class VirtualPageTest_ClassA extends Page implements TestOnly {
static $db = array(
private static $db = array(
'MyInitiallyCopiedField' => 'Text',
'MyVirtualField' => 'Text',
'MyNonVirtualField' => 'Text',
);
static $allowed_children = array('VirtualPageTest_ClassB');
private static $allowed_children = array('VirtualPageTest_ClassB');
}
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 {
static $allowed_children = array();
private static $allowed_children = array();
}
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 {
static $db = array(
private static $db = array(
'MyProperty' => 'Varchar',
);
}
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.
// Not possible through direct $db definitions due to VirtualPage inheriting from Page, and Page being defined elsewhere.
'MySharedVirtualField' => 'Text',

View File

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

View File

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

View File

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

View File

@ -11,15 +11,14 @@ class FilesystemPublisherTest extends SapphireTest {
protected $orig = array();
static $fixture_file = 'cms/tests/staticpublisher/FilesystemPublisherTest.yml';
protected static $fixture_file = 'cms/tests/staticpublisher/FilesystemPublisherTest.yml';
public function setUp() {
parent::setUp();
SiteTree::add_extension("FilesystemPublisher('assets/FilesystemPublisherTest-static-folder/')");
$this->orig['domain_based_caching'] = FilesystemPublisher::$domain_based_caching;
FilesystemPublisher::$domain_based_caching = false;
Config::inst()->update('FilesystemPublisher', 'domain_based_caching', false);
}
public function tearDown() {
@ -27,8 +26,6 @@ class FilesystemPublisherTest extends SapphireTest {
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')) {
Filesystem::removeFolder(BASE_PATH . '/assets/FilesystemPublisherTest-static-folder');
}
@ -82,8 +79,7 @@ class FilesystemPublisherTest extends SapphireTest {
}
public function testUrlsToPathsWithDomainBasedCaching() {
$origDomainBasedCaching = FilesystemPublisher::$domain_based_caching;
FilesystemPublisher::$domain_based_caching = true;
Config::inst()->update('FilesystemPublisher', 'domain_based_caching', true);
$fsp = new FilesystemPublisher('.', 'html');
@ -107,8 +103,6 @@ class FilesystemPublisherTest extends SapphireTest {
array($url => 'domain2.com/parent/child.html'),
'Nested URLsegment path mapping'
);
FilesystemPublisher::$domain_based_caching = $origDomainBasedCaching;
}
/**
@ -134,7 +128,7 @@ class FilesystemPublisherTest extends SapphireTest {
public function testStaticPublisherTheme(){
//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->URLSegment = strtolower(__CLASS__).'-page-1';
@ -142,21 +136,13 @@ class FilesystemPublisherTest extends SapphireTest {
$p1->write();
$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');
//The CMS sometimes sets the theme to null. Check that the $current_custom_theme is still the default
SSViewer::set_theme(null);
$current_theme=SSViewer::current_custom_theme();
Config::inst()->update('SSViewer', 'theme', null);
$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');
//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() {

View File

@ -5,9 +5,9 @@
*/
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() {
ob_start();

View File

@ -32,9 +32,9 @@
*/
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() {
parent::setUp();