AutomatedLinkReport::Title()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Plugin: SEOToolbox
4
 * Author: Dylan Grech
5
 * Copyright: 2016
6
 *
7
 * Automated Link Report is a report that lists all automated
8
 * links and how they affect the website
9
 */
10
class AutomatedLinkReport extends SS_Report{
11
12
    protected $title       = 'Automated Link Report';
13
    protected $description = 'Shows a list of all automated links and how they affect the site';
14
15
    // Configs
16
    private static $run_in_realtime = true;
17
18
    public function Title() {
19
        return (string) $this->title;
20
    }
21
22
    public function columns() {
23
        return array(
24
            'Title'              => array(
25
                'title' => 'Page Title',
26
                'link' => true,
27
            ),
28
            'URLSegment'        => 'Page URLSegment',
29
            'OriginalLinkCount' => 'Amount of links originally',
30
            'Links'             => 'List of automated links present',
31
            'LinkCount'         => 'Amount of links created',
32
            'TotalLinks'        => 'Total Amount of links'
33
        );
34
    }
35
36
    public function sourceRecords(){
37
        if( !Config::inst()->get( $this->class, 'run_in_realtime' ) ) {
38
            return AutomatedLinkPageResult::get();
39
        }
40
41
        $task = new AutomatedLinkReportTask();
42
        return $task->checkLinks();
43
    }
44
45
    public function getReportField() {
46
        $gridField = parent::getReportField();
47
48
        $gridField->setModelClass('reportTotalBookings');
49
50
        $gridConfig = $gridField->getConfig();
51
52
        $gridConfig->removeComponentsByType('GridFieldPrintButton');
53
        $gridConfig->removeComponentsByType('GridFieldExportButton');
54
55
        $gridConfig->addComponents(
56
            new GridFieldPrintAllAutomatedLinksButton('buttons-after-left'),
57
            new GridFieldExportAllAutomatedLinksButton('buttons-after-left')
58
        );
59
60
        return $gridField;
61
    }
62
}
63