@@ -34,7 +34,7 @@ discard block |
||
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(); |
@@ -54,20 +54,20 @@ discard block |
||
54 | 54 | protected function addPagesLinks() |
55 | 55 | { |
56 | 56 | DashboardWelcomeQuicklinks::add_group('PAGES', 'Pages', 10); |
57 | - DashboardWelcomeQuicklinks::add_link('PAGES', DashboardWelcomeQuicklinks::get_base_phrase('add'). ' Page', '/admin/pages/add'); |
|
57 | + DashboardWelcomeQuicklinks::add_link('PAGES', DashboardWelcomeQuicklinks::get_base_phrase('add') . ' Page', '/admin/pages/add'); |
|
58 | 58 | $pagesCount = DataObject::get('Page')->count(); |
59 | 59 | $draftCount = CMSSiteTreeFilter_StatusDraftPages::create()->getFilteredPages()->count(); |
60 | 60 | $revisedCount = CMSSiteTreeFilter_ChangedPages::create()->getFilteredPages()->count(); |
61 | - DashboardWelcomeQuicklinks::add_link('PAGES', DashboardWelcomeQuicklinks::get_base_phrase('edit'). ' Pages ('.$pagesCount.')', '/admin/pages'); |
|
62 | - DashboardWelcomeQuicklinks::add_link('PAGES', DashboardWelcomeQuicklinks::get_base_phrase('edit'). ' Unpublished Drafts ('.$draftCount.')', '/admin/pages?q[FilterClass]=SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusDraftPages'); |
|
63 | - DashboardWelcomeQuicklinks::add_link('PAGES', DashboardWelcomeQuicklinks::get_base_phrase('edit'). ' Unpublished Changes ('.$revisedCount.')', '/admin/pages?q[FilterClass]=SilverStripe\CMS\Controllers\CMSSiteTreeFilter_ChangedPages'); |
|
61 | + DashboardWelcomeQuicklinks::add_link('PAGES', DashboardWelcomeQuicklinks::get_base_phrase('edit') . ' Pages (' . $pagesCount . ')', '/admin/pages'); |
|
62 | + DashboardWelcomeQuicklinks::add_link('PAGES', DashboardWelcomeQuicklinks::get_base_phrase('edit') . ' Unpublished Drafts (' . $draftCount . ')', '/admin/pages?q[FilterClass]=SilverStripe\CMS\Controllers\CMSSiteTreeFilter_StatusDraftPages'); |
|
63 | + DashboardWelcomeQuicklinks::add_link('PAGES', DashboardWelcomeQuicklinks::get_base_phrase('edit') . ' Unpublished Changes (' . $revisedCount . ')', '/admin/pages?q[FilterClass]=SilverStripe\CMS\Controllers\CMSSiteTreeFilter_ChangedPages'); |
|
64 | 64 | $pageLastEdited = DataObject::get_one('Page', '', true, 'LastEdited DESC'); |
65 | 65 | if ($pageLastEdited) { |
66 | - DashboardWelcomeQuicklinks::add_link('PAGES', '✎ Last Edited Page: '.$pageLastEdited->Title, $pageLastEdited->CMSEditLink()); |
|
66 | + DashboardWelcomeQuicklinks::add_link('PAGES', '✎ Last Edited Page: ' . $pageLastEdited->Title, $pageLastEdited->CMSEditLink()); |
|
67 | 67 | } |
68 | - $lastWeekLink = '/admin/pages?'.'q[LastEditedFrom]='.date('Y-m-d', strtotime('-1 week')); |
|
69 | - DashboardWelcomeQuicklinks::add_link('PAGES', DashboardWelcomeQuicklinks::get_base_phrase('review'). ' Recently Modified Pages', $lastWeekLink); |
|
70 | - DashboardWelcomeQuicklinks::add_link('PAGES', DashboardWelcomeQuicklinks::get_base_phrase('review'). ' Page Reports', '/admin/reports'); |
|
68 | + $lastWeekLink = '/admin/pages?' . 'q[LastEditedFrom]=' . date('Y-m-d', strtotime('-1 week')); |
|
69 | + DashboardWelcomeQuicklinks::add_link('PAGES', DashboardWelcomeQuicklinks::get_base_phrase('review') . ' Recently Modified Pages', $lastWeekLink); |
|
70 | + DashboardWelcomeQuicklinks::add_link('PAGES', DashboardWelcomeQuicklinks::get_base_phrase('review') . ' Page Reports', '/admin/reports'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | protected function addFindPages() |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | $notUsedArray = []; |
77 | 77 | $pagesToSkip = (array) $this->Config()->get('pages_to_skip'); |
78 | 78 | foreach (ClassInfo::subclassesFor(SiteTree::class, false) as $className) { |
79 | - if(in_array($className, $pagesToSkip)) { |
|
79 | + if (in_array($className, $pagesToSkip)) { |
|
80 | 80 | continue; |
81 | 81 | } |
82 | 82 | $pages[$className] = $className; |
83 | 83 | |
84 | 84 | } |
85 | - DashboardWelcomeQuicklinks::add_group('PAGEFILTER', 'Page Types ('.count($pages).')', 300); |
|
85 | + DashboardWelcomeQuicklinks::add_group('PAGEFILTER', 'Page Types (' . count($pages) . ')', 300); |
|
86 | 86 | $count = 0; |
87 | - foreach($pages as $pageClassName) { |
|
87 | + foreach ($pages as $pageClassName) { |
|
88 | 88 | $pageCount = $pageClassName::get()->filter(['ClassName' => $pageClassName])->count(); |
89 | - if($pageCount < 1) { |
|
89 | + if ($pageCount < 1) { |
|
90 | 90 | $notUsedArray[$pageClassName] = $pageClassName::singleton()->i18n_singular_name(); |
91 | 91 | continue; |
92 | 92 | } |
93 | 93 | $count++; |
94 | - if($pageCount === 1) { |
|
94 | + if ($pageCount === 1) { |
|
95 | 95 | $obj = DataObject::get_one($pageClassName, ['ClassName' => $pageClassName]); |
96 | - DashboardWelcomeQuicklinks::add_link('PAGEFILTER', DashboardWelcomeQuicklinks::get_base_phrase('edit'). ' '.$pageClassName::singleton()->i18n_singular_name() . ' (1)', $obj->CMSEditLink()); |
|
96 | + DashboardWelcomeQuicklinks::add_link('PAGEFILTER', DashboardWelcomeQuicklinks::get_base_phrase('edit') . ' ' . $pageClassName::singleton()->i18n_singular_name() . ' (1)', $obj->CMSEditLink()); |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | $page = Injector::inst()->get($pageClassName); |
100 | 100 | $pageTitle = $page->i18n_plural_name(); |
101 | - $query = 'q[ClassName]='.$pageClassName; |
|
101 | + $query = 'q[ClassName]=' . $pageClassName; |
|
102 | 102 | $link = 'admin/pages?' . $query; |
103 | - DashboardWelcomeQuicklinks::add_link('PAGEFILTER', DashboardWelcomeQuicklinks::get_base_phrase('edit'). ' '.$pageTitle.' ('.$pageCount.')', $link); |
|
103 | + DashboardWelcomeQuicklinks::add_link('PAGEFILTER', DashboardWelcomeQuicklinks::get_base_phrase('edit') . ' ' . $pageTitle . ' (' . $pageCount . ')', $link); |
|
104 | 104 | } |
105 | - foreach($notUsedArray as $pageClassName => $pageTitle) { |
|
106 | - DashboardWelcomeQuicklinks::add_link('PAGEFILTER', DashboardWelcomeQuicklinks::get_base_phrase('edit'). ' '.$pageTitle.' (0)', 'admin/pages/add?PageType='.$pageClassName); |
|
105 | + foreach ($notUsedArray as $pageClassName => $pageTitle) { |
|
106 | + DashboardWelcomeQuicklinks::add_link('PAGEFILTER', DashboardWelcomeQuicklinks::get_base_phrase('edit') . ' ' . $pageTitle . ' (0)', 'admin/pages/add?PageType=' . $pageClassName); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | protected function addFilesAndImages() |
@@ -113,44 +113,44 @@ discard block |
||
113 | 113 | $uploadFolderName = Config::inst()->get(Upload::class, 'uploads_folder'); |
114 | 114 | $uploadFolder = Folder::find_or_make($uploadFolderName); |
115 | 115 | // all |
116 | - DashboardWelcomeQuicklinks::add_link('FILESANDIMAGES', DashboardWelcomeQuicklinks::get_base_phrase('edit'). ' Open File Browswer', '/admin/assets'); |
|
116 | + DashboardWelcomeQuicklinks::add_link('FILESANDIMAGES', DashboardWelcomeQuicklinks::get_base_phrase('edit') . ' Open File Browswer', '/admin/assets'); |
|
117 | 117 | // per type |
118 | 118 | $filesCount = File::get()->exclude(['ClassName' => [Folder::class, Image::class]])->count(); |
119 | 119 | $imageCount = File::get()->filter(['ClassName' => [Image::class]])->count(); |
120 | - DashboardWelcomeQuicklinks::add_link('FILESANDIMAGES', DashboardWelcomeQuicklinks::get_base_phrase('review'). ' Images ('.$imageCount.')', 'admin/assets?filter[appCategory]=IMAGE'); |
|
121 | - DashboardWelcomeQuicklinks::add_link('FILESANDIMAGES', DashboardWelcomeQuicklinks::get_base_phrase('review'). ' Files ('.$filesCount.')', 'admin/assets?filter[appCategory]=DOCUMENT'); |
|
120 | + DashboardWelcomeQuicklinks::add_link('FILESANDIMAGES', DashboardWelcomeQuicklinks::get_base_phrase('review') . ' Images (' . $imageCount . ')', 'admin/assets?filter[appCategory]=IMAGE'); |
|
121 | + DashboardWelcomeQuicklinks::add_link('FILESANDIMAGES', DashboardWelcomeQuicklinks::get_base_phrase('review') . ' Files (' . $filesCount . ')', 'admin/assets?filter[appCategory]=DOCUMENT'); |
|
122 | 122 | |
123 | 123 | // default upload folder |
124 | - DashboardWelcomeQuicklinks::add_link('FILESANDIMAGES', DashboardWelcomeQuicklinks::get_base_phrase('review'). ' Open Default Upload Folder', $uploadFolder->CMSEditLink()); |
|
124 | + DashboardWelcomeQuicklinks::add_link('FILESANDIMAGES', DashboardWelcomeQuicklinks::get_base_phrase('review') . ' Open Default Upload Folder', $uploadFolder->CMSEditLink()); |
|
125 | 125 | |
126 | 126 | // recent |
127 | - $lastWeekLink = '/admin/assets?'.'filter[lastEditedFrom]='.date('Y-m-d', strtotime('-1 week')).'&view=tile'; |
|
128 | - DashboardWelcomeQuicklinks::add_link('FILESANDIMAGES', DashboardWelcomeQuicklinks::get_base_phrase('review'). ' Recently modified Files', $lastWeekLink); |
|
127 | + $lastWeekLink = '/admin/assets?' . 'filter[lastEditedFrom]=' . date('Y-m-d', strtotime('-1 week')) . '&view=tile'; |
|
128 | + DashboardWelcomeQuicklinks::add_link('FILESANDIMAGES', DashboardWelcomeQuicklinks::get_base_phrase('review') . ' Recently modified Files', $lastWeekLink); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | protected function addSiteConfigLinks() |
132 | 132 | { |
133 | 133 | DashboardWelcomeQuicklinks::add_group('SITECONFIG', 'Site Wide Configuration', 20); |
134 | - DashboardWelcomeQuicklinks::add_link('SITECONFIG', DashboardWelcomeQuicklinks::get_base_phrase('review'). ' Site Settings', '/admin/settings'); |
|
134 | + DashboardWelcomeQuicklinks::add_link('SITECONFIG', DashboardWelcomeQuicklinks::get_base_phrase('review') . ' Site Settings', '/admin/settings'); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | protected function addSecurityLinks() |
138 | 138 | { |
139 | 139 | DashboardWelcomeQuicklinks::add_group('SECURITY', 'Security', 30); |
140 | - DashboardWelcomeQuicklinks::add_link('SECURITY', DashboardWelcomeQuicklinks::get_base_phrase('add'). ' User', '/admin/security/users/EditForm/field/users/item/new'); |
|
140 | + DashboardWelcomeQuicklinks::add_link('SECURITY', DashboardWelcomeQuicklinks::get_base_phrase('add') . ' User', '/admin/security/users/EditForm/field/users/item/new'); |
|
141 | 141 | $userCount = Member::get()->count(); |
142 | 142 | $groupCount = Group::get()->count(); |
143 | - DashboardWelcomeQuicklinks::add_link('SECURITY', DashboardWelcomeQuicklinks::get_base_phrase('review'). ' Users ('.$userCount.')', '/admin/security'); |
|
144 | - DashboardWelcomeQuicklinks::add_link('SECURITY', DashboardWelcomeQuicklinks::get_base_phrase('review'). ' Groups ('.$groupCount.')', '/admin/security/groups'); |
|
143 | + DashboardWelcomeQuicklinks::add_link('SECURITY', DashboardWelcomeQuicklinks::get_base_phrase('review') . ' Users (' . $userCount . ')', '/admin/security'); |
|
144 | + DashboardWelcomeQuicklinks::add_link('SECURITY', DashboardWelcomeQuicklinks::get_base_phrase('review') . ' Groups (' . $groupCount . ')', '/admin/security/groups'); |
|
145 | 145 | DefaultAdminService::singleton()->extend('addSecurityLinks', $this); |
146 | 146 | $adminGroup = Permission::get_groups_by_permission('ADMIN')->first(); |
147 | - if($adminGroup) { |
|
147 | + if ($adminGroup) { |
|
148 | 148 | $userCount = $adminGroup->Members()->count(); |
149 | - DashboardWelcomeQuicklinks::add_link('SECURITY', DashboardWelcomeQuicklinks::get_base_phrase('review'). ' Administrators ('.$userCount.')', '/admin/security/groups/EditForm/field/groups/item/'.$adminGroup->ID.'/edit'); |
|
149 | + DashboardWelcomeQuicklinks::add_link('SECURITY', DashboardWelcomeQuicklinks::get_base_phrase('review') . ' Administrators (' . $userCount . ')', '/admin/security/groups/EditForm/field/groups/item/' . $adminGroup->ID . '/edit'); |
|
150 | 150 | } |
151 | - if(class_exists(EnabledMembers::class)) { |
|
151 | + if (class_exists(EnabledMembers::class)) { |
|
152 | 152 | $obj = Injector::inst()->get(EnabledMembers::class); |
153 | - DashboardWelcomeQuicklinks::add_link('SECURITY', DashboardWelcomeQuicklinks::get_base_phrase('review'). ' Multi-Factor Authentication Status', $obj->getLink()); |
|
153 | + DashboardWelcomeQuicklinks::add_link('SECURITY', DashboardWelcomeQuicklinks::get_base_phrase('review') . ' Multi-Factor Authentication Status', $obj->getLink()); |
|
154 | 154 | |
155 | 155 | } |
156 | 156 | } |
@@ -163,33 +163,33 @@ discard block |
||
163 | 163 | $modelAdmins = []; |
164 | 164 | $skips = (array) $this->Config()->get('model_admins_to_skip'); |
165 | 165 | foreach (ClassInfo::subclassesFor(ModelAdmin::class, false) as $className) { |
166 | - if(in_array($className, $skips)) { |
|
166 | + if (in_array($className, $skips)) { |
|
167 | 167 | continue; |
168 | 168 | } |
169 | 169 | $modelAdmins[$className] = $className; |
170 | 170 | |
171 | 171 | } |
172 | - foreach($modelAdmins as $modelAdminClassName) { |
|
172 | + foreach ($modelAdmins as $modelAdminClassName) { |
|
173 | 173 | $groupAdded = false; |
174 | 174 | $ma = Injector::inst()->get($modelAdminClassName); |
175 | - if($ma->canView()) { |
|
175 | + if ($ma->canView()) { |
|
176 | 176 | $mas = $ma->getManagedModels(); |
177 | - if(count($mas)) { |
|
177 | + if (count($mas)) { |
|
178 | 178 | $numberOfModels = count($mas); |
179 | 179 | $groupCode = strtoupper($modelAdminClassName); |
180 | 180 | $count = 0; |
181 | - foreach($mas as $model => $title) { |
|
181 | + foreach ($mas as $model => $title) { |
|
182 | 182 | $count++; |
183 | - if(is_array($title)) { |
|
183 | + if (is_array($title)) { |
|
184 | 184 | $title = $title['title']; |
185 | 185 | $model = $title['dataClass'] ?? $model; |
186 | 186 | } |
187 | - if(! class_exists($model)) { |
|
187 | + if (!class_exists($model)) { |
|
188 | 188 | continue; |
189 | 189 | } |
190 | 190 | $obj = Injector::inst()->get($model); |
191 | - if($obj && $obj->canView()) { |
|
192 | - if(! $groupAdded) { |
|
191 | + if ($obj && $obj->canView()) { |
|
192 | + if (!$groupAdded) { |
|
193 | 193 | DashboardWelcomeQuicklinks::add_group($groupCode, $ma->menu_title(), 100); |
194 | 194 | $groupAdded = true; |
195 | 195 | } |
@@ -197,41 +197,41 @@ discard block |
||
197 | 197 | $ma = ReflectionHelper::allowAccessToProperty(get_class($ma), 'modelClass'); |
198 | 198 | $ma->modelClass = $model; |
199 | 199 | $list = $ma->getList(); |
200 | - if(! $list) { |
|
200 | + if (!$list) { |
|
201 | 201 | $list = $model::get(); |
202 | 202 | } |
203 | 203 | $objectCount = $list->count(); |
204 | - if($objectCount === 1) { |
|
204 | + if ($objectCount === 1) { |
|
205 | 205 | $obj = DataObject::get_one($model, ['ClassName' => $model]); |
206 | - if(! $obj) { |
|
206 | + if (!$obj) { |
|
207 | 207 | $obj = DataObject::get_one($model); |
208 | 208 | } |
209 | - if($obj && $obj->hasMethod('CMSEditLink')) { |
|
209 | + if ($obj && $obj->hasMethod('CMSEditLink')) { |
|
210 | 210 | $link = $obj->CMSEditLink(); |
211 | - if($link) { |
|
212 | - DashboardWelcomeQuicklinks::add_link($groupCode, DashboardWelcomeQuicklinks::get_base_phrase('edit'). ' '.$model::singleton()->i18n_singular_name(), $link); |
|
211 | + if ($link) { |
|
212 | + DashboardWelcomeQuicklinks::add_link($groupCode, DashboardWelcomeQuicklinks::get_base_phrase('edit') . ' ' . $model::singleton()->i18n_singular_name(), $link); |
|
213 | 213 | continue; |
214 | 214 | } |
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | 218 | $link = ''; |
219 | - if($obj->hasMethod('CMSListLink')) { |
|
219 | + if ($obj->hasMethod('CMSListLink')) { |
|
220 | 220 | $link = $obj->CMSListLink(); |
221 | - } if(! $link) { |
|
221 | + } if (!$link) { |
|
222 | 222 | $link = $ma->getLinkForModelTab($model); |
223 | 223 | } |
224 | - $titleContainsObjectCount = strpos($title, ' ('.$objectCount.')'); |
|
225 | - if($titleContainsObjectCount === false) { |
|
226 | - $title .= ' ('.$objectCount.')'; |
|
224 | + $titleContainsObjectCount = strpos($title, ' (' . $objectCount . ')'); |
|
225 | + if ($titleContainsObjectCount === false) { |
|
226 | + $title .= ' (' . $objectCount . ')'; |
|
227 | 227 | } |
228 | - DashboardWelcomeQuicklinks::add_link($groupCode, DashboardWelcomeQuicklinks::get_base_phrase('edit'). ' '.$title, $link); |
|
229 | - if($numberOfModels < 4) { |
|
228 | + DashboardWelcomeQuicklinks::add_link($groupCode, DashboardWelcomeQuicklinks::get_base_phrase('edit') . ' ' . $title, $link); |
|
229 | + if ($numberOfModels < 4) { |
|
230 | 230 | $obj = Injector::inst()->get($model); |
231 | - if($obj->canCreate()) { |
|
231 | + if ($obj->canCreate()) { |
|
232 | 232 | $classNameEscaped = str_replace('\\', '-', $model); |
233 | - $linkNew = $link .= '/EditForm/field/'.$classNameEscaped.'/item/new'; |
|
234 | - DashboardWelcomeQuicklinks::add_link($groupCode, DashboardWelcomeQuicklinks::get_base_phrase('add'). ' '.$obj->i18n_singular_name(), $linkNew); |
|
233 | + $linkNew = $link .= '/EditForm/field/' . $classNameEscaped . '/item/new'; |
|
234 | + DashboardWelcomeQuicklinks::add_link($groupCode, DashboardWelcomeQuicklinks::get_base_phrase('add') . ' ' . $obj->i18n_singular_name(), $linkNew); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |