src/libraries/controllers/ApiPhotoController.php
/**
    * Retrieve the next and previous photo given photo $id
    *
    * @param string $id ID of the photo to be deleted.
    * @return string Standard JSON envelope
    */
Retrieve the next and previous photo given photo $id
@param string $id ID of the photo to be deleted.
@return string Standard JSON envelope
Retrieve the next and previous photo given photo $id @param string $id ID of the photo to be deleted . @return string Standard JSON envelope
public function nextPrevious($id, $filterOpts = null)
  {
    $db = getDb();
    extract($this->parseFilters($filterOpts));
    $nextPrevious = $db->getPhotoNextPrevious($id, $filters);
    if(!$nextPrevious)
      return $this->error('Could not get next/previous photo', false);
    $sizes = array();
    if(isset($_GET['returnSizes']))
      $sizes = (array)explode(',', $_GET['returnSizes']);
    foreach($nextPrevious as $key => $photo)
      $nextPrevious[$key] = $this->pruneSizes($photo, $sizes);
    $generate = $requery = false;
    if(isset($_GET['generate']) && $_GET['generate'] == 'true')
      $generate = true;
    if(!empty($sizes))
    {
      $protocol = $this->utility->getProtocol(false);
      if(isset($_GET['protocol']))
        $protocol = $_GET['protocol'];
      foreach($sizes as $size)
      {
        foreach($nextPrevious as $key => $photo)
        {
          $options = $this->photo->generateFragmentReverse($size);
          if($generate && !isset($nextPrevious[$key]["path{$size}"]))
          {
            $hash = $this->photo->generateHash($photo['id'], $options['width'], $options['height'], $options['options']);
            $this->photo->generate($photo['id'], $hash, $options['width'], $options['width'], $options['options']);
            $requery = true;
          }
        }
      }
      if($requery)
      {
        $nextPrevious = $db->getPhotoNextPrevious($id, $filters);
        foreach($nextPrevious as $key => $photo)
          $nextPrevious[$key] = $this->pruneSizes($photo, $sizes);
      }
    }
    foreach($nextPrevious as $key => $photo)
      $nextPrevious[$key] = $this->photo->addApiUrls($photo, $sizes);
    return $this->success("Next/previous for photo {$id}", $nextPrevious);
  }
public function nextPrevious ( $ id , $ filterOpts = null ) { $ db = getDb ( ) ; extract ( $ this -> parseFilters ( $ filterOpts ) ) ; $ nextPrevious = $ db -> getPhotoNextPrevious ( $ id , $ filters ) ; if ( ! $ nextPrevious ) return $ this -> error ( 'Could not get next/previous photo' , false ) ; $ sizes = array ( ) ; if ( isset ( $ _GET [ 'returnSizes' ] ) ) $ sizes = ( array ) explode ( ',' , $ _GET [ 'returnSizes' ] ) ; foreach ( $ nextPrevious as $ key => $ photo ) $ nextPrevious [ $ key ] = $ this -> pruneSizes ( $ photo , $ sizes ) ; $ generate = $ requery = false ; if ( isset ( $ _GET [ 'generate' ] ) && $ _GET [ 'generate' ] == 'true' ) $ generate = true ; if ( ! empty ( $ sizes ) ) { $ protocol = $ this -> utility -> getProtocol ( false ) ; if ( isset ( $ _GET [ 'protocol' ] ) ) $ protocol = $ _GET [ 'protocol' ] ; foreach ( $ sizes as $ size ) { foreach ( $ nextPrevious as $ key => $ photo ) { $ options = $ this -> photo -> generateFragmentReverse ( $ size ) ; if ( $ generate && ! isset ( $ nextPrevious [ $ key ] [ " path { $ size } " ] ) ) { $ hash = $ this -> photo -> generateHash ( $ photo [ 'id' ] , $ options [ 'width' ] , $ options [ 'height' ] , $ options [ 'options' ] ) ; $ this -> photo -> generate ( $ photo [ 'id' ] , $ hash , $ options [ 'width' ] , $ options [ 'width' ] , $ options [ 'options' ] ) ; $ requery = true ; } } } if ( $ requery ) { $ nextPrevious = $ db -> getPhotoNextPrevious ( $ id , $ filters ) ; foreach ( $ nextPrevious as $ key => $ photo ) $ nextPrevious [ $ key ] = $ this -> pruneSizes ( $ photo , $ sizes ) ; } } foreach ( $ nextPrevious as $ key => $ photo ) $ nextPrevious [ $ key ] = $ this -> photo -> addApiUrls ( $ photo , $ sizes ) ; return $ this -> success ( " Next/previous for photo  { $ id } " , $ nextPrevious ) ; }
Retrieve the next and previous photo given photo $id
 @param string $id ID of the photo to be deleted.
Retrieve the next and previous photo given photo $id @param string $id ID of the photo to be deleted .
// if specific sizes are requested then make sure we return them // requery to get generated paths