ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilExcCriteriaBool.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
12 {
16  protected $lng;
17 
18 
22  public function __construct()
23  {
24  global $DIC;
25 
27  $this->lng = $DIC->language();
28  }
29 
30  public function getType()
31  {
32  return "bool";
33  }
34 
35 
36  // PEER REVIEW
37 
38  public function addToPeerReviewForm($a_value = null)
39  {
40  $lng = $this->lng;
41 
42  if (!$this->isRequired()) {
43  $input = new ilCheckboxInputGUI($this->getTitle(), "prccc_bool_" . $this->getId());
44  $input->setInfo($this->getDescription());
45  $input->setRequired($this->isRequired());
46  $input->setChecked($a_value > 0);
47  } else {
48  $input = new ilSelectInputGUI($this->getTitle(), "prccc_bool_" . $this->getId());
49  $input->setInfo($this->getDescription());
50  $input->setRequired($this->isRequired());
51  $input->setValue($a_value);
52  $options = array();
53  if (!$a_value) {
54  $options[""] = $lng->txt("please_select");
55  }
56  $options[1] = $lng->txt("yes");
57  $options[-1] = $lng->txt("no");
58  $input->setOptions($options);
59  }
60  $this->form->addItem($input);
61  }
62 
63  public function importFromPeerReviewForm()
64  {
65  return (int) $this->form->getInput("prccc_bool_" . $this->getId());
66  }
67 
68  public function hasValue($a_value)
69  {
70  // see #35695, a non required un-checked checkbox is treated as a value
71  if (!is_null($a_value) && !$this->isRequired()) {
72  return 1;
73  }
74  return (int) $a_value;
75  }
76 
77  public function getHTML($a_value)
78  {
79  $lng = $this->lng;
80 
81  $caption = null;
82  // see #35694, a non required un-checked checkbox is treated as a "no"
83  if (!$this->isRequired()) {
84  $caption = $lng->txt("no");
85  }
86  if ($this->isRequired() && $a_value < 0) {
87  $caption = $lng->txt("no");
88  } elseif ($a_value == 1) {
89  $caption = $lng->txt("yes");
90  }
91  return $caption;
92  }
93 }
Class ilExcCriteria.
This class represents a checkbox property in a property form.
addToPeerReviewForm($a_value=null)
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
Class ilExcCriteriaBool.