mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
wscott: Added some additional fixes & such to sapphire
TooglePanel? can be created initially closed PasswordField? honors a max size passed to it SiteTree? / Pages can now have custom meta tags Sitemap can deal with pinging google on updates, plus a couple other minor changes git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@41690 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
5857c4cab6
commit
4cb5bd719a
@ -16,6 +16,12 @@ class Sitemap extends Controller {
|
||||
{
|
||||
foreach($this->Pages as $page)
|
||||
{
|
||||
// If the page has been set to 0 priority, we set a flag so it won't be included
|
||||
if(isset($page->Priority) && $page->Priority <= 0)
|
||||
$page->Include = false;
|
||||
else
|
||||
$page->Include = true;
|
||||
|
||||
// The one field that isn't easy to deal with in the template is
|
||||
// Change frequency, so we set that here.
|
||||
$properties = $page->toMap();
|
||||
@ -59,6 +65,10 @@ class Sitemap extends Controller {
|
||||
|
||||
static function Ping()
|
||||
{
|
||||
//Don't ping if the site has disabled it
|
||||
if(!Sitemap::$pings)
|
||||
return;
|
||||
|
||||
$location = urlencode(Director::absoluteBaseURL() . '/sitemap.xml');
|
||||
|
||||
$response = HTTP::sendRequest("www.google.com", "/webmasters/sitemaps/ping",
|
||||
@ -67,6 +77,19 @@ class Sitemap extends Controller {
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected static $pings = true;
|
||||
|
||||
/**
|
||||
* Disables pings to google when the sitemap changes
|
||||
* To use this, in your _config.php file simply include the line
|
||||
* Sitemap::DisableGoogleNotification();
|
||||
*/
|
||||
static function DisableGoogleNotification()
|
||||
{
|
||||
self::$pings = false;
|
||||
}
|
||||
|
||||
|
||||
function index($url)
|
||||
{
|
||||
// We need to override the default content-type
|
||||
|
@ -387,6 +387,9 @@ class SiteTree extends DataObject {
|
||||
if($this->MetaDescription) {
|
||||
$tags .= "<meta name=\"description\" http-equiv=\"description\" content=\"" . Convert::raw2att($this->MetaDescription) . "\" />\n";
|
||||
}
|
||||
if($this->ExtraMeta) {
|
||||
$tags .= $this->ExtraMeta . "\n";
|
||||
}
|
||||
|
||||
return $tags;
|
||||
}
|
||||
@ -672,8 +675,12 @@ class SiteTree extends DataObject {
|
||||
new TextField("MetaTitle", "Title"),
|
||||
new TextareaField("MetaDescription", "Description"),
|
||||
new TextareaField("MetaKeywords", "Keywords"),
|
||||
new LiteralField("", "<p>Manually specify a Priority for this page:: (valid values are from 0 to 1)</p>"),
|
||||
new NumericField("Priority","Page Priority")
|
||||
new TogglePanel("Advanced Options...",array(
|
||||
new TextareaField("ExtraMeta","Custom Meta Tags"),
|
||||
new LiteralField("", "<p>Manually specify a Priority for this page: (valid values are from 0 to 1, a zero will remove this page from the index)</p>"),
|
||||
new NumericField("Priority","Page Priority")),
|
||||
true
|
||||
)
|
||||
)
|
||||
),
|
||||
new Tab("Behaviour",
|
||||
@ -979,6 +986,7 @@ class SiteTree extends DataObject {
|
||||
"MetaTitle" => "Varchar(255)",
|
||||
"MetaDescription" => "Varchar(255)",
|
||||
"MetaKeywords" => "Varchar(255)",
|
||||
"ExtraMeta" => "HTMLText",
|
||||
"ShowInMenus" => "Boolean",
|
||||
"ShowInSearch" => "Boolean",
|
||||
"HomepageForDomain" => "Varchar(100)",
|
||||
|
@ -15,7 +15,7 @@ class PasswordField extends FormField {
|
||||
|
||||
function Field() {
|
||||
if($this->maxLength){
|
||||
return "<input class=\"text\" type=\"password\" id=\"" . $this->id() . "\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" maxlength=\"$this->maxLength\" />";
|
||||
return "<input class=\"text\" type=\"password\" id=\"" . $this->id() . "\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" maxlength=\"$this->maxLength\" size=\"$this->maxLength\"/>";
|
||||
}else{
|
||||
return "<input class=\"text\" type=\"password\" id=\"" . $this->id() . "\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" />";
|
||||
}
|
||||
|
@ -3,8 +3,9 @@
|
||||
class TogglePanel extends CompositeField {
|
||||
protected $closed = false;
|
||||
|
||||
function __construct($title, $children) {
|
||||
function __construct($title, $children, $startClosed = false) {
|
||||
$this->title = $title;
|
||||
$this->closed = $startClosed;
|
||||
$this->name = ereg_replace('[^A-Za-z0-9]','',$this->title);
|
||||
parent::__construct($children);
|
||||
}
|
||||
|
@ -3,11 +3,13 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84">
|
||||
<% control Items %>
|
||||
<% if Include %>
|
||||
<url>
|
||||
<loc>$AbsoluteLink</loc>
|
||||
<lastmod>$LastEdited.Format(c)</lastmod>
|
||||
<% if ChangeFreq %><changefreq>$ChangeFreq</changefreq><% end_if %>
|
||||
<% if Priority %><priority>$Priority</priority><% end_if %>
|
||||
</url>
|
||||
<% end_if %>
|
||||
<% end_control %>
|
||||
</urlset>
|
Loading…
Reference in New Issue
Block a user