Fixed topic type string usage.
This commit is contained in:
parent
460a0ca57d
commit
57b9e82c10
3 changed files with 11 additions and 16 deletions
|
@ -169,11 +169,6 @@ if(!empty($_POST)) {
|
||||||
} else {
|
} else {
|
||||||
$isEditingTopic = empty($topicInfo) || ($mode === 'edit' && $originalPostInfo->getId() == $postInfo->getId());
|
$isEditingTopic = empty($topicInfo) || ($mode === 'edit' && $originalPostInfo->getId() == $postInfo->getId());
|
||||||
|
|
||||||
if(is_string($topicType))
|
|
||||||
$topicType = ForumTopicInfo::TYPE_ALIASES[$topicType] ?? ForumTopicInfo::TYPE_DISCUSSION;
|
|
||||||
else
|
|
||||||
$topicType = (int)$topicType;
|
|
||||||
|
|
||||||
if($mode === 'create') {
|
if($mode === 'create') {
|
||||||
$postTimeout = $cfg->getInteger('forum.posting.timeout', 5);
|
$postTimeout = $cfg->getInteger('forum.posting.timeout', 5);
|
||||||
if($postTimeout > 0) {
|
if($postTimeout > 0) {
|
||||||
|
@ -192,7 +187,7 @@ if(!empty($_POST)) {
|
||||||
if($isEditingTopic) {
|
if($isEditingTopic) {
|
||||||
$originalTopicTitle = $topicInfo?->getTitle() ?? null;
|
$originalTopicTitle = $topicInfo?->getTitle() ?? null;
|
||||||
$topicTitleChanged = $topicTitle !== $originalTopicTitle;
|
$topicTitleChanged = $topicTitle !== $originalTopicTitle;
|
||||||
$originalTopicType = (int)($topicInfo?->getType() ?? 0);
|
$originalTopicType = $topicInfo?->getTypeString() ?? 'discussion';
|
||||||
$topicTypeChanged = $topicType !== null && $topicType !== $originalTopicType;
|
$topicTypeChanged = $topicType !== null && $topicType !== $originalTopicType;
|
||||||
|
|
||||||
$topicTitleLengths = $cfg->getValues([
|
$topicTitleLengths = $cfg->getValues([
|
||||||
|
@ -329,14 +324,6 @@ try {
|
||||||
$selectedParser = Parser::BBCODE;
|
$selectedParser = Parser::BBCODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this sucks, fix it!
|
|
||||||
$topicTypeName = match($topicType ?? $topicInfo?->getType() ?? null) {
|
|
||||||
default => 'discussion',
|
|
||||||
ForumTopicInfo::TYPE_STICKY => 'sticky',
|
|
||||||
ForumTopicInfo::TYPE_ANNOUNCE => 'announce',
|
|
||||||
ForumTopicInfo::TYPE_GLOBAL => 'global',
|
|
||||||
};
|
|
||||||
|
|
||||||
Template::render('forum.posting', [
|
Template::render('forum.posting', [
|
||||||
'posting_breadcrumbs' => $forum->getCategoryAncestry($categoryInfo),
|
'posting_breadcrumbs' => $forum->getCategoryAncestry($categoryInfo),
|
||||||
'global_accent_colour' => $forum->getCategoryColour($categoryInfo),
|
'global_accent_colour' => $forum->getCategoryColour($categoryInfo),
|
||||||
|
@ -348,7 +335,6 @@ Template::render('forum.posting', [
|
||||||
'posting_notices' => $notices,
|
'posting_notices' => $notices,
|
||||||
'posting_mode' => $mode,
|
'posting_mode' => $mode,
|
||||||
'posting_types' => $topicTypes,
|
'posting_types' => $topicTypes,
|
||||||
'posting_type_selected' => $topicTypeName,
|
|
||||||
'posting_defaults' => [
|
'posting_defaults' => [
|
||||||
'title' => $topicTitle ?? null,
|
'title' => $topicTitle ?? null,
|
||||||
'type' => $topicType ?? null,
|
'type' => $topicType ?? null,
|
||||||
|
|
|
@ -65,6 +65,15 @@ class ForumTopicInfo {
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTypeString(): string {
|
||||||
|
return match($this->type) {
|
||||||
|
self::TYPE_GLOBAL => 'global',
|
||||||
|
self::TYPE_ANNOUNCE => 'announce',
|
||||||
|
self::TYPE_STICKY => 'sticky',
|
||||||
|
default => 'discussion',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public function isDiscussion(): bool {
|
public function isDiscussion(): bool {
|
||||||
return $this->type === self::TYPE_DISCUSSION;
|
return $this->type === self::TYPE_DISCUSSION;
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@
|
||||||
{% if is_opening and posting_types|length > 1 %}
|
{% if is_opening and posting_types|length > 1 %}
|
||||||
<select class="input__select forum__post__dropdown" name="post[type]">
|
<select class="input__select forum__post__dropdown" name="post[type]">
|
||||||
{% for type_name, type_title in posting_types %}
|
{% for type_name, type_title in posting_types %}
|
||||||
<option value="{{ type_name }}"{% if type_name == posting_type_selected %} selected{% endif %}>{{ type_title }}</option>
|
<option value="{{ type_name }}"{% if type_name == posting_topic.typeString|default('discussion') %} selected{% endif %}>{{ type_title }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Reference in a new issue