Version 5.0.0 beta 11.1

This commit is contained in:
Neo committed 2025-12-19 18:00:22 -08:00
1 parent 264eeb97e0
commit 90e8c7e903
466 files changed
+7796 -2394

No files matched your search

+106 -39
View File
@@ -16,6 +16,7 @@ namespace IPS\Widget;
use Exception;
use IPS\Application;
use IPS\cms\widgets\Database as DatabaseWidget;
use IPS\Db;
use IPS\Lang;
use IPS\Member;
@@ -196,19 +197,33 @@ class Area
$this->parentData = $parent->toArray( false );
$this->parentData['styles'] = $parent->styles();
$this->depth = $parent->depth + 1;
}
if( isset( $data['widgets'] ) and count( $data['widgets'] ) )
{
/* If this has widgets, set the orientation for this level */
if( isset( $data['orientation'] ) )
/* Widgets don't go on the root level, they go one level down */
if( isset( $data['widgets'] ) and count( $data['widgets'] ) )
{
$this->setOption( 'orientation', $data['orientation'] );
}
/* If this has widgets, set the orientation for this level */
if( isset( $data['orientation'] ) )
{
$this->setOption( 'orientation', $data['orientation'] );
}
foreach( $data['widgets'] as $key => $widget )
{
$this->addWidget( $widget );
}
}
}
elseif( empty( $data['children'] ) and !empty( $data['widgets'] ) )
{
/* If we have no children, and we have widgets at the root, move them one level down,
with each widget as a separate child. */
$data['children'] = [];
foreach( $data['widgets'] as $key => $widget )
{
$this->addWidget( $widget );
$data['children'][] = [
'otherOptions' => $data['otherOptions'],
'widgets' => [ $key => $widget ]
];
}
}
@@ -370,6 +385,35 @@ class Area
return !$this->isRoot() and !$this->isWidget();
}
/**
* Check if this area uses no box styles
*
* @return bool
*/
public function noBoxStyles() : bool
{
if ( !$this->isWidget() )
{
return false;
}
if ( empty( $this->options['noBox'] ) )
{
return false;
}
try
{
foreach ( $this->widgets as $widgetData )
{
$widget = is_array( $widgetData ) ? Widget::createWidgetFromStoredData( $widgetData ) : null;
return $widget instanceof Widget and $widget->allowNoBox;
}
}
catch ( \Exception $e ) {}
return false;
}
/**
* Whether we should treat this area as an "area widget". This means that it's a wrapper for 1 widget and the widget supports different layouts
*
@@ -454,6 +498,7 @@ class Area
{
$classList[] = 'cWidgetContainer--noImages';
}
/* Grab the configuration from the first widget in this area.
There should be only one widget at this point.
We use this to get the responsive classes so that we can show//hide
@@ -469,6 +514,13 @@ class Area
$classList[] = 'ipsResponsive_hide' . $device;
}
}
/* Are we removing the widget */
if ( $this->noBoxStyles() )
{
$classList[] = 'cWidgetContainer--nobox';
}
break;
}
}
@@ -476,6 +528,37 @@ class Area
return $classList;
}
/**
* Return any CSS classes that should be applied on the widget level
*
* @param Widget $widget
* @return array
*/
public function widgetClasses( Widget $widget ) : array
{
if( !$this->isWidget() )
{
return [];
}
/* Get anything configured on the widget level.
3rd party devs may wish to add classes based on their own logic. */
$classList = $widget->getWrapperClasses();
if( !( $widget instanceof DatabaseWidget ) )
{
$classList[] = 'ipsWidget--' . $this->orientation();
}
/* Additional classes based on area attributes */
if( $this->noBoxStyles() )
{
$classList[] = 'ipsWidget--transparent';
}
return array_unique( $classList );
}
/**
* @return array
*/
@@ -559,42 +642,26 @@ class Area
{
$obj = new static( [], $id );
/* If this is a reaserved area, we don't allow nesting, so put the widgets straight in here */
if( in_array( $id, static::$reservedAreas ) )
$child = new static( [
'otherOptions' => [
'gapSize' => 20
]
], $id, $obj );
/* Set any custom options passed in */
foreach( $options as $option => $value )
{
foreach( $options as $option => $value )
{
$obj->setOption( $option, $value );
}
foreach( $widgets as $widget )
{
$obj->addWidget( $widget );
}
$child->setOption( $option, $value );
}
else
/* Add them individually so that they get cleaned up and defined properly */
foreach( $widgets as $widget )
{
$child = new static( [
'otherOptions' => [
'gapSize' => 20
]
], $id, $obj );
/* Set any custom options passed in */
foreach( $options as $option => $value )
{
$child->setOption( $option, $value );
}
/* Add them individually so that they get cleaned up and defined properly */
foreach( $widgets as $widget )
{
$child->addWidget( $widget );
}
$obj->addChild( $child );
$child->addWidget( $widget );
}
$obj->addChild( $child );
return $obj;
}