diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2020-02-06 18:06:07 +0100 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2020-02-06 18:06:38 +0100 |
commit | 9d3f97870810e739041eccad234d47308747cb1f (patch) | |
tree | 94c7491ed5313de517c28ecc8c49a341d99db636 /app/class/Modeladmin.php | |
parent | 1aa2b136656e42d8523d31f79e9cc1321c1dbba9 (diff) | |
download | wcms-9d3f97870810e739041eccad234d47308747cb1f.tar.gz wcms-9d3f97870810e739041eccad234d47308747cb1f.zip |
new feature : admin database manager fix #12
Diffstat (limited to 'app/class/Modeladmin.php')
-rw-r--r-- | app/class/Modeladmin.php | 48 |
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 |