ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilForumExportGUI Class Reference

Forum export to HTML and Print. More...

+ Collaboration diagram for ilForumExportGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 printThread ()
 
 ensureThreadBelongsToForum (int $objId, \ilForumTopic $thread)
 
 printPost ()
 
 exportHTML ()
 

Data Fields

const MODE_EXPORT_WEB = 1
 
const MODE_EXPORT_CLIENT = 2
 
 $ctrl
 
 $lng
 
 $access
 
 $error
 
 $user
 
 $ilObjDataCache
 

Protected Member Functions

 prepare ()
 Prepare the export (init MathJax rendering) More...
 
 renderPostHtml (\ilGlobalTemplate $tpl, ilForumPost $post, $counter, $mode)
 

Protected Attributes

 $is_moderator = false
 
 $frm
 

Detailed Description

Forum export to HTML and Print.

Author
Wolfgang Merkens wmerk.nosp@m.ens@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilForumExportGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilForumExportGUI::__construct ( )

Definition at line 31 of file class.ilForumExportGUI.php.

32 {
33 global $DIC;
34
35 $this->lng = $DIC->language();
36 $this->ctrl = $DIC->ctrl();
37 $this->access = $DIC->access();
38 $this->error = $DIC['ilErr'];
39
40 $this->user = $DIC->user();
41 $this->ilObjDataCache = $DIC['ilObjDataCache'];
42
43 $forum = new ilObjForum((int) $_GET['ref_id']);
44 $this->frm = $forum->Forum;
45 $this->objProperties = ilForumProperties::getInstance($forum->getId());
46
47 $this->frm->setForumId($forum->getId());
48 $this->frm->setForumRefId($forum->getRefId());
49
50 $this->lng->loadLanguageModule('forum');
51
52 $this->is_moderator = $this->access->checkAccess('moderate_frm', '', (int) $_GET['ref_id']);
53 }
user()
Definition: user.php:4
$_GET["client_id"]
error($a_errmsg)
set error message @access public
static getInstance($a_obj_id=0)
Class ilObjForum.
$DIC
Definition: xapitoken.php:46

References $_GET, $DIC, error(), ilForumProperties\getInstance(), and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ ensureThreadBelongsToForum()

ilForumExportGUI::ensureThreadBelongsToForum ( int  $objId,
\ilForumTopic  $thread 
)
Parameters
int$objId
ilForumTopic$thread

Definition at line 128 of file class.ilForumExportGUI.php.

129 {
131 if ((int) $thread->getForumId() !== (int) $forumId) {
132 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
133 }
134 }
static lookupForumIdByObjId($obj_id)
$objId
Definition: xapitoken.php:41

References $objId, error(), ilForumTopic\getForumId(), and ilObjForum\lookupForumIdByObjId().

Referenced by exportHTML(), printPost(), and printThread().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilForumExportGUI::executeCommand ( )

Definition at line 58 of file class.ilForumExportGUI.php.

59 {
60 $next_class = $this->ctrl->getNextClass($this);
61 $cmd = $this->ctrl->getCmd();
62
63 switch ($next_class) {
64 default:
65 return $this->$cmd();
66 break;
67 }
68 }

◆ exportHTML()

ilForumExportGUI::exportHTML ( )

Definition at line 330 of file class.ilForumExportGUI.php.

