Skip to content

Commit

Permalink
fixes. support for external vendors
Browse files Browse the repository at this point in the history
  • Loading branch information
Praesidiarius committed Feb 17, 2020
1 parent 230a21c commit a774ee2
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 10 deletions.
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.21",
"version": "1.0.22",
"license": "BSD-3-Clause",
"keywords": [
"laminas",
Expand Down
7 changes: 6 additions & 1 deletion module/Application/data/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ INSERT INTO `core_widget` (`Widget_ID`, `widget_name`, `label`, `permission`) VA
(NULL, 'manage_themes', 'Manage Themes', 'themes-Application\\Controller\\IndexController'),
(NULL, 'discover_modules', 'Discover Modules', 'update-Application\\Controller\\IndexController'),
(NULL, 'help_support', 'Help & Support', 'index-Application\\Controller\\IndexController'),
(NULL, 'welcome_default', 'Welcome Default', 'index-Application\\Controller\\IndexController');
(NULL, 'welcome_default', 'Welcome Default', 'index-Application\\Controller\\IndexController');

--
-- default vendor for updating
--
INSERT INTO `settings` (`settings_key`, `settings_value`) VALUES ('app-vendors', '[\"oneplace\"]');
47 changes: 41 additions & 6 deletions module/Application/src/Controller/CoreApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public function listAction() {
return false;
}

$iPage = $this->params()->fromRoute('id', 0);

# Set default values
$bSelect2 = true;
$sListLabel = 'label';
Expand All @@ -104,8 +106,8 @@ public function listAction() {
$translator = new Translator();
$aLangs = ['en_US','de_DE'];
foreach($aLangs as $sLoadLang) {
if(file_exists(__DIR__.'/../../../oneplace-translation/language/'.$sLoadLang.'.mo')) {
$translator->addTranslationFile('gettext', __DIR__.'/../../../oneplace-translation/language/'.$sLang.'.mo', $sEntityType, $sLoadLang);
if(file_exists('vendor/oneplace/oneplace-translation/language/'.$sLoadLang.'.mo')) {
$translator->addTranslationFile('gettext', 'vendor/oneplace/oneplace-translation/language/'.$sLang.'.mo', $sEntityType, $sLoadLang);
}
}

Expand Down Expand Up @@ -134,8 +136,17 @@ public function listAction() {
return false;
}

$bPaginated = false;
if($iPage > 0) {
$bPaginated = true;
}

# Get All Article Entities from Database
$oItemsDB = $this->oTableGateway->fetchAll(false);
$oItemsDB = $this->oTableGateway->fetchAll($bPaginated);
if($bPaginated) {
$oItemsDB->setItemCountPerPage(25);
$oItemsDB->setCurrentPageNumber($iPage);
}
if(count($oItemsDB) > 0) {
# Loop all items
foreach($oItemsDB as $oItem) {
Expand Down Expand Up @@ -241,6 +252,10 @@ public function listAction() {
'pagination' => (object)['more'=>false],
];

if($bPaginated) {
$aReturn['pages'] = $oItemsDB->getPages()->pageCount;
}

# Print List with all Entities
echo json_encode($aReturn);

Expand Down Expand Up @@ -287,8 +302,8 @@ public function getAction() {
$translator = new Translator();
$aLangs = ['en_US','de_DE'];
foreach($aLangs as $sLoadLang) {
if(file_exists(__DIR__.'/../../../oneplace-translation/language/'.$sLoadLang.'.mo')) {
$translator->addTranslationFile('gettext', __DIR__.'/../../../oneplace-translation/language/'.$sLang.'.mo', $sEntityType, $sLoadLang);
if(file_exists('vendor/oneplace/oneplace-translation/language/'.$sLoadLang.'.mo')) {
$translator->addTranslationFile('gettext', 'vendor/oneplace/oneplace-translation/language/'.$sLang.'.mo', $sEntityType, $sLoadLang);
}
}

Expand Down Expand Up @@ -373,9 +388,29 @@ public function getfieldsAction() {
$this->layout('layout/json');

$aData = $this->getPublicFormFields($this->sSingleForm);
$sEntityType = explode('-',$this->sSingleForm)[0];

# get list label from query
$sLang = 'en_US';
if(isset($_REQUEST['lang'])) {
$sLang = $_REQUEST['lang'];
}

// translating system
$translator = new Translator();
$aLangs = ['en_US','de_DE'];
foreach($aLangs as $sLoadLang) {
if(file_exists('vendor/oneplace/oneplace-translation/language/'.$sLoadLang.'.mo')) {
$translator->addTranslationFile('gettext', 'vendor/oneplace/oneplace-translation/language/'.$sLang.'.mo', $sEntityType, $sLoadLang);
}
}

$translator->setLocale($sLang);

return new ViewModel([
'aFields'=>$aData,
'aFields' => $aData,
'translator' => $translator,
'sEntityType' => $sEntityType,
]);
}
}
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.21';
const VERSION = '1.0.22';

public function getConfig() : array {
return include __DIR__ . '/../config/module.config.php';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<?php

use Application\Controller\CoreController;

?>
<div class="row">
<div class="col-md-6">
<div class="card">
Expand Down Expand Up @@ -46,7 +51,7 @@
<div class="card-body">
<ul class="list-group">
<?php
$aVendors = ['oneplace'];
$aVendors = json_decode(CoreController::$aGlobalSettings['app-vendors']);
foreach ($aVendors as $sVendor) {
$aModules = glob('vendor/'.$sVendor.'/*', GLOB_ONLYDIR);
foreach ($aModules as $sMod) {
Expand Down

0 comments on commit a774ee2

Please sign in to comment.