diff options
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 |