ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilPollContentRenderer Class Reference
+ Collaboration diagram for ilPollContentRenderer:

Public Member Functions

 __construct (ilLanguage $lng, UIFactory $ui_factory, UIRenderer $ui_renderer, Refinery $refinery, ilPollStateInfo $availability, ilPollCommentsHandler $comments, ilPollAnswersHandler $answers, ilPollAnswersRenderer $answers_renderer, ilPollResultsHandler $results, ilPollResultsRenderer $results_renderer, ilPollImageFactoryInterface $poll_image_factory)
 
 render (ilTemplate $tpl, int $ref_id, int $user_id, ilObjPoll $poll, bool $admin_view=false)
 

Protected Member Functions

 renderAnswersAndResults (ilTemplate $tpl, ilObjPoll $poll, int $user_id)
 
 renderAnswers (ilTemplate $tpl, ilObjPoll $poll, int $user_id)
 
 renderResults (ilTemplate $tpl, ilObjPoll $poll)
 
 renderTotalParticipantsInfo (ilTemplate $tpl, int $total)
 
 renderNotAbleToVoteMessage (ilTemplate $tpl, bool $has_voted, bool $results_in_future, int $voting_end_date)
 
 renderQuestion (ilTemplate $tpl, string $text, ?string $img_path)
 
 renderMiscVoteInfo (ilTemplate $tpl, ?int $answer_limit, int $deadline)
 
 renderAnonimityInfo (ilTemplate $tpl, bool $anonymous)
 
 renderNotWithinVotingPeriodMessage (ilTemplate $tpl, int $vote_start, int $vote_end)
 
 renderNoQuestionMessage (ilTemplate $tpl)
 
 renderAnchor (ilTemplate $tpl, int $obj_id)
 
 renderDescription (ilTemplate $tpl, string $description)
 
 renderAvailability (ilTemplate $tpl, ilObjPoll $poll)
 
 renderAlertForAnonymousUser (ilTemplate $tpl)
 
 renderComments (ilTemplate $tpl, int $ref_id)
 
 getMessageBox (string $message)
 
 getFormattedDate (int $date)
 

Protected Attributes

ilPollStateInfo $state
 
ilPollCommentsHandler $comments
 
ilPollAnswersHandler $answers
 
ilPollAnswersRenderer $answers_renderer
 
ilPollResultsHandler $results
 
ilPollResultsRenderer $results_renderer
 
ilLanguage $lng
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 
Refinery $refinery
 
ilPollImageFactoryInterface $poll_image_factory
 

Detailed Description

Definition at line 27 of file class.ilPollContentRenderer.php.

Constructor & Destructor Documentation

◆ __construct()

ilPollContentRenderer::__construct ( ilLanguage  $lng,
UIFactory  $ui_factory,
UIRenderer  $ui_renderer,
Refinery  $refinery,
ilPollStateInfo  $availability,
ilPollCommentsHandler  $comments,
ilPollAnswersHandler  $answers,
ilPollAnswersRenderer  $answers_renderer,
ilPollResultsHandler  $results,
ilPollResultsRenderer  $results_renderer,
ilPollImageFactoryInterface  $poll_image_factory 
)

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

53 {
54 $this->lng = $lng;
55 $this->ui_factory = $ui_factory;
56 $this->ui_renderer = $ui_renderer;
57 $this->refinery = $refinery;
58 $this->state = $availability;
59 $this->comments = $comments;
60 $this->answers = $answers;
61 $this->answers_renderer = $answers_renderer;
62 $this->results = $results;
63 $this->results_renderer = $results_renderer;
64 $this->poll_image_factory = $poll_image_factory;
65 }
ilPollResultsRenderer $results_renderer
ilPollAnswersRenderer $answers_renderer
ilPollImageFactoryInterface $poll_image_factory

References $answers, $answers_renderer, $comments, $lng, $poll_image_factory, $refinery, $results, $results_renderer, $ui_factory, $ui_renderer, ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

Member Function Documentation

◆ getFormattedDate()

ilPollContentRenderer::getFormattedDate ( int  $date)
protected

Definition at line 355 of file class.ilPollContentRenderer.php.

355 : string
356 {
358 new ilDateTime($date, IL_CAL_UNIX)
359 );
360 }
const IL_CAL_UNIX
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling

References ilDatePresentation\formatDate(), and IL_CAL_UNIX.

+ Here is the call graph for this function:

◆ getMessageBox()

ilPollContentRenderer::getMessageBox ( string  $message)
protected

Definition at line 348 of file class.ilPollContentRenderer.php.

