Newer
Older
<?php
if(!defined('OSTSCPINC') || !$thisstaff || !$thisstaff->canManageFAQ()) die('Access Denied');
$info=array();
$qstr='';
if($faq){
$title=__('Update FAQ').': '.$faq->getQuestion();
$submit_text=__('Save Changes');
$info=$faq->getHashtable();
$info['id']=$faq->getId();
$info['topics']=$faq->getHelpTopicsIds();
$info['answer']=Format::viewableImages($faq->getAnswer());
$info['notes']=Format::viewableImages($faq->getNotes());
$langs = $cfg->getSecondaryLanguages();
$translations = $faq->getAllTranslations();
foreach ($cfg->getSecondaryLanguages() as $tag) {
foreach ($translations as $t) {
if (strcasecmp($t->lang, $tag) === 0) {
$trans = $t->getComplex();
$info['trans'][$tag] = array(
'question' => $trans['q'],
'answer' => Format::viewableImages($trans['a']),
);
break;
}
}
}
if($category) {
$qstr='cid='.$category->getId();
$info['category_id']=$category->getId();
}
}
//TODO: Add attachment support.
$info=Format::htmlchars(($errors && $_POST)?$_POST:$info);
?>
<form action="faq.php?<?php echo $qstr; ?>" method="post" id="save" enctype="multipart/form-data">
<?php csrf_token(); ?>
<input type="hidden" name="do" value="<?php echo $action; ?>">
<input type="hidden" name="a" value="<?php echo Format::htmlchars($_REQUEST['a']); ?>">
<input type="hidden" name="id" value="<?php echo $info['id']; ?>">
<h2><?php echo __('FAQ');?></h2>
<?php if ($info['question']) { ?>
<h4><?php echo $info['question']; ?></h4>
<?php } ?>
<div>
<div>
<b><?php echo __('Category Listing');?></b>:
<span class="error">*</span>
<span class="faded"><?php echo __('FAQ category the question belongs to.');?></span>
</div>
<select name="category_id" style="width:350px;">
<option value="0"><?php echo __('Select FAQ Category');?> </option>
$sql='SELECT category_id, name, ispublic FROM '.FAQ_CATEGORY_TABLE;
if(($res=db_query($sql)) && db_num_rows($res)) {
while($row=db_fetch_array($res)) {
echo sprintf('<option value="%d" %s>%s (%s)</option>',
$row['category_id'],
(($info['category_id']==$row['category_id'])?'selected="selected"':''),
$row['name'],
($info['ispublic']?__('Public'):__('Internal')));
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
}
?>
</select>
<div class="error"><?php echo $errors['category_id']; ?></div>
<?php
if ($topics = Topic::getAllHelpTopics()) { ?>
<div style="padding-top:9px">
<strong><?php echo __('Help Topics');?></strong>:
<?php echo __('Check all help topics related to this FAQ.');?>
</div>
<select multiple="multiple" name="topics[]" class="multiselect"
id="help-topic-selection" style="width:350px;">
<?php while (list($topicId,$topic) = each($topics)) { ?>
<option value="<?php echo $topicId; ?>" <?php
if (in_array($topicID, $info['topics'])) echo 'selected="selected"';
?>><?php echo $topic; ?></option>
<?php } ?>
</select>
<script type="text/javascript">
$(function() { $("#help-topic-selection").multiselect({
noneSelectedText: '<?php echo __('Help Topics'); ?>'});
});
</script>
<?php } ?>
<div style="padding-top:9px;">
<b><?php echo __('Listing Type');?></b>:
<span class="error">*</span>
<i class="help-tip icon-question-sign" href="#listing_type"></i>
</div>
<select name="ispublished">
<option value="1" <?php echo $info['ispublished'] ? 'selected="selected"' : ''; ?>>
<?php echo __('Public (publish)'); ?>
</option>
<option value="0" <?php echo !$info['ispublished'] ? 'selected="selected"' : ''; ?>>
<?php echo __('Internal (private)'); ?>
</option>
</select>
<div class="error"><?php echo $errors['ispublished']; ?></div>
</div>
<ul class="tabs" style="margin-top:9px;">
<li class="active"><a class="active" href="#article"><?php echo __('Article Content'); ?></a></li>
<li><a href="#attachments"><?php echo __('Attachments') . sprintf(' (%d)',
count($faq->attachments->getSeparates(''))); ?></a></li>
<li><a href="#notes"><?php echo __('Internal Notes'); ?></a></li>
</ul>
<div class="tab_content" id="article">
<?php if ($faq && ($langs = $cfg->getSecondaryLanguages())) { ?>
<div class="banner" style="margin-top:12px;">
<span class="pull-left" style="padding-top:2px">
<i class="icon-globe icon-large"></i>
<?php echo __('This content is translatable'); ?>
</span>
<span class="pull-right">
<?php echo __('View'); ?>:
<select onchange="javascript:
$('option', this).each(function(){$($(this).val()).hide()});
$($('option:selected', this).val()).show(); ">
<option value="#reference-text"><?php echo
Internationalization::getLanguageDescription($cfg->getPrimaryLanguage());
?> — <?php echo __('Primary'); ?></option>
<?php foreach ($langs as $tag) { ?>
<option value="#translation-<?php echo $tag; ?>"><?php echo
Internationalization::getLanguageDescription($tag);
?></option>
<?php } ?>
</select>
</span>
</div>
<?php } ?>
<div id="reference-text">
<div style="padding-top:9px;">
<b><?php echo __('Question');?>
<span class="error">*</span>
</b>
<div class="error"><?php echo $errors['question']; ?></div>
</div>
<input type="text" size="70" name="question"
style="font-size:105%;display:block;width:98%"
value="<?php echo $info['question']; ?>">
<div style="margin-bottom:0.5em;margin-top:9px">
<b><?php echo __('Answer');?></b>
<span class="error">*</span>
<div class="error"><?php echo $errors['answer']; ?></div>
</div>
<textarea name="answer" cols="21" rows="12"
style="width:98%;" class="richtext draft" <?php
list($draft, $attrs) = Draft::getDraftAndDataAttrs('faq',
is_object($faq) ? $faq->getId() : false, $info['answer']);
echo $attrs; ?>><?php echo $draft ?: $info['answer'];
?></textarea>
<?php if (count($langs)) {
$lang = $cfg->getPrimaryLanguage(); ?>
<div style="padding-top:9px">
<strong><?php echo sprintf(__(
/* %s is the name of a language */ 'Attachments for %s'),
Internationalization::getLanguageDescription($lang));
?></strong>
<div style="margin:0 0 3px"><em class="faded"><?php echo __(
'These attachments are only available when article is rendered in this language.'
); ?></em></div>
</div>
<?php
print $faq_form->getField('attachments.'.$lang)->render(); ?>
<?php } ?>
</div> <!-- end of reference-text -->
<?php if ($langs && $faq) {
foreach ($langs as $tag) { ?>
<div id="translation-<?php echo $tag; ?>" style="display:none" lang="<?php echo $tag; ?>">
<div style="padding-top:9px;">
<b><?php echo __('Question');?>
<span class="error">*</span>
</b>
<div class="error"><?php echo $errors['question']; ?></div>
</div>
<input type="text" size="70" name="trans[<?php echo $tag; ?>][question]"
style="font-size:105%;display:block;width:98%"
value="<?php echo $info['trans'][$tag]['question']; ?>">
<div style="margin-bottom:0.5em;margin-top:9px">
<b><?php echo __('Answer');?></b>
<span class="error">*</span>
<div class="error"><?php echo $errors['answer']; ?></div>
</div>
<textarea name="trans[<?php echo $tag; ?>][answer]" cols="21" rows="12"
style="width:98%;" class="richtext draft" <?php
list($draft, $attrs) = Draft::getDraftAndDataAttrs('faq', $faq->getId().'.'.$tag,
$info['trans'][$tag]['answer']);
echo $attrs; ?>><?php echo $draft ?: $info['trans'][$tag]['answer'];
?></textarea>
<div style="padding-top:9px">
<strong><?php echo sprintf(__('Attachments for %s'),
Internationalization::getLanguageDescription($tag));
?></strong>
<div style="margin:0 0 3px"><em class="faded"><?php echo __(
'These attachments are only available when article is rendered in this language.'
); ?></em></div>
</div>
<?php
print $faq_form->getField('attachments.'.$tag)->render(); ?>
</div> <!-- End of this language -->
<?php } ?>
<?php } ?>
</div>
<div class="tab_content" id="attachments" style="display:none">
<div>
<p><em><?php echo __(
'These attachments are always available, regardless of the language in which the article is rendered'
); ?></em></p>
<div class="error"><?php echo $errors['files']; ?></div>
</div>
<?php
print $faq_form->getField('attachments')->render(); ?>
</div>
<div class="tab_content" style="display:none;" id="notes">
<textarea class="richtext no-bar" name="notes" cols="21"
rows="8" style="width: 80%;"><?php echo $info['notes']; ?></textarea>
</div>
<p style="text-align:center;">
<input type="submit" name="submit" value="<?php echo $submit_text; ?>">
<input type="reset" name="reset" value="<?php echo __('Reset'); ?>" onclick="javascript:
$(this.form).find('textarea.richtext')
.redactor('deleteDraft');
location.reload();" />
<input type="button" name="cancel" value="<?php echo __('Cancel'); ?>" onclick='window.location.href="faq.php?<?php echo $qstr; ?>"'>
<link rel="stylesheet" type="text/css" href="<?php echo ROOT_PATH; ?>css/jquery.multiselect.css" />