Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion apps/theming/lib/ThemingDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IL10N;
use OCP\INavigationManager;
use OCP\IURLGenerator;

class ThemingDefaults extends \OC_Defaults {
Expand All @@ -57,6 +58,9 @@ class ThemingDefaults extends \OC_Defaults {
private $util;
/** @var IAppManager */
private $appManager;
/** @var INavigationManager */
private $navigationManager;

/** @var string */
private $name;
/** @var string */
Expand Down Expand Up @@ -94,7 +98,8 @@ public function __construct(IConfig $config,
ICacheFactory $cacheFactory,
Util $util,
ImageManager $imageManager,
IAppManager $appManager
IAppManager $appManager,
INavigationManager $navigationManager
) {
parent::__construct();
$this->config = $config;
Expand All @@ -104,6 +109,7 @@ public function __construct(IConfig $config,
$this->cacheFactory = $cacheFactory;
$this->util = $util;
$this->appManager = $appManager;
$this->navigationManager = $navigationManager;

$this->name = parent::getName();
$this->title = parent::getTitle();
Expand Down Expand Up @@ -170,6 +176,15 @@ public function getShortFooter() {
],
];

$navigation = $this->navigationManager->getAll(INavigationManager::TYPE_GUEST);
$guestNavigation = array_map(function($nav) {
return [
'text' => $nav['name'],
'url' => $nav['href']
];
}, $navigation);
$links = array_merge($links, $guestNavigation);

$legalLinks = ''; $divider = '';
foreach($links as $link) {
if($link['url'] !== ''
Expand Down
14 changes: 13 additions & 1 deletion apps/theming/tests/ThemingDefaultsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IL10N;
use OCP\INavigationManager;
use OCP\IURLGenerator;
use Test\TestCase;

Expand All @@ -67,6 +68,8 @@ class ThemingDefaultsTest extends TestCase {
private $appManager;
/** @var ImageManager|\PHPUnit_Framework_MockObject_MockObject */
private $imageManager;
/** @var INavigationManager|\PHPUnit_Framework_MockObject_MockObject */
private $navigationManager;

public function setUp() {
parent::setUp();
Expand All @@ -78,6 +81,7 @@ public function setUp() {
$this->util = $this->createMock(Util::class);
$this->imageManager = $this->createMock(ImageManager::class);
$this->appManager = $this->createMock(IAppManager::class);
$this->navigationManager = $this->createMock(INavigationManager::class);
$this->defaults = new \OC_Defaults();
$this->urlGenerator
->expects($this->any())
Expand All @@ -90,7 +94,8 @@ public function setUp() {
$this->cacheFactory,
$this->util,
$this->imageManager,
$this->appManager
$this->appManager,
$this->navigationManager
);
}

Expand Down Expand Up @@ -266,6 +271,7 @@ public function testGetShortFooter() {
}

public function testGetShortFooterEmptyUrl() {
$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
$this->config
->expects($this->exactly(5))
->method('getAppValue')
Expand All @@ -281,6 +287,7 @@ public function testGetShortFooterEmptyUrl() {
}

public function testGetShortFooterEmptySlogan() {
$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
$this->config
->expects($this->exactly(5))
->method('getAppValue')
Expand All @@ -296,6 +303,7 @@ public function testGetShortFooterEmptySlogan() {
}

public function testGetShortFooterImprint() {
$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
$this->config
->expects($this->exactly(5))
->method('getAppValue')
Expand All @@ -316,6 +324,7 @@ public function testGetShortFooterImprint() {
}

public function testGetShortFooterPrivacy() {
$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
$this->config
->expects($this->exactly(5))
->method('getAppValue')
Expand All @@ -336,6 +345,7 @@ public function testGetShortFooterPrivacy() {
}

public function testGetShortFooterAllLegalLinks() {
$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
$this->config
->expects($this->exactly(5))
->method('getAppValue')
Expand Down Expand Up @@ -367,6 +377,7 @@ public function invalidLegalUrlProvider() {
* @dataProvider invalidLegalUrlProvider
*/
public function testGetShortFooterInvalidImprint($invalidImprintUrl) {
$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
$this->config
->expects($this->exactly(5))
->method('getAppValue')
Expand All @@ -386,6 +397,7 @@ public function testGetShortFooterInvalidImprint($invalidImprintUrl) {
* @dataProvider invalidLegalUrlProvider
*/
public function testGetShortFooterInvalidPrivacy($invalidPrivacyUrl) {
$this->navigationManager->expects($this->once())->method('getAll')->with(INavigationManager::TYPE_GUEST)->willReturn([]);
$this->config
->expects($this->exactly(5))
->method('getAppValue')
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,8 @@ public function __construct($webRoot, \OC\Config $config) {
$c->getMemCacheFactory(),
new Util($c->getConfig(), $this->getAppManager(), $c->getAppDataDir('theming')),
new ImageManager($c->getConfig(), $c->getAppDataDir('theming'), $c->getURLGenerator(), $this->getMemCacheFactory(), $this->getLogger()),
$c->getAppManager()
$c->getAppManager(),
$c->getNavigationManager()
);
}
return new \OC_Defaults();
Expand Down
21 changes: 20 additions & 1 deletion lib/public/INavigationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,25 @@
* @since 6.0.0
*/
interface INavigationManager {

/**
* Navigation entries of the app navigation
* @since 16.0.0
*/
const TYPE_APPS = 'link';

/**
* Navigation entries of the settings navigation
* @since 16.0.0
*/
const TYPE_SETTINGS = 'settings';

/**
* Navigation entries for public page footer navigation
* @since 16.0.0
*/
const TYPE_GUEST = 'guest';

/**
* Creates a new navigation entry
*
Expand All @@ -65,5 +84,5 @@ public function setActiveEntry($appId);
* @return array
* @since 14.0.0
*/
public function getAll(string $type = 'link'): array;
public function getAll(string $type = self::TYPE_APPS): array;
}