mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge branch '4.0' into 4.1
This commit is contained in:
commit
a4b78c4041
@ -301,7 +301,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
||||
* @config
|
||||
* @var string
|
||||
*/
|
||||
private static $meta_generator = 'SilverStripe - http://silverstripe.org';
|
||||
private static $meta_generator = 'SilverStripe - https://www.silverstripe.org';
|
||||
|
||||
protected $_cache_statusFlags = null;
|
||||
|
||||
|
@ -26,17 +26,18 @@ class ContentControllerSearchExtension extends Extension
|
||||
*/
|
||||
public function SearchForm()
|
||||
{
|
||||
$searchText = _t('SilverStripe\\CMS\\Search\\SearchForm.SEARCH', 'Search');
|
||||
|
||||
$searchText = '';
|
||||
if ($this->owner->getRequest() && $this->owner->getRequest()->getVar('Search')) {
|
||||
$searchText = $this->owner->getRequest()->getVar('Search');
|
||||
}
|
||||
|
||||
$fields = new FieldList(
|
||||
new TextField('Search', false, $searchText)
|
||||
$placeholder = _t('SilverStripe\\CMS\\Search\\SearchForm.SEARCH', 'Search');
|
||||
$fields = FieldList::create(
|
||||
TextField::create('Search', false, $searchText)
|
||||
->setAttribute('placeholder', $placeholder)
|
||||
);
|
||||
$actions = new FieldList(
|
||||
new FormAction('results', _t('SilverStripe\\CMS\\Search\\SearchForm.GO', 'Go'))
|
||||
$actions = FieldList::create(
|
||||
FormAction::create('results', _t('SilverStripe\\CMS\\Search\\SearchForm.GO', 'Go'))
|
||||
);
|
||||
/** @skipUpgrade */
|
||||
$form = SearchForm::create($this->owner, 'SearchForm', $fields, $actions);
|
||||
|
@ -1277,35 +1277,36 @@ class SiteTreeTest extends SapphireTest
|
||||
{
|
||||
$generator = Config::inst()->get(SiteTree::class, 'meta_generator');
|
||||
|
||||
// Stub to ensure customisations don't affect the test
|
||||
Config::modify()->set(SiteTree::class, 'meta_generator', 'SilverStripe - https://www.silverstripe.org');
|
||||
|
||||
$page = new SiteTreeTest_PageNode();
|
||||
|
||||
$meta = $page->MetaTags();
|
||||
$this->assertEquals(
|
||||
1,
|
||||
preg_match('/.*meta name="generator" content="SilverStripe - http:\/\/silverstripe.org".*/', $meta),
|
||||
'test default functionality - uses value from Config'
|
||||
$this->assertContains('meta name="generator"', $meta, 'Should include generator tag');
|
||||
$this->assertContains(
|
||||
'content="SilverStripe - https://www.silverstripe.org',
|
||||
$meta,
|
||||
'Should contain default meta generator info'
|
||||
);
|
||||
|
||||
// test proper escaping of quotes in attribute value
|
||||
Config::modify()->set(SiteTree::class, 'meta_generator', 'Generator with "quotes" in it');
|
||||
$meta = $page->MetaTags();
|
||||
$this->assertEquals(
|
||||
1,
|
||||
preg_match('/.*meta name="generator" content="Generator with "quotes" in it".*/', $meta),
|
||||
$this->assertContains(
|
||||
'content="Generator with "quotes" in it',
|
||||
$meta,
|
||||
'test proper escaping of values from Config'
|
||||
);
|
||||
|
||||
// test empty generator - no tag should appear at all
|
||||
Config::modify()->set(SiteTree::class, 'meta_generator', '');
|
||||
$meta = $page->MetaTags();
|
||||
$this->assertEquals(
|
||||
0,
|
||||
preg_match('/.*meta name=.generator..*/', $meta),
|
||||
$this->assertNotContains(
|
||||
'meta name="generator"',
|
||||
$meta,
|
||||
'test blank value means no tag generated'
|
||||
);
|
||||
|
||||
// reset original value
|
||||
Config::modify()->set(SiteTree::class, 'meta_generator', $generator);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user