Version 4.3.6

This commit is contained in:
Neo committed 2025-12-19 05:49:12 -08:00
1 parent fe1acf984a
commit 1a0c7fd3c2
609 files changed
+14707 -5726

No files matched your search

@@ -35,6 +35,12 @@ class _categories extends \IPS\Node\Controller
*/
public function execute()
{
/* This controller can not be accessed without a database ID */
if( !\IPS\Request::i()->database_id )
{
\IPS\Output::i()->error( 'node_error', '2S390/1', 404, '' );
}
$this->url = $this->url->setQueryString( array( 'database_id' => \IPS\Request::i()->database_id ) );
/* Assign the correct nodeClass so contentItem is specified */
@@ -1593,11 +1593,12 @@ class _databases extends \IPS\Node\Controller
), NULL, NULL, NULL, 'database_cat_index_type' ) );
$fields = array(
'primary_id_field' => 'database_field__id',
'member_id' => 'database_field__member',
'record_publish_date' => 'database_field__saved',
'record_last_comment' => ( $current and $current->_comment_bump === \IPS\cms\Databases::BUMP_ON_EDIT ) ? 'database_field__edited' : 'database_field__updated',
'record_rating' => 'database_field__rating'
'primary_id_field' => 'database_field__id',
'member_id' => 'database_field__member',
'record_publish_date' => 'database_field__saved',
'record_updated' => ( $current and $current->_comment_bump === \IPS\cms\Databases::BUMP_ON_EDIT ) ? 'database_field__edited' : 'database_field__updated',
'record_last_comment' => "database_field__last_comment",
'record_rating' => 'database_field__rating'
);
if ( $current )
@@ -351,14 +351,14 @@ class _records extends \IPS\Dispatcher\Controller
$fieldsClass = 'IPS\cms\Fields' . \IPS\Request::i()->database_id;
$catClass = 'IPS\cms\Categories' . \IPS\Request::i()->database_id;
$container = ( $current ) ? $catClass::load( $current->category_id ) : ( isset( \IPS\Request::i()->category_id ) ? $catClass::load( \IPS\Request::i()->category_id ) : NULL );
$customFields = $fieldsClass::fields( $customValues, 'view', $container, 0, $current );
$manuallyHandledFields = array( 'record_publish_date', 'record_expiry_date', 'record_allow_comments', 'record_comment_cutoff', 'record_meta_keywords', 'record_meta_description' );
$form = new \IPS\Helpers\Form();
$form->addTab( 'content_database_record_tab_content' );
$formElements = $class::formElements( $current, $container );
$formElements = $class::formElements( $current, $container );
$customFields = $class::$customFields;
foreach( $formElements as $name => $field )
{
@@ -457,13 +457,15 @@ class _records extends \IPS\Dispatcher\Controller
}
$current = $recordClass::createFromForm( $values, $category );
}
else
{
/* Claim attachments */
foreach( $fieldClass::data() as $key => $field )
{
if ( mb_ucfirst( $field->type ) === 'Editor' )
{
\IPS\File::claimAttachments( 'RecordField_'. $field->id , $current->id, NULL, 'RecordField_'. $field->id, FALSE );
\IPS\File::claimAttachments( 'RecordField_' . ( $new ? 'new' : $current->primary_id_field ) . '_' . $field->id , $current->primary_id_field, $field->id, \IPS\Request::i()->database_id );
}
}
}
+101 -85
View File
@@ -107,92 +107,100 @@ class _media extends \IPS\Node\Controller
*/
protected function manage()
{
$url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=media" );
/* Display the table */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__cms_pages_media');
$output = new \IPS\Helpers\Tree\Tree( $url, 'menu__cms_pages_media',
/* Get Roots */
function () use ( $url )
{
$data = \IPS\cms\modules\admin\pages\media::getRowsForTree( 0 );
$rows = array();
foreach ( $data as $id => $row )
{
if( ( \IPS\Request::i()->isAjax() && $row instanceof \IPS\cms\Media ) || !\IPS\Request::i()->isAjax() )
{
$rows[ $id ] = ( $row instanceof \IPS\cms\Media) ? \IPS\cms\modules\admin\pages\media::getItemRow( $row, $url ) : \IPS\cms\modules\admin\pages\media::getFolderRow( $row, $url );
}
}
if( \IPS\Request::i()->isAjax() ){
\IPS\Output::i()->sendOutput( json_encode( $rows ), 200, 'application/json', \IPS\Output::i()->httpHeaders );
}
return $data;
},
/* Get Row */
function ( $id, $root ) use ( $url )
{
if ( $root )
{
return \IPS\cms\modules\admin\pages\media::getFolderRow( \IPS\cms\Media\Folder::load( $id ), $url );
}
else
{
return \IPS\cms\modules\admin\pages\media::getItemRow( \IPS\cms\Media::load( $id ), $url );
}
},
/* Get Row Parent ID*/
function ()
{
return NULL;
},
/* Get Children */
function ( $id ) use ( $url )
{
$rows = array();
$data = \IPS\cms\modules\admin\pages\media::getRowsForTree( $id );
if ( ! isset( \IPS\Request::i()->subnode ) )
{
foreach ( $data as $id => $row )
{
if( \IPS\Request::i()->get == 'folders' && !( $row instanceof \IPS\cms\Media ) )
{
$rows[ $id ] = \IPS\cms\modules\admin\pages\media::getFolderRow( $row, $url );
}
elseif ( \IPS\Request::i()->get == 'files' && $row instanceof \IPS\cms\Media )
{
$rows[ $id ] = \IPS\cms\modules\admin\pages\media::getItemRow( $row, $url );
}
}
}
if( \IPS\Request::i()->isAjax() ){
\IPS\Output::i()->sendOutput( json_encode( $rows ), 200, 'application/json', \IPS\Output::i()->httpHeaders );
}
return $rows;
},
array( $this, '_getRootButtons' ),
TRUE,
FALSE,
FALSE
);
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_media.js', 'cms' ) );
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'media/media.css', 'cms', 'admin' ) );
if( \IPS\Request::i()->isAjax() )
if ( \IPS\Theme::designersModeEnabled() )
{
\IPS\Output::i()->sendOutput( $output, 200, 'text/html', \IPS\Output::i()->httpHeaders );
$link = \IPS\Http\Url::internal( 'app=core&module=customization&controller=themes&do=designersmode' );
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( \IPS\Member::loggedIn()->language()->addToStack('cms_media_designer_mode_warning', NULL, array( 'sprintf' => array( $link ) ) ), 'information', NULL, FALSE );
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'media', 'cms', 'admin' )->media( $output );
$url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=media" );
/* Display the table */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__cms_pages_media');
$output = new \IPS\Helpers\Tree\Tree( $url, 'menu__cms_pages_media',
/* Get Roots */
function () use ( $url )
{
$data = \IPS\cms\modules\admin\pages\media::getRowsForTree( 0 );
$rows = array();
foreach ( $data as $id => $row )
{
if( ( \IPS\Request::i()->isAjax() && $row instanceof \IPS\cms\Media ) || !\IPS\Request::i()->isAjax() )
{
$rows[ $id ] = ( $row instanceof \IPS\cms\Media) ? \IPS\cms\modules\admin\pages\media::getItemRow( $row, $url ) : \IPS\cms\modules\admin\pages\media::getFolderRow( $row, $url );
}
}
if( \IPS\Request::i()->isAjax() ){
\IPS\Output::i()->sendOutput( json_encode( $rows ), 200, 'application/json', \IPS\Output::i()->httpHeaders );
}
return $data;
},
/* Get Row */
function ( $id, $root ) use ( $url )
{
if ( $root )
{
return \IPS\cms\modules\admin\pages\media::getFolderRow( \IPS\cms\Media\Folder::load( $id ), $url );
}
else
{
return \IPS\cms\modules\admin\pages\media::getItemRow( \IPS\cms\Media::load( $id ), $url );
}
},
/* Get Row Parent ID*/
function ()
{
return NULL;
},
/* Get Children */
function ( $id ) use ( $url )
{
$rows = array();
$data = \IPS\cms\modules\admin\pages\media::getRowsForTree( $id );
if ( ! isset( \IPS\Request::i()->subnode ) )
{
foreach ( $data as $id => $row )
{
if( \IPS\Request::i()->get == 'folders' && !( $row instanceof \IPS\cms\Media ) )
{
$rows[ $id ] = \IPS\cms\modules\admin\pages\media::getFolderRow( $row, $url );
}
elseif ( \IPS\Request::i()->get == 'files' && $row instanceof \IPS\cms\Media )
{
$rows[ $id ] = \IPS\cms\modules\admin\pages\media::getItemRow( $row, $url );
}
}
}
if( \IPS\Request::i()->isAjax() ){
\IPS\Output::i()->sendOutput( json_encode( $rows ), 200, 'application/json', \IPS\Output::i()->httpHeaders );
}
return $rows;
},
array( $this, '_getRootButtons' ),
TRUE,
FALSE,
FALSE
);
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_media.js', 'cms' ) );
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'media/media.css', 'cms', 'admin' ) );
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->sendOutput( $output, 200, 'text/html', \IPS\Output::i()->httpHeaders );
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'media', 'cms', 'admin' )->media( $output );
}
}
}
@@ -220,7 +228,7 @@ class _media extends \IPS\Node\Controller
$form = new \IPS\Helpers\Form( 'form', 'upload' );
$form->class = 'ipsForm_vertical ipsForm_noLabels';
$form->add( new \IPS\Helpers\Form\Upload( 'media_filename', NULL, FALSE, array( 'allowedFileTypes' => array_merge( \IPS\File::$safeFileExtensions, array( 'pdf' ) ), 'obscure' => FALSE, 'maxFileSize' => 5, 'storageExtension' => 'core_Theme', 'storageContainer' => 'pages_media', 'multiple' => FALSE, 'minimize' => FALSE ), NULL, NULL, NULL, 'media_filename' ) );
$form->add( new \IPS\Helpers\Form\Upload( 'media_filename', NULL, FALSE, array( 'allowedFileTypes' => array_merge( \IPS\File::$safeFileExtensions, array( 'pdf' ) ), 'obscure' => FALSE, 'maxFileSize' => 5, 'storageExtension' => 'cms_Media', 'storageContainer' => 'pages_media', 'multiple' => FALSE, 'minimize' => FALSE ), NULL, NULL, NULL, 'media_filename' ) );
if ( $values = $form->values() )
{
@@ -250,7 +258,11 @@ class _media extends \IPS\Node\Controller
$values['media_filename']->delete();
}
catch( \Exception $ex ) { }
/* Wipe out included JS just in case we're using this media thing */
\IPS\cms\Templates::deleteCompiledFiles();
\IPS\cms\Pages\Page::deleteCachedIncludes();
if ( \IPS\Request::i()->isAjax() )
{
$url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=media" );
@@ -286,7 +298,7 @@ class _media extends \IPS\Node\Controller
$form = new \IPS\Helpers\Form( 'form', 'upload' );
$form->class = 'ipsForm_vertical ipsForm_noLabels';
$form->add( new \IPS\Helpers\Form\Upload( 'media_filename', NULL, FALSE, array( 'allowedFileTypes' => array_merge( \IPS\File::$safeFileExtensions, array( 'pdf', 'svg' ) ), 'obscure' => FALSE, 'maxFileSize' => 5, 'storageExtension' => 'core_Theme', 'storageContainer' => 'pages_media', 'multiple' => true, 'minimize' => FALSE ), NULL, NULL, NULL, 'media_filename' ) );
$form->add( new \IPS\Helpers\Form\Upload( 'media_filename', NULL, FALSE, array( 'allowedFileTypes' => array_merge( \IPS\File::$safeFileExtensions, array( 'pdf', 'svg' ) ), 'obscure' => FALSE, 'maxFileSize' => 5, 'storageExtension' => 'cms_Media', 'storageContainer' => 'pages_media', 'multiple' => true, 'minimize' => FALSE ), NULL, NULL, NULL, 'media_filename' ) );
if ( ! isset( \IPS\Request::i()->media_parent ) and ! \IPS\Request::i()->media_parent )
{
@@ -350,6 +362,10 @@ class _media extends \IPS\Node\Controller
$count++;
}
/* Wipe out included JS just in case we're using this media thing */
\IPS\cms\Templates::deleteCompiledFiles();
\IPS\cms\Pages\Page::deleteCachedIncludes();
if ( \IPS\Request::i()->isAjax() )
{
$url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=media" );
@@ -214,6 +214,7 @@ class _templates extends \IPS\Dispatcher\Controller
{
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'templates_' . $location, FALSE, FALSE, array( 'options' => $data ) ) );
}
$form->addButton( 'cms_templates_export_return', 'link', \IPS\Http\Url::internal( "app=cms&module=pages&controller=templates" ) );
if ( $values = $form->values() )
{
@@ -331,7 +332,10 @@ class _templates extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'cms_no_templates_selected', '1T285/1', 403, '' );
}
}
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( "app=cms&module=pages&controller=templates" ), \IPS\Member::loggedIn()->language()->addToStack( 'menu__cms_pages_templates' ) );
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack('cms_templates_export_title') );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('cms_templates_export_title');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( 'cms_templates_export_title', $form, FALSE );
}
@@ -435,7 +439,6 @@ class _templates extends \IPS\Dispatcher\Controller
'icon' => 'download',
'title' => 'cms_templates_export_title',
'link' => \IPS\Http\Url::internal( "app=cms&module=pages&controller=templates&do=export" ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_templates_export_title') )
);
\IPS\Output::i()->sidebar['actions']['upload'] = array(
@@ -956,16 +959,64 @@ class _templates extends \IPS\Dispatcher\Controller
foreach( \IPS\cms\Templates::$databaseDefaults as $field => $template )
{
\IPS\Db::i()->update( 'cms_databases', array( 'database_template_' . $field => $new ), array( 'database_template_' . $field . ' =?', \IPS\Request::i()->group ) );
\IPS\Db::i()->update( 'cms_databases', array( 'database_template_' . $field => mb_strtolower( $new ) ), array( 'database_template_' . $field . ' =?', \IPS\Request::i()->group ) );
}
unset( \IPS\Data\Store::i()->cms_databases );
$this->findAndUpdateTemplates( $new, \IPS\Request::i()->group );
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates' . ( isset( \IPS\Request::i()->t_location ) ? '&t_location=' . \IPS\Request::i()->t_location : '' ) ), 'deleted' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates' . ( isset( \IPS\Request::i()->t_location ) ? '&t_location=' . \IPS\Request::i()->t_location : '' ) ), 'saved' );
}
/* Display */
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( \IPS\Member::loggedIn()->language()->addToStack('cms_template_database_options'), $form, FALSE, '', NULL, TRUE );
}
/**
* Find templates referencing a template and update them
*
* @param string $new New template group name
* @param string $old Old template group name
* @return void
*/
protected function findAndUpdateTemplates( $new, $old )
{
foreach( \IPS\Db::i()->select( '*', 'cms_templates', array( 'template_content LIKE ?', '%' . $old . '%' ) ) as $template )
{
/* Make sure template tags call the correct group */
if ( mb_stristr( $template['template_content'], '{template' ) )
{
preg_match_all( '/\{([a-z]+?=([\'"]).+?\\2 ?+)}/', $template['template_content'], $matches, PREG_SET_ORDER );
/* Work out the plugin and the values to pass */
foreach( $matches as $index => $array )
{
preg_match_all( '/(.+?)=' . $array[ 2 ] . '(.+?)' . $array[ 2 ] . '\s?/', $array[ 1 ], $submatches );
$plugin = array_shift( $submatches[ 1 ] );
if ( $plugin == 'template' )
{
$value = array_shift( $submatches[ 2 ] );
$options = array();
foreach ( $submatches[ 1 ] as $k => $v )
{
$options[ $v ] = $submatches[ 2 ][ $k ];
}
if ( isset( $options['app'] ) and $options['app'] == 'cms' and isset( $options['location'] ) and $options['location'] == 'database' and isset( $options['group'] ) and $options['group'] == mb_strtolower( $old ) )
{
$replace = '{template="' . $value . '" app="' . $options['app'] . '" location="' . $options['location'] . '" group="' . mb_strtolower( $new ) . '" params="' . ( isset( $options['params'] ) ? $options['params'] : NULL ) . '"}';
\IPS\Db::i()->update( 'cms_templates', array( 'template_content' => str_replace( $matches[$index][0], $replace, $template['template_content'] ) ), array( 'template_id=?', $template['template_id'] ) );
}
}
}
}
}
}
/**
* Delete the template group! OH NOES