From b355009f53ec8f5ff74793af7501d93a654b9639 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 31 Jul 2021 17:20:49 +0200 Subject: [PATCH] bug fixes and template adjustments --- Admin/Install/Navigation.php | 10 +- Admin/Install/db.json | 237 ++++++++++++++++ Admin/Routes/Web/Backend.php | 32 ++- Controller/ApiController.php | 297 +++++++++++++++++++++ Controller/BackendController.php | 60 ++++- Models/Answer.php | 114 -------- Models/NullSurveyTemplate.php | 39 +++ Models/NullSurveyTemplateElement.php | 39 +++ Models/NullSurveyTemplateElmentL11n.php | 39 +++ Models/NullSurveyTemplateL11n.php | 39 +++ Models/NullSurveyTemplateLabelL11n.php | 39 +++ Models/PermissionState.php | 8 +- Models/Question.php | 114 -------- Models/Section.php | 114 -------- Models/Survey.php | 190 ------------- Models/SurveyAnswer.php | 35 +++ Models/SurveyElementType.php | 44 +++ Models/SurveyStatus.php | 30 +++ Models/SurveyTemplate.php | 205 ++++++++++++++ Models/SurveyTemplateElement.php | 161 +++++++++++ Models/SurveyTemplateElementL11n.php | 182 +++++++++++++ Models/SurveyTemplateElementL11nMapper.php | 59 ++++ Models/SurveyTemplateElementMapper.php | 95 +++++++ Models/SurveyTemplateL11n.php | 181 +++++++++++++ Models/SurveyTemplateL11nMapper.php | 59 ++++ Models/SurveyTemplateLabelL11n.php | 168 ++++++++++++ Models/SurveyTemplateLabelL11nMapper.php | 58 ++++ Models/SurveyTemplateMapper.php | 133 +++++++++ Theme/Backend/Lang/api.en.lang.php | 16 -- Theme/Backend/styles.css | 32 +++ Theme/Backend/styles.scss | 60 +++++ Theme/Backend/surveys-create.tpl.php | 237 +++++++++++----- Theme/Backend/surveys-list.tpl.php | 167 ++++++++++-- Theme/Backend/surveys-profile.tpl.php | 15 -- info.json | 1 + 35 files changed, 2653 insertions(+), 656 deletions(-) create mode 100644 Admin/Install/db.json create mode 100644 Controller/ApiController.php delete mode 100644 Models/Answer.php create mode 100644 Models/NullSurveyTemplate.php create mode 100644 Models/NullSurveyTemplateElement.php create mode 100644 Models/NullSurveyTemplateElmentL11n.php create mode 100644 Models/NullSurveyTemplateL11n.php create mode 100644 Models/NullSurveyTemplateLabelL11n.php delete mode 100644 Models/Question.php delete mode 100644 Models/Section.php delete mode 100644 Models/Survey.php create mode 100644 Models/SurveyAnswer.php create mode 100644 Models/SurveyElementType.php create mode 100644 Models/SurveyStatus.php create mode 100644 Models/SurveyTemplate.php create mode 100644 Models/SurveyTemplateElement.php create mode 100644 Models/SurveyTemplateElementL11n.php create mode 100644 Models/SurveyTemplateElementL11nMapper.php create mode 100644 Models/SurveyTemplateElementMapper.php create mode 100644 Models/SurveyTemplateL11n.php create mode 100644 Models/SurveyTemplateL11nMapper.php create mode 100644 Models/SurveyTemplateLabelL11n.php create mode 100644 Models/SurveyTemplateLabelL11nMapper.php create mode 100644 Models/SurveyTemplateMapper.php delete mode 100644 Theme/Backend/Lang/api.en.lang.php create mode 100644 Theme/Backend/styles.css create mode 100644 Theme/Backend/styles.scss delete mode 100644 Theme/Backend/surveys-profile.tpl.php diff --git a/Admin/Install/Navigation.php b/Admin/Install/Navigation.php index 657bec4..ec2a0b7 100644 --- a/Admin/Install/Navigation.php +++ b/Admin/Install/Navigation.php @@ -14,7 +14,7 @@ declare(strict_types=1); namespace Modules\Surveys\Admin\Install; -use phpOMS\DataStorage\Database\DatabasePool; +use phpOMS\Application\ApplicationAbstract; /** * Navigation class. @@ -29,15 +29,15 @@ class Navigation /** * Install navigation providing * - * @param string $path Module path - * @param DatabasePool $dbPool Database pool for database interaction + * @param string $path Module path + * @param ApplicationAbstract $app Application * * @return void * * @since 1.0.0 */ - public static function install(string $path, DatabasePool $dbPool) : void + public static function install(string $path, ApplicationAbstract $app) : void { - \Modules\Navigation\Admin\Installer::installExternal($dbPool, ['path' => __DIR__ . '/Navigation.install.json']); + \Modules\Navigation\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Navigation.install.json']); } } diff --git a/Admin/Install/db.json b/Admin/Install/db.json new file mode 100644 index 0000000..dd7e17b --- /dev/null +++ b/Admin/Install/db.json @@ -0,0 +1,237 @@ +{ + "survey_template": { + "name": "survey_template", + "fields": { + "survey_template_id": { + "name": "survey_template_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "survey_template_virtual": { + "name": "survey_template_virtual", + "type": "VARCHAR(255)", + "null": false + }, + "survey_template_status": { + "name": "survey_template_status", + "type": "TINYINT", + "null": false + }, + "survey_template_public_result": { + "name": "survey_template_public_result", + "type": "TINYINT", + "null": false + }, + "survey_template_start": { + "name": "survey_template_start", + "type": "DATETIME", + "null": true + }, + "survey_template_end": { + "name": "survey_template_end", + "type": "DATETIME", + "null": true + }, + "survey_template_created_by": { + "name": "survey_template_created_by", + "type": "INT", + "null": false, + "foreignTable": "account", + "foreignKey": "account_id" + }, + "survey_template_created_at": { + "name": "survey_template_created_at", + "type": "DATETIME", + "null": false + } + } + }, + "survey_template_l11n": { + "name": "survey_template_l11n", + "fields": { + "survey_template_l11n_id": { + "name": "survey_template_l11n_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "survey_template_l11n_title": { + "name": "survey_template_l11n_title", + "type": "VARCHAR(255)", + "null": false + }, + "survey_template_l11n_description": { + "name": "survey_template_l11n_description", + "type": "TEXT", + "null": false + }, + "survey_template_l11n_description_plain": { + "name": "survey_template_l11n_description_plain", + "type": "TEXT", + "null": false + }, + "survey_template_l11n_template": { + "name": "survey_template_l11n_template", + "type": "INT", + "null": false, + "foreignTable": "survey_template", + "foreignKey": "survey_template_id" + }, + "survey_template_l11n_language": { + "name": "survey_template_l11n_language", + "type": "VARCHAR(2)", + "default": null, + "null": true, + "foreignTable": "language", + "foreignKey": "language_639_1" + } + } + }, + "survey_template_tag": { + "name": "survey_template_tag", + "fields": { + "survey_template_tag_id": { + "name": "survey_template_tag_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "survey_template_tag_dst": { + "name": "survey_template_tag_dst", + "type": "INT", + "null": false, + "foreignTable": "survey_template", + "foreignKey": "survey_template_id" + }, + "survey_template_tag_src": { + "name": "survey_template_tag_src", + "type": "INT", + "null": false, + "foreignTable": "tag", + "foreignKey": "tag_id" + } + } + }, + "survey_template_element": { + "name": "survey_template_element", + "fields": { + "survey_template_element_id": { + "name": "survey_template_element_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "survey_template_element_type": { + "name": "survey_template_element_type", + "type": "TINYINT", + "null": false + }, + "survey_template_element_optional": { + "name": "survey_template_element_optional", + "type": "TINYINT(1)", + "null": false + }, + "survey_template_element_order": { + "name": "survey_template_element_order", + "type": "INT", + "null": false + }, + "survey_template_element_values": { + "name": "survey_template_element_values", + "type": "TEXT", + "null": false + }, + "survey_template_element_template": { + "name": "survey_template_element_template", + "type": "INT", + "null": false, + "foreignTable": "survey_template", + "foreignKey": "survey_template_id" + } + } + }, + "survey_template_element_l11n": { + "name": "survey_template_element_l11n", + "fields": { + "survey_template_element_l11n_id": { + "name": "survey_template_element_l11n_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "survey_template_element_l11n_text": { + "name": "survey_template_element_l11n_text", + "type": "VARCHAR(255)", + "null": false + }, + "survey_template_element_l11n_description": { + "name": "survey_template_element_l11n_description", + "type": "TEXT", + "null": false + }, + "survey_template_element_l11n_description_plain": { + "name": "survey_template_element_l11n_description_plain", + "type": "TEXT", + "null": false + }, + "survey_template_element_l11n_element": { + "name": "survey_template_element_l11n_element", + "type": "INT", + "null": false, + "foreignTable": "survey_template_element", + "foreignKey": "survey_template_element_id" + }, + "survey_template_element_l11n_language": { + "name": "survey_template_element_l11n_language", + "type": "VARCHAR(2)", + "default": null, + "null": true, + "foreignTable": "language", + "foreignKey": "language_639_1" + } + } + }, + "survey_template_element_label_l11n": { + "name": "survey_template_element_label_l11n", + "fields": { + "survey_template_element_label_l11n_id": { + "name": "survey_template_element_label_l11n_id", + "type": "INT", + "null": false, + "primary": true, + "autoincrement": true + }, + "survey_template_element_label_l11n_title": { + "name": "survey_template_element_label_l11n_title", + "type": "VARCHAR(255)", + "null": false + }, + "survey_template_element_label_l11n_order": { + "name": "survey_template_element_label_l11n_order", + "type": "INT", + "null": false + }, + "survey_template_element_label_l11n_element": { + "name": "survey_template_element_label_l11n_element", + "type": "INT", + "null": false, + "foreignTable": "survey_template_element", + "foreignKey": "survey_template_element_id" + }, + "survey_template_element_label_l11n_language": { + "name": "survey_template_element_label_l11n_language", + "type": "VARCHAR(2)", + "default": null, + "null": true, + "foreignTable": "language", + "foreignKey": "language_639_1" + } + } + } +} \ No newline at end of file diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php index 1e8624f..40acc1d 100644 --- a/Admin/Routes/Web/Backend.php +++ b/Admin/Routes/Web/Backend.php @@ -6,6 +6,17 @@ use phpOMS\Account\PermissionType; use phpOMS\Router\RouteVerb; return [ + '^.*/survey.*$' => [ + [ + 'dest' => '\Modules\Surveys\Controller\BackendController:setUpBackend', + 'verb' => RouteVerb::GET, + 'permission' => [ + 'module' => BackendController::MODULE_NAME, + 'type' => PermissionType::READ, + 'state' => PermissionState::SURVEY_ANSWER, + ], + ], + ], '^.*/survey/list.*$' => [ [ 'dest' => '\Modules\Surveys\Controller\BackendController:viewSurveysList', @@ -13,7 +24,7 @@ return [ 'permission' => [ 'module' => BackendController::MODULE_NAME, 'type' => PermissionType::READ, - 'state' => PermissionState::SURVEY, + 'state' => PermissionState::SURVEY_TEMPLATE, ], ], ], @@ -24,18 +35,29 @@ return [ 'permission' => [ 'module' => BackendController::MODULE_NAME, 'type' => PermissionType::CREATE, - 'state' => PermissionState::SURVEY, + 'state' => PermissionState::SURVEY_TEMPLATE, ], ], ], - '^.*/survey/profile.*$' => [ + '^.*/survey/edit.*$' => [ [ - 'dest' => '\Modules\Surveys\Controller\BackendController:viewSurveysProfile', + 'dest' => '\Modules\Surveys\Controller\BackendController:viewSurveysEdit', 'verb' => RouteVerb::GET, 'permission' => [ 'module' => BackendController::MODULE_NAME, 'type' => PermissionType::READ, - 'state' => PermissionState::SURVEY, + 'state' => PermissionState::SURVEY_TEMPLATE, + ], + ], + ], + '^.*/survey(\?.*|$)$' => [ + [ + 'dest' => '\Modules\Surveys\Controller\BackendController:viewSurveysSurvey', + 'verb' => RouteVerb::GET, + 'permission' => [ + 'module' => BackendController::MODULE_NAME, + 'type' => PermissionType::READ, + 'state' => PermissionState::SURVEY_ANSWER, ], ], ], diff --git a/Controller/ApiController.php b/Controller/ApiController.php new file mode 100644 index 0000000..f3f0421 --- /dev/null +++ b/Controller/ApiController.php @@ -0,0 +1,297 @@ + Returns the validation array of the request + * + * @since 1.0.0 + */ + private function validateSurveyTemplateCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['title'] = empty($request->getData('title'))) + ) { + return $val; + } + + return []; + } + + /** + * Api method to create a survey + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiSurveyTemplateCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void + { + if (!empty($val = $this->validateSurveyTemplateCreate($request))) { + $response->set($request->uri->__toString(), new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + + return; + } + + $survey = $this->createSurveyTemplateFromRequest($request); + $this->createModel($request->header->account, $survey, SurveyTemplateMapper::class, 'survey', $request->getOrigin()); + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'SurveyTemplate', 'SurveyTemplate successfully created.', $survey); + } + + /** + * Method to create survey from request. + * + * @param RequestAbstract $request Request + * + * @return SurveyTemplate Returns the created survey from the request + * + * @since 1.0.0 + */ + public function createSurveyTemplateFromRequest(RequestAbstract $request) : SurveyTemplate + { + $template = new SurveyTemplate(); + $template->start = empty($request->getData('start')) ? null : new \DateTime($request->getData('start')); + $template->end = empty($request->getData('end')) ? null : new \DateTime($request->getData('end')); + $template->status = $request->getData('status') ?? SurveyStatus::ACTIVE; + $template->createdBy = new NullAccount($request->header->account); + + $l11n = new SurveyTemplateL11n( + $request->getData('title') ?? '', + Markdown::parse((string) ($request->getData('description') ?? '')), + $request->getData('description') ?? '', + $request->getData('language') ?? ISO639x1Enum::_EN + ); + + $template->setL11n($l11n); + + if (!empty($tags = $request->getDataJson('tags'))) { + foreach ($tags as $tag) { + if (!isset($tag['id'])) { + $request->setData('title', $tag['title'], true); + $request->setData('color', $tag['color'], true); + $request->setData('icon', $tag['icon'] ?? null, true); + $request->setData('language', $tag['language'], true); + + $internalResponse = new HttpResponse(); + $this->app->moduleManager->get('Tag')->apiTagCreate($request, $internalResponse, null); + $template->addTag($internalResponse->get($request->uri->__toString())['response']); + } else { + $template->addTag(new NullTag((int) $tag['id'])); + } + } + } + + return $template; + } + + /** + * Validate task create request + * + * @param RequestAbstract $request Request + * + * @return array Returns the validation array of the request + * + * @since 1.0.0 + */ + private function validateSurveyTemplateElementCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['survey'] = empty((int) ($request->getData('survey')))) + || ($val['type'] = !SurveyElementType::isValidValue((int) ($request->getData('type') ?? -1))) + || ($val['labels_values'] = (($lCount = \count($request->getDataJson('labels'))) > 0 + && \count($request->getDataJson('values')) !== $lCount) + ) + ) { + return $val; + } + + return []; + } + + /** + * Api method to create a element + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiSurveyTemplateElementCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void + { + if (!empty($val = $this->validateSurveyTemplateElementCreate($request))) { + $response->set($request->uri->__toString(), new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + + return; + } + + $element = $this->createSurveyTemplateElementFromRequest($request); + $this->createModel($request->header->account, $element, SurveyTemplateElementMapper::class, 'element', $request->getOrigin()); + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'SurveyTemplateElement', 'SurveyTemplateElement successfully created.', $element); + } + + /** + * Method to create element from request. + * + * @param RequestAbstract $request Request + * + * @return SurveyTemplateElement Returns the created element from the request + * + * @since 1.0.0 + */ + public function createSurveyTemplateElementFromRequest(RequestAbstract $request) : SurveyTemplateElement + { + $element = new SurveyTemplateElement(); + $element->type = (int) $request->getData('type'); + $element->isOptional = (bool) ($request->getData('optional') ?? false); + $element->order = (int) ($request->getData('order') ?? 0); + $element->template = (int) ($request->getData('survey') ?? 0); + + $l11n = new SurveyTemplateElementL11n( + $request->getData('text') ?? '', + Markdown::parse((string) ($request->getData('description') ?? '')), + $request->getData('description') ?? '', + $request->getData('language') ?? ISO639x1Enum::_EN + ); + + $element->setL11n($l11n); + + $labels = $request->getDataJson('labels'); + foreach ($labels as $text) { + $label = new SurveyTemplateLabelL11n( + $text, + $request->getData('language') ?? ISO639x1Enum::_EN + ); + + $element->addLabel($label); + } + + $element->values = $request->getDataJson('values'); + + return $element; + } + + /** + * Validate survey create request + * + * @param RequestAbstract $request Request + * + * @return array Returns the validation array of the request + * + * @since 1.0.0 + */ + private function validateSurveyAnswerCreate(RequestAbstract $request) : array + { + $val = []; + if (($val['survey'] = empty($request->getData('survey'))) + ) { + return $val; + } + + return []; + } + + /** + * Api method to create a survey + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @api + * + * @since 1.0.0 + */ + public function apiSurveyAnswerCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : void + { + if (!empty($val = $this->validateSurveyAnswerCreate($request))) { + $response->set($request->uri->__toString(), new FormValidation($val)); + $response->header->status = RequestStatusCode::R_400; + + return; + } + + $survey = $this->createSurveyAnswerFromRequest($request); + //$this->createModel($request->header->account, $survey, SurveyAnswerMapper::class, 'survey', $request->getOrigin()); + $this->fillJsonResponse($request, $response, NotificationLevel::OK, 'SurveyAnswer', 'SurveyAnswer successfully created.', $survey); + } + + /** + * Method to create survey from request. + * + * @param RequestAbstract $request Request + * + * @return SurveyAnswer Returns the created survey from the request + * + * @since 1.0.0 + */ + public function createSurveyAnswerFromRequest(RequestAbstract $request) : SurveyAnswer + { + $answer = new SurveyAnswer(); + + $values = $request->getLike('e_\d'); + + return $answer; + } +} diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 29006a0..90b9407 100644 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -18,6 +18,9 @@ use phpOMS\Contract\RenderableInterface; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; use phpOMS\Views\View; +use Modules\Surveys\Models\SurveyTemplateMapper; +use Modules\Media\Models\CollectionMapper; +use phpOMS\Asset\AssetType; /** * Surveys controller class. @@ -29,6 +32,24 @@ use phpOMS\Views\View; */ final class BackendController extends Controller { + /** + * Routing end-point for application behaviour. + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return void + * + * @since 1.0.0 + * @codeCoverageIgnore + */ + public function setUpBackend(RequestAbstract $request, ResponseAbstract $response, $data = null) : void + { + $head = $response->get('Content')->getData('head'); + $head->addAsset(AssetType::CSS, '/Modules/Surveys/Theme/Backend/styles.css'); + } + /** * Routing end-point for application behaviour. * @@ -47,6 +68,17 @@ final class BackendController extends Controller $view->setTemplate('/Modules/Surveys/Theme/Backend/surveys-list'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000801001, $request, $response)); + $path = \str_replace('+', ' ', (string) ($request->getData('path') ?? '/')); + $surveys = SurveyTemplateMapper::with('language', $response->getLanguage())::getByVirtualPath($path); + + list($collection, $parent) = CollectionMapper::getCollectionsByPath($path); + + $view->addData('parent', $parent); + $view->addData('collections', $collection); + $view->addData('path', $path); + $view->addData('surveys', $surveys); + $view->addData('account', $this->app->accountManager->get($request->header->account)); + return $view; } @@ -83,10 +115,34 @@ final class BackendController extends Controller * @since 1.0.0 * @codeCoverageIgnore */ - public function viewSurveysProfile(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + public function viewSurveysEdit(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface { $view = new View($this->app->l11nManager, $request, $response); - $view->setTemplate('/Modules/Surveys/Theme/Backend/surveys-profile'); + $view->setTemplate('/Modules/Surveys/Theme/Backend/surveys-create'); + $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000801001, $request, $response)); + + $survey = SurveyTemplateMapper::get($request->getData('id')); + $view->addData('survey', $survey); + + return $view; + } + + /** + * Routing end-point for application behaviour. + * + * @param RequestAbstract $request Request + * @param ResponseAbstract $response Response + * @param mixed $data Generic data + * + * @return RenderableInterface + * + * @since 1.0.0 + * @codeCoverageIgnore + */ + public function viewSurveysSurvey(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface + { + $view = new View($this->app->l11nManager, $request, $response); + $view->setTemplate('/Modules/Surveys/Theme/Backend/surveys-survey'); $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000801001, $request, $response)); return $view; diff --git a/Models/Answer.php b/Models/Answer.php deleted file mode 100644 index 8418ae1..0000000 --- a/Models/Answer.php +++ /dev/null @@ -1,114 +0,0 @@ -id; - } - - /** - * Get answer name/title. - * - * @return string - * - * @since 1.0.0 - */ - public function getName() : string - { - return $this->name; - } - - /** - * Get name/title. - * - * @param string $name Name/title - * - * @return void - * - * @since 1.0.0 - */ - public function setName(string $name) : void - { - $this->name = $name; - } - - /** - * Get description. - * - * @return string - * - * @since 1.0.0 - */ - public function getDescription() : string - { - return $this->description; - } - - /** - * Set description. - * - * @param string $desc Description - * - * @return void - * - * @since 1.0.0 - */ - public function setDescription(string $desc) : void - { - $this->description = $desc; - } -} diff --git a/Models/NullSurveyTemplate.php b/Models/NullSurveyTemplate.php new file mode 100644 index 0000000..57cba42 --- /dev/null +++ b/Models/NullSurveyTemplate.php @@ -0,0 +1,39 @@ +id = $id; + parent::__construct(); + } +} diff --git a/Models/NullSurveyTemplateElement.php b/Models/NullSurveyTemplateElement.php new file mode 100644 index 0000000..e3dd216 --- /dev/null +++ b/Models/NullSurveyTemplateElement.php @@ -0,0 +1,39 @@ +id = $id; + parent::__construct(); + } +} diff --git a/Models/NullSurveyTemplateElmentL11n.php b/Models/NullSurveyTemplateElmentL11n.php new file mode 100644 index 0000000..a622ff3 --- /dev/null +++ b/Models/NullSurveyTemplateElmentL11n.php @@ -0,0 +1,39 @@ +id = $id; + parent::__construct(); + } +} diff --git a/Models/NullSurveyTemplateL11n.php b/Models/NullSurveyTemplateL11n.php new file mode 100644 index 0000000..f615fa7 --- /dev/null +++ b/Models/NullSurveyTemplateL11n.php @@ -0,0 +1,39 @@ +id = $id; + parent::__construct(); + } +} diff --git a/Models/NullSurveyTemplateLabelL11n.php b/Models/NullSurveyTemplateLabelL11n.php new file mode 100644 index 0000000..a5def0b --- /dev/null +++ b/Models/NullSurveyTemplateLabelL11n.php @@ -0,0 +1,39 @@ +id = $id; + parent::__construct(); + } +} diff --git a/Models/PermissionState.php b/Models/PermissionState.php index 1456864..3ee6bac 100644 --- a/Models/PermissionState.php +++ b/Models/PermissionState.php @@ -26,5 +26,11 @@ use phpOMS\Stdlib\Base\Enum; */ abstract class PermissionState extends Enum { - public const SURVEY = 1; + public const SURVEY_TEMPLATE = 1; + + public const SURVEY_ANSWER = 2; + + public const SURVEY_PUBLIC_STATISTICS = 3; + + public const SURVEY_ADMIN_STATISTICS = 4; } diff --git a/Models/Question.php b/Models/Question.php deleted file mode 100644 index 1be7d60..0000000 --- a/Models/Question.php +++ /dev/null @@ -1,114 +0,0 @@ -id; - } - - /** - * Get name/title. - * - * @return string - * - * @since 1.0.0 - */ - public function getName() : string - { - return $this->name; - } - - /** - * Set name/title. - * - * @param string $name Name/title - * - * @return void - * - * @since 1.0.0 - */ - public function setName(string $name) : void - { - $this->name = $name; - } - - /** - * Get string. - * - * @return string - * - * @since 1.0.0 - */ - public function getDescription() : string - { - return $this->description; - } - - /** - * Set description. - * - * @param string $desc Description - * - * @return void - * - * @since 1.0.0 - */ - public function setDescription($desc) : void - { - $this->description = $desc; - } -} diff --git a/Models/Section.php b/Models/Section.php deleted file mode 100644 index 81bc383..0000000 --- a/Models/Section.php +++ /dev/null @@ -1,114 +0,0 @@ -id; - } - - /** - * Get name. - * - * @return string - * - * @since 1.0.0 - */ - public function getName() : string - { - return $this->name; - } - - /** - * Set name. - * - * @param string $name Name - * - * @return void - * - * @since 1.0.0 - */ - public function setName(string $name) : void - { - $this->name = $name; - } - - /** - * Get description. - * - * @return string - * - * @since 1.0.0 - */ - public function getDescription() : string - { - return $this->description; - } - - /** - * Set description. - * - * @param string $desc Description - * - * @return void - * - * @since 1.0.0 - */ - public function setDescription(string $desc) : void - { - $this->description = $desc; - } -} diff --git a/Models/Survey.php b/Models/Survey.php deleted file mode 100644 index 88d9f52..0000000 --- a/Models/Survey.php +++ /dev/null @@ -1,190 +0,0 @@ -created = new \DateTime('now'); - } - - /** - * Get id. - * - * @return int - * - * @since 1.0.0 - */ - public function getId() : int - { - return $this->id; - } - - /** - * Get name/title. - * - * @return string - * - * @since 1.0.0 - */ - public function getName() : string - { - return $this->name; - } - - /** - * Set name/title. - * - * @param string $name Name/title - * - * @return void - * - * @since 1.0.0 - */ - public function setName(string $name) : void - { - $this->name = $name; - } - - /** - * Get description. - * - * @return string - * - * @since 1.0.0 - */ - public function getDescription() : string - { - return $this->description; - } - - /** - * Set description. - * - * @param string $desc Description - * - * @return void - * - * @since 1.0.0 - */ - public function setDescription(string $desc) : void - { - $this->description = $desc; - } - - /** - * Get created. - * - * @return \DateTime - * - * @since 1.0.0 - */ - public function getCreated() : \DateTime - { - return $this->created; - } - - /** - * Set created. - * - * @return void - * - * @since 1.0.0 - */ - public function setCreated($created) : void - { - $this->created = $created; - } - - /** - * Get creator. - * - * @return mixed - * - * @since 1.0.0 - */ - public function getCreator() - { - return $this->creator; - } - - /** - * Set creator. - * - * @param mixed $creator Creator - * - * @return void - * - * @since 1.0.0 - */ - public function setCreator($creator) : void - { - $this->creator = $creator; - } -} diff --git a/Models/SurveyAnswer.php b/Models/SurveyAnswer.php new file mode 100644 index 0000000..1ed6228 --- /dev/null +++ b/Models/SurveyAnswer.php @@ -0,0 +1,35 @@ +createdAt = new \DateTimeImmutable('now'); + } + + /** + * Get id. + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + /** + * @return SurveyTemplateL11n + * + * @since 1.0.0 + */ + public function getL11n() : SurveyTemplateL11n + { + return $this->l11n; + } + + /** + * Set l11n + * + * @param SurveyTemplateL11n $l11n Template l11n + * @param string $lang Language + * + * @return void + * + * @since 1.0.0 + */ + public function setL11n(SurveyTemplateL11n $l11n, string $lang = ISO639x1Enum::_EN) : void + { + $this->l11n = $l11n; + } + + /** + * Get tags + * + * @return array + * + * @since 1.0.0 + */ + public function getTags() : array + { + return $this->tags; + } + + /** + * Add tag + * + * @param Tag $tag Tag + * + * @return void + * + * @since 1.0.0 + */ + public function addTag(Tag $tag) : void + { + $this->tags[] = $tag; + } + + /** + * Get elements + * + * @return array + * + * @since 1.0.0 + */ + public function getElements() : array + { + return $this->elements; + } +} diff --git a/Models/SurveyTemplateElement.php b/Models/SurveyTemplateElement.php new file mode 100644 index 0000000..2fdab93 --- /dev/null +++ b/Models/SurveyTemplateElement.php @@ -0,0 +1,161 @@ +id; + } + + /** + * @return SurveyTemplateElementL11n + * + * @since 1.0.0 + */ + public function getL11n() : SurveyTemplateElementL11n + { + return $this->l11n ?? new NullSurveyTemplateElementL11n(); + } + + /** + * Set l11n + * + * @param SurveyTemplateElementL11n $l11n Template l11n + * @param string $lang Language + * + * @return void + * + * @since 1.0.0 + */ + public function setL11n(SurveyTemplateElementL11n $l11n, string $lang = ISO639x1Enum::_EN) : void + { + $this->l11n = $l11n; + } + + /** + * @param SurveyTemplateLabelL11n $label Label + * + * @return void + * + * @since 1.0.0 + */ + public function addLabel(SurveyTemplateLabelL11n $label) : void + { + $this->labels[] = $label; + } + + /** + * @return array + * + * @since 1.0.0 + */ + public function getLabels() : array + { + return $this->labels; + } + + /** + * @return array + * + * @since 1.0.0 + */ + public function getValues() : array + { + return $this->values; + } +} diff --git a/Models/SurveyTemplateElementL11n.php b/Models/SurveyTemplateElementL11n.php new file mode 100644 index 0000000..57af212 --- /dev/null +++ b/Models/SurveyTemplateElementL11n.php @@ -0,0 +1,182 @@ +text = $text; + $this->description = $description; + $this->descriptionPlain = $descriptionPlain; + $this->language = $language; + } + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + /** + * Set element. + * + * @param int $element Surveys id + * + * @return void + * + * @since 1.0.0 + */ + public function setElement(int $element) : void + { + $this->element = $element; + } + + /** + * Get element + * + * @return int + * + * @since 1.0.0 + */ + public function getElement() : int + { + return $this->element; + } + + /** + * Get language + * + * @return string + * + * @since 1.0.0 + */ + public function getLanguage() : string + { + return $this->language; + } + + /** + * Set language + * + * @param string $language Language + * + * @return void + * + * @since 1.0.0 + */ + public function setLanguage(string $language) : void + { + $this->language = $language; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return [ + 'id' => $this->id, + 'text' => $this->text, + 'description' => $this->description, + 'descriptionPlain' => $this->descriptionPlain, + 'element' => $this->element, + 'language' => $this->language, + ]; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/SurveyTemplateElementL11nMapper.php b/Models/SurveyTemplateElementL11nMapper.php new file mode 100644 index 0000000..8394d5e --- /dev/null +++ b/Models/SurveyTemplateElementL11nMapper.php @@ -0,0 +1,59 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'survey_template_element_l11n_id' => ['name' => 'survey_template_element_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'survey_template_element_l11n_text' => ['name' => 'survey_template_element_l11n_text', 'type' => 'string', 'internal' => 'text', 'autocomplete' => true], + 'survey_template_element_l11n_description' => ['name' => 'survey_template_element_l11n_description', 'type' => 'string', 'internal' => 'description'], + 'survey_template_element_l11n_description_plain' => ['name' => 'survey_template_element_l11n_description_plain', 'type' => 'string', 'internal' => 'descriptionPlain'], + 'survey_template_element_l11n_element' => ['name' => 'survey_template_element_l11n_element', 'type' => 'int', 'internal' => 'element'], + 'survey_template_element_l11n_language' => ['name' => 'survey_template_element_l11n_language', 'type' => 'string', 'internal' => 'language'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'survey_template_element_l11n'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'survey_template_element_l11n_id'; +} diff --git a/Models/SurveyTemplateElementMapper.php b/Models/SurveyTemplateElementMapper.php new file mode 100644 index 0000000..c85e8f7 --- /dev/null +++ b/Models/SurveyTemplateElementMapper.php @@ -0,0 +1,95 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'survey_template_element_id' => ['name' => 'survey_template_element_id', 'type' => 'int', 'internal' => 'id'], + 'survey_template_element_type' => ['name' => 'survey_template_element_type', 'type' => 'int', 'internal' => 'type'], + 'survey_template_element_order' => ['name' => 'survey_template_element_order', 'type' => 'int', 'internal' => 'order'], + 'survey_template_element_optional' => ['name' => 'survey_template_element_optional', 'type' => 'bool', 'internal' => 'isOptional'], + 'survey_template_element_values' => ['name' => 'survey_template_element_values', 'type' => 'Json', 'internal' => 'values'], + 'survey_template_element_template' => ['name' => 'survey_template_element_template', 'type' => 'int', 'internal' => 'template'], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + protected static array $hasMany = [ + 'l11n' => [ + 'mapper' => SurveyTemplateElementL11nMapper::class, + 'table' => 'survey_template_element_l11n', + 'self' => 'survey_template_element_l11n_element', + 'conditional' => true, + 'external' => null, + ], + 'labels' => [ + 'mapper' => SurveyTemplateLabelL11nMapper::class, + 'table' => 'survey_template_element_label_l11n', + 'self' => 'survey_template_element_label_l11n_element', + 'conditional' => true, + 'external' => null, + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'survey_template_element'; + + /** + * Created at. + * + * @var string + * @since 1.0.0 + */ + protected static string $createdAt = 'survey_template_element_created_at'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'survey_template_element_id'; +} diff --git a/Models/SurveyTemplateL11n.php b/Models/SurveyTemplateL11n.php new file mode 100644 index 0000000..f31a10e --- /dev/null +++ b/Models/SurveyTemplateL11n.php @@ -0,0 +1,181 @@ +title = $title; + $this->description = $description; + $this->descriptionPlain = $descriptionPlain; + $this->language = $language; + } + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + /** + * Set template. + * + * @param int $template Surveys id + * + * @return void + * + * @since 1.0.0 + */ + public function setSurvey(int $template) : void + { + $this->template = $template; + } + + /** + * Get template + * + * @return int + * + * @since 1.0.0 + */ + public function getSurvey() : int + { + return $this->template; + } + + /** + * Get language + * + * @return string + * + * @since 1.0.0 + */ + public function getLanguage() : string + { + return $this->language; + } + + /** + * Set language + * + * @param string $language Language + * + * @return void + * + * @since 1.0.0 + */ + public function setLanguage(string $language) : void + { + $this->language = $language; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return [ + 'id' => $this->id, + 'title' => $this->title, + 'description' => $this->description, + 'template' => $this->template, + 'language' => $this->language, + ]; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/SurveyTemplateL11nMapper.php b/Models/SurveyTemplateL11nMapper.php new file mode 100644 index 0000000..7762170 --- /dev/null +++ b/Models/SurveyTemplateL11nMapper.php @@ -0,0 +1,59 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'survey_template_l11n_id' => ['name' => 'survey_template_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'survey_template_l11n_title' => ['name' => 'survey_template_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true], + 'survey_template_l11n_description' => ['name' => 'survey_template_l11n_description', 'type' => 'string', 'internal' => 'description'], + 'survey_template_l11n_description_plain' => ['name' => 'survey_template_l11n_description_plain', 'type' => 'string', 'internal' => 'descriptionPlain'], + 'survey_template_l11n_template' => ['name' => 'survey_template_l11n_template', 'type' => 'int', 'internal' => 'template'], + 'survey_template_l11n_language' => ['name' => 'survey_template_l11n_language', 'type' => 'string', 'internal' => 'language'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'survey_template_l11n'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'survey_template_l11n_id'; +} diff --git a/Models/SurveyTemplateLabelL11n.php b/Models/SurveyTemplateLabelL11n.php new file mode 100644 index 0000000..a7f0e88 --- /dev/null +++ b/Models/SurveyTemplateLabelL11n.php @@ -0,0 +1,168 @@ +title = $title; + $this->language = $language; + } + + /** + * Get id + * + * @return int + * + * @since 1.0.0 + */ + public function getId() : int + { + return $this->id; + } + + /** + * Set element. + * + * @param int $element Surveys id + * + * @return void + * + * @since 1.0.0 + */ + public function setElement(int $element) : void + { + $this->element = $element; + } + + /** + * Get element + * + * @return int + * + * @since 1.0.0 + */ + public function getElement() : int + { + return $this->element; + } + + /** + * Get language + * + * @return string + * + * @since 1.0.0 + */ + public function getLanguage() : string + { + return $this->language; + } + + /** + * Set language + * + * @param string $language Language + * + * @return void + * + * @since 1.0.0 + */ + public function setLanguage(string $language) : void + { + $this->language = $language; + } + + /** + * {@inheritdoc} + */ + public function toArray() : array + { + return [ + 'id' => $this->id, + 'title' => $this->title, + 'element' => $this->element, + 'language' => $this->language, + ]; + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/Models/SurveyTemplateLabelL11nMapper.php b/Models/SurveyTemplateLabelL11nMapper.php new file mode 100644 index 0000000..324c2b6 --- /dev/null +++ b/Models/SurveyTemplateLabelL11nMapper.php @@ -0,0 +1,58 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'survey_template_element_label_l11n_id' => ['name' => 'survey_template_element_label_l11n_id', 'type' => 'int', 'internal' => 'id'], + 'survey_template_element_label_l11n_title' => ['name' => 'survey_template_element_label_l11n_title', 'type' => 'string', 'internal' => 'title', 'autocomplete' => true], + 'survey_template_element_label_l11n_element' => ['name' => 'survey_template_element_label_l11n_element', 'type' => 'int', 'internal' => 'element'], + 'survey_template_element_label_l11n_order' => ['name' => 'survey_template_element_label_l11n_order', 'type' => 'int', 'internal' => 'order'], + 'survey_template_element_label_l11n_language' => ['name' => 'survey_template_element_label_l11n_language', 'type' => 'string', 'internal' => 'language'], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'survey_template_element_label_l11n'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'survey_template_element_label_l11n_id'; +} diff --git a/Models/SurveyTemplateMapper.php b/Models/SurveyTemplateMapper.php new file mode 100644 index 0000000..18a824f --- /dev/null +++ b/Models/SurveyTemplateMapper.php @@ -0,0 +1,133 @@ + + * @since 1.0.0 + */ + protected static array $columns = [ + 'survey_template_id' => ['name' => 'survey_template_id', 'type' => 'int', 'internal' => 'id'], + 'survey_template_status' => ['name' => 'survey_template_status', 'type' => 'int', 'internal' => 'status'], + 'survey_template_public_result' => ['name' => 'survey_template_public_result', 'type' => 'bool', 'internal' => 'hasPublicResult'], + 'survey_template_start' => ['name' => 'survey_template_start', 'type' => 'DateTime', 'internal' => 'start'], + 'survey_template_end' => ['name' => 'survey_template_end', 'type' => 'DateTime', 'internal' => 'end'], + 'survey_template_virtual' => ['name' => 'survey_template_virtual', 'type' => 'string', 'internal' => 'virtualPath'], + 'survey_template_created_by' => ['name' => 'survey_template_created_by', 'type' => 'int', 'internal' => 'createdBy'], + 'survey_template_created_at' => ['name' => 'survey_template_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt'], + ]; + + /** + * Has many relation. + * + * @var array + * @since 1.0.0 + */ + protected static array $hasMany = [ + 'elements' => [ + 'mapper' => SurveyTemplateElementMapper::class, + 'table' => 'survey_template_element', + 'self' => 'survey_template_element_template', + 'external' => null, + ], + 'l11n' => [ + 'mapper' => SurveyTemplateL11nMapper::class, + 'table' => 'survey_template_l11n', + 'self' => 'survey_template_l11n_template', + 'conditional' => true, + 'external' => null, + ], + 'tags' => [ + 'mapper' => TagMapper::class, + 'table' => 'survey_template_tag', + 'self' => 'survey_template_tag_dst', + 'external' => 'survey_template_tag_src', + ], + ]; + + /** + * Belongs to. + * + * @var array + * @since 1.0.0 + */ + protected static array $belongsTo = [ + 'createdBy' => [ + 'mapper' => AccountMapper::class, + 'external' => 'survey_template_created_by', + ], + ]; + + /** + * Primary table. + * + * @var string + * @since 1.0.0 + */ + protected static string $table = 'survey_template'; + + /** + * Created at. + * + * @var string + * @since 1.0.0 + */ + protected static string $createdAt = 'survey_template_created_at'; + + /** + * Primary field name. + * + * @var string + * @since 1.0.0 + */ + protected static string $primaryField = 'survey_template_id'; + + /** + * Get editor doc based on virtual path. + * + * @param string $virtualPath Virtual path + * + * @return array + * + * @since 1.0.0 + */ + public static function getByVirtualPath(string $virtualPath = '/') : array + { + $depth = 2; + $query = self::getQuery(depth: $depth); + $query->where(self::$table . '_d' . $depth . '.survey_template_virtual', '=', $virtualPath); + + return self::getAllByQuery($query, RelationType::ALL, $depth); + } +} diff --git a/Theme/Backend/Lang/api.en.lang.php b/Theme/Backend/Lang/api.en.lang.php deleted file mode 100644 index 1776cb6..0000000 --- a/Theme/Backend/Lang/api.en.lang.php +++ /dev/null @@ -1,16 +0,0 @@ -getData('survey'); + echo $this->getData('nav')->render(); ?> -
-
-
-

