Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -0,0 +1,96 @@
|
||||
<?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>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Code
|
||||
* @since 03 September 2021
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stored Replies
|
||||
*/
|
||||
class _storedreplies extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\core\StoredReplies';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'stored_replies_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function manage()
|
||||
{
|
||||
/* 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();
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,7 @@ class _toolbar extends \IPS\Dispatcher\Controller
|
||||
'ipssource',
|
||||
'ipsspoiler',
|
||||
'ipsgiphy',
|
||||
'ipsstockreplies',
|
||||
'justify',
|
||||
'lineutils',
|
||||
'list',
|
||||
@@ -203,12 +204,25 @@ class _toolbar extends \IPS\Dispatcher\Controller
|
||||
/* Custom Plugin */
|
||||
if ( preg_match( '/^custom-(\w{32})$/i', $button, $matches ) and !\IPS\IN_DEV and !\IPS\NO_WRITES )
|
||||
{
|
||||
$code = file_get_contents( \IPS\ROOT_PATH . "/applications/core/interface/ckeditor/ckeditor/plugins/{$matches[0]}/plugin.js" );
|
||||
|
||||
$option = file_exists( \IPS\ROOT_PATH . "/applications/core/interface/ckeditor/ckeditor/plugins/{$matches[0]}/dialogs/{$matches[0]}.js" );
|
||||
if ( $option )
|
||||
if ( \IPS\CIC2 )
|
||||
{
|
||||
$code = file_get_contents( \IPS\ROOT_PATH . "/applications/core/interface/ckeditor/ckeditor/plugins/{$matches[0]}/dialogs/{$matches[0]}.js" );
|
||||
$code = file_get_contents( \IPS\SITE_FILES_PATH . "/ckeditor_custom/{$matches[0]}/plugin.js" );
|
||||
|
||||
$option = file_exists( \IPS\SITE_FILES_PATH . "/ckeditor_custom/{$matches[0]}/dialogs/{$matches[0]}.js" );
|
||||
if ( $option )
|
||||
{
|
||||
$code = file_get_contents( \IPS\SITE_FILES_PATH . "/ckeditor_custom/{$matches[0]}/dialogs/{$matches[0]}.js" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = file_get_contents( \IPS\ROOT_PATH . "/applications/core/interface/ckeditor/ckeditor/plugins/{$matches[0]}/plugin.js" );
|
||||
|
||||
$option = file_exists( \IPS\ROOT_PATH . "/applications/core/interface/ckeditor/ckeditor/plugins/{$matches[0]}/dialogs/{$matches[0]}.js" );
|
||||
if ( $option )
|
||||
{
|
||||
$code = file_get_contents( \IPS\ROOT_PATH . "/applications/core/interface/ckeditor/ckeditor/plugins/{$matches[0]}/dialogs/{$matches[0]}.js" );
|
||||
}
|
||||
}
|
||||
|
||||
$type = 'inline';
|
||||
@@ -900,7 +914,7 @@ JS;
|
||||
$dir = \IPS\ROOT_PATH . '/applications/core/interface/ckeditor/ckeditor/plugins/' . $key;
|
||||
if ( is_dir( $dir ) )
|
||||
{
|
||||
$this->_recursiveDelete( $dir );
|
||||
$this->_recursiveRmDir( $dir );
|
||||
}
|
||||
|
||||
/* Remove from plugin list */
|
||||
@@ -924,33 +938,6 @@ JS;
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=core&module=editor&controller=toolbar' ), 'saved' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive delete
|
||||
*
|
||||
* @param string $dir Directory
|
||||
* @return void
|
||||
*/
|
||||
protected function _recursiveDelete( $dir )
|
||||
{
|
||||
foreach ( new \DirectoryIterator( $dir ) as $file )
|
||||
{
|
||||
if ( !$file->isDot() )
|
||||
{
|
||||
if ( $file->isDir() )
|
||||
{
|
||||
$this->_recursiveDelete( $file->getPathname() );
|
||||
}
|
||||
else
|
||||
{
|
||||
unlink( $file->getPathname() );
|
||||
}
|
||||
}
|
||||
}
|
||||
$handle = opendir( $dir );
|
||||
closedir ( $handle );
|
||||
rmdir( $dir );
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert Editor back to default
|
||||
*
|
||||
@@ -968,7 +955,11 @@ JS;
|
||||
{
|
||||
if ( \IPS\CIC2 )
|
||||
{
|
||||
\IPS\Cicloud\folderDelete( "ckeditor_custom/{$key}" );
|
||||
if ( is_dir( \IPS\SITE_FILES_PATH . '/ckeditor_custom/' . $key ) )
|
||||
{
|
||||
/* If this is cloud we only need the key */
|
||||
$this->_recursiveRmDir( $key );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user