Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

@@ -12,62 +12,68 @@
namespace IPS\cms\Templates;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Db;
use IPS\Http\Url\Friendly;
use IPS\Patterns\ActiveRecord;
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;
}
/**
* @brief Template Model
*/
class _Container extends \IPS\Patterns\ActiveRecord
class Container extends ActiveRecord
{
/**
* @brief [ActiveRecord] Multiton Store
*/
protected static $multitons = array();
protected static array $multitons = array();
/**
* @brief [ActiveRecord] Database Prefix
*/
public static $databasePrefix = 'container_';
public static string $databasePrefix = 'container_';
/**
* @brief [ActiveRecord] ID Database Table
*/
public static $databaseTable = 'cms_containers';
public static ?string $databaseTable = 'cms_containers';
/**
* @brief [ActiveRecord] ID Database Column
*/
public static $databaseColumnId = 'id';
public static string $databaseColumnId = 'id';
/**
* @brief [ActiveRecord] Database ID Fields
*/
protected static $databaseIdFields = array( 'container_key' );
protected static array $databaseIdFields = array( 'container_key' );
/**
* @brief [ActiveRecord] Multiton Map
*/
protected static $multitonMap = array();
protected static array $multitonMap = array();
/**
* @brief Have fetched all?
*/
protected static $gotAll = FALSE;
protected static bool $gotAll = FALSE;
/**
* Return all containers
*
* @return array
*/
public static function containers()
public static function containers() : array
{
if ( ! static::$gotAll )
{
foreach( \IPS\Db::i()->select( '*', static::$databaseTable ) as $container )
foreach( Db::i()->select( '*', static::$databaseTable ) as $container )
{
static::$multitons[ $container['container_id'] ] = static::constructFromData( $container );
}
@@ -84,7 +90,7 @@ class _Container extends \IPS\Patterns\ActiveRecord
* @param string $type Type of container (template_block, page, etc)
* @return array of Container objects
*/
public static function getByType( $type )
public static function getByType( string $type ) : array
{
$return = array();
static::containers();
@@ -109,18 +115,20 @@ class _Container extends \IPS\Patterns\ActiveRecord
* Add a new container
*
* @param array $container Template Data
* @return object \IPS\cms\Templates
* @return static
*/
public static function add( $container )
public static function add( array $container ) : static
{
$newContainer = new static;
$newContainer->_new = TRUE;
$newContainer->name = $container['name'];
$newContainer->type = $container['type'];
$newContainer->save();
/* Create a unique key */
if ( empty( $newContainer->key ) )
{
$newContainer->key = 'template__' . \IPS\Http\Url\Friendly::seoTitle( $newContainer->name ) . '.' . $newContainer->id;
$newContainer->key = 'template__' . Friendly::seoTitle( $newContainer->name ) . '.' . $newContainer->id;
$newContainer->save();
}