XOOPS  2.6.0
text.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
27 {
33  public function render()
34  {
35  $form = $this->loadText() . '&nbsp;&nbsp; <input type="text" name="' . $this->config['name']
36  . '" id="' . $this->config['name'] . '" size="' . $this->config['num_chars']
37  . '" maxlength="' . $this->config['num_chars'] . '" value="" />';
39  if (!empty($this->config['maxattempts'])) {
40  $form .= '<br />' . sprintf(XoopsLocale::F_MAXIMUM_ATTEMPTS, $this->config['maxattempts']);
41  }
42  return $form;
43  }
44 
50  public function loadText()
51  {
52  $val_a = rand(0, 9);
53  $val_b = rand(0, 9);
54  if ($val_a > $val_b) {
55  $expression = "{$val_a} - {$val_b} = ?";
56  $this->code = $val_a - $val_b;
57  } else {
58  $expression = "{$val_a} + {$val_b} = ?";
59  $this->code = $val_a + $val_b;
60  }
61  return '<span style="font-style: normal; font-weight: bold; font-size: 100%; font-color: #333; border: 1px solid #333; padding: 1px 5px;">' . $expression . '</span>';
62  }
63 }
$form
Definition: xoops_code.php:21
const F_MAXIMUM_ATTEMPTS
Definition: en_US.php:420
const INPUT_RESULT_FROM_EXPRESSION
Definition: en_US.php:482