-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#80] Restore compatibility with Nextcloud 14+
Signed-off-by: Marius David Wieschollek <git.public@mdns.eu>
- Loading branch information
1 parent
e0d24a0
commit 2fba69a
Showing
9 changed files
with
209 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/** | ||
* This file is part of the Unpslash App | ||
* and licensed under the AGPL. | ||
*/ | ||
|
||
namespace OCA\Unsplash\Services; | ||
|
||
use OC\Security\CSP\ContentSecurityPolicy; | ||
use OCP\Security\IContentSecurityPolicyManager; | ||
use OCP\Util; | ||
|
||
/** | ||
* Class LegacyInitialisationService | ||
* | ||
* @package OCA\Unsplash\Services | ||
*/ | ||
class LegacyInitialisationService { | ||
|
||
/** | ||
* @var SettingsService | ||
*/ | ||
protected $settingsService; | ||
|
||
/** | ||
* @var IContentSecurityPolicyManager | ||
*/ | ||
protected $contentSecurityPolicyManager; | ||
|
||
/** | ||
* LegacyInitialisationService constructor. | ||
* | ||
* @param SettingsService $settingsService | ||
* @param IContentSecurityPolicyManager $contentSecurityPolicyManager | ||
*/ | ||
public function __construct(SettingsService $settingsService, IContentSecurityPolicyManager $contentSecurityPolicyManager) { | ||
$this->settingsService = $settingsService; | ||
$this->contentSecurityPolicyManager = $contentSecurityPolicyManager; | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function initialize() { | ||
$this->registerStyleSheets(); | ||
$this->registerCsp(); | ||
} | ||
|
||
/** | ||
* Add the stylesheets | ||
*/ | ||
protected function registerStyleSheets() { | ||
if($this->settingsService->getUserStyleHeaderEnabled()) { | ||
Util::addStyle('unsplash', 'header'); | ||
} | ||
if($this->settingsService->getServerStyleLoginEnabled()) { | ||
Util::addStyle('unsplash', 'login'); | ||
} | ||
} | ||
|
||
/** | ||
* Allow Unsplash hosts in the csp | ||
*/ | ||
protected function registerCsp() { | ||
if($this->settingsService->getUserStyleHeaderEnabled() || $this->settingsService->getServerStyleLoginEnabled()) { | ||
$policy = new ContentSecurityPolicy(); | ||
$policy->addAllowedImageDomain('https://source.unsplash.com'); | ||
$policy->addAllowedImageDomain('https://images.unsplash.com'); | ||
$this->contentSecurityPolicyManager->addDefaultPolicy($policy); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
/** | ||
* This file is part of the Unpslash App | ||
* and licensed under the AGPL. | ||
*/ | ||
|
||
namespace OCA\Unsplash\Settings; | ||
|
||
use OCP\IL10N; | ||
use OCP\IURLGenerator; | ||
use OCP\Settings\IIconSection; | ||
|
||
/** | ||
* Class PersonalSection | ||
* | ||
* @package OCA\Unsplash\Settings | ||
*/ | ||
class PersonalSection implements IIconSection { | ||
|
||
/** | ||
* @var IURLGenerator | ||
*/ | ||
protected $urlGenerator; | ||
|
||
/** | ||
* @var IL10N | ||
*/ | ||
protected $localisation; | ||
|
||
/** | ||
* @var | ||
*/ | ||
protected $appName; | ||
|
||
/** | ||
* AdminSection constructor. | ||
* | ||
* @param IL10N $localisation | ||
* @param IURLGenerator $urlGenerator | ||
* @param $appName | ||
*/ | ||
public function __construct(IL10N $localisation, IURLGenerator $urlGenerator, $appName) { | ||
$this->localisation = $localisation; | ||
$this->urlGenerator = $urlGenerator; | ||
$this->appName = $appName; | ||
} | ||
|
||
/** | ||
* Returns the relative path to an 16*16 icon describing the section. | ||
* e.g. '/core/img/places/files.svg' | ||
* | ||
* @returns string | ||
* @since 12 | ||
*/ | ||
public function getIcon(): string { | ||
return $this->urlGenerator->imagePath($this->appName, 'app-dark.svg'); | ||
} | ||
|
||
/** | ||
* Returns the ID of the section. It is supposed to be a lower case string, | ||
* e.g. 'passwords' | ||
* | ||
* @returns string | ||
* @since 9.1 | ||
*/ | ||
public function getID(): string { | ||
return $this->appName; | ||
} | ||
|
||
/** | ||
* Returns the translated name as it should be displayed, e.g. 'Splash'. | ||
* Use the L10N service to translate it. | ||
* | ||
* @return string | ||
* @since 9.1 | ||
*/ | ||
public function getName(): string { | ||
return $this->localisation->t('Splash'); | ||
} | ||
|
||
/** | ||
* @return int whether the form should be rather on the top or bottom of | ||
* the settings navigation. The sections are arranged in ascending order of | ||
* the priority values. It is required to return a value between 0 and 99. | ||
* | ||
* E.g.: 70 | ||
* @since 9.1 | ||
*/ | ||
public function getPriority(): int { | ||
return 50; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters