ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilPollBlockGUI Class Reference

BlockGUI class for polls. More...

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

Public Member Functions

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

Static Public Member Functions

static getBlockType ()
 Get block type. More...
 
static isRepositoryObject ()
 Get block type. More...
 
static getScreenMode ()
 Get Screen Mode for current command. More...
 
- Static Public Member Functions inherited from ilBlockGUI
static getBlockType ()
 
static isRepositoryObject ()
 
static getScreenMode ()
 Get Screen Mode for current command. More...
 

Static Public Attributes

static $block_type = "poll"
 

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
 

Additional Inherited Members

- Protected Member Functions inherited from ilBlockGUI
 fillRowColor ($a_placeholder="CSS_ROW")
 
 preloadData (array $data)
 Can be overwritten in subclasses. More...
 

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

◆ __construct()

ilPollBlockGUI::__construct ( )

Constructor.

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

References $lng, and ilBlockGUI\setRowTemplate().

27  {
28  global $lng;
29 
30  parent::__construct();
31 
32  $lng->loadLanguageModule("poll");
33  $this->setRowTemplate("tpl.block.html", "Modules/Poll");
34  }
global $lng
Definition: privfeed.php:40
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
+ Here is the call graph for this function:

Member Function Documentation

◆ executeCommand()

& ilPollBlockGUI::executeCommand ( )

execute command

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

References $cmd, and $ilCtrl.

77  {
78  global $ilCtrl;
79 
80  $next_class = $ilCtrl->getNextClass();
81  $cmd = $ilCtrl->getCmd("getHTML");
82 
83  switch ($next_class)
84  {
85  default:
86  return $this->$cmd();
87  }
88  }
$cmd
Definition: sahs_server.php:35
global $ilCtrl
Definition: ilias.php:18

◆ fillRow()

ilPollBlockGUI::fillRow (   $a_poll)

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

References $_SESSION, $ilCtrl, $ilUser, $img, $lng, $total, ilDatePresentation\formatDate(), ilBlockGUI\getRefId(), IL_CAL_UNIX, ilDatePresentation\setUseRelativeDates(), and ilDatePresentation\useRelativeDates().

91  {
92  global $ilCtrl, $lng, $ilUser;
93 
94 
95  // handle messages
96 
97  $mess = $this->poll_block->getMessage($ilUser->getId());
98  if($mess)
99  {
100  $this->tpl->setVariable("TXT_QUESTION", $mess);
101  return;
102  }
103 
104 
105  // nested form problem
106  if(!$_SESSION["il_cont_admin_panel"])
107  {
108  // vote
109 
110  if($this->poll_block->mayVote($ilUser->getId()))
111  {
112  $this->tpl->setCurrentBlock("answer");
113  foreach($a_poll->getAnswers() as $item)
114  {
115  $this->tpl->setVariable("VALUE_ANSWER", $item["id"]);
116  $this->tpl->setVariable("TXT_ANSWER_VOTE", nl2br($item["answer"]));
117  $this->tpl->parseCurrentBlock();
118  }
119 
120  $ilCtrl->setParameterByClass("ilobjpollgui",
121  "ref_id", $this->getRefId());
122  $url = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjpollgui"),
123  "vote");
124  $ilCtrl->clearParametersByClass("ilobjpollgui");
125 
126  $url .= "#poll".$a_poll->getID();
127 
128  $this->tpl->setVariable("URL_FORM", $url);
129  $this->tpl->setVariable("CMD_FORM", "vote");
130  $this->tpl->setVariable("TXT_SUBMIT", $lng->txt("poll_vote"));
131 
132  if($this->poll_block->getPoll()->getVotingPeriod())
133  {
134  $this->tpl->setVariable("TXT_VOTING_PERIOD",
135  sprintf($lng->txt("poll_voting_period_info"),
136  ilDatePresentation::formatDate(new ilDateTime($this->poll_block->getPoll()->getVotingPeriodEnd(), IL_CAL_UNIX))));
137  }
138  }
139 
140 
141  // result
142  if($this->poll_block->maySeeResults($ilUser->getId()))
143  {
144  if(!$this->poll_block->mayNotResultsYet($ilUser->getId()))
145  {
146  $perc = $this->poll_block->getPoll()->getVotePercentages();
147  $total = $perc["total"];
148  $perc = $perc["perc"];
149 
150  $this->tpl->setVariable("TOTAL_ANSWERS", sprintf($lng->txt("poll_population"), $total));
151 
152  $this->tpl->setCurrentBlock("answer_result");
153  foreach($a_poll->getAnswers() as $item)
154  {
155  $this->tpl->setVariable("TXT_ANSWER_RESULT", nl2br($item["answer"]));
156  $this->tpl->setVariable("PERC_ANSWER_RESULT", round($perc[$item["id"]]["perc"]));
157  $this->tpl->parseCurrentBlock();
158  }
159  }
160  else
161  {
164  $end = $this->poll_block->getPoll()->getVotingPeriodEnd();
167 
168  // #14607
169  $info = "";
170  if($this->poll_block->getPoll()->hasUserVoted($ilUser->getId()))
171  {
172  $info .= $lng->txt("poll_block_message_already_voted")." ";
173  }
174 
175  $this->tpl->setVariable("TOTAL_ANSWERS", $info.
176  sprintf($lng->txt("poll_block_results_available_on"), $end));
177  }
178  }
179  else if($this->poll_block->getPoll()->hasUserVoted($ilUser->getId()))
180  {
181  $this->tpl->setVariable("TOTAL_ANSWERS", $lng->txt("poll_block_message_already_voted"));
182  }
183  }
184 
185 
186  $this->tpl->setVariable("ANCHOR_ID", $a_poll->getID());
187  $this->tpl->setVariable("TXT_QUESTION", nl2br(trim($a_poll->getQuestion())));
188 
189  $desc = trim($a_poll->getDescription());
190  if($desc)
191  {
192  $this->tpl->setVariable("TXT_DESC", nl2br($desc));
193  }
194 
195  $img = $a_poll->getImageFullPath();
196  if($img)
197  {
198  $this->tpl->setVariable("URL_IMAGE", $img);
199  }
200  }
< a tabindex="-1" style="border-style: none;" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = './securimage_show.php?sid=' + Math.random(); this.blur(); return false">< img src="./images/refresh.png" alt="Reload Image" height="32" width="32" onclick="this.blur()" align="bottom" border="0"/></a >< br/>< strong > Enter Code *if($_SERVER['REQUEST_METHOD']=='POST' &&@ $_POST['do']=='contact') $_SESSION['ctform']['success']
static setUseRelativeDates($a_status)
set use relative dates
const IL_CAL_UNIX
static useRelativeDates()
check if relative dates are used
global $ilCtrl
Definition: ilias.php:18
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
getRefId()
Get Ref Id (only used if isRepositoryObject() is true).
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ getBlockType()

static ilPollBlockGUI::getBlockType ( )
static

Get block type.

Returns
string Block type.

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

42  {
43  return self::$block_type;
44  }

◆ getHTML()

ilPollBlockGUI::getHTML ( )

Get block HTML code.

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

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

206  {
207  global $ilCtrl, $lng, $ilAccess, $ilUser, $tree, $objDefinition;
208 
209  $this->poll_block->setRefId($this->getRefId());
210  $this->may_write = $ilAccess->checkAccess("write", "", $this->getRefId());
211  $this->has_content = $this->poll_block->hasAnyContent($ilUser->getId(), $this->getRefId());
212 
213  if(!$this->may_write && !$this->has_content)
214  {
215  return "";
216  }
217 
218  $poll_obj = $this->poll_block->getPoll();
219  $this->setTitle($poll_obj->getTitle());
220  $this->setData(array($poll_obj));
221 
222  if ($this->may_write)
223  {
224  // edit
225  $ilCtrl->setParameterByClass("ilobjpollgui",
226  "ref_id", $this->getRefId());
227  $this->addBlockCommand(
228  $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjpollgui"),
229  "render"),
230  $lng->txt("edit_content"));
231  $this->addBlockCommand(
232  $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjpollgui"),
233  "edit"),
234  $lng->txt("settings"));
235 
236  /* delete (#10993 - see ilBlockGUI)
237  $parent_id = $tree->getParentId($this->getRefId());
238  $type = ilObject::_lookupType($parent_id, true);
239  $class = $objDefinition->getClassName($type);
240  if($class)
241  {
242  $class = "ilobj".strtolower($class)."gui";
243  $ilCtrl->setParameterByClass($class, "ref_id", $parent_id);
244  $ilCtrl->setParameterByClass($class, "item_ref_id", $this->getRefId());
245  $this->addBlockCommand(
246  $ilCtrl->getLinkTargetByClass($class, "delete"),
247  $lng->txt("delete"));
248  }
249  */
250 
251  $ilCtrl->clearParametersByClass("ilobjpollgui");
252  }
253 
254  return parent::getHTML();
255  }
addBlockCommand($a_href, $a_text, $a_target="", $a_img="", $a_right_aligned=false, $a_checked=false)
Add Block Command.
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title)
Set Title.
setData($a_data)
Set Data.
getRefId()
Get Ref Id (only used if isRepositoryObject() is true).
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ getScreenMode()

static ilPollBlockGUI::getScreenMode ( )
static

Get Screen Mode for current command.

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

References IL_SCREEN_SIDE.

60  {
61  return IL_SCREEN_SIDE;
62  }
const IL_SCREEN_SIDE

◆ isRepositoryObject()

static ilPollBlockGUI::isRepositoryObject ( )
static

Get block type.

Returns
string Block type.

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

52  {
53  return true;
54  }

◆ setBlock()

ilPollBlockGUI::setBlock (   $a_block)

Do most of the initialisation.

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

References ilBlockGUI\setBlockId().

68  {
69  $this->setBlockId($a_block->getId());
70  $this->poll_block = $a_block;
71  }
setBlockId($a_block_id=0)
Set Block Id.
+ Here is the call graph for this function:

Field Documentation

◆ $block_type

ilPollBlockGUI::$block_type = "poll"
static

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

◆ $poll_block

ilPollBlockGUI::$poll_block
protected

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


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