Skip to content

Commit cdae4c7

Browse files
committed
More independant BBCode Toolbar plugin
Allow passing php vars into JS block
1 parent 9d597a5 commit cdae4c7

File tree

12 files changed

+7
-81
lines changed

12 files changed

+7
-81
lines changed

featherbb/Controller/Post.php

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -189,25 +189,6 @@ public function newpost($fid = null, $tid = null, $qid = null)
189189
$post_data = '';
190190
}
191191

192-
$lang_bbeditor = array(
193-
'btnBold' => __('btnBold'),
194-
'btnItalic' => __('btnItalic'),
195-
'btnUnderline' => __('btnUnderline'),
196-
'btnColor' => __('btnColor'),
197-
'btnLeft' => __('btnLeft'),
198-
'btnRight' => __('btnRight'),
199-
'btnJustify' => __('btnJustify'),
200-
'btnCenter' => __('btnCenter'),
201-
'btnLink' => __('btnLink'),
202-
'btnPicture' => __('btnPicture'),
203-
'btnList' => __('btnList'),
204-
'btnQuote' => __('btnQuote'),
205-
'btnCode' => __('btnCode'),
206-
'promptImage' => __('promptImage'),
207-
'promptUrl' => __('promptUrl'),
208-
'promptQuote' => __('promptQuote')
209-
);
210-
211192
$this->feather->template->setPageInfo(array(
212193
'title' => array(Utils::escape($this->feather->forum_settings['o_board_title']), $action),
213194
'required_fields' => $required_fields,
@@ -219,7 +200,6 @@ public function newpost($fid = null, $tid = null, $qid = null)
219200
'cur_posting' => $cur_posting,
220201
'lang_antispam' => $lang_antispam,
221202
'lang_antispam_questions' => $lang_antispam_questions,
222-
'lang_bbeditor' => $lang_bbeditor,
223203
'index_questions' => $index_questions,
224204
'checkboxes' => $checkboxes,
225205
'action' => $action,
@@ -336,25 +316,6 @@ public function editpost($id)
336316
$preview_message = '';
337317
}
338318

339-
$lang_bbeditor = array(
340-
'btnBold' => __('btnBold'),
341-
'btnItalic' => __('btnItalic'),
342-
'btnUnderline' => __('btnUnderline'),
343-
'btnColor' => __('btnColor'),
344-
'btnLeft' => __('btnLeft'),
345-
'btnRight' => __('btnRight'),
346-
'btnJustify' => __('btnJustify'),
347-
'btnCenter' => __('btnCenter'),
348-
'btnLink' => __('btnLink'),
349-
'btnPicture' => __('btnPicture'),
350-
'btnList' => __('btnList'),
351-
'btnQuote' => __('btnQuote'),
352-
'btnCode' => __('btnCode'),
353-
'promptImage' => __('promptImage'),
354-
'promptUrl' => __('promptUrl'),
355-
'promptQuote' => __('promptQuote')
356-
);
357-
358319
$this->feather->template->setPageInfo(array(
359320
'title' => array(Utils::escape($this->feather->config['o_board_title']), __('Edit post')),
360321
'required_fields' => array('req_subject' => __('Subject'), 'req_message' => __('Message')),
@@ -365,7 +326,6 @@ public function editpost($id)
365326
'id' => $id,
366327
'checkboxes' => $this->model->get_edit_checkboxes($can_edit_subject, $is_admmod, $cur_post, 1),
367328
'can_edit_subject' => $can_edit_subject,
368-
'lang_bbeditor' => $lang_bbeditor,
369329
'post' => $post,
370330
)
371331
)->addTemplate('edit.php')->display();

featherbb/Controller/Topic.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public function __construct()
2323
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->feather->user->language.'/topic.mo');
2424
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->feather->user->language.'/misc.mo'); // To be removed
2525
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->feather->user->language.'/post.mo');
26-
load_textdomain('featherbb', $this->feather->forum_env['FEATHER_ROOT'].'featherbb/lang/'.$this->feather->user->language.'/bbeditor.mo');
2726
}
2827

2928
public function display($id = null, $name = null, $page = null, $pid = null)
@@ -70,25 +69,6 @@ public function display($id = null, $name = null, $page = null, $pid = null)
7069
$quickpost = $this->model->is_quickpost($cur_topic['post_replies'], $cur_topic['closed'], $is_admmod);
7170
$subscraction = $this->model->get_subscraction($cur_topic['is_subscribed'], $id);
7271

