Skip to content

Commit 18e3e67

Browse files
committed
Implement layouts, fixes #3
1 parent 1d145fc commit 18e3e67

File tree

9 files changed

+39
-37
lines changed

9 files changed

+39
-37
lines changed

bin/Files.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ class Files extends \Tatter\Files\Config\Files
1515
// Whether to continue instead of throwing exceptions
1616
public $silent = true;
1717

18-
// The session variable to check for a logged-in user ID
18+
// Session variable to check for a logged-in user ID
1919
public $userSource = 'logged_in';
2020

2121
// Directory to store files (with trailing slash)
2222
public $storagePath = ROOTPATH . 'writable/files/';
2323

24+
// Layouts to use for general access and for administration
25+
public $layouts = [
26+
'public' => 'Tatter\Files\Views\layout',
27+
'manage' => 'Tatter\Files\Views\layout',
28+
];
29+
2430
// Views to display for each function
2531
public $views = [
26-
'header' => 'Tatter\Files\Views\templates\header',
27-
'footer' => 'Tatter\Files\Views\templates\footer',
2832
'dropzone' => 'Tatter\Files\Views\dropzone\config',
2933
];
3034

src/Config/Files.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@ class Files extends BaseConfig
66
{
77
// Whether to continue instead of throwing exceptions
88
public $silent = true;
9-
9+
1010
// Session variable to check for a logged-in user ID
1111
public $userSource = 'logged_in';
12-
12+
1313
// Directory to store files (with trailing slash)
1414
public $storagePath = ROOTPATH . 'writable/files/';
15-
15+
16+
// Layouts to use for general access and for administration
17+
public $layouts = [
18+
'public' => 'Tatter\Files\Views\layout',
19+
'manage' => 'Tatter\Files\Views\layout',
20+
];
21+
1622
// Views to display for each function
1723
public $views = [
18-
'header' => 'Tatter\Files\Views\templates\header',
19-
'footer' => 'Tatter\Files\Views\templates\footer',
2024
'dropzone' => 'Tatter\Files\Views\dropzone\config',
2125
];
22-
26+
2327
// Default display format; built in are 'cards', 'list', 'select'
2428
public $defaultFormat = 'cards';
2529
}

src/Controllers/Files.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public function rename($fileId = null)
187187

188188
// Display only the form for AJAX
189189
if ($this->request->isAJAX())
190-
return view('Tatter\Files\Views\renameForm', $data);
190+
return view('Tatter\Files\Views\forms\rename', $data);
191191

192192
// Display the form
193193
return view('Tatter\Files\Views\rename', $data);

src/Views/index.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?= view($config->views['header']) ?>
1+
<?= $this->extend($config->layouts['public']) ?>
2+
<?= $this->section('main') ?>
23

34
<div class="row">
45
<div class="col">
@@ -57,4 +58,4 @@
5758

5859
<?= view($config->views['dropzone']) ?>
5960

60-
<?= view($config->views['footer'], ['config' => $config]) ?>
61+
<?= $this->endSection() ?>

src/Views/templates/header.php renamed to src/Views/layout.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
<!-- Bootstrap core CSS -->
1616
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
17-
17+
1818
<!-- FontAwesome Free -->
1919
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
20-
20+
2121
<?= service('alerts')->css() ?>
2222
</head>
2323
<body>
@@ -43,3 +43,13 @@
4343
<?= service('alerts')->display() ?>
4444

4545
<main role="main" class="container my-5">
46+
47+
<?= $this->renderSection('main') ?>
48+
49+
</main><!-- /.container -->
50+
51+
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
52+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
53+
54+
</body>
55+
</html>

src/Views/messages.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?= view($config->views['header']) ?>
1+
<?= $this->extend($config->layouts['public']) ?>
2+
<?= $this->section('main') ?>
23

34
<h2>Information</h2>
45

@@ -34,4 +35,4 @@
3435
endif;
3536
?>
3637

37-
<?= view($config->views['footer']) ?>
38+
<?= $this->endSection() ?>

src/Views/rename.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?= view($config->views['header']) ?>
1+
<?= $this->extend($config->layouts['public']) ?>
2+
<?= $this->section('main') ?>
23

34
<div class="row">
45
<div class="col">
@@ -7,4 +8,4 @@
78
</div>
89
</div>
910

10-
<?= view($config->views['footer'], ['config' => $config]) ?>
11+
<?= $this->endSection() ?>

src/Views/templates/footer.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/Views/upload.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)