Toolset Types – Custom Post Types, Custom Fields and Taxonomies - Version 1.7

Version Description

  • Added the word "mode" to the list of words reserved by WordPress. https://wp-types.com/forums/topic/when-types-is-activated-i-cant-filter-articles-by-category-in-the-wp-backend/
  • Added the feature that automatically creates a slug for the Custom Post Type and Custom Taxonomy.
  • Added bulk delete options to Custom Field Groups listing page.
  • Added bulk delete options to Custom Post Types listing page.
  • Added bulk delete options to Custom Taxonomies listing page.
  • Added the automatic check of availability for the "Title" and "Editor" fields in the child relationship dialog.
  • Added the duplicate option for Custom Post Type and Custom Taxonomy.
  • Added the "Excerpt" field to the Child Posts table.
  • Added the "wpcf_field_image_max_width" filter which allows user to change image width on admin listing pages.
  • Added the option to specify the custom archive slug for the Custom Post Type http://wp-types.com/forums/topic/specify-cpt-archive-slug-as-string/
  • All custom fields on Custom Post Type listing pages are now sortable.
  • Changes to the Types fields GUI for easier support.
  • Fixed a problem with Custom Post Type, Custom Taxonomy and Custom Fields Group editing pages where forms would "freeze" after validation fails.
  • Fixed a problem with selecting an image for the Custom Image Field in the Child Posts table, after using the "Add New", "Save All" and "Save" buttons. https://wp-types.com/forums/topic/featured-image-cannot-be-changed-after-first-save/
  • Fixed a problem with multi-line field not being wrapped with P (paragraph) HTML tag https://wp-types.com/forums/topic/multi-line-text-fields-are-missing-paragraph-tags/
  • Fixed problem with fields being covered by colorbox on the Custom Post Type editing page.
  • Fixed an issue where a wrong message was displayed when minimum number of characters has not been reached.
Download this release

Release Info

Developer iworks
Plugin Icon 128x128 Toolset Types – Custom Post Types, Custom Fields and Taxonomies
Version 1.7
Comparing to
See all releases

Code changes from version 1.6.2 to 1.7

Files changed (120) hide show
  1. admin.php +1184 -976
  2. classes/class.wpcf-marketing-messages.php +360 -0
  3. classes/class.wpcf-marketing-tutorial.php +243 -0
  4. classes/class.wpcf-marketing.php +227 -0
  5. embedded/admin.php +29 -58
  6. embedded/bootstrap.php +17 -10
  7. embedded/classes/class.wpcf-post-types.php +373 -4
  8. embedded/classes/editor.php +2 -4
  9. embedded/classes/field.php +77 -82
  10. embedded/classes/fields.php +0 -4
  11. embedded/classes/forms.php +12 -8
  12. embedded/classes/loader.php +17 -18
  13. embedded/classes/path.php +0 -4
  14. embedded/classes/post-types/messages.php +0 -4
  15. embedded/classes/relationship.php +106 -27
  16. embedded/classes/relationship/form-child.php +209 -105
  17. embedded/classes/repeater.php +58 -55
  18. embedded/classes/usermeta_field.php +16 -20
  19. embedded/classes/usermeta_repeater.php +46 -43
  20. embedded/classes/validate.php +24 -1
  21. embedded/classes/validation-cakephp.php +23 -0
  22. embedded/classes/wpviews.php +96 -46
  23. embedded/common/changelog.txt +28 -0
  24. embedded/common/classes/class-toolset-admin-bar-menu.php +732 -0
  25. embedded/common/classes/class.toolset.promo.php +193 -0
  26. embedded/common/classes/forms.php +14 -11
  27. embedded/common/classes/validation-cakephp.php +1102 -1089
  28. embedded/common/debug/debug-information.php +0 -4
  29. embedded/common/debug/functions_debug_information.php +41 -35
  30. embedded/common/expression-parser/js/parser.js +14 -14
  31. embedded/common/expression-parser/parser.php +15 -15
  32. embedded/common/functions.php +50 -99
  33. embedded/common/localization/locale/views-ar.mo +0 -0
  34. embedded/common/localization/locale/views-de_DE.mo +0 -0
  35. embedded/common/localization/locale/views-el.mo +0 -0
  36. embedded/common/localization/locale/views-es_ES.mo +0 -0
  37. embedded/common/localization/locale/views-fr_FR.mo +0 -0
  38. embedded/common/localization/locale/views-he_IL.mo +0 -0
  39. embedded/common/localization/locale/views-it_IT.mo +0 -0
  40. embedded/common/localization/locale/views-ja.mo +0 -0
  41. embedded/common/localization/locale/views-ko_KR.mo +0 -0
  42. embedded/common/localization/locale/views-nl_NL.mo +0 -0
  43. embedded/common/localization/locale/views-pl_PL.mo +0 -0
  44. embedded/common/localization/locale/views-pt_BR.mo +0 -0
  45. embedded/common/localization/locale/views-pt_PT.mo +0 -0
  46. embedded/common/localization/locale/views-ru_RU.mo +0 -0
  47. embedded/common/localization/locale/views-sv_SE.mo +0 -0
  48. embedded/common/localization/locale/views-uk.mo +0 -0
  49. embedded/common/localization/locale/views-vi.mo +0 -0
  50. embedded/common/localization/locale/views-zh_CN.mo +0 -0
  51. embedded/common/localization/locale/views-zh_TW.mo +0 -0
  52. embedded/common/res/css/colorbox.css +88 -0
  53. embedded/common/res/css/toolset-common.css +15 -3
  54. embedded/common/res/css/toolset-promotion.css +164 -0
  55. embedded/common/res/images/toolset.promotion/full.jpg +0 -0
  56. embedded/common/res/images/toolset.promotion/icons.png +0 -0
  57. embedded/common/res/images/toolset.promotion/toolset.png +0 -0
  58. embedded/common/res/js/jquery.colorbox-min.js +7 -0
  59. embedded/common/res/js/toolset-promotion.js +47 -0
  60. embedded/common/toolset-forms/api.php +36 -2
  61. embedded/common/toolset-forms/bootstrap.php +211 -111
  62. embedded/common/toolset-forms/classes/class.audio.php +0 -4
  63. embedded/common/toolset-forms/classes/class.checkbox.php +11 -8
  64. embedded/common/toolset-forms/classes/class.checkboxes.php +27 -12
  65. embedded/common/toolset-forms/classes/class.colorpicker.php +32 -18
  66. embedded/common/toolset-forms/classes/class.conditional.php +204 -207
  67. embedded/common/toolset-forms/classes/class.credaudio.php +0 -4
  68. embedded/common/toolset-forms/classes/class.credfile.php +83 -45
  69. embedded/common/toolset-forms/classes/class.credimage.php +0 -4
  70. embedded/common/toolset-forms/classes/class.credvideo.php +0 -4
  71. embedded/common/toolset-forms/classes/class.date.php +246 -218
  72. embedded/common/toolset-forms/classes/class.date.scripts.php +14 -3
  73. embedded/common/toolset-forms/classes/class.eforms.php +276 -329
  74. embedded/common/toolset-forms/classes/class.field_factory.php +31 -6
  75. embedded/common/toolset-forms/classes/class.fieldconfig.php +40 -31
  76. embedded/common/toolset-forms/classes/class.file.php +82 -123
  77. embedded/common/toolset-forms/classes/class.form_factory.php +73 -17
  78. embedded/common/toolset-forms/classes/class.image.php +15 -8
  79. embedded/common/toolset-forms/classes/class.integer.php +12 -0
  80. embedded/common/toolset-forms/classes/class.password.php +0 -4
  81. embedded/common/toolset-forms/classes/class.radios.php +33 -12
  82. embedded/common/toolset-forms/classes/class.recaptcha.php +7 -6
  83. embedded/common/toolset-forms/classes/class.repetitive.php +0 -4
  84. embedded/common/toolset-forms/classes/class.select.php +23 -8
  85. embedded/common/toolset-forms/classes/class.skype.php +28 -23
  86. embedded/common/toolset-forms/classes/class.submit.php +37 -29
  87. embedded/common/toolset-forms/classes/class.taxonomy.php +13 -39
  88. embedded/common/toolset-forms/classes/class.taxonomyhierarchical.php +132 -134
  89. embedded/common/toolset-forms/classes/class.textarea.php +0 -4
  90. embedded/common/toolset-forms/classes/class.textfield.php +2 -7
  91. embedded/common/toolset-forms/classes/class.types.php +19 -21
  92. embedded/common/toolset-forms/classes/class.validation.php +24 -20
  93. embedded/common/toolset-forms/classes/class.video.php +40 -8
  94. embedded/common/toolset-forms/classes/class.wysiwyg.php +7 -11
  95. embedded/common/toolset-forms/classes/submit.php +98 -0
  96. embedded/common/toolset-forms/css/wpt-jquery-ui/datepicker.css +1 -1
  97. embedded/common/toolset-forms/css/wpt-toolset-backend.css +4 -2
  98. embedded/common/toolset-forms/css/wpt-toolset-frontend.css +19 -31
  99. embedded/common/toolset-forms/external/autocompleter.php +0 -53
  100. embedded/common/toolset-forms/js/colorpicker.js +1 -0
  101. embedded/common/toolset-forms/js/conditional.js +550 -403
  102. embedded/common/toolset-forms/js/credfile.js +61 -60
  103. embedded/common/toolset-forms/js/date.js +108 -60
  104. embedded/common/toolset-forms/js/file-wp35.js +107 -0
  105. embedded/common/toolset-forms/js/file.js +0 -68
  106. embedded/common/toolset-forms/js/img/loading.gif +0 -0
  107. embedded/common/toolset-forms/js/img/progressbar.gif +0 -0
  108. embedded/common/toolset-forms/js/jquery.autocomplete.js +0 -507
  109. embedded/common/toolset-forms/js/jquery_upload/file_upload.js +304 -0
  110. embedded/common/toolset-forms/js/jquery_upload/jquery-ui.min.js +13 -0
  111. embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-audio.js +106 -0
  112. embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-image.js +315 -0
  113. embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-jquery-ui.js +152 -0
  114. embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-process.js +172 -0
  115. embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-ui.css +57 -0
  116. embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-ui.js +704 -0
  117. embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-validate.js +119 -0
  118. embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-video.js +106 -0
  119. embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload.css +247 -0
  120. embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload.js +329 -0
admin.php CHANGED
@@ -1,998 +1,1108 @@
1
- <?php
2
- /**
3
- *
4
- * Admin functions
5
- *
6
- * $HeadURL: https://www.onthegosystems.com/misc_svn/cck/tags/1.6.2/admin.php $
7
- * $LastChangedDate: 2014-08-12 04:19:36 +0200 (Tue, 12 Aug 2014) $
8
- * $LastChangedRevision: 25849 $
9
- * $LastChangedBy: bruce $
10
- *
11
- */
12
- require_once WPCF_ABSPATH . '/marketing.php';
13
- /*
14
- * This needs to be called after main 'init' hook.
15
- * Main init hook calls required Types code for frontend.
16
- * Admin init hook only in admin area.
17
- *
18
- * TODO Revise it to change to 'admin_init'
19
- */
20
- add_action( 'admin_init', 'wpcf_admin_init_hook', 11 );
21
- add_action( 'admin_menu', 'wpcf_admin_menu_hook' );
22
- add_action( 'wpcf_admin_page_init', 'wpcf_enqueue_scripts' );
23
-
24
- wpcf_admin_load_teasers( array('types-access.php') );
25
- if ( defined( 'DOING_AJAX' ) ) {
26
- require_once WPCF_INC_ABSPATH . '/ajax.php';
27
- }
28
-
29
- /**
30
- * admin_init hook.
31
- */
32
- function wpcf_admin_init_hook() {
33
- wpcf_types_plugin_redirect();
34
- wp_enqueue_style( 'wpcf-promo-tabs',
35
- WPCF_EMBEDDED_RES_RELPATH . '/css/tabs.css', array(), WPCF_VERSION );
36
- /* wp_enqueue_style('wpcf-promo-tabs',
37
- WPCF_RES_RELPATH . '/css/tabs.css', array(), WPCF_VERSION); */
38
- wp_enqueue_style('toolset-dashicons');
39
- }
40
-
41
- /**
42
- * admin_menu hook.
43
- */
44
- function wpcf_admin_menu_hook()
45
- {
46
- $wpcf_capability = apply_filters( 'wpcf_capability', 'manage_options' );
47
-
48
- add_menu_page(
49
- __( 'Types', 'wpcf' ),
50
- __( 'Types', 'wpcf' ),
51
- $wpcf_capability,
52
- 'wpcf',
53
- 'wpcf_admin_menu_summary',
54
- 'none'
55
- );
56
-
57
- $subpages = array(
58
-
59
- // Custom types and tax
60
- 'wpcf-ctt' => array(
61
- 'page_title' => __( 'Custom Types and Taxonomies', 'wpcf' ),
62
- 'menu_title' => __( 'Types &amp; Taxonomies', 'wpcf' ),
63
- 'function' => 'wpcf_admin_menu_summary_ctt',
64
- ),
65
-
66
- // Custom fields
67
- 'wpcf-cf' => array(
68
- 'page_title' => __( 'Custom Fields', 'wpcf' ),
69
- 'menu_title' => __( 'Custom Fields', 'wpcf' ),
70
- 'function' => 'wpcf_admin_menu_summary',
71
- ),
72
- // Custom Fields Control
73
- 'wpcf-custom-fields-control' => array(
74
- 'page_title' => __( 'Custom Fields Control', 'wpcf' ),
75
- 'menu_title' => __( 'Custom Fields Control', 'wpcf' ),
76
- 'function' => 'wpcf_admin_menu_custom_fields_control',
77
- ),
78
- // User Meta
79
- 'wpcf-um' => array(
80
- 'page_title' => __( 'User Fields', 'wpcf' ),
81
- 'menu_title' => __( 'User Fields', 'wpcf' ),
82
- 'function' => 'wpcf_usermeta_summary',
83
- 'load-hook' => 'wpcf_admin_menu_summary_hook',
84
- ),
85
- // User Fields Control
86
- 'wpcf-user-fields-control' => array(
87
- 'page_title' => __( 'User Fields Control', 'wpcf' ),
88
- 'menu_title' => __( 'User Fields Control', 'wpcf' ),
89
- 'function' => 'wpcf_admin_menu_user_fields_control',
90
- ),
91
-
92
- // Import/Export
93
- 'wpcf-import-export' => array(
94
- 'page_title' => __( 'Import/Export', 'wpcf' ),
95
- 'menu_title' => __( 'Import/Export', 'wpcf' ),
96
- 'function' => 'wpcf_admin_menu_import_export',
97
- ),
98
- // Settings
99
- 'wpcf-custom-settings' => array(
100
- 'page_title' => __( 'Settings', 'wpcf' ),
101
- 'menu_title' => __( 'Settings', 'wpcf' ),
102
- 'function' => 'wpcf_admin_menu_settings',
103
- ),
104
-
105
- // Introduction
106
- 'wpcf-help' => array(
107
- 'page_title' => __( 'Help', 'wpcf' ),
108
- 'menu_title' => __( 'Help', 'wpcf' ),
109
- 'function' => 'wpcf_admin_menu_introduction',
110
- 'submenu' => array(
111
- 'wpcf-debug-information' => array(
112
- 'page_title' => __( 'Debug information', 'wpcf' ),
113
- 'menu_title' => __( 'Debug information', 'wpcf' ),
114
- 'function' => 'wpcf_admin_menu_debug_information',
115
- ),
 
116
  ),
117
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  );
 
 
 
 
 
 
 
 
120
 
121
- foreach( $subpages as $menu_slug => $data ) {
122
- $hook = add_submenu_page(
123
- 'wpcf',
124
- $data['page_title'],
125
- $data['menu_title'],
126
- $wpcf_capability,
127
- $menu_slug,
128
- $data['function']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  );
130
- if ( array_key_exists('submenu', $data ) ) {
131
- foreach( $data['submenu'] as $submenu_slug => $submenu ) {
132
- add_submenu_page(
133
- $hook,
134
- $submenu['page_title'],
135
- $submenu['menu_title'],
136
- $wpcf_capability,
137
- $submenu_slug,
138
- $submenu['function']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  );
 
140
  }
 
 
141
  }
142
- if ( !array_key_exists('load-hook', $data ) ) {
143
- $data['load-hook'] = sprintf( '%s_hook', $data['function'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  }
145
- wpcf_admin_plugin_help( $hook, $menu_slug );
146
- add_action( 'load-' . $hook, $data['load-hook'] );
147
- }
148
-
149
- if ( isset( $_GET['page'] ) ) {
150
- switch ( $_GET['page'] ) {
151
- case 'wpcf-edit':
152
- $title = isset( $_GET['group_id'] ) ? __( 'Edit Group', 'wpcf' ) : __( 'Add New Group',
153
- 'wpcf' );
154
- $hook = add_submenu_page( 'wpcf', $title, $title,
155
- 'manage_options', 'wpcf-edit',
156
- 'wpcf_admin_menu_edit_fields' );
157
- add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_fields_hook' );
158
- wpcf_admin_plugin_help( $hook, 'wpcf-edit' );
159
- break;
160
-
161
- case 'wpcf-edit-type':
162
- $title = isset( $_GET['wpcf-post-type'] ) ? __( 'Edit Custom Post Type',
163
- 'wpcf' ) : __( 'Add New Custom Post Type',
164
- 'wpcf' );
165
- $hook = add_submenu_page( 'wpcf', $title, $title,
166
- 'manage_options', 'wpcf-edit-type',
167
- 'wpcf_admin_menu_edit_type' );
168
- add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_type_hook' );
169
- wpcf_admin_plugin_help( $hook, 'wpcf-edit-type' );
170
- break;
171
-
172
- case 'wpcf-edit-tax':
173
- $title = isset( $_GET['wpcf-tax'] ) ? __( 'Edit Taxonomy',
174
- 'wpcf' ) : __( 'Add New Taxonomy', 'wpcf' );
175
- $hook = add_submenu_page( 'wpcf', $title, $title,
176
- 'manage_options', 'wpcf-edit-tax',
177
- 'wpcf_admin_menu_edit_tax' );
178
- add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_tax_hook' );
179
- wpcf_admin_plugin_help( $hook, 'wpcf-edit-tax' );
180
- break;
181
- case 'wpcf-edit-usermeta':
182
- $title = isset( $_GET['group_id'] ) ? __( 'Edit User Fields Group', 'wpcf' ) : __( 'Add New User Fields Group',
183
- 'wpcf' );
184
- $hook = add_submenu_page( 'wpcf', $title, $title,
185
- 'manage_options', 'wpcf-edit-usermeta',
186
- 'wpcf_admin_menu_edit_user_fields' );
187
- add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_user_fields_hook' );
188
- wpcf_admin_plugin_help( $hook, 'wpcf-edit-usermeta' );
189
- break;
190
- }
191
- }
192
-
193
- // Check if migration from other plugin is needed
194
- if ( class_exists( 'Acf' ) || defined( 'CPT_VERSION' ) ) {
195
- $hook = add_submenu_page( 'wpcf', __( 'Migration', 'wpcf' ),
196
- __( 'Migration', 'wpcf' ), 'manage_options', 'wpcf-migration',
197
- 'wpcf_admin_menu_migration' );
198
- add_action( 'load-' . $hook, 'wpcf_admin_menu_migration_hook' );
199
- wpcf_admin_plugin_help( $hook, 'wpcf-migration' );
200
- }
201
-
202
- do_action( 'wpcf_menu_plus' );
203
-
204
- // remove the repeating Types submenu
205
- remove_submenu_page( 'wpcf', 'wpcf' );
206
- }
207
-
208
- /**
209
- * Menu page hook.
210
- */
211
- function wpcf_admin_menu_introduction_hook() {
212
- do_action( 'wpcf_admin_page_init' );
213
- }
214
-
215
- /**
216
- * Menu page display.
217
- */
218
- function wpcf_admin_menu_introduction() {
219
- require_once WPCF_INC_ABSPATH . '/introduction.php';
220
  }
221
 
222
  /**
223
- * Menu page hook.
224
  */
225
- function wpcf_admin_menu_debug_information()
226
  {
227
- require_once WPCF_EMBEDDED_ABSPATH.'/common/debug/debug-information.php';
 
 
 
 
 
 
 
 
 
228
  }
229
 
230
  /**
231
- * Menu page hook.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
232
  */
233
- function wpcf_admin_menu_summary_hook() {
234
- do_action( 'wpcf_admin_page_init' );
235
- wpcf_admin_load_collapsible();
236
- }
237
-
238
- /**
239
- * Menu page display.
240
- */
241
- function wpcf_admin_menu_summary() {
242
- echo wpcf_add_admin_header( __( 'Custom Fields', 'wpcf' ) );
243
- require_once WPCF_INC_ABSPATH . '/fields.php';
244
- require_once WPCF_INC_ABSPATH . '/fields-list.php';
245
- $to_display = wpcf_admin_fields_get_fields();
246
- if ( !empty( $to_display ) ) {
247
- add_action( 'wpcf_groups_list_table_after',
248
- 'wpcf_admin_promotional_text' );
249
- }
250
- wpcf_admin_fields_list();
251
- echo wpcf_add_admin_footer();
252
- }
253
-
254
- /**
255
- * Menu page hook.
256
- */
257
- function wpcf_admin_menu_edit_fields_hook() {
258
- do_action( 'wpcf_admin_page_init' );
259
-
260
- /*
261
- * Enqueue scripts
262
- */
263
- // Group filter
264
- wp_enqueue_script( 'wpcf-filter-js',
265
- WPCF_EMBEDDED_RES_RELPATH
266
- . '/js/custom-fields-form-filter.js', array('jquery'), WPCF_VERSION );
267
- // Form
268
- wp_enqueue_script( 'wpcf-form-validation',
269
- WPCF_EMBEDDED_RES_RELPATH . '/js/'
270
- . 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
271
- WPCF_VERSION );
272
- wp_enqueue_script( 'wpcf-form-validation-additional',
273
- WPCF_EMBEDDED_RES_RELPATH . '/js/'
274
- . 'jquery-form-validation/additional-methods.min.js',
275
- array('jquery'), WPCF_VERSION );
276
- // Scroll
277
- wp_enqueue_script( 'wpcf-scrollbar',
278
- WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/scrollbar.js',
279
- array('jquery') );
280
- wp_enqueue_script( 'wpcf-mousewheel',
281
- WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/mousewheel.js',
282
- array('wpcf-scrollbar') );
283
- // MAIN
284
- wp_enqueue_script( 'wpcf-fields-form',
285
- WPCF_EMBEDDED_RES_RELPATH
286
- . '/js/fields-form.js', array('wpcf-js') );
287
-
288
- /*
289
- * Enqueue styles
290
- */
291
- wp_enqueue_style( 'wpcf-scroll',
292
- WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/css/scroll.css' );
293
-
294
- //Css editor
295
- wp_enqueue_script( 'wpcf-form-codemirror' ,
296
- WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.js', array('wpcf-js'));
297
- wp_enqueue_script( 'wpcf-form-codemirror-css-editor' ,
298
- WPCF_RELPATH . '/resources/js/codemirror234/mode/css/css.js', array('wpcf-js'));
299
- wp_enqueue_script( 'wpcf-form-codemirror-html-editor' ,
300
- WPCF_RELPATH . '/resources/js/codemirror234/mode/xml/xml.js', array('wpcf-js'));
301
- wp_enqueue_script( 'wpcf-form-codemirror-html-editor2' ,
302
- WPCF_RELPATH . '/resources/js/codemirror234/mode/htmlmixed/htmlmixed.js', array('wpcf-js'));
303
- wp_enqueue_script( 'wpcf-form-codemirror-editor-resize' ,
304
- WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.resizable.min.js', array('wpcf-js'));
305
-
306
-
307
-
308
- wp_enqueue_style( 'wpcf-css-editor',
309
- WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.css' );
310
- wp_enqueue_style( 'wpcf-css-editor-resize',
311
- WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.theme.min.css' );
312
- wp_enqueue_style( 'wpcf-usermeta',
313
- WPCF_EMBEDDED_RES_RELPATH . '/css/usermeta.css' );
314
-
315
- add_action( 'admin_footer', 'wpcf_admin_fields_form_js_validation' );
316
- require_once WPCF_INC_ABSPATH . '/fields.php';
317
- require_once WPCF_INC_ABSPATH . '/fields-form.php';
318
- $form = wpcf_admin_fields_form();
319
- wpcf_form( 'wpcf_form_fields', $form );
320
- }
321
-
322
- /**
323
- * Menu page display.
324
- */
325
- function wpcf_admin_menu_edit_fields() {
326
- if ( isset( $_GET['group_id'] ) ) {
327
- $title = __( 'Edit Group', 'wpcf' );
328
- } else {
329
- $title = __( 'Add New Group', 'wpcf' );
330
- }
331
- echo wpcf_add_admin_header( $title );
332
- wpcf_wpml_warning();
333
- $form = wpcf_form( 'wpcf_form_fields' );
334
-
335
- ?>
336
- <script type="text/javascript">
337
- function wpcf_group_submit() {
338
- if (jQuery('#wpcf-group-name').val() == 'Enter group title') {
339
- jQuery('#wpcf-group-name').val('');
340
- }
341
- if (jQuery('#wpcf-group-description').val() == 'Enter a description for this group') {
342
- jQuery('#wpcf-group-description').val('');
343
- }
344
- jQuery('.wpcf-forms-set-legend').each(function(){
345
- if (jQuery(this).val() == 'Enter field name') {
346
- jQuery(this).val('');
347
- }
348
- if (jQuery(this).next().val() == 'Enter field slug') {
349
- jQuery(this).next().val('');
350
- }
351
- if (jQuery(this).next().next().val() == 'Describe this field') {
352
- jQuery(this).next().next().val('');
353
- }
354
- });
355
- }
356
- </script>
357
-
358
- <br /><form method="post" action="" class="wpcf-fields-form wpcf-form-validate" onsubmit="wpcf_group_submit()">
359
- <?php echo $form->renderForm(); ?>
360
- </form>
361
- <?php
362
- echo wpcf_add_admin_footer();
363
- }
364
-
365
- /**
366
- * Menu page hook.
367
- */
368
- function wpcf_admin_menu_summary_ctt_hook() {
369
- do_action( 'wpcf_admin_page_init' );
370
- wp_enqueue_style( 'wpcf-promo-tabs', WPCF_RES_RELPATH . '/css/tabs.css',
371
- array(), WPCF_VERSION );
372
- wpcf_admin_load_collapsible();
373
- require_once WPCF_INC_ABSPATH . '/custom-types.php';
374
- require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
375
- require_once WPCF_INC_ABSPATH . '/custom-types-taxonomies-list.php';
376
- }
377
-
378
- /**
379
- * Menu page display.
380
- */
381
- function wpcf_admin_menu_summary_ctt() {
382
- echo wpcf_add_admin_header( __( 'Custom Post Types and Taxonomies', 'wpcf' ) );
383
- $to_display_posts = get_option( 'wpcf-custom-types', array() );
384
- $to_display_tax = get_option( 'wpcf-custom-taxonomies', array() );
385
- if ( !empty( $to_display_posts ) || !empty( $to_display_tax ) ) {
386
- add_action( 'wpcf_types_tax_list_table_after',
387
- 'wpcf_admin_promotional_text' );
388
- }
389
- wpcf_admin_ctt_list();
390
- echo wpcf_add_admin_footer();
391
- }
392
-
393
- /**
394
- * Menu page hook.
395
- */
396
- function wpcf_admin_menu_edit_type_hook() {
397
- do_action( 'wpcf_admin_page_init' );
398
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-types.php';
399
- require_once WPCF_INC_ABSPATH . '/custom-types-form.php';
400
- require_once WPCF_INC_ABSPATH . '/post-relationship.php';
401
- wp_enqueue_script( 'wpcf-custom-types-form',
402
- WPCF_RES_RELPATH . '/js/'
403
- . 'custom-types-form.js', array('jquery'), WPCF_VERSION );
404
- wp_enqueue_script( 'wpcf-form-validation',
405
- WPCF_RES_RELPATH . '/js/'
406
- . 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
407
- WPCF_VERSION );
408
- wp_enqueue_script( 'wpcf-form-validation-additional',
409
- WPCF_RES_RELPATH . '/js/'
410
- . 'jquery-form-validation/additional-methods.min.js',
411
- array('jquery'), WPCF_VERSION );
412
- add_action( 'admin_footer', 'wpcf_admin_types_form_js_validation' );
413
- wpcf_post_relationship_init();
414
- $form = wpcf_admin_custom_types_form();
415
- wpcf_form( 'wpcf_form_types', $form );
416
- }
417
-
418
- /**
419
- * Menu page display.
420
- */
421
- function wpcf_admin_menu_edit_type() {
422
- if ( isset( $_GET['wpcf-post-type'] ) ) {
423
- $title = __( 'Edit Custom Post Type', 'wpcf' );
424
- } else {
425
- $title = __( 'Add New Custom Post Type', 'wpcf' );
426
- }
427
- echo wpcf_add_admin_header( $title );
428
- wpcf_wpml_warning();
429
- $form = wpcf_form( 'wpcf_form_types' );
430
- echo '<br /><form method="post" action="" class="wpcf-types-form '
431
- . 'wpcf-form-validate">';
432
- echo $form->renderForm();
433
- echo '</form>';
434
- echo wpcf_add_admin_footer();
435
- }
436
-
437
- /**
438
- * Menu page hook.
439
- */
440
- function wpcf_admin_menu_edit_tax_hook() {
441
- do_action( 'wpcf_admin_page_init' );
442
- wp_enqueue_script( 'wpcf-form-validation',
443
- WPCF_RES_RELPATH . '/js/'
444
- . 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
445
- WPCF_VERSION );
446
- wp_enqueue_script( 'wpcf-form-validation-additional',
447
- WPCF_RES_RELPATH . '/js/'
448
- . 'jquery-form-validation/additional-methods.min.js',
449
- array('jquery'), WPCF_VERSION );
450
- add_action( 'admin_footer', 'wpcf_admin_tax_form_js_validation' );
451
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
452
- require_once WPCF_INC_ABSPATH . '/custom-taxonomies-form.php';
453
- $form = wpcf_admin_custom_taxonomies_form();
454
- wpcf_form( 'wpcf_form_tax', $form );
455
- }
456
-
457
- /**
458
- * Menu page display.
459
- */
460
- function wpcf_admin_menu_edit_tax() {
461
- if ( isset( $_GET['wpcf-tax'] ) ) {
462
- $title = __( 'Edit Taxonomy', 'wpcf' );
463
- } else {
464
- $title = __( 'Add New Taxonomy', 'wpcf' );
465
- }
466
- echo wpcf_add_admin_header( $title );
467
- wpcf_wpml_warning();
468
- $form = wpcf_form( 'wpcf_form_tax' );
469
- echo '<br /><form method="post" action="" class="wpcf-tax-form '
470
- . 'wpcf-form-validate">';
471
- echo $form->renderForm();
472
- echo '</form>';
473
- echo wpcf_add_admin_footer();
474
- }
475
-
476
- /**
477
- * Menu page hook.
478
- */
479
- function wpcf_admin_menu_import_export_hook() {
480
- do_action( 'wpcf_admin_page_init' );
481
- require_once WPCF_INC_ABSPATH . '/fields.php';
482
- require_once WPCF_INC_ABSPATH . '/import-export.php';
483
- if ( extension_loaded( 'simplexml' ) && isset( $_POST['export'] )
484
- && wp_verify_nonce( $_POST['_wpnonce'], 'wpcf_import' ) ) {
485
- wpcf_admin_export_data();
486
- die();
487
- }
488
- }
489
-
490
- /**
491
- * Menu page display.
492
- */
493
- function wpcf_admin_menu_import_export() {
494
- echo wpcf_add_admin_header( __( 'Import/Export', 'wpcf' ) );
495
- echo '<br /><form method="post" action="" class="wpcf-import-export-form '
496
- . 'wpcf-form-validate" enctype="multipart/form-data">';
497
- echo wpcf_form_simple( wpcf_admin_import_export_form() );
498
- echo '</form>';
499
- echo wpcf_add_admin_footer();
500
- }
501
-
502
- /**
503
- * Menu page hook.
504
- */
505
- function wpcf_admin_menu_custom_fields_control_hook() {
506
- do_action( 'wpcf_admin_page_init' );
507
- add_action( 'admin_head', 'wpcf_admin_custom_fields_control_js' );
508
- add_thickbox();
509
- require_once WPCF_INC_ABSPATH . '/fields.php';
510
- require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
511
- require_once WPCF_INC_ABSPATH . '/fields-control.php';
512
-
513
- if ( isset( $_REQUEST['_wpnonce'] )
514
- && wp_verify_nonce( $_REQUEST['_wpnonce'],
515
- 'custom_fields_control_bulk' )
516
- && (isset( $_POST['action'] ) || isset( $_POST['action2'] )) && !empty( $_POST['fields'] ) ) {
517
- $action = $_POST['action'] == '-1' ? $_POST['action2'] : $_POST['action'];
518
- wpcf_admin_custom_fields_control_bulk_actions( $action );
519
- }
520
-
521
- global $wpcf_control_table;
522
- $wpcf_control_table = new WPCF_Custom_Fields_Control_Table( array(
523
- 'ajax' => true,
524
- 'singular' => __( 'Custom Field', 'wpcf' ),
525
- 'plural' => __( 'Custom Fields', 'wpcf' ),
526
- ) );
527
- $wpcf_control_table->prepare_items();
528
- }
529
-
530
- /**
531
- * Menu page display.
532
- */
533
- function wpcf_admin_menu_custom_fields_control() {
534
- global $wpcf_control_table;
535
- echo wpcf_add_admin_header( __( 'Custom Fields Control', 'wpcf' ) );
536
- echo '<form method="post" action="" id="wpcf-custom-fields-control-form" class="wpcf-custom-fields-control-form '
537
- . 'wpcf-form-validate" enctype="multipart/form-data">';
538
- echo wpcf_admin_custom_fields_control_form( $wpcf_control_table );
539
- wp_nonce_field( 'custom_fields_control_bulk' );
540
- echo '</form>';
541
- echo wpcf_add_admin_footer();
542
- }
543
-
544
- /**
545
- * Menu page hook.
546
- */
547
- function wpcf_admin_menu_migration_hook() {
548
- do_action( 'wpcf_admin_page_init' );
549
- require_once WPCF_INC_ABSPATH . '/fields.php';
550
- require_once WPCF_INC_ABSPATH . '/custom-types.php';
551
- require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
552
- require_once WPCF_INC_ABSPATH . '/migration.php';
553
- $form = wpcf_admin_migration_form();
554
- wpcf_form( 'wpcf_form_migration', $form );
555
- }
556
-
557
- /**
558
- * Menu page display.
559
- */
560
- function wpcf_admin_menu_migration() {
561
- echo wpcf_add_admin_header( __( 'Migration', 'wpcf' ) );
562
- echo '<br /><form method="post" action="" id="wpcf-migration-form" class="wpcf-migration-form '
563
- . 'wpcf-form-validate" enctype="multipart/form-data">';
564
- $form = wpcf_form( 'wpcf_form_migration' );
565
- echo $form->renderForm();
566
- echo '</form>';
567
- echo wpcf_add_admin_footer();
568
- }
569
-
570
- /**
571
- * Menu page hook.
572
- */
573
- function wpcf_admin_menu_settings_hook() {
574
- do_action( 'wpcf_admin_page_init' );
575
- require_once WPCF_INC_ABSPATH . '/settings.php';
576
- $form = wpcf_admin_image_settings_form();
577
- wpcf_form( 'wpcf_form_image_settings', $form );
578
- $form = wpcf_admin_general_settings_form();
579
- wpcf_form( 'wpcf_form_general_settings', $form );
580
- }
581
-
582
- /**
583
- * Menu page display.
584
- */
585
- function wpcf_admin_menu_settings() {
586
- ob_start();
587
- echo wpcf_add_admin_header( __( 'Settings', 'wpcf' ) );
588
-
589
- ?>
590
- <p style="font-weight: bold;"><?php
591
- _e( 'This screen contains the Types settings for your site.', 'wpcf' );
592
-
593
- ?></p>
594
- <ul class="horlist">
595
- <li><a href="#types-image-settings"><?php
596
- _e( 'Image Settings', 'wpcf' );
597
-
598
- ?></a></li>
599
- <li><a href="#types-general-settings"><?php
600
- _e( 'General Setings', 'wpcf' );
601
-
602
- ?></a></li>
603
- </ul>
604
- <br style='clear:both'/><br /><br />
605
- <a id="types-image-settings"></a>
606
- <table class="widefat" id="types_image_settings_table">
607
- <thead>
608
- <tr>
609
- <th><?php
610
- _e( 'Image Settings', 'wpcf' );
611
-
612
- ?></th>
613
- </tr>
614
- </thead>
615
- <tbody>
616
- <tr>
617
- <td>
618
- <?php
619
- echo '<br /><form method="post" action="" id="wpcf-image-settings-form" class="wpcf-settings-form '
620
- . 'wpcf-form-validate">';
621
- $form = wpcf_form( 'wpcf_form_image_settings' );
622
- echo $form->renderForm();
623
- echo '</form>';
624
-
625
- ?>
626
- </td>
627
- </tr>
628
- </tbody>
629
- </table>
630
- <br /><br />
631
- <a id="types-general-settings"></a>
632
- <table class="widefat" id="types_general_settings_table">
633
- <thead>
634
- <tr>
635
- <th><?php
636
- _e( 'General Settings', 'wpcf' );
637
-
638
- ?></th>
639
- </tr>
640
- </thead>
641
- <tbody>
642
- <tr>
643
- <td>
644
- <?php
645
- echo '<br /><form method="post" action="" id="wpcf-general-settings-form" class="wpcf-settings-form '
646
- . 'wpcf-form-validate">';
647
- $form = wpcf_form( 'wpcf_form_general_settings' );
648
- echo $form->renderForm();
649
- echo '</form>';
650
-
651
- ?>
652
- </td>
653
- </tr>
654
- </tbody>
655
- </table>
656
- <?php
657
- echo wpcf_add_admin_footer();
658
-
659
- echo ob_get_clean();
660
- }
661
-
662
- /**
663
- * Adds typical header on admin pages.
664
- *
665
- * @param string $title
666
- * @param string $icon_id Custom icon
667
- * @return string
668
- */
669
- function wpcf_add_admin_header( $title, $icon_id = 'icon-wpcf' )
670
- {
671
- global $wp_version;
672
- if ( version_compare( '3.8', $wp_version ) ) {
673
- echo PHP_EOL;
674
- printf('<div class="wrap"><div id="%s" class="icon32"><br /></div>', $icon_id );
675
- }
676
- printf('<h2>%s</h2>', $title );
677
- do_action( 'wpcf_admin_header' );
678
- do_action( 'wpcf_admin_header_' . $_GET['page'] );
679
- }
680
-
681
- /**
682
- * Adds footer on admin pages.
683
- *
684
- * <b>Strongly recomended</b> if wpcf_add_admin_header() is called before.
685
- * Otherwise invalid HTML formatting will occur.
686
- */
687
- function wpcf_add_admin_footer() {
688
- do_action( 'wpcf_admin_footer_' . $_GET['page'] );
689
- do_action( 'wpcf_admin_footer' );
690
- echo "\r\n" . '</div>' . "\r\n";
691
- }
692
-
693
- /**
694
- * Returns HTML formatted 'widefat' table.
695
- *
696
- * @param type $ID
697
- * @param type $header
698
- * @param type $rows
699
- * @param type $empty_message
700
- */
701
- function wpcf_admin_widefat_table( $ID, $header, $rows = array(),
702
- $empty_message = 'No results' ) {
703
- $head = '';
704
- $footer = '';
705
- foreach ( $header as $key => $value ) {
706
- $head .= '<th id="wpcf-table-' . $key . '">' . $value . '</th>' . "\r\n";
707
- $footer .= '<th>' . $value . '</th>' . "\r\n";
708
- }
709
- echo '<table id="' . $ID . '" class="widefat" cellspacing="0">
710
- <thead>
711
- <tr>
712
- ' . $head . '
713
- </tr>
714
- </thead>
715
- <tfoot>
716
- <tr>
717
- ' . $footer . '
718
- </tr>
719
- </tfoot>
720
- <tbody>
721
- ';
722
- $row = '';
723
- if ( empty( $rows ) ) {
724
- echo '<tr><td colspan="' . count( $header ) . '">' . $empty_message
725
- . '</td></tr>';
726
- } else {
727
- foreach ( $rows as $row ) {
728
- echo '<tr>';
729
- foreach ( $row as $column_name => $column_value ) {
730
- echo '<td class="wpcf-table-column-' . $column_name . '">';
731
- echo $column_value;
732
- echo '</td>' . "\r\n";
733
- }
734
- echo '</tr>' . "\r\n";
735
- }
736
- }
737
- echo '
738
- </tbody>
739
- </table>' . "\r\n";
740
- }
741
-
742
- /**
743
- * Admin tabs.
744
- *
745
- * @param type $tabs
746
- * @param type $page
747
- * @param type $default
748
- * @param type $current
749
- * @return string
750
- */
751
- function wpcf_admin_tabs( $tabs, $page, $default = '', $current = '' ) {
752
- if ( empty( $current ) && isset( $_GET['tab'] ) ) {
753
- $current = $_GET['tab'];
754
- } else {
755
- $current = $default;
756
- }
757
- $output = '<h2 class="nav-tab-wrapper">';
758
- foreach ( $tabs as $tab => $name ) {
759
- $class = ( $tab == $current ) ? ' nav-tab-active' : '';
760
- $output .= "<a class='nav-tab$class' href='?page=$page&tab=$tab'>$name</a>";
761
- }
762
- $output .= '</h2>';
763
- return $output;
764
- }
765
-
766
- /**
767
- * Saves open fieldsets.
768
- *
769
- * @param type $action
770
- * @param type $fieldset
771
- */
772
- function wpcf_admin_form_fieldset_save_toggle( $action, $fieldset ) {
773
- $data = get_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle',
774
- true );
775
- if ( $action == 'open' ) {
776
- $data[$fieldset] = 1;
777
- } else if ( $action == 'close' ) {
778
- unset( $data[$fieldset] );
779
- }
780
- update_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle', $data );
781
- }
782
-
783
- /**
784
- * Check if fieldset is saved as open.
785
- *
786
- * @param type $fieldset
787
- */
788
- function wpcf_admin_form_fieldset_is_collapsed( $fieldset ) {
789
- $data = get_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle',
790
- true );
791
- if ( empty( $data ) ) {
792
- return true;
793
- }
794
- return array_key_exists( $fieldset, $data ) ? false : true;
795
- }
796
-
797
- /**
798
- * Adds help on admin pages.
799
- *
800
- * @param type $contextual_help
801
- * @param type $screen_id
802
- * @param type $screen
803
- * @return type
804
- */
805
- function wpcf_admin_plugin_help( $hook, $page ) {
806
- global $wp_version;
807
- $call = false;
808
- $contextual_help = '';
809
- $page = $page;
810
- if ( isset( $page ) && isset( $_GET['page'] ) && $_GET['page'] == $page ) {
811
- switch ( $page ) {
812
- case 'wpcf-cf':
813
- $call = 'custom_fields';
814
- break;
815
-
816
- case 'wpcf-ctt':
817
- $call = 'custom_types_and_taxonomies';
818
- break;
819
-
820
- case 'wpcf-import-export':
821
- $call = 'import_export';
822
- break;
823
-
824
- case 'wpcf-edit':
825
- $call = 'edit_group';
826
- break;
827
-
828
- case 'wpcf-edit-type':
829
- $call = 'edit_type';
830
- break;
831
-
832
- case 'wpcf-edit-tax':
833
- $call = 'edit_tax';
834
- break;
835
- case 'wpcf':
836
- $call = 'wpcf';
837
- break;
838
- }
839
- }
840
- if ( $call ) {
841
- require_once WPCF_ABSPATH . '/help.php';
842
- $contextual_help = wpcf_admin_help( $call, $contextual_help );
843
- // WP 3.3 changes
844
- if ( version_compare( $wp_version, '3.2.1', '>' ) ) {
845
- set_current_screen( $hook );
846
- $screen = get_current_screen();
847
- if ( !is_null( $screen ) ) {
848
- $args = array(
849
- 'title' => __( 'Types', 'wpcf' ),
850
- 'id' => 'wpcf',
851
- 'content' => $contextual_help,
852
- 'callback' => false,
853
- );
854
- $screen->add_help_tab( $args );
855
- }
856
- } else {
857
- add_contextual_help( $hook, $contextual_help );
858
- }
859
- }
860
- }
861
-
862
- /**
863
- * Promo texts
864
- *
865
- * @todo Move!
866
- */
867
- function wpcf_admin_promotional_text() {
868
- $promo_tabs = get_option( '_wpcf_promo_tabs', false );
869
- // random selection every one hour
870
- if ( $promo_tabs ) {
871
- $time = time();
872
- $time_check = intval( $promo_tabs['time'] ) + 60 * 60;
873
- if ( $time > $time_check ) {
874
- $selected = mt_rand( 0, 3 );
875
- $promo_tabs['selected'] = $selected;
876
- $promo_tabs['time'] = $time;
877
- update_option( '_wpcf_promo_tabs', $promo_tabs );
878
- } else {
879
- $selected = $promo_tabs['selected'];
880
- }
881
- } else {
882
- $promo_tabs = array();
883
- $selected = mt_rand( 0, 3 );
884
- $promo_tabs['selected'] = $selected;
885
- $promo_tabs['time'] = time();
886
- update_option( '_wpcf_promo_tabs', $promo_tabs );
887
- }
888
- include WPCF_ABSPATH . '/marketing/helpful-links.php';
889
- }
890
-
891
- /**
892
- * Collapsible scripts.
893
- */
894
- function wpcf_admin_load_collapsible() {
895
- wp_enqueue_script( 'wpcf-collapsible',
896
- WPCF_RES_RELPATH . '/js/collapsible.js', array('jquery'),
897
- WPCF_VERSION );
898
- wp_enqueue_style( 'wpcf-collapsible',
899
- WPCF_RES_RELPATH . '/css/collapsible.css', array(), WPCF_VERSION );
900
- $option = get_option( 'wpcf_toggle', array() );
901
- if ( !empty( $option ) ) {
902
- $setting = 'new Array("' . implode( '", "', array_keys( $option ) ) . '")';
903
- wpcf_admin_add_js_settings( 'wpcf_collapsed', $setting );
904
- }
905
- }
906
-
907
- /**
908
- * Toggle button.
909
- *
910
- * @param type $div_id
911
- * @return type
912
- */
913
- function wpcf_admin_toggle_button( $div_id ) {
914
- return '<a href="'
915
- . admin_url( 'admin-ajax.php?action=wpcf_ajax&wpcf_action=toggle&div='
916
- . $div_id . '-toggle&_wpnonce='
917
- . wp_create_nonce( 'toggle' ) )
918
- . '" id="' . $div_id
919
- . '" class="wpcf-collapsible-button"></a>';
920
- }
921
-
922
- /**
923
- * Various delete/deactivate content actions.
924
- *
925
- * @param type $type
926
- * @param type $arg
927
- * @param type $action
928
- */
929
- function wpcf_admin_deactivate_content( $type, $arg, $action = 'delete' ) {
930
- switch ( $type ) {
931
- case 'post_type':
932
- // Clean tax relations
933
- if ( $action == 'delete' ) {
934
- $custom = get_option( 'wpcf-custom-taxonomies', array() );
935
- foreach ( $custom as $post_type => $data ) {
936
- if ( empty( $data['supports'] ) ) {
937
- continue;
938
- }
939
- if ( array_key_exists( $arg, $data['supports'] ) ) {
940
- unset( $custom[$post_type]['supports'][$arg] );
941
- }
942
- }
943
- update_option( 'wpcf-custom-taxonomies', $custom );
944
- }
945
- break;
946
-
947
- case 'taxonomy':
948
- // Clean post relations
949
- if ( $action == 'delete' ) {
950
- $custom = get_option( 'wpcf-custom-types', array() );
951
- foreach ( $custom as $post_type => $data ) {
952
- if ( empty( $data['taxonomies'] ) ) {
953
- continue;
954
- }
955
- if ( array_key_exists( $arg, $data['taxonomies'] ) ) {
956
- unset( $custom[$post_type]['taxonomies'][$arg] );
957
- }
958
- }
959
- update_option( 'wpcf-custom-types', $custom );
960
- }
961
- break;
962
-
963
- default:
964
- break;
965
- }
966
- }
967
-
968
- /**
969
- * Loads teasers.
970
- *
971
- * @param type $teasers
972
- */
973
- function wpcf_admin_load_teasers( $teasers ) {
974
- foreach ( $teasers as $teaser ) {
975
- $file = WPCF_ABSPATH . '/plus/' . $teaser;
976
- if ( file_exists( $file ) ) {
977
- require_once $file;
978
- }
979
- }
980
- }
981
-
982
- /**
983
- * Get temporary directory
984
- *
985
- * @return
986
- */
987
-
988
- function wpcf_get_temporary_directory()
989
- {
990
- $dir = sys_get_temp_dir();
991
- if ( !empty( $dir ) && is_dir( $dir ) && is_writable( $dir ) ) {
992
- return $dir;
993
- }
994
- $dir = wp_upload_dir();
995
- $dir = $dir['basedir'];
996
  return $dir;
997
  }
998
 
@@ -1016,6 +1126,37 @@ function wpcf_welcome_panel()
1016
  </div>
1017
  <?php
1018
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1019
 
1020
  /**
1021
  * add types configuration to debug
@@ -1030,3 +1171,70 @@ function wpcf_get_extra_debug_info($extra_debug)
1030
  add_action( 'wpcf_admin_header', 'wpcf_welcome_panel', PHP_INT_SIZE );
1031
  add_filter( 'icl_get_extra_debug_info', 'wpcf_get_extra_debug_info' );
1032
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Admin functions
5
+ *
6
+ *
7
+ */
8
+ require_once WPCF_ABSPATH . '/marketing.php';
9
+ /*
10
+ * This needs to be called after main 'init' hook.
11
+ * Main init hook calls required Types code for frontend.
12
+ * Admin init hook only in admin area.
13
+ *
14
+ * TODO Revise it to change to 'admin_init'
15
+ */
16
+ add_action( 'admin_init', 'wpcf_admin_init_hook', 11 );
17
+ add_action( 'admin_menu', 'wpcf_admin_menu_hook' );
18
+ add_action( 'wpcf_admin_page_init', 'wpcf_enqueue_scripts' );
19
+ add_action( 'admin_enqueue_scripts', 'wpcf_admin_enqueue_scripts' );
20
+
21
+ wpcf_admin_load_teasers( array('types-access.php') );
22
+ if ( defined( 'DOING_AJAX' ) ) {
23
+ require_once WPCF_INC_ABSPATH . '/ajax.php';
24
+ }
25
+ include_once WPCF_ABSPATH.'/classes/class.wpcf-marketing-messages.php';
26
+ new WPCF_Types_Marketing_Messages();
27
+
28
+ /**
29
+ * last edit flag
30
+ */
31
+ if ( !defined('TOOLSET_EDIT_LAST' )){
32
+ define( 'TOOLSET_EDIT_LAST', '_toolset_edit_last');
33
+ }
34
+
35
+ /**
36
+ * admin_init hook.
37
+ */
38
+ function wpcf_admin_init_hook()
39
+ {
40
+ wp_register_style('wpcf-css-embedded', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION );
41
+
42
+ wp_enqueue_style( 'wpcf-promo-tabs', WPCF_EMBEDDED_RES_RELPATH . '/css/tabs.css', array(), WPCF_VERSION );
43
+ wp_enqueue_style('toolset-dashicons');
44
+ }
45
+
46
+ /**
47
+ * admin_menu hook.
48
+ */
49
+ function wpcf_admin_menu_hook()
50
+ {
51
+ $wpcf_capability = apply_filters( 'wpcf_capability', 'manage_options' );
52
+
53
+ add_menu_page(
54
+ __( 'Types', 'wpcf' ),
55
+ __( 'Types', 'wpcf' ),
56
+ $wpcf_capability,
57
+ 'wpcf',
58
+ 'wpcf_admin_menu_summary',
59
+ 'none'
60
+ );
61
+
62
+ $subpages = array();
63
+
64
+ // Custom Post Types
65
+ $subpages['wpcf-cpt'] = array(
66
+ 'menu_title' => __( 'Custom Post Types', 'wpcf' ),
67
+ 'function' => 'wpcf_admin_menu_summary_cpt',
68
+ );
69
+
70
+ // Custom Taxonomies
71
+ $subpages['wpcf-ctt'] = array(
72
+ 'menu_title' => __( 'Custom Taxonomies', 'wpcf' ),
73
+ 'function' => 'wpcf_admin_menu_summary_ctt',
74
+ );
75
+
76
+ // Custom fields
77
+ $subpages['wpcf-cf'] = array(
78
+ 'menu_title' => __( 'Custom Fields', 'wpcf' ),
79
+ 'function' => 'wpcf_admin_menu_summary',
80
+ );
81
+
82
+ // Custom Fields Control
83
+ $subpages['wpcf-custom-fields-control'] = array(
84
+ 'menu_title' => __( 'Custom Fields Control', 'wpcf' ),
85
+ 'function' => 'wpcf_admin_menu_custom_fields_control',
86
+ );
87
+
88
+ // User Meta
89
+ $subpages['wpcf-um'] = array(
90
+ 'menu_title' => __( 'User Fields', 'wpcf' ),
91
+ 'function' => 'wpcf_usermeta_summary',
92
+ );
93
+
94
+ // User Fields Control
95
+ $subpages['wpcf-user-fields-control'] = array(
96
+ 'menu_title' => __( 'User Fields Control', 'wpcf' ),
97
+ 'function' => 'wpcf_admin_menu_user_fields_control',
98
+ );
99
+
100
+ if ( !empty($kind ) ) {
101
+ }
102
+
103
+ // Import/Export
104
+ $subpages['wpcf-import-export'] = array(
105
+ 'menu_title' => __( 'Import/Export', 'wpcf' ),
106
+ 'function' => 'wpcf_admin_menu_import_export',
107
+ );
108
+
109
+ // Settings
110
+ $subpages['wpcf-custom-settings'] = array(
111
+ 'menu_title' => __( 'Settings', 'wpcf' ),
112
+ 'function' => 'wpcf_admin_menu_settings',
113
+ 'submenu' => array(
114
+ 'wpcf-debug-information' => array(
115
+ 'menu_title' => __( 'Debug Information', 'wpcf' ),
116
+ 'function' => 'wpcf_admin_menu_debug_information',
117
  ),
118
  ),
119
+ );
120
+
121
+ foreach( $subpages as $menu_slug => $menu ) {
122
+ wpcf_admin_add_submenu_page($menu, $menu_slug);
123
+ }
124
+
125
+ if ( isset( $_GET['page'] ) ) {
126
+ switch ( $_GET['page'] ) {
127
+ case 'wpcf-edit':
128
+ $title = isset( $_GET['group_id'] ) ? __( 'Edit Group', 'wpcf' ) : __( 'Add New Group',
129
+ 'wpcf' );
130
+ $hook = add_submenu_page( 'wpcf', $title, $title,
131
+ 'manage_options', 'wpcf-edit',
132
+ 'wpcf_admin_menu_edit_fields' );
133
+ add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_fields_hook' );
134
+ wpcf_admin_plugin_help( $hook, 'wpcf-edit' );
135
+ break;
136
+
137
+ case 'wpcf-edit-type':
138
+ $title = isset( $_GET['wpcf-post-type'] ) ? __( 'Edit Custom Post Type',
139
+ 'wpcf' ) : __( 'Add New Custom Post Type',
140
+ 'wpcf' );
141
+ $hook = add_submenu_page( 'wpcf', $title, $title,
142
+ 'manage_options', 'wpcf-edit-type',
143
+ 'wpcf_admin_menu_edit_type' );
144
+ add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_type_hook' );
145
+ wpcf_admin_plugin_help( $hook, 'wpcf-edit-type' );
146
+ break;
147
+
148
+ case 'wpcf-edit-tax':
149
+ $title = isset( $_GET['wpcf-tax'] ) ? __( 'Edit Taxonomy',
150
+ 'wpcf' ) : __( 'Add New Taxonomy', 'wpcf' );
151
+ $hook = add_submenu_page( 'wpcf', $title, $title,
152
+ 'manage_options', 'wpcf-edit-tax',
153
+ 'wpcf_admin_menu_edit_tax' );
154
+ add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_tax_hook' );
155
+ wpcf_admin_plugin_help( $hook, 'wpcf-edit-tax' );
156
+ break;
157
+ case 'wpcf-edit-usermeta':
158
+ $title = isset( $_GET['group_id'] ) ? __( 'Edit User Fields Group', 'wpcf' ) : __( 'Add New User Fields Group',
159
+ 'wpcf' );
160
+ $hook = add_submenu_page( 'wpcf', $title, $title,
161
+ 'manage_options', 'wpcf-edit-usermeta',
162
+ 'wpcf_admin_menu_edit_user_fields' );
163
+ add_action( 'load-' . $hook, 'wpcf_admin_menu_edit_user_fields_hook' );
164
+ wpcf_admin_plugin_help( $hook, 'wpcf-edit-usermeta' );
165
+ break;
166
+ }
167
+ }
168
+
169
+ // Check if migration from other plugin is needed
170
+ if ( class_exists( 'Acf' ) || defined( 'CPT_VERSION' ) ) {
171
+ $hook = add_submenu_page( 'wpcf', __( 'Migration', 'wpcf' ),
172
+ __( 'Migration', 'wpcf' ), 'manage_options', 'wpcf-migration',
173
+ 'wpcf_admin_menu_migration' );
174
+ add_action( 'load-' . $hook, 'wpcf_admin_menu_migration_hook' );
175
+ wpcf_admin_plugin_help( $hook, 'wpcf-migration' );
176
+ }
177
+
178
+ do_action( 'wpcf_menu_plus' );
179
+
180
+ // remove the repeating Types submenu
181
+ remove_submenu_page( 'wpcf', 'wpcf' );
182
+ }
183
+
184
+ /**
185
+ * Menu page hook.
186
+ */
187
+ function wpcf_admin_menu_debug_information()
188
+ {
189
+ require_once WPCF_EMBEDDED_ABSPATH.'/common/debug/debug-information.php';
190
+ }
191
+
192
+ /**
193
+ * Menu page hook.
194
+ */
195
+ function wpcf_usermeta_summary_hook()
196
+ {
197
+ do_action( 'wpcf_admin_page_init' );
198
+ wpcf_admin_load_collapsible();
199
+ wpcf_admin_page_add_options('uf', __( 'User Fields', 'wpcf' ));
200
+ }
201
+
202
+ /**
203
+ * Menu page hook.
204
+ */
205
+ function wpcf_admin_menu_summary_hook()
206
+ {
207
+ do_action( 'wpcf_admin_page_init' );
208
+ wpcf_admin_load_collapsible();
209
+ wpcf_admin_page_add_options('cf', __( 'Custom Fields', 'wpcf' ));
210
+ }
211
+
212
+ /**
213
+ * Menu page display.
214
+ */
215
+ function wpcf_admin_menu_summary()
216
+ {
217
+ wpcf_add_admin_header(
218
+ __( 'Custom Fields', 'wpcf' ),
219
+ array('page'=>'wpcf-edit'),
220
+ __('Add New Group', 'wpcf')
221
+ );
222
+ require_once WPCF_INC_ABSPATH . '/fields.php';
223
+ require_once WPCF_INC_ABSPATH . '/fields-list.php';
224
+ $to_display = wpcf_admin_fields_get_fields();
225
+ if ( !empty( $to_display ) ) {
226
+ add_action( 'wpcf_groups_list_table_after', 'wpcf_admin_promotional_text' );
227
+ }
228
+ wpcf_admin_fields_list();
229
+ wpcf_add_admin_footer();
230
+ }
231
+
232
+ /**
233
+ * Menu page hook.
234
+ */
235
+ function wpcf_admin_menu_edit_fields_hook()
236
+ {
237
+ do_action( 'wpcf_admin_page_init' );
238
+
239
+ /*
240
+ * Enqueue scripts
241
+ */
242
+ // Group filter
243
+ wp_enqueue_script( 'wpcf-filter-js',
244
+ WPCF_EMBEDDED_RES_RELPATH
245
+ . '/js/custom-fields-form-filter.js', array('jquery'), WPCF_VERSION );
246
+ // Form
247
+ wp_enqueue_script( 'wpcf-form-validation',
248
+ WPCF_EMBEDDED_RES_RELPATH . '/js/'
249
+ . 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
250
+ WPCF_VERSION );
251
+ wp_enqueue_script( 'wpcf-form-validation-additional',
252
+ WPCF_EMBEDDED_RES_RELPATH . '/js/'
253
+ . 'jquery-form-validation/additional-methods.min.js',
254
+ array('jquery'), WPCF_VERSION );
255
+ // Scroll
256
+ wp_enqueue_script( 'wpcf-scrollbar',
257
+ WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/scrollbar.js',
258
+ array('jquery') );
259
+ wp_enqueue_script( 'wpcf-mousewheel',
260
+ WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/js/mousewheel.js',
261
+ array('wpcf-scrollbar') );
262
+ // MAIN
263
+ wp_enqueue_script( 'wpcf-fields-form',
264
+ WPCF_EMBEDDED_RES_RELPATH
265
+ . '/js/fields-form.js', array('wpcf-js') );
266
+
267
+ /*
268
+ * Enqueue styles
269
+ */
270
+ wp_enqueue_style( 'wpcf-scroll',
271
+ WPCF_EMBEDDED_RELPATH . '/common/visual-editor/res/css/scroll.css' );
272
+
273
+ //Css editor
274
+ wp_enqueue_script( 'wpcf-form-codemirror' ,
275
+ WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.js', array('wpcf-js'));
276
+ wp_enqueue_script( 'wpcf-form-codemirror-css-editor' ,
277
+ WPCF_RELPATH . '/resources/js/codemirror234/mode/css/css.js', array('wpcf-js'));
278
+ wp_enqueue_script( 'wpcf-form-codemirror-html-editor' ,
279
+ WPCF_RELPATH . '/resources/js/codemirror234/mode/xml/xml.js', array('wpcf-js'));
280
+ wp_enqueue_script( 'wpcf-form-codemirror-html-editor2' ,
281
+ WPCF_RELPATH . '/resources/js/codemirror234/mode/htmlmixed/htmlmixed.js', array('wpcf-js'));
282
+ wp_enqueue_script( 'wpcf-form-codemirror-editor-resize' ,
283
+ WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.resizable.min.js', array('wpcf-js'));
284
+
285
+ wp_enqueue_style( 'wpcf-css-editor',
286
+ WPCF_RELPATH . '/resources/js/codemirror234/lib/codemirror.css' );
287
+ wp_enqueue_style( 'wpcf-css-editor-resize',
288
+ WPCF_RELPATH . '/resources/js/jquery_ui/jquery.ui.theme.min.css' );
289
+ wp_enqueue_style( 'wpcf-usermeta',
290
+ WPCF_EMBEDDED_RES_RELPATH . '/css/usermeta.css' );
291
+
292
+ add_action( 'admin_footer', 'wpcf_admin_fields_form_js_validation' );
293
+ require_once WPCF_INC_ABSPATH . '/fields.php';
294
+ require_once WPCF_INC_ABSPATH . '/fields-form.php';
295
+ $form = wpcf_admin_fields_form();
296
+ wpcf_form( 'wpcf_form_fields', $form );
297
+ }
298
+
299
+ /**
300
+ * Menu page display.
301
+ */
302
+ function wpcf_admin_menu_edit_fields()
303
+ {
304
+ if ( isset( $_GET['group_id'] ) ) {
305
+ $title = __( 'Edit Group', 'wpcf' );
306
+ } else {
307
+ $title = __( 'Add New Group', 'wpcf' );
308
+ }
309
+ wpcf_add_admin_header( $title );
310
+ wpcf_wpml_warning();
311
+ $form = wpcf_form( 'wpcf_form_fields' );
312
+ echo '<form method="post" action="" class="wpcf-fields-form wpcf-form-validate js-types-show-modal">';
313
+ echo '<div id="poststuff">';
314
+ echo $form->renderForm();
315
+ echo '</div>';
316
+ echo '</form>';
317
+ wpcf_add_admin_footer();
318
+ }
319
+
320
+ function wpcf_admin_page_add_options( $name, $label)
321
+ {
322
+ $option = 'per_page';
323
+ $args = array(
324
+ 'label' => $label,
325
+ 'default' => 10,
326
+ 'option' => sprintf('wpcf_%s_%s', $name, $option),
327
+ );
328
+ add_screen_option( $option, $args );
329
+ }
330
+
331
+ function wpcf_admin_menu_summary_cpt_ctt_hook()
332
+ {
333
+ do_action( 'wpcf_admin_page_init' );
334
+ wp_enqueue_style( 'wpcf-promo-tabs', WPCF_RES_RELPATH . '/css/tabs.css', array(), WPCF_VERSION );
335
+ wpcf_admin_load_collapsible();
336
+ require_once WPCF_INC_ABSPATH . '/custom-types.php';
337
+ require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
338
+ require_once WPCF_INC_ABSPATH . '/custom-types-taxonomies-list.php';
339
+ }
340
 
341
+ /**
342
+ * Menu page hook.
343
+ */
344
+ function wpcf_admin_menu_summary_cpt_hook()
345
+ {
346
+ wpcf_admin_menu_summary_cpt_ctt_hook();
347
+ wpcf_admin_page_add_options('cpt', __( 'Custom Post Types', 'wpcf' ));
348
+ }
349
+
350
+ /**
351
+ * Menu page display.
352
+ */
353
+ function wpcf_admin_menu_summary_cpt()
354
+ {
355
+ wpcf_add_admin_header(
356
+ __( 'Custom Post Types', 'wpcf' ),
357
+ array('page'=>'wpcf-edit-type'),
358
+ __('Add New Custom Post Type', 'wpcf')
359
  );
360
+ $to_display_posts = get_option( WPCF_OPTION_NAME_CUSTOM_TYPES, array() );
361
+ $to_display_tax = get_option( WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, array() );
362
+ if ( !empty( $to_display_posts ) || !empty( $to_display_tax ) ) {
363
+ add_action( 'wpcf_types_tax_list_table_after', 'wpcf_admin_promotional_text' );
364
+ }
365
+ wpcf_admin_custom_post_types_list();
366
+ wpcf_add_admin_footer();
367
+ }
368
 
369
+ /**
370
+ * Menu page hook.
371
+ */
372
+ function wpcf_admin_menu_summary_ctt_hook()
373
+ {
374
+ wpcf_admin_menu_summary_cpt_ctt_hook();
375
+ wpcf_admin_page_add_options('ctt', __( 'Custom Taxonomies', 'wpcf' ));
376
+ }
377
+
378
+ /**
379
+ * Menu page display.
380
+ */
381
+ function wpcf_admin_menu_summary_ctt()
382
+ {
383
+ wpcf_add_admin_header( __( 'Custom Taxonomies', 'wpcf' ), array('page' => 'wpcf-edit-tax') );
384
+ wpcf_admin_custom_taxonomies_list();
385
+ do_action('wpcf_types_tax_list_table_after');
386
+ wpcf_add_admin_footer();
387
+ }
388
+
389
+ /**
390
+ * Menu page hook.
391
+ */
392
+ function wpcf_admin_menu_edit_type_hook()
393
+ {
394
+ do_action( 'wpcf_admin_page_init' );
395
+ require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-types.php';
396
+ require_once WPCF_INC_ABSPATH . '/custom-types-form.php';
397
+ require_once WPCF_INC_ABSPATH . '/post-relationship.php';
398
+ wp_enqueue_script( 'wpcf-custom-types-form',
399
+ WPCF_RES_RELPATH . '/js/'
400
+ . 'custom-types-form.js', array('jquery'), WPCF_VERSION );
401
+ wp_enqueue_script( 'wpcf-form-validation',
402
+ WPCF_RES_RELPATH . '/js/'
403
+ . 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
404
+ WPCF_VERSION );
405
+ wp_enqueue_script( 'wpcf-form-validation-additional',
406
+ WPCF_RES_RELPATH . '/js/'
407
+ . 'jquery-form-validation/additional-methods.min.js',
408
+ array('jquery'), WPCF_VERSION );
409
+ add_action( 'admin_footer', 'wpcf_admin_types_form_js_validation' );
410
+ wpcf_post_relationship_init();
411
+ $form = wpcf_admin_custom_types_form();
412
+ wpcf_form( 'wpcf_form_types', $form );
413
+ }
414
+
415
+ /**
416
+ * Menu page display.
417
+ */
418
+ function wpcf_admin_menu_edit_type()
419
+ {
420
+ if ( isset( $_GET['wpcf-post-type'] ) ) {
421
+ $title = __( 'Edit Custom Post Type', 'wpcf' );
422
+ /**
423
+ * add new CPT link
424
+ */
425
+ $title .= sprintf(
426
+ '<a href="%s" class="add-new-h2">%s</a>',
427
+ add_query_arg( 'page', 'wpcf-edit-type', admin_url('admin.php')),
428
+ __('Add New')
429
  );
430
+ } else {
431
+ $title = __( 'Add New Custom Post Type', 'wpcf' );
432
+ }
433
+ wpcf_add_admin_header( $title );
434
+ wpcf_wpml_warning();
435
+ $form = wpcf_form( 'wpcf_form_types' );
436
+ echo '<br /><form method="post" action="" class="wpcf-types-form wpcf-form-validate js-types-do-not-show-modal">';
437
+ echo $form->renderForm();
438
+ echo '</form>';
439
+ wpcf_add_admin_footer();
440
+ }
441
+
442
+ /**
443
+ * Menu page hook.
444
+ */
445
+ function wpcf_admin_menu_edit_tax_hook()
446
+ {
447
+ do_action( 'wpcf_admin_page_init' );
448
+ wp_enqueue_script( 'wpcf-form-validation',
449
+ WPCF_RES_RELPATH . '/js/'
450
+ . 'jquery-form-validation/jquery.validate.min.js', array('jquery'),
451
+ WPCF_VERSION );
452
+ wp_enqueue_script( 'wpcf-form-validation-additional',
453
+ WPCF_RES_RELPATH . '/js/'
454
+ . 'jquery-form-validation/additional-methods.min.js',
455
+ array('jquery'), WPCF_VERSION );
456
+ add_action( 'admin_footer', 'wpcf_admin_tax_form_js_validation' );
457
+ require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
458
+ require_once WPCF_INC_ABSPATH . '/custom-taxonomies-form.php';
459
+ $form = wpcf_admin_custom_taxonomies_form();
460
+ wpcf_form( 'wpcf_form_tax', $form );
461
+ }
462
+
463
+ /**
464
+ * Menu page display.
465
+ */
466
+ function wpcf_admin_menu_edit_tax()
467
+ {
468
+ if ( isset( $_GET['wpcf-tax'] ) ) {
469
+ $title = __( 'Edit Taxonomy', 'wpcf' );
470
+ /**
471
+ * add new CPT link
472
+ */
473
+ $title .= sprintf(
474
+ '<a href="%s" class="add-new-h2">%s</a>',
475
+ add_query_arg( 'page', 'wpcf-edit-tax', admin_url('admin.php')),
476
+ __('Add New')
477
+ );
478
+ } else {
479
+ $title = __( 'Add New Taxonomy', 'wpcf' );
480
+ }
481
+ wpcf_add_admin_header( $title );
482
+ wpcf_wpml_warning();
483
+ $form = wpcf_form( 'wpcf_form_tax' );
484
+ echo '<form method="post" action="" class="wpcf-tax-form wpcf-form-validate js-types-show-modal">';
485
+ echo $form->renderForm();
486
+ echo '</form>';
487
+ wpcf_add_admin_footer();
488
+ }
489
+
490
+ /**
491
+ * Menu page hook.
492
+ */
493
+ function wpcf_admin_menu_import_export_hook()
494
+ {
495
+ do_action( 'wpcf_admin_page_init' );
496
+ require_once WPCF_INC_ABSPATH . '/fields.php';
497
+ require_once WPCF_INC_ABSPATH . '/import-export.php';
498
+ if ( extension_loaded( 'simplexml' ) && isset( $_POST['export'] )
499
+ && wp_verify_nonce( $_POST['_wpnonce'], 'wpcf_import' ) ) {
500
+ wpcf_admin_export_data();
501
+ die();
502
+ }
503
+ }
504
+
505
+ /**
506
+ * Menu page display.
507
+ */
508
+ function wpcf_admin_menu_import_export()
509
+ {
510
+ wpcf_add_admin_header( __( 'Import/Export', 'wpcf' ) );
511
+ echo '<br /><form method="post" action="" class="wpcf-import-export-form '
512
+ . 'wpcf-form-validate" enctype="multipart/form-data">';
513
+ echo wpcf_form_simple( wpcf_admin_import_export_form() );
514
+ echo '</form>';
515
+ wpcf_add_admin_footer();
516
+ }
517
+
518
+ /**
519
+ * Menu page hook.
520
+ */
521
+ function wpcf_admin_menu_custom_fields_control_hook()
522
+ {
523
+ do_action( 'wpcf_admin_page_init' );
524
+ add_action( 'admin_head', 'wpcf_admin_custom_fields_control_js' );
525
+ add_thickbox();
526
+ require_once WPCF_INC_ABSPATH . '/fields.php';
527
+ require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
528
+ require_once WPCF_INC_ABSPATH . '/fields-control.php';
529
+
530
+ if ( isset( $_REQUEST['_wpnonce'] )
531
+ && wp_verify_nonce( $_REQUEST['_wpnonce'],
532
+ 'custom_fields_control_bulk' )
533
+ && (isset( $_POST['action'] ) || isset( $_POST['action2'] )) && !empty( $_POST['fields'] ) ) {
534
+ $action = ( $_POST['action'] == '-1' ) ? sanitize_text_field( $_POST['action2'] ) : sanitize_text_field( $_POST['action'] );
535
+ wpcf_admin_custom_fields_control_bulk_actions( $action );
536
+ }
537
+
538
+ global $wpcf_control_table;
539
+ $wpcf_control_table = new WPCF_Custom_Fields_Control_Table( array(
540
+ 'ajax' => true,
541
+ 'singular' => __( 'Custom Field', 'wpcf' ),
542
+ 'plural' => __( 'Custom Fields', 'wpcf' ),
543
+ ) );
544
+ $wpcf_control_table->prepare_items();
545
+ }
546
+
547
+ /**
548
+ * Menu page display.
549
+ */
550
+ function wpcf_admin_menu_custom_fields_control()
551
+ {
552
+ global $wpcf_control_table;
553
+ wpcf_add_admin_header( __( 'Custom Fields Control', 'wpcf' ) );
554
+ echo '<form method="post" action="" id="wpcf-custom-fields-control-form" class="wpcf-custom-fields-control-form wpcf-form-validate" enctype="multipart/form-data">';
555
+ echo wpcf_admin_custom_fields_control_form( $wpcf_control_table );
556
+ wp_nonce_field( 'custom_fields_control_bulk' );
557
+ echo '</form>';
558
+ wpcf_add_admin_footer();
559
+ }
560
+
561
+ /**
562
+ * Menu page hook.
563
+ */
564
+ function wpcf_admin_menu_migration_hook()
565
+ {
566
+ do_action( 'wpcf_admin_page_init' );
567
+ require_once WPCF_INC_ABSPATH . '/fields.php';
568
+ require_once WPCF_INC_ABSPATH . '/custom-types.php';
569
+ require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
570
+ require_once WPCF_INC_ABSPATH . '/migration.php';
571
+ $form = wpcf_admin_migration_form();
572
+ wpcf_form( 'wpcf_form_migration', $form );
573
+ }
574
+
575
+ /**
576
+ * Menu page display.
577
+ */
578
+ function wpcf_admin_menu_migration()
579
+ {
580
+ wpcf_add_admin_header( __( 'Migration', 'wpcf' ) );
581
+ echo '<br /><form method="post" action="" id="wpcf-migration-form" class="wpcf-migration-form '
582
+ . 'wpcf-form-validate" enctype="multipart/form-data">';
583
+ $form = wpcf_form( 'wpcf_form_migration' );
584
+ echo $form->renderForm();
585
+ echo '</form>';
586
+ wpcf_add_admin_footer();
587
+ }
588
+
589
+ /**
590
+ * Menu page hook.
591
+ */
592
+ function wpcf_admin_menu_settings_hook()
593
+ {
594
+ do_action( 'wpcf_admin_page_init' );
595
+ require_once WPCF_INC_ABSPATH . '/settings.php';
596
+ $form = wpcf_admin_image_settings_form();
597
+ wpcf_form( 'wpcf_form_image_settings', $form );
598
+ $form = wpcf_admin_general_settings_form();
599
+ wpcf_form( 'wpcf_form_general_settings', $form );
600
+ $form = wpcf_admin_toolset_messages_form();
601
+ wpcf_form( 'wpcf_form_toolset_messages', $form );
602
+ }
603
+
604
+ /**
605
+ * Menu page display.
606
+ */
607
+ function wpcf_admin_menu_settings()
608
+ {
609
+ $show_toolset_messages = !WPCF_Types_Marketing_Messages::check_register();
610
+ ob_start();
611
+ wpcf_add_admin_header( __( 'Settings', 'wpcf' ) );
612
+
613
+ ?>
614
+ <p style="font-weight: bold;"><?php
615
+ _e( 'This screen contains the Types settings for your site.', 'wpcf' );
616
+
617
+ ?></p>
618
+ <ul class="horlist">
619
+ <li><a href="#types-image-settings"><?php _e( 'Image Settings', 'wpcf' ); ?></a></li>
620
+ <li><a href="#types-general-settings"><?php _e( 'General Settings', 'wpcf' ); ?></a></li>
621
+ <?php if ( $show_toolset_messages ) { ?><li><a href="#toolset-messages"><?php _e( 'Toolset Messages', 'wpcf' ); ?></a></li><?php } ?>
622
+ <li><a href="#debug"><?php _e( 'Debug Information', 'wpcf' ); ?></a></li>
623
+ </ul>
624
+ <br style='clear:both'/><br /><br />
625
+ <a id="types-image-settings"></a>
626
+ <table class="widefat" id="types_image_settings_table">
627
+ <thead>
628
+ <tr>
629
+ <th><?php
630
+ _e( 'Image Settings', 'wpcf' );
631
+
632
+ ?></th>
633
+ </tr>
634
+ </thead>
635
+ <tbody>
636
+ <tr>
637
+ <td>
638
+ <?php
639
+ echo '<br /><form method="post" action="" id="wpcf-image-settings-form" class="wpcf-settings-form '
640
+ . 'wpcf-form-validate">';
641
+ $form = wpcf_form( 'wpcf_form_image_settings' );
642
+ echo $form->renderForm();
643
+ echo '</form>';
644
+
645
+ ?>
646
+ </td>
647
+ </tr>
648
+ </tbody>
649
+ </table>
650
+ <br /><br />
651
+ <a id="types-general-settings"></a>
652
+ <table class="widefat" id="types_general_settings_table">
653
+ <thead>
654
+ <tr>
655
+ <th><?php
656
+ _e( 'General Settings', 'wpcf' );
657
+
658
+ ?></th>
659
+ </tr>
660
+ </thead>
661
+ <tbody>
662
+ <tr>
663
+ <td>
664
+ <?php
665
+ echo '<br /><form method="post" action="" id="wpcf-general-settings-form" class="wpcf-settings-form '
666
+ . 'wpcf-form-validate">';
667
+ $form = wpcf_form( 'wpcf_form_general_settings' );
668
+ echo $form->renderForm();
669
+ echo '</form>';
670
+ ?>
671
+ </td>
672
+ </tr>
673
+ </tbody>
674
+ </table>
675
+ <br /><br />
676
+ <?php
677
+ /**
678
+ * Toolset Messages
679
+ */
680
+ if ( $show_toolset_messages ) {
681
+ ?>
682
+ <a id="toolset-messages"></a>
683
+ <table class="widefat" id="toolset_messages">
684
+ <thead>
685
+ <tr>
686
+ <th><?php _e( 'Toolset Messages', 'wpcf' ); ?></th>
687
+ </tr>
688
+ </thead>
689
+ <tbody>
690
+ <tr>
691
+ <td>
692
+ <?php
693
+ echo '<br /><form method="post" action="" id="wpcf-toolset-messages-form" class="wpcf-settings-form '
694
+ . 'wpcf-form-validate">';
695
+ $form = wpcf_form( 'wpcf_form_toolset_messages' );
696
+ echo $form->renderForm();
697
+ echo '</form>';
698
+ ?>
699
+ </td>
700
+ </tr>
701
+ </tbody>
702
+ </table>
703
+ <br /><br />
704
+ <?php } ?>
705
+ <?php
706
+ /**
707
+ * Debug Information
708
+ */
709
+ ?>
710
+ <a id="debug"></a>
711
+ <table class="widefat" id="debug_table">
712
+ <thead>
713
+ <tr>
714
+ <th><?php _e( 'Debug Information', 'wpcf' ); ?></th>
715
+ </tr>
716
+ </thead>
717
+ <tbody>
718
+ <tr>
719
+ <td>
720
+ <?php
721
+ printf(
722
+ __( 'For retrieving debug information if asked by a support person, use the <a href="%s">debug information</a> page.', 'wpcf' ),
723
+ admin_url('admin.php?page=wpcf-debug-information')
724
+ );
725
+ ?>
726
+ </td>
727
+ </tr>
728
+ </tbody>
729
+ </table>
730
+ <?php
731
+ wpcf_add_admin_footer();
732
+
733
+ echo ob_get_clean();
734
+ }
735
+
736
+ /**
737
+ * Adds typical header on admin pages.
738
+ *
739
+ * @param string $title
740
+ * @param string $icon_id Custom icon
741
+ * @return string
742
+ */
743
+ function wpcf_add_admin_header($title, $add_new = false, $add_new_title = false)
744
+ {
745
+ echo '<div class="wrap">';
746
+ echo '<h2>', $title;
747
+ if ( !$add_new_title ) {
748
+ $add_new_title = __('Add New', 'wpcf');
749
+ }
750
+ if ( $add_new ) {
751
+ printf(
752
+ ' <a href="%s" class="add-new-h2">%s</a>',
753
+ add_query_arg( $add_new, admin_url('admin.php')),
754
+ $add_new_title
755
+ );
756
+ }
757
+ echo '</h2>';
758
+ $current_page = sanitize_text_field( $_GET['page'] );
759
+ do_action( 'wpcf_admin_header' );
760
+ do_action( 'wpcf_admin_header_' . $current_page );
761
+ }
762
+
763
+ /**
764
+ * Adds footer on admin pages.
765
+ *
766
+ * <b>Strongly recomended</b> if wpcf_add_admin_header() is called before.
767
+ * Otherwise invalid HTML formatting will occur.
768
+ */
769
+ function wpcf_add_admin_footer()
770
+ {
771
+ $current_page = sanitize_text_field( $_GET['page'] );
772
+ do_action( 'wpcf_admin_footer_' . $current_page );
773
+ do_action( 'wpcf_admin_footer' );
774
+ echo '</div>';
775
+ }
776
+
777
+ /**
778
+ * Returns HTML formatted 'widefat' table.
779
+ *
780
+ * @param type $ID
781
+ * @param type $header
782
+ * @param type $rows
783
+ * @param type $empty_message
784
+ */
785
+ function wpcf_admin_widefat_table( $ID, $header, $rows = array(), $empty_message = 'No results' )
786
+ {
787
+ if ( 'No results' == $empty_message ) {
788
+ $empty_message = __('No results', 'wpcf');
789
+ }
790
+ $head = '';
791
+ $footer = '';
792
+ foreach ( $header as $key => $value ) {
793
+ $head .= '<th id="wpcf-table-' . $key . '">' . $value . '</th>' . "\r\n";
794
+ $footer .= '<th>' . $value . '</th>' . "\r\n";
795
+ }
796
+ echo '<table id="' . $ID . '" class="widefat" cellspacing="0">
797
+ <thead>
798
+ <tr>
799
+ ' . $head . '
800
+ </tr>
801
+ </thead>
802
+ <tfoot>
803
+ <tr>
804
+ ' . $footer . '
805
+ </tr>
806
+ </tfoot>
807
+ <tbody>
808
+ ';
809
+ $row = '';
810
+ if ( empty( $rows ) ) {
811
+ echo '<tr><td colspan="' . count( $header ) . '">' . $empty_message
812
+ . '</td></tr>';
813
+ } else {
814
+ $i = 0;
815
+ foreach ( $rows as $row ) {
816
+ $classes = array();
817
+ if ( $i++%2 ) {
818
+ $classes[] = 'alternate';
819
+ }
820
+ if ( isset($row['status']) && 'inactive' == $row['status'] ) {
821
+ $classes[] = sprintf('status-%s', $row['status']);
822
+ };
823
+ printf('<tr class="%s">', implode(' ', $classes ));
824
+ foreach ( $row as $column_name => $column_value ) {
825
+ if ( preg_match( '/^(status|raw_name)$/', $column_name )) {
826
+ continue;
827
+ }
828
+ echo '<td class="wpcf-table-column-' . $column_name . '">';
829
+ echo $column_value;
830
+ echo '</td>' . "\r\n";
831
+ }
832
+ echo '</tr>' . "\r\n";
833
+ }
834
+ }
835
+ echo '
836
+ </tbody>
837
+ </table>' . "\r\n";
838
+ }
839
+
840
+ /**
841
+ * Admin tabs.
842
+ *
843
+ * @param type $tabs
844
+ * @param type $page
845
+ * @param type $default
846
+ * @param type $current
847
+ * @return string
848
+ */
849
+ function wpcf_admin_tabs($tabs, $page, $default = '', $current = '')
850
+ {
851
+ if ( empty( $current ) && isset( $_GET['tab'] ) ) {
852
+ $current = sanitize_text_field( $_GET['tab'] );
853
+ } else {
854
+ $current = $default;
855
+ }
856
+ $output = '<h2 class="nav-tab-wrapper">';
857
+ foreach ( $tabs as $tab => $name ) {
858
+ $class = ( $tab == $current ) ? ' nav-tab-active' : '';
859
+ $output .= "<a class='nav-tab$class' href='?page=$page&tab=$tab'>$name</a>";
860
+ }
861
+ $output .= '</h2>';
862
+ return $output;
863
+ }
864
+
865
+ /**
866
+ * Saves open fieldsets.
867
+ *
868
+ * @param type $action
869
+ * @param type $fieldset
870
+ */
871
+ function wpcf_admin_form_fieldset_save_toggle($action, $fieldset)
872
+ {
873
+ $data = get_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle',
874
+ true );
875
+ if ( $action == 'open' ) {
876
+ $data[$fieldset] = 1;
877
+ } elseif ( $action == 'close' ) {
878
+ unset( $data[$fieldset] );
879
+ }
880
+ update_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle', $data );
881
+ }
882
+
883
+ /**
884
+ * Check if fieldset is saved as open.
885
+ *
886
+ * @param type $fieldset
887
+ */
888
+ function wpcf_admin_form_fieldset_is_collapsed($fieldset)
889
+ {
890
+ $data = get_user_meta( get_current_user_id(), 'wpcf-form-fieldsets-toggle',
891
+ true );
892
+ if ( empty( $data ) ) {
893
+ return true;
894
+ }
895
+ return array_key_exists( $fieldset, $data ) ? false : true;
896
+ }
897
+
898
+ /**
899
+ * Adds help on admin pages.
900
+ *
901
+ * @param type $contextual_help
902
+ * @param type $screen_id
903
+ * @param type $screen
904
+ * @return type
905
+ */
906
+ function wpcf_admin_plugin_help($hook, $page)
907
+ {
908
+ global $wp_version;
909
+ $call = false;
910
+ $contextual_help = '';
911
+ $page = $page;
912
+ if ( isset( $page ) && isset( $_GET['page'] ) && $_GET['page'] == $page ) {
913
+ switch ( $page ) {
914
+ case 'wpcf-cf':
915
+ $call = 'custom_fields';
916
+ break;
917
+
918
+ case 'wpcf-cpt':
919
+ case 'wpcf-ctt':
920
+ $call = 'custom_types_and_taxonomies';
921
+ break;
922
+
923
+ case 'wpcf-import-export':
924
+ $call = 'import_export';
925
+ break;
926
+
927
+ case 'wpcf-edit':
928
+ $call = 'edit_group';
929
+ break;
930
+
931
+ case 'wpcf-edit-type':
932
+ $call = 'edit_type';
933
+ break;
934
+
935
+ case 'wpcf-edit-tax':
936
+ $call = 'edit_tax';
937
+ break;
938
+ case 'wpcf':
939
+ $call = 'wpcf';
940
+ break;
941
+ }
942
+ }
943
+ if ( $call ) {
944
+ require_once WPCF_ABSPATH . '/help.php';
945
+ $contextual_help = wpcf_admin_help( $call, $contextual_help );
946
+ // WP 3.3 changes
947
+ if ( version_compare( $wp_version, '3.2.1', '>' ) ) {
948
+ set_current_screen( $hook );
949
+ $screen = get_current_screen();
950
+ if ( !is_null( $screen ) ) {
951
+ $args = array(
952
+ 'title' => __( 'Types', 'wpcf' ),
953
+ 'id' => 'wpcf',
954
+ 'content' => $contextual_help,
955
+ 'callback' => false,
956
  );
957
+ $screen->add_help_tab( $args );
958
  }
959
+ } else {
960
+ add_contextual_help( $hook, $contextual_help );
961
  }
962
+ }
963
+ }
964
+
965
+ /**
966
+ * Promo texts
967
+ *
968
+ * @todo Move!
969
+ */
970
+ function wpcf_admin_promotional_text()
971
+ {
972
+ $promo_tabs = get_option( '_wpcf_promo_tabs', false );
973
+ // random selection every one hour
974
+ if ( $promo_tabs ) {
975
+ $time = time();
976
+ $time_check = intval( $promo_tabs['time'] ) + 60 * 60;
977
+ if ( $time > $time_check ) {
978
+ $selected = mt_rand( 0, 3 );
979
+ $promo_tabs['selected'] = $selected;
980
+ $promo_tabs['time'] = $time;
981
+ update_option( '_wpcf_promo_tabs', $promo_tabs );
982
+ } else {
983
+ $selected = $promo_tabs['selected'];
984
  }
985
+ } else {
986
+ $promo_tabs = array();
987
+ $selected = mt_rand( 0, 3 );
988
+ $promo_tabs['selected'] = $selected;
989
+ $promo_tabs['time'] = time();
990
+ update_option( '_wpcf_promo_tabs', $promo_tabs );
991
+ }
992
+ include WPCF_ABSPATH . '/marketing/helpful-links.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
993
  }
994
 
995
  /**
996
+ * Collapsible scripts.
997
  */
998
+ function wpcf_admin_load_collapsible()
999
  {
1000
+ wp_enqueue_script( 'wpcf-collapsible',
1001
+ WPCF_RES_RELPATH . '/js/collapsible.js', array('jquery'),
1002
+ WPCF_VERSION );
1003
+ wp_enqueue_style( 'wpcf-collapsible',
1004
+ WPCF_RES_RELPATH . '/css/collapsible.css', array(), WPCF_VERSION );
1005
+ $option = get_option( 'wpcf_toggle', array() );
1006
+ if ( !empty( $option ) ) {
1007
+ $setting = 'new Array("' . implode( '", "', array_keys( $option ) ) . '")';
1008
+ wpcf_admin_add_js_settings( 'wpcf_collapsed', $setting );
1009
+ }
1010
  }
1011
 
1012
  /**
1013
+ * Toggle button.
1014
+ *
1015
+ * @param type $div_id
1016
+ * @return type
1017
+ */
1018
+ function wpcf_admin_toggle_button($div_id)
1019
+ {
1020
+ return '<a href="'
1021
+ . admin_url( 'admin-ajax.php?action=wpcf_ajax&wpcf_action=toggle&div='
1022
+ . $div_id . '-toggle&_wpnonce='
1023
+ . wp_create_nonce( 'toggle' ) )
1024
+ . '" id="' . $div_id
1025
+ . '" class="wpcf-collapsible-button"></a>';
1026
+ }
1027
+
1028
+ /**
1029
+ * Various delete/deactivate content actions.
1030
+ *
1031
+ * @param type $type
1032
+ * @param type $arg
1033
+ * @param type $action
1034
+ */
1035
+ function wpcf_admin_deactivate_content($type, $arg, $action = 'delete')
1036
+ {
1037
+ switch ( $type ) {
1038
+ case 'post_type':
1039
+ // Clean tax relations
1040
+ if ( $action == 'delete' ) {
1041
+ $custom = get_option( WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, array() );
1042
+ foreach ( $custom as $post_type => $data ) {
1043
+ if ( empty( $data['supports'] ) ) {
1044
+ continue;
1045
+ }
1046
+ if ( array_key_exists( $arg, $data['supports'] ) ) {
1047
+ unset( $custom[$post_type]['supports'][$arg] );
1048
+ $custom[$post_type][TOOLSET_EDIT_LAST] = time();
1049
+ }
1050
+ }
1051
+ update_option( WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, $custom );
1052
+ }
1053
+ break;
1054
+
1055
+ case 'taxonomy':
1056
+ // Clean post relations
1057
+ if ( $action == 'delete' ) {
1058
+ $custom = get_option( WPCF_OPTION_NAME_CUSTOM_TYPES, array() );
1059
+ foreach ( $custom as $post_type => $data ) {
1060
+ if ( empty( $data['taxonomies'] ) ) {
1061
+ continue;
1062
+ }
1063
+ if ( array_key_exists( $arg, $data['taxonomies'] ) ) {
1064
+ unset( $custom[$post_type]['taxonomies'][$arg] );
1065
+ $custom[$post_type][TOOLSET_EDIT_LAST] = time();
1066
+ }
1067
+ }
1068
+ update_option( WPCF_OPTION_NAME_CUSTOM_TYPES, $custom );
1069
+ }
1070
+ break;
1071
+
1072
+ default:
1073
+ break;
1074
+ }
1075
+ }
1076
+
1077
+ /**
1078
+ * Loads teasers.
1079
+ *
1080
+ * @param type $teasers
1081
  */
1082
+ function wpcf_admin_load_teasers($teasers)
1083
+ {
1084
+ foreach ( $teasers as $teaser ) {
1085
+ $file = WPCF_ABSPATH . '/plus/' . $teaser;
1086
+ if ( file_exists( $file ) ) {
1087
+ require_once $file;
1088
+ }
1089
+ }
1090
+ }
1091
+
1092
+ /**
1093
+ * Get temporary directory
1094
+ *
1095
+ * @return
1096
+ */
1097
+
1098
+ function wpcf_get_temporary_directory()
1099
+ {
1100
+ $dir = sys_get_temp_dir();
1101
+ if ( !empty( $dir ) && is_dir( $dir ) && is_writable( $dir ) ) {
1102
+ return $dir;
1103
+ }
1104
+ $dir = wp_upload_dir();
1105
+ $dir = $dir['basedir'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1106
  return $dir;
1107
  }
1108
 
1126
  </div>
1127
  <?php
1128
  }
1129
+ /**
1130
+ *
1131
+ */
1132
+
1133
+ function wpcf_admin_enqueue_scripts($hook)
1134
+ {
1135
+ wp_register_script(
1136
+ 'marketing-getting-started',
1137
+ plugin_dir_url( __FILE__ ).'/marketing/getting-started/assets/scripts/getting-started.js',
1138
+ array('jquery'),
1139
+ WPCF_VERSION,
1140
+ true
1141
+ );
1142
+ if ( preg_match( '@/marketing/getting-started/[^/]+.php$@', $hook ) ) {
1143
+ $marketing = new WPCF_Types_Marketing_Messages();
1144
+ wp_localize_script(
1145
+ 'marketing-getting-started',
1146
+ 'marketing_getting_started',
1147
+ array( 'id' => $marketing->get_option_name() )
1148
+ );
1149
+ wp_enqueue_script('marketing-getting-started');
1150
+ wp_enqueue_style(
1151
+ 'marketing-getting-started',
1152
+ plugin_dir_url( __FILE__ ).'/marketing/getting-started/assets/css/getting-started.css',
1153
+ array(),
1154
+ WPCF_VERSION,
1155
+ 'all'
1156
+ );
1157
+ }
1158
+ }
1159
+
1160
 
1161
  /**
1162
  * add types configuration to debug
1171
  add_action( 'wpcf_admin_header', 'wpcf_welcome_panel', PHP_INT_SIZE );
1172
  add_filter( 'icl_get_extra_debug_info', 'wpcf_get_extra_debug_info' );
1173
 
1174
+ function wpcf_admin_add_submenu_page($menu, $menu_slug = null, $menu_parent = 'wpcf')
1175
+ {
1176
+ if ( !is_admin() ) {
1177
+ return;
1178
+ }
1179
+ $wpcf_capability = apply_filters( 'wpcf_capability', 'manage_options' );
1180
+ $menu_slug = array_key_exists('menu_slug', $menu)? $menu['menu_slug']:$menu_slug;
1181
+ /**
1182
+ * add submenu
1183
+ */
1184
+ $hook = add_submenu_page(
1185
+ $menu_parent,
1186
+ isset($menu['page_title'])? $menu['page_title']:$menu['menu_title'],
1187
+ $menu['menu_title'],
1188
+ $wpcf_capability,
1189
+ $menu_slug,
1190
+ array_key_exists('function', $menu)? $menu['function']:null
1191
+ );
1192
+ if ( !empty($menu_slug) ) {
1193
+ wpcf_admin_plugin_help( $hook, $menu_slug );
1194
+ }
1195
+ /**
1196
+ * add action
1197
+ */
1198
+ if ( !array_key_exists('load_hook', $menu) && array_key_exists('function', $menu) ) {
1199
+ $menu['load_hook'] = sprintf( '%s_hook', $menu['function'] );
1200
+ }
1201
+ if ( !empty($menu['load_hook']) && function_exists( $menu['load_hook'] ) ) {
1202
+ $action = sprintf(
1203
+ 'load-%s',
1204
+ array_key_exists('hook', $menu)? $menu['hook']:$hook
1205
+ );
1206
+ add_action( $action, $menu['load_hook'] );
1207
+ }
1208
+ /**
1209
+ * add submenu to submenu
1210
+ */
1211
+ if ( array_key_exists('submenu', $menu) ) {
1212
+ foreach( $menu['submenu'] as $submenu_slug => $submenu ) {
1213
+ wpcf_admin_add_submenu_page($submenu, $submenu_slug, $hook);
1214
+ }
1215
+ }
1216
+ return $hook;
1217
+ }
1218
+
1219
+ /**
1220
+ * sort helper for tables
1221
+ */
1222
+ function wpcf_usort_reorder($a,$b)
1223
+ {
1224
+ $orderby = (!empty($_REQUEST['orderby'])) ? sanitize_text_field( $_REQUEST['orderby'] ) : 'title'; //If no sort, default to title
1225
+ $order = (!empty($_REQUEST['order'])) ? sanitize_text_field( $_REQUEST['order'] ) : 'asc'; //If no order, default to asc
1226
+ if ( ! in_array( $order, array( 'asc', 'desc' ) ) ) {
1227
+ $order = 'asc';
1228
+ }
1229
+ if ('title' == $orderby || !isset($a[$orderby])) {
1230
+ $orderby = 'slug';
1231
+ }
1232
+ $result = strcmp($a[$orderby], $b[$orderby]); //Determine sort order
1233
+ return ($order==='asc') ? $result : -$result; //Send final sort direction to usort
1234
+ }
1235
+
1236
+ add_filter('set-screen-option', 'wpcf_table_set_option', 10, 3);
1237
+ function wpcf_table_set_option($status, $option, $value)
1238
+ {
1239
+ return $value;
1240
+ }
classes/class.wpcf-marketing-messages.php ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Types Marketing Class
5
+ *
6
+ *
7
+ */
8
+
9
+ include_once dirname(__FILE__).'/class.wpcf-marketing.php';
10
+
11
+ /**
12
+ * Types Marketing Class
13
+ *
14
+ * @since Types 1.6.5
15
+ * @package Types
16
+ * @subpackage Classes
17
+ * @version 0.1
18
+ * @category Help
19
+ * @author marcin <marcin.p@icanlocalize.com>
20
+ */
21
+ class WPCF_Types_Marketing_Messages extends WPCF_Types_Marketing
22
+ {
23
+ private $state;
24
+
25
+ public function __construct()
26
+ {
27
+ parent::__construct();
28
+ add_action('admin_enqueue_scripts', array($this, 'register_scripts'), 1);
29
+ add_action('wp_ajax_toolset_messages', array( $this, 'update_toolset_messages' ));
30
+ add_action('admin_notices', array($this, 'add_message_after_activate'));
31
+ $this->set_state();
32
+ }
33
+
34
+ private function set_state()
35
+ {
36
+ $this->state = '0' == get_option($this->option_disable, '0')? 'endabled':'disabled';
37
+
38
+ if ('disabled' == $this->state) {
39
+ return;
40
+ }
41
+ if ( self::check_register() ) {
42
+ $this->state = 'disabled';
43
+ }
44
+ }
45
+
46
+ public static function check_register()
47
+ {
48
+ if(!function_exists('WP_Installer')){
49
+ return false;
50
+ }
51
+ $repos = array(
52
+ 'toolset'
53
+ );
54
+ foreach( $repos as $repository_id ) {
55
+ $key = WP_Installer()->repository_has_subscription($repository_id);
56
+ if ( empty($key) ) {
57
+ continue;
58
+ }
59
+ return true;
60
+ }
61
+ return false;
62
+ }
63
+
64
+ private function get_data()
65
+ {
66
+ /**
67
+ * check kind
68
+ */
69
+ $kind = $this->get_kind();
70
+ /**
71
+ * get default
72
+ */
73
+ if ( empty($kind) ) {
74
+ $kind = $this->get_default_kind();
75
+ }
76
+ /**
77
+ * check exists?
78
+ */
79
+ if ( empty($kind) || !array_key_exists($kind, $this->adverts ) ) {
80
+ return;
81
+ }
82
+
83
+ /**
84
+ * check type
85
+ */
86
+ $type = $this->get_page_type();
87
+ if ( empty($type) || !array_key_exists($type, $this->adverts[$kind]) ) {
88
+ return;
89
+ }
90
+ if ( !is_array($this->adverts[$kind][$type]) ) {
91
+ return;
92
+ }
93
+ /**
94
+ * get number
95
+ */
96
+ $number = intval(get_user_option('types-modal'));
97
+ if ( !isset($this->adverts[$kind][$type][$number]) ) {
98
+ if ( empty($this->adverts[$kind][$type]) ) {
99
+ return;
100
+ }
101
+ $number = 0;
102
+ }
103
+
104
+ $data = $this->adverts[$kind][$type][$number];
105
+ $data['number'] = $number;
106
+ $data['count'] = count($this->adverts[$kind][$type]);
107
+ return $data;
108
+ }
109
+
110
+ private function replace_placeholders($text)
111
+ {
112
+ $type = $this->get_page_type();
113
+ switch($type) {
114
+ case 'cpt':
115
+ if (
116
+ is_array($_GET)
117
+ && array_key_exists('wpcf-post-type', $_GET)
118
+ ) {
119
+ $types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
120
+ $candidate_key = sanitize_text_field( $_GET['wpcf-post-type'] );
121
+ if ( array_key_exists($candidate_key, $types ) ) {
122
+ $text = preg_replace( '/PPP/', $types[$candidate_key]['labels']['name'], $text);
123
+ }
124
+ }
125
+ break;
126
+
127
+ case 'taxonomy':
128
+ if (
129
+ is_array($_GET)
130
+ && array_key_exists('wpcf-tax', $_GET)
131
+ ) {
132
+ $taxonomies = get_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, array());
133
+ $candidate_key = sanitize_text_field( $_GET['wpcf-tax'] );
134
+ if ( array_key_exists($candidate_key, $taxonomies) ) {
135
+ $text = preg_replace( '/TTT/', $taxonomies[$candidate_key]['labels']['name'], $text);
136
+ if ( array_key_exists('supports', $taxonomies[$candidate_key]) ) {
137
+ $types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
138
+ $post_type = array_keys($taxonomies[$candidate_key]['supports']);
139
+ if ( !empty($post_type) ) {
140
+ $post_type = $post_type[array_rand($post_type)];
141
+ $post_type = get_post_type_object($post_type);
142
+ if ( $post_type ) {
143
+ $text = preg_replace( '/PPP/', $post_type->labels->name, $text);
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
149
+ break;
150
+ }
151
+ /**
152
+ * defaults
153
+ */
154
+ $text = preg_replace( '/PPP/', __('Posts'), $text);
155
+ $text = preg_replace( '/TTT/', __('Tags'), $text);
156
+
157
+ return $text;
158
+ }
159
+
160
+ public function register_scripts()
161
+ {
162
+
163
+ $data = $this->get_data();
164
+ if ( empty($data) ) {
165
+ return;
166
+ }
167
+ /**
168
+ * common question
169
+ */
170
+ $data['message'] = __('Saving your changes', 'wpcf');
171
+ $data['spinner'] = apply_filters('wpcf_marketing_message', admin_url('/images/spinner.gif'), $data, 'spinner');
172
+ $data['question'] = apply_filters('wpcf_marketing_message', __('Did you know?', 'wpcf'), $data, 'question');
173
+ /**
174
+ * random image & class
175
+ */
176
+ $image = isset($data['image'])? $data['image']:'views';
177
+ $src = sprintf(
178
+ '%s/marketing/assets/images/%s.png',
179
+ WPCF_RELPATH,
180
+ $image
181
+ );
182
+ $data['image'] = apply_filters('wpcf_marketing_message', $src, $data, 'image');
183
+ $data['class'] = apply_filters('wpcf_marketing_message', $image, $data, 'class');
184
+ /**
185
+ * values depend on type
186
+ */
187
+ foreach ( array('header', 'description') as $key ) {
188
+ $value = '';
189
+ if ( isset($data[$key]) && $data[$key] ) {
190
+ $value = $this->replace_placeholders($data[$key]);
191
+ }
192
+ $data[$key] = apply_filters('wpcf_marketing_message', $value, $data, $key );
193
+ $data['state'] = $this->state;
194
+ }
195
+ wp_register_script( 'types-modal', WPCF_EMBEDDED_RES_RELPATH.'/js/modal.js', array('toolset-colorbox'), WPCF_VERSION, true);
196
+ wp_localize_script( 'types-modal', 'types_modal', $data);
197
+ wp_enqueue_script('types-modal');
198
+ }
199
+
200
+ public function update_message($message = false)
201
+ {
202
+ if (empty($message)) {
203
+ return;
204
+ }
205
+ echo '<div class="updated"><p>', $message, '</p></div>';
206
+ }
207
+
208
+ public function update_options()
209
+ {
210
+ if(!isset($_POST['marketing'])) {
211
+ return;
212
+ }
213
+ if ( !wp_verify_nonce($_POST['marketing'], 'update')) {
214
+ return;
215
+ }
216
+ if (
217
+ array_key_exists($this->option_name, $_POST)
218
+ && array_key_exists($_POST[$this->option_name], $this->options)
219
+ ) {
220
+ // @todo we need to sanitize $_POST[$this->option_name]: is it a string, an array or what?
221
+ if ( !add_option($this->option_name, $_POST[$this->option_name], '', 'no') ) {
222
+ update_option($this->option_name, $_POST[$this->option_name]);
223
+ }
224
+ }
225
+ $this->set_state();
226
+ }
227
+
228
+ public function delete_option_kind()
229
+ {
230
+ delete_option($this->option_name);
231
+ }
232
+
233
+ public function get_kind_list()
234
+ {
235
+ $type = get_option($this->option_name);
236
+ $content = '<ul class="marketing-kind-list">';
237
+ foreach( $this->options as $key => $one ) {
238
+ $content .= '<li>';
239
+ $content .= sprintf(
240
+ '<input type="radio" name="%s" value="%s" id="getting_started_%s" %s/>',
241
+ $this->get_option_name(),
242
+ $key,
243
+ $key,
244
+ $type == $key? ' checked="checked" ':''
245
+ );
246
+ $content .= sprintf(
247
+ '<label for="getting_started_%s"> <strong>%s</strong>%s%s</label>',
248
+ $key,
249
+ $one['title'],
250
+ array_key_exists('description', $one)? ' | ':'',
251
+ array_key_exists('description', $one)? $one['description']:''
252
+ );
253
+ $content .= '</li>';
254
+ }
255
+ $content .= '</ul>';
256
+ return $content;
257
+ }
258
+
259
+ public function kind_list()
260
+ {
261
+ echo $this->get_kind_list();
262
+ }
263
+
264
+ public function show_top($update = true)
265
+ {
266
+ $data = $this->get_data();
267
+ if ( empty($data) ) {
268
+ return false;
269
+ }
270
+ $content = '<div class="icon-toolset-logo icon-toolset">';
271
+ $content .= sprintf('<p class="wpcf-notif-header">%s</p>', $update? __('Updated!', 'wpcf'):__('Created!', 'wpcf') );
272
+ if ( 'endabled' == $this->state) {
273
+ $content .= '<p class="wpcf-notif-description">';
274
+ if ( isset($data['link']) ) {
275
+ $content .= sprintf(
276
+ '<a href="%s">%s</a>',
277
+ $this->add_ga_campain($data['link'], 'save-updated'),
278
+ $data['description']
279
+ );
280
+ } else {
281
+ $content .= $data['description'];
282
+ }
283
+ $content .= '</p>';
284
+ }
285
+ $content .= '</div>';
286
+
287
+ $content = $this->replace_placeholders($content);
288
+
289
+ /**
290
+ * after all set up types-modal for next time
291
+ */
292
+ $key = rand( 0, $data['count']-1 );
293
+ $user_id = get_current_user_id();
294
+ update_user_option($user_id, 'types-modal', $key);
295
+
296
+ return $content;
297
+ }
298
+
299
+ public function get_content()
300
+ {
301
+ if ( $url = $this->get_kind_url() ) {
302
+ include_once dirname(__FILE__).'/class.wpcf-marketing-tutorial.php';
303
+ $tutorial = new WPCF_Types_Marketing_Tutorial();
304
+ return $tutorial->get_content('kind');
305
+ }
306
+ return;
307
+ }
308
+
309
+ // @todo nonce ?
310
+ // @todo auth ?
311
+ public function update_toolset_messages()
312
+ {
313
+ $settings = wpcf_get_settings();
314
+ if (
315
+ array_key_exists('value', $_POST)
316
+ && 'checked' == $_POST['value']
317
+ ) {
318
+ if ( !add_option($this->option_disable, '1', '', 'no') ) {
319
+ update_option($this->option_disable, '1');
320
+ }
321
+ $settings['toolset_messages'] = true;
322
+ } else {
323
+ delete_option($this->option_disable);
324
+ $settings['toolset_messages'] = false;
325
+ }
326
+ update_option('wpcf_settings', $settings);
327
+ echo '<div class="updated"><p>';
328
+ _e('Toolset Messages state saved!', 'wpcf');
329
+ echo '</p></div>';
330
+ die;
331
+ }
332
+
333
+ public function add_message_after_activate()
334
+ {
335
+ if ( !isset($_GET['activate']) ) {
336
+ return;
337
+ }
338
+ if ( is_multisite() ) {
339
+ return;
340
+ }
341
+ if ( 'show' != get_option('types_show_on_activate') ) {
342
+ return;
343
+ }
344
+ wp_enqueue_style('onthego-admin-styles');
345
+ wp_enqueue_style('wpcf-css-embedded');
346
+ $data = array(
347
+ 'header' => __('Need help with <em>Types</em>?', 'wpcf'),
348
+ 'text' => __('Types plugin includes a lot of options. Tell us what kind of site you are building and we\'ll show you how to use Types in the best way.', 'wpcf'),
349
+ 'button_primary_url' => add_query_arg( 'page', basename(dirname(dirname(__FILE__))).'/marketing/getting-started/index.php', admin_url('admin.php') ),
350
+ 'button_primary_text' => __('Get Started', 'wpcf'),
351
+ 'button_dismiss_url' => '',
352
+ 'button_dismiss_text' => __('Dismiss', 'wpcf'),
353
+ );
354
+ wp_localize_script('marketing-getting-started', 'types_activate', $data);
355
+ wp_enqueue_script('marketing-getting-started');
356
+ update_option('types_show_on_activate', 'hide');
357
+ }
358
+
359
+ }
360
+
classes/class.wpcf-marketing-tutorial.php ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Types Tutorial Class
5
+ *
6
+ *
7
+ */
8
+
9
+ include_once dirname(__FILE__).'/class.wpcf-marketing.php';
10
+
11
+ /**
12
+ * Types Tutorial Class
13
+ *
14
+ * @since Types 1.6.5
15
+ * @package Types
16
+ * @subpackage Classes
17
+ * @version 0.1
18
+ * @category Help
19
+ * @author marcin <marcin.p@icanlocalize.com>
20
+ */
21
+ class WPCF_Types_Marketing_Tutorial extends WPCF_Types_Marketing
22
+ {
23
+ private $id;
24
+ private $cache;
25
+ private $tutorials;
26
+
27
+ public function __construct()
28
+ {
29
+ parent::__construct();
30
+ }
31
+
32
+ private function error($error_id, $message = false)
33
+ {
34
+ $content = wpcf_add_admin_header(__('Tutorial error', 'wpcf'));
35
+ $content .= '<div class="error settings-error"><p><strong>';
36
+ switch( $error_id ) {
37
+ case 'no id':
38
+ case 'wrong id':
39
+ $content .= __('Wrong tutorial id.', 'wpcf');
40
+ break;
41
+ case 'empty url':
42
+ case 'wrong response status':
43
+ case 'http request failed':
44
+ $content .= __('There is a problem with tutorial url.', 'wpcf');
45
+ break;
46
+ case 'empty body':
47
+ $content .= __('Selected tutorial is empty.', 'wpcf');
48
+ if ( current_user_can('manage_options') ) {
49
+ }
50
+ break;
51
+ default:
52
+ if ( $message ) {
53
+ $content .= $message;
54
+ } else {
55
+ $content .= __('Some error occured.', 'wpcf');
56
+ }
57
+ }
58
+ $content .= '</strong></p></div>';
59
+ return $content;
60
+ }
61
+
62
+ private function produce($url = false)
63
+ {
64
+ if ( empty( $url ) ) {
65
+ $url = $this->get('url');
66
+ }
67
+ if ( empty($url) ) {
68
+ return $this->error('empty url');
69
+ }
70
+ $url = $this->add_ga_campain($url, 'fetch-data');
71
+
72
+ $resp = wp_remote_get($url);
73
+
74
+ if ( is_wp_error( $resp ) ) {
75
+ /**
76
+ * if user can manage_options then display a real error message
77
+ */
78
+ if( current_user_can('manage_options') ) {
79
+ return $this->error(false, $resp->get_error_message());
80
+ } else {
81
+ return $this->error('http request failed');
82
+ }
83
+ }
84
+
85
+ if ( 200 != $resp['response']['code'] ) {
86
+ return $this->error('wrong response status');
87
+ }
88
+
89
+ $title = preg_split('/<header class="masthead">/', $resp['body']);
90
+ $title = preg_split('/<h1>/', $title[1]);
91
+ $title = preg_split('@</h1>@', $title[1]);
92
+ $title = $title[0];
93
+
94
+ $body = '';
95
+ $containers = preg_split( '/<div class="container">/', $resp['body'] );
96
+ foreach( $containers as $container ) {
97
+ if ( !preg_match('/<div class="col-sm-[\d]+ post-content[^>]+>/', $container) ) {
98
+ continue;
99
+ }
100
+ $body = $container;
101
+
102
+ }
103
+ if ( empty( $body ) ) {
104
+ return $this->error('empty body');
105
+ }
106
+ $body = preg_split('/<aside/', $body);
107
+ $body = $body[0];
108
+ if ( empty( $body ) ) {
109
+ return $this->error('empty body');
110
+ }
111
+ $body = sprintf(
112
+ '<h1 class="title">%s</h1><div class="container"><div class="post-content">%s',
113
+ $title,
114
+ $body
115
+ );
116
+ set_transient( $this->cache, $body, 14 * DAY_IN_SECONDS);
117
+ return $body;
118
+ }
119
+
120
+ private function add_select_site_kind_intruction()
121
+ {
122
+ $kind = $this->get_kind();
123
+ if ( empty($kind) ) {
124
+ return;
125
+ }
126
+ $content = '';
127
+ /**
128
+ * current url
129
+ */
130
+ $current_url = add_query_arg(
131
+ array( 'page' => basename(WPCF_ABSPATH).'/marketing/getting-started/index.php',),
132
+ admin_url('admin.php')
133
+ );
134
+ /**
135
+ * add button to change site kind
136
+ */
137
+ $content .= sprintf(
138
+ '<a class="button" href="%s">%s</a>',
139
+ add_query_arg( array( 'kind' => 'choose',), $current_url),
140
+ __('Select instructions for other kinds of sites', 'wpcf')
141
+ );
142
+ /**
143
+ * add reload link
144
+ */
145
+ $content .= sprintf(
146
+ ' <a class="alignright" href="%s">%s</a>',
147
+ wp_nonce_url($current_url, 'reload', 'toolset'),
148
+ __('Reload', 'wpcf')
149
+ );
150
+ return sprintf( '<div class="container wpcf-tutorial-other wpcf-notif"><p>%s</p></div>', $content);
151
+ }
152
+
153
+ public function get_content()
154
+ {
155
+ $class = ' class="wp-types-icon-external" ';
156
+ $target = ' target="_blank" ';
157
+
158
+ $url = $this->get_kind_url();
159
+ $this->cache = md5($url);
160
+ $content = get_transient($this->cache);
161
+ /**
162
+ * check force reload
163
+ */
164
+ $force_reload = isset($_GET['toolset']) && wp_verify_nonce($_GET['toolset'], 'reload');
165
+ if ( $force_reload || false === apply_filters( 'tooleset_messages_get_transient', $content ) ) {
166
+ $content = $this->produce($url);
167
+ }
168
+ /**
169
+ * create array to replace
170
+ */
171
+ $replces = array(
172
+ 'from' => array(),
173
+ 'to' => array(),
174
+ );
175
+
176
+ $content = preg_replace('/(<a.*?)[ ]?target="_blank"(.*?)/', '$1$2', $content);
177
+
178
+ /**
179
+ * with '
180
+ */
181
+ preg_match_all('/href=\'([^\']+)\'/', $content, $matches );
182
+ if ( $matches ) {
183
+ foreach ( $matches[1] as $url ) {
184
+ if ( !preg_match('/wp-types.com/', $url ) ) {
185
+ continue;
186
+ }
187
+ $replces['from'][] = sprintf("|'%s'|", $url);
188
+ $replces['to'][] = sprintf( "'%s'", $this->add_ga_campain($url).$class.$target);
189
+ }
190
+ }
191
+ /**
192
+ * with "
193
+ */
194
+ preg_match_all('/href="([^"]+)"/', $content, $matches );
195
+ if ( $matches ) {
196
+ foreach ( $matches[1] as $url ) {
197
+ if ( !preg_match('/wp-types.com/', $url ) ) {
198
+ continue;
199
+ }
200
+ $replces['from'][] = sprintf('|"%s"|', $url);
201
+ $replces['to'][] = sprintf( '"%s"', $this->add_ga_campain($url)).$class.$target;
202
+ }
203
+ }
204
+
205
+ //WP-Types External
206
+
207
+ /**
208
+ * with '
209
+ */
210
+ preg_match_all('/href=\'([^\']+)\'/', $content, $matches );
211
+ if ( $matches ) {
212
+ foreach ( $matches[1] as $url ) {
213
+ if ( preg_match('/wp-types.com/', $url ) ) {
214
+ continue;
215
+ }
216
+ $replces['from'][] = sprintf("|'%s'|", $url);
217
+ $replces['to'][] = sprintf( "'%s'", $this->add_ga_campain($url).$class.$target);
218
+ }
219
+ }
220
+ /**
221
+ * with "
222
+ */
223
+ preg_match_all('/href="([^"]+)"/', $content, $matches );
224
+ if ( $matches ) {
225
+ foreach ( $matches[1] as $url ) {
226
+ if ( preg_match('/wp-types.com/', $url ) ) {
227
+ continue;
228
+ }
229
+ $replces['from'][] = sprintf('|"%s"|', $url);
230
+ $replces['to'][] = sprintf( '"%s"', $this->add_ga_campain($url)).$class.$target;
231
+ }
232
+ }
233
+
234
+
235
+
236
+ if (count($replces['from'])) {
237
+ $content = preg_replace( $replces['from'], $replces['to'], $content );
238
+ }
239
+ $content .= $this->add_select_site_kind_intruction();
240
+ return $content;
241
+ }
242
+
243
+ }
classes/class.wpcf-marketing.php ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Types Marketing Class
5
+ *
6
+ *
7
+ */
8
+
9
+ /**
10
+ * Types Marketing Class
11
+ *
12
+ * @since Types 1.6.5
13
+ * @package Types
14
+ * @subpackage Classes
15
+ * @version 0.1
16
+ * @category Help
17
+ * @author marcin <marcin.p@icanlocalize.com>
18
+ */
19
+ class WPCF_Types_Marketing
20
+ {
21
+ protected $option_name = 'types-site-kind';
22
+ protected $option_disable = 'types-site-kind-disable';
23
+ protected $options;
24
+ protected $adverts;
25
+
26
+ public function __construct()
27
+ {
28
+ $this->options = include WPCF_ABSPATH.'/marketing/etc/types-site-kinds.php';
29
+ $this->adverts = include WPCF_ABSPATH.'/marketing/etc/types.php';
30
+ add_filter('admin_body_class', array($this, 'admin_body_class'));
31
+ add_action( 'wpcf_menu_plus', array( $this, 'add_getting_started_to_admin_menu'), PHP_INT_MAX);
32
+ add_filter('editor_addon_dropdown_after_title', array($this, 'add_views_advertising'));
33
+ }
34
+
35
+ /**
36
+ * Add Views advertising on modal shortcode window.
37
+ *
38
+ * Add Views advertising on modal shortcode window. Advertisng will be
39
+ * added only when Views plugin is not active.
40
+ *
41
+ * @since 1.7
42
+ * @param string $content Content of this filter.
43
+ * @return string Content with advert or not.
44
+ */
45
+ public function add_views_advertising($content)
46
+ {
47
+ /**
48
+ * do not load advertising if Views are active
49
+ */
50
+ if ( defined('WPV_VERSION') ) {
51
+ return $content;
52
+ }
53
+ /**
54
+ * Allow to turn off views advert.
55
+ *
56
+ * This filter allow to turn off views advert even Viwes plugin is not
57
+ * avaialbe.
58
+ *
59
+ * @since 1.7
60
+ *
61
+ * @param boolean $show Show adver?
62
+ */
63
+ if ( !apply_filters('show_views_advertising', true )) {
64
+ return;
65
+ }
66
+ $content .= '<div class="types-marketing types-marketing-views">';
67
+ $content .= sprintf(
68
+ '<h4><span class="icon-toolset-logo ont-color-orange"></span>%s</h4>',
69
+ __('Want to create templates with fields?', 'wpcf')
70
+ );
71
+ $content .= sprintf(
72
+ '<p>%s</p>',
73
+ __('The full Toolset package allows you to design templates for content and insert fields using the WordPress editor.', 'wpcf')
74
+ );
75
+ $content .= sprintf(
76
+ '<p class="buttons"><a href="%s" class="button" target="_blank">%s</a> <a href="%s" class="more" target="_blank">%s</a></p>',
77
+ esc_attr(
78
+ add_query_arg(
79
+ array(
80
+ 'utm_source' => 'typesplugin',
81
+ 'utm_medium' => 'insert-fields',
82
+ 'utm_campaig' => 'postedit',
83
+ 'utm_term' => 'meet-toolset',
84
+ ),
85
+ 'http://wp-types.com/'
86
+ )
87
+ ),
88
+ __('Meet Toolset', 'wpcf'),
89
+ esc_attr(
90
+ add_query_arg(
91
+ array(
92
+ 'utm_source' => 'typesplugin',
93
+ 'utm_medium' => 'insert-fields',
94
+ 'utm_campaig' => 'postedit',
95
+ 'utm_term' => 'creating-content-templates',
96
+ ),
97
+ 'http://wp-types.com/documentation/user-guides/view-templates/'
98
+ )
99
+ ),
100
+ __('Creating Templates for Content', 'wpcf')
101
+ );
102
+ $content .= '</div>';
103
+ return $content;
104
+ }
105
+
106
+ public function admin_body_class($classes)
107
+ {
108
+ $screen = get_current_screen();
109
+ if ( isset($screen->id) && preg_match( '@marketing/getting-started/index$@', $screen->id ) ) {
110
+ if ( !isset($_GET['kind'] )) {
111
+ $classes = 'wpcf-marketing';
112
+ }
113
+ else if ( isset($_POST['marketing'])) {
114
+ $classes = 'wpcf-marketing';
115
+ }
116
+ }
117
+
118
+ return $classes;
119
+ }
120
+
121
+ protected function get_page_type()
122
+ {
123
+ $screen = get_current_screen();
124
+ switch($screen->id) {
125
+ case 'types_page_wpcf-edit-type':
126
+ return 'cpt';
127
+ case 'types_page_wpcf-edit-tax':
128
+ return 'taxonomy';
129
+ case 'types_page_wpcf-edit':
130
+ case 'types_page_wpcf-edit-usermeta':
131
+ return 'fields';
132
+ }
133
+ return false;
134
+ }
135
+
136
+ public function get_options()
137
+ {
138
+ return $this->options;
139
+ }
140
+
141
+ public function get_option_name()
142
+ {
143
+ return $this->option_name;
144
+ }
145
+
146
+ public function get_default_kind()
147
+ {
148
+ if ( isset($this->options) && is_array($this->options) ) {
149
+ foreach ( $this->options as $kind => $options ) {
150
+ if ( array_key_exists('default', $options ) && $options['default']) {
151
+ return $kind;
152
+ }
153
+ }
154
+ }
155
+ return false;
156
+ }
157
+
158
+ public function get_kind()
159
+ {
160
+ $kind = get_option($this->option_name, false);
161
+ if (
162
+ $kind
163
+ && isset($this->options)
164
+ && is_array($this->options)
165
+ && array_key_exists( $kind, $this->options )
166
+ ) {
167
+ return $kind;
168
+ }
169
+ return false;
170
+ }
171
+
172
+ public function get_kind_url($kind = false)
173
+ {
174
+ if ( empty($kind) ) {
175
+ $kind = $this->get_kind();
176
+ }
177
+ if (
178
+ $kind
179
+ && isset($this->options)
180
+ && is_array($this->options)
181
+ && array_key_exists('url', $this->options[$kind] )
182
+ ) {
183
+ return $this->options[$kind]['url'];
184
+ }
185
+ return;
186
+ }
187
+
188
+ public function get_option_disiable_value()
189
+ {
190
+ return get_option($this->option_disable, 0);
191
+ }
192
+
193
+ public function get_option_disiable_name()
194
+ {
195
+ return $this->option_disable;
196
+ }
197
+
198
+ protected function add_ga_campain($url, $utm_medium = 'getting-started')
199
+ {
200
+ $url = add_query_arg(
201
+ array(
202
+ 'utm_source' => 'typesplugin',
203
+ 'utm_medium' => $utm_medium,
204
+ 'utm_campaig' => sprintf('%s-howto', $this->get_kind() ),
205
+ ),
206
+ $url
207
+ );
208
+ return $url;
209
+ }
210
+
211
+ /**
212
+ * add Getting Started to menu
213
+ */
214
+ public function add_getting_started_to_admin_menu()
215
+ {
216
+ $menu = array(
217
+ 'page_title' => __( 'What kind of site are you building?', 'wpcf' ),
218
+ 'menu_title' => __( 'Getting Started', 'wpcf' ),
219
+ 'menu_slug' => basename(dirname(dirname(__FILE__))).'/marketing/getting-started/index.php',
220
+ 'hook' => 'wpcf_marketing',
221
+ 'load_hook' => 'wpcf_marketing_hook',
222
+ );
223
+ wpcf_admin_add_submenu_page($menu);
224
+ }
225
+
226
+
227
+ }
embedded/admin.php CHANGED
@@ -1,10 +1,6 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/admin.php $
5
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
6
- * $LastChangedRevision: 970205 $
7
- * $LastChangedBy: brucepearson $
8
  *
9
  */
10
  require_once(WPCF_EMBEDDED_ABSPATH . '/common/visual-editor/editor-addon.class.php');
@@ -52,11 +48,8 @@ function wpcf_embedded_admin_init_hook() {
52
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/file.php';
53
  // Add types button
54
  add_filter( 'attachment_fields_to_edit', 'wpcf_fields_file_attachment_fields_to_edit_filter', PHP_INT_MAX, 2 );
55
- // Add JS
56
- add_action( 'admin_head', 'wpcf_fields_file_media_admin_head' );
57
  // Filter media TABs
58
- add_filter( 'media_upload_tabs',
59
- 'wpcf_fields_file_media_upload_tabs_filter' );
60
  }
61
 
62
  register_post_type( 'wp-types-group',
@@ -157,14 +150,15 @@ function wpcf_admin_fields_postfields_styles(){
157
 
158
  // $groups = wpcf_admin_fields_get_groups();
159
  $groups = wpcf_admin_post_get_post_groups_fields( wpcf_admin_get_edited_post() );
160
- echo '<style type="text/css">';
161
  if ( !empty( $groups ) ) {
 
162
  foreach ( $groups as $group ) {
163
  echo str_replace( "}", "}\n",
164
  wpcf_admin_get_groups_admin_styles_by_group( $group['id'] ) );
165
  }
 
166
  }
167
- echo '</style>';
168
  }
169
 
170
  /**
@@ -187,42 +181,6 @@ function wpcf_form( $id, $form = array() ) {
187
  return $wpcf_forms[$id];
188
  }
189
 
190
- /**
191
- * Add submit button, cancel button and help link to the popup.
192
- *
193
- */
194
- function wpcf_form_popup_helper( $form, $submit_text = '', $cancel_text = '',
195
- $help = array() ) {
196
- if ( $submit_text ) {
197
- $form['submit'] = array(
198
- '#type' => 'submit',
199
- '#name' => 'submit',
200
- '#value' => $submit_text,
201
- '#attributes' => array('class' => 'button-primary'),
202
- );
203
- }
204
- if ( $cancel_text ) {
205
- $form['cancel'] = array(
206
- '#type' => 'button',
207
- '#name' => 'cancel',
208
- '#value' => $cancel_text,
209
- '#attributes' => array('class' => 'button-secondary',
210
- 'onclick' => 'window.parent.jQuery(\'#TB_closeWindowButton\').click();return true;'),
211
- '#before' => ' ',
212
- );
213
- }
214
- if ( $help ) {
215
- $form = array_reverse( $form, true );
216
- $form['help'] = array(
217
- '#type' => 'markup',
218
- '#markup' => '<a class="wpcf-help-link" href="' . $help['url'] . '" target="_blank">' . $help['text'] . '</a>',
219
- );
220
- $form = array_reverse( $form, true );
221
- }
222
-
223
- return $form;
224
- }
225
-
226
  /**
227
  * Renders form elements.
228
  *
@@ -329,16 +287,17 @@ function wpcf_admin_validation_messages( $method = false, $sprintf = '' ) {
329
  'date' => __( 'Please enter a valid date', 'wpcf' ),
330
  'digits' => __( 'Please enter numeric data', 'wpcf' ),
331
  'number' => __( 'Please enter numeric data', 'wpcf' ),
332
- 'alphanumeric' => __( 'Letters, numbers, spaces or underscores only please',
333
- 'wpcf' ),
334
- 'nospecialchars' => __( 'Letters, numbers, spaces, underscores and dashes only please',
335
- 'wpcf' ),
336
- 'rewriteslug' => __( 'Letters, numbers, slashes, underscores and dashes only please',
337
- 'wpcf' ),
338
- 'negativeTimestamp' => __( 'Please enter a date after 1 January 1970.',
339
- 'wpcf' ),
340
- 'maxlength' => sprintf( __( 'Maximum of %s characters exceeded.', 'wpcf' ),
341
- strval( $sprintf ) ),
 
342
  );
343
  if ( $method ) {
344
  return isset( $messages[$method] ) ? $messages[$method] : '';
@@ -387,8 +346,20 @@ function wpcf_show_admin_messages() {
387
  * @param type $class
388
  * @return type
389
  */
390
- function wpcf_admin_message_store( $message, $class = 'updated',
391
- $keep_id = false ) {
 
 
 
 
 
 
 
 
 
 
 
 
392
  $messages = get_option( 'wpcf-messages', array() );
393
  $messages[get_current_user_id()][md5( $message )] = array(
394
  'message' => $message,
1
  <?php
2
  /**
3
  *
 
 
 
 
4
  *
5
  */
6
  require_once(WPCF_EMBEDDED_ABSPATH . '/common/visual-editor/editor-addon.class.php');
48
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/file.php';
49
  // Add types button
50
  add_filter( 'attachment_fields_to_edit', 'wpcf_fields_file_attachment_fields_to_edit_filter', PHP_INT_MAX, 2 );
 
 
51
  // Filter media TABs
52
+ add_filter( 'media_upload_tabs', 'wpcf_fields_file_media_upload_tabs_filter' );
 
53
  }
54
 
55
  register_post_type( 'wp-types-group',
150
 
151
  // $groups = wpcf_admin_fields_get_groups();
152
  $groups = wpcf_admin_post_get_post_groups_fields( wpcf_admin_get_edited_post() );
153
+
154
  if ( !empty( $groups ) ) {
155
+ echo '<style type="text/css">';
156
  foreach ( $groups as $group ) {
157
  echo str_replace( "}", "}\n",
158
  wpcf_admin_get_groups_admin_styles_by_group( $group['id'] ) );
159
  }
160
+ echo '</style>';
161
  }
 
162
  }
163
 
164
  /**
181
  return $wpcf_forms[$id];
182
  }
183
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  /**
185
  * Renders form elements.
186
  *
287
  'date' => __( 'Please enter a valid date', 'wpcf' ),
288
  'digits' => __( 'Please enter numeric data', 'wpcf' ),
289
  'number' => __( 'Please enter numeric data', 'wpcf' ),
290
+ 'alphanumeric' => __( 'Letters, numbers, spaces or underscores only please', 'wpcf' ),
291
+ 'nospecialchars' => __( 'Letters, numbers, spaces, underscores and dashes only please', 'wpcf' ),
292
+ 'rewriteslug' => __( 'Letters, numbers, slashes, underscores and dashes only please', 'wpcf' ),
293
+ 'negativeTimestamp' => __( 'Please enter a date after 1 January 1970.', 'wpcf' ),
294
+ 'maxlength' => sprintf( __( 'Maximum of %s characters exceeded.', 'wpcf' ), strval( $sprintf ) ),
295
+ 'minlength' => sprintf( __( 'Minimum of %s characters has not been reached.', 'wpcf' ), strval( $sprintf ) ),
296
+ /**
297
+ * see
298
+ * https://support.skype.com/en/faq/FA10858/what-is-a-skype-name-and-how-do-i-find-mine
299
+ */
300
+ 'skype' => __( 'Letters, numbers, dashes, underscores, commas and periods only please.', 'wpcf' ),
301
  );
302
  if ( $method ) {
303
  return isset( $messages[$method] ) ? $messages[$method] : '';
346
  * @param type $class
347
  * @return type
348
  */
349
+ function wpcf_admin_message_store( $message, $class = 'updated', $keep_id = false )
350
+ {
351
+ /**
352
+ * Allow to store or note
353
+ *
354
+ * Filter allow to turn off storing messages in Types
355
+ *
356
+ * @since 1.6.6
357
+ *
358
+ * @param boolean $var default value is true to show messages
359
+ */
360
+ if (!apply_filters('wpcf_admin_message_store', true) ) {
361
+ return;
362
+ }
363
  $messages = get_option( 'wpcf-messages', array() );
364
  $messages[get_current_user_id()][md5( $message )] = array(
365
  'message' => $message,
embedded/bootstrap.php CHANGED
@@ -7,10 +7,6 @@
7
  *
8
  * @since Types 1.2
9
  *
10
- * $HeadURL: https://www.onthegosystems.com/misc_svn/cck/tags/1.6.2/embedded/bootstrap.php $
11
- * $LastChangedDate: 2014-08-28 12:06:20 +0200 (Thu, 28 Aug 2014) $
12
- * $LastChangedRevision: 26516 $
13
- * $LastChangedBy: bruce $
14
  *
15
  */
16
 
@@ -43,6 +39,12 @@ if ( !defined( 'TYPES_INIT_PRIORITY' ) ) {
43
  */
44
  add_action( 'init', 'wpcf_embedded_init', TYPES_INIT_PRIORITY );
45
 
 
 
 
 
 
 
46
  /*
47
  *
48
  *
@@ -131,7 +133,7 @@ function wpcf_embedded_init() {
131
  // Define necessary constants if plugin is not present
132
  // This ones are skipped if used as embedded code!
133
  if ( !defined( 'WPCF_VERSION' ) ) {
134
- define( 'WPCF_VERSION', '1.6.2' );
135
  define( 'WPCF_META_PREFIX', 'wpcf-' );
136
  }
137
 
@@ -300,16 +302,21 @@ function wpcf_embedded_init() {
300
  // 'attachment' = Media
301
  //
302
  $wpcf->excluded_post_types = array(
303
- 'revision', 'view', 'view-template', 'cred-form', 'nav_menu_item', 'mediapage',
 
 
 
 
 
 
 
 
 
304
  );
305
 
306
  // Init loader
307
  WPCF_Loader::init();
308
 
309
- // Init custom types and taxonomies
310
- wpcf_init_custom_types_taxonomies();
311
-
312
-
313
  /*
314
  * TODO Check why we enabled this
315
  *
7
  *
8
  * @since Types 1.2
9
  *
 
 
 
 
10
  *
11
  */
12
 
39
  */
40
  add_action( 'init', 'wpcf_embedded_init', TYPES_INIT_PRIORITY );
41
 
42
+ /**
43
+ * register_post_type & register_taxonomy - must be with default pririty to
44
+ * handle defult taxonomies
45
+ */
46
+ add_action( 'init', 'wpcf_init_custom_types_taxonomies');
47
+
48
  /*
49
  *
50
  *
133
  // Define necessary constants if plugin is not present
134
  // This ones are skipped if used as embedded code!
135
  if ( !defined( 'WPCF_VERSION' ) ) {
136
+ define( 'WPCF_VERSION', '1.7' );
137
  define( 'WPCF_META_PREFIX', 'wpcf-' );
138
  }
139
 
302
  // 'attachment' = Media
303
  //
304
  $wpcf->excluded_post_types = array(
305
+ 'dd_layouts',
306
+ 'cred-form',
307
+ 'cred-user-form',
308
+ 'mediapage',
309
+ 'nav_menu_item',
310
+ 'revision',
311
+ 'view',
312
+ 'view-template',
313
+ 'wp-types-group',
314
+ 'wp-types-user-group',
315
  );
316
 
317
  // Init loader
318
  WPCF_Loader::init();
319
 
 
 
 
 
320
  /*
321
  * TODO Check why we enabled this
322
  *
embedded/classes/class.wpcf-post-types.php CHANGED
@@ -3,10 +3,6 @@
3
  *
4
  * Post Types Class
5
  *
6
- * $HeadURL: https://www.onthegosystems.com/misc_svn/cck/tags/1.6.2/embedded/classes/class.wpcf-post-types.php $
7
- * $LastChangedDate: 2014-05-13 12:49:25 +0200 (Tue, 13 May 2014) $
8
- * $LastChangedRevision: 22267 $
9
- * $LastChangedBy: marcin $
10
  *
11
  */
12
 
@@ -29,6 +25,379 @@ class WPCF_Post_Types
29
  var $settings;
30
  var $messages = null;
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  function set($post_type, $settings = null)
33
  {
34
  $data = get_post_type_object( $post_type );
3
  *
4
  * Post Types Class
5
  *
 
 
 
 
6
  *
7
  */
8
 
25
  var $settings;
26
  var $messages = null;
27
 
28
+ function __construct()
29
+ {
30
+ add_action('admin_init', array($this, 'admin_init'));
31
+ add_action('admin_head-nav-menus.php', array($this, 'add_filters'));
32
+ add_filter('wp_setup_nav_menu_item', array( $this, 'setup_archive_item'));
33
+ add_filter('wp_nav_menu_objects', array( $this, 'maybe_make_current'));
34
+ }
35
+ /**
36
+ * Check has some custom fields to display.
37
+ *
38
+ * Check custom post type for custom fields to display on custom post edit
39
+ * screen.
40
+ *
41
+ * @since 1.7
42
+ *
43
+ * @param array $data CPT data
44
+ * @param string $field name of field to check
45
+ *
46
+ * @return bool It has some fields?
47
+ */
48
+ private function check_has_custom_fields($data, $field = false)
49
+ {
50
+ $value = isset($data['custom_fields']) && is_array($data['custom_fields']) && !empty($data['custom_fields']);
51
+ if ( false == $value ) {
52
+ return $value;
53
+ }
54
+ if ( true == $value && false == $field ) {
55
+ return $value;
56
+ }
57
+ return isset($data['custom_fields'][$field]);
58
+ }
59
+
60
+ /**
61
+ * Add sort to admin table list.
62
+ *
63
+ * Add sort by custom field to admin table with list of entries
64
+ *
65
+ * @since 1.7
66
+ *
67
+ * @param object $query QP Query object
68
+ *
69
+ */
70
+ public function pre_get_posts($query)
71
+ {
72
+ /**
73
+ * do not run in admin
74
+ */
75
+ if ( !is_admin() ) {
76
+ return;
77
+ }
78
+ /**
79
+ * check is main query and is set orderby and post_type
80
+ */
81
+ if (
82
+ $query->is_main_query()
83
+ && ( $orderby = $query->get( 'orderby' ) )
84
+ && ( $post_type = $query->get( 'post_type' ) )
85
+ ) {
86
+ $custom_post_types = wpcf_get_active_custom_types();
87
+ /**
88
+ * this CPT exists as a Types CPT?
89
+ */
90
+ if (!isset($custom_post_types[$post_type])) {
91
+ return;
92
+ }
93
+ /**
94
+ * set up meta_key if this CPT has this field to sort
95
+ */
96
+ if ($this->check_has_custom_fields($custom_post_types[$post_type], $orderby)) {
97
+ $query->set('meta_key',$orderby);
98
+ }
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Admin init.
104
+ *
105
+ * Admin init function used to add columns..
106
+ *
107
+ * @since 1.6.6
108
+ */
109
+ public function admin_init()
110
+ {
111
+ add_action('pre_get_posts', array($this, 'pre_get_posts'));
112
+ $custom_post_types = wpcf_get_active_custom_types();
113
+ foreach( $custom_post_types as $post_type => $data ) {
114
+ if ( $this->check_has_custom_fields($data)) {
115
+ $hook = sprintf('manage_edit-%s_columns', $post_type);
116
+ add_filter($hook, array($this, 'manage_posts_columns'));
117
+
118
+ $hook = sprintf('manage_edit-%s_sortable_columns', $post_type);
119
+ add_filter($hook, array($this, 'manage_posts_sortable_columns'));
120
+
121
+ $hook = sprintf('manage_%s_posts_custom_column', $post_type);
122
+ add_action($hook, array($this, 'manage_custom_columns'), 10, 2);
123
+ }
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Add custom fields as a sortable columns.
129
+ *
130
+ * Add custom fields as a sortable columns on custom post admin list
131
+ *
132
+ * @since 1.7
133
+ *
134
+ * @param array $columns Hashtable of columns;
135
+ *
136
+ * @return array Hashtable of columns;
137
+ */
138
+ public function manage_posts_sortable_columns($columns)
139
+ {
140
+ return $this->manage_posts_columns_common($columns, 'sortable');
141
+ }
142
+
143
+ /**
144
+ * Add custom fields column helper.
145
+ *
146
+ * Add custom fields as a sortable columns on custom post admin list
147
+ *
148
+ * @since 1.7
149
+ *
150
+ * @param array $columns Hashtable of columns;
151
+ * @param string $mode Work Mode.
152
+ *
153
+ * @return array Hashtable of columns;
154
+ */
155
+ private function manage_posts_columns_common($columns, $mode = 'normal')
156
+ {
157
+ $screen = get_current_screen();
158
+ if ( !isset( $screen->post_type) ) {
159
+ return $columns;
160
+ }
161
+ $custom_post_types = wpcf_get_active_custom_types();
162
+ if(
163
+ !isset($custom_post_types[$screen->post_type])
164
+ || !$this->check_has_custom_fields($custom_post_types[$screen->post_type])
165
+ || !isset($custom_post_types[$screen->post_type]['custom_fields'])
166
+ || empty($custom_post_types[$screen->post_type]['custom_fields'])
167
+ ) {
168
+ return $columns;
169
+ }
170
+ $fields = wpcf_admin_fields_get_fields();
171
+
172
+ foreach( array_keys($custom_post_types[$screen->post_type]['custom_fields']) as $full_id) {
173
+
174
+ $data = array();
175
+ $key = null;
176
+
177
+ foreach( $fields as $field_key => $field_data ) {
178
+ if ( !isset($field_data['meta_key']) ) {
179
+ continue;
180
+ }
181
+ if ( $full_id != $field_data['meta_key'] ) {
182
+ continue;
183
+ }
184
+ $key = $field_key;
185
+ $data = $field_data;
186
+ }
187
+
188
+ if ( !isset($data['meta_key']) ) {
189
+ continue;
190
+ }
191
+
192
+ if ( isset($custom_post_types[$screen->post_type]['custom_fields'][$data['meta_key']]) ) {
193
+ switch($mode) {
194
+ case 'sortable':
195
+ switch( $data['type'] ) {
196
+ /**
197
+ * turn of sorting for complex data
198
+ */
199
+ case 'date':
200
+ case 'skype':
201
+ $columns[$data['meta_key']] = false;;
202
+ break;
203
+ default:
204
+ $columns[$data['meta_key']] = $data['meta_key'];
205
+ break;
206
+ }
207
+ break;
208
+ case 'normal':
209
+ default:
210
+ $columns[$data['meta_key']] = $data['name'];
211
+ break;
212
+ }
213
+ }
214
+ }
215
+ return $columns;
216
+ }
217
+
218
+ /**
219
+ * Add custom fields as a columns.
220
+ *
221
+ * Add custom fields as a columns on custom post admin list
222
+ *
223
+ * @since 1.6.6
224
+ *
225
+ * @param array $columns Hashtable of columns;
226
+ *
227
+ * @return array Hashtable of columns;
228
+ */
229
+ public function manage_posts_columns($columns)
230
+ {
231
+ return $this->manage_posts_columns_common($columns, 'normal');
232
+ }
233
+
234
+ /**
235
+ * Show value of custom field.
236
+ *
237
+ * Show value of custom field.
238
+ *
239
+ * @since 1.6.6
240
+ *
241
+ * @param string $column Column name,
242
+ * @param int $var Current post ID.
243
+ */
244
+ public function manage_custom_columns($column, $post_id)
245
+ {
246
+ $value = get_post_meta($post_id, $column, true);
247
+ if ( empty($value) ) {
248
+ return;
249
+ }
250
+ $field = wpcf_admin_fields_get_field_by_meta_key($column);
251
+ if ( isset( $field['type'] ) ) {
252
+ switch( $field['type'] ) {
253
+ case 'image':
254
+ $default_width = '100px';
255
+ /**
256
+ * Width of image.
257
+ *
258
+ * Filter allow to change default image size displayed on
259
+ * admin etry list for custom field type image. Default is
260
+ * 100px - you can change it to any proper CSS width
261
+ * definition.
262
+ *
263
+ * @since 1.7
264
+ *
265
+ * @param string $var Default width "100px".
266
+ */
267
+ $width = apply_filters('wpcf_field_image_max_width', $default_width);
268
+ if (empty($width)) {
269
+ $width = $default_width;
270
+ }
271
+ $value = sprintf(
272
+ '<img src="%s" style="max-width:%s" alt="" />',
273
+ esc_attr($value),
274
+ esc_attr($width)
275
+ );
276
+ break;
277
+ case 'skype':
278
+ $value = isset($value['skypename'])? $value['skypename']:'';
279
+ break;
280
+ case 'date':
281
+ require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
282
+ $value = WPToolset_Field_Date::timetodate($value);
283
+ break;
284
+ }
285
+ }
286
+ if ( is_string($value ) ) {
287
+ echo $value;
288
+ }
289
+ }
290
+
291
+ /**
292
+ * Assign menu item the appropriate url
293
+ * @param object $menu_item
294
+ * @return object $menu_item
295
+ */
296
+ public function setup_archive_item( $menu_item ) {
297
+ if ( $menu_item->type !== 'post_type_archive' ) {
298
+ return $menu_item;
299
+ }
300
+ $post_type = $menu_item->object;
301
+ if (post_type_exists( $post_type )) {
302
+ $data = get_post_type_object( $post_type );
303
+ $menu_item->type_label = sprintf( __( 'Archive for %s', 'wpcf' ), $data->labels->name);
304
+ $menu_item->url = get_post_type_archive_link( $post_type );
305
+ }
306
+ return $menu_item;
307
+ }
308
+
309
+ public function add_filters()
310
+ {
311
+ $custom_post_types = wpcf_get_active_custom_types();
312
+ if ( empty($custom_post_types) ) {
313
+ return;
314
+ }
315
+ foreach ( $custom_post_types as $slug => $data ) {
316
+ add_filter( 'nav_menu_items_' . $slug, array( $this, 'add_archive_checkbox' ), null, 3 );
317
+ }
318
+ }
319
+
320
+ public function add_archive_checkbox( $posts, $args, $post_type )
321
+ {
322
+ global $_nav_menu_placeholder, $wp_rewrite;
323
+ $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
324
+
325
+ array_unshift( $posts, (object) array(
326
+ 'ID' => 0,
327
+ 'object_id' => $_nav_menu_placeholder,
328
+ 'post_title' => $post_type['args']->labels->all_items,
329
+ 'post_type' => 'nav_menu_item',
330
+ 'type' => 'post_type_archive',
331
+ 'object' => $post_type['args']->slug,
332
+ ) );
333
+
334
+ return $posts;
335
+ }
336
+
337
+ /**
338
+ * Make post type archive link 'current'
339
+ * @uses Post_Type_Archive_Links :: get_item_ancestors()
340
+ * @param array $items
341
+ * @return array $items
342
+ */
343
+ public function maybe_make_current( $items ) {
344
+ foreach ( $items as $item ) {
345
+ if ( 'post_type_archive' !== $item->type ) {
346
+ continue;
347
+ }
348
+ $post_type = $item->object;
349
+ if (
350
+ ! is_post_type_archive( $post_type )
351
+ AND ! is_singular( $post_type )
352
+ )
353
+ continue;
354
+
355
+ // Make item current
356
+ $item->current = true;
357
+ $item->classes[] = 'current-menu-item';
358
+
359
+ // Loop through ancestors and give them 'parent' or 'ancestor' class
360
+ $active_anc_item_ids = $this->get_item_ancestors( $item );
361
+ foreach ( $items as $key => $parent_item ) {
362
+ $classes = (array) $parent_item->classes;
363
+
364
+ // If menu item is the parent
365
+ if ( $parent_item->db_id == $item->menu_item_parent ) {
366
+ $classes[] = 'current-menu-parent';
367
+ $items[ $key ]->current_item_parent = true;
368
+ }
369
+
370
+ // If menu item is an ancestor
371
+ if ( in_array( intval( $parent_item->db_id ), $active_anc_item_ids ) ) {
372
+ $classes[] = 'current-menu-ancestor';
373
+ $items[ $key ]->current_item_ancestor = true;
374
+ }
375
+
376
+ $items[ $key ]->classes = array_unique( $classes );
377
+ }
378
+ }
379
+
380
+ return $items;
381
+ }
382
+
383
+ /**
384
+ * Get menu item's ancestors
385
+ * @param object $item
386
+ * @return array $active_anc_item_ids
387
+ */
388
+ public function get_item_ancestors( $item ) {
389
+ $anc_id = absint( $item->db_id );
390
+
391
+ $active_anc_item_ids = array();
392
+ while (
393
+ $anc_id = get_post_meta( $anc_id, '_menu_item_menu_item_parent', true )
394
+ AND ! in_array( $anc_id, $active_anc_item_ids )
395
+ )
396
+ $active_anc_item_ids[] = $anc_id;
397
+
398
+ return $active_anc_item_ids;
399
+ }
400
+
401
  function set($post_type, $settings = null)
402
  {
403
  $data = get_post_type_object( $post_type );
embedded/classes/editor.php CHANGED
@@ -284,8 +284,7 @@ class WPCF_Editor
284
  /*
285
  * Callback
286
  */
287
- $shortcode = call_user_func( $function, $_POST, $this->field,
288
- $this->_meta_type );
289
  } else {
290
  /*
291
  * Generic
@@ -305,8 +304,7 @@ class WPCF_Editor
305
  */
306
  $shortcode = preg_replace( '@</?script[^>]*>@im', '', wp_kses_post($shortcode) );
307
  // Add additional parameters if required
308
- $shortcode = $this->_add_parameters_to_shortcode( $shortcode,
309
- $_POST );
310
  // Insert shortcode
311
  echo '<script type="text/javascript">jQuery(function(){tedFrame.close(\''
312
  . $shortcode . '\', \'' . esc_js( $shortcode ) . '\');});</script>';
284
  /*
285
  * Callback
286
  */
287
+ $shortcode = call_user_func( $function, $_POST, $this->field, $this->_meta_type );
 
288
  } else {
289
  /*
290
  * Generic
304
  */
305
  $shortcode = preg_replace( '@</?script[^>]*>@im', '', wp_kses_post($shortcode) );
306
  // Add additional parameters if required
307
+ $shortcode = $this->_add_parameters_to_shortcode( $shortcode, $_POST );
 
308
  // Insert shortcode
309
  echo '<script type="text/javascript">jQuery(function(){tedFrame.close(\''
310
  . $shortcode . '\', \'' . esc_js( $shortcode ) . '\');});</script>';
embedded/classes/field.php CHANGED
@@ -2,37 +2,33 @@
2
  /*
3
  * Field class.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/classes/field.php $
6
- * $LastChangedDate: 2015-06-15 08:18:54 +0000 (Mon, 15 Jun 2015) $
7
- * $LastChangedRevision: 1180956 $
8
- * $LastChangedBy: iworks $
9
  *
10
  */
11
 
12
  /**
13
  * Base class.
14
- *
15
  * Fields are our core items and we'll use this class to sort them out a little.
16
  * Very useful, should be used to finish small tasks for field.
17
- *
18
  * Example:
19
- *
20
  * // Setup field
21
  * global $wpcf;
22
  * $my_field = new WPCF_Field();
23
  * $my_field->set($wpcf->post, wpcf_admin_fields_get_field('image'));
24
- *
25
  * // Use it
26
  * $my_field->save();
27
- *
28
  * // Generic instance can be found in global $wpcf.
29
  * global $wpcf;
30
  * $wpcf->field->set(...);
31
- *
32
  * !! BE CAREFUL !! not to disturb global instance if you suspect processing
33
  * current item is not finished. Core code sometimes use same instance over
34
  * few functions and places.
35
- *
36
  * @since Types 1.2
37
  * @package Types
38
  * @subpackage Classes
@@ -45,18 +41,18 @@ class WPCF_Field
45
 
46
  /**
47
  * Field structure
48
- *
49
  * This is actually a form array collected from files per specific field:
50
  * /embedded/includes/fields/$field_type.php
51
  * /includes/fields/$field_type.php
52
- *
53
  * @var type array
54
  */
55
  var $cf = array();
56
 
57
  /**
58
  * All Types created fields
59
- * @var type
60
  */
61
  var $fields = null;
62
 
@@ -68,9 +64,9 @@ class WPCF_Field
68
 
69
  /**
70
  * Field config.
71
- *
72
  * Use it to set default configuration.
73
- *
74
  * @var type array
75
  */
76
  var $config = array(
@@ -102,8 +98,8 @@ class WPCF_Field
102
 
103
  /**
104
  * Cache.DEPRECATED
105
- *
106
- * @var type
107
  */
108
  var $cache = array();
109
 
@@ -115,25 +111,25 @@ class WPCF_Field
115
 
116
  /**
117
  * Context in which class is called
118
- * @var type
119
  */
120
  var $context = 'group';
121
 
122
  /**
123
  * Invalid fields
124
- *
125
  * @todo Revise
126
- * @var type
127
  */
128
  var $invalid_fields = array();
129
 
130
  /**
131
- * ID
132
  */
133
  var $ID = '';
134
 
135
  /**
136
- * Unique ID
137
  */
138
  var $unique_id = '';
139
 
@@ -144,16 +140,16 @@ class WPCF_Field
144
 
145
  /**
146
  * Set current post and field.
147
- *
148
  * @param type $post
149
- * @param type $cf
150
  */
151
  function set( $post, $cf ) {
152
 
153
  global $wpcf;
154
 
155
  /*
156
- *
157
  * Check if $cf is string
158
  */
159
  if ( is_string( $cf ) ) {
@@ -218,8 +214,8 @@ class WPCF_Field
218
 
219
  /**
220
  * Set needed but not required form elements.
221
- *
222
- * @param string $cf
223
  */
224
  function _parse_cf_form_element( $cf ) {
225
  $p = array('#before' => '', '#after' => '', '#description' => '');
@@ -233,8 +229,9 @@ class WPCF_Field
233
 
234
  /**
235
  * Fetch and sort fields.
236
- *
237
- * @global type $wpdb
 
238
  */
239
  function _get_meta() {
240
  global $wpdb;
@@ -301,18 +298,16 @@ class WPCF_Field
301
  * Apply filters
302
  */
303
  $meta = apply_filters( 'wpcf_fields_value_get', $meta, $this );
304
- $meta = apply_filters( 'wpcf_fields_slug_' . $this->cf['slug']
305
- . '_value_get', $meta, $this );
306
- $meta = apply_filters( 'wpcf_fields_type_' . $this->cf['type']
307
- . '_value_get', $meta, $this );
308
 
309
  return $meta;
310
  }
311
 
312
  /**
313
  * Gets $_POST data.
314
- *
315
- * @return type
316
  */
317
  function get_submitted_data() {
318
  $posted = isset( $_POST['wpcf'][$this->cf['slug']] ) ? $_POST['wpcf'][$this->cf['slug']] : null;
@@ -322,12 +317,12 @@ class WPCF_Field
322
 
323
  /**
324
  * Save field.
325
- *
326
  * If $value is empty, $_POST will be checked.
327
  * 1.3.2 Reverted saving empty fields
328
  * removed - if ( !empty( $value ) || is_numeric( $value ) ) {
329
- *
330
- * @param type $value
331
  */
332
  function save( $value = null )
333
  {
@@ -396,18 +391,16 @@ class WPCF_Field
396
 
397
  /**
398
  * Apply filters to saved value.
399
- *
400
  * @param type $value
401
- * @return type
402
  */
403
- function _filter_save_value( $value ) {
 
404
  // Apply filters
405
- $value = apply_filters( 'wpcf_fields_value_save', $value,
406
- $this->cf['type'], $this->cf['slug'], $this->cf, $this );
407
- $value = apply_filters( 'wpcf_fields_slug_' . $this->cf['slug']
408
- . '_value_save', $value, $this->cf, $this );
409
- $value = apply_filters( 'wpcf_fields_type_' . $this->cf['type']
410
- . '_value_save', $value, $this->cf, $this );
411
 
412
  return $value;
413
  }
@@ -415,18 +408,16 @@ class WPCF_Field
415
  /**
416
  * Use these hooks to add future functionality.
417
  * Do not add any more code to core.
418
- *
419
  * @param type $field
420
  * @param type $value
421
  * @param type $meta_id
422
  */
423
- function _action_save( $field, $value, $meta_id, $meta_value_original ) {
424
- do_action( 'wpcf_fields_save', $value, $field, $this, $meta_id,
425
- $meta_value_original );
426
- do_action( 'wpcf_fields_slug_' . $field['slug'] . '_save', $value,
427
- $field, $this, $meta_id, $meta_value_original );
428
- do_action( 'wpcf_fields_type_' . $field['type'] . '_save', $value,
429
- $field, $this, $meta_id, $meta_value_original );
430
  }
431
 
432
  /**
@@ -448,8 +439,8 @@ class WPCF_Field
448
 
449
  /**
450
  * Sets field config.
451
- *
452
- * @return type
453
  */
454
  function _get_config() {
455
  $this->_include_file_by_field_type($this->cf['type']);
@@ -462,7 +453,7 @@ class WPCF_Field
462
 
463
  /**
464
  * Discouraged usage.
465
- *
466
  * @return type
467
  */
468
  function _deprecated_inherited_allowed() {
@@ -477,8 +468,8 @@ class WPCF_Field
477
 
478
  /**
479
  * Sets field meta box form.
480
- *
481
- * @return type
482
  */
483
  function _get_meta_form( $meta_value = null, $meta_id = null, $wrap = true ) {
484
 
@@ -490,7 +481,7 @@ class WPCF_Field
490
 
491
  /*
492
  * Set value
493
- *
494
  * IMPORTANT
495
  * Here we set values for form elements
496
  */
@@ -512,10 +503,10 @@ class WPCF_Field
512
  }
513
 
514
  /*
515
- *
516
- *
517
- *
518
- *
519
  * Since Types 1.2
520
  * Avoid using parent (inherited) type
521
  * $this->config->inherited_field_type
@@ -555,7 +546,7 @@ class WPCF_Field
555
  $func = 'wpcf_fields_' . $this->cf['type'] . '_meta_box_form';
556
  if ( is_callable( $func ) ) {
557
  /*
558
- *
559
  * From Types 1.2 use complete form setup
560
  */
561
  $form_meta_box = call_user_func_array( 'wpcf_fields_'
@@ -582,7 +573,7 @@ class WPCF_Field
582
  foreach ( $form as $element_key => $element ) {
583
 
584
  /*
585
- *
586
  * Start using __ in keys to skip element
587
  */
588
  // Skip protected
@@ -620,8 +611,7 @@ class WPCF_Field
620
  }
621
 
622
  // Set form element
623
- $form[$element_key] = apply_filters( 'wpcf_post_edit_field',
624
- $element, $this->cf, $this->post, $this->context );
625
  }
626
 
627
  // Add to editor
@@ -703,10 +693,17 @@ class WPCF_Field
703
 
704
  /**
705
  * Use this function to add final filters to HTML output.
706
- *
707
- * @param type $output
708
  */
709
- function html( $html, $params ) {
 
 
 
 
 
 
 
710
  /**
711
  *
712
  * Exception when RAW = TRUE.
@@ -719,20 +716,18 @@ class WPCF_Field
719
  $html = htmlspecialchars( $html );
720
  }
721
  // Process shortcodes too
722
- // $shortcode = do_shortcode( $html );
723
  $html = do_shortcode( htmlspecialchars_decode( stripslashes( $html ) ) );
724
-
725
  return $html;
726
  }
727
 
728
  /**
729
  * Determines if field is created with Types.
730
- *
731
  * @param type $field_key
732
  */
733
  function is_under_control( $field_key ) {
734
  /*
735
- *
736
  * We force checking our meta prefix
737
  */
738
  $key = $this->__get_slug_no_prefix( $field_key );
@@ -741,7 +736,7 @@ class WPCF_Field
741
 
742
  /**
743
  * Return slug.
744
- *
745
  * @param type $meta_key
746
  * @return type
747
  */
@@ -752,14 +747,14 @@ class WPCF_Field
752
 
753
  /**
754
  * Returns altered element form name.
755
- *
756
  * Use $prefix to set name like:
757
  * wpcf_post_relationship[214][wpcf-my-checkbox]
758
- *
759
  * Or if multi array
760
  * wpcf_post_relationship[214][wpcf-my-date][datepicker]
761
  * wpcf_post_relationship[214][wpcf-my-date][hour]
762
- *
763
  * @param type $prefix
764
  * @param type $name
765
  * @return type
@@ -776,7 +771,7 @@ class WPCF_Field
776
  . $this->post->ID
777
  . '][' . $this->slug . ']';
778
  /*
779
- *
780
  * Multi array case
781
  */
782
  } else {
2
  /*
3
  * Field class.
4
  *
 
 
 
 
5
  *
6
  */
7
 
8
  /**
9
  * Base class.
10
+ *
11
  * Fields are our core items and we'll use this class to sort them out a little.
12
  * Very useful, should be used to finish small tasks for field.
13
+ *
14
  * Example:
15
+ *
16
  * // Setup field
17
  * global $wpcf;
18
  * $my_field = new WPCF_Field();
19
  * $my_field->set($wpcf->post, wpcf_admin_fields_get_field('image'));
20
+ *
21
  * // Use it
22
  * $my_field->save();
23
+ *
24
  * // Generic instance can be found in global $wpcf.
25
  * global $wpcf;
26
  * $wpcf->field->set(...);
27
+ *
28
  * !! BE CAREFUL !! not to disturb global instance if you suspect processing
29
  * current item is not finished. Core code sometimes use same instance over
30
  * few functions and places.
31
+ *
32
  * @since Types 1.2
33
  * @package Types
34
  * @subpackage Classes
41
 
42
  /**
43
  * Field structure
44
+ *
45
  * This is actually a form array collected from files per specific field:
46
  * /embedded/includes/fields/$field_type.php
47
  * /includes/fields/$field_type.php
48
+ *
49
  * @var type array
50
  */
51
  var $cf = array();
52
 
53
  /**
54
  * All Types created fields
55
+ * @var type
56
  */
57
  var $fields = null;
58
 
64
 
65
  /**
66
  * Field config.
67
+ *
68
  * Use it to set default configuration.
69
+ *
70
  * @var type array
71
  */
72
  var $config = array(
98
 
99
  /**
100
  * Cache.DEPRECATED
101
+ *
102
+ * @var type
103
  */
104
  var $cache = array();
105
 
111
 
112
  /**
113
  * Context in which class is called
114
+ * @var type
115
  */
116
  var $context = 'group';
117
 
118
  /**
119
  * Invalid fields
120
+ *
121
  * @todo Revise
122
+ * @var type
123
  */
124
  var $invalid_fields = array();
125
 
126
  /**
127
+ * ID
128
  */
129
  var $ID = '';
130
 
131
  /**
132
+ * Unique ID
133
  */
134
  var $unique_id = '';
135
 
140
 
141
  /**
142
  * Set current post and field.
143
+ *
144
  * @param type $post
145
+ * @param type $cf
146
  */
147
  function set( $post, $cf ) {
148
 
149
  global $wpcf;
150
 
151
  /*
152
+ *
153
  * Check if $cf is string
154
  */
155
  if ( is_string( $cf ) ) {
214
 
215
  /**
216
  * Set needed but not required form elements.
217
+ *
218
+ * @param string $cf
219
  */
220
  function _parse_cf_form_element( $cf ) {
221
  $p = array('#before' => '', '#after' => '', '#description' => '');
229
 
230
  /**
231
  * Fetch and sort fields.
232
+ *
233
+ * @global object $wpdb
234
+ *
235
  */
236
  function _get_meta() {
237
  global $wpdb;
298
  * Apply filters
299
  */
300
  $meta = apply_filters( 'wpcf_fields_value_get', $meta, $this );
301
+ $meta = apply_filters( 'wpcf_fields_slug_' . $this->cf['slug'] . '_value_get', $meta, $this );
302
+ $meta = apply_filters( 'wpcf_fields_type_' . $this->cf['type'] . '_value_get', $meta, $this );
 
 
303
 
304
  return $meta;
305
  }
306
 
307
  /**
308
  * Gets $_POST data.
309
+ *
310
+ * @return type
311
  */
312
  function get_submitted_data() {
313
  $posted = isset( $_POST['wpcf'][$this->cf['slug']] ) ? $_POST['wpcf'][$this->cf['slug']] : null;
317
 
318
  /**
319
  * Save field.
320
+ *
321
  * If $value is empty, $_POST will be checked.
322
  * 1.3.2 Reverted saving empty fields
323
  * removed - if ( !empty( $value ) || is_numeric( $value ) ) {
324
+ *
325
+ * @param type $value
326
  */
327
  function save( $value = null )
328
  {
391
 
392
  /**
393
  * Apply filters to saved value.
394
+ *
395
  * @param type $value
396
+ * @return type
397
  */
398
+ function _filter_save_value( $value )
399
+ {
400
  // Apply filters
401
+ $value = apply_filters( 'wpcf_fields_value_save', $value, $this->cf['type'], $this->cf['slug'], $this->cf, $this );
402
+ $value = apply_filters( 'wpcf_fields_slug_' . $this->cf['slug'] . '_value_save', $value, $this->cf, $this );
403
+ $value = apply_filters( 'wpcf_fields_type_' . $this->cf['type'] . '_value_save', $value, $this->cf, $this );
 
 
 
404
 
405
  return $value;
406
  }
408
  /**
409
  * Use these hooks to add future functionality.
410
  * Do not add any more code to core.
411
+ *
412
  * @param type $field
413
  * @param type $value
414
  * @param type $meta_id
415
  */
416
+ function _action_save( $field, $value, $meta_id, $meta_value_original )
417
+ {
418
+ do_action( 'wpcf_fields_save', $value, $field, $this, $meta_id, $meta_value_original );
419
+ do_action( 'wpcf_fields_slug_' . $field['slug'] . '_save', $value, $field, $this, $meta_id, $meta_value_original );
420
+ do_action( 'wpcf_fields_type_' . $field['type'] . '_save', $value, $field, $this, $meta_id, $meta_value_original );
 
 
421
  }
422
 
423
  /**
439
 
440
  /**
441
  * Sets field config.
442
+ *
443
+ * @return type
444
  */
445
  function _get_config() {
446
  $this->_include_file_by_field_type($this->cf['type']);
453
 
454
  /**
455
  * Discouraged usage.
456
+ *
457
  * @return type
458
  */
459
  function _deprecated_inherited_allowed() {
468
 
469
  /**
470
  * Sets field meta box form.
471
+ *
472
+ * @return type
473
  */
474
  function _get_meta_form( $meta_value = null, $meta_id = null, $wrap = true ) {
475
 
481
 
482
  /*
483
  * Set value
484
+ *
485
  * IMPORTANT
486
  * Here we set values for form elements
487
  */
503
  }
504
 
505
  /*
506
+ *
507
+ *
508
+ *
509
+ *
510
  * Since Types 1.2
511
  * Avoid using parent (inherited) type
512
  * $this->config->inherited_field_type
546
  $func = 'wpcf_fields_' . $this->cf['type'] . '_meta_box_form';
547
  if ( is_callable( $func ) ) {
548
  /*
549
+ *
550
  * From Types 1.2 use complete form setup
551
  */
552
  $form_meta_box = call_user_func_array( 'wpcf_fields_'
573
  foreach ( $form as $element_key => $element ) {
574
 
575
  /*
576
+ *
577
  * Start using __ in keys to skip element
578
  */
579
  // Skip protected
611
  }
612
 
613
  // Set form element
614
+ $form[$element_key] = apply_filters( 'wpcf_post_edit_field', $element, $this->cf, $this->post, $this->context );
 
615
  }
616
 
617
  // Add to editor
693
 
694
  /**
695
  * Use this function to add final filters to HTML output.
696
+ *
697
+ * @param type $output
698
  */
699
+ function html( $html, $params )
700
+ {
701
+ /**
702
+ * check input
703
+ */
704
+ if ( is_array($html) || is_object($html) ) {
705
+ return '';
706
+ }
707
  /**
708
  *
709
  * Exception when RAW = TRUE.
716
  $html = htmlspecialchars( $html );
717
  }
718
  // Process shortcodes too
 
719
  $html = do_shortcode( htmlspecialchars_decode( stripslashes( $html ) ) );
 
720
  return $html;
721
  }
722
 
723
  /**
724
  * Determines if field is created with Types.
725
+ *
726
  * @param type $field_key
727
  */
728
  function is_under_control( $field_key ) {
729
  /*
730
+ *
731
  * We force checking our meta prefix
732
  */
733
  $key = $this->__get_slug_no_prefix( $field_key );
736
 
737
  /**
738
  * Return slug.
739
+ *
740
  * @param type $meta_key
741
  * @return type
742
  */
747
 
748
  /**
749
  * Returns altered element form name.
750
+ *
751
  * Use $prefix to set name like:
752
  * wpcf_post_relationship[214][wpcf-my-checkbox]
753
+ *
754
  * Or if multi array
755
  * wpcf_post_relationship[214][wpcf-my-date][datepicker]
756
  * wpcf_post_relationship[214][wpcf-my-date][hour]
757
+ *
758
  * @param type $prefix
759
  * @param type $name
760
  * @return type
771
  . $this->post->ID
772
  . '][' . $this->slug . ']';
773
  /*
774
+ *
775
  * Multi array case
776
  */
777
  } else {
embedded/classes/fields.php CHANGED
@@ -2,10 +2,6 @@
2
  /**
3
  * Fields class.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/classes/fields.php $
6
- * $LastChangedDate: 2014-05-07 06:56:23 +0000 (Wed, 07 May 2014) $
7
- * $LastChangedRevision: 909470 $
8
- * $LastChangedBy: iworks $
9
  *
10
  */
11
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
2
  /**
3
  * Fields class.
4
  *
 
 
 
 
5
  *
6
  */
7
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
embedded/classes/forms.php CHANGED
@@ -4,10 +4,6 @@
4
  *
5
  * Returns HTML formatted output for elements and handles form submission.
6
  *
7
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/classes/forms.php $
8
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
9
- * $LastChangedRevision: 970205 $
10
- * $LastChangedBy: brucepearson $
11
  *
12
  *
13
  * @version 1.0
@@ -125,8 +121,10 @@ class Enlimbo_Forms_Wpcf
125
  if ( empty( $id ) ) {
126
  $id = $this->_id;
127
  }
128
- return (isset( $_REQUEST['_wpnonce_wpcf'] )
129
- && wp_verify_nonce( $_REQUEST['_wpnonce_wpcf'], $id ));
 
 
130
  }
131
 
132
  /**
@@ -920,9 +918,15 @@ class Enlimbo_Forms_Wpcf
920
  array('textfield', 'textarea') ) ? '' : 0;
921
  }
922
 
 
 
 
 
 
 
 
923
  $parts = explode( '[', $name );
924
- $parts = array_map( create_function( '&$a', 'return trim($a, \']\');' ),
925
- $parts );
926
  if ( !isset( $_REQUEST[$parts[0]] ) ) {
927
  return in_array( $element['#type'], array('textfield', 'textarea') ) ? '' : 0;
928
  }
4
  *
5
  * Returns HTML formatted output for elements and handles form submission.
6
  *
 
 
 
 
7
  *
8
  *
9
  * @version 1.0
121
  if ( empty( $id ) ) {
122
  $id = $this->_id;
123
  }
124
+ return (
125
+ isset( $_REQUEST['_wpnonce_wpcf'] )
126
+ && wp_verify_nonce( $_REQUEST['_wpnonce_wpcf'], $id )
127
+ );
128
  }
129
 
130
  /**
918
  array('textfield', 'textarea') ) ? '' : 0;
919
  }
920
 
921
+ if ( !function_exists('getSubmittedDataTrim')) {
922
+ function getSubmittedDataTrim($a)
923
+ {
924
+ return trim($a, ']');
925
+ }
926
+ }
927
+
928
  $parts = explode( '[', $name );
929
+ $parts = array_map( 'getSubmittedDataTrim', $parts );
 
930
  if ( !isset( $_REQUEST[$parts[0]] ) ) {
931
  return in_array( $element['#type'], array('textfield', 'textarea') ) ? '' : 0;
932
  }
embedded/classes/loader.php CHANGED
@@ -3,16 +3,12 @@
3
  *
4
  * Loader class
5
  *
6
- * $HeadURL: https://www.onthegosystems.com/misc_svn/cck/tags/1.6.2/embedded/classes/loader.php $
7
- * $LastChangedDate: 2014-06-26 19:13:20 +0200 (Thu, 26 Jun 2014) $
8
- * $LastChangedRevision: 24403 $
9
- * $LastChangedBy: juan $
10
  *
11
  */
12
 
13
  /**
14
  * Loader Class
15
- *
16
  * @since Types 1.2
17
  * @package Types
18
  * @subpackage Classes
@@ -25,7 +21,7 @@ class WPCF_Loader
25
 
26
  /**
27
  * Settings
28
- * @var array
29
  */
30
  private static $__settings = array();
31
 
@@ -38,11 +34,14 @@ class WPCF_Loader
38
  array('WPCF_Loader', 'renderJsSettings'), 5 );
39
  add_filter( 'the_posts', array('WPCF_Loader', 'wpcf_cache_complete_postmeta') );
40
  }
41
-
42
  /**
43
- * Cache the postmeta for posts returned by a WP_Query
44
- */
45
-
 
 
 
46
  public static function wpcf_cache_complete_postmeta( $posts ) {
47
  global $wpdb;
48
  if ( !$posts )
@@ -54,7 +53,7 @@ class WPCF_Loader
54
  $cache_key_looped_post = md5( 'post::_is_cached' . $post->ID );
55
  $cached_object = wp_cache_get( $cache_key_looped_post, $cache_group_ids );
56
  if ( false === $cached_object ) {
57
- $post_ids[] = $post->ID;
58
  wp_cache_add( $cache_key_looped_post, $post->ID, $cache_group_ids );
59
  }
60
  }
@@ -150,7 +149,7 @@ class WPCF_Loader
150
 
151
  /**
152
  * Returns HTML formatted output.
153
- *
154
  * @param string $view
155
  * @param mixed $data
156
  * @return string
@@ -171,7 +170,7 @@ class WPCF_Loader
171
 
172
  /**
173
  * Returns HTML formatted output.
174
- *
175
  * @param string $view
176
  * @param mixed $data
177
  * @return string
@@ -187,7 +186,7 @@ class WPCF_Loader
187
 
188
  /**
189
  * Returns HTML formatted output.
190
- *
191
  * @param string $template
192
  * @param mixed $data
193
  * @return string
@@ -208,7 +207,7 @@ class WPCF_Loader
208
 
209
  /**
210
  * Loads model.
211
- *
212
  * @param string $template
213
  * @param mixed $data
214
  * @return string
@@ -224,7 +223,7 @@ class WPCF_Loader
224
 
225
  /**
226
  * Loads class.
227
- *
228
  * @param string $template
229
  * @param mixed $data
230
  * @return string
@@ -240,7 +239,7 @@ class WPCF_Loader
240
 
241
  /**
242
  * Loads include.
243
- *
244
  * @param string $template
245
  * @param mixed $data
246
  * @return string
@@ -256,7 +255,7 @@ class WPCF_Loader
256
 
257
  /**
258
  * Adds JS settings.
259
- *
260
  * @staticvar array $settings
261
  * @param type $id
262
  * @param type $setting
3
  *
4
  * Loader class
5
  *
 
 
 
 
6
  *
7
  */
8
 
9
  /**
10
  * Loader Class
11
+ *
12
  * @since Types 1.2
13
  * @package Types
14
  * @subpackage Classes
21
 
22
  /**
23
  * Settings
24
+ * @var array
25
  */
26
  private static $__settings = array();
27
 
34
  array('WPCF_Loader', 'renderJsSettings'), 5 );
35
  add_filter( 'the_posts', array('WPCF_Loader', 'wpcf_cache_complete_postmeta') );
36
  }
37
+
38
  /**
39
+ * Cache the postmeta for posts returned by a WP_Query
40
+ *
41
+ * @global object $wpdb
42
+ *
43
+ */
44
+
45
  public static function wpcf_cache_complete_postmeta( $posts ) {
46
  global $wpdb;
47
  if ( !$posts )
53
  $cache_key_looped_post = md5( 'post::_is_cached' . $post->ID );
54
  $cached_object = wp_cache_get( $cache_key_looped_post, $cache_group_ids );
55
  if ( false === $cached_object ) {
56
+ $post_ids[] = intval( $post->ID );
57
  wp_cache_add( $cache_key_looped_post, $post->ID, $cache_group_ids );
58
  }
59
  }
149
 
150
  /**
151
  * Returns HTML formatted output.
152
+ *
153
  * @param string $view
154
  * @param mixed $data
155
  * @return string
170
 
171
  /**
172
  * Returns HTML formatted output.
173
+ *
174
  * @param string $view
175
  * @param mixed $data
176
  * @return string
186
 
187
  /**
188
  * Returns HTML formatted output.
189
+ *
190
  * @param string $template
191
  * @param mixed $data
192
  * @return string
207
 
208
  /**
209
  * Loads model.
210
+ *
211
  * @param string $template
212
  * @param mixed $data
213
  * @return string
223
 
224
  /**
225
  * Loads class.
226
+ *
227
  * @param string $template
228
  * @param mixed $data
229
  * @return string
239
 
240
  /**
241
  * Loads include.
242
+ *
243
  * @param string $template
244
  * @param mixed $data
245
  * @return string
255
 
256
  /**
257
  * Adds JS settings.
258
+ *
259
  * @staticvar array $settings
260
  * @param type $id
261
  * @param type $setting
embedded/classes/path.php CHANGED
@@ -2,10 +2,6 @@
2
  /**
3
  * WPCF_Path
4
  *
5
- * $HeadURL: https://www.onthegosystems.com/misc_svn/cck/tags/1.6.2/embedded/classes/path.php $
6
- * $LastChangedDate: 2014-05-12 16:47:19 +0200 (Mon, 12 May 2014) $
7
- * $LastChangedRevision: 22250 $
8
- * $LastChangedBy: marcin $
9
  *
10
  */
11
  final class WPCF_Path
2
  /**
3
  * WPCF_Path
4
  *
 
 
 
 
5
  *
6
  */
7
  final class WPCF_Path
embedded/classes/post-types/messages.php CHANGED
@@ -2,10 +2,6 @@
2
  /*
3
  * Messages.
4
  *
5
- * $HeadURL: https://www.onthegosystems.com/misc_svn/cck/tags/1.6.2/embedded/classes/post-types/messages.php $
6
- * $LastChangedDate: 2014-05-13 12:49:25 +0200 (Tue, 13 May 2014) $
7
- * $LastChangedRevision: 22267 $
8
- * $LastChangedBy: marcin $
9
  *
10
  */
11
 
2
  /*
3
  * Messages.
4
  *
 
 
 
 
5
  *
6
  */
7
 
embedded/classes/relationship.php CHANGED
@@ -2,10 +2,6 @@
2
  /*
3
  * Post relationship class.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/classes/relationship.php $
6
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
7
- * $LastChangedRevision: 970205 $
8
- * $LastChangedBy: brucepearson $
9
  *
10
  */
11
 
@@ -201,8 +197,8 @@ class WPCF_Relationship
201
  /**
202
  * Bulk saving children.
203
  *
204
- * @param type $parent_id
205
- * @param type $children
206
  */
207
  function save_children($parent_id, $children)
208
  {
@@ -214,13 +210,13 @@ class WPCF_Relationship
214
  /**
215
  * Unified save child function.
216
  *
217
- * @param type $child_id
218
- * @param type $parent_id
 
 
219
  */
220
  function save_child( $parent_id, $child_id, $save_fields = array() )
221
  {
222
- global $wpdb;
223
-
224
  $parent = get_post( intval( $parent_id ) );
225
  $child = get_post( intval( $child_id ) );
226
  $post_data = array();
@@ -254,8 +250,10 @@ class WPCF_Relationship
254
  $post_title = $save_fields['_wp_title'];
255
  }
256
 
 
257
  $post_data['post_title'] = $post_title;
258
  $post_data['post_content'] = isset( $save_fields['_wp_body'] ) ? $save_fields['_wp_body'] : $child->post_content;
 
259
  $post_data['post_type'] = $child->post_type;
260
 
261
  // Check post status - if new, convert to 'publish' else keep remaining
@@ -275,7 +273,37 @@ class WPCF_Relationship
275
  * UPDATE POST
276
  */
277
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
  $updated_id = wp_update_post( $post_data );
 
 
 
 
 
279
  if ( empty( $updated_id ) ) {
280
  return new WP_Error( 'relationship-update-post-failed', 'Updating post failed' );
281
  }
@@ -366,37 +394,47 @@ class WPCF_Relationship
366
  /**
367
  * Saves new child.
368
  *
369
- * @param type $parent_id
370
- * @param type $post_type
371
- * @return type
372
  */
373
  function add_new_child($parent_id, $post_type)
374
  {
375
  global $wpdb;
376
-
377
  $parent = get_post( $parent_id );
378
  if ( empty( $parent ) ) {
379
  return new WP_Error( 'wpcf-relationship-no-parent', 'No parent' );
380
  }
381
  $new_post = array(
382
- 'post_title' => ' ', // WP requires at least title with space
383
  'post_type' => $post_type,
384
  'post_status' => 'draft',
385
  );
386
  $id = wp_insert_post( $new_post, true );
387
- if ( !is_wp_error( $id ) ) {
388
- // Mark that it is new post
389
- update_post_meta( $id, '_wpcf_relationship_new', 1 );
390
- // Save relationship
391
- update_post_meta( $id,
392
- '_wpcf_belongs_' . $parent->post_type . '_id', $parent->ID );
393
- // Fix title
394
- $wpdb->update( $wpdb->posts,
395
- array('post_title' => $post_type . ' ' . $id),
396
- array('ID' => $id), array('%s'), array('%d') );
397
- do_action( 'wpcf_relationship_add_child', get_post( $id ), $parent );
398
- wp_cache_flush();
399
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
400
  return $id;
401
  }
402
 
@@ -493,4 +531,45 @@ class WPCF_Relationship
493
  die();
494
  }
495
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
496
  }
2
  /*
3
  * Post relationship class.
4
  *
 
 
 
 
5
  *
6
  */
7
 
197
  /**
198
  * Bulk saving children.
199
  *
200
+ * @param int $parent_id
201
+ * @param array $children Array $child_id => $fields. For details about $fields see save_child().
202
  */
203
  function save_children($parent_id, $children)
204
  {
210
  /**
211
  * Unified save child function.
212
  *
213
+ * @param int $parent_id
214
+ * @param int $child_id
215
+ * @param array $save_fields
216
+ * @return bool|WP_Error
217
  */
218
  function save_child( $parent_id, $child_id, $save_fields = array() )
219
  {
 
 
220
  $parent = get_post( intval( $parent_id ) );
221
  $child = get_post( intval( $child_id ) );
222
  $post_data = array();
250
  $post_title = $save_fields['_wp_title'];
251
  }
252
 
253
+
254
  $post_data['post_title'] = $post_title;
255
  $post_data['post_content'] = isset( $save_fields['_wp_body'] ) ? $save_fields['_wp_body'] : $child->post_content;
256
+ $post_data['post_excerpt'] = isset( $save_fields['_wp_excerpt'] ) ? $save_fields['_wp_excerpt'] : $child->post_excerpt;
257
  $post_data['post_type'] = $child->post_type;
258
 
259
  // Check post status - if new, convert to 'publish' else keep remaining
273
  * UPDATE POST
274
  */
275
 
276
+ $cf = new WPCF_Field;
277
+ if (
278
+ isset( $_POST['wpcf_post_relationship'][$parent_id])
279
+ && isset( $_POST['wpcf_post_relationship'][$parent_id][$child_id] )
280
+ ) {
281
+ $_POST['wpcf'] = array();
282
+ foreach( $_POST['wpcf_post_relationship'][$parent_id][$child_id] as $slug => $value ) {
283
+ $_POST['wpcf'][$cf->__get_slug_no_prefix( $slug )] = $value;
284
+ $_POST['wpcf'][$slug] = $value;
285
+ }
286
+ }
287
+ unset($cf);
288
+
289
+ /**
290
+ * avoid send data to children
291
+ */
292
+ if ( isset( $_POST['post_ID'] ) ) {
293
+ $temp_post_data = $_POST;
294
+ $_POST = array();
295
+ foreach( array('wpcf_post_relationship', 'post_ID', '_wptoolset_checkbox', 'wpcf', '_wpnonce') as $key ) {
296
+ if ( isset($temp_post_data[$key]) ) {
297
+ $_POST[$key] = $temp_post_data[$key];
298
+ }
299
+ }
300
+ }
301
  $updated_id = wp_update_post( $post_data );
302
+ if ( isset($temp_post_data) ) {
303
+ $_POST = $temp_post_data;
304
+ unset($temp_post_data);
305
+ }
306
+
307
  if ( empty( $updated_id ) ) {
308
  return new WP_Error( 'relationship-update-post-failed', 'Updating post failed' );
309
  }
394
  /**
395
  * Saves new child.
396
  *
397
+ * @param int $parent_id
398
+ * @param string $post_type
399
+ * @return int|WP_Error
400
  */
401
  function add_new_child($parent_id, $post_type)
402
  {
403
  global $wpdb;
 
404
  $parent = get_post( $parent_id );
405
  if ( empty( $parent ) ) {
406
  return new WP_Error( 'wpcf-relationship-no-parent', 'No parent' );
407
  }
408
  $new_post = array(
409
+ 'post_title' => __('New'). ': '.$post_type,
410
  'post_type' => $post_type,
411
  'post_status' => 'draft',
412
  );
413
  $id = wp_insert_post( $new_post, true );
414
+ /**
415
+ * return wp_error
416
+ */
417
+ if ( is_wp_error( $id ) ) {
418
+ return $id;
 
 
 
 
 
 
 
419
  }
420
+ /**
421
+ * Mark that it is new post
422
+ */
423
+ update_post_meta( $id, '_wpcf_relationship_new', 1 );
424
+ /**
425
+ * Save relationship
426
+ */
427
+ update_post_meta( $id, '_wpcf_belongs_' . $parent->post_type . '_id', $parent->ID );
428
+ /**
429
+ * Fix title
430
+ */
431
+ $wpdb->update(
432
+ $wpdb->posts,
433
+ array('post_title' => $post_type . ' ' . $id),
434
+ array('ID' => $id), array('%s'), array('%d')
435
+ );
436
+ do_action( 'wpcf_relationship_add_child', get_post( $id ), $parent );
437
+ wp_cache_flush();
438
  return $id;
439
  }
440
 
531
  die();
532
  }
533
 
534
+ /**
535
+ * Meta box form on post edit page.
536
+ *
537
+ * @param type $parent Parent post
538
+ * @param type $post_type Child post type
539
+ * @return type string HTML formatted list
540
+ */
541
+ function child_list($parent, $post_type)
542
+ {
543
+ if ( is_integer( $parent ) ) {
544
+ $parent = get_post( $parent );
545
+ }
546
+ $output = '';
547
+ require_once dirname( __FILE__ ) . '/relationship/form-child.php';
548
+ $this->child_form = new WPCF_Relationship_Child_Form(
549
+ $parent,
550
+ $post_type,
551
+ $this->settings( $parent->post_type, $post_type )
552
+ );
553
+ foreach($this->child_form->children as $child) {
554
+ $output .= sprintf(
555
+ '<li>%s</li>',
556
+ apply_filters('post_title', $child->post_title)
557
+ );
558
+ }
559
+ if ( $output ) {
560
+ $output = sprintf(
561
+ '<ul>%s</ul>',
562
+ $output
563
+ );
564
+ } else {
565
+ $output = sprintf(
566
+ '<p class="info">%s</p>',
567
+ $this->child_form->child_post_type_object->labels->not_found
568
+ );
569
+ }
570
+
571
+ return $output;
572
+ }
573
+
574
+
575
  }
embedded/classes/relationship/form-child.php CHANGED
@@ -1,14 +1,14 @@
1
  <?php
2
  /*
3
  * Relationship form class.
4
- *
5
  * Used to render child forms
6
  */
7
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
8
 
9
  /**
10
  * Relationship form class.
11
- *
12
  * Used on post edit page to show children rows
13
  */
14
  class WPCF_Relationship_Child_Form
@@ -16,29 +16,29 @@ class WPCF_Relationship_Child_Form
16
 
17
  /**
18
  * Current post.
19
- *
20
  * @var type object
21
  */
22
  var $post;
23
 
24
  /**
25
  * Field object.
26
- *
27
  * @var type array
28
  */
29
  var $cf = array();
30
 
31
  /**
32
  * Saved data.
33
- *
34
  * @var type array
35
  */
36
  var $data = array();
37
 
38
  /**
39
  * Child post object.
40
- *
41
- * @var type
42
  */
43
  var $child_post_type_object;
44
  var $parent;
@@ -48,10 +48,26 @@ class WPCF_Relationship_Child_Form
48
  var $children;
49
  var $headers = array();
50
  var $_dummy_post = false;
51
- private $__params = array('page', '_wpcf_relationship_items_per_page', 'sort',
52
- 'field');
53
  private $__urlParams = array();
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  /**
56
  * Construct function.
57
  */
@@ -67,33 +83,58 @@ class WPCF_Relationship_Child_Form
67
  }
68
  $this->cf = new WPCF_Field();
69
  $this->cf->context = 'relationship';
70
- $this->children = WPCF_Relationship_Model::getChildrenByPostType( $this->parent,
71
- $this->child_post_type, $this->data, $_GET );
 
 
 
 
 
72
  // If no children - use dummy post
73
  if ( empty( $this->children ) ) {
74
- $_dummy_post = get_default_post_to_edit( $this->child_post_type,
75
- false );
76
  $this->children = array($_dummy_post);
77
  $this->_dummy_post = true;
78
  }
79
  $this->child_post_type_object = get_post_type_object( $this->child_post_type );
80
-
81
  // Collect params from request
82
  foreach ( $this->__params as $__param ) {
83
  if ( isset( $_GET[$__param] ) ) {
84
  $this->__urlParams[$__param] = $_GET[$__param];
85
  }
86
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  }
88
-
89
  function getParamsQuery() {
90
- return count( $this->__urlParams ) ? '&amp;' . http_build_query( $this->__urlParams,
91
- '', '&amp;' ) : '';
92
  }
93
 
94
  /**
95
  * Sets form.
96
- *
97
  * @param type $o
98
  */
99
  function _set( $child ) {
@@ -102,11 +143,11 @@ class WPCF_Relationship_Child_Form
102
 
103
  /**
104
  * Returns HTML formatted form.
105
- *
106
  * Renders children per row.
107
- *
108
  * @todo move all here
109
- *
110
  * @return type string (HTML formatted)
111
  */
112
  function render() {
@@ -156,16 +197,16 @@ class WPCF_Relationship_Child_Form
156
  $this->child_post_type, $page, $prev, $next, $per_page,
157
  $total_items );
158
  /*
159
- *
160
- *
161
  * Add pagination bottom
162
  */
163
  $options = array(__( 'All', 'wpcf' ) => 'all', 5 => 5, 10 => 10, 15 => 15);
164
  // Add sorting
165
- $add_data = isset( $_GET['sort'] ) && isset( $_GET['field'] ) ? '&sort=' . strval( $_GET['sort'] ) . '&field='
166
- . strval( $_GET['field'] ) : '';
167
  if ( isset( $_GET['post_type_sort_parent'] ) ) {
168
- $add_data .= '&post_type_sort_parent=' . $_GET['post_type_sort_parent'];
169
  }
170
  $this->pagination_bottom = wpcf_form_simple( array(
171
  'pagination' => array(
@@ -189,7 +230,7 @@ class WPCF_Relationship_Child_Form
189
 
190
  /**
191
  * Returns rows.
192
- *
193
  * @return type
194
  */
195
  function rows() {
@@ -203,9 +244,9 @@ class WPCF_Relationship_Child_Form
203
 
204
  /**
205
  * Returns HTML formatted row
206
- *
207
  * While generating rows we collect headers too.
208
- *
209
  * @return type
210
  */
211
  function row() {
@@ -219,51 +260,70 @@ class WPCF_Relationship_Child_Form
219
  * LOOP over fields
220
  * Custom settings (specific)
221
  */
222
- if ( $this->data['fields_setting'] == 'specific'
223
- && !empty( $this->data['fields'] ) ) {
224
  // Set title
225
- if ( isset( $this->data['fields']['_wp_title'] ) ) {
 
 
 
 
226
  $this->headers[] = '_wp_title';
227
  $row[] = $this->title();
228
  }
229
  // Set body
230
- if ( isset( $this->data['fields']['_wp_body'] ) ) {
 
 
 
231
  $this->headers[] = '_wp_body';
232
  $row[] = $this->body();
233
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  // Loop over Types fields
235
  foreach ( $this->data['fields'] as $field_key => $true ) {
236
- // If field belongs only to disabled group - remove it.
237
- $groups = wpcf_admin_fields_get_groups_by_field( $this->cf->__get_slug_no_prefix( $field_key ) );
238
- if ( empty($groups ) ) {
239
- continue;
240
- }
241
- $_continue = false;
242
- // If at least one active - proceed
243
- foreach ( $groups as $group ) {
244
- if ( $group['is_active'] ) {
245
- $_continue = true;
246
- }
247
- }
248
- if ( !$_continue ) {
249
- continue;
250
- }
251
  // Skip parents
252
  if ( in_array( $field_key,
253
- array('_wp_title', '_wp_body', '_wpcf_pr_parents', '_wpcf_pr_taxonomies') ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  continue;
255
- } else {
256
- /*
257
- * Set field
258
- */
259
- // $field_key = $this->cf->__get_slug_no_prefix( $field_key );
260
- $this->cf->set( $this->child, $field_key );
261
- $row[] = $this->field_form();
262
- $this->_field_triggers();
263
- // Add to header
264
- // $this->headers[] = WPCF_META_PREFIX . $field_key;
265
- $this->headers[] = $field_key;
266
  }
 
 
 
 
 
 
 
 
 
267
  }
268
  // Add parent forms
269
  if ( !empty( $this->data['fields']['_wpcf_pr_parents'] ) ) {
@@ -287,10 +347,10 @@ class WPCF_Relationship_Child_Form
287
  }
288
  }
289
  /*
290
- *
291
- *
292
- *
293
- *
294
  * DEFAULT SETTINGS
295
  */
296
  } else {
@@ -302,13 +362,14 @@ class WPCF_Relationship_Child_Form
302
  if ( $this->data['fields_setting'] == 'all_cf_standard' ) {
303
  $this->headers[] = '_wp_body';
304
  $row[] = $this->body();
 
 
305
  }
306
  /*
307
  * Loop over groups and fields
308
  */
309
  // Get groups
310
- $groups = wpcf_admin_post_get_post_groups_fields( $this->child,
311
- 'post_relationships' );
312
  foreach ( $groups as $group ) {
313
  if ( empty( $group['fields'] ) ) {
314
  continue;
@@ -345,7 +406,6 @@ class WPCF_Relationship_Child_Form
345
  }
346
  }
347
  }
348
-
349
  return $row;
350
  }
351
 
@@ -370,29 +430,45 @@ class WPCF_Relationship_Child_Form
370
 
371
  /**
372
  * Returns HTML formatted title field.
373
- *
374
  * @param type $post
375
  * @return type
376
  */
377
- function title() {
378
- return wpcf_form_simple(
379
- array('field' => array(
380
- '#type' => 'textfield',
381
- '#id' => 'wpcf_post_relationship_'
382
- . $this->child->ID . '_wp_title',
383
- '#name' => 'wpcf_post_relationship['
384
- . $this->parent->ID . ']['
385
- . $this->child->ID . '][_wp_title]',
386
- '#value' => trim( $this->child->post_title ),
387
- '#inline' => true,
388
- )
389
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
390
  );
 
391
  }
392
 
393
  /**
394
  * Returns HTML formatted body field.
395
- *
396
  * @return type
397
  */
398
  function body() {
@@ -411,10 +487,32 @@ class WPCF_Relationship_Child_Form
411
  )
412
  );
413
  }
414
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
415
  /**
416
  * Returns HTML formatted taxonomy form.
417
- *
418
  * @param type $taxonomy
419
  * @return type
420
  */
@@ -441,7 +539,7 @@ class WPCF_Relationship_Child_Form
441
  );
442
 
443
  return empty( $output ) ? sprintf( __( 'No %s', 'wpcf' ),
444
- $taxonomy->label ) : $output;
445
  }
446
 
447
  $data = array(
@@ -471,9 +569,9 @@ class WPCF_Relationship_Child_Form
471
 
472
  /**
473
  * Returns element form as array.
474
- *
475
  * This is done per field.
476
- *
477
  * @param type $key Field key as stored
478
  * @return array
479
  */
@@ -500,13 +598,13 @@ class WPCF_Relationship_Child_Form
500
  return wptoolset_form_field( 'post', $config, $meta );
501
  }
502
  /*
503
- *
504
  * Get meta form for field
505
  */
506
  $form = $this->cf->_get_meta_form( $this->cf->__meta,
507
  $this->cf->meta_object->meta_id, false );
508
  /*
509
- *
510
  * Filter form
511
  */
512
  $_filtered_form = $this->__filter_meta_form( $form );
@@ -517,17 +615,17 @@ class WPCF_Relationship_Child_Form
517
 
518
  /**
519
  * Filters meta form.
520
- *
521
  * IMPORTANT: This is place where look of child form is altered.
522
  * Try not to spread it over other code.
523
- *
524
  * @param string $form
525
  * @return string
526
  */
527
  function __filter_meta_form( $form = array() ) {
528
  foreach ( $form as $k => &$e ) {
529
  /*
530
- *
531
  * Filter name
532
  */
533
  if ( isset( $e['#name'] ) ) {
@@ -568,7 +666,7 @@ class WPCF_Relationship_Child_Form
568
 
569
  /**
570
  * Content for choose parent column.
571
- *
572
  * @return boolean
573
  */
574
  function _parent_form( $post_parent = '' ) {
@@ -617,7 +715,7 @@ class WPCF_Relationship_Child_Form
617
 
618
  /**
619
  * HTML formatted row.
620
- *
621
  * @return type
622
  */
623
  function child_row( $child ) {
@@ -633,9 +731,9 @@ class WPCF_Relationship_Child_Form
633
 
634
  /**
635
  * Header HTML formatted output.
636
- *
637
  * Each header <th> is array element. Sortable.
638
- *
639
  * @return array 'header_id' => html
640
  */
641
  function headers() {
@@ -643,7 +741,7 @@ class WPCF_Relationship_Child_Form
643
  // Sorting
644
  $dir = isset( $_GET['sort'] ) && $_GET['sort'] == 'ASC' ? 'DESC' : 'ASC';
645
  $dir_default = 'ASC';
646
- $sort_field = isset( $_GET['field'] ) ? $_GET['field'] : '';
647
 
648
  // Set values
649
  $post = $this->parent;
@@ -660,13 +758,17 @@ class WPCF_Relationship_Child_Form
660
  }
661
 
662
  if ( $header == '_wp_title' ) {
663
- $title_dir = $sort_field == '_wp_title' ? $dir : 'ASC';
664
- $headers[$header] = '';
665
- $headers[$header] .= $sort_field == '_wp_title' ? '<div class="wpcf-pr-sort-' . $dir . '"></div>' : '';
666
- $headers[$header] .= '<a href="' . admin_url( 'admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=pr_sort&amp;field='
667
- . '_wp_title&amp;sort=' . $title_dir . '&amp;post_id=' . $post->ID . '&amp;post_type='
668
- . $post_type . '&amp;_wpnonce='
669
- . wp_create_nonce( 'pr_sort' ) ) . '">' . __( 'Post Title' ) . '</a>';
 
 
 
 
670
  } else if ( $header == '_wp_body' ) {
671
  $body_dir = $sort_field == '_wp_body' ? $dir : $dir_default;
672
  $headers[$header] = '';
@@ -675,6 +777,8 @@ class WPCF_Relationship_Child_Form
675
  . '_wp_body&amp;sort=' . $body_dir . '&amp;post_id=' . $post->ID . '&amp;post_type='
676
  . $post_type . '&amp;_wpnonce='
677
  . wp_create_nonce( 'pr_sort' ) ) . '">' . __( 'Post Body' ) . '</a>';
 
 
678
  } else if ( strpos( $header, WPCF_META_PREFIX ) === 0
679
  && isset( $wpcf_fields[str_replace( WPCF_META_PREFIX, '',
680
  $header )] ) ) {
@@ -726,4 +830,4 @@ class WPCF_Relationship_Child_Form
726
  return $headers;
727
  }
728
 
729
- }
1
  <?php
2
  /*
3
  * Relationship form class.
4
+ *
5
  * Used to render child forms
6
  */
7
  require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
8
 
9
  /**
10
  * Relationship form class.
11
+ *
12
  * Used on post edit page to show children rows
13
  */
14
  class WPCF_Relationship_Child_Form
16
 
17
  /**
18
  * Current post.
19
+ *
20
  * @var type object
21
  */
22
  var $post;
23
 
24
  /**
25
  * Field object.
26
+ *
27
  * @var type array
28
  */
29
  var $cf = array();
30
 
31
  /**
32
  * Saved data.
33
+ *
34
  * @var type array
35
  */
36
  var $data = array();
37
 
38
  /**
39
  * Child post object.
40
+ *
41
+ * @var type
42
  */
43
  var $child_post_type_object;
44
  var $parent;
48
  var $children;
49
  var $headers = array();
50
  var $_dummy_post = false;
51
+ private $__params = array('page', '_wpcf_relationship_items_per_page', 'sort', 'field');
 
52
  private $__urlParams = array();
53
 
54
+ /**
55
+ * post type configuration
56
+ */
57
+ private $child_supports = array(
58
+ 'title' => false,
59
+ 'editor' => false,
60
+ 'comments' => false,
61
+ 'trackbacks' => false,
62
+ 'revisions' => false,
63
+ 'author' => false,
64
+ 'excerpt' => false,
65
+ 'thumbnail' => false,
66
+ 'custom-fields' => false,
67
+ 'page-attributes' => false,
68
+ 'post-formats' => false,
69
+ );
70
+
71
  /**
72
  * Construct function.
73
  */
83
  }
84
  $this->cf = new WPCF_Field();
85
  $this->cf->context = 'relationship';
86
+ $this->children = WPCF_Relationship_Model::getChildrenByPostType(
87
+ $this->parent,
88
+ $this->child_post_type,
89
+ $this->data,
90
+ $_GET
91
+ );
92
+
93
  // If no children - use dummy post
94
  if ( empty( $this->children ) ) {
95
+ $_dummy_post = get_default_post_to_edit( $this->child_post_type, false );
 
96
  $this->children = array($_dummy_post);
97
  $this->_dummy_post = true;
98
  }
99
  $this->child_post_type_object = get_post_type_object( $this->child_post_type );
100
+
101
  // Collect params from request
102
  foreach ( $this->__params as $__param ) {
103
  if ( isset( $_GET[$__param] ) ) {
104
  $this->__urlParams[$__param] = $_GET[$__param];
105
  }
106
  }
107
+ /**
108
+ * build-in types
109
+ */
110
+ if ( in_array($child_post_type, array('page', 'post', 'attachment', 'revision', 'nav_menu_item') ) ) {
111
+ foreach( array_keys($this->child_supports) as $key ) {
112
+ $this->child_supports[$key] = post_type_supports($child_post_type, $key);
113
+ }
114
+ return;
115
+ }
116
+ /**
117
+ * custom post types
118
+ */
119
+ $post_types = get_option( WPCF_OPTION_NAME_CUSTOM_TYPES, array() );
120
+ if (
121
+ array_key_exists($child_post_type, $post_types )
122
+ && array_key_exists('supports', $post_types[$child_post_type] )
123
+ ) {
124
+ foreach( $post_types[$child_post_type]['supports'] as $key => $value ) {
125
+ $this->child_supports[$key] = (boolean)$value;
126
+ }
127
+ }
128
+ unset($post_types);
129
  }
130
+
131
  function getParamsQuery() {
132
+ return count( $this->__urlParams ) ? '&amp;' . http_build_query( $this->__urlParams, '', '&amp;' ) : '';
 
133
  }
134
 
135
  /**
136
  * Sets form.
137
+ *
138
  * @param type $o
139
  */
140
  function _set( $child ) {
143
 
144
  /**
145
  * Returns HTML formatted form.
146
+ *
147
  * Renders children per row.
148
+ *
149
  * @todo move all here
150
+ *
151
  * @return type string (HTML formatted)
152
  */
153
  function render() {
197
  $this->child_post_type, $page, $prev, $next, $per_page,
198
  $total_items );
199
  /*
200
+ *
201
+ *
202
  * Add pagination bottom
203
  */
204
  $options = array(__( 'All', 'wpcf' ) => 'all', 5 => 5, 10 => 10, 15 => 15);
205
  // Add sorting
206
+ $add_data = isset( $_GET['sort'] ) && isset( $_GET['field'] ) ? '&sort=' . sanitize_text_field( $_GET['sort'] ) . '&field='
207
+ . sanitize_text_field( $_GET['field'] ) : '';
208
  if ( isset( $_GET['post_type_sort_parent'] ) ) {
209
+ $add_data .= '&post_type_sort_parent=' . sanitize_text_field( $_GET['post_type_sort_parent'] );
210
  }
211
  $this->pagination_bottom = wpcf_form_simple( array(
212
  'pagination' => array(
230
 
231
  /**
232
  * Returns rows.
233
+ *
234
  * @return type
235
  */
236
  function rows() {
244
 
245
  /**
246
  * Returns HTML formatted row
247
+ *
248
  * While generating rows we collect headers too.
249
+ *
250
  * @return type
251
  */
252
  function row() {
260
  * LOOP over fields
261
  * Custom settings (specific)
262
  */
263
+ if ( $this->data['fields_setting'] == 'specific' && !empty( $this->data['fields'] ) ) {
 
264
  // Set title
265
+ if (
266
+ isset( $this->data['fields']['_wp_title'] )
267
+ && isset( $this->child_post_type_object->slug)
268
+ && post_type_supports( $this->child_post_type_object->slug, 'title')
269
+ ) {
270
  $this->headers[] = '_wp_title';
271
  $row[] = $this->title();
272
  }
273
  // Set body
274
+ if (
275
+ isset( $this->data['fields']['_wp_body'] )
276
+ && post_type_supports( $this->child_post_type_object->slug, 'editor')
277
+ ) {
278
  $this->headers[] = '_wp_body';
279
  $row[] = $this->body();
280
  }
281
+ // Set excerpt
282
+ if (
283
+ isset( $this->data['fields']['_wp_excerpt'] )
284
+ && post_type_supports( $this->child_post_type_object->slug, 'excerpt' )
285
+ ) {
286
+ $this->headers[] = '_wp_excerpt';
287
+ $row[] = $this->excerpt();
288
+ }
289
+
290
+ /**
291
+ * get allowed fields for this post type
292
+ */
293
+ $allowed_fields = array();
294
+ if ( isset( $this->child_post_type_object->slug) ) {
295
+ $allowed_fields = wpcf_admin_get_allowed_fields_by_post_type($this->child_post_type_object->slug);
296
+ }
297
+
298
  // Loop over Types fields
299
  foreach ( $this->data['fields'] as $field_key => $true ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300
  // Skip parents
301
  if ( in_array( $field_key,
302
+ array(
303
+ '_wp_title',
304
+ '_wp_body',
305
+ '_wp_excerpt',
306
+ '_wpcf_pr_parents',
307
+ '_wpcf_pr_taxonomies',
308
+ ) ) )
309
+ {
310
+ continue;
311
+ }
312
+ /**
313
+ * check field
314
+ */
315
+ if ( !in_array($field_key, $allowed_fields) ) {
316
  continue;
 
 
 
 
 
 
 
 
 
 
 
317
  }
318
+
319
+ /*
320
+ * Set field
321
+ */
322
+ $this->cf->set( $this->child, $field_key );
323
+ $row[] = $this->field_form();
324
+ $this->_field_triggers();
325
+ // Add to header
326
+ $this->headers[] = $field_key;
327
  }
328
  // Add parent forms
329
  if ( !empty( $this->data['fields']['_wpcf_pr_parents'] ) ) {
347
  }
348
  }
349
  /*
350
+ *
351
+ *
352
+ *
353
+ *
354
  * DEFAULT SETTINGS
355
  */
356
  } else {
362
  if ( $this->data['fields_setting'] == 'all_cf_standard' ) {
363
  $this->headers[] = '_wp_body';
364
  $row[] = $this->body();
365
+ $this->headers[] = '_wp_excerpt';
366
+ $row[] = $this->excerpt();
367
  }
368
  /*
369
  * Loop over groups and fields
370
  */
371
  // Get groups
372
+ $groups = wpcf_admin_post_get_post_groups_fields( $this->child, 'post_relationships' );
 
373
  foreach ( $groups as $group ) {
374
  if ( empty( $group['fields'] ) ) {
375
  continue;
406
  }
407
  }
408
  }
 
409
  return $row;
410
  }
411
 
430
 
431
  /**
432
  * Returns HTML formatted title field.
433
+ *
434
  * @param type $post
435
  * @return type
436
  */
437
+ function title()
438
+ {
439
+ $title = '';
440
+ $type = 'textfield';
441
+ if ( !$this->child_supports['title']) {
442
+ $type = 'hidden';
443
+ $title .= wpcf_form_simple(
444
+ array(
445
+ 'field' => array(
446
+ '#type' => 'markup',
447
+ '#markup' => sprintf('%s id: %d', $this->child_post_type_object->labels->singular_name, $this->child->ID),
448
+ ),
449
+ )
450
+ );
451
+ }
452
+ $title .= wpcf_form_simple(
453
+ array(
454
+ 'field' => array(
455
+ '#type' => $type,
456
+ '#id' => 'wpcf_post_relationship_'
457
+ . $this->child->ID . '_wp_title',
458
+ '#name' => 'wpcf_post_relationship['
459
+ . $this->parent->ID . ']['
460
+ . $this->child->ID . '][_wp_title]',
461
+ '#value' => trim( $this->child->post_title ),
462
+ '#inline' => true,
463
+ ),
464
+ )
465
  );
466
+ return $title;
467
  }
468
 
469
  /**
470
  * Returns HTML formatted body field.
471
+ *
472
  * @return type
473
  */
474
  function body() {
487
  )
488
  );
489
  }
490
+
491
+ /**
492
+ * Returns HTML formatted excerpt field.
493
+ *
494
+ * @return type
495
+ */
496
+ function excerpt() {
497
+ return wpcf_form_simple(
498
+ array('field' => array(
499
+ '#type' => 'textarea',
500
+ '#id' => 'wpcf_post_relationship_'
501
+ . $this->child->ID . '_wp_excerpt',
502
+ '#name' => 'wpcf_post_relationship['
503
+ . $this->parent->ID . ']['
504
+ . $this->child->ID . '][_wp_excerpt]',
505
+ '#value' => $this->child->post_excerpt,
506
+ '#attributes' => array('style' => 'width:300px;height:100px;'),
507
+ '#inline' => true,
508
+ )
509
+ )
510
+ );
511
+ }
512
+
513
  /**
514
  * Returns HTML formatted taxonomy form.
515
+ *
516
  * @param type $taxonomy
517
  * @return type
518
  */
539
  );
540
 
541
  return empty( $output ) ? sprintf( __( 'No %s', 'wpcf' ),
542
+ $taxonomy->label ) : $output;
543
  }
544
 
545
  $data = array(
569
 
570
  /**
571
  * Returns element form as array.
572
+ *
573
  * This is done per field.
574
+ *
575
  * @param type $key Field key as stored
576
  * @return array
577
  */
598
  return wptoolset_form_field( 'post', $config, $meta );
599
  }
600
  /*
601
+ *
602
  * Get meta form for field
603
  */
604
  $form = $this->cf->_get_meta_form( $this->cf->__meta,
605
  $this->cf->meta_object->meta_id, false );
606
  /*
607
+ *
608
  * Filter form
609
  */
610
  $_filtered_form = $this->__filter_meta_form( $form );
615
 
616
  /**
617
  * Filters meta form.
618
+ *
619
  * IMPORTANT: This is place where look of child form is altered.
620
  * Try not to spread it over other code.
621
+ *
622
  * @param string $form
623
  * @return string
624
  */
625
  function __filter_meta_form( $form = array() ) {
626
  foreach ( $form as $k => &$e ) {
627
  /*
628
+ *
629
  * Filter name
630
  */
631
  if ( isset( $e['#name'] ) ) {
666
 
667
  /**
668
  * Content for choose parent column.
669
+ *
670
  * @return boolean
671
  */
672
  function _parent_form( $post_parent = '' ) {
715
 
716
  /**
717
  * HTML formatted row.
718
+ *
719
  * @return type
720
  */
721
  function child_row( $child ) {
731
 
732
  /**
733
  * Header HTML formatted output.
734
+ *
735
  * Each header <th> is array element. Sortable.
736
+ *
737
  * @return array 'header_id' => html
738
  */
739
  function headers() {
741
  // Sorting
742
  $dir = isset( $_GET['sort'] ) && $_GET['sort'] == 'ASC' ? 'DESC' : 'ASC';
743
  $dir_default = 'ASC';
744
+ $sort_field = isset( $_GET['field'] ) ? sanitize_text_field( $_GET['field'] ) : '';
745
 
746
  // Set values
747
  $post = $this->parent;
758
  }
759
 
760
  if ( $header == '_wp_title' ) {
761
+ if ( $this->child_supports['title']) {
762
+ $title_dir = $sort_field == '_wp_title' ? $dir : 'ASC';
763
+ $headers[$header] = '';
764
+ $headers[$header] .= $sort_field == '_wp_title' ? '<div class="wpcf-pr-sort-' . $dir . '"></div>' : '';
765
+ $headers[$header] .= '<a href="' . admin_url( 'admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=pr_sort&amp;field='
766
+ . '_wp_title&amp;sort=' . $title_dir . '&amp;post_id=' . $post->ID . '&amp;post_type='
767
+ . $post_type . '&amp;_wpnonce='
768
+ . wp_create_nonce( 'pr_sort' ) ) . '">' . __( 'Post Title' ) . '</a>';
769
+ } else {
770
+ $headers[$header] = 'ID';
771
+ }
772
  } else if ( $header == '_wp_body' ) {
773
  $body_dir = $sort_field == '_wp_body' ? $dir : $dir_default;
774
  $headers[$header] = '';
777
  . '_wp_body&amp;sort=' . $body_dir . '&amp;post_id=' . $post->ID . '&amp;post_type='
778
  . $post_type . '&amp;_wpnonce='
779
  . wp_create_nonce( 'pr_sort' ) ) . '">' . __( 'Post Body' ) . '</a>';
780
+ } else if ( $header == '_wp_excerpt' ) {
781
+ $headers[$header] = __( 'Post excerpt' );
782
  } else if ( strpos( $header, WPCF_META_PREFIX ) === 0
783
  && isset( $wpcf_fields[str_replace( WPCF_META_PREFIX, '',
784
  $header )] ) ) {
830
  return $headers;
831
  }
832
 
833
+ }
embedded/classes/repeater.php CHANGED
@@ -1,29 +1,29 @@
1
  <?php
2
  /*
3
- *
4
- *
5
  * Repeater fields class.
6
  */
7
 
8
  /**
9
  * Repater class
10
- *
11
  * Very useful, should be used to finish small tasks for repeater field.
12
- *
13
  * Example:
14
- *
15
  * // Setup field
16
  * global $wpcf;
17
  * $my_field = new WPCF_Repeater();
18
  * $my_field->set($wpcf->post, wpcf_admin_fields_get_field('image'));
19
- *
20
  * // Use it
21
  * $my_field->save();
22
- *
23
  * Generic instance can be found in global $wpcf.
24
  * global $wpcf;
25
  * $wpcf->repeater->set(...);
26
- *
27
  * @since Types 1.2
28
  * @package Types
29
  * @subpackage Classes
@@ -36,30 +36,30 @@ class WPCF_Repeater extends WPCF_Field
36
 
37
  /**
38
  * Field order
39
- *
40
- * @var type
41
  */
42
  var $order;
43
 
44
  /**
45
  * Indexing
46
- *
47
  * Set counts when processing fields.
48
- *
49
- * @var type
50
  */
51
  var $index = 0;
52
 
53
  /**
54
  * Field title
55
- * @var type
56
  */
57
  var $title = '';
58
 
59
  /**
60
  * Field description.
61
- *
62
- * @var type
63
  */
64
  var $description = '';
65
 
@@ -73,9 +73,9 @@ class WPCF_Repeater extends WPCF_Field
73
 
74
  /**
75
  * Calls parent set func.
76
- *
77
  * @param type $post
78
- * @param type $field
79
  */
80
  function set( $post, $field ) {
81
  parent::set( $post, $field );
@@ -84,12 +84,12 @@ class WPCF_Repeater extends WPCF_Field
84
 
85
  /**
86
  * Save fields
87
- *
88
  * If $data empty, $_POST will be checked
89
- *
90
  * @global type $wpcf
91
  * @param type $data
92
- * @return boolean
93
  */
94
  function save( $data = null ) {
95
 
@@ -107,7 +107,7 @@ class WPCF_Repeater extends WPCF_Field
107
 
108
  // Set data
109
  if ( !empty( $data ) ) {
110
-
111
  do_action('wpcf_postmeta_before_add_repetitive', $this->post, $this->cf);
112
 
113
  // Insert new meta and collect all new mids
@@ -116,7 +116,7 @@ class WPCF_Repeater extends WPCF_Field
116
  foreach ( $data as $meta_value ) {
117
 
118
  /*
119
- *
120
  * Deprecated!
121
  */
122
  if ( is_array( $meta_value ) && isset( $meta_value['new_value'] ) ) {
@@ -142,7 +142,7 @@ class WPCF_Repeater extends WPCF_Field
142
  // Call insert post actions on each field
143
  $this->_action_save( $this->cf, $_meta_value, $mid, $meta_value );
144
  }
145
-
146
  do_action('wpcf_postmeta_after_add_repetitive', $this->post, $this->cf);
147
 
148
  // Save order
@@ -160,8 +160,8 @@ class WPCF_Repeater extends WPCF_Field
160
 
161
  /**
162
  * Fetch and sort fields.
163
- *
164
- * @global type $wpdb
165
  */
166
  function _get_meta() {
167
  global $wpdb;
@@ -169,7 +169,7 @@ class WPCF_Repeater extends WPCF_Field
169
  $cache_key = md5( 'repeater::_get_meta' . $this->post->ID . $this->slug );
170
  $cache_group = 'types_cache';
171
  $cached_object = wp_cache_get( $cache_key, $cache_group );
172
-
173
  if ( $this->use_cache ) {
174
  if ( false != $cached_object && is_array( $cached_object ) ) {
175
  return $cached_object;
@@ -181,10 +181,10 @@ class WPCF_Repeater extends WPCF_Field
181
  $ordered = array();
182
  $this->order = get_post_meta( $this->post->ID, $this->order_meta_name,
183
  true );
184
-
185
  $cache_key_field = md5( 'field::_get_meta' . $this->post->ID . $this->slug );
186
  $cached_object_field = wp_cache_get( $cache_key_field, $cache_group );
187
-
188
  if ( $this->use_cache ) {
189
  if ( false != $cached_object_field && is_array( $cached_object_field ) ) {// WordPress cache
190
  $r = $cached_object_field;
@@ -265,8 +265,8 @@ class WPCF_Repeater extends WPCF_Field
265
  }
266
 
267
  /**
268
- * Sets repetitive field form.
269
- *
270
  * @todo Make more distinction between $field_form and $form_field
271
  */
272
  function get_fields_form() {
@@ -315,8 +315,8 @@ class WPCF_Repeater extends WPCF_Field
315
 
316
  // Set style
317
  /*
318
- *
319
- *
320
  * Hide if field not passed check
321
  * TODO Move this to WPCF_Conditional
322
  */
@@ -328,17 +328,17 @@ class WPCF_Repeater extends WPCF_Field
328
  $css_cd = !$show ? 'display:none;' : '';
329
 
330
  /**
331
- *
332
- *
333
- *
334
- *
335
  * Set title and description
336
  * TODO See if can be improved getting main element
337
- *
338
  * Get first element and extract details
339
  * Pass emty string as value to avoid using meta as array
340
  */
341
- //
342
  $_c = array_values( parent::_get_meta_form( '' ) );
343
  array_shift( $_c );
344
  $_main_element = array_shift( $_c );
@@ -351,8 +351,8 @@ class WPCF_Repeater extends WPCF_Field
351
  }
352
 
353
  /*
354
- *
355
- *
356
  * Start wrapper
357
  */
358
  $form[$unique_id . '_repetitive_wrapper_open'] = array(
@@ -372,12 +372,12 @@ class WPCF_Repeater extends WPCF_Field
372
 
373
  // Set hidden mark field
374
  /*
375
- *
376
- *
377
- *
378
  * This actually marks field as repetitive
379
  * IMPORTANT!!! IF NOT marked field won't be saved at all!
380
- *
381
  * @see wpcf_admin_post_save_post_hook()
382
  */
383
  $form[$form_id . '_hidden_mark'] = array(
@@ -443,9 +443,9 @@ class WPCF_Repeater extends WPCF_Field
443
 
444
  /**
445
  * Sete repetitive form for single field.
446
- *
447
  * @param type $meta
448
- * @return string
449
  */
450
  function get_field_form( $meta_value = null, $meta_id = null ) {
451
 
@@ -456,8 +456,8 @@ class WPCF_Repeater extends WPCF_Field
456
  $key = 'wpcf_field_' . md5( maybe_serialize( $meta_value ) . $meta_id );
457
  }
458
  /*
459
- *
460
- *
461
  * TODO We prevented array because of some fails we had before.
462
  * Now it should work fine
463
  * Add debug log if meta_value['custom_order'] passed.
@@ -480,7 +480,7 @@ class WPCF_Repeater extends WPCF_Field
480
  $field_form = parent::_get_meta_form( $meta_value, $meta_id, false );
481
 
482
  /*
483
- *
484
  * Apply filters to each form element.
485
  * Here we add specific properties
486
  * e.g. Skype alters fields.
@@ -489,7 +489,7 @@ class WPCF_Repeater extends WPCF_Field
489
  foreach ( $field_form as $k => $field ) {
490
 
491
  /*
492
- *
493
  * IMPORTANT
494
  * We change name to hold array
495
  */
@@ -579,7 +579,7 @@ class WPCF_Repeater extends WPCF_Field
579
  }
580
 
581
  /**
582
- * Set counting elements.
583
  */
584
  function _set_form_count() {
585
  if ( $this->index === 0 ) {
@@ -592,8 +592,11 @@ class WPCF_Repeater extends WPCF_Field
592
 
593
  /**
594
  * Deletes meta.
595
- *
596
- * @param type $meta_key
 
 
 
597
  */
598
  function delete( $meta_id ) {
599
  global $wpdb;
@@ -613,4 +616,4 @@ class WPCF_Repeater extends WPCF_Field
613
  return $r;
614
  }
615
 
616
- }
1
  <?php
2
  /*
3
+ *
4
+ *
5
  * Repeater fields class.
6
  */
7
 
8
  /**
9
  * Repater class
10
+ *
11
  * Very useful, should be used to finish small tasks for repeater field.
12
+ *
13
  * Example:
14
+ *
15
  * // Setup field
16
  * global $wpcf;
17
  * $my_field = new WPCF_Repeater();
18
  * $my_field->set($wpcf->post, wpcf_admin_fields_get_field('image'));
19
+ *
20
  * // Use it
21
  * $my_field->save();
22
+ *
23
  * Generic instance can be found in global $wpcf.
24
  * global $wpcf;
25
  * $wpcf->repeater->set(...);
26
+ *
27
  * @since Types 1.2
28
  * @package Types
29
  * @subpackage Classes
36
 
37
  /**
38
  * Field order
39
+ *
40
+ * @var type
41
  */
42
  var $order;
43
 
44
  /**
45
  * Indexing
46
+ *
47
  * Set counts when processing fields.
48
+ *
49
+ * @var type
50
  */
51
  var $index = 0;
52
 
53
  /**
54
  * Field title
55
+ * @var type
56
  */
57
  var $title = '';
58
 
59
  /**
60
  * Field description.
61
+ *
62
+ * @var type
63
  */
64
  var $description = '';
65
 
73
 
74
  /**
75
  * Calls parent set func.
76
+ *
77
  * @param type $post
78
+ * @param type $field
79
  */
80
  function set( $post, $field ) {
81
  parent::set( $post, $field );
84
 
85
  /**
86
  * Save fields
87
+ *
88
  * If $data empty, $_POST will be checked
89
+ *
90
  * @global type $wpcf
91
  * @param type $data
92
+ * @return boolean
93
  */
94
  function save( $data = null ) {
95
 
107
 
108
  // Set data
109
  if ( !empty( $data ) ) {
110
+
111
  do_action('wpcf_postmeta_before_add_repetitive', $this->post, $this->cf);
112
 
113
  // Insert new meta and collect all new mids
116
  foreach ( $data as $meta_value ) {
117
 
118
  /*
119
+ *
120
  * Deprecated!
121
  */
122
  if ( is_array( $meta_value ) && isset( $meta_value['new_value'] ) ) {
142
  // Call insert post actions on each field
143
  $this->_action_save( $this->cf, $_meta_value, $mid, $meta_value );
144
  }
145
+
146
  do_action('wpcf_postmeta_after_add_repetitive', $this->post, $this->cf);
147
 
148
  // Save order
160
 
161
  /**
162
  * Fetch and sort fields.
163
+ *
164
+ * @global object $wpdb
165
  */
166
  function _get_meta() {
167
  global $wpdb;
169
  $cache_key = md5( 'repeater::_get_meta' . $this->post->ID . $this->slug );
170
  $cache_group = 'types_cache';
171
  $cached_object = wp_cache_get( $cache_key, $cache_group );
172
+
173
  if ( $this->use_cache ) {
174
  if ( false != $cached_object && is_array( $cached_object ) ) {
175
  return $cached_object;
181
  $ordered = array();
182
  $this->order = get_post_meta( $this->post->ID, $this->order_meta_name,
183
  true );
184
+
185
  $cache_key_field = md5( 'field::_get_meta' . $this->post->ID . $this->slug );
186
  $cached_object_field = wp_cache_get( $cache_key_field, $cache_group );
187
+
188
  if ( $this->use_cache ) {
189
  if ( false != $cached_object_field && is_array( $cached_object_field ) ) {// WordPress cache
190
  $r = $cached_object_field;
265
  }
266
 
267
  /**
268
+ * Sets repetitive field form.
269
+ *
270
  * @todo Make more distinction between $field_form and $form_field
271
  */
272
  function get_fields_form() {
315
 
316
  // Set style
317
  /*
318
+ *
319
+ *
320
  * Hide if field not passed check
321
  * TODO Move this to WPCF_Conditional
322
  */
328
  $css_cd = !$show ? 'display:none;' : '';
329
 
330
  /**
331
+ *
332
+ *
333
+ *
334
+ *
335
  * Set title and description
336
  * TODO See if can be improved getting main element
337
+ *
338
  * Get first element and extract details
339
  * Pass emty string as value to avoid using meta as array
340
  */
341
+ //
342
  $_c = array_values( parent::_get_meta_form( '' ) );
343
  array_shift( $_c );
344
  $_main_element = array_shift( $_c );
351
  }
352
 
353
  /*
354
+ *
355
+ *
356
  * Start wrapper
357
  */
358
  $form[$unique_id . '_repetitive_wrapper_open'] = array(
372
 
373
  // Set hidden mark field
374
  /*
375
+ *
376
+ *
377
+ *
378
  * This actually marks field as repetitive
379
  * IMPORTANT!!! IF NOT marked field won't be saved at all!
380
+ *
381
  * @see wpcf_admin_post_save_post_hook()
382
  */
383
  $form[$form_id . '_hidden_mark'] = array(
443
 
444
  /**
445
  * Sete repetitive form for single field.
446
+ *
447
  * @param type $meta
448
+ * @return string
449
  */
450
  function get_field_form( $meta_value = null, $meta_id = null ) {
451
 
456
  $key = 'wpcf_field_' . md5( maybe_serialize( $meta_value ) . $meta_id );
457
  }
458
  /*
459
+ *
460
+ *
461
  * TODO We prevented array because of some fails we had before.
462
  * Now it should work fine
463
  * Add debug log if meta_value['custom_order'] passed.
480
  $field_form = parent::_get_meta_form( $meta_value, $meta_id, false );
481
 
482
  /*
483
+ *
484
  * Apply filters to each form element.
485
  * Here we add specific properties
486
  * e.g. Skype alters fields.
489
  foreach ( $field_form as $k => $field ) {
490
 
491
  /*
492
+ *
493
  * IMPORTANT
494
  * We change name to hold array
495
  */
579
  }
580
 
581
  /**
582
+ * Set counting elements.
583
  */
584
  function _set_form_count() {
585
  if ( $this->index === 0 ) {
592
 
593
  /**
594
  * Deletes meta.
595
+ *
596
+ * @global object $wpdb
597
+ *
598
+ * @param type $meta_key
599
+ *
600
  */
601
  function delete( $meta_id ) {
602
  global $wpdb;
616
  return $r;
617
  }
618
 
619
+ }
embedded/classes/usermeta_field.php CHANGED
@@ -1,7 +1,5 @@
1
  <?php
2
  /*
3
- *
4
- *
5
  * Usermeta Field class extends Field.
6
  */
7
 
@@ -13,16 +11,16 @@ class WPCF_Usermeta_Field extends WPCF_Field
13
 
14
  /**
15
  * Set current post and field.
16
- *
17
  * @param type $post
18
- * @param type $cf
19
  */
20
  function set( $user_id, $cf ) {
21
 
22
  global $wpcf;
23
 
24
  /*
25
- *
26
  * Check if $cf is string
27
  */
28
  if ( is_string( $cf ) ) {
@@ -63,9 +61,9 @@ class WPCF_Usermeta_Field extends WPCF_Field
63
 
64
  /**
65
  * Save usermeta field.
66
- *
67
- *
68
- * @param type $value
69
  */
70
  function usermeta_save( $value = null ) {
71
 
@@ -74,8 +72,8 @@ class WPCF_Usermeta_Field extends WPCF_Field
74
  $value = $this->get_submitted_data();
75
  }
76
  /*
77
- *
78
- *
79
  * Since Types 1.2
80
  * We completely rewrite meta.
81
  * It has no impact on frontend and covers a lot of cases
@@ -105,17 +103,17 @@ class WPCF_Usermeta_Field extends WPCF_Field
105
 
106
  /**
107
  * Fetch and sort fields.
108
- *
109
- *
 
110
  */
111
  function _get_meta() {
112
  global $wpdb;
113
 
114
-
115
  $cache_key = md5( 'usermeta::_get_meta' . $this->currentUID . $this->slug );
116
  $cache_group = 'types_cache';
117
  $cached_object = wp_cache_get( $cache_key, $cache_group );
118
-
119
  if ( $this->use_cache ) {
120
  if ( false != $cached_object && is_array( $cached_object ) && isset( $cached_object[0] ) ) {// WordPress cache
121
  $r = $cached_object[0];
@@ -173,17 +171,15 @@ class WPCF_Usermeta_Field extends WPCF_Field
173
  $this->__meta = $meta;
174
 
175
  /*
176
- *
177
  * Apply filters
178
  * !!! IMPORTANT !!!
179
  * TODO Make this only place where field meta value is filtered
180
  */
181
  $meta = apply_filters( 'wpcf_fields_value_get', $meta, $this );
182
- $meta = apply_filters( 'wpcf_fields_slug_' . $this->cf['slug']
183
- . '_value_get', $meta, $this );
184
- $meta = apply_filters( 'wpcf_fields_type_' . $this->cf['type']
185
- . '_value_get', $meta, $this );
186
  return $meta;
187
  }
188
 
189
- }
1
  <?php
2
  /*
 
 
3
  * Usermeta Field class extends Field.
4
  */
5
 
11
 
12
  /**
13
  * Set current post and field.
14
+ *
15
  * @param type $post
16
+ * @param type $cf
17
  */
18
  function set( $user_id, $cf ) {
19
 
20
  global $wpcf;
21
 
22
  /*
23
+ *
24
  * Check if $cf is string
25
  */
26
  if ( is_string( $cf ) ) {
61
 
62
  /**
63
  * Save usermeta field.
64
+ *
65
+ *
66
+ * @param type $value
67
  */
68
  function usermeta_save( $value = null ) {
69
 
72
  $value = $this->get_submitted_data();
73
  }
74
  /*
75
+ *
76
+ *
77
  * Since Types 1.2
78
  * We completely rewrite meta.
79
  * It has no impact on frontend and covers a lot of cases
103
 
104
  /**
105
  * Fetch and sort fields.
106
+ *
107
+ * @global object $wpdb
108
+ *
109
  */
110
  function _get_meta() {
111
  global $wpdb;
112
 
 
113
  $cache_key = md5( 'usermeta::_get_meta' . $this->currentUID . $this->slug );
114
  $cache_group = 'types_cache';
115
  $cached_object = wp_cache_get( $cache_key, $cache_group );
116
+
117
  if ( $this->use_cache ) {
118
  if ( false != $cached_object && is_array( $cached_object ) && isset( $cached_object[0] ) ) {// WordPress cache
119
  $r = $cached_object[0];
171
  $this->__meta = $meta;
172
 
173
  /*
174
+ *
175
  * Apply filters
176
  * !!! IMPORTANT !!!
177
  * TODO Make this only place where field meta value is filtered
178
  */
179
  $meta = apply_filters( 'wpcf_fields_value_get', $meta, $this );
180
+ $meta = apply_filters( 'wpcf_fields_slug_' . $this->cf['slug'] . '_value_get', $meta, $this );
181
+ $meta = apply_filters( 'wpcf_fields_type_' . $this->cf['type'] . '_value_get', $meta, $this );
 
 
182
  return $meta;
183
  }
184
 
185
+ }
embedded/classes/usermeta_repeater.php CHANGED
@@ -8,30 +8,30 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
8
 
9
  /**
10
  * Field order
11
- *
12
- * @var type
13
  */
14
  var $order;
15
 
16
  /**
17
  * Indexing
18
- *
19
  * Set counts when processing fields.
20
- *
21
- * @var type
22
  */
23
  var $index = 0;
24
 
25
  /**
26
  * Field title
27
- * @var type
28
  */
29
  var $title = '';
30
 
31
  /**
32
  * Field description.
33
- *
34
- * @var type
35
  */
36
  var $description = '';
37
 
@@ -45,9 +45,9 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
45
 
46
  /**
47
  * Calls parent set func.
48
- *
49
  * @param type $post
50
- * @param type $field
51
  */
52
  function set( $user_id, $field ) {
53
  parent::set( $user_id, $field );
@@ -56,12 +56,12 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
56
 
57
  /**
58
  * Save fields
59
- *
60
  * If $data empty, $_POST will be checked
61
- *
62
  * @global type $wpcf
63
  * @param type $data
64
- * @return boolean
65
  */
66
  function save( $data = null ) {
67
 
@@ -83,7 +83,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
83
  foreach ( $data as $meta_value ) {
84
 
85
  /*
86
- *
87
  * Deprecated!
88
  */
89
  if ( is_array( $meta_value ) && isset( $meta_value['new_value'] ) ) {
@@ -123,8 +123,8 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
123
 
124
  /**
125
  * Fetch and sort fields.
126
- *
127
- * @global type $wpdb
128
  */
129
  function _get_meta() {
130
  global $wpdb;
@@ -132,7 +132,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
132
  $cache_key = md5( 'usermetarepeater::_get_meta' . $this->currentUID . $this->slug );
133
  $cache_group = 'types_cache';
134
  $cached_object = wp_cache_get( $cache_key, $cache_group );
135
-
136
  if ( $this->use_cache ) {
137
  if ( false != $cached_object && is_array( $cached_object ) ) {
138
  return $cached_object;
@@ -146,10 +146,10 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
146
  $ordered = array();
147
  $this->order = get_user_meta( $this->currentUID, $this->order_meta_name,
148
  true );
149
-
150
  $cache_key_userfield = md5( 'usermeta::_get_meta' . $this->currentUID . $this->slug );
151
  $cached_object_userfield = wp_cache_get( $cache_key_userfield, $cache_group );
152
-
153
  if ( $this->use_cache ) {
154
  if ( false != $cached_object_userfield && is_array( $cached_object_userfield ) ) {// WordPress cache
155
  $r = $cached_object_userfield;
@@ -221,8 +221,8 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
221
  }
222
 
223
  /**
224
- * Sets repetitive field form.
225
- *
226
  * @todo Make more distinction between $field_form and $form_field
227
  */
228
  function get_fields_form( $is_profile = '' ) {
@@ -273,8 +273,8 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
273
 
274
  // Set style
275
  /*
276
- *
277
- *
278
  * Hide if field not passed check
279
  * TODO Move this to WPCF_Conditional
280
  */
@@ -286,17 +286,17 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
286
  $css_cd = !$show ? 'display:none;' : '';
287
 
288
  /**
289
- *
290
- *
291
- *
292
- *
293
  * Set title and description
294
  * TODO See if can be improved getting main element
295
- *
296
  * Get first element and extract details
297
  * Pass emty string as value to avoid using meta as array
298
  */
299
- //
300
  $_c = array_values( parent::_get_meta_form( '' ) );
301
  array_shift( $_c );
302
  $_main_element = array_shift( $_c );
@@ -319,8 +319,8 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
319
  );
320
 
321
  /*
322
- *
323
- *
324
  * Start wrapper
325
  */
326
  $form[$unique_id . '_repetitive_wrapper_open'] = array(
@@ -334,12 +334,12 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
334
 
335
  // Set hidden mark field
336
  /*
337
- *
338
- *
339
- *
340
  * This actually marks field as repetitive
341
  * IMPORTANT!!! IF NOT marked field won't be saved at all!
342
- *
343
  * @see wpcf_admin_post_save_post_hook()
344
  */
345
  $form[$form_id . '_hidden_mark'] = array(
@@ -406,9 +406,9 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
406
 
407
  /**
408
  * Sete repetitive form for single field.
409
- *
410
  * @param type $meta
411
- * @return string
412
  */
413
  function get_field_form( $meta_value = null, $meta_id = null ) {
414
 
@@ -435,7 +435,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
435
  $field_form = parent::_get_meta_form( $meta_value, $meta_id, false );
436
 
437
  /*
438
- *
439
  * Apply filters to each form element.
440
  * Here we add specific properties
441
  * e.g. Skype alters fields.
@@ -444,7 +444,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
444
  foreach ( $field_form as $k => $field ) {
445
 
446
  /*
447
- *
448
  * IMPORTANT
449
  * We change name to hold array
450
  */
@@ -534,7 +534,7 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
534
  }
535
 
536
  /**
537
- * Set counting elements.
538
  */
539
  function _set_form_count() {
540
  if ( $this->index === 0 ) {
@@ -547,8 +547,11 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
547
 
548
  /**
549
  * Deletes meta.
550
- *
551
- * @param type $meta_key
 
 
 
552
  */
553
  function delete( $meta_id ) {
554
  global $wpdb;
@@ -568,4 +571,4 @@ class WPCF_Usermeta_Repeater extends WPCF_Usermeta_Field
568
  return $r;
569
  }
570
 
571
- }
8
 
9
  /**
10
  * Field order
11
+ *
12
+ * @var type
13
  */
14
  var $order;
15
 
16
  /**
17
  * Indexing
18
+ *
19
  * Set counts when processing fields.
20
+ *
21
+ * @var type
22
  */
23
  var $index = 0;
24
 
25
  /**
26
  * Field title
27
+ * @var type
28
  */
29
  var $title = '';
30
 
31
  /**
32
  * Field description.
33
+ *
34
+ * @var type
35
  */
36
  var $description = '';
37
 
45
 
46
  /**
47
  * Calls parent set func.
48
+ *
49
  * @param type $post
50
+ * @param type $field
51
  */
52
  function set( $user_id, $field ) {
53
  parent::set( $user_id, $field );
56
 
57
  /**
58
  * Save fields
59
+ *
60
  * If $data empty, $_POST will be checked
61
+ *
62
  * @global type $wpcf
63
  * @param type $data
64
+ * @return boolean
65
  */
66
  function save( $data = null ) {
67
 
83
  foreach ( $data as $meta_value ) {
84
 
85
  /*
86
+ *
87
  * Deprecated!
88
  */
89
  if ( is_array( $meta_value ) && isset( $meta_value['new_value'] ) ) {
123
 
124
  /**
125
  * Fetch and sort fields.
126
+ *
127
+ * @global object $wpdb
128
  */
129
  function _get_meta() {
130
  global $wpdb;
132
  $cache_key = md5( 'usermetarepeater::_get_meta' . $this->currentUID . $this->slug );
133
  $cache_group = 'types_cache';
134
  $cached_object = wp_cache_get( $cache_key, $cache_group );
135
+
136
  if ( $this->use_cache ) {
137
  if ( false != $cached_object && is_array( $cached_object ) ) {
138
  return $cached_object;
146
  $ordered = array();
147
  $this->order = get_user_meta( $this->currentUID, $this->order_meta_name,
148
  true );
149
+
150
  $cache_key_userfield = md5( 'usermeta::_get_meta' . $this->currentUID . $this->slug );
151
  $cached_object_userfield = wp_cache_get( $cache_key_userfield, $cache_group );
152
+
153
  if ( $this->use_cache ) {
154
  if ( false != $cached_object_userfield && is_array( $cached_object_userfield ) ) {// WordPress cache
155
  $r = $cached_object_userfield;
221
  }
222
 
223
  /**
224
+ * Sets repetitive field form.
225
+ *
226
  * @todo Make more distinction between $field_form and $form_field
227
  */
228
  function get_fields_form( $is_profile = '' ) {
273
 
274
  // Set style
275
  /*
276
+ *
277
+ *
278
  * Hide if field not passed check
279
  * TODO Move this to WPCF_Conditional
280
  */
286
  $css_cd = !$show ? 'display:none;' : '';
287
 
288
  /**
289
+ *
290
+ *
291
+ *
292
+ *
293
  * Set title and description
294
  * TODO See if can be improved getting main element
295
+ *
296
  * Get first element and extract details
297
  * Pass emty string as value to avoid using meta as array
298
  */
299
+ //
300
  $_c = array_values( parent::_get_meta_form( '' ) );
301
  array_shift( $_c );
302
  $_main_element = array_shift( $_c );
319
  );
320
 
321
  /*
322
+ *
323
+ *
324
  * Start wrapper
325
  */
326
  $form[$unique_id . '_repetitive_wrapper_open'] = array(
334
 
335
  // Set hidden mark field
336
  /*
337
+ *
338
+ *
339
+ *
340
  * This actually marks field as repetitive
341
  * IMPORTANT!!! IF NOT marked field won't be saved at all!
342
+ *
343
  * @see wpcf_admin_post_save_post_hook()
344
  */
345
  $form[$form_id . '_hidden_mark'] = array(
406
 
407
  /**
408
  * Sete repetitive form for single field.
409
+ *
410
  * @param type $meta
411
+ * @return string
412
  */
413
  function get_field_form( $meta_value = null, $meta_id = null ) {
414
 
435
  $field_form = parent::_get_meta_form( $meta_value, $meta_id, false );
436
 
437
  /*
438
+ *
439
  * Apply filters to each form element.
440
  * Here we add specific properties
441
  * e.g. Skype alters fields.
444
  foreach ( $field_form as $k => $field ) {
445
 
446
  /*
447
+ *
448
  * IMPORTANT
449
  * We change name to hold array
450
  */
534
  }
535
 
536
  /**
537
+ * Set counting elements.
538
  */
539
  function _set_form_count() {
540
  if ( $this->index === 0 ) {
547
 
548
  /**
549
  * Deletes meta.
550
+ *
551
+ * @global object $wpdb
552
+ *
553
+ * @param type $meta_key
554
+ *
555
  */
556
  function delete( $meta_id ) {
557
  global $wpdb;
571
  return $r;
572
  }
573
 
574
+ }
embedded/classes/validate.php CHANGED
@@ -388,6 +388,29 @@ class Wpcf_Validate
388
  return $form;
389
  }
390
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  public static function setForced( $element, $field, $data = array() )
392
  {
393
  $attributes = array();
@@ -432,4 +455,4 @@ class Wpcf_Validate
432
  return true;
433
  }
434
 
435
- }
388
  return $form;
389
  }
390
 
391
+ /**
392
+ * Returns form data.
393
+ *
394
+ * @param type $field
395
+ * @param type $data
396
+ * @return array
397
+ */
398
+ public static function skype_form( $field, $data = array() )
399
+ {
400
+ $form = array();
401
+ $form['skype-checkbox'] = array(
402
+ '#type' => 'checkbox',
403
+ '#title' => 'Skype',
404
+ '#name' => $field['#name'] . '[active]',
405
+ '#default_value' => isset( $data['active'] ) ? 1 : 0,
406
+ '#inline' => true,
407
+ '#suffix' => '<br />',
408
+ );
409
+ $form['skype-checkbox'] = self::setForced( $form['skype-checkbox'], $field, $data );
410
+ $form['skype-message'] = self::get_custom_message( $field, self::get_message( 'skype' ), $data );
411
+ return $form;
412
+ }
413
+
414
  public static function setForced( $element, $field, $data = array() )
415
  {
416
  $attributes = array();
455
  return true;
456
  }
457
 
458
+ }
embedded/classes/validation-cakephp.php CHANGED
@@ -195,6 +195,29 @@ class Wpcf_Cake_Validation
195
  return $return;
196
  }
197
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  /**
199
  * Checks that a string length is within s specified range.
200
  * Spaces are included in the character count.
195
  return $return;
196
  }
197
 
198
+ function skype( $check ) {
199
+ $_this = &Wpcf_Cake_Validation::getInstance();
200
+ $_this->__reset();
201
+ $_this->check = $check;
202
+
203
+ if ( is_array( $check ) ) {
204
+ $_this->_extract( $check );
205
+ }
206
+
207
+ if ( empty( $_this->check ) && $_this->check != '0' ) {
208
+ return false;
209
+ }
210
+ $_this->regex = '/^[a-zA-Z0-9\s\-\_]*$/mu';
211
+ $return = $_this->_check();
212
+
213
+ if ( !$return ) {
214
+ $_this->regex = '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}\s\-\_]+$/mu';
215
+ $return = $_this->_check();
216
+ }
217
+
218
+ return $return;
219
+ }
220
+
221
  /**
222
  * Checks that a string length is within s specified range.
223
  * Spaces are included in the character count.
embedded/classes/wpviews.php CHANGED
@@ -7,20 +7,56 @@ class WPCF_WPViews
7
  * Init called from WPCF_Loader.
8
  */
9
  public static function init() {
 
 
10
  add_action( 'views_edit_screen', array('WPCF_WPViews', 'editScreenInit') );
11
  add_action( 'layouts_edit_screen', array('WPCF_WPViews', 'editScreenInit') );
12
- add_action( 'views_ct_inline_editor',
13
- array('WPCF_WPViews', 'addEditorDropdownFilter') );
 
14
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  /**
17
  * Actions for Views edit screens.
18
  */
19
  public static function editScreenInit() {
20
- wp_enqueue_script( 'types' );
21
- wp_enqueue_script( 'types-wp-views' );
22
- wp_enqueue_script( 'toolset-colorbox' );
23
- wp_enqueue_style( 'toolset-colorbox' );
 
 
 
 
 
 
 
 
24
  self::addEditorDropdownFilter();
25
  }
26
 
@@ -31,8 +67,58 @@ class WPCF_WPViews
31
  add_filter( 'editor_addon_menus_wpv-views',
32
  array('WPCF_WPViews', 'editorDropdownFilter') );
33
  add_filter( 'editor_addon_menus_wpv-views',
34
- 'wpcf_admin_post_add_usermeta_to_editor_js' );
35
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  /**
38
  * Adds items to view dropdown.
@@ -40,7 +126,7 @@ class WPCF_WPViews
40
  * @param type $items
41
  * @return type
42
  */
43
- public static function editorDropdownFilter( $items ) {
44
  $post = wpcf_admin_get_edited_post();
45
  if ( empty( $post ) ) {
46
  $post = (object) array('ID' => -1);
@@ -71,7 +157,7 @@ class WPCF_WPViews
71
  foreach ( $fields as $field ) {
72
  $callback = 'wpcfFieldsEditorCallback(\'' . $field['id']
73
  . '\', \'postmeta\', ' . $post->ID . ')';
74
- $add[$group['name']][stripslashes( $field['name'] )] = array(stripslashes( $field['name'] ), trim( wpcf_fields_get_shortcode( $field ),
75
  '[]' ), $group['name'], $callback);
76
  // TODO Remove - it's not post edit screen (meta box JS and CSS)
77
  WPCF_Fields::enqueueScript( $field['type'] );
@@ -80,43 +166,7 @@ class WPCF_WPViews
80
  }
81
  }
82
  }
83
-
84
- $search_key = '';
85
-
86
- // Iterate all items to be displayed in the "V" menu
87
- foreach ( $items as $key => $item ) {
88
- if ( $key == __( 'Basic', 'wpv-views' ) ) {
89
- $search_key = 'found';
90
- continue;
91
- }
92
- if ( $search_key == 'found' ) {
93
- $search_key = $key;
94
- }
95
-
96
- if ( $key == __( 'Field', 'wpv-views' ) && isset( $item[trim( wpcf_types_get_meta_prefix(),
97
- '-' )] ) ) {
98
- unset( $items[$key][trim( wpcf_types_get_meta_prefix(), '-' )] );
99
- }
100
- }
101
- if ( empty( $search_key ) || $search_key == 'found' ) {
102
- $search_key = count( $items );
103
- }
104
-
105
- $insert_position = array_search( $search_key, array_keys( $items ) );
106
- $part_one = array_slice( $items, 0, $insert_position );
107
- $part_two = array_slice( $items, $insert_position );
108
- $items = $part_one + $add + $part_two;
109
-
110
- // apply CSS styles to each item based on post types
111
- foreach ( $items as $key => $value ) {
112
- if ( isset( $item_styles[$key] ) ) {
113
- $items[$key]['css'] = $item_styles[$key];
114
- } else {
115
- $items[$key]['css'] = $all_post_types;
116
- }
117
- }
118
-
119
- return $items;
120
  }
121
 
122
  }
7
  * Init called from WPCF_Loader.
8
  */
9
  public static function init() {
10
+ add_action( 'load-post.php', array( 'WPCF_WPViews', 'wpcf_wpv_admin_post_add_postmeta_usermeta_to_editor_js') );
11
+ add_action( 'load-post-new.php', array( 'WPCF_WPViews', 'wpcf_wpv_admin_post_add_postmeta_usermeta_to_editor_js') );
12
  add_action( 'views_edit_screen', array('WPCF_WPViews', 'editScreenInit') );
13
  add_action( 'layouts_edit_screen', array('WPCF_WPViews', 'editScreenInit') );
14
+ add_action( 'current_screen', array( 'WPCF_WPViews', 'include_types_fields_on_views_dialog_on_demand' ) );
15
+ add_action( 'views_ct_inline_editor', array('WPCF_WPViews', 'addEditorDropdownFilter') );
16
+ add_action( 'wpv_action_wpv_add_types_postmeta_usermeta_to_editor_menus', array('WPCF_WPViews', 'addEditorDropdownFilter') );
17
  }
18
+
19
+ /**
20
+ * Include the Types custom fields and usermeta fields, along with the needed scripts to mange them, in the Fields and Views dialog, on demand
21
+ */
22
+
23
+ public static function include_types_fields_on_views_dialog_on_demand( $current_screen ) {
24
+
25
+ /**
26
+ * wpcf_filter_force_include_types_fields_on_views_dialog
27
+ *
28
+ * Force include the Types fields and usermeta fields as groups on the Fields and Views popup.
29
+ * This adds assets as well as menu items.
30
+ * Note that this happens on current_screen so this filter need to be added before that.
31
+ *
32
+ * @param (bool) Whether to include those items or not.
33
+ * @param $current_screen (object) The current WP_Screen object.
34
+ *
35
+ * @since 1.7
36
+ */
37
+ $force_include_types_in_fields_and_views_dialog = apply_filters( 'wpcf_filter_force_include_types_fields_on_views_dialog', false, $current_screen );
38
+
39
+ if ( $force_include_types_in_fields_and_views_dialog ) {
40
+ self::editScreenInit();
41
+ }
42
+ }
43
 
44
  /**
45
  * Actions for Views edit screens.
46
  */
47
  public static function editScreenInit() {
48
+ if ( ! wp_script_is( 'types', 'enqueued' ) ) {
49
+ wp_enqueue_script( 'types' );
50
+ }
51
+ if ( ! wp_script_is( 'types-wp-views', 'enqueued' ) ) {
52
+ wp_enqueue_script( 'types-wp-views' );
53
+ }
54
+ if ( ! wp_script_is( 'toolset-colorbox', 'enqueued' ) ) {
55
+ wp_enqueue_script( 'toolset-colorbox' );
56
+ }
57
+ if ( ! wp_style_is( 'toolset-colorbox', 'enqueued' ) ) {
58
+ wp_enqueue_style( 'toolset-colorbox' );
59
+ }
60
  self::addEditorDropdownFilter();
61
  }
62
 
67
  add_filter( 'editor_addon_menus_wpv-views',
68
  array('WPCF_WPViews', 'editorDropdownFilter') );
69
  add_filter( 'editor_addon_menus_wpv-views',
70
+ 'wpcf_admin_post_add_usermeta_to_editor_js', 20 );
71
  }
72
+
73
+ public static function wpcf_wpv_admin_post_add_postmeta_usermeta_to_editor_js() {
74
+ add_action( 'wpv_action_wpv_add_types_postmeta_to_editor', array( 'WPCF_WPViews', 'wpcf_admin_post_add_postmeta_to_editor_on_demand' ) );
75
+ add_action( 'wpv_action_wpv_add_types_post_usermeta_to_editor', array( 'WPCF_WPViews', 'wpcf_admin_post_add_usermeta_to_editor_on_demand') );
76
+ }
77
+
78
+ public static function wpcf_admin_post_add_postmeta_to_editor_on_demand( $editor ) {
79
+ add_action( 'admin_footer', 'wpcf_admin_post_js_validation' );
80
+ wpcf_enqueue_scripts();
81
+ wp_enqueue_script( 'toolset-colorbox' );
82
+ wp_enqueue_style( 'toolset-colorbox' );
83
+
84
+ $current_post = wpcf_admin_get_edited_post();
85
+ if ( empty( $current_post ) ) {
86
+ $current_post = (object) array('ID' => -1);
87
+ }
88
+
89
+ $fields = wpcf_admin_post_add_to_editor( 'get' );
90
+ $groups = wpcf_admin_post_get_post_groups_fields( $current_post );
91
+ if (
92
+ ! empty( $fields )
93
+ && ! empty( $groups )
94
+ ) {
95
+ foreach ( $groups as $group ) {
96
+ if ( empty( $group['fields'] ) ) {
97
+ continue;
98
+ }
99
+ foreach ( $group['fields'] as $group_field_id => $group_field ) {
100
+ if ( isset( $fields[$group_field_id] ) ) {
101
+ $field = $fields[$group_field_id];
102
+ $callback = 'wpcfFieldsEditorCallback(\'' . $field['id'] . '\', \'postmeta\', ' . $current_post->ID . ')';
103
+ $editor->add_insert_shortcode_menu(
104
+ stripslashes( $field['name'] ),
105
+ trim( wpcf_fields_get_shortcode( $field ), '[]' ),
106
+ $group['name'],
107
+ $callback
108
+ );
109
+ }
110
+ }
111
+ }
112
+ }
113
+ }
114
+
115
+ public static function wpcf_admin_post_add_usermeta_to_editor_on_demand() {
116
+ add_action( 'admin_footer', 'wpcf_admin_post_js_validation' );
117
+ wpcf_enqueue_scripts();
118
+ wp_enqueue_script( 'toolset-colorbox' );
119
+ wp_enqueue_style( 'toolset-colorbox' );
120
+ add_filter( 'editor_addon_menus_wpv-views', 'wpcf_admin_post_add_usermeta_to_editor_js' );
121
+ }
122
 
123
  /**
124
  * Adds items to view dropdown.
126
  * @param type $items
127
  * @return type
128
  */
129
+ public static function editorDropdownFilter( $menu ) {
130
  $post = wpcf_admin_get_edited_post();
131
  if ( empty( $post ) ) {
132
  $post = (object) array('ID' => -1);
157
  foreach ( $fields as $field ) {
158
  $callback = 'wpcfFieldsEditorCallback(\'' . $field['id']
159
  . '\', \'postmeta\', ' . $post->ID . ')';
160
+ $menu[$group['name']][stripslashes( $field['name'] )] = array(stripslashes( $field['name'] ), trim( wpcf_fields_get_shortcode( $field ),
161
  '[]' ), $group['name'], $callback);
162
  // TODO Remove - it's not post edit screen (meta box JS and CSS)
163
  WPCF_Fields::enqueueScript( $field['type'] );
166
  }
167
  }
168
  }
169
+ return $menu;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  }
171
 
172
  }
embedded/common/changelog.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Common 1.6 (June 11, 2015)
2
+ - Tagged for Types 1.7, Views 1.9 and Layouts 1.2
3
+
4
+ -------------------------------------------------------------------------------------------------------------------
5
+ Common 1.5 (Apr 1, 2015)
6
+ - Tagged for Types 1.6.6, Views 1.8, CRED 1.3.6 and Layouts 1.1.
7
+ - Fixed issue when there is more than one CRED form on a page with the same taxonomy.
8
+ - Fixed a little problem with edit skype button modal window - was too narrow.
9
+ - Fixed empty title problem for filter "wpt_field_options" on user edit/add screen.
10
+ https://wp-types.com/forums/topic/populate-select-field-in-wpcf-um-group/
11
+ - Added filter "toolset_editor_add_form_buttons" to disable Toolset buttons on the post editor.
12
+ - Added placeholder attributes to fields.
13
+ - Updated CakePHP validation URL method to allow new TLD's.
14
+
15
+ -------------------------------------------------------------------------------------------------------------------
16
+ Common 1.4 (Feb 2 2015)
17
+ - Tagged for Views 1.7, Types 1.6.5, CRED 1.3.5 and Layouts 1.0 beta1
18
+ - Updated Installer to 1.5
19
+
20
+ -------------------------------------------------------------------------------------------------------------------
21
+ Common 1.3.1 (Dec 16 2014)
22
+ - Tagged for Views 1.7 beta1 and Layouts 1.0 beta1
23
+ - Fixed issue about Editor addon and ACF compatibility
24
+ - Fixed issue about branding loader
25
+
26
+ -------------------------------------------------------------------------------------------------------------------
27
+ Common 1.3 (Dec 15 2014)
28
+ - Tagged for Views 1.7 beta1 and Layouts 1.0 beta1
embedded/common/classes/class-toolset-admin-bar-menu.php ADDED
@@ -0,0 +1,732 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! class_exists( 'Toolset_Admin_Bar_Menu' ) ) {
4
+
5
+ class Toolset_Admin_Bar_Menu {
6
+
7
+ // singleton
8
+ private static $instance;
9
+
10
+ /**
11
+ * Avoid executing more than once the code
12
+ * @var type bool
13
+ */
14
+ private $done;
15
+
16
+ /** @const */
17
+ public static $default_wordpress_archives = array( 'home-blog', 'search', 'author', 'year', 'month', 'day' );
18
+
19
+ private function __construct() {
20
+ $this->done = false;
21
+
22
+ add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 99 );
23
+
24
+ if ( is_admin() ) {
25
+
26
+ /*
27
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
28
+ */
29
+
30
+ } else {
31
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) );
32
+ }
33
+ }
34
+
35
+ public static function get_instance() {
36
+ if ( ! self::$instance ) {
37
+ self::$instance = new Toolset_Admin_Bar_Menu();
38
+ }
39
+
40
+ return self::$instance;
41
+ }
42
+
43
+ public function enqueue_styles() {
44
+
45
+ if( ! is_admin_bar_showing() ) {
46
+ return;
47
+ }
48
+
49
+ if ( $this->is_layouts_available() ) {
50
+
51
+ // Check also @WPDD_Layouts::enqueue_toolset_common_styles()
52
+ global $wpddlayout;
53
+ $wpddlayout->enqueue_styles( array( 'toolset-common' ) );
54
+
55
+ } else if ( $this->is_views_available() ) {
56
+
57
+ wp_enqueue_style( 'onthegosystems-icons', WPV_URL_EMBEDDED . '/common/res/css/toolset-common.css', array(), WPV_VERSION );
58
+ wp_enqueue_style( 'toolset-common', WPV_URL_EMBEDDED . '/onthego-resources/onthegosystems-icons/css/onthegosystems-icons.css', array( 'onthegosystems-icons' ), WPV_VERSION );
59
+
60
+ }
61
+ }
62
+
63
+ /**
64
+ * @see action admin_bar_menu
65
+ */
66
+ public function admin_bar_menu( $wp_admin_bar ) {
67
+ // Check this haven't called more than once
68
+ if ( $this->done ) {
69
+ return;
70
+ }
71
+
72
+ if ( $this->get_default_plugin() && $this->has_capatibilities() && $this->is_assignable() ) {
73
+
74
+ //
75
+ // We create a Toolset menu and a child submenu.
76
+ // Clicking the parent achieves the same result than clicking the child
77
+ // Maybe we add extra menu options in the future
78
+ //
79
+ // (Icon) Design with Toolset < $href >
80
+ // |
81
+ // +- $title < $href >
82
+ //
83
+
84
+ $menu_data = $this->get_menu_data();
85
+ if ( empty( $menu_data ) ) {
86
+ // If no menu is available, then don't render menu
87
+ return;
88
+ }
89
+ list( $title, $href ) = $menu_data;
90
+
91
+ $args = array(
92
+ 'id' => 'toolset_admin_bar_menu',
93
+ 'title' => __( 'Design with Toolset', 'wpv-views' ),
94
+ 'href' => $href,
95
+ 'meta' => array( 'class' => 'toolset-edit-link' )
96
+ );
97
+ $wp_admin_bar->add_node( $args );
98
+
99
+ $args = array(
100
+ 'parent' => 'toolset_admin_bar_menu',
101
+ 'id' => 'toolset_design_this_item',
102
+ 'title' => $title,
103
+ 'href' => $href,
104
+ );
105
+ $wp_admin_bar->add_node( $args );
106
+
107
+ $this->done = true;
108
+ }
109
+ }
110
+
111
+ /**
112
+ * User is admin or similar?
113
+ * @return boolean
114
+ */
115
+ private function has_capatibilities() {
116
+ $manage_options = current_user_can( 'manage_options' );
117
+
118
+ $has_layouts = $this->is_layouts_available();
119
+
120
+ $has_views = $this->is_views_available();
121
+
122
+ return $manage_options && ( $has_layouts || $has_views );
123
+ }
124
+
125
+ /**
126
+ * Can you assign what you are seeing right now to a Layout, Content Template or WordPress Archive?
127
+ * @return boolean
128
+ */
129
+ private function is_assignable() {
130
+
131
+ $context = $this->get_context();
132
+ if ( ! $context ) { return false; }
133
+ list( $type, $class ) = explode( '|', $context );
134
+
135
+ if ( is_admin() ) {
136
+
137
+ /*
138
+ global $post_type;
139
+ $screen = get_current_screen();
140
+ if( preg_match( '/^(edit|edit-tags|post)$/', $screen->base ) && empty($screen->action) ) {
141
+
142
+ if( 'edit' === $screen->base ) {
143
+
144
+ // $post_type | archive
145
+
146
+ if ( 'page' === $post_type ) {
147
+ return false;
148
+ }
149
+
150
+ $post_type_object = get_post_type_object( $screen->post_type );
151
+ if ( ! ( $post_type_object->publicly_queryable && $post_type_object->has_archive ) ) {
152
+ return false;
153
+ }
154
+
155
+ } else if( 'edit-tags' === $screen->base ) {
156
+
157
+ // $taxonomy | archive
158
+
159
+ $taxonomy = get_taxonomy( $screen->taxonomy );
160
+ if ( !( $taxonomy->public ) ) {
161
+ return false;
162
+ }
163
+
164
+ } else if( 'post' === $screen->base ) {
165
+
166
+ // $post_type | page
167
+
168
+ $post_type_object = get_post_type_object( $screen->post_type );
169
+ if ( ! $post_type_object->publicly_queryable ) {
170
+ return false;
171
+ }
172
+
173
+ }
174
+
175
+ }
176
+ */
177
+
178
+ } else {
179
+
180
+ // Backend
181
+ if( 'page' === $class && '404' === $type ) {
182
+
183
+ return $this->is_layouts_available() && ( WPDD_Layouts_Users_Profiles::user_can_create() && WPDD_Layouts_Users_Profiles::user_can_assign() || WPDD_Layouts_Users_Profiles::user_can_edit() );
184
+
185
+ } else if ( 'page' === $class ) {
186
+
187
+ $post_type_object = get_post_type_object( $type );
188
+ $is_cpt = $post_type_object != null;
189
+ if( ! $is_cpt /* || ! $post_type_object->publicly_queryable */ ) {
190
+ return false;
191
+ }
192
+
193
+ } else if ( 'archive' === $class && in_array( $type, self::$default_wordpress_archives ) ) {
194
+ // DO NOTHING
195
+ } else if ( 'archive' === $class && 'page' === $type ) {
196
+ return false;
197
+ } else if ( 'archive' === $class ) {
198
+
199
+ $taxonomy = get_taxonomy( $type );
200
+ $is_tax = $taxonomy !== false;
201
+ if ( $is_tax && ! $taxonomy->public ) {
202
+ return false;
203
+ }
204
+
205
+ $post_type_object = get_post_type_object( $type );
206
+ $is_cpt = $post_type_object != null;
207
+ if( $is_cpt && ( ! $post_type_object->publicly_queryable || ! $post_type_object->has_archive ) ) {
208
+ return false;
209
+ }
210
+
211
+ }
212
+
213
+ }
214
+
215
+ return true;
216
+ }
217
+
218
+ private function is_layouts_available() {
219
+ global $wpddlayout;
220
+
221
+ // class WPDDL_Admin_Pages exists only in full version
222
+ return class_exists( 'WPDDL_Admin_Pages' ) && isset( $wpddlayout ) && is_object( $wpddlayout );
223
+ }
224
+
225
+ private function is_views_available() {
226
+ global $WP_Views;
227
+
228
+ // class WP_Views_plugin exists only in full version
229
+ return class_exists( 'WP_Views_plugin' ) && isset( $WP_Views ) && is_object( $WP_Views );
230
+ }
231
+
232
+ /**
233
+ * Get the best plugin available
234
+ * @return string (layouts|views|)
235
+ */
236
+ private function get_default_plugin() {
237
+ // Layouts always has precedence
238
+ if ( $this->is_layouts_available() ) {
239
+ return 'layouts';
240
+ } else if ( $this->is_views_available() ) {
241
+ return 'views';
242
+ } else {
243
+ // Other toolset plugins may be present
244
+ return null;
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Finds the right action depending on what you're seeing and have done
250
+ * @returns array ($title, $href) or null (do not show menu)
251
+ */
252
+ private function get_menu_data() {
253
+
254
+ $context = $this->get_context();
255
+ if ( ! $context ) {
256
+ // No context => No menu
257
+ return null;
258
+ }
259
+
260
+ // Get type {post types, taxonomies, wordpress archives slugs, 404} and class {page, archive}
261
+ list( $type, $class ) = explode( '|', $context );
262
+
263
+ // We are using the best plugin available by default, unless state otherwise below
264
+ $plugin_used = $this->get_default_plugin();
265
+
266
+ $layout_id = 0;
267
+ $ct_id = 0;
268
+ $wpa_id = 0;
269
+ $post_id = 0;
270
+ $edit_link = null;
271
+
272
+ $is_new = true;
273
+ // warning! syntax sugar ahead
274
+
275
+ // Layouts - Edit Link
276
+ if ( $is_new && $this->is_layouts_available() && WPDD_Layouts_Users_Profiles::user_can_edit() ) {
277
+
278
+ global $wpddlayout;
279
+
280
+ if( is_admin() ) {
281
+
282
+ /*
283
+ // Only individual pages, post type pages, post type archives
284
+ // and taxonomy archives are editable from backend
285
+ //
286
+
287
+ $screen = get_current_screen();
288
+ if( preg_match( '/^(edit|edit-tags|post)$/', $screen->base ) ) {
289
+ // Exists layout? $layout_id?
290
+
291
+ if( 'edit' === $screen->base ) {
292
+ // $post_type | archive
293
+
294
+ $post_type_object = get_post_type_object( $screen->post_type );
295
+ $option_type_name = WPDD_layout_post_loop_cell_manager::OPTION_TYPES_PREFIX . $post_type_object->name;
296
+ if ( $post_type_object && property_exists( $post_type_object, 'public' ) && $post_type_object->public && $wpddlayout->layout_post_loop_cell_manager->get_option( $option_type_name ) ) {
297
+ $layout_id = (int) $wpddlayout->layout_post_loop_cell_manager->get_option( $option_type_name );
298
+ }
299
+
300
+ } else if( 'edit-tags' === $screen->base ) {
301
+ // $taxonomy | archive
302
+
303
+ $option_type_name = WPDD_layout_post_loop_cell_manager::OPTION_TAXONOMY_PREFIX . $screen->taxonomy;
304
+ if ( $wpddlayout->layout_post_loop_cell_manager->get_option( $option_type_name ) ) {
305
+ $layout_id = (int) $wpddlayout->layout_post_loop_cell_manager->get_option( $option_type_name );
306
+ }
307
+
308
+ } else if( 'post' === $screen->base ) {
309
+ // $post_type | page
310
+
311
+ // Individual
312
+ $layout_slug = get_post_meta( (int) $_GET['post'], WPDDL_LAYOUTS_META_KEY, true );
313
+ if( ! empty( $layout_slug ) ) {
314
+ $layout_id = WPDD_Layouts::get_layout_id_by_slug( $layout_slug );
315
+
316
+ }
317
+
318
+ // Multiple
319
+ if( (int) $layout_id == 0 ) {
320
+ $layout_object = $wpddlayout->post_types_manager->get_layout_to_type_object( $type );
321
+ $layout_id = $layout_object && property_exists( $layout_object, 'layout_id' ) && $layout_object->layout_id > 0
322
+ ? $layout_object->layout_id
323
+ : 0;
324
+ }
325
+
326
+ }
327
+
328
+ }
329
+ */
330
+
331
+ } else if ( (int) $wpddlayout->get_rendered_layout_id() > 0 ) {
332
+
333
+ $layout_id = $wpddlayout->get_rendered_layout_id();
334
+
335
+ }
336
+
337
+ $is_new = $layout_id > 0 ? false : true;
338
+ $plugin_used = ! $is_new ? 'layouts' : $plugin_used;
339
+
340
+ }
341
+
342
+ // Views - Edit Link
343
+ if ( $is_new && $this->is_views_available() ) {
344
+
345
+ global $WPV_settings;
346
+
347
+ if( is_admin() ) {
348
+
349
+ /*
350
+ // Same as Layouts
351
+ $screen = get_current_screen();
352
+ if( preg_match( '/^(edit|edit-tags|post)$/', $screen->base ) ) {
353
+ // Exists layout? $layout_id?
354
+
355
+ if( 'edit' === $screen->base ) {
356
+ // $post_type | archive
357
+
358
+ if ( isset( $WPV_settings['view_cpt_' . $type] ) && $WPV_settings['views_template_for_' . $type] > 0 ) {
359
+ $wpa_id = $WPV_settings['view_cpt_' . $type];
360
+ }
361
+
362
+ } else if( 'edit-tags' === $screen->base ) {
363
+ // $taxonomy | archive
364
+
365
+ if ( isset( $WPV_settings['view_taxonomy_loop_' . $type] ) && $WPV_settings['view_taxonomy_loop_' . $type] > 0 ) {
366
+ $wpa_id = $WPV_settings['view_taxonomy_loop_' . $type];
367
+ }
368
+
369
+ } else if( 'post' === $screen->base ) {
370
+ // $post_type | page
371
+
372
+ // Individual
373
+ if ( isset( $_GET['post'] ) && (int) $_GET['post'] > 0 ) {
374
+ $ct_id = (int) get_post_meta( (int) $_GET['post'], '_views_template', true );
375
+ }
376
+
377
+ // Multiple
378
+ if ( (int) $ct_id == 0
379
+ && isset( $WPV_settings['views_template_for_' . $type] )
380
+ && $WPV_settings['views_template_for_' . $type] > 0
381
+ ) {
382
+ $ct_id = $WPV_settings['views_template_for_' . $type];
383
+ }
384
+
385
+ }
386
+
387
+ }
388
+
389
+ if ( ( int ) $wpa_id > 0 || ( int ) $ct_id > 0 ) {
390
+ $is_new = false;
391
+ }
392
+ */
393
+ } else {
394
+
395
+ if ( 'archive' === $class && 'page' != $type ) {
396
+ /* WordPress Archive */
397
+
398
+ // WordPress Loop Archives
399
+ if( in_array( $type, self::$default_wordpress_archives )
400
+ && isset( $WPV_settings['view_'.$type.'-page'] )
401
+ && (int) $WPV_settings['view_'.$type.'-page'] > 0
402
+ ) {
403
+ $wpa_id = (int) $WPV_settings['view_'.$type.'-page'];
404
+ }
405
+
406
+ // Taxonomy Archive
407
+ if( ! $wpa_id ) {
408
+ $taxonomy = get_taxonomy( $type );
409
+ $is_tax = $taxonomy !== false;
410
+ if( $is_tax
411
+ && isset( $WPV_settings['view_taxonomy_loop_' . $type] )
412
+ && (int) $WPV_settings['view_taxonomy_loop_' . $type] > 0
413
+ ) {
414
+ $wpa_id = $WPV_settings['view_taxonomy_loop_' . $type];
415
+ }
416
+ }
417
+
418
+ // Post Type Archive
419
+ if( ! $wpa_id ) {
420
+ $post_type_object = get_post_type_object( $type );
421
+ $is_cpt = $post_type_object != null;
422
+ if( $is_cpt && isset( $WPV_settings['view_cpt_' . $type] )
423
+ && $WPV_settings['view_cpt_' . $type] > 0
424
+ ) {
425
+ $wpa_id = $WPV_settings['view_cpt_' . $type];
426
+ }
427
+ }
428
+
429
+ if ( (int) $wpa_id > 0 ) {
430
+ $is_new = false;
431
+ }
432
+
433
+ } else if( 'page' === $class && ! is_404() ) {
434
+ /* Content Template */
435
+
436
+ // Individual
437
+ $ct_id = (int) get_post_meta( get_the_ID(), '_views_template', true );
438
+
439
+ // Multiple
440
+ if( (int) $ct_id == 0 ) {
441
+
442
+ // This doesn't satisfies expectations.
443
+ // You cannot edit content templates you're not seeing, even if they're assigned to the current post type.
444
+ // FIXME: Define the right behavior.
445
+ // My proposal: if there is a CT assigned to post type, suggest "bind this and edit template" or similar approach
446
+
447
+ /*
448
+ if( isset( $WPV_settings['views_template_for_'.$type] ) && $WPV_settings['views_template_for_'.$type] > 0 ) {
449
+ $ct_id = $WPV_settings['views_template_for_'.$type];
450
+ }
451
+ */
452
+ }
453
+
454
+ if ( (int) $ct_id > 0 ) {
455
+ $is_new = false;
456
+ }
457
+
458
+ }
459
+
460
+ }
461
+
462
+ $plugin_used = ! $is_new ? 'views' : $plugin_used;
463
+
464
+ }
465
+
466
+ // $plugin_used - Create Link
467
+ if ( $is_new ) {
468
+ if( is_admin() ) {
469
+
470
+ /*
471
+ $screen = get_current_screen();
472
+ if( $screen->id == 'post' ) {
473
+ $post_id = (int) $_GET['post'];
474
+ }
475
+ */
476
+
477
+ } else {
478
+ $post_id = get_the_ID();
479
+ }
480
+ }
481
+
482
+ $title = $this->get_title ( $plugin_used, $is_new, $type, $class, max( array( $layout_id, $ct_id, $wpa_id, $post_id ) ) );
483
+ $edit_link = $this->get_edit_link( $plugin_used, $is_new, $type, $class, max( array( $layout_id, $ct_id, $wpa_id, $post_id ) ) );
484
+
485
+ if ( $edit_link !== null ) {
486
+ return array( $title, $edit_link );
487
+ } else {
488
+ // No valid data => No menu
489
+ return null;
490
+ }
491
+ }
492
+
493
+ /**
494
+ * Returns an string with the context where the link is going to be display
495
+ * It is going to be like "post_type|archive" or null if link should not be displayed
496
+ * @return string {post_type or archive_type or taxonomy or 404}|{page or archive}
497
+ */
498
+ private function get_context() {
499
+
500
+ // Rule of thumb: if there is a list of posts, it is an archive
501
+
502
+ // null means we will not show the link
503
+ $context = null;
504
+
505
+ if ( is_admin() ) {
506
+
507
+ /*
508
+ // There are less places inside the admin to define Layouts/Templates
509
+
510
+ global $post_type;
511
+
512
+ $screen = get_current_screen();
513
+
514
+ if ( $screen->base == 'edit' && $post_type !== 'page' ) {
515
+ // list of posts page => create an archive ( WordPress Archive )
516
+ return "$post_type|archive";
517
+ } else if ( $screen->base == 'post' && empty( $screen->action ) ) {
518
+ // post editor page => create a page ( Content Template )
519
+ return "$post_type|page";
520
+ } else if ( $screen->base == 'edit-tags' ) {
521
+ // taxonomy page => always an archive ( WordPress Archive )
522
+ return "{$screen->taxonomy}|archive";
523
+ }
524
+ */
525
+
526
+ } else {
527
+
528
+ global $post, $wp_query;
529
+
530
+ if ( is_home() ) {
531
+ // Blog posts index
532
+ $context = 'home-blog|archive';
533
+ } else if ( is_search() ) {
534
+ $context = 'search|archive';
535
+ } else if ( is_author() ) {
536
+ $context = 'author|archive';
537
+ } else if ( is_year() ) {
538
+ $context = 'year|archive';
539
+ } else if ( is_month() ) {
540
+ $context = 'month|archive';
541
+ } else if ( is_day() ) {
542
+ $context = 'day|archive';
543
+ } else if ( is_category() ) {
544
+ $context = 'category|archive';
545
+ } else if ( is_tag() ) {
546
+ $context = 'post_tag|archive';
547
+ } else if ( is_tax() ) {
548
+ $term = $wp_query->get_queried_object();
549
+ if (
550
+ $term
551
+ && isset( $term->taxonomy )
552
+ ) {
553
+ $context = $term->taxonomy . '|archive';
554
+ }
555
+ } else if ( is_post_type_archive() ) {
556
+ $post_type = $wp_query->get('post_type');
557
+ if ( is_array( $post_type ) ) {
558
+ $post_type = reset( $post_type );
559
+ }
560
+ $context = $post_type . '|archive';
561
+ } else if ( is_404() ) {
562
+ // Special WordPress Error 404 Page
563
+ $context = '404|page';
564
+ } else if ( is_object( $post ) && get_class( $post ) === 'WP_Post' ) {
565
+ $context = get_post_type() . '|page';
566
+ }
567
+
568
+ }
569
+
570
+ return $context;
571
+ }
572
+
573
+ /**
574
+ * Get title for menu subitem
575
+ * @param string $plugin are we using 'layouts' or 'views'?
576
+ * @param boolean $is_new are we creating a new object?
577
+ * @param string $type post_type, taxonomy or wp slug
578
+ * @param string $class (single) page or archive
579
+ * @param int $post_id must be layout or template id if !$is_new, else post
580
+ * @return string title for menu subitem
581
+ */
582
+ private function get_title( $plugin, $is_new, $type, $class, $post_id = null) {
583
+
584
+ if ( $is_new ) {
585
+ /* Create */
586
+ // "Create a new 'Layout for Restaurant archives'"
587
+ // "Create a new 'Content Template for Restaurants'"
588
+ // "Create a new 'WordPress Archive for Restaurant archives'"
589
+
590
+ $create_a_new = __( 'Create a new', 'wpv-views' );
591
+ $object = $this->get_name_auto( $plugin, $type, $class, $post_id );
592
+
593
+ return trim( sprintf( '%s %s', $create_a_new, $object ) );
594
+
595
+ } else {
596
+ /* Edit */
597
+ // "Edit 'Restaurants' Layout"
598
+ // "Edit 'Layout for Restaurants' Layout" => "Edit 'Layout for Restaurants'"
599
+ // "Edit 'Layout for Restaurant archives' Layout" => "Edit 'Layout for Restaurant' archives"
600
+
601
+ $edit = __( 'Edit', 'wpv-views' );
602
+
603
+ // Layout or Content Template or WordPress Archive
604
+ $layouts = __( 'Layout', 'wpv-views' );
605
+ $views = 'archive' === $class ? __( 'Archive', 'wpv-views' ) : __( 'Template', 'wpv-views' );
606
+ $artifact = 'layouts' === $plugin ? $layouts : $views;
607
+
608
+ // avoid "'Layout for Restaurant archives' Layout"
609
+ // get "'Layout for Restaurants'" instead
610
+ $post_title = get_the_title( $post_id );
611
+ $object = strpos( $post_title, $artifact ) === false ? sprintf( '%s %s', $post_title, $artifact ) : $post_title;
612
+
613
+ return trim( sprintf( '%s %s', $edit, $object ) );
614
+
615
+ }
616
+
617
+ }
618
+
619
+ /**
620
+ * Get a valid and self-defining title for a Layout, Content Template or WordPress Archive
621
+ *
622
+ * @param string $plugin layouts or views
623
+ * @param string $type post_type, taxonomy or wp slug
624
+ * @param string $class page or archive
625
+ * @param int|null $post_id
626
+ *
627
+ * @return string
628
+ *
629
+ * @since unknown
630
+ */
631
+ public function get_name_auto( $plugin, $type, $class, $post_id = null ) {
632
+ // Examples:
633
+ // Layout for Restaurants
634
+ // Layout for Restaurant archives
635
+ // Content Template for Restaurants
636
+ // WordPress Archive for Restaurants
637
+
638
+ /* Layout or Content Template or WordPress Archive */
639
+ $layouts = __( 'Layout', 'wpv-views' );
640
+ $views = 'archive' === $class ? __( 'Archive', 'wpv-views' ) : __( 'Template', 'wpv-views' );
641
+ $artifact = 'layouts' === $plugin ? $layouts : $views;
642
+
643
+ /* for */
644
+ $for = __( 'for', 'wpv-views' );
645
+
646
+ /* selection */
647
+ $selection = '';
648
+
649
+ if ( 'page' === $class && '404' === $type && 'layouts' === $plugin ) {
650
+ $selection = __( 'Error 404 page', 'wpv-views' );
651
+ } else if ( 'page' === $type ) {
652
+ $selection = get_the_title( $post_id );
653
+ } else if ( 'page' === $class ) {
654
+ $post_type = get_post_type_object( $type );
655
+ $selection = ucfirst( $post_type->label );
656
+ } else if ( 'archive' === $class && in_array( $type, self::$default_wordpress_archives ) ) {
657
+ $selection = sprintf( '%s %s', ucfirst( $type ), __( 'Archives', 'wpv-views' ) );
658
+ /*
659
+ } else if ( 'archive' === $class && preg_match( '/^(category|post_tag)$/', $type ) ) {
660
+ $taxonomy = get_taxonomy( $type );
661
+ $selection = 'layouts' === $plugin ? sprintf( '%s %s', ucfirst( $taxonomy->labels->singular_name ), __( 'Archives', 'wpv-views' ) ) : ucfirst( $taxonomy->labels->name );
662
+ */
663
+ } else if ( 'archive' === $class ) {
664
+ $post_type = get_post_type_object( $type );
665
+ $is_cpt = $post_type != null;
666
+
667
+ $taxonomy = get_taxonomy( $type );
668
+ $is_tax = $taxonomy !== false;
669
+
670
+ if ( $is_cpt ) {
671
+ $selection = 'layouts' === $plugin ? sprintf( '%s %s', ucfirst( $post_type->labels->singular_name ), __( 'Archives', 'wpv-views' ) ) : ucfirst( $post_type->labels->name );
672
+ } else if ( $is_tax ) {
673
+ $selection = 'layouts' === $plugin ? sprintf( '%s %s', ucfirst( $taxonomy->labels->singular_name ), __( 'Archives', 'wpv-views' ) ) : ucfirst( $taxonomy->labels->name );
674
+ } else {
675
+ $selection = __( 'Unsupported post type archives', 'wpv-views' );
676
+ }
677
+
678
+ } else {
679
+ $selection = __( 'Unsupported page', 'wpv-views' );
680
+ }
681
+
682
+ return trim( sprintf( '%s %s %s', $artifact, $for, $selection ) );
683
+ }
684
+
685
+ public function get_edit_link( $plugin, $is_new, $type, $class, $post_id = null ) {
686
+ $edit_link = null;
687
+
688
+ if( 'layouts' === $plugin ) {
689
+
690
+ if( $is_new && WPDD_Layouts_Users_Profiles::user_can_create() && WPDD_Layouts_Users_Profiles::user_can_assign() ) {
691
+ $edit_link = wp_nonce_url( admin_url( sprintf( 'admin.php?page=dd_layouts_create_auto&type=%s&class=%s&post=%s', $type, $class, $post_id ) ), 'create_auto' );
692
+ } else if( $post_id > 0 && WPDD_Layouts_Users_Profiles::user_can_edit() ) {
693
+ // Layouts editor
694
+ $edit_link = admin_url( sprintf( 'admin.php?page=dd_layouts_edit&layout_id=%s&action=edit', $post_id ) );
695
+ }
696
+
697
+ } else if ( 'views' === $plugin && '404' != $type /* No support for Error 404 page */ ) {
698
+
699
+ if ( $is_new ) {
700
+ $edit_link = wp_nonce_url( admin_url( sprintf( 'admin.php?page=views_create_auto&type=%s&class=%s&post=%s', $type, $class, $post_id ) ), 'create_auto' );
701
+ } else if( $post_id > 0 ) {
702
+
703
+ if( 'archive' === $class ) {
704
+ // Views' WordPress Archive editor
705
+ $edit_link = admin_url( sprintf( 'admin.php?page=view-archives-editor&view_id=%s', $post_id ) );
706
+ } else if( 'page' === $class ) {
707
+ // Views' Content Temaplate editor
708
+ //$edit_link = admin_url( sprintf( 'post.php?action=edit&post=%s', $post_id ) );
709
+ $edit_link = esc_url_raw(
710
+ add_query_arg(
711
+ array( 'page' => WPV_CT_EDITOR_PAGE_NAME, 'ct_id' => esc_attr( $post_id ), 'action' => 'edit' ),
712
+ admin_url( 'admin.php' )
713
+ )
714
+ );
715
+ }
716
+
717
+ }
718
+ }
719
+
720
+ return $edit_link;
721
+ }
722
+
723
+ }
724
+
725
+ // We have checked if @class Toolset_Admin_Bar_Menu already existed.
726
+ // After that, we've defined the class. Now, we instantiate it once.
727
+ // This works lìke a singleton.
728
+ // But the class itself is also a singleton. Using design patterns
729
+ // clarifies and prevents against changes in future.
730
+ global $toolset_admin_bar_menu;
731
+ $toolset_admin_bar_menu = Toolset_Admin_Bar_Menu::get_instance();
732
+ }
embedded/common/classes/class.toolset.promo.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ *
6
+ */
7
+
8
+ if (!class_exists('Toolset_Promotion')) {
9
+
10
+ /**
11
+ * Class to show promotion message.
12
+ *
13
+ * @since 1.5
14
+ * @access public
15
+ */
16
+ class Toolset_Promotion
17
+ {
18
+ private $version = '1.0';
19
+
20
+ public function __construct()
21
+ {
22
+ add_action('admin_init', array($this, 'admin_init'));
23
+ add_action('admin_footer', array($this, 'admin_footer'));
24
+ add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
25
+ add_action('plugins_loaded', 'on_the_go_systems_branding_plugins_loaded');
26
+ }
27
+
28
+ /**
29
+ * Register script and styles
30
+ *
31
+ * Register script and styles for future usage.
32
+ *
33
+ * @since 1.5
34
+ *
35
+ */
36
+ public function admin_init()
37
+ {
38
+ wp_register_script(
39
+ 'toolset-colorbox',
40
+ plugins_url('/res/js/jquery.colorbox-min.js', dirname(__FILE__)),
41
+ array('jquery'),
42
+ '1.4.31'
43
+ );
44
+ wp_register_script(
45
+ __CLASS__,
46
+ plugins_url('/res/js/toolset-promotion.js', dirname(__FILE__)),
47
+ array('underscore', 'toolset-colorbox'),
48
+ $this->version,
49
+ true
50
+ );
51
+ wp_register_style(
52
+ 'toolset-colorbox',
53
+ plugins_url('/res/css/colorbox.css', dirname(__FILE__)),
54
+ false,
55
+ '1.4.31'
56
+ );
57
+ wp_register_style(
58
+ __CLASS__,
59
+ plugins_url('/res/css/toolset-promotion.css', dirname(__FILE__)),
60
+ array('toolset-colorbox', 'onthego-admin-styles'),
61
+ $this->version
62
+ );
63
+ }
64
+
65
+ /**
66
+ * Enqueue scripts & styles
67
+ *
68
+ * After check is a correct place, this function enqueue scripts & styles
69
+ * for toolset promotion box.
70
+ *
71
+ * @since 1.5
72
+ *
73
+ */
74
+ public function admin_enqueue_scripts()
75
+ {
76
+ if (!is_admin() || !function_exists('get_current_screen')) {
77
+ return;
78
+ }
79
+ /**
80
+ * List of admin page id
81
+ *
82
+ * Filter allow to add or change list of admin screen id for checking
83
+ * where we need enqueue toolset promotion assets.
84
+ *
85
+ * @since 1.5
86
+ *
87
+ * @param array $screen_ids List of admin page screen ids.
88
+ *
89
+ */
90
+ $screen_ids = apply_filters('toolset_promotion_screen_ids', array());
91
+ if (empty($screen_ids)) {
92
+ return;
93
+ }
94
+ $screen = get_current_screen();
95
+ if (!in_array($screen->id, $screen_ids)) {
96
+ return;
97
+ }
98
+ wp_enqueue_style(__CLASS__);
99
+ wp_enqueue_script(__CLASS__);
100
+ }
101
+
102
+ /**
103
+ * Print in footer
104
+ *
105
+ * Print nessary elemnt in admin footer
106
+ *
107
+ * @since 1.5
108
+ *
109
+ */
110
+ public function admin_footer()
111
+ {
112
+ $link_learn = $this->get_affiliate_link_string('http://wp-types.com/');
113
+ $link_button = $this->get_affiliate_link_string('http://wp-types.com/#buy-toolset');
114
+
115
+ ob_start();
116
+ ?>
117
+
118
+ <div class="ddl-dialogs-container">
119
+ <div id="js-buy-toolset-embedded-message-wrap"></div>
120
+ </div>
121
+ <script type="text/html" id="js-buy-toolset-embedded-message">
122
+ <div class="toolset-modal">
123
+ <h2><?php _e('Want to edit Views, CRED forms and Layouts? Get the full <em>Toolset</em> package!', 'wpcf'); ?></h2>
124
+
125
+ <div class="content">
126
+ <p class="full"><?php _e('The full <em>Toolset</em> package allows you to develop and customize themes without touching PHP. You will be able to:', 'wpcf'); ?></p>
127
+
128
+ <div class="icons">
129
+ <ul>
130
+ <li class="template"><?php _e('Create templates', 'wpcf'); ?></li>
131
+ <li class="layout"><?php _e('Design page layouts using drag-and-drop', 'wpcf'); ?></li>
132
+ <li class="toolset-search"><?php _e('Build parametric searches', 'wpcf'); ?></li>
133
+ </ul>
134
+ <ul>
135
+ <li class="list"><?php _e('Display lists of content', 'wpcf'); ?></li>
136
+ <li class="form"><?php _e('Create front-end content editing forms', 'wpcf'); ?></li>
137
+ <li class="more"><?php _e('and more…', 'wpcf'); ?></li>
138
+ </ul>
139
+ </div>
140
+
141
+ <p class="description"><?php _e('Once you buy the full Toolset, you will be able to edit Views, CRED forms and Layouts in your site, as well as build new ones.', 'wpcf'); ?></p>
142
+
143
+ <a href="<?php echo $link_button; ?>"
144
+ class="button"><?php _e('<em>Toolset</em> Package Options', 'wpcf'); ?></a>
145
+ <a href="<?php echo $link_learn; ?>"
146
+ class="learn"><?php _e('Learn more about <em>Toolset</em>', 'wpcf'); ?></a>
147
+
148
+ </div>
149
+ <span class="icon-toolset-logo"></span>
150
+ <span class="js-close-promotional-message"></span>
151
+ </div>
152
+ </script>
153
+ <?php
154
+ echo ob_get_clean();
155
+ }
156
+
157
+ private function get_affiliate_link_string($link)
158
+ {
159
+ if (function_exists('installer_ep_get_configuration') === false) {
160
+ return $link;
161
+ }
162
+
163
+ $info = installer_ep_get_configuration(wp_get_theme()->Name);
164
+
165
+ if (!isset($info['repositories']) &&
166
+ !isset($info['repositories']['toolset'])
167
+ ) {
168
+ return $link;
169
+
170
+ } else if (
171
+ isset($info['repositories']['toolset']['affiliate_id']) &&
172
+ isset($info['repositories']['toolset']['affiliate_key'])
173
+ ) {
174
+ $id = $info['repositories']['toolset']['affiliate_id'];
175
+ $key = $info['repositories']['toolset']['affiliate_key'];
176
+
177
+ $hash = explode( '#', $link );
178
+ if( count($hash) > 1 ){
179
+ $link = $hash[0];
180
+ $hash = "#" . $hash[1];
181
+ } else {
182
+ $hash = '';
183
+ }
184
+
185
+ return sprintf("%s?aid=%s&affiliate_key=%s%s", $link, $id, $key, $hash);
186
+ }
187
+
188
+ return $link;
189
+ }
190
+
191
+ }
192
+
193
+ }
embedded/common/classes/forms.php CHANGED
@@ -2,15 +2,11 @@
2
  /**
3
  * Returns HTML formatted output for elements and handles form submission.
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/classes/forms.php $
6
- * $LastChangedDate: 2014-05-29 08:44:10 +0000 (Thu, 29 May 2014) $
7
- * $LastChangedRevision: 922956 $
8
- * $LastChangedBy: iworks $
9
  *
10
  * @version 1.0
11
  */
12
- if (!class_exists('Enlimbo_Forms_Wpcf')) {
13
-
14
  class Enlimbo_Forms_Wpcf
15
  {
16
 
@@ -323,7 +319,7 @@ if (!class_exists('Enlimbo_Forms_Wpcf')) {
323
  continue;
324
  }
325
  // Don't set disabled for checkbox
326
- if ($attribute == 'disabled' && $element['#type'] == 'checkbox') {
327
  continue;
328
  }
329
  // Append class values
@@ -368,10 +364,15 @@ if (!class_exists('Enlimbo_Forms_Wpcf')) {
368
  if ( isset( $element['#labelclass'] ) ) {
369
  $labelclass = $element['#labelclass'] . ' ';
370
  }
 
 
 
 
371
  $element['_render']['label'] = isset($element['#title']) ? '<label class="'
372
  . $labelclass
373
  . $this->css_class . '-label ' . $this->css_class . '-'
374
- . $element['#type'] . '-label" for="' . $element['#id'] . '">'
 
375
  . stripslashes($element['#title'])
376
  . '</label>' . "\r\n" : '';
377
  $element['_render']['title'] = $this->_setElementTitle($element);
@@ -583,7 +584,7 @@ if (!class_exists('Enlimbo_Forms_Wpcf')) {
583
  $element['_render']['element'] .= ' onclick="javascript:return false; if(this.checked == 1){this.checked=1; return true;}else{this.checked=0; return false;}"';
584
  }
585
  if (!empty($element['#attributes']['#disabled'])) {
586
- $element['_render']['element'] .= ' disabled="disabled""';
587
  }
588
 
589
  $element['_render']['element'] .= ' />';
@@ -932,8 +933,10 @@ if (!class_exists('Enlimbo_Forms_Wpcf')) {
932
  }
933
 
934
  $parts = explode('[', $name);
935
- $parts = array_map(create_function('&$a', 'return trim($a, \']\');'),
936
- $parts);
 
 
937
  if (!isset($_REQUEST[$parts[0]])) {
938
  return in_array($element['#type'],
939
  array('textfield', 'textarea')) ? '' : 0;
2
  /**
3
  * Returns HTML formatted output for elements and handles form submission.
4
  *
 
 
 
 
5
  *
6
  * @version 1.0
7
  */
8
+ if (!class_exists('Enlimbo_Forms_Wpcf')) {
9
+
10
  class Enlimbo_Forms_Wpcf
11
  {
12
 
319
  continue;
320
  }
321
  // Don't set disabled for checkbox
322
+ if ( ( 'disabled' == $attribute || '#disabled' == $attribute ) && $element['#type'] == 'checkbox') {
323
  continue;
324
  }
325
  // Append class values
364
  if ( isset( $element['#labelclass'] ) ) {
365
  $labelclass = $element['#labelclass'] . ' ';
366
  }
367
+ $labelstyle = '';
368
+ if ( isset( $element['#labelstyle'] ) ) {
369
+ $labelstyle = ' style="' . $element['#labelstyle'] . '" ';
370
+ }
371
  $element['_render']['label'] = isset($element['#title']) ? '<label class="'
372
  . $labelclass
373
  . $this->css_class . '-label ' . $this->css_class . '-'
374
+ . $element['#type'] . '-label" for="' . $element['#id'] . '"'.
375
+ $labelstyle . '>'
376
  . stripslashes($element['#title'])
377
  . '</label>' . "\r\n" : '';
378
  $element['_render']['title'] = $this->_setElementTitle($element);
584
  $element['_render']['element'] .= ' onclick="javascript:return false; if(this.checked == 1){this.checked=1; return true;}else{this.checked=0; return false;}"';
585
  }
586
  if (!empty($element['#attributes']['#disabled'])) {
587
+ $element['_render']['element'] .= ' disabled="disabled"';
588
  }
589
 
590
  $element['_render']['element'] .= ' />';
933
  }
934
 
935
  $parts = explode('[', $name);
936
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196173458/comments
937
+ //Security Fixing
938
+ //$parts = array_map(create function('&$a', 'return trim($a, \']\');'), $parts);
939
+ $parts = array_map("cred_mytrimfunction", $parts);
940
  if (!isset($_REQUEST[$parts[0]])) {
941
  return in_array($element['#type'],
942
  array('textfield', 'textarea')) ? '' : 0;
embedded/common/classes/validation-cakephp.php CHANGED
@@ -29,1098 +29,1111 @@
29
  * @since CakePHP v 1.2.0.3830
30
  */
31
  //class Validation extends Object {
32
- if(!class_exists('Wpcf_Cake_Validation')) {
33
- class Wpcf_Cake_Validation
34
- {
35
-
36
- /**
37
- * Set the value of methods $check param.
38
- *
39
- * @var string
40
- * @access public
41
- */
42
- var $check = null;
43
-
44
- /**
45
- * Set to a valid regular expression in the class methods.
46
- * Can be set from $regex param also
47
- *
48
- * @var string
49
- * @access public
50
- */
51
- var $regex = null;
52
-
53
- /**
54
- * Some complex patterns needed in multiple places
55
- *
56
- * @var array
57
- * @access private
58
- */
59
- var $__pattern = array(
60
- 'hostname' => '(?:[a-z0-9][-a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,4}|museum|travel)'
61
- );
62
-
63
- /**
64
- * Some class methods use a country to determine proper validation.
65
- * This can be passed to methods in the $country param
66
- *
67
- * @var string
68
- * @access public
69
- */
70
- var $country = null;
71
-
72
- /**
73
- * Some class methods use a deeper validation when set to true
74
- *
75
- * @var string
76
- * @access public
77
- */
78
- var $deep = null;
79
-
80
- /**
81
- * Some class methods use the $type param to determine which validation to perfom in the method
82
- *
83
- * @var string
84
- * @access public
85
- */
86
- var $type = null;
87
-
88
- /**
89
- * Holds an array of errors messages set in this class.
90
- * These are used for debugging purposes
91
- *
92
- * @var array
93
- * @access public
94
- */
95
- var $errors = array();
96
-
97
- /**
98
- * Gets a reference to the Validation object instance
99
- *
100
- * @return object Validation instance
101
- * @access public
102
- * @static
103
- */
104
- function &getInstance() {
105
- static $instance = array();
106
-
107
- if (!$instance) {
108
- $instance[0] = new Wpcf_Cake_Validation();
109
- }
110
- return $instance[0];
111
- }
112
-
113
- /**
114
- * Checks that a string contains something other than whitespace
115
- *
116
- * Returns true if string contains something other than whitespace
117
- *
118
- * $check can be passed as an array:
119
- * array('check' => 'valueToCheck');
120
- *
121
- * @param mixed $check Value to check
122
- * @return boolean Success
123
- * @access public
124
- */
125
- function notEmpty($check) {
126
- $_this = & Wpcf_Cake_Validation::getInstance();
127
- $_this->__reset();
128
- $_this->check = $check;
129
-
130
- if (is_array($check)) {
131
- $_this->_extract($check);
132
- }
133
-
134
- if (empty($_this->check) && $_this->check != '0') {
135
- return false;
136
- }
137
- $_this->regex = '/[^\s]+/m';
138
- return $_this->_check();
139
- }
140
-
141
- /**
142
- * Checks that a string contains only integer or letters
143
- *
144
- * Returns true if string contains only integer or letters
145
- *
146
- * $check can be passed as an array:
147
- * array('check' => 'valueToCheck');
148
- *
149
- * @param mixed $check Value to check
150
- * @return boolean Success
151
- * @access public
152
- */
153
- function alphaNumeric($check) {
154
- $_this = & Wpcf_Cake_Validation::getInstance();
155
- $_this->__reset();
156
- $_this->check = $check;
157
-
158
- if (is_array($check)) {
159
- $_this->_extract($check);
160
- }
161
-
162
- if (empty($_this->check) && $_this->check != '0') {
163
- return false;
164
- }
165
- $_this->regex = '/^[a-zA-Z0-9]*$/mu';
166
- $return = $_this->_check();
167
-
168
- if (!$return) {
169
- $_this->regex = '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/mu';
170
- $return = $_this->_check();
171
- }
172
-
173
- return $_this->_check();
174
- }
175
-
176
- function alphaNumericWhitespaces($check) {
177
- $_this = & Wpcf_Cake_Validation::getInstance();
178
- $_this->__reset();
179
- $_this->check = $check;
180
-
181
- if (is_array($check)) {
182
- $_this->_extract($check);
183
- }
184
-
185
- if (empty($_this->check) && $_this->check != '0') {
186
- return false;
187
- }
188
- $_this->regex = '/^[a-zA-Z0-9\s\-\_]*$/mu';
189
- $return = $_this->_check();
190
-
191
- if (!$return) {
192
- $_this->regex = '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}\s\-\_]+$/mu';
193
- $return = $_this->_check();
194
- }
195
-
196
- return $return;
197
- }
198
-
199
- /**
200
- * Checks that a string length is within s specified range.
201
- * Spaces are included in the character count.
202
- * Returns true is string matches value min, max, or between min and max,
203
- *
204
- * @param string $check Value to check for length
205
- * @param integer $min Minimum value in range (inclusive)
206
- * @param integer $max Maximum value in range (inclusive)
207
- * @return boolean Success
208
- * @access public
209
- */
210
- function between($check, $min, $max) {
211
- $length = strlen($check);
212
- return ($length >= $min && $length <= $max);
213
- }
214
-
215
- /**
216
- * Returns true if field is left blank -OR- only whitespace characters are present in it's value
217
- * Whitespace characters include Space, Tab, Carriage Return, Newline
218
- *
219
- * $check can be passed as an array:
220
- * array('check' => 'valueToCheck');
221
- *
222
- * @param mixed $check Value to check
223
- * @return boolean Success
224
- * @access public
225
- */
226
- function blank($check) {
227
- $_this = & Wpcf_Cake_Validation::getInstance();
228
- $_this->__reset();
229
- $_this->check = $check;
230
-
231
- if (is_array($check)) {
232
- $_this->_extract($check);
233
- }
234
-
235
- $_this->regex = '/[^\\s]/';
236
- return!$_this->_check();
237
- }
238
-
239
- /**
240
- * Validation of credit card numbers.
241
- * Returns true if $check is in the proper credit card format.
242
- *
243
- * @param mixed $check credit card number to validate
244
- * @param mixed $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit cards
245
- * if an array is used only the values of the array are checked.
246
- * Example: array('amex', 'bankcard', 'maestro')
247
- * @param boolean $deep set to true this will check the Luhn algorithm of the credit card.
248
- * @param string $regex A custom regex can also be passed, this will be used instead of the defined regex values
249
- * @return boolean Success
250
- * @access public
251
- * @see Wpcf_Cake_Validation::_luhn()
252
- */
253
- function cc($check, $type = 'fast', $deep = false, $regex = null) {
254
- $_this = & Wpcf_Cake_Validation::getInstance();
255
- $_this->__reset();
256
- $_this->check = $check;
257
- $_this->type = $type;
258
- $_this->deep = $deep;
259
- $_this->regex = $regex;
260
-
261
- if (is_array($check)) {
262
- $_this->_extract($check);
263
- }
264
- $_this->check = str_replace(array('-', ' '), '', $_this->check);
265
-
266
- if (strlen($_this->check) < 13) {
267
- return false;
268
- }
269
-
270
- if (!is_null($_this->regex)) {
271
- if ($_this->_check()) {
272
- return $_this->_luhn();
273
- }
274
- }
275
- $cards = array(
276
- 'all' => array(
277
- 'amex' => '/^3[4|7]\\d{13}$/',
278
- 'bankcard' => '/^56(10\\d\\d|022[1-5])\\d{10}$/',
279
- 'diners' => '/^(?:3(0[0-5]|[68]\\d)\\d{11})|(?:5[1-5]\\d{14})$/',
280
- 'disc' => '/^(?:6011|650\\d)\\d{12}$/',
281
- 'electron' => '/^(?:417500|4917\\d{2}|4913\\d{2})\\d{10}$/',
282
- 'enroute' => '/^2(?:014|149)\\d{11}$/',
283
- 'jcb' => '/^(3\\d{4}|2100|1800)\\d{11}$/',
284
- 'maestro' => '/^(?:5020|6\\d{3})\\d{12}$/',
285
- 'mc' => '/^5[1-5]\\d{14}$/',
286
- 'solo' => '/^(6334[5-9][0-9]|6767[0-9]{2})\\d{10}(\\d{2,3})?$/',
287
- 'switch' => '/^(?:49(03(0[2-9]|3[5-9])|11(0[1-2]|7[4-9]|8[1-2])|36[0-9]{2})\\d{10}(\\d{2,3})?)|(?:564182\\d{10}(\\d{2,3})?)|(6(3(33[0-4][0-9])|759[0-9]{2})\\d{10}(\\d{2,3})?)$/',
288
- 'visa' => '/^4\\d{12}(\\d{3})?$/',
289
- 'voyager' => '/^8699[0-9]{11}$/'
290
- ),
291
- 'fast' => '/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$/'
292
- );
293
-
294
- if (is_array($_this->type)) {
295
- foreach ($_this->type as $value) {
296
- $_this->regex = $cards['all'][strtolower($value)];
297
-
298
- if ($_this->_check()) {
299
- return $_this->_luhn();
300
- }
301
- }
302
- } elseif ($_this->type == 'all') {
303
- foreach ($cards['all'] as $value) {
304
- $_this->regex = $value;
305
-
306
- if ($_this->_check()) {
307
- return $_this->_luhn();
308
- }
309
- }
310
- } else {
311
- $_this->regex = $cards['fast'];
312
-
313
- if ($_this->_check()) {
314
- return $_this->_luhn();
315
- }
316
- }
317
- }
318
-
319
- /**
320
- * Used to compare 2 numeric values.
321
- *
322
- * @param mixed $check1 if string is passed for a string must also be passed for $check2
323
- * used as an array it must be passed as array('check1' => value, 'operator' => 'value', 'check2' -> value)
324
- * @param string $operator Can be either a word or operand
325
- * is greater >, is less <, greater or equal >=
326
- * less or equal <=, is less <, equal to ==, not equal !=
327
- * @param integer $check2 only needed if $check1 is a string
328
- * @return boolean Success
329
- * @access public
330
- */
331
- function comparison($check1, $operator = null, $check2 = null) {
332
- if (is_array($check1)) {
333
- extract($check1, EXTR_OVERWRITE);
334
- }
335
- $operator = str_replace(array(' ', "\t", "\n", "\r", "\0", "\x0B"), '',
336
- strtolower($operator));
337
-
338
- switch ($operator) {
339
- case 'isgreater':
340
- case '>':
341
- if ($check1 > $check2) {
342
- return true;
343
- }
344
- break;
345
- case 'isless':
346
- case '<':
347
- if ($check1 < $check2) {
348
- return true;
349
- }
350
- break;
351
- case 'greaterorequal':
352
- case '>=':
353
- if ($check1 >= $check2) {
354
- return true;
355
- }
356
- break;
357
- case 'lessorequal':
358
- case '<=':
359
- if ($check1 <= $check2) {
360
- return true;
361
- }
362
- break;
363
- case 'equalto':
364
- case '==':
365
- if ($check1 == $check2) {
366
- return true;
367
- }
368
- break;
369
- case 'notequal':
370
- case '!=':
371
- if ($check1 != $check2) {
372
- return true;
373
- }
374
- break;
375
- default:
376
- $_this = & Wpcf_Cake_Validation::getInstance();
377
- $_this->errors[] = __('You must define the $operator parameter for Wpcf_Cake_Validation::comparison()',
378
- 'wpcf');
379
- break;
380
- }
381
- return false;
382
- }
383
-
384
- /**
385
- * Used when a custom regular expression is needed.
386
- *
387
- * @param mixed $check When used as a string, $regex must also be a valid regular expression.
388
- * As and array: array('check' => value, 'regex' => 'valid regular expression')
389
- * @param string $regex If $check is passed as a string, $regex must also be set to valid regular expression
390
- * @return boolean Success
391
- * @access public
392
- */
393
- function custom($check, $regex = null) {
394
- $_this = & Wpcf_Cake_Validation::getInstance();
395
- $_this->__reset();
396
- $_this->check = $check;
397
- $_this->regex = $regex;
398
- if (is_array($check)) {
399
- $_this->_extract($check);
400
- }
401
- if ($_this->regex === null) {
402
- $_this->errors[] = __('You must define a regular expression for Wpcf_Cake_Validation::custom()',
403
- 'wpcf');
404
- return false;
405
- }
406
- return $_this->_check();
407
- }
408
-
409
- /**
410
- * Date validation, determines if the string passed is a valid date.
411
- * keys that expect full month, day and year will validate leap years
412
- *
413
- * @param string $check a valid date string
414
- * @param mixed $format Use a string or an array of the keys below. Arrays should be passed as array('dmy', 'mdy', etc)
415
- * Keys: dmy 27-12-2006 or 27-12-06 separators can be a space, period, dash, forward slash
416
- * mdy 12-27-2006 or 12-27-06 separators can be a space, period, dash, forward slash
417
- * ymd 2006-12-27 or 06-12-27 separators can be a space, period, dash, forward slash
418
- * dMy 27 December 2006 or 27 Dec 2006
419
- * Mdy December 27, 2006 or Dec 27, 2006 comma is optional
420
- * My December 2006 or Dec 2006
421
- * my 12/2006 separators can be a space, period, dash, forward slash
422
- * @param string $regex If a custom regular expression is used this is the only validation that will occur.
423
- * @return boolean Success
424
- * @access public
425
- */
426
- function date($check, $format = 'ymd', $regex = null) {
427
-
428
- $date_format = wpcf_get_date_format();
429
  $cake_date_formats = array(
430
  'F j, Y' => 'Mdy',
431
- 'Y/m/d' => 'ymd',
432
- 'm/d/Y' => 'mdy',
433
- 'd/m/Y' => 'dmy',
434
- 'd/m/y' => 'dmy',
435
  );
436
 
437
  $format = $cake_date_formats[$date_format];
438
-
439
- $_this = & Wpcf_Cake_Validation::getInstance();
440
- $_this->__reset();
441
- $_this->check = $check;
442
- $_this->regex = $regex;
443
-
444
- if (!is_null($_this->regex)) {
445
- return $_this->_check();
446
- }
447
-
448
- $regex['dmy'] = '%^(?:(?:31(\\/|-|\\.|\\x20)(?:0?[13578]|1[02]))\\1|(?:(?:29|30)(\\/|-|\\.|\\x20)(?:0?[1,3-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:29(\\/|-|\\.|\\x20)0?2\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\\d|2[0-8])(\\/|-|\\.|\\x20)(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$%';
449
- $regex['mdy'] = '%^(?:(?:(?:0?[13578]|1[02])(\\/|-|\\.|\\x20)31)\\1|(?:(?:0?[13-9]|1[0-2])(\\/|-|\\.|\\x20)(?:29|30)\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:0?2(\\/|-|\\.|\\x20)29\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\\/|-|\\.|\\x20)(?:0?[1-9]|1\\d|2[0-8])\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$%';
450
- $regex['ymd'] = '%^(?:(?:(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\\/|-|\\.|\\x20)(?:0?2\\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\\d)?\\d{2})(\\/|-|\\.|\\x20)(?:(?:(?:0?[13578]|1[02])\\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\\2(?:0?[1-9]|1\\d|2[0-8]))))$%';
451
- $regex['dMy'] = '/^((31(?!\\ (Feb(ruary)?|Apr(il)?|June?|(Sep(?=\\b|t)t?|Nov)(ember)?)))|((30|29)(?!\\ Feb(ruary)?))|(29(?=\\ Feb(ruary)?\\ (((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1\\d|2[0-8])\\ (Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\\b|t)t?|Nov|Dec)(ember)?)\\ ((1[6-9]|[2-9]\\d)\\d{2})$/';
452
- $regex['Mdy'] = '/^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?|Oct(ober)?|Dec(ember)?)\\ 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sept|Nov|Dec)(ember)?)\\ (0?[1-9]|([12]\\d)|30))|(Feb(ruary)?\\ (0?[1-9]|1\\d|2[0-8]|(29(?=,?\\ ((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))))\\,?\\ ((1[6-9]|[2-9]\\d)\\d{2}))$/';
453
- $regex['My'] = '%^(Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\\b|t)t?|Nov|Dec)(ember)?)[ /]((1[6-9]|[2-9]\\d)\\d{2})$%';
454
- $regex['my'] = '%^(((0[123456789]|10|11|12)([- /.])(([1][9][0-9][0-9])|([2][0-9][0-9][0-9]))))$%';
455
-
456
- $format = (is_array($format)) ? array_values($format) : array($format);
457
- foreach ($format as $key) {
458
- $_this->regex = $regex[$key];
459
-
460
- if ($_this->_check() === true) {
461
- return true;
462
- }
463
- }
464
- return false;
465
- }
466
-
467
- /**
468
- * Time validation, determines if the string passed is a valid time.
469
- * Validates time as 24hr (HH:MM) or am/pm ([H]H:MM[a|p]m)
470
- * Does not allow/validate seconds.
471
- *
472
- * @param string $check a valid time string
473
- * @return boolean Success
474
- * @access public
475
- */
476
- function time($check) {
477
- $_this = & Wpcf_Cake_Validation::getInstance();
478
- $_this->__reset();
479
- $_this->check = $check;
480
- $_this->regex = '%^((0?[1-9]|1[012])(:[0-5]\d){0,2}([AP]M|[ap]m))$|^([01]\d|2[0-3])(:[0-5]\d){0,2}$%';
481
- return $_this->_check();
482
- }
483
-
484
- /**
485
- * Boolean validation, determines if value passed is a boolean integer or true/false.
486
- *
487
- * @param string $check a valid boolean
488
- * @return boolean Success
489
- * @access public
490
- */
491
- function boolean($check) {
492
- $booleanList = array(0, 1, '0', '1', true, false);
493
- return in_array($check, $booleanList, true);
494
- }
495
-
496
- /**
497
- * Checks that a value is a valid decimal. If $places is null, the $check is allowed to be a scientific float
498
- * If no decimal point is found a false will be returned. Both the sign and exponent are optional.
499
- *
500
- * @param integer $check The value the test for decimal
501
- * @param integer $places if set $check value must have exactly $places after the decimal point
502
- * @param string $regex If a custom regular expression is used this is the only validation that will occur.
503
- * @return boolean Success
504
- * @access public
505
- */
506
- function decimal($check, $places = null, $regex = null) {
507
- $_this = & Wpcf_Cake_Validation::getInstance();
508
- $_this->__reset();
509
- $_this->regex = $regex;
510
- $_this->check = $check;
511
-
512
- if (is_null($_this->regex)) {
513
- if (is_null($places)) {
514
- $_this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]+(?:[eE][-+]?[0-9]+)?$/';
515
- } else {
516
- $_this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]{' . $places . '}$/';
517
- }
518
- }
519
- return $_this->_check();
520
- }
521
-
522
- /**
523
- * Validates for an email address.
524
- *
525
- * @param string $check Value to check
526
- * @param boolean $deep Perform a deeper validation (if true), by also checking availability of host
527
- * @param string $regex Regex to use (if none it will use built in regex)
528
- * @return boolean Success
529
- * @access public
530
- */
531
- function email($check, $deep = false, $regex = null) {
532
- $_this = & Wpcf_Cake_Validation::getInstance();
533
- $_this->__reset();
534
- $_this->check = $check;
535
- $_this->regex = $regex;
536
- $_this->deep = $deep;
537
-
538
- if (is_array($check)) {
539
- $_this->_extract($check);
540
- }
541
-
542
- if (is_null($_this->regex)) {
543
- $_this->regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . $_this->__pattern['hostname'] . '$/i';
544
- }
545
- $return = $_this->_check();
546
-
547
- if ($_this->deep === false || $_this->deep === null) {
548
- return $return;
549
- }
550
-
551
- if ($return === true && preg_match('/@(' . $_this->__pattern['hostname'] . ')$/i',
552
- $_this->check, $regs)) {
553
- if (function_exists('getmxrr') && getmxrr($regs[1], $mxhosts)) {
554
- return true;
555
- }
556
- if (function_exists('checkdnsrr') && checkdnsrr($regs[1], 'MX')) {
557
- return true;
558
- }
559
- return is_array(gethostbynamel($regs[1]));
560
- }
561
- return false;
562
- }
563
-
564
- /**
565
- * Check that value is exactly $comparedTo.
566
- *
567
- * @param mixed $check Value to check
568
- * @param mixed $comparedTo Value to compare
569
- * @return boolean Success
570
- * @access public
571
- */
572
- function equalTo($check, $comparedTo) {
573
- return ($check === $comparedTo);
574
- }
575
-
576
- /**
577
- * Check that value has a valid file extension.
578
- *
579
- * @param mixed $check Value to check
580
- * @param array $extensions file extenstions to allow
581
- * @return boolean Success
582
- * @access public
583
- */
584
- function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg')) {
585
- if (is_array($check)) {
586
- return Wpcf_Cake_Validation::extension(array_shift($check),
587
- $extensions);
588
- }
589
- $extension = strtolower(array_pop(explode('.', $check)));
590
- foreach ($extensions as $value) {
591
- if ($extension == strtolower($value)) {
592
- return true;
593
- }
594
- }
595
- return false;
596
- }
597
-
598
- /**
599
- * Validation of an IP address.
600
- *
601
- * Valid IP version strings for type restriction are:
602
- * - both: Check both IPv4 and IPv6, return true if the supplied address matches either version
603
- * - IPv4: Version 4 (Eg: 127.0.0.1, 192.168.10.123, 203.211.24.8)
604
- * - IPv6: Version 6 (Eg: ::1, 2001:0db8::1428:57ab)
605
- *
606
- * @param string $check The string to test.
607
- * @param string $type The IP Version to test against
608
- * @return boolean Success
609
- * @access public
610
- */
611
- function ip($check, $type = 'both') {
612
- $_this = & Wpcf_Cake_Validation::getInstance();
613
- $success = false;
614
- $type = strtolower($type);
615
- if ($type === 'ipv4' || $type === 'both') {
616
- $success |= $_this->_ipv4($check);
617
- }
618
- if ($type === 'ipv6' || $type === 'both') {
619
- $success |= $_this->_ipv6($check);
620
- }
621
- return $success;
622
- }
623
-
624
- /**
625
- * Validation of IPv4 addresses.
626
- *
627
- * @param string $check IP Address to test
628
- * @return boolean Success
629
- * @access protected
630
- */
631
- function _ipv4($check) {
632
- if (function_exists('filter_var')) {
633
- return filter_var($check, FILTER_VALIDATE_IP,
634
- array('flags' => FILTER_FLAG_IPV4)) !== false;
635
- }
636
- $this->__populateIp();
637
- $this->check = $check;
638
- $this->regex = '/^' . $this->__pattern['IPv4'] . '$/';
639
- return $this->_check();
640
- }
641
-
642
- /**
643
- * Validation of IPv6 addresses.
644
- *
645
- * @param string $check IP Address to test
646
- * @return boolean Success
647
- * @access protected
648
- */
649
- function _ipv6($check) {
650
- if (function_exists('filter_var')) {
651
- return filter_var($check, FILTER_VALIDATE_IP,
652
- array('flags' => FILTER_FLAG_IPV6)) !== false;
653
- }
654
- $this->__populateIp();
655
- $this->check = $check;
656
- $this->regex = '/^' . $this->__pattern['IPv6'] . '$/';
657
- return $this->_check();
658
- }
659
-
660
- /**
661
- * Checks whether the length of a string is greater or equal to a minimal length.
662
- *
663
- * @param string $check The string to test
664
- * @param integer $min The minimal string length
665
- * @return boolean Success
666
- * @access public
667
- */
668
- function minLength($check, $min) {
669
- $length = strlen($check);
670
- return ($length >= $min);
671
- }
672
-
673
- /**
674
- * Checks whether the length of a string is smaller or equal to a maximal length..
675
- *
676
- * @param string $check The string to test
677
- * @param integer $max The maximal string length
678
- * @return boolean Success
679
- * @access public
680
- */
681
- function maxLength($check, $max) {
682
- $length = strlen($check);
683
- return ($length <= $max);
684
- }
685
-
686
- /**
687
- * Checks that a value is a monetary amount.
688
- *
689
- * @param string $check Value to check
690
- * @param string $symbolPosition Where symbol is located (left/right)
691
- * @return boolean Success
692
- * @access public
693
- */
694
- function money($check, $symbolPosition = 'left') {
695
- $_this = & Wpcf_Cake_Validation::getInstance();
696
- $_this->check = $check;
697
-
698
- if ($symbolPosition == 'right') {
699
- $_this->regex = '/^(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?(?<!\x{00a2})\p{Sc}?$/u';
700
- } else {
701
- $_this->regex = '/^(?!\x{00a2})\p{Sc}?(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?$/u';
702
- }
703
- return $_this->_check();
704
- }
705
-
706
- /**
707
- * Validate a multiple select.
708
- *
709
- * Valid Options
710
- *
711
- * - in => provide a list of choices that selections must be made from
712
- * - max => maximun number of non-zero choices that can be made
713
- * - min => minimum number of non-zero choices that can be made
714
- *
715
- * @param mixed $check Value to check
716
- * @param mixed $options Options for the check.
717
- * @return boolean Success
718
- * @access public
719
- */
720
- function multiple($check, $options = array()) {
721
- $defaults = array('in' => null, 'max' => null, 'min' => null);
722
- $options = array_merge($defaults, $options);
723
- $check = array_filter((array) $check);
724
- if (empty($check)) {
725
- return false;
726
- }
727
- if ($options['max'] && count($check) > $options['max']) {
728
- return false;
729
- }
730
- if ($options['min'] && count($check) < $options['min']) {
731
- return false;
732
- }
733
- if ($options['in'] && is_array($options['in'])) {
734
- foreach ($check as $val) {
735
- if (!in_array($val, $options['in'])) {
736
- return false;
737
- }
738
- }
739
- }
740
- return true;
741
- }
742
-
743
- /**
744
- * Checks if a value is numeric.
745
- *
746
- * @param string $check Value to check
747
- * @return boolean Succcess
748
- * @access public
749
- */
750
- function numeric($check) {
751
- return is_numeric($check);
752
- }
753
-
754
- /**
755
- * Check that a value is a valid phone number.
756
- *
757
- * @param mixed $check Value to check (string or array)
758
- * @param string $regex Regular expression to use
759
- * @param string $country Country code (defaults to 'all')
760
- * @return boolean Success
761
- * @access public
762
- */
763
- function phone($check, $regex = null, $country = 'all') {
764
- $_this = & Wpcf_Cake_Validation::getInstance();
765
- $_this->check = $check;
766
- $_this->regex = $regex;
767
- $_this->country = $country;
768
- if (is_array($check)) {
769
- $_this->_extract($check);
770
- }
771
-
772
- if (is_null($_this->regex)) {
773
- switch ($_this->country) {
774
- case 'us':
775
- case 'all':
776
- case 'can':
777
- // includes all NANPA members. see http://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories
778
- $_this->regex = '/^(?:\+?1)?[-. ]?\\(?[2-9][0-8][0-9]\\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}$/';
779
- break;
780
- }
781
- }
782
- if (empty($_this->regex)) {
783
- return $_this->_pass('phone', $check, $country);
784
- }
785
- return $_this->_check();
786
- }
787
-
788
- /**
789
- * Checks that a given value is a valid postal code.
790
- *
791
- * @param mixed $check Value to check
792
- * @param string $regex Regular expression to use
793
- * @param string $country Country to use for formatting
794
- * @return boolean Success
795
- * @access public
796
- */
797
- function postal($check, $regex = null, $country = null) {
798
- $_this = & Wpcf_Cake_Validation::getInstance();
799
- $_this->check = $check;
800
- $_this->regex = $regex;
801
- $_this->country = $country;
802
- if (is_array($check)) {
803
- $_this->_extract($check);
804
- }
805
- if (empty($country)) {
806
- $_this->country = 'us';
807
- }
808
-
809
- if (is_null($_this->regex)) {
810
- switch ($_this->country) {
811
- case 'uk':
812
- $_this->regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';
813
- break;
814
- case 'ca':
815
- $_this->regex = '/\\A\\b[ABCEGHJKLMNPRSTVXY][0-9][A-Z] ?[0-9][A-Z][0-9]\\b\\z/i';
816
- break;
817
- case 'it':
818
- case 'de':
819
- $_this->regex = '/^[0-9]{5}$/i';
820
- break;
821
- case 'be':
822
- $_this->regex = '/^[1-9]{1}[0-9]{3}$/i';
823
- break;
824
- case 'us':
825
- $_this->regex = '/\\A\\b[0-9]{5}(?:-[0-9]{4})?\\b\\z/i';
826
- break;
827
- }
828
- }
829
- if (empty($_this->regex)) {
830
- return $_this->_pass('postal', $check, $country);
831
- }
832
- return $_this->_check();
833
- }
834
-
835
- /**
836
- * Validate that a number is in specified range.
837
- * if $lower and $upper are not set, will return true if
838
- * $check is a legal finite on this platform
839
- *
840
- * @param string $check Value to check
841
- * @param integer $lower Lower limit
842
- * @param integer $upper Upper limit
843
- * @return boolean Success
844
- * @access public
845
- */
846
- function range($check, $lower = null, $upper = null) {
847
- if (!is_numeric($check)) {
848
- return false;
849
- }
850
- if (isset($lower) && isset($upper)) {
851
- return ($check > $lower && $check < $upper);
852
- }
853
- return is_finite($check);
854
- }
855
-
856
- /**
857
- * Checks that a value is a valid Social Security Number.
858
- *
859
- * @param mixed $check Value to check
860
- * @param string $regex Regular expression to use
861
- * @param string $country Country
862
- * @return boolean Success
863
- * @access public
864
- */
865
- function ssn($check, $regex = null, $country = null) {
866
- $_this = & Wpcf_Cake_Validation::getInstance();
867
- $_this->check = $check;
868
- $_this->regex = $regex;
869
- $_this->country = $country;
870
- if (is_array($check)) {
871
- $_this->_extract($check);
872
- }
873
-
874
- if (is_null($_this->regex)) {
875
- switch ($_this->country) {
876
- case 'dk':
877
- $_this->regex = '/\\A\\b[0-9]{6}-[0-9]{4}\\b\\z/i';
878
- break;
879
- case 'nl':
880
- $_this->regex = '/\\A\\b[0-9]{9}\\b\\z/i';
881
- break;
882
- case 'us':
883
- $_this->regex = '/\\A\\b[0-9]{3}-[0-9]{2}-[0-9]{4}\\b\\z/i';
884
- break;
885
- }
886
- }
887
- if (empty($_this->regex)) {
888
- return $_this->_pass('ssn', $check, $country);
889
- }
890
- return $_this->_check();
891
- }
892
-
893
- /**
894
- * Checks that a value is a valid uuid - http://tools.ietf.org/html/rfc4122
895
- *
896
- * @param string $check Value to check
897
- * @return boolean Success
898
- * @access public
899
- */
900
- function uuid($check) {
901
- $_this = & Wpcf_Cake_Validation::getInstance();
902
- $_this->check = $check;
903
- $_this->regex = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i';
904
- return $_this->_check();
905
- }
906
-
907
- /**
908
- * Checks that a value is a valid URL according to http://www.w3.org/Addressing/URL/url-spec.txt
909
- *
910
- * The regex checks for the following component parts:
911
- *
912
- * - a valid, optional, scheme
913
- * - a valid ip address OR
914
- * a valid domain name as defined by section 2.3.1 of http://www.ietf.org/rfc/rfc1035.txt
915
- * with an optional port number
916
- * - an optional valid path
917
- * - an optional query string (get parameters)
918
- * - an optional fragment (anchor tag)
919
- *
920
- * @param string $check Value to check
921
- * @param boolean $strict Require URL to be prefixed by a valid scheme (one of http(s)/ftp(s)/file/news/gopher)
922
- * @return boolean Success
923
- * @access public
924
- */
925
- function url($check, $strict = false) {
926
- $_this = & Wpcf_Cake_Validation::getInstance();
927
- $_this->__populateIp();
928
- $_this->check = $check;
929
- $validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~[]') . '\/0-9a-z\p{L}\p{N}]|(%[0-9a-f]{2}))';
930
- $_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
931
- '(?:' . $_this->__pattern['IPv4'] . '|\[' . $_this->__pattern['IPv6'] . '\]|' . $_this->__pattern['hostname'] . ')' .
932
- '(?::[1-9][0-9]{0,4})?' .
933
- '(?:\/?|\/' . $validChars . '*)?' .
934
- '(?:\?' . $validChars . '*)?' .
935
- '(?:#' . $validChars . '*)?$/iu';
936
- return $_this->_check();
937
- }
938
-
939
- /**
940
- * Checks if a value is in a given list.
941
- *
942
- * @param string $check Value to check
943
- * @param array $list List to check against
944
- * @return boolean Succcess
945
- * @access public
946
- */
947
- function inList($check, $list) {
948
- return in_array($check, $list);
949
- }
950
-
951
- /**
952
- * Runs an user-defined validation.
953
- *
954
- * @param mixed $check value that will be validated in user-defined methods.
955
- * @param object $object class that holds validation method
956
- * @param string $method class method name for validation to run
957
- * @param array $args arguments to send to method
958
- * @return mixed user-defined class class method returns
959
- * @access public
960
- */
961
- function userDefined($check, $object, $method, $args = null) {
962
- return call_user_func_array(array(&$object, $method),
963
- array($check, $args));
964
- }
965
-
966
- function noSpecialChars($check) {
967
- return preg_match('#[^a-zA-Z0-9\s\_\-]#', $check) ? false : true;
968
- }
969
-
970
- function rewriteSlug($check) {
971
- return preg_match('#[^a-zA-Z0-9\s\_\-\%]#', $check) ? false : true;
972
- }
973
-
974
- /**
975
- * Attempts to pass unhandled Validation locales to a class starting with $classPrefix
976
- * and ending with Validation. For example $classPrefix = 'nl', the class would be
977
- * `NlValidation`.
978
- *
979
- * @param string $method The method to call on the other class.
980
- * @param mixed $check The value to check or an array of parameters for the method to be called.
981
- * @param string $classPrefix The prefix for the class to do the validation.
982
- * @return mixed Return of Passed method, false on failure
983
- * @access protected
984
- * */
985
- function _pass($method, $check, $classPrefix) {
986
- $className = ucwords($classPrefix) . 'Validation';
987
- if (!class_exists($className)) {
988
- trigger_error(sprintf(__('Could not find %s class, unable to complete validation.',
989
- true), $className), E_USER_WARNING);
990
- return false;
991
- }
992
- if (!is_callable(array($className, $method))) {
993
- trigger_error(sprintf(__('Method %s does not exist on %s unable to complete validation.',
994
- true), $method, $className), E_USER_WARNING);
995
- return false;
996
- }
997
- $check = (array) $check;
998
- return call_user_func_array(array($className, $method), $check);
999
- }
1000
-
1001
- /**
1002
- * Runs a regular expression match.
1003
- *
1004
- * @return boolean Success of match
1005
- * @access protected
1006
- */
1007
- function _check() {
1008
- $_this = & Wpcf_Cake_Validation::getInstance();
1009
- if (preg_match($_this->regex, $_this->check)) {
1010
- $_this->error[] = false;
1011
- return true;
1012
- } else {
1013
- $_this->error[] = true;
1014
- return false;
1015
- }
1016
- }
1017
-
1018
- /**
1019
- * Get the values to use when value sent to validation method is
1020
- * an array.
1021
- *
1022
- * @param array $params Parameters sent to validation method
1023
- * @return void
1024
- * @access protected
1025
- */
1026
- function _extract($params) {
1027
- $_this = & Wpcf_Cake_Validation::getInstance();
1028
- extract($params, EXTR_OVERWRITE);
1029
-
1030
- if (isset($check)) {
1031
- $_this->check = $check;
1032
- }
1033
- if (isset($regex)) {
1034
- $_this->regex = $regex;
1035
- }
1036
- if (isset($country)) {
1037
- $_this->country = strtolower($country);
1038
- }
1039
- if (isset($deep)) {
1040
- $_this->deep = $deep;
1041
- }
1042
- if (isset($type)) {
1043
- $_this->type = $type;
1044
- }
1045
- }
1046
-
1047
- /**
1048
- * Luhn algorithm
1049
- *
1050
- * @see http://en.wikipedia.org/wiki/Luhn_algorithm
1051
- * @return boolean Success
1052
- * @access protected
1053
- */
1054
- function _luhn() {
1055
- $_this = & Wpcf_Cake_Validation::getInstance();
1056
- if ($_this->deep !== true) {
1057
- return true;
1058
- }
1059
- if ($_this->check == 0) {
1060
- return false;
1061
- }
1062
- $sum = 0;
1063
- $length = strlen($_this->check);
1064
-
1065
- for ($position = 1 - ($length % 2); $position < $length; $position += 2) {
1066
- $sum += $_this->check[$position];
1067
- }
1068
-
1069
- for ($position = ($length % 2); $position < $length; $position += 2) {
1070
- $number = $_this->check[$position] * 2;
1071
- $sum += ($number < 10) ? $number : $number - 9;
1072
- }
1073
-
1074
- return ($sum % 10 == 0);
1075
- }
1076
-
1077
- /*
1078
- * Lazily popualate the IP address patterns used for validations
1079
- *
1080
- * @return void
1081
- * @access private
1082
- */
1083
-
1084
- function __populateIp() {
1085
- if (!isset($this->__pattern['IPv6'])) {
1086
- $pattern = '((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}';
1087
- $pattern .= '(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})';
1088
- $pattern .= '|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})';
1089
- $pattern .= '(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)';
1090
- $pattern .= '{4}(:[0-9A-Fa-f]{1,4}){0,1}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2}))';
1091
- $pattern .= '{3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}';
1092
- $pattern .= '((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|';
1093
- $pattern .= '((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}';
1094
- $pattern .= '((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2}))';
1095
- $pattern .= '{3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)(:[0-9A-Fa-f]{1,4})';
1096
- $pattern .= '{0,4}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)';
1097
- $pattern .= '|((:[0-9A-Fa-f]{1,4}){1,2})))|(:(:[0-9A-Fa-f]{1,4}){0,5}((:((25[0-5]|2[0-4]';
1098
- $pattern .= '\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4})';
1099
- $pattern .= '{1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?';
1100
-
1101
- $this->__pattern['IPv6'] = $pattern;
1102
- }
1103
- if (!isset($this->__pattern['IPv4'])) {
1104
- $pattern = '(?:(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])';
1105
- $this->__pattern['IPv4'] = $pattern;
1106
- }
1107
- }
1108
-
1109
- /**
1110
- * Reset internal variables for another validation run.
1111
- *
1112
- * @return void
1113
- * @access private
1114
- */
1115
- function __reset() {
1116
- $this->check = null;
1117
- $this->regex = null;
1118
- $this->country = null;
1119
- $this->deep = null;
1120
- $this->type = null;
1121
- $this->error = array();
1122
- $this->errors = array();
1123
- }
1124
-
1125
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1126
  }
29
  * @since CakePHP v 1.2.0.3830
30
  */
31
  //class Validation extends Object {
32
+ if (!class_exists('Wpcf_Cake_Validation')) {
33
+
34
+ class Wpcf_Cake_Validation {
35
+
36
+ /**
37
+ * Set the value of methods $check param.
38
+ *
39
+ * @var string
40
+ * @access public
41
+ */
42
+ var $check = null;
43
+
44
+ /**
45
+ * Set to a valid regular expression in the class methods.
46
+ * Can be set from $regex param also
47
+ *
48
+ * @var string
49
+ * @access public
50
+ */
51
+ var $regex = null;
52
+
53
+ /**
54
+ * Some complex patterns needed in multiple places
55
+ *
56
+ * @var array
57
+ * @access private
58
+ */
59
+ var $__pattern = array(
60
+ 'hostname' => '(?:[a-z0-9][-a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,4}|museum|travel)'
61
+ );
62
+
63
+ /**
64
+ * Some class methods use a country to determine proper validation.
65
+ * This can be passed to methods in the $country param
66
+ *
67
+ * @var string
68
+ * @access public
69
+ */
70
+ var $country = null;
71
+
72
+ /**
73
+ * Some class methods use a deeper validation when set to true
74
+ *
75
+ * @var string
76
+ * @access public
77
+ */
78
+ var $deep = null;
79
+
80
+ /**
81
+ * Some class methods use the $type param to determine which validation to perfom in the method
82
+ *
83
+ * @var string
84
+ * @access public
85
+ */
86
+ var $type = null;
87
+
88
+ /**
89
+ * Holds an array of errors messages set in this class.
90
+ * These are used for debugging purposes
91
+ *
92
+ * @var array
93
+ * @access public
94
+ */
95
+ var $errors = array();
96
+
97
+ /**
98
+ * Gets a reference to the Validation object instance
99
+ *
100
+ * @return object Validation instance
101
+ * @access public
102
+ * @static
103
+ */
104
+ function &getInstance() {
105
+ static $instance = array();
106
+
107
+ if (!$instance) {
108
+ $instance[0] = new Wpcf_Cake_Validation();
109
+ }
110
+ return $instance[0];
111
+ }
112
+
113
+ /**
114
+ * Checks that a string contains something other than whitespace
115
+ *
116
+ * Returns true if string contains something other than whitespace
117
+ *
118
+ * $check can be passed as an array:
119
+ * array('check' => 'valueToCheck');
120
+ *
121
+ * @param mixed $check Value to check
122
+ * @return boolean Success
123
+ * @access public
124
+ */
125
+ function notEmpty($check) {
126
+ $_this = & Wpcf_Cake_Validation::getInstance();
127
+ $_this->__reset();
128
+ $_this->check = $check;
129
+
130
+ if (is_array($check)) {
131
+ $_this->_extract($check);
132
+ }
133
+
134
+ if (empty($_this->check) && $_this->check != '0') {
135
+ return false;
136
+ }
137
+ $_this->regex = '/[^\s]+/m';
138
+ return $_this->_check();
139
+ }
140
+
141
+ /**
142
+ * Checks that a string contains only integer or letters
143
+ *
144
+ * Returns true if string contains only integer or letters
145
+ *
146
+ * $check can be passed as an array:
147
+ * array('check' => 'valueToCheck');
148
+ *
149
+ * @param mixed $check Value to check
150
+ * @return boolean Success
151
+ * @access public
152
+ */
153
+ function alphaNumeric($check) {
154
+ $_this = & Wpcf_Cake_Validation::getInstance();
155
+ $_this->__reset();
156
+ $_this->check = $check;
157
+
158
+ if (is_array($check)) {
159
+ $_this->_extract($check);
160
+ }
161
+
162
+ if (empty($_this->check) && $_this->check != '0') {
163
+ return false;
164
+ }
165
+ $_this->regex = '/^[a-zA-Z0-9]*$/mu';
166
+ $return = $_this->_check();
167
+
168
+ if (!$return) {
169
+ $_this->regex = '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]+$/mu';
170
+ $return = $_this->_check();
171
+ }
172
+
173
+ return $_this->_check();
174
+ }
175
+
176
+ function alphaNumericWhitespaces($check) {
177
+ $_this = & Wpcf_Cake_Validation::getInstance();
178
+ $_this->__reset();
179
+ $_this->check = $check;
180
+
181
+ if (is_array($check)) {
182
+ $_this->_extract($check);
183
+ }
184
+
185
+ if (empty($_this->check) && $_this->check != '0') {
186
+ return false;
187
+ }
188
+ $_this->regex = '/^[a-zA-Z0-9\s\-\_]*$/mu';
189
+ $return = $_this->_check();
190
+
191
+ if (!$return) {
192
+ $_this->regex = '/^[\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}\s\-\_]+$/mu';
193
+ $return = $_this->_check();
194
+ }
195
+
196
+ return $return;
197
+ }
198
+
199
+ /**
200
+ * Checks that a string length is within s specified range.
201
+ * Spaces are included in the character count.
202
+ * Returns true is string matches value min, max, or between min and max,
203
+ *
204
+ * @param string $check Value to check for length
205
+ * @param integer $min Minimum value in range (inclusive)
206
+ * @param integer $max Maximum value in range (inclusive)
207
+ * @return boolean Success
208
+ * @access public
209
+ */
210
+ function between($check, $min, $max) {
211
+ $length = strlen($check);
212
+ return ($length >= $min && $length <= $max);
213
+ }
214
+
215
+ /**
216
+ * Returns true if field is left blank -OR- only whitespace characters are present in it's value
217
+ * Whitespace characters include Space, Tab, Carriage Return, Newline
218
+ *
219
+ * $check can be passed as an array:
220
+ * array('check' => 'valueToCheck');
221
+ *
222
+ * @param mixed $check Value to check
223
+ * @return boolean Success
224
+ * @access public
225
+ */
226
+ function blank($check) {
227
+ $_this = & Wpcf_Cake_Validation::getInstance();
228
+ $_this->__reset();
229
+ $_this->check = $check;
230
+
231
+ if (is_array($check)) {
232
+ $_this->_extract($check);
233
+ }
234
+
235
+ $_this->regex = '/[^\\s]/';
236
+ return !$_this->_check();
237
+ }
238
+
239
+ /**
240
+ * Validation of credit card numbers.
241
+ * Returns true if $check is in the proper credit card format.
242
+ *
243
+ * @param mixed $check credit card number to validate
244
+ * @param mixed $type 'all' may be passed as a sting, defaults to fast which checks format of most major credit cards
245
+ * if an array is used only the values of the array are checked.
246
+ * Example: array('amex', 'bankcard', 'maestro')
247
+ * @param boolean $deep set to true this will check the Luhn algorithm of the credit card.
248
+ * @param string $regex A custom regex can also be passed, this will be used instead of the defined regex values
249
+ * @return boolean Success
250
+ * @access public
251
+ * @see Wpcf_Cake_Validation::_luhn()
252
+ */
253
+ function cc($check, $type = 'fast', $deep = false, $regex = null) {
254
+ $_this = & Wpcf_Cake_Validation::getInstance();
255
+ $_this->__reset();
256
+ $_this->check = $check;
257
+ $_this->type = $type;
258
+ $_this->deep = $deep;
259
+ $_this->regex = $regex;
260
+
261
+ if (is_array($check)) {
262
+ $_this->_extract($check);
263
+ }
264
+ $_this->check = str_replace(array('-', ' '), '', $_this->check);
265
+
266
+ if (strlen($_this->check) < 13) {
267
+ return false;
268
+ }
269
+
270
+ if (!is_null($_this->regex)) {
271
+ if ($_this->_check()) {
272
+ return $_this->_luhn();
273
+ }
274
+ }
275
+ $cards = array(
276
+ 'all' => array(
277
+ 'amex' => '/^3[4|7]\\d{13}$/',
278
+ 'bankcard' => '/^56(10\\d\\d|022[1-5])\\d{10}$/',
279
+ 'diners' => '/^(?:3(0[0-5]|[68]\\d)\\d{11})|(?:5[1-5]\\d{14})$/',
280
+ 'disc' => '/^(?:6011|650\\d)\\d{12}$/',
281
+ 'electron' => '/^(?:417500|4917\\d{2}|4913\\d{2})\\d{10}$/',
282
+ 'enroute' => '/^2(?:014|149)\\d{11}$/',
283
+ 'jcb' => '/^(3\\d{4}|2100|1800)\\d{11}$/',
284
+ 'maestro' => '/^(?:5020|6\\d{3})\\d{12}$/',
285
+ 'mc' => '/^5[1-5]\\d{14}$/',
286
+ 'solo' => '/^(6334[5-9][0-9]|6767[0-9]{2})\\d{10}(\\d{2,3})?$/',
287
+ 'switch' => '/^(?:49(03(0[2-9]|3[5-9])|11(0[1-2]|7[4-9]|8[1-2])|36[0-9]{2})\\d{10}(\\d{2,3})?)|(?:564182\\d{10}(\\d{2,3})?)|(6(3(33[0-4][0-9])|759[0-9]{2})\\d{10}(\\d{2,3})?)$/',
288
+ 'visa' => '/^4\\d{12}(\\d{3})?$/',
289
+ 'voyager' => '/^8699[0-9]{11}$/'
290
+ ),
291
+ 'fast' => '/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$/'
292
+ );
293
+
294
+ if (is_array($_this->type)) {
295
+ foreach ($_this->type as $value) {
296
+ $_this->regex = $cards['all'][strtolower($value)];
297
+
298
+ if ($_this->_check()) {
299
+ return $_this->_luhn();
300
+ }
301
+ }
302
+ } elseif ($_this->type == 'all') {
303
+ foreach ($cards['all'] as $value) {
304
+ $_this->regex = $value;
305
+
306
+ if ($_this->_check()) {
307
+ return $_this->_luhn();
308
+ }
309
+ }
310
+ } else {
311
+ $_this->regex = $cards['fast'];
312
+
313
+ if ($_this->_check()) {
314
+ return $_this->_luhn();
315
+ }
316
+ }
317
+ }
318
+
319
+ /**
320
+ * Used to compare 2 numeric values.
321
+ *
322
+ * @param mixed $check1 if string is passed for a string must also be passed for $check2
323
+ * used as an array it must be passed as array('check1' => value, 'operator' => 'value', 'check2' -> value)
324
+ * @param string $operator Can be either a word or operand
325
+ * is greater >, is less <, greater or equal >=
326
+ * less or equal <=, is less <, equal to ==, not equal !=
327
+ * @param integer $check2 only needed if $check1 is a string
328
+ * @return boolean Success
329
+ * @access public
330
+ */
331
+ function comparison($check1, $operator = null, $check2 = null) {
332
+ if (is_array($check1)) {
333
+ extract($check1, EXTR_OVERWRITE);
334
+ }
335
+ $operator = str_replace(array(' ', "\t", "\n", "\r", "\0", "\x0B"), '', strtolower($operator));
336
+
337
+ switch ($operator) {
338
+ case 'isgreater':
339
+ case '>':
340
+ if ($check1 > $check2) {
341
+ return true;
342
+ }
343
+ break;
344
+ case 'isless':
345
+ case '<':
346
+ if ($check1 < $check2) {
347
+ return true;
348
+ }
349
+ break;
350
+ case 'greaterorequal':
351
+ case '>=':
352
+ if ($check1 >= $check2) {
353
+ return true;
354
+ }
355
+ break;
356
+ case 'lessorequal':
357
+ case '<=':
358
+ if ($check1 <= $check2) {
359
+ return true;
360
+ }
361
+ break;
362
+ case 'equalto':
363
+ case '==':
364
+ if ($check1 == $check2) {
365
+ return true;
366
+ }
367
+ break;
368
+ case 'notequal':
369
+ case '!=':
370
+ if ($check1 != $check2) {
371
+ return true;
372
+ }
373
+ break;
374
+ default:
375
+ $_this = & Wpcf_Cake_Validation::getInstance();
376
+ $_this->errors[] = __('You must define the $operator parameter for Wpcf_Cake_Validation::comparison()', 'wpcf');
377
+ break;
378
+ }
379
+ return false;
380
+ }
381
+
382
+ /**
383
+ * Used when a custom regular expression is needed.
384
+ *
385
+ * @param mixed $check When used as a string, $regex must also be a valid regular expression.
386
+ * As and array: array('check' => value, 'regex' => 'valid regular expression')
387
+ * @param string $regex If $check is passed as a string, $regex must also be set to valid regular expression
388
+ * @return boolean Success
389
+ * @access public
390
+ */
391
+ function custom($check, $regex = null) {
392
+ $_this = & Wpcf_Cake_Validation::getInstance();
393
+ $_this->__reset();
394
+ $_this->check = $check;
395
+ $_this->regex = $regex;
396
+ if (is_array($check)) {
397
+ $_this->_extract($check);
398
+ }
399
+ if ($_this->regex === null) {
400
+ $_this->errors[] = __('You must define a regular expression for Wpcf_Cake_Validation::custom()', 'wpcf');
401
+ return false;
402
+ }
403
+ return $_this->_check();
404
+ }
405
+
406
+ /**
407
+ * Date validation, determines if the string passed is a valid date.
408
+ * keys that expect full month, day and year will validate leap years
409
+ *
410
+ * @param string $check a valid date string
411
+ * @param mixed $format Use a string or an array of the keys below. Arrays should be passed as array('dmy', 'mdy', etc)
412
+ * Keys: dmy 27-12-2006 or 27-12-06 separators can be a space, period, dash, forward slash
413
+ * mdy 12-27-2006 or 12-27-06 separators can be a space, period, dash, forward slash
414
+ * ymd 2006-12-27 or 06-12-27 separators can be a space, period, dash, forward slash
415
+ * dMy 27 December 2006 or 27 Dec 2006
416
+ * Mdy December 27, 2006 or Dec 27, 2006 comma is optional
417
+ * My December 2006 or Dec 2006
418
+ * my 12/2006 separators can be a space, period, dash, forward slash
419
+ * @param string $regex If a custom regular expression is used this is the only validation that will occur.
420
+ * @return boolean Success
421
+ * @access public
422
+ */
423
+ function date($check, $format = 'ymd', $regex = null) {
424
+
425
+ $date_format = wpcf_get_date_format();
 
 
 
426
  $cake_date_formats = array(
427
  'F j, Y' => 'Mdy',
428
+ 'Y/m/d' => 'ymd',
429
+ 'm/d/Y' => 'mdy',
430
+ 'd/m/Y' => 'dmy',
431
+ 'd/m/y' => 'dmy',
432
  );
433
 
434
  $format = $cake_date_formats[$date_format];
435
+
436
+ $_this = & Wpcf_Cake_Validation::getInstance();
437
+ $_this->__reset();
438
+ $_this->check = $check;
439
+ $_this->regex = $regex;
440
+
441
+ if (!is_null($_this->regex)) {
442
+ return $_this->_check();
443
+ }
444
+
445
+ $regex['dmy'] = '%^(?:(?:31(\\/|-|\\.|\\x20)(?:0?[13578]|1[02]))\\1|(?:(?:29|30)(\\/|-|\\.|\\x20)(?:0?[1,3-9]|1[0-2])\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:29(\\/|-|\\.|\\x20)0?2\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:0?[1-9]|1\\d|2[0-8])(\\/|-|\\.|\\x20)(?:(?:0?[1-9])|(?:1[0-2]))\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$%';
446
+ $regex['mdy'] = '%^(?:(?:(?:0?[13578]|1[02])(\\/|-|\\.|\\x20)31)\\1|(?:(?:0?[13-9]|1[0-2])(\\/|-|\\.|\\x20)(?:29|30)\\2))(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$|^(?:0?2(\\/|-|\\.|\\x20)29\\3(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\\/|-|\\.|\\x20)(?:0?[1-9]|1\\d|2[0-8])\\4(?:(?:1[6-9]|[2-9]\\d)?\\d{2})$%';
447
+ $regex['ymd'] = '%^(?:(?:(?:(?:(?:1[6-9]|[2-9]\\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00)))(\\/|-|\\.|\\x20)(?:0?2\\1(?:29)))|(?:(?:(?:1[6-9]|[2-9]\\d)?\\d{2})(\\/|-|\\.|\\x20)(?:(?:(?:0?[13578]|1[02])\\2(?:31))|(?:(?:0?[1,3-9]|1[0-2])\\2(29|30))|(?:(?:0?[1-9])|(?:1[0-2]))\\2(?:0?[1-9]|1\\d|2[0-8]))))$%';
448
+ $regex['dMy'] = '/^((31(?!\\ (Feb(ruary)?|Apr(il)?|June?|(Sep(?=\\b|t)t?|Nov)(ember)?)))|((30|29)(?!\\ Feb(ruary)?))|(29(?=\\ Feb(ruary)?\\ (((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1\\d|2[0-8])\\ (Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\\b|t)t?|Nov|Dec)(ember)?)\\ ((1[6-9]|[2-9]\\d)\\d{2})$/';
449
+ $regex['Mdy'] = '/^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?|Oct(ober)?|Dec(ember)?)\\ 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sept|Nov|Dec)(ember)?)\\ (0?[1-9]|([12]\\d)|30))|(Feb(ruary)?\\ (0?[1-9]|1\\d|2[0-8]|(29(?=,?\\ ((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))))\\,?\\ ((1[6-9]|[2-9]\\d)\\d{2}))$/';
450
+ $regex['My'] = '%^(Jan(uary)?|Feb(ruary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sep(?=\\b|t)t?|Nov|Dec)(ember)?)[ /]((1[6-9]|[2-9]\\d)\\d{2})$%';
451
+ $regex['my'] = '%^(((0[123456789]|10|11|12)([- /.])(([1][9][0-9][0-9])|([2][0-9][0-9][0-9]))))$%';
452
+
453
+ $format = (is_array($format)) ? array_values($format) : array($format);
454
+ foreach ($format as $key) {
455
+ $_this->regex = $regex[$key];
456
+
457
+ if ($_this->_check() === true) {
458
+ return true;
459
+ }
460
+ }
461
+ return false;
462
+ }
463
+
464
+ /**
465
+ * Time validation, determines if the string passed is a valid time.
466
+ * Validates time as 24hr (HH:MM) or am/pm ([H]H:MM[a|p]m)
467
+ * Does not allow/validate seconds.
468
+ *
469
+ * @param string $check a valid time string
470
+ * @return boolean Success
471
+ * @access public
472
+ */
473
+ function time($check) {
474
+ $_this = & Wpcf_Cake_Validation::getInstance();
475
+ $_this->__reset();
476
+ $_this->check = $check;
477
+ $_this->regex = '%^((0?[1-9]|1[012])(:[0-5]\d){0,2}([AP]M|[ap]m))$|^([01]\d|2[0-3])(:[0-5]\d){0,2}$%';
478
+ return $_this->_check();
479
+ }
480
+
481
+ /**
482
+ * Boolean validation, determines if value passed is a boolean integer or true/false.
483
+ *
484
+ * @param string $check a valid boolean
485
+ * @return boolean Success
486
+ * @access public
487
+ */
488
+ function boolean($check) {
489
+ $booleanList = array(0, 1, '0', '1', true, false);
490
+ return in_array($check, $booleanList, true);
491
+ }
492
+
493
+ /**
494
+ * Checks that a value is a valid decimal. If $places is null, the $check is allowed to be a scientific float
495
+ * If no decimal point is found a false will be returned. Both the sign and exponent are optional.
496
+ *
497
+ * @param integer $check The value the test for decimal
498
+ * @param integer $places if set $check value must have exactly $places after the decimal point
499
+ * @param string $regex If a custom regular expression is used this is the only validation that will occur.
500
+ * @return boolean Success
501
+ * @access public
502
+ */
503
+ function decimal($check, $places = null, $regex = null) {
504
+ $_this = & Wpcf_Cake_Validation::getInstance();
505
+ $_this->__reset();
506
+ $_this->regex = $regex;
507
+ $_this->check = $check;
508
+
509
+ if (is_null($_this->regex)) {
510
+ if (is_null($places)) {
511
+ $_this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]+(?:[eE][-+]?[0-9]+)?$/';
512
+ } else {
513
+ $_this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]{' . $places . '}$/';
514
+ }
515
+ }
516
+ return $_this->_check();
517
+ }
518
+
519
+ /**
520
+ * Validates for an email address.
521
+ *
522
+ * @param string $check Value to check
523
+ * @param boolean $deep Perform a deeper validation (if true), by also checking availability of host
524
+ * @param string $regex Regex to use (if none it will use built in regex)
525
+ * @return boolean Success
526
+ * @access public
527
+ */
528
+ function email($check, $deep = false, $regex = null) {
529
+ $_this = & Wpcf_Cake_Validation::getInstance();
530
+ $_this->__reset();
531
+ $_this->check = $check;
532
+ $_this->regex = $regex;
533
+ $_this->deep = $deep;
534
+
535
+ if (is_array($check)) {
536
+ $_this->_extract($check);
537
+ }
538
+
539
+ if (is_null($_this->regex)) {
540
+ $_this->regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . $_this->__pattern['hostname'] . '$/i';
541
+ }
542
+ $return = $_this->_check();
543
+
544
+ if ($_this->deep === false || $_this->deep === null) {
545
+ return $return;
546
+ }
547
+
548
+ if ($return === true && preg_match('/@(' . $_this->__pattern['hostname'] . ')$/i', $_this->check, $regs)) {
549
+ if (function_exists('getmxrr') && getmxrr($regs[1], $mxhosts)) {
550
+ return true;
551
+ }
552
+ if (function_exists('checkdnsrr') && checkdnsrr($regs[1], 'MX')) {
553
+ return true;
554
+ }
555
+ return is_array(gethostbynamel($regs[1]));
556
+ }
557
+ return false;
558
+ }
559
+
560
+ /**
561
+ * Check that value is exactly $comparedTo.
562
+ *
563
+ * @param mixed $check Value to check
564
+ * @param mixed $comparedTo Value to compare
565
+ * @return boolean Success
566
+ * @access public
567
+ */
568
+ function equalTo($check, $comparedTo) {
569
+ return ($check === $comparedTo);
570
+ }
571
+
572
+ /**
573
+ * Check that value has a valid file extension.
574
+ *
575
+ * @param mixed $check Value to check
576
+ * @param array $extensions file extenstions to allow
577
+ * @return boolean Success
578
+ * @access public
579
+ */
580
+ function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg')) {
581
+ if (is_array($check)) {
582
+ return Wpcf_Cake_Validation::extension(array_shift($check), $extensions);
583
+ }
584
+ $extension = strtolower(array_pop(explode('.', $check)));
585
+ foreach ($extensions as $value) {
586
+ if ($extension == strtolower($value)) {
587
+ return true;
588
+ }
589
+ }
590
+ return false;
591
+ }
592
+
593
+ /**
594
+ * Validation of an IP address.
595
+ *
596
+ * Valid IP version strings for type restriction are:
597
+ * - both: Check both IPv4 and IPv6, return true if the supplied address matches either version
598
+ * - IPv4: Version 4 (Eg: 127.0.0.1, 192.168.10.123, 203.211.24.8)
599
+ * - IPv6: Version 6 (Eg: ::1, 2001:0db8::1428:57ab)
600
+ *
601
+ * @param string $check The string to test.
602
+ * @param string $type The IP Version to test against
603
+ * @return boolean Success
604
+ * @access public
605
+ */
606
+ function ip($check, $type = 'both') {
607
+ $_this = & Wpcf_Cake_Validation::getInstance();
608
+ $success = false;
609
+ $type = strtolower($type);
610
+ if ($type === 'ipv4' || $type === 'both') {
611
+ $success |= $_this->_ipv4($check);
612
+ }
613
+ if ($type === 'ipv6' || $type === 'both') {
614
+ $success |= $_this->_ipv6($check);
615
+ }
616
+ return $success;
617
+ }
618
+
619
+ /**
620
+ * Validation of IPv4 addresses.
621
+ *
622
+ * @param string $check IP Address to test
623
+ * @return boolean Success
624
+ * @access protected
625
+ */
626
+ function _ipv4($check) {
627
+ if (function_exists('filter_var')) {
628
+ return filter_var($check, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)) !== false;
629
+ }
630
+ $this->__populateIp();
631
+ $this->check = $check;
632
+ $this->regex = '/^' . $this->__pattern['IPv4'] . '$/';
633
+ return $this->_check();
634
+ }
635
+
636
+ /**
637
+ * Validation of IPv6 addresses.
638
+ *
639
+ * @param string $check IP Address to test
640
+ * @return boolean Success
641
+ * @access protected
642
+ */
643
+ function _ipv6($check) {
644
+ if (function_exists('filter_var')) {
645
+ return filter_var($check, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV6)) !== false;
646
+ }
647
+ $this->__populateIp();
648
+ $this->check = $check;
649
+ $this->regex = '/^' . $this->__pattern['IPv6'] . '$/';
650
+ return $this->_check();
651
+ }
652
+
653
+ /**
654
+ * Checks whether the length of a string is greater or equal to a minimal length.
655
+ *
656
+ * @param string $check The string to test
657
+ * @param integer $min The minimal string length
658
+ * @return boolean Success
659
+ * @access public
660
+ */
661
+ function minLength($check, $min) {
662
+ $length = strlen($check);
663
+ return ($length >= $min);
664
+ }
665
+
666
+ /**
667
+ * Checks whether the length of a string is smaller or equal to a maximal length..
668
+ *
669
+ * @param string $check The string to test
670
+ * @param integer $max The maximal string length
671
+ * @return boolean Success
672
+ * @access public
673
+ */
674
+ function maxLength($check, $max) {
675
+ $length = strlen($check);
676
+ return ($length <= $max);
677
+ }
678
+
679
+ /**
680
+ * Checks that a value is a monetary amount.
681
+ *
682
+ * @param string $check Value to check
683
+ * @param string $symbolPosition Where symbol is located (left/right)
684
+ * @return boolean Success
685
+ * @access public
686
+ */
687
+ function money($check, $symbolPosition = 'left') {
688
+ $_this = & Wpcf_Cake_Validation::getInstance();
689
+ $_this->check = $check;
690
+
691
+ if ($symbolPosition == 'right') {
692
+ $_this->regex = '/^(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?(?<!\x{00a2})\p{Sc}?$/u';
693
+ } else {
694
+ $_this->regex = '/^(?!\x{00a2})\p{Sc}?(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))((?!\1)[,.]\d{2})?$/u';
695
+ }
696
+ return $_this->_check();
697
+ }
698
+
699
+ /**
700
+ * Validate a multiple select.
701
+ *
702
+ * Valid Options
703
+ *
704
+ * - in => provide a list of choices that selections must be made from
705
+ * - max => maximun number of non-zero choices that can be made
706
+ * - min => minimum number of non-zero choices that can be made
707
+ *
708
+ * @param mixed $check Value to check
709
+ * @param mixed $options Options for the check.
710
+ * @return boolean Success
711
+ * @access public
712
+ */
713
+ function multiple($check, $options = array()) {
714
+ $defaults = array('in' => null, 'max' => null, 'min' => null);
715
+ $options = array_merge($defaults, $options);
716
+ $check = array_filter((array) $check);
717
+ if (empty($check)) {
718
+ return false;
719
+ }
720
+ if ($options['max'] && count($check) > $options['max']) {
721
+ return false;
722
+ }
723
+ if ($options['min'] && count($check) < $options['min']) {
724
+ return false;
725
+ }
726
+ if ($options['in'] && is_array($options['in'])) {
727
+ foreach ($check as $val) {
728
+ if (!in_array($val, $options['in'])) {
729
+ return false;
730
+ }
731
+ }
732
+ }
733
+ return true;
734
+ }
735
+
736
+ /**
737
+ * Checks if a value is numeric.
738
+ *
739
+ * @param string $check Value to check
740
+ * @return boolean Succcess
741
+ * @access public
742
+ */
743
+ function numeric($check) {
744
+ return is_numeric($check);
745
+ }
746
+
747
+ /**
748
+ * Checks if a value is integer.
749
+ *
750
+ * @param string $check Value to check
751
+ * @return boolean Succcess
752
+ * @access public
753
+ */
754
+ function integer($check) {
755
+ return is_int(intval($check));
756
+ }
757
+
758
+ /**
759
+ * Checks if a value is valid hexadecimal.
760
+ *
761
+ * @param string $check Value to check
762
+ * @return boolean Succcess
763
+ * @access public
764
+ */
765
+ function hexadecimal($check) {
766
+ return preg_match('/^#[a-f0-9]{6}$/i', $check);
767
+ }
768
+
769
+ /**
770
+ * Check that a value is a valid phone number.
771
+ *
772
+ * @param mixed $check Value to check (string or array)
773
+ * @param string $regex Regular expression to use
774
+ * @param string $country Country code (defaults to 'all')
775
+ * @return boolean Success
776
+ * @access public
777
+ */
778
+ function phone($check, $regex = null, $country = 'all') {
779
+ $_this = & Wpcf_Cake_Validation::getInstance();
780
+ $_this->check = $check;
781
+ $_this->regex = $regex;
782
+ $_this->country = $country;
783
+ if (is_array($check)) {
784
+ $_this->_extract($check);
785
+ }
786
+
787
+ if (is_null($_this->regex)) {
788
+ switch ($_this->country) {
789
+ case 'us':
790
+ case 'all':
791
+ case 'can':
792
+ // includes all NANPA members. see http://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories
793
+ $_this->regex = '/^(?:\+?1)?[-. ]?\\(?[2-9][0-8][0-9]\\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}$/';
794
+ break;
795
+ }
796
+ }
797
+ if (empty($_this->regex)) {
798
+ return $_this->_pass('phone', $check, $country);
799
+ }
800
+ return $_this->_check();
801
+ }
802
+
803
+ /**
804
+ * Checks that a given value is a valid postal code.
805
+ *
806
+ * @param mixed $check Value to check
807
+ * @param string $regex Regular expression to use
808
+ * @param string $country Country to use for formatting
809
+ * @return boolean Success
810
+ * @access public
811
+ */
812
+ function postal($check, $regex = null, $country = null) {
813
+ $_this = & Wpcf_Cake_Validation::getInstance();
814
+ $_this->check = $check;
815
+ $_this->regex = $regex;
816
+ $_this->country = $country;
817
+ if (is_array($check)) {
818
+ $_this->_extract($check);
819
+ }
820
+ if (empty($country)) {
821
+ $_this->country = 'us';
822
+ }
823
+
824
+ if (is_null($_this->regex)) {
825
+ switch ($_this->country) {
826
+ case 'uk':
827
+ $_this->regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i';
828
+ break;
829
+ case 'ca':
830
+ $_this->regex = '/\\A\\b[ABCEGHJKLMNPRSTVXY][0-9][A-Z] ?[0-9][A-Z][0-9]\\b\\z/i';
831
+ break;
832
+ case 'it':
833
+ case 'de':
834
+ $_this->regex = '/^[0-9]{5}$/i';
835
+ break;
836
+ case 'be':
837
+ $_this->regex = '/^[1-9]{1}[0-9]{3}$/i';
838
+ break;
839
+ case 'us':
840
+ $_this->regex = '/\\A\\b[0-9]{5}(?:-[0-9]{4})?\\b\\z/i';
841
+ break;
842
+ }
843
+ }
844
+ if (empty($_this->regex)) {
845
+ return $_this->_pass('postal', $check, $country);
846
+ }
847
+ return $_this->_check();
848
+ }
849
+
850
+ /**
851
+ * Validate that a number is in specified range.
852
+ * if $lower and $upper are not set, will return true if
853
+ * $check is a legal finite on this platform
854
+ *
855
+ * @param string $check Value to check
856
+ * @param integer $lower Lower limit
857
+ * @param integer $upper Upper limit
858
+ * @return boolean Success
859
+ * @access public
860
+ */
861
+ function range($check, $lower = null, $upper = null) {
862
+ if (!is_numeric($check)) {
863
+ return false;
864
+ }
865
+ if (isset($lower) && isset($upper)) {
866
+ return ($check > $lower && $check < $upper);
867
+ }
868
+ return is_finite($check);
869
+ }
870
+
871
+ /**
872
+ * Checks that a value is a valid Social Security Number.
873
+ *
874
+ * @param mixed $check Value to check
875
+ * @param string $regex Regular expression to use
876
+ * @param string $country Country
877
+ * @return boolean Success
878
+ * @access public
879
+ */
880
+ function ssn($check, $regex = null, $country = null) {
881
+ $_this = & Wpcf_Cake_Validation::getInstance();
882
+ $_this->check = $check;
883
+ $_this->regex = $regex;
884
+ $_this->country = $country;
885
+ if (is_array($check)) {
886
+ $_this->_extract($check);
887
+ }
888
+
889
+ if (is_null($_this->regex)) {
890
+ switch ($_this->country) {
891
+ case 'dk':
892
+ $_this->regex = '/\\A\\b[0-9]{6}-[0-9]{4}\\b\\z/i';
893
+ break;
894
+ case 'nl':
895
+ $_this->regex = '/\\A\\b[0-9]{9}\\b\\z/i';
896
+ break;
897
+ case 'us':
898
+ $_this->regex = '/\\A\\b[0-9]{3}-[0-9]{2}-[0-9]{4}\\b\\z/i';
899
+ break;
900
+ }
901
+ }
902
+ if (empty($_this->regex)) {
903
+ return $_this->_pass('ssn', $check, $country);
904
+ }
905
+ return $_this->_check();
906
+ }
907
+
908
+ /**
909
+ * Checks that a value is a valid uuid - http://tools.ietf.org/html/rfc4122
910
+ *
911
+ * @param string $check Value to check
912
+ * @return boolean Success
913
+ * @access public
914
+ */
915
+ function uuid($check) {
916
+ $_this = & Wpcf_Cake_Validation::getInstance();
917
+ $_this->check = $check;
918
+ $_this->regex = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i';
919
+ return $_this->_check();
920
+ }
921
+
922
+ /**
923
+ * Checks that a value is a valid URL according to http://www.w3.org/Addressing/URL/url-spec.txt
924
+ *
925
+ * The regex checks for the following component parts:
926
+ *
927
+ * - a valid, optional, scheme
928
+ * - a valid ip address OR
929
+ * a valid domain name as defined by section 2.3.1 of http://www.ietf.org/rfc/rfc1035.txt
930
+ * with an optional port number
931
+ * - an optional valid path
932
+ * - an optional query string (get parameters)
933
+ * - an optional fragment (anchor tag)
934
+ *
935
+ * @param string $check Value to check
936
+ * @param boolean $strict Require URL to be prefixed by a valid scheme (one of http(s)/ftp(s)/file/news/gopher)
937
+ * @return boolean Success
938
+ * @access public
939
+ */
940
+ function url($check, $strict = false) {
941
+ $_this = & Wpcf_Cake_Validation::getInstance();
942
+ $_this->__populateIp();
943
+ $_this->check = $check;
944
+ $validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~[]') . '\/0-9a-z\p{L}\p{N}]|(%[0-9a-f]{2}))';
945
+ $_this->regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
946
+ '(?:' . $_this->__pattern['IPv4'] . '|\[' . $_this->__pattern['IPv6'] . '\]|' . $_this->__pattern['hostname'] . ')' .
947
+ '(?::[1-9][0-9]{0,4})?' .
948
+ '(?:\/?|\/' . $validChars . '*)?' .
949
+ '(?:\?' . $validChars . '*)?' .
950
+ '(?:#' . $validChars . '*)?$/iu';
951
+ return $_this->_check();
952
+ }
953
+
954
+ /**
955
+ * Checks if a value is in a given list.
956
+ *
957
+ * @param string $check Value to check
958
+ * @param array $list List to check against
959
+ * @return boolean Succcess
960
+ * @access public
961
+ */
962
+ function inList($check, $list) {
963
+ return in_array($check, $list);
964
+ }
965
+
966
+ /**
967
+ * Runs an user-defined validation.
968
+ *
969
+ * @param mixed $check value that will be validated in user-defined methods.
970
+ * @param object $object class that holds validation method
971
+ * @param string $method class method name for validation to run
972
+ * @param array $args arguments to send to method
973
+ * @return mixed user-defined class class method returns
974
+ * @access public
975
+ */
976
+ function userDefined($check, $object, $method, $args = null) {
977
+ return call_user_func_array(array(&$object, $method), array($check, $args));
978
+ }
979
+
980
+ function noSpecialChars($check) {
981
+ return preg_match('#[^a-zA-Z0-9\s\_\-]#', $check) ? false : true;
982
+ }
983
+
984
+ function rewriteSlug($check) {
985
+ return preg_match('#[^a-zA-Z0-9\s\_\-\%]#', $check) ? false : true;
986
+ }
987
+
988
+ /**
989
+ * Attempts to pass unhandled Validation locales to a class starting with $classPrefix
990
+ * and ending with Validation. For example $classPrefix = 'nl', the class would be
991
+ * `NlValidation`.
992
+ *
993
+ * @param string $method The method to call on the other class.
994
+ * @param mixed $check The value to check or an array of parameters for the method to be called.
995
+ * @param string $classPrefix The prefix for the class to do the validation.
996
+ * @return mixed Return of Passed method, false on failure
997
+ * @access protected
998
+ * */
999
+ function _pass($method, $check, $classPrefix) {
1000
+ $className = ucwords($classPrefix) . 'Validation';
1001
+ if (!class_exists($className)) {
1002
+ trigger_error(sprintf(__('Could not find %s class, unable to complete validation.', true), $className), E_USER_WARNING);
1003
+ return false;
1004
+ }
1005
+ if (!is_callable(array($className, $method))) {
1006
+ trigger_error(sprintf(__('Method %s does not exist on %s unable to complete validation.', true), $method, $className), E_USER_WARNING);
1007
+ return false;
1008
+ }
1009
+ $check = (array) $check;
1010
+ return call_user_func_array(array($className, $method), $check);
1011
+ }
1012
+
1013
+ /**
1014
+ * Runs a regular expression match.
1015
+ *
1016
+ * @return boolean Success of match
1017
+ * @access protected
1018
+ */
1019
+ function _check() {
1020
+ $_this = & Wpcf_Cake_Validation::getInstance();
1021
+ if (preg_match($_this->regex, $_this->check)) {
1022
+ $_this->error[] = false;
1023
+ return true;
1024
+ } else {
1025
+ $_this->error[] = true;
1026
+ return false;
1027
+ }
1028
+ }
1029
+
1030
+ /**
1031
+ * Get the values to use when value sent to validation method is
1032
+ * an array.
1033
+ *
1034
+ * @param array $params Parameters sent to validation method
1035
+ * @return void
1036
+ * @access protected
1037
+ */
1038
+ function _extract($params) {
1039
+ $_this = & Wpcf_Cake_Validation::getInstance();
1040
+ extract($params, EXTR_OVERWRITE);
1041
+
1042
+ if (isset($check)) {
1043
+ $_this->check = $check;
1044
+ }
1045
+ if (isset($regex)) {
1046
+ $_this->regex = $regex;
1047
+ }
1048
+ if (isset($country)) {
1049
+ $_this->country = strtolower($country);
1050
+ }
1051
+ if (isset($deep)) {
1052
+ $_this->deep = $deep;
1053
+ }
1054
+ if (isset($type)) {
1055
+ $_this->type = $type;
1056
+ }
1057
+ }
1058
+
1059
+ /**
1060
+ * Luhn algorithm
1061
+ *
1062
+ * @see http://en.wikipedia.org/wiki/Luhn_algorithm
1063
+ * @return boolean Success
1064
+ * @access protected
1065
+ */
1066
+ function _luhn() {
1067
+ $_this = & Wpcf_Cake_Validation::getInstance();
1068
+ if ($_this->deep !== true) {
1069
+ return true;
1070
+ }
1071
+ if ($_this->check == 0) {
1072
+ return false;
1073
+ }
1074
+ $sum = 0;
1075
+ $length = strlen($_this->check);
1076
+
1077
+ for ($position = 1 - ($length % 2); $position < $length; $position += 2) {
1078
+ $sum += $_this->check[$position];
1079
+ }
1080
+
1081
+ for ($position = ($length % 2); $position < $length; $position += 2) {
1082
+ $number = $_this->check[$position] * 2;
1083
+ $sum += ($number < 10) ? $number : $number - 9;
1084
+ }
1085
+
1086
+ return ($sum % 10 == 0);
1087
+ }
1088
+
1089
+ /*
1090
+ * Lazily popualate the IP address patterns used for validations
1091
+ *
1092
+ * @return void
1093
+ * @access private
1094
+ */
1095
+
1096
+ function __populateIp() {
1097
+ if (!isset($this->__pattern['IPv6'])) {
1098
+ $pattern = '((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}';
1099
+ $pattern .= '(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})';
1100
+ $pattern .= '|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})';
1101
+ $pattern .= '(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)';
1102
+ $pattern .= '{4}(:[0-9A-Fa-f]{1,4}){0,1}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2}))';
1103
+ $pattern .= '{3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}';
1104
+ $pattern .= '((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|';
1105
+ $pattern .= '((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}';
1106
+ $pattern .= '((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2}))';
1107
+ $pattern .= '{3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)(:[0-9A-Fa-f]{1,4})';
1108
+ $pattern .= '{0,4}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)';
1109
+ $pattern .= '|((:[0-9A-Fa-f]{1,4}){1,2})))|(:(:[0-9A-Fa-f]{1,4}){0,5}((:((25[0-5]|2[0-4]';
1110
+ $pattern .= '\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4})';
1111
+ $pattern .= '{1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?';
1112
+
1113
+ $this->__pattern['IPv6'] = $pattern;
1114
+ }
1115
+ if (!isset($this->__pattern['IPv4'])) {
1116
+ $pattern = '(?:(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|(?:(?:1[0-9])?|[1-9]?)[0-9])';
1117
+ $this->__pattern['IPv4'] = $pattern;
1118
+ }
1119
+ }
1120
+
1121
+ /**
1122
+ * Reset internal variables for another validation run.
1123
+ *
1124
+ * @return void
1125
+ * @access private
1126
+ */
1127
+ function __reset() {
1128
+ $this->check = null;
1129
+ $this->regex = null;
1130
+ $this->country = null;
1131
+ $this->deep = null;
1132
+ $this->type = null;
1133
+ $this->error = array();
1134
+ $this->errors = array();
1135
+ }
1136
+
1137
+ }
1138
+
1139
  }
embedded/common/debug/debug-information.php CHANGED
@@ -3,10 +3,6 @@
3
  /**
4
  * produce debug information
5
  *
6
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/debug/debug-information.php $
7
- * $LastChangedDate: 2014-08-13 03:38:06 +0200 (Wed, 13 Aug 2014) $
8
- * $LastChangedRevision: 25892 $
9
- * $LastChangedBy: bruce $
10
  *
11
  */
12
 
3
  /**
4
  * produce debug information
5
  *
 
 
 
 
6
  *
7
  */
8
 
embedded/common/debug/functions_debug_information.php CHANGED
@@ -2,10 +2,6 @@
2
  /**
3
  * produce debug information
4
  *
5
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/debug/functions_debug_information.php $
6
- * $LastChangedDate: 2014-08-12 17:40:07 +0200 (Tue, 12 Aug 2014) $
7
- * $LastChangedRevision: 25886 $
8
- * $LastChangedBy: marcin $
9
  *
10
  */
11
 
@@ -23,7 +19,7 @@ class ICL_Debug_Information
23
  if (empty($info)) {
24
  $info = array('core', 'plugins', 'theme', 'extra-debug');
25
  }
26
-
27
  $output = array();
28
  foreach ($info as $type) {
29
  switch ($type) {
@@ -42,12 +38,17 @@ class ICL_Debug_Information
42
  }
43
  }
44
  return $output;
45
- }
46
-
 
 
 
 
 
47
  function get_core_info() {
48
-
49
  global $wpdb;
50
-
51
  $core = array(
52
  'Wordpress' => array(
53
  'Multisite' => is_multisite() ? 'Yes' : 'No',
@@ -77,12 +78,12 @@ class ICL_Debug_Information
77
  }
78
 
79
  function get_plugins_info() {
80
-
81
  if ( ! function_exists( 'get_plugins' ) ) {
82
  $admin_includes_path = str_replace( site_url('/', 'admin'), ABSPATH, admin_url('includes/', 'admin') );
83
  require_once $admin_includes_path . 'plugin.php';
84
  }
85
-
86
  $plugins = get_plugins();
87
  $active_plugins = get_option('active_plugins');
88
  $active_plugins_info = array();
@@ -92,7 +93,7 @@ class ICL_Debug_Information
92
  $active_plugins_info[$plugin] = $plugins[$plugin];
93
  }
94
  }
95
-
96
  $mu_plugins = get_mu_plugins();
97
 
98
  $dropins = get_dropins();
@@ -102,12 +103,12 @@ class ICL_Debug_Information
102
  'mu_plugins' => $mu_plugins,
103
  'dropins' => $dropins,
104
  );
105
-
106
  return $output;
107
  }
108
-
109
  function get_theme_info() {
110
-
111
  if ( get_bloginfo( 'version' ) < '3.4' ) {
112
  $current_theme = get_theme_data( get_stylesheet_directory() . '/style.css' );
113
  $theme = $current_theme;
@@ -127,28 +128,33 @@ class ICL_Debug_Information
127
  'DomainPath' => $current_theme->DomainPath,
128
  );
129
  }
130
-
131
  return $theme;
132
  }
133
 
134
 
135
- function do_json_encode($data) {
136
- $json_options = 0;
137
- if (defined('JSON_HEX_TAG')) {
138
- $json_options += JSON_HEX_TAG;
139
- }
140
- if (defined('JSON_HEX_APOS')) {
141
- $json_options += JSON_HEX_APOS;
142
- }
143
- if (defined('JSON_HEX_QUOT')) {
144
- $json_options += JSON_HEX_QUOT;
145
- }
146
- if (defined('JSON_HEX_AMP')) {
147
- $json_options += JSON_HEX_AMP;
148
- }
149
- if (defined('JSON_UNESCAPED_UNICODE')) {
150
- $json_options += JSON_UNESCAPED_UNICODE;
151
- }
152
- return json_encode($data, $json_options);
153
- }
 
 
 
 
 
154
  }
2
  /**
3
  * produce debug information
4
  *
 
 
 
 
5
  *
6
  */
7
 
19
  if (empty($info)) {
20
  $info = array('core', 'plugins', 'theme', 'extra-debug');
21
  }
22
+
23
  $output = array();
24
  foreach ($info as $type) {
25
  switch ($type) {
38
  }
39
  }
40
  return $output;
41
+ }
42
+
43
+ /**
44
+ *
45
+ * @global object $wpdb
46
+ *
47
+ */
48
  function get_core_info() {
49
+
50
  global $wpdb;
51
+
52
  $core = array(
53
  'Wordpress' => array(
54
  'Multisite' => is_multisite() ? 'Yes' : 'No',
78
  }
79
 
80
  function get_plugins_info() {
81
+
82
  if ( ! function_exists( 'get_plugins' ) ) {
83
  $admin_includes_path = str_replace( site_url('/', 'admin'), ABSPATH, admin_url('includes/', 'admin') );
84
  require_once $admin_includes_path . 'plugin.php';
85
  }
86
+
87
  $plugins = get_plugins();
88
  $active_plugins = get_option('active_plugins');
89
  $active_plugins_info = array();
93
  $active_plugins_info[$plugin] = $plugins[$plugin];
94
  }
95
  }
96
+
97
  $mu_plugins = get_mu_plugins();
98
 
99
  $dropins = get_dropins();
103
  'mu_plugins' => $mu_plugins,
104
  'dropins' => $dropins,
105
  );
106
+
107
  return $output;
108
  }
109
+
110
  function get_theme_info() {
111
+
112
  if ( get_bloginfo( 'version' ) < '3.4' ) {
113
  $current_theme = get_theme_data( get_stylesheet_directory() . '/style.css' );
114
  $theme = $current_theme;
128
  'DomainPath' => $current_theme->DomainPath,
129
  );
130
  }
131
+
132
  return $theme;
133
  }
134
 
135
 
136
+ function do_json_encode($data)
137
+ {
138
+ if (version_compare(phpversion(), '5.3.0', '<')) {
139
+ return json_encode($data);
140
+ }
141
+ $json_options = 0;
142
+ if (defined('JSON_HEX_TAG')) {
143
+ $json_options += JSON_HEX_TAG;
144
+ }
145
+ if (defined('JSON_HEX_APOS')) {
146
+ $json_options += JSON_HEX_APOS;
147
+ }
148
+ if (defined('JSON_HEX_QUOT')) {
149
+ $json_options += JSON_HEX_QUOT;
150
+ }
151
+ if (defined('JSON_HEX_AMP')) {
152
+ $json_options += JSON_HEX_AMP;
153
+ }
154
+ if (defined('JSON_UNESCAPED_UNICODE')) {
155
+ $json_options += JSON_UNESCAPED_UNICODE;
156
+ }
157
+ return json_encode($data, $json_options);
158
+ }
159
+
160
  }
embedded/common/expression-parser/js/parser.js CHANGED
@@ -1602,14 +1602,14 @@ window.ToolsetParser=window.ToolsetParser ||
1602
  if (varTmp != "RAND")
1603
  {
1604
  if (arrArgs.length < 1)
1605
- throw varTmp + " requires atleast one argument!";
1606
  else if (arrArgs.length > 1)
1607
  throw varTmp + " requires only one argument!";
1608
  }
1609
  else
1610
  {
1611
  if (arrArgs.length < 1)
1612
- throw varTmp + " requires atleast one argument!";
1613
  else if (arrArgs.length > 2)
1614
  throw varTmp + " requires at most two arguments!";
1615
  }
@@ -1687,7 +1687,7 @@ window.ToolsetParser=window.ToolsetParser ||
1687
  break;
1688
  case "STR" :
1689
  if (arrArgs.length < 1)
1690
- throw varTmp + " requires atleast one argument!";
1691
  else if (arrArgs.length > 2)
1692
  throw varTmp + " requires at most two arguments!";
1693
  varTerm = arrArgs[arrArgs.length-1];
@@ -1729,7 +1729,7 @@ window.ToolsetParser=window.ToolsetParser ||
1729
  if (arrArgs.length > 1)
1730
  throw varTmp + " requires only one argument!";
1731
  else if (arrArgs.length < 1)
1732
- throw varTmp + " requires atleast one argument!";
1733
  varTerm = arrArgs[0];
1734
  if (varTerm.isVariable)
1735
  {
@@ -1758,7 +1758,7 @@ window.ToolsetParser=window.ToolsetParser ||
1758
  break;
1759
  case "REGEX" :
1760
  if (arrArgs.length < 1)
1761
- throw varTmp + " requires atleast one argument!";
1762
  else if (arrArgs.length > 2)
1763
  throw varTmp + " requires at most two arguments!";
1764
 
@@ -1798,7 +1798,7 @@ window.ToolsetParser=window.ToolsetParser ||
1798
  case "NUM" :
1799
 
1800
  if (arrArgs.length < 1)
1801
- throw varTmp + " requires atleast one argument!";
1802
  else if (arrArgs.length > 1)
1803
  throw varTmp + " requires only one argument!";
1804
 
@@ -1841,7 +1841,7 @@ window.ToolsetParser=window.ToolsetParser ||
1841
  break;
1842
  case "LEN" :
1843
  if (arrArgs.length < 1)
1844
- throw varTmp + " requires atleast one argument!";
1845
  else if (arrArgs.length > 1)
1846
  throw varTmp + " requires only one argument!";
1847
 
@@ -1864,7 +1864,7 @@ window.ToolsetParser=window.ToolsetParser ||
1864
  break;
1865
  case "USER" :
1866
  if (arrArgs.length < 1)
1867
- throw varTmp + " requires atleast one argument!";
1868
  else if (arrArgs.length > 1)
1869
  throw varTmp + " requires only one argument!";
1870
 
@@ -1887,7 +1887,7 @@ window.ToolsetParser=window.ToolsetParser ||
1887
  break;
1888
  case "COOKIE" :
1889
  if (arrArgs.length < 1)
1890
- throw varTmp + " requires atleast one argument!";
1891
  else if (arrArgs.length > 1)
1892
  throw varTmp + " requires only one argument!";
1893
 
@@ -1912,7 +1912,7 @@ window.ToolsetParser=window.ToolsetParser ||
1912
  case "CONTAINS" :
1913
  // console.log( 'testing functions ', varTmp, arrArgs );
1914
  if (arrArgs.length < 2)
1915
- throw varTmp + " requires atleast two arguments!";
1916
  else if (arrArgs.length > 2)
1917
  throw varTmp + " requires only two arguments!";
1918
 
@@ -1955,7 +1955,7 @@ window.ToolsetParser=window.ToolsetParser ||
1955
  break;
1956
  case "DATE" :
1957
  if (arrArgs.length < 2)
1958
- throw varTmp + " requires atleast two arguments!";
1959
  else if (arrArgs.length > 2)
1960
  throw varTmp + " requires only two arguments!";
1961
 
@@ -2030,7 +2030,7 @@ window.ToolsetParser=window.ToolsetParser ||
2030
  case "LEFT" :
2031
  case "RIGHT" :
2032
  if (arrArgs.length < 2)
2033
- throw varTmp + " requires atleast two arguments!";
2034
  else if (arrArgs.length > 2)
2035
  throw varTmp + " requires only two arguments!";
2036
 
@@ -2073,7 +2073,7 @@ window.ToolsetParser=window.ToolsetParser ||
2073
  case "IIF" :
2074
 
2075
  if (arrArgs.length < 3)
2076
- throw varTmp + " requires atleast three arguments!";
2077
  else if (arrArgs.length > 3)
2078
  throw varTmp + " requires only three arguments!";
2079
 
@@ -2134,7 +2134,7 @@ window.ToolsetParser=window.ToolsetParser ||
2134
  case "MAX" :
2135
  case "MIN" :
2136
  if (arrArgs.length < 1)
2137
- throw varTmp + " requires atleast one operand!";
2138
 
2139
  var _arr=[];
2140
  intCntr = arrArgs.length;
1602
  if (varTmp != "RAND")
1603
  {
1604
  if (arrArgs.length < 1)
1605
+ throw varTmp + " requires at least one argument!";
1606
  else if (arrArgs.length > 1)
1607
  throw varTmp + " requires only one argument!";
1608
  }
1609
  else
1610
  {
1611
  if (arrArgs.length < 1)
1612
+ throw varTmp + " requires at least one argument!";
1613
  else if (arrArgs.length > 2)
1614
  throw varTmp + " requires at most two arguments!";
1615
  }
1687
  break;
1688
  case "STR" :
1689
  if (arrArgs.length < 1)
1690
+ throw varTmp + " requires at least one argument!";
1691
  else if (arrArgs.length > 2)
1692
  throw varTmp + " requires at most two arguments!";
1693
  varTerm = arrArgs[arrArgs.length-1];
1729
  if (arrArgs.length > 1)
1730
  throw varTmp + " requires only one argument!";
1731
  else if (arrArgs.length < 1)
1732
+ throw varTmp + " requires at least one argument!";
1733
  varTerm = arrArgs[0];
1734
  if (varTerm.isVariable)
1735
  {
1758
  break;
1759
  case "REGEX" :
1760
  if (arrArgs.length < 1)
1761
+ throw varTmp + " requires at least one argument!";
1762
  else if (arrArgs.length > 2)
1763
  throw varTmp + " requires at most two arguments!";
1764
 
1798
  case "NUM" :
1799
 
1800
  if (arrArgs.length < 1)
1801
+ throw varTmp + " requires at least one argument!";
1802
  else if (arrArgs.length > 1)
1803
  throw varTmp + " requires only one argument!";
1804
 
1841
  break;
1842
  case "LEN" :
1843
  if (arrArgs.length < 1)
1844
+ throw varTmp + " requires at least one argument!";
1845
  else if (arrArgs.length > 1)
1846
  throw varTmp + " requires only one argument!";
1847
 
1864
  break;
1865
  case "USER" :
1866
  if (arrArgs.length < 1)
1867
+ throw varTmp + " requires at least one argument!";
1868
  else if (arrArgs.length > 1)
1869
  throw varTmp + " requires only one argument!";
1870
 
1887
  break;
1888
  case "COOKIE" :
1889
  if (arrArgs.length < 1)
1890
+ throw varTmp + " requires at least one argument!";
1891
  else if (arrArgs.length > 1)
1892
  throw varTmp + " requires only one argument!";
1893
 
1912
  case "CONTAINS" :
1913
  // console.log( 'testing functions ', varTmp, arrArgs );
1914
  if (arrArgs.length < 2)
1915
+ throw varTmp + " requires at least two arguments!";
1916
  else if (arrArgs.length > 2)
1917
  throw varTmp + " requires only two arguments!";
1918
 
1955
  break;
1956
  case "DATE" :
1957
  if (arrArgs.length < 2)
1958
+ throw varTmp + " requires at least two arguments!";
1959
  else if (arrArgs.length > 2)
1960
  throw varTmp + " requires only two arguments!";
1961
 
2030
  case "LEFT" :
2031
  case "RIGHT" :
2032
  if (arrArgs.length < 2)
2033
+ throw varTmp + " requires at least two arguments!";
2034
  else if (arrArgs.length > 2)
2035
  throw varTmp + " requires only two arguments!";
2036
 
2073
  case "IIF" :
2074
 
2075
  if (arrArgs.length < 3)
2076
+ throw varTmp + " requires at least three arguments!";
2077
  else if (arrArgs.length > 3)
2078
  throw varTmp + " requires only three arguments!";
2079
 
2134
  case "MAX" :
2135
  case "MIN" :
2136
  if (arrArgs.length < 1)
2137
+ throw varTmp + " requires at least one operand!";
2138
 
2139
  var _arr=[];
2140
  intCntr = arrArgs.length;
embedded/common/expression-parser/parser.php CHANGED
@@ -1639,14 +1639,14 @@ class Toolset_Parser
1639
  if ($varTmp != "RAND")
1640
  {
1641
  if (count($arrArgs) < 1)
1642
- throw new Exception($varTmp . " requires atleast one argument!");
1643
  else if (count($arrArgs) > 1)
1644
  throw new Exception($varTmp . " requires only one argument!");
1645
  }
1646
  else
1647
  {
1648
  if (count($arrArgs) < 1)
1649
- throw new Exception($varTmp . " requires atleast one argument!");
1650
  else if (count($arrArgs) > 2)
1651
  throw new Exception($varTmp . " requires at most two arguments!");
1652
  }
@@ -1717,7 +1717,7 @@ class Toolset_Parser
1717
  break;
1718
  case "STR" :
1719
  if (count($arrArgs) < 1)
1720
- throw new Exception($varTmp . " requires atleast one argument!");
1721
  else if (count($arrArgs) > 2)
1722
  throw new Exception($varTmp . " requires at most two arguments!");
1723
  $varTerm = $arrArgs[count($arrArgs)-1];
@@ -1756,7 +1756,7 @@ class Toolset_Parser
1756
  if (count($arrArgs) > 1)
1757
  throw new Exception($varTmp . " requires only one argument!");
1758
  else if (count($arrArgs) < 1)
1759
- throw new Exception($varTmp . " requires atleast one argument!");
1760
  $varTerm = $arrArgs[0];
1761
  if ($varTerm->isVariable)
1762
  {
@@ -1791,7 +1791,7 @@ class Toolset_Parser
1791
  break;
1792
  case "REGEX" :
1793
  if (count($arrArgs) < 1)
1794
- throw new Exception($varTmp . " requires atleast one argument!");
1795
  else if (count($arrArgs) > 2)
1796
  throw new Exception($varTmp . " requires at most two arguments!");
1797
 
@@ -1828,7 +1828,7 @@ class Toolset_Parser
1828
  case "UCASE" :
1829
  case "NUM" :
1830
  if (count($arrArgs) < 1)
1831
- throw new Exception($varTmp . " requires atleast one argument!");
1832
  else if (count($arrArgs) > 1)
1833
  throw new Exception($varTmp . " requires only one argument!");
1834
 
@@ -1870,7 +1870,7 @@ class Toolset_Parser
1870
  break;
1871
  case "LEN" :
1872
  if (count($arrArgs) < 1)
1873
- throw new Exception($varTmp . " requires atleast one argument!");
1874
  else if (count($arrArgs) > 1)
1875
  throw new Exception($varTmp . " requires only one argument!");
1876
 
@@ -1895,7 +1895,7 @@ class Toolset_Parser
1895
  break;
1896
  case "USER" :
1897
  if (count($arrArgs) < 1)
1898
- throw new Exception($varTmp . " requires atleast one argument!");
1899
  else if (count($arrArgs) > 1)
1900
  throw new Exception($varTmp . " requires only one argument!");
1901
 
@@ -1917,7 +1917,7 @@ class Toolset_Parser
1917
  break;
1918
  case "COOKIE" :
1919
  if (count($arrArgs) < 1)
1920
- throw new Exception($varTmp . " requires atleast one argument!");
1921
  else if (count($arrArgs) > 1)
1922
  throw new Exception($varTmp . " requires only one argument!");
1923
 
@@ -1939,7 +1939,7 @@ class Toolset_Parser
1939
  break;
1940
  case "CONTAINS" :
1941
  if (count($arrArgs) < 2)
1942
- throw new Exception($varTmp . " requires atleast two arguments!");
1943
  else if (count($arrArgs) > 2)
1944
  throw new Exception($varTmp . " requires only two arguments!");
1945
 
@@ -1970,7 +1970,7 @@ class Toolset_Parser
1970
  break;
1971
  case "DATE" :
1972
  if (count($arrArgs) < 2)
1973
- throw new Exception($varTmp . " requires atleast two arguments!");
1974
  else if (count($arrArgs) > 2)
1975
  throw new Exception($varTmp . " requires only two arguments!");
1976
 
@@ -2010,7 +2010,7 @@ class Toolset_Parser
2010
  case "empty" :
2011
  case "EMPTY" :
2012
  if (count($arrArgs) < 1)
2013
- throw new Exception($varTmp . " requires atleast one argument!");
2014
  else if (count($arrArgs) > 1)
2015
  throw new Exception($varTmp . " requires only one arguments!");
2016
 
@@ -2041,7 +2041,7 @@ class Toolset_Parser
2041
  case "LEFT" :
2042
  case "RIGHT" :
2043
  if (count($arrArgs) < 2)
2044
- throw new Exception($varTmp . " requires atleast two arguments!");
2045
  else if (count($arrArgs) > 2)
2046
  throw new Exception($varTmp . " requires only two arguments!");
2047
 
@@ -2082,7 +2082,7 @@ class Toolset_Parser
2082
  case "MID" :
2083
  case "IIF" :
2084
  if (count($arrArgs) < 3)
2085
- throw new Exception($varTmp . " requires atleast three arguments!");
2086
  else if (count($arrArgs) > 3)
2087
  throw new Exception($varTmp . " requires only three arguments!");
2088
 
@@ -2132,7 +2132,7 @@ class Toolset_Parser
2132
  case "MAX" :
2133
  case "MIN" :
2134
  if (count($arrArgs) < 1)
2135
- throw new Exception($varTmp . " requires atleast one operand!");
2136
 
2137
  $_arr=array();
2138
  $intCntr = count($arrArgs);
1639
  if ($varTmp != "RAND")
1640
  {
1641
  if (count($arrArgs) < 1)
1642
+ throw new Exception($varTmp . " requires at least one argument!");
1643
  else if (count($arrArgs) > 1)
1644
  throw new Exception($varTmp . " requires only one argument!");
1645
  }
1646
  else
1647
  {
1648
  if (count($arrArgs) < 1)
1649
+ throw new Exception($varTmp . " requires at least one argument!");
1650
  else if (count($arrArgs) > 2)
1651
  throw new Exception($varTmp . " requires at most two arguments!");
1652
  }
1717
  break;
1718
  case "STR" :
1719
  if (count($arrArgs) < 1)
1720
+ throw new Exception($varTmp . " requires at least one argument!");
1721
  else if (count($arrArgs) > 2)
1722
  throw new Exception($varTmp . " requires at most two arguments!");
1723
  $varTerm = $arrArgs[count($arrArgs)-1];
1756
  if (count($arrArgs) > 1)
1757
  throw new Exception($varTmp . " requires only one argument!");
1758
  else if (count($arrArgs) < 1)
1759
+ throw new Exception($varTmp . " requires at least one argument!");
1760
  $varTerm = $arrArgs[0];
1761
  if ($varTerm->isVariable)
1762
  {
1791
  break;
1792
  case "REGEX" :
1793
  if (count($arrArgs) < 1)
1794
+ throw new Exception($varTmp . " requires at least one argument!");
1795
  else if (count($arrArgs) > 2)
1796
  throw new Exception($varTmp . " requires at most two arguments!");
1797
 
1828
  case "UCASE" :
1829
  case "NUM" :
1830
  if (count($arrArgs) < 1)
1831
+ throw new Exception($varTmp . " requires at least one argument!");
1832
  else if (count($arrArgs) > 1)
1833
  throw new Exception($varTmp . " requires only one argument!");
1834
 
1870
  break;
1871
  case "LEN" :
1872
  if (count($arrArgs) < 1)
1873
+ throw new Exception($varTmp . " requires at least one argument!");
1874
  else if (count($arrArgs) > 1)
1875
  throw new Exception($varTmp . " requires only one argument!");
1876
 
1895
  break;
1896
  case "USER" :
1897
  if (count($arrArgs) < 1)
1898
+ throw new Exception($varTmp . " requires at least one argument!");
1899
  else if (count($arrArgs) > 1)
1900
  throw new Exception($varTmp . " requires only one argument!");
1901
 
1917
  break;
1918
  case "COOKIE" :
1919
  if (count($arrArgs) < 1)
1920
+ throw new Exception($varTmp . " requires at least one argument!");
1921
  else if (count($arrArgs) > 1)
1922
  throw new Exception($varTmp . " requires only one argument!");
1923
 
1939
  break;
1940
  case "CONTAINS" :
1941
  if (count($arrArgs) < 2)
1942
+ throw new Exception($varTmp . " requires at least two arguments!");
1943
  else if (count($arrArgs) > 2)
1944
  throw new Exception($varTmp . " requires only two arguments!");
1945
 
1970
  break;
1971
  case "DATE" :
1972
  if (count($arrArgs) < 2)
1973
+ throw new Exception($varTmp . " requires at least two arguments!");
1974
  else if (count($arrArgs) > 2)
1975
  throw new Exception($varTmp . " requires only two arguments!");
1976
 
2010
  case "empty" :
2011
  case "EMPTY" :
2012
  if (count($arrArgs) < 1)
2013
+ throw new Exception($varTmp . " requires at least one argument!");
2014
  else if (count($arrArgs) > 1)
2015
  throw new Exception($varTmp . " requires only one arguments!");
2016
 
2041
  case "LEFT" :
2042
  case "RIGHT" :
2043
  if (count($arrArgs) < 2)
2044
+ throw new Exception($varTmp . " requires at least two arguments!");
2045
  else if (count($arrArgs) > 2)
2046
  throw new Exception($varTmp . " requires only two arguments!");
2047
 
2082
  case "MID" :
2083
  case "IIF" :
2084
  if (count($arrArgs) < 3)
2085
+ throw new Exception($varTmp . " requires at least three arguments!");
2086
  else if (count($arrArgs) > 3)
2087
  throw new Exception($varTmp . " requires only three arguments!");
2088
 
2132
  case "MAX" :
2133
  case "MIN" :
2134
  if (count($arrArgs) < 1)
2135
+ throw new Exception($varTmp . " requires at least one operand!");
2136
 
2137
  $_arr=array();
2138
  $intCntr = count($arrArgs);
embedded/common/functions.php CHANGED
@@ -4,6 +4,15 @@
4
  */
5
  define( 'ICL_COMMON_FUNCTIONS', true );
6
 
 
 
 
 
 
 
 
 
 
7
  /**
8
  * Calculates relative path for given file.
9
  *
@@ -11,24 +20,28 @@ define( 'ICL_COMMON_FUNCTIONS', true );
11
  * @return string Relative path
12
  */
13
  function icl_get_file_relpath( $file ) {
14
- $is_https = isset( $_SERVER['HTTPS'] ) && strtolower( $_SERVER['HTTPS'] ) == 'on';
15
- $http_protocol = $is_https ? 'https' : 'http';
16
- $base_root = $http_protocol . '://' . $_SERVER['HTTP_HOST'];
17
- $base_url = $base_root;
18
- $dir = rtrim( dirname( $file ), '\/' );
19
- if ( $dir ) {
20
- $base_path = $dir;
21
- $base_url .= $base_path;
22
- $base_path .= '/';
23
- } else {
24
- $base_path = '/';
25
- }
26
- $relpath = $base_root
27
- . str_replace(
28
- str_replace( '\\', '/',
29
- realpath( $_SERVER['DOCUMENT_ROOT'] ) )
30
- , '', str_replace( '\\', '/', dirname( $file ) )
31
- );
 
 
 
 
32
  return $relpath;
33
  }
34
 
@@ -69,6 +82,8 @@ function wpv_parse_args_recursive( $arg, $defaults ) {
69
 
70
  /*
71
  * Extra check for date for shortcode in shortcode. Called as filter in wpv_condition bellow.
 
 
72
  */
73
 
74
  function wpv_add_time_functions( $value ) {
@@ -90,6 +105,7 @@ function wpv_add_time_functions( $value ) {
90
  * empty() function that checks for blank or non-existing fields
91
  *
92
  *
 
93
  */
94
  function wpv_condition( $atts, $post_to_check = null ) {
95
  extract(
@@ -136,6 +152,8 @@ function wpv_condition( $atts, $post_to_check = null ) {
136
 
137
  add_filter( 'wpv-extra-condition-filters', 'wpv_add_time_functions' );
138
  $evaluate = apply_filters( 'wpv-extra-condition-filters', $evaluate );
 
 
139
 
140
  // evaluate empty() statements for variables
141
  if ( $has_post ) {
@@ -152,8 +170,8 @@ function wpv_condition( $atts, $post_to_check = null ) {
152
  || ( is_array( $match_var ) && empty( $match_var ) ) ) {
153
  $is_empty = '1=1';
154
  }
155
-
156
  $evaluate = str_replace( $matches[0][$i], $is_empty, $evaluate );
 
157
  }
158
  }
159
  }
@@ -172,10 +190,9 @@ function wpv_condition( $atts, $post_to_check = null ) {
172
  if ( strpos( $string, '$' ) === 0 ) {
173
  $variable_name = substr( $string, 1 ); // omit dollar sign
174
  if ( isset( $atts[$variable_name] ) ) {
175
- $string = get_post_meta( $post->ID, $atts[$variable_name],
176
- true );
177
- $evaluate = str_replace( $matches[1][$i],
178
- "'" . $string . "'", $evaluate );
179
  }
180
  }
181
  }
@@ -233,11 +250,10 @@ function wpv_condition( $atts, $post_to_check = null ) {
233
  $evaluate = str_replace( $matches[0][$i], '1=0', $evaluate );
234
  }
235
  } else {
236
- $evaluate = str_replace( $matches[1][$i], $first_string,
237
- $evaluate );
238
- $evaluate = str_replace( $matches[5][$i], $second_string,
239
- $evaluate );
240
  }
 
241
  }
242
  }
243
 
@@ -248,10 +264,10 @@ function wpv_condition( $atts, $post_to_check = null ) {
248
  for ( $i = 0; $i < $strings_count; $i++ ) {
249
  $string = $matches[1][$i];
250
  // remove single quotes from string literals to get value only
251
- $string = (strpos( $string, '\'' ) === 0) ? substr( $string, 1,
252
- strlen( $string ) - 2 ) : $string;
253
  if ( is_numeric( $string ) ) {
254
  $evaluate = str_replace( $matches[1][$i], $string, $evaluate );
 
255
  }
256
  }
257
  }
@@ -279,6 +295,7 @@ function wpv_condition( $atts, $post_to_check = null ) {
279
  $meta = "0";
280
  }
281
  $evaluate = str_replace( '$' . $match, $meta, $evaluate );
 
282
  }
283
  }
284
  }
@@ -474,7 +491,7 @@ class WPV_wpcf_switch_post_from_attr_id
474
  $this->found = true;
475
 
476
  // save original post
477
- $this->post = isset( $post ) ? clone $post : null;
478
  if ( $authordata ) {
479
  $this->authordata = clone $authordata;
480
  } else {
@@ -496,7 +513,7 @@ class WPV_wpcf_switch_post_from_attr_id
496
  global $post, $authordata, $id;
497
 
498
  // restore the global post values.
499
- $post = isset( $this->post ) ? clone $this->post : null;
500
  if ( $this->authordata ) {
501
  $authordata = clone $this->authordata;
502
  } else {
@@ -548,7 +565,8 @@ function WPV_wpcf_record_post_relationship_belongs( $content ) {
548
  /**
549
  * Form for Enlimbo calls for wpv-control shortcode calls
550
  *
551
- * @param unknown_type $elements
 
552
  */
553
  function wpv_form_control( $elements ) {
554
  static $form = NULL;
@@ -602,70 +620,3 @@ function wpv_dismiss_message_ajax() {
602
  die( 'ajax' );
603
  }
604
 
605
- // disable the admin messages for now. They are causing problems.
606
- //add_action('admin_head', 'wpv_show_admin_messages');
607
-
608
- /**
609
- * Shows stored admin messages.
610
- */
611
- function wpv_show_admin_messages() {
612
- $messages = get_option( 'wpv-messages', array() );
613
- $dismissed_messages = get_option( 'wpv-dismissed-messages', array() );
614
- foreach ( $messages as $message_id => $message ) {
615
- if ( array_key_exists( $message_id, $dismissed_messages ) ) {
616
- unset( $messages[$message_id] );
617
- continue;
618
- }
619
- // update the nonce
620
- $text = $message['message'];
621
- $nonce = preg_match_all( "/_wpnonce=[^']+/", $text, $matches );
622
-
623
- if ( $nonce ) {
624
- $text = str_replace( $matches[0][0],
625
- '_wpnonce=' . wp_create_nonce( 'dismiss_message' ), $text );
626
- }
627
-
628
- wpv_admin_message( $message_id, $text, $message['class'] );
629
- if ( $show_once ) {
630
- unset( $messages[$message_id] );
631
- }
632
- }
633
- update_option( 'wpv-messages', $messages );
634
- }
635
-
636
- /**
637
- * Stores admin messages.
638
- *
639
- * @param type $message_id
640
- * @param type $message
641
- * @param type $show_once
642
- * @param type $class
643
- */
644
- function wpv_admin_message_store( $message_id, $message, $show_once = true,
645
- $class = 'updated' ) {
646
- $messages = get_option( 'wpv-messages', array() );
647
- $messages[strval( $message_id )] = array(
648
- 'message' => strval( $message ),
649
- 'class' => strval( $class ),
650
- 'show_once' => $show_once,
651
- );
652
- update_option( 'wpv-messages', $messages );
653
- }
654
-
655
- /**
656
- * Shows admin message.
657
- *
658
- * @param type $message_id
659
- * @param type $message
660
- * @param type $class
661
- */
662
- function wpv_admin_message( $message_id, $message, $class = 'updated' ) {
663
- if ( apply_filters( 'wpv-show-message', true, $message_id ) ) {
664
- add_action( 'admin_notices',
665
- create_function( '$a=1, $message_id=\'' . strval( $message_id )
666
- . '\', $class=\'' . strval( $class )
667
- . '\', $message=\''
668
- . htmlentities( strval( $message ), ENT_QUOTES ) . '\'',
669
- '$screen = get_current_screen(); if (!$screen->is_network) echo "<div class=\"message $class\" id=\"wpv-message-$message_id\"><p>" . html_entity_decode($message, ENT_QUOTES) . "</p></div>";' ) );
670
- }
671
- }
4
  */
5
  define( 'ICL_COMMON_FUNCTIONS', true );
6
 
7
+ // for retro compatibility with WP < 3.5
8
+ if( !function_exists('wp_normalize_path') ){
9
+ function wp_normalize_path( $path ) {
10
+ $path = str_replace( '\\', '/', $path );
11
+ $path = preg_replace( '|/+|','/', $path );
12
+ return $path;
13
+ }
14
+ }
15
+
16
  /**
17
  * Calculates relative path for given file.
18
  *
20
  * @return string Relative path
21
  */
22
  function icl_get_file_relpath( $file ) {
23
+ // website url form DB
24
+ $url = get_option('siteurl');
25
+ // fix the protocol
26
+ $base_root = set_url_scheme( $url );
27
+
28
+ // normalise windows paths
29
+ $path_to_file = wp_normalize_path($file);
30
+ // get file directory
31
+ $file_dir = wp_normalize_path( dirname( $path_to_file ) );
32
+ // get the path to 'wp-content'
33
+ $from_content_dir = wp_normalize_path( realpath( WP_CONTENT_DIR ) );
34
+ // get wp-content dirname
35
+ $content_dir = wp_normalize_path( basename(WP_CONTENT_DIR) );
36
+
37
+ // remove absolute path part until 'wp-content' folder
38
+ $path = str_replace( $from_content_dir, '', $file_dir);
39
+ // add wp-content dir to path
40
+ $path = wp_normalize_path( $content_dir.$path );
41
+
42
+ // build url
43
+ $relpath = $base_root . '/' . $path;
44
+
45
  return $relpath;
46
  }
47
 
82
 
83
  /*
84
  * Extra check for date for shortcode in shortcode. Called as filter in wpv_condition bellow.
85
+ *
86
+ * @note As of 1.9 this is not used in Views anymore
87
  */
88
 
89
  function wpv_add_time_functions( $value ) {
105
  * empty() function that checks for blank or non-existing fields
106
  *
107
  *
108
+ * @note As of 1.9, this is not used in Views anymore, seems to be used on the toolset-forms library
109
  */
110
  function wpv_condition( $atts, $post_to_check = null ) {
111
  extract(
152
 
153
  add_filter( 'wpv-extra-condition-filters', 'wpv_add_time_functions' );
154
  $evaluate = apply_filters( 'wpv-extra-condition-filters', $evaluate );
155
+
156
+ $logging_string .= "; After extra conditions: " . $evaluate;
157
 
158
  // evaluate empty() statements for variables
159
  if ( $has_post ) {
170
  || ( is_array( $match_var ) && empty( $match_var ) ) ) {
171
  $is_empty = '1=1';
172
  }
 
173
  $evaluate = str_replace( $matches[0][$i], $is_empty, $evaluate );
174
+ $logging_string .= "; After empty: " . $evaluate;
175
  }
176
  }
177
  }
190
  if ( strpos( $string, '$' ) === 0 ) {
191
  $variable_name = substr( $string, 1 ); // omit dollar sign
192
  if ( isset( $atts[$variable_name] ) ) {
193
+ $string = get_post_meta( $post->ID, $atts[$variable_name], true );
194
+ $evaluate = str_replace( $matches[1][$i], "'" . $string . "'", $evaluate );
195
+ $logging_string .= "; After variables I: " . $evaluate;
 
196
  }
197
  }
198
  }
250
  $evaluate = str_replace( $matches[0][$i], '1=0', $evaluate );
251
  }
252
  } else {
253
+ $evaluate = str_replace( $matches[1][$i], $first_string, $evaluate );
254
+ $evaluate = str_replace( $matches[5][$i], $second_string, $evaluate );
 
 
255
  }
256
+ $logging_string .= "; After variables II: " . $evaluate;
257
  }
258
  }
259
 
264
  for ( $i = 0; $i < $strings_count; $i++ ) {
265
  $string = $matches[1][$i];
266
  // remove single quotes from string literals to get value only
267
+ $string = (strpos( $string, '\'' ) === 0) ? substr( $string, 1, strlen( $string ) - 2 ) : $string;
 
268
  if ( is_numeric( $string ) ) {
269
  $evaluate = str_replace( $matches[1][$i], $string, $evaluate );
270
+ $logging_string .= "; After variables III: " . $evaluate;
271
  }
272
  }
273
  }
295
  $meta = "0";
296
  }
297
  $evaluate = str_replace( '$' . $match, $meta, $evaluate );
298
+ $logging_string .= "; After variables IV: " . $evaluate;
299
  }
300
  }
301
  }
491
  $this->found = true;
492
 
493
  // save original post
494
+ $this->post = ( isset( $post ) && ( $post instanceof WP_Post ) ) ? clone $post : null;
495
  if ( $authordata ) {
496
  $this->authordata = clone $authordata;
497
  } else {
513
  global $post, $authordata, $id;
514
 
515
  // restore the global post values.
516
+ $post = ( isset( $this->post ) && ( $this->post instanceof WP_Post ) ) ? clone $this->post : null;
517
  if ( $this->authordata ) {
518
  $authordata = clone $this->authordata;
519
  } else {
565
  /**
566
  * Form for Enlimbo calls for wpv-control shortcode calls
567
  *
568
+ * @param mixed $elements
569
+ * @return string
570
  */
571
  function wpv_form_control( $elements ) {
572
  static $form = NULL;
620
  die( 'ajax' );
621
  }
622
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
embedded/common/localization/locale/views-ar.mo CHANGED
Binary file
embedded/common/localization/locale/views-de_DE.mo CHANGED
Binary file
embedded/common/localization/locale/views-el.mo CHANGED
Binary file
embedded/common/localization/locale/views-es_ES.mo CHANGED
Binary file
embedded/common/localization/locale/views-fr_FR.mo CHANGED
Binary file
embedded/common/localization/locale/views-he_IL.mo CHANGED
Binary file
embedded/common/localization/locale/views-it_IT.mo CHANGED
Binary file
embedded/common/localization/locale/views-ja.mo CHANGED
Binary file
embedded/common/localization/locale/views-ko_KR.mo CHANGED
Binary file
embedded/common/localization/locale/views-nl_NL.mo CHANGED
Binary file
embedded/common/localization/locale/views-pl_PL.mo CHANGED
Binary file
embedded/common/localization/locale/views-pt_BR.mo CHANGED
Binary file
embedded/common/localization/locale/views-pt_PT.mo CHANGED
Binary file
embedded/common/localization/locale/views-ru_RU.mo CHANGED
Binary file
embedded/common/localization/locale/views-sv_SE.mo CHANGED
Binary file
embedded/common/localization/locale/views-uk.mo ADDED
Binary file
embedded/common/localization/locale/views-vi.mo CHANGED
Binary file
embedded/common/localization/locale/views-zh_CN.mo CHANGED
Binary file
embedded/common/localization/locale/views-zh_TW.mo CHANGED
Binary file
embedded/common/res/css/colorbox.css ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* -------- */
2
+ /* Colorbox */
3
+ /* -------- */
4
+
5
+ /* This file contains styles for default Colorbox elements only */
6
+ /* TODO: This file can be removed, we can load it from common */
7
+
8
+ body.disable-scrollbar {
9
+ overflow: hidden;
10
+ }
11
+
12
+ #colorbox,
13
+ #cboxOverlay,
14
+ #cboxWrapper {
15
+ position:absolute;
16
+ top:0;
17
+ left:0;
18
+ z-index:10000;
19
+ /* overflow:hidden;*/
20
+ }
21
+
22
+ #cboxOverlay {
23
+ position:fixed;
24
+ width:100%;
25
+ max-width: 100%;
26
+ height:100%;
27
+ background: #000;
28
+ }
29
+ #cboxMiddleLeft,
30
+ #cboxBottomLeft {
31
+ clear:left;
32
+ }
33
+ #cboxContent {
34
+ position:relative;
35
+ }
36
+ #cboxLoadedContent {
37
+ overflow:visible!important;
38
+ -webkit-overflow-scrolling: touch;
39
+ }
40
+ #cboxTitle {
41
+ margin:0;
42
+ }
43
+ #cboxLoadingOverlay,
44
+ #cboxLoadingGraphic {
45
+ position:absolute;
46
+ top:0;
47
+ left:0;
48
+ width:100%;
49
+ height:100%;
50
+ }
51
+ #cboxPrevious,
52
+ #cboxNext,
53
+ #cboxClose,
54
+ #cboxSlideshow {
55
+ cursor:pointer;
56
+ }
57
+ .cboxPhoto {
58
+ display:block;
59
+ float:left;
60
+ margin:auto;
61
+ max-width:none;
62
+ border:0;
63
+ -ms-interpolation-mode:bicubic;
64
+ }
65
+ .cboxIframe {
66
+ display:block;
67
+ width:100%;
68
+ height:100%;
69
+ border:0;
70
+ }
71
+ #colorbox,
72
+ #cboxContent,
73
+ #cboxLoadedContent {
74
+ -webkit-box-sizing:content-box;
75
+ -moz-box-sizing:content-box;
76
+ box-sizing:content-box;
77
+ }
78
+
79
+ .cboxIE #cboxTopLeft,
80
+ .cboxIE #cboxTopCenter,
81
+ .cboxIE #cboxTopRight,
82
+ .cboxIE #cboxBottomLeft,
83
+ .cboxIE #cboxBottomCenter,
84
+ .cboxIE #cboxBottomRight,
85
+ .cboxIE #cboxMiddleLeft,
86
+ .cboxIE #cboxMiddleRight {
87
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);
88
+ }
embedded/common/res/css/toolset-common.css CHANGED
@@ -11,7 +11,7 @@ Toolset Primary Button Style - use with .button.button-primary-toolset classname
11
  border-color: #EF6223;
12
  -webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5), 0 1px 0 rgba(0,0,0,.15);
13
  box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5), 0 1px 0 rgba(0,0,0,.15);
14
- color: #fff;
15
  text-decoration: none;
16
  }
17
 
@@ -23,7 +23,7 @@ Toolset Primary Button Style - use with .button.button-primary-toolset classname
23
  border-color: #EF6223;
24
  -webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5);
25
  box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5);
26
- color: #fff;
27
  }
28
 
29
  .wp-core-ui .button-primary-toolset.focus,
@@ -59,4 +59,16 @@ Toolset Primary Button Style - use with .button.button-primary-toolset classname
59
  /* ----------------------------------------------------------------------------
60
  Generic CSS to be applied anywhere
61
  ---------------------------------------------------------------------------- */
62
- .padding-top-30{padding-top:30px;}
 
 
 
 
 
 
 
 
 
 
 
 
11
  border-color: #EF6223;
12
  -webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5), 0 1px 0 rgba(0,0,0,.15);
13
  box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5), 0 1px 0 rgba(0,0,0,.15);
14
+ color: #fff !important;
15
  text-decoration: none;
16
  }
17
 
23
  border-color: #EF6223;
24
  -webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5);
25
  box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5);
26
+ color: #fff !important;
27
  }
28
 
29
  .wp-core-ui .button-primary-toolset.focus,
59
  /* ----------------------------------------------------------------------------
60
  Generic CSS to be applied anywhere
61
  ---------------------------------------------------------------------------- */
62
+ .padding-top-30{padding-top:30px;}
63
+
64
+ /* ----------------------------------------------------------------------------
65
+ Design with Toolset icon
66
+ ---------------------------------------------------------------------------- */
67
+ #wpadminbar ul#wp-admin-bar-root-default> li.toolset-edit-link { white-space: nowrap; }
68
+
69
+ #wpadminbar ul#wp-admin-bar-root-default> li.toolset-edit-link> a { position:relative; }
70
+ #wpadminbar ul#wp-admin-bar-root-default> li.toolset-edit-link> a:before {
71
+ font-family: "onthegosystems-icons"!important;
72
+ content: "\f11a";
73
+ top:2px;
74
+ }
embedded/common/res/css/toolset-promotion.css ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ .toolset-modal
3
+ {
4
+ font-family: "Open Sans";
5
+ font-size: 15px;
6
+ width: 550px;
7
+ background-color: #fff;
8
+ padding: 45px 0 20px 0;
9
+ position: relative;
10
+
11
+ -webkit-box-shadow: 5px 5px 15px 0px rgba(50, 50, 50, 0.38);
12
+ -moz-box-shadow: 5px 5px 15px 0px rgba(50, 50, 50, 0.38);
13
+ box-shadow: 5px 5px 15px 0px rgba(50, 50, 50, 0.38);
14
+
15
+ }
16
+
17
+ .toolset-modal h2
18
+ {
19
+ color: #fff;
20
+ position: relative;
21
+ background-color: #333;
22
+ padding: 10px 30px;
23
+ font-size: 24px;
24
+ line-height: 30px;
25
+ font-weight: 300;
26
+ margin: 0;
27
+ }
28
+
29
+ .toolset-modal .icon-toolset-logo
30
+ {
31
+ color: #f05a28;
32
+ position: absolute;
33
+ top: 6px;
34
+ left: 23px;
35
+ font-size: 53px;
36
+ background: transparent url(../images/toolset.promotion/toolset.png) no-repeat 7px 3px;
37
+ width: 55px;
38
+ height: 55px;
39
+ }
40
+
41
+ .toolset-modal .icon-toolset-logo:before
42
+ {
43
+ content: none;
44
+ display: none;
45
+ }
46
+
47
+ .toolset-modal ul:before
48
+ {
49
+ content: "";
50
+ display: table;
51
+ }
52
+
53
+ .toolset-modal .content
54
+ {
55
+ padding: 0 28px;
56
+ }
57
+
58
+ .toolset-modal ul
59
+ {
60
+ display: table-row;
61
+ }
62
+
63
+ .toolset-modal li:first-child
64
+ {
65
+ min-width: 75px;
66
+ }
67
+
68
+ .toolset-modal li:last-child
69
+ {
70
+ padding-right: 0;
71
+ min-width: 115px;
72
+ }
73
+
74
+ .toolset-modal li
75
+ ,.js-close-promotional-message
76
+ {
77
+ background: transparent url(../images/toolset.promotion/icons.png) no-repeat;
78
+ }
79
+
80
+ .toolset-modal li
81
+ {
82
+ display: table-cell;
83
+ font-size: 13px;
84
+ font-weight: 700;
85
+ height: 46px;
86
+ padding: 0 20px 0 38px;
87
+ }
88
+
89
+
90
+ .toolset-modal li.layout{background-position: 0 -65px}
91
+ .toolset-modal li.toolset-search{background-position: 0 -130px}
92
+ .toolset-modal li.list {background-position: 0 -195px}
93
+ .toolset-modal li.form {background-position: 0 -260px}
94
+ .toolset-modal li.more {background-position: 0 -325px}
95
+
96
+ .toolset-modal .full img
97
+ {
98
+ padding-bottom: 19px;
99
+ }
100
+
101
+ .toolset-modal .full
102
+ {
103
+ background: transparent url(../images/toolset.promotion/full.jpg) no-repeat;
104
+ padding-left: 298px;
105
+ min-height: 160px;
106
+ font-size: 15px;
107
+ margin: 10px 0 0 0;
108
+ }
109
+
110
+ .toolset-modal .icons
111
+ {
112
+ border: 1px solid #777;
113
+ border-width: 1px 0;
114
+ padding-top: 10px;
115
+ }
116
+
117
+ .toolset-modal .description
118
+ {
119
+ font-size: 13px;
120
+ color: #4d4d4d;
121
+ margin: 10px 0 20px 0;
122
+ }
123
+
124
+ .toolset-modal em
125
+ {
126
+ font-weight: 600;
127
+ }
128
+
129
+ .toolset-modal .button
130
+ {
131
+ padding: 10px 15px;
132
+ background-color: #f05a28;
133
+ color: #fff;
134
+ text-decoration: none;
135
+ margin-top: -10px;
136
+ height: auto;
137
+ font-size: 18px;
138
+ line-height: 1em;
139
+ }
140
+
141
+ .toolset-modal .learn
142
+ {
143
+ font-size: 15px;
144
+ color: #f05a28;
145
+ display: inline-block;
146
+ margin-left: 20px;
147
+ }
148
+
149
+ .ddl-dialogs-container
150
+ {
151
+ display: none;
152
+ }
153
+
154
+ .js-close-promotional-message
155
+ {
156
+ background-position: 0 -480px;
157
+ cursor: pointer;
158
+ display: block;
159
+ height: 20px;
160
+ position: absolute;
161
+ right: -10px;
162
+ top: -10px;
163
+ width: 20px;
164
+ }
embedded/common/res/images/toolset.promotion/full.jpg ADDED
Binary file
embedded/common/res/images/toolset.promotion/icons.png ADDED
Binary file
embedded/common/res/images/toolset.promotion/toolset.png ADDED
Binary file
embedded/common/res/js/jquery.colorbox-min.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ /*!
2
+ Colorbox v1.4.31 - 2013-09-25
3
+ jQuery lightbox and modal window plugin
4
+ (c) 2013 Jack Moore - http://www.jacklmoore.com/colorbox
5
+ license: http://www.opensource.org/licenses/mit-license.php
6
+ */
7
+ (function(e,t,i){function o(i,o,n){var r=t.createElement(i);return o&&(r.id=Z+o),n&&(r.style.cssText=n),e(r)}function n(){return i.innerHeight?i.innerHeight:e(i).height()}function r(e){var t=k.length,i=(z+e)%t;return 0>i?t+i:i}function h(e,t){return Math.round((/%/.test(e)?("x"===t?E.width():n())/100:1)*parseInt(e,10))}function s(e,t){return e.photo||e.photoRegex.test(t)}function l(e,t){return e.retinaUrl&&i.devicePixelRatio>1?t.replace(e.photoRegex,e.retinaSuffix):t}function a(e){"contains"in g[0]&&!g[0].contains(e.target)&&(e.stopPropagation(),g.focus())}function d(){var t,i=e.data(N,Y);null==i?(B=e.extend({},X),console&&console.log&&console.log("Error: cboxElement missing settings object")):B=e.extend({},i);for(t in B)e.isFunction(B[t])&&"on"!==t.slice(0,2)&&(B[t]=B[t].call(N));B.rel=B.rel||N.rel||e(N).data("rel")||"nofollow",B.href=B.href||e(N).attr("href"),B.title=B.title||N.title,"string"==typeof B.href&&(B.href=e.trim(B.href))}function c(i,o){e(t).trigger(i),st.trigger(i),e.isFunction(o)&&o.call(N)}function u(i){q||(N=i,d(),k=e(N),z=0,"nofollow"!==B.rel&&(k=e("."+et).filter(function(){var t,i=e.data(this,Y);return i&&(t=e(this).data("rel")||i.rel||this.rel),t===B.rel}),z=k.index(N),-1===z&&(k=k.add(N),z=k.length-1)),w.css({opacity:parseFloat(B.opacity),cursor:B.overlayClose?"pointer":"auto",visibility:"visible"}).show(),J&&g.add(w).removeClass(J),B.className&&g.add(w).addClass(B.className),J=B.className,B.closeButton?K.html(B.close).appendTo(y):K.appendTo("<div/>"),U||(U=$=!0,g.css({visibility:"hidden",display:"block"}),H=o(lt,"LoadedContent","width:0; height:0; overflow:hidden"),y.css({width:"",height:""}).append(H),O=x.height()+C.height()+y.outerHeight(!0)-y.height(),_=b.width()+T.width()+y.outerWidth(!0)-y.width(),D=H.outerHeight(!0),A=H.outerWidth(!0),B.w=h(B.initialWidth,"x"),B.h=h(B.initialHeight,"y"),H.css({width:"",height:B.h}),Q.position(),c(tt,B.onOpen),P.add(L).hide(),g.focus(),B.trapFocus&&t.addEventListener&&(t.addEventListener("focus",a,!0),st.one(rt,function(){t.removeEventListener("focus",a,!0)})),B.returnFocus&&st.one(rt,function(){e(N).focus()})),m())}function f(){!g&&t.body&&(V=!1,E=e(i),g=o(lt).attr({id:Y,"class":e.support.opacity===!1?Z+"IE":"",role:"dialog",tabindex:"-1"}).hide(),w=o(lt,"Overlay").hide(),F=e([o(lt,"LoadingOverlay")[0],o(lt,"LoadingGraphic")[0]]),v=o(lt,"Wrapper"),y=o(lt,"Content").append(L=o(lt,"Title"),S=o(lt,"Current"),I=e('<button type="button"/>').attr({id:Z+"Previous"}),R=e('<button type="button"/>').attr({id:Z+"Next"}),M=o("button","Slideshow"),F),K=e('<button type="button"/>').attr({id:Z+"Close"}),v.append(o(lt).append(o(lt,"TopLeft"),x=o(lt,"TopCenter"),o(lt,"TopRight")),o(lt,!1,"clear:left").append(b=o(lt,"MiddleLeft"),y,T=o(lt,"MiddleRight")),o(lt,!1,"clear:left").append(o(lt,"BottomLeft"),C=o(lt,"BottomCenter"),o(lt,"BottomRight"))).find("div div").css({"float":"left"}),W=o(lt,!1,"position:absolute; width:9999px; visibility:hidden; display:none"),P=R.add(I).add(S).add(M),e(t.body).append(w,g.append(v,W)))}function p(){function i(e){e.which>1||e.shiftKey||e.altKey||e.metaKey||e.ctrlKey||(e.preventDefault(),u(this))}return g?(V||(V=!0,R.click(function(){Q.next()}),I.click(function(){Q.prev()}),K.click(function(){Q.close()}),w.click(function(){B.overlayClose&&Q.close()}),e(t).bind("keydown."+Z,function(e){var t=e.keyCode;U&&B.escKey&&27===t&&(e.preventDefault(),Q.close()),U&&B.arrowKey&&k[1]&&!e.altKey&&(37===t?(e.preventDefault(),I.click()):39===t&&(e.preventDefault(),R.click()))}),e.isFunction(e.fn.on)?e(t).on("click."+Z,"."+et,i):e("."+et).live("click."+Z,i)),!0):!1}function m(){var n,r,a,u=Q.prep,f=++at;$=!0,j=!1,N=k[z],d(),c(ht),c(it,B.onLoad),B.h=B.height?h(B.height,"y")-D-O:B.innerHeight&&h(B.innerHeight,"y"),B.w=B.width?h(B.width,"x")-A-_:B.innerWidth&&h(B.innerWidth,"x"),B.mw=B.w,B.mh=B.h,B.maxWidth&&(B.mw=h(B.maxWidth,"x")-A-_,B.mw=B.w&&B.w<B.mw?B.w:B.mw),B.maxHeight&&(B.mh=h(B.maxHeight,"y")-D-O,B.mh=B.h&&B.h<B.mh?B.h:B.mh),n=B.href,G=setTimeout(function(){F.show()},100),B.inline?(a=o(lt).hide().insertBefore(e(n)[0]),st.one(ht,function(){a.replaceWith(H.children())}),u(e(n))):B.iframe?u(" "):B.html?u(B.html):s(B,n)?(n=l(B,n),j=t.createElement("img"),e(j).addClass(Z+"Photo").bind("error",function(){B.title=!1,u(o(lt,"Error").html(B.imgError))}).one("load",function(){var t;f===at&&(e.each(["alt","longdesc","aria-describedby"],function(t,i){var o=e(N).attr(i)||e(N).attr("data-"+i);o&&j.setAttribute(i,o)}),B.retinaImage&&i.devicePixelRatio>1&&(j.height=j.height/i.devicePixelRatio,j.width=j.width/i.devicePixelRatio),B.scalePhotos&&(r=function(){j.height-=j.height*t,j.width-=j.width*t},B.mw&&j.width>B.mw&&(t=(j.width-B.mw)/j.width,r()),B.mh&&j.height>B.mh&&(t=(j.height-B.mh)/j.height,r())),B.h&&(j.style.marginTop=Math.max(B.mh-j.height,0)/2+"px"),k[1]&&(B.loop||k[z+1])&&(j.style.cursor="pointer",j.onclick=function(){Q.next()}),j.style.width=j.width+"px",j.style.height=j.height+"px",setTimeout(function(){u(j)},1))}),setTimeout(function(){j.src=n},1)):n&&W.load(n,B.data,function(t,i){f===at&&u("error"===i?o(lt,"Error").html(B.xhrError):e(this).contents())})}var w,g,v,y,x,b,T,C,k,E,H,W,F,L,S,M,R,I,K,P,B,O,_,D,A,N,z,j,U,$,q,G,Q,J,V,X={html:!1,photo:!1,iframe:!1,inline:!1,transition:"elastic",speed:300,fadeOut:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,href:!1,title:!1,rel:!1,opacity:.9,preloading:!0,className:!1,overlayClose:!0,escKey:!0,arrowKey:!0,top:!1,bottom:!1,left:!1,right:!1,fixed:!1,data:void 0,closeButton:!0,fastIframe:!0,open:!1,reposition:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",photoRegex:/\.(gif|png|jp(e|g|eg)|bmp|ico|webp)((#|\?).*)?$/i,retinaImage:!1,retinaUrl:!1,retinaSuffix:"@2x.$1",current:"image {current} of {total}",previous:"previous",next:"next",close:"close",xhrError:"This content failed to load.",imgError:"This image failed to load.",returnFocus:!0,trapFocus:!0,onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1},Y="colorbox",Z="cbox",et=Z+"Element",tt=Z+"_open",it=Z+"_load",ot=Z+"_complete",nt=Z+"_cleanup",rt=Z+"_closed",ht=Z+"_purge",st=e("<a/>"),lt="div",at=0,dt={},ct=function(){function e(){clearTimeout(h)}function t(){(B.loop||k[z+1])&&(e(),h=setTimeout(Q.next,B.slideshowSpeed))}function i(){M.html(B.slideshowStop).unbind(l).one(l,o),st.bind(ot,t).bind(it,e),g.removeClass(s+"off").addClass(s+"on")}function o(){e(),st.unbind(ot,t).unbind(it,e),M.html(B.slideshowStart).unbind(l).one(l,function(){Q.next(),i()}),g.removeClass(s+"on").addClass(s+"off")}function n(){r=!1,M.hide(),e(),st.unbind(ot,t).unbind(it,e),g.removeClass(s+"off "+s+"on")}var r,h,s=Z+"Slideshow_",l="click."+Z;return function(){r?B.slideshow||(st.unbind(nt,n),n()):B.slideshow&&k[1]&&(r=!0,st.one(nt,n),B.slideshowAuto?i():o(),M.show())}}();e.colorbox||(e(f),Q=e.fn[Y]=e[Y]=function(t,i){var o=this;if(t=t||{},f(),p()){if(e.isFunction(o))o=e("<a/>"),t.open=!0;else if(!o[0])return o;i&&(t.onComplete=i),o.each(function(){e.data(this,Y,e.extend({},e.data(this,Y)||X,t))}).addClass(et),(e.isFunction(t.open)&&t.open.call(o)||t.open)&&u(o[0])}return o},Q.position=function(t,i){function o(){x[0].style.width=C[0].style.width=y[0].style.width=parseInt(g[0].style.width,10)-_+"px",y[0].style.height=b[0].style.height=T[0].style.height=parseInt(g[0].style.height,10)-O+"px"}var r,s,l,a=0,d=0,c=g.offset();if(E.unbind("resize."+Z),g.css({top:-9e4,left:-9e4}),s=E.scrollTop(),l=E.scrollLeft(),B.fixed?(c.top-=s,c.left-=l,g.css({position:"fixed"})):(a=s,d=l,g.css({position:"absolute"})),d+=B.right!==!1?Math.max(E.width()-B.w-A-_-h(B.right,"x"),0):B.left!==!1?h(B.left,"x"):Math.round(Math.max(E.width()-B.w-A-_,0)/2),a+=B.bottom!==!1?Math.max(n()-B.h-D-O-h(B.bottom,"y"),0):B.top!==!1?h(B.top,"y"):Math.round(Math.max(n()-B.h-D-O,0)/2),g.css({top:c.top,left:c.left,visibility:"visible"}),v[0].style.width=v[0].style.height="9999px",r={width:B.w+A+_,height:B.h+D+O,top:a,left:d},t){var u=0;e.each(r,function(e){return r[e]!==dt[e]?(u=t,void 0):void 0}),t=u}dt=r,t||g.css(r),g.dequeue().animate(r,{duration:t||0,complete:function(){o(),$=!1,v[0].style.width=B.w+A+_+"px",v[0].style.height=B.h+D+O+"px",B.reposition&&setTimeout(function(){E.bind("resize."+Z,Q.position)},1),i&&i()},step:o})},Q.resize=function(e){var t;U&&(e=e||{},e.width&&(B.w=h(e.width,"x")-A-_),e.innerWidth&&(B.w=h(e.innerWidth,"x")),H.css({width:B.w}),e.height&&(B.h=h(e.height,"y")-D-O),e.innerHeight&&(B.h=h(e.innerHeight,"y")),e.innerHeight||e.height||(t=H.scrollTop(),H.css({height:"auto"}),B.h=H.height()),H.css({height:B.h}),t&&H.scrollTop(t),Q.position("none"===B.transition?0:B.speed))},Q.prep=function(i){function n(){return B.w=B.w||H.width(),B.w=B.mw&&B.mw<B.w?B.mw:B.w,B.w}function h(){return B.h=B.h||H.height(),B.h=B.mh&&B.mh<B.h?B.mh:B.h,B.h}if(U){var a,d="none"===B.transition?0:B.speed;H.empty().remove(),H=o(lt,"LoadedContent").append(i),H.hide().appendTo(W.show()).css({width:n(),overflow:B.scrolling?"auto":"hidden"}).css({height:h()}).prependTo(y),W.hide(),e(j).css({"float":"none"}),a=function(){function i(){e.support.opacity===!1&&g[0].style.removeAttribute("filter")}var n,h,a=k.length,u="frameBorder",f="allowTransparency";U&&(h=function(){clearTimeout(G),F.hide(),c(ot,B.onComplete)},L.html(B.title).add(H).show(),a>1?("string"==typeof B.current&&S.html(B.current.replace("{current}",z+1).replace("{total}",a)).show(),R[B.loop||a-1>z?"show":"hide"]().html(B.next),I[B.loop||z?"show":"hide"]().html(B.previous),ct(),B.preloading&&e.each([r(-1),r(1)],function(){var i,o,n=k[this],r=e.data(n,Y);r&&r.href?(i=r.href,e.isFunction(i)&&(i=i.call(n))):i=e(n).attr("href"),i&&s(r,i)&&(i=l(r,i),o=t.createElement("img"),o.src=i)})):P.hide(),B.iframe?(n=o("iframe")[0],u in n&&(n[u]=0),f in n&&(n[f]="true"),B.scrolling||(n.scrolling="no"),e(n).attr({src:B.href,name:(new Date).getTime(),"class":Z+"Iframe",allowFullScreen:!0,webkitAllowFullScreen:!0,mozallowfullscreen:!0}).one("load",h).appendTo(H),st.one(ht,function(){n.src="//about:blank"}),B.fastIframe&&e(n).trigger("load")):h(),"fade"===B.transition?g.fadeTo(d,1,i):i())},"fade"===B.transition?g.fadeTo(d,0,function(){Q.position(0,a)}):Q.position(d,a)}},Q.next=function(){!$&&k[1]&&(B.loop||k[z+1])&&(z=r(1),u(k[z]))},Q.prev=function(){!$&&k[1]&&(B.loop||z)&&(z=r(-1),u(k[z]))},Q.close=function(){U&&!q&&(q=!0,U=!1,c(nt,B.onCleanup),E.unbind("."+Z),w.fadeTo(B.fadeOut||0,0),g.stop().fadeTo(B.fadeOut||0,0,function(){g.add(w).css({opacity:1,cursor:"auto"}).hide(),c(ht),H.empty().remove(),setTimeout(function(){q=!1,c(rt,B.onClosed)},1)}))},Q.remove=function(){g&&(g.stop(),e.colorbox.close(),g.stop().remove(),w.remove(),q=!1,g=null,e("."+et).removeData(Y).removeClass(et),e(t).unbind("click."+Z))},Q.element=function(){return e(N)},Q.settings=X)})(jQuery,document,window);
embedded/common/res/js/toolset-promotion.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var Toolset_Promotion = Toolset_Promotion || {};
2
+
3
+ Toolset_Promotion = function($){
4
+ var self = this;
5
+
6
+ self.init = function(){
7
+ self.toolset_open_promotional_message();
8
+ };
9
+
10
+ self.toolset_open_promotional_message = function(){
11
+ var $el = $('.js-open-promotional-message')
12
+ , template = $('#js-buy-toolset-embedded-message').html()
13
+ , $container = $('#js-buy-toolset-embedded-message-wrap');
14
+
15
+ $container.html( _.template( template ) );
16
+
17
+ $(document).on('click', $el.selector, function(event){
18
+ event.preventDefault();
19
+ $.colorbox({
20
+ href: $container.selector,
21
+ inline: true,
22
+ open: true,
23
+ closeButton: false,
24
+ fixed: true,
25
+ top: false,
26
+ width:'554px',
27
+ onComplete: function() {
28
+
29
+ },
30
+ onCleanup: function() {
31
+
32
+ },
33
+ opacity: .2
34
+ });
35
+ })
36
+ $('.js-close-promotional-message').on('click', function(){
37
+ $.colorbox.close();
38
+ });
39
+ };
40
+
41
+ self.init();
42
+
43
+ };
44
+
45
+ ;(function($){
46
+ var toolset_promotion_message = new Toolset_Promotion($);
47
+ }(jQuery));
embedded/common/toolset-forms/api.php CHANGED
@@ -1,5 +1,10 @@
1
  <?php
2
 
 
 
 
 
 
3
  function wptoolset_form( $form_id, $config = array() ){
4
  global $wptoolset_forms;
5
  $html = $wptoolset_forms->form( $form_id, $config );
@@ -8,7 +13,7 @@ function wptoolset_form( $form_id, $config = array() ){
8
 
9
  function wptoolset_form_field( $form_id, $config, $value = array() ){
10
  global $wptoolset_forms;
11
- $html = $wptoolset_forms->field( $form_id, $config, $value );
12
  return apply_filters( 'wptoolset_fieldform', $html, $config, $form_id );
13
  }
14
 
@@ -56,4 +61,33 @@ function wptoolset_strtotime( $date, $format = null ){
56
  function wptoolset_timetodate( $timestamp, $format = null ){
57
  global $wptoolset_forms;
58
  return $wptoolset_forms->timetodate( $timestamp, $format );
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
+ /**
4
+ *
5
+ *
6
+ */
7
+
8
  function wptoolset_form( $form_id, $config = array() ){
9
  global $wptoolset_forms;
10
  $html = $wptoolset_forms->form( $form_id, $config );
13
 
14
  function wptoolset_form_field( $form_id, $config, $value = array() ){
15
  global $wptoolset_forms;
16
+ $html = $wptoolset_forms->field( $form_id, $config, $value );
17
  return apply_filters( 'wptoolset_fieldform', $html, $config, $form_id );
18
  }
19
 
61
  function wptoolset_timetodate( $timestamp, $format = null ){
62
  global $wptoolset_forms;
63
  return $wptoolset_forms->timetodate( $timestamp, $format );
64
+ }
65
+
66
+ /**
67
+ * wptoolset_esc_like
68
+ *
69
+ * In WordPress 4.0, like_escape() was deprecated, due to incorrect
70
+ * documentation and improper sanitization leading to a history of misuse
71
+ * To maintain compatibility with versions of WP before 4.0, we duplicate the
72
+ * logic of the replacement, wpdb::esc_like()
73
+ *
74
+ * @see wpdb::esc_like() for more details on proper use.
75
+ *
76
+ * @global object $wpdb
77
+ *
78
+ * @param string $text The raw text to be escaped.
79
+ * @return string Text in the form of a LIKE phrase. Not SQL safe. Run through
80
+ * wpdb::prepare() before use.
81
+ */
82
+ function wptoolset_esc_like( $like )
83
+ {
84
+ global $wpdb;
85
+ if ( method_exists( $wpdb, 'esc_like' ) ) {
86
+ return $wpdb->esc_like( $like );
87
+ }
88
+ if ( version_compare( get_bloginfo('version'), '4' ) < 0 ) {
89
+ return like_escape( $like );
90
+ }
91
+ return addcslashes( $like, '_%\\' );
92
+ }
93
+
embedded/common/toolset-forms/bootstrap.php CHANGED
@@ -2,199 +2,299 @@
2
 
3
  /**
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/bootstrap.php $
6
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
7
- * $LastChangedRevision: 970205 $
8
- * $LastChangedBy: brucepearson $
9
  *
10
  */
11
-
12
  require_once 'api.php';
13
 
14
- define( 'WPTOOLSET_FORMS_VERSION', '0.1.1' );
15
- define( 'WPTOOLSET_FORMS_ABSPATH', dirname( __FILE__ ) );
16
 
17
  /**
18
  * check we are as a embedded?
19
  */
20
- if ( defined('WPCF_RUNNING_EMBEDDED' ) && WPCF_RUNNING_EMBEDDED ) {
21
- define( 'WPTOOLSET_FORMS_RELPATH', wpcf_get_file_url( __FILE__, false ) );
22
  }
23
  /**
24
  * setup WPTOOLSET_FORMS_RELPATH for plugin
25
  */
26
- if ( !defined( 'WPTOOLSET_FORMS_RELPATH' ) ) {
27
- define( 'WPTOOLSET_FORMS_RELPATH', plugins_url( '', __FILE__ ) );
28
  }
29
- if ( !defined( 'WPTOOLSET_COMMON_PATH' ) ) {
30
- define( 'WPTOOLSET_COMMON_PATH', plugin_dir_path( __FILE__ ) );
31
  }
32
 
33
- class WPToolset_Forms_Bootstrap
34
- {
35
 
36
  private $__forms;
37
 
38
- public final function __construct()
39
- {
40
  // Custom conditinal AJAX check
41
- add_action( 'wp_ajax_wptoolset_custom_conditional',
42
- array($this, 'ajaxCustomConditional') );
43
 
44
  // Date conditinal AJAX check
45
- add_action( 'wp_ajax_wptoolset_conditional',
46
- array($this, 'ajaxConditional') );
47
-
48
- // Date extended localization AJAX callback
49
- add_action( 'wp_ajax_wpt_localize_extended_date', array( $this, 'wpt_localize_extended_date' ) );
50
- add_action( 'wp_ajax_nopriv_wpt_localize_extended_date', array( $this, 'wpt_localize_extended_date' ) );
51
-
52
- // File media popup
53
- if ( (isset( $_GET['context'] ) && $_GET['context'] == 'wpt-fields-media-insert') || (isset( $_SERVER['HTTP_REFERER'] ) && strpos( $_SERVER['HTTP_REFERER'],
54
- 'context=wpt-fields-media-insert' ) !== false)
55
- ) {
56
- require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.file.php';
57
- add_action( 'init', array('WPToolset_Field_File', 'mediaPopup') );
58
- }
59
- add_filter('sanitize_file_name', array( $this, 'sanitize_file_name' ) );
60
-
61
- add_filter( 'wptoolset_filter_wptoolset_repdrag_image', array( $this, 'set_default_repdrag_image' ), 10, 1 );
62
  /**
63
  * common class for calendar
64
  */
65
- require_once WPTOOLSET_FORMS_ABSPATH.'/classes/class.date.scripts.php';
66
  new WPToolset_Field_Date_Scripts();
 
 
67
  }
68
 
69
  // returns HTML
70
- public function field($form_id, $config, $value)
71
- {
72
- $form = $this->form( $form_id, array() );
73
- return $form->metaform( $config, $config['name'], $value );
74
  }
75
 
76
  // returns HTML
77
- // public function fieldEdit($form_id, $config) {
78
- // $form = $this->form( $form_id, array() );
79
- // return $form->editform( $config );
80
- // }
81
-
82
- public function form( $form_id, $config = array() )
83
- {
84
- if ( isset( $this->__forms[$form_id] ) ) {
85
  return $this->__forms[$form_id];
86
  }
87
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.form_factory.php';
88
- return $this->__forms[$form_id] = new FormFactory( $form_id, $config );
89
  }
90
 
91
- public function validate_field($form_id, $config, $value)
92
- {
93
- if ( empty( $config['validation'] ) ) {
94
  return true;
95
  }
96
- $form = $this->form( $form_id, array() );
97
- return $form->validateField( $config, $value );
98
  }
99
 
100
- public function ajaxCustomConditional()
101
- {
102
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.conditional.php';
103
  WPToolset_Forms_Conditional::ajaxCustomConditional();
104
  }
105
 
106
- public function checkConditional($config)
107
- {
108
- if ( empty( $config['conditional'] ) ) {
109
  return true;
110
  }
111
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.conditional.php';
112
- return WPToolset_Forms_Conditional::evaluate( $config['conditional'] );
113
  }
114
 
115
- public function addConditional($form_id, $config)
116
- {
117
- $this->form( $form_id )->addConditional( $config );
118
  }
119
 
120
- public function ajaxConditional()
121
- {
122
  $data = $_POST['conditions'];
123
  $data['values'] = $_POST['values'];
124
- echo $this->checkConditional( array('conditional' => $data) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  die();
126
  }
127
-
128
- public function wpt_localize_extended_date()
129
- {
130
- $date_format = $_POST['date-format'];
131
- if ($date_format == '') {
132
- $date_format = get_option('date_format');
133
- }
134
- $date = $_POST['date'];
135
- $date = adodb_mktime(0, 0, 0, substr($date, 2, 2), substr($date, 0, 2), substr($date, 4, 4));
136
- $date_format = str_replace('\\\\', '\\', $date_format);
137
- echo json_encode(array('display' => adodb_date($date_format, $date),'timestamp' => $date));
138
- die();
139
- }
140
-
141
- public function filterTypesField($field, $post_id = null, $_post_wpcf = array())
142
- {
143
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.types.php';
144
- return WPToolset_Types::filterField( $field, $post_id, $_post_wpcf);
145
  }
146
 
147
- public function addFieldFilters($type)
148
- {
149
- if ( $class = $this->form( 'generic' )->loadFieldClass( $type ) ) {
150
- call_user_func( array($class, 'addFilters') );
151
- call_user_func( array($class, 'addActions') );
152
  }
153
  }
154
 
155
- public function getConditionalData($form_id)
156
- {
157
- return $this->form( $form_id )->getConditionalClass()->getData();
158
  }
159
 
160
- public function strtotime($date, $format = null)
161
- {
162
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
163
- return WPToolset_Field_Date::strtotime( $date, $format );
164
  }
165
 
166
- public function timetodate($timestamp, $format = null)
167
- {
168
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
169
- return WPToolset_Field_Date::timetodate( $timestamp, $format );
170
  }
171
 
172
- public function sanitize_file_name( $filename )
173
- {
174
  /**
175
  * replace german special characters
176
  */
177
- $de_from = array('ä','ö','ü','ß','Ä','Ö','Ü');
178
- $de_to = array('ae','oe','ue','ss','Ae','Oe','Ue');
179
  $filename = str_replace($de_from, $de_to, $filename);
180
  /**
181
  * replace polish special characters
182
  */
183
- $pl_from = array( 'ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ź', 'ż', 'Ą', 'Ć', 'Ę', 'Ł', 'Ń', 'Ó', 'Ś', 'Ź', 'Ż' );
184
- $pl_to = array( 'a', 'c', 'e', 'l', 'n', 'o', 's', 'z', 'z', 'A', 'C', 'E', 'L', 'N', 'O', 'S', 'Z', 'Z' );
185
  $filename = str_replace($pl_from, $pl_to, $filename);
186
  /**
187
  * remove special characters
188
  */
189
- $filename = preg_replace( '/[^A-Za-z0-9\._]/', '-', $filename);
190
- $filename = preg_replace( '/[_ ]+/', '-', $filename);
191
- $filename = preg_replace( '/%20/', '-', $filename);
192
  return $filename;
193
  }
194
-
195
- public function set_default_repdrag_image( $image ) {
196
- return WPTOOLSET_FORMS_RELPATH . '/images/move.png';
197
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  }
199
 
200
  $GLOBALS['wptoolset_forms'] = new WPToolset_Forms_Bootstrap();
2
 
3
  /**
4
  *
 
 
 
 
5
  *
6
  */
 
7
  require_once 'api.php';
8
 
9
+ define('WPTOOLSET_FORMS_VERSION', '0.1.1');
10
+ define('WPTOOLSET_FORMS_ABSPATH', dirname(__FILE__));
11
 
12
  /**
13
  * check we are as a embedded?
14
  */
15
+ if (defined('WPCF_RUNNING_EMBEDDED') && WPCF_RUNNING_EMBEDDED) {
16
+ define('WPTOOLSET_FORMS_RELPATH', wpcf_get_file_url(__FILE__, false));
17
  }
18
  /**
19
  * setup WPTOOLSET_FORMS_RELPATH for plugin
20
  */
21
+ if (!defined('WPTOOLSET_FORMS_RELPATH')) {
22
+ define('WPTOOLSET_FORMS_RELPATH', plugins_url('', __FILE__));
23
  }
24
+ if (!defined('WPTOOLSET_COMMON_PATH')) {
25
+ define('WPTOOLSET_COMMON_PATH', plugin_dir_path(__FILE__));
26
  }
27
 
28
+ class WPToolset_Forms_Bootstrap {
 
29
 
30
  private $__forms;
31
 
32
+ public final function __construct() {
 
33
  // Custom conditinal AJAX check
34
+ add_action('wp_ajax_wptoolset_custom_conditional', array($this, 'ajaxCustomConditional'));
 
35
 
36
  // Date conditinal AJAX check
37
+ add_action('wp_ajax_wptoolset_conditional', array($this, 'ajaxConditional'));
38
+
39
+ // Date extended localization AJAX callback
40
+ add_action('wp_ajax_wpt_localize_extended_date', array($this, 'wpt_localize_extended_date'));
41
+ add_action('wp_ajax_nopriv_wpt_localize_extended_date', array($this, 'wpt_localize_extended_date'));
42
+
43
+ // Taxonomy term suggest AJAX callback
44
+ add_action('wp_ajax_wpt_suggest_taxonomy_term', array($this, 'wpt_suggest_taxonomy_term'));
45
+ add_action('wp_ajax_nopriv_wpt_suggest_taxonomy_term', array($this, 'wpt_suggest_taxonomy_term'));
46
+
47
+ add_filter('sanitize_file_name', array($this, 'sanitize_file_name'));
48
+
49
+ add_filter('wptoolset_filter_wptoolset_repdrag_image', array($this, 'set_default_repdrag_image'), 10, 1);
 
 
 
 
50
  /**
51
  * common class for calendar
52
  */
53
+ require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.scripts.php';
54
  new WPToolset_Field_Date_Scripts();
55
+
56
+ add_action('pre_get_posts', array($this, 'pre_get_posts'));
57
  }
58
 
59
  // returns HTML
60
+ public function field($form_id, $config, $value) {
61
+ $form = $this->form($form_id, array());
62
+ return $form->metaform($config, $config['name'], $value);
 
63
  }
64
 
65
  // returns HTML
66
+ // public function fieldEdit($form_id, $config) {
67
+ // $form = $this->form( $form_id, array() );
68
+ // return $form->editform( $config );
69
+ // }
70
+
71
+ public function form($form_id, $config = array()) {
72
+ if (isset($this->__forms[$form_id])) {
 
73
  return $this->__forms[$form_id];
74
  }
75
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.form_factory.php';
76
+ return $this->__forms[$form_id] = new FormFactory($form_id, $config);
77
  }
78
 
79
+ public function validate_field($form_id, $config, $value) {
80
+ if (empty($config['validation'])) {
 
81
  return true;
82
  }
83
+ $form = $this->form($form_id, array());
84
+ return $form->validateField($config, $value);
85
  }
86
 
87
+ public function ajaxCustomConditional() {
 
88
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.conditional.php';
89
  WPToolset_Forms_Conditional::ajaxCustomConditional();
90
  }
91
 
92
+ public function checkConditional($config) {
93
+ if (empty($config['conditional'])) {
 
94
  return true;
95
  }
96
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.conditional.php';
97
+ return WPToolset_Forms_Conditional::evaluate($config['conditional']);
98
  }
99
 
100
+ public function addConditional($form_id, $config) {
101
+ $this->form($form_id)->addConditional($config);
 
102
  }
103
 
104
+ public function ajaxConditional() {
 
105
  $data = $_POST['conditions'];
106
  $data['values'] = $_POST['values'];
107
+ echo $this->checkConditional(array('conditional' => $data));
108
+ die();
109
+ }
110
+
111
+ public function wpt_localize_extended_date() {
112
+ if (!isset($_POST['date'])) {
113
+ die();
114
+ }
115
+ $date = $_POST['date'];
116
+ $date_format = '';
117
+ if (isset($_POST['date-format'])) {
118
+ $date_format = $_POST['date-format'];
119
+ }
120
+ if ($date_format == '') {
121
+ $date_format = get_option('date_format');
122
+ }
123
+ $date = adodb_mktime(0, 0, 0, substr($date, 2, 2), substr($date, 0, 2), substr($date, 4, 4));
124
+ $date_format = str_replace('\\\\', '\\', $date_format);
125
+ echo json_encode(array('display' => adodb_date($date_format, $date), 'timestamp' => $date));
126
+ die();
127
+ }
128
+
129
+ /**
130
+ * wpt_suggest_taxonomy_term
131
+ *
132
+ * Renders the suggestions when adding new flat taxonomy terms on a CRED form
133
+ *
134
+ * Needs a non-empty q attribute and can take an optional non-empty taxonomy attribute on the $_REQUEST
135
+ *
136
+ * @since 1.5.0
137
+ */
138
+ public function wpt_suggest_taxonomy_term() {
139
+ if (
140
+ !isset($_REQUEST['q']) || $_REQUEST['q'] == ''
141
+ ) {
142
+ die();
143
+ }
144
+ global $wpdb;
145
+ $values_to_prepare = array();
146
+ if (function_exists("wpv_esc_like")) {
147
+ $term_name = '%' . wpv_esc_like($_REQUEST['q']) . '%';
148
+ } else {
149
+ if (function_exists("cred_wrap_esc_like")) {
150
+ $term_name = '%' . cred_wrap_esc_like($_REQUEST['q']) . '%';
151
+ }
152
+ }
153
+ $values_to_prepare[] = $term_name;
154
+
155
+ $tax_join = "";
156
+ $tax_where = "";
157
+ if (
158
+ isset($_REQUEST['taxonomy']) && $_REQUEST['taxonomy'] != ''
159
+ ) {
160
+ $tax_join = " JOIN {$wpdb->term_taxonomy} tt ON t.term_id = tt.term_id ";
161
+ $tax_where = " AND tt.taxonomy = %s ";
162
+ $values_to_prepare[] = $_REQUEST['taxonomy'];
163
+ }
164
+ //
165
+ $results = $wpdb->get_results(
166
+ $wpdb->prepare(
167
+ "SELECT name FROM {$wpdb->terms} t {$tax_join}
168
+ WHERE t.name LIKE %s
169
+ {$tax_where}
170
+ ORDER BY name DESC
171
+ LIMIT 5", $values_to_prepare
172
+ )
173
+ );
174
+ foreach ($results as $row) {
175
+ echo $row->name . "\n";
176
+ }
177
+
178
  die();
179
  }
180
+
181
+ public function filterTypesField($field, $post_id = null, $_post_wpcf = array()) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.types.php';
183
+ return WPToolset_Types::filterField($field, $post_id, $_post_wpcf);
184
  }
185
 
186
+ public function addFieldFilters($type) {
187
+ if ($class = $this->form('generic')->loadFieldClass($type)) {
188
+ call_user_func(array($class, 'addFilters'));
189
+ call_user_func(array($class, 'addActions'));
 
190
  }
191
  }
192
 
193
+ public function getConditionalData($form_id) {
194
+ return $this->form($form_id)->getConditionalClass()->getData();
 
195
  }
196
 
197
+ public function strtotime($date, $format = null) {
 
198
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
199
+ return WPToolset_Field_Date::strtotime($date, $format);
200
  }
201
 
202
+ public function timetodate($timestamp, $format = null) {
 
203
  require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.date.php';
204
+ return WPToolset_Field_Date::timetodate($timestamp, $format);
205
  }
206
 
207
+ public function sanitize_file_name($filename) {
 
208
  /**
209
  * replace german special characters
210
  */
211
+ $de_from = array('ä', 'ö', 'ü', 'ß', 'Ä', 'Ö', 'Ü');
212
+ $de_to = array('ae', 'oe', 'ue', 'ss', 'Ae', 'Oe', 'Ue');
213
  $filename = str_replace($de_from, $de_to, $filename);
214
  /**
215
  * replace polish special characters
216
  */
217
+ $pl_from = array('ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ź', 'ż', 'Ą', 'Ć', 'Ę', 'Ł', 'Ń', 'Ó', 'Ś', 'Ź', 'Ż');
218
+ $pl_to = array('a', 'c', 'e', 'l', 'n', 'o', 's', 'z', 'z', 'A', 'C', 'E', 'L', 'N', 'O', 'S', 'Z', 'Z');
219
  $filename = str_replace($pl_from, $pl_to, $filename);
220
  /**
221
  * remove special characters
222
  */
223
+ $filename = preg_replace('/[^A-Za-z0-9\._@]/', '-', $filename);
224
+ $filename = preg_replace('/%20/', '-', $filename);
 
225
  return $filename;
226
  }
227
+
228
+ public function set_default_repdrag_image($image) {
229
+ return WPTOOLSET_FORMS_RELPATH . '/images/move.png';
230
+ }
231
+
232
+ /**
233
+ * add custom post type to query when they use category or tags taxonomy.
234
+ */
235
+ public function pre_get_posts($query) {
236
+ if (is_admin()) {
237
+ return;
238
+ }
239
+ /**
240
+ * do that only for main query
241
+ */
242
+ if (!$query->is_main_query()) {
243
+ return;
244
+ }
245
+ $types_cpt = get_option('wpcf-custom-types');
246
+ if (!is_array($types_cpt) || empty($types_cpt)) {
247
+ return;
248
+ }
249
+ $cpt_to_add = array();
250
+ /**
251
+ * check category
252
+ */
253
+ if (is_category()) {
254
+ foreach ($types_cpt as $cpt_slug => $cpt) {
255
+ if (array_key_exists('taxonomies', $cpt) && is_array($cpt['taxonomies'])) {
256
+ foreach ($cpt['taxonomies'] as $tax_slug => $value) {
257
+ if ('category' == $tax_slug && $value) {
258
+ $cpt_to_add[] = $cpt_slug;
259
+ }
260
+ }
261
+ }
262
+ }
263
+ }
264
+ /**
265
+ * check tags
266
+ */
267
+ if (is_tag()) {
268
+ foreach ($types_cpt as $cpt_slug => $cpt) {
269
+ if (array_key_exists('taxonomies', $cpt) && is_array($cpt['taxonomies'])) {
270
+ foreach ($cpt['taxonomies'] as $tax_slug => $value) {
271
+ if ('post_tag' == $tax_slug && $value) {
272
+ $cpt_to_add[] = $cpt_slug;
273
+ }
274
+ }
275
+ }
276
+ }
277
+ }
278
+ /**
279
+ * change query if some CPT use this
280
+ */
281
+ if (!empty($cpt_to_add)) {
282
+ /**
283
+ * remeber if is empty, then is post
284
+ */
285
+ $current_types = $query->get('post_type');
286
+ if (empty($current_types)) {
287
+ $cpt_to_add[] = 'post';
288
+ } elseif (is_array($current_types)) {
289
+ $cpt_to_add = array_merge($current_types, $cpt_to_add);
290
+ } elseif (is_string($current_types)) {
291
+ $cpt_to_add[] = $current_types;
292
+ }
293
+ $query->set('post_type', $cpt_to_add);
294
+ }
295
+ return;
296
+ }
297
+
298
  }
299
 
300
  $GLOBALS['wptoolset_forms'] = new WPToolset_Forms_Bootstrap();
embedded/common/toolset-forms/classes/class.audio.php CHANGED
@@ -6,10 +6,6 @@ require_once 'class.file.php';
6
  *
7
  * @author Srdjan
8
  *
9
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.audio.php $
10
- * $LastChangedDate: 2014-08-22 12:23:29 +0200 (Fri, 22 Aug 2014) $
11
- * $LastChangedRevision: 26350 $
12
- * $LastChangedBy: francesco $
13
  *
14
  */
15
  class WPToolset_Field_Audio extends WPToolset_Field_File
6
  *
7
  * @author Srdjan
8
  *
 
 
 
 
9
  *
10
  */
11
  class WPToolset_Field_Audio extends WPToolset_Field_File
embedded/common/toolset-forms/classes/class.checkbox.php CHANGED
@@ -1,10 +1,6 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.checkbox.php $
5
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
6
- * $LastChangedRevision: 970205 $
7
- * $LastChangedBy: brucepearson $
8
  *
9
  */
10
  require_once 'class.field_factory.php';
@@ -20,7 +16,7 @@ class WPToolset_Field_Checkbox extends FieldFactory
20
  {
21
  global $post;
22
  $value = $this->getValue();
23
- $data = $this->getData();
24
  $checked = null;
25
 
26
  /**
@@ -34,11 +30,17 @@ class WPToolset_Field_Checkbox extends FieldFactory
34
  */
35
  if ( isset($data['options']) && array_key_exists( 'checked', $data['options'] ) ) {
36
  $checked = $data['options']['checked'];
37
- }
38
- if ( array_key_exists('default_value', $data) && $value == $data['default_value'] ) {
 
 
 
 
 
 
39
  $checked = true;
40
  }
41
-
42
  // Comment out broken code. This tries to set the previous state after validation fails
43
  //if (!$checked&&$this->getValue()==1) {
44
  // $checked=true;
@@ -52,6 +54,7 @@ class WPToolset_Field_Checkbox extends FieldFactory
52
  '#value' => $value,
53
  '#default_value' => array_key_exists( 'default_value', $data )? $data['default_value']:null,
54
  '#name' => $this->getName(),
 
55
  '#title' => $this->getTitle(),
56
  '#validate' => $this->getValidationData(),
57
  '#after' => '<input type="hidden" name="_wptoolset_checkbox[' . $this->getId() . ']" value="1" />',
1
  <?php
2
  /**
3
  *
 
 
 
 
4
  *
5
  */
6
  require_once 'class.field_factory.php';
16
  {
17
  global $post;
18
  $value = $this->getValue();
19
+ $data = $this->getData();
20
  $checked = null;
21
 
22
  /**
30
  */
31
  if ( isset($data['options']) && array_key_exists( 'checked', $data['options'] ) ) {
32
  $checked = $data['options']['checked'];
33
+ }
34
+ /**
35
+ * if is a default value, there value is 1 or default_value
36
+ */
37
+ if (
38
+ array_key_exists('default_value', $data)
39
+ && ( 'y' === $value || $value === $data['default_value'])
40
+ ) {
41
  $checked = true;
42
  }
43
+
44
  // Comment out broken code. This tries to set the previous state after validation fails
45
  //if (!$checked&&$this->getValue()==1) {
46
  // $checked=true;
54
  '#value' => $value,
55
  '#default_value' => array_key_exists( 'default_value', $data )? $data['default_value']:null,
56
  '#name' => $this->getName(),
57
+ '#description' => $this->getDescription(),
58
  '#title' => $this->getTitle(),
59
  '#validate' => $this->getValidationData(),
60
  '#after' => '<input type="hidden" name="_wptoolset_checkbox[' . $this->getId() . ']" value="1" />',
embedded/common/toolset-forms/classes/class.checkboxes.php CHANGED
@@ -4,10 +4,6 @@
4
  *
5
  * @author Srdjan
6
  *
7
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.checkboxes.php $
8
- * $LastChangedDate: 2014-08-27 04:51:19 +0200 (Wed, 27 Aug 2014) $
9
- * $LastChangedRevision: 26470 $
10
- * $LastChangedBy: bruce $
11
  *
12
  */
13
 
@@ -20,18 +16,19 @@ class WPToolset_Field_Checkboxes extends FieldFactory
20
  global $post;
21
  $value = $this->getValue();
22
  $data = $this->getData();
23
- $name = $this->getName();
 
24
  $form = array();
25
  $_options = array();
26
  if (isset($data['options'])) {
27
  foreach ( $data['options'] as $option_key => $option ) {
28
-
29
  $checked = isset( $option['checked'] ) ? $option['checked'] : !empty( $value[$option_key] );
30
-
31
  if (isset($post) && 'auto-draft' == $post->post_status && array_key_exists( 'checked', $option ) && $option['checked']) {
32
  $checked = true;
33
  }
34
-
35
  // Comment out broken code. This tries to set the previous state after validation fails
36
  //$_values=$this->getValue();
37
  //if (!$checked&&isset($value)&&!empty($value)&&is_array($value)&&in_array($option['value'],$value)) {
@@ -46,14 +43,31 @@ class WPToolset_Field_Checkboxes extends FieldFactory
46
  '#name' => $option['name']."[]",
47
  //'#inline' => true,
48
  );
49
-
50
  if ( isset( $option['data-value'] ) ) {
51
  //Fixing https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188528502/comments
52
  $_options[$option_key]['#attributes'] = array('data-value' => $option['data-value']);
53
  }
54
-
55
- if ( !is_admin() ) {// TODO maybe add a doing_ajax() check too, what if we want to load a form using AJAX?
56
- $_options[$option_key]['#before'] = '<li class="wpt-form-item wpt-form-item-checkbox">';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  $_options[$option_key]['#after'] = '</li>';
58
  $_options[$option_key]['#pattern'] = '<BEFORE><PREFIX><ELEMENT><LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
59
  }
@@ -62,6 +76,7 @@ class WPToolset_Field_Checkboxes extends FieldFactory
62
  $metaform = array(
63
  '#type' => 'checkboxes',
64
  '#options' => $_options,
 
65
  );
66
  if ( is_admin() ) {
67
  $metaform['#title'] = $this->getTitle();
4
  *
5
  * @author Srdjan
6
  *
 
 
 
 
7
  *
8
  */
9
 
16
  global $post;
17
  $value = $this->getValue();
18
  $data = $this->getData();
19
+ $name = $this->getName();
20
+
21
  $form = array();
22
  $_options = array();
23
  if (isset($data['options'])) {
24
  foreach ( $data['options'] as $option_key => $option ) {
25
+
26
  $checked = isset( $option['checked'] ) ? $option['checked'] : !empty( $value[$option_key] );
27
+
28
  if (isset($post) && 'auto-draft' == $post->post_status && array_key_exists( 'checked', $option ) && $option['checked']) {
29
  $checked = true;
30
  }
31
+
32
  // Comment out broken code. This tries to set the previous state after validation fails
33
  //$_values=$this->getValue();
34
  //if (!$checked&&isset($value)&&!empty($value)&&is_array($value)&&in_array($option['value'],$value)) {
43
  '#name' => $option['name']."[]",
44
  //'#inline' => true,
45
  );
46
+
47
  if ( isset( $option['data-value'] ) ) {
48
  //Fixing https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188528502/comments
49
  $_options[$option_key]['#attributes'] = array('data-value' => $option['data-value']);
50
  }
51
+
52
+ if ( !is_admin() ) {// TODO maybe add a doing_ajax() check too, what if we want to load a form using AJAX?
53
+ $clases = array(
54
+ 'wpt-form-item',
55
+ 'wpt-form-item-checkbox',
56
+ 'checkbox-'.sanitize_title($option['title'])
57
+ );
58
+ /**
59
+ * filter: cred_checkboxes_class
60
+ * @param array $clases current array of classes
61
+ * @parem array $option current option
62
+ * @param string field type
63
+ *
64
+ * @return array
65
+ */
66
+ $clases = apply_filters( 'cred_item_li_class', $clases, $option, 'checkboxes' );
67
+ $_options[$option_key]['#before'] = sprintf(
68
+ '<li class="%s">',
69
+ implode(' ', $clases)
70
+ );
71
  $_options[$option_key]['#after'] = '</li>';
72
  $_options[$option_key]['#pattern'] = '<BEFORE><PREFIX><ELEMENT><LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
73
  }
76
  $metaform = array(
77
  '#type' => 'checkboxes',
78
  '#options' => $_options,
79
+ '#description' => $this->getDescription(),
80
  );
81
  if ( is_admin() ) {
82
  $metaform['#title'] = $this->getTitle();
embedded/common/toolset-forms/classes/class.colorpicker.php CHANGED
@@ -1,10 +1,6 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.colorpicker.php $
5
- * $LastChangedDate: 2014-07-12 10:38:18 +0200 (Sat, 12 Jul 2014) $
6
- * $LastChangedRevision: 24908 $
7
- * $LastChangedBy: gen $
8
  *
9
  */
10
  require_once 'class.field_factory.php';
@@ -18,8 +14,7 @@ class WPToolset_Field_Colorpicker extends FieldFactory
18
  {
19
  public function init()
20
  {
21
-
22
- if ( !is_admin() ) {
23
  wp_enqueue_style( 'wp-color-picker' );
24
  wp_enqueue_script(
25
  'iris',
@@ -38,44 +33,63 @@ class WPToolset_Field_Colorpicker extends FieldFactory
38
  $colorpicker_l10n = array(
39
  'clear' => __( 'Clear' ),
40
  'defaultString' => __( 'Default', 'wpv-views' ),
41
- 'pick' => __( 'Select Color', 'wpv-views' )
42
  );
43
  wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', $colorpicker_l10n );
44
  }
45
- wp_register_script(
46
  'wptoolset-field-colorpicker',
47
  WPTOOLSET_FORMS_RELPATH . '/js/colorpicker.js',
48
  array('iris'),
49
  WPTOOLSET_FORMS_VERSION,
50
  true
51
  );
52
- wp_enqueue_script( 'wptoolset-field-colorpicker' );
53
-
54
- }
55
 
56
  static public function registerScripts()
57
  {
58
-
59
  }
60
 
61
  public function enqueueScripts()
62
  {
63
-
 
 
 
 
 
 
 
 
 
 
64
  }
65
 
66
  public function metaform()
67
  {
68
- $classes = array();
69
- $classes[] = 'js-wpt-colorpicker';
 
 
 
 
 
 
 
 
 
 
70
  $form = array();
71
  $form['name'] = array(
72
  '#type' => 'textfield',
73
  '#title' => $this->getTitle(),
74
- '#description' => $this->getDescription(),
75
  '#value' => $this->getValue(),
76
  '#name' => $this->getName(),
77
- '#attributes' => array('class' => implode(' ', $classes )),
78
- '#validate' => $this->getValidationData(),
79
  '#after' => '',
80
  '#repetitive' => $this->isRepetitive(),
81
  );
1
  <?php
2
  /**
3
  *
 
 
 
 
4
  *
5
  */
6
  require_once 'class.field_factory.php';
14
  {
15
  public function init()
16
  {
17
+ if ( !is_admin() ) {
 
18
  wp_enqueue_style( 'wp-color-picker' );
19
  wp_enqueue_script(
20
  'iris',
33
  $colorpicker_l10n = array(
34
  'clear' => __( 'Clear' ),
35
  'defaultString' => __( 'Default', 'wpv-views' ),
36
+ 'pick' => __( 'Select', 'wpv-views' )." Color"
37
  );
38
  wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', $colorpicker_l10n );
39
  }
40
+ wp_register_script(
41
  'wptoolset-field-colorpicker',
42
  WPTOOLSET_FORMS_RELPATH . '/js/colorpicker.js',
43
  array('iris'),
44
  WPTOOLSET_FORMS_VERSION,
45
  true
46
  );
47
+ wp_enqueue_script( 'wptoolset-field-colorpicker' );
48
+ $this->set_placeholder_as_attribute();
49
+ }
50
 
51
  static public function registerScripts()
52
  {
 
53
  }
54
 
55
  public function enqueueScripts()
56
  {
57
+
58
+ }
59
+
60
+ public function addTypeValidation($validation) {
61
+ $validation['hexadecimal'] = array(
62
+ 'args' => array(
63
+ 'hexadecimal'
64
+ ),
65
+ 'message' => __( 'You can add valid hexadecimal.', 'wpv-views' ),
66
+ );
67
+ return $validation;
68
  }
69
 
70
  public function metaform()
71
  {
72
+ $validation = $this->getValidationData();
73
+ $validation = $this->addTypeValidation($validation);
74
+ $this->setValidationData($validation);
75
+
76
+ $attributes = $this->getAttr();
77
+ if ( isset($attributes['class'] ) ) {
78
+ $attributes['class'] .= ' ';
79
+ } else {
80
+ $attributes['class'] = '';
81
+ }
82
+ $attributes['class'] = 'js-wpt-colorpicker';
83
+
84
  $form = array();
85
  $form['name'] = array(
86
  '#type' => 'textfield',
87
  '#title' => $this->getTitle(),
88
+ '#description' => $this->getDescription(),
89
  '#value' => $this->getValue(),
90
  '#name' => $this->getName(),
91
+ '#attributes' => $attributes,
92
+ '#validate' => $validation,
93
  '#after' => '',
94
  '#repetitive' => $this->isRepetitive(),
95
  );
embedded/common/toolset-forms/classes/class.conditional.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /*
3
  * - Checks conditionals when form is displayed and values changed
4
  * - Checks simple conditionals using JS
@@ -40,11 +41,11 @@
40
  * 'custom' => '($wpcf-text = show) OR ($wpcf-date > '21-01-2014')'
41
  * );
42
  */
43
- if ( !defined( 'ICL_COMMON_FUNCTIONS' ) ) {
44
- require_once WPTOOLSET_COMMON_PATH . '/functions.php';
45
  }
46
  if (!function_exists('wpv_filter_parse_date')) {
47
- require_once WPTOOLSET_COMMON_PATH . '/wpv-filter-date-embedded.php';
48
  }
49
 
50
  require_once WPTOOLSET_COMMON_PATH . '/expression-parser/parser.php';
@@ -57,9 +58,7 @@ require_once WPTOOLSET_COMMON_PATH . '/expression-parser/parser.php';
57
  *
58
  * @author Srdjan
59
  */
60
-
61
- class WPToolset_Forms_Conditional
62
- {
63
 
64
  private $__formID;
65
  protected $_collected = array(), $_triggers = array(), $_fields = array(), $_custom_triggers = array(), $_custom_fields = array();
@@ -69,30 +68,26 @@ class WPToolset_Forms_Conditional
69
  *
70
  * @param type $formID
71
  */
72
- public function __construct( $formID ) {
73
- $this->__formID = trim( $formID, '#' );
74
  // Register and enqueue
75
- wp_register_script( 'wptoolset-form-conditional',
76
- WPTOOLSET_FORMS_RELPATH . '/js/conditional.js', array('jquery', 'jquery-effects-scale'),
77
- WPTOOLSET_FORMS_VERSION, true );
78
- wp_enqueue_script( 'wptoolset-form-conditional' );
79
  $js_data = array(
80
- 'ajaxurl' => admin_url('admin-ajax.php', null),
81
  );
82
- wp_localize_script( 'wptoolset-form-conditional', 'wptConditional', $js_data );
83
 
84
- wp_register_script( 'wptoolset-parser',
85
- icl_get_file_relpath(__FILE__) . '/../../expression-parser/js/parser.js', array('jquery'),
86
- WPTOOLSET_FORMS_VERSION, true );
87
- wp_enqueue_script( 'wptoolset-parser' );
88
  $js_data = array(
89
- 'ajaxurl' => admin_url('admin-ajax.php', null),
90
  );
91
  // Render settings
92
- add_action( 'admin_print_footer_scripts', array($this, 'renderJsonData'), 30 );
93
- add_action( 'wp_footer', array($this, 'renderJsonData'), 30 );
94
  // Check conditional and hide field
95
- add_action('wptoolset_field_class', array($this, 'actionFieldClass') );
96
  }
97
 
98
  /**
@@ -102,8 +97,8 @@ class WPToolset_Forms_Conditional
102
  *
103
  * @param type $config
104
  */
105
- public function add( $config ) {
106
- if ( !empty( $config['conditional'] ) ) {
107
  $this->_collected[$config['id']] = $config['conditional'];
108
  return;
109
  }
@@ -113,38 +108,44 @@ class WPToolset_Forms_Conditional
113
  * Sets JSON data to be used with conditional.js
114
  */
115
  protected function _parseData() {
116
- foreach ( $this->_collected as $id => $config ) {
117
- if ( !empty( $config['custom'] ) ) {
118
-
119
- $evaluate = wpv_filter_parse_date($config['custom']);
120
- $evaluate = self::handle_user_function( $evaluate );
121
- $fields = self::extractFields( $evaluate );
 
 
 
 
 
 
 
122
 
123
- foreach ( $fields as $field ) {
124
  $this->_custom_fields[$id]['custom'] = $evaluate;
125
  $this->_custom_fields[$id]['triggers'][] = $field;
126
  $this->_custom_triggers[$field][] = $id;
127
  }
128
  } else {
129
- if (isset($config)&&isset($config['conditions'])) {
130
- if (isset($config)&&isset($config['relation']))
131
- $this->_fields[$id]['relation'] = $config['relation'];
132
-
133
- foreach ( $config['conditions'] as &$c ) {
134
- /*
135
- * $c[id] - field id
136
- * $c[type] - field type
137
- * $c[operator] - operator
138
- * $c[args] - array(value, [value2]...)
139
- */
140
- if ( !isset( $this->_triggers[$c['id']] ) )
141
- $this->_triggers[$c['id']] = array();
142
- $c['args'] = apply_filters( 'wptoolset_conditional_args_js',
143
- $c['args'], $c['type'] );
144
- $this->_fields[$id]['conditions'][] = $c;
145
- if ( !in_array( $id, $this->_triggers[$c['id']] ) )
146
- $this->_triggers[$c['id']][] = $id;
147
- }
148
  }
149
  }
150
  }
@@ -155,21 +156,21 @@ class WPToolset_Forms_Conditional
155
  */
156
  public function renderJsonData() {
157
  $this->_parseData();
158
- if ( !empty( $this->_triggers ) ) {
159
  echo '<script type="text/javascript">wptCondTriggers["#'
160
- . $this->__formID . '"] = ' . json_encode( $this->_triggers ) . ';</script>';
161
  }
162
- if ( !empty( $this->_fields ) ) {
163
  echo '<script type="text/javascript">wptCondFields["#'
164
- . $this->__formID . '"] = ' . json_encode( $this->_fields ) . ';</script>';
165
  }
166
- if ( !empty( $this->_custom_triggers ) ) {
167
  echo '<script type="text/javascript">wptCondCustomTriggers["#'
168
- . $this->__formID . '"] = ' . json_encode( $this->_custom_triggers ) . ';</script>';
169
  }
170
- if ( !empty( $this->_custom_fields ) ) {
171
  echo '<script type="text/javascript">wptCondCustomFields["#'
172
- . $this->__formID . '"] = ' . json_encode( $this->_custom_fields ) . ';</script>';
173
  }
174
  }
175
 
@@ -180,51 +181,50 @@ class WPToolset_Forms_Conditional
180
  * @param array $values
181
  * @return type
182
  */
183
- public static function evaluate( $config ) {
184
  // Custom conditional
185
- if ( !empty( $config['custom'] ) ) {
186
- return self::evaluateCustom( $config['custom'], $config['values'] );
187
  }
188
 
189
  /**
190
  * check conditions
191
  */
192
- if ( !array_key_exists( 'conditions', $config ) ) {
193
- return false;
194
  }
195
 
196
  $passedOne = false;
197
  $passedAll = true;
198
  $relation = $config['relation'];
199
 
200
- foreach ( $config['conditions'] as $c ) {
201
  // Add filters
202
- wptoolset_form_field_add_filters( $c['type'] );
203
- $c['args'] = apply_filters( 'wptoolset_conditional_args_php',
204
- $c['args'], $c['type'] );
205
- $value = isset( $config['values'][$c['id']] ) ? $config['values'][$c['id']] : null;
206
- $value = apply_filters( 'wptoolset_conditional_value_php', $value, $c['type'] );
207
  $compare = $c['args'][0];
208
- switch ( $c['operator'] ) {
209
  case '=':
210
  case '==':
211
  $passed = $value == $compare;
212
  break;
213
 
214
  case '>':
215
- $passed = floatval( $value ) > floatval( $compare );
216
  break;
217
 
218
  case '>=':
219
- $passed = floatval( $value ) >= floatval( $compare );
220
  break;
221
 
222
  case '<':
223
- $passed = floatval( $value ) < floatval( $compare );
224
  break;
225
 
226
  case '<=':
227
- $passed = floatval( $value ) <= floatval( $compare );
228
  break;
229
 
230
  case '===':
@@ -240,23 +240,23 @@ class WPToolset_Forms_Conditional
240
  break;
241
 
242
  case 'between':
243
- $passed = floatval( $value ) > floatval( $compare ) && floatval( $value ) < floatval( $c['args'][1] );
244
  break;
245
 
246
  default:
247
  $passed = false;
248
  break;
249
  }
250
- if ( !$passed ) {
251
  $passedAll = false;
252
  } else {
253
  $passedOne = true;
254
  }
255
  }
256
- if ( $relation == 'AND' && $passedAll ) {
257
  return true;
258
  }
259
- if ( $relation == 'OR' && $passedOne ) {
260
  return true;
261
  }
262
  return false;
@@ -271,88 +271,86 @@ class WPToolset_Forms_Conditional
271
  * @param type $evaluate
272
  * @return boolean
273
  */
274
- public static function evaluateCustom( $evaluate, $values ) {
275
- $evaluate = trim( stripslashes( $evaluate ) );
276
- // Check dates
277
- $evaluate = wpv_filter_parse_date( $evaluate );
278
- $evaluate = self::handle_user_function( $evaluate );
279
- $fields = self::extractFields( $evaluate );
280
- $evaluate = self::_update_values_in_expression($evaluate, $fields, $values);
281
-
282
- $check = false;
283
- try {
284
- $parser = new Toolset_Parser($evaluate);
285
- $parser->parse();
286
- $check = $parser->evaluate();
287
- } catch (Exception $e) {
288
- $check = false;
289
- }
290
- return $check;
291
- }
292
-
293
- static function sortByLength ($a, $b) {
294
- return strlen($b) - strlen($a);
295
- }
296
 
 
 
297
 
298
- private static function _update_values_in_expression($evaluate, $fields, $values) {
 
 
 
 
 
 
 
 
 
299
 
300
- // use string replace to replace any fields with their values.
 
 
301
 
302
- // Sort by length just in case a field name contians a shorter version of another field name.
303
- // eg. $my-field and $my-field-2
 
 
304
 
305
- $keys = array_keys($fields);
306
- usort($keys, 'WPToolset_Forms_Conditional::sortByLength');
307
 
308
- foreach($keys as $key) {
309
- $value = isset($values[$fields[$key]]) ? $values[$fields[$key]] : '';
310
- if ($value == '') {
311
- $value = "''";
312
- }
313
- if (is_numeric($value)) {
314
- $value = '\'' . $value . '\'';
315
- }
 
 
 
316
 
317
- if( 'array' === gettype($value) )
318
- {
319
  // workaround for datepicker data to cover all cases
320
- if( array_key_exists ( 'timestamp' , $value ) )
321
- {
322
- if ( is_numeric( $value['timestamp'] ) )
323
- {
324
- $value = $value['timestamp'];
325
- }
326
- else if ( is_array( $value['timestamp'] ) )
327
- {
328
- $value = implode(',', array_values ( $value['timestamp'] ) );
329
- }
330
- }
331
- else if( array_key_exists('datepicker', $value ) )
332
- {
333
- if ( is_numeric( $value['datepicker'] ) )
334
- {
335
- $value = $value['datepicker'];
336
- }
337
- else if ( is_array( $value['datepicker'] ) )
338
- {
339
- $value = implode(',', array_values ( $value['datepicker'] ) );
340
- }
341
- }
342
- else{
343
- $value = implode(',', array_values ( $value ) );
344
  }
345
  }
346
 
 
 
 
347
 
348
- // First replace the $(field_name) format
349
- $evaluate = str_replace('$(' . $fields[$key] . ')', $value, $evaluate);
350
- // next replace the $field_name format
351
- $evaluate = str_replace('$' . $fields[$key], $value, $evaluate);
352
- }
353
-
354
- return $evaluate;
355
- }
356
 
357
  /**
358
  * Extracts fields from custom conditional statement.
@@ -360,62 +358,62 @@ class WPToolset_Forms_Conditional
360
  * @param type $evaluate
361
  * @return type
362
  */
363
- public static function extractFields( $evaluate ) {
364
- $evaluate = trim( stripslashes( $evaluate ) );
365
- // Check dates
366
- $evaluate = wpv_filter_parse_date( $evaluate );
367
- $evaluate = self::handle_user_function($evaluate);
 
 
 
 
 
368
 
369
  // Add quotes = > < >= <= === <> !==
370
- $strings_count = preg_match_all( '/[=|==|===|<=|<==|<===|>=|>==|>===|\!===|\!==|\!=|<>]\s(?!\$)(\w*)[\)|\$|\W]/',
371
- $evaluate, $matches );
372
-
373
- if ( !empty( $matches[1] ) ) {
374
- foreach ( $matches[1] as $temp_match ) {
375
- $temp_replace = is_numeric( $temp_match ) ? $temp_match : '\'' . $temp_match . '\'';
376
- $evaluate = str_replace( ' ' . $temp_match . ')',
377
- ' ' . $temp_replace . ')', $evaluate );
378
  }
379
  }
380
  // if new version $(field-value) use this regex
381
- if( preg_match('/\$\(([^()]+)\)/', $evaluate) ){
382
- preg_match_all( '/\$\(([^()]+)\)/', $evaluate, $matches );
383
  }
384
  // if old version $field-value use this other
385
- else{
386
- preg_match_all( '/\$([^\s]*)/', $evaluate, $matches );
387
  }
388
 
389
 
390
  $fields = array();
391
- if ( !empty( $matches ) ) {
392
- foreach ( $matches[1] as $field_name ) {
393
- $fields[trim($field_name, '()')] = trim($field_name,'()');
394
  }
395
  }
396
 
397
  return $fields;
398
  }
399
 
400
- public static function handle_user_function( $evaluate )
401
- {
402
- $evaluate = stripcslashes( $evaluate );
403
  $occurrences = preg_match_all('/(\\w+)\(([^\)]*)\)/', $evaluate, $matches);
404
 
405
- if( $occurrences > 0 )
406
- {
407
  for ($i = 0; $i < $occurrences; $i++) {
408
  $result = false;
409
  $function = $matches[1][$i];
410
- $field = isset( $matches[2] ) ? rtrim( $matches[2][$i], ',' ) : '';
411
 
412
- if( $function === 'USER' )
413
- {
414
- $result = WPV_Handle_Users_Functions::get_user_field( $field );
415
  }
416
 
417
- if( $result ){
418
- $evaluate = str_replace( $matches[0][$i], $result, $evaluate );
419
  }
420
  }
421
  }
@@ -428,26 +426,25 @@ class WPToolset_Forms_Conditional
428
  */
429
  public static function ajaxCustomConditional() {
430
  $res = array('passed' => array(), 'failed' => array());
431
- $conditional = stripslashes_deep($_POST['conditions']);
432
- foreach ($conditional as $k => $c ) {
433
- $post_values = stripslashes_deep($_POST['values']);
434
  $values = array();
435
- foreach ( $post_values as $fid => $value ) {
436
- if ( isset( $_POST['field_types'][$fid] ) ) {
437
  $field_type = stripslashes_deep($_POST['field_types'][$fid]);
438
- wptoolset_form_field_add_filters( $field_type );
439
- $value = apply_filters( 'wptoolset_conditional_value_php',
440
- $value, $field_type );
441
  }
442
  $values[$fid] = $value;
443
  }
444
- if ( $passed = self::evaluateCustom( $c, $values ) ) {
445
  $res['passed'][] = $k;
446
  } else {
447
  $res['failed'][] = $k;
448
  }
449
  }
450
- echo json_encode( $res );
451
  die();
452
  }
453
 
@@ -456,11 +453,9 @@ class WPToolset_Forms_Conditional
456
  *
457
  * @param type $config
458
  */
459
- public function actionFieldClass( $config ) {
460
  if (
461
- !empty( $config['conditional'] )
462
- && array_key_exists( 'conditions', $config['conditional'] )
463
- && !self::evaluate( $config['conditional'] )
464
  ) {
465
  echo ' wpt-hidden js-wpt-remove-on-submit js-wpt-validation-ignore';
466
  }
@@ -471,7 +466,7 @@ class WPToolset_Forms_Conditional
471
  *
472
  * @return type
473
  */
474
- public function getData(){
475
  $this->_parseData();
476
  return array(
477
  'triggers' => $this->_triggers,
@@ -483,35 +478,35 @@ class WPToolset_Forms_Conditional
483
 
484
  }
485
 
 
486
 
487
-
488
- if( !class_exists('WPV_Handle_Users_Functions') )
489
- {
490
- class WPV_Handle_Users_Functions{
491
 
492
  private static $field;
493
 
494
- public static function get_user_field( $field )
495
- {
496
- if( !$field ) return false;
497
 
498
  self::$field = str_replace("'", '', $field);
499
 
500
- $ret = self::get_info( );
501
 
502
- if( $ret !== false ) return "'".$ret."'";
 
503
 
504
  return false;
505
  }
506
 
507
- private static function get_info( )
508
- {
 
 
509
  global $current_user;
510
 
511
  get_currentuserinfo();
512
 
513
- switch( self::$field )
514
- {
515
  case 'role':
516
  return isset($current_user->roles[0]) ? $current_user->roles[0] : 'Subscriber';
517
  break;
@@ -531,5 +526,7 @@ if( !class_exists('WPV_Handle_Users_Functions') )
531
 
532
  return false;
533
  }
 
534
  }
 
535
  }
1
  <?php
2
+
3
  /*
4
  * - Checks conditionals when form is displayed and values changed
5
  * - Checks simple conditionals using JS
41
  * 'custom' => '($wpcf-text = show) OR ($wpcf-date > '21-01-2014')'
42
  * );
43
  */
44
+ if (!defined('ICL_COMMON_FUNCTIONS')) {
45
+ require_once WPTOOLSET_COMMON_PATH . '/functions.php';
46
  }
47
  if (!function_exists('wpv_filter_parse_date')) {
48
+ require_once WPTOOLSET_COMMON_PATH . '/wpv-filter-date-embedded.php';
49
  }
50
 
51
  require_once WPTOOLSET_COMMON_PATH . '/expression-parser/parser.php';
58
  *
59
  * @author Srdjan
60
  */
61
+ class WPToolset_Forms_Conditional {
 
 
62
 
63
  private $__formID;
64
  protected $_collected = array(), $_triggers = array(), $_fields = array(), $_custom_triggers = array(), $_custom_fields = array();
68
  *
69
  * @param type $formID
70
  */
71
+ public function __construct($formID) {
72
+ $this->__formID = trim($formID, '#');
73
  // Register and enqueue
74
+ wp_register_script('wptoolset-form-conditional', WPTOOLSET_FORMS_RELPATH . '/js/conditional.js', array('jquery', 'jquery-effects-scale'), WPTOOLSET_FORMS_VERSION, true);
75
+ wp_enqueue_script('wptoolset-form-conditional');
 
 
76
  $js_data = array(
77
+ 'ajaxurl' => admin_url('admin-ajax.php', null),
78
  );
79
+ wp_localize_script('wptoolset-form-conditional', 'wptConditional', $js_data);
80
 
81
+ wp_register_script('wptoolset-parser', icl_get_file_relpath(dirname(dirname(__FILE__))) . '/expression-parser/js/parser.js', array('jquery'), WPTOOLSET_FORMS_VERSION, true);
82
+ wp_enqueue_script('wptoolset-parser');
 
 
83
  $js_data = array(
84
+ 'ajaxurl' => admin_url('admin-ajax.php', null),
85
  );
86
  // Render settings
87
+ add_action('admin_print_footer_scripts', array($this, 'renderJsonData'), 30);
88
+ add_action('wp_footer', array($this, 'renderJsonData'), 30);
89
  // Check conditional and hide field
90
+ add_action('wptoolset_field_class', array($this, 'actionFieldClass'));
91
  }
92
 
93
  /**
97
  *
98
  * @param type $config
99
  */
100
+ public function add($config) {
101
+ if (!empty($config['conditional'])) {
102
  $this->_collected[$config['id']] = $config['conditional'];
103
  return;
104
  }
108
  * Sets JSON data to be used with conditional.js
109
  */
110
  protected function _parseData() {
111
+ foreach ($this->_collected as $id => $config) {
112
+ if (!empty($config['custom'])) {
113
+
114
+ $evaluate = $config['custom'];
115
+ //###############################################################################################
116
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193583580/comments
117
+ //Fix REGEX conditions that contains \ that is stripped out
118
+ if (strpos($evaluate, "REGEX") === false) {
119
+ $evaluate = wpv_filter_parse_date($evaluate);
120
+ $evaluate = self::handle_user_function($evaluate);
121
+ }
122
+ //###############################################################################################
123
+ $fields = self::extractFields($evaluate);
124
 
125
+ foreach ($fields as $field) {
126
  $this->_custom_fields[$id]['custom'] = $evaluate;
127
  $this->_custom_fields[$id]['triggers'][] = $field;
128
  $this->_custom_triggers[$field][] = $id;
129
  }
130
  } else {
131
+ if (isset($config) && isset($config['conditions'])) {
132
+ if (isset($config) && isset($config['relation']))
133
+ $this->_fields[$id]['relation'] = $config['relation'];
134
+
135
+ foreach ($config['conditions'] as &$c) {
136
+ /*
137
+ * $c[id] - field id
138
+ * $c[type] - field type
139
+ * $c[operator] - operator
140
+ * $c[args] - array(value, [value2]...)
141
+ */
142
+ if (!isset($this->_triggers[$c['id']]))
143
+ $this->_triggers[$c['id']] = array();
144
+ $c['args'] = apply_filters('wptoolset_conditional_args_js', $c['args'], $c['type']);
145
+ $this->_fields[$id]['conditions'][] = $c;
146
+ if (!in_array($id, $this->_triggers[$c['id']]))
147
+ $this->_triggers[$c['id']][] = $id;
148
+ }
 
149
  }
150
  }
151
  }
156
  */
157
  public function renderJsonData() {
158
  $this->_parseData();
159
+ if (!empty($this->_triggers)) {
160
  echo '<script type="text/javascript">wptCondTriggers["#'
161
+ . $this->__formID . '"] = ' . json_encode($this->_triggers) . ';</script>';
162
  }
163
+ if (!empty($this->_fields)) {
164
  echo '<script type="text/javascript">wptCondFields["#'
165
+ . $this->__formID . '"] = ' . json_encode($this->_fields) . ';</script>';
166
  }
167
+ if (!empty($this->_custom_triggers)) {
168
  echo '<script type="text/javascript">wptCondCustomTriggers["#'
169
+ . $this->__formID . '"] = ' . json_encode($this->_custom_triggers) . ';</script>';
170
  }
171
+ if (!empty($this->_custom_fields)) {
172
  echo '<script type="text/javascript">wptCondCustomFields["#'
173
+ . $this->__formID . '"] = ' . json_encode($this->_custom_fields) . ';</script>';
174
  }
175
  }
176
 
181
  * @param array $values
182
  * @return type
183
  */
184
+ public static function evaluate($config) {
185
  // Custom conditional
186
+ if (!empty($config['custom'])) {
187
+ return self::evaluateCustom($config['custom'], $config['values']);
188
  }
189
 
190
  /**
191
  * check conditions
192
  */
193
+ if (!array_key_exists('conditions', $config)) {
194
+ return true;
195
  }
196
 
197
  $passedOne = false;
198
  $passedAll = true;
199
  $relation = $config['relation'];
200
 
201
+ foreach ($config['conditions'] as $c) {
202
  // Add filters
203
+ wptoolset_form_field_add_filters($c['type']);
204
+ $c['args'] = apply_filters('wptoolset_conditional_args_php', $c['args'], $c['type']);
205
+ $value = isset($config['values'][$c['id']]) ? $config['values'][$c['id']] : null;
206
+ $value = apply_filters('wptoolset_conditional_value_php', $value, $c['type']);
 
207
  $compare = $c['args'][0];
208
+ switch ($c['operator']) {
209
  case '=':
210
  case '==':
211
  $passed = $value == $compare;
212
  break;
213
 
214
  case '>':
215
+ $passed = floatval($value) > floatval($compare);
216
  break;
217
 
218
  case '>=':
219
+ $passed = floatval($value) >= floatval($compare);
220
  break;
221
 
222
  case '<':
223
+ $passed = floatval($value) < floatval($compare);
224
  break;
225
 
226
  case '<=':
227
+ $passed = floatval($value) <= floatval($compare);
228
  break;
229
 
230
  case '===':
240
  break;
241
 
242
  case 'between':
243
+ $passed = floatval($value) > floatval($compare) && floatval($value) < floatval($c['args'][1]);
244
  break;
245
 
246
  default:
247
  $passed = false;
248
  break;
249
  }
250
+ if (!$passed) {
251
  $passedAll = false;
252
  } else {
253
  $passedOne = true;
254
  }
255
  }
256
+ if ($relation == 'AND' && $passedAll) {
257
  return true;
258
  }
259
+ if ($relation == 'OR' && $passedOne) {
260
  return true;
261
  }
262
  return false;
271
  * @param type $evaluate
272
  * @return boolean
273
  */
274
+ public static function evaluateCustom($evaluate, $values) {
275
+ //###############################################################################################
276
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193583580/comments
277
+ //Fix REGEX conditions that contains \ that is stripped out
278
+ if (strpos($evaluate, "REGEX") === false) {
279
+ $evaluate = trim(stripslashes($evaluate));
280
+ // Check dates
281
+ $evaluate = wpv_filter_parse_date($evaluate);
282
+ $evaluate = self::handle_user_function($evaluate);
283
+ }
 
 
 
 
 
 
 
 
 
 
 
 
284
 
285
+ $fields = self::extractFields($evaluate);
286
+ $evaluate = self::_update_values_in_expression($evaluate, $fields, $values);
287
 
288
+ $check = false;
289
+ try {
290
+ $parser = new Toolset_Parser($evaluate);
291
+ $parser->parse();
292
+ $check = $parser->evaluate();
293
+ } catch (Exception $e) {
294
+ $check = false;
295
+ }
296
+ return $check;
297
+ }
298
 
299
+ static function sortByLength($a, $b) {
300
+ return strlen($b) - strlen($a);
301
+ }
302
 
303
+ private static function _update_values_in_expression($evaluate, $fields, $values) {
304
+ // use string replace to replace any fields with their values.
305
+ // Sort by length just in case a field name contians a shorter version of another field name.
306
+ // eg. $my-field and $my-field-2
307
 
308
+ $keys = array_keys($fields);
309
+ usort($keys, 'WPToolset_Forms_Conditional::sortByLength');
310
 
311
+ foreach ($keys as $key) {
312
+ $is_numeric = false;
313
+ $is_array = false;
314
+ $value = isset($values[$fields[$key]]) ? $values[$fields[$key]] : '';
315
+ if ($value == '') {
316
+ $value = "''";
317
+ }
318
+ if (is_numeric($value)) {
319
+ $value = '\'' . $value . '\'';
320
+ $is_numeric = true;
321
+ }
322
 
323
+ if ('array' === gettype($value)) {
324
+ $is_array = true;
325
  // workaround for datepicker data to cover all cases
326
+ if (array_key_exists('timestamp', $value)) {
327
+ if (is_numeric($value['timestamp'])) {
328
+ $value = $value['timestamp'];
329
+ } else if (is_array($value['timestamp'])) {
330
+ $value = implode(',', array_values($value['timestamp']));
331
+ }
332
+ } else if (array_key_exists('datepicker', $value)) {
333
+ if (is_numeric($value['datepicker'])) {
334
+ $value = $value['datepicker'];
335
+ } else if (is_array($value['datepicker'])) {
336
+ $value = implode(',', array_values($value['datepicker']));
337
+ }
338
+ } else {
339
+ $value = implode(',', array_values($value));
 
 
 
 
 
 
 
 
 
 
340
  }
341
  }
342
 
343
+ if (!empty($value) && $value != "''" && !$is_numeric && !$is_array) {
344
+ $value = '\'' . $value . '\'';
345
+ }
346
 
347
+ // First replace the $(field_name) format
348
+ $evaluate = str_replace('$(' . $fields[$key] . ')', $value, $evaluate);
349
+ // next replace the $field_name format
350
+ $evaluate = str_replace('$' . $fields[$key], $value, $evaluate);
351
+ }
352
+ return $evaluate;
353
+ }
 
354
 
355
  /**
356
  * Extracts fields from custom conditional statement.
358
  * @param type $evaluate
359
  * @return type
360
  */
361
+ public static function extractFields($evaluate) {
362
+ //###############################################################################################
363
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193583580/comments
364
+ //Fix REGEX conditions that contains \ that is stripped out
365
+ if (strpos($evaluate, "REGEX") === false) {
366
+ $evaluate = trim(stripslashes($evaluate));
367
+ // Check dates
368
+ $evaluate = wpv_filter_parse_date($evaluate);
369
+ $evaluate = self::handle_user_function($evaluate);
370
+ }
371
 
372
  // Add quotes = > < >= <= === <> !==
373
+ $strings_count = preg_match_all('/[=|==|===|<=|<==|<===|>=|>==|>===|\!===|\!==|\!=|<>]\s(?!\$)(\w*)[\)|\$|\W]/', $evaluate, $matches);
374
+
375
+ if (!empty($matches[1])) {
376
+ foreach ($matches[1] as $temp_match) {
377
+ $temp_replace = is_numeric($temp_match) ? $temp_match : '\'' . $temp_match . '\'';
378
+ $evaluate = str_replace(' ' . $temp_match . ')', ' ' . $temp_replace . ')', $evaluate);
 
 
379
  }
380
  }
381
  // if new version $(field-value) use this regex
382
+ if (preg_match('/\$\(([^()]+)\)/', $evaluate)) {
383
+ preg_match_all('/\$\(([^()]+)\)/', $evaluate, $matches);
384
  }
385
  // if old version $field-value use this other
386
+ else {
387
+ preg_match_all('/\$([^\s]*)/', $evaluate, $matches);
388
  }
389
 
390
 
391
  $fields = array();
392
+ if (!empty($matches)) {
393
+ foreach ($matches[1] as $field_name) {
394
+ $fields[trim($field_name, '()')] = trim($field_name, '()');
395
  }
396
  }
397
 
398
  return $fields;
399
  }
400
 
401
+ public static function handle_user_function($evaluate) {
402
+ $evaluate = stripcslashes($evaluate);
 
403
  $occurrences = preg_match_all('/(\\w+)\(([^\)]*)\)/', $evaluate, $matches);
404
 
405
+ if ($occurrences > 0) {
 
406
  for ($i = 0; $i < $occurrences; $i++) {
407
  $result = false;
408
  $function = $matches[1][$i];
409
+ $field = isset($matches[2]) ? rtrim($matches[2][$i], ',') : '';
410
 
411
+ if ($function === 'USER') {
412
+ $result = WPV_Handle_Users_Functions::get_user_field($field);
 
413
  }
414
 
415
+ if ($result) {
416
+ $evaluate = str_replace($matches[0][$i], $result, $evaluate);
417
  }
418
  }
419
  }
426
  */
427
  public static function ajaxCustomConditional() {
428
  $res = array('passed' => array(), 'failed' => array());
429
+ $conditional = stripslashes_deep($_POST['conditions']);
430
+ foreach ($conditional as $k => $c) {
431
+ $post_values = stripslashes_deep($_POST['values']);
432
  $values = array();
433
+ foreach ($post_values as $fid => $value) {
434
+ if (isset($_POST['field_types'][$fid])) {
435
  $field_type = stripslashes_deep($_POST['field_types'][$fid]);
436
+ wptoolset_form_field_add_filters($field_type);
437
+ $value = apply_filters('wptoolset_conditional_value_php', $value, $field_type);
 
438
  }
439
  $values[$fid] = $value;
440
  }
441
+ if ($passed = self::evaluateCustom($c, $values)) {
442
  $res['passed'][] = $k;
443
  } else {
444
  $res['failed'][] = $k;
445
  }
446
  }
447
+ echo json_encode($res);
448
  die();
449
  }
450
 
453
  *
454
  * @param type $config
455
  */
456
+ public function actionFieldClass($config) {
457
  if (
458
+ !empty($config['conditional']) && array_key_exists('conditions', $config['conditional']) && !self::evaluate($config['conditional'])
 
 
459
  ) {
460
  echo ' wpt-hidden js-wpt-remove-on-submit js-wpt-validation-ignore';
461
  }
466
  *
467
  * @return type
468
  */
469
+ public function getData() {
470
  $this->_parseData();
471
  return array(
472
  'triggers' => $this->_triggers,
478
 
479
  }
480
 
481
+ if (!class_exists('WPV_Handle_Users_Functions')) {
482
 
483
+ class WPV_Handle_Users_Functions {
 
 
 
484
 
485
  private static $field;
486
 
487
+ public static function get_user_field($field) {
488
+ if (!$field)
489
+ return false;
490
 
491
  self::$field = str_replace("'", '', $field);
492
 
493
+ $ret = self::get_info();
494
 
495
+ if ($ret !== false)
496
+ return "'" . $ret . "'";
497
 
498
  return false;
499
  }
500
 
501
+ private static function get_info() {
502
+ if (!is_user_logged_in()) {
503
+ return false;
504
+ }
505
  global $current_user;
506
 
507
  get_currentuserinfo();
508
 
509
+ switch (self::$field) {
 
510
  case 'role':
511
  return isset($current_user->roles[0]) ? $current_user->roles[0] : 'Subscriber';
512
  break;
526
 
527
  return false;
528
  }
529
+
530
  }
531
+
532
  }
embedded/common/toolset-forms/classes/class.credaudio.php CHANGED
@@ -7,10 +7,6 @@ require_once 'class.audio.php';
7
  *
8
  * @author Srdjan
9
  *
10
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.credaudio.php $
11
- * $LastChangedDate: 2014-08-22 12:23:29 +0200 (Fri, 22 Aug 2014) $
12
- * $LastChangedRevision: 26350 $
13
- * $LastChangedBy: francesco $
14
  *
15
  */
16
  class WPToolset_Field_Credaudio extends WPToolset_Field_Credfile
7
  *
8
  * @author Srdjan
9
  *
 
 
 
 
10
  *
11
  */
12
  class WPToolset_Field_Credaudio extends WPToolset_Field_Credfile
embedded/common/toolset-forms/classes/class.credfile.php CHANGED
@@ -1,10 +1,7 @@
1
  <?php
 
2
  /**
3
  *
4
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.credfile.php $
5
- * $LastChangedDate: 2014-08-08 23:11:46 +0200 (Fri, 08 Aug 2014) $
6
- * $LastChangedRevision: 25806 $
7
- * $LastChangedBy: francesco $
8
  *
9
  */
10
  require_once 'class.textfield.php';
@@ -14,15 +11,46 @@ require_once 'class.textfield.php';
14
  *
15
  * @author Francesco / Srdjan
16
  */
17
- class WPToolset_Field_Credfile extends WPToolset_Field_Textfield
18
- {
19
 
 
 
20
  public function init() {
21
- wp_register_script( 'wpt-field-credfile',
22
- WPTOOLSET_FORMS_RELPATH . '/js/credfile.js',
23
- array('wptoolset-forms'), WPTOOLSET_FORMS_VERSION, true );
24
- wp_enqueue_script( 'wpt-field-credfile' );
25
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  public static function registerScripts() {
28
 
@@ -43,51 +71,51 @@ class WPToolset_Field_Credfile extends WPToolset_Field_Textfield
43
  public function metaform() {
44
  $value = $this->getValue();
45
  $name = $this->getName();
46
- if ( isset($this->_data['title']) ){
47
- $title = $this->_data['title'];
48
- }else{
49
- $title = $name;
50
  }
51
 
52
- $id = str_replace( array( "[", "]" ), "", $name );
53
  $delete_input_showhide = '';
54
  $button_extra_classnames = '';
55
 
56
  $has_image = false;
57
  $is_empty = false;
58
 
59
- if ( empty( $value ) ) {
60
- $value = ''; // NOTE we need to set it to an empty string because sometimes it is NULL on repeating fields
61
- $is_empty = true;
62
- $delete_input_showhide = ' style="display:none"';
63
  }
64
 
65
- if ( $name == '_featured_image' ) {
66
- $title = __( 'Featured Image', 'wpv-views' );
67
- if ( !$is_empty ) {
68
- if ( preg_match( '/src="([\w\d\:\/\._-]*)"/', $value, $_v ) ) {
69
- $value = $_v[1];
70
- }
71
  }
 
72
  }
73
 
74
- if ( !$is_empty ) {
75
- $pathinfo = pathinfo( $value );
76
- // TODO we should check against the allowed mime types, not file extensions
77
- if ( isset( $pathinfo['extension'] ) && in_array( strtolower( $pathinfo['extension'] ), array( 'png', 'gif', 'jpg', 'jpeg', 'bmp', 'tif' ) ) ) {
78
- $has_image = true;
79
- }
80
  }
81
 
82
- if ( array_key_exists( 'use_bootstrap', $this->_data ) && $this->_data['use_bootstrap'] ) {
83
- $button_extra_classnames = ' btn btn-default btn-sm';
84
  }
85
-
86
- $preview_file = '';//WPTOOLSET_FORMS_RELPATH . '/images/icon-attachment32.png';
87
  $attr_hidden = array(
88
  'id' => $id . "_hidden",
89
- 'class' => 'js-wpv-credfile-hidden',
90
- 'data-wpt-type' => 'file'
91
  );
92
  $attr_file = array(
93
  'id' => $id . "_file",
@@ -95,7 +123,7 @@ class WPToolset_Field_Credfile extends WPToolset_Field_Textfield
95
  'alt' => $value,
96
  );
97
 
98
- if ( !$is_empty ) {
99
  $preview_file = $value;
100
  // Set attributes
101
  $attr_file['disabled'] = 'disabled';
@@ -105,13 +133,14 @@ class WPToolset_Field_Credfile extends WPToolset_Field_Textfield
105
  }
106
 
107
  $form = array();
 
108
  $form[] = array(
109
- '#type' => 'markup',
110
- '#markup' => '<input type="button" style="display:none" data-action="undo" class="js-wpt-credfile-undo wpt-credfile-undo' . $button_extra_classnames . '" value="' . esc_attr( __( 'Restore original', 'wpv-views' ) ) . '" />',
111
  );
112
  $form[] = array(
113
- '#type' => 'markup',
114
- '#markup' => '<input type="button"' . $delete_input_showhide . ' data-action="delete" class="js-wpt-credfile-delete wpt-credfile-delete' . $button_extra_classnames . '" value="' . esc_attr( __( 'Delete', 'wpv-views' ) ) . '" />',
115
  );
116
  $form[] = array(
117
  '#type' => 'hidden',
@@ -130,10 +159,19 @@ class WPToolset_Field_Credfile extends WPToolset_Field_Textfield
130
  '#validate' => $this->getValidationData(),
131
  '#repetitive' => $this->isRepetitive(),
132
  );
133
- if ( $has_image ) {
 
 
 
 
 
 
 
 
 
134
  $form[] = array(
135
  '#type' => 'markup',
136
- '#markup' => '<span class="js-wpt-credfile-preview wpt-credfile-preview"><img id="'.$id.'_image" src="' . $preview_file . '" title="' . $preview_file . '" alt="' . $preview_file . '" class="js-wpt-credfile-preview-item wpt-credfile-preview-item" /></span>',
137
  );
138
  } else {
139
  //if ( !$is_empty )
1
  <?php
2
+
3
  /**
4
  *
 
 
 
 
5
  *
6
  */
7
  require_once 'class.textfield.php';
11
  *
12
  * @author Francesco / Srdjan
13
  */
14
+ class WPToolset_Field_Credfile extends WPToolset_Field_Textfield {
 
15
 
16
+ public $enable_progress_bar;
17
+
18
  public function init() {
19
+ wp_register_script('wpt-field-credfile', WPTOOLSET_FORMS_RELPATH . '/js/credfile.js', array('wptoolset-forms'), WPTOOLSET_FORMS_VERSION, true);
20
+ wp_enqueue_script('wpt-field-credfile');
21
+
22
+ $this->enable_progress_bar = true;
23
+ if ($this->enable_progress_bar) {
24
+ //Add settings switch in order to use AJAX JQUERY UPLOAD or not
25
+ $scriptpath = WPTOOLSET_FORMS_RELPATH . '/js/jquery_upload/';
26
+ $stylepath = WPTOOLSET_FORMS_RELPATH . '/js/jquery_upload/';
27
+
28
+ wp_enqueue_style('progress_bar-style', $stylepath . 'progress_bar.css');
29
+
30
+ if (!wp_script_is('jquery')) {
31
+ wp_enqueue_script('jquery', $scriptpath . 'jquery.min.js', array(), '', false);
32
+ }
33
+ wp_enqueue_script('jquery-ui-script', $scriptpath . 'jquery-ui.min.js', array('jquery'), '', true);
34
+ wp_enqueue_script('jquery-ui-widget-script', $scriptpath . 'jquery.ui.widget.js', array('jquery'), '', true);
35
+ //wp_enqueue_script('jtmpl-script', $scriptpath . 'tmpl.min.js', array('jquery'), '', true);
36
+ wp_enqueue_script('load-image-all-script', $scriptpath . 'load-image.all.min.js', array('jquery'), '', true);
37
+ //wp_enqueue_script('canvas-to-blob-script', $scriptpath . 'canvas-to-blob.min.js', array('jquery'), '', true);
38
+ //wp_enqueue_script('jquery-blueimp-gallery-script', $scriptpath . 'jquery.blueimp-gallery.min.js', array('jquery'), '', true);
39
+ wp_enqueue_script('jquery-iframe-transport-script', $scriptpath . 'jquery.iframe-transport.js', array('jquery'), '', true);
40
+ wp_enqueue_script('jquery-fileupload-script', $scriptpath . 'jquery.fileupload.js', array('jquery'), '', true);
41
+ wp_enqueue_script('jquery-fileupload-process-script', $scriptpath . 'jquery.fileupload-process.js', array('jquery'), '', true);
42
+ wp_enqueue_script('jquery-fileupload-image-script', $scriptpath . 'jquery.fileupload-image.js', array('jquery'), '', true);
43
+ wp_enqueue_script('jquery-fileupload-audio-script', $scriptpath . 'jquery.fileupload-audio.js', array('jquery'), '', true);
44
+ wp_enqueue_script('jquery-fileupload-video-script', $scriptpath . 'jquery.fileupload-video.js', array('jquery'), '', true);
45
+ wp_enqueue_script('jquery-fileupload-validate-script', $scriptpath . 'jquery.fileupload-validate.js', array('jquery'), '', true);
46
+ wp_enqueue_script('jquery-fileupload-ui-script', $scriptpath . 'jquery.fileupload-ui.js', array('jquery'), '', true);
47
+ wp_enqueue_script('jquery-fileupload-jquery-ui-script', $scriptpath . 'jquery.fileupload-jquery-ui.js', array('jquery'), '', true);
48
+ wp_enqueue_script('my_ajax_file_uploader', $scriptpath . 'file_upload.js', array('jquery'));
49
+
50
+ //wp_localize_script('my_ajax_file_uploader_thing', 'settings', array('ajaxurl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('uploader_nonce')));
51
+ wp_localize_script('my_ajax_file_uploader', 'settings', array('ajaxurl' => plugins_url("submit.php", __FILE__)));
52
+ }
53
+ }
54
 
55
  public static function registerScripts() {
56
 
71
  public function metaform() {
72
  $value = $this->getValue();
73
  $name = $this->getName();
74
+ if (isset($this->_data['title'])) {
75
+ $title = $this->_data['title'];
76
+ } else {
77
+ $title = $name;
78
  }
79
 
80
+ $id = str_replace(array("[", "]"), "", $name);
81
  $delete_input_showhide = '';
82
  $button_extra_classnames = '';
83
 
84
  $has_image = false;
85
  $is_empty = false;
86
 
87
+ if (empty($value)) {
88
+ $value = ''; // NOTE we need to set it to an empty string because sometimes it is NULL on repeating fields
89
+ $is_empty = true;
90
+ $delete_input_showhide = ' style="display:none"';
91
  }
92
 
93
+ if ($name == '_featured_image') {
94
+ $title = __('Featured Image', 'wpv-views');
95
+ if (!$is_empty) {
96
+ if (preg_match('/src="([\w\d\:\/\._-]*)"/', $value, $_v)) {
97
+ $value = $_v[1];
 
98
  }
99
+ }
100
  }
101
 
102
+ if (!$is_empty) {
103
+ $pathinfo = pathinfo($value);
104
+ // TODO we should check against the allowed mime types, not file extensions
105
+ if (isset($pathinfo['extension']) && in_array(strtolower($pathinfo['extension']), array('png', 'gif', 'jpg', 'jpeg', 'bmp', 'tif'))) {
106
+ $has_image = true;
107
+ }
108
  }
109
 
110
+ if (array_key_exists('use_bootstrap', $this->_data) && $this->_data['use_bootstrap']) {
111
+ $button_extra_classnames = ' btn btn-default btn-sm';
112
  }
113
+
114
+ $preview_file = ''; //WPTOOLSET_FORMS_RELPATH . '/images/icon-attachment32.png';
115
  $attr_hidden = array(
116
  'id' => $id . "_hidden",
117
+ 'class' => 'js-wpv-credfile-hidden',
118
+ 'data-wpt-type' => 'file'
119
  );
120
  $attr_file = array(
121
  'id' => $id . "_file",
123
  'alt' => $value,
124
  );
125
 
126
+ if (!$is_empty) {
127
  $preview_file = $value;
128
  // Set attributes
129
  $attr_file['disabled'] = 'disabled';
133
  }
134
 
135
  $form = array();
136
+
137
  $form[] = array(
138
+ '#type' => 'markup',
139
+ '#markup' => '<input type="button" style="display:none" data-action="undo" class="js-wpt-credfile-undo wpt-credfile-undo' . $button_extra_classnames . '" value="' . esc_attr(__('Restore original', 'wpv-views')) . '" />',
140
  );
141
  $form[] = array(
142
+ '#type' => 'markup',
143
+ '#markup' => '<input type="button"' . $delete_input_showhide . ' data-action="delete" class="js-wpt-credfile-delete wpt-credfile-delete' . $button_extra_classnames . '" value="' . esc_attr(__('Clear', 'wpv-views')) . '" />',
144
  );
145
  $form[] = array(
146
  '#type' => 'hidden',
159
  '#validate' => $this->getValidationData(),
160
  '#repetitive' => $this->isRepetitive(),
161
  );
162
+
163
+ if ($this->enable_progress_bar) {
164
+ //Progress Bar
165
+ $form[] = array(
166
+ '#type' => 'markup',
167
+ '#markup' => '<div id="progress_' . $id . '" class="meter" style="display:none;"><span class = "progress-bar" style="width:0;"></span></div>',
168
+ );
169
+ }
170
+
171
+ if ($has_image) {
172
  $form[] = array(
173
  '#type' => 'markup',
174
+ '#markup' => '<span class="js-wpt-credfile-preview wpt-credfile-preview"><img id="' . $id . '_image" src="' . $preview_file . '" title="' . $preview_file . '" alt="' . $preview_file . '" class="js-wpt-credfile-preview-item wpt-credfile-preview-item" /></span>',
175
  );
176
  } else {
177
  //if ( !$is_empty )
embedded/common/toolset-forms/classes/class.credimage.php CHANGED
@@ -7,10 +7,6 @@ require_once 'class.image.php';
7
  *
8
  * @author Srdjan
9
  *
10
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.credimage.php $
11
- * $LastChangedDate: 2014-08-22 12:23:29 +0200 (Fri, 22 Aug 2014) $
12
- * $LastChangedRevision: 26350 $
13
- * $LastChangedBy: francesco $
14
  *
15
  */
16
  class WPToolset_Field_Credimage extends WPToolset_Field_Credfile
7
  *
8
  * @author Srdjan
9
  *
 
 
 
 
10
  *
11
  */
12
  class WPToolset_Field_Credimage extends WPToolset_Field_Credfile
embedded/common/toolset-forms/classes/class.credvideo.php CHANGED
@@ -7,10 +7,6 @@ require_once 'class.video.php';
7
  *
8
  * @author Srdjan
9
  *
10
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.credvideo.php $
11
- * $LastChangedDate: 2014-08-22 12:23:29 +0200 (Fri, 22 Aug 2014) $
12
- * $LastChangedRevision: 26350 $
13
- * $LastChangedBy: francesco $
14
  *
15
  */
16
  class WPToolset_Field_Credvideo extends WPToolset_Field_Credfile
7
  *
8
  * @author Srdjan
9
  *
 
 
 
 
10
  *
11
  */
12
  class WPToolset_Field_Credvideo extends WPToolset_Field_Credfile
embedded/common/toolset-forms/classes/class.date.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
 
2
  require_once 'class.field_factory.php';
3
  if (!function_exists('adodb_mktime')) {
4
- require_once WPTOOLSET_FORMS_ABSPATH . '/lib/adodb-time.inc.php';
5
  }
6
 
7
  /**
@@ -11,13 +12,13 @@ if (!function_exists('adodb_mktime')) {
11
  */
12
  class WPToolset_Field_Date extends FieldFactory
13
  {
14
-
15
  // 15/10/1582 00:00 - 31/12/3000 23:59
16
  protected static $_mintimestamp = -12219292800, $_maxtimestamp = 32535215940;
17
 
18
  public function init()
19
  {
20
- }
 
21
 
22
  public static function registerScripts()
23
  {
@@ -27,25 +28,19 @@ class WPToolset_Field_Date extends FieldFactory
27
  {
28
  }
29
 
30
- public static function addFilters(){
31
- if ( has_filter( 'wptoolset_validation_value_date',
32
- array('WPToolset_Field_Date', 'filterValidationValue') ) )
33
- return;
 
34
  // Filter validation
35
- add_filter( 'wptoolset_validation_value_date',
36
- array('WPToolset_Field_Date', 'filterValidationValue') );
37
- add_filter( 'wptoolset_validation_rule_js',
38
- array('WPToolset_Field_Date', 'filterValidationRuleJs') );
39
- add_filter( 'wptoolset_validation_args_php',
40
- array('WPToolset_Field_Date', 'filterValidationArgsPhp'), 10, 2 );
41
  // Filter conditional
42
- add_filter( 'wptoolset_conditional_args_php',
43
- array('WPToolset_Field_Date', 'filterConditionalArgsPhp'), 10, 2 );
44
- add_filter( 'wptoolset_conditional_value_php',
45
- array('WPToolset_Field_Date', 'filterConditionalValuePhp'), 10,
46
- 2 );
47
- add_filter( 'wptoolset_conditional_args_js',
48
- array('WPToolset_Field_Date', 'filterConditionalArgsJs'), 10, 2 );
49
  }
50
 
51
  public function enqueueScripts()
@@ -56,178 +51,197 @@ class WPToolset_Field_Date extends FieldFactory
56
  {
57
  }
58
 
59
- public function metaform() {
 
60
  $time_value = $this->getValue();
61
  $datepicker = $hour = $minute = null;
62
- $timestamp = false;
63
- $readonly = false;
64
- if ( is_admin() ) {
65
- // In this case, getValue returns the timestamp stored as postmeta value on the database
66
- // So we compose $timestamp, $datepicker, $hour and $minute based on that value
67
- if ( !empty( $time_value ) && $time_value != '0' ) {
68
- if ( !is_numeric( $time_value ) ) {
69
- $timestamp = self::strtotime( $time_value );
70
- } else {
71
- $timestamp = $time_value;
72
- }
73
- if ( $timestamp !== false && self::_isTimestampInRange( $timestamp ) ) {
74
- $datepicker = self::timetodate( $timestamp );
75
- $hour = self::timetodate( $timestamp, 'H' );
76
- $minute = self::timetodate( $timestamp, 'i' );
77
- }
78
- }
79
- } else {
80
- // We are on a CRED form, on frontend, so getVAlue returns nothing or a string or an array of the kind array( 'datepicker' =>, 'hour' =>, 'minute' => )
81
- // Note that even if the array is passed, 'hour' and 'minute' will only be passed if there are any
82
- if ( !empty( $time_value ) ) {
83
- if ( is_array( $time_value ) ) {
84
- if ( isset ( $time_value['timestamp'] ) && is_numeric( $time_value['timestamp'] ) && self::_isTimestampInRange( $time_value['timestamp'] ) ) {
85
- $timestamp = $time_value['timestamp'];
86
- $datepicker = self::timetodate( $timestamp );
87
- } else if ( isset( $time_value['datepicker'] ) && $time_value['datepicker'] !== false && is_numeric( $time_value['datepicker'] ) && self::_isTimestampInRange( $time_value['datepicker'] ) ) {
88
- $timestamp = $time_value['datepicker'];
89
- $datepicker = self::timetodate( $timestamp );
90
- }
91
- if ( isset( $time_value['hour'] ) && is_numeric( $time_value['hour'] ) ) {
92
- $hour = $time_value['hour'];
93
- }
94
- if ( isset( $time_value['minute'] ) && is_numeric( $time_value['minute'] ) ) {
95
- $minute = $time_value['minute'];
96
- }
97
- } else {
98
- if ( is_numeric( $time_value ) && self::_isTimestampInRange( $time_value ) ) {
99
- $timestamp = $time_value;
100
- $datepicker = self::timetodate( $timestamp );
101
- } else {
102
- $timestamp = self::strtotime( $time_value );
103
- $datepicker = $time_value;
104
- }
105
- }
106
- }
107
- }
108
  $data = $this->getData();
109
- if ( !$timestamp ) {
110
- // If there is no timestamp, we need to make it an empty string
111
- // A false value would render the hidden field with a value of 1
112
- $timestamp = '';
113
- $datepicker = null;
114
- }
115
-
 
116
  $def_class = 'js-wpt-date';
117
-
118
- $def_class_aux = 'js-wpt-date-auxiliar';
119
-
120
- if ( isset( $data['attribute'] ) && isset( $data['attribute']['readonly'] ) && $data['attribute']['readonly'] == 'readonly' ) {
121
- $def_class .= ' js-wpv-date-readonly';
122
- $def_class_aux .= ' js-wpt-date-readonly';
123
- $readonly = true;
124
- }
125
-
126
  $form = array();
127
-
128
- $validate = $this->getValidationData();
129
- $title = $this->getTitle();
130
-
131
- if ( isset( $validate['required'] ) && !empty( $title ) ) {
132
- // Asterisk
133
- $title .= '&#42;';
134
- }
135
-
136
- $attr_visible = array('class' => $def_class, 'style' => 'display:inline;width:150px;position:relative;z-index:20;', 'readonly' => 'readonly');
137
- $attr_hidden = array('class' => $def_class_aux, 'data-ts' => $timestamp, 'data-wpt-type' => 'date' );
138
-
139
- if ( isset( $data['attribute'] ) && isset( $data['attribute']['placeholder'] ) ) {
140
- $attr_visible['placeholder'] = $data['attribute']['placeholder'];
141
- }
142
-
143
- $form[] = array(
 
 
 
 
 
144
  '#type' => 'textfield',
145
  '#title' => $title,
146
- '#description' => $this->getDescription(),
147
  '#attributes' => $attr_visible,
148
- '#name' => '',
149
  '#value' => $datepicker,
 
150
  );
151
- $form[] = array(
152
  '#type' => 'hidden',
153
  '#title' => $title,
154
  '#attributes' => $attr_hidden,
155
  '#name' => $this->getName() . '[datepicker]',
156
  '#value' => $timestamp,
157
- '#validate' => $validate,
158
  '#repetitive' => $this->isRepetitive(),
159
  );
160
-
161
- /*
162
- // This was the old implementaton
163
- // We have implemented the above one because we need a hidden field to hold the timestamp
164
- // And the visible text input field to display the date string to the user
165
- $form[] = array(
166
- '#type' => 'textfield',
167
- '#title' => $this->getTitle(),
168
- '#attributes' => array('class' => $def_class, 'style' => 'width:150px;'),
169
- '#name' => $this->getName() . '[datepicker]',
170
- '#value' => $timestamp,
171
- '#validate' => $this->getValidationData(),
172
- '#repetitive' => $this->isRepetitive(),
173
- );
174
- */
175
- if ( !empty( $data['add_time'] ) ) {
176
  // Shared attributes
177
- $attributes_hour_minute = array();
178
- if ( $readonly ) {
179
- $attributes_hour_minute['disabled'] = 'disabled' ;
180
- }
181
- if ( array_key_exists( 'use_bootstrap', $this->_data ) && $this->_data['use_bootstrap'] ) {
182
- $attributes_hour_minute['style'] = 'display:inline;width:auto;' ;
183
  }
184
-
185
- // Hour
 
 
 
186
  $hours = 24;
187
  $options = array();
188
- for ( $index = 0; $index < $hours; $index++ ) {
189
  $prefix = $index < 10 ? '0' : '';
190
  $options[$index] = array(
191
- '#title' => $prefix . strval( $index ),
192
  '#value' => $index,
193
  );
194
  }
195
  $hour_element = array(
196
  '#type' => 'select',
197
- '#title' => __( 'Hour', 'wpv-views' ),
198
  '#options' => $options,
199
  '#default_value' => $hour,
200
  '#name' => $this->getName() . '[hour]',
201
  '#inline' => true,
 
202
  );
203
- if ( !empty( $attributes_hour_minute ) ) {
204
- $hour_element['#attributes'] = $attributes_hour_minute;
205
- }
206
  $form[] = $hour_element;
207
  // Minutes
208
  $minutes = 60;
209
  $options = array();
210
- for ( $index = 0; $index < $minutes; $index++ ) {
211
  $prefix = $index < 10 ? '0' : '';
212
  $options[$index] = array(
213
- '#title' => $prefix . strval( $index ),
214
  '#value' => $index,
215
  );
216
  }
217
- $minute_element = array(
218
  '#type' => 'select',
219
- '#title' => __( 'Minute', 'wpv-views' ),
220
  '#options' => $options,
221
  '#default_value' => $minute,
222
  '#name' => $this->getName() . '[minute]',
223
  '#inline' => true,
 
224
  );
225
- if ( !empty( $attributes_hour_minute ) ) {
226
- $minute_element['#attributes'] = $attributes_hour_minute;
227
- }
228
  $form[] = $minute_element;
229
  }
230
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  return $form;
232
  }
233
 
@@ -236,141 +250,154 @@ class WPToolset_Field_Date extends FieldFactory
236
  return WPToolset_Field_Date_Scripts::getDateFormat();
237
  }
238
 
239
- protected function _dateToStrftime( $format ) {
240
- $format = str_replace( 'd', '%d', $format );
241
- $format = str_replace( 'D', '%a', $format );
242
- $format = str_replace( 'j', '%e', $format );
243
- $format = str_replace( 'l', '%A', $format );
244
- $format = str_replace( 'N', '%u', $format );
245
- $format = str_replace( 'w', '%w', $format );
 
246
 
247
- $format = str_replace( 'W', '%W', $format );
248
 
249
- $format = str_replace( 'F', '%B', $format );
250
- $format = str_replace( 'm', '%m', $format );
251
- $format = str_replace( 'M', '%b', $format );
252
- $format = str_replace( 'n', '%m', $format );
253
 
254
- $format = str_replace( 'o', '%g', $format );
255
- $format = str_replace( 'Y', '%Y', $format );
256
- $format = str_replace( 'y', '%y', $format );
257
 
258
  return $format;
259
  }
260
 
261
- public static function filterValidationValue( $value ) {
262
- if ( isset( $value['datepicker'] ) ) {
 
 
 
 
 
 
 
263
  return $value['datepicker'];
264
  }
265
  return $value;
266
  }
267
 
268
- public static function filterValidationRuleJs( $rule ) {
269
- if ( $rule == 'date' ) {
270
- return 'dateADODB_STAMP';
271
- } else {
272
- return $rule;
273
- }
 
274
  }
275
 
276
- public static function filterValidationArgsPhp( $args, $rule ) {
277
- if ( $rule == 'date' ) {
 
278
  return array('$value', self::getDateFormat());
279
  }
280
  return $args;
281
  }
282
 
283
- public static function filterConditionalArgsJs( $args, $type ) {
284
- if ( $type == 'date' ) {
285
- foreach ( $args as &$arg ) {
286
- if ( !is_numeric( $arg ) ) {
287
- // Well it should be a numeric timestamp indeed
288
- $arg = self::strtotime( $arg );
 
289
  }
290
  }
291
  }
292
  return $args;
293
  }
294
 
295
- public static function filterConditionalArgsPhp( $args, $type ) {
296
- if ( $type == 'date' ) {
297
- foreach ( $args as &$arg ) {
298
- $arg = self::filterConditionalValuePhp( $arg, $type );
 
299
  }
300
  }
301
  return $args;
302
  }
303
 
304
- public static function filterConditionalValuePhp( $value, $type ) {
305
- if ( $type == 'date' ) {
306
- if ( !is_numeric( $value ) ) {
307
- // Well it should be a numeric timestamp indeed
308
- $value = self::strtotime( $value );
 
309
  }
310
  // Use timestamp with PHP
311
  // Convert back/forward to have rounded timestamp (no H and i)
312
- // TODO review this because we should not play with timestamps generated on adodb_xxx functions
313
  //$value = self::strtotime( self::timetodate( $value ) );
314
  }
315
  return $value;
316
  }
317
 
318
- // We need to keep this for backwards compatibility
319
- // Note that this function will only convert dates coming on a string:
320
- // - in english
321
- // - inside the valid PHP date range
322
- // We are only using this when the value being checked is not a timestamp
323
- // And we have tried to avoid that situation from happening
324
- // But for old implementation, this happens for date conditions on conditional fields
325
- public static function strtotime( $value, $format = null )
326
  {
327
- if ( is_null( $format ) ) {
328
  $format = self::getDateFormat();
329
  }
330
  /**
331
  * add exception to handle short year
332
  */
333
- if ( 'd/m/y' == $format ) {
334
- preg_match_all( '/(\d{2})/', $value, $value );
335
- $value[0][2] += $value[0][2] < 70? 2000:1900;
336
- $value = implode('-', $value[0] );
337
  }
338
- if ( strpos($format, 'd/m/Y') !== false ) {
339
  // strtotime requires a dash or dot separator to determine dd/mm/yyyy format
340
- preg_match( '/\d{2}\/\d{2}\/\d{4}/', $value, $matches );
341
- if ( !empty( $matches ) ) {
342
- foreach ( $matches as $match ) {
343
- $value = str_replace( $match,
344
- str_replace( '/', '-', $match ), $value );
345
  }
346
  }
347
  }
348
  try {
349
- $date = new DateTime( $value );
350
- } catch ( Exception $e ) {
351
  return false;
352
  }
353
- $timestamp = $date->format( "U" );
354
- return self::_isTimestampInRange( $timestamp ) ? $timestamp : false;
355
  }
356
 
357
- // TODO review this because we should not play with timestamps generated on adodb_xxx functions
358
- public static function timetodate( $timestamp, $format = null )
359
  {
360
- return WPToolset_Field_Date_Scripts::timetodate( $timestamp, $format );
361
  }
362
 
363
- protected static function _isTimestampInRange( $timestamp )
364
  {
365
  return WPToolset_Field_Date_Scripts::_isTimestampInRange($timestamp);
366
  }
367
 
368
  /**
369
  * DEPRECATED
370
- *
371
- * This is not used anymore
372
  */
373
- public static function timeIsValid( $time ) {
 
374
  /*
375
  * http://php.net/manual/en/function.strtotime.php
376
  * The valid range of a timestamp is typically
@@ -384,23 +411,24 @@ class WPToolset_Field_Date extends FieldFactory
384
  * This means that e.g. dates prior to Jan 1, 1970 will not
385
  * work on Windows, some Linux distributions,
386
  * and a few other operating systems.
387
- * PHP 5.1.0 and newer versions overcome this limitation though.
388
  */
389
  // MIN 'Jan 1, 1970' - 0 | Fri, 13 Dec 1901 20:45:54 UTC
390
  $_min_time = self::timeNegativeSupported() ? -2147483646 : 0;
391
  // MAX 'Tue, 19 Jan 2038 03:14:07 UTC' - 2147483647
392
  $_max_time = 2147483647;
393
 
394
- return is_numeric( $time ) && $_min_time <= intval( $time ) && intval( $time ) <= $_max_time;
395
  }
396
 
397
  /**
398
  * DEPRECATED
399
- *
400
- * This is not used anymore
401
  */
402
- public static function timeNegativeSupported() {
403
- return strtotime( 'Fri, 13 Dec 1950 20:45:54 UTC' ) === -601010046;
 
404
  }
405
 
406
  }
1
  <?php
2
+
3
  require_once 'class.field_factory.php';
4
  if (!function_exists('adodb_mktime')) {
5
+ require_once WPTOOLSET_FORMS_ABSPATH . '/lib/adodb-time.inc.php';
6
  }
7
 
8
  /**
12
  */
13
  class WPToolset_Field_Date extends FieldFactory
14
  {
 
15
  // 15/10/1582 00:00 - 31/12/3000 23:59
16
  protected static $_mintimestamp = -12219292800, $_maxtimestamp = 32535215940;
17
 
18
  public function init()
19
  {
20
+ $this->set_placeholder_as_attribute();
21
+ }
22
 
23
  public static function registerScripts()
24
  {
28
  {
29
  }
30
 
31
+ public static function addFilters()
32
+ {
33
+ if (has_filter('wptoolset_validation_value_date', array('WPToolset_Field_Date', 'filterValidationValue'))) {
34
+ return;
35
+ }
36
  // Filter validation
37
+ add_filter('wptoolset_validation_value_date', array('WPToolset_Field_Date', 'filterValidationValue'));
38
+ add_filter('wptoolset_validation_rule_js', array('WPToolset_Field_Date', 'filterValidationRuleJs'));
39
+ add_filter('wptoolset_validation_args_php', array('WPToolset_Field_Date', 'filterValidationArgsPhp'), 10, 2);
 
 
 
40
  // Filter conditional
41
+ add_filter('wptoolset_conditional_args_php', array('WPToolset_Field_Date', 'filterConditionalArgsPhp'), 10, 2);
42
+ add_filter('wptoolset_conditional_value_php', array('WPToolset_Field_Date', 'filterConditionalValuePhp'), 10, 2);
43
+ add_filter('wptoolset_conditional_args_js', array('WPToolset_Field_Date', 'filterConditionalArgsJs'), 10, 2);
 
 
 
 
44
  }
45
 
46
  public function enqueueScripts()
51
  {
52
  }
53
 
54
+ public function metaform()
55
+ {
56
  $time_value = $this->getValue();
57
  $datepicker = $hour = $minute = null;
58
+ $timestamp = null;
59
+ $readonly = false;
60
+ if (is_admin()) {
61
+ if (is_array($time_value) && array_key_exists('timestamp', $time_value) && $time_value ) {
62
+ $timestamp = $time_value['timestamp'];
63
+ }
64
+ $datepicker = self::timetodate($timestamp);
65
+ $hour = self::timetodate($timestamp, 'H');
66
+ $minute = self::timetodate($timestamp, 'i');
67
+ } else {
68
+ // We are on a CRED form, on frontend, so getVAlue returns nothing or a string or an array of the kind array( 'datepicker' =>, 'hour' =>, 'minute' => )
69
+ // Note that even if the array is passed, 'hour' and 'minute' will only be passed if there are any
70
+ if (!empty($time_value)) {
71
+ if (is_array($time_value)) {
72
+ if (isset($time_value['timestamp']) && is_numeric($time_value['timestamp']) && self::_isTimestampInRange($time_value['timestamp'])) {
73
+ $timestamp = $time_value['timestamp'];
74
+ $datepicker = self::timetodate($timestamp);
75
+ } elseif (isset($time_value['datepicker']) && $time_value['datepicker'] !== false && is_numeric($time_value['datepicker']) && self::_isTimestampInRange($time_value['datepicker'])) {
76
+ $timestamp = $time_value['datepicker'];
77
+ $datepicker = self::timetodate($timestamp);
78
+ }
79
+ if (isset($time_value['hour']) && is_numeric($time_value['hour'])) {
80
+ $hour = $time_value['hour'];
81
+ }
82
+ if (isset($time_value['minute']) && is_numeric($time_value['minute'])) {
83
+ $minute = $time_value['minute'];
84
+ }
85
+ } else {
86
+ if (is_numeric($time_value) && self::_isTimestampInRange($time_value)) {
87
+ $timestamp = $time_value;
88
+ $datepicker = self::timetodate($timestamp);
89
+ } else {
90
+ $timestamp = self::strtotime($time_value);
91
+ $datepicker = $time_value;
92
+ }
93
+ }
94
+ }
95
+ }
 
 
 
 
 
 
 
 
96
  $data = $this->getData();
97
+
98
+ if (!$timestamp) {
99
+ // If there is no timestamp, we need to make it an empty string
100
+ // A false value would render the hidden field with a value of 1
101
+ $timestamp = '';
102
+ $datepicker = null;
103
+ }
104
+
105
  $def_class = 'js-wpt-date';
106
+
107
+ $def_class_aux = 'js-wpt-date-auxiliar';
108
+
109
+ if (isset($data['attribute']) && isset($data['attribute']['readonly']) && $data['attribute']['readonly'] == 'readonly') {
110
+ $def_class .= ' js-wpv-date-readonly';
111
+ $def_class_aux .= ' js-wpt-date-readonly';
112
+ $readonly = true;
113
+ }
114
+
115
  $form = array();
116
+
117
+ $validate = $this->getValidationData();
118
+ $title = $this->getTitle();
119
+
120
+ if (isset($validate['required']) && !empty($title)) {
121
+ // Asterisk
122
+ $title .= '&#42;';
123
+ }
124
+
125
+ $attr_visible = array(
126
+ 'class' => $def_class,
127
+ 'style' => 'display:inline;width:150px;position:relative;',
128
+ 'readonly' => 'readonly',
129
+ 'title' => esc_attr(__('Select', 'wpv-views'))." Date"
130
+ );
131
+ $attr_hidden = array('class' => $def_class_aux, 'data-ts' => $timestamp, 'data-wpt-type' => 'date');
132
+
133
+ if (isset($data['attribute']) && isset($data['attribute']['placeholder'])) {
134
+ $attr_visible['placeholder'] = $data['attribute']['placeholder'];
135
+ }
136
+
137
+ $form[] = array(
138
  '#type' => 'textfield',
139
  '#title' => $title,
140
+ '#description' => $this->getDescription(),
141
  '#attributes' => $attr_visible,
142
+ '#name' => $this->getName() . '[display-only]',
143
  '#value' => $datepicker,
144
+ '#inline' => true,
145
  );
146
+ $form[] = array(
147
  '#type' => 'hidden',
148
  '#title' => $title,
149
  '#attributes' => $attr_hidden,
150
  '#name' => $this->getName() . '[datepicker]',
151
  '#value' => $timestamp,
152
+ '#validate' => $validate,
153
  '#repetitive' => $this->isRepetitive(),
154
  );
155
+
156
+ /*
157
+ // This was the old implementaton
158
+ // We have implemented the above one because we need a hidden field to hold the timestamp
159
+ // And the visible text input field to display the date string to the user
160
+ $form[] = array(
161
+ '#type' => 'textfield',
162
+ '#title' => $this->getTitle(),
163
+ '#attributes' => array('class' => $def_class, 'style' => 'width:150px;'),
164
+ '#name' => $this->getName() . '[datepicker]',
165
+ '#value' => $timestamp,
166
+ '#validate' => $this->getValidationData(),
167
+ '#repetitive' => $this->isRepetitive(),
168
+ );
169
+ */
170
+ if (!empty($data['add_time'])) {
171
  // Shared attributes
172
+ $attributes_hour_minute = array();
173
+ if ($readonly) {
174
+ $attributes_hour_minute['disabled'] = 'disabled';
 
 
 
175
  }
176
+ if (array_key_exists('use_bootstrap', $this->_data) && $this->_data['use_bootstrap']) {
177
+ $attributes_hour_minute['style'] = 'display:inline;width:auto;';
178
+ }
179
+
180
+ // Hour
181
  $hours = 24;
182
  $options = array();
183
+ for ($index = 0; $index < $hours; $index++) {
184
  $prefix = $index < 10 ? '0' : '';
185
  $options[$index] = array(
186
+ '#title' => $prefix . strval($index),
187
  '#value' => $index,
188
  );
189
  }
190
  $hour_element = array(
191
  '#type' => 'select',
192
+ '#before' => '<span class="wpt-form-label">' . __('Hour', 'wpv-views') . '</span>',
193
  '#options' => $options,
194
  '#default_value' => $hour,
195
  '#name' => $this->getName() . '[hour]',
196
  '#inline' => true,
197
+ '#attributes' => array('title' => esc_attr(__('Select', 'wpv-views'))." Date"),
198
  );
199
+ if (!empty($attributes_hour_minute)) {
200
+ $hour_element['#attributes'] = $attributes_hour_minute;
201
+ }
202
  $form[] = $hour_element;
203
  // Minutes
204
  $minutes = 60;
205
  $options = array();
206
+ for ($index = 0; $index < $minutes; $index++) {
207
  $prefix = $index < 10 ? '0' : '';
208
  $options[$index] = array(
209
+ '#title' => $prefix . strval($index),
210
  '#value' => $index,
211
  );
212
  }
213
+ $minute_element = array(
214
  '#type' => 'select',
215
+ '#before' => '<span class="wpt-form-label">' . __('Minute', 'wpv-views') . '</span>',
216
  '#options' => $options,
217
  '#default_value' => $minute,
218
  '#name' => $this->getName() . '[minute]',
219
  '#inline' => true,
220
+ '#attributes' => array('title' => esc_attr(__('Select minute', 'wpv-views'))),
221
  );
222
+ if (!empty($attributes_hour_minute)) {
223
+ $minute_element['#attributes'] = $attributes_hour_minute;
224
+ }
225
  $form[] = $minute_element;
226
  }
227
 
228
+ $form[] = array(
229
+ '#type' => 'markup',
230
+ '#inline' => true,
231
+ '#markup' => sprintf(
232
+ '<input type="button" class="button button-secondary js-wpt-date-clear wpt-date-clear" value="%s" %s/>',
233
+ esc_attr(__('Clear', 'wpv-views'))." Date",
234
+ /**
235
+ * show button if array is empty or timestamp in array is
236
+ * empty
237
+ */
238
+ (
239
+ empty($time_value)
240
+ || !isset($time_value['timestamp'])
241
+ || (isset($time_value['timestamp']) && empty($time_value['timestamp']))
242
+ )? 'style="display:none" ':''
243
+ ),
244
+ );
245
  return $form;
246
  }
247
 
250
  return WPToolset_Field_Date_Scripts::getDateFormat();
251
  }
252
 
253
+ protected function _dateToStrftime($format)
254
+ {
255
+ $format = str_replace('d', '%d', $format);
256
+ $format = str_replace('D', '%a', $format);
257
+ $format = str_replace('j', '%e', $format);
258
+ $format = str_replace('l', '%A', $format);
259
+ $format = str_replace('N', '%u', $format);
260
+ $format = str_replace('w', '%w', $format);
261
 
262
+ $format = str_replace('W', '%W', $format);
263
 
264
+ $format = str_replace('F', '%B', $format);
265
+ $format = str_replace('m', '%m', $format);
266
+ $format = str_replace('M', '%b', $format);
267
+ $format = str_replace('n', '%m', $format);
268
 
269
+ $format = str_replace('o', '%g', $format);
270
+ $format = str_replace('Y', '%Y', $format);
271
+ $format = str_replace('y', '%y', $format);
272
 
273
  return $format;
274
  }
275
 
276
+ public static function filterValidationValue($value)
277
+ {
278
+ /**
279
+ * validate fimestamp range is possible
280
+ */
281
+ if (isset($value['timestamp'])) {
282
+ return $value['timestamp'];
283
+ }
284
+ if (isset($value['datepicker'])) {
285
  return $value['datepicker'];
286
  }
287
  return $value;
288
  }
289
 
290
+ public static function filterValidationRuleJs($rule)
291
+ {
292
+ if ($rule == 'date') {
293
+ return 'dateADODB_STAMP';
294
+ } else {
295
+ return $rule;
296
+ }
297
  }
298
 
299
+ public static function filterValidationArgsPhp($args, $rule)
300
+ {
301
+ if ($rule == 'date') {
302
  return array('$value', self::getDateFormat());
303
  }
304
  return $args;
305
  }
306
 
307
+ public static function filterConditionalArgsJs($args, $type)
308
+ {
309
+ if ($type == 'date') {
310
+ foreach ($args as &$arg) {
311
+ if (!is_numeric($arg)) {
312
+ // Well it should be a numeric timestamp indeed
313
+ $arg = self::strtotime($arg);
314
  }
315
  }
316
  }
317
  return $args;
318
  }
319
 
320
+ public static function filterConditionalArgsPhp($args, $type)
321
+ {
322
+ if ($type == 'date') {
323
+ foreach ($args as &$arg) {
324
+ $arg = self::filterConditionalValuePhp($arg, $type);
325
  }
326
  }
327
  return $args;
328
  }
329
 
330
+ public static function filterConditionalValuePhp($value, $type)
331
+ {
332
+ if ($type == 'date') {
333
+ if (!is_numeric($value)) {
334
+ // Well it should be a numeric timestamp indeed
335
+ $value = self::strtotime($value);
336
  }
337
  // Use timestamp with PHP
338
  // Convert back/forward to have rounded timestamp (no H and i)
339
+ // TODO review this because we should not play with timestamps generated on adodb_xxx functions
340
  //$value = self::strtotime( self::timetodate( $value ) );
341
  }
342
  return $value;
343
  }
344
 
345
+ // We need to keep this for backwards compatibility
346
+ // Note that this function will only convert dates coming on a string:
347
+ // - in english
348
+ // - inside the valid PHP date range
349
+ // We are only using this when the value being checked is not a timestamp
350
+ // And we have tried to avoid that situation from happening
351
+ // But for old implementation, this happens for date conditions on conditional fields
352
+ public static function strtotime($value, $format = null)
353
  {
354
+ if (is_null($format)) {
355
  $format = self::getDateFormat();
356
  }
357
  /**
358
  * add exception to handle short year
359
  */
360
+ if ('d/m/y' == $format) {
361
+ preg_match_all('/(\d{2})/', $value, $value);
362
+ $value[0][2] += $value[0][2] < 70 ? 2000 : 1900;
363
+ $value = implode('-', $value[0]);
364
  }
365
+ if (strpos($format, 'd/m/Y') !== false) {
366
  // strtotime requires a dash or dot separator to determine dd/mm/yyyy format
367
+ preg_match('/\d{2}\/\d{2}\/\d{4}/', $value, $matches);
368
+ if (!empty($matches)) {
369
+ foreach ($matches as $match) {
370
+ $value = str_replace($match, str_replace('/', '-', $match), $value);
 
371
  }
372
  }
373
  }
374
  try {
375
+ $date = new DateTime($value);
376
+ } catch (Exception $e) {
377
  return false;
378
  }
379
+ $timestamp = $date->format("U");
380
+ return self::_isTimestampInRange($timestamp) ? $timestamp : false;
381
  }
382
 
383
+ // TODO review this because we should not play with timestamps generated on adodb_xxx functions
384
+ public static function timetodate($timestamp, $format = null)
385
  {
386
+ return WPToolset_Field_Date_Scripts::timetodate($timestamp, $format);
387
  }
388
 
389
+ protected static function _isTimestampInRange($timestamp)
390
  {
391
  return WPToolset_Field_Date_Scripts::_isTimestampInRange($timestamp);
392
  }
393
 
394
  /**
395
  * DEPRECATED
396
+ *
397
+ * This is not used anymore
398
  */
399
+ public static function timeIsValid($time)
400
+ {
401
  /*
402
  * http://php.net/manual/en/function.strtotime.php
403
  * The valid range of a timestamp is typically
411
  * This means that e.g. dates prior to Jan 1, 1970 will not
412
  * work on Windows, some Linux distributions,
413
  * and a few other operating systems.
414
+ * PHP 5.1.0 and newer versions overcome this limitation though.
415
  */
416
  // MIN 'Jan 1, 1970' - 0 | Fri, 13 Dec 1901 20:45:54 UTC
417
  $_min_time = self::timeNegativeSupported() ? -2147483646 : 0;
418
  // MAX 'Tue, 19 Jan 2038 03:14:07 UTC' - 2147483647
419
  $_max_time = 2147483647;
420
 
421
+ return is_numeric($time) && $_min_time <= intval($time) && intval($time) <= $_max_time;
422
  }
423
 
424
  /**
425
  * DEPRECATED
426
+ *
427
+ * This is not used anymore
428
  */
429
+ public static function timeNegativeSupported()
430
+ {
431
+ return strtotime('Fri, 13 Dec 1950 20:45:54 UTC') === -601010046;
432
  }
433
 
434
  }
embedded/common/toolset-forms/classes/class.date.scripts.php CHANGED
@@ -37,13 +37,24 @@ class WPToolset_Field_Date_Scripts
37
  //for edit pages including profile pages
38
  ($pagenow == 'profile.php' || $pagenow == 'post-new.php' || $pagenow == 'user-edit.php' || $pagenow == 'user-new.php' || $pagenow == 'post.php' || $pagenow == 'admin-ajax.php') && is_admin() ) ){
39
  add_action( 'admin_enqueue_scripts', array( $this,'date_enqueue_scripts' ) );
40
- add_action( 'wp_enqueue_scripts', array( $this, 'date_enqueue_scripts' ) );
 
 
41
  }
42
  $this->localization_slug = false;
43
  }
44
 
45
  public function date_enqueue_scripts()
46
  {
 
 
 
 
 
 
 
 
 
47
  /**
48
  * styles
49
  */
@@ -119,8 +130,8 @@ class WPToolset_Field_Date_Scripts
119
  'yearMin' => intval( self::timetodate( self::$_mintimestamp, 'Y' ) ) + 1,
120
  'yearMax' => self::timetodate( self::$_maxtimestamp, 'Y' ),
121
  'ajaxurl' => admin_url('admin-ajax.php', null),
122
- 'readonly' => esc_js( __( 'This is a readonly date input', 'wpv-views' ) ),
123
- 'readonly_image' => $calendar_image_readonly
124
  );
125
  wp_localize_script( 'wptoolset-field-date', 'wptDateData', $js_data );
126
  if ( $this->localization_slug && !wp_script_is( 'jquery-ui-datepicker-local-' . $this->localization_slug ) ) {
37
  //for edit pages including profile pages
38
  ($pagenow == 'profile.php' || $pagenow == 'post-new.php' || $pagenow == 'user-edit.php' || $pagenow == 'user-new.php' || $pagenow == 'post.php' || $pagenow == 'admin-ajax.php') && is_admin() ) ){
39
  add_action( 'admin_enqueue_scripts', array( $this,'date_enqueue_scripts' ) );
40
+ if ( defined('CRED_FE_VERSION')) {
41
+ add_action( 'wp_enqueue_scripts', array( $this, 'date_enqueue_scripts' ) );
42
+ }
43
  }
44
  $this->localization_slug = false;
45
  }
46
 
47
  public function date_enqueue_scripts()
48
  {
49
+ /**
50
+ * prevent load scripts on custom field group edit screen
51
+ */
52
+ if ( is_admin() ) {
53
+ $screen = get_current_screen();
54
+ if ( 'types_page_wpcf-edit' == $screen->id ) {
55
+ return;
56
+ }
57
+ }
58
  /**
59
  * styles
60
  */
130
  'yearMin' => intval( self::timetodate( self::$_mintimestamp, 'Y' ) ) + 1,
131
  'yearMax' => self::timetodate( self::$_maxtimestamp, 'Y' ),
132
  'ajaxurl' => admin_url('admin-ajax.php', null),
133
+ 'readonly' => esc_js( __( 'This is a read-only date input', 'wpv-views' ) ),
134
+ 'readonly_image' => $calendar_image_readonly,
135
  );
136
  wp_localize_script( 'wptoolset-field-date', 'wptDateData', $js_data );
137
  if ( $this->localization_slug && !wp_script_is( 'jquery-ui-datepicker-local-' . $this->localization_slug ) ) {
embedded/common/toolset-forms/classes/class.eforms.php CHANGED
@@ -1,19 +1,20 @@
1
  <?php
 
2
  /* Copyright 2011 enlimbo lancers (email : lancers@enlimbo.net)
3
 
4
- This program is free software; you can redistribute it and/or
5
- modify it under the terms of the GNU General Public License
6
- as published by the Free Software Foundation; either version 2
7
- of the License, or (at your option) any later version.
8
 
9
- This program is distributed in the hope that it will be useful,
10
- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- GNU General Public License for more details.
13
 
14
- You should have received a copy of the GNU General Public License
15
- along with this program; if not, write to the Free Software
16
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
  */
18
 
19
  /**
@@ -27,22 +28,16 @@
27
  * @link http://enlimbo.net/forms
28
  * @author srdjan <srdjan@enlimbo.net>
29
  *
30
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.eforms.php $
31
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
32
- * $LastChangedRevision: 970205 $
33
- * $LastChangedBy: brucepearson $
34
  *
35
  */
36
-
37
- /*
38
- Element attributes
39
-
40
- General rules when adding attributes to an element using strings in chunks
41
- * always start the chunk with a space and do not end the chunk with another space
42
- * mind the closing tags and add a space when needed
43
  */
44
- class Enlimbo_Forms
45
- {
46
 
47
  /**
48
  * @var string
@@ -79,8 +74,7 @@ class Enlimbo_Forms
79
  */
80
  public $form_settings = array();
81
 
82
- public function __construct( $id )
83
- {
84
  /**
85
  * default settings
86
  */
@@ -89,21 +83,22 @@ class Enlimbo_Forms
89
  'use_bootstrap' => false,
90
  );
91
  $this->_id = $id;
92
- if ( !is_admin() ) {// TODO check also doing_ajax as this gives false positives
93
- $cred_form_id = preg_replace( '/^cred_form_(\d+)_\d+$/', "$1", $this->_id );
94
- $form_settings = get_post_meta( $cred_form_id, '_cred_form_settings', true );
95
- if ( isset($form_settings->form) ) {
 
96
  $this->form_settings = $form_settings->form;
97
  }
98
  unset($form_settings);
99
- /**
100
- * check CRED setting for bootstrap: only on frontend
101
- */
102
- $cred_cred_settings = get_option( 'cred_cred_settings' );
103
- if ( is_array($cred_cred_settings) ) {
104
- $this->form_settings['use_bootstrap'] = array_key_exists( 'use_bootstrap', $cred_cred_settings ) && $cred_cred_settings['use_bootstrap'];;
105
- }
106
- }
107
  }
108
 
109
  /**
@@ -114,8 +109,7 @@ class Enlimbo_Forms
114
  * @param array $element
115
  * @return HTML formatted output
116
  */
117
- public function autoHandle($id, $form)
118
- {
119
  // Auto-add nonce field
120
  $form['nonce'] = array(
121
  '#type' => 'hidden',
@@ -167,13 +161,11 @@ class Enlimbo_Forms
167
  * @param type $id
168
  * @return type
169
  */
170
- public function isSubmitted($id = '')
171
- {
172
  if (empty($id)) {
173
  $id = $this->_id;
174
  }
175
- return (isset($_REQUEST['_nonce'])
176
- && md5($_REQUEST['_nonce']) == $id);
177
  }
178
 
179
  /**
@@ -191,23 +183,18 @@ class Enlimbo_Forms
191
  *
192
  * @param type $elements
193
  */
194
- public function validate(&$elements)
195
- {
196
  foreach ($elements as $key => &$element) {
197
- if (!isset($element['#type'])
198
- || !$this->_isValidType($element['#type'])) {
199
  continue;
200
  }
201
  if ($element['#type'] != 'fieldset') {
202
- if (isset($element['#name'])
203
- && !in_array($element['#type'], array('submit', 'reset'))) {
204
  if ($this->isSubmitted()) {
205
  // Set submitted data
206
- if (!in_array($element['#type'], array('checkboxes'))
207
- && empty($element['#forced_value'])) {
208
  $element['#value'] = $this->getSubmittedData($element);
209
- } else if (!empty($element['#options'])
210
- && empty($element['#forced_value'])) {
211
  foreach ($element['#options'] as $option_key => $option) {
212
  $option['#type'] = 'checkbox';
213
  $element['#options'][$option_key]['#value'] = $this->getSubmittedData($option);
@@ -219,8 +206,7 @@ class Enlimbo_Forms
219
  if (isset($element['#validate'])) {
220
  $this->validateElement($element);
221
  }
222
- } else if (isset($element['#type'])
223
- && $element['#type'] == 'fieldset') {
224
  $this->validate($element);
225
  } else if (is_array($element)) {
226
  $this->validate($element);
@@ -233,15 +219,13 @@ class Enlimbo_Forms
233
  *
234
  * @param type $element
235
  */
236
- public function validateElement( &$element )
237
- {
238
- $value = isset( $element['#value'] ) ? $element['#value'] : null;
239
- if ( is_null( $value ) && isset( $element['#default_value'] ) ) {
240
  $value = $element['#default_value'];
241
  }
242
- $element = apply_filters( 'wptoolset_form_' . $this->_id . '_validate_field',
243
- $element, $value );
244
- if ( isset( $element['error'] ) ) {
245
  $this->_errors = true;
246
  $_errors = $element['error']->get_error_data();
247
  $element['#error'] = $_errors[0];
@@ -253,16 +237,14 @@ class Enlimbo_Forms
253
  *
254
  * @return type
255
  */
256
- public function isError()
257
- {
258
  return $this->_errors;
259
  }
260
 
261
  /**
262
  * Sets errors to true.
263
  */
264
- public function triggerError()
265
- {
266
  $this->_errors = true;
267
  }
268
 
@@ -271,8 +253,7 @@ class Enlimbo_Forms
271
  *
272
  * @return type
273
  */
274
- public function renderForm()
275
- {
276
  // loop over elements and render them
277
  return $this->renderElements($this->_elements);
278
  }
@@ -297,12 +278,10 @@ class Enlimbo_Forms
297
  * @param string $type
298
  * @return boolean
299
  */
300
- private function _isValidType($type)
301
- {
302
- return in_array($type,
303
- array('select', 'checkboxes', 'checkbox', 'radios',
304
- 'radio', 'textfield', 'textarea', 'file', 'submit', 'reset',
305
- 'hidden', 'fieldset', 'markup', 'button', 'password' ));
306
  }
307
 
308
  /**
@@ -311,31 +290,31 @@ class Enlimbo_Forms
311
  * @param type $elements
312
  * @return type
313
  */
314
- public function renderElements($elements)
315
- {
316
  $output = '';
317
- if (!isset($elements)) return $output;
318
- foreach ($elements as $key => $element) {
 
319
  if (!isset($element['#type']) || !$this->_isValidType($element['#type'])) {
320
  continue;
321
  }
322
  if ($element['#type'] != 'fieldset') {
323
-
324
  /**
325
- * Temporary fixing validation for checkbox/radios/skype because _cakeValidation is not working for thats
326
- * https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/186243370/comments
327
- */
328
  if (!is_admin()) {
329
- if ($element['#type']=='radios') {
330
  if (isset($element['#error'])) {
331
- if (isset($element['#options'])&&count($element['#options'])>0&&!isset($element['#options'][0]['#error']))
332
- $element['#options'][0]['#error']=$element['#error'];
333
  }
334
  }
335
  }
336
  //##################################################################################################
337
-
338
- $output .= $this->renderElement($element);
339
  } else if (isset($element['#type']) && $element['#type'] == 'fieldset') {
340
  $buffer = $this->renderElements($element);
341
  $output .= $this->fieldset($element, 'wrap', $buffer);
@@ -354,10 +333,9 @@ class Enlimbo_Forms
354
  * @param array $element
355
  * @return HTML formatted output
356
  */
357
- public function renderElement($element)
358
- {
359
  $method = $element['#type'];
360
- if (!isset($element['#name']) && !in_array( $element['#type'], array('markup', 'checkboxes'))) {
361
  if (!isset($element['#attributes']['name'])) {
362
  return '#name or #attributes[\'name\'] required!';
363
  } else {
@@ -366,46 +344,52 @@ class Enlimbo_Forms
366
  }
367
  if (is_callable(array($this, $method))) {
368
  $custom_field_title = '';
369
- if ( isset($element['#title']) && !empty($element['#title']) ){
370
- $custom_field_title = $element['#title'];
371
  }
372
 
373
- if ( empty($custom_field_title) && isset($element['#name']) && !empty($element['#name']) ){
374
- $custom_field_title = $element['#name'];
375
  }
376
  if (!isset($element['#id'])) {
377
  if (isset($element['#attributes']['id'])) {
378
  $element['#id'] = $element['#attributes']['id'];
379
  } else {
380
- $_id = isset( $this->_id ) ? $this->_id . '-' : '';
381
  $element['#id'] = "{$_id}{$element['#type']}-"
382
  . $this->_count($element['#type']) . '-' . time();
383
  }
384
  }
385
-
386
  if (isset($this->_errors[$element['#id']])) {
387
  $element['#error'] = $this->_errors[$element['#id']];
388
  }
389
  // Add JS validation
390
- if ( !empty( $element['#validate'] ) ) {
391
- if ( isset( $element['#validate']['required'] )
392
- && !empty( $element['#title'] ) ) {
393
  // Asterisk
394
  $element['#title'] .= '&#42;';
395
  }
396
- $element['#attributes']['data-wpt-validate'] = esc_js( self::json_encode( apply_filters( 'wptoolset_forms_field_js_validation_data_' . $this->_id,
397
- $element['#validate'] ) ) );
398
- $element['#attributes']['data-wpt-field-title'] = esc_js( $custom_field_title );
399
  }
400
- if ( $element['#type'] == 'radios' && !empty( $element['#options'] ) ) {
401
- foreach ( $element['#options'] as &$option ) {
402
- if ( !empty( $option['#validate'] ) ) {
403
- $option['#attributes']['data-wpt-validate'] = esc_js( self::json_encode( apply_filters( 'wptoolset_forms_field_js_validation_data_' . $this->_id,
404
- $option['#validate'] ) ) );
405
- $option['#attributes']['data-wpt-field-title'] = esc_js( $custom_field_title );
406
  }
407
  }
408
  }
 
 
 
 
 
 
 
 
 
409
  return $this->{$method}($element);
410
  }
411
  }
@@ -416,56 +400,57 @@ class Enlimbo_Forms
416
  * @param array $element
417
  * @return string
418
  */
419
- private function _setElementAttributes($element)
420
- {
421
  $attributes = '';
422
 
423
  $classes = array();
424
  $classes[] = $this->css_class . '-' . $element['#type'];
425
  $classes[] = 'form-' . $element['#type'];
426
 
427
- if ( $this->form_settings['use_bootstrap'] ) {
428
- switch( $element['#type'] ) {
429
- case 'hidden':
430
- case 'button':
431
- case 'submit':
432
- case 'radio':
433
- case 'checkbox':
434
- case 'file':
435
- break;
436
- default:
437
- $classes[] = 'form-control';
 
 
 
 
 
 
 
 
 
 
 
 
 
438
  }
439
  } else {
440
- $classes[] = $element['#type'];
 
 
441
  }
442
 
443
- if ( isset( $element['#attributes'] )
444
- && !empty( $element['#attributes'] )
445
- ) {
446
- if ( isset( $element['#attributes']['class'] ) ) {
447
- $element['#attributes']['class'] .= ' ' . implode( ' ', $classes );
448
- } else {
449
- $element['#attributes']['class'] = implode( ' ', $classes );
450
- }
451
- } else {
452
- $element['#attributes'] = array(
453
- 'class' => implode( ' ', $classes )
454
- );
455
- }
456
-
457
- foreach ($element['#attributes'] as $attribute => $value) {
458
- // Prevent undesired elements
459
- if (in_array($attribute, array('id', 'name'))) {
460
- continue;
461
- }
462
- // Don't set disabled for checkbox
463
- if ($attribute == 'disabled' && $element['#type'] == 'checkbox') {
464
- continue;
465
- }
466
- // Set return string
467
- $attributes .= ' ' . $attribute . '="' . $value . '"';
468
- }
469
 
470
  return $attributes;
471
  }
@@ -475,8 +460,7 @@ class Enlimbo_Forms
475
  *
476
  * @param array $element
477
  */
478
- private function _setRender($element)
479
- {
480
  if (!isset($element['#id'])) {
481
  if (isset($element['#attributes']['id'])) {
482
  $element['#id'] = $element['#attributes']['id'];
@@ -497,27 +481,24 @@ class Enlimbo_Forms
497
  * label
498
  */
499
  $element['_render']['label'] = '';
500
- if ( isset($element['#title']) ) {
501
  $classes = array();
502
  $classes[] = sprintf('%s-label', $this->css_class);
503
  $classes[] = sprintf('%s-%s-label', $this->css_class, $element['#type']);
504
- if ( $this->form_settings['use_bootstrap']) {
505
- switch( $element['#type'] ) {
506
- case 'checkbox':
507
- case 'radio':
508
- $classes[] = 'control-label';
509
- break;
510
  }
511
  }
512
  $element['_render']['label'] .= sprintf(
513
- '<label class="%s" for="%s">',
514
- implode(' ', $classes),
515
- $element['#id']
516
  );
517
  $element['_render']['label'] .= stripslashes($element['#title']);
518
  $element['_render']['label'] .= '</label>';
519
  }
520
-
521
  return $element;
522
  }
523
 
@@ -530,8 +511,7 @@ class Enlimbo_Forms
530
  * Accepts: <prefix><suffix><label><title><desription><error>
531
  * @param array $element
532
  */
533
- private function _pattern($pattern, $element)
534
- {
535
  $pattern = strtolower($pattern);
536
  foreach ($element['_render'] as $key => $value) {
537
  $pattern = str_replace('<' . strtolower($key) . '>', $value, $pattern);
@@ -546,28 +526,24 @@ class Enlimbo_Forms
546
  * @param string $output
547
  * @return string
548
  */
549
- private function _wrapElement($element, $output)
550
- {
551
  if (!empty($element['#inline'])) {
552
  return $output;
553
  }
554
  $classes = array();
555
  $classes[] = 'form-item';
556
  $classes[] = 'form-item-' . $element['#type'];
557
- $classes[] = $this->css_class . '-item';
558
- $classes[] = $this->css_class . '-item-' . $element['#type'];
559
- if ( $this->form_settings['use_bootstrap'] ) {
560
  $classes[] = 'form-group';
561
  }
562
- if ( preg_match( '/_hidden$/', $element['#id'] ) && !is_admin() ) {
563
  $classes[] = 'wpt-form-hide-container';
564
  }
565
- if ( is_admin() ) {
566
  return sprintf(
567
- '<div id="%s-wrapper" class="%s">%s</div>',
568
- $element['#id'],
569
- implode( ' ', $classes ),
570
- $output
571
  );
572
  }
573
  return $output;
@@ -579,8 +555,7 @@ class Enlimbo_Forms
579
  * @param string $element
580
  * @return string
581
  */
582
- private function _setElementTitle($element)
583
- {
584
  $output = '';
585
  if (isset($element['#title'])) {
586
  $output .= '<div class="title '
@@ -599,9 +574,9 @@ class Enlimbo_Forms
599
  * @param array $element
600
  * @return string
601
  */
602
- private function _setElementDescription($element)
603
- {
604
- if ( empty( $element['#description'] ) ) return '';
605
  $element['#description'] = stripslashes($element['#description']);
606
  $output = "\r\n"
607
  . '<div class="description '
@@ -620,8 +595,7 @@ class Enlimbo_Forms
620
  * @param array $element
621
  * @return string
622
  */
623
- public function renderError($element)
624
- {
625
  if (!isset($element['#error'])) {
626
  return '';
627
  }
@@ -646,8 +620,7 @@ class Enlimbo_Forms
646
  * @param string $wrap_content HTML formatted output of child elements
647
  * @return string
648
  */
649
- public function fieldset($element, $action = 'open', $wrap_content = '')
650
- {
651
  $collapsible_open = '<div class="fieldset-wrapper">';
652
  $collapsible_close = '</div>';
653
  $legend_class = '';
@@ -657,15 +630,13 @@ class Enlimbo_Forms
657
  if (!isset($element['_attributes_string'])) {
658
  $element['_attributes_string'] = $this->_setElementAttributes($element);
659
  }
660
- if ((isset($element['#collapsible']) && $element['#collapsible'])
661
- || (isset($element['#collapsed']) && $element['#collapsed'])) {
662
  $collapsible_open = '<div class="collapsible fieldset-wrapper">';
663
  $collapsible_close = '</div>';
664
  $legend_class = ' class="legend-expanded"';
665
  }
666
  if (isset($element['#collapsed']) && $element['#collapsed']) {
667
- $collapsible_open = str_replace('class="', 'class="collapsed ',
668
- $collapsible_open);
669
  $legend_class = ' class="legend-collapsed"';
670
  }
671
  $output = '';
@@ -719,19 +690,18 @@ class Enlimbo_Forms
719
  * @param array $element
720
  * @return string
721
  */
722
- public function checkbox($element)
723
- {
724
  $element['#type'] = 'checkbox';
725
  $element = $this->_setRender($element);
726
  $element['_render']['element'] = '<input type="checkbox"';
727
- foreach( array( 'id', 'name' ) as $key ) {
728
- $element['_render']['element'] .= sprintf( ' %s="%s"', $key, $element['#'.$key] );
729
  }
730
  /**
731
  * type and data_id
732
  */
733
- $element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
734
- $element['_render']['element'] .= $this->_getDataWptId( $element );
735
 
736
  $element['_render']['element'] .= ' value="';
737
  /**
@@ -739,19 +709,17 @@ class Enlimbo_Forms
739
  * but if is defined default value, use default
740
  */
741
  $value = 1;
742
- if ( array_key_exists( '#default_value', $element ) ) {
743
  $value = $element['#default_value'];
744
  }
745
- $element['_render']['element'] .= ( empty($element['#value']) && !preg_match( '/^0$/', $element['#value']) )? $value:esc_attr($element['#value']);
746
  $element['_render']['element'] .= '"' . $element['_attributes_string'];
747
  if (
748
- (
749
  !$this->isSubmitted() && (
750
- ( !empty($element['#default_value']) && $element['#default_value'] == $element['#value'] )
751
- || ( isset($element['#checked']) && $element['#checked'] )
752
  )
753
- )
754
- || ($this->isSubmitted() && !empty($element['#value']))
755
  ) {
756
  $element['_render']['element'] .= ' checked="checked"';
757
  }
@@ -760,7 +728,7 @@ class Enlimbo_Forms
760
  }
761
  $element['_render']['element'] .= ' />';
762
 
763
- $pattern = $this->_getStatndardPatern( $element, '<BEFORE><PREFIX><ELEMENT>&nbsp;<LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>');
764
  $output = $this->_pattern($pattern, $element);
765
  $output = $this->_wrapElement($element, $output);
766
  return $output . "\r\n";
@@ -775,8 +743,7 @@ class Enlimbo_Forms
775
  * @param array $element
776
  * @return string
777
  */
778
- public function checkboxes($element)
779
- {
780
  $element['#type'] = 'checkboxes';
781
  $element = $this->_setRender($element);
782
  $clone = $element;
@@ -788,7 +755,7 @@ class Enlimbo_Forms
788
  }
789
  $element['_render']['element'] .= $this->checkbox($value);
790
  }
791
- $pattern = $this->_getStatndardPatern( $element, '<BEFORE><PREFIX><TITLE><DESCRIPTION><ELEMENT><SUFFIX><AFTER>' );
792
  $output = $this->_pattern($pattern, $element);
793
  $output = $this->_wrapElement($element, $output);
794
  return $output;
@@ -800,8 +767,7 @@ class Enlimbo_Forms
800
  * @param array $element
801
  * @return string
802
  */
803
- public function radio($element)
804
- {
805
  $element['#type'] = 'radio';
806
  $element = $this->_setRender($element);
807
  $element['_render']['element'] = '<input type="radio" id="'
@@ -810,22 +776,21 @@ class Enlimbo_Forms
810
  $element['_render']['element'] .= isset($element['#value']) ? htmlspecialchars($element['#value']) : $this->_count['radio'];
811
  $element['_render']['element'] .= '"';
812
  $element['_render']['element'] .= $element['_attributes_string'];
813
- $element['_render']['element'] .= ( isset($element['#value'])
814
- && $element['#value'] === $element['#default_value']) ? ' checked="checked"' : '';
815
  if (isset($element['#disable']) && $element['#disable']) {
816
  $element['_render']['element'] .= ' disabled="disabled"';
817
  }
818
- if ( array_key_exists( '#types-value', $element ) ) {
819
- $element['_render']['element'] .= sprintf( ' data-types-value="%s"', $element['#types-value'] );
820
  }
821
  /**
822
  * type and data_id
823
  */
824
- $element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
825
- $element['_render']['element'] .= $this->_getDataWptId( $element );
826
 
827
  $element['_render']['element'] .= ' />';
828
-
829
  $pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><PREFIX><ELEMENT>&nbsp;<LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
830
  $output = $this->_pattern($pattern, $element);
831
  $output = $this->_wrapElement($element, $output);
@@ -841,8 +806,7 @@ class Enlimbo_Forms
841
  * @param array $element
842
  * @return string
843
  */
844
- public function radios($element)
845
- {
846
  if (!isset($element['#name']) || empty($element['#name'])) {
847
  return FALSE;
848
  }
@@ -866,7 +830,7 @@ class Enlimbo_Forms
866
  } else {
867
  $pattern = '<BEFORE><PREFIX><DESCRIPTION><ELEMENT><SUFFIX><AFTER>';
868
  }
869
-
870
  $pattern = $this->_getStatndardPatern($element, $pattern);
871
  $output = $this->_pattern($pattern, $element);
872
  $output = $this->_wrapElement($element, $output);
@@ -879,24 +843,23 @@ class Enlimbo_Forms
879
  * @param array $element
880
  * @return string
881
  */
882
- public function select($element)
883
- {
884
  $element = $this->_setRender($element);
885
 
886
  $element['_render']['element'] = '';
887
  $element['_render']['element'] .= '<select id="' . $element['#id'] . '" ';
888
  $element['_render']['element'] .= $element['_attributes_string'];
889
- $element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
890
  /**
891
  * multiple
892
  */
893
- if ( array_key_exists( '#multiple', $element ) && $element['#multiple'] ) {
894
  $element['_render']['element'] .= ' multiple="multiple"';
895
  $element['_render']['element'] .= ' name="' . $element['#name'] . '[]"';
896
  } else {
897
  $element['_render']['element'] .= ' name="' . $element['#name'] . '"';
898
  }
899
- $element['_render']['element'] .= ">\r\n";
900
  $count = 1;
901
  foreach ($element['#options'] as $id => $value) {
902
  if (!is_array($value)) {
@@ -909,22 +872,22 @@ class Enlimbo_Forms
909
  }
910
  $element['_render']['element'] .= '<option value="' . htmlspecialchars($value['#value']) . '"';
911
  $element['_render']['element'] .= $this->_setElementAttributes($value);
912
- if ( array_key_exists( '#types-value', $value ) ) {
913
- $element['_render']['element'] .= sprintf( ' data-types-value="%s"', $value['#types-value'] );
914
  }
915
  /**
916
  * type and data_id
917
  */
918
  $element['_render']['element'] .= ' data-wpt-type="option"';
919
- $element['_render']['element'] .= $this->_getDataWptId( $element );
920
  /**
921
  * selected
922
  */
923
- if ( array_key_exists( '#multiple', $element ) && $element['#multiple'] ) {
924
- if ( is_array( $element['#default_value'] ) && in_array( $value['#value'], $element['#default_value'] ) ) {
925
  $element['_render']['element'] .= ' selected="selected"';
926
  }
927
- } elseif ( $element['#default_value'] == $value['#value']) {
928
  $element['_render']['element'] .= ' selected="selected"';
929
  }
930
  $element['_render']['element'] .= '>';
@@ -934,7 +897,7 @@ class Enlimbo_Forms
934
  $element['_render']['element'] .= '</select>';
935
  $element['_render']['element'] .= PHP_EOL;
936
 
937
- $pattern = $this->_getStatndardPatern( $element );
938
  $output = $this->_pattern($pattern, $element);
939
  $output = $this->_wrapElement($element, $output);
940
 
@@ -947,16 +910,15 @@ class Enlimbo_Forms
947
  * @param array $element
948
  * @return string
949
  */
950
- public function textfield($element)
951
- {
952
  $element['#type'] = 'textfield';
953
  $element = $this->_setRender($element);
954
 
955
  $element['_render']['element'] = '<input type="text"';
956
  //$element['_render']['element'] .= sprintf( ' data-wpt-type="%s" ', __FUNCTION__ );
957
- $element['_render']['element'] .= sprintf( ' id="%s"', $element['#id']);
958
- $element['_render']['element'] .= sprintf( ' name="%s"', $element['#name']);
959
- $element['_render']['element'] .= sprintf( ' value="%s"', isset($element['#value']) ? esc_attr($element['#value']) : '' );
960
  $element['_render']['element'] .= $element['_attributes_string'];
961
  if (isset($element['#disable']) && $element['#disable']) {
962
  $element['_render']['element'] .= ' disabled="disabled"';
@@ -964,11 +926,11 @@ class Enlimbo_Forms
964
  /**
965
  * type and data_id
966
  */
967
- $element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
968
- $element['_render']['element'] .= $this->_getDataWptId( $element );
969
 
970
  $element['_render']['element'] .= ' />';
971
- $pattern = $this->_getStatndardPatern( $element );
972
  $output = $this->_pattern($pattern, $element);
973
  $output = $this->_wrapElement($element, $output);
974
  return $output . "\r\n";
@@ -980,8 +942,7 @@ class Enlimbo_Forms
980
  * @param array $element
981
  * @return string
982
  */
983
- public function password($element)
984
- {
985
  $element['#type'] = 'password';
986
  $element = $this->_setRender($element);
987
  $element['_render']['element'] = '<input type="password" id="'
@@ -994,8 +955,8 @@ class Enlimbo_Forms
994
  /**
995
  * type and data_id
996
  */
997
- $element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
998
- $element['_render']['element'] .= $this->_getDataWptId( $element );
999
 
1000
  $element['_render']['element'] .= ' />';
1001
  $pattern = $this->_getStatndardPatern($element);
@@ -1010,8 +971,7 @@ class Enlimbo_Forms
1010
  * @param array $element
1011
  * @return string
1012
  */
1013
- public function textarea($element)
1014
- {
1015
  $element['#type'] = 'textarea';
1016
  if (!isset($element['#attributes']['rows'])) {
1017
  $element['#attributes']['rows'] = 5;
@@ -1026,14 +986,14 @@ class Enlimbo_Forms
1026
  /**
1027
  * type and data_id
1028
  */
1029
- $element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
1030
- $element['_render']['element'] .= $this->_getDataWptId( $element );
1031
 
1032
  $element['_render']['element'] .= '>';
1033
 
1034
  $element['_render']['element'] .= isset($element['#value']) ? esc_attr($element['#value']) : '';
1035
  $element['_render']['element'] .= '</textarea>' . "\r\n";
1036
- $pattern = $this->_getStatndardPatern( $element );
1037
  $output = $this->_pattern($pattern, $element);
1038
  $output = $this->_wrapElement($element, $output);
1039
  return $output . "\r\n";
@@ -1045,8 +1005,7 @@ class Enlimbo_Forms
1045
  * @param array $element
1046
  * @return string
1047
  */
1048
- public function file($element)
1049
- {
1050
  $element['#type'] = 'file';
1051
  $element = $this->_setRender($element);
1052
  $element['_render']['element'] = '<input type="file" id="'
@@ -1058,11 +1017,11 @@ class Enlimbo_Forms
1058
  /**
1059
  * type and data_id
1060
  */
1061
- $element['_render']['element'] .= sprintf( ' data-wpt-type="%s"', __FUNCTION__ );
1062
- $element['_render']['element'] .= $this->_getDataWptId( $element );
1063
 
1064
  $element['_render']['element'] .= ' />';
1065
- $pattern = $this->_getStatndardPatern( $element );
1066
  $output = $this->_pattern($pattern, $element);
1067
  $output = $this->_wrapElement($element, $output);
1068
  return $output;
@@ -1074,8 +1033,7 @@ class Enlimbo_Forms
1074
  * @param array $element
1075
  * @return string
1076
  */
1077
- public function markup($element)
1078
- {
1079
  return $element['#markup'];
1080
  }
1081
 
@@ -1085,14 +1043,13 @@ class Enlimbo_Forms
1085
  * @param array $element
1086
  * @return string
1087
  */
1088
- public function hidden($element)
1089
- {
1090
  $element['#type'] = 'hidden';
1091
  $element = $this->_setRender($element);
1092
  $output = '<input type="hidden" id="' . $element['#id'] . '" name="'
1093
  . $element['#name'] . '" value="';
1094
  $output .= isset($element['#value']) ? $element['#value'] : 1;
1095
- $output .= '"' . $element['_attributes_string'] . $this->_getDataWptId( $element ) . ' />';
1096
  return $output;
1097
  }
1098
 
@@ -1102,8 +1059,7 @@ class Enlimbo_Forms
1102
  * @param array $element
1103
  * @return string
1104
  */
1105
- public function reset($element)
1106
- {
1107
  return $this->submit($element, 'reset', 'Reset');
1108
  }
1109
 
@@ -1113,8 +1069,7 @@ class Enlimbo_Forms
1113
  * @param array $element
1114
  * @return string
1115
  */
1116
- public function button($element)
1117
- {
1118
  return $this->submit($element, 'button', 'Button');
1119
  }
1120
 
@@ -1128,8 +1083,7 @@ class Enlimbo_Forms
1128
  * @param string $title
1129
  * @return string
1130
  */
1131
- public function submit($element, $type = 'submit', $title = 'Submit')
1132
- {
1133
  $element['#type'] = $type;
1134
  $element = $this->_setRender($element);
1135
  $element['_render']['element'] = '<input type="' . $type . '" id="'
@@ -1137,7 +1091,7 @@ class Enlimbo_Forms
1137
  $element['_render']['element'] .= isset($element['#value']) ? $element['#value'] : $title;
1138
  $element['_render']['element'] .= '"' . $element['_attributes_string']
1139
  . ' />';
1140
- $pattern = $this->_getStatndardPatern( $element, '<BEFORE><PREFIX><ELEMENT><SUFFIX><AFTER>' );
1141
  $output = $this->_pattern($pattern, $element);
1142
  return $output;
1143
  }
@@ -1148,20 +1102,20 @@ class Enlimbo_Forms
1148
  * @param type $element
1149
  * @return type mixed
1150
  */
1151
- public function getSubmittedData($element)
1152
- {
1153
  $name = $element['#name'];
1154
  if (strpos($name, '[') === false) {
1155
  if ($element['#type'] == 'file') {
1156
  return $_FILES[$name]['tmp_name'];
1157
  }
1158
- return isset($_REQUEST[$name]) ? $_REQUEST[$name] : in_array($element['#type'],
1159
- array('textfield', 'textarea')) ? '' : 0;
1160
  }
1161
 
1162
  $parts = explode('[', $name);
1163
- $parts = array_map(create_function('&$a', 'return trim($a, \']\');'),
1164
- $parts);
 
 
1165
  if (!isset($_REQUEST[$parts[0]])) {
1166
  return in_array($element['#type'], array('textfield', 'textarea')) ? '' : 0;
1167
  }
@@ -1170,14 +1124,12 @@ class Enlimbo_Forms
1170
  $key = $parts[$index];
1171
  // We're at the end but no data retrieved
1172
  if (!isset($parts[$index + 1])) {
1173
- return in_array($element['#type'],
1174
- array('textfield', 'textarea')) ? '' : 0;
1175
  }
1176
  $key_next = $parts[$index + 1];
1177
  if ($index > 0) {
1178
  if (!isset($search[$key])) {
1179
- return in_array($element['#type'],
1180
- array('textfield', 'textarea')) ? '' : 0;
1181
  } else {
1182
  $search = $search[$key];
1183
  }
@@ -1191,25 +1143,23 @@ class Enlimbo_Forms
1191
  return 0;
1192
  }
1193
 
1194
- private function _getDataWptId($element)
1195
- {
1196
  $html = '';
1197
- if ( array_key_exists( '#id', $element ) ) {
1198
- if ( is_admin() ) {
1199
- $html .= sprintf( ' data-wpt-id="%s"', preg_replace( '/\[/', '-', preg_replace( '/\]/', '', $element['#name'] ) ) );
1200
  } else {
1201
- $html .= sprintf( ' data-wpt-id="%s_%s"', $this->_id, $element['#id'] );
1202
  }
1203
- if ( array_key_exists( '#name', $element ) && $element['#name'] ) {
1204
- if ( !is_admin() && $this->_isRepetitive($element)) {
1205
- $html .= sprintf( ' data-wpt-name="%s"', preg_replace( '/\[.+$/', '', $element['#name'] ) );
1206
  } else {
1207
- if ( preg_match( '/^wpcf_post_relationship\[\d+\]\[\d+\]\[[^\]]+\]/', $element['#name'] ) ) {
1208
  $html .= sprintf(
1209
- ' data-wpt-name="%s"',
1210
- preg_replace( '/^wpcf_post_relationship\[\d+\]\[(\d+)\]\[wpcf-([^\]]+)\]/', "wpcf[$2-$1]", $element['#name'] ) );
1211
  } else {
1212
- $html .= sprintf( ' data-wpt-name="%s"', $element['#name'] );
1213
  }
1214
  }
1215
  }
@@ -1217,63 +1167,60 @@ class Enlimbo_Forms
1217
  return $html;
1218
  }
1219
 
1220
- private function _getStatndardPatern($element, $default = false )
1221
- {
1222
- if ( isset($element['#pattern'] ) ) {
1223
  return $element['#pattern'];
1224
  }
1225
- if ( $default ) {
1226
  return $default;
1227
  }
1228
- if ( is_admin() ) {
1229
  return '<BEFORE><LABEL><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>';
1230
  }
1231
  return '<BEFORE><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>';
1232
  }
1233
 
1234
- private function _isRepetitive($element)
1235
- {
1236
- if ( !is_array($element) ) {
1237
  return false;
1238
  }
1239
- return array_key_exists( '#repetitive', $element ) && $element['#repetitive'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1240
  }
1241
-
1242
- static function json_encode( $array )
1243
- {
1244
- // php > 5.3 do not escape utf-8 characters using native constant argument
1245
- if( defined('JSON_UNESCAPED_UNICODE') )
1246
- {
1247
- return json_encode($array, JSON_UNESCAPED_UNICODE );
1248
- }
1249
- // fallback for php < 5.3 to support unicode characters in json string
1250
- else
1251
- {
1252
- if (function_exists('mb_decode_numericentity')) {
1253
- return self::json_encode_unescaped_unicode( $array );
1254
- } else {
1255
- return json_encode( $array );
1256
- }
1257
- }
1258
- }
1259
-
1260
- /**
1261
- * @param $arr
1262
- * @return string
1263
- * courtesy from: http://www.php.net/manual/ru/function.json-encode.php#105789
1264
- */
1265
- public static function json_encode_unescaped_unicode($arr)
1266
- {
1267
-
1268
- array_walk_recursive($arr, array(__CLASS__, 'json_unescaped_unicode_walk_callback' ));
1269
-
1270
- return mb_decode_numericentity(json_encode($arr), array (0x80, 0xffff, 0, 0xffff), 'UTF-8');
1271
- }
1272
 
1273
  /*
1274
  * Helper function to json_encode with UTF-8 support for php < 5.3
1275
  */
1276
- public static function json_unescaped_unicode_walk_callback (&$item, $key){
1277
- if (is_string($item)) $item = mb_encode_numericentity($item, array (0x80, 0xffff, 0, 0xffff), 'UTF-8');
1278
- }
 
 
 
1279
  }
1
  <?php
2
+
3
  /* Copyright 2011 enlimbo lancers (email : lancers@enlimbo.net)
4
 
5
+ This program is free software; you can redistribute it and/or
6
+ modify it under the terms of the GNU General Public License
7
+ as published by the Free Software Foundation; either version 2
8
+ of the License, or (at your option) any later version.
9
 
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
 
15
+ You should have received a copy of the GNU General Public License
16
+ along with this program; if not, write to the Free Software
17
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
  */
19
 
20
  /**
28
  * @link http://enlimbo.net/forms
29
  * @author srdjan <srdjan@enlimbo.net>
30
  *
 
 
 
 
31
  *
32
  */
33
+ /*
34
+ Element attributes
35
+
36
+ General rules when adding attributes to an element using strings in chunks
37
+ * always start the chunk with a space and do not end the chunk with another space
38
+ * mind the closing tags and add a space when needed
 
39
  */
40
+ class Enlimbo_Forms {
 
41
 
42
  /**
43
  * @var string
74
  */
75
  public $form_settings = array();
76
 
77
+ public function __construct($id) {
 
78
  /**
79
  * default settings
80
  */
83
  'use_bootstrap' => false,
84
  );
85
  $this->_id = $id;
86
+ if (!is_admin()|| (defined( 'DOING_AJAX' ) && DOING_AJAX)) {
87
+ // TODO check also doing_ajax as this gives false positives
88
+ $cred_form_id = preg_replace('/^cred_form_(\d+)_\d+$/', "$1", $this->_id);
89
+ $form_settings = get_post_meta($cred_form_id, '_cred_form_settings', true);
90
+ if (isset($form_settings->form)) {
91
  $this->form_settings = $form_settings->form;
92
  }
93
  unset($form_settings);
94
+ /**
95
+ * check CRED setting for bootstrap: only on frontend
96
+ */
97
+ $cred_cred_settings = get_option('cred_cred_settings');
98
+ if (is_array($cred_cred_settings)) {
99
+ $this->form_settings['use_bootstrap'] = array_key_exists('use_bootstrap', $cred_cred_settings) && $cred_cred_settings['use_bootstrap'];
100
+ }
101
+ }
102
  }
103
 
104
  /**
109
  * @param array $element
110
  * @return HTML formatted output
111
  */
112
+ public function autoHandle($id, $form) {
 
113
  // Auto-add nonce field
114
  $form['nonce'] = array(
115
  '#type' => 'hidden',
161
  * @param type $id
162
  * @return type
163
  */
164
+ public function isSubmitted($id = '') {
 
165
  if (empty($id)) {
166
  $id = $this->_id;
167
  }
168
+ return (isset($_REQUEST['_nonce']) && md5($_REQUEST['_nonce']) == $id);
 
169
  }
170
 
171
  /**
183
  *
184
  * @param type $elements
185
  */
186
+ public function validate(&$elements) {
 
187
  foreach ($elements as $key => &$element) {
188
+ if (!isset($element['#type']) || !$this->_isValidType($element['#type'])) {
 
189
  continue;
190
  }
191
  if ($element['#type'] != 'fieldset') {
192
+ if (isset($element['#name']) && !in_array($element['#type'], array('submit', 'reset'))) {
 
193
  if ($this->isSubmitted()) {
194
  // Set submitted data
195
+ if (!in_array($element['#type'], array('checkboxes')) && empty($element['#forced_value'])) {
 
196
  $element['#value'] = $this->getSubmittedData($element);
197
+ } else if (!empty($element['#options']) && empty($element['#forced_value'])) {
 
198
  foreach ($element['#options'] as $option_key => $option) {
199
  $option['#type'] = 'checkbox';
200
  $element['#options'][$option_key]['#value'] = $this->getSubmittedData($option);
206
  if (isset($element['#validate'])) {
207
  $this->validateElement($element);
208
  }
209
+ } else if (isset($element['#type']) && $element['#type'] == 'fieldset') {
 
210
  $this->validate($element);
211
  } else if (is_array($element)) {
212
  $this->validate($element);
219
  *
220
  * @param type $element
221
  */
222
+ public function validateElement(&$element) {
223
+ $value = isset($element['#value']) ? $element['#value'] : null;
224
+ if (is_null($value) && isset($element['#default_value'])) {
 
225
  $value = $element['#default_value'];
226
  }
227
+ $element = apply_filters('wptoolset_form_' . $this->_id . '_validate_field', $element, $value);
228
+ if (isset($element['error'])) {
 
229
  $this->_errors = true;
230
  $_errors = $element['error']->get_error_data();
231
  $element['#error'] = $_errors[0];
237
  *
238
  * @return type
239
  */
240
+ public function isError() {
 
241
  return $this->_errors;
242
  }
243
 
244
  /**
245
  * Sets errors to true.
246
  */
247
+ public function triggerError() {
 
248
  $this->_errors = true;
249
  }
250
 
253
  *
254
  * @return type
255
  */
256
+ public function renderForm() {
 
257
  // loop over elements and render them
258
  return $this->renderElements($this->_elements);
259
  }
278
  * @param string $type
279
  * @return boolean
280
  */
281
+ private function _isValidType($type) {
282
+ return in_array($type, array('select', 'checkboxes', 'checkbox', 'radios',
283
+ 'radio', 'textfield', 'textarea', 'file', 'submit', 'reset',
284
+ 'hidden', 'fieldset', 'markup', 'button', 'password'));
 
 
285
  }
286
 
287
  /**
290
  * @param type $elements
291
  * @return type
292
  */
293
+ public function renderElements($elements) {
 
294
  $output = '';
295
+ if (!isset($elements))
296
+ return $output;
297
+ foreach ($elements as $key => $element) {
298
  if (!isset($element['#type']) || !$this->_isValidType($element['#type'])) {
299
  continue;
300
  }
301
  if ($element['#type'] != 'fieldset') {
302
+
303
  /**
304
+ * Temporary fixing validation for checkbox/radios/skype because _cakeValidation is not working for thats
305
+ * https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/186243370/comments
306
+ */
307
  if (!is_admin()) {
308
+ if ($element['#type'] == 'radios') {
309
  if (isset($element['#error'])) {
310
+ if (isset($element['#options']) && count($element['#options']) > 0 && !isset($element['#options'][0]['#error']))
311
+ $element['#options'][0]['#error'] = $element['#error'];
312
  }
313
  }
314
  }
315
  //##################################################################################################
316
+
317
+ $output .= $this->renderElement($element);
318
  } else if (isset($element['#type']) && $element['#type'] == 'fieldset') {
319
  $buffer = $this->renderElements($element);
320
  $output .= $this->fieldset($element, 'wrap', $buffer);
333
  * @param array $element
334
  * @return HTML formatted output
335
  */
336
+ public function renderElement($element) {
 
337
  $method = $element['#type'];
338
+ if (!isset($element['#name']) && !in_array($element['#type'], array('markup', 'checkboxes'))) {
339
  if (!isset($element['#attributes']['name'])) {
340
  return '#name or #attributes[\'name\'] required!';
341
  } else {
344
  }
345
  if (is_callable(array($this, $method))) {
346
  $custom_field_title = '';
347
+ if (isset($element['#title']) && !empty($element['#title'])) {
348
+ $custom_field_title = $element['#title'];
349
  }
350
 
351
+ if (empty($custom_field_title) && isset($element['#name']) && !empty($element['#name'])) {
352
+ $custom_field_title = $element['#name'];
353
  }
354
  if (!isset($element['#id'])) {
355
  if (isset($element['#attributes']['id'])) {
356
  $element['#id'] = $element['#attributes']['id'];
357
  } else {
358
+ $_id = isset($this->_id) ? $this->_id . '-' : '';
359
  $element['#id'] = "{$_id}{$element['#type']}-"
360
  . $this->_count($element['#type']) . '-' . time();
361
  }
362
  }
363
+
364
  if (isset($this->_errors[$element['#id']])) {
365
  $element['#error'] = $this->_errors[$element['#id']];
366
  }
367
  // Add JS validation
368
+ if (!empty($element['#validate'])) {
369
+ if (isset($element['#validate']['required']) && !empty($element['#title'])) {
 
370
  // Asterisk
371
  $element['#title'] .= '&#42;';
372
  }
373
+ $element['#attributes']['data-wpt-validate'] = esc_html(self::json_encode(apply_filters('wptoolset_forms_field_js_validation_data_' . $this->_id, $element['#validate'])));
374
+ $element['#attributes']['data-wpt-field-title'] = esc_js($custom_field_title);
 
375
  }
376
+ if ($element['#type'] == 'radios' && !empty($element['#options'])) {
377
+ foreach ($element['#options'] as &$option) {
378
+ if (!empty($option['#validate'])) {
379
+ $option['#attributes']['data-wpt-validate'] = esc_html(self::json_encode(apply_filters('wptoolset_forms_field_js_validation_data_' . $this->_id, $option['#validate'])));
380
+ $option['#attributes']['data-wpt-field-title'] = esc_js($custom_field_title);
 
381
  }
382
  }
383
  }
384
+ /**
385
+ * WPML - lock CF is has option "copy from original".
386
+ */
387
+ if (is_admin() && function_exists('wpcf_wpml_field_is_copied') && wpcf_wpml_field_is_copied($element)) {
388
+ $element['#title'] .= sprintf(
389
+ '<img src="%s/images/locked.png" alt="%s" title="%s" style="position:relative;left:2px;top:2px;" />', WPCF_EMBEDDED_RES_RELPATH, __('This field is locked for editing because WPML will copy its value from the original language.', 'wpcf'), __('This field is locked for editing because WPML will copy its value from the original language.', 'wpcf')
390
+ );
391
+ $element['#attributes']['readonly'] = true;
392
+ }
393
  return $this->{$method}($element);
394
  }
395
  }
400
  * @param array $element
401
  * @return string
402
  */
403
+ private function _setElementAttributes($element) {
 
404
  $attributes = '';
405
 
406
  $classes = array();
407
  $classes[] = $this->css_class . '-' . $element['#type'];
408
  $classes[] = 'form-' . $element['#type'];
409
 
410
+ if ($this->form_settings['use_bootstrap']) {
411
+ switch ($element['#type']) {
412
+ case 'hidden':
413
+ case 'button':
414
+ case 'submit':
415
+ case 'radio':
416
+ case 'checkbox':
417
+ case 'file':
418
+ break;
419
+ default:
420
+ $classes[] = 'form-control';
421
+ }
422
+ } else {
423
+ if ('hidden' != $element['#type']) {
424
+ $classes[] = $element['#type'];
425
+ }
426
+ }
427
+
428
+ if (isset($element['#attributes']) && !empty($element['#attributes'])
429
+ ) {
430
+ if (isset($element['#attributes']['class'])) {
431
+ $element['#attributes']['class'] .= ' ' . implode(' ', $classes);
432
+ } else {
433
+ $element['#attributes']['class'] = implode(' ', $classes);
434
  }
435
  } else {
436
+ $element['#attributes'] = array(
437
+ 'class' => implode(' ', $classes)
438
+ );
439
  }
440
 
441
+
442
+ foreach ($element['#attributes'] as $attribute => $value) {
443
+ // Prevent undesired elements
444
+ if (in_array($attribute, array('id', 'name'))) {
445
+ continue;
446
+ }
447
+ // Don't set disabled for checkbox
448
+ if ($attribute == 'disabled' && $element['#type'] == 'checkbox') {
449
+ continue;
450
+ }
451
+ // Set return string
452
+ $attributes .= ' ' . $attribute . '="' . $value . '"';
453
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
454
 
455
  return $attributes;
456
  }
460
  *
461
  * @param array $element
462
  */
463
+ private function _setRender($element) {
 
464
  if (!isset($element['#id'])) {
465
  if (isset($element['#attributes']['id'])) {
466
  $element['#id'] = $element['#attributes']['id'];
481
  * label
482
  */
483
  $element['_render']['label'] = '';
484
+ if (isset($element['#title'])) {
485
  $classes = array();
486
  $classes[] = sprintf('%s-label', $this->css_class);
487
  $classes[] = sprintf('%s-%s-label', $this->css_class, $element['#type']);
488
+ if ($this->form_settings['use_bootstrap']) {
489
+ switch ($element['#type']) {
490
+ case 'checkbox':
491
+ case 'radio':
492
+ $classes[] = 'control-label';
493
+ break;
494
  }
495
  }
496
  $element['_render']['label'] .= sprintf(
497
+ '<label class="%s" for="%s">', implode(' ', $classes), $element['#id']
 
 
498
  );
499
  $element['_render']['label'] .= stripslashes($element['#title']);
500
  $element['_render']['label'] .= '</label>';
501
  }
 
502
  return $element;
503
  }
504
 
511
  * Accepts: <prefix><suffix><label><title><desription><error>
512
  * @param array $element
513
  */
514
+ private function _pattern($pattern, $element) {
 
515
  $pattern = strtolower($pattern);
516
  foreach ($element['_render'] as $key => $value) {
517
  $pattern = str_replace('<' . strtolower($key) . '>', $value, $pattern);
526
  * @param string $output
527
  * @return string
528
  */
529
+ private function _wrapElement($element, $output) {
 
530
  if (!empty($element['#inline'])) {
531
  return $output;
532
  }
533
  $classes = array();
534
  $classes[] = 'form-item';
535
  $classes[] = 'form-item-' . $element['#type'];
536
+ $classes[] = $this->css_class . '-item';
537
+ $classes[] = $this->css_class . '-item-' . $element['#type'];
538
+ if ($this->form_settings['use_bootstrap']) {
539
  $classes[] = 'form-group';
540
  }
541
+ if (preg_match('/_hidden$/', $element['#id']) && !is_admin()) {
542
  $classes[] = 'wpt-form-hide-container';
543
  }
544
+ if (is_admin()) {
545
  return sprintf(
546
+ '<div id="%s-wrapper" class="%s">%s</div>', $element['#id'], implode(' ', $classes), $output
 
 
 
547
  );
548
  }
549
  return $output;
555
  * @param string $element
556
  * @return string
557
  */
558
+ private function _setElementTitle($element) {
 
559
  $output = '';
560
  if (isset($element['#title'])) {
561
  $output .= '<div class="title '
574
  * @param array $element
575
  * @return string
576
  */
577
+ private function _setElementDescription($element) {
578
+ if (empty($element['#description']))
579
+ return '';
580
  $element['#description'] = stripslashes($element['#description']);
581
  $output = "\r\n"
582
  . '<div class="description '
595
  * @param array $element
596
  * @return string
597
  */
598
+ public function renderError($element) {
 
599
  if (!isset($element['#error'])) {
600
  return '';
601
  }
620
  * @param string $wrap_content HTML formatted output of child elements
621
  * @return string
622
  */
623
+ public function fieldset($element, $action = 'open', $wrap_content = '') {
 
624
  $collapsible_open = '<div class="fieldset-wrapper">';
625
  $collapsible_close = '</div>';
626
  $legend_class = '';
630
  if (!isset($element['_attributes_string'])) {
631
  $element['_attributes_string'] = $this->_setElementAttributes($element);
632
  }
633
+ if ((isset($element['#collapsible']) && $element['#collapsible']) || (isset($element['#collapsed']) && $element['#collapsed'])) {
 
634
  $collapsible_open = '<div class="collapsible fieldset-wrapper">';
635
  $collapsible_close = '</div>';
636
  $legend_class = ' class="legend-expanded"';
637
  }
638
  if (isset($element['#collapsed']) && $element['#collapsed']) {
639
+ $collapsible_open = str_replace('class="', 'class="collapsed ', $collapsible_open);
 
640
  $legend_class = ' class="legend-collapsed"';
641
  }
642
  $output = '';
690
  * @param array $element
691
  * @return string
692
  */
693
+ public function checkbox($element) {
 
694
  $element['#type'] = 'checkbox';
695
  $element = $this->_setRender($element);
696
  $element['_render']['element'] = '<input type="checkbox"';
697
+ foreach (array('id', 'name') as $key) {
698
+ $element['_render']['element'] .= sprintf(' %s="%s"', $key, $element['#' . $key]);
699
  }
700
  /**
701
  * type and data_id
702
  */
703
+ $element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
704
+ $element['_render']['element'] .= $this->_getDataWptId($element);
705
 
706
  $element['_render']['element'] .= ' value="';
707
  /**
709
  * but if is defined default value, use default
710
  */
711
  $value = 1;
712
+ if (array_key_exists('#default_value', $element)) {
713
  $value = $element['#default_value'];
714
  }
715
+ $element['_render']['element'] .= ( empty($element['#value']) && !preg_match('/^0$/', $element['#value']) ) ? $value : esc_attr($element['#value']);
716
  $element['_render']['element'] .= '"' . $element['_attributes_string'];
717
  if (
718
+ (
719
  !$this->isSubmitted() && (
720
+ (!empty($element['#default_value']) && $element['#default_value'] == $element['#value'] ) || ( isset($element['#checked']) && $element['#checked'] )
 
721
  )
722
+ ) || ($this->isSubmitted() && !empty($element['#value']))
 
723
  ) {
724
  $element['_render']['element'] .= ' checked="checked"';
725
  }
728
  }
729
  $element['_render']['element'] .= ' />';
730
 
731
+ $pattern = $this->_getStatndardPatern($element, '<BEFORE><PREFIX><ELEMENT>&nbsp;<LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>');
732
  $output = $this->_pattern($pattern, $element);
733
  $output = $this->_wrapElement($element, $output);
734
  return $output . "\r\n";
743
  * @param array $element
744
  * @return string
745
  */
746
+ public function checkboxes($element) {
 
747
  $element['#type'] = 'checkboxes';
748
  $element = $this->_setRender($element);
749
  $clone = $element;
755
  }
756
  $element['_render']['element'] .= $this->checkbox($value);
757
  }
758
+ $pattern = $this->_getStatndardPatern($element, '<BEFORE><PREFIX><TITLE><DESCRIPTION><ELEMENT><SUFFIX><AFTER>');
759
  $output = $this->_pattern($pattern, $element);
760
  $output = $this->_wrapElement($element, $output);
761
  return $output;
767
  * @param array $element
768
  * @return string
769
  */
770
+ public function radio($element) {
 
771
  $element['#type'] = 'radio';
772
  $element = $this->_setRender($element);
773
  $element['_render']['element'] = '<input type="radio" id="'
776
  $element['_render']['element'] .= isset($element['#value']) ? htmlspecialchars($element['#value']) : $this->_count['radio'];
777
  $element['_render']['element'] .= '"';
778
  $element['_render']['element'] .= $element['_attributes_string'];
779
+ $element['_render']['element'] .= ( isset($element['#value']) && $element['#value'] === $element['#default_value']) ? ' checked="checked"' : '';
 
780
  if (isset($element['#disable']) && $element['#disable']) {
781
  $element['_render']['element'] .= ' disabled="disabled"';
782
  }
783
+ if (array_key_exists('#types-value', $element)) {
784
+ $element['_render']['element'] .= sprintf(' data-types-value="%s"', $element['#types-value']);
785
  }
786
  /**
787
  * type and data_id
788
  */
789
+ $element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
790
+ $element['_render']['element'] .= $this->_getDataWptId($element);
791
 
792
  $element['_render']['element'] .= ' />';
793
+
794
  $pattern = isset($element['#pattern']) ? $element['#pattern'] : '<BEFORE><PREFIX><ELEMENT>&nbsp;<LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
795
  $output = $this->_pattern($pattern, $element);
796
  $output = $this->_wrapElement($element, $output);
806
  * @param array $element
807
  * @return string
808
  */
809
+ public function radios($element) {
 
810
  if (!isset($element['#name']) || empty($element['#name'])) {
811
  return FALSE;
812
  }
830
  } else {
831
  $pattern = '<BEFORE><PREFIX><DESCRIPTION><ELEMENT><SUFFIX><AFTER>';
832
  }
833
+
834
  $pattern = $this->_getStatndardPatern($element, $pattern);
835
  $output = $this->_pattern($pattern, $element);
836
  $output = $this->_wrapElement($element, $output);
843
  * @param array $element
844
  * @return string
845
  */
846
+ public function select($element) {
 
847
  $element = $this->_setRender($element);
848
 
849
  $element['_render']['element'] = '';
850
  $element['_render']['element'] .= '<select id="' . $element['#id'] . '" ';
851
  $element['_render']['element'] .= $element['_attributes_string'];
852
+ $element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
853
  /**
854
  * multiple
855
  */
856
+ if (array_key_exists('#multiple', $element) && $element['#multiple']) {
857
  $element['_render']['element'] .= ' multiple="multiple"';
858
  $element['_render']['element'] .= ' name="' . $element['#name'] . '[]"';
859
  } else {
860
  $element['_render']['element'] .= ' name="' . $element['#name'] . '"';
861
  }
862
+ $element['_render']['element'] .= ">\r\n";
863
  $count = 1;
864
  foreach ($element['#options'] as $id => $value) {
865
  if (!is_array($value)) {
872
  }
873
  $element['_render']['element'] .= '<option value="' . htmlspecialchars($value['#value']) . '"';
874
  $element['_render']['element'] .= $this->_setElementAttributes($value);
875
+ if (array_key_exists('#types-value', $value)) {
876
+ $element['_render']['element'] .= sprintf(' data-types-value="%s"', $value['#types-value']);
877
  }
878
  /**
879
  * type and data_id
880
  */
881
  $element['_render']['element'] .= ' data-wpt-type="option"';
882
+ $element['_render']['element'] .= $this->_getDataWptId($element);
883
  /**
884
  * selected
885
  */
886
+ if (array_key_exists('#multiple', $element) && $element['#multiple']) {
887
+ if (is_array($element['#default_value']) && in_array($value['#value'], $element['#default_value'])) {
888
  $element['_render']['element'] .= ' selected="selected"';
889
  }
890
+ } elseif ($element['#default_value'] == $value['#value']) {
891
  $element['_render']['element'] .= ' selected="selected"';
892
  }
893
  $element['_render']['element'] .= '>';
897
  $element['_render']['element'] .= '</select>';
898
  $element['_render']['element'] .= PHP_EOL;
899
 
900
+ $pattern = $this->_getStatndardPatern($element);
901
  $output = $this->_pattern($pattern, $element);
902
  $output = $this->_wrapElement($element, $output);
903
 
910
  * @param array $element
911
  * @return string
912
  */
913
+ public function textfield($element) {
 
914
  $element['#type'] = 'textfield';
915
  $element = $this->_setRender($element);
916
 
917
  $element['_render']['element'] = '<input type="text"';
918
  //$element['_render']['element'] .= sprintf( ' data-wpt-type="%s" ', __FUNCTION__ );
919
+ $element['_render']['element'] .= sprintf(' id="%s"', $element['#id']);
920
+ $element['_render']['element'] .= sprintf(' name="%s"', $element['#name']);
921
+ $element['_render']['element'] .= sprintf(' value="%s"', isset($element['#value']) ? esc_attr($element['#value']) : '' );
922
  $element['_render']['element'] .= $element['_attributes_string'];
923
  if (isset($element['#disable']) && $element['#disable']) {
924
  $element['_render']['element'] .= ' disabled="disabled"';
926
  /**
927
  * type and data_id
928
  */
929
+ $element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
930
+ $element['_render']['element'] .= $this->_getDataWptId($element);
931
 
932
  $element['_render']['element'] .= ' />';
933
+ $pattern = $this->_getStatndardPatern($element);
934
  $output = $this->_pattern($pattern, $element);
935
  $output = $this->_wrapElement($element, $output);
936
  return $output . "\r\n";
942
  * @param array $element
943
  * @return string
944
  */
945
+ public function password($element) {
 
946
  $element['#type'] = 'password';
947
  $element = $this->_setRender($element);
948
  $element['_render']['element'] = '<input type="password" id="'
955
  /**
956
  * type and data_id
957
  */
958
+ $element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
959
+ $element['_render']['element'] .= $this->_getDataWptId($element);
960
 
961
  $element['_render']['element'] .= ' />';
962
  $pattern = $this->_getStatndardPatern($element);
971
  * @param array $element
972
  * @return string
973
  */
974
+ public function textarea($element) {
 
975
  $element['#type'] = 'textarea';
976
  if (!isset($element['#attributes']['rows'])) {
977
  $element['#attributes']['rows'] = 5;
986
  /**
987
  * type and data_id
988
  */
989
+ $element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
990
+ $element['_render']['element'] .= $this->_getDataWptId($element);
991
 
992
  $element['_render']['element'] .= '>';
993
 
994
  $element['_render']['element'] .= isset($element['#value']) ? esc_attr($element['#value']) : '';
995
  $element['_render']['element'] .= '</textarea>' . "\r\n";
996
+ $pattern = $this->_getStatndardPatern($element);
997
  $output = $this->_pattern($pattern, $element);
998
  $output = $this->_wrapElement($element, $output);
999
  return $output . "\r\n";
1005
  * @param array $element
1006
  * @return string
1007
  */
1008
+ public function file($element) {
 
1009
  $element['#type'] = 'file';
1010
  $element = $this->_setRender($element);
1011
  $element['_render']['element'] = '<input type="file" id="'
1017
  /**
1018
  * type and data_id
1019
  */
1020
+ $element['_render']['element'] .= sprintf(' data-wpt-type="%s"', __FUNCTION__);
1021
+ $element['_render']['element'] .= $this->_getDataWptId($element);
1022
 
1023
  $element['_render']['element'] .= ' />';
1024
+ $pattern = $this->_getStatndardPatern($element);
1025
  $output = $this->_pattern($pattern, $element);
1026
  $output = $this->_wrapElement($element, $output);
1027
  return $output;
1033
  * @param array $element
1034
  * @return string
1035
  */
1036
+ public function markup($element) {
 
1037
  return $element['#markup'];
1038
  }
1039
 
1043
  * @param array $element
1044
  * @return string
1045
  */
1046
+ public function hidden($element) {
 
1047
  $element['#type'] = 'hidden';
1048
  $element = $this->_setRender($element);
1049
  $output = '<input type="hidden" id="' . $element['#id'] . '" name="'
1050
  . $element['#name'] . '" value="';
1051
  $output .= isset($element['#value']) ? $element['#value'] : 1;
1052
+ $output .= '"' . $element['_attributes_string'] . $this->_getDataWptId($element) . ' />';
1053
  return $output;
1054
  }
1055
 
1059
  * @param array $element
1060
  * @return string
1061
  */
1062
+ public function reset($element) {
 
1063
  return $this->submit($element, 'reset', 'Reset');
1064
  }
1065
 
1069
  * @param array $element
1070
  * @return string
1071
  */
1072
+ public function button($element) {
 
1073
  return $this->submit($element, 'button', 'Button');
1074
  }
1075
 
1083
  * @param string $title
1084
  * @return string
1085
  */
1086
+ public function submit($element, $type = 'submit', $title = 'Submit') {
 
1087
  $element['#type'] = $type;
1088
  $element = $this->_setRender($element);
1089
  $element['_render']['element'] = '<input type="' . $type . '" id="'
1091
  $element['_render']['element'] .= isset($element['#value']) ? $element['#value'] : $title;
1092
  $element['_render']['element'] .= '"' . $element['_attributes_string']
1093
  . ' />';
1094
+ $pattern = $this->_getStatndardPatern($element, '<BEFORE><PREFIX><ELEMENT><SUFFIX><AFTER>');
1095
  $output = $this->_pattern($pattern, $element);
1096
  return $output;
1097
  }
1102
  * @param type $element
1103
  * @return type mixed
1104
  */
1105
+ public function getSubmittedData($element) {
 
1106
  $name = $element['#name'];
1107
  if (strpos($name, '[') === false) {
1108
  if ($element['#type'] == 'file') {
1109
  return $_FILES[$name]['tmp_name'];
1110
  }
1111
+ return isset($_REQUEST[$name]) ? $_REQUEST[$name] : in_array($element['#type'], array('textfield', 'textarea')) ? '' : 0;
 
1112
  }
1113
 
1114
  $parts = explode('[', $name);
1115
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196173458/comments
1116
+ //Security Fixing
1117
+ //$parts = array_map(create function('&$a', 'return trim($a, \']\');'), $parts);
1118
+ $parts = array_map("cred_mytrimfunction", $parts);
1119
  if (!isset($_REQUEST[$parts[0]])) {
1120
  return in_array($element['#type'], array('textfield', 'textarea')) ? '' : 0;
1121
  }
1124
  $key = $parts[$index];
1125
  // We're at the end but no data retrieved
1126
  if (!isset($parts[$index + 1])) {
1127
+ return in_array($element['#type'], array('textfield', 'textarea')) ? '' : 0;
 
1128
  }
1129
  $key_next = $parts[$index + 1];
1130
  if ($index > 0) {
1131
  if (!isset($search[$key])) {
1132
+ return in_array($element['#type'], array('textfield', 'textarea')) ? '' : 0;
 
1133
  } else {
1134
  $search = $search[$key];
1135
  }
1143
  return 0;
1144
  }
1145
 
1146
+ private function _getDataWptId($element) {
 
1147
  $html = '';
1148
+ if (array_key_exists('#id', $element)) {
1149
+ if (is_admin()) {
1150
+ $html .= sprintf(' data-wpt-id="%s"', preg_replace('/\[/', '-', preg_replace('/\]/', '', $element['#name'])));
1151
  } else {
1152
+ $html .= sprintf(' data-wpt-id="%s_%s"', $this->_id, $element['#id']);
1153
  }
1154
+ if (array_key_exists('#name', $element) && $element['#name']) {
1155
+ if (!is_admin() && $this->_isRepetitive($element)) {
1156
+ $html .= sprintf(' data-wpt-name="%s"', preg_replace('/\[.+$/', '', $element['#name']));
1157
  } else {
1158
+ if (preg_match('/^wpcf_post_relationship\[\d+\]\[\d+\]\[[^\]]+\]/', $element['#name'])) {
1159
  $html .= sprintf(
1160
+ ' data-wpt-name="%s"', preg_replace('/^wpcf_post_relationship\[\d+\]\[(\d+)\]\[wpcf-([^\]]+)\]/', "wpcf[$2-$1]", $element['#name']));
 
1161
  } else {
1162
+ $html .= sprintf(' data-wpt-name="%s"', $element['#name']);
1163
  }
1164
  }
1165
  }
1167
  return $html;
1168
  }
1169
 
1170
+ private function _getStatndardPatern($element, $default = false) {
1171
+ if (isset($element['#pattern'])) {
 
1172
  return $element['#pattern'];
1173
  }
1174
+ if ($default) {
1175
  return $default;
1176
  }
1177
+ if (is_admin()) {
1178
  return '<BEFORE><LABEL><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>';
1179
  }
1180
  return '<BEFORE><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>';
1181
  }
1182
 
1183
+ private function _isRepetitive($element) {
1184
+ if (!is_array($element)) {
 
1185
  return false;
1186
  }
1187
+ return array_key_exists('#repetitive', $element) && $element['#repetitive'];
1188
+ }
1189
+
1190
+ static function json_encode($array) {
1191
+ // php > 5.3 do not escape utf-8 characters using native constant argument
1192
+ if (defined('JSON_UNESCAPED_UNICODE')) {
1193
+ return json_encode($array, JSON_UNESCAPED_UNICODE);
1194
+ }
1195
+ // fallback for php < 5.3 to support unicode characters in json string
1196
+ else {
1197
+ if (function_exists('mb_decode_numericentity')) {
1198
+ return self::json_encode_unescaped_unicode($array);
1199
+ } else {
1200
+ return json_encode($array);
1201
+ }
1202
+ }
1203
+ }
1204
+
1205
+ /**
1206
+ * @param $arr
1207
+ * @return string
1208
+ * courtesy from: http://www.php.net/manual/ru/function.json-encode.php#105789
1209
+ */
1210
+ public static function json_encode_unescaped_unicode($arr) {
1211
+
1212
+ array_walk_recursive($arr, array(__CLASS__, 'json_unescaped_unicode_walk_callback'));
1213
+
1214
+ return mb_decode_numericentity(json_encode($arr), array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
1215
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1216
 
1217
  /*
1218
  * Helper function to json_encode with UTF-8 support for php < 5.3
1219
  */
1220
+
1221
+ public static function json_unescaped_unicode_walk_callback(&$item, $key) {
1222
+ if (is_string($item))
1223
+ $item = mb_encode_numericentity($item, array(0x80, 0xffff, 0, 0xffff), 'UTF-8');
1224
+ }
1225
+
1226
  }
embedded/common/toolset-forms/classes/class.field_factory.php CHANGED
@@ -2,10 +2,6 @@
2
 
3
  /**
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.field_factory.php $
6
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
7
- * $LastChangedRevision: 970205 $
8
- * $LastChangedBy: brucepearson $
9
  *
10
  */
11
 
@@ -28,6 +24,17 @@ abstract class FieldFactory extends FieldAbstract
28
  {
29
  $cred_cred_settings = get_option( 'cred_cred_settings' );
30
  $this->_use_bootstrap = is_array($cred_cred_settings) && array_key_exists( 'use_bootstrap', $cred_cred_settings ) && $cred_cred_settings['use_bootstrap'];
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
 
33
  public function set_metaform($metaform)
@@ -72,11 +79,21 @@ abstract class FieldFactory extends FieldAbstract
72
 
73
  public function getValue()
74
  {
75
- return $this->_value;
 
 
 
 
 
 
 
76
  }
77
 
78
- public function getTitle()
79
  {
 
 
 
80
  return $this->_data['title'];
81
  }
82
 
@@ -122,6 +139,14 @@ abstract class FieldFactory extends FieldAbstract
122
  return array();
123
  }
124
 
 
 
 
 
 
 
 
 
125
  public static function registerScripts() {}
126
  public static function registerStyles() {}
127
  public static function addFilters() {}
2
 
3
  /**
4
  *
 
 
 
 
5
  *
6
  */
7
 
24
  {
25
  $cred_cred_settings = get_option( 'cred_cred_settings' );
26
  $this->_use_bootstrap = is_array($cred_cred_settings) && array_key_exists( 'use_bootstrap', $cred_cred_settings ) && $cred_cred_settings['use_bootstrap'];
27
+ $this->set_placeholder_as_attribute();
28
+ }
29
+
30
+ public function set_placeholder_as_attribute()
31
+ {
32
+ if ( !isset($this->_data['attribute']) ) {
33
+ $this->_data['attribute'] = array();
34
+ }
35
+ if ( isset($this->_data['placeholder']) && !empty($this->_data['placeholder'])) {
36
+ $this->_data['attribute']['placeholder'] = htmlentities(stripcslashes($this->_data['placeholder']));
37
+ }
38
  }
39
 
40
  public function set_metaform($metaform)
79
 
80
  public function getValue()
81
  {
82
+ global $post;
83
+ $value = $this->_value;
84
+ $value = apply_filters( 'wpcf_fields_value_get', $value, $post );
85
+ if ( array_key_exists('slug', $this->_data ) ) {
86
+ $value = apply_filters( 'wpcf_fields_slug_' . $this->_data['slug'] . '_value_get', $value, $post );
87
+ }
88
+ $value = apply_filters( 'wpcf_fields_type_' . $this->_data['type'] . '_value_get', $value, $post );
89
+ return $value;
90
  }
91
 
92
+ public function getTitle($_title = false)
93
  {
94
+ if ( $_title && empty($this->_data['title']) && isset($this->_data['_title']) ) {
95
+ return $this->_data['_title'];
96
+ }
97
  return $this->_data['title'];
98
  }
99
 
139
  return array();
140
  }
141
 
142
+ public function getWPMLAction()
143
+ {
144
+ if ( array_key_exists( 'wpml_action', $this->_data ) ) {
145
+ return $this->_data['wpml_action'];
146
+ }
147
+ return 0;
148
+ }
149
+
150
  public static function registerScripts() {}
151
  public static function registerStyles() {}
152
  public static function addFilters() {}
embedded/common/toolset-forms/classes/class.fieldconfig.php CHANGED
@@ -1,13 +1,11 @@
1
  <?php
 
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.fieldconfig.php $
5
- * $LastChangedDate: 2015-06-15 08:18:54 +0000 (Mon, 15 Jun 2015) $
6
- * $LastChangedRevision: 1180956 $
7
- * $LastChangedBy: iworks $
8
  *
9
  */
10
  if (!class_exists("FieldConfig")) {
 
11
  /**
12
  * Description of FieldConfig
13
  *
@@ -28,10 +26,10 @@ if (!class_exists("FieldConfig")) {
28
  private $default_value = '';
29
  private $validation = array();
30
  private $attr;
31
-
32
  private $add_time = false;
33
 
34
  public function __construct() {
 
35
  }
36
 
37
  public function setRepetitive($repetitive) {
@@ -45,32 +43,41 @@ if (!class_exists("FieldConfig")) {
45
  public function set_add_time($addtime) {
46
  $this->add_time = $addtime;
47
  }
48
-
49
  public function setAttr($attr) {
50
  $this->attr = $attr;
51
  }
52
-
53
  public function getAttr() {
54
  return $this->attr;
55
  }
56
 
57
- public function setDefaultValue($type,$field_arr)
58
- {
59
  switch ($type) {
60
  case 'date':
61
  $this->add_time = false;
62
- if ( isset( $field_arr['data']['date_and_time'] ) && 'and_time' == $field_arr['data']['date_and_time'] ) {
63
- $this->add_time = true;
64
- }
65
  break;
66
  case 'checkboxes':
67
- if ( is_array( $field_arr['attr']['default'] ) && count( $field_arr['attr']['default'] ) ) {
68
  $this->default_value = $field_arr['attr']['default'][0];
69
  }
70
  break;
71
 
72
  case 'select':
73
- $this->default_value = isset( $field_arr['attr']['actual_value'][0] )? $field_arr['attr']['actual_value'][0] : null;
 
 
 
 
 
 
 
 
 
 
74
  break;
75
 
76
  case 'radios':
@@ -78,33 +85,35 @@ if (!class_exists("FieldConfig")) {
78
  break;
79
 
80
  case 'checkbox':
81
- $this->default_value = isset($field_arr['data']['checked'])?$field_arr['data']['checked']:0;
 
 
82
  break;
83
-
84
  default:
85
  $this->default_value = "";
86
  break;
87
  }
88
  }
89
 
90
- public function setOptions($name,$type,$values,$attrs) {
91
  $arr = array();
92
  switch ($type) {
93
  case 'checkbox':
94
- $arr=$attrs;
95
  break;
96
  case 'checkboxes':
97
- foreach ($attrs['actual_titles'] as $refvalue=>$title) {
98
  $value = $attrs['actual_values'][$refvalue];
99
- $arr[$refvalue] = array('value'=>$refvalue,'title'=>$title,'name'=>$name,'data-value'=>$value);
100
- if ( in_array($refvalue, $attrs['default']) ) {
101
  $arr[$refvalue]['checked'] = true;
102
  }
103
  }
104
  break;
105
  case 'select':
106
  $values = $attrs['options'];
107
- foreach ($values as $refvalue=>$title) {
108
  $arr[$refvalue] = array(
109
  'value' => $refvalue,
110
  'title' => $title,
@@ -113,7 +122,7 @@ if (!class_exists("FieldConfig")) {
113
  }
114
  break;
115
  case 'radios':
116
- foreach ($attrs['actual_titles'] as $refvalue=>$title) {
117
  $arr[$refvalue] = array(
118
  'value' => $refvalue,
119
  'title' => $title,
@@ -122,10 +131,10 @@ if (!class_exists("FieldConfig")) {
122
  'types-value' => $attrs['actual_values'][$refvalue],
123
  );
124
  }
125
- break;
126
  default:
127
  return;
128
- break;
129
  }
130
  $this->options = $arr;
131
  }
@@ -140,13 +149,13 @@ if (!class_exists("FieldConfig")) {
140
  'default_value' => $this->getDefaultValue(),
141
  'description' => $this->getDescription(),
142
  'repetitive' => $this->isRepetitive(),
143
- /*'name' => $base_name."[".$this->getType()."]",*/
144
  'name' => $this->getName(),
145
  'value' => $this->getValue(),
146
  'add_time' => $this->getAddTime(),
147
  'validation' => array(),
148
  'display' => $this->getDisplay(),
149
- 'attribute' => $this->getAttr()
150
  );
151
  return $this->config;
152
  }
@@ -175,8 +184,7 @@ if (!class_exists("FieldConfig")) {
175
  return $this->title;
176
  }
177
 
178
- public function getDisplay()
179
- {
180
  return $this->display;
181
  }
182
 
@@ -232,10 +240,11 @@ if (!class_exists("FieldConfig")) {
232
  $this->id = $id;
233
  }
234
 
235
- public function setDisplay($display)
236
- {
237
  $this->display = $display;
238
  }
 
239
  }
 
240
  }
241
 
1
  <?php
2
+
3
  /**
4
  *
 
 
 
 
5
  *
6
  */
7
  if (!class_exists("FieldConfig")) {
8
+
9
  /**
10
  * Description of FieldConfig
11
  *
26
  private $default_value = '';
27
  private $validation = array();
28
  private $attr;
 
29
  private $add_time = false;
30
 
31
  public function __construct() {
32
+
33
  }
34
 
35
  public function setRepetitive($repetitive) {
43
  public function set_add_time($addtime) {
44
  $this->add_time = $addtime;
45
  }
46
+
47
  public function setAttr($attr) {
48
  $this->attr = $attr;
49
  }
50
+
51
  public function getAttr() {
52
  return $this->attr;
53
  }
54
 
55
+ public function setDefaultValue($type, $field_arr) {
 
56
  switch ($type) {
57
  case 'date':
58
  $this->add_time = false;
59
+ if (isset($field_arr['data']['date_and_time']) && 'and_time' == $field_arr['data']['date_and_time']) {
60
+ $this->add_time = true;
61
+ }
62
  break;
63
  case 'checkboxes':
64
+ if (is_array($field_arr['attr']['default']) && count($field_arr['attr']['default'])) {
65
  $this->default_value = $field_arr['attr']['default'][0];
66
  }
67
  break;
68
 
69
  case 'select':
70
+ if (isset($field_arr['attr']['multiple'])) {
71
+ //Multiselect
72
+ if (isset($field_arr['value']))
73
+ foreach ($field_arr['value'] as $value) {
74
+ if (isset($value[0])) {
75
+ $this->default_value = $value;
76
+ break;
77
+ }
78
+ }
79
+ } else
80
+ $this->default_value = isset($field_arr['attr']['actual_value'][0]) ? $field_arr['attr']['actual_value'][0] : null;
81
  break;
82
 
83
  case 'radios':
85
  break;
86
 
87
  case 'checkbox':
88
+ $this->default_value = isset($field_arr['data']['checked']) ? $field_arr['data']['checked'] : false;
89
+ /*if (!$this->default_value)
90
+ $this->default_value = isset($field_arr['data']['set_value']) && $field_arr['data']['set_value'] == 'y' ? true : false;*/
91
  break;
92
+
93
  default:
94
  $this->default_value = "";
95
  break;
96
  }
97
  }
98
 
99
+ public function setOptions($name, $type, $values, $attrs) {
100
  $arr = array();
101
  switch ($type) {
102
  case 'checkbox':
103
+ $arr = $attrs;
104
  break;
105
  case 'checkboxes':
106
+ foreach ($attrs['actual_titles'] as $refvalue => $title) {
107
  $value = $attrs['actual_values'][$refvalue];
108
+ $arr[$refvalue] = array('value' => $refvalue, 'title' => $title, 'name' => $name, 'data-value' => $value);
109
+ if (in_array($refvalue, $attrs['default'])) {
110
  $arr[$refvalue]['checked'] = true;
111
  }
112
  }
113
  break;
114
  case 'select':
115
  $values = $attrs['options'];
116
+ foreach ($values as $refvalue => $title) {
117
  $arr[$refvalue] = array(
118
  'value' => $refvalue,
119
  'title' => $title,
122
  }
123
  break;
124
  case 'radios':
125
+ foreach ($attrs['actual_titles'] as $refvalue => $title) {
126
  $arr[$refvalue] = array(
127
  'value' => $refvalue,
128
  'title' => $title,
131
  'types-value' => $attrs['actual_values'][$refvalue],
132
  );
133
  }
134
+ break;
135
  default:
136
  return;
137
+ break;
138
  }
139
  $this->options = $arr;
140
  }
149
  'default_value' => $this->getDefaultValue(),
150
  'description' => $this->getDescription(),
151
  'repetitive' => $this->isRepetitive(),
152
+ /* 'name' => $base_name."[".$this->getType()."]", */
153
  'name' => $this->getName(),
154
  'value' => $this->getValue(),
155
  'add_time' => $this->getAddTime(),
156
  'validation' => array(),
157
  'display' => $this->getDisplay(),
158
+ 'attribute' => $this->getAttr()
159
  );
160
  return $this->config;
161
  }
184
  return $this->title;
185
  }
186
 
187
+ public function getDisplay() {
 
188
  return $this->display;
189
  }
190
 
240
  $this->id = $id;
241
  }
242
 
243
+ public function setDisplay($display) {
 
244
  $this->display = $display;
245
  }
246
+
247
  }
248
+
249
  }
250
 
embedded/common/toolset-forms/classes/class.file.php CHANGED
@@ -1,10 +1,6 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.file.php $
5
- * $LastChangedDate: 2014-08-08 16:42:50 +0200 (Fri, 08 Aug 2014) $
6
- * $LastChangedRevision: 25798 $
7
- * $LastChangedBy: juan $
8
  *
9
  */
10
  require_once 'class.textfield.php';
@@ -20,72 +16,110 @@ class WPToolset_Field_File extends WPToolset_Field_Textfield
20
  protected $_validation = array('required');
21
  //protected $_defaults = array('filename' => '', 'button_style' => 'btn2');
22
 
23
- public function init() {
 
24
  WPToolset_Field_File::file_enqueue_scripts();
 
25
  }
26
 
27
- public static function file_enqueue_scripts() {
28
- wp_register_script( 'wptoolset-field-file',
29
- WPTOOLSET_FORMS_RELPATH . '/js/file.js', array('jquery'),
30
- WPTOOLSET_FORMS_VERSION, true );
31
-
 
 
 
 
 
32
  if ( !wp_script_is( 'wptoolset-field-file', 'enqueued' ) ) {
33
- wp_enqueue_script( 'wptoolset-field-file' );
34
- add_thickbox();
35
- global $post;
36
- $for_post = (!empty( $post->ID ) ? 'post_id=' . $post->ID . '&' : '');
37
- $js_data = array('title' => esc_js( __( 'Select file', 'wpv-views' ) ), 'for_post' => $for_post, 'adminurl' => admin_url());
38
- wp_localize_script( 'wptoolset-field-file', 'wptFileData', $js_data );
39
- }
40
- }
41
-
42
- public function enqueueStyles() {
43
-
 
 
 
 
 
 
44
  }
45
 
46
- public function metaform() {
 
 
 
 
 
 
 
 
 
 
47
  $value = $this->getValue();
48
- $type = $this->getType();
49
- $translated_type = '';
50
  $form = array();
51
  $preview = '';
52
-
53
  // Get attachment by guid
54
  if ( !empty( $value ) ) {
55
  global $wpdb;
56
- $attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s", $value ) );
 
 
 
 
 
57
  }
58
 
59
  // Set preview
60
  if ( !empty( $attachment_id ) ) {
61
- $preview = wp_get_attachment_image( $attachment_id, 'thumbnail' );
 
 
 
 
 
62
  } else {
63
  // If external image set preview
64
  $file_path = parse_url( $value );
65
- if ( $file_path && isset( $file_path['path'] ) )
66
- $file = pathinfo( $file_path['path'] );
67
- else $file = pathinfo( $value );
68
- if ( isset( $file['extension'] ) && in_array( strtolower( $file['extension'] ),
69
- array('jpg', 'jpeg', 'gif', 'png') ) ) {
 
 
 
 
 
70
  $preview = '<img alt="" src="' . $value . '" />';
71
  }
72
  }
73
 
74
  // Set button
75
- switch( $type ) {
76
- case 'audio':
77
- $translated_type = __( 'audio', 'wpv-views' );
78
- break;
79
- case 'image':
80
- $translated_type = __( 'image', 'wpv-views' );
81
- break;
82
- case 'video':
83
- $translated_type = __( 'video', 'wpv-views' );
84
- break;
85
- default:
86
- $translated_type = __( 'file', 'wpv-views' );
87
- break;
88
- }
89
  $button = sprintf(
90
  '<a href="#" class="js-wpt-file-upload button button-secondary" data-wpt-type="%s">%s</a>',
91
  $type,
@@ -97,11 +131,12 @@ class WPToolset_Field_File extends WPToolset_Field_Textfield
97
  '#type' => 'textfield',
98
  '#name' => $this->getName(),
99
  '#title' => $this->getTitle(),
100
- '#description' => $this->getDescription(),
101
  '#value' => $value,
102
  '#suffix' => '&nbsp;' . $button,
103
  '#validate' => $this->getValidationData(),
104
  '#repetitive' => $this->isRepetitive(),
 
105
  );
106
 
107
  $form[] = array(
@@ -111,80 +146,4 @@ class WPToolset_Field_File extends WPToolset_Field_Textfield
111
 
112
  return $form;
113
  }
114
-
115
- public static function mediaPopup() {
116
- WPToolset_Field_File::file_enqueue_scripts();
117
- // Add types button
118
- add_filter( 'attachment_fields_to_edit',
119
- array('WPToolset_Field_File', 'attachmentFieldsToEditFilter'),
120
- 9999, 2 );
121
- // Filter media TABs
122
- add_filter( 'media_upload_tabs',
123
- array('WPToolset_Field_File', 'mediaUploadTabsFilter') );
124
- // Add head data
125
- add_filter( 'admin_head',
126
- array('WPToolset_Field_File', 'mediaPopupHead') );
127
- }
128
-
129
- /**
130
- * Adds column to media item table.
131
- *
132
- * @param type $form_fields
133
- * @param type $post
134
- * @return type
135
- */
136
- public static function attachmentFieldsToEditFilter( $form_fields, $post ) {
137
- // Reset form
138
- $form_fields = array();
139
- $type = (strpos( $post->post_mime_type, 'image/' ) !== false) ? 'image' : 'file';
140
- $url = wp_get_attachment_url( $post->ID );
141
- $form_fields['wpt_fields_file'] = array(
142
- 'label' => __( 'Toolset' ),
143
- 'input' => 'html',
144
- 'html' => '<a href="#" title="' . $url
145
- . '" class="js-wpt-file-insert-button'
146
- . ' button-primary" onclick="wptFile.mediaInsertTrigger(\''
147
- . $url . '\', \'' . $type . '\')">'
148
- . __( 'Use as field value', 'wpv-views' ) . '</a><br /><br />',
149
- );
150
- return $form_fields;
151
- }
152
-
153
- /**
154
- * Filters media TABs.
155
- *
156
- * @param type $tabs
157
- * @return type
158
- */
159
- public static function mediaUploadTabsFilter( $tabs ) {
160
- unset( $tabs['type_url'] );
161
- return $tabs;
162
- }
163
-
164
- /**
165
- * Media popup head.
166
- */
167
- public static function mediaPopupHead() {
168
- ?>
169
- <script type="text/javascript">
170
- <?php
171
- if ( isset( $_GET['wpt']['type'] ) && in_array( $_GET['wpt']['type'],
172
- array('audio', 'video') ) ):
173
-
174
- ?>
175
- jQuery(document).ready(function($) {
176
- $('#media-upload-header').after('<div class="message updated"><p><?php
177
- printf( esc_js( __( 'Please note that not all video and audio formats are supported by the WordPress media player. Before you upload media files, have a look at %ssupported media formats%s.', 'wpv-views' ) ),
178
- '<a href="http://wp-types.com/documentation/user-guides/adding-audio-video-and-other-embedded-content-to-your-site/?utm_source=typesplugin&utm_campaign=types&utm_medium=types-field-media-popup&utm_term=supported media formats" target="_blank">',
179
- '</a>' );
180
-
181
- ?></p></div>');
182
- });
183
- <?php endif; ?>
184
- </script>
185
- <style type="text/css">
186
- tr.submit, .ml-submit, #save, #media-items .A1B1 p:last-child { display: none; }
187
- </style>
188
- <?php
189
- }
190
  }
1
  <?php
2
  /**
3
  *
 
 
 
 
4
  *
5
  */
6
  require_once 'class.textfield.php';
16
  protected $_validation = array('required');
17
  //protected $_defaults = array('filename' => '', 'button_style' => 'btn2');
18
 
19
+ public function init()
20
+ {
21
  WPToolset_Field_File::file_enqueue_scripts();
22
+ $this->set_placeholder_as_attribute();
23
  }
24
 
25
+ public static function file_enqueue_scripts()
26
+ {
27
+ wp_register_script(
28
+ 'wptoolset-field-file',
29
+ WPTOOLSET_FORMS_RELPATH . '/js/file-wp35.js',
30
+ array('jquery', 'jquery-masonry'),
31
+ WPTOOLSET_FORMS_VERSION,
32
+ true
33
+ );
34
+
35
  if ( !wp_script_is( 'wptoolset-field-file', 'enqueued' ) ) {
36
+ wp_enqueue_script( 'wptoolset-field-file' );
37
+ }
38
+
39
+ if ( is_admin() ) {
40
+ $screen = get_current_screen();
41
+ if (isset($screen->parent_base) && 'users' == $screen->parent_base) {
42
+ wp_enqueue_media();
43
+ }
44
+
45
+ if (isset($screen->post_type) && !empty($screen->parent_base)) {
46
+ global $post;
47
+ if ( is_object($post) ) {
48
+ wp_enqueue_media(array('post' => $post->ID));
49
+ }
50
+ }
51
+ }
52
+
53
  }
54
 
55
+ public function enqueueStyles()
56
+ {
57
+ }
58
+
59
+ /**
60
+ *
61
+ * @global object $wpdb
62
+ *
63
+ */
64
+ public function metaform()
65
+ {
66
  $value = $this->getValue();
67
+ $type = $this->getType();
68
+ $translated_type = '';
69
  $form = array();
70
  $preview = '';
71
+
72
  // Get attachment by guid
73
  if ( !empty( $value ) ) {
74
  global $wpdb;
75
+ $attachment_id = $wpdb->get_var(
76
+ $wpdb->prepare(
77
+ "SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s",
78
+ $value
79
+ )
80
+ );
81
  }
82
 
83
  // Set preview
84
  if ( !empty( $attachment_id ) ) {
85
+ $attributes = array();
86
+ $full = wp_get_attachment_image_src($attachment_id, 'full');
87
+ if ( !empty($full) ) {
88
+ $attributes['data-full-src'] = esc_attr($full[0]);
89
+ }
90
+ $preview = wp_get_attachment_image( $attachment_id, 'thumbnail', false, $attributes);
91
  } else {
92
  // If external image set preview
93
  $file_path = parse_url( $value );
94
+ if ( $file_path && isset( $file_path['path'] ) ) {
95
+ $file = pathinfo( $file_path['path'] );
96
+ }
97
+ else {
98
+ $file = pathinfo( $value );
99
+ }
100
+ if (
101
+ isset( $file['extension'] )
102
+ && in_array( strtolower( $file['extension'] ), array('jpg', 'jpeg', 'gif', 'png') )
103
+ ) {
104
  $preview = '<img alt="" src="' . $value . '" />';
105
  }
106
  }
107
 
108
  // Set button
109
+ switch( $type ) {
110
+ case 'audio':
111
+ $translated_type = __( 'audio', 'wpv-views' );
112
+ break;
113
+ case 'image':
114
+ $translated_type = __( 'image', 'wpv-views' );
115
+ break;
116
+ case 'video':
117
+ $translated_type = __( 'video', 'wpv-views' );
118
+ break;
119
+ default:
120
+ $translated_type = __( 'file', 'wpv-views' );
121
+ break;
122
+ }
123
  $button = sprintf(
124
  '<a href="#" class="js-wpt-file-upload button button-secondary" data-wpt-type="%s">%s</a>',
125
  $type,
131
  '#type' => 'textfield',
132
  '#name' => $this->getName(),
133
  '#title' => $this->getTitle(),
134
+ '#description' => $this->getDescription(),
135
  '#value' => $value,
136
  '#suffix' => '&nbsp;' . $button,
137
  '#validate' => $this->getValidationData(),
138
  '#repetitive' => $this->isRepetitive(),
139
+ '#attributes' => $this->getAttr(),
140
  );
141
 
142
  $form[] = array(
146
 
147
  return $form;
148
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  }
embedded/common/toolset-forms/classes/class.form_factory.php CHANGED
@@ -10,10 +10,6 @@ define( "CLASS_NAME_PREFIX", "WPToolset_Field_" );
10
  * Creation Form Class
11
  * @author onTheGo System
12
  *
13
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.form_factory.php $
14
- * $LastChangedDate: 2015-06-15 08:18:54 +0000 (Mon, 15 Jun 2015) $
15
- * $LastChangedRevision: 1180956 $
16
- * $LastChangedBy: iworks $
17
  *
18
  *
19
  */
@@ -37,8 +33,12 @@ class FormFactory extends FormAbstract
37
 
38
  wp_register_script( 'wptoolset-forms',
39
  WPTOOLSET_FORMS_RELPATH . '/js/main.js',
40
- array('jquery', 'underscore'), WPTOOLSET_FORMS_VERSION, false );
41
  wp_enqueue_script( 'wptoolset-forms' );
 
 
 
 
42
 
43
  if ( is_admin() ) {
44
  wp_register_style( 'wptoolset-forms-admin',
@@ -52,10 +52,22 @@ class FormFactory extends FormAbstract
52
  $cred_cred_settings = get_option( 'cred_cred_settings' );
53
  /**
54
  * load or not cred.css
 
55
  */
56
  $load_cred_css = true;
57
- if ( is_array($cred_cred_settings) && array_key_exists('dont_load_cred_css', $cred_cred_settings ) && $cred_cred_settings['dont_load_cred_css'] ) {
58
- $load_cred_css = false;
 
 
 
 
 
 
 
 
 
 
 
59
  }
60
  /**
61
  * register
@@ -69,10 +81,6 @@ class FormFactory extends FormAbstract
69
  );
70
  wp_enqueue_style( 'wptoolset-forms-cred' );
71
  }
72
-
73
- if ( array_key_exists( 'use_bootstrap', $cred_cred_settings ) && $cred_cred_settings['use_bootstrap'] ) {
74
- $this->_use_bootstrap = true;
75
- }
76
  }
77
  }
78
 
@@ -170,16 +178,28 @@ class FormFactory extends FormAbstract
170
  */
171
  $config['use_bootstrap'] = $this->theForm->form_settings['use_bootstrap'];
172
  $config['has_media_button'] = $this->theForm->form_settings['has_media_button'];
 
 
 
 
 
173
  $htmlArray = array();
174
  $_gnf = $global_name_field;
175
  $_cfg = $config;
176
  if ( empty( $value ) ) $value = array(null);
177
  elseif ( !is_array( $value ) ) $value = array($value);
178
  $count = 0;
179
- foreach ( $value as $val ) {
 
 
 
 
 
 
 
180
  if ( !empty( $config['repetitive'] ) ) {
181
  $_gnf = $_cfg['name'] = "{$global_name_field}[{$count}]";
182
- }
183
  //CHECKGEN
184
  if ( isset($_cfg['validation']) &&
185
  is_array($_cfg['validation']) &&
@@ -187,7 +207,7 @@ class FormFactory extends FormAbstract
187
  !is_admin() && $_SERVER['REQUEST_METHOD'] == 'POST' &&
188
  isset( $_GET['_tt'] ) &&
189
  !isset( $_GET['_success'] ) &&
190
- !isset( $_GET['_success_message'] ) )
191
  {
192
  $_cfg['validate'] = 1;
193
  }
@@ -211,10 +231,24 @@ class FormFactory extends FormAbstract
211
  }
212
  $this->form[$global_name_field] = $form;
213
  $this->field_count++;
214
- $htmlArray[] = $this->theForm->renderElements( $form );
215
  if ( empty( $config['repetitive'] ) ) break;
216
  $count++;
217
- } else echo "error";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  }
219
  if ( !empty( $htmlArray ) && isset($config['repetitive']) && $config['repetitive'] ) {
220
  $_gnf = $_cfg['name'] = "{$global_name_field}[%%{$count}%%]";
@@ -224,6 +258,7 @@ class FormFactory extends FormAbstract
224
  $this->_repetitive()->add( $config, $tpl );
225
  }
226
  }
 
227
  return !empty( $htmlArray ) ? $this->_tpl( $config, $htmlArray ) : '';
228
  }
229
 
@@ -352,7 +387,7 @@ class FormFactory extends FormAbstract
352
  {
353
  $mess = $field->getTitle().' Field is required';
354
  return new WP_Error( 'wptoolset_forms', $mess,
355
- array($field->getTitle().' Field is required') );;
356
  }
357
  }
358
  }
@@ -380,6 +415,15 @@ class FormFactory extends FormAbstract
380
  public function loadFieldClass( $type ) {
381
  $type = strtolower( $type );
382
  $class = $this->getClassFromType( $type );
 
 
 
 
 
 
 
 
 
383
  if ( !class_exists( $class ) ) {
384
  $file = WPTOOLSET_FORMS_ABSPATH . "/classes/class.{$type}.php";
385
  if ( file_exists( $file ) ) {
@@ -398,4 +442,16 @@ class FormFactory extends FormAbstract
398
  return class_exists( $class ) ? $class : false;
399
  }
400
 
 
 
 
 
 
 
 
 
 
 
 
 
401
  }
10
  * Creation Form Class
11
  * @author onTheGo System
12
  *
 
 
 
 
13
  *
14
  *
15
  */
33
 
34
  wp_register_script( 'wptoolset-forms',
35
  WPTOOLSET_FORMS_RELPATH . '/js/main.js',
36
+ array('jquery', 'underscore', 'suggest'), WPTOOLSET_FORMS_VERSION, false );
37
  wp_enqueue_script( 'wptoolset-forms' );
38
+ $wptoolset_forms_localization = array(
39
+ 'ajaxurl' => admin_url( 'admin-ajax.php', null )
40
+ );
41
+ wp_localize_script( 'wptoolset-forms', 'wptoolset_forms_local', $wptoolset_forms_localization );
42
 
43
  if ( is_admin() ) {
44
  wp_register_style( 'wptoolset-forms-admin',
52
  $cred_cred_settings = get_option( 'cred_cred_settings' );
53
  /**
54
  * load or not cred.css
55
+ * and check use bootstrap
56
  */
57
  $load_cred_css = true;
58
+ if ( is_array($cred_cred_settings) ) {
59
+ if (
60
+ array_key_exists('dont_load_cred_css', $cred_cred_settings )
61
+ && $cred_cred_settings['dont_load_cred_css']
62
+ ) {
63
+ $load_cred_css = false;
64
+ }
65
+ if (
66
+ array_key_exists( 'use_bootstrap', $cred_cred_settings )
67
+ && $cred_cred_settings['use_bootstrap']
68
+ ) {
69
+ $this->_use_bootstrap = true;
70
+ }
71
  }
72
  /**
73
  * register
81
  );
82
  wp_enqueue_style( 'wptoolset-forms-cred' );
83
  }
 
 
 
 
84
  }
85
  }
86
 
178
  */
179
  $config['use_bootstrap'] = $this->theForm->form_settings['use_bootstrap'];
180
  $config['has_media_button'] = $this->theForm->form_settings['has_media_button'];
181
+ /**
182
+ * WMPL configuration
183
+ */
184
+ $config['wpml_action'] = $this->get_wpml_action($config['id']);
185
+
186
  $htmlArray = array();
187
  $_gnf = $global_name_field;
188
  $_cfg = $config;
189
  if ( empty( $value ) ) $value = array(null);
190
  elseif ( !is_array( $value ) ) $value = array($value);
191
  $count = 0;
192
+
193
+ //Fix if i get skype i receive skype i have 2 elements array in $value !!
194
+ if ($config['type']=='skype') {
195
+ if (isset($value['style'])) unset($value['style']);
196
+ if (isset($value['button_style'])) unset($value['button_style']);
197
+ }
198
+
199
+ foreach ( $value as $val ) {
200
  if ( !empty( $config['repetitive'] ) ) {
201
  $_gnf = $_cfg['name'] = "{$global_name_field}[{$count}]";
202
+ }
203
  //CHECKGEN
204
  if ( isset($_cfg['validation']) &&
205
  is_array($_cfg['validation']) &&
207
  !is_admin() && $_SERVER['REQUEST_METHOD'] == 'POST' &&
208
  isset( $_GET['_tt'] ) &&
209
  !isset( $_GET['_success'] ) &&
210
+ !isset( $_GET['_success_message'] ) )
211
  {
212
  $_cfg['validate'] = 1;
213
  }
231
  }
232
  $this->form[$global_name_field] = $form;
233
  $this->field_count++;
234
+ $htmlArray[] = $this->theForm->renderElements( $form );
235
  if ( empty( $config['repetitive'] ) ) break;
236
  $count++;
237
+ } else {
238
+ if ( current_user_can('manage_options') ) {
239
+ $htmlArray[] = sprintf(
240
+ '<div id="message" class="error"><p>%s</p><p>%s</p></div>',
241
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196628627/comments#310360880
242
+ //changed render to rendering
243
+ sprintf(
244
+ __('There is a problem rendering field <strong>%s (%s)</strong>.', 'wpv-views'),
245
+ $_cfg['title'],
246
+ $_cfg['type']
247
+ ),
248
+ $field->get_error_message()
249
+ );
250
+ }
251
+ }
252
  }
253
  if ( !empty( $htmlArray ) && isset($config['repetitive']) && $config['repetitive'] ) {
254
  $_gnf = $_cfg['name'] = "{$global_name_field}[%%{$count}%%]";
258
  $this->_repetitive()->add( $config, $tpl );
259
  }
260
  }
261
+
262
  return !empty( $htmlArray ) ? $this->_tpl( $config, $htmlArray ) : '';
263
  }
264
 
387
  {
388
  $mess = $field->getTitle().' Field is required';
389
  return new WP_Error( 'wptoolset_forms', $mess,
390
+ array($field->getTitle().' Field is required') );
391
  }
392
  }
393
  }
415
  public function loadFieldClass( $type ) {
416
  $type = strtolower( $type );
417
  $class = $this->getClassFromType( $type );
418
+
419
+ /**
420
+ * try to load custom class
421
+ */
422
+ $loader = $class.'_loader';
423
+ if ( function_exists($loader) ) {
424
+ $loader();
425
+ }
426
+
427
  if ( !class_exists( $class ) ) {
428
  $file = WPTOOLSET_FORMS_ABSPATH . "/classes/class.{$type}.php";
429
  if ( file_exists( $file ) ) {
442
  return class_exists( $class ) ? $class : false;
443
  }
444
 
445
+ private function get_wpml_action($id)
446
+ {
447
+ global $iclTranslationManagement;
448
+ if (
449
+ is_object($iclTranslationManagement)
450
+ && 'TranslationManagement' == get_class($iclTranslationManagement)
451
+ && isset($iclTranslationManagement->settings['custom_fields_translation'][$id])
452
+ ) {
453
+ return $iclTranslationManagement->settings['custom_fields_translation'][$id];
454
+ }
455
+ return 0;
456
+ }
457
  }
embedded/common/toolset-forms/classes/class.image.php CHANGED
@@ -6,10 +6,6 @@ require_once 'class.file.php';
6
  *
7
  * @author Srdjan
8
  *
9
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.image.php $
10
- * $LastChangedDate: 2014-08-22 12:23:29 +0200 (Fri, 22 Aug 2014) $
11
- * $LastChangedRevision: 26350 $
12
- * $LastChangedBy: francesco $
13
  *
14
  */
15
  class WPToolset_Field_Image extends WPToolset_Field_File
@@ -19,17 +15,28 @@ class WPToolset_Field_Image extends WPToolset_Field_File
19
  $validation = $this->getValidationData();
20
  $validation = self::addTypeValidation($validation);
21
  $this->setValidationData($validation);
22
- return parent::metaform();
23
  }
24
 
25
- public static function addTypeValidation($validation) {
 
 
 
 
 
 
 
 
 
 
 
26
  $validation['extension'] = array(
27
  'args' => array(
28
  'extension',
29
- 'jpg|jpeg|gif|png|bmp|webp',
30
  ),
31
  'message' => __( 'You can add only images.', 'wpv-views' ),
32
  );
33
  return $validation;
34
- }
35
  }
6
  *
7
  * @author Srdjan
8
  *
 
 
 
 
9
  *
10
  */
11
  class WPToolset_Field_Image extends WPToolset_Field_File
15
  $validation = $this->getValidationData();
16
  $validation = self::addTypeValidation($validation);
17
  $this->setValidationData($validation);
18
+ return parent::metaform();
19
  }
20
 
21
+ public static function addTypeValidation($validation)
22
+ {
23
+ $valid_extensions = array(
24
+ 'bmp',
25
+ 'gif',
26
+ 'jpeg',
27
+ 'jpg',
28
+ 'png',
29
+ 'svg',
30
+ 'webp',
31
+ );
32
+ $valid_extensions = apply_filters( 'toolset_valid_image_extentions', $valid_extensions);
33
  $validation['extension'] = array(
34
  'args' => array(
35
  'extension',
36
+ implode('|', $valid_extensions),
37
  ),
38
  'message' => __( 'You can add only images.', 'wpv-views' ),
39
  );
40
  return $validation;
41
+ }
42
  }
embedded/common/toolset-forms/classes/class.integer.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'class.textfield.php';
3
+
4
+ /**
5
+ * Description of class
6
+ *
7
+ * @author Srdjan
8
+ */
9
+ class WPToolset_Field_Integer extends WPToolset_Field_Textfield
10
+ {
11
+
12
+ }
embedded/common/toolset-forms/classes/class.password.php CHANGED
@@ -1,10 +1,6 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/trunk/toolset-forms/classes/class.password.php $
5
- * $LastChangedDate: 2014-07-10 11:46:40 +0300 (Чт, 10 июл 2014) $
6
- * $LastChangedRevision: 24820 $
7
- * $LastChangedBy: francesco $
8
  *
9
  */
10
  require_once 'class.field_factory.php';
1
  <?php
2
  /**
3
  *
 
 
 
 
4
  *
5
  */
6
  require_once 'class.field_factory.php';
embedded/common/toolset-forms/classes/class.radios.php CHANGED
@@ -1,10 +1,6 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.radios.php $
5
- * $LastChangedDate: 2014-08-14 09:35:38 +0200 (Thu, 14 Aug 2014) $
6
- * $LastChangedRevision: 25961 $
7
- * $LastChangedBy: francesco $
8
  *
9
  */
10
  require_once 'class.field_factory.php';
@@ -30,11 +26,28 @@ class WPToolset_Field_Radios extends FieldFactory
30
  '#title' => $option['title'],
31
  '#validate' => $this->getValidationData()
32
  );
33
- if ( !is_admin() ) {// TODO maybe add a doing_ajax() check too, what if we want to load a form using AJAX?
34
- $one_option_data['#before'] = '<li class="wpt-form-item wpt-form-item-radio">';
35
- $one_option_data['#after'] = '</li>';
36
- $one_option_data['#pattern'] = '<BEFORE><PREFIX><ELEMENT><LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  /**
39
  * add default value if needed
40
  * issue: frontend, multiforms CRED
@@ -47,7 +60,15 @@ class WPToolset_Field_Radios extends FieldFactory
47
  */
48
  $options[] = $one_option_data;
49
  }
50
- $options = apply_filters( 'wpt_field_options', $options, $this->getTitle(), 'select' );
 
 
 
 
 
 
 
 
51
  /**
52
  * default_value
53
  */
@@ -67,12 +88,12 @@ class WPToolset_Field_Radios extends FieldFactory
67
  '#repetitive' => $this->isRepetitive(),
68
  '#validate' => $this->getValidationData(),
69
  );
70
-
71
  if ( !is_admin() ) {// TODO maybe add a doing_ajax() check too, what if we want to load a form using AJAX?
72
  $form_attr['#before'] = '<ul class="wpt-form-set wpt-form-set-radios wpt-form-set-radios-' . $name . '">';
73
  $form_attr['#after'] = '</ul>';
74
  }
75
-
76
  $form[] = $form_attr;
77
 
78
  return $form;
1
  <?php
2
  /**
3
  *
 
 
 
 
4
  *
5
  */
6
  require_once 'class.field_factory.php';
26
  '#title' => $option['title'],
27
  '#validate' => $this->getValidationData()
28
  );
29
+ if ( !is_admin() ) {// TODO maybe add a doing_ajax() check too, what if we want to load a form using AJAX?
30
+ $clases = array(
31
+ 'wpt-form-item',
32
+ 'wpt-form-item-radio',
33
+ 'radio-'.sanitize_title($option['title'])
34
+ );
35
+ /**
36
+ * filter: cred_checkboxes_class
37
+ * @param array $clases current array of classes
38
+ * @parem array $option current option
39
+ * @param string field type
40
+ *
41
+ * @return array
42
+ */
43
+ $clases = apply_filters( 'cred_item_li_class', $clases, $option, 'radio' );
44
+ $one_option_data['#before'] = sprintf(
45
+ '<li class="%s">',
46
+ implode(' ', $clases)
47
+ );
48
+ $one_option_data['#after'] = '</li>';
49
+ $one_option_data['#pattern'] = '<BEFORE><PREFIX><ELEMENT><LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>';
50
+ }
51
  /**
52
  * add default value if needed
53
  * issue: frontend, multiforms CRED
60
  */
61
  $options[] = $one_option_data;
62
  }
63
+ /**
64
+ * for user fields we reset title and description to avoid double
65
+ * display
66
+ */
67
+ $title = $this->getTitle();
68
+ if ( empty($title) ) {
69
+ $title = $this->getTitle(true);
70
+ }
71
+ $options = apply_filters( 'wpt_field_options', $options, $title, 'select' );
72
  /**
73
  * default_value
74
  */
88
  '#repetitive' => $this->isRepetitive(),
89
  '#validate' => $this->getValidationData(),
90
  );
91
+
92
  if ( !is_admin() ) {// TODO maybe add a doing_ajax() check too, what if we want to load a form using AJAX?
93
  $form_attr['#before'] = '<ul class="wpt-form-set wpt-form-set-radios wpt-form-set-radios-' . $name . '">';
94
  $form_attr['#after'] = '</ul>';
95
  }
96
+
97
  $form[] = $form_attr;
98
 
99
  return $form;
embedded/common/toolset-forms/classes/class.recaptcha.php CHANGED
@@ -40,20 +40,21 @@ class WPToolset_Field_Recaptcha extends WPToolset_Field_Textfield
40
  public function metaform() {
41
  $form = array();
42
 
43
- $capture = '';
44
  if ($this->pubkey || !is_admin()) {
45
  try {
46
- $capture = recaptcha_get_html($this->pubkey);
47
  } catch(Exception $e ) {
 
48
  if ( current_user_can( 'manage_options' ) ) {
49
- echo '<div class="message error">';
50
- echo 'Caught exception: ', $e->getMessage(), "\n";
51
- echo '</div>';
52
  }
 
53
  }
54
  }
55
 
56
-
57
  $form[] = array(
58
  '#type' => 'textfield',
59
  '#title' => '',
40
  public function metaform() {
41
  $form = array();
42
 
43
+ $capture = '';
44
  if ($this->pubkey || !is_admin()) {
45
  try {
46
+ $capture = recaptcha_get_html($this->pubkey,null,is_ssl());
47
  } catch(Exception $e ) {
48
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188424989/comments
49
  if ( current_user_can( 'manage_options' ) ) {
50
+ $id_field = $this->getId();
51
+ $text = 'Caught exception: '. $e->getMessage();
52
+ $capture = "<label id=\"lbl_$id_field\" class=\"wpt-form-error\">$text</label><div style=\"clear:both;\"></div>";
53
  }
54
+ //###########################################################################################
55
  }
56
  }
57
 
 
58
  $form[] = array(
59
  '#type' => 'textfield',
60
  '#title' => '',
embedded/common/toolset-forms/classes/class.repetitive.php CHANGED
@@ -2,10 +2,6 @@
2
  /*
3
  * Repetitive controller
4
  *
5
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.repetitive.php $
6
- * $LastChangedDate: 2014-07-03 09:27:50 +0200 (Thu, 03 Jul 2014) $
7
- * $LastChangedRevision: 24580 $
8
- * $LastChangedBy: juan $
9
  *
10
  * If field is repetitive
11
  * - queues repetitive CSS and JS
2
  /*
3
  * Repetitive controller
4
  *
 
 
 
 
5
  *
6
  * If field is repetitive
7
  * - queues repetitive CSS and JS
embedded/common/toolset-forms/classes/class.select.php CHANGED
@@ -1,10 +1,6 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.select.php $
5
- * $LastChangedDate: 2014-07-29 16:50:22 +0200 (Tue, 29 Jul 2014) $
6
- * $LastChangedRevision: 25428 $
7
- * $LastChangedBy: marcin $
8
  *
9
  */
10
  require_once 'class.field_factory.php';
@@ -28,7 +24,7 @@ class WPToolset_Field_Select extends FieldFactory
28
  foreach ( $data['options'] as $option ) {
29
  $one_option_data = array(
30
  '#value' => $option['value'],
31
- '#title' => $option['title'],
32
  );
33
  /**
34
  * add default value if needed
@@ -43,13 +39,32 @@ class WPToolset_Field_Select extends FieldFactory
43
  $options[] = $one_option_data;
44
  }
45
  }
46
- $options = apply_filters( 'wpt_field_options', $options, $this->getTitle(), 'select' );
 
 
 
 
 
 
 
 
 
47
  /**
48
  * default_value
49
  */
50
  if ( !empty( $value ) || $value == '0' ) {
51
  $data['default_value'] = $value;
52
  }
 
 
 
 
 
 
 
 
 
 
53
  /**
54
  * metaform
55
  */
@@ -59,8 +74,8 @@ class WPToolset_Field_Select extends FieldFactory
59
  '#description' => $this->getDescription(),
60
  '#name' => $this->getName(),
61
  '#options' => $options,
62
- '#default_value' => isset( $data['default_value'] ) ? $data['default_value'] : null,
63
- '#multiple' => array_key_exists('multiple', $attributes) && 'multiple' == $attributes['multiple'],
64
  '#validate' => $this->getValidationData(),
65
  '#class' => 'form-inline',
66
  '#repetitive' => $this->isRepetitive(),
1
  <?php
2
  /**
3
  *
 
 
 
 
4
  *
5
  */
6
  require_once 'class.field_factory.php';
24
  foreach ( $data['options'] as $option ) {
25
  $one_option_data = array(
26
  '#value' => $option['value'],
27
+ '#title' => stripslashes($option['title']),
28
  );
29
  /**
30
  * add default value if needed
39
  $options[] = $one_option_data;
40
  }
41
  }
42
+
43
+ /**
44
+ * for user fields we reset title and description to avoid double
45
+ * display
46
+ */
47
+ $title = $this->getTitle();
48
+ if ( empty($title) ) {
49
+ $title = $this->getTitle(true);
50
+ }
51
+ $options = apply_filters( 'wpt_field_options', $options, $title, 'select' );
52
  /**
53
  * default_value
54
  */
55
  if ( !empty( $value ) || $value == '0' ) {
56
  $data['default_value'] = $value;
57
  }
58
+
59
+ $is_multiselect = array_key_exists('multiple', $attributes) && 'multiple' == $attributes['multiple'];
60
+ $default_value = isset( $data['default_value'] ) ? $data['default_value'] : null;
61
+ //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/189219391/comments
62
+ if ($is_multiselect) {
63
+ $default_value = new RecursiveIteratorIterator(new RecursiveArrayIterator($default_value));
64
+ $default_value = iterator_to_array($default_value,false);
65
+ }
66
+ //##############################################################################################
67
+
68
  /**
69
  * metaform
70
  */
74
  '#description' => $this->getDescription(),
75
  '#name' => $this->getName(),
76
  '#options' => $options,
77
+ '#default_value' => $default_value,
78
+ '#multiple' => $is_multiselect,
79
  '#validate' => $this->getValidationData(),
80
  '#class' => 'form-inline',
81
  '#repetitive' => $this->isRepetitive(),
embedded/common/toolset-forms/classes/class.skype.php CHANGED
@@ -1,10 +1,6 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.skype.php $
5
- * $LastChangedDate: 2014-08-05 18:18:16 +0200 (Tue, 05 Aug 2014) $
6
- * $LastChangedRevision: 25657 $
7
- * $LastChangedBy: juan $
8
  *
9
  */
10
  require_once 'class.textfield.php';
@@ -14,29 +10,38 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
14
 
15
  protected $_defaults = array('skypename' => '', 'button_style' => 'btn2');
16
 
17
- public function init(){
18
-
19
- add_action( 'admin_footer', array($this, 'editButtonTemplate') );
20
  add_action( 'wp_footer', array($this, 'editButtonTemplate') );
21
-
22
- wp_register_script( 'wptoolset-field-skype',
23
- WPTOOLSET_FORMS_RELPATH . '/js/skype.js', array('jquery'),
24
- WPTOOLSET_FORMS_VERSION, true );
 
 
 
 
25
  wp_enqueue_script( 'wptoolset-field-skype' );
26
  add_thickbox();
27
  $translation = array('title' => esc_js( __( 'Edit Skype button', 'wpv-views' ) ) );
28
- wp_localize_script( 'wptoolset-field-skype', 'wptSkypeData',
29
- $translation );
30
-
31
  }
32
 
33
  public function enqueueStyles() {
34
-
35
  }
36
 
37
  public function metaform() {
38
  $value = wp_parse_args( $this->getValue(), $this->_defaults );
39
- $def_class='js-wpt-skypename js-wpt-cond-trigger';// What is this js-wpt-cond-trigger classname for?
 
 
 
 
 
 
40
  $form = array();
41
  $form[] = array(
42
  '#type' => 'textfield',
@@ -46,7 +51,7 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
46
  '#attributes' => array(),
47
  '#value' => $value['skypename'],
48
  '#validate' => $this->getValidationData(),
49
- '#attributes' => array('class' => $def_class), // Mark to be checked as conditional
50
  '#repetitive' => $this->isRepetitive(),
51
  );
52
  $form['style'] = array(
@@ -63,7 +68,7 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
63
  $button_element = array(
64
  '#name' => '',
65
  '#type' => 'button',
66
- '#value' => esc_attr( __( 'Edit Skype button', 'wpv-views' ) ),
67
  '#attributes' => array('class' => 'js-wpt-skype-edit-button button button-small button-secondary'),
68
  );
69
  /*
@@ -102,7 +107,7 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
102
  }
103
 
104
  public function editform( $config = null ) {
105
-
106
  }
107
 
108
  public function mediaEditor(){
@@ -111,11 +116,11 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
111
 
112
  /**
113
  * Returns HTML formatted skype button.
114
- *
115
  * @param type $skypename
116
  * @param type $template
117
  * @param type $class
118
- * @return type
119
  */
120
  function getButton( $skypename, $template = '', $class = false ) {
121
 
@@ -179,10 +184,10 @@ class WPToolset_Field_Skype extends WPToolset_Field_Textfield
179
 
180
  /**
181
  * Returns HTML formatted skype button image.
182
- *
183
  * @param type $skypename
184
  * @param type $template
185
- * @return type
186
  */
187
  public function getButtonImage( $skypename = '', $template = '', $class = '' ) {
188
 
1
  <?php
2
  /**
3
  *
 
 
 
 
4
  *
5
  */
6
  require_once 'class.textfield.php';
10
 
11
  protected $_defaults = array('skypename' => '', 'button_style' => 'btn2');
12
 
13
+ public function init()
14
+ {
15
+ add_action( 'admin_footer', array($this, 'editButtonTemplate') );
16
  add_action( 'wp_footer', array($this, 'editButtonTemplate') );
17
+
18
+ wp_register_script(
19
+ 'wptoolset-field-skype',
20
+ WPTOOLSET_FORMS_RELPATH . '/js/skype.js',
21
+ array('jquery'),
22
+ WPTOOLSET_FORMS_VERSION,
23
+ true
24
+ );
25
  wp_enqueue_script( 'wptoolset-field-skype' );
26
  add_thickbox();
27
  $translation = array('title' => esc_js( __( 'Edit Skype button', 'wpv-views' ) ) );
28
+ wp_localize_script( 'wptoolset-field-skype', 'wptSkypeData', $translation );
29
+ $this->set_placeholder_as_attribute();
 
30
  }
31
 
32
  public function enqueueStyles() {
33
+
34
  }
35
 
36
  public function metaform() {
37
  $value = wp_parse_args( $this->getValue(), $this->_defaults );
38
+ $attributes = $this->getAttr();
39
+ if ( isset($attributes['class'] ) ) {
40
+ $attributes['class'] .= ' ';
41
+ } else {
42
+ $attributes['class'] = '';
43
+ }
44
+ $attributes['class'] = 'js-wpt-skypename js-wpt-cond-trigger';// What is this js-wpt-cond-trigger classname for?
45
  $form = array();
46
  $form[] = array(
47
  '#type' => 'textfield',
51
  '#attributes' => array(),
52
  '#value' => $value['skypename'],
53
  '#validate' => $this->getValidationData(),
54
+ '#attributes' => $attributes,
55
  '#repetitive' => $this->isRepetitive(),
56
  );
57
  $form['style'] = array(
68
  $button_element = array(
69
  '#name' => '',
70
  '#type' => 'button',
71
+ '#value' => esc_attr( __( 'Edit', 'wpv-views' ) )." Skype button",
72
  '#attributes' => array('class' => 'js-wpt-skype-edit-button button button-small button-secondary'),
73
  );
74
  /*
107
  }
108
 
109
  public function editform( $config = null ) {
110
+
111
  }
112
 
113
  public function mediaEditor(){
116
 
117
  /**
118
  * Returns HTML formatted skype button.
119
+ *
120
  * @param type $skypename
121
  * @param type $template
122
  * @param type $class
123
+ * @return type
124
  */
125
  function getButton( $skypename, $template = '', $class = false ) {
126
 
184
 
185
  /**
186
  * Returns HTML formatted skype button image.
187
+ *
188
  * @param type $skypename
189
  * @param type $template
190
+ * @return type
191
  */
192
  public function getButtonImage( $skypename = '', $template = '', $class = '' ) {
193
 
embedded/common/toolset-forms/classes/class.submit.php CHANGED
@@ -1,29 +1,37 @@
1
- <?php
2
- require_once 'class.textfield.php';
3
-
4
- /**
5
- * Description of class
6
- *
7
- * @author Franko
8
- */
9
- class WPToolset_Field_Submit extends WPToolset_Field_Textfield
10
- {
11
-
12
- public function metaform() {
13
- $metaform = array();
14
- $metaform[] = array(
15
- '#type' => 'submit',
16
- '#title' => $this->getTitle(),
17
- '#description' => $this->getDescription(),
18
- '#name' => $this->getName(),
19
- '#value' => $this->getValue(),
20
- '#validate' => $this->getValidationData()
21
- );
22
- if ( array_key_exists( 'use_bootstrap', $this->_data ) && $this->_data['use_bootstrap'] ) {
23
- $metaform[0]['#attributes']['class'] = 'btn btn-primary';
24
- }
25
- $this->set_metaform($metaform);
26
- return $metaform;
27
- }
28
-
29
- }
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ *
5
+ */
6
+ require_once 'class.textfield.php';
7
+
8
+ class WPToolset_Field_Submit extends WPToolset_Field_Textfield
9
+ {
10
+
11
+ public function metaform()
12
+ {
13
+ $attributes = $this->getAttr();
14
+
15
+ $metaform = array();
16
+ $metaform[] = array(
17
+ '#type' => 'submit',
18
+ '#title' => $this->getTitle(),
19
+ '#description' => $this->getDescription(),
20
+ '#name' => $this->getName(),
21
+ '#value' => esc_attr(__($this->getValue(), 'wpv-views')),
22
+ '#validate' => $this->getValidationData(),
23
+ '#attributes' => array(
24
+ 'class' => '',
25
+ ),
26
+ );
27
+ if (array_key_exists( 'class', $attributes )) {
28
+ $metaform[0]['#attributes']['class'] = $attributes['class'];
29
+ }
30
+ if ( array_key_exists( 'use_bootstrap', $this->_data ) && $this->_data['use_bootstrap'] ) {
31
+ $metaform[0]['#attributes']['class'] .= ' btn btn-primary';
32
+ }
33
+ $this->set_metaform($metaform);
34
+ return $metaform;
35
+ }
36
+
37
+ }
embedded/common/toolset-forms/classes/class.taxonomy.php CHANGED
@@ -2,10 +2,6 @@
2
 
3
  /**
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.taxonomy.php $
6
- * $LastChangedDate: 2015-06-15 08:18:54 +0000 (Mon, 15 Jun 2015) $
7
- * $LastChangedRevision: 1180956 $
8
- * $LastChangedBy: iworks $
9
  *
10
  */
11
 
@@ -26,40 +22,15 @@ class WPToolset_Field_Taxonomy extends WPToolset_Field_Textfield
26
  $this->objValues[$term->slug] = $term;
27
  $i++;
28
  }
29
-
30
- wp_register_script( 'wptoolset-jquery-autocompleter',
31
- WPTOOLSET_FORMS_RELPATH . '/js/jquery.autocomplete.js',
32
- array('jquery'), WPTOOLSET_FORMS_VERSION, true );
33
-
34
- wp_register_style('wptoolset-autocompleter', WPTOOLSET_FORMS_RELPATH.'/css/autocompleter.css');
35
- wp_enqueue_script('wptoolset-jquery-autocompleter');
36
  add_action( 'wp_footer', array($this, 'javascript_autocompleter') );
37
  }
38
 
39
  public function javascript_autocompleter() {
40
- $autosubmit = 'function onSelectItem(row)
41
- {
42
- jQuery("input#'.$this->getName().'").focus();
43
- }';
44
- $extra = '
45
- function formatItem(row) {
46
- return row[0];
47
- }
48
- function formatItem2(row) {
49
- if(row.length == 3){
50
- var attr = "attr=\"" + row[2] + "\"";
51
- } else {
52
- attr = "";
53
- }
54
- return "<span "+attr+">" + row[1] + " matches</span>" + row[0];
55
- }';
56
- $results = 1;
57
  echo '<script type="text/javascript">
58
  jQuery(document).ready(function() {
59
  initTaxonomies("'. $this->values .'", "'.$this->getName().'", "'.WPTOOLSET_FORMS_RELPATH.'", "'.$this->_nameField.'");
60
  });
61
- '.$autosubmit.'
62
- '.$extra.'
63
  </script>';
64
  }
65
 
@@ -104,7 +75,7 @@ class WPToolset_Field_Taxonomy extends WPToolset_Field_Textfield
104
  '#title' => '',
105
  '#description' => '',
106
  '#name' => "new_tax_button_".$taxonomy,
107
- '#value' => esc_attr( $attributes['add_text'] ),
108
  '#attributes' => array(
109
  'class' => $use_bootstrap ? 'btn btn-default wpt-taxonomy-add-new js-wpt-taxonomy-add-new' : 'wpt-taxonomy-add-new js-wpt-taxonomy-add-new',
110
  'data-taxonomy' => $taxonomy,
@@ -132,12 +103,12 @@ class WPToolset_Field_Taxonomy extends WPToolset_Field_Textfield
132
  '#title' => '',
133
  '#description' => '',
134
  '#name' => "sh_".$taxonomy,
135
- '#value' => esc_attr( $attributes['show_popular_text'] ),
136
  '#attributes' => array(
137
  'class' => $use_bootstrap ? 'btn btn-default popular wpt-taxonomy-popular-show-hide js-wpt-taxonomy-popular-show-hide' : 'popular wpt-taxonomy-popular-show-hide js-wpt-taxonomy-popular-show-hide',
138
  'data-taxonomy' => $this->getName(),
139
- 'data-show-popular-text' => esc_attr( $attributes['show_popular_text'] ),
140
- 'data-hide-popular-text' => esc_attr( $attributes['hide_popular_text'] ),
141
  'data-after-selector' => 'js-show-popular-after',
142
  'style' => $show ? '' : 'display:none;'
143
  ),
@@ -222,15 +193,18 @@ class WPToolset_Field_Taxonomy extends WPToolset_Field_Textfield
222
  );
223
  }
224
 
225
- $style = '';
226
  foreach($terms as $term) {
 
227
  if ( $add_sizes ) {
228
- $font_size = ( ( $term->count - $min ) * 10 ) / ( $max - $min ) + 5;
229
- $style = sprintf( ' style="font-size:1.%dem;"', $font_size );
230
  }
231
- _pre($term);
 
 
232
  $content .= sprintf(
233
- '<a href="#" class="wpt-taxonomy-popular-add js-wpt-taxonomy-popular-add" data-slug="%s" data-name="%s" data-taxonomy="%s"%s>%s</a> ',
 
234
  $term->slug,
235
  $term->name,
236
  $this->getName(),
2
 
3
  /**
4
  *
 
 
 
 
5
  *
6
  */
7
 
22
  $this->objValues[$term->slug] = $term;
23
  $i++;
24
  }
25
+
 
 
 
 
 
 
26
  add_action( 'wp_footer', array($this, 'javascript_autocompleter') );
27
  }
28
 
29
  public function javascript_autocompleter() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  echo '<script type="text/javascript">
31
  jQuery(document).ready(function() {
32
  initTaxonomies("'. $this->values .'", "'.$this->getName().'", "'.WPTOOLSET_FORMS_RELPATH.'", "'.$this->_nameField.'");
33
  });
 
 
34
  </script>';
35
  }
36
 
75
  '#title' => '',
76
  '#description' => '',
77
  '#name' => "new_tax_button_".$taxonomy,
78
+ '#value' => apply_filters('toolset_button_add_text', esc_attr( $attributes['add_text'] )),
79
  '#attributes' => array(
80
  'class' => $use_bootstrap ? 'btn btn-default wpt-taxonomy-add-new js-wpt-taxonomy-add-new' : 'wpt-taxonomy-add-new js-wpt-taxonomy-add-new',
81
  'data-taxonomy' => $taxonomy,
103
  '#title' => '',
104
  '#description' => '',
105
  '#name' => "sh_".$taxonomy,
106
+ '#value' => apply_filters('toolset_button_show_popular_text', esc_attr( $attributes['show_popular_text'] )),
107
  '#attributes' => array(
108
  'class' => $use_bootstrap ? 'btn btn-default popular wpt-taxonomy-popular-show-hide js-wpt-taxonomy-popular-show-hide' : 'popular wpt-taxonomy-popular-show-hide js-wpt-taxonomy-popular-show-hide',
109
  'data-taxonomy' => $this->getName(),
110
+ 'data-show-popular-text' => apply_filters('toolset_button_show_popular_text', esc_attr( $attributes['show_popular_text'] )),
111
+ 'data-hide-popular-text' => apply_filters('toolset_button_hide_popular_text', esc_attr( $attributes['hide_popular_text'] )),
112
  'data-after-selector' => 'js-show-popular-after',
113
  'style' => $show ? '' : 'display:none;'
114
  ),
193
  );
194
  }
195
 
 
196
  foreach($terms as $term) {
197
+ $style = '';
198
  if ( $add_sizes ) {
199
+ $font_size = ( ( $term->count - $min ) * 10 ) / ( $max - $min ) + 8;
200
+ $style = sprintf( ' style="font-size:%fem;"', $font_size/10 );
201
  }
202
+ $clases = array('wpt-taxonomy-popular-add', 'js-wpt-taxonomy-popular-add');
203
+ $clases[] = 'tax-'.$term->slug;
204
+ $clases[] = 'taxonomy-'.$this->getName().'-'.$term->term_id;
205
  $content .= sprintf(
206
+ '<a href="#" class="%s" data-slug="%s" data-name="%s" data-taxonomy="%s"%s>%s</a> ',
207
+ implode(' ', $clases ),
208
  $term->slug,
209
  $term->name,
210
  $this->getName(),
embedded/common/toolset-forms/classes/class.taxonomyhierarchical.php CHANGED
@@ -1,25 +1,20 @@
1
  <?php
 
2
  /**
3
  *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.taxonomyhierarchical.php $
5
- * $LastChangedDate: 2015-06-15 08:18:54 +0000 (Mon, 15 Jun 2015) $
6
- * $LastChangedRevision: 1180956 $
7
- * $LastChangedBy: iworks $
8
  *
9
  */
10
-
11
  include_once 'class.textfield.php';
12
 
13
- class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
14
- {
15
  protected $child;
16
  protected $names;
17
  protected $values = array();
18
  protected $valuesId = array();
19
  protected $objValues;
20
 
21
- public function init()
22
- {
23
  global $post;
24
 
25
  $this->objValues = array();
@@ -31,44 +26,43 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
31
  $this->objValues[$term->slug] = $term;
32
  }
33
  }
34
-
35
- $all = $this->buildTerms(get_terms($this->getName(),array('hide_empty'=>0,'fields'=>'all')));
36
 
37
-
38
-
39
- $childs=array();
40
- $names=array();
 
 
41
  foreach ($all as $term) {
42
- $names[$term['term_id']]=$term['name'];
43
  if (!isset($childs[$term['parent']]) || !is_array($childs[$term['parent']]))
44
- $childs[$term['parent']]=array();
45
- $childs[$term['parent']][]=$term['term_id'];
46
  }
47
 
48
  // ksort($childs);
49
-
50
  $this->childs = $childs;
51
  $this->names = $names;
52
  }
53
 
54
- public function enqueueScripts()
55
- {
56
  }
57
 
58
- public function enqueueStyles()
59
- {
60
  }
61
 
62
- public function metaform()
63
- {
64
- $use_bootstrap = array_key_exists( 'use_bootstrap', $this->_data ) && $this->_data['use_bootstrap'];
65
  $attributes = $this->getAttr();
66
- $taxname = $this->getName();
67
  $res = '';
68
  $metaform = array();
69
  $build_what = '';
70
-
71
- if ( array_key_exists( 'display', $this->_data ) && 'select' == $this->_data['display'] ) {
72
  $metaform = $this->buildSelect();
73
  $build_what = 'select';
74
  } else {
@@ -76,15 +70,14 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
76
  $this->set_metaform($res);
77
  $build_what = 'checkboxes';
78
  }
79
-
80
- /**
81
- * TODO
82
- *
83
- * Use this to get the taxonomy labels for the "Add new" event
84
- *
85
- * $taxobject = get_taxonomy( $taxname );
86
- */
87
-
88
  /**
89
  * "Add new" button
90
  */
@@ -92,48 +85,47 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
92
  '#type' => 'button',
93
  '#title' => '',
94
  '#description' => '',
95
- '#name' => "btn_".$taxname,
96
- '#value' => esc_attr( $attributes['add_new_text'] ),
97
  '#attributes' => array(
98
  'style' => 'display:none;',
99
  'data-taxonomy' => $taxname,
100
  'data-build_what' => $build_what,
101
- 'data-after-selector' => 'js-wpt-hierarchical-taxonomy-add-new-' . $taxname,
102
- 'data-close' => esc_attr( __( 'Cancel', 'wpv-views' ) ),// TODO adjust the button value depending on open/close action
103
- 'class' => $use_bootstrap? 'btn btn-default wpt-hierarchical-taxonomy-add-new-show-hide js-wpt-hierarchical-taxonomy-add-new-show-hide' : 'wpt-hierarchical-taxonomy-add-new-show-hide js-wpt-hierarchical-taxonomy-add-new-show-hide',
 
104
  ),
105
-
106
  '#validate' => $this->getValidationData(),
107
  );
108
 
109
  // Input for new taxonomy
110
-
111
- if ( $use_bootstrap ) {
112
- $container = '<div style="display:none" class="form-group wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new-' . $taxname . '" data-taxonomy="' . $taxname . '">';
113
- } else {
114
- $container = '<div style="display:none" class="wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new-' . $taxname . '" data-taxonomy="' . $taxname . '">';
115
- }
116
-
117
- /**
118
- * The textfield input
119
- */
120
  $metaform[] = array(
121
  '#type' => 'textfield',
122
  '#title' => '',
123
  '#description' => '',
124
- '#name' => "new_tax_text_".$taxname,
125
  '#value' => '',
126
  '#attributes' => array(
127
  'data-taxonomy' => $taxname,
128
- 'data-taxtype' => 'hierarchical',
129
- 'class' => $use_bootstrap ? 'inline wpt-new-taxonomy-title js-wpt-new-taxonomy-title' : 'wpt-new-taxonomy-title js-wpt-new-taxonomy-title',
130
  ),
131
  '#validate' => $this->getValidationData(),
132
  '#before' => $container,
133
-
134
  );
135
-
136
- /**
137
  * The select for parent
138
  */
139
  $metaform[] = array(
@@ -145,13 +137,12 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
145
  )),
146
  '#default_value' => 0,
147
  '#description' => '',
148
- '#name' => "new_tax_select_".$taxname,
149
  '#attributes' => array(
150
  'data-parent-text' => $attributes['parent_text'],
151
  'data-taxonomy' => $taxname,
152
- 'class' => 'js-taxonomy-parent'
153
  ),
154
-
155
  '#validate' => $this->getValidationData(),
156
  );
157
 
@@ -162,49 +153,44 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
162
  '#type' => 'button',
163
  '#title' => '',
164
  '#description' => '',
165
- '#name' => "new_tax_button_".$taxname,
166
- '#value' => esc_attr( $attributes['add_text'] ),
167
  '#attributes' => array(
168
  'data-taxonomy' => $taxname,
169
  'data-build_what' => $build_what,
170
- 'class' => $use_bootstrap ? 'btn btn-default wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new' : 'wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new',
171
  ),
172
-
173
  '#validate' => $this->getValidationData(),
174
- '#after' => '</div>',
175
- );
176
-
177
  return $metaform;
178
-
179
  }
180
 
181
- private function buildTerms($obj_terms)
182
- {
183
- $tax_terms=array();
184
  foreach ($obj_terms as $term) {
185
- $tax_terms[]=array(
186
- 'name'=>$term->name,
187
- 'count'=>$term->count,
188
- 'parent'=>$term->parent,
189
- 'term_taxonomy_id'=>$term->term_taxonomy_id,
190
- 'term_id'=>$term->term_id
191
  );
192
  }
193
  return $tax_terms;
194
  }
195
 
196
- private function buildSelect()
197
- {
198
  $attributes = $this->getAttr();
199
-
200
  $multiple = !isset($attributes['single_select']) || !$attributes['single_select'];
201
-
202
  $curr_options = $this->getOptions();
203
  $values = $this->valuesId;
204
  $options = array();
205
- if( $curr_options )
206
- {
207
- foreach ($curr_options as $name=>$data) {
208
  $option = array(
209
  '#value' => $name,
210
  '#title' => $data['value'],
@@ -222,7 +208,7 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
222
  * default_value
223
  */
224
  $default_value = null;
225
- if ( count( $this->valuesId) ) {
226
  $default_value = $this->valuesId[0];
227
  }
228
  /**
@@ -235,16 +221,16 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
235
  '#description' => $this->getDescription(),
236
  '#name' => $this->getName() . '[]',
237
  '#options' => $options,
238
- '#default_value' => isset( $data['default_value'] ) && !empty( $data['default_value'] ) ? $data['default_value'] : $default_value,
239
  '#validate' => $this->getValidationData(),
240
  '#class' => 'form-inline',
241
  '#repetitive' => $this->isRepetitive(),
242
  );
243
-
244
  if ($multiple) {
245
  $select['#attributes'] = array('multiple' => 'multiple');
246
  }
247
-
248
  if (count($options) == 0) {
249
  if (isset($select['#attributes'])) {
250
  $select['#attributes']['style'] = 'display:none';
@@ -257,18 +243,17 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
257
  return $form;
258
  }
259
 
260
- private function getOptions($index = 0, $level = 0, $parent = -1)
261
- {
262
- if ( !isset($this->childs[$index]) || empty( $this->childs[$index] ) ) {
263
  return;
264
  }
265
  $options = array();
266
 
267
- foreach( $this->childs[$index] as $one ) {
268
- $options[$one] = array('value' => sprintf('%s%s', str_repeat('&nbsp;', 2*$level ), $this->names[$one]),
269
- 'parent' => $parent);
270
- if ( isset($this->childs[$one]) && count($this->childs[$one])) {
271
- foreach( $this->getOptions( $one, $level + 1, $one ) as $id => $data ) {
272
  $options[$id] = $data;
273
  }
274
  }
@@ -276,65 +261,78 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield
276
  return $options;
277
  }
278
 
279
- private function buildCheckboxes( $index, &$childs, &$names, &$metaform, $level = 0, $parent = -1 )
280
- {
281
  if (isset($childs[$index])) {
282
- $level_count = count( $childs[$index] );
283
- foreach ( $childs[$index] as $tkey => $tid ) {
284
  $name = $names[$tid];
285
  /**
286
  * check for "checked"
287
  */
288
  $default_value = false;
289
- if ( isset( $this->valuesId ) && is_array( $this->valuesId ) && !empty($this->valuesId)) {
290
- $default_value = in_array( $tid, $this->valuesId );
291
- } else if ( is_array( $this->getValue() ) ) {
292
- $default_value = in_array( $tid, $this->getValue() );
293
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
294
  $item = array(
295
- '#type' => 'checkbox',
296
- '#title' => $names[$tid],
297
- '#description' => '',
298
- '#name' => $this->getName()."[]",
299
- '#value' => $tid,
300
- '#default_value' => $default_value,
301
- '#validate' => $this->getValidationData(),
302
- '#before' => '<li>',
303
- '#after' => '</li>',
304
- '#attributes' => array(
305
- 'data-parent' => $parent
306
- ),
307
- '#pattern' => '<BEFORE><PREFIX><ELEMENT><LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>'
308
- );
309
-
310
- if ( $tkey == 0 ) {
 
311
  if ($level > 0) {
312
- $item['#before'] = '<li><ul class="wpt-form-set-children wpt-form-set-children-level-' . $level . '" data-level="' . $level . '"><li>';
313
- } else {
314
- $item['#before'] = '<ul class="wpt-form-set wpt-form-set-checkboxes wpt-form-set-checkboxes-' . $this->getName() . '" data-level="0"><li>';
315
  }
316
  }
317
- if ( $tkey == ( $level_count - 1 ) ) {
318
  $item['#after'] = '</li>';
319
  }
320
-
321
  $metaform[] = $item;
322
 
323
- if ( isset( $childs[$tid] ) ) {
324
- $metaform = $this->buildCheckboxes( $tid, $childs, $names, $metaform, $level + 1, $tid );
325
  }
326
-
327
  }
328
  }
329
-
330
  if (count($metaform)) {
331
  if ($level == 0) {
332
  $metaform[count($metaform) - 1]['#after'] .= '</ul>';
333
- } else {
334
  $metaform[count($metaform) - 1]['#after'] .= '</ul></li>';
335
  }
336
  }
337
-
338
  return $metaform;
339
  }
 
340
  }
1
  <?php
2
+
3
  /**
4
  *
 
 
 
 
5
  *
6
  */
 
7
  include_once 'class.textfield.php';
8
 
9
+ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield {
10
+
11
  protected $child;
12
  protected $names;
13
  protected $values = array();
14
  protected $valuesId = array();
15
  protected $objValues;
16
 
17
+ public function init() {
 
18
  global $post;
19
 
20
  $this->objValues = array();
26
  $this->objValues[$term->slug] = $term;
27
  }
28
  }
 
 
29
 
30
+ $all = $this->buildTerms(get_terms($this->getName(), array('hide_empty' => 0, 'fields' => 'all')));
31
+
32
+
33
+
34
+ $childs = array();
35
+ $names = array();
36
  foreach ($all as $term) {
37
+ $names[$term['term_id']] = $term['name'];
38
  if (!isset($childs[$term['parent']]) || !is_array($childs[$term['parent']]))
39
+ $childs[$term['parent']] = array();
40
+ $childs[$term['parent']][] = $term['term_id'];
41
  }
42
 
43
  // ksort($childs);
44
+
45
  $this->childs = $childs;
46
  $this->names = $names;
47
  }
48
 
49
+ public function enqueueScripts() {
50
+
51
  }
52
 
53
+ public function enqueueStyles() {
54
+
55
  }
56
 
57
+ public function metaform() {
58
+ $use_bootstrap = array_key_exists('use_bootstrap', $this->_data) && $this->_data['use_bootstrap'];
 
59
  $attributes = $this->getAttr();
60
+ $taxname = $this->getName();
61
  $res = '';
62
  $metaform = array();
63
  $build_what = '';
64
+
65
+ if (array_key_exists('display', $this->_data) && 'select' == $this->_data['display']) {
66
  $metaform = $this->buildSelect();
67
  $build_what = 'select';
68
  } else {
70
  $this->set_metaform($res);
71
  $build_what = 'checkboxes';
72
  }
73
+
74
+ /**
75
+ * TODO
76
+ *
77
+ * Use this to get the taxonomy labels for the "Add new" event
78
+ *
79
+ * $taxobject = get_taxonomy( $taxname );
80
+ */
 
81
  /**
82
  * "Add new" button
83
  */
85
  '#type' => 'button',
86
  '#title' => '',
87
  '#description' => '',
88
+ '#name' => "btn_" . $taxname,
89
+ '#value' => apply_filters('toolset_button_add_new_text', esc_attr($attributes['add_new_text'])),
90
  '#attributes' => array(
91
  'style' => 'display:none;',
92
  'data-taxonomy' => $taxname,
93
  'data-build_what' => $build_what,
94
+ 'data-after-selector' => 'js-wpt-hierarchical-taxonomy-add-new-' . $taxname,
95
+ 'data-open' => apply_filters('toolset_button_add_new_text', esc_attr($attributes['add_new_text'])),
96
+ 'data-close' => apply_filters('toolset_button_cancel_text', esc_attr(__('Cancel', 'wpv-views'))), // TODO adjust the button value depending on open/close action
97
+ 'class' => $use_bootstrap ? 'btn btn-default wpt-hierarchical-taxonomy-add-new-show-hide js-wpt-hierarchical-taxonomy-add-new-show-hide' : 'wpt-hierarchical-taxonomy-add-new-show-hide js-wpt-hierarchical-taxonomy-add-new-show-hide',
98
  ),
 
99
  '#validate' => $this->getValidationData(),
100
  );
101
 
102
  // Input for new taxonomy
103
+
104
+ if ($use_bootstrap) {
105
+ $container = '<div style="display:none" class="form-group wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new-' . $taxname . '" data-taxonomy="' . $taxname . '">';
106
+ } else {
107
+ $container = '<div style="display:none" class="wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new-' . $taxname . '" data-taxonomy="' . $taxname . '">';
108
+ }
109
+
110
+ /**
111
+ * The textfield input
112
+ */
113
  $metaform[] = array(
114
  '#type' => 'textfield',
115
  '#title' => '',
116
  '#description' => '',
117
+ '#name' => "new_tax_text_" . $taxname,
118
  '#value' => '',
119
  '#attributes' => array(
120
  'data-taxonomy' => $taxname,
121
+ 'data-taxtype' => 'hierarchical',
122
+ 'class' => $use_bootstrap ? 'inline wpt-new-taxonomy-title js-wpt-new-taxonomy-title' : 'wpt-new-taxonomy-title js-wpt-new-taxonomy-title',
123
  ),
124
  '#validate' => $this->getValidationData(),
125
  '#before' => $container,
 
126
  );
127
+
128
+ /**
129
  * The select for parent
130
  */
131
  $metaform[] = array(
137
  )),
138
  '#default_value' => 0,
139
  '#description' => '',
140
+ '#name' => "new_tax_select_" . $taxname,
141
  '#attributes' => array(
142
  'data-parent-text' => $attributes['parent_text'],
143
  'data-taxonomy' => $taxname,
144
+ 'class' => 'js-taxonomy-parent wpt-taxonomy-parent'
145
  ),
 
146
  '#validate' => $this->getValidationData(),
147
  );
148
 
153
  '#type' => 'button',
154
  '#title' => '',
155
  '#description' => '',
156
+ '#name' => "new_tax_button_" . $taxname,
157
+ '#value' => apply_filters('toolset_button_add_text', esc_attr($attributes['add_text'])),
158
  '#attributes' => array(
159
  'data-taxonomy' => $taxname,
160
  'data-build_what' => $build_what,
161
+ 'class' => $use_bootstrap ? 'btn btn-default wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new' : 'wpt-hierarchical-taxonomy-add-new js-wpt-hierarchical-taxonomy-add-new',
162
  ),
 
163
  '#validate' => $this->getValidationData(),
164
+ '#after' => '</div>',
165
+ );
166
+
167
  return $metaform;
 
168
  }
169
 
170
+ private function buildTerms($obj_terms) {
171
+ $tax_terms = array();
 
172
  foreach ($obj_terms as $term) {
173
+ $tax_terms[] = array(
174
+ 'name' => $term->name,
175
+ 'count' => $term->count,
176
+ 'parent' => $term->parent,
177
+ 'term_taxonomy_id' => $term->term_taxonomy_id,
178
+ 'term_id' => $term->term_id
179
  );
180
  }
181
  return $tax_terms;
182
  }
183
 
184
+ private function buildSelect() {
 
185
  $attributes = $this->getAttr();
186
+
187
  $multiple = !isset($attributes['single_select']) || !$attributes['single_select'];
188
+
189
  $curr_options = $this->getOptions();
190
  $values = $this->valuesId;
191
  $options = array();
192
+ if ($curr_options) {
193
+ foreach ($curr_options as $name => $data) {
 
194
  $option = array(
195
  '#value' => $name,
196
  '#title' => $data['value'],
208
  * default_value
209
  */
210
  $default_value = null;
211
+ if (count($this->valuesId)) {
212
  $default_value = $this->valuesId[0];
213
  }
214
  /**
221
  '#description' => $this->getDescription(),
222
  '#name' => $this->getName() . '[]',
223
  '#options' => $options,
224
+ '#default_value' => isset($data['default_value']) && !empty($data['default_value']) ? $data['default_value'] : $default_value,
225
  '#validate' => $this->getValidationData(),
226
  '#class' => 'form-inline',
227
  '#repetitive' => $this->isRepetitive(),
228
  );
229
+
230
  if ($multiple) {
231
  $select['#attributes'] = array('multiple' => 'multiple');
232
  }
233
+
234
  if (count($options) == 0) {
235
  if (isset($select['#attributes'])) {
236
  $select['#attributes']['style'] = 'display:none';
243
  return $form;
244
  }
245
 
246
+ private function getOptions($index = 0, $level = 0, $parent = -1) {
247
+ if (!isset($this->childs[$index]) || empty($this->childs[$index])) {
 
248
  return;
249
  }
250
  $options = array();
251
 
252
+ foreach ($this->childs[$index] as $one) {
253
+ $options[$one] = array('value' => sprintf('%s%s', str_repeat('&nbsp;', 2 * $level), $this->names[$one]),
254
+ 'parent' => $parent);
255
+ if (isset($this->childs[$one]) && count($this->childs[$one])) {
256
+ foreach ($this->getOptions($one, $level + 1, $one) as $id => $data) {
257
  $options[$id] = $data;
258
  }
259
  }
261
  return $options;
262
  }
263
 
264
+ private function buildCheckboxes($index, &$childs, &$names, &$metaform, $level = 0, $parent = -1) {
 
265
  if (isset($childs[$index])) {
266
+ $level_count = count($childs[$index]);
267
+ foreach ($childs[$index] as $tkey => $tid) {
268
  $name = $names[$tid];
269
  /**
270
  * check for "checked"
271
  */
272
  $default_value = false;
273
+ if (isset($this->valuesId) && is_array($this->valuesId) && !empty($this->valuesId)) {
274
+ $default_value = in_array($tid, $this->valuesId);
275
+ } else if (is_array($this->getValue())) {
276
+ $default_value = in_array($tid, $this->getValue());
277
  }
278
+ $clases = array();
279
+ $clases[] = 'tax-' . sanitize_title($names[$tid]);
280
+ $clases[] = 'tax-' . $this->_data['name'] . '-' . $tid;
281
+ /**
282
+ * filter: cred_checkboxes_class
283
+ * @param array $clases current array of classes
284
+ * @parem array $option current option
285
+ * @param string field type
286
+ *
287
+ * @return array
288
+ */
289
+ $clases = apply_filters('cred_item_li_class', $clases, array('id' => $tid, 'name' => $name), 'taxonomyhierarchical');
290
+
291
  $item = array(
292
+ '#type' => 'checkbox',
293
+ '#title' => $names[$tid],
294
+ '#description' => '',
295
+ '#name' => $this->getName() . "[]",
296
+ '#value' => $tid,
297
+ '#default_value' => $default_value,
298
+ '#validate' => $this->getValidationData(),
299
+ '#before' => sprintf('<li class="%s">', implode(' ', $clases)),
300
+ '#after' => '</li>',
301
+ '#attributes' => array(
302
+ 'data-parent' => $parent,
303
+ 'data-value' => $names[$tid]
304
+ ),
305
+ '#pattern' => '<BEFORE><PREFIX><ELEMENT><LABEL><ERROR><SUFFIX><DESCRIPTION><AFTER>',
306
+ );
307
+
308
+ if ($tkey == 0) {
309
  if ($level > 0) {
310
+ $item['#before'] = '<li class="tax-children-of-' . $parent . '"><ul class="wpt-form-set-children wpt-form-set-children-level-' . $level . '" data-level="' . $level . '">' . $item['#before'];
311
+ } else {
312
+ $item['#before'] = '<ul class="wpt-form-set wpt-form-set-checkboxes wpt-form-set-checkboxes-' . $this->getName() . '" data-level="0">' . $item['#before'];
313
  }
314
  }
315
+ if ($tkey == ( $level_count - 1 )) {
316
  $item['#after'] = '</li>';
317
  }
318
+
319
  $metaform[] = $item;
320
 
321
+ if (isset($childs[$tid])) {
322
+ $metaform = $this->buildCheckboxes($tid, $childs, $names, $metaform, $level + 1, $tid);
323
  }
 
324
  }
325
  }
326
+
327
  if (count($metaform)) {
328
  if ($level == 0) {
329
  $metaform[count($metaform) - 1]['#after'] .= '</ul>';
330
+ } else {
331
  $metaform[count($metaform) - 1]['#after'] .= '</ul></li>';
332
  }
333
  }
334
+
335
  return $metaform;
336
  }
337
+
338
  }
embedded/common/toolset-forms/classes/class.textarea.php CHANGED
@@ -1,10 +1,6 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.textarea.php $
5
- * $LastChangedDate: 2014-07-10 10:46:40 +0200 (Thu, 10 Jul 2014) $
6
- * $LastChangedRevision: 24820 $
7
- * $LastChangedBy: francesco $
8
  *
9
  */
10
  require_once 'class.field_factory.php';
1
  <?php
2
  /**
3
  *
 
 
 
 
4
  *
5
  */
6
  require_once 'class.field_factory.php';
embedded/common/toolset-forms/classes/class.textfield.php CHANGED
@@ -1,10 +1,6 @@
1
  <?php
2
  /**
3
  *
4
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.textfield.php $
5
- * $LastChangedDate: 2014-07-09 10:26:51 +0200 (Wed, 09 Jul 2014) $
6
- * $LastChangedRevision: 24777 $
7
- * $LastChangedBy: juan $
8
  *
9
  */
10
  require_once "class.field_factory.php";
@@ -22,8 +18,6 @@ class WPToolset_Field_Textfield extends FieldFactory
22
  {
23
  public function metaform()
24
  {
25
- $attributes = $this->getAttr();
26
-
27
  $metaform = array();
28
  $metaform[] = array(
29
  '#type' => 'textfield',
@@ -33,7 +27,8 @@ class WPToolset_Field_Textfield extends FieldFactory
33
  '#value' => $this->getValue(),
34
  '#validate' => $this->getValidationData(),
35
  '#repetitive' => $this->isRepetitive(),
36
- '#attributes' => $attributes,
 
37
  );
38
  return $metaform;
39
  }
1
  <?php
2
  /**
3
  *
 
 
 
 
4
  *
5
  */
6
  require_once "class.field_factory.php";
18
  {
19
  public function metaform()
20
  {
 
 
21
  $metaform = array();
22
  $metaform[] = array(
23
  '#type' => 'textfield',
27
  '#value' => $this->getValue(),
28
  '#validate' => $this->getValidationData(),
29
  '#repetitive' => $this->isRepetitive(),
30
+ '#attributes' => $this->getAttr(),
31
+ 'wpml_action' => $this->getWPMLAction(),
32
  );
33
  return $metaform;
34
  }
embedded/common/toolset-forms/classes/class.types.php CHANGED
@@ -2,10 +2,6 @@
2
  /**
3
  * Types fields specific
4
  *
5
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.types.php $
6
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
7
- * $LastChangedRevision: 970205 $
8
- * $LastChangedBy: brucepearson $
9
  *
10
  */
11
 
@@ -20,10 +16,10 @@ class WPToolset_Types
20
  /**
21
  * Filters Types field to match data structure needed for shared code.
22
  *
23
- * @global type $pagenow
24
  * @staticvar array $cache
25
- * @param type $field array|string $field settings array (as stored in DB) or field ID
26
- * @param type $post_id Post or user ID used for conditional
 
27
  * @return array
28
  */
29
  static function filterField($field, $post_id = null, $_post_wpcf = array())
@@ -68,6 +64,7 @@ class WPToolset_Types
68
  *
69
  * Main settings that are returned.
70
  */
 
71
  $_field = array(
72
  'id' => $prefix . $field['id'] . $suffix, // Used as main ID (raw date wpt-id), used to connect conditional relations
73
  'meta_key' => $prefix . $field['id'], // Used by Types (meta key of field saved to DB)
@@ -82,6 +79,7 @@ class WPToolset_Types
82
  'repetitive' => self::isRepetitive( $field ), // Is repetitive?
83
  'validation' => self::filterValidation( $field ), // Validation settings
84
  'conditional' => self::filterConditional( $field, $post_id, $_post_wpcf ), // Conditional settings
 
85
  );
86
 
87
  /* Specific field settings
@@ -140,6 +138,7 @@ class WPToolset_Types
140
  if ( $field['type'] == 'radio' ) {
141
  $_field['type'] = 'radios';
142
  }
 
143
  return $cache[$cache_key] = $_field;
144
  }
145
 
@@ -194,7 +193,7 @@ class WPToolset_Types
194
  $validation[$rule] = array(
195
  'args' => isset( $settings['args'] ) ? array_unshift( $value,
196
  $settings['args'] ) : array($value, true),
197
- 'message' => self::translate('field ' . $id . ' validation message ' . $rule, $settings['message'])
198
  );
199
  }
200
  }
@@ -314,7 +313,7 @@ class WPToolset_Types
314
 
315
  // Get [values]
316
  $cond_values = self::getConditionalValues($post_id, $field['meta_type']);
317
-
318
  if ( function_exists('wpcf_fields_get_field_by_slug') ){
319
  // Update the conditional values according to what's being saved.
320
  foreach ( $_post_wpcf as $field_slug => $field_value ) {
@@ -323,11 +322,10 @@ class WPToolset_Types
323
  if ( empty( $field ) ) {
324
  continue;
325
  }
326
-
327
- $field_value = apply_filters( 'wpcf_fields_type_' . $field['type']
328
- . '_value_save', $field_value, $field, null );
329
-
330
- $cond_values[$field['meta_key']] = $field_value;
331
  }
332
  }
333
 
@@ -382,7 +380,7 @@ class WPToolset_Types
382
  unset( $cond_values, $c_values, $c_field );
383
  return $cache[$cache_key] = $cond;
384
  }
385
-
386
  public static function getConditionalValues($post_id, $meta_type = 'postmeta') {
387
  $cond_values = array();
388
  if ( !empty( $post_id ) ) {
@@ -396,10 +394,10 @@ class WPToolset_Types
396
  $v = self::getStringFromArray($v);
397
  }
398
  }
399
-
400
  return $cond_values;
401
  }
402
-
403
  public static function getCustomConditional($custom, $suffix = '', $cond_values = array()) {
404
  $c_fields = WPToolset_Forms_Conditional::extractFields( $custom );
405
  $c_values = array();
@@ -439,7 +437,7 @@ class WPToolset_Types
439
  'custom' => $custom,
440
  'values' => $c_values,
441
  );
442
-
443
  return $cond;
444
  }
445
 
@@ -495,9 +493,9 @@ class WPToolset_Types
495
  /**
496
  * Translates various strings connected to Types using WPML icl_t().
497
  *
498
- * @param type $name
499
- * @param type $string
500
- * @param type $context
501
  * @return string
502
  */
503
  public static function translate($name, $string, $context = 'plugin Types')
2
  /**
3
  * Types fields specific
4
  *
 
 
 
 
5
  *
6
  */
7
 
16
  /**
17
  * Filters Types field to match data structure needed for shared code.
18
  *
 
19
  * @staticvar array $cache
20
+ *
21
+ * @param array|string $field settings array (as stored in DB) or field ID
22
+ * @param int $post_id Post or user ID used for conditional
23
  * @return array
24
  */
25
  static function filterField($field, $post_id = null, $_post_wpcf = array())
64
  *
65
  * Main settings that are returned.
66
  */
67
+
68
  $_field = array(
69
  'id' => $prefix . $field['id'] . $suffix, // Used as main ID (raw date wpt-id), used to connect conditional relations
70
  'meta_key' => $prefix . $field['id'], // Used by Types (meta key of field saved to DB)
79
  'repetitive' => self::isRepetitive( $field ), // Is repetitive?
80
  'validation' => self::filterValidation( $field ), // Validation settings
81
  'conditional' => self::filterConditional( $field, $post_id, $_post_wpcf ), // Conditional settings
82
+ 'placeholder' => isset($field['data']) && isset($field['data']['placeholder'])? $field['data']['placeholder']:null, // HTML5 placeholder
83
  );
84
 
85
  /* Specific field settings
138
  if ( $field['type'] == 'radio' ) {
139
  $_field['type'] = 'radios';
140
  }
141
+
142
  return $cache[$cache_key] = $_field;
143
  }
144
 
193
  $validation[$rule] = array(
194
  'args' => isset( $settings['args'] ) ? array_unshift( $value,
195
  $settings['args'] ) : array($value, true),
196
+ 'message' => self::translate('field ' . $id . ' validation message ' . $rule, stripslashes( $settings['message']))
197
  );
198
  }
199
  }
313
 
314
  // Get [values]
315
  $cond_values = self::getConditionalValues($post_id, $field['meta_type']);
316
+
317
  if ( function_exists('wpcf_fields_get_field_by_slug') ){
318
  // Update the conditional values according to what's being saved.
319
  foreach ( $_post_wpcf as $field_slug => $field_value ) {
322
  if ( empty( $field ) ) {
323
  continue;
324
  }
325
+
326
+ $field_value = apply_filters( 'wpcf_fields_type_' . $field['type'] . '_value_save', $field_value, $field, null );
327
+
328
+ $cond_values[$field['meta_key']] = $field_value;
 
329
  }
330
  }
331
 
380
  unset( $cond_values, $c_values, $c_field );
381
  return $cache[$cache_key] = $cond;
382
  }
383
+
384
  public static function getConditionalValues($post_id, $meta_type = 'postmeta') {
385
  $cond_values = array();
386
  if ( !empty( $post_id ) ) {
394
  $v = self::getStringFromArray($v);
395
  }
396
  }
397
+
398
  return $cond_values;
399
  }
400
+
401
  public static function getCustomConditional($custom, $suffix = '', $cond_values = array()) {
402
  $c_fields = WPToolset_Forms_Conditional::extractFields( $custom );
403
  $c_values = array();
437
  'custom' => $custom,
438
  'values' => $c_values,
439
  );
440
+
441
  return $cond;
442
  }
443
 
493
  /**
494
  * Translates various strings connected to Types using WPML icl_t().
495
  *
496
+ * @param string $name
497
+ * @param string $string
498
+ * @param string $context
499
  * @return string
500
  */
501
  public static function translate($name, $string, $context = 'plugin Types')
embedded/common/toolset-forms/classes/class.validation.php CHANGED
@@ -3,7 +3,7 @@
3
  * Libraries
4
  * - CakePHP library for PHP validation
5
  * - jQuery Validation plugin for JS validation
6
- *
7
  * Flow
8
  * - Hooks to form filtering to collect data
9
  * - Filters data-wpt-validation (adds array of rules) to form element
@@ -15,7 +15,7 @@
15
 
16
  /**
17
  * Class description
18
- *
19
  * @author Srdjan
20
  */
21
  class WPToolset_Forms_Validation
@@ -50,7 +50,7 @@ class WPToolset_Forms_Validation
50
  array($this, 'filterFormField'), 10, 2 );
51
  // Render classes
52
  add_action('wptoolset_field_class', array($this, 'actionFieldClass') );
53
-
54
  // Render settings
55
  add_action( 'admin_print_footer_scripts', array($this, 'renderJsonData'), 30 );
56
  add_action( 'wp_footer', array($this, 'renderJsonData'), 30 );
@@ -60,7 +60,7 @@ class WPToolset_Forms_Validation
60
 
61
  /**
62
  * Adjusts validation data for JS processing (data-wpt-validate HTML attribute)
63
- *
64
  * @param type $rules
65
  * @return type
66
  */
@@ -91,11 +91,11 @@ class WPToolset_Forms_Validation
91
 
92
  /**
93
  * Form PHP validation.
94
- *
95
  * Called from Form_Factory or save_post hook.
96
  * Form Factory should check if element has 'error' property (WP_Error)
97
  * and use WP_Error::get_error_message() to display error message
98
- *
99
  * @param type $element
100
  * @param type $value
101
  * @return type
@@ -126,26 +126,26 @@ class WPToolset_Forms_Validation
126
 
127
  /**
128
  * Bulk PHP validation.
129
- *
130
  * @param type $field Field class instance
131
  * @param type $value
132
  * @return \WP_Error|boolean
133
  * @throws Exception
134
  */
135
- public function validateField( $field ) {
136
- $value = apply_filters( 'wptoolset_validation_value_' . $field->getType(),
137
- $field->getValue() );
138
  $rules = $this->_parseRules( $field->getValidationData(), $value );
139
  // If not required but empty - skip
140
  if ( !isset( $rules['required'] )
141
  && ( is_null( $value ) || $value === false || $value === '' ) ) {
142
  return true;
143
  }
 
144
  try {
145
- $errors = array();
146
  foreach ( $rules as $rule => $args ) {
147
  if ( !$this->validate( $rule, $args['args'] ) ) {
148
- $errors[] = $field->getTitle() . ' ' . $args['message'];
149
  }
150
  }
151
  if ( !empty( $errors ) ) {
@@ -157,7 +157,7 @@ class WPToolset_Forms_Validation
157
  }
158
  return true;
159
  }
160
-
161
  protected function _parseRules( $rules, $value ) {
162
  $_rules = array();
163
  foreach ( $rules as $rule => $args ) {
@@ -178,9 +178,9 @@ class WPToolset_Forms_Validation
178
 
179
  /**
180
  * Single rule PHP validation.
181
- *
182
  * Accepts e.g. validate('maxlength', array($value, '15'))
183
- *
184
  * @param type $method
185
  * @param type $args
186
  * @return boolean
@@ -188,6 +188,11 @@ class WPToolset_Forms_Validation
188
  public function validate( $rule, $args ) {
189
  $validator = $this->_cake();
190
  $rule = $this->_map_rule_js_to_php( $rule );
 
 
 
 
 
191
  if ( is_callable( array($validator, $rule) ) ) {
192
  return call_user_func_array( array($validator, $rule), $args );
193
  }
@@ -196,7 +201,7 @@ class WPToolset_Forms_Validation
196
 
197
  /**
198
  * Loads CakePHP Validation class.
199
- *
200
  * @return type
201
  */
202
  protected function _cake() {
@@ -209,7 +214,7 @@ class WPToolset_Forms_Validation
209
 
210
  /**
211
  * Maps rules between JS and PHP.
212
- *
213
  * @param type $rule
214
  * @return type
215
  */
@@ -221,10 +226,9 @@ class WPToolset_Forms_Validation
221
  * Renders JSON data.
222
  */
223
  public function renderJsonData() {
224
- echo '<script type="text/javascript">wptValidationForms.push("#'
225
- . $this->__formID . '");</script>';
226
  }
227
-
228
  public function actionFieldClass( $config ) {
229
  if ( !empty( $config['validation'] ) ) {
230
  foreach ($config['validation'] as $rule => $data) {
3
  * Libraries
4
  * - CakePHP library for PHP validation
5
  * - jQuery Validation plugin for JS validation
6
+ *
7
  * Flow
8
  * - Hooks to form filtering to collect data
9
  * - Filters data-wpt-validation (adds array of rules) to form element
15
 
16
  /**
17
  * Class description
18
+ *
19
  * @author Srdjan
20
  */
21
  class WPToolset_Forms_Validation
50
  array($this, 'filterFormField'), 10, 2 );
51
  // Render classes
52
  add_action('wptoolset_field_class', array($this, 'actionFieldClass') );
53
+
54
  // Render settings
55
  add_action( 'admin_print_footer_scripts', array($this, 'renderJsonData'), 30 );
56
  add_action( 'wp_footer', array($this, 'renderJsonData'), 30 );
60
 
61
  /**
62
  * Adjusts validation data for JS processing (data-wpt-validate HTML attribute)
63
+ *
64
  * @param type $rules
65
  * @return type
66
  */
91
 
92
  /**
93
  * Form PHP validation.
94
+ *
95
  * Called from Form_Factory or save_post hook.
96
  * Form Factory should check if element has 'error' property (WP_Error)
97
  * and use WP_Error::get_error_message() to display error message
98
+ *
99
  * @param type $element
100
  * @param type $value
101
  * @return type
126
 
127
  /**
128
  * Bulk PHP validation.
129
+ *
130
  * @param type $field Field class instance
131
  * @param type $value
132
  * @return \WP_Error|boolean
133
  * @throws Exception
134
  */
135
+ public function validateField( $field ) {
136
+ $value = apply_filters( 'wptoolset_validation_value_' . $field->getType(), $field->getValue() );
 
137
  $rules = $this->_parseRules( $field->getValidationData(), $value );
138
  // If not required but empty - skip
139
  if ( !isset( $rules['required'] )
140
  && ( is_null( $value ) || $value === false || $value === '' ) ) {
141
  return true;
142
  }
143
+
144
  try {
145
+ $errors = array();
146
  foreach ( $rules as $rule => $args ) {
147
  if ( !$this->validate( $rule, $args['args'] ) ) {
148
+ $errors[] = $field->getTitle() . ' ' . $args['message'];
149
  }
150
  }
151
  if ( !empty( $errors ) ) {
157
  }
158
  return true;
159
  }
160
+
161
  protected function _parseRules( $rules, $value ) {
162
  $_rules = array();
163
  foreach ( $rules as $rule => $args ) {
178
 
179
  /**
180
  * Single rule PHP validation.
181
+ *
182
  * Accepts e.g. validate('maxlength', array($value, '15'))
183
+ *
184
  * @param type $method
185
  * @param type $args
186
  * @return boolean
188
  public function validate( $rule, $args ) {
189
  $validator = $this->_cake();
190
  $rule = $this->_map_rule_js_to_php( $rule );
191
+
192
+ if ( 'skype' == $rule ) {
193
+ return $validator->custom($args[0]['skypename'], '/^([a-zA-Z0-9\,\.\-\_]+)$/');
194
+ }
195
+
196
  if ( is_callable( array($validator, $rule) ) ) {
197
  return call_user_func_array( array($validator, $rule), $args );
198
  }
201
 
202
  /**
203
  * Loads CakePHP Validation class.
204
+ *
205
  * @return type
206
  */
207
  protected function _cake() {
214
 
215
  /**
216
  * Maps rules between JS and PHP.
217
+ *
218
  * @param type $rule
219
  * @return type
220
  */
226
  * Renders JSON data.
227
  */
228
  public function renderJsonData() {
229
+ printf('<script type="text/javascript">wptValidationForms.push("#%s");</script>', $this->__formID);
 
230
  }
231
+
232
  public function actionFieldClass( $config ) {
233
  if ( !empty( $config['validation'] ) ) {
234
  foreach ($config['validation'] as $rule => $data) {
embedded/common/toolset-forms/classes/class.video.php CHANGED
@@ -6,10 +6,6 @@ require_once 'class.file.php';
6
  *
7
  * @author Srdjan
8
  *
9
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/classes/class.video.php $
10
- * $LastChangedDate: 2014-08-22 12:23:29 +0200 (Fri, 22 Aug 2014) $
11
- * $LastChangedRevision: 26350 $
12
- * $LastChangedBy: francesco $
13
  *
14
  */
15
  class WPToolset_Field_Video extends WPToolset_Field_File
@@ -23,15 +19,51 @@ class WPToolset_Field_Video extends WPToolset_Field_File
23
  $this->setValidationData($validation);
24
  return parent::metaform();
25
  }
26
-
27
- public static function addTypeValidation($validation) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  $validation['extension'] = array(
29
  'args' => array(
30
  'extension',
31
- '3gp|aaf|asf|avchd|avi|cam|dat|dsh|fla|flr|flv|m1v|m2v|m4v|mng|mp4|mxf|nsv|ogg|rm|roq|smi|sol|svi|swf|wmv|wrap|mkv|mov|mpe|mpeg|mpg',
32
  ),
33
  'message' => __( 'You can add only video.', 'wpv-views' ),
34
  );
35
  return $validation;
36
- }
37
  }
6
  *
7
  * @author Srdjan
8
  *
 
 
 
 
9
  *
10
  */
11
  class WPToolset_Field_Video extends WPToolset_Field_File
19
  $this->setValidationData($validation);
20
  return parent::metaform();
21
  }
22
+
23
+ public static function addTypeValidation($validation)
24
+ {
25
+ $valid_extensions = array(
26
+ '3gp',
27
+ 'aaf',
28
+ 'asf',
29
+ 'avchd',
30
+ 'avi',
31
+ 'cam',
32
+ 'dat',
33
+ 'dsh',
34
+ 'fla',
35
+ 'flr',
36
+ 'flv',
37
+ 'm1v',
38
+ 'm2v',
39
+ 'm4v',
40
+ 'mng',
41
+ 'mp4',
42
+ 'mxf',
43
+ 'nsv',
44
+ 'ogg',
45
+ 'rm',
46
+ 'roq',
47
+ 'smi',
48
+ 'sol',
49
+ 'svi',
50
+ 'swf',
51
+ 'wmv',
52
+ 'wrap',
53
+ 'mkv',
54
+ 'mov',
55
+ 'mpe',
56
+ 'mpeg',
57
+ 'mpg',
58
+ );
59
+ $valid_extensions = apply_filters( 'toolset_valid_video_extentions', $valid_extensions);
60
  $validation['extension'] = array(
61
  'args' => array(
62
  'extension',
63
+ implode('|', $valid_extensions),
64
  ),
65
  'message' => __( 'You can add only video.', 'wpv-views' ),
66
  );
67
  return $validation;
68
+ }
69
  }
embedded/common/toolset-forms/classes/class.wysiwyg.php CHANGED
@@ -6,19 +6,15 @@ require_once 'class.textarea.php';
6
  *
7
  * @author Srdjan
8
  *
9
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/classes/class.wysiwyg.php $
10
- * $LastChangedDate: 2015-06-15 08:18:54 +0000 (Mon, 15 Jun 2015) $
11
- * $LastChangedRevision: 1180956 $
12
- * $LastChangedBy: iworks $
13
  *
14
  */
15
  class WPToolset_Field_Wysiwyg extends WPToolset_Field_Textarea
16
- {
17
  protected $_settings = array('min_wp_version' => '3.3');
18
 
19
  public function metaform()
20
  {
21
-
22
  $attributes = $this->getAttr();
23
  $form = array();
24
  $markup = '';
@@ -26,7 +22,7 @@ class WPToolset_Field_Wysiwyg extends WPToolset_Field_Textarea
26
  $markup .= '<div class="form-item form-item-markup">';
27
  $markup .= sprintf( '<label class="wpt-form-label wpt-form-textfield-label">%s</label>', $this->getTitle() );
28
  }
29
- $markup .= $this->getDescription();
30
  $markup .= $this->_editor($attributes);
31
  if ( is_admin() ) {
32
  $markup .= '</div>';
@@ -41,15 +37,14 @@ class WPToolset_Field_Wysiwyg extends WPToolset_Field_Textarea
41
  protected function _editor(&$attributes)
42
  {
43
 
44
-
45
  if (isset($attributes['readonly'])&&$attributes['readonly']=='readonly') {
46
  add_filter( 'tiny_mce_before_init', array(&$this, 'tiny_mce_before_init_callback'));
47
  }
48
 
49
- //EMERSON: Rewritten to set do_concat to TRUE so WordPress won't echo styles directly to the browser
50
  //This will fix a lot of issues as WordPress will not be echoing content to the browser before header() is called
51
  //This fix is important so we will not be necessarily adding ob_start() here in this todo:
52
- //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/185336518/comments#282283111
53
  //Using ob_start in that code will have some side effects of some styles from other plugins not being properly loaded.
54
 
55
  global $wp_styles;
@@ -74,7 +69,8 @@ class WPToolset_Field_Wysiwyg extends WPToolset_Field_Textarea
74
  }
75
 
76
  /*RICCARDO: removed anonymous function for retrocompatibility */
77
- public function tiny_mce_before_init_callback( $args ) {
 
78
  // do you existing check for published here
79
  if ( 1 == 1 )
80
  $args['readonly'] = 1;
6
  *
7
  * @author Srdjan
8
  *
 
 
 
 
9
  *
10
  */
11
  class WPToolset_Field_Wysiwyg extends WPToolset_Field_Textarea
12
+ {
13
  protected $_settings = array('min_wp_version' => '3.3');
14
 
15
  public function metaform()
16
  {
17
+
18
  $attributes = $this->getAttr();
19
  $form = array();
20
  $markup = '';
22
  $markup .= '<div class="form-item form-item-markup">';
23
  $markup .= sprintf( '<label class="wpt-form-label wpt-form-textfield-label">%s</label>', $this->getTitle() );
24
  }
25
+ $markup .= stripcslashes($this->getDescription());
26
  $markup .= $this->_editor($attributes);
27
  if ( is_admin() ) {
28
  $markup .= '</div>';
37
  protected function _editor(&$attributes)
38
  {
39
 
 
40
  if (isset($attributes['readonly'])&&$attributes['readonly']=='readonly') {
41
  add_filter( 'tiny_mce_before_init', array(&$this, 'tiny_mce_before_init_callback'));
42
  }
43
 
44
+ //EMERSON: Rewritten to set do_concat to TRUE so WordPress won't echo styles directly to the browser
45
  //This will fix a lot of issues as WordPress will not be echoing content to the browser before header() is called
46
  //This fix is important so we will not be necessarily adding ob_start() here in this todo:
47
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/185336518/comments#282283111
48
  //Using ob_start in that code will have some side effects of some styles from other plugins not being properly loaded.
49
 
50
  global $wp_styles;
69
  }
70
 
71
  /*RICCARDO: removed anonymous function for retrocompatibility */
72
+ public function tiny_mce_before_init_callback($args)
73
+ {
74
  // do you existing check for published here
75
  if ( 1 == 1 )
76
  $args['readonly'] = 1;
embedded/common/toolset-forms/classes/submit.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ @ini_set('upload_max_size', '64M');
4
+ @ini_set('post_max_size', '64M');
5
+ @ini_set('max_execution_time', '300');
6
+
7
+ function _pre($v) {
8
+ echo "<pre>";
9
+ print_r($v);
10
+ echo "</pre>";
11
+ }
12
+
13
+ function get_local($url) {
14
+ $urlParts = parse_url($url);
15
+ return $_SERVER['DOCUMENT_ROOT'] . "/" . $urlParts['path'];
16
+ }
17
+
18
+ function clean($string) {
19
+ $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
20
+ return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
21
+ }
22
+
23
+ /**
24
+ * Executing AJAX process.
25
+ *
26
+ * @since 2.1.0
27
+ */
28
+ define('WP_USE_THEMES', false);
29
+ define('DOING_AJAX', true);
30
+ //if (!defined('WP_ADMIN')) {
31
+ // define('WP_ADMIN', true);
32
+ //}
33
+
34
+ /** Load WordPress Bootstrap */
35
+ require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
36
+
37
+ /** Allow for cross-domain requests (from the frontend). */
38
+ send_origin_headers();
39
+
40
+ if (!function_exists('wp_handle_upload')) {
41
+ require_once( ABSPATH . '/wp-admin/includes/file.php' );
42
+ }
43
+
44
+ $data = array();
45
+
46
+ if (isset($_POST['action']) && $_POST['action'] == 'delete' && isset($_POST['file'])) {
47
+ $file = $_POST['file'];
48
+
49
+ $del_nonce = $_POST['nonce'];
50
+
51
+ if (!isset($del_nonce) || (time() - $del_nonce > 100)) {
52
+ $data = array('result' => false, 'error' => 'Delete Error: Invalid NONCE', 'debug' => $_POST['nonce'] . " " . $md5);
53
+ } else {
54
+ $local_file = get_local($file);
55
+
56
+ if (file_exists($local_file))
57
+ $res = unlink($local_file);
58
+
59
+ $data = ($res) ? array('result' => $res) : array('result' => $res, 'error' => 'Error Deleting ' . $file);
60
+ }
61
+ } else {
62
+
63
+ if (!isset($_REQUEST['un'])) { // || !wp_verify_nonce($_REQUEST['un'], '_cred_cred_wpnonce')) {
64
+ $data = array('result' => false, 'error' => 'Upload Error: Invalid NONCE ');
65
+ } else {
66
+
67
+ $error = false;
68
+ $files = array();
69
+
70
+ $upload_overrides = array('test_form' => false);
71
+ if (!empty($_FILES)) {
72
+ foreach ($_FILES as $file) {
73
+ //For repetitive
74
+ foreach ($file as &$f) {
75
+ if (is_array($f)) {
76
+ foreach ($f as $p) {
77
+ $f = $p;
78
+ break;
79
+ }
80
+ }
81
+ }
82
+
83
+ $res = wp_handle_upload($file, $upload_overrides);
84
+ if (!isset($res['error'])) {
85
+ $files[] = $res['url'];
86
+ } else {
87
+ $error = true;
88
+ }
89
+ }
90
+ $data = ($error) ? array('error' => 'There was an error uploading your files: ' . $res['error']) : array('files' => $files, 'delete_nonce' => time());
91
+ } else {
92
+ $data = array('error' => 'Error: Files is too big, Max upload size is: ' . ini_get('post_max_size'));
93
+ }
94
+ }
95
+ }
96
+
97
+ echo json_encode($data);
98
+ ?>
embedded/common/toolset-forms/css/wpt-jquery-ui/datepicker.css CHANGED
@@ -133,7 +133,7 @@
133
  .ui-datepicker .ui-datepicker-next-hover { right:1px; }
134
  .ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
135
  .ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
136
- .ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
137
  .ui-datepicker select.ui-datepicker-month-year {width: 100%;}
138
  .ui-datepicker select.ui-datepicker-month,
139
  .ui-datepicker select.ui-datepicker-year { width: 49%;}
133
  .ui-datepicker .ui-datepicker-next-hover { right:1px; }
134
  .ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
135
  .ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
136
+ .ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; color: #333333; }
137
  .ui-datepicker select.ui-datepicker-month-year {width: 100%;}
138
  .ui-datepicker select.ui-datepicker-month,
139
  .ui-datepicker select.ui-datepicker-year { width: 49%;}
embedded/common/toolset-forms/css/wpt-toolset-backend.css CHANGED
@@ -198,11 +198,13 @@ img.ui-datepicker-trigger {
198
  }
199
 
200
  /* File */
201
- .wpt-file-preview img {
 
202
  border: 1px solid #A0A0A0;
203
  height: 50px;
204
  margin-top: 10px;
205
  width: auto;
 
206
  }
207
  .wpt-file .textfield,
208
  .wpt-image .textfield,
@@ -271,4 +273,4 @@ img.ui-datepicker-trigger {
271
  box-shadow: none !important;
272
  text-shadow: 0 -1px 0 rgba(0,0,0,0.1) !important;
273
  cursor: default;
274
- }
198
  }
199
 
200
  /* File */
201
+ .wpt-file-preview img
202
+ {
203
  border: 1px solid #A0A0A0;
204
  height: 50px;
205
  margin-top: 10px;
206
  width: auto;
207
+ cursor: zoom-in;
208
  }
209
  .wpt-file .textfield,
210
  .wpt-image .textfield,
273
  box-shadow: none !important;
274
  text-shadow: 0 -1px 0 rgba(0,0,0,0.1) !important;
275
  cursor: default;
276
+ }
embedded/common/toolset-forms/css/wpt-toolset-frontend.css CHANGED
@@ -100,6 +100,17 @@ ul.wpt-form-set, ul.wpt-form-set-children {
100
  margin: 10px 0;
101
  display: block;
102
  }
 
 
 
 
 
 
 
 
 
 
 
103
  input.wpt-form-error {
104
  background-color: #F8F8F8;
105
  border-color: red !important;
@@ -182,7 +193,7 @@ img.ui-datepicker-trigger, img.ui-datepicker-readonly
182
  ,.wpt-credfile-undo {
183
  margin: 0 5px 0 0;
184
  }
185
- .wpt-repdelete {
186
  margin: 0 0 0 5px;
187
  }
188
  .wpt-repadd {
@@ -285,34 +296,17 @@ img.wpt-credfile-preview-upload {
285
  }
286
 
287
  /* Autocomplete */
288
- .ac_results {
 
 
 
 
289
  padding: 0px;
290
- border: 1px solid WindowFrame;
291
  background-color: Window;
292
  overflow: hidden;
293
  }
294
 
295
- .ac_results ul {
296
- width: 100%;
297
- list-style-position: outside;
298
- list-style: none;
299
- padding: 0;
300
- margin: 0;
301
- }
302
-
303
- .ac_results iframe {
304
- display:none;/*sorry for IE5*/
305
- display/**/:block;/*sorry for IE5*/
306
- position:absolute;
307
- top:0;
308
- left:0;
309
- z-index:-1;
310
- filter:mask();
311
- width:3000px;
312
- height:3000px;
313
- }
314
-
315
- .ac_results li {
316
  margin: 0px;
317
  padding: 2px 5px;
318
  cursor: pointer;
@@ -323,13 +317,7 @@ img.wpt-credfile-preview-upload {
323
  overflow: hidden;
324
  }
325
 
326
- /* changes for matches */
327
- .ac_results li span{
328
- float: right;
329
- padding-right: 10px;
330
- }
331
-
332
- .ac_over {
333
  background-color: Highlight;
334
  color: HighlightText;
335
  }
100
  margin: 10px 0;
101
  display: block;
102
  }
103
+
104
+ .wpt-form-success {
105
+ color:#eee;
106
+ background-color: #666600;
107
+ border: 1px solid #aaaa00;
108
+ padding: 5px 10px;
109
+ width: auto;
110
+ margin: 10px 0;
111
+ display: block;
112
+ }
113
+
114
  input.wpt-form-error {
115
  background-color: #F8F8F8;
116
  border-color: red !important;
193
  ,.wpt-credfile-undo {
194
  margin: 0 5px 0 0;
195
  }
196
+ .wpt-repdelete, .wpt-date-clear {
197
  margin: 0 0 0 5px;
198
  }
199
  .wpt-repadd {
296
  }
297
 
298
  /* Autocomplete */
299
+ .wpt-suggest-taxonomy-term {
300
+ position: absolute;
301
+ display: none;
302
+ min-width: 100px;
303
+ outline: solid #ccc 1px;
304
  padding: 0px;
 
305
  background-color: Window;
306
  overflow: hidden;
307
  }
308
 
309
+ .wpt-suggest-taxonomy-term li {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  margin: 0px;
311
  padding: 2px 5px;
312
  cursor: pointer;
317
  overflow: hidden;
318
  }
319
 
320
+ .wpt-suggest-taxonomy-term-select {
 
 
 
 
 
 
321
  background-color: Highlight;
322
  color: HighlightText;
323
  }
embedded/common/toolset-forms/external/autocompleter.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
- /**
3
- *
4
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/external/autocompleter.php $
5
- * $LastChangedDate: 2014-05-29 08:44:10 +0000 (Thu, 29 May 2014) $
6
- * $LastChangedRevision: 922956 $
7
- * $LastChangedBy: iworks $
8
- *
9
- */
10
-
11
- $path = dirname(__FILE__);
12
- $file = '/wp-config.php';
13
- while ( !is_file( $path.$file) ) {
14
- $path = dirname($path);
15
- }
16
- require_once $path.$file;
17
- function autocompleter()
18
- {
19
- $results = 1;
20
- $wpdb =& $GLOBALS['wpdb'];
21
- $search = @$wpdb->escape($_GET['q']);
22
- if(strlen($search)){
23
- switch($results){
24
- case 1: //Tags and categories
25
- $words = $wpdb->get_results("SELECT concat( name, '|', sum( count ) ) name, sum( count ) cnt FROM ".$wpdb->prefix."terms t, ".$wpdb->prefix."term_taxonomy tt WHERE t.term_id = tt.term_id AND name LIKE '$search%' GROUP BY t.term_id ORDER BY cnt DESC");
26
- break;
27
- case 2: //Only tags
28
- $words = $wpdb->get_results("SELECT concat( name, '|', sum( count ) ) name, sum( count ) cnt FROM ".$wpdb->prefix."terms t, ".$wpdb->prefix."term_taxonomy tt WHERE t.term_id = tt.term_id AND tt.taxonomy='post_tag' AND name LIKE '$search%' GROUP BY t.term_id ORDER BY cnt DESC");
29
- break;
30
- case 3: //Only categories
31
- $words = $wpdb->get_results("SELECT concat( name, '|', sum( count ) ) name, sum( count ) cnt FROM ".$wpdb->prefix."terms t, ".$wpdb->prefix."term_taxonomy tt WHERE t.term_id = tt.term_id AND tt.taxonomy='category' AND name LIKE '$search%' GROUP BY t.term_id ORDER BY cnt DESC");
32
- break;
33
- case 4: //Posts and pages titles
34
- $words = $wpdb->get_results("SELECT concat( post_title, '|', 1 ) name, 1 cnt, ID FROM ".$wpdb->prefix."posts t WHERE post_status='publish' and (post_type='post' OR post_type='page') and post_date < NOW() and post_title LIKE '%$search%' ORDER BY post_title");
35
- break;
36
- case 5: //Posts titles
37
- $words = $wpdb->get_results("SELECT concat( post_title, '|', 1 ) name, 1 cnt, ID FROM ".$wpdb->prefix."posts t WHERE post_status='publish' and (post_type='post') and post_date < NOW() and post_title LIKE '%$search%' ORDER BY post_title");
38
- break;
39
- case 6: //Pages titles
40
- $words = $wpdb->get_results("SELECT concat( post_title, '|', 1 ) name, 1 cnt, ID FROM ".$wpdb->prefix."posts t WHERE post_status='publish' and (post_type='page') and post_date < NOW() and post_title LIKE '%$search%' ORDER BY post_title");
41
- break;
42
- }
43
- foreach ($words as $word){
44
- if($results > 3)
45
- echo $word->name."|".get_permalink($word->ID)."\n";
46
- else
47
- echo $word->name."\n";
48
- }
49
- }
50
- }
51
- if($_GET['q']){
52
- autocompleter();
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
embedded/common/toolset-forms/js/colorpicker.js CHANGED
@@ -5,6 +5,7 @@ var wptColorpicker = (function($) {
5
  if ( 'function' == typeof ( $(event.target).data('_bindChange') ) ) {
6
  $(event.target).data('_bindChange')();
7
  }
 
8
  }
9
  });
10
  $(document).click(function (e) {
5
  if ( 'function' == typeof ( $(event.target).data('_bindChange') ) ) {
6
  $(event.target).data('_bindChange')();
7
  }
8
+
9
  }
10
  });
11
  $(document).click(function (e) {
embedded/common/toolset-forms/js/conditional.js CHANGED
@@ -1,35 +1,31 @@
1
  /**
2
  * @see WPToolset_Forms_Conditional (classes/conditional.php)
3
  *
4
- * $HeadURL: https://www.onthegosystems.com/misc_svn/common/tags/Types-1.6.2/toolset-forms/js/conditional.js $
5
- * $LastChangedDate: 2014-08-27 17:35:29 +0200 (Wed, 27 Aug 2014) $
6
- * $LastChangedRevision: 26501 $
7
- * $LastChangedBy: riccardo $ Riccardo
8
  *
9
  */
10
  var wptCondTriggers = {}
11
- ,wptCondFields = {}
12
- ,wptCondCustomTriggers = {}
13
- ,wptCondCustomFields = {}
14
- ,wptCondDebug = false;
15
 
16
- var wptCond = (function($) {
17
 
18
  function init()
19
  {
20
- _.each(wptCondTriggers, function(triggers, formID) {
21
- _.each(triggers, function(fields, trigger) {
22
  var $trigger = _getTrigger(trigger, formID);
23
- _bindChange(formID, $trigger, function(e) {
24
  _check(formID, fields);
25
  });
26
  _check(formID, fields); // Check conditional on init
27
  });
28
  });
29
- _.each(wptCondCustomTriggers, function(triggers, formID) {
30
- _.each(triggers, function(fields, trigger) {
31
  var $trigger = _getTrigger(trigger, formID);
32
- _bindChange(formID, $trigger, function(e) {
33
  _custom(formID, fields);
34
  });
35
  _custom(formID, fields); // Check conditional on init
@@ -37,228 +33,242 @@ var wptCond = (function($) {
37
  });
38
  // Fire validation after init conditional
39
  wptCallbacks.validationInit.fire();
40
- // check initial custom NOTE this might be deprecated and not needed anymore
41
- _init_custom();
 
42
  }
43
-
44
- // hide / show effects
45
-
46
- $.fn.condSlideFadeDown = function(speed, easing, callback) {
47
  easing = easing || 'linear';
48
- return this.each(function(){$(this).animate({opacity: 'show', height: 'show'}, speed, easing, function() {
49
- $(this).css('height', 'auto');
50
- if ($.browser.msie) { this.style.removeAttribute('filter'); }
51
- if ($.isFunction(callback)) { callback.call(this); }
52
- });
53
- });
 
 
 
 
 
54
  };
55
-
56
- $.fn.condSlideFadeUp = function(speed, easing, callback) {
57
  easing = easing || 'linear';
58
- return this.each(function(){$(this).animate({opacity: 'hide', height: 'hide'}, speed, easing, function() {
59
- $(this).css('height', 'auto');
60
- if ($.browser.msie) { this.style.removeAttribute('filter'); }
61
- if ($.isFunction(callback)) { callback.call(this); }
62
- });
63
- });
 
 
 
 
 
64
  };
65
 
66
  function _getTrigger(trigger, formID)
67
  {
68
- var $trigger = $('[data-wpt-name="'+ trigger + '"]', formID);
69
  /**
70
  * wp-admin
71
  */
72
- if ( $('body').hasClass('wp-admin') ) {
73
- trigger = trigger.replace( /wpcf\-/, 'wpcf[' ) + ']';
74
- $trigger = $('[data-wpt-name="'+ trigger + '"]', formID);
75
 
76
  }
77
  /**
78
  * handle skype field
79
  */
80
- if ( $trigger.length < 1 ) {
81
- $trigger = $('[data-wpt-name="'+ trigger + '[skypename]"]', formID);
82
  }
83
  /**
84
  * handle date field
85
  */
86
- if ( $trigger.length < 1 ) {
87
- $trigger = $('[data-wpt-name="'+ trigger + '[datepicker]"]', formID);
88
  }
89
- /**
90
  * handle checkboxes and multiselect
91
  */
92
- if ( $trigger.length < 1 ) {
93
- $trigger = $('[data-wpt-name="'+ trigger + '[]"]', formID);
94
  }
95
  /**
96
  * handle select
97
  */
98
- if ( $trigger.length > 0 && 'option' == $trigger.data('wpt-type') ) {
99
  $trigger = $trigger.parent();
100
  }
101
  /**
102
  * debug
103
  */
104
- if ( wptCondDebug ) {
105
  console.info('_getTrigger');
106
- console.log( 'trigger', trigger );
107
- console.log( '$trigger', $trigger );
108
- console.log( 'formID', formID );
109
  }
110
  return $trigger;
111
  }
112
 
113
  function _getTriggerValue($trigger, formID)
114
  {
115
- if ( wptCondDebug ) {
116
  console.info('_getTriggerValue');
117
- console.log( '$trigger', $trigger );
118
- console.log( '$trigger.type', $trigger.data('wpt-type') );
119
  }
120
  // Do not add specific filtering for fields here
121
  // Use add_filter() to apply filters from /js/$type.js
122
  var val = null;
123
- // NOTE we might want to set val = ''; by default?
124
- switch( $trigger.data('wpt-type') ) {
125
  case 'radio':
126
  case 'radios':
127
  radio = $('[name="' + $trigger.attr('name') + '"]:checked', formID);
128
- // If no option was selected, the value should be empty
129
- val = '';
130
- if ( 'undefined' == typeof( radio.data('types-value' ) ) ) {
131
  val = radio.val();
132
  } else {
133
  val = radio.data('types-value');
134
  }
 
 
 
135
  break;
136
- case 'select':
137
- option = $('[name="' + $trigger.attr('name') + '"] option:selected', formID);
138
- // If no option was selected, the value should be empty
139
- val = '';
140
- if ( wptCondDebug ) {
141
- console.log( 'option', option );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  }
143
- if ( option.length == 1 ) {
144
- if ( 'undefined' == typeof( option.data('types-value' ) ) ) {
145
- val = option.val();
146
- } else {
147
- val = option.data('types-value');
148
- }
149
- } else if ( option.length > 1 ) {
150
- val = [];
151
- option.each(function() {
152
- if ( 'undefined' == typeof( $(this).data('types-value' ) ) ) {
153
- val.push($(this).val());
154
- } else {
155
- val.push($(this).data('types-value'));
156
- }
157
- });
158
- }
159
  break;
160
  case 'checkbox':
161
  var $trigger_checked = $trigger.filter(':checked');
162
- // If no checkbox was checked, the value should be empty
163
  val = '';
164
  //added data-value checking in order to fix
165
  //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188528502/comments
166
- if ( $trigger_checked.length == 1 ) {
167
- val = ($trigger_checked.attr('data-value'))?$trigger_checked.attr('data-value'):$trigger_checked.val();
168
- } else if ( $trigger_checked.length > 1 ) {
169
- val = [];
170
- $trigger_checked.each(function() {
171
- val.push(($(this).attr('data-value'))?$(this).attr('data-value'):$(this).val());
172
- });
173
  }
174
  //#########################################################################################
175
  break;
176
  case 'file':
177
- var $trigger_checked = $trigger.filter(':not([disabled])');
178
- val = $trigger_checked.val();
179
- break;
180
  default:
181
  val = $trigger.val();
182
  }
183
- if ( wptCondDebug ) {
184
- console.log( 'val', val );
185
  }
186
  return val;
187
  }
188
 
189
  function _getAffected(affected, formID)
190
  {
191
- if ( wptCondDebug ) {
192
  console.info('_getAffected');
193
  }
194
  var $el = $('[data-wpt-id="' + affected + '"]', formID);
195
- if ( $('body').hasClass('wp-admin') ) {
196
  $el = $el.closest('.wpt-field');
197
  if ($el.length < 1) {
198
  $el = $('#' + affected, formID).closest('.form-item');
199
  }
200
  } else {
201
- if ( $el.length < 1 ) {
202
- /**
203
- * get pure field name, without form prefix
204
- */
205
- re = new RegExp(formID+'_');
206
- name = '#'+affected;
207
- name = name.replace( re, '' );
208
- /**
209
- * try get element
210
- */
211
- $obj = $('[data-wpt-id="' + affected + '_file"]', formID);
212
- /**
213
- * handle by wpt field name
214
- */
215
- if ( $obj.length < 1 ) {
216
- $obj = $('[data-wpt-name="'+ name + '"]', formID);
217
- }
218
- /**
219
- * handle date field
220
- */
221
- if ( $obj.length < 1 ) {
222
- $obj = $('[data-wpt-name="'+ name + '[datepicker]"]', formID);
223
- }
224
- /**
225
- * handle skype field
226
- */
227
- if ( $obj.length < 1 ) {
228
- $obj = $('[data-wpt-name="'+ name + '[skypename]"]', formID);
229
- }
230
- /**
231
- * handle checkboxes field
232
- */
233
- if ( $obj.length < 1 ) {
234
- $obj = $('[data-wpt-name="'+ name + '[]"]', formID);
235
- }
236
- /**
237
- * catch by id
238
- */
239
- if ($obj.length < 1) {
240
- $obj = $('#' + affected, formID);
241
- }
242
-
243
- } else {
244
- $obj = $el;
245
- }
246
  /**
247
  * finally catch parent: we should have catched the $obj
248
  */
249
  if ($obj.length > 0) {
250
  $el = $obj.closest('.js-wpt-conditional-field');
251
- if ( $el.length < 1 ) {
252
- $el = $obj.closest('.cred-field');// This for backwards compatibility
253
- if ( $el.length < 1 ) {
254
- $el = $obj.closest('.js-wpt-field-items');
255
- }
256
- }
257
  }
258
  /**
259
  * debug
260
  */
261
- if ( wptCondDebug ) {
262
  console.log('$obj', $obj);
263
  }
264
  }
@@ -274,7 +284,7 @@ var wptCond = (function($) {
274
  /**
275
  * debug
276
  */
277
- if ( wptCondDebug ) {
278
  console.log('affected', affected);
279
  console.log('$el', $el);
280
  }
@@ -287,24 +297,24 @@ var wptCond = (function($) {
287
  var c = wptCondFields[formID][field];
288
  var passedOne = false, passedAll = true, passed = false;
289
  var $trigger;
290
- _.each(c.conditions, function(data) {
291
  if (__ignore) {
292
  return;
293
  }
294
  $trigger = _getTrigger(data.id, formID);
295
  var val = _getTriggerValue($trigger, formID);
296
- if ( wptCondDebug ) {
297
- console.log( 'formID', formID );
298
- console.log( '$trigger', $trigger );
299
  console.log('val', 1, val);
300
  }
301
 
302
- var field_type = $trigger.data('wpt-type');
303
- if ( data.type == 'date' ) {
304
- field_type = 'date';
305
- }
306
  val = apply_filters('conditional_value_' + field_type, val, $trigger);
307
- if ( wptCondDebug ) {
308
  console.log('val', 2, val);
309
  }
310
  do_action('conditional_check_' + data.type, formID, c, field);
@@ -312,92 +322,92 @@ var wptCond = (function($) {
312
  /**
313
  * handle types
314
  */
315
- // Not needed anymore
316
- // NEVER Date.parse timestamps coming from adodb_xxx functions
317
- /*
318
- switch(data.type) {
319
- case 'date'://alert(_val);alert(val);
320
- if ( _val ) {//alert('this is _val ' + _val);
321
- // _val = Date.parse(_val);//alert('this is _val after parse ' + _val);
322
- }//alert('val is ' + val);
323
- //val = Date.parse(val);//alert('parsed val is ' + val);
324
- break;
325
- }
326
- */
327
- if ('__ignore' == val ) {
328
  __ignore = true;
329
  return;
330
  }
331
  /**
332
  * debug
333
  */
334
- if ( wptCondDebug ) {
335
  console.log('val', 3, val);
336
  console.log('_val', _val);
337
  }
338
  /**
339
  * for __ignore_negative set some dummy operator
340
  */
341
- if ( 0 && '__ignore_negative' == val ) {
342
  operator = '__ignore';
343
  }
344
-
345
- if ( $.isArray( val ) ) {
346
- // If the selected value is an array, we just can check == and != operators, which means in_array and not_in_array
347
- // We return false in any other scenario
348
- switch (operator) {
349
- case '===':
350
- case '==':
351
- case '=':
352
- passed_single = jQuery.inArray( _val, val ) !== -1;
353
- break;
354
- case '!==':
355
- case '!=':
356
- case '<>':
357
- passed_single = jQuery.inArray( _val, val ) == -1;
358
- break;
359
- default:
360
- passed_single = false;
361
- break;
362
- }
363
- } else {
364
- // Note: we can use parseInt here although we are dealing with extended timestamps coming from adodb_xxx functions
365
- // Because javascript parseInt can deal with integers up to ±1e+21
366
- switch (operator) {
367
- case '===':
368
- case '==':
369
- case '=':
370
- if ( $.isArray( val ) ) {
371
-
372
- } else {
373
- passed_single = val == _val;
374
- }
375
- break;
376
- case '!==':
377
- case '!=':
378
- case '<>':
379
- passed_single = val != _val;
380
- break;
381
- case '>':
382
- passed_single = parseInt(val) > parseInt(_val);
383
- break;
384
- case '<':
385
- passed_single = parseInt(val) < parseInt(_val);
386
- break;
387
- case '>=':
388
- passed_single = parseInt(val) >= parseInt(_val);
389
- break;
390
- case '<=':
391
- passed_single = parseInt(val) <= parseInt(_val);
392
- break;
393
- case 'between':
394
- passed_single = parseInt(val) > parseInt(_val) && parseInt(val) < parseInt(data.args[1]);
395
- break;
396
- default:
397
- passed_single = false;
398
- break;
399
- }
400
- }
401
  if (!passed_single) {
402
  passedAll = false;
403
  } else {
@@ -414,14 +424,14 @@ var wptCond = (function($) {
414
  /**
415
  * debug
416
  */
417
- if ( wptCondDebug ) {
418
  console.log('passedAll', passedAll, 'passedOne', passedOne, 'passed', passed, '__ignore', __ignore);
419
  console.log('field', field);
420
  }
421
  if (!__ignore) {
422
  _showHide(passed, _getAffected(field, formID));
423
  }
424
- // No need to set a timeout anymore
425
  //if ( $trigger.length && next && $trigger.hasClass('js-wpt-date' ) ) {
426
  // setTimeout(function() {
427
  // _checkOneField( formID, field, false );
@@ -431,10 +441,10 @@ var wptCond = (function($) {
431
 
432
  function _check(formID, fields)
433
  {
434
- if ( wptCondDebug ) {
435
  console.info('_check');
436
  }
437
- _.each(fields, function(field) {
438
  _checkOneField(formID, field, true);
439
  });
440
  wptCallbacks.conditionalCheck.fire(formID);
@@ -452,207 +462,340 @@ var wptCond = (function($) {
452
  /**
453
  * debug
454
  */
455
- if ( wptCondDebug ) {
456
  console.info('_bindChange');
457
  console.log('$trigger', $trigger);
458
  console.log('wpt-type', $trigger.data('wpt-type'));
459
  }
460
- switch( $trigger.data('wpt-type') ) {
461
  case 'checkbox':
462
  $trigger.on('click', func);
463
  break;
464
  case 'radio':
465
  case 'radios':
466
- $('[name="' + $trigger.attr('name') + '"]').on('click', func);
 
 
 
467
  break;
468
  case 'select':
469
  $trigger.on('change', func);
470
  break;
471
- case 'date':
 
 
 
472
  $trigger.on('change', func);
473
  break;
474
- case 'file':
475
- $trigger.on('change', func);
476
- break;
477
  default:
478
- if ( $trigger.hasClass('js-wpt-colorpicker') ) {
479
  $trigger.data('_bindChange', func)
480
  }
481
  $($trigger).on('blur', func);
482
- break;
483
  }
484
  }
485
 
486
  function _custom(formID, fields)
487
  {
488
- _.each(fields, function(field) {
 
 
 
 
 
 
 
 
489
  var c = wptCondCustomFields[formID][field];
490
- var expression = c.custom;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
 
492
- // Get the values and update the expression.
493
- _.each(c.triggers, function(t) {
494
- var $trigger = _getTrigger(t),
495
- value = _getTriggerValue($trigger),
496
- is_array = $trigger.length > 1 ? true : false;
497
 
498
- console.log(":::: AND THE VALUE??????", value, " for t: ", t, $trigger );
 
499
 
500
- if (typeof value != 'undefined') {
501
 
502
- // make it a string by wrapping in quotes if
503
- // 1. the value is an empty string
504
- // 2. or it's not a number
505
-
506
- // if the trigger is an array, eg checkboxes
507
- // then convert value to ARRAY(...)
508
-
509
 
510
- if( is_array === true )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
511
  {
 
 
 
 
512
 
513
- var val_array = '';
514
-
515
- console.log();
516
-
517
- if (value instanceof Array) {
518
- for(var i = 0; i < value.length; i++) {
519
- var val = value[i];
520
- if (val === '' || isNaN(val)) {
521
- val = '\'' + val + '\'';
522
- }
523
-
524
- if (val_array == '') {
525
- val_array = val;
526
- } else {
527
- val_array += ',' + val;
528
- }
529
- }
530
- } else {
531
- if (isNaN(value)) {
532
- value = '\'' + value + '\'';
533
- }
534
- val_array = value;
535
- }
536
-
537
- value = 'ARRAY(' + val_array + ')';
538
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
539
  }
540
- else
541
- {
542
- if (value === '' || isNaN(value)) {
543
- value = '\'' + value + '\'';
544
- }
545
- }
546
 
547
- // First replace the $(field_name) format
548
- var replace = new RegExp( '\\$\\(' + t + '\\)', 'g' );
549
 
550
- expression = expression.replace( replace, value );
551
 
552
- // next replace the $field_name format
553
- var replace_old = new RegExp( '\\$' + t, 'g' );
554
 
555
- expression = expression.replace( replace_old, value );
556
 
557
- }
558
 
559
  });
560
-
561
- var result = false;
562
-
563
- try {
564
- var parser = new ToolsetParser.Expression(expression);
565
- parser.parse();
566
- result = parser.eval();
567
- }
568
- catch(e) {
569
- console.info( "Error in Tokenizer", e, expression, " there may be an error in your expression syntax" );
570
- }
571
-
572
-
573
-
574
- _showHide(result, _getAffected(field, formID));
575
-
576
  });
577
- wptCallbacks.conditionalCheck.fire(formID);
578
  }
579
 
580
  function _showHide(show, $el)
581
  {
582
- if ( wptCondDebug ) {
 
 
 
 
 
 
 
583
  console.info('_showHide');
584
  console.log(show, $el);
585
  }
586
-
587
- var effectmode = '',
588
- dur = 'slow',
589
- delay = 50;
590
-
591
- if ( $el.attr( 'data-effectmode' ) ) {
592
- effectmode = $el.data( 'effectmode' );
593
- } else {
594
- effectmode = 'slide';
595
- }
596
-
597
- if ( show ) {
598
- $el.addClass( 'wpt-conditional-visible' ).removeClass( 'wpt-conditional-hidden js-wpt-remove-on-submit js-wpt-validation-ignore' );
599
- switch( effectmode ) {
600
- case 'fade-slide':
601
- setTimeout( function() {
602
- $el.stop( true ).condSlideFadeDown( dur, 'linear' );
603
- }, delay );
604
- break;
605
- case 'slide':
606
- setTimeout( function() {
607
- $el.stop( true ).slideDown( dur, 'linear', function() {
608
- $el.css('height', 'auto');
609
- });
610
- }, delay );
611
- break;
612
- case 'fade':
613
- setTimeout( function() {
614
- $el.stop( true ).fadeIn( dur );
615
- }, delay );
616
- break;
617
- case 'none':
618
- break;
619
- default:
620
- $el.show();
621
- break;
622
- }
623
- } else {
624
- $el.addClass( 'wpt-conditional-hidden js-wpt-remove-on-submit js-wpt-validation-ignore' ).removeClass( 'wpt-conditional-visible' );
625
- switch( effectmode ) {
626
- case 'fade-slide':
627
- setTimeout( function() {
628
- $el.stop( true ).condSlideFadeUp( dur, 'linear' );
629
- }, delay );
630
- break;
631
- case 'slide':
632
- setTimeout( function() {
633
- $el.stop( true ).slideUp( dur, 'linear', function() {
634
- $el.css('height', 'auto');
635
- });
636
- }, delay );
637
- break;
638
- case 'fade':
639
- setTimeout( function() {
640
- $el.stop( true ).fadeOut( dur );
641
- }, delay );
642
- break;
643
- case 'none':
644
- break;
645
- default:
646
- $el.hide();
647
- break;
648
- }
649
- }
 
 
 
 
 
 
650
  }
651
 
652
  function ajaxCheck(formID, field, conditions)
653
  {
654
  var values = {};
655
- _.each(conditions.conditions, function(c) {
656
  var $trigger = _getTrigger(c.id, formID);
657
  values[c.id] = _getTriggerValue($trigger);
658
  });
@@ -661,63 +804,67 @@ var wptCond = (function($) {
661
  'conditions': conditions,
662
  'values': values
663
  };
664
- $.post(wptConditional.ajaxurl, data, function(passed) {
665
  _showHide(passed, _getAffected(field, formID));
666
  wptCallbacks.conditionalCheck.fire(formID);
667
- }).fail(function(data) {
668
  //alert(data);
669
  });
670
  }
671
 
672
  function addConditionals(data)
673
  {
674
- _.each(data, function(c, formID) {
675
  if (typeof c.triggers != 'undefined'
676
  && typeof wptCondTriggers[formID] != 'undefined') {
677
- _.each(c.triggers, function(fields, trigger) {
678
  wptCondTriggers[formID][trigger] = fields;
679
  var $trigger = _getTrigger(trigger, formID);
680
- _bindChange(formID, $trigger, function() {
681
  _check(formID, fields);
682
  });
683
  });
684
  }
685
  if (typeof c.fields != 'undefined'
686
  && typeof wptCondFields[formID] != 'undefined') {
687
- _.each(c.fields, function(conditionals, field) {
688
  wptCondFields[formID][field] = conditionals;
689
  });
690
  }
691
  if (typeof c.custom_triggers != 'undefined'
692
  && typeof wptCondCustomTriggers[formID] != 'undefined') {
693
- _.each(c.custom_triggers, function(fields, trigger) {
694
  wptCondCustomTriggers[formID][trigger] = fields;
695
  var $trigger = _getTrigger(trigger, formID);
696
- _bindChange(formID, $trigger, function() {
697
  _custom(formID, fields);
698
  });
699
  });
700
  }
701
  if (typeof c.custom_fields != 'undefined'
702
  && typeof wptCondCustomFields[formID] != 'undefined') {
703
- _.each(c.custom_fields, function(conditionals, field) {
704
  wptCondCustomFields[formID][field] = conditionals;
705
  });
706
  }
707
  });
708
  }
709
-
710
- function _init_custom() {
711
- $('.js-wpt-field-items').each( function () {
712
- var init_custom = $(this).data('initial-conditional');
713
- if (init_custom) {
714
- var field = $(this).closest('.cred-field');
715
- if (field.length) {
716
- _showHide(false, field);
717
- }
718
- }
719
- })
720
- }
 
 
 
 
721
 
722
  return {
723
  init: init,
1
  /**
2
  * @see WPToolset_Forms_Conditional (classes/conditional.php)
3
  *
 
 
 
 
4
  *
5
  */
6
  var wptCondTriggers = {}
7
+ , wptCondFields = {}
8
+ , wptCondCustomTriggers = {}
9
+ , wptCondCustomFields = {}
10
+ , wptCondDebug = false;
11
 
12
+ var wptCond = (function ($) {
13
 
14
  function init()
15
  {
16
+ _.each(wptCondTriggers, function (triggers, formID) {
17
+ _.each(triggers, function (fields, trigger) {
18
  var $trigger = _getTrigger(trigger, formID);
19
+ _bindChange(formID, $trigger, function (e) {
20
  _check(formID, fields);
21
  });
22
  _check(formID, fields); // Check conditional on init
23
  });
24
  });
25
+ _.each(wptCondCustomTriggers, function (triggers, formID) {
26
+ _.each(triggers, function (fields, trigger) {
27
  var $trigger = _getTrigger(trigger, formID);
28
+ _bindChange(formID, $trigger, function (e) {
29
  _custom(formID, fields);
30
  });
31
  _custom(formID, fields); // Check conditional on init
33
  });
34
  // Fire validation after init conditional
35
  wptCallbacks.validationInit.fire();
36
+ // check initial custom NOTE this might be deprecated and not needed anymore
37
+ //Fix double showHide on submition failed: commenting this
38
+ //_init_custom();
39
  }
40
+
41
+ // hide / show effects
42
+
43
+ $.fn.condSlideFadeDown = function (speed, easing, callback) {
44
  easing = easing || 'linear';
45
+ return this.each(function () {
46
+ $(this).animate({opacity: 'show', height: 'show'}, speed, easing, function () {
47
+ $(this).css('height', 'auto');
48
+ if ($.browser.msie) {
49
+ this.style.removeAttribute('filter');
50
+ }
51
+ if ($.isFunction(callback)) {
52
+ callback.call(this);
53
+ }
54
+ });
55
+ });
56
  };
57
+
58
+ $.fn.condSlideFadeUp = function (speed, easing, callback) {
59
  easing = easing || 'linear';
60
+ return this.each(function () {
61
+ $(this).animate({opacity: 'hide', height: 'hide'}, speed, easing, function () {
62
+ $(this).css('height', 'auto');
63
+ if ($.browser.msie) {
64
+ this.style.removeAttribute('filter');
65
+ }
66
+ if ($.isFunction(callback)) {
67
+ callback.call(this);
68
+ }
69
+ });
70
+ });
71
  };
72
 
73
  function _getTrigger(trigger, formID)
74
  {
75
+ var $trigger = $('[data-wpt-name="' + trigger + '"]', formID);
76
  /**
77
  * wp-admin
78
  */
79
+ if ($('body').hasClass('wp-admin')) {
80
+ trigger = trigger.replace(/wpcf\-/, 'wpcf[') + ']';
81
+ $trigger = $('[data-wpt-name="' + trigger + '"]', formID);
82
 
83
  }
84
  /**
85
  * handle skype field
86
  */
87
+ if ($trigger.length < 1) {
88
+ $trigger = $('[data-wpt-name="' + trigger + '[skypename]"]', formID);
89
  }
90
  /**
91
  * handle date field
92
  */
93
+ if ($trigger.length < 1) {
94
+ $trigger = $('[data-wpt-name="' + trigger + '[datepicker]"]', formID);
95
  }
96
+ /**
97
  * handle checkboxes and multiselect
98
  */
99
+ if ($trigger.length < 1) {
100
+ $trigger = $('[data-wpt-name="' + trigger + '[]"]', formID);
101
  }
102
  /**
103
  * handle select
104
  */
105
+ if ($trigger.length > 0 && 'option' == $trigger.data('wpt-type')) {
106
  $trigger = $trigger.parent();
107
  }
108
  /**
109
  * debug
110
  */
111
+ if (wptCondDebug) {
112
  console.info('_getTrigger');
113
+ console.log('trigger', trigger);
114
+ console.log('$trigger', $trigger);
115
+ console.log('formID', formID);
116
  }
117
  return $trigger;
118
  }
119
 
120
  function _getTriggerValue($trigger, formID)
121
  {
122
+ if (wptCondDebug) {
123
  console.info('_getTriggerValue');
124
+ console.log('$trigger', $trigger);
125
+ console.log('$trigger.type', $trigger.data('wpt-type'));
126
  }
127
  // Do not add specific filtering for fields here
128
  // Use add_filter() to apply filters from /js/$type.js
129
  var val = null;
130
+ // NOTE we might want to set val = ''; by default?
131
+ switch ($trigger.data('wpt-type')) {
132
  case 'radio':
133
  case 'radios':
134
  radio = $('[name="' + $trigger.attr('name') + '"]:checked', formID);
135
+ // If no option was selected, the value should be empty
136
+ val = '';
137
+ if ('undefined' == typeof (radio.data('types-value'))) {
138
  val = radio.val();
139
  } else {
140
  val = radio.data('types-value');
141
  }
142
+ if (wptCondDebug) {
143
+ console.log('radio', radio);
144
+ }
145
  break;
146
+ case 'select':
147
+ option = $('[name="' + $trigger.attr('name') + '"] option:selected', formID);
148
+ // If no option was selected, the value should be empty
149
+ val = '';
150
+ if (wptCondDebug) {
151
+ console.log('option', option);
152
+ }
153
+ if (option.length == 1) {
154
+ if ('undefined' == typeof (option.data('types-value'))) {
155
+ val = option.val();
156
+ } else {
157
+ val = option.data('types-value');
158
+ }
159
+ } else if (option.length > 1) {
160
+ val = [];
161
+ option.each(function () {
162
+ if ('undefined' == typeof ($(this).data('types-value'))) {
163
+ val.push($(this).val());
164
+ } else {
165
+ val.push($(this).data('types-value'));
166
+ }
167
+ });
168
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  break;
170
  case 'checkbox':
171
  var $trigger_checked = $trigger.filter(':checked');
172
+ // If no checkbox was checked, the value should be empty
173
  val = '';
174
  //added data-value checking in order to fix
175
  //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188528502/comments
176
+ if ($trigger_checked.length == 1) {
177
+ val = ($trigger_checked.attr('data-value')) ? $trigger_checked.attr('data-value') : $trigger_checked.val();
178
+ } else if ($trigger_checked.length > 1) {
179
+ val = [];
180
+ $trigger_checked.each(function () {
181
+ val.push(($(this).attr('data-value')) ? $(this).attr('data-value') : $(this).val());
182
+ });
183
  }
184
  //#########################################################################################
185
  break;
186
  case 'file':
187
+ var $trigger_checked = $trigger.filter(':not([disabled])');
188
+ val = $trigger_checked.val();
189
+ break;
190
  default:
191
  val = $trigger.val();
192
  }
193
+ if (wptCondDebug) {
194
+ console.log('val', val);
195
  }
196
  return val;
197
  }
198
 
199
  function _getAffected(affected, formID)
200
  {
201
+ if (wptCondDebug) {
202
  console.info('_getAffected');
203
  }
204
  var $el = $('[data-wpt-id="' + affected + '"]', formID);
205
+ if ($('body').hasClass('wp-admin')) {
206
  $el = $el.closest('.wpt-field');
207
  if ($el.length < 1) {
208
  $el = $('#' + affected, formID).closest('.form-item');
209
  }
210
  } else {
211
+ if ($el.length < 1) {
212
+ /**
213
+ * get pure field name, without form prefix
214
+ */
215
+ re = new RegExp(formID + '_');
216
+ name = '#' + affected;
217
+ name = name.replace(re, '');
218
+ /**
219
+ * try get element
220
+ */
221
+ $obj = $('[data-wpt-id="' + affected + '_file"]', formID);
222
+ /**
223
+ * handle by wpt field name
224
+ */
225
+ if ($obj.length < 1) {
226
+ $obj = $('[data-wpt-name="' + name + '"]', formID);
227
+ }
228
+ /**
229
+ * handle date field
230
+ */
231
+ if ($obj.length < 1) {
232
+ $obj = $('[data-wpt-name="' + name + '[datepicker]"]', formID);
233
+ }
234
+ /**
235
+ * handle skype field
236
+ */
237
+ if ($obj.length < 1) {
238
+ $obj = $('[data-wpt-name="' + name + '[skypename]"]', formID);
239
+ }
240
+ /**
241
+ * handle checkboxes field
242
+ */
243
+ if ($obj.length < 1) {
244
+ $obj = $('[data-wpt-name="' + name + '[]"]', formID);
245
+ }
246
+ /**
247
+ * catch by id
248
+ */
249
+ if ($obj.length < 1) {
250
+ $obj = $('#' + affected, formID);
251
+ }
252
+
253
+ } else {
254
+ $obj = $el;
255
+ }
256
  /**
257
  * finally catch parent: we should have catched the $obj
258
  */
259
  if ($obj.length > 0) {
260
  $el = $obj.closest('.js-wpt-conditional-field');
261
+ if ($el.length < 1) {
262
+ $el = $obj.closest('.cred-field');// This for backwards compatibility
263
+ if ($el.length < 1) {
264
+ $el = $obj.closest('.js-wpt-field-items');
265
+ }
266
+ }
267
  }
268
  /**
269
  * debug
270
  */
271
+ if (wptCondDebug) {
272
  console.log('$obj', $obj);
273
  }
274
  }
284
  /**
285
  * debug
286
  */
287
+ if (wptCondDebug) {
288
  console.log('affected', affected);
289
  console.log('$el', $el);
290
  }
297
  var c = wptCondFields[formID][field];
298
  var passedOne = false, passedAll = true, passed = false;
299
  var $trigger;
300
+ _.each(c.conditions, function (data) {
301
  if (__ignore) {
302
  return;
303
  }
304
  $trigger = _getTrigger(data.id, formID);
305
  var val = _getTriggerValue($trigger, formID);
306
+ if (wptCondDebug) {
307
+ console.log('formID', formID);
308
+ console.log('$trigger', $trigger);
309
  console.log('val', 1, val);
310
  }
311
 
312
+ var field_type = $trigger.data('wpt-type');
313
+ if (data.type == 'date') {
314
+ field_type = 'date';
315
+ }
316
  val = apply_filters('conditional_value_' + field_type, val, $trigger);
317
+ if (wptCondDebug) {
318
  console.log('val', 2, val);
319
  }
320
  do_action('conditional_check_' + data.type, formID, c, field);
322
  /**
323
  * handle types
324
  */
325
+ // Not needed anymore
326
+ // NEVER Date.parse timestamps coming from adodb_xxx functions
327
+ /*
328
+ switch(data.type) {
329
+ case 'date'://alert(_val);alert(val);
330
+ if ( _val ) {//alert('this is _val ' + _val);
331
+ // _val = Date.parse(_val);//alert('this is _val after parse ' + _val);
332
+ }//alert('val is ' + val);
333
+ //val = Date.parse(val);//alert('parsed val is ' + val);
334
+ break;
335
+ }
336
+ */
337
+ if ('__ignore' == val) {
338
  __ignore = true;
339
  return;
340
  }
341
  /**
342
  * debug
343
  */
344
+ if (wptCondDebug) {
345
  console.log('val', 3, val);
346
  console.log('_val', _val);
347
  }
348
  /**
349
  * for __ignore_negative set some dummy operator
350
  */
351
+ if (0 && '__ignore_negative' == val) {
352
  operator = '__ignore';
353
  }
354
+
355
+ if ($.isArray(val)) {
356
+ // If the selected value is an array, we just can check == and != operators, which means in_array and not_in_array
357
+ // We return false in any other scenario
358
+ switch (operator) {
359
+ case '===':
360
+ case '==':
361
+ case '=':
362
+ passed_single = jQuery.inArray(_val, val) !== -1;
363
+ break;
364
+ case '!==':
365
+ case '!=':
366
+ case '<>':
367
+ passed_single = jQuery.inArray(_val, val) == -1;
368
+ break;
369
+ default:
370
+ passed_single = false;
371
+ break;
372
+ }
373
+ } else {
374
+ // Note: we can use parseInt here although we are dealing with extended timestamps coming from adodb_xxx functions
375
+ // Because javascript parseInt can deal with integers up to ±1e+21
376
+ switch (operator) {
377
+ case '===':
378
+ case '==':
379
+ case '=':
380
+ if ($.isArray(val)) {
381
+
382
+ } else {
383
+ passed_single = val == _val;
384
+ }
385
+ break;
386
+ case '!==':
387
+ case '!=':
388
+ case '<>':
389
+ passed_single = val != _val;
390
+ break;
391
+ case '>':
392
+ passed_single = parseInt(val) > parseInt(_val);
393
+ break;
394
+ case '<':
395
+ passed_single = parseInt(val) < parseInt(_val);
396
+ break;
397
+ case '>=':
398
+ passed_single = parseInt(val) >= parseInt(_val);
399
+ break;
400
+ case '<=':
401
+ passed_single = parseInt(val) <= parseInt(_val);
402
+ break;
403
+ case 'between':
404
+ passed_single = parseInt(val) > parseInt(_val) && parseInt(val) < parseInt(data.args[1]);
405
+ break;
406
+ default:
407
+ passed_single = false;
408
+ break;
409
+ }
410
+ }
411
  if (!passed_single) {
412
  passedAll = false;
413
  } else {
424
  /**
425
  * debug
426
  */
427
+ if (wptCondDebug) {
428
  console.log('passedAll', passedAll, 'passedOne', passedOne, 'passed', passed, '__ignore', __ignore);
429
  console.log('field', field);
430
  }
431
  if (!__ignore) {
432
  _showHide(passed, _getAffected(field, formID));
433
  }
434
+ // No need to set a timeout anymore
435
  //if ( $trigger.length && next && $trigger.hasClass('js-wpt-date' ) ) {
436
  // setTimeout(function() {
437
  // _checkOneField( formID, field, false );
441
 
442
  function _check(formID, fields)
443
  {
444
+ if (wptCondDebug) {
445
  console.info('_check');
446
  }
447
+ _.each(fields, function (field) {
448
  _checkOneField(formID, field, true);
449
  });
450
  wptCallbacks.conditionalCheck.fire(formID);
462
  /**
463
  * debug
464
  */
465
+ if (wptCondDebug) {
466
  console.info('_bindChange');
467
  console.log('$trigger', $trigger);
468
  console.log('wpt-type', $trigger.data('wpt-type'));
469
  }
470
+ switch ($trigger.data('wpt-type')) {
471
  case 'checkbox':
472
  $trigger.on('click', func);
473
  break;
474
  case 'radio':
475
  case 'radios':
476
+ /**
477
+ * when selecting again, do not forget about formID
478
+ */
479
+ $('[name="' + $trigger.attr('name') + '"]', formID).on('click', func);
480
  break;
481
  case 'select':
482
  $trigger.on('change', func);
483
  break;
484
+ case 'date':
485
+ $trigger.on('change', func);
486
+ break;
487
+ case 'file':
488
  $trigger.on('change', func);
489
  break;
 
 
 
490
  default:
491
+ if ($trigger.hasClass('js-wpt-colorpicker')) {
492
  $trigger.data('_bindChange', func)
493
  }
494
  $($trigger).on('blur', func);
495
+ break;
496
  }
497
  }
498
 
499
  function _custom(formID, fields)
500
  {
501
+ /**
502
+ * debug
503
+ */
504
+ if (wptCondDebug) {
505
+ console.log('_custom');
506
+ console.log('formID', formID);
507
+ console.log('fields', fields);
508
+ }
509
+ _.each(fields, function (field) {
510
  var c = wptCondCustomFields[formID][field];
511
+ var expression = c.custom;
512
+
513
+ // Get the values and update the expression.
514
+ _.each(c.triggers, function (t) {
515
+ var $trigger = _getTrigger(t, formID),
516
+ value = _getTriggerValue($trigger, formID),
517
+ is_array = $trigger.length > 1 ? true : false;
518
+ if (wptCondDebug) {
519
+ console.log("The value is ", value, " for element: ", t, $trigger);
520
+ }
521
+
522
+ //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193595717/comments
523
+ //group issue on select
524
+ if (false) {
525
+ if ($trigger.is('select') && !$trigger.attr('multiple')) {
526
+ $("#" + $trigger.attr('id') + " > option").each(function () {
527
+ //console.log(value + " " + this.text + ' ' + this.value + ' ' + $(this).data('typesValue'));
528
+ if ($(this).data('typesValue') && $(this).data('typesValue') == value || this.text==value || value==this.value)
529
+ value = this.text;
530
+ });
531
+ }
532
+ }
533
+ //#####################################################################################
534
+
535
+ if (typeof value != 'undefined') {
536
 
537
+ // make it a string by wrapping in quotes if
538
+ // 1. the value is an empty string
539
+ // 2. or it's not a number
 
 
540
 
541
+ // if the trigger is an array, eg checkboxes
542
+ // then convert value to ARRAY(...)
543
 
 
544
 
545
+ if (is_array === true) {
 
 
 
 
 
 
546
 
547
+ var val_array = '';
548
+
549
+ if (wptCondDebug) {
550
+ console.log();
551
+ }
552
+
553
+ if (value instanceof Array) {
554
+ for (var i = 0; i < value.length; i++) {
555
+ var val = value[i];
556
+ if (val === '' || isNaN(val)) {
557
+ val = '\'' + val + '\'';
558
+ }
559
+
560
+ if (val_array == '') {
561
+ val_array = val;
562
+ } else {
563
+ val_array += ',' + val;
564
+ }
565
+ }
566
+ } else {
567
+ if (isNaN(value)) {
568
+ value = '\'' + value + '\'';
569
+ }
570
+ val_array = value;
571
+ }
572
+
573
+ value = 'ARRAY(' + val_array + ')';
574
+
575
+ }
576
+ else
577
  {
578
+ if (value === '' || isNaN(value)) {
579
+ value = '\'' + value + '\'';
580
+ }
581
+ }
582
 
583
+ // First replace the $(field_name) format
584
+ var replace = new RegExp('\\$\\(' + t + '\\)', 'g');
585
+
586
+ expression = expression.replace(replace, value);
587
+
588
+ // next replace the $field_name format
589
+ var replace_old = new RegExp('\\$' + t, 'g');
590
+
591
+ expression = expression.replace(replace_old, value);
592
+
593
+ }
594
+
595
+ });
596
+
597
+ var result = false;
598
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196173370/comments#309696464
599
+ //Added a new check using text element on select
600
+ var result2 = false;
601
+
602
+ try {
603
+ var parser = new ToolsetParser.Expression(expression);
604
+ parser.parse();
605
+ result = parser.eval();
606
+ }
607
+ catch (e) {
608
+ console.info("Error in Tokenizer", e, expression, " there may be an error in your expression syntax");
609
+ }
610
+
611
+ //https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/196173370/comments#309696464
612
+ //Added a new check using text element on select
613
+ // Get the values and update the expression.
614
+ _.each(c.triggers, function (t) {
615
+ var $trigger = _getTrigger(t, formID),
616
+ value = _getTriggerValue($trigger, formID),
617
+ is_array = $trigger.length > 1 ? true : false;
618
+ if (wptCondDebug) {
619
+ console.log("The value is ", value, " for element: ", t, $trigger);
620
+ }
621
+
622
+ //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193595717/comments
623
+ //group issue on select
624
+ if ($trigger.is('select') && !$trigger.attr('multiple')) {
625
+ $("#" + $trigger.attr('id') + " > option").each(function () {
626
+ //console.log(value + " " + this.text + ' ' + this.value + ' ' + $(this).data('typesValue'));
627
+ if ($(this).data('typesValue') && $(this).data('typesValue') == value || this.text==value || value==this.value)
628
+ value = this.text;
629
+ });
630
+ }
631
+ //#####################################################################################
632
+
633
+ if (typeof value != 'undefined') {
634
+
635
+ // make it a string by wrapping in quotes if
636
+ // 1. the value is an empty string
637
+ // 2. or it's not a number
638
+
639
+ // if the trigger is an array, eg checkboxes
640
+ // then convert value to ARRAY(...)
641
+
642
+
643
+ if (is_array === true) {
644
+
645
+ var val_array = '';
646
+
647
+ if (wptCondDebug) {
648
+ console.log();
649
+ }
650
+
651
+ if (value instanceof Array) {
652
+ for (var i = 0; i < value.length; i++) {
653
+ var val = value[i];
654
+ if (val === '' || isNaN(val)) {
655
+ val = '\'' + val + '\'';
656
+ }
657
+
658
+ if (val_array == '') {
659
+ val_array = val;
660
+ } else {
661
+ val_array += ',' + val;
662
+ }
663
+ }
664
+ } else {
665
+ if (isNaN(value)) {
666
+ value = '\'' + value + '\'';
667
+ }
668
+ val_array = value;
669
+ }
670
+
671
+ value = 'ARRAY(' + val_array + ')';
672
+
673
+ }
674
+ else
675
+ {
676
+ if (value === '' || isNaN(value)) {
677
+ value = '\'' + value + '\'';
678
+ }
679
  }
 
 
 
 
 
 
680
 
681
+ // First replace the $(field_name) format
682
+ var replace = new RegExp('\\$\\(' + t + '\\)', 'g');
683
 
684
+ expression = expression.replace(replace, value);
685
 
686
+ // next replace the $field_name format
687
+ var replace_old = new RegExp('\\$' + t, 'g');
688
 
689
+ expression = expression.replace(replace_old, value);
690
 
691
+ }
692
 
693
  });
694
+
695
+ try {
696
+ var parser = new ToolsetParser.Expression(expression);
697
+ parser.parse();
698
+ result2 = parser.eval();
699
+ }
700
+ catch (e) {
701
+ console.info("Error in Tokenizer", e, expression, " there may be an error in your expression syntax");
702
+ }
703
+
704
+ _showHide(result||result2, _getAffected(field, formID));
705
+
 
 
 
 
706
  });
707
+ wptCallbacks.conditionalCheck.fire(formID);
708
  }
709
 
710
  function _showHide(show, $el)
711
  {
712
+ //Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/193353994/comments#302703480
713
+
714
+ //TODO: check this cause side effect
715
+ /*if (jQuery('.wpt-form-error').length) {
716
+ jQuery('.wpt-form-error').hide();
717
+ }*/
718
+
719
+ if (wptCondDebug) {
720
  console.info('_showHide');
721
  console.log(show, $el);
722
  }
723
+
724
+ var effectmode = '',
725
+ dur = 'slow',
726
+ delay = 50;
727
+
728
+ if ($el.attr('data-effectmode')) {
729
+ effectmode = $el.data('effectmode');
730
+ } else {
731
+ effectmode = 'slide';
732
+ }
733
+
734
+ if (show) {
735
+ if ( $el.hasClass('wpt-date') && 'object' == typeof wptDate) {
736
+ $('.js-wpt-date', $el).removeAttr('disabled');
737
+ wptDate.init('body');
738
+ }
739
+ $el.addClass('wpt-conditional-visible').removeClass('wpt-conditional-hidden js-wpt-remove-on-submit js-wpt-validation-ignore');
740
+ switch (effectmode) {
741
+ case 'fade-slide':
742
+ setTimeout(function () {
743
+ $el.stop(true).condSlideFadeDown(dur, 'linear');
744
+ }, delay);
745
+ break;
746
+ case 'slide':
747
+ setTimeout(function () {
748
+ $el.stop(true).slideDown(dur, 'linear', function () {
749
+ $el.css('height', 'auto');
750
+ });
751
+ }, delay);
752
+ break;
753
+ case 'fade':
754
+ setTimeout(function () {
755
+ $el.stop(true).fadeIn(dur);
756
+ }, delay);
757
+ break;
758
+ case 'none':
759
+ break;
760
+ default:
761
+ $el.show();
762
+ break;
763
+ }
764
+ $($el).find('input, textarea, button, select').prop("disabled", false);
765
+ } else {
766
+ $el.addClass('wpt-conditional-hidden js-wpt-remove-on-submit js-wpt-validation-ignore').removeClass('wpt-conditional-visible');
767
+ switch (effectmode) {
768
+ case 'fade-slide':
769
+ setTimeout(function () {
770
+ $el.stop(true).condSlideFadeUp(dur, 'linear');
771
+ }, delay);
772
+ break;
773
+ case 'slide':
774
+ setTimeout(function () {
775
+ $el.stop(true).slideUp(dur, 'linear', function () {
776
+ $el.css('height', 'auto');
777
+ });
778
+ }, delay);
779
+ break;
780
+ case 'fade':
781
+ setTimeout(function () {
782
+ $el.stop(true).fadeOut(dur);
783
+ }, delay);
784
+ break;
785
+ case 'none':
786
+ break;
787
+ default:
788
+ $el.hide();
789
+ break;
790
+ }
791
+ $($el).find('input, textarea, button, select').attr('disabled','disabled');
792
+ }
793
  }
794
 
795
  function ajaxCheck(formID, field, conditions)
796
  {
797
  var values = {};
798
+ _.each(conditions.conditions, function (c) {
799
  var $trigger = _getTrigger(c.id, formID);
800
  values[c.id] = _getTriggerValue($trigger);
801
  });
804
  'conditions': conditions,
805
  'values': values
806
  };
807
+ $.post(wptConditional.ajaxurl, data, function (passed) {
808
  _showHide(passed, _getAffected(field, formID));
809
  wptCallbacks.conditionalCheck.fire(formID);
810
+ }).fail(function (data) {
811
  //alert(data);
812
  });
813
  }
814
 
815
  function addConditionals(data)
816
  {
817
+ _.each(data, function (c, formID) {
818
  if (typeof c.triggers != 'undefined'
819
  && typeof wptCondTriggers[formID] != 'undefined') {
820
+ _.each(c.triggers, function (fields, trigger) {
821
  wptCondTriggers[formID][trigger] = fields;
822
  var $trigger = _getTrigger(trigger, formID);
823
+ _bindChange(formID, $trigger, function () {
824
  _check(formID, fields);
825
  });
826
  });
827
  }
828
  if (typeof c.fields != 'undefined'
829
  && typeof wptCondFields[formID] != 'undefined') {
830
+ _.each(c.fields, function (conditionals, field) {
831
  wptCondFields[formID][field] = conditionals;
832
  });
833
  }
834
  if (typeof c.custom_triggers != 'undefined'
835
  && typeof wptCondCustomTriggers[formID] != 'undefined') {
836
+ _.each(c.custom_triggers, function (fields, trigger) {
837
  wptCondCustomTriggers[formID][trigger] = fields;
838
  var $trigger = _getTrigger(trigger, formID);
839
+ _bindChange(formID, $trigger, function () {
840
  _custom(formID, fields);
841
  });
842
  });
843
  }
844
  if (typeof c.custom_fields != 'undefined'
845
  && typeof wptCondCustomFields[formID] != 'undefined') {
846
+ _.each(c.custom_fields, function (conditionals, field) {
847
  wptCondCustomFields[formID][field] = conditionals;
848
  });
849
  }
850
  });
851
  }
852
+
853
+ /**
854
+ * deprecated
855
+ * @returns {undefined}
856
+ */
857
+ function _init_custom() {
858
+ $('.js-wpt-field-items').each(function () {
859
+ var init_custom = $(this).data('initial-conditional');
860
+ if (init_custom) {
861
+ var field = $(this).closest('.cred-field');
862
+ if (field.length) {
863
+ _showHide(false, field);
864
+ }
865
+ }
866
+ })
867
+ }
868
 
869
  return {
870
  init: init,
embedded/common/toolset-forms/js/credfile.js CHANGED
@@ -1,70 +1,71 @@
1
 
2
- var wptCredfile = (function($) {
3
  function init(selector) {
4
- $(document).on( 'click', '.js-wpt-credfile-delete, .js-wpt-credfile-undo', function(e) {
5
- e.preventDefault();
6
- var thiz = $( this ),
7
- credfile_action = thiz.data( 'action' ),
8
- credfile_container = thiz.closest('.wpt-repctl');
9
- if ( credfile_container.length < 1 ) {
10
- credfile_container = thiz.closest('.js-wpt-field-items');
11
- }
12
- var thiz_delete_button = $( '.js-wpt-credfile-delete', credfile_container ),
13
- thiz_undo_button = $( '.js-wpt-credfile-undo', credfile_container ),
14
- thiz_hidden_input = $( '.js-wpv-credfile-hidden', credfile_container ),
15
- thiz_file_input = $( '.js-wpt-credfile-upload-file', credfile_container ),
16
- thiz_preview = $( '.js-wpt-credfile-preview', credfile_container ),
17
- thiz_existing_value = thiz_hidden_input.val();
18
- if ( credfile_action == 'delete' ) {
19
- thiz_file_input.prop('disabled', false).show().val( '' );
20
- thiz_hidden_input.prop('disabled', true);
21
- thiz_preview.hide();
22
- thiz_delete_button.hide();
23
- if ( thiz_existing_value != '' ) {
24
- thiz_undo_button.show();
25
- } else {
26
- thiz_undo_button.hide();
27
- }
28
- thiz_file_input.trigger( 'change' );
29
- } else if ( credfile_action == 'undo' ) {
30
- thiz_file_input.prop('disabled', true ).hide();
31
- thiz_hidden_input.prop( 'disabled', false );
32
- thiz_file_input.trigger( 'change' );
33
- thiz_preview.show();
34
- thiz_delete_button.show();
35
- thiz_undo_button.hide();
36
- }
37
- });
38
-
39
- $(document).on( 'change', '.js-wpt-credfile-upload-file', function(e) {
40
- e.preventDefault();
41
- var thiz = $( this ),
42
- credfile_container = thiz.closest('.wpt-repctl');
43
- if ( credfile_container.length < 1 ) {
44
- credfile_container = thiz.closest('.js-wpt-field-items');
45
- }
46
- var thiz_delete_button = $( '.js-wpt-credfile-delete', credfile_container ),
47
- thiz_undo_button = $( '.js-wpt-credfile-undo', credfile_container ),
48
- thiz_hidden_input = $( '.js-wpv-credfile-hidden', credfile_container ),
49
- thiz_preview = $( '.js-wpt-credfile-preview', credfile_container ),
50
- thiz_existing_value = thiz_hidden_input.val();
51
- if ( thiz.val() != '' ) {
52
- thiz_delete_button.show();
53
- } else {
54
- thiz_delete_button.hide();
55
- }
56
- if ( thiz_existing_value != '' && thiz_existing_value != thiz.val() ) {
57
- thiz_undo_button.show();
58
- } else {
59
- thiz_undo_button.hide();
60
- }
61
- });
62
  }
63
  return {
64
  init: init
65
  };
66
  })(jQuery);
67
 
68
- jQuery(document).ready(function() {
69
  wptCredfile.init('body');
 
70
  });
1
 
2
+ var wptCredfile = (function ($) {
3
  function init(selector) {
4
+ $(document).on('click', '.js-wpt-credfile-delete, .js-wpt-credfile-undo', function (e) {
5
+ e.preventDefault();
6
+ var thiz = $(this),
7
+ credfile_action = thiz.data('action'),
8
+ credfile_container = thiz.closest('.wpt-repctl');
9
+ if (credfile_container.length < 1) {
10
+ credfile_container = thiz.closest('.js-wpt-field-items');
11
+ }
12
+ var thiz_delete_button = $('.js-wpt-credfile-delete', credfile_container),
13
+ thiz_undo_button = $('.js-wpt-credfile-undo', credfile_container),
14
+ thiz_hidden_input = $('.js-wpv-credfile-hidden', credfile_container),
15
+ thiz_file_input = $('.js-wpt-credfile-upload-file', credfile_container),
16
+ thiz_preview = $('.js-wpt-credfile-preview', credfile_container),
17
+ thiz_existing_value = thiz_hidden_input.val();
18
+ if (credfile_action == 'delete') {
19
+ thiz_file_input.prop('disabled', false).show().val('');
20
+ thiz_hidden_input.prop('disabled', true);
21
+ thiz_preview.hide();
22
+ thiz_delete_button.hide();
23
+ if (thiz_existing_value != '') {
24
+ thiz_undo_button.show();
25
+ } else {
26
+ thiz_undo_button.hide();
27
+ }
28
+ thiz_file_input.trigger('change');
29
+ } else if (credfile_action == 'undo') {
30
+ thiz_file_input.prop('disabled', true).hide();
31
+ thiz_hidden_input.prop('disabled', false);
32
+ thiz_file_input.trigger('change');
33
+ thiz_preview.show();
34
+ thiz_delete_button.show();
35
+ thiz_undo_button.hide();
36
+ }
37
+ });
38
+
39
+ $(document).on('change', '.js-wpt-credfile-upload-file', function (e) {
40
+ e.preventDefault();
41
+ var thiz = $(this),
42
+ credfile_container = thiz.closest('.wpt-repctl');
43
+ if (credfile_container.length < 1) {
44
+ credfile_container = thiz.closest('.js-wpt-field-items');
45
+ }
46
+ var thiz_delete_button = $('.js-wpt-credfile-delete', credfile_container),
47
+ thiz_undo_button = $('.js-wpt-credfile-undo', credfile_container),
48
+ thiz_hidden_input = $('.js-wpv-credfile-hidden', credfile_container),
49
+ thiz_preview = $('.js-wpt-credfile-preview', credfile_container),
50
+ thiz_existing_value = thiz_hidden_input.val();
51
+ if (thiz.val() != '') {
52
+ thiz_delete_button.show();
53
+ } else {
54
+ thiz_delete_button.hide();
55
+ }
56
+ if (thiz_existing_value != '' && thiz_existing_value != thiz.val()) {
57
+ thiz_undo_button.show();
58
+ } else {
59
+ thiz_undo_button.hide();
60
+ }
61
+ });
62
  }
63
  return {
64
  init: init
65
  };
66
  })(jQuery);
67
 
68
+ jQuery(document).ready(function () {
69
  wptCredfile.init('body');
70
+
71
  });
embedded/common/toolset-forms/js/date.js CHANGED
@@ -1,68 +1,115 @@
1
-
2
- var wptDate = (function($) {
3
  var _tempConditions, _tempField;
4
  function init(parent) {
5
  if ($.isFunction($.fn.datepicker)) {
6
- $('input.js-wpt-date', $(parent)).each(function(index) {
7
  if (!$(this).is(':disabled') && !$(this).hasClass('hasDatepicker')) {
8
  a = wptDate.add($(this));
9
  //a.next().after('<span style="margin-left:10px"><i>' + wptDateData.dateFormatNote + '</i></span>').data( 'dateFormatNote', true );
10
  }
11
  });
12
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
14
 
15
  function add(el)
16
  {
17
  // Before anything, return if this is readonly
18
- if ( el.hasClass('js-wpv-date-readonly') ) {
19
- if ( !el.hasClass('js-wpv-date-readonly-added') ) {
20
- el.addClass('js-wpv-date-readonly-added').after('<img src="' + wptDateData.readonly_image + '" alt="' + wptDateData.readonly + '" title="' + wptDateData.readonly + '" class="ui-datepicker-readonly" />');
21
- }
22
- return;
23
- }
24
- // First, a hacky hack: make the id of each el unique, because the way they are produced on repetitive date fields does not ensure it
25
- var rand_number = 1 + Math.floor(Math.random() * 150),
26
- old_id = el.attr('id');
27
- el.attr('id', old_id + '-' + rand_number);
28
- // Walk along, nothing to see here...
29
- return el.datepicker({
30
- onSelect: function( dateText, inst ) {
31
- // The el_aux element depends on the scenario: backend or frontend
32
- var el_aux;
33
- el.val('');
34
- if ( el.closest('.js-wpt-field-item').length > 0 ) {
35
- el_aux = el.closest('.js-wpt-field-item').find('.js-wpt-date-auxiliar');
36
- } else if ( el.closest('.wpt-repctl').length > 0 ) {
37
- el_aux = el.closest('.wpt-repctl').find('.js-wpt-date-auxiliar');
38
- } else if ( el.closest('.js-wpt-field-items').length > 0 ) {
39
- el_aux = el.closest('.js-wpt-field-items').find('.js-wpt-date-auxiliar');
40
- } else {
41
- // This should be an empty object, but as we use the variable later we need to set it
42
- el_aux = el.closest('.js-wpt-field-items');
43
- }
44
- var data = 'date=' + dateText;
45
- data += '&date-format=' + wptDateData.dateFormatPhp;
46
- data += '&action=wpt_localize_extended_date';
47
- $.post( wptDateData.ajaxurl, data, function( response ) {
48
- response = $.parseJSON( response );
49
- if ( el_aux.length > 0 ) {
50
- el_aux.val( response['timestamp'] ).trigger('wptDateSelect');
51
- }
52
- el.val( response['display'] );
53
- });
54
- //el.trigger('wptDateSelect');
55
- },
56
- showOn: "both",
57
- buttonImage: wptDateData.buttonImage,
58
- buttonImageOnly: true,
59
- buttonText: wptDateData.buttonText,
60
- dateFormat: 'ddmmyy',
61
- //dateFormat: wptDateData.dateFormat,
62
- //altFormat: wptDateData.dateFormat,
63
- changeMonth: true,
64
- changeYear: true,
65
- yearRange: wptDateData.yearMin+':'+wptDateData.yearMax
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  });
67
  }
68
 
@@ -76,10 +123,10 @@ var wptDate = (function($) {
76
  wptCond.ajaxCheck(formID, _tempField, _tempConditions);
77
  }
78
  function ignoreConditional(val) {
79
- if ( '' == val ) {
80
  return '__ignore_negative';
81
  }
82
- return val;
83
  //return Date.parse(val);
84
  }
85
  function bindConditionalChange($trigger, func, formID) {
@@ -88,8 +135,9 @@ var wptDate = (function($) {
88
  //$trigger.on('keyup', lazy);
89
  return false;
90
  }
91
- function triggerAjax(func){
92
- if ($(this).val().length >= wptDateData.dateFormatPhp.length) func();
 
93
  }
94
  return {
95
  init: init,
@@ -102,23 +150,23 @@ var wptDate = (function($) {
102
  };
103
  })(jQuery);
104
 
105
- jQuery(document).ready(function() {
106
  wptDate.init('body');
107
  //fixing unknown Srdjan error
108
  jQuery('.ui-datepicker-inline').hide();
109
  });
110
 
111
- if ( 'undefined' != typeof(wptCallbacks) ) {
112
- wptCallbacks.reset.add(function(parent) {
113
  wptDate.init(parent);
114
  });
115
  wptCallbacks.addRepetitive.add(wptDate.init);
116
  }
117
 
118
  //add_action('conditional_check_date', wptDate.ajaxConditional, 10, 3);
119
- if ( 'function' == typeof(add_filter) ) {
120
  add_filter('conditional_value_date', wptDate.ignoreConditional, 10, 1);
121
  }
122
- if ( 'function' == typeof(add_action) ) {
123
  add_action('conditional_trigger_bind_date', wptDate.bindConditionalChange, 10, 3);
124
  }
1
+ var wptDate = (function ($) {
 
2
  var _tempConditions, _tempField;
3
  function init(parent) {
4
  if ($.isFunction($.fn.datepicker)) {
5
+ $('input.js-wpt-date', $(parent)).each(function (index) {
6
  if (!$(this).is(':disabled') && !$(this).hasClass('hasDatepicker')) {
7
  a = wptDate.add($(this));
8
  //a.next().after('<span style="margin-left:10px"><i>' + wptDateData.dateFormatNote + '</i></span>').data( 'dateFormatNote', true );
9
  }
10
  });
11
  }
12
+
13
+ $(document).on('click', '.js-wpt-date-clear', function () {
14
+ var thiz = $(this), thiz_close, el, el_aux, el_select;
15
+ if (thiz.closest('.js-wpt-field-item').length > 0) {
16
+ thiz_close = thiz.closest('.js-wpt-field-item');
17
+ el_aux = thiz_close.find('.js-wpt-date-auxiliar');
18
+ el = thiz_close.find('.js-wpt-date');
19
+ el_select = thiz_close.find('select');
20
+ } else if (thiz.closest('.wpt-repctl').length > 0) {
21
+ thiz_close = thiz.closest('.wpt-repctl');
22
+ el_aux = thiz_close.find('.js-wpt-date-auxiliar');
23
+ el = thiz_close.find('.js-wpt-date');
24
+ el_select = thiz_close.find('select');
25
+ } else if (thiz.closest('.js-wpt-field-items').length > 0) {
26
+ thiz_close = thiz.closest('.js-wpt-field-items');
27
+ el_aux = thiz_close.find('.js-wpt-date-auxiliar');
28
+ el = thiz_close.find('.js-wpt-date');
29
+ el_select = thiz_close.find('select');
30
+ } else {
31
+ // This should be an empty object, but as we use the variable later we need to set it
32
+ el_aux = thiz.closest('.js-wpt-field-items');
33
+ el = thiz.closest('.js-wpt-date');
34
+ el_select = thiz.closest('select');
35
+ }
36
+ //Added trigger('wptDateSelect'); fix trigger validation and condition on click of clear
37
+ el_aux.val('').trigger('change').trigger('wptDateSelect');
38
+ el.val('');
39
+ el_select.val('0');
40
+ thiz.hide();
41
+
42
+ });
43
  }
44
 
45
  function add(el)
46
  {
47
  // Before anything, return if this is readonly
48
+ if (el.hasClass('js-wpv-date-readonly')) {
49
+ if (!el.hasClass('js-wpv-date-readonly-added')) {
50
+ el.addClass('js-wpv-date-readonly-added').after('<img src="' + wptDateData.readonly_image + '" alt="' + wptDateData.readonly + '" title="' + wptDateData.readonly + '" class="ui-datepicker-readonly" />');
51
+ }
52
+ return;
53
+ }
54
+ // First, a hacky hack: make the id of each el unique, because the way they are produced on repetitive date fields does not ensure it
55
+ var rand_number = 1 + Math.floor(Math.random() * 150),
56
+ old_id = el.attr('id');
57
+ el.attr('id', old_id + '-' + rand_number);
58
+ // Walk along, nothing to see here...
59
+ return el.datepicker({
60
+ onSelect: function (dateText, inst) {
61
+ // The el_aux element depends on the scenario: backend or frontend
62
+ var el_close, el_aux, el_clear;
63
+ el.val('');
64
+ if (el.closest('.js-wpt-field-item').length > 0) {
65
+ el_close = el.closest('.js-wpt-field-item');
66
+ el_aux = el_close.find('.js-wpt-date-auxiliar');
67
+ el_clear = el_close.find('.js-wpt-date-clear');
68
+ } else if (el.closest('.wpt-repctl').length > 0) {
69
+ el_close = el.closest('.wpt-repctl');
70
+ el_aux = el_close.find('.js-wpt-date-auxiliar');
71
+ el_clear = el_close.find('.js-wpt-date-clear');
72
+ } else if (el.closest('.js-wpt-field-items').length > 0) {
73
+ el_close = el.closest('.js-wpt-field-items');
74
+ el_aux = el_close.find('.js-wpt-date-auxiliar');
75
+ el_clear = el_close.find('.js-wpt-date-clear');
76
+ } else {
77
+ // This should be an empty object, but as we use the variable later we need to set it
78
+ el_aux = el.closest('.js-wpt-field-items');
79
+ el_clear = el.closest('.js-wpt-date-clear');
80
+ }
81
+ var data = 'date=' + dateText;
82
+ data += '&date-format=' + wptDateData.dateFormatPhp;
83
+ data += '&action=wpt_localize_extended_date';
84
+
85
+ $.post(wptDateData.ajaxurl, data, function (response) {
86
+ response = $.parseJSON(response);
87
+ if (el_aux.length > 0) {
88
+ el_aux.val(response['timestamp']).trigger('wptDateSelect');
89
+ }
90
+ el.val(response['display']);
91
+ el_clear.show();
92
+
93
+ //Fix adding remove label on date
94
+ el.prev('label.wpt-form-error').remove();
95
+ });
96
+ //el.trigger('wptDateSelect');
97
+ },
98
+ showOn: "both",
99
+ buttonImage: wptDateData.buttonImage,
100
+ buttonImageOnly: true,
101
+ buttonText: wptDateData.buttonText,
102
+ dateFormat: 'ddmmyy',
103
+ //dateFormat: wptDateData.dateFormat,
104
+ //altFormat: wptDateData.dateFormat,
105
+ changeMonth: true,
106
+ changeYear: true,
107
+ yearRange: wptDateData.yearMin + ':' + wptDateData.yearMax,
108
+ beforeShow: function(input) {
109
+ $(input).css({
110
+ zIndex: 159999 // media library has z-index 160000
111
+ })
112
+ }
113
  });
114
  }
115
 
123
  wptCond.ajaxCheck(formID, _tempField, _tempConditions);
124
  }
125
  function ignoreConditional(val) {
126
+ if ('' == val) {
127
  return '__ignore_negative';
128
  }
129
+ return val;
130
  //return Date.parse(val);
131
  }
132
  function bindConditionalChange($trigger, func, formID) {
135
  //$trigger.on('keyup', lazy);
136
  return false;
137
  }
138
+ function triggerAjax(func) {
139
+ if ($(this).val().length >= wptDateData.dateFormatPhp.length)
140
+ func();
141
  }
142
  return {
143
  init: init,
150
  };
151
  })(jQuery);
152
 
153
+ jQuery(document).ready(function () {
154
  wptDate.init('body');
155
  //fixing unknown Srdjan error
156
  jQuery('.ui-datepicker-inline').hide();
157
  });
158
 
159
+ if ('undefined' != typeof (wptCallbacks)) {
160
+ wptCallbacks.reset.add(function (parent) {
161
  wptDate.init(parent);
162
  });
163
  wptCallbacks.addRepetitive.add(wptDate.init);
164
  }
165
 
166
  //add_action('conditional_check_date', wptDate.ajaxConditional, 10, 3);
167
+ if ('function' == typeof (add_filter)) {
168
  add_filter('conditional_value_date', wptDate.ignoreConditional, 10, 1);
169
  }
170
+ if ('function' == typeof (add_action)) {
171
  add_action('conditional_trigger_bind_date', wptDate.bindConditionalChange, 10, 3);
172
  }
embedded/common/toolset-forms/js/file-wp35.js ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ *
3
+ *
4
+ */
5
+ var wptFile = (function($, w) {
6
+ var frame = [];
7
+ var $item, $parent, $preview;
8
+
9
+ function init() {
10
+ // Fetch available headers and apply jQuery.masonry
11
+ // once the images have loaded.
12
+ var $headers = $('.available-headers');
13
+
14
+ $headers.imagesLoaded( function() {
15
+ $headers.masonry({
16
+ itemSelector: '.default-header',
17
+ isRTL: !! ( 'undefined' != typeof isRtl && isRtl )
18
+ });
19
+ });
20
+ /*
21
+ $('.js-wpt-field').on('click', 'a.js-wpt-file-upload', function() {
22
+ if ( $(this).data('attched-thickbox') ) {
23
+ return;
24
+ }
25
+ return wptFile.open(this, true);
26
+ });
27
+ */
28
+ // Build the choose from library frame.
29
+ $('.js-wpt-field').on('click', 'a.js-wpt-file-upload', function( event ) {
30
+ wptFile.bindOpen($(this), event);
31
+ });
32
+ }
33
+
34
+ function bindOpen($el, event)
35
+ {
36
+ var $type = $el.data('wpt-type');
37
+ var $id = $el.parent().attr('id');
38
+
39
+ if ( event ) {
40
+ event.preventDefault();
41
+ }
42
+
43
+ // If the media frame already exists, reopen it.
44
+ if ( frame[$id] ) {
45
+ frame[$id].open();
46
+ return;
47
+ }
48
+
49
+ // Create the media frame.
50
+ frame[$id] = wp.media.frames.customHeader = wp.media({
51
+ // Set the title of the modal.
52
+ title: $el.html(),
53
+
54
+ // Tell the modal to show only images.
55
+ library: {
56
+ type: 'file' == $type? null:$type
57
+ },
58
+
59
+ // Customize the submit button.
60
+ button: {
61
+ // Set the text of the button.
62
+ text: $el.data('update'),
63
+ // Tell the button not to close the modal, since we're
64
+ // going to refresh the page when the image is selected.
65
+ close: false
66
+ }
67
+ });
68
+
69
+ // When an image is selected, run a callback.
70
+ frame[$id].on( 'select', function() {
71
+ // Grab the selected attachment.
72
+ var attachment = frame[$id].state().get('selection').first();
73
+ var $parent = $el.parent();
74
+ switch( $type ) {
75
+ case 'image':
76
+ $('.textfield', $parent).val(attachment.attributes.sizes.full.url);
77
+ if ( 0 == $('.wpt-file-preview img', $parent.parent()).length) {
78
+ $('.wpt-file-preview', $parent.parent()).append('<img src="">');
79
+ }
80
+ if ( 'undefined' != typeof attachment.attributes.sizes.thumbnail ) {
81
+ $('.wpt-file-preview img', $parent.parent()).attr('src', attachment.attributes.sizes.thumbnail.url);
82
+ } else {
83
+ $('.wpt-file-preview img', $parent.parent()).attr('src', attachment.attributes.sizes.full.url);
84
+ }
85
+ $('.wpt-file-preview img', $parent.parent()).data('full-src', attachment.attributes.sizes.full.url);
86
+ if ( 'function' == typeof bind_colorbox_to_thumbnail_preview) {
87
+ bind_colorbox_to_thumbnail_preview();
88
+ }
89
+ break;
90
+ default:
91
+ $('.textfield', $parent).val(attachment.attributes.url);
92
+ break;
93
+ }
94
+ frame[$id].close();
95
+ });
96
+
97
+ frame[$id].open();
98
+ }
99
+
100
+ return {
101
+ init: init,
102
+ bindOpen: bindOpen,
103
+ };
104
+ })(jQuery);
105
+
106
+ jQuery(document).ready(wptFile.init);
107
+
embedded/common/toolset-forms/js/file.js DELETED
@@ -1,68 +0,0 @@
1
- /**
2
- *
3
- * $HeadURL: http://plugins.svn.wordpress.org/types/tags/1.6.2/embedded/common/toolset-forms/js/file.js $
4
- * $LastChangedDate: 2014-08-22 01:02:43 +0000 (Fri, 22 Aug 2014) $
5
- * $LastChangedRevision: 970205 $
6
- * $LastChangedBy: brucepearson $
7
- *
8
- */
9
- var wptFile = (function($, w) {
10
- var $item, $parent, $preview;
11
- function init() {
12
- $('.js-wpt-field').on('click', 'a.js-wpt-file-upload', function() {
13
- if ( $(this).data('attched-thickbox') ) {
14
- return;
15
- }
16
- return wptFile.open(this, true);
17
- });
18
- }
19
- function initRow(row) {
20
- $('.js-wpt-field', row).on('click', 'a.js-wpt-file-upload', function() {
21
- $(this).data('attched-thickbox', true );
22
- return wptFile.open(this, true);
23
- });
24
- }
25
- function mediaInsert(url, type) {
26
- $(':input', $item).first().val(url);
27
- if (type == 'image') {
28
- $preview.html('<img src="' + url + '" />');
29
- } else {
30
- $preview.html('');
31
- }
32
- tb_remove();
33
- }
34
- function mediaInsertTrigger(guid, type) {
35
- window.parent.wptFile.mediaInsert(guid, type);
36
- window.parent.jQuery('#TB_closeWindowButton').trigger('click');
37
- }
38
- function open(el)
39
- {
40
- height = $('body').height()-20;
41
- if ( 800 < height ) {
42
- height = 800;
43
- }
44
- width = $('body').width()-20;
45
- if ( 670 < width ) {
46
- width = 670;
47
- }
48
- $item = $(el).parents('.js-wpt-field-item');
49
- $parent = $item.parents('.js-wpt-field');
50
- $preview = $('.js-wpt-file-preview', $item);
51
- type = 'file';
52
- if ( $(el).data('wpt-type') ) {
53
- type = $(el).data('wpt-type');
54
- }
55
- tb_show(wptFileData.title, wptFileData.adminurl + 'media-upload.php?' + wptFileData.for_post + 'type='+type+'&context=wpt-fields-media-insert&wpt[id]=' + $parent.data('wpt-id') + '&wpt[type]=' + $parent.data('wpt-type') + '&TB_iframe=true&width='+width+'&height='+height);
56
- return false;
57
- }
58
- return {
59
- init: init,
60
- initRow: initRow,
61
- open: open,
62
- mediaInsert: mediaInsert,
63
- mediaInsertTrigger: mediaInsertTrigger
64
- };
65
- })(jQuery);
66
-
67
- jQuery(document).ready(wptFile.init);
68
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
embedded/common/toolset-forms/js/img/loading.gif ADDED
Binary file
embedded/common/toolset-forms/js/img/progressbar.gif ADDED
Binary file
embedded/common/toolset-forms/js/jquery.autocomplete.js DELETED
@@ -1,507 +0,0 @@
1
- /*
2
- original jQuery plugin by http://www.pengoworks.com/workshop/jquery/autocomplete.htm
3
- just replaced $ with jQuery in order to be complaint with other JavaScript libraries.
4
- */
5
-
6
- jQuery.autocomplete = function(input, options) {
7
- // Create a link to self
8
- var me = this;
9
-
10
- // Create jQuery object for input element
11
- var $input = jQuery(input).attr("autocomplete", "off");
12
-
13
- // Apply inputClass if necessary
14
- if (options.inputClass) $input.addClass(options.inputClass);
15
-
16
- // Create results
17
- var results = document.createElement("div");
18
- // Create jQuery object for results
19
- var $results = jQuery(results);
20
- $results.hide().addClass(options.resultsClass).css("position", "absolute");
21
- if( options.width > 0 ) $results.css("width", options.width);
22
-
23
- // Add to body element
24
- jQuery("body").append(results);
25
-
26
- input.autocompleter = me;
27
-
28
- var timeout = null;
29
- var prev = "";
30
- var active = -1;
31
- var cache = {};
32
- var keyb = false;
33
- var hasFocus = false;
34
- var lastKeyPressCode = null;
35
-
36
- // flush cache
37
- function flushCache(){
38
- cache = {};
39
- cache.data = {};
40
- cache.length = 0;
41
- };
42
-
43
- // flush cache
44
- flushCache();
45
-
46
- // if there is a data array supplied
47
- if( options.data != null ){
48
- var sFirstChar = "", stMatchSets = {}, row = [];
49
-
50
- // no url was specified, we need to adjust the cache length to make sure it fits the local data store
51
- if( typeof options.url != "string" ) options.cacheLength = 1;
52
-
53
- // loop through the array and create a lookup structure
54
- for( var i=0; i < options.data.length; i++ ){
55
- // if row is a string, make an array otherwise just reference the array
56
- row = ((typeof options.data[i] == "string") ? [options.data[i]] : options.data[i]);
57
-
58
- // if the length is zero, don't add to list
59
- if( row[0].length > 0 ){
60
- // get the first character
61
- sFirstChar = row[0].substring(0, 1).toLowerCase();
62
- // if no lookup array for this character exists, look it up now
63
- if( !stMatchSets[sFirstChar] ) stMatchSets[sFirstChar] = [];
64
- // if the match is a string
65
- stMatchSets[sFirstChar].push(row);
66
- }
67
- }
68
-
69
- // add the data items to the cache
70
- for( var k in stMatchSets ){
71
- // increase the cache size
72
- options.cacheLength++;
73
- // add to the cache
74
- addToCache(k, stMatchSets[k]);
75
- }
76
- }
77
-
78
- $input
79
- .keydown(function(e) {
80
- // track last key pressed
81
- lastKeyPressCode = e.keyCode;
82
- switch(e.keyCode) {
83
- case 38: // up
84
- e.preventDefault();
85
- moveSelect(-1);
86
- break;
87
- case 40: // down
88
- e.preventDefault();
89
- moveSelect(1);
90
- break;
91
- case 9: // tab
92
- case 13: // return
93
- if( selectCurrent() ){
94
- // make sure to blur off the current field
95
- $input.get(0).blur();
96
- e.preventDefault();
97
- }
98
- break;
99
- default:
100
- active = -1;
101
- if (timeout) clearTimeout(timeout);
102
- timeout = setTimeout(function(){onChange();}, options.delay);
103
- break;
104
- }
105
- })
106
- .focus(function(){
107
- // track whether the field has focus, we shouldn't process any results if the field no longer has focus
108
- hasFocus = true;
109
- })
110
- .blur(function() {
111
- // track whether the field has focus
112
- hasFocus = false;
113
- hideResults();
114
- });
115
-
116
- hideResultsNow();
117
-
118
- function onChange() {
119
- // ignore if the following keys are pressed: [del] [shift] [capslock]
120
- if( lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32) ) return $results.hide();
121
- var v = $input.val();
122
- if (v == prev) return;
123
- prev = v;
124
- if (v.length >= options.minChars) {
125
- $input.addClass(options.loadingClass);
126
- requestData(v);
127
- } else {
128
- $input.removeClass(options.loadingClass);
129
- $results.hide();
130
- }
131
- };
132
-
133
- function moveSelect(step) {
134
-
135
- var lis = jQuery("li", results);
136
- if (!lis) return;
137
-
138
- active += step;
139
-
140
- if (active < 0) {
141
- active = 0;
142
- } else if (active >= lis.size()) {
143
- active = lis.size() - 1;
144
- }
145
-
146
- lis.removeClass("ac_over");
147
-
148
- jQuery(lis[active]).addClass("ac_over");
149
-
150
- // Weird behaviour in IE
151
- // if (lis[active] && lis[active].scrollIntoView) {
152
- // lis[active].scrollIntoView(false);
153
- // }
154
-
155
- };
156
-
157
- function selectCurrent() {
158
- var li = jQuery("li.ac_over", results)[0];
159
- if (!li) {
160
- var $li = jQuery("li", results);
161
- if (options.selectOnly) {
162
- if ($li.length == 1) li = $li[0];
163
- } else if (options.selectFirst) {
164
- li = $li[0];
165
- }
166
- }
167
- if (li) {
168
- selectItem(li);
169
- return true;
170
- } else {
171
- return false;
172
- }
173
- };
174
-
175
- function selectItem(li) {
176
- if (!li) {
177
- li = document.createElement("li");
178
- li.extra = [];
179
- li.selectValue = "";
180
- }
181
- var v = jQuery.trim(li.selectValue ? li.selectValue : li.innerHTML);
182
- input.lastSelected = v;
183
- prev = v;
184
- $results.html("");
185
- $input.val(v);
186
- hideResultsNow();
187
- if (options.onItemSelect) setTimeout(function() { options.onItemSelect(li) }, 1);
188
- };
189
-
190
- // selects a portion of the input string
191
- function createSelection(start, end){
192
- // get a reference to the input element
193
- var field = $input.get(0);
194
- if( field.createTextRange ){
195
- var selRange = field.createTextRange();
196
- selRange.collapse(true);
197
- selRange.moveStart("character", start);
198
- selRange.moveEnd("character", end);
199
- selRange.select();
200
- } else if( field.setSelectionRange ){
201
- field.setSelectionRange(start, end);
202
- } else {
203
- if( field.selectionStart ){
204
- field.selectionStart = start;
205
- field.selectionEnd = end;
206
- }
207
- }
208
- field.focus();
209
- };
210
-
211
- // fills in the input box w/the first match (assumed to be the best match)
212
- function autoFill(sValue){
213
- // if the last user key pressed was backspace, don't autofill
214
- if( lastKeyPressCode != 8 ){
215
- // fill in the value (keep the case the user has typed)
216
- $input.val($input.val() + sValue.substring(prev.length));
217
- // select the portion of the value not typed by the user (so the next character will erase)
218
- createSelection(prev.length, sValue.length);
219
- }
220
- };
221
-
222
- function showResults() {
223
- // get the position of the input field right now (in case the DOM is shifted)
224
- var pos = findPos(input);
225
- // either use the specified width, or autocalculate based on form element
226
- var iWidth = (options.width > 0) ? options.width : $input.width();
227
- // reposition
228
- $results.css({
229
- width: parseInt(iWidth) + "px",
230
- top: (pos.y + input.offsetHeight + 28) + "px",
231
- left: pos.x + "px"
232
- }).show();
233
- };
234
-
235
- function hideResults() {
236
- if (timeout) clearTimeout(timeout);
237
- timeout = setTimeout(hideResultsNow, 200);
238
- };
239
-
240
- function hideResultsNow() {
241
- if (timeout) clearTimeout(timeout);
242
- $input.removeClass(options.loadingClass);
243
- if ($results.is(":visible")) {
244
- $results.hide();
245
- }
246
- if (options.mustMatch) {
247
- var v = $input.val();
248
- if (v != input.lastSelected) {
249
- selectItem(null);
250
- }
251
- }
252
- };
253
-
254
- function receiveData(q, data) {
255
- if (data) {
256
- $input.removeClass(options.loadingClass);
257
- results.innerHTML = "";
258
-
259
- // if the field no longer has focus or if there are no matches, do not display the drop down
260
- if( !hasFocus || data.length == 0 ) return hideResultsNow();
261
-
262
- if (jQuery.browser.msie) {
263
- // we put a styled iframe behind the calendar so HTML SELECT elements don't show through
264
- $results.append(document.createElement('iframe'));
265
- }
266
- results.appendChild(dataToDom(data));
267
- // autofill in the complete box w/the first match as long as the user hasn't entered in more data
268
- if( options.autoFill && ($input.val().toLowerCase() == q.toLowerCase()) ) autoFill(data[0][0]);
269
- showResults();
270
- } else {
271
- hideResultsNow();
272
- }
273
- };
274
-
275
- function parseData(data) {
276
- if (!data) return null;
277
- var parsed = [];
278
- var rows = data.split(options.lineSeparator);
279
- for (var i=0; i < rows.length; i++) {
280
- var row = jQuery.trim(rows[i]);
281
- if (row) {
282
- parsed[parsed.length] = row.split(options.cellSeparator);
283
- }
284
- }
285
- return parsed;
286
- };
287
-
288
- function dataToDom(data) {
289
- var ul = document.createElement("ul");
290
- var num = data.length;
291
-
292
- // limited results to a max number
293
- if( (options.maxItemsToShow > 0) && (options.maxItemsToShow < num) ) num = options.maxItemsToShow;
294
-
295
- for (var i=0; i < num; i++) {
296
- var row = data[i];
297
- if (!row) continue;
298
- var li = document.createElement("li");
299
- if (options.formatItem) {
300
- li.innerHTML = options.formatItem(row, i, num);
301
- li.selectValue = row[0];
302
- } else {
303
- li.innerHTML = row[0];
304
- li.selectValue = row[0];
305
- }
306
- var extra = null;
307
- if (row.length > 1) {
308
- extra = [];
309
- for (var j=1; j < row.length; j++) {
310
- extra[extra.length] = row[j];
311
- }
312
- }
313
- li.extra = extra;
314
- ul.appendChild(li);
315
- jQuery(li).hover(
316
- function() { jQuery("li", ul).removeClass("ac_over"); jQuery(this).addClass("ac_over"); active = jQuery("li", ul).indexOf(jQuery(this).get(0)); },
317
- function() { jQuery(this).removeClass("ac_over"); }
318
- ).click(function(e) { e.preventDefault(); e.stopPropagation(); selectItem(this) });
319
- }
320
- return ul;
321
- };
322
-
323
- function requestData(q) {
324
- if (!options.matchCase) q = q.toLowerCase();
325
- var data = options.cacheLength ? loadFromCache(q) : null;
326
- // recieve the cached data
327
- if (data) {
328
- receiveData(q, data);
329
- // if an AJAX url has been supplied, try loading the data now
330
- } else if( (typeof options.url == "string") && (options.url.length > 0) ){
331
- jQuery.get(makeUrl(q), function(data) {
332
- data = parseData(data);
333
- addToCache(q, data);
334
- receiveData(q, data);
335
- });
336
- // if there's been no data found, remove the loading class
337
- } else {
338
- $input.removeClass(options.loadingClass);
339
- }
340
- };
341
-
342
- function makeUrl(q) {
343
- var url = options.url + "?q=" + encodeURI(q);
344
- for (var i in options.extraParams) {
345
- url += "&" + i + "=" + encodeURI(options.extraParams[i]);
346
- }
347
- return url;
348
- };
349
-
350
- function loadFromCache(q) {
351
- if (!q) return null;
352
- if (cache.data[q]) return cache.data[q];
353
- if (options.matchSubset) {
354
- for (var i = q.length - 1; i >= options.minChars; i--) {
355
- var qs = q.substr(0, i);
356
- var c = cache.data[qs];
357
- if (c) {
358
- var csub = [];
359
- for (var j = 0; j < c.length; j++) {
360
- var x = c[j];
361
- var x0 = x[0];
362
- if (matchSubset(x0, q)) {
363
- csub[csub.length] = x;
364
- }
365
- }
366
- return csub;
367
- }
368
- }
369
- }
370
- return null;
371
- };
372
-
373
- function matchSubset(s, sub) {
374
- if (!options.matchCase) s = s.toLowerCase();
375
- var i = s.indexOf(sub);
376
- if (i == -1) return false;
377
- return i == 0 || options.matchContains;
378
- };
379
-
380
- this.flushCache = function() {
381
- flushCache();
382
- };
383
-
384
- this.setExtraParams = function(p) {
385
- options.extraParams = p;
386
- };
387
-
388
- this.findValue = function(){
389
- var q = $input.val();
390
-
391
- if (!options.matchCase) q = q.toLowerCase();
392
- var data = options.cacheLength ? loadFromCache(q) : null;
393
- if (data) {
394
- findValueCallback(q, data);
395
- } else if( (typeof options.url == "string") && (options.url.length > 0) ){
396
- jQuery.get(makeUrl(q), function(data) {
397
- data = parseData(data)
398
- addToCache(q, data);
399
- findValueCallback(q, data);
400
- });
401
- } else {
402
- // no matches
403
- findValueCallback(q, null);
404
- }
405
- }
406
-
407
- function findValueCallback(q, data){
408
- if (data) $input.removeClass(options.loadingClass);
409
-
410
- var num = (data) ? data.length : 0;
411
- var li = null;
412
-
413
- for (var i=0; i < num; i++) {
414
- var row = data[i];
415
-
416
- if( row[0].toLowerCase() == q.toLowerCase() ){
417
- li = document.createElement("li");
418
- if (options.formatItem) {
419
- li.innerHTML = options.formatItem(row, i, num);
420
- li.selectValue = row[0];
421
- } else {
422
- li.innerHTML = row[0];
423
- li.selectValue = row[0];
424
- }
425
- var extra = null;
426
- if( row.length > 1 ){
427
- extra = [];
428
- for (var j=1; j < row.length; j++) {
429
- extra[extra.length] = row[j];
430
- }
431
- }
432
- li.extra = extra;
433
- }
434
- }
435
-
436
- if( options.onFindValue ) setTimeout(function() { options.onFindValue(li) }, 1);
437
- }
438
-
439
- function addToCache(q, data) {
440
- if (!data || !q || !options.cacheLength) return;
441
- if (!cache.length || cache.length > options.cacheLength) {
442
- flushCache();
443
- cache.length++;
444
- } else if (!cache[q]) {
445
- cache.length++;
446
- }
447
- cache.data[q] = data;
448
- };
449
-
450
- function findPos(obj) {
451
- var curleft = obj.offsetLeft || 0;
452
- var curtop = obj.offsetTop || 0;
453
- while (obj = obj.offsetParent) {
454
- curleft += obj.offsetLeft
455
- curtop += obj.offsetTop
456
- }
457
- return {x:curleft,y:curtop};
458
- }
459
- }
460
-
461
- jQuery.fn.autocomplete = function(url, options, data) {
462
- // Make sure options exists
463
- options = options || {};
464
- // Set url as option
465
- options.url = url;
466
- // set some bulk local data
467
- options.data = ((typeof data == "object") && (data.constructor == Array)) ? data : null;
468
-
469
- // Set default values for required options
470
- options.inputClass = options.inputClass || "ac_input";
471
- options.resultsClass = options.resultsClass || "ac_results";
472
- options.lineSeparator = options.lineSeparator || "\n";
473
- options.cellSeparator = options.cellSeparator || "|";
474
- options.minChars = options.minChars || 1;
475
- options.delay = options.delay || 400;
476
- options.matchCase = options.matchCase || 0;
477
- options.matchSubset = options.matchSubset || 1;
478
- options.matchContains = options.matchContains || 0;
479
- options.cacheLength = options.cacheLength || 1;
480
- options.mustMatch = options.mustMatch || 0;
481
- options.extraParams = options.extraParams || {};
482
- options.loadingClass = options.loadingClass || "ac_loading";
483
- options.selectFirst = options.selectFirst || false;
484
- options.selectOnly = options.selectOnly || false;
485
- options.maxItemsToShow = options.maxItemsToShow || -1;
486
- options.autoFill = options.autoFill || false;
487
- options.width = parseInt(options.width, 10) || 0;
488
-
489
- this.each(function() {
490
- var input = this;
491
- new jQuery.autocomplete(input, options);
492
- });
493
-
494
- // Don't break the chain
495
- return this;
496
- }
497
-
498
- jQuery.fn.autocompleteArray = function(data, options) {
499
- return this.autocomplete(null, options, data);
500
- }
501
-
502
- jQuery.fn.indexOf = function(e){
503
- for( var i=0; i<this.length; i++ ){
504
- if( this[i] == e ) return i;
505
- }
506
- return -1;
507
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
embedded/common/toolset-forms/js/jquery_upload/file_upload.js ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //console.log(settings.ajaxurl);
2
+ //jQuery(function ()
3
+ //{
4
+ // // Variable to store your files
5
+ // var files;
6
+ //
7
+ // // Add events
8
+ // jQuery('input[type=file]').on('change', prepareUpload);
9
+ // jQuery('.cred-form').on('submit', uploadFiles);
10
+ //
11
+ // // Grab the files and set them to our variable
12
+ // function prepareUpload(event)
13
+ // {
14
+ // files = event.target.files;
15
+ // console.log(files);
16
+ // }
17
+ //
18
+ // // Catch the form submit and upload the files
19
+ // function uploadFiles(event)
20
+ // {
21
+ // event.stopPropagation(); // Stop stuff happening
22
+ // event.preventDefault(); // Totally stop stuff happening
23
+ //
24
+ // var data = new FormData();
25
+ // jQuery.each(jQuery('input[type="file"]')[0].files, function(i, file) {
26
+ // data.append('file-'+i, file);
27
+ // });
28
+ //
29
+ // jQuery.ajax({
30
+ // url: settings.ajaxurl+"?files",
31
+ // type: 'POST',
32
+ // data: data,
33
+ // cache: false,
34
+ // dataType: 'json',
35
+ // processData: false, // Don't process the files
36
+ // contentType: false, // Set content type to false as jQuery will tell the server its a query string request
37
+ // success: function (data, textStatus, jqXHR)
38
+ // {
39
+ // if (typeof data.error === 'undefined')
40
+ // {
41
+ // // Success so call function to process the form
42
+ // //submitForm(event, data);
43
+ // }
44
+ // else
45
+ // {
46
+ // // Handle errors here
47
+ // console.log('ERRORS: ' + data.error);
48
+ // }
49
+ // },
50
+ // error: function (jqXHR, textStatus, errorThrown)
51
+ // {
52
+ // // Handle errors here
53
+ // console.log('ERRORS: ' + textStatus);
54
+ // // STOP LOADING SPINNER
55
+ // }
56
+ // });
57
+ // }
58
+ //
59
+ // function submitForm(event, data)
60
+ // {
61
+ // // Create a jQuery object from the form
62
+ // jQueryform = jQuery(event.target);
63
+ //
64
+ // // Serialize the form data
65
+ // var formData = jQueryform.serialize();
66
+ //
67
+ // // You should sterilise the file names
68
+ // jQuery.each(data.files, function (key, value)
69
+ // {
70
+ // formData = formData + '&filenames[]=' + value;
71
+ // });
72
+ //
73
+ // jQuery.ajax({
74
+ // url: 'submit.php',
75
+ // type: 'POST',
76
+ // data: formData,
77
+ // cache: false,
78
+ // dataType: 'json',
79
+ // success: function (data, textStatus, jqXHR)
80
+ // {
81
+ // if (typeof data.error === 'undefined')
82
+ // {
83
+ // // Success so call function to process the form
84
+ // console.log('SUCCESS: ' + data.success);
85
+ // }
86
+ // else
87
+ // {
88
+ // // Handle errors here
89
+ // console.log('ERRORS: ' + data.error);
90
+ // }
91
+ // },
92
+ // error: function (jqXHR, textStatus, errorThrown)
93
+ // {
94
+ // // Handle errors here
95
+ // console.log('ERRORS: ' + textStatus);
96
+ // },
97
+ // complete: function ()
98
+ // {
99
+ // // STOP LOADING SPINNER
100
+ // }
101
+ // });
102
+ // }
103
+ //});
104
+
105
+ function getExtension(filename) {
106
+ return filename.split('.').pop().toLowerCase();
107
+ }
108
+
109
+ function isImage(file) {
110
+ switch (getExtension(file)) {
111
+ //if .jpg/.gif/.png do something
112
+ case 'jpg':
113
+ case 'gif':
114
+ case 'png':
115
+ case 'jpeg':
116
+ case 'bmp':
117
+ case 'svg':
118
+ return true;
119
+ break;
120
+
121
+ }
122
+ return false;
123
+ }
124
+
125
+ //new RegExp('/regex'+DATA-FROM-INPUT+'', 'i');
126
+ jQuery(function () {
127
+ 'use strict';
128
+ // Change this to the location of your server-side upload handler:
129
+ var url = settings.ajaxurl;
130
+ //console.log(url);
131
+ var nonce = jQuery("input[name='_cred_cred_wpnonce']").val();
132
+
133
+ console.log(nonce);
134
+
135
+ function o(i, file) {
136
+ //console.log(file);
137
+ var curr_file = file;
138
+ var validation = jQuery(curr_file).attr('data-wpt-validate');
139
+ //console.log(validation);
140
+ var obj_validation = jQuery.parseJSON(validation);
141
+
142
+ for (var x in obj_validation) {
143
+ if (x == 'extension') {
144
+ for (var y in obj_validation[x]) {
145
+ if (y == 'args') {
146
+ var validation_args = obj_validation[x][y][0];
147
+ //validation_args = validation_args.split('|').join(',');
148
+ }
149
+ if (y == 'message') {
150
+ var validation_message = obj_validation[x][y];
151
+ }
152
+ }
153
+
154
+
155
+ }
156
+ }
157
+
158
+ jQuery(file).fileupload({
159
+ url: url + "?un=" + nonce,
160
+ dataType: 'json',
161
+ //maxChunkSize: 10000000,
162
+ //formData: {nonce: nonce},
163
+ //acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
164
+ done: function (e, data) {
165
+ var id = jQuery(curr_file).attr('id');
166
+ var wpt_id = id.replace("_file", "");
167
+ //progress bar hide
168
+ jQuery('#progress_' + wpt_id).css({'width': '0%'});
169
+ jQuery('#progress_' + wpt_id).hide();
170
+
171
+ var delete_nonce = data.result.delete_nonce;
172
+ if (data._response.result.error && data._response.result.error != '') {
173
+ alert(data._response.result.error);
174
+ }
175
+ if (data.result.files) {
176
+ jQuery.each(data.result.files, function (index, file) {
177
+
178
+ var id = jQuery(curr_file).attr('id');
179
+ console.log(id);
180
+ var wpt_id = id.replace("_file", "");
181
+ // var wpt_id = jQuery(curr_file).attr('data-wpt-name');
182
+ // wpt_id = wpt_id.replace(/[^a-z0-9\-\_]/gi, '');
183
+ console.log(wpt_id);
184
+ var myid = wpt_id;
185
+ console.log(myid);
186
+
187
+ if (id.toLowerCase().indexOf("wpt-form-el") >= 0) {
188
+ var number = id.replace(/[^0-9]/g, '');
189
+ var new_num = number - 1;
190
+ var hidden_id = "wpt-form-el" + new_num;
191
+ } else
192
+ var hidden_id = wpt_id + '_hidden';
193
+
194
+ console.log(hidden_id);
195
+
196
+ //hidden text set
197
+ jQuery('#' + hidden_id).val(file);
198
+ jQuery('#' + hidden_id).prop('disabled', false);
199
+ //file field disabled and hided
200
+ jQuery('#' + id).hide();
201
+ jQuery('#' + id).prop('disabled', true);
202
+ //add image/file uploaded and button to delete
203
+ if (isImage(file)) {
204
+ jQuery("<img id='loaded_" + myid + "' src='" + file + "'><input id='butt_" + myid + "' style='width:100%;margin-top:2px;margin-bottom:2px;' type='button' value='delete' rel='" + file + "' class='delete_ajax_file'>").insertAfter('#' + jQuery(curr_file).attr('id'));
205
+ } else {
206
+ jQuery("<a id='loaded_" + myid + "' href='" + file + "' target='_blank'>" + file + "</a></label><input id='butt_" + myid + "' style='width:100%;margin-top:2px;margin-bottom:2px;' type='button' value='delete' rel='" + file + "' class='delete_ajax_file'>").insertAfter('#' + jQuery(curr_file).attr('id'));
207
+ }
208
+ //add function to delete button
209
+ jQuery("#butt_" + myid).on('click', function () {
210
+ if (confirm('Are you sure to delete this file ?')) {
211
+ jQuery("#loaded_" + myid).remove();
212
+ jQuery("#butt_" + myid).remove();
213
+
214
+ jQuery('#' + id).show();
215
+ jQuery('#' + id).prop('disabled', false);
216
+
217
+ jQuery('#' + hidden_id).val("");
218
+ jQuery('#' + hidden_id).prop('disabled', true);
219
+
220
+ jQuery.ajax({
221
+ url: url,
222
+ timeout: 10000,
223
+ type: 'POST',
224
+ data: {action: 'delete', file: file, nonce: delete_nonce},
225
+ dataType: 'json',
226
+ success: function (data)
227
+ {
228
+ console.log(data);
229
+ if (!data.result) {
230
+ if (data.error)
231
+ alert(data.error);
232
+ else
233
+ alert('Error deleting file !');
234
+ }
235
+ },
236
+ error: function ()
237
+ {
238
+ }
239
+ });
240
+ }
241
+ });
242
+ });
243
+ }
244
+ },
245
+ add: function (e, data) {
246
+ if (validation_args) {
247
+ var uploadErrors = [];
248
+ var acceptFileTypes = new RegExp('/regex' + validation_args + '', 'i'); //^image\/(gif|jpe?g|png)$/i;
249
+ if (data.originalFiles[0]['type'].length && !acceptFileTypes.test(data.originalFiles[0]['type'])) {
250
+ uploadErrors.push(validation_message);
251
+ }
252
+ if (data.originalFiles[0]['size'].length && data.originalFiles[0]['size'] > 5000000) {
253
+ uploadErrors.push('Filesize is too big');
254
+ }
255
+ if (uploadErrors.length > 0) {
256
+ alert(uploadErrors.join("\n"));
257
+ } else {
258
+ data.submit();
259
+ }
260
+ } else {
261
+ data.submit();
262
+ }
263
+
264
+ },
265
+ progressall: function (e, data) {
266
+ var progress = parseInt(data.loaded / data.total * 100, 10);
267
+ var id = jQuery(curr_file).attr('id');
268
+ var wpt_id = id.replace("_file", "");
269
+ jQuery('#progress_' + wpt_id).show();
270
+ jQuery('#progress_' + wpt_id + ' .progress-bar').css(
271
+ {'width': progress + '%'}
272
+ );
273
+ },
274
+ fail: function (e, data) {
275
+ var id = jQuery(curr_file).attr('id');
276
+ var wpt_id = id.replace("_file", "");
277
+ jQuery('#progress_' + wpt_id).hide();
278
+ jQuery('#progress_' + wpt_id).css({'width': '0%'});
279
+ alert("Upload Failed !");
280
+ }
281
+ }).prop('disabled', !jQuery.support.fileInput)
282
+ .parent().addClass(jQuery.support.fileInput ? undefined : 'disabled');
283
+
284
+ }
285
+
286
+ jQuery('input[type="file"]:not(#_featured_image_file)').each(o);
287
+
288
+ //AddRepetitive add event
289
+ wptCallbacks.addRepetitive.add(function () {
290
+ jQuery('input[type="file"]:not(#_featured_image_file)').each(o);
291
+ });
292
+
293
+ //AddRepetitive remove event
294
+ wptCallbacks.addRepetitive.remove(function () {
295
+ console.log("TODO: delete file related before removing")
296
+ });
297
+
298
+ // jQuery('.js-wpt-repadd').on('click', function (e) {
299
+ // e.preventDefault();
300
+ // alert("ciao");
301
+ // jQuery('input[type="file"]').each(o);
302
+ // });
303
+
304
+ });
embedded/common/toolset-forms/js/jquery_upload/jquery-ui.min.js ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*! jQuery UI - v1.11.1 - 2014-08-13
2
+ * http://jqueryui.com
3
+ * Includes: core.js, widget.js, mouse.js, position.js, accordion.js, autocomplete.js, button.js, datepicker.js, dialog.js, draggable.js, droppable.js, effect.js, effect-blind.js, effect-bounce.js, effect-clip.js, effect-drop.js, effect-explode.js, effect-fade.js, effect-fold.js, effect-highlight.js, effect-puff.js, effect-pulsate.js, effect-scale.js, effect-shake.js, effect-size.js, effect-slide.js, effect-transfer.js, menu.js, progressbar.js, resizable.js, selectable.js, selectmenu.js, slider.js, sortable.js, spinner.js, tabs.js, tooltip.js
4
+ * Copyright 2014 jQuery Foundation and other contributors; Licensed MIT */
5
+
6
+ (function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e(jQuery)})(function(e){function t(t,s){var n,a,o,r=t.nodeName.toLowerCase();return"area"===r?(n=t.parentNode,a=n.name,t.href&&a&&"map"===n.nodeName.toLowerCase()?(o=e("img[usemap='#"+a+"']")[0],!!o&&i(o)):!1):(/input|select|textarea|button|object/.test(r)?!t.disabled:"a"===r?t.href||s:s)&&i(t)}function i(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}function s(e){for(var t,i;e.length&&e[0]!==document;){if(t=e.css("position"),("absolute"===t||"relative"===t||"fixed"===t)&&(i=parseInt(e.css("zIndex"),10),!isNaN(i)&&0!==i))return i;e=e.parent()}return 0}function n(){this._curInst=null,this._keyEvent=!1,this._disabledInputs=[],this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId="ui-datepicker-div",this._inlineClass="ui-datepicker-inline",this._appendClass="ui-datepicker-append",this._triggerClass="ui-datepicker-trigger",this._dialogClass="ui-datepicker-dialog",this._disableClass="ui-datepicker-disabled",this._unselectableClass="ui-datepicker-unselectable",this._currentClass="ui-datepicker-current-day",this._dayOverClass="ui-datepicker-days-cell-over",this.regional=[],this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:""},this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:!1,hideIfNoPrevNext:!1,navigationAsDateFormat:!1,gotoCurrent:!1,changeMonth:!1,changeYear:!1,yearRange:"c-10:c+10",showOtherMonths:!1,selectOtherMonths:!1,showWeek:!1,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:!0,showButtonPanel:!1,autoSize:!1,disabled:!1},e.extend(this._defaults,this.regional[""]),this.regional.en=e.extend(!0,{},this.regional[""]),this.regional["en-US"]=e.extend(!0,{},this.regional.en),this.dpDiv=a(e("<div id='"+this._mainDivId+"' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"))}function a(t){var i="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return t.delegate(i,"mouseout",function(){e(this).removeClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&e(this).removeClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&e(this).removeClass("ui-datepicker-next-hover")}).delegate(i,"mouseover",o)}function o(){e.datepicker._isDisabledDatepicker(v.inline?v.dpDiv.parent()[0]:v.input[0])||(e(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),e(this).addClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&e(this).addClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&e(this).addClass("ui-datepicker-next-hover"))}function r(t,i){e.extend(t,i);for(var s in i)null==i[s]&&(t[s]=i[s]);return t}function h(e){return function(){var t=this.element.val();e.apply(this,arguments),this._refresh(),t!==this.element.val()&&this._trigger("change")}}e.ui=e.ui||{},e.extend(e.ui,{version:"1.11.1",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({scrollParent:function(t){var i=this.css("position"),s="absolute"===i,n=t?/(auto|scroll|hidden)/:/(auto|scroll)/,a=this.parents().filter(function(){var t=e(this);return s&&"static"===t.css("position")?!1:n.test(t.css("overflow")+t.css("overflow-y")+t.css("overflow-x"))}).eq(0);return"fixed"!==i&&a.length?a:e(this[0].ownerDocument||document)},uniqueId:function(){var e=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++e)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(i){return!!e.data(i,t)}}):function(t,i,s){return!!e.data(t,s[3])},focusable:function(i){return t(i,!isNaN(e.attr(i,"tabindex")))},tabbable:function(i){var s=e.attr(i,"tabindex"),n=isNaN(s);return(n||s>=0)&&t(i,!n)}}),e("<a>").outerWidth(1).jquery||e.each(["Width","Height"],function(t,i){function s(t,i,s,a){return e.each(n,function(){i-=parseFloat(e.css(t,"padding"+this))||0,s&&(i-=parseFloat(e.css(t,"border"+this+"Width"))||0),a&&(i-=parseFloat(e.css(t,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],a=i.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+i]=function(t){return void 0===t?o["inner"+i].call(this):this.each(function(){e(this).css(a,s(this,t)+"px")})},e.fn["outer"+i]=function(t,n){return"number"!=typeof t?o["outer"+i].call(this,t):this.each(function(){e(this).css(a,s(this,t,!0,n)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(i){return arguments.length?t.call(this,e.camelCase(i)):t.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.fn.extend({focus:function(t){return function(i,s){return"number"==typeof i?this.each(function(){var t=this;setTimeout(function(){e(t).focus(),s&&s.call(t)},i)}):t.apply(this,arguments)}}(e.fn.focus),disableSelection:function(){var e="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.bind(e+".ui-disableSelection",function(e){e.preventDefault()})}}(),enableSelection:function(){return this.unbind(".ui-disableSelection")},zIndex:function(t){if(void 0!==t)return this.css("zIndex",t);if(this.length)for(var i,s,n=e(this[0]);n.length&&n[0]!==document;){if(i=n.css("position"),("absolute"===i||"relative"===i||"fixed"===i)&&(s=parseInt(n.css("zIndex"),10),!isNaN(s)&&0!==s))return s;n=n.parent()}return 0}}),e.ui.plugin={add:function(t,i,s){var n,a=e.ui[t].prototype;for(n in s)a.plugins[n]=a.plugins[n]||[],a.plugins[n].push([i,s[n]])},call:function(e,t,i,s){var n,a=e.plugins[t];if(a&&(s||e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType))for(n=0;a.length>n;n++)e.options[a[n][0]]&&a[n][1].apply(e.element,i)}};var l=0,u=Array.prototype.slice;e.cleanData=function(t){return function(i){var s,n,a;for(a=0;null!=(n=i[a]);a++)try{s=e._data(n,"events"),s&&s.remove&&e(n).triggerHandler("remove")}catch(o){}t(i)}}(e.cleanData),e.widget=function(t,i,s){var n,a,o,r,h={},l=t.split(".")[0];return t=t.split(".")[1],n=l+"-"+t,s||(s=i,i=e.Widget),e.expr[":"][n.toLowerCase()]=function(t){return!!e.data(t,n)},e[l]=e[l]||{},a=e[l][t],o=e[l][t]=function(e,t){return this._createWidget?(arguments.length&&this._createWidget(e,t),void 0):new o(e,t)},e.extend(o,a,{version:s.version,_proto:e.extend({},s),_childConstructors:[]}),r=new i,r.options=e.widget.extend({},r.options),e.each(s,function(t,s){return e.isFunction(s)?(h[t]=function(){var e=function(){return i.prototype[t].apply(this,arguments)},n=function(e){return i.prototype[t].apply(this,e)};return function(){var t,i=this._super,a=this._superApply;return this._super=e,this._superApply=n,t=s.apply(this,arguments),this._super=i,this._superApply=a,t}}(),void 0):(h[t]=s,void 0)}),o.prototype=e.widget.extend(r,{widgetEventPrefix:a?r.widgetEventPrefix||t:t},h,{constructor:o,namespace:l,widgetName:t,widgetFullName:n}),a?(e.each(a._childConstructors,function(t,i){var s=i.prototype;e.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete a._childConstructors):i._childConstructors.push(o),e.widget.bridge(t,o),o},e.widget.extend=function(t){for(var i,s,n=u.call(arguments,1),a=0,o=n.length;o>a;a++)for(i in n[a])s=n[a][i],n[a].hasOwnProperty(i)&&void 0!==s&&(t[i]=e.isPlainObject(s)?e.isPlainObject(t[i])?e.widget.extend({},t[i],s):e.widget.extend({},s):s);return t},e.widget.bridge=function(t,i){var s=i.prototype.widgetFullName||t;e.fn[t]=function(n){var a="string"==typeof n,o=u.call(arguments,1),r=this;return n=!a&&o.length?e.widget.extend.apply(null,[n].concat(o)):n,a?this.each(function(){var i,a=e.data(this,s);return"instance"===n?(r=a,!1):a?e.isFunction(a[n])&&"_"!==n.charAt(0)?(i=a[n].apply(a,o),i!==a&&void 0!==i?(r=i&&i.jquery?r.pushStack(i.get()):i,!1):void 0):e.error("no such method '"+n+"' for "+t+" widget instance"):e.error("cannot call methods on "+t+" prior to initialization; "+"attempted to call method '"+n+"'")}):this.each(function(){var t=e.data(this,s);t?(t.option(n||{}),t._init&&t._init()):e.data(this,s,new i(n,this))}),r}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(t,i){i=e(i||this.defaultElement||this)[0],this.element=e(i),this.uuid=l++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),i!==this&&(e.data(i,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===i&&this.destroy()}}),this.document=e(i.style?i.ownerDocument:i.document||i),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(t,i){var s,n,a,o=t;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof t)if(o={},s=t.split("."),t=s.shift(),s.length){for(n=o[t]=e.widget.extend({},this.options[t]),a=0;s.length-1>a;a++)n[s[a]]=n[s[a]]||{},n=n[s[a]];if(t=s.pop(),1===arguments.length)return void 0===n[t]?null:n[t];n[t]=i}else{if(1===arguments.length)return void 0===this.options[t]?null:this.options[t];o[t]=i}return this._setOptions(o),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,"disabled"===e&&(this.widget().toggleClass(this.widgetFullName+"-disabled",!!t),t&&(this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus"))),this},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_on:function(t,i,s){var n,a=this;"boolean"!=typeof t&&(s=i,i=t,t=!1),s?(i=n=e(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),e.each(s,function(s,o){function r(){return t||a.options.disabled!==!0&&!e(this).hasClass("ui-state-disabled")?("string"==typeof o?a[o]:o).apply(a,arguments):void 0}"string"!=typeof o&&(r.guid=o.guid=o.guid||r.guid||e.guid++);var h=s.match(/^([\w:-]*)\s*(.*)$/),l=h[1]+a.eventNamespace,u=h[2];u?n.delegate(u,l,r):i.bind(l,r)})},_off:function(e,t){t=(t||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,e.unbind(t).undelegate(t)},_delay:function(e,t){function i(){return("string"==typeof e?s[e]:e).apply(s,arguments)}var s=this;return setTimeout(i,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,i,s){var n,a,o=this.options[t];if(s=s||{},i=e.Event(i),i.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),i.target=this.element[0],a=i.originalEvent)for(n in a)n in i||(i[n]=a[n]);return this.element.trigger(i,s),!(e.isFunction(o)&&o.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,i){e.Widget.prototype["_"+t]=function(s,n,a){"string"==typeof n&&(n={effect:n});var o,r=n?n===!0||"number"==typeof n?i:n.effect||i:t;n=n||{},"number"==typeof n&&(n={duration:n}),o=!e.isEmptyObject(n),n.complete=a,n.delay&&s.delay(n.delay),o&&e.effects&&e.effects.effect[r]?s[t](n):r!==t&&s[r]?s[r](n.duration,n.easing,a):s.queue(function(i){e(this)[t](),a&&a.call(s[0]),i()})}}),e.widget;var d=!1;e(document).mouseup(function(){d=!1}),e.widget("ui.mouse",{version:"1.11.1",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.bind("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).bind("click."+this.widgetName,function(i){return!0===e.data(i.target,t.widgetName+".preventClickEvent")?(e.removeData(i.target,t.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&this.document.unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(t){if(!d){this._mouseStarted&&this._mouseUp(t),this._mouseDownEvent=t;var i=this,s=1===t.which,n="string"==typeof this.options.cancel&&t.target.nodeName?e(t.target).closest(this.options.cancel).length:!1;return s&&!n&&this._mouseCapture(t)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(t)!==!1,!this._mouseStarted)?(t.preventDefault(),!0):(!0===e.data(t.target,this.widgetName+".preventClickEvent")&&e.removeData(t.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return i._mouseMove(e)},this._mouseUpDelegate=function(e){return i._mouseUp(e)},this.document.bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),t.preventDefault(),d=!0,!0)):!0}},_mouseMove:function(t){return e.ui.ie&&(!document.documentMode||9>document.documentMode)&&!t.button?this._mouseUp(t):t.which?this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,t)!==!1,this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted):this._mouseUp(t)},_mouseUp:function(t){return this.document.unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&e.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),d=!1,!1},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),function(){function t(e,t,i){return[parseFloat(e[0])*(p.test(e[0])?t/100:1),parseFloat(e[1])*(p.test(e[1])?i/100:1)]}function i(t,i){return parseInt(e.css(t,i),10)||0}function s(t){var i=t[0];return 9===i.nodeType?{width:t.width(),height:t.height(),offset:{top:0,left:0}}:e.isWindow(i)?{width:t.width(),height:t.height(),offset:{top:t.scrollTop(),left:t.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:t.outerWidth(),height:t.outerHeight(),offset:t.offset()}}e.ui=e.ui||{};var n,a,o=Math.max,r=Math.abs,h=Math.round,l=/left|center|right/,u=/top|center|bottom/,d=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,p=/%$/,f=e.fn.position;e.position={scrollbarWidth:function(){if(void 0!==n)return n;var t,i,s=e("<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),a=s.children()[0];return e("body").append(s),t=a.offsetWidth,s.css("overflow","scroll"),i=a.offsetWidth,t===i&&(i=s[0].clientWidth),s.remove(),n=t-i},getScrollInfo:function(t){var i=t.isWindow||t.isDocument?"":t.element.css("overflow-x"),s=t.isWindow||t.isDocument?"":t.element.css("overflow-y"),n="scroll"===i||"auto"===i&&t.width<t.element[0].scrollWidth,a="scroll"===s||"auto"===s&&t.height<t.element[0].scrollHeight;return{width:a?e.position.scrollbarWidth():0,height:n?e.position.scrollbarWidth():0}},getWithinInfo:function(t){var i=e(t||window),s=e.isWindow(i[0]),n=!!i[0]&&9===i[0].nodeType;return{element:i,isWindow:s,isDocument:n,offset:i.offset()||{left:0,top:0},scrollLeft:i.scrollLeft(),scrollTop:i.scrollTop(),width:s||n?i.width():i.outerWidth(),height:s||n?i.height():i.outerHeight()}}},e.fn.position=function(n){if(!n||!n.of)return f.apply(this,arguments);n=e.extend({},n);var p,m,g,v,y,b,_=e(n.of),x=e.position.getWithinInfo(n.within),w=e.position.getScrollInfo(x),k=(n.collision||"flip").split(" "),T={};return b=s(_),_[0].preventDefault&&(n.at="left top"),m=b.width,g=b.height,v=b.offset,y=e.extend({},v),e.each(["my","at"],function(){var e,t,i=(n[this]||"").split(" ");1===i.length&&(i=l.test(i[0])?i.concat(["center"]):u.test(i[0])?["center"].concat(i):["center","center"]),i[0]=l.test(i[0])?i[0]:"center",i[1]=u.test(i[1])?i[1]:"center",e=d.exec(i[0]),t=d.exec(i[1]),T[this]=[e?e[0]:0,t?t[0]:0],n[this]=[c.exec(i[0])[0],c.exec(i[1])[0]]}),1===k.length&&(k[1]=k[0]),"right"===n.at[0]?y.left+=m:"center"===n.at[0]&&(y.left+=m/2),"bottom"===n.at[1]?y.top+=g:"center"===n.at[1]&&(y.top+=g/2),p=t(T.at,m,g),y.left+=p[0],y.top+=p[1],this.each(function(){var s,l,u=e(this),d=u.outerWidth(),c=u.outerHeight(),f=i(this,"marginLeft"),b=i(this,"marginTop"),D=d+f+i(this,"marginRight")+w.width,S=c+b+i(this,"marginBottom")+w.height,M=e.extend({},y),N=t(T.my,u.outerWidth(),u.outerHeight());"right"===n.my[0]?M.left-=d:"center"===n.my[0]&&(M.left-=d/2),"bottom"===n.my[1]?M.top-=c:"center"===n.my[1]&&(M.top-=c/2),M.left+=N[0],M.top+=N[1],a||(M.left=h(M.left),M.top=h(M.top)),s={marginLeft:f,marginTop:b},e.each(["left","top"],function(t,i){e.ui.position[k[t]]&&e.ui.position[k[t]][i](M,{targetWidth:m,targetHeight:g,elemWidth:d,elemHeight:c,collisionPosition:s,collisionWidth:D,collisionHeight:S,offset:[p[0]+N[0],p[1]+N[1]],my:n.my,at:n.at,within:x,elem:u})}),n.using&&(l=function(e){var t=v.left-M.left,i=t+m-d,s=v.top-M.top,a=s+g-c,h={target:{element:_,left:v.left,top:v.top,width:m,height:g},element:{element:u,left:M.left,top:M.top,width:d,height:c},horizontal:0>i?"left":t>0?"right":"center",vertical:0>a?"top":s>0?"bottom":"middle"};d>m&&m>r(t+i)&&(h.horizontal="center"),c>g&&g>r(s+a)&&(h.vertical="middle"),h.important=o(r(t),r(i))>o(r(s),r(a))?"horizontal":"vertical",n.using.call(this,e,h)}),u.offset(e.extend(M,{using:l}))})},e.ui.position={fit:{left:function(e,t){var i,s=t.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=e.left-t.collisionPosition.marginLeft,h=n-r,l=r+t.collisionWidth-a-n;t.collisionWidth>a?h>0&&0>=l?(i=e.left+h+t.collisionWidth-a-n,e.left+=h-i):e.left=l>0&&0>=h?n:h>l?n+a-t.collisionWidth:n:h>0?e.left+=h:l>0?e.left-=l:e.left=o(e.left-r,e.left)},top:function(e,t){var i,s=t.within,n=s.isWindow?s.scrollTop:s.offset.top,a=t.within.height,r=e.top-t.collisionPosition.marginTop,h=n-r,l=r+t.collisionHeight-a-n;t.collisionHeight>a?h>0&&0>=l?(i=e.top+h+t.collisionHeight-a-n,e.top+=h-i):e.top=l>0&&0>=h?n:h>l?n+a-t.collisionHeight:n:h>0?e.top+=h:l>0?e.top-=l:e.top=o(e.top-r,e.top)}},flip:{left:function(e,t){var i,s,n=t.within,a=n.offset.left+n.scrollLeft,o=n.width,h=n.isWindow?n.scrollLeft:n.offset.left,l=e.left-t.collisionPosition.marginLeft,u=l-h,d=l+t.collisionWidth-o-h,c="left"===t.my[0]?-t.elemWidth:"right"===t.my[0]?t.elemWidth:0,p="left"===t.at[0]?t.targetWidth:"right"===t.at[0]?-t.targetWidth:0,f=-2*t.offset[0];0>u?(i=e.left+c+p+f+t.collisionWidth-o-a,(0>i||r(u)>i)&&(e.left+=c+p+f)):d>0&&(s=e.left-t.collisionPosition.marginLeft+c+p+f-h,(s>0||d>r(s))&&(e.left+=c+p+f))},top:function(e,t){var i,s,n=t.within,a=n.offset.top+n.scrollTop,o=n.height,h=n.isWindow?n.scrollTop:n.offset.top,l=e.top-t.collisionPosition.marginTop,u=l-h,d=l+t.collisionHeight-o-h,c="top"===t.my[1],p=c?-t.elemHeight:"bottom"===t.my[1]?t.elemHeight:0,f="top"===t.at[1]?t.targetHeight:"bottom"===t.at[1]?-t.targetHeight:0,m=-2*t.offset[1];0>u?(s=e.top+p+f+m+t.collisionHeight-o-a,e.top+p+f+m>u&&(0>s||r(u)>s)&&(e.top+=p+f+m)):d>0&&(i=e.top-t.collisionPosition.marginTop+p+f+m-h,e.top+p+f+m>d&&(i>0||d>r(i))&&(e.top+=p+f+m))}},flipfit:{left:function(){e.ui.position.flip.left.apply(this,arguments),e.ui.position.fit.left.apply(this,arguments)},top:function(){e.ui.position.flip.top.apply(this,arguments),e.ui.position.fit.top.apply(this,arguments)}}},function(){var t,i,s,n,o,r=document.getElementsByTagName("body")[0],h=document.createElement("div");t=document.createElement(r?"div":"body"),s={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},r&&e.extend(s,{position:"absolute",left:"-1000px",top:"-1000px"});for(o in s)t.style[o]=s[o];t.appendChild(h),i=r||document.documentElement,i.insertBefore(t,i.firstChild),h.style.cssText="position: absolute; left: 10.7432222px;",n=e(h).offset().left,a=n>10&&11>n,t.innerHTML="",i.removeChild(t)}()}(),e.ui.position,e.widget("ui.accordion",{version:"1.11.1",options:{active:0,animate:{},collapsible:!1,event:"click",header:"> li > :first-child,> :not(li):even",heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},hideProps:{borderTopWidth:"hide",borderBottomWidth:"hide",paddingTop:"hide",paddingBottom:"hide",height:"hide"},showProps:{borderTopWidth:"show",borderBottomWidth:"show",paddingTop:"show",paddingBottom:"show",height:"show"},_create:function(){var t=this.options;this.prevShow=this.prevHide=e(),this.element.addClass("ui-accordion ui-widget ui-helper-reset").attr("role","tablist"),t.collapsible||t.active!==!1&&null!=t.active||(t.active=0),this._processPanels(),0>t.active&&(t.active+=this.headers.length),this._refresh()},_getCreateEventData:function(){return{header:this.active,panel:this.active.length?this.active.next():e()}},_createIcons:function(){var t=this.options.icons;t&&(e("<span>").addClass("ui-accordion-header-icon ui-icon "+t.header).prependTo(this.headers),this.active.children(".ui-accordion-header-icon").removeClass(t.header).addClass(t.activeHeader),this.headers.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.removeClass("ui-accordion-icons").children(".ui-accordion-header-icon").remove()},_destroy:function(){var e;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"),this.headers.removeClass("ui-accordion-header ui-accordion-header-active ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("aria-controls").removeAttr("tabIndex").removeUniqueId(),this._destroyIcons(),e=this.headers.next().removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled").css("display","").removeAttr("role").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeUniqueId(),"content"!==this.options.heightStyle&&e.css("height","")},_setOption:function(e,t){return"active"===e?(this._activate(t),void 0):("event"===e&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(t)),this._super(e,t),"collapsible"!==e||t||this.options.active!==!1||this._activate(0),"icons"===e&&(this._destroyIcons(),t&&this._createIcons()),"disabled"===e&&(this.element.toggleClass("ui-state-disabled",!!t).attr("aria-disabled",t),this.headers.add(this.headers.next()).toggleClass("ui-state-disabled",!!t)),void 0)},_keydown:function(t){if(!t.altKey&&!t.ctrlKey){var i=e.ui.keyCode,s=this.headers.length,n=this.headers.index(t.target),a=!1;switch(t.keyCode){case i.RIGHT:case i.DOWN:a=this.headers[(n+1)%s];break;case i.LEFT:case i.UP:a=this.headers[(n-1+s)%s];break;case i.SPACE:case i.ENTER:this._eventHandler(t);break;case i.HOME:a=this.headers[0];break;case i.END:a=this.headers[s-1]}a&&(e(t.target).attr("tabIndex",-1),e(a).attr("tabIndex",0),a.focus(),t.preventDefault())}},_panelKeyDown:function(t){t.keyCode===e.ui.keyCode.UP&&t.ctrlKey&&e(t.currentTarget).prev().focus()},refresh:function(){var t=this.options;this._processPanels(),t.active===!1&&t.collapsible===!0||!this.headers.length?(t.active=!1,this.active=e()):t.active===!1?this._activate(0):this.active.length&&!e.contains(this.element[0],this.active[0])?this.headers.length===this.headers.find(".ui-state-disabled").length?(t.active=!1,this.active=e()):this._activate(Math.max(0,t.active-1)):t.active=this.headers.index(this.active),this._destroyIcons(),this._refresh()},_processPanels:function(){this.headers=this.element.find(this.options.header).addClass("ui-accordion-header ui-state-default ui-corner-all"),this.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").filter(":not(.ui-accordion-content-active)").hide()},_refresh:function(){var t,i=this.options,s=i.heightStyle,n=this.element.parent();this.active=this._findActive(i.active).addClass("ui-accordion-header-active ui-state-active ui-corner-top").removeClass("ui-corner-all"),this.active.next().addClass("ui-accordion-content-active").show(),this.headers.attr("role","tab").each(function(){var t=e(this),i=t.uniqueId().attr("id"),s=t.next(),n=s.uniqueId().attr("id");t.attr("aria-controls",n),s.attr("aria-labelledby",i)}).next().attr("role","tabpanel"),this.headers.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}).next().attr({"aria-hidden":"true"}).hide(),this.active.length?this.active.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}).next().attr({"aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0),this._createIcons(),this._setupEvents(i.event),"fill"===s?(t=n.height(),this.element.siblings(":visible").each(function(){var i=e(this),s=i.css("position");"absolute"!==s&&"fixed"!==s&&(t-=i.outerHeight(!0))}),this.headers.each(function(){t-=e(this).outerHeight(!0)}),this.headers.next().each(function(){e(this).height(Math.max(0,t-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):"auto"===s&&(t=0,this.headers.next().each(function(){t=Math.max(t,e(this).css("height","").height())}).height(t))},_activate:function(t){var i=this._findActive(t)[0];i!==this.active[0]&&(i=i||this.active[0],this._eventHandler({target:i,currentTarget:i,preventDefault:e.noop}))},_findActive:function(t){return"number"==typeof t?this.headers.eq(t):e()},_setupEvents:function(t){var i={keydown:"_keydown"};t&&e.each(t.split(" "),function(e,t){i[t]="_eventHandler"}),this._off(this.headers.add(this.headers.next())),this._on(this.headers,i),this._on(this.headers.next(),{keydown:"_panelKeyDown"}),this._hoverable(this.headers),this._focusable(this.headers)},_eventHandler:function(t){var i=this.options,s=this.active,n=e(t.currentTarget),a=n[0]===s[0],o=a&&i.collapsible,r=o?e():n.next(),h=s.next(),l={oldHeader:s,oldPanel:h,newHeader:o?e():n,newPanel:r};t.preventDefault(),a&&!i.collapsible||this._trigger("beforeActivate",t,l)===!1||(i.active=o?!1:this.headers.index(n),this.active=a?e():n,this._toggle(l),s.removeClass("ui-accordion-header-active ui-state-active"),i.icons&&s.children(".ui-accordion-header-icon").removeClass(i.icons.activeHeader).addClass(i.icons.header),a||(n.removeClass("ui-corner-all").addClass("ui-accordion-header-active ui-state-active ui-corner-top"),i.icons&&n.children(".ui-accordion-header-icon").removeClass(i.icons.header).addClass(i.icons.activeHeader),n.next().addClass("ui-accordion-content-active")))},_toggle:function(t){var i=t.newPanel,s=this.prevShow.length?this.prevShow:t.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=i,this.prevHide=s,this.options.animate?this._animate(i,s,t):(s.hide(),i.show(),this._toggleComplete(t)),s.attr({"aria-hidden":"true"}),s.prev().attr("aria-selected","false"),i.length&&s.length?s.prev().attr({tabIndex:-1,"aria-expanded":"false"}):i.length&&this.headers.filter(function(){return 0===e(this).attr("tabIndex")}).attr("tabIndex",-1),i.attr("aria-hidden","false").prev().attr({"aria-selected":"true",tabIndex:0,"aria-expanded":"true"})},_animate:function(e,t,i){var s,n,a,o=this,r=0,h=e.length&&(!t.length||e.index()<t.index()),l=this.options.animate||{},u=h&&l.down||l,d=function(){o._toggleComplete(i)};return"number"==typeof u&&(a=u),"string"==typeof u&&(n=u),n=n||u.easing||l.easing,a=a||u.duration||l.duration,t.length?e.length?(s=e.show().outerHeight(),t.animate(this.hideProps,{duration:a,easing:n,step:function(e,t){t.now=Math.round(e)}}),e.hide().animate(this.showProps,{duration:a,easing:n,complete:d,step:function(e,i){i.now=Math.round(e),"height"!==i.prop?r+=i.now:"content"!==o.options.heightStyle&&(i.now=Math.round(s-t.outerHeight()-r),r=0)}}),void 0):t.animate(this.hideProps,a,n,d):e.animate(this.showProps,a,n,d)},_toggleComplete:function(e){var t=e.oldPanel;t.removeClass("ui-accordion-content-active").prev().removeClass("ui-corner-top").addClass("ui-corner-all"),t.length&&(t.parent()[0].className=t.parent()[0].className),this._trigger("activate",null,e)}}),e.widget("ui.menu",{version:"1.11.1",defaultElement:"<ul>",delay:300,options:{icons:{submenu:"ui-icon-carat-1-e"},items:"> *",menus:"ul",position:{my:"left-1 top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.mouseHandled=!1,this.element.uniqueId().addClass("ui-menu ui-widget ui-widget-content").toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length).attr({role:this.options.role,tabIndex:0}),this.options.disabled&&this.element.addClass("ui-state-disabled").attr("aria-disabled","true"),this._on({"mousedown .ui-menu-item":function(e){e.preventDefault()},"click .ui-menu-item":function(t){var i=e(t.target);!this.mouseHandled&&i.not(".ui-state-disabled").length&&(this.select(t),t.isPropagationStopped()||(this.mouseHandled=!0),i.has(".ui-menu").length?this.expand(t):!this.element.is(":focus")&&e(this.document[0].activeElement).closest(".ui-menu").length&&(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(t){var i=e(t.currentTarget);i.siblings(".ui-state-active").removeClass("ui-state-active"),this.focus(t,i)},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(e,t){var i=this.active||this.element.find(this.options.items).eq(0);t||this.focus(e,i)},blur:function(t){this._delay(function(){e.contains(this.element[0],this.document[0].activeElement)||this.collapseAll(t)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(e){this._closeOnDocumentClick(e)&&this.collapseAll(e),this.mouseHandled=!1
7
+ }})},_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeClass("ui-menu ui-widget ui-widget-content ui-menu-icons ui-front").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show(),this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").removeUniqueId().removeClass("ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function(){var t=e(this);t.data("ui-menu-submenu-carat")&&t.remove()}),this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")},_keydown:function(t){function i(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}var s,n,a,o,r,h=!0;switch(t.keyCode){case e.ui.keyCode.PAGE_UP:this.previousPage(t);break;case e.ui.keyCode.PAGE_DOWN:this.nextPage(t);break;case e.ui.keyCode.HOME:this._move("first","first",t);break;case e.ui.keyCode.END:this._move("last","last",t);break;case e.ui.keyCode.UP:this.previous(t);break;case e.ui.keyCode.DOWN:this.next(t);break;case e.ui.keyCode.LEFT:this.collapse(t);break;case e.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(t);break;case e.ui.keyCode.ENTER:case e.ui.keyCode.SPACE:this._activate(t);break;case e.ui.keyCode.ESCAPE:this.collapse(t);break;default:h=!1,n=this.previousFilter||"",a=String.fromCharCode(t.keyCode),o=!1,clearTimeout(this.filterTimer),a===n?o=!0:a=n+a,r=RegExp("^"+i(a),"i"),s=this.activeMenu.find(this.options.items).filter(function(){return r.test(e(this).text())}),s=o&&-1!==s.index(this.active.next())?this.active.nextAll(".ui-menu-item"):s,s.length||(a=String.fromCharCode(t.keyCode),r=RegExp("^"+i(a),"i"),s=this.activeMenu.find(this.options.items).filter(function(){return r.test(e(this).text())})),s.length?(this.focus(t,s),s.length>1?(this.previousFilter=a,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter):delete this.previousFilter}h&&t.preventDefault()},_activate:function(e){this.active.is(".ui-state-disabled")||(this.active.is("[aria-haspopup='true']")?this.expand(e):this.select(e))},refresh:function(){var t,i,s=this,n=this.options.icons.submenu,a=this.element.find(this.options.menus);this.element.toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length),a.filter(":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-front").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var t=e(this),i=t.parent(),s=e("<span>").addClass("ui-menu-icon ui-icon "+n).data("ui-menu-submenu-carat",!0);i.attr("aria-haspopup","true").prepend(s),t.attr("aria-labelledby",i.attr("id"))}),t=a.add(this.element),i=t.find(this.options.items),i.not(".ui-menu-item").each(function(){var t=e(this);s._isDivider(t)&&t.addClass("ui-widget-content ui-menu-divider")}),i.not(".ui-menu-item, .ui-menu-divider").addClass("ui-menu-item").uniqueId().attr({tabIndex:-1,role:this._itemRole()}),i.filter(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!e.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},_setOption:function(e,t){"icons"===e&&this.element.find(".ui-menu-icon").removeClass(this.options.icons.submenu).addClass(t.submenu),"disabled"===e&&this.element.toggleClass("ui-state-disabled",!!t).attr("aria-disabled",t),this._super(e,t)},focus:function(e,t){var i,s;this.blur(e,e&&"focus"===e.type),this._scrollIntoView(t),this.active=t.first(),s=this.active.addClass("ui-state-focus").removeClass("ui-state-active"),this.options.role&&this.element.attr("aria-activedescendant",s.attr("id")),this.active.parent().closest(".ui-menu-item").addClass("ui-state-active"),e&&"keydown"===e.type?this._close():this.timer=this._delay(function(){this._close()},this.delay),i=t.children(".ui-menu"),i.length&&e&&/^mouse/.test(e.type)&&this._startOpening(i),this.activeMenu=t.parent(),this._trigger("focus",e,{item:t})},_scrollIntoView:function(t){var i,s,n,a,o,r;this._hasScroll()&&(i=parseFloat(e.css(this.activeMenu[0],"borderTopWidth"))||0,s=parseFloat(e.css(this.activeMenu[0],"paddingTop"))||0,n=t.offset().top-this.activeMenu.offset().top-i-s,a=this.activeMenu.scrollTop(),o=this.activeMenu.height(),r=t.outerHeight(),0>n?this.activeMenu.scrollTop(a+n):n+r>o&&this.activeMenu.scrollTop(a+n-o+r))},blur:function(e,t){t||clearTimeout(this.timer),this.active&&(this.active.removeClass("ui-state-focus"),this.active=null,this._trigger("blur",e,{item:this.active}))},_startOpening:function(e){clearTimeout(this.timer),"true"===e.attr("aria-hidden")&&(this.timer=this._delay(function(){this._close(),this._open(e)},this.delay))},_open:function(t){var i=e.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(t.parents(".ui-menu")).hide().attr("aria-hidden","true"),t.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(i)},collapseAll:function(t,i){clearTimeout(this.timer),this.timer=this._delay(function(){var s=i?this.element:e(t&&t.target).closest(this.element.find(".ui-menu"));s.length||(s=this.element),this._close(s),this.blur(t),this.activeMenu=s},this.delay)},_close:function(e){e||(e=this.active?this.active.parent():this.element),e.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false").end().find(".ui-state-active").not(".ui-state-focus").removeClass("ui-state-active")},_closeOnDocumentClick:function(t){return!e(t.target).closest(".ui-menu").length},_isDivider:function(e){return!/[^\-\u2014\u2013\s]/.test(e.text())},collapse:function(e){var t=this.active&&this.active.parent().closest(".ui-menu-item",this.element);t&&t.length&&(this._close(),this.focus(e,t))},expand:function(e){var t=this.active&&this.active.children(".ui-menu ").find(this.options.items).first();t&&t.length&&(this._open(t.parent()),this._delay(function(){this.focus(e,t)}))},next:function(e){this._move("next","first",e)},previous:function(e){this._move("prev","last",e)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_move:function(e,t,i){var s;this.active&&(s="first"===e||"last"===e?this.active["first"===e?"prevAll":"nextAll"](".ui-menu-item").eq(-1):this.active[e+"All"](".ui-menu-item").eq(0)),s&&s.length&&this.active||(s=this.activeMenu.find(this.options.items)[t]()),this.focus(i,s)},nextPage:function(t){var i,s,n;return this.active?(this.isLastItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){return i=e(this),0>i.offset().top-s-n}),this.focus(t,i)):this.focus(t,this.activeMenu.find(this.options.items)[this.active?"last":"first"]())),void 0):(this.next(t),void 0)},previousPage:function(t){var i,s,n;return this.active?(this.isFirstItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){return i=e(this),i.offset().top-s+n>0}),this.focus(t,i)):this.focus(t,this.activeMenu.find(this.options.items).first())),void 0):(this.next(t),void 0)},_hasScroll:function(){return this.element.outerHeight()<this.element.prop("scrollHeight")},select:function(t){this.active=this.active||e(t.target).closest(".ui-menu-item");var i={item:this.active};this.active.has(".ui-menu").length||this.collapseAll(t,!0),this._trigger("select",t,i)}}),e.widget("ui.autocomplete",{version:"1.11.1",defaultElement:"<input>",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,_create:function(){var t,i,s,n=this.element[0].nodeName.toLowerCase(),a="textarea"===n,o="input"===n;this.isMultiLine=a?!0:o?!1:this.element.prop("isContentEditable"),this.valueMethod=this.element[a||o?"val":"text"],this.isNewMenu=!0,this.element.addClass("ui-autocomplete-input").attr("autocomplete","off"),this._on(this.element,{keydown:function(n){if(this.element.prop("readOnly"))return t=!0,s=!0,i=!0,void 0;t=!1,s=!1,i=!1;var a=e.ui.keyCode;switch(n.keyCode){case a.PAGE_UP:t=!0,this._move("previousPage",n);break;case a.PAGE_DOWN:t=!0,this._move("nextPage",n);break;case a.UP:t=!0,this._keyEvent("previous",n);break;case a.DOWN:t=!0,this._keyEvent("next",n);break;case a.ENTER:this.menu.active&&(t=!0,n.preventDefault(),this.menu.select(n));break;case a.TAB:this.menu.active&&this.menu.select(n);break;case a.ESCAPE:this.menu.element.is(":visible")&&(this.isMultiLine||this._value(this.term),this.close(n),n.preventDefault());break;default:i=!0,this._searchTimeout(n)}},keypress:function(s){if(t)return t=!1,(!this.isMultiLine||this.menu.element.is(":visible"))&&s.preventDefault(),void 0;if(!i){var n=e.ui.keyCode;switch(s.keyCode){case n.PAGE_UP:this._move("previousPage",s);break;case n.PAGE_DOWN:this._move("nextPage",s);break;case n.UP:this._keyEvent("previous",s);break;case n.DOWN:this._keyEvent("next",s)}}},input:function(e){return s?(s=!1,e.preventDefault(),void 0):(this._searchTimeout(e),void 0)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(e){return this.cancelBlur?(delete this.cancelBlur,void 0):(clearTimeout(this.searching),this.close(e),this._change(e),void 0)}}),this._initSource(),this.menu=e("<ul>").addClass("ui-autocomplete ui-front").appendTo(this._appendTo()).menu({role:null}).hide().menu("instance"),this._on(this.menu.element,{mousedown:function(t){t.preventDefault(),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur});var i=this.menu.element[0];e(t.target).closest(".ui-menu-item").length||this._delay(function(){var t=this;this.document.one("mousedown",function(s){s.target===t.element[0]||s.target===i||e.contains(i,s.target)||t.close()})})},menufocus:function(t,i){var s,n;return this.isNewMenu&&(this.isNewMenu=!1,t.originalEvent&&/^mouse/.test(t.originalEvent.type))?(this.menu.blur(),this.document.one("mousemove",function(){e(t.target).trigger(t.originalEvent)}),void 0):(n=i.item.data("ui-autocomplete-item"),!1!==this._trigger("focus",t,{item:n})&&t.originalEvent&&/^key/.test(t.originalEvent.type)&&this._value(n.value),s=i.item.attr("aria-label")||n.value,s&&e.trim(s).length&&(this.liveRegion.children().hide(),e("<div>").text(s).appendTo(this.liveRegion)),void 0)},menuselect:function(e,t){var i=t.item.data("ui-autocomplete-item"),s=this.previous;this.element[0]!==this.document[0].activeElement&&(this.element.focus(),this.previous=s,this._delay(function(){this.previous=s,this.selectedItem=i})),!1!==this._trigger("select",e,{item:i})&&this._value(i.value),this.term=this._value(),this.close(e),this.selectedItem=i}}),this.liveRegion=e("<span>",{role:"status","aria-live":"assertive","aria-relevant":"additions"}).addClass("ui-helper-hidden-accessible").appendTo(this.document[0].body),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_destroy:function(){clearTimeout(this.searching),this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete"),this.menu.element.remove(),this.liveRegion.remove()},_setOption:function(e,t){this._super(e,t),"source"===e&&this._initSource(),"appendTo"===e&&this.menu.element.appendTo(this._appendTo()),"disabled"===e&&t&&this.xhr&&this.xhr.abort()},_appendTo:function(){var t=this.options.appendTo;return t&&(t=t.jquery||t.nodeType?e(t):this.document.find(t).eq(0)),t&&t[0]||(t=this.element.closest(".ui-front")),t.length||(t=this.document[0].body),t},_initSource:function(){var t,i,s=this;e.isArray(this.options.source)?(t=this.options.source,this.source=function(i,s){s(e.ui.autocomplete.filter(t,i.term))}):"string"==typeof this.options.source?(i=this.options.source,this.source=function(t,n){s.xhr&&s.xhr.abort(),s.xhr=e.ajax({url:i,data:t,dataType:"json",success:function(e){n(e)},error:function(){n([])}})}):this.source=this.options.source},_searchTimeout:function(e){clearTimeout(this.searching),this.searching=this._delay(function(){var t=this.term===this._value(),i=this.menu.element.is(":visible"),s=e.altKey||e.ctrlKey||e.metaKey||e.shiftKey;(!t||t&&!i&&!s)&&(this.selectedItem=null,this.search(null,e))},this.options.delay)},search:function(e,t){return e=null!=e?e:this._value(),this.term=this._value(),e.length<this.options.minLength?this.close(t):this._trigger("search",t)!==!1?this._search(e):void 0},_search:function(e){this.pending++,this.element.addClass("ui-autocomplete-loading"),this.cancelSearch=!1,this.source({term:e},this._response())},_response:function(){var t=++this.requestIndex;return e.proxy(function(e){t===this.requestIndex&&this.__response(e),this.pending--,this.pending||this.element.removeClass("ui-autocomplete-loading")},this)},__response:function(e){e&&(e=this._normalize(e)),this._trigger("response",null,{content:e}),!this.options.disabled&&e&&e.length&&!this.cancelSearch?(this._suggest(e),this._trigger("open")):this._close()},close:function(e){this.cancelSearch=!0,this._close(e)},_close:function(e){this.menu.element.is(":visible")&&(this.menu.element.hide(),this.menu.blur(),this.isNewMenu=!0,this._trigger("close",e))},_change:function(e){this.previous!==this._value()&&this._trigger("change",e,{item:this.selectedItem})},_normalize:function(t){return t.length&&t[0].label&&t[0].value?t:e.map(t,function(t){return"string"==typeof t?{label:t,value:t}:e.extend({},t,{label:t.label||t.value,value:t.value||t.label})})},_suggest:function(t){var i=this.menu.element.empty();this._renderMenu(i,t),this.isNewMenu=!0,this.menu.refresh(),i.show(),this._resizeMenu(),i.position(e.extend({of:this.element},this.options.position)),this.options.autoFocus&&this.menu.next()},_resizeMenu:function(){var e=this.menu.element;e.outerWidth(Math.max(e.width("").outerWidth()+1,this.element.outerWidth()))},_renderMenu:function(t,i){var s=this;e.each(i,function(e,i){s._renderItemData(t,i)})},_renderItemData:function(e,t){return this._renderItem(e,t).data("ui-autocomplete-item",t)},_renderItem:function(t,i){return e("<li>").text(i.label).appendTo(t)},_move:function(e,t){return this.menu.element.is(":visible")?this.menu.isFirstItem()&&/^previous/.test(e)||this.menu.isLastItem()&&/^next/.test(e)?(this.isMultiLine||this._value(this.term),this.menu.blur(),void 0):(this.menu[e](t),void 0):(this.search(null,t),void 0)},widget:function(){return this.menu.element},_value:function(){return this.valueMethod.apply(this.element,arguments)},_keyEvent:function(e,t){(!this.isMultiLine||this.menu.element.is(":visible"))&&(this._move(e,t),t.preventDefault())}}),e.extend(e.ui.autocomplete,{escapeRegex:function(e){return e.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},filter:function(t,i){var s=RegExp(e.ui.autocomplete.escapeRegex(i),"i");return e.grep(t,function(e){return s.test(e.label||e.value||e)})}}),e.widget("ui.autocomplete",e.ui.autocomplete,{options:{messages:{noResults:"No search results.",results:function(e){return e+(e>1?" results are":" result is")+" available, use up and down arrow keys to navigate."}}},__response:function(t){var i;this._superApply(arguments),this.options.disabled||this.cancelSearch||(i=t&&t.length?this.options.messages.results(t.length):this.options.messages.noResults,this.liveRegion.children().hide(),e("<div>").text(i).appendTo(this.liveRegion))}}),e.ui.autocomplete;var c,p="ui-button ui-widget ui-state-default ui-corner-all",f="ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only",m=function(){var t=e(this);setTimeout(function(){t.find(":ui-button").button("refresh")},1)},g=function(t){var i=t.name,s=t.form,n=e([]);return i&&(i=i.replace(/'/g,"\\'"),n=s?e(s).find("[name='"+i+"'][type=radio]"):e("[name='"+i+"'][type=radio]",t.ownerDocument).filter(function(){return!this.form})),n};e.widget("ui.button",{version:"1.11.1",defaultElement:"<button>",options:{disabled:null,text:!0,label:null,icons:{primary:null,secondary:null}},_create:function(){this.element.closest("form").unbind("reset"+this.eventNamespace).bind("reset"+this.eventNamespace,m),"boolean"!=typeof this.options.disabled?this.options.disabled=!!this.element.prop("disabled"):this.element.prop("disabled",this.options.disabled),this._determineButtonType(),this.hasTitle=!!this.buttonElement.attr("title");var t=this,i=this.options,s="checkbox"===this.type||"radio"===this.type,n=s?"":"ui-state-active";null===i.label&&(i.label="input"===this.type?this.buttonElement.val():this.buttonElement.html()),this._hoverable(this.buttonElement),this.buttonElement.addClass(p).attr("role","button").bind("mouseenter"+this.eventNamespace,function(){i.disabled||this===c&&e(this).addClass("ui-state-active")}).bind("mouseleave"+this.eventNamespace,function(){i.disabled||e(this).removeClass(n)}).bind("click"+this.eventNamespace,function(e){i.disabled&&(e.preventDefault(),e.stopImmediatePropagation())}),this._on({focus:function(){this.buttonElement.addClass("ui-state-focus")},blur:function(){this.buttonElement.removeClass("ui-state-focus")}}),s&&this.element.bind("change"+this.eventNamespace,function(){t.refresh()}),"checkbox"===this.type?this.buttonElement.bind("click"+this.eventNamespace,function(){return i.disabled?!1:void 0}):"radio"===this.type?this.buttonElement.bind("click"+this.eventNamespace,function(){if(i.disabled)return!1;e(this).addClass("ui-state-active"),t.buttonElement.attr("aria-pressed","true");var s=t.element[0];g(s).not(s).map(function(){return e(this).button("widget")[0]}).removeClass("ui-state-active").attr("aria-pressed","false")}):(this.buttonElement.bind("mousedown"+this.eventNamespace,function(){return i.disabled?!1:(e(this).addClass("ui-state-active"),c=this,t.document.one("mouseup",function(){c=null}),void 0)}).bind("mouseup"+this.eventNamespace,function(){return i.disabled?!1:(e(this).removeClass("ui-state-active"),void 0)}).bind("keydown"+this.eventNamespace,function(t){return i.disabled?!1:((t.keyCode===e.ui.keyCode.SPACE||t.keyCode===e.ui.keyCode.ENTER)&&e(this).addClass("ui-state-active"),void 0)}).bind("keyup"+this.eventNamespace+" blur"+this.eventNamespace,function(){e(this).removeClass("ui-state-active")}),this.buttonElement.is("a")&&this.buttonElement.keyup(function(t){t.keyCode===e.ui.keyCode.SPACE&&e(this).click()})),this._setOption("disabled",i.disabled),this._resetButton()},_determineButtonType:function(){var e,t,i;this.type=this.element.is("[type=checkbox]")?"checkbox":this.element.is("[type=radio]")?"radio":this.element.is("input")?"input":"button","checkbox"===this.type||"radio"===this.type?(e=this.element.parents().last(),t="label[for='"+this.element.attr("id")+"']",this.buttonElement=e.find(t),this.buttonElement.length||(e=e.length?e.siblings():this.element.siblings(),this.buttonElement=e.filter(t),this.buttonElement.length||(this.buttonElement=e.find(t))),this.element.addClass("ui-helper-hidden-accessible"),i=this.element.is(":checked"),i&&this.buttonElement.addClass("ui-state-active"),this.buttonElement.prop("aria-pressed",i)):this.buttonElement=this.element},widget:function(){return this.buttonElement},_destroy:function(){this.element.removeClass("ui-helper-hidden-accessible"),this.buttonElement.removeClass(p+" ui-state-active "+f).removeAttr("role").removeAttr("aria-pressed").html(this.buttonElement.find(".ui-button-text").html()),this.hasTitle||this.buttonElement.removeAttr("title")},_setOption:function(e,t){return this._super(e,t),"disabled"===e?(this.widget().toggleClass("ui-state-disabled",!!t),this.element.prop("disabled",!!t),t&&("checkbox"===this.type||"radio"===this.type?this.buttonElement.removeClass("ui-state-focus"):this.buttonElement.removeClass("ui-state-focus ui-state-active")),void 0):(this._resetButton(),void 0)},refresh:function(){var t=this.element.is("input, button")?this.element.is(":disabled"):this.element.hasClass("ui-button-disabled");t!==this.options.disabled&&this._setOption("disabled",t),"radio"===this.type?g(this.element[0]).each(function(){e(this).is(":checked")?e(this).button("widget").addClass("ui-state-active").attr("aria-pressed","true"):e(this).button("widget").removeClass("ui-state-active").attr("aria-pressed","false")}):"checkbox"===this.type&&(this.element.is(":checked")?this.buttonElement.addClass("ui-state-active").attr("aria-pressed","true"):this.buttonElement.removeClass("ui-state-active").attr("aria-pressed","false"))},_resetButton:function(){if("input"===this.type)return this.options.label&&this.element.val(this.options.label),void 0;var t=this.buttonElement.removeClass(f),i=e("<span></span>",this.document[0]).addClass("ui-button-text").html(this.options.label).appendTo(t.empty()).text(),s=this.options.icons,n=s.primary&&s.secondary,a=[];s.primary||s.secondary?(this.options.text&&a.push("ui-button-text-icon"+(n?"s":s.primary?"-primary":"-secondary")),s.primary&&t.prepend("<span class='ui-button-icon-primary ui-icon "+s.primary+"'></span>"),s.secondary&&t.append("<span class='ui-button-icon-secondary ui-icon "+s.secondary+"'></span>"),this.options.text||(a.push(n?"ui-button-icons-only":"ui-button-icon-only"),this.hasTitle||t.attr("title",e.trim(i)))):a.push("ui-button-text-only"),t.addClass(a.join(" "))}}),e.widget("ui.buttonset",{version:"1.11.1",options:{items:"button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(e,t){"disabled"===e&&this.buttons.button("option",e,t),this._super(e,t)},refresh:function(){var t="rtl"===this.element.css("direction"),i=this.element.find(this.options.items),s=i.filter(":ui-button");i.not(":ui-button").button(),s.button("refresh"),this.buttons=i.map(function(){return e(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(t?"ui-corner-right":"ui-corner-left").end().filter(":last").addClass(t?"ui-corner-left":"ui-corner-right").end().end()},_destroy:function(){this.element.removeClass("ui-buttonset"),this.buttons.map(function(){return e(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy")}}),e.ui.button,e.extend(e.ui,{datepicker:{version:"1.11.1"}});var v;e.extend(n.prototype,{markerClassName:"hasDatepicker",maxRows:4,_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(e){return r(this._defaults,e||{}),this},_attachDatepicker:function(t,i){var s,n,a;s=t.nodeName.toLowerCase(),n="div"===s||"span"===s,t.id||(this.uuid+=1,t.id="dp"+this.uuid),a=this._newInst(e(t),n),a.settings=e.extend({},i||{}),"input"===s?this._connectDatepicker(t,a):n&&this._inlineDatepicker(t,a)},_newInst:function(t,i){var s=t[0].id.replace(/([^A-Za-z0-9_\-])/g,"\\\\$1");return{id:s,input:t,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:i,dpDiv:i?a(e("<div class='"+this._inlineClass+" ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")):this.dpDiv}},_connectDatepicker:function(t,i){var s=e(t);i.append=e([]),i.trigger=e([]),s.hasClass(this.markerClassName)||(this._attachments(s,i),s.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp),this._autoSize(i),e.data(t,"datepicker",i),i.settings.disabled&&this._disableDatepicker(t))},_attachments:function(t,i){var s,n,a,o=this._get(i,"appendText"),r=this._get(i,"isRTL");i.append&&i.append.remove(),o&&(i.append=e("<span class='"+this._appendClass+"'>"+o+"</span>"),t[r?"before":"after"](i.append)),t.unbind("focus",this._showDatepicker),i.trigger&&i.trigger.remove(),s=this._get(i,"showOn"),("focus"===s||"both"===s)&&t.focus(this._showDatepicker),("button"===s||"both"===s)&&(n=this._get(i,"buttonText"),a=this._get(i,"buttonImage"),i.trigger=e(this._get(i,"buttonImageOnly")?e("<img/>").addClass(this._triggerClass).attr({src:a,alt:n,title:n}):e("<button type='button'></button>").addClass(this._triggerClass).html(a?e("<img/>").attr({src:a,alt:n,title:n}):n)),t[r?"before":"after"](i.trigger),i.trigger.click(function(){return e.datepicker._datepickerShowing&&e.datepicker._lastInput===t[0]?e.datepicker._hideDatepicker():e.datepicker._datepickerShowing&&e.datepicker._lastInput!==t[0]?(e.datepicker._hideDatepicker(),e.datepicker._showDatepicker(t[0])):e.datepicker._showDatepicker(t[0]),!1}))},_autoSize:function(e){if(this._get(e,"autoSize")&&!e.inline){var t,i,s,n,a=new Date(2009,11,20),o=this._get(e,"dateFormat");o.match(/[DM]/)&&(t=function(e){for(i=0,s=0,n=0;e.length>n;n++)e[n].length>i&&(i=e[n].length,s=n);return s},a.setMonth(t(this._get(e,o.match(/MM/)?"monthNames":"monthNamesShort"))),a.setDate(t(this._get(e,o.match(/DD/)?"dayNames":"dayNamesShort"))+20-a.getDay())),e.input.attr("size",this._formatDate(e,a).length)}},_inlineDatepicker:function(t,i){var s=e(t);s.hasClass(this.markerClassName)||(s.addClass(this.markerClassName).append(i.dpDiv),e.data(t,"datepicker",i),this._setDate(i,this._getDefaultDate(i),!0),this._updateDatepicker(i),this._updateAlternate(i),i.settings.disabled&&this._disableDatepicker(t),i.dpDiv.css("display","block"))},_dialogDatepicker:function(t,i,s,n,a){var o,h,l,u,d,c=this._dialogInst;return c||(this.uuid+=1,o="dp"+this.uuid,this._dialogInput=e("<input type='text' id='"+o+"' style='position: absolute; top: -100px; width: 0px;'/>"),this._dialogInput.keydown(this._doKeyDown),e("body").append(this._dialogInput),c=this._dialogInst=this._newInst(this._dialogInput,!1),c.settings={},e.data(this._dialogInput[0],"datepicker",c)),r(c.settings,n||{}),i=i&&i.constructor===Date?this._formatDate(c,i):i,this._dialogInput.val(i),this._pos=a?a.length?a:[a.pageX,a.pageY]:null,this._pos||(h=document.documentElement.clientWidth,l=document.documentElement.clientHeight,u=document.documentElement.scrollLeft||document.body.scrollLeft,d=document.documentElement.scrollTop||document.body.scrollTop,this._pos=[h/2-100+u,l/2-150+d]),this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px"),c.settings.onSelect=s,this._inDialog=!0,this.dpDiv.addClass(this._dialogClass),this._showDatepicker(this._dialogInput[0]),e.blockUI&&e.blockUI(this.dpDiv),e.data(this._dialogInput[0],"datepicker",c),this},_destroyDatepicker:function(t){var i,s=e(t),n=e.data(t,"datepicker");s.hasClass(this.markerClassName)&&(i=t.nodeName.toLowerCase(),e.removeData(t,"datepicker"),"input"===i?(n.append.remove(),n.trigger.remove(),s.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)):("div"===i||"span"===i)&&s.removeClass(this.markerClassName).empty())},_enableDatepicker:function(t){var i,s,n=e(t),a=e.data(t,"datepicker");n.hasClass(this.markerClassName)&&(i=t.nodeName.toLowerCase(),"input"===i?(t.disabled=!1,a.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""})):("div"===i||"span"===i)&&(s=n.children("."+this._inlineClass),s.children().removeClass("ui-state-disabled"),s.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!1)),this._disabledInputs=e.map(this._disabledInputs,function(e){return e===t?null:e}))},_disableDatepicker:function(t){var i,s,n=e(t),a=e.data(t,"datepicker");n.hasClass(this.markerClassName)&&(i=t.nodeName.toLowerCase(),"input"===i?(t.disabled=!0,a.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"})):("div"===i||"span"===i)&&(s=n.children("."+this._inlineClass),s.children().addClass("ui-state-disabled"),s.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!0)),this._disabledInputs=e.map(this._disabledInputs,function(e){return e===t?null:e}),this._disabledInputs[this._disabledInputs.length]=t)},_isDisabledDatepicker:function(e){if(!e)return!1;for(var t=0;this._disabledInputs.length>t;t++)if(this._disabledInputs[t]===e)return!0;return!1},_getInst:function(t){try{return e.data(t,"datepicker")}catch(i){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(t,i,s){var n,a,o,h,l=this._getInst(t);return 2===arguments.length&&"string"==typeof i?"defaults"===i?e.extend({},e.datepicker._defaults):l?"all"===i?e.extend({},l.settings):this._get(l,i):null:(n=i||{},"string"==typeof i&&(n={},n[i]=s),l&&(this._curInst===l&&this._hideDatepicker(),a=this._getDateDatepicker(t,!0),o=this._getMinMaxDate(l,"min"),h=this._getMinMaxDate(l,"max"),r(l.settings,n),null!==o&&void 0!==n.dateFormat&&void 0===n.minDate&&(l.settings.minDate=this._formatDate(l,o)),null!==h&&void 0!==n.dateFormat&&void 0===n.maxDate&&(l.settings.maxDate=this._formatDate(l,h)),"disabled"in n&&(n.disabled?this._disableDatepicker(t):this._enableDatepicker(t)),this._attachments(e(t),l),this._autoSize(l),this._setDate(l,a),this._updateAlternate(l),this._updateDatepicker(l)),void 0)},_changeDatepicker:function(e,t,i){this._optionDatepicker(e,t,i)},_refreshDatepicker:function(e){var t=this._getInst(e);t&&this._updateDatepicker(t)},_setDateDatepicker:function(e,t){var i=this._getInst(e);i&&(this._setDate(i,t),this._updateDatepicker(i),this._updateAlternate(i))},_getDateDatepicker:function(e,t){var i=this._getInst(e);return i&&!i.inline&&this._setDateFromField(i,t),i?this._getDate(i):null},_doKeyDown:function(t){var i,s,n,a=e.datepicker._getInst(t.target),o=!0,r=a.dpDiv.is(".ui-datepicker-rtl");if(a._keyEvent=!0,e.datepicker._datepickerShowing)switch(t.keyCode){case 9:e.datepicker._hideDatepicker(),o=!1;break;case 13:return n=e("td."+e.datepicker._dayOverClass+":not(."+e.datepicker._currentClass+")",a.dpDiv),n[0]&&e.datepicker._selectDay(t.target,a.selectedMonth,a.selectedYear,n[0]),i=e.datepicker._get(a,"onSelect"),i?(s=e.datepicker._formatDate(a),i.apply(a.input?a.input[0]:null,[s,a])):e.datepicker._hideDatepicker(),!1;case 27:e.datepicker._hideDatepicker();break;case 33:e.datepicker._adjustDate(t.target,t.ctrlKey?-e.datepicker._get(a,"stepBigMonths"):-e.datepicker._get(a,"stepMonths"),"M");break;case 34:e.datepicker._adjustDate(t.target,t.ctrlKey?+e.datepicker._get(a,"stepBigMonths"):+e.datepicker._get(a,"stepMonths"),"M");break;case 35:(t.ctrlKey||t.metaKey)&&e.datepicker._clearDate(t.target),o=t.ctrlKey||t.metaKey;break;case 36:(t.ctrlKey||t.metaKey)&&e.datepicker._gotoToday(t.target),o=t.ctrlKey||t.metaKey;break;case 37:(t.ctrlKey||t.metaKey)&&e.datepicker._adjustDate(t.target,r?1:-1,"D"),o=t.ctrlKey||t.metaKey,t.originalEvent.altKey&&e.datepicker._adjustDate(t.target,t.ctrlKey?-e.datepicker._get(a,"stepBigMonths"):-e.datepicker._get(a,"stepMonths"),"M");break;case 38:(t.ctrlKey||t.metaKey)&&e.datepicker._adjustDate(t.target,-7,"D"),o=t.ctrlKey||t.metaKey;break;case 39:(t.ctrlKey||t.metaKey)&&e.datepicker._adjustDate(t.target,r?-1:1,"D"),o=t.ctrlKey||t.metaKey,t.originalEvent.altKey&&e.datepicker._adjustDate(t.target,t.ctrlKey?+e.datepicker._get(a,"stepBigMonths"):+e.datepicker._get(a,"stepMonths"),"M");break;case 40:(t.ctrlKey||t.metaKey)&&e.datepicker._adjustDate(t.target,7,"D"),o=t.ctrlKey||t.metaKey;break;default:o=!1}else 36===t.keyCode&&t.ctrlKey?e.datepicker._showDatepicker(this):o=!1;o&&(t.preventDefault(),t.stopPropagation())},_doKeyPress:function(t){var i,s,n=e.datepicker._getInst(t.target);return e.datepicker._get(n,"constrainInput")?(i=e.datepicker._possibleChars(e.datepicker._get(n,"dateFormat")),s=String.fromCharCode(null==t.charCode?t.keyCode:t.charCode),t.ctrlKey||t.metaKey||" ">s||!i||i.indexOf(s)>-1):void 0},_doKeyUp:function(t){var i,s=e.datepicker._getInst(t.target);if(s.input.val()!==s.lastVal)try{i=e.datepicker.parseDate(e.datepicker._get(s,"dateFormat"),s.input?s.input.val():null,e.datepicker._getFormatConfig(s)),i&&(e.datepicker._setDateFromField(s),e.datepicker._updateAlternate(s),e.datepicker._updateDatepicker(s))
8
+ }catch(n){}return!0},_showDatepicker:function(t){if(t=t.target||t,"input"!==t.nodeName.toLowerCase()&&(t=e("input",t.parentNode)[0]),!e.datepicker._isDisabledDatepicker(t)&&e.datepicker._lastInput!==t){var i,n,a,o,h,l,u;i=e.datepicker._getInst(t),e.datepicker._curInst&&e.datepicker._curInst!==i&&(e.datepicker._curInst.dpDiv.stop(!0,!0),i&&e.datepicker._datepickerShowing&&e.datepicker._hideDatepicker(e.datepicker._curInst.input[0])),n=e.datepicker._get(i,"beforeShow"),a=n?n.apply(t,[t,i]):{},a!==!1&&(r(i.settings,a),i.lastVal=null,e.datepicker._lastInput=t,e.datepicker._setDateFromField(i),e.datepicker._inDialog&&(t.value=""),e.datepicker._pos||(e.datepicker._pos=e.datepicker._findPos(t),e.datepicker._pos[1]+=t.offsetHeight),o=!1,e(t).parents().each(function(){return o|="fixed"===e(this).css("position"),!o}),h={left:e.datepicker._pos[0],top:e.datepicker._pos[1]},e.datepicker._pos=null,i.dpDiv.empty(),i.dpDiv.css({position:"absolute",display:"block",top:"-1000px"}),e.datepicker._updateDatepicker(i),h=e.datepicker._checkOffset(i,h,o),i.dpDiv.css({position:e.datepicker._inDialog&&e.blockUI?"static":o?"fixed":"absolute",display:"none",left:h.left+"px",top:h.top+"px"}),i.inline||(l=e.datepicker._get(i,"showAnim"),u=e.datepicker._get(i,"duration"),i.dpDiv.css("z-index",s(e(t))+1),e.datepicker._datepickerShowing=!0,e.effects&&e.effects.effect[l]?i.dpDiv.show(l,e.datepicker._get(i,"showOptions"),u):i.dpDiv[l||"show"](l?u:null),e.datepicker._shouldFocusInput(i)&&i.input.focus(),e.datepicker._curInst=i))}},_updateDatepicker:function(t){this.maxRows=4,v=t,t.dpDiv.empty().append(this._generateHTML(t)),this._attachHandlers(t);var i,s=this._getNumberOfMonths(t),n=s[1],a=17,r=t.dpDiv.find("."+this._dayOverClass+" a");r.length>0&&o.apply(r.get(0)),t.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""),n>1&&t.dpDiv.addClass("ui-datepicker-multi-"+n).css("width",a*n+"em"),t.dpDiv[(1!==s[0]||1!==s[1]?"add":"remove")+"Class"]("ui-datepicker-multi"),t.dpDiv[(this._get(t,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl"),t===e.datepicker._curInst&&e.datepicker._datepickerShowing&&e.datepicker._shouldFocusInput(t)&&t.input.focus(),t.yearshtml&&(i=t.yearshtml,setTimeout(function(){i===t.yearshtml&&t.yearshtml&&t.dpDiv.find("select.ui-datepicker-year:first").replaceWith(t.yearshtml),i=t.yearshtml=null},0))},_shouldFocusInput:function(e){return e.input&&e.input.is(":visible")&&!e.input.is(":disabled")&&!e.input.is(":focus")},_checkOffset:function(t,i,s){var n=t.dpDiv.outerWidth(),a=t.dpDiv.outerHeight(),o=t.input?t.input.outerWidth():0,r=t.input?t.input.outerHeight():0,h=document.documentElement.clientWidth+(s?0:e(document).scrollLeft()),l=document.documentElement.clientHeight+(s?0:e(document).scrollTop());return i.left-=this._get(t,"isRTL")?n-o:0,i.left-=s&&i.left===t.input.offset().left?e(document).scrollLeft():0,i.top-=s&&i.top===t.input.offset().top+r?e(document).scrollTop():0,i.left-=Math.min(i.left,i.left+n>h&&h>n?Math.abs(i.left+n-h):0),i.top-=Math.min(i.top,i.top+a>l&&l>a?Math.abs(a+r):0),i},_findPos:function(t){for(var i,s=this._getInst(t),n=this._get(s,"isRTL");t&&("hidden"===t.type||1!==t.nodeType||e.expr.filters.hidden(t));)t=t[n?"previousSibling":"nextSibling"];return i=e(t).offset(),[i.left,i.top]},_hideDatepicker:function(t){var i,s,n,a,o=this._curInst;!o||t&&o!==e.data(t,"datepicker")||this._datepickerShowing&&(i=this._get(o,"showAnim"),s=this._get(o,"duration"),n=function(){e.datepicker._tidyDialog(o)},e.effects&&(e.effects.effect[i]||e.effects[i])?o.dpDiv.hide(i,e.datepicker._get(o,"showOptions"),s,n):o.dpDiv["slideDown"===i?"slideUp":"fadeIn"===i?"fadeOut":"hide"](i?s:null,n),i||n(),this._datepickerShowing=!1,a=this._get(o,"onClose"),a&&a.apply(o.input?o.input[0]:null,[o.input?o.input.val():"",o]),this._lastInput=null,this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),e.blockUI&&(e.unblockUI(),e("body").append(this.dpDiv))),this._inDialog=!1)},_tidyDialog:function(e){e.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(t){if(e.datepicker._curInst){var i=e(t.target),s=e.datepicker._getInst(i[0]);(i[0].id!==e.datepicker._mainDivId&&0===i.parents("#"+e.datepicker._mainDivId).length&&!i.hasClass(e.datepicker.markerClassName)&&!i.closest("."+e.datepicker._triggerClass).length&&e.datepicker._datepickerShowing&&(!e.datepicker._inDialog||!e.blockUI)||i.hasClass(e.datepicker.markerClassName)&&e.datepicker._curInst!==s)&&e.datepicker._hideDatepicker()}},_adjustDate:function(t,i,s){var n=e(t),a=this._getInst(n[0]);this._isDisabledDatepicker(n[0])||(this._adjustInstDate(a,i+("M"===s?this._get(a,"showCurrentAtPos"):0),s),this._updateDatepicker(a))},_gotoToday:function(t){var i,s=e(t),n=this._getInst(s[0]);this._get(n,"gotoCurrent")&&n.currentDay?(n.selectedDay=n.currentDay,n.drawMonth=n.selectedMonth=n.currentMonth,n.drawYear=n.selectedYear=n.currentYear):(i=new Date,n.selectedDay=i.getDate(),n.drawMonth=n.selectedMonth=i.getMonth(),n.drawYear=n.selectedYear=i.getFullYear()),this._notifyChange(n),this._adjustDate(s)},_selectMonthYear:function(t,i,s){var n=e(t),a=this._getInst(n[0]);a["selected"+("M"===s?"Month":"Year")]=a["draw"+("M"===s?"Month":"Year")]=parseInt(i.options[i.selectedIndex].value,10),this._notifyChange(a),this._adjustDate(n)},_selectDay:function(t,i,s,n){var a,o=e(t);e(n).hasClass(this._unselectableClass)||this._isDisabledDatepicker(o[0])||(a=this._getInst(o[0]),a.selectedDay=a.currentDay=e("a",n).html(),a.selectedMonth=a.currentMonth=i,a.selectedYear=a.currentYear=s,this._selectDate(t,this._formatDate(a,a.currentDay,a.currentMonth,a.currentYear)))},_clearDate:function(t){var i=e(t);this._selectDate(i,"")},_selectDate:function(t,i){var s,n=e(t),a=this._getInst(n[0]);i=null!=i?i:this._formatDate(a),a.input&&a.input.val(i),this._updateAlternate(a),s=this._get(a,"onSelect"),s?s.apply(a.input?a.input[0]:null,[i,a]):a.input&&a.input.trigger("change"),a.inline?this._updateDatepicker(a):(this._hideDatepicker(),this._lastInput=a.input[0],"object"!=typeof a.input[0]&&a.input.focus(),this._lastInput=null)},_updateAlternate:function(t){var i,s,n,a=this._get(t,"altField");a&&(i=this._get(t,"altFormat")||this._get(t,"dateFormat"),s=this._getDate(t),n=this.formatDate(i,s,this._getFormatConfig(t)),e(a).each(function(){e(this).val(n)}))},noWeekends:function(e){var t=e.getDay();return[t>0&&6>t,""]},iso8601Week:function(e){var t,i=new Date(e.getTime());return i.setDate(i.getDate()+4-(i.getDay()||7)),t=i.getTime(),i.setMonth(0),i.setDate(1),Math.floor(Math.round((t-i)/864e5)/7)+1},parseDate:function(t,i,s){if(null==t||null==i)throw"Invalid arguments";if(i="object"==typeof i?""+i:i+"",""===i)return null;var n,a,o,r,h=0,l=(s?s.shortYearCutoff:null)||this._defaults.shortYearCutoff,u="string"!=typeof l?l:(new Date).getFullYear()%100+parseInt(l,10),d=(s?s.dayNamesShort:null)||this._defaults.dayNamesShort,c=(s?s.dayNames:null)||this._defaults.dayNames,p=(s?s.monthNamesShort:null)||this._defaults.monthNamesShort,f=(s?s.monthNames:null)||this._defaults.monthNames,m=-1,g=-1,v=-1,y=-1,b=!1,_=function(e){var i=t.length>n+1&&t.charAt(n+1)===e;return i&&n++,i},x=function(e){var t=_(e),s="@"===e?14:"!"===e?20:"y"===e&&t?4:"o"===e?3:2,n="y"===e?s:1,a=RegExp("^\\d{"+n+","+s+"}"),o=i.substring(h).match(a);if(!o)throw"Missing number at position "+h;return h+=o[0].length,parseInt(o[0],10)},w=function(t,s,n){var a=-1,o=e.map(_(t)?n:s,function(e,t){return[[t,e]]}).sort(function(e,t){return-(e[1].length-t[1].length)});if(e.each(o,function(e,t){var s=t[1];return i.substr(h,s.length).toLowerCase()===s.toLowerCase()?(a=t[0],h+=s.length,!1):void 0}),-1!==a)return a+1;throw"Unknown name at position "+h},k=function(){if(i.charAt(h)!==t.charAt(n))throw"Unexpected literal at position "+h;h++};for(n=0;t.length>n;n++)if(b)"'"!==t.charAt(n)||_("'")?k():b=!1;else switch(t.charAt(n)){case"d":v=x("d");break;case"D":w("D",d,c);break;case"o":y=x("o");break;case"m":g=x("m");break;case"M":g=w("M",p,f);break;case"y":m=x("y");break;case"@":r=new Date(x("@")),m=r.getFullYear(),g=r.getMonth()+1,v=r.getDate();break;case"!":r=new Date((x("!")-this._ticksTo1970)/1e4),m=r.getFullYear(),g=r.getMonth()+1,v=r.getDate();break;case"'":_("'")?k():b=!0;break;default:k()}if(i.length>h&&(o=i.substr(h),!/^\s+/.test(o)))throw"Extra/unparsed characters found in date: "+o;if(-1===m?m=(new Date).getFullYear():100>m&&(m+=(new Date).getFullYear()-(new Date).getFullYear()%100+(u>=m?0:-100)),y>-1)for(g=1,v=y;;){if(a=this._getDaysInMonth(m,g-1),a>=v)break;g++,v-=a}if(r=this._daylightSavingAdjust(new Date(m,g-1,v)),r.getFullYear()!==m||r.getMonth()+1!==g||r.getDate()!==v)throw"Invalid date";return r},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:1e7*60*60*24*(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925)),formatDate:function(e,t,i){if(!t)return"";var s,n=(i?i.dayNamesShort:null)||this._defaults.dayNamesShort,a=(i?i.dayNames:null)||this._defaults.dayNames,o=(i?i.monthNamesShort:null)||this._defaults.monthNamesShort,r=(i?i.monthNames:null)||this._defaults.monthNames,h=function(t){var i=e.length>s+1&&e.charAt(s+1)===t;return i&&s++,i},l=function(e,t,i){var s=""+t;if(h(e))for(;i>s.length;)s="0"+s;return s},u=function(e,t,i,s){return h(e)?s[t]:i[t]},d="",c=!1;if(t)for(s=0;e.length>s;s++)if(c)"'"!==e.charAt(s)||h("'")?d+=e.charAt(s):c=!1;else switch(e.charAt(s)){case"d":d+=l("d",t.getDate(),2);break;case"D":d+=u("D",t.getDay(),n,a);break;case"o":d+=l("o",Math.round((new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()-new Date(t.getFullYear(),0,0).getTime())/864e5),3);break;case"m":d+=l("m",t.getMonth()+1,2);break;case"M":d+=u("M",t.getMonth(),o,r);break;case"y":d+=h("y")?t.getFullYear():(10>t.getYear()%100?"0":"")+t.getYear()%100;break;case"@":d+=t.getTime();break;case"!":d+=1e4*t.getTime()+this._ticksTo1970;break;case"'":h("'")?d+="'":c=!0;break;default:d+=e.charAt(s)}return d},_possibleChars:function(e){var t,i="",s=!1,n=function(i){var s=e.length>t+1&&e.charAt(t+1)===i;return s&&t++,s};for(t=0;e.length>t;t++)if(s)"'"!==e.charAt(t)||n("'")?i+=e.charAt(t):s=!1;else switch(e.charAt(t)){case"d":case"m":case"y":case"@":i+="0123456789";break;case"D":case"M":return null;case"'":n("'")?i+="'":s=!0;break;default:i+=e.charAt(t)}return i},_get:function(e,t){return void 0!==e.settings[t]?e.settings[t]:this._defaults[t]},_setDateFromField:function(e,t){if(e.input.val()!==e.lastVal){var i=this._get(e,"dateFormat"),s=e.lastVal=e.input?e.input.val():null,n=this._getDefaultDate(e),a=n,o=this._getFormatConfig(e);try{a=this.parseDate(i,s,o)||n}catch(r){s=t?"":s}e.selectedDay=a.getDate(),e.drawMonth=e.selectedMonth=a.getMonth(),e.drawYear=e.selectedYear=a.getFullYear(),e.currentDay=s?a.getDate():0,e.currentMonth=s?a.getMonth():0,e.currentYear=s?a.getFullYear():0,this._adjustInstDate(e)}},_getDefaultDate:function(e){return this._restrictMinMax(e,this._determineDate(e,this._get(e,"defaultDate"),new Date))},_determineDate:function(t,i,s){var n=function(e){var t=new Date;return t.setDate(t.getDate()+e),t},a=function(i){try{return e.datepicker.parseDate(e.datepicker._get(t,"dateFormat"),i,e.datepicker._getFormatConfig(t))}catch(s){}for(var n=(i.toLowerCase().match(/^c/)?e.datepicker._getDate(t):null)||new Date,a=n.getFullYear(),o=n.getMonth(),r=n.getDate(),h=/([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,l=h.exec(i);l;){switch(l[2]||"d"){case"d":case"D":r+=parseInt(l[1],10);break;case"w":case"W":r+=7*parseInt(l[1],10);break;case"m":case"M":o+=parseInt(l[1],10),r=Math.min(r,e.datepicker._getDaysInMonth(a,o));break;case"y":case"Y":a+=parseInt(l[1],10),r=Math.min(r,e.datepicker._getDaysInMonth(a,o))}l=h.exec(i)}return new Date(a,o,r)},o=null==i||""===i?s:"string"==typeof i?a(i):"number"==typeof i?isNaN(i)?s:n(i):new Date(i.getTime());return o=o&&"Invalid Date"==""+o?s:o,o&&(o.setHours(0),o.setMinutes(0),o.setSeconds(0),o.setMilliseconds(0)),this._daylightSavingAdjust(o)},_daylightSavingAdjust:function(e){return e?(e.setHours(e.getHours()>12?e.getHours()+2:0),e):null},_setDate:function(e,t,i){var s=!t,n=e.selectedMonth,a=e.selectedYear,o=this._restrictMinMax(e,this._determineDate(e,t,new Date));e.selectedDay=e.currentDay=o.getDate(),e.drawMonth=e.selectedMonth=e.currentMonth=o.getMonth(),e.drawYear=e.selectedYear=e.currentYear=o.getFullYear(),n===e.selectedMonth&&a===e.selectedYear||i||this._notifyChange(e),this._adjustInstDate(e),e.input&&e.input.val(s?"":this._formatDate(e))},_getDate:function(e){var t=!e.currentYear||e.input&&""===e.input.val()?null:this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return t},_attachHandlers:function(t){var i=this._get(t,"stepMonths"),s="#"+t.id.replace(/\\\\/g,"\\");t.dpDiv.find("[data-handler]").map(function(){var t={prev:function(){e.datepicker._adjustDate(s,-i,"M")},next:function(){e.datepicker._adjustDate(s,+i,"M")},hide:function(){e.datepicker._hideDatepicker()},today:function(){e.datepicker._gotoToday(s)},selectDay:function(){return e.datepicker._selectDay(s,+this.getAttribute("data-month"),+this.getAttribute("data-year"),this),!1},selectMonth:function(){return e.datepicker._selectMonthYear(s,this,"M"),!1},selectYear:function(){return e.datepicker._selectMonthYear(s,this,"Y"),!1}};e(this).bind(this.getAttribute("data-event"),t[this.getAttribute("data-handler")])})},_generateHTML:function(e){var t,i,s,n,a,o,r,h,l,u,d,c,p,f,m,g,v,y,b,_,x,w,k,T,D,S,M,N,C,A,I,P,z,H,F,E,j,O,W,L=new Date,R=this._daylightSavingAdjust(new Date(L.getFullYear(),L.getMonth(),L.getDate())),Y=this._get(e,"isRTL"),B=this._get(e,"showButtonPanel"),J=this._get(e,"hideIfNoPrevNext"),q=this._get(e,"navigationAsDateFormat"),K=this._getNumberOfMonths(e),V=this._get(e,"showCurrentAtPos"),U=this._get(e,"stepMonths"),Q=1!==K[0]||1!==K[1],G=this._daylightSavingAdjust(e.currentDay?new Date(e.currentYear,e.currentMonth,e.currentDay):new Date(9999,9,9)),X=this._getMinMaxDate(e,"min"),$=this._getMinMaxDate(e,"max"),Z=e.drawMonth-V,et=e.drawYear;if(0>Z&&(Z+=12,et--),$)for(t=this._daylightSavingAdjust(new Date($.getFullYear(),$.getMonth()-K[0]*K[1]+1,$.getDate())),t=X&&X>t?X:t;this._daylightSavingAdjust(new Date(et,Z,1))>t;)Z--,0>Z&&(Z=11,et--);for(e.drawMonth=Z,e.drawYear=et,i=this._get(e,"prevText"),i=q?this.formatDate(i,this._daylightSavingAdjust(new Date(et,Z-U,1)),this._getFormatConfig(e)):i,s=this._canAdjustMonth(e,-1,et,Z)?"<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click' title='"+i+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"e":"w")+"'>"+i+"</span></a>":J?"":"<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='"+i+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"e":"w")+"'>"+i+"</span></a>",n=this._get(e,"nextText"),n=q?this.formatDate(n,this._daylightSavingAdjust(new Date(et,Z+U,1)),this._getFormatConfig(e)):n,a=this._canAdjustMonth(e,1,et,Z)?"<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click' title='"+n+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"w":"e")+"'>"+n+"</span></a>":J?"":"<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='"+n+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"w":"e")+"'>"+n+"</span></a>",o=this._get(e,"currentText"),r=this._get(e,"gotoCurrent")&&e.currentDay?G:R,o=q?this.formatDate(o,r,this._getFormatConfig(e)):o,h=e.inline?"":"<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>"+this._get(e,"closeText")+"</button>",l=B?"<div class='ui-datepicker-buttonpane ui-widget-content'>"+(Y?h:"")+(this._isInRange(e,r)?"<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'>"+o+"</button>":"")+(Y?"":h)+"</div>":"",u=parseInt(this._get(e,"firstDay"),10),u=isNaN(u)?0:u,d=this._get(e,"showWeek"),c=this._get(e,"dayNames"),p=this._get(e,"dayNamesMin"),f=this._get(e,"monthNames"),m=this._get(e,"monthNamesShort"),g=this._get(e,"beforeShowDay"),v=this._get(e,"showOtherMonths"),y=this._get(e,"selectOtherMonths"),b=this._getDefaultDate(e),_="",w=0;K[0]>w;w++){for(k="",this.maxRows=4,T=0;K[1]>T;T++){if(D=this._daylightSavingAdjust(new Date(et,Z,e.selectedDay)),S=" ui-corner-all",M="",Q){if(M+="<div class='ui-datepicker-group",K[1]>1)switch(T){case 0:M+=" ui-datepicker-group-first",S=" ui-corner-"+(Y?"right":"left");break;case K[1]-1:M+=" ui-datepicker-group-last",S=" ui-corner-"+(Y?"left":"right");break;default:M+=" ui-datepicker-group-middle",S=""}M+="'>"}for(M+="<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix"+S+"'>"+(/all|left/.test(S)&&0===w?Y?a:s:"")+(/all|right/.test(S)&&0===w?Y?s:a:"")+this._generateMonthYearHeader(e,Z,et,X,$,w>0||T>0,f,m)+"</div><table class='ui-datepicker-calendar'><thead>"+"<tr>",N=d?"<th class='ui-datepicker-week-col'>"+this._get(e,"weekHeader")+"</th>":"",x=0;7>x;x++)C=(x+u)%7,N+="<th scope='col'"+((x+u+6)%7>=5?" class='ui-datepicker-week-end'":"")+">"+"<span title='"+c[C]+"'>"+p[C]+"</span></th>";for(M+=N+"</tr></thead><tbody>",A=this._getDaysInMonth(et,Z),et===e.selectedYear&&Z===e.selectedMonth&&(e.selectedDay=Math.min(e.selectedDay,A)),I=(this._getFirstDayOfMonth(et,Z)-u+7)%7,P=Math.ceil((I+A)/7),z=Q?this.maxRows>P?this.maxRows:P:P,this.maxRows=z,H=this._daylightSavingAdjust(new Date(et,Z,1-I)),F=0;z>F;F++){for(M+="<tr>",E=d?"<td class='ui-datepicker-week-col'>"+this._get(e,"calculateWeek")(H)+"</td>":"",x=0;7>x;x++)j=g?g.apply(e.input?e.input[0]:null,[H]):[!0,""],O=H.getMonth()!==Z,W=O&&!y||!j[0]||X&&X>H||$&&H>$,E+="<td class='"+((x+u+6)%7>=5?" ui-datepicker-week-end":"")+(O?" ui-datepicker-other-month":"")+(H.getTime()===D.getTime()&&Z===e.selectedMonth&&e._keyEvent||b.getTime()===H.getTime()&&b.getTime()===D.getTime()?" "+this._dayOverClass:"")+(W?" "+this._unselectableClass+" ui-state-disabled":"")+(O&&!v?"":" "+j[1]+(H.getTime()===G.getTime()?" "+this._currentClass:"")+(H.getTime()===R.getTime()?" ui-datepicker-today":""))+"'"+(O&&!v||!j[2]?"":" title='"+j[2].replace(/'/g,"&#39;")+"'")+(W?"":" data-handler='selectDay' data-event='click' data-month='"+H.getMonth()+"' data-year='"+H.getFullYear()+"'")+">"+(O&&!v?"&#xa0;":W?"<span class='ui-state-default'>"+H.getDate()+"</span>":"<a class='ui-state-default"+(H.getTime()===R.getTime()?" ui-state-highlight":"")+(H.getTime()===G.getTime()?" ui-state-active":"")+(O?" ui-priority-secondary":"")+"' href='#'>"+H.getDate()+"</a>")+"</td>",H.setDate(H.getDate()+1),H=this._daylightSavingAdjust(H);M+=E+"</tr>"}Z++,Z>11&&(Z=0,et++),M+="</tbody></table>"+(Q?"</div>"+(K[0]>0&&T===K[1]-1?"<div class='ui-datepicker-row-break'></div>":""):""),k+=M}_+=k}return _+=l,e._keyEvent=!1,_},_generateMonthYearHeader:function(e,t,i,s,n,a,o,r){var h,l,u,d,c,p,f,m,g=this._get(e,"changeMonth"),v=this._get(e,"changeYear"),y=this._get(e,"showMonthAfterYear"),b="<div class='ui-datepicker-title'>",_="";if(a||!g)_+="<span class='ui-datepicker-month'>"+o[t]+"</span>";else{for(h=s&&s.getFullYear()===i,l=n&&n.getFullYear()===i,_+="<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>",u=0;12>u;u++)(!h||u>=s.getMonth())&&(!l||n.getMonth()>=u)&&(_+="<option value='"+u+"'"+(u===t?" selected='selected'":"")+">"+r[u]+"</option>");_+="</select>"}if(y||(b+=_+(!a&&g&&v?"":"&#xa0;")),!e.yearshtml)if(e.yearshtml="",a||!v)b+="<span class='ui-datepicker-year'>"+i+"</span>";else{for(d=this._get(e,"yearRange").split(":"),c=(new Date).getFullYear(),p=function(e){var t=e.match(/c[+\-].*/)?i+parseInt(e.substring(1),10):e.match(/[+\-].*/)?c+parseInt(e,10):parseInt(e,10);return isNaN(t)?c:t},f=p(d[0]),m=Math.max(f,p(d[1]||"")),f=s?Math.max(f,s.getFullYear()):f,m=n?Math.min(m,n.getFullYear()):m,e.yearshtml+="<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";m>=f;f++)e.yearshtml+="<option value='"+f+"'"+(f===i?" selected='selected'":"")+">"+f+"</option>";e.yearshtml+="</select>",b+=e.yearshtml,e.yearshtml=null}return b+=this._get(e,"yearSuffix"),y&&(b+=(!a&&g&&v?"":"&#xa0;")+_),b+="</div>"},_adjustInstDate:function(e,t,i){var s=e.drawYear+("Y"===i?t:0),n=e.drawMonth+("M"===i?t:0),a=Math.min(e.selectedDay,this._getDaysInMonth(s,n))+("D"===i?t:0),o=this._restrictMinMax(e,this._daylightSavingAdjust(new Date(s,n,a)));e.selectedDay=o.getDate(),e.drawMonth=e.selectedMonth=o.getMonth(),e.drawYear=e.selectedYear=o.getFullYear(),("M"===i||"Y"===i)&&this._notifyChange(e)},_restrictMinMax:function(e,t){var i=this._getMinMaxDate(e,"min"),s=this._getMinMaxDate(e,"max"),n=i&&i>t?i:t;return s&&n>s?s:n},_notifyChange:function(e){var t=this._get(e,"onChangeMonthYear");t&&t.apply(e.input?e.input[0]:null,[e.selectedYear,e.selectedMonth+1,e])},_getNumberOfMonths:function(e){var t=this._get(e,"numberOfMonths");return null==t?[1,1]:"number"==typeof t?[1,t]:t},_getMinMaxDate:function(e,t){return this._determineDate(e,this._get(e,t+"Date"),null)},_getDaysInMonth:function(e,t){return 32-this._daylightSavingAdjust(new Date(e,t,32)).getDate()},_getFirstDayOfMonth:function(e,t){return new Date(e,t,1).getDay()},_canAdjustMonth:function(e,t,i,s){var n=this._getNumberOfMonths(e),a=this._daylightSavingAdjust(new Date(i,s+(0>t?t:n[0]*n[1]),1));return 0>t&&a.setDate(this._getDaysInMonth(a.getFullYear(),a.getMonth())),this._isInRange(e,a)},_isInRange:function(e,t){var i,s,n=this._getMinMaxDate(e,"min"),a=this._getMinMaxDate(e,"max"),o=null,r=null,h=this._get(e,"yearRange");return h&&(i=h.split(":"),s=(new Date).getFullYear(),o=parseInt(i[0],10),r=parseInt(i[1],10),i[0].match(/[+\-].*/)&&(o+=s),i[1].match(/[+\-].*/)&&(r+=s)),(!n||t.getTime()>=n.getTime())&&(!a||t.getTime()<=a.getTime())&&(!o||t.getFullYear()>=o)&&(!r||r>=t.getFullYear())},_getFormatConfig:function(e){var t=this._get(e,"shortYearCutoff");return t="string"!=typeof t?t:(new Date).getFullYear()%100+parseInt(t,10),{shortYearCutoff:t,dayNamesShort:this._get(e,"dayNamesShort"),dayNames:this._get(e,"dayNames"),monthNamesShort:this._get(e,"monthNamesShort"),monthNames:this._get(e,"monthNames")}},_formatDate:function(e,t,i,s){t||(e.currentDay=e.selectedDay,e.currentMonth=e.selectedMonth,e.currentYear=e.selectedYear);var n=t?"object"==typeof t?t:this._daylightSavingAdjust(new Date(s,i,t)):this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return this.formatDate(this._get(e,"dateFormat"),n,this._getFormatConfig(e))}}),e.fn.datepicker=function(t){if(!this.length)return this;e.datepicker.initialized||(e(document).mousedown(e.datepicker._checkExternalClick),e.datepicker.initialized=!0),0===e("#"+e.datepicker._mainDivId).length&&e("body").append(e.datepicker.dpDiv);var i=Array.prototype.slice.call(arguments,1);return"string"!=typeof t||"isDisabled"!==t&&"getDate"!==t&&"widget"!==t?"option"===t&&2===arguments.length&&"string"==typeof arguments[1]?e.datepicker["_"+t+"Datepicker"].apply(e.datepicker,[this[0]].concat(i)):this.each(function(){"string"==typeof t?e.datepicker["_"+t+"Datepicker"].apply(e.datepicker,[this].concat(i)):e.datepicker._attachDatepicker(this,t)}):e.datepicker["_"+t+"Datepicker"].apply(e.datepicker,[this[0]].concat(i))},e.datepicker=new n,e.datepicker.initialized=!1,e.datepicker.uuid=(new Date).getTime(),e.datepicker.version="1.11.1",e.datepicker,e.widget("ui.draggable",e.ui.mouse,{version:"1.11.1",widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1,drag:null,start:null,stop:null},_create:function(){"original"!==this.options.helper||/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._setHandleClassName(),this._mouseInit()},_setOption:function(e,t){this._super(e,t),"handle"===e&&(this._removeHandleClassName(),this._setHandleClassName())},_destroy:function(){return(this.helper||this.element).is(".ui-draggable-dragging")?(this.destroyOnClear=!0,void 0):(this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._removeHandleClassName(),this._mouseDestroy(),void 0)},_mouseCapture:function(t){var i=this.document[0],s=this.options;try{i.activeElement&&"body"!==i.activeElement.nodeName.toLowerCase()&&e(i.activeElement).blur()}catch(n){}return this.helper||s.disabled||e(t.target).closest(".ui-resizable-handle").length>0?!1:(this.handle=this._getHandle(t),this.handle?(e(s.iframeFix===!0?"iframe":s.iframeFix).each(function(){e("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>").css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(e(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(t){var i=this.options;return this.helper=this._createHelper(t),this.helper.addClass("ui-draggable-dragging"),this._cacheHelperProportions(),e.ui.ddmanager&&(e.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(!0),this.offsetParent=this.helper.offsetParent(),this.offsetParentCssPosition=this.offsetParent.css("position"),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},this.offset.scroll=!1,e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(t,!1),this.originalPageX=t.pageX,this.originalPageY=t.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),this._setContainment(),this._trigger("start",t)===!1?(this._clear(),!1):(this._cacheHelperProportions(),e.ui.ddmanager&&!i.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this._mouseDrag(t,!0),e.ui.ddmanager&&e.ui.ddmanager.dragStart(this,t),!0)},_mouseDrag:function(t,i){if("fixed"===this.offsetParentCssPosition&&(this.offset.parent=this._getParentOffset()),this.position=this._generatePosition(t,!0),this.positionAbs=this._convertPositionTo("absolute"),!i){var s=this._uiHash();if(this._trigger("drag",t,s)===!1)return this._mouseUp({}),!1;this.position=s.position}return this.helper[0].style.left=this.position.left+"px",this.helper[0].style.top=this.position.top+"px",e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),!1},_mouseStop:function(t){var i=this,s=!1;return e.ui.ddmanager&&!this.options.dropBehaviour&&(s=e.ui.ddmanager.drop(this,t)),this.dropped&&(s=this.dropped,this.dropped=!1),"invalid"===this.options.revert&&!s||"valid"===this.options.revert&&s||this.options.revert===!0||e.isFunction(this.options.revert)&&this.options.revert.call(this.element,s)?e(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){i._trigger("stop",t)!==!1&&i._clear()}):this._trigger("stop",t)!==!1&&this._clear(),!1},_mouseUp:function(t){return e("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),e.ui.ddmanager&&e.ui.ddmanager.dragStop(this,t),this.element.focus(),e.ui.mouse.prototype._mouseUp.call(this,t)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(t){return this.options.handle?!!e(t.target).closest(this.element.find(this.options.handle)).length:!0},_setHandleClassName:function(){this.handleElement=this.options.handle?this.element.find(this.options.handle):this.element,this.handleElement.addClass("ui-draggable-handle")},_removeHandleClassName:function(){this.handleElement.removeClass("ui-draggable-handle")},_createHelper:function(t){var i=this.options,s=e.isFunction(i.helper)?e(i.helper.apply(this.element[0],[t])):"clone"===i.helper?this.element.clone().removeAttr("id"):this.element;return s.parents("body").length||s.appendTo("parent"===i.appendTo?this.element[0].parentNode:i.appendTo),s[0]===this.element[0]||/(fixed|absolute)/.test(s.css("position"))||s.css("position","absolute"),s},_adjustOffsetFromHelper:function(t){"string"==typeof t&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_isRootNode:function(e){return/(html|body)/i.test(e.tagName)||e===this.document[0]},_getParentOffset:function(){var t=this.offsetParent.offset(),i=this.document[0];return"absolute"===this.cssPosition&&this.scrollParent[0]!==i&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop()),this._isRootNode(this.offsetParent[0])&&(t={top:0,left:0}),{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"!==this.cssPosition)return{top:0,left:0};var e=this.element.position(),t=this._isRootNode(this.scrollParent[0]);return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+(t?0:this.scrollParent.scrollTop()),left:e.left-(parseInt(this.helper.css("left"),10)||0)+(t?0:this.scrollParent.scrollLeft())}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t,i,s,n=this.options,a=this.document[0];return this.relativeContainer=null,n.containment?"window"===n.containment?(this.containment=[e(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,e(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,e(window).scrollLeft()+e(window).width()-this.helperProportions.width-this.margins.left,e(window).scrollTop()+(e(window).height()||a.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):"document"===n.containment?(this.containment=[0,0,e(a).width()-this.helperProportions.width-this.margins.left,(e(a).height()||a.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top],void 0):n.containment.constructor===Array?(this.containment=n.containment,void 0):("parent"===n.containment&&(n.containment=this.helper[0].parentNode),i=e(n.containment),s=i[0],s&&(t="hidden"!==i.css("overflow"),this.containment=[(parseInt(i.css("borderLeftWidth"),10)||0)+(parseInt(i.css("paddingLeft"),10)||0),(parseInt(i.css("borderTopWidth"),10)||0)+(parseInt(i.css("paddingTop"),10)||0),(t?Math.max(s.scrollWidth,s.offsetWidth):s.offsetWidth)-(parseInt(i.css("borderRightWidth"),10)||0)-(parseInt(i.css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(t?Math.max(s.scrollHeight,s.offsetHeight):s.offsetHeight)-(parseInt(i.css("borderBottomWidth"),10)||0)-(parseInt(i.css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relativeContainer=i),void 0):(this.containment=null,void 0)},_convertPositionTo:function(e,t){t||(t=this.position);var i="absolute"===e?1:-1,s=this._isRootNode(this.scrollParent[0]);return{top:t.top+this.offset.relative.top*i+this.offset.parent.top*i-("fixed"===this.cssPosition?-this.offset.scroll.top:s?0:this.offset.scroll.top)*i,left:t.left+this.offset.relative.left*i+this.offset.parent.left*i-("fixed"===this.cssPosition?-this.offset.scroll.left:s?0:this.offset.scroll.left)*i}
9
+ },_generatePosition:function(e,t){var i,s,n,a,o=this.options,r=this._isRootNode(this.scrollParent[0]),h=e.pageX,l=e.pageY;return r&&this.offset.scroll||(this.offset.scroll={top:this.scrollParent.scrollTop(),left:this.scrollParent.scrollLeft()}),t&&(this.containment&&(this.relativeContainer?(s=this.relativeContainer.offset(),i=[this.containment[0]+s.left,this.containment[1]+s.top,this.containment[2]+s.left,this.containment[3]+s.top]):i=this.containment,e.pageX-this.offset.click.left<i[0]&&(h=i[0]+this.offset.click.left),e.pageY-this.offset.click.top<i[1]&&(l=i[1]+this.offset.click.top),e.pageX-this.offset.click.left>i[2]&&(h=i[2]+this.offset.click.left),e.pageY-this.offset.click.top>i[3]&&(l=i[3]+this.offset.click.top)),o.grid&&(n=o.grid[1]?this.originalPageY+Math.round((l-this.originalPageY)/o.grid[1])*o.grid[1]:this.originalPageY,l=i?n-this.offset.click.top>=i[1]||n-this.offset.click.top>i[3]?n:n-this.offset.click.top>=i[1]?n-o.grid[1]:n+o.grid[1]:n,a=o.grid[0]?this.originalPageX+Math.round((h-this.originalPageX)/o.grid[0])*o.grid[0]:this.originalPageX,h=i?a-this.offset.click.left>=i[0]||a-this.offset.click.left>i[2]?a:a-this.offset.click.left>=i[0]?a-o.grid[0]:a+o.grid[0]:a),"y"===o.axis&&(h=this.originalPageX),"x"===o.axis&&(l=this.originalPageY)),{top:l-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.offset.scroll.top:r?0:this.offset.scroll.top),left:h-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.offset.scroll.left:r?0:this.offset.scroll.left)}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1,this.destroyOnClear&&this.destroy()},_trigger:function(t,i,s){return s=s||this._uiHash(),e.ui.plugin.call(this,t,[i,s,this],!0),"drag"===t&&(this.positionAbs=this._convertPositionTo("absolute")),e.Widget.prototype._trigger.call(this,t,i,s)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),e.ui.plugin.add("draggable","connectToSortable",{start:function(t,i,s){var n=s.options,a=e.extend({},i,{item:s.element});s.sortables=[],e(n.connectToSortable).each(function(){var i=e(this).sortable("instance");i&&!i.options.disabled&&(s.sortables.push({instance:i,shouldRevert:i.options.revert}),i.refreshPositions(),i._trigger("activate",t,a))})},stop:function(t,i,s){var n=e.extend({},i,{item:s.element});e.each(s.sortables,function(){this.instance.isOver?(this.instance.isOver=0,s.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=this.shouldRevert),this.instance._mouseStop(t),this.instance.options.helper=this.instance.options._helper,"original"===s.options.helper&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",t,n))})},drag:function(t,i,s){var n=this;e.each(s.sortables,function(){var a=!1,o=this;this.instance.positionAbs=s.positionAbs,this.instance.helperProportions=s.helperProportions,this.instance.offset.click=s.offset.click,this.instance._intersectsWith(this.instance.containerCache)&&(a=!0,e.each(s.sortables,function(){return this.instance.positionAbs=s.positionAbs,this.instance.helperProportions=s.helperProportions,this.instance.offset.click=s.offset.click,this!==o&&this.instance._intersectsWith(this.instance.containerCache)&&e.contains(o.instance.element[0],this.instance.element[0])&&(a=!1),a})),a?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=e(n).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return i.helper[0]},t.target=this.instance.currentItem[0],this.instance._mouseCapture(t,!0),this.instance._mouseStart(t,!0,!0),this.instance.offset.click.top=s.offset.click.top,this.instance.offset.click.left=s.offset.click.left,this.instance.offset.parent.left-=s.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=s.offset.parent.top-this.instance.offset.parent.top,s._trigger("toSortable",t),s.dropped=this.instance.element,s.currentItem=s.element,this.instance.fromOutside=s),this.instance.currentItem&&this.instance._mouseDrag(t)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",t,this.instance._uiHash(this.instance)),this.instance._mouseStop(t,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),s._trigger("fromSortable",t),s.dropped=!1)})}}),e.ui.plugin.add("draggable","cursor",{start:function(t,i,s){var n=e("body"),a=s.options;n.css("cursor")&&(a._cursor=n.css("cursor")),n.css("cursor",a.cursor)},stop:function(t,i,s){var n=s.options;n._cursor&&e("body").css("cursor",n._cursor)}}),e.ui.plugin.add("draggable","opacity",{start:function(t,i,s){var n=e(i.helper),a=s.options;n.css("opacity")&&(a._opacity=n.css("opacity")),n.css("opacity",a.opacity)},stop:function(t,i,s){var n=s.options;n._opacity&&e(i.helper).css("opacity",n._opacity)}}),e.ui.plugin.add("draggable","scroll",{start:function(e,t,i){i.scrollParentNotHidden||(i.scrollParentNotHidden=i.helper.scrollParent(!1)),i.scrollParentNotHidden[0]!==i.document[0]&&"HTML"!==i.scrollParentNotHidden[0].tagName&&(i.overflowOffset=i.scrollParentNotHidden.offset())},drag:function(t,i,s){var n=s.options,a=!1,o=s.scrollParentNotHidden[0],r=s.document[0];o!==r&&"HTML"!==o.tagName?(n.axis&&"x"===n.axis||(s.overflowOffset.top+o.offsetHeight-t.pageY<n.scrollSensitivity?o.scrollTop=a=o.scrollTop+n.scrollSpeed:t.pageY-s.overflowOffset.top<n.scrollSensitivity&&(o.scrollTop=a=o.scrollTop-n.scrollSpeed)),n.axis&&"y"===n.axis||(s.overflowOffset.left+o.offsetWidth-t.pageX<n.scrollSensitivity?o.scrollLeft=a=o.scrollLeft+n.scrollSpeed:t.pageX-s.overflowOffset.left<n.scrollSensitivity&&(o.scrollLeft=a=o.scrollLeft-n.scrollSpeed))):(n.axis&&"x"===n.axis||(t.pageY-e(r).scrollTop()<n.scrollSensitivity?a=e(r).scrollTop(e(r).scrollTop()-n.scrollSpeed):e(window).height()-(t.pageY-e(r).scrollTop())<n.scrollSensitivity&&(a=e(r).scrollTop(e(r).scrollTop()+n.scrollSpeed))),n.axis&&"y"===n.axis||(t.pageX-e(r).scrollLeft()<n.scrollSensitivity?a=e(r).scrollLeft(e(r).scrollLeft()-n.scrollSpeed):e(window).width()-(t.pageX-e(r).scrollLeft())<n.scrollSensitivity&&(a=e(r).scrollLeft(e(r).scrollLeft()+n.scrollSpeed)))),a!==!1&&e.ui.ddmanager&&!n.dropBehaviour&&e.ui.ddmanager.prepareOffsets(s,t)}}),e.ui.plugin.add("draggable","snap",{start:function(t,i,s){var n=s.options;s.snapElements=[],e(n.snap.constructor!==String?n.snap.items||":data(ui-draggable)":n.snap).each(function(){var t=e(this),i=t.offset();this!==s.element[0]&&s.snapElements.push({item:this,width:t.outerWidth(),height:t.outerHeight(),top:i.top,left:i.left})})},drag:function(t,i,s){var n,a,o,r,h,l,u,d,c,p,f=s.options,m=f.snapTolerance,g=i.offset.left,v=g+s.helperProportions.width,y=i.offset.top,b=y+s.helperProportions.height;for(c=s.snapElements.length-1;c>=0;c--)h=s.snapElements[c].left,l=h+s.snapElements[c].width,u=s.snapElements[c].top,d=u+s.snapElements[c].height,h-m>v||g>l+m||u-m>b||y>d+m||!e.contains(s.snapElements[c].item.ownerDocument,s.snapElements[c].item)?(s.snapElements[c].snapping&&s.options.snap.release&&s.options.snap.release.call(s.element,t,e.extend(s._uiHash(),{snapItem:s.snapElements[c].item})),s.snapElements[c].snapping=!1):("inner"!==f.snapMode&&(n=m>=Math.abs(u-b),a=m>=Math.abs(d-y),o=m>=Math.abs(h-v),r=m>=Math.abs(l-g),n&&(i.position.top=s._convertPositionTo("relative",{top:u-s.helperProportions.height,left:0}).top-s.margins.top),a&&(i.position.top=s._convertPositionTo("relative",{top:d,left:0}).top-s.margins.top),o&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h-s.helperProportions.width}).left-s.margins.left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l}).left-s.margins.left)),p=n||a||o||r,"outer"!==f.snapMode&&(n=m>=Math.abs(u-y),a=m>=Math.abs(d-b),o=m>=Math.abs(h-g),r=m>=Math.abs(l-v),n&&(i.position.top=s._convertPositionTo("relative",{top:u,left:0}).top-s.margins.top),a&&(i.position.top=s._convertPositionTo("relative",{top:d-s.helperProportions.height,left:0}).top-s.margins.top),o&&(i.position.left=s._convertPositionTo("relative",{top:0,left:h}).left-s.margins.left),r&&(i.position.left=s._convertPositionTo("relative",{top:0,left:l-s.helperProportions.width}).left-s.margins.left)),!s.snapElements[c].snapping&&(n||a||o||r||p)&&s.options.snap.snap&&s.options.snap.snap.call(s.element,t,e.extend(s._uiHash(),{snapItem:s.snapElements[c].item})),s.snapElements[c].snapping=n||a||o||r||p)}}),e.ui.plugin.add("draggable","stack",{start:function(t,i,s){var n,a=s.options,o=e.makeArray(e(a.stack)).sort(function(t,i){return(parseInt(e(t).css("zIndex"),10)||0)-(parseInt(e(i).css("zIndex"),10)||0)});o.length&&(n=parseInt(e(o[0]).css("zIndex"),10)||0,e(o).each(function(t){e(this).css("zIndex",n+t)}),this.css("zIndex",n+o.length))}}),e.ui.plugin.add("draggable","zIndex",{start:function(t,i,s){var n=e(i.helper),a=s.options;n.css("zIndex")&&(a._zIndex=n.css("zIndex")),n.css("zIndex",a.zIndex)},stop:function(t,i,s){var n=s.options;n._zIndex&&e(i.helper).css("zIndex",n._zIndex)}}),e.ui.draggable,e.widget("ui.resizable",e.ui.mouse,{version:"1.11.1",widgetEventPrefix:"resize",options:{alsoResize:!1,animate:!1,animateDuration:"slow",animateEasing:"swing",aspectRatio:!1,autoHide:!1,containment:!1,ghost:!1,grid:!1,handles:"e,s,se",helper:!1,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:90,resize:null,start:null,stop:null},_num:function(e){return parseInt(e,10)||0},_isNumber:function(e){return!isNaN(parseInt(e,10))},_hasScroll:function(t,i){if("hidden"===e(t).css("overflow"))return!1;var s=i&&"left"===i?"scrollLeft":"scrollTop",n=!1;return t[s]>0?!0:(t[s]=1,n=t[s]>0,t[s]=0,n)},_create:function(){var t,i,s,n,a,o=this,r=this.options;if(this.element.addClass("ui-resizable"),e.extend(this,{_aspectRatio:!!r.aspectRatio,aspectRatio:r.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:r.helper||r.ghost||r.animate?r.helper||"ui-resizable-helper":null}),this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)&&(this.element.wrap(e("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")}),this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0}),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css({margin:this.originalElement.css("margin")}),this._proportionallyResize()),this.handles=r.handles||(e(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),t=this.handles.split(","),this.handles={},i=0;t.length>i;i++)s=e.trim(t[i]),a="ui-resizable-"+s,n=e("<div class='ui-resizable-handle "+a+"'></div>"),n.css({zIndex:r.zIndex}),"se"===s&&n.addClass("ui-icon ui-icon-gripsmall-diagonal-se"),this.handles[s]=".ui-resizable-"+s,this.element.append(n);this._renderAxis=function(t){var i,s,n,a;t=t||this.element;for(i in this.handles)this.handles[i].constructor===String&&(this.handles[i]=this.element.children(this.handles[i]).first().show()),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)&&(s=e(this.handles[i],this.element),a=/sw|ne|nw|se|n|s/.test(i)?s.outerHeight():s.outerWidth(),n=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join(""),t.css(n,a),this._proportionallyResize()),e(this.handles[i]).length},this._renderAxis(this.element),this._handles=e(".ui-resizable-handle",this.element).disableSelection(),this._handles.mouseover(function(){o.resizing||(this.className&&(n=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),o.axis=n&&n[1]?n[1]:"se")}),r.autoHide&&(this._handles.hide(),e(this.element).addClass("ui-resizable-autohide").mouseenter(function(){r.disabled||(e(this).removeClass("ui-resizable-autohide"),o._handles.show())}).mouseleave(function(){r.disabled||o.resizing||(e(this).addClass("ui-resizable-autohide"),o._handles.hide())})),this._mouseInit()},_destroy:function(){this._mouseDestroy();var t,i=function(t){e(t).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};return this.elementIsWrapper&&(i(this.element),t=this.element,this.originalElement.css({position:t.css("position"),width:t.outerWidth(),height:t.outerHeight(),top:t.css("top"),left:t.css("left")}).insertAfter(t),t.remove()),this.originalElement.css("resize",this.originalResizeStyle),i(this.originalElement),this},_mouseCapture:function(t){var i,s,n=!1;for(i in this.handles)s=e(this.handles[i])[0],(s===t.target||e.contains(s,t.target))&&(n=!0);return!this.options.disabled&&n},_mouseStart:function(t){var i,s,n,a=this.options,o=this.element;return this.resizing=!0,this._renderProxy(),i=this._num(this.helper.css("left")),s=this._num(this.helper.css("top")),a.containment&&(i+=e(a.containment).scrollLeft()||0,s+=e(a.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:i,top:s},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:o.width(),height:o.height()},this.originalSize=this._helper?{width:o.outerWidth(),height:o.outerHeight()}:{width:o.width(),height:o.height()},this.sizeDiff={width:o.outerWidth()-o.width(),height:o.outerHeight()-o.height()},this.originalPosition={left:i,top:s},this.originalMousePosition={left:t.pageX,top:t.pageY},this.aspectRatio="number"==typeof a.aspectRatio?a.aspectRatio:this.originalSize.width/this.originalSize.height||1,n=e(".ui-resizable-"+this.axis).css("cursor"),e("body").css("cursor","auto"===n?this.axis+"-resize":n),o.addClass("ui-resizable-resizing"),this._propagate("start",t),!0},_mouseDrag:function(t){var i,s,n=this.originalMousePosition,a=this.axis,o=t.pageX-n.left||0,r=t.pageY-n.top||0,h=this._change[a];return this._updatePrevProperties(),h?(i=h.apply(this,[t,o,r]),this._updateVirtualBoundaries(t.shiftKey),(this._aspectRatio||t.shiftKey)&&(i=this._updateRatio(i,t)),i=this._respectSize(i,t),this._updateCache(i),this._propagate("resize",t),s=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),e.isEmptyObject(s)||(this._updatePrevProperties(),this._trigger("resize",t,this.ui()),this._applyChanges()),!1):!1},_mouseStop:function(t){this.resizing=!1;var i,s,n,a,o,r,h,l=this.options,u=this;return this._helper&&(i=this._proportionallyResizeElements,s=i.length&&/textarea/i.test(i[0].nodeName),n=s&&this._hasScroll(i[0],"left")?0:u.sizeDiff.height,a=s?0:u.sizeDiff.width,o={width:u.helper.width()-a,height:u.helper.height()-n},r=parseInt(u.element.css("left"),10)+(u.position.left-u.originalPosition.left)||null,h=parseInt(u.element.css("top"),10)+(u.position.top-u.originalPosition.top)||null,l.animate||this.element.css(e.extend(o,{top:h,left:r})),u.helper.height(u.size.height),u.helper.width(u.size.width),this._helper&&!l.animate&&this._proportionallyResize()),e("body").css("cursor","auto"),this.element.removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var e={};return this.position.top!==this.prevPosition.top&&(e.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(e.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(e.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(e.height=this.size.height+"px"),this.helper.css(e),e},_updateVirtualBoundaries:function(e){var t,i,s,n,a,o=this.options;a={minWidth:this._isNumber(o.minWidth)?o.minWidth:0,maxWidth:this._isNumber(o.maxWidth)?o.maxWidth:1/0,minHeight:this._isNumber(o.minHeight)?o.minHeight:0,maxHeight:this._isNumber(o.maxHeight)?o.maxHeight:1/0},(this._aspectRatio||e)&&(t=a.minHeight*this.aspectRatio,s=a.minWidth/this.aspectRatio,i=a.maxHeight*this.aspectRatio,n=a.maxWidth/this.aspectRatio,t>a.minWidth&&(a.minWidth=t),s>a.minHeight&&(a.minHeight=s),a.maxWidth>i&&(a.maxWidth=i),a.maxHeight>n&&(a.maxHeight=n)),this._vBoundaries=a},_updateCache:function(e){this.offset=this.helper.offset(),this._isNumber(e.left)&&(this.position.left=e.left),this._isNumber(e.top)&&(this.position.top=e.top),this._isNumber(e.height)&&(this.size.height=e.height),this._isNumber(e.width)&&(this.size.width=e.width)},_updateRatio:function(e){var t=this.position,i=this.size,s=this.axis;return this._isNumber(e.height)?e.width=e.height*this.aspectRatio:this._isNumber(e.width)&&(e.height=e.width/this.aspectRatio),"sw"===s&&(e.left=t.left+(i.width-e.width),e.top=null),"nw"===s&&(e.top=t.top+(i.height-e.height),e.left=t.left+(i.width-e.width)),e},_respectSize:function(e){var t=this._vBoundaries,i=this.axis,s=this._isNumber(e.width)&&t.maxWidth&&t.maxWidth<e.width,n=this._isNumber(e.height)&&t.maxHeight&&t.maxHeight<e.height,a=this._isNumber(e.width)&&t.minWidth&&t.minWidth>e.width,o=this._isNumber(e.height)&&t.minHeight&&t.minHeight>e.height,r=this.originalPosition.left+this.originalSize.width,h=this.position.top+this.size.height,l=/sw|nw|w/.test(i),u=/nw|ne|n/.test(i);return a&&(e.width=t.minWidth),o&&(e.height=t.minHeight),s&&(e.width=t.maxWidth),n&&(e.height=t.maxHeight),a&&l&&(e.left=r-t.minWidth),s&&l&&(e.left=r-t.maxWidth),o&&u&&(e.top=h-t.minHeight),n&&u&&(e.top=h-t.maxHeight),e.width||e.height||e.left||!e.top?e.width||e.height||e.top||!e.left||(e.left=null):e.top=null,e},_getPaddingPlusBorderDimensions:function(e){for(var t=0,i=[],s=[e.css("borderTopWidth"),e.css("borderRightWidth"),e.css("borderBottomWidth"),e.css("borderLeftWidth")],n=[e.css("paddingTop"),e.css("paddingRight"),e.css("paddingBottom"),e.css("paddingLeft")];4>t;t++)i[t]=parseInt(s[t],10)||0,i[t]+=parseInt(n[t],10)||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var e,t=0,i=this.helper||this.element;this._proportionallyResizeElements.length>t;t++)e=this._proportionallyResizeElements[t],this.outerDimensions||(this.outerDimensions=this._getPaddingPlusBorderDimensions(e)),e.css({height:i.height()-this.outerDimensions.height||0,width:i.width()-this.outerDimensions.width||0})},_renderProxy:function(){var t=this.element,i=this.options;this.elementOffset=t.offset(),this._helper?(this.helper=this.helper||e("<div style='overflow:hidden;'></div>"),this.helper.addClass(this._helper).css({width:this.element.outerWidth()-1,height:this.element.outerHeight()-1,position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++i.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(e,t){return{width:this.originalSize.width+t}},w:function(e,t){var i=this.originalSize,s=this.originalPosition;return{left:s.left+t,width:i.width-t}},n:function(e,t,i){var s=this.originalSize,n=this.originalPosition;return{top:n.top+i,height:s.height-i}},s:function(e,t,i){return{height:this.originalSize.height+i}},se:function(t,i,s){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,i,s]))},sw:function(t,i,s){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,i,s]))},ne:function(t,i,s){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,i,s]))},nw:function(t,i,s){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,i,s]))}},_propagate:function(t,i){e.ui.plugin.call(this,t,[i,this.ui()]),"resize"!==t&&this._trigger(t,i,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),e.ui.plugin.add("resizable","animate",{stop:function(t){var i=e(this).resizable("instance"),s=i.options,n=i._proportionallyResizeElements,a=n.length&&/textarea/i.test(n[0].nodeName),o=a&&i._hasScroll(n[0],"left")?0:i.sizeDiff.height,r=a?0:i.sizeDiff.width,h={width:i.size.width-r,height:i.size.height-o},l=parseInt(i.element.css("left"),10)+(i.position.left-i.originalPosition.left)||null,u=parseInt(i.element.css("top"),10)+(i.position.top-i.originalPosition.top)||null;i.element.animate(e.extend(h,u&&l?{top:u,left:l}:{}),{duration:s.animateDuration,easing:s.animateEasing,step:function(){var s={width:parseInt(i.element.css("width"),10),height:parseInt(i.element.css("height"),10),top:parseInt(i.element.css("top"),10),left:parseInt(i.element.css("left"),10)};n&&n.length&&e(n[0]).css({width:s.width,height:s.height}),i._updateCache(s),i._propagate("resize",t)}})}}),e.ui.plugin.add("resizable","containment",{start:function(){var t,i,s,n,a,o,r,h=e(this).resizable("instance"),l=h.options,u=h.element,d=l.containment,c=d instanceof e?d.get(0):/parent/.test(d)?u.parent().get(0):d;c&&(h.containerElement=e(c),/document/.test(d)||d===document?(h.containerOffset={left:0,top:0},h.containerPosition={left:0,top:0},h.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}):(t=e(c),i=[],e(["Top","Right","Left","Bottom"]).each(function(e,s){i[e]=h._num(t.css("padding"+s))}),h.containerOffset=t.offset(),h.containerPosition=t.position(),h.containerSize={height:t.innerHeight()-i[3],width:t.innerWidth()-i[1]},s=h.containerOffset,n=h.containerSize.height,a=h.containerSize.width,o=h._hasScroll(c,"left")?c.scrollWidth:a,r=h._hasScroll(c)?c.scrollHeight:n,h.parentData={element:c,left:s.left,top:s.top,width:o,height:r}))},resize:function(t){var i,s,n,a,o=e(this).resizable("instance"),r=o.options,h=o.containerOffset,l=o.position,u=o._aspectRatio||t.shiftKey,d={top:0,left:0},c=o.containerElement,p=!0;c[0]!==document&&/static/.test(c.css("position"))&&(d=h),l.left<(o._helper?h.left:0)&&(o.size.width=o.size.width+(o._helper?o.position.left-h.left:o.position.left-d.left),u&&(o.size.height=o.size.width/o.aspectRatio,p=!1),o.position.left=r.helper?h.left:0),l.top<(o._helper?h.top:0)&&(o.size.height=o.size.height+(o._helper?o.position.top-h.top:o.position.top),u&&(o.size.width=o.size.height*o.aspectRatio,p=!1),o.position.top=o._helper?h.top:0),n=o.containerElement.get(0)===o.element.parent().get(0),a=/relative|absolute/.test(o.containerElement.css("position")),n&&a?(o.offset.left=o.parentData.left+o.position.left,o.offset.top=o.parentData.top+o.position.top):(o.offset.left=o.element.offset().left,o.offset.top=o.element.offset().top),i=Math.abs(o.sizeDiff.width+(o._helper?o.offset.left-d.left:o.offset.left-h.left)),s=Math.abs(o.sizeDiff.height+(o._helper?o.offset.top-d.top:o.offset.top-h.top)),i+o.size.width>=o.parentData.width&&(o.size.width=o.parentData.width-i,u&&(o.size.height=o.size.width/o.aspectRatio,p=!1)),s+o.size.height>=o.parentData.height&&(o.size.height=o.parentData.height-s,u&&(o.size.width=o.size.height*o.aspectRatio,p=!1)),p||(o.position.left=o.prevPosition.left,o.position.top=o.prevPosition.top,o.size.width=o.prevSize.width,o.size.height=o.prevSize.height)},stop:function(){var t=e(this).resizable("instance"),i=t.options,s=t.containerOffset,n=t.containerPosition,a=t.containerElement,o=e(t.helper),r=o.offset(),h=o.outerWidth()-t.sizeDiff.width,l=o.outerHeight()-t.sizeDiff.height;t._helper&&!i.animate&&/relative/.test(a.css("position"))&&e(this).css({left:r.left-n.left-s.left,width:h,height:l}),t._helper&&!i.animate&&/static/.test(a.css("position"))&&e(this).css({left:r.left-n.left-s.left,width:h,height:l})}}),e.ui.plugin.add("resizable","alsoResize",{start:function(){var t=e(this).resizable("instance"),i=t.options,s=function(t){e(t).each(function(){var t=e(this);t.data("ui-resizable-alsoresize",{width:parseInt(t.width(),10),height:parseInt(t.height(),10),left:parseInt(t.css("left"),10),top:parseInt(t.css("top"),10)})})};"object"!=typeof i.alsoResize||i.alsoResize.parentNode?s(i.alsoResize):i.alsoResize.length?(i.alsoResize=i.alsoResize[0],s(i.alsoResize)):e.each(i.alsoResize,function(e){s(e)})},resize:function(t,i){var s=e(this).resizable("instance"),n=s.options,a=s.originalSize,o=s.originalPosition,r={height:s.size.height-a.height||0,width:s.size.width-a.width||0,top:s.position.top-o.top||0,left:s.position.left-o.left||0},h=function(t,s){e(t).each(function(){var t=e(this),n=e(this).data("ui-resizable-alsoresize"),a={},o=s&&s.length?s:t.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(o,function(e,t){var i=(n[t]||0)+(r[t]||0);i&&i>=0&&(a[t]=i||null)}),t.css(a)})};"object"!=typeof n.alsoResize||n.alsoResize.nodeType?h(n.alsoResize):e.each(n.alsoResize,function(e,t){h(e,t)})},stop:function(){e(this).removeData("resizable-alsoresize")}}),e.ui.plugin.add("resizable","ghost",{start:function(){var t=e(this).resizable("instance"),i=t.options,s=t.size;t.ghost=t.originalElement.clone(),t.ghost.css({opacity:.25,display:"block",position:"relative",height:s.height,width:s.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass("string"==typeof i.ghost?i.ghost:""),t.ghost.appendTo(t.helper)},resize:function(){var t=e(this).resizable("instance");t.ghost&&t.ghost.css({position:"relative",height:t.size.height,width:t.size.width})},stop:function(){var t=e(this).resizable("instance");t.ghost&&t.helper&&t.helper.get(0).removeChild(t.ghost.get(0))}}),e.ui.plugin.add("resizable","grid",{resize:function(){var t,i=e(this).resizable("instance"),s=i.options,n=i.size,a=i.originalSize,o=i.originalPosition,r=i.axis,h="number"==typeof s.grid?[s.grid,s.grid]:s.grid,l=h[0]||1,u=h[1]||1,d=Math.round((n.width-a.width)/l)*l,c=Math.round((n.height-a.height)/u)*u,p=a.width+d,f=a.height+c,m=s.maxWidth&&p>s.maxWidth,g=s.maxHeight&&f>s.maxHeight,v=s.minWidth&&s.minWidth>p,y=s.minHeight&&s.minHeight>f;s.grid=h,v&&(p+=l),y&&(f+=u),m&&(p-=l),g&&(f-=u),/^(se|s|e)$/.test(r)?(i.size.width=p,i.size.height=f):/^(ne)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.top=o.top-c):/^(sw)$/.test(r)?(i.size.width=p,i.size.height=f,i.position.left=o.left-d):((0>=f-u||0>=p-l)&&(t=i._getPaddingPlusBorderDimensions(this)),f-u>0?(i.size.height=f,i.position.top=o.top-c):(f=u-t.height,i.size.height=f,i.position.top=o.top+a.height-f),p-l>0?(i.size.width=p,i.position.left=o.left-d):(p=u-t.height,i.size.width=p,i.position.left=o.left+a.width-p))}}),e.ui.resizable,e.widget("ui.dialog",{version:"1.11.1",options:{appendTo:"body",autoOpen:!0,buttons:[],closeOnEscape:!0,closeText:"Close",dialogClass:"",draggable:!0,hide:null,height:"auto",maxHeight:null,maxWidth:null,minHeight:150,minWidth:150,modal:!1,position:{my:"center",at:"center",of:window,collision:"fit",using:function(t){var i=e(this).css(t).offset().top;0>i&&e(this).css("top",t.top-i)}},resizable:!0,show:null,title:null,width:300,beforeClose:null,close:null,drag:null,dragStart:null,dragStop:null,focus:null,open:null,resize:null,resizeStart:null,resizeStop:null},sizeRelatedOptions:{buttons:!0,height:!0,maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0,width:!0},resizableRelatedOptions:{maxHeight:!0,maxWidth:!0,minHeight:!0,minWidth:!0},_create:function(){this.originalCss={display:this.element[0].style.display,width:this.element[0].style.width,minHeight:this.element[0].style.minHeight,maxHeight:this.element[0].style.maxHeight,height:this.element[0].style.height},this.originalPosition={parent:this.element.parent(),index:this.element.parent().children().index(this.element)},this.originalTitle=this.element.attr("title"),this.options.title=this.options.title||this.originalTitle,this._createWrapper(),this.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(this.uiDialog),this._createTitlebar(),this._createButtonPane(),this.options.draggable&&e.fn.draggable&&this._makeDraggable(),this.options.resizable&&e.fn.resizable&&this._makeResizable(),this._isOpen=!1,this._trackFocus()},_init:function(){this.options.autoOpen&&this.open()},_appendTo:function(){var t=this.options.appendTo;return t&&(t.jquery||t.nodeType)?e(t):this.document.find(t||"body").eq(0)},_destroy:function(){var e,t=this.originalPosition;this._destroyOverlay(),this.element.removeUniqueId().removeClass("ui-dialog-content ui-widget-content").css(this.originalCss).detach(),this.uiDialog.stop(!0,!0).remove(),this.originalTitle&&this.element.attr("title",this.originalTitle),e=t.parent.children().eq(t.index),e.length&&e[0]!==this.element[0]?e.before(this.element):t.parent.append(this.element)},widget:function(){return this.uiDialog},disable:e.noop,enable:e.noop,close:function(t){var i,s=this;if(this._isOpen&&this._trigger("beforeClose",t)!==!1){if(this._isOpen=!1,this._focusedElement=null,this._destroyOverlay(),this._untrackInstance(),!this.opener.filter(":focusable").focus().length)try{i=this.document[0].activeElement,i&&"body"!==i.nodeName.toLowerCase()&&e(i).blur()}catch(n){}this._hide(this.uiDialog,this.options.hide,function(){s._trigger("close",t)})}},isOpen:function(){return this._isOpen},moveToTop:function(){this._moveToTop()},_moveToTop:function(t,i){var s=!1,n=this.uiDialog.siblings(".ui-front:visible").map(function(){return+e(this).css("z-index")}).get(),a=Math.max.apply(null,n);return a>=+this.uiDialog.css("z-index")&&(this.uiDialog.css("z-index",a+1),s=!0),s&&!i&&this._trigger("focus",t),s},open:function(){var t=this;return this._isOpen?(this._moveToTop()&&this._focusTabbable(),void 0):(this._isOpen=!0,this.opener=e(this.document[0].activeElement),this._size(),this._position(),this._createOverlay(),this._moveToTop(null,!0),this.overlay&&this.overlay.css("z-index",this.uiDialog.css("z-index")-1),this._show(this.uiDialog,this.options.show,function(){t._focusTabbable(),t._trigger("focus")}),this._makeFocusTarget(),this._trigger("open"),void 0)},_focusTabbable:function(){var e=this._focusedElement;e||(e=this.element.find("[autofocus]")),e.length||(e=this.element.find(":tabbable")),e.length||(e=this.uiDialogButtonPane.find(":tabbable")),e.length||(e=this.uiDialogTitlebarClose.filter(":tabbable")),e.length||(e=this.uiDialog),e.eq(0).focus()},_keepFocus:function(t){function i(){var t=this.document[0].activeElement,i=this.uiDialog[0]===t||e.contains(this.uiDialog[0],t);i||this._focusTabbable()}t.preventDefault(),i.call(this),this._delay(i)},_createWrapper:function(){this.uiDialog=e("<div>").addClass("ui-dialog ui-widget ui-widget-content ui-corner-all ui-front "+this.options.dialogClass).hide().attr({tabIndex:-1,role:"dialog"}).appendTo(this._appendTo()),this._on(this.uiDialog,{keydown:function(t){if(this.options.closeOnEscape&&!t.isDefaultPrevented()&&t.keyCode&&t.keyCode===e.ui.keyCode.ESCAPE)return t.preventDefault(),this.close(t),void 0;
10
+ if(t.keyCode===e.ui.keyCode.TAB&&!t.isDefaultPrevented()){var i=this.uiDialog.find(":tabbable"),s=i.filter(":first"),n=i.filter(":last");t.target!==n[0]&&t.target!==this.uiDialog[0]||t.shiftKey?t.target!==s[0]&&t.target!==this.uiDialog[0]||!t.shiftKey||(this._delay(function(){n.focus()}),t.preventDefault()):(this._delay(function(){s.focus()}),t.preventDefault())}},mousedown:function(e){this._moveToTop(e)&&this._focusTabbable()}}),this.element.find("[aria-describedby]").length||this.uiDialog.attr({"aria-describedby":this.element.uniqueId().attr("id")})},_createTitlebar:function(){var t;this.uiDialogTitlebar=e("<div>").addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(this.uiDialog),this._on(this.uiDialogTitlebar,{mousedown:function(t){e(t.target).closest(".ui-dialog-titlebar-close")||this.uiDialog.focus()}}),this.uiDialogTitlebarClose=e("<button type='button'></button>").button({label:this.options.closeText,icons:{primary:"ui-icon-closethick"},text:!1}).addClass("ui-dialog-titlebar-close").appendTo(this.uiDialogTitlebar),this._on(this.uiDialogTitlebarClose,{click:function(e){e.preventDefault(),this.close(e)}}),t=e("<span>").uniqueId().addClass("ui-dialog-title").prependTo(this.uiDialogTitlebar),this._title(t),this.uiDialog.attr({"aria-labelledby":t.attr("id")})},_title:function(e){this.options.title||e.html("&#160;"),e.text(this.options.title)},_createButtonPane:function(){this.uiDialogButtonPane=e("<div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),this.uiButtonSet=e("<div>").addClass("ui-dialog-buttonset").appendTo(this.uiDialogButtonPane),this._createButtons()},_createButtons:function(){var t=this,i=this.options.buttons;return this.uiDialogButtonPane.remove(),this.uiButtonSet.empty(),e.isEmptyObject(i)||e.isArray(i)&&!i.length?(this.uiDialog.removeClass("ui-dialog-buttons"),void 0):(e.each(i,function(i,s){var n,a;s=e.isFunction(s)?{click:s,text:i}:s,s=e.extend({type:"button"},s),n=s.click,s.click=function(){n.apply(t.element[0],arguments)},a={icons:s.icons,text:s.showText},delete s.icons,delete s.showText,e("<button></button>",s).button(a).appendTo(t.uiButtonSet)}),this.uiDialog.addClass("ui-dialog-buttons"),this.uiDialogButtonPane.appendTo(this.uiDialog),void 0)},_makeDraggable:function(){function t(e){return{position:e.position,offset:e.offset}}var i=this,s=this.options;this.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(s,n){e(this).addClass("ui-dialog-dragging"),i._blockFrames(),i._trigger("dragStart",s,t(n))},drag:function(e,s){i._trigger("drag",e,t(s))},stop:function(n,a){var o=a.offset.left-i.document.scrollLeft(),r=a.offset.top-i.document.scrollTop();s.position={my:"left top",at:"left"+(o>=0?"+":"")+o+" "+"top"+(r>=0?"+":"")+r,of:i.window},e(this).removeClass("ui-dialog-dragging"),i._unblockFrames(),i._trigger("dragStop",n,t(a))}})},_makeResizable:function(){function t(e){return{originalPosition:e.originalPosition,originalSize:e.originalSize,position:e.position,size:e.size}}var i=this,s=this.options,n=s.resizable,a=this.uiDialog.css("position"),o="string"==typeof n?n:"n,e,s,w,se,sw,ne,nw";this.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:this.element,maxWidth:s.maxWidth,maxHeight:s.maxHeight,minWidth:s.minWidth,minHeight:this._minHeight(),handles:o,start:function(s,n){e(this).addClass("ui-dialog-resizing"),i._blockFrames(),i._trigger("resizeStart",s,t(n))},resize:function(e,s){i._trigger("resize",e,t(s))},stop:function(n,a){var o=i.uiDialog.offset(),r=o.left-i.document.scrollLeft(),h=o.top-i.document.scrollTop();s.height=i.uiDialog.height(),s.width=i.uiDialog.width(),s.position={my:"left top",at:"left"+(r>=0?"+":"")+r+" "+"top"+(h>=0?"+":"")+h,of:i.window},e(this).removeClass("ui-dialog-resizing"),i._unblockFrames(),i._trigger("resizeStop",n,t(a))}}).css("position",a)},_trackFocus:function(){this._on(this.widget(),{focusin:function(t){this._makeFocusTarget(),this._focusedElement=e(t.target)}})},_makeFocusTarget:function(){this._untrackInstance(),this._trackingInstances().unshift(this)},_untrackInstance:function(){var t=this._trackingInstances(),i=e.inArray(this,t);-1!==i&&t.splice(i,1)},_trackingInstances:function(){var e=this.document.data("ui-dialog-instances");return e||(e=[],this.document.data("ui-dialog-instances",e)),e},_minHeight:function(){var e=this.options;return"auto"===e.height?e.minHeight:Math.min(e.minHeight,e.height)},_position:function(){var e=this.uiDialog.is(":visible");e||this.uiDialog.show(),this.uiDialog.position(this.options.position),e||this.uiDialog.hide()},_setOptions:function(t){var i=this,s=!1,n={};e.each(t,function(e,t){i._setOption(e,t),e in i.sizeRelatedOptions&&(s=!0),e in i.resizableRelatedOptions&&(n[e]=t)}),s&&(this._size(),this._position()),this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option",n)},_setOption:function(e,t){var i,s,n=this.uiDialog;"dialogClass"===e&&n.removeClass(this.options.dialogClass).addClass(t),"disabled"!==e&&(this._super(e,t),"appendTo"===e&&this.uiDialog.appendTo(this._appendTo()),"buttons"===e&&this._createButtons(),"closeText"===e&&this.uiDialogTitlebarClose.button({label:""+t}),"draggable"===e&&(i=n.is(":data(ui-draggable)"),i&&!t&&n.draggable("destroy"),!i&&t&&this._makeDraggable()),"position"===e&&this._position(),"resizable"===e&&(s=n.is(":data(ui-resizable)"),s&&!t&&n.resizable("destroy"),s&&"string"==typeof t&&n.resizable("option","handles",t),s||t===!1||this._makeResizable()),"title"===e&&this._title(this.uiDialogTitlebar.find(".ui-dialog-title")))},_size:function(){var e,t,i,s=this.options;this.element.show().css({width:"auto",minHeight:0,maxHeight:"none",height:0}),s.minWidth>s.width&&(s.width=s.minWidth),e=this.uiDialog.css({height:"auto",width:s.width}).outerHeight(),t=Math.max(0,s.minHeight-e),i="number"==typeof s.maxHeight?Math.max(0,s.maxHeight-e):"none","auto"===s.height?this.element.css({minHeight:t,maxHeight:i,height:"auto"}):this.element.height(Math.max(0,s.height-e)),this.uiDialog.is(":data(ui-resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())},_blockFrames:function(){this.iframeBlocks=this.document.find("iframe").map(function(){var t=e(this);return e("<div>").css({position:"absolute",width:t.outerWidth(),height:t.outerHeight()}).appendTo(t.parent()).offset(t.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_allowInteraction:function(t){return e(t.target).closest(".ui-dialog").length?!0:!!e(t.target).closest(".ui-datepicker").length},_createOverlay:function(){if(this.options.modal){var t=!0;this._delay(function(){t=!1}),this.document.data("ui-dialog-overlays")||this._on(this.document,{focusin:function(e){t||this._allowInteraction(e)||(e.preventDefault(),this._trackingInstances()[0]._focusTabbable())}}),this.overlay=e("<div>").addClass("ui-widget-overlay ui-front").appendTo(this._appendTo()),this._on(this.overlay,{mousedown:"_keepFocus"}),this.document.data("ui-dialog-overlays",(this.document.data("ui-dialog-overlays")||0)+1)}},_destroyOverlay:function(){if(this.options.modal&&this.overlay){var e=this.document.data("ui-dialog-overlays")-1;e?this.document.data("ui-dialog-overlays",e):this.document.unbind("focusin").removeData("ui-dialog-overlays"),this.overlay.remove(),this.overlay=null}}}),e.widget("ui.droppable",{version:"1.11.1",widgetEventPrefix:"drop",options:{accept:"*",activeClass:!1,addClasses:!0,greedy:!1,hoverClass:!1,scope:"default",tolerance:"intersect",activate:null,deactivate:null,drop:null,out:null,over:null},_create:function(){var t,i=this.options,s=i.accept;this.isover=!1,this.isout=!0,this.accept=e.isFunction(s)?s:function(e){return e.is(s)},this.proportions=function(){return arguments.length?(t=arguments[0],void 0):t?t:t={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight}},this._addToManager(i.scope),i.addClasses&&this.element.addClass("ui-droppable")},_addToManager:function(t){e.ui.ddmanager.droppables[t]=e.ui.ddmanager.droppables[t]||[],e.ui.ddmanager.droppables[t].push(this)},_splice:function(e){for(var t=0;e.length>t;t++)e[t]===this&&e.splice(t,1)},_destroy:function(){var t=e.ui.ddmanager.droppables[this.options.scope];this._splice(t),this.element.removeClass("ui-droppable ui-droppable-disabled")},_setOption:function(t,i){if("accept"===t)this.accept=e.isFunction(i)?i:function(e){return e.is(i)};else if("scope"===t){var s=e.ui.ddmanager.droppables[this.options.scope];this._splice(s),this._addToManager(i)}this._super(t,i)},_activate:function(t){var i=e.ui.ddmanager.current;this.options.activeClass&&this.element.addClass(this.options.activeClass),i&&this._trigger("activate",t,this.ui(i))},_deactivate:function(t){var i=e.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass),i&&this._trigger("deactivate",t,this.ui(i))},_over:function(t){var i=e.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this.options.hoverClass&&this.element.addClass(this.options.hoverClass),this._trigger("over",t,this.ui(i)))},_out:function(t){var i=e.ui.ddmanager.current;i&&(i.currentItem||i.element)[0]!==this.element[0]&&this.accept.call(this.element[0],i.currentItem||i.element)&&(this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("out",t,this.ui(i)))},_drop:function(t,i){var s=i||e.ui.ddmanager.current,n=!1;return s&&(s.currentItem||s.element)[0]!==this.element[0]?(this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function(){var i=e(this).droppable("instance");return i.options.greedy&&!i.options.disabled&&i.options.scope===s.options.scope&&i.accept.call(i.element[0],s.currentItem||s.element)&&e.ui.intersect(s,e.extend(i,{offset:i.element.offset()}),i.options.tolerance,t)?(n=!0,!1):void 0}),n?!1:this.accept.call(this.element[0],s.currentItem||s.element)?(this.options.activeClass&&this.element.removeClass(this.options.activeClass),this.options.hoverClass&&this.element.removeClass(this.options.hoverClass),this._trigger("drop",t,this.ui(s)),this.element):!1):!1},ui:function(e){return{draggable:e.currentItem||e.element,helper:e.helper,position:e.position,offset:e.positionAbs}}}),e.ui.intersect=function(){function e(e,t,i){return e>=t&&t+i>e}return function(t,i,s,n){if(!i.offset)return!1;var a=(t.positionAbs||t.position.absolute).left,o=(t.positionAbs||t.position.absolute).top,r=a+t.helperProportions.width,h=o+t.helperProportions.height,l=i.offset.left,u=i.offset.top,d=l+i.proportions().width,c=u+i.proportions().height;switch(s){case"fit":return a>=l&&d>=r&&o>=u&&c>=h;case"intersect":return a+t.helperProportions.width/2>l&&d>r-t.helperProportions.width/2&&o+t.helperProportions.height/2>u&&c>h-t.helperProportions.height/2;case"pointer":return e(n.pageY,u,i.proportions().height)&&e(n.pageX,l,i.proportions().width);case"touch":return(o>=u&&c>=o||h>=u&&c>=h||u>o&&h>c)&&(a>=l&&d>=a||r>=l&&d>=r||l>a&&r>d);default:return!1}}}(),e.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(t,i){var s,n,a=e.ui.ddmanager.droppables[t.options.scope]||[],o=i?i.type:null,r=(t.currentItem||t.element).find(":data(ui-droppable)").addBack();e:for(s=0;a.length>s;s++)if(!(a[s].options.disabled||t&&!a[s].accept.call(a[s].element[0],t.currentItem||t.element))){for(n=0;r.length>n;n++)if(r[n]===a[s].element[0]){a[s].proportions().height=0;continue e}a[s].visible="none"!==a[s].element.css("display"),a[s].visible&&("mousedown"===o&&a[s]._activate.call(a[s],i),a[s].offset=a[s].element.offset(),a[s].proportions({width:a[s].element[0].offsetWidth,height:a[s].element[0].offsetHeight}))}},drop:function(t,i){var s=!1;return e.each((e.ui.ddmanager.droppables[t.options.scope]||[]).slice(),function(){this.options&&(!this.options.disabled&&this.visible&&e.ui.intersect(t,this,this.options.tolerance,i)&&(s=this._drop.call(this,i)||s),!this.options.disabled&&this.visible&&this.accept.call(this.element[0],t.currentItem||t.element)&&(this.isout=!0,this.isover=!1,this._deactivate.call(this,i)))}),s},dragStart:function(t,i){t.element.parentsUntil("body").bind("scroll.droppable",function(){t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,i)})},drag:function(t,i){t.options.refreshPositions&&e.ui.ddmanager.prepareOffsets(t,i),e.each(e.ui.ddmanager.droppables[t.options.scope]||[],function(){if(!this.options.disabled&&!this.greedyChild&&this.visible){var s,n,a,o=e.ui.intersect(t,this,this.options.tolerance,i),r=!o&&this.isover?"isout":o&&!this.isover?"isover":null;r&&(this.options.greedy&&(n=this.options.scope,a=this.element.parents(":data(ui-droppable)").filter(function(){return e(this).droppable("instance").options.scope===n}),a.length&&(s=e(a[0]).droppable("instance"),s.greedyChild="isover"===r)),s&&"isover"===r&&(s.isover=!1,s.isout=!0,s._out.call(s,i)),this[r]=!0,this["isout"===r?"isover":"isout"]=!1,this["isover"===r?"_over":"_out"].call(this,i),s&&"isout"===r&&(s.isout=!1,s.isover=!0,s._over.call(s,i)))}})},dragStop:function(t,i){t.element.parentsUntil("body").unbind("scroll.droppable"),t.options.refreshPositions||e.ui.ddmanager.prepareOffsets(t,i)}},e.ui.droppable;var y="ui-effects-",b=e;e.effects={effect:{}},function(e,t){function i(e,t,i){var s=d[t.type]||{};return null==e?i||!t.def?null:t.def:(e=s.floor?~~e:parseFloat(e),isNaN(e)?t.def:s.mod?(e+s.mod)%s.mod:0>e?0:e>s.max?s.max:e)}function s(i){var s=l(),n=s._rgba=[];return i=i.toLowerCase(),f(h,function(e,a){var o,r=a.re.exec(i),h=r&&a.parse(r),l=a.space||"rgba";return h?(o=s[l](h),s[u[l].cache]=o[u[l].cache],n=s._rgba=o._rgba,!1):t}),n.length?("0,0,0,0"===n.join()&&e.extend(n,a.transparent),s):a[i]}function n(e,t,i){return i=(i+1)%1,1>6*i?e+6*(t-e)*i:1>2*i?t:2>3*i?e+6*(t-e)*(2/3-i):e}var a,o="backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",r=/^([\-+])=\s*(\d+\.?\d*)/,h=[{re:/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(e){return[e[1],e[2],e[3],e[4]]}},{re:/rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,parse:function(e){return[2.55*e[1],2.55*e[2],2.55*e[3],e[4]]}},{re:/#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,parse:function(e){return[parseInt(e[1],16),parseInt(e[2],16),parseInt(e[3],16)]}},{re:/#([a-f0-9])([a-f0-9])([a-f0-9])/,parse:function(e){return[parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16)]}},{re:/hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,space:"hsla",parse:function(e){return[e[1],e[2]/100,e[3]/100,e[4]]}}],l=e.Color=function(t,i,s,n){return new e.Color.fn.parse(t,i,s,n)},u={rgba:{props:{red:{idx:0,type:"byte"},green:{idx:1,type:"byte"},blue:{idx:2,type:"byte"}}},hsla:{props:{hue:{idx:0,type:"degrees"},saturation:{idx:1,type:"percent"},lightness:{idx:2,type:"percent"}}}},d={"byte":{floor:!0,max:255},percent:{max:1},degrees:{mod:360,floor:!0}},c=l.support={},p=e("<p>")[0],f=e.each;p.style.cssText="background-color:rgba(1,1,1,.5)",c.rgba=p.style.backgroundColor.indexOf("rgba")>-1,f(u,function(e,t){t.cache="_"+e,t.props.alpha={idx:3,type:"percent",def:1}}),l.fn=e.extend(l.prototype,{parse:function(n,o,r,h){if(n===t)return this._rgba=[null,null,null,null],this;(n.jquery||n.nodeType)&&(n=e(n).css(o),o=t);var d=this,c=e.type(n),p=this._rgba=[];return o!==t&&(n=[n,o,r,h],c="array"),"string"===c?this.parse(s(n)||a._default):"array"===c?(f(u.rgba.props,function(e,t){p[t.idx]=i(n[t.idx],t)}),this):"object"===c?(n instanceof l?f(u,function(e,t){n[t.cache]&&(d[t.cache]=n[t.cache].slice())}):f(u,function(t,s){var a=s.cache;f(s.props,function(e,t){if(!d[a]&&s.to){if("alpha"===e||null==n[e])return;d[a]=s.to(d._rgba)}d[a][t.idx]=i(n[e],t,!0)}),d[a]&&0>e.inArray(null,d[a].slice(0,3))&&(d[a][3]=1,s.from&&(d._rgba=s.from(d[a])))}),this):t},is:function(e){var i=l(e),s=!0,n=this;return f(u,function(e,a){var o,r=i[a.cache];return r&&(o=n[a.cache]||a.to&&a.to(n._rgba)||[],f(a.props,function(e,i){return null!=r[i.idx]?s=r[i.idx]===o[i.idx]:t})),s}),s},_space:function(){var e=[],t=this;return f(u,function(i,s){t[s.cache]&&e.push(i)}),e.pop()},transition:function(e,t){var s=l(e),n=s._space(),a=u[n],o=0===this.alpha()?l("transparent"):this,r=o[a.cache]||a.to(o._rgba),h=r.slice();return s=s[a.cache],f(a.props,function(e,n){var a=n.idx,o=r[a],l=s[a],u=d[n.type]||{};null!==l&&(null===o?h[a]=l:(u.mod&&(l-o>u.mod/2?o+=u.mod:o-l>u.mod/2&&(o-=u.mod)),h[a]=i((l-o)*t+o,n)))}),this[n](h)},blend:function(t){if(1===this._rgba[3])return this;var i=this._rgba.slice(),s=i.pop(),n=l(t)._rgba;return l(e.map(i,function(e,t){return(1-s)*n[t]+s*e}))},toRgbaString:function(){var t="rgba(",i=e.map(this._rgba,function(e,t){return null==e?t>2?1:0:e});return 1===i[3]&&(i.pop(),t="rgb("),t+i.join()+")"},toHslaString:function(){var t="hsla(",i=e.map(this.hsla(),function(e,t){return null==e&&(e=t>2?1:0),t&&3>t&&(e=Math.round(100*e)+"%"),e});return 1===i[3]&&(i.pop(),t="hsl("),t+i.join()+")"},toHexString:function(t){var i=this._rgba.slice(),s=i.pop();return t&&i.push(~~(255*s)),"#"+e.map(i,function(e){return e=(e||0).toString(16),1===e.length?"0"+e:e}).join("")},toString:function(){return 0===this._rgba[3]?"transparent":this.toRgbaString()}}),l.fn.parse.prototype=l.fn,u.hsla.to=function(e){if(null==e[0]||null==e[1]||null==e[2])return[null,null,null,e[3]];var t,i,s=e[0]/255,n=e[1]/255,a=e[2]/255,o=e[3],r=Math.max(s,n,a),h=Math.min(s,n,a),l=r-h,u=r+h,d=.5*u;return t=h===r?0:s===r?60*(n-a)/l+360:n===r?60*(a-s)/l+120:60*(s-n)/l+240,i=0===l?0:.5>=d?l/u:l/(2-u),[Math.round(t)%360,i,d,null==o?1:o]},u.hsla.from=function(e){if(null==e[0]||null==e[1]||null==e[2])return[null,null,null,e[3]];var t=e[0]/360,i=e[1],s=e[2],a=e[3],o=.5>=s?s*(1+i):s+i-s*i,r=2*s-o;return[Math.round(255*n(r,o,t+1/3)),Math.round(255*n(r,o,t)),Math.round(255*n(r,o,t-1/3)),a]},f(u,function(s,n){var a=n.props,o=n.cache,h=n.to,u=n.from;l.fn[s]=function(s){if(h&&!this[o]&&(this[o]=h(this._rgba)),s===t)return this[o].slice();var n,r=e.type(s),d="array"===r||"object"===r?s:arguments,c=this[o].slice();return f(a,function(e,t){var s=d["object"===r?e:t.idx];null==s&&(s=c[t.idx]),c[t.idx]=i(s,t)}),u?(n=l(u(c)),n[o]=c,n):l(c)},f(a,function(t,i){l.fn[t]||(l.fn[t]=function(n){var a,o=e.type(n),h="alpha"===t?this._hsla?"hsla":"rgba":s,l=this[h](),u=l[i.idx];return"undefined"===o?u:("function"===o&&(n=n.call(this,u),o=e.type(n)),null==n&&i.empty?this:("string"===o&&(a=r.exec(n),a&&(n=u+parseFloat(a[2])*("+"===a[1]?1:-1))),l[i.idx]=n,this[h](l)))})})}),l.hook=function(t){var i=t.split(" ");f(i,function(t,i){e.cssHooks[i]={set:function(t,n){var a,o,r="";if("transparent"!==n&&("string"!==e.type(n)||(a=s(n)))){if(n=l(a||n),!c.rgba&&1!==n._rgba[3]){for(o="backgroundColor"===i?t.parentNode:t;(""===r||"transparent"===r)&&o&&o.style;)try{r=e.css(o,"backgroundColor"),o=o.parentNode}catch(h){}n=n.blend(r&&"transparent"!==r?r:"_default")}n=n.toRgbaString()}try{t.style[i]=n}catch(h){}}},e.fx.step[i]=function(t){t.colorInit||(t.start=l(t.elem,i),t.end=l(t.end),t.colorInit=!0),e.cssHooks[i].set(t.elem,t.start.transition(t.end,t.pos))}})},l.hook(o),e.cssHooks.borderColor={expand:function(e){var t={};return f(["Top","Right","Bottom","Left"],function(i,s){t["border"+s+"Color"]=e}),t}},a=e.Color.names={aqua:"#00ffff",black:"#000000",blue:"#0000ff",fuchsia:"#ff00ff",gray:"#808080",green:"#008000",lime:"#00ff00",maroon:"#800000",navy:"#000080",olive:"#808000",purple:"#800080",red:"#ff0000",silver:"#c0c0c0",teal:"#008080",white:"#ffffff",yellow:"#ffff00",transparent:[null,null,null,0],_default:"#ffffff"}}(b),function(){function t(t){var i,s,n=t.ownerDocument.defaultView?t.ownerDocument.defaultView.getComputedStyle(t,null):t.currentStyle,a={};if(n&&n.length&&n[0]&&n[n[0]])for(s=n.length;s--;)i=n[s],"string"==typeof n[i]&&(a[e.camelCase(i)]=n[i]);else for(i in n)"string"==typeof n[i]&&(a[i]=n[i]);return a}function i(t,i){var s,a,o={};for(s in i)a=i[s],t[s]!==a&&(n[s]||(e.fx.step[s]||!isNaN(parseFloat(a)))&&(o[s]=a));return o}var s=["add","remove","toggle"],n={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};e.each(["borderLeftStyle","borderRightStyle","borderBottomStyle","borderTopStyle"],function(t,i){e.fx.step[i]=function(e){("none"!==e.end&&!e.setAttr||1===e.pos&&!e.setAttr)&&(b.style(e.elem,i,e.end),e.setAttr=!0)}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e.effects.animateClass=function(n,a,o,r){var h=e.speed(a,o,r);return this.queue(function(){var a,o=e(this),r=o.attr("class")||"",l=h.children?o.find("*").addBack():o;l=l.map(function(){var i=e(this);return{el:i,start:t(this)}}),a=function(){e.each(s,function(e,t){n[t]&&o[t+"Class"](n[t])})},a(),l=l.map(function(){return this.end=t(this.el[0]),this.diff=i(this.start,this.end),this}),o.attr("class",r),l=l.map(function(){var t=this,i=e.Deferred(),s=e.extend({},h,{queue:!1,complete:function(){i.resolve(t)}});return this.el.animate(this.diff,s),i.promise()}),e.when.apply(e,l.get()).done(function(){a(),e.each(arguments,function(){var t=this.el;e.each(this.diff,function(e){t.css(e,"")})}),h.complete.call(o[0])})})},e.fn.extend({addClass:function(t){return function(i,s,n,a){return s?e.effects.animateClass.call(this,{add:i},s,n,a):t.apply(this,arguments)}}(e.fn.addClass),removeClass:function(t){return function(i,s,n,a){return arguments.length>1?e.effects.animateClass.call(this,{remove:i},s,n,a):t.apply(this,arguments)}}(e.fn.removeClass),toggleClass:function(t){return function(i,s,n,a,o){return"boolean"==typeof s||void 0===s?n?e.effects.animateClass.call(this,s?{add:i}:{remove:i},n,a,o):t.apply(this,arguments):e.effects.animateClass.call(this,{toggle:i},s,n,a)}}(e.fn.toggleClass),switchClass:function(t,i,s,n,a){return e.effects.animateClass.call(this,{add:i,remove:t},s,n,a)}})}(),function(){function t(t,i,s,n){return e.isPlainObject(t)&&(i=t,t=t.effect),t={effect:t},null==i&&(i={}),e.isFunction(i)&&(n=i,s=null,i={}),("number"==typeof i||e.fx.speeds[i])&&(n=s,s=i,i={}),e.isFunction(s)&&(n=s,s=null),i&&e.extend(t,i),s=s||i.duration,t.duration=e.fx.off?0:"number"==typeof s?s:s in e.fx.speeds?e.fx.speeds[s]:e.fx.speeds._default,t.complete=n||i.complete,t}function i(t){return!t||"number"==typeof t||e.fx.speeds[t]?!0:"string"!=typeof t||e.effects.effect[t]?e.isFunction(t)?!0:"object"!=typeof t||t.effect?!1:!0:!0}e.extend(e.effects,{version:"1.11.1",save:function(e,t){for(var i=0;t.length>i;i++)null!==t[i]&&e.data(y+t[i],e[0].style[t[i]])},restore:function(e,t){var i,s;for(s=0;t.length>s;s++)null!==t[s]&&(i=e.data(y+t[s]),void 0===i&&(i=""),e.css(t[s],i))},setMode:function(e,t){return"toggle"===t&&(t=e.is(":hidden")?"show":"hide"),t},getBaseline:function(e,t){var i,s;switch(e[0]){case"top":i=0;break;case"middle":i=.5;break;case"bottom":i=1;break;default:i=e[0]/t.height}switch(e[1]){case"left":s=0;break;case"center":s=.5;break;case"right":s=1;break;default:s=e[1]/t.width}return{x:s,y:i}},createWrapper:function(t){if(t.parent().is(".ui-effects-wrapper"))return t.parent();var i={width:t.outerWidth(!0),height:t.outerHeight(!0),"float":t.css("float")},s=e("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}),n={width:t.width(),height:t.height()},a=document.activeElement;try{a.id}catch(o){a=document.body}return t.wrap(s),(t[0]===a||e.contains(t[0],a))&&e(a).focus(),s=t.parent(),"static"===t.css("position")?(s.css({position:"relative"}),t.css({position:"relative"})):(e.extend(i,{position:t.css("position"),zIndex:t.css("z-index")}),e.each(["top","left","bottom","right"],function(e,s){i[s]=t.css(s),isNaN(parseInt(i[s],10))&&(i[s]="auto")}),t.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})),t.css(n),s.css(i).show()},removeWrapper:function(t){var i=document.activeElement;return t.parent().is(".ui-effects-wrapper")&&(t.parent().replaceWith(t),(t[0]===i||e.contains(t[0],i))&&e(i).focus()),t},setTransition:function(t,i,s,n){return n=n||{},e.each(i,function(e,i){var a=t.cssUnit(i);a[0]>0&&(n[i]=a[0]*s+a[1])}),n}}),e.fn.extend({effect:function(){function i(t){function i(){e.isFunction(a)&&a.call(n[0]),e.isFunction(t)&&t()}var n=e(this),a=s.complete,r=s.mode;(n.is(":hidden")?"hide"===r:"show"===r)?(n[r](),i()):o.call(n[0],s,i)}var s=t.apply(this,arguments),n=s.mode,a=s.queue,o=e.effects.effect[s.effect];return e.fx.off||!o?n?this[n](s.duration,s.complete):this.each(function(){s.complete&&s.complete.call(this)}):a===!1?this.each(i):this.queue(a||"fx",i)},show:function(e){return function(s){if(i(s))return e.apply(this,arguments);var n=t.apply(this,arguments);return n.mode="show",this.effect.call(this,n)}}(e.fn.show),hide:function(e){return function(s){if(i(s))return e.apply(this,arguments);var n=t.apply(this,arguments);return n.mode="hide",this.effect.call(this,n)}}(e.fn.hide),toggle:function(e){return function(s){if(i(s)||"boolean"==typeof s)return e.apply(this,arguments);var n=t.apply(this,arguments);return n.mode="toggle",this.effect.call(this,n)}}(e.fn.toggle),cssUnit:function(t){var i=this.css(t),s=[];return e.each(["em","px","%","pt"],function(e,t){i.indexOf(t)>0&&(s=[parseFloat(i),t])}),s}})}(),function(){var t={};e.each(["Quad","Cubic","Quart","Quint","Expo"],function(e,i){t[i]=function(t){return Math.pow(t,e+2)}}),e.extend(t,{Sine:function(e){return 1-Math.cos(e*Math.PI/2)},Circ:function(e){return 1-Math.sqrt(1-e*e)},Elastic:function(e){return 0===e||1===e?e:-Math.pow(2,8*(e-1))*Math.sin((80*(e-1)-7.5)*Math.PI/15)},Back:function(e){return e*e*(3*e-2)},Bounce:function(e){for(var t,i=4;((t=Math.pow(2,--i))-1)/11>e;);return 1/Math.pow(4,3-i)-7.5625*Math.pow((3*t-2)/22-e,2)}}),e.each(t,function(t,i){e.easing["easeIn"+t]=i,e.easing["easeOut"+t]=function(e){return 1-i(1-e)},e.easing["easeInOut"+t]=function(e){return.5>e?i(2*e)/2:1-i(-2*e+2)/2}})}(),e.effects,e.effects.effect.blind=function(t,i){var s,n,a,o=e(this),r=/up|down|vertical/,h=/up|left|vertical|horizontal/,l=["position","top","bottom","left","right","height","width"],u=e.effects.setMode(o,t.mode||"hide"),d=t.direction||"up",c=r.test(d),p=c?"height":"width",f=c?"top":"left",m=h.test(d),g={},v="show"===u;o.parent().is(".ui-effects-wrapper")?e.effects.save(o.parent(),l):e.effects.save(o,l),o.show(),s=e.effects.createWrapper(o).css({overflow:"hidden"}),n=s[p](),a=parseFloat(s.css(f))||0,g[p]=v?n:0,m||(o.css(c?"bottom":"right",0).css(c?"top":"left","auto").css({position:"absolute"}),g[f]=v?a:n+a),v&&(s.css(p,0),m||s.css(f,a+n)),s.animate(g,{duration:t.duration,easing:t.easing,queue:!1,complete:function(){"hide"===u&&o.hide(),e.effects.restore(o,l),e.effects.removeWrapper(o),i()}})},e.effects.effect.bounce=function(t,i){var s,n,a,o=e(this),r=["position","top","bottom","left","right","height","width"],h=e.effects.setMode(o,t.mode||"effect"),l="hide"===h,u="show"===h,d=t.direction||"up",c=t.distance,p=t.times||5,f=2*p+(u||l?1:0),m=t.duration/f,g=t.easing,v="up"===d||"down"===d?"top":"left",y="up"===d||"left"===d,b=o.queue(),_=b.length;for((u||l)&&r.push("opacity"),e.effects.save(o,r),o.show(),e.effects.createWrapper(o),c||(c=o["top"===v?"outerHeight":"outerWidth"]()/3),u&&(a={opacity:1},a[v]=0,o.css("opacity",0).css(v,y?2*-c:2*c).animate(a,m,g)),l&&(c/=Math.pow(2,p-1)),a={},a[v]=0,s=0;p>s;s++)n={},n[v]=(y?"-=":"+=")+c,o.animate(n,m,g).animate(a,m,g),c=l?2*c:c/2;l&&(n={opacity:0},n[v]=(y?"-=":"+=")+c,o.animate(n,m,g)),o.queue(function(){l&&o.hide(),e.effects.restore(o,r),e.effects.removeWrapper(o),i()}),_>1&&b.splice.apply(b,[1,0].concat(b.splice(_,f+1))),o.dequeue()},e.effects.effect.clip=function(t,i){var s,n,a,o=e(this),r=["position","top","bottom","left","right","height","width"],h=e.effects.setMode(o,t.mode||"hide"),l="show"===h,u=t.direction||"vertical",d="vertical"===u,c=d?"height":"width",p=d?"top":"left",f={};e.effects.save(o,r),o.show(),s=e.effects.createWrapper(o).css({overflow:"hidden"}),n="IMG"===o[0].tagName?s:o,a=n[c](),l&&(n.css(c,0),n.css(p,a/2)),f[c]=l?a:0,f[p]=l?0:a/2,n.animate(f,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){l||o.hide(),e.effects.restore(o,r),e.effects.removeWrapper(o),i()}})},e.effects.effect.drop=function(t,i){var s,n=e(this),a=["position","top","bottom","left","right","opacity","height","width"],o=e.effects.setMode(n,t.mode||"hide"),r="show"===o,h=t.direction||"left",l="up"===h||"down"===h?"top":"left",u="up"===h||"left"===h?"pos":"neg",d={opacity:r?1:0};e.effects.save(n,a),n.show(),e.effects.createWrapper(n),s=t.distance||n["top"===l?"outerHeight":"outerWidth"](!0)/2,r&&n.css("opacity",0).css(l,"pos"===u?-s:s),d[l]=(r?"pos"===u?"+=":"-=":"pos"===u?"-=":"+=")+s,n.animate(d,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){"hide"===o&&n.hide(),e.effects.restore(n,a),e.effects.removeWrapper(n),i()}})},e.effects.effect.explode=function(t,i){function s(){b.push(this),b.length===d*c&&n()}function n(){p.css({visibility:"visible"}),e(b).remove(),m||p.hide(),i()}var a,o,r,h,l,u,d=t.pieces?Math.round(Math.sqrt(t.pieces)):3,c=d,p=e(this),f=e.effects.setMode(p,t.mode||"hide"),m="show"===f,g=p.show().css("visibility","hidden").offset(),v=Math.ceil(p.outerWidth()/c),y=Math.ceil(p.outerHeight()/d),b=[];for(a=0;d>a;a++)for(h=g.top+a*y,u=a-(d-1)/2,o=0;c>o;o++)r=g.left+o*v,l=o-(c-1)/2,p.clone().appendTo("body").wrap("<div></div>").css({position:"absolute",visibility:"visible",left:-o*v,top:-a*y}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:v,height:y,left:r+(m?l*v:0),top:h+(m?u*y:0),opacity:m?0:1}).animate({left:r+(m?0:l*v),top:h+(m?0:u*y),opacity:m?1:0},t.duration||500,t.easing,s)},e.effects.effect.fade=function(t,i){var s=e(this),n=e.effects.setMode(s,t.mode||"toggle");s.animate({opacity:n},{queue:!1,duration:t.duration,easing:t.easing,complete:i})},e.effects.effect.fold=function(t,i){var s,n,a=e(this),o=["position","top","bottom","left","right","height","width"],r=e.effects.setMode(a,t.mode||"hide"),h="show"===r,l="hide"===r,u=t.size||15,d=/([0-9]+)%/.exec(u),c=!!t.horizFirst,p=h!==c,f=p?["width","height"]:["height","width"],m=t.duration/2,g={},v={};e.effects.save(a,o),a.show(),s=e.effects.createWrapper(a).css({overflow:"hidden"}),n=p?[s.width(),s.height()]:[s.height(),s.width()],d&&(u=parseInt(d[1],10)/100*n[l?0:1]),h&&s.css(c?{height:0,width:u}:{height:u,width:0}),g[f[0]]=h?n[0]:u,v[f[1]]=h?n[1]:0,s.animate(g,m,t.easing).animate(v,m,t.easing,function(){l&&a.hide(),e.effects.restore(a,o),e.effects.removeWrapper(a),i()})},e.effects.effect.highlight=function(t,i){var s=e(this),n=["backgroundImage","backgroundColor","opacity"],a=e.effects.setMode(s,t.mode||"show"),o={backgroundColor:s.css("backgroundColor")};"hide"===a&&(o.opacity=0),e.effects.save(s,n),s.show().css({backgroundImage:"none",backgroundColor:t.color||"#ffff99"}).animate(o,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){"hide"===a&&s.hide(),e.effects.restore(s,n),i()}})},e.effects.effect.size=function(t,i){var s,n,a,o=e(this),r=["position","top","bottom","left","right","width","height","overflow","opacity"],h=["position","top","bottom","left","right","overflow","opacity"],l=["width","height","overflow"],u=["fontSize"],d=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],c=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],p=e.effects.setMode(o,t.mode||"effect"),f=t.restore||"effect"!==p,m=t.scale||"both",g=t.origin||["middle","center"],v=o.css("position"),y=f?r:h,b={height:0,width:0,outerHeight:0,outerWidth:0};"show"===p&&o.show(),s={height:o.height(),width:o.width(),outerHeight:o.outerHeight(),outerWidth:o.outerWidth()},"toggle"===t.mode&&"show"===p?(o.from=t.to||b,o.to=t.from||s):(o.from=t.from||("show"===p?b:s),o.to=t.to||("hide"===p?b:s)),a={from:{y:o.from.height/s.height,x:o.from.width/s.width},to:{y:o.to.height/s.height,x:o.to.width/s.width}},("box"===m||"both"===m)&&(a.from.y!==a.to.y&&(y=y.concat(d),o.from=e.effects.setTransition(o,d,a.from.y,o.from),o.to=e.effects.setTransition(o,d,a.to.y,o.to)),a.from.x!==a.to.x&&(y=y.concat(c),o.from=e.effects.setTransition(o,c,a.from.x,o.from),o.to=e.effects.setTransition(o,c,a.to.x,o.to))),("content"===m||"both"===m)&&a.from.y!==a.to.y&&(y=y.concat(u).concat(l),o.from=e.effects.setTransition(o,u,a.from.y,o.from),o.to=e.effects.setTransition(o,u,a.to.y,o.to)),e.effects.save(o,y),o.show(),e.effects.createWrapper(o),o.css("overflow","hidden").css(o.from),g&&(n=e.effects.getBaseline(g,s),o.from.top=(s.outerHeight-o.outerHeight())*n.y,o.from.left=(s.outerWidth-o.outerWidth())*n.x,o.to.top=(s.outerHeight-o.to.outerHeight)*n.y,o.to.left=(s.outerWidth-o.to.outerWidth)*n.x),o.css(o.from),("content"===m||"both"===m)&&(d=d.concat(["marginTop","marginBottom"]).concat(u),c=c.concat(["marginLeft","marginRight"]),l=r.concat(d).concat(c),o.find("*[width]").each(function(){var i=e(this),s={height:i.height(),width:i.width(),outerHeight:i.outerHeight(),outerWidth:i.outerWidth()};
11
+ f&&e.effects.save(i,l),i.from={height:s.height*a.from.y,width:s.width*a.from.x,outerHeight:s.outerHeight*a.from.y,outerWidth:s.outerWidth*a.from.x},i.to={height:s.height*a.to.y,width:s.width*a.to.x,outerHeight:s.height*a.to.y,outerWidth:s.width*a.to.x},a.from.y!==a.to.y&&(i.from=e.effects.setTransition(i,d,a.from.y,i.from),i.to=e.effects.setTransition(i,d,a.to.y,i.to)),a.from.x!==a.to.x&&(i.from=e.effects.setTransition(i,c,a.from.x,i.from),i.to=e.effects.setTransition(i,c,a.to.x,i.to)),i.css(i.from),i.animate(i.to,t.duration,t.easing,function(){f&&e.effects.restore(i,l)})})),o.animate(o.to,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){0===o.to.opacity&&o.css("opacity",o.from.opacity),"hide"===p&&o.hide(),e.effects.restore(o,y),f||("static"===v?o.css({position:"relative",top:o.to.top,left:o.to.left}):e.each(["top","left"],function(e,t){o.css(t,function(t,i){var s=parseInt(i,10),n=e?o.to.left:o.to.top;return"auto"===i?n+"px":s+n+"px"})})),e.effects.removeWrapper(o),i()}})},e.effects.effect.scale=function(t,i){var s=e(this),n=e.extend(!0,{},t),a=e.effects.setMode(s,t.mode||"effect"),o=parseInt(t.percent,10)||(0===parseInt(t.percent,10)?0:"hide"===a?0:100),r=t.direction||"both",h=t.origin,l={height:s.height(),width:s.width(),outerHeight:s.outerHeight(),outerWidth:s.outerWidth()},u={y:"horizontal"!==r?o/100:1,x:"vertical"!==r?o/100:1};n.effect="size",n.queue=!1,n.complete=i,"effect"!==a&&(n.origin=h||["middle","center"],n.restore=!0),n.from=t.from||("show"===a?{height:0,width:0,outerHeight:0,outerWidth:0}:l),n.to={height:l.height*u.y,width:l.width*u.x,outerHeight:l.outerHeight*u.y,outerWidth:l.outerWidth*u.x},n.fade&&("show"===a&&(n.from.opacity=0,n.to.opacity=1),"hide"===a&&(n.from.opacity=1,n.to.opacity=0)),s.effect(n)},e.effects.effect.puff=function(t,i){var s=e(this),n=e.effects.setMode(s,t.mode||"hide"),a="hide"===n,o=parseInt(t.percent,10)||150,r=o/100,h={height:s.height(),width:s.width(),outerHeight:s.outerHeight(),outerWidth:s.outerWidth()};e.extend(t,{effect:"scale",queue:!1,fade:!0,mode:n,complete:i,percent:a?o:100,from:a?h:{height:h.height*r,width:h.width*r,outerHeight:h.outerHeight*r,outerWidth:h.outerWidth*r}}),s.effect(t)},e.effects.effect.pulsate=function(t,i){var s,n=e(this),a=e.effects.setMode(n,t.mode||"show"),o="show"===a,r="hide"===a,h=o||"hide"===a,l=2*(t.times||5)+(h?1:0),u=t.duration/l,d=0,c=n.queue(),p=c.length;for((o||!n.is(":visible"))&&(n.css("opacity",0).show(),d=1),s=1;l>s;s++)n.animate({opacity:d},u,t.easing),d=1-d;n.animate({opacity:d},u,t.easing),n.queue(function(){r&&n.hide(),i()}),p>1&&c.splice.apply(c,[1,0].concat(c.splice(p,l+1))),n.dequeue()},e.effects.effect.shake=function(t,i){var s,n=e(this),a=["position","top","bottom","left","right","height","width"],o=e.effects.setMode(n,t.mode||"effect"),r=t.direction||"left",h=t.distance||20,l=t.times||3,u=2*l+1,d=Math.round(t.duration/u),c="up"===r||"down"===r?"top":"left",p="up"===r||"left"===r,f={},m={},g={},v=n.queue(),y=v.length;for(e.effects.save(n,a),n.show(),e.effects.createWrapper(n),f[c]=(p?"-=":"+=")+h,m[c]=(p?"+=":"-=")+2*h,g[c]=(p?"-=":"+=")+2*h,n.animate(f,d,t.easing),s=1;l>s;s++)n.animate(m,d,t.easing).animate(g,d,t.easing);n.animate(m,d,t.easing).animate(f,d/2,t.easing).queue(function(){"hide"===o&&n.hide(),e.effects.restore(n,a),e.effects.removeWrapper(n),i()}),y>1&&v.splice.apply(v,[1,0].concat(v.splice(y,u+1))),n.dequeue()},e.effects.effect.slide=function(t,i){var s,n=e(this),a=["position","top","bottom","left","right","width","height"],o=e.effects.setMode(n,t.mode||"show"),r="show"===o,h=t.direction||"left",l="up"===h||"down"===h?"top":"left",u="up"===h||"left"===h,d={};e.effects.save(n,a),n.show(),s=t.distance||n["top"===l?"outerHeight":"outerWidth"](!0),e.effects.createWrapper(n).css({overflow:"hidden"}),r&&n.css(l,u?isNaN(s)?"-"+s:-s:s),d[l]=(r?u?"+=":"-=":u?"-=":"+=")+s,n.animate(d,{queue:!1,duration:t.duration,easing:t.easing,complete:function(){"hide"===o&&n.hide(),e.effects.restore(n,a),e.effects.removeWrapper(n),i()}})},e.effects.effect.transfer=function(t,i){var s=e(this),n=e(t.to),a="fixed"===n.css("position"),o=e("body"),r=a?o.scrollTop():0,h=a?o.scrollLeft():0,l=n.offset(),u={top:l.top-r,left:l.left-h,height:n.innerHeight(),width:n.innerWidth()},d=s.offset(),c=e("<div class='ui-effects-transfer'></div>").appendTo(document.body).addClass(t.className).css({top:d.top-r,left:d.left-h,height:s.innerHeight(),width:s.innerWidth(),position:a?"fixed":"absolute"}).animate(u,t.duration,t.easing,function(){c.remove(),i()})},e.widget("ui.progressbar",{version:"1.11.1",options:{max:100,value:0,change:null,complete:null},min:0,_create:function(){this.oldValue=this.options.value=this._constrainedValue(),this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min}),this.valueDiv=e("<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>").appendTo(this.element),this._refreshValue()},_destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.valueDiv.remove()},value:function(e){return void 0===e?this.options.value:(this.options.value=this._constrainedValue(e),this._refreshValue(),void 0)},_constrainedValue:function(e){return void 0===e&&(e=this.options.value),this.indeterminate=e===!1,"number"!=typeof e&&(e=0),this.indeterminate?!1:Math.min(this.options.max,Math.max(this.min,e))},_setOptions:function(e){var t=e.value;delete e.value,this._super(e),this.options.value=this._constrainedValue(t),this._refreshValue()},_setOption:function(e,t){"max"===e&&(t=Math.max(this.min,t)),"disabled"===e&&this.element.toggleClass("ui-state-disabled",!!t).attr("aria-disabled",t),this._super(e,t)},_percentage:function(){return this.indeterminate?100:100*(this.options.value-this.min)/(this.options.max-this.min)},_refreshValue:function(){var t=this.options.value,i=this._percentage();this.valueDiv.toggle(this.indeterminate||t>this.min).toggleClass("ui-corner-right",t===this.options.max).width(i.toFixed(0)+"%"),this.element.toggleClass("ui-progressbar-indeterminate",this.indeterminate),this.indeterminate?(this.element.removeAttr("aria-valuenow"),this.overlayDiv||(this.overlayDiv=e("<div class='ui-progressbar-overlay'></div>").appendTo(this.valueDiv))):(this.element.attr({"aria-valuemax":this.options.max,"aria-valuenow":t}),this.overlayDiv&&(this.overlayDiv.remove(),this.overlayDiv=null)),this.oldValue!==t&&(this.oldValue=t,this._trigger("change")),t===this.options.max&&this._trigger("complete")}}),e.widget("ui.selectable",e.ui.mouse,{version:"1.11.1",options:{appendTo:"body",autoRefresh:!0,distance:0,filter:"*",tolerance:"touch",selected:null,selecting:null,start:null,stop:null,unselected:null,unselecting:null},_create:function(){var t,i=this;this.element.addClass("ui-selectable"),this.dragged=!1,this.refresh=function(){t=e(i.options.filter,i.element[0]),t.addClass("ui-selectee"),t.each(function(){var t=e(this),i=t.offset();e.data(this,"selectable-item",{element:this,$element:t,left:i.left,top:i.top,right:i.left+t.outerWidth(),bottom:i.top+t.outerHeight(),startselected:!1,selected:t.hasClass("ui-selected"),selecting:t.hasClass("ui-selecting"),unselecting:t.hasClass("ui-unselecting")})})},this.refresh(),this.selectees=t.addClass("ui-selectee"),this._mouseInit(),this.helper=e("<div class='ui-selectable-helper'></div>")},_destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item"),this.element.removeClass("ui-selectable ui-selectable-disabled"),this._mouseDestroy()},_mouseStart:function(t){var i=this,s=this.options;this.opos=[t.pageX,t.pageY],this.options.disabled||(this.selectees=e(s.filter,this.element[0]),this._trigger("start",t),e(s.appendTo).append(this.helper),this.helper.css({left:t.pageX,top:t.pageY,width:0,height:0}),s.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var s=e.data(this,"selectable-item");s.startselected=!0,t.metaKey||t.ctrlKey||(s.$element.removeClass("ui-selected"),s.selected=!1,s.$element.addClass("ui-unselecting"),s.unselecting=!0,i._trigger("unselecting",t,{unselecting:s.element}))}),e(t.target).parents().addBack().each(function(){var s,n=e.data(this,"selectable-item");return n?(s=!t.metaKey&&!t.ctrlKey||!n.$element.hasClass("ui-selected"),n.$element.removeClass(s?"ui-unselecting":"ui-selected").addClass(s?"ui-selecting":"ui-unselecting"),n.unselecting=!s,n.selecting=s,n.selected=s,s?i._trigger("selecting",t,{selecting:n.element}):i._trigger("unselecting",t,{unselecting:n.element}),!1):void 0}))},_mouseDrag:function(t){if(this.dragged=!0,!this.options.disabled){var i,s=this,n=this.options,a=this.opos[0],o=this.opos[1],r=t.pageX,h=t.pageY;return a>r&&(i=r,r=a,a=i),o>h&&(i=h,h=o,o=i),this.helper.css({left:a,top:o,width:r-a,height:h-o}),this.selectees.each(function(){var i=e.data(this,"selectable-item"),l=!1;i&&i.element!==s.element[0]&&("touch"===n.tolerance?l=!(i.left>r||a>i.right||i.top>h||o>i.bottom):"fit"===n.tolerance&&(l=i.left>a&&r>i.right&&i.top>o&&h>i.bottom),l?(i.selected&&(i.$element.removeClass("ui-selected"),i.selected=!1),i.unselecting&&(i.$element.removeClass("ui-unselecting"),i.unselecting=!1),i.selecting||(i.$element.addClass("ui-selecting"),i.selecting=!0,s._trigger("selecting",t,{selecting:i.element}))):(i.selecting&&((t.metaKey||t.ctrlKey)&&i.startselected?(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.$element.addClass("ui-selected"),i.selected=!0):(i.$element.removeClass("ui-selecting"),i.selecting=!1,i.startselected&&(i.$element.addClass("ui-unselecting"),i.unselecting=!0),s._trigger("unselecting",t,{unselecting:i.element}))),i.selected&&(t.metaKey||t.ctrlKey||i.startselected||(i.$element.removeClass("ui-selected"),i.selected=!1,i.$element.addClass("ui-unselecting"),i.unselecting=!0,s._trigger("unselecting",t,{unselecting:i.element})))))}),!1}},_mouseStop:function(t){var i=this;return this.dragged=!1,e(".ui-unselecting",this.element[0]).each(function(){var s=e.data(this,"selectable-item");s.$element.removeClass("ui-unselecting"),s.unselecting=!1,s.startselected=!1,i._trigger("unselected",t,{unselected:s.element})}),e(".ui-selecting",this.element[0]).each(function(){var s=e.data(this,"selectable-item");s.$element.removeClass("ui-selecting").addClass("ui-selected"),s.selecting=!1,s.selected=!0,s.startselected=!0,i._trigger("selected",t,{selected:s.element})}),this._trigger("stop",t),this.helper.remove(),!1}}),e.widget("ui.selectmenu",{version:"1.11.1",defaultElement:"<select>",options:{appendTo:null,disabled:null,icons:{button:"ui-icon-triangle-1-s"},position:{my:"left top",at:"left bottom",collision:"none"},width:null,change:null,close:null,focus:null,open:null,select:null},_create:function(){var e=this.element.uniqueId().attr("id");this.ids={element:e,button:e+"-button",menu:e+"-menu"},this._drawButton(),this._drawMenu(),this.options.disabled&&this.disable()},_drawButton:function(){var t=this,i=this.element.attr("tabindex");this.label=e("label[for='"+this.ids.element+"']").attr("for",this.ids.button),this._on(this.label,{click:function(e){this.button.focus(),e.preventDefault()}}),this.element.hide(),this.button=e("<span>",{"class":"ui-selectmenu-button ui-widget ui-state-default ui-corner-all",tabindex:i||this.options.disabled?-1:0,id:this.ids.button,role:"combobox","aria-expanded":"false","aria-autocomplete":"list","aria-owns":this.ids.menu,"aria-haspopup":"true"}).insertAfter(this.element),e("<span>",{"class":"ui-icon "+this.options.icons.button}).prependTo(this.button),this.buttonText=e("<span>",{"class":"ui-selectmenu-text"}).appendTo(this.button),this._setText(this.buttonText,this.element.find("option:selected").text()),this._resizeButton(),this._on(this.button,this._buttonEvents),this.button.one("focusin",function(){t.menuItems||t._refreshMenu()}),this._hoverable(this.button),this._focusable(this.button)},_drawMenu:function(){var t=this;this.menu=e("<ul>",{"aria-hidden":"true","aria-labelledby":this.ids.button,id:this.ids.menu}),this.menuWrap=e("<div>",{"class":"ui-selectmenu-menu ui-front"}).append(this.menu).appendTo(this._appendTo()),this.menuInstance=this.menu.menu({role:"listbox",select:function(e,i){e.preventDefault(),t._select(i.item.data("ui-selectmenu-item"),e)},focus:function(e,i){var s=i.item.data("ui-selectmenu-item");null!=t.focusIndex&&s.index!==t.focusIndex&&(t._trigger("focus",e,{item:s}),t.isOpen||t._select(s,e)),t.focusIndex=s.index,t.button.attr("aria-activedescendant",t.menuItems.eq(s.index).attr("id"))}}).menu("instance"),this.menu.addClass("ui-corner-bottom").removeClass("ui-corner-all"),this.menuInstance._off(this.menu,"mouseleave"),this.menuInstance._closeOnDocumentClick=function(){return!1},this.menuInstance._isDivider=function(){return!1}},refresh:function(){this._refreshMenu(),this._setText(this.buttonText,this._getSelectedItem().text()),this.options.width||this._resizeButton()},_refreshMenu:function(){this.menu.empty();var e,t=this.element.find("option");t.length&&(this._parseOptions(t),this._renderMenu(this.menu,this.items),this.menuInstance.refresh(),this.menuItems=this.menu.find("li").not(".ui-selectmenu-optgroup"),e=this._getSelectedItem(),this.menuInstance.focus(null,e),this._setAria(e.data("ui-selectmenu-item")),this._setOption("disabled",this.element.prop("disabled")))},open:function(e){this.options.disabled||(this.menuItems?(this.menu.find(".ui-state-focus").removeClass("ui-state-focus"),this.menuInstance.focus(null,this._getSelectedItem())):this._refreshMenu(),this.isOpen=!0,this._toggleAttr(),this._resizeMenu(),this._position(),this._on(this.document,this._documentClick),this._trigger("open",e))},_position:function(){this.menuWrap.position(e.extend({of:this.button},this.options.position))},close:function(e){this.isOpen&&(this.isOpen=!1,this._toggleAttr(),this._off(this.document),this._trigger("close",e))},widget:function(){return this.button},menuWidget:function(){return this.menu},_renderMenu:function(t,i){var s=this,n="";e.each(i,function(i,a){a.optgroup!==n&&(e("<li>",{"class":"ui-selectmenu-optgroup ui-menu-divider"+(a.element.parent("optgroup").prop("disabled")?" ui-state-disabled":""),text:a.optgroup}).appendTo(t),n=a.optgroup),s._renderItemData(t,a)})},_renderItemData:function(e,t){return this._renderItem(e,t).data("ui-selectmenu-item",t)},_renderItem:function(t,i){var s=e("<li>");return i.disabled&&s.addClass("ui-state-disabled"),this._setText(s,i.label),s.appendTo(t)},_setText:function(e,t){t?e.text(t):e.html("&#160;")},_move:function(e,t){var i,s,n=".ui-menu-item";this.isOpen?i=this.menuItems.eq(this.focusIndex):(i=this.menuItems.eq(this.element[0].selectedIndex),n+=":not(.ui-state-disabled)"),s="first"===e||"last"===e?i["first"===e?"prevAll":"nextAll"](n).eq(-1):i[e+"All"](n).eq(0),s.length&&this.menuInstance.focus(t,s)},_getSelectedItem:function(){return this.menuItems.eq(this.element[0].selectedIndex)},_toggle:function(e){this[this.isOpen?"close":"open"](e)},_documentClick:{mousedown:function(t){this.isOpen&&(e(t.target).closest(".ui-selectmenu-menu, #"+this.ids.button).length||this.close(t))}},_buttonEvents:{mousedown:function(e){e.preventDefault()},click:"_toggle",keydown:function(t){var i=!0;switch(t.keyCode){case e.ui.keyCode.TAB:case e.ui.keyCode.ESCAPE:this.close(t),i=!1;break;case e.ui.keyCode.ENTER:this.isOpen&&this._selectFocusedItem(t);break;case e.ui.keyCode.UP:t.altKey?this._toggle(t):this._move("prev",t);break;case e.ui.keyCode.DOWN:t.altKey?this._toggle(t):this._move("next",t);break;case e.ui.keyCode.SPACE:this.isOpen?this._selectFocusedItem(t):this._toggle(t);break;case e.ui.keyCode.LEFT:this._move("prev",t);break;case e.ui.keyCode.RIGHT:this._move("next",t);break;case e.ui.keyCode.HOME:case e.ui.keyCode.PAGE_UP:this._move("first",t);break;case e.ui.keyCode.END:case e.ui.keyCode.PAGE_DOWN:this._move("last",t);break;default:this.menu.trigger(t),i=!1}i&&t.preventDefault()}},_selectFocusedItem:function(e){var t=this.menuItems.eq(this.focusIndex);t.hasClass("ui-state-disabled")||this._select(t.data("ui-selectmenu-item"),e)},_select:function(e,t){var i=this.element[0].selectedIndex;this.element[0].selectedIndex=e.index,this._setText(this.buttonText,e.label),this._setAria(e),this._trigger("select",t,{item:e}),e.index!==i&&this._trigger("change",t,{item:e}),this.close(t)},_setAria:function(e){var t=this.menuItems.eq(e.index).attr("id");this.button.attr({"aria-labelledby":t,"aria-activedescendant":t}),this.menu.attr("aria-activedescendant",t)},_setOption:function(e,t){"icons"===e&&this.button.find("span.ui-icon").removeClass(this.options.icons.button).addClass(t.button),this._super(e,t),"appendTo"===e&&this.menuWrap.appendTo(this._appendTo()),"disabled"===e&&(this.menuInstance.option("disabled",t),this.button.toggleClass("ui-state-disabled",t).attr("aria-disabled",t),this.element.prop("disabled",t),t?(this.button.attr("tabindex",-1),this.close()):this.button.attr("tabindex",0)),"width"===e&&this._resizeButton()},_appendTo:function(){var t=this.options.appendTo;return t&&(t=t.jquery||t.nodeType?e(t):this.document.find(t).eq(0)),t&&t[0]||(t=this.element.closest(".ui-front")),t.length||(t=this.document[0].body),t},_toggleAttr:function(){this.button.toggleClass("ui-corner-top",this.isOpen).toggleClass("ui-corner-all",!this.isOpen).attr("aria-expanded",this.isOpen),this.menuWrap.toggleClass("ui-selectmenu-open",this.isOpen),this.menu.attr("aria-hidden",!this.isOpen)},_resizeButton:function(){var e=this.options.width;e||(e=this.element.show().outerWidth(),this.element.hide()),this.button.outerWidth(e)},_resizeMenu:function(){this.menu.outerWidth(Math.max(this.button.outerWidth(),this.menu.width("").outerWidth()+1))},_getCreateOptions:function(){return{disabled:this.element.prop("disabled")}},_parseOptions:function(t){var i=[];t.each(function(t,s){var n=e(s),a=n.parent("optgroup");i.push({element:n,index:t,value:n.attr("value"),label:n.text(),optgroup:a.attr("label")||"",disabled:a.prop("disabled")||n.prop("disabled")})}),this.items=i},_destroy:function(){this.menuWrap.remove(),this.button.remove(),this.element.show(),this.element.removeUniqueId(),this.label.attr("for",this.ids.element)}}),e.widget("ui.slider",e.ui.mouse,{version:"1.11.1",widgetEventPrefix:"slide",options:{animate:!1,distance:0,max:100,min:0,orientation:"horizontal",range:!1,step:1,value:0,values:null,change:null,slide:null,start:null,stop:null},numPages:5,_create:function(){this._keySliding=!1,this._mouseSliding=!1,this._animateOff=!0,this._handleIndex=null,this._detectOrientation(),this._mouseInit(),this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget"+" ui-widget-content"+" ui-corner-all"),this._refresh(),this._setOption("disabled",this.options.disabled),this._animateOff=!1},_refresh:function(){this._createRange(),this._createHandles(),this._setupEvents(),this._refreshValue()},_createHandles:function(){var t,i,s=this.options,n=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),a="<span class='ui-slider-handle ui-state-default ui-corner-all' tabindex='0'></span>",o=[];for(i=s.values&&s.values.length||1,n.length>i&&(n.slice(i).remove(),n=n.slice(0,i)),t=n.length;i>t;t++)o.push(a);this.handles=n.add(e(o.join("")).appendTo(this.element)),this.handle=this.handles.eq(0),this.handles.each(function(t){e(this).data("ui-slider-handle-index",t)})},_createRange:function(){var t=this.options,i="";t.range?(t.range===!0&&(t.values?t.values.length&&2!==t.values.length?t.values=[t.values[0],t.values[0]]:e.isArray(t.values)&&(t.values=t.values.slice(0)):t.values=[this._valueMin(),this._valueMin()]),this.range&&this.range.length?this.range.removeClass("ui-slider-range-min ui-slider-range-max").css({left:"",bottom:""}):(this.range=e("<div></div>").appendTo(this.element),i="ui-slider-range ui-widget-header ui-corner-all"),this.range.addClass(i+("min"===t.range||"max"===t.range?" ui-slider-range-"+t.range:""))):(this.range&&this.range.remove(),this.range=null)},_setupEvents:function(){this._off(this.handles),this._on(this.handles,this._handleEvents),this._hoverable(this.handles),this._focusable(this.handles)},_destroy:function(){this.handles.remove(),this.range&&this.range.remove(),this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-widget ui-widget-content ui-corner-all"),this._mouseDestroy()},_mouseCapture:function(t){var i,s,n,a,o,r,h,l,u=this,d=this.options;return d.disabled?!1:(this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()},this.elementOffset=this.element.offset(),i={x:t.pageX,y:t.pageY},s=this._normValueFromMouse(i),n=this._valueMax()-this._valueMin()+1,this.handles.each(function(t){var i=Math.abs(s-u.values(t));(n>i||n===i&&(t===u._lastChangedValue||u.values(t)===d.min))&&(n=i,a=e(this),o=t)}),r=this._start(t,o),r===!1?!1:(this._mouseSliding=!0,this._handleIndex=o,a.addClass("ui-state-active").focus(),h=a.offset(),l=!e(t.target).parents().addBack().is(".ui-slider-handle"),this._clickOffset=l?{left:0,top:0}:{left:t.pageX-h.left-a.width()/2,top:t.pageY-h.top-a.height()/2-(parseInt(a.css("borderTopWidth"),10)||0)-(parseInt(a.css("borderBottomWidth"),10)||0)+(parseInt(a.css("marginTop"),10)||0)},this.handles.hasClass("ui-state-hover")||this._slide(t,o,s),this._animateOff=!0,!0))},_mouseStart:function(){return!0},_mouseDrag:function(e){var t={x:e.pageX,y:e.pageY},i=this._normValueFromMouse(t);return this._slide(e,this._handleIndex,i),!1},_mouseStop:function(e){return this.handles.removeClass("ui-state-active"),this._mouseSliding=!1,this._stop(e,this._handleIndex),this._change(e,this._handleIndex),this._handleIndex=null,this._clickOffset=null,this._animateOff=!1,!1},_detectOrientation:function(){this.orientation="vertical"===this.options.orientation?"vertical":"horizontal"},_normValueFromMouse:function(e){var t,i,s,n,a;return"horizontal"===this.orientation?(t=this.elementSize.width,i=e.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)):(t=this.elementSize.height,i=e.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)),s=i/t,s>1&&(s=1),0>s&&(s=0),"vertical"===this.orientation&&(s=1-s),n=this._valueMax()-this._valueMin(),a=this._valueMin()+s*n,this._trimAlignValue(a)},_start:function(e,t){var i={handle:this.handles[t],value:this.value()};return this.options.values&&this.options.values.length&&(i.value=this.values(t),i.values=this.values()),this._trigger("start",e,i)},_slide:function(e,t,i){var s,n,a;this.options.values&&this.options.values.length?(s=this.values(t?0:1),2===this.options.values.length&&this.options.range===!0&&(0===t&&i>s||1===t&&s>i)&&(i=s),i!==this.values(t)&&(n=this.values(),n[t]=i,a=this._trigger("slide",e,{handle:this.handles[t],value:i,values:n}),s=this.values(t?0:1),a!==!1&&this.values(t,i))):i!==this.value()&&(a=this._trigger("slide",e,{handle:this.handles[t],value:i}),a!==!1&&this.value(i))},_stop:function(e,t){var i={handle:this.handles[t],value:this.value()};this.options.values&&this.options.values.length&&(i.value=this.values(t),i.values=this.values()),this._trigger("stop",e,i)},_change:function(e,t){if(!this._keySliding&&!this._mouseSliding){var i={handle:this.handles[t],value:this.value()};this.options.values&&this.options.values.length&&(i.value=this.values(t),i.values=this.values()),this._lastChangedValue=t,this._trigger("change",e,i)}},value:function(e){return arguments.length?(this.options.value=this._trimAlignValue(e),this._refreshValue(),this._change(null,0),void 0):this._value()},values:function(t,i){var s,n,a;if(arguments.length>1)return this.options.values[t]=this._trimAlignValue(i),this._refreshValue(),this._change(null,t),void 0;if(!arguments.length)return this._values();if(!e.isArray(arguments[0]))return this.options.values&&this.options.values.length?this._values(t):this.value();for(s=this.options.values,n=arguments[0],a=0;s.length>a;a+=1)s[a]=this._trimAlignValue(n[a]),this._change(null,a);this._refreshValue()},_setOption:function(t,i){var s,n=0;switch("range"===t&&this.options.range===!0&&("min"===i?(this.options.value=this._values(0),this.options.values=null):"max"===i&&(this.options.value=this._values(this.options.values.length-1),this.options.values=null)),e.isArray(this.options.values)&&(n=this.options.values.length),"disabled"===t&&this.element.toggleClass("ui-state-disabled",!!i),this._super(t,i),t){case"orientation":this._detectOrientation(),this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation),this._refreshValue(),this.handles.css("horizontal"===i?"bottom":"left","");break;case"value":this._animateOff=!0,this._refreshValue(),this._change(null,0),this._animateOff=!1;break;case"values":for(this._animateOff=!0,this._refreshValue(),s=0;n>s;s+=1)this._change(null,s);this._animateOff=!1;break;case"min":case"max":this._animateOff=!0,this._refreshValue(),this._animateOff=!1;break;case"range":this._animateOff=!0,this._refresh(),this._animateOff=!1}},_value:function(){var e=this.options.value;return e=this._trimAlignValue(e)},_values:function(e){var t,i,s;if(arguments.length)return t=this.options.values[e],t=this._trimAlignValue(t);if(this.options.values&&this.options.values.length){for(i=this.options.values.slice(),s=0;i.length>s;s+=1)i[s]=this._trimAlignValue(i[s]);return i}return[]},_trimAlignValue:function(e){if(this._valueMin()>=e)return this._valueMin();if(e>=this._valueMax())return this._valueMax();var t=this.options.step>0?this.options.step:1,i=(e-this._valueMin())%t,s=e-i;return 2*Math.abs(i)>=t&&(s+=i>0?t:-t),parseFloat(s.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var t,i,s,n,a,o=this.options.range,r=this.options,h=this,l=this._animateOff?!1:r.animate,u={};this.options.values&&this.options.values.length?this.handles.each(function(s){i=100*((h.values(s)-h._valueMin())/(h._valueMax()-h._valueMin())),u["horizontal"===h.orientation?"left":"bottom"]=i+"%",e(this).stop(1,1)[l?"animate":"css"](u,r.animate),h.options.range===!0&&("horizontal"===h.orientation?(0===s&&h.range.stop(1,1)[l?"animate":"css"]({left:i+"%"},r.animate),1===s&&h.range[l?"animate":"css"]({width:i-t+"%"},{queue:!1,duration:r.animate})):(0===s&&h.range.stop(1,1)[l?"animate":"css"]({bottom:i+"%"},r.animate),1===s&&h.range[l?"animate":"css"]({height:i-t+"%"},{queue:!1,duration:r.animate}))),t=i}):(s=this.value(),n=this._valueMin(),a=this._valueMax(),i=a!==n?100*((s-n)/(a-n)):0,u["horizontal"===this.orientation?"left":"bottom"]=i+"%",this.handle.stop(1,1)[l?"animate":"css"](u,r.animate),"min"===o&&"horizontal"===this.orientation&&this.range.stop(1,1)[l?"animate":"css"]({width:i+"%"},r.animate),"max"===o&&"horizontal"===this.orientation&&this.range[l?"animate":"css"]({width:100-i+"%"},{queue:!1,duration:r.animate}),"min"===o&&"vertical"===this.orientation&&this.range.stop(1,1)[l?"animate":"css"]({height:i+"%"},r.animate),"max"===o&&"vertical"===this.orientation&&this.range[l?"animate":"css"]({height:100-i+"%"},{queue:!1,duration:r.animate}))},_handleEvents:{keydown:function(t){var i,s,n,a,o=e(t.target).data("ui-slider-handle-index");switch(t.keyCode){case e.ui.keyCode.HOME:case e.ui.keyCode.END:case e.ui.keyCode.PAGE_UP:case e.ui.keyCode.PAGE_DOWN:case e.ui.keyCode.UP:case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:case e.ui.keyCode.LEFT:if(t.preventDefault(),!this._keySliding&&(this._keySliding=!0,e(t.target).addClass("ui-state-active"),i=this._start(t,o),i===!1))return}switch(a=this.options.step,s=n=this.options.values&&this.options.values.length?this.values(o):this.value(),t.keyCode){case e.ui.keyCode.HOME:n=this._valueMin();break;case e.ui.keyCode.END:n=this._valueMax();break;case e.ui.keyCode.PAGE_UP:n=this._trimAlignValue(s+(this._valueMax()-this._valueMin())/this.numPages);break;case e.ui.keyCode.PAGE_DOWN:n=this._trimAlignValue(s-(this._valueMax()-this._valueMin())/this.numPages);break;case e.ui.keyCode.UP:case e.ui.keyCode.RIGHT:if(s===this._valueMax())return;n=this._trimAlignValue(s+a);break;case e.ui.keyCode.DOWN:case e.ui.keyCode.LEFT:if(s===this._valueMin())return;n=this._trimAlignValue(s-a)}this._slide(t,o,n)},keyup:function(t){var i=e(t.target).data("ui-slider-handle-index");this._keySliding&&(this._keySliding=!1,this._stop(t,i),this._change(t,i),e(t.target).removeClass("ui-state-active"))}}}),e.widget("ui.sortable",e.ui.mouse,{version:"1.11.1",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_isOverAxis:function(e,t,i){return e>=t&&t+i>e},_isFloating:function(e){return/left|right/.test(e.css("float"))||/inline|table-cell/.test(e.css("display"))},_create:function(){var e=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?"x"===e.axis||this._isFloating(this.items[0].item):!1,this.offset=this.element.offset(),this._mouseInit(),this._setHandleClassName(),this.ready=!0},_setOption:function(e,t){this._super(e,t),"handle"===e&&this._setHandleClassName()},_setHandleClassName:function(){this.element.find(".ui-sortable-handle").removeClass("ui-sortable-handle"),e.each(this.items,function(){(this.instance.options.handle?this.item.find(this.instance.options.handle):this.item).addClass("ui-sortable-handle")})},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").find(".ui-sortable-handle").removeClass("ui-sortable-handle"),this._mouseDestroy();for(var e=this.items.length-1;e>=0;e--)this.items[e].item.removeData(this.widgetName+"-item");return this},_mouseCapture:function(t,i){var s=null,n=!1,a=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(t),e(t.target).parents().each(function(){return e.data(this,a.widgetName+"-item")===a?(s=e(this),!1):void 0}),e.data(t.target,a.widgetName+"-item")===a&&(s=e(t.target)),s?!this.options.handle||i||(e(this.options.handle,s).find("*").addBack().each(function(){this===t.target&&(n=!0)}),n)?(this.currentItem=s,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(t,i,s){var n,a,o=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(t),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,o.cursorAt&&this._adjustOffsetFromHelper(o.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),o.containment&&this._setContainment(),o.cursor&&"auto"!==o.cursor&&(a=this.document.find("body"),this.storedCursor=a.css("cursor"),a.css("cursor",o.cursor),this.storedStylesheet=e("<style>*{ cursor: "+o.cursor+" !important; }</style>").appendTo(a)),o.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",o.opacity)),o.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",o.zIndex)),this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",t,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!s)for(n=this.containers.length-1;n>=0;n--)this.containers[n]._trigger("activate",t,this._uiHash(this));
12
+ return e.ui.ddmanager&&(e.ui.ddmanager.current=this),e.ui.ddmanager&&!o.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(t),!0},_mouseDrag:function(t){var i,s,n,a,o=this.options,r=!1;for(this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-t.pageY<o.scrollSensitivity?this.scrollParent[0].scrollTop=r=this.scrollParent[0].scrollTop+o.scrollSpeed:t.pageY-this.overflowOffset.top<o.scrollSensitivity&&(this.scrollParent[0].scrollTop=r=this.scrollParent[0].scrollTop-o.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-t.pageX<o.scrollSensitivity?this.scrollParent[0].scrollLeft=r=this.scrollParent[0].scrollLeft+o.scrollSpeed:t.pageX-this.overflowOffset.left<o.scrollSensitivity&&(this.scrollParent[0].scrollLeft=r=this.scrollParent[0].scrollLeft-o.scrollSpeed)):(t.pageY-e(document).scrollTop()<o.scrollSensitivity?r=e(document).scrollTop(e(document).scrollTop()-o.scrollSpeed):e(window).height()-(t.pageY-e(document).scrollTop())<o.scrollSensitivity&&(r=e(document).scrollTop(e(document).scrollTop()+o.scrollSpeed)),t.pageX-e(document).scrollLeft()<o.scrollSensitivity?r=e(document).scrollLeft(e(document).scrollLeft()-o.scrollSpeed):e(window).width()-(t.pageX-e(document).scrollLeft())<o.scrollSensitivity&&(r=e(document).scrollLeft(e(document).scrollLeft()+o.scrollSpeed))),r!==!1&&e.ui.ddmanager&&!o.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t)),this.positionAbs=this._convertPositionTo("absolute"),this.options.axis&&"y"===this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"===this.options.axis||(this.helper[0].style.top=this.position.top+"px"),i=this.items.length-1;i>=0;i--)if(s=this.items[i],n=s.item[0],a=this._intersectsWithPointer(s),a&&s.instance===this.currentContainer&&n!==this.currentItem[0]&&this.placeholder[1===a?"next":"prev"]()[0]!==n&&!e.contains(this.placeholder[0],n)&&("semi-dynamic"===this.options.type?!e.contains(this.element[0],n):!0)){if(this.direction=1===a?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(s))break;this._rearrange(t,s),this._trigger("change",t,this._uiHash());break}return this._contactContainers(t),e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),this._trigger("sort",t,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(t,i){if(t){if(e.ui.ddmanager&&!this.options.dropBehaviour&&e.ui.ddmanager.drop(this,t),this.options.revert){var s=this,n=this.placeholder.offset(),a=this.options.axis,o={};a&&"x"!==a||(o.left=n.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollLeft)),a&&"y"!==a||(o.top=n.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,e(this.helper).animate(o,parseInt(this.options.revert,10)||500,function(){s._clear(t)})}else this._clear(t,i);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var t=this.containers.length-1;t>=0;t--)this.containers[t]._trigger("deactivate",null,this._uiHash(this)),this.containers[t].containerCache.over&&(this.containers[t]._trigger("out",null,this._uiHash(this)),this.containers[t].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),e.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?e(this.domPosition.prev).after(this.currentItem):e(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(t){var i=this._getItemsAsjQuery(t&&t.connected),s=[];return t=t||{},e(i).each(function(){var i=(e(t.item||this).attr(t.attribute||"id")||"").match(t.expression||/(.+)[\-=_](.+)/);i&&s.push((t.key||i[1]+"[]")+"="+(t.key&&t.expression?i[1]:i[2]))}),!s.length&&t.key&&s.push(t.key+"="),s.join("&")},toArray:function(t){var i=this._getItemsAsjQuery(t&&t.connected),s=[];return t=t||{},i.each(function(){s.push(e(t.item||this).attr(t.attribute||"id")||"")}),s},_intersectsWith:function(e){var t=this.positionAbs.left,i=t+this.helperProportions.width,s=this.positionAbs.top,n=s+this.helperProportions.height,a=e.left,o=a+e.width,r=e.top,h=r+e.height,l=this.offset.click.top,u=this.offset.click.left,d="x"===this.options.axis||s+l>r&&h>s+l,c="y"===this.options.axis||t+u>a&&o>t+u,p=d&&c;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>e[this.floating?"width":"height"]?p:t+this.helperProportions.width/2>a&&o>i-this.helperProportions.width/2&&s+this.helperProportions.height/2>r&&h>n-this.helperProportions.height/2},_intersectsWithPointer:function(e){var t="x"===this.options.axis||this._isOverAxis(this.positionAbs.top+this.offset.click.top,e.top,e.height),i="y"===this.options.axis||this._isOverAxis(this.positionAbs.left+this.offset.click.left,e.left,e.width),s=t&&i,n=this._getDragVerticalDirection(),a=this._getDragHorizontalDirection();return s?this.floating?a&&"right"===a||"down"===n?2:1:n&&("down"===n?2:1):!1},_intersectsWithSides:function(e){var t=this._isOverAxis(this.positionAbs.top+this.offset.click.top,e.top+e.height/2,e.height),i=this._isOverAxis(this.positionAbs.left+this.offset.click.left,e.left+e.width/2,e.width),s=this._getDragVerticalDirection(),n=this._getDragHorizontalDirection();return this.floating&&n?"right"===n&&i||"left"===n&&!i:s&&("down"===s&&t||"up"===s&&!t)},_getDragVerticalDirection:function(){var e=this.positionAbs.top-this.lastPositionAbs.top;return 0!==e&&(e>0?"down":"up")},_getDragHorizontalDirection:function(){var e=this.positionAbs.left-this.lastPositionAbs.left;return 0!==e&&(e>0?"right":"left")},refresh:function(e){return this._refreshItems(e),this._setHandleClassName(),this.refreshPositions(),this},_connectWith:function(){var e=this.options;return e.connectWith.constructor===String?[e.connectWith]:e.connectWith},_getItemsAsjQuery:function(t){function i(){r.push(this)}var s,n,a,o,r=[],h=[],l=this._connectWith();if(l&&t)for(s=l.length-1;s>=0;s--)for(a=e(l[s]),n=a.length-1;n>=0;n--)o=e.data(a[n],this.widgetFullName),o&&o!==this&&!o.options.disabled&&h.push([e.isFunction(o.options.items)?o.options.items.call(o.element):e(o.options.items,o.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),o]);for(h.push([e.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):e(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),s=h.length-1;s>=0;s--)h[s][0].each(i);return e(r)},_removeCurrentsFromItems:function(){var t=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=e.grep(this.items,function(e){for(var i=0;t.length>i;i++)if(t[i]===e.item[0])return!1;return!0})},_refreshItems:function(t){this.items=[],this.containers=[this];var i,s,n,a,o,r,h,l,u=this.items,d=[[e.isFunction(this.options.items)?this.options.items.call(this.element[0],t,{item:this.currentItem}):e(this.options.items,this.element),this]],c=this._connectWith();if(c&&this.ready)for(i=c.length-1;i>=0;i--)for(n=e(c[i]),s=n.length-1;s>=0;s--)a=e.data(n[s],this.widgetFullName),a&&a!==this&&!a.options.disabled&&(d.push([e.isFunction(a.options.items)?a.options.items.call(a.element[0],t,{item:this.currentItem}):e(a.options.items,a.element),a]),this.containers.push(a));for(i=d.length-1;i>=0;i--)for(o=d[i][1],r=d[i][0],s=0,l=r.length;l>s;s++)h=e(r[s]),h.data(this.widgetName+"-item",o),u.push({item:h,instance:o,width:0,height:0,left:0,top:0})},refreshPositions:function(t){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var i,s,n,a;for(i=this.items.length-1;i>=0;i--)s=this.items[i],s.instance!==this.currentContainer&&this.currentContainer&&s.item[0]!==this.currentItem[0]||(n=this.options.toleranceElement?e(this.options.toleranceElement,s.item):s.item,t||(s.width=n.outerWidth(),s.height=n.outerHeight()),a=n.offset(),s.left=a.left,s.top=a.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(i=this.containers.length-1;i>=0;i--)a=this.containers[i].element.offset(),this.containers[i].containerCache.left=a.left,this.containers[i].containerCache.top=a.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight();return this},_createPlaceholder:function(t){t=t||this;var i,s=t.options;s.placeholder&&s.placeholder.constructor!==String||(i=s.placeholder,s.placeholder={element:function(){var s=t.currentItem[0].nodeName.toLowerCase(),n=e("<"+s+">",t.document[0]).addClass(i||t.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tr"===s?t.currentItem.children().each(function(){e("<td>&#160;</td>",t.document[0]).attr("colspan",e(this).attr("colspan")||1).appendTo(n)}):"img"===s&&n.attr("src",t.currentItem.attr("src")),i||n.css("visibility","hidden"),n},update:function(e,n){(!i||s.forcePlaceholderSize)&&(n.height()||n.height(t.currentItem.innerHeight()-parseInt(t.currentItem.css("paddingTop")||0,10)-parseInt(t.currentItem.css("paddingBottom")||0,10)),n.width()||n.width(t.currentItem.innerWidth()-parseInt(t.currentItem.css("paddingLeft")||0,10)-parseInt(t.currentItem.css("paddingRight")||0,10)))}}),t.placeholder=e(s.placeholder.element.call(t.element,t.currentItem)),t.currentItem.after(t.placeholder),s.placeholder.update(t,t.placeholder)},_contactContainers:function(t){var i,s,n,a,o,r,h,l,u,d,c=null,p=null;for(i=this.containers.length-1;i>=0;i--)if(!e.contains(this.currentItem[0],this.containers[i].element[0]))if(this._intersectsWith(this.containers[i].containerCache)){if(c&&e.contains(this.containers[i].element[0],c.element[0]))continue;c=this.containers[i],p=i}else this.containers[i].containerCache.over&&(this.containers[i]._trigger("out",t,this._uiHash(this)),this.containers[i].containerCache.over=0);if(c)if(1===this.containers.length)this.containers[p].containerCache.over||(this.containers[p]._trigger("over",t,this._uiHash(this)),this.containers[p].containerCache.over=1);else{for(n=1e4,a=null,u=c.floating||this._isFloating(this.currentItem),o=u?"left":"top",r=u?"width":"height",d=u?"clientX":"clientY",s=this.items.length-1;s>=0;s--)e.contains(this.containers[p].element[0],this.items[s].item[0])&&this.items[s].item[0]!==this.currentItem[0]&&(h=this.items[s].item.offset()[o],l=!1,t[d]-h>this.items[s][r]/2&&(l=!0),n>Math.abs(t[d]-h)&&(n=Math.abs(t[d]-h),a=this.items[s],this.direction=l?"up":"down"));if(!a&&!this.options.dropOnEmpty)return;if(this.currentContainer===this.containers[p])return;a?this._rearrange(t,a,null,!0):this._rearrange(t,null,this.containers[p].element,!0),this._trigger("change",t,this._uiHash()),this.containers[p]._trigger("change",t,this._uiHash(this)),this.currentContainer=this.containers[p],this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[p]._trigger("over",t,this._uiHash(this)),this.containers[p].containerCache.over=1}},_createHelper:function(t){var i=this.options,s=e.isFunction(i.helper)?e(i.helper.apply(this.element[0],[t,this.currentItem])):"clone"===i.helper?this.currentItem.clone():this.currentItem;return s.parents("body").length||e("parent"!==i.appendTo?i.appendTo:this.currentItem[0].parentNode)[0].appendChild(s[0]),s[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(!s[0].style.width||i.forceHelperSize)&&s.width(this.currentItem.width()),(!s[0].style.height||i.forceHelperSize)&&s.height(this.currentItem.height()),s},_adjustOffsetFromHelper:function(t){"string"==typeof t&&(t=t.split(" ")),e.isArray(t)&&(t={left:+t[0],top:+t[1]||0}),"left"in t&&(this.offset.click.left=t.left+this.margins.left),"right"in t&&(this.offset.click.left=this.helperProportions.width-t.right+this.margins.left),"top"in t&&(this.offset.click.top=t.top+this.margins.top),"bottom"in t&&(this.offset.click.top=this.helperProportions.height-t.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var t=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])&&(t.left+=this.scrollParent.scrollLeft(),t.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&e.ui.ie)&&(t={top:0,left:0}),{top:t.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:t.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var e=this.currentItem.position();return{top:e.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:e.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var t,i,s,n=this.options;"parent"===n.containment&&(n.containment=this.helper[0].parentNode),("document"===n.containment||"window"===n.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,e("document"===n.containment?document:window).width()-this.helperProportions.width-this.margins.left,(e("document"===n.containment?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(n.containment)||(t=e(n.containment)[0],i=e(n.containment).offset(),s="hidden"!==e(t).css("overflow"),this.containment=[i.left+(parseInt(e(t).css("borderLeftWidth"),10)||0)+(parseInt(e(t).css("paddingLeft"),10)||0)-this.margins.left,i.top+(parseInt(e(t).css("borderTopWidth"),10)||0)+(parseInt(e(t).css("paddingTop"),10)||0)-this.margins.top,i.left+(s?Math.max(t.scrollWidth,t.offsetWidth):t.offsetWidth)-(parseInt(e(t).css("borderLeftWidth"),10)||0)-(parseInt(e(t).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,i.top+(s?Math.max(t.scrollHeight,t.offsetHeight):t.offsetHeight)-(parseInt(e(t).css("borderTopWidth"),10)||0)-(parseInt(e(t).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(t,i){i||(i=this.position);var s="absolute"===t?1:-1,n="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,a=/(html|body)/i.test(n[0].tagName);return{top:i.top+this.offset.relative.top*s+this.offset.parent.top*s-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():a?0:n.scrollTop())*s,left:i.left+this.offset.relative.left*s+this.offset.parent.left*s-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():a?0:n.scrollLeft())*s}},_generatePosition:function(t){var i,s,n=this.options,a=t.pageX,o=t.pageY,r="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&e.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,h=/(html|body)/i.test(r[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==document&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(t.pageX-this.offset.click.left<this.containment[0]&&(a=this.containment[0]+this.offset.click.left),t.pageY-this.offset.click.top<this.containment[1]&&(o=this.containment[1]+this.offset.click.top),t.pageX-this.offset.click.left>this.containment[2]&&(a=this.containment[2]+this.offset.click.left),t.pageY-this.offset.click.top>this.containment[3]&&(o=this.containment[3]+this.offset.click.top)),n.grid&&(i=this.originalPageY+Math.round((o-this.originalPageY)/n.grid[1])*n.grid[1],o=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-n.grid[1]:i+n.grid[1]:i,s=this.originalPageX+Math.round((a-this.originalPageX)/n.grid[0])*n.grid[0],a=this.containment?s-this.offset.click.left>=this.containment[0]&&s-this.offset.click.left<=this.containment[2]?s:s-this.offset.click.left>=this.containment[0]?s-n.grid[0]:s+n.grid[0]:s)),{top:o-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():h?0:r.scrollTop()),left:a-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():h?0:r.scrollLeft())}},_rearrange:function(e,t,i,s){i?i[0].appendChild(this.placeholder[0]):t.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?t.item[0]:t.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var n=this.counter;this._delay(function(){n===this.counter&&this.refreshPositions(!s)})},_clear:function(e,t){function i(e,t,i){return function(s){i._trigger(e,s,t._uiHash(t))}}this.reverting=!1;var s,n=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(s in this._storedCSS)("auto"===this._storedCSS[s]||"static"===this._storedCSS[s])&&(this._storedCSS[s]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!t&&n.push(function(e){this._trigger("receive",e,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||t||n.push(function(e){this._trigger("update",e,this._uiHash())}),this!==this.currentContainer&&(t||(n.push(function(e){this._trigger("remove",e,this._uiHash())}),n.push(function(e){return function(t){e._trigger("receive",t,this._uiHash(this))}}.call(this,this.currentContainer)),n.push(function(e){return function(t){e._trigger("update",t,this._uiHash(this))}}.call(this,this.currentContainer)))),s=this.containers.length-1;s>=0;s--)t||n.push(i("deactivate",this,this.containers[s])),this.containers[s].containerCache.over&&(n.push(i("out",this,this.containers[s])),this.containers[s].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!t){for(this._trigger("beforeStop",e,this._uiHash()),s=0;n.length>s;s++)n[s].call(this,e);this._trigger("stop",e,this._uiHash())}return this.fromOutside=!1,!1}if(t||this._trigger("beforeStop",e,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null,!t){for(s=0;n.length>s;s++)n[s].call(this,e);this._trigger("stop",e,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){e.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(t){var i=t||this;return{helper:i.helper,placeholder:i.placeholder||e([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:t?t.element:null}}}),e.widget("ui.spinner",{version:"1.11.1",defaultElement:"<input>",widgetEventPrefix:"spin",options:{culture:null,icons:{down:"ui-icon-triangle-1-s",up:"ui-icon-triangle-1-n"},incremental:!0,max:null,min:null,numberFormat:null,page:10,step:1,change:null,spin:null,start:null,stop:null},_create:function(){this._setOption("max",this.options.max),this._setOption("min",this.options.min),this._setOption("step",this.options.step),""!==this.value()&&this._value(this.element.val(),!0),this._draw(),this._on(this._events),this._refresh(),this._on(this.window,{beforeunload:function(){this.element.removeAttr("autocomplete")}})},_getCreateOptions:function(){var t={},i=this.element;return e.each(["min","max","step"],function(e,s){var n=i.attr(s);void 0!==n&&n.length&&(t[s]=n)}),t},_events:{keydown:function(e){this._start(e)&&this._keydown(e)&&e.preventDefault()},keyup:"_stop",focus:function(){this.previous=this.element.val()},blur:function(e){return this.cancelBlur?(delete this.cancelBlur,void 0):(this._stop(),this._refresh(),this.previous!==this.element.val()&&this._trigger("change",e),void 0)},mousewheel:function(e,t){if(t){if(!this.spinning&&!this._start(e))return!1;this._spin((t>0?1:-1)*this.options.step,e),clearTimeout(this.mousewheelTimer),this.mousewheelTimer=this._delay(function(){this.spinning&&this._stop(e)},100),e.preventDefault()}},"mousedown .ui-spinner-button":function(t){function i(){var e=this.element[0]===this.document[0].activeElement;e||(this.element.focus(),this.previous=s,this._delay(function(){this.previous=s}))}var s;s=this.element[0]===this.document[0].activeElement?this.previous:this.element.val(),t.preventDefault(),i.call(this),this.cancelBlur=!0,this._delay(function(){delete this.cancelBlur,i.call(this)}),this._start(t)!==!1&&this._repeat(null,e(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t)},"mouseup .ui-spinner-button":"_stop","mouseenter .ui-spinner-button":function(t){return e(t.currentTarget).hasClass("ui-state-active")?this._start(t)===!1?!1:(this._repeat(null,e(t.currentTarget).hasClass("ui-spinner-up")?1:-1,t),void 0):void 0},"mouseleave .ui-spinner-button":"_stop"},_draw:function(){var e=this.uiSpinner=this.element.addClass("ui-spinner-input").attr("autocomplete","off").wrap(this._uiSpinnerHtml()).parent().append(this._buttonHtml());this.element.attr("role","spinbutton"),this.buttons=e.find(".ui-spinner-button").attr("tabIndex",-1).button().removeClass("ui-corner-all"),this.buttons.height()>Math.ceil(.5*e.height())&&e.height()>0&&e.height(e.height()),this.options.disabled&&this.disable()},_keydown:function(t){var i=this.options,s=e.ui.keyCode;switch(t.keyCode){case s.UP:return this._repeat(null,1,t),!0;case s.DOWN:return this._repeat(null,-1,t),!0;case s.PAGE_UP:return this._repeat(null,i.page,t),!0;case s.PAGE_DOWN:return this._repeat(null,-i.page,t),!0}return!1},_uiSpinnerHtml:function(){return"<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>"},_buttonHtml:function(){return"<a class='ui-spinner-button ui-spinner-up ui-corner-tr'><span class='ui-icon "+this.options.icons.up+"'>&#9650;</span>"+"</a>"+"<a class='ui-spinner-button ui-spinner-down ui-corner-br'>"+"<span class='ui-icon "+this.options.icons.down+"'>&#9660;</span>"+"</a>"},_start:function(e){return this.spinning||this._trigger("start",e)!==!1?(this.counter||(this.counter=1),this.spinning=!0,!0):!1},_repeat:function(e,t,i){e=e||500,clearTimeout(this.timer),this.timer=this._delay(function(){this._repeat(40,t,i)},e),this._spin(t*this.options.step,i)},_spin:function(e,t){var i=this.value()||0;this.counter||(this.counter=1),i=this._adjustValue(i+e*this._increment(this.counter)),this.spinning&&this._trigger("spin",t,{value:i})===!1||(this._value(i),this.counter++)},_increment:function(t){var i=this.options.incremental;return i?e.isFunction(i)?i(t):Math.floor(t*t*t/5e4-t*t/500+17*t/200+1):1},_precision:function(){var e=this._precisionOf(this.options.step);return null!==this.options.min&&(e=Math.max(e,this._precisionOf(this.options.min))),e},_precisionOf:function(e){var t=""+e,i=t.indexOf(".");return-1===i?0:t.length-i-1},_adjustValue:function(e){var t,i,s=this.options;return t=null!==s.min?s.min:0,i=e-t,i=Math.round(i/s.step)*s.step,e=t+i,e=parseFloat(e.toFixed(this._precision())),null!==s.max&&e>s.max?s.max:null!==s.min&&s.min>e?s.min:e},_stop:function(e){this.spinning&&(clearTimeout(this.timer),clearTimeout(this.mousewheelTimer),this.counter=0,this.spinning=!1,this._trigger("stop",e))},_setOption:function(e,t){if("culture"===e||"numberFormat"===e){var i=this._parse(this.element.val());return this.options[e]=t,this.element.val(this._format(i)),void 0}("max"===e||"min"===e||"step"===e)&&"string"==typeof t&&(t=this._parse(t)),"icons"===e&&(this.buttons.first().find(".ui-icon").removeClass(this.options.icons.up).addClass(t.up),this.buttons.last().find(".ui-icon").removeClass(this.options.icons.down).addClass(t.down)),this._super(e,t),"disabled"===e&&(this.widget().toggleClass("ui-state-disabled",!!t),this.element.prop("disabled",!!t),this.buttons.button(t?"disable":"enable"))},_setOptions:h(function(e){this._super(e)}),_parse:function(e){return"string"==typeof e&&""!==e&&(e=window.Globalize&&this.options.numberFormat?Globalize.parseFloat(e,10,this.options.culture):+e),""===e||isNaN(e)?null:e},_format:function(e){return""===e?"":window.Globalize&&this.options.numberFormat?Globalize.format(e,this.options.numberFormat,this.options.culture):e},_refresh:function(){this.element.attr({"aria-valuemin":this.options.min,"aria-valuemax":this.options.max,"aria-valuenow":this._parse(this.element.val())})},isValid:function(){var e=this.value();return null===e?!1:e===this._adjustValue(e)},_value:function(e,t){var i;""!==e&&(i=this._parse(e),null!==i&&(t||(i=this._adjustValue(i)),e=this._format(i))),this.element.val(e),this._refresh()},_destroy:function(){this.element.removeClass("ui-spinner-input").prop("disabled",!1).removeAttr("autocomplete").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"),this.uiSpinner.replaceWith(this.element)},stepUp:h(function(e){this._stepUp(e)}),_stepUp:function(e){this._start()&&(this._spin((e||1)*this.options.step),this._stop())},stepDown:h(function(e){this._stepDown(e)}),_stepDown:function(e){this._start()&&(this._spin((e||1)*-this.options.step),this._stop())},pageUp:h(function(e){this._stepUp((e||1)*this.options.page)}),pageDown:h(function(e){this._stepDown((e||1)*this.options.page)}),value:function(e){return arguments.length?(h(this._value).call(this,e),void 0):this._parse(this.element.val())},widget:function(){return this.uiSpinner}}),e.widget("ui.tabs",{version:"1.11.1",delay:300,options:{active:null,collapsible:!1,event:"click",heightStyle:"content",hide:null,show:null,activate:null,beforeActivate:null,beforeLoad:null,load:null},_isLocal:function(){var e=/#.*$/;return function(t){var i,s;t=t.cloneNode(!1),i=t.href.replace(e,""),s=location.href.replace(e,"");try{i=decodeURIComponent(i)}catch(n){}try{s=decodeURIComponent(s)}catch(n){}return t.hash.length>1&&i===s}}(),_create:function(){var t=this,i=this.options;this.running=!1,this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all").toggleClass("ui-tabs-collapsible",i.collapsible),this._processTabs(),i.active=this._initialActive(),e.isArray(i.disabled)&&(i.disabled=e.unique(i.disabled.concat(e.map(this.tabs.filter(".ui-state-disabled"),function(e){return t.tabs.index(e)}))).sort()),this.active=this.options.active!==!1&&this.anchors.length?this._findActive(i.active):e(),this._refresh(),this.active.length&&this.load(i.active)},_initialActive:function(){var t=this.options.active,i=this.options.collapsible,s=location.hash.substring(1);return null===t&&(s&&this.tabs.each(function(i,n){return e(n).attr("aria-controls")===s?(t=i,!1):void 0}),null===t&&(t=this.tabs.index(this.tabs.filter(".ui-tabs-active"))),(null===t||-1===t)&&(t=this.tabs.length?0:!1)),t!==!1&&(t=this.tabs.index(this.tabs.eq(t)),-1===t&&(t=i?!1:0)),!i&&t===!1&&this.anchors.length&&(t=0),t},_getCreateEventData:function(){return{tab:this.active,panel:this.active.length?this._getPanelForTab(this.active):e()}},_tabKeydown:function(t){var i=e(this.document[0].activeElement).closest("li"),s=this.tabs.index(i),n=!0;if(!this._handlePageNav(t)){switch(t.keyCode){case e.ui.keyCode.RIGHT:case e.ui.keyCode.DOWN:s++;break;case e.ui.keyCode.UP:case e.ui.keyCode.LEFT:n=!1,s--;break;case e.ui.keyCode.END:s=this.anchors.length-1;break;case e.ui.keyCode.HOME:s=0;break;case e.ui.keyCode.SPACE:return t.preventDefault(),clearTimeout(this.activating),this._activate(s),void 0;case e.ui.keyCode.ENTER:return t.preventDefault(),clearTimeout(this.activating),this._activate(s===this.options.active?!1:s),void 0;default:return}t.preventDefault(),clearTimeout(this.activating),s=this._focusNextTab(s,n),t.ctrlKey||(i.attr("aria-selected","false"),this.tabs.eq(s).attr("aria-selected","true"),this.activating=this._delay(function(){this.option("active",s)},this.delay))}},_panelKeydown:function(t){this._handlePageNav(t)||t.ctrlKey&&t.keyCode===e.ui.keyCode.UP&&(t.preventDefault(),this.active.focus())},_handlePageNav:function(t){return t.altKey&&t.keyCode===e.ui.keyCode.PAGE_UP?(this._activate(this._focusNextTab(this.options.active-1,!1)),!0):t.altKey&&t.keyCode===e.ui.keyCode.PAGE_DOWN?(this._activate(this._focusNextTab(this.options.active+1,!0)),!0):void 0},_findNextTab:function(t,i){function s(){return t>n&&(t=0),0>t&&(t=n),t}for(var n=this.tabs.length-1;-1!==e.inArray(s(),this.options.disabled);)t=i?t+1:t-1;return t},_focusNextTab:function(e,t){return e=this._findNextTab(e,t),this.tabs.eq(e).focus(),e},_setOption:function(e,t){return"active"===e?(this._activate(t),void 0):"disabled"===e?(this._setupDisabled(t),void 0):(this._super(e,t),"collapsible"===e&&(this.element.toggleClass("ui-tabs-collapsible",t),t||this.options.active!==!1||this._activate(0)),"event"===e&&this._setupEvents(t),"heightStyle"===e&&this._setupHeightStyle(t),void 0)},_sanitizeSelector:function(e){return e?e.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g,"\\$&"):""},refresh:function(){var t=this.options,i=this.tablist.children(":has(a[href])");t.disabled=e.map(i.filter(".ui-state-disabled"),function(e){return i.index(e)}),this._processTabs(),t.active!==!1&&this.anchors.length?this.active.length&&!e.contains(this.tablist[0],this.active[0])?this.tabs.length===t.disabled.length?(t.active=!1,this.active=e()):this._activate(this._findNextTab(Math.max(0,t.active-1),!1)):t.active=this.tabs.index(this.active):(t.active=!1,this.active=e()),this._refresh()},_refresh:function(){this._setupDisabled(this.options.disabled),this._setupEvents(this.options.event),this._setupHeightStyle(this.options.heightStyle),this.tabs.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}),this.panels.not(this._getPanelForTab(this.active)).hide().attr({"aria-hidden":"true"}),this.active.length?(this.active.addClass("ui-tabs-active ui-state-active").attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}),this._getPanelForTab(this.active).show().attr({"aria-hidden":"false"})):this.tabs.eq(0).attr("tabIndex",0)},_processTabs:function(){var t=this;this.tablist=this._getList().addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").attr("role","tablist").delegate("> li","mousedown"+this.eventNamespace,function(t){e(this).is(".ui-state-disabled")&&t.preventDefault()}).delegate(".ui-tabs-anchor","focus"+this.eventNamespace,function(){e(this).closest("li").is(".ui-state-disabled")&&this.blur()}),this.tabs=this.tablist.find("> li:has(a[href])").addClass("ui-state-default ui-corner-top").attr({role:"tab",tabIndex:-1}),this.anchors=this.tabs.map(function(){return e("a",this)[0]
13
+ }).addClass("ui-tabs-anchor").attr({role:"presentation",tabIndex:-1}),this.panels=e(),this.anchors.each(function(i,s){var n,a,o,r=e(s).uniqueId().attr("id"),h=e(s).closest("li"),l=h.attr("aria-controls");t._isLocal(s)?(n=s.hash,o=n.substring(1),a=t.element.find(t._sanitizeSelector(n))):(o=h.attr("aria-controls")||e({}).uniqueId()[0].id,n="#"+o,a=t.element.find(n),a.length||(a=t._createPanel(o),a.insertAfter(t.panels[i-1]||t.tablist)),a.attr("aria-live","polite")),a.length&&(t.panels=t.panels.add(a)),l&&h.data("ui-tabs-aria-controls",l),h.attr({"aria-controls":o,"aria-labelledby":r}),a.attr("aria-labelledby",r)}),this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").attr("role","tabpanel")},_getList:function(){return this.tablist||this.element.find("ol,ul").eq(0)},_createPanel:function(t){return e("<div>").attr("id",t).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").data("ui-tabs-destroy",!0)},_setupDisabled:function(t){e.isArray(t)&&(t.length?t.length===this.anchors.length&&(t=!0):t=!1);for(var i,s=0;i=this.tabs[s];s++)t===!0||-1!==e.inArray(s,t)?e(i).addClass("ui-state-disabled").attr("aria-disabled","true"):e(i).removeClass("ui-state-disabled").removeAttr("aria-disabled");this.options.disabled=t},_setupEvents:function(t){var i={};t&&e.each(t.split(" "),function(e,t){i[t]="_eventHandler"}),this._off(this.anchors.add(this.tabs).add(this.panels)),this._on(!0,this.anchors,{click:function(e){e.preventDefault()}}),this._on(this.anchors,i),this._on(this.tabs,{keydown:"_tabKeydown"}),this._on(this.panels,{keydown:"_panelKeydown"}),this._focusable(this.tabs),this._hoverable(this.tabs)},_setupHeightStyle:function(t){var i,s=this.element.parent();"fill"===t?(i=s.height(),i-=this.element.outerHeight()-this.element.height(),this.element.siblings(":visible").each(function(){var t=e(this),s=t.css("position");"absolute"!==s&&"fixed"!==s&&(i-=t.outerHeight(!0))}),this.element.children().not(this.panels).each(function(){i-=e(this).outerHeight(!0)}),this.panels.each(function(){e(this).height(Math.max(0,i-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):"auto"===t&&(i=0,this.panels.each(function(){i=Math.max(i,e(this).height("").height())}).height(i))},_eventHandler:function(t){var i=this.options,s=this.active,n=e(t.currentTarget),a=n.closest("li"),o=a[0]===s[0],r=o&&i.collapsible,h=r?e():this._getPanelForTab(a),l=s.length?this._getPanelForTab(s):e(),u={oldTab:s,oldPanel:l,newTab:r?e():a,newPanel:h};t.preventDefault(),a.hasClass("ui-state-disabled")||a.hasClass("ui-tabs-loading")||this.running||o&&!i.collapsible||this._trigger("beforeActivate",t,u)===!1||(i.active=r?!1:this.tabs.index(a),this.active=o?e():a,this.xhr&&this.xhr.abort(),l.length||h.length||e.error("jQuery UI Tabs: Mismatching fragment identifier."),h.length&&this.load(this.tabs.index(a),t),this._toggle(t,u))},_toggle:function(t,i){function s(){a.running=!1,a._trigger("activate",t,i)}function n(){i.newTab.closest("li").addClass("ui-tabs-active ui-state-active"),o.length&&a.options.show?a._show(o,a.options.show,s):(o.show(),s())}var a=this,o=i.newPanel,r=i.oldPanel;this.running=!0,r.length&&this.options.hide?this._hide(r,this.options.hide,function(){i.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),n()}):(i.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active"),r.hide(),n()),r.attr("aria-hidden","true"),i.oldTab.attr({"aria-selected":"false","aria-expanded":"false"}),o.length&&r.length?i.oldTab.attr("tabIndex",-1):o.length&&this.tabs.filter(function(){return 0===e(this).attr("tabIndex")}).attr("tabIndex",-1),o.attr("aria-hidden","false"),i.newTab.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0})},_activate:function(t){var i,s=this._findActive(t);s[0]!==this.active[0]&&(s.length||(s=this.active),i=s.find(".ui-tabs-anchor")[0],this._eventHandler({target:i,currentTarget:i,preventDefault:e.noop}))},_findActive:function(t){return t===!1?e():this.tabs.eq(t)},_getIndex:function(e){return"string"==typeof e&&(e=this.anchors.index(this.anchors.filter("[href$='"+e+"']"))),e},_destroy:function(){this.xhr&&this.xhr.abort(),this.element.removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible"),this.tablist.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all").removeAttr("role"),this.anchors.removeClass("ui-tabs-anchor").removeAttr("role").removeAttr("tabIndex").removeUniqueId(),this.tablist.unbind(this.eventNamespace),this.tabs.add(this.panels).each(function(){e.data(this,"ui-tabs-destroy")?e(this).remove():e(this).removeClass("ui-state-default ui-state-active ui-state-disabled ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel").removeAttr("tabIndex").removeAttr("aria-live").removeAttr("aria-busy").removeAttr("aria-selected").removeAttr("aria-labelledby").removeAttr("aria-hidden").removeAttr("aria-expanded").removeAttr("role")}),this.tabs.each(function(){var t=e(this),i=t.data("ui-tabs-aria-controls");i?t.attr("aria-controls",i).removeData("ui-tabs-aria-controls"):t.removeAttr("aria-controls")}),this.panels.show(),"content"!==this.options.heightStyle&&this.panels.css("height","")},enable:function(t){var i=this.options.disabled;i!==!1&&(void 0===t?i=!1:(t=this._getIndex(t),i=e.isArray(i)?e.map(i,function(e){return e!==t?e:null}):e.map(this.tabs,function(e,i){return i!==t?i:null})),this._setupDisabled(i))},disable:function(t){var i=this.options.disabled;if(i!==!0){if(void 0===t)i=!0;else{if(t=this._getIndex(t),-1!==e.inArray(t,i))return;i=e.isArray(i)?e.merge([t],i).sort():[t]}this._setupDisabled(i)}},load:function(t,i){t=this._getIndex(t);var s=this,n=this.tabs.eq(t),a=n.find(".ui-tabs-anchor"),o=this._getPanelForTab(n),r={tab:n,panel:o};this._isLocal(a[0])||(this.xhr=e.ajax(this._ajaxSettings(a,i,r)),this.xhr&&"canceled"!==this.xhr.statusText&&(n.addClass("ui-tabs-loading"),o.attr("aria-busy","true"),this.xhr.success(function(e){setTimeout(function(){o.html(e),s._trigger("load",i,r)},1)}).complete(function(e,t){setTimeout(function(){"abort"===t&&s.panels.stop(!1,!0),n.removeClass("ui-tabs-loading"),o.removeAttr("aria-busy"),e===s.xhr&&delete s.xhr},1)})))},_ajaxSettings:function(t,i,s){var n=this;return{url:t.attr("href"),beforeSend:function(t,a){return n._trigger("beforeLoad",i,e.extend({jqXHR:t,ajaxSettings:a},s))}}},_getPanelForTab:function(t){var i=e(t).attr("aria-controls");return this.element.find(this._sanitizeSelector("#"+i))}}),e.widget("ui.tooltip",{version:"1.11.1",options:{content:function(){var t=e(this).attr("title")||"";return e("<a>").text(t).html()},hide:!0,items:"[title]:not([disabled])",position:{my:"left top+15",at:"left bottom",collision:"flipfit flip"},show:!0,tooltipClass:null,track:!1,close:null,open:null},_addDescribedBy:function(t,i){var s=(t.attr("aria-describedby")||"").split(/\s+/);s.push(i),t.data("ui-tooltip-id",i).attr("aria-describedby",e.trim(s.join(" ")))},_removeDescribedBy:function(t){var i=t.data("ui-tooltip-id"),s=(t.attr("aria-describedby")||"").split(/\s+/),n=e.inArray(i,s);-1!==n&&s.splice(n,1),t.removeData("ui-tooltip-id"),s=e.trim(s.join(" ")),s?t.attr("aria-describedby",s):t.removeAttr("aria-describedby")},_create:function(){this._on({mouseover:"open",focusin:"open"}),this.tooltips={},this.parents={},this.options.disabled&&this._disable(),this.liveRegion=e("<div>").attr({role:"log","aria-live":"assertive","aria-relevant":"additions"}).addClass("ui-helper-hidden-accessible").appendTo(this.document[0].body)},_setOption:function(t,i){var s=this;return"disabled"===t?(this[i?"_disable":"_enable"](),this.options[t]=i,void 0):(this._super(t,i),"content"===t&&e.each(this.tooltips,function(e,t){s._updateContent(t)}),void 0)},_disable:function(){var t=this;e.each(this.tooltips,function(i,s){var n=e.Event("blur");n.target=n.currentTarget=s[0],t.close(n,!0)}),this.element.find(this.options.items).addBack().each(function(){var t=e(this);t.is("[title]")&&t.data("ui-tooltip-title",t.attr("title")).removeAttr("title")})},_enable:function(){this.element.find(this.options.items).addBack().each(function(){var t=e(this);t.data("ui-tooltip-title")&&t.attr("title",t.data("ui-tooltip-title"))})},open:function(t){var i=this,s=e(t?t.target:this.element).closest(this.options.items);s.length&&!s.data("ui-tooltip-id")&&(s.attr("title")&&s.data("ui-tooltip-title",s.attr("title")),s.data("ui-tooltip-open",!0),t&&"mouseover"===t.type&&s.parents().each(function(){var t,s=e(this);s.data("ui-tooltip-open")&&(t=e.Event("blur"),t.target=t.currentTarget=this,i.close(t,!0)),s.attr("title")&&(s.uniqueId(),i.parents[this.id]={element:this,title:s.attr("title")},s.attr("title",""))}),this._updateContent(s,t))},_updateContent:function(e,t){var i,s=this.options.content,n=this,a=t?t.type:null;return"string"==typeof s?this._open(t,e,s):(i=s.call(e[0],function(i){e.data("ui-tooltip-open")&&n._delay(function(){t&&(t.type=a),this._open(t,e,i)})}),i&&this._open(t,e,i),void 0)},_open:function(t,i,s){function n(e){l.of=e,a.is(":hidden")||a.position(l)}var a,o,r,h,l=e.extend({},this.options.position);if(s){if(a=this._find(i),a.length)return a.find(".ui-tooltip-content").html(s),void 0;i.is("[title]")&&(t&&"mouseover"===t.type?i.attr("title",""):i.removeAttr("title")),a=this._tooltip(i),this._addDescribedBy(i,a.attr("id")),a.find(".ui-tooltip-content").html(s),this.liveRegion.children().hide(),s.clone?(h=s.clone(),h.removeAttr("id").find("[id]").removeAttr("id")):h=s,e("<div>").html(h).appendTo(this.liveRegion),this.options.track&&t&&/^mouse/.test(t.type)?(this._on(this.document,{mousemove:n}),n(t)):a.position(e.extend({of:i},this.options.position)),this.hiding=!1,this.closing=!1,a.hide(),this._show(a,this.options.show),this.options.show&&this.options.show.delay&&(r=this.delayedShow=setInterval(function(){a.is(":visible")&&(n(l.of),clearInterval(r))},e.fx.interval)),this._trigger("open",t,{tooltip:a}),o={keyup:function(t){if(t.keyCode===e.ui.keyCode.ESCAPE){var s=e.Event(t);s.currentTarget=i[0],this.close(s,!0)}}},i[0]!==this.element[0]&&(o.remove=function(){this._removeTooltip(a)}),t&&"mouseover"!==t.type||(o.mouseleave="close"),t&&"focusin"!==t.type||(o.focusout="close"),this._on(!0,i,o)}},close:function(t){var i=this,s=e(t?t.currentTarget:this.element),n=this._find(s);this.closing||(clearInterval(this.delayedShow),s.data("ui-tooltip-title")&&!s.attr("title")&&s.attr("title",s.data("ui-tooltip-title")),this._removeDescribedBy(s),this.hiding=!0,n.stop(!0),this._hide(n,this.options.hide,function(){i._removeTooltip(e(this)),this.hiding=!1,this.closing=!1}),s.removeData("ui-tooltip-open"),this._off(s,"mouseleave focusout keyup"),s[0]!==this.element[0]&&this._off(s,"remove"),this._off(this.document,"mousemove"),t&&"mouseleave"===t.type&&e.each(this.parents,function(t,s){e(s.element).attr("title",s.title),delete i.parents[t]}),this.closing=!0,this._trigger("close",t,{tooltip:n}),this.hiding||(this.closing=!1))},_tooltip:function(t){var i=e("<div>").attr("role","tooltip").addClass("ui-tooltip ui-widget ui-corner-all ui-widget-content "+(this.options.tooltipClass||"")),s=i.uniqueId().attr("id");return e("<div>").addClass("ui-tooltip-content").appendTo(i),i.appendTo(this.document[0].body),this.tooltips[s]=t,i},_find:function(t){var i=t.data("ui-tooltip-id");return i?e("#"+i):e()},_removeTooltip:function(e){e.remove(),delete this.tooltips[e.attr("id")]},_destroy:function(){var t=this;e.each(this.tooltips,function(i,s){var n=e.Event("blur");n.target=n.currentTarget=s[0],t.close(n,!0),e("#"+i).remove(),s.data("ui-tooltip-title")&&(s.attr("title")||s.attr("title",s.data("ui-tooltip-title")),s.removeData("ui-tooltip-title"))}),this.liveRegion.remove()}})});
embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-audio.js ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery File Upload Audio Preview Plugin 1.0.3
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2013, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /* jshint nomen:false */
13
+ /* global define, window, document */
14
+
15
+ (function (factory) {
16
+ 'use strict';
17
+ if (typeof define === 'function' && define.amd) {
18
+ // Register as an anonymous AMD module:
19
+ define([
20
+ 'jquery',
21
+ 'load-image',
22
+ './jquery.fileupload-process'
23
+ ], factory);
24
+ } else {
25
+ // Browser globals:
26
+ factory(
27
+ window.jQuery,
28
+ window.loadImage
29
+ );
30
+ }
31
+ }(function ($, loadImage) {
32
+ 'use strict';
33
+
34
+ // Prepend to the default processQueue:
35
+ $.blueimp.fileupload.prototype.options.processQueue.unshift(
36
+ {
37
+ action: 'loadAudio',
38
+ // Use the action as prefix for the "@" options:
39
+ prefix: true,
40
+ fileTypes: '@',
41
+ maxFileSize: '@',
42
+ disabled: '@disableAudioPreview'
43
+ },
44
+ {
45
+ action: 'setAudio',
46
+ name: '@audioPreviewName',
47
+ disabled: '@disableAudioPreview'
48
+ }
49
+ );
50
+
51
+ // The File Upload Audio Preview plugin extends the fileupload widget
52
+ // with audio preview functionality:
53
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
54
+
55
+ options: {
56
+ // The regular expression for the types of audio files to load,
57
+ // matched against the file type:
58
+ loadAudioFileTypes: /^audio\/.*$/
59
+ },
60
+
61
+ _audioElement: document.createElement('audio'),
62
+
63
+ processActions: {
64
+
65
+ // Loads the audio file given via data.files and data.index
66
+ // as audio element if the browser supports playing it.
67
+ // Accepts the options fileTypes (regular expression)
68
+ // and maxFileSize (integer) to limit the files to load:
69
+ loadAudio: function (data, options) {
70
+ if (options.disabled) {
71
+ return data;
72
+ }
73
+ var file = data.files[data.index],
74
+ url,
75
+ audio;
76
+ if (this._audioElement.canPlayType &&
77
+ this._audioElement.canPlayType(file.type) &&
78
+ ($.type(options.maxFileSize) !== 'number' ||
79
+ file.size <= options.maxFileSize) &&
80
+ (!options.fileTypes ||
81
+ options.fileTypes.test(file.type))) {
82
+ url = loadImage.createObjectURL(file);
83
+ if (url) {
84
+ audio = this._audioElement.cloneNode(false);
85
+ audio.src = url;
86
+ audio.controls = true;
87
+ data.audio = audio;
88
+ return data;
89
+ }
90
+ }
91
+ return data;
92
+ },
93
+
94
+ // Sets the audio element as a property of the file object:
95
+ setAudio: function (data, options) {
96
+ if (data.audio && !options.disabled) {
97
+ data.files[data.index][options.name || 'preview'] = data.audio;
98
+ }
99
+ return data;
100
+ }
101
+
102
+ }
103
+
104
+ });
105
+
106
+ }));
embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-image.js ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery File Upload Image Preview & Resize Plugin 1.7.2
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2013, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /* jshint nomen:false */
13
+ /* global define, window, Blob */
14
+
15
+ (function (factory) {
16
+ 'use strict';
17
+ if (typeof define === 'function' && define.amd) {
18
+ // Register as an anonymous AMD module:
19
+ define([
20
+ 'jquery',
21
+ 'load-image',
22
+ 'load-image-meta',
23
+ 'load-image-exif',
24
+ 'load-image-ios',
25
+ 'canvas-to-blob',
26
+ './jquery.fileupload-process'
27
+ ], factory);
28
+ } else {
29
+ // Browser globals:
30
+ factory(
31
+ window.jQuery,
32
+ window.loadImage
33
+ );
34
+ }
35
+ }(function ($, loadImage) {
36
+ 'use strict';
37
+
38
+ // Prepend to the default processQueue:
39
+ $.blueimp.fileupload.prototype.options.processQueue.unshift(
40
+ {
41
+ action: 'loadImageMetaData',
42
+ disableImageHead: '@',
43
+ disableExif: '@',
44
+ disableExifThumbnail: '@',
45
+ disableExifSub: '@',
46
+ disableExifGps: '@',
47
+ disabled: '@disableImageMetaDataLoad'
48
+ },
49
+ {
50
+ action: 'loadImage',
51
+ // Use the action as prefix for the "@" options:
52
+ prefix: true,
53
+ fileTypes: '@',
54
+ maxFileSize: '@',
55
+ noRevoke: '@',
56
+ disabled: '@disableImageLoad'
57
+ },
58
+ {
59
+ action: 'resizeImage',
60
+ // Use "image" as prefix for the "@" options:
61
+ prefix: 'image',
62
+ maxWidth: '@',
63
+ maxHeight: '@',
64
+ minWidth: '@',
65
+ minHeight: '@',
66
+ crop: '@',
67
+ orientation: '@',
68
+ forceResize: '@',
69
+ disabled: '@disableImageResize'
70
+ },
71
+ {
72
+ action: 'saveImage',
73
+ quality: '@imageQuality',
74
+ type: '@imageType',
75
+ disabled: '@disableImageResize'
76
+ },
77
+ {
78
+ action: 'saveImageMetaData',
79
+ disabled: '@disableImageMetaDataSave'
80
+ },
81
+ {
82
+ action: 'resizeImage',
83
+ // Use "preview" as prefix for the "@" options:
84
+ prefix: 'preview',
85
+ maxWidth: '@',
86
+ maxHeight: '@',
87
+ minWidth: '@',
88
+ minHeight: '@',
89
+ crop: '@',
90
+ orientation: '@',
91
+ thumbnail: '@',
92
+ canvas: '@',
93
+ disabled: '@disableImagePreview'
94
+ },
95
+ {
96
+ action: 'setImage',
97
+ name: '@imagePreviewName',
98
+ disabled: '@disableImagePreview'
99
+ },
100
+ {
101
+ action: 'deleteImageReferences',
102
+ disabled: '@disableImageReferencesDeletion'
103
+ }
104
+ );
105
+
106
+ // The File Upload Resize plugin extends the fileupload widget
107
+ // with image resize functionality:
108
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
109
+
110
+ options: {
111
+ // The regular expression for the types of images to load:
112
+ // matched against the file type:
113
+ loadImageFileTypes: /^image\/(gif|jpeg|png|svg\+xml)$/,
114
+ // The maximum file size of images to load:
115
+ loadImageMaxFileSize: 10000000, // 10MB
116
+ // The maximum width of resized images:
117
+ imageMaxWidth: 1920,
118
+ // The maximum height of resized images:
119
+ imageMaxHeight: 1080,
120
+ // Defines the image orientation (1-8) or takes the orientation
121
+ // value from Exif data if set to true:
122
+ imageOrientation: false,
123
+ // Define if resized images should be cropped or only scaled:
124
+ imageCrop: false,
125
+ // Disable the resize image functionality by default:
126
+ disableImageResize: true,
127
+ // The maximum width of the preview images:
128
+ previewMaxWidth: 80,
129
+ // The maximum height of the preview images:
130
+ previewMaxHeight: 80,
131
+ // Defines the preview orientation (1-8) or takes the orientation
132
+ // value from Exif data if set to true:
133
+ previewOrientation: true,
134
+ // Create the preview using the Exif data thumbnail:
135
+ previewThumbnail: true,
136
+ // Define if preview images should be cropped or only scaled:
137
+ previewCrop: false,
138
+ // Define if preview images should be resized as canvas elements:
139
+ previewCanvas: true
140
+ },
141
+
142
+ processActions: {
143
+
144
+ // Loads the image given via data.files and data.index
145
+ // as img element, if the browser supports the File API.
146
+ // Accepts the options fileTypes (regular expression)
147
+ // and maxFileSize (integer) to limit the files to load:
148
+ loadImage: function (data, options) {
149
+ if (options.disabled) {
150
+ return data;
151
+ }
152
+ var that = this,
153
+ file = data.files[data.index],
154
+ dfd = $.Deferred();
155
+ if (($.type(options.maxFileSize) === 'number' &&
156
+ file.size > options.maxFileSize) ||
157
+ (options.fileTypes &&
158
+ !options.fileTypes.test(file.type)) ||
159
+ !loadImage(
160
+ file,
161
+ function (img) {
162
+ if (img.src) {
163
+ data.img = img;
164
+ }
165
+ dfd.resolveWith(that, [data]);
166
+ },
167
+ options
168
+ )) {
169
+ return data;
170
+ }
171
+ return dfd.promise();
172
+ },
173
+
174
+ // Resizes the image given as data.canvas or data.img
175
+ // and updates data.canvas or data.img with the resized image.
176
+ // Also stores the resized image as preview property.
177
+ // Accepts the options maxWidth, maxHeight, minWidth,
178
+ // minHeight, canvas and crop:
179
+ resizeImage: function (data, options) {
180
+ if (options.disabled || !(data.canvas || data.img)) {
181
+ return data;
182
+ }
183
+ options = $.extend({canvas: true}, options);
184
+ var that = this,
185
+ dfd = $.Deferred(),
186
+ img = (options.canvas && data.canvas) || data.img,
187
+ resolve = function (newImg) {
188
+ if (newImg && (newImg.width !== img.width ||
189
+ newImg.height !== img.height ||
190
+ options.forceResize)) {
191
+ data[newImg.getContext ? 'canvas' : 'img'] = newImg;
192
+ }
193
+ data.preview = newImg;
194
+ dfd.resolveWith(that, [data]);
195
+ },
196
+ thumbnail;
197
+ if (data.exif) {
198
+ if (options.orientation === true) {
199
+ options.orientation = data.exif.get('Orientation');
200
+ }
201
+ if (options.thumbnail) {
202
+ thumbnail = data.exif.get('Thumbnail');
203
+ if (thumbnail) {
204
+ loadImage(thumbnail, resolve, options);
205
+ return dfd.promise();
206
+ }
207
+ }
208
+ // Prevent orienting the same image twice:
209
+ if (data.orientation) {
210
+ delete options.orientation;
211
+ } else {
212
+ data.orientation = options.orientation;
213
+ }
214
+ }
215
+ if (img) {
216
+ resolve(loadImage.scale(img, options));
217
+ return dfd.promise();
218
+ }
219
+ return data;
220
+ },
221
+
222
+ // Saves the processed image given as data.canvas
223
+ // inplace at data.index of data.files:
224
+ saveImage: function (data, options) {
225
+ if (!data.canvas || options.disabled) {
226
+ return data;
227
+ }
228
+ var that = this,
229
+ file = data.files[data.index],
230
+ dfd = $.Deferred();
231
+ if (data.canvas.toBlob) {
232
+ data.canvas.toBlob(
233
+ function (blob) {
234
+ if (!blob.name) {
235
+ if (file.type === blob.type) {
236
+ blob.name = file.name;
237
+ } else if (file.name) {
238
+ blob.name = file.name.replace(
239
+ /\..+$/,
240
+ '.' + blob.type.substr(6)
241
+ );
242
+ }
243
+ }
244
+ // Don't restore invalid meta data:
245
+ if (file.type !== blob.type) {
246
+ delete data.imageHead;
247
+ }
248
+ // Store the created blob at the position
249
+ // of the original file in the files list:
250
+ data.files[data.index] = blob;
251
+ dfd.resolveWith(that, [data]);
252
+ },
253
+ options.type || file.type,
254
+ options.quality
255
+ );
256
+ } else {
257
+ return data;
258
+ }
259
+ return dfd.promise();
260
+ },
261
+
262
+ loadImageMetaData: function (data, options) {
263
+ if (options.disabled) {
264
+ return data;
265
+ }
266
+ var that = this,
267
+ dfd = $.Deferred();
268
+ loadImage.parseMetaData(data.files[data.index], function (result) {
269
+ $.extend(data, result);
270
+ dfd.resolveWith(that, [data]);
271
+ }, options);
272
+ return dfd.promise();
273
+ },
274
+
275
+ saveImageMetaData: function (data, options) {
276
+ if (!(data.imageHead && data.canvas &&
277
+ data.canvas.toBlob && !options.disabled)) {
278
+ return data;
279
+ }
280
+ var file = data.files[data.index],
281
+ blob = new Blob([
282
+ data.imageHead,
283
+ // Resized images always have a head size of 20 bytes,
284
+ // including the JPEG marker and a minimal JFIF header:
285
+ this._blobSlice.call(file, 20)
286
+ ], {type: file.type});
287
+ blob.name = file.name;
288
+ data.files[data.index] = blob;
289
+ return data;
290
+ },
291
+
292
+ // Sets the resized version of the image as a property of the
293
+ // file object, must be called after "saveImage":
294
+ setImage: function (data, options) {
295
+ if (data.preview && !options.disabled) {
296
+ data.files[data.index][options.name || 'preview'] = data.preview;
297
+ }
298
+ return data;
299
+ },
300
+
301
+ deleteImageReferences: function (data, options) {
302
+ if (!options.disabled) {
303
+ delete data.img;
304
+ delete data.canvas;
305
+ delete data.preview;
306
+ delete data.imageHead;
307
+ }
308
+ return data;
309
+ }
310
+
311
+ }
312
+
313
+ });
314
+
315
+ }));
embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-jquery-ui.js ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery File Upload jQuery UI Plugin 8.7.1
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2013, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /* jshint nomen:false */
13
+ /* global define, window */
14
+
15
+ (function (factory) {
16
+ 'use strict';
17
+ if (typeof define === 'function' && define.amd) {
18
+ // Register as an anonymous AMD module:
19
+ define(['jquery', './jquery.fileupload-ui'], factory);
20
+ } else {
21
+ // Browser globals:
22
+ factory(window.jQuery);
23
+ }
24
+ }(function ($) {
25
+ 'use strict';
26
+
27
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
28
+
29
+ options: {
30
+ processdone: function (e, data) {
31
+ data.context.find('.start').button('enable');
32
+ },
33
+ progress: function (e, data) {
34
+ if (data.context) {
35
+ data.context.find('.progress').progressbar(
36
+ 'option',
37
+ 'value',
38
+ parseInt(data.loaded / data.total * 100, 10)
39
+ );
40
+ }
41
+ },
42
+ progressall: function (e, data) {
43
+ var $this = $(this);
44
+ $this.find('.fileupload-progress')
45
+ .find('.progress').progressbar(
46
+ 'option',
47
+ 'value',
48
+ parseInt(data.loaded / data.total * 100, 10)
49
+ ).end()
50
+ .find('.progress-extended').each(function () {
51
+ $(this).html(
52
+ ($this.data('blueimp-fileupload') ||
53
+ $this.data('fileupload'))
54
+ ._renderExtendedProgress(data)
55
+ );
56
+ });
57
+ }
58
+ },
59
+
60
+ _renderUpload: function (func, files) {
61
+ var node = this._super(func, files),
62
+ showIconText = $(window).width() > 480;
63
+ node.find('.progress').empty().progressbar();
64
+ node.find('.start').button({
65
+ icons: {primary: 'ui-icon-circle-arrow-e'},
66
+ text: showIconText
67
+ });
68
+ node.find('.cancel').button({
69
+ icons: {primary: 'ui-icon-cancel'},
70
+ text: showIconText
71
+ });
72
+ if (node.hasClass('jqhfu-fade')) {
73
+ node.hide();
74
+ }
75
+ return node;
76
+ },
77
+
78
+ _renderDownload: function (func, files) {
79
+ var node = this._super(func, files),
80
+ showIconText = $(window).width() > 480;
81
+ node.find('.delete').button({
82
+ icons: {primary: 'ui-icon-trash'},
83
+ text: showIconText
84
+ });
85
+ if (node.hasClass('jqhfu-fade')) {
86
+ node.hide();
87
+ }
88
+ return node;
89
+ },
90
+
91
+ _startHandler: function (e) {
92
+ $(e.currentTarget).button('disable');
93
+ this._super(e);
94
+ },
95
+
96
+ _transition: function (node) {
97
+ var deferred = $.Deferred();
98
+ if (node.hasClass('jqhfu-fade')) {
99
+ node.fadeToggle(
100
+ this.options.transitionDuration,
101
+ this.options.transitionEasing,
102
+ function () {
103
+ deferred.resolveWith(node);
104
+ }
105
+ );
106
+ } else {
107
+ deferred.resolveWith(node);
108
+ }
109
+ return deferred;
110
+ },
111
+
112
+ _create: function () {
113
+ this._super();
114
+ this.element
115
+ .find('.fileupload-buttonbar')
116
+ .find('.fileinput-button').each(function () {
117
+ var input = $(this).find('input:file').detach();
118
+ $(this)
119
+ .button({icons: {primary: 'ui-icon-plusthick'}})
120
+ .append(input);
121
+ })
122
+ .end().find('.start')
123
+ .button({icons: {primary: 'ui-icon-circle-arrow-e'}})
124
+ .end().find('.cancel')
125
+ .button({icons: {primary: 'ui-icon-cancel'}})
126
+ .end().find('.delete')
127
+ .button({icons: {primary: 'ui-icon-trash'}})
128
+ .end().find('.progress').progressbar();
129
+ },
130
+
131
+ _destroy: function () {
132
+ this.element
133
+ .find('.fileupload-buttonbar')
134
+ .find('.fileinput-button').each(function () {
135
+ var input = $(this).find('input:file').detach();
136
+ $(this)
137
+ .button('destroy')
138
+ .append(input);
139
+ })
140
+ .end().find('.start')
141
+ .button('destroy')
142
+ .end().find('.cancel')
143
+ .button('destroy')
144
+ .end().find('.delete')
145
+ .button('destroy')
146
+ .end().find('.progress').progressbar('destroy');
147
+ this._super();
148
+ }
149
+
150
+ });
151
+
152
+ }));
embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-process.js ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery File Upload Processing Plugin 1.3.0
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2012, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /* jshint nomen:false */
13
+ /* global define, window */
14
+
15
+ (function (factory) {
16
+ 'use strict';
17
+ if (typeof define === 'function' && define.amd) {
18
+ // Register as an anonymous AMD module:
19
+ define([
20
+ 'jquery',
21
+ './jquery.fileupload'
22
+ ], factory);
23
+ } else {
24
+ // Browser globals:
25
+ factory(
26
+ window.jQuery
27
+ );
28
+ }
29
+ }(function ($) {
30
+ 'use strict';
31
+
32
+ var originalAdd = $.blueimp.fileupload.prototype.options.add;
33
+
34
+ // The File Upload Processing plugin extends the fileupload widget
35
+ // with file processing functionality:
36
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
37
+
38
+ options: {
39
+ // The list of processing actions:
40
+ processQueue: [
41
+ /*
42
+ {
43
+ action: 'log',
44
+ type: 'debug'
45
+ }
46
+ */
47
+ ],
48
+ add: function (e, data) {
49
+ var $this = $(this);
50
+ data.process(function () {
51
+ return $this.fileupload('process', data);
52
+ });
53
+ originalAdd.call(this, e, data);
54
+ }
55
+ },
56
+
57
+ processActions: {
58
+ /*
59
+ log: function (data, options) {
60
+ console[options.type](
61
+ 'Processing "' + data.files[data.index].name + '"'
62
+ );
63
+ }
64
+ */
65
+ },
66
+
67
+ _processFile: function (data, originalData) {
68
+ var that = this,
69
+ dfd = $.Deferred().resolveWith(that, [data]),
70
+ chain = dfd.promise();
71
+ this._trigger('process', null, data);
72
+ $.each(data.processQueue, function (i, settings) {
73
+ var func = function (data) {
74
+ if (originalData.errorThrown) {
75
+ return $.Deferred()
76
+ .rejectWith(that, [originalData]).promise();
77
+ }
78
+ return that.processActions[settings.action].call(
79
+ that,
80
+ data,
81
+ settings
82
+ );
83
+ };
84
+ chain = chain.pipe(func, settings.always && func);
85
+ });
86
+ chain
87
+ .done(function () {
88
+ that._trigger('processdone', null, data);
89
+ that._trigger('processalways', null, data);
90
+ })
91
+ .fail(function () {
92
+ that._trigger('processfail', null, data);
93
+ that._trigger('processalways', null, data);
94
+ });
95
+ return chain;
96
+ },
97
+
98
+ // Replaces the settings of each processQueue item that
99
+ // are strings starting with an "@", using the remaining
100
+ // substring as key for the option map,
101
+ // e.g. "@autoUpload" is replaced with options.autoUpload:
102
+ _transformProcessQueue: function (options) {
103
+ var processQueue = [];
104
+ $.each(options.processQueue, function () {
105
+ var settings = {},
106
+ action = this.action,
107
+ prefix = this.prefix === true ? action : this.prefix;
108
+ $.each(this, function (key, value) {
109
+ if ($.type(value) === 'string' &&
110
+ value.charAt(0) === '@') {
111
+ settings[key] = options[
112
+ value.slice(1) || (prefix ? prefix +
113
+ key.charAt(0).toUpperCase() + key.slice(1) : key)
114
+ ];
115
+ } else {
116
+ settings[key] = value;
117
+ }
118
+
119
+ });
120
+ processQueue.push(settings);
121
+ });
122
+ options.processQueue = processQueue;
123
+ },
124
+
125
+ // Returns the number of files currently in the processsing queue:
126
+ processing: function () {
127
+ return this._processing;
128
+ },
129
+
130
+ // Processes the files given as files property of the data parameter,
131
+ // returns a Promise object that allows to bind callbacks:
132
+ process: function (data) {
133
+ var that = this,
134
+ options = $.extend({}, this.options, data);
135
+ if (options.processQueue && options.processQueue.length) {
136
+ this._transformProcessQueue(options);
137
+ if (this._processing === 0) {
138
+ this._trigger('processstart');
139
+ }
140
+ $.each(data.files, function (index) {
141
+ var opts = index ? $.extend({}, options) : options,
142
+ func = function () {
143
+ if (data.errorThrown) {
144
+ return $.Deferred()
145
+ .rejectWith(that, [data]).promise();
146
+ }
147
+ return that._processFile(opts, data);
148
+ };
149
+ opts.index = index;
150
+ that._processing += 1;
151
+ that._processingQueue = that._processingQueue.pipe(func, func)
152
+ .always(function () {
153
+ that._processing -= 1;
154
+ if (that._processing === 0) {
155
+ that._trigger('processstop');
156
+ }
157
+ });
158
+ });
159
+ }
160
+ return this._processingQueue;
161
+ },
162
+
163
+ _create: function () {
164
+ this._super();
165
+ this._processing = 0;
166
+ this._processingQueue = $.Deferred().resolveWith(this)
167
+ .promise();
168
+ }
169
+
170
+ });
171
+
172
+ }));
embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-ui.css ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @charset "UTF-8";
2
+ /*
3
+ * jQuery File Upload UI Plugin CSS 9.0.0
4
+ * https://github.com/blueimp/jQuery-File-Upload
5
+ *
6
+ * Copyright 2010, Sebastian Tschan
7
+ * https://blueimp.net
8
+ *
9
+ * Licensed under the MIT license:
10
+ * http://www.opensource.org/licenses/MIT
11
+ */
12
+
13
+ .fileupload-buttonbar .btn,
14
+ .fileupload-buttonbar .toggle {
15
+ margin-bottom: 5px;
16
+ }
17
+ .progress-animated .progress-bar,
18
+ .progress-animated .bar {
19
+ background: url("../img/progressbar.gif") !important;
20
+ filter: none;
21
+ }
22
+ .fileupload-process {
23
+ float: right;
24
+ display: none;
25
+ }
26
+ .fileupload-processing .fileupload-process,
27
+ .files .processing .preview {
28
+ display: block;
29
+ width: 32px;
30
+ height: 32px;
31
+ background: url("../img/loading.gif") center no-repeat;
32
+ background-size: contain;
33
+ }
34
+ .files audio,
35
+ .files video {
36
+ max-width: 300px;
37
+ }
38
+
39
+ @media (max-width: 767px) {
40
+ .fileupload-buttonbar .toggle,
41
+ .files .toggle,
42
+ .files .btn span {
43
+ display: none;
44
+ }
45
+ .files .name {
46
+ width: 80px;
47
+ word-wrap: break-word;
48
+ }
49
+ .files audio,
50
+ .files video {
51
+ max-width: 80px;
52
+ }
53
+ .files img,
54
+ .files canvas {
55
+ max-width: 100%;
56
+ }
57
+ }
embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-ui.js ADDED
@@ -0,0 +1,704 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery File Upload User Interface Plugin 9.6.0
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2010, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /* jshint nomen:false */
13
+ /* global define, window */
14
+
15
+ (function (factory) {
16
+ 'use strict';
17
+ if (typeof define === 'function' && define.amd) {
18
+ // Register as an anonymous AMD module:
19
+ define([
20
+ 'jquery',
21
+ 'tmpl',
22
+ './jquery.fileupload-image',
23
+ './jquery.fileupload-audio',
24
+ './jquery.fileupload-video',
25
+ './jquery.fileupload-validate'
26
+ ], factory);
27
+ } else {
28
+ // Browser globals:
29
+ factory(
30
+ window.jQuery,
31
+ window.tmpl
32
+ );
33
+ }
34
+ }(function ($, tmpl) {
35
+ 'use strict';
36
+
37
+ $.blueimp.fileupload.prototype._specialOptions.push(
38
+ 'filesContainer',
39
+ 'uploadTemplateId',
40
+ 'downloadTemplateId'
41
+ );
42
+
43
+ // The UI version extends the file upload widget
44
+ // and adds complete user interface interaction:
45
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
46
+
47
+ options: {
48
+ // By default, files added to the widget are uploaded as soon
49
+ // as the user clicks on the start buttons. To enable automatic
50
+ // uploads, set the following option to true:
51
+ autoUpload: false,
52
+ // The ID of the upload template:
53
+ uploadTemplateId: 'template-upload',
54
+ // The ID of the download template:
55
+ downloadTemplateId: 'template-download',
56
+ // The container for the list of files. If undefined, it is set to
57
+ // an element with class "files" inside of the widget element:
58
+ filesContainer: undefined,
59
+ // By default, files are appended to the files container.
60
+ // Set the following option to true, to prepend files instead:
61
+ prependFiles: false,
62
+ // The expected data type of the upload response, sets the dataType
63
+ // option of the $.ajax upload requests:
64
+ dataType: 'json',
65
+
66
+ // Error and info messages:
67
+ messages: {
68
+ unknownError: 'Unknown error'
69
+ },
70
+
71
+ // Function returning the current number of files,
72
+ // used by the maxNumberOfFiles validation:
73
+ getNumberOfFiles: function () {
74
+ return this.filesContainer.children()
75
+ .not('.processing').length;
76
+ },
77
+
78
+ // Callback to retrieve the list of files from the server response:
79
+ getFilesFromResponse: function (data) {
80
+ if (data.result && $.isArray(data.result.files)) {
81
+ return data.result.files;
82
+ }
83
+ return [];
84
+ },
85
+
86
+ // The add callback is invoked as soon as files are added to the fileupload
87
+ // widget (via file input selection, drag & drop or add API call).
88
+ // See the basic file upload widget for more information:
89
+ add: function (e, data) {
90
+ if (e.isDefaultPrevented()) {
91
+ return false;
92
+ }
93
+ var $this = $(this),
94
+ that = $this.data('blueimp-fileupload') ||
95
+ $this.data('fileupload'),
96
+ options = that.options;
97
+ data.context = that._renderUpload(data.files)
98
+ .data('data', data)
99
+ .addClass('processing');
100
+ options.filesContainer[
101
+ options.prependFiles ? 'prepend' : 'append'
102
+ ](data.context);
103
+ that._forceReflow(data.context);
104
+ that._transition(data.context);
105
+ data.process(function () {
106
+ return $this.fileupload('process', data);
107
+ }).always(function () {
108
+ data.context.each(function (index) {
109
+ $(this).find('.size').text(
110
+ that._formatFileSize(data.files[index].size)
111
+ );
112
+ }).removeClass('processing');
113
+ that._renderPreviews(data);
114
+ }).done(function () {
115
+ data.context.find('.start').prop('disabled', false);
116
+ if ((that._trigger('added', e, data) !== false) &&
117
+ (options.autoUpload || data.autoUpload) &&
118
+ data.autoUpload !== false) {
119
+ data.submit();
120
+ }
121
+ }).fail(function () {
122
+ if (data.files.error) {
123
+ data.context.each(function (index) {
124
+ var error = data.files[index].error;
125
+ if (error) {
126
+ $(this).find('.error').text(error);
127
+ }
128
+ });
129
+ }
130
+ });
131
+ },
132
+ // Callback for the start of each file upload request:
133
+ send: function (e, data) {
134
+ if (e.isDefaultPrevented()) {
135
+ return false;
136
+ }
137
+ var that = $(this).data('blueimp-fileupload') ||
138
+ $(this).data('fileupload');
139
+ if (data.context && data.dataType &&
140
+ data.dataType.substr(0, 6) === 'iframe') {
141
+ // Iframe Transport does not support progress events.
142
+ // In lack of an indeterminate progress bar, we set
143
+ // the progress to 100%, showing the full animated bar:
144
+ data.context
145
+ .find('.progress').addClass(
146
+ !$.support.transition && 'progress-animated'
147
+ )
148
+ .attr('aria-valuenow', 100)
149
+ .children().first().css(
150
+ 'width',
151
+ '100%'
152
+ );
153
+ }
154
+ return that._trigger('sent', e, data);
155
+ },
156
+ // Callback for successful uploads:
157
+ done: function (e, data) {
158
+ if (e.isDefaultPrevented()) {
159
+ return false;
160
+ }
161
+ var that = $(this).data('blueimp-fileupload') ||
162
+ $(this).data('fileupload'),
163
+ getFilesFromResponse = data.getFilesFromResponse ||
164
+ that.options.getFilesFromResponse,
165
+ files = getFilesFromResponse(data),
166
+ template,
167
+ deferred;
168
+ if (data.context) {
169
+ data.context.each(function (index) {
170
+ var file = files[index] ||
171
+ {error: 'Empty file upload result'};
172
+ deferred = that._addFinishedDeferreds();
173
+ that._transition($(this)).done(
174
+ function () {
175
+ var node = $(this);
176
+ template = that._renderDownload([file])
177
+ .replaceAll(node);
178
+ that._forceReflow(template);
179
+ that._transition(template).done(
180
+ function () {
181
+ data.context = $(this);
182
+ that._trigger('completed', e, data);
183
+ that._trigger('finished', e, data);
184
+ deferred.resolve();
185
+ }
186
+ );
187
+ }
188
+ );
189
+ });
190
+ } else {
191
+ template = that._renderDownload(files)[
192
+ that.options.prependFiles ? 'prependTo' : 'appendTo'
193
+ ](that.options.filesContainer);
194
+ that._forceReflow(template);
195
+ deferred = that._addFinishedDeferreds();
196
+ that._transition(template).done(
197
+ function () {
198
+ data.context = $(this);
199
+ that._trigger('completed', e, data);
200
+ that._trigger('finished', e, data);
201
+ deferred.resolve();
202
+ }
203
+ );
204
+ }
205
+ },
206
+ // Callback for failed (abort or error) uploads:
207
+ fail: function (e, data) {
208
+ if (e.isDefaultPrevented()) {
209
+ return false;
210
+ }
211
+ var that = $(this).data('blueimp-fileupload') ||
212
+ $(this).data('fileupload'),
213
+ template,
214
+ deferred;
215
+ if (data.context) {
216
+ data.context.each(function (index) {
217
+ if (data.errorThrown !== 'abort') {
218
+ var file = data.files[index];
219
+ file.error = file.error || data.errorThrown ||
220
+ data.i18n('unknownError');
221
+ deferred = that._addFinishedDeferreds();
222
+ that._transition($(this)).done(
223
+ function () {
224
+ var node = $(this);
225
+ template = that._renderDownload([file])
226
+ .replaceAll(node);
227
+ that._forceReflow(template);
228
+ that._transition(template).done(
229
+ function () {
230
+ data.context = $(this);
231
+ that._trigger('failed', e, data);
232
+ that._trigger('finished', e, data);
233
+ deferred.resolve();
234
+ }
235
+ );
236
+ }
237
+ );
238
+ } else {
239
+ deferred = that._addFinishedDeferreds();
240
+ that._transition($(this)).done(
241
+ function () {
242
+ $(this).remove();
243
+ that._trigger('failed', e, data);
244
+ that._trigger('finished', e, data);
245
+ deferred.resolve();
246
+ }
247
+ );
248
+ }
249
+ });
250
+ } else if (data.errorThrown !== 'abort') {
251
+ data.context = that._renderUpload(data.files)[
252
+ that.options.prependFiles ? 'prependTo' : 'appendTo'
253
+ ](that.options.filesContainer)
254
+ .data('data', data);
255
+ that._forceReflow(data.context);
256
+ deferred = that._addFinishedDeferreds();
257
+ that._transition(data.context).done(
258
+ function () {
259
+ data.context = $(this);
260
+ that._trigger('failed', e, data);
261
+ that._trigger('finished', e, data);
262
+ deferred.resolve();
263
+ }
264
+ );
265
+ } else {
266
+ that._trigger('failed', e, data);
267
+ that._trigger('finished', e, data);
268
+ that._addFinishedDeferreds().resolve();
269
+ }
270
+ },
271
+ // Callback for upload progress events:
272
+ progress: function (e, data) {
273
+ if (e.isDefaultPrevented()) {
274
+ return false;
275
+ }
276
+ var progress = Math.floor(data.loaded / data.total * 100);
277
+ if (data.context) {
278
+ data.context.each(function () {
279
+ $(this).find('.progress')
280
+ .attr('aria-valuenow', progress)
281
+ .children().first().css(
282
+ 'width',
283
+ progress + '%'
284
+ );
285
+ });
286
+ }
287
+ },
288
+ // Callback for global upload progress events:
289
+ progressall: function (e, data) {
290
+ if (e.isDefaultPrevented()) {
291
+ return false;
292
+ }
293
+ var $this = $(this),
294
+ progress = Math.floor(data.loaded / data.total * 100),
295
+ globalProgressNode = $this.find('.fileupload-progress'),
296
+ extendedProgressNode = globalProgressNode
297
+ .find('.progress-extended');
298
+ if (extendedProgressNode.length) {
299
+ extendedProgressNode.html(
300
+ ($this.data('blueimp-fileupload') || $this.data('fileupload'))
301
+ ._renderExtendedProgress(data)
302
+ );
303
+ }
304
+ globalProgressNode
305
+ .find('.progress')
306
+ .attr('aria-valuenow', progress)
307
+ .children().first().css(
308
+ 'width',
309
+ progress + '%'
310
+ );
311
+ },
312
+ // Callback for uploads start, equivalent to the global ajaxStart event:
313
+ start: function (e) {
314
+ if (e.isDefaultPrevented()) {
315
+ return false;
316
+ }
317
+ var that = $(this).data('blueimp-fileupload') ||
318
+ $(this).data('fileupload');
319
+ that._resetFinishedDeferreds();
320
+ that._transition($(this).find('.fileupload-progress')).done(
321
+ function () {
322
+ that._trigger('started', e);
323
+ }
324
+ );
325
+ },
326
+ // Callback for uploads stop, equivalent to the global ajaxStop event:
327
+ stop: function (e) {
328
+ if (e.isDefaultPrevented()) {
329
+ return false;
330
+ }
331
+ var that = $(this).data('blueimp-fileupload') ||
332
+ $(this).data('fileupload'),
333
+ deferred = that._addFinishedDeferreds();
334
+ $.when.apply($, that._getFinishedDeferreds())
335
+ .done(function () {
336
+ that._trigger('stopped', e);
337
+ });
338
+ that._transition($(this).find('.fileupload-progress')).done(
339
+ function () {
340
+ $(this).find('.progress')
341
+ .attr('aria-valuenow', '0')
342
+ .children().first().css('width', '0%');
343
+ $(this).find('.progress-extended').html('&nbsp;');
344
+ deferred.resolve();
345
+ }
346
+ );
347
+ },
348
+ processstart: function (e) {
349
+ if (e.isDefaultPrevented()) {
350
+ return false;
351
+ }
352
+ $(this).addClass('fileupload-processing');
353
+ },
354
+ processstop: function (e) {
355
+ if (e.isDefaultPrevented()) {
356
+ return false;
357
+ }
358
+ $(this).removeClass('fileupload-processing');
359
+ },
360
+ // Callback for file deletion:
361
+ destroy: function (e, data) {
362
+ if (e.isDefaultPrevented()) {
363
+ return false;
364
+ }
365
+ var that = $(this).data('blueimp-fileupload') ||
366
+ $(this).data('fileupload'),
367
+ removeNode = function () {
368
+ that._transition(data.context).done(
369
+ function () {
370
+ $(this).remove();
371
+ that._trigger('destroyed', e, data);
372
+ }
373
+ );
374
+ };
375
+ if (data.url) {
376
+ data.dataType = data.dataType || that.options.dataType;
377
+ $.ajax(data).done(removeNode).fail(function () {
378
+ that._trigger('destroyfailed', e, data);
379
+ });
380
+ } else {
381
+ removeNode();
382
+ }
383
+ }
384
+ },
385
+
386
+ _resetFinishedDeferreds: function () {
387
+ this._finishedUploads = [];
388
+ },
389
+
390
+ _addFinishedDeferreds: function (deferred) {
391
+ if (!deferred) {
392
+ deferred = $.Deferred();
393
+ }
394
+ this._finishedUploads.push(deferred);
395
+ return deferred;
396
+ },
397
+
398
+ _getFinishedDeferreds: function () {
399
+ return this._finishedUploads;
400
+ },
401
+
402
+ // Link handler, that allows to download files
403
+ // by drag & drop of the links to the desktop:
404
+ _enableDragToDesktop: function () {
405
+ var link = $(this),
406
+ url = link.prop('href'),
407
+ name = link.prop('download'),
408
+ type = 'application/octet-stream';
409
+ link.bind('dragstart', function (e) {
410
+ try {
411
+ e.originalEvent.dataTransfer.setData(
412
+ 'DownloadURL',
413
+ [type, name, url].join(':')
414
+ );
415
+ } catch (ignore) {}
416
+ });
417
+ },
418
+
419
+ _formatFileSize: function (bytes) {
420
+ if (typeof bytes !== 'number') {
421
+ return '';
422
+ }
423
+ if (bytes >= 1000000000) {
424
+ return (bytes / 1000000000).toFixed(2) + ' GB';
425
+ }
426
+ if (bytes >= 1000000) {
427
+ return (bytes / 1000000).toFixed(2) + ' MB';
428
+ }
429
+ return (bytes / 1000).toFixed(2) + ' KB';
430
+ },
431
+
432
+ _formatBitrate: function (bits) {
433
+ if (typeof bits !== 'number') {
434
+ return '';
435
+ }
436
+ if (bits >= 1000000000) {
437
+ return (bits / 1000000000).toFixed(2) + ' Gbit/s';
438
+ }
439
+ if (bits >= 1000000) {
440
+ return (bits / 1000000).toFixed(2) + ' Mbit/s';
441
+ }
442
+ if (bits >= 1000) {
443
+ return (bits / 1000).toFixed(2) + ' kbit/s';
444
+ }
445
+ return bits.toFixed(2) + ' bit/s';
446
+ },
447
+
448
+ _formatTime: function (seconds) {
449
+ var date = new Date(seconds * 1000),
450
+ days = Math.floor(seconds / 86400);
451
+ days = days ? days + 'd ' : '';
452
+ return days +
453
+ ('0' + date.getUTCHours()).slice(-2) + ':' +
454
+ ('0' + date.getUTCMinutes()).slice(-2) + ':' +
455
+ ('0' + date.getUTCSeconds()).slice(-2);
456
+ },
457
+
458
+ _formatPercentage: function (floatValue) {
459
+ return (floatValue * 100).toFixed(2) + ' %';
460
+ },
461
+
462
+ _renderExtendedProgress: function (data) {
463
+ return this._formatBitrate(data.bitrate) + ' | ' +
464
+ this._formatTime(
465
+ (data.total - data.loaded) * 8 / data.bitrate
466
+ ) + ' | ' +
467
+ this._formatPercentage(
468
+ data.loaded / data.total
469
+ ) + ' | ' +
470
+ this._formatFileSize(data.loaded) + ' / ' +
471
+ this._formatFileSize(data.total);
472
+ },
473
+
474
+ _renderTemplate: function (func, files) {
475
+ if (!func) {
476
+ return $();
477
+ }
478
+ var result = func({
479
+ files: files,
480
+ formatFileSize: this._formatFileSize,
481
+ options: this.options
482
+ });
483
+ if (result instanceof $) {
484
+ return result;
485
+ }
486
+ return $(this.options.templatesContainer).html(result).children();
487
+ },
488
+
489
+ _renderPreviews: function (data) {
490
+ data.context.find('.preview').each(function (index, elm) {
491
+ $(elm).append(data.files[index].preview);
492
+ });
493
+ },
494
+
495
+ _renderUpload: function (files) {
496
+ return this._renderTemplate(
497
+ this.options.uploadTemplate,
498
+ files
499
+ );
500
+ },
501
+
502
+ _renderDownload: function (files) {
503
+ return this._renderTemplate(
504
+ this.options.downloadTemplate,
505
+ files
506
+ ).find('a[download]').each(this._enableDragToDesktop).end();
507
+ },
508
+
509
+ _startHandler: function (e) {
510
+ e.preventDefault();
511
+ var button = $(e.currentTarget),
512
+ template = button.closest('.template-upload'),
513
+ data = template.data('data');
514
+ button.prop('disabled', true);
515
+ if (data && data.submit) {
516
+ data.submit();
517
+ }
518
+ },
519
+
520
+ _cancelHandler: function (e) {
521
+ e.preventDefault();
522
+ var template = $(e.currentTarget)
523
+ .closest('.template-upload,.template-download'),
524
+ data = template.data('data') || {};
525
+ data.context = data.context || template;
526
+ if (data.abort) {
527
+ data.abort();
528
+ } else {
529
+ data.errorThrown = 'abort';
530
+ this._trigger('fail', e, data);
531
+ }
532
+ },
533
+
534
+ _deleteHandler: function (e) {
535
+ e.preventDefault();
536
+ var button = $(e.currentTarget);
537
+ this._trigger('destroy', e, $.extend({
538
+ context: button.closest('.template-download'),
539
+ type: 'DELETE'
540
+ }, button.data()));
541
+ },
542
+
543
+ _forceReflow: function (node) {
544
+ return $.support.transition && node.length &&
545
+ node[0].offsetWidth;
546
+ },
547
+
548
+ _transition: function (node) {
549
+ var dfd = $.Deferred();
550
+ if ($.support.transition && node.hasClass('jqhfu-fade') && node.is(':visible')) {
551
+ node.bind(
552
+ $.support.transition.end,
553
+ function (e) {
554
+ // Make sure we don't respond to other transitions events
555
+ // in the container element, e.g. from button elements:
556
+ if (e.target === node[0]) {
557
+ node.unbind($.support.transition.end);
558
+ dfd.resolveWith(node);
559
+ }
560
+ }
561
+ ).toggleClass('in');
562
+ } else {
563
+ node.toggleClass('in');
564
+ dfd.resolveWith(node);
565
+ }
566
+ return dfd;
567
+ },
568
+
569
+ _initButtonBarEventHandlers: function () {
570
+ var fileUploadButtonBar = this.element.find('.fileupload-buttonbar'),
571
+ filesList = this.options.filesContainer;
572
+ this._on(fileUploadButtonBar.find('.start'), {
573
+ click: function (e) {
574
+ e.preventDefault();
575
+ filesList.find('.start').click();
576
+ }
577
+ });
578
+ this._on(fileUploadButtonBar.find('.cancel'), {
579
+ click: function (e) {
580
+ e.preventDefault();
581
+ filesList.find('.cancel').click();
582
+ }
583
+ });
584
+ this._on(fileUploadButtonBar.find('.delete'), {
585
+ click: function (e) {
586
+ e.preventDefault();
587
+ filesList.find('.toggle:checked')
588
+ .closest('.template-download')
589
+ .find('.delete').click();
590
+ fileUploadButtonBar.find('.toggle')
591
+ .prop('checked', false);
592
+ }
593
+ });
594
+ this._on(fileUploadButtonBar.find('.toggle'), {
595
+ change: function (e) {
596
+ filesList.find('.toggle').prop(
597
+ 'checked',
598
+ $(e.currentTarget).is(':checked')
599
+ );
600
+ }
601
+ });
602
+ },
603
+
604
+ _destroyButtonBarEventHandlers: function () {
605
+ this._off(
606
+ this.element.find('.fileupload-buttonbar')
607
+ .find('.start, .cancel, .delete'),
608
+ 'click'
609
+ );
610
+ this._off(
611
+ this.element.find('.fileupload-buttonbar .toggle'),
612
+ 'change.'
613
+ );
614
+ },
615
+
616
+ _initEventHandlers: function () {
617
+ this._super();
618
+ this._on(this.options.filesContainer, {
619
+ 'click .start': this._startHandler,
620
+ 'click .cancel': this._cancelHandler,
621
+ 'click .delete': this._deleteHandler
622
+ });
623
+ this._initButtonBarEventHandlers();
624
+ },
625
+
626
+ _destroyEventHandlers: function () {
627
+ this._destroyButtonBarEventHandlers();
628
+ this._off(this.options.filesContainer, 'click');
629
+ this._super();
630
+ },
631
+
632
+ _enableFileInputButton: function () {
633
+ this.element.find('.fileinput-button input')
634
+ .prop('disabled', false)
635
+ .parent().removeClass('disabled');
636
+ },
637
+
638
+ _disableFileInputButton: function () {
639
+ this.element.find('.fileinput-button input')
640
+ .prop('disabled', true)
641
+ .parent().addClass('disabled');
642
+ },
643
+
644
+ _initTemplates: function () {
645
+ var options = this.options;
646
+ options.templatesContainer = this.document[0].createElement(
647
+ options.filesContainer.prop('nodeName')
648
+ );
649
+ if (tmpl) {
650
+ if (options.uploadTemplateId) {
651
+ options.uploadTemplate = tmpl(options.uploadTemplateId);
652
+ }
653
+ if (options.downloadTemplateId) {
654
+ options.downloadTemplate = tmpl(options.downloadTemplateId);
655
+ }
656
+ }
657
+ },
658
+
659
+ _initFilesContainer: function () {
660
+ var options = this.options;
661
+ if (options.filesContainer === undefined) {
662
+ options.filesContainer = this.element.find('.files');
663
+ } else if (!(options.filesContainer instanceof $)) {
664
+ options.filesContainer = $(options.filesContainer);
665
+ }
666
+ },
667
+
668
+ _initSpecialOptions: function () {
669
+ this._super();
670
+ this._initFilesContainer();
671
+ this._initTemplates();
672
+ },
673
+
674
+ _create: function () {
675
+ this._super();
676
+ this._resetFinishedDeferreds();
677
+ if (!$.support.fileInput) {
678
+ this._disableFileInputButton();
679
+ }
680
+ },
681
+
682
+ enable: function () {
683
+ var wasDisabled = false;
684
+ if (this.options.disabled) {
685
+ wasDisabled = true;
686
+ }
687
+ this._super();
688
+ if (wasDisabled) {
689
+ this.element.find('input, button').prop('disabled', false);
690
+ this._enableFileInputButton();
691
+ }
692
+ },
693
+
694
+ disable: function () {
695
+ if (!this.options.disabled) {
696
+ this.element.find('input, button').prop('disabled', true);
697
+ this._disableFileInputButton();
698
+ }
699
+ this._super();
700
+ }
701
+
702
+ });
703
+
704
+ }));
embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-validate.js ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery File Upload Validation Plugin 1.1.2
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2013, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /* global define, window */
13
+
14
+ (function (factory) {
15
+ 'use strict';
16
+ if (typeof define === 'function' && define.amd) {
17
+ // Register as an anonymous AMD module:
18
+ define([
19
+ 'jquery',
20
+ './jquery.fileupload-process'
21
+ ], factory);
22
+ } else {
23
+ // Browser globals:
24
+ factory(
25
+ window.jQuery
26
+ );
27
+ }
28
+ }(function ($) {
29
+ 'use strict';
30
+
31
+ // Append to the default processQueue:
32
+ $.blueimp.fileupload.prototype.options.processQueue.push(
33
+ {
34
+ action: 'validate',
35
+ // Always trigger this action,
36
+ // even if the previous action was rejected:
37
+ always: true,
38
+ // Options taken from the global options map:
39
+ acceptFileTypes: '@',
40
+ maxFileSize: '@',
41
+ minFileSize: '@',
42
+ maxNumberOfFiles: '@',
43
+ disabled: '@disableValidation'
44
+ }
45
+ );
46
+
47
+ // The File Upload Validation plugin extends the fileupload widget
48
+ // with file validation functionality:
49
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
50
+
51
+ options: {
52
+ /*
53
+ // The regular expression for allowed file types, matches
54
+ // against either file type or file name:
55
+ acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
56
+ // The maximum allowed file size in bytes:
57
+ maxFileSize: 10000000, // 10 MB
58
+ // The minimum allowed file size in bytes:
59
+ minFileSize: undefined, // No minimal file size
60
+ // The limit of files to be uploaded:
61
+ maxNumberOfFiles: 10,
62
+ */
63
+
64
+ // Function returning the current number of files,
65
+ // has to be overriden for maxNumberOfFiles validation:
66
+ getNumberOfFiles: $.noop,
67
+
68
+ // Error and info messages:
69
+ messages: {
70
+ maxNumberOfFiles: 'Maximum number of files exceeded',
71
+ acceptFileTypes: 'File type not allowed',
72
+ maxFileSize: 'File is too large',
73
+ minFileSize: 'File is too small'
74
+ }
75
+ },
76
+
77
+ processActions: {
78
+
79
+ validate: function (data, options) {
80
+ if (options.disabled) {
81
+ return data;
82
+ }
83
+ var dfd = $.Deferred(),
84
+ settings = this.options,
85
+ file = data.files[data.index],
86
+ fileSize;
87
+ if (options.minFileSize || options.maxFileSize) {
88
+ fileSize = file.size;
89
+ }
90
+ if ($.type(options.maxNumberOfFiles) === 'number' &&
91
+ (settings.getNumberOfFiles() || 0) + data.files.length >
92
+ options.maxNumberOfFiles) {
93
+ file.error = settings.i18n('maxNumberOfFiles');
94
+ } else if (options.acceptFileTypes &&
95
+ !(options.acceptFileTypes.test(file.type) ||
96
+ options.acceptFileTypes.test(file.name))) {
97
+ file.error = settings.i18n('acceptFileTypes');
98
+ } else if (fileSize > options.maxFileSize) {
99
+ file.error = settings.i18n('maxFileSize');
100
+ } else if ($.type(fileSize) === 'number' &&
101
+ fileSize < options.minFileSize) {
102
+ file.error = settings.i18n('minFileSize');
103
+ } else {
104
+ delete file.error;
105
+ }
106
+ if (file.error || data.files.error) {
107
+ data.files.error = true;
108
+ dfd.rejectWith(this, [data]);
109
+ } else {
110
+ dfd.resolveWith(this, [data]);
111
+ }
112
+ return dfd.promise();
113
+ }
114
+
115
+ }
116
+
117
+ });
118
+
119
+ }));
embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload-video.js ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery File Upload Video Preview Plugin 1.0.3
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2013, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /* jshint nomen:false */
13
+ /* global define, window, document */
14
+
15
+ (function (factory) {
16
+ 'use strict';
17
+ if (typeof define === 'function' && define.amd) {
18
+ // Register as an anonymous AMD module:
19
+ define([
20
+ 'jquery',
21
+ 'load-image',
22
+ './jquery.fileupload-process'
23
+ ], factory);
24
+ } else {
25
+ // Browser globals:
26
+ factory(
27
+ window.jQuery,
28
+ window.loadImage
29
+ );
30
+ }
31
+ }(function ($, loadImage) {
32
+ 'use strict';
33
+
34
+ // Prepend to the default processQueue:
35
+ $.blueimp.fileupload.prototype.options.processQueue.unshift(
36
+ {
37
+ action: 'loadVideo',
38
+ // Use the action as prefix for the "@" options:
39
+ prefix: true,
40
+ fileTypes: '@',
41
+ maxFileSize: '@',
42
+ disabled: '@disableVideoPreview'
43
+ },
44
+ {
45
+ action: 'setVideo',
46
+ name: '@videoPreviewName',
47
+ disabled: '@disableVideoPreview'
48
+ }
49
+ );
50
+
51
+ // The File Upload Video Preview plugin extends the fileupload widget
52
+ // with video preview functionality:
53
+ $.widget('blueimp.fileupload', $.blueimp.fileupload, {
54
+
55
+ options: {
56
+ // The regular expression for the types of video files to load,
57
+ // matched against the file type:
58
+ loadVideoFileTypes: /^video\/.*$/
59
+ },
60
+
61
+ _videoElement: document.createElement('video'),
62
+
63
+ processActions: {
64
+
65
+ // Loads the video file given via data.files and data.index
66
+ // as video element if the browser supports playing it.
67
+ // Accepts the options fileTypes (regular expression)
68
+ // and maxFileSize (integer) to limit the files to load:
69
+ loadVideo: function (data, options) {
70
+ if (options.disabled) {
71
+ return data;
72
+ }
73
+ var file = data.files[data.index],
74
+ url,
75
+ video;
76
+ if (this._videoElement.canPlayType &&
77
+ this._videoElement.canPlayType(file.type) &&
78
+ ($.type(options.maxFileSize) !== 'number' ||
79
+ file.size <= options.maxFileSize) &&
80
+ (!options.fileTypes ||
81
+ options.fileTypes.test(file.type))) {
82
+ url = loadImage.createObjectURL(file);
83
+ if (url) {
84
+ video = this._videoElement.cloneNode(false);
85
+ video.src = url;
86
+ video.controls = true;
87
+ data.video = video;
88
+ return data;
89
+ }
90
+ }
91
+ return data;
92
+ },
93
+
94
+ // Sets the video element as a property of the file object:
95
+ setVideo: function (data, options) {
96
+ if (data.video && !options.disabled) {
97
+ data.files[data.index][options.name || 'preview'] = data.video;
98
+ }
99
+ return data;
100
+ }
101
+
102
+ }
103
+
104
+ });
105
+
106
+ }));
embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload.css ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .jqhfu-button {
2
+ background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf));
3
+ background:-moz-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
4
+ background:-webkit-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
5
+ background:-o-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
6
+ background:-ms-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
7
+ background:linear-gradient(to bottom, #ededed 5%, #dfdfdf 100%);
8
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf',GradientType=0);
9
+ background-color:#ededed;
10
+ -moz-border-radius:6px;
11
+ -webkit-border-radius:6px;
12
+ border-radius:6px;
13
+ border:1px solid #dcdcdc;
14
+ display:inline-block;
15
+ cursor:pointer;
16
+ color:#777777;
17
+ font-family:Verdana;
18
+ font-size:12px;
19
+ font-weight:bold;
20
+ padding:7px 10px;
21
+ text-decoration:none;
22
+ }
23
+ .jqhfu-button:focus,
24
+ .jqhfu-button:hover {
25
+ background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #dfdfdf), color-stop(1, #ededed));
26
+ background:-moz-linear-gradient(top, #dfdfdf 5%, #ededed 100%);
27
+ background:-webkit-linear-gradient(top, #dfdfdf 5%, #ededed 100%);
28
+ background:-o-linear-gradient(top, #dfdfdf 5%, #ededed 100%);
29
+ background:-ms-linear-gradient(top, #dfdfdf 5%, #ededed 100%);
30
+ background:linear-gradient(to bottom, #dfdfdf 5%, #ededed 100%);
31
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#dfdfdf', endColorstr='#ededed',GradientType=0);
32
+ background-color:#dfdfdf;
33
+ color:#555555;
34
+ padding:7px 10px;
35
+ border:1px solid #dcdcdc;
36
+ }
37
+ .jqhfu-button:active {
38
+ background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf));
39
+ background:-moz-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
40
+ background:-webkit-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
41
+ background:-o-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
42
+ background:-ms-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
43
+ background:linear-gradient(to bottom, #ededed 5%, #dfdfdf 100%);
44
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf',GradientType=0);
45
+ background-color:#ededed;
46
+ -moz-border-radius:6px;
47
+ -webkit-border-radius:6px;
48
+ border-radius:6px;
49
+ position:relative;
50
+ top:1px;
51
+ color:#555555;
52
+ padding:7px 10px;
53
+ border:1px solid #dcdcdc;
54
+ }
55
+ .jqhfu-button input[type="file"] {
56
+ cursor: inherit;
57
+ display: block;
58
+ filter: alpha(opacity=0);
59
+ min-height: 100%;
60
+ min-width: 100%;
61
+ opacity: 0;
62
+ width:100px;
63
+ height:32px;
64
+ }
65
+
66
+ .jqhfu-file-container {
67
+ overflow: hidden;
68
+ position: relative;
69
+ }
70
+
71
+ .jqhfu-file-container [type=file] {
72
+ cursor: inherit;
73
+ display: block;
74
+ font-size: 999px;
75
+ filter: alpha(opacity=0);
76
+ min-height: 100%;
77
+ min-width: 100%;
78
+ opacity: 0;
79
+ position: absolute;
80
+ right: 0;
81
+ text-align: right;
82
+ top: 0;
83
+ width:100px;
84
+ height:30px;
85
+
86
+ }
87
+
88
+ /* Example stylistic flourishes */
89
+
90
+ .jqhfu-file-container {
91
+ float: left;
92
+ background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf));
93
+ background:-moz-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
94
+ background:-webkit-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
95
+ background:-o-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
96
+ background:-ms-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
97
+ background:linear-gradient(to bottom, #ededed 5%, #dfdfdf 100%);
98
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf',GradientType=0);
99
+ background-color:#ededed;
100
+ -moz-border-radius:6px;
101
+ -webkit-border-radius:6px;
102
+ border-radius:6px;
103
+ border:1px solid #dcdcdc;
104
+ cursor:pointer;
105
+ color:#777777;
106
+ font-family:Verdana;
107
+ font-size:12px;
108
+ font-weight:bold;
109
+ padding:7px 10px;
110
+ text-decoration:none;
111
+ margin:1px 3px 0 0;
112
+ line-height: normal;
113
+ }
114
+ .jqhfu-file-container:focus,
115
+ .jqhfu-file-container:hover {
116
+ background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #dfdfdf), color-stop(1, #ededed));
117
+ background:-moz-linear-gradient(top, #dfdfdf 5%, #ededed 100%);
118
+ background:-webkit-linear-gradient(top, #dfdfdf 5%, #ededed 100%);
119
+ background:-o-linear-gradient(top, #dfdfdf 5%, #ededed 100%);
120
+ background:-ms-linear-gradient(top, #dfdfdf 5%, #ededed 100%);
121
+ background:linear-gradient(to bottom, #dfdfdf 5%, #ededed 100%);
122
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#dfdfdf', endColorstr='#ededed',GradientType=0);
123
+ background-color:#dfdfdf;
124
+ color:#555555;
125
+ padding:7px 10px;
126
+ border:1px solid #dcdcdc;
127
+ }
128
+ .jqhfu-file-container:active {
129
+ background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf));
130
+ background:-moz-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
131
+ background:-webkit-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
132
+ background:-o-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
133
+ background:-ms-linear-gradient(top, #ededed 5%, #dfdfdf 100%);
134
+ background:linear-gradient(to bottom, #ededed 5%, #dfdfdf 100%);
135
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf',GradientType=0);
136
+ background-color:#ededed;
137
+ -moz-border-radius:6px;
138
+ -webkit-border-radius:6px;
139
+ border-radius:6px;
140
+ position:relative;
141
+ top:1px;
142
+ color:#555555;
143
+ padding:7px 10px;
144
+ border:1px solid #dcdcdc;
145
+ }
146
+
147
+ .jqhfu-file-container [type=file] {
148
+ cursor: pointer;
149
+ }
150
+
151
+ .jqhfu-upload-download-table {
152
+ max-width:500px;
153
+ padding:2px 0;
154
+ margin-top:5px;
155
+ }
156
+
157
+ .jqhfu-upload-download-table table {
158
+ border-collapse:collapse;
159
+ border-spacing:0;
160
+ margin:0;
161
+ padding:0;
162
+ width:100%;
163
+ border-width:0 0 0 0;
164
+ }
165
+
166
+ .jqhfu-upload-download-table td {
167
+ border:1px solid #ddd;
168
+ border-width:1px 0 0 0;
169
+ color:#000;
170
+ font-family:Arial;
171
+ font-size:10px;
172
+ font-weight:400;
173
+ padding:7px;
174
+ text-align:left;
175
+ vertical-align:middle;
176
+ }
177
+
178
+ .jqhfu-upload-download-table tr:nth-child(even) {
179
+ background-color:#fff;
180
+ }
181
+
182
+ .jqhfu-upload-download-table tr:nth-child(odd) {
183
+ background-color:#f9f9f9;
184
+ }
185
+
186
+ .progress-animated .progress-bar,.progress-animated .bar {
187
+ background:url(../img/progressbar.gif)!important;
188
+ filter:none;
189
+ }
190
+
191
+ .ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl {
192
+ -khtml-border-bottom-left-radius:6px;
193
+ -moz-border-radius-bottomleft:6px;
194
+ -webkit-border-bottom-left-radius:6px;
195
+ border-bottom-left-radius:6px;
196
+ }
197
+
198
+ .ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br {
199
+ -khtml-border-bottom-right-radius:6px;
200
+ -moz-border-radius-bottomright:6px;
201
+ -webkit-border-bottom-right-radius:6px;
202
+ border-bottom-right-radius:6px;
203
+ }
204
+
205
+ .ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl {
206
+ -khtml-border-top-left-radius:6px;
207
+ -moz-border-radius-topleft:6px;
208
+ -webkit-border-top-left-radius:6px;
209
+ border-top-left-radius:6px;
210
+ }
211
+
212
+ .ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr {
213
+ -khtml-border-top-right-radius:6px;
214
+ -moz-border-radius-topright:6px;
215
+ -webkit-border-top-right-radius:6px;
216
+ border-top-right-radius:6px;
217
+ }
218
+
219
+ .ui-progressbar {
220
+ height:18px;
221
+ overflow:hidden;
222
+ text-align:left;
223
+ }
224
+
225
+ .ui-progressbar .ui-progressbar-value {
226
+ height:100%;
227
+ margin:-1px;
228
+ background: url(../img/progressbar.gif);
229
+ }
230
+
231
+ .ui-widget-content {
232
+ background:url(../img/progressbar.gif) repeat scroll 50% 50% #000;
233
+ border:1px solid #555;
234
+ }
235
+
236
+ .fileupload-buttonbar .ui-progressbar-value {
237
+ background: url(../img/progressbar.gif);
238
+ }
239
+
240
+ @media only screen and (max-width: 480px) {
241
+ .jqhfu-upload-download-table td {
242
+ padding:1px;
243
+ }
244
+ .jqhfu-upload-download-table .name {
245
+ width:50px;
246
+ }
247
+ }
embedded/common/toolset-forms/js/jquery_upload/jquery.fileupload.js ADDED
@@ -0,0 +1,1468 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery File Upload Plugin 5.42.3
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2010, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /* jshint nomen:false */
13
+ /* global define, require, window, document, location, Blob, FormData */
14
+
15
+ (function (factory) {
16
+ 'use strict';
17
+ if (typeof define === 'function' && define.amd) {
18
+ // Register as an anonymous AMD module:
19
+ define([
20
+ 'jquery',
21
+ 'jquery.ui.widget'
22
+ ], factory);
23
+ } else if (typeof exports === 'object') {
24
+ // Node/CommonJS:
25
+ factory(
26
+ require('jquery'),
27
+ require('./vendor/jquery.ui.widget')
28
+ );
29
+ } else {
30
+ // Browser globals:
31
+ factory(window.jQuery);
32
+ }
33
+ }(function ($) {
34
+ 'use strict';
35
+
36
+ // Detect file input support, based on
37
+ // http://viljamis.com/blog/2012/file-upload-support-on-mobile/
38
+ $.support.fileInput = !(new RegExp(
39
+ // Handle devices which give false positives for the feature detection:
40
+ '(Android (1\\.[0156]|2\\.[01]))' +
41
+ '|(Windows Phone (OS 7|8\\.0))|(XBLWP)|(ZuneWP)|(WPDesktop)' +
42
+ '|(w(eb)?OSBrowser)|(webOS)' +
43
+ '|(Kindle/(1\\.0|2\\.[05]|3\\.0))'
44
+ ).test(window.navigator.userAgent) ||
45
+ // Feature detection for all other devices:
46
+ $('<input type="file">').prop('disabled'));
47
+
48
+ // The FileReader API is not actually used, but works as feature detection,
49
+ // as some Safari versions (5?) support XHR file uploads via the FormData API,
50
+ // but not non-multipart XHR file uploads.
51
+ // window.XMLHttpRequestUpload is not available on IE10, so we check for
52
+ // window.ProgressEvent instead to detect XHR2 file upload capability:
53
+ $.support.xhrFileUpload = !!(window.ProgressEvent && window.FileReader);
54
+ $.support.xhrFormDataFileUpload = !!window.FormData;
55
+
56
+ // Detect support for Blob slicing (required for chunked uploads):
57
+ $.support.blobSlice = window.Blob && (Blob.prototype.slice ||
58
+ Blob.prototype.webkitSlice || Blob.prototype.mozSlice);
59
+
60
+ // Helper function to create drag handlers for dragover/dragenter/dragleave:
61
+ function getDragHandler(type) {
62
+ var isDragOver = type === 'dragover';
63
+ return function (e) {
64
+ e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer;
65
+ var dataTransfer = e.dataTransfer;
66
+ if (dataTransfer && $.inArray('Files', dataTransfer.types) !== -1 &&
67
+ this._trigger(
68
+ type,
69
+ $.Event(type, {delegatedEvent: e})
70
+ ) !== false) {
71
+ e.preventDefault();
72
+ if (isDragOver) {
73
+ dataTransfer.dropEffect = 'copy';
74
+ }
75
+ }
76
+ };
77
+ }
78
+
79
+ // The fileupload widget listens for change events on file input fields defined
80
+ // via fileInput setting and paste or drop events of the given dropZone.
81
+ // In addition to the default jQuery Widget methods, the fileupload widget
82
+ // exposes the "add" and "send" methods, to add or directly send files using
83
+ // the fileupload API.
84
+ // By default, files added via file input selection, paste, drag & drop or
85
+ // "add" method are uploaded immediately, but it is possible to override
86
+ // the "add" callback option to queue file uploads.
87
+ $.widget('blueimp.fileupload', {
88
+
89
+ options: {
90
+ // The drop target element(s), by the default the complete document.
91
+ // Set to null to disable drag & drop support:
92
+ dropZone: $(document),
93
+ // The paste target element(s), by the default undefined.
94
+ // Set to a DOM node or jQuery object to enable file pasting:
95
+ pasteZone: undefined,
96
+ // The file input field(s), that are listened to for change events.
97
+ // If undefined, it is set to the file input fields inside
98
+ // of the widget element on plugin initialization.
99
+ // Set to null to disable the change listener.
100
+ fileInput: undefined,
101
+ // By default, the file input field is replaced with a clone after
102
+ // each input field change event. This is required for iframe transport
103
+ // queues and allows change events to be fired for the same file
104
+ // selection, but can be disabled by setting the following option to false:
105
+ replaceFileInput: true,
106
+ // The parameter name for the file form data (the request argument name).
107
+ // If undefined or empty, the name property of the file input field is
108
+ // used, or "files[]" if the file input name property is also empty,
109
+ // can be a string or an array of strings:
110
+ paramName: undefined,
111
+ // By default, each file of a selection is uploaded using an individual
112
+ // request for XHR type uploads. Set to false to upload file
113
+ // selections in one request each:
114
+ singleFileUploads: true,
115
+ // To limit the number of files uploaded with one XHR request,
116
+ // set the following option to an integer greater than 0:
117
+ limitMultiFileUploads: undefined,
118
+ // The following option limits the number of files uploaded with one
119
+ // XHR request to keep the request size under or equal to the defined
120
+ // limit in bytes:
121
+ limitMultiFileUploadSize: undefined,
122
+ // Multipart file uploads add a number of bytes to each uploaded file,
123
+ // therefore the following option adds an overhead for each file used
124
+ // in the limitMultiFileUploadSize configuration:
125
+ limitMultiFileUploadSizeOverhead: 512,
126
+ // Set the following option to true to issue all file upload requests
127
+ // in a sequential order:
128
+ sequentialUploads: false,
129
+ // To limit the number of concurrent uploads,
130
+ // set the following option to an integer greater than 0:
131
+ limitConcurrentUploads: undefined,
132
+ // Set the following option to true to force iframe transport uploads:
133
+ forceIframeTransport: false,
134
+ // Set the following option to the location of a redirect url on the
135
+ // origin server, for cross-domain iframe transport uploads:
136
+ redirect: undefined,
137
+ // The parameter name for the redirect url, sent as part of the form
138
+ // data and set to 'redirect' if this option is empty:
139
+ redirectParamName: undefined,
140
+ // Set the following option to the location of a postMessage window,
141
+ // to enable postMessage transport uploads:
142
+ postMessage: undefined,
143
+ // By default, XHR file uploads are sent as multipart/form-data.
144
+ // The iframe transport is always using multipart/form-data.
145
+ // Set to false to enable non-multipart XHR uploads:
146
+ multipart: true,
147
+ // To upload large files in smaller chunks, set the following option
148
+ // to a preferred maximum chunk size. If set to 0, null or undefined,
149
+ // or the browser does not support the required Blob API, files will
150
+ // be uploaded as a whole.
151
+ maxChunkSize: undefined,
152
+ // When a non-multipart upload or a chunked multipart upload has been
153
+ // aborted, this option can be used to resume the upload by setting
154
+ // it to the size of the already uploaded bytes. This option is most
155
+ // useful when modifying the options object inside of the "add" or
156
+ // "send" callbacks, as the options are cloned for each file upload.
157
+ uploadedBytes: undefined,
158
+ // By default, failed (abort or error) file uploads are removed from the
159
+ // global progress calculation. Set the following option to false to
160
+ // prevent recalculating the global progress data:
161
+ recalculateProgress: true,
162
+ // Interval in milliseconds to calculate and trigger progress events:
163
+ progressInterval: 100,
164
+ // Interval in milliseconds to calculate progress bitrate:
165
+ bitrateInterval: 500,
166
+ // By default, uploads are started automatically when adding files:
167
+ autoUpload: true,
168
+
169
+ // Error and info messages:
170
+ messages: {
171
+ uploadedBytes: 'Uploaded bytes exceed file size'
172
+ },
173
+
174
+ // Translation function, gets the message key to be translated
175
+ // and an object with context specific data as arguments:
176
+ i18n: function (message, context) {
177
+ message = this.messages[message] || message.toString();
178
+ if (context) {
179
+ $.each(context, function (key, value) {
180
+ message = message.replace('{' + key + '}', value);
181
+ });
182
+ }
183
+ return message;
184
+ },
185
+
186
+ // Additional form data to be sent along with the file uploads can be set
187
+ // using this option, which accepts an array of objects with name and
188
+ // value properties, a function returning such an array, a FormData
189
+ // object (for XHR file uploads), or a simple object.
190
+ // The form of the first fileInput is given as parameter to the function:
191
+ formData: function (form) {
192
+ return form.serializeArray();
193
+ },
194
+
195
+ // The add callback is invoked as soon as files are added to the fileupload
196
+ // widget (via file input selection, drag & drop, paste or add API call).
197
+ // If the singleFileUploads option is enabled, this callback will be
198
+ // called once for each file in the selection for XHR file uploads, else
199
+ // once for each file selection.
200
+ //
201
+ // The upload starts when the submit method is invoked on the data parameter.
202
+ // The data object contains a files property holding the added files
203
+ // and allows you to override plugin options as well as define ajax settings.
204
+ //
205
+ // Listeners for this callback can also be bound the following way:
206
+ // .bind('fileuploadadd', func);
207
+ //
208
+ // data.submit() returns a Promise object and allows to attach additional
209
+ // handlers using jQuery's Deferred callbacks:
210
+ // data.submit().done(func).fail(func).always(func);
211
+ add: function (e, data) {
212
+ if (e.isDefaultPrevented()) {
213
+ return false;
214
+ }
215
+ if (data.autoUpload || (data.autoUpload !== false &&
216
+ $(this).fileupload('option', 'autoUpload'))) {
217
+ data.process().done(function () {
218
+ data.submit();
219
+ });
220
+ }
221
+ },
222
+
223
+ // Other callbacks:
224
+
225
+ // Callback for the submit event of each file upload:
226
+ // submit: function (e, data) {}, // .bind('fileuploadsubmit', func);
227
+
228
+ // Callback for the start of each file upload request:
229
+ // send: function (e, data) {}, // .bind('fileuploadsend', func);
230
+
231
+ // Callback for successful uploads:
232
+ // done: function (e, data) {}, // .bind('fileuploaddone', func);
233
+
234
+ // Callback for failed (abort or error) uploads:
235
+ // fail: function (e, data) {}, // .bind('fileuploadfail', func);
236
+
237
+ // Callback for completed (success, abort or error) requests:
238
+ // always: function (e, data) {}, // .bind('fileuploadalways', func);
239
+
240
+ // Callback for upload progress events:
241
+ // progress: function (e, data) {}, // .bind('fileuploadprogress', func);
242
+
243
+ // Callback for global upload progress events:
244
+ // progressall: function (e, data) {}, // .bind('fileuploadprogressall', func);
245
+
246
+ // Callback for uploads start, equivalent to the global ajaxStart event:
247
+ // start: function (e) {}, // .bind('fileuploadstart', func);
248
+
249
+ // Callback for uploads stop, equivalent to the global ajaxStop event:
250
+ // stop: function (e) {}, // .bind('fileuploadstop', func);
251
+
252
+ // Callback for change events of the fileInput(s):
253
+ // change: function (e, data) {}, // .bind('fileuploadchange', func);
254
+
255
+ // Callback for paste events to the pasteZone(s):
256
+ // paste: function (e, data) {}, // .bind('fileuploadpaste', func);
257
+
258
+ // Callback for drop events of the dropZone(s):
259
+ // drop: function (e, data) {}, // .bind('fileuploaddrop', func);
260
+
261
+ // Callback for dragover events of the dropZone(s):
262
+ // dragover: function (e) {}, // .bind('fileuploaddragover', func);
263
+
264
+ // Callback for the start of each chunk upload request:
265
+ // chunksend: function (e, data) {}, // .bind('fileuploadchunksend', func);
266
+
267
+ // Callback for successful chunk uploads:
268
+ // chunkdone: function (e, data) {}, // .bind('fileuploadchunkdone', func);
269
+
270
+ // Callback for failed (abort or error) chunk uploads:
271
+ // chunkfail: function (e, data) {}, // .bind('fileuploadchunkfail', func);
272
+
273
+ // Callback for completed (success, abort or error) chunk upload requests:
274
+ // chunkalways: function (e, data) {}, // .bind('fileuploadchunkalways', func);
275
+
276
+ // The plugin options are used as settings object for the ajax calls.
277
+ // The following are jQuery ajax settings required for the file uploads:
278
+ processData: false,
279
+ contentType: false,
280
+ cache: false,
281
+ timeout: 0
282
+ },
283
+
284
+ // A list of options that require reinitializing event listeners and/or
285
+ // special initialization code:
286
+ _specialOptions: [
287
+ 'fileInput',
288
+ 'dropZone',
289
+ 'pasteZone',
290
+ 'multipart',
291
+ 'forceIframeTransport'
292
+ ],
293
+
294
+ _blobSlice: $.support.blobSlice && function () {
295
+ var slice = this.slice || this.webkitSlice || this.mozSlice;
296
+ return slice.apply(this, arguments);
297
+ },
298
+
299
+ _BitrateTimer: function () {
300
+ this.timestamp = ((Date.now) ? Date.now() : (new Date()).getTime());
301
+ this.loaded = 0;
302
+ this.bitrate = 0;
303
+ this.getBitrate = function (now, loaded, interval) {
304
+ var timeDiff = now - this.timestamp;
305
+ if (!this.bitrate || !interval || timeDiff > interval) {
306
+ this.bitrate = (loaded - this.loaded) * (1000 / timeDiff) * 8;
307
+ this.loaded = loaded;
308
+ this.timestamp = now;
309
+ }
310
+ return this.bitrate;
311
+ };
312
+ },
313
+
314
+ _isXHRUpload: function (options) {
315
+ return !options.forceIframeTransport &&
316
+ ((!options.multipart && $.support.xhrFileUpload) ||
317
+ $.support.xhrFormDataFileUpload);
318
+ },
319
+
320
+ _getFormData: function (options) {
321
+ var formData;
322
+ if ($.type(options.formData) === 'function') {
323
+ return options.formData(options.form);
324
+ }
325
+ if ($.isArray(options.formData)) {
326
+ return options.formData;
327
+ }
328
+ if ($.type(options.formData) === 'object') {
329
+