Passed
Push — master ( 07940f...841329 )
by Nicolaas
03:51 queued 01:48
created
src/Api/DefaultDashboardProvider.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         $this->addFindPages();
33 33
         $this->addFilesAndImages();
34 34
         $this->addSiteConfigLinks();
35
-        if(Permission::check('ADMIN')) {
35
+        if (Permission::check('ADMIN')) {
36 36
             $this->addSecurityLinks();
37 37
         }
38 38
         $this->addModelAdminLinks();
@@ -55,16 +55,16 @@  discard block
 block discarded – undo
55 55
     protected function addPagesLinks()
56 56
     {
57 57
         $this->addGroup('PAGES', 'Pages', 10);
58
-        $this->addLink('PAGES', $this->phrase('add'). ' Page', '/admin/pages/add');
58
+        $this->addLink('PAGES', $this->phrase('add') . ' Page', '/admin/pages/add');
59 59
         $pagesCount = DataObject::get('Page')->count();
60
-        $this->addLink('PAGES', $this->phrase('edit'). ' Pages ('.$pagesCount.')', '/admin/pages');
60
+        $this->addLink('PAGES', $this->phrase('edit') . ' Pages (' . $pagesCount . ')', '/admin/pages');
61 61
         $pageLastEdited = DataObject::get_one('Page', '', true, 'LastEdited DESC');
62 62
         if ($pageLastEdited) {
63
-            $this->addLink('PAGES', '✎ Last Edited Page: '.$pageLastEdited->Title, $pageLastEdited->CMSEditLink());
63
+            $this->addLink('PAGES', '✎ Last Edited Page: ' . $pageLastEdited->Title, $pageLastEdited->CMSEditLink());
64 64
         }
65
-        $this->addLink('PAGES', $this->phrase('review'). ' Page Reports', '/admin/reports');
66
-        $lastWeekLink = '/admin/pages?'.'q[LastEditedFrom]='.date('Y-m-d', strtotime('-1 week'));
67
-        $this->addLink('PAGES', $this->phrase('review'). ' Recently Modified Pages', $lastWeekLink);
65
+        $this->addLink('PAGES', $this->phrase('review') . ' Page Reports', '/admin/reports');
66
+        $lastWeekLink = '/admin/pages?' . 'q[LastEditedFrom]=' . date('Y-m-d', strtotime('-1 week'));
67
+        $this->addLink('PAGES', $this->phrase('review') . ' Recently Modified Pages', $lastWeekLink);
68 68
     }
69 69
 
70 70
     protected function addFindPages()
@@ -72,29 +72,29 @@  discard block
 block discarded – undo
72 72
         $pages = [];
73 73
         $pagesToSkip = (array) $this->Config()->get('pages_to_skip');
74 74
         foreach (ClassInfo::subclassesFor(SiteTree::class, false) as $className) {
75
-            if(in_array($className, $pagesToSkip)) {
75
+            if (in_array($className, $pagesToSkip)) {
76 76
                 continue;
77 77
             }
78 78
             $pages[$className] = $className;
79 79
 
80 80
         }
81
-        $this->addGroup('PAGEFILTER', 'Page Types ('.count($pages).')', 300);
81
+        $this->addGroup('PAGEFILTER', 'Page Types (' . count($pages) . ')', 300);
82 82
         $count = 0;
83
-        foreach($pages as $pageClassName) {
83
+        foreach ($pages as $pageClassName) {
84 84
             $pageCount = $pageClassName::get()->filter(['ClassName' => $pageClassName])->count();
85
-            if($pageCount < 1) {
85
+            if ($pageCount < 1) {
86 86
                 continue;
87 87
             }
88 88
             $count++;
89
-            if($count > 7) {
89
+            if ($count > 7) {
90 90
                 $this->addLink('PAGEFILTER', 'More ...', '/admin/pages');
91 91
                 break;
92 92
             }
93 93
             $page = Injector::inst()->get($pageClassName);
94 94
             $pageTitle = $page->i18n_singular_name();
95
-            $query = 'q[ClassName]='.$pageClassName;
95
+            $query = 'q[ClassName]=' . $pageClassName;
96 96
             $link = 'admin/pages?' . $query;
97
-            $this->addLink('PAGEFILTER', $this->phrase('edit'). ' '.$pageTitle.' ('.$pageCount.')', $link);
97
+            $this->addLink('PAGEFILTER', $this->phrase('edit') . ' ' . $pageTitle . ' (' . $pageCount . ')', $link);
98 98
         }
99 99
     }
100 100
     protected function addFilesAndImages()
@@ -104,44 +104,44 @@  discard block
 block discarded – undo
104 104
         $uploadFolderName = Config::inst()->get(Upload::class, 'uploads_folder');
105 105
         $uploadFolder = Folder::find_or_make($uploadFolderName);
106 106
         // all
107
-        $this->addLink('FILESANDIMAGES', $this->phrase('edit'). ' Open File Browswer', '/admin/assets');
107
+        $this->addLink('FILESANDIMAGES', $this->phrase('edit') . ' Open File Browswer', '/admin/assets');
108 108
         // per type
109 109
         $filesCount = File::get()->exclude(['ClassName' => [Folder::class, Image::class]])->count();
110 110
         $imageCount = File::get()->filter(['ClassName' => [Image::class]])->count();
111
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Images ('.$imageCount.')', 'admin/assets?filter[appCategory]=IMAGE');
112
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Files ('.$filesCount.')', 'admin/assets?filter[appCategory]=DOCUMENT');
111
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Images (' . $imageCount . ')', 'admin/assets?filter[appCategory]=IMAGE');
112
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Files (' . $filesCount . ')', 'admin/assets?filter[appCategory]=DOCUMENT');
113 113
 
114 114
         // default upload folder
115
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Open Default Upload Folder', $uploadFolder->CMSEditLink());
115
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Open Default Upload Folder', $uploadFolder->CMSEditLink());
116 116
 
117 117
         // recent
118
-        $lastWeekLink = '/admin/assets?'.'filter[lastEditedFrom]='.date('Y-m-d', strtotime('-1 week')).'&view=tile';
119
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Recently modified Files', $lastWeekLink);
118
+        $lastWeekLink = '/admin/assets?' . 'filter[lastEditedFrom]=' . date('Y-m-d', strtotime('-1 week')) . '&view=tile';
119
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Recently modified Files', $lastWeekLink);
120 120
     }
121 121
 
122 122
     protected function addSiteConfigLinks()
123 123
     {
124 124
         $this->addGroup('SITECONFIG', 'Site Wide Configuration', 20);
125
-        $this->addLink('SITECONFIG', $this->phrase('review'). ' Site Settings', '/admin/settings');
125
+        $this->addLink('SITECONFIG', $this->phrase('review') . ' Site Settings', '/admin/settings');
126 126
     }
127 127
 
128 128
     protected function addSecurityLinks()
129 129
     {
130 130
         $this->addGroup('SECURITY', 'Security', 30);
131
-        $this->addLink('SECURITY', $this->phrase('add'). ' User', '/admin/security/users/EditForm/field/users/item/new');
131
+        $this->addLink('SECURITY', $this->phrase('add') . ' User', '/admin/security/users/EditForm/field/users/item/new');
132 132
         $userCount = Member::get()->count();
133 133
         $groupCount = Group::get()->count();
134
-        $this->addLink('SECURITY', $this->phrase('review'). ' Users ('.$userCount.')', '/admin/security');
135
-        $this->addLink('SECURITY', $this->phrase('review'). ' Groups  ('.$groupCount.')', '/admin/security/groups');
134
+        $this->addLink('SECURITY', $this->phrase('review') . ' Users (' . $userCount . ')', '/admin/security');
135
+        $this->addLink('SECURITY', $this->phrase('review') . ' Groups  (' . $groupCount . ')', '/admin/security/groups');
136 136
         DefaultAdminService::singleton()->extend('addSecurityLinks', $this);
137 137
         $adminGroup = Permission::get_groups_by_permission('ADMIN')->first();
138
-        if($adminGroup) {
138
+        if ($adminGroup) {
139 139
             $userCount = $adminGroup->Members()->count();
140
-            $this->addLink('SECURITY', $this->phrase('review'). ' Administrators ('.$userCount.')', '/admin/security/groups/EditForm/field/groups/item/'.$adminGroup->ID.'/edit');
140
+            $this->addLink('SECURITY', $this->phrase('review') . ' Administrators (' . $userCount . ')', '/admin/security/groups/EditForm/field/groups/item/' . $adminGroup->ID . '/edit');
141 141
         }
142
-        if(class_exists(EnabledMembers::class)) {
142
+        if (class_exists(EnabledMembers::class)) {
143 143
             $obj = Injector::inst()->get(EnabledMembers::class);
144
-            $this->addLink('SECURITY', $this->phrase('review'). ' Multi-Factor Authentication Status', $obj->getLink());
144
+            $this->addLink('SECURITY', $this->phrase('review') . ' Multi-Factor Authentication Status', $obj->getLink());
145 145
 
146 146
         }
147 147
     }
@@ -154,58 +154,58 @@  discard block
 block discarded – undo
154 154
         $modelAdmins = [];
155 155
         $skips = (array) $this->Config()->get('model_admins_to_skip');
156 156
         foreach (ClassInfo::subclassesFor(ModelAdmin::class, false) as $className) {
157
-            if(in_array($className, $skips)) {
157
+            if (in_array($className, $skips)) {
158 158
                 continue;
159 159
             }
160 160
             $modelAdmins[$className] = $className;
161 161
 
162 162
         }
163
-        foreach($modelAdmins as $modelAdminClassName) {
163
+        foreach ($modelAdmins as $modelAdminClassName) {
164 164
             $groupAdded = false;
165 165
             $ma = Injector::inst()->get($modelAdminClassName);
166
-            if($ma->canView()) {
166
+            if ($ma->canView()) {
167 167
                 $mas = $ma->getManagedModels();
168
-                if(count($mas)) {
168
+                if (count($mas)) {
169 169
                     $numberOfModels = count($mas);
170 170
                     $groupCode = strtoupper($modelAdminClassName);
171 171
                     $count = 0;
172
-                    foreach($mas as $model => $title) {
172
+                    foreach ($mas as $model => $title) {
173 173
                         $count++;
174
-                        if($count > 7) {
174
+                        if ($count > 7) {
175 175
                             $this->addLink('PAGEFILTER', 'More ...', $ma->Link());
176 176
                             break;
177 177
                         }
178
-                        if(is_array($title)) {
178
+                        if (is_array($title)) {
179 179
                             $title = $title['title'];
180 180
                             $model = $title['dataClass'] ?? $model;
181 181
                         }
182
-                        if(! class_exists($model)) {
182
+                        if (!class_exists($model)) {
183 183
                             continue;
184 184
                         }
185 185
                         $obj = Injector::inst()->get($model);
186
-                        if($obj && $obj->canView()) {
187
-                            if(! $groupAdded) {
186
+                        if ($obj && $obj->canView()) {
187
+                            if (!$groupAdded) {
188 188
                                 $this->addGroup($groupCode, $ma->menu_title(), 100);
189 189
                                 $groupAdded = true;
190 190
                             }
191 191
                             $link = '';
192
-                            if($obj->hasMethod('CMSListLink')) {
192
+                            if ($obj->hasMethod('CMSListLink')) {
193 193
                                 $link = $obj->CMSListLink();
194 194
                             } else {
195 195
                                 $link = $ma->getLinkForModelTab($model);
196 196
                             }
197 197
                             $objectCount = $model::get()->count();
198
-                            $titleContainsObjectCount = strpos($title, ' ('.$objectCount.')');
199
-                            if($titleContainsObjectCount === false) {
200
-                                $title .= ' ('.$objectCount.')';
198
+                            $titleContainsObjectCount = strpos($title, ' (' . $objectCount . ')');
199
+                            if ($titleContainsObjectCount === false) {
200
+                                $title .= ' (' . $objectCount . ')';
201 201
                             }
202
-                            $this->addLink($groupCode, $this->phrase('edit'). ' '.$title, $link);
203
-                            if($numberOfModels < 4) {
202
+                            $this->addLink($groupCode, $this->phrase('edit') . ' ' . $title, $link);
203
+                            if ($numberOfModels < 4) {
204 204
                                 $obj = Injector::inst()->get($model);
205
-                                if($obj->canCreate()) {
205
+                                if ($obj->canCreate()) {
206 206
                                     $classNameEscaped = str_replace('\\', '-', $model);
207
-                                    $linkNew = $link .= '/EditForm/field/'.$classNameEscaped.'/item/new';
208
-                                    $this->addLink($groupCode, $this->phrase('add'). ' '.$obj->i18n_singular_name(), $linkNew);
207
+                                    $linkNew = $link .= '/EditForm/field/' . $classNameEscaped . '/item/new';
208
+                                    $this->addLink($groupCode, $this->phrase('add') . ' ' . $obj->i18n_singular_name(), $linkNew);
209 209
                                 }
210 210
                             }
211 211
                         }
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
 
245 245
     protected function phrase(string $phrase): string
246 246
     {
247
-        if($phrase === 'add') {
247
+        if ($phrase === 'add') {
248 248
             $phrase = $this->config()->get('new_phrase');
249
-        } elseif($phrase === 'review') {
249
+        } elseif ($phrase === 'review') {
250 250
             $phrase = $this->config()->get('review_phrase');
251
-        } elseif($phrase === 'edit') {
251
+        } elseif ($phrase === 'edit') {
252 252
             $phrase = $this->config()->get('edit_phrase');
253 253
         }
254
-        return _t('DashboardWelcomeQuicklinks.'.$phrase, $phrase);
254
+        return _t('DashboardWelcomeQuicklinks.' . $phrase, $phrase);
255 255
     }
256 256
 
257 257
 }
Please login to merge, or discard this patch.