mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
BUG Fix encoding of SiteTree.MetaTags
This commit is contained in:
parent
9bff36c078
commit
89fbae2c2e
@ -1380,7 +1380,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
||||
public function MetaTags($includeTitle = true) {
|
||||
$tags = "";
|
||||
if($includeTitle === true || $includeTitle == 'true') {
|
||||
$tags .= "<title>" . $this->Title . "</title>\n";
|
||||
$tags .= "<title>" . Convert::raw2xml($this->Title) . "</title>\n";
|
||||
}
|
||||
|
||||
$generator = trim(Config::inst()->get('SiteTree', 'meta_generator'));
|
||||
|
@ -944,6 +944,29 @@ class SiteTreeTest extends SapphireTest {
|
||||
Config::inst()->update('SiteTree', 'meta_generator', $generator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests SiteTree::MetaTags
|
||||
* Note that this test makes no assumption on the closing of tags (other than <title></title>)
|
||||
*/
|
||||
public function testMetaTags() {
|
||||
$this->logInWithPermission('ADMIN');
|
||||
$page = $this->objFromFixture('Page', 'metapage');
|
||||
|
||||
// Test with title
|
||||
$meta = $page->MetaTags();
|
||||
$charset = Config::inst()->get('ContentNegotiator', 'encoding');
|
||||
$this->assertContains('<meta http-equiv="Content-type" content="text/html; charset='.$charset.'"', $meta);
|
||||
$this->assertContains('<meta name="description" content="The <br /> and <br> tags"', $meta);
|
||||
$this->assertContains('<link rel="canonical" href="http://www.mysite.com/html-and-xml"', $meta);
|
||||
$this->assertContains('<meta name="x-page-id" content="'.$page->ID.'"', $meta);
|
||||
$this->assertContains('<meta name="x-cms-edit-link" content="'.$page->CMSEditLink().'" />', $meta);
|
||||
$this->assertContains('<title>HTML & XML</title>', $meta);
|
||||
|
||||
// Test without title
|
||||
$meta = $page->MetaTags(false);
|
||||
$this->assertNotContains('<title>', $meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that orphaned pages are handled correctly
|
||||
*/
|
||||
|
@ -1,104 +1,107 @@
|
||||
Group:
|
||||
editors:
|
||||
Title: Editors
|
||||
admins:
|
||||
Title: Administrators
|
||||
allsections:
|
||||
Title: All Section Editors
|
||||
securityadmins:
|
||||
Title: Security Admins
|
||||
editors:
|
||||
Title: Editors
|
||||
admins:
|
||||
Title: Administrators
|
||||
allsections:
|
||||
Title: All Section Editors
|
||||
securityadmins:
|
||||
Title: Security Admins
|
||||
|
||||
Permission:
|
||||
admins:
|
||||
Code: ADMIN
|
||||
Group: =>Group.admins
|
||||
editors:
|
||||
Code: CMS_ACCESS_CMSMain
|
||||
Group: =>Group.editors
|
||||
allsections:
|
||||
Code: CMS_ACCESS_LeftAndMain
|
||||
Group: =>Group.allsections
|
||||
securityadmins:
|
||||
Code: CMS_ACCESS_SecurityAdmin
|
||||
Group: =>Group.securityadmins
|
||||
admins:
|
||||
Code: ADMIN
|
||||
Group: =>Group.admins
|
||||
editors:
|
||||
Code: CMS_ACCESS_CMSMain
|
||||
Group: =>Group.editors
|
||||
allsections:
|
||||
Code: CMS_ACCESS_LeftAndMain
|
||||
Group: =>Group.allsections
|
||||
securityadmins:
|
||||
Code: CMS_ACCESS_SecurityAdmin
|
||||
Group: =>Group.securityadmins
|
||||
|
||||
Member:
|
||||
editor:
|
||||
FirstName: Test
|
||||
Surname: Editor
|
||||
Groups: =>Group.editors
|
||||
admin:
|
||||
FirstName: Test
|
||||
Surname: Administrator
|
||||
Groups: =>Group.admins
|
||||
allsections:
|
||||
Groups: =>Group.allsections
|
||||
securityadmin:
|
||||
Groups: =>Group.securityadmins
|
||||
editor:
|
||||
FirstName: Test
|
||||
Surname: Editor
|
||||
Groups: =>Group.editors
|
||||
admin:
|
||||
FirstName: Test
|
||||
Surname: Administrator
|
||||
Groups: =>Group.admins
|
||||
allsections:
|
||||
Groups: =>Group.allsections
|
||||
securityadmin:
|
||||
Groups: =>Group.securityadmins
|
||||
|
||||
Page:
|
||||
home:
|
||||
Title: Home
|
||||
CanEditType: OnlyTheseUsers
|
||||
EditorGroups: =>Group.admins
|
||||
about:
|
||||
Title: About Us
|
||||
CanEditType: OnlyTheseUsers
|
||||
EditorGroups: =>Group.admins
|
||||
staff:
|
||||
Title: Staff
|
||||
URLSegment: my-staff
|
||||
Parent: =>Page.about
|
||||
ceo:
|
||||
Title: CEO
|
||||
Parent: =>Page.staff
|
||||
staffduplicate:
|
||||
Title: Staff
|
||||
URLSegment: my-staff
|
||||
Parent: =>Page.about
|
||||
products:
|
||||
Title: Products
|
||||
CanEditType: OnlyTheseUsers
|
||||
EditorGroups: =>Group.editors
|
||||
product1:
|
||||
Title: 1.1 Test Product
|
||||
Parent: =>Page.products
|
||||
CanEditType: Inherit
|
||||
product2:
|
||||
Title: Another Product
|
||||
Parent: =>Page.products
|
||||
CanEditType: Inherit
|
||||
product3:
|
||||
Title: Another Product
|
||||
Parent: =>Page.products
|
||||
CanEditType: Inherit
|
||||
product4:
|
||||
Title: Another Product
|
||||
Parent: =>Page.products
|
||||
CanEditType: OnlyTheseUsers
|
||||
EditorGroups: =>Group.admins
|
||||
contact:
|
||||
Title: Contact Us
|
||||
object:
|
||||
Title: Object
|
||||
controller:
|
||||
Title: Controller
|
||||
numericonly:
|
||||
Title: 1930
|
||||
home:
|
||||
Title: Home
|
||||
CanEditType: OnlyTheseUsers
|
||||
EditorGroups: =>Group.admins
|
||||
about:
|
||||
Title: About Us
|
||||
CanEditType: OnlyTheseUsers
|
||||
EditorGroups: =>Group.admins
|
||||
staff:
|
||||
Title: Staff
|
||||
URLSegment: my-staff
|
||||
Parent: =>Page.about
|
||||
ceo:
|
||||
Title: CEO
|
||||
Parent: =>Page.staff
|
||||
staffduplicate:
|
||||
Title: Staff
|
||||
URLSegment: my-staff
|
||||
Parent: =>Page.about
|
||||
products:
|
||||
Title: Products
|
||||
CanEditType: OnlyTheseUsers
|
||||
EditorGroups: =>Group.editors
|
||||
product1:
|
||||
Title: 1.1 Test Product
|
||||
Parent: =>Page.products
|
||||
CanEditType: Inherit
|
||||
product2:
|
||||
Title: Another Product
|
||||
Parent: =>Page.products
|
||||
CanEditType: Inherit
|
||||
product3:
|
||||
Title: Another Product
|
||||
Parent: =>Page.products
|
||||
CanEditType: Inherit
|
||||
product4:
|
||||
Title: Another Product
|
||||
Parent: =>Page.products
|
||||
CanEditType: OnlyTheseUsers
|
||||
EditorGroups: =>Group.admins
|
||||
contact:
|
||||
Title: Contact Us
|
||||
object:
|
||||
Title: Object
|
||||
controller:
|
||||
Title: Controller
|
||||
numericonly:
|
||||
Title: 1930
|
||||
metapage:
|
||||
Title: 'HTML & XML'
|
||||
MetaDescription: 'The <br /> and <br> tags'
|
||||
ExtraMeta: '<link rel="canonical" href="http://www.mysite.com/html-and-xml" />'
|
||||
|
||||
SiteTreeTest_Conflicted:
|
||||
parent:
|
||||
Title: Parent
|
||||
parent:
|
||||
Title: Parent
|
||||
|
||||
ErrorPage:
|
||||
404:
|
||||
Title: Page not Found
|
||||
ErrorCode: 404
|
||||
404:
|
||||
Title: Page not Found
|
||||
ErrorCode: 404
|
||||
|
||||
RedirectorPage:
|
||||
external:
|
||||
Title: External
|
||||
URLSegment: external
|
||||
RedirectionType: External
|
||||
ExternalURL: "http://www.google.com?a&b"
|
||||
|
||||
external:
|
||||
Title: External
|
||||
URLSegment: external
|
||||
RedirectionType: External
|
||||
ExternalURL: "http://www.google.com?a&b"
|
||||
|
Loading…
Reference in New Issue
Block a user