git-svn-id: https://msi/svn/firstRepo/Service/branches/Manut_2.2.3@28 0f545695-f87b-41b6-9a03-7f16563b5454
This commit is contained in:
+29
-6
@@ -81,7 +81,6 @@ $app->get('/categoryitems/:categoryID/lastinserted(/:numItems)', function ($cate
|
||||
$app->get('/categoryitems/search/:numItems(/:categoryId(/:difficolta(/:titolo)))',
|
||||
function ($numItems = 10, $categoryId = 0, $difficolta = 0, $titolo = "") use ($app) {
|
||||
$callbackFn = $app->request()->get('callback');
|
||||
//$filterItem = json_decode($app->request()->post('post'));
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
$query = "select ricette.ID as ricetta_id, categorie.name AS categoria_name, titolo, autore, valutazione, difficolta from ricette"
|
||||
. " INNER JOIN categorie ON categorie.ID = ricette.id_categoria"
|
||||
@@ -90,13 +89,14 @@ $app->get('/categoryitems/search/:numItems(/:categoryId(/:difficolta(/:titolo)))
|
||||
$query = $query . " AND ID_CATEGORIA = " . $categoryId;
|
||||
}
|
||||
if ($titolo != null && $titolo != "") {
|
||||
foreach (explode(" ", $titolo) as $ele)
|
||||
foreach (explode(" ", htmlentities(urldecode($titolo))) as $ele)
|
||||
$query = $query . " AND titolo like '%" . $ele . "%'";
|
||||
}
|
||||
if ($difficolta > 0) {
|
||||
$query = $query . " AND difficolta = " . $difficolta;
|
||||
}
|
||||
$query = $query . " order by titolo, autore LIMIT " . $numItems;
|
||||
$query = $query . " order by titolo, autore LIMIT " . $numItems;
|
||||
|
||||
$retObj = $mysqlconnetion->queryToObject($query);
|
||||
$mysqlconnetion->disconnetti();
|
||||
|
||||
@@ -106,6 +106,25 @@ $app->get('/categoryitems/search/:numItems(/:categoryId(/:difficolta(/:titolo)))
|
||||
returnJson($app, $callbackFn, $retObj);
|
||||
});
|
||||
|
||||
$app->get('/ricette/authors(/:startWith)',
|
||||
function ($startWith = "") use ($app) {
|
||||
$callbackFn = $app->request()->get('callback');
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
$query = "select distinct autore from ricette"
|
||||
. " where 1 = 1";
|
||||
|
||||
if ($startWith != null && $startWith != "") {
|
||||
$query = $query . " AND autore like '%" . $startWith . "%'";
|
||||
}
|
||||
|
||||
$query = $query . " order by autore";
|
||||
|
||||
$retObj = $mysqlconnetion->queryToObject($query);
|
||||
$mysqlconnetion->disconnetti();
|
||||
|
||||
returnJson($app, $callbackFn, $retObj);
|
||||
});
|
||||
|
||||
$app->get('/ricetta/body/:itemID', function ($itemID) use ($app) {
|
||||
$callbackFn = $app->request()->get('callback');
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
@@ -122,6 +141,10 @@ $app->get('/ricetta/body/:itemID', function ($itemID) use ($app) {
|
||||
"where ingredienti.ID_RICETTE = " . $itemID . " order by ingredienti.posizione";
|
||||
|
||||
$retObj2 = $mysqlconnetion->queryToObject($query2);
|
||||
|
||||
foreach ($retObj2 as $ele) {
|
||||
$ele["note"] = html_entity_decode($ele["note"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
|
||||
}
|
||||
|
||||
$retObj[0]["titolo"] = html_entity_decode($retObj[0]["titolo"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
|
||||
$retObj[0]["procedimento"] = html_entity_decode($retObj[0]["procedimento"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
|
||||
@@ -167,9 +190,9 @@ $app->get('/ricetta/ingredienti/:itemID', function ($itemID) use ($app) {
|
||||
|
||||
$retObj2 = $mysqlconnetion->queryToObject($query2);
|
||||
|
||||
//$retObj[0]["titolo"] = html_entity_decode($retObj[0]["titolo"]);
|
||||
//$retObj[0]["procedimento"] = html_entity_decode($retObj[0]["procedimento"]);
|
||||
//$retObj[0]["ingredienti"] = $retObj2;
|
||||
foreach ($retObj2 as $ele) {
|
||||
$ele["note"] = html_entity_decode($ele["note"], ENT_COMPAT | ENT_HTML401, 'ISO-8859-1');
|
||||
}
|
||||
|
||||
$mysqlconnetion->disconnetti();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user