Passed
Push — master ( 62b4f9...011aab )
by Roeland
12:11
created
settings/templates/settings/personal/personal.info.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 /** @var array $_ */
27 27
 
28 28
 script('settings', [
29
-	'usersettings',
30
-	'templates',
31
-	'federationsettingsview',
32
-	'federationscopemenu',
33
-	'settings/personalInfo',
29
+    'usersettings',
30
+    'templates',
31
+    'federationsettingsview',
32
+    'federationscopemenu',
33
+    'settings/personalInfo',
34 34
 ]);
35 35
 ?>
36 36
 
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
 					<p class="quotatext">
86 86
 						<?php if ($_['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED): ?>
87 87
 							<?php print_unescaped($l->t('You are using <strong>%s</strong>',
88
-								[$_['usage']]));?>
88
+                                [$_['usage']]));?>
89 89
 						<?php else: ?>
90 90
 							<?php print_unescaped($l->t('You are using <strong>%1$s</strong> of <strong>%2$s</strong> (<strong>%3$s %%</strong>)',
91
-								[$_['usage'], $_['total_space'],  $_['usage_relative']]));?>
91
+                                [$_['usage'], $_['total_space'],  $_['usage_relative']]));?>
92 92
 						<?php endif ?>
93 93
 					</p>
94 94
 				</div>
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
 				<div class="verify <?php if ($_['email'] === ''  || $_['emailScope'] !== 'public') p('hidden'); ?>">
136 136
 					<img id="verify-email" title="<?php p($_['emailMessage']); ?>" data-status="<?php p($_['emailVerification']) ?>" src="
137 137
 				<?php
138
-					switch($_['emailVerification']) {
139
-						case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
140
-							p(image_path('core', 'actions/verifying.svg'));
141
-							break;
142
-						case \OC\Accounts\AccountManager::VERIFIED:
143
-							p(image_path('core', 'actions/verified.svg'));
144
-							break;
145
-						default:
146
-							p(image_path('core', 'actions/verify.svg'));
147
-					}
148
-					?>">
138
+                    switch($_['emailVerification']) {
139
+                        case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
140
+                            p(image_path('core', 'actions/verifying.svg'));
141
+                            break;
142
+                        case \OC\Accounts\AccountManager::VERIFIED:
143
+                            p(image_path('core', 'actions/verified.svg'));
144
+                            break;
145
+                        default:
146
+                            p(image_path('core', 'actions/verify.svg'));
147
+                    }
148
+                    ?>">
149 149
 				</div>
150 150
 				<input type="email" name="email" id="email" value="<?php p($_['email']); ?>"
151 151
 					<?php if(!$_['displayNameChangeSupported']) { print_unescaped('class="hidden"'); } ?>
@@ -223,17 +223,17 @@  discard block
 block discarded – undo
223 223
 				<div class="verify <?php if ($_['website'] === ''  || $_['websiteScope'] !== 'public') p('hidden'); ?>">
224 224
 					<img id="verify-website" title="<?php p($_['websiteMessage']); ?>" data-status="<?php p($_['websiteVerification']) ?>" src="
225 225
 					<?php