73-
$lang_bbeditor = array(
74-
'btnBold' => __('btnBold'),
75-
'btnItalic' => __('btnItalic'),
76-
'btnUnderline' => __('btnUnderline'),
77-
'btnColor' => __('btnColor'),
78-
'btnLeft' => __('btnLeft'),
79-
'btnRight' => __('btnRight'),
80-
'btnJustify' => __('btnJustify'),
81-
'btnCenter' => __('btnCenter'),
82-
'btnLink' => __('btnLink'),
83-
'btnPicture' => __('btnPicture'),
84-
'btnList' => __('btnList'),
85-
'btnQuote' => __('btnQuote'),
86-
'btnCode' => __('btnCode'),
87-
'promptImage' => __('promptImage'),
88-
'promptUrl' => __('promptUrl'),
89-
'promptQuote' => __('promptQuote')
90-
);
91-
9272
$this->feather->template->addAsset('canonical', $this->feather->urlFor('Forum', ['id' => $id, 'name' => $url_forum]));
9373
if ($num_pages > 1) {
9474
if ($p > 1) {
@@ -124,7 +104,6 @@ public function display($id = null, $name = null, $page = null, $pid = null)
124104
'quickpost' => $quickpost,
125105
'index_questions' => $index_questions,
126106
'lang_antispam_questions' => $lang_antispam_questions,
127-
'lang_bbeditor' => $lang_bbeditor,
128107
'url_forum' => $url_forum,
129108
'url_topic' => $url_topic,
130109
))->addTemplate('topic.php')->display();

featherbb/View/edit.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@
7070
<?php
7171
endif;
7272
?>
73-
<!-- Init BBcode editor toolbar -->
74-
<script>
75-
var baseUrl = '<?= Utils::escape(Url::base(true)); ?>',
76-
langBbeditor = <?= json_encode($lang_bbeditor, JSON_PRETTY_PRINT); ?>;
77-
</script>
7873
<div id="editform" class="blockform">
7974
<h2><span><?php _e('Edit post') ?></span></h2>
8075
<div class="box">

featherbb/View/footer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@
157157
</section>
158158
</body>
159159
<!-- JS -->
160-
160+
<script>
161+
var baseUrl = '<?= Utils::escape(Url::base(true)); ?>',
162+
phpVars = <?= isset($jsVars) ? json_encode($jsVars) : json_encode(array()); ?>;
163+
</script>
161164
<?php foreach ($assets['js'] as $script) {
162165
echo '<script ';
163166
foreach ($script['params'] as $key => $value) {

featherbb/View/post.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,6 @@
7777

7878
$cur_index = 1;
7979
?>
80-
<!-- Init BBcode editor toolbar -->
81-
<script>
82-
var baseUrl = '<?= Utils::escape(Url::base(true)); ?>',
83-
langBbeditor = <?= json_encode($lang_bbeditor, JSON_PRETTY_PRINT); ?>;
84-
</script>
85-
8680
<div id="postform" class="blockform">
8781
<h2><span><?= $action ?></span></h2>
8882
<div class="box">

featherbb/View/topic.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,6 @@
156156
}
157157

158158
?>
159-
<!-- Init BBcode editor toolbar -->
160-
<script>
161-
var baseUrl = '<?= Utils::escape(Url::base(true)); ?>',
162-
langBbeditor = <?= json_encode($lang_bbeditor, JSON_PRETTY_PRINT); ?>;
163-
</script>
164-
165159
<textarea name="req_message" id="req_message" rows="7" cols="75" tabindex="<?= $cur_index++ ?>"></textarea></label>
166160
<ul class="bblinks">
167161
<li><span><a href="<?= $feather->urlFor('help').'#bbcode' ?>" onclick="window.open(this.href); return false;"><?php _e('BBCode') ?></a> <?php echo($feather->forum_settings['p_message_bbcode'] == '1') ? __('on') : __('off');
File renamed without changes.
File renamed without changes.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
/*****************************************/
99
// Inspired by :
10-
1110
// Name: Javascript Textarea BBCode Markup Editor
1211
// Version: 1.3
1312
// Author: Balakrishnan
@@ -24,7 +23,9 @@ var textarea,
2423
target.insertAdjacentHTML( 'beforeBegin', toolbar );
2524

2625
function postEditorToolbar(obj) {
27-
var output = '';
26+
// Get translations from js block in footer
27+
var langBbeditor = JSON.parse(phpVars.bbcodeToolbar),
28+
output = '';
2829
// Toolbar buttons
2930
output += "<div class=\"toolbar\">";
3031
output += "<img class=\"toolbar-icon\" src=\""+baseUrl+"/style/img/bbeditor/bold.png\" name=\"btnBold\" title=\""+langBbeditor.btnBold+"\" onClick=\"doAddTags('[b]','[/b]','" + obj + "')\">";

0 commit comments

Comments
 (0)