diff --git a/Sources/Editor.php b/Sources/Editor.php index 3eab1f4beb..5c14756d8d 100644 --- a/Sources/Editor.php +++ b/Sources/Editor.php @@ -20,7 +20,7 @@ /** * Creates the editor input box so that people can write messages to post. - * + * * Provides a configurable rich text editor with support for BBCodes, smileys, * and various toolbar customizations. Integrates with theme and language settings, * and supports plugin extensions via integration hooks. @@ -205,22 +205,34 @@ class Editor implements \ArrayAccess, \Stringable * Public static properties **************************/ - /** @var array All loaded Editor instances, keyed by ID. */ + /** + * @var array All loaded Editor instances, keyed by ID. + */ public static array $loaded = []; - /** @var array BBC tags configuration for the toolbar. */ + /** + * @var array BBC tags configuration for the toolbar. + */ public static array $bbc_tags = []; - /** @var array Disabled BBC tags for this context. */ + /** + * @var array Disabled BBC tags for this context. + */ public static array $disabled_tags = []; - /** @var array BBC toolbar groups. */ + /** + * @var array BBC toolbar groups. + */ public static array $bbc_toolbar = []; - /** @var array Handlers for custom BBC toolbar commands. */ + /** + * @var array Handlers for custom BBC toolbar commands. + */ public static array $bbc_handlers = []; - /** @var array Smileys to show in the toolbar. */ + /** + * @var array Smileys to show in the toolbar. + */ public static array $smileys_toolbar = []; /********************* @@ -498,180 +510,6 @@ public static function getMessageIcons(int $board_id): array return array_values($icons); } - /************************* - * Internal static methods - *************************/ - - /** - * Initializes default BBC tags for the toolbar. - */ - protected static function initBbcTags(): void - { - // The below array makes it dead easy to add images to this control. Add it to the array and everything else is done for you! - /* - array( - 'code' => 'b', // Required - 'description' => Lang::$editortxt['bold'], // Required - 'image' => 'bold', // Optional - 'before' => '[b]', // Optional - 'after' => '[/b]', // Optional - ), - */ - self::$bbc_tags = [ - [ - [ - 'code' => 'bold', - 'description' => Lang::getTxt('bold', var: 'editortxt'), - ], - [ - 'code' => 'italic', - 'description' => Lang::getTxt('italic', var: 'editortxt'), - ], - [ - 'code' => 'underline', - 'description' => Lang::getTxt('underline', var: 'editortxt'), - ], - [ - 'code' => 'strike', - 'description' => Lang::getTxt('strikethrough', var: 'editortxt'), - ], - [ - 'code' => 'superscript', - 'description' => Lang::getTxt('superscript', var: 'editortxt'), - ], - [ - 'code' => 'subscript', - 'description' => Lang::getTxt('subscript', var: 'editortxt'), - ], - [ - 'image' => 'tt', - 'code' => 'tt', - 'description' => Lang::getTxt('tt', var: 'editortxt'), - ], - [ - 'image' => 'hidden', - 'code' => 'spoiler', - 'description' => Lang::getTxt('spoiler', var: 'editortxt'), - ], - [], - [ - 'code' => 'pre', - 'description' => Lang::getTxt('preformatted_text', var: 'editortxt'), - ], - [ - 'code' => 'left', - 'description' => Lang::getTxt('align_left', var: 'editortxt'), - ], - [ - 'code' => 'center', - 'description' => Lang::getTxt('center', var: 'editortxt'), - ], - [ - 'code' => 'right', - 'description' => Lang::getTxt('align_right', var: 'editortxt'), - ], - [ - 'code' => 'justify', - 'description' => Lang::getTxt('justify', var: 'editortxt'), - ], - [], - [ - 'code' => 'font', - 'description' => Lang::getTxt('font_name', var: 'editortxt'), - ], - [ - 'code' => 'size', - 'description' => Lang::getTxt('font_size', var: 'editortxt'), - ], - [ - 'code' => 'color', - 'description' => Lang::getTxt('font_color', var: 'editortxt'), - ], - [], - [ - 'code' => 'removeformat', - 'description' => Lang::getTxt('remove_formatting', var: 'editortxt'), - ], - ], - [ - [ - 'code' => 'floatleft', - 'description' => Lang::getTxt('float_left', var: 'editortxt'), - ], - [ - 'code' => 'floatright', - 'description' => Lang::getTxt('float_right', var: 'editortxt'), - ], - [], - [ - 'code' => 'youtube', - 'description' => Lang::getTxt('insert_youtube_video', var: 'editortxt'), - ], - [ - 'code' => 'image', - 'description' => Lang::getTxt('insert_image', var: 'editortxt'), - ], - [ - 'code' => 'email', - 'description' => Lang::getTxt('insert_email', var: 'editortxt'), - ], - [ - 'code' => 'link', - 'description' => Lang::getTxt('insert_link', var: 'editortxt'), - ], - [ - 'code' => 'unlink', - 'description' => Lang::getTxt('unlink', var: 'editortxt'), - ], - [], - [ - 'code' => 'table', - 'description' => Lang::getTxt('insert_table', var: 'editortxt'), - ], - [ - 'code' => 'code', - 'description' => Lang::getTxt('code', var: 'editortxt'), - ], - [ - 'code' => 'quote', - 'description' => Lang::getTxt('insert_quote', var: 'editortxt'), - ], - [ - 'image' => 'details', - 'code' => 'details', - 'description' => Lang::getTxt('details', var: 'editortxt'), - ], - [], - [ - 'image' => 'heading', - 'code' => 'heading', - 'description' => Lang::getTxt('heading', var: 'editortxt'), - ], - [ - 'code' => 'bulletlist', - 'description' => Lang::getTxt('bullet_list', var: 'editortxt'), - ], - [ - 'code' => 'orderedlist', - 'description' => Lang::getTxt('numbered_list', var: 'editortxt'), - ], - [ - 'code' => 'horizontalrule', - 'description' => Lang::getTxt('insert_horizontal_rule', var: 'editortxt'), - ], - [], - [ - 'code' => 'maximize', - 'description' => Lang::getTxt('maximize', var: 'editortxt'), - ], - [ - 'code' => 'source', - 'description' => Lang::getTxt('view_source', var: 'editortxt'), - ], - ], - ]; - } - /****************** * Internal methods ******************/ @@ -796,7 +634,6 @@ protected function buildButtons(): void * Sets up available BBC tags, disables tags as required, applies integration hooks, * and builds the toolbar structure for rendering. * - * @return void */ protected function buildBbcToolbar(): void { @@ -891,7 +728,7 @@ protected function implodeRecursive(array $glue, array $pieces, int $counter = 0 return implode( $glue[$counter++], array_map( - fn($v) => is_array($v) ? $this->implodeRecursive($glue, $v, $counter) : $v, + fn($v) => \is_array($v) ? $this->implodeRecursive($glue, $v, $counter) : $v, $pieces, ), ); @@ -947,7 +784,6 @@ protected function buildSmileysToolbar(): void * applies integration hooks and user-supplied overrides. * * @param array $editorOptions SCEditor options/overrides. - * @return void */ protected function setSCEditorOptions(array $editorOptions) { @@ -1039,4 +875,178 @@ protected function setSCEditorOptions(array $editorOptions) // Useful if, e.g., a mod wants to add an SCEditor plugin. IntegrationHook::call('integrate_sceditor_options', [&$this->sce_options]); } + + /************************* + * Internal static methods + *************************/ + + /** + * Initializes default BBC tags for the toolbar. + */ + protected static function initBbcTags(): void + { + // The below array makes it dead easy to add images to this control. Add it to the array and everything else is done for you! + /* + array( + 'code' => 'b', // Required + 'description' => Lang::$editortxt['bold'], // Required + 'image' => 'bold', // Optional + 'before' => '[b]', // Optional + 'after' => '[/b]', // Optional + ), + */ + self::$bbc_tags = [ + [ + [ + 'code' => 'bold', + 'description' => Lang::getTxt('bold', var: 'editortxt'), + ], + [ + 'code' => 'italic', + 'description' => Lang::getTxt('italic', var: 'editortxt'), + ], + [ + 'code' => 'underline', + 'description' => Lang::getTxt('underline', var: 'editortxt'), + ], + [ + 'code' => 'strike', + 'description' => Lang::getTxt('strikethrough', var: 'editortxt'), + ], + [ + 'code' => 'superscript', + 'description' => Lang::getTxt('superscript', var: 'editortxt'), + ], + [ + 'code' => 'subscript', + 'description' => Lang::getTxt('subscript', var: 'editortxt'), + ], + [ + 'image' => 'tt', + 'code' => 'tt', + 'description' => Lang::getTxt('tt', var: 'editortxt'), + ], + [ + 'image' => 'hidden', + 'code' => 'spoiler', + 'description' => Lang::getTxt('spoiler', var: 'editortxt'), + ], + [], + [ + 'code' => 'pre', + 'description' => Lang::getTxt('preformatted_text', var: 'editortxt'), + ], + [ + 'code' => 'left', + 'description' => Lang::getTxt('align_left', var: 'editortxt'), + ], + [ + 'code' => 'center', + 'description' => Lang::getTxt('center', var: 'editortxt'), + ], + [ + 'code' => 'right', + 'description' => Lang::getTxt('align_right', var: 'editortxt'), + ], + [ + 'code' => 'justify', + 'description' => Lang::getTxt('justify', var: 'editortxt'), + ], + [], + [ + 'code' => 'font', + 'description' => Lang::getTxt('font_name', var: 'editortxt'), + ], + [ + 'code' => 'size', + 'description' => Lang::getTxt('font_size', var: 'editortxt'), + ], + [ + 'code' => 'color', + 'description' => Lang::getTxt('font_color', var: 'editortxt'), + ], + [], + [ + 'code' => 'removeformat', + 'description' => Lang::getTxt('remove_formatting', var: 'editortxt'), + ], + ], + [ + [ + 'code' => 'floatleft', + 'description' => Lang::getTxt('float_left', var: 'editortxt'), + ], + [ + 'code' => 'floatright', + 'description' => Lang::getTxt('float_right', var: 'editortxt'), + ], + [], + [ + 'code' => 'youtube', + 'description' => Lang::getTxt('insert_youtube_video', var: 'editortxt'), + ], + [ + 'code' => 'image', + 'description' => Lang::getTxt('insert_image', var: 'editortxt'), + ], + [ + 'code' => 'email', + 'description' => Lang::getTxt('insert_email', var: 'editortxt'), + ], + [ + 'code' => 'link', + 'description' => Lang::getTxt('insert_link', var: 'editortxt'), + ], + [ + 'code' => 'unlink', + 'description' => Lang::getTxt('unlink', var: 'editortxt'), + ], + [], + [ + 'code' => 'table', + 'description' => Lang::getTxt('insert_table', var: 'editortxt'), + ], + [ + 'code' => 'code', + 'description' => Lang::getTxt('code', var: 'editortxt'), + ], + [ + 'code' => 'quote', + 'description' => Lang::getTxt('insert_quote', var: 'editortxt'), + ], + [ + 'image' => 'details', + 'code' => 'details', + 'description' => Lang::getTxt('details', var: 'editortxt'), + ], + [], + [ + 'image' => 'heading', + 'code' => 'heading', + 'description' => Lang::getTxt('heading', var: 'editortxt'), + ], + [ + 'code' => 'bulletlist', + 'description' => Lang::getTxt('bullet_list', var: 'editortxt'), + ], + [ + 'code' => 'orderedlist', + 'description' => Lang::getTxt('numbered_list', var: 'editortxt'), + ], + [ + 'code' => 'horizontalrule', + 'description' => Lang::getTxt('insert_horizontal_rule', var: 'editortxt'), + ], + [], + [ + 'code' => 'maximize', + 'description' => Lang::getTxt('maximize', var: 'editortxt'), + ], + [ + 'code' => 'source', + 'description' => Lang::getTxt('view_source', var: 'editortxt'), + ], + ], + ]; + } }