331 {
332 if (!$this->access->checkAccess('read,visible', '', $_GET['ref_id'])) {
333 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
334 }
335
336 // call prepare to init mathjax rendering
337 $this->prepare();
338
340
341 $tpl = new ilGlobalTemplate('tpl.forums_export_html.html', true, true, 'Modules/Forum');
342 $location_stylesheet = ilUtil::getStyleSheetLocation();
343 $tpl->setVariable('LOCATION_STYLESHEET', $location_stylesheet);
344 $tpl->setVariable('BASE', (substr(ILIAS_HTTP_PATH, -1) == '/' ? ILIAS_HTTP_PATH : ILIAS_HTTP_PATH . '/'));
345
347 ilMathJax::getInstance()->includeMathJax($tpl);
348
349 $threads = [];
350 $isModerator = $this->is_moderator;
351 $postIds = (array) $_POST['thread_ids'];
352 array_walk($postIds, function ($threadId) use (&$threads, $isModerator) {
353 $thread = new \ilForumTopic($threadId, $isModerator);
354 $this->ensureThreadBelongsToForum((int) $this->frm->getForumId(), $thread);
355
356 $threads[] = $thread;
357 });
358
359 $j = 0;
360 foreach ($threads as $topic) {
361 $this->frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($topic->getForumId()));
362 if (is_array($thread_data = $this->frm->getOneTopic())) {
363 if (0 == $j) {
364 $tpl->setVariable('TITLE', $thread_data['top_name']);
365 }
366
367 $first_post = $topic->getFirstPostNode();
368 $topic->setOrderField('frm_posts_tree.rgt');
369 $post_collection = $topic->getPostTree($first_post);
370
371 $z = 0;
372 foreach ($post_collection as $post) {
373 $this->renderPostHtml($tpl, $post, $z++, self::MODE_EXPORT_CLIENT);
374 }
375
376 $tpl->setCurrentBlock('thread_headline');
377 $tpl->setVariable('T_TITLE', $topic->getSubject());
378 if ($this->is_moderator) {
379 $tpl->setVariable('T_NUM_POSTS', $topic->countPosts(true));
380 } else {
381 $tpl->setVariable('T_NUM_POSTS', $topic->countActivePosts(true));
382 }
383 $tpl->setVariable('T_NUM_VISITS', $topic->getVisits());
384 $tpl->setVariable('T_FORUM', $thread_data['top_name']);
385 $authorinfo = new ilForumAuthorInformation(
386 $topic->getThrAuthorId(),
387 $topic->getDisplayUserId(),
388 $topic->getUserAlias(),
389 $topic->getImportName()
390 );
391 $tpl->setVariable('T_AUTHOR', $authorinfo->getAuthorName());
392 $tpl->setVariable('T_TXT_FORUM', $this->lng->txt('forum') . ': ');
393 $tpl->setVariable('T_TXT_TOPIC', $this->lng->txt('forums_thread') . ': ');
394 $tpl->setVariable('T_TXT_AUTHOR', $this->lng->txt('forums_thread_create_from') . ': ');
395 $tpl->setVariable('T_TXT_NUM_POSTS', $this->lng->txt('forums_articles') . ': ');
396 $tpl->setVariable('T_TXT_NUM_VISITS', $this->lng->txt('visits') . ': ');
397 $tpl->parseCurrentBlock();
398
399 ++$j;
400 }
401
402 $tpl->setCurrentBlock('thread_block');
403 $tpl->parseCurrentBlock();
404 }
405
407 $tpl->get('DEFAULT', false, false, false, true, false, false),
408 'forum_html_export_' . $_GET['ref_id'] . '.html'
409 );
410 }
$_POST["username"]
static setUseRelativeDates($a_status)
set use relative dates
renderPostHtml(\ilGlobalTemplate $tpl, ilForumPost $post, $counter, $mode)
ensureThreadBelongsToForum(int $objId, \ilForumTopic $thread)
prepare()
Prepare the export (init MathJax rendering)
special template class to simplify handling of ITX/PEAR
static getInstance()
Singleton: get instance.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl

References $_GET, $_POST, $is_moderator, $tpl, ilUtil\deliverData(), ensureThreadBelongsToForum(), error(), ilMathJax\getInstance(), ilUtil\getStyleSheetLocation(), ILIAS_HTTP_PATH, iljQueryUtil\initjQuery(), prepare(), renderPostHtml(), and ilDatePresentation\setUseRelativeDates().

+ Here is the call graph for this function:

◆ prepare()

ilForumExportGUI::prepare ( )
protected

Prepare the export (init MathJax rendering)

Definition at line 117 of file class.ilForumExportGUI.php.

118 {
121 ->setZoomFactor(10);
122 }
const PURPOSE_EXPORT

References ilMathJax\getInstance(), and ilMathJax\PURPOSE_EXPORT.

Referenced by exportHTML(), printPost(), and printThread().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printPost()

ilForumExportGUI::printPost ( )

Definition at line 293 of file class.ilForumExportGUI.php.

