@@ -36,50 +36,50 @@ |
||
36 | 36 | |
37 | 37 | $eventDispatcher = \OC::$server->getEventDispatcher(); |
38 | 38 | $eventDispatcher->addListener( |
39 | - 'OCA\Files::loadAdditionalScripts', |
|
40 | - function() { |
|
41 | - \OCP\Util::addStyle('files_sharing', 'mergedAdditionalStyles'); |
|
42 | - \OCP\Util::addScript('files_sharing', 'additionalScripts'); |
|
43 | - } |
|
39 | + 'OCA\Files::loadAdditionalScripts', |
|
40 | + function() { |
|
41 | + \OCP\Util::addStyle('files_sharing', 'mergedAdditionalStyles'); |
|
42 | + \OCP\Util::addScript('files_sharing', 'additionalScripts'); |
|
43 | + } |
|
44 | 44 | ); |
45 | 45 | |
46 | 46 | $config = \OC::$server->getConfig(); |
47 | 47 | if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') { |
48 | - \OCA\Files\App::getNavigationManager()->add(function () { |
|
49 | - $l = \OC::$server->getL10N('files_sharing'); |
|
50 | - return [ |
|
51 | - 'id' => 'sharingin', |
|
52 | - 'appname' => 'files_sharing', |
|
53 | - 'script' => 'list.php', |
|
54 | - 'order' => 10, |
|
55 | - 'name' => $l->t('Shared with you'), |
|
56 | - ]; |
|
57 | - }); |
|
48 | + \OCA\Files\App::getNavigationManager()->add(function () { |
|
49 | + $l = \OC::$server->getL10N('files_sharing'); |
|
50 | + return [ |
|
51 | + 'id' => 'sharingin', |
|
52 | + 'appname' => 'files_sharing', |
|
53 | + 'script' => 'list.php', |
|
54 | + 'order' => 10, |
|
55 | + 'name' => $l->t('Shared with you'), |
|
56 | + ]; |
|
57 | + }); |
|
58 | 58 | |
59 | - if (\OCP\Util::isSharingDisabledForUser() === false) { |
|
60 | - \OCA\Files\App::getNavigationManager()->add(function () { |
|
61 | - $l = \OC::$server->getL10N('files_sharing'); |
|
62 | - return [ |
|
63 | - 'id' => 'sharingout', |
|
64 | - 'appname' => 'files_sharing', |
|
65 | - 'script' => 'list.php', |
|
66 | - 'order' => 15, |
|
67 | - 'name' => $l->t('Shared with others'), |
|
68 | - ]; |
|
69 | - }); |
|
59 | + if (\OCP\Util::isSharingDisabledForUser() === false) { |
|
60 | + \OCA\Files\App::getNavigationManager()->add(function () { |
|
61 | + $l = \OC::$server->getL10N('files_sharing'); |
|
62 | + return [ |
|
63 | + 'id' => 'sharingout', |
|
64 | + 'appname' => 'files_sharing', |
|
65 | + 'script' => 'list.php', |
|
66 | + 'order' => 15, |
|
67 | + 'name' => $l->t('Shared with others'), |
|
68 | + ]; |
|
69 | + }); |
|
70 | 70 | |
71 | - // Check if sharing by link is enabled |
|
72 | - if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') { |
|
73 | - \OCA\Files\App::getNavigationManager()->add(function () { |
|
74 | - $l = \OC::$server->getL10N('files_sharing'); |
|
75 | - return [ |
|
76 | - 'id' => 'sharinglinks', |
|
77 | - 'appname' => 'files_sharing', |
|
78 | - 'script' => 'list.php', |
|
79 | - 'order' => 20, |
|
80 | - 'name' => $l->t('Shared by link'), |
|
81 | - ]; |
|
82 | - }); |
|
83 | - } |
|
84 | - } |
|
71 | + // Check if sharing by link is enabled |
|
72 | + if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') { |
|
73 | + \OCA\Files\App::getNavigationManager()->add(function () { |
|
74 | + $l = \OC::$server->getL10N('files_sharing'); |
|
75 | + return [ |
|
76 | + 'id' => 'sharinglinks', |
|
77 | + 'appname' => 'files_sharing', |
|
78 | + 'script' => 'list.php', |
|
79 | + 'order' => 20, |
|
80 | + 'name' => $l->t('Shared by link'), |
|
81 | + ]; |
|
82 | + }); |
|
83 | + } |
|
84 | + } |
|
85 | 85 | } |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | |
36 | 36 | $application = new Application(); |
37 | 37 | $application->registerRoutes($this, [ |
38 | - 'routes' => [ |
|
39 | - ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
40 | - ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
41 | - ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
42 | - ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
43 | - ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
44 | - ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
45 | - ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
46 | - ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
47 | - ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
48 | - ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
49 | - ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
50 | - ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
51 | - ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
52 | - ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
53 | - ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
54 | - ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
55 | - ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
56 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'], |
|
57 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
58 | - ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
59 | - ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
60 | - ], |
|
61 | - 'ocs' => [ |
|
62 | - ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
63 | - ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
64 | - ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
65 | - ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
66 | - ], |
|
38 | + 'routes' => [ |
|
39 | + ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
40 | + ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
41 | + ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
42 | + ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
43 | + ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
44 | + ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
45 | + ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
46 | + ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
47 | + ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
48 | + ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
49 | + ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
50 | + ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
51 | + ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
52 | + ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
53 | + ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
54 | + ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
55 | + ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
56 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'], |
|
57 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
58 | + ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
59 | + ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
60 | + ], |
|
61 | + 'ocs' => [ |
|
62 | + ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
63 | + ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
64 | + ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
65 | + ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
66 | + ], |
|
67 | 67 | ]); |
68 | 68 | |
69 | 69 | // Post installation check |
@@ -72,36 +72,36 @@ discard block |
||
72 | 72 | // Core ajax actions |
73 | 73 | // Search |
74 | 74 | $this->create('search_ajax_search', '/core/search') |
75 | - ->actionInclude('core/search/ajax/search.php'); |
|
75 | + ->actionInclude('core/search/ajax/search.php'); |
|
76 | 76 | // Routing |
77 | 77 | $this->create('core_ajax_update', '/core/ajax/update.php') |
78 | - ->actionInclude('core/ajax/update.php'); |
|
78 | + ->actionInclude('core/ajax/update.php'); |
|
79 | 79 | |
80 | 80 | // File routes |
81 | 81 | $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($urlParams) { |
82 | - $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
83 | - $app->dispatch('ViewController', 'index'); |
|
82 | + $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
83 | + $app->dispatch('ViewController', 'index'); |
|
84 | 84 | }); |
85 | 85 | |
86 | 86 | // Sharing routes |
87 | 87 | $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) { |
88 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
89 | - $app->dispatch('ShareController', 'showShare'); |
|
88 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
89 | + $app->dispatch('ShareController', 'showShare'); |
|
90 | 90 | }); |
91 | 91 | $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate')->post()->action(function($urlParams) { |
92 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
93 | - $app->dispatch('ShareController', 'authenticate'); |
|
92 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
93 | + $app->dispatch('ShareController', 'authenticate'); |
|
94 | 94 | }); |
95 | 95 | $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate')->get()->action(function($urlParams) { |
96 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
97 | - $app->dispatch('ShareController', 'showAuthenticate'); |
|
96 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
97 | + $app->dispatch('ShareController', 'showAuthenticate'); |
|
98 | 98 | }); |
99 | 99 | $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) { |
100 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
101 | - $app->dispatch('ShareController', 'downloadShare'); |
|
100 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
101 | + $app->dispatch('ShareController', 'downloadShare'); |
|
102 | 102 | }); |
103 | 103 | |
104 | 104 | // used for heartbeat |
105 | 105 | $this->create('heartbeat', '/heartbeat')->action(function(){ |
106 | - // do nothing |
|
106 | + // do nothing |
|
107 | 107 | }); |
@@ -48,54 +48,54 @@ |
||
48 | 48 | */ |
49 | 49 | class Application extends App { |
50 | 50 | |
51 | - public function __construct() { |
|
52 | - parent::__construct('core'); |
|
51 | + public function __construct() { |
|
52 | + parent::__construct('core'); |
|
53 | 53 | |
54 | - $container = $this->getContainer(); |
|
54 | + $container = $this->getContainer(); |
|
55 | 55 | |
56 | - $container->registerService('defaultMailAddress', function () { |
|
57 | - return Util::getDefaultEmailAddress('lostpassword-noreply'); |
|
58 | - }); |
|
59 | - $container->registerService(Manager::class, function () { |
|
60 | - return new Manager( |
|
61 | - \OC::$server->getAppDataDir('identityproof'), |
|
62 | - \OC::$server->getCrypto() |
|
63 | - ); |
|
64 | - }); |
|
65 | - $container->registerService(CssController::class, function () use ($container) { |
|
66 | - return new CssController( |
|
67 | - $container->query('appName'), |
|
68 | - $container->query(IRequest::class), |
|
69 | - \OC::$server->getAppDataDir('css'), |
|
70 | - $container->query(ITimeFactory::class) |
|
71 | - ); |
|
72 | - }); |
|
73 | - $container->registerService(OCJSController::class, function () use ($container) { |
|
74 | - /** @var Server $server */ |
|
75 | - $server = $container->getServer(); |
|
76 | - return new OCJSController( |
|
77 | - $container->query('appName'), |
|
78 | - $server->getRequest(), |
|
79 | - $server->getL10N('core'), |
|
80 | - // This is required for the theming to overwrite the `OC_Defaults`, see |
|
81 | - // https://github.com/nextcloud/server/issues/3148 |
|
82 | - $server->getThemingDefaults(), |
|
83 | - $server->getAppManager(), |
|
84 | - $server->getSession(), |
|
85 | - $server->getUserSession(), |
|
86 | - $server->getConfig(), |
|
87 | - $server->getGroupManager(), |
|
88 | - $server->getIniWrapper(), |
|
89 | - $server->getURLGenerator() |
|
90 | - ); |
|
91 | - }); |
|
92 | - $container->registerService(JsController::class, function () use ($container) { |
|
93 | - return new JsController( |
|
94 | - $container->query('AppName'), |
|
95 | - $container->query(IRequest::class), |
|
96 | - $container->getServer()->getAppDataDir('js'), |
|
97 | - $container->query(ITimeFactory::class) |
|
98 | - ); |
|
99 | - }); |
|
100 | - } |
|
56 | + $container->registerService('defaultMailAddress', function () { |
|
57 | + return Util::getDefaultEmailAddress('lostpassword-noreply'); |
|
58 | + }); |
|
59 | + $container->registerService(Manager::class, function () { |
|
60 | + return new Manager( |
|
61 | + \OC::$server->getAppDataDir('identityproof'), |
|
62 | + \OC::$server->getCrypto() |
|
63 | + ); |
|
64 | + }); |
|
65 | + $container->registerService(CssController::class, function () use ($container) { |
|
66 | + return new CssController( |
|
67 | + $container->query('appName'), |
|
68 | + $container->query(IRequest::class), |
|
69 | + \OC::$server->getAppDataDir('css'), |
|
70 | + $container->query(ITimeFactory::class) |
|
71 | + ); |
|
72 | + }); |
|
73 | + $container->registerService(OCJSController::class, function () use ($container) { |
|
74 | + /** @var Server $server */ |
|
75 | + $server = $container->getServer(); |
|
76 | + return new OCJSController( |
|
77 | + $container->query('appName'), |
|
78 | + $server->getRequest(), |
|
79 | + $server->getL10N('core'), |
|
80 | + // This is required for the theming to overwrite the `OC_Defaults`, see |
|
81 | + // https://github.com/nextcloud/server/issues/3148 |
|
82 | + $server->getThemingDefaults(), |
|
83 | + $server->getAppManager(), |
|
84 | + $server->getSession(), |
|
85 | + $server->getUserSession(), |
|
86 | + $server->getConfig(), |
|
87 | + $server->getGroupManager(), |
|
88 | + $server->getIniWrapper(), |
|
89 | + $server->getURLGenerator() |
|
90 | + ); |
|
91 | + }); |
|
92 | + $container->registerService(JsController::class, function () use ($container) { |
|
93 | + return new JsController( |
|
94 | + $container->query('AppName'), |
|
95 | + $container->query(IRequest::class), |
|
96 | + $container->getServer()->getAppDataDir('js'), |
|
97 | + $container->query(ITimeFactory::class) |
|
98 | + ); |
|
99 | + }); |
|
100 | + } |
|
101 | 101 | } |
@@ -33,48 +33,48 @@ |
||
33 | 33 | |
34 | 34 | class JsController extends Controller { |
35 | 35 | |
36 | - /** @var IAppData */ |
|
37 | - protected $appData; |
|
36 | + /** @var IAppData */ |
|
37 | + protected $appData; |
|
38 | 38 | |
39 | - /** @var ITimeFactory */ |
|
40 | - protected $timeFactory; |
|
39 | + /** @var ITimeFactory */ |
|
40 | + protected $timeFactory; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param string $appName |
|
44 | - * @param IRequest $request |
|
45 | - * @param IAppData $appData |
|
46 | - * @param ITimeFactory $timeFactory |
|
47 | - */ |
|
48 | - public function __construct($appName, IRequest $request, IAppData $appData, ITimeFactory $timeFactory) { |
|
49 | - parent::__construct($appName, $request); |
|
42 | + /** |
|
43 | + * @param string $appName |
|
44 | + * @param IRequest $request |
|
45 | + * @param IAppData $appData |
|
46 | + * @param ITimeFactory $timeFactory |
|
47 | + */ |
|
48 | + public function __construct($appName, IRequest $request, IAppData $appData, ITimeFactory $timeFactory) { |
|
49 | + parent::__construct($appName, $request); |
|
50 | 50 | |
51 | - $this->appData = $appData; |
|
52 | - $this->timeFactory = $timeFactory; |
|
53 | - } |
|
51 | + $this->appData = $appData; |
|
52 | + $this->timeFactory = $timeFactory; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @PublicPage |
|
57 | - * @NoCSRFRequired |
|
58 | - * |
|
59 | - * @param string $fileName css filename with extension |
|
60 | - * @param string $appName css folder name |
|
61 | - * @return FileDisplayResponse|NotFoundResponse |
|
62 | - */ |
|
63 | - public function getJs($fileName, $appName) { |
|
64 | - try { |
|
65 | - $folder = $this->appData->getFolder($appName); |
|
66 | - $jsFile = $folder->getFile($fileName); |
|
67 | - } catch(NotFoundException $e) { |
|
68 | - return new NotFoundResponse(); |
|
69 | - } |
|
55 | + /** |
|
56 | + * @PublicPage |
|
57 | + * @NoCSRFRequired |
|
58 | + * |
|
59 | + * @param string $fileName css filename with extension |
|
60 | + * @param string $appName css folder name |
|
61 | + * @return FileDisplayResponse|NotFoundResponse |
|
62 | + */ |
|
63 | + public function getJs($fileName, $appName) { |
|
64 | + try { |
|
65 | + $folder = $this->appData->getFolder($appName); |
|
66 | + $jsFile = $folder->getFile($fileName); |
|
67 | + } catch(NotFoundException $e) { |
|
68 | + return new NotFoundResponse(); |
|
69 | + } |
|
70 | 70 | |
71 | - $response = new FileDisplayResponse($jsFile, Http::STATUS_OK, ['Content-Type' => 'application/javascript']); |
|
72 | - $response->cacheFor(86400); |
|
73 | - $expires = new \DateTime(); |
|
74 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
75 | - $expires->add(new \DateInterval('PT24H')); |
|
76 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC1123)); |
|
77 | - $response->addHeader('Pragma', 'cache'); |
|
78 | - return $response; |
|
79 | - } |
|
71 | + $response = new FileDisplayResponse($jsFile, Http::STATUS_OK, ['Content-Type' => 'application/javascript']); |
|
72 | + $response->cacheFor(86400); |
|
73 | + $expires = new \DateTime(); |
|
74 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
75 | + $expires->add(new \DateInterval('PT24H')); |
|
76 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC1123)); |
|
77 | + $response->addHeader('Pragma', 'cache'); |
|
78 | + return $response; |
|
79 | + } |
|
80 | 80 | } |
@@ -32,168 +32,168 @@ |
||
32 | 32 | |
33 | 33 | class JSCombiner { |
34 | 34 | |
35 | - /** @var IAppData */ |
|
36 | - protected $appData; |
|
37 | - |
|
38 | - /** @var IURLGenerator */ |
|
39 | - protected $urlGenerator; |
|
40 | - |
|
41 | - /** @var ICache */ |
|
42 | - protected $depsCache; |
|
43 | - |
|
44 | - /** @var SystemConfig */ |
|
45 | - protected $config; |
|
46 | - |
|
47 | - /** |
|
48 | - * JSCombiner constructor. |
|
49 | - * |
|
50 | - * @param IAppData $appData |
|
51 | - * @param IURLGenerator $urlGenerator |
|
52 | - * @param ICache $depsCache |
|
53 | - */ |
|
54 | - public function __construct(IAppData $appData, |
|
55 | - IURLGenerator $urlGenerator, |
|
56 | - ICache $depsCache, |
|
57 | - SystemConfig $config) { |
|
58 | - $this->appData = $appData; |
|
59 | - $this->urlGenerator = $urlGenerator; |
|
60 | - $this->depsCache = $depsCache; |
|
61 | - $this->config = $config; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * @param string $root |
|
66 | - * @param string $file |
|
67 | - * @param string $app |
|
68 | - * @return bool |
|
69 | - */ |
|
70 | - public function process($root, $file, $app) { |
|
71 | - if ($this->config->getValue('debug')) { |
|
72 | - return false; |
|
73 | - } |
|
74 | - |
|
75 | - $path = explode('/', $root . '/' . $file); |
|
76 | - |
|
77 | - $fileName = array_pop($path); |
|
78 | - $path = implode('/', $path); |
|
79 | - |
|
80 | - try { |
|
81 | - $folder = $this->appData->getFolder($app); |
|
82 | - } catch(NotFoundException $e) { |
|
83 | - // creating css appdata folder |
|
84 | - $folder = $this->appData->newFolder($app); |
|
85 | - } |
|
86 | - |
|
87 | - if($this->isCached($fileName, $folder)) { |
|
88 | - return true; |
|
89 | - } |
|
90 | - return $this->cache($path, $fileName, $folder); |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * @param string $fileName |
|
95 | - * @param ISimpleFolder $folder |
|
96 | - * @return bool |
|
97 | - */ |
|
98 | - protected function isCached($fileName, ISimpleFolder $folder) { |
|
99 | - $fileName = str_replace('.json', '.js', $fileName) . '.deps'; |
|
100 | - try { |
|
101 | - $deps = $this->depsCache->get($folder->getName() . '-' . $fileName); |
|
102 | - if ($deps === null) { |
|
103 | - $depFile = $folder->getFile($fileName); |
|
104 | - $deps = $depFile->getContent(); |
|
105 | - $this->depsCache->set($folder->getName() . '-' . $fileName, $deps); |
|
106 | - } |
|
107 | - $deps = json_decode($deps, true); |
|
108 | - |
|
109 | - foreach ($deps as $file=>$mtime) { |
|
110 | - if (!file_exists($file) || filemtime($file) > $mtime) { |
|
111 | - return false; |
|
112 | - } |
|
113 | - } |
|
114 | - |
|
115 | - return true; |
|
116 | - } catch(NotFoundException $e) { |
|
117 | - return false; |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * @param string $path |
|
123 | - * @param string $fileName |
|
124 | - * @param ISimpleFolder $folder |
|
125 | - * @return bool |
|
126 | - */ |
|
127 | - protected function cache($path, $fileName, ISimpleFolder $folder) { |
|
128 | - $deps = []; |
|
129 | - $fullPath = $path . '/' . $fileName; |
|
130 | - $data = json_decode(file_get_contents($fullPath)); |
|
131 | - $deps[$fullPath] = filemtime($fullPath); |
|
132 | - |
|
133 | - $res = ''; |
|
134 | - foreach ($data as $file) { |
|
135 | - $filePath = $path . '/' . $file; |
|
136 | - |
|
137 | - if (is_file($filePath)) { |
|
138 | - $res .= file_get_contents($filePath); |
|
139 | - $res .= PHP_EOL . PHP_EOL; |
|
140 | - $deps[$filePath] = filemtime($filePath); |
|
141 | - } |
|
142 | - } |
|
143 | - |
|
144 | - $fileName = str_replace('.json', '.js', $fileName); |
|
145 | - try { |
|
146 | - $cachedfile = $folder->getFile($fileName); |
|
147 | - } catch(NotFoundException $e) { |
|
148 | - $cachedfile = $folder->newFile($fileName); |
|
149 | - } |
|
150 | - |
|
151 | - $depFileName = $fileName . '.deps'; |
|
152 | - try { |
|
153 | - $depFile = $folder->getFile($depFileName); |
|
154 | - } catch (NotFoundException $e) { |
|
155 | - $depFile = $folder->newFile($depFileName); |
|
156 | - } |
|
157 | - |
|
158 | - try { |
|
159 | - $cachedfile->putContent($res); |
|
160 | - $depFile->putContent(json_encode($deps)); |
|
161 | - return true; |
|
162 | - } catch (NotPermittedException $e) { |
|
163 | - return false; |
|
164 | - } |
|
165 | - } |
|
166 | - |
|
167 | - /** |
|
168 | - * @param string $appName |
|
169 | - * @param string $fileName |
|
170 | - * @return string |
|
171 | - */ |
|
172 | - public function getCachedJS($appName, $fileName) { |
|
173 | - $tmpfileLoc = explode('/', $fileName); |
|
174 | - $fileName = array_pop($tmpfileLoc); |
|
175 | - $fileName = str_replace('.json', '.js', $fileName); |
|
176 | - |
|
177 | - return substr($this->urlGenerator->linkToRoute('core.Js.getJs', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1); |
|
178 | - } |
|
179 | - |
|
180 | - /** |
|
181 | - * @param string $root |
|
182 | - * @param string $file |
|
183 | - * @return string[] |
|
184 | - */ |
|
185 | - public function getContent($root, $file) { |
|
186 | - $data = json_decode(file_get_contents($root . '/' . $file)); |
|
187 | - |
|
188 | - $path = explode('/', $file); |
|
189 | - array_pop($path); |
|
190 | - $path = implode('/', $path); |
|
191 | - |
|
192 | - $result = []; |
|
193 | - foreach ($data as $f) { |
|
194 | - $result[] = $path . '/' . $f; |
|
195 | - } |
|
196 | - |
|
197 | - return $result; |
|
198 | - } |
|
35 | + /** @var IAppData */ |
|
36 | + protected $appData; |
|
37 | + |
|
38 | + /** @var IURLGenerator */ |
|
39 | + protected $urlGenerator; |
|
40 | + |
|
41 | + /** @var ICache */ |
|
42 | + protected $depsCache; |
|
43 | + |
|
44 | + /** @var SystemConfig */ |
|
45 | + protected $config; |
|
46 | + |
|
47 | + /** |
|
48 | + * JSCombiner constructor. |
|
49 | + * |
|
50 | + * @param IAppData $appData |
|
51 | + * @param IURLGenerator $urlGenerator |
|
52 | + * @param ICache $depsCache |
|
53 | + */ |
|
54 | + public function __construct(IAppData $appData, |
|
55 | + IURLGenerator $urlGenerator, |
|
56 | + ICache $depsCache, |
|
57 | + SystemConfig $config) { |
|
58 | + $this->appData = $appData; |
|
59 | + $this->urlGenerator = $urlGenerator; |
|
60 | + $this->depsCache = $depsCache; |
|
61 | + $this->config = $config; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * @param string $root |
|
66 | + * @param string $file |
|
67 | + * @param string $app |
|
68 | + * @return bool |
|
69 | + */ |
|
70 | + public function process($root, $file, $app) { |
|
71 | + if ($this->config->getValue('debug')) { |
|
72 | + return false; |
|
73 | + } |
|
74 | + |
|
75 | + $path = explode('/', $root . '/' . $file); |
|
76 | + |
|
77 | + $fileName = array_pop($path); |
|
78 | + $path = implode('/', $path); |
|
79 | + |
|
80 | + try { |
|
81 | + $folder = $this->appData->getFolder($app); |
|
82 | + } catch(NotFoundException $e) { |
|
83 | + // creating css appdata folder |
|
84 | + $folder = $this->appData->newFolder($app); |
|
85 | + } |
|
86 | + |
|
87 | + if($this->isCached($fileName, $folder)) { |
|
88 | + return true; |
|
89 | + } |
|
90 | + return $this->cache($path, $fileName, $folder); |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * @param string $fileName |
|
95 | + * @param ISimpleFolder $folder |
|
96 | + * @return bool |
|
97 | + */ |
|
98 | + protected function isCached($fileName, ISimpleFolder $folder) { |
|
99 | + $fileName = str_replace('.json', '.js', $fileName) . '.deps'; |
|
100 | + try { |
|
101 | + $deps = $this->depsCache->get($folder->getName() . '-' . $fileName); |
|
102 | + if ($deps === null) { |
|
103 | + $depFile = $folder->getFile($fileName); |
|
104 | + $deps = $depFile->getContent(); |
|
105 | + $this->depsCache->set($folder->getName() . '-' . $fileName, $deps); |
|
106 | + } |
|
107 | + $deps = json_decode($deps, true); |
|
108 | + |
|
109 | + foreach ($deps as $file=>$mtime) { |
|
110 | + if (!file_exists($file) || filemtime($file) > $mtime) { |
|
111 | + return false; |
|
112 | + } |
|
113 | + } |
|
114 | + |
|
115 | + return true; |
|
116 | + } catch(NotFoundException $e) { |
|
117 | + return false; |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * @param string $path |
|
123 | + * @param string $fileName |
|
124 | + * @param ISimpleFolder $folder |
|
125 | + * @return bool |
|
126 | + */ |
|
127 | + protected function cache($path, $fileName, ISimpleFolder $folder) { |
|
128 | + $deps = []; |
|
129 | + $fullPath = $path . '/' . $fileName; |
|
130 | + $data = json_decode(file_get_contents($fullPath)); |
|
131 | + $deps[$fullPath] = filemtime($fullPath); |
|
132 | + |
|
133 | + $res = ''; |
|
134 | + foreach ($data as $file) { |
|
135 | + $filePath = $path . '/' . $file; |
|
136 | + |
|
137 | + if (is_file($filePath)) { |
|
138 | + $res .= file_get_contents($filePath); |
|
139 | + $res .= PHP_EOL . PHP_EOL; |
|
140 | + $deps[$filePath] = filemtime($filePath); |
|
141 | + } |
|
142 | + } |
|
143 | + |
|
144 | + $fileName = str_replace('.json', '.js', $fileName); |
|
145 | + try { |
|
146 | + $cachedfile = $folder->getFile($fileName); |
|
147 | + } catch(NotFoundException $e) { |
|
148 | + $cachedfile = $folder->newFile($fileName); |
|
149 | + } |
|
150 | + |
|
151 | + $depFileName = $fileName . '.deps'; |
|
152 | + try { |
|
153 | + $depFile = $folder->getFile($depFileName); |
|
154 | + } catch (NotFoundException $e) { |
|
155 | + $depFile = $folder->newFile($depFileName); |
|
156 | + } |
|
157 | + |
|
158 | + try { |
|
159 | + $cachedfile->putContent($res); |
|
160 | + $depFile->putContent(json_encode($deps)); |
|
161 | + return true; |
|
162 | + } catch (NotPermittedException $e) { |
|
163 | + return false; |
|
164 | + } |
|
165 | + } |
|
166 | + |
|
167 | + /** |
|
168 | + * @param string $appName |
|
169 | + * @param string $fileName |
|
170 | + * @return string |
|
171 | + */ |
|
172 | + public function getCachedJS($appName, $fileName) { |
|
173 | + $tmpfileLoc = explode('/', $fileName); |
|
174 | + $fileName = array_pop($tmpfileLoc); |
|
175 | + $fileName = str_replace('.json', '.js', $fileName); |
|
176 | + |
|
177 | + return substr($this->urlGenerator->linkToRoute('core.Js.getJs', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1); |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * @param string $root |
|
182 | + * @param string $file |
|
183 | + * @return string[] |
|
184 | + */ |
|
185 | + public function getContent($root, $file) { |
|
186 | + $data = json_decode(file_get_contents($root . '/' . $file)); |
|
187 | + |
|
188 | + $path = explode('/', $file); |
|
189 | + array_pop($path); |
|
190 | + $path = implode('/', $path); |
|
191 | + |
|
192 | + $result = []; |
|
193 | + foreach ($data as $f) { |
|
194 | + $result[] = $path . '/' . $f; |
|
195 | + } |
|
196 | + |
|
197 | + return $result; |
|
198 | + } |
|
199 | 199 | } |
@@ -27,86 +27,86 @@ |
||
27 | 27 | |
28 | 28 | class JSResourceLocator extends ResourceLocator { |
29 | 29 | |
30 | - /** @var JSCombiner */ |
|
31 | - protected $jsCombiner; |
|
30 | + /** @var JSCombiner */ |
|
31 | + protected $jsCombiner; |
|
32 | 32 | |
33 | - public function __construct(\OCP\ILogger $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) { |
|
34 | - parent::__construct($logger, $theme, $core_map, $party_map); |
|
33 | + public function __construct(\OCP\ILogger $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) { |
|
34 | + parent::__construct($logger, $theme, $core_map, $party_map); |
|
35 | 35 | |
36 | - $this->jsCombiner = $JSCombiner; |
|
37 | - } |
|
36 | + $this->jsCombiner = $JSCombiner; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param string $script |
|
41 | - */ |
|
42 | - public function doFind($script) { |
|
43 | - $theme_dir = 'themes/'.$this->theme.'/'; |
|
44 | - if (strpos($script, '3rdparty') === 0 |
|
45 | - && $this->appendIfExist($this->thirdpartyroot, $script.'.js')) { |
|
46 | - return; |
|
47 | - } |
|
39 | + /** |
|
40 | + * @param string $script |
|
41 | + */ |
|
42 | + public function doFind($script) { |
|
43 | + $theme_dir = 'themes/'.$this->theme.'/'; |
|
44 | + if (strpos($script, '3rdparty') === 0 |
|
45 | + && $this->appendIfExist($this->thirdpartyroot, $script.'.js')) { |
|
46 | + return; |
|
47 | + } |
|
48 | 48 | |
49 | - if (strpos($script, '/l10n/') !== false) { |
|
50 | - // For language files we try to load them all, so themes can overwrite |
|
51 | - // single l10n strings without having to translate all of them. |
|
52 | - $found = 0; |
|
53 | - $found += $this->appendIfExist($this->serverroot, 'core/'.$script.'.js'); |
|
54 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js'); |
|
55 | - $found += $this->appendIfExist($this->serverroot, $script.'.js'); |
|
56 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js'); |
|
57 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js'); |
|
49 | + if (strpos($script, '/l10n/') !== false) { |
|
50 | + // For language files we try to load them all, so themes can overwrite |
|
51 | + // single l10n strings without having to translate all of them. |
|
52 | + $found = 0; |
|
53 | + $found += $this->appendIfExist($this->serverroot, 'core/'.$script.'.js'); |
|
54 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js'); |
|
55 | + $found += $this->appendIfExist($this->serverroot, $script.'.js'); |
|
56 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js'); |
|
57 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js'); |
|
58 | 58 | |
59 | - if ($found) { |
|
60 | - return; |
|
61 | - } |
|
62 | - } else if ($this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js') |
|
63 | - || $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js') |
|
64 | - || $this->appendIfExist($this->serverroot, $script.'.js') |
|
65 | - || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, $script.'.json') |
|
66 | - || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js') |
|
67 | - || $this->appendIfExist($this->serverroot, 'core/'.$script.'.js') |
|
68 | - || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, 'core/'.$script.'.json') |
|
69 | - ) { |
|
70 | - return; |
|
71 | - } |
|
59 | + if ($found) { |
|
60 | + return; |
|
61 | + } |
|
62 | + } else if ($this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js') |
|
63 | + || $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js') |
|
64 | + || $this->appendIfExist($this->serverroot, $script.'.js') |
|
65 | + || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, $script.'.json') |
|
66 | + || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js') |
|
67 | + || $this->appendIfExist($this->serverroot, 'core/'.$script.'.js') |
|
68 | + || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, 'core/'.$script.'.json') |
|
69 | + ) { |
|
70 | + return; |
|
71 | + } |
|
72 | 72 | |
73 | - $app = substr($script, 0, strpos($script, '/')); |
|
74 | - $script = substr($script, strpos($script, '/')+1); |
|
75 | - $app_path = \OC_App::getAppPath($app); |
|
76 | - $app_url = \OC_App::getAppWebPath($app); |
|
73 | + $app = substr($script, 0, strpos($script, '/')); |
|
74 | + $script = substr($script, strpos($script, '/')+1); |
|
75 | + $app_path = \OC_App::getAppPath($app); |
|
76 | + $app_url = \OC_App::getAppWebPath($app); |
|
77 | 77 | |
78 | - // missing translations files fill be ignored |
|
79 | - if (strpos($script, 'l10n/') === 0) { |
|
80 | - $this->appendIfExist($app_path, $script . '.js', $app_url); |
|
81 | - return; |
|
82 | - } |
|
83 | - if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) { |
|
84 | - $this->append($app_path, $script . '.js', $app_url); |
|
85 | - } |
|
86 | - } |
|
78 | + // missing translations files fill be ignored |
|
79 | + if (strpos($script, 'l10n/') === 0) { |
|
80 | + $this->appendIfExist($app_path, $script . '.js', $app_url); |
|
81 | + return; |
|
82 | + } |
|
83 | + if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) { |
|
84 | + $this->append($app_path, $script . '.js', $app_url); |
|
85 | + } |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * @param string $script |
|
90 | - */ |
|
91 | - public function doFindTheme($script) { |
|
92 | - } |
|
88 | + /** |
|
89 | + * @param string $script |
|
90 | + */ |
|
91 | + public function doFindTheme($script) { |
|
92 | + } |
|
93 | 93 | |
94 | - protected function cacheAndAppendCombineJsonIfExist($root, $file, $app = 'core') { |
|
95 | - if (is_file($root.'/'.$file)) { |
|
96 | - if ($this->jsCombiner->process($root, $file, $app)) { |
|
97 | - $this->append($this->serverroot, $this->jsCombiner->getCachedJS($app, $file), false, false); |
|
98 | - } else { |
|
99 | - // Add all the files from the json |
|
100 | - $files = $this->jsCombiner->getContent($root, $file); |
|
101 | - $app_url = \OC_App::getAppWebPath($app); |
|
94 | + protected function cacheAndAppendCombineJsonIfExist($root, $file, $app = 'core') { |
|
95 | + if (is_file($root.'/'.$file)) { |
|
96 | + if ($this->jsCombiner->process($root, $file, $app)) { |
|
97 | + $this->append($this->serverroot, $this->jsCombiner->getCachedJS($app, $file), false, false); |
|
98 | + } else { |
|
99 | + // Add all the files from the json |
|
100 | + $files = $this->jsCombiner->getContent($root, $file); |
|
101 | + $app_url = \OC_App::getAppWebPath($app); |
|
102 | 102 | |
103 | - foreach ($files as $jsFile) { |
|
104 | - $this->append($root, $jsFile, $app_url); |
|
105 | - } |
|
106 | - } |
|
107 | - return true; |
|
108 | - } |
|
103 | + foreach ($files as $jsFile) { |
|
104 | + $this->append($root, $jsFile, $app_url); |
|
105 | + } |
|
106 | + } |
|
107 | + return true; |
|
108 | + } |
|
109 | 109 | |
110 | - return false; |
|
111 | - } |
|
110 | + return false; |
|
111 | + } |
|
112 | 112 | } |
@@ -41,239 +41,239 @@ |
||
41 | 41 | |
42 | 42 | class TemplateLayout extends \OC_Template { |
43 | 43 | |
44 | - private static $versionHash = ''; |
|
44 | + private static $versionHash = ''; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @var \OCP\IConfig |
|
48 | - */ |
|
49 | - private $config; |
|
46 | + /** |
|
47 | + * @var \OCP\IConfig |
|
48 | + */ |
|
49 | + private $config; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @param string $renderAs |
|
53 | - * @param string $appId application id |
|
54 | - */ |
|
55 | - public function __construct( $renderAs, $appId = '' ) { |
|
51 | + /** |
|
52 | + * @param string $renderAs |
|
53 | + * @param string $appId application id |
|
54 | + */ |
|
55 | + public function __construct( $renderAs, $appId = '' ) { |
|
56 | 56 | |
57 | - // yes - should be injected .... |
|
58 | - $this->config = \OC::$server->getConfig(); |
|
57 | + // yes - should be injected .... |
|
58 | + $this->config = \OC::$server->getConfig(); |
|
59 | 59 | |
60 | - // Decide which page we show |
|
61 | - if($renderAs == 'user') { |
|
62 | - parent::__construct( 'core', 'layout.user' ); |
|
63 | - if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
64 | - $this->assign('bodyid', 'body-settings'); |
|
65 | - }else{ |
|
66 | - $this->assign('bodyid', 'body-user'); |
|
67 | - } |
|
60 | + // Decide which page we show |
|
61 | + if($renderAs == 'user') { |
|
62 | + parent::__construct( 'core', 'layout.user' ); |
|
63 | + if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) { |
|
64 | + $this->assign('bodyid', 'body-settings'); |
|
65 | + }else{ |
|
66 | + $this->assign('bodyid', 'body-user'); |
|
67 | + } |
|
68 | 68 | |
69 | - // Code integrity notification |
|
70 | - $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
|
71 | - if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
72 | - \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
|
73 | - } |
|
69 | + // Code integrity notification |
|
70 | + $integrityChecker = \OC::$server->getIntegrityCodeChecker(); |
|
71 | + if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) { |
|
72 | + \OCP\Util::addScript('core', 'integritycheck-failed-notification'); |
|
73 | + } |
|
74 | 74 | |
75 | - // Add navigation entry |
|
76 | - $this->assign( 'application', ''); |
|
77 | - $this->assign( 'appid', $appId ); |
|
78 | - $navigation = \OC_App::getNavigation(); |
|
79 | - $this->assign( 'navigation', $navigation); |
|
80 | - $navigation = \OC_App::getHeaderNavigation(); |
|
81 | - $this->assign( 'headernavigation', $navigation); |
|
82 | - $settingsNavigation = \OC_App::getSettingsNavigation(); |
|
83 | - $this->assign( 'settingsnavigation', $settingsNavigation); |
|
84 | - foreach($navigation as $entry) { |
|
85 | - if ($entry['active']) { |
|
86 | - $this->assign( 'application', $entry['name'] ); |
|
87 | - break; |
|
88 | - } |
|
89 | - } |
|
75 | + // Add navigation entry |
|
76 | + $this->assign( 'application', ''); |
|
77 | + $this->assign( 'appid', $appId ); |
|
78 | + $navigation = \OC_App::getNavigation(); |
|
79 | + $this->assign( 'navigation', $navigation); |
|
80 | + $navigation = \OC_App::getHeaderNavigation(); |
|
81 | + $this->assign( 'headernavigation', $navigation); |
|
82 | + $settingsNavigation = \OC_App::getSettingsNavigation(); |
|
83 | + $this->assign( 'settingsnavigation', $settingsNavigation); |
|
84 | + foreach($navigation as $entry) { |
|
85 | + if ($entry['active']) { |
|
86 | + $this->assign( 'application', $entry['name'] ); |
|
87 | + break; |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - foreach($settingsNavigation as $entry) { |
|
92 | - if ($entry['active']) { |
|
93 | - $this->assign( 'application', $entry['name'] ); |
|
94 | - break; |
|
95 | - } |
|
96 | - } |
|
97 | - $userDisplayName = \OC_User::getDisplayName(); |
|
98 | - $appsMgmtActive = strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0; |
|
99 | - if ($appsMgmtActive) { |
|
100 | - $l = \OC::$server->getL10N('lib'); |
|
101 | - $this->assign('application', $l->t('Apps')); |
|
102 | - } |
|
103 | - $this->assign('user_displayname', $userDisplayName); |
|
104 | - $this->assign('user_uid', \OC_User::getUser()); |
|
105 | - $this->assign('appsmanagement_active', $appsMgmtActive); |
|
91 | + foreach($settingsNavigation as $entry) { |
|
92 | + if ($entry['active']) { |
|
93 | + $this->assign( 'application', $entry['name'] ); |
|
94 | + break; |
|
95 | + } |
|
96 | + } |
|
97 | + $userDisplayName = \OC_User::getDisplayName(); |
|
98 | + $appsMgmtActive = strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0; |
|
99 | + if ($appsMgmtActive) { |
|
100 | + $l = \OC::$server->getL10N('lib'); |
|
101 | + $this->assign('application', $l->t('Apps')); |
|
102 | + } |
|
103 | + $this->assign('user_displayname', $userDisplayName); |
|
104 | + $this->assign('user_uid', \OC_User::getUser()); |
|
105 | + $this->assign('appsmanagement_active', $appsMgmtActive); |
|
106 | 106 | |
107 | - if (\OC_User::getUser() === false) { |
|
108 | - $this->assign('userAvatarSet', false); |
|
109 | - } else { |
|
110 | - $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
111 | - $this->assign('userAvatarVersion', \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
112 | - } |
|
107 | + if (\OC_User::getUser() === false) { |
|
108 | + $this->assign('userAvatarSet', false); |
|
109 | + } else { |
|
110 | + $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists()); |
|
111 | + $this->assign('userAvatarVersion', \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0)); |
|
112 | + } |
|
113 | 113 | |
114 | - } else if ($renderAs == 'error') { |
|
115 | - parent::__construct('core', 'layout.guest', '', false); |
|
116 | - $this->assign('bodyid', 'body-login'); |
|
117 | - } else if ($renderAs == 'guest') { |
|
118 | - parent::__construct('core', 'layout.guest'); |
|
119 | - $this->assign('bodyid', 'body-login'); |
|
120 | - } else { |
|
121 | - parent::__construct('core', 'layout.base'); |
|
114 | + } else if ($renderAs == 'error') { |
|
115 | + parent::__construct('core', 'layout.guest', '', false); |
|
116 | + $this->assign('bodyid', 'body-login'); |
|
117 | + } else if ($renderAs == 'guest') { |
|
118 | + parent::__construct('core', 'layout.guest'); |
|
119 | + $this->assign('bodyid', 'body-login'); |
|
120 | + } else { |
|
121 | + parent::__construct('core', 'layout.base'); |
|
122 | 122 | |
123 | - } |
|
124 | - // Send the language to our layouts |
|
125 | - $this->assign('language', \OC::$server->getL10NFactory()->findLanguage()); |
|
123 | + } |
|
124 | + // Send the language to our layouts |
|
125 | + $this->assign('language', \OC::$server->getL10NFactory()->findLanguage()); |
|
126 | 126 | |
127 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
128 | - if (empty(self::$versionHash)) { |
|
129 | - $v = \OC_App::getAppVersions(); |
|
130 | - $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
131 | - self::$versionHash = md5(implode(',', $v)); |
|
132 | - } |
|
133 | - } else { |
|
134 | - self::$versionHash = md5('not installed'); |
|
135 | - } |
|
127 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
128 | + if (empty(self::$versionHash)) { |
|
129 | + $v = \OC_App::getAppVersions(); |
|
130 | + $v['core'] = implode('.', \OCP\Util::getVersion()); |
|
131 | + self::$versionHash = md5(implode(',', $v)); |
|
132 | + } |
|
133 | + } else { |
|
134 | + self::$versionHash = md5('not installed'); |
|
135 | + } |
|
136 | 136 | |
137 | - // Add the js files |
|
138 | - $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
139 | - $this->assign('jsfiles', array()); |
|
140 | - if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
141 | - if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
142 | - $jsConfigHelper = new JSConfigHelper( |
|
143 | - \OC::$server->getL10N('core'), |
|
144 | - \OC::$server->getThemingDefaults(), |
|
145 | - \OC::$server->getAppManager(), |
|
146 | - \OC::$server->getSession(), |
|
147 | - \OC::$server->getUserSession()->getUser(), |
|
148 | - \OC::$server->getConfig(), |
|
149 | - \OC::$server->getGroupManager(), |
|
150 | - \OC::$server->getIniWrapper(), |
|
151 | - \OC::$server->getURLGenerator() |
|
152 | - ); |
|
153 | - $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
154 | - } else { |
|
155 | - $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
156 | - } |
|
157 | - } |
|
158 | - foreach($jsFiles as $info) { |
|
159 | - $web = $info[1]; |
|
160 | - $file = $info[2]; |
|
161 | - $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
162 | - } |
|
137 | + // Add the js files |
|
138 | + $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts); |
|
139 | + $this->assign('jsfiles', array()); |
|
140 | + if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') { |
|
141 | + if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { |
|
142 | + $jsConfigHelper = new JSConfigHelper( |
|
143 | + \OC::$server->getL10N('core'), |
|
144 | + \OC::$server->getThemingDefaults(), |
|
145 | + \OC::$server->getAppManager(), |
|
146 | + \OC::$server->getSession(), |
|
147 | + \OC::$server->getUserSession()->getUser(), |
|
148 | + \OC::$server->getConfig(), |
|
149 | + \OC::$server->getGroupManager(), |
|
150 | + \OC::$server->getIniWrapper(), |
|
151 | + \OC::$server->getURLGenerator() |
|
152 | + ); |
|
153 | + $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); |
|
154 | + } else { |
|
155 | + $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash])); |
|
156 | + } |
|
157 | + } |
|
158 | + foreach($jsFiles as $info) { |
|
159 | + $web = $info[1]; |
|
160 | + $file = $info[2]; |
|
161 | + $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
162 | + } |
|
163 | 163 | |
164 | - try { |
|
165 | - $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
166 | - } catch (\Exception $e) { |
|
167 | - $pathInfo = ''; |
|
168 | - } |
|
164 | + try { |
|
165 | + $pathInfo = \OC::$server->getRequest()->getPathInfo(); |
|
166 | + } catch (\Exception $e) { |
|
167 | + $pathInfo = ''; |
|
168 | + } |
|
169 | 169 | |
170 | - // Do not initialise scss appdata until we have a fully installed instance |
|
171 | - // Do not load scss for update, errors, installation or login page |
|
172 | - if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
173 | - && !\OCP\Util::needUpgrade() |
|
174 | - && $pathInfo !== '' |
|
175 | - && !preg_match('/^\/login/', $pathInfo)) { |
|
176 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
177 | - } else { |
|
178 | - // If we ignore the scss compiler, |
|
179 | - // we need to load the guest css fallback |
|
180 | - \OC_Util::addStyle('guest'); |
|
181 | - $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
182 | - } |
|
170 | + // Do not initialise scss appdata until we have a fully installed instance |
|
171 | + // Do not load scss for update, errors, installation or login page |
|
172 | + if(\OC::$server->getSystemConfig()->getValue('installed', false) |
|
173 | + && !\OCP\Util::needUpgrade() |
|
174 | + && $pathInfo !== '' |
|
175 | + && !preg_match('/^\/login/', $pathInfo)) { |
|
176 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles); |
|
177 | + } else { |
|
178 | + // If we ignore the scss compiler, |
|
179 | + // we need to load the guest css fallback |
|
180 | + \OC_Util::addStyle('guest'); |
|
181 | + $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false); |
|
182 | + } |
|
183 | 183 | |
184 | - $this->assign('cssfiles', array()); |
|
185 | - $this->assign('printcssfiles', []); |
|
186 | - $this->assign('versionHash', self::$versionHash); |
|
187 | - foreach($cssFiles as $info) { |
|
188 | - $web = $info[1]; |
|
189 | - $file = $info[2]; |
|
184 | + $this->assign('cssfiles', array()); |
|
185 | + $this->assign('printcssfiles', []); |
|
186 | + $this->assign('versionHash', self::$versionHash); |
|
187 | + foreach($cssFiles as $info) { |
|
188 | + $web = $info[1]; |
|
189 | + $file = $info[2]; |
|
190 | 190 | |
191 | - if (substr($file, -strlen('print.css')) === 'print.css') { |
|
192 | - $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
193 | - } else { |
|
194 | - $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
195 | - } |
|
196 | - } |
|
197 | - } |
|
191 | + if (substr($file, -strlen('print.css')) === 'print.css') { |
|
192 | + $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
193 | + } else { |
|
194 | + $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); |
|
195 | + } |
|
196 | + } |
|
197 | + } |
|
198 | 198 | |
199 | - protected function getVersionHashSuffix() { |
|
200 | - if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
201 | - // allows chrome workspace mapping in debug mode |
|
202 | - return ""; |
|
203 | - } |
|
199 | + protected function getVersionHashSuffix() { |
|
200 | + if(\OC::$server->getConfig()->getSystemValue('debug', false)) { |
|
201 | + // allows chrome workspace mapping in debug mode |
|
202 | + return ""; |
|
203 | + } |
|
204 | 204 | |
205 | - return '?v=' . self::$versionHash; |
|
206 | - } |
|
205 | + return '?v=' . self::$versionHash; |
|
206 | + } |
|
207 | 207 | |
208 | - /** |
|
209 | - * @param array $styles |
|
210 | - * @return array |
|
211 | - */ |
|
212 | - static public function findStylesheetFiles($styles, $compileScss = true) { |
|
213 | - // Read the selected theme from the config file |
|
214 | - $theme = \OC_Util::getTheme(); |
|
208 | + /** |
|
209 | + * @param array $styles |
|
210 | + * @return array |
|
211 | + */ |
|
212 | + static public function findStylesheetFiles($styles, $compileScss = true) { |
|
213 | + // Read the selected theme from the config file |
|
214 | + $theme = \OC_Util::getTheme(); |
|
215 | 215 | |
216 | - if($compileScss) { |
|
217 | - /** @var \OC\Memcache\Factory $cache */ |
|
218 | - $cache = \OC::$server->query('MemCacheFactory'); |
|
219 | - $SCSSCacher = new SCSSCacher( |
|
220 | - \OC::$server->getLogger(), |
|
221 | - \OC::$server->getAppDataDir('css'), |
|
222 | - \OC::$server->getURLGenerator(), |
|
223 | - \OC::$server->getConfig(), |
|
224 | - \OC::$SERVERROOT, |
|
225 | - $cache->createLocal('SCSS') |
|
226 | - ); |
|
227 | - } else { |
|
228 | - $SCSSCacher = null; |
|
229 | - } |
|
216 | + if($compileScss) { |
|
217 | + /** @var \OC\Memcache\Factory $cache */ |
|
218 | + $cache = \OC::$server->query('MemCacheFactory'); |
|
219 | + $SCSSCacher = new SCSSCacher( |
|
220 | + \OC::$server->getLogger(), |
|
221 | + \OC::$server->getAppDataDir('css'), |
|
222 | + \OC::$server->getURLGenerator(), |
|
223 | + \OC::$server->getConfig(), |
|
224 | + \OC::$SERVERROOT, |
|
225 | + $cache->createLocal('SCSS') |
|
226 | + ); |
|
227 | + } else { |
|
228 | + $SCSSCacher = null; |
|
229 | + } |
|
230 | 230 | |
231 | - $locator = new \OC\Template\CSSResourceLocator( |
|
232 | - \OC::$server->getLogger(), |
|
233 | - $theme, |
|
234 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
235 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
236 | - $SCSSCacher); |
|
237 | - $locator->find($styles); |
|
238 | - return $locator->getResources(); |
|
239 | - } |
|
231 | + $locator = new \OC\Template\CSSResourceLocator( |
|
232 | + \OC::$server->getLogger(), |
|
233 | + $theme, |
|
234 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
235 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
236 | + $SCSSCacher); |
|
237 | + $locator->find($styles); |
|
238 | + return $locator->getResources(); |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * @param array $scripts |
|
243 | - * @return array |
|
244 | - */ |
|
245 | - static public function findJavascriptFiles($scripts) { |
|
246 | - // Read the selected theme from the config file |
|
247 | - $theme = \OC_Util::getTheme(); |
|
241 | + /** |
|
242 | + * @param array $scripts |
|
243 | + * @return array |
|
244 | + */ |
|
245 | + static public function findJavascriptFiles($scripts) { |
|
246 | + // Read the selected theme from the config file |
|
247 | + $theme = \OC_Util::getTheme(); |
|
248 | 248 | |
249 | - $locator = new \OC\Template\JSResourceLocator( |
|
250 | - \OC::$server->getLogger(), |
|
251 | - $theme, |
|
252 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
253 | - array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
254 | - new JSCombiner( |
|
255 | - \OC::$server->getAppDataDir('js'), |
|
256 | - \OC::$server->getURLGenerator(), |
|
257 | - \OC::$server->getMemCacheFactory()->create('JS'), |
|
258 | - \OC::$server->getSystemConfig() |
|
259 | - ) |
|
260 | - ); |
|
261 | - $locator->find($scripts); |
|
262 | - return $locator->getResources(); |
|
263 | - } |
|
249 | + $locator = new \OC\Template\JSResourceLocator( |
|
250 | + \OC::$server->getLogger(), |
|
251 | + $theme, |
|
252 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
253 | + array( \OC::$SERVERROOT => \OC::$WEBROOT ), |
|
254 | + new JSCombiner( |
|
255 | + \OC::$server->getAppDataDir('js'), |
|
256 | + \OC::$server->getURLGenerator(), |
|
257 | + \OC::$server->getMemCacheFactory()->create('JS'), |
|
258 | + \OC::$server->getSystemConfig() |
|
259 | + ) |
|
260 | + ); |
|
261 | + $locator->find($scripts); |
|
262 | + return $locator->getResources(); |
|
263 | + } |
|
264 | 264 | |
265 | - /** |
|
266 | - * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
267 | - * @param string $filePath Absolute path |
|
268 | - * @return string Relative path |
|
269 | - * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
270 | - */ |
|
271 | - public static function convertToRelativePath($filePath) { |
|
272 | - $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
273 | - if(count($relativePath) !== 2) { |
|
274 | - throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
275 | - } |
|
265 | + /** |
|
266 | + * Converts the absolute file path to a relative path from \OC::$SERVERROOT |
|
267 | + * @param string $filePath Absolute path |
|
268 | + * @return string Relative path |
|
269 | + * @throws \Exception If $filePath is not under \OC::$SERVERROOT |
|
270 | + */ |
|
271 | + public static function convertToRelativePath($filePath) { |
|
272 | + $relativePath = explode(\OC::$SERVERROOT, $filePath); |
|
273 | + if(count($relativePath) !== 2) { |
|
274 | + throw new \Exception('$filePath is not under the \OC::$SERVERROOT'); |
|
275 | + } |
|
276 | 276 | |
277 | - return $relativePath[1]; |
|
278 | - } |
|
277 | + return $relativePath[1]; |
|
278 | + } |
|
279 | 279 | } |