ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilForumExportGUI Class Reference

Forum export to HTML and Print. More...

+ Collaboration diagram for ilForumExportGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 printThread ()
 
 printPost ()
 

Data Fields

ilCtrlInterface $ctrl
 
ilLanguage $lng
 
ilAccessHandler $access
 
ilErrorHandling $error
 
ilObjUser $user
 
ilObjectDataCache $ilObjDataCache
 

Protected Member Functions

 renderPostHtml (ilGlobalTemplateInterface $tpl, ilForumPost $post, int $counter, int $mode)
 

Protected Attributes

bool $is_moderator = false
 
ilForum $frm
 

Private Member Functions

 retrieveRefId ()
 
 prepare ()
 
 ensureThreadBelongsToForum (int $objId, ilForumTopic $thread)
 

Private Attributes

const MODE_EXPORT_WEB = 1
 
const MODE_EXPORT_CLIENT = 2
 
readonly ilForumProperties $objProperties
 
readonly GlobalHttpState $http
 
readonly Refinery $refinery
 
readonly int $ref_id
 

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 \

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

Constructor & Destructor Documentation

◆ __construct()

ilForumExportGUI::__construct ( )

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

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), ilForumProperties\getInstance(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), retrieveRefId(), and ILIAS\Repository\user().

48  {
49  global $DIC;
50 
51  $this->lng = $DIC->language();
52  $this->ctrl = $DIC->ctrl();
53  $this->access = $DIC->access();
54  $this->error = $DIC['ilErr'];
55  $this->user = $DIC->user();
56  $this->ilObjDataCache = $DIC['ilObjDataCache'];
57  $this->http = $DIC->http();
58  $this->refinery = $DIC->refinery();
59 
60  $this->ref_id = $this->retrieveRefId();
61 
62  $forum = new ilObjForum($this->ref_id);
63  $this->frm = $forum->Forum;
64  $this->objProperties = ilForumProperties::getInstance($forum->getId());
65 
66  $this->frm->setForumId($forum->getId());
67  $this->frm->setForumRefId($forum->getRefId());
68 
69  $this->lng->loadLanguageModule('forum');
70 
71  $this->is_moderator = $this->access->checkAccess('moderate_frm', '', $this->ref_id);
72  }
static getInstance(int $a_obj_id=0)
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ ensureThreadBelongsToForum()

ilForumExportGUI::ensureThreadBelongsToForum ( int  $objId,
ilForumTopic  $thread 
)
private

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

References ilForumTopic\getForumId(), ILIAS\Repository\lng(), and ilObjForum\lookupForumIdByObjId().

Referenced by printPost(), and printThread().

94  : void
95  {
97  if ($thread->getForumId() !== $forumId) {
98  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
99  }
100  }
static lookupForumIdByObjId(int $obj_id)
$objId
Definition: xapitoken.php:57
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilForumExportGUI::executeCommand ( )

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

References ILIAS\Repository\ctrl().

102  : void
103  {
104  $cmd = $this->ctrl->getCmd();
105  $this->$cmd();
106  }
+ Here is the call graph for this function:

◆ prepare()

ilForumExportGUI::prepare ( )
private

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

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

Referenced by printPost(), and printThread().

87  : void
88  {
91  ->setZoomFactor(10);
92  }
const PURPOSE_EXPORT
static getInstance()
Singleton: get instance for use in ILIAS requests with a config loaded from the settings.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printPost()

ilForumExportGUI::printPost ( )

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

References $is_moderator, $post, ILIAS\GlobalScreen\Scope\$topics, ILIAS\Repository\access(), ilUtil\deliverData(), ensureThreadBelongsToForum(), ilMathJax\getInstance(), ilForum\getSortedThreadSubjects(), ilUtil\getStyleSheetLocation(), ILIAS\FileDelivery\http(), iljQueryUtil\initjQuery(), ILIAS\Repository\lng(), prepare(), ILIAS\Repository\refinery(), renderPostHtml(), and ilDatePresentation\setUseRelativeDates().

