@@ -20,145 +20,145 @@ |
||
20 | 20 | |
21 | 21 | class OC_Theme { |
22 | 22 | |
23 | - /** |
|
24 | - * Returns the base URL |
|
25 | - * @return string URL |
|
26 | - */ |
|
27 | - public function getBaseUrl() { |
|
28 | - return 'https://nextcloud.com'; |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * Returns the URL where the sync clients are listed |
|
33 | - * @return string URL |
|
34 | - */ |
|
35 | - public function getSyncClientUrl() { |
|
36 | - return 'https://nextcloud.com/install/#install-clients'; |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * Returns the URL to the App Store for the iOS Client |
|
41 | - * @return string URL |
|
42 | - */ |
|
43 | - public function getiOSClientUrl() { |
|
44 | - return 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8'; |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Returns the AppId for the App Store for the iOS Client |
|
49 | - * @return string AppId |
|
50 | - */ |
|
51 | - public function getiTunesAppId() { |
|
52 | - return '1125420102'; |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Returns the URL to Google Play for the Android Client |
|
57 | - * @return string URL |
|
58 | - */ |
|
59 | - public function getAndroidClientUrl() { |
|
60 | - return 'https://play.google.com/store/apps/details?id=com.nextcloud.client'; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Returns the documentation URL |
|
65 | - * @return string URL |
|
66 | - */ |
|
67 | - public function getDocBaseUrl() { |
|
68 | - return 'https://docs.nextcloud.com'; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * Returns the title |
|
73 | - * @return string title |
|
74 | - */ |
|
75 | - public function getTitle() { |
|
76 | - return 'Custom Cloud'; |
|
77 | - } |
|
78 | - |
|
79 | - /** |
|
80 | - * Returns the short name of the software |
|
81 | - * @return string title |
|
82 | - */ |
|
83 | - public function getName() { |
|
84 | - return 'Custom Cloud'; |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Returns the short name of the software containing HTML strings |
|
89 | - * @return string title |
|
90 | - */ |
|
91 | - public function getHTMLName() { |
|
92 | - return 'Custom Cloud'; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Returns entity (e.g. company name) - used for footer, copyright |
|
97 | - * @return string entity name |
|
98 | - */ |
|
99 | - public function getEntity() { |
|
100 | - return 'Custom Cloud Co.'; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Returns slogan |
|
105 | - * @return string slogan |
|
106 | - */ |
|
107 | - public function getSlogan() { |
|
108 | - return 'Your custom cloud, personalized for you!'; |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Returns logo claim |
|
113 | - * @return string logo claim |
|
114 | - */ |
|
115 | - public function getLogoClaim() { |
|
116 | - return ''; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * Returns short version of the footer |
|
121 | - * @return string short footer |
|
122 | - */ |
|
123 | - public function getShortFooter() { |
|
124 | - $footer = '© 2016 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'. |
|
125 | - '<br/>' . $this->getSlogan(); |
|
126 | - |
|
127 | - return $footer; |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Returns long version of the footer |
|
132 | - * @return string long footer |
|
133 | - */ |
|
134 | - public function getLongFooter() { |
|
135 | - $footer = '© 2016 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'. |
|
136 | - '<br/>' . $this->getSlogan(); |
|
137 | - |
|
138 | - return $footer; |
|
139 | - } |
|
140 | - |
|
141 | - public function buildDocLinkToKey($key) { |
|
142 | - return $this->getDocBaseUrl() . '/server/11/go.php?to=' . $key; |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * Returns mail header color |
|
148 | - * @return string |
|
149 | - */ |
|
150 | - public function getMailHeaderColor() { |
|
151 | - return '#745bca'; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * Returns variables to overload defaults from core/css/variables.scss |
|
156 | - * @return array |
|
157 | - */ |
|
158 | - public function getScssVariables() { |
|
159 | - return [ |
|
160 | - 'color-primary' => '#745bca' |
|
161 | - ]; |
|
162 | - } |
|
23 | + /** |
|
24 | + * Returns the base URL |
|
25 | + * @return string URL |
|
26 | + */ |
|
27 | + public function getBaseUrl() { |
|
28 | + return 'https://nextcloud.com'; |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * Returns the URL where the sync clients are listed |
|
33 | + * @return string URL |
|
34 | + */ |
|
35 | + public function getSyncClientUrl() { |
|
36 | + return 'https://nextcloud.com/install/#install-clients'; |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * Returns the URL to the App Store for the iOS Client |
|
41 | + * @return string URL |
|
42 | + */ |
|
43 | + public function getiOSClientUrl() { |
|
44 | + return 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8'; |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Returns the AppId for the App Store for the iOS Client |
|
49 | + * @return string AppId |
|
50 | + */ |
|
51 | + public function getiTunesAppId() { |
|
52 | + return '1125420102'; |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Returns the URL to Google Play for the Android Client |
|
57 | + * @return string URL |
|
58 | + */ |
|
59 | + public function getAndroidClientUrl() { |
|
60 | + return 'https://play.google.com/store/apps/details?id=com.nextcloud.client'; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Returns the documentation URL |
|
65 | + * @return string URL |
|
66 | + */ |
|
67 | + public function getDocBaseUrl() { |
|
68 | + return 'https://docs.nextcloud.com'; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * Returns the title |
|
73 | + * @return string title |
|
74 | + */ |
|
75 | + public function getTitle() { |
|
76 | + return 'Custom Cloud'; |
|
77 | + } |
|
78 | + |
|
79 | + /** |
|
80 | + * Returns the short name of the software |
|
81 | + * @return string title |
|
82 | + */ |
|
83 | + public function getName() { |
|
84 | + return 'Custom Cloud'; |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Returns the short name of the software containing HTML strings |
|
89 | + * @return string title |
|
90 | + */ |
|
91 | + public function getHTMLName() { |
|
92 | + return 'Custom Cloud'; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Returns entity (e.g. company name) - used for footer, copyright |
|
97 | + * @return string entity name |
|
98 | + */ |
|
99 | + public function getEntity() { |
|
100 | + return 'Custom Cloud Co.'; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Returns slogan |
|
105 | + * @return string slogan |
|
106 | + */ |
|
107 | + public function getSlogan() { |
|
108 | + return 'Your custom cloud, personalized for you!'; |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Returns logo claim |
|
113 | + * @return string logo claim |
|
114 | + */ |
|
115 | + public function getLogoClaim() { |
|
116 | + return ''; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * Returns short version of the footer |
|
121 | + * @return string short footer |
|
122 | + */ |
|
123 | + public function getShortFooter() { |
|
124 | + $footer = '© 2016 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'. |
|
125 | + '<br/>' . $this->getSlogan(); |
|
126 | + |
|
127 | + return $footer; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Returns long version of the footer |
|
132 | + * @return string long footer |
|
133 | + */ |
|
134 | + public function getLongFooter() { |
|
135 | + $footer = '© 2016 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'. |
|
136 | + '<br/>' . $this->getSlogan(); |
|
137 | + |
|
138 | + return $footer; |
|
139 | + } |
|
140 | + |
|
141 | + public function buildDocLinkToKey($key) { |
|
142 | + return $this->getDocBaseUrl() . '/server/11/go.php?to=' . $key; |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * Returns mail header color |
|
148 | + * @return string |
|
149 | + */ |
|
150 | + public function getMailHeaderColor() { |
|
151 | + return '#745bca'; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * Returns variables to overload defaults from core/css/variables.scss |
|
156 | + * @return array |
|
157 | + */ |
|
158 | + public function getScssVariables() { |
|
159 | + return [ |
|
160 | + 'color-primary' => '#745bca' |
|
161 | + ]; |
|
162 | + } |
|
163 | 163 | |
164 | 164 | } |
@@ -31,269 +31,269 @@ |
||
31 | 31 | */ |
32 | 32 | class OC_Defaults { |
33 | 33 | |
34 | - private $theme; |
|
35 | - private $l; |
|
34 | + private $theme; |
|
35 | + private $l; |
|
36 | 36 | |
37 | - private $defaultEntity; |
|
38 | - private $defaultName; |
|
39 | - private $defaultTitle; |
|
40 | - private $defaultBaseUrl; |
|
41 | - private $defaultSyncClientUrl; |
|
42 | - private $defaultiOSClientUrl; |
|
43 | - private $defaultiTunesAppId; |
|
44 | - private $defaultAndroidClientUrl; |
|
45 | - private $defaultDocBaseUrl; |
|
46 | - private $defaultDocVersion; |
|
47 | - private $defaultSlogan; |
|
48 | - private $defaultLogoClaim; |
|
49 | - private $defaultMailHeaderColor; |
|
37 | + private $defaultEntity; |
|
38 | + private $defaultName; |
|
39 | + private $defaultTitle; |
|
40 | + private $defaultBaseUrl; |
|
41 | + private $defaultSyncClientUrl; |
|
42 | + private $defaultiOSClientUrl; |
|
43 | + private $defaultiTunesAppId; |
|
44 | + private $defaultAndroidClientUrl; |
|
45 | + private $defaultDocBaseUrl; |
|
46 | + private $defaultDocVersion; |
|
47 | + private $defaultSlogan; |
|
48 | + private $defaultLogoClaim; |
|
49 | + private $defaultMailHeaderColor; |
|
50 | 50 | |
51 | - function __construct() { |
|
52 | - $this->l = \OC::$server->getL10N('lib'); |
|
51 | + function __construct() { |
|
52 | + $this->l = \OC::$server->getL10N('lib'); |
|
53 | 53 | |
54 | - $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */ |
|
55 | - $this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */ |
|
56 | - $this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */ |
|
57 | - $this->defaultBaseUrl = 'https://nextcloud.com'; |
|
58 | - $this->defaultSyncClientUrl = 'https://nextcloud.com/install/#install-clients'; |
|
59 | - $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8'; |
|
60 | - $this->defaultiTunesAppId = '1125420102'; |
|
61 | - $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.nextcloud.client'; |
|
62 | - $this->defaultDocBaseUrl = 'https://docs.nextcloud.com'; |
|
63 | - $this->defaultDocVersion = '11'; // used to generate doc links |
|
64 | - $this->defaultSlogan = $this->l->t('a safe home for all your data'); |
|
65 | - $this->defaultLogoClaim = ''; |
|
66 | - $this->defaultMailHeaderColor = '#0082c9'; /* header color of mail notifications */ |
|
54 | + $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */ |
|
55 | + $this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */ |
|
56 | + $this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */ |
|
57 | + $this->defaultBaseUrl = 'https://nextcloud.com'; |
|
58 | + $this->defaultSyncClientUrl = 'https://nextcloud.com/install/#install-clients'; |
|
59 | + $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8'; |
|
60 | + $this->defaultiTunesAppId = '1125420102'; |
|
61 | + $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.nextcloud.client'; |
|
62 | + $this->defaultDocBaseUrl = 'https://docs.nextcloud.com'; |
|
63 | + $this->defaultDocVersion = '11'; // used to generate doc links |
|
64 | + $this->defaultSlogan = $this->l->t('a safe home for all your data'); |
|
65 | + $this->defaultLogoClaim = ''; |
|
66 | + $this->defaultMailHeaderColor = '#0082c9'; /* header color of mail notifications */ |
|
67 | 67 | |
68 | - $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php'; |
|
69 | - if (file_exists($themePath)) { |
|
70 | - // prevent defaults.php from printing output |
|
71 | - ob_start(); |
|
72 | - require_once $themePath; |
|
73 | - ob_end_clean(); |
|
74 | - if (class_exists('OC_Theme')) { |
|
75 | - $this->theme = new OC_Theme(); |
|
76 | - } |
|
77 | - } |
|
78 | - } |
|
68 | + $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php'; |
|
69 | + if (file_exists($themePath)) { |
|
70 | + // prevent defaults.php from printing output |
|
71 | + ob_start(); |
|
72 | + require_once $themePath; |
|
73 | + ob_end_clean(); |
|
74 | + if (class_exists('OC_Theme')) { |
|
75 | + $this->theme = new OC_Theme(); |
|
76 | + } |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @param string $method |
|
82 | - */ |
|
83 | - private function themeExist($method) { |
|
84 | - if (isset($this->theme) && method_exists($this->theme, $method)) { |
|
85 | - return true; |
|
86 | - } |
|
87 | - return false; |
|
88 | - } |
|
80 | + /** |
|
81 | + * @param string $method |
|
82 | + */ |
|
83 | + private function themeExist($method) { |
|
84 | + if (isset($this->theme) && method_exists($this->theme, $method)) { |
|
85 | + return true; |
|
86 | + } |
|
87 | + return false; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * Returns the base URL |
|
92 | - * @return string URL |
|
93 | - */ |
|
94 | - public function getBaseUrl() { |
|
95 | - if ($this->themeExist('getBaseUrl')) { |
|
96 | - return $this->theme->getBaseUrl(); |
|
97 | - } else { |
|
98 | - return $this->defaultBaseUrl; |
|
99 | - } |
|
100 | - } |
|
90 | + /** |
|
91 | + * Returns the base URL |
|
92 | + * @return string URL |
|
93 | + */ |
|
94 | + public function getBaseUrl() { |
|
95 | + if ($this->themeExist('getBaseUrl')) { |
|
96 | + return $this->theme->getBaseUrl(); |
|
97 | + } else { |
|
98 | + return $this->defaultBaseUrl; |
|
99 | + } |
|
100 | + } |
|
101 | 101 | |
102 | - /** |
|
103 | - * Returns the URL where the sync clients are listed |
|
104 | - * @return string URL |
|
105 | - */ |
|
106 | - public function getSyncClientUrl() { |
|
107 | - if ($this->themeExist('getSyncClientUrl')) { |
|
108 | - return $this->theme->getSyncClientUrl(); |
|
109 | - } else { |
|
110 | - return $this->defaultSyncClientUrl; |
|
111 | - } |
|
112 | - } |
|
102 | + /** |
|
103 | + * Returns the URL where the sync clients are listed |
|
104 | + * @return string URL |
|
105 | + */ |
|
106 | + public function getSyncClientUrl() { |
|
107 | + if ($this->themeExist('getSyncClientUrl')) { |
|
108 | + return $this->theme->getSyncClientUrl(); |
|
109 | + } else { |
|
110 | + return $this->defaultSyncClientUrl; |
|
111 | + } |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * Returns the URL to the App Store for the iOS Client |
|
116 | - * @return string URL |
|
117 | - */ |
|
118 | - public function getiOSClientUrl() { |
|
119 | - if ($this->themeExist('getiOSClientUrl')) { |
|
120 | - return $this->theme->getiOSClientUrl(); |
|
121 | - } else { |
|
122 | - return $this->defaultiOSClientUrl; |
|
123 | - } |
|
124 | - } |
|
114 | + /** |
|
115 | + * Returns the URL to the App Store for the iOS Client |
|
116 | + * @return string URL |
|
117 | + */ |
|
118 | + public function getiOSClientUrl() { |
|
119 | + if ($this->themeExist('getiOSClientUrl')) { |
|
120 | + return $this->theme->getiOSClientUrl(); |
|
121 | + } else { |
|
122 | + return $this->defaultiOSClientUrl; |
|
123 | + } |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * Returns the AppId for the App Store for the iOS Client |
|
128 | - * @return string AppId |
|
129 | - */ |
|
130 | - public function getiTunesAppId() { |
|
131 | - if ($this->themeExist('getiTunesAppId')) { |
|
132 | - return $this->theme->getiTunesAppId(); |
|
133 | - } else { |
|
134 | - return $this->defaultiTunesAppId; |
|
135 | - } |
|
136 | - } |
|
126 | + /** |
|
127 | + * Returns the AppId for the App Store for the iOS Client |
|
128 | + * @return string AppId |
|
129 | + */ |
|
130 | + public function getiTunesAppId() { |
|
131 | + if ($this->themeExist('getiTunesAppId')) { |
|
132 | + return $this->theme->getiTunesAppId(); |
|
133 | + } else { |
|
134 | + return $this->defaultiTunesAppId; |
|
135 | + } |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * Returns the URL to Google Play for the Android Client |
|
140 | - * @return string URL |
|
141 | - */ |
|
142 | - public function getAndroidClientUrl() { |
|
143 | - if ($this->themeExist('getAndroidClientUrl')) { |
|
144 | - return $this->theme->getAndroidClientUrl(); |
|
145 | - } else { |
|
146 | - return $this->defaultAndroidClientUrl; |
|
147 | - } |
|
148 | - } |
|
138 | + /** |
|
139 | + * Returns the URL to Google Play for the Android Client |
|
140 | + * @return string URL |
|
141 | + */ |
|
142 | + public function getAndroidClientUrl() { |
|
143 | + if ($this->themeExist('getAndroidClientUrl')) { |
|
144 | + return $this->theme->getAndroidClientUrl(); |
|
145 | + } else { |
|
146 | + return $this->defaultAndroidClientUrl; |
|
147 | + } |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * Returns the documentation URL |
|
152 | - * @return string URL |
|
153 | - */ |
|
154 | - public function getDocBaseUrl() { |
|
155 | - if ($this->themeExist('getDocBaseUrl')) { |
|
156 | - return $this->theme->getDocBaseUrl(); |
|
157 | - } else { |
|
158 | - return $this->defaultDocBaseUrl; |
|
159 | - } |
|
160 | - } |
|
150 | + /** |
|
151 | + * Returns the documentation URL |
|
152 | + * @return string URL |
|
153 | + */ |
|
154 | + public function getDocBaseUrl() { |
|
155 | + if ($this->themeExist('getDocBaseUrl')) { |
|
156 | + return $this->theme->getDocBaseUrl(); |
|
157 | + } else { |
|
158 | + return $this->defaultDocBaseUrl; |
|
159 | + } |
|
160 | + } |
|
161 | 161 | |
162 | - /** |
|
163 | - * Returns the title |
|
164 | - * @return string title |
|
165 | - */ |
|
166 | - public function getTitle() { |
|
167 | - if ($this->themeExist('getTitle')) { |
|
168 | - return $this->theme->getTitle(); |
|
169 | - } else { |
|
170 | - return $this->defaultTitle; |
|
171 | - } |
|
172 | - } |
|
162 | + /** |
|
163 | + * Returns the title |
|
164 | + * @return string title |
|
165 | + */ |
|
166 | + public function getTitle() { |
|
167 | + if ($this->themeExist('getTitle')) { |
|
168 | + return $this->theme->getTitle(); |
|
169 | + } else { |
|
170 | + return $this->defaultTitle; |
|
171 | + } |
|
172 | + } |
|
173 | 173 | |
174 | - /** |
|
175 | - * Returns the short name of the software |
|
176 | - * @return string title |
|
177 | - */ |
|
178 | - public function getName() { |
|
179 | - if ($this->themeExist('getName')) { |
|
180 | - return $this->theme->getName(); |
|
181 | - } else { |
|
182 | - return $this->defaultName; |
|
183 | - } |
|
184 | - } |
|
174 | + /** |
|
175 | + * Returns the short name of the software |
|
176 | + * @return string title |
|
177 | + */ |
|
178 | + public function getName() { |
|
179 | + if ($this->themeExist('getName')) { |
|
180 | + return $this->theme->getName(); |
|
181 | + } else { |
|
182 | + return $this->defaultName; |
|
183 | + } |
|
184 | + } |
|
185 | 185 | |
186 | - /** |
|
187 | - * Returns the short name of the software containing HTML strings |
|
188 | - * @return string title |
|
189 | - */ |
|
190 | - public function getHTMLName() { |
|
191 | - if ($this->themeExist('getHTMLName')) { |
|
192 | - return $this->theme->getHTMLName(); |
|
193 | - } else { |
|
194 | - return $this->defaultName; |
|
195 | - } |
|
196 | - } |
|
186 | + /** |
|
187 | + * Returns the short name of the software containing HTML strings |
|
188 | + * @return string title |
|
189 | + */ |
|
190 | + public function getHTMLName() { |
|
191 | + if ($this->themeExist('getHTMLName')) { |
|
192 | + return $this->theme->getHTMLName(); |
|
193 | + } else { |
|
194 | + return $this->defaultName; |
|
195 | + } |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * Returns entity (e.g. company name) - used for footer, copyright |
|
200 | - * @return string entity name |
|
201 | - */ |
|
202 | - public function getEntity() { |
|
203 | - if ($this->themeExist('getEntity')) { |
|
204 | - return $this->theme->getEntity(); |
|
205 | - } else { |
|
206 | - return $this->defaultEntity; |
|
207 | - } |
|
208 | - } |
|
198 | + /** |
|
199 | + * Returns entity (e.g. company name) - used for footer, copyright |
|
200 | + * @return string entity name |
|
201 | + */ |
|
202 | + public function getEntity() { |
|
203 | + if ($this->themeExist('getEntity')) { |
|
204 | + return $this->theme->getEntity(); |
|
205 | + } else { |
|
206 | + return $this->defaultEntity; |
|
207 | + } |
|
208 | + } |
|
209 | 209 | |
210 | - /** |
|
211 | - * Returns slogan |
|
212 | - * @return string slogan |
|
213 | - */ |
|
214 | - public function getSlogan() { |
|
215 | - if ($this->themeExist('getSlogan')) { |
|
216 | - return $this->theme->getSlogan(); |
|
217 | - } else { |
|
218 | - return $this->defaultSlogan; |
|
219 | - } |
|
220 | - } |
|
210 | + /** |
|
211 | + * Returns slogan |
|
212 | + * @return string slogan |
|
213 | + */ |
|
214 | + public function getSlogan() { |
|
215 | + if ($this->themeExist('getSlogan')) { |
|
216 | + return $this->theme->getSlogan(); |
|
217 | + } else { |
|
218 | + return $this->defaultSlogan; |
|
219 | + } |
|
220 | + } |
|
221 | 221 | |
222 | - /** |
|
223 | - * Returns logo claim |
|
224 | - * @return string logo claim |
|
225 | - */ |
|
226 | - public function getLogoClaim() { |
|
227 | - if ($this->themeExist('getLogoClaim')) { |
|
228 | - return $this->theme->getLogoClaim(); |
|
229 | - } else { |
|
230 | - return $this->defaultLogoClaim; |
|
231 | - } |
|
232 | - } |
|
222 | + /** |
|
223 | + * Returns logo claim |
|
224 | + * @return string logo claim |
|
225 | + */ |
|
226 | + public function getLogoClaim() { |
|
227 | + if ($this->themeExist('getLogoClaim')) { |
|
228 | + return $this->theme->getLogoClaim(); |
|
229 | + } else { |
|
230 | + return $this->defaultLogoClaim; |
|
231 | + } |
|
232 | + } |
|
233 | 233 | |
234 | - /** |
|
235 | - * Returns short version of the footer |
|
236 | - * @return string short footer |
|
237 | - */ |
|
238 | - public function getShortFooter() { |
|
239 | - if ($this->themeExist('getShortFooter')) { |
|
240 | - $footer = $this->theme->getShortFooter(); |
|
241 | - } else { |
|
242 | - $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
243 | - ' rel="noreferrer">' .$this->getEntity() . '</a>'. |
|
244 | - ' – ' . $this->getSlogan(); |
|
245 | - } |
|
234 | + /** |
|
235 | + * Returns short version of the footer |
|
236 | + * @return string short footer |
|
237 | + */ |
|
238 | + public function getShortFooter() { |
|
239 | + if ($this->themeExist('getShortFooter')) { |
|
240 | + $footer = $this->theme->getShortFooter(); |
|
241 | + } else { |
|
242 | + $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
243 | + ' rel="noreferrer">' .$this->getEntity() . '</a>'. |
|
244 | + ' – ' . $this->getSlogan(); |
|
245 | + } |
|
246 | 246 | |
247 | - return $footer; |
|
248 | - } |
|
247 | + return $footer; |
|
248 | + } |
|
249 | 249 | |
250 | - /** |
|
251 | - * Returns long version of the footer |
|
252 | - * @return string long footer |
|
253 | - */ |
|
254 | - public function getLongFooter() { |
|
255 | - if ($this->themeExist('getLongFooter')) { |
|
256 | - $footer = $this->theme->getLongFooter(); |
|
257 | - } else { |
|
258 | - $footer = $this->getShortFooter(); |
|
259 | - } |
|
250 | + /** |
|
251 | + * Returns long version of the footer |
|
252 | + * @return string long footer |
|
253 | + */ |
|
254 | + public function getLongFooter() { |
|
255 | + if ($this->themeExist('getLongFooter')) { |
|
256 | + $footer = $this->theme->getLongFooter(); |
|
257 | + } else { |
|
258 | + $footer = $this->getShortFooter(); |
|
259 | + } |
|
260 | 260 | |
261 | - return $footer; |
|
262 | - } |
|
261 | + return $footer; |
|
262 | + } |
|
263 | 263 | |
264 | - /** |
|
265 | - * @param string $key |
|
266 | - */ |
|
267 | - public function buildDocLinkToKey($key) { |
|
268 | - if ($this->themeExist('buildDocLinkToKey')) { |
|
269 | - return $this->theme->buildDocLinkToKey($key); |
|
270 | - } |
|
271 | - return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key; |
|
272 | - } |
|
264 | + /** |
|
265 | + * @param string $key |
|
266 | + */ |
|
267 | + public function buildDocLinkToKey($key) { |
|
268 | + if ($this->themeExist('buildDocLinkToKey')) { |
|
269 | + return $this->theme->buildDocLinkToKey($key); |
|
270 | + } |
|
271 | + return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key; |
|
272 | + } |
|
273 | 273 | |
274 | - /** |
|
275 | - * Returns mail header color |
|
276 | - * @return string |
|
277 | - */ |
|
278 | - public function getMailHeaderColor() { |
|
279 | - if ($this->themeExist('getMailHeaderColor')) { |
|
280 | - return $this->theme->getMailHeaderColor(); |
|
281 | - } else { |
|
282 | - return $this->defaultMailHeaderColor; |
|
283 | - } |
|
284 | - } |
|
274 | + /** |
|
275 | + * Returns mail header color |
|
276 | + * @return string |
|
277 | + */ |
|
278 | + public function getMailHeaderColor() { |
|
279 | + if ($this->themeExist('getMailHeaderColor')) { |
|
280 | + return $this->theme->getMailHeaderColor(); |
|
281 | + } else { |
|
282 | + return $this->defaultMailHeaderColor; |
|
283 | + } |
|
284 | + } |
|
285 | 285 | |
286 | - /** |
|
287 | - * @return array scss variables to overwrite |
|
288 | - */ |
|
289 | - public function getScssVariables() { |
|
290 | - if($this->themeExist('getScssVariables')) { |
|
291 | - return $this->theme->getScssVariables(); |
|
292 | - } |
|
293 | - return []; |
|
294 | - } |
|
286 | + /** |
|
287 | + * @return array scss variables to overwrite |
|
288 | + */ |
|
289 | + public function getScssVariables() { |
|
290 | + if($this->themeExist('getScssVariables')) { |
|
291 | + return $this->theme->getScssVariables(); |
|
292 | + } |
|
293 | + return []; |
|
294 | + } |
|
295 | 295 | |
296 | - public function shouldReplaceIcons() { |
|
297 | - return false; |
|
298 | - } |
|
296 | + public function shouldReplaceIcons() { |
|
297 | + return false; |
|
298 | + } |
|
299 | 299 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $this->defaultLogoClaim = ''; |
66 | 66 | $this->defaultMailHeaderColor = '#0082c9'; /* header color of mail notifications */ |
67 | 67 | |
68 | - $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php'; |
|
68 | + $themePath = OC::$SERVERROOT.'/themes/'.OC_Util::getTheme().'/defaults.php'; |
|
69 | 69 | if (file_exists($themePath)) { |
70 | 70 | // prevent defaults.php from printing output |
71 | 71 | ob_start(); |
@@ -239,9 +239,9 @@ discard block |
||
239 | 239 | if ($this->themeExist('getShortFooter')) { |
240 | 240 | $footer = $this->theme->getShortFooter(); |
241 | 241 | } else { |
242 | - $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
243 | - ' rel="noreferrer">' .$this->getEntity() . '</a>'. |
|
244 | - ' – ' . $this->getSlogan(); |
|
242 | + $footer = '<a href="'.$this->getBaseUrl().'" target="_blank"'. |
|
243 | + ' rel="noreferrer">'.$this->getEntity().'</a>'. |
|
244 | + ' – '.$this->getSlogan(); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | return $footer; |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | if ($this->themeExist('buildDocLinkToKey')) { |
269 | 269 | return $this->theme->buildDocLinkToKey($key); |
270 | 270 | } |
271 | - return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key; |
|
271 | + return $this->getDocBaseUrl().'/server/'.$this->defaultDocVersion.'/go.php?to='.$key; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @return array scss variables to overwrite |
288 | 288 | */ |
289 | 289 | public function getScssVariables() { |
290 | - if($this->themeExist('getScssVariables')) { |
|
290 | + if ($this->themeExist('getScssVariables')) { |
|
291 | 291 | return $this->theme->getScssVariables(); |
292 | 292 | } |
293 | 293 | return []; |
@@ -95,7 +95,6 @@ |
||
95 | 95 | use OC\Tagging\TagMapper; |
96 | 96 | use OC\Template\SCSSCacher; |
97 | 97 | use OCA\Theming\ThemingDefaults; |
98 | - |
|
99 | 98 | use OCP\App\IAppManager; |
100 | 99 | use OCA\Theming\Util; |
101 | 100 | use OCP\Federation\ICloudIdManager; |
@@ -119,1609 +119,1609 @@ |
||
119 | 119 | * TODO: hookup all manager classes |
120 | 120 | */ |
121 | 121 | class Server extends ServerContainer implements IServerContainer { |
122 | - /** @var string */ |
|
123 | - private $webRoot; |
|
124 | - |
|
125 | - /** |
|
126 | - * @param string $webRoot |
|
127 | - * @param \OC\Config $config |
|
128 | - */ |
|
129 | - public function __construct($webRoot, \OC\Config $config) { |
|
130 | - parent::__construct(); |
|
131 | - $this->webRoot = $webRoot; |
|
132 | - |
|
133 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
134 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
135 | - |
|
136 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
137 | - return new PreviewManager( |
|
138 | - $c->getConfig(), |
|
139 | - $c->getRootFolder(), |
|
140 | - $c->getAppDataDir('preview'), |
|
141 | - $c->getEventDispatcher(), |
|
142 | - $c->getSession()->get('user_id') |
|
143 | - ); |
|
144 | - }); |
|
145 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
146 | - |
|
147 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
148 | - return new \OC\Preview\Watcher( |
|
149 | - $c->getAppDataDir('preview') |
|
150 | - ); |
|
151 | - }); |
|
152 | - |
|
153 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
154 | - $view = new View(); |
|
155 | - $util = new Encryption\Util( |
|
156 | - $view, |
|
157 | - $c->getUserManager(), |
|
158 | - $c->getGroupManager(), |
|
159 | - $c->getConfig() |
|
160 | - ); |
|
161 | - return new Encryption\Manager( |
|
162 | - $c->getConfig(), |
|
163 | - $c->getLogger(), |
|
164 | - $c->getL10N('core'), |
|
165 | - new View(), |
|
166 | - $util, |
|
167 | - new ArrayCache() |
|
168 | - ); |
|
169 | - }); |
|
170 | - |
|
171 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
172 | - $util = new Encryption\Util( |
|
173 | - new View(), |
|
174 | - $c->getUserManager(), |
|
175 | - $c->getGroupManager(), |
|
176 | - $c->getConfig() |
|
177 | - ); |
|
178 | - return new Encryption\File($util); |
|
179 | - }); |
|
180 | - |
|
181 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
182 | - $view = new View(); |
|
183 | - $util = new Encryption\Util( |
|
184 | - $view, |
|
185 | - $c->getUserManager(), |
|
186 | - $c->getGroupManager(), |
|
187 | - $c->getConfig() |
|
188 | - ); |
|
189 | - |
|
190 | - return new Encryption\Keys\Storage($view, $util); |
|
191 | - }); |
|
192 | - $this->registerService('TagMapper', function (Server $c) { |
|
193 | - return new TagMapper($c->getDatabaseConnection()); |
|
194 | - }); |
|
195 | - |
|
196 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
197 | - $tagMapper = $c->query('TagMapper'); |
|
198 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
199 | - }); |
|
200 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
201 | - |
|
202 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
203 | - $config = $c->getConfig(); |
|
204 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
205 | - /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
206 | - $factory = new $factoryClass($this); |
|
207 | - return $factory; |
|
208 | - }); |
|
209 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
210 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
211 | - }); |
|
212 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
213 | - |
|
214 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
215 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
216 | - }); |
|
217 | - $this->registerService('RootFolder', function (Server $c) { |
|
218 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
219 | - $view = new View(); |
|
220 | - $root = new Root( |
|
221 | - $manager, |
|
222 | - $view, |
|
223 | - null, |
|
224 | - $c->getUserMountCache(), |
|
225 | - $this->getLogger(), |
|
226 | - $this->getUserManager() |
|
227 | - ); |
|
228 | - $connector = new HookConnector($root, $view); |
|
229 | - $connector->viewToNode(); |
|
230 | - |
|
231 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
232 | - $previewConnector->connectWatcher(); |
|
233 | - |
|
234 | - return $root; |
|
235 | - }); |
|
236 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
237 | - |
|
238 | - $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
239 | - return new LazyRoot(function() use ($c) { |
|
240 | - return $c->query('RootFolder'); |
|
241 | - }); |
|
242 | - }); |
|
243 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
244 | - |
|
245 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
246 | - $config = $c->getConfig(); |
|
247 | - return new \OC\User\Manager($config); |
|
248 | - }); |
|
249 | - $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
250 | - |
|
251 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
252 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
253 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
254 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
255 | - }); |
|
256 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
257 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
258 | - }); |
|
259 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
260 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
261 | - }); |
|
262 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
263 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
264 | - }); |
|
265 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
266 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
267 | - }); |
|
268 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
269 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
270 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
271 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
272 | - }); |
|
273 | - return $groupManager; |
|
274 | - }); |
|
275 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
276 | - |
|
277 | - $this->registerService(Store::class, function(Server $c) { |
|
278 | - $session = $c->getSession(); |
|
279 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
280 | - $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
281 | - } else { |
|
282 | - $tokenProvider = null; |
|
283 | - } |
|
284 | - $logger = $c->getLogger(); |
|
285 | - return new Store($session, $logger, $tokenProvider); |
|
286 | - }); |
|
287 | - $this->registerAlias(IStore::class, Store::class); |
|
288 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
289 | - $dbConnection = $c->getDatabaseConnection(); |
|
290 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
291 | - }); |
|
292 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
293 | - $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
294 | - $crypto = $c->getCrypto(); |
|
295 | - $config = $c->getConfig(); |
|
296 | - $logger = $c->getLogger(); |
|
297 | - $timeFactory = new TimeFactory(); |
|
298 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
299 | - }); |
|
300 | - $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
301 | - |
|
302 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
303 | - $manager = $c->getUserManager(); |
|
304 | - $session = new \OC\Session\Memory(''); |
|
305 | - $timeFactory = new TimeFactory(); |
|
306 | - // Token providers might require a working database. This code |
|
307 | - // might however be called when ownCloud is not yet setup. |
|
308 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
309 | - $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
310 | - } else { |
|
311 | - $defaultTokenProvider = null; |
|
312 | - } |
|
313 | - |
|
314 | - $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
|
315 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
316 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
317 | - }); |
|
318 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
319 | - /** @var $user \OC\User\User */ |
|
320 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
321 | - }); |
|
322 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
323 | - /** @var $user \OC\User\User */ |
|
324 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
325 | - }); |
|
326 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
327 | - /** @var $user \OC\User\User */ |
|
328 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
329 | - }); |
|
330 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
331 | - /** @var $user \OC\User\User */ |
|
332 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
333 | - }); |
|
334 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
335 | - /** @var $user \OC\User\User */ |
|
336 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
337 | - }); |
|
338 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
339 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
340 | - }); |
|
341 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
342 | - /** @var $user \OC\User\User */ |
|
343 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
344 | - }); |
|
345 | - $userSession->listen('\OC\User', 'logout', function () { |
|
346 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
347 | - }); |
|
348 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
349 | - /** @var $user \OC\User\User */ |
|
350 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
|
351 | - }); |
|
352 | - return $userSession; |
|
353 | - }); |
|
354 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
355 | - |
|
356 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
357 | - return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
358 | - }); |
|
359 | - |
|
360 | - $this->registerService(\OCP\INavigationManager::class, function (Server $c) { |
|
361 | - return new \OC\NavigationManager($c->getAppManager(), |
|
362 | - $c->getURLGenerator(), |
|
363 | - $c->getL10NFactory(), |
|
364 | - $c->getUserSession(), |
|
365 | - $c->getGroupManager()); |
|
366 | - }); |
|
367 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
368 | - |
|
369 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
370 | - return new \OC\AllConfig( |
|
371 | - $c->getSystemConfig() |
|
372 | - ); |
|
373 | - }); |
|
374 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
375 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
376 | - |
|
377 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
378 | - return new \OC\SystemConfig($config); |
|
379 | - }); |
|
380 | - |
|
381 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
382 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
383 | - }); |
|
384 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
385 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
386 | - |
|
387 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
388 | - return new \OC\L10N\Factory( |
|
389 | - $c->getConfig(), |
|
390 | - $c->getRequest(), |
|
391 | - $c->getUserSession(), |
|
392 | - \OC::$SERVERROOT |
|
393 | - ); |
|
394 | - }); |
|
395 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
396 | - |
|
397 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
398 | - $config = $c->getConfig(); |
|
399 | - $cacheFactory = $c->getMemCacheFactory(); |
|
400 | - return new \OC\URLGenerator( |
|
401 | - $config, |
|
402 | - $cacheFactory |
|
403 | - ); |
|
404 | - }); |
|
405 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
406 | - |
|
407 | - $this->registerService('AppHelper', function ($c) { |
|
408 | - return new \OC\AppHelper(); |
|
409 | - }); |
|
410 | - $this->registerService('AppFetcher', function ($c) { |
|
411 | - return new AppFetcher( |
|
412 | - $this->getAppDataDir('appstore'), |
|
413 | - $this->getHTTPClientService(), |
|
414 | - $this->query(TimeFactory::class), |
|
415 | - $this->getConfig() |
|
416 | - ); |
|
417 | - }); |
|
418 | - $this->registerService('CategoryFetcher', function ($c) { |
|
419 | - return new CategoryFetcher( |
|
420 | - $this->getAppDataDir('appstore'), |
|
421 | - $this->getHTTPClientService(), |
|
422 | - $this->query(TimeFactory::class), |
|
423 | - $this->getConfig() |
|
424 | - ); |
|
425 | - }); |
|
426 | - |
|
427 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
428 | - return new Cache\File(); |
|
429 | - }); |
|
430 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
431 | - |
|
432 | - $this->registerService(Factory::class, function (Server $c) { |
|
433 | - $config = $c->getConfig(); |
|
434 | - |
|
435 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
436 | - $v = \OC_App::getAppVersions(); |
|
437 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
438 | - $version = implode(',', $v); |
|
439 | - $instanceId = \OC_Util::getInstanceId(); |
|
440 | - $path = \OC::$SERVERROOT; |
|
441 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
442 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
443 | - $config->getSystemValue('memcache.local', null), |
|
444 | - $config->getSystemValue('memcache.distributed', null), |
|
445 | - $config->getSystemValue('memcache.locking', null) |
|
446 | - ); |
|
447 | - } |
|
448 | - |
|
449 | - return new \OC\Memcache\Factory('', $c->getLogger(), |
|
450 | - '\\OC\\Memcache\\ArrayCache', |
|
451 | - '\\OC\\Memcache\\ArrayCache', |
|
452 | - '\\OC\\Memcache\\ArrayCache' |
|
453 | - ); |
|
454 | - }); |
|
455 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
456 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
457 | - |
|
458 | - $this->registerService('RedisFactory', function (Server $c) { |
|
459 | - $systemConfig = $c->getSystemConfig(); |
|
460 | - return new RedisFactory($systemConfig); |
|
461 | - }); |
|
462 | - |
|
463 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
464 | - return new \OC\Activity\Manager( |
|
465 | - $c->getRequest(), |
|
466 | - $c->getUserSession(), |
|
467 | - $c->getConfig(), |
|
468 | - $c->query(IValidator::class) |
|
469 | - ); |
|
470 | - }); |
|
471 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
472 | - |
|
473 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
474 | - return new \OC\Activity\EventMerger( |
|
475 | - $c->getL10N('lib') |
|
476 | - ); |
|
477 | - }); |
|
478 | - $this->registerAlias(IValidator::class, Validator::class); |
|
479 | - |
|
480 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
481 | - return new AvatarManager( |
|
482 | - $c->getUserManager(), |
|
483 | - $c->getAppDataDir('avatar'), |
|
484 | - $c->getL10N('lib'), |
|
485 | - $c->getLogger(), |
|
486 | - $c->getConfig() |
|
487 | - ); |
|
488 | - }); |
|
489 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
490 | - |
|
491 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
492 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
493 | - $logger = Log::getLogClass($logType); |
|
494 | - call_user_func(array($logger, 'init')); |
|
495 | - |
|
496 | - return new Log($logger); |
|
497 | - }); |
|
498 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
499 | - |
|
500 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
501 | - $config = $c->getConfig(); |
|
502 | - return new \OC\BackgroundJob\JobList( |
|
503 | - $c->getDatabaseConnection(), |
|
504 | - $config, |
|
505 | - new TimeFactory() |
|
506 | - ); |
|
507 | - }); |
|
508 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
509 | - |
|
510 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
511 | - $cacheFactory = $c->getMemCacheFactory(); |
|
512 | - $logger = $c->getLogger(); |
|
513 | - if ($cacheFactory->isAvailable()) { |
|
514 | - $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
515 | - } else { |
|
516 | - $router = new \OC\Route\Router($logger); |
|
517 | - } |
|
518 | - return $router; |
|
519 | - }); |
|
520 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
521 | - |
|
522 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
523 | - return new Search(); |
|
524 | - }); |
|
525 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
526 | - |
|
527 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
528 | - return new SecureRandom(); |
|
529 | - }); |
|
530 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
531 | - |
|
532 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
533 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
534 | - }); |
|
535 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
536 | - |
|
537 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
538 | - return new Hasher($c->getConfig()); |
|
539 | - }); |
|
540 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
541 | - |
|
542 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
543 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
544 | - }); |
|
545 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
546 | - |
|
547 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
548 | - $systemConfig = $c->getSystemConfig(); |
|
549 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
550 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
551 | - if (!$factory->isValidType($type)) { |
|
552 | - throw new \OC\DatabaseException('Invalid database type'); |
|
553 | - } |
|
554 | - $connectionParams = $factory->createConnectionParams(); |
|
555 | - $connection = $factory->getConnection($type, $connectionParams); |
|
556 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
557 | - return $connection; |
|
558 | - }); |
|
559 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
560 | - |
|
561 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
562 | - $config = $c->getConfig(); |
|
563 | - return new HTTPHelper( |
|
564 | - $config, |
|
565 | - $c->getHTTPClientService() |
|
566 | - ); |
|
567 | - }); |
|
568 | - |
|
569 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
570 | - $user = \OC_User::getUser(); |
|
571 | - $uid = $user ? $user : null; |
|
572 | - return new ClientService( |
|
573 | - $c->getConfig(), |
|
574 | - new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
575 | - ); |
|
576 | - }); |
|
577 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
578 | - |
|
579 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
580 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
581 | - return new EventLogger(); |
|
582 | - } else { |
|
583 | - return new NullEventLogger(); |
|
584 | - } |
|
585 | - }); |
|
586 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
587 | - |
|
588 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
589 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
590 | - return new QueryLogger(); |
|
591 | - } else { |
|
592 | - return new NullQueryLogger(); |
|
593 | - } |
|
594 | - }); |
|
595 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
596 | - |
|
597 | - $this->registerService(TempManager::class, function (Server $c) { |
|
598 | - return new TempManager( |
|
599 | - $c->getLogger(), |
|
600 | - $c->getConfig() |
|
601 | - ); |
|
602 | - }); |
|
603 | - $this->registerAlias('TempManager', TempManager::class); |
|
604 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
605 | - |
|
606 | - $this->registerService(AppManager::class, function (Server $c) { |
|
607 | - return new \OC\App\AppManager( |
|
608 | - $c->getUserSession(), |
|
609 | - $c->getAppConfig(), |
|
610 | - $c->getGroupManager(), |
|
611 | - $c->getMemCacheFactory(), |
|
612 | - $c->getEventDispatcher() |
|
613 | - ); |
|
614 | - }); |
|
615 | - $this->registerAlias('AppManager', AppManager::class); |
|
616 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
617 | - |
|
618 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
619 | - return new DateTimeZone( |
|
620 | - $c->getConfig(), |
|
621 | - $c->getSession() |
|
622 | - ); |
|
623 | - }); |
|
624 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
625 | - |
|
626 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
627 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
628 | - |
|
629 | - return new DateTimeFormatter( |
|
630 | - $c->getDateTimeZone()->getTimeZone(), |
|
631 | - $c->getL10N('lib', $language) |
|
632 | - ); |
|
633 | - }); |
|
634 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
635 | - |
|
636 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
637 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
638 | - $listener = new UserMountCacheListener($mountCache); |
|
639 | - $listener->listen($c->getUserManager()); |
|
640 | - return $mountCache; |
|
641 | - }); |
|
642 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
643 | - |
|
644 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
645 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
646 | - $mountCache = $c->query('UserMountCache'); |
|
647 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
648 | - |
|
649 | - // builtin providers |
|
650 | - |
|
651 | - $config = $c->getConfig(); |
|
652 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
653 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
654 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
655 | - |
|
656 | - return $manager; |
|
657 | - }); |
|
658 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
659 | - |
|
660 | - $this->registerService('IniWrapper', function ($c) { |
|
661 | - return new IniGetWrapper(); |
|
662 | - }); |
|
663 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
664 | - $jobList = $c->getJobList(); |
|
665 | - return new AsyncBus($jobList); |
|
666 | - }); |
|
667 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
668 | - return new TrustedDomainHelper($this->getConfig()); |
|
669 | - }); |
|
670 | - $this->registerService('Throttler', function(Server $c) { |
|
671 | - return new Throttler( |
|
672 | - $c->getDatabaseConnection(), |
|
673 | - new TimeFactory(), |
|
674 | - $c->getLogger(), |
|
675 | - $c->getConfig() |
|
676 | - ); |
|
677 | - }); |
|
678 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
679 | - // IConfig and IAppManager requires a working database. This code |
|
680 | - // might however be called when ownCloud is not yet setup. |
|
681 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
682 | - $config = $c->getConfig(); |
|
683 | - $appManager = $c->getAppManager(); |
|
684 | - } else { |
|
685 | - $config = null; |
|
686 | - $appManager = null; |
|
687 | - } |
|
688 | - |
|
689 | - return new Checker( |
|
690 | - new EnvironmentHelper(), |
|
691 | - new FileAccessHelper(), |
|
692 | - new AppLocator(), |
|
693 | - $config, |
|
694 | - $c->getMemCacheFactory(), |
|
695 | - $appManager, |
|
696 | - $c->getTempManager() |
|
697 | - ); |
|
698 | - }); |
|
699 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
700 | - if (isset($this['urlParams'])) { |
|
701 | - $urlParams = $this['urlParams']; |
|
702 | - } else { |
|
703 | - $urlParams = []; |
|
704 | - } |
|
705 | - |
|
706 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
707 | - && in_array('fakeinput', stream_get_wrappers()) |
|
708 | - ) { |
|
709 | - $stream = 'fakeinput://data'; |
|
710 | - } else { |
|
711 | - $stream = 'php://input'; |
|
712 | - } |
|
713 | - |
|
714 | - return new Request( |
|
715 | - [ |
|
716 | - 'get' => $_GET, |
|
717 | - 'post' => $_POST, |
|
718 | - 'files' => $_FILES, |
|
719 | - 'server' => $_SERVER, |
|
720 | - 'env' => $_ENV, |
|
721 | - 'cookies' => $_COOKIE, |
|
722 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
723 | - ? $_SERVER['REQUEST_METHOD'] |
|
724 | - : null, |
|
725 | - 'urlParams' => $urlParams, |
|
726 | - ], |
|
727 | - $this->getSecureRandom(), |
|
728 | - $this->getConfig(), |
|
729 | - $this->getCsrfTokenManager(), |
|
730 | - $stream |
|
731 | - ); |
|
732 | - }); |
|
733 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
734 | - |
|
735 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
736 | - return new Mailer( |
|
737 | - $c->getConfig(), |
|
738 | - $c->getLogger(), |
|
739 | - $c->getThemingDefaults() |
|
740 | - ); |
|
741 | - }); |
|
742 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
743 | - |
|
744 | - $this->registerService('LDAPProvider', function(Server $c) { |
|
745 | - $config = $c->getConfig(); |
|
746 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
747 | - if(is_null($factoryClass)) { |
|
748 | - throw new \Exception('ldapProviderFactory not set'); |
|
749 | - } |
|
750 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
751 | - $factory = new $factoryClass($this); |
|
752 | - return $factory->getLDAPProvider(); |
|
753 | - }); |
|
754 | - $this->registerService('LockingProvider', function (Server $c) { |
|
755 | - $ini = $c->getIniWrapper(); |
|
756 | - $config = $c->getConfig(); |
|
757 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
758 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
759 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
760 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
761 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
762 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
763 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
764 | - } |
|
765 | - return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
766 | - } |
|
767 | - return new NoopLockingProvider(); |
|
768 | - }); |
|
769 | - |
|
770 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
771 | - return new \OC\Files\Mount\Manager(); |
|
772 | - }); |
|
773 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
774 | - |
|
775 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
776 | - return new \OC\Files\Type\Detection( |
|
777 | - $c->getURLGenerator(), |
|
778 | - \OC::$configDir, |
|
779 | - \OC::$SERVERROOT . '/resources/config/' |
|
780 | - ); |
|
781 | - }); |
|
782 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
783 | - |
|
784 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
785 | - return new \OC\Files\Type\Loader( |
|
786 | - $c->getDatabaseConnection() |
|
787 | - ); |
|
788 | - }); |
|
789 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
790 | - |
|
791 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
792 | - return new Manager( |
|
793 | - $c->query(IValidator::class) |
|
794 | - ); |
|
795 | - }); |
|
796 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
797 | - |
|
798 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
799 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
800 | - $manager->registerCapability(function () use ($c) { |
|
801 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
802 | - }); |
|
803 | - return $manager; |
|
804 | - }); |
|
805 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
806 | - |
|
807 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
808 | - $config = $c->getConfig(); |
|
809 | - $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
810 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
811 | - $factory = new $factoryClass($this); |
|
812 | - return $factory->getManager(); |
|
813 | - }); |
|
814 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
815 | - |
|
816 | - $this->registerService('ThemingDefaults', function(Server $c) { |
|
817 | - /* |
|
122 | + /** @var string */ |
|
123 | + private $webRoot; |
|
124 | + |
|
125 | + /** |
|
126 | + * @param string $webRoot |
|
127 | + * @param \OC\Config $config |
|
128 | + */ |
|
129 | + public function __construct($webRoot, \OC\Config $config) { |
|
130 | + parent::__construct(); |
|
131 | + $this->webRoot = $webRoot; |
|
132 | + |
|
133 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
134 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
135 | + |
|
136 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
137 | + return new PreviewManager( |
|
138 | + $c->getConfig(), |
|
139 | + $c->getRootFolder(), |
|
140 | + $c->getAppDataDir('preview'), |
|
141 | + $c->getEventDispatcher(), |
|
142 | + $c->getSession()->get('user_id') |
|
143 | + ); |
|
144 | + }); |
|
145 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
146 | + |
|
147 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
148 | + return new \OC\Preview\Watcher( |
|
149 | + $c->getAppDataDir('preview') |
|
150 | + ); |
|
151 | + }); |
|
152 | + |
|
153 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
154 | + $view = new View(); |
|
155 | + $util = new Encryption\Util( |
|
156 | + $view, |
|
157 | + $c->getUserManager(), |
|
158 | + $c->getGroupManager(), |
|
159 | + $c->getConfig() |
|
160 | + ); |
|
161 | + return new Encryption\Manager( |
|
162 | + $c->getConfig(), |
|
163 | + $c->getLogger(), |
|
164 | + $c->getL10N('core'), |
|
165 | + new View(), |
|
166 | + $util, |
|
167 | + new ArrayCache() |
|
168 | + ); |
|
169 | + }); |
|
170 | + |
|
171 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
172 | + $util = new Encryption\Util( |
|
173 | + new View(), |
|
174 | + $c->getUserManager(), |
|
175 | + $c->getGroupManager(), |
|
176 | + $c->getConfig() |
|
177 | + ); |
|
178 | + return new Encryption\File($util); |
|
179 | + }); |
|
180 | + |
|
181 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
182 | + $view = new View(); |
|
183 | + $util = new Encryption\Util( |
|
184 | + $view, |
|
185 | + $c->getUserManager(), |
|
186 | + $c->getGroupManager(), |
|
187 | + $c->getConfig() |
|
188 | + ); |
|
189 | + |
|
190 | + return new Encryption\Keys\Storage($view, $util); |
|
191 | + }); |
|
192 | + $this->registerService('TagMapper', function (Server $c) { |
|
193 | + return new TagMapper($c->getDatabaseConnection()); |
|
194 | + }); |
|
195 | + |
|
196 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
197 | + $tagMapper = $c->query('TagMapper'); |
|
198 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
199 | + }); |
|
200 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
201 | + |
|
202 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
203 | + $config = $c->getConfig(); |
|
204 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
205 | + /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
206 | + $factory = new $factoryClass($this); |
|
207 | + return $factory; |
|
208 | + }); |
|
209 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
210 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
211 | + }); |
|
212 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
213 | + |
|
214 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
215 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
216 | + }); |
|
217 | + $this->registerService('RootFolder', function (Server $c) { |
|
218 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
219 | + $view = new View(); |
|
220 | + $root = new Root( |
|
221 | + $manager, |
|
222 | + $view, |
|
223 | + null, |
|
224 | + $c->getUserMountCache(), |
|
225 | + $this->getLogger(), |
|
226 | + $this->getUserManager() |
|
227 | + ); |
|
228 | + $connector = new HookConnector($root, $view); |
|
229 | + $connector->viewToNode(); |
|
230 | + |
|
231 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
232 | + $previewConnector->connectWatcher(); |
|
233 | + |
|
234 | + return $root; |
|
235 | + }); |
|
236 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
237 | + |
|
238 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
239 | + return new LazyRoot(function() use ($c) { |
|
240 | + return $c->query('RootFolder'); |
|
241 | + }); |
|
242 | + }); |
|
243 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
244 | + |
|
245 | + $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
246 | + $config = $c->getConfig(); |
|
247 | + return new \OC\User\Manager($config); |
|
248 | + }); |
|
249 | + $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
250 | + |
|
251 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
252 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
253 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
254 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
255 | + }); |
|
256 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
257 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
258 | + }); |
|
259 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
260 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
261 | + }); |
|
262 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
263 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
264 | + }); |
|
265 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
266 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
267 | + }); |
|
268 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
269 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
270 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
271 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
272 | + }); |
|
273 | + return $groupManager; |
|
274 | + }); |
|
275 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
276 | + |
|
277 | + $this->registerService(Store::class, function(Server $c) { |
|
278 | + $session = $c->getSession(); |
|
279 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
280 | + $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
281 | + } else { |
|
282 | + $tokenProvider = null; |
|
283 | + } |
|
284 | + $logger = $c->getLogger(); |
|
285 | + return new Store($session, $logger, $tokenProvider); |
|
286 | + }); |
|
287 | + $this->registerAlias(IStore::class, Store::class); |
|
288 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
289 | + $dbConnection = $c->getDatabaseConnection(); |
|
290 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
291 | + }); |
|
292 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
293 | + $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
294 | + $crypto = $c->getCrypto(); |
|
295 | + $config = $c->getConfig(); |
|
296 | + $logger = $c->getLogger(); |
|
297 | + $timeFactory = new TimeFactory(); |
|
298 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
299 | + }); |
|
300 | + $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
301 | + |
|
302 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
303 | + $manager = $c->getUserManager(); |
|
304 | + $session = new \OC\Session\Memory(''); |
|
305 | + $timeFactory = new TimeFactory(); |
|
306 | + // Token providers might require a working database. This code |
|
307 | + // might however be called when ownCloud is not yet setup. |
|
308 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
309 | + $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
310 | + } else { |
|
311 | + $defaultTokenProvider = null; |
|
312 | + } |
|
313 | + |
|
314 | + $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
|
315 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
316 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
317 | + }); |
|
318 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
319 | + /** @var $user \OC\User\User */ |
|
320 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
321 | + }); |
|
322 | + $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
323 | + /** @var $user \OC\User\User */ |
|
324 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
325 | + }); |
|
326 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
327 | + /** @var $user \OC\User\User */ |
|
328 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
329 | + }); |
|
330 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
331 | + /** @var $user \OC\User\User */ |
|
332 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
333 | + }); |
|
334 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
335 | + /** @var $user \OC\User\User */ |
|
336 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
337 | + }); |
|
338 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
339 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
340 | + }); |
|
341 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
342 | + /** @var $user \OC\User\User */ |
|
343 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
344 | + }); |
|
345 | + $userSession->listen('\OC\User', 'logout', function () { |
|
346 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
347 | + }); |
|
348 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
349 | + /** @var $user \OC\User\User */ |
|
350 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
|
351 | + }); |
|
352 | + return $userSession; |
|
353 | + }); |
|
354 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
355 | + |
|
356 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
357 | + return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
358 | + }); |
|
359 | + |
|
360 | + $this->registerService(\OCP\INavigationManager::class, function (Server $c) { |
|
361 | + return new \OC\NavigationManager($c->getAppManager(), |
|
362 | + $c->getURLGenerator(), |
|
363 | + $c->getL10NFactory(), |
|
364 | + $c->getUserSession(), |
|
365 | + $c->getGroupManager()); |
|
366 | + }); |
|
367 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
368 | + |
|
369 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
370 | + return new \OC\AllConfig( |
|
371 | + $c->getSystemConfig() |
|
372 | + ); |
|
373 | + }); |
|
374 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
375 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
376 | + |
|
377 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
378 | + return new \OC\SystemConfig($config); |
|
379 | + }); |
|
380 | + |
|
381 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
382 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
383 | + }); |
|
384 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
385 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
386 | + |
|
387 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
388 | + return new \OC\L10N\Factory( |
|
389 | + $c->getConfig(), |
|
390 | + $c->getRequest(), |
|
391 | + $c->getUserSession(), |
|
392 | + \OC::$SERVERROOT |
|
393 | + ); |
|
394 | + }); |
|
395 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
396 | + |
|
397 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
398 | + $config = $c->getConfig(); |
|
399 | + $cacheFactory = $c->getMemCacheFactory(); |
|
400 | + return new \OC\URLGenerator( |
|
401 | + $config, |
|
402 | + $cacheFactory |
|
403 | + ); |
|
404 | + }); |
|
405 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
406 | + |
|
407 | + $this->registerService('AppHelper', function ($c) { |
|
408 | + return new \OC\AppHelper(); |
|
409 | + }); |
|
410 | + $this->registerService('AppFetcher', function ($c) { |
|
411 | + return new AppFetcher( |
|
412 | + $this->getAppDataDir('appstore'), |
|
413 | + $this->getHTTPClientService(), |
|
414 | + $this->query(TimeFactory::class), |
|
415 | + $this->getConfig() |
|
416 | + ); |
|
417 | + }); |
|
418 | + $this->registerService('CategoryFetcher', function ($c) { |
|
419 | + return new CategoryFetcher( |
|
420 | + $this->getAppDataDir('appstore'), |
|
421 | + $this->getHTTPClientService(), |
|
422 | + $this->query(TimeFactory::class), |
|
423 | + $this->getConfig() |
|
424 | + ); |
|
425 | + }); |
|
426 | + |
|
427 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
428 | + return new Cache\File(); |
|
429 | + }); |
|
430 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
431 | + |
|
432 | + $this->registerService(Factory::class, function (Server $c) { |
|
433 | + $config = $c->getConfig(); |
|
434 | + |
|
435 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
436 | + $v = \OC_App::getAppVersions(); |
|
437 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
438 | + $version = implode(',', $v); |
|
439 | + $instanceId = \OC_Util::getInstanceId(); |
|
440 | + $path = \OC::$SERVERROOT; |
|
441 | + $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
442 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
443 | + $config->getSystemValue('memcache.local', null), |
|
444 | + $config->getSystemValue('memcache.distributed', null), |
|
445 | + $config->getSystemValue('memcache.locking', null) |
|
446 | + ); |
|
447 | + } |
|
448 | + |
|
449 | + return new \OC\Memcache\Factory('', $c->getLogger(), |
|
450 | + '\\OC\\Memcache\\ArrayCache', |
|
451 | + '\\OC\\Memcache\\ArrayCache', |
|
452 | + '\\OC\\Memcache\\ArrayCache' |
|
453 | + ); |
|
454 | + }); |
|
455 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
456 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
457 | + |
|
458 | + $this->registerService('RedisFactory', function (Server $c) { |
|
459 | + $systemConfig = $c->getSystemConfig(); |
|
460 | + return new RedisFactory($systemConfig); |
|
461 | + }); |
|
462 | + |
|
463 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
464 | + return new \OC\Activity\Manager( |
|
465 | + $c->getRequest(), |
|
466 | + $c->getUserSession(), |
|
467 | + $c->getConfig(), |
|
468 | + $c->query(IValidator::class) |
|
469 | + ); |
|
470 | + }); |
|
471 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
472 | + |
|
473 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
474 | + return new \OC\Activity\EventMerger( |
|
475 | + $c->getL10N('lib') |
|
476 | + ); |
|
477 | + }); |
|
478 | + $this->registerAlias(IValidator::class, Validator::class); |
|
479 | + |
|
480 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
481 | + return new AvatarManager( |
|
482 | + $c->getUserManager(), |
|
483 | + $c->getAppDataDir('avatar'), |
|
484 | + $c->getL10N('lib'), |
|
485 | + $c->getLogger(), |
|
486 | + $c->getConfig() |
|
487 | + ); |
|
488 | + }); |
|
489 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
490 | + |
|
491 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
492 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
493 | + $logger = Log::getLogClass($logType); |
|
494 | + call_user_func(array($logger, 'init')); |
|
495 | + |
|
496 | + return new Log($logger); |
|
497 | + }); |
|
498 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
499 | + |
|
500 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
501 | + $config = $c->getConfig(); |
|
502 | + return new \OC\BackgroundJob\JobList( |
|
503 | + $c->getDatabaseConnection(), |
|
504 | + $config, |
|
505 | + new TimeFactory() |
|
506 | + ); |
|
507 | + }); |
|
508 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
509 | + |
|
510 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
511 | + $cacheFactory = $c->getMemCacheFactory(); |
|
512 | + $logger = $c->getLogger(); |
|
513 | + if ($cacheFactory->isAvailable()) { |
|
514 | + $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
515 | + } else { |
|
516 | + $router = new \OC\Route\Router($logger); |
|
517 | + } |
|
518 | + return $router; |
|
519 | + }); |
|
520 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
521 | + |
|
522 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
523 | + return new Search(); |
|
524 | + }); |
|
525 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
526 | + |
|
527 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
528 | + return new SecureRandom(); |
|
529 | + }); |
|
530 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
531 | + |
|
532 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
533 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
534 | + }); |
|
535 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
536 | + |
|
537 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
538 | + return new Hasher($c->getConfig()); |
|
539 | + }); |
|
540 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
541 | + |
|
542 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
543 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
544 | + }); |
|
545 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
546 | + |
|
547 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
548 | + $systemConfig = $c->getSystemConfig(); |
|
549 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
550 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
551 | + if (!$factory->isValidType($type)) { |
|
552 | + throw new \OC\DatabaseException('Invalid database type'); |
|
553 | + } |
|
554 | + $connectionParams = $factory->createConnectionParams(); |
|
555 | + $connection = $factory->getConnection($type, $connectionParams); |
|
556 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
557 | + return $connection; |
|
558 | + }); |
|
559 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
560 | + |
|
561 | + $this->registerService('HTTPHelper', function (Server $c) { |
|
562 | + $config = $c->getConfig(); |
|
563 | + return new HTTPHelper( |
|
564 | + $config, |
|
565 | + $c->getHTTPClientService() |
|
566 | + ); |
|
567 | + }); |
|
568 | + |
|
569 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
570 | + $user = \OC_User::getUser(); |
|
571 | + $uid = $user ? $user : null; |
|
572 | + return new ClientService( |
|
573 | + $c->getConfig(), |
|
574 | + new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
575 | + ); |
|
576 | + }); |
|
577 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
578 | + |
|
579 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
580 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
581 | + return new EventLogger(); |
|
582 | + } else { |
|
583 | + return new NullEventLogger(); |
|
584 | + } |
|
585 | + }); |
|
586 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
587 | + |
|
588 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
589 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
590 | + return new QueryLogger(); |
|
591 | + } else { |
|
592 | + return new NullQueryLogger(); |
|
593 | + } |
|
594 | + }); |
|
595 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
596 | + |
|
597 | + $this->registerService(TempManager::class, function (Server $c) { |
|
598 | + return new TempManager( |
|
599 | + $c->getLogger(), |
|
600 | + $c->getConfig() |
|
601 | + ); |
|
602 | + }); |
|
603 | + $this->registerAlias('TempManager', TempManager::class); |
|
604 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
605 | + |
|
606 | + $this->registerService(AppManager::class, function (Server $c) { |
|
607 | + return new \OC\App\AppManager( |
|
608 | + $c->getUserSession(), |
|
609 | + $c->getAppConfig(), |
|
610 | + $c->getGroupManager(), |
|
611 | + $c->getMemCacheFactory(), |
|
612 | + $c->getEventDispatcher() |
|
613 | + ); |
|
614 | + }); |
|
615 | + $this->registerAlias('AppManager', AppManager::class); |
|
616 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
617 | + |
|
618 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
619 | + return new DateTimeZone( |
|
620 | + $c->getConfig(), |
|
621 | + $c->getSession() |
|
622 | + ); |
|
623 | + }); |
|
624 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
625 | + |
|
626 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
627 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
628 | + |
|
629 | + return new DateTimeFormatter( |
|
630 | + $c->getDateTimeZone()->getTimeZone(), |
|
631 | + $c->getL10N('lib', $language) |
|
632 | + ); |
|
633 | + }); |
|
634 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
635 | + |
|
636 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
637 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
638 | + $listener = new UserMountCacheListener($mountCache); |
|
639 | + $listener->listen($c->getUserManager()); |
|
640 | + return $mountCache; |
|
641 | + }); |
|
642 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
643 | + |
|
644 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
645 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
646 | + $mountCache = $c->query('UserMountCache'); |
|
647 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
648 | + |
|
649 | + // builtin providers |
|
650 | + |
|
651 | + $config = $c->getConfig(); |
|
652 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
653 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
654 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
655 | + |
|
656 | + return $manager; |
|
657 | + }); |
|
658 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
659 | + |
|
660 | + $this->registerService('IniWrapper', function ($c) { |
|
661 | + return new IniGetWrapper(); |
|
662 | + }); |
|
663 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
664 | + $jobList = $c->getJobList(); |
|
665 | + return new AsyncBus($jobList); |
|
666 | + }); |
|
667 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
668 | + return new TrustedDomainHelper($this->getConfig()); |
|
669 | + }); |
|
670 | + $this->registerService('Throttler', function(Server $c) { |
|
671 | + return new Throttler( |
|
672 | + $c->getDatabaseConnection(), |
|
673 | + new TimeFactory(), |
|
674 | + $c->getLogger(), |
|
675 | + $c->getConfig() |
|
676 | + ); |
|
677 | + }); |
|
678 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
679 | + // IConfig and IAppManager requires a working database. This code |
|
680 | + // might however be called when ownCloud is not yet setup. |
|
681 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
682 | + $config = $c->getConfig(); |
|
683 | + $appManager = $c->getAppManager(); |
|
684 | + } else { |
|
685 | + $config = null; |
|
686 | + $appManager = null; |
|
687 | + } |
|
688 | + |
|
689 | + return new Checker( |
|
690 | + new EnvironmentHelper(), |
|
691 | + new FileAccessHelper(), |
|
692 | + new AppLocator(), |
|
693 | + $config, |
|
694 | + $c->getMemCacheFactory(), |
|
695 | + $appManager, |
|
696 | + $c->getTempManager() |
|
697 | + ); |
|
698 | + }); |
|
699 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
700 | + if (isset($this['urlParams'])) { |
|
701 | + $urlParams = $this['urlParams']; |
|
702 | + } else { |
|
703 | + $urlParams = []; |
|
704 | + } |
|
705 | + |
|
706 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
707 | + && in_array('fakeinput', stream_get_wrappers()) |
|
708 | + ) { |
|
709 | + $stream = 'fakeinput://data'; |
|
710 | + } else { |
|
711 | + $stream = 'php://input'; |
|
712 | + } |
|
713 | + |
|
714 | + return new Request( |
|
715 | + [ |
|
716 | + 'get' => $_GET, |
|
717 | + 'post' => $_POST, |
|
718 | + 'files' => $_FILES, |
|
719 | + 'server' => $_SERVER, |
|
720 | + 'env' => $_ENV, |
|
721 | + 'cookies' => $_COOKIE, |
|
722 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
723 | + ? $_SERVER['REQUEST_METHOD'] |
|
724 | + : null, |
|
725 | + 'urlParams' => $urlParams, |
|
726 | + ], |
|
727 | + $this->getSecureRandom(), |
|
728 | + $this->getConfig(), |
|
729 | + $this->getCsrfTokenManager(), |
|
730 | + $stream |
|
731 | + ); |
|
732 | + }); |
|
733 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
734 | + |
|
735 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
736 | + return new Mailer( |
|
737 | + $c->getConfig(), |
|
738 | + $c->getLogger(), |
|
739 | + $c->getThemingDefaults() |
|
740 | + ); |
|
741 | + }); |
|
742 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
743 | + |
|
744 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
745 | + $config = $c->getConfig(); |
|
746 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
747 | + if(is_null($factoryClass)) { |
|
748 | + throw new \Exception('ldapProviderFactory not set'); |
|
749 | + } |
|
750 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
751 | + $factory = new $factoryClass($this); |
|
752 | + return $factory->getLDAPProvider(); |
|
753 | + }); |
|
754 | + $this->registerService('LockingProvider', function (Server $c) { |
|
755 | + $ini = $c->getIniWrapper(); |
|
756 | + $config = $c->getConfig(); |
|
757 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
758 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
759 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
760 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
761 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
762 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
763 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
764 | + } |
|
765 | + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
766 | + } |
|
767 | + return new NoopLockingProvider(); |
|
768 | + }); |
|
769 | + |
|
770 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
771 | + return new \OC\Files\Mount\Manager(); |
|
772 | + }); |
|
773 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
774 | + |
|
775 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
776 | + return new \OC\Files\Type\Detection( |
|
777 | + $c->getURLGenerator(), |
|
778 | + \OC::$configDir, |
|
779 | + \OC::$SERVERROOT . '/resources/config/' |
|
780 | + ); |
|
781 | + }); |
|
782 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
783 | + |
|
784 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
785 | + return new \OC\Files\Type\Loader( |
|
786 | + $c->getDatabaseConnection() |
|
787 | + ); |
|
788 | + }); |
|
789 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
790 | + |
|
791 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
792 | + return new Manager( |
|
793 | + $c->query(IValidator::class) |
|
794 | + ); |
|
795 | + }); |
|
796 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
797 | + |
|
798 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
799 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
800 | + $manager->registerCapability(function () use ($c) { |
|
801 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
802 | + }); |
|
803 | + return $manager; |
|
804 | + }); |
|
805 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
806 | + |
|
807 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
808 | + $config = $c->getConfig(); |
|
809 | + $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
810 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
811 | + $factory = new $factoryClass($this); |
|
812 | + return $factory->getManager(); |
|
813 | + }); |
|
814 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
815 | + |
|
816 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
817 | + /* |
|
818 | 818 | * Dark magic for autoloader. |
819 | 819 | * If we do a class_exists it will try to load the class which will |
820 | 820 | * make composer cache the result. Resulting in errors when enabling |
821 | 821 | * the theming app. |
822 | 822 | */ |
823 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
824 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
825 | - $classExists = true; |
|
826 | - } else { |
|
827 | - $classExists = false; |
|
828 | - } |
|
829 | - |
|
830 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
831 | - return new ThemingDefaults( |
|
832 | - $c->getConfig(), |
|
833 | - $c->getL10N('theming'), |
|
834 | - $c->getURLGenerator(), |
|
835 | - new \OC_Defaults(), |
|
836 | - $c->getAppDataDir('theming'), |
|
837 | - $c->getMemCacheFactory(), |
|
838 | - new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager()) |
|
839 | - ); |
|
840 | - } |
|
841 | - return new \OC_Defaults(); |
|
842 | - }); |
|
843 | - $this->registerService(SCSSCacher::class, function(Server $c) { |
|
844 | - /** @var Factory $cacheFactory */ |
|
845 | - $cacheFactory = $c->query(Factory::class); |
|
846 | - return new SCSSCacher( |
|
847 | - $c->getLogger(), |
|
848 | - $c->query(\OC\Files\AppData\Factory::class), |
|
849 | - $c->getURLGenerator(), |
|
850 | - $c->getConfig(), |
|
851 | - $c->getThemingDefaults(), |
|
852 | - \OC::$SERVERROOT, |
|
853 | - $cacheFactory->createLocal('SCSS') |
|
854 | - |
|
855 | - ); |
|
856 | - }); |
|
857 | - $this->registerService(EventDispatcher::class, function () { |
|
858 | - return new EventDispatcher(); |
|
859 | - }); |
|
860 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
861 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
862 | - |
|
863 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
864 | - // FIXME: Instantiiated here due to cyclic dependency |
|
865 | - $request = new Request( |
|
866 | - [ |
|
867 | - 'get' => $_GET, |
|
868 | - 'post' => $_POST, |
|
869 | - 'files' => $_FILES, |
|
870 | - 'server' => $_SERVER, |
|
871 | - 'env' => $_ENV, |
|
872 | - 'cookies' => $_COOKIE, |
|
873 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
874 | - ? $_SERVER['REQUEST_METHOD'] |
|
875 | - : null, |
|
876 | - ], |
|
877 | - $c->getSecureRandom(), |
|
878 | - $c->getConfig() |
|
879 | - ); |
|
880 | - |
|
881 | - return new CryptoWrapper( |
|
882 | - $c->getConfig(), |
|
883 | - $c->getCrypto(), |
|
884 | - $c->getSecureRandom(), |
|
885 | - $request |
|
886 | - ); |
|
887 | - }); |
|
888 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
889 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
890 | - |
|
891 | - return new CsrfTokenManager( |
|
892 | - $tokenGenerator, |
|
893 | - $c->query(SessionStorage::class) |
|
894 | - ); |
|
895 | - }); |
|
896 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
897 | - return new SessionStorage($c->getSession()); |
|
898 | - }); |
|
899 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
900 | - return new ContentSecurityPolicyManager(); |
|
901 | - }); |
|
902 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
903 | - |
|
904 | - $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
905 | - return new ContentSecurityPolicyNonceManager( |
|
906 | - $c->getCsrfTokenManager(), |
|
907 | - $c->getRequest() |
|
908 | - ); |
|
909 | - }); |
|
910 | - |
|
911 | - $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
912 | - $config = $c->getConfig(); |
|
913 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
914 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
915 | - $factory = new $factoryClass($this); |
|
916 | - |
|
917 | - $manager = new \OC\Share20\Manager( |
|
918 | - $c->getLogger(), |
|
919 | - $c->getConfig(), |
|
920 | - $c->getSecureRandom(), |
|
921 | - $c->getHasher(), |
|
922 | - $c->getMountManager(), |
|
923 | - $c->getGroupManager(), |
|
924 | - $c->getL10N('core'), |
|
925 | - $factory, |
|
926 | - $c->getUserManager(), |
|
927 | - $c->getLazyRootFolder(), |
|
928 | - $c->getEventDispatcher() |
|
929 | - ); |
|
930 | - |
|
931 | - return $manager; |
|
932 | - }); |
|
933 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
934 | - |
|
935 | - $this->registerService('SettingsManager', function(Server $c) { |
|
936 | - $manager = new \OC\Settings\Manager( |
|
937 | - $c->getLogger(), |
|
938 | - $c->getDatabaseConnection(), |
|
939 | - $c->getL10N('lib'), |
|
940 | - $c->getConfig(), |
|
941 | - $c->getEncryptionManager(), |
|
942 | - $c->getUserManager(), |
|
943 | - $c->getLockingProvider(), |
|
944 | - $c->getRequest(), |
|
945 | - new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
946 | - $c->getURLGenerator() |
|
947 | - ); |
|
948 | - return $manager; |
|
949 | - }); |
|
950 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
951 | - return new \OC\Files\AppData\Factory( |
|
952 | - $c->getRootFolder(), |
|
953 | - $c->getSystemConfig() |
|
954 | - ); |
|
955 | - }); |
|
956 | - |
|
957 | - $this->registerService('LockdownManager', function (Server $c) { |
|
958 | - return new LockdownManager(); |
|
959 | - }); |
|
960 | - |
|
961 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
962 | - return new CloudIdManager(); |
|
963 | - }); |
|
964 | - |
|
965 | - /* To trick DI since we don't extend the DIContainer here */ |
|
966 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
967 | - return new CleanPreviewsBackgroundJob( |
|
968 | - $c->getRootFolder(), |
|
969 | - $c->getLogger(), |
|
970 | - $c->getJobList(), |
|
971 | - new TimeFactory() |
|
972 | - ); |
|
973 | - }); |
|
974 | - |
|
975 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
976 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
977 | - |
|
978 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
979 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
980 | - |
|
981 | - $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
982 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
983 | - }); |
|
984 | - } |
|
985 | - |
|
986 | - /** |
|
987 | - * @return \OCP\Contacts\IManager |
|
988 | - */ |
|
989 | - public function getContactsManager() { |
|
990 | - return $this->query('ContactsManager'); |
|
991 | - } |
|
992 | - |
|
993 | - /** |
|
994 | - * @return \OC\Encryption\Manager |
|
995 | - */ |
|
996 | - public function getEncryptionManager() { |
|
997 | - return $this->query('EncryptionManager'); |
|
998 | - } |
|
999 | - |
|
1000 | - /** |
|
1001 | - * @return \OC\Encryption\File |
|
1002 | - */ |
|
1003 | - public function getEncryptionFilesHelper() { |
|
1004 | - return $this->query('EncryptionFileHelper'); |
|
1005 | - } |
|
1006 | - |
|
1007 | - /** |
|
1008 | - * @return \OCP\Encryption\Keys\IStorage |
|
1009 | - */ |
|
1010 | - public function getEncryptionKeyStorage() { |
|
1011 | - return $this->query('EncryptionKeyStorage'); |
|
1012 | - } |
|
1013 | - |
|
1014 | - /** |
|
1015 | - * The current request object holding all information about the request |
|
1016 | - * currently being processed is returned from this method. |
|
1017 | - * In case the current execution was not initiated by a web request null is returned |
|
1018 | - * |
|
1019 | - * @return \OCP\IRequest |
|
1020 | - */ |
|
1021 | - public function getRequest() { |
|
1022 | - return $this->query('Request'); |
|
1023 | - } |
|
1024 | - |
|
1025 | - /** |
|
1026 | - * Returns the preview manager which can create preview images for a given file |
|
1027 | - * |
|
1028 | - * @return \OCP\IPreview |
|
1029 | - */ |
|
1030 | - public function getPreviewManager() { |
|
1031 | - return $this->query('PreviewManager'); |
|
1032 | - } |
|
1033 | - |
|
1034 | - /** |
|
1035 | - * Returns the tag manager which can get and set tags for different object types |
|
1036 | - * |
|
1037 | - * @see \OCP\ITagManager::load() |
|
1038 | - * @return \OCP\ITagManager |
|
1039 | - */ |
|
1040 | - public function getTagManager() { |
|
1041 | - return $this->query('TagManager'); |
|
1042 | - } |
|
1043 | - |
|
1044 | - /** |
|
1045 | - * Returns the system-tag manager |
|
1046 | - * |
|
1047 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1048 | - * |
|
1049 | - * @since 9.0.0 |
|
1050 | - */ |
|
1051 | - public function getSystemTagManager() { |
|
1052 | - return $this->query('SystemTagManager'); |
|
1053 | - } |
|
1054 | - |
|
1055 | - /** |
|
1056 | - * Returns the system-tag object mapper |
|
1057 | - * |
|
1058 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1059 | - * |
|
1060 | - * @since 9.0.0 |
|
1061 | - */ |
|
1062 | - public function getSystemTagObjectMapper() { |
|
1063 | - return $this->query('SystemTagObjectMapper'); |
|
1064 | - } |
|
1065 | - |
|
1066 | - /** |
|
1067 | - * Returns the avatar manager, used for avatar functionality |
|
1068 | - * |
|
1069 | - * @return \OCP\IAvatarManager |
|
1070 | - */ |
|
1071 | - public function getAvatarManager() { |
|
1072 | - return $this->query('AvatarManager'); |
|
1073 | - } |
|
1074 | - |
|
1075 | - /** |
|
1076 | - * Returns the root folder of ownCloud's data directory |
|
1077 | - * |
|
1078 | - * @return \OCP\Files\IRootFolder |
|
1079 | - */ |
|
1080 | - public function getRootFolder() { |
|
1081 | - return $this->query('LazyRootFolder'); |
|
1082 | - } |
|
1083 | - |
|
1084 | - /** |
|
1085 | - * Returns the root folder of ownCloud's data directory |
|
1086 | - * This is the lazy variant so this gets only initialized once it |
|
1087 | - * is actually used. |
|
1088 | - * |
|
1089 | - * @return \OCP\Files\IRootFolder |
|
1090 | - */ |
|
1091 | - public function getLazyRootFolder() { |
|
1092 | - return $this->query('LazyRootFolder'); |
|
1093 | - } |
|
1094 | - |
|
1095 | - /** |
|
1096 | - * Returns a view to ownCloud's files folder |
|
1097 | - * |
|
1098 | - * @param string $userId user ID |
|
1099 | - * @return \OCP\Files\Folder|null |
|
1100 | - */ |
|
1101 | - public function getUserFolder($userId = null) { |
|
1102 | - if ($userId === null) { |
|
1103 | - $user = $this->getUserSession()->getUser(); |
|
1104 | - if (!$user) { |
|
1105 | - return null; |
|
1106 | - } |
|
1107 | - $userId = $user->getUID(); |
|
1108 | - } |
|
1109 | - $root = $this->getRootFolder(); |
|
1110 | - return $root->getUserFolder($userId); |
|
1111 | - } |
|
1112 | - |
|
1113 | - /** |
|
1114 | - * Returns an app-specific view in ownClouds data directory |
|
1115 | - * |
|
1116 | - * @return \OCP\Files\Folder |
|
1117 | - * @deprecated since 9.2.0 use IAppData |
|
1118 | - */ |
|
1119 | - public function getAppFolder() { |
|
1120 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1121 | - $root = $this->getRootFolder(); |
|
1122 | - if (!$root->nodeExists($dir)) { |
|
1123 | - $folder = $root->newFolder($dir); |
|
1124 | - } else { |
|
1125 | - $folder = $root->get($dir); |
|
1126 | - } |
|
1127 | - return $folder; |
|
1128 | - } |
|
1129 | - |
|
1130 | - /** |
|
1131 | - * @return \OC\User\Manager |
|
1132 | - */ |
|
1133 | - public function getUserManager() { |
|
1134 | - return $this->query('UserManager'); |
|
1135 | - } |
|
1136 | - |
|
1137 | - /** |
|
1138 | - * @return \OC\Group\Manager |
|
1139 | - */ |
|
1140 | - public function getGroupManager() { |
|
1141 | - return $this->query('GroupManager'); |
|
1142 | - } |
|
1143 | - |
|
1144 | - /** |
|
1145 | - * @return \OC\User\Session |
|
1146 | - */ |
|
1147 | - public function getUserSession() { |
|
1148 | - return $this->query('UserSession'); |
|
1149 | - } |
|
1150 | - |
|
1151 | - /** |
|
1152 | - * @return \OCP\ISession |
|
1153 | - */ |
|
1154 | - public function getSession() { |
|
1155 | - return $this->query('UserSession')->getSession(); |
|
1156 | - } |
|
1157 | - |
|
1158 | - /** |
|
1159 | - * @param \OCP\ISession $session |
|
1160 | - */ |
|
1161 | - public function setSession(\OCP\ISession $session) { |
|
1162 | - $this->query(SessionStorage::class)->setSession($session); |
|
1163 | - $this->query('UserSession')->setSession($session); |
|
1164 | - $this->query(Store::class)->setSession($session); |
|
1165 | - } |
|
1166 | - |
|
1167 | - /** |
|
1168 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1169 | - */ |
|
1170 | - public function getTwoFactorAuthManager() { |
|
1171 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1172 | - } |
|
1173 | - |
|
1174 | - /** |
|
1175 | - * @return \OC\NavigationManager |
|
1176 | - */ |
|
1177 | - public function getNavigationManager() { |
|
1178 | - return $this->query('NavigationManager'); |
|
1179 | - } |
|
1180 | - |
|
1181 | - /** |
|
1182 | - * @return \OCP\IConfig |
|
1183 | - */ |
|
1184 | - public function getConfig() { |
|
1185 | - return $this->query('AllConfig'); |
|
1186 | - } |
|
1187 | - |
|
1188 | - /** |
|
1189 | - * @internal For internal use only |
|
1190 | - * @return \OC\SystemConfig |
|
1191 | - */ |
|
1192 | - public function getSystemConfig() { |
|
1193 | - return $this->query('SystemConfig'); |
|
1194 | - } |
|
1195 | - |
|
1196 | - /** |
|
1197 | - * Returns the app config manager |
|
1198 | - * |
|
1199 | - * @return \OCP\IAppConfig |
|
1200 | - */ |
|
1201 | - public function getAppConfig() { |
|
1202 | - return $this->query('AppConfig'); |
|
1203 | - } |
|
1204 | - |
|
1205 | - /** |
|
1206 | - * @return \OCP\L10N\IFactory |
|
1207 | - */ |
|
1208 | - public function getL10NFactory() { |
|
1209 | - return $this->query('L10NFactory'); |
|
1210 | - } |
|
1211 | - |
|
1212 | - /** |
|
1213 | - * get an L10N instance |
|
1214 | - * |
|
1215 | - * @param string $app appid |
|
1216 | - * @param string $lang |
|
1217 | - * @return IL10N |
|
1218 | - */ |
|
1219 | - public function getL10N($app, $lang = null) { |
|
1220 | - return $this->getL10NFactory()->get($app, $lang); |
|
1221 | - } |
|
1222 | - |
|
1223 | - /** |
|
1224 | - * @return \OCP\IURLGenerator |
|
1225 | - */ |
|
1226 | - public function getURLGenerator() { |
|
1227 | - return $this->query('URLGenerator'); |
|
1228 | - } |
|
1229 | - |
|
1230 | - /** |
|
1231 | - * @return \OCP\IHelper |
|
1232 | - */ |
|
1233 | - public function getHelper() { |
|
1234 | - return $this->query('AppHelper'); |
|
1235 | - } |
|
1236 | - |
|
1237 | - /** |
|
1238 | - * @return AppFetcher |
|
1239 | - */ |
|
1240 | - public function getAppFetcher() { |
|
1241 | - return $this->query('AppFetcher'); |
|
1242 | - } |
|
1243 | - |
|
1244 | - /** |
|
1245 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1246 | - * getMemCacheFactory() instead. |
|
1247 | - * |
|
1248 | - * @return \OCP\ICache |
|
1249 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1250 | - */ |
|
1251 | - public function getCache() { |
|
1252 | - return $this->query('UserCache'); |
|
1253 | - } |
|
1254 | - |
|
1255 | - /** |
|
1256 | - * Returns an \OCP\CacheFactory instance |
|
1257 | - * |
|
1258 | - * @return \OCP\ICacheFactory |
|
1259 | - */ |
|
1260 | - public function getMemCacheFactory() { |
|
1261 | - return $this->query('MemCacheFactory'); |
|
1262 | - } |
|
1263 | - |
|
1264 | - /** |
|
1265 | - * Returns an \OC\RedisFactory instance |
|
1266 | - * |
|
1267 | - * @return \OC\RedisFactory |
|
1268 | - */ |
|
1269 | - public function getGetRedisFactory() { |
|
1270 | - return $this->query('RedisFactory'); |
|
1271 | - } |
|
1272 | - |
|
1273 | - |
|
1274 | - /** |
|
1275 | - * Returns the current session |
|
1276 | - * |
|
1277 | - * @return \OCP\IDBConnection |
|
1278 | - */ |
|
1279 | - public function getDatabaseConnection() { |
|
1280 | - return $this->query('DatabaseConnection'); |
|
1281 | - } |
|
1282 | - |
|
1283 | - /** |
|
1284 | - * Returns the activity manager |
|
1285 | - * |
|
1286 | - * @return \OCP\Activity\IManager |
|
1287 | - */ |
|
1288 | - public function getActivityManager() { |
|
1289 | - return $this->query('ActivityManager'); |
|
1290 | - } |
|
1291 | - |
|
1292 | - /** |
|
1293 | - * Returns an job list for controlling background jobs |
|
1294 | - * |
|
1295 | - * @return \OCP\BackgroundJob\IJobList |
|
1296 | - */ |
|
1297 | - public function getJobList() { |
|
1298 | - return $this->query('JobList'); |
|
1299 | - } |
|
1300 | - |
|
1301 | - /** |
|
1302 | - * Returns a logger instance |
|
1303 | - * |
|
1304 | - * @return \OCP\ILogger |
|
1305 | - */ |
|
1306 | - public function getLogger() { |
|
1307 | - return $this->query('Logger'); |
|
1308 | - } |
|
1309 | - |
|
1310 | - /** |
|
1311 | - * Returns a router for generating and matching urls |
|
1312 | - * |
|
1313 | - * @return \OCP\Route\IRouter |
|
1314 | - */ |
|
1315 | - public function getRouter() { |
|
1316 | - return $this->query('Router'); |
|
1317 | - } |
|
1318 | - |
|
1319 | - /** |
|
1320 | - * Returns a search instance |
|
1321 | - * |
|
1322 | - * @return \OCP\ISearch |
|
1323 | - */ |
|
1324 | - public function getSearch() { |
|
1325 | - return $this->query('Search'); |
|
1326 | - } |
|
1327 | - |
|
1328 | - /** |
|
1329 | - * Returns a SecureRandom instance |
|
1330 | - * |
|
1331 | - * @return \OCP\Security\ISecureRandom |
|
1332 | - */ |
|
1333 | - public function getSecureRandom() { |
|
1334 | - return $this->query('SecureRandom'); |
|
1335 | - } |
|
1336 | - |
|
1337 | - /** |
|
1338 | - * Returns a Crypto instance |
|
1339 | - * |
|
1340 | - * @return \OCP\Security\ICrypto |
|
1341 | - */ |
|
1342 | - public function getCrypto() { |
|
1343 | - return $this->query('Crypto'); |
|
1344 | - } |
|
1345 | - |
|
1346 | - /** |
|
1347 | - * Returns a Hasher instance |
|
1348 | - * |
|
1349 | - * @return \OCP\Security\IHasher |
|
1350 | - */ |
|
1351 | - public function getHasher() { |
|
1352 | - return $this->query('Hasher'); |
|
1353 | - } |
|
1354 | - |
|
1355 | - /** |
|
1356 | - * Returns a CredentialsManager instance |
|
1357 | - * |
|
1358 | - * @return \OCP\Security\ICredentialsManager |
|
1359 | - */ |
|
1360 | - public function getCredentialsManager() { |
|
1361 | - return $this->query('CredentialsManager'); |
|
1362 | - } |
|
1363 | - |
|
1364 | - /** |
|
1365 | - * Returns an instance of the HTTP helper class |
|
1366 | - * |
|
1367 | - * @deprecated Use getHTTPClientService() |
|
1368 | - * @return \OC\HTTPHelper |
|
1369 | - */ |
|
1370 | - public function getHTTPHelper() { |
|
1371 | - return $this->query('HTTPHelper'); |
|
1372 | - } |
|
1373 | - |
|
1374 | - /** |
|
1375 | - * Get the certificate manager for the user |
|
1376 | - * |
|
1377 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1378 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1379 | - */ |
|
1380 | - public function getCertificateManager($userId = '') { |
|
1381 | - if ($userId === '') { |
|
1382 | - $userSession = $this->getUserSession(); |
|
1383 | - $user = $userSession->getUser(); |
|
1384 | - if (is_null($user)) { |
|
1385 | - return null; |
|
1386 | - } |
|
1387 | - $userId = $user->getUID(); |
|
1388 | - } |
|
1389 | - return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1390 | - } |
|
1391 | - |
|
1392 | - /** |
|
1393 | - * Returns an instance of the HTTP client service |
|
1394 | - * |
|
1395 | - * @return \OCP\Http\Client\IClientService |
|
1396 | - */ |
|
1397 | - public function getHTTPClientService() { |
|
1398 | - return $this->query('HttpClientService'); |
|
1399 | - } |
|
1400 | - |
|
1401 | - /** |
|
1402 | - * Create a new event source |
|
1403 | - * |
|
1404 | - * @return \OCP\IEventSource |
|
1405 | - */ |
|
1406 | - public function createEventSource() { |
|
1407 | - return new \OC_EventSource(); |
|
1408 | - } |
|
1409 | - |
|
1410 | - /** |
|
1411 | - * Get the active event logger |
|
1412 | - * |
|
1413 | - * The returned logger only logs data when debug mode is enabled |
|
1414 | - * |
|
1415 | - * @return \OCP\Diagnostics\IEventLogger |
|
1416 | - */ |
|
1417 | - public function getEventLogger() { |
|
1418 | - return $this->query('EventLogger'); |
|
1419 | - } |
|
1420 | - |
|
1421 | - /** |
|
1422 | - * Get the active query logger |
|
1423 | - * |
|
1424 | - * The returned logger only logs data when debug mode is enabled |
|
1425 | - * |
|
1426 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1427 | - */ |
|
1428 | - public function getQueryLogger() { |
|
1429 | - return $this->query('QueryLogger'); |
|
1430 | - } |
|
1431 | - |
|
1432 | - /** |
|
1433 | - * Get the manager for temporary files and folders |
|
1434 | - * |
|
1435 | - * @return \OCP\ITempManager |
|
1436 | - */ |
|
1437 | - public function getTempManager() { |
|
1438 | - return $this->query('TempManager'); |
|
1439 | - } |
|
1440 | - |
|
1441 | - /** |
|
1442 | - * Get the app manager |
|
1443 | - * |
|
1444 | - * @return \OCP\App\IAppManager |
|
1445 | - */ |
|
1446 | - public function getAppManager() { |
|
1447 | - return $this->query('AppManager'); |
|
1448 | - } |
|
1449 | - |
|
1450 | - /** |
|
1451 | - * Creates a new mailer |
|
1452 | - * |
|
1453 | - * @return \OCP\Mail\IMailer |
|
1454 | - */ |
|
1455 | - public function getMailer() { |
|
1456 | - return $this->query('Mailer'); |
|
1457 | - } |
|
1458 | - |
|
1459 | - /** |
|
1460 | - * Get the webroot |
|
1461 | - * |
|
1462 | - * @return string |
|
1463 | - */ |
|
1464 | - public function getWebRoot() { |
|
1465 | - return $this->webRoot; |
|
1466 | - } |
|
1467 | - |
|
1468 | - /** |
|
1469 | - * @return \OC\OCSClient |
|
1470 | - */ |
|
1471 | - public function getOcsClient() { |
|
1472 | - return $this->query('OcsClient'); |
|
1473 | - } |
|
1474 | - |
|
1475 | - /** |
|
1476 | - * @return \OCP\IDateTimeZone |
|
1477 | - */ |
|
1478 | - public function getDateTimeZone() { |
|
1479 | - return $this->query('DateTimeZone'); |
|
1480 | - } |
|
1481 | - |
|
1482 | - /** |
|
1483 | - * @return \OCP\IDateTimeFormatter |
|
1484 | - */ |
|
1485 | - public function getDateTimeFormatter() { |
|
1486 | - return $this->query('DateTimeFormatter'); |
|
1487 | - } |
|
1488 | - |
|
1489 | - /** |
|
1490 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1491 | - */ |
|
1492 | - public function getMountProviderCollection() { |
|
1493 | - return $this->query('MountConfigManager'); |
|
1494 | - } |
|
1495 | - |
|
1496 | - /** |
|
1497 | - * Get the IniWrapper |
|
1498 | - * |
|
1499 | - * @return IniGetWrapper |
|
1500 | - */ |
|
1501 | - public function getIniWrapper() { |
|
1502 | - return $this->query('IniWrapper'); |
|
1503 | - } |
|
1504 | - |
|
1505 | - /** |
|
1506 | - * @return \OCP\Command\IBus |
|
1507 | - */ |
|
1508 | - public function getCommandBus() { |
|
1509 | - return $this->query('AsyncCommandBus'); |
|
1510 | - } |
|
1511 | - |
|
1512 | - /** |
|
1513 | - * Get the trusted domain helper |
|
1514 | - * |
|
1515 | - * @return TrustedDomainHelper |
|
1516 | - */ |
|
1517 | - public function getTrustedDomainHelper() { |
|
1518 | - return $this->query('TrustedDomainHelper'); |
|
1519 | - } |
|
1520 | - |
|
1521 | - /** |
|
1522 | - * Get the locking provider |
|
1523 | - * |
|
1524 | - * @return \OCP\Lock\ILockingProvider |
|
1525 | - * @since 8.1.0 |
|
1526 | - */ |
|
1527 | - public function getLockingProvider() { |
|
1528 | - return $this->query('LockingProvider'); |
|
1529 | - } |
|
1530 | - |
|
1531 | - /** |
|
1532 | - * @return \OCP\Files\Mount\IMountManager |
|
1533 | - **/ |
|
1534 | - function getMountManager() { |
|
1535 | - return $this->query('MountManager'); |
|
1536 | - } |
|
1537 | - |
|
1538 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1539 | - function getUserMountCache() { |
|
1540 | - return $this->query('UserMountCache'); |
|
1541 | - } |
|
1542 | - |
|
1543 | - /** |
|
1544 | - * Get the MimeTypeDetector |
|
1545 | - * |
|
1546 | - * @return \OCP\Files\IMimeTypeDetector |
|
1547 | - */ |
|
1548 | - public function getMimeTypeDetector() { |
|
1549 | - return $this->query('MimeTypeDetector'); |
|
1550 | - } |
|
1551 | - |
|
1552 | - /** |
|
1553 | - * Get the MimeTypeLoader |
|
1554 | - * |
|
1555 | - * @return \OCP\Files\IMimeTypeLoader |
|
1556 | - */ |
|
1557 | - public function getMimeTypeLoader() { |
|
1558 | - return $this->query('MimeTypeLoader'); |
|
1559 | - } |
|
1560 | - |
|
1561 | - /** |
|
1562 | - * Get the manager of all the capabilities |
|
1563 | - * |
|
1564 | - * @return \OC\CapabilitiesManager |
|
1565 | - */ |
|
1566 | - public function getCapabilitiesManager() { |
|
1567 | - return $this->query('CapabilitiesManager'); |
|
1568 | - } |
|
1569 | - |
|
1570 | - /** |
|
1571 | - * Get the EventDispatcher |
|
1572 | - * |
|
1573 | - * @return EventDispatcherInterface |
|
1574 | - * @since 8.2.0 |
|
1575 | - */ |
|
1576 | - public function getEventDispatcher() { |
|
1577 | - return $this->query('EventDispatcher'); |
|
1578 | - } |
|
1579 | - |
|
1580 | - /** |
|
1581 | - * Get the Notification Manager |
|
1582 | - * |
|
1583 | - * @return \OCP\Notification\IManager |
|
1584 | - * @since 8.2.0 |
|
1585 | - */ |
|
1586 | - public function getNotificationManager() { |
|
1587 | - return $this->query('NotificationManager'); |
|
1588 | - } |
|
1589 | - |
|
1590 | - /** |
|
1591 | - * @return \OCP\Comments\ICommentsManager |
|
1592 | - */ |
|
1593 | - public function getCommentsManager() { |
|
1594 | - return $this->query('CommentsManager'); |
|
1595 | - } |
|
1596 | - |
|
1597 | - /** |
|
1598 | - * @return \OC_Defaults |
|
1599 | - */ |
|
1600 | - public function getThemingDefaults() { |
|
1601 | - return $this->query('ThemingDefaults'); |
|
1602 | - } |
|
1603 | - |
|
1604 | - /** |
|
1605 | - * @return \OC\IntegrityCheck\Checker |
|
1606 | - */ |
|
1607 | - public function getIntegrityCodeChecker() { |
|
1608 | - return $this->query('IntegrityCodeChecker'); |
|
1609 | - } |
|
1610 | - |
|
1611 | - /** |
|
1612 | - * @return \OC\Session\CryptoWrapper |
|
1613 | - */ |
|
1614 | - public function getSessionCryptoWrapper() { |
|
1615 | - return $this->query('CryptoWrapper'); |
|
1616 | - } |
|
1617 | - |
|
1618 | - /** |
|
1619 | - * @return CsrfTokenManager |
|
1620 | - */ |
|
1621 | - public function getCsrfTokenManager() { |
|
1622 | - return $this->query('CsrfTokenManager'); |
|
1623 | - } |
|
1624 | - |
|
1625 | - /** |
|
1626 | - * @return Throttler |
|
1627 | - */ |
|
1628 | - public function getBruteForceThrottler() { |
|
1629 | - return $this->query('Throttler'); |
|
1630 | - } |
|
1631 | - |
|
1632 | - /** |
|
1633 | - * @return IContentSecurityPolicyManager |
|
1634 | - */ |
|
1635 | - public function getContentSecurityPolicyManager() { |
|
1636 | - return $this->query('ContentSecurityPolicyManager'); |
|
1637 | - } |
|
1638 | - |
|
1639 | - /** |
|
1640 | - * @return ContentSecurityPolicyNonceManager |
|
1641 | - */ |
|
1642 | - public function getContentSecurityPolicyNonceManager() { |
|
1643 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1644 | - } |
|
1645 | - |
|
1646 | - /** |
|
1647 | - * Not a public API as of 8.2, wait for 9.0 |
|
1648 | - * |
|
1649 | - * @return \OCA\Files_External\Service\BackendService |
|
1650 | - */ |
|
1651 | - public function getStoragesBackendService() { |
|
1652 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1653 | - } |
|
1654 | - |
|
1655 | - /** |
|
1656 | - * Not a public API as of 8.2, wait for 9.0 |
|
1657 | - * |
|
1658 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1659 | - */ |
|
1660 | - public function getGlobalStoragesService() { |
|
1661 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1662 | - } |
|
1663 | - |
|
1664 | - /** |
|
1665 | - * Not a public API as of 8.2, wait for 9.0 |
|
1666 | - * |
|
1667 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1668 | - */ |
|
1669 | - public function getUserGlobalStoragesService() { |
|
1670 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1671 | - } |
|
1672 | - |
|
1673 | - /** |
|
1674 | - * Not a public API as of 8.2, wait for 9.0 |
|
1675 | - * |
|
1676 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1677 | - */ |
|
1678 | - public function getUserStoragesService() { |
|
1679 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1680 | - } |
|
1681 | - |
|
1682 | - /** |
|
1683 | - * @return \OCP\Share\IManager |
|
1684 | - */ |
|
1685 | - public function getShareManager() { |
|
1686 | - return $this->query('ShareManager'); |
|
1687 | - } |
|
1688 | - |
|
1689 | - /** |
|
1690 | - * Returns the LDAP Provider |
|
1691 | - * |
|
1692 | - * @return \OCP\LDAP\ILDAPProvider |
|
1693 | - */ |
|
1694 | - public function getLDAPProvider() { |
|
1695 | - return $this->query('LDAPProvider'); |
|
1696 | - } |
|
1697 | - |
|
1698 | - /** |
|
1699 | - * @return \OCP\Settings\IManager |
|
1700 | - */ |
|
1701 | - public function getSettingsManager() { |
|
1702 | - return $this->query('SettingsManager'); |
|
1703 | - } |
|
1704 | - |
|
1705 | - /** |
|
1706 | - * @return \OCP\Files\IAppData |
|
1707 | - */ |
|
1708 | - public function getAppDataDir($app) { |
|
1709 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1710 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1711 | - return $factory->get($app); |
|
1712 | - } |
|
1713 | - |
|
1714 | - /** |
|
1715 | - * @return \OCP\Lockdown\ILockdownManager |
|
1716 | - */ |
|
1717 | - public function getLockdownManager() { |
|
1718 | - return $this->query('LockdownManager'); |
|
1719 | - } |
|
1720 | - |
|
1721 | - /** |
|
1722 | - * @return \OCP\Federation\ICloudIdManager |
|
1723 | - */ |
|
1724 | - public function getCloudIdManager() { |
|
1725 | - return $this->query(ICloudIdManager::class); |
|
1726 | - } |
|
823 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
824 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
825 | + $classExists = true; |
|
826 | + } else { |
|
827 | + $classExists = false; |
|
828 | + } |
|
829 | + |
|
830 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
831 | + return new ThemingDefaults( |
|
832 | + $c->getConfig(), |
|
833 | + $c->getL10N('theming'), |
|
834 | + $c->getURLGenerator(), |
|
835 | + new \OC_Defaults(), |
|
836 | + $c->getAppDataDir('theming'), |
|
837 | + $c->getMemCacheFactory(), |
|
838 | + new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager()) |
|
839 | + ); |
|
840 | + } |
|
841 | + return new \OC_Defaults(); |
|
842 | + }); |
|
843 | + $this->registerService(SCSSCacher::class, function(Server $c) { |
|
844 | + /** @var Factory $cacheFactory */ |
|
845 | + $cacheFactory = $c->query(Factory::class); |
|
846 | + return new SCSSCacher( |
|
847 | + $c->getLogger(), |
|
848 | + $c->query(\OC\Files\AppData\Factory::class), |
|
849 | + $c->getURLGenerator(), |
|
850 | + $c->getConfig(), |
|
851 | + $c->getThemingDefaults(), |
|
852 | + \OC::$SERVERROOT, |
|
853 | + $cacheFactory->createLocal('SCSS') |
|
854 | + |
|
855 | + ); |
|
856 | + }); |
|
857 | + $this->registerService(EventDispatcher::class, function () { |
|
858 | + return new EventDispatcher(); |
|
859 | + }); |
|
860 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
861 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
862 | + |
|
863 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
864 | + // FIXME: Instantiiated here due to cyclic dependency |
|
865 | + $request = new Request( |
|
866 | + [ |
|
867 | + 'get' => $_GET, |
|
868 | + 'post' => $_POST, |
|
869 | + 'files' => $_FILES, |
|
870 | + 'server' => $_SERVER, |
|
871 | + 'env' => $_ENV, |
|
872 | + 'cookies' => $_COOKIE, |
|
873 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
874 | + ? $_SERVER['REQUEST_METHOD'] |
|
875 | + : null, |
|
876 | + ], |
|
877 | + $c->getSecureRandom(), |
|
878 | + $c->getConfig() |
|
879 | + ); |
|
880 | + |
|
881 | + return new CryptoWrapper( |
|
882 | + $c->getConfig(), |
|
883 | + $c->getCrypto(), |
|
884 | + $c->getSecureRandom(), |
|
885 | + $request |
|
886 | + ); |
|
887 | + }); |
|
888 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
889 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
890 | + |
|
891 | + return new CsrfTokenManager( |
|
892 | + $tokenGenerator, |
|
893 | + $c->query(SessionStorage::class) |
|
894 | + ); |
|
895 | + }); |
|
896 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
897 | + return new SessionStorage($c->getSession()); |
|
898 | + }); |
|
899 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
900 | + return new ContentSecurityPolicyManager(); |
|
901 | + }); |
|
902 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
903 | + |
|
904 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
905 | + return new ContentSecurityPolicyNonceManager( |
|
906 | + $c->getCsrfTokenManager(), |
|
907 | + $c->getRequest() |
|
908 | + ); |
|
909 | + }); |
|
910 | + |
|
911 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
912 | + $config = $c->getConfig(); |
|
913 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
914 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
915 | + $factory = new $factoryClass($this); |
|
916 | + |
|
917 | + $manager = new \OC\Share20\Manager( |
|
918 | + $c->getLogger(), |
|
919 | + $c->getConfig(), |
|
920 | + $c->getSecureRandom(), |
|
921 | + $c->getHasher(), |
|
922 | + $c->getMountManager(), |
|
923 | + $c->getGroupManager(), |
|
924 | + $c->getL10N('core'), |
|
925 | + $factory, |
|
926 | + $c->getUserManager(), |
|
927 | + $c->getLazyRootFolder(), |
|
928 | + $c->getEventDispatcher() |
|
929 | + ); |
|
930 | + |
|
931 | + return $manager; |
|
932 | + }); |
|
933 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
934 | + |
|
935 | + $this->registerService('SettingsManager', function(Server $c) { |
|
936 | + $manager = new \OC\Settings\Manager( |
|
937 | + $c->getLogger(), |
|
938 | + $c->getDatabaseConnection(), |
|
939 | + $c->getL10N('lib'), |
|
940 | + $c->getConfig(), |
|
941 | + $c->getEncryptionManager(), |
|
942 | + $c->getUserManager(), |
|
943 | + $c->getLockingProvider(), |
|
944 | + $c->getRequest(), |
|
945 | + new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
946 | + $c->getURLGenerator() |
|
947 | + ); |
|
948 | + return $manager; |
|
949 | + }); |
|
950 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
951 | + return new \OC\Files\AppData\Factory( |
|
952 | + $c->getRootFolder(), |
|
953 | + $c->getSystemConfig() |
|
954 | + ); |
|
955 | + }); |
|
956 | + |
|
957 | + $this->registerService('LockdownManager', function (Server $c) { |
|
958 | + return new LockdownManager(); |
|
959 | + }); |
|
960 | + |
|
961 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
962 | + return new CloudIdManager(); |
|
963 | + }); |
|
964 | + |
|
965 | + /* To trick DI since we don't extend the DIContainer here */ |
|
966 | + $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
967 | + return new CleanPreviewsBackgroundJob( |
|
968 | + $c->getRootFolder(), |
|
969 | + $c->getLogger(), |
|
970 | + $c->getJobList(), |
|
971 | + new TimeFactory() |
|
972 | + ); |
|
973 | + }); |
|
974 | + |
|
975 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
976 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
977 | + |
|
978 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
979 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
980 | + |
|
981 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
982 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
983 | + }); |
|
984 | + } |
|
985 | + |
|
986 | + /** |
|
987 | + * @return \OCP\Contacts\IManager |
|
988 | + */ |
|
989 | + public function getContactsManager() { |
|
990 | + return $this->query('ContactsManager'); |
|
991 | + } |
|
992 | + |
|
993 | + /** |
|
994 | + * @return \OC\Encryption\Manager |
|
995 | + */ |
|
996 | + public function getEncryptionManager() { |
|
997 | + return $this->query('EncryptionManager'); |
|
998 | + } |
|
999 | + |
|
1000 | + /** |
|
1001 | + * @return \OC\Encryption\File |
|
1002 | + */ |
|
1003 | + public function getEncryptionFilesHelper() { |
|
1004 | + return $this->query('EncryptionFileHelper'); |
|
1005 | + } |
|
1006 | + |
|
1007 | + /** |
|
1008 | + * @return \OCP\Encryption\Keys\IStorage |
|
1009 | + */ |
|
1010 | + public function getEncryptionKeyStorage() { |
|
1011 | + return $this->query('EncryptionKeyStorage'); |
|
1012 | + } |
|
1013 | + |
|
1014 | + /** |
|
1015 | + * The current request object holding all information about the request |
|
1016 | + * currently being processed is returned from this method. |
|
1017 | + * In case the current execution was not initiated by a web request null is returned |
|
1018 | + * |
|
1019 | + * @return \OCP\IRequest |
|
1020 | + */ |
|
1021 | + public function getRequest() { |
|
1022 | + return $this->query('Request'); |
|
1023 | + } |
|
1024 | + |
|
1025 | + /** |
|
1026 | + * Returns the preview manager which can create preview images for a given file |
|
1027 | + * |
|
1028 | + * @return \OCP\IPreview |
|
1029 | + */ |
|
1030 | + public function getPreviewManager() { |
|
1031 | + return $this->query('PreviewManager'); |
|
1032 | + } |
|
1033 | + |
|
1034 | + /** |
|
1035 | + * Returns the tag manager which can get and set tags for different object types |
|
1036 | + * |
|
1037 | + * @see \OCP\ITagManager::load() |
|
1038 | + * @return \OCP\ITagManager |
|
1039 | + */ |
|
1040 | + public function getTagManager() { |
|
1041 | + return $this->query('TagManager'); |
|
1042 | + } |
|
1043 | + |
|
1044 | + /** |
|
1045 | + * Returns the system-tag manager |
|
1046 | + * |
|
1047 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1048 | + * |
|
1049 | + * @since 9.0.0 |
|
1050 | + */ |
|
1051 | + public function getSystemTagManager() { |
|
1052 | + return $this->query('SystemTagManager'); |
|
1053 | + } |
|
1054 | + |
|
1055 | + /** |
|
1056 | + * Returns the system-tag object mapper |
|
1057 | + * |
|
1058 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1059 | + * |
|
1060 | + * @since 9.0.0 |
|
1061 | + */ |
|
1062 | + public function getSystemTagObjectMapper() { |
|
1063 | + return $this->query('SystemTagObjectMapper'); |
|
1064 | + } |
|
1065 | + |
|
1066 | + /** |
|
1067 | + * Returns the avatar manager, used for avatar functionality |
|
1068 | + * |
|
1069 | + * @return \OCP\IAvatarManager |
|
1070 | + */ |
|
1071 | + public function getAvatarManager() { |
|
1072 | + return $this->query('AvatarManager'); |
|
1073 | + } |
|
1074 | + |
|
1075 | + /** |
|
1076 | + * Returns the root folder of ownCloud's data directory |
|
1077 | + * |
|
1078 | + * @return \OCP\Files\IRootFolder |
|
1079 | + */ |
|
1080 | + public function getRootFolder() { |
|
1081 | + return $this->query('LazyRootFolder'); |
|
1082 | + } |
|
1083 | + |
|
1084 | + /** |
|
1085 | + * Returns the root folder of ownCloud's data directory |
|
1086 | + * This is the lazy variant so this gets only initialized once it |
|
1087 | + * is actually used. |
|
1088 | + * |
|
1089 | + * @return \OCP\Files\IRootFolder |
|
1090 | + */ |
|
1091 | + public function getLazyRootFolder() { |
|
1092 | + return $this->query('LazyRootFolder'); |
|
1093 | + } |
|
1094 | + |
|
1095 | + /** |
|
1096 | + * Returns a view to ownCloud's files folder |
|
1097 | + * |
|
1098 | + * @param string $userId user ID |
|
1099 | + * @return \OCP\Files\Folder|null |
|
1100 | + */ |
|
1101 | + public function getUserFolder($userId = null) { |
|
1102 | + if ($userId === null) { |
|
1103 | + $user = $this->getUserSession()->getUser(); |
|
1104 | + if (!$user) { |
|
1105 | + return null; |
|
1106 | + } |
|
1107 | + $userId = $user->getUID(); |
|
1108 | + } |
|
1109 | + $root = $this->getRootFolder(); |
|
1110 | + return $root->getUserFolder($userId); |
|
1111 | + } |
|
1112 | + |
|
1113 | + /** |
|
1114 | + * Returns an app-specific view in ownClouds data directory |
|
1115 | + * |
|
1116 | + * @return \OCP\Files\Folder |
|
1117 | + * @deprecated since 9.2.0 use IAppData |
|
1118 | + */ |
|
1119 | + public function getAppFolder() { |
|
1120 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1121 | + $root = $this->getRootFolder(); |
|
1122 | + if (!$root->nodeExists($dir)) { |
|
1123 | + $folder = $root->newFolder($dir); |
|
1124 | + } else { |
|
1125 | + $folder = $root->get($dir); |
|
1126 | + } |
|
1127 | + return $folder; |
|
1128 | + } |
|
1129 | + |
|
1130 | + /** |
|
1131 | + * @return \OC\User\Manager |
|
1132 | + */ |
|
1133 | + public function getUserManager() { |
|
1134 | + return $this->query('UserManager'); |
|
1135 | + } |
|
1136 | + |
|
1137 | + /** |
|
1138 | + * @return \OC\Group\Manager |
|
1139 | + */ |
|
1140 | + public function getGroupManager() { |
|
1141 | + return $this->query('GroupManager'); |
|
1142 | + } |
|
1143 | + |
|
1144 | + /** |
|
1145 | + * @return \OC\User\Session |
|
1146 | + */ |
|
1147 | + public function getUserSession() { |
|
1148 | + return $this->query('UserSession'); |
|
1149 | + } |
|
1150 | + |
|
1151 | + /** |
|
1152 | + * @return \OCP\ISession |
|
1153 | + */ |
|
1154 | + public function getSession() { |
|
1155 | + return $this->query('UserSession')->getSession(); |
|
1156 | + } |
|
1157 | + |
|
1158 | + /** |
|
1159 | + * @param \OCP\ISession $session |
|
1160 | + */ |
|
1161 | + public function setSession(\OCP\ISession $session) { |
|
1162 | + $this->query(SessionStorage::class)->setSession($session); |
|
1163 | + $this->query('UserSession')->setSession($session); |
|
1164 | + $this->query(Store::class)->setSession($session); |
|
1165 | + } |
|
1166 | + |
|
1167 | + /** |
|
1168 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1169 | + */ |
|
1170 | + public function getTwoFactorAuthManager() { |
|
1171 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1172 | + } |
|
1173 | + |
|
1174 | + /** |
|
1175 | + * @return \OC\NavigationManager |
|
1176 | + */ |
|
1177 | + public function getNavigationManager() { |
|
1178 | + return $this->query('NavigationManager'); |
|
1179 | + } |
|
1180 | + |
|
1181 | + /** |
|
1182 | + * @return \OCP\IConfig |
|
1183 | + */ |
|
1184 | + public function getConfig() { |
|
1185 | + return $this->query('AllConfig'); |
|
1186 | + } |
|
1187 | + |
|
1188 | + /** |
|
1189 | + * @internal For internal use only |
|
1190 | + * @return \OC\SystemConfig |
|
1191 | + */ |
|
1192 | + public function getSystemConfig() { |
|
1193 | + return $this->query('SystemConfig'); |
|
1194 | + } |
|
1195 | + |
|
1196 | + /** |
|
1197 | + * Returns the app config manager |
|
1198 | + * |
|
1199 | + * @return \OCP\IAppConfig |
|
1200 | + */ |
|
1201 | + public function getAppConfig() { |
|
1202 | + return $this->query('AppConfig'); |
|
1203 | + } |
|
1204 | + |
|
1205 | + /** |
|
1206 | + * @return \OCP\L10N\IFactory |
|
1207 | + */ |
|
1208 | + public function getL10NFactory() { |
|
1209 | + return $this->query('L10NFactory'); |
|
1210 | + } |
|
1211 | + |
|
1212 | + /** |
|
1213 | + * get an L10N instance |
|
1214 | + * |
|
1215 | + * @param string $app appid |
|
1216 | + * @param string $lang |
|
1217 | + * @return IL10N |
|
1218 | + */ |
|
1219 | + public function getL10N($app, $lang = null) { |
|
1220 | + return $this->getL10NFactory()->get($app, $lang); |
|
1221 | + } |
|
1222 | + |
|
1223 | + /** |
|
1224 | + * @return \OCP\IURLGenerator |
|
1225 | + */ |
|
1226 | + public function getURLGenerator() { |
|
1227 | + return $this->query('URLGenerator'); |
|
1228 | + } |
|
1229 | + |
|
1230 | + /** |
|
1231 | + * @return \OCP\IHelper |
|
1232 | + */ |
|
1233 | + public function getHelper() { |
|
1234 | + return $this->query('AppHelper'); |
|
1235 | + } |
|
1236 | + |
|
1237 | + /** |
|
1238 | + * @return AppFetcher |
|
1239 | + */ |
|
1240 | + public function getAppFetcher() { |
|
1241 | + return $this->query('AppFetcher'); |
|
1242 | + } |
|
1243 | + |
|
1244 | + /** |
|
1245 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1246 | + * getMemCacheFactory() instead. |
|
1247 | + * |
|
1248 | + * @return \OCP\ICache |
|
1249 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1250 | + */ |
|
1251 | + public function getCache() { |
|
1252 | + return $this->query('UserCache'); |
|
1253 | + } |
|
1254 | + |
|
1255 | + /** |
|
1256 | + * Returns an \OCP\CacheFactory instance |
|
1257 | + * |
|
1258 | + * @return \OCP\ICacheFactory |
|
1259 | + */ |
|
1260 | + public function getMemCacheFactory() { |
|
1261 | + return $this->query('MemCacheFactory'); |
|
1262 | + } |
|
1263 | + |
|
1264 | + /** |
|
1265 | + * Returns an \OC\RedisFactory instance |
|
1266 | + * |
|
1267 | + * @return \OC\RedisFactory |
|
1268 | + */ |
|
1269 | + public function getGetRedisFactory() { |
|
1270 | + return $this->query('RedisFactory'); |
|
1271 | + } |
|
1272 | + |
|
1273 | + |
|
1274 | + /** |
|
1275 | + * Returns the current session |
|
1276 | + * |
|
1277 | + * @return \OCP\IDBConnection |
|
1278 | + */ |
|
1279 | + public function getDatabaseConnection() { |
|
1280 | + return $this->query('DatabaseConnection'); |
|
1281 | + } |
|
1282 | + |
|
1283 | + /** |
|
1284 | + * Returns the activity manager |
|
1285 | + * |
|
1286 | + * @return \OCP\Activity\IManager |
|
1287 | + */ |
|
1288 | + public function getActivityManager() { |
|
1289 | + return $this->query('ActivityManager'); |
|
1290 | + } |
|
1291 | + |
|
1292 | + /** |
|
1293 | + * Returns an job list for controlling background jobs |
|
1294 | + * |
|
1295 | + * @return \OCP\BackgroundJob\IJobList |
|
1296 | + */ |
|
1297 | + public function getJobList() { |
|
1298 | + return $this->query('JobList'); |
|
1299 | + } |
|
1300 | + |
|
1301 | + /** |
|
1302 | + * Returns a logger instance |
|
1303 | + * |
|
1304 | + * @return \OCP\ILogger |
|
1305 | + */ |
|
1306 | + public function getLogger() { |
|
1307 | + return $this->query('Logger'); |
|
1308 | + } |
|
1309 | + |
|
1310 | + /** |
|
1311 | + * Returns a router for generating and matching urls |
|
1312 | + * |
|
1313 | + * @return \OCP\Route\IRouter |
|
1314 | + */ |
|
1315 | + public function getRouter() { |
|
1316 | + return $this->query('Router'); |
|
1317 | + } |
|
1318 | + |
|
1319 | + /** |
|
1320 | + * Returns a search instance |
|
1321 | + * |
|
1322 | + * @return \OCP\ISearch |
|
1323 | + */ |
|
1324 | + public function getSearch() { |
|
1325 | + return $this->query('Search'); |
|
1326 | + } |
|
1327 | + |
|
1328 | + /** |
|
1329 | + * Returns a SecureRandom instance |
|
1330 | + * |
|
1331 | + * @return \OCP\Security\ISecureRandom |
|
1332 | + */ |
|
1333 | + public function getSecureRandom() { |
|
1334 | + return $this->query('SecureRandom'); |
|
1335 | + } |
|
1336 | + |
|
1337 | + /** |
|
1338 | + * Returns a Crypto instance |
|
1339 | + * |
|
1340 | + * @return \OCP\Security\ICrypto |
|
1341 | + */ |
|
1342 | + public function getCrypto() { |
|
1343 | + return $this->query('Crypto'); |
|
1344 | + } |
|
1345 | + |
|
1346 | + /** |
|
1347 | + * Returns a Hasher instance |
|
1348 | + * |
|
1349 | + * @return \OCP\Security\IHasher |
|
1350 | + */ |
|
1351 | + public function getHasher() { |
|
1352 | + return $this->query('Hasher'); |
|
1353 | + } |
|
1354 | + |
|
1355 | + /** |
|
1356 | + * Returns a CredentialsManager instance |
|
1357 | + * |
|
1358 | + * @return \OCP\Security\ICredentialsManager |
|
1359 | + */ |
|
1360 | + public function getCredentialsManager() { |
|
1361 | + return $this->query('CredentialsManager'); |
|
1362 | + } |
|
1363 | + |
|
1364 | + /** |
|
1365 | + * Returns an instance of the HTTP helper class |
|
1366 | + * |
|
1367 | + * @deprecated Use getHTTPClientService() |
|
1368 | + * @return \OC\HTTPHelper |
|
1369 | + */ |
|
1370 | + public function getHTTPHelper() { |
|
1371 | + return $this->query('HTTPHelper'); |
|
1372 | + } |
|
1373 | + |
|
1374 | + /** |
|
1375 | + * Get the certificate manager for the user |
|
1376 | + * |
|
1377 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1378 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1379 | + */ |
|
1380 | + public function getCertificateManager($userId = '') { |
|
1381 | + if ($userId === '') { |
|
1382 | + $userSession = $this->getUserSession(); |
|
1383 | + $user = $userSession->getUser(); |
|
1384 | + if (is_null($user)) { |
|
1385 | + return null; |
|
1386 | + } |
|
1387 | + $userId = $user->getUID(); |
|
1388 | + } |
|
1389 | + return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1390 | + } |
|
1391 | + |
|
1392 | + /** |
|
1393 | + * Returns an instance of the HTTP client service |
|
1394 | + * |
|
1395 | + * @return \OCP\Http\Client\IClientService |
|
1396 | + */ |
|
1397 | + public function getHTTPClientService() { |
|
1398 | + return $this->query('HttpClientService'); |
|
1399 | + } |
|
1400 | + |
|
1401 | + /** |
|
1402 | + * Create a new event source |
|
1403 | + * |
|
1404 | + * @return \OCP\IEventSource |
|
1405 | + */ |
|
1406 | + public function createEventSource() { |
|
1407 | + return new \OC_EventSource(); |
|
1408 | + } |
|
1409 | + |
|
1410 | + /** |
|
1411 | + * Get the active event logger |
|
1412 | + * |
|
1413 | + * The returned logger only logs data when debug mode is enabled |
|
1414 | + * |
|
1415 | + * @return \OCP\Diagnostics\IEventLogger |
|
1416 | + */ |
|
1417 | + public function getEventLogger() { |
|
1418 | + return $this->query('EventLogger'); |
|
1419 | + } |
|
1420 | + |
|
1421 | + /** |
|
1422 | + * Get the active query logger |
|
1423 | + * |
|
1424 | + * The returned logger only logs data when debug mode is enabled |
|
1425 | + * |
|
1426 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1427 | + */ |
|
1428 | + public function getQueryLogger() { |
|
1429 | + return $this->query('QueryLogger'); |
|
1430 | + } |
|
1431 | + |
|
1432 | + /** |
|
1433 | + * Get the manager for temporary files and folders |
|
1434 | + * |
|
1435 | + * @return \OCP\ITempManager |
|
1436 | + */ |
|
1437 | + public function getTempManager() { |
|
1438 | + return $this->query('TempManager'); |
|
1439 | + } |
|
1440 | + |
|
1441 | + /** |
|
1442 | + * Get the app manager |
|
1443 | + * |
|
1444 | + * @return \OCP\App\IAppManager |
|
1445 | + */ |
|
1446 | + public function getAppManager() { |
|
1447 | + return $this->query('AppManager'); |
|
1448 | + } |
|
1449 | + |
|
1450 | + /** |
|
1451 | + * Creates a new mailer |
|
1452 | + * |
|
1453 | + * @return \OCP\Mail\IMailer |
|
1454 | + */ |
|
1455 | + public function getMailer() { |
|
1456 | + return $this->query('Mailer'); |
|
1457 | + } |
|
1458 | + |
|
1459 | + /** |
|
1460 | + * Get the webroot |
|
1461 | + * |
|
1462 | + * @return string |
|
1463 | + */ |
|
1464 | + public function getWebRoot() { |
|
1465 | + return $this->webRoot; |
|
1466 | + } |
|
1467 | + |
|
1468 | + /** |
|
1469 | + * @return \OC\OCSClient |
|
1470 | + */ |
|
1471 | + public function getOcsClient() { |
|
1472 | + return $this->query('OcsClient'); |
|
1473 | + } |
|
1474 | + |
|
1475 | + /** |
|
1476 | + * @return \OCP\IDateTimeZone |
|
1477 | + */ |
|
1478 | + public function getDateTimeZone() { |
|
1479 | + return $this->query('DateTimeZone'); |
|
1480 | + } |
|
1481 | + |
|
1482 | + /** |
|
1483 | + * @return \OCP\IDateTimeFormatter |
|
1484 | + */ |
|
1485 | + public function getDateTimeFormatter() { |
|
1486 | + return $this->query('DateTimeFormatter'); |
|
1487 | + } |
|
1488 | + |
|
1489 | + /** |
|
1490 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1491 | + */ |
|
1492 | + public function getMountProviderCollection() { |
|
1493 | + return $this->query('MountConfigManager'); |
|
1494 | + } |
|
1495 | + |
|
1496 | + /** |
|
1497 | + * Get the IniWrapper |
|
1498 | + * |
|
1499 | + * @return IniGetWrapper |
|
1500 | + */ |
|
1501 | + public function getIniWrapper() { |
|
1502 | + return $this->query('IniWrapper'); |
|
1503 | + } |
|
1504 | + |
|
1505 | + /** |
|
1506 | + * @return \OCP\Command\IBus |
|
1507 | + */ |
|
1508 | + public function getCommandBus() { |
|
1509 | + return $this->query('AsyncCommandBus'); |
|
1510 | + } |
|
1511 | + |
|
1512 | + /** |
|
1513 | + * Get the trusted domain helper |
|
1514 | + * |
|
1515 | + * @return TrustedDomainHelper |
|
1516 | + */ |
|
1517 | + public function getTrustedDomainHelper() { |
|
1518 | + return $this->query('TrustedDomainHelper'); |
|
1519 | + } |
|
1520 | + |
|
1521 | + /** |
|
1522 | + * Get the locking provider |
|
1523 | + * |
|
1524 | + * @return \OCP\Lock\ILockingProvider |
|
1525 | + * @since 8.1.0 |
|
1526 | + */ |
|
1527 | + public function getLockingProvider() { |
|
1528 | + return $this->query('LockingProvider'); |
|
1529 | + } |
|
1530 | + |
|
1531 | + /** |
|
1532 | + * @return \OCP\Files\Mount\IMountManager |
|
1533 | + **/ |
|
1534 | + function getMountManager() { |
|
1535 | + return $this->query('MountManager'); |
|
1536 | + } |
|
1537 | + |
|
1538 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1539 | + function getUserMountCache() { |
|
1540 | + return $this->query('UserMountCache'); |
|
1541 | + } |
|
1542 | + |
|
1543 | + /** |
|
1544 | + * Get the MimeTypeDetector |
|
1545 | + * |
|
1546 | + * @return \OCP\Files\IMimeTypeDetector |
|
1547 | + */ |
|
1548 | + public function getMimeTypeDetector() { |
|
1549 | + return $this->query('MimeTypeDetector'); |
|
1550 | + } |
|
1551 | + |
|
1552 | + /** |
|
1553 | + * Get the MimeTypeLoader |
|
1554 | + * |
|
1555 | + * @return \OCP\Files\IMimeTypeLoader |
|
1556 | + */ |
|
1557 | + public function getMimeTypeLoader() { |
|
1558 | + return $this->query('MimeTypeLoader'); |
|
1559 | + } |
|
1560 | + |
|
1561 | + /** |
|
1562 | + * Get the manager of all the capabilities |
|
1563 | + * |
|
1564 | + * @return \OC\CapabilitiesManager |
|
1565 | + */ |
|
1566 | + public function getCapabilitiesManager() { |
|
1567 | + return $this->query('CapabilitiesManager'); |
|
1568 | + } |
|
1569 | + |
|
1570 | + /** |
|
1571 | + * Get the EventDispatcher |
|
1572 | + * |
|
1573 | + * @return EventDispatcherInterface |
|
1574 | + * @since 8.2.0 |
|
1575 | + */ |
|
1576 | + public function getEventDispatcher() { |
|
1577 | + return $this->query('EventDispatcher'); |
|
1578 | + } |
|
1579 | + |
|
1580 | + /** |
|
1581 | + * Get the Notification Manager |
|
1582 | + * |
|
1583 | + * @return \OCP\Notification\IManager |
|
1584 | + * @since 8.2.0 |
|
1585 | + */ |
|
1586 | + public function getNotificationManager() { |
|
1587 | + return $this->query('NotificationManager'); |
|
1588 | + } |
|
1589 | + |
|
1590 | + /** |
|
1591 | + * @return \OCP\Comments\ICommentsManager |
|
1592 | + */ |
|
1593 | + public function getCommentsManager() { |
|
1594 | + return $this->query('CommentsManager'); |
|
1595 | + } |
|
1596 | + |
|
1597 | + /** |
|
1598 | + * @return \OC_Defaults |
|
1599 | + */ |
|
1600 | + public function getThemingDefaults() { |
|
1601 | + return $this->query('ThemingDefaults'); |
|
1602 | + } |
|
1603 | + |
|
1604 | + /** |
|
1605 | + * @return \OC\IntegrityCheck\Checker |
|
1606 | + */ |
|
1607 | + public function getIntegrityCodeChecker() { |
|
1608 | + return $this->query('IntegrityCodeChecker'); |
|
1609 | + } |
|
1610 | + |
|
1611 | + /** |
|
1612 | + * @return \OC\Session\CryptoWrapper |
|
1613 | + */ |
|
1614 | + public function getSessionCryptoWrapper() { |
|
1615 | + return $this->query('CryptoWrapper'); |
|
1616 | + } |
|
1617 | + |
|
1618 | + /** |
|
1619 | + * @return CsrfTokenManager |
|
1620 | + */ |
|
1621 | + public function getCsrfTokenManager() { |
|
1622 | + return $this->query('CsrfTokenManager'); |
|
1623 | + } |
|
1624 | + |
|
1625 | + /** |
|
1626 | + * @return Throttler |
|
1627 | + */ |
|
1628 | + public function getBruteForceThrottler() { |
|
1629 | + return $this->query('Throttler'); |
|
1630 | + } |
|
1631 | + |
|
1632 | + /** |
|
1633 | + * @return IContentSecurityPolicyManager |
|
1634 | + */ |
|
1635 | + public function getContentSecurityPolicyManager() { |
|
1636 | + return $this->query('ContentSecurityPolicyManager'); |
|
1637 | + } |
|
1638 | + |
|
1639 | + /** |
|
1640 | + * @return ContentSecurityPolicyNonceManager |
|
1641 | + */ |
|
1642 | + public function getContentSecurityPolicyNonceManager() { |
|
1643 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1644 | + } |
|
1645 | + |
|
1646 | + /** |
|
1647 | + * Not a public API as of 8.2, wait for 9.0 |
|
1648 | + * |
|
1649 | + * @return \OCA\Files_External\Service\BackendService |
|
1650 | + */ |
|
1651 | + public function getStoragesBackendService() { |
|
1652 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1653 | + } |
|
1654 | + |
|
1655 | + /** |
|
1656 | + * Not a public API as of 8.2, wait for 9.0 |
|
1657 | + * |
|
1658 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1659 | + */ |
|
1660 | + public function getGlobalStoragesService() { |
|
1661 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1662 | + } |
|
1663 | + |
|
1664 | + /** |
|
1665 | + * Not a public API as of 8.2, wait for 9.0 |
|
1666 | + * |
|
1667 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1668 | + */ |
|
1669 | + public function getUserGlobalStoragesService() { |
|
1670 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1671 | + } |
|
1672 | + |
|
1673 | + /** |
|
1674 | + * Not a public API as of 8.2, wait for 9.0 |
|
1675 | + * |
|
1676 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1677 | + */ |
|
1678 | + public function getUserStoragesService() { |
|
1679 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1680 | + } |
|
1681 | + |
|
1682 | + /** |
|
1683 | + * @return \OCP\Share\IManager |
|
1684 | + */ |
|
1685 | + public function getShareManager() { |
|
1686 | + return $this->query('ShareManager'); |
|
1687 | + } |
|
1688 | + |
|
1689 | + /** |
|
1690 | + * Returns the LDAP Provider |
|
1691 | + * |
|
1692 | + * @return \OCP\LDAP\ILDAPProvider |
|
1693 | + */ |
|
1694 | + public function getLDAPProvider() { |
|
1695 | + return $this->query('LDAPProvider'); |
|
1696 | + } |
|
1697 | + |
|
1698 | + /** |
|
1699 | + * @return \OCP\Settings\IManager |
|
1700 | + */ |
|
1701 | + public function getSettingsManager() { |
|
1702 | + return $this->query('SettingsManager'); |
|
1703 | + } |
|
1704 | + |
|
1705 | + /** |
|
1706 | + * @return \OCP\Files\IAppData |
|
1707 | + */ |
|
1708 | + public function getAppDataDir($app) { |
|
1709 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1710 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1711 | + return $factory->get($app); |
|
1712 | + } |
|
1713 | + |
|
1714 | + /** |
|
1715 | + * @return \OCP\Lockdown\ILockdownManager |
|
1716 | + */ |
|
1717 | + public function getLockdownManager() { |
|
1718 | + return $this->query('LockdownManager'); |
|
1719 | + } |
|
1720 | + |
|
1721 | + /** |
|
1722 | + * @return \OCP\Federation\ICloudIdManager |
|
1723 | + */ |
|
1724 | + public function getCloudIdManager() { |
|
1725 | + return $this->query(ICloudIdManager::class); |
|
1726 | + } |
|
1727 | 1727 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
134 | 134 | $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
135 | 135 | |
136 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
136 | + $this->registerService(\OCP\IPreview::class, function(Server $c) { |
|
137 | 137 | return new PreviewManager( |
138 | 138 | $c->getConfig(), |
139 | 139 | $c->getRootFolder(), |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | }); |
145 | 145 | $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
146 | 146 | |
147 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
147 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
148 | 148 | return new \OC\Preview\Watcher( |
149 | 149 | $c->getAppDataDir('preview') |
150 | 150 | ); |
151 | 151 | }); |
152 | 152 | |
153 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
153 | + $this->registerService('EncryptionManager', function(Server $c) { |
|
154 | 154 | $view = new View(); |
155 | 155 | $util = new Encryption\Util( |
156 | 156 | $view, |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | ); |
169 | 169 | }); |
170 | 170 | |
171 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
171 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
172 | 172 | $util = new Encryption\Util( |
173 | 173 | new View(), |
174 | 174 | $c->getUserManager(), |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | return new Encryption\File($util); |
179 | 179 | }); |
180 | 180 | |
181 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
181 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
182 | 182 | $view = new View(); |
183 | 183 | $util = new Encryption\Util( |
184 | 184 | $view, |
@@ -189,32 +189,32 @@ discard block |
||
189 | 189 | |
190 | 190 | return new Encryption\Keys\Storage($view, $util); |
191 | 191 | }); |
192 | - $this->registerService('TagMapper', function (Server $c) { |
|
192 | + $this->registerService('TagMapper', function(Server $c) { |
|
193 | 193 | return new TagMapper($c->getDatabaseConnection()); |
194 | 194 | }); |
195 | 195 | |
196 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
196 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
197 | 197 | $tagMapper = $c->query('TagMapper'); |
198 | 198 | return new TagManager($tagMapper, $c->getUserSession()); |
199 | 199 | }); |
200 | 200 | $this->registerAlias('TagManager', \OCP\ITagManager::class); |
201 | 201 | |
202 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
202 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
203 | 203 | $config = $c->getConfig(); |
204 | 204 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
205 | 205 | /** @var \OC\SystemTag\ManagerFactory $factory */ |
206 | 206 | $factory = new $factoryClass($this); |
207 | 207 | return $factory; |
208 | 208 | }); |
209 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
209 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) { |
|
210 | 210 | return $c->query('SystemTagManagerFactory')->getManager(); |
211 | 211 | }); |
212 | 212 | $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
213 | 213 | |
214 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
214 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) { |
|
215 | 215 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
216 | 216 | }); |
217 | - $this->registerService('RootFolder', function (Server $c) { |
|
217 | + $this->registerService('RootFolder', function(Server $c) { |
|
218 | 218 | $manager = \OC\Files\Filesystem::getMountManager(null); |
219 | 219 | $view = new View(); |
220 | 220 | $root = new Root( |
@@ -242,30 +242,30 @@ discard block |
||
242 | 242 | }); |
243 | 243 | $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
244 | 244 | |
245 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
245 | + $this->registerService(\OCP\IUserManager::class, function(Server $c) { |
|
246 | 246 | $config = $c->getConfig(); |
247 | 247 | return new \OC\User\Manager($config); |
248 | 248 | }); |
249 | 249 | $this->registerAlias('UserManager', \OCP\IUserManager::class); |
250 | 250 | |
251 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
251 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
252 | 252 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
253 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
253 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
254 | 254 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
255 | 255 | }); |
256 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
256 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
257 | 257 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
258 | 258 | }); |
259 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
259 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
260 | 260 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
261 | 261 | }); |
262 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
262 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
263 | 263 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
264 | 264 | }); |
265 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
265 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
266 | 266 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
267 | 267 | }); |
268 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
268 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
269 | 269 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
270 | 270 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
271 | 271 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -285,11 +285,11 @@ discard block |
||
285 | 285 | return new Store($session, $logger, $tokenProvider); |
286 | 286 | }); |
287 | 287 | $this->registerAlias(IStore::class, Store::class); |
288 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
288 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function(Server $c) { |
|
289 | 289 | $dbConnection = $c->getDatabaseConnection(); |
290 | 290 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
291 | 291 | }); |
292 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
292 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function(Server $c) { |
|
293 | 293 | $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
294 | 294 | $crypto = $c->getCrypto(); |
295 | 295 | $config = $c->getConfig(); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | }); |
300 | 300 | $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
301 | 301 | |
302 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
302 | + $this->registerService(\OCP\IUserSession::class, function(Server $c) { |
|
303 | 303 | $manager = $c->getUserManager(); |
304 | 304 | $session = new \OC\Session\Memory(''); |
305 | 305 | $timeFactory = new TimeFactory(); |
@@ -312,40 +312,40 @@ discard block |
||
312 | 312 | } |
313 | 313 | |
314 | 314 | $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom()); |
315 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
315 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
316 | 316 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
317 | 317 | }); |
318 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
318 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
319 | 319 | /** @var $user \OC\User\User */ |
320 | 320 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
321 | 321 | }); |
322 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
322 | + $userSession->listen('\OC\User', 'preDelete', function($user) { |
|
323 | 323 | /** @var $user \OC\User\User */ |
324 | 324 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
325 | 325 | }); |
326 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
326 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
327 | 327 | /** @var $user \OC\User\User */ |
328 | 328 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
329 | 329 | }); |
330 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
330 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
331 | 331 | /** @var $user \OC\User\User */ |
332 | 332 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
333 | 333 | }); |
334 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
334 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
335 | 335 | /** @var $user \OC\User\User */ |
336 | 336 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
337 | 337 | }); |
338 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
338 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
339 | 339 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
340 | 340 | }); |
341 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
341 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password) { |
|
342 | 342 | /** @var $user \OC\User\User */ |
343 | 343 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
344 | 344 | }); |
345 | - $userSession->listen('\OC\User', 'logout', function () { |
|
345 | + $userSession->listen('\OC\User', 'logout', function() { |
|
346 | 346 | \OC_Hook::emit('OC_User', 'logout', array()); |
347 | 347 | }); |
348 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
348 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value) { |
|
349 | 349 | /** @var $user \OC\User\User */ |
350 | 350 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
351 | 351 | }); |
@@ -353,11 +353,11 @@ discard block |
||
353 | 353 | }); |
354 | 354 | $this->registerAlias('UserSession', \OCP\IUserSession::class); |
355 | 355 | |
356 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
356 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) { |
|
357 | 357 | return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
358 | 358 | }); |
359 | 359 | |
360 | - $this->registerService(\OCP\INavigationManager::class, function (Server $c) { |
|
360 | + $this->registerService(\OCP\INavigationManager::class, function(Server $c) { |
|
361 | 361 | return new \OC\NavigationManager($c->getAppManager(), |
362 | 362 | $c->getURLGenerator(), |
363 | 363 | $c->getL10NFactory(), |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | }); |
367 | 367 | $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
368 | 368 | |
369 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
369 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
370 | 370 | return new \OC\AllConfig( |
371 | 371 | $c->getSystemConfig() |
372 | 372 | ); |
@@ -374,17 +374,17 @@ discard block |
||
374 | 374 | $this->registerAlias('AllConfig', \OC\AllConfig::class); |
375 | 375 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
376 | 376 | |
377 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
377 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
378 | 378 | return new \OC\SystemConfig($config); |
379 | 379 | }); |
380 | 380 | |
381 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
381 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
382 | 382 | return new \OC\AppConfig($c->getDatabaseConnection()); |
383 | 383 | }); |
384 | 384 | $this->registerAlias('AppConfig', \OC\AppConfig::class); |
385 | 385 | $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
386 | 386 | |
387 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
387 | + $this->registerService(\OCP\L10N\IFactory::class, function(Server $c) { |
|
388 | 388 | return new \OC\L10N\Factory( |
389 | 389 | $c->getConfig(), |
390 | 390 | $c->getRequest(), |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | }); |
395 | 395 | $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
396 | 396 | |
397 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
397 | + $this->registerService(\OCP\IURLGenerator::class, function(Server $c) { |
|
398 | 398 | $config = $c->getConfig(); |
399 | 399 | $cacheFactory = $c->getMemCacheFactory(); |
400 | 400 | return new \OC\URLGenerator( |
@@ -404,10 +404,10 @@ discard block |
||
404 | 404 | }); |
405 | 405 | $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
406 | 406 | |
407 | - $this->registerService('AppHelper', function ($c) { |
|
407 | + $this->registerService('AppHelper', function($c) { |
|
408 | 408 | return new \OC\AppHelper(); |
409 | 409 | }); |
410 | - $this->registerService('AppFetcher', function ($c) { |
|
410 | + $this->registerService('AppFetcher', function($c) { |
|
411 | 411 | return new AppFetcher( |
412 | 412 | $this->getAppDataDir('appstore'), |
413 | 413 | $this->getHTTPClientService(), |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | $this->getConfig() |
416 | 416 | ); |
417 | 417 | }); |
418 | - $this->registerService('CategoryFetcher', function ($c) { |
|
418 | + $this->registerService('CategoryFetcher', function($c) { |
|
419 | 419 | return new CategoryFetcher( |
420 | 420 | $this->getAppDataDir('appstore'), |
421 | 421 | $this->getHTTPClientService(), |
@@ -424,21 +424,21 @@ discard block |
||
424 | 424 | ); |
425 | 425 | }); |
426 | 426 | |
427 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
427 | + $this->registerService(\OCP\ICache::class, function($c) { |
|
428 | 428 | return new Cache\File(); |
429 | 429 | }); |
430 | 430 | $this->registerAlias('UserCache', \OCP\ICache::class); |
431 | 431 | |
432 | - $this->registerService(Factory::class, function (Server $c) { |
|
432 | + $this->registerService(Factory::class, function(Server $c) { |
|
433 | 433 | $config = $c->getConfig(); |
434 | 434 | |
435 | 435 | if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
436 | 436 | $v = \OC_App::getAppVersions(); |
437 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
437 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT.'/version.php')); |
|
438 | 438 | $version = implode(',', $v); |
439 | 439 | $instanceId = \OC_Util::getInstanceId(); |
440 | 440 | $path = \OC::$SERVERROOT; |
441 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
441 | + $prefix = md5($instanceId.'-'.$version.'-'.$path.'-'.\OC::$WEBROOT); |
|
442 | 442 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
443 | 443 | $config->getSystemValue('memcache.local', null), |
444 | 444 | $config->getSystemValue('memcache.distributed', null), |
@@ -455,12 +455,12 @@ discard block |
||
455 | 455 | $this->registerAlias('MemCacheFactory', Factory::class); |
456 | 456 | $this->registerAlias(ICacheFactory::class, Factory::class); |
457 | 457 | |
458 | - $this->registerService('RedisFactory', function (Server $c) { |
|
458 | + $this->registerService('RedisFactory', function(Server $c) { |
|
459 | 459 | $systemConfig = $c->getSystemConfig(); |
460 | 460 | return new RedisFactory($systemConfig); |
461 | 461 | }); |
462 | 462 | |
463 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
463 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
464 | 464 | return new \OC\Activity\Manager( |
465 | 465 | $c->getRequest(), |
466 | 466 | $c->getUserSession(), |
@@ -470,14 +470,14 @@ discard block |
||
470 | 470 | }); |
471 | 471 | $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
472 | 472 | |
473 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
473 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
474 | 474 | return new \OC\Activity\EventMerger( |
475 | 475 | $c->getL10N('lib') |
476 | 476 | ); |
477 | 477 | }); |
478 | 478 | $this->registerAlias(IValidator::class, Validator::class); |
479 | 479 | |
480 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
480 | + $this->registerService(\OCP\IAvatarManager::class, function(Server $c) { |
|
481 | 481 | return new AvatarManager( |
482 | 482 | $c->getUserManager(), |
483 | 483 | $c->getAppDataDir('avatar'), |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | }); |
489 | 489 | $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
490 | 490 | |
491 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
491 | + $this->registerService(\OCP\ILogger::class, function(Server $c) { |
|
492 | 492 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
493 | 493 | $logger = Log::getLogClass($logType); |
494 | 494 | call_user_func(array($logger, 'init')); |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | }); |
498 | 498 | $this->registerAlias('Logger', \OCP\ILogger::class); |
499 | 499 | |
500 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
500 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) { |
|
501 | 501 | $config = $c->getConfig(); |
502 | 502 | return new \OC\BackgroundJob\JobList( |
503 | 503 | $c->getDatabaseConnection(), |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | }); |
508 | 508 | $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
509 | 509 | |
510 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
510 | + $this->registerService(\OCP\Route\IRouter::class, function(Server $c) { |
|
511 | 511 | $cacheFactory = $c->getMemCacheFactory(); |
512 | 512 | $logger = $c->getLogger(); |
513 | 513 | if ($cacheFactory->isAvailable()) { |
@@ -519,32 +519,32 @@ discard block |
||
519 | 519 | }); |
520 | 520 | $this->registerAlias('Router', \OCP\Route\IRouter::class); |
521 | 521 | |
522 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
522 | + $this->registerService(\OCP\ISearch::class, function($c) { |
|
523 | 523 | return new Search(); |
524 | 524 | }); |
525 | 525 | $this->registerAlias('Search', \OCP\ISearch::class); |
526 | 526 | |
527 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
527 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
528 | 528 | return new SecureRandom(); |
529 | 529 | }); |
530 | 530 | $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
531 | 531 | |
532 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
532 | + $this->registerService(\OCP\Security\ICrypto::class, function(Server $c) { |
|
533 | 533 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
534 | 534 | }); |
535 | 535 | $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
536 | 536 | |
537 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
537 | + $this->registerService(\OCP\Security\IHasher::class, function(Server $c) { |
|
538 | 538 | return new Hasher($c->getConfig()); |
539 | 539 | }); |
540 | 540 | $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
541 | 541 | |
542 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
542 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) { |
|
543 | 543 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
544 | 544 | }); |
545 | 545 | $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
546 | 546 | |
547 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
547 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
548 | 548 | $systemConfig = $c->getSystemConfig(); |
549 | 549 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
550 | 550 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | }); |
559 | 559 | $this->registerAlias('DatabaseConnection', IDBConnection::class); |
560 | 560 | |
561 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
561 | + $this->registerService('HTTPHelper', function(Server $c) { |
|
562 | 562 | $config = $c->getConfig(); |
563 | 563 | return new HTTPHelper( |
564 | 564 | $config, |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | ); |
567 | 567 | }); |
568 | 568 | |
569 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
569 | + $this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) { |
|
570 | 570 | $user = \OC_User::getUser(); |
571 | 571 | $uid = $user ? $user : null; |
572 | 572 | return new ClientService( |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | }); |
577 | 577 | $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
578 | 578 | |
579 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
579 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) { |
|
580 | 580 | if ($c->getSystemConfig()->getValue('debug', false)) { |
581 | 581 | return new EventLogger(); |
582 | 582 | } else { |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | }); |
586 | 586 | $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
587 | 587 | |
588 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
588 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) { |
|
589 | 589 | if ($c->getSystemConfig()->getValue('debug', false)) { |
590 | 590 | return new QueryLogger(); |
591 | 591 | } else { |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | }); |
595 | 595 | $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
596 | 596 | |
597 | - $this->registerService(TempManager::class, function (Server $c) { |
|
597 | + $this->registerService(TempManager::class, function(Server $c) { |
|
598 | 598 | return new TempManager( |
599 | 599 | $c->getLogger(), |
600 | 600 | $c->getConfig() |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | $this->registerAlias('TempManager', TempManager::class); |
604 | 604 | $this->registerAlias(ITempManager::class, TempManager::class); |
605 | 605 | |
606 | - $this->registerService(AppManager::class, function (Server $c) { |
|
606 | + $this->registerService(AppManager::class, function(Server $c) { |
|
607 | 607 | return new \OC\App\AppManager( |
608 | 608 | $c->getUserSession(), |
609 | 609 | $c->getAppConfig(), |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | $this->registerAlias('AppManager', AppManager::class); |
616 | 616 | $this->registerAlias(IAppManager::class, AppManager::class); |
617 | 617 | |
618 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
618 | + $this->registerService(\OCP\IDateTimeZone::class, function(Server $c) { |
|
619 | 619 | return new DateTimeZone( |
620 | 620 | $c->getConfig(), |
621 | 621 | $c->getSession() |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | }); |
624 | 624 | $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
625 | 625 | |
626 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
626 | + $this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) { |
|
627 | 627 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
628 | 628 | |
629 | 629 | return new DateTimeFormatter( |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | }); |
634 | 634 | $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
635 | 635 | |
636 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
636 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) { |
|
637 | 637 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
638 | 638 | $listener = new UserMountCacheListener($mountCache); |
639 | 639 | $listener->listen($c->getUserManager()); |
@@ -641,10 +641,10 @@ discard block |
||
641 | 641 | }); |
642 | 642 | $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
643 | 643 | |
644 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
644 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) { |
|
645 | 645 | $loader = \OC\Files\Filesystem::getLoader(); |
646 | 646 | $mountCache = $c->query('UserMountCache'); |
647 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
647 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
648 | 648 | |
649 | 649 | // builtin providers |
650 | 650 | |
@@ -657,14 +657,14 @@ discard block |
||
657 | 657 | }); |
658 | 658 | $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
659 | 659 | |
660 | - $this->registerService('IniWrapper', function ($c) { |
|
660 | + $this->registerService('IniWrapper', function($c) { |
|
661 | 661 | return new IniGetWrapper(); |
662 | 662 | }); |
663 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
663 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
664 | 664 | $jobList = $c->getJobList(); |
665 | 665 | return new AsyncBus($jobList); |
666 | 666 | }); |
667 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
667 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
668 | 668 | return new TrustedDomainHelper($this->getConfig()); |
669 | 669 | }); |
670 | 670 | $this->registerService('Throttler', function(Server $c) { |
@@ -675,10 +675,10 @@ discard block |
||
675 | 675 | $c->getConfig() |
676 | 676 | ); |
677 | 677 | }); |
678 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
678 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
679 | 679 | // IConfig and IAppManager requires a working database. This code |
680 | 680 | // might however be called when ownCloud is not yet setup. |
681 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
681 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
682 | 682 | $config = $c->getConfig(); |
683 | 683 | $appManager = $c->getAppManager(); |
684 | 684 | } else { |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | $c->getTempManager() |
697 | 697 | ); |
698 | 698 | }); |
699 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
699 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
700 | 700 | if (isset($this['urlParams'])) { |
701 | 701 | $urlParams = $this['urlParams']; |
702 | 702 | } else { |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | }); |
733 | 733 | $this->registerAlias('Request', \OCP\IRequest::class); |
734 | 734 | |
735 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
735 | + $this->registerService(\OCP\Mail\IMailer::class, function(Server $c) { |
|
736 | 736 | return new Mailer( |
737 | 737 | $c->getConfig(), |
738 | 738 | $c->getLogger(), |
@@ -744,14 +744,14 @@ discard block |
||
744 | 744 | $this->registerService('LDAPProvider', function(Server $c) { |
745 | 745 | $config = $c->getConfig(); |
746 | 746 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
747 | - if(is_null($factoryClass)) { |
|
747 | + if (is_null($factoryClass)) { |
|
748 | 748 | throw new \Exception('ldapProviderFactory not set'); |
749 | 749 | } |
750 | 750 | /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
751 | 751 | $factory = new $factoryClass($this); |
752 | 752 | return $factory->getLDAPProvider(); |
753 | 753 | }); |
754 | - $this->registerService('LockingProvider', function (Server $c) { |
|
754 | + $this->registerService('LockingProvider', function(Server $c) { |
|
755 | 755 | $ini = $c->getIniWrapper(); |
756 | 756 | $config = $c->getConfig(); |
757 | 757 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -767,37 +767,37 @@ discard block |
||
767 | 767 | return new NoopLockingProvider(); |
768 | 768 | }); |
769 | 769 | |
770 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
770 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function() { |
|
771 | 771 | return new \OC\Files\Mount\Manager(); |
772 | 772 | }); |
773 | 773 | $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
774 | 774 | |
775 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
775 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) { |
|
776 | 776 | return new \OC\Files\Type\Detection( |
777 | 777 | $c->getURLGenerator(), |
778 | 778 | \OC::$configDir, |
779 | - \OC::$SERVERROOT . '/resources/config/' |
|
779 | + \OC::$SERVERROOT.'/resources/config/' |
|
780 | 780 | ); |
781 | 781 | }); |
782 | 782 | $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
783 | 783 | |
784 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
784 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) { |
|
785 | 785 | return new \OC\Files\Type\Loader( |
786 | 786 | $c->getDatabaseConnection() |
787 | 787 | ); |
788 | 788 | }); |
789 | 789 | $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
790 | 790 | |
791 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
791 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
792 | 792 | return new Manager( |
793 | 793 | $c->query(IValidator::class) |
794 | 794 | ); |
795 | 795 | }); |
796 | 796 | $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
797 | 797 | |
798 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
798 | + $this->registerService(\OC\CapabilitiesManager::class, function(Server $c) { |
|
799 | 799 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
800 | - $manager->registerCapability(function () use ($c) { |
|
800 | + $manager->registerCapability(function() use ($c) { |
|
801 | 801 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
802 | 802 | }); |
803 | 803 | return $manager; |
@@ -854,13 +854,13 @@ discard block |
||
854 | 854 | |
855 | 855 | ); |
856 | 856 | }); |
857 | - $this->registerService(EventDispatcher::class, function () { |
|
857 | + $this->registerService(EventDispatcher::class, function() { |
|
858 | 858 | return new EventDispatcher(); |
859 | 859 | }); |
860 | 860 | $this->registerAlias('EventDispatcher', EventDispatcher::class); |
861 | 861 | $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
862 | 862 | |
863 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
863 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
864 | 864 | // FIXME: Instantiiated here due to cyclic dependency |
865 | 865 | $request = new Request( |
866 | 866 | [ |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | $request |
886 | 886 | ); |
887 | 887 | }); |
888 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
888 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
889 | 889 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
890 | 890 | |
891 | 891 | return new CsrfTokenManager( |
@@ -893,10 +893,10 @@ discard block |
||
893 | 893 | $c->query(SessionStorage::class) |
894 | 894 | ); |
895 | 895 | }); |
896 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
896 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
897 | 897 | return new SessionStorage($c->getSession()); |
898 | 898 | }); |
899 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
899 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) { |
|
900 | 900 | return new ContentSecurityPolicyManager(); |
901 | 901 | }); |
902 | 902 | $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
@@ -947,23 +947,23 @@ discard block |
||
947 | 947 | ); |
948 | 948 | return $manager; |
949 | 949 | }); |
950 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
950 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
951 | 951 | return new \OC\Files\AppData\Factory( |
952 | 952 | $c->getRootFolder(), |
953 | 953 | $c->getSystemConfig() |
954 | 954 | ); |
955 | 955 | }); |
956 | 956 | |
957 | - $this->registerService('LockdownManager', function (Server $c) { |
|
957 | + $this->registerService('LockdownManager', function(Server $c) { |
|
958 | 958 | return new LockdownManager(); |
959 | 959 | }); |
960 | 960 | |
961 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
961 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
962 | 962 | return new CloudIdManager(); |
963 | 963 | }); |
964 | 964 | |
965 | 965 | /* To trick DI since we don't extend the DIContainer here */ |
966 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
966 | + $this->registerService(CleanPreviewsBackgroundJob::class, function(Server $c) { |
|
967 | 967 | return new CleanPreviewsBackgroundJob( |
968 | 968 | $c->getRootFolder(), |
969 | 969 | $c->getLogger(), |
@@ -1117,7 +1117,7 @@ discard block |
||
1117 | 1117 | * @deprecated since 9.2.0 use IAppData |
1118 | 1118 | */ |
1119 | 1119 | public function getAppFolder() { |
1120 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1120 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
1121 | 1121 | $root = $this->getRootFolder(); |
1122 | 1122 | if (!$root->nodeExists($dir)) { |
1123 | 1123 | $folder = $root->newFolder($dir); |
@@ -114,8 +114,8 @@ |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | - * @param $appName |
|
118 | - * @param $fileName |
|
117 | + * @param string $appName |
|
118 | + * @param string $fileName |
|
119 | 119 | * @return ISimpleFile |
120 | 120 | */ |
121 | 121 | public function getCachedCSS($appName, $fileName) { |
@@ -25,7 +25,6 @@ |
||
25 | 25 | use Leafo\ScssPhp\Exception\ParserException; |
26 | 26 | use Leafo\ScssPhp\Formatter\Crunched; |
27 | 27 | use Leafo\ScssPhp\Formatter\Expanded; |
28 | - |
|
29 | 28 | use OC\Files\AppData\Factory; |
30 | 29 | use OCP\Files\IAppData; |
31 | 30 | use OCP\Files\NotFoundException; |
@@ -39,251 +39,251 @@ |
||
39 | 39 | |
40 | 40 | class SCSSCacher { |
41 | 41 | |
42 | - /** @var ILogger */ |
|
43 | - protected $logger; |
|
44 | - |
|
45 | - /** @var IAppData */ |
|
46 | - protected $appData; |
|
47 | - |
|
48 | - /** @var IURLGenerator */ |
|
49 | - protected $urlGenerator; |
|
50 | - |
|
51 | - /** @var IConfig */ |
|
52 | - protected $config; |
|
53 | - |
|
54 | - /** @var string */ |
|
55 | - protected $serverRoot; |
|
56 | - |
|
57 | - /** @var ICache */ |
|
58 | - protected $depsCache; |
|
59 | - |
|
60 | - /** |
|
61 | - * @param ILogger $logger |
|
62 | - * @param Factory $appDataFactory |
|
63 | - * @param IURLGenerator $urlGenerator |
|
64 | - * @param IConfig $config |
|
65 | - * @param \OC_Defaults $defaults |
|
66 | - * @param string $serverRoot |
|
67 | - * @param ICache $depsCache |
|
68 | - */ |
|
69 | - public function __construct(ILogger $logger, |
|
70 | - Factory $appDataFactory, |
|
71 | - IURLGenerator $urlGenerator, |
|
72 | - IConfig $config, |
|
73 | - \OC_Defaults $defaults, |
|
74 | - $serverRoot, |
|
75 | - ICache $depsCache) { |
|
76 | - $this->logger = $logger; |
|
77 | - $this->appData = $appDataFactory->get('css'); |
|
78 | - $this->urlGenerator = $urlGenerator; |
|
79 | - $this->config = $config; |
|
80 | - $this->defaults = $defaults; |
|
81 | - $this->serverRoot = $serverRoot; |
|
82 | - $this->depsCache = $depsCache; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Process the caching process if needed |
|
87 | - * @param string $root Root path to the nextcloud installation |
|
88 | - * @param string $file |
|
89 | - * @param string $app The app name |
|
90 | - * @return boolean |
|
91 | - */ |
|
92 | - public function process($root, $file, $app) { |
|
93 | - $path = explode('/', $root . '/' . $file); |
|
94 | - |
|
95 | - $fileNameSCSS = array_pop($path); |
|
96 | - $fileNameCSS = str_replace('.scss', '.css', $fileNameSCSS); |
|
97 | - |
|
98 | - $path = implode('/', $path); |
|
99 | - |
|
100 | - $webDir = substr($path, strlen($this->serverRoot)+1); |
|
101 | - |
|
102 | - try { |
|
103 | - $folder = $this->appData->getFolder($app); |
|
104 | - } catch(NotFoundException $e) { |
|
105 | - // creating css appdata folder |
|
106 | - $folder = $this->appData->newFolder($app); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - if(!$this->variablesChanged() && $this->isCached($fileNameCSS, $folder)) { |
|
111 | - return true; |
|
112 | - } |
|
113 | - return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir); |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * @param $appName |
|
118 | - * @param $fileName |
|
119 | - * @return ISimpleFile |
|
120 | - */ |
|
121 | - public function getCachedCSS($appName, $fileName) { |
|
122 | - $folder = $this->appData->getFolder($appName); |
|
123 | - return $folder->getFile($fileName); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Check if the file is cached or not |
|
128 | - * @param string $fileNameCSS |
|
129 | - * @param ISimpleFolder $folder |
|
130 | - * @return boolean |
|
131 | - */ |
|
132 | - private function isCached($fileNameCSS, ISimpleFolder $folder) { |
|
133 | - try { |
|
134 | - $cachedFile = $folder->getFile($fileNameCSS); |
|
135 | - if ($cachedFile->getSize() > 0) { |
|
136 | - $depFileName = $fileNameCSS . '.deps'; |
|
137 | - $deps = $this->depsCache->get($folder->getName() . '-' . $depFileName); |
|
138 | - if ($deps === null) { |
|
139 | - $depFile = $folder->getFile($depFileName); |
|
140 | - $deps = $depFile->getContent(); |
|
141 | - //Set to memcache for next run |
|
142 | - $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); |
|
143 | - } |
|
144 | - $deps = json_decode($deps, true); |
|
145 | - |
|
146 | - foreach ($deps as $file=>$mtime) { |
|
147 | - if (!file_exists($file) || filemtime($file) > $mtime) { |
|
148 | - return false; |
|
149 | - } |
|
150 | - } |
|
151 | - } |
|
152 | - return true; |
|
153 | - } catch(NotFoundException $e) { |
|
154 | - return false; |
|
155 | - } |
|
156 | - } |
|
157 | - |
|
158 | - /** |
|
159 | - * Check if the variables file has changed |
|
160 | - * @return bool |
|
161 | - */ |
|
162 | - private function variablesChanged() { |
|
163 | - $injectedVariables = $this->getInjectedVariables(); |
|
164 | - if($this->config->getAppValue('core', 'scss.variables') !== md5($injectedVariables)) { |
|
165 | - $this->resetCache(); |
|
166 | - $this->config->setAppValue('core', 'scss.variables', md5($injectedVariables)); |
|
167 | - return true; |
|
168 | - } |
|
169 | - return false; |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Cache the file with AppData |
|
174 | - * @param string $path |
|
175 | - * @param string $fileNameCSS |
|
176 | - * @param string $fileNameSCSS |
|
177 | - * @param ISimpleFolder $folder |
|
178 | - * @param string $webDir |
|
179 | - * @return boolean |
|
180 | - */ |
|
181 | - private function cache($path, $fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $webDir) { |
|
182 | - $scss = new Compiler(); |
|
183 | - $scss->setImportPaths([ |
|
184 | - $path, |
|
185 | - \OC::$SERVERROOT . '/core/css/', |
|
186 | - ]); |
|
187 | - if($this->config->getSystemValue('debug')) { |
|
188 | - // Debug mode |
|
189 | - $scss->setFormatter(Expanded::class); |
|
190 | - $scss->setLineNumberStyle(Compiler::LINE_COMMENTS); |
|
191 | - } else { |
|
192 | - // Compression |
|
193 | - $scss->setFormatter(Crunched::class); |
|
194 | - } |
|
195 | - |
|
196 | - try { |
|
197 | - $cachedfile = $folder->getFile($fileNameCSS); |
|
198 | - } catch(NotFoundException $e) { |
|
199 | - $cachedfile = $folder->newFile($fileNameCSS); |
|
200 | - } |
|
201 | - |
|
202 | - $depFileName = $fileNameCSS . '.deps'; |
|
203 | - try { |
|
204 | - $depFile = $folder->getFile($depFileName); |
|
205 | - } catch (NotFoundException $e) { |
|
206 | - $depFile = $folder->newFile($depFileName); |
|
207 | - } |
|
208 | - |
|
209 | - // Compile |
|
210 | - try { |
|
211 | - $compiledScss = $scss->compile( |
|
212 | - '@import "variables.scss";' . |
|
213 | - $this->getInjectedVariables() . |
|
214 | - '@import "'.$fileNameSCSS.'";'); |
|
215 | - } catch(ParserException $e) { |
|
216 | - $this->logger->error($e, ['app' => 'core']); |
|
217 | - return false; |
|
218 | - } |
|
219 | - |
|
220 | - try { |
|
221 | - $cachedfile->putContent($this->rebaseUrls($compiledScss, $webDir)); |
|
222 | - $depFile->putContent(json_encode($scss->getParsedFiles())); |
|
223 | - $this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']); |
|
224 | - return true; |
|
225 | - } catch(NotPermittedException $e) { |
|
226 | - return false; |
|
227 | - } |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Reset scss cache by deleting all generated css files |
|
232 | - * We need to regenerate all files when variables change |
|
233 | - */ |
|
234 | - private function resetCache() { |
|
235 | - $appDirectory = $this->appData->getDirectoryListing(); |
|
236 | - if(empty($appDirectory)){ |
|
237 | - return; |
|
238 | - } |
|
239 | - foreach ($appDirectory as $folder) { |
|
240 | - foreach ($folder->getDirectoryListing() as $file) { |
|
241 | - if (substr($file->getName(), -3) === "css" || substr($file->getName(), -4) === "deps") { |
|
242 | - $file->delete(); |
|
243 | - } |
|
244 | - } |
|
245 | - } |
|
246 | - } |
|
247 | - |
|
248 | - /** |
|
249 | - * @return string SCSS code for variables from OC_Defaults |
|
250 | - */ |
|
251 | - private function getInjectedVariables() { |
|
252 | - $variables = ''; |
|
253 | - foreach ($this->defaults->getScssVariables() as $key => $value) { |
|
254 | - $variables .= '$' . $key . ': ' . $value . ';'; |
|
255 | - } |
|
256 | - return $variables; |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Add the correct uri prefix to make uri valid again |
|
261 | - * @param string $css |
|
262 | - * @param string $webDir |
|
263 | - * @return string |
|
264 | - */ |
|
265 | - private function rebaseUrls($css, $webDir) { |
|
266 | - $re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x'; |
|
267 | - // OC\Route\Router:75 |
|
268 | - if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { |
|
269 | - $subst = 'url(\'../../'.$webDir.'/$1\')'; |
|
270 | - } else { |
|
271 | - $subst = 'url(\'../../../'.$webDir.'/$1\')'; |
|
272 | - } |
|
273 | - return preg_replace($re, $subst, $css); |
|
274 | - } |
|
275 | - |
|
276 | - /** |
|
277 | - * Return the cached css file uri |
|
278 | - * @param string $appName the app name |
|
279 | - * @param string $fileName |
|
280 | - * @return string |
|
281 | - */ |
|
282 | - public function getCachedSCSS($appName, $fileName) { |
|
283 | - $tmpfileLoc = explode('/', $fileName); |
|
284 | - $fileName = array_pop($tmpfileLoc); |
|
285 | - $fileName = str_replace('.scss', '.css', $fileName); |
|
286 | - |
|
287 | - return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1); |
|
288 | - } |
|
42 | + /** @var ILogger */ |
|
43 | + protected $logger; |
|
44 | + |
|
45 | + /** @var IAppData */ |
|
46 | + protected $appData; |
|
47 | + |
|
48 | + /** @var IURLGenerator */ |
|
49 | + protected $urlGenerator; |
|
50 | + |
|
51 | + /** @var IConfig */ |
|
52 | + protected $config; |
|
53 | + |
|
54 | + /** @var string */ |
|
55 | + protected $serverRoot; |
|
56 | + |
|
57 | + /** @var ICache */ |
|
58 | + protected $depsCache; |
|
59 | + |
|
60 | + /** |
|
61 | + * @param ILogger $logger |
|
62 | + * @param Factory $appDataFactory |
|
63 | + * @param IURLGenerator $urlGenerator |
|
64 | + * @param IConfig $config |
|
65 | + * @param \OC_Defaults $defaults |
|
66 | + * @param string $serverRoot |
|
67 | + * @param ICache $depsCache |
|
68 | + */ |
|
69 | + public function __construct(ILogger $logger, |
|
70 | + Factory $appDataFactory, |
|
71 | + IURLGenerator $urlGenerator, |
|
72 | + IConfig $config, |
|
73 | + \OC_Defaults $defaults, |
|
74 | + $serverRoot, |
|
75 | + ICache $depsCache) { |
|
76 | + $this->logger = $logger; |
|
77 | + $this->appData = $appDataFactory->get('css'); |
|
78 | + $this->urlGenerator = $urlGenerator; |
|
79 | + $this->config = $config; |
|
80 | + $this->defaults = $defaults; |
|
81 | + $this->serverRoot = $serverRoot; |
|
82 | + $this->depsCache = $depsCache; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Process the caching process if needed |
|
87 | + * @param string $root Root path to the nextcloud installation |
|
88 | + * @param string $file |
|
89 | + * @param string $app The app name |
|
90 | + * @return boolean |
|
91 | + */ |
|
92 | + public function process($root, $file, $app) { |
|
93 | + $path = explode('/', $root . '/' . $file); |
|
94 | + |
|
95 | + $fileNameSCSS = array_pop($path); |
|
96 | + $fileNameCSS = str_replace('.scss', '.css', $fileNameSCSS); |
|
97 | + |
|
98 | + $path = implode('/', $path); |
|
99 | + |
|
100 | + $webDir = substr($path, strlen($this->serverRoot)+1); |
|
101 | + |
|
102 | + try { |
|
103 | + $folder = $this->appData->getFolder($app); |
|
104 | + } catch(NotFoundException $e) { |
|
105 | + // creating css appdata folder |
|
106 | + $folder = $this->appData->newFolder($app); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + if(!$this->variablesChanged() && $this->isCached($fileNameCSS, $folder)) { |
|
111 | + return true; |
|
112 | + } |
|
113 | + return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir); |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * @param $appName |
|
118 | + * @param $fileName |
|
119 | + * @return ISimpleFile |
|
120 | + */ |
|
121 | + public function getCachedCSS($appName, $fileName) { |
|
122 | + $folder = $this->appData->getFolder($appName); |
|
123 | + return $folder->getFile($fileName); |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Check if the file is cached or not |
|
128 | + * @param string $fileNameCSS |
|
129 | + * @param ISimpleFolder $folder |
|
130 | + * @return boolean |
|
131 | + */ |
|
132 | + private function isCached($fileNameCSS, ISimpleFolder $folder) { |
|
133 | + try { |
|
134 | + $cachedFile = $folder->getFile($fileNameCSS); |
|
135 | + if ($cachedFile->getSize() > 0) { |
|
136 | + $depFileName = $fileNameCSS . '.deps'; |
|
137 | + $deps = $this->depsCache->get($folder->getName() . '-' . $depFileName); |
|
138 | + if ($deps === null) { |
|
139 | + $depFile = $folder->getFile($depFileName); |
|
140 | + $deps = $depFile->getContent(); |
|
141 | + //Set to memcache for next run |
|
142 | + $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); |
|
143 | + } |
|
144 | + $deps = json_decode($deps, true); |
|
145 | + |
|
146 | + foreach ($deps as $file=>$mtime) { |
|
147 | + if (!file_exists($file) || filemtime($file) > $mtime) { |
|
148 | + return false; |
|
149 | + } |
|
150 | + } |
|
151 | + } |
|
152 | + return true; |
|
153 | + } catch(NotFoundException $e) { |
|
154 | + return false; |
|
155 | + } |
|
156 | + } |
|
157 | + |
|
158 | + /** |
|
159 | + * Check if the variables file has changed |
|
160 | + * @return bool |
|
161 | + */ |
|
162 | + private function variablesChanged() { |
|
163 | + $injectedVariables = $this->getInjectedVariables(); |
|
164 | + if($this->config->getAppValue('core', 'scss.variables') !== md5($injectedVariables)) { |
|
165 | + $this->resetCache(); |
|
166 | + $this->config->setAppValue('core', 'scss.variables', md5($injectedVariables)); |
|
167 | + return true; |
|
168 | + } |
|
169 | + return false; |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Cache the file with AppData |
|
174 | + * @param string $path |
|
175 | + * @param string $fileNameCSS |
|
176 | + * @param string $fileNameSCSS |
|
177 | + * @param ISimpleFolder $folder |
|
178 | + * @param string $webDir |
|
179 | + * @return boolean |
|
180 | + */ |
|
181 | + private function cache($path, $fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $webDir) { |
|
182 | + $scss = new Compiler(); |
|
183 | + $scss->setImportPaths([ |
|
184 | + $path, |
|
185 | + \OC::$SERVERROOT . '/core/css/', |
|
186 | + ]); |
|
187 | + if($this->config->getSystemValue('debug')) { |
|
188 | + // Debug mode |
|
189 | + $scss->setFormatter(Expanded::class); |
|
190 | + $scss->setLineNumberStyle(Compiler::LINE_COMMENTS); |
|
191 | + } else { |
|
192 | + // Compression |
|
193 | + $scss->setFormatter(Crunched::class); |
|
194 | + } |
|
195 | + |
|
196 | + try { |
|
197 | + $cachedfile = $folder->getFile($fileNameCSS); |
|
198 | + } catch(NotFoundException $e) { |
|
199 | + $cachedfile = $folder->newFile($fileNameCSS); |
|
200 | + } |
|
201 | + |
|
202 | + $depFileName = $fileNameCSS . '.deps'; |
|
203 | + try { |
|
204 | + $depFile = $folder->getFile($depFileName); |
|
205 | + } catch (NotFoundException $e) { |
|
206 | + $depFile = $folder->newFile($depFileName); |
|
207 | + } |
|
208 | + |
|
209 | + // Compile |
|
210 | + try { |
|
211 | + $compiledScss = $scss->compile( |
|
212 | + '@import "variables.scss";' . |
|
213 | + $this->getInjectedVariables() . |
|
214 | + '@import "'.$fileNameSCSS.'";'); |
|
215 | + } catch(ParserException $e) { |
|
216 | + $this->logger->error($e, ['app' => 'core']); |
|
217 | + return false; |
|
218 | + } |
|
219 | + |
|
220 | + try { |
|
221 | + $cachedfile->putContent($this->rebaseUrls($compiledScss, $webDir)); |
|
222 | + $depFile->putContent(json_encode($scss->getParsedFiles())); |
|
223 | + $this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']); |
|
224 | + return true; |
|
225 | + } catch(NotPermittedException $e) { |
|
226 | + return false; |
|
227 | + } |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Reset scss cache by deleting all generated css files |
|
232 | + * We need to regenerate all files when variables change |
|
233 | + */ |
|
234 | + private function resetCache() { |
|
235 | + $appDirectory = $this->appData->getDirectoryListing(); |
|
236 | + if(empty($appDirectory)){ |
|
237 | + return; |
|
238 | + } |
|
239 | + foreach ($appDirectory as $folder) { |
|
240 | + foreach ($folder->getDirectoryListing() as $file) { |
|
241 | + if (substr($file->getName(), -3) === "css" || substr($file->getName(), -4) === "deps") { |
|
242 | + $file->delete(); |
|
243 | + } |
|
244 | + } |
|
245 | + } |
|
246 | + } |
|
247 | + |
|
248 | + /** |
|
249 | + * @return string SCSS code for variables from OC_Defaults |
|
250 | + */ |
|
251 | + private function getInjectedVariables() { |
|
252 | + $variables = ''; |
|
253 | + foreach ($this->defaults->getScssVariables() as $key => $value) { |
|
254 | + $variables .= '$' . $key . ': ' . $value . ';'; |
|
255 | + } |
|
256 | + return $variables; |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Add the correct uri prefix to make uri valid again |
|
261 | + * @param string $css |
|
262 | + * @param string $webDir |
|
263 | + * @return string |
|
264 | + */ |
|
265 | + private function rebaseUrls($css, $webDir) { |
|
266 | + $re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x'; |
|
267 | + // OC\Route\Router:75 |
|
268 | + if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { |
|
269 | + $subst = 'url(\'../../'.$webDir.'/$1\')'; |
|
270 | + } else { |
|
271 | + $subst = 'url(\'../../../'.$webDir.'/$1\')'; |
|
272 | + } |
|
273 | + return preg_replace($re, $subst, $css); |
|
274 | + } |
|
275 | + |
|
276 | + /** |
|
277 | + * Return the cached css file uri |
|
278 | + * @param string $appName the app name |
|
279 | + * @param string $fileName |
|
280 | + * @return string |
|
281 | + */ |
|
282 | + public function getCachedSCSS($appName, $fileName) { |
|
283 | + $tmpfileLoc = explode('/', $fileName); |
|
284 | + $fileName = array_pop($tmpfileLoc); |
|
285 | + $fileName = str_replace('.scss', '.css', $fileName); |
|
286 | + |
|
287 | + return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1); |
|
288 | + } |
|
289 | 289 | } |
@@ -90,24 +90,24 @@ discard block |
||
90 | 90 | * @return boolean |
91 | 91 | */ |
92 | 92 | public function process($root, $file, $app) { |
93 | - $path = explode('/', $root . '/' . $file); |
|
93 | + $path = explode('/', $root.'/'.$file); |
|
94 | 94 | |
95 | 95 | $fileNameSCSS = array_pop($path); |
96 | 96 | $fileNameCSS = str_replace('.scss', '.css', $fileNameSCSS); |
97 | 97 | |
98 | 98 | $path = implode('/', $path); |
99 | 99 | |
100 | - $webDir = substr($path, strlen($this->serverRoot)+1); |
|
100 | + $webDir = substr($path, strlen($this->serverRoot) + 1); |
|
101 | 101 | |
102 | 102 | try { |
103 | 103 | $folder = $this->appData->getFolder($app); |
104 | - } catch(NotFoundException $e) { |
|
104 | + } catch (NotFoundException $e) { |
|
105 | 105 | // creating css appdata folder |
106 | 106 | $folder = $this->appData->newFolder($app); |
107 | 107 | } |
108 | 108 | |
109 | 109 | |
110 | - if(!$this->variablesChanged() && $this->isCached($fileNameCSS, $folder)) { |
|
110 | + if (!$this->variablesChanged() && $this->isCached($fileNameCSS, $folder)) { |
|
111 | 111 | return true; |
112 | 112 | } |
113 | 113 | return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir); |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | try { |
134 | 134 | $cachedFile = $folder->getFile($fileNameCSS); |
135 | 135 | if ($cachedFile->getSize() > 0) { |
136 | - $depFileName = $fileNameCSS . '.deps'; |
|
137 | - $deps = $this->depsCache->get($folder->getName() . '-' . $depFileName); |
|
136 | + $depFileName = $fileNameCSS.'.deps'; |
|
137 | + $deps = $this->depsCache->get($folder->getName().'-'.$depFileName); |
|
138 | 138 | if ($deps === null) { |
139 | 139 | $depFile = $folder->getFile($depFileName); |
140 | 140 | $deps = $depFile->getContent(); |
141 | 141 | //Set to memcache for next run |
142 | - $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); |
|
142 | + $this->depsCache->set($folder->getName().'-'.$depFileName, $deps); |
|
143 | 143 | } |
144 | 144 | $deps = json_decode($deps, true); |
145 | 145 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | } |
151 | 151 | } |
152 | 152 | return true; |
153 | - } catch(NotFoundException $e) { |
|
153 | + } catch (NotFoundException $e) { |
|
154 | 154 | return false; |
155 | 155 | } |
156 | 156 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | private function variablesChanged() { |
163 | 163 | $injectedVariables = $this->getInjectedVariables(); |
164 | - if($this->config->getAppValue('core', 'scss.variables') !== md5($injectedVariables)) { |
|
164 | + if ($this->config->getAppValue('core', 'scss.variables') !== md5($injectedVariables)) { |
|
165 | 165 | $this->resetCache(); |
166 | 166 | $this->config->setAppValue('core', 'scss.variables', md5($injectedVariables)); |
167 | 167 | return true; |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | $scss = new Compiler(); |
183 | 183 | $scss->setImportPaths([ |
184 | 184 | $path, |
185 | - \OC::$SERVERROOT . '/core/css/', |
|
185 | + \OC::$SERVERROOT.'/core/css/', |
|
186 | 186 | ]); |
187 | - if($this->config->getSystemValue('debug')) { |
|
187 | + if ($this->config->getSystemValue('debug')) { |
|
188 | 188 | // Debug mode |
189 | 189 | $scss->setFormatter(Expanded::class); |
190 | 190 | $scss->setLineNumberStyle(Compiler::LINE_COMMENTS); |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | |
196 | 196 | try { |
197 | 197 | $cachedfile = $folder->getFile($fileNameCSS); |
198 | - } catch(NotFoundException $e) { |
|
198 | + } catch (NotFoundException $e) { |
|
199 | 199 | $cachedfile = $folder->newFile($fileNameCSS); |
200 | 200 | } |
201 | 201 | |
202 | - $depFileName = $fileNameCSS . '.deps'; |
|
202 | + $depFileName = $fileNameCSS.'.deps'; |
|
203 | 203 | try { |
204 | 204 | $depFile = $folder->getFile($depFileName); |
205 | 205 | } catch (NotFoundException $e) { |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | // Compile |
210 | 210 | try { |
211 | 211 | $compiledScss = $scss->compile( |
212 | - '@import "variables.scss";' . |
|
213 | - $this->getInjectedVariables() . |
|
212 | + '@import "variables.scss";'. |
|
213 | + $this->getInjectedVariables(). |
|
214 | 214 | '@import "'.$fileNameSCSS.'";'); |
215 | - } catch(ParserException $e) { |
|
215 | + } catch (ParserException $e) { |
|
216 | 216 | $this->logger->error($e, ['app' => 'core']); |
217 | 217 | return false; |
218 | 218 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $depFile->putContent(json_encode($scss->getParsedFiles())); |
223 | 223 | $this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']); |
224 | 224 | return true; |
225 | - } catch(NotPermittedException $e) { |
|
225 | + } catch (NotPermittedException $e) { |
|
226 | 226 | return false; |
227 | 227 | } |
228 | 228 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | private function resetCache() { |
235 | 235 | $appDirectory = $this->appData->getDirectoryListing(); |
236 | - if(empty($appDirectory)){ |
|
236 | + if (empty($appDirectory)) { |
|
237 | 237 | return; |
238 | 238 | } |
239 | 239 | foreach ($appDirectory as $folder) { |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | private function getInjectedVariables() { |
252 | 252 | $variables = ''; |
253 | 253 | foreach ($this->defaults->getScssVariables() as $key => $value) { |
254 | - $variables .= '$' . $key . ': ' . $value . ';'; |
|
254 | + $variables .= '$'.$key.': '.$value.';'; |
|
255 | 255 | } |
256 | 256 | return $variables; |
257 | 257 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | private function rebaseUrls($css, $webDir) { |
266 | 266 | $re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x'; |
267 | 267 | // OC\Route\Router:75 |
268 | - if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { |
|
268 | + if (($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { |
|
269 | 269 | $subst = 'url(\'../../'.$webDir.'/$1\')'; |
270 | 270 | } else { |
271 | 271 | $subst = 'url(\'../../../'.$webDir.'/$1\')'; |
@@ -56,312 +56,312 @@ discard block |
||
56 | 56 | * @package OCA\Theming\Controller |
57 | 57 | */ |
58 | 58 | class ThemingController extends Controller { |
59 | - /** @var ThemingDefaults */ |
|
60 | - private $themingDefaults; |
|
61 | - /** @var Util */ |
|
62 | - private $util; |
|
63 | - /** @var ITimeFactory */ |
|
64 | - private $timeFactory; |
|
65 | - /** @var IL10N */ |
|
66 | - private $l10n; |
|
67 | - /** @var IConfig */ |
|
68 | - private $config; |
|
69 | - /** @var ITempManager */ |
|
70 | - private $tempManager; |
|
71 | - /** @var IAppData */ |
|
72 | - private $appData; |
|
73 | - /** @var SCSSCacher */ |
|
74 | - private $scssCacher; |
|
59 | + /** @var ThemingDefaults */ |
|
60 | + private $themingDefaults; |
|
61 | + /** @var Util */ |
|
62 | + private $util; |
|
63 | + /** @var ITimeFactory */ |
|
64 | + private $timeFactory; |
|
65 | + /** @var IL10N */ |
|
66 | + private $l10n; |
|
67 | + /** @var IConfig */ |
|
68 | + private $config; |
|
69 | + /** @var ITempManager */ |
|
70 | + private $tempManager; |
|
71 | + /** @var IAppData */ |
|
72 | + private $appData; |
|
73 | + /** @var SCSSCacher */ |
|
74 | + private $scssCacher; |
|
75 | 75 | |
76 | - /** |
|
77 | - * ThemingController constructor. |
|
78 | - * |
|
79 | - * @param string $appName |
|
80 | - * @param IRequest $request |
|
81 | - * @param IConfig $config |
|
82 | - * @param ThemingDefaults $themingDefaults |
|
83 | - * @param Util $util |
|
84 | - * @param ITimeFactory $timeFactory |
|
85 | - * @param IL10N $l |
|
86 | - * @param ITempManager $tempManager |
|
87 | - * @param IAppData $appData |
|
88 | - * @param SCSSCacher $scssCacher |
|
89 | - */ |
|
90 | - public function __construct( |
|
91 | - $appName, |
|
92 | - IRequest $request, |
|
93 | - IConfig $config, |
|
94 | - ThemingDefaults $themingDefaults, |
|
95 | - Util $util, |
|
96 | - ITimeFactory $timeFactory, |
|
97 | - IL10N $l, |
|
98 | - ITempManager $tempManager, |
|
99 | - IAppData $appData, |
|
100 | - SCSSCacher $scssCacher |
|
101 | - ) { |
|
102 | - parent::__construct($appName, $request); |
|
76 | + /** |
|
77 | + * ThemingController constructor. |
|
78 | + * |
|
79 | + * @param string $appName |
|
80 | + * @param IRequest $request |
|
81 | + * @param IConfig $config |
|
82 | + * @param ThemingDefaults $themingDefaults |
|
83 | + * @param Util $util |
|
84 | + * @param ITimeFactory $timeFactory |
|
85 | + * @param IL10N $l |
|
86 | + * @param ITempManager $tempManager |
|
87 | + * @param IAppData $appData |
|
88 | + * @param SCSSCacher $scssCacher |
|
89 | + */ |
|
90 | + public function __construct( |
|
91 | + $appName, |
|
92 | + IRequest $request, |
|
93 | + IConfig $config, |
|
94 | + ThemingDefaults $themingDefaults, |
|
95 | + Util $util, |
|
96 | + ITimeFactory $timeFactory, |
|
97 | + IL10N $l, |
|
98 | + ITempManager $tempManager, |
|
99 | + IAppData $appData, |
|
100 | + SCSSCacher $scssCacher |
|
101 | + ) { |
|
102 | + parent::__construct($appName, $request); |
|
103 | 103 | |
104 | - $this->themingDefaults = $themingDefaults; |
|
105 | - $this->util = $util; |
|
106 | - $this->timeFactory = $timeFactory; |
|
107 | - $this->l10n = $l; |
|
108 | - $this->config = $config; |
|
109 | - $this->tempManager = $tempManager; |
|
110 | - $this->appData = $appData; |
|
111 | - $this->scssCacher = $scssCacher; |
|
112 | - } |
|
104 | + $this->themingDefaults = $themingDefaults; |
|
105 | + $this->util = $util; |
|
106 | + $this->timeFactory = $timeFactory; |
|
107 | + $this->l10n = $l; |
|
108 | + $this->config = $config; |
|
109 | + $this->tempManager = $tempManager; |
|
110 | + $this->appData = $appData; |
|
111 | + $this->scssCacher = $scssCacher; |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * @param string $setting |
|
116 | - * @param string $value |
|
117 | - * @return DataResponse |
|
118 | - * @internal param string $color |
|
119 | - */ |
|
120 | - public function updateStylesheet($setting, $value) { |
|
121 | - $value = trim($value); |
|
122 | - switch ($setting) { |
|
123 | - case 'name': |
|
124 | - if (strlen($value) > 250) { |
|
125 | - return new DataResponse([ |
|
126 | - 'data' => [ |
|
127 | - 'message' => $this->l10n->t('The given name is too long'), |
|
128 | - ], |
|
129 | - 'status' => 'error' |
|
130 | - ]); |
|
131 | - } |
|
132 | - break; |
|
133 | - case 'url': |
|
134 | - if (strlen($value) > 500) { |
|
135 | - return new DataResponse([ |
|
136 | - 'data' => [ |
|
137 | - 'message' => $this->l10n->t('The given web address is too long'), |
|
138 | - ], |
|
139 | - 'status' => 'error' |
|
140 | - ]); |
|
141 | - } |
|
142 | - break; |
|
143 | - case 'slogan': |
|
144 | - if (strlen($value) > 500) { |
|
145 | - return new DataResponse([ |
|
146 | - 'data' => [ |
|
147 | - 'message' => $this->l10n->t('The given slogan is too long'), |
|
148 | - ], |
|
149 | - 'status' => 'error' |
|
150 | - ]); |
|
151 | - } |
|
152 | - break; |
|
153 | - case 'color': |
|
154 | - if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) { |
|
155 | - return new DataResponse([ |
|
156 | - 'data' => [ |
|
157 | - 'message' => $this->l10n->t('The given color is invalid'), |
|
158 | - ], |
|
159 | - 'status' => 'error' |
|
160 | - ]); |
|
161 | - } |
|
162 | - break; |
|
163 | - } |
|
114 | + /** |
|
115 | + * @param string $setting |
|
116 | + * @param string $value |
|
117 | + * @return DataResponse |
|
118 | + * @internal param string $color |
|
119 | + */ |
|
120 | + public function updateStylesheet($setting, $value) { |
|
121 | + $value = trim($value); |
|
122 | + switch ($setting) { |
|
123 | + case 'name': |
|
124 | + if (strlen($value) > 250) { |
|
125 | + return new DataResponse([ |
|
126 | + 'data' => [ |
|
127 | + 'message' => $this->l10n->t('The given name is too long'), |
|
128 | + ], |
|
129 | + 'status' => 'error' |
|
130 | + ]); |
|
131 | + } |
|
132 | + break; |
|
133 | + case 'url': |
|
134 | + if (strlen($value) > 500) { |
|
135 | + return new DataResponse([ |
|
136 | + 'data' => [ |
|
137 | + 'message' => $this->l10n->t('The given web address is too long'), |
|
138 | + ], |
|
139 | + 'status' => 'error' |
|
140 | + ]); |
|
141 | + } |
|
142 | + break; |
|
143 | + case 'slogan': |
|
144 | + if (strlen($value) > 500) { |
|
145 | + return new DataResponse([ |
|
146 | + 'data' => [ |
|
147 | + 'message' => $this->l10n->t('The given slogan is too long'), |
|
148 | + ], |
|
149 | + 'status' => 'error' |
|
150 | + ]); |
|
151 | + } |
|
152 | + break; |
|
153 | + case 'color': |
|
154 | + if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) { |
|
155 | + return new DataResponse([ |
|
156 | + 'data' => [ |
|
157 | + 'message' => $this->l10n->t('The given color is invalid'), |
|
158 | + ], |
|
159 | + 'status' => 'error' |
|
160 | + ]); |
|
161 | + } |
|
162 | + break; |
|
163 | + } |
|
164 | 164 | |
165 | - $this->themingDefaults->set($setting, $value); |
|
166 | - return new DataResponse( |
|
167 | - [ |
|
168 | - 'data' => |
|
169 | - [ |
|
170 | - 'message' => $this->l10n->t('Saved') |
|
171 | - ], |
|
172 | - 'status' => 'success' |
|
173 | - ] |
|
174 | - ); |
|
175 | - } |
|
165 | + $this->themingDefaults->set($setting, $value); |
|
166 | + return new DataResponse( |
|
167 | + [ |
|
168 | + 'data' => |
|
169 | + [ |
|
170 | + 'message' => $this->l10n->t('Saved') |
|
171 | + ], |
|
172 | + 'status' => 'success' |
|
173 | + ] |
|
174 | + ); |
|
175 | + } |
|
176 | 176 | |
177 | - /** |
|
178 | - * Update the logos and background image |
|
179 | - * |
|
180 | - * @return DataResponse |
|
181 | - */ |
|
182 | - public function updateLogo() { |
|
183 | - $newLogo = $this->request->getUploadedFile('uploadlogo'); |
|
184 | - $newBackgroundLogo = $this->request->getUploadedFile('upload-login-background'); |
|
185 | - if (empty($newLogo) && empty($newBackgroundLogo)) { |
|
186 | - return new DataResponse( |
|
187 | - [ |
|
188 | - 'data' => [ |
|
189 | - 'message' => $this->l10n->t('No file uploaded') |
|
190 | - ] |
|
191 | - ], |
|
192 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
193 | - ); |
|
194 | - } |
|
177 | + /** |
|
178 | + * Update the logos and background image |
|
179 | + * |
|
180 | + * @return DataResponse |
|
181 | + */ |
|
182 | + public function updateLogo() { |
|
183 | + $newLogo = $this->request->getUploadedFile('uploadlogo'); |
|
184 | + $newBackgroundLogo = $this->request->getUploadedFile('upload-login-background'); |
|
185 | + if (empty($newLogo) && empty($newBackgroundLogo)) { |
|
186 | + return new DataResponse( |
|
187 | + [ |
|
188 | + 'data' => [ |
|
189 | + 'message' => $this->l10n->t('No file uploaded') |
|
190 | + ] |
|
191 | + ], |
|
192 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
193 | + ); |
|
194 | + } |
|
195 | 195 | |
196 | - $name = ''; |
|
197 | - try { |
|
198 | - $folder = $this->appData->getFolder('images'); |
|
199 | - } catch (NotFoundException $e) { |
|
200 | - $folder = $this->appData->newFolder('images'); |
|
201 | - } |
|
196 | + $name = ''; |
|
197 | + try { |
|
198 | + $folder = $this->appData->getFolder('images'); |
|
199 | + } catch (NotFoundException $e) { |
|
200 | + $folder = $this->appData->newFolder('images'); |
|
201 | + } |
|
202 | 202 | |
203 | - if (!empty($newLogo)) { |
|
204 | - $target = $folder->newFile('logo'); |
|
205 | - $target->putContent(file_get_contents($newLogo['tmp_name'], 'r')); |
|
206 | - $this->themingDefaults->set('logoMime', $newLogo['type']); |
|
207 | - $name = $newLogo['name']; |
|
208 | - } |
|
209 | - if (!empty($newBackgroundLogo)) { |
|
210 | - $target = $folder->newFile('background'); |
|
211 | - $image = @imagecreatefromstring(file_get_contents($newBackgroundLogo['tmp_name'], 'r')); |
|
212 | - if ($image === false) { |
|
213 | - return new DataResponse( |
|
214 | - [ |
|
215 | - 'data' => [ |
|
216 | - 'message' => $this->l10n->t('Unsupported image type'), |
|
217 | - ], |
|
218 | - 'status' => 'failure', |
|
219 | - ], |
|
220 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
221 | - ); |
|
222 | - } |
|
203 | + if (!empty($newLogo)) { |
|
204 | + $target = $folder->newFile('logo'); |
|
205 | + $target->putContent(file_get_contents($newLogo['tmp_name'], 'r')); |
|
206 | + $this->themingDefaults->set('logoMime', $newLogo['type']); |
|
207 | + $name = $newLogo['name']; |
|
208 | + } |
|
209 | + if (!empty($newBackgroundLogo)) { |
|
210 | + $target = $folder->newFile('background'); |
|
211 | + $image = @imagecreatefromstring(file_get_contents($newBackgroundLogo['tmp_name'], 'r')); |
|
212 | + if ($image === false) { |
|
213 | + return new DataResponse( |
|
214 | + [ |
|
215 | + 'data' => [ |
|
216 | + 'message' => $this->l10n->t('Unsupported image type'), |
|
217 | + ], |
|
218 | + 'status' => 'failure', |
|
219 | + ], |
|
220 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
221 | + ); |
|
222 | + } |
|
223 | 223 | |
224 | - // Optimize the image since some people may upload images that will be |
|
225 | - // either to big or are not progressive rendering. |
|
226 | - $tmpFile = $this->tempManager->getTemporaryFile(); |
|
227 | - if (function_exists('imagescale')) { |
|
228 | - // FIXME: Once PHP 5.5.0 is a requirement the above check can be removed |
|
229 | - // Workaround for https://bugs.php.net/bug.php?id=65171 |
|
230 | - $newHeight = imagesy($image) / (imagesx($image) / 1920); |
|
231 | - $image = imagescale($image, 1920, $newHeight); |
|
232 | - } |
|
233 | - imageinterlace($image, 1); |
|
234 | - imagejpeg($image, $tmpFile, 75); |
|
235 | - imagedestroy($image); |
|
224 | + // Optimize the image since some people may upload images that will be |
|
225 | + // either to big or are not progressive rendering. |
|
226 | + $tmpFile = $this->tempManager->getTemporaryFile(); |
|
227 | + if (function_exists('imagescale')) { |
|
228 | + // FIXME: Once PHP 5.5.0 is a requirement the above check can be removed |
|
229 | + // Workaround for https://bugs.php.net/bug.php?id=65171 |
|
230 | + $newHeight = imagesy($image) / (imagesx($image) / 1920); |
|
231 | + $image = imagescale($image, 1920, $newHeight); |
|
232 | + } |
|
233 | + imageinterlace($image, 1); |
|
234 | + imagejpeg($image, $tmpFile, 75); |
|
235 | + imagedestroy($image); |
|
236 | 236 | |
237 | - $target->putContent(file_get_contents($tmpFile, 'r')); |
|
238 | - $this->themingDefaults->set('backgroundMime', $newBackgroundLogo['type']); |
|
239 | - $name = $newBackgroundLogo['name']; |
|
240 | - } |
|
237 | + $target->putContent(file_get_contents($tmpFile, 'r')); |
|
238 | + $this->themingDefaults->set('backgroundMime', $newBackgroundLogo['type']); |
|
239 | + $name = $newBackgroundLogo['name']; |
|
240 | + } |
|
241 | 241 | |
242 | - return new DataResponse( |
|
243 | - [ |
|
244 | - 'data' => |
|
245 | - [ |
|
246 | - 'name' => $name, |
|
247 | - 'message' => $this->l10n->t('Saved') |
|
248 | - ], |
|
249 | - 'status' => 'success' |
|
250 | - ] |
|
251 | - ); |
|
252 | - } |
|
242 | + return new DataResponse( |
|
243 | + [ |
|
244 | + 'data' => |
|
245 | + [ |
|
246 | + 'name' => $name, |
|
247 | + 'message' => $this->l10n->t('Saved') |
|
248 | + ], |
|
249 | + 'status' => 'success' |
|
250 | + ] |
|
251 | + ); |
|
252 | + } |
|
253 | 253 | |
254 | - /** |
|
255 | - * Revert setting to default value |
|
256 | - * |
|
257 | - * @param string $setting setting which should be reverted |
|
258 | - * @return DataResponse |
|
259 | - */ |
|
260 | - public function undo($setting) { |
|
261 | - $value = $this->themingDefaults->undo($setting); |
|
262 | - return new DataResponse( |
|
263 | - [ |
|
264 | - 'data' => |
|
265 | - [ |
|
266 | - 'value' => $value, |
|
267 | - 'message' => $this->l10n->t('Saved') |
|
268 | - ], |
|
269 | - 'status' => 'success' |
|
270 | - ] |
|
271 | - ); |
|
272 | - } |
|
254 | + /** |
|
255 | + * Revert setting to default value |
|
256 | + * |
|
257 | + * @param string $setting setting which should be reverted |
|
258 | + * @return DataResponse |
|
259 | + */ |
|
260 | + public function undo($setting) { |
|
261 | + $value = $this->themingDefaults->undo($setting); |
|
262 | + return new DataResponse( |
|
263 | + [ |
|
264 | + 'data' => |
|
265 | + [ |
|
266 | + 'value' => $value, |
|
267 | + 'message' => $this->l10n->t('Saved') |
|
268 | + ], |
|
269 | + 'status' => 'success' |
|
270 | + ] |
|
271 | + ); |
|
272 | + } |
|
273 | 273 | |
274 | - /** |
|
275 | - * @PublicPage |
|
276 | - * @NoCSRFRequired |
|
277 | - * |
|
278 | - * @return FileDisplayResponse|NotFoundResponse |
|
279 | - */ |
|
280 | - public function getLogo() { |
|
281 | - try { |
|
282 | - /** @var File $file */ |
|
283 | - $file = $this->appData->getFolder('images')->getFile('logo'); |
|
284 | - } catch (NotFoundException $e) { |
|
285 | - return new NotFoundResponse(); |
|
286 | - } |
|
274 | + /** |
|
275 | + * @PublicPage |
|
276 | + * @NoCSRFRequired |
|
277 | + * |
|
278 | + * @return FileDisplayResponse|NotFoundResponse |
|
279 | + */ |
|
280 | + public function getLogo() { |
|
281 | + try { |
|
282 | + /** @var File $file */ |
|
283 | + $file = $this->appData->getFolder('images')->getFile('logo'); |
|
284 | + } catch (NotFoundException $e) { |
|
285 | + return new NotFoundResponse(); |
|
286 | + } |
|
287 | 287 | |
288 | - $response = new FileDisplayResponse($file); |
|
289 | - $response->cacheFor(3600); |
|
290 | - $expires = new \DateTime(); |
|
291 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
292 | - $expires->add(new \DateInterval('PT24H')); |
|
293 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
294 | - $response->addHeader('Pragma', 'cache'); |
|
295 | - $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', '')); |
|
296 | - return $response; |
|
297 | - } |
|
288 | + $response = new FileDisplayResponse($file); |
|
289 | + $response->cacheFor(3600); |
|
290 | + $expires = new \DateTime(); |
|
291 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
292 | + $expires->add(new \DateInterval('PT24H')); |
|
293 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
294 | + $response->addHeader('Pragma', 'cache'); |
|
295 | + $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', '')); |
|
296 | + return $response; |
|
297 | + } |
|
298 | 298 | |
299 | - /** |
|
300 | - * @PublicPage |
|
301 | - * @NoCSRFRequired |
|
302 | - * |
|
303 | - * @return FileDisplayResponse|NotFoundResponse |
|
304 | - */ |
|
305 | - public function getLoginBackground() { |
|
306 | - try { |
|
307 | - /** @var File $file */ |
|
308 | - $file = $this->appData->getFolder('images')->getFile('background'); |
|
309 | - } catch (NotFoundException $e) { |
|
310 | - return new NotFoundResponse(); |
|
311 | - } |
|
299 | + /** |
|
300 | + * @PublicPage |
|
301 | + * @NoCSRFRequired |
|
302 | + * |
|
303 | + * @return FileDisplayResponse|NotFoundResponse |
|
304 | + */ |
|
305 | + public function getLoginBackground() { |
|
306 | + try { |
|
307 | + /** @var File $file */ |
|
308 | + $file = $this->appData->getFolder('images')->getFile('background'); |
|
309 | + } catch (NotFoundException $e) { |
|
310 | + return new NotFoundResponse(); |
|
311 | + } |
|
312 | 312 | |
313 | - $response = new FileDisplayResponse($file); |
|
314 | - $response->cacheFor(3600); |
|
315 | - $expires = new \DateTime(); |
|
316 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
317 | - $expires->add(new \DateInterval('PT24H')); |
|
318 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
319 | - $response->addHeader('Pragma', 'cache'); |
|
320 | - $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', '')); |
|
321 | - return $response; |
|
322 | - } |
|
313 | + $response = new FileDisplayResponse($file); |
|
314 | + $response->cacheFor(3600); |
|
315 | + $expires = new \DateTime(); |
|
316 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
317 | + $expires->add(new \DateInterval('PT24H')); |
|
318 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC2822)); |
|
319 | + $response->addHeader('Pragma', 'cache'); |
|
320 | + $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', '')); |
|
321 | + return $response; |
|
322 | + } |
|
323 | 323 | |
324 | - /** |
|
325 | - * @NoCSRFRequired |
|
326 | - * @PublicPage |
|
327 | - * |
|
328 | - * @return FileDisplayResponse|NotFoundResponse |
|
329 | - */ |
|
330 | - public function getStylesheet() { |
|
331 | - $appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1); |
|
332 | - /* SCSSCacher is required here |
|
324 | + /** |
|
325 | + * @NoCSRFRequired |
|
326 | + * @PublicPage |
|
327 | + * |
|
328 | + * @return FileDisplayResponse|NotFoundResponse |
|
329 | + */ |
|
330 | + public function getStylesheet() { |
|
331 | + $appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1); |
|
332 | + /* SCSSCacher is required here |
|
333 | 333 | * We cannot rely on automatic caching done by \OC_Util::addStyle, |
334 | 334 | * since we need to add the cacheBuster value to the url |
335 | 335 | */ |
336 | - $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming'); |
|
337 | - if(!$cssCached) { |
|
338 | - return new NotFoundResponse(); |
|
339 | - } |
|
336 | + $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming'); |
|
337 | + if(!$cssCached) { |
|
338 | + return new NotFoundResponse(); |
|
339 | + } |
|
340 | 340 | |
341 | - try { |
|
342 | - $cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css'); |
|
343 | - $response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']); |
|
344 | - $response->cacheFor(86400); |
|
345 | - $expires = new \DateTime(); |
|
346 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
347 | - $expires->add(new \DateInterval('PT24H')); |
|
348 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC1123)); |
|
349 | - $response->addHeader('Pragma', 'cache'); |
|
350 | - return $response; |
|
351 | - } catch (NotFoundException $e) { |
|
352 | - return new NotFoundResponse(); |
|
353 | - } |
|
354 | - } |
|
341 | + try { |
|
342 | + $cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css'); |
|
343 | + $response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']); |
|
344 | + $response->cacheFor(86400); |
|
345 | + $expires = new \DateTime(); |
|
346 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
347 | + $expires->add(new \DateInterval('PT24H')); |
|
348 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC1123)); |
|
349 | + $response->addHeader('Pragma', 'cache'); |
|
350 | + return $response; |
|
351 | + } catch (NotFoundException $e) { |
|
352 | + return new NotFoundResponse(); |
|
353 | + } |
|
354 | + } |
|
355 | 355 | |
356 | - /** |
|
357 | - * @NoCSRFRequired |
|
358 | - * @PublicPage |
|
359 | - * |
|
360 | - * @return DataDownloadResponse |
|
361 | - */ |
|
362 | - public function getJavascript() { |
|
363 | - $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
364 | - $responseJS = '(function() { |
|
356 | + /** |
|
357 | + * @NoCSRFRequired |
|
358 | + * @PublicPage |
|
359 | + * |
|
360 | + * @return DataDownloadResponse |
|
361 | + */ |
|
362 | + public function getJavascript() { |
|
363 | + $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
364 | + $responseJS = '(function() { |
|
365 | 365 | OCA.Theming = { |
366 | 366 | name: ' . json_encode($this->themingDefaults->getName()) . ', |
367 | 367 | url: ' . json_encode($this->themingDefaults->getBaseUrl()) . ', |
@@ -371,10 +371,10 @@ discard block |
||
371 | 371 | cacheBuster: ' . json_encode($cacheBusterValue) . ' |
372 | 372 | }; |
373 | 373 | })();'; |
374 | - $response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript'); |
|
375 | - $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime())); |
|
376 | - $response->addHeader('Pragma', 'cache'); |
|
377 | - $response->cacheFor(3600); |
|
378 | - return $response; |
|
379 | - } |
|
374 | + $response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript'); |
|
375 | + $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime())); |
|
376 | + $response->addHeader('Pragma', 'cache'); |
|
377 | + $response->cacheFor(3600); |
|
378 | + return $response; |
|
379 | + } |
|
380 | 380 | } |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | * We cannot rely on automatic caching done by \OC_Util::addStyle, |
334 | 334 | * since we need to add the cacheBuster value to the url |
335 | 335 | */ |
336 | - $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming'); |
|
337 | - if(!$cssCached) { |
|
336 | + $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath.'/css/theming.scss', 'theming'); |
|
337 | + if (!$cssCached) { |
|
338 | 338 | return new NotFoundResponse(); |
339 | 339 | } |
340 | 340 | |
@@ -363,12 +363,12 @@ discard block |
||
363 | 363 | $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
364 | 364 | $responseJS = '(function() { |
365 | 365 | OCA.Theming = { |
366 | - name: ' . json_encode($this->themingDefaults->getName()) . ', |
|
367 | - url: ' . json_encode($this->themingDefaults->getBaseUrl()) . ', |
|
368 | - slogan: ' . json_encode($this->themingDefaults->getSlogan()) . ', |
|
369 | - color: ' . json_encode($this->themingDefaults->getMailHeaderColor()) . ', |
|
370 | - inverted: ' . json_encode($this->util->invertTextColor($this->themingDefaults->getMailHeaderColor())) . ', |
|
371 | - cacheBuster: ' . json_encode($cacheBusterValue) . ' |
|
366 | + name: ' . json_encode($this->themingDefaults->getName()).', |
|
367 | + url: ' . json_encode($this->themingDefaults->getBaseUrl()).', |
|
368 | + slogan: ' . json_encode($this->themingDefaults->getSlogan()).', |
|
369 | + color: ' . json_encode($this->themingDefaults->getMailHeaderColor()).', |
|
370 | + inverted: ' . json_encode($this->util->invertTextColor($this->themingDefaults->getMailHeaderColor())).', |
|
371 | + cacheBuster: ' . json_encode($cacheBusterValue).' |
|
372 | 372 | }; |
373 | 373 | })();'; |
374 | 374 | $response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript'); |
@@ -28,7 +28,6 @@ |
||
28 | 28 | use OCP\IConfig; |
29 | 29 | use OCP\IL10N; |
30 | 30 | use OCP\IURLGenerator; |
31 | -use OCP\Files\IRootFolder; |
|
32 | 31 | |
33 | 32 | class ThemingDefaults extends \OC_Defaults { |
34 | 33 |
@@ -32,242 +32,242 @@ |
||
32 | 32 | |
33 | 33 | class ThemingDefaults extends \OC_Defaults { |
34 | 34 | |
35 | - /** @var IConfig */ |
|
36 | - private $config; |
|
37 | - /** @var IL10N */ |
|
38 | - private $l; |
|
39 | - /** @var IURLGenerator */ |
|
40 | - private $urlGenerator; |
|
41 | - /** @var IAppData */ |
|
42 | - private $appData; |
|
43 | - /** @var \OC_Defaults */ |
|
44 | - private $defaults; |
|
45 | - /** @var ICacheFactory */ |
|
46 | - private $cacheFactory; |
|
47 | - /** @var string */ |
|
48 | - private $name; |
|
49 | - /** @var string */ |
|
50 | - private $url; |
|
51 | - /** @var string */ |
|
52 | - private $slogan; |
|
53 | - /** @var string */ |
|
54 | - private $color; |
|
35 | + /** @var IConfig */ |
|
36 | + private $config; |
|
37 | + /** @var IL10N */ |
|
38 | + private $l; |
|
39 | + /** @var IURLGenerator */ |
|
40 | + private $urlGenerator; |
|
41 | + /** @var IAppData */ |
|
42 | + private $appData; |
|
43 | + /** @var \OC_Defaults */ |
|
44 | + private $defaults; |
|
45 | + /** @var ICacheFactory */ |
|
46 | + private $cacheFactory; |
|
47 | + /** @var string */ |
|
48 | + private $name; |
|
49 | + /** @var string */ |
|
50 | + private $url; |
|
51 | + /** @var string */ |
|
52 | + private $slogan; |
|
53 | + /** @var string */ |
|
54 | + private $color; |
|
55 | 55 | |
56 | - /** |
|
57 | - * ThemingDefaults constructor. |
|
58 | - * |
|
59 | - * @param IConfig $config |
|
60 | - * @param IL10N $l |
|
61 | - * @param IURLGenerator $urlGenerator |
|
62 | - * @param \OC_Defaults $defaults |
|
63 | - * @param IAppData $appData |
|
64 | - * @param ICacheFactory $cacheFactory |
|
65 | - * @param Util $util |
|
66 | - */ |
|
67 | - public function __construct(IConfig $config, |
|
68 | - IL10N $l, |
|
69 | - IURLGenerator $urlGenerator, |
|
70 | - \OC_Defaults $defaults, |
|
71 | - IAppData $appData, |
|
72 | - ICacheFactory $cacheFactory, |
|
73 | - Util $util |
|
74 | - ) { |
|
75 | - $this->config = $config; |
|
76 | - $this->l = $l; |
|
77 | - $this->urlGenerator = $urlGenerator; |
|
78 | - $this->defaults = $defaults; |
|
79 | - $this->appData = $appData; |
|
80 | - $this->cacheFactory = $cacheFactory; |
|
81 | - $this->util = $util; |
|
56 | + /** |
|
57 | + * ThemingDefaults constructor. |
|
58 | + * |
|
59 | + * @param IConfig $config |
|
60 | + * @param IL10N $l |
|
61 | + * @param IURLGenerator $urlGenerator |
|
62 | + * @param \OC_Defaults $defaults |
|
63 | + * @param IAppData $appData |
|
64 | + * @param ICacheFactory $cacheFactory |
|
65 | + * @param Util $util |
|
66 | + */ |
|
67 | + public function __construct(IConfig $config, |
|
68 | + IL10N $l, |
|
69 | + IURLGenerator $urlGenerator, |
|
70 | + \OC_Defaults $defaults, |
|
71 | + IAppData $appData, |
|
72 | + ICacheFactory $cacheFactory, |
|
73 | + Util $util |
|
74 | + ) { |
|
75 | + $this->config = $config; |
|
76 | + $this->l = $l; |
|
77 | + $this->urlGenerator = $urlGenerator; |
|
78 | + $this->defaults = $defaults; |
|
79 | + $this->appData = $appData; |
|
80 | + $this->cacheFactory = $cacheFactory; |
|
81 | + $this->util = $util; |
|
82 | 82 | |
83 | - $this->name = $this->defaults->getName(); |
|
84 | - $this->url = $this->defaults->getBaseUrl(); |
|
85 | - $this->slogan = $this->defaults->getSlogan(); |
|
86 | - $this->color = $this->defaults->getMailHeaderColor(); |
|
87 | - } |
|
83 | + $this->name = $this->defaults->getName(); |
|
84 | + $this->url = $this->defaults->getBaseUrl(); |
|
85 | + $this->slogan = $this->defaults->getSlogan(); |
|
86 | + $this->color = $this->defaults->getMailHeaderColor(); |
|
87 | + } |
|
88 | 88 | |
89 | - public function getName() { |
|
90 | - return strip_tags($this->config->getAppValue('theming', 'name', $this->name)); |
|
91 | - } |
|
89 | + public function getName() { |
|
90 | + return strip_tags($this->config->getAppValue('theming', 'name', $this->name)); |
|
91 | + } |
|
92 | 92 | |
93 | - public function getHTMLName() { |
|
94 | - return $this->config->getAppValue('theming', 'name', $this->name); |
|
95 | - } |
|
93 | + public function getHTMLName() { |
|
94 | + return $this->config->getAppValue('theming', 'name', $this->name); |
|
95 | + } |
|
96 | 96 | |
97 | - public function getTitle() { |
|
98 | - return $this->getName(); |
|
99 | - } |
|
97 | + public function getTitle() { |
|
98 | + return $this->getName(); |
|
99 | + } |
|
100 | 100 | |
101 | - public function getEntity() { |
|
102 | - return $this->getName(); |
|
103 | - } |
|
101 | + public function getEntity() { |
|
102 | + return $this->getName(); |
|
103 | + } |
|
104 | 104 | |
105 | - public function getBaseUrl() { |
|
106 | - return $this->config->getAppValue('theming', 'url', $this->url); |
|
107 | - } |
|
105 | + public function getBaseUrl() { |
|
106 | + return $this->config->getAppValue('theming', 'url', $this->url); |
|
107 | + } |
|
108 | 108 | |
109 | - public function getSlogan() { |
|
110 | - return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan)); |
|
111 | - } |
|
109 | + public function getSlogan() { |
|
110 | + return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan)); |
|
111 | + } |
|
112 | 112 | |
113 | - public function getShortFooter() { |
|
114 | - $slogan = $this->getSlogan(); |
|
115 | - $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
116 | - ' rel="noreferrer">' .$this->getEntity() . '</a>'. |
|
117 | - ($slogan !== '' ? ' – ' . $slogan : ''); |
|
113 | + public function getShortFooter() { |
|
114 | + $slogan = $this->getSlogan(); |
|
115 | + $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
116 | + ' rel="noreferrer">' .$this->getEntity() . '</a>'. |
|
117 | + ($slogan !== '' ? ' – ' . $slogan : ''); |
|
118 | 118 | |
119 | - return $footer; |
|
120 | - } |
|
119 | + return $footer; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Color that is used for the header as well as for mail headers |
|
124 | - * |
|
125 | - * @return string |
|
126 | - */ |
|
127 | - public function getMailHeaderColor() { |
|
128 | - return $this->config->getAppValue('theming', 'color', $this->color); |
|
129 | - } |
|
122 | + /** |
|
123 | + * Color that is used for the header as well as for mail headers |
|
124 | + * |
|
125 | + * @return string |
|
126 | + */ |
|
127 | + public function getMailHeaderColor() { |
|
128 | + return $this->config->getAppValue('theming', 'color', $this->color); |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * Themed logo url |
|
133 | - * |
|
134 | - * @return string |
|
135 | - */ |
|
136 | - public function getLogo() { |
|
137 | - try { |
|
138 | - $file = $this->appData->getFolder('images')->getFile('logo'); |
|
139 | - } catch (NotFoundException $e) { |
|
140 | - $file = null; |
|
141 | - } |
|
142 | - $logo = $this->config->getAppValue('theming', 'logoMime', false); |
|
143 | - if(!$logo || $file === null) { |
|
144 | - return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core','logo.svg')); |
|
145 | - } else { |
|
146 | - return $this->urlGenerator->linkToRouteAbsolute('theming.Theming.getLogo'); |
|
147 | - } |
|
148 | - } |
|
131 | + /** |
|
132 | + * Themed logo url |
|
133 | + * |
|
134 | + * @return string |
|
135 | + */ |
|
136 | + public function getLogo() { |
|
137 | + try { |
|
138 | + $file = $this->appData->getFolder('images')->getFile('logo'); |
|
139 | + } catch (NotFoundException $e) { |
|
140 | + $file = null; |
|
141 | + } |
|
142 | + $logo = $this->config->getAppValue('theming', 'logoMime', false); |
|
143 | + if(!$logo || $file === null) { |
|
144 | + return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core','logo.svg')); |
|
145 | + } else { |
|
146 | + return $this->urlGenerator->linkToRouteAbsolute('theming.Theming.getLogo'); |
|
147 | + } |
|
148 | + } |
|
149 | 149 | |
150 | - /** |
|
151 | - * Themed background image url |
|
152 | - * |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - public function getBackground() { |
|
156 | - try { |
|
157 | - $file = $this->appData->getFolder('images')->getFile('background'); |
|
158 | - } catch (NotFoundException $e) { |
|
159 | - $file = null; |
|
160 | - } |
|
161 | - $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false); |
|
162 | - if(!$backgroundLogo || $file === null) { |
|
163 | - return $this->urlGenerator->imagePath('core','background.jpg'); |
|
164 | - } else { |
|
165 | - return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground'); |
|
166 | - } |
|
167 | - } |
|
150 | + /** |
|
151 | + * Themed background image url |
|
152 | + * |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + public function getBackground() { |
|
156 | + try { |
|
157 | + $file = $this->appData->getFolder('images')->getFile('background'); |
|
158 | + } catch (NotFoundException $e) { |
|
159 | + $file = null; |
|
160 | + } |
|
161 | + $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false); |
|
162 | + if(!$backgroundLogo || $file === null) { |
|
163 | + return $this->urlGenerator->imagePath('core','background.jpg'); |
|
164 | + } else { |
|
165 | + return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground'); |
|
166 | + } |
|
167 | + } |
|
168 | 168 | |
169 | 169 | |
170 | - /** |
|
171 | - * @return array scss variables to overwrite |
|
172 | - */ |
|
173 | - public function getScssVariables() { |
|
174 | - $cache = $this->cacheFactory->create('theming'); |
|
175 | - if ($value = $cache->get('getScssVariables')) { |
|
176 | - return $value; |
|
177 | - } |
|
170 | + /** |
|
171 | + * @return array scss variables to overwrite |
|
172 | + */ |
|
173 | + public function getScssVariables() { |
|
174 | + $cache = $this->cacheFactory->create('theming'); |
|
175 | + if ($value = $cache->get('getScssVariables')) { |
|
176 | + return $value; |
|
177 | + } |
|
178 | 178 | |
179 | - $variables = [ |
|
180 | - 'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'", |
|
181 | - ]; |
|
179 | + $variables = [ |
|
180 | + 'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'", |
|
181 | + ]; |
|
182 | 182 | |
183 | - $variables['image-logo'] = "'".$this->getLogo()."'"; |
|
184 | - $variables['image-login-background'] = "'".$this->getBackground()."'"; |
|
183 | + $variables['image-logo'] = "'".$this->getLogo()."'"; |
|
184 | + $variables['image-login-background'] = "'".$this->getBackground()."'"; |
|
185 | 185 | |
186 | - if ($this->config->getAppValue('theming', 'color', null) !== null) { |
|
187 | - if ($this->util->invertTextColor($this->getMailHeaderColor())) { |
|
188 | - $colorPrimaryText = '#000000'; |
|
189 | - } else { |
|
190 | - $colorPrimaryText = '#ffffff'; |
|
191 | - } |
|
192 | - $variables['color-primary'] = $this->getMailHeaderColor(); |
|
193 | - $variables['color-primary-text'] = $colorPrimaryText; |
|
194 | - } |
|
195 | - $cache->set('getScssVariables', $variables); |
|
196 | - return $variables; |
|
197 | - } |
|
186 | + if ($this->config->getAppValue('theming', 'color', null) !== null) { |
|
187 | + if ($this->util->invertTextColor($this->getMailHeaderColor())) { |
|
188 | + $colorPrimaryText = '#000000'; |
|
189 | + } else { |
|
190 | + $colorPrimaryText = '#ffffff'; |
|
191 | + } |
|
192 | + $variables['color-primary'] = $this->getMailHeaderColor(); |
|
193 | + $variables['color-primary-text'] = $colorPrimaryText; |
|
194 | + } |
|
195 | + $cache->set('getScssVariables', $variables); |
|
196 | + return $variables; |
|
197 | + } |
|
198 | 198 | |
199 | - /** |
|
200 | - * Check if Imagemagick is enabled and if SVG is supported |
|
201 | - * otherwise we can't render custom icons |
|
202 | - * |
|
203 | - * @return bool |
|
204 | - */ |
|
205 | - public function shouldReplaceIcons() { |
|
206 | - $cache = $this->cacheFactory->create('theming'); |
|
207 | - if($value = $cache->get('shouldReplaceIcons')) { |
|
208 | - return (bool)$value; |
|
209 | - } |
|
210 | - $value = false; |
|
211 | - if(extension_loaded('imagick')) { |
|
212 | - $checkImagick = new \Imagick(); |
|
213 | - if (count($checkImagick->queryFormats('SVG')) >= 1) { |
|
214 | - $value = true; |
|
215 | - } |
|
216 | - $checkImagick->clear(); |
|
217 | - } |
|
218 | - $cache->set('shouldReplaceIcons', $value); |
|
219 | - return $value; |
|
220 | - } |
|
199 | + /** |
|
200 | + * Check if Imagemagick is enabled and if SVG is supported |
|
201 | + * otherwise we can't render custom icons |
|
202 | + * |
|
203 | + * @return bool |
|
204 | + */ |
|
205 | + public function shouldReplaceIcons() { |
|
206 | + $cache = $this->cacheFactory->create('theming'); |
|
207 | + if($value = $cache->get('shouldReplaceIcons')) { |
|
208 | + return (bool)$value; |
|
209 | + } |
|
210 | + $value = false; |
|
211 | + if(extension_loaded('imagick')) { |
|
212 | + $checkImagick = new \Imagick(); |
|
213 | + if (count($checkImagick->queryFormats('SVG')) >= 1) { |
|
214 | + $value = true; |
|
215 | + } |
|
216 | + $checkImagick->clear(); |
|
217 | + } |
|
218 | + $cache->set('shouldReplaceIcons', $value); |
|
219 | + return $value; |
|
220 | + } |
|
221 | 221 | |
222 | - /** |
|
223 | - * Increases the cache buster key |
|
224 | - */ |
|
225 | - private function increaseCacheBuster() { |
|
226 | - $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
227 | - $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); |
|
228 | - $this->cacheFactory->create('theming')->clear('getScssVariables'); |
|
229 | - } |
|
222 | + /** |
|
223 | + * Increases the cache buster key |
|
224 | + */ |
|
225 | + private function increaseCacheBuster() { |
|
226 | + $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
227 | + $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); |
|
228 | + $this->cacheFactory->create('theming')->clear('getScssVariables'); |
|
229 | + } |
|
230 | 230 | |
231 | - /** |
|
232 | - * Update setting in the database |
|
233 | - * |
|
234 | - * @param string $setting |
|
235 | - * @param string $value |
|
236 | - */ |
|
237 | - public function set($setting, $value) { |
|
238 | - $this->config->setAppValue('theming', $setting, $value); |
|
239 | - $this->increaseCacheBuster(); |
|
240 | - } |
|
231 | + /** |
|
232 | + * Update setting in the database |
|
233 | + * |
|
234 | + * @param string $setting |
|
235 | + * @param string $value |
|
236 | + */ |
|
237 | + public function set($setting, $value) { |
|
238 | + $this->config->setAppValue('theming', $setting, $value); |
|
239 | + $this->increaseCacheBuster(); |
|
240 | + } |
|
241 | 241 | |
242 | - /** |
|
243 | - * Revert settings to the default value |
|
244 | - * |
|
245 | - * @param string $setting setting which should be reverted |
|
246 | - * @return string default value |
|
247 | - */ |
|
248 | - public function undo($setting) { |
|
249 | - $this->config->deleteAppValue('theming', $setting); |
|
250 | - $this->increaseCacheBuster(); |
|
242 | + /** |
|
243 | + * Revert settings to the default value |
|
244 | + * |
|
245 | + * @param string $setting setting which should be reverted |
|
246 | + * @return string default value |
|
247 | + */ |
|
248 | + public function undo($setting) { |
|
249 | + $this->config->deleteAppValue('theming', $setting); |
|
250 | + $this->increaseCacheBuster(); |
|
251 | 251 | |
252 | - switch ($setting) { |
|
253 | - case 'name': |
|
254 | - $returnValue = $this->getEntity(); |
|
255 | - break; |
|
256 | - case 'url': |
|
257 | - $returnValue = $this->getBaseUrl(); |
|
258 | - break; |
|
259 | - case 'slogan': |
|
260 | - $returnValue = $this->getSlogan(); |
|
261 | - break; |
|
262 | - case 'color': |
|
263 | - $returnValue = $this->getMailHeaderColor(); |
|
264 | - break; |
|
265 | - default: |
|
266 | - $returnValue = ''; |
|
267 | - break; |
|
268 | - } |
|
252 | + switch ($setting) { |
|
253 | + case 'name': |
|
254 | + $returnValue = $this->getEntity(); |
|
255 | + break; |
|
256 | + case 'url': |
|
257 | + $returnValue = $this->getBaseUrl(); |
|
258 | + break; |
|
259 | + case 'slogan': |
|
260 | + $returnValue = $this->getSlogan(); |
|
261 | + break; |
|
262 | + case 'color': |
|
263 | + $returnValue = $this->getMailHeaderColor(); |
|
264 | + break; |
|
265 | + default: |
|
266 | + $returnValue = ''; |
|
267 | + break; |
|
268 | + } |
|
269 | 269 | |
270 | - return $returnValue; |
|
271 | - } |
|
270 | + return $returnValue; |
|
271 | + } |
|
272 | 272 | |
273 | 273 | } |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | |
113 | 113 | public function getShortFooter() { |
114 | 114 | $slogan = $this->getSlogan(); |
115 | - $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
116 | - ' rel="noreferrer">' .$this->getEntity() . '</a>'. |
|
117 | - ($slogan !== '' ? ' – ' . $slogan : ''); |
|
115 | + $footer = '<a href="'.$this->getBaseUrl().'" target="_blank"'. |
|
116 | + ' rel="noreferrer">'.$this->getEntity().'</a>'. |
|
117 | + ($slogan !== '' ? ' – '.$slogan : ''); |
|
118 | 118 | |
119 | 119 | return $footer; |
120 | 120 | } |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | $file = null; |
141 | 141 | } |
142 | 142 | $logo = $this->config->getAppValue('theming', 'logoMime', false); |
143 | - if(!$logo || $file === null) { |
|
144 | - return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core','logo.svg')); |
|
143 | + if (!$logo || $file === null) { |
|
144 | + return $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'logo.svg')); |
|
145 | 145 | } else { |
146 | 146 | return $this->urlGenerator->linkToRouteAbsolute('theming.Theming.getLogo'); |
147 | 147 | } |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | $file = null; |
160 | 160 | } |
161 | 161 | $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false); |
162 | - if(!$backgroundLogo || $file === null) { |
|
163 | - return $this->urlGenerator->imagePath('core','background.jpg'); |
|
162 | + if (!$backgroundLogo || $file === null) { |
|
163 | + return $this->urlGenerator->imagePath('core', 'background.jpg'); |
|
164 | 164 | } else { |
165 | 165 | return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground'); |
166 | 166 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | } |
178 | 178 | |
179 | 179 | $variables = [ |
180 | - 'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'", |
|
180 | + 'theming-cachebuster' => "'".$this->config->getAppValue('theming', 'cachebuster', '0')."'", |
|
181 | 181 | ]; |
182 | 182 | |
183 | 183 | $variables['image-logo'] = "'".$this->getLogo()."'"; |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function shouldReplaceIcons() { |
206 | 206 | $cache = $this->cacheFactory->create('theming'); |
207 | - if($value = $cache->get('shouldReplaceIcons')) { |
|
208 | - return (bool)$value; |
|
207 | + if ($value = $cache->get('shouldReplaceIcons')) { |
|
208 | + return (bool) $value; |
|
209 | 209 | } |
210 | 210 | $value = false; |
211 | - if(extension_loaded('imagick')) { |
|
211 | + if (extension_loaded('imagick')) { |
|
212 | 212 | $checkImagick = new \Imagick(); |
213 | 213 | if (count($checkImagick->queryFormats('SVG')) >= 1) { |
214 | 214 | $value = true; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | private function increaseCacheBuster() { |
226 | 226 | $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); |
227 | - $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); |
|
227 | + $this->config->setAppValue('theming', 'cachebuster', (int) $cacheBusterKey + 1); |
|
228 | 228 | $this->cacheFactory->create('theming')->clear('getScssVariables'); |
229 | 229 | } |
230 | 230 |
@@ -41,232 +41,232 @@ |
||
41 | 41 | |
42 | 42 | class TemplateLayout extends \OC_Template { |
43 | 43 | |
44 | - private static $versionHash = ''; |
|
44 | + private static $versionHash = ''; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @var \OCP\IConfig |
|
48 | - */ |
|
49 | - private $config; |
|
46 | + /** |
|
47 | + * @var \OCP\IConfig |
|
48 | + */ |
|
49 | + private $config; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param string $renderAs |
|
53 | - * @param string $appId application id |
|
54 | - */ |
|
55 | - public function __construct( $renderAs, $appId = '' ) { |
|
51 | + /** |
|
52 | + * @param string $renderAs |
|
53 | + * @param string $appId application id |
|
54 | + */ |
|
55 | + public function __construct( $renderAs, $appId = '' ) { |
|
56 | 56 | |
57 | - // yes - should be injected .... |
|
58 | - $this->config = \OC::$server->getConfig(); |
|
57 | + // yes - should be injected .... |
|
58 | + $this->config = \OC::$server->getConfig(); |
|
59 | 59 | |
60 | 60 | |
61 | - // Decide which page we show |
|
62 | - if($renderAs == 'user') { |
|
63 | - parent::__construct( 'core', 'layout.user' ); |
|
64 | - if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
65 | - $this->assign('bodyid', 'body-settings'); |
|
66 | - }else{ |
|
67 | - $this->assign('bodyid', 'body-user'); |
|
68 | - } |
|
61 | + // Decide which page we show |
|
62 | + if($renderAs == 'user') { |
|
63 | + parent::__construct( 'core', 'layout.user' ); |
|
64 | + if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
65 | + $this->assign('bodyid', 'body-settings'); |
|
66 | + }else{ |
|
67 | + $this->assign('bodyid', 'body-user'); |
|
68 | + } |
|
69 | 69 | |
70 | - // Code integrity notification |
|
71 | - $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
|
72 | - if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
73 | - \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
|
74 | - } |
|
70 | + // Code integrity notification |
|
71 | + $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
|
72 | + if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
73 | + \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
|
74 | + } |
|
75 | 75 | |
76 | - // Add navigation entry |
|
77 | - $this->assign( 'application', ''); |
|
78 | - $this->assign( 'appid', $appId ); |
|
79 | - $navigation = \OC_App::getNavigation(); |
|
80 | - $this->assign( 'navigation', $navigation); |
|
81 | - $navigation = \OC_App::getHeaderNavigation(); |
|
82 | - $this->assign( 'headernavigation', $navigation); |
|
83 | - $settingsNavigation = \OC_App::getSettingsNavigation(); |
|
84 | - $this->assign( 'settingsnavigation', $settingsNavigation); |
|
85 | - foreach($navigation as $entry) { |
|
86 | - if ($entry['active']) { |
|
87 | - $this->assign( 'application', $entry['name'] ); |
|
88 | - break; |
|
89 | - } |
|
90 | - } |
|
76 | + // Add navigation entry |
|
77 | + $this->assign( 'application', ''); |
|
78 | + $this->assign( 'appid', $appId ); |
|
79 | + $navigation = \OC_App::getNavigation(); |
|
80 | + $this->assign( 'navigation', $navigation); |
|
81 | + $navigation = \OC_App::getHeaderNavigation(); |
|
82 | + $this->assign( 'headernavigation', $navigation); |
|
83 | + $settingsNavigation = \OC_App::getSettingsNavigation(); |
|
84 | + $this->assign( 'settingsnavigation', $settingsNavigation); |
|
85 | + foreach($navigation as $entry) { |
|
86 | + if ($entry['active']) { |
|
87 | + $this->assign( 'application', $entry['name'] ); |
|
88 | + break; |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - foreach($settingsNavigation as $entry) { |
|
93 | - if ($entry['active']) { |
|
94 | - $this->assign( 'application', $entry['name'] ); |
|
95 | - break; |
|
96 | - } |
|
97 | - } |
|
98 | - $userDisplayName = \OC_User::getDisplayName(); |
|
99 | - $appsMgmtActive = strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0; |
|
100 | - if ($appsMgmtActive) { |
|
101 | - $l = \OC::$server->getL10N('lib'); |
|
102 | - $this->assign('application', $l->t('Apps')); |
|
103 | - } |
|
104 | - $this->assign('user_displayname', $userDisplayName); |
|
105 | - $this->assign('user_uid', \OC_User::getUser()); |
|
106 | - $this->assign('appsmanagement_active', $appsMgmtActive); |
|
92 | + foreach($settingsNavigation as $entry) { |
|
93 | + if ($entry['active']) { |
|
94 | + $this->assign( 'application', $entry['name'] ); |
|
95 | + break; |
|
96 | + } |
|
97 | + } |
|
98 | + $userDisplayName = \OC_User::getDisplayName(); |
|
99 | + $appsMgmtActive = strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0; |
|
100 | + if ($appsMgmtActive) { |
|
101 | + $l = \OC::$server->getL10N('lib'); |
|
102 | + $this->assign('application', $l->t('Apps')); |
|
103 | + } |
|
104 | + $this->assign('user_displayname', $userDisplayName); |
|
105 | + $this->assign('user_uid', \OC_User::getUser()); |
|
106 | + $this->assign('appsmanagement_active', $appsMgmtActive); |
|
107 | 107 | |
108 | - if (\OC_User::getUser() === false) { |
|
109 | - $this->assign('userAvatarSet', false); |
|
110 | - } else { |
|
111 | - $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
112 | - $this->assign('userAvatarVersion', \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
113 | - } |
|
108 | + if (\OC_User::getUser() === false) { |
|
109 | + $this->assign('userAvatarSet', false); |
|
110 | + } else { |
|
111 | + $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
112 | + $this->assign('userAvatarVersion', \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
113 | + } |
|
114 | 114 | |
115 | - } else if ($renderAs == 'error') { |
|
116 | - parent::__construct('core', 'layout.guest', '', false); |
|
117 | - $this->assign('bodyid', 'body-login'); |
|
118 | - } else if ($renderAs == 'guest') { |
|
119 | - parent::__construct('core', 'layout.guest'); |
|
120 | - $this->assign('bodyid', 'body-login'); |
|
121 | - } else { |
|
122 | - parent::__construct('core', 'layout.base'); |
|
115 | + } else if ($renderAs == 'error') { |
|
116 | + parent::__construct('core', 'layout.guest', '', false); |
|
117 | + $this->assign('bodyid', 'body-login'); |
|
118 | + } else if ($renderAs == 'guest') { |
|
119 | + parent::__construct('core', 'layout.guest'); |
|
120 | + $this->assign('bodyid', 'body-login'); |
|
121 | + } else { |
|
122 | + parent::__construct('core', 'layout.base'); |
|
123 | 123 | |
124 | - } |
|
125 | - // Send the language to our layouts |
|
126 | - $this->assign('language', \OC::$server->getL10NFactory()->findLanguage()); |
|
124 | + } |
|
125 | + // Send the language to our layouts |
|
126 | + $this->assign('language', \OC::$server->getL10NFactory()->findLanguage()); |
|
127 | 127 | |
128 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
129 | - if (empty(self::$versionHash)) { |
|
130 | - $v = \OC_App::getAppVersions(); |
|
131 | - $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
132 | - self::$versionHash = md5(implode(',', $v)); |
|
133 | - } |
|
134 | - } else { |
|
135 | - self::$versionHash = md5('not installed'); |
|
136 | - } |
|
128 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
129 | + if (empty(self::$versionHash)) { |
|
130 | + $v = \OC_App::getAppVersions(); |
|
131 | + $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
132 | + self::$versionHash = md5(implode(',', $v)); |
|
133 | + } |
|
134 | + } else { |
|
135 | + self::$versionHash = md5('not installed'); |
|
136 | + } |
|
137 | 137 | |
138 | - // Add the js files |
|
139 | - $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
140 | - $this->assign('jsfiles', array()); |
|
141 | - if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
142 | - if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
143 | - $jsConfigHelper = new JSConfigHelper( |
|
144 | - \OC::$server->getL10N('core'), |
|
145 | - \OC::$server->getThemingDefaults(), |
|
146 | - \OC::$server->getAppManager(), |
|
147 | - \OC::$server->getSession(), |
|
148 | - \OC::$server->getUserSession()->getUser(), |
|
149 | - \OC::$server->getConfig(), |
|
150 | - \OC::$server->getGroupManager(), |
|
151 | - \OC::$server->getIniWrapper(), |
|
152 | - \OC::$server->getURLGenerator() |
|
153 | - ); |
|
154 | - $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
155 | - } else { |
|
156 | - $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
157 | - } |
|
158 | - } |
|
159 | - foreach($jsFiles as $info) { |
|
160 | - $web = $info[1]; |
|
161 | - $file = $info[2]; |
|
162 | - $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
163 | - } |
|
138 | + // Add the js files |
|
139 | + $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
140 | + $this->assign('jsfiles', array()); |
|
141 | + if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
142 | + if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
143 | + $jsConfigHelper = new JSConfigHelper( |
|
144 | + \OC::$server->getL10N('core'), |
|
145 | + \OC::$server->getThemingDefaults(), |
|
146 | + \OC::$server->getAppManager(), |
|
147 | + \OC::$server->getSession(), |
|
148 | + \OC::$server->getUserSession()->getUser(), |
|
149 | + \OC::$server->getConfig(), |
|
150 | + \OC::$server->getGroupManager(), |
|
151 | + \OC::$server->getIniWrapper(), |
|
152 | + \OC::$server->getURLGenerator() |
|
153 | + ); |
|
154 | + $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
155 | + } else { |
|
156 | + $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
157 | + } |
|
158 | + } |
|
159 | + foreach($jsFiles as $info) { |
|
160 | + $web = $info[1]; |
|
161 | + $file = $info[2]; |
|
162 | + $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
163 | + } |
|
164 | 164 | |
165 | - try { |
|
166 | - $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
167 | - } catch (\Exception $e) { |
|
168 | - $pathInfo = ''; |
|
169 | - } |
|
165 | + try { |
|
166 | + $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
167 | + } catch (\Exception $e) { |
|
168 | + $pathInfo = ''; |
|
169 | + } |
|
170 | 170 | |
171 | - // Do not initialise scss appdata until we have a fully installed instance |
|
172 | - // Do not load scss for update, errors, installation or login page |
|
173 | - if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
174 | - && !\OCP\Util::needUpgrade() |
|
175 | - && $pathInfo !== '' |
|
176 | - && !preg_match('/^\/login/', $pathInfo)) { |
|
177 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
178 | - } else { |
|
179 | - // If we ignore the scss compiler, |
|
180 | - // we need to load the guest css fallback |
|
181 | - \OC_Util::addStyle('guest'); |
|
182 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
183 | - } |
|
171 | + // Do not initialise scss appdata until we have a fully installed instance |
|
172 | + // Do not load scss for update, errors, installation or login page |
|
173 | + if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
174 | + && !\OCP\Util::needUpgrade() |
|
175 | + && $pathInfo !== '' |
|
176 | + && !preg_match('/^\/login/', $pathInfo)) { |
|
177 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
178 | + } else { |
|
179 | + // If we ignore the scss compiler, |
|
180 | + // we need to load the guest css fallback |
|
181 | + \OC_Util::addStyle('guest'); |
|
182 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
183 | + } |
|
184 | 184 | |
185 | - $this->assign('cssfiles', array()); |
|
186 | - $this->assign('printcssfiles', []); |
|
187 | - $this->assign('versionHash', self::$versionHash); |
|
188 | - foreach($cssFiles as $info) { |
|
189 | - $web = $info[1]; |
|
190 | - $file = $info[2]; |
|
185 | + $this->assign('cssfiles', array()); |
|
186 | + $this->assign('printcssfiles', []); |
|
187 | + $this->assign('versionHash', self::$versionHash); |
|
188 | + foreach($cssFiles as $info) { |
|
189 | + $web = $info[1]; |
|
190 | + $file = $info[2]; |
|
191 | 191 | |
192 | - if (substr($file, -strlen('print.css')) === 'print.css') { |
|
193 | - $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
194 | - } else { |
|
195 | - $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
196 | - } |
|
197 | - } |
|
198 | - } |
|
192 | + if (substr($file, -strlen('print.css')) === 'print.css') { |
|
193 | + $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
194 | + } else { |
|
195 | + $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
196 | + } |
|
197 | + } |
|
198 | + } |
|
199 | 199 | |
200 | - protected function getVersionHashSuffix() { |
|
201 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
202 | - // allows chrome workspace mapping in debug mode |
|
203 | - return ""; |
|
204 | - } |
|
200 | + protected function getVersionHashSuffix() { |
|
201 | + if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
202 | + // allows chrome workspace mapping in debug mode |
|
203 | + return ""; |
|
204 | + } |
|
205 | 205 | |
206 | - return '?v=' . self::$versionHash; |
|
207 | - } |
|
206 | + return '?v=' . self::$versionHash; |
|
207 | + } |
|
208 | 208 | |
209 | - /** |
|
210 | - * @param array $styles |
|
211 | - * @return array |
|
212 | - */ |
|
213 | - static public function findStylesheetFiles($styles, $compileScss = true) { |
|
214 | - // Read the selected theme from the config file |
|
215 | - $theme = \OC_Util::getTheme(); |
|
209 | + /** |
|
210 | + * @param array $styles |
|
211 | + * @return array |
|
212 | + */ |
|
213 | + static public function findStylesheetFiles($styles, $compileScss = true) { |
|
214 | + // Read the selected theme from the config file |
|
215 | + $theme = \OC_Util::getTheme(); |
|
216 | 216 | |
217 | - if($compileScss) { |
|
218 | - $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
|
219 | - } else { |
|
220 | - $SCSSCacher = null; |
|
221 | - } |
|
217 | + if($compileScss) { |
|
218 | + $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
|
219 | + } else { |
|
220 | + $SCSSCacher = null; |
|
221 | + } |
|
222 | 222 | |
223 | - $locator = new \OC\Template\CSSResourceLocator( |
|
224 | - \OC::$server->getLogger(), |
|
225 | - $theme, |
|
226 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
227 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
228 | - $SCSSCacher |
|
229 | - ); |
|
230 | - $locator->find($styles); |
|
231 | - return $locator->getResources(); |
|
232 | - } |
|
223 | + $locator = new \OC\Template\CSSResourceLocator( |
|
224 | + \OC::$server->getLogger(), |
|
225 | + $theme, |
|
226 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
227 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
228 | + $SCSSCacher |
|
229 | + ); |
|
230 | + $locator->find($styles); |
|
231 | + return $locator->getResources(); |
|
232 | + } |
|
233 | 233 | |
234 | - /** |
|
235 | - * @param array $scripts |
|
236 | - * @return array |
|
237 | - */ |
|
238 | - static public function findJavascriptFiles($scripts) { |
|
239 | - // Read the selected theme from the config file |
|
240 | - $theme = \OC_Util::getTheme(); |
|
234 | + /** |
|
235 | + * @param array $scripts |
|
236 | + * @return array |
|
237 | + */ |
|
238 | + static public function findJavascriptFiles($scripts) { |
|
239 | + // Read the selected theme from the config file |
|
240 | + $theme = \OC_Util::getTheme(); |
|
241 | 241 | |
242 | - $locator = new \OC\Template\JSResourceLocator( |
|
243 | - \OC::$server->getLogger(), |
|
244 | - $theme, |
|
245 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
246 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
247 | - new JSCombiner( |
|
248 | - \OC::$server->getAppDataDir('js'), |
|
249 | - \OC::$server->getURLGenerator(), |
|
250 | - \OC::$server->getMemCacheFactory()->create('JS'), |
|
251 | - \OC::$server->getSystemConfig() |
|
252 | - ) |
|
253 | - ); |
|
254 | - $locator->find($scripts); |
|
255 | - return $locator->getResources(); |
|
256 | - } |
|
242 | + $locator = new \OC\Template\JSResourceLocator( |
|
243 | + \OC::$server->getLogger(), |
|
244 | + $theme, |
|
245 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
246 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
247 | + new JSCombiner( |
|
248 | + \OC::$server->getAppDataDir('js'), |
|
249 | + \OC::$server->getURLGenerator(), |
|
250 | + \OC::$server->getMemCacheFactory()->create('JS'), |
|
251 | + \OC::$server->getSystemConfig() |
|
252 | + ) |
|
253 | + ); |
|
254 | + $locator->find($scripts); |
|
255 | + return $locator->getResources(); |
|
256 | + } |
|
257 | 257 | |
258 | - /** |
|
259 | - * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
260 | - * @param string $filePath Absolute path |
|
261 | - * @return string Relative path |
|
262 | - * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
263 | - */ |
|
264 | - public static function convertToRelativePath($filePath) { |
|
265 | - $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
266 | - if(count($relativePath) !== 2) { |
|
267 | - throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
268 | - } |
|
258 | + /** |
|
259 | + * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
260 | + * @param string $filePath Absolute path |
|
261 | + * @return string Relative path |
|
262 | + * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
263 | + */ |
|
264 | + public static function convertToRelativePath($filePath) { |
|
265 | + $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
266 | + if(count($relativePath) !== 2) { |
|
267 | + throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
268 | + } |
|
269 | 269 | |
270 | - return $relativePath[1]; |
|
271 | - } |
|
270 | + return $relativePath[1]; |
|
271 | + } |
|
272 | 272 | } |
@@ -52,46 +52,46 @@ discard block |
||
52 | 52 | * @param string $renderAs |
53 | 53 | * @param string $appId application id |
54 | 54 | */ |
55 | - public function __construct( $renderAs, $appId = '' ) { |
|
55 | + public function __construct($renderAs, $appId = '') { |
|
56 | 56 | |
57 | 57 | // yes - should be injected .... |
58 | 58 | $this->config = \OC::$server->getConfig(); |
59 | 59 | |
60 | 60 | |
61 | 61 | // Decide which page we show |
62 | - if($renderAs == 'user') { |
|
63 | - parent::__construct( 'core', 'layout.user' ); |
|
64 | - if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
62 | + if ($renderAs == 'user') { |
|
63 | + parent::__construct('core', 'layout.user'); |
|
64 | + if (in_array(\OC_App::getCurrentApp(), ['settings', 'admin', 'help']) !== false) { |
|
65 | 65 | $this->assign('bodyid', 'body-settings'); |
66 | - }else{ |
|
66 | + } else { |
|
67 | 67 | $this->assign('bodyid', 'body-user'); |
68 | 68 | } |
69 | 69 | |
70 | 70 | // Code integrity notification |
71 | 71 | $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
72 | - if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
72 | + if (\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
73 | 73 | \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
74 | 74 | } |
75 | 75 | |
76 | 76 | // Add navigation entry |
77 | - $this->assign( 'application', ''); |
|
78 | - $this->assign( 'appid', $appId ); |
|
77 | + $this->assign('application', ''); |
|
78 | + $this->assign('appid', $appId); |
|
79 | 79 | $navigation = \OC_App::getNavigation(); |
80 | - $this->assign( 'navigation', $navigation); |
|
80 | + $this->assign('navigation', $navigation); |
|
81 | 81 | $navigation = \OC_App::getHeaderNavigation(); |
82 | - $this->assign( 'headernavigation', $navigation); |
|
82 | + $this->assign('headernavigation', $navigation); |
|
83 | 83 | $settingsNavigation = \OC_App::getSettingsNavigation(); |
84 | - $this->assign( 'settingsnavigation', $settingsNavigation); |
|
85 | - foreach($navigation as $entry) { |
|
84 | + $this->assign('settingsnavigation', $settingsNavigation); |
|
85 | + foreach ($navigation as $entry) { |
|
86 | 86 | if ($entry['active']) { |
87 | - $this->assign( 'application', $entry['name'] ); |
|
87 | + $this->assign('application', $entry['name']); |
|
88 | 88 | break; |
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | - foreach($settingsNavigation as $entry) { |
|
92 | + foreach ($settingsNavigation as $entry) { |
|
93 | 93 | if ($entry['active']) { |
94 | - $this->assign( 'application', $entry['name'] ); |
|
94 | + $this->assign('application', $entry['name']); |
|
95 | 95 | break; |
96 | 96 | } |
97 | 97 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | // Send the language to our layouts |
126 | 126 | $this->assign('language', \OC::$server->getL10NFactory()->findLanguage()); |
127 | 127 | |
128 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
128 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
129 | 129 | if (empty(self::$versionHash)) { |
130 | 130 | $v = \OC_App::getAppVersions(); |
131 | 131 | $v['core'] = implode('.', \OCP\Util::getVersion()); |
@@ -156,10 +156,10 @@ discard block |
||
156 | 156 | $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
157 | 157 | } |
158 | 158 | } |
159 | - foreach($jsFiles as $info) { |
|
159 | + foreach ($jsFiles as $info) { |
|
160 | 160 | $web = $info[1]; |
161 | 161 | $file = $info[2]; |
162 | - $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
162 | + $this->append('jsfiles', $web.'/'.$file.$this->getVersionHashSuffix()); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | try { |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | |
171 | 171 | // Do not initialise scss appdata until we have a fully installed instance |
172 | 172 | // Do not load scss for update, errors, installation or login page |
173 | - if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
173 | + if (\OC::$server->getSystemConfig()->getValue('installed', false) |
|
174 | 174 | && !\OCP\Util::needUpgrade() |
175 | 175 | && $pathInfo !== '' |
176 | 176 | && !preg_match('/^\/login/', $pathInfo)) { |
@@ -185,25 +185,25 @@ discard block |
||
185 | 185 | $this->assign('cssfiles', array()); |
186 | 186 | $this->assign('printcssfiles', []); |
187 | 187 | $this->assign('versionHash', self::$versionHash); |
188 | - foreach($cssFiles as $info) { |
|
188 | + foreach ($cssFiles as $info) { |
|
189 | 189 | $web = $info[1]; |
190 | 190 | $file = $info[2]; |
191 | 191 | |
192 | 192 | if (substr($file, -strlen('print.css')) === 'print.css') { |
193 | - $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
193 | + $this->append('printcssfiles', $web.'/'.$file.$this->getVersionHashSuffix()); |
|
194 | 194 | } else { |
195 | - $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
195 | + $this->append('cssfiles', $web.'/'.$file.$this->getVersionHashSuffix()); |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | 200 | protected function getVersionHashSuffix() { |
201 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
201 | + if (\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
202 | 202 | // allows chrome workspace mapping in debug mode |
203 | 203 | return ""; |
204 | 204 | } |
205 | 205 | |
206 | - return '?v=' . self::$versionHash; |
|
206 | + return '?v='.self::$versionHash; |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | // Read the selected theme from the config file |
215 | 215 | $theme = \OC_Util::getTheme(); |
216 | 216 | |
217 | - if($compileScss) { |
|
217 | + if ($compileScss) { |
|
218 | 218 | $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
219 | 219 | } else { |
220 | 220 | $SCSSCacher = null; |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | $locator = new \OC\Template\CSSResourceLocator( |
224 | 224 | \OC::$server->getLogger(), |
225 | 225 | $theme, |
226 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
227 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
226 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
227 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
228 | 228 | $SCSSCacher |
229 | 229 | ); |
230 | 230 | $locator->find($styles); |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | $locator = new \OC\Template\JSResourceLocator( |
243 | 243 | \OC::$server->getLogger(), |
244 | 244 | $theme, |
245 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
246 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
245 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
246 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
247 | 247 | new JSCombiner( |
248 | 248 | \OC::$server->getAppDataDir('js'), |
249 | 249 | \OC::$server->getURLGenerator(), |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | */ |
264 | 264 | public static function convertToRelativePath($filePath) { |
265 | 265 | $relativePath = explode(\OC::$SERVERROOT, $filePath); |
266 | - if(count($relativePath) !== 2) { |
|
266 | + if (count($relativePath) !== 2) { |
|
267 | 267 | throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
268 | 268 | } |
269 | 269 |