SEOToolboxSiteTreeExtension::updateCMSFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 9.52
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
class SEOToolboxSiteTreeExtension extends DataExtension {
4
5
    private static $db = array(
6
        'MetaTitle' => 'VARCHAR(255)'
7
    );
8
9
    public function MetaTags($tags) {
10
        $tags = preg_replace('/<title(.*?)<\/title>/im', '', $tags);
11
        $title = ($this->owner->MetaTitle) ? $this->owner->MetaTitle : $this->owner->Title;
0 ignored issues
show
Bug introduced by
The property MetaTitle does not seem to exist in SS_Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
Bug introduced by
The property Title does not seem to exist in SS_Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
12
        $tags .= "<title>{$title}</title>";
13
        return $tags;
14
    }
15
16
    public function updateCMSFields(FieldList $fields) {
17
        $fields->removeByName('Metadata');
18
        $fields->addFieldsToTab('Root.SEO', array(
19
            TextField::create("MetaTitle",
20
                _t('SEOToolbox.SEOMetaTitle', 'Meta title')
21
            )->setRightTitle(
22
                _t('SEOToolbox.SEOMetaTitleHelp',
23
                    'Name of the page, search engines use this as title of search results. 
24
                    If unset, the page title will be used.')
25
            ),
26
            TextareaField::create("MetaDescription", $this->owner->fieldLabel('MetaDescription'))
27
                ->setRightTitle(
28
                    _t('SEOToolbox.METADESCHELP',
29
                        "Search engines use this content for displaying search results 
30
                        (although it will not influence their ranking).")
31
                )->addExtraClass('help'),
32
            TextareaField::create("ExtraMeta", $this->owner->fieldLabel('ExtraMeta'))
33
                ->setRightTitle(
34
                    _t('SEOToolbox.METAEXTRAHELP',
35
                        "HTML tags for additional meta information. For example &lt;meta name=\"customName\" 
36
                        content=\"your custom content here\" /&gt;")
37
                )->addExtraClass('help'),
38
            SEOToolboxAnalyzerField::create('Analyzer', $this->owner->URLSegment),
0 ignored issues
show
Bug introduced by
The property URLSegment does not seem to exist in SS_Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
39
        ));
40
    }
41
42
}
43