Plugin Directory

Changeset 2103033


Ignore:
Timestamp:
06/09/2019 09:23:11 PM (7 years ago)
Author:
dman25560
Message:

2.0.4

  • Fixed issue where empty albums would refuse to delete
  • Added detailed error handling to video api endpoints
Location:
utubevideo-gallery
Files:
765 added
24 edited

Legend:

Unmodified
Added
Removed
  • utubevideo-gallery/trunk/.git/COMMIT_EDITMSG

    r2013784 r2103033  
    1 Compatibility fix for NextGEN Gallery
     1Updated plugin version and WordPress dependecies
  • utubevideo-gallery/trunk/.git/FETCH_HEAD

    r2087886 r2103033  
    1 cacc3e309c14b0766ee654035c8398d91df3427e        branch 'master' of https://github.com/dman25560/utubevideogallery
     1cacc3e309c14b0766ee654035c8398d91df3427e        branch 'master' of https://github.com/dustinscarberry/utubevideogallery
  • utubevideo-gallery/trunk/.git/ORIG_HEAD

    r2087886 r2103033  
    1 a1c8fce8aebc92babf3ed9da6d1947971eadcea8
     1cacc3e309c14b0766ee654035c8398d91df3427e
  • utubevideo-gallery/trunk/.git/config

    r2003169 r2103033  
    77    ignorecase = true
    88[remote "origin"]
    9     url = https://github.com/dman25560/utubevideogallery.git
     9    url = https://github.com/dustinscarberry/utubevideogallery.git
    1010    fetch = +refs/heads/*:refs/remotes/origin/*
    1111[branch "master"]
  • utubevideo-gallery/trunk/.git/logs/HEAD

    r2087886 r2103033  
    1010a1c8fce8aebc92babf3ed9da6d1947971eadcea8 a1c8fce8aebc92babf3ed9da6d1947971eadcea8 Dustin Scarberry <dustin@codeclouds.net> 1557291324 -0400 reset: moving to HEAD
    1111a1c8fce8aebc92babf3ed9da6d1947971eadcea8 cacc3e309c14b0766ee654035c8398d91df3427e Dustin Scarberry <dustin@codeclouds.net> 1557291350 -0400 pull: Fast-forward
     12cacc3e309c14b0766ee654035c8398d91df3427e 70580a68fac1fb3c45a5be33949fe4213a38a92c Dustin Scarberry <dustin@codeclouds.net> 1560099301 -0400 commit: Fixed issue preventing delete of empty albums
     1370580a68fac1fb3c45a5be33949fe4213a38a92c 0a0bfda4ac85fe65cd29c817dd1206d068398031 Dustin Scarberry <dustin@codeclouds.net> 1560099324 -0400 commit: Added try/catch to api endpoints
     140a0bfda4ac85fe65cd29c817dd1206d068398031 70d3374aae665bbe0dee154b974770d319571d76 Dustin Scarberry <dustin@codeclouds.net> 1560104154 -0400 commit: Better error handling for video creation
     1570d3374aae665bbe0dee154b974770d319571d76 8ef2e564a5dc869ec818c11e54479ec20dc9b82d Dustin Scarberry <dustin@codeclouds.net> 1560104255 -0400 commit: Fixed typo
     168ef2e564a5dc869ec818c11e54479ec20dc9b82d fbdfeec00027a13d4d938c070d68a94aa58b8c95 Dustin Scarberry <dustin@codeclouds.net> 1560104425 -0400 commit: Fixed typo
     17fbdfeec00027a13d4d938c070d68a94aa58b8c95 6ae8b7cc80e5516d931271f162f4f94a698c9281 Dustin Scarberry <dustin@codeclouds.net> 1560112151 -0400 commit: Further exception handling
     186ae8b7cc80e5516d931271f162f4f94a698c9281 017c9b189cce5c74baf93000f281c641ef0a6c4c Dustin Scarberry <dustin@codeclouds.net> 1560113923 -0400 commit: Updated plugin version and WordPress dependecies
  • utubevideo-gallery/trunk/.git/logs/refs/heads/master

    r2087886 r2103033  
    662b6a59cb92bea9a796cf4a29cb44c3596dd462f5 a1c8fce8aebc92babf3ed9da6d1947971eadcea8 Dustin Scarberry <dustin@codeclouds.net> 1557195783 -0400 pull: Fast-forward
    77a1c8fce8aebc92babf3ed9da6d1947971eadcea8 cacc3e309c14b0766ee654035c8398d91df3427e Dustin Scarberry <dustin@codeclouds.net> 1557291350 -0400 pull: Fast-forward
     8cacc3e309c14b0766ee654035c8398d91df3427e 70580a68fac1fb3c45a5be33949fe4213a38a92c Dustin Scarberry <dustin@codeclouds.net> 1560099301 -0400 commit: Fixed issue preventing delete of empty albums
     970580a68fac1fb3c45a5be33949fe4213a38a92c 0a0bfda4ac85fe65cd29c817dd1206d068398031 Dustin Scarberry <dustin@codeclouds.net> 1560099324 -0400 commit: Added try/catch to api endpoints
     100a0bfda4ac85fe65cd29c817dd1206d068398031 70d3374aae665bbe0dee154b974770d319571d76 Dustin Scarberry <dustin@codeclouds.net> 1560104154 -0400 commit: Better error handling for video creation
     1170d3374aae665bbe0dee154b974770d319571d76 8ef2e564a5dc869ec818c11e54479ec20dc9b82d Dustin Scarberry <dustin@codeclouds.net> 1560104255 -0400 commit: Fixed typo
     128ef2e564a5dc869ec818c11e54479ec20dc9b82d fbdfeec00027a13d4d938c070d68a94aa58b8c95 Dustin Scarberry <dustin@codeclouds.net> 1560104425 -0400 commit: Fixed typo
     13fbdfeec00027a13d4d938c070d68a94aa58b8c95 6ae8b7cc80e5516d931271f162f4f94a698c9281 Dustin Scarberry <dustin@codeclouds.net> 1560112151 -0400 commit: Further exception handling
     146ae8b7cc80e5516d931271f162f4f94a698c9281 017c9b189cce5c74baf93000f281c641ef0a6c4c Dustin Scarberry <dustin@codeclouds.net> 1560113923 -0400 commit: Updated plugin version and WordPress dependecies
  • utubevideo-gallery/trunk/.git/logs/refs/remotes/origin/master

    r2087886 r2103033  
    552b6a59cb92bea9a796cf4a29cb44c3596dd462f5 a1c8fce8aebc92babf3ed9da6d1947971eadcea8 Dustin Scarberry <dustin@codeclouds.net> 1557195783 -0400 pull: fast-forward
    66a1c8fce8aebc92babf3ed9da6d1947971eadcea8 cacc3e309c14b0766ee654035c8398d91df3427e Dustin Scarberry <dustin@codeclouds.net> 1557291350 -0400 pull: fast-forward
     7cacc3e309c14b0766ee654035c8398d91df3427e 0a0bfda4ac85fe65cd29c817dd1206d068398031 Dustin Scarberry <dustin@codeclouds.net> 1560099330 -0400 update by push
     80a0bfda4ac85fe65cd29c817dd1206d068398031 70d3374aae665bbe0dee154b974770d319571d76 Dustin Scarberry <dustin@codeclouds.net> 1560104159 -0400 update by push
     970d3374aae665bbe0dee154b974770d319571d76 8ef2e564a5dc869ec818c11e54479ec20dc9b82d Dustin Scarberry <dustin@codeclouds.net> 1560104267 -0400 update by push
     108ef2e564a5dc869ec818c11e54479ec20dc9b82d fbdfeec00027a13d4d938c070d68a94aa58b8c95 Dustin Scarberry <dustin@codeclouds.net> 1560104432 -0400 update by push
     11fbdfeec00027a13d4d938c070d68a94aa58b8c95 6ae8b7cc80e5516d931271f162f4f94a698c9281 Dustin Scarberry <dustin@codeclouds.net> 1560112346 -0400 update by push
     126ae8b7cc80e5516d931271f162f4f94a698c9281 017c9b189cce5c74baf93000f281c641ef0a6c4c Dustin Scarberry <dustin@codeclouds.net> 1560113960 -0400 update by push
  • utubevideo-gallery/trunk/.git/refs/heads/master

    r2087886 r2103033  
    1 cacc3e309c14b0766ee654035c8398d91df3427e
     1017c9b189cce5c74baf93000f281c641ef0a6c4c
  • utubevideo-gallery/trunk/.git/refs/remotes/origin/master

    r2087886 r2103033  
    1 cacc3e309c14b0766ee654035c8398d91df3427e
     1017c9b189cce5c74baf93000f281c641ef0a6c4c
  • utubevideo-gallery/trunk/class/CodeClouds/UTubeVideoGallery/API/AlbumAPIv1.php

    r2003169 r2103033  
    9797  public function getItem(WP_REST_Request $req)
    9898  {
    99     //check for valid albumID
    100     if (!$req['albumID'])
    101       return $this->errorResponse(__('Invalid album ID', 'utvg'));
    102 
    103     //sanitize data
    104     $albumID = sanitize_key($req['albumID']);
    105 
    106     //get album
    107     $albumRepository = new AlbumRepository();
    108     $album = $albumRepository->getItem($albumID);
    109 
    110     //check if album exists
    111     if (!$album)
    112       return $this->errorResponse(__('The specified album resource was not found', 'utvg'));
    113 
    114     return $this->response($album);
     99    try
     100    {
     101      //check for valid albumID
     102      if (!$req['albumID'])
     103        return $this->errorResponse(__('Invalid album ID', 'utvg'));
     104
     105      //sanitize data
     106      $albumID = sanitize_key($req['albumID']);
     107
     108      //get album
     109      $albumRepository = new AlbumRepository();
     110      $album = $albumRepository->getItem($albumID);
     111
     112      //check if album exists
     113      if (!$album)
     114        return $this->errorResponse(__('The specified album resource was not found', 'utvg'));
     115
     116      return $this->response($album);
     117    }
     118    catch (\Exception $e)
     119    {
     120      return $this->errorResponse($e->getMessage());
     121    }
    115122  }
    116123
     
    118125  public function createItem(WP_REST_Request $req)
    119126  {
    120     //create repository
    121     $albumRepository = new AlbumRepository();
    122 
    123     //gather data fields
    124     $title = sanitize_text_field($req['title']);
    125     $videoSorting = ($req['videoSorting'] == 'desc' ? 'desc' : 'asc');
    126     $galleryID = sanitize_key($req['galleryID']);
    127 
    128     //check for required fields
    129     if (empty($title) || empty($videoSorting) || !isset($galleryID))
    130       return $this->errorResponse(__('Invalid parameters', 'utvg'));
    131 
    132     //get next album sort position
    133     $nextSortPosition = $albumRepository->getNextSortPositionByGallery($galleryID);
    134 
    135     //generate slug and store for possible use in future
    136     $slug = $this->generateSlug($title, $wpdb);
    137 
    138     //insert new album
    139     $albumID = $albumRepository->createItem(
    140       $title,
    141       $slug,
    142       $videoSorting,
    143       $nextSortPosition,
    144       $galleryID
    145     );
    146 
    147     //if successfull album creation..
    148     if ($albumID)
    149       return $this->response(null, 201);
    150     else
    151       return $this->errorResponse(__('A database error has occurred', 'utvg'));
     127    try
     128    {
     129      //create repository
     130      $albumRepository = new AlbumRepository();
     131
     132      //gather data fields
     133      $title = sanitize_text_field($req['title']);
     134      $videoSorting = ($req['videoSorting'] == 'desc' ? 'desc' : 'asc');
     135      $galleryID = sanitize_key($req['galleryID']);
     136     
     137      //check for required fields
     138      if (empty($title) || empty($videoSorting) || !isset($galleryID))
     139        throw new \Exception(__('Invalid parameters', 'utvg'));
     140        //return $this->errorResponse(__('Invalid parameters', 'utvg'));
     141
     142      //get next album sort position
     143      $nextSortPosition = $albumRepository->getNextSortPositionByGallery($galleryID);
     144
     145      //generate slug and store for possible use in future
     146      $slug = $this->generateSlug($title, $wpdb);
     147
     148      //insert new album
     149      $albumID = $albumRepository->createItem(
     150        $title,
     151        $slug,
     152        $videoSorting,
     153        $nextSortPosition,
     154        $galleryID
     155      );
     156
     157      //if successfull album creation..
     158      if ($albumID)
     159        return $this->response(null, 201);
     160      else
     161        return $this->errorResponse(__('A database error has occurred', 'utvg'));
     162    }
     163    catch (\Exception $e)
     164    {
     165      return $this->errorResponse($e->getMessage());
     166    }
    152167  }
    153168
     
    155170  public function deleteItem(WP_REST_Request $req)
    156171  {
    157     //check for valid albumID
    158     if (!$req['albumID'])
    159       return $this->errorResponse(__('Invalid album ID', 'utvg'));
    160 
    161     //sanitize fields
    162     $albumID = sanitize_key($req['albumID']);
    163 
    164     //get all videos in album
    165     $videoRepository = new VideoRepository();
    166     $albumVideos = $videoRepository->getItemsByAlbum($albumID);
    167 
    168     //delete album and videos from database
    169     $albumRepository = new AlbumRepository();
    170 
    171     if (
    172       !$videoRepository->deleteItemsByAlbum($albumID)
    173       || !$albumRepository->deleteItem($albumID)
    174     )
    175       return $this->errorResponse(__('A database error has occurred', 'utvg'));
    176 
    177     //delete thumbnails
    178     $thumbnailPath = wp_upload_dir();
    179     $thumbnailPath = $thumbnailPath['basedir'] . '/utubevideo-cache/';
    180 
    181     //delete video thumbnails
    182     foreach ($videos as $video)
    183     {
    184       unlink($thumbnailPath . $video->getThumbnail() . '.jpg');
    185       unlink($thumbnailPath . $video->getThumbnail() . '@2x.jpg');
    186     }
    187 
    188     return $this->response(null);
     172    try
     173    {
     174      //check for valid albumID
     175      if (!$req['albumID'])
     176        return $this->errorResponse(__('Invalid album ID', 'utvg'));
     177
     178      //sanitize fields
     179      $albumID = sanitize_key($req['albumID']);
     180
     181      //get all videos in album
     182      $videoRepository = new VideoRepository();
     183      $albumVideos = $videoRepository->getItemsByAlbum($albumID);
     184
     185      //delete album and videos from database
     186      $albumRepository = new AlbumRepository();
     187
     188      if (
     189        !$videoRepository->deleteItemsByAlbum($albumID)
     190        || !$albumRepository->deleteItem($albumID)
     191      )
     192        return $this->errorResponse(__('A database error has occurred', 'utvg'));
     193
     194      //delete thumbnails
     195      $thumbnailPath = wp_upload_dir();
     196      $thumbnailPath = $thumbnailPath['basedir'] . '/utubevideo-cache/';
     197
     198      //delete video thumbnails
     199      foreach ($videos as $video)
     200      {
     201        unlink($thumbnailPath . $video->getThumbnail() . '.jpg');
     202        unlink($thumbnailPath . $video->getThumbnail() . '@2x.jpg');
     203      }
     204
     205      return $this->response(null);
     206    }
     207    catch (\Exception $e)
     208    {
     209      return $this->errorResponse($e->getMessage());
     210    }
    189211  }
    190212
     
    192214  public function updateItem(WP_REST_Request $req)
    193215  {
    194     //check for valid albumID
    195     if (!$req['albumID'])
    196       return $this->errorResponse(__('Invalid album ID', 'utvg'));
    197 
    198     //gather data fields
    199     $albumID = sanitize_key($req['albumID']);
    200     $title = sanitize_text_field($req['title']);
    201     $thumbnail = sanitize_text_field($req['thumbnail']);
    202 
    203     if (isset($req['videoSorting']))
    204       $videoSorting = $req['videoSorting'] == 'desc' ? 'desc' : 'asc';
    205     else
    206       $videoSorting = null;
    207 
    208     if (isset($req['published']))
    209       $published = $req['published'] ? true : false;
    210     else
    211       $published = null;
    212 
    213     $galleryID = sanitize_key($req['galleryID']);
    214     $currentTime = current_time('timestamp');
    215 
    216     //create updatedFields array
    217     $updatedFields = [];
    218 
    219     //set optional update fields
    220     if ($title != null)
    221       $updatedFields['ALB_NAME'] = $title;
    222 
    223     if ($thumbnail != null)
    224       $updatedFields['ALB_THUMB'] = $thumbnail;
    225 
    226     if ($videoSorting != null)
    227       $updatedFields['ALB_SORT'] = $videoSorting;
    228 
    229     if ($published !== null)
    230       $updatedFields['ALB_PUBLISH'] = $published;
    231 
    232     if ($galleryID != null)
    233       $updatedFields['DATA_ID'] = $galleryID;
    234 
    235     //set required update fields
    236     $updatedFields['ALB_UPDATEDATE'] = $currentTime;
    237 
    238     //update album
    239     $albumRepository = new AlbumRepository();
    240 
    241     if ($albumRepository->updateItem($albumID, $updatedFields))
    242       return $this->response(null);
    243     else
    244       return $this->errorResponse(__('A database error has occurred', 'utvg'));
     216    try
     217    {
     218      //check for valid albumID
     219      if (!$req['albumID'])
     220        return $this->errorResponse(__('Invalid album ID', 'utvg'));
     221
     222      //gather data fields
     223      $albumID = sanitize_key($req['albumID']);
     224      $title = sanitize_text_field($req['title']);
     225      $thumbnail = sanitize_text_field($req['thumbnail']);
     226
     227      if (isset($req['videoSorting']))
     228        $videoSorting = $req['videoSorting'] == 'desc' ? 'desc' : 'asc';
     229      else
     230        $videoSorting = null;
     231
     232      if (isset($req['published']))
     233        $published = $req['published'] ? true : false;
     234      else
     235        $published = null;
     236
     237      $galleryID = sanitize_key($req['galleryID']);
     238      $currentTime = current_time('timestamp');
     239
     240      //create updatedFields array
     241      $updatedFields = [];
     242
     243      //set optional update fields
     244      if ($title != null)
     245        $updatedFields['ALB_NAME'] = $title;
     246
     247      if ($thumbnail != null)
     248        $updatedFields['ALB_THUMB'] = $thumbnail;
     249
     250      if ($videoSorting != null)
     251        $updatedFields['ALB_SORT'] = $videoSorting;
     252
     253      if ($published !== null)
     254        $updatedFields['ALB_PUBLISH'] = $published;
     255
     256      if ($galleryID != null)
     257        $updatedFields['DATA_ID'] = $galleryID;
     258
     259      //set required update fields
     260      $updatedFields['ALB_UPDATEDATE'] = $currentTime;
     261
     262      //update album
     263      $albumRepository = new AlbumRepository();
     264
     265      if ($albumRepository->updateItem($albumID, $updatedFields))
     266        return $this->response(null);
     267      else
     268        return $this->errorResponse(__('A database error has occurred', 'utvg'));
     269    }
     270    catch (\Exception $e)
     271    {
     272      return $this->errorResponse($e->getMessage());
     273    }
    245274  }
    246275
     
    248277  public function getAllItems(WP_REST_Request $req)
    249278  {
    250     //check for valid gallery id
    251     if (!$req['galleryID'])
    252       return $this->errorResponse(__('Invalid gallery ID', 'utvg'));
    253 
    254     //sanitize data
    255     $galleryID = sanitize_key($req['galleryID']);
    256 
    257     //get albums
    258     $albumRepository = new AlbumRepository();
    259     $albums = $albumRepository->getItemsByGallery($galleryID);
    260 
    261     return $this->response($albums);
     279    try
     280    {
     281      //check for valid gallery id
     282      if (!$req['galleryID'])
     283        return $this->errorResponse(__('Invalid gallery ID', 'utvg'));
     284
     285      //sanitize data
     286      $galleryID = sanitize_key($req['galleryID']);
     287
     288      //get albums
     289      $albumRepository = new AlbumRepository();
     290      $albums = $albumRepository->getItemsByGallery($galleryID);
     291
     292      return $this->response($albums);
     293    }
     294    catch (\Exception $e)
     295    {
     296      return $this->errorResponse($e->getMessage());
     297    }
    262298  }
    263299
     
    265301  public function getAnyAllItems(WP_REST_Request $req)
    266302  {
    267     //get albums
    268     $albumRepository = new AlbumRepository();
    269     $albums = $albumRepository->getItems();
    270 
    271     return $this->response($albums);
     303    try
     304    {
     305      //get albums
     306      $albumRepository = new AlbumRepository();
     307      $albums = $albumRepository->getItems();
     308
     309      return $this->response($albums);
     310    }
     311    catch (\Exception $e)
     312    {
     313      return $this->errorResponse($e->getMessage());
     314    }
    272315  }
    273316
  • utubevideo-gallery/trunk/class/CodeClouds/UTubeVideoGallery/API/AlbumOrderAPIv1.php

    r2003169 r2103033  
    3333  public function updateItem(WP_REST_Request $req)
    3434  {
    35     global $wpdb;
     35    try
     36    {
     37      global $wpdb;
    3638
    37     if (!$req['albumids'])
    38       return $this->errorResponse(__('Invalid data', 'utvg'));
     39      if (!$req['albumids'])
     40        return $this->errorResponse(__('Invalid data', 'utvg'));
    3941
    40     $albumCount = count($req['albumids']);
     42      $albumCount = count($req['albumids']);
    4143
    42     for ($i = 0; $i < $albumCount; $i++)
     44      for ($i = 0; $i < $albumCount; $i++)
     45      {
     46        $albumID = sanitize_key($req['albumids'][$i]);
     47
     48        if (!$albumID)
     49          return $this->errorResponse(__('Invalid data value', 'utvg'));
     50
     51        $wpdb->update(
     52          $wpdb->prefix . 'utubevideo_album',
     53          ['ALB_POS' => $i],
     54          ['ALB_ID' => $albumID]
     55        );
     56      }
     57
     58      return $this->response(null);
     59    }
     60    catch (\Exception $e)
    4361    {
    44       $albumID = sanitize_key($req['albumids'][$i]);
    45 
    46       if (!$albumID)
    47         return $this->errorResponse(__('Invalid data value', 'utvg'));
    48 
    49       $wpdb->update(
    50         $wpdb->prefix . 'utubevideo_album',
    51         ['ALB_POS' => $i],
    52         ['ALB_ID' => $albumID]
    53       );
     62      return $this->errorResponse($e->getMessage());
    5463    }
    55 
    56     return $this->response(null);
    5764  }
    5865}
  • utubevideo-gallery/trunk/class/CodeClouds/UTubeVideoGallery/API/GalleryAPIv1.php

    r2003169 r2103033  
    8181  public function getItem(WP_REST_Request $req)
    8282  {
    83     //check for valid galleryID
    84     if (!$req['galleryID'])
    85       return $this->errorResponse(__('Invalid gallery ID', 'utvg'));
    86 
    87     //sanitize data
    88     $galleryID = sanitize_key($req['galleryID']);
    89 
    90     //get gallery
    91     $galleryRepository = new GalleryRepository();
    92     $gallery = $galleryRepository->getItem($galleryID);
    93 
    94     if (!$gallery)
    95       return $this->errorResponse(__('The specified gallery resource was not found', 'utvg'));
    96 
    97     return $this->response($gallery);
     83    try
     84    {
     85      //check for valid galleryID
     86      if (!$req['galleryID'])
     87        return $this->errorResponse(__('Invalid gallery ID', 'utvg'));
     88
     89      //sanitize data
     90      $galleryID = sanitize_key($req['galleryID']);
     91
     92      //get gallery
     93      $galleryRepository = new GalleryRepository();
     94      $gallery = $galleryRepository->getItem($galleryID);
     95
     96      if (!$gallery)
     97        return $this->errorResponse(__('The specified gallery resource was not found', 'utvg'));
     98
     99      return $this->response($gallery);
     100    }
     101    catch (\Exception $e)
     102    {
     103      return $this->errorResponse($e->getMessage());
     104    }
    98105  }
    99106
    100107  public function createItem(WP_REST_Request $req)
    101108  {
    102     //gather data fields
    103     $title = sanitize_text_field($req['title']);
    104     $albumSorting = sanitize_text_field($req['albumSorting'] == 'desc' ? 'desc' : 'asc');
    105     $thumbnailType = sanitize_text_field($req['thumbnailType'] == 'square' ? 'square' : 'rectangle');
    106     $displayType = sanitize_text_field($req['displayType'] == 'video' ? 'video' : 'album');
    107 
    108     //check for required fields
    109     if (
    110       empty($title)
    111       || empty($albumSorting)
    112       || empty($thumbnailType)
    113       || empty($displayType)
    114     )
    115       return $this->errorResponse(__('Invalid parameters', 'utvg'));
    116 
    117     //insert new gallery
    118     $galleryRepository = new GalleryRepository();
    119     $galleryID = $galleryRepository->createItem(
    120       $title,
    121       $albumSorting,
    122       $thumbnailType,
    123       $displayType
    124     );
    125 
    126     if ($galleryID)
    127       return $this->response($galleryID, 201);
    128     else
    129       return $this->errorResponse(__('A database error has occurred', 'utvg'));
     109    try
     110    {
     111      //gather data fields
     112      $title = sanitize_text_field($req['title']);
     113      $albumSorting = sanitize_text_field($req['albumSorting'] == 'desc' ? 'desc' : 'asc');
     114      $thumbnailType = sanitize_text_field($req['thumbnailType'] == 'square' ? 'square' : 'rectangle');
     115      $displayType = sanitize_text_field($req['displayType'] == 'video' ? 'video' : 'album');
     116
     117      //check for required fields
     118      if (
     119        empty($title)
     120        || empty($albumSorting)
     121        || empty($thumbnailType)
     122        || empty($displayType)
     123      )
     124        return $this->errorResponse(__('Invalid parameters', 'utvg'));
     125
     126      //insert new gallery
     127      $galleryRepository = new GalleryRepository();
     128      $galleryID = $galleryRepository->createItem(
     129        $title,
     130        $albumSorting,
     131        $thumbnailType,
     132        $displayType
     133      );
     134
     135      if ($galleryID)
     136        return $this->response($galleryID, 201);
     137      else
     138        return $this->errorResponse(__('A database error has occurred', 'utvg'));
     139    }
     140    catch (\Exception $e)
     141    {
     142      return $this->errorResponse($e->getMessage());
     143    }
     144
    130145  }
    131146
    132147  public function deleteItem(WP_REST_Request $req)
    133148  {
    134     //check for valid galleryID
    135     if (!$req['galleryID'])
    136       return $this->errorResponse(__('Invalid gallery ID', 'utvg'));
    137 
    138     //sanitize fields
    139     $galleryID = sanitize_key($req['galleryID']);
    140 
    141     //create repositories
    142     $galleryRepository = new GalleryRepository();
    143     $albumRepository = new AlbumRepository();
    144     $videoRepository = new VideoRepository();
    145 
    146     //get videos for thumbnail deletion
    147     $videos = $videoRepository->getItemsByGallery($galleryID);
    148 
    149     //delete gallery, albums, and videos from database
    150     if (
    151       !$videoRepository->deleteItemsByGallery($galleryID)
    152       || !$albumRepository->deleteItemsByGallery($galleryID)
    153       || !$galleryRepository->deleteItem($galleryID)
    154     )
    155       return $this->errorResponse(__('A database error has occured', 'utvg'));
    156 
    157     //delete video thumbnails
    158     $thumbnailPath = wp_upload_dir();
    159     $thumbnailPath = $thumbnailPath['basedir'] . '/utubevideo-cache/';
    160 
    161     foreach ($videos as $video)
    162     {
    163       unlink($thumbnailPath . $video->getThumbnail() . '.jpg');
    164       unlink($thumbnailPath . $video->getThumbnail() . '@2x.jpg');
    165     }
    166 
    167     return $this->response(null);
     149    try
     150    {
     151      //check for valid galleryID
     152      if (!$req['galleryID'])
     153        return $this->errorResponse(__('Invalid gallery ID', 'utvg'));
     154
     155      //sanitize fields
     156      $galleryID = sanitize_key($req['galleryID']);
     157
     158      //create repositories
     159      $galleryRepository = new GalleryRepository();
     160      $albumRepository = new AlbumRepository();
     161      $videoRepository = new VideoRepository();
     162
     163      //get videos for thumbnail deletion
     164      $videos = $videoRepository->getItemsByGallery($galleryID);
     165
     166      //delete gallery, albums, and videos from database
     167      if (
     168        !$videoRepository->deleteItemsByGallery($galleryID)
     169        || !$albumRepository->deleteItemsByGallery($galleryID)
     170        || !$galleryRepository->deleteItem($galleryID)
     171      )
     172        return $this->errorResponse(__('A database error has occured', 'utvg'));
     173
     174      //delete video thumbnails
     175      $thumbnailPath = wp_upload_dir();
     176      $thumbnailPath = $thumbnailPath['basedir'] . '/utubevideo-cache/';
     177
     178      foreach ($videos as $video)
     179      {
     180        unlink($thumbnailPath . $video->getThumbnail() . '.jpg');
     181        unlink($thumbnailPath . $video->getThumbnail() . '@2x.jpg');
     182      }
     183
     184      return $this->response(null);
     185    }
     186    catch (\Exception $e)
     187    {
     188      return $this->errorResponse($e->getMessage());
     189    }
    168190  }
    169191
    170192  public function updateItem(WP_REST_Request $req)
    171193  {
    172     //check for valid galleryID
    173     if (!$req['galleryID'])
    174       return $this->errorResponse(__('Invalid gallery ID', 'utvg'));
    175 
    176     //gather data fields
    177     $galleryID = sanitize_key($req['galleryID']);
    178     $title = sanitize_text_field($req['title']);
    179 
    180     if (isset($req['albumSorting']))
    181       $albumSorting = $req['albumSorting'] == 'desc' ? 'desc' : 'asc';
    182     else
    183       $albumSorting = null;
    184 
    185     $thumbnailType = sanitize_text_field($req['thumbnailType']);
    186     $displayType = sanitize_text_field($req['displayType']);
    187     $currentTime = current_time('timestamp');
    188 
    189     //create updatedFields array
    190     $updatedFields = [];
    191 
    192     //set optional update fields
    193     if ($title != null)
    194       $updatedFields['DATA_NAME'] = $title;
    195 
    196     if ($thumbnailType != null)
    197       $updatedFields['DATA_THUMBTYPE'] = $thumbnailType;
    198 
    199     if ($displayType != null)
    200       $updatedFields['DATA_DISPLAYTYPE'] = $displayType;
    201 
    202     if ($albumSorting != null)
    203       $updatedFields['DATA_SORT'] = $albumSorting;
    204 
    205     //set required update fields
    206     $updatedFields['DATA_UPDATEDATE'] = $currentTime;
    207 
    208     //update gallery
    209     $galleryRepository = new GalleryRepository();
    210 
    211     if ($galleryRepository->updateItem($galleryID, $updatedFields))
    212       return $this->response(null);
    213     else
    214       return $this->errorResponse(__('A database error has occurred', 'utvg'));
     194    try
     195    {
     196      //check for valid galleryID
     197      if (!$req['galleryID'])
     198        return $this->errorResponse(__('Invalid gallery ID', 'utvg'));
     199
     200      //gather data fields
     201      $galleryID = sanitize_key($req['galleryID']);
     202      $title = sanitize_text_field($req['title']);
     203
     204      if (isset($req['albumSorting']))
     205        $albumSorting = $req['albumSorting'] == 'desc' ? 'desc' : 'asc';
     206      else
     207        $albumSorting = null;
     208
     209      $thumbnailType = sanitize_text_field($req['thumbnailType']);
     210      $displayType = sanitize_text_field($req['displayType']);
     211      $currentTime = current_time('timestamp');
     212
     213      //create updatedFields array
     214      $updatedFields = [];
     215
     216      //set optional update fields
     217      if ($title != null)
     218        $updatedFields['DATA_NAME'] = $title;
     219
     220      if ($thumbnailType != null)
     221        $updatedFields['DATA_THUMBTYPE'] = $thumbnailType;
     222
     223      if ($displayType != null)
     224        $updatedFields['DATA_DISPLAYTYPE'] = $displayType;
     225
     226      if ($albumSorting != null)
     227        $updatedFields['DATA_SORT'] = $albumSorting;
     228
     229      //set required update fields
     230      $updatedFields['DATA_UPDATEDATE'] = $currentTime;
     231
     232      //update gallery
     233      $galleryRepository = new GalleryRepository();
     234
     235      if ($galleryRepository->updateItem($galleryID, $updatedFields))
     236        return $this->response(null);
     237      else
     238        return $this->errorResponse(__('A database error has occurred', 'utvg'));
     239    }
     240    catch (\Exception $e)
     241    {
     242      return $this->errorResponse($e->getMessage());
     243    }
    215244  }
    216245
    217246  public function getAllItems(WP_REST_Request $req)
    218247  {
    219     //get galleries
    220     $galleryRepository = new GalleryRepository();
    221     $galleries = $galleryRepository->getItems();
    222 
    223     return $this->response($galleries);
     248    try
     249    {
     250      //get galleries
     251      $galleryRepository = new GalleryRepository();
     252      $galleries = $galleryRepository->getItems();
     253
     254      return $this->response($galleries);
     255    }
     256    catch (\Exception $e)
     257    {
     258      return $this->errorResponse($e->getMessage());
     259    }
    224260  }
    225261}
  • utubevideo-gallery/trunk/class/CodeClouds/UTubeVideoGallery/API/GalleryDataAPIv1.php

    r2003169 r2103033  
    3434  public function getItem(WP_REST_Request $req)
    3535  {
    36     $data = new stdClass();
    37     $thumbnailDirectory = wp_upload_dir();
    38     $thumbnailDirectory = $thumbnailDirectory['baseurl'];
    39     global $wpdb;
     36    try
     37    {
     38      $data = new stdClass();
     39      $thumbnailDirectory = wp_upload_dir();
     40      $thumbnailDirectory = $thumbnailDirectory['baseurl'];
     41      global $wpdb;
    4042
    41     //get gallery data
    42     $gallery = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'utubevideo_dataset WHERE DATA_ID = "' . $req['galleryID'] . '"');
    43     $gallery = $gallery[0];
     43      //get gallery data
     44      $gallery = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'utubevideo_dataset WHERE DATA_ID = "' . $req['galleryID'] . '"');
     45      $gallery = $gallery[0];
    4446
    45     $data->ID = $gallery->DATA_ID;
    46     $data->name = $gallery->DATA_NAME;
    47     $data->displaytype = $gallery->DATA_DISPLAYTYPE;
    48     $data->thumbnailType = $gallery->DATA_THUMBTYPE;
    49     $data->albumsort = $gallery->DATA_SORT;
    50     $data->albums = [];
     47      $data->ID = $gallery->DATA_ID;
     48      $data->name = $gallery->DATA_NAME;
     49      $data->displaytype = $gallery->DATA_DISPLAYTYPE;
     50      $data->thumbnailType = $gallery->DATA_THUMBTYPE;
     51      $data->albumsort = $gallery->DATA_SORT;
     52      $data->albums = [];
    5153
    52     //get video albums
    53     $albums = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'utubevideo_album WHERE ALB_PUBLISH = 1 && DATA_ID = ' . $gallery->DATA_ID);
     54      //get video albums
     55      $albums = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'utubevideo_album WHERE ALB_PUBLISH = 1 && DATA_ID = ' . $gallery->DATA_ID);
    5456
    55     foreach ($albums as $album)
    56     {
    57       $albumData = new stdClass();
    58       $albumData->ID = $album->ALB_ID;
    59       $albumData->title = $album->ALB_NAME;
    60       $albumData->slug = $album->ALB_SLUG;
    61       $albumData->thumbnail = $thumbnailDirectory . '/utubevideo-cache/' . $album->ALB_THUMB . '.jpg';
    62       $albumData->sort = $album->ALB_SORT;
    63       $albumData->position = $album->ALB_POS;
    64       $albumData->videos = [];
     57      foreach ($albums as $album)
     58      {
     59        $albumData = new stdClass();
     60        $albumData->ID = $album->ALB_ID;
     61        $albumData->title = $album->ALB_NAME;
     62        $albumData->slug = $album->ALB_SLUG;
     63        $albumData->thumbnail = $thumbnailDirectory . '/utubevideo-cache/' . $album->ALB_THUMB . '.jpg';
     64        $albumData->sort = $album->ALB_SORT;
     65        $albumData->position = $album->ALB_POS;
     66        $albumData->videos = [];
    6567
    66       //get videos for album
    67       $videos = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'utubevideo_video WHERE ALB_ID = ' . $album->ALB_ID . ' && VID_PUBLISH = 1 ORDER BY VID_POS ' . $album->ALB_SORT);
     68        //get videos for album
     69        $videos = $wpdb->get_results('SELECT * FROM ' . $wpdb->prefix . 'utubevideo_video WHERE ALB_ID = ' . $album->ALB_ID . ' && VID_PUBLISH = 1 ORDER BY VID_POS ' . $album->ALB_SORT);
    6870
    69       foreach ($videos as $video)
    70       {
    71         $videoData = new stdClass();
    72         $videoData->ID = $video->VID_ID;
    73         $videoData->title = $video->VID_NAME;
    74         $videoData->description = $video->VID_DESCRIPTION;
    75         $videoData->slugID = $video->VID_URL;
    76         $videoData->thumbnail = $thumbnailDirectory . '/utubevideo-cache/' . $video->VID_URL . $video->VID_ID . '.jpg';
    77         $videoData->source = $video->VID_SOURCE;
    78         $videoData->quality = $video->VID_QUALITY;
    79         $videoData->chrome = $video->VID_CHROME == 1 ? true : false;
    80         $videoData->startTime = $video->VID_STARTTIME;
    81         $videoData->endTime = $video->VID_ENDTIME;
     71        foreach ($videos as $video)
     72        {
     73          $videoData = new stdClass();
     74          $videoData->ID = $video->VID_ID;
     75          $videoData->title = $video->VID_NAME;
     76          $videoData->description = $video->VID_DESCRIPTION;
     77          $videoData->slugID = $video->VID_URL;
     78          $videoData->thumbnail = $thumbnailDirectory . '/utubevideo-cache/' . $video->VID_URL . $video->VID_ID . '.jpg';
     79          $videoData->source = $video->VID_SOURCE;
     80          $videoData->quality = $video->VID_QUALITY;
     81          $videoData->chrome = $video->VID_CHROME == 1 ? true : false;
     82          $videoData->startTime = $video->VID_STARTTIME;
     83          $videoData->endTime = $video->VID_ENDTIME;
    8284
    83         $albumData->videos[] = $videoData;
     85          $albumData->videos[] = $videoData;
     86        }
     87
     88        $data->albums[] = $albumData;
    8489      }
    8590
    86       $data->albums[] = $albumData;
     91      return $data;
    8792    }
    88 
    89     return $data;
     93    catch (\Exception $e)
     94    {
     95      return $this->errorResponse($e->getMessage());
     96    }
    9097  }
    9198}
  • utubevideo-gallery/trunk/class/CodeClouds/UTubeVideoGallery/API/PlaylistAPIv1.php

    r2003169 r2103033  
    8080  public function getItem(WP_REST_Request $req)
    8181  {
    82     //check for valid playlistID
    83     if (!$req['playlistID'])
    84       return $this->errorResponse(__('Invalid playlist ID', 'utvg'));
    85 
    86     //get playlist
    87     $playlistRepository = new PlaylistRepository();
    88     $playlist = $playlistRepository->getItem($req['playlistID']);
    89 
    90     //check if playlist exists
    91     if (!$playlist)
    92       return $this->errorResponse(__('The specified video resource was not found', 'utvg'));
    93 
    94     return $this->response($playlist);
     82    try
     83    {
     84      //check for valid playlistID
     85      if (!$req['playlistID'])
     86        return $this->errorResponse(__('Invalid playlist ID', 'utvg'));
     87
     88      //get playlist
     89      $playlistRepository = new PlaylistRepository();
     90      $playlist = $playlistRepository->getItem($req['playlistID']);
     91
     92      //check if playlist exists
     93      if (!$playlist)
     94        return $this->errorResponse(__('The specified video resource was not found', 'utvg'));
     95
     96      return $this->response($playlist);
     97    }
     98    catch (\Exception $e)
     99    {
     100      return $this->errorResponse($e->getMessage());
     101    }
    95102  }
    96103
    97104  public function createItem(WP_REST_Request $req)
    98105  {
    99     //create repository
    100     $playlistRepository = new PlaylistRepository();
    101 
    102     //gather data fields
    103     $title = sanitize_text_field($req['title']);
    104     $source = sanitize_text_field($req['source']);
    105     $sourceID = sanitize_text_field($req['sourceID']);
    106     $videoQuality = sanitize_text_field($req['videoQuality']);
    107     $showControls = $req['showControls'] ? 0 : 1;
    108     $albumID = sanitize_key($req['albumID']);
    109 
    110     //check for required fields
    111     if (empty($title)
    112       || empty($source)
    113       || empty($sourceID)
    114       || empty($videoQuality)
    115       || empty($albumID)
    116     )
    117       return $this->errorResponse(__('Invalid parameters', 'utvg'));
    118 
    119     //insert new playlist
    120     $playlistID = $playlistRepository->createItem(
    121       $title,
    122       $source,
    123       $sourceID,
    124       $videoQuality,
    125       $showControls,
    126       $albumID
    127     );
    128 
    129     //if successfull playlist creation..
    130     if ($playlistID)
    131       return $this->response((object)['id' => $playlistID], 201);
    132     else
    133       return $this->errorResponse(__('A database error has occurred', 'utvg'));
     106    try
     107    {
     108      //create repository
     109      $playlistRepository = new PlaylistRepository();
     110
     111      //gather data fields
     112      $title = sanitize_text_field($req['title']);
     113      $source = sanitize_text_field($req['source']);
     114      $sourceID = sanitize_text_field($req['sourceID']);
     115      $videoQuality = sanitize_text_field($req['videoQuality']);
     116      $showControls = $req['showControls'] ? 0 : 1;
     117      $albumID = sanitize_key($req['albumID']);
     118
     119      //check for required fields
     120      if (empty($title)
     121        || empty($source)
     122        || empty($sourceID)
     123        || empty($videoQuality)
     124        || empty($albumID)
     125      )
     126        throw new \Exception(__('Invalid parameters', 'utvg'));
     127
     128      //insert new playlist
     129      $playlistID = $playlistRepository->createItem(
     130        $title,
     131        $source,
     132        $sourceID,
     133        $videoQuality,
     134        $showControls,
     135        $albumID
     136      );
     137
     138      //if successfull playlist creation..
     139      if ($playlistID)
     140        return $this->response((object)['id' => $playlistID], 201);
     141      else
     142        throw new \Exception(__('Database Error: Playlist failed to save', 'utvg'));
     143    }
     144    catch (\Exception $e)
     145    {
     146      return $this->errorResponse($e->getMessage());
     147    }
    134148  }
    135149
    136150  public function deleteItem(WP_REST_Request $req)
    137151  {
    138     //check for valid playlistID
    139     if (!$req['playlistID'])
    140       return $this->errorResponse(__('Invalid playlist ID', 'utvg'));
    141 
    142     //sanitize fields
    143     $playlistID = sanitize_key($req['playlistID']);
    144 
    145     //get playlist
    146     $playlistRepository = new PlaylistRepository();
    147     $playlist = $playlistRepository->getItem($playlistID);
    148 
    149     //check if playlist exists
    150     if (!$playlist)
    151       return $this->errorResponse(__('Playlist does not exist', 'utvg'));
    152 
    153     //get playlist videos
    154     $videoRepository = new VideoRepository();
    155     $playlistVideos = $videoRepository->getItemsByPlaylist($playlistID);
    156 
    157     //delete videos
    158     foreach ($playlistVideos as $video)
    159     {
    160       if (!$videoRepository->deleteItem($video->getID()))
     152    try
     153    {
     154      //check for valid playlistID
     155      if (!$req['playlistID'])
     156        return $this->errorResponse(__('Invalid playlist ID', 'utvg'));
     157
     158      //sanitize fields
     159      $playlistID = sanitize_key($req['playlistID']);
     160
     161      //get playlist
     162      $playlistRepository = new PlaylistRepository();
     163      $playlist = $playlistRepository->getItem($playlistID);
     164
     165      //check if playlist exists
     166      if (!$playlist)
     167        return $this->errorResponse(__('Playlist does not exist', 'utvg'));
     168
     169      //get playlist videos
     170      $videoRepository = new VideoRepository();
     171      $playlistVideos = $videoRepository->getItemsByPlaylist($playlistID);
     172
     173      //delete videos
     174      foreach ($playlistVideos as $video)
     175      {
     176        if (!$videoRepository->deleteItem($video->getID()))
     177          return $this->errorResponse(__('A database error has occurred', 'utvg'));
     178
     179        //delete video thumbnail
     180        $thumbnailPath = wp_upload_dir();
     181        $thumbnailPath = $thumbnailPath['basedir'] . '/utubevideo-cache/';
     182        unlink($thumbnailPath . $video->getThumbnail() . '.jpg');
     183        unlink($thumbnailPath . $video->getThumbnail() . '@2x.jpg');
     184      }
     185
     186      //delete playlist
     187      if (!$playlistRepository->deleteItem($playlistID))
    161188        return $this->errorResponse(__('A database error has occurred', 'utvg'));
    162189
    163       //delete video thumbnail
    164       $thumbnailPath = wp_upload_dir();
    165       $thumbnailPath = $thumbnailPath['basedir'] . '/utubevideo-cache/';
    166       unlink($thumbnailPath . $video->getThumbnail() . '.jpg');
    167       unlink($thumbnailPath . $video->getThumbnail() . '@2x.jpg');
    168     }
    169 
    170     //delete playlist
    171     if (!$playlistRepository->deleteItem($playlistID))
    172       return $this->errorResponse(__('A database error has occurred', 'utvg'));
    173 
    174     return $this->response(null);
     190      return $this->response(null);
     191    }
     192    catch (\Exception $e)
     193    {
     194      return $this->errorResponse($e->getMessage());
     195    }
    175196  }
    176197
    177198  public function updateItem(WP_REST_Request $req)
    178199  {
    179     //check for valid playlistID
    180     if (!$req['playlistID'])
    181       return $this->errorResponse(__('Invalid playlist ID', 'utvg'));
    182 
    183     //gather data fields
    184     $playlistID = sanitize_key($req['playlistID']);
    185     $title = sanitize_text_field($req['title']);
    186     $videoQuality = sanitize_text_field($req['videoQuality']);
    187 
    188     if (isset($req['showControls']))
    189       $showControls = $req['showControls'] ? 0 : 1;
    190     else
    191       $showControls = null;
    192 
    193     $currentTime = current_time('timestamp');
    194 
    195     //create updatedFields array
    196     $updatedFields = [];
    197 
    198     //set optional update fields
    199     if ($title != null)
    200       $updatedFields['PLAY_TITLE'] = $title;
    201 
    202     if ($videoQuality != null)
    203       $updatedFields['PLAY_QUALITY'] = $videoQuality;
    204 
    205     if ($showControls != null)
    206       $updatedFields['PLAY_CHROME'] = $showControls;
    207 
    208     //set required update fields
    209     $updatedFields['PLAY_UPDATEDATE'] = $currentTime;
    210 
    211     $playlistRepository = new PlaylistRepository();
    212 
    213     if ($playlistRepository->updateItem($playlistID, $updatedFields))
    214       return $this->response(null);
    215     else
    216       return $this->errorResponse(__('A database error has occurred', 'utvg'));
     200    try
     201    {
     202      //check for valid playlistID
     203      if (!$req['playlistID'])
     204        return $this->errorResponse(__('Invalid playlist ID', 'utvg'));
     205
     206      //gather data fields
     207      $playlistID = sanitize_key($req['playlistID']);
     208      $title = sanitize_text_field($req['title']);
     209      $videoQuality = sanitize_text_field($req['videoQuality']);
     210
     211      if (isset($req['showControls']))
     212        $showControls = $req['showControls'] ? 0 : 1;
     213      else
     214        $showControls = null;
     215
     216      $currentTime = current_time('timestamp');
     217
     218      //create updatedFields array
     219      $updatedFields = [];
     220
     221      //set optional update fields
     222      if ($title != null)
     223        $updatedFields['PLAY_TITLE'] = $title;
     224
     225      if ($videoQuality != null)
     226        $updatedFields['PLAY_QUALITY'] = $videoQuality;
     227
     228      if ($showControls != null)
     229        $updatedFields['PLAY_CHROME'] = $showControls;
     230
     231      //set required update fields
     232      $updatedFields['PLAY_UPDATEDATE'] = $currentTime;
     233
     234      $playlistRepository = new PlaylistRepository();
     235
     236      if ($playlistRepository->updateItem($playlistID, $updatedFields))
     237        return $this->response(null);
     238      else
     239        return $this->errorResponse(__('A database error has occurred', 'utvg'));
     240    }
     241    catch (\Exception $e)
     242    {
     243      return $this->errorResponse($e->getMessage());
     244    }
    217245  }
    218246
    219247  public function getAllItems(WP_REST_Request $req)
    220248  {
    221     $playlistRepository = new PlaylistRepository();
    222     $playlists = $playlistRepository->getItems();
    223 
    224     return $this->response($playlists);
     249    try
     250    {
     251      $playlistRepository = new PlaylistRepository();
     252      $playlists = $playlistRepository->getItems();
     253
     254      return $this->response($playlists);
     255    }
     256    catch (\Exception $e)
     257    {
     258      return $this->errorResponse($e->getMessage());
     259    }
    225260  }
    226261}
  • utubevideo-gallery/trunk/class/CodeClouds/UTubeVideoGallery/API/SettingsAPIv1.php

    r2003169 r2103033  
    4444  public function getItem(WP_REST_Request $req)
    4545  {
    46     $pluginSettings = get_option('utubevideo_main_opts');
     46    try
     47    {
     48      $pluginSettings = get_option('utubevideo_main_opts');
    4749
    48     $settingData = new stdClass();
    49     $settingData->version = $pluginSettings['version'];
    50     $settingData->popupPlayerWidth = $pluginSettings['playerWidth'];
    51     $settingData->playerControlsTheme = $pluginSettings['playerControlTheme'];
    52     $settingData->playerControlsColor = $pluginSettings['playerProgressColor'];
    53     $settingData->popupPlayerOverlayOpacity = $pluginSettings['fancyboxOverlayOpacity'];
    54     $settingData->popupPlayerOverlayColor = $pluginSettings['fancyboxOverlayColor'];
    55     $settingData->thumbnailWidth = $pluginSettings['thumbnailWidth'];
    56     $settingData->thumbnailVerticalPadding = $pluginSettings['thumbnailVerticalPadding'];
    57     $settingData->thumbnailHorizontalPadding = $pluginSettings['thumbnailPadding'];
    58     $settingData->thumbnailBorderRadius = $pluginSettings['thumbnailBorderRadius'];
    59     $settingData->youtubeAPIKey = $pluginSettings['youtubeApiKey'];
    60     $settingData->youtubeAutoplay = $pluginSettings['youtubeAutoplay'] ? true : false;
    61     $settingData->youtubeHideDetails = $pluginSettings['youtubeDetailsHide'] ? true : false;
    62     $settingData->vimeoAutoplay = $pluginSettings['vimeoAutoplay'] ? true : false;
    63     $settingData->vimeoHideDetails = $pluginSettings['vimeoDetailsHide'] ? true : false;
    64     $settingData->removeVideoPopupScript = $pluginSettings['skipMagnificPopup'] == 'yes' ? true : false;
    65     $settingData->showVideoDescription = $pluginSettings['showVideoDescription'] ? true : false;
     50      $settingData = new stdClass();
     51      $settingData->version = $pluginSettings['version'];
     52      $settingData->popupPlayerWidth = $pluginSettings['playerWidth'];
     53      $settingData->playerControlsTheme = $pluginSettings['playerControlTheme'];
     54      $settingData->playerControlsColor = $pluginSettings['playerProgressColor'];
     55      $settingData->popupPlayerOverlayOpacity = $pluginSettings['fancyboxOverlayOpacity'];
     56      $settingData->popupPlayerOverlayColor = $pluginSettings['fancyboxOverlayColor'];
     57      $settingData->thumbnailWidth = $pluginSettings['thumbnailWidth'];
     58      $settingData->thumbnailVerticalPadding = $pluginSettings['thumbnailVerticalPadding'];
     59      $settingData->thumbnailHorizontalPadding = $pluginSettings['thumbnailPadding'];
     60      $settingData->thumbnailBorderRadius = $pluginSettings['thumbnailBorderRadius'];
     61      $settingData->youtubeAPIKey = $pluginSettings['youtubeApiKey'];
     62      $settingData->youtubeAutoplay = $pluginSettings['youtubeAutoplay'] ? true : false;
     63      $settingData->youtubeHideDetails = $pluginSettings['youtubeDetailsHide'] ? true : false;
     64      $settingData->vimeoAutoplay = $pluginSettings['vimeoAutoplay'] ? true : false;
     65      $settingData->vimeoHideDetails = $pluginSettings['vimeoDetailsHide'] ? true : false;
     66      $settingData->removeVideoPopupScript = $pluginSettings['skipMagnificPopup'] == 'yes' ? true : false;
     67      $settingData->showVideoDescription = $pluginSettings['showVideoDescription'] ? true : false;
    6668
    67     //get php version
    68     preg_match('/^(.*?)-(.*)/', PHP_VERSION, $matches);
    69     $settingData->phpVersion = isset($matches[1]) ? $matches[1] : '';
     69      //get php version
     70      preg_match('/^(.*?)-(.*)/', PHP_VERSION, $matches);
     71      $settingData->phpVersion = isset($matches[1]) ? $matches[1] : '';
    7072
    71     //get WordPress version
    72     $settingData->wpVersion = get_bloginfo('version');
     73      //get WordPress version
     74      $settingData->wpVersion = get_bloginfo('version');
    7375
    74     //get gd status
    75     $settingData->gdEnabled = extension_loaded('gd');
     76      //get gd status
     77      $settingData->gdEnabled = extension_loaded('gd');
    7678
    77     //get imagemagick status
    78     $settingData->imageMagickEnabled = extension_loaded('imagick');
     79      //get imagemagick status
     80      $settingData->imageMagickEnabled = extension_loaded('imagick');
    7981
    80     return $this->response($settingData);
     82      return $this->response($settingData);
     83    }
     84    catch (\Exception $e)
     85    {
     86      return $this->errorResponse($e->getMessage());
     87    }
    8188  }
    8289
    8390  public function updateItem(WP_REST_Request $req)
    8491  {
    85     $pluginSettings = get_option('utubevideo_main_opts');
     92    try
     93    {
     94      $pluginSettings = get_option('utubevideo_main_opts');
    8695
    87     //gather data fields
    88     $playerControlsColor = sanitize_text_field($req['playerControlsColor']);
    89     $playerControlsTheme = sanitize_text_field($req['playerControlsTheme']);
    90     $popupPlayerWidth = sanitize_text_field($req['popupPlayerWidth']);
    91     $popupPlayerOverlayColor = sanitize_text_field($req['popupPlayerOverlayColor']);
    92     $popupPlayerOverlayOpacity = sanitize_text_field($req['popupPlayerOverlayOpacity']);
    93     $thumbnailBorderRadius = sanitize_text_field($req['thumbnailBorderRadius']);
    94     $thumbnailWidth = sanitize_text_field($req['thumbnailWidth']);
    95     $thumbnailHorizontalPadding = sanitize_text_field($req['thumbnailHorizontalPadding']);
    96     $thumbnailVerticalPadding = sanitize_text_field($req['thumbnailVerticalPadding']);
    97     $youtubeAPIKey = sanitize_text_field($req['youtubeAPIKey']);
     96      //gather data fields
     97      $playerControlsColor = sanitize_text_field($req['playerControlsColor']);
     98      $playerControlsTheme = sanitize_text_field($req['playerControlsTheme']);
     99      $popupPlayerWidth = sanitize_text_field($req['popupPlayerWidth']);
     100      $popupPlayerOverlayColor = sanitize_text_field($req['popupPlayerOverlayColor']);
     101      $popupPlayerOverlayOpacity = sanitize_text_field($req['popupPlayerOverlayOpacity']);
     102      $thumbnailBorderRadius = sanitize_text_field($req['thumbnailBorderRadius']);
     103      $thumbnailWidth = sanitize_text_field($req['thumbnailWidth']);
     104      $thumbnailHorizontalPadding = sanitize_text_field($req['thumbnailHorizontalPadding']);
     105      $thumbnailVerticalPadding = sanitize_text_field($req['thumbnailVerticalPadding']);
     106      $youtubeAPIKey = sanitize_text_field($req['youtubeAPIKey']);
    98107
    99     if (isset($req['removeVideoPopupScript']))
    100       $removeVideoPopupScript = $req['removeVideoPopupScript'] ? 'yes' : 'no';
    101     else
    102       $removeVideoPopupScript = null;
     108      if (isset($req['removeVideoPopupScript']))
     109        $removeVideoPopupScript = $req['removeVideoPopupScript'] ? 'yes' : 'no';
     110      else
     111        $removeVideoPopupScript = null;
    103112
    104     if (isset($req['vimeoAutoplay']))
    105       $vimeoAutoplay = $req['vimeoAutoplay'] ? 1 : 0;
    106     else
    107       $vimeoAutoplay = null;
     113      if (isset($req['vimeoAutoplay']))
     114        $vimeoAutoplay = $req['vimeoAutoplay'] ? 1 : 0;
     115      else
     116        $vimeoAutoplay = null;
    108117
    109     if (isset($req['vimeoHideDetails']))
    110       $vimeoHideDetails = $req['vimeoHideDetails'] ? 1 : 0;
    111     else
    112       $vimeoHideDetails = null;
     118      if (isset($req['vimeoHideDetails']))
     119        $vimeoHideDetails = $req['vimeoHideDetails'] ? 1 : 0;
     120      else
     121        $vimeoHideDetails = null;
    113122
    114     if (isset($req['youtubeAutoplay']))
    115       $youtubeAutoplay = $req['youtubeAutoplay'] ? 1 : 0;
    116     else
    117       $youtubeAutoplay = null;
     123      if (isset($req['youtubeAutoplay']))
     124        $youtubeAutoplay = $req['youtubeAutoplay'] ? 1 : 0;
     125      else
     126        $youtubeAutoplay = null;
    118127
    119     if (isset($req['youtubeHideDetails']))
    120       $youtubeHideDetails = $req['youtubeHideDetails'] ? 1 : 0;
    121     else
    122       $youtubeHideDetails = null;
     128      if (isset($req['youtubeHideDetails']))
     129        $youtubeHideDetails = $req['youtubeHideDetails'] ? 1 : 0;
     130      else
     131        $youtubeHideDetails = null;
    123132
    124     if (isset($req['showVideoDescription']))
    125       $showVideoDescription = $req['showVideoDescription'] ? true : false;
    126     else
    127       $showVideoDescription = null;
     133      if (isset($req['showVideoDescription']))
     134        $showVideoDescription = $req['showVideoDescription'] ? true : false;
     135      else
     136        $showVideoDescription = null;
    128137
    129     //set optional update fields
    130     if ($playerControlsColor)
    131       $pluginSettings['playerProgressColor'] = $playerControlsColor;
     138      //set optional update fields
     139      if ($playerControlsColor)
     140        $pluginSettings['playerProgressColor'] = $playerControlsColor;
    132141
    133     if ($playerControlsTheme)
    134       $pluginSettings['playerControlTheme'] = $playerControlsTheme;
     142      if ($playerControlsTheme)
     143        $pluginSettings['playerControlTheme'] = $playerControlsTheme;
    135144
    136     if ($popupPlayerWidth > 0)
    137       $pluginSettings['playerWidth'] = $popupPlayerWidth;
     145      if ($popupPlayerWidth > 0)
     146        $pluginSettings['playerWidth'] = $popupPlayerWidth;
    138147
    139     if ($popupPlayerOverlayColor)
    140       $pluginSettings['fancyboxOverlayColor'] = $popupPlayerOverlayColor;
     148      if ($popupPlayerOverlayColor)
     149        $pluginSettings['fancyboxOverlayColor'] = $popupPlayerOverlayColor;
    141150
    142     if ($popupPlayerOverlayOpacity)
    143       $pluginSettings['fancyboxOverlayOpacity'] = $popupPlayerOverlayOpacity;
     151      if ($popupPlayerOverlayOpacity)
     152        $pluginSettings['fancyboxOverlayOpacity'] = $popupPlayerOverlayOpacity;
    144153
    145     if ($thumbnailBorderRadius !== null)
    146       $pluginSettings['thumbnailBorderRadius'] = $thumbnailBorderRadius;
     154      if ($thumbnailBorderRadius !== null)
     155        $pluginSettings['thumbnailBorderRadius'] = $thumbnailBorderRadius;
    147156
    148     if ($thumbnailWidth > 0)
    149       $pluginSettings['thumbnailWidth'] = $thumbnailWidth;
     157      if ($thumbnailWidth > 0)
     158        $pluginSettings['thumbnailWidth'] = $thumbnailWidth;
    150159
    151     if ($thumbnailHorizontalPadding > 0)
    152       $pluginSettings['thumbnailPadding'] = $thumbnailHorizontalPadding;
     160      if ($thumbnailHorizontalPadding > 0)
     161        $pluginSettings['thumbnailPadding'] = $thumbnailHorizontalPadding;
    153162
    154     if ($thumbnailVerticalPadding > 0)
    155       $pluginSettings['thumbnailVerticalPadding'] = $thumbnailVerticalPadding;
     163      if ($thumbnailVerticalPadding > 0)
     164        $pluginSettings['thumbnailVerticalPadding'] = $thumbnailVerticalPadding;
    156165
    157     if ($youtubeAPIKey !== null)
    158       $pluginSettings['youtubeApiKey'] = $youtubeAPIKey;
     166      if ($youtubeAPIKey !== null)
     167        $pluginSettings['youtubeApiKey'] = $youtubeAPIKey;
    159168
    160     if ($removeVideoPopupScript)
    161       $pluginSettings['skipMagnificPopup'] = $removeVideoPopupScript;
     169      if ($removeVideoPopupScript)
     170        $pluginSettings['skipMagnificPopup'] = $removeVideoPopupScript;
    162171
    163     if ($vimeoAutoplay !== null)
    164       $pluginSettings['vimeoAutoplay'] = $vimeoAutoplay;
     172      if ($vimeoAutoplay !== null)
     173        $pluginSettings['vimeoAutoplay'] = $vimeoAutoplay;
    165174
    166     if ($vimeoHideDetails !== null)
    167       $pluginSettings['vimeoDetailsHide'] = $vimeoHideDetails;
     175      if ($vimeoHideDetails !== null)
     176        $pluginSettings['vimeoDetailsHide'] = $vimeoHideDetails;
    168177
    169     if ($youtubeAutoplay !== null)
    170       $pluginSettings['youtubeAutoplay'] = $youtubeAutoplay;
     178      if ($youtubeAutoplay !== null)
     179        $pluginSettings['youtubeAutoplay'] = $youtubeAutoplay;
    171180
    172     if ($youtubeHideDetails !== null)
    173       $pluginSettings['youtubeDetailsHide'] = $youtubeHideDetails;
     181      if ($youtubeHideDetails !== null)
     182        $pluginSettings['youtubeDetailsHide'] = $youtubeHideDetails;
    174183
    175     if ($showVideoDescription !== null)
    176       $pluginSettings['showVideoDescription'] = $showVideoDescription;
     184      if ($showVideoDescription !== null)
     185        $pluginSettings['showVideoDescription'] = $showVideoDescription;
    177186
    178     update_option('utubevideo_main_opts', $pluginSettings);
     187      update_option('utubevideo_main_opts', $pluginSettings);
    179188
    180     return $this->response(null);
     189      return $this->response(null);
     190    }
     191    catch (\Exception $e)
     192    {
     193      return $this->errorResponse($e->getMessage());
     194    }
    181195  }
    182196}
  • utubevideo-gallery/trunk/class/CodeClouds/UTubeVideoGallery/API/VideoAPIv1.php

    r2003169 r2103033  
    102102  public function getItem(WP_REST_Request $req)
    103103  {
    104     //check for valid videoID
    105     if (!$req['videoID'])
    106       return $this->errorResponse(__('Invalid video ID', 'utvg'));
    107 
    108     //sanitize data
    109     $videoID = sanitize_key($req['videoID']);
    110 
    111     //get video
    112     $videoRepository = new VideoRepository();
    113     $video = $videoRepository->getItem($videoID);
    114 
    115     //check if video exists
    116     if (!$video)
    117       return $this->errorResponse(__('The specified video resource was not found', 'utvg'));
    118 
    119     return $this->response($video);
     104    try
     105    {
     106      //check for valid videoID
     107      if ($req['videoID'] === false)
     108        throw new \Exception(__('Invalid video ID', 'utvg'));
     109
     110      //sanitize data
     111      $videoID = sanitize_key($req['videoID']);
     112
     113      //get video
     114      $videoRepository = new VideoRepository();
     115      $video = $videoRepository->getItem($videoID);
     116
     117      //check if video exists
     118      if (!$video)
     119        throw new \Exception(__('Database Error: The video does not exist', 'utvg'));
     120
     121      return $this->response($video);
     122    }
     123    catch (\Exception $e)
     124    {
     125      return $this->errorResponse($e->getMessage());
     126    }
    120127  }
    121128
     
    123130  public function createItem(WP_REST_Request $req)
    124131  {
    125     //create repository
    126     $videoRepository = new VideoRepository();
    127 
    128     //gather data fields
    129     $sourceID = sanitize_text_field($req['sourceID']);
    130     $title = sanitize_text_field($req['title']);
    131     $description = sanitize_text_field($req['description']);
    132     $quality = sanitize_text_field($req['quality']);
    133     $showControls = ($req['controls'] ? 1 : 0);
    134     $startTime = sanitize_text_field($req['startTime']);
    135     $endTime = sanitize_text_field($req['endTime']);
    136     $source = sanitize_text_field($req['source']);
    137     $albumID = sanitize_key($req['albumID']);
    138     $playlistID = sanitize_key($req['playlistID']);
    139 
    140     //check for required fields
    141     if (
    142       empty($sourceID)
    143       || empty($quality)
    144       || !isset($showControls)
    145       || empty($source)
    146       || !isset($albumID)
    147     )
    148       return $this->errorResponse(__('Invalid parameters', 'utvg'));
    149 
    150     //get next video sort position
    151     $nextSortPosition = $videoRepository->getNextSortPositionByAlbum($albumID);
    152 
    153     //check if value exists
    154     if ($nextSortPosition === false)
    155       return $this->errorResponse(__('A database error has occured', 'utvg'));
    156 
    157     //get video thumbnail type
    158     $thumbnailType = $videoRepository->getThumbnailTypeByAlbum($albumID);
    159 
    160     if (!$thumbnailType)
    161       return $this->errorResponse(__('A database error has occured', 'utvg'));
    162 
    163     //insert new video
    164     $videoID = $videoRepository->createItem(
    165       $source,
    166       $title,
    167       $description,
    168       $sourceID,
    169       $thumbnailType,
    170       $quality,
    171       $showControls,
    172       $startTime,
    173       $endTime,
    174       $nextSortPosition,
    175       $albumID,
    176       $playlistID
    177     );
    178 
    179     //if successfull video creation..
    180     if ($videoID)
    181     {
    182       $thumbnail = new Thumbnail($videoID);
    183 
    184       if (!$thumbnail->save())
     132    try
     133    {
     134      //create repository
     135      $videoRepository = new VideoRepository();
     136
     137      //gather data fields
     138      $sourceID = sanitize_text_field($req['sourceID']);
     139      $title = sanitize_text_field($req['title']);
     140      $description = sanitize_text_field($req['description']);
     141      $quality = sanitize_text_field($req['quality']);
     142      $showControls = ($req['controls'] ? 1 : 0);
     143      $startTime = sanitize_text_field($req['startTime']);
     144      $endTime = sanitize_text_field($req['endTime']);
     145      $source = sanitize_text_field($req['source']);
     146      $albumID = sanitize_key($req['albumID']);
     147      $playlistID = sanitize_key($req['playlistID']);
     148
     149      //check for required fields
     150      if (
     151        empty($sourceID)
     152        || empty($quality)
     153        || !isset($showControls)
     154        || empty($source)
     155        || !isset($albumID)
     156      )
     157        throw new \Exception(__('Invalid parameters', 'utvg'));
     158
     159      //get next video sort position
     160      $nextSortPosition = $videoRepository->getNextSortPositionByAlbum($albumID);
     161
     162      //get video thumbnail type
     163      $thumbnailType = $videoRepository->getThumbnailTypeByAlbum($albumID);
     164
     165      //insert new video
     166      $videoID = $videoRepository->createItem(
     167        $source,
     168        $title,
     169        $description,
     170        $sourceID,
     171        $thumbnailType,
     172        $quality,
     173        $showControls,
     174        $startTime,
     175        $endTime,
     176        $nextSortPosition,
     177        $albumID,
     178        $playlistID
     179      );
     180
     181      //if successfull video creation..
     182      if ($videoID)
    185183      {
    186         //delete video on failure
    187         if (!$videoRepository->deleteItem($videoID))
    188           return $this->errorResponse(__('A database error has occurred', 'utvg'));
    189 
    190         //return error message
    191         return $this->errorResponse(__('Video thumbnail failed to save', 'utvg'));
     184        $thumbnail = new Thumbnail($videoID);
     185        $thumbnail->save();
     186        return $this->response(null, 201);
    192187      }
    193 
    194       return $this->response(null, 201);
    195     }
    196     else
    197       return $this->errorResponse(__('A database error has occurred', 'utvg'));
     188      else
     189        throw new \Exception(__('Database Error: Video creation failed', 'utvg'));
     190    }
     191    catch (\Exception $e)
     192    {
     193      //delete video from db due to error if needed
     194      if (isset($videoID) && $videoID !== false)
     195        $videoRepository->deleteItem($videoID);
     196
     197      return $this->errorResponse($e->getMessage());
     198    }
    198199  }
    199200
     
    201202  public function deleteItem(WP_REST_Request $req)
    202203  {
    203     //check for valid videoID
    204     if (!$req['videoID'])
    205       return $this->errorResponse(__('Invalid video ID', 'utvg'));
    206 
    207     //sanitize data
    208     $videoID = sanitize_key($req['videoID']);
    209 
    210     //get video
    211     $videoRepository = new VideoRepository();
    212     $video = $videoRepository->getItem($videoID);
    213 
    214     //check if video exists
    215     if (!$video)
    216       return $this->errorResponse(__('Video does not exist', 'utvg'));
    217 
    218     //delete video
    219     if (!$videoRepository->deleteItem($videoID))
    220       return $this->errorResponse(__('A database error has occurred', 'utvg'));
    221 
    222     //delete video thumbnail
    223     $thumbnailPath = wp_upload_dir();
    224     $thumbnailPath = $thumbnailPath['basedir'] . '/utubevideo-cache/';
    225     unlink($thumbnailPath . $video->getThumbnail() . '.jpg');
    226     unlink($thumbnailPath . $video->getThumbnail() . '@2x.jpg');
    227 
    228     return $this->response(null);
     204    try
     205    {
     206      //check for valid videoID
     207      if (!$req['videoID'])
     208        throw new \Exception(__('Invalid video ID', 'utvg'));
     209
     210      //sanitize data
     211      $videoID = sanitize_key($req['videoID']);
     212
     213      //get video
     214      $videoRepository = new VideoRepository();
     215      $video = $videoRepository->getItem($videoID);
     216
     217      //check if video exists
     218      if (!$video)
     219        throw new \Exception(__('Database Error: Video does not exist', 'utvg'));
     220
     221      //delete video
     222      if (!$videoRepository->deleteItem($videoID))
     223        throw new \Exception(__('Database Error: Failed to delete video', 'utvg'));
     224
     225      //delete video thumbnail
     226      $thumbnailPath = wp_upload_dir();
     227      $thumbnailPath = $thumbnailPath['basedir'] . '/utubevideo-cache/';
     228      unlink($thumbnailPath . $video->getThumbnail() . '.jpg');
     229      unlink($thumbnailPath . $video->getThumbnail() . '@2x.jpg');
     230
     231      return $this->response(null);
     232    }
     233    catch (\Exception $e)
     234    {
     235      return $this->errorResponse($e->getMessage());
     236    }
    229237  }
    230238
     
    232240  public function updateItem(WP_REST_Request $req)
    233241  {
    234     //check for valid videoID
    235     if (!$req['videoID'])
    236       return $this->errorResponse(__('Invalid video ID', 'utvg'));
    237 
    238     //gather data fields
    239     $videoID = sanitize_key($req['videoID']);
    240     $title = sanitize_text_field($req['title']);
    241     $description = sanitize_text_field($req['description']);
    242     $quality = sanitize_text_field($req['quality']);
    243     $startTime = sanitize_text_field($req['startTime']);
    244     $endTime = sanitize_text_field($req['endTime']);
    245 
    246     if (isset($req['controls']))
    247       $controls = $req['controls'] ? 1 : 0;
    248     else
    249       $controls = null;
    250 
    251     if (isset($req['published']))
    252       $published = $req['published'] ? 1 : 0;
    253     else
    254       $published = null;
    255 
    256     $albumID = sanitize_key($req['albumID']);
    257     $currentTime = current_time('timestamp');
    258     $skipThumbnailRender = $req['skipThumbnailRender'] ? true : false;
    259 
    260     //create updatedFields array
    261     $updatedFields = [];
    262 
    263     //set optional update fields
    264     if ($title != null)
    265       $updatedFields['VID_NAME'] = $title;
    266 
    267     if ($description != null)
    268       $updatedFields['VID_DESCRIPTION'] = $description;
    269 
    270     if ($quality != null)
    271       $updatedFields['VID_QUALITY'] = $quality;
    272 
    273     if ($controls !== null)
    274       $updatedFields['VID_CHROME'] = $controls;
    275 
    276     if ($startTime != null)
    277       $updatedFields['VID_STARTTIME'] = $startTime;
    278 
    279     if ($endTime != null)
    280       $updatedFields['VID_ENDTIME'] = $endTime;
    281 
    282     if ($published !== null)
    283       $updatedFields['VID_PUBLISH'] = $published;
    284 
    285     if ($albumID != null)
    286       $updatedFields['ALB_ID'] = $albumID;
    287 
    288     //set required update fields
    289     $updatedFields['VID_UPDATEDATE'] = $currentTime;
    290     $updatedFields['VID_THUMBTYPE'] = 'default';
    291 
    292     //update video
    293     $videoRepository = new VideoRepository();
    294 
    295     if ($videoRepository->updateItem($videoID, $updatedFields))
    296     {
    297       if (!$skipThumbnailRender)
     242    try
     243    {
     244      //check for valid videoID
     245      if (!$req['videoID'])
     246        throw new \Exception(__('Invalid video ID', 'utvg'));
     247
     248      //gather data fields
     249      $videoID = sanitize_key($req['videoID']);
     250      $title = sanitize_text_field($req['title']);
     251      $description = sanitize_text_field($req['description']);
     252      $quality = sanitize_text_field($req['quality']);
     253      $startTime = sanitize_text_field($req['startTime']);
     254      $endTime = sanitize_text_field($req['endTime']);
     255
     256      if (isset($req['controls']))
     257        $controls = $req['controls'] ? 1 : 0;
     258      else
     259        $controls = null;
     260
     261      if (isset($req['published']))
     262        $published = $req['published'] ? 1 : 0;
     263      else
     264        $published = null;
     265
     266      $albumID = sanitize_key($req['albumID']);
     267      $currentTime = current_time('timestamp');
     268      $skipThumbnailRender = $req['skipThumbnailRender'] ? true : false;
     269
     270      //create updatedFields array
     271      $updatedFields = [];
     272
     273      //set optional update fields
     274      if ($title != null)
     275        $updatedFields['VID_NAME'] = $title;
     276
     277      if ($description != null)
     278        $updatedFields['VID_DESCRIPTION'] = $description;
     279
     280      if ($quality != null)
     281        $updatedFields['VID_QUALITY'] = $quality;
     282
     283      if ($controls !== null)
     284        $updatedFields['VID_CHROME'] = $controls;
     285
     286      if ($startTime != null)
     287        $updatedFields['VID_STARTTIME'] = $startTime;
     288
     289      if ($endTime != null)
     290        $updatedFields['VID_ENDTIME'] = $endTime;
     291
     292      if ($published !== null)
     293        $updatedFields['VID_PUBLISH'] = $published;
     294
     295      if ($albumID != null)
     296        $updatedFields['ALB_ID'] = $albumID;
     297
     298      //set required update fields
     299      $updatedFields['VID_UPDATEDATE'] = $currentTime;
     300      $updatedFields['VID_THUMBTYPE'] = 'default';
     301
     302      //update video
     303      $videoRepository = new VideoRepository();
     304
     305      if ($videoRepository->updateItem($videoID, $updatedFields))
    298306      {
    299         //resave thumbnail
    300         $thumbnail = new Thumbnail($videoID);
    301 
    302         if (!$thumbnail->save())
    303           return $this->errorResponse(__('Video thumbnail refresh failed', 'utvg'));
     307        if (!$skipThumbnailRender)
     308        {
     309          //refresh video thumbnail
     310          $thumbnail = new Thumbnail($videoID);
     311          $thumbnail->save();
     312        }
     313
     314        return $this->response(null);
    304315      }
    305 
    306       return $this->response(null);
    307     }
    308     else
    309       return $this->errorResponse(__('A database error has occurred', 'utvg'));
     316      else
     317        throw new \Exception(__('Database Error: Failed to update video', 'utvg'));
     318    }
     319    catch (\Exception $e)
     320    {
     321      return $this->errorResponse($e->getMessage());
     322    }
    310323  }
    311324
     
    313326  public function getAllItems(WP_REST_Request $req)
    314327  {
    315     //check for valid videoID
    316     if (!$req['albumID'])
    317       return $this->errorResponse(__('Invalid album ID', 'utvg'));
    318 
    319     //sanitize data
    320     $albumID = sanitize_key($req['albumID']);
    321 
    322     //get videos
    323     $videoRepository = new VideoRepository();
    324     $videos = $videoRepository->getItemsByAlbum($albumID);
    325 
    326     return $this->response($videos);
     328    try
     329    {
     330      //check for valid videoID
     331      if ($req['albumID'] === false)
     332        throw new \Exception(__('Invalid album ID', 'utvg'));
     333
     334      //sanitize data
     335      $albumID = sanitize_key($req['albumID']);
     336
     337      //get videos
     338      $videoRepository = new VideoRepository();
     339      $videos = $videoRepository->getItemsByAlbum($albumID);
     340
     341      return $this->response($videos);
     342    }
     343    catch (\Exception $e)
     344    {
     345      return $this->errorResponse($e->getMessage());
     346    }
    327347  }
    328348
     
    330350  public function getAnyAllItems(WP_REST_Request $req)
    331351  {
    332     //get videos
    333     $videoRepository = new VideoRepository();
    334     $videos = $videoRepository->getItems();
    335 
    336     return $this->response($videos);
     352    try
     353    {
     354      //get videos
     355      $videoRepository = new VideoRepository();
     356      $videos = $videoRepository->getItems();
     357
     358      return $this->response($videos);
     359    }
     360    catch (\Exception $e)
     361    {
     362      return $this->errorResponse($e->getMessage());
     363    }
    337364  }
    338365}
  • utubevideo-gallery/trunk/class/CodeClouds/UTubeVideoGallery/API/VideoOrderAPIv1.php

    r2003169 r2103033  
    3333  public function updateItem(WP_REST_Request $req)
    3434  {
    35     global $wpdb;
     35    try
     36    {
     37      global $wpdb;
    3638
    37     if (!$req['videoids'])
    38       return $this->errorResponse(__('Invalid data', 'utvg'));
     39      if (!$req['videoids'])
     40        return $this->errorResponse(__('Invalid data', 'utvg'));
    3941
    40     $videoCount = count($req['videoids']);
     42      $videoCount = count($req['videoids']);
    4143
    42     for ($i = 0; $i < $videoCount; $i++)
     44      for ($i = 0; $i < $videoCount; $i++)
     45      {
     46        $videoID = sanitize_key($req['videoids'][$i]);
     47
     48        if (!$videoID)
     49          return $this->errorResponse(__('Invalid data value', 'utvg'));
     50
     51        $wpdb->update(
     52          $wpdb->prefix . 'utubevideo_video',
     53          ['VID_POS' => $i],
     54          ['VID_ID' => $videoID]
     55        );
     56      }
     57
     58      return $this->response(null);
     59    }
     60    catch (\Exception $e)
    4361    {
    44       $videoID = sanitize_key($req['videoids'][$i]);
    45 
    46       if (!$videoID)
    47         return $this->errorResponse(__('Invalid data value', 'utvg'));
    48 
    49       $wpdb->update(
    50         $wpdb->prefix . 'utubevideo_video',
    51         ['VID_POS' => $i],
    52         ['VID_ID' => $videoID]
    53       );
    54     }
    55 
    56     return $this->response(null);
     62      return $this->errorResponse($e->getMessage());
     63    } 
    5764  }
    5865}
  • utubevideo-gallery/trunk/class/CodeClouds/UTubeVideoGallery/API/VimeoPlaylistAPIv1.php

    r2003169 r2103033  
    4444  public function getAllItems(WP_REST_Request $req)
    4545  {
    46     //initialize return object
    47     $returnData = new stdClass();
    48     $returnData->title = '';
    49     $returnData->videos = [];
     46    try
     47    {
     48      //initialize return object
     49      $returnData = new stdClass();
     50      $returnData->title = '';
     51      $returnData->videos = [];
    5052
    51     //check for valid sourceID
    52     if (!$req['sourceID'])
    53       return $this->errorResponse(__('Invalid source ID', 'utvg'));
     53      //check for valid sourceID
     54      if (!$req['sourceID'])
     55        return $this->errorResponse(__('Invalid source ID', 'utvg'));
    5456
    55     //gather data fields
    56     $sourceID = sanitize_text_field($req['sourceID']);
     57      //gather data fields
     58      $sourceID = sanitize_text_field($req['sourceID']);
    5759
    58     //retrieve playlist base data
    59     $data = Utility::queryAPI(
    60       'https://vimeo.com/api/v2/album/'
    61       . $sourceID
    62       . '/info.json'
    63     );
    64 
    65     //check data fetch
    66     if (!$data)
    67       return $this->errorResponse(__('Vimeo API call failed', 'utvg'));
    68 
    69     //retrieve playlist title
    70     if (isset($data->title))
    71       $returnData->title = $data->title;
    72 
    73     //retreive playlist total videos
    74     if ($data->total_videos >= 60)
    75       $pages = 3;
    76     else
    77       $pages = ceil($data->total_videos / 20);
    78 
    79     //get base videos data
    80     $baseVideoData = [];
    81 
    82     for ($i = 1; $i <= $pages; $i++)
    83     {
    84       $videoData = Utility::queryAPI(
     60      //retrieve playlist base data
     61      $data = Utility::queryAPI(
    8562        'https://vimeo.com/api/v2/album/'
    8663        . $sourceID
    87         . '/videos.json?page='
    88         . $i
     64        . '/info.json'
    8965      );
    9066
    91       if (!$videoData)
     67      //check data fetch
     68      if (!$data)
    9269        return $this->errorResponse(__('Vimeo API call failed', 'utvg'));
    9370
    94       $baseVideoData = array_merge($baseVideoData, $videoData);
     71      //retrieve playlist title
     72      if (isset($data->title))
     73        $returnData->title = $data->title;
     74
     75      //retreive playlist total videos
     76      if ($data->total_videos >= 60)
     77        $pages = 3;
     78      else
     79        $pages = ceil($data->total_videos / 20);
     80
     81      //get base videos data
     82      $baseVideoData = [];
     83
     84      for ($i = 1; $i <= $pages; $i++)
     85      {
     86        $videoData = Utility::queryAPI(
     87          'https://vimeo.com/api/v2/album/'
     88          . $sourceID
     89          . '/videos.json?page='
     90          . $i
     91        );
     92
     93        if (!$videoData)
     94          return $this->errorResponse(__('Vimeo API call failed', 'utvg'));
     95
     96        $baseVideoData = array_merge($baseVideoData, $videoData);
     97      }
     98
     99      //filter videos and add them to return data
     100      foreach ($baseVideoData as $video)
     101      {
     102        $duration = gmdate('H:i:s', $video->duration);
     103
     104        //map video
     105        $videoData = new stdClass();
     106        $videoData->sourceID = $video->id;
     107        $videoData->title = $video->title;
     108        $videoData->description = '';
     109        $videoData->thumbnail = $video->thumbnail_large;
     110        $videoData->duration = $duration;
     111
     112        $returnData->videos[] = $videoData;
     113      }
     114
     115      return $this->response($returnData);
    95116    }
    96 
    97     //filter videos and add them to return data
    98     foreach ($baseVideoData as $video)
     117    catch (\Exception $e)
    99118    {
    100       $duration = gmdate('H:i:s', $video->duration);
    101 
    102       //map video
    103       $videoData = new stdClass();
    104       $videoData->sourceID = $video->id;
    105       $videoData->title = $video->title;
    106       $videoData->description = '';
    107       $videoData->thumbnail = $video->thumbnail_large;
    108       $videoData->duration = $duration;
    109 
    110       $returnData->videos[] = $videoData;
     119      return $this->errorResponse($e->getMessage());
    111120    }
    112 
    113     return $this->response($returnData);
    114121  }
    115122}
  • utubevideo-gallery/trunk/class/CodeClouds/UTubeVideoGallery/API/YouTubePlaylistAPIv1.php

    r2003169 r2103033  
    4343  public function getAllItems(WP_REST_Request $req)
    4444  {
    45     //initialize return object
    46     $returnData = new stdClass();
    47     $returnData->title = '';
    48     $returnData->videos = [];
     45    try
     46    {
     47      //initialize return object
     48      $returnData = new stdClass();
     49      $returnData->title = '';
     50      $returnData->videos = [];
    4951
    50     //check for a possibly valid api key before continuing
    51     if (Utility::isNullOrEmpty($this->_options['youtubeApiKey']))
    52       return $this->errorResponse(__('YouTube API key is missing', 'utvg'));
     52      //check for a possibly valid api key before continuing
     53      if (Utility::isNullOrEmpty($this->_options['youtubeApiKey']))
     54        return $this->errorResponse(__('YouTube API key is missing', 'utvg'));
    5355
    54     //check for valid sourceID
    55     if (!$req['sourceID'])
    56       return $this->errorResponse(__('Invalid source ID', 'utvg'));
     56      //check for valid sourceID
     57      if (!$req['sourceID'])
     58        return $this->errorResponse(__('Invalid source ID', 'utvg'));
    5759
    58     //gather data fields
    59     $sourceID = sanitize_text_field($req['sourceID']);
     60      //gather data fields
     61      $sourceID = sanitize_text_field($req['sourceID']);
    6062
    61     //retrieve playlist title
    62     $data = Utility::queryAPI(
    63       'https://www.googleapis.com/youtube/v3/playlists?key='
    64       . $this->_options['youtubeApiKey']
    65       . '&part=snippet&id='
    66       . $sourceID
    67     );
    68 
    69     if ($data)
    70     {
    71       if (isset($data->items[0]->snippet->title))
    72         $returnData->title = $data->items[0]->snippet->title;
    73     }
    74 
    75     //get base video data
    76     $nextPageToken = true;
    77     $baseVideosData = [];
    78 
    79     while ($nextPageToken)
    80     {
     63      //retrieve playlist title
    8164      $data = Utility::queryAPI(
    82         'https://www.googleapis.com/youtube/v3/playlistItems?key='
     65        'https://www.googleapis.com/youtube/v3/playlists?key='
    8366        . $this->_options['youtubeApiKey']
    84         . '&part=snippet,contentDetails,status&maxResults=50&playlistId='
     67        . '&part=snippet&id='
    8568        . $sourceID
    86         . (strlen($nextPageToken) > 1 ? '&pageToken=' . $nextPageToken : '')
    8769      );
    8870
    8971      if ($data)
    9072      {
    91         if (isset($data->items))
    92           $baseVideosData = array_merge($baseVideosData, $data->items);
     73        if (isset($data->items[0]->snippet->title))
     74          $returnData->title = $data->items[0]->snippet->title;
     75      }
    9376
    94         if (isset($data->nextPageToken))
    95           $nextPageToken = $data->nextPageToken;
    96         else
    97           $nextPageToken = false;
     77      //get base video data
     78      $nextPageToken = true;
     79      $baseVideosData = [];
     80
     81      while ($nextPageToken)
     82      {
     83        $data = Utility::queryAPI(
     84          'https://www.googleapis.com/youtube/v3/playlistItems?key='
     85          . $this->_options['youtubeApiKey']
     86          . '&part=snippet,contentDetails,status&maxResults=50&playlistId='
     87          . $sourceID
     88          . (strlen($nextPageToken) > 1 ? '&pageToken=' . $nextPageToken : '')
     89        );
     90
     91        if ($data)
     92        {
     93          if (isset($data->items))
     94            $baseVideosData = array_merge($baseVideosData, $data->items);
     95
     96          if (isset($data->nextPageToken))
     97            $nextPageToken = $data->nextPageToken;
     98          else
     99            $nextPageToken = false;
     100        }
    98101      }
     102
     103      //create search id string to query video details for filtering info
     104      $videoIDsList = [];
     105      $videoIDSetList = [];
     106
     107      foreach ($baseVideosData as $video)
     108      {
     109        if (isset($video->snippet->resourceId->videoId))
     110          $videoIDsList[] = $video->snippet->resourceId->videoId;
     111
     112        if (count($videoIDsList) == 50)
     113        {
     114          $videoIDSetList[] = $videoIDsList;
     115          $videoIDsList = [];
     116        }
     117      }
     118
     119      if (count($videoIDsList) > 0)
     120        $videoIDSetList[] = $videoIDsList;
     121
     122      $finalVideoData = [];
     123
     124      //get final video data to filter with
     125      foreach ($videoIDSetList as $list)
     126      {
     127        $data = Utility::queryAPI(
     128          'https://www.googleapis.com/youtube/v3/videos?key='
     129          . $this->_options['youtubeApiKey']
     130          . '&part=contentDetails,snippet,status&id='
     131          . implode(',', $list)
     132        );
     133
     134        if ($data && isset($data->items))
     135          $finalVideoData = array_merge($finalVideoData, $data->items);
     136      }
     137
     138      //filter videos and add them to return data
     139      foreach ($finalVideoData as $video)
     140      {
     141        if (
     142          !Utility::hasValue($video->status->uploadStatus, 'rejected')
     143          && Utility::hasValue($video->status->embeddable, true)
     144          && Utility::hasValue($video->status->privacyStatus, 'public')
     145        )
     146        {
     147          //convert duration
     148          $duration = new DateTime('@0');
     149          $duration->add(new DateInterval($video->contentDetails->duration));
     150          $duration = $duration->format('H:i:s');
     151
     152          //get best thumbnail
     153          $thumbnailSources = $video->snippet->thumbnails;
     154          end($thumbnailSources);
     155          $thumbnailKey = key($thumbnailSources);
     156          $thumbnailURL = $thumbnailSources->{$thumbnailKey}->url;
     157
     158          //map video
     159          $videoData = new stdClass();
     160          $videoData->sourceID = $video->id;
     161          $videoData->title = $video->snippet->title;
     162          $videoData->description = $video->snippet->description;
     163          $videoData->thumbnail = $thumbnailURL;
     164          $videoData->duration = $duration;
     165
     166          $returnData->videos[] = $videoData;
     167        }
     168      }
     169
     170      return $this->response($returnData);
    99171    }
    100 
    101     //create search id string to query video details for filtering info
    102     $videoIDsList = [];
    103     $videoIDSetList = [];
    104 
    105     foreach ($baseVideosData as $video)
     172    catch (\Exception $e)
    106173    {
    107       if (isset($video->snippet->resourceId->videoId))
    108         $videoIDsList[] = $video->snippet->resourceId->videoId;
    109 
    110       if (count($videoIDsList) == 50)
    111       {
    112         $videoIDSetList[] = $videoIDsList;
    113         $videoIDsList = [];
    114       }
     174      return $this->errorResponse($e->getMessage());
    115175    }
    116 
    117     if (count($videoIDsList) > 0)
    118       $videoIDSetList[] = $videoIDsList;
    119 
    120     $finalVideoData = [];
    121 
    122     //get final video data to filter with
    123     foreach ($videoIDSetList as $list)
    124     {
    125       $data = Utility::queryAPI(
    126         'https://www.googleapis.com/youtube/v3/videos?key='
    127         . $this->_options['youtubeApiKey']
    128         . '&part=contentDetails,snippet,status&id='
    129         . implode(',', $list)
    130       );
    131 
    132       if ($data && isset($data->items))
    133         $finalVideoData = array_merge($finalVideoData, $data->items);
    134     }
    135 
    136     //filter videos and add them to return data
    137     foreach ($finalVideoData as $video)
    138     {
    139       if (
    140         !Utility::hasValue($video->status->uploadStatus, 'rejected')
    141         && Utility::hasValue($video->status->embeddable, true)
    142         && Utility::hasValue($video->status->privacyStatus, 'public')
    143       )
    144       {
    145         //convert duration
    146         $duration = new DateTime('@0');
    147         $duration->add(new DateInterval($video->contentDetails->duration));
    148         $duration = $duration->format('H:i:s');
    149 
    150         //get best thumbnail
    151         $thumbnailSources = $video->snippet->thumbnails;
    152         end($thumbnailSources);
    153         $thumbnailKey = key($thumbnailSources);
    154         $thumbnailURL = $thumbnailSources->{$thumbnailKey}->url;
    155 
    156         //map video
    157         $videoData = new stdClass();
    158         $videoData->sourceID = $video->id;
    159         $videoData->title = $video->snippet->title;
    160         $videoData->description = $video->snippet->description;
    161         $videoData->thumbnail = $thumbnailURL;
    162         $videoData->duration = $duration;
    163 
    164         $returnData->videos[] = $videoData;
    165       }
    166     }
    167 
    168     return $this->response($returnData);
    169176  }
    170177}
  • utubevideo-gallery/trunk/class/CodeClouds/UTubeVideoGallery/Repository/VideoRepository.php

    r2003169 r2103033  
    204204
    205205    //check for valid albumID
    206     if (!$albumID)
    207       return false;
     206    if ($albumID === false)
     207      throw new \Exception(__('Database Error: Invalid album ID', 'utvg'));
    208208
    209209    $query = $wpdb->prepare(
     
    217217    $nextSortPosition = $wpdb->get_var($query);
    218218
    219     if (!$nextSortPosition)
     219    if ($nextSortPosition === false)
    220220      $nextSortPosition = 0;
    221221
     
    223223  }
    224224
    225   public function getThumbnailTypeByAlbum($albumID)
     225  public function getThumbnailTypeByAlbum($albumID = false)
    226226  {
    227227    global $wpdb;
    228228
    229229    //check for valid albumID
    230     if (!$albumID)
    231       return false;
     230    if ($albumID === false)
     231      throw new \Exception(__('Database Error: Invalid album ID', 'utvg'));
    232232
    233233    $query = $wpdb->prepare(
     
    241241    $thumbnailType = $wpdb->get_var($query);
    242242
    243     if ($thumbnailType)
    244       return $thumbnailType;
    245 
    246     return false;
    247   }
    248 
    249   public function deleteItemsByAlbum($albumID)
     243    if (!$thumbnailType)
     244      $thumbnailType = 'rectangle';
     245
     246    return $thumbnailType;
     247  }
     248
     249  public function deleteItemsByAlbum($albumID = false)
    250250  {
    251251    global $wpdb;
     
    255255      $wpdb->prefix . 'utubevideo_video',
    256256      ['ALB_ID' => $albumID]
    257     ) != false)
     257    ) !== false)
    258258      return true;
    259259
  • utubevideo-gallery/trunk/class/CodeClouds/UTubeVideoGallery/Service/Thumbnail.php

    r2003169 r2103033  
    2929  {
    3030    if (!$this->_videoID)
    31       return false;
     31      throw new \Exception(__('Thumbnail Error: Invalid Video ID', 'utvg'));
    3232
    3333    $this->setThumbnailData();
    3434    $this->setSourceURL();
    35 
    36     if (!$this->saveThumbnail())
    37       return false;
    38 
    39     return true;
     35    $this->saveThumbnail();
    4036  }
    4137
     
    5147
    5248      if (is_wp_error($image))
    53         return false;//image magick or gd is required or bad api key
     49        throw new \Exception(__('Imagick or GD may be missing or bad YouTube API Key', 'utvg'));
    5450    }
    5551
     
    8884      $image->save($this->_destinationPath . $baseFilename . '.jpg');
    8985    }
    90 
    91     return true;
    9286  }
    9387
     
    106100
    107101    if (!$thumbnailData)
    108       return false;
     102      throw new \Exception(__('Database Error: Can\'t determine video information', 'utvg'));
    109103
    110104    $thumbnailData = $thumbnailData[0];
     
    121115    elseif ($this->_videoSource == 'vimeo')
    122116      $this->_sourceURL = $this->getVimeoSource();
     117    else
     118      throw new \Exception(__('Thumbnail Error: Invalid source type', 'utvg'));
    123119  }
    124120
     
    131127
    132128    if (!$data)
    133       return false;
     129      throw new \Exception(__('Thumbnail Error: Can\'t contact the YouTube API. Ensure your API key is set.', 'utvg'));
    134130
    135131    $thumbnailSources = $data->items[0]->snippet->thumbnails;
     
    146142
    147143    if (!$data)
    148       return false;
     144      throw new \Exception(__('Thumbnail Error: Can\'t contact the Vimeo API', 'utvg'));
    149145
    150146    $data = $data[0];
    151 
    152147    return $data->thumbnail_large;
    153148  }
     
    156151  {
    157152    $data = wp_remote_get($query);
     153
     154    if (is_wp_error($data))
     155      throw new \Exception($data->get_error_message());
     156
    158157    return json_decode($data['body']);
    159158  }
  • utubevideo-gallery/trunk/readme.txt

    r2087886 r2103033  
    33Donate link: https://www.codeclouds.net/utubevideo-gallery/
    44Tags: video, gallery, youtube, vimeo
    5 Requires at least: 4.4.0
     5Requires at least: 4.9.0
    66Requires PHP: 7.0
    77Tested up to: 5.2.0
    8 Stable tag: 2.0.3
     8Stable tag: 2.0.4
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    9292
    9393== Changelog ==
     94
     95= 2.0.4 =
     96* Fixed issue where empty albums would refuse to delete
     97* Added detailed error handling to video api endpoints
    9498
    9599= 2.0.3 =
  • utubevideo-gallery/trunk/utubevideo.php

    r2087886 r2103033  
    44Plugin URI: http://www.codeclouds.net/
    55Description: This plugin allows you to create YouTube video galleries to embed in a WordPress site.
    6 Version: 2.0.3
     6Version: 2.0.4
    77Author: Dustin Scarberry
    88Author URI: http://www.codeclouds.net/
     
    4646  {
    4747    private $_options;
    48     const CURRENT_VERSION = '2.0.3';
     48    const CURRENT_VERSION = '2.0.4';
    4949
    5050    public function __construct()
Note: See TracChangeset for help on using the changeset viewer.