@@ -20,135 +20,135 @@ |
||
| 20 | 20 | |
| 21 | 21 | class OC_Theme { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Returns the base URL |
|
| 25 | - * @return string URL |
|
| 26 | - */ |
|
| 27 | - public function getBaseUrl() { |
|
| 28 | - return 'https://nextcloud.com'; |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Returns the URL where the sync clients are listed |
|
| 33 | - * @return string URL |
|
| 34 | - */ |
|
| 35 | - public function getSyncClientUrl() { |
|
| 36 | - return 'https://nextcloud.com/install/#install-clients'; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Returns the URL to the App Store for the iOS Client |
|
| 41 | - * @return string URL |
|
| 42 | - */ |
|
| 43 | - public function getiOSClientUrl() { |
|
| 44 | - return 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8'; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Returns the AppId for the App Store for the iOS Client |
|
| 49 | - * @return string AppId |
|
| 50 | - */ |
|
| 51 | - public function getiTunesAppId() { |
|
| 52 | - return '1125420102'; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Returns the URL to Google Play for the Android Client |
|
| 57 | - * @return string URL |
|
| 58 | - */ |
|
| 59 | - public function getAndroidClientUrl() { |
|
| 60 | - return 'https://play.google.com/store/apps/details?id=com.nextcloud.client'; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Returns the documentation URL |
|
| 65 | - * @return string URL |
|
| 66 | - */ |
|
| 67 | - public function getDocBaseUrl() { |
|
| 68 | - return 'https://docs.nextcloud.com'; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Returns the title |
|
| 73 | - * @return string title |
|
| 74 | - */ |
|
| 75 | - public function getTitle() { |
|
| 76 | - return 'Custom Cloud'; |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Returns the short name of the software |
|
| 81 | - * @return string title |
|
| 82 | - */ |
|
| 83 | - public function getName() { |
|
| 84 | - return 'Custom Cloud'; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Returns the short name of the software containing HTML strings |
|
| 89 | - * @return string title |
|
| 90 | - */ |
|
| 91 | - public function getHTMLName() { |
|
| 92 | - return 'Custom Cloud'; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Returns entity (e.g. company name) - used for footer, copyright |
|
| 97 | - * @return string entity name |
|
| 98 | - */ |
|
| 99 | - public function getEntity() { |
|
| 100 | - return 'Custom Cloud Co.'; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Returns slogan |
|
| 105 | - * @return string slogan |
|
| 106 | - */ |
|
| 107 | - public function getSlogan() { |
|
| 108 | - return 'Your custom cloud, personalized for you!'; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Returns logo claim |
|
| 113 | - * @return string logo claim |
|
| 114 | - */ |
|
| 115 | - public function getLogoClaim() { |
|
| 116 | - return ''; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * Returns short version of the footer |
|
| 121 | - * @return string short footer |
|
| 122 | - */ |
|
| 123 | - public function getShortFooter() { |
|
| 124 | - $footer = '© 2016 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'. |
|
| 125 | - '<br/>' . $this->getSlogan(); |
|
| 126 | - |
|
| 127 | - return $footer; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * Returns long version of the footer |
|
| 132 | - * @return string long footer |
|
| 133 | - */ |
|
| 134 | - public function getLongFooter() { |
|
| 135 | - $footer = '© 2016 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'. |
|
| 136 | - '<br/>' . $this->getSlogan(); |
|
| 137 | - |
|
| 138 | - return $footer; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - public function buildDocLinkToKey($key) { |
|
| 142 | - return $this->getDocBaseUrl() . '/server/11/go.php?to=' . $key; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Returns mail header color |
|
| 148 | - * @return string |
|
| 149 | - */ |
|
| 150 | - public function getColorPrimary() { |
|
| 151 | - return '#745bca'; |
|
| 152 | - } |
|
| 23 | + /** |
|
| 24 | + * Returns the base URL |
|
| 25 | + * @return string URL |
|
| 26 | + */ |
|
| 27 | + public function getBaseUrl() { |
|
| 28 | + return 'https://nextcloud.com'; |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Returns the URL where the sync clients are listed |
|
| 33 | + * @return string URL |
|
| 34 | + */ |
|
| 35 | + public function getSyncClientUrl() { |
|
| 36 | + return 'https://nextcloud.com/install/#install-clients'; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Returns the URL to the App Store for the iOS Client |
|
| 41 | + * @return string URL |
|
| 42 | + */ |
|
| 43 | + public function getiOSClientUrl() { |
|
| 44 | + return 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8'; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Returns the AppId for the App Store for the iOS Client |
|
| 49 | + * @return string AppId |
|
| 50 | + */ |
|
| 51 | + public function getiTunesAppId() { |
|
| 52 | + return '1125420102'; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Returns the URL to Google Play for the Android Client |
|
| 57 | + * @return string URL |
|
| 58 | + */ |
|
| 59 | + public function getAndroidClientUrl() { |
|
| 60 | + return 'https://play.google.com/store/apps/details?id=com.nextcloud.client'; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Returns the documentation URL |
|
| 65 | + * @return string URL |
|
| 66 | + */ |
|
| 67 | + public function getDocBaseUrl() { |
|
| 68 | + return 'https://docs.nextcloud.com'; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Returns the title |
|
| 73 | + * @return string title |
|
| 74 | + */ |
|
| 75 | + public function getTitle() { |
|
| 76 | + return 'Custom Cloud'; |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Returns the short name of the software |
|
| 81 | + * @return string title |
|
| 82 | + */ |
|
| 83 | + public function getName() { |
|
| 84 | + return 'Custom Cloud'; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Returns the short name of the software containing HTML strings |
|
| 89 | + * @return string title |
|
| 90 | + */ |
|
| 91 | + public function getHTMLName() { |
|
| 92 | + return 'Custom Cloud'; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Returns entity (e.g. company name) - used for footer, copyright |
|
| 97 | + * @return string entity name |
|
| 98 | + */ |
|
| 99 | + public function getEntity() { |
|
| 100 | + return 'Custom Cloud Co.'; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Returns slogan |
|
| 105 | + * @return string slogan |
|
| 106 | + */ |
|
| 107 | + public function getSlogan() { |
|
| 108 | + return 'Your custom cloud, personalized for you!'; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Returns logo claim |
|
| 113 | + * @return string logo claim |
|
| 114 | + */ |
|
| 115 | + public function getLogoClaim() { |
|
| 116 | + return ''; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * Returns short version of the footer |
|
| 121 | + * @return string short footer |
|
| 122 | + */ |
|
| 123 | + public function getShortFooter() { |
|
| 124 | + $footer = '© 2016 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'. |
|
| 125 | + '<br/>' . $this->getSlogan(); |
|
| 126 | + |
|
| 127 | + return $footer; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * Returns long version of the footer |
|
| 132 | + * @return string long footer |
|
| 133 | + */ |
|
| 134 | + public function getLongFooter() { |
|
| 135 | + $footer = '© 2016 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'. |
|
| 136 | + '<br/>' . $this->getSlogan(); |
|
| 137 | + |
|
| 138 | + return $footer; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + public function buildDocLinkToKey($key) { |
|
| 142 | + return $this->getDocBaseUrl() . '/server/11/go.php?to=' . $key; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Returns mail header color |
|
| 148 | + * @return string |
|
| 149 | + */ |
|
| 150 | + public function getColorPrimary() { |
|
| 151 | + return '#745bca'; |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | 154 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $isIE8 = false; |
| 36 | 36 | preg_match('/MSIE (.*?);/', $_SERVER['HTTP_USER_AGENT'], $matches); |
| 37 | 37 | if (count($matches) > 0 && $matches[1] <= 9) { |
| 38 | - $isIE8 = true; |
|
| 38 | + $isIE8 = true; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $cloudID = \OC::$server->getUserSession()->getUser()->getCloudId(); |
@@ -45,15 +45,15 @@ discard block |
||
| 45 | 45 | $color = $theme->getColorPrimary(); |
| 46 | 46 | $textColor = "#ffffff"; |
| 47 | 47 | if(\OC::$server->getAppManager()->isEnabledForUser("theming")) { |
| 48 | - $logoPath = $theme->getLogo(); |
|
| 49 | - try { |
|
| 50 | - $util = \OC::$server->query("\OCA\Theming\Util"); |
|
| 51 | - if($util->invertTextColor($color)) { |
|
| 52 | - $textColor = "#000000"; |
|
| 53 | - } |
|
| 54 | - } catch (OCP\AppFramework\QueryException $e) { |
|
| 48 | + $logoPath = $theme->getLogo(); |
|
| 49 | + try { |
|
| 50 | + $util = \OC::$server->query("\OCA\Theming\Util"); |
|
| 51 | + if($util->invertTextColor($color)) { |
|
| 52 | + $textColor = "#000000"; |
|
| 53 | + } |
|
| 54 | + } catch (OCP\AppFramework\QueryException $e) { |
|
| 55 | 55 | |
| 56 | - } |
|
| 56 | + } |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
@@ -31,72 +31,72 @@ |
||
| 31 | 31 | use OCP\Settings\ISettings; |
| 32 | 32 | |
| 33 | 33 | class Admin implements ISettings { |
| 34 | - /** @var IConfig */ |
|
| 35 | - private $config; |
|
| 36 | - /** @var IL10N */ |
|
| 37 | - private $l; |
|
| 38 | - /** @var ThemingDefaults */ |
|
| 39 | - private $themingDefaults; |
|
| 40 | - /** @var IURLGenerator */ |
|
| 41 | - private $urlGenerator; |
|
| 34 | + /** @var IConfig */ |
|
| 35 | + private $config; |
|
| 36 | + /** @var IL10N */ |
|
| 37 | + private $l; |
|
| 38 | + /** @var ThemingDefaults */ |
|
| 39 | + private $themingDefaults; |
|
| 40 | + /** @var IURLGenerator */ |
|
| 41 | + private $urlGenerator; |
|
| 42 | 42 | |
| 43 | - public function __construct(IConfig $config, |
|
| 44 | - IL10N $l, |
|
| 45 | - ThemingDefaults $themingDefaults, |
|
| 46 | - IURLGenerator $urlGenerator) { |
|
| 47 | - $this->config = $config; |
|
| 48 | - $this->l = $l; |
|
| 49 | - $this->themingDefaults = $themingDefaults; |
|
| 50 | - $this->urlGenerator = $urlGenerator; |
|
| 51 | - } |
|
| 43 | + public function __construct(IConfig $config, |
|
| 44 | + IL10N $l, |
|
| 45 | + ThemingDefaults $themingDefaults, |
|
| 46 | + IURLGenerator $urlGenerator) { |
|
| 47 | + $this->config = $config; |
|
| 48 | + $this->l = $l; |
|
| 49 | + $this->themingDefaults = $themingDefaults; |
|
| 50 | + $this->urlGenerator = $urlGenerator; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @return TemplateResponse |
|
| 55 | - */ |
|
| 56 | - public function getForm() { |
|
| 57 | - $path = $this->urlGenerator->linkToRoute('theming.Theming.updateLogo'); |
|
| 53 | + /** |
|
| 54 | + * @return TemplateResponse |
|
| 55 | + */ |
|
| 56 | + public function getForm() { |
|
| 57 | + $path = $this->urlGenerator->linkToRoute('theming.Theming.updateLogo'); |
|
| 58 | 58 | |
| 59 | - $themable = true; |
|
| 60 | - $errorMessage = ''; |
|
| 61 | - $theme = $this->config->getSystemValue('theme', ''); |
|
| 62 | - if ($theme !== '') { |
|
| 63 | - $themable = false; |
|
| 64 | - $errorMessage = $this->l->t('You are already using a custom theme'); |
|
| 65 | - } |
|
| 59 | + $themable = true; |
|
| 60 | + $errorMessage = ''; |
|
| 61 | + $theme = $this->config->getSystemValue('theme', ''); |
|
| 62 | + if ($theme !== '') { |
|
| 63 | + $themable = false; |
|
| 64 | + $errorMessage = $this->l->t('You are already using a custom theme'); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - $parameters = [ |
|
| 68 | - 'themable' => $themable, |
|
| 69 | - 'errorMessage' => $errorMessage, |
|
| 70 | - 'name' => $this->themingDefaults->getEntity(), |
|
| 71 | - 'url' => $this->themingDefaults->getBaseUrl(), |
|
| 72 | - 'slogan' => $this->themingDefaults->getSlogan(), |
|
| 73 | - 'color' => $this->themingDefaults->getColorPrimary(), |
|
| 74 | - 'logo' => $this->themingDefaults->getLogo(), |
|
| 75 | - 'logoMime' => $this->config->getAppValue('theming', 'logoMime', ''), |
|
| 76 | - 'background' => $this->themingDefaults->getBackground(), |
|
| 77 | - 'backgroundMime' => $this->config->getAppValue('theming', 'backgroundMime', ''), |
|
| 78 | - 'uploadLogoRoute' => $path, |
|
| 79 | - ]; |
|
| 67 | + $parameters = [ |
|
| 68 | + 'themable' => $themable, |
|
| 69 | + 'errorMessage' => $errorMessage, |
|
| 70 | + 'name' => $this->themingDefaults->getEntity(), |
|
| 71 | + 'url' => $this->themingDefaults->getBaseUrl(), |
|
| 72 | + 'slogan' => $this->themingDefaults->getSlogan(), |
|
| 73 | + 'color' => $this->themingDefaults->getColorPrimary(), |
|
| 74 | + 'logo' => $this->themingDefaults->getLogo(), |
|
| 75 | + 'logoMime' => $this->config->getAppValue('theming', 'logoMime', ''), |
|
| 76 | + 'background' => $this->themingDefaults->getBackground(), |
|
| 77 | + 'backgroundMime' => $this->config->getAppValue('theming', 'backgroundMime', ''), |
|
| 78 | + 'uploadLogoRoute' => $path, |
|
| 79 | + ]; |
|
| 80 | 80 | |
| 81 | - return new TemplateResponse('theming', 'settings-admin', $parameters, ''); |
|
| 82 | - } |
|
| 81 | + return new TemplateResponse('theming', 'settings-admin', $parameters, ''); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @return string the section ID, e.g. 'sharing' |
|
| 86 | - */ |
|
| 87 | - public function getSection() { |
|
| 88 | - return 'theming'; |
|
| 89 | - } |
|
| 84 | + /** |
|
| 85 | + * @return string the section ID, e.g. 'sharing' |
|
| 86 | + */ |
|
| 87 | + public function getSection() { |
|
| 88 | + return 'theming'; |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @return int whether the form should be rather on the top or bottom of |
|
| 93 | - * the admin section. The forms are arranged in ascending order of the |
|
| 94 | - * priority values. It is required to return a value between 0 and 100. |
|
| 95 | - * |
|
| 96 | - * E.g.: 70 |
|
| 97 | - */ |
|
| 98 | - public function getPriority() { |
|
| 99 | - return 5; |
|
| 100 | - } |
|
| 91 | + /** |
|
| 92 | + * @return int whether the form should be rather on the top or bottom of |
|
| 93 | + * the admin section. The forms are arranged in ascending order of the |
|
| 94 | + * priority values. It is required to return a value between 0 and 100. |
|
| 95 | + * |
|
| 96 | + * E.g.: 70 |
|
| 97 | + */ |
|
| 98 | + public function getPriority() { |
|
| 99 | + return 5; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | 102 | } |
@@ -32,196 +32,196 @@ |
||
| 32 | 32 | |
| 33 | 33 | class ThemingDefaults extends \OC_Defaults { |
| 34 | 34 | |
| 35 | - /** @var IConfig */ |
|
| 36 | - private $config; |
|
| 37 | - /** @var IL10N */ |
|
| 38 | - private $l; |
|
| 39 | - /** @var IURLGenerator */ |
|
| 40 | - private $urlGenerator; |
|
| 41 | - /** @var IRootFolder */ |
|
| 42 | - private $rootFolder; |
|
| 43 | - /** @var ICacheFactory */ |
|
| 44 | - private $cacheFactory; |
|
| 45 | - /** @var string */ |
|
| 46 | - private $name; |
|
| 47 | - /** @var string */ |
|
| 48 | - private $url; |
|
| 49 | - /** @var string */ |
|
| 50 | - private $slogan; |
|
| 51 | - /** @var string */ |
|
| 52 | - private $color; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * ThemingDefaults constructor. |
|
| 56 | - * |
|
| 57 | - * @param IConfig $config |
|
| 58 | - * @param IL10N $l |
|
| 59 | - * @param IURLGenerator $urlGenerator |
|
| 60 | - * @param \OC_Defaults $defaults |
|
| 61 | - * @param IRootFolder $rootFolder |
|
| 62 | - * @param ICacheFactory $cacheFactory |
|
| 63 | - */ |
|
| 64 | - public function __construct(IConfig $config, |
|
| 65 | - IL10N $l, |
|
| 66 | - IURLGenerator $urlGenerator, |
|
| 67 | - \OC_Defaults $defaults, |
|
| 68 | - IRootFolder $rootFolder, |
|
| 69 | - ICacheFactory $cacheFactory |
|
| 70 | - ) { |
|
| 71 | - parent::__construct(); |
|
| 72 | - $this->config = $config; |
|
| 73 | - $this->l = $l; |
|
| 74 | - $this->urlGenerator = $urlGenerator; |
|
| 75 | - $this->rootFolder = $rootFolder; |
|
| 76 | - $this->cacheFactory = $cacheFactory; |
|
| 77 | - |
|
| 78 | - $this->name = $defaults->getName(); |
|
| 79 | - $this->url = $defaults->getBaseUrl(); |
|
| 80 | - $this->slogan = $defaults->getSlogan(); |
|
| 81 | - $this->color = $defaults->getColorPrimary(); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - public function getName() { |
|
| 85 | - return strip_tags($this->config->getAppValue('theming', 'name', $this->name)); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - public function getHTMLName() { |
|
| 89 | - return $this->config->getAppValue('theming', 'name', $this->name); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - public function getTitle() { |
|
| 93 | - return $this->getName(); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - public function getEntity() { |
|
| 97 | - return $this->getName(); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - public function getBaseUrl() { |
|
| 101 | - return $this->config->getAppValue('theming', 'url', $this->url); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - public function getSlogan() { |
|
| 105 | - return Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan)); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - public function getShortFooter() { |
|
| 109 | - $slogan = $this->getSlogan(); |
|
| 110 | - $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
| 111 | - ' rel="noreferrer">' .$this->getEntity() . '</a>'. |
|
| 112 | - ($slogan !== '' ? ' – ' . $slogan : ''); |
|
| 113 | - |
|
| 114 | - return $footer; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Color that is used for the header as well as for mail headers |
|
| 119 | - * |
|
| 120 | - * @return string |
|
| 121 | - */ |
|
| 122 | - public function getColorPrimary() { |
|
| 123 | - return $this->config->getAppValue('theming', 'color', $this->color); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Themed logo url |
|
| 128 | - * |
|
| 129 | - * @return string |
|
| 130 | - */ |
|
| 131 | - public function getLogo() { |
|
| 132 | - $logo = $this->config->getAppValue('theming', 'logoMime'); |
|
| 133 | - if(!$logo || !$this->rootFolder->nodeExists('/themedinstancelogo')) { |
|
| 134 | - return $this->urlGenerator->imagePath('core','logo.svg'); |
|
| 135 | - } else { |
|
| 136 | - return $this->urlGenerator->linkToRoute('theming.Theming.getLogo'); |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Themed background image url |
|
| 142 | - * |
|
| 143 | - * @return string |
|
| 144 | - */ |
|
| 145 | - public function getBackground() { |
|
| 146 | - $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime'); |
|
| 147 | - if(!$backgroundLogo || !$this->rootFolder->nodeExists('/themedbackgroundlogo')) { |
|
| 148 | - return $this->urlGenerator->imagePath('core','background.jpg'); |
|
| 149 | - } else { |
|
| 150 | - return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground'); |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Check if Imagemagick is enabled and if SVG is supported |
|
| 156 | - * otherwise we can't render custom icons |
|
| 157 | - * |
|
| 158 | - * @return bool |
|
| 159 | - */ |
|
| 160 | - public function shouldReplaceIcons() { |
|
| 161 | - $cache = $this->cacheFactory->create('theming'); |
|
| 162 | - if($value = $cache->get('shouldReplaceIcons')) { |
|
| 163 | - return (bool)$value; |
|
| 164 | - } |
|
| 165 | - $value = false; |
|
| 166 | - if(extension_loaded('imagick')) { |
|
| 167 | - $checkImagick = new \Imagick(); |
|
| 168 | - if (count($checkImagick->queryFormats('SVG')) >= 1) { |
|
| 169 | - $value = true; |
|
| 170 | - } |
|
| 171 | - $checkImagick->clear(); |
|
| 172 | - } |
|
| 173 | - $cache->set('shouldReplaceIcons', $value); |
|
| 174 | - return $value; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * Increases the cache buster key |
|
| 179 | - */ |
|
| 180 | - private function increaseCacheBuster() { |
|
| 181 | - $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
| 182 | - $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * Update setting in the database |
|
| 187 | - * |
|
| 188 | - * @param string $setting |
|
| 189 | - * @param string $value |
|
| 190 | - */ |
|
| 191 | - public function set($setting, $value) { |
|
| 192 | - $this->config->setAppValue('theming', $setting, $value); |
|
| 193 | - $this->increaseCacheBuster(); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * Revert settings to the default value |
|
| 198 | - * |
|
| 199 | - * @param string $setting setting which should be reverted |
|
| 200 | - * @return string default value |
|
| 201 | - */ |
|
| 202 | - public function undo($setting) { |
|
| 203 | - $this->config->deleteAppValue('theming', $setting); |
|
| 204 | - $this->increaseCacheBuster(); |
|
| 205 | - |
|
| 206 | - switch ($setting) { |
|
| 207 | - case 'name': |
|
| 208 | - $returnValue = $this->getEntity(); |
|
| 209 | - break; |
|
| 210 | - case 'url': |
|
| 211 | - $returnValue = $this->getBaseUrl(); |
|
| 212 | - break; |
|
| 213 | - case 'slogan': |
|
| 214 | - $returnValue = $this->getSlogan(); |
|
| 215 | - break; |
|
| 216 | - case 'color': |
|
| 217 | - $returnValue = $this->getColorPrimary(); |
|
| 218 | - break; |
|
| 219 | - default: |
|
| 220 | - $returnValue = ''; |
|
| 221 | - break; |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - return $returnValue; |
|
| 225 | - } |
|
| 35 | + /** @var IConfig */ |
|
| 36 | + private $config; |
|
| 37 | + /** @var IL10N */ |
|
| 38 | + private $l; |
|
| 39 | + /** @var IURLGenerator */ |
|
| 40 | + private $urlGenerator; |
|
| 41 | + /** @var IRootFolder */ |
|
| 42 | + private $rootFolder; |
|
| 43 | + /** @var ICacheFactory */ |
|
| 44 | + private $cacheFactory; |
|
| 45 | + /** @var string */ |
|
| 46 | + private $name; |
|
| 47 | + /** @var string */ |
|
| 48 | + private $url; |
|
| 49 | + /** @var string */ |
|
| 50 | + private $slogan; |
|
| 51 | + /** @var string */ |
|
| 52 | + private $color; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * ThemingDefaults constructor. |
|
| 56 | + * |
|
| 57 | + * @param IConfig $config |
|
| 58 | + * @param IL10N $l |
|
| 59 | + * @param IURLGenerator $urlGenerator |
|
| 60 | + * @param \OC_Defaults $defaults |
|
| 61 | + * @param IRootFolder $rootFolder |
|
| 62 | + * @param ICacheFactory $cacheFactory |
|
| 63 | + */ |
|
| 64 | + public function __construct(IConfig $config, |
|
| 65 | + IL10N $l, |
|
| 66 | + IURLGenerator $urlGenerator, |
|
| 67 | + \OC_Defaults $defaults, |
|
| 68 | + IRootFolder $rootFolder, |
|
| 69 | + ICacheFactory $cacheFactory |
|
| 70 | + ) { |
|
| 71 | + parent::__construct(); |
|
| 72 | + $this->config = $config; |
|
| 73 | + $this->l = $l; |
|
| 74 | + $this->urlGenerator = $urlGenerator; |
|
| 75 | + $this->rootFolder = $rootFolder; |
|
| 76 | + $this->cacheFactory = $cacheFactory; |
|
| 77 | + |
|
| 78 | + $this->name = $defaults->getName(); |
|
| 79 | + $this->url = $defaults->getBaseUrl(); |
|
| 80 | + $this->slogan = $defaults->getSlogan(); |
|
| 81 | + $this->color = $defaults->getColorPrimary(); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + public function getName() { |
|
| 85 | + return strip_tags($this->config->getAppValue('theming', 'name', $this->name)); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + public function getHTMLName() { |
|
| 89 | + return $this->config->getAppValue('theming', 'name', $this->name); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + public function getTitle() { |
|
| 93 | + return $this->getName(); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + public function getEntity() { |
|
| 97 | + return $this->getName(); |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + public function getBaseUrl() { |
|
| 101 | + return $this->config->getAppValue('theming', 'url', $this->url); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + public function getSlogan() { |
|
| 105 | + return Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan)); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + public function getShortFooter() { |
|
| 109 | + $slogan = $this->getSlogan(); |
|
| 110 | + $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
| 111 | + ' rel="noreferrer">' .$this->getEntity() . '</a>'. |
|
| 112 | + ($slogan !== '' ? ' – ' . $slogan : ''); |
|
| 113 | + |
|
| 114 | + return $footer; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Color that is used for the header as well as for mail headers |
|
| 119 | + * |
|
| 120 | + * @return string |
|
| 121 | + */ |
|
| 122 | + public function getColorPrimary() { |
|
| 123 | + return $this->config->getAppValue('theming', 'color', $this->color); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Themed logo url |
|
| 128 | + * |
|
| 129 | + * @return string |
|
| 130 | + */ |
|
| 131 | + public function getLogo() { |
|
| 132 | + $logo = $this->config->getAppValue('theming', 'logoMime'); |
|
| 133 | + if(!$logo || !$this->rootFolder->nodeExists('/themedinstancelogo')) { |
|
| 134 | + return $this->urlGenerator->imagePath('core','logo.svg'); |
|
| 135 | + } else { |
|
| 136 | + return $this->urlGenerator->linkToRoute('theming.Theming.getLogo'); |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Themed background image url |
|
| 142 | + * |
|
| 143 | + * @return string |
|
| 144 | + */ |
|
| 145 | + public function getBackground() { |
|
| 146 | + $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime'); |
|
| 147 | + if(!$backgroundLogo || !$this->rootFolder->nodeExists('/themedbackgroundlogo')) { |
|
| 148 | + return $this->urlGenerator->imagePath('core','background.jpg'); |
|
| 149 | + } else { |
|
| 150 | + return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground'); |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Check if Imagemagick is enabled and if SVG is supported |
|
| 156 | + * otherwise we can't render custom icons |
|
| 157 | + * |
|
| 158 | + * @return bool |
|
| 159 | + */ |
|
| 160 | + public function shouldReplaceIcons() { |
|
| 161 | + $cache = $this->cacheFactory->create('theming'); |
|
| 162 | + if($value = $cache->get('shouldReplaceIcons')) { |
|
| 163 | + return (bool)$value; |
|
| 164 | + } |
|
| 165 | + $value = false; |
|
| 166 | + if(extension_loaded('imagick')) { |
|
| 167 | + $checkImagick = new \Imagick(); |
|
| 168 | + if (count($checkImagick->queryFormats('SVG')) >= 1) { |
|
| 169 | + $value = true; |
|
| 170 | + } |
|
| 171 | + $checkImagick->clear(); |
|
| 172 | + } |
|
| 173 | + $cache->set('shouldReplaceIcons', $value); |
|
| 174 | + return $value; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * Increases the cache buster key |
|
| 179 | + */ |
|
| 180 | + private function increaseCacheBuster() { |
|
| 181 | + $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
| 182 | + $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * Update setting in the database |
|
| 187 | + * |
|
| 188 | + * @param string $setting |
|
| 189 | + * @param string $value |
|
| 190 | + */ |
|
| 191 | + public function set($setting, $value) { |
|
| 192 | + $this->config->setAppValue('theming', $setting, $value); |
|
| 193 | + $this->increaseCacheBuster(); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * Revert settings to the default value |
|
| 198 | + * |
|
| 199 | + * @param string $setting setting which should be reverted |
|
| 200 | + * @return string default value |
|
| 201 | + */ |
|
| 202 | + public function undo($setting) { |
|
| 203 | + $this->config->deleteAppValue('theming', $setting); |
|
| 204 | + $this->increaseCacheBuster(); |
|
| 205 | + |
|
| 206 | + switch ($setting) { |
|
| 207 | + case 'name': |
|
| 208 | + $returnValue = $this->getEntity(); |
|
| 209 | + break; |
|
| 210 | + case 'url': |
|
| 211 | + $returnValue = $this->getBaseUrl(); |
|
| 212 | + break; |
|
| 213 | + case 'slogan': |
|
| 214 | + $returnValue = $this->getSlogan(); |
|
| 215 | + break; |
|
| 216 | + case 'color': |
|
| 217 | + $returnValue = $this->getColorPrimary(); |
|
| 218 | + break; |
|
| 219 | + default: |
|
| 220 | + $returnValue = ''; |
|
| 221 | + break; |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + return $returnValue; |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | 227 | } |
@@ -33,37 +33,37 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class Capabilities implements ICapability { |
| 35 | 35 | |
| 36 | - /** @var ThemingDefaults */ |
|
| 37 | - protected $theming; |
|
| 36 | + /** @var ThemingDefaults */ |
|
| 37 | + protected $theming; |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | - /** @var IURLGenerator */ |
|
| 41 | - protected $url; |
|
| 40 | + /** @var IURLGenerator */ |
|
| 41 | + protected $url; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param ThemingDefaults $theming |
|
| 45 | - * @param IURLGenerator $url |
|
| 46 | - */ |
|
| 47 | - public function __construct(ThemingDefaults $theming, IURLGenerator $url) { |
|
| 48 | - $this->theming = $theming; |
|
| 49 | - $this->url = $url; |
|
| 50 | - } |
|
| 43 | + /** |
|
| 44 | + * @param ThemingDefaults $theming |
|
| 45 | + * @param IURLGenerator $url |
|
| 46 | + */ |
|
| 47 | + public function __construct(ThemingDefaults $theming, IURLGenerator $url) { |
|
| 48 | + $this->theming = $theming; |
|
| 49 | + $this->url = $url; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Return this classes capabilities |
|
| 54 | - * |
|
| 55 | - * @return array |
|
| 56 | - */ |
|
| 57 | - public function getCapabilities() { |
|
| 58 | - return [ |
|
| 59 | - 'theming' => [ |
|
| 60 | - 'name' => $this->theming->getName(), |
|
| 61 | - 'url' => $this->theming->getBaseUrl(), |
|
| 62 | - 'slogan' => $this->theming->getSlogan(), |
|
| 63 | - 'color' => $this->theming->getColorPrimary(), |
|
| 64 | - 'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
|
| 65 | - 'background' => $this->url->getAbsoluteURL($this->theming->getBackground()), |
|
| 66 | - ], |
|
| 67 | - ]; |
|
| 68 | - } |
|
| 52 | + /** |
|
| 53 | + * Return this classes capabilities |
|
| 54 | + * |
|
| 55 | + * @return array |
|
| 56 | + */ |
|
| 57 | + public function getCapabilities() { |
|
| 58 | + return [ |
|
| 59 | + 'theming' => [ |
|
| 60 | + 'name' => $this->theming->getName(), |
|
| 61 | + 'url' => $this->theming->getBaseUrl(), |
|
| 62 | + 'slogan' => $this->theming->getSlogan(), |
|
| 63 | + 'color' => $this->theming->getColorPrimary(), |
|
| 64 | + 'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
|
| 65 | + 'background' => $this->url->getAbsoluteURL($this->theming->getBackground()), |
|
| 66 | + ], |
|
| 67 | + ]; |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -28,162 +28,162 @@ |
||
| 28 | 28 | use OCP\App\AppPathNotFoundException; |
| 29 | 29 | |
| 30 | 30 | class IconBuilder { |
| 31 | - /** @var ThemingDefaults */ |
|
| 32 | - private $themingDefaults; |
|
| 33 | - /** @var Util */ |
|
| 34 | - private $util; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * IconBuilder constructor. |
|
| 38 | - * |
|
| 39 | - * @param ThemingDefaults $themingDefaults |
|
| 40 | - * @param Util $util |
|
| 41 | - */ |
|
| 42 | - public function __construct( |
|
| 43 | - ThemingDefaults $themingDefaults, |
|
| 44 | - Util $util |
|
| 45 | - ) { |
|
| 46 | - $this->themingDefaults = $themingDefaults; |
|
| 47 | - $this->util = $util; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @param $app string app name |
|
| 52 | - * @return string|false image blob |
|
| 53 | - */ |
|
| 54 | - public function getFavicon($app) { |
|
| 55 | - $icon = $this->renderAppIcon($app, 32); |
|
| 56 | - if($icon === false) { |
|
| 57 | - return false; |
|
| 58 | - } |
|
| 59 | - $icon->setImageFormat("png24"); |
|
| 60 | - $data = $icon->getImageBlob(); |
|
| 61 | - $icon->destroy(); |
|
| 62 | - return $data; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * @param $app string app name |
|
| 67 | - * @return string|false image blob |
|
| 68 | - */ |
|
| 69 | - public function getTouchIcon($app) { |
|
| 70 | - $icon = $this->renderAppIcon($app, 512); |
|
| 71 | - if($icon === false) { |
|
| 72 | - return false; |
|
| 73 | - } |
|
| 74 | - $icon->setImageFormat("png24"); |
|
| 75 | - $data = $icon->getImageBlob(); |
|
| 76 | - $icon->destroy(); |
|
| 77 | - return $data; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * Render app icon on themed background color |
|
| 82 | - * fallback to logo |
|
| 83 | - * |
|
| 84 | - * @param $app string app name |
|
| 85 | - * @param $size int size of the icon in px |
|
| 86 | - * @return Imagick|false |
|
| 87 | - */ |
|
| 88 | - public function renderAppIcon($app, $size) { |
|
| 89 | - try { |
|
| 90 | - $appIcon = $this->util->getAppIcon($app); |
|
| 91 | - $appIconContent = file_get_contents($appIcon); |
|
| 92 | - } catch (AppPathNotFoundException $e) { |
|
| 93 | - return false; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if($appIconContent === false) { |
|
| 97 | - return false; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - $color = $this->themingDefaults->getColorPrimary(); |
|
| 101 | - $mime = mime_content_type($appIcon); |
|
| 102 | - |
|
| 103 | - // generate background image with rounded corners |
|
| 104 | - $background = '<?xml version="1.0" encoding="UTF-8"?>' . |
|
| 105 | - '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:cc="http://creativecommons.org/ns#" width="512" height="512" xmlns:xlink="http://www.w3.org/1999/xlink">' . |
|
| 106 | - '<rect x="0" y="0" rx="100" ry="100" width="512" height="512" style="fill:' . $color . ';" />' . |
|
| 107 | - '</svg>'; |
|
| 108 | - // resize svg magic as this seems broken in Imagemagick |
|
| 109 | - if($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") { |
|
| 110 | - if(substr($appIconContent, 0, 5) !== "<?xml") { |
|
| 111 | - $svg = "<?xml version=\"1.0\"?>".$appIconContent; |
|
| 112 | - } else { |
|
| 113 | - $svg = $appIconContent; |
|
| 114 | - } |
|
| 115 | - $tmp = new Imagick(); |
|
| 116 | - $tmp->readImageBlob($svg); |
|
| 117 | - $x = $tmp->getImageWidth(); |
|
| 118 | - $y = $tmp->getImageHeight(); |
|
| 119 | - $res = $tmp->getImageResolution(); |
|
| 120 | - $tmp->destroy(); |
|
| 121 | - |
|
| 122 | - if($x>$y) { |
|
| 123 | - $max = $x; |
|
| 124 | - } else { |
|
| 125 | - $max = $y; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - // convert svg to resized image |
|
| 129 | - $appIconFile = new Imagick(); |
|
| 130 | - $resX = (int)(512 * $res['x'] / $max * 2.53); |
|
| 131 | - $resY = (int)(512 * $res['y'] / $max * 2.53); |
|
| 132 | - $appIconFile->setResolution($resX, $resY); |
|
| 133 | - $appIconFile->setBackgroundColor(new ImagickPixel('transparent')); |
|
| 134 | - $appIconFile->readImageBlob($svg); |
|
| 135 | - $appIconFile->scaleImage(512, 512, true); |
|
| 136 | - } else { |
|
| 137 | - $appIconFile = new Imagick(); |
|
| 138 | - $appIconFile->setBackgroundColor(new ImagickPixel('transparent')); |
|
| 139 | - $appIconFile->readImageBlob(file_get_contents($appIcon)); |
|
| 140 | - $appIconFile->scaleImage(512, 512, true); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // offset for icon positioning |
|
| 144 | - $border_w = (int)($appIconFile->getImageWidth() * 0.05); |
|
| 145 | - $border_h = (int)($appIconFile->getImageHeight() * 0.05); |
|
| 146 | - $innerWidth = (int)($appIconFile->getImageWidth() - $border_w * 2); |
|
| 147 | - $innerHeight = (int)($appIconFile->getImageHeight() - $border_h * 2); |
|
| 148 | - $appIconFile->adaptiveResizeImage($innerWidth, $innerHeight); |
|
| 149 | - // center icon |
|
| 150 | - $offset_w = 512 / 2 - $innerWidth / 2; |
|
| 151 | - $offset_h = 512 / 2 - $innerHeight / 2; |
|
| 152 | - |
|
| 153 | - $appIconFile->setImageFormat("png24"); |
|
| 154 | - |
|
| 155 | - $finalIconFile = new Imagick(); |
|
| 156 | - $finalIconFile->setBackgroundColor(new ImagickPixel('transparent')); |
|
| 157 | - $finalIconFile->readImageBlob($background); |
|
| 158 | - $finalIconFile->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT); |
|
| 159 | - $finalIconFile->setImageArtifact('compose:args', "1,0,-0.5,0.5"); |
|
| 160 | - $finalIconFile->compositeImage($appIconFile, Imagick::COMPOSITE_ATOP, $offset_w, $offset_h); |
|
| 161 | - $finalIconFile->setImageFormat('png24'); |
|
| 162 | - if (defined("Imagick::INTERPOLATE_BICUBIC") === true) { |
|
| 163 | - $filter = Imagick::INTERPOLATE_BICUBIC; |
|
| 164 | - } else { |
|
| 165 | - $filter = Imagick::FILTER_LANCZOS; |
|
| 166 | - } |
|
| 167 | - $finalIconFile->resizeImage($size, $size, $filter, 1, false); |
|
| 168 | - |
|
| 169 | - $appIconFile->destroy(); |
|
| 170 | - return $finalIconFile; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - public function colorSvg($app, $image) { |
|
| 174 | - try { |
|
| 175 | - $imageFile = $this->util->getAppImage($app, $image); |
|
| 176 | - } catch (AppPathNotFoundException $e) { |
|
| 177 | - return false; |
|
| 178 | - } |
|
| 179 | - $svg = file_get_contents($imageFile); |
|
| 180 | - if ($svg !== false && $svg !== "") { |
|
| 181 | - $color = $this->util->elementColor($this->themingDefaults->getColorPrimary()); |
|
| 182 | - $svg = $this->util->colorizeSvg($svg, $color); |
|
| 183 | - return $svg; |
|
| 184 | - } else { |
|
| 185 | - return false; |
|
| 186 | - } |
|
| 187 | - } |
|
| 31 | + /** @var ThemingDefaults */ |
|
| 32 | + private $themingDefaults; |
|
| 33 | + /** @var Util */ |
|
| 34 | + private $util; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * IconBuilder constructor. |
|
| 38 | + * |
|
| 39 | + * @param ThemingDefaults $themingDefaults |
|
| 40 | + * @param Util $util |
|
| 41 | + */ |
|
| 42 | + public function __construct( |
|
| 43 | + ThemingDefaults $themingDefaults, |
|
| 44 | + Util $util |
|
| 45 | + ) { |
|
| 46 | + $this->themingDefaults = $themingDefaults; |
|
| 47 | + $this->util = $util; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @param $app string app name |
|
| 52 | + * @return string|false image blob |
|
| 53 | + */ |
|
| 54 | + public function getFavicon($app) { |
|
| 55 | + $icon = $this->renderAppIcon($app, 32); |
|
| 56 | + if($icon === false) { |
|
| 57 | + return false; |
|
| 58 | + } |
|
| 59 | + $icon->setImageFormat("png24"); |
|
| 60 | + $data = $icon->getImageBlob(); |
|
| 61 | + $icon->destroy(); |
|
| 62 | + return $data; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * @param $app string app name |
|
| 67 | + * @return string|false image blob |
|
| 68 | + */ |
|
| 69 | + public function getTouchIcon($app) { |
|
| 70 | + $icon = $this->renderAppIcon($app, 512); |
|
| 71 | + if($icon === false) { |
|
| 72 | + return false; |
|
| 73 | + } |
|
| 74 | + $icon->setImageFormat("png24"); |
|
| 75 | + $data = $icon->getImageBlob(); |
|
| 76 | + $icon->destroy(); |
|
| 77 | + return $data; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * Render app icon on themed background color |
|
| 82 | + * fallback to logo |
|
| 83 | + * |
|
| 84 | + * @param $app string app name |
|
| 85 | + * @param $size int size of the icon in px |
|
| 86 | + * @return Imagick|false |
|
| 87 | + */ |
|
| 88 | + public function renderAppIcon($app, $size) { |
|
| 89 | + try { |
|
| 90 | + $appIcon = $this->util->getAppIcon($app); |
|
| 91 | + $appIconContent = file_get_contents($appIcon); |
|
| 92 | + } catch (AppPathNotFoundException $e) { |
|
| 93 | + return false; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if($appIconContent === false) { |
|
| 97 | + return false; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + $color = $this->themingDefaults->getColorPrimary(); |
|
| 101 | + $mime = mime_content_type($appIcon); |
|
| 102 | + |
|
| 103 | + // generate background image with rounded corners |
|
| 104 | + $background = '<?xml version="1.0" encoding="UTF-8"?>' . |
|
| 105 | + '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:cc="http://creativecommons.org/ns#" width="512" height="512" xmlns:xlink="http://www.w3.org/1999/xlink">' . |
|
| 106 | + '<rect x="0" y="0" rx="100" ry="100" width="512" height="512" style="fill:' . $color . ';" />' . |
|
| 107 | + '</svg>'; |
|
| 108 | + // resize svg magic as this seems broken in Imagemagick |
|
| 109 | + if($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") { |
|
| 110 | + if(substr($appIconContent, 0, 5) !== "<?xml") { |
|
| 111 | + $svg = "<?xml version=\"1.0\"?>".$appIconContent; |
|
| 112 | + } else { |
|
| 113 | + $svg = $appIconContent; |
|
| 114 | + } |
|
| 115 | + $tmp = new Imagick(); |
|
| 116 | + $tmp->readImageBlob($svg); |
|
| 117 | + $x = $tmp->getImageWidth(); |
|
| 118 | + $y = $tmp->getImageHeight(); |
|
| 119 | + $res = $tmp->getImageResolution(); |
|
| 120 | + $tmp->destroy(); |
|
| 121 | + |
|
| 122 | + if($x>$y) { |
|
| 123 | + $max = $x; |
|
| 124 | + } else { |
|
| 125 | + $max = $y; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + // convert svg to resized image |
|
| 129 | + $appIconFile = new Imagick(); |
|
| 130 | + $resX = (int)(512 * $res['x'] / $max * 2.53); |
|
| 131 | + $resY = (int)(512 * $res['y'] / $max * 2.53); |
|
| 132 | + $appIconFile->setResolution($resX, $resY); |
|
| 133 | + $appIconFile->setBackgroundColor(new ImagickPixel('transparent')); |
|
| 134 | + $appIconFile->readImageBlob($svg); |
|
| 135 | + $appIconFile->scaleImage(512, 512, true); |
|
| 136 | + } else { |
|
| 137 | + $appIconFile = new Imagick(); |
|
| 138 | + $appIconFile->setBackgroundColor(new ImagickPixel('transparent')); |
|
| 139 | + $appIconFile->readImageBlob(file_get_contents($appIcon)); |
|
| 140 | + $appIconFile->scaleImage(512, 512, true); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // offset for icon positioning |
|
| 144 | + $border_w = (int)($appIconFile->getImageWidth() * 0.05); |
|
| 145 | + $border_h = (int)($appIconFile->getImageHeight() * 0.05); |
|
| 146 | + $innerWidth = (int)($appIconFile->getImageWidth() - $border_w * 2); |
|
| 147 | + $innerHeight = (int)($appIconFile->getImageHeight() - $border_h * 2); |
|
| 148 | + $appIconFile->adaptiveResizeImage($innerWidth, $innerHeight); |
|
| 149 | + // center icon |
|
| 150 | + $offset_w = 512 / 2 - $innerWidth / 2; |
|
| 151 | + $offset_h = 512 / 2 - $innerHeight / 2; |
|
| 152 | + |
|
| 153 | + $appIconFile->setImageFormat("png24"); |
|
| 154 | + |
|
| 155 | + $finalIconFile = new Imagick(); |
|
| 156 | + $finalIconFile->setBackgroundColor(new ImagickPixel('transparent')); |
|
| 157 | + $finalIconFile->readImageBlob($background); |
|
| 158 | + $finalIconFile->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_TRANSPARENT); |
|
| 159 | + $finalIconFile->setImageArtifact('compose:args', "1,0,-0.5,0.5"); |
|
| 160 | + $finalIconFile->compositeImage($appIconFile, Imagick::COMPOSITE_ATOP, $offset_w, $offset_h); |
|
| 161 | + $finalIconFile->setImageFormat('png24'); |
|
| 162 | + if (defined("Imagick::INTERPOLATE_BICUBIC") === true) { |
|
| 163 | + $filter = Imagick::INTERPOLATE_BICUBIC; |
|
| 164 | + } else { |
|
| 165 | + $filter = Imagick::FILTER_LANCZOS; |
|
| 166 | + } |
|
| 167 | + $finalIconFile->resizeImage($size, $size, $filter, 1, false); |
|
| 168 | + |
|
| 169 | + $appIconFile->destroy(); |
|
| 170 | + return $finalIconFile; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + public function colorSvg($app, $image) { |
|
| 174 | + try { |
|
| 175 | + $imageFile = $this->util->getAppImage($app, $image); |
|
| 176 | + } catch (AppPathNotFoundException $e) { |
|
| 177 | + return false; |
|
| 178 | + } |
|
| 179 | + $svg = file_get_contents($imageFile); |
|
| 180 | + if ($svg !== false && $svg !== "") { |
|
| 181 | + $color = $this->util->elementColor($this->themingDefaults->getColorPrimary()); |
|
| 182 | + $svg = $this->util->colorizeSvg($svg, $color); |
|
| 183 | + return $svg; |
|
| 184 | + } else { |
|
| 185 | + return false; |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | 189 | } |
@@ -31,262 +31,262 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | class OC_Defaults { |
| 33 | 33 | |
| 34 | - private $theme; |
|
| 35 | - private $l; |
|
| 34 | + private $theme; |
|
| 35 | + private $l; |
|
| 36 | 36 | |
| 37 | - private $defaultEntity; |
|
| 38 | - private $defaultName; |
|
| 39 | - private $defaultTitle; |
|
| 40 | - private $defaultBaseUrl; |
|
| 41 | - private $defaultSyncClientUrl; |
|
| 42 | - private $defaultiOSClientUrl; |
|
| 43 | - private $defaultiTunesAppId; |
|
| 44 | - private $defaultAndroidClientUrl; |
|
| 45 | - private $defaultDocBaseUrl; |
|
| 46 | - private $defaultDocVersion; |
|
| 47 | - private $defaultSlogan; |
|
| 48 | - private $defaultLogoClaim; |
|
| 49 | - private $defaultMailHeaderColor; |
|
| 37 | + private $defaultEntity; |
|
| 38 | + private $defaultName; |
|
| 39 | + private $defaultTitle; |
|
| 40 | + private $defaultBaseUrl; |
|
| 41 | + private $defaultSyncClientUrl; |
|
| 42 | + private $defaultiOSClientUrl; |
|
| 43 | + private $defaultiTunesAppId; |
|
| 44 | + private $defaultAndroidClientUrl; |
|
| 45 | + private $defaultDocBaseUrl; |
|
| 46 | + private $defaultDocVersion; |
|
| 47 | + private $defaultSlogan; |
|
| 48 | + private $defaultLogoClaim; |
|
| 49 | + private $defaultMailHeaderColor; |
|
| 50 | 50 | |
| 51 | - function __construct() { |
|
| 52 | - $this->l = \OC::$server->getL10N('lib'); |
|
| 51 | + function __construct() { |
|
| 52 | + $this->l = \OC::$server->getL10N('lib'); |
|
| 53 | 53 | |
| 54 | - $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */ |
|
| 55 | - $this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */ |
|
| 56 | - $this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */ |
|
| 57 | - $this->defaultBaseUrl = 'https://nextcloud.com'; |
|
| 58 | - $this->defaultSyncClientUrl = 'https://nextcloud.com/install/#install-clients'; |
|
| 59 | - $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8'; |
|
| 60 | - $this->defaultiTunesAppId = '1125420102'; |
|
| 61 | - $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.nextcloud.client'; |
|
| 62 | - $this->defaultDocBaseUrl = 'https://docs.nextcloud.com'; |
|
| 63 | - $this->defaultDocVersion = '11'; // used to generate doc links |
|
| 64 | - $this->defaultSlogan = $this->l->t('a safe home for all your data'); |
|
| 65 | - $this->defaultLogoClaim = ''; |
|
| 66 | - $this->defaultMailHeaderColor = '#0082c9'; /* header color of mail notifications */ |
|
| 54 | + $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */ |
|
| 55 | + $this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */ |
|
| 56 | + $this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */ |
|
| 57 | + $this->defaultBaseUrl = 'https://nextcloud.com'; |
|
| 58 | + $this->defaultSyncClientUrl = 'https://nextcloud.com/install/#install-clients'; |
|
| 59 | + $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8'; |
|
| 60 | + $this->defaultiTunesAppId = '1125420102'; |
|
| 61 | + $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.nextcloud.client'; |
|
| 62 | + $this->defaultDocBaseUrl = 'https://docs.nextcloud.com'; |
|
| 63 | + $this->defaultDocVersion = '11'; // used to generate doc links |
|
| 64 | + $this->defaultSlogan = $this->l->t('a safe home for all your data'); |
|
| 65 | + $this->defaultLogoClaim = ''; |
|
| 66 | + $this->defaultMailHeaderColor = '#0082c9'; /* header color of mail notifications */ |
|
| 67 | 67 | |
| 68 | - $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php'; |
|
| 69 | - if (file_exists($themePath)) { |
|
| 70 | - // prevent defaults.php from printing output |
|
| 71 | - ob_start(); |
|
| 72 | - require_once $themePath; |
|
| 73 | - ob_end_clean(); |
|
| 74 | - if (class_exists('OC_Theme')) { |
|
| 75 | - $this->theme = new OC_Theme(); |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - } |
|
| 68 | + $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php'; |
|
| 69 | + if (file_exists($themePath)) { |
|
| 70 | + // prevent defaults.php from printing output |
|
| 71 | + ob_start(); |
|
| 72 | + require_once $themePath; |
|
| 73 | + ob_end_clean(); |
|
| 74 | + if (class_exists('OC_Theme')) { |
|
| 75 | + $this->theme = new OC_Theme(); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * @param string $method |
|
| 82 | - */ |
|
| 83 | - private function themeExist($method) { |
|
| 84 | - if (isset($this->theme) && method_exists($this->theme, $method)) { |
|
| 85 | - return true; |
|
| 86 | - } |
|
| 87 | - return false; |
|
| 88 | - } |
|
| 80 | + /** |
|
| 81 | + * @param string $method |
|
| 82 | + */ |
|
| 83 | + private function themeExist($method) { |
|
| 84 | + if (isset($this->theme) && method_exists($this->theme, $method)) { |
|
| 85 | + return true; |
|
| 86 | + } |
|
| 87 | + return false; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Returns the base URL |
|
| 92 | - * @return string URL |
|
| 93 | - */ |
|
| 94 | - public function getBaseUrl() { |
|
| 95 | - if ($this->themeExist('getBaseUrl')) { |
|
| 96 | - return $this->theme->getBaseUrl(); |
|
| 97 | - } else { |
|
| 98 | - return $this->defaultBaseUrl; |
|
| 99 | - } |
|
| 100 | - } |
|
| 90 | + /** |
|
| 91 | + * Returns the base URL |
|
| 92 | + * @return string URL |
|
| 93 | + */ |
|
| 94 | + public function getBaseUrl() { |
|
| 95 | + if ($this->themeExist('getBaseUrl')) { |
|
| 96 | + return $this->theme->getBaseUrl(); |
|
| 97 | + } else { |
|
| 98 | + return $this->defaultBaseUrl; |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - /** |
|
| 103 | - * Returns the URL where the sync clients are listed |
|
| 104 | - * @return string URL |
|
| 105 | - */ |
|
| 106 | - public function getSyncClientUrl() { |
|
| 107 | - if ($this->themeExist('getSyncClientUrl')) { |
|
| 108 | - return $this->theme->getSyncClientUrl(); |
|
| 109 | - } else { |
|
| 110 | - return $this->defaultSyncClientUrl; |
|
| 111 | - } |
|
| 112 | - } |
|
| 102 | + /** |
|
| 103 | + * Returns the URL where the sync clients are listed |
|
| 104 | + * @return string URL |
|
| 105 | + */ |
|
| 106 | + public function getSyncClientUrl() { |
|
| 107 | + if ($this->themeExist('getSyncClientUrl')) { |
|
| 108 | + return $this->theme->getSyncClientUrl(); |
|
| 109 | + } else { |
|
| 110 | + return $this->defaultSyncClientUrl; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Returns the URL to the App Store for the iOS Client |
|
| 116 | - * @return string URL |
|
| 117 | - */ |
|
| 118 | - public function getiOSClientUrl() { |
|
| 119 | - if ($this->themeExist('getiOSClientUrl')) { |
|
| 120 | - return $this->theme->getiOSClientUrl(); |
|
| 121 | - } else { |
|
| 122 | - return $this->defaultiOSClientUrl; |
|
| 123 | - } |
|
| 124 | - } |
|
| 114 | + /** |
|
| 115 | + * Returns the URL to the App Store for the iOS Client |
|
| 116 | + * @return string URL |
|
| 117 | + */ |
|
| 118 | + public function getiOSClientUrl() { |
|
| 119 | + if ($this->themeExist('getiOSClientUrl')) { |
|
| 120 | + return $this->theme->getiOSClientUrl(); |
|
| 121 | + } else { |
|
| 122 | + return $this->defaultiOSClientUrl; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * Returns the AppId for the App Store for the iOS Client |
|
| 128 | - * @return string AppId |
|
| 129 | - */ |
|
| 130 | - public function getiTunesAppId() { |
|
| 131 | - if ($this->themeExist('getiTunesAppId')) { |
|
| 132 | - return $this->theme->getiTunesAppId(); |
|
| 133 | - } else { |
|
| 134 | - return $this->defaultiTunesAppId; |
|
| 135 | - } |
|
| 136 | - } |
|
| 126 | + /** |
|
| 127 | + * Returns the AppId for the App Store for the iOS Client |
|
| 128 | + * @return string AppId |
|
| 129 | + */ |
|
| 130 | + public function getiTunesAppId() { |
|
| 131 | + if ($this->themeExist('getiTunesAppId')) { |
|
| 132 | + return $this->theme->getiTunesAppId(); |
|
| 133 | + } else { |
|
| 134 | + return $this->defaultiTunesAppId; |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - /** |
|
| 139 | - * Returns the URL to Google Play for the Android Client |
|
| 140 | - * @return string URL |
|
| 141 | - */ |
|
| 142 | - public function getAndroidClientUrl() { |
|
| 143 | - if ($this->themeExist('getAndroidClientUrl')) { |
|
| 144 | - return $this->theme->getAndroidClientUrl(); |
|
| 145 | - } else { |
|
| 146 | - return $this->defaultAndroidClientUrl; |
|
| 147 | - } |
|
| 148 | - } |
|
| 138 | + /** |
|
| 139 | + * Returns the URL to Google Play for the Android Client |
|
| 140 | + * @return string URL |
|
| 141 | + */ |
|
| 142 | + public function getAndroidClientUrl() { |
|
| 143 | + if ($this->themeExist('getAndroidClientUrl')) { |
|
| 144 | + return $this->theme->getAndroidClientUrl(); |
|
| 145 | + } else { |
|
| 146 | + return $this->defaultAndroidClientUrl; |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - /** |
|
| 151 | - * Returns the documentation URL |
|
| 152 | - * @return string URL |
|
| 153 | - */ |
|
| 154 | - public function getDocBaseUrl() { |
|
| 155 | - if ($this->themeExist('getDocBaseUrl')) { |
|
| 156 | - return $this->theme->getDocBaseUrl(); |
|
| 157 | - } else { |
|
| 158 | - return $this->defaultDocBaseUrl; |
|
| 159 | - } |
|
| 160 | - } |
|
| 150 | + /** |
|
| 151 | + * Returns the documentation URL |
|
| 152 | + * @return string URL |
|
| 153 | + */ |
|
| 154 | + public function getDocBaseUrl() { |
|
| 155 | + if ($this->themeExist('getDocBaseUrl')) { |
|
| 156 | + return $this->theme->getDocBaseUrl(); |
|
| 157 | + } else { |
|
| 158 | + return $this->defaultDocBaseUrl; |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * Returns the title |
|
| 164 | - * @return string title |
|
| 165 | - */ |
|
| 166 | - public function getTitle() { |
|
| 167 | - if ($this->themeExist('getTitle')) { |
|
| 168 | - return $this->theme->getTitle(); |
|
| 169 | - } else { |
|
| 170 | - return $this->defaultTitle; |
|
| 171 | - } |
|
| 172 | - } |
|
| 162 | + /** |
|
| 163 | + * Returns the title |
|
| 164 | + * @return string title |
|
| 165 | + */ |
|
| 166 | + public function getTitle() { |
|
| 167 | + if ($this->themeExist('getTitle')) { |
|
| 168 | + return $this->theme->getTitle(); |
|
| 169 | + } else { |
|
| 170 | + return $this->defaultTitle; |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - /** |
|
| 175 | - * Returns the short name of the software |
|
| 176 | - * @return string title |
|
| 177 | - */ |
|
| 178 | - public function getName() { |
|
| 179 | - if ($this->themeExist('getName')) { |
|
| 180 | - return $this->theme->getName(); |
|
| 181 | - } else { |
|
| 182 | - return $this->defaultName; |
|
| 183 | - } |
|
| 184 | - } |
|
| 174 | + /** |
|
| 175 | + * Returns the short name of the software |
|
| 176 | + * @return string title |
|
| 177 | + */ |
|
| 178 | + public function getName() { |
|
| 179 | + if ($this->themeExist('getName')) { |
|
| 180 | + return $this->theme->getName(); |
|
| 181 | + } else { |
|
| 182 | + return $this->defaultName; |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - /** |
|
| 187 | - * Returns the short name of the software containing HTML strings |
|
| 188 | - * @return string title |
|
| 189 | - */ |
|
| 190 | - public function getHTMLName() { |
|
| 191 | - if ($this->themeExist('getHTMLName')) { |
|
| 192 | - return $this->theme->getHTMLName(); |
|
| 193 | - } else { |
|
| 194 | - return $this->defaultName; |
|
| 195 | - } |
|
| 196 | - } |
|
| 186 | + /** |
|
| 187 | + * Returns the short name of the software containing HTML strings |
|
| 188 | + * @return string title |
|
| 189 | + */ |
|
| 190 | + public function getHTMLName() { |
|
| 191 | + if ($this->themeExist('getHTMLName')) { |
|
| 192 | + return $this->theme->getHTMLName(); |
|
| 193 | + } else { |
|
| 194 | + return $this->defaultName; |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - /** |
|
| 199 | - * Returns entity (e.g. company name) - used for footer, copyright |
|
| 200 | - * @return string entity name |
|
| 201 | - */ |
|
| 202 | - public function getEntity() { |
|
| 203 | - if ($this->themeExist('getEntity')) { |
|
| 204 | - return $this->theme->getEntity(); |
|
| 205 | - } else { |
|
| 206 | - return $this->defaultEntity; |
|
| 207 | - } |
|
| 208 | - } |
|
| 198 | + /** |
|
| 199 | + * Returns entity (e.g. company name) - used for footer, copyright |
|
| 200 | + * @return string entity name |
|
| 201 | + */ |
|
| 202 | + public function getEntity() { |
|
| 203 | + if ($this->themeExist('getEntity')) { |
|
| 204 | + return $this->theme->getEntity(); |
|
| 205 | + } else { |
|
| 206 | + return $this->defaultEntity; |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - /** |
|
| 211 | - * Returns slogan |
|
| 212 | - * @return string slogan |
|
| 213 | - */ |
|
| 214 | - public function getSlogan() { |
|
| 215 | - if ($this->themeExist('getSlogan')) { |
|
| 216 | - return $this->theme->getSlogan(); |
|
| 217 | - } else { |
|
| 218 | - return $this->defaultSlogan; |
|
| 219 | - } |
|
| 220 | - } |
|
| 210 | + /** |
|
| 211 | + * Returns slogan |
|
| 212 | + * @return string slogan |
|
| 213 | + */ |
|
| 214 | + public function getSlogan() { |
|
| 215 | + if ($this->themeExist('getSlogan')) { |
|
| 216 | + return $this->theme->getSlogan(); |
|
| 217 | + } else { |
|
| 218 | + return $this->defaultSlogan; |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - /** |
|
| 223 | - * Returns logo claim |
|
| 224 | - * @return string logo claim |
|
| 225 | - */ |
|
| 226 | - public function getLogoClaim() { |
|
| 227 | - if ($this->themeExist('getLogoClaim')) { |
|
| 228 | - return $this->theme->getLogoClaim(); |
|
| 229 | - } else { |
|
| 230 | - return $this->defaultLogoClaim; |
|
| 231 | - } |
|
| 232 | - } |
|
| 222 | + /** |
|
| 223 | + * Returns logo claim |
|
| 224 | + * @return string logo claim |
|
| 225 | + */ |
|
| 226 | + public function getLogoClaim() { |
|
| 227 | + if ($this->themeExist('getLogoClaim')) { |
|
| 228 | + return $this->theme->getLogoClaim(); |
|
| 229 | + } else { |
|
| 230 | + return $this->defaultLogoClaim; |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - /** |
|
| 235 | - * Returns short version of the footer |
|
| 236 | - * @return string short footer |
|
| 237 | - */ |
|
| 238 | - public function getShortFooter() { |
|
| 239 | - if ($this->themeExist('getShortFooter')) { |
|
| 240 | - $footer = $this->theme->getShortFooter(); |
|
| 241 | - } else { |
|
| 242 | - $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
| 243 | - ' rel="noreferrer">' .$this->getEntity() . '</a>'. |
|
| 244 | - ' – ' . $this->getSlogan(); |
|
| 245 | - } |
|
| 234 | + /** |
|
| 235 | + * Returns short version of the footer |
|
| 236 | + * @return string short footer |
|
| 237 | + */ |
|
| 238 | + public function getShortFooter() { |
|
| 239 | + if ($this->themeExist('getShortFooter')) { |
|
| 240 | + $footer = $this->theme->getShortFooter(); |
|
| 241 | + } else { |
|
| 242 | + $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
| 243 | + ' rel="noreferrer">' .$this->getEntity() . '</a>'. |
|
| 244 | + ' – ' . $this->getSlogan(); |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - return $footer; |
|
| 248 | - } |
|
| 247 | + return $footer; |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - /** |
|
| 251 | - * Returns long version of the footer |
|
| 252 | - * @return string long footer |
|
| 253 | - */ |
|
| 254 | - public function getLongFooter() { |
|
| 255 | - if ($this->themeExist('getLongFooter')) { |
|
| 256 | - $footer = $this->theme->getLongFooter(); |
|
| 257 | - } else { |
|
| 258 | - $footer = $this->getShortFooter(); |
|
| 259 | - } |
|
| 250 | + /** |
|
| 251 | + * Returns long version of the footer |
|
| 252 | + * @return string long footer |
|
| 253 | + */ |
|
| 254 | + public function getLongFooter() { |
|
| 255 | + if ($this->themeExist('getLongFooter')) { |
|
| 256 | + $footer = $this->theme->getLongFooter(); |
|
| 257 | + } else { |
|
| 258 | + $footer = $this->getShortFooter(); |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - return $footer; |
|
| 262 | - } |
|
| 261 | + return $footer; |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - /** |
|
| 265 | - * @param string $key |
|
| 266 | - */ |
|
| 267 | - public function buildDocLinkToKey($key) { |
|
| 268 | - if ($this->themeExist('buildDocLinkToKey')) { |
|
| 269 | - return $this->theme->buildDocLinkToKey($key); |
|
| 270 | - } |
|
| 271 | - return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key; |
|
| 272 | - } |
|
| 264 | + /** |
|
| 265 | + * @param string $key |
|
| 266 | + */ |
|
| 267 | + public function buildDocLinkToKey($key) { |
|
| 268 | + if ($this->themeExist('buildDocLinkToKey')) { |
|
| 269 | + return $this->theme->buildDocLinkToKey($key); |
|
| 270 | + } |
|
| 271 | + return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - /** |
|
| 275 | - * Returns mail header color |
|
| 276 | - * @return string |
|
| 277 | - */ |
|
| 278 | - public function getColorPrimary() { |
|
| 274 | + /** |
|
| 275 | + * Returns mail header color |
|
| 276 | + * @return string |
|
| 277 | + */ |
|
| 278 | + public function getColorPrimary() { |
|
| 279 | 279 | |
| 280 | - if ($this->themeExist('getColorPrimary')) { |
|
| 281 | - return $this->theme->getColorPrimary(); |
|
| 282 | - } |
|
| 283 | - if ($this->themeExist('getMailHeaderColor')) { |
|
| 284 | - return $this->theme->getMailHeaderColor(); |
|
| 285 | - } |
|
| 286 | - return $this->defaultMailHeaderColor; |
|
| 287 | - } |
|
| 280 | + if ($this->themeExist('getColorPrimary')) { |
|
| 281 | + return $this->theme->getColorPrimary(); |
|
| 282 | + } |
|
| 283 | + if ($this->themeExist('getMailHeaderColor')) { |
|
| 284 | + return $this->theme->getMailHeaderColor(); |
|
| 285 | + } |
|
| 286 | + return $this->defaultMailHeaderColor; |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - public function shouldReplaceIcons() { |
|
| 290 | - return false; |
|
| 291 | - } |
|
| 289 | + public function shouldReplaceIcons() { |
|
| 290 | + return false; |
|
| 291 | + } |
|
| 292 | 292 | } |