Version 4.7.8
This commit is contained in:
1 parent
7b7404e741
commit
fd22d99e69
688 files changed
+19814
-10890
No files matched your search
@@ -149,6 +149,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
$return[] = 'image_small_file_name';
|
||||
$return[] = 'image_album_id';
|
||||
$return[] = 'image_copyright';
|
||||
$return[] = 'image_nsfw';
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -938,6 +939,11 @@ class _Image extends \IPS\Content\Item implements
|
||||
$sortBy = static::$databaseColumnMap[ $this->directContainer()->sort_options_img ?: 'updated' ];
|
||||
}
|
||||
|
||||
if( $sortBy == 'caption' )
|
||||
{
|
||||
$direction = ( $direction == 'ASC' ) ? 'DESC' : 'ASC';
|
||||
}
|
||||
|
||||
foreach( \IPS\gallery\Image::getItemsWithPermission( $where, static::$databasePrefix . $sortBy . ' ' . $direction . ', image_id ' . $direction, 1 ) as $image )
|
||||
{
|
||||
return $image;
|
||||
@@ -970,16 +976,34 @@ class _Image extends \IPS\Content\Item implements
|
||||
$sortBy = static::$databaseColumnMap[ $this->directContainer()->sort_options_img ?: 'updated' ];
|
||||
}
|
||||
|
||||
$where['id'] = array( 'image_id' . $dir . '?', $this->id );
|
||||
|
||||
if( $sortBy == 'caption' )
|
||||
$where['id'] = array( 'image_id<>?', $this->id );
|
||||
|
||||
if( in_array( $sortBy, array( 'caption', 'rating' ) ) )
|
||||
{
|
||||
$direction = ( $direction == 'ASC' ) ? 'DESC' : 'ASC';
|
||||
$dir = ( $dir == '>' ) ? '<' : '>';
|
||||
if( $sortBy == 'caption' )
|
||||
{
|
||||
$direction = ( $direction == 'ASC' ) ? 'DESC' : 'ASC';
|
||||
$dir = ( $dir == '>' ) ? '<' : '>';
|
||||
}
|
||||
|
||||
/* We need to sort on a unique value */
|
||||
$sortValue = $this->$sortBy . $this->updated;
|
||||
$sortBy = 'CONCAT(image_' . $sortBy . ',image_updated)';
|
||||
}
|
||||
elseif( in_array( $sortBy, array( 'date', 'updated' ) ) )
|
||||
{
|
||||
/* We need to sort on a unique value */
|
||||
$sortValue = $this->$sortBy . $this->id;
|
||||
$sortBy = 'CONCAT(image_' . $sortBy . ',image_id)';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sortValue = $this->$sortBy;
|
||||
$sortBy = static::$databasePrefix . $sortBy;
|
||||
}
|
||||
|
||||
$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 ) );
|
||||
$where['date'] = array( $sortBy . " {$dir}= ?", $sortValue );
|
||||
return iterator_to_array( \IPS\gallery\Image::getItemsWithPermission( $where, $sortBy . ' ' . $direction . ', image_id ' . $direction, $count ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1158,6 +1182,11 @@ class _Image extends \IPS\Content\Item implements
|
||||
$return['credit_info'] = new \IPS\Helpers\Form\TextArea( 'image_credit_info', $item ? $item->credit_info : NULL, FALSE );
|
||||
$return['copyright'] = new \IPS\Helpers\Form\Text( 'image_copyright', $item ? $item->copyright : NULL, FALSE, array( 'maxLength' => 255 ) );
|
||||
|
||||
if( \IPS\Settings::i()->gallery_nsfw )
|
||||
{
|
||||
$return['nsfw'] = new \IPS\Helpers\Form\YesNo( 'image_nsfw', $item ? $item->nsfw : FALSE );
|
||||
}
|
||||
|
||||
/* If we are editing, return the appropriate fields */
|
||||
if( $item )
|
||||
{
|
||||
@@ -1245,6 +1274,11 @@ class _Image extends \IPS\Content\Item implements
|
||||
{
|
||||
$this->credit_info = $values['image_credit_info'];
|
||||
}
|
||||
|
||||
if ( isset( $values['image_nsfw'] ) )
|
||||
{
|
||||
$this->nsfw = $values['image_nsfw'];
|
||||
}
|
||||
|
||||
/* If we are editing and have a movie, update it */
|
||||
if( isset( $values['mediaLocation'] ) )
|
||||
@@ -1252,6 +1286,11 @@ class _Image extends \IPS\Content\Item implements
|
||||
$values['imageLocation'] = $values['mediaLocation'];
|
||||
}
|
||||
|
||||
if ( isset( $values['labels'] ) )
|
||||
{
|
||||
$this->labels = $values['labels'];
|
||||
}
|
||||
|
||||
/* Get the file... */
|
||||
$file = NULL;
|
||||
if( isset( $values['imageLocation'] ) AND $values['imageLocation'] )
|
||||
@@ -1757,6 +1796,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
* @apiresponse bool pinned Image is pinned
|
||||
* @apiresponse string url URL
|
||||
* @apiresponse float rating Average Rating
|
||||
* @apiresponse bool nsfw Not safe for work
|
||||
*/
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
{
|
||||
@@ -1790,6 +1830,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
'pinned' => (bool) $this->mapped('pinned'),
|
||||
'url' => (string) $this->url(),
|
||||
'rating' => $this->averageRating(),
|
||||
'nsfw' => $this->nsfw
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2010,7 +2051,9 @@ class _Image extends \IPS\Content\Item implements
|
||||
*/
|
||||
public function canSetAsAlbumCover( $member=NULL )
|
||||
{
|
||||
if( ( $this->album_id AND $this->canEdit() ) OR static::modPermission( 'edit', $member, $this->container() ) )
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
/* Allow album owners to always change the album cover */
|
||||
if( ( $this->album_id AND $album = \IPS\gallery\Album::load( $this->album_id ) AND $member->member_id AND $album->owner_id == $member->member_id ) OR static::modPermission( 'edit', $member, $this->container() ) )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -2433,7 +2476,7 @@ class _Image extends \IPS\Content\Item implements
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function clubImageExclusion()
|
||||
public static function clubImageExclusion(): array
|
||||
{
|
||||
if( \IPS\Settings::i()->club_nodes_in_apps )
|
||||
{
|
||||
@@ -2447,4 +2490,38 @@ class _Image extends \IPS\Content\Item implements
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the labels from image scanner for search
|
||||
*
|
||||
* @return array|NULL
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function imageLabelsForSearch()
|
||||
{
|
||||
$return = [];
|
||||
|
||||
$labels = $this->labels ? json_decode( $this->labels, TRUE ) : array();
|
||||
|
||||
if( $labels and \count( $labels ) )
|
||||
{
|
||||
foreach( $labels as $label )
|
||||
{
|
||||
$return[] = $label['Name'];
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the image NSFW?
|
||||
*
|
||||
* @param \IPS\Member\NULL $member The member (NULL for currently logged in member)
|
||||
* @return bool
|
||||
*/
|
||||
public function nsfw()
|
||||
{
|
||||
return (bool) $this->nsfw;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user