Version 5.0.6

This commit is contained in:
Neo committed 2025-12-19 18:55:49 -08:00
1 parent a3a4a9ccbd
commit b89858b2ff
1214 files changed
+92828 -14859

No files matched your search

+69 -34
View File
@@ -34,6 +34,7 @@ use IPS\Dispatcher\Front;
use IPS\File;
use IPS\Helpers\Form;
use IPS\Helpers\Form\CheckboxSet;
use IPS\Helpers\Form\Codemirror;
use IPS\Helpers\Form\Node;
use IPS\Helpers\Form\Radio;
use IPS\Helpers\Form\Select;
@@ -207,16 +208,6 @@ class Page extends Model implements Permissions
*/
public static array $defaultPage = array();
/**
* @brief Pre save flag
*/
const PRE_SAVE = 1;
/**
* @brief Post save flag
*/
const POST_SAVE = 2;
/**
* Set Default Values
*
@@ -626,6 +617,7 @@ class Page extends Model implements Permissions
*/
static public function formElements( ?Page $item=NULL ) : array
{
$pageType = Request::i()->page_type ?? $item?->type;
$return = array();
$return['tab_details'] = array( 'content_page_form_tab__details', NULL, NULL, 'ipsForm--horizontal' );
@@ -700,12 +692,7 @@ class Page extends Model implements Permissions
/* List of templates */
$return['page_wrapper_template'] = new Select( 'page_wrapper_template', ($item?->wrapper_template), null, array(
'options' => $wrapperTemplates
), function( $val ){
if( $val == '_none_' and !Request::i()->page_ipb_wrapper )
{
throw new InvalidArgumentException('form_required');
}
}, NULL, Theme::i()->getTemplate( 'pages', 'cms', 'admin' )->previewTemplateLink(), 'page_wrapper_template' );
), null, NULL, Theme::i()->getTemplate( 'pages', 'cms', 'admin' )->previewTemplateLink(), 'page_wrapper_template' );
if ( count( Theme::themes() ) > 1 )
{
@@ -766,6 +753,30 @@ class Page extends Model implements Permissions
$return['page_includes_css'] = new CheckboxSet( 'page_includes_css', $item ? $item->css_includes : FALSE, FALSE, array( 'options' => $cssincludes, 'multiple' => true ), NULL, NULL, NULL, 'page_includes_css' );
}
}
if ( $pageType == 'html' )
{
$return['tab_content'] = array( 'content_page_form_tab__content', NULL, NULL, 'ipsForm_vertical' );
$tagSource = Url::internal( "app=cms&module=pages&controller=ajax&do=loadTags" );
if ( $item )
{
$tagSource = $tagSource->setQueryString( 'pageId', $item->id );
}
$return['page_content'] = new Codemirror( 'page_content', $item ? htmlentities( $item->content, ENT_DISALLOWED, 'UTF-8' ) : NULL, FALSE, array( 'tagSource' => $tagSource, 'height' => 600, 'codeMode' => true, 'codeModeAllowedLanguages' => [ 'txt', 'ipsphtml' ] ), function( $val )
{
/* Test */
try
{
Theme::checkTemplateSyntax( $val );
}
catch( LogicException $e )
{
throw new LogicException('cms_page_error_bad_syntax');
}
}, NULL, NULL, 'page_content' );
}
$return['tab_meta'] = array( 'content_page_form_tab__meta', NULL, NULL, 'ipsForm--horizontal ipsForm--page-meta' );
$return['page_title'] = new Text( 'page_title', $item ? $item->title : '', FALSE, array( 'maxLength' => 64 ), NULL, NULL, NULL, 'page_title' );
@@ -791,12 +802,13 @@ class Page extends Model implements Permissions
* Create a new page from a form. Pretty much what the function says.
*
* @param array $values Array of form values
* @param string|null $pageType Type of page. 'html' or 'builder'
* @return Page object
*/
static public function createFromForm( array $values ) : static
static public function createFromForm( array $values, ?string $pageType='builder' ) : static
{
$page = new self;
$page->type = 'builder';
$page->type = $pageType;
$page->save();
$page->saveForm( $page->formatFormValues( $values ) );
@@ -1375,16 +1387,17 @@ class Page extends Model implements Permissions
if ( isset( $buttons['edit'] ) )
{
$return['builder'] = array(
/* Builder pages open the page editor */
if( $this->type == 'builder' )
{
$return['builder'] = array(
'icon' => 'magic',
'title' => 'content_launch_page_builder',
'link' => $this->url()->setQueryString( array( '_blockManager' => 1 ) ),
'target' => '_blank'
);
}
if ( isset( $buttons['edit'] ) )
{
);
}
/* Is this a database page? We don't allow editing from here, use the database URL instead */
try
{
@@ -1416,7 +1429,7 @@ class Page extends Model implements Permissions
$return['edit'] = $buttons['edit'];
}
if ( Member::loggedIn()->hasAcpRestriction( 'cms', 'pages', 'page_edit' ) )
if ( Member::loggedIn()->hasAcpRestriction( 'cms', 'pages', 'page_edit' ) and !$this->default )
{
$return['default'] = array(
'icon' => $this->default ? 'star' : 'regular fa-star',
@@ -1462,6 +1475,16 @@ class Page extends Model implements Permissions
*/
public function form( Form &$form ) : void
{
/* Build form */
if ( ! $this->id )
{
$form->hiddenValues['page_type'] = $pageType = Request::i()->page_type;
}
else
{
$pageType = $this->type;
}
/* We shut off the main class and add it per-tab to allow the content field to look good */
$form->class = '';
@@ -1528,13 +1551,16 @@ class Page extends Model implements Permissions
$form->add( new CheckboxSet( 'menu_manager_access', '*', NULL, array( 'multiple' => TRUE, 'options' => $groups, 'unlimited' => '*', 'unlimitedLang' => 'everyone', 'impliedUnlimited' => TRUE ), NULL, NULL, NULL, 'menu_manager_access' ) );
}
if ( $this->id )
if( $pageType == 'builder' )
{
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core', 'global' )->message( Member::loggedIn()->language()->addToStack('content_acp_page_builder_msg_edit', TRUE, array( 'sprintf' => array( $this->url() ) ) ), 'information', NULL, FALSE );
}
else
{
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core', 'global' )->message( Member::loggedIn()->language()->addToStack('content_acp_page_builder_msg_new' ), 'information', NULL, FALSE );
if ( $this->id )
{
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core', 'global' )->message( Member::loggedIn()->language()->addToStack('content_acp_page_builder_msg_edit', TRUE, array( 'sprintf' => array( $this->url() ) ) ), 'information', NULL, FALSE );
}
else
{
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core', 'global' )->message( Member::loggedIn()->language()->addToStack('content_acp_page_builder_msg_new' ), 'information', NULL, FALSE );
}
}
if( $this->id )
@@ -1557,7 +1583,7 @@ class Page extends Model implements Permissions
if ( ! $this->id )
{
$this->type = 'builder';
$this->type = Request::i()->page_type ?? 'builder';
$this->save();
}
@@ -2072,7 +2098,7 @@ class Page extends Model implements Permissions
Output::i()->jsVars['pageID'] = $this->id;
/* Display */
if ( $this->ipb_wrapper )
if ( $this->ipb_wrapper or $this->type == 'builder' )
{
$nav = array();
Output::i()->title = $this->getHtmlTitle();
@@ -2089,6 +2115,9 @@ class Page extends Model implements Permissions
}
}
/* Load the global areas */
Output::i()->loadGlobalAreas();
/* Make sure we initialize the main area */
Output::i()->sidebar['widgets']['col1'] = [];
@@ -2138,7 +2167,8 @@ class Page extends Model implements Permissions
Output::i()->buildMetaTags();
/* Set up the content */
$content = Theme::i()->getTemplate( 'pages', 'cms' )->globalWrap( null, $content ?: $this->getPageContent(), $this );
$content = $content ?? $this->getPageContent();
//$content = Theme::i()->getTemplate( 'pages', 'cms' )->globalWrap( null, $content ?: $this->getPageContent(), $this );
/* Ensure MFA pop up shows */
$content .= ( Front::i()->checkMfa( TRUE ) ?: '' );
@@ -2170,6 +2200,11 @@ class Page extends Model implements Permissions
*/
protected function getPageContent() : string
{
if( $this->type == 'html' )
{
return $this->getHtmlContent();
}
$widgets = [];
foreach( Db::i()->select( '*', 'cms_page_widget_areas', [ 'area_page_id=?', $this->id ] ) as $item )