forked from bgermann/cforms2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib_options_presets.php
More file actions
96 lines (89 loc) · 4.24 KB
/
lib_options_presets.php
File metadata and controls
96 lines (89 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/*
* Copyright (c) 2006-2012 Oliver Seidel (email : oliver.seidel @ deliciousdays.com)
* Copyright (c) 2014 Bastian Germann
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
$file = plugin_dir_path(__FILE__) . 'formpresets'. DIRECTORY_SEPARATOR . $_REQUEST['formpresets'];
if( is_file($file) && filesize($file) > 0)
$fields = file($file);
else {
echo '<div id="message" class="updated fade"><p><strong>'.__('Sorry, this form preset can\'t be loaded. I Can\'t find file ', 'cforms').'<br />'.$file.'</strong></p></div>';
return;
}
$i = 1;
$taf = false;
foreach( $fields as $field ){
if ( strpos($field,'~~~')===false ) continue;
$data = explode('~~~',$field);
if( $data[0]=='ff' ){
$cformsSettings['form'.$no]["cforms{$no}_count_field_{$i}"] = str_replace(array("\n","\r"),array('',''),$data[1]);
$i++;
}
else if( $data[0]=='mx' ){
$cformsSettings['form'.$no]["cforms{$no}_maxentries"] = str_replace(array("\n","\r"),array('',''),$data[1]);
}
else if( $data[0]=='su' ){
$cformsSettings['form'.$no]["cforms{$no}_submit_text"] = str_replace(array("\n","\r"),array('',''),$data[1]);
}
else if( $data[0]=='lt' ){
$cformsSettings['form'.$no]["cforms{$no}_limittxt"] = str_replace(array("\n","\r"),array('',''),$data[1]);
}
else if( $data[0]=='hd' ){
$cformsSettings['form'.$no]["cforms{$no}_hide"] = str_replace(array("\n","\r"),array('',''),$data[1]);
}
else if( $data[0]=='ri' ){
$cformsSettings['form'.$no]["cforms{$no}_required"] = str_replace(array("\n","\r"),array('',''),$data[1]);
}
else if( $data[0]=='re' ){
$cformsSettings['form'.$no]["cforms{$no}_emailrequired"] = str_replace(array("\n","\r"),array('',''),$data[1]);
}
else if( $data[0]=='tf' ){
$cformsSettings['form'.$no]["cforms{$no}_tellafriend"] = str_replace(array("\n","\r"),array('',''),$data[1]);
}
else if( $data[0]=='tt' ){
$cformsSettings['form'.$no]["cforms{$no}_cmsg"] = str_replace('|nl|',"\r\n",$data[1]) ;
$cformsSettings['form'.$no]["cforms{$no}_cmsg_html"] = str_replace('|nl|',"<br />\r\n",$data[1]) ;
$cformsSettings['form'.$no]["cforms{$no}_confirm"] = '1';
$taf = str_replace(array("\n","\r"),array('',''),$data[1]);
}
else if( $data[0]=='ts' ){
$cformsSettings['form'.$no]["cforms{$no}_csubject"] = str_replace(array("\n","\r"),array('',''),$data[1]);
}
else if( $data[0]=='cs' ){
$cformsSettings['global']['cforms_css'] = str_replace(array("\n","\r"),array('',''),$data[1]);
}
else if( $data[0]=='dp' ){
$cformsSettings['global']['cforms_datepicker'] = str_replace(array("\n","\r"),array('',''),$data[1]);
}
}
$max = $cformsSettings['form'.$no]["cforms{$no}_count_fields"];
for ( $j=$i; $j<=$max; $j++) {
$cformsSettings['form'.$no]["cforms{$no}_count_field_{$j}"] = '';
}
$cformsSettings['form'.$no]["cforms{$no}_count_fields"] = ($i-1);
?>
<div id="message" class="updated fade"><p><strong>
<?php
_e('Your form has been populated with the preset input fields.', 'cforms');
if( $taf==2 ){
echo '<br />'.sprintf(__('Please note, that in order to make this form work, the <strong>%s</strong> has been turned on, too!','cforms'),__('WP comment feature','cforms'));
echo '<br />'.__('Check with the HELP page on how to <u>properly</u> use this cforms feature and check all your settings below!','cforms');
} else if( $taf==11 ){
echo '<br />'.sprintf(__('Please note, that in order to make this form work, the <strong>%s</strong> has been turned on, too!','cforms'),__('TAF feature','cforms'));
echo '<br />'.__('Check with the HELP page on how to <u>properly</u> use this cforms feature and check all your settings below!','cforms');
}
?>
</strong></p></div>