/**
* Themed logo url
*
+ * @param bool $useSvg Whether to point to the SVG image or a fallback
* @return string
*/
- public function getLogo() {
+ public function getLogo($useSvg = true) {
$logo = $this->config->getAppValue('theming', 'logoMime', false);
$logoExists = true;
$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
if(!$logo || !$logoExists) {
- return $this->urlGenerator->imagePath('core','logo.svg') . '?v=' . $cacheBusterCounter;
+ if($useSvg) {
+ $logo = $this->urlGenerator->imagePath('core', 'logo.svg');
+ } else {
+ $logo = $this->urlGenerator->imagePath('core', 'logo.png');
+ }
+ return $logo . '?v=' . $cacheBusterCounter;
}
return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter;
$this->assertEquals('custom-background?v=0', $this->template->getBackground());
}
- public function testGetLogoDefault() {
+ private function getLogoHelper($withName, $useSvg) {
$this->appData->expects($this->once())
->method('getFolder')
->willThrowException(new NotFoundException());
->willThrowException(new \Exception());
$this->urlGenerator->expects($this->once())
->method('imagePath')
- ->with('core', 'logo.svg')
+ ->with('core', $withName)
->willReturn('core-logo');
- $this->assertEquals('core-logo?v=0', $this->template->getLogo());
+ $this->assertEquals('core-logo?v=0', $this->template->getLogo($useSvg));
+ }
+
+ public function testGetLogoDefaultWithSvg() {
+ $this->getLogoHelper('logo.svg', true);
+ }
+
+ public function testGetLogoDefaultWithoutSvg() {
+ $this->getLogoHelper('logo.png', false);
}
public function testGetLogoCustom() {
}
$this->headerAdded = true;
- $logoUrl = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo());
+ $logoUrl = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo(false));
$this->htmlBody .= vsprintf($this->header, [$this->themingDefaults->getColorPrimary(), $logoUrl, $this->themingDefaults->getName()]);
}
private $defaultSlogan;
private $defaultLogoClaim;
private $defaultColorPrimary;
- private $defaultLogoUrl;
- function __construct() {
+ public function __construct() {
$this->l = \OC::$server->getL10N('lib');
$this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */
$this->defaultSlogan = $this->l->t('a safe home for all your data');
$this->defaultLogoClaim = '';
$this->defaultColorPrimary = '#0082c9';
- $this->defaultLogoUrl = \OC::$server->getURLGenerator()->imagePath('core','logo.svg');
- $this->defaultLogoUrl .= '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion()));
$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
if (file_exists($themePath)) {
/**
* Themed logo url
*
+ * @param bool $useSvg Whether to point to the SVG image or a fallback
* @return string
*/
- public function getLogo() {
+ public function getLogo($useSvg = true) {
if ($this->themeExist('getLogo')) {
- return $this->theme->getLogo();
+ return $this->theme->getLogo($useSvg);
}
- return $this->defaultLogoUrl;
+ if($useSvg) {
+ $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.svg');
+ } else {
+ $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.png');
+ }
+ return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion()));
}
}
/**
* Themed logo url
*
+ * @param bool $useSvg Whether to point to the SVG image or a fallback
* @return string
* @since 12.0.0
*/
- public function getLogo() {
- return $this->defaults->getLogo();
+ public function getLogo($useSvg = true) {
+ return $this->defaults->getLogo($useSvg);
}
/**