294 {
295 if (!$this->access->checkAccess('read,visible', '', $_GET['ref_id'])) {
296 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
297 }
298
299 // call prepare to init mathjax rendering
300 $this->prepare();
301
303
304 $tpl = new ilGlobalTemplate('tpl.forums_export_print.html', true, true, 'Modules/Forum');
305 $location_stylesheet = ilUtil::getStyleSheetLocation();
306 $tpl->setVariable('LOCATION_STYLESHEET', $location_stylesheet);
307
309 ilMathJax::getInstance()->includeMathJax($tpl);
310
311 $this->frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array((int) $_GET['top_pk']));
312 if (is_array($frmData = $this->frm->getOneTopic())) {
313 $post = new ilForumPost((int) $_GET['print_post'], $this->is_moderator);
314 $this->ensureThreadBelongsToForum((int) $this->frm->getForumId(), $post->getThread());
315
316 $tpl->setVariable('TITLE', $post->getThread()->getSubject());
317 $tpl->setVariable(
318 'HEADLINE',
319 $this->lng->txt('forum') . ': ' . $frmData['top_name'] . ' > ' . $this->lng->txt('forums_thread') . ': ' . $post->getThread()->getSubject()
320 );
321
322 $this->renderPostHtml($tpl, $post, 0, self::MODE_EXPORT_WEB);
323 }
324 $tpl->printToStdout();
325 }

References $_GET, $tpl, ensureThreadBelongsToForum(), error(), ilMathJax\getInstance(), ilUtil\getStyleSheetLocation(), iljQueryUtil\initjQuery(), prepare(), renderPostHtml(), and ilDatePresentation\setUseRelativeDates().

+ Here is the call graph for this function:

◆ printThread()

ilForumExportGUI::printThread ( )

Definition at line 70 of file class.ilForumExportGUI.php.

71 {
72 if (!$this->access->checkAccess('read,visible', '', (int) $_GET['ref_id'])) {
73 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
74 }
75
76 // fau: call prepare to init mathjax rendering
77 $this->prepare();
78
80
81 $tpl = new ilGlobalTemplate('tpl.forums_export_print.html', true, true, 'Modules/Forum');
82 $location_stylesheet = ilUtil::getStyleSheetLocation();
83 $tpl->setVariable('LOCATION_STYLESHEET', $location_stylesheet);
84
86 ilMathJax::getInstance()->includeMathJax($tpl);
87
88 $this->frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array((int) $_GET['thr_top_fk']));
89 if (is_array($frmData = $this->frm->getOneTopic())) {
90 $topic = new ilForumTopic(addslashes($_GET['print_thread']), $this->is_moderator);
91 $this->ensureThreadBelongsToForum((int) $this->frm->getForumId(), $topic);
92
93 $topic->setOrderField('frm_posts_tree.rgt');
94 $first_post = $topic->getFirstPostNode();
95 $post_collection = $topic->getPostTree($first_post);
96 $num_posts = count($post_collection);
97
98 $tpl->setVariable('TITLE', $topic->getSubject());
99 $tpl->setVariable(
100 'HEADLINE',
101 $this->lng->txt('forum') . ': ' . $frmData['top_name'] . ' > ' .
102 $this->lng->txt('forums_thread') . ': ' . $topic->getSubject() . ' > ' .
103 $this->lng->txt('forums_count_art') . ': ' . $num_posts
104 );
105
106 $z = 0;
107 foreach ($post_collection as $post) {
108 $this->renderPostHtml($tpl, $post, $z++, self::MODE_EXPORT_WEB);
109 }
110 }
111 $tpl->printToStdout();
112 }

References $_GET, $tpl, ensureThreadBelongsToForum(), error(), ilMathJax\getInstance(), ilUtil\getStyleSheetLocation(), iljQueryUtil\initjQuery(), prepare(), renderPostHtml(), and ilDatePresentation\setUseRelativeDates().

+ Here is the call graph for this function:

◆ renderPostHtml()

ilForumExportGUI::renderPostHtml ( \ilGlobalTemplate  $tpl,
ilForumPost  $post,
  $counter,
  $mode 
)
protected
Parameters
\ilGlobalTemplate$tpl
ilForumPost$post
int$counter
int$mode

