@@ -26,11 +26,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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"> |
@@ -22,16 +22,16 @@ discard block |
||
| 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 |
||
| 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()) ?> |
@@ -29,25 +29,25 @@ discard block |
||
| 29 | 29 | 'settings/authtoken-init' |
| 30 | 30 | ]); |
| 31 | 31 | |
| 32 | -if($_['passwordChangeSupported']) { |
|
| 32 | +if ($_['passwordChangeSupported']) { |
|
| 33 | 33 | script('settings', 'security_password'); |
| 34 | 34 | script('jquery-showpassword'); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | ?> |
| 38 | -<?php if($_['passwordChangeSupported']) { ?> |
|
| 38 | +<?php if ($_['passwordChangeSupported']) { ?> |
|
| 39 | 39 | <div id="security-password" class="section"> |
| 40 | - <h2 class="inlineblock"><?php p($l->t('Password'));?></h2> |
|
| 40 | + <h2 class="inlineblock"><?php p($l->t('Password')); ?></h2> |
|
| 41 | 41 | <span id="password-error-msg" class="msg success hidden">Saved</span> |
| 42 | 42 | <div class="personal-settings-setting-box personal-settings-password-box"> |
| 43 | 43 | <form id="passwordform"> |
| 44 | 44 | <label for="pass1" class="hidden-visually"><?php p($l->t('Current password')); ?>: </label> |
| 45 | 45 | <input type="password" id="pass1" name="oldpassword" |
| 46 | - placeholder="<?php p($l->t('Current password'));?>" |
|
| 46 | + placeholder="<?php p($l->t('Current password')); ?>" |
|
| 47 | 47 | autocomplete="off" autocapitalize="none" autocorrect="off" /> |
| 48 | 48 | |
| 49 | 49 | <div class="personal-show-container"> |
| 50 | - <label for="pass2" class="hidden-visually"><?php p($l->t('New password'));?>: </label> |
|
| 50 | + <label for="pass2" class="hidden-visually"><?php p($l->t('New password')); ?>: </label> |
|
| 51 | 51 | <input type="password" id="pass2" name="newpassword" |
| 52 | 52 | placeholder="<?php p($l->t('New password')); ?>" |
| 53 | 53 | data-typetoggle="#personal-show" |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | <?php } ?> |
| 65 | 65 | |
| 66 | 66 | <div id="security" class="section"> |
| 67 | - <h2><?php p($l->t('Devices & sessions'));?></h2> |
|
| 68 | - <p class="settings-hint hidden-when-empty"><?php p($l->t('Web, desktop and mobile clients currently logged in to your account.'));?></p> |
|
| 67 | + <h2><?php p($l->t('Devices & sessions')); ?></h2> |
|
| 68 | + <p class="settings-hint hidden-when-empty"><?php p($l->t('Web, desktop and mobile clients currently logged in to your account.')); ?></p> |
|
| 69 | 69 | <table class="icon-loading"> |
| 70 | 70 | <thead class="token-list-header"> |
| 71 | 71 | <tr> |
| 72 | 72 | <th></th> |
| 73 | - <th><?php p($l->t('Device'));?></th> |
|
| 74 | - <th><?php p($l->t('Last activity'));?></th> |
|
| 73 | + <th><?php p($l->t('Device')); ?></th> |
|
| 74 | + <th><?php p($l->t('Last activity')); ?></th> |
|
| 75 | 75 | <th></th> |
| 76 | 76 | </tr> |
| 77 | 77 | </thead> |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | </div> |
| 102 | 102 | |
| 103 | 103 | <div id="two-factor-auth" class="section"> |
| 104 | - <h2><?php p($l->t('Two-Factor Authentication'));?></h2> |
|
| 104 | + <h2><?php p($l->t('Two-Factor Authentication')); ?></h2> |
|
| 105 | 105 | <ul> |
| 106 | 106 | <?php foreach ($_['twoFactorProviderData']['providers'] as $data) { ?> |
| 107 | 107 | <li> |
@@ -46,318 +46,318 @@ |
||
| 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 | } |
@@ -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('css-variables', null, true); |
| 113 | 113 | OC_Util::addStyle('server', null, true); |
| 114 | - OC_Util::addStyle('jquery-ui-fixes',null,true); |
|
| 114 | + OC_Util::addStyle('jquery-ui-fixes', null, true); |
|
| 115 | 115 | OC_Util::addStyle('jquery.ocdialog'); |
| 116 | 116 | OC_Util::addTranslations("core", null, true); |
| 117 | 117 | OC_Util::addStyle('search', 'results'); |
@@ -148,12 +148,12 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | protected function findTemplate($theme, $app, $name) { |
| 150 | 150 | // Check if it is a app template or not. |
| 151 | - if( $app !== '' ) { |
|
| 151 | + if ($app !== '') { |
|
| 152 | 152 | $dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app)); |
| 153 | 153 | } else { |
| 154 | 154 | $dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT); |
| 155 | 155 | } |
| 156 | - $locator = new \OC\Template\TemplateFileLocator( $dirs ); |
|
| 156 | + $locator = new \OC\Template\TemplateFileLocator($dirs); |
|
| 157 | 157 | $template = $locator->find($name); |
| 158 | 158 | $path = $locator->getPath(); |
| 159 | 159 | return array($path, $template); |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | * @param string $text the text content for the element. If $text is null then the |
| 167 | 167 | * element will be written as empty element. So use "" to get a closing tag. |
| 168 | 168 | */ |
| 169 | - public function addHeader($tag, $attributes, $text=null) { |
|
| 170 | - $this->headers[]= array( |
|
| 169 | + public function addHeader($tag, $attributes, $text = null) { |
|
| 170 | + $this->headers[] = array( |
|
| 171 | 171 | 'tag' => $tag, |
| 172 | 172 | 'attributes' => $attributes, |
| 173 | 173 | 'text' => $text |
@@ -184,10 +184,10 @@ discard block |
||
| 184 | 184 | public function fetchPage($additionalParams = null) { |
| 185 | 185 | $data = parent::fetchPage($additionalParams); |
| 186 | 186 | |
| 187 | - if( $this->renderAs ) { |
|
| 187 | + if ($this->renderAs) { |
|
| 188 | 188 | $page = new TemplateLayout($this->renderAs, $this->app); |
| 189 | 189 | |
| 190 | - if(is_array($additionalParams)) { |
|
| 190 | + if (is_array($additionalParams)) { |
|
| 191 | 191 | foreach ($additionalParams as $key => $value) { |
| 192 | 192 | $page->assign($key, $value); |
| 193 | 193 | } |
@@ -195,12 +195,12 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | // Add custom headers |
| 197 | 197 | $headers = ''; |
| 198 | - foreach(OC_Util::$headers as $header) { |
|
| 198 | + foreach (OC_Util::$headers as $header) { |
|
| 199 | 199 | $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']); |
| 200 | - if ( strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes']))) ) { |
|
| 200 | + if (strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes'])))) { |
|
| 201 | 201 | $headers .= ' defer'; |
| 202 | 202 | } |
| 203 | - foreach($header['attributes'] as $name=>$value) { |
|
| 203 | + foreach ($header['attributes'] as $name=>$value) { |
|
| 204 | 204 | $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"'; |
| 205 | 205 | } |
| 206 | 206 | if ($header['text'] !== null) { |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * Includes another template. use <?php echo $this->inc('template'); ?> to |
| 230 | 230 | * do this. |
| 231 | 231 | */ |
| 232 | - public function inc( $file, $additionalParams = null ) { |
|
| 232 | + public function inc($file, $additionalParams = null) { |
|
| 233 | 233 | return $this->load($this->path.$file.'.php', $additionalParams); |
| 234 | 234 | } |
| 235 | 235 | |
@@ -240,10 +240,10 @@ discard block |
||
| 240 | 240 | * @param array $parameters Parameters for the template |
| 241 | 241 | * @return boolean|null |
| 242 | 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 ); |
|
| 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 | 247 | } |
| 248 | 248 | print $content->printPage(); |
| 249 | 249 | } |
@@ -255,10 +255,10 @@ discard block |
||
| 255 | 255 | * @param array $parameters Parameters for the template |
| 256 | 256 | * @return bool |
| 257 | 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 ); |
|
| 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 | 262 | } |
| 263 | 263 | return $content->printPage(); |
| 264 | 264 | } |
@@ -270,10 +270,10 @@ discard block |
||
| 270 | 270 | * @param array|string $parameters Parameters for the template |
| 271 | 271 | * @return bool |
| 272 | 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 ); |
|
| 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 | 277 | } |
| 278 | 278 | return $content->printPage(); |
| 279 | 279 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | * @param int $statusCode |
| 286 | 286 | * @suppress PhanAccessMethodInternal |
| 287 | 287 | */ |
| 288 | - public static function printErrorPage( $error_msg, $hint = '', $statusCode = 500) { |
|
| 288 | + public static function printErrorPage($error_msg, $hint = '', $statusCode = 500) { |
|
| 289 | 289 | if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) { |
| 290 | 290 | \OC_App::loadApp('theming'); |
| 291 | 291 | } |
@@ -298,9 +298,9 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | http_response_code($statusCode); |
| 300 | 300 | try { |
| 301 | - $content = new \OC_Template( '', 'error', 'error', false ); |
|
| 301 | + $content = new \OC_Template('', 'error', 'error', false); |
|
| 302 | 302 | $errors = array(array('error' => $error_msg, 'hint' => $hint)); |
| 303 | - $content->assign( 'errors', $errors ); |
|
| 303 | + $content->assign('errors', $errors); |
|
| 304 | 304 | $content->printPage(); |
| 305 | 305 | } catch (\Exception $e) { |
| 306 | 306 | $logger = \OC::$server->getLogger(); |
@@ -33,95 +33,95 @@ |
||
| 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 | } |
@@ -1,10 +1,10 @@ |
||
| 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 | ?> |