1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Modules\Forms;
13
14 use Brickrouge\Element;
15
16 class PopForm extends Element
17 {
18 public function __toString()
19 {
20 global $core;
21
22 try
23 {
24 $site = $core->site;
25 $value = (int) $this['value'];
26
27 $options = $core->models['forms']->select('nid, title')
28 ->where('nid = ? OR ((siteid = 0 OR siteid = ?) AND (language = "" OR language = ?))', $value, $site->siteid, $site->language)
29 ->order('title')
30 ->pairs;
31
32 if (!$options)
33 {
34 $url = \Brickrouge\escape($core->site->path . '/admin/forms/new');
35
36 return <<<EOT
37 <a href="$url" class="btn btn-info">Créer un premier formulaire...</a>
38 EOT;
39 }
40
41 if ($this->type == 'select')
42 {
43 $options = array(null => '') + $options;
44 }
45
46 $this[self::OPTIONS] = $options;
47 }
48 catch (\Exception $e)
49 {
50 return \Brickrouge\render_exception($e);
51 }
52
53 return parent::__toString();
54 }
55 }