Skip to content

Commit 14b140e

Browse files
committed
Custom assets path.
Added the ability to specify a custom assets path to the instantiated Web object.
1 parent c2d881b commit 14b140e

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
99
[2020.07.31; Maikuolan]: Improved the way that the (generated by ...) notice, displayed at the footer of HTML pages, is rendered.
1010

1111
[2020.10.09; Maikuolan]: Aesthetic patch + added a new theme.
12+
13+
### v3.1.0
14+
15+
[2020.10.30; New Feature; Maikuolan]: Added the ability to specify a custom assets path to the instantiated Web object.

src/Web.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Upload handler (last modified: 2020.07.31).
11+
* This file: Upload handler (last modified: 2020.10.30).
1212
*/
1313

1414
namespace phpMussel\Web;
@@ -30,6 +30,11 @@ class Web
3030
*/
3131
private $AssetsPath = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR;
3232

33+
/**
34+
* @var string A path for any custom front-end asset files.
35+
*/
36+
public $CustomAssetsPath = '';
37+
3338
/**
3439
* @var string The path to the upload handler's L10N files.
3540
*/
@@ -49,6 +54,7 @@ class Web
4954
* Construct the loader.
5055
*
5156
* @param \phpMussel\Core\Loader $Loader The instantiated loader object, passed by reference.
57+
* @param \phpMussel\Core\Scanner $Scanner The instantiated scanner object, passed by reference.
5258
*/
5359
public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Scanner &$Scanner)
5460
{
@@ -300,11 +306,20 @@ public function scan()
300306
}
301307

302308
/** Determine which template file to use. */
303-
if (is_readable($this->AssetsPath . 'template_' . $this->Loader->Configuration['web']['theme'] . '.html')) {
304-
$TemplateFile = $this->AssetsPath . 'template_' . $this->Loader->Configuration['web']['theme'] . '.html';
305-
} elseif (is_readable($this->AssetsPath . 'template_default.html')) {
306-
$TemplateFile = $this->AssetsPath . 'template_default.html';
309+
if ($this->CustomAssetsPath) {
310+
if (is_readable($this->CustomAssetsPath . 'template_' . $this->Loader->Configuration['web']['theme'] . '.html')) {
311+
$TemplateFile = $this->CustomAssetsPath . 'template_' . $this->Loader->Configuration['web']['theme'] . '.html';
312+
} elseif (is_readable($this->CustomAssetsPath . 'template_default.html')) {
313+
$TemplateFile = $this->CustomAssetsPath . 'template_default.html';
314+
}
307315
} else {
316+
if (is_readable($this->AssetsPath . 'template_' . $this->Loader->Configuration['web']['theme'] . '.html')) {
317+
$TemplateFile = $this->AssetsPath . 'template_' . $this->Loader->Configuration['web']['theme'] . '.html';
318+
} elseif (is_readable($this->AssetsPath . 'template_default.html')) {
319+
$TemplateFile = $this->AssetsPath . 'template_default.html';
320+
}
321+
}
322+
if (empty($TemplateFile)) {
308323
$TemplateFile = '';
309324
}
310325

0 commit comments

Comments
 (0)