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