Completed
Push — master ( bdc3e4...d48199 )
by
unknown
12s
created
src/Report/CwpStatsReport.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -20,108 +20,108 @@
 block discarded – undo
20 20
  */
21 21
 class CwpStatsReport extends Report
22 22
 {
23
-    public function title()
24
-    {
25
-        return _t(__CLASS__ . '.Title', 'Summary statistics');
26
-    }
27
-
28
-    public function description()
29
-    {
30
-        return _t(
31
-            __CLASS__ . '.Description',
32
-            'This report provides various statistics for this site. The "total live page count" is the number that ' .
33
-                'can be compared against the instance size specifications.'
34
-        );
35
-    }
36
-
37
-    public function columns()
38
-    {
39
-        return [
40
-            'Name' => _t(__CLASS__ . '.Name', 'Name'),
41
-            'Count' => _t(__CLASS__ . '.Count', 'Count'),
42
-        ];
43
-    }
44
-
45
-    /**
46
-     * Manually create source records for the report. Agreggates cannot be provided as a column of a DataQuery result.
47
-     *
48
-     * {@inheritDoc}
49
-     */
50
-    public function sourceRecords($params = [], $sort = null, $limit = null)
51
-    {
52
-        $records = [];
53
-
54
-        // Get the query to apply across all variants: looks at all subsites, translations, live stage only.
55
-        $crossVariant = (function ($dataQuery) {
56
-            $params = [
57
-                'Subsite.filter' => false,
58
-                'Versioned.mode' => 'stage',
59
-                'Versioned.stage' => Versioned::LIVE,
60
-            ];
61
-
62
-            return $dataQuery->setDataQueryParam($params);
63
-        });
64
-
65
-        // Total.
66
-        $records[] = [
67
-            'Name' => _t(
68
-                __CLASS__ . '.TotalPageCount',
69
-                'Total live page count, across all translations and subsites'
70
-            ),
71
-            'Count' => $crossVariant(SiteTree::get())->count(),
72
-        ];
73
-
74
-        if (class_exists(Subsite::class)) {
75
-            // Main site.
76
-            $records[] = [
77
-                'Name' => _t(__CLASS__ . '.PagesForMainSite', '- in the main site'),
78
-                'Count' => $crossVariant(SiteTree::get())
79
-                    ->filter(['SubsiteID' => 0])
80
-                    ->count(),
81
-            ];
82
-
83
-            // Per subsite.
84
-            $subsites = Subsite::get();
85
-            foreach ($subsites as $subsite) {
86
-                $records[] = [
87
-                    'Name' => _t(
88
-                        __CLASS__ . '.PagesForSubsite',
89
-                        "- in the subsite '{SubsiteTitle}'",
90
-                        ['SubsiteTitle' => $subsite->Title]
91
-                    ),
92
-                    'Count' => $crossVariant(SiteTree::get())
93
-                        ->filter(['SubsiteID' => $subsite->ID])
94
-                        ->count(),
95
-                ];
96
-            }
97
-        }
98
-
99
-        // Files.
100
-        $records[] = [
101
-            'Name' => _t(__CLASS__ . '.FileCount', 'File count'),
102
-            'Count' => File::get()
103
-                ->setDataQueryParam('Subsite.filter', false)
104
-                ->filter(['ClassName:not' => Folder::class])
105
-                ->count(),
106
-        ];
107
-
108
-        return ArrayList::create($records);
109
-    }
110
-
111
-    /**
112
-     * @return GridField
113
-     */
114
-    public function getReportField()
115
-    {
116
-        /** @var GridField $gridField */
117
-        $gridField = parent::getReportField();
118
-
119
-        /** @var GridFieldConfig $gridConfig */
120
-        $gridConfig = $gridField->getConfig();
121
-        $gridConfig->removeComponentsByType(GridFieldPrintButton::class);
122
-        $gridConfig->removeComponentsByType(GridFieldExportButton::class);
123
-        $gridConfig->removeComponentsByType(GridFieldSortableHeader::class);
124
-
125
-        return $gridField;
126
-    }
23
+	public function title()
24
+	{
25
+		return _t(__CLASS__ . '.Title', 'Summary statistics');
26
+	}
27
+
28
+	public function description()
29
+	{
30
+		return _t(
31
+			__CLASS__ . '.Description',
32
+			'This report provides various statistics for this site. The "total live page count" is the number that ' .
33
+				'can be compared against the instance size specifications.'
34
+		);
35
+	}
36
+
37
+	public function columns()
38
+	{
39
+		return [
40
+			'Name' => _t(__CLASS__ . '.Name', 'Name'),
41
+			'Count' => _t(__CLASS__ . '.Count', 'Count'),
42
+		];
43
+	}
44
+
45
+	/**
46
+	 * Manually create source records for the report. Agreggates cannot be provided as a column of a DataQuery result.
47
+	 *
48
+	 * {@inheritDoc}
49
+	 */
50
+	public function sourceRecords($params = [], $sort = null, $limit = null)
51
+	{
52
+		$records = [];
53
+
54
+		// Get the query to apply across all variants: looks at all subsites, translations, live stage only.
55
+		$crossVariant = (function ($dataQuery) {
56
+			$params = [
57
+				'Subsite.filter' => false,
58
+				'Versioned.mode' => 'stage',
59
+				'Versioned.stage' => Versioned::LIVE,
60
+			];
61
+
62
+			return $dataQuery->setDataQueryParam($params);
63
+		});
64
+
65
+		// Total.
66
+		$records[] = [
67
+			'Name' => _t(
68
+				__CLASS__ . '.TotalPageCount',
69
+				'Total live page count, across all translations and subsites'
70
+			),
71
+			'Count' => $crossVariant(SiteTree::get())->count(),
72
+		];
73
+
74
+		if (class_exists(Subsite::class)) {
75
+			// Main site.
76
+			$records[] = [
77
+				'Name' => _t(__CLASS__ . '.PagesForMainSite', '- in the main site'),
78
+				'Count' => $crossVariant(SiteTree::get())
79
+					->filter(['SubsiteID' => 0])
80
+					->count(),
81
+			];
82
+
83
+			// Per subsite.
84
+			$subsites = Subsite::get();
85
+			foreach ($subsites as $subsite) {
86
+				$records[] = [
87
+					'Name' => _t(
88
+						__CLASS__ . '.PagesForSubsite',
89
+						"- in the subsite '{SubsiteTitle}'",
90
+						['SubsiteTitle' => $subsite->Title]
91
+					),
92
+					'Count' => $crossVariant(SiteTree::get())
93
+						->filter(['SubsiteID' => $subsite->ID])
94
+						->count(),
95
+				];
96
+			}
97
+		}
98
+
99
+		// Files.
100
+		$records[] = [
101
+			'Name' => _t(__CLASS__ . '.FileCount', 'File count'),
102
+			'Count' => File::get()
103
+				->setDataQueryParam('Subsite.filter', false)
104
+				->filter(['ClassName:not' => Folder::class])
105
+				->count(),
106
+		];
107
+
108
+		return ArrayList::create($records);
109
+	}
110
+
111
+	/**
112
+	 * @return GridField
113
+	 */
114
+	public function getReportField()
115
+	{
116
+		/** @var GridField $gridField */
117
+		$gridField = parent::getReportField();
118
+
119
+		/** @var GridFieldConfig $gridConfig */
120
+		$gridConfig = $gridField->getConfig();
121
+		$gridConfig->removeComponentsByType(GridFieldPrintButton::class);
122
+		$gridConfig->removeComponentsByType(GridFieldExportButton::class);
123
+		$gridConfig->removeComponentsByType(GridFieldSortableHeader::class);
124
+
125
+		return $gridField;
126
+	}
127 127
 }
