|
41 | 41 | // Hook for driver to call when generating edit form |
42 | 42 | // Add form fields to $form |
43 | 43 | public function ttf_form(&$form, &$page) { |
| 44 | + $p = new XMLElement('p', __('Wrap patterns with slashes, e.g., "/pattern_here/". You can use backreferences in replacement. Syntax for pattern and replacement is exactly the same as in <a href="http://www.php.net/manual/en/function.preg-replace.php" target="_blank">preg_replace()</a> PHP function.')); |
| 45 | + $p->setAttribute('class', 'help'); |
| 46 | + $form->appendChild($p); |
| 47 | + |
44 | 48 | $subsection = new XMLElement('div'); |
45 | | - $subsection->setAttribute('class', 'subsection'); |
| 49 | + $subsection->setAttribute('class', 'frame'); |
46 | 50 | $p = new XMLElement('p', __('Patterns and replacements')); |
47 | 51 | $p->setAttribute('class', 'label'); |
48 | 52 | $subsection->appendChild($p); |
49 | 53 |
|
50 | 54 | $ol = new XMLElement('ol'); |
51 | | - $ol->setAttribute('id', 'fields-duplicator'); |
| 55 | + $ol->setAttribute('id', 'regex-duplicator'); |
| 56 | + $ol->setAttribute('class', 'templatedtextformatter-duplicator'); |
| 57 | + $ol->setAttribute('data-add', __('Add regex')); |
| 58 | + $ol->setAttribute('data-remove', __('Remove regex')); |
52 | 59 |
|
53 | 60 | $temp = $this->_patterns; |
54 | 61 | $temp[''] = ''; |
55 | 62 | foreach ($temp as $pattern => $replacement) { |
56 | 63 | $li = new XMLElement('li'); |
57 | | - $li->setAttribute('class', ($pattern ? 'unique field-regex' : ' template field-regex')); |
58 | | - $li->appendChild(new XMLElement('h4', __('Replace'))); |
| 64 | + $li->setAttribute('class', ($pattern ? 'field-regex' : 'template field-regex')); |
| 65 | + $li->setAttribute('data-type', 'regex'); |
| 66 | + |
| 67 | + $header = new XMLElement('header', NULL, array('class' => 'main', 'data-name' => __('Replace'))); |
| 68 | + $header->appendChild(new XMLElement('h4', '<strong>' . __('Replace') . '</strong> <span class="type">' . __('regex') . '</span>')); |
| 69 | + $li->appendChild($header); |
59 | 70 |
|
60 | 71 | $div = new XMLElement('div'); |
61 | | - $div->setAttribute('class', 'group'); |
| 72 | + $div->setAttribute('class', 'two columns'); |
62 | 73 |
|
63 | | - $label = Widget::Label(__('Pattern')); |
| 74 | + $label = Widget::Label(__('Find with pattern')); |
| 75 | + $label->setAttribute('class', 'column'); |
64 | 76 | $label->appendChild(Widget::Input('fields[patterns][]', htmlentities($pattern, ENT_QUOTES, 'UTF-8'))); |
65 | 77 | $div->appendChild($label); |
66 | 78 |
|
67 | | - $label = Widget::Label(__('Replacement')); |
| 79 | + $label = Widget::Label(__('Replace with')); |
| 80 | + $label->setAttribute('class', 'column'); |
68 | 81 | $label->appendChild(Widget::Input('fields[replacements][]', htmlentities($replacement, ENT_QUOTES, 'UTF-8'))); |
69 | 82 | $div->appendChild($label); |
70 | 83 |
|
|
74 | 87 |
|
75 | 88 | $subsection->appendChild($ol); |
76 | 89 | $form->appendChild($subsection); |
77 | | - |
78 | | - $p = new XMLElement('p', __('Wrap patterns with slashes, e.g., "/pattern_here/". You can use backreferences in replacement. Syntax for pattern and replacement is exactly the same as in <a href="http://www.php.net/manual/en/function.preg-replace.php" target="_blank">preg_replace()</a> function in PHP.')); |
79 | | - $p->setAttribute('class', 'help'); |
80 | | - $form->appendChild($p); |
81 | 90 | } |
82 | 91 |
|
83 | 92 | // Hook called by TemplatedTextFormatters when generating formatter |
|
92 | 101 | $code = ''; |
93 | 102 | if (!empty($_POST['fields']['patterns']) && count($_POST['fields']['patterns']) == count($_POST['fields']['replacements'])) { |
94 | 103 | $this->_patterns = array_combine($_POST['fields']['patterns'], $_POST['fields']['replacements']); |
| 104 | + unset($this->_patterns['']); |
95 | 105 | } |
96 | 106 | } |
97 | 107 |
|
|
0 commit comments