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

@@ -76,7 +76,6 @@ class Categories extends Model implements Permissions
ClubContainer
{
ClubContainer::clubAcpTitle as public _clubAcpTitle;
ClubContainer::clubForm as public _clubForm;
ClubContainer::_saveClubForm as public _saveClubFormParent;
ClubContainer::canBeAddedToClub as public _canBeAddedToClub;
}
@@ -361,11 +360,12 @@ class Categories extends Model implements Permissions
* @param Club $club
* @return void
*/
public function clubForm( Form $form, Club $club ): void
public function _clubForm( Form $form, Club $club ): void
{
$this->database_id = static::$customDatabaseId;
static::_clubForm( $form, $club );
$itemClass = static::$contentItemClass;
$form->add( new Text( 'club_node_name', $this->_id ? $this->_title : Member::loggedIn()->language()->addToStack( static::clubFrontTitle() ), TRUE, array( 'maxLength' => 255 ) ) );
if( $club->type != Club::TYPE_PUBLIC )
{
@@ -1618,9 +1618,9 @@ class Categories extends Model implements Permissions
/**
* [Node] Get number of unapproved content items
*
* @return int
* @return int|null
*/
protected function get__unapprovedItems() : int
protected function get__unapprovedItems() : ?int
{
return $this->records_queued;
}
@@ -1701,7 +1701,7 @@ class Categories extends Model implements Permissions
if ( $this->template_listing AND static::database()->use_categories )
{
$data = json_decode( $this->template_listing, true );
return ( $data['layout'] == 'custom' ) ? $data['template'] : 'listing';
return ( $data['layout'] == 'custom' and $data['template'] ) ? $data['template'] : 'listing';
}
return static::database()->template_listing;
@@ -905,7 +905,7 @@ class Databases extends Model implements Permissions
*/
public function get_template_form() : string
{
return $this->display_settings['form']['template'];
return $this->display_settings['form']['template'] ?? 'form';
}
/**
@@ -913,7 +913,7 @@ class Databases extends Model implements Permissions
*/
public function get_template_display() : string
{
return $this->display_settings['display']['template'];
return $this->display_settings['display']['template'] ?? 'display';
}
/**
@@ -921,7 +921,7 @@ class Databases extends Model implements Permissions
*/
public function get_template_listing() : string
{
return $this->display_settings['listing']['layout'] == 'custom' ? $this->display_settings['listing']['template'] : 'listing';
return ( $this->display_settings['listing']['layout'] == 'custom' and $this->display_settings['listing']['template'] ) ? $this->display_settings['listing']['template'] : 'listing';
}
/**
@@ -929,7 +929,7 @@ class Databases extends Model implements Permissions
*/
public function get_template_categories() : string
{
return $this->display_settings['categories']['layout'] == 'custom' ? $this->display_settings['categories']['template'] : 'category_index';
return ( $this->display_settings['categories']['layout'] == 'custom' and $this->display_settings['categories']['template'] ) ? $this->display_settings['categories']['template'] : 'category_index';
}
/**
@@ -939,7 +939,7 @@ class Databases extends Model implements Permissions
{
if( $this->display_settings['index']['type'] != 'categories' )
{
return $this->display_settings['index']['layout'] == 'custom' ? $this->display_settings['index']['template'] : 'category_articles';
return ( $this->display_settings['index']['layout'] == 'custom' and $this->display_settings['index']['template'] ) ? $this->display_settings['index']['template'] : 'category_articles';
}
return $this->template_categories;
@@ -1006,7 +1006,7 @@ class Databases extends Model implements Permissions
public function preLoadWords() : void
{
/* Skip this during installation / uninstallation as the words won't be loaded */
if ( !Dispatcher::hasInstance() or Dispatcher::i()->controllerLocation === 'setup' OR ( Dispatcher::i()->controllerLocation === 'admin' AND Dispatcher::i()->module->key === 'applications' ) )
if ( !Dispatcher::hasInstance() or Dispatcher::i()->controllerLocation === 'setup' OR ( Dispatcher::i()->controllerLocation === 'admin' and Dispatcher::i()->module and Dispatcher::i()->module->key === 'applications' ) )
{
$this->langLoaded = TRUE;
return;
+13 -9
View File
@@ -33,7 +33,6 @@ use IPS\Db\Exception as DbException;
use IPS\Dispatcher;
use IPS\Extensions\CustomFieldAbstract;
use IPS\File;
use IPS\File\FileSystem;
use IPS\GeoLocation;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Codemirror;
@@ -1322,11 +1321,11 @@ class Fields extends CustomField implements Permissions
try
{
return Member::loggedIn()->language()->get( static::$langKey . '_' . $this->id );
return (string) Member::loggedIn()->language()->get( static::$langKey . '_' . $this->id ); # If the key doesn't exist, we populate with null
}
catch( UnderflowException $e )
{
return FALSE;
return '';
}
}
@@ -1900,9 +1899,9 @@ class Fields extends CustomField implements Permissions
'Upload' => array_merge( array( 'field_upload_is_image', 'field_upload_is_multiple', 'field_upload_thumb' ), $displayDefaults ),
'Url' => array_merge( array( 'field_default_value', 'field_unique' ), $displayDefaults ),
'YesNo' => array_merge( array( 'field_default_value' ), $displayDefaults ),
'Youtube' => array( 'media_params', 'media_display_listing_method', 'media_display_display_method', 'field_unique' ),
'Spotify' => array( 'media_params', 'media_display_listing_method', 'media_display_display_method', 'field_unique' ),
'Soundcloud'=> array( 'media_params', 'media_display_listing_method', 'media_display_display_method', 'field_unique' )
'Youtube' => array( 'media_params', 'media_display_listing_method', 'media_display_display_method', 'field_unique', 'field_display_display_json_where' ),
'Spotify' => array( 'media_params', 'media_display_listing_method', 'media_display_display_method', 'field_unique', 'field_display_display_json_where' ),
'Soundcloud'=> array( 'media_params', 'media_display_listing_method', 'media_display_display_method', 'field_unique', 'field_display_display_json_where' )
);
foreach ( $toggles as $k => $v )
@@ -2327,12 +2326,12 @@ class Fields extends CustomField implements Permissions
}, NULL, NULL, 'field_display_display_json_custom' ) );
/* Display where? */
$form->add( new Radio( 'field_display_display_json_where', ($displayJson['display']['where'] ?? 'top'), FALSE, array( 'options' => array( 'top' => 'cms_field_display_top', 'bottom' => 'cms_field_display_bottom' ) ), NULL, NULL, NULL, 'field_display_display_json_where' ) );
/* Media display */
$form->add( new Radio( 'media_display_display_method', $mediaDisplayDefault, FALSE, array( 'options' => $mediaListingOptions ), NULL, NULL, NULL, 'media_display_display_method' ) );
/* Display where? */
$form->add( new Radio( 'field_display_display_json_where', ($displayJson['display']['where'] ?? 'top'), FALSE, array( 'options' => array( 'top' => 'cms_field_display_top', 'bottom' => 'cms_field_display_bottom' ) ), NULL, NULL, NULL, 'field_display_display_json_where' ) );
$form->addSeparator();
$form->add( new YesNo( 'field_display_commentform', $this->id ? $this->display_commentform : 0, FALSE, array(), NULL, NULL, NULL, 'field_display_commentform' ) );
@@ -2745,6 +2744,11 @@ class Fields extends CustomField implements Permissions
{
$displayJson['listing']['method'] = $values['media_display_listing_method'];
$displayJson['display']['method'] = $values['media_display_display_method'];
if ( isset( $values['field_display_display_json_where'] ) )
{
$displayJson['display']['where'] = $values['field_display_display_json_where'];
}
}
else
{
+2 -1
View File
@@ -190,7 +190,8 @@ class Folder extends Model
$buttons['add_page'] = array(
'icon' => 'plus-circle',
'title' => 'content_add_page',
'link' => $url->setQueryString( array( 'subnode' => 1, 'do' => 'form', 'parent' => $this->_id ) )
'link' => $url->setQueryString( array( 'subnode' => 1, 'do' => 'add', 'parent' => $this->_id ) ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('content_add_page') )
);
}
+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 )
+1 -1
View File
@@ -113,6 +113,6 @@ class PageItem extends Item
*/
public function url( ?string $action=NULL ): Url
{
return Page::constructFromData( $this->_data )->url();
return Page::load( $this->id )->url();
}
}
+2 -2
View File
@@ -3594,7 +3594,7 @@ class Records extends Item implements
* @param array $where Where clause
* @param string|null $order MySQL ORDER BY clause (NULL to order by date)
* @param int|array|null $limit Limit clause
* @param string $permissionKey A key which has a value in the permission map (either of the container or of this class) matching a column ID in core_permission_index or NULL to ignore permissions
* @param string|null $permissionKey A key which has a value in the permission map (either of the container or of this class) matching a column ID in core_permission_index or NULL to ignore permissions
* @param int|bool|null $includeHiddenItems Include hidden items? NULL to detect if currently logged in member has permission, -1 to return public content only, TRUE to return unapproved content and FALSE to only return unapproved content the viewing member submitted
* @param int $queryFlags Select bitwise flags
* @param Member|null $member The member (NULL to use currently logged in member)
@@ -3611,7 +3611,7 @@ class Records extends Item implements
* @param array|null $location Array of item lat and long
* @return ActiveRecordIterator|int
*/
public static function getItemsWithPermission( array $where=array(), string $order=null, int|array|null $limit=10, string $permissionKey='read', int|bool|null $includeHiddenItems= Filter::FILTER_AUTOMATIC, int $queryFlags=0, Member $member=null, bool $joinContainer=FALSE, bool $joinComments=FALSE, bool $joinReviews=FALSE, bool $countOnly=FALSE, array|null $joins=null, bool|Model $skipPermission=FALSE, bool $joinTags=TRUE, bool $joinAuthor=TRUE, bool $joinLastCommenter=TRUE, bool $showMovedLinks=FALSE, array|null $location=null ): ActiveRecordIterator|int
public static function getItemsWithPermission( array $where=array(), string $order=null, int|array|null $limit=10, ?string $permissionKey='read', int|bool|null $includeHiddenItems= Filter::FILTER_AUTOMATIC, int $queryFlags=0, Member $member=null, bool $joinContainer=FALSE, bool $joinComments=FALSE, bool $joinReviews=FALSE, bool $countOnly=FALSE, array|null $joins=null, bool|Model $skipPermission=FALSE, bool $joinTags=TRUE, bool $joinAuthor=TRUE, bool $joinLastCommenter=TRUE, bool $showMovedLinks=FALSE, array|null $location=null ): ActiveRecordIterator|int
{
$where = static::getItemsWithPermissionWhere( $where, $permissionKey, $member, $joinContainer, $skipPermission );
return parent::getItemsWithPermission( $where, $order, $limit, $permissionKey, $includeHiddenItems, $queryFlags, $member, $joinContainer, $joinComments, $joinReviews, $countOnly, $joins, $skipPermission, $joinTags, $joinAuthor, $joinLastCommenter, $showMovedLinks );
@@ -1255,12 +1255,9 @@ class Templates extends ActiveRecord
$content = $this->content;
/* Build on demand */
if ( $this->type != 'js' and ( mb_stristr( $this->content, "{block=" ) or mb_stristr( $this->content, "{{if" ) or mb_stristr( $this->content, "{media=" ) ) )
if ( $this->type != 'js' )
{
$functionName = 'css_' . mt_rand();
Theme::makeProcessFunction( str_replace( '\\', '\\\\', $content ), $functionName );
$functionName = "IPS\Theme\\{$functionName}";
$content = $functionName();
$content = Theme::compileCustomCss( $content );
}
$this->file_object = (string) File::create( 'cms_Pages', $this->title, $content ?: ' ', 'page_objects', TRUE );