Completed
Push — master ( 09d5b6...052221 )
by John
19:20
created

appnavigation.php ➔ NavigationElementMenu()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 1
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
1
<div id="app-navigation">
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 66 and the first side effect is on line 1.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
	<ul class="with-icon">
3
4
		<?php
5
6
		$pinned = 0;
7
		foreach ($_['navigationItems'] as $item) {
8
			$pinned = NavigationListElements($item, $l, $pinned);
9
		}
10
		?>
11
12
		<li id="quota"
13
			class="pinned <?php p($pinned === 0 ? 'first-pinned ' : '') ?><?php
14
			if ($_['quota'] !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
15
			?>has-tooltip" title="<?php p($_['usage_relative'] . '%');
16
		} ?>">
17
			<a href="#" class="icon-quota svg">
18
				<p id="quotatext"><?php
19
					if ($_['quota'] !== \OCP\Files\FileInfo::SPACE_UNLIMITED) {
20
						p($l->t('%s of %s used', [$_['usage'], $_['total_space']]));
21
					} else {
22
						p($l->t('%s used', [$_['usage']]));
23
					} ?></p>
24
				<div class="quota-container">
25
					<progress value="<?php p($_['usage_relative']); ?>"
26
							  max="100"
27
						<?php if ($_['usage_relative'] > 80): ?> class="warn" <?php endif; ?>></progress>
28
				</div>
29
			</a>
30
		</li>
31
	</ul>
32
	<div id="app-settings">
33
		<div id="app-settings-header">
34
			<button class="settings-button"
35
					data-apps-slide-toggle="#app-settings-content">
36
				<?php p($l->t('Settings')); ?>
37
			</button>
38
		</div>
39
		<div id="app-settings-content">
40
			<div id="files-setting-showhidden">
41
				<input class="checkbox" id="showhiddenfilesToggle"
42
					   checked="checked" type="checkbox">
43
				<label for="showhiddenfilesToggle"><?php p($l->t('Show hidden files')); ?></label>
44
			</div>
45
			<label for="webdavurl"><?php p($l->t('WebDAV')); ?></label>
46
			<input id="webdavurl" type="text" readonly="readonly"
47
				   value="<?php p(\OCP\Util::linkToRemote('webdav')); ?>"/>
48
			<em><?php print_unescaped($l->t('Use this address to <a href="%s" target="_blank" rel="noreferrer noopener">access your Files via WebDAV</a>', array(link_to_docs('user-webdav')))); ?></em>
49
		</div>
50
	</div>
51
52
</div>
53
54
55
<?php
56
57
/**
58
 * Prints the HTML for a single Entry.
59
 *
60
 * @param $item The item to be added
61
 * @param $l Translator
62
 * @param $pinned IntegerValue to count the pinned entries at the bottom
63
 *
64
 * @return int Returns the pinned value
65
 */
66
function NavigationListElements($item, $l, $pinned) {
67
	strpos($item['classes'], 'pinned') !== false ? $pinned++ : '';
68
	?>
69
	<li <?php if (isset($item['sublist'])){ ?>id="button-collapse-parent-<?php p($item['id']); ?>"<?php } ?>
70
		data-id="<?php p($item['id']) ?>" data-dir="<?php p($item['dir']) ?>" data-view="<?php p($item['view']) ?>"
71
		class="nav-<?php p($item['id']) ?> <?php p($item['classes']) ?> <?php p($pinned === 1 ? 'first-pinned' : '') ?> <?php if ($item['defaultExpandedState']) { ?> open<?php } ?>"
72
		<?php if (isset($item['folderPosition'])) { ?> folderposition="<?php p($item['folderPosition']); ?>" <?php } ?>>
73
74
		<a href="<?php p(isset($item['href']) ? $item['href'] : '#') ?>"
75
		   class="nav-icon-<?php p($item['icon'] !== '' ? $item['icon'] : $item['id']) ?> svg"><?php p($item['name']); ?></a>
76
77
78
		<?php
79
		NavigationElementMenu($item);
80
		if (isset($item['sublist'])) {
81
			?>
82
			<button id="button-collapse-<?php p($item['id']); ?>"
83
					class="collapse app-navigation-noclose" <?php if (sizeof($item['sublist']) == 0) { ?> style="display: none" <?php } ?>></button>
84
			<ul id="sublist-<?php p($item['id']); ?>">
85
				<?php
86
				foreach ($item['sublist'] as $item) {
87
					$pinned = NavigationListElements($item, $l, $pinned);
88
				}
89
				?>
90
			</ul>
91
		<?php } ?>
92
	</li>
93
94
95
	<?php
96
	return $pinned;
97
}
98
99
/**
100
 * Prints the HTML for a dotmenu.
101
 *
102
 * @param $item The item to be added
103
 *
104
 * @return void
105
 */
106
function NavigationElementMenu($item) {
107
	if ($item['menubuttons'] === 'true') {
108
		?>
109
		<div id="dotmenu-<?php p($item['id']); ?>"
110
			 class="app-navigation-entry-utils" <?php if ($item['enableMenuButton'] === 0) { ?> style="display: none"<?php } ?>>
111
			<ul>
112
				<li class="app-navigation-entry-utils-menu-button svg">
113
					<button id="dotmenu-button-<?php p($item['id']) ?>"></button>
114
				</li>
115
			</ul>
116
		</div>
117
		<div id="dotmenu-content-<?php p($item['id']) ?>"
118
			 class="app-navigation-entry-menu">
119
			<ul>
120
121
			</ul>
122
		</div>
123
	<?php }
124
}
125