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,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