ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilForumExportGUI Class Reference

Forum export to HTML and Print. More...

+ Collaboration diagram for ilForumExportGUI:

Public Member Functions

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

Data Fields

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

Protected Member Functions

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

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 17 of file class.ilForumExportGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilForumExportGUI::__construct ( )

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

40 {
41 global $DIC;
42
43 $this->lng = $DIC->language();
44 $this->ctrl = $DIC->ctrl();
45 $this->access = $DIC->access();
46 $this->error = $DIC['ilErr'];
47
48 $this->user = $DIC->user();
49 $this->ilObjDataCache = $DIC['ilObjDataCache'];
50
51 $forum = new ilObjForum((int) $_GET['ref_id']);
52 $this->frm = $forum->Forum;
53 $this->objProperties = ilForumProperties::getInstance($forum->getId());
54
55 $this->frm->setForumId($forum->getId());
56 $this->frm->setForumRefId($forum->getRefId());
57
58 $this->lng->loadLanguageModule('forum');
59
60 $this->is_moderator = $this->access->checkAccess('moderate_frm', '', (int) $_GET['ref_id']);
61 }
user()
Definition: user.php:4
$_GET["client_id"]
error($a_errmsg)
set error message @access public
static getInstance($a_obj_id=0)
Class ilObjForum.
global $DIC
Definition: saml.php:7

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

+ Here is the call graph for this function:

Member Function Documentation

◆ ensureThreadBelongsToForum()

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

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

68 {
69 $forumId = \ilObjForum::lookupForumIdByObjId($objId);
70 if ((int) $thread->getForumId() !== (int) $forumId) {
71 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
72 }
73 }
static lookupForumIdByObjId($obj_id)

References 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 78 of file class.ilForumExportGUI.php.

79 {
80 $next_class = $this->ctrl->getNextClass($this);
81 $cmd = $this->ctrl->getCmd();
82
83 switch ($next_class) {
84 default:
85 return $this->$cmd();
86 break;
87 }
88 }

◆ exportHTML()

ilForumExportGUI::exportHTML ( )

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

169 {
170 if (!$this->access->checkAccess('read,visible', '', $_GET['ref_id'])) {
171 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
172 }
173
174 // call prepare to init mathjax rendering
175 $this->prepare();
176
178
179 $tpl = new ilTemplate('tpl.forums_export_html.html', true, true, 'Modules/Forum');
180 $location_stylesheet = ilUtil::getStyleSheetLocation();
181 $tpl->setVariable('LOCATION_STYLESHEET', $location_stylesheet);
182 $tpl->setVariable('BASE', (substr(ILIAS_HTTP_PATH, -1) == '/' ? ILIAS_HTTP_PATH : ILIAS_HTTP_PATH . '/'));
183
184 $threads = [];
185 $isModerator = $this->is_moderator;
186 $postIds = (array) $_POST['thread_ids'];
187 array_walk($postIds, function ($threadId) use (&$threads, $isModerator) {
188 $thread = new \ilForumTopic($threadId, $isModerator);
189 $this->ensureThreadBelongsToForum((int) $this->frm->getForumId(), $thread);
190
191 $threads[] = $thread;
192 });
193
194 $j = 0;
195 foreach ($threads as $topic) {
196 $this->frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($topic->getForumId()));
197 if (is_array($thread_data = $this->frm->getOneTopic())) {
198 if (0 == $j) {
199 $tpl->setVariable('TITLE', $thread_data['top_name']);
200 }
201
202 $first_post = $topic->getFirstPostNode();
203 $topic->setOrderField('frm_posts_tree.rgt');
204 $post_collection = $topic->getPostTree($first_post);
205
206 $z = 0;
207 foreach ($post_collection as $post) {
208 $this->renderPostHtml($tpl, $post, $z++, self::MODE_EXPORT_CLIENT);
209 }
210
211 $tpl->setCurrentBlock('thread_headline');
212 $tpl->setVariable('T_TITLE', $topic->getSubject());
213 if ($this->is_moderator) {
214 $tpl->setVariable('T_NUM_POSTS', $topic->countPosts());
215 } else {
216 $tpl->setVariable('T_NUM_POSTS', $topic->countActivePosts());
217 }
218 $tpl->setVariable('T_NUM_VISITS', $topic->getVisits());
219 $tpl->setVariable('T_FORUM', $thread_data['top_name']);
220 $authorinfo = new ilForumAuthorInformation(
221 $topic->getThrAuthorId(),
222 $topic->getDisplayUserId(),
223 $topic->getUserAlias(),
224 $topic->getImportName()
225 );
226 $tpl->setVariable('T_AUTHOR', $authorinfo->getAuthorName());
227 $tpl->setVariable('T_TXT_FORUM', $this->lng->txt('forum') . ': ');
228 $tpl->setVariable('T_TXT_TOPIC', $this->lng->txt('forums_thread') . ': ');
229 $tpl->setVariable('T_TXT_AUTHOR', $this->lng->txt('forums_thread_create_from') . ': ');
230 $tpl->setVariable('T_TXT_NUM_POSTS', $this->lng->txt('forums_articles') . ': ');
231 $tpl->setVariable('T_TXT_NUM_VISITS', $this->lng->txt('visits') . ': ');
232 $tpl->parseCurrentBlock();
233
234 ++$j;
235 }
236
237 $tpl->setCurrentBlock('thread_block');
238 $tpl->parseCurrentBlock();
239 }
240
241 ilUtil::deliverData($tpl->get('DEFAULT', false, false, false, true, false, false), 'forum_html_export_' . $_GET['ref_id'] . '.html');
242 }
$tpl
Definition: ilias.php:10
$_POST["username"]
static setUseRelativeDates($a_status)
set use relative dates
ensureThreadBelongsToForum($objId, \ilForumTopic $thread)
renderPostHtml(ilTemplate $tpl, ilForumPost $post, $counter, $mode)
prepare()
Prepare the export (init MathJax rendering)
special template class to simplify handling of ITX/PEAR
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.
$post
Definition: post.php:34

