Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,26 +12,34 @@
|
||||
namespace IPS\gallery\extensions\core\EditorMedia;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Extensions\EditorMediaAbstract;
|
||||
use IPS\File;
|
||||
use IPS\gallery\Image;
|
||||
use IPS\Member;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Editor Media: Images
|
||||
*/
|
||||
class _Images
|
||||
class Images extends EditorMediaAbstract
|
||||
{
|
||||
/**
|
||||
* Get Counts
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @param string $postKey The post key
|
||||
* @param string|null $search The search term (or NULL for all)
|
||||
* @return array array( 'Title' => 0 )
|
||||
* @return array|int array( 'Title' => 0 )
|
||||
*/
|
||||
public function count( $member, $postKey, $search=NULL )
|
||||
public function count( Member $member, string $postKey, string $search=NULL ): array|int
|
||||
{
|
||||
$where = array(
|
||||
array( "image_member_id=? AND image_approved=?", $member->member_id, 1 ),
|
||||
@@ -40,14 +48,14 @@ class _Images
|
||||
if ( $search )
|
||||
{
|
||||
$albumIds = [];
|
||||
foreach( \IPS\Db::i()->select( 'album_id', 'gallery_albums', array( "album_owner_id=? AND album_name LIKE ( CONCAT( '%', ?, '%' ) )", $member->member_id, $search ), NULL, 250 ) as $album )
|
||||
foreach( Db::i()->select( 'album_id', 'gallery_albums', array( "album_owner_id=? AND album_name LIKE ( CONCAT( '%', ?, '%' ) )", $member->member_id, $search ), NULL, 250 ) as $album )
|
||||
{
|
||||
$albumIds[] = $album;
|
||||
}
|
||||
|
||||
if ( count( $albumIds ) )
|
||||
{
|
||||
$where[] = array( "( image_caption LIKE ( CONCAT( '%', ?, '%' ) ) OR ( " . \IPS\Db::i()->in( 'image_album_id', $albumIds ) . " ) )", $search );
|
||||
$where[] = array( "( image_caption LIKE ( CONCAT( '%', ?, '%' ) ) OR ( " . Db::i()->in( 'image_album_id', $albumIds ) . " ) )", $search );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -55,20 +63,20 @@ class _Images
|
||||
}
|
||||
}
|
||||
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'gallery_images', $where )->first();
|
||||
return Db::i()->select( 'COUNT(*)', 'gallery_images', $where )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Files
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param Member $member The member
|
||||
* @param string|null $search The search term (or NULL for all)
|
||||
* @param string $postKey The post key
|
||||
* @param int $page Page
|
||||
* @param int $limit Number to get
|
||||
* @return array array( 'Title' => array( (IPS\File, \IPS\File, ... ), ... )
|
||||
*/
|
||||
public function get( $member, $search, $postKey, $page, $limit )
|
||||
public function get( Member $member, ?string $search, string $postKey, int $page, int $limit ): array
|
||||
{
|
||||
$where = array(
|
||||
array( "image_member_id=? AND image_approved=?", $member->member_id, 1 ),
|
||||
@@ -77,14 +85,14 @@ class _Images
|
||||
if ( $search )
|
||||
{
|
||||
$albumIds = [];
|
||||
foreach( \IPS\Db::i()->select( 'album_id', 'gallery_albums', array( "album_owner_id=? AND album_name LIKE ( CONCAT( '%', ?, '%' ) )", $member->member_id, $search ), NULL, 250 ) as $album )
|
||||
foreach( Db::i()->select( 'album_id', 'gallery_albums', array( "album_owner_id=? AND album_name LIKE ( CONCAT( '%', ?, '%' ) )", $member->member_id, $search ), NULL, 250 ) as $album )
|
||||
{
|
||||
$albumIds[] = $album;
|
||||
}
|
||||
|
||||
if ( count( $albumIds ) )
|
||||
{
|
||||
$where[] = array( "( image_caption LIKE ( CONCAT( '%', ?, '%' ) ) OR ( " . \IPS\Db::i()->in( 'image_album_id', $albumIds ) . " ) )", $search );
|
||||
$where[] = array( "( image_caption LIKE ( CONCAT( '%', ?, '%' ) ) OR ( " . Db::i()->in( 'image_album_id', $albumIds ) . " ) )", $search );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -93,11 +101,11 @@ class _Images
|
||||
}
|
||||
|
||||
$return = array();
|
||||
foreach ( \IPS\Db::i()->select( '*', 'gallery_images', $where, 'image_date DESC', array( ( $page - 1 ) * $limit, $limit ) ) as $row )
|
||||
foreach ( Db::i()->select( '*', 'gallery_images', $where, 'image_date DESC', array( ( $page - 1 ) * $limit, $limit ) ) as $row )
|
||||
{
|
||||
$image = \IPS\gallery\Image::load( $row['image_id'] );
|
||||
$image = Image::load( $row['image_id'] );
|
||||
$fileName = $image->masked_file_name ?: $image->original_file_name;
|
||||
$obj = \IPS\File::get( 'gallery_Images', $fileName );
|
||||
$obj = File::get( 'gallery_Images', $fileName );
|
||||
$obj->contextInfo = $image->caption;
|
||||
$return[ (string) $image->url() ] = $obj;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user