Merge branch '4.0' into 4.1

This commit is contained in:
Aaron Carlino 2018-12-11 11:42:11 +13:00
commit a4b78c4041
3 changed files with 22 additions and 20 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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);
}