ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilForumThreadFormGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8{
10 protected $delegatingGui;
11
13 protected $properties;
14
16 protected $allowPseudonyms = false;
17
19 protected $allowNotification = false;
20
22 protected $isDraftContext = false;
23
25 protected $draftId = 0;
26
36 public function __construct(
41 bool $isDraftContext,
42 int $draftId
43 ) {
45
46 $this->delegatingGui = $delegatingGui;
47 $this->properties = $properties;
48 $this->allowPseudonyms = $allowPseudonyms;
49 $this->allowNotification = $allowNotification;
50 $this->isDraftContext = $isDraftContext;
51 $this->draftId = $draftId;
52
53 $this->initForm();
54 }
55
59 protected function initForm()
60 {
61 $this->setTitleIcon(\ilUtil::getImagePath('icon_frm.svg'));
62 $this->setTableWidth('100%');
63 $this->setTitle($this->lng->txt('forums_new_thread'));
64 if ($this->isDraftContext) {
65 $this->setTitle($this->lng->txt('edit_thread_draft'));
66 }
67
68 if ($this->allowPseudonyms) {
69 $alias = new \ilTextInputGUI($this->lng->txt('forums_your_name'), 'alias');
70 $alias->setInfo($this->lng->txt('forums_use_alias'));
71 $alias->setMaxLength(255);
72 $alias->setSize(50);
73 } else {
74 $alias = new \ilNonEditableValueGUI($this->lng->txt('forums_your_name'), 'alias');
75 $alias->setValue($this->user->getLogin());
76 }
77 $this->addItem($alias);
78
79 $subject = new \ilTextInputGUI($this->lng->txt('forums_thread'), 'subject');
80 $subject->setMaxLength(255);
81 $subject->setSize(50);
82 $subject->setRequired(true);
83 $this->addItem($subject);
84
85 $message = new ilTextAreaInputGUI($this->lng->txt('forums_the_post'), 'message');
86 $message->setCols(50);
87 $message->setRows(15);
88 $message->setRequired(true);
89 $message->setUseRte(true);
90 $message->addPlugin('latex');
91 $message->addButton('latex');
92 $message->addButton('pastelatex');
93 $message->addPlugin('ilfrmquote');
94
95 $message->removePlugin('advlink');
96 $message->usePurifier(true);
97 $message->setRTERootBlockElement('');
98 $message->setRTESupport($this->user->getId(), 'frm~', 'frm_post', 'tpl.tinymce_frm_post.js', false, '3.5.11');
99 $message->disableButtons(array(
100 'charmap',
101 'undo',
102 'redo',
103 'justifyleft',
104 'justifycenter',
105 'justifyright',
106 'justifyfull',
107 'anchor',
108 'fullscreen',
109 'cut',
110 'copy',
111 'paste',
112 'pastetext',
113 'formatselect'
114 ));
115 $message->setPurifier(\ilHtmlPurifierFactory::_getInstanceByType('frm_post'));
116 $this->addItem($message);
117
118 if ($this->properties->isFileUploadAllowed()) {
119 $files = new \ilFileWizardInputGUI($this->lng->txt('forums_attachments_add'), 'userfile');
120 $files->setFilenames([0 => '']);
121 $this->addItem($files);
122
123 if ($this->isDraftContext) {
124 if ($this->draftId > 0) {
125 $threadDraft = \ilForumPostDraft::newInstanceByDraftId($this->draftId);
126 if ((int) $threadDraft->getDraftId() > 0) {
127 $draftFileData = new \ilFileDataForumDrafts(0, $threadDraft->getDraftId());
128 if (count($draftFileData->getFilesOfPost()) > 0) {
129 $existingFileSelection = new \ilCheckboxGroupInputGUI(
130 $this->lng->txt('forums_delete_file'),
131 'del_file'
132 );
133 foreach ($draftFileData->getFilesOfPost() as $file) {
134 $currentAttachment = new \ilCheckboxInputGUI($file['name'], 'del_file');
135 $currentAttachment->setValue($file['md5']);
136 $existingFileSelection->addOption($currentAttachment);
137 }
138 $this->addItem($existingFileSelection);
139 }
140 }
141 }
142 }
143 }
144
145 if ($this->allowNotification) {
146 $notifyOnAnswer = new ilCheckboxInputGUI($this->lng->txt('forum_direct_notification'), 'notify');
147 $notifyOnAnswer->setInfo($this->lng->txt('forum_notify_me'));
148 $notifyOnAnswer->setValue(1);
149 $this->addItem($notifyOnAnswer);
150 }
151
152 if ($this->user->isAnonymous() && !$this->user->isCaptchaVerified() && \ilCaptchaUtil::isActiveForForum()) {
153 $captcha = new \ilCaptchaInputGUI($this->lng->txt('cont_captcha_code'), 'captcha_code');
154 $captcha->setRequired(true);
155 $this->addItem($captcha);
156 }
157
158 if (\ilForumPostDraft::isSavePostDraftAllowed() && !$this->user->isAnonymous()) {
159 $this->ctrl->setParameter($this->delegatingGui, 'draft_id', $this->draftId);
160 if (in_array($this->ctrl->getCmd(), ['publishThreadDraft', 'editThreadDraft', 'updateThreadDraft'])) {
161 $this->addCommandButton('publishThreadDraft', $this->lng->txt('publish'));
162 $this->addCommandButton('updateThreadDraft', $this->lng->txt('save_message'));
163 $this->setFormAction($this->ctrl->getFormAction($this->delegatingGui, 'updateThreadDraft'));
164 } else {
165 $this->addCommandButton('addThread', $this->lng->txt('create'));
166 $this->addCommandButton('saveThreadAsDraft', $this->lng->txt('save_message'));
167 $this->setFormAction($this->ctrl->getFormAction($this->delegatingGui, 'saveThreadAsDraft'));
168 }
169 $this->addCommandButton('cancelDraft', $this->lng->txt('cancel'));
170 } else {
171 $this->addCommandButton('addThread', $this->lng->txt('create'));
172 $this->addCommandButton('showThreads', $this->lng->txt('cancel'));
173 $this->setFormAction($this->ctrl->getFormAction($this->delegatingGui, 'addThread'));
174 }
175 }
176}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
setFormAction($a_formaction)
Set FormAction.
static newInstanceByDraftId($draft_id)
Class ilForumThreadFormGUI.
__construct(\ilObjForumGUI $delegatingGui, \ilForumProperties $properties, bool $allowPseudonyms, bool $allowNotification, bool $isDraftContext, int $draftId)
ilForumThreadFormGUI constructor.
static _getInstanceByType(string $type)
Factory method for creating purifier instances.
Class ilObjForumGUI.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
setTableWidth($a_width)
Set table width.
setTitleIcon($a_titleicon)
Set TitleIcon.
setTitle($a_title)
Set Title.
This class represents a text area property in a property form.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$message
Definition: xapiexit.php:14