19declare(strict_types=1);
46 protected \ILIAS\Notes\Service
$notes;
53 protected int $blog_id,
55 protected ?
string $current_month =
null,
56 protected ?
int $node_id =
null,
60 $this->notes =
$DIC->notes();
61 $this->approve_cmd_path = [
63 \ILIAS\Blog\Editing\EditingGUI::class
65 $this->approve_cmd_class = end($this->approve_cmd_path);
66 $this->admin_cmd_path = [
68 \ILIAS\Blog\Editing\EditingGUI::class
70 $this->admin_cmd_class = end($this->admin_cmd_path);
73 $this->posting_manager = $domain->
posting();
74 $this->reading_time_manager = $domain->
readingTime();
75 $this->blog_settings =
78 $this->keyword =
$req->getKeyword();
79 $this->author =
$req->getAuthor();
80 $this->exp_manager = $domain->
export()->manager();
81 $this->keyword_manager = $domain->
keywords();
84 public function render(
86 string $a_cmd =
"preview",
87 string $a_link_template =
"",
88 bool $a_show_inactive =
false,
89 string $a_export_directory =
""
92 $ilCtrl = $this->gui->ctrl();
93 $ui_factory = $this->gui->ui()->factory();
96 $wtpl =
new ilTemplate(
"tpl.blog_list.html",
true,
true,
"components/ILIAS/Blog");
98 $is_admin = $this->perm->canManage();
102 foreach ($items as $item) {
104 $item_id = $item->getId();
106 $created = $item->getCreated();
107 $approved = $item->isApproved();
109 $is_active = $this->page_manager->lookupActive($item_id,
"blp");
110 if (!$is_active && !$a_show_inactive) {
117 if (!$this->keyword && !$this->author) {
121 if (!$last_month || $last_month != $month) {
123 $wtpl->setCurrentBlock(
"month_bl");
124 $wtpl->parseCurrentBlock();
128 if ($this->keyword) {
130 } elseif ($this->author) {
133 $title = $this->gui->presentation()->util()->getMonthPresentation($month);
134 $last_month = $month;
137 $wtpl->setVariable(
"TXT_CURRENT_MONTH", $title);
140 if (!$a_link_template) {
141 $ilCtrl->setParameterByClass(
"ilblogpostinggui",
"bmn", $this->current_month);
142 $ilCtrl->setParameterByClass(
"ilblogpostinggui",
"blpg", $item_id);
143 $preview = $ilCtrl->getLinkTargetByClass(
"ilblogpostinggui", $a_cmd);
145 $preview = $this->exp_manager->buildExportLink(
149 $this->keyword_manager->getKeywords($this->blog_id,
false)
152 $more_link = $preview;
155 $posting_edit = $this->perm->mayEditPosting($item_id,
$author);
156 if (($posting_edit || $is_admin) && !$a_link_template && $a_cmd ===
"preview") {
159 if ($is_active && $this->blog_settings->getApproval() && !$approved) {
161 $ilCtrl->setParameterByClass($this->approve_cmd_class,
"apid", $item_id);
162 $actions[] = $ui_factory->link()->standard(
163 $lng->txt(
"blog_approve"),
164 $ilCtrl->getLinkTargetByClass($this->approve_cmd_path,
"approve")
166 $ilCtrl->setParameterByClass($this->approve_cmd_class,
"apid",
"");
169 $wtpl->setVariable(
"APPROVAL",
$lng->txt(
"blog_needs_approval"));
173 $actions[] = $ui_factory->link()->standard(
174 $lng->txt(
"edit_content"),
175 $ilCtrl->getLinkTargetByClass(
"ilblogpostinggui",
"edit")
177 $more_link = $ilCtrl->getLinkTargetByClass(
"ilblogpostinggui",
"edit");
181 $actions[] = $ui_factory->link()->standard(
182 $lng->txt(
"blog_toggle_draft"),
183 $ilCtrl->getLinkTargetByClass(
"ilblogpostinggui",
"deactivatePageToList")
186 $actions[] = $ui_factory->link()->standard(
187 $lng->txt(
"blog_toggle_final"),
188 $ilCtrl->getLinkTargetByClass(
"ilblogpostinggui",
"activatePageToList")
192 $actions[] = $ui_factory->link()->standard(
194 $ilCtrl->getLinkTargetByClass(
"ilblogpostinggui",
"edittitle")
197 if ($this->blog_settings->getKeywords()) {
198 $actions[] = $ui_factory->link()->standard(
199 $lng->txt(
"blog_edit_keywords"),
200 $ilCtrl->getLinkTargetByClass(
"ilblogpostinggui",
"editKeywords")
204 $actions[] = $ui_factory->link()->standard(
205 $lng->txt(
"blog_edit_date"),
206 $ilCtrl->getLinkTargetByClass(
"ilblogpostinggui",
"editdate")
209 $actions[] = $ui_factory->link()->standard(
211 $ilCtrl->getLinkTargetByClass(
"ilblogpostinggui",
"deleteBlogPostingConfirmationScreen")
213 } elseif ($is_admin) {
216 $ilCtrl->setParameterByClass($this->admin_cmd_class,
"apid", $item_id);
217 $actions[] = $ui_factory->link()->standard(
218 $lng->txt(
"blog_toggle_draft_admin"),
219 $ilCtrl->getLinkTargetByClass($this->admin_cmd_path,
"deactivateAdmin")
221 $ilCtrl->setParameterByClass($this->admin_cmd_class,
"apid",
"");
224 $actions[] = $ui_factory->link()->standard(
226 $ilCtrl->getLinkTargetByClass(
"ilblogpostinggui",
"deleteBlogPostingConfirmationScreen")
230 $dd = $ui_factory->dropdown()->standard($actions)->withLabel(
$lng->txt(
"actions"));
232 $wtpl->setCurrentBlock(
"actions");
233 $wtpl->setVariable(
"ACTION_SELECTOR",
$ui_renderer->render($dd));
234 $wtpl->parseCurrentBlock();
238 $notes_status = $this->notes->domain()->commentsActive($this->blog_id);
239 if ($notes_status && !$a_link_template) {
241 $notes_context = $this->notes
248 $count = $this->notes
250 ->getNrOfCommentsForContext($notes_context);
252 if ($a_cmd !==
"preview") {
253 $wtpl->setCurrentBlock(
"comments");
254 $wtpl->setVariable(
"TEXT_COMMENTS",
$lng->txt(
"blog_comments"));
255 $wtpl->setVariable(
"URL_COMMENTS", $preview);
256 $wtpl->setVariable(
"COUNT_COMMENTS", $count);
257 $wtpl->parseCurrentBlock();
262 if ($this->node_id !==
null &&
263 $a_cmd !==
"preview") {
265 $goto = $this->gui->permanentLink(0, (
int) $this->node_id)->getPermanentLink((
int) $item_id);
267 $goto = $this->gui->permanentLink((
int) $this->node_id)->getPermanentLink((
int) $item_id);
269 $wtpl->setCurrentBlock(
"permalink");
270 $wtpl->setVariable(
"URL_PERMALINK", $goto);
271 $wtpl->setVariable(
"TEXT_PERMALINK",
$lng->txt(
"blog_link"));
272 $wtpl->parseCurrentBlock();
275 $snippet = $this->gui->posting()->getSnippet(
277 $this->blog_settings->getAbstractShorten(),
278 $this->blog_settings->getAbstractShortenLength(),
280 $this->blog_settings->getAbstractImage(),
281 $this->blog_settings->getAbstractImageWidth(),
282 $this->blog_settings->getAbstractImageHeight(),
287 $wtpl->setCurrentBlock(
"more");
288 $wtpl->setVariable(
"URL_MORE", $more_link);
289 $wtpl->setVariable(
"TEXT_MORE",
$lng->txt(
"blog_list_more"));
290 $wtpl->parseCurrentBlock();
294 $wtpl->setCurrentBlock(
"draft_text");
295 $wtpl->setVariable(
"DRAFT_TEXT",
$lng->txt(
"blog_draft_text"));
296 $wtpl->parseCurrentBlock();
297 $wtpl->setVariable(
"DRAFT_CLASS",
" ilBlogListItemDraft");
301 $reading_time = $this->reading_time_manager->getReadingTime(
305 if (!is_null($reading_time)) {
306 $lng->loadLanguageModule(
"copg");
307 $wtpl->setCurrentBlock(
"reading_time");
310 $lng->txt(
"copg_est_reading_time") .
": " .
311 sprintf(
$lng->txt(
"copg_x_minutes"), $reading_time)
313 $wtpl->parseCurrentBlock();
316 $wtpl->setCurrentBlock(
"posting");
328 foreach ($this->page_manager->getPageContributors(
"blp", $item_id) as $editor) {
329 $editor_id = (
int) $editor[
"user_id"];
336 $author_str = implode(
", ", $authors) .
" - ";
341 $wtpl->setVariable(
"URL_TITLE", $preview);
342 $wtpl->setVariable(
"TITLE", $item->getTitle());
344 $kw = $this->posting_manager->getKeywords($this->blog_id, $item_id);
346 $keywords = (count($kw) > 0)
347 ?
"<br>" .
$lng->txt(
"keywords") .
": " . implode(
", ", $kw)
350 $wtpl->setVariable(
"DATETIME", $author_str .
354 $wtpl->setVariable(
"CONTENT", $snippet);
356 $wtpl->parseCurrentBlock();
360 if ($a_cmd ===
"previewFullscreen") {
367 $this->gui->permanentLink($ref_id, $wsp_id)->setPermanentLink();
370 if (!$is_empty || $a_show_inactive) {
ILIAS Notes Service $notes
ILIAS Blog Settings Settings $blog_settings
ILIAS Blog Export ExportManager $exp_manager
PostingManager $posting_manager
string $approve_cmd_class
ILIAS Blog Keywords KeywordManager $keyword_manager
__construct(protected InternalDataService $data, protected InternalDomainService $domain, protected InternalGUIService $gui, protected PageManagerInterface $page_manager, protected int $blog_id, protected PermissionManager $perm, protected ?string $current_month=null, protected ?int $node_id=null, protected int $id_type=\ilObjBlogGUI::REPOSITORY_NODE_ID)
ILIAS Blog ReadingTime ReadingTimeManager $reading_time_manager
Class for date presentation.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@ilCtrl_Calls ilObjBlogGUI: ilWorkspaceAccessGUI @ilCtrl_Calls ilObjBlogGUI: ilInfoScreenGUI,...
special template class to simplify handling of ITX/PEAR
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link='', bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path=null)
Default behaviour is:
readonly UIRenderer $ui_renderer
catch(\Exception $e) $req