Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,31 +11,62 @@
|
||||
namespace IPS\core\modules\admin\editor;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use InvalidArgumentException;
|
||||
use IPS\Data\Cache;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\File;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\Select;
|
||||
use IPS\Helpers\Form\Translatable;
|
||||
use IPS\Helpers\Form\Upload;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Lang;
|
||||
use IPS\Log;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
use function mb_stristr;
|
||||
use const IPS\CIC;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Emoticons
|
||||
*/
|
||||
class _emoticons extends \IPS\Dispatcher\Controller
|
||||
class emoticons extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'emoticons_manage' );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'customization/emoticons.css', 'core', 'admin' ) );
|
||||
Dispatcher::i()->checkAcpPermission( 'emoticons_manage' );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'customization/emoticons.css', 'core', 'admin' ) );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -44,58 +75,57 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$tabs = array(
|
||||
'standard' => 'standard_emoji',
|
||||
'custom' => 'custom_emoji',
|
||||
);
|
||||
$activeTab = ( isset( \IPS\Request::i()->tab ) and array_key_exists( \IPS\Request::i()->tab, $tabs ) ) ? \IPS\Request::i()->tab : 'standard';
|
||||
$activeTab = ( isset( Request::i()->tab ) and array_key_exists( Request::i()->tab, $tabs ) ) ? Request::i()->tab : 'standard';
|
||||
|
||||
if ( $activeTab == 'standard' )
|
||||
{
|
||||
if ( \IPS\Settings::i()->getFromConfGlobal('sql_utf8mb4') === TRUE )
|
||||
if ( Settings::i()->getFromConfGlobal('sql_utf8mb4') === TRUE )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'emoji_style', \IPS\Settings::i()->emoji_style, FALSE, array(
|
||||
$form = new Form;
|
||||
$form->add( new Radio( 'emoji_style', Settings::i()->emoji_style, FALSE, array(
|
||||
'options' => array(
|
||||
'native' => 'emoji_style_native',
|
||||
'twemoji' => 'emoji_style_twemoji',
|
||||
'disabled' => 'emoji_style_disabled',
|
||||
),
|
||||
) ) );
|
||||
\IPS\Member::loggedIn()->language()->get( 'emoji_style_native' ); // We need to preload the word before we can add more text to it.
|
||||
\IPS\Member::loggedIn()->language()->words['emoji_style_native'] .= "<br><div class='ipsType_large ipsSpacer_top ipsSpacer_half'><span class='ipsEmoji'>😀</span><span class='ipsEmoji'>😉</span><span class='ipsEmoji'>😂</span><span class='ipsEmoji'>😍</span><span class='ipsEmoji'>🤘</span><span class='ipsEmoji'>🤦♀️</span><span class='ipsEmoji'>🤷♂️</span><span class='ipsEmoji'>🍿</span><span class='ipsEmoji'>🚀</span><span class='ipsEmoji'>🎉</span><span class='ipsEmoji'>🏳️🌈</span></div>"; // Have to do this here because if we try to put it in the actual language string, that will cause an error if not utf8mb4
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'emoji_shortcodes', \IPS\Settings::i()->emoji_shortcodes, FALSE, array(), NULL, NULL, NULL, 'emoji_shortcodes' ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'emoji_ascii', \IPS\Settings::i()->emoji_ascii, FALSE, array(), NULL, NULL, NULL, 'emoji_ascii' ) );
|
||||
Member::loggedIn()->language()->get( 'emoji_style_native' ); // We need to preload the word before we can add more text to it.
|
||||
Member::loggedIn()->language()->words['emoji_style_native'] .= "<div class='i-font-size_2 i-margin-top_1'><span class='ipsEmoji'>😀</span><span class='ipsEmoji'>😉</span><span class='ipsEmoji'>😂</span><span class='ipsEmoji'>😍</span><span class='ipsEmoji'>🤘</span><span class='ipsEmoji'>🤦♀️</span><span class='ipsEmoji'>🤷♂️</span><span class='ipsEmoji'>🍿</span><span class='ipsEmoji'>🚀</span><span class='ipsEmoji'>🎉</span><span class='ipsEmoji'>🏳️🌈</span></div>"; // Have to do this here because if we try to put it in the actual language string, that will cause an error if not utf8mb4
|
||||
$form->add( new YesNo( 'emoji_shortcodes', Settings::i()->emoji_shortcodes, FALSE, array(), NULL, NULL, NULL, 'emoji_shortcodes' ) );
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$values['emoji_cache'] = time();
|
||||
$form->saveAsSettings( $values );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=editor&controller=emoticons&tab=standard' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=editor&controller=emoticons&tab=standard' ), 'saved' );
|
||||
}
|
||||
|
||||
$activeTabContents = $form;
|
||||
}
|
||||
else
|
||||
{
|
||||
$activeTabContents = \IPS\Theme::i()->getTemplate( 'global' )->message( \IPS\CIC ? 'emoji_utf8mb4_required_cic' : 'emoji_utf8mb4_required', 'error', NULL, TRUE, TRUE );
|
||||
$activeTabContents = Theme::i()->getTemplate( 'global' )->message( CIC ? 'emoji_utf8mb4_required_cic' : 'emoji_utf8mb4_required', 'error', NULL, TRUE, TRUE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$activeTabContents = \IPS\Theme::i()->getTemplate( 'customization' )->emoticons( $this->_getEmoticons() );
|
||||
$activeTabContents = Theme::i()->getTemplate( 'customization' )->emoticons( $this->_getEmoticons() );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__core_editor_emoticons');
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('admin_customization.js', 'core', 'admin') );
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__core_editor_emoticons');
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js('admin_customization.js', 'core', 'admin') );
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $activeTabContents;
|
||||
Output::i()->output = $activeTabContents;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->tabs( $tabs, $activeTab, $activeTabContents, \IPS\Http\Url::internal( "app=core&module=editor&controller=emoticons" ) );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->tabs( $tabs, $activeTab, $activeTabContents, Url::internal( "app=core&module=editor&controller=emoticons" ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,30 +134,30 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function add()
|
||||
protected function add() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'emoticons_add' );
|
||||
Dispatcher::i()->checkAcpPermission( 'emoticons_add' );
|
||||
|
||||
$groups = iterator_to_array( \IPS\Db::i()->select( "emo_set, CONCAT( 'core_emoticon_group_', emo_set ) as emo_set_name", 'core_emoticons', null, null, null, 'emo_set' )->setKeyField('emo_set')->setValueField('emo_set_name') );
|
||||
$groups = iterator_to_array( Db::i()->select( "emo_set, CONCAT( 'core_emoticon_group_', emo_set ) as emo_set_name", 'core_emoticons', null, null, null, 'emo_set' )->setKeyField('emo_set')->setValueField('emo_set_name') );
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'emoticons_upload', NULL, TRUE, array( 'multiple' => TRUE, 'image' => TRUE, 'storageExtension' => 'core_Emoticons', 'storageContainer' => 'emoticons', 'obscure' => FALSE ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'emoticons_add_group', 'create', TRUE, array(
|
||||
$form = new Form;
|
||||
$form->add( new Upload( 'emoticons_upload', NULL, TRUE, array( 'multiple' => TRUE, 'image' => TRUE, 'storageExtension' => 'core_Emoticons', 'storageContainer' => 'emoticons', 'obscure' => FALSE ) ) );
|
||||
$form->add( new Radio( 'emoticons_add_group', 'create', TRUE, array(
|
||||
'options' => array( 'create' => 'emoticons_add_create', 'existing' => 'emoticons_add_existing' ),
|
||||
'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(), function( $value )
|
||||
$form->add( new Translatable( 'emoticons_add_newgroup', NULL, FALSE, array(), function( $value )
|
||||
{
|
||||
if ( \IPS\Request::i()->emoticons_add_group === 'create' )
|
||||
if ( Request::i()->emoticons_add_group === 'create' )
|
||||
{
|
||||
foreach ( \IPS\Lang::languages() as $lang )
|
||||
foreach ( Lang::languages() as $lang )
|
||||
{
|
||||
if ( $lang->default )
|
||||
{
|
||||
if( ! $value[ $lang->id ] )
|
||||
{
|
||||
throw new \InvalidArgumentException('form_required');
|
||||
throw new InvalidArgumentException('form_required');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,7 +166,7 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( !empty( $groups ) )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'emoticons_add_choosegroup', NULL, FALSE, array( 'options' => $groups ), NULL, NULL, NULL, 'emoticons_add_choosegroup' ) );
|
||||
$form->add( new Select( 'emoticons_add_choosegroup', NULL, FALSE, array( 'options' => $groups ), NULL, NULL, NULL, 'emoticons_add_choosegroup' ) );
|
||||
}
|
||||
|
||||
if ( $values = $form->values() )
|
||||
@@ -145,16 +175,16 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$position = 0;
|
||||
$setId = mt_rand();
|
||||
\IPS\Lang::saveCustom( 'core', "core_emoticon_group_{$setId}", $values['emoticons_add_newgroup'] );
|
||||
\IPS\Session::i()->log( 'acplog__emoticon_group_created', array( "core_emoticon_group_{$setId}" => TRUE ) );
|
||||
Lang::saveCustom( 'core', "core_emoticon_group_{$setId}", $values['emoticons_add_newgroup'] );
|
||||
Session::i()->log( 'acplog__emoticon_group_created', array( "core_emoticon_group_{$setId}" => TRUE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$setId = $values['emoticons_add_choosegroup'];
|
||||
$position = \IPS\Db::i()->select( 'MAX(emo_position)', 'core_emoticons', array( 'emo_set=?', $setId ) )->first( );
|
||||
$position = Db::i()->select( 'MAX(emo_position)', 'core_emoticons', array( 'emo_set=?', $setId ) )->first( );
|
||||
}
|
||||
|
||||
if ( !\is_array( $values['emoticons_upload'] ) )
|
||||
if ( !is_array( $values['emoticons_upload'] ) )
|
||||
{
|
||||
$values['emoticons_upload'] = array( $values['emoticons_upload'] );
|
||||
}
|
||||
@@ -164,7 +194,7 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
foreach ( $values['emoticons_upload'] as $file )
|
||||
{
|
||||
/* Is it "retina" */
|
||||
if( \mb_stristr( $file->filename, '@2x' ) )
|
||||
if( mb_stristr( $file->filename, '@2x' ) )
|
||||
{
|
||||
$filename_2x = preg_replace( "/^(.+?)\.[0-9a-f]{32}(?:\..+?)$/i", "$1", str_replace( '@2x', '', $file->filename ) );
|
||||
|
||||
@@ -183,17 +213,17 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
}
|
||||
|
||||
if( \count( $inserts ) )
|
||||
if( count( $inserts ) )
|
||||
{
|
||||
\IPS\Db::i()->insert( 'core_emoticons', $inserts );
|
||||
Db::i()->insert( 'core_emoticons', $inserts );
|
||||
}
|
||||
|
||||
/* Add 2x */
|
||||
if( \count( $images2x ) )
|
||||
if( count( $images2x ) )
|
||||
{
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_emoticons', array( 'emo_set=?', $setId ) ) as $emo )
|
||||
foreach( Db::i()->select( '*', 'core_emoticons', array( 'emo_set=?', $setId ) ) as $emo )
|
||||
{
|
||||
$file = \IPS\File::get( 'core_Emoticons', $emo['image'] );
|
||||
$file = File::get( 'core_Emoticons', $emo['image'] );
|
||||
$filename = $this->_getRawFilename( $file->filename );
|
||||
|
||||
/* There isn't an original for the 2x emo */
|
||||
@@ -205,7 +235,7 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
/* Get the dimensions of the smaller emoticon */
|
||||
$imageDimensions = $file->getImageDimensions();
|
||||
|
||||
\IPS\Db::i()->update( 'core_emoticons', array(
|
||||
Db::i()->update( 'core_emoticons', array(
|
||||
'image_2x' => $images2x[ $filename ],
|
||||
'width' => $imageDimensions[0],
|
||||
'height' => $imageDimensions[1]
|
||||
@@ -217,21 +247,19 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
/* Delete any unused 2x files */
|
||||
foreach( $images2x as $img )
|
||||
{
|
||||
\IPS\File::get( 'core_Emoticons', $img )->delete();
|
||||
File::get( 'core_Emoticons', $img )->delete();
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Settings::i()->changeValues( array( 'emoji_cache' => time() ) );
|
||||
unset( Cache::i()->core_editor_emoji_sets );
|
||||
Settings::i()->changeValues( array( 'emoji_cache' => time() ) );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__emoticons_added', array( "core_emoticon_group_{$setId}" => TRUE ) );
|
||||
Session::i()->log( 'acplog__emoticons_added', array( "core_emoticon_group_{$setId}" => TRUE ) );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=editor&controller=emoticons&tab=custom' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=editor&controller=emoticons&tab=custom' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'emoticons_add', $form, FALSE );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'emoticons_add', $form, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,39 +267,39 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function edit()
|
||||
protected function edit() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'emoticons_edit' );
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Dispatcher::i()->checkAcpPermission( 'emoticons_edit' );
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
$position = 0;
|
||||
$set = NULL;
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
if ( Request::i()->isAjax() )
|
||||
{
|
||||
$i = 1;
|
||||
if ( isset( \IPS\Request::i()->setOrder ) )
|
||||
if ( isset( Request::i()->setOrder ) )
|
||||
{
|
||||
foreach ( \IPS\Request::i()->setOrder as $set )
|
||||
foreach ( Request::i()->setOrder as $set )
|
||||
{
|
||||
$set = preg_replace( '/^core_emoticon_group_/', '', $set );
|
||||
|
||||
\IPS\Db::i()->update( 'core_emoticons', array( 'emo_set_position' => $i ), array( 'emo_set=?', $set ) );
|
||||
Db::i()->update( 'core_emoticons', array( 'emo_set_position' => $i ), array( 'emo_set=?', $set ) );
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$emoticons = $this->_getEmoticons( TRUE );
|
||||
$emoticons = $this->_getEmoticons();
|
||||
$setPos = 1;
|
||||
|
||||
foreach ( $emoticons as $group => $emos )
|
||||
{
|
||||
if( isset( \IPS\Request::i()->$group ) AND \is_array( \IPS\Request::i()->$group ) )
|
||||
if( isset( Request::i()->$group ) AND is_array( Request::i()->$group ) )
|
||||
{
|
||||
foreach( \IPS\Request::i()->$group as $id )
|
||||
foreach( Request::i()->$group as $id )
|
||||
{
|
||||
\IPS\Db::i()->update( 'core_emoticons', array( 'emo_position' => $i, 'emo_set_position' => $setPos, 'emo_set' => str_replace( 'core_emoticon_group_', '', $group ) ), array( 'id=?', $id ) );
|
||||
Db::i()->update( 'core_emoticons', array( 'emo_position' => $i, 'emo_set_position' => $setPos, 'emo_set' => str_replace( 'core_emoticon_group_', '', $group ) ), array( 'id=?', $id ) );
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
@@ -279,36 +307,36 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
$setPos++;
|
||||
}
|
||||
}
|
||||
|
||||
unset( Cache::i()->core_editor_emoji_sets );// clear the cache
|
||||
Settings::i()->changeValues( array( 'emoji_cache' => time() ) );
|
||||
|
||||
\IPS\Settings::i()->changeValues( array( 'emoji_cache' => time() ) );
|
||||
Session::i()->log( 'acplog__emoticons_edited' );
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__emoticons_edited' );
|
||||
|
||||
\IPS\Output::i()->json( 'OK' );
|
||||
return;
|
||||
Output::i()->json( 'OK' );
|
||||
}
|
||||
|
||||
// Do we need to unsquash any values?
|
||||
// Squashed values are json_encoded by javascript to prevent us exceeding max_post_vars
|
||||
// If 'squashedField' isn't in the request it might indicate the user didn't have JS enabled
|
||||
if ( isset( \IPS\Request::i()->emoticons_squashed ) )
|
||||
if ( isset( Request::i()->emoticons_squashed ) )
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->emoticons_squashed ) )
|
||||
if ( isset( Request::i()->emoticons_squashed ) )
|
||||
{
|
||||
$unsquashed = json_decode( \IPS\Request::i()->emoticons_squashed, TRUE );
|
||||
$unsquashed = json_decode( Request::i()->emoticons_squashed, TRUE );
|
||||
|
||||
foreach( $unsquashed as $key => $value )
|
||||
{
|
||||
\IPS\Request::i()->$key = $value;
|
||||
Request::i()->$key = $value;
|
||||
}
|
||||
|
||||
unset( \IPS\Request::i()->emoticons_squashed );
|
||||
unset( Request::i()->emoticons_squashed );
|
||||
}
|
||||
}
|
||||
|
||||
$emoticons = $this->_getEmoticons( FALSE );
|
||||
|
||||
foreach ( \IPS\Request::i()->emo as $id => $data )
|
||||
foreach ( Request::i()->emo as $id => $data )
|
||||
{
|
||||
if ( isset( $emoticons[ $id ] ) )
|
||||
{
|
||||
@@ -326,19 +354,16 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
$save['emo_set'] = str_replace( 'core_emoticon_group_', '', $data['set'] );
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'core_emoticons', $save, array( 'id=?', $id ) );
|
||||
Db::i()->update( 'core_emoticons', $save, array( 'id=?', $id ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Settings::i()->changeValues( array( 'emoji_cache' => time() ) );
|
||||
Settings::i()->changeValues( array( 'emoji_cache' => time() ) );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__emoticons_edited' );
|
||||
Session::i()->log( 'acplog__emoticons_edited' );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=editor&controller=emoticons&tab=custom' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=editor&controller=emoticons&tab=custom' ), 'saved' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,42 +371,49 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function delete()
|
||||
protected function delete() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'emoticons_delete' );
|
||||
Dispatcher::i()->checkAcpPermission( 'emoticons_delete' );
|
||||
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
Request::i()->confirmedDelete();
|
||||
|
||||
try
|
||||
{
|
||||
$emoticon = \IPS\Db::i()->select( '*', 'core_emoticons', array( 'id=?', \IPS\Request::i()->id ) )->first();
|
||||
$emoticon = Db::i()->select( '*', 'core_emoticons', array( 'id=?', Request::i()->id ) )->first();
|
||||
if ( $emoticon['id'] )
|
||||
{
|
||||
\IPS\File::get( 'core_Emoticons', $emoticon['image'] )->delete();
|
||||
\IPS\File::get( 'core_Emoticons', $emoticon['image_2x'] )->delete();
|
||||
foreach ( ['image', 'image_2x'] as $field )
|
||||
{
|
||||
if ( is_string( $emoticon[$field] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
File::get( 'core_Emoticons', $emoticon[$field] )->delete();
|
||||
}
|
||||
catch ( OutOfRangeException ) {} // if the file doesn't exist anyway, we don't care
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->delete( 'core_emoticons', array( 'id=?', (int) \IPS\Request::i()->id ) );
|
||||
Db::i()->delete( 'core_emoticons', array( 'id=?', (int) Request::i()->id ) );
|
||||
|
||||
/* delete the group name, if there are no other emoticons in this group */
|
||||
$emoticons = \IPS\Db::i()->select( 'COUNT(*) as count', 'core_emoticons', array( 'emo_set =?', $emoticon['emo_set'] ) )->first();
|
||||
$emoticons = Db::i()->select( 'COUNT(*) as count', 'core_emoticons', array( 'emo_set =?', $emoticon['emo_set'] ) )->first();
|
||||
|
||||
if ( $emoticons == 0 )
|
||||
{
|
||||
\IPS\Lang::deleteCustom( 'core', 'core_emoticon_group_'. $emoticon['emo_set'] );
|
||||
Lang::deleteCustom( 'core', 'core_emoticon_group_'. $emoticon['emo_set'] );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__emoticon_deleted' );
|
||||
Session::i()->log( 'acplog__emoticon_deleted' );
|
||||
|
||||
\IPS\Settings::i()->changeValues( array( 'emoji_cache' => time() ) );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
Settings::i()->changeValues( array( 'emoji_cache' => time() ) );
|
||||
unset( Cache::i()->core_editor_emoji_sets ); // clear the cache
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
catch ( UnderflowException $e ) { }
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=editor&controller=emoticons&tab=custom' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=editor&controller=emoticons&tab=custom' ), 'saved' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -389,36 +421,34 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function deleteSet()
|
||||
public function deleteSet() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'emoticons_delete' );
|
||||
Dispatcher::i()->checkAcpPermission( 'emoticons_delete' );
|
||||
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
Request::i()->confirmedDelete();
|
||||
|
||||
$set = preg_replace( '/^core_emoticon_group_/', '', \IPS\Request::i()->key );
|
||||
$set = preg_replace( '/^core_emoticon_group_/', '', Request::i()->key );
|
||||
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_emoticons', array( 'emo_set=?', $set ) ) as $emoticon )
|
||||
foreach ( Db::i()->select( '*', 'core_emoticons', array( 'emo_set=?', $set ) ) as $emoticon )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'core_Emoticons', $emoticon['image'] )->delete();
|
||||
\IPS\File::get( 'core_Emoticons', $emoticon['image_2x'] )->delete();
|
||||
File::get( 'core_Emoticons', $emoticon['image'] )->delete();
|
||||
File::get( 'core_Emoticons', $emoticon['image_2x'] )->delete();
|
||||
}
|
||||
catch ( \UnderflowException $e ) { }
|
||||
catch ( UnderflowException $e ) { }
|
||||
}
|
||||
|
||||
\IPS\Db::i()->delete( 'core_emoticons', array( 'emo_set=?', $set ) );
|
||||
\IPS\Lang::deleteCustom( 'core', 'core_emoticon_group_'. $set );
|
||||
Db::i()->delete( 'core_emoticons', array( 'emo_set=?', $set ) );
|
||||
Lang::deleteCustom( 'core', 'core_emoticon_group_'. $set );
|
||||
|
||||
\IPS\Settings::i()->changeValues( array( 'emoji_cache' => time() ) );
|
||||
|
||||
/* Clear guest page caches */
|
||||
\IPS\Data\Cache::i()->clearAll();
|
||||
Settings::i()->changeValues( array( 'emoji_cache' => time() ) );
|
||||
unset( Cache::i()->core_editor_emoji_sets ); // clear the cache
|
||||
|
||||
\IPS\Session::i()->log( 'acplog__emoticon_set_deleted' );
|
||||
Session::i()->log( 'acplog__emoticon_set_deleted' );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=editor&controller=emoticons&tab=custom' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=editor&controller=emoticons&tab=custom' ), 'saved' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -426,28 +456,28 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function editTitle()
|
||||
protected function editTitle() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'emoticons_edit' );
|
||||
Dispatcher::i()->checkAcpPermission( 'emoticons_edit' );
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->class = 'ipsForm_vertical ipsForm_fullWidth';
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'emoticons_add_newgroup', NULL, FALSE, array( 'app' => 'core', 'key' => \IPS\Request::i()->key ), NULL, NULL, NULL, 'emoticons_add_newgroup' ) );
|
||||
$form = new Form;
|
||||
$form->class = 'ipsForm--vertical ipsForm--edit-emoticon-group ipsForm_fullWidth';
|
||||
$form->add( new Translatable( 'emoticons_add_newgroup', NULL, FALSE, array( 'app' => 'core', 'key' => Request::i()->key ), NULL, NULL, NULL, 'emoticons_add_newgroup' ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
\IPS\Lang::saveCustom( 'core', \IPS\Request::i()->key, $values['emoticons_add_newgroup'] );
|
||||
Lang::saveCustom( 'core', Request::i()->key, $values['emoticons_add_newgroup'] );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=editor&controller=emoticons&tab=custom' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=core&module=editor&controller=emoticons&tab=custom' ), 'saved' );
|
||||
}
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
if( Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
return;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global' )->block( 'emoticons_edit_groupname', $form, FALSE );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'global' )->block( 'emoticons_edit_groupname', $form, FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -456,10 +486,10 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
* @param bool $group Group by their group?
|
||||
* @return array
|
||||
*/
|
||||
protected function _getEmoticons( $group=TRUE )
|
||||
protected function _getEmoticons( bool $group=TRUE ) : array
|
||||
{
|
||||
$emoticons = array();
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_emoticons', NULL, 'emo_set_position,emo_position' ) as $row )
|
||||
foreach ( Db::i()->select( '*', 'core_emoticons', NULL, 'emo_set_position,emo_position' ) as $row )
|
||||
{
|
||||
if ( $group )
|
||||
{
|
||||
@@ -480,12 +510,10 @@ class _emoticons extends \IPS\Dispatcher\Controller
|
||||
* @param string $path Emoticon path
|
||||
* @return string
|
||||
*/
|
||||
protected function _getRawFilename( $path )
|
||||
protected function _getRawFilename( string $path ) : string
|
||||
{
|
||||
$parts = explode( '/', $path );
|
||||
$filenamePart = array_pop( $parts );
|
||||
$filename = mb_substr( $filenamePart, 0, mb_strrpos( $filenamePart, '.' ) );
|
||||
|
||||
return $filename;
|
||||
return mb_substr( $filenamePart, 0, mb_strrpos( $filenamePart, '.' ) );
|
||||
}
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief settings
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 13 Aug 2015
|
||||
*/
|
||||
|
||||
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
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* 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 */
|
||||
$methodToCall = '_manage' . mb_ucfirst( $this->activeTab );
|
||||
$activeTabContents = $this->$methodToCall();
|
||||
|
||||
/* 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'
|
||||
) ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'enable_bbcode', \IPS\Settings::i()->enable_bbcode, FALSE ) );
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief Editor Stored Replies aka Stock Actions aka whatever else I rename it during this coding session
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
@@ -12,35 +13,47 @@
|
||||
namespace IPS\core\modules\admin\editor;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\StoredReplies as StoredRepliesClass;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Node\Controller;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stored Replies
|
||||
*/
|
||||
class _storedreplies extends \IPS\Node\Controller
|
||||
class storedreplies extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\core\StoredReplies';
|
||||
protected string $nodeClass = 'IPS\core\StoredReplies';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'stored_replies_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'stored_replies_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -49,49 +62,12 @@ class _storedreplies extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
public function manage() : void
|
||||
{
|
||||
/* Have we not dragged the button to the editor bar? */
|
||||
$toolbars = json_decode( \IPS\Settings::i()->ckeditor_toolbars, true );
|
||||
$found = 0;
|
||||
foreach ( array('desktop', 'tablet', 'phone') as $device )
|
||||
{
|
||||
foreach ( $toolbars[$device] as $row )
|
||||
{
|
||||
if ( \is_array( $row ) and isset( $row['items'] ) )
|
||||
{
|
||||
if ( \in_array( 'ipsstockreplies', $row['items'] ) )
|
||||
{
|
||||
$found++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Do we have any stored replies yet? */
|
||||
if ( \IPS\Db::i()->select('count(*)', 'core_editor_stored_replies' )->first() )
|
||||
{
|
||||
if ( $found > 0 and $found < 3 )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( 'editor_stored_replies_not_all_editors_have_button', 'info' );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $found == 0 )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( 'editor_stored_replies_no_editor_has_button', 'warning' );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $found )
|
||||
{
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( 'editor_stored_replies_none_created_button', 'info' );
|
||||
}
|
||||
}
|
||||
|
||||
parent::manage();
|
||||
|
||||
Output::i()->output = Theme::i()->getTemplate( 'forms', 'core' )->blurb( 'editor_stored_replies_blurb' ) . Output::i()->output;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +75,7 @@ class _storedreplies extends \IPS\Node\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function search()
|
||||
protected function search() : void
|
||||
{
|
||||
$rows = array();
|
||||
|
||||
@@ -108,12 +84,13 @@ class _storedreplies extends \IPS\Node\Controller
|
||||
$results = [];
|
||||
|
||||
/* Convert to HTML */
|
||||
foreach ( $nodeClass::search( 'reply_title', \IPS\Request::i()->input, 'reply_title' ) as $result )
|
||||
/* @var StoredRepliesClass $nodeClass */
|
||||
foreach ( $nodeClass::search( 'reply_title', Request::i()->input, 'reply_title' ) as $result )
|
||||
{
|
||||
$id = ( $result instanceof $this->nodeClass ? '' : 's.' ) . $result->_id;
|
||||
$rows[ $id ] = $this->_getRow( $result, FALSE, TRUE );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'trees', 'core' )->rows( $rows, '' );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'trees', 'core' )->rows( $rows, '' );
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user