Skip to content

Commit

Permalink
updated the namespace cases
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsekaean committed Feb 1, 2022
1 parent b472bda commit 04803e3
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/Control/RobotsTXTController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* To change this template use File | Settings | File Templates.
*/

namespace SilverStripers\seo\Control;
namespace SilverStripers\SEO\Control;


use SilverStripe\CMS\Model\SiteTree;
Expand Down
97 changes: 60 additions & 37 deletions src/Extension/SiteConfigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,72 @@
* To change this template use File | Settings | File Templates.
*/

namespace SilverStripers\seo\Extensions;

namespace SilverStripers\SEO\Extension;

use SilverStripe\AssetAdmin\Forms\UploadField;
use SilverStripe\Assets\Image;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;
use SilverStripe\Forms\HeaderField;
use SilverStripe\Forms\LiteralField;
use SilverStripe\Forms\TextareaField;
use SilverStripe\Forms\TextField;
use SilverStripe\ORM\DataExtension;
use SilverStripers\SEO\Model\MetaTitleTemplate;
use SilverStripers\SEO\Model\Variable;

class SiteConfigExtension extends DataExtension
{

private static $db = [
'DisableSearchEngineVisibility' => 'Boolean',
'TwitterUsername' => 'Varchar(250)',
'FacebookAdmin' => 'Varchar(250)',
'FacebookAppID' => 'Varchar(250)',
private static $db = [
'DisableSearchEngineVisibility' => 'Boolean',
'TwitterUsername' => 'Varchar(250)',
'FacebookAdmin' => 'Varchar(250)',
'FacebookAppID' => 'Varchar(250)',

'HeadScripts' => 'Text',
'BodyStartScripts' => 'Text',
'BodyEndScripts' => 'Text',
'HeadScripts' => 'Text',
'BodyStartScripts' => 'Text',
'BodyEndScripts' => 'Text',

'RobotsTXT' => 'Text',
'RobotsPublishedPagesOnly' => 'Boolean'
];
'RobotsPublishedPagesOnly' => 'Boolean',

private static $has_one = [
'GlobalSocialSharingImage' => Image::class
];
'DefaultMetaTitle' => 'Varchar(255)'
];

private static $owns = [
'GlobalSocialSharingImage'
private static $has_one = [
'GlobalSocialSharingImage' => Image::class
];

public function updateCMSFields(FieldList $fields)
{
$fields->addFieldsToTab('Root.SEO', [
HeaderField::create('SEAccess', 'Search engine access')->setHeadingLevel(4),
CheckboxField::create('DisableSearchEngineVisibility', 'Disable search engine visibility'),
LiteralField::create('SearchNote', '<p>Note that it is up to the search engines not to index this site</p>'),
TextField::create('TwitterUsername', 'Twitter Username'),
TextField::create('FacebookAdmin', 'Facebook Admin Meta'),
TextField::create('FacebookAppID', 'Facebook App ID'),
UploadField::create('GlobalSocialSharingImage', 'Global Social Sharing Image'),

HeaderField::create('Embeds', 'Embed scripts for analytics etc')->setHeadingLevel(4),
TextareaField::create('HeadScripts', 'Scripts within <head> block'),
TextareaField::create('BodyStartScripts', 'Scripts just after opening <body>'),
TextareaField::create('BodyEndScripts', 'Scripts just before opening <body>'),

HeaderField::create('RobotsTXTHeading', 'Robots TXT')->setHeadingLevel(4),
private static $owns = [
'GlobalSocialSharingImage'
];

public function updateCMSFields(FieldList $fields)
{
$fields->addFieldsToTab('Root.SEO.Main', [
CheckboxField::create('DisableSearchEngineVisibility', 'Disable search engine visibility'),
LiteralField::create('SearchNote', '<p>Note that it is up to the search engines not to index this site</p>')
]);


$fields->addFieldsToTab('Root.SEO.Social', [
TextField::create('TwitterUsername', 'Twitter Username'),
TextField::create('FacebookAdmin', 'Facebook Admin Meta'),
TextField::create('FacebookAppID', 'Facebook App ID'),
UploadField::create('GlobalSocialSharingImage', 'Global Social Sharing Image')
]);


$fields->addFieldsToTab('Root.SEO.Embeds', [
TextareaField::create('HeadScripts', 'Scripts within <head> block'),
TextareaField::create('BodyStartScripts', 'Scripts just after opening <body>'),
TextareaField::create('BodyEndScripts', 'Scripts just before opening <body>')
]);

$fields->addFieldsToTab('Root.SEO.Robots', [
CheckboxField::create('RobotsPublishedPagesOnly', 'Include published pages only in Robots TXT'),
TextareaField::create('RobotsTXT', 'Robots TXT')
->setDescription('<p>An example robots.txt<br>
Expand All @@ -71,9 +82,21 @@ public function updateCMSFields(FieldList $fields)
</pre></p>')
]);

$this->owner->invokeWithExtensions('updateSEOFields', $fields);

}
$fields->addFieldsToTab('Root.SEO.Variables', [
GridField::create('SEOVariables', 'Variables')
->setList(Variable::get())
->setConfig(GridFieldConfig_RecordEditor::create())
]);

$fields->addFieldsToTab('Root.SEO.MetaTitles', [
TextField::create('DefaultMetaTitle', 'Default Meta Title Template')
->setValue(MetaTitleTemplate::get_default_title())
->setDescription('Default value: ' . MetaTitleTemplate::get_default_title()),
GridField::create('MetaTitles', 'Templates')
->setList(MetaTitleTemplate::get())
->setConfig(GridFieldConfig_RecordEditor::create())
]);

$this->owner->invokeWithExtensions('updateSEOFields', $fields);
}
}

0 comments on commit 04803e3

Please sign in to comment.