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,35 +12,39 @@
|
||||
namespace IPS\cms\extensions\core\OutputPlugins;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\cms\Databases;
|
||||
use IPS\Extensions\OutputPluginsAbstract;
|
||||
use IPS\Member;
|
||||
use LogicException;
|
||||
use OutofRangeException;
|
||||
use function defined;
|
||||
use function is_numeric;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Template Plugin - Content: Database
|
||||
*/
|
||||
class _Database
|
||||
class Database extends OutputPluginsAbstract
|
||||
{
|
||||
/**
|
||||
* @brief Can be used when compiling CSS
|
||||
*/
|
||||
public static $canBeUsedInCss = FALSE;
|
||||
|
||||
/**
|
||||
* @brief Record how many database tags there are per page
|
||||
*/
|
||||
public static $count = 0;
|
||||
public static int $count = 0;
|
||||
|
||||
/**
|
||||
* Run the plug-in
|
||||
*
|
||||
* @param string $data The initial data from the tag
|
||||
* @param array $options Array of options
|
||||
* @return string Code to eval
|
||||
* @return string|array Code to eval
|
||||
*/
|
||||
public static function runPlugin( $data, $options )
|
||||
public static function runPlugin( string $data, array $options ): string|array
|
||||
{
|
||||
if ( isset( $options['category'] ) )
|
||||
{
|
||||
@@ -53,43 +57,41 @@ class _Database
|
||||
/**
|
||||
* Do any processing before a page is added/saved
|
||||
*
|
||||
* @param string $data The initial data from the tag
|
||||
* @param array $options Array of options
|
||||
* @param object $page Page being edited/saved
|
||||
* @param string $data The initial data from the tag
|
||||
* @param array $options Array of options
|
||||
* @param object $page Page being edited/saved
|
||||
* @return void
|
||||
*/
|
||||
public static function preSaveProcess( $data, $options, $page )
|
||||
public static function preSaveProcess( string $data, array $options, object $page ) : void
|
||||
{
|
||||
/* Keep a count of databases used so far */
|
||||
static::$count++;
|
||||
|
||||
if ( static::$count > 1 )
|
||||
{
|
||||
throw new \LogicException( \IPS\Member::loggedIn()->language()->addToStack('cms_err_db_already_on_page') );
|
||||
throw new LogicException( Member::loggedIn()->language()->addToStack('cms_err_db_already_on_page') );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do any processing after a page is added/saved
|
||||
*
|
||||
* @param string $data The initial data from the tag
|
||||
* @param array $options Array of options
|
||||
* @param object $page Page being edited/saved
|
||||
* @param string $data The initial data from the tag
|
||||
* @param array $options Array of options
|
||||
* @param object $page Page being edited/saved
|
||||
* @return void
|
||||
*/
|
||||
public static function postSaveProcess( $data, $options, $page )
|
||||
public static function postSaveProcess( string $data, array $options, object $page ) : void
|
||||
{
|
||||
$database = NULL;
|
||||
|
||||
try
|
||||
{
|
||||
if ( \is_numeric( $data ) )
|
||||
if ( is_numeric( $data ) )
|
||||
{
|
||||
$database = \IPS\cms\Databases::load( $data );
|
||||
$database = Databases::load( $data );
|
||||
}
|
||||
else
|
||||
{
|
||||
$database = \IPS\cms\Databases::load( $data, 'database_key' );
|
||||
$database = Databases::load( $data, 'database_key' );
|
||||
}
|
||||
|
||||
if ( $database->id AND $page->id )
|
||||
@@ -98,13 +100,13 @@ class _Database
|
||||
{
|
||||
$page->mapToDatabase( $database->id );
|
||||
}
|
||||
catch( \LogicException $ex )
|
||||
catch( LogicException $ex )
|
||||
{
|
||||
throw new \LogicException( $ex->getMessage() );
|
||||
throw new LogicException( $ex->getMessage() );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \OutofRangeException $ex ) { }
|
||||
catch( OutofRangeException $ex ) { }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user