public function fn_genfromfolder($location, $params) { $folder = Qdmvc::getPluginDir('controllers/pages'); $count = 0; foreach (glob("{$folder}/*") as $file) { if ($count == 0) { QdQdmvcPage::delete_all(); } if (is_dir($file)) { $folder_name = basename($file); if (QdQdmvcPage::GET($folder_name) == null) { $tmp = new QdQdmvcPage(); $tmp->id = $folder_name; if ($tmp->save()) { $count++; } } } } $this->pushValidateError('', sprintf('Total items: %s', $count), 'info'); return true; }
public function fn_genfromfolder($location, $params) { $folder = Qdmvc::getPluginDir('models'); $count = 0; $t = glob("{$folder}/*"); foreach (glob("{$folder}/*") as $file) { if ($count == 0) { QdQdmvcModel::delete_all(); } if (is_file($file)) { $file_name = basename($file); $file_name = str_replace(".php", "", $file_name); if (QdQdmvcModel::GET($file_name) == null) { $tmp = new QdQdmvcModel(); $tmp->id = $file_name; if ($tmp->save()) { $count++; } } } } $this->pushValidateError('', sprintf('Total items: %s', $count), 'info'); return true; }
public static function cacheRemoveAll() { $folder = Qdmvc::getPluginDir('caches'); foreach (glob("{$folder}/*") as $file) { if (is_dir($file)) { continue; } else { unlink($file); } } return true; }
public static function extractQdmvcCoreFiles() { $folders = array(Qdmvc::getPluginDir('controllers/dataports/root') => '_core_pkg/controllers/dataports/root', Qdmvc::getPluginDir('controllers/pages/root') => '_core_pkg/controllers/pages/root', Qdmvc::getPluginDir('controllers/pages/root_list') => '_core_pkg/controllers/pages/root_list', Qdmvc::getPluginDir('controllers/pages/root_setup') => '_core_pkg/controllers/pages/root_setup', Qdmvc::getPluginDir('controllers/pages/user') => '_core_pkg/controllers/pages/user', Qdmvc::getPluginDir('controllers/pages/user_list') => '_core_pkg/controllers/pages/user_list', Qdmvc::getPluginDir('helpers') => '_core_pkg/helpers', Qdmvc::getPluginDir('views') => '_core_pkg/views', Qdmvc::getPluginDir('widgets') => '_core_pkg/widgets'); $coreFiles = array(Qdmvc::getPluginDir('index.php') => '_core_pkg', Qdmvc::getPluginDir('qdmvc.php') => '_core_pkg', Qdmvc::getPluginDir('models/QdRoot.php') => '_core_pkg/models', Qdmvc::getPluginDir('models/QdRootReport.php') => '_core_pkg/models', Qdmvc::getPluginDir('models/QdRootSetup.php') => '_core_pkg/models', Qdmvc::getPluginDir('models/QdUser.php') => '_core_pkg/models', Qdmvc::getPluginDir('controllers/pages/index.php') => '_core_pkg/controllers/pages', Qdmvc::getPluginDir('controllers/menus/index.php') => '_core_pkg/controllers/menus', Qdmvc::getPluginDir('controllers/dataports/index.php') => '_core_pkg/controllers/dataports', Qdmvc::getPluginDir('controllers/index.php') => '_core_pkg/controllers', Qdmvc::getPluginDir('native/index.php') => '_core_pkg/native', Qdmvc::getPluginDir('native/router.php') => '_core_pkg/native', Qdmvc::getPluginDir('native/register-admin-menu.php') => '_core_pkg/native', Qdmvc::getPluginDir('native/register-hook.php') => '_core_pkg/native', Qdmvc::getPluginDir('native/db-init.php') => '_core_pkg/native', Qdmvc::getPluginDir('messages/index.php') => '_core_pkg/messages', Qdmvc::getPluginDir('messages/global.php') => '_core_pkg/messages'); $zip = new ZipArchive(); $zipPath = Qdmvc::getPluginDir("_core_pkg.zip"); $report = ''; if ($zip->open($zipPath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) { foreach ($folders as $rootPath => $rp) { $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($rootPath), RecursiveIteratorIterator::LEAVES_ONLY); foreach ($files as $name => $file) { // Skip directories (they would be added automatically) if (!$file->isDir()) { // Get real and relative path for current file $filePath = $file->getRealPath(); $relativePath = $rp . '/' . substr($filePath, strlen($rootPath) + 1); // Add current file to archive $zip->addFile($filePath, $relativePath); $report .= $filePath . ' => ' . $relativePath . '<br>'; } } } foreach ($coreFiles as $file => $rp) { // Skip directories (they would be added automatically) if (!is_dir($file)) { $rootPath = dirname($file); // Get real and relative path for current file $relativePath = $rp . '/' . substr($file, strlen($rootPath) + 1); // Add current file to archive $zip->addFile($file, $relativePath); $report .= $file . ' => ' . $relativePath . '<br>'; } } $zip->close(); } return $report; }