Passed
Push — master ( bc462e...cf9ff7 )
by Nicolaas
02:17
created
src/Api/DefaultDashboardProvider.php 1 patch
Spacing   +50 added lines, -50 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();
@@ -48,16 +48,16 @@  discard block
 block discarded – undo
48 48
     protected function addPagesLinks()
49 49
     {
50 50
         $this->addGroup('PAGES', 'Pages', 10);
51
-        $this->addLink('PAGES', $this->phrase('add'). ' Page', '/admin/pages/add');
51
+        $this->addLink('PAGES', $this->phrase('add') . ' Page', '/admin/pages/add');
52 52
         $pagesCount = DataObject::get('Page')->count();
53
-        $this->addLink('PAGES', $this->phrase('edit'). ' Pages ('.$pagesCount.')', '/admin/pages');
53
+        $this->addLink('PAGES', $this->phrase('edit') . ' Pages (' . $pagesCount . ')', '/admin/pages');
54 54
         $pageLastEdited = DataObject::get_one('Page', '', true, 'LastEdited DESC');
55 55
         if ($pageLastEdited) {
56
-            $this->addLink('PAGES', '✎ Last Edited Page: '.$pageLastEdited->Title, $pageLastEdited->CMSEditLink());
56
+            $this->addLink('PAGES', '✎ Last Edited Page: ' . $pageLastEdited->Title, $pageLastEdited->CMSEditLink());
57 57
         }
58
-        $this->addLink('PAGES', $this->phrase('review'). ' Page Reports', '/admin/reports');
59
-        $lastWeekLink = '/admin/pages?'.'q[LastEditedFrom]='.date('Y-m-d', strtotime('-1 week'));
60
-        $this->addLink('PAGES', $this->phrase('review'). ' Recently Modified Pages', $lastWeekLink);
58
+        $this->addLink('PAGES', $this->phrase('review') . ' Page Reports', '/admin/reports');
59
+        $lastWeekLink = '/admin/pages?' . 'q[LastEditedFrom]=' . date('Y-m-d', strtotime('-1 week'));
60
+        $this->addLink('PAGES', $this->phrase('review') . ' Recently Modified Pages', $lastWeekLink);
61 61
     }
62 62
 
63 63
     protected function addFindPages()
@@ -67,22 +67,22 @@  discard block
 block discarded – undo
67 67
             $pages[$className] = $className;
68 68
 
69 69
         }
70
-        $this->addGroup('PAGEFILTER', 'Page Types ('.count($pages).')', 300);
70
+        $this->addGroup('PAGEFILTER', 'Page Types (' . count($pages) . ')', 300);
71 71
         $count = 0;
