|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ajax\semantic\widgets\dataform; |
|
4
|
|
|
|
|
5
|
|
|
use Ajax\semantic\widgets\base\InstanceViewer; |
|
6
|
|
|
use Ajax\service\JString; |
|
7
|
|
|
use Ajax\semantic\html\collections\form\HtmlFormInput; |
|
8
|
|
|
|
|
9
|
|
|
class FormInstanceViewer extends InstanceViewer { |
|
10
|
|
|
protected $separators; |
|
11
|
|
|
|
|
12
|
|
|
public function __construct($identifier,$instance=NULL, $captions=NULL) { |
|
13
|
|
|
parent::__construct($identifier,$instance=NULL, $captions=NULL); |
|
14
|
|
|
$this->separators=[-1]; |
|
15
|
|
|
$this->defaultValueFunction=function($name,$value,$index){ |
|
16
|
|
|
$caption=$this->getCaption($index); |
|
17
|
|
|
$input=new HtmlFormInput($this->widgetIdentifier."-".$name,$caption,"text",$value); |
|
18
|
|
|
$input->setName($name); |
|
19
|
|
|
return $input; |
|
20
|
|
|
}; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
protected function _beforeAddProperty($index,&$field){ |
|
24
|
|
|
if(JString::endswith($field, "\n")===true){ |
|
25
|
|
|
$this->addSeparatorAfter($index); |
|
26
|
|
|
} |
|
27
|
|
|
if($index>1 && JString::startswith($field, "\n")===true){ |
|
28
|
|
|
$this->addSeparatorAfter($index-1); |
|
29
|
|
|
} |
|
30
|
|
|
$field=\str_replace("\n", "", $field); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
public function addSeparatorAfter($fieldNum){ |
|
36
|
|
|
if(\array_search($fieldNum, $this->separators)===false) |
|
37
|
|
|
$this->separators[]=$fieldNum; |
|
38
|
|
|
return $this; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getSeparators() { |
|
42
|
|
|
return $this->separators; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function setSeparators($separators) { |
|
46
|
|
|
$this->separators=\array_merge([-1], $separators); |
|
47
|
|
|
return $this; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
} |