Passed
Branch develop (56c45f)
by Jens
02:42
created

renderFolder()   B

Complexity

Conditions 6
Paths 8

Size

Total Lines 43
Code Lines 43

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
cc 6
eloc 43
nc 8
nop 5
dl 0
loc 43
rs 8.439
c 4
b 0
f 1
1
<?
2
/**
3
 * @param \CloudControl\Cms\storage\entities\Document $document
4
 * @param string $cmsPrefix
5
 * @param string $slugPrefix
6
 * @param bool $root
7
 * @param \CloudControl\Cms\cc\Request $request
8
 */
9
function renderFolder($document, $cmsPrefix, $slugPrefix = '', $root = false, $request)
10
{ ?>
11
  <div class="grid-box-8">
12
    <h3>
13
      <a class="btn documentTitle openFolder" data-slug="<?= $slugPrefix . $document->slug ?>" title="Open">
14
        <i class="fa fa-folder-o "></i> <?= $document->title ?>
15
      </a>
16
    </h3>
17
  </div>
18
  <div class="documentActions grid-box-4">
19
      <? renderAction(
20
          true,
21
          'Edit',
22
          '',
23
          $request::$subfolders . $cmsPrefix . '/documents/edit-folder?slug=' . $slugPrefix . $document->slug,
24
          'pencil'); ?>
25
      <? renderAction(
26
          true,
27
          'Delete',
28
          'error',
29
          $request::$subfolders . $cmsPrefix . '/documents/delete-folder?slug=' . $slugPrefix . $document->slug,
30
          'trash',
31
          'return confirm(\'Are you sure you want to delete this document?\');'); ?>
0 ignored issues
show
Bug introduced by
'return confirm('Are you...lete this document?');' of type string is incompatible with the type boolean expected by parameter $onclick of renderAction(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
          /** @scrutinizer ignore-type */ 'return confirm(\'Are you sure you want to delete this document?\');'); ?>
Loading history...
32
  </div>
33
  <ul class="documents grid-wrapper nested<?= $root ? ' root' : '' ?>">
34
      <? foreach ($document->getContent() as $subDocument) : ?>
35
        <li class="grid-container">
36
            <? if ($subDocument->type == 'document') : ?>
37
                <? renderDocument($subDocument, $cmsPrefix, $slugPrefix . $document->slug . '/', $request); ?>
38
            <? elseif ($subDocument->type == 'folder') : ?>
39
                <? renderFolder($subDocument, $cmsPrefix, $slugPrefix . $document->slug . '/', false, $request); ?>
40
            <? endif ?>
41
        </li>
42
      <? endforeach ?>
43
      <? if (count($document->getContent()) == 0) : ?>
44
        <li class="grid-container">
45
          <div class="grid-box-12">
46
            <i class="fa fa-ellipsis-h empty"></i>
47
            <i>Empty</i>
48
          </div>
49
        </li>
50
      <? endif ?>
51
  </ul>
52
<? } ?>