ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCaptchaInputGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
13 {
14  protected $value;
15 
22  function __construct($a_title = "", $a_postvar = "")
23  {
24  global $lng;
25 
26  parent::__construct($a_title, $a_postvar);
27  $this->setType("captcha");
28  $lng->loadLanguageModule("cptch");
29  }
30 
36  function setValue($a_value)
37  {
38  $this->value = $a_value;
39  }
40 
46  function getValue()
47  {
48  return $this->value;
49  }
50 
56  function checkInput()
57  {
58  global $lng;
59 
61  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
62  {
63  $this->setAlert($lng->txt("msg_input_is_required"));
64 
65  return false;
66  }
67 
68  include_once("./Services/Captcha/classes/class.ilSecurImage.php");
69  $si = new ilSecurImage();
70  if (!$si->check($_POST[$this->getPostVar()]))
71  {
72  $this->setAlert($lng->txt("cptch_wrong_input"));
73 
74  return false;
75  }
76 
77  return true;
78  }
79 
83  function render()
84  {
85  global $lng;
86 
87  $tpl = new ilTemplate("tpl.prop_captchainput.html", true, true, "Services/Captcha");
88  if (strlen($this->getValue()))
89  {
90  $tpl->setCurrentBlock("prop_text_propval");
91  $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
92  $tpl->parseCurrentBlock();
93  }
94 
95  include_once("./Services/Captcha/classes/class.ilSecurImageUtil.php");
96  $tpl->setVariable("IMAGE_SCRIPT",
98 
99  $tpl->setVariable("POST_VAR", $this->getPostVar());
100  $tpl->setVariable("TXT_CONSTR_PROP", $lng->txt("cont_constrain_proportions"));
101 
102 // $GLOBALS["tpl"]->addJavascript("./Services/MediaObjects/js/ServiceMediaObjectPropWidthHeight.js");
103 
104  return $tpl->get();
105  }
106 
110  function insert(&$a_tpl)
111  {
112  $html = $this->render();
113 
114  $a_tpl->setCurrentBlock("prop_generic");
115  $a_tpl->setVariable("PROP_GENERIC", $html);
116  $a_tpl->parseCurrentBlock();
117  }
118 
124  function setValueByArray($a_values)
125  {
126  global $ilUser;
127 
128  $this->setValue($a_values[$this->getPostVar()]);
129  }
130 
131 }