Passed
Push — master ( c199aa...07940f )
by Nicolaas
02:09
created
src/Admin/DashboardWelcomeQuickLinks.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
             usort(
54 54
                 $shortcuts,
55
-                function ($a, $b) {
55
+                function($a, $b) {
56 56
                     ($a['SortOrder'] ?? 0) <=> ($b['SortOrder'] ?? 0);
57 57
                 }
58 58
             );
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         $useDefaultDashboard = $this->config()->get('use_default_dashboard');
132 132
         $classNames = ClassInfo::implementorsOf(DashboardWelcomeQuickLinksProvider::class);
133 133
         foreach ($classNames as $className) {
134
-            if($useDefaultDashboard === false && $className === DefaultDashboardProvider::class) {
134
+            if ($useDefaultDashboard === false && $className === DefaultDashboardProvider::class) {
135 135
                 continue;
136 136
             }
137 137
             $array += Injector::inst()->get($className)->provideDashboardWelcomeQuickLinks();
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
         if (!empty($iconClass)) {
154 154
             $icon = '<i class="' . $iconClass . '"></i> ';
155 155
         }
156
-        if(!$target) {
156
+        if (!$target) {
157 157
             $target = '_self';
158 158
         }
159
-        $target = ' target="'.$target.'"';
159
+        $target = ' target="' . $target . '"';
160 160
         if ($link) {
161 161
             $html = '
162 162
             ' . $script . '
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
     {
188 188
         $app = $this->getApplicationName();
189 189
         $siteConfigTitle = SiteConfig::current_site_config()->Title;
190
-        if($siteConfigTitle) {
191
-            $app = $siteConfigTitle . ' ('.$app.')';
190
+        if ($siteConfigTitle) {
191
+            $app = $siteConfigTitle . ' (' . $app . ')';
192 192
         }
193 193
         return ($section = $this->SectionTitle()) ? sprintf('%s for %s', $section, $app) : $app;
194 194
     }
Please login to merge, or discard this patch.
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();
@@ -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()
@@ -74,23 +74,23 @@  discard block
 block discarded – undo
74 74
             $pages[$className] = $className;
75 75
 
76 76
         }
77
-        $this->addGroup('PAGEFILTER', 'Page Types ('.count($pages).')', 300);
77
+        $this->addGroup('PAGEFILTER', 'Page Types (' . count($pages) . ')', 300);
78 78
         $count = 0;
79
-        foreach($pages as $pageClassName) {
79
+        foreach ($pages as $pageClassName) {
80 80
             $pageCount = $pageClassName::get()->filter(['ClassName' => $pageClassName])->count();
81
-            if($pageCount < 1) {
81
+            if ($pageCount < 1) {
82 82
                 continue;
83 83
             }
84 84
             $count++;
85
-            if($count > 7) {
85
+            if ($count > 7) {
86 86
                 $this->addLink('PAGEFILTER', 'More ...', '/admin/pages');
87 87
                 break;
88 88
             }
89 89
             $page = Injector::inst()->get($pageClassName);
90 90
             $pageTitle = $page->i18n_singular_name();
91
-            $query = 'q[ClassName]='.$pageClassName;
91
+            $query = 'q[ClassName]=' . $pageClassName;
92 92
             $link = 'admin/pages?' . $query;
93
-            $this->addLink('PAGEFILTER', $this->phrase('edit'). ' '.$pageTitle.' ('.$pageCount.')', $link);
93
+            $this->addLink('PAGEFILTER', $this->phrase('edit') . ' ' . $pageTitle . ' (' . $pageCount . ')', $link);
94 94
         }
95 95
     }
96 96
     protected function addFilesAndImages()
@@ -100,44 +100,44 @@  discard block
 block discarded – undo
100 100
         $uploadFolderName = Config::inst()->get(Upload::class, 'uploads_folder');
101 101
         $uploadFolder = Folder::find_or_make($uploadFolderName);
102 102
         // all
103
-        $this->addLink('FILESANDIMAGES', $this->phrase('edit'). ' Open File Browswer', '/admin/assets');
103
+        $this->addLink('FILESANDIMAGES', $this->phrase('edit') . ' Open File Browswer', '/admin/assets');
104 104
         // per type
105 105
         $filesCount = File::get()->exclude(['ClassName' => [Folder::class, Image::class]])->count();
106 106
         $imageCount = File::get()->filter(['ClassName' => [Image::class]])->count();
107
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Images ('.$imageCount.')', 'admin/assets?filter[appCategory]=IMAGE');
108
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Files ('.$filesCount.')', 'admin/assets?filter[appCategory]=DOCUMENT');
107
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Images (' . $imageCount . ')', 'admin/assets?filter[appCategory]=IMAGE');
108
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Files (' . $filesCount . ')', 'admin/assets?filter[appCategory]=DOCUMENT');
109 109
 
110 110
         // default upload folder
111
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Open Default Upload Folder', $uploadFolder->CMSEditLink());
111
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Open Default Upload Folder', $uploadFolder->CMSEditLink());
112 112
 
113 113
         // recent
114
-        $lastWeekLink = '/admin/assets?'.'filter[lastEditedFrom]='.date('Y-m-d', strtotime('-1 week')).'&view=tile';
115
-        $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Recently modified Files', $lastWeekLink);
114
+        $lastWeekLink = '/admin/assets?' . 'filter[lastEditedFrom]=' . date('Y-m-d', strtotime('-1 week')) . '&view=tile';
115
+        $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Recently modified Files', $lastWeekLink);
116 116
     }
117 117
 
118 118
     protected function addSiteConfigLinks()
119 119
     {
120 120
         $this->addGroup('SITECONFIG', 'Site Wide Configuration', 20);
121
-        $this->addLink('SITECONFIG', $this->phrase('review'). ' Site Settings', '/admin/settings');
121
+        $this->addLink('SITECONFIG', $this->phrase('review') . ' Site Settings', '/admin/settings');
122 122
     }
123 123
 
124 124
     protected function addSecurityLinks()
125 125
     {
126 126
         $this->addGroup('SECURITY', 'Security', 30);
127
-        $this->addLink('SECURITY', $this->phrase('add'). ' User', '/admin/security/users/EditForm/field/users/item/new');
127
+        $this->addLink('SECURITY', $this->phrase('add') . ' User', '/admin/security/users/EditForm/field/users/item/new');
128 128
         $userCount = Member::get()->count();
129 129
         $groupCount = Group::get()->count();
130
-        $this->addLink('SECURITY', $this->phrase('review'). ' Users ('.$userCount.')', '/admin/security');
131
-        $this->addLink('SECURITY', $this->phrase('review'). ' Groups  ('.$groupCount.')', '/admin/security/groups');
130
+        $this->addLink('SECURITY', $this->phrase('review') . ' Users (' . $userCount . ')', '/admin/security');
131
+        $this->addLink('SECURITY', $this->phrase('review') . ' Groups  (' . $groupCount . ')', '/admin/security/groups');
132 132
         DefaultAdminService::singleton()->extend('addSecurityLinks', $this);
133 133
         $adminGroup = Permission::get_groups_by_permission('ADMIN')->first();
134
-        if($adminGroup) {
134
+        if ($adminGroup) {
135 135
             $userCount = $adminGroup->Members()->count();
136
-            $this->addLink('SECURITY', $this->phrase('review'). ' Administrators ('.$userCount.')', '/admin/security/groups/EditForm/field/groups/item/'.$adminGroup->ID.'/edit');
136
+            $this->addLink('SECURITY', $this->phrase('review') . ' Administrators (' . $userCount . ')', '/admin/security/groups/EditForm/field/groups/item/' . $adminGroup->ID . '/edit');
137 137
         }
138
-        if(class_exists(EnabledMembers::class)) {
138
+        if (class_exists(EnabledMembers::class)) {
139 139
             $obj = Injector::inst()->get(EnabledMembers::class);
140
-            $this->addLink('SECURITY', $this->phrase('review'). ' Multi-Factor Authentication Status', $obj->getLink());
140
+            $this->addLink('SECURITY', $this->phrase('review') . ' Multi-Factor Authentication Status', $obj->getLink());
141 141
 
142 142
         }
143 143
     }
@@ -150,58 +150,58 @@  discard block
 block discarded – undo
150 150
         $modelAdmins = [];
151 151
         $skips = (array) $this->Config()->get('model_admins_to_skip');
152 152
         foreach (ClassInfo::subclassesFor(ModelAdmin::class, false) as $className) {
153
-            if(in_array($className, $skips)) {
153
+            if (in_array($className, $skips)) {
154 154
                 continue;
155 155
             }
156 156
             $modelAdmins[$className] = $className;
157 157
 
158 158
         }
159
-        foreach($modelAdmins as $modelAdminClassName) {
159
+        foreach ($modelAdmins as $modelAdminClassName) {
160 160
             $groupAdded = false;
161 161
             $ma = Injector::inst()->get($modelAdminClassName);
162
-            if($ma->canView()) {
162
+            if ($ma->canView()) {
163 163
                 $mas = $ma->getManagedModels();
164
-                if(count($mas)) {
164
+                if (count($mas)) {
165 165
                     $numberOfModels = count($mas);
166 166
                     $groupCode = strtoupper($modelAdminClassName);
167 167
                     $count = 0;
168
-                    foreach($mas as $model => $title) {
168
+                    foreach ($mas as $model => $title) {
169 169
                         $count++;
170
-                        if($count > 7) {
170
+                        if ($count > 7) {
171 171
                             $this->addLink('PAGEFILTER', 'More ...', $ma->Link());
172 172
                             break;
173 173
                         }
174
-                        if(is_array($title)) {
174
+                        if (is_array($title)) {
175 175
                             $title = $title['title'];
176 176
                             $model = $title['dataClass'] ?? $model;
177 177
                         }
178
-                        if(! class_exists($model)) {
178
+                        if (!class_exists($model)) {
179 179
                             continue;
180 180
                         }
181 181
                         $obj = Injector::inst()->get($model);
182
-                        if($obj && $obj->canView()) {
183
-                            if(! $groupAdded) {
182
+                        if ($obj && $obj->canView()) {
183
+                            if (!$groupAdded) {
184 184
                                 $this->addGroup($groupCode, $ma->menu_title(), 100);
185 185
                                 $groupAdded = true;
186 186
                             }
187 187
                             $link = '';
188
-                            if($obj->hasMethod('CMSListLink')) {
188
+                            if ($obj->hasMethod('CMSListLink')) {
189 189
                                 $link = $obj->CMSListLink();
190 190
                             } else {
191 191
                                 $link = $ma->getLinkForModelTab($model);
192 192
                             }
193 193
                             $objectCount = $model::get()->count();
194
-                            $titleContainsObjectCount = strpos($title, ' ('.$objectCount.')');
195
-                            if($titleContainsObjectCount === false) {
196
-                                $title .= ' ('.$objectCount.')';
194
+                            $titleContainsObjectCount = strpos($title, ' (' . $objectCount . ')');
195
+                            if ($titleContainsObjectCount === false) {
196
+                                $title .= ' (' . $objectCount . ')';
197 197
                             }
198
-                            $this->addLink($groupCode, $this->phrase('edit'). ' '.$title, $link);
199
-                            if($numberOfModels < 4) {
198
+                            $this->addLink($groupCode, $this->phrase('edit') . ' ' . $title, $link);
199
+                            if ($numberOfModels < 4) {
200 200
                                 $obj = Injector::inst()->get($model);
201
-                                if($obj->canCreate()) {
201
+                                if ($obj->canCreate()) {
202 202
                                     $classNameEscaped = str_replace('\\', '-', $model);
203
-                                    $linkNew = $link .= '/EditForm/field/'.$classNameEscaped.'/item/new';
204
-                                    $this->addLink($groupCode, $this->phrase('add'). ' '.$obj->i18n_singular_name(), $linkNew);
203
+                                    $linkNew = $link .= '/EditForm/field/' . $classNameEscaped . '/item/new';
204
+                                    $this->addLink($groupCode, $this->phrase('add') . ' ' . $obj->i18n_singular_name(), $linkNew);
205 205
                                 }
206 206
                             }
207 207
                         }
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
 
241 241
     protected function phrase(string $phrase): string
242 242
     {
243
-        if($phrase === 'add') {
243
+        if ($phrase === 'add') {
244 244
             $phrase = $this->config()->get('new_phrase');
245
-        } elseif($phrase === 'review') {
245
+        } elseif ($phrase === 'review') {
246 246
             $phrase = $this->config()->get('review_phrase');
247
-        } elseif($phrase === 'edit') {
247
+        } elseif ($phrase === 'edit') {
248 248
             $phrase = $this->config()->get('edit_phrase');
249 249
         }
250
-        return _t('DashboardWelcomeQuicklinks.'.$phrase, $phrase);
250
+        return _t('DashboardWelcomeQuicklinks.' . $phrase, $phrase);
251 251
     }
252 252
 
253 253
 }
Please login to merge, or discard this patch.