|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Copyright (C) 2015-2016 FeatherBB |
| 5 | + * based on code by (C) 2008-2012 FluxBB |
| 6 | + * and Rickard Andersson (C) 2002-2008 PunBB |
| 7 | + * License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher |
| 8 | + */ |
| 9 | + |
| 10 | +namespace FeatherBB\Plugins; |
| 11 | + |
| 12 | +use FeatherBB\Core\Plugin as BasePlugin; |
| 13 | + |
| 14 | +class BbcodeToolbar extends BasePlugin |
| 15 | +{ |
| 16 | + |
| 17 | + public function run() |
| 18 | + { |
| 19 | + // Add language files into javascript footer block |
| 20 | + $this->feather->hooks->bind('view.alter_data', [$this, 'addLanguage']); |
| 21 | + // Support default actions |
| 22 | + $this->hooks->bind('controller.post.create', [$this, 'addToolbar']); |
| 23 | + $this->hooks->bind('controller.post.edit', [$this, 'addToolbar']); |
| 24 | + $this->hooks->bind('controller.topic.display', [$this, 'addToolbar']); |
| 25 | + // Support PMs plugin |
| 26 | + $this->hooks->bind('conversationsPlugin.send.preview', [$this, 'addToolbar']); |
| 27 | + $this->hooks->bind('conversationsPlugin.send.display', [$this, 'addToolbar']); |
| 28 | + } |
| 29 | + |
| 30 | + public function addLanguage($data) |
| 31 | + { |
| 32 | + load_textdomain('bbcode-toolbar', dirname(__FILE__).'/lang/'.$this->feather->user->language.'/bbeditor.mo'); |
| 33 | + $lang_bbeditor = array( |
| 34 | + 'btnBold' => __('btnBold', 'bbcode-toolbar'), |
| 35 | + 'btnItalic' => __('btnItalic', 'bbcode-toolbar'), |
| 36 | + 'btnUnderline' => __('btnUnderline', 'bbcode-toolbar'), |
| 37 | + 'btnColor' => __('btnColor', 'bbcode-toolbar'), |
| 38 | + 'btnLeft' => __('btnLeft', 'bbcode-toolbar'), |
| 39 | + 'btnRight' => __('btnRight', 'bbcode-toolbar'), |
| 40 | + 'btnJustify' => __('btnJustify', 'bbcode-toolbar'), |
| 41 | + 'btnCenter' => __('btnCenter', 'bbcode-toolbar'), |
| 42 | + 'btnLink' => __('btnLink', 'bbcode-toolbar'), |
| 43 | + 'btnPicture' => __('btnPicture', 'bbcode-toolbar'), |
| 44 | + 'btnList' => __('btnList', 'bbcode-toolbar'), |
| 45 | + 'btnQuote' => __('btnQuote', 'bbcode-toolbar'), |
| 46 | + 'btnCode' => __('btnCode', 'bbcode-toolbar'), |
| 47 | + 'promptImage' => __('promptImage', 'bbcode-toolbar'), |
| 48 | + 'promptUrl' => __('promptUrl', 'bbcode-toolbar'), |
| 49 | + 'promptQuote' => __('promptQuote', 'bbcode-toolbar') |
| 50 | + ); |
| 51 | + $data['jsVars']['bbcodeToolbar'] = json_encode($lang_bbeditor); |
| 52 | + return $data; |
| 53 | + } |
| 54 | + |
| 55 | + public function addToolbar() |
| 56 | + { |
| 57 | + $this->feather->template->addAsset('css', 'plugins/bbcode-toolbar/style/bbeditor.css', array('type' => 'text/css', 'rel' => 'stylesheet')); |
| 58 | + $this->feather->template->addAsset('css', 'plugins/bbcode-toolbar/style/colorPicker.css', array('type' => 'text/css', 'rel' => 'stylesheet')); |
| 59 | + $this->feather->template->addAsset('js', 'plugins/bbcode-toolbar/style/bbeditor.js', array('type' => 'text/javascript')); |
| 60 | + $this->feather->template->addAsset('js', 'plugins/bbcode-toolbar/style/colorPicker.js', array('type' => 'text/javascript')); |
| 61 | + return true; |
| 62 | + } |
| 63 | + |
| 64 | +} |
0 commit comments