This commit is contained in:
JoseluCross
2018-10-01 16:05:19 +02:00
parent 94d28dc292
commit e796883167
3 changed files with 37 additions and 14 deletions

View File

@@ -58,19 +58,42 @@ $app->boot();
$app->get('/', function (Request $request) use($app) {
connectDB();
$user = getUser($app);
$query = $app['db']->loadLast();
$last = lastToArray($app["db"],$query,$app['supported']);
$last = array();
$ajax=false;
if($request->getMethod()=="POST"){
if($request->get('globalSearch')!=null){
$data = array('search'=>$request->get('globalSearch'));
$type=true;
}else{
$data = $request->request->all();
$type=false;
$ajax=true;
}
$last = $app['db']->loadFilter($data,$type);
$last = lastToArray($app['db'],$last,$app['supported']);
}else{
$query = $app['db']->loadLast();
$last = lastToArray($app["db"],$query,$app['supported']);
}
$page = array( 'title' => "CodeShare",
"description" => "Sharing your solutions with all",
"last" => $last,
"supported" => $app["supported"],
"page" => "home",
"grouped" => groupByCategory($app["supported"]));
if($ajax){
return $app['twig']->render($app['fronthtml'] . '/firstCodes.twig' ,array(
"page" => $page,
'user' => $user
));
}else{
return $app['twig']->render($app['fronthtml'] . '/firstpage.twig' ,array(
"page" => $page,
'user' => $user
));
}
})->bind('home')->method('GET|POST');
return $app['twig']->render($app['fronthtml'] . '/firstpage.twig' ,array(
'page' => array('title' => "CodeShare",
"description" => "Sharing your solutions with all",
"last" => $last,
"supported" => $app["supported"],
"page" => "home",
"grouped" => groupByCategory($app["supported"])),
'user' => $user
));
})->bind('home');
$app->get('/doc', function (Request $request) use($app){
connectDB();