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
File diff suppressed because it is too large.
Load diff
@@ -13,99 +13,83 @@ namespace IPS\downloads;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\Lang;
|
||||
use IPS\Application;
|
||||
use IPS\CustomField;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\TextArea;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Member;
|
||||
use IPS\Settings;
|
||||
use function defined;
|
||||
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Field Node
|
||||
*/
|
||||
class _Field extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
class Field extends CustomField
|
||||
{
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
protected static array $multitons;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'downloads_cfields';
|
||||
public static ?string $databaseTable = 'downloads_cfields';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'cf_';
|
||||
public static string $databasePrefix = 'cf_';
|
||||
|
||||
/**
|
||||
* @brief [Node] Order Database Column
|
||||
*/
|
||||
public static $databaseColumnOrder = 'position';
|
||||
public static ?string $databaseColumnOrder = 'position';
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
public static array $databaseColumnMap = array(
|
||||
'not_null' => 'not_null'
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief [Node] Node Title
|
||||
*/
|
||||
public static $nodeTitle = 'ccfields';
|
||||
public static string $nodeTitle = 'ccfields';
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Title/Description lang prefix
|
||||
*/
|
||||
protected static $langKey = 'downloads_field';
|
||||
protected static string $langKey = 'downloads_field';
|
||||
|
||||
/**
|
||||
* @brief [Node] Title prefix. If specified, will look for a language key with "{$key}_title" as the key
|
||||
*/
|
||||
public static $titleLangPrefix = 'downloads_field_';
|
||||
public static ?string $titleLangPrefix = 'downloads_field_';
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Content Table
|
||||
*/
|
||||
public static $contentDatabaseTable = 'downloads_ccontent';
|
||||
public static string $contentDatabaseTable = 'downloads_ccontent';
|
||||
|
||||
/**
|
||||
* @brief [CustomField] Set to TRUE if uploads fields are capable of holding the submitted content for moderation
|
||||
*/
|
||||
public static $uploadsCanBeModerated = TRUE;
|
||||
|
||||
/**
|
||||
* @brief The map of permission columns
|
||||
*/
|
||||
public static $permissionMap = array(
|
||||
'view' => 'view',
|
||||
'edit' => 2,
|
||||
'add' => 3
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief [Node] App for permission index
|
||||
*/
|
||||
public static $permApp = 'downloads';
|
||||
|
||||
/**
|
||||
* @brief [Node] Type for permission index
|
||||
*/
|
||||
public static $permType = 'fields';
|
||||
|
||||
/**
|
||||
* @brief [Node] Prefix string that is automatically prepended to permission matrix language strings
|
||||
*/
|
||||
public static $permissionLangPrefix = 'perm_cfield_';
|
||||
public static bool $uploadsCanBeModerated = TRUE;
|
||||
|
||||
/**
|
||||
* @brief [Node] ACP Restrictions
|
||||
*/
|
||||
protected static $restrictions = array(
|
||||
protected static ?array $restrictions = array(
|
||||
'app' => 'downloads',
|
||||
'module' => 'downloads',
|
||||
'prefix' => 'fields_',
|
||||
@@ -114,69 +98,58 @@ class _Field extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
/**
|
||||
* @brief [CustomField] Editor Options
|
||||
*/
|
||||
public static $editorOptions = array( 'app' => 'downloads', 'key' => 'Downloads' );
|
||||
public static array $editorOptions = array( 'app' => 'downloads', 'key' => 'Downloads' );
|
||||
|
||||
/**
|
||||
* @brief [CustomField] FileStorage Extension for Upload fields
|
||||
*/
|
||||
public static $uploadStorageExtension = 'downloads_FileField';
|
||||
public static string $uploadStorageExtension = 'downloads_FileField';
|
||||
|
||||
/**
|
||||
* @brief [CustomField] An array of the 'keys' of the Field types toggles that shouldn't be an option. The main use is for excluding polls
|
||||
*/
|
||||
public static $disabledFieldTypes = array( 'Poll' );
|
||||
public static array $disabledFieldTypes = array( 'Poll' );
|
||||
|
||||
|
||||
/**
|
||||
* Get topic format
|
||||
*
|
||||
* @return void
|
||||
* @return string|null
|
||||
*/
|
||||
public function get_topic_format()
|
||||
public function get_topic_format() : string|null
|
||||
{
|
||||
return $this->format;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* [Node] Does the currently logged in user have permission to edit permissions for this node?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canManagePermissions()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Add/Edit Form
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form
|
||||
* @param Form $form The form
|
||||
* @return void
|
||||
*/
|
||||
public function form( &$form )
|
||||
public function form( Form &$form ) : void
|
||||
{
|
||||
parent::form( $form );
|
||||
|
||||
|
||||
|
||||
unset( $form->elements['']['pf_search_type'] );
|
||||
unset( $form->elements['']['pf_search_type_on_off'] );
|
||||
\IPS\Member::loggedIn()->language()->words['field_displayoptions'] = \IPS\Member::loggedIn()->language()->addToStack('pfield_displayoptions');
|
||||
Member::loggedIn()->language()->words['field_displayoptions'] = Member::loggedIn()->language()->addToStack('pfield_displayoptions');
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'downloads_field_location', $this->id ? $this->display_location : 'below', FALSE, array( 'options' => array( 'sidebar' => 'idm_cfield_sidebar', 'below' => 'idm_cfield_below', 'tab' => 'idm_cfield_tab' ) ), NULL, NULL, NULL, 'idm_field_location' ) );
|
||||
$form->add( new Radio( 'downloads_field_location', $this->id ? $this->display_location : 'below', FALSE, array( 'options' => array( 'sidebar' => 'idm_cfield_sidebar', 'below' => 'idm_cfield_below', 'tab' => 'idm_cfield_tab' ) ), NULL, NULL, NULL, 'idm_field_location' ) );
|
||||
|
||||
if ( \IPS\Application::appIsEnabled( 'nexus' ) and \IPS\Settings::i()->idm_nexus_on )
|
||||
if ( Application::appIsEnabled( 'nexus' ) and Settings::i()->idm_nexus_on )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'downloads_field_paid', $this->id ? $this->paid_field : FALSE, FALSE, array( 'togglesOff' => array( 'idm_cf_topic', 'idm_pf_format', 'form_' . ( $this->id ?? 'new' ) . '_header_category_forums_integration' ) ) ) );
|
||||
$form->add( new YesNo( 'downloads_field_paid', $this->id ? $this->paid_field : FALSE, FALSE, array( 'togglesOff' => array( 'idm_cf_topic', 'idm_pf_format', 'form_' . ( $this->id ?? 'new' ) . '_header_category_forums_integration' ) ) ) );
|
||||
}
|
||||
|
||||
if ( \IPS\Application::appIsEnabled( 'forums' ) )
|
||||
if ( Application::appIsEnabled( 'forums' ) )
|
||||
{
|
||||
$form->addHeader('category_forums_integration');
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'cf_topic', $this->topic, FALSE, array(), NULL, NULL, NULL, 'idm_cf_topic' ) );
|
||||
$form->add( new \IPS\Helpers\Form\TextArea( 'pf_format', $this->id ? $this->topic_format : '', FALSE, array(), NULL, NULL, NULL, 'idm_pf_format' ) );
|
||||
$form->add( new YesNo( 'cf_topic', $this->topic, FALSE, array(), NULL, NULL, NULL, 'idm_cf_topic' ) );
|
||||
$form->add( new TextArea( 'pf_format', $this->id ? $this->topic_format : '', FALSE, array(), NULL, NULL, NULL, 'idm_pf_format' ) );
|
||||
|
||||
\IPS\Member::loggedIn()->language()->words['pf_format_desc'] = \IPS\Member::loggedIn()->language()->addToStack('cf_format_desc');
|
||||
Member::loggedIn()->language()->words['pf_format_desc'] = Member::loggedIn()->language()->addToStack('cf_format_desc');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,9 +159,9 @@ class _Field extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
* @param array $values Values from the form
|
||||
* @return array
|
||||
*/
|
||||
public function formatFormValues( $values )
|
||||
public function formatFormValues( array $values ): array
|
||||
{
|
||||
if ( \IPS\Application::appIsEnabled( 'forums' ) AND isset( $values['cf_topic'] ) )
|
||||
if ( Application::appIsEnabled( 'forums' ) AND isset( $values['cf_topic'] ) )
|
||||
{
|
||||
/* Forcibly disable include in topic option if it is a paid field */
|
||||
$values['topic'] = ( isset( $values['downloads_field_paid'] ) AND $values['downloads_field_paid'] ) ? 0 : $values['cf_topic'];
|
||||
@@ -205,28 +178,4 @@ class _Field extends \IPS\CustomField implements \IPS\Node\Permissions
|
||||
|
||||
return parent::formatFormValues( $values );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @param array $fieldValues Current values for a specific file
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse string name Name
|
||||
* @apiresponse string description Description
|
||||
* @apiresponse string value Raw field value from the database
|
||||
* @apiresponse string|int|array|boolean displayValue Parsed Field value with all field data
|
||||
*/
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL, $fieldValues=array() )
|
||||
{
|
||||
$lang = $authorizedMember ? $authorizedMember->language() : Lang::load( Lang::defaultLanguage() );
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $lang->addToStack( 'downloads_field_' . $this->id ),
|
||||
'description' => $lang->addToStack( 'downloads_field_' . $this->id . '_desc' ),
|
||||
'value' => $fieldValues[ 'field_' . $this->id ] ?? null,
|
||||
'displayValue' => $this->apiValue( $fieldValues[ 'field_' . $this->id ] )
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -12,43 +12,66 @@
|
||||
namespace IPS\downloads\File;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Content\Anonymous;
|
||||
use IPS\Content\Comment as ContentComment;
|
||||
use IPS\Content\EditHistory;
|
||||
use IPS\Content\Embeddable;
|
||||
use IPS\Content\Filter;
|
||||
use IPS\Content\Hideable;
|
||||
use IPS\Content\Featurable;
|
||||
use IPS\Content\Reactable;
|
||||
use IPS\Content\Reportable;
|
||||
use IPS\Content\Shareable;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Output;
|
||||
use IPS\Theme;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Comment Model
|
||||
*/
|
||||
class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable, \IPS\Content\Shareable, \IPS\Content\Anonymous
|
||||
class Comment extends ContentComment implements Embeddable,
|
||||
Filter
|
||||
{
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
use Reactable,
|
||||
Reportable,
|
||||
Anonymous,
|
||||
Shareable,
|
||||
EditHistory,
|
||||
Hideable,
|
||||
Featurable;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
protected static array $multitons;
|
||||
|
||||
/**
|
||||
* @brief [Content\Comment] Item Class
|
||||
*/
|
||||
public static $itemClass = 'IPS\downloads\File';
|
||||
public static ?string $itemClass = 'IPS\downloads\File';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'downloads_comments';
|
||||
public static ?string $databaseTable = 'downloads_comments';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'comment_';
|
||||
public static string $databasePrefix = 'comment_';
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
public static array $databaseColumnMap = array(
|
||||
'item' => 'fid',
|
||||
'author' => 'mid',
|
||||
'author_name' => 'author',
|
||||
@@ -65,64 +88,40 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $application = 'downloads';
|
||||
public static string $application = 'downloads';
|
||||
|
||||
/**
|
||||
* @brief Title
|
||||
*/
|
||||
public static $title = 'downloads_file_comment';
|
||||
public static string $title = 'downloads_file_comment';
|
||||
|
||||
/**
|
||||
* @brief Icon
|
||||
*/
|
||||
public static $icon = 'download';
|
||||
public static string $icon = 'download';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
public static $hideLogKey = 'downloads-files';
|
||||
public static ?string $hideLogKey = 'downloads-files';
|
||||
|
||||
/**
|
||||
* Get URL for doing stuff
|
||||
*
|
||||
* @param string|NULL $action Action
|
||||
* @return \IPS\Http\Url
|
||||
* @return Url
|
||||
*/
|
||||
public function url( $action='find' )
|
||||
public function url( ?string $action='find' ): Url
|
||||
{
|
||||
return parent::url( $action )->setQueryString( 'tab', 'comments' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get snippet HTML for search result display
|
||||
*
|
||||
* @param array $indexData Data from the search index
|
||||
* @param array $authorData Basic data about the author. Only includes columns returned by \IPS\Member::columnsForPhoto()
|
||||
* @param array $itemData Basic data about the item. Only includes columns returned by item::basicDataColumns()
|
||||
* @param array|NULL $containerData Basic data about the container. Only includes columns returned by container::basicDataColumns()
|
||||
* @param array $reputationData Array of people who have given reputation and the reputation they gave
|
||||
* @param int|NULL $reviewRating If this is a review, the rating
|
||||
* @param string $view 'expanded' or 'condensed'
|
||||
* @return callable
|
||||
*/
|
||||
public static function searchResultSnippet( array $indexData, array $authorData, array $itemData, ?array $containerData, array $reputationData, $reviewRating, $view )
|
||||
{
|
||||
$screenshot = NULL;
|
||||
if ( isset( $itemData['extra'] ) )
|
||||
{
|
||||
$screenshot = isset( $itemData['extra']['record_thumb'] ) ? $itemData['extra']['record_thumb'] : $itemData['extra']['record_location'];
|
||||
}
|
||||
$url = \IPS\Http\Url::internal( \IPS\downloads\File::$urlBase . $indexData['index_item_id'], 'front', \IPS\downloads\File::$urlTemplate, \IPS\Http\Url\Friendly::seoTitle( $indexData['index_title'] ?: $itemData[ \IPS\downloads\File::$databasePrefix . \IPS\downloads\File::$databaseColumnMap['title'] ] ) );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'downloads', 'front' )->searchResultCommentSnippet( $indexData, $screenshot, $url, $reviewRating, $view == 'condensed' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reaction Type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function reactionType()
|
||||
public static function reactionType(): string
|
||||
{
|
||||
return 'comment_id';
|
||||
}
|
||||
@@ -133,9 +132,9 @@ class _Comment extends \IPS\Content\Comment implements \IPS\Content\EditHistory,
|
||||
* @param array $params Additional parameters to add to URL
|
||||
* @return string
|
||||
*/
|
||||
public function embedContent( $params )
|
||||
public function embedContent( array $params ): string
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'embed.css', 'downloads', 'front' ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'downloads' )->embedFileComment( $this, $this->item(), $this->url()->setQueryString( $params ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'embed.css', 'downloads', 'front' ) );
|
||||
return Theme::i()->getTemplate( 'global', 'downloads' )->embedFileComment( $this, $this->item(), $this->url()->setQueryString( $params ) );
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -12,56 +12,85 @@
|
||||
namespace IPS\downloads\File;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Api\Webhook;
|
||||
use IPS\Content\Filter;
|
||||
use IPS\Content\Hideable;
|
||||
use IPS\Content\Item;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\downloads\File;
|
||||
use IPS\File as SystemFile;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use OutOfRangeException;
|
||||
use RuntimeException;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function floatval;
|
||||
use function is_array;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* PendingVersion Model
|
||||
*/
|
||||
class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
class PendingVersion extends Item implements Filter
|
||||
{
|
||||
use Hideable
|
||||
{
|
||||
Hideable::unhide as public _unhide;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $application = 'downloads';
|
||||
public static string $application = 'downloads';
|
||||
|
||||
/**
|
||||
* @brief Module
|
||||
*/
|
||||
public static $module = 'downloads';
|
||||
public static string $module = 'downloads';
|
||||
|
||||
/**
|
||||
* @brief Database Table
|
||||
*/
|
||||
public static $databaseTable = 'downloads_files_pending';
|
||||
public static ?string $databaseTable = 'downloads_files_pending';
|
||||
|
||||
/**
|
||||
* @brief Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'pending_';
|
||||
public static string $databasePrefix = 'pending_';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] ID Database Column
|
||||
*/
|
||||
public static $databaseColumnId = 'id';
|
||||
public static string $databaseColumnId = 'id';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database ID Fields
|
||||
*/
|
||||
protected static $databaseIdFields = array('pending_file_id');
|
||||
protected static array $databaseIdFields = array('pending_file_id');
|
||||
|
||||
/**
|
||||
* @brief Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
protected static array $multitons;
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
public static array $databaseColumnMap = array(
|
||||
'author' => 'member_id',
|
||||
'title' => 'name',
|
||||
'date' => 'date',
|
||||
@@ -71,41 +100,41 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
/**
|
||||
* @brief Title
|
||||
*/
|
||||
public static $title = 'downloads_file_pending';
|
||||
public static string $title = 'downloads_file_pending';
|
||||
|
||||
/**
|
||||
* @brief Icon
|
||||
*/
|
||||
public static $icon = 'download';
|
||||
public static string $icon = 'download';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
public static $hideLogKey = 'downloads-file-pending';
|
||||
public static ?string $hideLogKey = 'downloads-file-pending';
|
||||
|
||||
/**
|
||||
* @brief Used by the dataLayer
|
||||
*/
|
||||
public static $contentType = 'file';
|
||||
public static string $contentType = 'file';
|
||||
|
||||
/**
|
||||
* Can unhide?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @param Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @return boolean
|
||||
*/
|
||||
public function canUnhide( $member=NULL )
|
||||
public function canUnhide( ?Member $member=NULL ): bool
|
||||
{
|
||||
return \IPS\downloads\File::modPermission( 'unhide', $member, $this->file()->containerWrapper() );
|
||||
return File::modPermission( 'unhide', $member, $this->file()->containerWrapper() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Can hide?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @param Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @return bool
|
||||
*/
|
||||
public function canHide( $member=NULL )
|
||||
public function canHide( ?Member $member=NULL ): bool
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -113,13 +142,12 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
/**
|
||||
* Can delete pending version?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @param Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @return bool
|
||||
*/
|
||||
public function canDelete( $member=NULL )
|
||||
public function canDelete( ?Member $member=NULL ): bool
|
||||
{
|
||||
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$member = $member ?: Member::loggedIn();
|
||||
if( !$member->member_id )
|
||||
{
|
||||
return FALSE;
|
||||
@@ -136,9 +164,9 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
/**
|
||||
* Returns the content
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function content()
|
||||
public function content(): ?string
|
||||
{
|
||||
return $this->form_values['file_changelog'];
|
||||
}
|
||||
@@ -146,17 +174,17 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
/**
|
||||
* @brief Cached URLs
|
||||
*/
|
||||
protected $_url = array();
|
||||
protected mixed $_url = array();
|
||||
|
||||
/**
|
||||
* Pending URL
|
||||
*
|
||||
* @param null|string $action 'do' action
|
||||
* @return \IPS\Http\Url
|
||||
* @param string|null $action 'do' action
|
||||
* @return Url
|
||||
*/
|
||||
public function url( $action=NULL ): \IPS\Http\Url
|
||||
public function url( string $action=NULL ): Url
|
||||
{
|
||||
$url = \IPS\Http\Url::internal( "app=downloads&module=downloads&controller=pending&file_id={$this->file()->id}&id={$this->id}", 'front', 'downloads_file_pending', $this->file()->name_furl );
|
||||
$url = Url::internal( "app=downloads&module=downloads&controller=pending&file_id={$this->file()->id}&id={$this->id}", 'front', 'downloads_file_pending', $this->file()->name_furl );
|
||||
|
||||
if( $action )
|
||||
{
|
||||
@@ -169,7 +197,7 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
/**
|
||||
* @brief store decoded form values
|
||||
*/
|
||||
protected $_formValues = NULL;
|
||||
protected ?array $_formValues = NULL;
|
||||
|
||||
/**
|
||||
* Get form values decoded
|
||||
@@ -211,7 +239,7 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultValues()
|
||||
public function setDefaultValues() : void
|
||||
{
|
||||
$this->approved = 0;
|
||||
}
|
||||
@@ -221,7 +249,7 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function saveVersion()
|
||||
public function saveVersion() : void
|
||||
{
|
||||
$this->save_version = 1;
|
||||
}
|
||||
@@ -231,19 +259,19 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
*
|
||||
* @param array $values
|
||||
*/
|
||||
public function set_form_values( array $values )
|
||||
public function set_form_values( array $values ) : void
|
||||
{
|
||||
foreach( $values as $k => $v )
|
||||
{
|
||||
if( $v instanceof \IPS\File )
|
||||
if( $v instanceof SystemFile )
|
||||
{
|
||||
$values[ $k ] = (string) $v;
|
||||
}
|
||||
elseif( \is_array( $v ) )
|
||||
elseif( is_array( $v ) )
|
||||
{
|
||||
foreach( $v as $_key => $_value )
|
||||
{
|
||||
if( $_value instanceof \IPS\File )
|
||||
if( $_value instanceof SystemFile )
|
||||
{
|
||||
$values[ $k ][ $_key ] = (string) $_value;
|
||||
}
|
||||
@@ -260,7 +288,7 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
*
|
||||
* @param array $ids
|
||||
*/
|
||||
public function set_record_deletions( array $ids )
|
||||
public function set_record_deletions( array $ids ) : void
|
||||
{
|
||||
$this->_data['record_deletions'] = json_encode( $ids );
|
||||
}
|
||||
@@ -268,9 +296,9 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
/**
|
||||
* Setter for download updated date
|
||||
*
|
||||
* @param $value New date
|
||||
* @param int $value New date
|
||||
*/
|
||||
public function set_updated( $value )
|
||||
public function set_updated( int $value ) : void
|
||||
{
|
||||
$this->date = $value;
|
||||
}
|
||||
@@ -279,13 +307,13 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
* Do Moderator Action
|
||||
*
|
||||
* @param string $action The action
|
||||
* @param \IPS\Member|NULL $member The member doing the action (NULL for currently logged in member)
|
||||
* @param Member|NULL $member The member doing the action (NULL for currently logged in member)
|
||||
* @param string|NULL $reason Reason (for hides)
|
||||
* @param bool $immediately Delete immediately
|
||||
* @return void
|
||||
* @throws \OutOfRangeException|\InvalidArgumentException|\RuntimeException
|
||||
* @throws OutOfRangeException|InvalidArgumentException|RuntimeException
|
||||
*/
|
||||
public function modAction( $action, \IPS\Member $member = NULL, $reason = NULL, $immediately = FALSE )
|
||||
public function modAction( string $action, ?Member $member = NULL, mixed $reason = NULL, bool $immediately=FALSE ): void
|
||||
{
|
||||
/* We always want to immediately delete these records instead of leaving them soft deleted */
|
||||
if( $action === 'delete' )
|
||||
@@ -294,15 +322,15 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
$this->delete();
|
||||
|
||||
/* Moderator log */
|
||||
\IPS\Session::i()->modLog( 'modlog__action_newversion_reject', array( (string) $file->url() => FALSE, $file->name => FALSE ), $file );
|
||||
Session::i()->modLog( 'modlog__action_newversion_reject', array( (string) $file->url() => FALSE, $file->name => FALSE ), $file );
|
||||
|
||||
if( \IPS\Dispatcher::hasInstance() AND !\IPS\Request::i()->isAjax() )
|
||||
if( Dispatcher::hasInstance() AND !Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->redirect( $file->url() );
|
||||
Output::i()->redirect( $file->url() );
|
||||
}
|
||||
elseif( \IPS\Request::i()->isAjax() )
|
||||
elseif( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json( 'OK' );
|
||||
Output::i()->json( 'OK' );
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -310,23 +338,22 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
elseif( $action == 'approve' OR $action == 'unhide' )
|
||||
{
|
||||
/* Moderator log */
|
||||
\IPS\Session::i()->modLog( 'modlog__action_newversion_approved', array( (string) $this->file()->url() => FALSE, $this->file()->name => FALSE ), $this->file() );
|
||||
\IPS\Api\Webhook::fire( 'downloads_new_version_approved', $this );
|
||||
Session::i()->modLog( 'modlog__action_newversion_approved', array( (string) $this->file()->url() => FALSE, $this->file()->name => FALSE ), $this->file() );
|
||||
Webhook::fire( 'downloads_new_version_approved', $this );
|
||||
}
|
||||
|
||||
return parent::modAction( $action, $member, $reason, $immediately );
|
||||
parent::modAction( $action, $member, $reason, $immediately );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Record
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete(): void
|
||||
{
|
||||
$ids = [];
|
||||
/* @note SELECT_FROM_WRITE_SERVER added in pull #6913 "We update record_hidden=0 then delete record_hidden=1 pretty quickly afterwards before the change had propagated to the reader." */
|
||||
foreach( \IPS\Db::i()->select( '*', 'downloads_files_records', [ 'record_file_id=? AND record_hidden=1', $this->file_id ], NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER ) as $record )
|
||||
foreach( Db::i()->select( '*', 'downloads_files_records', [ 'record_file_id=? AND record_hidden=1', $this->file_id ], NULL, NULL, NULL, NULL, Db::SELECT_FROM_WRITE_SERVER ) as $record )
|
||||
{
|
||||
switch( $record['record_type'] )
|
||||
{
|
||||
@@ -337,12 +364,12 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
try
|
||||
{
|
||||
if( $record['record_type'] == 'ssupload' AND !empty( $record['record_thumb'] )
|
||||
AND !\IPS\Db::i()->select( 'COUNT(record_id)', 'downloads_files_records', [ 'record_id<>? AND record_thumb=?', $record['record_id'], $record['record_thumb'] ] )->first() )
|
||||
AND !Db::i()->select( 'COUNT(record_id)', 'downloads_files_records', [ 'record_id<>? AND record_thumb=?', $record['record_id'], $record['record_thumb'] ] )->first() )
|
||||
{
|
||||
\IPS\File::get( 'downloads_Screenshots', $record['record_thumb'] )->delete();
|
||||
SystemFile::get( 'downloads_Screenshots', $record['record_thumb'] )->delete();
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception $e ){}
|
||||
break;
|
||||
case 'link':
|
||||
case 'sslink':
|
||||
@@ -351,7 +378,7 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
}
|
||||
}
|
||||
|
||||
if( \count( $ids ) )
|
||||
if( count( $ids ) )
|
||||
{
|
||||
$this->file()->deleteRecords( $ids );
|
||||
}
|
||||
@@ -362,22 +389,22 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
/**
|
||||
* Get related file object
|
||||
*
|
||||
* @return \IPS\downloads\File
|
||||
* @return File
|
||||
*/
|
||||
public function file()
|
||||
public function file(): File
|
||||
{
|
||||
return \IPS\downloads\File::load( $this->file_id );
|
||||
return File::load( $this->file_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unhide
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member doing the action (NULL for currently logged in member)
|
||||
* @param Member|NULL $member The member doing the action (NULL for currently logged in member)
|
||||
* @return void
|
||||
*/
|
||||
public function unhide( $member )
|
||||
public function unhide( ?Member $member=NULL ) : void
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$member = $member ?: Member::loggedIn();
|
||||
|
||||
if( $this->save_version )
|
||||
{
|
||||
@@ -385,7 +412,7 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
}
|
||||
|
||||
/* Remove hidden flag */
|
||||
\IPS\Db::i()->update( 'downloads_files_records', array( 'record_hidden' => 0 ), array( 'record_file_id=?', $this->file_id ) );
|
||||
Db::i()->update( 'downloads_files_records', array( 'record_hidden' => 0 ), array( 'record_file_id=?', $this->file_id ) );
|
||||
|
||||
$deletions = $this->record_deletions;
|
||||
$file = $this->file();
|
||||
@@ -398,21 +425,19 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'downloads_Screenshots', $url )->delete();
|
||||
SystemFile::get( 'downloads_Screenshots', $url )->delete();
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception $e ){}
|
||||
}
|
||||
|
||||
/* @note SELECT_FROM_WRITE_SERVER race condition */
|
||||
$file->size = \floatval( \IPS\Db::i()->select( 'SUM(record_size)', 'downloads_files_records', array( 'record_file_id=? AND record_type=? AND record_backup=0', $file->id, 'upload' ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first() );
|
||||
$file->size = floatval( Db::i()->select( 'SUM(record_size)', 'downloads_files_records', array( 'record_file_id=? AND record_type=? AND record_backup=0', $file->id, 'upload' ), NULL, NULL, NULL, NULL, Db::SELECT_FROM_WRITE_SERVER )->first() );
|
||||
|
||||
/* Work out the new primary screenshot */
|
||||
try
|
||||
{
|
||||
/* @note SELECT_FROM_WRITE_SERVER race condition */
|
||||
$file->primary_screenshot = \IPS\Db::i()->select( 'record_id', 'downloads_files_records', array( 'record_file_id=? AND ( record_type=? OR record_type=? ) AND record_backup=0 AND record_hidden=0', $file->id, 'ssupload', 'sslink' ), 'record_default DESC, record_id ASC', NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
$file->primary_screenshot = Db::i()->select( 'record_id', 'downloads_files_records', array( 'record_file_id=? AND ( record_type=? OR record_type=? ) AND record_backup=0 AND record_hidden=0', $file->id, 'ssupload', 'sslink' ), 'record_default DESC, record_id ASC', NULL, NULL, NULL, Db::SELECT_FROM_WRITE_SERVER )->first();
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
catch ( UnderflowException $e ) { }
|
||||
|
||||
/* The container may not have versions enabled */
|
||||
if( !empty( $this->form_values['file_version'] ) )
|
||||
@@ -445,12 +470,12 @@ class _PendingVersion extends \IPS\Content\Item implements \IPS\Content\Hideable
|
||||
/**
|
||||
* Save Changed Columns
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function save()
|
||||
public function save(): void
|
||||
{
|
||||
parent::save();
|
||||
|
||||
\IPS\File::claimAttachments( "downloads-{$this->file_id}-changelog", $this->file_id, $this->id, 'changelogpending' );
|
||||
SystemFile::claimAttachments( "downloads-{$this->file_id}-changelog", $this->file_id, $this->id, 'changelogpending' );
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief File Record Model
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Downloads
|
||||
* @since 9 Dec 2015
|
||||
*/
|
||||
|
||||
namespace IPS\downloads\File;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Record Model
|
||||
*/
|
||||
class _Record
|
||||
{
|
||||
|
||||
}
|
||||
@@ -12,43 +12,64 @@
|
||||
namespace IPS\downloads\File;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use BadMethodCallException;
|
||||
use IPS\Content\EditHistory;
|
||||
use IPS\Content\Embeddable;
|
||||
use IPS\Content\Filter;
|
||||
use IPS\Content\Hideable;
|
||||
use IPS\Content\Reactable;
|
||||
use IPS\Content\Reportable;
|
||||
use IPS\Content\Review as ContentReview;
|
||||
use IPS\Content\Shareable;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Http\Url\Exception;
|
||||
use IPS\Output;
|
||||
use IPS\Theme;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* File Review Model
|
||||
*/
|
||||
class _Review extends \IPS\Content\Review implements \IPS\Content\EditHistory, \IPS\Content\Hideable, \IPS\Content\Searchable, \IPS\Content\Embeddable
|
||||
class Review extends ContentReview implements Embeddable,
|
||||
Filter
|
||||
{
|
||||
use \IPS\Content\Reactable, \IPS\Content\Reportable;
|
||||
use Reactable,
|
||||
Reportable,
|
||||
Shareable,
|
||||
EditHistory,
|
||||
Hideable;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
protected static array $multitons;
|
||||
|
||||
/**
|
||||
* @brief [Content\Comment] Item Class
|
||||
*/
|
||||
public static $itemClass = 'IPS\downloads\File';
|
||||
public static ?string $itemClass = 'IPS\downloads\File';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'downloads_reviews';
|
||||
public static ?string $databaseTable = 'downloads_reviews';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'review_';
|
||||
public static string $databasePrefix = 'review_';
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
public static array $databaseColumnMap = array(
|
||||
'item' => 'fid',
|
||||
'author' => 'mid',
|
||||
'author_name' => 'author_name',
|
||||
@@ -69,60 +90,42 @@ class _Review extends \IPS\Content\Review implements \IPS\Content\EditHistory, \
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $application = 'downloads';
|
||||
public static string $application = 'downloads';
|
||||
|
||||
/**
|
||||
* @brief Title
|
||||
*/
|
||||
public static $title = 'downloads_file_review';
|
||||
public static string $title = 'downloads_file_review';
|
||||
|
||||
/**
|
||||
* @brief Icon
|
||||
*/
|
||||
public static $icon = 'download';
|
||||
public static string $icon = 'download';
|
||||
|
||||
/**
|
||||
* @brief [Content] Key for hide reasons
|
||||
*/
|
||||
public static $hideLogKey = 'downloads-files-rev';
|
||||
public static ?string $hideLogKey = 'downloads-files-rev';
|
||||
|
||||
/**
|
||||
* Get URL for doing stuff
|
||||
*
|
||||
* @param string|NULL $action Action
|
||||
* @return \IPS\Http\Url
|
||||
* @throws \BadMethodCallException
|
||||
* @throws \IPS\Http\Url\Exception
|
||||
* @return Url
|
||||
* @throws BadMethodCallException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function url( $action='find' )
|
||||
public function url( ?string $action='find' ): Url
|
||||
{
|
||||
return parent::url( $action )->setQueryString( 'tab', 'reviews' );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get snippet HTML for search result display
|
||||
*
|
||||
* @param array $indexData Data from the search index
|
||||
* @param array $authorData Basic data about the author. Only includes columns returned by \IPS\Member::columnsForPhoto()
|
||||
* @param array $itemData Basic data about the item. Only includes columns returned by item::basicDataColumns()
|
||||
* @param array|NULL $containerData Basic data about the container. Only includes columns returned by container::basicDataColumns()
|
||||
* @param array $reputationData Array of people who have given reputation and the reputation they gave
|
||||
* @param int|NULL $reviewRating If this is a review, the rating
|
||||
* @param string $view 'expanded' or 'condensed'
|
||||
* @return callable
|
||||
*/
|
||||
public static function searchResultSnippet( array $indexData, array $authorData, array $itemData, ?array $containerData, array $reputationData, $reviewRating, $view )
|
||||
{
|
||||
return \IPS\downloads\File\Comment::searchResultSnippet( $indexData, $authorData, $itemData, $containerData, $reputationData, $reviewRating, $view );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reaction type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function reactionType()
|
||||
public static function reactionType(): string
|
||||
{
|
||||
return 'review_id';
|
||||
}
|
||||
@@ -133,9 +136,9 @@ class _Review extends \IPS\Content\Review implements \IPS\Content\EditHistory, \
|
||||
* @param array $params Additional parameters to add to URL
|
||||
* @return string
|
||||
*/
|
||||
public function embedContent( $params )
|
||||
public function embedContent( array $params ): string
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'embed.css', 'downloads', 'front' ) );
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'downloads' )->embedFileReview( $this, $this->item(), $this->url()->setQueryString( $params ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'embed.css', 'downloads', 'front' ) );
|
||||
return Theme::i()->getTemplate( 'global', 'downloads' )->embedFileReview( $this, $this->item(), $this->url()->setQueryString( $params ) );
|
||||
}
|
||||
}
|
||||
@@ -12,25 +12,36 @@
|
||||
namespace IPS\downloads\Form;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DomainException;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Helpers\Form\FormAbstract;
|
||||
use IPS\Http\Request\Exception;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form helper class for linked screenshots
|
||||
*/
|
||||
class _LinkedScreenshots extends \IPS\Helpers\Form\FormAbstract
|
||||
class LinkedScreenshots extends FormAbstract
|
||||
{
|
||||
/**
|
||||
* Validate
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \DomainException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws DomainException
|
||||
* @return TRUE
|
||||
*/
|
||||
public function validate()
|
||||
public function validate(): bool
|
||||
{
|
||||
parent::validate();
|
||||
|
||||
@@ -38,7 +49,7 @@ class _LinkedScreenshots extends \IPS\Helpers\Form\FormAbstract
|
||||
{
|
||||
foreach( $this->formatValue() as $value )
|
||||
{
|
||||
$value = \IPS\Http\Url::createFromString( $value );
|
||||
$value = Url::createFromString( $value );
|
||||
|
||||
try
|
||||
{
|
||||
@@ -50,16 +61,18 @@ class _LinkedScreenshots extends \IPS\Helpers\Form\FormAbstract
|
||||
{
|
||||
if ( !preg_match( '/^image\/.+$/i', $contentType ) )
|
||||
{
|
||||
throw new \DomainException( 'form_url_bad_mime' );
|
||||
throw new DomainException( 'form_url_bad_mime' );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \IPS\Http\Request\Exception $e )
|
||||
catch ( Exception $e )
|
||||
{
|
||||
throw new \DomainException( 'form_url_error' );
|
||||
throw new DomainException( 'form_url_error' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,16 +80,16 @@ class _LinkedScreenshots extends \IPS\Helpers\Form\FormAbstract
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function html()
|
||||
public function html(): string
|
||||
{
|
||||
if ( \is_array( $this->value ) and !isset( $this->value['values'] ) )
|
||||
if ( is_array( $this->value ) and !isset( $this->value['values'] ) )
|
||||
{
|
||||
$value = array( 'values' => $this->value, 'default' => \IPS\Request::i()->screenshots_primary_screenshot );
|
||||
$value = array( 'values' => $this->value, 'default' => Request::i()->screenshots_primary_screenshot );
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = $this->value;
|
||||
}
|
||||
return \IPS\Theme::i()->getTemplate( 'submit', 'downloads', 'front' )->linkedScreenshotField( $this->name, $value );
|
||||
return Theme::i()->getTemplate( 'submit', 'downloads', 'front' )->linkedScreenshotField( $this->name, $value );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user