Skip to content

Commit

Permalink
rebase to current skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
JBinggi committed Jan 30, 2020
1 parent 91cb5c3 commit 4c7eb2b
Show file tree
Hide file tree
Showing 25 changed files with 489 additions and 151 deletions.
25 changes: 0 additions & 25 deletions CHANGELOG.md

This file was deleted.

1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"mvc",
"project",
"oneplace",
"oneplace-module",
"framework"
],
"require-dev": {
Expand Down
12 changes: 12 additions & 0 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,16 @@
'project' => __DIR__ . '/../view',
],
],

# Translator
'translator' => [
'locale' => 'de_DE',
'translation_file_patterns' => [
[
'type' => 'gettext',
'base_dir' => __DIR__ . '/../language',
'pattern' => '%s.mo',
],
],
],
];
6 changes: 0 additions & 6 deletions data/createmodulefromskeleton.ps1

This file was deleted.

10 changes: 9 additions & 1 deletion data/install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ INSERT INTO `permission` (`permission_key`, `module`, `label`, `nav_label`, `nav
--
-- Form
--
INSERT INTO `core_form` (`form_key`, `label`) VALUES ('project-single', 'Project');
INSERT INTO `core_form` (`form_key`, `label`, `entity_class`, `entity_tbl_class`) VALUES
('project-single', 'Project', 'OnePlace\\Project\\Model\\Project', 'OnePlace\\Project\\Model\\ProjectTable');

--
-- Index List
Expand All @@ -56,4 +57,11 @@ INSERT INTO `core_form_button` (`Button_ID`, `label`, `icon`, `title`, `href`, `
INSERT INTO `core_form_field` (`Field_ID`, `type`, `label`, `fieldkey`, `tab`, `form`, `class`, `url_view`, `url_ist`, `show_widget_left`, `allow_clear`, `readonly`, `tbl_cached_name`, `tbl_class`, `tbl_permission`) VALUES
(NULL, 'text', 'Name', 'label', 'project-base', 'project-single', 'col-md-3', '/project/view/##ID##', '', 0, 1, 0, '', '', '');

--
-- Default Widgets
--
INSERT INTO `core_widget` (`Widget_ID`, `widget_name`, `label`, `permission`) VALUES
(NULL, 'project_dailystats', 'Project - Daily Stats', 'index-Project\\Controller\\ProjectController'),
(NULL, 'project_taginfo', 'Project - Tag Info', 'index-Project\\Controller\\ProjectController');

COMMIT;
Empty file removed docs/book/index.md
Empty file.
28 changes: 0 additions & 28 deletions docs/book/quick-start.md

This file was deleted.

Binary file added language/de_DE.mo
Binary file not shown.
68 changes: 68 additions & 0 deletions language/de_DE.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2019-02-13 18:38+0100\n"
"PO-Revision-Date: 2020-01-30 18:54+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.2.4\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: de_DE\n"

msgid "Model"
msgstr "Modell"

msgid "Coolant"
msgstr "Kühlmittel"

msgid "Internal"
msgstr "Intern"

msgid "State"
msgstr "Status"

msgid "Year of Construction"
msgstr "Baujahr"

msgid "Origin"
msgstr "Ursprungsland"

msgid "Categories"
msgstr "Kategorien"

msgid "Condition"
msgstr "Zustand"

msgid "Owner"
msgstr "Eigentümer"

msgid "Loadbase"
msgstr "Frachtbasis"

msgid "Specialaddons"
msgstr "Spezialzubehör"

msgid "Description"
msgstr "Beschreibung"

msgid "Created"
msgstr "Erstellt"

msgid "Last Edited"
msgstr "Zuletzt bearbeitet"

msgid "Edit Project"
msgstr "Project bearbeiten"

msgid "Add Project"
msgstr "Project erfassen"

msgid "Dates"
msgstr "Daten"

msgid "Images"
msgstr "Bilder"
Binary file added language/en_US.mo
Binary file not shown.
20 changes: 20 additions & 0 deletions language/en_US.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2019-02-13 18:38+0100\n"
"PO-Revision-Date: 2020-01-30 18:55+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.2.4\n"
"X-Poedit-Basepath: .\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: en_US\n"

msgid "Testmodell"
msgstr "Testmodel"

msgid "Neue Location"
msgstr "New Location"
15 changes: 0 additions & 15 deletions mkdocs.yml

This file was deleted.

129 changes: 127 additions & 2 deletions src/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use OnePlace\Project\Model\ProjectTable;
use Laminas\View\Model\ViewModel;
use Laminas\Db\Adapter\AdapterInterface;
use Zend\I18n\Translator\Translator;

class ApiController extends CoreController {
/**
Expand Down Expand Up @@ -67,7 +68,46 @@ public function indexAction() {
public function listAction() {
$this->layout('layout/json');

# Check license
if(!$this->checkLicense('project')) {
$aReturn = ['state'=>'error','message'=>'no valid license for project found'];
echo json_encode($aReturn);
return false;
}

# Set default values
$bSelect2 = true;
$sListLabel = 'label';

# Get list mode from query
if(isset($_REQUEST['listmode'])) {
if($_REQUEST['listmode'] == 'entity') {
$bSelect2 = false;
}
}

# get list label from query
if(isset($_REQUEST['listlabel'])) {
$sListLabel = $_REQUEST['listlabel'];
}

# 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(__DIR__.'/../../../oneplace-translation/language/'.$sLoadLang.'.mo')) {
$translator->addTranslationFile('gettext', __DIR__.'/../../../oneplace-translation/language/'.$sLang.'.mo', 'project', $sLoadLang);
}
}

$translator->setLocale($sLang);


/**
* todo: enforce to use /api/contact instead of /contact/api so we can do security checks in main api controller
Expand All @@ -79,16 +119,94 @@ public function listAction() {
}
**/

# Init Item List for Response
$aItems = [];

$aFields = $this->getFormFields('project-single');
$aFieldsByKey = [];
# fields are sorted by tab , we need an index with all fields
foreach($aFields as $oField) {
$aFieldsByKey[$oField->fieldkey] = $oField;
}

# only allow form fields as list labels
if(!array_key_exists($sListLabel,$aFieldsByKey)) {
$aReturn = [
'state'=>'error',
'results' => [],
'message' => 'invalid list label',
];

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

# Get All Project Entities from Database
$oItemsDB = $this->oTableGateway->fetchAll(false);
if(count($oItemsDB) > 0) {
# Loop all items
foreach($oItemsDB as $oItem) {

# Output depending on list mode
if($bSelect2) {
$aItems[] = ['id'=>$oItem->getID(),'text'=>$oItem->getLabel()];
$sVal = null;
# get value for list label field
switch($aFieldsByKey[$sListLabel]->type) {
case 'select':
$oTag = $oItem->getSelectField($aFieldsByKey[$sListLabel]->fieldkey);
if($oTag) {
$sVal = $oTag->getLabel();
}
break;
case 'text':
case 'date':
case 'textarea':
$sVal = $oItem->getTextField($aFieldsByKey[$sListLabel]->fieldkey);
break;
default:
break;
}
$aItems[] = ['id'=>$oItem->getID(),'text'=>$sVal];
} else {
$aItems[] = $oItem;
# Init public item
$aPublicItem = [];

# add all fields to item
foreach($aFields as $oField) {
switch($oField->type) {
case 'multiselect':
# get selected
$oTags = $oItem->getMultiSelectField($oField->fieldkey);
$aTags = [];
foreach($oTags as $oTag) {
$aTags[] = ['id'=>$oTag->id,'label'=>$translator->translate($oTag->text,'project',$sLang)];
}
$aPublicItem[$oField->fieldkey] = $aTags;
break;
case 'select':
# get selected
$oTag = $oItem->getSelectField($oField->fieldkey);
if($oTag) {
if (property_exists($oTag, 'tag_value')) {
$aPublicItem[$oField->fieldkey] = ['id' => $oTag->id, 'label' => $translator->translate($oTag->tag_value,'project',$sLang)];
} else {
$aPublicItem[$oField->fieldkey] = ['id' => $oTag->getID(), 'label' => $translator->translate($oTag->getLabel(),'project',$sLang)];
}
}
break;
case 'text':
case 'date':
case 'textarea':
$aPublicItem[$oField->fieldkey] = $translator->translate($oItem->getTextField($oField->fieldkey),'project',$sLang);
break;
default:
break;
}
}

# add item to list
$aItems[] = $aPublicItem;
}

}
Expand Down Expand Up @@ -118,6 +236,13 @@ public function listAction() {
public function getAction() {
$this->layout('layout/json');

# Check license
if(!$this->checkLicense('project')) {
$aReturn = ['state'=>'error','message'=>'no valid license for project found'];
echo json_encode($aReturn);
return false;
}

# Get Project ID from route
$iItemID = $this->params()->fromRoute('id', 0);

Expand Down
Loading

0 comments on commit 4c7eb2b

Please sign in to comment.