308  : void
309  {
310  if (!$this->access->checkAccess('read,visible', '', $this->ref_id)) {
311  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
312  }
313 
314  $this->prepare();
315 
317 
318  $tpl = new ilGlobalTemplate('tpl.forums_export_print.html', true, true, 'components/ILIAS/Forum');
319  $location_stylesheet = ilUtil::getStyleSheetLocation();
320  $tpl->setVariable('LOCATION_STYLESHEET', $location_stylesheet);
321 
323  ilMathJax::getInstance()->includeMathJax($tpl);
324 
325  $this->frm->setMDB2WhereCondition('top_pk = %s ', ['integer'], [$this->http->wrapper()->query()->retrieve(
326  'top_pk',
327  $this->refinery->kindlyTo()->int()
328  )]);
329  $frmData = $this->frm->getOneTopic();
330 
331  if ($frmData->getTopPk() > 0) {
332  $post = new ilForumPost($this->http->wrapper()->query()->retrieve(
333  'print_post',
334  $this->refinery->kindlyTo()->int()
335  ), $this->is_moderator);
336  $this->ensureThreadBelongsToForum($this->frm->getForumId(), $post->getThread());
337 
338  $tpl->setVariable('TITLE', $post->getThread()->getSubject());
339  $tpl->setVariable(
340  'HEADLINE',
341  $this->lng->txt('forum') . ': ' . $frmData->getTopName() . ' > ' .
342  $this->lng->txt('forums_thread') . ': ' . $post->getThread()->getSubject()
343  );
344 
345  $this->renderPostHtml($tpl, $post, 0, self::MODE_EXPORT_WEB);
346  }
347  $tpl->printToStdout();
348  }
static array static setUseRelativeDates(bool $a_status)
set use relative dates
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
special template class to simplify handling of ITX/PEAR
static http()
Fetches the global http state from ILIAS.
renderPostHtml(ilGlobalTemplateInterface $tpl, ilForumPost $post, int $counter, int $mode)
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static getInstance()
Singleton: get instance for use in ILIAS requests with a config loaded from the settings.
$post
Definition: ltitoken.php:46
+ Here is the call graph for this function:

◆ printThread()

ilForumExportGUI::printThread ( )

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

References $post, ILIAS\Repository\access(), ensureThreadBelongsToForum(), ilMathJax\getInstance(), ilUtil\getStyleSheetLocation(), ILIAS\FileDelivery\http(), iljQueryUtil\initjQuery(), ILIAS\Repository\lng(), prepare(), ILIAS\Repository\refinery(), renderPostHtml(), and ilDatePresentation\setUseRelativeDates().

251  : void
252  {
253  if (
254  !$this->access->checkAccess('read,visible', '', $this->ref_id) ||
255  !$this->http->wrapper()->query()->has('thr_top_fk') ||
256  !$this->http->wrapper()->query()->has('print_thread')
257  ) {
258  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
259  }
260 
261  $this->prepare();
262 
264 
265  $tpl = new ilGlobalTemplate('tpl.forums_export_print.html', true, true, 'components/ILIAS/Forum');
266  $location_stylesheet = ilUtil::getStyleSheetLocation();
267  $tpl->setVariable('LOCATION_STYLESHEET', $location_stylesheet);
268 
270  ilMathJax::getInstance()->includeMathJax($tpl);
271 
272  $this->frm->setMDB2WhereCondition('top_pk = %s ', ['integer'], [$this->http->wrapper()->query()->retrieve(
273  'thr_top_fk',
274  $this->refinery->kindlyTo()->int()
275  )]);
276  $frmData = $this->frm->getOneTopic();
277 
278  if ($frmData->getTopPk() > 0) {
279  $topic = new ilForumTopic($this->http->wrapper()->query()->retrieve(
280  'print_thread',
281  $this->refinery->kindlyTo()->int()
282  ), $this->is_moderator);
283 
284  $this->ensureThreadBelongsToForum($this->frm->getForumId(), $topic);
285 
286  $topic->setOrderField('frm_posts_tree.rgt');
287  $first_post = $topic->getPostRootNode();
288  $post_collection = $topic->getPostTree($first_post);
289  $num_posts = count($post_collection);
290 
291  $tpl->setVariable('TITLE', $topic->getSubject());
292  $tpl->setVariable(
293  'HEADLINE',
294  $this->lng->txt('forum') . ': ' . $frmData->getTopName() . ' > ' .
295  $this->lng->txt('forums_thread') . ': ' . $topic->getSubject() . ' > ' .
296  $this->lng->txt('forums_count_art') . ': ' . $num_posts
297  );
298 
299  $i = 0;
300  foreach ($post_collection as $post) {
301  $this->renderPostHtml($tpl, $post, $i++, self::MODE_EXPORT_WEB);
302  }
303  }
304 
305  $tpl->printToStdout();
306  }
static array static setUseRelativeDates(bool $a_status)
set use relative dates
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
special template class to simplify handling of ITX/PEAR
static http()
Fetches the global http state from ILIAS.
renderPostHtml(ilGlobalTemplateInterface $tpl, ilForumPost $post, int $counter, int $mode)
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static getInstance()
Singleton: get instance for use in ILIAS requests with a config loaded from the settings.
$post
Definition: ltitoken.php:46
+ Here is the call graph for this function:

