Version 4.7.6
This commit is contained in:
1 parent
8ba7d43898
commit
7b7404e741
1085 files changed
+30590
-7837
No files matched your search
@@ -900,9 +900,51 @@ class _Image extends \IPS\Content\Item implements
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Images that match the current one based on the current sort
|
||||
* Does this image need next/previous icons?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected $imagesSameSort = NULL;
|
||||
public function hasPreviousOrNext(): bool
|
||||
{
|
||||
$images = $this->directContainer()->_items;
|
||||
|
||||
if ( static::canViewHiddenItems( NULL, $this->directContainer() ) )
|
||||
{
|
||||
$images += $this->directContainer()->_unapprovedItems;
|
||||
}
|
||||
|
||||
return $images > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the first or last image in this album or category
|
||||
*
|
||||
* @return \IPS\Patterns\ActiveRecord|null
|
||||
*/
|
||||
public function fetchFirstOrLast( $which='first')
|
||||
{
|
||||
$where = array();
|
||||
$direction = $which == 'first' ? 'DESC' : 'ASC';
|
||||
|
||||
if( $this->album_id )
|
||||
{
|
||||
$where[] = array( 'image_album_id=?', $this->album_id );
|
||||
$sortBy = static::$databaseColumnMap[ $this->directContainer()->_sortBy ?: 'updated' ];
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( 'image_category_id=?', $this->category_id );
|
||||
$where[] = array( 'image_album_id=?', 0 );
|
||||
$sortBy = static::$databaseColumnMap[ $this->directContainer()->sort_options_img ?: 'updated' ];
|
||||
}
|
||||
|
||||
foreach( \IPS\gallery\Image::getItemsWithPermission( $where, static::$databasePrefix . $sortBy . ' ' . $direction . ', image_id ' . $direction, 1 ) as $image )
|
||||
{
|
||||
return $image;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next or previous 5 images in the container
|
||||
@@ -928,7 +970,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
$sortBy = static::$databaseColumnMap[ $this->directContainer()->sort_options_img ?: 'updated' ];
|
||||
}
|
||||
|
||||
$where['id'] = array( 'image_id<>?', $this->id );
|
||||
$where['id'] = array( 'image_id' . $dir . '?', $this->id );
|
||||
|
||||
if( $sortBy == 'caption' )
|
||||
{
|
||||
@@ -936,52 +978,8 @@ class _Image extends \IPS\Content\Item implements
|
||||
$dir = ( $dir == '>' ) ? '<' : '>';
|
||||
}
|
||||
|
||||
if( $this->imagesSameSort === NULL )
|
||||
{
|
||||
$where['date'] = array( static::$databasePrefix . $sortBy . '= ?', $this->$sortBy );
|
||||
$this->imagesSameSort = \IPS\Db::i()->select( 'COUNT(*)', 'gallery_images', $where )->first();
|
||||
}
|
||||
|
||||
if( !$this->imagesSameSort )
|
||||
{
|
||||
$where['date'] = array( static::$databasePrefix . $sortBy . " {$dir}= ?", $this->$sortBy );
|
||||
return iterator_to_array( \IPS\gallery\Image::getItemsWithPermission( $where, static::$databasePrefix . $sortBy . ' ' . $direction . ', image_id ' . $direction, $count ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $where['id'] );
|
||||
|
||||
$results = array();
|
||||
$seen = FALSE;
|
||||
|
||||
foreach( \IPS\gallery\Image::getItemsWithPermission( $where, static::$databasePrefix . $sortBy . ' ' . $direction . ', image_id ' . $direction, NULL ) as $image )
|
||||
{
|
||||
if( !$seen )
|
||||
{
|
||||
if( $image->id == $this->id )
|
||||
{
|
||||
$seen = TRUE;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$results[] = $image;
|
||||
|
||||
if( \count( $results ) == $count )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( \count( $results ) < $count )
|
||||
{
|
||||
$where['date'] = array( static::$databasePrefix . $sortBy . " {$dir} ?", $this->$sortBy );
|
||||
$results = array_merge( $results, iterator_to_array( \IPS\gallery\Image::getItemsWithPermission( $where, static::$databasePrefix . $sortBy . ' ' . $direction, $count - \count( $results ) ) ) );
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
$where['date'] = array( static::$databasePrefix . $sortBy . " {$dir}= ?", $this->$sortBy );
|
||||
return iterator_to_array( \IPS\gallery\Image::getItemsWithPermission( $where, static::$databasePrefix . $sortBy . ' ' . $direction . ', image_id ' . $direction, $count ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2101,9 +2099,10 @@ class _Image extends \IPS\Content\Item implements
|
||||
* @param bool $joinAuthor If true, will join the members table for the author
|
||||
* @param bool $joinLastCommenter If true, will join the members table for the last commenter
|
||||
* @param bool $showMovedLinks If true, moved item links are included in the results
|
||||
* @param array|null $location Array of item lat and long
|
||||
* @return \IPS\Patterns\ActiveRecordIterator|int
|
||||
*/
|
||||
public static function getItemsWithPermission( $where=array(), $order=NULL, $limit=10, $permissionKey='read', $includeHiddenItems=NULL, $queryFlags=0, \IPS\Member $member=NULL, $joinContainer=FALSE, $joinComments=FALSE, $joinReviews=FALSE, $countOnly=FALSE, $joins=NULL, $skipPermission=FALSE, $joinTags=TRUE, $joinAuthor=TRUE, $joinLastCommenter=TRUE, $showMovedLinks=FALSE )
|
||||
public static function getItemsWithPermission( $where=array(), $order=NULL, $limit=10, $permissionKey='read', $includeHiddenItems=NULL, $queryFlags=0, \IPS\Member $member=NULL, $joinContainer=FALSE, $joinComments=FALSE, $joinReviews=FALSE, $countOnly=FALSE, $joins=NULL, $skipPermission=FALSE, $joinTags=TRUE, $joinAuthor=TRUE, $joinLastCommenter=TRUE, $showMovedLinks=FALSE, $location=NULL )
|
||||
{
|
||||
if ( $order === NULL )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user