Skip to content

Commit ca5191f

Browse files
committed
Add post preview capability
1 parent 2a7c1af commit ca5191f

3 files changed

Lines changed: 28 additions & 3 deletions

File tree

controller/post_controller.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ public function post()
4545
include $this->root_path . 'includes/functions_display.' . $this->php_ext;
4646
}
4747

48-
$mode = $this->request->variable('mode', '');
4948
$title = $this->request->variable('title', '', true);
5049
$message = $this->request->variable('message', '', true);
5150

52-
if ($mode === 'submit')
51+
if ($this->request->is_set_post('post'))
5352
{
5453
$submit = $this->ideas->submit($title, $message, $this->user->data['user_id']);
5554

@@ -71,6 +70,17 @@ public function post()
7170
}
7271
}
7372

73+
if ($this->request->is_set_post('preview'))
74+
{
75+
$preview_message = $this->ideas->preview($message);
76+
77+
$this->template->assign_vars(array(
78+
'S_DISPLAY_PREVIEW' => !empty($preview_message),
79+
'PREVIEW_SUBJECT' => $title,
80+
'PREVIEW_MESSAGE' => $preview_message,
81+
));
82+
}
83+
7484
display_custom_bbcodes();
7585
generate_smilies('inline', 0);
7686

@@ -83,8 +93,9 @@ public function post()
8393

8494
$this->template->assign_vars(array(
8595
'TITLE' => $title,
96+
'MESSAGE' => $message,
8697

87-
'S_POST_ACTION' => $this->helper->route('phpbb_ideas_post_controller', array('mode' => 'submit')),
98+
'S_POST_ACTION' => $this->helper->route('phpbb_ideas_post_controller'),
8899
'S_BBCODE_ALLOWED' => $bbcode_status,
89100
'S_SMILIES_ALLOWED' => $smilies_status,
90101
'S_LINKS_ALLOWED' => $url_status,

factory/ideas.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,19 @@ public function submit($title, $message, $user_id)
670670
return $idea_id;
671671
}
672672

673+
/**
674+
* Preview a new idea.
675+
*
676+
* @param string $message The description of the idea.
677+
* @return string The idea parsed for display in preview.
678+
*/
679+
public function preview($message)
680+
{
681+
$uid = $bitfield = $flags = '';
682+
generate_text_for_storage($message, $uid, $bitfield, $flags, true, true, true);
683+
return generate_text_for_display($message, $uid, $bitfield, $flags);
684+
}
685+
673686
/**
674687
* Deletes an idea and the topic to go with it.
675688
*

styles/prosilver/template/idea_new.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ <h3>{{ lang('POST_IDEA') }}</h3>
6161
<fieldset class="submit-buttons">
6262
{{ S_HIDDEN_FIELDS }}
6363
<input type="submit" accesskey="s" tabindex="6" name="post" value="{{ lang('SUBMIT') }}" class="button1 default-submit-action" />
64+
<input type="submit" name="preview" value="{{ lang('PREVIEW') }}" class="button2" />
6465
</fieldset>
6566
</div>
6667
</div>

0 commit comments

Comments
 (0)