@@ -51,7 +51,6 @@ |
||
| 51 | 51 | * @param ILogger $logger |
| 52 | 52 | * @param IAppData $appData |
| 53 | 53 | * @param IURLGenerator $urlGenerator |
| 54 | - * @param SystemConfig $systemConfig |
|
| 55 | 54 | */ |
| 56 | 55 | public function __construct(ILogger $logger, IAppData $appData, IURLGenerator $urlGenerator, IConfig $config) { |
| 57 | 56 | $this->logger = $logger; |
@@ -35,197 +35,197 @@ |
||
| 35 | 35 | |
| 36 | 36 | class SCSSCacher { |
| 37 | 37 | |
| 38 | - /** @var ILogger */ |
|
| 39 | - protected $logger; |
|
| 40 | - |
|
| 41 | - /** @var IAppData */ |
|
| 42 | - protected $appData; |
|
| 43 | - |
|
| 44 | - /** @var IURLGenerator */ |
|
| 45 | - protected $urlGenerator; |
|
| 46 | - |
|
| 47 | - /** @var IConfig */ |
|
| 48 | - protected $config; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @param ILogger $logger |
|
| 52 | - * @param IAppData $appData |
|
| 53 | - * @param IURLGenerator $urlGenerator |
|
| 54 | - * @param SystemConfig $systemConfig |
|
| 55 | - */ |
|
| 56 | - public function __construct(ILogger $logger, IAppData $appData, IURLGenerator $urlGenerator, IConfig $config) { |
|
| 57 | - $this->logger = $logger; |
|
| 58 | - $this->appData = $appData; |
|
| 59 | - $this->urlGenerator = $urlGenerator; |
|
| 60 | - $this->config = $config; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Process the caching process if needed |
|
| 65 | - * @param string $root Root path to the nextcloud installation |
|
| 66 | - * @param string $file |
|
| 67 | - * @param string $app The app name |
|
| 68 | - * @return boolean |
|
| 69 | - */ |
|
| 70 | - public function process($root, $file, $app) { |
|
| 71 | - $path = explode('/', $root . '/' . $file); |
|
| 72 | - |
|
| 73 | - $fileNameSCSS = array_pop($path); |
|
| 74 | - $fileNameCSS = str_replace('.scss', '.css', $fileNameSCSS); |
|
| 75 | - |
|
| 76 | - $path = implode('/', $path); |
|
| 77 | - |
|
| 78 | - $webDir = explode('/', $file); |
|
| 79 | - array_pop($webDir); |
|
| 80 | - $webDir = implode('/', $webDir); |
|
| 81 | - |
|
| 82 | - try { |
|
| 83 | - $folder = $this->appData->getFolder($app); |
|
| 84 | - } catch(NotFoundException $e) { |
|
| 85 | - // creating css appdata folder |
|
| 86 | - $folder = $this->appData->newFolder($app); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - if($this->isCached($fileNameCSS, $fileNameSCSS, $folder, $path) && !$this->variablesChanged($fileNameCSS, $folder)) { |
|
| 90 | - return true; |
|
| 91 | - } |
|
| 92 | - return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Check if the file is cached or not |
|
| 97 | - * @param string $fileNameCSS |
|
| 98 | - * @param string $fileNameSCSS |
|
| 99 | - * @param ISimpleFolder $folder |
|
| 100 | - * @param string $path |
|
| 101 | - * @return boolean |
|
| 102 | - */ |
|
| 103 | - private function isCached($fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $path) { |
|
| 104 | - try { |
|
| 105 | - $cachedFile = $folder->getFile($fileNameCSS); |
|
| 106 | - if ($cachedFile->getSize() > 0) { |
|
| 107 | - $depFile = $folder->getFile($fileNameCSS . '.deps'); |
|
| 108 | - $deps = json_decode($depFile->getContent(), true); |
|
| 109 | - |
|
| 110 | - foreach ($deps as $file=>$mtime) { |
|
| 111 | - if (!file_exists($file) || filemtime($file) > $mtime) { |
|
| 112 | - return false; |
|
| 113 | - } |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - return true; |
|
| 117 | - } catch(NotFoundException $e) { |
|
| 118 | - return false; |
|
| 119 | - } |
|
| 120 | - return false; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Check if the variables file has changed |
|
| 125 | - * @param string $fileNameCSS |
|
| 126 | - * @param ISimpleFolder $folder |
|
| 127 | - * @return bool |
|
| 128 | - */ |
|
| 129 | - private function variablesChanged($fileNameCSS, ISimpleFolder $folder) { |
|
| 130 | - $variablesFile = \OC::$SERVERROOT . '/core/css/variables.scss'; |
|
| 131 | - try { |
|
| 132 | - $cachedFile = $folder->getFile($fileNameCSS); |
|
| 133 | - if ($cachedFile->getMTime() < filemtime($variablesFile) |
|
| 134 | - || $cachedFile->getSize() === 0 |
|
| 135 | - ) { |
|
| 136 | - return true; |
|
| 137 | - } |
|
| 138 | - } catch (NotFoundException $e) { |
|
| 139 | - return true; |
|
| 140 | - } |
|
| 141 | - return false; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * Cache the file with AppData |
|
| 146 | - * @param string $path |
|
| 147 | - * @param string $fileNameCSS |
|
| 148 | - * @param string $fileNameSCSS |
|
| 149 | - * @param ISimpleFolder $folder |
|
| 150 | - * @param string $webDir |
|
| 151 | - * @return boolean |
|
| 152 | - */ |
|
| 153 | - private function cache($path, $fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $webDir) { |
|
| 154 | - $scss = new Compiler(); |
|
| 155 | - $scss->setImportPaths([ |
|
| 156 | - $path, |
|
| 157 | - \OC::$SERVERROOT . '/core/css/', |
|
| 158 | - ]); |
|
| 159 | - if($this->config->getSystemValue('debug')) { |
|
| 160 | - // Debug mode |
|
| 161 | - $scss->setFormatter(Expanded::class); |
|
| 162 | - $scss->setLineNumberStyle(Compiler::LINE_COMMENTS); |
|
| 163 | - } else { |
|
| 164 | - // Compression |
|
| 165 | - $scss->setFormatter(Crunched::class); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - try { |
|
| 169 | - $cachedfile = $folder->getFile($fileNameCSS); |
|
| 170 | - } catch(NotFoundException $e) { |
|
| 171 | - $cachedfile = $folder->newFile($fileNameCSS); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - $depFileName = $fileNameCSS . '.deps'; |
|
| 175 | - try { |
|
| 176 | - $depFile = $folder->getFile($depFileName); |
|
| 177 | - } catch (NotFoundException $e) { |
|
| 178 | - $depFile = $folder->newFile($depFileName); |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - // Compile |
|
| 182 | - try { |
|
| 183 | - $compiledScss = $scss->compile( |
|
| 184 | - '@import "variables.scss";' . |
|
| 185 | - '@import "'.$fileNameSCSS.'";'); |
|
| 186 | - } catch(ParserException $e) { |
|
| 187 | - $this->logger->error($e, ['app' => 'core']); |
|
| 188 | - return false; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - try { |
|
| 192 | - $cachedfile->putContent($this->rebaseUrls($compiledScss, $webDir)); |
|
| 193 | - $depFile->putContent(json_encode($scss->getParsedFiles())); |
|
| 194 | - $this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']); |
|
| 195 | - return true; |
|
| 196 | - } catch(NotFoundException $e) { |
|
| 197 | - return false; |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Add the correct uri prefix to make uri valid again |
|
| 203 | - * @param string $css |
|
| 204 | - * @param string $webDir |
|
| 205 | - * @return string |
|
| 206 | - */ |
|
| 207 | - private function rebaseUrls($css, $webDir) { |
|
| 208 | - $re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x'; |
|
| 209 | - // OC\Route\Router:75 |
|
| 210 | - if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { |
|
| 211 | - $subst = 'url(\'../../'.$webDir.'/$1\')'; |
|
| 212 | - } else { |
|
| 213 | - $subst = 'url(\'../../../'.$webDir.'/$1\')'; |
|
| 214 | - } |
|
| 215 | - return preg_replace($re, $subst, $css); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * Return the cached css file uri |
|
| 220 | - * @param string $appName the app name |
|
| 221 | - * @param string $fileName |
|
| 222 | - * @return string |
|
| 223 | - */ |
|
| 224 | - public function getCachedSCSS($appName, $fileName) { |
|
| 225 | - $tmpfileLoc = explode('/', $fileName); |
|
| 226 | - $fileName = array_pop($tmpfileLoc); |
|
| 227 | - $fileName = str_replace('.scss', '.css', $fileName); |
|
| 228 | - |
|
| 229 | - return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1); |
|
| 230 | - } |
|
| 38 | + /** @var ILogger */ |
|
| 39 | + protected $logger; |
|
| 40 | + |
|
| 41 | + /** @var IAppData */ |
|
| 42 | + protected $appData; |
|
| 43 | + |
|
| 44 | + /** @var IURLGenerator */ |
|
| 45 | + protected $urlGenerator; |
|
| 46 | + |
|
| 47 | + /** @var IConfig */ |
|
| 48 | + protected $config; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @param ILogger $logger |
|
| 52 | + * @param IAppData $appData |
|
| 53 | + * @param IURLGenerator $urlGenerator |
|
| 54 | + * @param SystemConfig $systemConfig |
|
| 55 | + */ |
|
| 56 | + public function __construct(ILogger $logger, IAppData $appData, IURLGenerator $urlGenerator, IConfig $config) { |
|
| 57 | + $this->logger = $logger; |
|
| 58 | + $this->appData = $appData; |
|
| 59 | + $this->urlGenerator = $urlGenerator; |
|
| 60 | + $this->config = $config; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Process the caching process if needed |
|
| 65 | + * @param string $root Root path to the nextcloud installation |
|
| 66 | + * @param string $file |
|
| 67 | + * @param string $app The app name |
|
| 68 | + * @return boolean |
|
| 69 | + */ |
|
| 70 | + public function process($root, $file, $app) { |
|
| 71 | + $path = explode('/', $root . '/' . $file); |
|
| 72 | + |
|
| 73 | + $fileNameSCSS = array_pop($path); |
|
| 74 | + $fileNameCSS = str_replace('.scss', '.css', $fileNameSCSS); |
|
| 75 | + |
|
| 76 | + $path = implode('/', $path); |
|
| 77 | + |
|
| 78 | + $webDir = explode('/', $file); |
|
| 79 | + array_pop($webDir); |
|
| 80 | + $webDir = implode('/', $webDir); |
|
| 81 | + |
|
| 82 | + try { |
|
| 83 | + $folder = $this->appData->getFolder($app); |
|
| 84 | + } catch(NotFoundException $e) { |
|
| 85 | + // creating css appdata folder |
|
| 86 | + $folder = $this->appData->newFolder($app); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + if($this->isCached($fileNameCSS, $fileNameSCSS, $folder, $path) && !$this->variablesChanged($fileNameCSS, $folder)) { |
|
| 90 | + return true; |
|
| 91 | + } |
|
| 92 | + return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Check if the file is cached or not |
|
| 97 | + * @param string $fileNameCSS |
|
| 98 | + * @param string $fileNameSCSS |
|
| 99 | + * @param ISimpleFolder $folder |
|
| 100 | + * @param string $path |
|
| 101 | + * @return boolean |
|
| 102 | + */ |
|
| 103 | + private function isCached($fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $path) { |
|
| 104 | + try { |
|
| 105 | + $cachedFile = $folder->getFile($fileNameCSS); |
|
| 106 | + if ($cachedFile->getSize() > 0) { |
|
| 107 | + $depFile = $folder->getFile($fileNameCSS . '.deps'); |
|
| 108 | + $deps = json_decode($depFile->getContent(), true); |
|
| 109 | + |
|
| 110 | + foreach ($deps as $file=>$mtime) { |
|
| 111 | + if (!file_exists($file) || filemtime($file) > $mtime) { |
|
| 112 | + return false; |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + return true; |
|
| 117 | + } catch(NotFoundException $e) { |
|
| 118 | + return false; |
|
| 119 | + } |
|
| 120 | + return false; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Check if the variables file has changed |
|
| 125 | + * @param string $fileNameCSS |
|
| 126 | + * @param ISimpleFolder $folder |
|
| 127 | + * @return bool |
|
| 128 | + */ |
|
| 129 | + private function variablesChanged($fileNameCSS, ISimpleFolder $folder) { |
|
| 130 | + $variablesFile = \OC::$SERVERROOT . '/core/css/variables.scss'; |
|
| 131 | + try { |
|
| 132 | + $cachedFile = $folder->getFile($fileNameCSS); |
|
| 133 | + if ($cachedFile->getMTime() < filemtime($variablesFile) |
|
| 134 | + || $cachedFile->getSize() === 0 |
|
| 135 | + ) { |
|
| 136 | + return true; |
|
| 137 | + } |
|
| 138 | + } catch (NotFoundException $e) { |
|
| 139 | + return true; |
|
| 140 | + } |
|
| 141 | + return false; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * Cache the file with AppData |
|
| 146 | + * @param string $path |
|
| 147 | + * @param string $fileNameCSS |
|
| 148 | + * @param string $fileNameSCSS |
|
| 149 | + * @param ISimpleFolder $folder |
|
| 150 | + * @param string $webDir |
|
| 151 | + * @return boolean |
|
| 152 | + */ |
|
| 153 | + private function cache($path, $fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $webDir) { |
|
| 154 | + $scss = new Compiler(); |
|
| 155 | + $scss->setImportPaths([ |
|
| 156 | + $path, |
|
| 157 | + \OC::$SERVERROOT . '/core/css/', |
|
| 158 | + ]); |
|
| 159 | + if($this->config->getSystemValue('debug')) { |
|
| 160 | + // Debug mode |
|
| 161 | + $scss->setFormatter(Expanded::class); |
|
| 162 | + $scss->setLineNumberStyle(Compiler::LINE_COMMENTS); |
|
| 163 | + } else { |
|
| 164 | + // Compression |
|
| 165 | + $scss->setFormatter(Crunched::class); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + try { |
|
| 169 | + $cachedfile = $folder->getFile($fileNameCSS); |
|
| 170 | + } catch(NotFoundException $e) { |
|
| 171 | + $cachedfile = $folder->newFile($fileNameCSS); |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + $depFileName = $fileNameCSS . '.deps'; |
|
| 175 | + try { |
|
| 176 | + $depFile = $folder->getFile($depFileName); |
|
| 177 | + } catch (NotFoundException $e) { |
|
| 178 | + $depFile = $folder->newFile($depFileName); |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + // Compile |
|
| 182 | + try { |
|
| 183 | + $compiledScss = $scss->compile( |
|
| 184 | + '@import "variables.scss";' . |
|
| 185 | + '@import "'.$fileNameSCSS.'";'); |
|
| 186 | + } catch(ParserException $e) { |
|
| 187 | + $this->logger->error($e, ['app' => 'core']); |
|
| 188 | + return false; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + try { |
|
| 192 | + $cachedfile->putContent($this->rebaseUrls($compiledScss, $webDir)); |
|
| 193 | + $depFile->putContent(json_encode($scss->getParsedFiles())); |
|
| 194 | + $this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']); |
|
| 195 | + return true; |
|
| 196 | + } catch(NotFoundException $e) { |
|
| 197 | + return false; |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Add the correct uri prefix to make uri valid again |
|
| 203 | + * @param string $css |
|
| 204 | + * @param string $webDir |
|
| 205 | + * @return string |
|
| 206 | + */ |
|
| 207 | + private function rebaseUrls($css, $webDir) { |
|
| 208 | + $re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x'; |
|
| 209 | + // OC\Route\Router:75 |
|
| 210 | + if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { |
|
| 211 | + $subst = 'url(\'../../'.$webDir.'/$1\')'; |
|
| 212 | + } else { |
|
| 213 | + $subst = 'url(\'../../../'.$webDir.'/$1\')'; |
|
| 214 | + } |
|
| 215 | + return preg_replace($re, $subst, $css); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * Return the cached css file uri |
|
| 220 | + * @param string $appName the app name |
|
| 221 | + * @param string $fileName |
|
| 222 | + * @return string |
|
| 223 | + */ |
|
| 224 | + public function getCachedSCSS($appName, $fileName) { |
|
| 225 | + $tmpfileLoc = explode('/', $fileName); |
|
| 226 | + $fileName = array_pop($tmpfileLoc); |
|
| 227 | + $fileName = str_replace('.scss', '.css', $fileName); |
|
| 228 | + |
|
| 229 | + return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1); |
|
| 230 | + } |
|
| 231 | 231 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return boolean |
| 69 | 69 | */ |
| 70 | 70 | public function process($root, $file, $app) { |
| 71 | - $path = explode('/', $root . '/' . $file); |
|
| 71 | + $path = explode('/', $root.'/'.$file); |
|
| 72 | 72 | |
| 73 | 73 | $fileNameSCSS = array_pop($path); |
| 74 | 74 | $fileNameCSS = str_replace('.scss', '.css', $fileNameSCSS); |
@@ -81,12 +81,12 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | try { |
| 83 | 83 | $folder = $this->appData->getFolder($app); |
| 84 | - } catch(NotFoundException $e) { |
|
| 84 | + } catch (NotFoundException $e) { |
|
| 85 | 85 | // creating css appdata folder |
| 86 | 86 | $folder = $this->appData->newFolder($app); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if($this->isCached($fileNameCSS, $fileNameSCSS, $folder, $path) && !$this->variablesChanged($fileNameCSS, $folder)) { |
|
| 89 | + if ($this->isCached($fileNameCSS, $fileNameSCSS, $folder, $path) && !$this->variablesChanged($fileNameCSS, $folder)) { |
|
| 90 | 90 | return true; |
| 91 | 91 | } |
| 92 | 92 | return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | try { |
| 105 | 105 | $cachedFile = $folder->getFile($fileNameCSS); |
| 106 | 106 | if ($cachedFile->getSize() > 0) { |
| 107 | - $depFile = $folder->getFile($fileNameCSS . '.deps'); |
|
| 107 | + $depFile = $folder->getFile($fileNameCSS.'.deps'); |
|
| 108 | 108 | $deps = json_decode($depFile->getContent(), true); |
| 109 | 109 | |
| 110 | 110 | foreach ($deps as $file=>$mtime) { |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | return true; |
| 117 | - } catch(NotFoundException $e) { |
|
| 117 | + } catch (NotFoundException $e) { |
|
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | 120 | return false; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @return bool |
| 128 | 128 | */ |
| 129 | 129 | private function variablesChanged($fileNameCSS, ISimpleFolder $folder) { |
| 130 | - $variablesFile = \OC::$SERVERROOT . '/core/css/variables.scss'; |
|
| 130 | + $variablesFile = \OC::$SERVERROOT.'/core/css/variables.scss'; |
|
| 131 | 131 | try { |
| 132 | 132 | $cachedFile = $folder->getFile($fileNameCSS); |
| 133 | 133 | if ($cachedFile->getMTime() < filemtime($variablesFile) |
@@ -154,9 +154,9 @@ discard block |
||
| 154 | 154 | $scss = new Compiler(); |
| 155 | 155 | $scss->setImportPaths([ |
| 156 | 156 | $path, |
| 157 | - \OC::$SERVERROOT . '/core/css/', |
|
| 157 | + \OC::$SERVERROOT.'/core/css/', |
|
| 158 | 158 | ]); |
| 159 | - if($this->config->getSystemValue('debug')) { |
|
| 159 | + if ($this->config->getSystemValue('debug')) { |
|
| 160 | 160 | // Debug mode |
| 161 | 161 | $scss->setFormatter(Expanded::class); |
| 162 | 162 | $scss->setLineNumberStyle(Compiler::LINE_COMMENTS); |
@@ -167,11 +167,11 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | try { |
| 169 | 169 | $cachedfile = $folder->getFile($fileNameCSS); |
| 170 | - } catch(NotFoundException $e) { |
|
| 170 | + } catch (NotFoundException $e) { |
|
| 171 | 171 | $cachedfile = $folder->newFile($fileNameCSS); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - $depFileName = $fileNameCSS . '.deps'; |
|
| 174 | + $depFileName = $fileNameCSS.'.deps'; |
|
| 175 | 175 | try { |
| 176 | 176 | $depFile = $folder->getFile($depFileName); |
| 177 | 177 | } catch (NotFoundException $e) { |
@@ -181,9 +181,9 @@ discard block |
||
| 181 | 181 | // Compile |
| 182 | 182 | try { |
| 183 | 183 | $compiledScss = $scss->compile( |
| 184 | - '@import "variables.scss";' . |
|
| 184 | + '@import "variables.scss";'. |
|
| 185 | 185 | '@import "'.$fileNameSCSS.'";'); |
| 186 | - } catch(ParserException $e) { |
|
| 186 | + } catch (ParserException $e) { |
|
| 187 | 187 | $this->logger->error($e, ['app' => 'core']); |
| 188 | 188 | return false; |
| 189 | 189 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $depFile->putContent(json_encode($scss->getParsedFiles())); |
| 194 | 194 | $this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']); |
| 195 | 195 | return true; |
| 196 | - } catch(NotFoundException $e) { |
|
| 196 | + } catch (NotFoundException $e) { |
|
| 197 | 197 | return false; |
| 198 | 198 | } |
| 199 | 199 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | private function rebaseUrls($css, $webDir) { |
| 208 | 208 | $re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x'; |
| 209 | 209 | // OC\Route\Router:75 |
| 210 | - if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { |
|
| 210 | + if (($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { |
|
| 211 | 211 | $subst = 'url(\'../../'.$webDir.'/$1\')'; |
| 212 | 212 | } else { |
| 213 | 213 | $subst = 'url(\'../../../'.$webDir.'/$1\')'; |
@@ -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->getConfig() |
|
| 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->getConfig() |
|
| 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 | } |