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
|
* @config
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private static $meta_generator = 'SilverStripe - http://silverstripe.org';
|
private static $meta_generator = 'SilverStripe - https://www.silverstripe.org';
|
||||||
|
|
||||||
protected $_cache_statusFlags = null;
|
protected $_cache_statusFlags = null;
|
||||||
|
|
||||||
|
@ -26,17 +26,18 @@ class ContentControllerSearchExtension extends Extension
|
|||||||
*/
|
*/
|
||||||
public function SearchForm()
|
public function SearchForm()
|
||||||
{
|
{
|
||||||
$searchText = _t('SilverStripe\\CMS\\Search\\SearchForm.SEARCH', 'Search');
|
$searchText = '';
|
||||||
|
|
||||||
if ($this->owner->getRequest() && $this->owner->getRequest()->getVar('Search')) {
|
if ($this->owner->getRequest() && $this->owner->getRequest()->getVar('Search')) {
|
||||||
$searchText = $this->owner->getRequest()->getVar('Search');
|
$searchText = $this->owner->getRequest()->getVar('Search');
|
||||||
}
|
}
|
||||||
|
|
||||||
$fields = new FieldList(
|
$placeholder = _t('SilverStripe\\CMS\\Search\\SearchForm.SEARCH', 'Search');
|
||||||
new TextField('Search', false, $searchText)
|
$fields = FieldList::create(
|
||||||
|
TextField::create('Search', false, $searchText)
|
||||||
|
->setAttribute('placeholder', $placeholder)
|
||||||
);
|
);
|
||||||
$actions = new FieldList(
|
$actions = FieldList::create(
|
||||||
new FormAction('results', _t('SilverStripe\\CMS\\Search\\SearchForm.GO', 'Go'))
|
FormAction::create('results', _t('SilverStripe\\CMS\\Search\\SearchForm.GO', 'Go'))
|
||||||
);
|
);
|
||||||
/** @skipUpgrade */
|
/** @skipUpgrade */
|
||||||
$form = SearchForm::create($this->owner, 'SearchForm', $fields, $actions);
|
$form = SearchForm::create($this->owner, 'SearchForm', $fields, $actions);
|
||||||
|
@ -1277,35 +1277,36 @@ class SiteTreeTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
$generator = Config::inst()->get(SiteTree::class, 'meta_generator');
|
$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();
|
$page = new SiteTreeTest_PageNode();
|
||||||
|
|
||||||
$meta = $page->MetaTags();
|
$meta = $page->MetaTags();
|
||||||
$this->assertEquals(
|
$this->assertContains('meta name="generator"', $meta, 'Should include generator tag');
|
||||||
1,
|
$this->assertContains(
|
||||||
preg_match('/.*meta name="generator" content="SilverStripe - http:\/\/silverstripe.org".*/', $meta),
|
'content="SilverStripe - https://www.silverstripe.org',
|
||||||
'test default functionality - uses value from Config'
|
$meta,
|
||||||
|
'Should contain default meta generator info'
|
||||||
);
|
);
|
||||||
|
|
||||||
// test proper escaping of quotes in attribute value
|
// test proper escaping of quotes in attribute value
|
||||||
Config::modify()->set(SiteTree::class, 'meta_generator', 'Generator with "quotes" in it');
|
Config::modify()->set(SiteTree::class, 'meta_generator', 'Generator with "quotes" in it');
|
||||||
$meta = $page->MetaTags();
|
$meta = $page->MetaTags();
|
||||||
$this->assertEquals(
|
$this->assertContains(
|
||||||
1,
|
'content="Generator with "quotes" in it',
|
||||||
preg_match('/.*meta name="generator" content="Generator with "quotes" in it".*/', $meta),
|
$meta,
|
||||||
'test proper escaping of values from Config'
|
'test proper escaping of values from Config'
|
||||||
);
|
);
|
||||||
|
|
||||||
// test empty generator - no tag should appear at all
|
// test empty generator - no tag should appear at all
|
||||||
Config::modify()->set(SiteTree::class, 'meta_generator', '');
|
Config::modify()->set(SiteTree::class, 'meta_generator', '');
|
||||||
$meta = $page->MetaTags();
|
$meta = $page->MetaTags();
|
||||||
$this->assertEquals(
|
$this->assertNotContains(
|
||||||
0,
|
'meta name="generator"',
|
||||||
preg_match('/.*meta name=.generator..*/', $meta),
|
$meta,
|
||||||
'test blank value means no tag generated'
|
'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