/** * @param array $row */ public function fillRow(array $row) { $old_value = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); $row['date'] = ilDatePresentation::formatDate(new ilDateTime($row['date'], IL_CAL_UNIX)); ilDatePresentation::setUseRelativeDates($old_value); if (array_key_exists('percentage', $row)) { $row['percentage'] = sprintf('%.2f', $row['percentage']) . '%'; } // fill columns if (!$this->isObjectiveOrientedPresentationEnabled()) { $this->tpl->setVariable('VAL_SCORED', $row['scored']); $this->tpl->setVariable('VAL_PASS', $row['pass']); } $this->tpl->setVariable('VAL_DATE', $row['date']); if ($this->isObjectiveOrientedPresentationEnabled()) { $this->tpl->setVariable('VAL_LO_OBJECTIVES', $row['objectives']); $this->tpl->setVariable('VAL_LO_TRY', sprintf($this->lng->txt('tst_res_lo_try_n'), $row['pass'])); } $this->tpl->setVariable('VAL_ANSWERED', $row['answered']); if (isset($row['hints'])) { $this->tpl->setVariable('VAL_HINTS', $row['hints']); } $this->tpl->setVariable('VAL_REACHED', $row['reached']); $this->tpl->setVariable('VAL_PERCENTAGE', $row['percentage']); if (!$this->pdf_view) { $this->tpl->setVariable('VAL_PASS_DETAILS', $row['pass_details']); } }
/** * Returns an array containing all variables and values which can be exchanged in the certificate * The values should be calculated from real data. The $params parameter array should contain all * necessary information to calculate the values. * * @param array $params An array of parameters to calculate the certificate parameter values * @return array The certificate variables */ public function getCertificateVariablesForPresentation($params = array()) { global $lng; $lng->loadLanguageModule('certificate'); $user_data = $params["user_data"]; $vars = $this->getBaseVariablesForPresentation($user_data, $params["last_access"], null); $vars["SKILL_TITLE"] = ilUtil::prepareFormOutput($this->skill->getTitleForCertificate()); $vars["SKILL_LEVEL_TITLE"] = ilUtil::prepareFormOutput($this->skill->getLevelTitleForCertificate($this->skill_level_id)); $vars["SKILL_TRIGGER_TITLE"] = ilUtil::prepareFormOutput($this->skill->getTriggerTitleForCertificate($this->skill_level_id)); // custom completion date $achievement_date = ilBasicSkill::lookupLevelAchievementDate($user_data["usr_id"], $this->skill_level_id); if ($achievement_date !== false) { $old = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); $vars["DATE_COMPLETED"] = ilDatePresentation::formatDate(new ilDate($achievement_date, IL_CAL_DATETIME)); $vars["DATETIME_COMPLETED"] = ilDatePresentation::formatDate(new ilDateTime($achievement_date, IL_CAL_DATETIME)); ilDatePresentation::setUseRelativeDates($old); } else { $vars["DATE_COMPLETED"] = ""; $vars["DATETIME_COMPLETED"] = ""; } foreach ($vars as $id => $caption) { $insert_tags["[" . $id . "]"] = $caption; } return $insert_tags; }
public function send() { global $lng; $additional_information = $this->getAdditionalInformation(); $old_val = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); foreach ($this->getRecipients() as $rcp) { try { $this->handleCurrentRecipient($rcp); } catch (ilMailException $e) { continue; } $this->initMimeMail(); $this->initLanguageByIso2Code(); ilDatePresentation::setLanguage($this->getLanguage()); $date_for_deletion = ilDatePresentation::formatDate(new ilDate($additional_information["date"], IL_CAL_UNIX)); $this->setSubject($this->getLanguage()->txt('del_mail_subject')); $body = sprintf($this->getLanguage()->txt("del_mail_body"), $rcp->fullname, "\n\n", $additional_information["www"], $date_for_deletion); $this->appendBody($body); $this->appendBody(ilMail::_getInstallationSignature()); $this->sendMimeMail($this->getCurrentRecipient()); } ilDatePresentation::setUseRelativeDates($old_val); ilDatePresentation::setLanguage($lng); }
/** * @param array $row */ public function fillRow(array $row) { $old_value = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); $row['date'] = ilDatePresentation::formatDate(new ilDateTime($row['date'], IL_CAL_UNIX)); ilDatePresentation::setUseRelativeDates($old_value); if (array_key_exists('percentage', $row)) { $row['percentage'] = sprintf('%.2f', $row['percentage']) . '%'; } if ($this->pdf_view && array_key_exists('pass_details', $row)) { unset($row['pass_details']); } parent::fillRow($row); }
/** * Prepares history table and displays it. * * @global ilTemplate $tpl * @global ilLanguage $lng * @param array $messages * @param ilPropertyFormGUI $durationForm */ private function showMessages($messages, $durationForm, $export = false, $psessions = array(), $from, $to) { //global $tpl, $ilUser, $ilCtrl, $lng; global $tpl, $lng, $ilCtrl; include_once 'Modules/Chatroom/classes/class.ilChatroom.php'; if (!ilChatroom::checkUserPermissions('read', $this->gui->ref_id)) { $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", ROOT_FOLDER_ID); $ilCtrl->redirectByClass("ilrepositorygui", ""); } $this->gui->switchToVisibleMode(); $tpl->addCSS('Modules/Chatroom/templates/default/style.css'); // should be able to grep templates if ($export) { $roomTpl = new ilTemplate('tpl.history_export.html', true, true, 'Modules/Chatroom'); } else { $roomTpl = new ilTemplate('tpl.history.html', true, true, 'Modules/Chatroom'); } $scopes = array(); if ($export) { ilDatePresentation::setUseRelativeDates(false); } global $ilUser; $time_format = $ilUser->getTimeFormat(); $prevDate = ''; $messagesShown = 0; $lastDateTime = null; foreach ($messages as $message) { $message['message']->message = json_decode($message['message']->message); switch ($message['message']->type) { case 'message': if ($_REQUEST['scope'] && $message['message']->sub == $_REQUEST['scope'] || !$_REQUEST['scope'] && !$message['message']->sub) { $date = new ilDate($message['timestamp'], IL_CAL_UNIX); $dateTime = new ilDateTime($message['timestamp'], IL_CAL_UNIX); $currentDate = ilDatePresentation::formatDate($dateTime); $roomTpl->setCurrentBlock('MESSAGELINE'); $roomTpl->setVariable('MESSAGECONTENT', $message['message']->message->content); // oops... it is a message? ^^ $roomTpl->setVariable('MESSAGESENDER', $message['message']->user->username); if (null == $lastDateTime || date('d', $lastDateTime->get(IL_CAL_UNIX)) != date('d', $dateTime->get(IL_CAL_UNIX)) || date('m', $lastDateTime->get(IL_CAL_UNIX)) != date('m', $dateTime->get(IL_CAL_UNIX)) || date('Y', $lastDateTime->get(IL_CAL_UNIX)) != date('Y', $dateTime->get(IL_CAL_UNIX))) { $roomTpl->setVariable('MESSAGEDATE', ilDatePresentation::formatDate($date)); } if ($prevDate != $currentDate) { switch ($time_format) { case ilCalendarSettings::TIME_FORMAT_24: $date_string = $dateTime->get(IL_CAL_FKT_DATE, 'H:i', $ilUser->getTimeZone()); break; case ilCalendarSettings::TIME_FORMAT_12: $date_string = $dateTime->get(IL_CAL_FKT_DATE, 'g:ia', $ilUser->getTimeZone()); break; } $roomTpl->setVariable('MESSAGETIME', $date_string); $prevDate = $currentDate; } $roomTpl->parseCurrentBlock(); $lastDateTime = $dateTime; ++$messagesShown; } break; } } foreach ($psessions as $session) { $scopes[$session['proom_id']] = $session['title']; } if (isset($scopes[''])) { unset($scopes['']); } if (!$messagesShown) { //$roomTpl->touchBlock('NO_MESSAGES'); $roomTpl->setVariable('LBL_NO_MESSAGES', $lng->txt('no_messages')); } asort($scopes, SORT_STRING); $scopes = array($lng->txt('main')) + $scopes; if (count($scopes) > 1) { $select = new ilSelectInputGUI($lng->txt('scope'), 'scope'); $select->setOptions($scopes); if (isset($_REQUEST['scope'])) { $select->setValue($_REQUEST['scope']); } $durationForm->addItem($select); } $room = ilChatroom::byObjectId($this->gui->object->getId()); //if ($room->getSetting('private_rooms_enabled')) { $prevUseRelDates = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); $unixFrom = $from->getUnixTime(); $unixTo = $to->getUnixTime(); if ($unixFrom == $unixTo) { $date = new ilDate($unixFrom, IL_CAL_UNIX); $date_sub = ilDatePresentation::formatDate($date); } else { $date1 = new ilDate($unixFrom, IL_CAL_UNIX); $date2 = new ilDate($unixTo, IL_CAL_UNIX); $date_sub = ilDatePresentation::formatPeriod($date1, $date2); } ilDatePresentation::setUseRelativeDates($prevUseRelDates); $isPrivateRoom = (bool) (int) $_REQUEST['scope']; if ($isPrivateRoom) { $roomTpl->setVariable('ROOM_TITLE', sprintf($lng->txt('history_title_private_room'), $scopes[(int) $_REQUEST['scope']]) . ' (' . $date_sub . ')'); } else { $roomTpl->setVariable('ROOM_TITLE', sprintf($lng->txt('history_title_general'), $this->gui->object->getTitle()) . ' (' . $date_sub . ')'); } //} if ($export) { header("Content-Type: text/html"); header("Content-Disposition: attachment; filename=\"" . urlencode($scopes[(int) $_REQUEST['scope']] . '.html') . "\""); echo $roomTpl->get(); exit; } $roomTpl->setVariable('PERIOD_FORM', $durationForm->getHTML()); $tpl->setVariable('ADM_CONTENT', $roomTpl->get()); }
function getExerciseInfo($a_assignment_id) { global $lng, $ilCtrl, $ilUser; include_once "Modules/Exercise/classes/class.ilExAssignment.php"; $ass = new ilExAssignment($a_assignment_id); $exercise_id = $ass->getExerciseId(); if (!$exercise_id) { return; } // is the assignment still open? $times_up = false; if ($ass->getDeadline() && $ass->getDeadline() - time() <= 0) { $times_up = true; } // exercise goto include_once "./Services/Link/classes/class.ilLink.php"; $exc_ref_id = array_shift(ilObject::_getAllReferences($exercise_id)); $exc_link = ilLink::_getStaticLink($exc_ref_id, "exc"); $info = sprintf($lng->txt("blog_exercise_info"), $ass->getTitle(), "<a href=\"" . $exc_link . "\">" . ilObject::_lookupTitle($exercise_id) . "</a>"); // submit button if (!$times_up) { $ilCtrl->setParameter($this, "exc", $exercise_id); $ilCtrl->setParameter($this, "ass", $a_assignment_id); $submit_link = $ilCtrl->getLinkTarget($this, "finalize"); $ilCtrl->setParameter($this, "ass", ""); $ilCtrl->setParameter($this, "exc", ""); $info .= " <a class=\"submit emphsubmit\" href=\"" . $submit_link . "\">" . $lng->txt("blog_finalize_blog") . "</a>"; } // submitted files $submitted = ilExAssignment::getDeliveredFiles($exercise_id, $a_assignment_id, $ilUser->getId(), true); if ($submitted) { $submitted = array_pop($submitted); $ilCtrl->setParameter($this, "ass", $a_assignment_id); $dl_link = $ilCtrl->getLinkTarget($this, "downloadExcSubFile"); $ilCtrl->setParameter($this, "ass", ""); $rel = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); $info .= "<br />" . sprintf($lng->txt("blog_exercise_submitted_info"), ilDatePresentation::formatDate(new ilDateTime($submitted["ts"], IL_CAL_DATETIME)), "<a href=\"" . $dl_link . "\" class=\"submit\">" . $lng->txt("download") . "</a>"); ilDatePresentation::setUseRelativeDates($rel); } // work instructions incl. files $tooltip = ""; $ass = $ass->getInstruction(); if ($ass) { $tooltip .= nl2br($ass); } $ass_files = ilExAssignment::getFiles($exercise_id, $a_assignment_id); if (count($ass_files) > 0) { $tooltip .= "<br /><br />"; foreach ($ass_files as $file) { $ilCtrl->setParameter($this, "ass", $a_assignment_id); $ilCtrl->setParameter($this, "file", urlencode($file["name"])); $dl_link = $ilCtrl->getLinkTarget($this, "downloadExcAssFile"); $ilCtrl->setParameter($this, "file", ""); $ilCtrl->setParameter($this, "ass", ""); $tooltip .= $file["name"] . ": <a href=\"" . $dl_link . "\">" . $lng->txt("download") . "</a>"; } } if ($tooltip) { $ol_id = "exc_ass_" . $a_assignment_id; include_once "Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php"; $overlay = new ilOverlayGUI($ol_id); // overlay $overlay->setAnchor($ol_id . "_tr"); $overlay->setTrigger($ol_id . "_tr", "click", $ol_id . "_tr"); $overlay->add(); $info .= "<div id=\"" . $ol_id . "_tr\"><a href=\"#\">" . $lng->txt("exc_instruction") . "</a></div>" . "<div id=\"" . $ol_id . "\" style=\"display:none; padding:10px;\" class=\"ilOverlay\">" . $tooltip . "</div>"; } return "<div>" . $info . "</div>"; }
/** * Fill data section */ function fillDataSection() { global $lng; $btpl = new ilTemplate("tpl.wiki_advmd_block.html", true, true, "Modules/Wiki"); // see ilAdvancedMDRecordGUI::parseInfoPage() $old_dt = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); include_once 'Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php'; include_once 'Services/ADT/classes/class.ilADTFactory.php'; $values = new ilAdvancedMDValues($this->record->getRecordId(), $this->obj_id, "wpg", $this->page_id); // this correctly binds group and definitions $values->read(); $defs = $values->getDefinitions(); foreach ($values->getADTGroup()->getElements() as $element_id => $element) { $btpl->setCurrentBlock("item"); $btpl->setVariable("CAPTION", $defs[$element_id]->getTitle()); if ($element->isNull()) { $value = "-"; } else { $value = ilADTFactory::getInstance()->getPresentationBridgeForInstance($element); if ($element instanceof ilADTLocation) { $value->setSize("100%", "200px"); } $value = $value->getHTML(); } $btpl->setVariable("VALUE", $value); $btpl->parseCurrentBlock(); } /* if ($this->isHidden()) { $btpl->setVariable("HIDDEN_INFO", $lng->txt("wiki_adv_md_hidden")); } */ $this->setDataSection($btpl->get()); ilDatePresentation::setUseRelativeDates($old_dt); return; }
/** * Finalizing output processing * * @param string $a_output * @return string */ function postOutputProcessing($a_output) { // #8626/#9370 if (($this->getOutputMode() == "preview" || $this->getOutputMode() == "offline") && !$this->getAbstractOnly() && $this->add_date) { if (!$this->isInWorkspace()) { $author = ""; $author_id = $this->getBlogPosting()->getAuthor(); if ($author_id) { include_once "Services/User/classes/class.ilUserUtil.php"; $author = ilUserUtil::getNamePresentation($author_id) . " - "; } } // prepend creation date $rel = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); $prefix = "<div class=\"il_BlockInfo\" style=\"text-align:right\">" . $author . ilDatePresentation::formatDate($this->getBlogPosting()->getCreated()) . "</div>"; ilDatePresentation::setUseRelativeDates($rel); $a_output = $prefix . $a_output; } return $a_output; }
/** * Get variable values * * @param array $a_user_data * @param datetime $a_last_access * @param datetime $a_completion_date * @return array */ protected function getBaseVariablesForPresentation($a_user_data, $a_last_access = null, $a_completion_date = false) { global $lng; $old = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); $salutation = ""; if (strlen($a_user_data["gender"])) { $salutation = $lng->txt("salutation_" . $a_user_data["gender"]); } $birthday = ""; if ($a_user_data["birthday"]) { $birthday = ilDatePresentation::formatDate(new ilDate($a_user_data["birthday"], IL_CAL_DATE)); } $country = $a_user_data["sel_country"]; if ($country) { $lng->loadLanguageModule("meta"); $country = $lng->txt("meta_c_" . $country); } else { $country = $a_user_data["country"]; } $vars = array("USER_LOGIN" => ilUtil::prepareFormOutput(trim($a_user_data["login"])), "USER_FULLNAME" => ilUtil::prepareFormOutput(trim($a_user_data["title"] . " " . $a_user_data["firstname"] . " " . $a_user_data["lastname"])), "USER_FIRSTNAME" => ilUtil::prepareFormOutput($a_user_data["firstname"]), "USER_LASTNAME" => ilUtil::prepareFormOutput($a_user_data["lastname"]), "USER_TITLE" => ilUtil::prepareFormOutput($a_user_data["title"]), "USER_SALUTATION" => ilUtil::prepareFormOutput($salutation), "USER_BIRTHDAY" => ilUtil::prepareFormOutput($birthday), "USER_INSTITUTION" => ilUtil::prepareFormOutput($a_user_data["institution"]), "USER_DEPARTMENT" => ilUtil::prepareFormOutput($a_user_data["department"]), "USER_STREET" => ilUtil::prepareFormOutput($a_user_data["street"]), "USER_CITY" => ilUtil::prepareFormOutput($a_user_data["city"]), "USER_ZIPCODE" => ilUtil::prepareFormOutput($a_user_data["zipcode"]), "USER_COUNTRY" => ilUtil::prepareFormOutput($country)); if ($a_last_access) { $vars["USER_LASTACCESS"] = ilDatePresentation::formatDate(new ilDateTime($a_last_access, IL_CAL_DATETIME)); } $vars["DATE"] = ilDatePresentation::formatDate(new ilDate(time(), IL_CAL_UNIX)); $vars["DATETIME"] = ilDatePresentation::formatDate(new ilDateTime(time(), IL_CAL_UNIX)); if ($a_completion_date) { $vars["DATE_COMPLETED"] = ilDatePresentation::formatDate(new ilDate($a_completion_date, IL_CAL_DATETIME)); $vars["DATETIME_COMPLETED"] = ilDatePresentation::formatDate(new ilDateTime($a_completion_date, IL_CAL_DATETIME)); } ilDatePresentation::setUseRelativeDates($old); return $vars; }
/** * */ protected function showLastResetDate() { /** * @var $ilToolbar ilToolbarGUI */ global $ilToolbar; if ($this->object->getLastResetDate() && $this->object->getLastResetDate()->get(IL_CAL_UNIX) != 0) { $status = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); $ilToolbar->addText(sprintf($this->lng->txt('tos_last_reset_date'), ilDatePresentation::formatDate($this->object->getLastResetDate()))); ilDatePresentation::setUseRelativeDates($status); } }
function fillRow($a_poll) { global $ilCtrl, $lng, $ilUser; // handle messages $mess = $this->poll_block->getMessage($ilUser->getId()); if ($mess) { $this->tpl->setVariable("TXT_QUESTION", $mess); return; } // nested form problem if (!$_SESSION["il_cont_admin_panel"]) { // vote if ($this->poll_block->mayVote($ilUser->getId())) { $this->tpl->setCurrentBlock("answer"); foreach ($a_poll->getAnswers() as $item) { $this->tpl->setVariable("VALUE_ANSWER", $item["id"]); $this->tpl->setVariable("TXT_ANSWER_VOTE", nl2br($item["answer"])); $this->tpl->parseCurrentBlock(); } $ilCtrl->setParameterByClass("ilobjpollgui", "ref_id", $this->getRefId()); $url = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjpollgui"), "vote"); $ilCtrl->clearParametersByClass("ilobjpollgui"); $url .= "#poll" . $a_poll->getID(); $this->tpl->setVariable("URL_FORM", $url); $this->tpl->setVariable("CMD_FORM", "vote"); $this->tpl->setVariable("TXT_SUBMIT", $lng->txt("poll_vote")); } // result if ($this->poll_block->maySeeResults($ilUser->getId())) { if (!$this->poll_block->mayNotResultsYet($ilUser->getId())) { $perc = $this->poll_block->getPoll()->getVotePercentages(); $total = $perc["total"]; $perc = $perc["perc"]; $this->tpl->setVariable("TOTAL_ANSWERS", sprintf($lng->txt("poll_population"), $total)); $this->tpl->setCurrentBlock("answer_result"); foreach ($a_poll->getAnswers() as $item) { $this->tpl->setVariable("TXT_ANSWER_RESULT", nl2br($item["answer"])); $this->tpl->setVariable("PERC_ANSWER_RESULT", round($perc[$item["id"]]["perc"])); $this->tpl->parseCurrentBlock(); } } else { $rel = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); $end = $this->poll_block->getPoll()->getVotingPeriodEnd(); $end = ilDatePresentation::formatDate(new ilDateTime($end, IL_CAL_UNIX)); ilDatePresentation::setUseRelativeDates($rel); $this->tpl->setVariable("TOTAL_ANSWERS", $lng->txt("poll_block_message_already_voted") . ' ' . sprintf($lng->txt("poll_block_results_available_on"), $end)); } } else { if ($this->poll_block->getPoll()->hasUserVoted($ilUser->getId())) { $this->tpl->setVariable("TOTAL_ANSWERS", $lng->txt("poll_block_message_already_voted")); } } } $this->tpl->setVariable("ANCHOR_ID", $a_poll->getID()); $this->tpl->setVariable("TXT_QUESTION", nl2br(trim($a_poll->getQuestion()))); $desc = trim($a_poll->getDescription()); if ($desc) { $this->tpl->setVariable("TXT_DESC", nl2br($desc)); } $img = $a_poll->getImageFullPath(); if ($img) { $this->tpl->setVariable("URL_IMAGE", $img); } }
function getExerciseInfo($a_assignment_id, $a_add_submit = false) { include_once "Modules/Exercise/classes/class.ilExAssignment.php"; $ass = new ilExAssignment($a_assignment_id); $exercise_id = $ass->getExerciseId(); if (!$exercise_id) { return; } // is the assignment still open? $times_up = false; if ($ass->getDeadline() && $ass->getDeadline() - time() <= 0) { $times_up = true; } // exercise goto include_once "./Services/Link/classes/class.ilLink.php"; $exc_ref_id = array_shift(ilObject::_getAllReferences($exercise_id)); $exc_link = ilLink::_getStaticLink($exc_ref_id, "exc"); $info = sprintf($this->lng->txt("prtf_exercise_info"), $ass->getTitle(), "<a href=\"" . $exc_link . "\">" . ilObject::_lookupTitle($exercise_id) . "</a>"); // submit button if ($a_add_submit && !$times_up) { $this->ctrl->setParameter($this, "exc", $exercise_id); $this->ctrl->setParameter($this, "ass", $a_assignment_id); $submit_link = $this->ctrl->getLinkTarget($this, "finalize"); $this->ctrl->setParameter($this, "ass", ""); $this->ctrl->setParameter($this, "exc", ""); include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php"; $button = ilLinkButton::getInstance(); $button->setCaption("prtf_finalize_portfolio"); $button->setPrimary(true); $button->setUrl($submit_link); $info .= " " . $button->render(); } // submitted files $submitted = ilExAssignment::getDeliveredFiles($exercise_id, $a_assignment_id, $this->user_id, true); if ($submitted) { $submitted = array_pop($submitted); $this->ctrl->setParameter($this, "ass", $a_assignment_id); $dl_link = $this->ctrl->getLinkTarget($this, "downloadExcSubFile"); $this->ctrl->setParameter($this, "ass", ""); $rel = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php"; $button = ilLinkButton::getInstance(); $button->setCaption("download"); $button->setUrl($dl_link); $info .= "<br />" . sprintf($this->lng->txt("prtf_exercise_submitted_info"), ilDatePresentation::formatDate(new ilDateTime($submitted["ts"], IL_CAL_DATETIME)), $button->render()); ilDatePresentation::setUseRelativeDates($rel); } // work instructions incl. files $tooltip = ""; $ass = $ass->getInstruction(); if ($ass) { $tooltip .= nl2br($ass); } $ass_files = ilExAssignment::getFiles($exercise_id, $a_assignment_id); if (count($ass_files) > 0) { $tooltip .= "<br /><br />"; foreach ($ass_files as $file) { $this->ctrl->setParameter($this, "ass", $a_assignment_id); $this->ctrl->setParameter($this, "file", urlencode($file["name"])); $dl_link = $this->ctrl->getLinkTarget($this, "downloadExcAssFile"); $this->ctrl->setParameter($this, "file", ""); $this->ctrl->setParameter($this, "ass", ""); $tooltip .= $file["name"] . ": <a href=\"" . $dl_link . "\">" . $this->lng->txt("download") . "</a>"; } } if ($tooltip) { $ol_id = "exc_ass_" . $a_assignment_id; include_once "Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php"; $overlay = new ilOverlayGUI($ol_id); // overlay $overlay->setAnchor($ol_id . "_tr"); $overlay->setTrigger($ol_id . "_tr", "click", $ol_id . "_tr"); $overlay->setAutoHide(false); // $overlay->setCloseElementId($cl_id); $overlay->add(); // trigger $overlay->addTrigger($ol_id . "_tr", "click", $ol_id . "_tr"); $info .= "<div id=\"" . $ol_id . "_tr\"><a href=\"#\">" . $this->lng->txt("exc_instruction") . "</a></div>" . "<div id=\"" . $ol_id . "\" style=\"display:none; background-color:white; border: 1px solid #bbb; padding: 10px;\">" . $tooltip . "</div>"; } return $info; }
/** * get notes/comments list as html code */ function getNoteListHTML($a_type = IL_NOTE_PRIVATE, $a_init_form = true) { global $lng, $ilCtrl, $ilUser; include_once "./Services/User/classes/class.ilUserUtil.php"; $suffix = $a_type == IL_NOTE_PRIVATE ? "private" : "public"; /* user settings are deprecated $user_setting_notes_public_all = $ilUser->getPref("notes_pub_all"); $user_setting_notes_by_type = $ilUser->getPref("notes_".$suffix); */ $user_setting_notes_public_all = "y"; $user_setting_notes_by_type = "y"; if ($this->delete_note || $this->export_html || $this->print) { if ($_GET["note_id"] != "") { $filter = $_GET["note_id"]; } else { $filter = $_POST["note"]; } } $notes = ilNote::_getNotesOfObject($this->rep_obj_id, $this->obj_id, $this->obj_type, $a_type, $this->inc_sub, $filter, $user_setting_notes_public_all, $this->repository_mode, (bool) $_SESSION["comments_sort_asc"]); $all_notes = ilNote::_getNotesOfObject($this->rep_obj_id, $this->obj_id, $this->obj_type, $a_type, $this->inc_sub, $filter, "", $this->repository_mode); $tpl = new ilTemplate("tpl.notes_list.html", true, true, "Services/Notes"); if ($this->ajax) { include_once "./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php"; $tpl->setCurrentBlock("close_img"); $tpl->setVariable("CLOSE_IMG", ilGlyphGUI::get(ilGlyphGUI::CLOSE)); $tpl->parseCurrentBlock(); } // show counter if notes are hidden $cnt_str = count($all_notes) > 0 ? " (" . count($all_notes) . ")" : ""; // title if ($this->ajax) { switch ($this->obj_type) { case "catr": case "crsr": include_once "Services/ContainerReference/classes/class.ilContainerReference.php"; $title = ilContainerReference::_lookupTitle($this->rep_obj_id); break; default: $title = ilObject::_lookupTitle($this->rep_obj_id); break; } $img = ilUtil::img(ilObject::_getIcon($this->rep_obj_id, "tiny")); // add sub-object if given if ($this->obj_id) { $sub_title = $this->getSubObjectTitle($this->rep_obj_id, $this->obj_id); if ($sub_title) { $title .= " - " . $sub_title; } } $tpl->setCurrentBlock("title"); $tpl->setVariable("TITLE", $img . " " . $title); $tpl->parseCurrentBlock(); } if ($this->delete_note) { $cnt_str = ""; } if ($a_type == IL_NOTE_PRIVATE) { $tpl->setVariable("TXT_NOTES", $lng->txt("private_notes") . $cnt_str); $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PRIVATE); } else { $tpl->setVariable("TXT_NOTES", $lng->txt("notes_public_comments") . $cnt_str); $ilCtrl->setParameterByClass("ilnotegui", "note_type", IL_NOTE_PUBLIC); } $anch = $this->anchor_jump ? "notes_top" : ""; $tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this, "getNotesHTML", $anch)); if ($this->ajax) { $os = "onsubmit = \"ilNotes.cmdAjaxForm(event, '" . $ilCtrl->getFormActionByClass("ilnotegui", "", "", true) . "'); return false;\""; $tpl->setVariable("ON_SUBMIT_FORM", $os); $tpl->setVariable("FORM_ID", "Ajax"); } if ($this->export_html || $this->print) { $tpl->touchBlock("print_style"); } // show add new note button if (!$this->add_note_form && !$this->edit_note_form && !$this->delete_note && !$this->export_html && !$this->print && $ilUser->getId() != ANONYMOUS_USER_ID) { if (!$this->inc_sub) { // are displayed if ($this->rep_obj_id > 0 || $a_type != IL_NOTE_PUBLIC) { $tpl->setCurrentBlock("add_note_btn"); if ($a_type == IL_NOTE_PUBLIC) { $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("notes_add_comment")); } else { $tpl->setVariable("TXT_ADD_NOTE", $lng->txt("add_note")); } $tpl->setVariable("LINK_ADD_NOTE", $ilCtrl->getLinkTargetByClass("ilnotegui", "addNoteForm") . "#note_edit"); $tpl->parseCurrentBlock(); } } } // show show/hide button for note list if (count($all_notes) > 0 && $this->enable_hiding && !$this->delete_note && !$this->export_html && !$this->print && !$this->edit_note_form && !$this->add_note_form) { if ($user_setting_notes_by_type == "n") { if ($a_type == IL_NOTE_PUBLIC) { $txt = $lng->txt("notes_show_comments"); } else { $txt = $lng->txt("show_" . $suffix . "_notes"); } $this->renderLink($tpl, "show_notes", $txt, "showNotes", "notes_top"); } else { // never individually hide for anonymous users if ($ilUser->getId() != ANONYMOUS_USER_ID) { if ($a_type == IL_NOTE_PUBLIC) { $txt = $lng->txt("notes_hide_comments"); } else { $txt = $lng->txt("hide_" . $suffix . "_notes"); } $this->renderLink($tpl, "hide_notes", $txt, "hideNotes", "notes_top"); // show all public notes / my notes only switch if ($a_type == IL_NOTE_PUBLIC) { if ($user_setting_notes_public_all == "n") { $this->renderLink($tpl, "all_pub_notes", $lng->txt("notes_all_comments"), "showAllPublicNotes", "notes_top"); } else { $this->renderLink($tpl, "my_pub_notes", $lng->txt("notes_my_comments"), "showMyPublicNotes", "notes_top"); } } } } } // show add new note text area if (!$this->edit_note_form && $user_setting_notes_by_type != "n" && !$this->delete_note && $ilUser->getId() != ANONYMOUS_USER_ID) { if ($a_init_form) { $this->initNoteForm("create", $a_type); } $tpl->setCurrentBlock("edit_note_form"); // $tpl->setVariable("EDIT_FORM", $this->form->getHTML()); $tpl->setVariable("EDIT_FORM", $this->form_tpl->get()); $tpl->parseCurrentBlock(); $tpl->parseCurrentBlock(); $tpl->setCurrentBlock("note_row"); $tpl->parseCurrentBlock(); } // list all notes if ($user_setting_notes_by_type != "n" || !$this->enable_hiding) { $reldates = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); if (sizeof($notes)) { if ((int) $_SESSION["comments_sort_asc"] == 1) { $sort_txt = $lng->txt("notes_sort_desc"); $sort_cmd = "listSortDesc"; } else { $sort_txt = $lng->txt("notes_sort_asc"); $sort_cmd = "listSortAsc"; } $this->renderLink($tpl, "sort_list", $sort_txt, $sort_cmd, $anch); } $notes_given = false; foreach ($notes as $note) { if ($this->edit_note_form && $note->getId() == $_GET["note_id"] && $a_type == $_GET["note_type"]) { if ($a_init_form) { $this->initNoteForm("edit", $a_type, $note); } $tpl->setCurrentBlock("edit_note_form"); // $tpl->setVariable("EDIT_FORM", $this->form->getHTML()); $tpl->setVariable("EDIT_FORM", $this->form_tpl->get()); $tpl->parseCurrentBlock(); } else { $cnt_col = 2; // delete note stuff for all private notes if ($this->checkDeletion($note) && !$this->delete_note && !$this->export_html && !$this->print && !$this->edit_note_form && !$this->add_note_form) { $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId()); $this->renderLink($tpl, "delete_note", $lng->txt("delete"), "deleteNote", "note_" . $note->getId()); } // checkboxes in multiselection mode if ($this->multi_selection && !$this->delete_note) { $tpl->setCurrentBlock("checkbox_col"); $tpl->setVariable("CHK_NOTE", "note[]"); $tpl->setVariable("CHK_NOTE_ID", $note->getId()); $tpl->parseCurrentBlock(); $cnt_col = 1; } // edit note stuff for all private notes if ($this->checkEdit($note)) { if (!$this->delete_note && !$this->export_html && !$this->print && !$this->edit_note_form && !$this->add_note_form) { $ilCtrl->setParameterByClass("ilnotegui", "note_id", $note->getId()); $this->renderLink($tpl, "edit_note", $lng->txt("edit"), "editNoteForm", "note_edit"); } } $tpl->setVariable("CNT_COL", $cnt_col); // output author account if ($a_type == IL_NOTE_PUBLIC && ilObject::_exists($note->getAuthor())) { //$tpl->setCurrentBlock("author"); //$tpl->setVariable("VAL_AUTHOR", ilObjUser::_lookupLogin($note->getAuthor())); //$tpl->parseCurrentBlock(); $tpl->setCurrentBlock("user_img"); $tpl->setVariable("USR_IMG", ilObjUser::_getPersonalPicturePath($note->getAuthor(), "xxsmall")); $tpl->setVariable("USR_ALT", $lng->txt("user_image") . ": " . ilObjUser::_lookupLogin($note->getAuthor())); $tpl->parseCurrentBlock(); $tpl->setVariable("TXT_USR", ilUserUtil::getNamePresentation($note->getAuthor(), false, false) . " - "); } // last edited if ($note->getUpdateDate() != null) { $tpl->setVariable("TXT_LAST_EDIT", $lng->txt("last_edited_on")); $tpl->setVariable("DATE_LAST_EDIT", ilDatePresentation::formatDate(new ilDate($note->getUpdateDate(), IL_CAL_DATETIME))); } else { $tpl->setVariable("VAL_DATE", ilDatePresentation::formatDate(new ilDate($note->getCreationDate(), IL_CAL_DATETIME))); } // hidden note ids for deletion if ($this->delete_note) { $tpl->setCurrentBlock("delete_ids"); $tpl->setVariable("HID_NOTE", "note[]"); $tpl->setVariable("HID_NOTE_ID", $note->getId()); $tpl->parseCurrentBlock(); } $target = $note->getObject(); // target objects $this->showTargets($tpl, $this->rep_obj_id, $note->getId(), $target["obj_type"], $target["obj_id"]); $rowclass = $rowclass != "tblrow1" ? "tblrow1" : "tblrow2"; if (!$this->export_html && !$this->print) { $tpl->setCurrentBlock("note_img"); if ($a_type == IL_NOTE_PUBLIC) { $tpl->setVariable("IMG_NOTE", $this->comment_img[$note->getLabel()]["img"]); $tpl->setVariable("ALT_NOTE", $this->comment_img[$note->getLabel()]["alt"]); } else { $tpl->setVariable("IMG_NOTE", $this->note_img[$note->getLabel()]["img"]); $tpl->setVariable("ALT_NOTE", $this->note_img[$note->getLabel()]["alt"]); } $tpl->parseCurrentBlock(); } else { switch ($note->getLabel()) { case IL_NOTE_UNLABELED: $tpl->setVariable("EXP_ICON", "[ ]"); break; case IL_NOTE_IMPORTANT: $tpl->setVariable("EXP_ICON", "[!]"); break; case IL_NOTE_QUESTION: $tpl->setVariable("EXP_ICON", "[?]"); break; case IL_NOTE_PRO: $tpl->setVariable("EXP_ICON", "[+]"); break; case IL_NOTE_CONTRA: $tpl->setVariable("EXP_ICON", "[-]"); break; } } $tpl->setCurrentBlock("note"); $tpl->setVariable("ROWCLASS", $rowclass); $text = trim($note->getText()) != "" ? nl2br($note->getText()) : "<p class='subtitle'>" . $lng->txt("note_content_removed") . "</p>"; $tpl->setVariable("NOTE_TEXT", $text); $tpl->setVariable("VAL_SUBJECT", $note->getSubject()); $tpl->setVariable("NOTE_ID", $note->getId()); $tpl->setVariable("CLASS", $a_type == IL_NOTE_PUBLIC ? "ilComment" : "ilNote"); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock("note_row"); $tpl->parseCurrentBlock(); $notes_given = true; } if (!$notes_given) { $tpl->setCurrentBlock("no_notes"); if ($a_type == IL_NOTE_PUBLIC) { $tpl->setVariable("NO_NOTES", $lng->txt("notes_no_comments")); } /* else { $tpl->setVariable("NO_NOTES", $lng->txt("notes_no_notes")); }*/ $tpl->parseCurrentBlock(); } ilDatePresentation::setUseRelativeDates($reldates); // multiple items commands if ($this->multi_selection && !$this->delete_note && !$this->edit_note_form && count($notes) > 0) { if ($a_type == IL_NOTE_PRIVATE) { $tpl->setCurrentBlock("delete_cmd"); $tpl->setVariable("TXT_DELETE_NOTES", $this->lng->txt("delete")); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock("multiple_commands"); $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all")); $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg")); $tpl->setVariable("ALT_ARROW", $this->lng->txt("actions")); $tpl->setVariable("TXT_PRINT_NOTES", $this->lng->txt("print")); $tpl->setVariable("TXT_EXPORT_NOTES", $this->lng->txt("exp_html")); $tpl->parseCurrentBlock(); } // delete / cancel row if ($this->delete_note) { $tpl->setCurrentBlock("delete_cancel"); $tpl->setVariable("TXT_DEL_NOTES", $this->lng->txt("delete")); $tpl->setVariable("TXT_CANCEL_DEL_NOTES", $this->lng->txt("cancel")); $tpl->parseCurrentBlock(); } // print if ($this->print) { $tpl->touchBlock("print_js"); $tpl->setCurrentBlock("print_back"); $tpl->setVariable("LINK_BACK", $this->ctrl->getLinkTarget($this, "showNotes")); $tpl->setVariable("TXT_BACK", $this->lng->txt("back")); $tpl->parseCurrentBlock(); } } // message switch ($_GET["note_mess"] != "" ? $_GET["note_mess"] : $this->note_mess) { case "mod": $mtype = "success"; $mtxt = $lng->txt("msg_obj_modified"); break; case "ntsdel": $mtype = "success"; $mtxt = $a_type == IL_NOTE_PRIVATE ? $lng->txt("notes_notes_deleted") : $lng->txt("notes_comments_deleted"); break; case "ntdel": $mtype = "success"; $mtxt = $a_type == IL_NOTE_PRIVATE ? $lng->txt("notes_note_deleted") : $lng->txt("notes_comment_deleted"); break; case "frmfld": $mtype = "failure"; $mtxt = $lng->txt("form_input_not_valid"); break; case "qdel": $mtype = "question"; $mtxt = $lng->txt("info_delete_sure"); break; case "noc": $mtype = "failure"; $mtxt = $lng->txt("no_checkbox"); break; } if ($mtxt != "") { $tpl->setVariable("MESS", $tpl->getMessageHTML($mtxt, $mtype)); } else { $tpl->setVariable("MESS", ""); } if ($this->delete_note && count($notes) == 0) { return ""; } else { return $tpl->get(); } }
public function displayPostInfo() { global $tpl, $ilUser, $lng, $ilCtrl; $id = (int) $_GET["object_id"]; if (!$id) { return; } // placeholder include_once 'Modules/BookingManager/classes/class.ilBookingReservation.php'; $book_ids = ilBookingReservation::getObjectReservationForUser($id, $ilUser->getId(), true); $tmp = array(); $rsv_ids = explode(";", $_GET["rsv_ids"]); foreach ($book_ids as $book_id) { if (in_array($book_id, $rsv_ids)) { $obj = new ilBookingReservation($book_id); $from = $obj->getFrom(); $to = $obj->getTo(); if ($from > time()) { $tmp[$from . "-" . $to]++; } } } $olddt = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); $period = array(); ksort($tmp); foreach ($tmp as $time => $counter) { $time = explode("-", $time); $time = ilDatePresentation::formatPeriod(new ilDateTime($time[0], IL_CAL_UNIX), new ilDateTime($time[1], IL_CAL_UNIX)); if ($counter > 1) { $time .= " (" . $counter . ")"; } $period[] = $time; } $book_id = array_shift($book_ids); ilDatePresentation::setUseRelativeDates($olddt); $obj = new ilBookingReservation($book_id); if ($obj->getUserId() != $ilUser->getId()) { return; } include_once 'Modules/BookingManager/classes/class.ilBookingObject.php'; $obj = new ilBookingObject($id); $pfile = $obj->getPostFile(); $ptext = $obj->getPostText(); $mytpl = new ilTemplate('tpl.booking_reservation_post.html', true, true, 'Modules/BookingManager'); $mytpl->setVariable("TITLE", $lng->txt('book_post_booking_information')); if ($ptext) { // placeholder $ptext = str_replace("[OBJECT]", $obj->getTitle(), $ptext); $ptext = str_replace("[PERIOD]", implode("<br />", $period), $ptext); $mytpl->setVariable("POST_TEXT", nl2br($ptext)); } if ($pfile) { $ilCtrl->setParameter($this, "object_id", $obj->getId()); $url = $ilCtrl->getLinkTarget($this, 'deliverPostFile'); $ilCtrl->setParameter($this, "object_id", ""); $mytpl->setVariable("DOWNLOAD", $lng->txt('download')); $mytpl->setVariable("URL_FILE", $url); $mytpl->setVariable("TXT_FILE", $pfile); } $mytpl->setVariable("TXT_SUBMIT", $lng->txt('ok')); $mytpl->setVariable("URL_SUBMIT", $ilCtrl->getLinkTargetByClass('ilobjbookingpoolgui', 'render')); $tpl->setContent($mytpl->get()); }
/** * Returns the user data for a test results output * * @param ilTestSession|ilTestSessionDynamicQuestionSet * @param integer $user_id The user ID of the user * @param boolean $overwrite_anonymity TRUE if the anonymity status should be overwritten, FALSE otherwise * @return string HTML code of the user data for the test results * @access public */ function getResultsUserdata($testSession, $active_id, $overwrite_anonymity = FALSE) { if (!is_object($testSession)) { throw new TestException(); } $template = new ilTemplate("tpl.il_as_tst_results_userdata.html", TRUE, TRUE, "Modules/Test"); include_once './Services/User/classes/class.ilObjUser.php'; $user_id = $this->object->_getUserIdFromActiveId($active_id); if (strlen(ilObjUser::_lookupLogin($user_id)) > 0) { $user = new ilObjUser($user_id); } else { $user = new ilObjUser(); $user->setLastname($this->lng->txt("deleted_user")); } $t = $testSession->getSubmittedTimestamp(); if (!$t) { $t = $this->object->_getLastAccess($testSession->getActiveId()); } $print_date = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y")); $title_matric = ""; if (strlen($user->getMatriculation()) && ($this->object->getAnonymity() == FALSE || $overwrite_anonymity)) { $template->setCurrentBlock("user_matric"); $template->setVariable("TXT_USR_MATRIC", $this->lng->txt("matriculation")); $template->parseCurrentBlock(); $template->setCurrentBlock("user_matric_value"); $template->setVariable("VALUE_USR_MATRIC", $user->getMatriculation()); $template->parseCurrentBlock(); $template->touchBlock("user_matric_separator"); $title_matric = " - " . $this->lng->txt("matriculation") . ": " . $user->getMatriculation(); } $invited_user = array_pop($this->object->getInvitedUsers($user_id)); if (strlen($invited_user["clientip"])) { $template->setCurrentBlock("user_clientip"); $template->setVariable("TXT_CLIENT_IP", $this->lng->txt("client_ip")); $template->parseCurrentBlock(); $template->setCurrentBlock("user_clientip_value"); $template->setVariable("VALUE_CLIENT_IP", $invited_user["clientip"]); $template->parseCurrentBlock(); $template->touchBlock("user_clientip_separator"); $title_client = " - " . $this->lng->txt("clientip") . ": " . $invited_user["clientip"]; } $template->setVariable("TXT_TEST_TITLE", $this->lng->txt("title")); $template->setVariable("VALUE_TEST_TITLE", $this->object->getTitle()); $template->setVariable("TXT_USR_NAME", $this->lng->txt("name")); $uname = $this->object->userLookupFullName($user_id, $overwrite_anonymity); $template->setVariable("VALUE_USR_NAME", $uname); $template->setVariable("TXT_TEST_DATE", $this->lng->txt("tst_tst_date")); $template->setVariable("TXT_PRINT_DATE", $this->lng->txt("tst_print_date")); $old_value = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); $template->setVariable("VALUE_TEST_DATE", ilDatePresentation::formatDate(new ilDateTime(ilUtil::date_mysql2time($t), IL_CAL_UNIX))); $template->setVariable("VALUE_PRINT_DATE", ilDatePresentation::formatDate(new ilDateTime($print_date, IL_CAL_UNIX))); ilDatePresentation::setUseRelativeDates($old_value); // change the pagetitle $pagetitle = ": " . $this->object->getTitle() . $title_matric . $title_client; $this->tpl->setHeaderPageTitle($pagetitle); return $template->get(); }
function fillRow($a_poll) { global $ilCtrl, $lng, $ilUser, $tpl; // handle messages $mess = $this->poll_block->getMessage($ilUser->getId()); if ($mess) { $this->tpl->setVariable("TXT_QUESTION", $mess); return; } // nested form problem if (!$_SESSION["il_cont_admin_panel"]) { // vote if ($this->poll_block->mayVote($ilUser->getId())) { $this->tpl->setCurrentBlock("mode_info_bl"); if ($this->poll_block->getPoll()->getNonAnonymous()) { $mode_info = $lng->txt("poll_non_anonymous_warning"); } else { $mode_info = $lng->txt("poll_anonymous_warning"); } $this->tpl->setVariable("MODE_INFO", $mode_info); $this->tpl->parseCurrentBlock(); $is_multi_answer = $this->poll_block->getPoll()->getMaxNumberOfAnswers() > 1; if (isset($_SESSION["last_poll_vote"][$this->poll_block->getPoll()->getId()])) { $last_vote = $_SESSION["last_poll_vote"][$this->poll_block->getPoll()->getId()]; unset($_SESSION["last_poll_vote"][$this->poll_block->getPoll()->getId()]); if ($is_multi_answer) { $error = sprintf($lng->txt("poll_vote_error_multi"), $this->poll_block->getPoll()->getMaxNumberOfAnswers()); } else { $error = $lng->txt("poll_vote_error_single"); } $this->tpl->setCurrentBlock("error_bl"); $this->tpl->setVariable("FORM_ERROR", $error); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock("answer"); foreach ($a_poll->getAnswers() as $item) { if (!$is_multi_answer) { $this->tpl->setVariable("ANSWER_INPUT", "radio"); $this->tpl->setVariable("ANSWER_NAME", "aw"); } else { $this->tpl->setVariable("ANSWER_INPUT", "checkbox"); $this->tpl->setVariable("ANSWER_NAME", "aw[]"); if (is_array($last_vote) && in_array($item["id"], $last_vote)) { $this->tpl->setVariable("ANSWER_STATUS", 'checked="checked"'); } } $this->tpl->setVariable("VALUE_ANSWER", $item["id"]); $this->tpl->setVariable("TXT_ANSWER_VOTE", nl2br($item["answer"])); $this->tpl->parseCurrentBlock(); } $ilCtrl->setParameterByClass($this->getRepositoryObjectGUIName(), "ref_id", $this->getRefId()); $url = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", $this->getRepositoryObjectGUIName()), "vote"); $ilCtrl->clearParametersByClass($this->getRepositoryObjectGUIName()); $url .= "#poll" . $a_poll->getID(); $this->tpl->setVariable("URL_FORM", $url); $this->tpl->setVariable("CMD_FORM", "vote"); $this->tpl->setVariable("TXT_SUBMIT", $lng->txt("poll_vote")); if ($this->poll_block->getPoll()->getVotingPeriod()) { $this->tpl->setVariable("TXT_VOTING_PERIOD", sprintf($lng->txt("poll_voting_period_info"), ilDatePresentation::formatDate(new ilDateTime($this->poll_block->getPoll()->getVotingPeriodEnd(), IL_CAL_UNIX)))); } } // result if ($this->poll_block->maySeeResults($ilUser->getId())) { if (!$this->poll_block->mayNotResultsYet($ilUser->getId())) { $answers = array(); foreach ($a_poll->getAnswers() as $item) { $answers[$item["id"]] = $item["answer"]; } $perc = $this->poll_block->getPoll()->getVotePercentages(); $total = $perc["total"]; $perc = $perc["perc"]; $this->tpl->setVariable("TOTAL_ANSWERS", sprintf($lng->txt("poll_population"), $total)); if ($total) { // sort results by votes / original position if ($this->poll_block->getPoll()->getSortResultByVotes()) { $order = array_keys(ilUtil::sortArray($perc, "abs", "desc", true, true)); foreach (array_keys($answers) as $answer_id) { if (!in_array($answer_id, $order)) { $order[] = $answer_id; } } } else { $order = array_keys($answers); } // pie chart if ($this->poll_block->showResultsAs() == ilObjPoll::SHOW_RESULTS_AS_PIECHART) { include_once "./Services/Chart/classes/class.ilChart.php"; $chart = ilChart::getInstanceByType(ilCHart::TYPE_PIE, "poll_results_pie_" . $this->getRefId()); $chart->setSize("100%", 200); $chart->setAutoResize(true); $chart_data = $chart->getDataInstance(); foreach ($order as $answer_id) { $chart_data->addPoint(round($perc[$answer_id]["perc"]), nl2br($answers[$answer_id])); } // disable legend, use inner labels - currently not preferred // $chart_data->setLabelRadius(0.8); $chart->addData($chart_data); $pie_legend_id = "poll_legend_" . $this->getRefId(); $legend = new ilChartLegend(); $legend->setContainer($pie_legend_id); $chart->setLegend($legend); $this->tpl->setVariable("PIE_LEGEND_ID", $pie_legend_id); $this->tpl->setVariable("PIE_CHART", $chart->getHTML()); } else { include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php"; $this->tpl->setCurrentBlock("answer_result"); foreach ($order as $answer_id) { $pbar = ilProgressBar::getInstance(); $pbar->setCurrent(round($perc[$answer_id]["perc"])); $this->tpl->setVariable("PERC_ANSWER_RESULT", $pbar->render()); $this->tpl->setVariable("TXT_ANSWER_RESULT", nl2br($answers[$answer_id])); $this->tpl->parseCurrentBlock(); } } } } else { $rel = ilDatePresentation::useRelativeDates(); ilDatePresentation::setUseRelativeDates(false); $end = $this->poll_block->getPoll()->getVotingPeriodEnd(); $end = ilDatePresentation::formatDate(new ilDateTime($end, IL_CAL_UNIX)); ilDatePresentation::setUseRelativeDates($rel); // #14607 $info = ""; if ($this->poll_block->getPoll()->hasUserVoted($ilUser->getId())) { $info .= $lng->txt("poll_block_message_already_voted") . " "; } $this->tpl->setVariable("TOTAL_ANSWERS", $info . sprintf($lng->txt("poll_block_results_available_on"), $end)); } } else { if ($this->poll_block->getPoll()->hasUserVoted($ilUser->getId())) { $this->tpl->setVariable("TOTAL_ANSWERS", $lng->txt("poll_block_message_already_voted")); } } } $this->tpl->setVariable("ANCHOR_ID", $a_poll->getID()); $this->tpl->setVariable("TXT_QUESTION", nl2br(trim($a_poll->getQuestion()))); $desc = trim($a_poll->getDescription()); if ($desc) { $this->tpl->setVariable("TXT_DESC", nl2br($desc)); } $img = $a_poll->getImageFullPath(); if ($img) { $this->tpl->setVariable("URL_IMAGE", $img); } if ($this->poll_block->showComments()) { $this->tpl->setCurrentBlock("comment_link"); $this->tpl->setVariable("LANG_COMMENTS", $lng->txt('poll_comments')); $this->tpl->setVariable("COMMENT_JSCALL", $this->commentJSCall()); $this->tpl->setVariable("COMMENTS_COUNT_ID", $this->getRefId()); $comments_count = $this->getNumberOfComments($this->getRefId()); if ($comments_count > 0) { $this->tpl->setVariable("COMMENTS_COUNT", "(" . $comments_count . ")"); } if (!self::$js_init) { $redraw_url = $ilCtrl->getLinkTarget($this, "getNumberOfCommentsForRedraw", "", true, false); $this->tpl->setVariable("COMMENTS_REDRAW_URL", $redraw_url); $tpl->addJavaScript("Modules/Poll/js/ilPoll.js"); self::$js_init = true; } } }