Please login to merge, or discard this patch.
src/Extension/RichLinksExtension.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -16,48 +16,48 @@
 block discarded – undo
16 16
 class RichLinksExtension extends Extension
17 17
 {
18 18
 
19
-    /**
20
-     * @var array
21
-     */
22
-    private static $casting = [
23
-        'RichLinks' => 'HTMLText'
24
-    ];
25
-
26
-    /**
27
-     * @return string
28
-     */
29
-    public function RichLinks()
30
-    {
31
-        // Note:
32
-        // Assume we can use Regexes because the link will always be formatted
33
-        // in the same way coming from the CMS.
34
-
35
-        $content = $this->owner->value;
36
-
37
-        // Find all file links for processing.
38
-        preg_match_all('/<a.*href="\[file_link,id=([0-9]+)\].*".*>.*<\/a>/U', $content, $matches);
39
-
40
-        // Attach the file type and size to each of the links.
41
-        for ($i = 0; $i < count($matches[0]); $i++) {
42
-            $file = DataObject::get_by_id('File', $matches[1][$i]);
43
-            if ($file) {
44
-                $size = $file->getSize();
45
-                $ext = strtoupper($file->getExtension());
46
-                // Replace the closing </a> tag with the size span (and reattach the closing tag).
47
-                $newLink = substr($matches[0][$i], 0, strlen($matches[0][$i]) - 4)
48
-                    . "<span class='fileExt'> [$ext, $size]</span></a>";
49
-                $content = str_replace($matches[0][$i], $newLink, $content);
50
-            }
51
-        }
52
-
53
-        // Inject extra attributes into the external links.
54
-        $pattern = '/(<a.*)(href=\"https?:\/\/[^\"]*\"[^>]*>.*)(<\/a>)/iU';
55
-        $replacement = sprintf(
56
-            '$1class="external" rel="external" title="%s" $2<span class="nonvisual-indicator">(external link)</span>$3',
57
-            _t(__CLASS__ . '.OpenLinkTitle', 'Open external link')
58
-        );
59
-        $content = preg_replace($pattern, $replacement, $content, -1);
60
-
61
-        return $content;
62
-    }
19
+	/**
20
+	 * @var array
21
+	 */
22
+	private static $casting = [
23
+		'RichLinks' => 'HTMLText'
24
+	];
25
+
26
+	/**
27
+	 * @return string
28
+	 */
29
+	public function RichLinks()
30
+	{
31
+		// Note:
32
+		// Assume we can use Regexes because the link will always be formatted
33
+		// in the same way coming from the CMS.
34
+
35
+		$content = $this->owner->value;
36
+
37
+		// Find all file links for processing.
38
+		preg_match_all('/<a.*href="\[file_link,id=([0-9]+)\].*".*>.*<\/a>/U', $content, $matches);
39
+
40
+		// Attach the file type and size to each of the links.
41
+		for ($i = 0; $i < count($matches[0]); $i++) {
42
+			$file = DataObject::get_by_id('File', $matches[1][$i]);
43
+			if ($file) {
44
+				$size = $file->getSize();
45
+				$ext = strtoupper($file->getExtension());
46
+				// Replace the closing </a> tag with the size span (and reattach the closing tag).
47
+				$newLink = substr($matches[0][$i], 0, strlen($matches[0][$i]) - 4)
48
+					. "<span class='fileExt'> [$ext, $size]</span></a>";
49
+				$content = str_replace($matches[0][$i], $newLink, $content);
50
+			}
51
+		}
52
+
53
+		// Inject extra attributes into the external links.
54
+		$pattern = '/(<a.*)(href=\"https?:\/\/[^\"]*\"[^>]*>.*)(<\/a>)/iU';
55
+		$replacement = sprintf(
56
+			'$1class="external" rel="external" title="%s" $2<span class="nonvisual-indicator">(external link)</span>$3',
57
+			_t(__CLASS__ . '.OpenLinkTitle', 'Open external link')
58
+		);
59
+		$content = preg_replace($pattern, $replacement, $content, -1);
60
+
61
+		return $content;
62
+	}
63 63
 }
Please login to merge, or discard this patch.