◆ renderPostHtml()

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

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

References ilForum\_isModerator(), ilRTE\_replaceMediaObjectImageSrc(), ilForumPost\getCensorshipComment(), ilForumPost\getChangeDate(), ilForumPost\getCreateDate(), ilForumPost\getDisplayUserId(), ilForumPost\getImportName(), ilForumProperties\getInstance(), ilForumPost\getMessage(), ilForumPost\getPosAuthorId(), ilForumPost\getSubject(), ilForumPost\getUpdateUserId(), ilForumPost\getUserAlias(), ilForumPost\isActivated(), ilForumPost\isAuthorModerator(), ilForumPost\isCensored(), ilForumPost\isOwner(), ILIAS\Repository\lng(), null, ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ilForumPost\setChangeDate(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), ilForumPost\setMessage(), ILIAS\UICore\GlobalTemplate\setVariable(), ilUtil\switchColor(), and ILIAS\Repository\user().

Referenced by printPost(), and printThread().

108  : void
109  {
110  $tpl->setCurrentBlock('posts_row');
111 
112  if (ilForumProperties::getInstance($this->ilObjDataCache->lookupObjId($this->ref_id))->getMarkModeratorPosts()) {
114  $this->ref_id,
115  $post->getPosAuthorId()
116  )) {
117  $rowCol = 'ilModeratorPosting';
118  } elseif ($post->isAuthorModerator()) {
119  $rowCol = 'ilModeratorPosting';
120  } else {
121  $rowCol = ilUtil::switchColor($counter, 'tblrow1', 'tblrow2');
122  }
123  } else {
124  $rowCol = ilUtil::switchColor($counter, 'tblrow1', 'tblrow2');
125  }
126 
127  $tpl->setVariable('ROWCOL', ' ' . $rowCol);
128 
129  if ($post->isCensored()) {
130  $tpl->setVariable('TXT_CENSORSHIP_ADVICE', $this->lng->txt('post_censored_comment_by_moderator'));
131  $rowCol = 'tblrowmarked';
132  }
133 
134  $tpl->setVariable('ROWCOL', ' ' . $rowCol);
135  if (!$post->isActivated() && $post->isOwner($this->user->getId())) {
136  $tpl->setVariable('POST_NOT_ACTIVATED_YET', $this->lng->txt('frm_post_not_activated_yet'));
137  }
138 
139  $authorinfo = new ilForumAuthorInformation(
140  $post->getPosAuthorId(),
141  $post->getDisplayUserId(),
142  (string) $post->getUserAlias(),
143  (string) $post->getImportName()
144  );
145 
146  if ($authorinfo->hasSuffix()) {
147  if (!$authorinfo->isDeleted()) {
148  $tpl->setVariable('USR_NAME', $authorinfo->getAlias());
149  }
150  $tpl->setVariable('AUTHOR', $authorinfo->getSuffix());
151  } else {
152  if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized()) {
153  $tpl->setVariable('USR_NAME', $authorinfo->getAuthorName(true));
154  }
155  $tpl->setVariable('AUTHOR', $authorinfo->getAuthorShortName());
156  }
157 
158  if (self::MODE_EXPORT_CLIENT === $mode) {
159  if ($authorinfo->getAuthor()->getPref('public_profile') !== 'n') {
160  $tpl->setVariable('TXT_REGISTERED', $this->lng->txt('registered_since'));
161  $tpl->setVariable(
162  'REGISTERED_SINCE',
163  $this->frm->convertDate($authorinfo->getAuthor()->getCreateDate())
164  );
165  }
166 
167  if ($post->getDisplayUserId() !== 0) {
168  if ($this->is_moderator) {
169  $num_posts = $this->frm->countUserArticles($post->getDisplayUserId());
170  } else {
171  $num_posts = $this->frm->countActiveUserArticles($post->getDisplayUserId());
172  }
173  $tpl->setVariable('TXT_NUM_POSTS', $this->lng->txt('forums_posts'));
174  $tpl->setVariable('NUM_POSTS', $num_posts);
175  }
176  }
177 
178  $tpl->setVariable('USR_IMAGE', $authorinfo->getProfilePicture());
179  if ($authorinfo->getAuthor()->getId() && ilForum::_isModerator(
180  $this->ref_id,
181  $post->getPosAuthorId()
182  )) {
183  if ($authorinfo->getAuthor()->getGender() === 'f') {
184  $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_f'));
185  } elseif ($authorinfo->getAuthor()->getGender() === 'm') {
186  $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_m'));
187  } else {
188  $tpl->setVariable('ROLE', $this->lng->txt('frm_moderator_n'));
189  }
190  }
191 
192  if ($post->getUpdateUserId() > 0) {
193  $spanClass = '';
194  if (ilForum::_isModerator($this->ref_id, $post->getUpdateUserId())) {
195  $spanClass = 'moderator_small';
196  }
197 
198  $post->setChangeDate($post->getChangeDate());
199 
200  $authorinfo = new ilForumAuthorInformation(
201  $post->getPosAuthorId(),
202  $post->getDisplayUserId(),
203  (string) $post->getUserAlias(),
204  ''
205  );
206 
207  $tpl->setVariable(
208  'POST_UPDATE_TXT',
209  $this->lng->txt('edited_on') . ': ' . $this->frm->convertDate($post->getChangeDate()) . ' - ' . strtolower($this->lng->txt('by'))
210  );
211  $tpl->setVariable('UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
212  if ($authorinfo->getAuthorName(true) && !$this->objProperties->isAnonymized()) {
213  $tpl->setVariable('UPDATE_USR_NAME', $authorinfo->getAuthorName(true));
214  }
215  }
216 
217  $post->setMessage($this->frm->prepareText($post->getMessage()));
218  $tpl->setVariable('POST_DATE', $this->frm->convertDate($post->getCreateDate()));
219  $tpl->setVariable('SUBJECT', $post->getSubject());
220 
221  if (!$post->isCensored()) {
222  $spanClass = "";
223  if (ilForum::_isModerator($this->ref_id, $post->getDisplayUserId())) {
224  $spanClass = 'moderator';
225  }
226 
227  // possible bugfix for mantis #8223
228  if ($post->getMessage() === strip_tags($post->getMessage())) {
229  // We can be sure, that there are not html tags
230  $post->setMessage(nl2br($post->getMessage()));
231  }
232 
233  if ($spanClass !== '') {
234  $tpl->setVariable(
235  'POST',
236  "<span class=\"" . $spanClass . "\">" . ilRTE::_replaceMediaObjectImageSrc(
237  $post->getMessage(),
238  1
239  ) . "</span>"
240  );
241  } else {
242  $tpl->setVariable('POST', ilRTE::_replaceMediaObjectImageSrc($post->getMessage(), 1));
243  }
244  } else {
245  $tpl->setVariable('POST', "<span class=\"moderator\">" . nl2br((string) $post->getCensorshipComment()) . "</span>");
246  }
247 
248  $tpl->parseCurrentBlock('posts_row');
249  }
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
static switchColor(int $a_num, string $a_css1, string $a_css2)
switches style sheets for each even $a_num (used for changing colors of different result rows) ...
setMessage(string $a_message)
isOwner(int $a_user_id=0)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static getInstance(int $a_obj_id=0)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setChangeDate(?string $a_changedate)
static _isModerator(int $a_ref_id, int $a_usr_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ retrieveRefId()

ilForumExportGUI::retrieveRefId ( )
private

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

References $ref_id, ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by __construct().

74  : int
75  {
76  $ref_id = 0;
77  if ($this->http->wrapper()->query()->has('ref_id')) {
78  $ref_id = $this->http->wrapper()->query()->retrieve(
79  'ref_id',
80  $this->refinery->kindlyTo()->int()
81  );
82  }
83 
84  return $ref_id;
85  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilForumExportGUI::$access

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

◆ $ctrl

ilCtrlInterface ilForumExportGUI::$ctrl

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

◆ $error

ilErrorHandling ilForumExportGUI::$error

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

◆ $frm

ilForum ilForumExportGUI::$frm
protected

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

◆ $http

readonly GlobalHttpState ilForumExportGUI::$http
private

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

◆ $ilObjDataCache

ilObjectDataCache ilForumExportGUI::$ilObjDataCache

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

◆ $is_moderator

bool ilForumExportGUI::$is_moderator = false
protected

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

Referenced by printPost().

◆ $lng

ilLanguage ilForumExportGUI::$lng

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

◆ $objProperties

readonly ilForumProperties ilForumExportGUI::$objProperties
private

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

◆ $ref_id

readonly int ilForumExportGUI::$ref_id
private

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

Referenced by retrieveRefId().

◆ $refinery

readonly Refinery ilForumExportGUI::$refinery
private

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

◆ $user

ilObjUser ilForumExportGUI::$user

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

◆ MODE_EXPORT_CLIENT

const ilForumExportGUI::MODE_EXPORT_CLIENT = 2
private

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

◆ MODE_EXPORT_WEB

const ilForumExportGUI::MODE_EXPORT_WEB = 1
private

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


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