72
-        foreach($pages as $pageClassName) {
72
+        foreach ($pages as $pageClassName) {
73 73
             $pageCount = $pageClassName::get()->count();
74
-            if($pageCount < 1) {
74
+            if ($pageCount < 1) {
75 75
                 continue;
76 76
             }
77 77
             $count++;
78
-            if($count > 12) {
78
+            if ($count > 12) {
79 79
                 break;
80 80
             }
81 81
             $page = Injector::inst()->get($pageClassName);
82 82
             $pageTitle = $page->i18n_singular_name();
83
-            $query = urlencode('q[ClassName]='.$pageClassName);
83
+            $query = urlencode('q[ClassName]=' . $pageClassName);
84 84
             $link = 'admin/pages?' . $query;
85
-            $this->addLink('PAGEFILTER', $this->phrase('edit'). ' '.$pageTitle.' ('.$pageCount.')', $link);
85
+            $this->addLink('PAGEFILTER', $this->phrase('edit') . ' ' . $pageTitle . ' (' . $pageCount . ')', $link);
86 86
         }
87 87
     }
88 88
     protected function addFilesAndImages()
@@ -92,44 +92,44 @@  discard block
 block discarded – undo
92 92
         $uploadFolderName = Config::inst()->get(Upload::class, 'uploads_folder');
93 93
         $uploadFolder = Folder::find_or_make($uploadFolderName);
94 94
         // all
95
-        $this->addLink('FILESANDIMAGES', $this->phrase('edit'). ' Open File Browswer', '/admin/assets');
95
+        $this->addLink('FILESANDIMAGES', $this->phrase('edit') . ' Open File Browswer', '/admin/assets');
96 96
         // per type
97 97
         $filesCount = File::get()->exclude(['ClassName' => [Folder::class, Image::class]])->count();
98 98
         $imageCount = File::get()->filter(['ClassName' => [Image::class]])->count();
99
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Images ('.$imageCount.')', 'admin/assets?filter[appCategory]=IMAGE');
100
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Files ('.$filesCount.')', 'admin/assets?filter[appCategory]=DOCUMENT');
99
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Images (' . $imageCount . ')', 'admin/assets?filter[appCategory]=IMAGE');
100
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Files (' . $filesCount . ')', 'admin/assets?filter[appCategory]=DOCUMENT');
101 101
 
102 102
         // default upload folder
103
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Open Default Upload Folder', $uploadFolder->CMSEditLink());
103
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Open Default Upload Folder', $uploadFolder->CMSEditLink());
104 104
 
105 105
         // recent
106
-        $lastWeekLink = '/admin/assets?'.'filter[lastEditedFrom]='.date('Y-m-d', strtotime('-1 week')).'&view=tile';
107
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Recently modified Files', $lastWeekLink);
106
+        $lastWeekLink = '/admin/assets?' . 'filter[lastEditedFrom]=' . date('Y-m-d', strtotime('-1 week')) . '&view=tile';
107
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Recently modified Files', $lastWeekLink);
108 108
     }
109 109
 
110 110
     protected function addSiteConfigLinks()
111 111
     {
112 112
         $this->addGroup('SITECONFIG', 'Site Wide Configuration', 20);
113
-        $this->addLink('SITECONFIG', $this->phrase('review'). ' Site Settings', '/admin/settings');
113
+        $this->addLink('SITECONFIG', $this->phrase('review') . ' Site Settings', '/admin/settings');
114 114
     }
115 115
 
116 116
     protected function addSecurityLinks()
117 117
     {
118 118
         $this->addGroup('SECURITY', 'Security', 30);
119
-        $this->addLink('SECURITY', $this->phrase('add'). ' User', '/admin/security/users/EditForm/field/users/item/new');
119
+        $this->addLink('SECURITY', $this->phrase('add') . ' User', '/admin/security/users/EditForm/field/users/item/new');
120 120
         $userCount = Member::get()->count();
121 121
         $groupCount = Group::get()->count();
122
-        $this->addLink('SECURITY', $this->phrase('review'). ' Users ('.$userCount.')', '/admin/security');
123
-        $this->addLink('SECURITY', $this->phrase('review'). ' Groups  ('.$groupCount.')', '/admin/security/groups');
122
+        $this->addLink('SECURITY', $this->phrase('review') . ' Users (' . $userCount . ')', '/admin/security');
123
+        $this->addLink('SECURITY', $this->phrase('review') . ' Groups  (' . $groupCount . ')', '/admin/security/groups');
124 124
         DefaultAdminService::singleton()->extend('addSecurityLinks', $this);
125 125
         $adminGroup = Permission::get_groups_by_permission('ADMIN')->first();
126
-        if($adminGroup) {
126
+        if ($adminGroup) {
127 127
             $userCount = $adminGroup->Members()->count();
128
-            $this->addLink('SECURITY', $this->phrase('review'). ' Administrators ('.$userCount.')', '/admin/security/groups/EditForm/field/groups/item/'.$adminGroup->ID.'/edit');
128
+            $this->addLink('SECURITY', $this->phrase('review') . ' Administrators (' . $userCount . ')', '/admin/security/groups/EditForm/field/groups/item/' . $adminGroup->ID . '/edit');
129 129
         }
130
-        if(class_exists(EnabledMembers::class)) {
130
+        if (class_exists(EnabledMembers::class)) {
131 131
             $obj = Injector::inst()->get(EnabledMembers::class);
132
-            $this->addLink('SECURITY', $this->phrase('review'). ' Multi-Factor Authentication Status', $obj->getLink());
132
+            $this->addLink('SECURITY', $this->phrase('review') . ' Multi-Factor Authentication Status', $obj->getLink());
133 133
 
134 134
         }
135 135
     }
@@ -141,57 +141,57 @@  discard block
 block discarded – undo
141 141
     {
142 142
         $modelAdmins = [];
143 143
         foreach (ClassInfo::subclassesFor(ModelAdmin::class, false) as $className) {
144
-            if($className === ArchiveAdmin::class) {
144
+            if ($className === ArchiveAdmin::class) {
145 145
                 continue;
146 146
             }
147 147
             $modelAdmins[$className] = $className;
148 148
 
149 149
         }
150
-        foreach($modelAdmins as $modelAdminClassName) {
150
+        foreach ($modelAdmins as $modelAdminClassName) {
151 151
             $groupAdded = false;
152 152
             $ma = Injector::inst()->get($modelAdminClassName);
153
-            if($ma->canView()) {
153
+            if ($ma->canView()) {
154 154
                 $mas = $ma->getManagedModels();
155
-                if(count($mas)) {
155
+                if (count($mas)) {
156 156
                     $numberOfModels = count($mas);
157 157
                     $groupCode = strtoupper($modelAdminClassName);
158 158
                     $count = 0;
159
-                    foreach($mas as $model => $title) {
159
+                    foreach ($mas as $model => $title) {
160 160
                         $count++;
161
-                        if($count > 7) {
161
+                        if ($count > 7) {
162 162
                             break;
163 163
                         }
164
-                        if(is_array($title)) {
164
+                        if (is_array($title)) {
165 165
                             $title = $title['title'];
166 166
                             $model = $title['dataClass'] ?? $model;
167 167
                         }
168
-                        if(! class_exists($model)) {
168
+                        if (!class_exists($model)) {
169 169
                             continue;
170 170
                         }
171 171
                         $obj = Injector::inst()->get($model);
172
-                        if($obj && $obj->canView()) {
173
-                            if(! $groupAdded) {
172
+                        if ($obj && $obj->canView()) {
173
+                            if (!$groupAdded) {
174 174
                                 $this->addGroup($groupCode, $ma->menu_title(), 100);
175 175
                                 $groupAdded = true;
176 176
                             }
177 177
                             $link = '';
178
-                            if($obj->hasMethod('CMSListLink')) {
178
+                            if ($obj->hasMethod('CMSListLink')) {
179 179
                                 $link = $obj->CMSListLink();
180 180
                             } else {
181 181
                                 $link = $ma->getLinkForModelTab($model);
182 182
                             }
183 183
                             $objectCount = $model::get()->count();
184
-                            $titleContainsObjectCount = strpos($title, ' ('.$objectCount.')');
185
-                            if($titleContainsObjectCount === false) {
186
-                                $title .= ' ('.$objectCount.')';
184
+                            $titleContainsObjectCount = strpos($title, ' (' . $objectCount . ')');
185
+                            if ($titleContainsObjectCount === false) {
186
+                                $title .= ' (' . $objectCount . ')';
187 187
                             }
188
-                            $this->addLink($groupCode, $this->phrase('edit'). ' '.$title, $link);
189
-                            if($numberOfModels < 4) {
188
+                            $this->addLink($groupCode, $this->phrase('edit') . ' ' . $title, $link);
189
+                            if ($numberOfModels < 4) {
190 190
                                 $obj = Injector::inst()->get($model);
191
-                                if($obj->canCreate()) {
191
+                                if ($obj->canCreate()) {
192 192
                                     $classNameEscaped = str_replace('\\', '-', $model);
193
-                                    $linkNew = $link .= '/EditForm/field/'.$classNameEscaped.'/item/new';
194
-                                    $this->addLink($groupCode, $this->phrase('add'). ' '.$obj->i18n_singular_name(), $linkNew);
193
+                                    $linkNew = $link .= '/EditForm/field/' . $classNameEscaped . '/item/new';
194
+                                    $this->addLink($groupCode, $this->phrase('add') . ' ' . $obj->i18n_singular_name(), $linkNew);
195 195
                                 }
196 196
                             }
197 197
                         }
@@ -230,14 +230,14 @@  discard block
 block discarded – undo
230 230
 
231 231
     protected function phrase(string $phrase): string
232 232
     {
233
-        if($phrase === 'add') {
233
+        if ($phrase === 'add') {
234 234
             $phrase = $this->config()->get('new_phrase');
235
-        } elseif($phrase === 'review') {
235
+        } elseif ($phrase === 'review') {
236 236
             $phrase = $this->config()->get('review_phrase');
237
-        } elseif($phrase === 'edit') {
237
+        } elseif ($phrase === 'edit') {
238 238
             $phrase = $this->config()->get('edit_phrase');
239 239
         }
240
-        return _t('DashboardWelcomeQuicklinks.'.$phrase, $phrase);
240
+        return _t('DashboardWelcomeQuicklinks.' . $phrase, $phrase);
241 241
     }
242 242
 
243 243
 }
Please login to merge, or discard this patch.