Definition at line 142 of file class.ilForumExportGUI.php.

143 {
144 $tpl->setCurrentBlock('posts_row');
145
146 if (ilForumProperties::getInstance($this->ilObjDataCache->lookupObjId($_GET['ref_id']))->getMarkModeratorPosts() == 1) {
148 $_GET['ref_id'],
149 $post->getPosAuthorId()
150 )) {
151 $rowCol = 'ilModeratorPosting';
152 } else {
153 if ($post->getIsAuthorModerator()) {
154 $rowCol = 'ilModeratorPosting';
155 } else {
156 $rowCol = ilUtil::switchColor($counter, 'tblrow1', 'tblrow2');
157 }
158 }
159 } else {
160 $rowCol = ilUtil::switchColor($counter, 'tblrow1', 'tblrow2');
161 }
162
163 $tpl->setVariable('ROWCOL', ' ' . $rowCol);
164
165 if ($post->isCensored()) {
166 $tpl->setVariable('TXT_CENSORSHIP_ADVICE', $this->lng->txt('post_censored_comment_by_moderator'));
167 $rowCol = 'tblrowmarked';
168 }
169
170 $tpl->setVariable('ROWCOL', ' ' . $rowCol);
171 if (!$post->isActivated() && $post->isOwner($this->user->getId())) {
172 $tpl->setVariable('POST_NOT_ACTIVATED_YET', $this->lng->txt('frm_post_not_activated_yet'));
173 }
174
175 $authorinfo = new ilForumAuthorInformation(
176 $post->getPosAuthorId(),
177 $post->getDisplayUserId(),
178 $post->getUserAlias(),
179 $post->getImportName()
180 );
181
182 if ($authorinfo->hasSuffix()) {
183 if (!$authorinfo->isDeleted()) {
184 $tpl->setVariable('USR_NAME', $authorinfo->getAlias());
185 }
186 $tpl->setVariable('AUTHOR', $authorinfo->getSuffix());
187 } else {
188 if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized()) {
189 $tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true));
190 }
191 $tpl->setVariable('AUTHOR', $authorinfo->getAuthorShortName());
192 }
193
194 if (self::MODE_EXPORT_CLIENT == $mode) {
195 if ($authorinfo->getAuthor()->getPref('public_profile') != 'n') {
196 $tpl->setVariable('TXT_REGISTERED', $this->lng->txt('registered_since'));
197 $tpl->setVariable(
198 'REGISTERED_SINCE',
199 $this->frm->convertDate($authorinfo->getAuthor()->getCreateDate())
200 );
201 }
202
203 if ($post->getDisplayUserId()) {
204 if ($this->is_moderator) {
205 $num_posts = $this->frm->countUserArticles($post->getDisplayUserId());
206 } else {
207 $num_posts = $this->frm->countActiveUserArticles($post->getDisplayUserId());
208 }
209 $tpl->setVariable('TXT_NUM_POSTS', $this->lng->txt('forums_posts'));
210 $tpl->setVariable('NUM_POSTS', $num_posts);
211 }
212 }
213
214 $tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture());
215 if ($authorinfo->getAuthor()->getId() && ilForum::_isModerator(
216 (int) $_GET['ref_id'],
217 $post->getPosAuthorId()
218 )) {
219 if ($authorinfo->getAuthor()->getGender() == 'f') {
220 $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_f'));
221 } else {
222 if ($authorinfo->getAuthor()->getGender() == 'm') {
223 $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_m'));
224 } else {
225 if ($authorinfo->getAuthor()->getGender() == 'n') {
226 $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_n'));
227 }
228 }
229 }
230 }
231
232 // get create- and update-dates
233 if ($post->getUpdateUserId() > 0) {
234 $spanClass = '';
235 if (ilForum::_isModerator((int) $_GET['ref_id'], $post->getUpdateUserId())) {
236 $spanClass = 'moderator_small';
237 }
238
239 $post->setChangeDate($post->getChangeDate());
240
241 $authorinfo = new ilForumAuthorInformation(
242 $post->getPosAuthorId(),
243 $post->getDisplayUserId(),
244 $post->getUserAlias(),
245 ''
246 );
247
248 $tpl->setVariable(
249 'POST_UPDATE_TXT',
250 $this->lng->txt('edited_on') . ': ' . $this->frm->convertDate($post->getChangeDate()) . ' - ' . strtolower($this->lng->txt('by'))
251 );
252 $tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
253 if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized()) {
254 $tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true));
255 }
256 }
257
258 // prepare post
259 $post->setMessage($this->frm->prepareText($post->getMessage()));
260 $tpl->setVariable('POST_DATE', $this->frm->convertDate($post->getCreateDate()));
261 $tpl->setVariable('SUBJECT', $post->getSubject());
262
263 if (!$post->isCensored()) {
264 $spanClass = "";
265 if (ilForum::_isModerator((int) $_GET['ref_id'], $post->getDisplayUserId())) {
266 $spanClass = 'moderator';
267 }
268
269 // possible bugfix for mantis #8223
270 if ($post->getMessage() == strip_tags($post->getMessage())) {
271 // We can be sure, that there are not html tags
272 $post->setMessage(nl2br($post->getMessage()));
273 }
274
275 if ($spanClass != "") {
276 $tpl->setVariable(
277 'POST',
278 "<span class=\"" . $spanClass . "\">" . ilRTE::_replaceMediaObjectImageSrc(
279 $post->getMessage(),
280 1
281 ) . "</span>"
282 );
283 } else {
284 $tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($post->getMessage(), 1));
285 }
286 } else {
287 $tpl->setVariable('POST', "<span class=\"moderator\">" . nl2br($post->getCensorshipComment()) . "</span>");
288 }
289
290 $tpl->parseCurrentBlock('posts_row');
291 }
isOwner($a_user_id=0)
setChangeDate($a_changedate)
setMessage($a_message)
static _isModerator($a_ref_id, $a_usr_id)
checks whether a user is moderator of a given forum object
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
static switchColor($a_num, $a_css1, $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows)

