diff --git a/CHANGELOG.md b/CHANGELOG.md index da20f12..517fbc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. +## [1.0.36] - + +### Added +- getCustomTable and fetchCustomTable + ## [1.0.35] - 2021-04-01 ### Added diff --git a/composer.json b/composer.json index 49c104b..015bfd7 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "oneplace/oneplace-core", "description": "onePlace Core Application", "type": "project", - "version": "1.0.35", + "version": "1.0.36", "license": "BSD-3-Clause", "keywords": [ "laminas", diff --git a/module/Application/config/module.config.php b/module/Application/config/module.config.php index 6abe54f..384ac31 100644 --- a/module/Application/config/module.config.php +++ b/module/Application/config/module.config.php @@ -64,36 +64,6 @@ ], ], ], - 'web-contact' => [ - 'type' => Literal::class, - 'options' => [ - 'route' => '/contact', - 'defaults' => [ - 'controller' => Controller\WebController::class, - 'action' => 'contact', - ], - ], - ], - 'web-blog' => [ - 'type' => Literal::class, - 'options' => [ - 'route' => '/blog', - 'defaults' => [ - 'controller' => Controller\WebController::class, - 'action' => 'blog', - ], - ], - ], - 'web-map' => [ - 'type' => Literal::class, - 'options' => [ - 'route' => '/towns/map', - 'defaults' => [ - 'controller' => Controller\WebController::class, - 'action' => 'map', - ], - ], - ], 'filepond' => [ 'type' => Literal::class, 'options' => [ diff --git a/module/Application/data/structure.sql b/module/Application/data/structure.sql index dc72cba..97a615c 100644 --- a/module/Application/data/structure.sql +++ b/module/Application/data/structure.sql @@ -145,7 +145,7 @@ ALTER TABLE `core_perfomance_log` -- CREATE TABLE `settings` ( `settings_key` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, - `settings_value` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL + `settings_value` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ALTER TABLE `settings` diff --git a/module/Application/src/Controller/CoreApiController.php b/module/Application/src/Controller/CoreApiController.php index c657a1c..853fe64 100644 --- a/module/Application/src/Controller/CoreApiController.php +++ b/module/Application/src/Controller/CoreApiController.php @@ -66,7 +66,7 @@ public function indexAction() { * @return bool - no View File * @since 1.0.0 */ - public function listAction() { + public function listAction($aWhere = []) { $this->layout('layout/json'); $sEntityType = explode('-',$this->sSingleForm)[0]; @@ -137,7 +137,6 @@ public function listAction() { } $bPaginated = false; - $aWhere = []; if(isset($_REQUEST['filter'])) { $aFilters = json_decode($_REQUEST['filter']); if(is_array($aFilters)) { diff --git a/module/Application/src/Controller/CoreController.php b/module/Application/src/Controller/CoreController.php index e7a90ed..078ac5a 100644 --- a/module/Application/src/Controller/CoreController.php +++ b/module/Application/src/Controller/CoreController.php @@ -433,6 +433,68 @@ public function getFormTabs() { return $aTabsByForms; } + /** + * Get Custom TableGateway + * + * @param $sTableName + * @return TableGateway + * @since 1.0.36 + */ + protected function getCustomTable($sTableName) + { + return new TableGateway($sTableName, CoreController::$oDbAdapter); + } + + /** + * Fetch Custom Table via Gateway + * + * @param string $sTableName + * @param array|object $oWhere + * @return mixed + * @since 1.0.36 + */ + protected function fetchCustomTable($sTableName,$oWhere = []) { + $oTbl = $this->getCustomTable($sTableName); + + return $oTbl->select($oWhere); + } + + /** + * Insert Data to Custom Table + * + * @param $sTableName + * @param $aData + * @return false + * @since 1.0.36 + */ + protected function insertToCustomTable($sTableName,$aData) { + $oTbl = $this->getCustomTable($sTableName); + + if($oTbl->insert($aData)) { + return $oTbl->lastInsertValue; + } else { + return false; + } + } + + /** + * Update Data in custom table + * + * @param $sTableName + * @param $aData + * @param $aWhere + * @return bool + * @since 1.0.36 + */ + protected function updateCustomTable($sTableName,$aData,$aWhere) { + $oTbl = $this->getCustomTable($sTableName); + if($oTbl->update($aData,$aWhere)) { + return true; + } else { + return false; + } + } + /** * Load all permissions based on Modules * diff --git a/module/Application/src/Controller/UploadController.php b/module/Application/src/Controller/UploadController.php index 4c572f3..9cc6432 100644 --- a/module/Application/src/Controller/UploadController.php +++ b/module/Application/src/Controller/UploadController.php @@ -51,60 +51,75 @@ public function addthemeAction() { $source = $_FILES["zip_file"]["tmp_name"]; $type = $_FILES["zip_file"]["type"]; - # Check file extension - $name = explode(".", $filename); - $accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed'); - foreach($accepted_types as $mime_type) { - if($mime_type == $type) { - $okay = true; - break; + if($filename) { + + # Check file extension + $name = explode(".", $filename); + $accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed'); + foreach ($accepted_types as $mime_type) { + if ($mime_type == $type) { + $okay = true; + break; + } } - } - # allow only zip - $continue = strtolower($name[1]) == 'zip' ? true : false; - if(!$continue) { - $message = "The file you are trying to upload is not a .zip file. Please try again."; - } + # allow only zip + $continue = strtolower($name[1]) == 'zip' ? true : false; + if (!$continue) { + $message = "The file you are trying to upload is not a .zip file. Please try again."; + } - # create theme dir if its the first theme - if(!is_dir($_SERVER['DOCUMENT_ROOT'].'/../data/themes')) { - mkdir($_SERVER['DOCUMENT_ROOT'].'/../data/themes'); - } + # create theme dir if its the first theme + if (!is_dir($_SERVER['DOCUMENT_ROOT'] . '/../data/themes')) { + mkdir($_SERVER['DOCUMENT_ROOT'] . '/../data/themes'); + } - # upload theme - $target_path = $_SERVER['DOCUMENT_ROOT'].'/themes/'.$filename; // change this to the correct site path - if(move_uploaded_file($source, $target_path)) { - # unzip theme - $zip = new \ZipArchive(); - $x = $zip->open($target_path); - if ($x === true) { - $zip->extractTo($_SERVER['DOCUMENT_ROOT'].'/themes/'); // change this to the correct site path - $zip->close(); - - unlink($target_path); + # upload theme + $target_path = $_SERVER['DOCUMENT_ROOT'] . '/themes/' . $filename; // change this to the correct site path + if (move_uploaded_file($source, $target_path)) { + # unzip theme + $zip = new \ZipArchive(); + $x = $zip->open($target_path); + if ($x === true) { + $zip->extractTo($_SERVER['DOCUMENT_ROOT'] . '/themes/'); // change this to the correct site path + $zip->close(); + + unlink($target_path); + } + $message = "Your .zip file was uploaded and unpacked."; + } else { + $message = "There was a problem with the upload. Please try again."; } - $message = "Your .zip file was uploaded and unpacked."; - } else { - $message = "There was a problem with the upload. Please try again."; - } - echo $message; + echo $message; - # todo: theme name MUST be dynamic - define how to determine correct name, maybe add a json to theme - # because currently we only have zip name as indicator which is like nothing - $sThemeName = 'vuze'; + # todo: theme name MUST be dynamic - define how to determine correct name, maybe add a json to theme + # because currently we only have zip name as indicator which is like nothing + $sThemeName = explode('-',$filename)[0]; - # Install Layouts - foreach(glob($_SERVER['DOCUMENT_ROOT'].'/themes/'.$sThemeName.'/view/layout/*',GLOB_NOSORT) as $sThemeFile) { - rename($sThemeFile,$_SERVER['DOCUMENT_ROOT'].'/../module/Application/view/layout/'.basename($sThemeFile)); - } - # Install Partials - foreach(glob($_SERVER['DOCUMENT_ROOT'].'/themes/'.$sThemeName.'/view/partial/*',GLOB_NOSORT) as $sThemeFile) { - rename($sThemeFile,$_SERVER['DOCUMENT_ROOT'].'/../module/Application/view/partial/'.basename($sThemeFile)); - } + # Install Layouts + foreach (glob($_SERVER['DOCUMENT_ROOT'] . '/themes/' . $sThemeName . '/view/layout/*', GLOB_NOSORT) as $sThemeFile) { + rename($sThemeFile, $_SERVER['DOCUMENT_ROOT'] . '/../module/Application/view/layout/' . basename($sThemeFile)); + } + # Install Partials + if(!is_dir($_SERVER['DOCUMENT_ROOT'] . '/../module/Application/view/theme/')) { + mkdir($_SERVER['DOCUMENT_ROOT'] . '/../module/Application/view/theme/'); + } + if(!is_dir($_SERVER['DOCUMENT_ROOT'] . '/../module/Application/view/theme/'.$sThemeName)) { + mkdir($_SERVER['DOCUMENT_ROOT'] . '/../module/Application/view/theme/'.$sThemeName); + } + foreach (glob($_SERVER['DOCUMENT_ROOT'] . '/themes/' . $sThemeName . '/view/theme/'.$sThemeName.'/*', GLOB_NOSORT) as $sThemeFile) { + rename($sThemeFile, $_SERVER['DOCUMENT_ROOT'] . '/../module/Application/view/theme/'.$sThemeName.'/' . basename($sThemeFile)); + } + # Install Partials + foreach (glob($_SERVER['DOCUMENT_ROOT'] . '/themes/' . $sThemeName . '/view/partial/*', GLOB_NOSORT) as $sThemeFile) { + rename($sThemeFile, $_SERVER['DOCUMENT_ROOT'] . '/../module/Application/view/partial/' . basename($sThemeFile)); + } - echo 'theme files installed'; + echo 'theme files installed'; + } else { + echo 'theme was not uploaded'; + } return $this->redirect()->toRoute('application',['action'=>'themes']); } diff --git a/module/Application/src/Module.php b/module/Application/src/Module.php index 65d0032..1ea365c 100644 --- a/module/Application/src/Module.php +++ b/module/Application/src/Module.php @@ -27,7 +27,7 @@ class Module { * * @since 1.0.0 */ - const VERSION = '1.0.35'; + const VERSION = '1.0.36'; public function getConfig() : array {