@@ -28,27 +28,27 @@ |
||
28 | 28 | |
29 | 29 | class LinkMenuAction extends SimpleMenuAction { |
30 | 30 | |
31 | - /** |
|
32 | - * LinkMenuAction constructor. |
|
33 | - * |
|
34 | - * @param string $label |
|
35 | - * @param string $icon |
|
36 | - * @param string $link |
|
37 | - */ |
|
38 | - public function __construct(string $label, string $icon, string $link) { |
|
39 | - parent::__construct('directLink-container', $label, $icon, $link); |
|
40 | - } |
|
31 | + /** |
|
32 | + * LinkMenuAction constructor. |
|
33 | + * |
|
34 | + * @param string $label |
|
35 | + * @param string $icon |
|
36 | + * @param string $link |
|
37 | + */ |
|
38 | + public function __construct(string $label, string $icon, string $link) { |
|
39 | + parent::__construct('directLink-container', $label, $icon, $link); |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return string |
|
44 | - */ |
|
45 | - public function render(): string { |
|
46 | - return '<li>' . |
|
47 | - '<a id="directLink-container">' . |
|
48 | - '<span class="icon ' . Util::sanitizeHTML($this->getIcon()) . '"></span>' . |
|
49 | - '<label for="directLink">' . Util::sanitizeHTML($this->getLabel()) . '</label>' . |
|
50 | - '<input id="directLink" type="text" readonly="" value="' . Util::sanitizeHTML($this->getLink()) . '">' . |
|
51 | - '</a>' . |
|
52 | - '</li>'; |
|
53 | - } |
|
42 | + /** |
|
43 | + * @return string |
|
44 | + */ |
|
45 | + public function render(): string { |
|
46 | + return '<li>' . |
|
47 | + '<a id="directLink-container">' . |
|
48 | + '<span class="icon ' . Util::sanitizeHTML($this->getIcon()) . '"></span>' . |
|
49 | + '<label for="directLink">' . Util::sanitizeHTML($this->getLabel()) . '</label>' . |
|
50 | + '<input id="directLink" type="text" readonly="" value="' . Util::sanitizeHTML($this->getLink()) . '">' . |
|
51 | + '</a>' . |
|
52 | + '</li>'; |
|
53 | + } |
|
54 | 54 | } |
55 | 55 | \ No newline at end of file |
@@ -43,12 +43,12 @@ |
||
43 | 43 | * @return string |
44 | 44 | */ |
45 | 45 | public function render(): string { |
46 | - return '<li>' . |
|
47 | - '<a id="directLink-container">' . |
|
48 | - '<span class="icon ' . Util::sanitizeHTML($this->getIcon()) . '"></span>' . |
|
49 | - '<label for="directLink">' . Util::sanitizeHTML($this->getLabel()) . '</label>' . |
|
50 | - '<input id="directLink" type="text" readonly="" value="' . Util::sanitizeHTML($this->getLink()) . '">' . |
|
51 | - '</a>' . |
|
46 | + return '<li>'. |
|
47 | + '<a id="directLink-container">'. |
|
48 | + '<span class="icon '.Util::sanitizeHTML($this->getIcon()).'"></span>'. |
|
49 | + '<label for="directLink">'.Util::sanitizeHTML($this->getLabel()).'</label>'. |
|
50 | + '<input id="directLink" type="text" readonly="" value="'.Util::sanitizeHTML($this->getLink()).'">'. |
|
51 | + '</a>'. |
|
52 | 52 | '</li>'; |
53 | 53 | } |
54 | 54 | } |
55 | 55 | \ No newline at end of file |
@@ -46,349 +46,349 @@ |
||
46 | 46 | */ |
47 | 47 | class OC_Template extends \OC\Template\Base { |
48 | 48 | |
49 | - /** @var string */ |
|
50 | - private $renderAs; // Create a full page? |
|
51 | - |
|
52 | - /** @var string */ |
|
53 | - private $path; // The path to the template |
|
54 | - |
|
55 | - /** @var array */ |
|
56 | - private $headers = array(); //custom headers |
|
57 | - |
|
58 | - /** @var string */ |
|
59 | - protected $app; // app id |
|
60 | - |
|
61 | - protected static $initTemplateEngineFirstRun = true; |
|
62 | - |
|
63 | - /** |
|
64 | - * Constructor |
|
65 | - * |
|
66 | - * @param string $app app providing the template |
|
67 | - * @param string $name of the template file (without suffix) |
|
68 | - * @param string $renderAs If $renderAs is set, OC_Template will try to |
|
69 | - * produce a full page in the according layout. For |
|
70 | - * now, $renderAs can be set to "guest", "user" or |
|
71 | - * "admin". |
|
72 | - * @param bool $registerCall = true |
|
73 | - */ |
|
74 | - public function __construct( $app, $name, $renderAs = "", $registerCall = true ) { |
|
75 | - // Read the selected theme from the config file |
|
76 | - self::initTemplateEngine($renderAs); |
|
77 | - |
|
78 | - $theme = OC_Util::getTheme(); |
|
79 | - |
|
80 | - $requestToken = (OC::$server->getSession() && $registerCall) ? \OCP\Util::callRegister() : ''; |
|
81 | - |
|
82 | - $parts = explode('/', $app); // fix translation when app is something like core/lostpassword |
|
83 | - $l10n = \OC::$server->getL10N($parts[0]); |
|
84 | - /** @var \OCP\Defaults $themeDefaults */ |
|
85 | - $themeDefaults = \OC::$server->query(\OCP\Defaults::class); |
|
86 | - |
|
87 | - list($path, $template) = $this->findTemplate($theme, $app, $name); |
|
88 | - |
|
89 | - // Set the private data |
|
90 | - $this->renderAs = $renderAs; |
|
91 | - $this->path = $path; |
|
92 | - $this->app = $app; |
|
93 | - |
|
94 | - parent::__construct($template, $requestToken, $l10n, $themeDefaults); |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * @param string $renderAs |
|
99 | - */ |
|
100 | - public static function initTemplateEngine($renderAs) { |
|
101 | - if (self::$initTemplateEngineFirstRun){ |
|
102 | - |
|
103 | - //apps that started before the template initialization can load their own scripts/styles |
|
104 | - //so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true |
|
105 | - //meaning the last script/style in this list will be loaded first |
|
106 | - if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) { |
|
107 | - if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') { |
|
108 | - OC_Util::addScript ( 'backgroundjobs', null, true ); |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - OC_Util::addStyle('server', null, true); |
|
113 | - OC_Util::addStyle('jquery-ui-fixes',null,true); |
|
114 | - OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true); |
|
115 | - OC_Util::addVendorStyle('select2/select2', null, true); |
|
116 | - OC_Util::addStyle('jquery.ocdialog'); |
|
117 | - OC_Util::addTranslations("core", null, true); |
|
118 | - OC_Util::addScript('search', 'search', true); |
|
119 | - OC_Util::addScript('merged-template-prepend', null, true); |
|
120 | - OC_Util::addScript('jquery-ui-fixes'); |
|
121 | - OC_Util::addScript('files/fileinfo'); |
|
122 | - OC_Util::addScript('files/client'); |
|
123 | - OC_Util::addScript('contactsmenu'); |
|
124 | - |
|
125 | - if (\OC::$server->getConfig()->getSystemValue('debug')) { |
|
126 | - // Add the stuff we need always |
|
127 | - // following logic will import all vendor libraries that are |
|
128 | - // specified in core/js/core.json |
|
129 | - $fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json'); |
|
130 | - if($fileContent !== false) { |
|
131 | - $coreDependencies = json_decode($fileContent, true); |
|
132 | - foreach(array_reverse($coreDependencies['vendor']) as $vendorLibrary) { |
|
133 | - //remove trailing ".js" as addVendorScript will append it |
|
134 | - OC_Util::addVendorScript( |
|
135 | - substr($vendorLibrary, 0, -3),null,true); |
|
136 | - } |
|
137 | - } else { |
|
138 | - throw new \Exception('Cannot read core/js/core.json'); |
|
139 | - } |
|
140 | - } else { |
|
141 | - // Import all (combined) default vendor libraries |
|
142 | - OC_Util::addVendorScript('core', null, true); |
|
143 | - } |
|
144 | - |
|
145 | - if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) { |
|
146 | - // polyfill for btoa/atob for IE friends |
|
147 | - OC_Util::addVendorScript('base64/base64'); |
|
148 | - // shim for the davclient.js library |
|
149 | - \OCP\Util::addScript('files/iedavclient'); |
|
150 | - } |
|
151 | - |
|
152 | - self::$initTemplateEngineFirstRun = false; |
|
153 | - } |
|
154 | - |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * find the template with the given name |
|
160 | - * @param string $name of the template file (without suffix) |
|
161 | - * |
|
162 | - * Will select the template file for the selected theme. |
|
163 | - * Checking all the possible locations. |
|
164 | - * @param string $theme |
|
165 | - * @param string $app |
|
166 | - * @return string[] |
|
167 | - */ |
|
168 | - protected function findTemplate($theme, $app, $name) { |
|
169 | - // Check if it is a app template or not. |
|
170 | - if( $app !== '' ) { |
|
171 | - $dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app)); |
|
172 | - } else { |
|
173 | - $dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT); |
|
174 | - } |
|
175 | - $locator = new \OC\Template\TemplateFileLocator( $dirs ); |
|
176 | - $template = $locator->find($name); |
|
177 | - $path = $locator->getPath(); |
|
178 | - return array($path, $template); |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * Add a custom element to the header |
|
183 | - * @param string $tag tag name of the element |
|
184 | - * @param array $attributes array of attributes for the element |
|
185 | - * @param string $text the text content for the element. If $text is null then the |
|
186 | - * element will be written as empty element. So use "" to get a closing tag. |
|
187 | - */ |
|
188 | - public function addHeader($tag, $attributes, $text=null) { |
|
189 | - $this->headers[]= array( |
|
190 | - 'tag' => $tag, |
|
191 | - 'attributes' => $attributes, |
|
192 | - 'text' => $text |
|
193 | - ); |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * Process the template |
|
198 | - * @return boolean|string |
|
199 | - * |
|
200 | - * This function process the template. If $this->renderAs is set, it |
|
201 | - * will produce a full page. |
|
202 | - */ |
|
203 | - public function fetchPage($additionalParams = null) { |
|
204 | - $data = parent::fetchPage($additionalParams); |
|
205 | - |
|
206 | - if( $this->renderAs ) { |
|
207 | - $page = new TemplateLayout($this->renderAs, $this->app); |
|
208 | - |
|
209 | - if(is_array($additionalParams)) { |
|
210 | - foreach ($additionalParams as $key => $value) { |
|
211 | - $page->assign($key, $value); |
|
212 | - } |
|
213 | - } |
|
214 | - |
|
215 | - // Add custom headers |
|
216 | - $headers = ''; |
|
217 | - foreach(OC_Util::$headers as $header) { |
|
218 | - $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']); |
|
219 | - if ( strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes']))) ) { |
|
220 | - $headers .= ' defer'; |
|
221 | - } |
|
222 | - foreach($header['attributes'] as $name=>$value) { |
|
223 | - $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"'; |
|
224 | - } |
|
225 | - if ($header['text'] !== null) { |
|
226 | - $headers .= '>'.\OCP\Util::sanitizeHTML($header['text']).'</'.\OCP\Util::sanitizeHTML($header['tag']).'>'; |
|
227 | - } else { |
|
228 | - $headers .= '/>'; |
|
229 | - } |
|
230 | - } |
|
231 | - |
|
232 | - $page->assign('headers', $headers); |
|
233 | - |
|
234 | - $page->assign('content', $data); |
|
235 | - return $page->fetchPage($additionalParams); |
|
236 | - } |
|
237 | - |
|
238 | - return $data; |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Include template |
|
243 | - * |
|
244 | - * @param string $file |
|
245 | - * @param array|null $additionalParams |
|
246 | - * @return string returns content of included template |
|
247 | - * |
|
248 | - * Includes another template. use <?php echo $this->inc('template'); ?> to |
|
249 | - * do this. |
|
250 | - */ |
|
251 | - public function inc( $file, $additionalParams = null ) { |
|
252 | - return $this->load($this->path.$file.'.php', $additionalParams); |
|
253 | - } |
|
254 | - |
|
255 | - /** |
|
256 | - * Shortcut to print a simple page for users |
|
257 | - * @param string $application The application we render the template for |
|
258 | - * @param string $name Name of the template |
|
259 | - * @param array $parameters Parameters for the template |
|
260 | - * @return boolean|null |
|
261 | - */ |
|
262 | - public static function printUserPage( $application, $name, $parameters = array() ) { |
|
263 | - $content = new OC_Template( $application, $name, "user" ); |
|
264 | - foreach( $parameters as $key => $value ) { |
|
265 | - $content->assign( $key, $value ); |
|
266 | - } |
|
267 | - print $content->printPage(); |
|
268 | - } |
|
269 | - |
|
270 | - /** |
|
271 | - * Shortcut to print a simple page for admins |
|
272 | - * @param string $application The application we render the template for |
|
273 | - * @param string $name Name of the template |
|
274 | - * @param array $parameters Parameters for the template |
|
275 | - * @return bool |
|
276 | - */ |
|
277 | - public static function printAdminPage( $application, $name, $parameters = array() ) { |
|
278 | - $content = new OC_Template( $application, $name, "admin" ); |
|
279 | - foreach( $parameters as $key => $value ) { |
|
280 | - $content->assign( $key, $value ); |
|
281 | - } |
|
282 | - return $content->printPage(); |
|
283 | - } |
|
284 | - |
|
285 | - /** |
|
286 | - * Shortcut to print a simple page for guests |
|
287 | - * @param string $application The application we render the template for |
|
288 | - * @param string $name Name of the template |
|
289 | - * @param array|string $parameters Parameters for the template |
|
290 | - * @return bool |
|
291 | - */ |
|
292 | - public static function printGuestPage( $application, $name, $parameters = array() ) { |
|
293 | - $content = new OC_Template( $application, $name, "guest" ); |
|
294 | - foreach( $parameters as $key => $value ) { |
|
295 | - $content->assign( $key, $value ); |
|
296 | - } |
|
297 | - return $content->printPage(); |
|
298 | - } |
|
299 | - |
|
300 | - /** |
|
301 | - * Print a fatal error page and terminates the script |
|
302 | - * @param string $error_msg The error message to show |
|
303 | - * @param string $hint An optional hint message - needs to be properly escape |
|
304 | - * @suppress PhanAccessMethodInternal |
|
305 | - */ |
|
306 | - public static function printErrorPage( $error_msg, $hint = '' ) { |
|
307 | - if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) { |
|
308 | - \OC_App::loadApp('theming'); |
|
309 | - } |
|
310 | - |
|
311 | - |
|
312 | - if ($error_msg === $hint) { |
|
313 | - // If the hint is the same as the message there is no need to display it twice. |
|
314 | - $hint = ''; |
|
315 | - } |
|
316 | - |
|
317 | - try { |
|
318 | - $content = new \OC_Template( '', 'error', 'error', false ); |
|
319 | - $errors = array(array('error' => $error_msg, 'hint' => $hint)); |
|
320 | - $content->assign( 'errors', $errors ); |
|
321 | - $content->printPage(); |
|
322 | - } catch (\Exception $e) { |
|
323 | - $logger = \OC::$server->getLogger(); |
|
324 | - $logger->error("$error_msg $hint", ['app' => 'core']); |
|
325 | - $logger->logException($e, ['app' => 'core']); |
|
326 | - |
|
327 | - header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
328 | - header('Content-Type: text/plain; charset=utf-8'); |
|
329 | - print("$error_msg $hint"); |
|
330 | - } |
|
331 | - die(); |
|
332 | - } |
|
333 | - |
|
334 | - /** |
|
335 | - * print error page using Exception details |
|
336 | - * @param Exception|Throwable $exception |
|
337 | - * @param bool $fetchPage |
|
338 | - * @return bool|string |
|
339 | - * @suppress PhanAccessMethodInternal |
|
340 | - */ |
|
341 | - public static function printExceptionErrorPage($exception, $fetchPage = false) { |
|
342 | - try { |
|
343 | - $request = \OC::$server->getRequest(); |
|
344 | - $content = new \OC_Template('', 'exception', 'error', false); |
|
345 | - $content->assign('errorClass', get_class($exception)); |
|
346 | - $content->assign('errorMsg', $exception->getMessage()); |
|
347 | - $content->assign('errorCode', $exception->getCode()); |
|
348 | - $content->assign('file', $exception->getFile()); |
|
349 | - $content->assign('line', $exception->getLine()); |
|
350 | - $content->assign('trace', $exception->getTraceAsString()); |
|
351 | - $content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false)); |
|
352 | - $content->assign('remoteAddr', $request->getRemoteAddress()); |
|
353 | - $content->assign('requestID', $request->getId()); |
|
354 | - if ($fetchPage) { |
|
355 | - return $content->fetchPage(); |
|
356 | - } |
|
357 | - $content->printPage(); |
|
358 | - } catch (\Exception $e) { |
|
359 | - $logger = \OC::$server->getLogger(); |
|
360 | - $logger->logException($exception, ['app' => 'core']); |
|
361 | - $logger->logException($e, ['app' => 'core']); |
|
362 | - |
|
363 | - header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
364 | - header('Content-Type: text/plain; charset=utf-8'); |
|
365 | - print("Internal Server Error\n\n"); |
|
366 | - print("The server encountered an internal error and was unable to complete your request.\n"); |
|
367 | - print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n"); |
|
368 | - print("More details can be found in the server log.\n"); |
|
369 | - } |
|
370 | - die(); |
|
371 | - } |
|
372 | - |
|
373 | - /** |
|
374 | - * This is only here to reduce the dependencies in case of an exception to |
|
375 | - * still be able to print a plain error message. |
|
376 | - * |
|
377 | - * Returns the used HTTP protocol. |
|
378 | - * |
|
379 | - * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0. |
|
380 | - * @internal Don't use this - use AppFramework\Http\Request->getHttpProtocol instead |
|
381 | - */ |
|
382 | - protected static function getHttpProtocol() { |
|
383 | - $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']); |
|
384 | - $validProtocols = [ |
|
385 | - 'HTTP/1.0', |
|
386 | - 'HTTP/1.1', |
|
387 | - 'HTTP/2', |
|
388 | - ]; |
|
389 | - if(in_array($claimedProtocol, $validProtocols, true)) { |
|
390 | - return $claimedProtocol; |
|
391 | - } |
|
392 | - return 'HTTP/1.1'; |
|
393 | - } |
|
49 | + /** @var string */ |
|
50 | + private $renderAs; // Create a full page? |
|
51 | + |
|
52 | + /** @var string */ |
|
53 | + private $path; // The path to the template |
|
54 | + |
|
55 | + /** @var array */ |
|
56 | + private $headers = array(); //custom headers |
|
57 | + |
|
58 | + /** @var string */ |
|
59 | + protected $app; // app id |
|
60 | + |
|
61 | + protected static $initTemplateEngineFirstRun = true; |
|
62 | + |
|
63 | + /** |
|
64 | + * Constructor |
|
65 | + * |
|
66 | + * @param string $app app providing the template |
|
67 | + * @param string $name of the template file (without suffix) |
|
68 | + * @param string $renderAs If $renderAs is set, OC_Template will try to |
|
69 | + * produce a full page in the according layout. For |
|
70 | + * now, $renderAs can be set to "guest", "user" or |
|
71 | + * "admin". |
|
72 | + * @param bool $registerCall = true |
|
73 | + */ |
|
74 | + public function __construct( $app, $name, $renderAs = "", $registerCall = true ) { |
|
75 | + // Read the selected theme from the config file |
|
76 | + self::initTemplateEngine($renderAs); |
|
77 | + |
|
78 | + $theme = OC_Util::getTheme(); |
|
79 | + |
|
80 | + $requestToken = (OC::$server->getSession() && $registerCall) ? \OCP\Util::callRegister() : ''; |
|
81 | + |
|
82 | + $parts = explode('/', $app); // fix translation when app is something like core/lostpassword |
|
83 | + $l10n = \OC::$server->getL10N($parts[0]); |
|
84 | + /** @var \OCP\Defaults $themeDefaults */ |
|
85 | + $themeDefaults = \OC::$server->query(\OCP\Defaults::class); |
|
86 | + |
|
87 | + list($path, $template) = $this->findTemplate($theme, $app, $name); |
|
88 | + |
|
89 | + // Set the private data |
|
90 | + $this->renderAs = $renderAs; |
|
91 | + $this->path = $path; |
|
92 | + $this->app = $app; |
|
93 | + |
|
94 | + parent::__construct($template, $requestToken, $l10n, $themeDefaults); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * @param string $renderAs |
|
99 | + */ |
|
100 | + public static function initTemplateEngine($renderAs) { |
|
101 | + if (self::$initTemplateEngineFirstRun){ |
|
102 | + |
|
103 | + //apps that started before the template initialization can load their own scripts/styles |
|
104 | + //so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true |
|
105 | + //meaning the last script/style in this list will be loaded first |
|
106 | + if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) { |
|
107 | + if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') { |
|
108 | + OC_Util::addScript ( 'backgroundjobs', null, true ); |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + OC_Util::addStyle('server', null, true); |
|
113 | + OC_Util::addStyle('jquery-ui-fixes',null,true); |
|
114 | + OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true); |
|
115 | + OC_Util::addVendorStyle('select2/select2', null, true); |
|
116 | + OC_Util::addStyle('jquery.ocdialog'); |
|
117 | + OC_Util::addTranslations("core", null, true); |
|
118 | + OC_Util::addScript('search', 'search', true); |
|
119 | + OC_Util::addScript('merged-template-prepend', null, true); |
|
120 | + OC_Util::addScript('jquery-ui-fixes'); |
|
121 | + OC_Util::addScript('files/fileinfo'); |
|
122 | + OC_Util::addScript('files/client'); |
|
123 | + OC_Util::addScript('contactsmenu'); |
|
124 | + |
|
125 | + if (\OC::$server->getConfig()->getSystemValue('debug')) { |
|
126 | + // Add the stuff we need always |
|
127 | + // following logic will import all vendor libraries that are |
|
128 | + // specified in core/js/core.json |
|
129 | + $fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json'); |
|
130 | + if($fileContent !== false) { |
|
131 | + $coreDependencies = json_decode($fileContent, true); |
|
132 | + foreach(array_reverse($coreDependencies['vendor']) as $vendorLibrary) { |
|
133 | + //remove trailing ".js" as addVendorScript will append it |
|
134 | + OC_Util::addVendorScript( |
|
135 | + substr($vendorLibrary, 0, -3),null,true); |
|
136 | + } |
|
137 | + } else { |
|
138 | + throw new \Exception('Cannot read core/js/core.json'); |
|
139 | + } |
|
140 | + } else { |
|
141 | + // Import all (combined) default vendor libraries |
|
142 | + OC_Util::addVendorScript('core', null, true); |
|
143 | + } |
|
144 | + |
|
145 | + if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) { |
|
146 | + // polyfill for btoa/atob for IE friends |
|
147 | + OC_Util::addVendorScript('base64/base64'); |
|
148 | + // shim for the davclient.js library |
|
149 | + \OCP\Util::addScript('files/iedavclient'); |
|
150 | + } |
|
151 | + |
|
152 | + self::$initTemplateEngineFirstRun = false; |
|
153 | + } |
|
154 | + |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * find the template with the given name |
|
160 | + * @param string $name of the template file (without suffix) |
|
161 | + * |
|
162 | + * Will select the template file for the selected theme. |
|
163 | + * Checking all the possible locations. |
|
164 | + * @param string $theme |
|
165 | + * @param string $app |
|
166 | + * @return string[] |
|
167 | + */ |
|
168 | + protected function findTemplate($theme, $app, $name) { |
|
169 | + // Check if it is a app template or not. |
|
170 | + if( $app !== '' ) { |
|
171 | + $dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app)); |
|
172 | + } else { |
|
173 | + $dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT); |
|
174 | + } |
|
175 | + $locator = new \OC\Template\TemplateFileLocator( $dirs ); |
|
176 | + $template = $locator->find($name); |
|
177 | + $path = $locator->getPath(); |
|
178 | + return array($path, $template); |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * Add a custom element to the header |
|
183 | + * @param string $tag tag name of the element |
|
184 | + * @param array $attributes array of attributes for the element |
|
185 | + * @param string $text the text content for the element. If $text is null then the |
|
186 | + * element will be written as empty element. So use "" to get a closing tag. |
|
187 | + */ |
|
188 | + public function addHeader($tag, $attributes, $text=null) { |
|
189 | + $this->headers[]= array( |
|
190 | + 'tag' => $tag, |
|
191 | + 'attributes' => $attributes, |
|
192 | + 'text' => $text |
|
193 | + ); |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * Process the template |
|
198 | + * @return boolean|string |
|
199 | + * |
|
200 | + * This function process the template. If $this->renderAs is set, it |
|
201 | + * will produce a full page. |
|
202 | + */ |
|
203 | + public function fetchPage($additionalParams = null) { |
|
204 | + $data = parent::fetchPage($additionalParams); |
|
205 | + |
|
206 | + if( $this->renderAs ) { |
|
207 | + $page = new TemplateLayout($this->renderAs, $this->app); |
|
208 | + |
|
209 | + if(is_array($additionalParams)) { |
|
210 | + foreach ($additionalParams as $key => $value) { |
|
211 | + $page->assign($key, $value); |
|
212 | + } |
|
213 | + } |
|
214 | + |
|
215 | + // Add custom headers |
|
216 | + $headers = ''; |
|
217 | + foreach(OC_Util::$headers as $header) { |
|
218 | + $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']); |
|
219 | + if ( strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes']))) ) { |
|
220 | + $headers .= ' defer'; |
|
221 | + } |
|
222 | + foreach($header['attributes'] as $name=>$value) { |
|
223 | + $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"'; |
|
224 | + } |
|
225 | + if ($header['text'] !== null) { |
|
226 | + $headers .= '>'.\OCP\Util::sanitizeHTML($header['text']).'</'.\OCP\Util::sanitizeHTML($header['tag']).'>'; |
|
227 | + } else { |
|
228 | + $headers .= '/>'; |
|
229 | + } |
|
230 | + } |
|
231 | + |
|
232 | + $page->assign('headers', $headers); |
|
233 | + |
|
234 | + $page->assign('content', $data); |
|
235 | + return $page->fetchPage($additionalParams); |
|
236 | + } |
|
237 | + |
|
238 | + return $data; |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Include template |
|
243 | + * |
|
244 | + * @param string $file |
|
245 | + * @param array|null $additionalParams |
|
246 | + * @return string returns content of included template |
|
247 | + * |
|
248 | + * Includes another template. use <?php echo $this->inc('template'); ?> to |
|
249 | + * do this. |
|
250 | + */ |
|
251 | + public function inc( $file, $additionalParams = null ) { |
|
252 | + return $this->load($this->path.$file.'.php', $additionalParams); |
|
253 | + } |
|
254 | + |
|
255 | + /** |
|
256 | + * Shortcut to print a simple page for users |
|
257 | + * @param string $application The application we render the template for |
|
258 | + * @param string $name Name of the template |
|
259 | + * @param array $parameters Parameters for the template |
|
260 | + * @return boolean|null |
|
261 | + */ |
|
262 | + public static function printUserPage( $application, $name, $parameters = array() ) { |
|
263 | + $content = new OC_Template( $application, $name, "user" ); |
|
264 | + foreach( $parameters as $key => $value ) { |
|
265 | + $content->assign( $key, $value ); |
|
266 | + } |
|
267 | + print $content->printPage(); |
|
268 | + } |
|
269 | + |
|
270 | + /** |
|
271 | + * Shortcut to print a simple page for admins |
|
272 | + * @param string $application The application we render the template for |
|
273 | + * @param string $name Name of the template |
|
274 | + * @param array $parameters Parameters for the template |
|
275 | + * @return bool |
|
276 | + */ |
|
277 | + public static function printAdminPage( $application, $name, $parameters = array() ) { |
|
278 | + $content = new OC_Template( $application, $name, "admin" ); |
|
279 | + foreach( $parameters as $key => $value ) { |
|
280 | + $content->assign( $key, $value ); |
|
281 | + } |
|
282 | + return $content->printPage(); |
|
283 | + } |
|
284 | + |
|
285 | + /** |
|
286 | + * Shortcut to print a simple page for guests |
|
287 | + * @param string $application The application we render the template for |
|
288 | + * @param string $name Name of the template |
|
289 | + * @param array|string $parameters Parameters for the template |
|
290 | + * @return bool |
|
291 | + */ |
|
292 | + public static function printGuestPage( $application, $name, $parameters = array() ) { |
|
293 | + $content = new OC_Template( $application, $name, "guest" ); |
|
294 | + foreach( $parameters as $key => $value ) { |
|
295 | + $content->assign( $key, $value ); |
|
296 | + } |
|
297 | + return $content->printPage(); |
|
298 | + } |
|
299 | + |
|
300 | + /** |
|
301 | + * Print a fatal error page and terminates the script |
|
302 | + * @param string $error_msg The error message to show |
|
303 | + * @param string $hint An optional hint message - needs to be properly escape |
|
304 | + * @suppress PhanAccessMethodInternal |
|
305 | + */ |
|
306 | + public static function printErrorPage( $error_msg, $hint = '' ) { |
|
307 | + if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) { |
|
308 | + \OC_App::loadApp('theming'); |
|
309 | + } |
|
310 | + |
|
311 | + |
|
312 | + if ($error_msg === $hint) { |
|
313 | + // If the hint is the same as the message there is no need to display it twice. |
|
314 | + $hint = ''; |
|
315 | + } |
|
316 | + |
|
317 | + try { |
|
318 | + $content = new \OC_Template( '', 'error', 'error', false ); |
|
319 | + $errors = array(array('error' => $error_msg, 'hint' => $hint)); |
|
320 | + $content->assign( 'errors', $errors ); |
|
321 | + $content->printPage(); |
|
322 | + } catch (\Exception $e) { |
|
323 | + $logger = \OC::$server->getLogger(); |
|
324 | + $logger->error("$error_msg $hint", ['app' => 'core']); |
|
325 | + $logger->logException($e, ['app' => 'core']); |
|
326 | + |
|
327 | + header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
328 | + header('Content-Type: text/plain; charset=utf-8'); |
|
329 | + print("$error_msg $hint"); |
|
330 | + } |
|
331 | + die(); |
|
332 | + } |
|
333 | + |
|
334 | + /** |
|
335 | + * print error page using Exception details |
|
336 | + * @param Exception|Throwable $exception |
|
337 | + * @param bool $fetchPage |
|
338 | + * @return bool|string |
|
339 | + * @suppress PhanAccessMethodInternal |
|
340 | + */ |
|
341 | + public static function printExceptionErrorPage($exception, $fetchPage = false) { |
|
342 | + try { |
|
343 | + $request = \OC::$server->getRequest(); |
|
344 | + $content = new \OC_Template('', 'exception', 'error', false); |
|
345 | + $content->assign('errorClass', get_class($exception)); |
|
346 | + $content->assign('errorMsg', $exception->getMessage()); |
|
347 | + $content->assign('errorCode', $exception->getCode()); |
|
348 | + $content->assign('file', $exception->getFile()); |
|
349 | + $content->assign('line', $exception->getLine()); |
|
350 | + $content->assign('trace', $exception->getTraceAsString()); |
|
351 | + $content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false)); |
|
352 | + $content->assign('remoteAddr', $request->getRemoteAddress()); |
|
353 | + $content->assign('requestID', $request->getId()); |
|
354 | + if ($fetchPage) { |
|
355 | + return $content->fetchPage(); |
|
356 | + } |
|
357 | + $content->printPage(); |
|
358 | + } catch (\Exception $e) { |
|
359 | + $logger = \OC::$server->getLogger(); |
|
360 | + $logger->logException($exception, ['app' => 'core']); |
|
361 | + $logger->logException($e, ['app' => 'core']); |
|
362 | + |
|
363 | + header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
364 | + header('Content-Type: text/plain; charset=utf-8'); |
|
365 | + print("Internal Server Error\n\n"); |
|
366 | + print("The server encountered an internal error and was unable to complete your request.\n"); |
|
367 | + print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n"); |
|
368 | + print("More details can be found in the server log.\n"); |
|
369 | + } |
|
370 | + die(); |
|
371 | + } |
|
372 | + |
|
373 | + /** |
|
374 | + * This is only here to reduce the dependencies in case of an exception to |
|
375 | + * still be able to print a plain error message. |
|
376 | + * |
|
377 | + * Returns the used HTTP protocol. |
|
378 | + * |
|
379 | + * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0. |
|
380 | + * @internal Don't use this - use AppFramework\Http\Request->getHttpProtocol instead |
|
381 | + */ |
|
382 | + protected static function getHttpProtocol() { |
|
383 | + $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']); |
|
384 | + $validProtocols = [ |
|
385 | + 'HTTP/1.0', |
|
386 | + 'HTTP/1.1', |
|
387 | + 'HTTP/2', |
|
388 | + ]; |
|
389 | + if(in_array($claimedProtocol, $validProtocols, true)) { |
|
390 | + return $claimedProtocol; |
|
391 | + } |
|
392 | + return 'HTTP/1.1'; |
|
393 | + } |
|
394 | 394 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * "admin". |
72 | 72 | * @param bool $registerCall = true |
73 | 73 | */ |
74 | - public function __construct( $app, $name, $renderAs = "", $registerCall = true ) { |
|
74 | + public function __construct($app, $name, $renderAs = "", $registerCall = true) { |
|
75 | 75 | // Read the selected theme from the config file |
76 | 76 | self::initTemplateEngine($renderAs); |
77 | 77 | |
@@ -98,20 +98,20 @@ discard block |
||
98 | 98 | * @param string $renderAs |
99 | 99 | */ |
100 | 100 | public static function initTemplateEngine($renderAs) { |
101 | - if (self::$initTemplateEngineFirstRun){ |
|
101 | + if (self::$initTemplateEngineFirstRun) { |
|
102 | 102 | |
103 | 103 | //apps that started before the template initialization can load their own scripts/styles |
104 | 104 | //so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true |
105 | 105 | //meaning the last script/style in this list will be loaded first |
106 | - if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) { |
|
107 | - if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') { |
|
108 | - OC_Util::addScript ( 'backgroundjobs', null, true ); |
|
106 | + if (\OC::$server->getSystemConfig()->getValue('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) { |
|
107 | + if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') { |
|
108 | + OC_Util::addScript('backgroundjobs', null, true); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
112 | 112 | OC_Util::addStyle('server', null, true); |
113 | - OC_Util::addStyle('jquery-ui-fixes',null,true); |
|
114 | - OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true); |
|
113 | + OC_Util::addStyle('jquery-ui-fixes', null, true); |
|
114 | + OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui', null, true); |
|
115 | 115 | OC_Util::addVendorStyle('select2/select2', null, true); |
116 | 116 | OC_Util::addStyle('jquery.ocdialog'); |
117 | 117 | OC_Util::addTranslations("core", null, true); |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | // Add the stuff we need always |
127 | 127 | // following logic will import all vendor libraries that are |
128 | 128 | // specified in core/js/core.json |
129 | - $fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json'); |
|
130 | - if($fileContent !== false) { |
|
129 | + $fileContent = file_get_contents(OC::$SERVERROOT.'/core/js/core.json'); |
|
130 | + if ($fileContent !== false) { |
|
131 | 131 | $coreDependencies = json_decode($fileContent, true); |
132 | - foreach(array_reverse($coreDependencies['vendor']) as $vendorLibrary) { |
|
132 | + foreach (array_reverse($coreDependencies['vendor']) as $vendorLibrary) { |
|
133 | 133 | //remove trailing ".js" as addVendorScript will append it |
134 | 134 | OC_Util::addVendorScript( |
135 | - substr($vendorLibrary, 0, -3),null,true); |
|
135 | + substr($vendorLibrary, 0, -3), null, true); |
|
136 | 136 | } |
137 | 137 | } else { |
138 | 138 | throw new \Exception('Cannot read core/js/core.json'); |
@@ -167,12 +167,12 @@ discard block |
||
167 | 167 | */ |
168 | 168 | protected function findTemplate($theme, $app, $name) { |
169 | 169 | // Check if it is a app template or not. |
170 | - if( $app !== '' ) { |
|
170 | + if ($app !== '') { |
|
171 | 171 | $dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app)); |
172 | 172 | } else { |
173 | 173 | $dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT); |
174 | 174 | } |
175 | - $locator = new \OC\Template\TemplateFileLocator( $dirs ); |
|
175 | + $locator = new \OC\Template\TemplateFileLocator($dirs); |
|
176 | 176 | $template = $locator->find($name); |
177 | 177 | $path = $locator->getPath(); |
178 | 178 | return array($path, $template); |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | * @param string $text the text content for the element. If $text is null then the |
186 | 186 | * element will be written as empty element. So use "" to get a closing tag. |
187 | 187 | */ |
188 | - public function addHeader($tag, $attributes, $text=null) { |
|
189 | - $this->headers[]= array( |
|
188 | + public function addHeader($tag, $attributes, $text = null) { |
|
189 | + $this->headers[] = array( |
|
190 | 190 | 'tag' => $tag, |
191 | 191 | 'attributes' => $attributes, |
192 | 192 | 'text' => $text |
@@ -203,10 +203,10 @@ discard block |
||
203 | 203 | public function fetchPage($additionalParams = null) { |
204 | 204 | $data = parent::fetchPage($additionalParams); |
205 | 205 | |
206 | - if( $this->renderAs ) { |
|
206 | + if ($this->renderAs) { |
|
207 | 207 | $page = new TemplateLayout($this->renderAs, $this->app); |
208 | 208 | |
209 | - if(is_array($additionalParams)) { |
|
209 | + if (is_array($additionalParams)) { |
|
210 | 210 | foreach ($additionalParams as $key => $value) { |
211 | 211 | $page->assign($key, $value); |
212 | 212 | } |
@@ -214,12 +214,12 @@ discard block |
||
214 | 214 | |
215 | 215 | // Add custom headers |
216 | 216 | $headers = ''; |
217 | - foreach(OC_Util::$headers as $header) { |
|
217 | + foreach (OC_Util::$headers as $header) { |
|
218 | 218 | $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']); |
219 | - if ( strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes']))) ) { |
|
219 | + if (strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes'])))) { |
|
220 | 220 | $headers .= ' defer'; |
221 | 221 | } |
222 | - foreach($header['attributes'] as $name=>$value) { |
|
222 | + foreach ($header['attributes'] as $name=>$value) { |
|
223 | 223 | $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"'; |
224 | 224 | } |
225 | 225 | if ($header['text'] !== null) { |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * Includes another template. use <?php echo $this->inc('template'); ?> to |
249 | 249 | * do this. |
250 | 250 | */ |
251 | - public function inc( $file, $additionalParams = null ) { |
|
251 | + public function inc($file, $additionalParams = null) { |
|
252 | 252 | return $this->load($this->path.$file.'.php', $additionalParams); |
253 | 253 | } |
254 | 254 | |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | * @param array $parameters Parameters for the template |
260 | 260 | * @return boolean|null |
261 | 261 | */ |
262 | - public static function printUserPage( $application, $name, $parameters = array() ) { |
|
263 | - $content = new OC_Template( $application, $name, "user" ); |
|
264 | - foreach( $parameters as $key => $value ) { |
|
265 | - $content->assign( $key, $value ); |
|
262 | + public static function printUserPage($application, $name, $parameters = array()) { |
|
263 | + $content = new OC_Template($application, $name, "user"); |
|
264 | + foreach ($parameters as $key => $value) { |
|
265 | + $content->assign($key, $value); |
|
266 | 266 | } |
267 | 267 | print $content->printPage(); |
268 | 268 | } |
@@ -274,10 +274,10 @@ discard block |
||
274 | 274 | * @param array $parameters Parameters for the template |
275 | 275 | * @return bool |
276 | 276 | */ |
277 | - public static function printAdminPage( $application, $name, $parameters = array() ) { |
|
278 | - $content = new OC_Template( $application, $name, "admin" ); |
|
279 | - foreach( $parameters as $key => $value ) { |
|
280 | - $content->assign( $key, $value ); |
|
277 | + public static function printAdminPage($application, $name, $parameters = array()) { |
|
278 | + $content = new OC_Template($application, $name, "admin"); |
|
279 | + foreach ($parameters as $key => $value) { |
|
280 | + $content->assign($key, $value); |
|
281 | 281 | } |
282 | 282 | return $content->printPage(); |
283 | 283 | } |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | * @param array|string $parameters Parameters for the template |
290 | 290 | * @return bool |
291 | 291 | */ |
292 | - public static function printGuestPage( $application, $name, $parameters = array() ) { |
|
293 | - $content = new OC_Template( $application, $name, "guest" ); |
|
294 | - foreach( $parameters as $key => $value ) { |
|
295 | - $content->assign( $key, $value ); |
|
292 | + public static function printGuestPage($application, $name, $parameters = array()) { |
|
293 | + $content = new OC_Template($application, $name, "guest"); |
|
294 | + foreach ($parameters as $key => $value) { |
|
295 | + $content->assign($key, $value); |
|
296 | 296 | } |
297 | 297 | return $content->printPage(); |
298 | 298 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * @param string $hint An optional hint message - needs to be properly escape |
304 | 304 | * @suppress PhanAccessMethodInternal |
305 | 305 | */ |
306 | - public static function printErrorPage( $error_msg, $hint = '' ) { |
|
306 | + public static function printErrorPage($error_msg, $hint = '') { |
|
307 | 307 | if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) { |
308 | 308 | \OC_App::loadApp('theming'); |
309 | 309 | } |
@@ -315,16 +315,16 @@ discard block |
||
315 | 315 | } |
316 | 316 | |
317 | 317 | try { |
318 | - $content = new \OC_Template( '', 'error', 'error', false ); |
|
318 | + $content = new \OC_Template('', 'error', 'error', false); |
|
319 | 319 | $errors = array(array('error' => $error_msg, 'hint' => $hint)); |
320 | - $content->assign( 'errors', $errors ); |
|
320 | + $content->assign('errors', $errors); |
|
321 | 321 | $content->printPage(); |
322 | 322 | } catch (\Exception $e) { |
323 | 323 | $logger = \OC::$server->getLogger(); |
324 | 324 | $logger->error("$error_msg $hint", ['app' => 'core']); |
325 | 325 | $logger->logException($e, ['app' => 'core']); |
326 | 326 | |
327 | - header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
327 | + header(self::getHttpProtocol().' 500 Internal Server Error'); |
|
328 | 328 | header('Content-Type: text/plain; charset=utf-8'); |
329 | 329 | print("$error_msg $hint"); |
330 | 330 | } |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | $logger->logException($exception, ['app' => 'core']); |
361 | 361 | $logger->logException($e, ['app' => 'core']); |
362 | 362 | |
363 | - header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
363 | + header(self::getHttpProtocol().' 500 Internal Server Error'); |
|
364 | 364 | header('Content-Type: text/plain; charset=utf-8'); |
365 | 365 | print("Internal Server Error\n\n"); |
366 | 366 | print("The server encountered an internal error and was unable to complete your request.\n"); |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | 'HTTP/1.1', |
387 | 387 | 'HTTP/2', |
388 | 388 | ]; |
389 | - if(in_array($claimedProtocol, $validProtocols, true)) { |
|
389 | + if (in_array($claimedProtocol, $validProtocols, true)) { |
|
390 | 390 | return $claimedProtocol; |
391 | 391 | } |
392 | 392 | return 'HTTP/1.1'; |
@@ -45,290 +45,290 @@ |
||
45 | 45 | |
46 | 46 | class TemplateLayout extends \OC_Template { |
47 | 47 | |
48 | - private static $versionHash = ''; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var \OCP\IConfig |
|
52 | - */ |
|
53 | - private $config; |
|
54 | - |
|
55 | - /** |
|
56 | - * @param string $renderAs |
|
57 | - * @param string $appId application id |
|
58 | - */ |
|
59 | - public function __construct( $renderAs, $appId = '' ) { |
|
60 | - |
|
61 | - // yes - should be injected .... |
|
62 | - $this->config = \OC::$server->getConfig(); |
|
63 | - |
|
64 | - |
|
65 | - // Decide which page we show |
|
66 | - if($renderAs == 'user') { |
|
67 | - parent::__construct( 'core', 'layout.user' ); |
|
68 | - if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
69 | - $this->assign('bodyid', 'body-settings'); |
|
70 | - }else{ |
|
71 | - $this->assign('bodyid', 'body-user'); |
|
72 | - } |
|
73 | - |
|
74 | - // Code integrity notification |
|
75 | - $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
|
76 | - if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
77 | - \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
|
78 | - } |
|
79 | - |
|
80 | - // Add navigation entry |
|
81 | - $this->assign( 'application', ''); |
|
82 | - $this->assign( 'appid', $appId ); |
|
83 | - $navigation = \OC_App::getNavigation(); |
|
84 | - $this->assign( 'navigation', $navigation); |
|
85 | - $settingsNavigation = \OC_App::getSettingsNavigation(); |
|
86 | - $this->assign( 'settingsnavigation', $settingsNavigation); |
|
87 | - foreach($navigation as $entry) { |
|
88 | - if ($entry['active']) { |
|
89 | - $this->assign( 'application', $entry['name'] ); |
|
90 | - break; |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - foreach($settingsNavigation as $entry) { |
|
95 | - if ($entry['active']) { |
|
96 | - $this->assign( 'application', $entry['name'] ); |
|
97 | - break; |
|
98 | - } |
|
99 | - } |
|
100 | - $userDisplayName = \OC_User::getDisplayName(); |
|
101 | - $this->assign('user_displayname', $userDisplayName); |
|
102 | - $this->assign('user_uid', \OC_User::getUser()); |
|
103 | - |
|
104 | - if (\OC_User::getUser() === false) { |
|
105 | - $this->assign('userAvatarSet', false); |
|
106 | - } else { |
|
107 | - $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
108 | - $this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
109 | - } |
|
110 | - |
|
111 | - // check if app menu icons should be inverted |
|
112 | - try { |
|
113 | - /** @var \OCA\Theming\Util $util */ |
|
114 | - $util = \OC::$server->query(\OCA\Theming\Util::class); |
|
115 | - $this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary())); |
|
116 | - } catch (\OCP\AppFramework\QueryException $e) { |
|
117 | - $this->assign('themingInvertMenu', false); |
|
118 | - } |
|
119 | - |
|
120 | - } else if ($renderAs == 'error') { |
|
121 | - parent::__construct('core', 'layout.guest', '', false); |
|
122 | - $this->assign('bodyid', 'body-login'); |
|
123 | - } else if ($renderAs == 'guest') { |
|
124 | - parent::__construct('core', 'layout.guest'); |
|
125 | - $this->assign('bodyid', 'body-login'); |
|
126 | - } else if ($renderAs == 'public') { |
|
127 | - parent::__construct('core', 'layout.public'); |
|
128 | - $this->assign( 'appid', $appId ); |
|
129 | - $this->assign('bodyid', 'body-public'); |
|
130 | - } else { |
|
131 | - parent::__construct('core', 'layout.base'); |
|
132 | - |
|
133 | - } |
|
134 | - // Send the language to our layouts |
|
135 | - $lang = \OC::$server->getL10NFactory()->findLanguage(); |
|
136 | - $lang = str_replace('_', '-', $lang); |
|
137 | - $this->assign('language', $lang); |
|
138 | - |
|
139 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
140 | - if (empty(self::$versionHash)) { |
|
141 | - $v = \OC_App::getAppVersions(); |
|
142 | - $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
143 | - self::$versionHash = substr(md5(implode(',', $v)), 0, 8); |
|
144 | - } |
|
145 | - } else { |
|
146 | - self::$versionHash = md5('not installed'); |
|
147 | - } |
|
148 | - |
|
149 | - // Add the js files |
|
150 | - $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
151 | - $this->assign('jsfiles', array()); |
|
152 | - if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
153 | - if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
154 | - $jsConfigHelper = new JSConfigHelper( |
|
155 | - \OC::$server->getL10N('lib'), |
|
156 | - \OC::$server->query(Defaults::class), |
|
157 | - \OC::$server->getAppManager(), |
|
158 | - \OC::$server->getSession(), |
|
159 | - \OC::$server->getUserSession()->getUser(), |
|
160 | - $this->config, |
|
161 | - \OC::$server->getGroupManager(), |
|
162 | - \OC::$server->getIniWrapper(), |
|
163 | - \OC::$server->getURLGenerator() |
|
164 | - ); |
|
165 | - $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
166 | - } else { |
|
167 | - $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
168 | - } |
|
169 | - } |
|
170 | - foreach($jsFiles as $info) { |
|
171 | - $web = $info[1]; |
|
172 | - $file = $info[2]; |
|
173 | - $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
174 | - } |
|
175 | - |
|
176 | - try { |
|
177 | - $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
178 | - } catch (\Exception $e) { |
|
179 | - $pathInfo = ''; |
|
180 | - } |
|
181 | - |
|
182 | - // Do not initialise scss appdata until we have a fully installed instance |
|
183 | - // Do not load scss for update, errors, installation or login page |
|
184 | - if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
185 | - && !\OCP\Util::needUpgrade() |
|
186 | - && $pathInfo !== '' |
|
187 | - && !preg_match('/^\/login/', $pathInfo) |
|
188 | - && $renderAs !== 'error' && $renderAs !== 'guest' |
|
189 | - ) { |
|
190 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
191 | - } else { |
|
192 | - // If we ignore the scss compiler, |
|
193 | - // we need to load the guest css fallback |
|
194 | - \OC_Util::addStyle('guest'); |
|
195 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
196 | - } |
|
197 | - |
|
198 | - $this->assign('cssfiles', array()); |
|
199 | - $this->assign('printcssfiles', []); |
|
200 | - $this->assign('versionHash', self::$versionHash); |
|
201 | - foreach($cssFiles as $info) { |
|
202 | - $web = $info[1]; |
|
203 | - $file = $info[2]; |
|
204 | - |
|
205 | - if (substr($file, -strlen('print.css')) === 'print.css') { |
|
206 | - $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
207 | - } else { |
|
208 | - $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file) ); |
|
209 | - } |
|
210 | - } |
|
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * @param string $path |
|
215 | - * @param string $file |
|
216 | - * @return string |
|
217 | - */ |
|
218 | - protected function getVersionHashSuffix($path = false, $file = false) { |
|
219 | - if ($this->config->getSystemValue('debug', false)) { |
|
220 | - // allows chrome workspace mapping in debug mode |
|
221 | - return ""; |
|
222 | - } |
|
223 | - $themingSuffix = ''; |
|
224 | - $v = []; |
|
225 | - |
|
226 | - if ($this->config->getSystemValue('installed', false)) { |
|
227 | - if (\OC::$server->getAppManager()->isInstalled('theming')) { |
|
228 | - $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
229 | - } |
|
230 | - $v = \OC_App::getAppVersions(); |
|
231 | - } |
|
232 | - |
|
233 | - // Try the webroot path for a match |
|
234 | - if ($path !== false && $path !== '') { |
|
235 | - $appName = $this->getAppNamefromPath($path); |
|
236 | - if(array_key_exists($appName, $v)) { |
|
237 | - $appVersion = $v[$appName]; |
|
238 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
239 | - } |
|
240 | - } |
|
241 | - // fallback to the file path instead |
|
242 | - if ($file !== false && $file !== '') { |
|
243 | - $appName = $this->getAppNamefromPath($file); |
|
244 | - if(array_key_exists($appName, $v)) { |
|
245 | - $appVersion = $v[$appName]; |
|
246 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
247 | - } |
|
248 | - } |
|
249 | - |
|
250 | - return '?v=' . self::$versionHash . $themingSuffix; |
|
251 | - } |
|
252 | - |
|
253 | - /** |
|
254 | - * @param array $styles |
|
255 | - * @return array |
|
256 | - */ |
|
257 | - static public function findStylesheetFiles($styles, $compileScss = true) { |
|
258 | - // Read the selected theme from the config file |
|
259 | - $theme = \OC_Util::getTheme(); |
|
260 | - |
|
261 | - if($compileScss) { |
|
262 | - $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
|
263 | - } else { |
|
264 | - $SCSSCacher = null; |
|
265 | - } |
|
266 | - |
|
267 | - $locator = new \OC\Template\CSSResourceLocator( |
|
268 | - \OC::$server->getLogger(), |
|
269 | - $theme, |
|
270 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
271 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
272 | - $SCSSCacher |
|
273 | - ); |
|
274 | - $locator->find($styles); |
|
275 | - return $locator->getResources(); |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * @param string $path |
|
280 | - * @return string|boolean |
|
281 | - */ |
|
282 | - public function getAppNamefromPath($path) { |
|
283 | - if ($path !== '' && is_string($path)) { |
|
284 | - $pathParts = explode('/', $path); |
|
285 | - if ($pathParts[0] === 'css') { |
|
286 | - // This is a scss request |
|
287 | - return $pathParts[1]; |
|
288 | - } |
|
289 | - return end($pathParts); |
|
290 | - } |
|
291 | - return false; |
|
292 | - |
|
293 | - } |
|
294 | - |
|
295 | - /** |
|
296 | - * @param array $scripts |
|
297 | - * @return array |
|
298 | - */ |
|
299 | - static public function findJavascriptFiles($scripts) { |
|
300 | - // Read the selected theme from the config file |
|
301 | - $theme = \OC_Util::getTheme(); |
|
302 | - |
|
303 | - $locator = new \OC\Template\JSResourceLocator( |
|
304 | - \OC::$server->getLogger(), |
|
305 | - $theme, |
|
306 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
307 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
308 | - new JSCombiner( |
|
309 | - \OC::$server->getAppDataDir('js'), |
|
310 | - \OC::$server->getURLGenerator(), |
|
311 | - \OC::$server->getMemCacheFactory()->createDistributed('JS'), |
|
312 | - \OC::$server->getSystemConfig(), |
|
313 | - \OC::$server->getLogger() |
|
314 | - ) |
|
315 | - ); |
|
316 | - $locator->find($scripts); |
|
317 | - return $locator->getResources(); |
|
318 | - } |
|
319 | - |
|
320 | - /** |
|
321 | - * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
322 | - * @param string $filePath Absolute path |
|
323 | - * @return string Relative path |
|
324 | - * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
325 | - */ |
|
326 | - public static function convertToRelativePath($filePath) { |
|
327 | - $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
328 | - if(count($relativePath) !== 2) { |
|
329 | - throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
330 | - } |
|
331 | - |
|
332 | - return $relativePath[1]; |
|
333 | - } |
|
48 | + private static $versionHash = ''; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var \OCP\IConfig |
|
52 | + */ |
|
53 | + private $config; |
|
54 | + |
|
55 | + /** |
|
56 | + * @param string $renderAs |
|
57 | + * @param string $appId application id |
|
58 | + */ |
|
59 | + public function __construct( $renderAs, $appId = '' ) { |
|
60 | + |
|
61 | + // yes - should be injected .... |
|
62 | + $this->config = \OC::$server->getConfig(); |
|
63 | + |
|
64 | + |
|
65 | + // Decide which page we show |
|
66 | + if($renderAs == 'user') { |
|
67 | + parent::__construct( 'core', 'layout.user' ); |
|
68 | + if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
69 | + $this->assign('bodyid', 'body-settings'); |
|
70 | + }else{ |
|
71 | + $this->assign('bodyid', 'body-user'); |
|
72 | + } |
|
73 | + |
|
74 | + // Code integrity notification |
|
75 | + $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
|
76 | + if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
77 | + \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
|
78 | + } |
|
79 | + |
|
80 | + // Add navigation entry |
|
81 | + $this->assign( 'application', ''); |
|
82 | + $this->assign( 'appid', $appId ); |
|
83 | + $navigation = \OC_App::getNavigation(); |
|
84 | + $this->assign( 'navigation', $navigation); |
|
85 | + $settingsNavigation = \OC_App::getSettingsNavigation(); |
|
86 | + $this->assign( 'settingsnavigation', $settingsNavigation); |
|
87 | + foreach($navigation as $entry) { |
|
88 | + if ($entry['active']) { |
|
89 | + $this->assign( 'application', $entry['name'] ); |
|
90 | + break; |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + foreach($settingsNavigation as $entry) { |
|
95 | + if ($entry['active']) { |
|
96 | + $this->assign( 'application', $entry['name'] ); |
|
97 | + break; |
|
98 | + } |
|
99 | + } |
|
100 | + $userDisplayName = \OC_User::getDisplayName(); |
|
101 | + $this->assign('user_displayname', $userDisplayName); |
|
102 | + $this->assign('user_uid', \OC_User::getUser()); |
|
103 | + |
|
104 | + if (\OC_User::getUser() === false) { |
|
105 | + $this->assign('userAvatarSet', false); |
|
106 | + } else { |
|
107 | + $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
108 | + $this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
109 | + } |
|
110 | + |
|
111 | + // check if app menu icons should be inverted |
|
112 | + try { |
|
113 | + /** @var \OCA\Theming\Util $util */ |
|
114 | + $util = \OC::$server->query(\OCA\Theming\Util::class); |
|
115 | + $this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary())); |
|
116 | + } catch (\OCP\AppFramework\QueryException $e) { |
|
117 | + $this->assign('themingInvertMenu', false); |
|
118 | + } |
|
119 | + |
|
120 | + } else if ($renderAs == 'error') { |
|
121 | + parent::__construct('core', 'layout.guest', '', false); |
|
122 | + $this->assign('bodyid', 'body-login'); |
|
123 | + } else if ($renderAs == 'guest') { |
|
124 | + parent::__construct('core', 'layout.guest'); |
|
125 | + $this->assign('bodyid', 'body-login'); |
|
126 | + } else if ($renderAs == 'public') { |
|
127 | + parent::__construct('core', 'layout.public'); |
|
128 | + $this->assign( 'appid', $appId ); |
|
129 | + $this->assign('bodyid', 'body-public'); |
|
130 | + } else { |
|
131 | + parent::__construct('core', 'layout.base'); |
|
132 | + |
|
133 | + } |
|
134 | + // Send the language to our layouts |
|
135 | + $lang = \OC::$server->getL10NFactory()->findLanguage(); |
|
136 | + $lang = str_replace('_', '-', $lang); |
|
137 | + $this->assign('language', $lang); |
|
138 | + |
|
139 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
140 | + if (empty(self::$versionHash)) { |
|
141 | + $v = \OC_App::getAppVersions(); |
|
142 | + $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
143 | + self::$versionHash = substr(md5(implode(',', $v)), 0, 8); |
|
144 | + } |
|
145 | + } else { |
|
146 | + self::$versionHash = md5('not installed'); |
|
147 | + } |
|
148 | + |
|
149 | + // Add the js files |
|
150 | + $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
151 | + $this->assign('jsfiles', array()); |
|
152 | + if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
153 | + if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
154 | + $jsConfigHelper = new JSConfigHelper( |
|
155 | + \OC::$server->getL10N('lib'), |
|
156 | + \OC::$server->query(Defaults::class), |
|
157 | + \OC::$server->getAppManager(), |
|
158 | + \OC::$server->getSession(), |
|
159 | + \OC::$server->getUserSession()->getUser(), |
|
160 | + $this->config, |
|
161 | + \OC::$server->getGroupManager(), |
|
162 | + \OC::$server->getIniWrapper(), |
|
163 | + \OC::$server->getURLGenerator() |
|
164 | + ); |
|
165 | + $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
166 | + } else { |
|
167 | + $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
168 | + } |
|
169 | + } |
|
170 | + foreach($jsFiles as $info) { |
|
171 | + $web = $info[1]; |
|
172 | + $file = $info[2]; |
|
173 | + $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
174 | + } |
|
175 | + |
|
176 | + try { |
|
177 | + $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
178 | + } catch (\Exception $e) { |
|
179 | + $pathInfo = ''; |
|
180 | + } |
|
181 | + |
|
182 | + // Do not initialise scss appdata until we have a fully installed instance |
|
183 | + // Do not load scss for update, errors, installation or login page |
|
184 | + if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
185 | + && !\OCP\Util::needUpgrade() |
|
186 | + && $pathInfo !== '' |
|
187 | + && !preg_match('/^\/login/', $pathInfo) |
|
188 | + && $renderAs !== 'error' && $renderAs !== 'guest' |
|
189 | + ) { |
|
190 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
191 | + } else { |
|
192 | + // If we ignore the scss compiler, |
|
193 | + // we need to load the guest css fallback |
|
194 | + \OC_Util::addStyle('guest'); |
|
195 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
196 | + } |
|
197 | + |
|
198 | + $this->assign('cssfiles', array()); |
|
199 | + $this->assign('printcssfiles', []); |
|
200 | + $this->assign('versionHash', self::$versionHash); |
|
201 | + foreach($cssFiles as $info) { |
|
202 | + $web = $info[1]; |
|
203 | + $file = $info[2]; |
|
204 | + |
|
205 | + if (substr($file, -strlen('print.css')) === 'print.css') { |
|
206 | + $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
207 | + } else { |
|
208 | + $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file) ); |
|
209 | + } |
|
210 | + } |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * @param string $path |
|
215 | + * @param string $file |
|
216 | + * @return string |
|
217 | + */ |
|
218 | + protected function getVersionHashSuffix($path = false, $file = false) { |
|
219 | + if ($this->config->getSystemValue('debug', false)) { |
|
220 | + // allows chrome workspace mapping in debug mode |
|
221 | + return ""; |
|
222 | + } |
|
223 | + $themingSuffix = ''; |
|
224 | + $v = []; |
|
225 | + |
|
226 | + if ($this->config->getSystemValue('installed', false)) { |
|
227 | + if (\OC::$server->getAppManager()->isInstalled('theming')) { |
|
228 | + $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
229 | + } |
|
230 | + $v = \OC_App::getAppVersions(); |
|
231 | + } |
|
232 | + |
|
233 | + // Try the webroot path for a match |
|
234 | + if ($path !== false && $path !== '') { |
|
235 | + $appName = $this->getAppNamefromPath($path); |
|
236 | + if(array_key_exists($appName, $v)) { |
|
237 | + $appVersion = $v[$appName]; |
|
238 | + return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
239 | + } |
|
240 | + } |
|
241 | + // fallback to the file path instead |
|
242 | + if ($file !== false && $file !== '') { |
|
243 | + $appName = $this->getAppNamefromPath($file); |
|
244 | + if(array_key_exists($appName, $v)) { |
|
245 | + $appVersion = $v[$appName]; |
|
246 | + return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
247 | + } |
|
248 | + } |
|
249 | + |
|
250 | + return '?v=' . self::$versionHash . $themingSuffix; |
|
251 | + } |
|
252 | + |
|
253 | + /** |
|
254 | + * @param array $styles |
|
255 | + * @return array |
|
256 | + */ |
|
257 | + static public function findStylesheetFiles($styles, $compileScss = true) { |
|
258 | + // Read the selected theme from the config file |
|
259 | + $theme = \OC_Util::getTheme(); |
|
260 | + |
|
261 | + if($compileScss) { |
|
262 | + $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
|
263 | + } else { |
|
264 | + $SCSSCacher = null; |
|
265 | + } |
|
266 | + |
|
267 | + $locator = new \OC\Template\CSSResourceLocator( |
|
268 | + \OC::$server->getLogger(), |
|
269 | + $theme, |
|
270 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
271 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
272 | + $SCSSCacher |
|
273 | + ); |
|
274 | + $locator->find($styles); |
|
275 | + return $locator->getResources(); |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * @param string $path |
|
280 | + * @return string|boolean |
|
281 | + */ |
|
282 | + public function getAppNamefromPath($path) { |
|
283 | + if ($path !== '' && is_string($path)) { |
|
284 | + $pathParts = explode('/', $path); |
|
285 | + if ($pathParts[0] === 'css') { |
|
286 | + // This is a scss request |
|
287 | + return $pathParts[1]; |
|
288 | + } |
|
289 | + return end($pathParts); |
|
290 | + } |
|
291 | + return false; |
|
292 | + |
|
293 | + } |
|
294 | + |
|
295 | + /** |
|
296 | + * @param array $scripts |
|
297 | + * @return array |
|
298 | + */ |
|
299 | + static public function findJavascriptFiles($scripts) { |
|
300 | + // Read the selected theme from the config file |
|
301 | + $theme = \OC_Util::getTheme(); |
|
302 | + |
|
303 | + $locator = new \OC\Template\JSResourceLocator( |
|
304 | + \OC::$server->getLogger(), |
|
305 | + $theme, |
|
306 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
307 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
308 | + new JSCombiner( |
|
309 | + \OC::$server->getAppDataDir('js'), |
|
310 | + \OC::$server->getURLGenerator(), |
|
311 | + \OC::$server->getMemCacheFactory()->createDistributed('JS'), |
|
312 | + \OC::$server->getSystemConfig(), |
|
313 | + \OC::$server->getLogger() |
|
314 | + ) |
|
315 | + ); |
|
316 | + $locator->find($scripts); |
|
317 | + return $locator->getResources(); |
|
318 | + } |
|
319 | + |
|
320 | + /** |
|
321 | + * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
322 | + * @param string $filePath Absolute path |
|
323 | + * @return string Relative path |
|
324 | + * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
325 | + */ |
|
326 | + public static function convertToRelativePath($filePath) { |
|
327 | + $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
328 | + if(count($relativePath) !== 2) { |
|
329 | + throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
330 | + } |
|
331 | + |
|
332 | + return $relativePath[1]; |
|
333 | + } |
|
334 | 334 | } |
@@ -56,44 +56,44 @@ discard block |
||
56 | 56 | * @param string $renderAs |
57 | 57 | * @param string $appId application id |
58 | 58 | */ |
59 | - public function __construct( $renderAs, $appId = '' ) { |
|
59 | + public function __construct($renderAs, $appId = '') { |
|
60 | 60 | |
61 | 61 | // yes - should be injected .... |
62 | 62 | $this->config = \OC::$server->getConfig(); |
63 | 63 | |
64 | 64 | |
65 | 65 | // Decide which page we show |
66 | - if($renderAs == 'user') { |
|
67 | - parent::__construct( 'core', 'layout.user' ); |
|
68 | - if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
66 | + if ($renderAs == 'user') { |
|
67 | + parent::__construct('core', 'layout.user'); |
|
68 | + if (in_array(\OC_App::getCurrentApp(), ['settings', 'admin', 'help']) !== false) { |
|
69 | 69 | $this->assign('bodyid', 'body-settings'); |
70 | - }else{ |
|
70 | + } else { |
|
71 | 71 | $this->assign('bodyid', 'body-user'); |
72 | 72 | } |
73 | 73 | |
74 | 74 | // Code integrity notification |
75 | 75 | $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
76 | - if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
76 | + if (\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
77 | 77 | \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // Add navigation entry |
81 | - $this->assign( 'application', ''); |
|
82 | - $this->assign( 'appid', $appId ); |
|
81 | + $this->assign('application', ''); |
|
82 | + $this->assign('appid', $appId); |
|
83 | 83 | $navigation = \OC_App::getNavigation(); |
84 | - $this->assign( 'navigation', $navigation); |
|
84 | + $this->assign('navigation', $navigation); |
|
85 | 85 | $settingsNavigation = \OC_App::getSettingsNavigation(); |
86 | - $this->assign( 'settingsnavigation', $settingsNavigation); |
|
87 | - foreach($navigation as $entry) { |
|
86 | + $this->assign('settingsnavigation', $settingsNavigation); |
|
87 | + foreach ($navigation as $entry) { |
|
88 | 88 | if ($entry['active']) { |
89 | - $this->assign( 'application', $entry['name'] ); |
|
89 | + $this->assign('application', $entry['name']); |
|
90 | 90 | break; |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | - foreach($settingsNavigation as $entry) { |
|
94 | + foreach ($settingsNavigation as $entry) { |
|
95 | 95 | if ($entry['active']) { |
96 | - $this->assign( 'application', $entry['name'] ); |
|
96 | + $this->assign('application', $entry['name']); |
|
97 | 97 | break; |
98 | 98 | } |
99 | 99 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $this->assign('bodyid', 'body-login'); |
126 | 126 | } else if ($renderAs == 'public') { |
127 | 127 | parent::__construct('core', 'layout.public'); |
128 | - $this->assign( 'appid', $appId ); |
|
128 | + $this->assign('appid', $appId); |
|
129 | 129 | $this->assign('bodyid', 'body-public'); |
130 | 130 | } else { |
131 | 131 | parent::__construct('core', 'layout.base'); |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $lang = str_replace('_', '-', $lang); |
137 | 137 | $this->assign('language', $lang); |
138 | 138 | |
139 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
139 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
140 | 140 | if (empty(self::$versionHash)) { |
141 | 141 | $v = \OC_App::getAppVersions(); |
142 | 142 | $v['core'] = implode('.', \OCP\Util::getVersion()); |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
168 | 168 | } |
169 | 169 | } |
170 | - foreach($jsFiles as $info) { |
|
170 | + foreach ($jsFiles as $info) { |
|
171 | 171 | $web = $info[1]; |
172 | 172 | $file = $info[2]; |
173 | - $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
173 | + $this->append('jsfiles', $web.'/'.$file.$this->getVersionHashSuffix()); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | try { |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | // Do not initialise scss appdata until we have a fully installed instance |
183 | 183 | // Do not load scss for update, errors, installation or login page |
184 | - if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
184 | + if (\OC::$server->getSystemConfig()->getValue('installed', false) |
|
185 | 185 | && !\OCP\Util::needUpgrade() |
186 | 186 | && $pathInfo !== '' |
187 | 187 | && !preg_match('/^\/login/', $pathInfo) |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | $this->assign('cssfiles', array()); |
199 | 199 | $this->assign('printcssfiles', []); |
200 | 200 | $this->assign('versionHash', self::$versionHash); |
201 | - foreach($cssFiles as $info) { |
|
201 | + foreach ($cssFiles as $info) { |
|
202 | 202 | $web = $info[1]; |
203 | 203 | $file = $info[2]; |
204 | 204 | |
205 | 205 | if (substr($file, -strlen('print.css')) === 'print.css') { |
206 | - $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
206 | + $this->append('printcssfiles', $web.'/'.$file.$this->getVersionHashSuffix()); |
|
207 | 207 | } else { |
208 | - $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file) ); |
|
208 | + $this->append('cssfiles', $web.'/'.$file.$this->getVersionHashSuffix($web, $file)); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | |
226 | 226 | if ($this->config->getSystemValue('installed', false)) { |
227 | 227 | if (\OC::$server->getAppManager()->isInstalled('theming')) { |
228 | - $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
228 | + $themingSuffix = '-'.$this->config->getAppValue('theming', 'cachebuster', '0'); |
|
229 | 229 | } |
230 | 230 | $v = \OC_App::getAppVersions(); |
231 | 231 | } |
@@ -233,21 +233,21 @@ discard block |
||
233 | 233 | // Try the webroot path for a match |
234 | 234 | if ($path !== false && $path !== '') { |
235 | 235 | $appName = $this->getAppNamefromPath($path); |
236 | - if(array_key_exists($appName, $v)) { |
|
236 | + if (array_key_exists($appName, $v)) { |
|
237 | 237 | $appVersion = $v[$appName]; |
238 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
238 | + return '?v='.substr(md5($appVersion), 0, 8).$themingSuffix; |
|
239 | 239 | } |
240 | 240 | } |
241 | 241 | // fallback to the file path instead |
242 | 242 | if ($file !== false && $file !== '') { |
243 | 243 | $appName = $this->getAppNamefromPath($file); |
244 | - if(array_key_exists($appName, $v)) { |
|
244 | + if (array_key_exists($appName, $v)) { |
|
245 | 245 | $appVersion = $v[$appName]; |
246 | - return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix; |
|
246 | + return '?v='.substr(md5($appVersion), 0, 8).$themingSuffix; |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | |
250 | - return '?v=' . self::$versionHash . $themingSuffix; |
|
250 | + return '?v='.self::$versionHash.$themingSuffix; |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | // Read the selected theme from the config file |
259 | 259 | $theme = \OC_Util::getTheme(); |
260 | 260 | |
261 | - if($compileScss) { |
|
261 | + if ($compileScss) { |
|
262 | 262 | $SCSSCacher = \OC::$server->query(SCSSCacher::class); |
263 | 263 | } else { |
264 | 264 | $SCSSCacher = null; |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | $locator = new \OC\Template\CSSResourceLocator( |
268 | 268 | \OC::$server->getLogger(), |
269 | 269 | $theme, |
270 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
271 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
270 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
271 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
272 | 272 | $SCSSCacher |
273 | 273 | ); |
274 | 274 | $locator->find($styles); |
@@ -303,8 +303,8 @@ discard block |
||
303 | 303 | $locator = new \OC\Template\JSResourceLocator( |
304 | 304 | \OC::$server->getLogger(), |
305 | 305 | $theme, |
306 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
307 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
306 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
307 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
308 | 308 | new JSCombiner( |
309 | 309 | \OC::$server->getAppDataDir('js'), |
310 | 310 | \OC::$server->getURLGenerator(), |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | */ |
326 | 326 | public static function convertToRelativePath($filePath) { |
327 | 327 | $relativePath = explode(\OC::$SERVERROOT, $filePath); |
328 | - if(count($relativePath) !== 2) { |
|
328 | + if (count($relativePath) !== 2) { |
|
329 | 329 | throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
330 | 330 | } |
331 | 331 |
@@ -33,142 +33,142 @@ |
||
33 | 33 | */ |
34 | 34 | class SimpleMenuAction implements IMenuAction { |
35 | 35 | |
36 | - /** @var string */ |
|
37 | - private $id; |
|
38 | - |
|
39 | - /** @var string */ |
|
40 | - private $label; |
|
41 | - |
|
42 | - /** @var string */ |
|
43 | - private $icon; |
|
44 | - |
|
45 | - /** @var string */ |
|
46 | - private $link; |
|
47 | - |
|
48 | - /** @var int */ |
|
49 | - private $priority; |
|
50 | - |
|
51 | - /** @var string */ |
|
52 | - private $detail; |
|
53 | - |
|
54 | - /** |
|
55 | - * SimpleMenuAction constructor. |
|
56 | - * |
|
57 | - * @param string $id |
|
58 | - * @param string $label |
|
59 | - * @param string $icon |
|
60 | - * @param string $link |
|
61 | - * @param int $priority |
|
62 | - * @param string $detail |
|
63 | - * @since 14.0.0 |
|
64 | - */ |
|
65 | - public function __construct(string $id, string $label, string $icon, string $link = '', int $priority = 100, string $detail = '') { |
|
66 | - $this->id = $id; |
|
67 | - $this->label = $label; |
|
68 | - $this->icon = $icon; |
|
69 | - $this->link = $link; |
|
70 | - $this->priority = $priority; |
|
71 | - $this->detail = $detail; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * @param string $id |
|
76 | - * @since 14.0.0 |
|
77 | - */ |
|
78 | - public function setId(string $id) { |
|
79 | - $this->id = $id; |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * @param string $label |
|
84 | - * @since 14.0.0 |
|
85 | - */ |
|
86 | - public function setLabel(string $label) { |
|
87 | - $this->label = $label; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * @param string $detail |
|
92 | - * @since 14.0.0 |
|
93 | - */ |
|
94 | - public function setDetail(string $detail) { |
|
95 | - $this->detail = $detail; |
|
96 | - } |
|
97 | - |
|
98 | - /** |
|
99 | - * @param string $icon |
|
100 | - * @since 14.0.0 |
|
101 | - */ |
|
102 | - public function setIcon(string $icon) { |
|
103 | - $this->icon = $icon; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * @param string $link |
|
108 | - * @since 14.0.0 |
|
109 | - */ |
|
110 | - public function setLink(string $link) { |
|
111 | - $this->link = $link; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * @param int $priority |
|
116 | - * @since 14.0.0 |
|
117 | - */ |
|
118 | - public function setPriority(int $priority) { |
|
119 | - $this->priority = $priority; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @return string |
|
124 | - * @since 14.0.0 |
|
125 | - */ |
|
126 | - public function getId(): string { |
|
127 | - return $this->id; |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @return string |
|
132 | - * @since 14.0.0 |
|
133 | - */ |
|
134 | - public function getLabel(): string { |
|
135 | - return $this->label; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * @return string |
|
140 | - * @since 14.0.0 |
|
141 | - */ |
|
142 | - public function getIcon(): string { |
|
143 | - return $this->icon; |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @return string |
|
148 | - * @since 14.0.0 |
|
149 | - */ |
|
150 | - public function getLink(): string { |
|
151 | - return $this->link; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * @return int |
|
156 | - * @since 14.0.0 |
|
157 | - */ |
|
158 | - public function getPriority(): int { |
|
159 | - return $this->priority; |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * @return string |
|
164 | - * @since 14.0.0 |
|
165 | - */ |
|
166 | - public function render(): string { |
|
167 | - $detailContent = ($this->detail !== '') ? ' <span class="download-size">(' . Util::sanitizeHTML($this->detail) . ')</span>' : ''; |
|
168 | - return sprintf( |
|
169 | - '<li><a href="%s"><span class="icon %s"></span>%s %s</a></li>', |
|
170 | - Util::sanitizeHTML($this->link), Util::sanitizeHTML($this->icon), Util::sanitizeHTML($this->label), Util::sanitizeHTML($detailContent) |
|
171 | - ); |
|
172 | - } |
|
36 | + /** @var string */ |
|
37 | + private $id; |
|
38 | + |
|
39 | + /** @var string */ |
|
40 | + private $label; |
|
41 | + |
|
42 | + /** @var string */ |
|
43 | + private $icon; |
|
44 | + |
|
45 | + /** @var string */ |
|
46 | + private $link; |
|
47 | + |
|
48 | + /** @var int */ |
|
49 | + private $priority; |
|
50 | + |
|
51 | + /** @var string */ |
|
52 | + private $detail; |
|
53 | + |
|
54 | + /** |
|
55 | + * SimpleMenuAction constructor. |
|
56 | + * |
|
57 | + * @param string $id |
|
58 | + * @param string $label |
|
59 | + * @param string $icon |
|
60 | + * @param string $link |
|
61 | + * @param int $priority |
|
62 | + * @param string $detail |
|
63 | + * @since 14.0.0 |
|
64 | + */ |
|
65 | + public function __construct(string $id, string $label, string $icon, string $link = '', int $priority = 100, string $detail = '') { |
|
66 | + $this->id = $id; |
|
67 | + $this->label = $label; |
|
68 | + $this->icon = $icon; |
|
69 | + $this->link = $link; |
|
70 | + $this->priority = $priority; |
|
71 | + $this->detail = $detail; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * @param string $id |
|
76 | + * @since 14.0.0 |
|
77 | + */ |
|
78 | + public function setId(string $id) { |
|
79 | + $this->id = $id; |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * @param string $label |
|
84 | + * @since 14.0.0 |
|
85 | + */ |
|
86 | + public function setLabel(string $label) { |
|
87 | + $this->label = $label; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * @param string $detail |
|
92 | + * @since 14.0.0 |
|
93 | + */ |
|
94 | + public function setDetail(string $detail) { |
|
95 | + $this->detail = $detail; |
|
96 | + } |
|
97 | + |
|
98 | + /** |
|
99 | + * @param string $icon |
|
100 | + * @since 14.0.0 |
|
101 | + */ |
|
102 | + public function setIcon(string $icon) { |
|
103 | + $this->icon = $icon; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * @param string $link |
|
108 | + * @since 14.0.0 |
|
109 | + */ |
|
110 | + public function setLink(string $link) { |
|
111 | + $this->link = $link; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * @param int $priority |
|
116 | + * @since 14.0.0 |
|
117 | + */ |
|
118 | + public function setPriority(int $priority) { |
|
119 | + $this->priority = $priority; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * @return string |
|
124 | + * @since 14.0.0 |
|
125 | + */ |
|
126 | + public function getId(): string { |
|
127 | + return $this->id; |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @return string |
|
132 | + * @since 14.0.0 |
|
133 | + */ |
|
134 | + public function getLabel(): string { |
|
135 | + return $this->label; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * @return string |
|
140 | + * @since 14.0.0 |
|
141 | + */ |
|
142 | + public function getIcon(): string { |
|
143 | + return $this->icon; |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @return string |
|
148 | + * @since 14.0.0 |
|
149 | + */ |
|
150 | + public function getLink(): string { |
|
151 | + return $this->link; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * @return int |
|
156 | + * @since 14.0.0 |
|
157 | + */ |
|
158 | + public function getPriority(): int { |
|
159 | + return $this->priority; |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * @return string |
|
164 | + * @since 14.0.0 |
|
165 | + */ |
|
166 | + public function render(): string { |
|
167 | + $detailContent = ($this->detail !== '') ? ' <span class="download-size">(' . Util::sanitizeHTML($this->detail) . ')</span>' : ''; |
|
168 | + return sprintf( |
|
169 | + '<li><a href="%s"><span class="icon %s"></span>%s %s</a></li>', |
|
170 | + Util::sanitizeHTML($this->link), Util::sanitizeHTML($this->icon), Util::sanitizeHTML($this->label), Util::sanitizeHTML($detailContent) |
|
171 | + ); |
|
172 | + } |
|
173 | 173 | |
174 | 174 | } |
175 | 175 | \ No newline at end of file |
@@ -164,7 +164,7 @@ |
||
164 | 164 | * @since 14.0.0 |
165 | 165 | */ |
166 | 166 | public function render(): string { |
167 | - $detailContent = ($this->detail !== '') ? ' <span class="download-size">(' . Util::sanitizeHTML($this->detail) . ')</span>' : ''; |
|
167 | + $detailContent = ($this->detail !== '') ? ' <span class="download-size">('.Util::sanitizeHTML($this->detail).')</span>' : ''; |
|
168 | 168 | return sprintf( |
169 | 169 | '<li><a href="%s"><span class="icon %s"></span>%s %s</a></li>', |
170 | 170 | Util::sanitizeHTML($this->link), Util::sanitizeHTML($this->icon), Util::sanitizeHTML($this->label), Util::sanitizeHTML($detailContent) |