Skip to content

Commit

Permalink
Merge pull request #39 from OnePlc/1.0.36-dev
Browse files Browse the repository at this point in the history
1.0.36 dev
  • Loading branch information
Praesidiarius authored Apr 12, 2021
2 parents a33b8d2 + d2f21e2 commit 9a13b12
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 80 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
30 changes: 0 additions & 30 deletions module/Application/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down
2 changes: 1 addition & 1 deletion module/Application/data/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
3 changes: 1 addition & 2 deletions module/Application/src/Controller/CoreApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -137,7 +137,6 @@ public function listAction() {
}

$bPaginated = false;
$aWhere = [];
if(isset($_REQUEST['filter'])) {
$aFilters = json_decode($_REQUEST['filter']);
if(is_array($aFilters)) {
Expand Down
62 changes: 62 additions & 0 deletions module/Application/src/Controller/CoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
105 changes: 60 additions & 45 deletions module/Application/src/Controller/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
Expand Down
2 changes: 1 addition & 1 deletion module/Application/src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Module {
*
* @since 1.0.0
*/
const VERSION = '1.0.35';
const VERSION = '1.0.36';

public function getConfig() : array
{
Expand Down

0 comments on commit 9a13b12

Please sign in to comment.