diff --git a/module/Application/config/module.config.php b/module/Application/config/module.config.php index c56183a..74559ff 100644 --- a/module/Application/config/module.config.php +++ b/module/Application/config/module.config.php @@ -74,10 +74,24 @@ ], ], ], + 'quicksearch' => [ + 'type' => Literal::class, + 'options' => [ + 'route' => '/quicksearch', + 'defaults' => [ + 'controller' => Controller\IndexController::class, + 'action' => 'quicksearch', + ], + ], + ], 'application' => [ 'type' => Segment::class, 'options' => [ - 'route' => '/application[/:action]', + 'route' => '/application[/:action[/:id]]', + 'constraints' => [ + 'action' => '[a-zA-Z][a-zA-Z0-9_-]*', + 'id' => '[0-9]+', + ], 'defaults' => [ 'controller' => Controller\IndexController::class, 'action' => 'index', diff --git a/module/Application/data/data.sql b/module/Application/data/data.sql index a52d3da..e2a1cdb 100644 --- a/module/Application/data/data.sql +++ b/module/Application/data/data.sql @@ -17,7 +17,10 @@ INSERT INTO `permission` (`permission_key`, `module`, `label`, `nav_label`, `nav ('addtheme', 'Application\\Controller\\IndexController', 'Upload Theme', '', '/application/addtheme', 0), ('themes', 'Application\\Controller\\IndexController', 'Theme Selection', '', '/application/themes', 0), ('filepond', 'Application\\Controller\\IndexController', 'Upload Featured Image', '', '', 0), -('uppy', 'Application\\Controller\\IndexController', 'Gallery Upload', '', '', 0); +('uppy', 'Application\\Controller\\IndexController', 'Gallery Upload', '', '', 0), +('togglemediapub', 'Application\\Controller\\IndexController', 'Gallery Upload', '', '', 0), +('updateuppysort', 'Application\\Controller\\IndexController', 'Gallery Upload', '', '', 0), +('quicksearch', 'Application\\Controller\\IndexController', 'Quick Search', '', '', 0); -- -- Default Widgets diff --git a/module/Application/data/structure.sql b/module/Application/data/structure.sql index 8544706..adcfb60 100644 --- a/module/Application/data/structure.sql +++ b/module/Application/data/structure.sql @@ -180,6 +180,28 @@ ALTER TABLE `core_api_key` ALTER TABLE `core_api_key` MODIFY `Apikey_ID` int(11) NOT NULL AUTO_INCREMENT; +-- +-- Gallery Media +-- +CREATE TABLE `core_gallery_media` ( + `Media_ID` int(11) NOT NULL, + `filename` varchar(255) NOT NULL, + `entity_idfs` int(11) NOT NULL, + `entity_type` varchar(50) NOT NULL, + `is_public` tinyint(1) NOT NULL, + `created_by` int(11) NOT NULL, + `created_date` datetime NOT NULL, + `modified_by` int(11) NOT NULL, + `modified_date` datetime NOT NULL, + `sort_id` int(4) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +ALTER TABLE `core_gallery_media` + ADD PRIMARY KEY (`Media_ID`); + +ALTER TABLE `core_gallery_media` + MODIFY `Media_ID` int(11) NOT NULL AUTO_INCREMENT; + -- -- Save -- diff --git a/module/Application/language/de_DE.mo b/module/Application/language/de_DE.mo index 3767778..c40ca85 100644 Binary files a/module/Application/language/de_DE.mo and b/module/Application/language/de_DE.mo differ diff --git a/module/Application/language/de_DE.po b/module/Application/language/de_DE.po index 442b498..9082605 100644 --- a/module/Application/language/de_DE.po +++ b/module/Application/language/de_DE.po @@ -67,3 +67,15 @@ msgstr "Kontakt" msgid "Terms & Conditions" msgstr "AGB" + +msgid "Is showed" +msgstr "Wird angezeigt" + +msgid "Show" +msgstr "Anzeigen" + +msgid "Hide" +msgstr "Verstecken" + +msgid "Not showed" +msgstr "Wird nicht angezeigt" diff --git a/module/Application/src/Controller/CoreController.php b/module/Application/src/Controller/CoreController.php index 042deef..6149ad9 100644 --- a/module/Application/src/Controller/CoreController.php +++ b/module/Application/src/Controller/CoreController.php @@ -121,6 +121,7 @@ public function __construct(AdapterInterface $oDbAdapter,$oTableGateway = false, CoreController::$aCoreTables['core-widget'] = new TableGateway('core_widget',CoreController::$oDbAdapter); CoreController::$aCoreTables['user-widget'] = new TableGateway('core_widget_user',CoreController::$oDbAdapter); CoreController::$aCoreTables['core-statistic'] = new TableGateway('core_statistic',CoreController::$oDbAdapter); + CoreController::$aCoreTables['core-gallery-media'] = new TableGateway('core_gallery_media',CoreController::$oDbAdapter); $this->loadSettings(); } diff --git a/module/Application/src/Controller/IndexController.php b/module/Application/src/Controller/IndexController.php index f7e7164..83d8cf6 100644 --- a/module/Application/src/Controller/IndexController.php +++ b/module/Application/src/Controller/IndexController.php @@ -113,9 +113,20 @@ public function updateAction() { } } + /** + * Add new theme to oneplace + * + * @return \Laminas\Http\Response|ViewModel + */ public function addthemeAction() { $this->setThemeBasedLayout('application'); + # Check if zip extension is loaded + if(!extension_loaded('zip')) { + $this->flashMessenger()->addErrorMessage('You need php-zip extension enabled on your webserver to add new themes'); + $this->redirect()->toRoute('application',['action'=>'themes']); + } + $oRequest = $this->getRequest(); if(!$oRequest->isPost()) { @@ -214,6 +225,12 @@ private function parseSQLInstallFile($sFile,$oAdapter) { } } + /** + * Server-Side for Filepond Upload + * + * @return bool + * @since 1.0.7 + */ public function filepondAction() { $this->layout('layout/json'); @@ -282,6 +299,12 @@ public function filepondAction() { } } + /** + * Server Side for UPPY Fileupload + * + * @return bool + * @since 1.0.7 + */ public function uppyAction() { $this->layout('layout/json'); @@ -290,16 +313,7 @@ public function uppyAction() { $sPath = ''; $oEntityTbl = false; - var_dump($sEntityType); - switch($sEntityType) { - case 'skeleton': - $oEntityTbl = CoreController::$oServiceManager->get(\OnePlace\Skeleton\Model\SkeletonTable::class); - $oEntity = $oEntityTbl->getSingle($iEntityID); - if($oEntity) { - $sPath = $_SERVER['DOCUMENT_ROOT'].'/data/'.$sEntityType.'/'.$oEntity->getID().'/'; - } - break; default: $oForm = CoreController::$aCoreTables['core-form']->select(['form_key'=>$sEntityType.'-single']); if(count($oForm) > 0) { @@ -309,14 +323,126 @@ public function uppyAction() { if($oEntity) { $sPath = $_SERVER['DOCUMENT_ROOT'].'/data/'.$sEntityType.'/'.$oEntity->getID().'/'; } + if(!is_dir($sPath)) { + mkdir($sPath); + } + } + $aFile = $_FILES['files']; + if(move_uploaded_file($aFile['tmp_name'][0],$sPath.'/'.trim($aFile['name'][0]))) { + if(isset($oForm)) { + CoreController::$aCoreTables['core-gallery-media']->insert([ + 'filename'=>trim($aFile['name'][0]), + 'entity_idfs'=>$iEntityID, + 'entity_type'=>$sEntityType, + 'is_public'=>0, + 'created_by'=>CoreController::$oSession->oUser->getID(), + 'created_date'=>date('Y-m-d H:i:s',time()), + 'modified_by'=>CoreController::$oSession->oUser->getID(), + 'modified_date'=>date('Y-m-d H:i:s',time()), + 'sort_id'=>0, + ]); + } } break; } - $aFile = $_FILES['files']; - if(move_uploaded_file($aFile['tmp_name'][0],$sPath.'/'.trim($aFile['name'][0]))) { - echo 'done'; + + return false; + } + + /** + * Sorting for uppy galleries + * + * @return bool no viewfile. echo json + * @since 1.0.12 + */ + public function updateuppysortAction() { + $this->layout('layout/json'); + + + $oRequest = $this->getRequest(); + $aImagesToSort = $oRequest->getPost('images'); + + $oGalleryTbl = CoreController::$aCoreTables['core-gallery-media']; + + $iSortID = 0; + # Loop over all columns provided + foreach($aImagesToSort as $sImgInfo) { + $iMediaID = substr($sImgInfo,strlen('gallery-media-')); + $oGalleryTbl->update(['sort_id'=>$iSortID],'Media_ID = '.$iMediaID); + $iSortID++; + } + + $aReturn = ['state'=>'success','message'=>'gallery successfully updated']; + + echo json_encode($aReturn); + + return false; + } + + /** + * Toggle Media Public Status + * + * @return \Laminas\Http\Response + * @since 1.0.12 + */ + public function togglemediapubAction() { + $this->layout('layout/json'); + + $iMediaID = $this->params()->fromRoute('id',0); + + if($iMediaID != 0) { + $oGalleryTbl = CoreController::$aCoreTables['core-gallery-media']; + $oMedia = $oGalleryTbl->select(['Media_ID'=>$iMediaID]); + if(count($oMedia) > 0) { + $oMedia = $oMedia->current(); + $bPublic = ($oMedia->is_public == 1) ? 0 : 1; + $oGalleryTbl->update(['is_public'=>$bPublic],'Media_ID = '.$iMediaID); + + return $this->redirect()->toRoute($oMedia->entity_type,['action'=>'view','id'=>$oMedia->entity_idfs]); + + } } + return $this->redirect()->toRoute('home'); + } + + /** + * Quicksearch across all registered entities + * + * @return bool + * @since 1.0.12 + */ + public function quicksearchAction() { + $this->layout('layout/json'); + + $aResponse = [ + 'results' => [], + ]; + + /** + * Example DATA + + $aResponse = [ + 'results' => [ + [ + 'text' => 'Articles', + 'children' => [ + ['id' => 1,'text' => 'Test Skel','view_link'=>'/article/view/##ID##'], + ['id' => 2,'text' => 'Test Skel 2','view_link'=>'/article/view/##ID##'], + ] + ], + [ + 'text' => 'Users', + 'children' => [ + ['id' => 1,'text' => 'Admin','view_link'=>'/user/view/##ID##'], + ] + ] + ], + ]; + * */ + + echo json_encode($aResponse); + return false; } } diff --git a/module/Application/view/partial/quicksearch.phtml b/module/Application/view/partial/quicksearch.phtml new file mode 100644 index 0000000..51da261 --- /dev/null +++ b/module/Application/view/partial/quicksearch.phtml @@ -0,0 +1,24 @@ + + + + \ No newline at end of file diff --git a/module/Application/view/partial/webgallery-add.phtml b/module/Application/view/partial/webgallery-add.phtml new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/module/Application/view/partial/webgallery-add.phtml @@ -0,0 +1 @@ +getTable()); +$oImgSel->where([ + 'entity_idfs'=>$oItem->getID(), + 'entity_type'=>$sEntityType, +]); +$oImgSel->order('sort_id ASC'); + +$aImages = CoreController::$aCoreTables['core-gallery-media']->selectWith($oImgSel); +?> + +