88
99namespace OCA \Files \Controller ;
1010
11- use OC \Files \FilenameValidator ;
1211use OC \Files \Filesystem ;
1312use OCA \Files \AppInfo \Application ;
14- use OCA \Files \ConfigLexicon ;
15- use OCA \Files \Event \LoadAdditionalScriptsEvent ;
16- use OCA \Files \Event \LoadSearchPlugins ;
17- use OCA \Files \Event \LoadSidebar ;
18- use OCA \Files \Service \UserConfig ;
19- use OCA \Files \Service \ViewConfig ;
20- use OCA \Viewer \Event \LoadViewer ;
13+ use OCA \Files \Event \LoadFilesApp ;
2114use OCP \App \IAppManager ;
2215use OCP \AppFramework \Controller ;
2316use OCP \AppFramework \Http \Attribute \NoAdminRequired ;
2720use OCP \AppFramework \Http \RedirectResponse ;
2821use OCP \AppFramework \Http \Response ;
2922use OCP \AppFramework \Http \TemplateResponse ;
30- use OCP \AppFramework \Services \IAppConfig ;
3123use OCP \AppFramework \Services \IInitialState ;
32- use OCP \Authentication \TwoFactorAuth \IRegistry ;
33- use OCP \Collaboration \Resources \LoadAdditionalScriptsEvent as ResourcesLoadAdditionalScriptsEvent ;
3424use OCP \EventDispatcher \IEventDispatcher ;
3525use OCP \Files \Folder ;
3626use OCP \Files \IRootFolder ;
3727use OCP \Files \NotFoundException ;
38- use OCP \Files \Template \ITemplateManager ;
39- use OCP \IConfig ;
4028use OCP \IL10N ;
4129use OCP \IRequest ;
4230use OCP \IURLGenerator ;
4331use OCP \IUserSession ;
44- use OCP \Util ;
4532
4633/**
4734 * @package OCA\Files\Controller
@@ -54,18 +41,11 @@ public function __construct(
5441 IRequest $ request ,
5542 private IURLGenerator $ urlGenerator ,
5643 private IL10N $ l10n ,
57- private IConfig $ config ,
5844 private IEventDispatcher $ eventDispatcher ,
5945 private IUserSession $ userSession ,
6046 private IAppManager $ appManager ,
6147 private IRootFolder $ rootFolder ,
6248 private IInitialState $ initialState ,
63- private ITemplateManager $ templateManager ,
64- private UserConfig $ userConfig ,
65- private ViewConfig $ viewConfig ,
66- private FilenameValidator $ filenameValidator ,
67- private IRegistry $ twoFactorRegistry ,
68- private IAppConfig $ appConfig ,
6949 ) {
7050 parent ::__construct ($ appName , $ request );
7151 }
@@ -143,10 +123,6 @@ public function index($dir = '', $view = '', $fileid = null) {
143123 }
144124 }
145125
146- // Load the files we need
147- Util::addInitScript ('files ' , 'init ' );
148- Util::addScript ('files ' , 'main ' );
149-
150126 $ user = $ this ->userSession ->getUser ();
151127 $ userId = $ user ->getUID ();
152128
@@ -175,46 +151,8 @@ public function index($dir = '', $view = '', $fileid = null) {
175151 }
176152
177153 $ this ->initialState ->provideInitialState ('storageStats ' , $ storageInfo );
178- $ this ->initialState ->provideInitialState ('config ' , $ this ->userConfig ->getConfigs ());
179- $ this ->initialState ->provideInitialState ('viewConfigs ' , $ this ->viewConfig ->getConfigs ());
180- $ this ->initialState ->provideInitialState ('recent_limit ' , $ this ->appConfig ->getAppValueInt (ConfigLexicon::RECENT_LIMIT , 100 ));
181- // Not yet consumed by the frontend, provided for future implementation
182- $ this ->initialState ->provideInitialState ('group_recent_files ' , $ this ->appConfig ->getAppValueBool (ConfigLexicon::GROUP_RECENT_FILES , false ));
183- $ this ->initialState ->provideInitialState ('recent_files_group_mime_types ' , $ this ->appConfig ->getAppValueArray (ConfigLexicon::RECENT_FILES_GROUP_MIME_TYPES , []));
184- $ this ->initialState ->provideInitialState ('recent_files_group_timespan_minutes ' , $ this ->appConfig ->getAppValueInt (ConfigLexicon::RECENT_FILES_GROUP_TIMESPAN_MINUTES , 2 ));
185-
186- // File sorting user config
187- $ filesSortingConfig = json_decode ($ this ->config ->getUserValue ($ userId , 'files ' , 'files_sorting_configs ' , '{} ' ), true );
188- $ this ->initialState ->provideInitialState ('filesSortingConfig ' , $ filesSortingConfig );
189-
190- // Forbidden file characters (deprecated use capabilities)
191- // TODO: Remove with next release of `@nextcloud/files`
192- $ forbiddenCharacters = $ this ->filenameValidator ->getForbiddenCharacters ();
193- $ this ->initialState ->provideInitialState ('forbiddenCharacters ' , $ forbiddenCharacters );
194-
195- $ event = new LoadAdditionalScriptsEvent ();
196- $ this ->eventDispatcher ->dispatchTyped ($ event );
197- $ this ->eventDispatcher ->dispatchTyped (new ResourcesLoadAdditionalScriptsEvent ());
198- $ this ->eventDispatcher ->dispatchTyped (new LoadSidebar ());
199- $ this ->eventDispatcher ->dispatchTyped (new LoadSearchPlugins ());
200- // Load Viewer scripts
201- if (class_exists (LoadViewer::class)) {
202- $ this ->eventDispatcher ->dispatchTyped (new LoadViewer ());
203- }
204-
205- $ this ->initialState ->provideInitialState ('templates_enabled ' , true );
206- $ this ->initialState ->provideInitialState ('templates_path ' , $ this ->templateManager ->hasTemplateDirectory () ? $ this ->templateManager ->getTemplatePath () : false );
207- $ this ->initialState ->provideInitialState ('templates ' , $ this ->templateManager ->listCreators ());
208- $ this ->initialState ->provideInitialState ('localClientEnabled ' , $ this ->appConfig ->getAppValueBool (ConfigLexicon::LOCAL_CLIENT_INTEGRATION ));
209-
210- $ isTwoFactorEnabled = false ;
211- foreach ($ this ->twoFactorRegistry ->getProviderStates ($ user ) as $ providerId => $ providerState ) {
212- if ($ providerId !== 'backup_codes ' && $ providerState === true ) {
213- $ isTwoFactorEnabled = true ;
214- }
215- }
216154
217- $ this ->initialState -> provideInitialState ( ' isTwoFactorEnabled ' , $ isTwoFactorEnabled );
155+ $ this ->eventDispatcher -> dispatchTyped ( new LoadFilesApp () );
218156
219157 $ response = new TemplateResponse (
220158 Application::APP_ID ,
0 commit comments