@@ -40,227 +40,227 @@ |
||
| 40 | 40 | |
| 41 | 41 | class TemplateLayout extends \OC_Template { |
| 42 | 42 | |
| 43 | - private static $versionHash = ''; |
|
| 43 | + private static $versionHash = ''; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @var \OCP\IConfig |
|
| 47 | - */ |
|
| 48 | - private $config; |
|
| 45 | + /** |
|
| 46 | + * @var \OCP\IConfig |
|
| 47 | + */ |
|
| 48 | + private $config; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @param string $renderAs |
|
| 52 | - * @param string $appId application id |
|
| 53 | - */ |
|
| 54 | - public function __construct( $renderAs, $appId = '' ) { |
|
| 50 | + /** |
|
| 51 | + * @param string $renderAs |
|
| 52 | + * @param string $appId application id |
|
| 53 | + */ |
|
| 54 | + public function __construct( $renderAs, $appId = '' ) { |
|
| 55 | 55 | |
| 56 | - // yes - should be injected .... |
|
| 57 | - $this->config = \OC::$server->getConfig(); |
|
| 56 | + // yes - should be injected .... |
|
| 57 | + $this->config = \OC::$server->getConfig(); |
|
| 58 | 58 | |
| 59 | - // Decide which page we show |
|
| 60 | - if($renderAs == 'user') { |
|
| 61 | - parent::__construct( 'core', 'layout.user' ); |
|
| 62 | - if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
| 63 | - $this->assign('bodyid', 'body-settings'); |
|
| 64 | - }else{ |
|
| 65 | - $this->assign('bodyid', 'body-user'); |
|
| 66 | - } |
|
| 59 | + // Decide which page we show |
|
| 60 | + if($renderAs == 'user') { |
|
| 61 | + parent::__construct( 'core', 'layout.user' ); |
|
| 62 | + if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
| 63 | + $this->assign('bodyid', 'body-settings'); |
|
| 64 | + }else{ |
|
| 65 | + $this->assign('bodyid', 'body-user'); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - // Code integrity notification |
|
| 69 | - $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
|
| 70 | - if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
| 71 | - \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
|
| 72 | - } |
|
| 68 | + // Code integrity notification |
|
| 69 | + $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
|
| 70 | + if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
| 71 | + \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - // Add navigation entry |
|
| 75 | - $this->assign( 'application', ''); |
|
| 76 | - $this->assign( 'appid', $appId ); |
|
| 77 | - $navigation = \OC_App::getNavigation(); |
|
| 78 | - $this->assign( 'navigation', $navigation); |
|
| 79 | - $settingsNavigation = \OC_App::getSettingsNavigation(); |
|
| 80 | - $this->assign( 'settingsnavigation', $settingsNavigation); |
|
| 81 | - foreach($navigation as $entry) { |
|
| 82 | - if ($entry['active']) { |
|
| 83 | - $this->assign( 'application', $entry['name'] ); |
|
| 84 | - break; |
|
| 85 | - } |
|
| 86 | - } |
|
| 74 | + // Add navigation entry |
|
| 75 | + $this->assign( 'application', ''); |
|
| 76 | + $this->assign( 'appid', $appId ); |
|
| 77 | + $navigation = \OC_App::getNavigation(); |
|
| 78 | + $this->assign( 'navigation', $navigation); |
|
| 79 | + $settingsNavigation = \OC_App::getSettingsNavigation(); |
|
| 80 | + $this->assign( 'settingsnavigation', $settingsNavigation); |
|
| 81 | + foreach($navigation as $entry) { |
|
| 82 | + if ($entry['active']) { |
|
| 83 | + $this->assign( 'application', $entry['name'] ); |
|
| 84 | + break; |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - foreach($settingsNavigation as $entry) { |
|
| 89 | - if ($entry['active']) { |
|
| 90 | - $this->assign( 'application', $entry['name'] ); |
|
| 91 | - break; |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - $userDisplayName = \OC_User::getDisplayName(); |
|
| 95 | - $appsMgmtActive = strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0; |
|
| 96 | - if ($appsMgmtActive) { |
|
| 97 | - $l = \OC::$server->getL10N('lib'); |
|
| 98 | - $this->assign('application', $l->t('Apps')); |
|
| 99 | - } |
|
| 100 | - $this->assign('user_displayname', $userDisplayName); |
|
| 101 | - $this->assign('user_uid', \OC_User::getUser()); |
|
| 102 | - $this->assign('appsmanagement_active', $appsMgmtActive); |
|
| 88 | + foreach($settingsNavigation as $entry) { |
|
| 89 | + if ($entry['active']) { |
|
| 90 | + $this->assign( 'application', $entry['name'] ); |
|
| 91 | + break; |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + $userDisplayName = \OC_User::getDisplayName(); |
|
| 95 | + $appsMgmtActive = strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0; |
|
| 96 | + if ($appsMgmtActive) { |
|
| 97 | + $l = \OC::$server->getL10N('lib'); |
|
| 98 | + $this->assign('application', $l->t('Apps')); |
|
| 99 | + } |
|
| 100 | + $this->assign('user_displayname', $userDisplayName); |
|
| 101 | + $this->assign('user_uid', \OC_User::getUser()); |
|
| 102 | + $this->assign('appsmanagement_active', $appsMgmtActive); |
|
| 103 | 103 | |
| 104 | - if (\OC_User::getUser() === false) { |
|
| 105 | - $this->assign('userAvatarSet', false); |
|
| 106 | - } else { |
|
| 107 | - $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
| 108 | - $this->assign('userAvatarVersion', \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
| 109 | - } |
|
| 104 | + if (\OC_User::getUser() === false) { |
|
| 105 | + $this->assign('userAvatarSet', false); |
|
| 106 | + } else { |
|
| 107 | + $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
| 108 | + $this->assign('userAvatarVersion', \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - } else if ($renderAs == 'error') { |
|
| 112 | - parent::__construct('core', 'layout.guest', '', false); |
|
| 113 | - $this->assign('bodyid', 'body-login'); |
|
| 114 | - } else if ($renderAs == 'guest') { |
|
| 115 | - parent::__construct('core', 'layout.guest'); |
|
| 116 | - $this->assign('bodyid', 'body-login'); |
|
| 117 | - } else { |
|
| 118 | - parent::__construct('core', 'layout.base'); |
|
| 111 | + } else if ($renderAs == 'error') { |
|
| 112 | + parent::__construct('core', 'layout.guest', '', false); |
|
| 113 | + $this->assign('bodyid', 'body-login'); |
|
| 114 | + } else if ($renderAs == 'guest') { |
|
| 115 | + parent::__construct('core', 'layout.guest'); |
|
| 116 | + $this->assign('bodyid', 'body-login'); |
|
| 117 | + } else { |
|
| 118 | + parent::__construct('core', 'layout.base'); |
|
| 119 | 119 | |
| 120 | - } |
|
| 121 | - // Send the language to our layouts |
|
| 122 | - $this->assign('language', \OC::$server->getL10NFactory()->findLanguage()); |
|
| 120 | + } |
|
| 121 | + // Send the language to our layouts |
|
| 122 | + $this->assign('language', \OC::$server->getL10NFactory()->findLanguage()); |
|
| 123 | 123 | |
| 124 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 125 | - if (empty(self::$versionHash)) { |
|
| 126 | - $v = \OC_App::getAppVersions(); |
|
| 127 | - $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
| 128 | - self::$versionHash = md5(implode(',', $v)); |
|
| 129 | - } |
|
| 130 | - } else { |
|
| 131 | - self::$versionHash = md5('not installed'); |
|
| 132 | - } |
|
| 124 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 125 | + if (empty(self::$versionHash)) { |
|
| 126 | + $v = \OC_App::getAppVersions(); |
|
| 127 | + $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
| 128 | + self::$versionHash = md5(implode(',', $v)); |
|
| 129 | + } |
|
| 130 | + } else { |
|
| 131 | + self::$versionHash = md5('not installed'); |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | - // Add the js files |
|
| 135 | - $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
| 136 | - $this->assign('jsfiles', array()); |
|
| 137 | - if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
| 138 | - if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
| 139 | - $jsConfigHelper = new JSConfigHelper( |
|
| 140 | - \OC::$server->getL10N('core'), |
|
| 141 | - \OC::$server->getThemingDefaults(), |
|
| 142 | - \OC::$server->getAppManager(), |
|
| 143 | - \OC::$server->getSession(), |
|
| 144 | - \OC::$server->getUserSession()->getUser(), |
|
| 145 | - \OC::$server->getConfig(), |
|
| 146 | - \OC::$server->getGroupManager(), |
|
| 147 | - \OC::$server->getIniWrapper(), |
|
| 148 | - \OC::$server->getURLGenerator() |
|
| 149 | - ); |
|
| 150 | - $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
| 151 | - $this->assign('foo', 'bar'); |
|
| 152 | - } else { |
|
| 153 | - $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - foreach($jsFiles as $info) { |
|
| 157 | - $web = $info[1]; |
|
| 158 | - $file = $info[2]; |
|
| 159 | - $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
| 160 | - } |
|
| 134 | + // Add the js files |
|
| 135 | + $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
| 136 | + $this->assign('jsfiles', array()); |
|
| 137 | + if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
| 138 | + if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
| 139 | + $jsConfigHelper = new JSConfigHelper( |
|
| 140 | + \OC::$server->getL10N('core'), |
|
| 141 | + \OC::$server->getThemingDefaults(), |
|
| 142 | + \OC::$server->getAppManager(), |
|
| 143 | + \OC::$server->getSession(), |
|
| 144 | + \OC::$server->getUserSession()->getUser(), |
|
| 145 | + \OC::$server->getConfig(), |
|
| 146 | + \OC::$server->getGroupManager(), |
|
| 147 | + \OC::$server->getIniWrapper(), |
|
| 148 | + \OC::$server->getURLGenerator() |
|
| 149 | + ); |
|
| 150 | + $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
| 151 | + $this->assign('foo', 'bar'); |
|
| 152 | + } else { |
|
| 153 | + $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + foreach($jsFiles as $info) { |
|
| 157 | + $web = $info[1]; |
|
| 158 | + $file = $info[2]; |
|
| 159 | + $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - try { |
|
| 163 | - $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
| 164 | - } catch (\Exception $e) { |
|
| 165 | - $pathInfo = ''; |
|
| 166 | - } |
|
| 162 | + try { |
|
| 163 | + $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
| 164 | + } catch (\Exception $e) { |
|
| 165 | + $pathInfo = ''; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - // Do not initialise scss appdata until we have a fully installed instance |
|
| 169 | - // Do not load scss for update, errors, installation or login page |
|
| 170 | - if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
| 171 | - && !\OCP\Util::needUpgrade() |
|
| 172 | - && $pathInfo !== '' |
|
| 173 | - && !preg_match('/^\/login/', $pathInfo)) { |
|
| 174 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
| 175 | - } else { |
|
| 176 | - // If we ignore the scss compiler, |
|
| 177 | - // we need to load the guest css fallback |
|
| 178 | - \OC_Util::addStyle('guest'); |
|
| 179 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
| 180 | - } |
|
| 168 | + // Do not initialise scss appdata until we have a fully installed instance |
|
| 169 | + // Do not load scss for update, errors, installation or login page |
|
| 170 | + if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
| 171 | + && !\OCP\Util::needUpgrade() |
|
| 172 | + && $pathInfo !== '' |
|
| 173 | + && !preg_match('/^\/login/', $pathInfo)) { |
|
| 174 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
| 175 | + } else { |
|
| 176 | + // If we ignore the scss compiler, |
|
| 177 | + // we need to load the guest css fallback |
|
| 178 | + \OC_Util::addStyle('guest'); |
|
| 179 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - $this->assign('cssfiles', array()); |
|
| 183 | - $this->assign('printcssfiles', []); |
|
| 184 | - $this->assign('versionHash', self::$versionHash); |
|
| 185 | - foreach($cssFiles as $info) { |
|
| 186 | - $web = $info[1]; |
|
| 187 | - $file = $info[2]; |
|
| 182 | + $this->assign('cssfiles', array()); |
|
| 183 | + $this->assign('printcssfiles', []); |
|
| 184 | + $this->assign('versionHash', self::$versionHash); |
|
| 185 | + foreach($cssFiles as $info) { |
|
| 186 | + $web = $info[1]; |
|
| 187 | + $file = $info[2]; |
|
| 188 | 188 | |
| 189 | - if (substr($file, -strlen('print.css')) === 'print.css') { |
|
| 190 | - $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
| 191 | - } else { |
|
| 192 | - $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - } |
|
| 189 | + if (substr($file, -strlen('print.css')) === 'print.css') { |
|
| 190 | + $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
| 191 | + } else { |
|
| 192 | + $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - protected function getVersionHashSuffix() { |
|
| 198 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 199 | - // allows chrome workspace mapping in debug mode |
|
| 200 | - return ""; |
|
| 201 | - } |
|
| 197 | + protected function getVersionHashSuffix() { |
|
| 198 | + if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 199 | + // allows chrome workspace mapping in debug mode |
|
| 200 | + return ""; |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - return '?v=' . self::$versionHash; |
|
| 204 | - } |
|
| 203 | + return '?v=' . self::$versionHash; |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - /** |
|
| 207 | - * @param array $styles |
|
| 208 | - * @return array |
|
| 209 | - */ |
|
| 210 | - static public function findStylesheetFiles($styles, $compileScss = true) { |
|
| 211 | - // Read the selected theme from the config file |
|
| 212 | - $theme = \OC_Util::getTheme(); |
|
| 206 | + /** |
|
| 207 | + * @param array $styles |
|
| 208 | + * @return array |
|
| 209 | + */ |
|
| 210 | + static public function findStylesheetFiles($styles, $compileScss = true) { |
|
| 211 | + // Read the selected theme from the config file |
|
| 212 | + $theme = \OC_Util::getTheme(); |
|
| 213 | 213 | |
| 214 | - if($compileScss) { |
|
| 215 | - $SCSSCacher = new SCSSCacher( |
|
| 216 | - \OC::$server->getLogger(), |
|
| 217 | - \OC::$server->getAppDataDir('css'), |
|
| 218 | - \OC::$server->getURLGenerator(), |
|
| 219 | - \OC::$server->getSystemConfig() |
|
| 220 | - ); |
|
| 221 | - } else { |
|
| 222 | - $SCSSCacher = null; |
|
| 223 | - } |
|
| 214 | + if($compileScss) { |
|
| 215 | + $SCSSCacher = new SCSSCacher( |
|
| 216 | + \OC::$server->getLogger(), |
|
| 217 | + \OC::$server->getAppDataDir('css'), |
|
| 218 | + \OC::$server->getURLGenerator(), |
|
| 219 | + \OC::$server->getSystemConfig() |
|
| 220 | + ); |
|
| 221 | + } else { |
|
| 222 | + $SCSSCacher = null; |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - $locator = new \OC\Template\CSSResourceLocator( |
|
| 226 | - \OC::$server->getLogger(), |
|
| 227 | - $theme, |
|
| 228 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
| 229 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
| 230 | - $SCSSCacher); |
|
| 231 | - $locator->find($styles); |
|
| 232 | - return $locator->getResources(); |
|
| 233 | - } |
|
| 225 | + $locator = new \OC\Template\CSSResourceLocator( |
|
| 226 | + \OC::$server->getLogger(), |
|
| 227 | + $theme, |
|
| 228 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
| 229 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
| 230 | + $SCSSCacher); |
|
| 231 | + $locator->find($styles); |
|
| 232 | + return $locator->getResources(); |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - /** |
|
| 236 | - * @param array $scripts |
|
| 237 | - * @return array |
|
| 238 | - */ |
|
| 239 | - static public function findJavascriptFiles($scripts) { |
|
| 240 | - // Read the selected theme from the config file |
|
| 241 | - $theme = \OC_Util::getTheme(); |
|
| 235 | + /** |
|
| 236 | + * @param array $scripts |
|
| 237 | + * @return array |
|
| 238 | + */ |
|
| 239 | + static public function findJavascriptFiles($scripts) { |
|
| 240 | + // Read the selected theme from the config file |
|
| 241 | + $theme = \OC_Util::getTheme(); |
|
| 242 | 242 | |
| 243 | - $locator = new \OC\Template\JSResourceLocator( |
|
| 244 | - \OC::$server->getLogger(), |
|
| 245 | - $theme, |
|
| 246 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
| 247 | - array( \OC::$SERVERROOT => \OC::$WEBROOT )); |
|
| 248 | - $locator->find($scripts); |
|
| 249 | - return $locator->getResources(); |
|
| 250 | - } |
|
| 243 | + $locator = new \OC\Template\JSResourceLocator( |
|
| 244 | + \OC::$server->getLogger(), |
|
| 245 | + $theme, |
|
| 246 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
| 247 | + array( \OC::$SERVERROOT => \OC::$WEBROOT )); |
|
| 248 | + $locator->find($scripts); |
|
| 249 | + return $locator->getResources(); |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - /** |
|
| 253 | - * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
| 254 | - * @param string $filePath Absolute path |
|
| 255 | - * @return string Relative path |
|
| 256 | - * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
| 257 | - */ |
|
| 258 | - public static function convertToRelativePath($filePath) { |
|
| 259 | - $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
| 260 | - if(count($relativePath) !== 2) { |
|
| 261 | - throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
| 262 | - } |
|
| 252 | + /** |
|
| 253 | + * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
| 254 | + * @param string $filePath Absolute path |
|
| 255 | + * @return string Relative path |
|
| 256 | + * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
| 257 | + */ |
|
| 258 | + public static function convertToRelativePath($filePath) { |
|
| 259 | + $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
| 260 | + if(count($relativePath) !== 2) { |
|
| 261 | + throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - return $relativePath[1]; |
|
| 265 | - } |
|
| 264 | + return $relativePath[1]; |
|
| 265 | + } |
|
| 266 | 266 | } |
@@ -51,43 +51,43 @@ discard block |
||
| 51 | 51 | * @param string $renderAs |
| 52 | 52 | * @param string $appId application id |
| 53 | 53 | */ |
| 54 | - public function __construct( $renderAs, $appId = '' ) { |
|
| 54 | + public function __construct($renderAs, $appId = '') { |
|
| 55 | 55 | |
| 56 | 56 | // yes - should be injected .... |
| 57 | 57 | $this->config = \OC::$server->getConfig(); |
| 58 | 58 | |
| 59 | 59 | // Decide which page we show |
| 60 | - if($renderAs == 'user') { |
|
| 61 | - parent::__construct( 'core', 'layout.user' ); |
|
| 62 | - if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
| 60 | + if ($renderAs == 'user') { |
|
| 61 | + parent::__construct('core', 'layout.user'); |
|
| 62 | + if (in_array(\OC_App::getCurrentApp(), ['settings', 'admin', 'help']) !== false) { |
|
| 63 | 63 | $this->assign('bodyid', 'body-settings'); |
| 64 | - }else{ |
|
| 64 | + } else { |
|
| 65 | 65 | $this->assign('bodyid', 'body-user'); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Code integrity notification |
| 69 | 69 | $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
| 70 | - if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
| 70 | + if (\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
| 71 | 71 | \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // Add navigation entry |
| 75 | - $this->assign( 'application', ''); |
|
| 76 | - $this->assign( 'appid', $appId ); |
|
| 75 | + $this->assign('application', ''); |
|
| 76 | + $this->assign('appid', $appId); |
|
| 77 | 77 | $navigation = \OC_App::getNavigation(); |
| 78 | - $this->assign( 'navigation', $navigation); |
|
| 78 | + $this->assign('navigation', $navigation); |
|
| 79 | 79 | $settingsNavigation = \OC_App::getSettingsNavigation(); |
| 80 | - $this->assign( 'settingsnavigation', $settingsNavigation); |
|
| 81 | - foreach($navigation as $entry) { |
|
| 80 | + $this->assign('settingsnavigation', $settingsNavigation); |
|
| 81 | + foreach ($navigation as $entry) { |
|
| 82 | 82 | if ($entry['active']) { |
| 83 | - $this->assign( 'application', $entry['name'] ); |
|
| 83 | + $this->assign('application', $entry['name']); |
|
| 84 | 84 | break; |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - foreach($settingsNavigation as $entry) { |
|
| 88 | + foreach ($settingsNavigation as $entry) { |
|
| 89 | 89 | if ($entry['active']) { |
| 90 | - $this->assign( 'application', $entry['name'] ); |
|
| 90 | + $this->assign('application', $entry['name']); |
|
| 91 | 91 | break; |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | // Send the language to our layouts |
| 122 | 122 | $this->assign('language', \OC::$server->getL10NFactory()->findLanguage()); |
| 123 | 123 | |
| 124 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 124 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 125 | 125 | if (empty(self::$versionHash)) { |
| 126 | 126 | $v = \OC_App::getAppVersions(); |
| 127 | 127 | $v['core'] = implode('.', \OCP\Util::getVersion()); |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | - foreach($jsFiles as $info) { |
|
| 156 | + foreach ($jsFiles as $info) { |
|
| 157 | 157 | $web = $info[1]; |
| 158 | 158 | $file = $info[2]; |
| 159 | - $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
| 159 | + $this->append('jsfiles', $web.'/'.$file.$this->getVersionHashSuffix()); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | try { |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | // Do not initialise scss appdata until we have a fully installed instance |
| 169 | 169 | // Do not load scss for update, errors, installation or login page |
| 170 | - if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
| 170 | + if (\OC::$server->getSystemConfig()->getValue('installed', false) |
|
| 171 | 171 | && !\OCP\Util::needUpgrade() |
| 172 | 172 | && $pathInfo !== '' |
| 173 | 173 | && !preg_match('/^\/login/', $pathInfo)) { |
@@ -182,25 +182,25 @@ discard block |
||
| 182 | 182 | $this->assign('cssfiles', array()); |
| 183 | 183 | $this->assign('printcssfiles', []); |
| 184 | 184 | $this->assign('versionHash', self::$versionHash); |
| 185 | - foreach($cssFiles as $info) { |
|
| 185 | + foreach ($cssFiles as $info) { |
|
| 186 | 186 | $web = $info[1]; |
| 187 | 187 | $file = $info[2]; |
| 188 | 188 | |
| 189 | 189 | if (substr($file, -strlen('print.css')) === 'print.css') { |
| 190 | - $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
| 190 | + $this->append('printcssfiles', $web.'/'.$file.$this->getVersionHashSuffix()); |
|
| 191 | 191 | } else { |
| 192 | - $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
| 192 | + $this->append('cssfiles', $web.'/'.$file.$this->getVersionHashSuffix()); |
|
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | protected function getVersionHashSuffix() { |
| 198 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 198 | + if (\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
| 199 | 199 | // allows chrome workspace mapping in debug mode |
| 200 | 200 | return ""; |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - return '?v=' . self::$versionHash; |
|
| 203 | + return '?v='.self::$versionHash; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | // Read the selected theme from the config file |
| 212 | 212 | $theme = \OC_Util::getTheme(); |
| 213 | 213 | |
| 214 | - if($compileScss) { |
|
| 214 | + if ($compileScss) { |
|
| 215 | 215 | $SCSSCacher = new SCSSCacher( |
| 216 | 216 | \OC::$server->getLogger(), |
| 217 | 217 | \OC::$server->getAppDataDir('css'), |
@@ -225,8 +225,8 @@ discard block |
||
| 225 | 225 | $locator = new \OC\Template\CSSResourceLocator( |
| 226 | 226 | \OC::$server->getLogger(), |
| 227 | 227 | $theme, |
| 228 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
| 229 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
| 228 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
| 229 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
| 230 | 230 | $SCSSCacher); |
| 231 | 231 | $locator->find($styles); |
| 232 | 232 | return $locator->getResources(); |
@@ -243,8 +243,8 @@ discard block |
||
| 243 | 243 | $locator = new \OC\Template\JSResourceLocator( |
| 244 | 244 | \OC::$server->getLogger(), |
| 245 | 245 | $theme, |
| 246 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
| 247 | - array( \OC::$SERVERROOT => \OC::$WEBROOT )); |
|
| 246 | + array(\OC::$SERVERROOT => \OC::$WEBROOT), |
|
| 247 | + array(\OC::$SERVERROOT => \OC::$WEBROOT)); |
|
| 248 | 248 | $locator->find($scripts); |
| 249 | 249 | return $locator->getResources(); |
| 250 | 250 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | */ |
| 258 | 258 | public static function convertToRelativePath($filePath) { |
| 259 | 259 | $relativePath = explode(\OC::$SERVERROOT, $filePath); |
| 260 | - if(count($relativePath) !== 2) { |
|
| 260 | + if (count($relativePath) !== 2) { |
|
| 261 | 261 | throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
| 262 | 262 | } |
| 263 | 263 | |