Skip to content

Commit 1a81549

Browse files
committed
rebase to Skeleton 1.0.8
1 parent 3daa8e3 commit 1a81549

15 files changed

Lines changed: 433 additions & 307 deletions

File tree

config/module.config.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,48 @@
5252
],
5353
],
5454
],
55+
'task-export' => [
56+
'type' => Segment::class,
57+
'options' => [
58+
'route' => '/task/export[/:action[/:id]]',
59+
'constraints' => [
60+
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
61+
'id' => '[0-9]+',
62+
],
63+
'defaults' => [
64+
'controller' => Controller\ExportController::class,
65+
'action' => 'index',
66+
],
67+
],
68+
],
69+
'task-search' => [
70+
'type' => Segment::class,
71+
'options' => [
72+
'route' => '/task/search[/:action[/:id]]',
73+
'constraints' => [
74+
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
75+
'id' => '[0-9]+',
76+
],
77+
'defaults' => [
78+
'controller' => Controller\SearchController::class,
79+
'action' => 'index',
80+
],
81+
],
82+
],
83+
'task-plugin' => [
84+
'type' => Segment::class,
85+
'options' => [
86+
'route' => '/task/plugin[/:action[/:id]]',
87+
'constraints' => [
88+
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
89+
'id' => '[0-9]+',
90+
],
91+
'defaults' => [
92+
'controller' => Controller\PluginController::class,
93+
'action' => 'index',
94+
],
95+
],
96+
],
5597
],
5698
],
5799