226
-					switch($_['websiteVerification']) {
227
-						case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
228
-							p(image_path('core', 'actions/verifying.svg'));
229
-							break;
230
-						case \OC\Accounts\AccountManager::VERIFIED:
231
-							p(image_path('core', 'actions/verified.svg'));
232
-							break;
233
-						default:
234
-							p(image_path('core', 'actions/verify.svg'));
235
-					}
236
-					?>"
226
+                    switch($_['websiteVerification']) {
227
+                        case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
228
+                            p(image_path('core', 'actions/verifying.svg'));
229
+                            break;
230
+                        case \OC\Accounts\AccountManager::VERIFIED:
231
+                            p(image_path('core', 'actions/verified.svg'));
232
+                            break;
233
+                        default:
234
+                            p(image_path('core', 'actions/verify.svg'));
235
+                    }
236
+                    ?>"
237 237
 					<?php if($_['websiteVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['websiteVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?>
238 238
 					>
239 239
 					<div class="verification-dialog popovermenu bubble menu">
@@ -272,17 +272,17 @@  discard block
 block discarded – undo
272 272
 				<div class="verify <?php if ($_['twitter'] === ''  || $_['twitterScope'] !== 'public') p('hidden'); ?>">
273 273
 					<img id="verify-twitter" title="<?php p($_['twitterMessage']); ?>" data-status="<?php p($_['twitterVerification']) ?>" src="
274 274
 					<?php
275
-					switch($_['twitterVerification']) {
276
-						case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
277
-							p(image_path('core', 'actions/verifying.svg'));
278
-							break;
279
-						case \OC\Accounts\AccountManager::VERIFIED:
280
-							p(image_path('core', 'actions/verified.svg'));
281
-							break;
282
-						default:
283
-							p(image_path('core', 'actions/verify.svg'));
284
-					}
285
-					?>"
275
+                    switch($_['twitterVerification']) {
276
+                        case \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS:
277
+                            p(image_path('core', 'actions/verifying.svg'));
278
+                            break;
279
+                        case \OC\Accounts\AccountManager::VERIFIED:
280
+                            p(image_path('core', 'actions/verified.svg'));
281
+                            break;
282
+                        default:
283
+                            p(image_path('core', 'actions/verify.svg'));
284
+                    }
285
+                    ?>"
286 286
 					<?php if($_['twitterVerification'] === \OC\Accounts\AccountManager::VERIFICATION_IN_PROGRESS || $_['twitterVerification'] === \OC\Accounts\AccountManager::NOT_VERIFIED) print_unescaped(' class="verify-action"') ?>
287 287
 					>
288 288
 					<div class="verification-dialog popovermenu bubble menu">
Please login to merge, or discard this patch.
settings/templates/settings/personal/security.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -22,16 +22,16 @@  discard block
 block discarded – undo
22 22
  */
23 23
 
24 24
 script('settings', [
25
-	'authtoken',
26
-	'authtoken_collection',
27
-	'templates',
28
-	'authtoken_view',
29
-	'settings/authtoken-init'
25
+    'authtoken',
26
+    'authtoken_collection',
27
+    'templates',
28
+    'authtoken_view',
29
+    'settings/authtoken-init'
30 30
 ]);
31 31
 
32 32
 if($_['passwordChangeSupported']) {
33
-	script('settings', 'security_password');
34
-	script('jquery-showpassword');
33
+    script('settings', 'security_password');
34
+    script('jquery-showpassword');
35 35
 }
36 36
 
37 37
 ?>
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
 	<?php foreach ($_['twoFactorProviderData']['providers'] as $data) { ?>
107 107
 		<li>
108 108
 			<?php
109
-			/** @var \OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings $provider */
110
-			$provider = $data['provider'];
111
-			if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) {
112
-				$icon = $provider->getDarkIcon();
113
-			} else {
114
-				$icon = image_path('core', 'actions/password.svg');
115
-			}
116
-			/** @var \OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings $settings */
117
-			$settings = $data['settings'];
118
-			?>
109
+            /** @var \OCP\Authentication\TwoFactorAuth\IProvidesPersonalSettings $provider */
110
+            $provider = $data['provider'];
111
+            if ($provider instanceof \OCP\Authentication\TwoFactorAuth\IProvidesIcons) {
112
+                $icon = $provider->getDarkIcon();
113
+            } else {
114
+                $icon = image_path('core', 'actions/password.svg');
115
+            }
116
+            /** @var \OCP\Authentication\TwoFactorAuth\IPersonalProviderSettings $settings */
117
+            $settings = $data['settings'];
118
+            ?>
119 119
 			<h3>
120 120
 				<img class="two-factor-provider-settings-icon" src="<?php p($icon) ?>" alt="">
121 121
 				<?php p($provider->getDisplayName()) ?>
Please login to merge, or discard this patch.
lib/private/legacy/template.php 1 patch
Indentation   +314 added lines, -314 removed lines patch added patch discarded remove patch
@@ -46,318 +46,318 @@
 block discarded – undo
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('css-variables', null, true);
113
-			OC_Util::addStyle('server', null, true);
114
-			OC_Util::addStyle('jquery-ui-fixes',null,true);
115
-			OC_Util::addStyle('jquery.ocdialog');
116
-			OC_Util::addTranslations("core", null, true);
117
-			OC_Util::addStyle('search', 'results');
118
-			OC_Util::addScript('search', 'search', true);
119
-			OC_Util::addScript('search', 'searchprovider');
120
-			OC_Util::addScript('merged-template-prepend', null, true);
121
-			OC_Util::addScript('jquery-ui-fixes');
122
-			OC_Util::addScript('files/fileinfo');
123
-			OC_Util::addScript('files/client');
124
-			OC_Util::addScript('contactsmenu');
125
-			OC_Util::addScript('contactsmenu_templates');
126
-			OC_Util::addScript('core', 'dist/main', true);
127
-
128
-			if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) {
129
-				// shim for the davclient.js library
130
-				\OCP\Util::addScript('files/iedavclient');
131
-			}
132
-
133
-			self::$initTemplateEngineFirstRun = false;
134
-		}
135
-
136
-	}
137
-
138
-
139
-	/**
140
-	 * find the template with the given name
141
-	 * @param string $name of the template file (without suffix)
142
-	 *
143
-	 * Will select the template file for the selected theme.
144
-	 * Checking all the possible locations.
145
-	 * @param string $theme
146
-	 * @param string $app
147
-	 * @return string[]
148
-	 */
149
-	protected function findTemplate($theme, $app, $name) {
150
-		// Check if it is a app template or not.
151
-		if( $app !== '' ) {
152
-			$dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app));
153
-		} else {
154
-			$dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT);
155
-		}
156
-		$locator = new \OC\Template\TemplateFileLocator( $dirs );
157
-		$template = $locator->find($name);
158
-		$path = $locator->getPath();
159
-		return array($path, $template);
160
-	}
161
-
162
-	/**
163
-	 * Add a custom element to the header
164
-	 * @param string $tag tag name of the element
165
-	 * @param array $attributes array of attributes for the element
166
-	 * @param string $text the text content for the element. If $text is null then the
167
-	 * element will be written as empty element. So use "" to get a closing tag.
168
-	 */
169
-	public function addHeader($tag, $attributes, $text=null) {
170
-		$this->headers[]= array(
171
-			'tag' => $tag,
172
-			'attributes' => $attributes,
173
-			'text' => $text
174
-		);
175
-	}
176
-
177
-	/**
178
-	 * Process the template
179
-	 * @return boolean|string
180
-	 *
181
-	 * This function process the template. If $this->renderAs is set, it
182
-	 * will produce a full page.
183
-	 */
184
-	public function fetchPage($additionalParams = null) {
185
-		$data = parent::fetchPage($additionalParams);
186
-
187
-		if( $this->renderAs ) {
188
-			$page = new TemplateLayout($this->renderAs, $this->app);
189
-
190
-			if(is_array($additionalParams)) {
191
-				foreach ($additionalParams as $key => $value) {
192
-					$page->assign($key, $value);
193
-				}
194
-			}
195
-
196
-			// Add custom headers
197
-			$headers = '';
198
-			foreach(OC_Util::$headers as $header) {
199
-				$headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']);
200
-				if ( strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes']))) ) {
201
-					$headers .= ' defer';
202
-				}
203
-				foreach($header['attributes'] as $name=>$value) {
204
-					$headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"';
205
-				}
206
-				if ($header['text'] !== null) {
207
-					$headers .= '>'.\OCP\Util::sanitizeHTML($header['text']).'</'.\OCP\Util::sanitizeHTML($header['tag']).'>';
208
-				} else {
209
-					$headers .= '/>';
210
-				}
211
-			}
212
-
213
-			$page->assign('headers', $headers);
214
-
215
-			$page->assign('content', $data);
216
-			return $page->fetchPage($additionalParams);
217
-		}
218
-
219
-		return $data;
220
-	}
221
-
222
-	/**
223
-	 * Include template
224
-	 *
225
-	 * @param string $file
226
-	 * @param array|null $additionalParams
227
-	 * @return string returns content of included template
228
-	 *
229
-	 * Includes another template. use <?php echo $this->inc('template'); ?> to
230
-	 * do this.
231
-	 */
232
-	public function inc( $file, $additionalParams = null ) {
233
-		return $this->load($this->path.$file.'.php', $additionalParams);
234
-	}
235
-
236
-	/**
237
-	 * Shortcut to print a simple page for users
238
-	 * @param string $application The application we render the template for
239
-	 * @param string $name Name of the template
240
-	 * @param array $parameters Parameters for the template
241
-	 * @return boolean|null
242
-	 */
243
-	public static function printUserPage( $application, $name, $parameters = array() ) {
244
-		$content = new OC_Template( $application, $name, "user" );
245
-		foreach( $parameters as $key => $value ) {
246
-			$content->assign( $key, $value );
247
-		}
248
-		print $content->printPage();
249
-	}
250
-
251
-	/**
252
-	 * Shortcut to print a simple page for admins
253
-	 * @param string $application The application we render the template for
254
-	 * @param string $name Name of the template
255
-	 * @param array $parameters Parameters for the template
256
-	 * @return bool
257
-	 */
258
-	public static function printAdminPage( $application, $name, $parameters = array() ) {
259
-		$content = new OC_Template( $application, $name, "admin" );
260
-		foreach( $parameters as $key => $value ) {
261
-			$content->assign( $key, $value );
262
-		}
263
-		return $content->printPage();
264
-	}
265
-
266
-	/**
267
-	 * Shortcut to print a simple page for guests
268
-	 * @param string $application The application we render the template for
269
-	 * @param string $name Name of the template
270
-	 * @param array|string $parameters Parameters for the template
271
-	 * @return bool
272
-	 */
273
-	public static function printGuestPage( $application, $name, $parameters = array() ) {
274
-		$content = new OC_Template( $application, $name, "guest" );
275
-		foreach( $parameters as $key => $value ) {
276
-			$content->assign( $key, $value );
277
-		}
278
-		return $content->printPage();
279
-	}
280
-
281
-	/**
282
-	 * Print a fatal error page and terminates the script
283
-	 * @param string $error_msg The error message to show
284
-	 * @param string $hint An optional hint message - needs to be properly escape
285
-	 * @param int $statusCode
286
-	 * @suppress PhanAccessMethodInternal
287
-	 */
288
-	public static function printErrorPage( $error_msg, $hint = '', $statusCode = 500) {
289
-		if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) {
290
-			\OC_App::loadApp('theming');
291
-		}
292
-
293
-
294
-		if ($error_msg === $hint) {
295
-			// If the hint is the same as the message there is no need to display it twice.
296
-			$hint = '';
297
-		}
298
-
299
-		http_response_code($statusCode);
300
-		try {
301
-			$content = new \OC_Template( '', 'error', 'error', false );
302
-			$errors = array(array('error' => $error_msg, 'hint' => $hint));
303
-			$content->assign( 'errors', $errors );
304
-			$content->printPage();
305
-		} catch (\Exception $e) {
306
-			$logger = \OC::$server->getLogger();
307
-			$logger->error("$error_msg $hint", ['app' => 'core']);
308
-			$logger->logException($e, ['app' => 'core']);
309
-
310
-			header('Content-Type: text/plain; charset=utf-8');
311
-			print("$error_msg $hint");
312
-		}
313
-		die();
314
-	}
315
-
316
-	/**
317
-	 * print error page using Exception details
318
-	 * @param Exception|Throwable $exception
319
-	 * @param int $statusCode
320
-	 * @return bool|string
321
-	 * @suppress PhanAccessMethodInternal
322
-	 */
323
-	public static function printExceptionErrorPage($exception, $statusCode = 503) {
324
-		http_response_code($statusCode);
325
-		try {
326
-			$request = \OC::$server->getRequest();
327
-			$content = new \OC_Template('', 'exception', 'error', false);
328
-			$content->assign('errorClass', get_class($exception));
329
-			$content->assign('errorMsg', $exception->getMessage());
330
-			$content->assign('errorCode', $exception->getCode());
331
-			$content->assign('file', $exception->getFile());
332
-			$content->assign('line', $exception->getLine());
333
-			$content->assign('trace', $exception->getTraceAsString());
334
-			$content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false));
335
-			$content->assign('remoteAddr', $request->getRemoteAddress());
336
-			$content->assign('requestID', $request->getId());
337
-			$content->printPage();
338
-		} catch (\Exception $e) {
339
-			try {
340
-				$logger = \OC::$server->getLogger();
341
-				$logger->logException($exception, ['app' => 'core']);
342
-				$logger->logException($e, ['app' => 'core']);
343
-			} catch (Throwable $e) {
344
-				// no way to log it properly - but to avoid a white page of death we send some output
345
-				header('Content-Type: text/plain; charset=utf-8');
346
-				print("Internal Server Error\n\n");
347
-				print("The server encountered an internal error and was unable to complete your request.\n");
348
-				print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n");
349
-				print("More details can be found in the server log.\n");
350
-
351
-				// and then throw it again to log it at least to the web server error log
352
-				throw $e;
353
-			}
354
-
355
-			header('Content-Type: text/plain; charset=utf-8');
356
-			print("Internal Server Error\n\n");
357
-			print("The server encountered an internal error and was unable to complete your request.\n");
358
-			print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n");
359
-			print("More details can be found in the server log.\n");
360
-		}
361
-		die();
362
-	}
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('css-variables', null, true);
113
+            OC_Util::addStyle('server', null, true);
114
+            OC_Util::addStyle('jquery-ui-fixes',null,true);
115
+            OC_Util::addStyle('jquery.ocdialog');
116
+            OC_Util::addTranslations("core", null, true);
117
+            OC_Util::addStyle('search', 'results');
118
+            OC_Util::addScript('search', 'search', true);
119
+            OC_Util::addScript('search', 'searchprovider');
120
+            OC_Util::addScript('merged-template-prepend', null, true);
121
+            OC_Util::addScript('jquery-ui-fixes');
122
+            OC_Util::addScript('files/fileinfo');
123
+            OC_Util::addScript('files/client');
124
+            OC_Util::addScript('contactsmenu');
125
+            OC_Util::addScript('contactsmenu_templates');
126
+            OC_Util::addScript('core', 'dist/main', true);
127
+
128
+            if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) {
129
+                // shim for the davclient.js library
130
+                \OCP\Util::addScript('files/iedavclient');
131
+            }
132
+
133
+            self::$initTemplateEngineFirstRun = false;
134
+        }
135
+
136
+    }
137
+
138
+
139
+    /**
140
+     * find the template with the given name
141
+     * @param string $name of the template file (without suffix)
142
+     *
143
+     * Will select the template file for the selected theme.
144
+     * Checking all the possible locations.
145
+     * @param string $theme
146
+     * @param string $app
147
+     * @return string[]
148
+     */
149
+    protected function findTemplate($theme, $app, $name) {
150
+        // Check if it is a app template or not.
151
+        if( $app !== '' ) {
152
+            $dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app));
153
+        } else {
154
+            $dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT);
155
+        }
156
+        $locator = new \OC\Template\TemplateFileLocator( $dirs );
157
+        $template = $locator->find($name);
158
+        $path = $locator->getPath();
159
+        return array($path, $template);
160
+    }
161
+
162
+    /**
163
+     * Add a custom element to the header
164
+     * @param string $tag tag name of the element
165
+     * @param array $attributes array of attributes for the element
166
+     * @param string $text the text content for the element. If $text is null then the
167
+     * element will be written as empty element. So use "" to get a closing tag.
168
+     */
169
+    public function addHeader($tag, $attributes, $text=null) {
170
+        $this->headers[]= array(
171
+            'tag' => $tag,
172
+            'attributes' => $attributes,
173
+            'text' => $text
174
+        );
175
+    }
176
+
177
+    /**
178
+     * Process the template
179
+     * @return boolean|string
180
+     *
181
+     * This function process the template. If $this->renderAs is set, it
182
+     * will produce a full page.
183
+     */
184
+    public function fetchPage($additionalParams = null) {
185
+        $data = parent::fetchPage($additionalParams);
186
+
187
+        if( $this->renderAs ) {
188
+            $page = new TemplateLayout($this->renderAs, $this->app);
189
+
190
+            if(is_array($additionalParams)) {
191
+                foreach ($additionalParams as $key => $value) {
192
+                    $page->assign($key, $value);
193
+                }
194
+            }
195
+
196
+            // Add custom headers
197
+            $headers = '';
198
+            foreach(OC_Util::$headers as $header) {
199
+                $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']);
200
+                if ( strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes']))) ) {
201
+                    $headers .= ' defer';
202
+                }
203
+                foreach($header['attributes'] as $name=>$value) {
204
+                    $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"';
205
+                }
206
+                if ($header['text'] !== null) {
207
+                    $headers .= '>'.\OCP\Util::sanitizeHTML($header['text']).'</'.\OCP\Util::sanitizeHTML($header['tag']).'>';
208
+                } else {
209
+                    $headers .= '/>';
210
+                }
211
+            }
212
+
213
+            $page->assign('headers', $headers);
214
+
215
+            $page->assign('content', $data);
216
+            return $page->fetchPage($additionalParams);
217
+        }
218
+
219
+        return $data;
220
+    }
221
+
222
+    /**
223
+     * Include template
224
+     *
225
+     * @param string $file
226
+     * @param array|null $additionalParams
227
+     * @return string returns content of included template
228
+     *
229
+     * Includes another template. use <?php echo $this->inc('template'); ?> to
230
+     * do this.
231
+     */
232
+    public function inc( $file, $additionalParams = null ) {
233
+        return $this->load($this->path.$file.'.php', $additionalParams);
234
+    }
235
+
236
+    /**
237
+     * Shortcut to print a simple page for users
238
+     * @param string $application The application we render the template for
239
+     * @param string $name Name of the template
240
+     * @param array $parameters Parameters for the template
241
+     * @return boolean|null
242
+     */
243
+    public static function printUserPage( $application, $name, $parameters = array() ) {
244
+        $content = new OC_Template( $application, $name, "user" );
245
+        foreach( $parameters as $key => $value ) {
246
+            $content->assign( $key, $value );
247
+        }
248
+        print $content->printPage();
249
+    }
250
+
251
+    /**
252
+     * Shortcut to print a simple page for admins
253
+     * @param string $application The application we render the template for
254
+     * @param string $name Name of the template
255
+     * @param array $parameters Parameters for the template
256
+     * @return bool
257
+     */
258
+    public static function printAdminPage( $application, $name, $parameters = array() ) {
259
+        $content = new OC_Template( $application, $name, "admin" );
260
+        foreach( $parameters as $key => $value ) {
261
+            $content->assign( $key, $value );
262
+        }
263
+        return $content->printPage();
264
+    }
265
+
266
+    /**
267
+     * Shortcut to print a simple page for guests
268
+     * @param string $application The application we render the template for
269
+     * @param string $name Name of the template
270
+     * @param array|string $parameters Parameters for the template
271
+     * @return bool
272
+     */
273
+    public static function printGuestPage( $application, $name, $parameters = array() ) {
274
+        $content = new OC_Template( $application, $name, "guest" );
275
+        foreach( $parameters as $key => $value ) {
276
+            $content->assign( $key, $value );
277
+        }
278
+        return $content->printPage();
279
+    }
280
+
281
+    /**
282
+     * Print a fatal error page and terminates the script
283
+     * @param string $error_msg The error message to show
284
+     * @param string $hint An optional hint message - needs to be properly escape
285
+     * @param int $statusCode
286
+     * @suppress PhanAccessMethodInternal
287
+     */
288
+    public static function printErrorPage( $error_msg, $hint = '', $statusCode = 500) {
289
+        if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) {
290
+            \OC_App::loadApp('theming');
291
+        }
292
+
293
+
294
+        if ($error_msg === $hint) {
295
+            // If the hint is the same as the message there is no need to display it twice.
296
+            $hint = '';
297
+        }
298
+
299
+        http_response_code($statusCode);
300
+        try {
301
+            $content = new \OC_Template( '', 'error', 'error', false );
302
+            $errors = array(array('error' => $error_msg, 'hint' => $hint));
303
+            $content->assign( 'errors', $errors );
304
+            $content->printPage();
305
+        } catch (\Exception $e) {
306
+            $logger = \OC::$server->getLogger();
307
+            $logger->error("$error_msg $hint", ['app' => 'core']);
308
+            $logger->logException($e, ['app' => 'core']);
309
+
310
+            header('Content-Type: text/plain; charset=utf-8');
311
+            print("$error_msg $hint");
312
+        }
313
+        die();
314
+    }
315
+
316
+    /**
317
+     * print error page using Exception details
318
+     * @param Exception|Throwable $exception
319
+     * @param int $statusCode
320
+     * @return bool|string
321
+     * @suppress PhanAccessMethodInternal
322
+     */
323
+    public static function printExceptionErrorPage($exception, $statusCode = 503) {
324
+        http_response_code($statusCode);
325
+        try {
326
+            $request = \OC::$server->getRequest();
327
+            $content = new \OC_Template('', 'exception', 'error', false);
328
+            $content->assign('errorClass', get_class($exception));
329
+            $content->assign('errorMsg', $exception->getMessage());
330
+            $content->assign('errorCode', $exception->getCode());
331
+            $content->assign('file', $exception->getFile());
332
+            $content->assign('line', $exception->getLine());
333
+            $content->assign('trace', $exception->getTraceAsString());
334
+            $content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false));
335
+            $content->assign('remoteAddr', $request->getRemoteAddress());
336
+            $content->assign('requestID', $request->getId());
337
+            $content->printPage();
338
+        } catch (\Exception $e) {
339
+            try {
340
+                $logger = \OC::$server->getLogger();
341
+                $logger->logException($exception, ['app' => 'core']);
342
+                $logger->logException($e, ['app' => 'core']);
343
+            } catch (Throwable $e) {
344
+                // no way to log it properly - but to avoid a white page of death we send some output
345
+                header('Content-Type: text/plain; charset=utf-8');
346
+                print("Internal Server Error\n\n");
347
+                print("The server encountered an internal error and was unable to complete your request.\n");
348
+                print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n");
349
+                print("More details can be found in the server log.\n");
350
+
351
+                // and then throw it again to log it at least to the web server error log
352
+                throw $e;
353
+            }
354
+
355
+            header('Content-Type: text/plain; charset=utf-8');
356
+            print("Internal Server Error\n\n");
357
+            print("The server encountered an internal error and was unable to complete your request.\n");
358
+            print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n");
359
+            print("More details can be found in the server log.\n");
360
+        }
361
+        die();
362
+    }
363 363
 }