getHtml('Survey'); ?>

-
-
- -
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>> +
+
+
+
+
+
getHtml('Survey'); ?>
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
-
-
-

getHtml('Section'); ?>

-
-
- -
-
-
-
-
-
-
-
-
-
- -
-
-
-

getHtml('Question'); ?>

-
-
- -
-
-
+
+
+
-
-
- +
+
+ +
+
+
-
+ request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>> +
+
+
+
+
+
printHtml($survey->getL11n()->title); ?>
+
+ getL11n()->description)) : ?> +
getL11n()->description; ?>
+ + getElements(); + foreach ($elements as $element) { + if ($element->type === SurveyElementType::HEADLINE) { + echo '

' . $this->printHtml($element->getL11n()->text) . '

'; + + echo !empty($element->getL11n()->description) + ? '

' . $element->getL11n()->description . '

' + : ''; + } elseif ($element->type === SurveyElementType::CHECKBOX + || $element->type === SurveyElementType::RADIO + || $element->type === SurveyElementType::DROPDOWN + || $element->type === SurveyElementType::TEXTFIELD + || $element->type === SurveyElementType::TEXTAREA + || $element->type === SurveyElementType::NUMERIC + || $element->type === SurveyElementType::DATE + ) { + echo '
'; + + // Question/Text section + echo '
'; + echo '
' . $this->printHtml($element->getL11n()->text) . '
'; + echo !empty($element->getL11n()->description) + ? '
' . $element->getL11n()->description . '
' + : ''; + echo '
'; + + // Value section + echo '
'; + if ($element->type === SurveyElementType::CHECKBOX + || $element->type === SurveyElementType::RADIO + ) : + $elementLabels = $element->getLabels(); + if (($eCount = \count($elementLabels)) > 0) { + echo '
'; + } + + foreach ($elementLabels as $elementLabel) { + echo '' . $this->printHtml($elementLabel->title) . ''; + } + + if ($eCount > 0) { + echo '
'; + } + + $elementValues = $element->getValues(); + echo '
'; + foreach ($elementValues as $elementValue) : + if ($element->type === SurveyElementType::CHECKBOX) : ?> +
+ +
+ type === SurveyElementType::RADIO) : ?> +
+ +
+ '; // closing "values" + elseif ($element->type === SurveyElementType::DROPDOWN) : + $elementValues = $element->getValues(); + + echo ' + type === SurveyElementType::TEXTAREA) : ?> + + type === SurveyElementType::NUMERIC) : ?> + + type === SurveyElementType::DATE) : ?> + + '; // closing "values-section" + echo '
'; // closing "survey-value-element" + } + } ?> +
+
+ +
+ +
+
+
+
+
\ No newline at end of file diff --git a/Theme/Backend/surveys-list.tpl.php b/Theme/Backend/surveys-list.tpl.php index 32e667f..5a0547a 100644 --- a/Theme/Backend/surveys-list.tpl.php +++ b/Theme/Backend/surveys-list.tpl.php @@ -12,35 +12,170 @@ */ declare(strict_types=1); +use phpOMS\Uri\UriFactory; -$footerView = new \phpOMS\Views\PaginationView($this->l11nManager, $this->request, $this->response); -$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig'); -$footerView->setPages(20); -$footerView->setPage(1); +/** + * @var \phpOMS\Views\View $this + * @var \Modules\Surveys\Models\Survey[] $surveys + */ +$surveys = $this->getData('surveys') ?? []; + +/** @var \Modules\Admin\Models\Account $account */ +$account = $this->getData('account'); + +$accountDir = $account->getId() . ' ' . $account->login; + +/** @var \Modules\Media\Models\Collection[] */ +$collections = $this->getData('collections'); +$mediaPath = \urldecode($this->getData('path') ?? '/'); + +$previous = empty($surveys) ? '{/prefix}survey/list' : '{/prefix}survey/list?{?}&id=' . \reset($surveys)->getId() . '&ptype=p'; +$next = empty($surveys) ? '{/prefix}survey/list' : '{/prefix}survey/list?{?}&id=' . \end($surveys)->getId() . '&ptype=n'; echo $this->getData('nav')->render(); ?>
-
- - +
+ +
+ + + +
+
+
+
getHtml('Surveys'); ?>
+
getHtml('Surveys'); ?>
- - - - $value) : ++$count; ?> + + + + +
getHtml('Status') ?> - getHtml('Title') ?> - getHtml('Created') ?> - getHtml('Creator') ?> -
+ + + getHtml('Name'); ?> + + + + getHtml('Tag'); ?> + + + + getHtml('Creator'); ?> + + + + getHtml('Created'); ?> + + +
+ + .. + + + + + + + $value) : ++$count; + $url = UriFactory::build('{/prefix}survey/list?path=' . \rtrim($value->getVirtualPath(), '/') . '/' . $value->name); + ?> +
+ + printHtml($value->name); ?> + + printHtml($value->createdBy->name1); ?> + printHtml($value->createdAt->format('Y-m-d')); ?> + + $value) : ++$count; + $url = UriFactory::build('{/prefix}survey/edit?{?}&id=' . $value->getId()); ?> + ?> +
+ + getL11n()->title; ?> + + createdBy->name1; ?> + createdAt->format('Y-m-d'); ?> -
getHtml('Empty', '0', '0'); ?> +
getHtml('Empty', '0', '0'); ?>
+
\ No newline at end of file diff --git a/Theme/Backend/surveys-profile.tpl.php b/Theme/Backend/surveys-profile.tpl.php deleted file mode 100644 index 5bf6bab..0000000 --- a/Theme/Backend/surveys-profile.tpl.php +++ /dev/null @@ -1,15 +0,0 @@ -getData('nav')->render(); diff --git a/info.json b/info.json index 727a31a..4d3de25 100644 --- a/info.json +++ b/info.json @@ -18,6 +18,7 @@ "directory": "Surveys", "dependencies": { "Admin": "1.0.0", + "Tag": "1.0.0", "Tools": "1.0.0" }, "providing": {