tpl adjustments and default_page.php for calculations

This commit is contained in:
Ulf Gebhardt 2019-08-26 14:14:25 +02:00
parent 9a3baffde8
commit 1c4b79d196
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
11 changed files with 161 additions and 25 deletions

View File

@ -20,38 +20,105 @@ class default_page implements \SYSTEM\PAGE\DefaultPage {
private static function getPersons(){
$result = '';
$column_counter = 0;
$_content_persons_imgs = '';
$_content_persons_details = '';
$column_counter = 0;
$_content_imgs = '';
$_content_details = '';
$persons = \SQL\SELECT_PERSONS::QQ();
$person_badges = \SQL\SELECT_PERSON_BADGES::QA(); // This part we filter phpside due to performance.
$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.
while($row = $persons->next()){
$badges = array_filter($person_badges, function($v)use($row){return $v['person'] == $row['id'];});
$row['badges'] = '';
foreach($badges as $badge){
$row['badges'] .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/person_badge.tpl'))->SERVERPATH(),$badge);
$row['badges'] .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/content_badge.tpl'))->SERVERPATH(),$badge);
}
$_content_persons_imgs .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/person_img.tpl'))->SERVERPATH(),$row);
$_content_persons_details .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/person_details.tpl'))->SERVERPATH(),$row);
$projects = array_filter($person_projects, function($v)use($row){return $v['person'] == $row['id'];});
$row['projects'] = '';
foreach($projects as $project){
$project['link'] = $project['visible'] != 1 ? $project['website'] : '#project-'.$project['project'];
$project['target'] = $project['visible'] != 1 ? '_blank' : '';
$row['projects'] .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/person_project.tpl'))->SERVERPATH(),$project);
$row['projects'] .= ', ';
}
$row['projects'] = substr($row['projects'],0,-2);
$_content_imgs .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/person_img.tpl'))->SERVERPATH(),$row);
$_content_details .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/person_details.tpl'))->SERVERPATH(),$row);
// Insert full row and start a new row
if($column_counter++ === 2){
$result .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/persons_row.tpl'))->SERVERPATH(),
array( '_content_persons_imgs' => $_content_persons_imgs,
'_content_persons_details' => $_content_persons_details));
$column_counter = 0;
$_content_persons_imgs = '';
$_content_persons_details = '';
$result .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/content_row.tpl'))->SERVERPATH(),
array( '_content_imgs' => $_content_imgs,
'_content_details' => $_content_details));
$column_counter = 0;
$_content_imgs = '';
$_content_details = '';
}
}
// Insert incomplete rows
if($column_counter != 0){
$result .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/persons_row.tpl'))->SERVERPATH(),
array( '_content_persons_imgs' => $_content_persons_imgs,
'_content_persons_details' => $_content_persons_details));
$result .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/content_row.tpl'))->SERVERPATH(),
array( '_content_imgs' => $_content_imgs,
'_content_details' => $_content_details));
}
return $result;
}
private static function getProjects(){
$result = '';
$column_counter = 0;
$_content_imgs = '';
$_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.
while($row = $projects->next()){
$focus = array_filter($project_focus, function($v)use($row){return $v['project'] == $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'];});
$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);
}
$persons = array_filter($project_persons, function($v)use($row){return $v['project'] == $row['id'];});
$row['persons'] = '';
foreach($persons as $person){
$row['persons'] .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/project_person.tpl'))->SERVERPATH(),$person);
}
$_content_imgs .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/project_img.tpl'))->SERVERPATH(),$row);
$_content_details .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/project_details.tpl'))->SERVERPATH(),$row);
// Insert full row and start a new row
if($column_counter++ === 2){
$result .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/content_row.tpl'))->SERVERPATH(),
array( '_content_imgs' => $_content_imgs,
'_content_details' => $_content_details));
$column_counter = 0;
$_content_imgs = '';
$_content_details = '';
}
}
// Insert incomplete rows
if($column_counter != 0){
$result .= \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/content_row.tpl'))->SERVERPATH(),
array( '_content_imgs' => $_content_imgs,
'_content_details' => $_content_details));
}
return $result;
@ -63,8 +130,8 @@ class default_page implements \SYSTEM\PAGE\DefaultPage {
if(!$_escaped_fragment_){
$vars['js'] = self::js();}
$vars['css'] = self::css();
//$vars['_content_persons'] = \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/content_persons.tpl'))->SERVERPATH());
$vars['_content_persons'] = self::getPersons();
$vars['_content_persons'] = self::getPersons();
$vars['_content_projects'] = self::getProjects();
$vars = array_merge($vars, \SYSTEM\PAGE\text::tag('wecker_manufaktur'));
return \SYSTEM\PAGE\replace::replaceFile((new PPAGE('default_page/tpl/default_page.tpl'))->SERVERPATH(), $vars);
}

