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,36 +12,46 @@
|
||||
namespace IPS\{app}\extensions\core\CommunityEnhancements;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Extensions\CommunityEnhancementsAbstract;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member as MemberClass;
|
||||
use IPS\Output;
|
||||
use IPS\Theme;
|
||||
use LogicException;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Community Enhancement
|
||||
*/
|
||||
class _{class}
|
||||
class {class} extends CommunityEnhancementsAbstract
|
||||
{
|
||||
/**
|
||||
* @brief Enhancement is enabled?
|
||||
*/
|
||||
public $enabled = FALSE;
|
||||
public bool $enabled = FALSE;
|
||||
|
||||
/**
|
||||
* @brief IPS-provided enhancement?
|
||||
*/
|
||||
public $ips = FALSE;
|
||||
public bool $ips = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Enhancement has configuration options?
|
||||
*/
|
||||
public $hasOptions = TRUE;
|
||||
public bool $hasOptions = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Icon data
|
||||
*/
|
||||
public $icon = "";
|
||||
public string $icon = "";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@@ -50,7 +60,7 @@ class _{class}
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//$this->enabled = \IPS\Settings::i()->xxxxxx;
|
||||
//$this->enabled = Settings::i()->xxxxxx;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,9 +68,9 @@ class _{class}
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function edit()
|
||||
public function edit() : void
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
//$form->add( ... );
|
||||
if ( $form->values() )
|
||||
{
|
||||
@@ -69,24 +79,24 @@ class _{class}
|
||||
$this->testSettings();
|
||||
$form->saveAsSettings();
|
||||
|
||||
\IPS\Output::i()->inlineMessage = \IPS\Member::loggedIn()->language()->addToStack('saved');
|
||||
Output::i()->inlineMessage = MemberClass::loggedIn()->language()->addToStack('saved');
|
||||
}
|
||||
catch ( \LogicException $e )
|
||||
catch ( LogicException $e )
|
||||
{
|
||||
$form->error = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
Output::i()->sidebar['actions'] = array(
|
||||
'help' => array(
|
||||
'title' => 'help',
|
||||
'icon' => 'question-circle',
|
||||
'link' => \IPS\Http\Url::internal( "http://www.example.com" ),
|
||||
'link' => Url::internal( "http://www.example.com" ),
|
||||
'target' => '_blank'
|
||||
),
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'enhancements__{app}_{class}', $form );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'enhancements__{app}_{class}', $form );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,29 +104,26 @@ class _{class}
|
||||
*
|
||||
* @param $enabled bool Enable/Disable
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function toggle( $enabled )
|
||||
public function toggle( bool $enabled ) : void
|
||||
{
|
||||
if ( $enabled )
|
||||
{
|
||||
$this->testSettings();
|
||||
}
|
||||
|
||||
//\IPS\Settings::i()->changeValues( array( 'xxxxxx' => $enabled ) );
|
||||
//Settings::i()->changeValues( array( 'xxxxxx' => $enabled ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Settings
|
||||
*
|
||||
* @return void
|
||||
* @throws \LogicException
|
||||
* @throws LogicException
|
||||
*/
|
||||
protected function testSettings()
|
||||
protected function testSettings() : void
|
||||
{
|
||||
if ( FALSE )
|
||||
{
|
||||
throw new \LogicException( 'error' );
|
||||
}
|
||||
throw new LogicException( 'error' );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user