Add languages, categorized them, add rechaptcha

This commit is contained in:
JoseluCross
2018-09-16 13:04:58 +02:00
parent 6d2466b5b1
commit d71a111fe9
14 changed files with 225 additions and 88 deletions

View File

@@ -211,15 +211,13 @@ class DB
}
}
}
if(count($array)==1)
$where = $where . "S.Lang<>''";
if (isset($array["o"]))
$first = $array["o"] * 10;
else
$first = 0;
if(array_key_exists("search",$array))
$search = $array("search");
$search = $this->search($array["search"]);
else
$search = "";
$queryLast = ") AND Version = (SELECT MAX(Version) FROM Sources WHERE S.Lang = Lang AND S.IDC = IDC)" . $search . " ORDER BY Modification DESC LIMIT $first, 10";

View File

@@ -18,7 +18,8 @@ $path = array(
"js" => "assets/js/",
"img" => "assets/img/",
);
$supported = ksonParse('data/supported.kson');
$string = file_get_contents(__DIR__."/../data/supported.json");
$supported = json_decode($string, true);
$loader = new Twig_Loader_Filesystem($path['html']);
$twig = new Twig_Environment($loader);
$user = array();
@@ -143,7 +144,8 @@ function firstPage($filter=false,$globalSearch=false){
"description" => "Sharing your solution with all",
"last" => $last,
"supported" => $supported,
"page" => "home"
"page" => "home",
"grouped" => groupByCategory($supported)
);
if(!$filter)
echo $twig->render("firstpage.twig",array("page" => $page, "path" => $path, "user" => $user));
@@ -237,7 +239,7 @@ function codeViewer(){
if($array){
$page = array(
"title" => "$array[Name] by $array[nick]",
"description" => "$array[Name] by $array[nick] in ".$supported[$_GET['lang']],
"description" => "$array[Name] by $array[nick] in ".$supported[$_GET['lang']][0],
"otherV" => false,
"otherI" => false,
"existedLangs" => $db->loadLangs($_GET['id']),

View File

@@ -20,7 +20,7 @@ function lastToArray($db,&$query,&$supported){
"version" => $var["Version"],
"name" => $var["Name"],
"nick" => $var["nick"],
"lLang" => $supported[$var["Lang"]],
"lLang" => $supported[$var["Lang"]][0],
"description" => $var["Description"],
"code" => html_entity_decode($var["Code"]),
);
@@ -37,7 +37,7 @@ function allCodeToArray(&$query,&$supported){
"name" => $query['Name'],
"nick" => $query['nick'],
"idu" => $query['IDU'],
"lLang" => $supported[$query['Lang']],
"lLang" => $supported[$query['Lang']][0],
"description" => $query['Description'],
"code" => html_entity_decode($query['Code']),
"input" => html_entity_decode($query['Input']),
@@ -56,7 +56,7 @@ function otherImplementationToArray($db,&$query,&$supported){
$array = array
( "lang" => $var["Lang"],
"version" => $var["Version"],
"lLang" => $supported[$var["Lang"]],
"lLang" => $supported[$var["Lang"]][0],
"code" => html_entity_decode($var["Code"]),
);
array_push($other,$array);

View File

@@ -49,4 +49,32 @@ function ksonParse($path){
}else{
die('<h3>Error, kson file not exist</h3>');
}
}
/**
* Group by $supported
*/
function groupByCategory(&$supported){
$grouped = Array();
foreach($supported as $key => $val){
if(!array_key_exists($val[1],$grouped)){
switch($val[1]){
case "Programming":
$num=5;
break;
case "Config":
case "Markup":
$num=2;
break;
case "Script":
case "Data":
case "Mathematics":
$num=1;
break;
}
$grouped[$val[1]] = Array(Array(),$num);
}
array_push($grouped[$val[1]][0],[$key,$val[0]]);
}
return $grouped;
}