Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

@@ -85,11 +85,11 @@ class _ajax extends \IPS\Dispatcher\Controller
/* Find it from the normal template system */
if ( isset( \IPS\Request::i()->block_app ) )
{
$plugin = \IPS\Widget::load( \IPS\Application::load( \IPS\Request::i()->block_app ), \IPS\Request::i()->block_key, uniqid() );
$plugin = \IPS\Widget::load( \IPS\Application::load( \IPS\Request::i()->block_app ), \IPS\Request::i()->block_key, mt_rand() );
}
else
{
$plugin = \IPS\Widget::load( \IPS\Plugin::load( \IPS\Request::i()->block_plugin ), \IPS\Request::i()->block_key, uniqid() );
$plugin = \IPS\Widget::load( \IPS\Plugin::load( \IPS\Request::i()->block_plugin ), \IPS\Request::i()->block_key, mt_rand() );
}
$location = $plugin->getTemplateLocation();
@@ -99,7 +99,7 @@ class _ajax extends \IPS\Dispatcher\Controller
if ( ! isset( \IPS\Request::i()->noencode ) OR ! \IPS\Request::i()->noencode )
{
$templateBit['template_content'] = htmlentities( $templateBit['template_content'], \IPS\HTMLENTITIES, 'UTF-8', TRUE );
$templateBit['template_content'] = htmlentities( $templateBit['template_content'], ENT_DISALLOWED, 'UTF-8', TRUE );
}
$templateArray = array(
@@ -142,7 +142,7 @@ class _ajax extends \IPS\Dispatcher\Controller
'template_key' => $template->key,
'template_title' => $template->title,
'template_desc' => $template->desc,
'template_content' => ( isset( \IPS\Request::i()->noencode ) AND \IPS\Request::i()->noencode ) ? $template->content : htmlentities( $template->content, \IPS\HTMLENTITIES, 'UTF-8', TRUE ),
'template_content' => ( isset( \IPS\Request::i()->noencode ) AND \IPS\Request::i()->noencode ) ? $template->content : htmlentities( $template->content, ENT_DISALLOWED, 'UTF-8', TRUE ),
'template_location' => $template->location,
'template_group' => $template->group,
'template_container' => $template->container,
+81 -1
View File
@@ -195,6 +195,86 @@ class _media extends \IPS\Node\Controller
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'media', 'cms', 'admin' )->media( $output );
}
}
/**
* Replace an existing file
*
* @return void
*/
public function replace()
{
if( !isset( \IPS\Request::i()->id ) OR !\IPS\Request::i()->id )
{
\IPS\Output::i()->error( 'missing_media_file', '3T334/2', 404, '' );
}
try
{
$media = \IPS\cms\Media::load( \IPS\Request::i()->id );
}
catch( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'missing_media_file', '3T334/3', 404, '' );
}
$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' ) );
if ( $values = $form->values() )
{
$existingFileExtension = mb_substr( $media->filename_stored, mb_strrpos( $media->filename_stored, '.' ) + 1 );
$newFileExtension = mb_substr( $values['media_filename']->originalFilename, mb_strrpos( $values['media_filename']->originalFilename, '.' ) + 1 );
/* If we have the same extension, we will just retain the same filename */
if( $existingFileExtension == $newFileExtension )
{
$media->file_object = (string) \IPS\File::create( 'cms_Media', $media->filename_stored, $values['media_filename']->contents(), 'pages_media', TRUE, NULL, FALSE );
}
/* Otherwise we need to update the rest of the file info too */
else
{
$media->is_image = $values['media_filename']->isImage();
$media->filename = $values['media_filename']->originalFilename;
$media->filename_stored = $media->parent . '_' . $media->filename;
$media->file_object = (string) \IPS\File::create( 'cms_Media', $media->filename_stored, $values['media_filename']->contents(), 'pages_media', TRUE, NULL, FALSE );
}
$media->setFullPath( ( $media->parent ? \IPS\cms\Media\Folder::load( $media->parent )->path : '' ) );
$media->save();
/* Remove the original as we created a copy with a slightly altered filename */
try
{
$values['media_filename']->delete();
}
catch( \Exception $ex ) { }
if ( \IPS\Request::i()->isAjax() )
{
$url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=media" );
$data = \IPS\cms\modules\admin\pages\media::getRowsForTree( $media->parent );
$rows = array();
foreach ( $data as $id => $row )
{
if ( $row instanceof \IPS\cms\Media )
{
$rows[ $id ] = \IPS\cms\modules\admin\pages\media::getItemRow( $row, $url );
}
}
\IPS\Output::i()->sendOutput( json_encode( array( 'fileID' => $media->id, 'folderID' => $media->parent, 'rows' => $rows ) ), 200, 'application/json', \IPS\Output::i()->httpHeaders );
}
else
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=media' ) );
}
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( 'upload', $form, FALSE );
}
/**
* Upload items
@@ -206,7 +286,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' => 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' => 'core_Theme', '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 )
{
@@ -240,6 +240,17 @@ class _pages extends \IPS\Node\Controller
/* Clear Sidebar Caches */
\IPS\Widget::deleteCaches();
/* Possible gateway choice changed and thusly menu and page_urls will change */
if ( isset( \IPS\Data\Store::i()->pages_page_urls ) )
{
unset( \IPS\Data\Store::i()->pages_page_urls );
}
if ( isset( \IPS\Data\Store::i()->frontNavigation ) )
{
unset( \IPS\Data\Store::i()->frontNavigation );
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=pages&controller=pages" ), 'saved' );
}
@@ -467,6 +478,12 @@ FILE;
/* No default found in destination folder, do nothing */
}
}
/* If page filename changes or the folder ID changes, we need to clear front navigation cache*/
if( $old !== NULL AND ( $old->folder_id != $new->folder_id OR $old->seo_name != $new->seo_name ) )
{
unset( \IPS\Data\Store::i()->pages_page_urls );
}
parent::_afterSave( $old, $new, $lastUsedTab );
}
@@ -93,7 +93,7 @@ class _templates extends \IPS\Dispatcher\Controller
/* Open XML file */
$xml = new \IPS\Xml\XMLReader;
$xml->open( \IPS\Request::i()->file );
$prefix = date('m') . '_' . date('d') . '_' . date('y') . '_';
$prefix = 'm' . date('m') . '_' . date('d') . '_' . date('y') . '_';
$templates = \IPS\cms\Theme::i()->getRawTemplates( 'cms', NULL, NULL, \IPS\cms\Theme::RETURN_ALL );
if ( ! @$xml->read() )
@@ -710,7 +710,7 @@ class _templates extends \IPS\Dispatcher\Controller
list( $widgetApp, $widgetKey ) = explode( '__', $values['block_template_plugin_import'] );
/* Find it from the normal template system */
$plugin = \IPS\Widget::load( \IPS\Application::load( $widgetApp ), $widgetKey, uniqid(), array() );
$plugin = \IPS\Widget::load( \IPS\Application::load( $widgetApp ), $widgetKey, mt_rand(), array() );
$location = $plugin->getTemplateLocation();