Completed
Push — master ( f78db1...a155f8 )
by Morris
34:10 queued 10s
created

appnavigation.php ➔ NavigationListElements()   F

Complexity

Conditions 16
Paths 384

Size

Total Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 16
nc 384
nop 3
dl 0
loc 37
rs 2.4333
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
70
		data-id="<?php p($item['id']) ?>"
71
		<?php if (isset($item['dir'])) { ?> data-dir="<?php p($item['dir']); ?>" <?php } ?>
72
		<?php if (isset($item['view'])) { ?> data-view="<?php p($item['view']); ?>" <?php } ?>
73
		<?php if (isset($item['expandedState'])) { ?> data-expandedstate="<?php p($item['expandedState']); ?>" <?php } ?>
74
		class="nav-<?php p($item['id']) ?>
75
		<?php if (isset($item['classes'])) { p($item['classes']); } ?>
76
		<?php p($pinned === 1 ? 'first-pinned' : '') ?>
77
		<?php if (isset($item['defaultExpandedState']) && $item['defaultExpandedState']) { ?> open<?php } ?>"
78
		<?php if (isset($item['folderPosition'])) { ?> folderposition="<?php p($item['folderPosition']); ?>" <?php } ?>>
79
80
		<a href="<?php p(isset($item['href']) ? $item['href'] : '#') ?>"
81
		   class="nav-icon-<?php p(isset($item['icon']) && $item['icon'] !== '' ? $item['icon'] : $item['id']) ?> svg"><?php p($item['name']); ?></a>
82
83
84
		<?php
85
		NavigationElementMenu($item);
86
		if (isset($item['sublist'])) {
87
			?>
88
			<button class="collapse app-navigation-noclose" <?php if (sizeof($item['sublist']) == 0) { ?> style="display: none" <?php } ?>></button>
89
			<ul id="sublist-<?php p($item['id']); ?>">
90
				<?php
91
				foreach ($item['sublist'] as $item) {
92
					$pinned = NavigationListElements($item, $l, $pinned);
93
				}
94
				?>
95
			</ul>
96
		<?php } ?>
97
	</li>
98
99
100
	<?php
101
	return $pinned;
102
}
103
104
/**
105
 * Prints the HTML for a dotmenu.
106
 *
107
 * @param $item The item to be added
108
 *
109
 * @return void
110
 */
111
function NavigationElementMenu($item) {
112
	if (isset($item['menubuttons']) && $item['menubuttons'] === 'true') {
113
		?>
114
		<div id="dotmenu-<?php p($item['id']); ?>"
115
			 class="app-navigation-entry-utils" <?php if (isset($item['enableMenuButton']) && $item['enableMenuButton'] === 0) { ?> style="display: none"<?php } ?>>
116
			<ul>
117
				<li class="app-navigation-entry-utils-menu-button svg">
118
					<button id="dotmenu-button-<?php p($item['id']) ?>"></button>
119
				</li>
120
			</ul>
121
		</div>
122
		<div id="dotmenu-content-<?php p($item['id']) ?>"
123
			 class="app-navigation-entry-menu">
124
			<ul>
125
126
			</ul>
127
		</div>
128
	<?php }
129
}
130