Ansel_Api::getRecentImages PHP Method

getRecentImages() public method

Return a list of recently added images
See also: Ansel_Api::getImages
public getRecentImages ( array $params = [] ) : array
$params array Parameter (optionally) containing:
  (string)app       Application used if null then use default.
  (array)galleries  An array of gallery ids to check.  If left empty,
                    will search all galleries with the given
                    permissions for the current user.
  (string)view      The type of image view to return.
  (boolean)full     Return a full URL if this is true.
  (integer)limit    The maximum number of images to return.
  (string)style     Force the use of this gallery style
  (array)slugs      An array of gallery slugs
return array A hash of image information arrays, keyed by image_id:
    public function getRecentImages(array $params = array())
    {
        $params = new Horde_Support_Array($params);
        if ($params->app) {
            $GLOBALS['injector']->getInstance('Ansel_Config')->set('scope', $params->app);
        }
        $images = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRecentImages($params->get('galleries', array()), $params->get('limit', 10), $params->get('slugs', array()));
        $imagelist = array();
        if ($params->style) {
            $params->style = Ansel::getStyleDefinition($params->style);
        }
        foreach ($images as $image) {
            $id = $image->id;
            $imagelist[$id]['id'] = $id;
            $imagelist[$id]['name'] = $image->filename;
            $imagelist[$id]['url'] = Ansel::getImageUrl($id, $params->get('view', 'screen'), $params->get('full', false), $params->style);
            $imagelist[$id]['caption'] = $image->caption;
            $imagelist[$id]['filename'] = $image->filename;
            $imagelist[$id]['gallery'] = $image->gallery;
            $imagelist[$id]['uploaded'] = $image->uploaded;
            $imagelist[$id]['original_date'] = $image->originalDate;
            if ($params->app && $GLOBALS['conf']['vfs']['src'] != 'direct') {
                $imagelist[$id]['url']->add('app', $params->app);
            }
        }
        return $imagelist;
    }