Please login to merge, or discard this patch.
core/Controller/SetupController.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -33,95 +33,95 @@
 block discarded – undo
33 33
 use OCP\ILogger;
34 34
 
35 35
 class SetupController {
36
-	/** @var Setup */
37
-	protected $setupHelper;
38
-	/** @var string */
39
-	private $autoConfigFile;
36
+    /** @var Setup */
37
+    protected $setupHelper;
38
+    /** @var string */
39
+    private $autoConfigFile;
40 40
 
41
-	/**
42
-	 * @param Setup $setupHelper
43
-	 */
44
-	function __construct(Setup $setupHelper) {
45
-		$this->autoConfigFile = \OC::$configDir.'autoconfig.php';
46
-		$this->setupHelper = $setupHelper;
47
-	}
41
+    /**
42
+     * @param Setup $setupHelper
43
+     */
44
+    function __construct(Setup $setupHelper) {
45
+        $this->autoConfigFile = \OC::$configDir.'autoconfig.php';
46
+        $this->setupHelper = $setupHelper;
47
+    }
48 48
 
49
-	/**
50
-	 * @param $post
51
-	 */
52
-	public function run($post) {
53
-		// Check for autosetup:
54
-		$post = $this->loadAutoConfig($post);
55
-		$opts = $this->setupHelper->getSystemInfo();
49
+    /**
50
+     * @param $post
51
+     */
52
+    public function run($post) {
53
+        // Check for autosetup:
54
+        $post = $this->loadAutoConfig($post);
55
+        $opts = $this->setupHelper->getSystemInfo();
56 56
 
57
-		// convert 'abcpassword' to 'abcpass'
58
-		if (isset($post['adminpassword'])) {
59
-			$post['adminpass'] = $post['adminpassword'];
60
-		}
61
-		if (isset($post['dbpassword'])) {
62
-			$post['dbpass'] = $post['dbpassword'];
63
-		}
57
+        // convert 'abcpassword' to 'abcpass'
58
+        if (isset($post['adminpassword'])) {
59
+            $post['adminpass'] = $post['adminpassword'];
60
+        }
61
+        if (isset($post['dbpassword'])) {
62
+            $post['dbpass'] = $post['dbpassword'];
63
+        }
64 64
 
65
-		if(isset($post['install']) AND $post['install']=='true') {
66
-			// We have to launch the installation process :
67
-			$e = $this->setupHelper->install($post);
68
-			$errors = array('errors' => $e);
65
+        if(isset($post['install']) AND $post['install']=='true') {
66
+            // We have to launch the installation process :
67
+            $e = $this->setupHelper->install($post);
68
+            $errors = array('errors' => $e);
69 69
 
70
-			if(count($e) > 0) {
71
-				$options = array_merge($opts, $post, $errors);
72
-				$this->display($options);
73
-			} else {
74
-				$this->finishSetup();
75
-			}
76
-		} else {
77
-			$options = array_merge($opts, $post);
78
-			$this->display($options);
79
-		}
80
-	}
70
+            if(count($e) > 0) {
71
+                $options = array_merge($opts, $post, $errors);
72
+                $this->display($options);
73
+            } else {
74
+                $this->finishSetup();
75
+            }
76
+        } else {
77
+            $options = array_merge($opts, $post);
78
+            $this->display($options);
79
+        }
80
+    }
81 81
 
82
-	public function display($post) {
83
-		$defaults = array(
84
-			'adminlogin' => '',
85
-			'adminpass' => '',
86
-			'dbuser' => '',
87
-			'dbpass' => '',
88
-			'dbname' => '',
89
-			'dbtablespace' => '',
90
-			'dbhost' => 'localhost',
91
-			'dbtype' => '',
92
-		);
93
-		$parameters = array_merge($defaults, $post);
82
+    public function display($post) {
83
+        $defaults = array(
84
+            'adminlogin' => '',
85
+            'adminpass' => '',
86
+            'dbuser' => '',
87
+            'dbpass' => '',
88
+            'dbname' => '',
89
+            'dbtablespace' => '',
90
+            'dbhost' => 'localhost',
91
+            'dbtype' => '',
92
+        );
93
+        $parameters = array_merge($defaults, $post);
94 94
 
95
-		\OC_Util::addScript('setup');
96
-		\OC_Template::printGuestPage('', 'installation', $parameters);
97
-	}
95
+        \OC_Util::addScript('setup');
96
+        \OC_Template::printGuestPage('', 'installation', $parameters);
97
+    }
98 98
 
99
-	public function finishSetup() {
100
-		if( file_exists( $this->autoConfigFile )) {
101
-			unlink($this->autoConfigFile);
102
-		}
103
-		\OC::$server->getIntegrityCodeChecker()->runInstanceVerification();
104
-		\OC_Util::redirectToDefaultPage();
105
-	}
99
+    public function finishSetup() {
100
+        if( file_exists( $this->autoConfigFile )) {
101
+            unlink($this->autoConfigFile);
102
+        }
103
+        \OC::$server->getIntegrityCodeChecker()->runInstanceVerification();
104
+        \OC_Util::redirectToDefaultPage();
105
+    }
106 106
 
107
-	public function loadAutoConfig($post) {
108
-		if( file_exists($this->autoConfigFile)) {
109
-			\OCP\Util::writeLog('core', 'Autoconfig file found, setting up ownCloud…', ILogger::INFO);
110
-			$AUTOCONFIG = array();
111
-			include $this->autoConfigFile;
112
-			$post = array_merge ($post, $AUTOCONFIG);
113
-		}
107
+    public function loadAutoConfig($post) {
108
+        if( file_exists($this->autoConfigFile)) {
109
+            \OCP\Util::writeLog('core', 'Autoconfig file found, setting up ownCloud…', ILogger::INFO);
110
+            $AUTOCONFIG = array();
111
+            include $this->autoConfigFile;
112
+            $post = array_merge ($post, $AUTOCONFIG);
113
+        }
114 114
 
115
-		$dbIsSet = isset($post['dbtype']);
116
-		$directoryIsSet = isset($post['directory']);
117
-		$adminAccountIsSet = isset($post['adminlogin']);
115
+        $dbIsSet = isset($post['dbtype']);
116
+        $directoryIsSet = isset($post['directory']);
117
+        $adminAccountIsSet = isset($post['adminlogin']);
118 118
 
119
-		if ($dbIsSet AND $directoryIsSet AND $adminAccountIsSet) {
120
-			$post['install'] = 'true';
121
-		}
122
-		$post['dbIsSet'] = $dbIsSet;
123
-		$post['directoryIsSet'] = $directoryIsSet;
119
+        if ($dbIsSet AND $directoryIsSet AND $adminAccountIsSet) {
120
+            $post['install'] = 'true';
121
+        }
122
+        $post['dbIsSet'] = $dbIsSet;
123
+        $post['directoryIsSet'] = $directoryIsSet;
124 124
 
125
-		return $post;
126
-	}
125
+        return $post;
126
+    }
127 127
 }
Please login to merge, or discard this patch.
apps/user_ldap/templates/renewpassword.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php /** @var $l OC_L10N */ ?>
2 2
 <?php
3 3
 script('core', [
4
-	'jquery-showpassword',
4
+    'jquery-showpassword',
5 5
 ]);
6 6
 script('user_ldap', [
7
-	'renewPassword',
7
+    'renewPassword',
8 8
 ]);
9 9
 style('user_ldap', 'renewPassword');
10 10
 ?>
Please login to merge, or discard this patch.