View File

@ -1,5 +1,6 @@
$(document).ready(function() {
//new SYSTEM('./api.php',1,'start');
$('.person-link').click(function(e){
e.preventDefault();
$person = $(this).attr('person');
@ -9,4 +10,32 @@ $(document).ready(function() {
$('#person-details-'+$person).removeClass('d-none');
}
})
$('.person-project-link').click(function(e){
$project = $(this).attr('project');
$isHidden = $('#project-details-'+$project).hasClass('d-none');
$('.project-details').addClass('d-none');
if($isHidden){
$('#project-details-'+$project).removeClass('d-none');
}
})
$('.project-link').click(function(e){
e.preventDefault();
$project = $(this).attr('project');
$isHidden = $('#project-details-'+$project).hasClass('d-none');
$('.project-details').addClass('d-none');
if($isHidden){
$('#project-details-'+$project).removeClass('d-none');
}
})
$('.project-person-link').click(function(e){
$person = $(this).attr('person');
$isHidden = $('#person-details-'+$person).hasClass('d-none');
$('.person-details').addClass('d-none');
if($isHidden){
$('#person-details-'+$person).removeClass('d-none');
}
})
});

View File

@ -0,0 +1,4 @@
<div class="row">
${_content_imgs}
${_content_details}
</div>

View File

@ -11,7 +11,7 @@
</tr>
<tr>
<th scope="row">Projekte</th>
<td>TODO</td>
<td>${projects}</td>
</tr>
</table>
</div>

View File

@ -1,5 +1,5 @@
<div class="col-lg-4">
<a href="#" person="${id}" class="person-link">
<a id="person-${id}" href="#person-details-${id}" person="${id}" class="person-link">
<div>
<img src="./files/persons/${img}" class="rounded-circle" alt="${name}" style="object-fit: cover; width: 300px; height: 300px;">
</div>

View File

@ -0,0 +1 @@
<a href="${link}" target="${target}" class="person-project-link" project="${project}">${name}</a>

View File

@ -1,4 +0,0 @@
<div class="row">
${_content_persons_imgs}
${_content_persons_details}
</div>

View File

@ -0,0 +1,26 @@
<div id="project-details-${id}" class="col-12 d-none project-details" style="text-align: left;">
<div>
<table class="table table-borderless">
<tr>
<th scope="row">Fokus</th>
<td>${focus}</td>
</tr>
<tr>
<th scope="row">Typ</th>
<td>${type}</td>
</tr>
<tr>
<th scope="row">Kurzinfo</th>
<td>${info}</td>
</tr>
<tr>
<th scope="row">Beteiligte</th>
<td>${persons}</td>
</tr>
<tr>
<th scope="row">Website</th>
<td><a href="${website}" target="_blank">${website}</a></td>
</tr>
</table>
</div>
</div>

View File

@ -0,0 +1,10 @@
<div class="col-lg-4">
<a id="project-${id}" href="#project-details-${id}" project="${id}" class="project-link">
<div>
<img src="./files/projects/${img}" class="rounded" alt="${name}" style="object-fit: cover; width: 300px; height: 300px;">
</div>
<div>
${name} <i class="fa fa-angle-down"></i>
</div>
</a>
</div>

View File

@ -0,0 +1,3 @@
<a href="#person-${id}" person="${id}" class="project-person-link">
<img src="./files/persons/${img}" class="rounded-circle" alt="${name}" style="object-fit: cover; width: 75px; height: 75px;">
</a>