mirror of
https://gitlab.com/CodeSolutionsProject/CodeShare.git
synced 2026-02-16 10:01:34 +01:00
#5 finished
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
<li>
|
<li>
|
||||||
<form class="nav navbar-nav navbar-form navbar-left" method="post">
|
<form class="nav navbar-nav navbar-form navbar-left" method="post">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="text" class="form-control" name="search" placeholder="Search">
|
<input type="text" class="form-control" name="globalSearch" placeholder="Search">
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary btn-sm">Submit</button>
|
<button type="submit" class="btn btn-primary btn-sm">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ function doAjax(postValue) {
|
|||||||
// Preparar la funcion de respuesta
|
// Preparar la funcion de respuesta
|
||||||
conexion.onreadystatechange = ajaxresponse; //Cuando el ajax sea procesado y suceda algo, se ejecuta esta funcion
|
conexion.onreadystatechange = ajaxresponse; //Cuando el ajax sea procesado y suceda algo, se ejecuta esta funcion
|
||||||
// Realizar peticion HTTP
|
// Realizar peticion HTTP
|
||||||
conexion.open('POST', 'ajax.php');
|
conexion.open('POST', '/');
|
||||||
conexion.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
conexion.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
conexion.send(postValue); //Las variables a mandar, en este caso POST
|
conexion.send(postValue); //Las variables a mandar, en este caso POST
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,19 +58,42 @@ $app->boot();
|
|||||||
$app->get('/', function (Request $request) use($app) {
|
$app->get('/', function (Request $request) use($app) {
|
||||||
connectDB();
|
connectDB();
|
||||||
$user = getUser($app);
|
$user = getUser($app);
|
||||||
$query = $app['db']->loadLast();
|
$last = array();
|
||||||
$last = lastToArray($app["db"],$query,$app['supported']);
|
$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){
|
$app->get('/doc', function (Request $request) use($app){
|
||||||
connectDB();
|
connectDB();
|
||||||
|
|||||||
Reference in New Issue
Block a user