348 : string
349 {
350 return $this->ui_renderer->render(
351 $this->ui_factory->messageBox()->info($message)
352 );
353 }
$message
Definition: xapiexit.php:31

References $message.

◆ render()

ilPollContentRenderer::render ( ilTemplate  $tpl,
int  $ref_id,
int  $user_id,
ilObjPoll  $poll,
bool  $admin_view = false 
)

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

73 : void {
74 $this->renderAnchor($tpl, $poll->getId());
75 $this->renderAvailability($tpl, $poll);
76 $this->renderDescription($tpl, $poll->getLongDescription());
77
78 if (!$this->state->hasQuestion($poll)) {
79 $this->renderNoQuestionMessage($tpl);
80 } elseif ($this->state->hasVotingPeriodNotStarted($poll, false)) {
82 $tpl,
83 $poll->getVotingPeriodBegin(),
84 $poll->getVotingPeriodEnd()
85 );
86 } else {
87 $this->renderQuestion(
88 $tpl,
89 $poll->getQuestion(),
90 $this->poll_image_factory->handler()->getProcessedImageURL(new ObjectId($poll->getId()))
91 );
92 if (!$admin_view) {
93 $this->renderAnswersAndResults($tpl, $poll, $user_id);
94 }
95 }
96
97 if ($poll->getShowComments()) {
98 $this->renderComments($tpl, $ref_id);
99 }
100
101 if ($this->state->isUserAnonymous($user_id)) {
102 $this->renderAlertForAnonymousUser($tpl);
103 }
104 }
getLongDescription()
get object long description (stored in object_description)
renderAnswersAndResults(ilTemplate $tpl, ilObjPoll $poll, int $user_id)
renderAvailability(ilTemplate $tpl, ilObjPoll $poll)
renderQuestion(ilTemplate $tpl, string $text, ?string $img_path)
renderAlertForAnonymousUser(ilTemplate $tpl)
renderAnchor(ilTemplate $tpl, int $obj_id)
renderDescription(ilTemplate $tpl, string $description)
renderComments(ilTemplate $tpl, int $ref_id)
renderNotWithinVotingPeriodMessage(ilTemplate $tpl, int $vote_start, int $vote_end)
$ref_id
Definition: ltiauth.php:66

◆ renderAlertForAnonymousUser()

ilPollContentRenderer::renderAlertForAnonymousUser ( ilTemplate  $tpl)
protected

Definition at line 328 of file class.ilPollContentRenderer.php.

328 : void
329 {
330 $tpl->setVariable("TXT_ANON", $this->lng->txt('no_access_item_public'));
331 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544

References ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ renderAnchor()

ilPollContentRenderer::renderAnchor ( ilTemplate  $tpl,
int  $obj_id 
)
protected

Definition at line 303 of file class.ilPollContentRenderer.php.

303 : void
304 {
305 $tpl->setVariable("ANCHOR_ID", $obj_id);
306 }

References HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ renderAnonimityInfo()

ilPollContentRenderer::renderAnonimityInfo ( ilTemplate  $tpl,
bool  $anonymous 
)
protected

Definition at line 268 of file class.ilPollContentRenderer.php.

271 : void {
272 if ($anonymous) {
273 $info = $this->lng->txt("poll_anonymous_warning");
274 } else {
275 $info = $this->lng->txt("poll_non_anonymous_warning");
276 }
277 $tpl->setVariable("ANONIMITY_INFO", $info);
278 }
$info
Definition: entry_point.php:21

References $info, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ renderAnswers()

ilPollContentRenderer::renderAnswers ( ilTemplate  $tpl,
ilObjPoll  $poll,
int  $user_id 
)
protected

Definition at line 147 of file class.ilPollContentRenderer.php.

151 : void {
152 $this->renderMiscVoteInfo(
153 $tpl,
154 $this->answers->getAnswerLimitForInfo(),
155 $poll->getVotingPeriodEnd()
156 );
157 $this->answers_renderer->render(
158 $tpl,
159 $this->answers,
160 !$this->state->mayUserVote($user_id)
161 );
162 $this->renderAnonimityInfo($tpl, !$poll->getNonAnonymous());
163 }
renderAnonimityInfo(ilTemplate $tpl, bool $anonymous)
renderMiscVoteInfo(ilTemplate $tpl, ?int $answer_limit, int $deadline)

◆ renderAnswersAndResults()

ilPollContentRenderer::renderAnswersAndResults ( ilTemplate  $tpl,
ilObjPoll  $poll,
int  $user_id 
)
protected

Definition at line 106 of file class.ilPollContentRenderer.php.

110 : void {
111 $either_is_shown = false;
112 if (
113 !$this->state->hasUserAlreadyVoted($user_id, $poll) &&
114 !$this->state->hasVotingPeriodEnded($poll, false)
115 ) {
116 $this->renderAnswers($tpl, $poll, $user_id);
117 $either_is_shown = true;
118 }
119
120 if (
121 $this->state->areResultsVisible($user_id, $poll) &&
122 $this->results->getTotalVotes()
123 ) {
124 $this->renderResults($tpl, $poll);
126 $tpl,
127 $this->results->getTotalVotes()
128 );
129 $either_is_shown = true;
130 } elseif ($this->state->areResultsVisible($user_id, $poll)) {
132 $tpl,
133 $this->results->getTotalVotes()
134 );
135 }
136
137 if (!$either_is_shown) {
139 $tpl,
140 $this->state->hasUserAlreadyVoted($user_id, $poll),
141 $this->state->willResultsBeShown($poll),
142 $poll->getVotingPeriodEnd()
143 );
144 }
145 }
renderTotalParticipantsInfo(ilTemplate $tpl, int $total)
renderAnswers(ilTemplate $tpl, ilObjPoll $poll, int $user_id)
renderResults(ilTemplate $tpl, ilObjPoll $poll)
renderNotAbleToVoteMessage(ilTemplate $tpl, bool $has_voted, bool $results_in_future, int $voting_end_date)

