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

+46 -35
View File
@@ -12,90 +12,101 @@
namespace IPS\cms\Blocks;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Helpers\Form;
use IPS\Helpers\Form\Node;
use IPS\Helpers\Form\Text;
use IPS\Http\Url;
use IPS\Member;
use IPS\Node\Model;
use IPS\Request;
use function defined;
use function get_called_class;
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 Block Container Model
*/
class _Container extends \IPS\Node\Model
class Container extends Model
{
/**
* @brief [ActiveRecord] Multiton Store
*/
protected static $multitons;
protected static array $multitons;
/**
* @brief [ActiveRecord] Database Table
*/
public static $databaseTable = 'cms_containers';
public static ?string $databaseTable = 'cms_containers';
/**
* @brief [ActiveRecord] Database Prefix
*/
public static $databasePrefix = 'container_';
public static string $databasePrefix = 'container_';
/**
* @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 [Node] Parent ID Database Column
*/
public static $databaseColumnParent = 'parent_id';
public static ?string $databaseColumnParent = 'parent_id';
/**
* @brief [Node] Parent ID Root Value
* @note This normally doesn't need changing though some legacy areas use -1 to indicate a root node
*/
public static $databaseColumnParentRootValue = 0;
public static int $databaseColumnParentRootValue = 0;
/**
* @brief [Node] Order Database Column
*/
public static $databaseColumnOrder = 'order';
public static ?string $databaseColumnOrder = 'order';
/**
* @brief [Node] Node Title
*/
public static $nodeTitle = '';
public static string $nodeTitle = '';
/**
* @brief [Node] Subnode class
*/
public static $subnodeClass = 'IPS\cms\Blocks\Block';
public static ?string $subnodeClass = 'IPS\cms\Blocks\Block';
/**
* @brief [Node] Show forms modally?
*/
public static $modalForms = TRUE;
public static bool $modalForms = TRUE;
/**
* @brief [Node] Sortable?
*/
public static $nodeSortable = TRUE;
public static bool $nodeSortable = TRUE;
/**
* [Node] Get Title
*
* @return string|null
* @return string
*/
protected function get__title()
protected function get__title(): string
{
return $this->name;
}
@@ -104,12 +115,12 @@ class _Container extends \IPS\Node\Model
* Fetch All Root Nodes
*
* @param string|NULL $permissionCheck The permission key to check for or NULl to not check permissions
* @param \IPS\Member|NULL $member The member to check permissions for or NULL for the currently logged in member
* @param Member|NULL $member The member to check permissions for or NULL for the currently logged in member
* @param mixed $where Additional WHERE clause
* @param array|NULL $limit Limit/offset to use, or NULL for no limit (default)
* @return array
*/
public static function roots( $permissionCheck='view', $member=NULL, $where=array(), $limit=NULL )
public static function roots( ?string $permissionCheck='view', Member $member=NULL, mixed $where=array(), array $limit=NULL ): array
{
return parent::roots( $permissionCheck, $member, array( array( 'container_type=?', 'block' ) ), $limit );
}
@@ -117,11 +128,11 @@ class _Container extends \IPS\Node\Model
/**
* [Node] Get buttons to display in tree
*
* @param string $url Base URL
* @param bool $subnode Is this a subnode?
* @return array
* @param Url $url Base URL
* @param bool $subnode Is this a subnode?
* @return array
*/
public function getButtons( $url, $subnode=FALSE )
public function getButtons( Url $url, bool $subnode=FALSE ): array
{
$buttons = parent::getButtons( $url, $subnode );
$return = array();
@@ -135,7 +146,7 @@ class _Container extends \IPS\Node\Model
{
$buttons['add']['icon'] = 'folder-open';
$buttons['add']['title'] = 'content_block_cat_add';
$buttons['add']['data'] = array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('content_block_cat_add') );
$buttons['add']['data'] = array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('content_block_cat_add') );
$buttons['add']['link'] = $url->setQueryString( array( 'subnode' => 0, 'do' => 'form', 'parent' => $this->_id ) );
$buttons['add_block'] = array(
@@ -172,9 +183,9 @@ class _Container extends \IPS\Node\Model
/**
* [Node] Does the currently logged in user have permission to delete this node?
*
* @return bool
* @return bool
*/
public function canDelete()
public function canDelete(): bool
{
if ( $this->key == 'block_custom' OR $this->key == 'block_plugins' )
{
@@ -187,17 +198,17 @@ class _Container extends \IPS\Node\Model
/**
* [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
{
/* Build form */
$form->add( new \IPS\Helpers\Form\Text( 'container_name', $this->id ? $this->name : '', TRUE, array( 'maxLength' => 64 ) ) );
$form->add( new Text( 'container_name', $this->id ? $this->name : '', TRUE, array( 'maxLength' => 64 ) ) );
$class = \get_called_class();
$class = get_called_class();
$form->add( new \IPS\Helpers\Form\Node( 'container_parent_id', $this->parent_id ? $this->parent_id : 0, FALSE, array(
$form->add( new Node( 'container_parent_id', $this->parent_id ? $this->parent_id : 0, FALSE, array(
'class' => '\IPS\cms\Blocks\Container',
'zeroVal' => 'node_no_parent',
'permissionCheck' => function( $node ) use ( $class )
@@ -207,7 +218,7 @@ class _Container extends \IPS\Node\Model
return FALSE;
}
return !isset( \IPS\Request::i()->id ) or ( $node->id != \IPS\Request::i()->id and !$node->isChildOf( $node::load( \IPS\Request::i()->id ) ) );
return !isset( Request::i()->id ) or ( $node->id != Request::i()->id and !$node->isChildOf( $node::load( Request::i()->id ) ) );
}
) ) );
}
@@ -218,7 +229,7 @@ class _Container extends \IPS\Node\Model
* @param array $values Values from the form
* @return array
*/
public function formatFormValues( $values )
public function formatFormValues( array $values ): array
{
if ( isset( $values['container_parent_id'] ) AND ( ! empty( $values['container_parent_id'] ) OR $values['container_parent_id'] === 0 ) )
{
@@ -239,7 +250,7 @@ class _Container extends \IPS\Node\Model
* @param mixed $where Where clause
* @return array
*/
public static function search( $column, $query, $order, $where=array() )
public static function search( string $column, string $query, ?string $order=NULL, mixed $where=array() ): array
{
if ( $column === '_title' )
{