Merge remote-tracking branch 'origin/3.0' into 3.1

This commit is contained in:
Ingo Schommer 2013-09-27 18:50:52 +02:00
commit 8a96bab70d
14 changed files with 39 additions and 460 deletions

View File

@ -742,13 +742,21 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
if($num) {
return sprintf(
'<a class="cms-panel-link list-children-link" data-pjax-target="ListViewForm,Breadcrumbs" href="%s">%s</a>',
Controller::join_links($controller->Link(), "?ParentID={$item->ID}&view=list"),
Controller::join_links(
$controller->Link(),
sprintf("?ParentID=%d&view=list", (int)$item->ID)
),
$num
);
}
},
'getTreeTitle' => function($value, &$item) use($controller) {
return '<a class="action-detail" href="' . singleton('CMSPageEditController')->Link('show') . '/' . $item->ID . '">' . $item->TreeTitle . '</a>';
return sprintf(
'<a class="action-detail" href="%s/%d">%s</a>',
singleton('CMSPageEditController')->Link('show'),
(int)$item->ID,
$item->TreeTitle // returns HTML, does its own escaping
);
}
));

View File

@ -164,7 +164,13 @@ class ReportAdmin extends LeftAndMain implements PermissionProvider {
'title' => _t('ReportAdmin.ReportTitle', 'Title'),
));
$columns->setFieldFormatting(array(
'title' => '<a href=\"$Link\" class=\"cms-panel-link\">$value</a>'
'title' => function($value, &$item) {
return sprintf(
'<a href=\"%s\" class=\"cms-panel-link\">%s</a>',
Convert::raw2xml($item->Link),
Convert::raw2xml($value)
);
}
));
$gridField->addExtraClass('all-reports-gridfield');
$fields->push($gridField);

View File

@ -121,6 +121,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
'Link' => 'Text',
'RelativeLink' => 'Text',
'AbsoluteLink' => 'Text',
'TreeTitle' => 'HTMLText',
);
private static $defaults = array(
@ -1858,8 +1859,20 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
$dependentTable->getConfig()->getComponentByType('GridFieldDataColumns')
->setDisplayFields($dependentColumns)
->setFieldFormatting(array(
'Title' => '<a href=\"admin/pages/edit/show/$ID\">$Title</a>',
'AbsoluteLink' => '<a href=\"$value\">$value</a>',
'Title' => function($value, &$item) {
return sprintf(
'<a href=\"admin/pages/edit/show/%d\">%s</a>',
(int)$item->ID,
Convert::raw2xml($item->Title)
);
},
'AbsoluteLink' => function($value, &$item) {
return sprintf(
'<a href=\"%s\">%s</a>',
Convert::raw2xml($value),
Convert::raw2xml($value)
);
}
));
}

View File