References $_GET, $is_moderator, $tpl, ilForum\_isModerator(), ilRTE\_replaceMediaObjectImageSrc(), ilForumPost\getCensorshipComment(), ilForumPost\getChangeDate(), ilForumPost\getCreateDate(), ilForumPost\getDisplayUserId(), ilForumPost\getImportName(), ilForumProperties\getInstance(), ilForumPost\getIsAuthorModerator(), ilForumPost\getMessage(), ilForumPost\getPosAuthorId(), ilForumPost\getSubject(), ilForumPost\getUpdateUserId(), ilForumPost\getUserAlias(), ilForumPost\isActivated(), ilForumPost\isCensored(), ilForumPost\isOwner(), ilForumPost\setChangeDate(), ilForumPost\setMessage(), and ilUtil\switchColor().

Referenced by exportHTML(), printPost(), and printThread().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilForumExportGUI::$access

Definition at line 18 of file class.ilForumExportGUI.php.

◆ $ctrl

ilForumExportGUI::$ctrl

Definition at line 16 of file class.ilForumExportGUI.php.

◆ $error

ilForumExportGUI::$error

Definition at line 19 of file class.ilForumExportGUI.php.

◆ $frm

ilForumExportGUI::$frm
protected

Definition at line 29 of file class.ilForumExportGUI.php.

◆ $ilObjDataCache

ilForumExportGUI::$ilObjDataCache

Definition at line 21 of file class.ilForumExportGUI.php.

◆ $is_moderator

ilForumExportGUI::$is_moderator = false
protected

Definition at line 25 of file class.ilForumExportGUI.php.

Referenced by exportHTML(), and renderPostHtml().

◆ $lng

ilForumExportGUI::$lng

Definition at line 17 of file class.ilForumExportGUI.php.

◆ $user

ilForumExportGUI::$user

Definition at line 20 of file class.ilForumExportGUI.php.

◆ MODE_EXPORT_CLIENT

const ilForumExportGUI::MODE_EXPORT_CLIENT = 2

Definition at line 15 of file class.ilForumExportGUI.php.

◆ MODE_EXPORT_WEB

const ilForumExportGUI::MODE_EXPORT_WEB = 1

Definition at line 14 of file class.ilForumExportGUI.php.


The documentation for this class was generated from the following file: