ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPollBlockGUI Class Reference

BlockGUI class for polls. More...

+ Inheritance diagram for ilPollBlockGUI:
+ Collaboration diagram for ilPollBlockGUI:

Public Member Functions

 __construct ()
 Constructor.
 setBlock ($a_block)
 Do most of the initialisation.
executeCommand ()
 execute command
 fillRow ($a_poll)
 getHTML ()
 Get block HTML code.
 getNumberOfCommentsForRedraw ()
 Returns comment count for JS Redraw.
 getNumberOfComments ($ref_id)
 Get comment count.
- Public Member Functions inherited from ilBlockGUI
 ilBlockGUI ()
 Constructor.
 addHeaderLink ($a_href, $a_text, $status=true)
 getHeaderLinks ()
 setData ($a_data)
 Set Data.
 getData ()
 Get Data.
 setBigMode ($a_bigmode)
 Set Big Mode.
 getBigMode ()
 Get Big Mode.
 setBlockId ($a_block_id=0)
 Set Block Id.
 getBlockId ()
 Get Block Id.
 setAvailableDetailLevels ($a_max, $a_min=0)
 Set Available Detail Levels.
 setCurrentDetailLevel ($a_currentdetaillevel)
 Set Current Detail Level.
 setGuiObject (&$a_gui_object)
 Set GuiObject.
 getGuiObject ()
 Get GuiObject.
 getCurrentDetailLevel ()
 Get Current Detail Level.
 setTitle ($a_title)
 Set Title.
 getTitle ()
 Get Title.
 setImage ($a_image)
 Set Image.
 getImage ()
 Get Image.
 setOffset ($a_offset)
 Set Offset.
 getOffset ()
 Get Offset.
 correctOffset ()
 setLimit ($a_limit)
 Set Limit.
 getLimit ()
 Get Limit.
 setEnableEdit ($a_enableedit)
 Set EnableEdit.
 getEnableEdit ()
 Get EnableEdit.
 setRepositoryMode ($a_repositorymode)
 Set RepositoryMode.
 getRepositoryMode ()
 Get RepositoryMode.
 setFooterInfo ($a_footerinfo, $a_hide_and_icon=false)
 Set Footer Info.
 getFooterInfo ($a_hide_and_icon=false)
 Get Footer Info.
 setSubtitle ($a_subtitle)
 Set Subtitle.
 getSubtitle ()
 Get Subtitle.
 setRefId ($a_refid)
 Set Ref Id (only used if isRepositoryObject() is true).
 getRefId ()
 Get Ref Id (only used if isRepositoryObject() is true).
 setAdminCommands ($a_admincommands)
 Set Administration Commmands.
 getAdminCommands ()
 Get Administration Commmands.
 setColSpan ($a_colspan)
 Set Columns Span.
 getColSpan ()
 Get Columns Span.
 setEnableDetailRow ($a_enabledetailrow)
 Set EnableDetailRow.
 getEnableDetailRow ()
 Get EnableDetailRow.
 setEnableNumInfo ($a_enablenuminfo)
 Set Enable Item Number Info.
 getEnableNumInfo ()
 Get Enable Item Number Info.
 setProperties ($a_properties)
 This function is supposed to be used for block type specific properties, that should be inherited through ilColumnGUI->setBlockProperties.
 getProperty ($a_property)
 setProperty ($a_property, $a_value)
 setRowTemplate ($a_rowtemplatename, $a_rowtemplatedir="")
 Set Row Template Name.
 getNavParameter ()
 getDetailParameter ()
 getConfigParameter ()
 getMoveParameter ()
 getRowTemplateName ()
 Get Row Template Name.
 getRowTemplateDir ()
 Get Row Template Directory.
 addBlockCommand ($a_href, $a_text, $a_target="", $a_img="", $a_right_aligned=false, $a_checked=false, $a_html="")
 Add Block Command.
 getBlockCommands ()
 Get Block commands.
 addHeaderCommand ($a_href, $a_text, $a_as_close=false)
 Add Header Block Command.
 getHeaderCommands ()
 Get Header Block commands.
 addFooterLink ($a_text, $a_href="", $a_onclick="", $a_block_id="", $a_top=false, $a_omit_separator=false, $a_checked=false)
 Add a footer text/link.
 getFooterLinks ()
 Get footer links.
 clearFooterLinks ()
 Clear footer links.
 handleDetailLevel ()
 Handle read/write current detail level.
 fillHeaderCommands ()
 Fill header commands block.
 fillHeaderTitleBlock ()
 Fill header title block (title and.
 setDataSection ($a_content)
 Call this from overwritten fillDataSection(), if standard row based data is not used.
 fillDataSection ()
 Standard implementation for row based data.
 fillFooter ()
 fillPreviousNext ()
 Fill previous/next row.
 setPreviousNextLinks ()
 Get previous/next linkbar.
 fillFooterLinks ($a_top=false, $a_numinfo="")
 Fill footer links.
 fillDetailRow ()
 Fill Detail Setting Row.

Static Public Member Functions

static getBlockType ()
 Get block type.
static isRepositoryObject ()
 Is block of repository object?
static getScreenMode ()
 Get Screen Mode for current command.

Static Public Attributes

static $block_type = "poll"
static $js_init = false

Protected Member Functions

 getRepositoryObjectGUIName ()
 Get repository object GUI name.
- Protected Member Functions inherited from ilBlockGUI
 fillRowColor ($a_placeholder="CSS_ROW")
 preloadData (array $data)
 Can be overwritten in subclasses.

Protected Attributes

 $poll_block
- Protected Attributes inherited from ilBlockGUI
 $data = array()
 $colspan = 1
 $enablenuminfo = true
 $detail_min = 0
 $detail_max = 0
 $bigmode = false
 $footer_links = array()
 $block_id = 0
 $header_commands = array()
 $allow_moving = true
 $move = array("left" => false, "right" => false, "up" => false, "down" => false)
 $enabledetailrow = true
 $header_links = array()
 $footerinfo = false
 $footerinfo_icon = false
 $block_commands = array()
 $max_count = false
 $close_command = false
 $image = false
 $property = false
 $nav_value = ""
 $css_row = ""
 $dropdown

Private Member Functions

 commentJSCall ()
 Builds JavaScript Call to open CommentLayer via html link.

Detailed Description

BlockGUI class for polls.

Author
Jörg Lützenkirchen
Version
$Id$

ilPollBlockGUI: ilColumnGUI

Definition at line 17 of file class.ilPollBlockGUI.php.

Constructor & Destructor Documentation

ilPollBlockGUI::__construct ( )

Constructor.

Definition at line 28 of file class.ilPollBlockGUI.php.

References $lng, and ilBlockGUI\setRowTemplate().

{
global $lng;
$lng->loadLanguageModule("poll");
$this->setRowTemplate("tpl.block.html", "Modules/Poll");
}

+ Here is the call graph for this function:

Member Function Documentation

ilPollBlockGUI::commentJSCall ( )
private

Builds JavaScript Call to open CommentLayer via html link.

Returns
string jsCall

Definition at line 437 of file class.ilPollBlockGUI.php.

References $comment, ilObject2\_lookupObjectId(), ilCommonActionDispatcherGUI\buildAjaxHash(), ilBlockGUI\getRefId(), and ilCommonActionDispatcherGUI\TYPE_REPOSITORY.

Referenced by fillRow().

{
include_once("./Services/Notes/classes/class.ilNoteGUI.php");
include_once("./Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
$refId = $this->getRefId();
$objectId = ilObject2::_lookupObjectId($refId);
ilCommonActionDispatcherGUI::TYPE_REPOSITORY, $refId, "poll", $objectId);
$jsCall = $comment->getListCommentsJSCall($ajaxHash, "ilPoll.redrawComments(".$refId.");");
return $jsCall;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& ilPollBlockGUI::executeCommand ( )

execute command

Definition at line 88 of file class.ilPollBlockGUI.php.

References $cmd, and $ilCtrl.

{
global $ilCtrl;
$next_class = $ilCtrl->getNextClass();
$cmd = $ilCtrl->getCmd("getHTML");
switch ($next_class)
{
default:
return $this->$cmd();
}
}
ilPollBlockGUI::fillRow (   $a_poll)

Reimplemented from ilBlockGUI.

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

References $_SESSION, $ilCtrl, $ilUser, $img, $lng, $total, $tpl, commentJSCall(), ilDatePresentation\formatDate(), ilProgressBar\getInstance(), ilChart\getInstanceByType(), getNumberOfComments(), ilBlockGUI\getRefId(), getRepositoryObjectGUIName(), IL_CAL_UNIX, ilDatePresentation\setUseRelativeDates(), ilObjPoll\SHOW_RESULTS_AS_PIECHART, ilUtil\sortArray(), and ilDatePresentation\useRelativeDates().

{
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());
}
// bar chart
else
{
include_once "Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php";
$this->tpl->setCurrentBlock("answer_result");
foreach ($order as $answer_id)
{
$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
{
$end = $this->poll_block->getPoll()->getVotingPeriodEnd();
// #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;
}
}
}

+ Here is the call graph for this function:

static ilPollBlockGUI::getBlockType ( )
static

Get block type.

Returns
string Block type.

Reimplemented from ilBlockGUI.

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

References $block_type.

{
}
ilPollBlockGUI::getHTML ( )

Get block HTML code.

Reimplemented from ilBlockGUI.

Definition at line 359 of file class.ilPollBlockGUI.php.

References $ilCtrl, $ilUser, $lng, ilBlockGUI\addBlockCommand(), ilBlockGUI\getRefId(), getRepositoryObjectGUIName(), ilNotification\hasNotification(), ilBlockGUI\setData(), ilBlockGUI\setTitle(), and ilNotification\TYPE_POLL.

{
global $ilCtrl, $lng, $ilAccess, $ilUser;
$this->poll_block->setRefId($this->getRefId());
$this->may_write = $ilAccess->checkAccess("write", "", $this->getRefId());
$this->has_content = $this->poll_block->hasAnyContent($ilUser->getId(), $this->getRefId());
if(!$this->may_write && !$this->has_content)
{
return "";
}
$poll_obj = $this->poll_block->getPoll();
$this->setTitle($poll_obj->getTitle());
$this->setData(array($poll_obj));
$ilCtrl->setParameterByClass($this->getRepositoryObjectGUIName(),
"ref_id", $this->getRefId());
if(!$this->poll_block->getMessage($ilUser->getId()))
{
// notification
include_once "./Services/Notification/classes/class.ilNotification.php";
if(ilNotification::hasNotification(ilNotification::TYPE_POLL, $ilUser->getId(), $this->poll_block->getPoll()->getId()))
{
$ilCtrl->getLinkTargetByClass(array("ilrepositorygui", $this->getRepositoryObjectGUIName()),
"unsubscribe"),
$lng->txt("poll_notification_unsubscribe"));
}
else
{
$ilCtrl->getLinkTargetByClass(array("ilrepositorygui", $this->getRepositoryObjectGUIName()),
"subscribe"),
$lng->txt("poll_notification_subscribe"));
}
}
if ($this->may_write)
{
// edit
$ilCtrl->getLinkTargetByClass(array("ilrepositorygui", $this->getRepositoryObjectGUIName()),
"render"),
$lng->txt("edit_content"));
$ilCtrl->getLinkTargetByClass(array("ilrepositorygui", $this->getRepositoryObjectGUIName()),
"edit"),
$lng->txt("settings"));
/* delete (#10993 - see ilBlockGUI)
$parent_id = $tree->getParentId($this->getRefId());
$type = ilObject::_lookupType($parent_id, true);
$class = $objDefinition->getClassName($type);
if($class)
{
$class = "ilobj".strtolower($class)."gui";
$ilCtrl->setParameterByClass($class, "ref_id", $parent_id);
$ilCtrl->setParameterByClass($class, "item_ref_id", $this->getRefId());
$this->addBlockCommand(
$ilCtrl->getLinkTargetByClass($class, "delete"),
$lng->txt("delete"));
}
*/
}
$ilCtrl->clearParametersByClass($this->getRepositoryObjectGUIName());
return parent::getHTML();
}

+ Here is the call graph for this function:

ilPollBlockGUI::getNumberOfComments (   $ref_id)

Get comment count.

Parameters
int$ref_id
Returns
int

Definition at line 480 of file class.ilPollBlockGUI.php.

References $ref_id, ilNote\_countNotesAndComments(), ilObject2\_lookupObjectId(), and IL_NOTE_PUBLIC.

Referenced by fillRow(), and getNumberOfCommentsForRedraw().

{
include_once("./Services/Notes/classes/class.ilNote.php");
$number = ilNote::_countNotesAndComments($obj_id);
if(count($number) == 0)
{
return 0;
}
return $number[$obj_id][IL_NOTE_PUBLIC];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPollBlockGUI::getNumberOfCommentsForRedraw ( )

Returns comment count for JS Redraw.

Definition at line 458 of file class.ilPollBlockGUI.php.

References $_GET, exit, and getNumberOfComments().

{
$number = $this->getNumberOfComments($_GET["poll_id"]);
if($number > 0)
{
echo "(".$number.")";
}
else
{
echo "";
}
exit();
}

+ Here is the call graph for this function:

ilPollBlockGUI::getRepositoryObjectGUIName ( )
protected

Get repository object GUI name.

Returns
string

Definition at line 63 of file class.ilPollBlockGUI.php.

Referenced by fillRow(), and getHTML().

{
return "ilobjpollgui";
}

+ Here is the caller graph for this function:

static ilPollBlockGUI::getScreenMode ( )
static

Get Screen Mode for current command.

Reimplemented from ilBlockGUI.

Definition at line 71 of file class.ilPollBlockGUI.php.

References IL_SCREEN_SIDE.

{
return IL_SCREEN_SIDE;
}
static ilPollBlockGUI::isRepositoryObject ( )
static

Is block of repository object?

Returns
string Block type.

Reimplemented from ilBlockGUI.

Definition at line 53 of file class.ilPollBlockGUI.php.

{
return true;
}
ilPollBlockGUI::setBlock (   $a_block)

Do most of the initialisation.

Definition at line 79 of file class.ilPollBlockGUI.php.

References ilBlockGUI\setBlockId().

{
$this->setBlockId($a_block->getId());
$this->poll_block = $a_block;
}

+ Here is the call graph for this function:

Field Documentation

ilPollBlockGUI::$block_type = "poll"
static

Definition at line 19 of file class.ilPollBlockGUI.php.

Referenced by getBlockType().

ilPollBlockGUI::$js_init = false
static

Definition at line 23 of file class.ilPollBlockGUI.php.

ilPollBlockGUI::$poll_block
protected

Definition at line 21 of file class.ilPollBlockGUI.php.


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