@ -283,8 +283,13 @@ class SS_Report extends ViewableData {
if(isset($info['casting'])) $fieldCasting[$source] = $info['casting'];
if(isset($info['link']) && $info['link']) {
$link = singleton('CMSPageEditController')->Link('show');
$fieldFormatting[$source] = '<a href=\"' . $link . '/$ID\">$value</a>';
$fieldFormatting[$source] = function($value, &$item) {
return sprintf(
'<a href=\"%s\">%s</a>',
Controller::join_links(singleton('CMSPageEditController')->Link('show'), $item->ID),
Convert::raw2xml($value)
);
};
}
$displayFields[$source] = isset($info['title']) ? $info['title'] : $source;

View File

@ -1,20 +0,0 @@
# Tests #
Given I click on the "Tab Name" tab
Given I close window and go back to clean state
Given I fill out the log in form with user "user" and password "password"
Given I get a permission denied error
Given I go to the draft site
Given I log in as Fred
Given I log in as user
Given I log into the CMS as Fred@example.com
Given I log out
Given I visit admin/security
Given I wait for a status message
Given I wait for a success message
Given a "Blog" page called "News" as a child of "Blogs"
Given a "Publishers" group
Given a top-level "BlogPage" page called "News"
Given a user called "Fred" in the "Authors" group
Given the "News" page can be edited by the "Publishers" group
Given the site can be edited by the "Publishers" group

View File

@ -1,117 +0,0 @@
Feature: Page creation in the CMS
As a content author
I want to create a basic text page at the root level and save it
So that our website can be kept up to date
Scenario: An initial change to page name modifies key fields
Given I log into the CMS as admin
And I create a new page
When I put "Change Name" in the "Page name" field
And I click on the "Metadata" tab
Then the "URLSegment" field is "change-name"
And the "MetaTitle" field is "Change Name"
When I click on the "Main" tab
Then the "Navigation label" field is "Change Name"
Scenario: Every subsequent change does not change the key fields
Given I save the page
And I cancel pop-ups
When I put "Change Again" in the "Page name" field
And I click on the "Metadata" tab
Then the "URLSegment" field is "change-name"
And the "MetaTitle" field is "Change Name"
When I click on the "Main" tab
Then the "Navigation label" field is "Change Name"
Then I delete the current page
Scenario: I can populate all fields
And I create a new page
And I set "Page name" to "Populate name"
And I set "Navigation label" to "Populate label"
And I click on the "Metadata" tab
And I set "URLSegment" to "populate-url-segment"
And I set "MetaTitle" to "Populate MetaTitle"
And I set "Description" to "Populate Description"
And I set "Keywords" to "Populate Keywords"
And I set "Custom Meta Tags" to "Populate Custom Meta Tags"
And I click on the "Main" tab
And I save the page
When I load the "Populate label" page
Then the "Page name" field is "Populate name"
And the "Navigation label" field is "Populate label"
When I click on the "Metadata" tab
Then the "URLSegment" field is "populate-url-segment"
And the "MetaTitle" field is "Populate MetaTitle"
And the "Description" field is "Populate Description"
And the "Custom Meta Tags" field is "Populate Custom Meta Tags"
And I click on the "Main" tab
Then I delete the current page
Scenario: I can create 2 identical pages
When I create a new page
And I create a new page
Then there are 2 root pages with navigation label "New Page"
Then I delete the current page
And I load the "New Page" root-level page
Then I delete the current page
Scenario: Each change to page name changes the URL
When I create a new page
And I set "Page name" to "First Change"
And I click on the "Metadata" tab
Then the "URLSegment" field is "first-change"
When I confirm pop-ups
And I click on the "Main" tab
And I set "Page name" to "Second Change"
And I click on the "Metadata" tab
Then the "URLSegment" field is "second-change"
When I cancel pop-ups
And I click on the "Main" tab
And I set "Page name" to "Third Change"
And I click on the "Metadata" tab
Then the "URLSegment" field is "second-change"
And I click on the "Main" tab
Then I delete the current page
Scenario: Changes aren't saved if I cancel the warning
Given I create a new page
And I set "Page name" to "Change name"
When I confirm pop-ups to ignore the warning that their is unsaved content
And I load the "New Page" page
Then the "Page name" field is "New Page"
Then I delete the current page
Scenario: Page name and navigation label default to new page
Given I create a new page
Then the "Page name" field is "New Page"
And the "Navigation label" field is "New Page"
When I click on the "Metadata" tab
Then the "URLSegment" field is "new-page"
And the "MetaTitle" field is blank
And the "Description" field is blank
And the "Keywords" field is blank
And the "Custom Meta Tags" field is blank
And I click on the "Main" tab
Then I delete the current page
Scenario: The navigation label is displayed in the site tree
Given I create a new page
And I set "Navigation label" to "New Label"
And I save the page
When I load the "New Label" page
Then the "Navigation label" field is "New Label"
Scenario: If the navigation label is blanked out, it takes the value in the Page Name field
Given I set "Page name" to "Page Title"
When I set "Navigation label" to ""
And I save the page
And I load the "Page Title" page
Then the "Navigation label" field is "Page Title"
Then I delete the current page

View File

@ -1,47 +0,0 @@
Feature: Page deletion in the CMS
As a content author
I want to delete pages in the CMS
So that out of date content can be removed
Scenario: User can delete a page without making any changes
Given I log into the CMS as admin
And there are 0 root pages with navigation label "delete-page.scenario1"
And I create a new page called "delete-page.scenario1"
And there are 1 root pages with navigation label "delete-page.scenario1"
When I delete the current page
Then there are 0 root pages with navigation label "delete-page.scenario1"
Scenario: A deleted page can't be viewed
And there are 0 root pages with navigation label "delete-page.scenario2"
Given I create a new page called "delete-page.scenario2"
And there is 1 root page with navigation label "delete-page.scenario2"
When I delete the current page
And there are 0 root pages with navigation label "delete-page.scenario2"
And I log out
Then url delete-page-scenario2 does not exist
Scenario: A deleted URL can be re-used
Given I log into the CMS as admin
And there are 0 root pages with navigation label "delete-page.scenario3"
And I create a new page called "delete-page.scenario3"
And there are 1 root pages with navigation label "delete-page.scenario3"
And I click on the "Metadata" tab
And the "URLSegment" field is "delete-page-scenario3"
And I delete the current page
And there are 0 root pages with navigation label "delete-page.scenario3"
When I create a new page called "delete-page.scenario3"
And I click on the "Metadata" tab
Then the "URLSegment" field is "delete-page-scenario3"
Then delete the current page
Scenario: A deleted page doesn't appear after re-login
Given there are 0 root pages with navigation label "delete-page.scenario4"
And I create a new page called "delete-page.scenario4"
And there is 1 root page with navigation label "delete-page.scenario4"
And I save the page
And I delete the current page
And there are 0 root pages with navigation label "delete-page.scenario4"
When I log out
And I log into the CMS as admin
Then there are 0 root pages with navigation label "delete-page.scenario4"

View File

@ -1,39 +0,0 @@
Feature: Log in
As a CMS user
I want to security log into the CMS
So that I can make changes, knowing that other people can't.
Background:
Given I visit Security/logout
Scenario: opening admin asks user log-in
And I visit admin
Then I am sent to Security/login
Scenario: valid login
When I fill out the login form with user "admin" and password "password"
Then I see "You're logged in as"
Scenario: no password login
When I fill out the log in form with user "admin" and password ""
Then I see "That doesn't seem to be the right e-mail address or password."
Scenario: no user login
When I fill out the log in form with user "" and password "password"
Then I see "That doesn't seem to be the right e-mail address or password."
Scenario: invalid login, getting right 2nd time
Given I visit admin
And I put "admin" in the "Email" field
And I put "wrongpassword" in the "Password" field
And I click the "Log in" button
Then I am sent to Security/login
And I see "That doesn't seem to be the right e-mail address or password."
Given I put "admin" in the "Email" field
And I put "password" in the "Password" field
And I click the "Log in" button
Then I am sent to admin
Scenario: Re-login
Given I visit Security/logout
Then I log into the CMS as admin

View File

@ -1,20 +0,0 @@
Feature: Log out
As a CMS user
I want to be able to log and be locked out of the CMS
So that I can know other people can't edit my site
Scenario: Log out from CMS
Given I log into the CMS as admin
And I click the "Log out" link
When I visit admin/
Then I see "Please choose an authentication method and enter your credentials to access the CMS."
When I visit admin/assets/
Then I see "Please choose an authentication method and enter your credentials to access the CMS."
When I visit admin/comments/
Then I see "Please choose an authentication method and enter your credentials to access the CMS."
When I visit admin/reports/
Then I see "Please choose an authentication method and enter your credentials to access the CMS."
When I visit admin/security/
Then I see "Please choose an authentication method and enter your credentials to access the CMS."
When I visit admin/subsites/
Then I see "Please choose an authentication method and enter your credentials to access the CMS."

View File

@ -1,101 +0,0 @@
## FIXTURE GENERATON
Given /^the site can be edited by the "([^\"]*)" group$/i do |arg1|
pending
end
Given /^the "([^\"]*)" page can be edited by the "([^\"]*)" group$/i do |arg1, arg2|
pending
end
Given /a "(.*)" page called "(.*)" as a child of "(.*)"/i do |type, title, parent|
Given "I click the \"#{parent}\" link"
And 'I wait 2s'
And 'I click the "Create" button'
And "I select \"#{type}\" from \"PageType\""
And 'I click the "Go" button'
And 'I click the "Create" button'
And "I put \"#{title}\" in the \"Title\" field"
And "I click \"Save\""
end
Given /^a top\-level "(.*)" page called "(.*)"$/i do |type,title|
Given "I click the \"Site Content\" link"
And "I create a new page "
And "I click on the \"Main\" tab"
And "I put \"#{title}\" in the \"Title\" field"
And "I click \"Save\""
end
## ACTIONS
Given /load the "(.*)" page/i do |title|
Given "I click the \"#{title}\" link"
end
Given /I load the "(.*)" root-level page/ do |nav|
@browser.link(:xpath, "//ul[@id='sitetree']/li/ul/li//a[.='#{nav}']").click
end
Given /I load the root node/ do
Given 'I click the "admin/show/root" link'
end
Given /create a new page$/i do
Given "I create a new page using template \"Page\""
end
Given /create a new page called "(.*)"$/i do |title|
Given "I create a new page using template \"Page\""
And "I click on the \"Main\" tab"
And "I put \"#{title}\" in the \"Page name\" field"
And "I click the \"Save\" button"
end
Given /create a new page using template \"(.*)\"/i do |type|
Given 'I load the root node (ajax)'
And 'I click the "Create" button'
And "I select \"#{type}\" from \"PageType\""
And 'I click the "Go" button (ajax)'
And 'I click the "Create" button'
end
Given /save the page$/i do
Given 'I click the "Form_EditForm_action_save" button (ajax)'
end
Given /delete the current page$/i do
Given 'I click the "Delete from the draft site" button'
end
## ASSERTIONS
Given /There (?:are|is) ([0-9]+) root pages? with navigation label "(.*)"/i do |count, nav|
@browser.elements_by_xpath("//ul[@id='sitetree']/li/ul/li//a[.='#{nav}']").count.should == count.to_i
end
Given /The "(.*)" page does not exist/i do | page|
@browser.link(:title, title).should empty?
#|''get url''|@{root_url}PAGE|
#|''title''|'''is not'''|PAGE|
end
## Current Page
Given /^The (.*) of the current page is "([^\"]*)"$/i do |arg1|
pending
end
Then /^The current page is editable$/i do
pending
end
Then /^The current page is read-only$/i do
pending
end
Then /^The current page is at the top\-level$/i do
pending
end

View File

@ -1,21 +0,0 @@
##
## Step definitions for testing the front-end site
##
Given /I go to the draft site/ do
pending
Given 'I click the "viewStageSite" link'
# |''element''|//a[@id="viewStageSite"]|''exists''|
# |''checking timeout''|@{fast_checking_timeout}|
# |''optionally''|''element''|//a[@id="viewStageSite"][@style=""]|''exists''|
# |''checking timeout''|@{checking_timeout}|
# |''click''|viewStageSite|
end
Given /I close window and go back to clean state/ do
# |''close''|
# |''select initial window''|
# |default frame|
# |''go to root node''|
end

View File

@ -1,40 +0,0 @@
##
## General rules for the SilverStripe CMS as a whole. They mostly have to do with the LeftAndMain
## interface
# Match general CMS tabs, ModelAdmin needs another system
Given /I click on the "([^\"]*)" tab/ do |tab|
found = nil
links = @salad.browser.links()
links.each {|link|
if /^tab-.+/.match(link.id) then
if link.innerText == tab or /^tab-.*#{tab}(_set)?/.match(link.id) then
found = link
break
end
end
}
if found then
Given "I click the \"#{found.id}\" link"
else
fail("Could not find the \"#{tab}\" tab")
end
end
Given /I wait for a status message/ do
Watir::Waiter::wait_until {
@browser.p(:id, 'statusMessage').exists? && @browser.p(:id, 'statusMessage').visible?
}
end
Given /I wait for a success message/ do
# We have to wait until after messages of the form 'Saving...', to get either a good message or
# a bad message
Watir::Waiter::wait_until {
@browser.p(:id, 'statusMessage').exists? && @browser.p(:id, 'statusMessage').visible? && @browser.p(:id, 'statusMessage').class_name != ""
}
@browser.p(:id, 'statusMessage').class_name.should == 'good'
end

View File

@ -1,25 +0,0 @@
# Log in
Given /log in as (.*)$/ do |user|
Given "I fill out the log in form with user \"#{user}\" and password \"password\""
And 'I see "You\'re logged in as"'
end
Given /log into the CMS as (.*)/ do |user|
Given "I log in as #{user}"
And "I visit admin/"
And "I load the root node"
end
Given /log out$/ do
Given "I visit Security/logout"
end
Given /fill out the log(?:\s*)in form with user "(.*)" and password "(.*)"/ do |user, password|
Given 'I visit Security/logout'
And 'I visit Security/login?BackURL=Security/login'
And "I put \"#{user}\" in the \"Email\" field"
And "I put \"#{password}\" in the \"Password\" field"
And "I click the \"Log in\" button"
end

View File

@ -1,23 +0,0 @@
# Steps definitions for security
# Fixture instantiation
Given /a "(.*)" group/ do |group|
Given 'I visit admin/security'
And 'I click the "Security Groups" link'
And 'I click the "Create" button'
And "I put \"#{group}\" in the \"Title\" field"
And 'I click the "Save" button'
end
Given /a user called "(.*)" in the "(.*)" group/ do |user, group|
Given 'I visit admin/security'
And "I click the \"#{group} (global group)\" link"
And "I put \"#{user}\" in the \"FirstName\" field"
And "I put \"#{user}\" in the \"Email\" field"
And "I put \"password\" in the \"SetPassword\" field"
And "I click the \"Add\" button"
end
Given /^I get a permission denied error$/ do
pending
end