References $_GET, $_POST, $is_moderator, $post, $tpl, ilUtil\deliverData(), ensureThreadBelongsToForum(), error(), ilUtil\getStyleSheetLocation(), 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 379 of file class.ilForumExportGUI.php.

380 {
381 include_once './Services/MathJax/classes/class.ilMathJax.php';
384 ->setZoomFactor(10);
385 }
static getInstance()
Singleton: get instance.
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 134 of file class.ilForumExportGUI.php.

135 {
136 if (!$this->access->checkAccess('read,visible', '', $_GET['ref_id'])) {
137 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
138 }
139
140 // call prepare to init mathjax rendering
141 $this->prepare();
142
144
145 $tpl = new ilTemplate('tpl.forums_export_print.html', true, true, 'Modules/Forum');
146 $location_stylesheet = ilUtil::getStyleSheetLocation();
147 $tpl->setVariable('LOCATION_STYLESHEET', $location_stylesheet);
148
149 require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
151
152 $this->frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array((int) $_GET['top_pk']));
153 if (is_array($frmData = $this->frm->getOneTopic())) {
154 $post = new ilForumPost((int) $_GET['print_post'], $this->is_moderator);
155 $this->ensureThreadBelongsToForum((int) $this->frm->getForumId(), $post->getThread());
156
157 $tpl->setVariable('TITLE', $post->getThread()->getSubject());
158 $tpl->setVariable('HEADLINE', $this->lng->txt('forum') . ': ' . $frmData['top_name'] . ' > ' . $this->lng->txt('forums_thread') . ': ' . $post->getThread()->getSubject());
159
160 $this->renderPostHtml($tpl, $post, 0, self::MODE_EXPORT_WEB);
161 }
162 $tpl->show();
163 }
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template

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

+ Here is the call graph for this function:

◆ printThread()

ilForumExportGUI::printThread ( )

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

