Passed
Push — master ( 5cdc85...37718d )
by Morris
38:53 queued 21:57
created

NavigationListElements()   F

Complexity

Conditions 16
Paths 384

Size

Total Lines 36
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 16
eloc 31
nc 384
nop 3
dl 0
loc 36
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">
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('%1$s of %2$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
0 ignored issues
show
Bug introduced by
The type The was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
61
 * @param $l Translator
0 ignored issues
show
Bug introduced by
The type Translator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
62
 * @param $pinned IntegerValue to count the pinned entries at the bottom
0 ignored issues
show
Bug introduced by
The type IntegerValue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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) {
0 ignored issues
show
introduced by
$item is overwriting one of the parameters of this function.
Loading history...
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