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,29 +12,36 @@
|
||||
namespace IPS\downloads\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\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: Files
|
||||
*/
|
||||
class _Files
|
||||
class Files 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( "record_file_id IN(?) AND record_type=? AND record_backup=0", \IPS\Db::i()->select( 'file_id', 'downloads_files', array( 'file_submitter=?', $member->member_id ) ), 'upload' ),
|
||||
array( "record_file_id IN(?) AND record_type=? AND record_backup=0", Db::i()->select( 'file_id', 'downloads_files', array( 'file_submitter=?', $member->member_id ) ), 'upload' ),
|
||||
);
|
||||
|
||||
if ( $search )
|
||||
@@ -42,23 +49,23 @@ class _Files
|
||||
$where[] = array( "record_realname LIKE ( CONCAT( '%', ?, '%' ) )", $search );
|
||||
}
|
||||
|
||||
return \IPS\Db::i()->select( 'COUNT(*)', 'downloads_files_records', $where )->first();
|
||||
return Db::i()->select( 'COUNT(*)', 'downloads_files_records', $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( "record_file_id IN(?) AND record_type=? AND record_backup=0", \IPS\Db::i()->select( 'file_id', 'downloads_files', array( 'file_submitter=?', $member->member_id ) ), 'upload' ),
|
||||
array( "record_file_id IN(?) AND record_type=? AND record_backup=0", Db::i()->select( 'file_id', 'downloads_files', array( 'file_submitter=?', $member->member_id ) ), 'upload' ),
|
||||
);
|
||||
|
||||
if ( $search )
|
||||
@@ -67,10 +74,10 @@ class _Files
|
||||
}
|
||||
|
||||
$return = array();
|
||||
foreach ( \IPS\Db::i()->select( '*', 'downloads_files_records', $where, 'record_time DESC', array( ( $page - 1 ) * $limit, $limit ) ) as $row )
|
||||
foreach ( Db::i()->select( '*', 'downloads_files_records', $where, 'record_time DESC', array( ( $page - 1 ) * $limit, $limit ) ) as $row )
|
||||
{
|
||||
$file = \IPS\downloads\File::load( $row['record_file_id'] );
|
||||
$obj = \IPS\File::get( 'downloads_Files', $row['record_location'], $row['record_size'] );
|
||||
$obj = File::get( 'downloads_Files', $row['record_location'], $row['record_size'] );
|
||||
$obj->contextInfo = $file->name;
|
||||
$obj->screenshot = $file->primary_screenshot;
|
||||
$obj->originalFilename = $row['record_realname'];
|
||||
|
||||
Reference in new issue
Block a user