mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
Merge remote-tracking branch 'origin/3'
This commit is contained in:
commit
dd49a888e8
@ -37,7 +37,7 @@ matrix:
|
|||||||
- sudo apt-get install -y tidy
|
- sudo apt-get install -y tidy
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- composer self-update
|
- composer self-update || true
|
||||||
- phpenv rehash
|
- phpenv rehash
|
||||||
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
|
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support
|
||||||
- "if [ \"$BEHAT_TEST\" = \"\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss; fi"
|
- "if [ \"$BEHAT_TEST\" = \"\" ]; then php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss; fi"
|
||||||
|
@ -290,7 +290,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function TreeIsFiltered() {
|
public function TreeIsFiltered() {
|
||||||
return $this->getRequest()->getVar('q');
|
$query = $this->getRequest()->getVar('q');
|
||||||
|
|
||||||
|
if (!$query || (count($query) === 1 && isset($query['FilterClass']) && $query['FilterClass'] === 'CMSSiteTreeFilter_Search')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ExtraTreeTools() {
|
public function ExtraTreeTools() {
|
||||||
@ -351,8 +357,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
|
|||||||
// Create the Search and Reset action
|
// Create the Search and Reset action
|
||||||
$actions = new FieldList(
|
$actions = new FieldList(
|
||||||
FormAction::create('doSearch', _t('CMSMain_left_ss.APPLY_FILTER', 'Apply Filter'))
|
FormAction::create('doSearch', _t('CMSMain_left_ss.APPLY_FILTER', 'Apply Filter'))
|
||||||
->addExtraClass('ss-ui-action-constructive'),
|
->addExtraClass('ss-ui-action-constructive'),
|
||||||
Object::create('ResetFormAction', 'clear', _t('CMSMain_left_ss.RESET', 'Reset'))
|
Object::create('ResetFormAction', 'clear', _t('CMSMain_left_ss.CLEAR_FILTER', 'Clear Filter'))
|
||||||
);
|
);
|
||||||
|
|
||||||
// Use <button> to allow full jQuery UI styling on the all of the Actions
|
// Use <button> to allow full jQuery UI styling on the all of the Actions
|
||||||
|
@ -15,7 +15,7 @@ class SiteTreeURLSegmentField extends TextField {
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $helpText, $urlPrefix, $urlSuffix;
|
protected $helpText, $urlPrefix, $urlSuffix, $defaultUrl;
|
||||||
|
|
||||||
private static $allowed_actions = array(
|
private static $allowed_actions = array(
|
||||||
'suggest'
|
'suggest'
|
||||||
@ -30,7 +30,8 @@ class SiteTreeURLSegmentField extends TextField {
|
|||||||
parent::getAttributes(),
|
parent::getAttributes(),
|
||||||
array(
|
array(
|
||||||
'data-prefix' => $this->getURLPrefix(),
|
'data-prefix' => $this->getURLPrefix(),
|
||||||
'data-suffix' => '?stage=Stage'
|
'data-suffix' => '?stage=Stage',
|
||||||
|
'data-default-url' => $this->getDefaultURL()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -74,7 +75,8 @@ class SiteTreeURLSegmentField extends TextField {
|
|||||||
* @param string $string The secondary text to show
|
* @param string $string The secondary text to show
|
||||||
*/
|
*/
|
||||||
public function setHelpText($string){
|
public function setHelpText($string){
|
||||||
$this->helpText = $string;
|
$this->helpText = $string;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,6 +92,7 @@ class SiteTreeURLSegmentField extends TextField {
|
|||||||
*/
|
*/
|
||||||
public function setURLPrefix($url){
|
public function setURLPrefix($url){
|
||||||
$this->urlPrefix = $url;
|
$this->urlPrefix = $url;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,8 +106,23 @@ class SiteTreeURLSegmentField extends TextField {
|
|||||||
return $this->urlSuffix;
|
return $this->urlSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Indicator for UI to respond to changes accurately,
|
||||||
|
* and auto-update the field value if changes to the default occur.
|
||||||
|
* Does not set the field default value.
|
||||||
|
*/
|
||||||
|
public function getDefaultURL(){
|
||||||
|
return $this->defaultUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDefaultURL($url) {
|
||||||
|
$this->defaultUrl = $url;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function setURLSuffix($suffix) {
|
public function setURLSuffix($suffix) {
|
||||||
$this->urlSuffix = $suffix;
|
$this->urlSuffix = $suffix;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function Type() {
|
public function Type() {
|
||||||
|
@ -1536,7 +1536,11 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If there is no URLSegment set, generate one from Title
|
// If there is no URLSegment set, generate one from Title
|
||||||
if((!$this->URLSegment || $this->URLSegment == 'new-page') && $this->Title) {
|
$defaultSegment = $this->generateURLSegment(_t(
|
||||||
|
'CMSMain.NEWPAGE',
|
||||||
|
array('pagetype' => $this->i18n_singular_name())
|
||||||
|
));
|
||||||
|
if((!$this->URLSegment || $this->URLSegment == $defaultSegment) && $this->Title) {
|
||||||
$this->URLSegment = $this->generateURLSegment($this->Title);
|
$this->URLSegment = $this->generateURLSegment($this->Title);
|
||||||
} else if($this->isChanged('URLSegment', 2)) {
|
} else if($this->isChanged('URLSegment', 2)) {
|
||||||
// Do a strict check on change level, to avoid double encoding caused by
|
// Do a strict check on change level, to avoid double encoding caused by
|
||||||
@ -1624,7 +1628,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$this->_cache_statusFlags = null;
|
$this->_cache_statusFlags = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate() {
|
protected function validate() {
|
||||||
$result = parent::validate();
|
$result = parent::validate();
|
||||||
|
|
||||||
// Allowed children validation
|
// Allowed children validation
|
||||||
@ -1974,8 +1978,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
(self::config()->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 = SiteTreeURLSegmentField::create("URLSegment", $this->fieldLabel('URLSegment'))
|
||||||
$urlsegment->setURLPrefix($baseLink);
|
->setURLPrefix($baseLink)
|
||||||
|
->setDefaultURL($this->generateURLSegment(_t(
|
||||||
|
'CMSMain.NEWPAGE',
|
||||||
|
array('pagetype' => $this->i18n_singular_name())
|
||||||
|
)));
|
||||||
$helpText = (self::config()->nested_urls && count($this->Children())) ? $this->fieldLabel('LinkChangeNote') : '';
|
$helpText = (self::config()->nested_urls && count($this->Children())) ? $this->fieldLabel('LinkChangeNote') : '';
|
||||||
if(!Config::inst()->get('URLSegmentFilter', 'default_allow_multibyte')) {
|
if(!Config::inst()->get('URLSegmentFilter', 'default_allow_multibyte')) {
|
||||||
$helpText .= $helpText ? '<br />' : '';
|
$helpText .= $helpText ? '<br />' : '';
|
||||||
|
@ -344,7 +344,7 @@ class VirtualPage extends Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validate() {
|
protected function validate() {
|
||||||
$result = parent::validate();
|
$result = parent::validate();
|
||||||
|
|
||||||
// "Can be root" validation
|
// "Can be root" validation
|
||||||
@ -517,6 +517,7 @@ class VirtualPage_Controller extends Page_Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent::init();
|
parent::init();
|
||||||
|
$this->__call('init', array());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadcontentall() {
|
public function loadcontentall() {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
.cms-content-tools #cms-content-treeview .cms-tree-view-modes, .cms-content-tools #cms-content-treeview .cms-content-batchactions { display: none; }
|
.cms-content-tools #cms-content-treeview .cms-tree-view-modes, .cms-content-tools #cms-content-treeview .cms-content-batchactions { display: none; }
|
||||||
.cms-content-tools #cms-content-treeview .cms-tree-expand-trigger { display: block; float: left; margin: 0 0 2px 0; }
|
.cms-content-tools #cms-content-treeview .cms-tree-expand-trigger { display: block; float: left; margin: 0 0 2px 0; }
|
||||||
.cms-content-tools #cms-content-treeview .cms-tree-expand-trigger span.ui-button-text { padding-right: 8px; }
|
.cms-content-tools #cms-content-treeview .cms-tree-expand-trigger span.ui-button-text { padding-right: 8px; }
|
||||||
.cms-content-tools #cms-content-treeview .cms-tree .badge, .cms-content-tools #cms-content-treeview .cms-tree a > .jstree-icon { display: none; }
|
.cms-content-tools #cms-content-treeview .cms-tree .badge { display: none; }
|
||||||
.cms-content-tools #cms-content-treeview .cms-tree a:hover > .text > .badge, .cms-content-tools #cms-content-treeview .cms-tree .jstree-clicked > .text > .badge { display: inline-block; }
|
.cms-content-tools #cms-content-treeview .cms-tree a:hover > .text > .badge, .cms-content-tools #cms-content-treeview .cms-tree .jstree-clicked > .text > .badge { display: inline-block; }
|
||||||
|
|
||||||
/** ------------------------------------------------------------------ URLSegment field ----------------------------------------------------------------- */
|
/** ------------------------------------------------------------------ URLSegment field ----------------------------------------------------------------- */
|
||||||
|
@ -39,7 +39,10 @@
|
|||||||
self.data('OrigVal', title);
|
self.data('OrigVal', title);
|
||||||
|
|
||||||
// Criteria for defining a "new" page
|
// Criteria for defining a "new" page
|
||||||
if ((urlSegmentInput.val().indexOf('new') == 0) && liveLinkInput.val() == '') {
|
if (
|
||||||
|
urlSegmentInput.val().indexOf(urlSegmentInput.data('defaultUrl')) === 0
|
||||||
|
&& liveLinkInput.val() == ''
|
||||||
|
) {
|
||||||
self.updateURLSegment(title);
|
self.updateURLSegment(title);
|
||||||
} else {
|
} else {
|
||||||
$('.update', self.parent()).show();
|
$('.update', self.parent()).show();
|
||||||
|
@ -76,8 +76,7 @@
|
|||||||
|
|
||||||
.cms-tree {
|
.cms-tree {
|
||||||
// Hide badges and drag icons to save space
|
// Hide badges and drag icons to save space
|
||||||
.badge,
|
.badge {
|
||||||
a > .jstree-icon {
|
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,8 +406,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
Versioned::reading_stage('Stage');
|
Versioned::reading_stage('Stage');
|
||||||
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true);
|
Config::inst()->update('SiteTree', 'enforce_strict_hierarchy', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testDeleteFromLiveOperatesRecursivelyStrict() {
|
public function testDeleteFromLiveOperatesRecursivelyStrict() {
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
|
|
||||||
@ -545,7 +544,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
// Confirm that Member.editor can still edit the page
|
// Confirm that Member.editor can still edit the page
|
||||||
$this->objFromFixture('Member','editor')->logIn();
|
$this->objFromFixture('Member','editor')->logIn();
|
||||||
$this->assertTrue($page->canEdit());
|
$this->assertTrue($page->canEdit());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCompareVersions() {
|
public function testCompareVersions() {
|
||||||
// Necessary to avoid
|
// Necessary to avoid
|
||||||
@ -693,6 +692,59 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
$this->assertTrue($ceo->isSection());
|
$this->assertTrue($ceo->isSection());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testURLSegmentAutoUpdate() {
|
||||||
|
$sitetree = new SiteTree();
|
||||||
|
$sitetree->Title = _t(
|
||||||
|
'CMSMain.NEWPAGE',
|
||||||
|
array('pagetype' => $sitetree->i18n_singular_name())
|
||||||
|
);
|
||||||
|
$sitetree->write();
|
||||||
|
$this->assertEquals($sitetree->URLSegment, 'new-page',
|
||||||
|
'Sets based on default title on first save'
|
||||||
|
);
|
||||||
|
|
||||||
|
$sitetree->Title = 'Changed';
|
||||||
|
$sitetree->write();
|
||||||
|
$this->assertEquals($sitetree->URLSegment, 'changed',
|
||||||
|
'Auto-updates when set to default title'
|
||||||
|
);
|
||||||
|
|
||||||
|
$sitetree->Title = 'Changed again';
|
||||||
|
$sitetree->write();
|
||||||
|
$this->assertEquals($sitetree->URLSegment, 'changed',
|
||||||
|
'Does not auto-update once title has been changed'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testURLSegmentAutoUpdateLocalized() {
|
||||||
|
$oldLocale = i18n::get_locale();
|
||||||
|
i18n::set_locale('de_DE');
|
||||||
|
|
||||||
|
$sitetree = new SiteTree();
|
||||||
|
$sitetree->Title = _t(
|
||||||
|
'CMSMain.NEWPAGE',
|
||||||
|
array('pagetype' => $sitetree->i18n_singular_name())
|
||||||
|
);
|
||||||
|
$sitetree->write();
|
||||||
|
$this->assertEquals($sitetree->URLSegment, 'neue-seite',
|
||||||
|
'Sets based on default title on first save'
|
||||||
|
);
|
||||||
|
|
||||||
|
$sitetree->Title = 'Changed';
|
||||||
|
$sitetree->write();
|
||||||
|
$this->assertEquals($sitetree->URLSegment, 'changed',
|
||||||
|
'Auto-updates when set to default title'
|
||||||
|
);
|
||||||
|
|
||||||
|
$sitetree->Title = 'Changed again';
|
||||||
|
$sitetree->write();
|
||||||
|
$this->assertEquals($sitetree->URLSegment, 'changed',
|
||||||
|
'Does not auto-update once title has been changed'
|
||||||
|
);
|
||||||
|
|
||||||
|
i18n::set_locale($oldLocale);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers SiteTree::validURLSegment
|
* @covers SiteTree::validURLSegment
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user