91 {
92 if (!$this->access->checkAccess('read,visible', '', (int) $_GET['ref_id'])) {
93 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
94 }
95
96 // fau: call prepare to init mathjax rendering
97 $this->prepare();
98
100
101 $tpl = new ilTemplate('tpl.forums_export_print.html', true, true, 'Modules/Forum');
102 $location_stylesheet = ilUtil::getStyleSheetLocation();
103 $tpl->setVariable('LOCATION_STYLESHEET', $location_stylesheet);
104
105 require_once 'Services/jQuery/classes/class.iljQueryUtil.php';
107
108 $this->frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array((int) $_GET['thr_top_fk']));
109 if (is_array($frmData = $this->frm->getOneTopic())) {
110 $topic = new ilForumTopic(addslashes($_GET['print_thread']), $this->is_moderator);
111 $this->ensureThreadBelongsToForum((int) $this->frm->getForumId(), $topic);
112
113 $topic->setOrderField('frm_posts_tree.rgt');
114 $first_post = $topic->getFirstPostNode();
115 $post_collection = $topic->getPostTree($first_post);
116 $num_posts = count($post_collection);
117
118 $tpl->setVariable('TITLE', $topic->getSubject());
119 $tpl->setVariable(
120 'HEADLINE',
121 $this->lng->txt('forum') . ': ' . $frmData['top_name'] . ' > ' .
122 $this->lng->txt('forums_thread') . ': ' . $topic->getSubject() . ' > ' .
123 $this->lng->txt('forums_count_art') . ': ' . $num_posts
124 );
125
126 $z = 0;
127 foreach ($post_collection as $post) {
128 $this->renderPostHtml($tpl, $post, $z++, self::MODE_EXPORT_WEB);
129 }
130 }
131 $tpl->show();
132 }

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

+ Here is the call graph for this function:

◆ renderPostHtml()

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

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

