git-svn-id: https://msi/svn/firstRepo/Service/branches/Manut_2.2.3@71 0f545695-f87b-41b6-9a03-7f16563b5454
This commit is contained in:
+18
-3
@@ -18,6 +18,21 @@ $app->get('/photo/publish/:imageID', function ($imageID) use ($app) {
|
||||
$mysqlconnetion->disconnetti();
|
||||
});
|
||||
|
||||
$app->get('/photo/set_cover/:imageID', function ($imageID) use ($app) {
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
|
||||
$query = "select id_ricette from immagini where id = " . $imageID;
|
||||
$retObj = $mysqlconnetion->queryToObject($query, false);
|
||||
|
||||
$query = "update immagini set bCover = 0 where id_ricette = " . $retObj["id_ricette"];
|
||||
$mysqlconnetion->insertRecord($query);
|
||||
|
||||
$query = "update immagini set bCover = 1 where id = " . $imageID;
|
||||
$mysqlconnetion->insertRecord($query);
|
||||
|
||||
$mysqlconnetion->disconnetti();
|
||||
});
|
||||
|
||||
$app->delete('/photo/:imageID', function ($imageID) use ($app,$dirRicetteDropBox) {
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
|
||||
@@ -55,9 +70,9 @@ $app->post('/photo', function () use ($app, $dirRicetteDropBox) {
|
||||
// istanza della classe
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
//$mysqlconneti on->connetti();
|
||||
$query = "insert into immagini(id_ricette, type_format, from_profile_id, uploaded_date) " .
|
||||
$query = "insert into immagini(id_ricette, type_format, from_profile_id, uploaded_date, bCover) " .
|
||||
"values(" . $idRicette . ", '" . image_type_to_mime_type(exif_imagetype($tmpFileName)) .
|
||||
"', '" . $profileID . "', NOW())";
|
||||
"', '" . $profileID . "', NOW(), 0)";
|
||||
$newID = $mysqlconnetion->insertRecord($query);
|
||||
$ext = image_type_to_extension(exif_imagetype($tmpFileName), FALSE);
|
||||
|
||||
@@ -76,7 +91,7 @@ $app->post('/photo', function () use ($app, $dirRicetteDropBox) {
|
||||
|
||||
$thumb_link = makeThumbImage($dropBoxObj, $layer, 80, dirname($tmpFileName), $thumbFileName, $folder);
|
||||
|
||||
$query = "update immagini set (thumb_link = '" . $thumb_link . "', medium_link ='" . $medium_link . "', full_link = '" . $full_link ."' )" .
|
||||
$query = "update immagini set thumb_link = '" . $thumb_link . "', medium_link ='" . $medium_link . "', full_link = '" . $full_link ."'" .
|
||||
" where id=" . $newID;
|
||||
|
||||
$newID = $mysqlconnetion->insertRecord($query);
|
||||
|
||||
+1
-1
@@ -191,7 +191,7 @@ $app->get('/photos/', function () use ($app) {
|
||||
$app->get('/ricetta/:itemID/photos', function ($itemID) use ($app) {
|
||||
$callbackFn = $app->request()->get('callback');
|
||||
|
||||
$query = "SELECT id as id_photo, type_format, from_profile_id, uploaded_date, profilo.Name as profile_name, published from immagini" .
|
||||
$query = "SELECT id as id_photo, type_format, from_profile_id, uploaded_date, profilo.Name as profile_name, published, bCover from immagini" .
|
||||
" INNER JOIN profilo ON profilo.ProfiloID = immagini.from_profile_id".
|
||||
" WHERE id_ricette = " . $itemID;
|
||||
|
||||
|
||||
+9
-4
@@ -56,7 +56,7 @@ $app->get('/ricette/:catID', function ($categoryID) use ($app) {
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
//$mysqlconnetion->connetti();
|
||||
$query = "select * from (select ID as ricetta_id, titolo, autore, valutazione, difficolta, " .
|
||||
"(select id from immagini where immagini.id_ricette = ricette.id and published = 1 order by published_date limit 1) as firstImage " .
|
||||
"(select id from immagini where immagini.id_ricette = ricette.id and bCover = 1) as firstImage " .
|
||||
"from ricette where ricette.ID_CATEGORIA = " . $categoryID . " order by titolo, autore) as TMP";
|
||||
$retObj = $mysqlconnetion->queryToObject($query);
|
||||
$mysqlconnetion->disconnetti();
|
||||
@@ -98,8 +98,8 @@ $app->get('/ricette/:categoryID/lastinserted(/:numItems)', function ($categoryID
|
||||
returnJson($app, $callbackFn, $retObj);
|
||||
});
|
||||
|
||||
$app->get('/ricette/search/:numItems/:startItem(/:categoryId(/:difficolta(/:titolo)))',
|
||||
function ($numItems = 10, $startItem = 0, $categoryId = 0, $difficolta = 0, $titolo = "") use ($app) {
|
||||
$app->get('/ricette/search/:numItems/:startItem(/:categoryId(/:difficolta/:autore(/:titolo)))',
|
||||
function ($numItems = 10, $startItem = 0, $categoryId = 0, $difficolta = 0,$autore="_", $titolo = "") use ($app) {
|
||||
$callbackFn = $app->request()->get('callback');
|
||||
$mysqlconnetion = new MysqlClass;
|
||||
$queryBase = " from ricette"
|
||||
@@ -108,6 +108,9 @@ $app->get('/ricette/search/:numItems/:startItem(/:categoryId(/:difficolta(/:tito
|
||||
if ($categoryId > 0) {
|
||||
$queryBase = $queryBase . " AND ID_CATEGORIA = " . $categoryId;
|
||||
}
|
||||
if ($autore != null && $autore != "_") {
|
||||
$queryBase = $queryBase . " AND autore like '%" . urldecode($autore) . "%'";
|
||||
}
|
||||
if ($titolo != null && $titolo != "") {
|
||||
foreach (explode(" ", htmlentities(urldecode($titolo))) as $ele)
|
||||
$queryBase = $queryBase . " AND titolo like '%" . $ele . "%'";
|
||||
@@ -117,7 +120,9 @@ $app->get('/ricette/search/:numItems/:startItem(/:categoryId(/:difficolta(/:tito
|
||||
}
|
||||
$queryBase = $queryBase . " order by titolo, autore";
|
||||
|
||||
$query = "select ricette.ID as ricetta_id, categorie.name AS categoria_name, titolo, autore, valutazione, difficolta" . $queryBase . " LIMIT " . $numItems * $startItem . " , " . $numItems;
|
||||
$query = "select * from (select ricette.ID as ricetta_id, categorie.name AS categoria_name, titolo, autore, valutazione, difficolta, " .
|
||||
"(select id from immagini where immagini.id_ricette = ricette.id and bCover = 1) as firstImage" .
|
||||
$queryBase . " LIMIT " . $numItems * $startItem . " , " . $numItems . ") as TMP";
|
||||
$retObj2 = $mysqlconnetion->queryToObject($query);
|
||||
|
||||
$query = "select COUNT(*) as TotalRecords" . $queryBase;
|
||||
|
||||
+2
-2
@@ -97,7 +97,7 @@ function resizeImage($dropBoxObj, $layer, $size, $dir, $fileName, $dirDropBox)
|
||||
|
||||
$dropBoxObj->UploadFile($fullPath, $dirDropBox . "/" . $fileName);
|
||||
|
||||
echo $dropBoxObj->GetLink($dirDropBox . "/" . $fileName);
|
||||
return $dropBoxObj->GetLink($dirDropBox . "/" . $fileName);
|
||||
}
|
||||
|
||||
function makeThumbImage($dropBoxObj, $layer, $size, $dir, $fileName, $dirDropBox)
|
||||
@@ -114,7 +114,7 @@ function makeThumbImage($dropBoxObj, $layer, $size, $dir, $fileName, $dirDropBox
|
||||
}
|
||||
|
||||
$dropBoxObj->UploadFile($fullPath, $dirDropBox . "/" . $fileName);
|
||||
echo $dropBoxObj->GetLink($dirDropBox . "/" . $fileName);
|
||||
return $dropBoxObj->GetLink($dirDropBox . "/" . $fileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user