References $user_id.

◆ renderAvailability()

ilPollContentRenderer::renderAvailability ( ilTemplate  $tpl,
ilObjPoll  $poll 
)
protected

Definition at line 321 of file class.ilPollContentRenderer.php.

321 : void
322 {
323 if ($this->state->isOfflineOrUnavailable($poll)) {
324 $tpl->setVariable("TXT_OFFLINE", $this->lng->txt('offline'));
325 }
326 }

References ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ renderComments()

ilPollContentRenderer::renderComments ( ilTemplate  $tpl,
int  $ref_id 
)
protected

Definition at line 333 of file class.ilPollContentRenderer.php.

333 : void
334 {
335 $tpl->setVariable("LANG_COMMENTS", $this->lng->txt('poll_comments'));
336 $tpl->setVariable("COMMENT_JSCALL", $this->comments->commentJSCall($ref_id));
337 $tpl->setVariable("COMMENTS_COUNT_ID", $ref_id);
338
339 $comments_count = $this->comments->getNumberOfComments($ref_id);
340
341 if ($comments_count > 0) {
342 $tpl->setVariable("COMMENTS_COUNT", "(" . $comments_count . ")");
343 }
344
345 $tpl->setVariable("COMMENTS_REDRAW_URL", $this->comments->getRedrawURL());
346 }

References $ref_id, ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ renderDescription()

ilPollContentRenderer::renderDescription ( ilTemplate  $tpl,
string  $description 
)
protected

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

311 : void {
312 $description = trim($description);
313 if ($description) {
314 $tpl->setVariable(
315 "TXT_DESC",
316 nl2br($this->refinery->encode()->htmlSpecialCharsAsEntities()->transform($description))
317 );
318 }
319 }

References ILIAS\Repository\refinery(), and HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ renderMiscVoteInfo()

ilPollContentRenderer::renderMiscVoteInfo ( ilTemplate  $tpl,
?int  $answer_limit,
int  $deadline 
)
protected

Definition at line 242 of file class.ilPollContentRenderer.php.

