@@ -32,7 +32,7 @@ discard block |
||
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(); |
@@ -56,16 +56,16 @@ discard block |
||
56 | 56 | protected function addPagesLinks() |
57 | 57 | { |
58 | 58 | $this->addGroup('PAGES', 'Pages', 10); |
59 | - $this->addLink('PAGES', $this->phrase('add'). ' Page', '/admin/pages/add'); |
|
59 | + $this->addLink('PAGES', $this->phrase('add') . ' Page', '/admin/pages/add'); |
|
60 | 60 | $pagesCount = DataObject::get('Page')->count(); |
61 | - $this->addLink('PAGES', $this->phrase('edit'). ' Pages ('.$pagesCount.')', '/admin/pages'); |
|
61 | + $this->addLink('PAGES', $this->phrase('edit') . ' Pages (' . $pagesCount . ')', '/admin/pages'); |
|
62 | 62 | $pageLastEdited = DataObject::get_one('Page', '', true, 'LastEdited DESC'); |
63 | 63 | if ($pageLastEdited) { |
64 | - $this->addLink('PAGES', '✎ Last Edited Page: '.$pageLastEdited->Title, $pageLastEdited->CMSEditLink()); |
|
64 | + $this->addLink('PAGES', '✎ Last Edited Page: ' . $pageLastEdited->Title, $pageLastEdited->CMSEditLink()); |
|
65 | 65 | } |
66 | - $this->addLink('PAGES', $this->phrase('review'). ' Page Reports', '/admin/reports'); |
|
67 | - $lastWeekLink = '/admin/pages?'.'q[LastEditedFrom]='.date('Y-m-d', strtotime('-1 week')); |
|
68 | - $this->addLink('PAGES', $this->phrase('review'). ' Recently Modified Pages', $lastWeekLink); |
|
66 | + $this->addLink('PAGES', $this->phrase('review') . ' Page Reports', '/admin/reports'); |
|
67 | + $lastWeekLink = '/admin/pages?' . 'q[LastEditedFrom]=' . date('Y-m-d', strtotime('-1 week')); |
|
68 | + $this->addLink('PAGES', $this->phrase('review') . ' Recently Modified Pages', $lastWeekLink); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | protected function addFindPages() |
@@ -73,34 +73,34 @@ discard block |
||
73 | 73 | $pages = []; |
74 | 74 | $pagesToSkip = (array) $this->Config()->get('pages_to_skip'); |
75 | 75 | foreach (ClassInfo::subclassesFor(SiteTree::class, false) as $className) { |
76 | - if(in_array($className, $pagesToSkip)) { |
|
76 | + if (in_array($className, $pagesToSkip)) { |
|
77 | 77 | continue; |
78 | 78 | } |
79 | 79 | $pages[$className] = $className; |
80 | 80 | |
81 | 81 | } |
82 | - $this->addGroup('PAGEFILTER', 'Page Types ('.count($pages).')', 300); |
|
82 | + $this->addGroup('PAGEFILTER', 'Page Types (' . count($pages) . ')', 300); |
|
83 | 83 | $count = 0; |
84 | - foreach($pages as $pageClassName) { |
|
84 | + foreach ($pages as $pageClassName) { |
|
85 | 85 | $pageCount = $pageClassName::get()->filter(['ClassName' => $pageClassName])->count(); |
86 | - if($pageCount < 1) { |
|
86 | + if ($pageCount < 1) { |
|
87 | 87 | continue; |
88 | 88 | } |
89 | 89 | $count++; |
90 | - if($count > 7) { |
|
90 | + if ($count > 7) { |
|
91 | 91 | $this->addLink('PAGEFILTER', $this->phrase('more'), '/admin/pages'); |
92 | 92 | break; |
93 | 93 | } |
94 | - if($pageCount === 1) { |
|
94 | + if ($pageCount === 1) { |
|
95 | 95 | $obj = DataObject::get_one($pageClassName, ['ClassName' => $pageClassName]); |
96 | - $this->addLink('PAGEFILTER', $this->phrase('edit'). ' '.$pageClassName::singleton()->i18n_singular_name(), $obj->CMSEditLink()); |
|
96 | + $this->addLink('PAGEFILTER', $this->phrase('edit') . ' ' . $pageClassName::singleton()->i18n_singular_name(), $obj->CMSEditLink()); |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | $page = Injector::inst()->get($pageClassName); |
100 | 100 | $pageTitle = $page->i18n_singular_name(); |
101 | - $query = 'q[ClassName]='.$pageClassName; |
|
101 | + $query = 'q[ClassName]=' . $pageClassName; |
|
102 | 102 | $link = 'admin/pages?' . $query; |
103 | - $this->addLink('PAGEFILTER', $this->phrase('edit'). ' '.$pageTitle.' ('.$pageCount.')', $link); |
|
103 | + $this->addLink('PAGEFILTER', $this->phrase('edit') . ' ' . $pageTitle . ' (' . $pageCount . ')', $link); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | protected function addFilesAndImages() |
@@ -110,44 +110,44 @@ discard block |
||
110 | 110 | $uploadFolderName = Config::inst()->get(Upload::class, 'uploads_folder'); |
111 | 111 | $uploadFolder = Folder::find_or_make($uploadFolderName); |
112 | 112 | // all |
113 | - $this->addLink('FILESANDIMAGES', $this->phrase('edit'). ' Open File Browswer', '/admin/assets'); |
|
113 | + $this->addLink('FILESANDIMAGES', $this->phrase('edit') . ' Open File Browswer', '/admin/assets'); |
|
114 | 114 | // per type |
115 | 115 | $filesCount = File::get()->exclude(['ClassName' => [Folder::class, Image::class]])->count(); |
116 | 116 | $imageCount = File::get()->filter(['ClassName' => [Image::class]])->count(); |
117 | - $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Images ('.$imageCount.')', 'admin/assets?filter[appCategory]=IMAGE'); |
|
118 | - $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Files ('.$filesCount.')', 'admin/assets?filter[appCategory]=DOCUMENT'); |
|
117 | + $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Images (' . $imageCount . ')', 'admin/assets?filter[appCategory]=IMAGE'); |
|
118 | + $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Files (' . $filesCount . ')', 'admin/assets?filter[appCategory]=DOCUMENT'); |
|
119 | 119 | |
120 | 120 | // default upload folder |
121 | - $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Open Default Upload Folder', $uploadFolder->CMSEditLink()); |
|
121 | + $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Open Default Upload Folder', $uploadFolder->CMSEditLink()); |
|
122 | 122 | |
123 | 123 | // recent |
124 | - $lastWeekLink = '/admin/assets?'.'filter[lastEditedFrom]='.date('Y-m-d', strtotime('-1 week')).'&view=tile'; |
|
125 | - $this->addLink('FILESANDIMAGES', $this->phrase('review'). ' Recently modified Files', $lastWeekLink); |
|
124 | + $lastWeekLink = '/admin/assets?' . 'filter[lastEditedFrom]=' . date('Y-m-d', strtotime('-1 week')) . '&view=tile'; |
|
125 | + $this->addLink('FILESANDIMAGES', $this->phrase('review') . ' Recently modified Files', $lastWeekLink); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | protected function addSiteConfigLinks() |
129 | 129 | { |
130 | 130 | $this->addGroup('SITECONFIG', 'Site Wide Configuration', 20); |
131 | - $this->addLink('SITECONFIG', $this->phrase('review'). ' Site Settings', '/admin/settings'); |
|
131 | + $this->addLink('SITECONFIG', $this->phrase('review') . ' Site Settings', '/admin/settings'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | protected function addSecurityLinks() |
135 | 135 | { |
136 | 136 | $this->addGroup('SECURITY', 'Security', 30); |
137 | - $this->addLink('SECURITY', $this->phrase('add'). ' User', '/admin/security/users/EditForm/field/users/item/new'); |
|
137 | + $this->addLink('SECURITY', $this->phrase('add') . ' User', '/admin/security/users/EditForm/field/users/item/new'); |
|
138 | 138 | $userCount = Member::get()->count(); |
139 | 139 | $groupCount = Group::get()->count(); |
140 | - $this->addLink('SECURITY', $this->phrase('review'). ' Users ('.$userCount.')', '/admin/security'); |
|
141 | - $this->addLink('SECURITY', $this->phrase('review'). ' Groups ('.$groupCount.')', '/admin/security/groups'); |
|
140 | + $this->addLink('SECURITY', $this->phrase('review') . ' Users (' . $userCount . ')', '/admin/security'); |
|
141 | + $this->addLink('SECURITY', $this->phrase('review') . ' Groups (' . $groupCount . ')', '/admin/security/groups'); |
|
142 | 142 | DefaultAdminService::singleton()->extend('addSecurityLinks', $this); |
143 | 143 | $adminGroup = Permission::get_groups_by_permission('ADMIN')->first(); |
144 | - if($adminGroup) { |
|
144 | + if ($adminGroup) { |
|
145 | 145 | $userCount = $adminGroup->Members()->count(); |
146 | - $this->addLink('SECURITY', $this->phrase('review'). ' Administrators ('.$userCount.')', '/admin/security/groups/EditForm/field/groups/item/'.$adminGroup->ID.'/edit'); |
|
146 | + $this->addLink('SECURITY', $this->phrase('review') . ' Administrators (' . $userCount . ')', '/admin/security/groups/EditForm/field/groups/item/' . $adminGroup->ID . '/edit'); |
|
147 | 147 | } |
148 | - if(class_exists(EnabledMembers::class)) { |
|
148 | + if (class_exists(EnabledMembers::class)) { |
|
149 | 149 | $obj = Injector::inst()->get(EnabledMembers::class); |
150 | - $this->addLink('SECURITY', $this->phrase('review'). ' Multi-Factor Authentication Status', $obj->getLink()); |
|
150 | + $this->addLink('SECURITY', $this->phrase('review') . ' Multi-Factor Authentication Status', $obj->getLink()); |
|
151 | 151 | |
152 | 152 | } |
153 | 153 | } |
@@ -160,66 +160,66 @@ discard block |
||
160 | 160 | $modelAdmins = []; |
161 | 161 | $skips = (array) $this->Config()->get('model_admins_to_skip'); |
162 | 162 | foreach (ClassInfo::subclassesFor(ModelAdmin::class, false) as $className) { |
163 | - if(in_array($className, $skips)) { |
|
163 | + if (in_array($className, $skips)) { |
|
164 | 164 | continue; |
165 | 165 | } |
166 | 166 | $modelAdmins[$className] = $className; |
167 | 167 | |
168 | 168 | } |
169 | - foreach($modelAdmins as $modelAdminClassName) { |
|
169 | + foreach ($modelAdmins as $modelAdminClassName) { |
|
170 | 170 | $groupAdded = false; |
171 | 171 | $ma = Injector::inst()->get($modelAdminClassName); |
172 | - if($ma->canView()) { |
|
172 | + if ($ma->canView()) { |
|
173 | 173 | $mas = $ma->getManagedModels(); |
174 | - if(count($mas)) { |
|
174 | + if (count($mas)) { |
|
175 | 175 | $numberOfModels = count($mas); |
176 | 176 | $groupCode = strtoupper($modelAdminClassName); |
177 | 177 | $count = 0; |
178 | - foreach($mas as $model => $title) { |
|
178 | + foreach ($mas as $model => $title) { |
|
179 | 179 | $count++; |
180 | - if(is_array($title)) { |
|
180 | + if (is_array($title)) { |
|
181 | 181 | $title = $title['title']; |
182 | 182 | $model = $title['dataClass'] ?? $model; |
183 | 183 | } |
184 | - if(! class_exists($model)) { |
|
184 | + if (!class_exists($model)) { |
|
185 | 185 | continue; |
186 | 186 | } |
187 | - if($count > 7) { |
|
187 | + if ($count > 7) { |
|
188 | 188 | $this->addLink($groupCode, $this->phrase('more'), $ma->Link()); |
189 | 189 | break; |
190 | 190 | } |
191 | 191 | $obj = Injector::inst()->get($model); |
192 | - if($obj && $obj->canView()) { |
|
193 | - if(! $groupAdded) { |
|
192 | + if ($obj && $obj->canView()) { |
|
193 | + if (!$groupAdded) { |
|
194 | 194 | $this->addGroup($groupCode, $ma->menu_title(), 100); |
195 | 195 | $groupAdded = true; |
196 | 196 | } |
197 | 197 | $objectCount = $model::get()->filter(['ClassName' => $model])->count(); |
198 | - if($objectCount === 1) { |
|
198 | + if ($objectCount === 1) { |
|
199 | 199 | $obj = DataObject::get_one($model, ['ClassName' => $model]); |
200 | - if($obj->hasMethod('CMSEditLink')) { |
|
201 | - $this->addLink('PAGEFILTER', $this->phrase('edit'). ' '.$model::singleton()->i18n_singular_name(), $obj->CMSEditLink()); |
|
200 | + if ($obj->hasMethod('CMSEditLink')) { |
|
201 | + $this->addLink('PAGEFILTER', $this->phrase('edit') . ' ' . $model::singleton()->i18n_singular_name(), $obj->CMSEditLink()); |
|
202 | 202 | continue; |
203 | 203 | } |
204 | 204 | } |
205 | 205 | |
206 | 206 | $link = ''; |
207 | - if($obj->hasMethod('CMSListLink')) { |
|
207 | + if ($obj->hasMethod('CMSListLink')) { |
|
208 | 208 | $link = $obj->CMSListLink(); |
209 | 209 | } else { |
210 | 210 | $link = $ma->getLinkForModelTab($model); |
211 | 211 | } |
212 | - $titleContainsObjectCount = strpos($title, ' ('.$objectCount.')'); |
|
213 | - if($titleContainsObjectCount === false) { |
|
214 | - $title .= ' ('.$objectCount.')'; |
|
212 | + $titleContainsObjectCount = strpos($title, ' (' . $objectCount . ')'); |
|
213 | + if ($titleContainsObjectCount === false) { |
|
214 | + $title .= ' (' . $objectCount . ')'; |
|
215 | 215 | } |
216 | - $this->addLink($groupCode, $this->phrase('edit'). ' '.$title, $link); |
|
217 | - if($numberOfModels < 4) { |
|
216 | + $this->addLink($groupCode, $this->phrase('edit') . ' ' . $title, $link); |
|
217 | + if ($numberOfModels < 4) { |
|
218 | 218 | $obj = Injector::inst()->get($model); |
219 | - if($obj->canCreate()) { |
|
219 | + if ($obj->canCreate()) { |
|
220 | 220 | $classNameEscaped = str_replace('\\', '-', $model); |
221 | - $linkNew = $link .= '/EditForm/field/'.$classNameEscaped.'/item/new'; |
|
222 | - $this->addLink($groupCode, $this->phrase('add'). ' '.$obj->i18n_singular_name(), $linkNew); |
|
221 | + $linkNew = $link .= '/EditForm/field/' . $classNameEscaped . '/item/new'; |
|
222 | + $this->addLink($groupCode, $this->phrase('add') . ' ' . $obj->i18n_singular_name(), $linkNew); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | } |
@@ -258,8 +258,8 @@ discard block |
||
258 | 258 | |
259 | 259 | protected function phrase(string $phrase): string |
260 | 260 | { |
261 | - $phrase = $this->config()->get($phrase .'_phrase'); |
|
262 | - return _t('DashboardWelcomeQuicklinks.'.$phrase, $phrase); |
|
261 | + $phrase = $this->config()->get($phrase . '_phrase'); |
|
262 | + return _t('DashboardWelcomeQuicklinks.' . $phrase, $phrase); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | usort( |
81 | 81 | $shortcuts, |
82 | - function ($a, $b) { |
|
82 | + function($a, $b) { |
|
83 | 83 | ($a['SortOrder'] ?? 0) <=> ($b['SortOrder'] ?? 0); |
84 | 84 | } |
85 | 85 | ); |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | } |
124 | 124 | } |
125 | 125 | $kc = (array) $this->Config()->get('colour_options'); |
126 | - if(empty($kc)) { |
|
126 | + if (empty($kc)) { |
|
127 | 127 | $kc = $this->Config()->get('default_colour_options'); |
128 | 128 | } |
129 | 129 | $kcCount = count($kc); |
130 | 130 | $colours = ''; |
131 | 131 | foreach ($kc as $key => $colour) { |
132 | - $colours .= ' .grid-wrapper .grid-cell:nth-child(' . $kcCount . 'n+' . ($key + 1) . ') div.header {background-color: ' . $colour . '; color: '.$this->getFontColor($colour).'!important;}'; |
|
132 | + $colours .= ' .grid-wrapper .grid-cell:nth-child(' . $kcCount . 'n+' . ($key + 1) . ') div.header {background-color: ' . $colour . '; color: ' . $this->getFontColor($colour) . '!important;}'; |
|
133 | 133 | } |
134 | 134 | $html .= '</div>'; |
135 | 135 | $html .= <<<JS |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $useDefaultDashboard = (bool) $this->config()->get('use_default_dashboard_provider'); |
234 | 234 | $classNames = ClassInfo::implementorsOf(DashboardWelcomeQuickLinksProvider::class); |
235 | 235 | foreach ($classNames as $className) { |
236 | - if($useDefaultDashboard === false && (string) $className === DefaultDashboardProvider::class) { |
|
236 | + if ($useDefaultDashboard === false && (string) $className === DefaultDashboardProvider::class) { |
|
237 | 237 | continue; |
238 | 238 | } |
239 | 239 | $array += Injector::inst()->get($className)->provideDashboardWelcomeQuickLinks(); |
@@ -255,10 +255,10 @@ discard block |
||
255 | 255 | if (!empty($iconClass)) { |
256 | 256 | $icon = '<i class="' . $iconClass . '"></i> '; |
257 | 257 | } |
258 | - if(!$target) { |
|
258 | + if (!$target) { |
|
259 | 259 | $target = '_self'; |
260 | 260 | } |
261 | - $target = ' target="'.$target.'"'; |
|
261 | + $target = ' target="' . $target . '"'; |
|
262 | 262 | if ($link) { |
263 | 263 | $html = ' |
264 | 264 | ' . $script . ' |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | { |
290 | 290 | $app = $this->getApplicationName(); |
291 | 291 | $siteConfigTitle = SiteConfig::current_site_config()->Title; |
292 | - if($siteConfigTitle) { |
|
293 | - $app = $siteConfigTitle . ' ('.$app.')'; |
|
292 | + if ($siteConfigTitle) { |
|
293 | + $app = $siteConfigTitle . ' (' . $app . ')'; |
|
294 | 294 | } |
295 | 295 | return ($section = $this->SectionTitle()) ? sprintf('%s for %s', $section, $app) : $app; |
296 | 296 | } |