unified all badges into one table

This commit is contained in:
Ulf Gebhardt 2019-08-29 12:18:10 +02:00
parent 882171b564
commit f64f773a8e
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
9 changed files with 29 additions and 120 deletions

View File

@ -17,6 +17,10 @@ class default_page implements \SYSTEM\PAGE\DefaultPage {
)));
}
const BADGE_TYPE_PERSON_ABILITIES = 1;
const BADGE_TYPE_PROJECT_FOCUS = 10;
const BADGE_TYPE_PROJECT_TYPE = 11;
private static function getPersons(){
$result = '';
@ -25,11 +29,11 @@ class default_page implements \SYSTEM\PAGE\DefaultPage {
$_content_details = '';
$persons = \SQL\SELECT_PERSONS::QQ();
$person_badges = \SQL\SELECT_PERSON_BADGES::QA(); // This part we filter phpside due to performance.
$person_projects= \SQL\SELECT_PERSON_PROJECTS::QA(); // This part we filter phpside due to performance.
$person_badges = \SQL\SELECT_BADGES::QA(array(self::BADGE_TYPE_PERSON_ABILITIES)); // This part we filter phpside due to performance.
$person_projects= \SQL\SELECT_PERSON_PROJECTS::QA(); // This part we filter phpside due to performance.
while($row = $persons->next()){
$badges = array_filter($person_badges, function($v)use($row){return $v['person'] == $row['id'];});
$badges = array_filter($person_badges, function($v)use($row){return $v['ref_id'] == $row['id'];});
$row['badges'] = '';
foreach($badges as $badge){
$row['badges'] .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/content_badge.tpl'))->SERVERPATH(),$badge);
@ -76,22 +80,20 @@ class default_page implements \SYSTEM\PAGE\DefaultPage {
$_content_details = '';
$projects = \SQL\SELECT_PROJECTS::QQ();
$project_focus = \SQL\SELECT_PROJECT_FOCUS::QA(); // This part we filter phpside due to performance.
$project_type = \SQL\SELECT_PROJECT_TYPE::QA(); // This part we filter phpside due to performance.
$project_persons= \SQL\SELECT_PROJECT_PERSONS::QA();// This part we filter phpside due to performance.
$project_focus = \SQL\SELECT_BADGES::QA(array(self::BADGE_TYPE_PROJECT_FOCUS)); // This part we filter phpside due to performance.
$project_type = \SQL\SELECT_BADGES::QA(array(self::BADGE_TYPE_PROJECT_TYPE)); // This part we filter phpside due to performance.
$project_persons= \SQL\SELECT_PROJECT_PERSONS::QA(); // This part we filter phpside due to performance.
while($row = $projects->next()){
$focus = array_filter($project_focus, function($v)use($row){return $v['project'] == $row['id'];});
$focus = array_filter($project_focus, function($v)use($row){return $v['ref_id'] == $row['id'];});
$row['focus'] = '';
foreach($focus as $f){
$f['badge'] = $f['focus'];
$row['focus'] .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/content_badge.tpl'))->SERVERPATH(),$f);
}
$type = array_filter($project_type, function($v)use($row){return $v['project'] == $row['id'];});
$type = array_filter($project_type, function($v)use($row){return $v['ref_id'] == $row['id'];});
$row['type'] = '';
foreach($type as $t){
$t['badge'] = $t['type'];
$row['type'] .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/content_badge.tpl'))->SERVERPATH(),$t);
}

View File

@ -14,7 +14,7 @@ namespace SQL;
/**
* QQ to get System Api Tree by group
*/
class SELECT_PERSON_BADGES extends \SYSTEM\DB\QQ {
class SELECT_BADGES extends \SYSTEM\DB\QP {
/**
* Get Classname of the QQ
*
@ -28,6 +28,6 @@ class SELECT_PERSON_BADGES extends \SYSTEM\DB\QQ {
* @return string Returns MYSQL Query String
*/
public static function mysql(){return
'SELECT * FROM `person_badges` WHERE `visible` = 1 ORDER BY `order`';
'SELECT * FROM `badges` WHERE `type` = ? AND `visible` = 1 ORDER BY `order`';
}
}

View File

@ -1,33 +0,0 @@
<?php
/**
* System - PHP Framework
*
* PHP Version 5.6
*
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/webcraftmedia/system
* @package SYSTEM\SQL
*/
namespace SQL;
/**
* QQ to get System Api Tree by group
*/
class SELECT_PROJECT_FOCUS extends \SYSTEM\DB\QQ {
/**
* Get Classname of the QQ
*
* @return string Returns classname
*/
public static function get_class(){return \get_class();}
/**
* Get QQs MYSQL Query String
*
* @return string Returns MYSQL Query String
*/
public static function mysql(){return
'SELECT * FROM `project_focus` WHERE `visible` = 1 ORDER BY `order`';
}
}

View File

@ -1,33 +0,0 @@
<?php
/**
* System - PHP Framework
*
* PHP Version 5.6
*
* @copyright 2016 Ulf Gebhardt (http://www.webcraft-media.de)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link https://github.com/webcraftmedia/system
* @package SYSTEM\SQL
*/
namespace SQL;
/**
* QQ to get System Api Tree by group
*/
class SELECT_PROJECT_TYPE extends \SYSTEM\DB\QQ {
/**
* Get Classname of the QQ
*
* @return string Returns classname
*/
public static function get_class(){return \get_class();}
/**
* Get QQs MYSQL Query String
*
* @return string Returns MYSQL Query String
*/
public static function mysql(){return
'SELECT * FROM `project_type` WHERE `visible` = 1 ORDER BY `order`';
}
}

View File

@ -6,10 +6,8 @@ class DATA_WECKER_MANUFAKTUR extends \SYSTEM\DB\QI {
return array( (new \PSQL('/mysql/system_page.sql'))->SERVERPATH(),
(new \PSQL('/mysql/system_text.sql'))->SERVERPATH(),
(new \PSQL('/mysql/persons.schema.sql'))->SERVERPATH(),
(new \PSQL('/mysql/person_badges.schema.sql'))->SERVERPATH(),
(new \PSQL('/mysql/badges.schema.sql'))->SERVERPATH(),
(new \PSQL('/mysql/projects.schema.sql'))->SERVERPATH(),
(new \PSQL('/mysql/projects_focus.schema.sql'))->SERVERPATH(),
(new \PSQL('/mysql/projects_type.schema.sql'))->SERVERPATH(),
(new \PSQL('/mysql/person_projects.schema.sql'))->SERVERPATH());
}
}

View File

@ -0,0 +1,14 @@
CREATE TABLE `badges` (
`type` INT(10) UNSIGNED NOT NULL,
`ref_id` INT(10) UNSIGNED NOT NULL,
`badge` VARCHAR(50) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`color` VARCHAR(50) NOT NULL DEFAULT 'badge-primary' COLLATE 'utf8mb4_unicode_ci',
`order` INT(10) UNSIGNED NOT NULL,
`visible` INT(10) UNSIGNED NULL DEFAULT 1,
PRIMARY KEY (`type`, `ref_id`, `badge`),
INDEX `type` (`type`),
INDEX `ref_id` (`ref_id`)
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;

View File

@ -1,13 +0,0 @@
CREATE TABLE `person_badges` (
`person` INT(10) UNSIGNED NOT NULL,
`badge` VARCHAR(20) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`color` VARCHAR(20) NOT NULL DEFAULT 'badge-primary' COLLATE 'utf8mb4_unicode_ci',
`order` INT(10) UNSIGNED NOT NULL,
`visible` INT(10) UNSIGNED NULL DEFAULT 1,
PRIMARY KEY (`person`, `badge`),
INDEX `person` (`person`),
CONSTRAINT `FK__persons` FOREIGN KEY (`person`) REFERENCES `persons` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;

View File

@ -1,13 +0,0 @@
CREATE TABLE `project_focus` (
`project` INT(10) UNSIGNED NOT NULL,
`focus` VARCHAR(20) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`color` VARCHAR(20) NOT NULL DEFAULT 'badge-primary' COLLATE 'utf8mb4_unicode_ci',
`order` INT(10) UNSIGNED NOT NULL,
`visible` INT(10) UNSIGNED NOT NULL DEFAULT 1,
PRIMARY KEY (`project`, `focus`),
INDEX `project` (`project`),
CONSTRAINT `FK_project_focus_projects` FOREIGN KEY (`project`) REFERENCES `projects` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;

View File

@ -1,13 +0,0 @@
CREATE TABLE `project_type` (
`project` INT(10) UNSIGNED NOT NULL,
`type` VARCHAR(20) NOT NULL COLLATE 'utf8mb4_unicode_ci',
`color` VARCHAR(20) NOT NULL DEFAULT 'badge-primary' COLLATE 'utf8mb4_unicode_ci',
`order` INT(10) UNSIGNED NOT NULL,
`visible` INT(10) UNSIGNED NOT NULL DEFAULT 1,
PRIMARY KEY (`project`, `type`),
INDEX `project` (`project`),
CONSTRAINT `FK_project_type_projects` FOREIGN KEY (`project`) REFERENCES `projects` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
)
COLLATE='utf8mb4_unicode_ci'
ENGINE=InnoDB
;