summaryrefslogtreecommitdiff
path: root/src/ste/FilesystemStorageAccess.php
diff options
context:
space:
mode:
authorLaria Carolin Chabowski <laria@laria.me>2020-04-26 16:48:01 +0200
committerLaria Carolin Chabowski <laria@laria.me>2020-04-26 16:48:01 +0200
commitbfd4763b4f831ed9eccbdd4717c98b7d95999d2e (patch)
tree73538562b347386a24e3b81f443a0b61309fe3de /src/ste/FilesystemStorageAccess.php
parent2464ac4fa63ccd169f36849a1f7372191066f305 (diff)
downloadste-bfd4763b4f831ed9eccbdd4717c98b7d95999d2e.tar.gz
ste-bfd4763b4f831ed9eccbdd4717c98b7d95999d2e.tar.bz2
ste-bfd4763b4f831ed9eccbdd4717c98b7d95999d2e.zip
Some simple code formatting
- Expand tabs into spaces - Remove trailing whitespace - Get rid of closing `?>` tags
Diffstat (limited to 'src/ste/FilesystemStorageAccess.php')
-rw-r--r--src/ste/FilesystemStorageAccess.php112
1 files changed, 56 insertions, 56 deletions
diff --git a/src/ste/FilesystemStorageAccess.php b/src/ste/FilesystemStorageAccess.php
index cdbce8b..d2e5e7f 100644
--- a/src/ste/FilesystemStorageAccess.php
+++ b/src/ste/FilesystemStorageAccess.php
@@ -10,60 +10,60 @@ namespace kch42\ste;
* The default <StorageAccess> implementation for loading / saving templates into a directory structure.
*/
class FilesystemStorageAccess implements StorageAccess {
- protected $sourcedir;
- protected $transcompileddir;
-
- /*
- * Constructor: __construct
- *
- * Parameters:
- * $src - The directory with the sources (Writing permissions are not mandatory, because STE does not save template sources).
- * $transc - The directory with the transcompiled templates (the PHP instance / the HTTP Server needs writing permissions to this directory).
- */
- public function __construct($src, $transc) {
- $this->sourcedir = $src;
- $this->transcompileddir = $transc;
- }
-
- public function load($tpl, &$mode) {
- $src_fn = $this->sourcedir . "/" . $tpl;
- $transc_fn = $this->transcompileddir . "/" . $tpl . ".php";
-
- if($mode == StorageAccess::MODE_SOURCE) {
- $content = @file_get_contents($src_fn);
- if($content === false) {
- throw new CantLoadTemplate("Template not found.");
- }
- return $content;
- }
-
- $src_stat = @stat($src_fn);
- $transc_stat = @stat($transc_fn);
-
- if(($src_stat === false) and ($transc_stat === false)) {
- throw new CantLoadTemplate("Template not found.");
- } else if($transc_stat === false) {
- $mode = StorageAccess::MODE_SOURCE;
- return file_get_contents($src_fn);
- } else if($src_stat === false) {
- include($transc_fn);
- return $transcompile_fx;
- } else {
- if($src_stat["mtime"] > $transc_stat["mtime"]) {
- $mode = StorageAccess::MODE_SOURCE;
- return file_get_contents($src_fn);
- } else {
- include($transc_fn);
- return $transcompile_fx;
- }
- }
- }
-
- public function save($tpl, $data, $mode) {
- $fn = (($mode == StorageAccess::MODE_SOURCE) ? $this->sourcedir : $this->transcompileddir) . "/" . $tpl . (($mode == StorageAccess::MODE_TRANSCOMPILED) ? ".php" : "");
- @mkdir(dirname($fn), 0777, true);
- if(file_put_contents($fn, "<?php\n\$transcompile_fx = $data; ?>") === false) {
- throw new CantSaveTemplate("Unable to save template.");
- }
- }
+ protected $sourcedir;
+ protected $transcompileddir;
+
+ /*
+ * Constructor: __construct
+ *
+ * Parameters:
+ * $src - The directory with the sources (Writing permissions are not mandatory, because STE does not save template sources).
+ * $transc - The directory with the transcompiled templates (the PHP instance / the HTTP Server needs writing permissions to this directory).
+ */
+ public function __construct($src, $transc) {
+ $this->sourcedir = $src;
+ $this->transcompileddir = $transc;
+ }
+
+ public function load($tpl, &$mode) {
+ $src_fn = $this->sourcedir . "/" . $tpl;
+ $transc_fn = $this->transcompileddir . "/" . $tpl . ".php";
+
+ if($mode == StorageAccess::MODE_SOURCE) {
+ $content = @file_get_contents($src_fn);
+ if($content === false) {
+ throw new CantLoadTemplate("Template not found.");
+ }
+ return $content;
+ }
+
+ $src_stat = @stat($src_fn);
+ $transc_stat = @stat($transc_fn);
+
+ if(($src_stat === false) and ($transc_stat === false)) {
+ throw new CantLoadTemplate("Template not found.");
+ } else if($transc_stat === false) {
+ $mode = StorageAccess::MODE_SOURCE;
+ return file_get_contents($src_fn);
+ } else if($src_stat === false) {
+ include($transc_fn);
+ return $transcompile_fx;
+ } else {
+ if($src_stat["mtime"] > $transc_stat["mtime"]) {
+ $mode = StorageAccess::MODE_SOURCE;
+ return file_get_contents($src_fn);
+ } else {
+ include($transc_fn);
+ return $transcompile_fx;
+ }
+ }
+ }
+
+ public function save($tpl, $data, $mode) {
+ $fn = (($mode == StorageAccess::MODE_SOURCE) ? $this->sourcedir : $this->transcompileddir) . "/" . $tpl . (($mode == StorageAccess::MODE_TRANSCOMPILED) ? ".php" : "");
+ @mkdir(dirname($fn), 0777, true);
+ if(file_put_contents($fn, "<?php\n\$transcompile_fx = $data; ?>") === false) {
+ throw new CantSaveTemplate("Unable to save template.");
+ }
+ }
}