Ejemplo n.º 1
0
 /**
  * Lists all galleries and images
  *
  * @param {string} $siteId
  * @return {array}
  */
 public static function listExtended($siteId)
 {
     $galleries = Gallery::listAll($siteId);
     $i = 0;
     foreach ($galleries as $gallery) {
         $galleries[$i]['images'] = GalleryImage::listAll($gallery['id'], $siteId);
         $i++;
     }
     return $galleries;
 }
 /**
  * Removes the gallery image
  *
  * @return Response
  */
 public function remove(Request $request)
 {
     // get request data
     $email = $request->input('auth-email');
     $siteId = $request->input('auth-id');
     // id, galleryId
     $id = $request->json()->get('id');
     $galleryId = $request->json()->get('galleryId');
     // get form
     $gallery = Gallery::getById($galleryId, $siteId);
     if ($gallery != NULL) {
         $index = GalleryImage::getIndexById($id, $galleryId, $siteId);
         array_splice($gallery->images, $index, 1);
         $gallery->save($siteId);
         // get site and user
         $site = Site::getById($siteId);
         $user = User::getByEmail($email, $siteId);
         // re-publish plugins
         Publish::publishPlugins($user, $site);
         return response('Ok', 200);
     }
     return response('Gallery not found', 400);
 }