19 declare(strict_types=1);
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();
63 $this->frm = $forum->Forum;
66 $this->frm->setForumId($forum->getId());
67 $this->frm->setForumRefId($forum->getRefId());
69 $this->
lng->loadLanguageModule(
'forum');
71 $this->is_moderator = $this->
access->checkAccess(
'moderate_frm',
'', $this->ref_id);
77 if ($this->
http->wrapper()->query()->has(
'ref_id')) {
78 $ref_id = $this->
http->wrapper()->query()->retrieve(
91 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
105 $tpl->
addJavaScript(
'node_modules/mathjax/es5/tex-chtml-full.js');
110 $cmd = $this->
ctrl->getCmd();
123 $rowCol =
'ilModeratorPosting';
125 $rowCol =
'ilModeratorPosting';
136 $tpl->
setVariable(
'TXT_CENSORSHIP_ADVICE', $this->
lng->txt(
'post_censored_comment_by_moderator'));
137 $rowCol =
'tblrowmarked';
142 $tpl->
setVariable(
'POST_NOT_ACTIVATED_YET', $this->
lng->txt(
'frm_post_not_activated_yet'));
152 if ($authorinfo->hasSuffix()) {
153 if (!$authorinfo->isDeleted()) {
154 $tpl->
setVariable(
'USR_NAME', $authorinfo->getAlias());
156 $tpl->
setVariable(
'AUTHOR', $authorinfo->getSuffix());
158 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized()) {
159 $tpl->
setVariable(
'USR_NAME', $authorinfo->getAuthorName(
true));
161 $tpl->
setVariable(
'AUTHOR', $authorinfo->getAuthorShortName());
164 if (self::MODE_EXPORT_CLIENT === $mode) {
165 if ($authorinfo->getAuthor()->getPref(
'public_profile') !==
'n') {
166 $tpl->
setVariable(
'TXT_REGISTERED', $this->
lng->txt(
'registered_since'));
169 $this->frm->convertDate($authorinfo->getAuthor()->getCreateDate())
174 if ($this->is_moderator) {
177 $num_posts = $this->frm->countActiveUserArticles($post->
getDisplayUserId());
179 $tpl->
setVariable(
'TXT_NUM_POSTS', $this->
lng->txt(
'forums_posts'));
184 $tpl->
setVariable(
'USR_IMAGE', $authorinfo->getProfilePicture());
189 if ($authorinfo->getAuthor()->getGender() ===
'f') {
191 } elseif ($authorinfo->getAuthor()->getGender() ===
'm') {
201 $spanClass =
'moderator_small';
215 $this->
lng->txt(
'edited_on') .
': ' . $this->frm->convertDate($post->
getChangeDate()) .
' - ' . strtolower($this->
lng->txt(
'by'))
217 $tpl->
setVariable(
'UPDATE_AUTHOR', $authorinfo->getLinkedAuthorShortName());
218 if ($authorinfo->getAuthorName(
true) && !$this->objProperties->isAnonymized()) {
219 $tpl->
setVariable(
'UPDATE_USR_NAME', $authorinfo->getAuthorName(
true));
230 $spanClass =
'moderator';
239 if ($spanClass !==
'') {
260 !$this->
access->checkAccess(
'read,visible',
'', $this->ref_id) ||
261 !$this->
http->wrapper()->query()->has(
'thr_top_fk') ||
262 !$this->
http->wrapper()->query()->has(
'print_thread')
264 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
269 $tpl =
new ilGlobalTemplate(
'tpl.forums_export_print.html',
true,
true,
'components/ILIAS/Forum');
271 $tpl->setVariable(
'LOCATION_STYLESHEET', $location_stylesheet);
276 $this->frm->setMDB2WhereCondition(
'top_pk = %s ', [
'integer'], [$this->
http->wrapper()->query()->retrieve(
280 $frmData = $this->frm->getOneTopic();
282 if ($frmData->getTopPk() > 0) {
286 ), $this->is_moderator);
290 $topic->setOrderField(
'frm_posts_tree.rgt');
291 $first_post = $topic->getPostRootNode();
292 $post_collection = $topic->getPostTree($first_post);
293 $num_posts = count($post_collection);
295 $tpl->setVariable(
'TITLE', $topic->getSubject());
298 $this->
lng->txt(
'forum') .
': ' . $frmData->getTopName() .
' > ' .
299 $this->
lng->txt(
'forums_thread') .
': ' . $topic->getSubject() .
' > ' .
300 $this->
lng->txt(
'forums_count_art') .
': ' . $num_posts
304 foreach ($post_collection as
$post) {
309 $tpl->printToStdout();
314 if (!$this->
access->checkAccess(
'read,visible',
'', $this->ref_id)) {
315 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
320 $tpl =
new ilGlobalTemplate(
'tpl.forums_export_print.html',
true,
true,
'components/ILIAS/Forum');
322 $tpl->setVariable(
'LOCATION_STYLESHEET', $location_stylesheet);
327 $this->frm->setMDB2WhereCondition(
'top_pk = %s ', [
'integer'], [$this->
http->wrapper()->query()->retrieve(
331 $frmData = $this->frm->getOneTopic();
333 if ($frmData->getTopPk() > 0) {
337 ), $this->is_moderator);
340 $tpl->setVariable(
'TITLE',
$post->getThread()->getSubject());
343 $this->
lng->txt(
'forum') .
': ' . $frmData->getTopName() .
' > ' .
344 $this->
lng->txt(
'forums_thread') .
': ' .
$post->getThread()->getSubject()
349 $tpl->printToStdout();
352 public function exportHTML():
void 354 if (!$this->
access->checkAccess(
'read,visible',
'', $this->ref_id)) {
355 $this->error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->MESSAGE);
360 $tpl =
new ilGlobalTemplate(
'tpl.forums_export_html.html',
true,
true,
'components/ILIAS/Forum');
362 $tpl->setVariable(
'LOCATION_STYLESHEET', $location_stylesheet);
363 $tpl->setVariable(
'BASE', (str_ends_with(ILIAS_HTTP_PATH,
'/') ? ILIAS_HTTP_PATH : ILIAS_HTTP_PATH .
'/'));
371 if ($this->
http->wrapper()->post()->has(
'thread_ids')) {
372 $thread_ids = $this->
http->wrapper()->post()->retrieve(
376 } elseif ($this->ref_id > 0) {
377 $obj_id = $this->ilObjDataCache->lookupObjId($this->ref_id);
380 $thread_ids = array_keys(
$topics);
383 array_walk($thread_ids,
function (
int $threadId) use (&$threads, $isModerator):
void {
387 $threads[] = $thread;
391 foreach ($threads as $topic) {
392 $this->frm->setMDB2WhereCondition(
'top_pk = %s ', [
'integer'], [$topic->getForumId()]);
393 $frmData = $this->frm->getOneTopic();
395 if ($frmData->getTopPk() > 0) {
397 $tpl->setVariable(
'TITLE', $frmData->getTopName());
400 $first_post = $topic->getPostRootNode();
401 $topic->setOrderField(
'frm_posts_tree.rgt');
402 $post_collection = $topic->getPostTree($first_post);
405 foreach ($post_collection as
$post) {
406 $this->
renderPostHtml($tpl, $post, $j++, self::MODE_EXPORT_CLIENT);
409 $tpl->setCurrentBlock(
'thread_headline');
410 $tpl->setVariable(
'T_TITLE', $topic->getSubject());
411 if ($this->is_moderator) {
412 $tpl->setVariable(
'T_NUM_POSTS', $topic->countPosts(
true));
414 $tpl->setVariable(
'T_NUM_POSTS', $topic->countActivePosts(
true));
416 $tpl->setVariable(
'T_NUM_VISITS', $topic->getVisits());
417 $tpl->setVariable(
'T_FORUM', $frmData->getTopName());
419 $topic->getThrAuthorId(),
420 $topic->getDisplayUserId(),
421 (string) $topic->getUserAlias(),
422 (string) $topic->getImportName()
424 $tpl->setVariable(
'T_AUTHOR', $authorinfo->getAuthorName());
425 $tpl->setVariable(
'T_TXT_FORUM', $this->
lng->txt(
'forum') .
': ');
426 $tpl->setVariable(
'T_TXT_TOPIC', $this->
lng->txt(
'forums_thread') .
': ');
427 $tpl->setVariable(
'T_TXT_AUTHOR', $this->
lng->txt(
'forums_thread_create_from') .
': ');
428 $tpl->setVariable(
'T_TXT_NUM_POSTS', $this->
lng->txt(
'forums_articles') .
': ');
429 $tpl->setVariable(
'T_TXT_NUM_VISITS', $this->
lng->txt(
'visits') .
': ');
430 $tpl->parseCurrentBlock();
435 $tpl->setCurrentBlock(
'thread_block');
436 $tpl->parseCurrentBlock();
440 $tpl->fillJavaScriptFiles();
444 'forum_html_export_' . $this->ref_id .
'.html' 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...
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
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
ensureThreadBelongsToForum(int $objId, ilForumTopic $thread)
static lookupForumIdByObjId(int $obj_id)
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
special template class to simplify handling of ITX/PEAR
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)
addLatexResources(ilGlobalTemplateInterface $tpl)
Register the resources needed for latex rendering We can't query these resources from the UI framewor...
isOwner(int $a_user_id=0)
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
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
static http()
Fetches the global http state from ILIAS.
renderPostHtml(ilGlobalTemplateInterface $tpl, ilForumPost $post, int $counter, int $mode)
Forum export to HTML and Print.
setChangeDate(?string $a_changedate)
const int MODE_EXPORT_WEB
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
readonly ilForumProperties $objProperties
static _isModerator(int $a_ref_id, int $a_usr_id)
const int MODE_EXPORT_CLIENT
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
readonly Refinery $refinery
readonly GlobalHttpState $http
static getSortedThreadSubjects(int $a_obj_id, int $a_sort_mode=self::SORT_DATE)
ilObjectDataCache $ilObjDataCache