251 {
252 $tpl->setCurrentBlock('posts_row');
253
254 if (ilForumProperties::getInstance($this->ilObjDataCache->lookupObjId($_GET['ref_id']))->getMarkModeratorPosts() == 1) {
255 if ($post->getIsAuthorModerator() === null && $is_moderator = ilForum::_isModerator($_GET['ref_id'], $post->getPosAuthorId())) {
256 $rowCol = 'ilModeratorPosting';
257 } elseif ($post->getIsAuthorModerator()) {
258 $rowCol = 'ilModeratorPosting';
259 } else {
260 $rowCol = ilUtil::switchColor($counter, 'tblrow1', 'tblrow2');
261 }
262 } else {
263 $rowCol = ilUtil::switchColor($counter, 'tblrow1', 'tblrow2');
264 }
265
266 $tpl->setVariable('ROWCOL', ' ' . $rowCol);
267
268 if ($post->isCensored()) {
269 $tpl->setVariable('TXT_CENSORSHIP_ADVICE', $this->lng->txt('post_censored_comment_by_moderator'));
270 $rowCol = 'tblrowmarked';
271 }
272
273 $tpl->setVariable('ROWCOL', ' ' . $rowCol);
274 if (!$post->isActivated() && $post->isOwner($this->user->getId())) {
275 $tpl->setVariable('POST_NOT_ACTIVATED_YET', $this->lng->txt('frm_post_not_activated_yet'));
276 }
277
278 $authorinfo = new ilForumAuthorInformation(
279 $post->getPosAuthorId(),
280 $post->getDisplayUserId(),
281 $post->getUserAlias(),
282 $post->getImportName()
283 );
284
285 if ($authorinfo->hasSuffix()) {
286 $tpl->setVariable('AUTHOR', $authorinfo->getSuffix());
287 $tpl->setVariable('USR_NAME', $post->getUserAlias());
288 } else {
289 $tpl->setVariable('AUTHOR', $authorinfo->getAuthorShortName());
290 if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized()) {
291 $tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true));
292 }
293 }
294
295 if (self::MODE_EXPORT_CLIENT == $mode) {
296 if ($authorinfo->getAuthor()->getPref('public_profile') != 'n') {
297 $tpl->setVariable('TXT_REGISTERED', $this->lng->txt('registered_since'));
298 $tpl->setVariable('REGISTERED_SINCE', $this->frm->convertDate($authorinfo->getAuthor()->getCreateDate()));
299 }
300
301 if ($post->getDisplayUserId()) {
302 if ($this->is_moderator) {
303 $num_posts = $this->frm->countUserArticles($post->getDisplayUserId());
304 } else {
305 $num_posts = $this->frm->countActiveUserArticles($post->getDisplayUserId());
306 }
307 $tpl->setVariable('TXT_NUM_POSTS', $this->lng->txt('forums_posts'));
308 $tpl->setVariable('NUM_POSTS', $num_posts);
309 }
310 }
311
312 $tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture());
313 if ($authorinfo->getAuthor()->getId() && ilForum::_isModerator((int) $_GET['ref_id'], $post->getPosAuthorId())) {
314 if ($authorinfo->getAuthor()->getGender() == 'f') {
315 $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_f'));
316 } elseif ($authorinfo->getAuthor()->getGender() == 'm') {
317 $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_m'));
318 } elseif ($authorinfo->getAuthor()->getGender() == 'n') {
319 $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_n'));
320 }
321 }
322
323 // get create- and update-dates
324 if ($post->getUpdateUserId() > 0) {
325 $spanClass = '';
326 if (ilForum::_isModerator((int) $_GET['ref_id'], $post->getUpdateUserId())) {
327 $spanClass = 'moderator_small';
328 }
329
330 $post->setChangeDate($post->getChangeDate());
331
332 require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
333 $authorinfo = new ilForumAuthorInformation(
334 $post->getPosAuthorId(),
335 $post->getDisplayUserId(),
336 $post->getUserAlias(),
337 ''
338 );
339
340 $tpl->setVariable('POST_UPDATE_TXT', $this->lng->txt('edited_on') . ': ' . $this->frm->convertDate($post->getChangeDate()) . ' - ' . strtolower($this->lng->txt('by')));
341 $tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
342 if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized()) {
343 $tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true));
344 }
345 }
346
347 // prepare post
348 $post->setMessage($this->frm->prepareText($post->getMessage()));
349 $tpl->setVariable('POST_DATE', $this->frm->convertDate($post->getCreateDate()));
350 $tpl->setVariable('SUBJECT', $post->getSubject());
351
352 if (!$post->isCensored()) {
353 $spanClass = "";
354 if (ilForum::_isModerator((int) $_GET['ref_id'], $post->getDisplayUserId())) {
355 $spanClass = 'moderator';
356 }
357
358 // possible bugfix for mantis #8223
359 if ($post->getMessage() == strip_tags($post->getMessage())) {
360 // We can be sure, that there are not html tags
361 $post->setMessage(nl2br($post->getMessage()));
362 }
363
364 if ($spanClass != "") {
365 $tpl->setVariable('POST', "<span class=\"" . $spanClass . "\">" . ilRTE::_replaceMediaObjectImageSrc($post->getMessage(), 1) . "</span>");
366 } else {
367 $tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($post->getMessage(), 1));
368 }
369 } else {
370 $tpl->setVariable('POST', "<span class=\"moderator\">" . nl2br($post->getCensorshipComment()) . "</span>");
371 }
372
373 $tpl->parseCurrentBlock('posts_row');
374 }
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)
$counter

References $_GET, $counter, $is_moderator, $post, $tpl, ilForum\_isModerator(), ilRTE\_replaceMediaObjectImageSrc(), ilForumProperties\getInstance(), 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 34 of file class.ilForumExportGUI.php.

◆ $ctrl

ilForumExportGUI::$ctrl

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

◆ $error

ilForumExportGUI::$error

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

◆ $frm

ilForumExportGUI::$frm
protected

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

◆ $ilObjDataCache

ilForumExportGUI::$ilObjDataCache

Definition at line 37 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 33 of file class.ilForumExportGUI.php.

◆ $user

ilForumExportGUI::$user

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

◆ MODE_EXPORT_CLIENT

const ilForumExportGUI::MODE_EXPORT_CLIENT = 2

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

◆ MODE_EXPORT_WEB

const ilForumExportGUI::MODE_EXPORT_WEB = 1

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


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