aboutsummaryrefslogtreecommitdiff
path: root/app/class/Modeladmin.php
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2020-02-06 18:07:53 +0100
committervincent-peugnet <v.peugnet@free.fr>2020-02-06 18:07:53 +0100
commit08a26d4d6fbd45cdc136b60d0fb30f53ac4fd2f7 (patch)
tree209ac84720836e39c6c96f131b5049e7ad6096b2 /app/class/Modeladmin.php
parentde939de88e1ed166d827616e3d17a22fe549202a (diff)
parent9d3f97870810e739041eccad234d47308747cb1f (diff)
downloadwcms-08a26d4d6fbd45cdc136b60d0fb30f53ac4fd2f7.tar.gz
wcms-08a26d4d6fbd45cdc136b60d0fb30f53ac4fd2f7.zip
Merge branch 'better-admin'
Diffstat (limited to 'app/class/Modeladmin.php')
-rw-r--r--app/class/Modeladmin.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/app/class/Modeladmin.php b/app/class/Modeladmin.php
new file mode 100644
index 0000000..54c4f0c
--- /dev/null
+++ b/app/class/Modeladmin.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace Wcms;
+
+class Modeladmin extends Model
+{
+
+
+ /**
+ * List all availalble pages databases
+ *
+ * @return array
+ */
+ public function pagesdblist() : array
+ {
+ $dblist = glob(self::PAGES_DIR . '*', GLOB_ONLYDIR);
+ $dblist = array_map('basename', $dblist);
+
+ return $dblist;
+ }
+
+ /**
+ * Duplicate actual page database using new name
+ *
+ * @param string $name of the new database
+ */
+ public function duplicate(string $name)
+ {
+ $this->copydb(Config::pagetable(), $name);
+ }
+
+ /**
+ * Copy database folder to a new folder if it doeas not already exsit
+ *
+ * @param string $db name of source page database to copy
+ * @param string $name of the destination database
+ */
+ public function copydb(string $db, string $name)
+ {
+ $dbdir = self::PAGES_DIR . $db;
+ $newdbdir = self::PAGES_DIR . idclean($name);
+ if(is_dir($dbdir) && !is_dir($newdbdir)) {
+ recurse_copy($dbdir, $newdbdir);
+ }
+ }
+}
+
+?> \ No newline at end of file