data/install.sql

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ INSERT INTO `permission` (`permission_key`, `module`, `label`, `nav_label`, `nav
2424
('edit', 'OnePlace\\Task\\Controller\\TaskController', 'Edit', '', '', 0),
2525
('index', 'OnePlace\\Task\\Controller\\TaskController', 'Index', 'Tasks', '/task', 1),
2626
('list', 'OnePlace\\Task\\Controller\\ApiController', 'List', '', '', 1),
27-
('view', 'OnePlace\\Task\\Controller\\TaskController', 'View', '', '', 0);
27+
('view', 'OnePlace\\Task\\Controller\\TaskController', 'View', '', '', 0),
28+
('dump', 'OnePlace\\Task\\Controller\\ExportController', 'Excel Dump', '', '', 0),
29+
('index', 'OnePlace\\Task\\Controller\\SearchController', 'Search', '', '', 0);
2830

2931
--
3032
-- Form
@@ -49,12 +51,16 @@ INSERT INTO `core_form_tab` (`Tab_ID`, `form`, `title`, `subtitle`, `icon`, `cou
4951
INSERT INTO `core_form_button` (`Button_ID`, `label`, `icon`, `title`, `href`, `class`, `append`, `form`, `mode`, `filter_check`, `filter_value`) VALUES
5052
(NULL, 'Save Task', 'fas fa-save', 'Save Task', '#', 'primary saveForm', '', 'task-single', 'link', '', ''),
5153
(NULL, 'Edit Task', 'fas fa-edit', 'Edit Task', '/task/edit/##ID##', 'primary', '', 'task-view', 'link', '', ''),
52-
(NULL, 'Add Task', 'fas fa-plus', 'Add Task', '/task/add', 'primary', '', 'task-index', 'link', '', '');
54+
(NULL, 'Add Task', 'fas fa-plus', 'Add Task', '/task/add', 'primary', '', 'task-index', 'link', '', ''),
55+
(NULL, 'Export Tasks', 'fas fa-file-excel', 'Export Tasks', '/task/export', 'primary', '', 'task-index', 'link', '', ''),
56+
(NULL, 'Find Tasks', 'fas fa-searh', 'Find Tasks', '/task/search', 'primary', '', 'task-index', 'link', '', ''),
57+
(NULL, 'Export Tasks', 'fas fa-file-excel', 'Export Tasks', '#', 'primary initExcelDump', '', 'task-search', 'link', '', ''),
58+
(NULL, 'New Search', 'fas fa-searh', 'New Search', '/task/search', 'primary', '', 'task-search', 'link', '', '');
5359

5460
--
5561
-- Fields
5662
--
57-
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
63+
INSERT INTO `core_form_field` (`Field_ID`, `type`, `label`, `fieldkey`, `tab`, `form`, `class`, `url_view`, `url_list`, `show_widget_left`, `allow_clear`, `readonly`, `tbl_cached_name`, `tbl_class`, `tbl_permission`) VALUES
5864
(NULL, 'text', 'Name', 'label', 'task-base', 'task-single', 'col-md-3', '/task/view/##ID##', '', 0, 1, 0, '', '', '');
5965

6066
--
@@ -64,4 +70,12 @@ INSERT INTO `core_widget` (`Widget_ID`, `widget_name`, `label`, `permission`) VA
6470
(NULL, 'task_dailystats', 'Task - Daily Stats', 'index-Task\\Controller\\TaskController'),
6571
(NULL, 'task_taginfo', 'Task - Tag Info', 'index-Task\\Controller\\TaskController');
6672

73+
--
74+
-- User XP Activity
75+
--
76+
INSERT INTO `user_xp_activity` (`Activity_ID`, `xp_key`, `label`, `xp_base`) VALUES
77+
(NULL, 'task-add', 'Add New Task', '50'),
78+
(NULL, 'task-edit', 'Edit Task', '5'),
79+
(NULL, 'task-export', 'Edit Task', '5');
80+
6781
COMMIT;

src/Controller/ApiController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Main Controller for Task Api
66
*
77
* @category Controller
8-
* @package Application
8+
* @package Task
99
* @author Verein onePlace
1010
* @copyright (C) 2020 Verein onePlace <admin@1plc.ch>
1111
* @license https://opensource.org/licenses/BSD-3-Clause
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* ExportController.php - Task Export Controller
4+
*
5+
* Main Controller for Task Export
6+
*
7+
* @category Controller
8+
* @package Task
9+
* @author Verein onePlace
10+
* @copyright (C) 2020 Verein onePlace <admin@1plc.ch>
11+
* @license https://opensource.org/licenses/BSD-3-Clause
12+
* @version 1.0.0
13+
* @since 1.0.1
14+
*/
15+
16+
namespace OnePlace\Task\Controller;
17+
18+
use Application\Controller\CoreController;
19+
use Application\Controller\CoreExportController;
20+
use OnePlace\Task\Model\TaskTable;
21+
use Laminas\Db\Sql\Where;
22+
use Laminas\Db\Adapter\AdapterInterface;
23+
use Laminas\View\Model\ViewModel;
24+
25+
26+
class ExportController extends CoreExportController
27+
{
28+
/**
29+
* ApiController constructor.
30+
*
31+
* @param AdapterInterface $oDbAdapter
32+
* @param TaskTable $oTableGateway
33+
* @since 1.0.0
34+
*/
35+
public function __construct(AdapterInterface $oDbAdapter,TaskTable $oTableGateway,$oServiceManager) {
36+
parent::__construct($oDbAdapter,$oTableGateway,$oServiceManager);
37+
}
38+
39+
40+
/**
41+
* Dump Tasks to excel file
42+
*
43+
* @return ViewModel
44+
* @since 1.0.1
45+
*/
46+
public function dumpAction() {
47+
$this->layout('layout/json');
48+
49+
# Use Default export function
50+
$aViewData = $this->exportData('Tasks','task');
51+
52+
# return data to view (popup)
53+
return new ViewModel($aViewData);
54+
}
55+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/**
3+
* TaskController.php - Main Controller
4+
*
5+
* Main Controller Task Module
6+
*
7+
* @category Controller
8+
* @package Task
9+
* @author Verein onePlace
10+
* @copyright (C) 2020 Verein onePlace <admin@1plc.ch>
11+
* @license https://opensource.org/licenses/BSD-3-Clause
12+
* @version 1.0.0
13+
* @since 1.0.0
14+
*/
15+
16+
declare(strict_types=1);
17+
18+
namespace OnePlace\Task\Controller;
19+
20+
use Application\Controller\CoreEntityController;
21+
use Application\Model\CoreEntityModel;
22+
use OnePlace\Task\Model\TaskTable;
23+
use Laminas\View\Model\ViewModel;
24+
use Laminas\Db\Adapter\AdapterInterface;
25+
26+
class PluginController extends CoreEntityController {
27+
/**
28+
* Task Table Object
29+
*
30+
* @since 1.0.0
31+
*/
32+
protected $oTableGateway;
33+
34+
/**
35+
* TaskController constructor.
36+
*
37+
* @param AdapterInterface $oDbAdapter
38+
* @param TaskTable $oTableGateway
39+
* @since 1.0.0
40+
*/
41+
public function __construct(AdapterInterface $oDbAdapter,TaskTable $oTableGateway,$oServiceManager) {
42+
$this->oTableGateway = $oTableGateway;
43+
$this->sSingleForm = 'task-single';
44+
parent::__construct($oDbAdapter,$oTableGateway,$oServiceManager);
45+
46+
if($oTableGateway) {
47+
# Attach TableGateway to Entity Models
48+
if(!isset(CoreEntityModel::$aEntityTables[$this->sSingleForm])) {
49+
CoreEntityModel::$aEntityTables[$this->sSingleForm] = $oTableGateway;
50+
}
51+
}
52+
}
53+
54+
public function testFunction() {
55+
/**
56+
* Execute your hook code here
57+
*
58+
* optional: return an array to attach data to View
59+
* otherwise return true
60+
*/
61+
return ['testData'=>'here i am'];
62+
}
63+
64+
public function indexAction() {
65+
$this->layout('layout/json');
66+
67+
echo 'index';
68+
69+
return false;
70+
}
71+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* SearchController.php - Task Search Controller
4+
*
5+
* Main Controller for Task Search
6+
*
7+
* @category Controller
8+
* @package Task
9+
* @author Verein onePlace
10+
* @copyright (C) 2020 Verein onePlace <admin@1plc.ch>
11+
* @license https://opensource.org/licenses/BSD-3-Clause
12+
* @version 1.0.0
13+
* @since 1.0.1
14+
*/
15+
16+
namespace OnePlace\Task\Controller;
17+
18+
use Application\Controller\CoreSearchController;
19+
use OnePlace\Task\Model\TaskTable;
20+
use Laminas\Db\Sql\Where;
21+
use Laminas\View\Model\ViewModel;
22+
use Laminas\Db\Adapter\AdapterInterface;
23+
use PhpOffice\PhpSpreadsheet\Spreadsheet;
24+
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
25+
use PhpOffice\PhpSpreadsheet\IOFactory;
26+
use PhpOffice\PhpSpreadsheet\Shared\Date;
27+
use PhpOffice\PhpSpreadsheet\Cell\Cell;
28+
use PhpOffice\PhpSpreadsheet\RichText\RichText;
29+
use PhpOffice\PhpSpreadsheet\Style\Alignment;
30+
use PhpOffice\PhpSpreadsheet\Style\Border;
31+
use PhpOffice\PhpSpreadsheet\Style\Color;
32+
use PhpOffice\PhpSpreadsheet\Style\Fill;
33+
use PhpOffice\PhpSpreadsheet\Style\Font;
34+
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
35+
use PhpOffice\PhpSpreadsheet\Style\Protection;
36+
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
37+
use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup;
38+
39+
40+
class SearchController extends CoreSearchController
41+
{
42+
/**
43+
* ApiController constructor.
44+
*
45+
* @param AdapterInterface $oDbAdapter
46+
* @param TaskTable $oTableGateway
47+
* @since 1.0.0
48+
*/
49+
public function __construct(AdapterInterface $oDbAdapter,TaskTable $oTableGateway,$oServiceManager) {
50+
parent::__construct($oDbAdapter,$oTableGateway,$oServiceManager);
51+
}
52+
53+
/**
54+
* Dump Task data to desired format
55+
*
56+
* @return bool
57+
* @since 1.0.1
58+
*/
59+
public function indexAction() {
60+
/**
61+
* You can just use the default function and customize it via hooks
62+
* or replace the entire function if you need more customization
63+
*
64+
* Hooks available:
65+
*
66+
* task-search-before (before show search form)
67+
* task-search-before-execute (before query)
68+
* task-search-after-execute (after query - before show results)
69+
*/
70+
return $this->generateSearchView('task');
71+
}
72+
}

0 commit comments

Comments
 (0)