Passed
Push — master ( 099597...b54a3e )
by Nicolaas
03:01
created
src/Api/DefaultDashboardProvider.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $this->addFindPages();
35 35
         $this->addFilesAndImages();
36 36
         $this->addSiteConfigLinks();
37
-        if(Permission::check('ADMIN')) {
37
+        if (Permission::check('ADMIN')) {
38 38
             $this->addSecurityLinks();
39 39
         }
40 40
         $this->addModelAdminLinks();
@@ -57,20 +57,20 @@  discard block
 block discarded – undo
57 57
     protected function addPagesLinks()
58 58
     {
59 59
         $this->addGroup('PAGES', 'Pages', 10);
60
-        $this->addLink('PAGES', $this->phrase('add'). ' Page', '/admin/pages/add');
60
+        $this->addLink('PAGES', $this->phrase('add') . ' Page', '/admin/pages/add');
61 61
         $pagesCount = DataObject::get('Page')->count();
62 62
         $draftCount = CMSSiteTreeFilter_StatusDraftPages::create()->getFilteredPages()->count();
63 63
         $revisedCount = CMSSiteTreeFilter_ChangedPages::create()->getFilteredPages()->count();
64
-        $this->addLink('PAGES', $this->phrase('edit'). ' Pages ('.$pagesCount.')', '/admin/pages');
65
-        $this->addLink('PAGES', $this->phrase('edit'). ' Unpublished Drafts ('.$draftCount.')', '/admin/pages?q[FilterClass]=SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusDraftPages');
66
-        $this->addLink('PAGES', $this->phrase('edit'). ' Unpublished Changes ('.$revisedCount.')', '/admin/pages?q[FilterClass]=SilverStripe\CMS\Controllers\CMSSiteTreeFilter_ChangedPages');
64
+        $this->addLink('PAGES', $this->phrase('edit') . ' Pages (' . $pagesCount . ')', '/admin/pages');
65
+        $this->addLink('PAGES', $this->phrase('edit') . ' Unpublished Drafts (' . $draftCount . ')', '/admin/pages?q[FilterClass]=SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusDraftPages');
66
+        $this->addLink('PAGES', $this->phrase('edit') . ' Unpublished Changes (' . $revisedCount . ')', '/admin/pages?q[FilterClass]=SilverStripe\CMS\Controllers\CMSSiteTreeFilter_ChangedPages');
67 67
         $pageLastEdited = DataObject::get_one('Page', '', true, 'LastEdited DESC');
68 68
         if ($pageLastEdited) {
69
-            $this->addLink('PAGES', '✎ Last Edited Page: '.$pageLastEdited->Title, $pageLastEdited->CMSEditLink());
69
+            $this->addLink('PAGES', '✎ Last Edited Page: ' . $pageLastEdited->Title, $pageLastEdited->CMSEditLink());
70 70
         }
71
-        $lastWeekLink = '/admin/pages?'.'q[LastEditedFrom]='.date('Y-m-d', strtotime('-1 week'));
72
-        $this->addLink('PAGES', $this->phrase('review'). ' Recently Modified Pages', $lastWeekLink);
73
-        $this->addLink('PAGES', $this->phrase('review'). ' Page Reports', '/admin/reports');
71
+        $lastWeekLink = '/admin/pages?' . 'q[LastEditedFrom]=' . date('Y-m-d', strtotime('-1 week'));
72
+        $this->addLink('PAGES', $this->phrase('review') . ' Recently Modified Pages', $lastWeekLink);
73
+        $this->addLink('PAGES', $this->phrase('review') . ' Page Reports', '/admin/reports');
74 74
     }
75 75
 
76 76
     protected function addFindPages()
@@ -78,30 +78,30 @@  discard block
 block discarded – undo
78 78
         $pages = [];
79 79
         $pagesToSkip = (array) $this->Config()->get('pages_to_skip');
80 80
         foreach (ClassInfo::subclassesFor(SiteTree::class, false) as $className) {
81
-            if(in_array($className, $pagesToSkip)) {
81
+            if (in_array($className, $pagesToSkip)) {
82 82
                 continue;
83 83
             }
84 84
             $pages[$className] = $className;
85 85
 
86 86
         }
87
-        $this->addGroup('PAGEFILTER', 'Page Types ('.count($pages).')', 300);
87
+        $this->addGroup('PAGEFILTER', 'Page Types (' . count($pages) . ')', 300);
88 88
         $count = 0;
89
-        foreach($pages as $pageClassName) {
89
+        foreach ($pages as $pageClassName) {
90 90
             $pageCount = $pageClassName::get()->filter(['ClassName' => $pageClassName])->count();
91
-            if($pageCount < 1) {
91
+            if ($pageCount < 1) {
92 92
                 continue;
93 93
             }
94 94
             $count++;
95
-            if($pageCount === 1) {
95
+            if ($pageCount === 1) {
96 96
                 $obj = DataObject::get_one($pageClassName, ['ClassName' => $pageClassName]);
97
-                $this->addLink('PAGEFILTER', $this->phrase('edit'). ' '.$pageClassName::singleton()->i18n_singular_name(), $obj->CMSEditLink());
97
+                $this->addLink('PAGEFILTER', $this->phrase('edit') . ' ' . $pageClassName::singleton()->i18n_singular_name(), $obj->CMSEditLink());
98 98
                 continue;
99 99
             }
100 100
             $page = Injector::inst()->get($pageClassName);
101 101
             $pageTitle = $page->i18n_singular_name();
102
-            $query = 'q[ClassName]='.$pageClassName;
102
+            $query = 'q[ClassName]=' . $pageClassName;
103 103
             $link = 'admin/pages?' . $query;
104
-            $this->addLink('PAGEFILTER', $this->phrase('edit'). ' '.$pageTitle.' ('.$pageCount.')', $link);
104
+            $this->addLink('PAGEFILTER', $this->phrase('edit') . ' ' . $pageTitle . ' (' . $pageCount . ')', $link);
105 105
         }
106 106
     }
107 107
     protected function addFilesAndImages()
@@ -111,44 +111,44 @@  discard block
 block discarded – undo
111 111
         $uploadFolderName = Config::inst()->get(Upload::class, 'uploads_folder');
112 112
         $uploadFolder = Folder::find_or_make($uploadFolderName);
113 113
         // all
114
-        $this->addLink('FILESANDIMAGES', $this->phrase('edit'). ' Open File Browswer', '/admin/assets');
114
+        $this->addLink('FILESANDIMAGES', $this->phrase('edit') . ' Open File Browswer', '/admin/assets');
115 115
         // per type
116 116
         $filesCount = File::get()->exclude(['ClassName' => [Folder::class, Image::class]])->count();
117 117
         $imageCount = File::get()->filter(['ClassName' => [Image::class]])->count();
118
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Images ('.$imageCount.')', 'admin/assets?filter[appCategory]=IMAGE');
119
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Files ('.$filesCount.')', 'admin/assets?filter[appCategory]=DOCUMENT');
118
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Images (' . $imageCount . ')', 'admin/assets?filter[appCategory]=IMAGE');
119
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Files (' . $filesCount . ')', 'admin/assets?filter[appCategory]=DOCUMENT');
120 120
 
121 121
         // default upload folder
122
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Open Default Upload Folder', $uploadFolder->CMSEditLink());
122
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Open Default Upload Folder', $uploadFolder->CMSEditLink());
123 123
 
124 124
         // recent
125
-        $lastWeekLink = '/admin/assets?'.'filter[lastEditedFrom]='.date('Y-m-d', strtotime('-1 week')).'&view=tile';
126
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Recently modified Files', $lastWeekLink);
125
+        $lastWeekLink = '/admin/assets?' . 'filter[lastEditedFrom]=' . date('Y-m-d', strtotime('-1 week')) . '&view=tile';
126
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Recently modified Files', $lastWeekLink);
127 127
     }
128 128
 
129 129
     protected function addSiteConfigLinks()
130 130
     {
131 131
         $this->addGroup('SITECONFIG', 'Site Wide Configuration', 20);
132
-        $this->addLink('SITECONFIG', $this->phrase('review'). ' Site Settings', '/admin/settings');
132
+        $this->addLink('SITECONFIG', $this->phrase('review') . ' Site Settings', '/admin/settings');
133 133
     }
134 134
 
135 135
     protected function addSecurityLinks()
136 136
     {
137 137
         $this->addGroup('SECURITY', 'Security', 30);
138
-        $this->addLink('SECURITY', $this->phrase('add'). ' User', '/admin/security/users/EditForm/field/users/item/new');
138
+        $this->addLink('SECURITY', $this->phrase('add') . ' User', '/admin/security/users/EditForm/field/users/item/new');
139 139
         $userCount = Member::get()->count();
140 140
         $groupCount = Group::get()->count();
141
-        $this->addLink('SECURITY', $this->phrase('review'). ' Users ('.$userCount.')', '/admin/security');
142
-        $this->addLink('SECURITY', $this->phrase('review'). ' Groups  ('.$groupCount.')', '/admin/security/groups');
141
+        $this->addLink('SECURITY', $this->phrase('review') . ' Users (' . $userCount . ')', '/admin/security');
142
+        $this->addLink('SECURITY', $this->phrase('review') . ' Groups  (' . $groupCount . ')', '/admin/security/groups');
143 143
         DefaultAdminService::singleton()->extend('addSecurityLinks', $this);
144 144
         $adminGroup = Permission::get_groups_by_permission('ADMIN')->first();
145
-        if($adminGroup) {
145
+        if ($adminGroup) {
146 146
             $userCount = $adminGroup->Members()->count();
147
-            $this->addLink('SECURITY', $this->phrase('review'). ' Administrators ('.$userCount.')', '/admin/security/groups/EditForm/field/groups/item/'.$adminGroup->ID.'/edit');
147
+            $this->addLink('SECURITY', $this->phrase('review') . ' Administrators (' . $userCount . ')', '/admin/security/groups/EditForm/field/groups/item/' . $adminGroup->ID . '/edit');
148 148
         }
149
-        if(class_exists(EnabledMembers::class)) {
149
+        if (class_exists(EnabledMembers::class)) {
150 150
             $obj = Injector::inst()->get(EnabledMembers::class);
151
-            $this->addLink('SECURITY', $this->phrase('review'). ' Multi-Factor Authentication Status', $obj->getLink());
151
+            $this->addLink('SECURITY', $this->phrase('review') . ' Multi-Factor Authentication Status', $obj->getLink());
152 152
 
153 153
         }
154 154
     }
@@ -161,63 +161,63 @@  discard block
 block discarded – undo
161 161
         $modelAdmins = [];
162 162
         $skips = (array) $this->Config()->get('model_admins_to_skip');
163 163
         foreach (ClassInfo::subclassesFor(ModelAdmin::class, false) as $className) {
164
-            if(in_array($className, $skips)) {
164
+            if (in_array($className, $skips)) {
165 165
                 continue;
166 166
             }
167 167
             $modelAdmins[$className] = $className;
168 168
 
169 169
         }
170
-        foreach($modelAdmins as $modelAdminClassName) {
170
+        foreach ($modelAdmins as $modelAdminClassName) {
171 171
             $groupAdded = false;
172 172
             $ma = Injector::inst()->get($modelAdminClassName);
173
-            if($ma->canView()) {
173
+            if ($ma->canView()) {
174 174
                 $mas = $ma->getManagedModels();
175
-                if(count($mas)) {
175
+                if (count($mas)) {
176 176
                     $numberOfModels = count($mas);
177 177
                     $groupCode = strtoupper($modelAdminClassName);
178 178
                     $count = 0;
179
-                    foreach($mas as $model => $title) {
179
+                    foreach ($mas as $model => $title) {
180 180
                         $count++;
181
-                        if(is_array($title)) {
181
+                        if (is_array($title)) {
182 182
                             $title = $title['title'];
183 183
                             $model = $title['dataClass'] ?? $model;
184 184
                         }
185
-                        if(! class_exists($model)) {
185
+                        if (!class_exists($model)) {
186 186
                             continue;
187 187
                         }
188 188
                         $obj = Injector::inst()->get($model);
189
-                        if($obj && $obj->canView()) {
190
-                            if(! $groupAdded) {
189
+                        if ($obj && $obj->canView()) {
190
+                            if (!$groupAdded) {
191 191
                                 $this->addGroup($groupCode, $ma->menu_title(), 100);
192 192
                                 $groupAdded = true;
193 193
                             }
194 194
                             // $classNameList = ClassInfo::subclassesFor($model);
195 195
                             $objectCount = $model::get()->count();
196
-                            if($objectCount === 1) {
196
+                            if ($objectCount === 1) {
197 197
                                 $obj = DataObject::get_one($model, ['ClassName' => $model]);
198
-                                if($obj->hasMethod('CMSEditLink')) {
199
-                                    $this->addLink('PAGEFILTER', $this->phrase('edit'). ' '.$model::singleton()->i18n_singular_name(), $obj->CMSEditLink());
198
+                                if ($obj->hasMethod('CMSEditLink')) {
199
+                                    $this->addLink('PAGEFILTER', $this->phrase('edit') . ' ' . $model::singleton()->i18n_singular_name(), $obj->CMSEditLink());
200 200
                                     continue;
201 201
                                 }
202 202
                             }
203 203
 
204 204
                             $link = '';
205
-                            if($obj->hasMethod('CMSListLink')) {
205
+                            if ($obj->hasMethod('CMSListLink')) {
206 206
                                 $link = $obj->CMSListLink();
207
-                            } if(! $link) {
207
+                            } if (!$link) {
208 208
                                 $link = $ma->getLinkForModelTab($model);
209 209
                             }
210
-                            $titleContainsObjectCount = strpos($title, ' ('.$objectCount.')');
211
-                            if($titleContainsObjectCount === false) {
212
-                                $title .= ' ('.$objectCount.')';
210
+                            $titleContainsObjectCount = strpos($title, ' (' . $objectCount . ')');
211
+                            if ($titleContainsObjectCount === false) {
212
+                                $title .= ' (' . $objectCount . ')';
213 213
                             }
214
-                            $this->addLink($groupCode, $this->phrase('edit'). ' '.$title, $link);
215
-                            if($numberOfModels < 4) {
214
+                            $this->addLink($groupCode, $this->phrase('edit') . ' ' . $title, $link);
215
+                            if ($numberOfModels < 4) {
216 216
                                 $obj = Injector::inst()->get($model);
217
-                                if($obj->canCreate()) {
217
+                                if ($obj->canCreate()) {
218 218
                                     $classNameEscaped = str_replace('\\', '-', $model);
219
-                                    $linkNew = $link .= '/EditForm/field/'.$classNameEscaped.'/item/new';
220
-                                    $this->addLink($groupCode, $this->phrase('add'). ' '.$obj->i18n_singular_name(), $linkNew);
219
+                                    $linkNew = $link .= '/EditForm/field/' . $classNameEscaped . '/item/new';
220
+                                    $this->addLink($groupCode, $this->phrase('add') . ' ' . $obj->i18n_singular_name(), $linkNew);
221 221
                                 }
222 222
                             }
223 223
                         }
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
 
257 257
     protected function phrase(string $phrase): string
258 258
     {
259
-        $phrase = $this->config()->get($phrase .'_phrase');
260
-        return _t('DashboardWelcomeQuicklinks.'.$phrase, $phrase);
259
+        $phrase = $this->config()->get($phrase . '_phrase');
260
+        return _t('DashboardWelcomeQuicklinks.' . $phrase, $phrase);
261 261
     }
262 262
 
263 263
 }
Please login to merge, or discard this patch.
src/Admin/DashboardWelcomeQuickLinks.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 
138 138
             usort(
139 139
                 $shortcuts,
140
-                function ($a, $b) {
140
+                function($a, $b) {
141 141
                     ($a['SortOrder'] ?? 0) <=> ($b['SortOrder'] ?? 0);
142 142
                 }
143 143
             );
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
                         $entry['IconClass'] ?? '',
179 179
                         $entry['Target'] ?? '',
180 180
                     )->Field();
181
-                    if($count > $max && count($items) == $count + 1) {
181
+                    if ($count > $max && count($items) == $count + 1) {
182 182
                         $html .= $this->makeShortCut(
183 183
                             $this->Config()->get('more_phrase'),
184 184
                             '#', // link
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
             }
193 193
         }
194 194
         $kc = (array) $this->Config()->get('colour_options');
195
-        if(empty($kc)) {
195
+        if (empty($kc)) {
196 196
             $kc = $this->Config()->get('default_colour_options');
197 197
         }
198 198
         $kcCount = count($kc);
199 199
         $colours = '';
200 200
         foreach ($kc as $key => $colour) {
201
-            $colours .= ' .grid-wrapper .grid-cell:nth-child(' . $kcCount . 'n+' . ($key + 1) . ') div.header {background-color: ' . $colour . '; color: '.$this->getFontColor($colour).'!important;}';
201
+            $colours .= ' .grid-wrapper .grid-cell:nth-child(' . $kcCount . 'n+' . ($key + 1) . ') div.header {background-color: ' . $colour . '; color: ' . $this->getFontColor($colour) . '!important;}';
202 202
         }
203 203
         $html .= '</div>';
204 204
         $html .= '<script>window.setTimeout(dashboardWelcomeQuickLinksSetupInputAndFilter, 500)</script>';
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         $useDefaultDashboard = (bool) $this->config()->get('use_default_dashboard_provider');
213 213
         $classNames = ClassInfo::implementorsOf(DashboardWelcomeQuickLinksProvider::class);
214 214
         foreach ($classNames as $className) {
215
-            if($useDefaultDashboard === false && (string) $className === DefaultDashboardProvider::class) {
215
+            if ($useDefaultDashboard === false && (string) $className === DefaultDashboardProvider::class) {
216 216
                 continue;
217 217
             }
218 218
             $array += Injector::inst()->get($className)->provideDashboardWelcomeQuickLinks();
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
         if (!empty($iconClass)) {
235 235
             $icon = '<i class="' . $iconClass . '"></i> ';
236 236
         }
237
-        if(!$target) {
237
+        if (!$target) {
238 238
             $target = '_self';
239 239
         }
240
-        $target = ' target="'.$target.'"';
240
+        $target = ' target="' . $target . '"';
241 241
         if ($link) {
242 242
             $html = '
243 243
             ' . $script . '
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
     {
266 266
         $app = $this->getApplicationName();
267 267
         $siteConfigTitle = SiteConfig::current_site_config()->Title;
268
-        if($siteConfigTitle) {
269
-            $app = $siteConfigTitle . ' ('.$app.')';
268
+        if ($siteConfigTitle) {
269
+            $app = $siteConfigTitle . ' (' . $app . ')';
270 270
         }
271 271
         return ($section = $this->SectionTitle()) ? sprintf('%s for %s', $section, $app) : $app;
272 272
     }
Please login to merge, or discard this patch.