246 : void {
247 $infos = [];
248
249 if ($answer_limit) {
250 $infos[] = sprintf(
251 $this->lng->txt('poll_max_number_of_answers_info'),
252 $answer_limit
253 );
254 }
255
256 if ($deadline) {
257 $infos[] = sprintf(
258 $this->lng->txt("poll_voting_period_info"),
259 $this->getFormattedDate($deadline)
260 );
261 }
262
263 if ($infos) {
264 $tpl->setVariable('VOTE_INFO', implode(' ', $infos));
265 }
266 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ renderNoQuestionMessage()

ilPollContentRenderer::renderNoQuestionMessage ( ilTemplate  $tpl)
protected

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

293 : void
294 {
295 $tpl->setVariable(
296 "MESSAGE_BOX",
297 $this->getMessageBox(
298 $this->lng->txt("poll_block_message_no_answers")
299 )
300 );
301 }

References ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ renderNotAbleToVoteMessage()

ilPollContentRenderer::renderNotAbleToVoteMessage ( ilTemplate  $tpl,
bool  $has_voted,
bool  $results_in_future,
int  $voting_end_date 
)
protected

Definition at line 193 of file class.ilPollContentRenderer.php.

198 : void {
199 $messages = [];
200
201 if ($has_voted) {
202 $messages[] = $this->lng->txt("poll_block_message_already_voted");
203 } else {
204 $messages[] = sprintf(
205 $this->lng->txt("poll_voting_period_ended_info"),
206 $this->getFormattedDate($voting_end_date)
207 );
208 }
209
210 if ($results_in_future && $has_voted) {
211 $messages[] = sprintf(
212 $this->lng->txt("poll_block_results_available_on"),
213 $this->getFormattedDate($voting_end_date)
214 );
215 }
216
217 $tpl->setVariable(
218 "MESSAGE_BOX",
219 $this->getMessageBox(
220 implode(' ', $messages)
221 )
222 );
223 }
$messages
Definition: xapiexit.php:21

References $messages, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ renderNotWithinVotingPeriodMessage()

ilPollContentRenderer::renderNotWithinVotingPeriodMessage ( ilTemplate  $tpl,
int  $vote_start,
int  $vote_end 
)
protected

Definition at line 280 of file class.ilPollContentRenderer.php.

284 : void {
285 $message = sprintf(
286 $this->lng->txt("poll_voting_period_full_info"),
287 $this->getFormattedDate($vote_start),
288 $this->getFormattedDate($vote_end)
289 );
290 $tpl->setVariable("MESSAGE_BOX", $this->getMessageBox($message));
291 }

◆ renderQuestion()

ilPollContentRenderer::renderQuestion ( ilTemplate  $tpl,
string  $text,
?string  $img_path 
)
protected

Definition at line 225 of file class.ilPollContentRenderer.php.

229 : void {
230 $tpl->setVariable(
231 "TXT_QUESTION",
232 $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform(nl2br(trim($text)))
233 );
234 if ($img_path) {
235 $tpl->setVariable(
236 "URL_IMAGE",
237 $img_path
238 );
239 }
240 }

References HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

◆ renderResults()

ilPollContentRenderer::renderResults ( ilTemplate  $tpl,
ilObjPoll  $poll 
)
protected

Definition at line 165 of file class.ilPollContentRenderer.php.

168 : void {
169 $this->results_renderer->render(
170 $tpl,
171 $this->results,
172 $poll->getShowResultsAs()
173 );
174 }

◆ renderTotalParticipantsInfo()

ilPollContentRenderer::renderTotalParticipantsInfo ( ilTemplate  $tpl,
int  $total 
)
protected

Definition at line 176 of file class.ilPollContentRenderer.php.

179 : void {
180 if ($total === 1) {
181 $tpl->setVariable(
182 "TOTAL_ANSWERS",
183 $this->lng->txt("poll_population_singular")
184 );
185 return;
186 }
187 $tpl->setVariable(
188 "TOTAL_ANSWERS",
189 sprintf($this->lng->txt("poll_population"), $total)
190 );
191 }

References ILIAS\Repository\lng(), and HTML_Template_IT\setVariable().

+ Here is the call graph for this function:

Field Documentation

◆ $answers

ilPollAnswersHandler ilPollContentRenderer::$answers
protected

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

Referenced by __construct().

◆ $answers_renderer

ilPollAnswersRenderer ilPollContentRenderer::$answers_renderer
protected

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

Referenced by __construct().

◆ $comments

ilPollCommentsHandler ilPollContentRenderer::$comments
protected

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

Referenced by __construct().

◆ $lng

ilLanguage ilPollContentRenderer::$lng
protected

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

Referenced by __construct().

◆ $poll_image_factory

ilPollImageFactoryInterface ilPollContentRenderer::$poll_image_factory
protected

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

Referenced by __construct().

◆ $refinery

Refinery ilPollContentRenderer::$refinery
protected

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

Referenced by __construct().

◆ $results

ilPollResultsHandler ilPollContentRenderer::$results
protected

Definition at line 33 of file class.ilPollContentRenderer.php.

Referenced by __construct().

◆ $results_renderer

ilPollResultsRenderer ilPollContentRenderer::$results_renderer
protected

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

Referenced by __construct().

◆ $state

ilPollStateInfo ilPollContentRenderer::$state
protected

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

◆ $ui_factory

UIFactory ilPollContentRenderer::$ui_factory
protected

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

Referenced by __construct().

◆ $ui_renderer

UIRenderer ilPollContentRenderer::$ui_renderer
protected

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

Referenced by __construct().


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