/*
LOGIN_CHECK();
$DOMSTR_TITLE = 'Hall of Fame';
$COMPONENTS['HALLOFFAME'] = [];
if (isset($_GET['showall'])) {
$DOMSTR_BODY_ATTRIBUTES .= 'get-has-showall';
}
global $BLUEPRINTS;
global $DOMSTR_METATAGS;
$BP = $BLUEPRINTS;
echo $BP['rMenuBar']('Hall of Fame');
// tool dropdown
$toolname_arr = [
['value' => 'kunststyletest', 'text' => 'Kunst-Style Test'],
['value' => 'mondrianmaker', 'text' => 'Mondrian Maker'],
['value' => 'robotmaker', 'text' => 'Robot Maker'],
['value' => 'bubblemaker', 'text' => 'Bubble Maker'],
['value' => 'gridmaker', 'text' => 'Grid Maker'],
['value' => 'stop-motion-tool', 'text' => 'Stop-Motion Tool'],
['value' => 'haikuwriter', 'text' => 'Haiku Writer'],
['value' => 'collagetool', 'text' => 'Collage Tool']
];
$ddobj_tool = [];
$ddobj_tool['name'] = 'tool';
if (isset($_GET['tool'])) {
$ddobj_tool['value'] = $_GET['tool'];
}
$ddobj_tool['defaulttext'] = 'alle Kreativtools';
$ddobj_tool['onvaluechange_callback'] = 'HALLOFFAME.updateThumbPoolDelayed';
foreach ($toolname_arr as $o) {
$ddobj_tool['options'][] = ['value' => $o['value'], 'text' => $o['text']];
}
$dropdown_tool = $BLUEPRINTS['rDropDown']($ddobj_tool);
// city dropdown
$baseurl = 'data/halloffame/';
$globqueryurl = $baseurl . '*/*/*/*/*/*/info.json';
$urls = glob($globqueryurl);
$city_arr_arr = [];
foreach ($urls as $url) {
if (!file_exists(dirname($url) . '/is.deleted') && file_exists(dirname($url) . '/is.public')) {
$infoobj = json2obj(file_get_contents($url));
$city = rObjValue($infoobj, 'city');
$citysortstr = rSortStr($city);
if ($citysortstr !== '') {
if (!isset($city_arr_arr[$citysortstr])) {
$city_arr_arr[$citysortstr] = [
'cityname' => htmlspecialchars($city),
'count' => 0
];
} else {
$city_arr_arr[$citysortstr]['count']++;
}
}
}
}
// 2 min pro stadt
$city_arr = [];
foreach ($city_arr_arr as $k => $info) {
if ($info['count'] > 1) {
$city_arr[$k] = ($info['cityname']);
}
}
//
ksort($city_arr);
$ddobj_city = [];
$ddobj_city['name'] = 'city';
if (isset($_GET['city'])) {
$ddobj_city['value'] = $_GET['city'];
}
$ddobj_city['defaulttext'] = 'alle Städte';
$ddobj_city['onvaluechange_callback'] = 'HALLOFFAME.updateThumbPoolDelayed';
foreach ($city_arr as $value => $text) {
$ddobj_city['options'][] = ['value' => $value, 'text' => $text];
}
$dropdown_city = $BLUEPRINTS['rDropDown']($ddobj_city);
// searchfield inputtext
$tiobj_searchfield = [];
$tiobj_searchfield['name'] = 'searchfield';
$tiobj_searchfield['placeholder'] = 'Name / Werkstitel';
if (isset($_GET['search'])) {
$tiobj_searchfield['value'] = $_GET['search'];
}
$tiobj_searchfield['onvaluechange_callback'] = 'HALLOFFAME.updateThumbPoolDelayed';
$textinput_searchfield = $BLUEPRINTS['rTextInput']($tiobj_searchfield);
// thumbpool
function rObjSearchHit($obj, $proparr, $searchterm)
{
$searchterm = rSearchStr($searchterm);
$searchinstr = '';
foreach ($proparr as $prop) {
$searchinstr .= ' ' . rObjValue($obj, $prop);
}
$searchinstr = rSearchStr($searchinstr);
$hit = strpos($searchinstr, $searchterm) !== false;
return $hit;
}
$COMPONENTS['HALLOFFAME']['rThumbPool'] = function ($parobj = null) {
global $LOGGEDIN;
$searchterm = rObjValue($parobj, 'searchterm');
$cityfilter = rObjValue($parobj, 'cityfilter');
$toolfilter = rObjValue($parobj, 'toolfilter');
$showall = rObjValue($parobj, 'showall', false);
$maxviewed = 500;
$showall_button = '';
if ($showall) {
$maxviewed = 99999;
}
$baseurl = 'data/halloffame/';
$globqueryurl = $baseurl . '*/*/*/*/*/*/info.json';
$urls = glob($globqueryurl);
$thumbpool_dom = '';
// collect data
$infoobj_arr = [];
foreach ($urls as $url) {
$ispublic = file_exists(dirname($url) . '/is.public');
if ($LOGGEDIN || $ispublic) {
$infoobj = json2obj(file_get_contents($url));
if ($ispublic) {
$infoobj['___ispublic'] = true;
}
$filterhits = 0;
$toolfilter_hit = false;
$cityfilter_hit = false;
$searchterm_hit = false;
// filter by tool
if ($toolfilter === '' || $toolfilter === rObjValue($infoobj, 'toolslug')) {
$toolfilter_hit = true;
}
// filter by city
if ($cityfilter === '' || $cityfilter === rSortStr(rObjValue($infoobj, 'city'))) {
$cityfilter_hit = true;
}
// filter by searchterm
if ($searchterm === '' || rObjSearchHit($infoobj, ['username', 'artworktitle', 'city'], $searchterm)) {
$searchterm_hit = true;
}
// collect if all match
if ($toolfilter_hit && $cityfilter_hit && $searchterm_hit) {
$infoobj_arr[$infoobj['id']] = $infoobj;
}
}
}
krsort($infoobj_arr);
// build dom
$thumbpool_dom = '';
$n = 0;
foreach ($infoobj_arr as $k => $infoobj) {
$id = $infoobj['id'];
$cleanid = ID2CleanID($id);
$username = rObjValue($infoobj, 'username');
if ($username === '') {
$username = 'Anonym';
}
$artworktitle = rObjValue($infoobj, 'artworktitle');
if ($artworktitle === '') {
$artworktitle = 'Ohne Titel';
}
$tool = rObjValue($infoobj, 'toolslug');
$city = rObjValue($infoobj, 'city');
$time = rObjValue($infoobj, 'time');
$searchstr_username = rSearchStr($username);
$searchstr_city = rSearchStr($city);
$searchstr_artworktitle = rSearchStr($artworktitle);
if ($city !== '') {
$city_arr[rSortStr($city)] = htmlspecialchars($city);
}
$artworktitle_dom = '' . htmlspecialchars($artworktitle) . '
';
$username_dom = 'von ' . htmlspecialchars($username) . '
';
$city_dom = '';
if ($city !== '') {
$city_dom = 'aus ' . htmlspecialchars($city) . '
';
}
$imgsrc = $baseurl . $id . 'stage.jpg';
if (file_exists($imgsrc)) {
$largeimgsrc = getOptimizedImageSrc($imgsrc, 1920);
} else {
$imgsrc = $baseurl . $id . 'stage.gif';
$largeimgsrc = $imgsrc;
}
$thumbimgsrc = getOptimizedImageSrc($imgsrc, 256);
$wh = getimagesize($thumbimgsrc);
$href = HTMLRELPATH . 'artwork_' . $cleanid;
// edit box ///////////////////////////////////
$editbox = '';
if ($LOGGEDIN) {
$makepublicbbt = '';
if (!isset ($infoobj['___ispublic'])) {
$makepublicbbt = 'veröffentlichen
';
}
$deletebt = 'löschen
';
$editbox = '
' . $makepublicbbt . '
' . $deletebt . '
';
}
////////////////////////////////////////////
$img = '
';
$thumbpool_dom .= '
' . $img . '
'
. $artworktitle_dom
. $username_dom
. $city_dom
. '
' . $editbox . '
';
if ($n >= $maxviewed) {
$showall_button = 'alle anzeigen
';
break;
}
$n++;
}
return $thumbpool_dom . $showall_button . '';
};
$COMPONENTS['HALLOFFAME']['rSlider'] = function ($parobj = null) {
global $BLUEPRINTS;
global $LOGGEDIN;
global $USER_ROLE;
// edit mode ///////////////////////////////////
if ($LOGGEDIN && $USER_ROLE === 'admin') {
return '';
}
////////////////////////////////////////////////////
$baseurl = 'data/halloffame/';
$globqueryurl = $baseurl . '*/*/*/*/*/*/info.json';
$urls = glob($globqueryurl);
$thumbpool_dom = '';
// collect data
$slots = [];
$tools = [];
foreach ($urls as $url) {
if (file_exists(dirname($url) . '/is.public')) {
$infoobj = json2obj(file_get_contents($url));
$tool = rObjValue($infoobj, 'toolslug');
if (!isset ($slots[$tool])) {
$slots[$tool] = [];
$tools[] = $tool;
}
$slots[$tool][$infoobj['id']] = $infoobj;
}
}
$infoobj_arr = [];
shuffle($tools);
foreach ($tools as $tool) {
$randkey = array_rand($slots[$tool], 1);
$infoobj_arr[] = $slots[$tool][$randkey];
}
// build sliderobj
$sliderobj = [];
$sliderobj['mediaboxes'] = [];
$sliderobj['class'] = 'bestofslider';
foreach ($infoobj_arr as $infoobj) {
$id = $infoobj['id'];
$username = rObjValue($infoobj, 'username');
if ($username === '') {
$username = 'Anonym';
}
$artworktitle = rObjValue($infoobj, 'artworktitle');
if ($artworktitle === '') {
$artworktitle = 'Ohne Titel';
}
$tool = rObjValue($infoobj, 'toolslug');
$city = rObjValue($infoobj, 'city');
$artworktitle_dom = '' . htmlspecialchars($artworktitle) . '
';
$username_dom = 'von ' . htmlspecialchars($username) . '
';
$city_dom = '';
if ($city !== '') {
$city_dom = 'aus ' . htmlspecialchars($city) . '
';
}
$closebt_onclick = 'window.history.back()';
if (!isset ($_SESSION['LASTPAGENAME'])) {
$closebt_onclick = 'window.location="' . ROOTPATH . BASEDIR . '";';
}
$imgsrc = $baseurl . $id . 'stage.jpg';
if (file_exists($imgsrc)) {
$largeimgsrc = getOptimizedImageSrc($imgsrc, 1920);
} else {
$imgsrc = $baseurl . $id . 'stage.gif';
$largeimgsrc = $imgsrc;
}
$mediabox_obj = [];
$mediabox_obj['mediasrc'] = $largeimgsrc;
$mediabox_obj['headline'] = $artworktitle_dom . $username_dom . $city_dom;
$sliderobj['mediaboxes'][] = $mediabox_obj;
}
return $BLUEPRINTS['rMediaSliderBox']($sliderobj);
};
//// ADMIN ///////////////
$COMPONENTS['HALLOFFAME']['deleteById'] = function ($parobj) {
// marks halloffame entry as deleted
// note: marked posts should be deleted regulary
global $BLUEPRINTS;
global $COMPONENTS;
global $USER_ROLE;
if ($USER_ROLE === 'admin') {
$deleteid = rObjValue($parobj, 'deleteid');
if (isValidId($deleteid)) {
deleteDir('data/halloffame/' . $deleteid, true);
return $COMPONENTS['HALLOFFAME']['rThumbPool']();
}
}
return 'if feel empty';
};
$COMPONENTS['HALLOFFAME']['makepublicById'] = function ($parobj) {
global $BLUEPRINTS;
global $COMPONENTS;
global $USER_ROLE;
if ($USER_ROLE === 'admin') {
$makepublicid = rObjValue($parobj, 'makepublicid');
if (isValidId($makepublicid)) {
$path = 'data/halloffame/' . $makepublicid . 'is.public';
saveJSON($path, '{}');
return $COMPONENTS['HALLOFFAME']['rThumbPool']();
}
}
return 'if feel empty';
};
?>
*/