Version Description
- Submit build form in one input with ajax to prevent max_input_vars limitations
- Load fields on the build page with ajax for long forms and other form builder page optimization
- Added submit button to customizable HTML
- Added clickable styling classes to form builder sidebar
- Create entry key from first required text field
- Set the default name of a field to the field type instead of "Untitled"
- Added minified version of formidable.js
- Added warning message if a non-unique value is added as a field value
- Removed messages for strict standards
- Fixed inline and left labels for checkboxes
- PRO: Added back button on multi-paged forms
- PRO: Added conditional logic on page breaks for skipping pages
- PRO: Added loading indicator by submit button and on dependent data from entries fields
- PRO: Switched out username and passwords for license numbers
- PRO: Updated timestamp in CSV to adjust for WordPress timezone selection
- PRO: Updated value in CSV for file upload fields
- PRO: Include comments in the CSV export
- PRO: Made dynamic default values clickable on form builder page
- PRO: Added column in CSV for value for fields that are set to use separate values
- PRO: Allow for quotation marks in field labels for the CSV export
- PRO: Added frm_import_val hook for CSV importing
- PRO: Removed border styling from the container around radio and checkbox fields
- PRO: Added frm_order_display hook
- PRO: Added utf8 support to sanitize_url=1 option
- PRO: Added "confirm" option to frm-entry-links shortocode that is used before an entry is deleted
- PRO: Copy conditional logic and field calculations into duplicated forms
- PRO: Allow clickable=1 and images to be used with Google formresults shortcode
- PRO: Allow [25 show="user_email"] for data from entries fields to get user info from the user ID from the linked form, and [25 show="30" show_info="user_email"] to get values from a field linked through 2 data from entries fields
- PRO: Allow tags fields to be used with hierarchal taxonomies
- PRO: No longer require fields in a conditionally hidden section heading
- PRO: Added option for frmThemeOverride_frmAfterSubmit function for custom javascript after ajax submit
- PRO: Updated star rating javascript version
- PRO: Check field key when creating a form from a template to see if the trailing "2" can be removed
- PRO: Don't show custom display content for password protected posts until allowed
- PRO: Switch the cancel link to edit link after a form is submitted with in-place-edit and ajax
- PRO: Switched front-end ajax to use hooks (frm_ajax_{controller}_{action})
- PRO: Call ajax later on the init hook to prevent php notices when WooCommerce is active
- PRO: Delete entries on the same page as the frm-entry-links shortcode, and added a confirmation message: confirm="Are you sure?"
- PRO: Correctly check if jQuery on() function exists
- PRO: Fixed calendar display for months starting on Sunday when the week start day is set to Monday
- PRO: Removed "custom display" from the post type options on the "create posts" settings tab
- PRO: Allow multiple values to be imported into an entry via csv in a multi-select dropdown field
Download this release
Release Info
Developer | sswells |
Plugin | Formidable Forms – Form Builder for WordPress |
Version | 1.07.0 |
Comparing to | |
See all releases |
Code changes from version 1.06.11 to 1.07.0
- classes/controllers/FrmAppController.php +79 -80
- classes/controllers/FrmEntriesController.php +25 -25
- classes/controllers/FrmFieldsController.php +76 -49
- classes/controllers/FrmFormsController.php +134 -108
- classes/controllers/FrmSettingsController.php +13 -10
- classes/controllers/FrmStatisticsController.php +6 -6
- classes/controllers/FrmUpdatesController.php +538 -0
- classes/helpers/FrmAppHelper.php +111 -60
- classes/helpers/FrmEntriesHelper.php +9 -6
- classes/helpers/FrmFieldsHelper.php +72 -40
- classes/helpers/FrmFormsHelper.php +75 -26
- classes/helpers/FrmListHelper.php +2 -2
- classes/models/FrmDb.php +7 -3
- classes/models/FrmEntry.php +16 -10
- classes/models/FrmEntryMeta.php +8 -8
- classes/models/FrmField.php +69 -23
- classes/models/FrmForm.php +14 -6
- classes/models/FrmNotification.php +2 -2
- classes/models/FrmUpdate.php +4 -3
- classes/templates/contact.php +3 -3
- classes/views/frm-entries/form.php +4 -0
- classes/views/frm-entries/new.php +0 -7
- classes/views/frm-fields/input.php +4 -3
- classes/views/frm-fields/radio.php +1 -1
- classes/views/frm-forms/add_field.php +19 -9
- classes/views/frm-forms/add_field_links.php +78 -10
- classes/views/frm-forms/edit.php +6 -4
- classes/views/frm-forms/footer.php +9 -5
- classes/views/frm-forms/form.php +3 -0
- classes/views/frm-forms/mb_html_tab.php +9 -0
- classes/views/frm-forms/mb_insert_fields.php +2 -2
- classes/views/frm-forms/new-field-js.php +0 -14
- classes/views/frm-forms/new-option-js.php +0 -7
- classes/views/frm-forms/new.php +6 -3
- classes/views/frm-forms/notification.php +14 -3
- classes/views/frm-forms/settings.php +16 -4
- classes/views/frm-settings/form.php +4 -2
- css/frm_admin.css +48 -24
- css/frm_display.css +9 -6
- formidable.php +39 -50
- js/formidable.js +84 -28
- js/formidable.min.js +33 -0
- js/formidable_admin.js +194 -59
- js/jquery/jquery.editinplace.js +649 -284
- js/jquery/jquery.editinplace.packed.js +21 -24
- js/jquery/jquery.elastic.js +0 -1
- languages/formidable-de_DE.mo +0 -0
- languages/formidable-de_DE.po +1267 -906
- languages/formidable-en_US.po +1267 -906
- languages/formidable-nl_NL.mo +0 -0
- languages/formidable-nl_NL.po +1267 -906
- languages/formidable-pl_PL.mo +0 -0
- languages/formidable-pl_PL.po +1267 -906
- languages/formidable-pt_BR.mo +0 -0
- languages/formidable-pt_BR.po +370 -418
classes/controllers/FrmAppController.php
CHANGED
@@ -5,34 +5,34 @@
|
|
5 |
|
6 |
class FrmAppController{
|
7 |
function FrmAppController(){
|
8 |
-
add_action('admin_menu',
|
9 |
-
add_action('admin_head',
|
10 |
-
add_filter('plugin_action_links_formidable/formidable.php',
|
11 |
-
add_action('after_plugin_row_formidable/formidable.php',
|
12 |
-
add_action('admin_notices',
|
13 |
-
add_filter('the_content',
|
14 |
-
add_action('init',
|
15 |
-
add_action('wp_footer',
|
16 |
-
add_action('admin_init',
|
17 |
-
register_activation_hook(FRM_PATH.'/formidable.php',
|
18 |
-
add_action('wp_ajax_frm_install',
|
19 |
-
add_action('wp_ajax_frm_uninstall',
|
20 |
-
add_action('wp_ajax_frm_deauthorize',
|
21 |
|
22 |
// Used to process standalone requests
|
23 |
-
add_action('init',
|
24 |
// Update the session data
|
25 |
-
add_action('init',
|
26 |
|
27 |
//Shortcodes
|
28 |
-
add_shortcode('formidable',
|
29 |
-
add_filter( 'widget_text',
|
30 |
}
|
31 |
|
32 |
-
function menu(){
|
33 |
global $frmpro_is_installed, $frm_settings;
|
34 |
|
35 |
-
if(
|
36 |
global $current_user;
|
37 |
$frm_roles = FrmAppHelper::frm_capabilities();
|
38 |
foreach($frm_roles as $frm_role => $frm_role_description)
|
@@ -47,22 +47,20 @@ class FrmAppController{
|
|
47 |
$pos = apply_filters('frm_menu_position', $pos);
|
48 |
|
49 |
if(current_user_can('frm_view_forms')){
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
global $frmpro_entries_controller;
|
54 |
-
add_menu_page('Formidable', $frm_settings->menu, 'frm_view_entries', 'formidable', array($frmpro_entries_controller, 'route'), 'div', $pos);
|
55 |
}
|
56 |
}
|
57 |
|
58 |
-
function menu_css(){ ?>
|
59 |
<style type="text/css">#adminmenu .toplevel_page_formidable div.wp-menu-image{background: url(<?php echo FRM_IMAGES_URL ?>/form_16.png) no-repeat center;}.menu-icon-frmdisplay .wp-menu-image img{display:none;}
|
60 |
</style>
|
61 |
<?php
|
62 |
//#adminmenu .toplevel_page_formidable:hover div.wp-menu-image{background: url(<?php echo FRM_IMAGES_URL /icon_16.png) no-repeat center;}
|
63 |
}
|
64 |
|
65 |
-
function get_form_nav($id, $show_nav=false){
|
66 |
global $pagenow;
|
67 |
|
68 |
$show_nav = FrmAppHelper::get_param('show_nav', $show_nav);
|
@@ -72,16 +70,15 @@ class FrmAppController{
|
|
72 |
}
|
73 |
|
74 |
// Adds a settings link to the plugins page
|
75 |
-
function settings_link($links, $file){
|
76 |
-
$settings = '<a href="'.admin_url('admin.php?page=formidable').'">' . __('Settings', 'formidable') . '</a>';
|
77 |
array_unshift($links, $settings);
|
78 |
|
79 |
return $links;
|
80 |
}
|
81 |
|
82 |
-
function pro_action_needed( $plugin ){
|
83 |
-
|
84 |
-
|
85 |
if( $frm_update->pro_is_authorized() and !$frm_update->pro_is_installed() ){
|
86 |
if (IS_WPMU and $frm_update->pro_wpmu and !FrmAppHelper::is_super_admin())
|
87 |
return;
|
@@ -93,27 +90,27 @@ class FrmAppController{
|
|
93 |
}
|
94 |
}
|
95 |
|
96 |
-
function pro_get_started_headline(){
|
97 |
-
|
98 |
|
99 |
// Don't display this error as we're upgrading the thing... cmon
|
100 |
if(isset($_GET['action']) and $_GET['action'] == 'upgrade-plugin')
|
101 |
return;
|
102 |
|
103 |
-
if (IS_WPMU and !
|
104 |
return;
|
105 |
|
106 |
if(!isset($_GET['activate'])){
|
107 |
-
global $frmpro_is_installed, $frm_db_version
|
108 |
$db_version = get_option('frm_db_version');
|
109 |
$pro_db_version = ($frmpro_is_installed) ? get_option('frmpro_db_version') : false;
|
110 |
-
if(((int)$db_version < (int)$frm_db_version) or ($frmpro_is_installed and (int)$pro_db_version <
|
111 |
?>
|
112 |
<div class="error" id="frm_install_message" style="padding:7px;"><?php _e('Your Formidable database needs to be updated.<br/>Please deactivate and reactivate the plugin to fix this or', 'formidable'); ?> <a id="frm_install_link" href="#" onclick="frm_install_now();return false;"><?php _e('Update Now', 'formidable') ?></a></div>
|
113 |
<script type="text/javascript">
|
114 |
function frm_install_now(){
|
115 |
jQuery('#frm_install_link').replaceWith('<img src="<?php echo FRM_IMAGES_URL; ?>/wpspin_light.gif" alt="<?php _e('Loading...', 'formidable'); ?>" />');
|
116 |
-
jQuery.ajax({type:"POST",url:"<?php echo
|
117 |
success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
|
118 |
});
|
119 |
};
|
@@ -131,13 +128,14 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
|
|
131 |
}
|
132 |
}
|
133 |
|
134 |
-
function admin_js(){
|
135 |
global $frm_version, $pagenow;
|
136 |
wp_enqueue_script('jquery');
|
137 |
wp_enqueue_script('jquery-ui-core');
|
138 |
|
139 |
if(isset($_GET) and (isset($_GET['page']) and preg_match('/formidable*/', $_GET['page'])) or ($pagenow == 'edit.php' and isset($_GET) and isset($_GET['post_type']) and $_GET['post_type'] == 'frm_display')){
|
140 |
-
add_filter('admin_body_class',
|
|
|
141 |
wp_enqueue_script('jquery-ui-sortable');
|
142 |
wp_enqueue_script('jquery-ui-draggable');
|
143 |
wp_enqueue_script('admin-widgets');
|
@@ -145,7 +143,6 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
|
|
145 |
wp_enqueue_script('formidable_admin', FRM_URL . '/js/formidable_admin.js', array('jquery', 'jquery-ui-draggable'), $frm_version);
|
146 |
wp_enqueue_script('formidable');
|
147 |
wp_enqueue_style('formidable-admin', FRM_URL. '/css/frm_admin.css', array(), $frm_version);
|
148 |
-
wp_enqueue_script('jquery-elastic', FRM_URL.'/js/jquery/jquery.elastic.js', array('jquery'));
|
149 |
add_thickbox();
|
150 |
}else if($pagenow == 'post.php' or ($pagenow == 'post-new.php' and isset($_REQUEST['post_type']) and $_REQUEST['post_type'] == 'frm_display')){
|
151 |
if(isset($_REQUEST['post_type'])){
|
@@ -162,13 +159,12 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
|
|
162 |
if($post_type == 'frm_display'){
|
163 |
wp_enqueue_script('jquery-ui-draggable');
|
164 |
wp_enqueue_script('formidable_admin', FRM_URL . '/js/formidable_admin.js', array('jquery', 'jquery-ui-draggable'), $frm_version);
|
165 |
-
wp_enqueue_script('jquery-elastic', FRM_URL.'/js/jquery/jquery.elastic.js', array('jquery'));
|
166 |
wp_enqueue_style('formidable-admin', FRM_URL. '/css/frm_admin.css', array(), $frm_version);
|
167 |
}
|
168 |
}
|
169 |
}
|
170 |
|
171 |
-
function admin_body_class($classes){
|
172 |
global $wp_version;
|
173 |
if(version_compare( $wp_version, '3.4.9', '>'))
|
174 |
$classes .= ' frm_35_trigger';
|
@@ -176,7 +172,7 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
|
|
176 |
return $classes;
|
177 |
}
|
178 |
|
179 |
-
function front_head(){
|
180 |
global $frm_settings, $frm_version, $frm_db_version;
|
181 |
|
182 |
if (IS_WPMU){
|
@@ -184,14 +180,24 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
|
|
184 |
//$frm_db_version is the version of the database we're moving to
|
185 |
$old_db_version = get_option('frm_db_version');
|
186 |
$pro_db_version = ($frmpro_is_installed) ? get_option('frmpro_db_version') : false;
|
187 |
-
if(((int)$old_db_version < (int)$frm_db_version) or ($frmpro_is_installed and (int)$pro_db_version <
|
188 |
-
|
189 |
}
|
190 |
|
191 |
-
wp_register_script('formidable', FRM_URL . '/js/formidable.js', array('jquery'), $frm_version, true);
|
192 |
wp_register_script('recaptcha-ajax', 'http'. (is_ssl() ? 's' : '').'://www.google.com/recaptcha/api/js/recaptcha_ajax.js', '', true);
|
193 |
wp_enqueue_script('jquery');
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
if(!is_admin() and $frm_settings->load_style == 'all'){
|
196 |
$css = apply_filters('get_frm_stylesheet', FRM_URL .'/css/frm_display.css', 'header');
|
197 |
if(is_array($css)){
|
@@ -208,7 +214,7 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
|
|
208 |
}
|
209 |
}
|
210 |
|
211 |
-
function footer_js($location='footer'){
|
212 |
global $frm_load_css, $frm_settings, $frm_version, $frm_css_loaded, $frm_forms_loaded;
|
213 |
|
214 |
if($frm_load_css and !is_admin() and ($frm_settings->load_style != 'none')){
|
@@ -240,13 +246,13 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
|
|
240 |
FrmAppHelper::load_scripts(array('formidable'));
|
241 |
}
|
242 |
|
243 |
-
function install($old_db_version=false){
|
244 |
global $frmdb;
|
245 |
$frmdb->upgrade($old_db_version);
|
246 |
}
|
247 |
|
248 |
-
function uninstall(){
|
249 |
-
if(
|
250 |
global $frmdb;
|
251 |
$frmdb->uninstall();
|
252 |
return true;
|
@@ -257,24 +263,25 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
|
|
257 |
}
|
258 |
}
|
259 |
|
260 |
-
function deauthorize(){
|
261 |
delete_option('frmpro-credentials');
|
262 |
delete_option('frmpro-authorized');
|
|
|
|
|
263 |
}
|
264 |
|
265 |
// Routes for wordpress pages -- we're just replacing content here folks.
|
266 |
-
function page_route($content){
|
267 |
global $post, $frm_settings;
|
268 |
|
269 |
if( $post && $post->ID == $frm_settings->preview_page_id && isset($_GET['form'])){
|
270 |
-
|
271 |
-
$content = $frm_forms_controller->page_preview();
|
272 |
}
|
273 |
|
274 |
return $content;
|
275 |
}
|
276 |
|
277 |
-
function referer_session() {
|
278 |
global $frm_siteurl, $frm_settings;
|
279 |
|
280 |
if(!isset($frm_settings->track) or !$frm_settings->track or defined('WP_IMPORTING'))
|
@@ -314,38 +321,31 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
|
|
314 |
}
|
315 |
|
316 |
// The tight way to process standalone requests dogg...
|
317 |
-
function parse_standalone_request(){
|
318 |
-
$plugin =
|
319 |
$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
|
320 |
-
$action =
|
321 |
-
$controller =
|
322 |
|
323 |
if( !empty($plugin) and $plugin == 'formidable' and !empty($controller) ){
|
324 |
-
|
325 |
-
|
326 |
}
|
327 |
}
|
328 |
|
329 |
// Routes for standalone / ajax requests
|
330 |
-
function standalone_route($controller, $action=''){
|
331 |
-
global $frm_forms_controller, $frm_fields_controller;
|
332 |
-
|
333 |
if($controller == 'forms' and !in_array($action, array('export', 'import', 'xml')))
|
334 |
-
|
335 |
-
else if($controller == 'fields' and $action == 'import_choices')
|
336 |
-
$frm_fields_controller->import_choices($this->get_param('field_id'));
|
337 |
else
|
338 |
do_action('frm_standalone_route', $controller, $action);
|
339 |
-
|
340 |
-
|
341 |
-
// Utility function to grab the parameter whether it's a get or post
|
342 |
-
function get_param($param, $default=''){
|
343 |
-
return (isset($_POST[$param]) ? $_POST[$param] : (isset($_GET[$param])?$_GET[$param]:$default));
|
344 |
}
|
345 |
|
346 |
|
347 |
//formidable shortcode
|
348 |
-
function get_form_shortcode($atts){
|
349 |
global $frm_skip_shortcode;
|
350 |
if($frm_skip_shortcode){
|
351 |
$sc = '[formidable';
|
@@ -354,28 +354,27 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
|
|
354 |
return $sc .']';
|
355 |
}
|
356 |
|
357 |
-
global $frm_entries_controller;
|
358 |
extract(shortcode_atts(array('id' => '', 'key' => '', 'title' => false, 'description' => false, 'readonly' => false, 'entry_id' => false, 'fields' => array()), $atts));
|
359 |
do_action('formidable_shortcode_atts', compact('id', 'key', 'title', 'description', 'readonly', 'entry_id', 'fields'));
|
360 |
-
return
|
361 |
}
|
362 |
|
363 |
//filter form shortcode in text widgets
|
364 |
-
function widget_text_filter( $content ){
|
365 |
$regex = '/\[\s*formidable\s+.*\]/';
|
366 |
-
return preg_replace_callback( $regex,
|
367 |
}
|
368 |
|
369 |
|
370 |
-
function widget_text_filter_callback( $matches ) {
|
371 |
return do_shortcode( $matches[0] );
|
372 |
}
|
373 |
|
374 |
-
function update_message($features){
|
375 |
include(FRM_VIEWS_PATH .'/shared/update_message.php');
|
376 |
}
|
377 |
|
378 |
-
function get_postbox_class(){
|
379 |
if(version_compare( $GLOBALS['wp_version'], '3.3.2', '>'))
|
380 |
return 'postbox-container';
|
381 |
else
|
5 |
|
6 |
class FrmAppController{
|
7 |
function FrmAppController(){
|
8 |
+
add_action('admin_menu', 'FrmAppController::menu', 1);
|
9 |
+
add_action('admin_head', 'FrmAppController::menu_css');
|
10 |
+
add_filter('plugin_action_links_formidable/formidable.php', 'FrmAppController::settings_link', 10, 2 );
|
11 |
+
add_action('after_plugin_row_formidable/formidable.php', 'FrmAppController::pro_action_needed');
|
12 |
+
add_action('admin_notices', 'FrmAppController::pro_get_started_headline');
|
13 |
+
add_filter('the_content', 'FrmAppController::page_route', 10);
|
14 |
+
add_action('init', 'FrmAppController::front_head');
|
15 |
+
add_action('wp_footer', 'FrmAppController::footer_js', 1, 0);
|
16 |
+
add_action('admin_init', 'FrmAppController::admin_js', 11);
|
17 |
+
register_activation_hook(FRM_PATH.'/formidable.php', 'FrmAppController::install');
|
18 |
+
add_action('wp_ajax_frm_install', 'FrmAppController::install');
|
19 |
+
add_action('wp_ajax_frm_uninstall', 'FrmAppController::uninstall');
|
20 |
+
add_action('wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize');
|
21 |
|
22 |
// Used to process standalone requests
|
23 |
+
add_action('init', 'FrmAppController::parse_standalone_request', 40);
|
24 |
// Update the session data
|
25 |
+
add_action('init', 'FrmAppController::referer_session', 1);
|
26 |
|
27 |
//Shortcodes
|
28 |
+
add_shortcode('formidable', 'FrmAppController::get_form_shortcode');
|
29 |
+
add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 9 );
|
30 |
}
|
31 |
|
32 |
+
public static function menu(){
|
33 |
global $frmpro_is_installed, $frm_settings;
|
34 |
|
35 |
+
if(is_super_admin() and !current_user_can('frm_view_forms')){
|
36 |
global $current_user;
|
37 |
$frm_roles = FrmAppHelper::frm_capabilities();
|
38 |
foreach($frm_roles as $frm_role => $frm_role_description)
|
47 |
$pos = apply_filters('frm_menu_position', $pos);
|
48 |
|
49 |
if(current_user_can('frm_view_forms')){
|
50 |
+
add_menu_page('Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', 'div', $pos);
|
51 |
+
}else if(current_user_can('frm_view_entries') and $frmpro_is_installed){
|
52 |
+
add_menu_page('Formidable', $frm_settings->menu, 'frm_view_entries', 'formidable', 'FrmProEntriesController::route', 'div', $pos);
|
|
|
|
|
53 |
}
|
54 |
}
|
55 |
|
56 |
+
public static function menu_css(){ ?>
|
57 |
<style type="text/css">#adminmenu .toplevel_page_formidable div.wp-menu-image{background: url(<?php echo FRM_IMAGES_URL ?>/form_16.png) no-repeat center;}.menu-icon-frmdisplay .wp-menu-image img{display:none;}
|
58 |
</style>
|
59 |
<?php
|
60 |
//#adminmenu .toplevel_page_formidable:hover div.wp-menu-image{background: url(<?php echo FRM_IMAGES_URL /icon_16.png) no-repeat center;}
|
61 |
}
|
62 |
|
63 |
+
public static function get_form_nav($id, $show_nav=false){
|
64 |
global $pagenow;
|
65 |
|
66 |
$show_nav = FrmAppHelper::get_param('show_nav', $show_nav);
|
70 |
}
|
71 |
|
72 |
// Adds a settings link to the plugins page
|
73 |
+
public static function settings_link($links, $file){
|
74 |
+
$settings = '<a href="'. admin_url('admin.php?page=formidable-settings') .'">' . __('Settings', 'formidable') . '</a>';
|
75 |
array_unshift($links, $settings);
|
76 |
|
77 |
return $links;
|
78 |
}
|
79 |
|
80 |
+
public static function pro_action_needed( $plugin ){
|
81 |
+
$frm_update = new FrmUpdatesController();
|
|
|
82 |
if( $frm_update->pro_is_authorized() and !$frm_update->pro_is_installed() ){
|
83 |
if (IS_WPMU and $frm_update->pro_wpmu and !FrmAppHelper::is_super_admin())
|
84 |
return;
|
90 |
}
|
91 |
}
|
92 |
|
93 |
+
public static function pro_get_started_headline(){
|
94 |
+
$frm_update = new FrmUpdatesController();
|
95 |
|
96 |
// Don't display this error as we're upgrading the thing... cmon
|
97 |
if(isset($_GET['action']) and $_GET['action'] == 'upgrade-plugin')
|
98 |
return;
|
99 |
|
100 |
+
if (IS_WPMU and !is_super_admin())
|
101 |
return;
|
102 |
|
103 |
if(!isset($_GET['activate'])){
|
104 |
+
global $frmpro_is_installed, $frm_db_version;
|
105 |
$db_version = get_option('frm_db_version');
|
106 |
$pro_db_version = ($frmpro_is_installed) ? get_option('frmpro_db_version') : false;
|
107 |
+
if(((int)$db_version < (int)$frm_db_version) or ($frmpro_is_installed and (int)$pro_db_version < 21)){ //this number should match the db_version in FrmDb.php
|
108 |
?>
|
109 |
<div class="error" id="frm_install_message" style="padding:7px;"><?php _e('Your Formidable database needs to be updated.<br/>Please deactivate and reactivate the plugin to fix this or', 'formidable'); ?> <a id="frm_install_link" href="#" onclick="frm_install_now();return false;"><?php _e('Update Now', 'formidable') ?></a></div>
|
110 |
<script type="text/javascript">
|
111 |
function frm_install_now(){
|
112 |
jQuery('#frm_install_link').replaceWith('<img src="<?php echo FRM_IMAGES_URL; ?>/wpspin_light.gif" alt="<?php _e('Loading...', 'formidable'); ?>" />');
|
113 |
+
jQuery.ajax({type:"POST",url:"<?php echo admin_url('admin-ajax.php') ?>",data:"action=frm_install",
|
114 |
success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
|
115 |
});
|
116 |
};
|
128 |
}
|
129 |
}
|
130 |
|
131 |
+
public static function admin_js(){
|
132 |
global $frm_version, $pagenow;
|
133 |
wp_enqueue_script('jquery');
|
134 |
wp_enqueue_script('jquery-ui-core');
|
135 |
|
136 |
if(isset($_GET) and (isset($_GET['page']) and preg_match('/formidable*/', $_GET['page'])) or ($pagenow == 'edit.php' and isset($_GET) and isset($_GET['post_type']) and $_GET['post_type'] == 'frm_display')){
|
137 |
+
add_filter('admin_body_class', 'FrmAppController::admin_body_class');
|
138 |
+
|
139 |
wp_enqueue_script('jquery-ui-sortable');
|
140 |
wp_enqueue_script('jquery-ui-draggable');
|
141 |
wp_enqueue_script('admin-widgets');
|
143 |
wp_enqueue_script('formidable_admin', FRM_URL . '/js/formidable_admin.js', array('jquery', 'jquery-ui-draggable'), $frm_version);
|
144 |
wp_enqueue_script('formidable');
|
145 |
wp_enqueue_style('formidable-admin', FRM_URL. '/css/frm_admin.css', array(), $frm_version);
|
|
|
146 |
add_thickbox();
|
147 |
}else if($pagenow == 'post.php' or ($pagenow == 'post-new.php' and isset($_REQUEST['post_type']) and $_REQUEST['post_type'] == 'frm_display')){
|
148 |
if(isset($_REQUEST['post_type'])){
|
159 |
if($post_type == 'frm_display'){
|
160 |
wp_enqueue_script('jquery-ui-draggable');
|
161 |
wp_enqueue_script('formidable_admin', FRM_URL . '/js/formidable_admin.js', array('jquery', 'jquery-ui-draggable'), $frm_version);
|
|
|
162 |
wp_enqueue_style('formidable-admin', FRM_URL. '/css/frm_admin.css', array(), $frm_version);
|
163 |
}
|
164 |
}
|
165 |
}
|
166 |
|
167 |
+
public static function admin_body_class($classes){
|
168 |
global $wp_version;
|
169 |
if(version_compare( $wp_version, '3.4.9', '>'))
|
170 |
$classes .= ' frm_35_trigger';
|
172 |
return $classes;
|
173 |
}
|
174 |
|
175 |
+
public static function front_head(){
|
176 |
global $frm_settings, $frm_version, $frm_db_version;
|
177 |
|
178 |
if (IS_WPMU){
|
180 |
//$frm_db_version is the version of the database we're moving to
|
181 |
$old_db_version = get_option('frm_db_version');
|
182 |
$pro_db_version = ($frmpro_is_installed) ? get_option('frmpro_db_version') : false;
|
183 |
+
if(((int)$old_db_version < (int)$frm_db_version) or ($frmpro_is_installed and (int)$pro_db_version < 21))
|
184 |
+
self::install($old_db_version);
|
185 |
}
|
186 |
|
187 |
+
wp_register_script('formidable', FRM_URL . '/js/formidable.min.js', array('jquery'), $frm_version, true);
|
188 |
wp_register_script('recaptcha-ajax', 'http'. (is_ssl() ? 's' : '').'://www.google.com/recaptcha/api/js/recaptcha_ajax.js', '', true);
|
189 |
wp_enqueue_script('jquery');
|
190 |
|
191 |
+
$style = apply_filters('get_frm_stylesheet', FRM_URL .'/css/frm_display.css');
|
192 |
+
if($style){
|
193 |
+
foreach((array)$style as $k => $file){
|
194 |
+
$k = $k ? 'frm-forms'. $k : 'formidable';
|
195 |
+
wp_register_style($k, $file, array(), $frm_version);
|
196 |
+
unset($k);
|
197 |
+
unset($file);
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
if(!is_admin() and $frm_settings->load_style == 'all'){
|
202 |
$css = apply_filters('get_frm_stylesheet', FRM_URL .'/css/frm_display.css', 'header');
|
203 |
if(is_array($css)){
|
214 |
}
|
215 |
}
|
216 |
|
217 |
+
public static function footer_js($location='footer'){
|
218 |
global $frm_load_css, $frm_settings, $frm_version, $frm_css_loaded, $frm_forms_loaded;
|
219 |
|
220 |
if($frm_load_css and !is_admin() and ($frm_settings->load_style != 'none')){
|
246 |
FrmAppHelper::load_scripts(array('formidable'));
|
247 |
}
|
248 |
|
249 |
+
public static function install($old_db_version=false){
|
250 |
global $frmdb;
|
251 |
$frmdb->upgrade($old_db_version);
|
252 |
}
|
253 |
|
254 |
+
public static function uninstall(){
|
255 |
+
if(is_super_admin()){
|
256 |
global $frmdb;
|
257 |
$frmdb->uninstall();
|
258 |
return true;
|
263 |
}
|
264 |
}
|
265 |
|
266 |
+
public static function deauthorize(){
|
267 |
delete_option('frmpro-credentials');
|
268 |
delete_option('frmpro-authorized');
|
269 |
+
delete_site_option('frmpro-credentials');
|
270 |
+
delete_site_option('frmpro-authorized');
|
271 |
}
|
272 |
|
273 |
// Routes for wordpress pages -- we're just replacing content here folks.
|
274 |
+
public static function page_route($content){
|
275 |
global $post, $frm_settings;
|
276 |
|
277 |
if( $post && $post->ID == $frm_settings->preview_page_id && isset($_GET['form'])){
|
278 |
+
$content = FrmFormsController::page_preview();
|
|
|
279 |
}
|
280 |
|
281 |
return $content;
|
282 |
}
|
283 |
|
284 |
+
public static function referer_session() {
|
285 |
global $frm_siteurl, $frm_settings;
|
286 |
|
287 |
if(!isset($frm_settings->track) or !$frm_settings->track or defined('WP_IMPORTING'))
|
321 |
}
|
322 |
|
323 |
// The tight way to process standalone requests dogg...
|
324 |
+
public static function parse_standalone_request(){
|
325 |
+
$plugin = FrmAppHelper::get_param('plugin');
|
326 |
$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
|
327 |
+
$action = FrmAppHelper::get_param($action);
|
328 |
+
$controller = FrmAppHelper::get_param('controller');
|
329 |
|
330 |
if( !empty($plugin) and $plugin == 'formidable' and !empty($controller) ){
|
331 |
+
self::standalone_route($controller, $action);
|
332 |
+
die();
|
333 |
}
|
334 |
}
|
335 |
|
336 |
// Routes for standalone / ajax requests
|
337 |
+
public static function standalone_route($controller, $action=''){
|
|
|
|
|
338 |
if($controller == 'forms' and !in_array($action, array('export', 'import', 'xml')))
|
339 |
+
FrmFormsController::preview(FrmAppHelper::get_param('form'));
|
|
|
|
|
340 |
else
|
341 |
do_action('frm_standalone_route', $controller, $action);
|
342 |
+
|
343 |
+
do_action('frm_ajax_'. $controller .'_'. $action);
|
|
|
|
|
|
|
344 |
}
|
345 |
|
346 |
|
347 |
//formidable shortcode
|
348 |
+
public static function get_form_shortcode($atts){
|
349 |
global $frm_skip_shortcode;
|
350 |
if($frm_skip_shortcode){
|
351 |
$sc = '[formidable';
|
354 |
return $sc .']';
|
355 |
}
|
356 |
|
|
|
357 |
extract(shortcode_atts(array('id' => '', 'key' => '', 'title' => false, 'description' => false, 'readonly' => false, 'entry_id' => false, 'fields' => array()), $atts));
|
358 |
do_action('formidable_shortcode_atts', compact('id', 'key', 'title', 'description', 'readonly', 'entry_id', 'fields'));
|
359 |
+
return FrmEntriesController::show_form($id, $key, $title, $description);
|
360 |
}
|
361 |
|
362 |
//filter form shortcode in text widgets
|
363 |
+
public static function widget_text_filter( $content ){
|
364 |
$regex = '/\[\s*formidable\s+.*\]/';
|
365 |
+
return preg_replace_callback( $regex, 'FrmAppController::widget_text_filter_callback', $content );
|
366 |
}
|
367 |
|
368 |
|
369 |
+
public static function widget_text_filter_callback( $matches ) {
|
370 |
return do_shortcode( $matches[0] );
|
371 |
}
|
372 |
|
373 |
+
public static function update_message($features){
|
374 |
include(FRM_VIEWS_PATH .'/shared/update_message.php');
|
375 |
}
|
376 |
|
377 |
+
public static function get_postbox_class(){
|
378 |
if(version_compare( $GLOBALS['wp_version'], '3.3.2', '>'))
|
379 |
return 'postbox-container';
|
380 |
else
|
classes/controllers/FrmEntriesController.php
CHANGED
@@ -6,23 +6,23 @@
|
|
6 |
class FrmEntriesController{
|
7 |
|
8 |
function FrmEntriesController(){
|
9 |
-
add_action('admin_menu',
|
10 |
-
add_action('wp',
|
11 |
-
add_action('frm_wp',
|
12 |
-
add_filter('frm_redirect_msg',
|
13 |
-
add_filter('frm_redirect_url',
|
14 |
-
add_action('frm_after_entry_processed',
|
15 |
-
add_filter('frm_email_value',
|
16 |
}
|
17 |
|
18 |
-
function menu(){
|
19 |
global $frmpro_is_installed;
|
20 |
if(!$frmpro_is_installed){
|
21 |
-
add_submenu_page('formidable', 'Formidable |'. __('Entries', 'formidable'), '<span style="opacity:.5;filter:alpha(opacity=50);">'. __('Entries', 'formidable') .'</span>', 'administrator', 'formidable-entries',
|
22 |
}
|
23 |
}
|
24 |
|
25 |
-
function list_entries(){
|
26 |
global $frm_form, $frm_entry;
|
27 |
$form_select = $frm_form->getAll("is_template=0 AND (status is NULL OR status = '' OR status = 'published')", ' ORDER BY name');
|
28 |
$form_id = FrmAppHelper::get_param('form', false);
|
@@ -34,10 +34,10 @@ class FrmEntriesController{
|
|
34 |
if($form)
|
35 |
$entry_count = $frm_entry->getRecordCount($form->id);
|
36 |
|
37 |
-
|
38 |
}
|
39 |
|
40 |
-
function show_form($id='', $key='', $title=false, $description=false){
|
41 |
global $frm_form, $user_ID, $frm_settings, $post;
|
42 |
if ($id) $form = $frm_form->getOne((int)$id);
|
43 |
else if ($key) $form = $frm_form->getOne($key);
|
@@ -66,7 +66,7 @@ class FrmEntriesController{
|
|
66 |
return FrmEntriesController::get_form(FRM_VIEWS_PATH.'/frm-entries/frm-entry.php', $form, $title, $description);
|
67 |
}
|
68 |
|
69 |
-
function get_form($filename, $form, $title, $description) {
|
70 |
if (is_file($filename)) {
|
71 |
ob_start();
|
72 |
include $filename;
|
@@ -77,7 +77,7 @@ class FrmEntriesController{
|
|
77 |
return false;
|
78 |
}
|
79 |
|
80 |
-
function process_entry($errors=''){
|
81 |
if(is_admin() or !isset($_POST) or !isset($_POST['form_id']) or !is_numeric($_POST['form_id']) or !isset($_POST['item_key']))
|
82 |
return;
|
83 |
|
@@ -115,23 +115,23 @@ class FrmEntriesController{
|
|
115 |
}
|
116 |
|
117 |
//Delete entry if it shouldn't be saved before redirect
|
118 |
-
function delete_entry_before_redirect($redirect_msg, $atts){
|
119 |
-
|
120 |
return $redirect_msg;
|
121 |
}
|
122 |
|
123 |
-
function delete_entry_before_wpredirect($url, $form, $atts){
|
124 |
if(!defined('DOING_AJAX'))
|
125 |
-
|
126 |
return $url;
|
127 |
}
|
128 |
|
129 |
//Delete entry if not redirected
|
130 |
-
function delete_entry_after_save($atts){
|
131 |
-
|
132 |
}
|
133 |
|
134 |
-
function _delete_entry($entry_id, $form){
|
135 |
if(!$form)
|
136 |
return;
|
137 |
|
@@ -142,18 +142,18 @@ class FrmEntriesController{
|
|
142 |
}
|
143 |
}
|
144 |
|
145 |
-
function &filter_email_value($value, $meta, $entry, $atts=array()){
|
146 |
global $frm_field;
|
147 |
|
148 |
$field = $frm_field->getOne($meta->field_id);
|
149 |
if(!$field)
|
150 |
return $value;
|
151 |
|
152 |
-
$value =
|
153 |
return $value;
|
154 |
}
|
155 |
|
156 |
-
function &filter_display_value($value, $field, $atts=array()){
|
157 |
$field->field_options = maybe_unserialize($field->field_options);
|
158 |
|
159 |
$saved_value = (isset($atts['saved_value']) and $atts['saved_value']) ? true : false;
|
@@ -194,7 +194,7 @@ class FrmEntriesController{
|
|
194 |
return $value;
|
195 |
}
|
196 |
|
197 |
-
function get_params($form=null){
|
198 |
global $frm_form, $frm_form_params;
|
199 |
|
200 |
if(!$form)
|
6 |
class FrmEntriesController{
|
7 |
|
8 |
function FrmEntriesController(){
|
9 |
+
add_action('admin_menu', 'FrmEntriesController::menu', 20);
|
10 |
+
add_action('wp', 'FrmEntriesController::process_entry', 10, 0);
|
11 |
+
add_action('frm_wp', 'FrmEntriesController::process_entry', 10, 0);
|
12 |
+
add_filter('frm_redirect_msg', 'FrmEntriesController::delete_entry_before_redirect', 50, 3);
|
13 |
+
add_filter('frm_redirect_url', 'FrmEntriesController::delete_entry_before_wpredirect', 50, 3);
|
14 |
+
add_action('frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100);
|
15 |
+
add_filter('frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3);
|
16 |
}
|
17 |
|
18 |
+
public static function menu(){
|
19 |
global $frmpro_is_installed;
|
20 |
if(!$frmpro_is_installed){
|
21 |
+
add_submenu_page('formidable', 'Formidable |'. __('Entries', 'formidable'), '<span style="opacity:.5;filter:alpha(opacity=50);">'. __('Entries', 'formidable') .'</span>', 'administrator', 'formidable-entries', 'FrmEntriesController::list_entries');
|
22 |
}
|
23 |
}
|
24 |
|
25 |
+
public static function list_entries(){
|
26 |
global $frm_form, $frm_entry;
|
27 |
$form_select = $frm_form->getAll("is_template=0 AND (status is NULL OR status = '' OR status = 'published')", ' ORDER BY name');
|
28 |
$form_id = FrmAppHelper::get_param('form', false);
|
34 |
if($form)
|
35 |
$entry_count = $frm_entry->getRecordCount($form->id);
|
36 |
|
37 |
+
include(FRM_VIEWS_PATH.'/frm-entries/list.php');
|
38 |
}
|
39 |
|
40 |
+
public static function show_form($id='', $key='', $title=false, $description=false){
|
41 |
global $frm_form, $user_ID, $frm_settings, $post;
|
42 |
if ($id) $form = $frm_form->getOne((int)$id);
|
43 |
else if ($key) $form = $frm_form->getOne($key);
|
66 |
return FrmEntriesController::get_form(FRM_VIEWS_PATH.'/frm-entries/frm-entry.php', $form, $title, $description);
|
67 |
}
|
68 |
|
69 |
+
public static function get_form($filename, $form, $title, $description) {
|
70 |
if (is_file($filename)) {
|
71 |
ob_start();
|
72 |
include $filename;
|
77 |
return false;
|
78 |
}
|
79 |
|
80 |
+
public static function process_entry($errors=''){
|
81 |
if(is_admin() or !isset($_POST) or !isset($_POST['form_id']) or !is_numeric($_POST['form_id']) or !isset($_POST['item_key']))
|
82 |
return;
|
83 |
|
115 |
}
|
116 |
|
117 |
//Delete entry if it shouldn't be saved before redirect
|
118 |
+
public static function delete_entry_before_redirect($redirect_msg, $atts){
|
119 |
+
self::_delete_entry($atts['entry_id'], $atts['form']);
|
120 |
return $redirect_msg;
|
121 |
}
|
122 |
|
123 |
+
public static function delete_entry_before_wpredirect($url, $form, $atts){
|
124 |
if(!defined('DOING_AJAX'))
|
125 |
+
self::_delete_entry($atts['id'], $form);
|
126 |
return $url;
|
127 |
}
|
128 |
|
129 |
//Delete entry if not redirected
|
130 |
+
public static function delete_entry_after_save($atts){
|
131 |
+
self::_delete_entry($atts['entry_id'], $atts['form']);
|
132 |
}
|
133 |
|
134 |
+
private static function _delete_entry($entry_id, $form){
|
135 |
if(!$form)
|
136 |
return;
|
137 |
|
142 |
}
|
143 |
}
|
144 |
|
145 |
+
public static function &filter_email_value($value, $meta, $entry, $atts=array()){
|
146 |
global $frm_field;
|
147 |
|
148 |
$field = $frm_field->getOne($meta->field_id);
|
149 |
if(!$field)
|
150 |
return $value;
|
151 |
|
152 |
+
$value = self::filter_display_value($value, $field, $atts);
|
153 |
return $value;
|
154 |
}
|
155 |
|
156 |
+
public static function &filter_display_value($value, $field, $atts=array()){
|
157 |
$field->field_options = maybe_unserialize($field->field_options);
|
158 |
|
159 |
$saved_value = (isset($atts['saved_value']) and $atts['saved_value']) ? true : false;
|
194 |
return $value;
|
195 |
}
|
196 |
|
197 |
+
public static function get_params($form=null){
|
198 |
global $frm_form, $frm_form_params;
|
199 |
|
200 |
if(!$form)
|
classes/controllers/FrmFieldsController.php
CHANGED
@@ -5,28 +5,52 @@
|
|
5 |
|
6 |
class FrmFieldsController{
|
7 |
function FrmFieldsController(){
|
8 |
-
add_action('
|
9 |
-
add_action('
|
10 |
-
add_action('
|
11 |
-
add_action('
|
12 |
-
add_action('
|
13 |
-
add_action('
|
14 |
-
add_action('
|
15 |
-
add_action('
|
16 |
-
add_action('
|
17 |
-
add_action('
|
18 |
-
add_action('
|
19 |
-
add_action('
|
20 |
-
add_action('
|
21 |
-
|
22 |
-
add_filter('
|
23 |
-
|
24 |
-
|
25 |
-
add_filter('
|
|
|
26 |
}
|
27 |
|
28 |
-
function
|
29 |
-
global $frm_field, $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
$field_data = $_POST['field'];
|
31 |
$form_id = $_POST['form_id'];
|
32 |
$values = array();
|
@@ -47,9 +71,9 @@ class FrmFieldsController{
|
|
47 |
die();
|
48 |
}
|
49 |
|
50 |
-
function edit_name(){
|
51 |
global $frm_field;
|
52 |
-
$id = str_replace('
|
53 |
$values = array('name' => trim($_POST['update_value']));
|
54 |
if ($_POST['original_html'] == 'Untitled')
|
55 |
$values['field_key'] = $_POST['update_value'];
|
@@ -59,21 +83,21 @@ class FrmFieldsController{
|
|
59 |
}
|
60 |
|
61 |
|
62 |
-
function edit_description(){
|
63 |
global $frm_field;
|
64 |
-
$id = str_replace('
|
65 |
$frm_field->update($id, array('description' => $_POST['update_value']));
|
66 |
echo stripslashes($_POST['update_value']);
|
67 |
die();
|
68 |
}
|
69 |
|
70 |
-
function mark_required(){
|
71 |
global $frm_field;
|
72 |
$frm_field->update($_POST['field'], array('required' => $_POST['required']));
|
73 |
die();
|
74 |
}
|
75 |
|
76 |
-
function update_ajax_option(){
|
77 |
global $frm_field;
|
78 |
$field = $frm_field->getOne($_POST['field']);
|
79 |
$field->field_options = maybe_unserialize($field->field_options);
|
@@ -93,8 +117,8 @@ class FrmFieldsController{
|
|
93 |
die();
|
94 |
}
|
95 |
|
96 |
-
function duplicate(){
|
97 |
-
global $frmdb, $frm_field
|
98 |
|
99 |
$copy_field = $frm_field->getOne($_POST['field_id']);
|
100 |
if (!$copy_field) return;
|
@@ -106,7 +130,7 @@ class FrmFieldsController{
|
|
106 |
$values['form_id'] = $copy_field->form_id;
|
107 |
foreach (array('name', 'description', 'type', 'field_options', 'required') as $col)
|
108 |
$values[$col] = $copy_field->{$col};
|
109 |
-
$field_count =
|
110 |
$values['field_order'] = $field_count + 1;
|
111 |
|
112 |
$field_id = $frm_field->create($values);
|
@@ -123,15 +147,15 @@ class FrmFieldsController{
|
|
123 |
die();
|
124 |
}
|
125 |
|
126 |
-
function destroy(){
|
127 |
global $frm_field;
|
128 |
$field_id = $frm_field->destroy($_POST['field_id']);
|
129 |
die();
|
130 |
}
|
131 |
|
132 |
/* Field Options */
|
133 |
-
function add_option(){
|
134 |
-
global $frm_field
|
135 |
|
136 |
$id = $_POST['field_id'];
|
137 |
$field = $frm_field->getOne($id);
|
@@ -162,12 +186,11 @@ class FrmFieldsController{
|
|
162 |
$field['separate_value'] = isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0;
|
163 |
$field_name = "item_meta[$id]";
|
164 |
|
165 |
-
require(FRM_VIEWS_PATH.'/frm-forms/new-option-js.php');
|
166 |
require(FRM_VIEWS_PATH.'/frm-fields/single-option.php');
|
167 |
die();
|
168 |
}
|
169 |
|
170 |
-
function edit_option(){
|
171 |
global $frm_field;
|
172 |
$ids = explode('-', $_POST['element_id']);
|
173 |
$id = str_replace('field_', '', $ids[0]);
|
@@ -201,7 +224,7 @@ class FrmFieldsController{
|
|
201 |
die();
|
202 |
}
|
203 |
|
204 |
-
function delete_option(){
|
205 |
global $frm_field;
|
206 |
$field = $frm_field->getOne($_POST['field_id']);
|
207 |
$options = maybe_unserialize($field->options);
|
@@ -210,13 +233,13 @@ class FrmFieldsController{
|
|
210 |
die();
|
211 |
}
|
212 |
|
213 |
-
function import_choices(){
|
214 |
if(!current_user_can('frm_edit_forms'))
|
215 |
return;
|
216 |
|
217 |
$field_id = $_REQUEST['field_id'];
|
218 |
|
219 |
-
global $current_screen, $hook_suffix;
|
220 |
|
221 |
// Catch plugins that include admin-header.php before admin.php completes.
|
222 |
if (empty( $current_screen ) and function_exists('set_current_screen')){
|
@@ -267,17 +290,17 @@ class FrmFieldsController{
|
|
267 |
__('Disagree', 'formidable'), __('Strongly Disagree', 'formidable'), __('N/A', 'formidable')
|
268 |
);
|
269 |
|
270 |
-
$field =
|
271 |
|
272 |
include(FRM_VIEWS_PATH.'/frm-fields/import_choices.php');
|
273 |
die();
|
274 |
}
|
275 |
|
276 |
-
function import_options(){
|
277 |
if(!is_admin() or !current_user_can('frm_edit_forms'))
|
278 |
return;
|
279 |
|
280 |
-
global $frm_field
|
281 |
|
282 |
extract($_POST);
|
283 |
|
@@ -322,7 +345,7 @@ class FrmFieldsController{
|
|
322 |
die();
|
323 |
}
|
324 |
|
325 |
-
function update_order(){
|
326 |
if(isset($_POST) and isset($_POST['frm_field_id'])){
|
327 |
global $frm_field;
|
328 |
|
@@ -332,7 +355,7 @@ class FrmFieldsController{
|
|
332 |
die();
|
333 |
}
|
334 |
|
335 |
-
function change_type($type){
|
336 |
global $frmpro_is_installed;
|
337 |
|
338 |
if ($frmpro_is_installed) return $type;
|
@@ -350,7 +373,7 @@ class FrmFieldsController{
|
|
350 |
return $type;
|
351 |
}
|
352 |
|
353 |
-
function display_field_options($display){
|
354 |
switch($display['type']){
|
355 |
case 'captcha':
|
356 |
$display['required'] = false;
|
@@ -373,19 +396,23 @@ class FrmFieldsController{
|
|
373 |
return $display;
|
374 |
}
|
375 |
|
376 |
-
function input_html($field, $echo=true){
|
377 |
global $frm_settings;
|
378 |
|
379 |
$class = ''; //$field['type'];
|
|
|
|
|
|
|
|
|
380 |
$add_html = '';
|
381 |
|
382 |
if(isset($field['size']) and $field['size'] > 0){
|
383 |
-
if(!in_array($field['type'], array('textarea', 'select', 'data', 'time')))
|
384 |
$add_html .= ' size="'. $field['size'] .'"';
|
385 |
$class .= " auto_width";
|
386 |
}
|
387 |
|
388 |
-
if(isset($field['max']) and !in_array($field['type'], array('textarea', 'rte')) and !empty($field['max']))
|
389 |
$add_html .= ' maxlength="'. $field['max'] .'"';
|
390 |
|
391 |
if(!is_admin() or !isset($_GET) or !isset($_GET['page']) or $_GET['page'] == 'formidable_entries'){
|
@@ -419,7 +446,7 @@ class FrmFieldsController{
|
|
419 |
|
420 |
$class = apply_filters('frm_field_classes', $class, $field);
|
421 |
if(!empty($class))
|
422 |
-
$add_html .= ' class="'. $class .'"';
|
423 |
|
424 |
if(isset($field['shortcodes']) and !empty($field['shortcodes'])){
|
425 |
foreach($field['shortcodes'] as $k => $v){
|
@@ -436,7 +463,7 @@ class FrmFieldsController{
|
|
436 |
return $add_html;
|
437 |
}
|
438 |
|
439 |
-
function check_value($opt, $opt_key, $field){
|
440 |
if(is_array($opt)){
|
441 |
if(isset($field['separate_value']) and $field['separate_value']){
|
442 |
$opt = isset($opt['value']) ? $opt['value'] : (isset($opt['label']) ? $opt['label'] : reset($opt));
|
@@ -447,7 +474,7 @@ class FrmFieldsController{
|
|
447 |
return $opt;
|
448 |
}
|
449 |
|
450 |
-
function check_label($opt, $opt_key, $field){
|
451 |
if(is_array($opt))
|
452 |
$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
|
453 |
|
5 |
|
6 |
class FrmFieldsController{
|
7 |
function FrmFieldsController(){
|
8 |
+
add_action('wp_ajax_frm_load_field', 'FrmFieldsController::load_field');
|
9 |
+
add_action('wp_ajax_frm_insert_field', 'FrmFieldsController::create');
|
10 |
+
add_action('wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name');
|
11 |
+
add_action('wp_ajax_frm_field_desc_in_place_edit', 'FrmFieldsController::edit_description');
|
12 |
+
add_action('wp_ajax_frm_mark_required', 'FrmFieldsController::mark_required');
|
13 |
+
add_action('wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option');
|
14 |
+
add_action('wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate');
|
15 |
+
add_action('wp_ajax_frm_delete_field', 'FrmFieldsController::destroy');
|
16 |
+
add_action('wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option');
|
17 |
+
add_action('wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option');
|
18 |
+
add_action('wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option');
|
19 |
+
add_action('wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices');
|
20 |
+
add_action('wp_ajax_frm_import_options', 'FrmFieldsController::import_options');
|
21 |
+
add_action('wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order');
|
22 |
+
add_filter('frm_field_type', 'FrmFieldsController::change_type');
|
23 |
+
add_filter('frm_display_field_options', 'FrmFieldsController::display_field_options');
|
24 |
+
add_action('frm_field_input_html', 'FrmFieldsController::input_html');
|
25 |
+
add_filter('frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3);
|
26 |
+
add_filter('frm_field_label_seen', 'FrmFieldsController::check_label', 10, 3);
|
27 |
}
|
28 |
|
29 |
+
public static function load_field(){
|
30 |
+
global $frm_field, $frm_form;
|
31 |
+
|
32 |
+
$id = $field_id = $_POST['field_id'];
|
33 |
+
if(!$field_id or !is_numeric($field_id))
|
34 |
+
die();
|
35 |
+
|
36 |
+
$_GET['page'] = 'formidable';
|
37 |
+
$field = htmlspecialchars_decode(nl2br(stripslashes_deep($_POST['field'])));
|
38 |
+
$field = json_decode($field, true);
|
39 |
+
if(!isset($field['value']))
|
40 |
+
$field['value'] = '';
|
41 |
+
|
42 |
+
$field_name = "item_meta[$field_id]";
|
43 |
+
|
44 |
+
$values = array();
|
45 |
+
|
46 |
+
include(FRM_VIEWS_PATH .'/frm-forms/add_field.php');
|
47 |
+
include(FRM_VIEWS_PATH .'/frm-forms/new-field-js.php');
|
48 |
+
|
49 |
+
die();
|
50 |
+
}
|
51 |
+
|
52 |
+
public static function create(){
|
53 |
+
global $frm_field;
|
54 |
$field_data = $_POST['field'];
|
55 |
$form_id = $_POST['form_id'];
|
56 |
$values = array();
|
71 |
die();
|
72 |
}
|
73 |
|
74 |
+
public static function edit_name(){
|
75 |
global $frm_field;
|
76 |
+
$id = str_replace('field_label_', '', $_POST['element_id']);
|
77 |
$values = array('name' => trim($_POST['update_value']));
|
78 |
if ($_POST['original_html'] == 'Untitled')
|
79 |
$values['field_key'] = $_POST['update_value'];
|
83 |
}
|
84 |
|
85 |
|
86 |
+
public static function edit_description(){
|
87 |
global $frm_field;
|
88 |
+
$id = str_replace('field_description_', '', $_POST['element_id']);
|
89 |
$frm_field->update($id, array('description' => $_POST['update_value']));
|
90 |
echo stripslashes($_POST['update_value']);
|
91 |
die();
|
92 |
}
|
93 |
|
94 |
+
public static function mark_required(){
|
95 |
global $frm_field;
|
96 |
$frm_field->update($_POST['field'], array('required' => $_POST['required']));
|
97 |
die();
|
98 |
}
|
99 |
|
100 |
+
public static function update_ajax_option(){
|
101 |
global $frm_field;
|
102 |
$field = $frm_field->getOne($_POST['field']);
|
103 |
$field->field_options = maybe_unserialize($field->field_options);
|
117 |
die();
|
118 |
}
|
119 |
|
120 |
+
public static function duplicate(){
|
121 |
+
global $frmdb, $frm_field;
|
122 |
|
123 |
$copy_field = $frm_field->getOne($_POST['field_id']);
|
124 |
if (!$copy_field) return;
|
130 |
$values['form_id'] = $copy_field->form_id;
|
131 |
foreach (array('name', 'description', 'type', 'field_options', 'required') as $col)
|
132 |
$values[$col] = $copy_field->{$col};
|
133 |
+
$field_count = FrmAppHelper::getRecordCount("form_id='$copy_field->form_id'", $frmdb->fields);
|
134 |
$values['field_order'] = $field_count + 1;
|
135 |
|
136 |
$field_id = $frm_field->create($values);
|
147 |
die();
|
148 |
}
|
149 |
|
150 |
+
public static function destroy(){
|
151 |
global $frm_field;
|
152 |
$field_id = $frm_field->destroy($_POST['field_id']);
|
153 |
die();
|
154 |
}
|
155 |
|
156 |
/* Field Options */
|
157 |
+
public static function add_option(){
|
158 |
+
global $frm_field;
|
159 |
|
160 |
$id = $_POST['field_id'];
|
161 |
$field = $frm_field->getOne($id);
|
186 |
$field['separate_value'] = isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0;
|
187 |
$field_name = "item_meta[$id]";
|
188 |
|
|
|
189 |
require(FRM_VIEWS_PATH.'/frm-fields/single-option.php');
|
190 |
die();
|
191 |
}
|
192 |
|
193 |
+
public static function edit_option(){
|
194 |
global $frm_field;
|
195 |
$ids = explode('-', $_POST['element_id']);
|
196 |
$id = str_replace('field_', '', $ids[0]);
|
224 |
die();
|
225 |
}
|
226 |
|
227 |
+
public static function delete_option(){
|
228 |
global $frm_field;
|
229 |
$field = $frm_field->getOne($_POST['field_id']);
|
230 |
$options = maybe_unserialize($field->options);
|
233 |
die();
|
234 |
}
|
235 |
|
236 |
+
public static function import_choices(){
|
237 |
if(!current_user_can('frm_edit_forms'))
|
238 |
return;
|
239 |
|
240 |
$field_id = $_REQUEST['field_id'];
|
241 |
|
242 |
+
global $current_screen, $hook_suffix, $frm_field;
|
243 |
|
244 |
// Catch plugins that include admin-header.php before admin.php completes.
|
245 |
if (empty( $current_screen ) and function_exists('set_current_screen')){
|
290 |
__('Disagree', 'formidable'), __('Strongly Disagree', 'formidable'), __('N/A', 'formidable')
|
291 |
);
|
292 |
|
293 |
+
$field = $frm_field->getOne($field_id);
|
294 |
|
295 |
include(FRM_VIEWS_PATH.'/frm-fields/import_choices.php');
|
296 |
die();
|
297 |
}
|
298 |
|
299 |
+
public static function import_options(){
|
300 |
if(!is_admin() or !current_user_can('frm_edit_forms'))
|
301 |
return;
|
302 |
|
303 |
+
global $frm_field;
|
304 |
|
305 |
extract($_POST);
|
306 |
|
345 |
die();
|
346 |
}
|
347 |
|
348 |
+
public static function update_order(){
|
349 |
if(isset($_POST) and isset($_POST['frm_field_id'])){
|
350 |
global $frm_field;
|
351 |
|
355 |
die();
|
356 |
}
|
357 |
|
358 |
+
public static function change_type($type){
|
359 |
global $frmpro_is_installed;
|
360 |
|
361 |
if ($frmpro_is_installed) return $type;
|
373 |
return $type;
|
374 |
}
|
375 |
|
376 |
+
public static function display_field_options($display){
|
377 |
switch($display['type']){
|
378 |
case 'captcha':
|
379 |
$display['required'] = false;
|
396 |
return $display;
|
397 |
}
|
398 |
|
399 |
+
public static function input_html($field, $echo=true){
|
400 |
global $frm_settings;
|
401 |
|
402 |
$class = ''; //$field['type'];
|
403 |
+
|
404 |
+
if(is_admin() and !in_array($field['type'], array('scale', 'radio', 'checkbox', 'data')))
|
405 |
+
$class .= 'dyn_default_value';
|
406 |
+
|
407 |
$add_html = '';
|
408 |
|
409 |
if(isset($field['size']) and $field['size'] > 0){
|
410 |
+
if(!in_array($field['type'], array('textarea', 'select', 'data', 'time', 'hidden')))
|
411 |
$add_html .= ' size="'. $field['size'] .'"';
|
412 |
$class .= " auto_width";
|
413 |
}
|
414 |
|
415 |
+
if(isset($field['max']) and !in_array($field['type'], array('textarea', 'rte', 'hidden')) and !empty($field['max']))
|
416 |
$add_html .= ' maxlength="'. $field['max'] .'"';
|
417 |
|
418 |
if(!is_admin() or !isset($_GET) or !isset($_GET['page']) or $_GET['page'] == 'formidable_entries'){
|
446 |
|
447 |
$class = apply_filters('frm_field_classes', $class, $field);
|
448 |
if(!empty($class))
|
449 |
+
$add_html .= ' class="'. trim($class) .'"';
|
450 |
|
451 |
if(isset($field['shortcodes']) and !empty($field['shortcodes'])){
|
452 |
foreach($field['shortcodes'] as $k => $v){
|
463 |
return $add_html;
|
464 |
}
|
465 |
|
466 |
+
public static function check_value($opt, $opt_key, $field){
|
467 |
if(is_array($opt)){
|
468 |
if(isset($field['separate_value']) and $field['separate_value']){
|
469 |
$opt = isset($opt['value']) ? $opt['value'] : (isset($opt['label']) ? $opt['label'] : reset($opt));
|
474 |
return $opt;
|
475 |
}
|
476 |
|
477 |
+
public static function check_label($opt, $opt_key, $field){
|
478 |
if(is_array($opt))
|
479 |
$opt = (isset($opt['label']) ? $opt['label'] : reset($opt));
|
480 |
|
classes/controllers/FrmFormsController.php
CHANGED
@@ -5,71 +5,76 @@
|
|
5 |
|
6 |
class FrmFormsController{
|
7 |
function FrmFormsController(){
|
8 |
-
add_action('admin_menu',
|
9 |
-
add_action('admin_menu',
|
10 |
-
add_action('admin_head-toplevel_page_formidable',
|
11 |
-
add_action('wp_ajax_frm_form_name_in_place_edit',
|
12 |
-
add_action('wp_ajax_frm_form_desc_in_place_edit',
|
13 |
-
add_action('wp_ajax_frm_delete_form_wo_fields',
|
14 |
-
|
15 |
-
add_filter('
|
16 |
-
|
17 |
-
add_action('
|
|
|
18 |
|
19 |
-
add_filter('set-screen-option',
|
20 |
}
|
21 |
|
22 |
-
function menu(){
|
23 |
global $frm_settings;
|
24 |
-
add_submenu_page('formidable', $frm_settings->menu .' | '. __('Forms', 'formidable'), __('Forms', 'formidable'), 'frm_view_forms', 'formidable',
|
25 |
-
add_submenu_page('formidable', $frm_settings->menu .' | '. __('Templates', 'formidable'), __('Templates', 'formidable'), 'frm_view_forms', 'formidable-templates',
|
26 |
|
27 |
-
add_action('admin_head-'. sanitize_title($frm_settings->menu) .'_page_formidable-new',
|
28 |
-
add_action('admin_head-'. sanitize_title($frm_settings->menu) .'_page_formidable-templates',
|
29 |
|
30 |
if(class_exists('WP_List_Table')){
|
31 |
-
add_filter('manage_toplevel_page_formidable_columns',
|
32 |
-
add_filter('manage_'. sanitize_title($frm_settings->menu) .'_page_formidable-templates_columns',
|
33 |
-
add_filter('manage_toplevel_page_formidable_sortable_columns',
|
34 |
-
add_filter('manage_'. sanitize_title($frm_settings->menu) .'_page_formidable-templates_sortable_columns',
|
35 |
-
add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden',
|
36 |
-
add_filter('get_user_option_manage'. sanitize_title($frm_settings->menu) .'_page_formidable-templatescolumnshidden',
|
37 |
}
|
38 |
}
|
39 |
|
40 |
-
function lower_menu(){
|
41 |
-
add_submenu_page('formidable', 'Formidable | '. __('Add New Form', 'formidable'), '<span style="display:none;">'. __('Add New Form', 'formidable') .'</span>', 'frm_edit_forms', 'formidable-new',
|
42 |
}
|
43 |
|
44 |
-
function head(){
|
45 |
global $frm_settings;
|
46 |
|
47 |
$js_file = array(FRM_URL . '/js/jquery/jquery-ui-themepicker.js', FRM_URL.'/js/jquery/jquery.editinplace.packed.js');
|
48 |
require(FRM_VIEWS_PATH . '/shared/head.php');
|
49 |
}
|
50 |
|
51 |
-
function list_form(){
|
52 |
-
$params =
|
53 |
$errors = apply_filters('frm_admin_list_form_action', array());
|
54 |
-
return
|
55 |
}
|
56 |
|
57 |
-
function template_list(){
|
58 |
$_POST['template'] = 1;
|
59 |
$errors = apply_filters('frm_admin_list_form_action', array());
|
60 |
-
return
|
61 |
}
|
62 |
|
63 |
-
function new_form(){
|
64 |
-
global $frm_form, $frmpro_is_installed
|
65 |
|
66 |
$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
|
67 |
-
|
|
|
|
|
|
|
|
|
68 |
if ($action == 'create'){
|
69 |
-
return
|
70 |
}else if ($action == 'new'){
|
71 |
$frm_field_selection = FrmFieldsHelper::field_selection();
|
72 |
-
$values = FrmFormsHelper::setup_new_vars();
|
73 |
$id = $frm_form->create( $values );
|
74 |
$values['id'] = $id;
|
75 |
require(FRM_VIEWS_PATH.'/frm-forms/new.php');
|
@@ -79,10 +84,14 @@ class FrmFormsController{
|
|
79 |
}
|
80 |
}
|
81 |
|
82 |
-
function create(){
|
83 |
global $frm_entry, $frm_form, $frm_field, $frmpro_is_installed;
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
86 |
|
87 |
if( count($errors) > 0 ){
|
88 |
$hide_preview = true;
|
@@ -92,39 +101,39 @@ class FrmFormsController{
|
|
92 |
$values = FrmAppHelper::setup_edit_vars($record, 'forms', $fields, true);
|
93 |
require(FRM_VIEWS_PATH.'/frm-forms/new.php');
|
94 |
}else{
|
95 |
-
$record = $frm_form->update( $id, $
|
96 |
die('<script type="text/javascript">window.location="'. admin_url('admin.php?page=formidable&frm_action=settings&id='. $id) .'"</script>');
|
97 |
//$message = __('Form was Successfully Created', 'formidable');
|
98 |
-
//return
|
99 |
}
|
100 |
}
|
101 |
|
102 |
-
function edit(){
|
103 |
-
$id = FrmAppHelper::get_param('id');
|
104 |
-
return
|
105 |
}
|
106 |
|
107 |
-
function settings($id=false, $message=''){
|
108 |
if(!$id or !is_numeric($id))
|
109 |
-
$id = FrmAppHelper::get_param('id');
|
110 |
-
return
|
111 |
}
|
112 |
|
113 |
-
function update_settings(){
|
114 |
global $frm_form;
|
115 |
|
116 |
$id = FrmAppHelper::get_param('id');
|
117 |
$errors = $frm_form->validate($_POST);
|
118 |
if( count($errors) > 0 ){
|
119 |
-
return
|
120 |
}else{
|
121 |
$record = $frm_form->update( $_POST['id'], $_POST );
|
122 |
$message = __('Settings Successfully Updated', 'formidable');
|
123 |
-
return
|
124 |
}
|
125 |
}
|
126 |
|
127 |
-
function translate($action){
|
128 |
global $frmpro_is_installed, $frm_form;
|
129 |
$id = FrmAppHelper::get_param('id', false);
|
130 |
$form = $frm_form->getOne($id);
|
@@ -132,7 +141,7 @@ class FrmFormsController{
|
|
132 |
include(FRM_VIEWS_PATH . '/frm-forms/translate.php');
|
133 |
}
|
134 |
|
135 |
-
function edit_name(){
|
136 |
global $frm_form;
|
137 |
$values = array('name' => trim($_POST['update_value']));
|
138 |
$form = $frm_form->update($_POST['form_id'], $values);
|
@@ -140,7 +149,7 @@ class FrmFormsController{
|
|
140 |
die();
|
141 |
}
|
142 |
|
143 |
-
function edit_description(){
|
144 |
global $frm_form;
|
145 |
$form = $frm_form->update($_POST['form_id'], array('description' => $_POST['update_value']));
|
146 |
$description = stripslashes($_POST['update_value']);
|
@@ -150,41 +159,44 @@ class FrmFormsController{
|
|
150 |
die();
|
151 |
}
|
152 |
|
153 |
-
function update(){
|
154 |
global $frm_form;
|
155 |
-
|
156 |
-
|
|
|
|
|
|
|
157 |
if( count($errors) > 0 ){
|
158 |
-
return
|
159 |
}else{
|
160 |
-
$record = $frm_form->update( $
|
161 |
$message = __('Form was Successfully Updated', 'formidable');
|
162 |
-
return
|
163 |
}
|
164 |
}
|
165 |
|
166 |
-
function duplicate(){
|
167 |
global $frm_form;
|
168 |
|
169 |
-
$params =
|
170 |
$record = $frm_form->duplicate( $params['id'], $params['template'], true );
|
171 |
$message = ($params['template']) ? __('Form template was Successfully Created', 'formidable') : __('Form was Successfully Copied', 'formidable');
|
172 |
if ($record)
|
173 |
-
return
|
174 |
else
|
175 |
-
return
|
176 |
}
|
177 |
|
178 |
-
function page_preview(){
|
179 |
global $frm_form;
|
180 |
-
$params =
|
181 |
if (!$params['form']) return;
|
182 |
$form = $frm_form->getOne($params['form']);
|
183 |
if(!$form) return;
|
184 |
return FrmEntriesController::show_form($form->id, '', true, true);
|
185 |
}
|
186 |
|
187 |
-
function preview(){
|
188 |
do_action('frm_wp');
|
189 |
|
190 |
global $frm_form, $frm_settings, $frmpro_is_installed;
|
@@ -210,21 +222,21 @@ class FrmFormsController{
|
|
210 |
require(FRM_VIEWS_PATH.'/frm-entries/direct.php');
|
211 |
}
|
212 |
|
213 |
-
function destroy(){
|
214 |
if(!current_user_can('frm_delete_forms')){
|
215 |
global $frm_settings;
|
216 |
wp_die($frm_settings->admin_permission);
|
217 |
}
|
218 |
|
219 |
global $frm_form;
|
220 |
-
$params =
|
221 |
$message = '';
|
222 |
if ($frm_form->destroy( $params['id'] ))
|
223 |
$message = __('Form was Successfully Deleted', 'formidable');
|
224 |
-
|
225 |
}
|
226 |
|
227 |
-
function destroy_wo_fields(){
|
228 |
global $frm_field, $frm_form, $frmdb;
|
229 |
$id = $_POST['form_id'];
|
230 |
if ($frmdb->get_count($frmdb->fields, array('form_id' => $id)) <= 0)
|
@@ -232,7 +244,7 @@ class FrmFormsController{
|
|
232 |
die();
|
233 |
}
|
234 |
|
235 |
-
function submit_button_label($submit){
|
236 |
if (!$submit or empty($submit)){
|
237 |
global $frm_settings;
|
238 |
$submit = $frm_settings->submit_value;
|
@@ -240,19 +252,19 @@ class FrmFormsController{
|
|
240 |
return $submit;
|
241 |
}
|
242 |
|
243 |
-
function insert_form_button($content){
|
244 |
if(current_user_can('frm_view_forms'))
|
245 |
$content .= '<a href="#TB_inline?width=450&height=550&inlineId=frm_insert_form" class="thickbox" title="' . __("Add Formidable Form", 'formidable') . '"><img src="'.FRM_IMAGES_URL.'/form_16.png" alt="' . __("Add Formidable Form", 'formidable') . '" /></a>';
|
246 |
return $content;
|
247 |
}
|
248 |
|
249 |
-
function show_form_button($id){
|
250 |
if($id != 'content')
|
251 |
return;
|
252 |
echo '<a href="#TB_inline?width=450&height=550&inlineId=frm_insert_form" class="thickbox" title="' . __("Add Formidable Form", 'formidable') . '"><img src="'. esc_url(FRM_IMAGES_URL.'/form_16.png'). '" alt="' . __("Add Formidable Form", 'formidable') . '" /></a>';
|
253 |
}
|
254 |
|
255 |
-
function insert_form_popup(){
|
256 |
$page = basename($_SERVER['PHP_SELF']);
|
257 |
if(in_array($page, array('post.php', 'page.php', 'page-new.php', 'post-new.php')) or (isset($_GET) and isset($_GET['page']) and $_GET['page'] == 'formidable-entry-templates')){
|
258 |
if(class_exists('FrmProDisplay')){
|
@@ -263,11 +275,11 @@ class FrmFormsController{
|
|
263 |
}
|
264 |
}
|
265 |
|
266 |
-
function display_forms_list($params=false, $message='', $page_params_ov = false, $current_page_ov = false, $errors = array()){
|
267 |
-
global $wpdb, $frmdb, $
|
268 |
|
269 |
if(!$params)
|
270 |
-
$params =
|
271 |
|
272 |
if($message=='')
|
273 |
$message = FrmAppHelper::frm_get_main_message();
|
@@ -294,7 +306,7 @@ class FrmFormsController{
|
|
294 |
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
|
295 |
if ( $pagenum > $total_pages && $total_pages > 0 ) {
|
296 |
wp_redirect( add_query_arg( 'paged', $total_pages ) );
|
297 |
-
|
298 |
}
|
299 |
|
300 |
if ( ! empty( $_REQUEST['s'] ) )
|
@@ -303,7 +315,7 @@ class FrmFormsController{
|
|
303 |
|
304 |
$where_clause = " (status is NULL OR status = '' OR status = 'published') AND default_template=0 AND is_template = ".$params['template'];
|
305 |
|
306 |
-
$form_vars =
|
307 |
|
308 |
$current_page = ($current_page_ov) ? $current_page_ov : $params['paged'];
|
309 |
$page_params .= ($page_params_ov) ? $page_params_ov : $form_vars['page_params'];
|
@@ -312,17 +324,17 @@ class FrmFormsController{
|
|
312 |
$sdir_str = $form_vars['sdir_str'];
|
313 |
$search_str = $form_vars['search_str'];
|
314 |
|
315 |
-
$record_count =
|
316 |
-
$page_count =
|
317 |
-
$forms =
|
318 |
-
$page_last_record =
|
319 |
-
$page_first_record =
|
320 |
}
|
321 |
|
322 |
require(FRM_VIEWS_PATH.'/frm-forms/list.php');
|
323 |
}
|
324 |
|
325 |
-
function get_form_sort_vars($params,$where_clause = ''){
|
326 |
$order_by = '';
|
327 |
$page_params = '';
|
328 |
|
@@ -376,7 +388,7 @@ class FrmFormsController{
|
|
376 |
return compact('order_by', 'sort_str', 'sdir_str', 'search_str', 'where_clause', 'page_params');
|
377 |
}
|
378 |
|
379 |
-
function get_columns($columns){
|
380 |
$columns['cb'] = '<input type="checkbox" />';
|
381 |
$columns['id'] = 'ID';
|
382 |
$columns['name'] = __('Name', 'formidable');
|
@@ -397,7 +409,7 @@ class FrmFormsController{
|
|
397 |
return $columns;
|
398 |
}
|
399 |
|
400 |
-
function get_sortable_columns() {
|
401 |
return array(
|
402 |
'id' => 'id',
|
403 |
'name' => 'name',
|
@@ -407,7 +419,7 @@ class FrmFormsController{
|
|
407 |
);
|
408 |
}
|
409 |
|
410 |
-
function hidden_columns($result){
|
411 |
$return = false;
|
412 |
foreach((array)$result as $r){
|
413 |
if(!empty($r)){
|
@@ -428,14 +440,14 @@ class FrmFormsController{
|
|
428 |
return $result;
|
429 |
}
|
430 |
|
431 |
-
function save_per_page($save, $option, $value){
|
432 |
if($option == 'formidable_page_formidable_per_page' or $option == 'formidable_page_formidable_templates_per_page')
|
433 |
$save = (int)$value;
|
434 |
return $save;
|
435 |
}
|
436 |
|
437 |
-
function get_edit_vars($id, $errors = '', $message='', $create_link=false){
|
438 |
-
global $frm_entry, $frm_form, $frm_field, $frmpro_is_installed
|
439 |
$record = $frm_form->getOne( $id );
|
440 |
$frm_field_selection = FrmFieldsHelper::field_selection();
|
441 |
$fields = $frm_field->getAll(array('fi.form_id' => $record->id), 'field_order');
|
@@ -447,14 +459,16 @@ class FrmFormsController{
|
|
447 |
|
448 |
if (isset($values['default_template']) && $values['default_template'])
|
449 |
wp_die(__('That template cannot be edited', 'formidable'));
|
|
|
|
|
450 |
else if($create_link)
|
451 |
require(FRM_VIEWS_PATH.'/frm-forms/new.php');
|
452 |
else
|
453 |
require(FRM_VIEWS_PATH.'/frm-forms/edit.php');
|
454 |
}
|
455 |
|
456 |
-
function get_settings_vars($id, $errors = '', $message=''){
|
457 |
-
global $frm_entry, $frm_form, $frm_field, $frmpro_is_installed
|
458 |
$record = $frm_form->getOne( $id );
|
459 |
$fields = $frm_field->getAll(array('fi.form_id' => $id), 'field_order');
|
460 |
$values = FrmAppHelper::setup_edit_vars($record, 'forms', $fields, true);
|
@@ -466,7 +480,7 @@ class FrmFormsController{
|
|
466 |
require(FRM_VIEWS_PATH.'/frm-forms/settings.php');
|
467 |
}
|
468 |
|
469 |
-
function get_params(){
|
470 |
$values = array();
|
471 |
foreach (array('template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '') as $var => $default)
|
472 |
$values[$var] = FrmAppHelper::get_param($var, $default);
|
@@ -474,7 +488,7 @@ class FrmFormsController{
|
|
474 |
return $values;
|
475 |
}
|
476 |
|
477 |
-
function add_default_templates($path, $default=true, $template=true){
|
478 |
global $frm_form, $frm_field;
|
479 |
$templates = glob($path."/*.php");
|
480 |
|
@@ -495,30 +509,42 @@ class FrmFormsController{
|
|
495 |
}
|
496 |
}
|
497 |
|
498 |
-
function route(){
|
499 |
$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
|
500 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
501 |
|
502 |
if($action == 'new')
|
503 |
-
return
|
504 |
else if($action == 'create')
|
505 |
-
return
|
506 |
else if($action == 'edit')
|
507 |
-
return
|
508 |
else if($action == 'update')
|
509 |
-
return
|
510 |
else if($action == 'duplicate')
|
511 |
-
return
|
512 |
else if($action == 'destroy')
|
513 |
-
return
|
514 |
else if($action == 'list-form')
|
515 |
-
return
|
516 |
else if($action == 'settings')
|
517 |
-
return
|
518 |
else if($action == 'update_settings')
|
519 |
-
return
|
520 |
else if($action == 'translate' or $action == 'update_translate')
|
521 |
-
return
|
522 |
else{
|
523 |
$action = FrmAppHelper::get_param('action');
|
524 |
if($action == -1)
|
@@ -530,9 +556,9 @@ class FrmFormsController{
|
|
530 |
if(isset($_GET) and isset($_GET['action2']))
|
531 |
$_SERVER['REQUEST_URI'] = str_replace('&action='.$_GET['action2'], '', $_SERVER['REQUEST_URI']);
|
532 |
|
533 |
-
return
|
534 |
}else{
|
535 |
-
return
|
536 |
}
|
537 |
}
|
538 |
}
|
5 |
|
6 |
class FrmFormsController{
|
7 |
function FrmFormsController(){
|
8 |
+
add_action('admin_menu', 'FrmFormsController::menu');
|
9 |
+
add_action('admin_menu', 'FrmFormsController::lower_menu', 90);
|
10 |
+
add_action('admin_head-toplevel_page_formidable', 'FrmFormsController::head');
|
11 |
+
add_action('wp_ajax_frm_form_name_in_place_edit', 'FrmFormsController::edit_name');
|
12 |
+
add_action('wp_ajax_frm_form_desc_in_place_edit', 'FrmFormsController::edit_description');
|
13 |
+
add_action('wp_ajax_frm_delete_form_wo_fields', 'FrmFormsController::destroy_wo_fields');
|
14 |
+
add_action('wp_ajax_frm_save_form', 'FrmFormsController::route');
|
15 |
+
add_filter('frm_submit_button', 'FrmFormsController::submit_button_label');
|
16 |
+
add_filter('media_buttons_context', 'FrmFormsController::insert_form_button');
|
17 |
+
//add_action('media_buttons', 'FrmFormsController::show_form_button', 20);
|
18 |
+
add_action('admin_footer', 'FrmFormsController::insert_form_popup');
|
19 |
|
20 |
+
add_filter('set-screen-option', 'FrmFormsController::save_per_page', 10, 3);
|
21 |
}
|
22 |
|
23 |
+
public static function menu(){
|
24 |
global $frm_settings;
|
25 |
+
add_submenu_page('formidable', $frm_settings->menu .' | '. __('Forms', 'formidable'), __('Forms', 'formidable'), 'frm_view_forms', 'formidable', 'FrmFormsController::route');
|
26 |
+
add_submenu_page('formidable', $frm_settings->menu .' | '. __('Templates', 'formidable'), __('Templates', 'formidable'), 'frm_view_forms', 'formidable-templates', 'FrmFormsController::template_list');
|
27 |
|
28 |
+
add_action('admin_head-'. sanitize_title($frm_settings->menu) .'_page_formidable-new', 'FrmFormsController::head');
|
29 |
+
add_action('admin_head-'. sanitize_title($frm_settings->menu) .'_page_formidable-templates', 'FrmFormsController::head');
|
30 |
|
31 |
if(class_exists('WP_List_Table')){
|
32 |
+
add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
|
33 |
+
add_filter('manage_'. sanitize_title($frm_settings->menu) .'_page_formidable-templates_columns', 'FrmFormsController::get_columns', 0 );
|
34 |
+
add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns');
|
35 |
+
add_filter('manage_'. sanitize_title($frm_settings->menu) .'_page_formidable-templates_sortable_columns', 'FrmFormsController::get_sortable_columns');
|
36 |
+
add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns');
|
37 |
+
add_filter('get_user_option_manage'. sanitize_title($frm_settings->menu) .'_page_formidable-templatescolumnshidden', 'FrmFormsController::hidden_columns');
|
38 |
}
|
39 |
}
|
40 |
|
41 |
+
public static function lower_menu(){
|
42 |
+
add_submenu_page('formidable', 'Formidable | '. __('Add New Form', 'formidable'), '<span style="display:none;">'. __('Add New Form', 'formidable') .'</span>', 'frm_edit_forms', 'formidable-new', 'FrmFormsController::new_form');
|
43 |
}
|
44 |
|
45 |
+
public static function head(){
|
46 |
global $frm_settings;
|
47 |
|
48 |
$js_file = array(FRM_URL . '/js/jquery/jquery-ui-themepicker.js', FRM_URL.'/js/jquery/jquery.editinplace.packed.js');
|
49 |
require(FRM_VIEWS_PATH . '/shared/head.php');
|
50 |
}
|
51 |
|
52 |
+
public static function list_form(){
|
53 |
+
$params = self::get_params();
|
54 |
$errors = apply_filters('frm_admin_list_form_action', array());
|
55 |
+
return self::display_forms_list($params, '', false, false, $errors);
|
56 |
}
|
57 |
|
58 |
+
public static function template_list(){
|
59 |
$_POST['template'] = 1;
|
60 |
$errors = apply_filters('frm_admin_list_form_action', array());
|
61 |
+
return self::display_forms_list();
|
62 |
}
|
63 |
|
64 |
+
public static function new_form($values=false){
|
65 |
+
global $frm_form, $frmpro_is_installed;
|
66 |
|
67 |
$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
|
68 |
+
if($values){
|
69 |
+
$action = $values[$action];
|
70 |
+
}else{
|
71 |
+
$action = FrmAppHelper::get_param($action);
|
72 |
+
}
|
73 |
if ($action == 'create'){
|
74 |
+
return self::create($values);
|
75 |
}else if ($action == 'new'){
|
76 |
$frm_field_selection = FrmFieldsHelper::field_selection();
|
77 |
+
$values = FrmFormsHelper::setup_new_vars($values);
|
78 |
$id = $frm_form->create( $values );
|
79 |
$values['id'] = $id;
|
80 |
require(FRM_VIEWS_PATH.'/frm-forms/new.php');
|
84 |
}
|
85 |
}
|
86 |
|
87 |
+
public static function create($values=false){
|
88 |
global $frm_entry, $frm_form, $frm_field, $frmpro_is_installed;
|
89 |
+
if(!$values)
|
90 |
+
$values = $_POST;
|
91 |
+
|
92 |
+
$id = isset($values['id']) ? (int)$values['id'] : (int)FrmAppHelper::get_param('id');
|
93 |
+
|
94 |
+
$errors = $frm_form->validate($values);
|
95 |
|
96 |
if( count($errors) > 0 ){
|
97 |
$hide_preview = true;
|
101 |
$values = FrmAppHelper::setup_edit_vars($record, 'forms', $fields, true);
|
102 |
require(FRM_VIEWS_PATH.'/frm-forms/new.php');
|
103 |
}else{
|
104 |
+
$record = $frm_form->update( $id, $values, true );
|
105 |
die('<script type="text/javascript">window.location="'. admin_url('admin.php?page=formidable&frm_action=settings&id='. $id) .'"</script>');
|
106 |
//$message = __('Form was Successfully Created', 'formidable');
|
107 |
+
//return self::settings($record, $message);
|
108 |
}
|
109 |
}
|
110 |
|
111 |
+
public static function edit($values=false){
|
112 |
+
$id = isset($values['id']) ? (int)$values['id'] : (int)FrmAppHelper::get_param('id');
|
113 |
+
return self::get_edit_vars($id);
|
114 |
}
|
115 |
|
116 |
+
public static function settings($id=false, $message=''){
|
117 |
if(!$id or !is_numeric($id))
|
118 |
+
$id = isset($values['id']) ? (int)$values['id'] : (int)FrmAppHelper::get_param('id');
|
119 |
+
return self::get_settings_vars($id, '', $message);
|
120 |
}
|
121 |
|
122 |
+
public static function update_settings(){
|
123 |
global $frm_form;
|
124 |
|
125 |
$id = FrmAppHelper::get_param('id');
|
126 |
$errors = $frm_form->validate($_POST);
|
127 |
if( count($errors) > 0 ){
|
128 |
+
return self::get_settings_vars($id, $errors);
|
129 |
}else{
|
130 |
$record = $frm_form->update( $_POST['id'], $_POST );
|
131 |
$message = __('Settings Successfully Updated', 'formidable');
|
132 |
+
return self::get_settings_vars($id, '', $message);
|
133 |
}
|
134 |
}
|
135 |
|
136 |
+
public static function translate($action){
|
137 |
global $frmpro_is_installed, $frm_form;
|
138 |
$id = FrmAppHelper::get_param('id', false);
|
139 |
$form = $frm_form->getOne($id);
|
141 |
include(FRM_VIEWS_PATH . '/frm-forms/translate.php');
|
142 |
}
|
143 |
|
144 |
+
public static function edit_name(){
|
145 |
global $frm_form;
|
146 |
$values = array('name' => trim($_POST['update_value']));
|
147 |
$form = $frm_form->update($_POST['form_id'], $values);
|
149 |
die();
|
150 |
}
|
151 |
|
152 |
+
public static function edit_description(){
|
153 |
global $frm_form;
|
154 |
$form = $frm_form->update($_POST['form_id'], array('description' => $_POST['update_value']));
|
155 |
$description = stripslashes($_POST['update_value']);
|
159 |
die();
|
160 |
}
|
161 |
|
162 |
+
public static function update($values=false){
|
163 |
global $frm_form;
|
164 |
+
|
165 |
+
if(!$values)
|
166 |
+
$values = $_POST;
|
167 |
+
$errors = $frm_form->validate($values);
|
168 |
+
$id = isset($values['id']) ? (int)$values['id'] : (int)FrmAppHelper::get_param('id');
|
169 |
if( count($errors) > 0 ){
|
170 |
+
return self::get_edit_vars($id, $errors);
|
171 |
}else{
|
172 |
+
$record = $frm_form->update( $id, $values );
|
173 |
$message = __('Form was Successfully Updated', 'formidable');
|
174 |
+
return self::get_edit_vars($id, '', $message);
|
175 |
}
|
176 |
}
|
177 |
|
178 |
+
public static function duplicate(){
|
179 |
global $frm_form;
|
180 |
|
181 |
+
$params = self::get_params();
|
182 |
$record = $frm_form->duplicate( $params['id'], $params['template'], true );
|
183 |
$message = ($params['template']) ? __('Form template was Successfully Created', 'formidable') : __('Form was Successfully Copied', 'formidable');
|
184 |
if ($record)
|
185 |
+
return self::get_edit_vars($record, '', $message, true);
|
186 |
else
|
187 |
+
return self::display_forms_list($params, __('There was a problem creating new template.', 'formidable'));
|
188 |
}
|
189 |
|
190 |
+
public static function page_preview(){
|
191 |
global $frm_form;
|
192 |
+
$params = self::get_params();
|
193 |
if (!$params['form']) return;
|
194 |
$form = $frm_form->getOne($params['form']);
|
195 |
if(!$form) return;
|
196 |
return FrmEntriesController::show_form($form->id, '', true, true);
|
197 |
}
|
198 |
|
199 |
+
public static function preview(){
|
200 |
do_action('frm_wp');
|
201 |
|
202 |
global $frm_form, $frm_settings, $frmpro_is_installed;
|
222 |
require(FRM_VIEWS_PATH.'/frm-entries/direct.php');
|
223 |
}
|
224 |
|
225 |
+
public static function destroy(){
|
226 |
if(!current_user_can('frm_delete_forms')){
|
227 |
global $frm_settings;
|
228 |
wp_die($frm_settings->admin_permission);
|
229 |
}
|
230 |
|
231 |
global $frm_form;
|
232 |
+
$params = self::get_params();
|
233 |
$message = '';
|
234 |
if ($frm_form->destroy( $params['id'] ))
|
235 |
$message = __('Form was Successfully Deleted', 'formidable');
|
236 |
+
self::display_forms_list($params, $message, '', 1);
|
237 |
}
|
238 |
|
239 |
+
public static function destroy_wo_fields(){
|
240 |
global $frm_field, $frm_form, $frmdb;
|
241 |
$id = $_POST['form_id'];
|
242 |
if ($frmdb->get_count($frmdb->fields, array('form_id' => $id)) <= 0)
|
244 |
die();
|
245 |
}
|
246 |
|
247 |
+
public static function submit_button_label($submit){
|
248 |
if (!$submit or empty($submit)){
|
249 |
global $frm_settings;
|
250 |
$submit = $frm_settings->submit_value;
|
252 |
return $submit;
|
253 |
}
|
254 |
|
255 |
+
public static function insert_form_button($content){
|
256 |
if(current_user_can('frm_view_forms'))
|
257 |
$content .= '<a href="#TB_inline?width=450&height=550&inlineId=frm_insert_form" class="thickbox" title="' . __("Add Formidable Form", 'formidable') . '"><img src="'.FRM_IMAGES_URL.'/form_16.png" alt="' . __("Add Formidable Form", 'formidable') . '" /></a>';
|
258 |
return $content;
|
259 |
}
|
260 |
|
261 |
+
public static function show_form_button($id){
|
262 |
if($id != 'content')
|
263 |
return;
|
264 |
echo '<a href="#TB_inline?width=450&height=550&inlineId=frm_insert_form" class="thickbox" title="' . __("Add Formidable Form", 'formidable') . '"><img src="'. esc_url(FRM_IMAGES_URL.'/form_16.png'). '" alt="' . __("Add Formidable Form", 'formidable') . '" /></a>';
|
265 |
}
|
266 |
|
267 |
+
public static function insert_form_popup(){
|
268 |
$page = basename($_SERVER['PHP_SELF']);
|
269 |
if(in_array($page, array('post.php', 'page.php', 'page-new.php', 'post-new.php')) or (isset($_GET) and isset($_GET['page']) and $_GET['page'] == 'formidable-entry-templates')){
|
270 |
if(class_exists('FrmProDisplay')){
|
275 |
}
|
276 |
}
|
277 |
|
278 |
+
public static function display_forms_list($params=false, $message='', $page_params_ov = false, $current_page_ov = false, $errors = array()){
|
279 |
+
global $wpdb, $frmdb, $frm_form, $frm_entry, $frm_page_size, $frmpro_is_installed;
|
280 |
|
281 |
if(!$params)
|
282 |
+
$params = self::get_params();
|
283 |
|
284 |
if($message=='')
|
285 |
$message = FrmAppHelper::frm_get_main_message();
|
306 |
$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
|
307 |
if ( $pagenum > $total_pages && $total_pages > 0 ) {
|
308 |
wp_redirect( add_query_arg( 'paged', $total_pages ) );
|
309 |
+
die();
|
310 |
}
|
311 |
|
312 |
if ( ! empty( $_REQUEST['s'] ) )
|
315 |
|
316 |
$where_clause = " (status is NULL OR status = '' OR status = 'published') AND default_template=0 AND is_template = ".$params['template'];
|
317 |
|
318 |
+
$form_vars = self::get_form_sort_vars($params, $where_clause);
|
319 |
|
320 |
$current_page = ($current_page_ov) ? $current_page_ov : $params['paged'];
|
321 |
$page_params .= ($page_params_ov) ? $page_params_ov : $form_vars['page_params'];
|
324 |
$sdir_str = $form_vars['sdir_str'];
|
325 |
$search_str = $form_vars['search_str'];
|
326 |
|
327 |
+
$record_count = FrmAppHelper::getRecordCount($form_vars['where_clause'], $frmdb->forms);
|
328 |
+
$page_count = FrmAppHelper::getPageCount($frm_page_size, $record_count, $frmdb->forms);
|
329 |
+
$forms = FrmAppHelper::getPage($current_page, $frm_page_size, $form_vars['where_clause'], $form_vars['order_by'], $frmdb->forms);
|
330 |
+
$page_last_record = FrmAppHelper::getLastRecordNum($record_count,$current_page,$frm_page_size);
|
331 |
+
$page_first_record = FrmAppHelper::getFirstRecordNum($record_count,$current_page,$frm_page_size);
|
332 |
}
|
333 |
|
334 |
require(FRM_VIEWS_PATH.'/frm-forms/list.php');
|
335 |
}
|
336 |
|
337 |
+
public static function get_form_sort_vars($params,$where_clause = ''){
|
338 |
$order_by = '';
|
339 |
$page_params = '';
|
340 |
|
388 |
return compact('order_by', 'sort_str', 'sdir_str', 'search_str', 'where_clause', 'page_params');
|
389 |
}
|
390 |
|
391 |
+
public static function get_columns($columns){
|
392 |
$columns['cb'] = '<input type="checkbox" />';
|
393 |
$columns['id'] = 'ID';
|
394 |
$columns['name'] = __('Name', 'formidable');
|
409 |
return $columns;
|
410 |
}
|
411 |
|
412 |
+
public static function get_sortable_columns() {
|
413 |
return array(
|
414 |
'id' => 'id',
|
415 |
'name' => 'name',
|
419 |
);
|
420 |
}
|
421 |
|
422 |
+
public static function hidden_columns($result){
|
423 |
$return = false;
|
424 |
foreach((array)$result as $r){
|
425 |
if(!empty($r)){
|
440 |
return $result;
|
441 |
}
|
442 |
|
443 |
+
public static function save_per_page($save, $option, $value){
|
444 |
if($option == 'formidable_page_formidable_per_page' or $option == 'formidable_page_formidable_templates_per_page')
|
445 |
$save = (int)$value;
|
446 |
return $save;
|
447 |
}
|
448 |
|
449 |
+
public static function get_edit_vars($id, $errors = '', $message='', $create_link=false){
|
450 |
+
global $frm_entry, $frm_form, $frm_field, $frmpro_is_installed;
|
451 |
$record = $frm_form->getOne( $id );
|
452 |
$frm_field_selection = FrmFieldsHelper::field_selection();
|
453 |
$fields = $frm_field->getAll(array('fi.form_id' => $record->id), 'field_order');
|
459 |
|
460 |
if (isset($values['default_template']) && $values['default_template'])
|
461 |
wp_die(__('That template cannot be edited', 'formidable'));
|
462 |
+
else if(defined('DOING_AJAX'))
|
463 |
+
die();
|
464 |
else if($create_link)
|
465 |
require(FRM_VIEWS_PATH.'/frm-forms/new.php');
|
466 |
else
|
467 |
require(FRM_VIEWS_PATH.'/frm-forms/edit.php');
|
468 |
}
|
469 |
|
470 |
+
public static function get_settings_vars($id, $errors = '', $message=''){
|
471 |
+
global $frm_entry, $frm_form, $frm_field, $frmpro_is_installed;
|
472 |
$record = $frm_form->getOne( $id );
|
473 |
$fields = $frm_field->getAll(array('fi.form_id' => $id), 'field_order');
|
474 |
$values = FrmAppHelper::setup_edit_vars($record, 'forms', $fields, true);
|
480 |
require(FRM_VIEWS_PATH.'/frm-forms/settings.php');
|
481 |
}
|
482 |
|
483 |
+
public static function get_params(){
|
484 |
$values = array();
|
485 |
foreach (array('template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '') as $var => $default)
|
486 |
$values[$var] = FrmAppHelper::get_param($var, $default);
|
488 |
return $values;
|
489 |
}
|
490 |
|
491 |
+
public static function add_default_templates($path, $default=true, $template=true){
|
492 |
global $frm_form, $frm_field;
|
493 |
$templates = glob($path."/*.php");
|
494 |
|
509 |
}
|
510 |
}
|
511 |
|
512 |
+
public static function route(){
|
513 |
$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
|
514 |
+
$vars = false;
|
515 |
+
if(isset($_POST['frm_compact_fields'])){
|
516 |
+
if(!current_user_can('frm_edit_forms') and !is_super_admin()){
|
517 |
+
global $frm_settings;
|
518 |
+
wp_die($frm_settings->admin_permission);
|
519 |
+
}
|
520 |
+
$json_vars = htmlspecialchars_decode(nl2br(stripslashes($_POST['frm_compact_fields'])));
|
521 |
+
$json_vars = json_decode($json_vars, true);
|
522 |
+
$vars = FrmAppHelper::json_to_array($json_vars);
|
523 |
+
$action = $vars[$action];
|
524 |
+
}else{
|
525 |
+
$action = FrmAppHelper::get_param($action);
|
526 |
+
}
|
527 |
|
528 |
if($action == 'new')
|
529 |
+
return self::new_form($vars);
|
530 |
else if($action == 'create')
|
531 |
+
return self::create($vars);
|
532 |
else if($action == 'edit')
|
533 |
+
return self::edit($vars);
|
534 |
else if($action == 'update')
|
535 |
+
return self::update($vars);
|
536 |
else if($action == 'duplicate')
|
537 |
+
return self::duplicate();
|
538 |
else if($action == 'destroy')
|
539 |
+
return self::destroy();
|
540 |
else if($action == 'list-form')
|
541 |
+
return self::list_form();
|
542 |
else if($action == 'settings')
|
543 |
+
return self::settings();
|
544 |
else if($action == 'update_settings')
|
545 |
+
return self::update_settings();
|
546 |
else if($action == 'translate' or $action == 'update_translate')
|
547 |
+
return self::translate($action);
|
548 |
else{
|
549 |
$action = FrmAppHelper::get_param('action');
|
550 |
if($action == -1)
|
556 |
if(isset($_GET) and isset($_GET['action2']))
|
557 |
$_SERVER['REQUEST_URI'] = str_replace('&action='.$_GET['action2'], '', $_SERVER['REQUEST_URI']);
|
558 |
|
559 |
+
return self::list_form();
|
560 |
}else{
|
561 |
+
return self::display_forms_list();
|
562 |
}
|
563 |
}
|
564 |
}
|
classes/controllers/FrmSettingsController.php
CHANGED
@@ -5,15 +5,17 @@
|
|
5 |
|
6 |
class FrmSettingsController{
|
7 |
function FrmSettingsController(){
|
8 |
-
add_action('admin_menu',
|
9 |
}
|
10 |
|
11 |
-
function menu(){
|
12 |
-
add_submenu_page('formidable', 'Formidable | '. __('Global Settings', 'formidable'), __('Global Settings', 'formidable'), 'frm_change_settings', 'formidable-settings',
|
13 |
}
|
14 |
|
15 |
-
function display_form(){
|
16 |
-
global $frm_settings, $
|
|
|
|
|
17 |
$frm_roles = FrmAppHelper::frm_capabilities();
|
18 |
|
19 |
$uploads = wp_upload_dir();
|
@@ -23,9 +25,10 @@ class FrmSettingsController{
|
|
23 |
require(FRM_VIEWS_PATH . '/frm-settings/form.php');
|
24 |
}
|
25 |
|
26 |
-
function process_form(){
|
27 |
-
global $frm_settings, $
|
28 |
|
|
|
29 |
//$errors = $frm_settings->validate($_POST,array());
|
30 |
$errors = array();
|
31 |
$frm_settings->update($_POST);
|
@@ -40,12 +43,12 @@ class FrmSettingsController{
|
|
40 |
require(FRM_VIEWS_PATH . '/frm-settings/form.php');
|
41 |
}
|
42 |
|
43 |
-
function route(){
|
44 |
$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
|
45 |
$action = FrmAppHelper::get_param($action);
|
46 |
if($action == 'process-form')
|
47 |
-
return
|
48 |
else
|
49 |
-
return
|
50 |
}
|
51 |
}
|
5 |
|
6 |
class FrmSettingsController{
|
7 |
function FrmSettingsController(){
|
8 |
+
add_action('admin_menu', 'FrmSettingsController::menu', 26);
|
9 |
}
|
10 |
|
11 |
+
public static function menu(){
|
12 |
+
add_submenu_page('formidable', 'Formidable | '. __('Global Settings', 'formidable'), __('Global Settings', 'formidable'), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route');
|
13 |
}
|
14 |
|
15 |
+
public static function display_form(){
|
16 |
+
global $frm_settings, $frmpro_is_installed;
|
17 |
+
|
18 |
+
$frm_update = new FrmUpdatesController();
|
19 |
$frm_roles = FrmAppHelper::frm_capabilities();
|
20 |
|
21 |
$uploads = wp_upload_dir();
|
25 |
require(FRM_VIEWS_PATH . '/frm-settings/form.php');
|
26 |
}
|
27 |
|
28 |
+
public static function process_form(){
|
29 |
+
global $frm_settings, $frmpro_is_installed;
|
30 |
|
31 |
+
$frm_update = new FrmUpdatesController();
|
32 |
//$errors = $frm_settings->validate($_POST,array());
|
33 |
$errors = array();
|
34 |
$frm_settings->update($_POST);
|
43 |
require(FRM_VIEWS_PATH . '/frm-settings/form.php');
|
44 |
}
|
45 |
|
46 |
+
public static function route(){
|
47 |
$action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
|
48 |
$action = FrmAppHelper::get_param($action);
|
49 |
if($action == 'process-form')
|
50 |
+
return self::process_form();
|
51 |
else
|
52 |
+
return self::display_form();
|
53 |
}
|
54 |
}
|
classes/controllers/FrmStatisticsController.php
CHANGED
@@ -2,25 +2,25 @@
|
|
2 |
|
3 |
class FrmStatisticsController{
|
4 |
function FrmStatisticsController(){
|
5 |
-
add_action('admin_menu',
|
6 |
}
|
7 |
|
8 |
-
function menu(){
|
9 |
global $frmpro_is_installed;
|
10 |
if($frmpro_is_installed)
|
11 |
return;
|
12 |
|
13 |
-
add_submenu_page('formidable', 'Formidable | '. __('Custom Displays', 'formidable'), '<span style="opacity:.5;filter:alpha(opacity=50);">'. __('Custom Displays', 'formidable') .'</span>', 'administrator', 'formidable-entry-templates',
|
14 |
|
15 |
-
add_submenu_page('formidable', 'Formidable | '. __('Reports', 'formidable'), '<span style="opacity:.5;filter:alpha(opacity=50);">'. __('Reports', 'formidable') .'</span>', 'administrator', 'formidable-reports',
|
16 |
}
|
17 |
|
18 |
-
function list_reports(){
|
19 |
$form = FrmAppHelper::get_param('form', false);
|
20 |
require(FRM_VIEWS_PATH . '/frm-statistics/list.php');
|
21 |
}
|
22 |
|
23 |
-
function list_displays(){
|
24 |
$form = FrmAppHelper::get_param('form', false);
|
25 |
require(FRM_VIEWS_PATH . '/frm-statistics/list_displays.php');
|
26 |
}
|
2 |
|
3 |
class FrmStatisticsController{
|
4 |
function FrmStatisticsController(){
|
5 |
+
add_action('admin_menu', 'FrmStatisticsController::menu', 24);
|
6 |
}
|
7 |
|
8 |
+
public static function menu(){
|
9 |
global $frmpro_is_installed;
|
10 |
if($frmpro_is_installed)
|
11 |
return;
|
12 |
|
13 |
+
add_submenu_page('formidable', 'Formidable | '. __('Custom Displays', 'formidable'), '<span style="opacity:.5;filter:alpha(opacity=50);">'. __('Custom Displays', 'formidable') .'</span>', 'administrator', 'formidable-entry-templates', 'FrmStatisticsController::list_displays');
|
14 |
|
15 |
+
add_submenu_page('formidable', 'Formidable | '. __('Reports', 'formidable'), '<span style="opacity:.5;filter:alpha(opacity=50);">'. __('Reports', 'formidable') .'</span>', 'administrator', 'formidable-reports', 'FrmStatisticsController::list_reports');
|
16 |
}
|
17 |
|
18 |
+
public static function list_reports(){
|
19 |
$form = FrmAppHelper::get_param('form', false);
|
20 |
require(FRM_VIEWS_PATH . '/frm-statistics/list.php');
|
21 |
}
|
22 |
|
23 |
+
public static function list_displays(){
|
24 |
$form = FrmAppHelper::get_param('form', false);
|
25 |
require(FRM_VIEWS_PATH . '/frm-statistics/list_displays.php');
|
26 |
}
|
classes/controllers/FrmUpdatesController.php
ADDED
@@ -0,0 +1,538 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|