Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

@@ -80,28 +80,32 @@ class _emoticons extends \IPS\Dispatcher\Controller
'toggles' => array( 'create' => array( 'emoticons_add_newgroup' ), 'existing' => array( 'emoticons_add_choosegroup' ) ),
'disabled' => empty($groups)
) ) );
$form->add( new \IPS\Helpers\Form\Translatable( 'emoticons_add_newgroup', NULL, FALSE, array(), NULL, NULL, NULL, 'emoticons_add_newgroup' ) );
$form->add( new \IPS\Helpers\Form\Select( 'emoticons_add_choosegroup', NULL, FALSE, array( 'options' => $groups ), NULL, NULL, NULL, 'emoticons_add_choosegroup' ) );
if ( $values = $form->values() )
$form->add( new \IPS\Helpers\Form\Translatable( 'emoticons_add_newgroup', NULL, FALSE, array(), function( $value )
{
if ( $values['emoticons_add_group'] === 'create' )
if ( \IPS\Request::i()->emoticons_add_group === 'create' )
{
foreach ( \IPS\Lang::languages() as $lang )
{
if ( $lang->default )
{
if( !$values['emoticons_add_newgroup'][ $lang->id ] )
if( ! $value[ $lang->id ] )
{
$form->elements['']['emoticons_add_newgroup']->error = \IPS\Member::loggedIn()->language()->addToStack( 'emoticon_group_name_error' );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'emoticons_add', $form, FALSE );
return;
throw new \InvalidArgumentException('form_required');
}
}
}
}
}, NULL, NULL, 'emoticons_add_newgroup' ) );
if ( !empty( $groups ) )
{
$form->add( new \IPS\Helpers\Form\Select( 'emoticons_add_choosegroup', NULL, FALSE, array( 'options' => $groups ), NULL, NULL, NULL, 'emoticons_add_choosegroup' ) );
}
if ( $values = $form->values() )
{
if ( $values['emoticons_add_group'] === 'create' )
{
$position = 0;
$setId = md5( uniqid() );
\IPS\Lang::saveCustom( 'core', "core_emoticon_group_{$setId}", $values['emoticons_add_newgroup'] );
@@ -120,8 +124,18 @@ class _emoticons extends \IPS\Dispatcher\Controller
}
$inserts = array();
$images2x = array();
foreach ( $values['emoticons_upload'] as $file )
{
/* Is it "retina" */
if( \mb_stristr( $file->filename, '@2x' ) )
{
$filename_2x = preg_replace( "/^(.+?)\.[0-9a-f]{32}(?:\..+?)$/i", "$1", str_replace( '@2x', '', $file->filename ) );
$images2x[ $filename_2x ] = (string) $file;
continue;
}
$filename = preg_replace( "/^(.+?)\.[0-9a-f]{32}(?:\..+?)$/i", "$1", $file->filename );
$inserts[] = array(
@@ -132,8 +146,42 @@ class _emoticons extends \IPS\Dispatcher\Controller
'emo_position' => ++$position,
);
}
\IPS\Db::i()->insert( 'core_emoticons', $inserts );
if( count( $inserts ) )
{
\IPS\Db::i()->insert( 'core_emoticons', $inserts );
}
/* Add 2x */
if( count( $images2x ) )
{
foreach( \IPS\Db::i()->select( '*', 'core_emoticons', array( 'emo_set=?', $setId ) ) as $emo )
{
$file = \IPS\File::get( 'core_Emoticons', $emo['image'] );
$imageDimensions = $file->getImageDimensions();
/* There isn't an original for the 2x emo */
if( !isset( $images2x[ $file->filename ] ) )
{
continue;
}
\IPS\Db::i()->update( 'core_emoticons', array(
'image_2x' => $images2x[ $file->filename ],
'width' => $imageDimensions[0],
'height' => $imageDimensions[1]
), 'id=' . $emo['id']);
unset( $images2x[ $file->filename ] );
}
/* Delete any unused 2x files */
foreach( $images2x as $img )
{
\IPS\File::get( 'core_Emoticons', $img )->delete();
}
}
unset( \IPS\Data\Store::i()->emoticons );
/* Clear guest page caches */
@@ -205,6 +253,11 @@ class _emoticons extends \IPS\Dispatcher\Controller
if ( isset( $emoticons[ $id ] ) )
{
if ( !$data['name'] )
{
continue;
}
if ( !isset( $data['order'] ) )
{
if ( !isset( $orders[ $set ] ) )
@@ -256,6 +309,7 @@ class _emoticons extends \IPS\Dispatcher\Controller
if ( $emoticon['id'] )
{
\IPS\File::get( 'core_Emoticons', $emoticon['image'] )->delete();
\IPS\File::get( 'core_Emoticons', $emoticon['image_2x'] )->delete();
}
\IPS\Db::i()->delete( 'core_emoticons', array( 'id=?', (int) \IPS\Request::i()->id ) );
@@ -296,6 +350,7 @@ class _emoticons extends \IPS\Dispatcher\Controller
try
{
\IPS\File::get( 'core_Emoticons', $emoticon['image'] )->delete();
\IPS\File::get( 'core_Emoticons', $emoticon['image_2x'] )->delete();
}
catch ( \UnderflowException $e ) { }
}
@@ -0,0 +1,132 @@
<?php
/**
* @brief settings
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 13 Aug 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\core\modules\admin\editor;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* settings
*/
class _settings extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
/* Restrictions check */
\IPS\Dispatcher::i()->checkAcpPermission( 'settings_manage' );
/* Choose active tab */
$this->tabs = array( 'general' => 'editor_settings_general', 'advanced' => 'editor_settings_advanced' );
if ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $this->tabs ) )
{
$this->activeTab = \IPS\Request::i()->tab;
}
else
{
$keys = array_keys( $this->tabs );
$this->activeTab = array_shift( $keys );
}
/* Run */
parent::execute();
}
/**
* Manage
*
* @return void
*/
protected function manage()
{
/* Work out output */
$activeTabContents = call_user_func( array( $this, '_manage'.ucfirst( $this->activeTab ) ) );
/* If this is an AJAX request, just return it */
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->output = $activeTabContents;
return;
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('editor_settings');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->tabs( $this->tabs, $this->activeTab, $activeTabContents, \IPS\Http\Url::internal( "app=core&module=editor&controller=settings" ) );
}
/**
* General Settings
*
* @return void
*/
protected function _manageGeneral()
{
$form = new \IPS\Helpers\Form( 'form' );
$form->add( new \IPS\Helpers\Form\Radio( 'editor_paste_behaviour', \IPS\Settings::i()->editor_paste_behaviour, FALSE, array( 'options' => array(
'rich' => 'editor_paste_behaviour_rich',
'force' => 'editor_paste_behaviour_force',
) ) ) );
$form->add( new \IPS\Helpers\Form\Radio( 'editor_paragraph_padding', \IPS\Settings::i()->editor_paragraph_padding, FALSE, array( 'options' => array(
1 => 'editor_paragraph_padding_on',
0 => 'editor_paragraph_padding_off'
) ) ) );
if ( $values = $form->values() )
{
$clearCss = ( $values['editor_paragraph_padding'] !== \IPS\Settings::i()->editor_paragraph_padding );
$form->saveAsSettings();
if ( $clearCss )
{
\IPS\Theme::deleteCompiledCss();
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=editor&controller=settings&tab=general" ), 'saved' );
}
/* Display */
return $form;
}
/**
* Advanced Settings
*
* @return void
*/
protected function _manageAdvanced()
{
$form = new \IPS\Helpers\Form( 'form' );
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack('editor_allowed_formmsg') );
$form->add( new \IPS\Helpers\Form\Stack( 'editor_allowed_classes', \IPS\Settings::i()->editor_allowed_classes ? explode( ',', \IPS\Settings::i()->editor_allowed_classes ) : array(), FALSE ) );
$form->add( new \IPS\Helpers\Form\Stack( 'editor_allowed_datacontrollers', \IPS\Settings::i()->editor_allowed_datacontrollers ? explode( ',', \IPS\Settings::i()->editor_allowed_datacontrollers ) : array(), FALSE ) );
$form->add( new \IPS\Helpers\Form\Stack( 'editor_allowed_iframe_bases', \IPS\Settings::i()->editor_allowed_iframe_bases ? explode( ',', \IPS\Settings::i()->editor_allowed_iframe_bases ) : array(), FALSE, array( 'placeholder' => 'example.com/embed/' ) ) );
if ( $values = $form->values() )
{
$form->saveAsSettings();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=editor&controller=settings&tab=advanced" ), 'saved' );
}
/* Display */
return $form;
}
}
@@ -77,39 +77,10 @@ class _toolbar extends \IPS\Dispatcher\Controller
'title' => 'editor_revert',
'link' => \IPS\Http\Url::internal( "app=core&module=editor&controller=toolbar&do=revert" ),
'data' => array( 'confirm' => '', 'confirmSubMessage' => \IPS\Member::loggedIn()->language()->addToStack('editor_revert_confirm' ) )
),
'edit' => array(
'icon' => 'cog',
'title' => 'editor_advanced_config',
'link' => \IPS\Http\Url::internal( "app=core&module=editor&controller=toolbar&do=advanced" ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('editor_advanced_config') )
),
)
);
}
/**
* Advanced ckeditor configuration options
*
* @return void
*/
public function advanced()
{
$form = new \IPS\Helpers\Form( 'form' );
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack('editor_allowed_formmsg') );
$form->add( new \IPS\Helpers\Form\Stack( 'editor_allowed_classes', \IPS\Settings::i()->editor_allowed_classes ? explode( ',', \IPS\Settings::i()->editor_allowed_classes ) : array(), FALSE ) );
$form->add( new \IPS\Helpers\Form\Stack( 'editor_allowed_datacontrollers', \IPS\Settings::i()->editor_allowed_datacontrollers ? explode( ',', \IPS\Settings::i()->editor_allowed_datacontrollers ) : array(), FALSE ) );
if ( $values = $form->values() )
{
$form->saveAsSettings();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=editor&controller=toolbar" ), 'saved' );
}
/* Display */
\IPS\Output::i()->output = $form;
}
/**
* Save
*
@@ -309,6 +280,7 @@ class _toolbar extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'editor_plugin_nowrite', '4C120/2', 403, '' );
}
$form->add( new \IPS\Helpers\Form\Upload( 'editor_plugin_zip', NULL, TRUE, array( 'allowedFileTypes' => array( 'zip' ), 'temporary' => TRUE ) ) );
\IPS\Member::loggedIn()->language()->words['editor_plugin_zip_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'editor_plugin_zip_desc' ), \IPS\Helpers\Form\Editor::ckeditorVersion() );
}
else
{
@@ -321,6 +293,7 @@ class _toolbar extends \IPS\Dispatcher\Controller
}
}
$form->add( new \IPS\Helpers\Form\Select( 'editor_plugin_folder', NULL, TRUE, array( 'options' => $plugins ) ) );
\IPS\Member::loggedIn()->language()->words['editor_plugin_folder_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'editor_plugin_folder_desc' ), \IPS\Helpers\Form\Editor::ckeditorVersion() );
}
/* Handle Submissions */
@@ -344,7 +317,7 @@ class _toolbar extends \IPS\Dispatcher\Controller
$name = mb_substr( zip_entry_name( $resource ), 0, -1 );
$name = explode( '/', $name );
$name = array_shift( $name );
if ( strstr( $fileName, $name ) !== FALSE )
if ( strstr( mb_strtolower( $fileName ), mb_strtolower( $name ) ) !== FALSE )
{
$inRoot = FALSE;
break;