Version Description
- Added dashboard for Toolset.
- Added setting to hide Front-end Display table.
- Added types_filter_query_field_definitions API filter.
- Added Import and Export support for term fields and field groups.
- Added ability to add term fields values on Add Term page.
- Added warning about possible conflicts between post type and taxonomy rewrite slugs.
- Added feature in Edit Field Group where fields with errors will be expanded on submit to make the error visible to the user.
- Added feature on term listing page to hide term field columns, if there are too many and user has not changed screen options .
- Added feature on post type edit screen to also display complex fields in Post Fields to be shown as columns in Post Type listing in WordPress Admin section, even if they are not available in the listing.
- Added ability to delete a taxonomy in edit page.
- Added ability to delete a field group in edit page.
- Added support for "id" in types_render_field() function.
- Changed label "Numeric" to "Number".
- Updated Where to include this Field Group section, which is no longer a meta box and is now placed under Name and description.
- Updated Front-end Display table, which will no longer display "Template" for built-in post types.
- Updated Cancel links in dialogs, which are now buttons to match WordPress style.
- Updated [types] shortcode attributes and they are now using single quotes, instead of double quotes.
- Updated screen header tags to h1, instead of h2.
- Updated plugin license information.
- Updated POT language file.
- Fixed issue with child post types not created by Types that could not be edited in child-relationship table.
- Fixed issue with name and singular name of post types and post field groups that were not being sanitised.
- Fixed issue with Types admin screens access when user role has been degraded from Administrator role.
- Fixed issue with post count display in "At a Glance" section, when it was above a thousand.
- Fixed issue in Conditional Display that advanced logic did not work without simple logic.
- Fixed issue in Conditional Display that simple logic was always being displayed, even if advanced logic was used.
- Fixed issue in Conditional Display that slugs with hyphens were not usable in advanced logic.
- Fixed issue with field control pages that were not displaying all groups.
- Fixed issue with fields that changing a slug removed the field conditions.
- Fixed issue with term fields showing field content instead of "Display text".
Download this release
Release Info
Developer | christianglingener |
Plugin | Toolset Types – Custom Post Types, Custom Fields and Taxonomies |
Version | 2.1 |
Comparing to | |
See all releases |
Code changes from version 2.0.1 to 2.1
- application/api.php +120 -2
- application/bootstrap.php +15 -10
- application/controllers/admin.php +28 -5
- application/controllers/admin_menu.php +4 -4
- application/controllers/ajax.php +153 -109
- application/controllers/ajax/handler/abstract.php +48 -0
- application/controllers/ajax/handler/check_slug_conflicts.php +258 -0
- application/controllers/ajax/handler/field_control_action.php +364 -0
- application/controllers/ajax/handler/settings_action.php +50 -0
- application/controllers/ajax/handler_interface.php +24 -0
- application/controllers/asset/help_tab_loader.php +3 -1
- application/controllers/asset/manager.php +38 -10
- application/controllers/dialog_box.php +5 -0
- application/controllers/embedded.php +3 -1
- application/controllers/field/utils.php +36 -255
- application/controllers/import_export.php +615 -0
- application/controllers/information/controller.php +38 -9
- application/controllers/main.php +46 -1
- application/controllers/page/dashboard.php +404 -0
- application/controllers/page/extension/edit_post.php +10 -8
- application/controllers/page/extension/edit_post_fields.php +6 -4
- application/controllers/page/extension/edit_post_type.php +6 -4
- application/controllers/page/extension/settings.php +86 -0
- application/controllers/page/field_control.php +1 -2
- application/controllers/page/hidden/helper.php +41 -0
- application/controllers/upgrade.php +264 -0
- {library/toolset/types/embedded/classes → application/controllers}/utils.php +1 -1
- application/data/dashboard/table/archive.php +234 -0
- application/data/dashboard/table/forms.php +134 -0
- application/data/dashboard/table/head.php +126 -0
- application/data/dashboard/table/template.php +212 -0
- application/data/dashboard/table/views.php +134 -0
- application/data/documentation-urls.php +52 -0
- application/data/information/documentation-urls.php +0 -27
- application/data/information/table/template.php +8 -2
- application/functions.php +0 -26
- {library/toolset/types/embedded/classes → application/models}/field/group.php +163 -10
- library/toolset/types/embedded/classes/field/group_factory.php → application/models/field/group/factory.php +51 -17
- application/models/field/group/post.php +138 -0
- library/toolset/types/embedded/classes/field/group_post_factory.php → application/models/field/group/post_factory.php +12 -12
- library/toolset/types/embedded/classes/field/group_term.php → application/models/field/group/term.php +28 -2
- library/toolset/types/embedded/classes/field/group_term_factory.php → application/models/field/group/term_factory.php +18 -17
- library/toolset/types/embedded/classes/field/group_user.php → application/models/field/group/user.php +1 -1
- library/toolset/types/embedded/classes/field/group_user_factory.php → application/models/field/group/user_factory.php +11 -11
- application/models/field/type/definition.php +107 -12
- application/models/field/type/definition/checkbox.php +16 -8
- application/models/field/type/definition/checkboxes.php +50 -0
- application/models/field/type/definition/date.php +30 -0
- application/models/field/type/definition/numeric.php +23 -3
- application/models/field/type/definition/radio.php +57 -0
- application/models/field/type/definition/select.php +56 -0
- application/models/field/type/definition_factory.php +7 -5
- application/models/helper/condition.php +15 -2
- application/models/helper/condition/archive/exists.php +5 -1
- application/models/helper/condition/archive/has_fields.php +5 -0
- application/models/helper/condition/archive/missing.php +5 -1
- application/models/helper/condition/archive/no_fields.php +7 -1
- application/models/helper/condition/archive/no_support.php +5 -1
- application/models/helper/condition/archive/support.php +6 -1
- application/models/helper/condition/cred/active.php +5 -0
- application/models/helper/condition/cred/forms_exist.php +5 -1
- application/models/helper/condition/cred/forms_missing.php +5 -1
- application/models/helper/condition/cred/missing.php +5 -1
- application/models/helper/condition/layouts/active.php +5 -1
- application/models/helper/condition/layouts/archive_exists.php +31 -13
- application/models/helper/condition/layouts/archive_missing.php +5 -0
- application/models/helper/condition/layouts/compatible.php +5 -1
- application/models/helper/condition/layouts/missing.php +5 -1
- application/models/helper/condition/layouts/template_exists.php +26 -34
- application/models/helper/condition/layouts/template_missing.php +7 -1
- application/models/helper/condition/screen.php +5 -1
- application/models/helper/condition/single/exists.php +5 -1
- application/models/helper/condition/single/has_fields.php +5 -0
- application/models/helper/condition/single/missing.php +5 -1
- application/models/helper/condition/single/no_fields.php +6 -1
- application/models/helper/condition/template.php +5 -1
- application/models/helper/condition/type/fields_assigned.php +17 -4
- application/models/helper/condition/views/active.php +5 -1
- application/models/helper/condition/views/archive_exists.php +29 -20
- application/models/helper/condition/views/archive_missing.php +5 -1
- application/models/helper/condition/views/missing.php +5 -1
- application/models/helper/condition/views/template_exists.php +36 -45
- application/models/helper/condition/views/template_missing.php +5 -1
- application/models/helper/condition/views/views_exist.php +5 -1
- application/models/helper/condition/views/views_missing.php +5 -1
- application/models/helper/create/content_template.php +39 -0
- application/models/helper/create/form.php +30 -0
- application/models/helper/create/layout.php +47 -3
- application/models/helper/create/view.php +21 -0
- application/models/helper/create/wordpress_archive.php +34 -2
- application/models/helper/output/interface.php +5 -1
- application/models/helper/output/meta_box.php +5 -1
- application/models/helper/placeholder.php +53 -93
- application/models/helper/twig.php +17 -1
- application/models/helper/type_hinting.php +0 -30
- application/models/helper/url.php +123 -25
- application/models/information/container.php +2 -3
- application/models/information/message.php +21 -5
- application/models/information/message/post_type.php +15 -0
- application/models/information/table.php +19 -8
- application/models/post_type.php +127 -0
- application/models/setting.php +36 -0
- application/models/setting/boolean.php +24 -0
- application/models/setting/interface.php +16 -0
- application/models/setting/option.php +63 -0
- application/models/setting/option/interface.php +14 -0
- application/models/setting/preset/information_table.php +34 -0
- application/models/taxonomy.php +55 -0
- application/views/information/table.twig +2 -0
- application/views/page/dashboard/help.twig +16 -0
- application/views/page/dashboard/main.twig +20 -0
- application/views/page/dashboard/table.twig +29 -0
- application/views/page/dashboard/table/tbody-cell.twig +9 -0
- application/views/page/dashboard/table/tbody-row.twig +61 -0
- application/views/page/dashboard/table/thead-cell.twig +17 -0
- application/views/setting/base.twig +8 -0
- application/views/setting/checkbox.twig +17 -0
- library/toolset/autoloader/autoloader.php +82 -58
- library/toolset/filesystem/file.php +11 -6
- library/toolset/installer/changelog.txt +7 -0
- library/toolset/installer/includes/installer.class.php +7 -6
- library/toolset/installer/installer.php +1 -1
- library/toolset/installer/loader.php +2 -11
- library/toolset/installer/res/css/admin.css +11 -0
- library/toolset/installer/res/js/admin.js +6 -10
- library/toolset/installer/res/js/installer_theme_install.js +13 -10
- library/toolset/onthego-resources/loader.php +1 -3
- library/toolset/onthego-resources/onthego-styles/onthego-admin-styles.css +2 -1
- library/toolset/onthego-resources/readme.md +1 -1
- library/toolset/toolset-common/bootstrap.php +13 -9
- library/toolset/toolset-common/changelog.md +85 -0
- library/toolset/toolset-common/changelog.txt +49 -40
- library/toolset/toolset-common/debug/debug-information.php +5 -10
- library/toolset/toolset-common/functions.php +6 -750
- library/toolset/toolset-common/inc/toolset.assets.manager.class.php +29 -5
- library/toolset/toolset-common/inc/toolset.export.import.screen.class.php +13 -2
- library/toolset/toolset-common/inc/toolset.function.helpers.php +10 -1
- library/toolset/toolset-common/inc/toolset.localization.class.php +26 -30
- library/toolset/toolset-common/inc/toolset.menu.class.php +234 -200
- library/toolset/toolset-common/inc/toolset.settings.screen.class.php +22 -4
- library/toolset/toolset-common/loader.php +2 -3
- library/toolset/toolset-common/res/css/toolset-common.css +7 -2
- library/toolset/toolset-common/res/lib/toolset-event-manager/toolset-event-manager.js +248 -0
- library/toolset/toolset-common/res/lib/toolset-event-manager/toolset-event-manager.min.js +1 -0
- library/toolset/toolset-common/toolset-common-loader.php +26 -3
- library/toolset/toolset-common/toolset-forms/classes/class.checkbox.php +5 -2
- library/toolset/toolset-common/toolset-forms/classes/class.credfile.php +19 -18
- library/toolset/toolset-common/toolset-forms/classes/class.fieldconfig.php +45 -14
- library/toolset/toolset-common/toolset-forms/classes/class.form_factory.php +2 -2
- library/toolset/toolset-common/toolset-forms/classes/class.radios.php +12 -12
- library/toolset/toolset-common/toolset-forms/classes/class.recaptcha.php +2 -2
- library/toolset/toolset-common/toolset-forms/classes/class.taxonomy.php +22 -16
- library/toolset/toolset-common/toolset-forms/classes/class.taxonomyhierarchical.php +1 -3
- library/toolset/toolset-common/toolset-forms/classes/class.validation.php +81 -75
- library/toolset/toolset-common/toolset-forms/classes/class.wysiwyg.php +50 -61
- library/toolset/toolset-common/toolset-forms/classes/submit.php +7 -4
- library/toolset/toolset-common/toolset-forms/css/wpt-toolset-backend.css +15 -2
- library/toolset/toolset-common/toolset-forms/css/wpt-toolset-frontend.css +46 -26
- library/toolset/toolset-common/toolset-forms/images/loading.png +0 -0
- library/toolset/toolset-common/toolset-forms/js/conditional.js +55 -33
- library/toolset/toolset-common/toolset-forms/js/credfile.js +11 -2
- library/toolset/toolset-common/toolset-forms/js/jquery-ui-186.min.js +401 -0
- library/toolset/toolset-common/toolset-forms/js/jquery-ui.min.js +13 -0
- library/toolset/toolset-common/toolset-forms/js/jquery_upload/file_upload.js +24 -17
- library/toolset/toolset-common/toolset-forms/js/main.js +22 -14
- library/toolset/toolset-common/toolset-forms/js/repetitive.js +13 -8
- library/toolset/toolset-common/toolset-forms/js/validation.js +118 -8
- library/toolset/toolset-common/utility/dialogs/css/dd-dialogs-forms.css +39 -2
- library/toolset/toolset-common/utility/dialogs/css/dd-dialogs-general.css +18 -6
- library/toolset/toolset-common/utility/dialogs/css/dd-dialogs.css +89 -84
- library/toolset/toolset-common/utility/dialogs/toolset.dialog-boxes.class.php +32 -10
- library/toolset/toolset-common/utility/help-videos/res/css/toolset-help-videos.css +138 -0
- library/toolset/toolset-common/utility/help-videos/res/images/ajax-loader-overlay.gif +0 -0
- library/toolset/toolset-common/utility/help-videos/res/images/ajax-loader-overlay2.gif +0 -0
- library/toolset/toolset-common/utility/help-videos/res/js/toolset-help-videos.js +373 -0
- library/toolset/toolset-common/utility/help-videos/templates/help-video.tpl.php +37 -0
- library/toolset/toolset-common/utility/help-videos/templates/tutorial-video-page.tpl.php +6 -0
- library/toolset/toolset-common/utility/help-videos/toolset-help-videos.php +225 -0
- library/toolset/toolset-common/utility/js/utils.js +457 -40
- library/toolset/toolset-common/utility/utils.php +181 -176
- library/toolset/toolset-common/visual-editor/res/js/icl_media_manager.js +1 -0
- library/toolset/types/admin.php +11 -3
- library/toolset/types/embedded/admin.php +17 -3
- library/toolset/types/embedded/classes/editor.php +11 -2
- library/toolset/types/embedded/classes/field/definition.php +114 -43
- library/toolset/types/embedded/classes/field/definition_abstract.php +18 -10
- library/toolset/types/embedded/classes/field/definition_factory.php +86 -3
- library/toolset/types/embedded/classes/field/definition_factory_post.php +2 -2
- library/toolset/types/embedded/classes/field/definition_factory_term.php +2 -2
- library/toolset/types/embedded/classes/field/definition_factory_user.php +2 -2
- library/toolset/types/embedded/classes/field/definition_term.php +1 -1
- library/toolset/types/embedded/classes/field/group_post.php +0 -34
- library/toolset/types/embedded/classes/field/instance_term.php +1 -1
- library/toolset/types/embedded/classes/field/renderer/factory.php +4 -4
- library/toolset/types/embedded/classes/field/renderer/preview/address.php +12 -3
- library/toolset/types/embedded/classes/field/renderer/preview/base.php +41 -16
- library/toolset/types/embedded/classes/field/renderer/preview/checkboxes.php +17 -2
- library/toolset/types/embedded/classes/field/renderer/preview/date.php +7 -3
- library/toolset/types/embedded/classes/field/renderer/preview/image.php +5 -5
- library/toolset/types/embedded/classes/field/renderer/preview/radio.php +1 -1
- library/toolset/types/embedded/classes/field/renderer/preview/textfield.php +4 -3
- library/toolset/types/embedded/classes/field/renderer/preview/url.php +4 -2
- library/toolset/types/embedded/classes/forms.php +9 -5
- library/toolset/types/embedded/classes/gui/term_field_editing.php +73 -26
application/api.php
CHANGED
@@ -1,4 +1,122 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Public Types hook API.
|
5 |
+
*
|
6 |
+
* This should be the only point where other plugins (incl. Toolset) interact with Types directly.
|
7 |
+
*
|
8 |
+
* Note: Types_Api is initialized on after_setup_theme with priority 10.
|
9 |
+
*
|
10 |
+
* @since 2.1
|
11 |
+
*/
|
12 |
+
final class Types_Api {
|
13 |
+
|
14 |
+
private static $instance;
|
15 |
+
|
16 |
+
public static function get_instance() {
|
17 |
+
if( null == self::$instance ) {
|
18 |
+
self::$instance = new self();
|
19 |
+
}
|
20 |
+
return self::$instance;
|
21 |
+
}
|
22 |
+
|
23 |
+
|
24 |
+
public static function initialize() {
|
25 |
+
self::get_instance();
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
private function __clone() { }
|
30 |
+
|
31 |
+
private function __construct() {
|
32 |
+
|
33 |
+
/**
|
34 |
+
* get all field group ids by post type
|
35 |
+
* @todo document
|
36 |
+
*/
|
37 |
+
add_filter( 'types_filter_get_field_group_ids_by_post_type', array( 'Types_Api_Helper', 'get_field_group_ids_by_post_type' ), 10, 2 );
|
38 |
+
|
39 |
+
/**
|
40 |
+
* types_filter_query_field_definitions
|
41 |
+
*
|
42 |
+
* @param mixed $default
|
43 |
+
* @param array $query Field definition query. See Types_Field_Definition_Factory::query() for allowed arguments.
|
44 |
+
* Additionally, you can specify:
|
45 |
+
* - 'domain': Field domain (see Types_Field_Utils; legacy domain names are also accepted):
|
46 |
+
* 'posts'|'users'|'terms'|'postmeta'|'usermeta'|'termmeta'|'all'. For 'all',
|
47 |
+
* the method returns a multidimensional arrays with results for individual domains:
|
48 |
+
* array( 'posts' => array( ... ), 'users' => array( ... ), ... ).
|
49 |
+
* @return null|array Field definition arrays, sanitized as per field type, or null if an error has occurred.
|
50 |
+
* @since 2.1
|
51 |
+
*/
|
52 |
+
add_filter( 'types_filter_query_field_definitions', array( $this, 'query_field_definitions' ), 10, 2 );
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Hook for types_filter_query_field_definitions.
|
58 |
+
*
|
59 |
+
* @param mixed $ignored
|
60 |
+
* @param array $query Field definition query. See Types_Field_Definition_Factory::query() for supported arguments.
|
61 |
+
* Additionally, you can specify:
|
62 |
+
* - 'domain': A single field domain (see Types_Field_Utils) or 'all'. Legacy domain names are also accepted.
|
63 |
+
* For 'all', the method returns a multidimensional arrays with results for individual domains:
|
64 |
+
* array( 'posts' => array( ... ), 'users' => array( ... ), ... ).
|
65 |
+
*
|
66 |
+
* @return null|array Field definition arrays, sanitized as per field type, or null if an error has occurred.
|
67 |
+
* @since 2.1
|
68 |
+
*/
|
69 |
+
public function query_field_definitions(
|
70 |
+
/** @noinspection PhpUnusedParameterInspection */ $ignored, $query )
|
71 |
+
{
|
72 |
+
$domain = wpcf_getarr( $query, 'domain', 'all' );
|
73 |
+
|
74 |
+
if( 'all' == $domain ) {
|
75 |
+
|
76 |
+
// Call itself for each available domain.
|
77 |
+
$results_by_domain = array();
|
78 |
+
$domains = Types_Field_Utils::get_domains();
|
79 |
+
foreach( $domains as $field_domain ) {
|
80 |
+
$per_domain_query = $query;
|
81 |
+
$per_domain_query['domain'] = $field_domain;
|
82 |
+
$results_by_domain[ $field_domain ] = $this->query_field_definitions( null, $per_domain_query );
|
83 |
+
}
|
84 |
+
|
85 |
+
return $results_by_domain;
|
86 |
+
|
87 |
+
} else {
|
88 |
+
|
89 |
+
// Sanitize input
|
90 |
+
if( ! is_string( $domain ) || ! is_array( $query ) ) {
|
91 |
+
return null;
|
92 |
+
}
|
93 |
+
|
94 |
+
// Get the factory by domain, and if it fails, try to convert from legacy meta_type value.
|
95 |
+
try {
|
96 |
+
$definition_factory = Types_Field_Utils::get_definition_factory_by_domain( $domain );
|
97 |
+
} catch( InvalidArgumentException $e ) {
|
98 |
+
$definition_factory = null;
|
99 |
+
}
|
100 |
+
|
101 |
+
if ( null == $definition_factory ) {
|
102 |
+
try {
|
103 |
+
$definition_factory = Types_Field_Utils::get_definition_factory_by_domain( Types_Field_Utils::legacy_meta_type_to_domain( $domain ) );
|
104 |
+
} catch( InvalidArgumentException $e ) {
|
105 |
+
return null;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
// Allways query only Types fields.
|
110 |
+
$query['filter'] = 'types';
|
111 |
+
|
112 |
+
/** @var WPCF_Field_Definition[] $definitions */
|
113 |
+
$definitions = $definition_factory->query_definitions( $query );
|
114 |
+
$definition_arrays = array();
|
115 |
+
foreach( $definitions as $definition ) {
|
116 |
+
$definition_arrays[] = $definition->get_definition_array();
|
117 |
+
}
|
118 |
+
|
119 |
+
return $definition_arrays;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
application/bootstrap.php
CHANGED
@@ -6,12 +6,16 @@
|
|
6 |
require_once( TYPES_ABSPATH . '/library/toolset/autoloader/autoloader.php' );
|
7 |
|
8 |
$autoloader = Toolset_Autoloader::get_instance();
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
|
16 |
|
17 |
/*
|
@@ -39,9 +43,10 @@ if ( !defined( 'EDITOR_ADDON_RELPATH' ) ) {
|
|
39 |
|
40 |
// installer
|
41 |
$installer = TYPES_ABSPATH . '/library/toolset/installer/loader.php';
|
42 |
-
if ( file_exists($installer) ) {
|
|
|
43 |
include_once $installer;
|
44 |
-
if ( function_exists('WP_Installer_Setup') ) {
|
45 |
WP_Installer_Setup(
|
46 |
$wp_installer_instance,
|
47 |
array(
|
@@ -59,10 +64,10 @@ require_once( dirname( __FILE__ ) . '/functions.php' );
|
|
59 |
// Initialize legacy code
|
60 |
require_once( dirname( __FILE__ ) . '/../library/toolset/types/wpcf.php' );
|
61 |
|
62 |
-
//
|
63 |
require_once( dirname( __FILE__ ) . '/api.php' );
|
64 |
|
65 |
-
//
|
66 |
Types_Embedded::initialize();
|
67 |
|
68 |
// Jumpstart new Types
|
6 |
require_once( TYPES_ABSPATH . '/library/toolset/autoloader/autoloader.php' );
|
7 |
|
8 |
$autoloader = Toolset_Autoloader::get_instance();
|
9 |
+
|
10 |
+
$autoloader->add_paths(
|
11 |
+
'Types',
|
12 |
+
array(
|
13 |
+
TYPES_ABSPATH . '/application/controllers',
|
14 |
+
TYPES_ABSPATH . '/application/models',
|
15 |
+
)
|
16 |
+
);
|
17 |
+
|
18 |
+
$autoloader->add_path( 'Toolset', TYPES_ABSPATH . '/library/toolset' );
|
19 |
|
20 |
|
21 |
/*
|
43 |
|
44 |
// installer
|
45 |
$installer = TYPES_ABSPATH . '/library/toolset/installer/loader.php';
|
46 |
+
if ( file_exists( $installer ) ) {
|
47 |
+
/** @noinspection PhpIncludeInspection */
|
48 |
include_once $installer;
|
49 |
+
if ( function_exists( 'WP_Installer_Setup' ) ) {
|
50 |
WP_Installer_Setup(
|
51 |
$wp_installer_instance,
|
52 |
array(
|
64 |
// Initialize legacy code
|
65 |
require_once( dirname( __FILE__ ) . '/../library/toolset/types/wpcf.php' );
|
66 |
|
67 |
+
// Public API
|
68 |
require_once( dirname( __FILE__ ) . '/api.php' );
|
69 |
|
70 |
+
// Handle embedded plugin mode
|
71 |
Types_Embedded::initialize();
|
72 |
|
73 |
// Jumpstart new Types
|
application/controllers/admin.php
CHANGED
@@ -30,18 +30,26 @@ final class Types_Admin {
|
|
30 |
|
31 |
private function on_init() {
|
32 |
|
|
|
|
|
33 |
// Load Twig - this is a bit hacky way to do it, see Types_Twig_Autoloader class for explanation.
|
34 |
Types_Twig_Autoloader::register();
|
35 |
|
36 |
-
// Load
|
37 |
-
if( apply_filters( 'types_register_pages', true ) )
|
38 |
Types_Admin_Menu::initialize();
|
|
|
39 |
|
40 |
-
|
41 |
-
$this->page_extensions();
|
42 |
}
|
43 |
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
// extensions for post edit page
|
46 |
add_action( 'load-post.php', array( 'Types_Page_Extension_Edit_Post', 'get_instance' ) );
|
47 |
|
@@ -50,5 +58,20 @@ final class Types_Admin {
|
|
50 |
|
51 |
// extension for post fields edit page
|
52 |
add_action( 'load-toolset_page_wpcf-edit', array( 'Types_Page_Extension_Edit_Post_Fields', 'get_instance' ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
}
|
|
|
54 |
}
|
30 |
|
31 |
private function on_init() {
|
32 |
|
33 |
+
Types_Upgrade::initialize();
|
34 |
+
|
35 |
// Load Twig - this is a bit hacky way to do it, see Types_Twig_Autoloader class for explanation.
|
36 |
Types_Twig_Autoloader::register();
|
37 |
|
38 |
+
// Load menu - won't be loaded in embedded version.
|
39 |
+
if( apply_filters( 'types_register_pages', true ) ) {
|
40 |
Types_Admin_Menu::initialize();
|
41 |
+
}
|
42 |
|
43 |
+
$this->init_page_extensions();
|
|
|
44 |
}
|
45 |
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Add hooks for loading page extensions.
|
49 |
+
*
|
50 |
+
* @since 2.1
|
51 |
+
*/
|
52 |
+
private function init_page_extensions() {
|
53 |
// extensions for post edit page
|
54 |
add_action( 'load-post.php', array( 'Types_Page_Extension_Edit_Post', 'get_instance' ) );
|
55 |
|
58 |
|
59 |
// extension for post fields edit page
|
60 |
add_action( 'load-toolset_page_wpcf-edit', array( 'Types_Page_Extension_Edit_Post_Fields', 'get_instance' ) );
|
61 |
+
|
62 |
+
// settings
|
63 |
+
add_action( 'load-toolset_page_toolset-settings', array( $this, 'init_settings' ) );
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Initialize the extension for the Toolset Settings page.
|
69 |
+
*
|
70 |
+
* @since 2.1
|
71 |
+
*/
|
72 |
+
public function init_settings() {
|
73 |
+
$settings = new Types_Page_Extension_Settings();
|
74 |
+
$settings->build();
|
75 |
}
|
76 |
+
|
77 |
}
|
application/controllers/admin_menu.php
CHANGED
@@ -18,6 +18,7 @@ final class Types_Admin_Menu {
|
|
18 |
// All (non-legacy) page slugs.
|
19 |
const PAGE_NAME_FIELD_CONTROL = 'types-field-control';
|
20 |
const PAGE_NAME_HELPER = 'types-helper'; // hidden page
|
|
|
21 |
|
22 |
|
23 |
private static $instance;
|
@@ -40,6 +41,9 @@ final class Types_Admin_Menu {
|
|
40 |
private function __construct() {
|
41 |
// Priority is hardcoded by filter documentation.
|
42 |
add_filter( 'toolset_filter_register_menu_pages', array( $this, 'on_admin_menu' ), 10 );
|
|
|
|
|
|
|
43 |
}
|
44 |
|
45 |
|
@@ -57,7 +61,6 @@ final class Types_Admin_Menu {
|
|
57 |
* @since 2.0
|
58 |
*/
|
59 |
public function on_admin_menu( $pages ) {
|
60 |
-
|
61 |
// Add legacy pages
|
62 |
$pages = wpcf_admin_toolset_register_menu_pages( $pages );
|
63 |
|
@@ -65,7 +68,6 @@ final class Types_Admin_Menu {
|
|
65 |
if( !empty( $page_name ) ) {
|
66 |
$pages = $this->maybe_add_ondemand_submenu( $pages, $page_name );
|
67 |
}
|
68 |
-
|
69 |
return $pages;
|
70 |
}
|
71 |
|
@@ -84,12 +86,10 @@ final class Types_Admin_Menu {
|
|
84 |
*/
|
85 |
private function maybe_add_ondemand_submenu( $pages, $page_name ) {
|
86 |
$page = null;
|
87 |
-
|
88 |
switch( $page_name ) {
|
89 |
case self::PAGE_NAME_FIELD_CONTROL:
|
90 |
$page = Types_Page_Field_Control::get_instance();
|
91 |
break;
|
92 |
-
|
93 |
case self::PAGE_NAME_HELPER:
|
94 |
Types_Page_Hidden_Helper::get_instance();
|
95 |
break;
|
18 |
// All (non-legacy) page slugs.
|
19 |
const PAGE_NAME_FIELD_CONTROL = 'types-field-control';
|
20 |
const PAGE_NAME_HELPER = 'types-helper'; // hidden page
|
21 |
+
const PAGE_NAME_DASHBOARD = 'types-dashboard';
|
22 |
|
23 |
|
24 |
private static $instance;
|
41 |
private function __construct() {
|
42 |
// Priority is hardcoded by filter documentation.
|
43 |
add_filter( 'toolset_filter_register_menu_pages', array( $this, 'on_admin_menu' ), 10 );
|
44 |
+
|
45 |
+
// Load Dashboard
|
46 |
+
Types_Page_Dashboard::get_instance();
|
47 |
}
|
48 |
|
49 |
|
61 |
* @since 2.0
|
62 |
*/
|
63 |
public function on_admin_menu( $pages ) {
|
|
|
64 |
// Add legacy pages
|
65 |
$pages = wpcf_admin_toolset_register_menu_pages( $pages );
|
66 |
|
68 |
if( !empty( $page_name ) ) {
|
69 |
$pages = $this->maybe_add_ondemand_submenu( $pages, $page_name );
|
70 |
}
|
|
|
71 |
return $pages;
|
72 |
}
|
73 |
|
86 |
*/
|
87 |
private function maybe_add_ondemand_submenu( $pages, $page_name ) {
|
88 |
$page = null;
|
|
|
89 |
switch( $page_name ) {
|
90 |
case self::PAGE_NAME_FIELD_CONTROL:
|
91 |
$page = Types_Page_Field_Control::get_instance();
|
92 |
break;
|
|
|
93 |
case self::PAGE_NAME_HELPER:
|
94 |
Types_Page_Hidden_Helper::get_instance();
|
95 |
break;
|
application/controllers/ajax.php
CHANGED
@@ -2,17 +2,36 @@
|
|
2 |
|
3 |
/**
|
4 |
* Main AJAX call controller for Types.
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
*
|
10 |
* @since 2.0
|
11 |
*/
|
12 |
final class Types_Ajax {
|
13 |
|
14 |
-
|
15 |
const CALLBACK_FIELD_CONTROL_ACTION = 'field_control_action';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
|
18 |
private static $instance;
|
@@ -27,16 +46,27 @@ final class Types_Ajax {
|
|
27 |
|
28 |
|
29 |
public static function initialize() {
|
30 |
-
self::get_instance();
|
|
|
|
|
|
|
31 |
}
|
32 |
|
33 |
|
34 |
private function __clone() { }
|
35 |
|
36 |
|
37 |
-
private function __construct() {
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
|
42 |
/**
|
@@ -49,14 +79,16 @@ final class Types_Ajax {
|
|
49 |
*/
|
50 |
private function register_callbacks() {
|
51 |
|
52 |
-
$
|
53 |
-
|
54 |
-
|
55 |
|
56 |
-
foreach(
|
57 |
-
add_action( 'wp_ajax_types_' . $callback_name, array( $this,
|
58 |
}
|
59 |
|
|
|
|
|
60 |
}
|
61 |
|
62 |
|
@@ -65,6 +97,42 @@ final class Types_Ajax {
|
|
65 |
}
|
66 |
|
67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
|
69 |
/**
|
70 |
* Perform basic authentication check.
|
@@ -73,7 +141,7 @@ final class Types_Ajax {
|
|
73 |
* is not successful.
|
74 |
*
|
75 |
* @param array $args Arguments (
|
76 |
-
* @type string $
|
77 |
* @type string $nonce_parameter Name of the parameter containing nonce value.
|
78 |
* Optional, defaults to "wpnonce".
|
79 |
* @type string $parameter_source Determines where the function should look for the nonce parameter.
|
@@ -144,7 +212,7 @@ final class Types_Ajax {
|
|
144 |
* @return array|void
|
145 |
* @since 2.0
|
146 |
*/
|
147 |
-
|
148 |
return $this->ajax_authenticate( $args );
|
149 |
}
|
150 |
|
@@ -160,7 +228,7 @@ final class Types_Ajax {
|
|
160 |
* @param bool $is_success
|
161 |
* @since 2.0
|
162 |
*/
|
163 |
-
|
164 |
if( $is_success ) {
|
165 |
wp_send_json_success( $response );
|
166 |
} else {
|
@@ -170,109 +238,85 @@ final class Types_Ajax {
|
|
170 |
|
171 |
|
172 |
/**
|
173 |
-
*
|
174 |
-
*
|
175 |
-
*
|
176 |
-
*
|
|
|
|
|
177 |
*/
|
178 |
-
|
179 |
-
$this->ajax_begin( array( 'nonce' => $this->get_action_js_name( self::CALLBACK_FIELD_CONTROL_ACTION ) ) );
|
180 |
|
181 |
-
//
|
182 |
-
|
183 |
-
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
}
|
189 |
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
$
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
} else if( false == $result ) {
|
210 |
-
// This should not happen...!
|
211 |
-
$errors[] = new WP_Error( 0, __( 'An unexpected error happened while processing the request.', 'wpcf' ) );
|
212 |
-
} else {
|
213 |
-
// Success
|
214 |
-
|
215 |
-
// Save the field definition model as a result if we got a whole definition
|
216 |
-
if( $result instanceof WPCF_Field_Definition ) {
|
217 |
-
$result = $result->to_json();
|
218 |
-
}
|
219 |
-
|
220 |
-
$results[ wpcf_getarr( $field, 'slug' ) ] = $result;
|
221 |
-
}
|
222 |
}
|
223 |
|
224 |
-
$data = array( 'results' => $results );
|
225 |
-
$is_success = empty( $errors );
|
226 |
-
|
227 |
-
if( !$is_success ) {
|
228 |
-
$error_messages = array();
|
229 |
-
/** @var WP_Error $error */
|
230 |
-
foreach( $errors as $error ) {
|
231 |
-
$error_messages[] = $error->get_error_message();
|
232 |
-
}
|
233 |
-
$data['messages'] = $error_messages;
|
234 |
-
}
|
235 |
-
|
236 |
-
$this->ajax_finish( $data, $is_success );
|
237 |
}
|
238 |
|
239 |
|
240 |
/**
|
241 |
-
*
|
242 |
-
*
|
243 |
-
*
|
244 |
-
*
|
245 |
-
* @
|
246 |
-
*
|
247 |
-
* @
|
|
|
|
|
248 |
*/
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
|
|
275 |
}
|
276 |
}
|
277 |
-
|
278 |
}
|
2 |
|
3 |
/**
|
4 |
* Main AJAX call controller for Types.
|
5 |
+
*
|
6 |
+
* When DOING_AJAX, you need to run initialize() to register the callbacks, only creating an instance will not be enough.
|
7 |
+
*
|
8 |
+
* When implementing AJAX actions, please follow these rules:
|
9 |
+
*
|
10 |
+
* 1. All AJAX action names are automatically prefixed with 'wp_ajax_types_'. Only lowercase characters and underscores
|
11 |
+
* can be used.
|
12 |
+
* 2. Action names (without a prefix) should be defined as constants, and be part of the Types_Ajax::$callbacks array.
|
13 |
+
* 3. For each action, there should be a dedicated class implementing the Types_Ajax_Handler_Interface. Name of the class
|
14 |
+
* must be Types_Ajax_Handler_{%capitalized_action_name}. So for example, for a hook to
|
15 |
+
* 'wp_ajax_types_field_control_action' you need to create a class 'Types_Ajax_Handler_Field_Control_Action'.
|
16 |
+
* 4. All callbacks must use the ajax_begin() and ajax_finish() methods.
|
17 |
*
|
18 |
* @since 2.0
|
19 |
*/
|
20 |
final class Types_Ajax {
|
21 |
|
22 |
+
// Action names
|
23 |
const CALLBACK_FIELD_CONTROL_ACTION = 'field_control_action';
|
24 |
+
const CALLBACK_CHECK_SLUG_CONFLICTS = 'check_slug_conflicts';
|
25 |
+
const CALLBACK_SETTINGS_ACTION = 'settings_action';
|
26 |
+
|
27 |
+
|
28 |
+
/** Prefix for the callback method name */
|
29 |
+
const CALLBACK_PREFIX = 'callback_';
|
30 |
+
|
31 |
+
/** Prefix for the handler class name */
|
32 |
+
const HANDLER_CLASS_PREFIX = 'Types_Ajax_Handler_';
|
33 |
+
|
34 |
+
const DELIMITER = '_';
|
35 |
|
36 |
|
37 |
private static $instance;
|
46 |
|
47 |
|
48 |
public static function initialize() {
|
49 |
+
$instance = self::get_instance();
|
50 |
+
|
51 |
+
$instance->register_callbacks();
|
52 |
+
$instance->additional_ajax_init();
|
53 |
}
|
54 |
|
55 |
|
56 |
private function __clone() { }
|
57 |
|
58 |
|
59 |
+
private function __construct() { }
|
60 |
+
|
61 |
+
|
62 |
+
private static $callbacks = array(
|
63 |
+
self::CALLBACK_FIELD_CONTROL_ACTION,
|
64 |
+
self::CALLBACK_CHECK_SLUG_CONFLICTS,
|
65 |
+
self::CALLBACK_SETTINGS_ACTION,
|
66 |
+
);
|
67 |
+
|
68 |
+
|
69 |
+
private $callbacks_registered = false;
|
70 |
|
71 |
|
72 |
/**
|
79 |
*/
|
80 |
private function register_callbacks() {
|
81 |
|
82 |
+
if( $this->callbacks_registered ) {
|
83 |
+
return;
|
84 |
+
}
|
85 |
|
86 |
+
foreach( self::$callbacks as $callback_name ) {
|
87 |
+
add_action( 'wp_ajax_types_' . $callback_name, array( $this, self::CALLBACK_PREFIX . $callback_name ) );
|
88 |
}
|
89 |
|
90 |
+
$this->callbacks_registered = true;
|
91 |
+
|
92 |
}
|
93 |
|
94 |
|
97 |
}
|
98 |
|
99 |
|
100 |
+
/**
|
101 |
+
* Handle a call to undefined method on this class, hopefully an AJAX call.
|
102 |
+
*
|
103 |
+
* @param string $name Method name.
|
104 |
+
* @param array $parameters Method parameters.
|
105 |
+
* @since 2.1
|
106 |
+
*/
|
107 |
+
public function __call( $name, $parameters ) {
|
108 |
+
// Check for the callback prefix in the method name
|
109 |
+
$name_parts = explode( self::DELIMITER, $name );
|
110 |
+
if( 0 !== strcmp( $name_parts[0] . self::DELIMITER, self::CALLBACK_PREFIX ) ) {
|
111 |
+
// Not a callback, resign.
|
112 |
+
return;
|
113 |
+
}
|
114 |
+
|
115 |
+
// Deduct the handler class name from the callback name
|
116 |
+
unset( $name_parts[0] );
|
117 |
+
$class_name = implode( self::DELIMITER, $name_parts );
|
118 |
+
$class_name = strtolower( $class_name );
|
119 |
+
$class_name = mb_convert_case( $class_name, MB_CASE_TITLE );
|
120 |
+
$class_name = self::HANDLER_CLASS_PREFIX . $class_name;
|
121 |
+
|
122 |
+
// Obtain an instance of the handler class.
|
123 |
+
try {
|
124 |
+
/** @var Types_Ajax_Handler_Interface $handler */
|
125 |
+
$handler = new $class_name( $this );
|
126 |
+
} catch( Exception $e ) {
|
127 |
+
// The handler class could not have been instantiated, resign.
|
128 |
+
return;
|
129 |
+
}
|
130 |
+
|
131 |
+
// Success
|
132 |
+
$handler->process_call( $parameters );
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
|
137 |
/**
|
138 |
* Perform basic authentication check.
|
141 |
* is not successful.
|
142 |
*
|
143 |
* @param array $args Arguments (
|
144 |
+
* @type string $nonce Name of the nonce that should be verified. Mandatory
|
145 |
* @type string $nonce_parameter Name of the parameter containing nonce value.
|
146 |
* Optional, defaults to "wpnonce".
|
147 |
* @type string $parameter_source Determines where the function should look for the nonce parameter.
|
212 |
* @return array|void
|
213 |
* @since 2.0
|
214 |
*/
|
215 |
+
public function ajax_begin( $args ) {
|
216 |
return $this->ajax_authenticate( $args );
|
217 |
}
|
218 |
|
228 |
* @param bool $is_success
|
229 |
* @since 2.0
|
230 |
*/
|
231 |
+
public function ajax_finish( $response, $is_success = true ) {
|
232 |
if( $is_success ) {
|
233 |
wp_send_json_success( $response );
|
234 |
} else {
|
238 |
|
239 |
|
240 |
/**
|
241 |
+
* Handles all initialization of except AJAX callbacks itself that is needed when
|
242 |
+
* we're DOING_AJAX.
|
243 |
+
*
|
244 |
+
* Since this is executed on every AJAX call, make sure it's as lightweight as possible.
|
245 |
+
*
|
246 |
+
* @since 2.1
|
247 |
*/
|
248 |
+
private function additional_ajax_init() {
|
|
|
249 |
|
250 |
+
// On the Add Term page, we need to initialize the page controller WPCF_GUI_Term_Field_Editing
|
251 |
+
// so that it saves term fields (if there are any).
|
252 |
+
add_action( 'create_term', array( $this, 'prepare_for_term_creation' ) );
|
253 |
|
254 |
+
add_action( 'updated_user_meta', array( $this, 'capture_columnshidden_update' ), 10, 4 );
|
255 |
+
}
|
256 |
+
|
|
|
257 |
|
258 |
+
/**
|
259 |
+
* On the Add Term page, we need to initialize the page controller WPCF_GUI_Term_Field_Editing
|
260 |
+
* so that it saves term fields (if there are any).
|
261 |
+
*
|
262 |
+
* @since 2.1
|
263 |
+
*/
|
264 |
+
public function prepare_for_term_creation() {
|
265 |
+
|
266 |
+
// Takes care of the rest, mainly we're interested about the create_{$taxonomy} action which follows
|
267 |
+
// immediately after create_term.
|
268 |
+
//
|
269 |
+
// On actions fired on the Add Term page, the action POST variable is allways add-tag and the screen is set
|
270 |
+
// to edit-{$taxonomy}. When creating the term on the post edit page, for example, the screen is not set. We use
|
271 |
+
// this to further limit the resource wasting. However, initializing the controller even if it's not supposed to
|
272 |
+
// will not lead to any errors - it gives up gracefully.
|
273 |
+
$action = wpcf_getpost( 'action' );
|
274 |
+
$screen = wpcf_getpost( 'screen', null );
|
275 |
+
if( 'add-tag' == $action && null !== $screen ) {
|
276 |
+
WPCF_GUI_Term_Field_Editing::initialize();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
}
|
278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
}
|
280 |
|
281 |
|
282 |
/**
|
283 |
+
* When updating screen options with hidden listing columns, we may need to store additional data.
|
284 |
+
*
|
285 |
+
* See WPCF_GUI_Term_Field_Editing::maybe_disable_column_autohiding() for details.
|
286 |
+
*
|
287 |
+
* @param mixed $meta_id Ignored.
|
288 |
+
* @param mixed $object_id Ignored.
|
289 |
+
* @param string $meta_key Meta key.
|
290 |
+
* @param mixed $_meta_value Meta value. We expect it to be an array.
|
291 |
+
* @since 2.1
|
292 |
*/
|
293 |
+
public function capture_columnshidden_update(
|
294 |
+
/** @noinspection PhpUnusedParameterInspection */ $meta_id, $object_id, $meta_key, $_meta_value )
|
295 |
+
{
|
296 |
+
// We're looking for a meta_key that looks like "manage{$page_name}columnshidden".
|
297 |
+
$txt_columnshidden = 'columnshidden';
|
298 |
+
$is_columnshidden_option = ( 0 == strcmp( $txt_columnshidden, substr( $meta_key, strlen( $txt_columnshidden ) * -1 ) ) );
|
299 |
+
|
300 |
+
if( $is_columnshidden_option ) {
|
301 |
+
|
302 |
+
// Extract the page name from the meta_key
|
303 |
+
$strip_begin = strlen( 'manage' );
|
304 |
+
$strip_end = strlen( $txt_columnshidden );
|
305 |
+
$page_name = substr( $meta_key, $strip_begin, strlen( $meta_key ) - ( $strip_begin + $strip_end ) );
|
306 |
+
|
307 |
+
// Determine if we're editing a taxonomy
|
308 |
+
$txt_edit = 'edit-';
|
309 |
+
$txt_edit_len = strlen( $txt_edit );
|
310 |
+
$is_tax_edit_page = ( 0 == strcmp( $txt_edit, substr( $page_name, 0, $txt_edit_len ) ) );
|
311 |
+
|
312 |
+
// This is not 100% certain but attempting to handle a taxonomy that doesn't exist does no harm.
|
313 |
+
if( $is_tax_edit_page ) {
|
314 |
+
|
315 |
+
// Now we know that we need to perform the extra action.
|
316 |
+
$taxonomy_name = substr( $page_name, $txt_edit_len );
|
317 |
+
$edit_term_page_extension = WPCF_GUI_Term_Field_Editing::get_instance();
|
318 |
+
$edit_term_page_extension->maybe_disable_column_autohiding( $taxonomy_name, $_meta_value, $page_name );
|
319 |
+
}
|
320 |
}
|
321 |
}
|
|
|
322 |
}
|
application/controllers/ajax/handler/abstract.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Abstract AJAX call handler.
|
5 |
+
*
|
6 |
+
* @since 2.1
|
7 |
+
*/
|
8 |
+
abstract class Types_Ajax_Handler_Abstract implements Types_Ajax_Handler_Interface {
|
9 |
+
|
10 |
+
|
11 |
+
/** @var Types_Ajax */
|
12 |
+
private $ajax_manager;
|
13 |
+
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Types_Ajax_Handler_Abstract constructor.
|
17 |
+
*
|
18 |
+
* @param Types_Ajax $ajax_manager
|
19 |
+
* @since 2.1
|
20 |
+
*/
|
21 |
+
public function __construct( $ajax_manager ) {
|
22 |
+
$this->ajax_manager = $ajax_manager;
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Get the Types AJAX manager.
|
28 |
+
*
|
29 |
+
* @return Types_Ajax
|
30 |
+
*/
|
31 |
+
protected function get_am() {
|
32 |
+
return $this->ajax_manager;
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
+
protected function ajax_begin( $arguments ) {
|
37 |
+
$am = $this->get_am();
|
38 |
+
return $am->ajax_begin( $arguments );
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
protected function ajax_finish( $response, $is_success = true ) {
|
43 |
+
$am = $this->get_am();
|
44 |
+
return $am->ajax_finish( $response, $is_success );
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
+
}
|
application/controllers/ajax/handler/check_slug_conflicts.php
ADDED
@@ -0,0 +1,258 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Handle checking for slug conflicts among different domains.
|
5 |
+
*
|
6 |
+
* Used by the slug_conflict_checker.js script. Compares given value with all values within specified domains
|
7 |
+
* and reports if a conflict is found.
|
8 |
+
*
|
9 |
+
* Currently supported domains are:
|
10 |
+
* - Post type rewrite slugs (value of the slug used for permalink rewriting or the post type slug if rewriting is
|
11 |
+
* not enabled for that post type)
|
12 |
+
* - Taxonomy rewrite slugs (analogous to post types)
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
class Types_Ajax_Handler_Check_Slug_Conflicts extends Types_Ajax_Handler_Abstract {
|
16 |
+
|
17 |
+
// Definition of supported domains
|
18 |
+
const DOMAIN_POST_TYPE_REWRITE_SLUGS = 'post_type_rewrite_slugs';
|
19 |
+
const DOMAIN_TAXONOMY_REWRITE_SLUGS = 'taxonomy_rewrite_slugs';
|
20 |
+
|
21 |
+
private static $supported_domains = array(
|
22 |
+
self::DOMAIN_POST_TYPE_REWRITE_SLUGS,
|
23 |
+
self::DOMAIN_TAXONOMY_REWRITE_SLUGS
|
24 |
+
);
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* todo document
|
29 |
+
* @param array $arguments Original action arguments.
|
30 |
+
* @return void
|
31 |
+
*/
|
32 |
+
function process_call( $arguments ) {
|
33 |
+
|
34 |
+
$this->ajax_begin(
|
35 |
+
array( 'nonce' => Types_Ajax::CALLBACK_CHECK_SLUG_CONFLICTS )
|
36 |
+
);
|
37 |
+
|
38 |
+
// Read and validate input
|
39 |
+
$domains = wpcf_getpost( 'domains' );
|
40 |
+
$value = wpcf_getpost( 'value' );
|
41 |
+
$exclude = wpcf_getpost( 'exclude' );
|
42 |
+
$exclude_id = wpcf_getarr( $exclude, 'id', 0 );
|
43 |
+
$exclude_domain = wpcf_getarr( $exclude, 'domain' );
|
44 |
+
$diff_domains = array_diff( $domains, self::$supported_domains );
|
45 |
+
|
46 |
+
if( !is_array( $domains )
|
47 |
+
|| !empty( $diff_domains )
|
48 |
+
|| !is_string( $value )
|
49 |
+
|| !is_array( $exclude )
|
50 |
+
|| 0 === $exclude_id
|
51 |
+
|| !in_array( $exclude_domain, self::$supported_domains )
|
52 |
+
) {
|
53 |
+
$this->ajax_finish( array(), false );
|
54 |
+
}
|
55 |
+
|
56 |
+
|
57 |
+
$conflict = $this->check_slug_conflicts( $value, $domains, $exclude_domain, $exclude_id );
|
58 |
+
|
59 |
+
|
60 |
+
// Parse output (report a conflict if there is any)
|
61 |
+
if( false === $conflict ) {
|
62 |
+
$this->ajax_finish( array( 'isConflict' => false ), true );
|
63 |
+
} else {
|
64 |
+
|
65 |
+
$message = sprintf(
|
66 |
+
'<strong>%s</strong>: %s',
|
67 |
+
__( 'Warning', 'wpcf' ),
|
68 |
+
wpcf_getarr( $conflict, 'message' )
|
69 |
+
);
|
70 |
+
|
71 |
+
$this->ajax_finish(
|
72 |
+
array(
|
73 |
+
'isConflict' => true,
|
74 |
+
'displayMessage' => $message
|
75 |
+
),
|
76 |
+
true
|
77 |
+
);
|
78 |
+
}
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Check given slug for conflicts across defined domains.
|
85 |
+
*
|
86 |
+
* @param string $value Value to check.
|
87 |
+
* @param string[] $domains Array of valid domains
|
88 |
+
* @param string $exclude_domain Domain of the excluded object.
|
89 |
+
* @param string|int|null $exclude_id Id of the excluded object.
|
90 |
+
*
|
91 |
+
* @return array|bool Conflict information (an associative array with conflicting_id, message) or false when
|
92 |
+
* there's no conflict.
|
93 |
+
*
|
94 |
+
* @since 2.1
|
95 |
+
*/
|
96 |
+
private function check_slug_conflicts( $value, $domains, $exclude_domain, $exclude_id ) {
|
97 |
+
|
98 |
+
foreach( $domains as $domain ) {
|
99 |
+
$conflict = $this->check_slug_conflicts_in_domain( $value, $domain, ( $domain == $exclude_domain ) ? $exclude_id : null );
|
100 |
+
if( false !== $conflict ) {
|
101 |
+
return $conflict;
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
// No conflicts found
|
106 |
+
return false;
|
107 |
+
}
|
108 |
+
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Check given slug for conflicts in one domain.
|
112 |
+
*
|
113 |
+
* @param string $value Value to check.
|
114 |
+
* @param string $domain Domain name.
|
115 |
+
* @param string|int|null $exclude_id ID of an object to exclude within this domain, or null if there is none.
|
116 |
+
*
|
117 |
+
* @return array|bool Conflict information (an associative array with conflicting_id, message) or false when
|
118 |
+
* there's no conflict.
|
119 |
+
*
|
120 |
+
* @since 2.1
|
121 |
+
*/
|
122 |
+
private function check_slug_conflicts_in_domain( $value, $domain, $exclude_id = null ) {
|
123 |
+
switch( $domain ) {
|
124 |
+
case self::DOMAIN_POST_TYPE_REWRITE_SLUGS:
|
125 |
+
return $this->check_slug_conflicts_in_post_type_rewrite_rules( $value, $exclude_id );
|
126 |
+
case self::DOMAIN_TAXONOMY_REWRITE_SLUGS:
|
127 |
+
return $this->check_slug_conflicts_in_taxonomy_rewrite_rules( $value, $exclude_id );
|
128 |
+
default:
|
129 |
+
return false;
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Check a slug for conflict with slugs used for taxonomy permalink rewriting.
|
136 |
+
*
|
137 |
+
* @param string $value Value to check.
|
138 |
+
* @param string $exclude_id Taxonomy slug to exclude from checking.
|
139 |
+
*
|
140 |
+
* @return array|bool Conflict information (an associative array with conflicting_id, message) or false when
|
141 |
+
* there's no conflict.
|
142 |
+
* @since 2.1
|
143 |
+
*/
|
144 |
+
private function check_slug_conflicts_in_taxonomy_rewrite_rules( $value, $exclude_id ) {
|
145 |
+
|
146 |
+
// Merge currently registered taxonomies (which might include some from other plugins) and
|
147 |
+
// Types settings (which might include deactivated taxonomies).
|
148 |
+
$taxonomy_settings = get_option( WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, array() );
|
149 |
+
if( !is_array( $taxonomy_settings ) ) {
|
150 |
+
return false;
|
151 |
+
}
|
152 |
+
$taxonomy_settings = array_merge( $taxonomy_settings, get_taxonomies( array(), 'objects' ) );
|
153 |
+
|
154 |
+
foreach( $taxonomy_settings as $taxonomy ) {
|
155 |
+
|
156 |
+
// Read information from the taxonomy object or Types settings
|
157 |
+
if( is_object( $taxonomy ) ) {
|
158 |
+
$slug = $taxonomy->name;
|
159 |
+
$rewrite_slug = wpcf_getarr( $taxonomy->rewrite, 'slug' );
|
160 |
+
$is_permalink_rewriting_enabled = !empty( $rewrite_slug );
|
161 |
+
} else {
|
162 |
+
$slug = wpcf_getarr( $taxonomy, 'slug' );
|
163 |
+
$is_permalink_rewriting_enabled = (bool) wpcf_getnest( $taxonomy, array( 'rewrite', 'enabled' ) );
|
164 |
+
$rewrite_slug = wpcf_getnest( $taxonomy, array( 'rewrite', 'slug' ) );
|
165 |
+
}
|
166 |
+
|
167 |
+
if( $slug == $exclude_id ) {
|
168 |
+
continue;
|
169 |
+
}
|
170 |
+
|
171 |
+
// Detect if there is a conflict
|
172 |
+
$is_custom_slug_used = !empty( $rewrite_slug );
|
173 |
+
|
174 |
+
if( $is_permalink_rewriting_enabled ) {
|
175 |
+
$conflict_candidate = ( $is_custom_slug_used ? $rewrite_slug : $slug );
|
176 |
+
|
177 |
+
if( $conflict_candidate == $value ) {
|
178 |
+
|
179 |
+
$conflict = array(
|
180 |
+
'conflicting_id' => $slug,
|
181 |
+
'message' => sprintf(
|
182 |
+
__( 'The same value is already used in permalink rewrite rules for the taxonomy "%s". Using it again can cause issues with permalinks.', 'wpcf' ),
|
183 |
+
esc_html( $slug )
|
184 |
+
)
|
185 |
+
);
|
186 |
+
|
187 |
+
return $conflict;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
}
|
191 |
+
|
192 |
+
// No conflicts found.
|
193 |
+
return false;
|
194 |
+
}
|
195 |
+
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Check a slug for conflict with slugs used for post type permalink rewriting.
|
199 |
+
*
|
200 |
+
* @param string $value Value to check.
|
201 |
+
* @param string $exclude_id Post type slug to exclude from checking.
|
202 |
+
*
|
203 |
+
* @return array|bool Conflict information (an associative array with conflicting_id, message) or false when
|
204 |
+
* there's no conflict.
|
205 |
+
* @since 2.1
|
206 |
+
*/
|
207 |
+
private function check_slug_conflicts_in_post_type_rewrite_rules( $value, $exclude_id ) {
|
208 |
+
|
209 |
+
// Merge currently registered post types (which might include some from other plugins) and
|
210 |
+
// Types settings (which might include deactivated post types).
|
211 |
+
$post_type_settings = get_option( WPCF_OPTION_NAME_CUSTOM_TYPES, array() );
|
212 |
+
if( !is_array( $post_type_settings ) ) {
|
213 |
+
return false;
|
214 |
+
}
|
215 |
+
$post_type_settings = array_merge( $post_type_settings, get_post_types( array(), 'objects' ) );
|
216 |
+
|
217 |
+
foreach( $post_type_settings as $post_type ) {
|
218 |
+
|
219 |
+
// Read information from the post type object or Types settings
|
220 |
+
if( is_object( $post_type ) ) {
|
221 |
+
$slug = $post_type->name;
|
222 |
+
$is_permalink_rewriting_enabled = (bool) wpcf_getarr( $post_type->rewrite, 'enabled' );
|
223 |
+
$rewrite_slug = wpcf_getarr( $post_type->rewrite, 'slug' );
|
224 |
+
$is_custom_slug_used = !empty( $rewrite_slug );
|
225 |
+
} else {
|
226 |
+
$slug = wpcf_getarr( $post_type, 'slug' );
|
227 |
+
$is_permalink_rewriting_enabled = (bool) wpcf_getnest( $post_type, array( 'rewrite', 'enabled' ) );
|
228 |
+
$is_custom_slug_used = ( wpcf_getnest( $post_type, array( 'rewrite', 'custom' ) ) == 'custom' );
|
229 |
+
$rewrite_slug = wpcf_getnest( $post_type, array( 'rewrite', 'slug' ) );
|
230 |
+
}
|
231 |
+
|
232 |
+
if( $slug == $exclude_id ) {
|
233 |
+
continue;
|
234 |
+
}
|
235 |
+
|
236 |
+
if( $is_permalink_rewriting_enabled ) {
|
237 |
+
$conflict_candidate = ( $is_custom_slug_used ? $rewrite_slug : $slug );
|
238 |
+
|
239 |
+
if( $conflict_candidate == $value ) {
|
240 |
+
|
241 |
+
$conflict = array(
|
242 |
+
'conflicting_id' => $slug,
|
243 |
+
'message' => sprintf(
|
244 |
+
__( 'The same value is already used in permalink rewrite rules for the custom post type "%s". Using it again can cause issues with permalinks.', 'wpcf' ),
|
245 |
+
esc_html( $slug )
|
246 |
+
)
|
247 |
+
);
|
248 |
+
|
249 |
+
return $conflict;
|
250 |
+
}
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
// No conflicts found.
|
255 |
+
return false;
|
256 |
+
}
|
257 |
+
|
258 |
+
}
|
application/controllers/ajax/handler/field_control_action.php
ADDED
@@ -0,0 +1,364 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Handle action with field definitions on the Field Control page.
|
5 |
+
*
|
6 |
+
* @since 2.1
|
7 |
+
*/
|
8 |
+
final class Types_Ajax_Handler_Field_Control_Action extends Types_Ajax_Handler_Abstract {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* @inheritdoc
|
13 |
+
*
|
14 |
+
* todo document
|
15 |
+
*
|
16 |
+
* @param array $arguments
|
17 |
+
*/
|
18 |
+
public function process_call( $arguments ) {
|
19 |
+
|
20 |
+
$am = $this->get_am();
|
21 |
+
|
22 |
+
$am->ajax_begin( array( 'nonce' => $am->get_action_js_name( Types_Ajax::CALLBACK_FIELD_CONTROL_ACTION ) ) );
|
23 |
+
|
24 |
+
// Read and validate input
|
25 |
+
$field_action = wpcf_getpost( 'field_action' );
|
26 |
+
$fields = wpcf_getpost( 'fields' );
|
27 |
+
|
28 |
+
$current_domain = wpcf_getpost( 'domain', null, Types_Field_Utils::get_domains() );
|
29 |
+
if( null == $current_domain ) {
|
30 |
+
$am->ajax_finish( array( 'message' => __( 'Wrong field domain.', 'wpcf' ) ), false );
|
31 |
+
}
|
32 |
+
|
33 |
+
if( !is_array( $fields ) || empty( $fields ) ) {
|
34 |
+
$am->ajax_finish( array( 'message' => __( 'No fields have been selected.', 'wpcf' ) ), false );
|
35 |
+
}
|
36 |
+
|
37 |
+
$action_specific_data = wpcf_getpost( 'action_specific', array() );
|
38 |
+
|
39 |
+
// Process fields one by one
|
40 |
+
$errors = array();
|
41 |
+
$results = array();
|
42 |
+
foreach( $fields as $field ) {
|
43 |
+
|
44 |
+
$result = $this->single_field_control_action( $field_action, $field, $current_domain, $action_specific_data );
|
45 |
+
|
46 |
+
if( is_array( $result ) ) {
|
47 |
+
// Array of errors
|
48 |
+
$errors = array_merge( $errors, $result );
|
49 |
+
} else if( $result instanceof WP_Error ) {
|
50 |
+
// Single error
|
51 |
+
$errors[] = $result;
|
52 |
+
} else if( false == $result ) {
|
53 |
+
// This should not happen...!
|
54 |
+
$errors[] = new WP_Error( 0, __( 'An unexpected error happened while processing the request.', 'wpcf' ) );
|
55 |
+
} else {
|
56 |
+
// Success
|
57 |
+
|
58 |
+
// Save the field definition model as a result if we got a whole definition
|
59 |
+
if( $result instanceof WPCF_Field_Definition ) {
|
60 |
+
$result = $result->to_json();
|
61 |
+
}
|
62 |
+
|
63 |
+
$results[ wpcf_getarr( $field, 'slug' ) ] = $result;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
$data = array( 'results' => $results );
|
68 |
+
$is_success = empty( $errors );
|
69 |
+
|
70 |
+
if( !$is_success ) {
|
71 |
+
$error_messages = array();
|
72 |
+
/** @var WP_Error $error */
|
73 |
+
foreach( $errors as $error ) {
|
74 |
+
$error_messages[] = $error->get_error_message();
|
75 |
+
}
|
76 |
+
$data['messages'] = $error_messages;
|
77 |
+
}
|
78 |
+
|
79 |
+
$am->ajax_finish( $data, $is_success );
|
80 |
+
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @param string $action_name One of the allowed action names: 'manage_with_types'
|
86 |
+
* @param array $field Field definition model passed from JS.
|
87 |
+
* @param string $domain Field domain name.
|
88 |
+
* @param mixed $action_specific_data
|
89 |
+
* @return bool|mixed|null|WP_Error|WP_Error[]|WPCF_Field_Definition An error, array of errors, boolean indicating
|
90 |
+
* success or a result value to be passed back to JS.
|
91 |
+
* @since 2.0
|
92 |
+
*/
|
93 |
+
private function single_field_control_action( $action_name, $field, $domain, $action_specific_data ) {
|
94 |
+
|
95 |
+
$field_slug = wpcf_getarr( $field, 'slug' );
|
96 |
+
|
97 |
+
switch ( $action_name ) {
|
98 |
+
|
99 |
+
case 'manage_with_types':
|
100 |
+
return $this->start_managing_field( wpcf_getarr( $field, 'metaKey' ), $domain );
|
101 |
+
|
102 |
+
case 'stop_managing_with_types':
|
103 |
+
return $this->stop_managing_field( $field_slug, $domain );
|
104 |
+
|
105 |
+
case 'change_group_assignment':
|
106 |
+
return $this->change_assignment_to_groups( $field_slug, $domain, $action_specific_data );
|
107 |
+
|
108 |
+
case 'delete_field':
|
109 |
+
return $this->delete_field( $field_slug, $domain );
|
110 |
+
|
111 |
+
case 'change_field_type':
|
112 |
+
return $this->change_field_type( $field_slug, $domain, $action_specific_data );
|
113 |
+
|
114 |
+
case 'change_field_cardinality':
|
115 |
+
return $this->change_field_cardinality( $field_slug, $domain, $action_specific_data );
|
116 |
+
|
117 |
+
default:
|
118 |
+
return new WP_Error( 42, __( 'Invalid action name.', 'wpcf' ) );
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Start managing a field with given meta_key with Types.
|
125 |
+
*
|
126 |
+
* Looks if there already exists a field definition that uses the meta_key. If yes, it's most probably a "disabled"
|
127 |
+
* one, that is stored only for the possibility of later "re-activation" (which is happening now). In that case,
|
128 |
+
* the field definition will be simply updated.
|
129 |
+
*
|
130 |
+
* If there is no matching field definition whatsoever, it will be created with in some default manner.
|
131 |
+
* Check WPCF_Field_Definition_Factory::create_field_definition_for_existing_fields() for details.
|
132 |
+
*
|
133 |
+
* AJAX callback helper only, do not use elsewhere.
|
134 |
+
*
|
135 |
+
* @param string $meta_key
|
136 |
+
* @param string $domain Field domain
|
137 |
+
* @return false|null|WPCF_Field_Definition The updated/newly created field definition or falsy value on failure.
|
138 |
+
* @since 2.0
|
139 |
+
*/
|
140 |
+
public function start_managing_field( $meta_key, $domain ) {
|
141 |
+
$factory = WPCF_Field_Definition_Factory::get_factory_by_domain( $domain );
|
142 |
+
$definition = $factory->meta_key_belongs_to_types_field( $meta_key, 'definition' );
|
143 |
+
if( null == $definition ) {
|
144 |
+
$result = $factory->create_field_definition_for_existing_fields( $meta_key );
|
145 |
+
if( false != $result ) {
|
146 |
+
return $factory->load_field_definition( $result );
|
147 |
+
} else {
|
148 |
+
return false;
|
149 |
+
}
|
150 |
+
} else {
|
151 |
+
$is_success = $definition->set_types_management_status( true );
|
152 |
+
return ( $is_success ? $definition : false );
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Stop managing a field with given field slug by Types.
|
159 |
+
*
|
160 |
+
* AJAX callback helper only, do not use elsewhere.
|
161 |
+
*
|
162 |
+
* @param string $field_slug
|
163 |
+
* @param string $domain Field domain.
|
164 |
+
* @return WP_Error|WPCF_Field_Definition Error with a user-friendly message on failure
|
165 |
+
* or the updated definition on success.
|
166 |
+
* @since 2.0
|
167 |
+
*/
|
168 |
+
public static function stop_managing_field( $field_slug, $domain ) {
|
169 |
+
|
170 |
+
$factory = WPCF_Field_Definition_Factory::get_factory_by_domain( $domain );
|
171 |
+
$definition = $factory->load_field_definition( $field_slug );
|
172 |
+
|
173 |
+
if( null == $definition ) {
|
174 |
+
|
175 |
+
return new WP_Error( 42, sprintf( __( 'Field definition for field "%s" not found in options.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
176 |
+
|
177 |
+
} else {
|
178 |
+
|
179 |
+
$is_success = $definition->set_types_management_status( false );
|
180 |
+
|
181 |
+
if( $is_success ) {
|
182 |
+
return $definition;
|
183 |
+
} else {
|
184 |
+
return new WP_Error(
|
185 |
+
42,
|
186 |
+
sprintf(
|
187 |
+
__( 'Unable to set types management status for field definition "%s".', 'wpcf' ),
|
188 |
+
sanitize_text_field( $field_slug )
|
189 |
+
)
|
190 |
+
);
|
191 |
+
}
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Change which groups is a field definition associated with.
|
198 |
+
*
|
199 |
+
* AJAX callback helper only, do not use elsewhere.
|
200 |
+
*
|
201 |
+
* @param string $field_slug Field definition slug.
|
202 |
+
* @param string $domain Field domain
|
203 |
+
* @param string[][] $groups Action-specific data passed through AJAX. Array containing a single key 'group_slugs',
|
204 |
+
* containing an array of field group slugs.
|
205 |
+
*
|
206 |
+
* @return WP_Error|WPCF_Field_Definition The updated field definition on success or an error object.
|
207 |
+
* @since 2.0
|
208 |
+
*/
|
209 |
+
public function change_assignment_to_groups( $field_slug, $domain, $groups ) {
|
210 |
+
$factory = WPCF_Field_Definition_Factory::get_factory_by_domain( $domain );
|
211 |
+
$definition = $factory->load_field_definition( $field_slug );
|
212 |
+
if( null == $definition ) {
|
213 |
+
return new WP_Error( 42, sprintf( __( 'Field definition for field "%s" not found in options.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
214 |
+
}
|
215 |
+
$new_groups = wpcf_ensarr( wpcf_getarr( $groups, 'group_slugs' ) );
|
216 |
+
$associated_groups = $definition->get_associated_groups();
|
217 |
+
$is_success = true;
|
218 |
+
foreach( $associated_groups as $group ) {
|
219 |
+
if( !in_array( $group->get_slug(), $new_groups ) ) {
|
220 |
+
$is_success = $is_success && $group->remove_field_definition( $definition );
|
221 |
+
}
|
222 |
+
}
|
223 |
+
$group_factory = $factory->get_group_factory();
|
224 |
+
foreach( $new_groups as $new_group_slug ) {
|
225 |
+
$new_group = $group_factory->load_field_group( $new_group_slug );
|
226 |
+
if( null != $new_group ) {
|
227 |
+
$is_success = $is_success && $new_group->add_field_definition( $definition );
|
228 |
+
} else {
|
229 |
+
$is_success = false;
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
if( $is_success ) {
|
234 |
+
return $definition;
|
235 |
+
} else {
|
236 |
+
return new WP_Error();
|
237 |
+
}
|
238 |
+
}
|
239 |
+
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Delete a field definition and all values of the field within given domain.
|
243 |
+
*
|
244 |
+
* @param string $field_slug
|
245 |
+
* @param string $domain
|
246 |
+
* @return bool|WP_Error True for success, false or WP_Error on error.
|
247 |
+
* @since 2.0
|
248 |
+
*/
|
249 |
+
public function delete_field( $field_slug, $domain ) {
|
250 |
+
|
251 |
+
$factory = WPCF_Field_Definition_Factory::get_factory_by_domain( $domain );
|
252 |
+
$definition = $factory->load_field_definition( $field_slug );
|
253 |
+
if( null == $definition ) {
|
254 |
+
return new WP_Error( 42, sprintf( __( 'Field definition for field "%s" not found in options.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
255 |
+
} else if( ! $definition->is_managed_by_types() ) {
|
256 |
+
return new WP_Error( 42, sprintf( __( 'Field "%s" will not be deleted because it is not managed by Types.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
257 |
+
}
|
258 |
+
|
259 |
+
$response = $factory->delete_definition( $definition );
|
260 |
+
|
261 |
+
return $response;
|
262 |
+
}
|
263 |
+
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Change a field type for given field definition.
|
267 |
+
*
|
268 |
+
* Performs checks if the conversion is allowed, and if not, generate a proper error message.
|
269 |
+
*
|
270 |
+
* @param string $field_slug
|
271 |
+
* @param string $domain
|
272 |
+
* @param string[] $arguments Needs to contain the 'field_type' key with target type slug.
|
273 |
+
* @return false|WP_Error|WPCF_Field_Definition The updated definition on succes, error/false otherwise.
|
274 |
+
* @since 2.0
|
275 |
+
*/
|
276 |
+
public function change_field_type( $field_slug, $domain, $arguments ) {
|
277 |
+
|
278 |
+
// Load all information we need, fail if it doesn't exist.
|
279 |
+
$factory = WPCF_Field_Definition_Factory::get_factory_by_domain( $domain );
|
280 |
+
$definition = $factory->load_field_definition( $field_slug );
|
281 |
+
if( null == $definition ) {
|
282 |
+
return new WP_Error( 42, sprintf( __( 'Field definition for field "%s" not found in options.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
283 |
+
} else if( ! $definition->is_managed_by_types() ) {
|
284 |
+
return new WP_Error( 42, sprintf( __( 'Field "%s" will not be converted because it is not managed by Types.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
285 |
+
}
|
286 |
+
|
287 |
+
$type_slug = wpcf_getarr( $arguments, 'field_type' );
|
288 |
+
$target_type = Types_Field_Type_Definition_Factory::get_instance()->load_field_type_definition( $type_slug );
|
289 |
+
if( null == $target_type ) {
|
290 |
+
return new WP_Error( 42, sprintf( __( 'Unknown field type "%s".', 'wpcf' ), $type_slug ) );
|
291 |
+
}
|
292 |
+
|
293 |
+
// Check if we can convert between types
|
294 |
+
$is_conversion_possible = Types_Field_Type_Converter::get_instance()->is_conversion_possible( $definition->get_type(), $target_type );
|
295 |
+
if( !$is_conversion_possible ) {
|
296 |
+
return new WP_Error(
|
297 |
+
42,
|
298 |
+
sprintf(
|
299 |
+
__( 'Conversion from type "%s" to "%s" is currently not allowed.', 'wpcf' ),
|
300 |
+
$definition->get_type()->get_display_name(),
|
301 |
+
$target_type->get_display_name()
|
302 |
+
)
|
303 |
+
);
|
304 |
+
}
|
305 |
+
|
306 |
+
// Check if we can do the conversion with current field's cardinality
|
307 |
+
$is_cardinality_sustainable = ( ! $definition->get_is_repetitive() || $target_type->can_be_repetitive() );
|
308 |
+
if( !$is_cardinality_sustainable ) {
|
309 |
+
return new WP_Error(
|
310 |
+
42,
|
311 |
+
sprintf(
|
312 |
+
__( 'Field "%s" cannot be converted from "%s" to "%s" because it is repetitive and the target type doesn\'t support that.', 'wpcf' ),
|
313 |
+
$definition->get_display_name(),
|
314 |
+
$definition->get_type()->get_display_name(),
|
315 |
+
$target_type->get_display_name()
|
316 |
+
)
|
317 |
+
);
|
318 |
+
}
|
319 |
+
|
320 |
+
// All is fine, proceed.
|
321 |
+
$result = $definition->change_type( $target_type );
|
322 |
+
if( $result ) {
|
323 |
+
return $definition;
|
324 |
+
} else {
|
325 |
+
// Something unexpected went wrong.
|
326 |
+
return false;
|
327 |
+
}
|
328 |
+
}
|
329 |
+
|
330 |
+
|
331 |
+
/**
|
332 |
+
* Change cardinality of given field, if it is permitted by its type.
|
333 |
+
*
|
334 |
+
* @param string $field_slug Field definition slug.
|
335 |
+
* @param string $domain Field domain.
|
336 |
+
* @param string[] $arguments Needs to contain the 'target_cardinality' key with 'single'|'repetitive' value.
|
337 |
+
* @return bool|WP_Error|WPCF_Field_Definition The updated definition on succes, error/false otherwise.
|
338 |
+
* @since 2.0
|
339 |
+
*/
|
340 |
+
public function change_field_cardinality( $field_slug, $domain, $arguments ) {
|
341 |
+
$factory = WPCF_Field_Definition_Factory::get_factory_by_domain( $domain );
|
342 |
+
$definition = $factory->load_field_definition( $field_slug );
|
343 |
+
if( null == $definition ) {
|
344 |
+
return new WP_Error( 42, sprintf( __( 'Field definition for field "%s" not found in options.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
345 |
+
} else if( ! $definition->is_managed_by_types() ) {
|
346 |
+
return new WP_Error( 42, sprintf( __( 'Field "%s" will not be converted because it is not managed by Types.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
347 |
+
}
|
348 |
+
|
349 |
+
$target_cardinality = wpcf_getarr( $arguments, 'target_cardinality', null, array( 'single', 'repetitive' ) );
|
350 |
+
if( null == $target_cardinality ) {
|
351 |
+
return false;
|
352 |
+
}
|
353 |
+
$set_as_repetitive = ( 'repetitive' == $target_cardinality );
|
354 |
+
|
355 |
+
$result = $definition->set_is_repetitive( $set_as_repetitive );
|
356 |
+
|
357 |
+
if( $result ) {
|
358 |
+
return $definition;
|
359 |
+
} else {
|
360 |
+
return false;
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
}
|
application/controllers/ajax/handler/settings_action.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Save handler for types settings
|
5 |
+
* Settings are defined in Controller/Page/Extension/Settings
|
6 |
+
*
|
7 |
+
* @since 2.1
|
8 |
+
*/
|
9 |
+
final class Types_Ajax_Handler_Settings_Action extends Types_Ajax_Handler_Abstract {
|
10 |
+
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @inheritdoc
|
14 |
+
*
|
15 |
+
* @param array $arguments
|
16 |
+
*/
|
17 |
+
public function process_call( $arguments ) {
|
18 |
+
|
19 |
+
$am = $this->get_am();
|
20 |
+
|
21 |
+
$am->ajax_begin( array( 'nonce' => $am->get_action_js_name( Types_Ajax::CALLBACK_SETTINGS_ACTION ) ) );
|
22 |
+
|
23 |
+
$setting = wpcf_getpost( 'setting' );
|
24 |
+
$value = wpcf_getpost( 'setting_value' );
|
25 |
+
|
26 |
+
if( !is_array( $value ) ) {
|
27 |
+
parse_str( $value, $value );
|
28 |
+
$value = array_pop( $value );
|
29 |
+
}
|
30 |
+
|
31 |
+
// use toolset settings if available
|
32 |
+
if( class_exists( 'Toolset_Settings' )
|
33 |
+
&& method_exists( 'Toolset_Settings', 'get_instance' ) ) {
|
34 |
+
$toolset_settings = Toolset_Settings::get_instance();
|
35 |
+
|
36 |
+
if( method_exists( $toolset_settings, 'save' ) ) {
|
37 |
+
$toolset_settings[$setting] = $value;
|
38 |
+
$toolset_settings->save();
|
39 |
+
$am->ajax_finish( 'success', true );
|
40 |
+
}
|
41 |
+
} else {
|
42 |
+
update_option( $setting, $value );
|
43 |
+
$am->ajax_finish( 'success', true );
|
44 |
+
}
|
45 |
+
|
46 |
+
// default toolset setting error will be used
|
47 |
+
// todo throw specific error
|
48 |
+
$am->ajax_finish( array('error'), false );
|
49 |
+
}
|
50 |
+
}
|
application/controllers/ajax/handler_interface.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Interface for an AJAX call handler.
|
5 |
+
*
|
6 |
+
* @since 2.1
|
7 |
+
*/
|
8 |
+
interface Types_Ajax_Handler_Interface {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Types_Ajax_Handler_Interface constructor.
|
12 |
+
*
|
13 |
+
* @param $ajax_manager Types_Ajax instance
|
14 |
+
*/
|
15 |
+
function __construct( $ajax_manager );
|
16 |
+
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @param array $arguments Original action arguments.
|
20 |
+
* @return void
|
21 |
+
*/
|
22 |
+
function process_call( $arguments );
|
23 |
+
|
24 |
+
}
|
application/controllers/asset/help_tab_loader.php
CHANGED
@@ -123,9 +123,11 @@ final class Types_Asset_Help_Tab_Loader {
|
|
123 |
return null;
|
124 |
}
|
125 |
|
|
|
|
|
126 |
return array(
|
127 |
'title' => wpcf_getarr( $config, 'title' ),
|
128 |
-
'content' => $
|
129 |
);
|
130 |
}
|
131 |
|
123 |
return null;
|
124 |
}
|
125 |
|
126 |
+
$twig = $this->get_twig();
|
127 |
+
|
128 |
return array(
|
129 |
'title' => wpcf_getarr( $config, 'title' ),
|
130 |
+
'content' => $twig->render( wpcf_getarr( $config, 'template' ), wpcf_getarr( $config, 'context' ) )
|
131 |
);
|
132 |
}
|
133 |
|
application/controllers/asset/manager.php
CHANGED
@@ -8,21 +8,28 @@
|
|
8 |
* @since 2.0
|
9 |
*/
|
10 |
final class Types_Asset_Manager extends Toolset_Assets_Manager {
|
11 |
-
|
12 |
-
const SCRIPT_ADJUST_MENU_LINK = 'types-adjust-menu-link';
|
13 |
|
14 |
const SCRIPT_KNOCKOUT = 'knockout';
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
// Registered in Toolset common
|
17 |
|
18 |
const SCRIPT_DIALOG_BOXES = 'ddl-dialog-boxes';
|
19 |
|
20 |
const SCRIPT_UTILS = 'toolset-utils';
|
|
|
|
|
21 |
|
22 |
// WordPress Core handles
|
23 |
|
24 |
const STYLE_JQUERY_UI_DIALOG = 'wp-jquery-ui-dialog';
|
25 |
-
|
|
|
26 |
/**
|
27 |
* @return Types_Asset_Manager
|
28 |
*/
|
@@ -38,21 +45,42 @@ final class Types_Asset_Manager extends Toolset_Assets_Manager {
|
|
38 |
|
39 |
protected function __initialize_scripts() {
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
$this->register_script(
|
42 |
self::SCRIPT_ADJUST_MENU_LINK,
|
43 |
TYPES_RELPATH . '/public/page/adjust_submenu_links.js',
|
44 |
array( 'jquery', 'underscore' ),
|
45 |
TYPES_VERSION
|
46 |
);
|
47 |
-
|
48 |
-
|
49 |
$this->register_script(
|
50 |
-
self::
|
51 |
-
TYPES_RELPATH . '/
|
52 |
-
array(),
|
53 |
-
|
54 |
);
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
return parent::__initialize_scripts();
|
57 |
}
|
58 |
|
8 |
* @since 2.0
|
9 |
*/
|
10 |
final class Types_Asset_Manager extends Toolset_Assets_Manager {
|
|
|
|
|
11 |
|
12 |
const SCRIPT_KNOCKOUT = 'knockout';
|
13 |
+
|
14 |
+
const SCRIPT_ADJUST_MENU_LINK = 'types-adjust-menu-link';
|
15 |
+
const SCRIPT_SLUG_CONFLICT_CHECKER = 'types-slug-conflict-checker';
|
16 |
+
|
17 |
+
const SCRIPT_PAGE_EDIT_POST_TYPE = 'types-page-edit-post-type';
|
18 |
+
const SCRIPT_PAGE_EDIT_TAXONOMY = 'types-page-edit-taxonomy';
|
19 |
+
|
20 |
// Registered in Toolset common
|
21 |
|
22 |
const SCRIPT_DIALOG_BOXES = 'ddl-dialog-boxes';
|
23 |
|
24 |
const SCRIPT_UTILS = 'toolset-utils';
|
25 |
+
|
26 |
+
const SCRIPT_HEADJS = 'headjs';
|
27 |
|
28 |
// WordPress Core handles
|
29 |
|
30 |
const STYLE_JQUERY_UI_DIALOG = 'wp-jquery-ui-dialog';
|
31 |
+
|
32 |
+
|
33 |
/**
|
34 |
* @return Types_Asset_Manager
|
35 |
*/
|
45 |
|
46 |
protected function __initialize_scripts() {
|
47 |
|
48 |
+
$this->register_script(
|
49 |
+
self::SCRIPT_KNOCKOUT,
|
50 |
+
TYPES_RELPATH . '/library/knockout/knockout-3.4.0.debug.js',
|
51 |
+
array(),
|
52 |
+
'3.4.0'
|
53 |
+
);
|
54 |
+
|
55 |
$this->register_script(
|
56 |
self::SCRIPT_ADJUST_MENU_LINK,
|
57 |
TYPES_RELPATH . '/public/page/adjust_submenu_links.js',
|
58 |
array( 'jquery', 'underscore' ),
|
59 |
TYPES_VERSION
|
60 |
);
|
61 |
+
|
|
|
62 |
$this->register_script(
|
63 |
+
self::SCRIPT_SLUG_CONFLICT_CHECKER,
|
64 |
+
TYPES_RELPATH . '/public/js/slug_conflict_checker.js',
|
65 |
+
array( 'jquery', 'underscore' ),
|
66 |
+
TYPES_VERSION
|
67 |
);
|
68 |
|
69 |
+
$this->register_script(
|
70 |
+
self::SCRIPT_PAGE_EDIT_POST_TYPE,
|
71 |
+
TYPES_RELPATH . '/public/page/edit_post_type/main.js',
|
72 |
+
array( 'jquery', 'underscore', self::SCRIPT_SLUG_CONFLICT_CHECKER, self::SCRIPT_UTILS ),
|
73 |
+
TYPES_VERSION
|
74 |
+
);
|
75 |
+
|
76 |
+
$this->register_script(
|
77 |
+
self::SCRIPT_PAGE_EDIT_TAXONOMY,
|
78 |
+
TYPES_RELPATH . '/public/page/edit_taxonomy/main.js',
|
79 |
+
array( 'jquery', 'underscore', self::SCRIPT_SLUG_CONFLICT_CHECKER, self::SCRIPT_UTILS ),
|
80 |
+
TYPES_VERSION
|
81 |
+
);
|
82 |
+
|
83 |
+
|
84 |
return parent::__initialize_scripts();
|
85 |
}
|
86 |
|
application/controllers/dialog_box.php
CHANGED
@@ -75,11 +75,16 @@ class Types_Dialog_Box extends Toolset_DialogBoxes {
|
|
75 |
* @since 2.0
|
76 |
*/
|
77 |
protected function late_register_assets() {
|
|
|
|
|
|
|
|
|
78 |
// Get script and styles from parent methods, and register them manually.
|
79 |
$styles = $this->register_styles( array() );
|
80 |
foreach( $styles as $style ) {
|
81 |
Types_Asset_Manager::get_instance()->register_toolset_style( $style );
|
82 |
}
|
|
|
83 |
|
84 |
$scripts = $this->register_scripts( array() );
|
85 |
foreach( $scripts as $script ) {
|
75 |
* @since 2.0
|
76 |
*/
|
77 |
protected function late_register_assets() {
|
78 |
+
/*
|
79 |
+
* Toolset_DialogBoxes::register_styles() no longer exists
|
80 |
+
* https://git.onthegosystems.com/toolset/toolset-common/commit/cb176128ac8382cebbad46a39848b4c76fdcc7a7
|
81 |
+
*
|
82 |
// Get script and styles from parent methods, and register them manually.
|
83 |
$styles = $this->register_styles( array() );
|
84 |
foreach( $styles as $style ) {
|
85 |
Types_Asset_Manager::get_instance()->register_toolset_style( $style );
|
86 |
}
|
87 |
+
*/
|
88 |
|
89 |
$scripts = $this->register_scripts( array() );
|
90 |
foreach( $scripts as $script ) {
|
application/controllers/embedded.php
CHANGED
@@ -21,8 +21,10 @@ final class Types_Embedded {
|
|
21 |
|
22 |
public static function initialize() {
|
23 |
if( file_exists( TYPES_ABSPATH . '/embedded.lock' )
|
24 |
-
|| ( defined( 'TYPES_EMBEDDED') && TYPES_EMBEDDED === true )
|
|
|
25 |
new self();
|
|
|
26 |
}
|
27 |
|
28 |
}
|
21 |
|
22 |
public static function initialize() {
|
23 |
if( file_exists( TYPES_ABSPATH . '/embedded.lock' )
|
24 |
+
|| ( defined( 'TYPES_EMBEDDED') && TYPES_EMBEDDED === true )
|
25 |
+
) {
|
26 |
new self();
|
27 |
+
}
|
28 |
}
|
29 |
|
30 |
}
|
application/controllers/field/utils.php
CHANGED
@@ -29,8 +29,14 @@ final class Types_Field_Utils {
|
|
29 |
public static function get_domains() {
|
30 |
return array( self::DOMAIN_POSTS, self::DOMAIN_USERS, self::DOMAIN_TERMS );
|
31 |
}
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
public static function get_definition_factory_by_domain( $domain ) {
|
35 |
switch( $domain ) {
|
36 |
case self::DOMAIN_POSTS:
|
@@ -49,23 +55,32 @@ final class Types_Field_Utils {
|
|
49 |
* For a given field domain, return the appropriate field group factory instance.
|
50 |
*
|
51 |
* @param string $domain
|
52 |
-
*
|
|
|
53 |
* @since 2.0
|
|
|
54 |
*/
|
55 |
public static function get_group_factory_by_domain( $domain ) {
|
56 |
switch( $domain ) {
|
57 |
case self::DOMAIN_POSTS:
|
58 |
-
return
|
59 |
case self::DOMAIN_USERS:
|
60 |
-
return
|
61 |
case self::DOMAIN_TERMS:
|
62 |
-
return
|
63 |
default:
|
64 |
throw new InvalidArgumentException( 'Invalid field domain.' );
|
65 |
}
|
66 |
}
|
67 |
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
/**
|
70 |
* Translate a field domain into a "meta_type" value, which is used in field definition arrays.
|
71 |
*
|
@@ -74,12 +89,20 @@ final class Types_Field_Utils {
|
|
74 |
* @since 2.0
|
75 |
*/
|
76 |
public static function domain_to_legacy_meta_type( $domain ) {
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
}
|
84 |
|
85 |
|
@@ -121,7 +144,7 @@ final class Types_Field_Utils {
|
|
121 |
* The groups are expected to belong to the same domain (term/post/user), otherwise problems may occur when
|
122 |
* field slugs conflict.
|
123 |
*
|
124 |
-
* @param
|
125 |
* @return WPCF_Field_Definition[]
|
126 |
* @since 1.9
|
127 |
*/
|
@@ -136,247 +159,5 @@ final class Types_Field_Utils {
|
|
136 |
}
|
137 |
return $field_definitions;
|
138 |
}
|
139 |
-
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Start managing a field with given meta_key with Types.
|
143 |
-
*
|
144 |
-
* Looks if there already exists a field definition that uses the meta_key. If yes, it's most probably a "disabled"
|
145 |
-
* one, that is stored only for the possibility of later "re-activation" (which is happening now). In that case,
|
146 |
-
* the field definition will be simply updated.
|
147 |
-
*
|
148 |
-
* If there is no matching field definition whatsoever, it will be created with in some default manner.
|
149 |
-
* Check WPCF_Field_Definition_Factory::create_field_definition_for_existing_fields() for details.
|
150 |
-
*
|
151 |
-
* AJAX callback helper only, do not use elsewhere.
|
152 |
-
*
|
153 |
-
* @param string $meta_key
|
154 |
-
* @param string $domain Field domain
|
155 |
-
* @return false|null|WPCF_Field_Definition The updated/newly created field definition or falsy value on failure.
|
156 |
-
* @since 2.0
|
157 |
-
*/
|
158 |
-
public static function start_managing_field( $meta_key, $domain ) {
|
159 |
-
$factory = self::get_definition_factory_by_domain( $domain );
|
160 |
-
$definition = $factory->meta_key_belongs_to_types_field( $meta_key, 'definition' );
|
161 |
-
if( null == $definition ) {
|
162 |
-
$result = $factory->create_field_definition_for_existing_fields( $meta_key );
|
163 |
-
if( false != $result ) {
|
164 |
-
return $factory->load_field_definition( $result );
|
165 |
-
} else {
|
166 |
-
return false;
|
167 |
-
}
|
168 |
-
} else {
|
169 |
-
$is_success = $definition->set_types_management_status( true );
|
170 |
-
return ( $is_success ? $definition : false );
|
171 |
-
}
|
172 |
-
}
|
173 |
-
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Stop managing a field with given field slug by Types.
|
177 |
-
*
|
178 |
-
* AJAX callback helper only, do not use elsewhere.
|
179 |
-
*
|
180 |
-
* @param string $field_slug
|
181 |
-
* @param string $domain Field domain.
|
182 |
-
* @return WP_Error|WPCF_Field_Definition Error with a user-friendly message on failure
|
183 |
-
* or the updated definition on success.
|
184 |
-
* @since 2.0
|
185 |
-
*/
|
186 |
-
public static function stop_managing_field( $field_slug, $domain ) {
|
187 |
-
|
188 |
-
$factory = self::get_definition_factory_by_domain( $domain );
|
189 |
-
$definition = $factory->load_field_definition( $field_slug );
|
190 |
-
|
191 |
-
if( null == $definition ) {
|
192 |
-
|
193 |
-
return new WP_Error( 42, sprintf( __( 'Field definition for field "%s" not found in options.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
194 |
-
|
195 |
-
} else {
|
196 |
-
|
197 |
-
$is_success = $definition->set_types_management_status( false );
|
198 |
-
|
199 |
-
if( $is_success ) {
|
200 |
-
return $definition;
|
201 |
-
} else {
|
202 |
-
return new WP_Error(
|
203 |
-
42,
|
204 |
-
sprintf(
|
205 |
-
__( 'Unable to set types management status for field definition "%s".', 'wpcf' ),
|
206 |
-
sanitize_text_field( $field_slug )
|
207 |
-
)
|
208 |
-
);
|
209 |
-
}
|
210 |
-
}
|
211 |
-
}
|
212 |
-
|
213 |
-
|
214 |
-
/**
|
215 |
-
* Change which groups is a field definition associated with.
|
216 |
-
*
|
217 |
-
* AJAX callback helper only, do not use elsewhere.
|
218 |
-
*
|
219 |
-
* @param string $field_slug Field definition slug.
|
220 |
-
* @param string $domain Field domain
|
221 |
-
* @param string[][] $groups Action-specific data passed through AJAX. Array containing a single key 'group_slugs',
|
222 |
-
* containing an array of field group slugs.
|
223 |
-
*
|
224 |
-
* @return WP_Error|WPCF_Field_Definition The updated field definition on success or an error object.
|
225 |
-
* @since 2.0
|
226 |
-
*/
|
227 |
-
public static function change_assignment_to_groups( $field_slug, $domain, $groups ) {
|
228 |
-
$factory = Types_Field_Utils::get_definition_factory_by_domain( $domain );
|
229 |
-
$definition = $factory->load_field_definition( $field_slug );
|
230 |
-
if( null == $definition ) {
|
231 |
-
return new WP_Error( 42, sprintf( __( 'Field definition for field "%s" not found in options.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
232 |
-
}
|
233 |
-
$new_groups = wpcf_ensarr( wpcf_getarr( $groups, 'group_slugs' ) );
|
234 |
-
$associated_groups = $definition->get_associated_groups();
|
235 |
-
$is_success = true;
|
236 |
-
foreach( $associated_groups as $group ) {
|
237 |
-
if( !in_array( $group->get_slug(), $new_groups ) ) {
|
238 |
-
$is_success = $is_success && $group->remove_field_definition( $definition );
|
239 |
-
}
|
240 |
-
}
|
241 |
-
$group_factory = $factory->get_group_factory();
|
242 |
-
foreach( $new_groups as $new_group_slug ) {
|
243 |
-
$new_group = $group_factory->load_field_group( $new_group_slug );
|
244 |
-
if( null != $new_group ) {
|
245 |
-
$is_success = $is_success && $new_group->add_field_definition( $definition );
|
246 |
-
} else {
|
247 |
-
$is_success = false;
|
248 |
-
}
|
249 |
-
}
|
250 |
-
|
251 |
-
if( $is_success ) {
|
252 |
-
return $definition;
|
253 |
-
} else {
|
254 |
-
return new WP_Error();
|
255 |
-
}
|
256 |
-
}
|
257 |
-
|
258 |
-
|
259 |
-
/**
|
260 |
-
* Delete a field definition and all values of the field within given domain.
|
261 |
-
*
|
262 |
-
* @param string $field_slug
|
263 |
-
* @param string $domain
|
264 |
-
* @return bool|WP_Error True for success, false or WP_Error on error.
|
265 |
-
* @since 2.0
|
266 |
-
*/
|
267 |
-
public static function delete_field( $field_slug, $domain ) {
|
268 |
-
|
269 |
-
$factory = Types_Field_Utils::get_definition_factory_by_domain( $domain );
|
270 |
-
$definition = $factory->load_field_definition( $field_slug );
|
271 |
-
if( null == $definition ) {
|
272 |
-
return new WP_Error( 42, sprintf( __( 'Field definition for field "%s" not found in options.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
273 |
-
} else if( ! $definition->is_managed_by_types() ) {
|
274 |
-
return new WP_Error( 42, sprintf( __( 'Field "%s" will not be deleted because it is not managed by Types.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
275 |
-
}
|
276 |
-
|
277 |
-
$response = $factory->delete_definition( $definition );
|
278 |
-
|
279 |
-
return $response;
|
280 |
-
}
|
281 |
-
|
282 |
-
|
283 |
-
/**
|
284 |
-
* Change a field type for given field definition.
|
285 |
-
*
|
286 |
-
* Performs checks if the conversion is allowed, and if not, generate a proper error message.
|
287 |
-
*
|
288 |
-
* @param string $field_slug
|
289 |
-
* @param string $domain
|
290 |
-
* @param string[] $arguments Needs to contain the 'field_type' key with target type slug.
|
291 |
-
* @return false|WP_Error|WPCF_Field_Definition The updated definition on succes, error/false otherwise.
|
292 |
-
* @since 2.0
|
293 |
-
*/
|
294 |
-
public static function change_field_type( $field_slug, $domain, $arguments ) {
|
295 |
-
|
296 |
-
// Load all information we need, fail if it doesn't exist.
|
297 |
-
$factory = Types_Field_Utils::get_definition_factory_by_domain( $domain );
|
298 |
-
$definition = $factory->load_field_definition( $field_slug );
|
299 |
-
if( null == $definition ) {
|
300 |
-
return new WP_Error( 42, sprintf( __( 'Field definition for field "%s" not found in options.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
301 |
-
} else if( ! $definition->is_managed_by_types() ) {
|
302 |
-
return new WP_Error( 42, sprintf( __( 'Field "%s" will not be converted because it is not managed by Types.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
303 |
-
}
|
304 |
-
|
305 |
-
$type_slug = wpcf_getarr( $arguments, 'field_type' );
|
306 |
-
$target_type = Types_Field_Type_Definition_Factory::get_instance()->load_field_type_definition( $type_slug );
|
307 |
-
if( null == $target_type ) {
|
308 |
-
return new WP_Error( 42, sprintf( __( 'Unknown field type "%s".', 'wpcf' ), $type_slug ) );
|
309 |
-
}
|
310 |
-
|
311 |
-
// Check if we can convert between types
|
312 |
-
$is_conversion_possible = Types_Field_Type_Converter::get_instance()->is_conversion_possible( $definition->get_type(), $target_type );
|
313 |
-
if( !$is_conversion_possible ) {
|
314 |
-
return new WP_Error(
|
315 |
-
42,
|
316 |
-
sprintf(
|
317 |
-
__( 'Conversion from type "%s" to "%s" is currently not allowed.', 'wpcf' ),
|
318 |
-
$definition->get_type()->get_display_name(),
|
319 |
-
$target_type->get_display_name()
|
320 |
-
)
|
321 |
-
);
|
322 |
-
}
|
323 |
-
|
324 |
-
// Check if we can do the conversion with current field's cardinality
|
325 |
-
$is_cardinality_sustainable = ( ! $definition->get_is_repetitive() || $target_type->can_be_repetitive() );
|
326 |
-
if( !$is_cardinality_sustainable ) {
|
327 |
-
return new WP_Error(
|
328 |
-
42,
|
329 |
-
sprintf(
|
330 |
-
__( 'Field "%s" cannot be converted from "%s" to "%s" because it is repetitive and the target type doesn\'t support that.', 'wpcf' ),
|
331 |
-
$definition->get_display_name(),
|
332 |
-
$definition->get_type()->get_display_name(),
|
333 |
-
$target_type->get_display_name()
|
334 |
-
)
|
335 |
-
);
|
336 |
-
}
|
337 |
-
|
338 |
-
// All is fine, proceed.
|
339 |
-
$result = $definition->change_type( $target_type );
|
340 |
-
if( $result ) {
|
341 |
-
return $definition;
|
342 |
-
} else {
|
343 |
-
// Something unexpected went wrong.
|
344 |
-
return false;
|
345 |
-
}
|
346 |
-
}
|
347 |
-
|
348 |
-
|
349 |
-
/**
|
350 |
-
* Change cardinality of given field, if it is permitted by its type.
|
351 |
-
*
|
352 |
-
* @param string $field_slug Field definition slug.
|
353 |
-
* @param string $domain Field domain.
|
354 |
-
* @param string[] $arguments Needs to contain the 'target_cardinality' key with 'single'|'repetitive' value.
|
355 |
-
* @return bool|WP_Error|WPCF_Field_Definition The updated definition on succes, error/false otherwise.
|
356 |
-
* @since 2.0
|
357 |
-
*/
|
358 |
-
public static function change_field_cardinality( $field_slug, $domain, $arguments ) {
|
359 |
-
$factory = Types_Field_Utils::get_definition_factory_by_domain( $domain );
|
360 |
-
$definition = $factory->load_field_definition( $field_slug );
|
361 |
-
if( null == $definition ) {
|
362 |
-
return new WP_Error( 42, sprintf( __( 'Field definition for field "%s" not found in options.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
363 |
-
} else if( ! $definition->is_managed_by_types() ) {
|
364 |
-
return new WP_Error( 42, sprintf( __( 'Field "%s" will not be converted because it is not managed by Types.', 'wpcf' ), sanitize_text_field( $field_slug ) ) );
|
365 |
-
}
|
366 |
-
|
367 |
-
$target_cardinality = wpcf_getarr( $arguments, 'target_cardinality', null, array( 'single', 'repetitive' ) );
|
368 |
-
if( null == $target_cardinality ) {
|
369 |
-
return false;
|
370 |
-
}
|
371 |
-
$set_as_repetitive = ( 'repetitive' == $target_cardinality );
|
372 |
-
|
373 |
-
$result = $definition->set_is_repetitive( $set_as_repetitive );
|
374 |
-
|
375 |
-
if( $result ) {
|
376 |
-
return $definition;
|
377 |
-
} else {
|
378 |
-
return false;
|
379 |
-
}
|
380 |
-
}
|
381 |
|
382 |
}
|
29 |
public static function get_domains() {
|
30 |
return array( self::DOMAIN_POSTS, self::DOMAIN_USERS, self::DOMAIN_TERMS );
|
31 |
}
|
32 |
+
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @param $domain
|
36 |
+
*
|
37 |
+
* @return WPCF_Field_Definition_Factory
|
38 |
+
* @deprecated Use WPCF_Field_Definition_Factory::get_factory_by_domain() instead.
|
39 |
+
*/
|
40 |
public static function get_definition_factory_by_domain( $domain ) {
|
41 |
switch( $domain ) {
|
42 |
case self::DOMAIN_POSTS:
|
55 |
* For a given field domain, return the appropriate field group factory instance.
|
56 |
*
|
57 |
* @param string $domain
|
58 |
+
*
|
59 |
+
* @return Types_Field_Group_Factory
|
60 |
* @since 2.0
|
61 |
+
* @deprecated Use Types_Field_Group_Factory::get_factory_by_domain() instead.
|
62 |
*/
|
63 |
public static function get_group_factory_by_domain( $domain ) {
|
64 |
switch( $domain ) {
|
65 |
case self::DOMAIN_POSTS:
|
66 |
+
return Types_Field_Group_Post_Factory::get_instance();
|
67 |
case self::DOMAIN_USERS:
|
68 |
+
return Types_Field_Group_User_Factory::get_instance();
|
69 |
case self::DOMAIN_TERMS:
|
70 |
+
return Types_Field_Group_Term_Factory::get_instance();
|
71 |
default:
|
72 |
throw new InvalidArgumentException( 'Invalid field domain.' );
|
73 |
}
|
74 |
}
|
75 |
|
76 |
|
77 |
+
private static $domain_legacy_value_map = array(
|
78 |
+
self::DOMAIN_POSTS => 'postmeta',
|
79 |
+
self::DOMAIN_USERS => 'usermeta',
|
80 |
+
self::DOMAIN_TERMS => 'termmeta'
|
81 |
+
);
|
82 |
+
|
83 |
+
|
84 |
/**
|
85 |
* Translate a field domain into a "meta_type" value, which is used in field definition arrays.
|
86 |
*
|
89 |
* @since 2.0
|
90 |
*/
|
91 |
public static function domain_to_legacy_meta_type( $domain ) {
|
92 |
+
return wpcf_getarr( self::$domain_legacy_value_map, $domain );
|
93 |
+
}
|
94 |
+
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Translate a "meta_type" value into a field domain name.
|
98 |
+
*
|
99 |
+
* @param $meta_type
|
100 |
+
* @return string
|
101 |
+
* @since 2.1
|
102 |
+
*/
|
103 |
+
public static function legacy_meta_type_to_domain( $meta_type ) {
|
104 |
+
$map = array_flip( self::$domain_legacy_value_map );
|
105 |
+
return wpcf_getarr( $map, $meta_type );
|
106 |
}
|
107 |
|
108 |
|
144 |
* The groups are expected to belong to the same domain (term/post/user), otherwise problems may occur when
|
145 |
* field slugs conflict.
|
146 |
*
|
147 |
+
* @param Types_Field_Group[] $field_groups
|
148 |
* @return WPCF_Field_Definition[]
|
149 |
* @since 1.9
|
150 |
*/
|
159 |
}
|
160 |
return $field_definitions;
|
161 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
|
163 |
}
|
application/controllers/import_export.php
ADDED
@@ -0,0 +1,615 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Types import and export controller.
|
5 |
+
*
|
6 |
+
* Currently it only contains new code that is hooked into legacy methods plus a bunch of temporary workarounds, but
|
7 |
+
* has the ambition to become the central point of handling all import and export-related activities.
|
8 |
+
*
|
9 |
+
* @since 2.1
|
10 |
+
*/
|
11 |
+
final class Types_Import_Export {
|
12 |
+
|
13 |
+
private static $instance;
|
14 |
+
|
15 |
+
public static function get_instance() {
|
16 |
+
if( null == self::$instance ) {
|
17 |
+
self::$instance = new self();
|
18 |
+
}
|
19 |
+
return self::$instance;
|
20 |
+
}
|
21 |
+
|
22 |
+
private function __clone() { }
|
23 |
+
|
24 |
+
private function __construct() { }
|
25 |
+
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Non-associative arrays which are to be exported to XML need to contain this key. Its value
|
29 |
+
* determines node names of all other items. For example,
|
30 |
+
*
|
31 |
+
* 'terms' => array( 'a', 'b', '__key' => 'term' )
|
32 |
+
*
|
33 |
+
* will translate into
|
34 |
+
*
|
35 |
+
* <terms>
|
36 |
+
* <term>a</term>
|
37 |
+
* <term>b</term>
|
38 |
+
* </terms>
|
39 |
+
*
|
40 |
+
* @since 2.1
|
41 |
+
*/
|
42 |
+
const XML_KEY = '__key';
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Hash and checksum is used to check if a certain post types, custom field groups inside a module is changed.
|
47 |
+
* It's using MD5hash. This will be used by module manager to check if the module is updated (meaning the types
|
48 |
+
* definition) has changed. And it will alert the user that he is importing a different module.
|
49 |
+
*
|
50 |
+
* @link https://onthegosystems.myjetbrains.com/youtrack/issue/types-749#comment=102-105945
|
51 |
+
*/
|
52 |
+
const XML_KEY_CHECKSUM = 'checksum';
|
53 |
+
const XML_KEY_HASH = 'hash';
|
54 |
+
|
55 |
+
|
56 |
+
/**
|
57 |
+
* '__types_id' is used as a unique identifier for CPT,Types taxonomy, custom fields groups, etc. As for the
|
58 |
+
* allowed values, it's usually using a slug as an identifier since this will not change during import/export.
|
59 |
+
* IDs on the otherhand will change after import.
|
60 |
+
*
|
61 |
+
* Now '__types_title' is just the title/label name corresponding to the '__types_id'.
|
62 |
+
*
|
63 |
+
* @link https://onthegosystems.myjetbrains.com/youtrack/issue/types-749#comment=102-105945
|
64 |
+
*/
|
65 |
+
const XML_TYPES_ID = '__types_id';
|
66 |
+
const XML_TYPES_TITLE = '__types_title';
|
67 |
+
|
68 |
+
|
69 |
+
/** Element name for a single field group. */
|
70 |
+
const XML_KEY_GROUP = 'group';
|
71 |
+
|
72 |
+
|
73 |
+
/** Element name for a single field definition. */
|
74 |
+
const XML_KEY_FIELD = 'field';
|
75 |
+
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Completely handle retrieving export data for field groups of one domain.
|
79 |
+
*
|
80 |
+
* @param string $domain Valid field domain.
|
81 |
+
* @return array Exported field groups.
|
82 |
+
* @since 2.1
|
83 |
+
*/
|
84 |
+
public function export_field_groups_for_domain( $domain ) {
|
85 |
+
|
86 |
+
$group_factory = Types_Field_Utils::get_group_factory_by_domain( $domain );
|
87 |
+
$all_groups = $group_factory->query_groups();
|
88 |
+
|
89 |
+
// Each group will handle its own export.
|
90 |
+
$results = array();
|
91 |
+
foreach( $all_groups as $field_group ) {
|
92 |
+
$results[] = $field_group->get_export_object();
|
93 |
+
}
|
94 |
+
|
95 |
+
$results[ self::XML_KEY ] = self::XML_KEY_GROUP;
|
96 |
+
|
97 |
+
return $results;
|
98 |
+
}
|
99 |
+
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Completely handle retrieving export data for field definitions of one domain.
|
103 |
+
*
|
104 |
+
* @param string $domain Valid field domain.
|
105 |
+
* @return array Exported field definitions.
|
106 |
+
* @since 2.1
|
107 |
+
*/
|
108 |
+
public function export_field_definitions_for_domain( $domain ) {
|
109 |
+
|
110 |
+
$definition_factory = Types_Field_Utils::get_definition_factory_by_domain( $domain );
|
111 |
+
$all_definitions = $definition_factory->query_definitions( array( 'filter' => 'types' ) );
|
112 |
+
|
113 |
+
// Each field definition will handle its own export.
|
114 |
+
$results = array();
|
115 |
+
/** @var WPCF_Field_Definition $field_definition */
|
116 |
+
foreach( $all_definitions as $field_definition ) {
|
117 |
+
$results[] = $field_definition->get_export_object();
|
118 |
+
}
|
119 |
+
|
120 |
+
$results[ self::XML_KEY ] = self::XML_KEY_FIELD;
|
121 |
+
|
122 |
+
return $results;
|
123 |
+
}
|
124 |
+
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Generate a checksum for an to-be-exported object and store it.
|
128 |
+
*
|
129 |
+
* @param array $data An associative array representing an object.
|
130 |
+
* @param null|string[] $keys_for_checksum Array keys that should be used when generating the checksum. If null,
|
131 |
+
* the whole $data is used.
|
132 |
+
* @param null|string[] $keys_to_remove Array keys that should be _not_ used when generating the checksum.
|
133 |
+
*
|
134 |
+
* @return array The updated $data with XML_KEY_CHECKSUM and XML_KEY_HASH set.
|
135 |
+
* @since 2.1
|
136 |
+
*/
|
137 |
+
public function add_checksum_to_object( $data, $keys_for_checksum = null, $keys_to_remove = null ) {
|
138 |
+
|
139 |
+
// pluck requested keys
|
140 |
+
if( null == $keys_for_checksum ) {
|
141 |
+
$checksum_source = $data;
|
142 |
+
} else {
|
143 |
+
$checksum_source = array();
|
144 |
+
foreach ( $data as $key => $value ) {
|
145 |
+
if ( in_array( $key, $keys_for_checksum ) ) {
|
146 |
+
$checksum_source[ $key ] = $value;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
|
151 |
+
// unset undesired keys
|
152 |
+
if( is_array( $keys_to_remove ) ) {
|
153 |
+
$checksum_source = $this->unset_recursive( $checksum_source, $keys_to_remove );
|
154 |
+
}
|
155 |
+
|
156 |
+
$checksum = $this->generate_checksum( $checksum_source );
|
157 |
+
|
158 |
+
$data[ self::XML_KEY_CHECKSUM ] = $checksum;
|
159 |
+
$data[ self::XML_KEY_HASH ] = $checksum;
|
160 |
+
|
161 |
+
return $data;
|
162 |
+
}
|
163 |
+
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Unset keys from a multidimensional array.
|
167 |
+
*
|
168 |
+
* @param array $unset_from The source array.
|
169 |
+
* @param array $unset_what Definition of keys that need to be unset. Each element of this array can be either
|
170 |
+
* a string, in which case it represents an key to be removed on the top level, or an 'key' => array( ... )
|
171 |
+
* value, in which case the unsetting will happen in $unset_from['key'].
|
172 |
+
*
|
173 |
+
* For example, unsetting array( 'c', 'd' => array( 'b' ) ) from
|
174 |
+
*
|
175 |
+
* array( 'a' => 1, 'b' => 2, 'c' => array( 'a' => 1 ), 'd' => array( 'a' => 1, 'b' => 2 ) )
|
176 |
+
*
|
177 |
+
* will return
|
178 |
+
*
|
179 |
+
* array( 'a' => 1, 'b' => 2, 'd' => array( 'a' => 1 ) )
|
180 |
+
*
|
181 |
+
* @return array
|
182 |
+
* @since 2.1
|
183 |
+
*/
|
184 |
+
private function unset_recursive( $unset_from, $unset_what ) {
|
185 |
+
if( is_array( $unset_from ) ) {
|
186 |
+
|
187 |
+
foreach ( $unset_what as $key => $value ) {
|
188 |
+
|
189 |
+
if ( is_array( $value ) && isset( $unset_from[ $key ] ) ) {
|
190 |
+
$unset_from[ $key ] = $this->unset_recursive( $unset_from[ $key ], $value );
|
191 |
+
} else {
|
192 |
+
unset( $unset_from[ $value ] );
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
+
return $unset_from;
|
199 |
+
}
|
200 |
+
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Add standard object annotation XML_TYPES_ID and XML_TYPES_TITLE.
|
204 |
+
*
|
205 |
+
* @param array $data An associative array representing an object.
|
206 |
+
* @param string $title
|
207 |
+
* @param string $id
|
208 |
+
* @return array Updated $data.
|
209 |
+
* @since 2.1
|
210 |
+
*/
|
211 |
+
public function annotate_object( $data, $title, $id ) {
|
212 |
+
$data[ self::XML_TYPES_ID ] = $id;
|
213 |
+
$data[ self::XML_TYPES_TITLE ] = $title;
|
214 |
+
return $data;
|
215 |
+
}
|
216 |
+
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Generate a checksum for given object.
|
220 |
+
*
|
221 |
+
* Note: Do not touch this.
|
222 |
+
*
|
223 |
+
* @param array $data
|
224 |
+
* @return string Checksum
|
225 |
+
* @since 2.1
|
226 |
+
*/
|
227 |
+
private function generate_checksum( $data ) {
|
228 |
+
return md5( maybe_serialize( $this->ksort_as_string( $data ) ) );
|
229 |
+
}
|
230 |
+
|
231 |
+
|
232 |
+
/**
|
233 |
+
* Sort a multidimensional array by keys recursively.
|
234 |
+
*
|
235 |
+
* @param array|mixed $data
|
236 |
+
* @return array|mixed Sorted $data.
|
237 |
+
* @since 2.1
|
238 |
+
*/
|
239 |
+
private function ksort_as_string( $data ) {
|
240 |
+
if ( is_array( $data ) ) {
|
241 |
+
ksort( $data, SORT_STRING );
|
242 |
+
foreach ( $data as $key => $value ) {
|
243 |
+
$data[ $key ] = $this->ksort_as_string( $value );
|
244 |
+
}
|
245 |
+
}
|
246 |
+
return $data;
|
247 |
+
}
|
248 |
+
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Import field definitions for given domain.
|
252 |
+
*
|
253 |
+
* Note: Currently only term fields are supported.
|
254 |
+
*
|
255 |
+
* @param string $domain Valid field domain.
|
256 |
+
* @param SimpleXMLElement $data Import data from XML.
|
257 |
+
* @param string $fields_key Node name where the field definitions can be found.
|
258 |
+
* @param bool $delete_other_fields If true, fields that are not being imported will be deleted from the site.
|
259 |
+
* @param array $field_settings Part of $_POST from the import form related to these fields.
|
260 |
+
*
|
261 |
+
* @return array
|
262 |
+
*/
|
263 |
+
public function process_field_definition_import_per_domain( $domain, $data, $fields_key, $delete_other_fields, $field_settings ) {
|
264 |
+
|
265 |
+
$results = array();
|
266 |
+
|
267 |
+
$fields_to_preserve = array();
|
268 |
+
|
269 |
+
$fields_import_data = array();
|
270 |
+
if( isset( $data->$fields_key ) ) {
|
271 |
+
/** @noinspection PhpParamsInspection */
|
272 |
+
$fields_import_data = $this->simplexmlelement_to_object( $data->$fields_key, true );
|
273 |
+
$fields_import_data = isset( $fields_import_data[ Types_Import_Export::XML_KEY_FIELD ] ) ? $fields_import_data[ Types_Import_Export::XML_KEY_FIELD ] : array();
|
274 |
+
}
|
275 |
+
|
276 |
+
foreach( $fields_import_data as $field_import_data ) {
|
277 |
+
$field_slug = $field_import_data['slug'];
|
278 |
+
|
279 |
+
$import_field = isset( $field_settings[ $field_slug ] ) && isset( $field_settings[ $field_slug ]['add'] );
|
280 |
+
|
281 |
+
if( $import_field ) {
|
282 |
+
$result = $this->import_field_definition( $domain, $field_import_data );
|
283 |
+
if( $result['is_success'] ) {
|
284 |
+
$fields_to_preserve[] = $field_slug;
|
285 |
+
}
|
286 |
+
$results[] = array(
|
287 |
+
'type' => ( $result['is_success'] ? 'success' : 'error' ),
|
288 |
+
'content' => $result['display_message']
|
289 |
+
);
|
290 |
+
}
|
291 |
+
}
|
292 |
+
|
293 |
+
$delete_results = $this->maybe_delete_fields( $domain, $delete_other_fields, $fields_to_preserve );
|
294 |
+
$results = array_merge( $results, $delete_results );
|
295 |
+
|
296 |
+
return $results;
|
297 |
+
|
298 |
+
}
|
299 |
+
|
300 |
+
|
301 |
+
/**
|
302 |
+
* @param string $domain
|
303 |
+
* @param bool $delete_other_fields
|
304 |
+
* @param string[] $fields_to_preserve Array of field slugs that should be preserved.
|
305 |
+
*
|
306 |
+
* @return array
|
307 |
+
*/
|
308 |
+
private function maybe_delete_fields( $domain, $delete_other_fields, $fields_to_preserve ) {
|
309 |
+
|
310 |
+
$results = array();
|
311 |
+
|
312 |
+
$definition_factory = Types_Field_Utils::get_definition_factory_by_domain( $domain );
|
313 |
+
$option_name = $definition_factory->get_option_name_workaround();
|
314 |
+
|
315 |
+
if ( $delete_other_fields ) {
|
316 |
+
|
317 |
+
$fields_existing = wpcf_admin_fields_get_fields( false, false, false, $option_name );
|
318 |
+
|
319 |
+
foreach ( $fields_existing as $key => $existing_field_definition ) {
|
320 |
+
|
321 |
+
if ( ! empty( $existing_field_definition['data']['controlled'] ) ) {
|
322 |
+
continue;
|
323 |
+
}
|
324 |
+
|
325 |
+
$existing_field_slug = $existing_field_definition['slug'];
|
326 |
+
|
327 |
+
if ( ! in_array( $existing_field_slug, $fields_to_preserve ) ) {
|
328 |
+
$results[] = array(
|
329 |
+
'type' => 'success',
|
330 |
+
'content' => sprintf(
|
331 |
+
__( 'User field "%s" deleted', 'wpcf' ),
|
332 |
+
$existing_field_definition['name']
|
333 |
+
)
|
334 |
+
);
|
335 |
+
unset( $fields_existing[ $key ] );
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
update_option( $option_name, $fields_existing );
|
340 |
+
}
|
341 |
+
|
342 |
+
|
343 |
+
return $results;
|
344 |
+
}
|
345 |
+
|
346 |
+
|
347 |
+
/**
|
348 |
+
* @param string $domain
|
349 |
+
* @param array $definition_array_import Field definition array (will contain some additional elements from the import file).
|
350 |
+
*
|
351 |
+
* @return array
|
352 |
+
*/
|
353 |
+
private function import_field_definition( $domain, $definition_array_import ) {
|
354 |
+
|
355 |
+
$definition = array(
|
356 |
+
'id' => $definition_array_import['id'],
|
357 |
+
'name' => $definition_array_import['name'],
|
358 |
+
'description' => isset( $definition_array_import['description'] ) ? $definition_array_import['description'] : '',
|
359 |
+
'type' => $definition_array_import['type'],
|
360 |
+
'slug' => $definition_array_import['slug'],
|
361 |
+
'data' => ( isset( $definition_array_import['data'] ) && is_array( $definition_array_import['data'] ) ) ? $definition_array_import['data'] : array()
|
362 |
+
);
|
363 |
+
|
364 |
+
if( isset( $definition_array_import['meta_key'] ) ) {
|
365 |
+
$definition['meta_key'] = $definition_array_import['meta_key'];
|
366 |
+
}
|
367 |
+
|
368 |
+
// WPML
|
369 |
+
global $iclTranslationManagement;
|
370 |
+
if ( !empty( $iclTranslationManagement ) && isset( $definition['wpml_action'] ) ) {
|
371 |
+
$iclTranslationManagement->settings['custom_fields_translation'][ wpcf_types_get_meta_prefix( $definition ) . $definition['slug'] ] = $definition['wpml_action'];
|
372 |
+
$iclTranslationManagement->save_settings();
|
373 |
+
}
|
374 |
+
|
375 |
+
$definition_factory = Types_Field_Utils::get_definition_factory_by_domain( $domain );
|
376 |
+
$definition_factory->set_field_definition_workaround( $definition['slug'], $definition );
|
377 |
+
|
378 |
+
return array(
|
379 |
+
'is_success' => true,
|
380 |
+
'display_message' => sprintf( __( 'Term field "%s" added/updated', 'wpcf' ), $definition['name'] )
|
381 |
+
);
|
382 |
+
}
|
383 |
+
|
384 |
+
|
385 |
+
/**
|
386 |
+
* Import field definitions for given domain.
|
387 |
+
*
|
388 |
+
* Note: Currently only term fields are supported.
|
389 |
+
*
|
390 |
+
* @param string $domain Valid field domain.
|
391 |
+
* @param SimpleXMLElement $data Import data from XML.
|
392 |
+
* @param string $groups_key Node name where the field groups can be found.
|
393 |
+
* @param bool $bulk_overwrite_groups If true, all (conflicting) groups will be overwritten by the ones from import.
|
394 |
+
* @param bool $delete_other_groups If true, groups that are not being imported will be deleted from the site.
|
395 |
+
* @param array $group_settings Part of $_POST from the import form related to these groups.
|
396 |
+
* @return array
|
397 |
+
*/
|
398 |
+
public function process_field_group_import_per_domain( $domain, $data, $groups_key, $bulk_overwrite_groups, $delete_other_groups, $group_settings ) {
|
399 |
+
|
400 |
+
$results = array();
|
401 |
+
$groups_to_preserve = array();
|
402 |
+
|
403 |
+
$groups_import_data = array();
|
404 |
+
if( isset( $data->$groups_key ) ) {
|
405 |
+
/** @noinspection PhpParamsInspection */
|
406 |
+
$groups_import_data = $this->simplexmlelement_to_object( $data->$groups_key, true );
|
407 |
+
$groups_import_data = isset( $groups_import_data[ Types_Import_Export::XML_KEY_GROUP ] ) ? $groups_import_data[ Types_Import_Export::XML_KEY_GROUP ] : array();
|
408 |
+
}
|
409 |
+
|
410 |
+
foreach( $groups_import_data as $group ) {
|
411 |
+
|
412 |
+
// ID of group from the import file
|
413 |
+
$import_group_id = wpcf_getarr( $group, Types_Field_Group::XML_ID );
|
414 |
+
|
415 |
+
$group_actions = wpcf_getarr( $group_settings, $import_group_id, array( 'add' => true ) );
|
416 |
+
$group_should_be_imported = isset( $group_actions['add'] );
|
417 |
+
|
418 |
+
if( $group_should_be_imported ) {
|
419 |
+
if( $bulk_overwrite_groups ) {
|
420 |
+
$group_action = 'update';
|
421 |
+
} else {
|
422 |
+
$group_action = wpcf_getarr( $group_actions, 'update', 'add', array( 'add', 'update' ) );
|
423 |
+
}
|
424 |
+
} else {
|
425 |
+
$group_action = 'nothing';
|
426 |
+
}
|
427 |
+
|
428 |
+
$result = null;
|
429 |
+
|
430 |
+
switch( $group_action ) {
|
431 |
+
case 'add':
|
432 |
+
$result = $this->import_field_group( $domain, $group, 'create_new' );
|
433 |
+
break;
|
434 |
+
case 'update':
|
435 |
+
$result = $this->import_field_group( $domain, $group, 'overwrite' );
|
436 |
+
break;
|
437 |
+
}
|
438 |
+
|
439 |
+
if( null != $result ) {
|
440 |
+
$results[] = array(
|
441 |
+
'type' => ( $result['is_success'] ? 'success' : 'error' ),
|
442 |
+
'content' => $result['display_message']
|
443 |
+
);
|
444 |
+
if( $result['is_success'] ) {
|
445 |
+
$groups_to_preserve[] = $result['new_group_id'];
|
446 |
+
}
|
447 |
+
}
|
448 |
+
|
449 |
+
}
|
450 |
+
|
451 |
+
$delete_results = $this->maybe_delete_groups( $domain, $delete_other_groups, $groups_to_preserve );
|
452 |
+
$results = array_merge( $results, $delete_results );
|
453 |
+
|
454 |
+
return $results;
|
455 |
+
}
|
456 |
+
|
457 |
+
|
458 |
+
/**
|
459 |
+
* @param string $domain
|
460 |
+
* @param bool $delete_other_groups
|
461 |
+
* @param int[] $groups_to_preserve
|
462 |
+
*
|
463 |
+
* @return array
|
464 |
+
*/
|
465 |
+
private function maybe_delete_groups( $domain, $delete_other_groups, $groups_to_preserve ) {
|
466 |
+
|
467 |
+
$results = array();
|
468 |
+
if( $delete_other_groups && !empty( $groups_to_preserve ) ) {
|
469 |
+
$group_factory = Types_Field_Utils::get_group_factory_by_domain( $domain );
|
470 |
+
$all_groups = $group_factory->query_groups();
|
471 |
+
|
472 |
+
foreach( $all_groups as $group_to_delete ) {
|
473 |
+
if( !in_array( $group_to_delete->get_id(), $groups_to_preserve ) ) {
|
474 |
+
|
475 |
+
$deleted_group_name = $group_to_delete->get_name();
|
476 |
+
$deleted = wp_delete_post( $group_to_delete->get_id(), true );
|
477 |
+
if ( !$deleted ) {
|
478 |
+
$results[] = array(
|
479 |
+
'type' => 'error',
|
480 |
+
'content' => sprintf( __( 'Term field group "%s" delete failed', 'wpcf' ), $deleted_group_name )
|
481 |
+
);
|
482 |
+
} else {
|
483 |
+
$results[] = array(
|
484 |
+
'type' => 'success',
|
485 |
+
'content' => sprintf( __( 'Term field group "%s" deleted', 'wpcf' ), $deleted_group_name )
|
486 |
+
);
|
487 |
+
}
|
488 |
+
|
489 |
+
}
|
490 |
+
}
|
491 |
+
}
|
492 |
+
|
493 |
+
return $results;
|
494 |
+
|
495 |
+
}
|
496 |
+
|
497 |
+
|
498 |
+
/**
|
499 |
+
* @param string $domain Valid field domain
|
500 |
+
* @param array $group Field group import data as associative array.
|
501 |
+
* @param string $conflict_resolution = 'overwrite'|'create_new' Defines how to handle a situation when a
|
502 |
+
* field group already exists in the database.
|
503 |
+
*
|
504 |
+
* @return array Import results:
|
505 |
+
* 'is_success' bool
|
506 |
+
* 'display_message' string
|
507 |
+
* 'new_group_id' int
|
508 |
+
*
|
509 |
+
* @since 2.1
|
510 |
+
*/
|
511 |
+
public function import_field_group( $domain, $group, $conflict_resolution ) {
|
512 |
+
|
513 |
+
$group_slug = wpcf_getarr( $group, Types_Field_Group::XML_SLUG );
|
514 |
+
|
515 |
+
$group_factory = Types_Field_Utils::get_group_factory_by_domain( $domain );
|
516 |
+
|
517 |
+
$existing_groups = $group_factory->query_groups( array( 'name' => $group_slug ) );
|
518 |
+
$group_already_exists = ( count( $existing_groups ) > 0 );
|
519 |
+
|
520 |
+
$new_post = array(
|
521 |
+
'post_status' => $group['post_status'],
|
522 |
+
'post_type' => $group_factory->get_post_type(),
|
523 |
+
'post_title' => $group['post_title'],
|
524 |
+
'post_content' => !empty( $group['post_content'] ) ? $group['post_content'] : '',
|
525 |
+
);
|
526 |
+
|
527 |
+
$update_existing = ( $group_already_exists && 'overwrite' == $conflict_resolution );
|
528 |
+
|
529 |
+
if( $update_existing ) {
|
530 |
+
$existing_group = $existing_groups[0];
|
531 |
+
$new_post['ID'] = $existing_group->get_id();
|
532 |
+
$new_group_id = wp_update_post( $new_post );
|
533 |
+
} else {
|
534 |
+
$new_group_id = wp_insert_post( $new_post, true );
|
535 |
+
}
|
536 |
+
|
537 |
+
$is_success = ( ! is_wp_error( $new_group_id ) && 0 < $new_group_id );
|
538 |
+
|
539 |
+
// Update group's postmeta
|
540 |
+
if( $is_success && ! empty( $group['meta'] ) ) {
|
541 |
+
foreach ( $group['meta'] as $meta_key => $meta_value ) {
|
542 |
+
if( Types_Field_Group_Term::POSTMETA_ASSOCIATED_TAXONOMY == $meta_key ) {
|
543 |
+
$meta_values = explode( ',', $meta_value );
|
544 |
+
delete_post_meta( $new_group_id, $meta_key );
|
545 |
+
foreach( $meta_values as $single_meta_value ) {
|
546 |
+
update_post_meta( $new_group_id, $meta_key, $single_meta_value );
|
547 |
+
}
|
548 |
+
} else {
|
549 |
+
update_post_meta( $new_group_id, $meta_key, $meta_value );
|
550 |
+
}
|
551 |
+
}
|
552 |
+
}
|
553 |
+
|
554 |
+
// Create display message
|
555 |
+
if( $is_success ) {
|
556 |
+
if( $update_existing ) {
|
557 |
+
$display_message = sprintf( __( 'Term field group "%s" updated', 'wpcf' ), $group['post_title'] );
|
558 |
+
} else {
|
559 |
+
$display_message = sprintf( __( 'Term field group "%s" added', 'wpcf' ), $group['post_title'] );
|
560 |
+
}
|
561 |
+
} else {
|
562 |
+
if( $update_existing ) {
|
563 |
+
$display_message = sprintf( __( 'Term field group "%s" update failed', 'wpcf' ), $group['post_title'] );
|
564 |
+
} else {
|
565 |
+
$display_message = sprintf( __( 'Term field group "%s" insert failed', 'wpcf' ), $group['post_title'] );
|
566 |
+
}
|
567 |
+
}
|
568 |
+
|
569 |
+
return array(
|
570 |
+
'is_success' => $is_success,
|
571 |
+
'display_message' => $display_message,
|
572 |
+
'new_group_id' => $new_group_id
|
573 |
+
);
|
574 |
+
}
|
575 |
+
|
576 |
+
|
577 |
+
/**
|
578 |
+
* @param SimpleXMLElement $element
|
579 |
+
* @param bool $allways_expand_top_level
|
580 |
+
*
|
581 |
+
* @return array|null
|
582 |
+
*/
|
583 |
+
public function simplexmlelement_to_object( $element, $allways_expand_top_level = false ) {
|
584 |
+
$text_content = trim( (string)$element );
|
585 |
+
if( !empty( $text_content ) ) {
|
586 |
+
return $text_content;
|
587 |
+
}
|
588 |
+
|
589 |
+
if( $element->count() > 0 ) {
|
590 |
+
$results_by_node_name = array();
|
591 |
+
|
592 |
+
/** @var SimpleXMLElement $child */
|
593 |
+
foreach( $element->children() as $child ) {
|
594 |
+
$child_name = $child->getName();
|
595 |
+
|
596 |
+
if( !isset( $results_by_node_name[ $child_name ] ) ) {
|
597 |
+
$results_by_node_name[ $child_name ] = array();
|
598 |
+
}
|
599 |
+
|
600 |
+
$results_by_node_name[ $child_name ][] = $this->simplexmlelement_to_object( $child, false );
|
601 |
+
}
|
602 |
+
|
603 |
+
$results = array();
|
604 |
+
foreach( $results_by_node_name as $node_name => $children ) {
|
605 |
+
$take_only_first_child = ( count( $children ) == 1 && ! $allways_expand_top_level );
|
606 |
+
$results[ $node_name ] = ( $take_only_first_child ? $children[0] : $children );
|
607 |
+
}
|
608 |
+
|
609 |
+
return $results;
|
610 |
+
}
|
611 |
+
|
612 |
+
return null;
|
613 |
+
}
|
614 |
+
|
615 |
+
}
|
application/controllers/information/controller.php
CHANGED
@@ -1,19 +1,44 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Information_Controller {
|
5 |
|
6 |
protected $information;
|
7 |
protected $twig;
|
8 |
|
9 |
-
|
10 |
-
if(
|
|
|
|
|
|
|
|
|
11 |
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
-
|
14 |
-
if( $this->
|
15 |
return false;
|
16 |
|
|
|
|
|
|
|
17 |
// twig
|
18 |
$this->twig = new Types_Helper_Twig();
|
19 |
|
@@ -152,8 +177,13 @@ class Types_Information_Controller {
|
|
152 |
$views = array();
|
153 |
|
154 |
$post_type = Types_Helper_Condition::get_post_type();
|
155 |
-
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
157 |
|
158 |
foreach( $thead_data as $data ) {
|
159 |
$views[] = $this->twig->render(
|
@@ -204,8 +234,7 @@ class Types_Information_Controller {
|
|
204 |
if( is_object( $WP_Views ) && method_exists( $WP_Views, 'is_embedded' ))
|
205 |
return $WP_Views->is_embedded();
|
206 |
}
|
207 |
-
|
208 |
-
|
209 |
return false;
|
210 |
}
|
211 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Information_Controller
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Information_Controller {
|
9 |
|
10 |
protected $information;
|
11 |
protected $twig;
|
12 |
|
13 |
+
private function requirements_met() {
|
14 |
+
if(
|
15 |
+
! current_user_can( 'manage_options' )
|
16 |
+
|| ! apply_filters( 'types_information_table', true )
|
17 |
+
|| $this->embedded_plugin_running()
|
18 |
+
) {
|
19 |
return false;
|
20 |
+
}
|
21 |
+
|
22 |
+
return true;
|
23 |
+
}
|
24 |
+
|
25 |
+
public function filter_columns( $columns, $post_type ) {
|
26 |
+
if( isset( $columns['archive'] ) && ( $post_type == 'post' || $post_type == 'page' || $post_type == 'attachment' ) )
|
27 |
+
unset( $columns['archive'] );
|
28 |
+
|
29 |
+
if( isset( $columns['template'] ) && ( $post_type == 'post' || $post_type == 'page' ) )
|
30 |
+
unset( $columns['template'] );
|
31 |
+
|
32 |
+
return $columns;
|
33 |
+
}
|
34 |
|
35 |
+
public function prepare() {
|
36 |
+
if( ! $this->requirements_met() )
|
37 |
return false;
|
38 |
|
39 |
+
// filter columns for specific post types
|
40 |
+
add_filter( 'types_information_table_columns', array( $this, 'filter_columns' ), 10, 2 );
|
41 |
+
|
42 |
// twig
|
43 |
$this->twig = new Types_Helper_Twig();
|
44 |
|
177 |
$views = array();
|
178 |
|
179 |
$post_type = Types_Helper_Condition::get_post_type();
|
180 |
+
|
181 |
+
$allowed_columns = apply_filters( 'types_information_table_columns', array_fill_keys( array( 'template', 'archive', 'views', 'forms' ), '' ), $post_type->name );
|
182 |
+
|
183 |
+
foreach( $thead_data as $key => $column ) {
|
184 |
+
if( ! array_key_exists( $key, $allowed_columns ) )
|
185 |
+
unset( $thead_data[$key] );
|
186 |
+
}
|
187 |
|
188 |
foreach( $thead_data as $data ) {
|
189 |
$views[] = $this->twig->render(
|
234 |
if( is_object( $WP_Views ) && method_exists( $WP_Views, 'is_embedded' ))
|
235 |
return $WP_Views->is_embedded();
|
236 |
}
|
237 |
+
|
|
|
238 |
return false;
|
239 |
}
|
240 |
}
|
application/controllers/main.php
CHANGED
@@ -10,7 +10,6 @@
|
|
10 |
*/
|
11 |
final class Types_Main {
|
12 |
|
13 |
-
|
14 |
private static $instance;
|
15 |
|
16 |
public static function get_instance() {
|
@@ -44,21 +43,65 @@ final class Types_Main {
|
|
44 |
public function on_init() {
|
45 |
if( is_admin() ) {
|
46 |
if( defined( 'DOING_AJAX' ) ) {
|
|
|
47 |
Types_Ajax::initialize();
|
48 |
} else {
|
|
|
49 |
Types_Admin::initialize();
|
50 |
}
|
51 |
} else {
|
|
|
52 |
Types_Frontend::initialize();
|
53 |
}
|
54 |
}
|
55 |
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
/**
|
58 |
* Early loading actions.
|
59 |
*
|
60 |
* Initialize the Toolset Common library with the new loader.
|
61 |
* Initialize asset manager if we're not doing an AJAX call.
|
|
|
62 |
*
|
63 |
* @since 2.0
|
64 |
*/
|
@@ -69,6 +112,8 @@ final class Types_Main {
|
|
69 |
if( !defined( 'DOING_AJAX' ) ) {
|
70 |
Types_Assets::get_instance()->initialize_scripts_and_styles();
|
71 |
}
|
|
|
|
|
72 |
}
|
73 |
|
74 |
|
10 |
*/
|
11 |
final class Types_Main {
|
12 |
|
|
|
13 |
private static $instance;
|
14 |
|
15 |
public static function get_instance() {
|
43 |
public function on_init() {
|
44 |
if( is_admin() ) {
|
45 |
if( defined( 'DOING_AJAX' ) ) {
|
46 |
+
$this->mode = self::MODE_AJAX;
|
47 |
Types_Ajax::initialize();
|
48 |
} else {
|
49 |
+
$this->mode = self::MODE_ADMIN;
|
50 |
Types_Admin::initialize();
|
51 |
}
|
52 |
} else {
|
53 |
+
$this->mode = self::MODE_FRONTEND;
|
54 |
Types_Frontend::initialize();
|
55 |
}
|
56 |
}
|
57 |
|
58 |
|
59 |
+
/**
|
60 |
+
* @var string One of the MODE_* constants.
|
61 |
+
*/
|
62 |
+
private $mode = self::MODE_UNDEFINED;
|
63 |
+
|
64 |
+
const MODE_UNDEFINED = '';
|
65 |
+
const MODE_AJAX = 'ajax';
|
66 |
+
const MODE_ADMIN = 'admin';
|
67 |
+
const MODE_FRONTEND = 'frontend';
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Get current plugin mode.
|
71 |
+
*
|
72 |
+
* Possible values are:
|
73 |
+
* - MODE_UNDEFINED before the main controller initialization is completed
|
74 |
+
* - MODE_AJAX when doing an AJAX request
|
75 |
+
* - MODE_ADMIN when showing a WP admin page
|
76 |
+
* - MODE_FRONTEND when rendering a frontend page
|
77 |
+
*
|
78 |
+
* @return string
|
79 |
+
* @since 2.1
|
80 |
+
*/
|
81 |
+
public function get_plugin_mode() {
|
82 |
+
return $this->mode;
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Determine whether a WP admin page is being loaded.
|
88 |
+
*
|
89 |
+
* Note that the behaviour differs from the native is_admin() which will return true also for AJAX requests.
|
90 |
+
*
|
91 |
+
* @return bool
|
92 |
+
* @since 2.1
|
93 |
+
*/
|
94 |
+
public function is_admin() {
|
95 |
+
return ( $this->get_plugin_mode() == self::MODE_ADMIN );
|
96 |
+
}
|
97 |
+
|
98 |
+
|
99 |
/**
|
100 |
* Early loading actions.
|
101 |
*
|
102 |
* Initialize the Toolset Common library with the new loader.
|
103 |
* Initialize asset manager if we're not doing an AJAX call.
|
104 |
+
* Initialize the Types hook API.
|
105 |
*
|
106 |
* @since 2.0
|
107 |
*/
|
112 |
if( !defined( 'DOING_AJAX' ) ) {
|
113 |
Types_Assets::get_instance()->initialize_scripts_and_styles();
|
114 |
}
|
115 |
+
|
116 |
+
Types_Api::initialize();
|
117 |
}
|
118 |
|
119 |
|
application/controllers/page/dashboard.php
ADDED
@@ -0,0 +1,404 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* "Dashboard" page controller.
|
5 |
+
*
|
6 |
+
* @since 2.1
|
7 |
+
*/
|
8 |
+
final class Types_Page_Dashboard extends Types_Page_Abstract {
|
9 |
+
|
10 |
+
protected $dashboard;
|
11 |
+
protected $table = false;
|
12 |
+
protected $twig;
|
13 |
+
protected $cpts;
|
14 |
+
|
15 |
+
private static $instance;
|
16 |
+
|
17 |
+
public static function get_instance() {
|
18 |
+
if( null == self::$instance ) {
|
19 |
+
self::$instance = new self();
|
20 |
+
add_filter( 'toolset_filter_register_menu_pages', array( Types_Page_Dashboard::$instance, 'register_page_dashboard_in_menu' ), 1000 );
|
21 |
+
add_action( 'load-toplevel_page_toolset-dashboard', array( Types_Page_Dashboard::$instance, 'on_load_page' ) );
|
22 |
+
add_filter( 'set-screen-option', array( Types_Page_Dashboard::$instance, 'screen_settings_save') , 11, 3);
|
23 |
+
}
|
24 |
+
return self::$instance;
|
25 |
+
}
|
26 |
+
|
27 |
+
private function __construct() { }
|
28 |
+
|
29 |
+
private function __clone() { }
|
30 |
+
|
31 |
+
public function on_load_page() {
|
32 |
+
add_filter( 'screen_settings', array( Types_Page_Dashboard::$instance, 'screen_settings' ), 10, 2 );
|
33 |
+
add_action( 'admin_enqueue_scripts', array( Types_Page_Dashboard::$instance, 'on_admin_enqueue_scripts' ) );
|
34 |
+
|
35 |
+
$this->help_information();
|
36 |
+
}
|
37 |
+
|
38 |
+
public function register_page_dashboard_in_menu( $pages ) {
|
39 |
+
array_unshift( $pages, array(
|
40 |
+
'slug' => 'toolset-dashboard',
|
41 |
+
'menu_title' => $this->get_menu_title(),
|
42 |
+
'page_title' => $this->get_title(),
|
43 |
+
'callback' => $this->get_render_callback()
|
44 |
+
) );
|
45 |
+
|
46 |
+
return $pages;
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @inheritdoc
|
52 |
+
* @return string
|
53 |
+
*/
|
54 |
+
public function get_title() {
|
55 |
+
return __( 'Toolset Dashboard', 'types' );
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @inheritdoc
|
60 |
+
* @return string
|
61 |
+
*/
|
62 |
+
public function get_menu_title() {
|
63 |
+
return __( 'Dashboard', 'types' );
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @inheritdoc
|
69 |
+
* @return callable
|
70 |
+
*/
|
71 |
+
public function get_render_callback() {
|
72 |
+
return array( $this, 'render_page' );
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @inheritdoc
|
78 |
+
* @return string
|
79 |
+
*/
|
80 |
+
public function get_page_name() {
|
81 |
+
return Types_Admin_Menu::PAGE_NAME_DASHBOARD;
|
82 |
+
}
|
83 |
+
|
84 |
+
|
85 |
+
/**
|
86 |
+
* @inheritdoc
|
87 |
+
* @return string
|
88 |
+
*/
|
89 |
+
public function get_required_capability() {
|
90 |
+
return 'manage_options'; // todo better role/cap handling
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @inheritdoc
|
96 |
+
* @return callable
|
97 |
+
*/
|
98 |
+
public function get_load_callback() {
|
99 |
+
return null;
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
public function on_admin_enqueue_scripts() {
|
104 |
+
$main_handle = 'types-page-dashboard-main';
|
105 |
+
|
106 |
+
// script
|
107 |
+
wp_enqueue_script(
|
108 |
+
$main_handle,
|
109 |
+
TYPES_RELPATH . '/public/js/information.js',
|
110 |
+
array( 'jquery-ui-dialog', 'wp-pointer' ),
|
111 |
+
TYPES_VERSION,
|
112 |
+
true
|
113 |
+
);
|
114 |
+
|
115 |
+
// style
|
116 |
+
wp_enqueue_style(
|
117 |
+
$main_handle,
|
118 |
+
TYPES_RELPATH . '/public/css/information.css',
|
119 |
+
array( 'wp-jquery-ui-dialog', 'wp-pointer' ),
|
120 |
+
TYPES_VERSION
|
121 |
+
);
|
122 |
+
|
123 |
+
// load icons
|
124 |
+
wp_enqueue_style(
|
125 |
+
'onthegosystems-icons',
|
126 |
+
WPCF_EMBEDDED_TOOLSET_RELPATH . '/onthego-resources/onthegosystems-icons/css/onthegosystems-icons.css',
|
127 |
+
array(),
|
128 |
+
TYPES_VERSION
|
129 |
+
);
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
private function get_twig() {
|
134 |
+
if( $this->twig == null )
|
135 |
+
$this->twig = new Types_Helper_Twig();
|
136 |
+
|
137 |
+
return $this->twig;
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
/**
|
142 |
+
* @inheritdoc
|
143 |
+
*
|
144 |
+
* @since 2.1
|
145 |
+
*/
|
146 |
+
public function render_page() {
|
147 |
+
|
148 |
+
$context = $this->build_page_context();
|
149 |
+
|
150 |
+
echo $this->get_twig()->render( '/page/dashboard/main.twig', $context );
|
151 |
+
}
|
152 |
+
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Build the context for main page template.
|
156 |
+
*
|
157 |
+
* @return array Page context. See the main page template for details.
|
158 |
+
* @since 2.1
|
159 |
+
*/
|
160 |
+
private function build_page_context() {
|
161 |
+
$this->get_dashboard();
|
162 |
+
|
163 |
+
$context = array(
|
164 |
+
'page' => self::get_instance(),
|
165 |
+
'table' => $this->table,
|
166 |
+
'labels' => array(
|
167 |
+
'create_type' => __( 'Add new post type', 'types' ),
|
168 |
+
'msg_no_custom_post_types' =>
|
169 |
+
__( 'To get started, create your first custom type. Then, you will be able to add fields and taxonomy and design how it displays.', 'types' )
|
170 |
+
)
|
171 |
+
|
172 |
+
);
|
173 |
+
|
174 |
+
return $context;
|
175 |
+
}
|
176 |
+
|
177 |
+
private function get_post_types() {
|
178 |
+
if( $this->cpts !== null )
|
179 |
+
return $this->cpts;
|
180 |
+
|
181 |
+
$cpts_raw = ! isset( $_GET['toolset-dashboard-simulate-no-custom-post-types'] )
|
182 |
+
? get_option( WPCF_OPTION_NAME_CUSTOM_TYPES, array() )
|
183 |
+
: array();
|
184 |
+
|
185 |
+
// make sure post type "post" is added
|
186 |
+
if( !isset( $cpts_raw['post'] ) )
|
187 |
+
$cpts_raw['post'] = array(
|
188 |
+
'slug' => 'post',
|
189 |
+
'_builtin' => 1
|
190 |
+
);
|
191 |
+
|
192 |
+
// make sure post type "page" is added
|
193 |
+
if( !isset( $cpts_raw['page'] ) )
|
194 |
+
$cpts_raw['page'] = array(
|
195 |
+
'slug' => 'page',
|
196 |
+
'_builtin' => 1
|
197 |
+
);
|
198 |
+
|
199 |
+
// make sure post type "attachment" is added
|
200 |
+
if( !isset( $cpts_raw['attachment'] ) )
|
201 |
+
$cpts_raw['attachment'] = array(
|
202 |
+
'slug' => 'attachment',
|
203 |
+
'_builtin' => 1
|
204 |
+
);
|
205 |
+
$cpts = array();
|
206 |
+
|
207 |
+
foreach( $cpts_raw as $cpt_raw ) {
|
208 |
+
$post_type = new Types_Post_Type( $cpt_raw['slug'] );
|
209 |
+
// only use active post types
|
210 |
+
if( isset( $post_type->name ) )
|
211 |
+
$cpts[$cpt_raw['slug']] = $post_type;
|
212 |
+
}
|
213 |
+
|
214 |
+
uasort( $cpts, array( $this, 'sort_post_types_by_name' ) );
|
215 |
+
|
216 |
+
$this->cpts = $cpts;
|
217 |
+
return $this->cpts;
|
218 |
+
}
|
219 |
+
|
220 |
+
private function sort_post_types_by_name( $a, $b ) {
|
221 |
+
return strcasecmp( $a->name, $b->name ) > 0 ? true : false;
|
222 |
+
}
|
223 |
+
|
224 |
+
private function get_post_types_filtered_by_screen_options() {
|
225 |
+
$cpts = $this->get_post_types();
|
226 |
+
$cpts_filtered = array();
|
227 |
+
|
228 |
+
$user = get_current_user_id();
|
229 |
+
$user_settings = get_user_meta($user, 'toolset_dashboard_screen_post_types', true );
|
230 |
+
|
231 |
+
// no user settings yet
|
232 |
+
if( empty( $user_settings ) ) {
|
233 |
+
|
234 |
+
// by default no post
|
235 |
+
if( isset( $cpts['post'] ) )
|
236 |
+
unset( $cpts['post'] );
|
237 |
+
|
238 |
+
// by default no page
|
239 |
+
if( isset( $cpts['page'] ) )
|
240 |
+
unset( $cpts['page'] );
|
241 |
+
|
242 |
+
// by default no media
|
243 |
+
if( isset( $cpts['attachment'] ) )
|
244 |
+
unset( $cpts['attachment'] );
|
245 |
+
|
246 |
+
$cpts_filtered = $cpts;
|
247 |
+
} else {
|
248 |
+
foreach( $cpts as $post_type => $cpt ) {
|
249 |
+
// default for post/page/media is unchecked
|
250 |
+
if( ! isset( $user_settings[$post_type] )
|
251 |
+
&& ( $post_type == 'post' || $post_type == 'page' || $post_type == 'attachment' )
|
252 |
+
) continue;
|
253 |
+
|
254 |
+
if( !empty( $user_settings ) ) {
|
255 |
+
|
256 |
+
if( ! isset( $user_settings[$post_type] ) // default = checked
|
257 |
+
|| $user_settings[$post_type] == 'on' ) // checked by user
|
258 |
+
$cpts_filtered[$post_type] = $cpt;
|
259 |
+
}
|
260 |
+
}
|
261 |
+
}
|
262 |
+
|
263 |
+
return $cpts_filtered;
|
264 |
+
}
|
265 |
+
|
266 |
+
private function get_dashboard() {
|
267 |
+
// post types
|
268 |
+
$post_types = $this->get_post_types_filtered_by_screen_options();
|
269 |
+
|
270 |
+
// abort if there are no post types
|
271 |
+
if( empty( $post_types ) )
|
272 |
+
return false;
|
273 |
+
|
274 |
+
// documentation urls
|
275 |
+
$documentation_urls = include( TYPES_DATA . '/documentation-urls.php' );
|
276 |
+
|
277 |
+
// add links to use analytics
|
278 |
+
Types_Helper_Url::add_urls( $documentation_urls );
|
279 |
+
|
280 |
+
// set analytics medium
|
281 |
+
Types_Helper_Url::set_medium( 'dashboard' );
|
282 |
+
|
283 |
+
/* messages */
|
284 |
+
$messages_files = array(
|
285 |
+
TYPES_DATA . '/dashboard/table/template.php',
|
286 |
+
TYPES_DATA . '/dashboard/table/archive.php',
|
287 |
+
TYPES_DATA . '/dashboard/table/views.php',
|
288 |
+
TYPES_DATA . '/dashboard/table/forms.php',
|
289 |
+
);
|
290 |
+
|
291 |
+
// add dashboard
|
292 |
+
$rows = '';
|
293 |
+
|
294 |
+
foreach( $post_types as $post_type ) {
|
295 |
+
$info_post_type = new Types_Information_Table( 'types-information-table' );
|
296 |
+
Types_Helper_Condition::set_post_type( $post_type->get_name() );
|
297 |
+
Types_Helper_Placeholder::set_post_type( $post_type->get_name() );
|
298 |
+
|
299 |
+
foreach( $messages_files as $message_file ) {
|
300 |
+
$this->load_data_to_table( $message_file, $info_post_type );
|
301 |
+
}
|
302 |
+
|
303 |
+
$row = $this->get_twig()->render(
|
304 |
+
'/page/dashboard/table/tbody-row.twig',
|
305 |
+
array(
|
306 |
+
'labels' => array(
|
307 |
+
'or' => __( 'Or...', 'types' ),
|
308 |
+
'create_taxonomy' => __( 'Create taxonomy', 'types' ),
|
309 |
+
'create_field_group' => __( 'Create field group', 'types' ),
|
310 |
+
'no_archive_for' => __( 'No archive available for %s', 'types' ),
|
311 |
+
),
|
312 |
+
'admin_url' => admin_url(),
|
313 |
+
'post_type' => $post_type,
|
314 |
+
'table' => $info_post_type
|
315 |
+
)
|
316 |
+
);
|
317 |
+
|
318 |
+
Types_Helper_Placeholder::replace( $row );
|
319 |
+
$rows .= $row;
|
320 |
+
}
|
321 |
+
|
322 |
+
|
323 |
+
// table view
|
324 |
+
$data_thead = require( TYPES_DATA . '/dashboard/table/head.php' );
|
325 |
+
$this->table = $this->get_twig()->render(
|
326 |
+
'/page/dashboard/table.twig',
|
327 |
+
array(
|
328 |
+
'labels' => array(
|
329 |
+
'admin' => __( 'WordPress admin', 'types' ),
|
330 |
+
'frontend' => __( 'Front-end', 'types' ),
|
331 |
+
'or' => __( 'Or...', 'types' ),
|
332 |
+
),
|
333 |
+
'admin_url' => admin_url(),
|
334 |
+
'thead' => $data_thead,
|
335 |
+
'rows' => $rows
|
336 |
+
)
|
337 |
+
);
|
338 |
+
}
|
339 |
+
|
340 |
+
protected function load_data_to_table( $path, &$info ) {
|
341 |
+
$data = require( $path );
|
342 |
+
|
343 |
+
foreach( $data as $msg_id => $msg_data ) {
|
344 |
+
$msg = new Types_Information_Message();
|
345 |
+
$msg_data['id'] = $msg_id;
|
346 |
+
$msg->data_import( $msg_data );
|
347 |
+
$info->add_message( $msg );
|
348 |
+
}
|
349 |
+
}
|
350 |
+
|
351 |
+
public function screen_settings( $status, $args ) {
|
352 |
+
$return = $status;
|
353 |
+
|
354 |
+
$cpts = $this->get_post_types();
|
355 |
+
$cpts_filtered = $this->get_post_types_filtered_by_screen_options();
|
356 |
+
|
357 |
+
$button = get_submit_button( __( 'Apply' ), 'button button-primary', 'screen-options-apply', false );
|
358 |
+
|
359 |
+
$return .= '
|
360 |
+
<fieldset>
|
361 |
+
<legend>' . __( 'Post Types on Dashboard', 'types' ) . '</legend>
|
362 |
+
<div class="metabox-prefs">
|
363 |
+
<div><input type="hidden" name="wp_screen_options[option]" value="toolset_dashboard_screen_post_types" /></div>
|
364 |
+
<div><input type="hidden" name="wp_screen_options[value]" value="yes" /></div>
|
365 |
+
<div class="toolset-dashboard-screen-post-types">';
|
366 |
+
foreach( $cpts as $cpt ) {
|
367 |
+
$checked = isset( $cpts_filtered[$cpt->get_name()] ) ? ' checked="checked" ' : ' ';
|
368 |
+
$return .= '<input type="hidden" value="off" name="toolset_dashboard_screen_post_types['.$cpt->get_name().']" />';
|
369 |
+
$return .= '<label for="toolset-dashboard-screen-post-type-'.$cpt->get_name().'"><input type="checkbox"' . $checked . 'value="on" name="toolset_dashboard_screen_post_types['.$cpt->get_name().']" id="toolset-dashboard-screen-post-type-'.$cpt->get_name().'" /> '.$cpt->name.'</label>';
|
370 |
+
}
|
371 |
+
$return .= '</div>
|
372 |
+
</div>
|
373 |
+
</fieldset>
|
374 |
+
<br class="clear">
|
375 |
+
' . $button;
|
376 |
+
|
377 |
+
return $return;
|
378 |
+
}
|
379 |
+
|
380 |
+
public function screen_settings_save($status, $option, $value) {
|
381 |
+
if ( 'toolset_dashboard_screen_post_types' == $option ) {
|
382 |
+
$value = $_POST['toolset_dashboard_screen_post_types'];
|
383 |
+
}
|
384 |
+
return $value;
|
385 |
+
}
|
386 |
+
|
387 |
+
|
388 |
+
private function help_information() {
|
389 |
+
$title = __('Toolset Dashboard', 'types');
|
390 |
+
$help_content = $this->get_twig()->render(
|
391 |
+
'/page/dashboard/help.twig',
|
392 |
+
array( 'title' => $title )
|
393 |
+
);
|
394 |
+
|
395 |
+
$screen = get_current_screen();
|
396 |
+
$screen->add_help_tab(
|
397 |
+
array(
|
398 |
+
'id' => 'toolset-dashboard-information',
|
399 |
+
'title' => $title,
|
400 |
+
'content' => $help_content,
|
401 |
+
)
|
402 |
+
);
|
403 |
+
}
|
404 |
+
}
|
application/controllers/page/extension/edit_post.php
CHANGED
@@ -37,23 +37,25 @@ final class Types_Page_Extension_Edit_Post {
|
|
37 |
|
38 |
public function prepare() {
|
39 |
// documentation urls
|
40 |
-
|
41 |
-
|
42 |
-
// add links to use analytics
|
43 |
-
Types_Helper_Url::add_urls( $documentation_urls );
|
44 |
|
45 |
// set analytics medium
|
46 |
Types_Helper_Url::set_medium( 'post_editor' );
|
47 |
-
|
48 |
-
// add
|
49 |
-
$this->
|
50 |
|
51 |
// @todo load scripts
|
52 |
if( function_exists( 'wpcf_edit_post_screen_scripts' ) )
|
53 |
wpcf_edit_post_screen_scripts();
|
54 |
}
|
55 |
|
56 |
-
private function
|
|
|
|
|
|
|
|
|
|
|
57 |
$information = new Types_Information_Controller;
|
58 |
$information->prepare();
|
59 |
}
|
37 |
|
38 |
public function prepare() {
|
39 |
// documentation urls
|
40 |
+
Types_Helper_Url::load_documentation_urls();
|
|
|
|
|
|
|
41 |
|
42 |
// set analytics medium
|
43 |
Types_Helper_Url::set_medium( 'post_editor' );
|
44 |
+
|
45 |
+
// add information
|
46 |
+
$this->prepare_information();
|
47 |
|
48 |
// @todo load scripts
|
49 |
if( function_exists( 'wpcf_edit_post_screen_scripts' ) )
|
50 |
wpcf_edit_post_screen_scripts();
|
51 |
}
|
52 |
|
53 |
+
private function prepare_information() {
|
54 |
+
$setting = new Types_Setting_Preset_Information_Table();
|
55 |
+
|
56 |
+
if( ! $setting->get_value( 'show-on-post' ) )
|
57 |
+
return false;
|
58 |
+
|
59 |
$information = new Types_Information_Controller;
|
60 |
$information->prepare();
|
61 |
}
|
application/controllers/page/extension/edit_post_fields.php
CHANGED
@@ -38,10 +38,7 @@ final class Types_Page_Extension_Edit_Post_Fields {
|
|
38 |
|
39 |
public function prepare() {
|
40 |
// documentation urls
|
41 |
-
|
42 |
-
|
43 |
-
// add links to use analytics
|
44 |
-
Types_Helper_Url::add_urls( $documentation_urls );
|
45 |
|
46 |
// set analytics medium
|
47 |
Types_Helper_Url::set_medium( 'field_group_editor' );
|
@@ -52,6 +49,11 @@ final class Types_Page_Extension_Edit_Post_Fields {
|
|
52 |
}
|
53 |
|
54 |
private function prepare_informations() {
|
|
|
|
|
|
|
|
|
|
|
55 |
$information = new Types_Information_Controller;
|
56 |
$information->prepare();
|
57 |
}
|
38 |
|
39 |
public function prepare() {
|
40 |
// documentation urls
|
41 |
+
Types_Helper_Url::load_documentation_urls();
|
|
|
|
|
|
|
42 |
|
43 |
// set analytics medium
|
44 |
Types_Helper_Url::set_medium( 'field_group_editor' );
|
49 |
}
|
50 |
|
51 |
private function prepare_informations() {
|
52 |
+
$setting = new Types_Setting_Preset_Information_Table();
|
53 |
+
|
54 |
+
if( ! $setting->get_value( 'show-on-field-group' ) )
|
55 |
+
return false;
|
56 |
+
|
57 |
$information = new Types_Information_Controller;
|
58 |
$information->prepare();
|
59 |
}
|
application/controllers/page/extension/edit_post_type.php
CHANGED
@@ -31,10 +31,7 @@ final class Types_Page_Extension_Edit_Post_Type {
|
|
31 |
|
32 |
public function prepare() {
|
33 |
// documentation urls
|
34 |
-
|
35 |
-
|
36 |
-
// add links to use analytics
|
37 |
-
Types_Helper_Url::add_urls( $documentation_urls );
|
38 |
|
39 |
// set analytics medium
|
40 |
Types_Helper_Url::set_medium( 'cpt_editor' );
|
@@ -45,6 +42,11 @@ final class Types_Page_Extension_Edit_Post_Type {
|
|
45 |
}
|
46 |
|
47 |
private function prepare_informations() {
|
|
|
|
|
|
|
|
|
|
|
48 |
$information = new Types_Information_Controller;
|
49 |
$information->prepare();
|
50 |
}
|
31 |
|
32 |
public function prepare() {
|
33 |
// documentation urls
|
34 |
+
Types_Helper_Url::load_documentation_urls();
|
|
|
|
|
|
|
35 |
|
36 |
// set analytics medium
|
37 |
Types_Helper_Url::set_medium( 'cpt_editor' );
|
42 |
}
|
43 |
|
44 |
private function prepare_informations() {
|
45 |
+
$setting = new Types_Setting_Preset_Information_Table();
|
46 |
+
|
47 |
+
if( ! $setting->get_value( 'show-on-post-type' ) )
|
48 |
+
return false;
|
49 |
+
|
50 |
$information = new Types_Information_Controller;
|
51 |
$information->prepare();
|
52 |
}
|
application/controllers/page/extension/settings.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Types_Page_Extension_Settings
|
5 |
+
*
|
6 |
+
* @since 2.1
|
7 |
+
*/
|
8 |
+
class Types_Page_Extension_Settings {
|
9 |
+
|
10 |
+
public function build() {
|
11 |
+
// general tab
|
12 |
+
add_filter( 'toolset_filter_toolset_register_settings_general_section', array( $this, 'general' ), 10, 2 );
|
13 |
+
|
14 |
+
// script
|
15 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'on_admin_enqueue_scripts' ) );
|
16 |
+
add_action( 'admin_print_scripts', array( $this, 'print_admin_scripts' ) );
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* General Tab
|
21 |
+
*
|
22 |
+
* @param $sections
|
23 |
+
* @param $toolset_options
|
24 |
+
*
|
25 |
+
* @return mixed
|
26 |
+
*/
|
27 |
+
public function general( $sections, $toolset_options ) {
|
28 |
+
|
29 |
+
$view = new Types_Helper_Twig();
|
30 |
+
|
31 |
+
// Information Table
|
32 |
+
$setting = new Types_Setting_Preset_Information_Table();
|
33 |
+
|
34 |
+
$sections[$setting->get_id()] = array(
|
35 |
+
'slug' => $setting->get_id(),
|
36 |
+
'title' => __( '"Front-end Display" table', 'types' ),
|
37 |
+
'content' => $view->render(
|
38 |
+
'/setting/checkbox.twig',
|
39 |
+
array(
|
40 |
+
'description' => __( 'Show information about Template, Archive, Views and Forms on:', 'types' ),
|
41 |
+
'setting' => $setting,
|
42 |
+
)
|
43 |
+
)
|
44 |
+
);
|
45 |
+
|
46 |
+
return $sections;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Admin Scripts
|
51 |
+
*/
|
52 |
+
public function on_admin_enqueue_scripts() {
|
53 |
+
// script
|
54 |
+
wp_enqueue_script(
|
55 |
+
'types-toolset-settings',
|
56 |
+
TYPES_RELPATH . '/public/js/settings.js',
|
57 |
+
array(),
|
58 |
+
TYPES_VERSION,
|
59 |
+
true
|
60 |
+
);
|
61 |
+
}
|
62 |
+
|
63 |
+
public function print_admin_scripts() {
|
64 |
+
echo '<script id="types_model_data" type="text/plain">'.base64_encode( wp_json_encode( $this->build_js_data() ) ).'</script>';
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Build data to be passed to JavaScript.
|
69 |
+
*
|
70 |
+
* @return array
|
71 |
+
* @since 2.1
|
72 |
+
*/
|
73 |
+
private function build_js_data() {
|
74 |
+
|
75 |
+
$types_settings_action = Types_Ajax::get_instance()->get_action_js_name( Types_Ajax::CALLBACK_SETTINGS_ACTION );
|
76 |
+
|
77 |
+
return array(
|
78 |
+
'ajaxInfo' => array(
|
79 |
+
'fieldAction' => array(
|
80 |
+
'name' => $types_settings_action,
|
81 |
+
'nonce' => wp_create_nonce( $types_settings_action )
|
82 |
+
)
|
83 |
+
),
|
84 |
+
);
|
85 |
+
}
|
86 |
+
}
|
application/controllers/page/field_control.php
CHANGED
@@ -171,8 +171,7 @@ final class Types_Page_Field_Control extends Types_Page_Abstract {
|
|
171 |
'wp-admin',
|
172 |
'common',
|
173 |
'font-awesome',
|
174 |
-
'wpcf-css-embedded'
|
175 |
-
'wp-jquery-ui-dialog'
|
176 |
)
|
177 |
);
|
178 |
|
171 |
'wp-admin',
|
172 |
'common',
|
173 |
'font-awesome',
|
174 |
+
'wpcf-css-embedded'
|
|
|
175 |
)
|
176 |
);
|
177 |
|
application/controllers/page/hidden/helper.php
CHANGED
@@ -1,5 +1,10 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
class Types_Page_Hidden_Helper extends Types_Page_Abstract {
|
4 |
|
5 |
private static $instance;
|
@@ -66,10 +71,14 @@ class Types_Page_Hidden_Helper extends Types_Page_Abstract {
|
|
66 |
case 'new-wordpress-archive':
|
67 |
$this->redirect_url = $this->new_wordpress_archive_action( $_GET['type'] );
|
68 |
break;
|
|
|
|
|
|
|
69 |
}
|
70 |
|
71 |
}
|
72 |
|
|
|
73 |
$this->redirect();
|
74 |
}
|
75 |
|
@@ -123,6 +132,38 @@ class Types_Page_Hidden_Helper extends Types_Page_Abstract {
|
|
123 |
return false;
|
124 |
}
|
125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
/**
|
127 |
* hidden page, but only when redirect after doing what we have to do
|
128 |
*/
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Page_Hidden_Helper
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Page_Hidden_Helper extends Types_Page_Abstract {
|
9 |
|
10 |
private static $instance;
|
71 |
case 'new-wordpress-archive':
|
72 |
$this->redirect_url = $this->new_wordpress_archive_action( $_GET['type'] );
|
73 |
break;
|
74 |
+
case 'new-post-field-group':
|
75 |
+
$this->redirect_url = $this->new_post_field_group_action( $_GET['type'] );
|
76 |
+
break;
|
77 |
}
|
78 |
|
79 |
}
|
80 |
|
81 |
+
$this->redirect_url = $this->add_params_to_url( $this->redirect_url );
|
82 |
$this->redirect();
|
83 |
}
|
84 |
|
132 |
return false;
|
133 |
}
|
134 |
|
135 |
+
private function new_post_field_group_action( $type ) {
|
136 |
+
|
137 |
+
$type_object = get_post_type_object( $type );
|
138 |
+
$title = sprintf( __( 'Field Group for %s', 'types' ), $type_object->labels->name );
|
139 |
+
$name = sanitize_title( $title );
|
140 |
+
|
141 |
+
$new_post_field_group = Types_Field_Group_Post_Factory::get_instance()->create( $name, $title, 'publish' );
|
142 |
+
|
143 |
+
if( ! $new_post_field_group )
|
144 |
+
return false;
|
145 |
+
|
146 |
+
$new_post_field_group->assign_post_type( $type );
|
147 |
+
|
148 |
+
$url = isset( $_GET['ref'] )
|
149 |
+
? 'admin.php?page=wpcf-edit&group_id='.$new_post_field_group->get_id().'&ref='.$_GET['ref']
|
150 |
+
: 'admin.php?page=wpcf-edit&group_id='.$new_post_field_group->get_id();
|
151 |
+
|
152 |
+
return admin_url( $url );
|
153 |
+
}
|
154 |
+
|
155 |
+
private function add_params_to_url( $url ) {
|
156 |
+
// forward parameter toolset_help_video
|
157 |
+
if( isset( $_GET['toolset_help_video'] ) )
|
158 |
+
$url = add_query_arg( 'toolset_help_video', $_GET['toolset_help_video'], $url );
|
159 |
+
|
160 |
+
// forward parameter ref
|
161 |
+
if( isset( $_GET['ref'] ) )
|
162 |
+
$url = add_query_arg( 'ref', $_GET['ref'], $url );
|
163 |
+
|
164 |
+
return $url;
|
165 |
+
}
|
166 |
+
|
167 |
/**
|
168 |
* hidden page, but only when redirect after doing what we have to do
|
169 |
*/
|
application/controllers/upgrade.php
ADDED
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Plugin upgrade controller.
|
5 |
+
*
|
6 |
+
* Compares current plugin version with a version number stored in the database, and performs upgrade routines if
|
7 |
+
* necessary.
|
8 |
+
*
|
9 |
+
* Note: Filters to add upgrade routines are not provided on purpose, so all routines need to be defined here.
|
10 |
+
*
|
11 |
+
* It works with version numbers, which are easier to compare and manipulate with. See convert_version_string_to_number()
|
12 |
+
* for details.
|
13 |
+
*
|
14 |
+
* @since 2.1
|
15 |
+
*/
|
16 |
+
class Types_Upgrade {
|
17 |
+
|
18 |
+
private static $instance;
|
19 |
+
|
20 |
+
public static function get_instance() {
|
21 |
+
if( null == self::$instance ) {
|
22 |
+
self::$instance = new self();
|
23 |
+
}
|
24 |
+
return self::$instance;
|
25 |
+
}
|
26 |
+
|
27 |
+
|
28 |
+
private function __construct() { }
|
29 |
+
|
30 |
+
|
31 |
+
private function __clone() { }
|
32 |
+
|
33 |
+
|
34 |
+
public static function initialize() {
|
35 |
+
$instance = self::get_instance();
|
36 |
+
$instance->check_upgrade();
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
// Legacy option names used to store version string.
|
41 |
+
const TYPES_DATABASE_VERSION_OPTION_LEGACY1 = 'WPCF_VERSION';
|
42 |
+
const TYPES_DATABASE_VERSION_OPTION_LEGACY2 = 'wpcf-version';
|
43 |
+
|
44 |
+
/** Name of the option used to store version number. */
|
45 |
+
const TYPES_DATABASE_VERSION_OPTION = 'types_database_version';
|
46 |
+
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Check if an upgrade is needed, and if yes, perform it.
|
50 |
+
*
|
51 |
+
* @since 2.1
|
52 |
+
*/
|
53 |
+
public function check_upgrade() {
|
54 |
+
|
55 |
+
if( $this->is_upgrade_needed() ) {
|
56 |
+
$this->do_upgrade();
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Returns true if an upgrade is needed.
|
64 |
+
*
|
65 |
+
* @return bool
|
66 |
+
* @since 2.1
|
67 |
+
*/
|
68 |
+
private function is_upgrade_needed() {
|
69 |
+
return ( $this->get_database_version() < $this->get_plugin_version() );
|
70 |
+
}
|
71 |
+
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Get current plugin version number.
|
75 |
+
*
|
76 |
+
* @return int
|
77 |
+
* @since 2.1
|
78 |
+
*/
|
79 |
+
private function get_plugin_version() {
|
80 |
+
return $this->convert_version_string_to_number( TYPES_VERSION );
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Get number of the version stored in the database.
|
86 |
+
*
|
87 |
+
* @return int
|
88 |
+
* @since 2.1
|
89 |
+
*/
|
90 |
+
private function get_database_version() {
|
91 |
+
$version = (int) get_option( self::TYPES_DATABASE_VERSION_OPTION, 0 );
|
92 |
+
|
93 |
+
if( 0 === $version ) {
|
94 |
+
$version = get_option( self::TYPES_DATABASE_VERSION_OPTION_LEGACY1, 0 );
|
95 |
+
|
96 |
+
if( 0 === $version ) {
|
97 |
+
$version = get_option( self::TYPES_DATABASE_VERSION_OPTION_LEGACY2, 0 );
|
98 |
+
}
|
99 |
+
|
100 |
+
$version = $this->convert_version_string_to_number( $version );
|
101 |
+
}
|
102 |
+
|
103 |
+
return $version;
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Transform a version string to a version number.
|
109 |
+
*
|
110 |
+
* The version string looks like this: "major.minor[.maintenance[.revision]]". We expect that all parts have
|
111 |
+
* two digits at most.
|
112 |
+
*
|
113 |
+
* Conversion to version number is done like this:
|
114 |
+
* $ver_num = MAJOR * 1000000
|
115 |
+
* + MINOR * 10000
|
116 |
+
* + MAINTENANCE * 100
|
117 |
+
* + REVISION * 1
|
118 |
+
*
|
119 |
+
* That means, for example "1.8.11.12" will be equal to:
|
120 |
+
* 1000000
|
121 |
+
* + 80000
|
122 |
+
* + 1100
|
123 |
+
* + 12
|
124 |
+
* ---------
|
125 |
+
* = 1081112
|
126 |
+
*
|
127 |
+
* @param string $version_string
|
128 |
+
* @return int
|
129 |
+
* @since 2.1
|
130 |
+
*/
|
131 |
+
private function convert_version_string_to_number( $version_string ) {
|
132 |
+
|
133 |
+
if( 0 === $version_string ) {
|
134 |
+
return 0;
|
135 |
+
}
|
136 |
+
|
137 |
+
$version_parts = explode( '.', $version_string );
|
138 |
+
$multipliers = array( 1000000, 10000, 100, 1 );
|
139 |
+
|
140 |
+
$version_part_count = count( $version_parts );
|
141 |
+
$version = 0;
|
142 |
+
for( $i = 0; $i < $version_part_count; ++$i ) {
|
143 |
+
$version_part = (int) $version_parts[ $i ];
|
144 |
+
$multiplier = $multipliers[ $i ];
|
145 |
+
|
146 |
+
$version += $version_part * $multiplier;
|
147 |
+
}
|
148 |
+
|
149 |
+
return $version;
|
150 |
+
}
|
151 |
+
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Update the version number stored in the database.
|
155 |
+
*
|
156 |
+
* @param int $version_number
|
157 |
+
* @since 2.1
|
158 |
+
*/
|
159 |
+
private function update_database_version( $version_number ) {
|
160 |
+
if( is_numeric( $version_number ) ) {
|
161 |
+
update_option( self::TYPES_DATABASE_VERSION_OPTION, (int) $version_number );
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Get an array of upgrade routines.
|
168 |
+
*
|
169 |
+
* Each routine is defined as an associative array with two elements:
|
170 |
+
* - 'version': int, which specifies the *target* version after the upgrade
|
171 |
+
* - 'callback': callable
|
172 |
+
*
|
173 |
+
* @return array
|
174 |
+
* @since 2.1
|
175 |
+
*/
|
176 |
+
private function get_upgrade_routines() {
|
177 |
+
|
178 |
+
$upgrade_routines = array(
|
179 |
+
array(
|
180 |
+
'version' => 2010000,
|
181 |
+
'callback' => array( $this, 'upgrade_db_to_2010000' )
|
182 |
+
)
|
183 |
+
);
|
184 |
+
|
185 |
+
return $upgrade_routines;
|
186 |
+
}
|
187 |
+
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Perform the upgrade by calling the appropriate upgrade routines and updating the version number in the database.
|
191 |
+
*
|
192 |
+
* @since 2.1
|
193 |
+
*/
|
194 |
+
private function do_upgrade() {
|
195 |
+
|
196 |
+
$from_version = $this->get_database_version();
|
197 |
+
$upgrade_routines = $this->get_upgrade_routines();
|
198 |
+
$target_version = $this->get_plugin_version();
|
199 |
+
|
200 |
+
// Sort upgrade routines by their version.
|
201 |
+
$routines_by_version = array();
|
202 |
+
foreach( $upgrade_routines as $key => $row ) {
|
203 |
+
$routines_by_version[ $key ] = $row['version'];
|
204 |
+
}
|
205 |
+
array_multisort( $routines_by_version, SORT_DESC, $upgrade_routines );
|
206 |
+
|
207 |
+
// Run all the routines necessary
|
208 |
+
foreach( $upgrade_routines as $routine ) {
|
209 |
+
$upgrade_version = (int) wpcf_getarr( $routine, 'version' );
|
210 |
+
|
211 |
+
if( $from_version < $upgrade_version && $upgrade_version <= $target_version ) {
|
212 |
+
$callback = wpcf_getarr( $routine, 'callback' );
|
213 |
+
if( is_callable( $callback ) ) {
|
214 |
+
call_user_func( $callback );
|
215 |
+
}
|
216 |
+
$this->update_database_version( $upgrade_version );
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
// Finally, update to current plugin version even if there are no other routines to run, so that
|
221 |
+
// this method is not called every time by check_upgrade().
|
222 |
+
$this->update_database_version( $target_version );
|
223 |
+
}
|
224 |
+
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Upgrade database to 2010000 (Types 2.1)
|
228 |
+
*
|
229 |
+
* Batch fix types-768 for all non-superadmin users.
|
230 |
+
*/
|
231 |
+
function upgrade_db_to_2010000() {
|
232 |
+
|
233 |
+
$roles_manager = WPCF_Roles::getInstance();
|
234 |
+
|
235 |
+
global $wpdb;
|
236 |
+
|
237 |
+
// Will find users without the administrator roles but with one of the Types management roles.
|
238 |
+
// A sign of the types-768 bug.
|
239 |
+
$user_query = new WP_User_Query(
|
240 |
+
array(
|
241 |
+
'meta_query' => array(
|
242 |
+
'relation' => 'AND',
|
243 |
+
array(
|
244 |
+
'key' => $wpdb->prefix . 'capabilities',
|
245 |
+
'value' => '"administrator"',
|
246 |
+
'compare' => 'NOT LIKE',
|
247 |
+
),
|
248 |
+
array(
|
249 |
+
'key' => $wpdb->prefix . 'capabilities',
|
250 |
+
'value' => '"wpcf_custom_post_type_view"',
|
251 |
+
'compare' => 'LIKE',
|
252 |
+
),
|
253 |
+
)
|
254 |
+
)
|
255 |
+
);
|
256 |
+
|
257 |
+
$users = $user_query->get_results();
|
258 |
+
|
259 |
+
foreach( $users as $user ) {
|
260 |
+
$roles_manager->clean_the_mess_in_nonadmin_user_caps( $user );
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
}
|
{library/toolset/types/embedded/classes → application/controllers}/utils.php
RENAMED
@@ -5,7 +5,7 @@
|
|
5 |
*
|
6 |
* @since 1.9
|
7 |
*/
|
8 |
-
final class
|
9 |
|
10 |
|
11 |
/**
|
5 |
*
|
6 |
* @since 1.9
|
7 |
*/
|
8 |
+
final class Types_Utils {
|
9 |
|
10 |
|
11 |
/**
|
application/data/dashboard/table/archive.php
ADDED
@@ -0,0 +1,234 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
return array(
|
3 |
+
/* Post Type with has_archive = false */
|
4 |
+
'no-archive-support' => array(
|
5 |
+
'type' => 'archive',
|
6 |
+
|
7 |
+
'priority' => 'important',
|
8 |
+
|
9 |
+
'conditions'=> array(
|
10 |
+
'Types_Helper_Condition_Archive_No_Support'
|
11 |
+
),
|
12 |
+
|
13 |
+
'description' => array(
|
14 |
+
array(
|
15 |
+
'type' => 'paragraph',
|
16 |
+
'content' => __( 'The archive is disabled for this post type.', 'types' )
|
17 |
+
),
|
18 |
+
array(
|
19 |
+
'type' => 'paragraph',
|
20 |
+
'content' => __( 'To enable, go to <a href="%POST-TYPE-EDIT-HAS-ARCHIVE%">Options</a> and mark "has_archive".', 'types' )
|
21 |
+
),
|
22 |
+
),
|
23 |
+
),
|
24 |
+
|
25 |
+
/* No Views, No Layouts, Archive missing */
|
26 |
+
'archive-missing' => array(
|
27 |
+
'type' => 'archive',
|
28 |
+
|
29 |
+
'priority' => 'important',
|
30 |
+
|
31 |
+
'conditions'=> array(
|
32 |
+
'Types_Helper_Condition_Layouts_Missing',
|
33 |
+
'Types_Helper_Condition_Views_Missing',
|
34 |
+
'Types_Helper_Condition_Archive_Missing'
|
35 |
+
),
|
36 |
+
|
37 |
+
'description' => array(
|
38 |
+
array(
|
39 |
+
'type' => 'paragraph',
|
40 |
+
'content' => __( 'Your theme is missing the standard WordPress archive for %POST-LABEL-PLURAL%.', 'types' )
|
41 |
+
),
|
42 |
+
array(
|
43 |
+
'type' => 'dialog',
|
44 |
+
'class' => 'button',
|
45 |
+
'label' => __( 'Create archive', 'types' ),
|
46 |
+
'dialog' => array(
|
47 |
+
'id' => 'resolve-no-archive',
|
48 |
+
'description' => array(
|
49 |
+
array(
|
50 |
+
'type' => 'paragraph',
|
51 |
+
'content' => __( 'Toolset plugins let you design archive pages without writing PHP. Your archives will include all
|
52 |
+
the fields that you need and your design.', 'types' )
|
53 |
+
),
|
54 |
+
array(
|
55 |
+
'type' => 'link',
|
56 |
+
'class' => 'button-primary types-button',
|
57 |
+
'external' => true,
|
58 |
+
'label' => __( 'Learn about creating archives with Toolset', 'types' ),
|
59 |
+
'target' => Types_Helper_Url::get_url( 'creating-archives-with-toolset', 'popup' ),
|
60 |
+
),
|
61 |
+
array(
|
62 |
+
'type' => 'paragraph',
|
63 |
+
'content' => __( 'Or...', 'types' )
|
64 |
+
),
|
65 |
+
array(
|
66 |
+
'type' => 'link',
|
67 |
+
'external' => true,
|
68 |
+
'label' => __( 'Instructions to create the archive-%POST-TYPE-NAME%.php in PHP', 'types' ),
|
69 |
+
'target' => Types_Helper_Url::get_url( 'creating-archives-with-php', 'popup' )
|
70 |
+
),
|
71 |
+
)
|
72 |
+
)
|
73 |
+
)
|
74 |
+
),
|
75 |
+
),
|
76 |
+
|
77 |
+
/* No Views, No Layouts, Archive without Fields */
|
78 |
+
'archive-fields-missing' => array(
|
79 |
+
'type' => 'archive',
|
80 |
+
|
81 |
+
'priority' => 'important',
|
82 |
+
|
83 |
+
'conditions'=> array(
|
84 |
+
'Types_Helper_Condition_Layouts_Missing',
|
85 |
+
'Types_Helper_Condition_Views_Missing',
|
86 |
+
'Types_Helper_Condition_Archive_No_Fields',
|
87 |
+
),
|
88 |
+
|
89 |
+
'description' => array(
|
90 |
+
array(
|
91 |
+
'type' => 'paragraph',
|
92 |
+
'content' => __( 'The %POST-LABEL-PLURAL% archive of your theme is missing custom fields.', 'types' )
|
93 |
+
),
|
94 |
+
array(
|
95 |
+
'type' => 'dialog',
|
96 |
+
'class' => 'button',
|
97 |
+
'label' => __( 'Resolve', 'types' ),
|
98 |
+
'dialog' => array(
|
99 |
+
'id' => 'resolve-no-custom-fields',
|
100 |
+
'description' => array(
|
101 |
+
array(
|
102 |
+
'type' => 'paragraph',
|
103 |
+
'content' => __( 'Toolset plugins let you design archives with custom fields, without writing PHP.', 'types' )
|
104 |
+
),
|
105 |
+
array(
|
106 |
+
'type' => 'link',
|
107 |
+
'class' => 'button-primary types-button',
|
108 |
+
'external' => true,
|
109 |
+
'label' => __( 'Learn about creating archives with Toolset', 'types' ),
|
110 |
+
'target' => Types_Helper_Url::get_url( 'creating-archives-with-toolset', 'popup' ),
|
111 |
+
),
|
112 |
+
array(
|
113 |
+
'type' => 'paragraph',
|
114 |
+
'content' => __( 'Or...', 'types' )
|
115 |
+
),
|
116 |
+
array(
|
117 |
+
'type' => 'link',
|
118 |
+
'external' => true,
|
119 |
+
'label' => __( 'Instructions to create the archive-%POST-TYPE-NAME%.php in PHP', 'types' ),
|
120 |
+
'target' => Types_Helper_Url::get_url( 'creating-archives-with-php', 'popup' )
|
121 |
+
),
|
122 |
+
)
|
123 |
+
)
|
124 |
+
)
|
125 |
+
),
|
126 |
+
),
|
127 |
+
|
128 |
+
/* No Views, No Layouts, Archive Fields */
|
129 |
+
'archive-fields' => array(
|
130 |
+
'type' => 'archive',
|
131 |
+
|
132 |
+
'conditions'=> array(
|
133 |
+
'Types_Helper_Condition_Layouts_Missing',
|
134 |
+
'Types_Helper_Condition_Views_Missing',
|
135 |
+
'Types_Helper_Condition_Archive_Has_Fields',
|
136 |
+
),
|
137 |
+
|
138 |
+
'description' => array(
|
139 |
+
array(
|
140 |
+
'type' => 'paragraph',
|
141 |
+
'content' => __( '%POST-ARCHIVE-FILE%', 'types' )
|
142 |
+
),
|
143 |
+
),
|
144 |
+
),
|
145 |
+
|
146 |
+
/* Views, template missing */
|
147 |
+
'views-archive-missing' => array(
|
148 |
+
'type' => 'archive',
|
149 |
+
|
150 |
+
'priority' => 'important',
|
151 |
+
|
152 |
+
'conditions'=> array(
|
153 |
+
'Types_Helper_Condition_Layouts_Missing',
|
154 |
+
'Types_Helper_Condition_Views_Archive_Missing'
|
155 |
+
),
|
156 |
+
|
157 |
+
'description' => array(
|
158 |
+
array(
|
159 |
+
'type' => 'paragraph',
|
160 |
+
'content' => __( 'There is no WordPress Archive for %POST-LABEL-PLURAL%.', 'types' )
|
161 |
+
),
|
162 |
+
array(
|
163 |
+
'type' => 'link',
|
164 |
+
'class' => 'button',
|
165 |
+
'target' => '%POST-CREATE-VIEWS-ARCHIVE%',
|
166 |
+
'label' => __( 'Create archive', 'types' )
|
167 |
+
)
|
168 |
+
|
169 |
+
),
|
170 |
+
|
171 |
+
),
|
172 |
+
|
173 |
+
/* Views, archive */
|
174 |
+
'views-archive' => array(
|
175 |
+
'type' => 'archive',
|
176 |
+
|
177 |
+
'conditions'=> array(
|
178 |
+
'Types_Helper_Condition_Layouts_Missing',
|
179 |
+
'Types_Helper_Condition_Views_Archive_Exists'
|
180 |
+
),
|
181 |
+
|
182 |
+
'description' => array(
|
183 |
+
array(
|
184 |
+
'type' => 'link',
|
185 |
+
'label' => '%POST-VIEWS-ARCHIVE%',
|
186 |
+
'target' => '%POST-EDIT-VIEWS-ARCHIVE%',
|
187 |
+
)
|
188 |
+
),
|
189 |
+
|
190 |
+
),
|
191 |
+
|
192 |
+
/* Layouts, Archive missing */
|
193 |
+
'layouts-archive-missing' => array(
|
194 |
+
'type' => 'archive',
|
195 |
+
|
196 |
+
'priority' => 'important',
|
197 |
+
|
198 |
+
'conditions'=> array(
|
199 |
+
'Types_Helper_Condition_Layouts_Active',
|
200 |
+
'Types_Helper_Condition_Layouts_Archive_Missing'
|
201 |
+
),
|
202 |
+
|
203 |
+
'description' => array(
|
204 |
+
array(
|
205 |
+
'type' => 'paragraph',
|
206 |
+
'content' => __( 'There is no layout for the %POST-LABEL-PLURAL% archive.', 'types' )
|
207 |
+
),
|
208 |
+
array(
|
209 |
+
'type' => 'link',
|
210 |
+
'class' => 'button',
|
211 |
+
'label' => __( 'Create archive', 'types' ),
|
212 |
+
'target' => '%POST-CREATE-LAYOUT-ARCHIVE%',
|
213 |
+
)
|
214 |
+
),
|
215 |
+
),
|
216 |
+
|
217 |
+
/* Layouts, Archive */
|
218 |
+
'layouts-archive' => array(
|
219 |
+
'type' => 'archive',
|
220 |
+
|
221 |
+
'conditions'=> array(
|
222 |
+
'Types_Helper_Condition_Layouts_Active',
|
223 |
+
'Types_Helper_Condition_Layouts_Archive_Exists'
|
224 |
+
),
|
225 |
+
|
226 |
+
'description' => array(
|
227 |
+
array(
|
228 |
+
'type' => 'link',
|
229 |
+
'label' => '%POST-LAYOUT-ARCHIVE%',
|
230 |
+
'target' => '%POST-EDIT-LAYOUT-ARCHIVE%',
|
231 |
+
)
|
232 |
+
),
|
233 |
+
)
|
234 |
+
);
|
application/data/dashboard/table/forms.php
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
return array(
|
3 |
+
/* CRED missing */
|
4 |
+
'cred-missing' => array(
|
5 |
+
'type' => 'forms',
|
6 |
+
|
7 |
+
'conditions'=> array(
|
8 |
+
'Types_Helper_Condition_Cred_Missing'
|
9 |
+
),
|
10 |
+
|
11 |
+
'description' => array(
|
12 |
+
array(
|
13 |
+
'type' => 'dialog',
|
14 |
+
'class' => 'button',
|
15 |
+
'label' => __( 'Create Form', 'types' ),
|
16 |
+
'dialog' => array(
|
17 |
+
'id' => 'create-form',
|
18 |
+
'description' => array(
|
19 |
+
array(
|
20 |
+
'type' => 'paragraph',
|
21 |
+
'content' => __( 'To create a form for front-end content submission and editing, you need have CRED plugin installed.
|
22 |
+
CRED is part of the complete Toolset package for adding and displaying custom content.', 'types' )
|
23 |
+
),
|
24 |
+
array(
|
25 |
+
'type' => 'link',
|
26 |
+
'external' => true,
|
27 |
+
'label' => __( 'Learn how CRED forms work', 'types' ),
|
28 |
+
'target' => Types_Helper_Url::get_url( 'how-cred-work', 'popup' )
|
29 |
+
),
|
30 |
+
/*
|
31 |
+
array(
|
32 |
+
'type' => 'link',
|
33 |
+
'external' => true,
|
34 |
+
'label' => __( 'Free Toolset Trial', 'types' ),
|
35 |
+
'target' => Types_Helper_Url::get_url( 'free-trial', 'popup' )
|
36 |
+
),
|
37 |
+
*/
|
38 |
+
)
|
39 |
+
)
|
40 |
+
)
|
41 |
+
),
|
42 |
+
),
|
43 |
+
|
44 |
+
/* CRED, forms missing */
|
45 |
+
'cred-forms-missing' => array(
|
46 |
+
'type' => 'forms',
|
47 |
+
|
48 |
+
'conditions'=> array(
|
49 |
+
'Types_Helper_Condition_Layouts_Missing',
|
50 |
+
'Types_Helper_Condition_Cred_Forms_Missing'
|
51 |
+
),
|
52 |
+
|
53 |
+
'description' => array(
|
54 |
+
array(
|
55 |
+
'type' => 'link',
|
56 |
+
'class' => 'button',
|
57 |
+
'target' => '%POST-CREATE-FORM%',
|
58 |
+
'label' => __( 'Create form', 'types' )
|
59 |
+
)
|
60 |
+
)
|
61 |
+
),
|
62 |
+
|
63 |
+
/* CRED, forms */
|
64 |
+
'cred-forms' => array(
|
65 |
+
'type' => 'forms',
|
66 |
+
|
67 |
+
'conditions'=> array(
|
68 |
+
'Types_Helper_Condition_Cred_Active',
|
69 |
+
'Types_Helper_Condition_Layouts_Missing',
|
70 |
+
'Types_Helper_Condition_Cred_Forms_Exist'
|
71 |
+
),
|
72 |
+
|
73 |
+
'description' => array(
|
74 |
+
array(
|
75 |
+
'type' => 'paragraph',
|
76 |
+
'content' => '%POST-FORMS-LIST%', 'types'
|
77 |
+
),
|
78 |
+
array(
|
79 |
+
'type' => 'link',
|
80 |
+
'class' => 'button',
|
81 |
+
'target' => '%POST-CREATE-FORM%',
|
82 |
+
'label' => __( 'Create form', 'types' )
|
83 |
+
)
|
84 |
+
)
|
85 |
+
),
|
86 |
+
|
87 |
+
/* CRED & Layouts, forms missing */
|
88 |
+
'cred-layouts-forms-missing' => array(
|
89 |
+
'type' => 'forms',
|
90 |
+
|
91 |
+
'conditions'=> array(
|
92 |
+
'Types_Helper_Condition_Layouts_Active',
|
93 |
+
'Types_Helper_Condition_Cred_Forms_Missing'
|
94 |
+
),
|
95 |
+
|
96 |
+
'description' => array(
|
97 |
+
array(
|
98 |
+
'type' => 'paragraph',
|
99 |
+
'content' => __(
|
100 |
+
'You can create forms for front-end submission and editing of %POST-LABEL-PLURAL%.', 'types'
|
101 |
+
)
|
102 |
+
),
|
103 |
+
array(
|
104 |
+
'type' => 'link',
|
105 |
+
'external' => true,
|
106 |
+
'target' => Types_Helper_Url::get_url( 'adding-forms-to-layouts', 'table' ),
|
107 |
+
'label' => __( 'Learn how', 'types' )
|
108 |
+
),
|
109 |
+
)
|
110 |
+
),
|
111 |
+
|
112 |
+
/* CRED & Layouts, forms exists */
|
113 |
+
'cred-layouts-forms' => array(
|
114 |
+
'type' => 'forms',
|
115 |
+
|
116 |
+
'conditions'=> array(
|
117 |
+
'Types_Helper_Condition_Layouts_Active',
|
118 |
+
'Types_Helper_Condition_Cred_Forms_Exist'
|
119 |
+
),
|
120 |
+
|
121 |
+
'description' => array(
|
122 |
+
array(
|
123 |
+
'type' => 'paragraph',
|
124 |
+
'content' => '%POST-FORMS-LIST%', 'types'
|
125 |
+
),
|
126 |
+
array(
|
127 |
+
'type' => 'link',
|
128 |
+
'external' => true,
|
129 |
+
'target' => Types_Helper_Url::get_url( 'adding-forms-to-layouts', 'table' ),
|
130 |
+
'label' => __( 'How to add forms to layouts', 'types' )
|
131 |
+
),
|
132 |
+
)
|
133 |
+
),
|
134 |
+
);
|
application/data/dashboard/table/head.php
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
return array(
|
3 |
+
|
4 |
+
'type' => array(
|
5 |
+
'id' => 'type',
|
6 |
+
'title' => __( 'Post Type', 'types' ),
|
7 |
+
'description' => array(
|
8 |
+
array(
|
9 |
+
'type' => 'paragraph',
|
10 |
+
'content' => __( 'A list of all Post Types available in your site.', 'types' )
|
11 |
+
),
|
12 |
+
array(
|
13 |
+
'type' => 'link',
|
14 |
+
'external' => true,
|
15 |
+
'label' => __( 'Learn more', 'types' ),
|
16 |
+
'target' => Types_Helper_Url::get_url( 'learn-how-post-types', 'tooltip' )
|
17 |
+
),
|
18 |
+
)
|
19 |
+
),
|
20 |
+
|
21 |
+
'fields' => array(
|
22 |
+
'id' => 'fields',
|
23 |
+
'title' => __( 'Fields', 'types' ),
|
24 |
+
'description' => array(
|
25 |
+
array(
|
26 |
+
'type' => 'paragraph',
|
27 |
+
'content' => __( 'A list of all Post Fields and their attachment to the Post Types.', 'types' )
|
28 |
+
),
|
29 |
+
array(
|
30 |
+
'type' => 'link',
|
31 |
+
'external' => true,
|
32 |
+
'label' => __( 'Learn more', 'types' ),
|
33 |
+
'target' => Types_Helper_Url::get_url( 'learn-how-fields', 'tooltip' )
|
34 |
+
),
|
35 |
+
)
|
36 |
+
),
|
37 |
+
|
38 |
+
'taxonomies' => array(
|
39 |
+
'id' => 'taxonomies',
|
40 |
+
'title' => __( 'Taxonomies', 'types' ),
|
41 |
+
'description' => array(
|
42 |
+
array(
|
43 |
+
'type' => 'paragraph',
|
44 |
+
'content' => __( 'A list of all Taxonomies and their attachment to the Post Types.', 'types' )
|
45 |
+
),
|
46 |
+
array(
|
47 |
+
'type' => 'link',
|
48 |
+
'external' => true,
|
49 |
+
'label' => __( 'Learn more', 'types' ),
|
50 |
+
'target' => Types_Helper_Url::get_url( 'learn-how-taxonomies', 'tooltip' )
|
51 |
+
),
|
52 |
+
)
|
53 |
+
),
|
54 |
+
|
55 |
+
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
+
'template' => array(
|
60 |
+
'id' => 'template',
|
61 |
+
'title' => __( 'Template', 'types' ),
|
62 |
+
'description' => array(
|
63 |
+
array(
|
64 |
+
'type' => 'paragraph',
|
65 |
+
'content' => __( 'A template displays single-item pages with your design and fields.', 'types' )
|
66 |
+
),
|
67 |
+
array(
|
68 |
+
'type' => 'link',
|
69 |
+
'external' => true,
|
70 |
+
'label' => __( 'Learn more', 'types' ),
|
71 |
+
'target' => Types_Helper_Url::get_url( 'learn-how-template', 'tooltip' )
|
72 |
+
),
|
73 |
+
)
|
74 |
+
),
|
75 |
+
|
76 |
+
'archive' => array(
|
77 |
+
'id' => 'archive',
|
78 |
+
'title' => __( 'Archive', 'types' ),
|
79 |
+
'description' => array(
|
80 |
+
array(
|
81 |
+
'type' => 'paragraph',
|
82 |
+
'content' => __( 'An archive is the standard list that WordPress produces for content.', 'types' )
|
83 |
+
),
|
84 |
+
array(
|
85 |
+
'type' => 'link',
|
86 |
+
'external' => true,
|
87 |
+
'label' => __( 'Learn more', 'types' ),
|
88 |
+
'target' => Types_Helper_Url::get_url( 'learn-how-archive', 'tooltip' )
|
89 |
+
),
|
90 |
+
)
|
91 |
+
),
|
92 |
+
|
93 |
+
'views' => array(
|
94 |
+
'id' => 'views',
|
95 |
+
'title' => __( 'Views', 'types' ),
|
96 |
+
'description' => array(
|
97 |
+
array(
|
98 |
+
'type' => 'paragraph',
|
99 |
+
'content' => __( 'Views are custom lists of content, which you can display anywhere in the site.', 'types' )
|
100 |
+
),
|
101 |
+
array(
|
102 |
+
'type' => 'link',
|
103 |
+
'external' => true,
|
104 |
+
'label' => __( 'Learn more', 'types' ),
|
105 |
+
'target' => Types_Helper_Url::get_url( 'learn-how-views', 'tooltip' )
|
106 |
+
),
|
107 |
+
)
|
108 |
+
),
|
109 |
+
|
110 |
+
'forms' => array(
|
111 |
+
'id' => 'forms',
|
112 |
+
'title' => __( 'Forms', 'types' ),
|
113 |
+
'description' => array(
|
114 |
+
array(
|
115 |
+
'type' => 'paragraph',
|
116 |
+
'content' => __( 'Forms allow to create and edit content from the site’s front-end.', 'types' )
|
117 |
+
),
|
118 |
+
array(
|
119 |
+
'type' => 'link',
|
120 |
+
'external' => true,
|
121 |
+
'label' => __( 'Learn more', 'types' ),
|
122 |
+
'target' => Types_Helper_Url::get_url( 'learn-how-forms', 'tooltip' )
|
123 |
+
),
|
124 |
+
)
|
125 |
+
)
|
126 |
+
);
|
application/data/dashboard/table/template.php
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
return array(
|
3 |
+
/* No Views, No Layouts, Single Missing */
|
4 |
+
'single-missing' => array(
|
5 |
+
'type' => 'template',
|
6 |
+
|
7 |
+
'priority' => 'important',
|
8 |
+
|
9 |
+
'conditions'=> array(
|
10 |
+
'Types_Helper_Condition_Layouts_Missing',
|
11 |
+
'Types_Helper_Condition_Views_Missing',
|
12 |
+
'Types_Helper_Condition_Single_Missing'
|
13 |
+
),
|
14 |
+
|
15 |
+
'description' => array(
|
16 |
+
array(
|
17 |
+
'type' => 'paragraph',
|
18 |
+
'content' => __( 'Your theme doesn’t have a template to display %POST-LABEL-PLURAL%.', 'types' )
|
19 |
+
),
|
20 |
+
array(
|
21 |
+
'type' => 'dialog',
|
22 |
+
'class' => 'button',
|
23 |
+
'label' => __( 'Create template', 'types' ),
|
24 |
+
'dialog' => array(
|
25 |
+
'id' => 'resolve-single-no-template',
|
26 |
+
'description' => array(
|
27 |
+
array(
|
28 |
+
'type' => 'paragraph',
|
29 |
+
'content' => __( 'Toolset plugins let you design templates for single items (%POST-LABEL-SINGULAR% pages) without
|
30 |
+
writing PHP. Your templates will include all the fields that you need and your design.', 'types' )
|
31 |
+
),
|
32 |
+
array(
|
33 |
+
'type' => 'link',
|
34 |
+
'class' => 'button-primary types-button',
|
35 |
+
'external' => true,
|
36 |
+
'label' => __( 'Learn about creating templates with Toolset', 'types' ),
|
37 |
+
'target' => Types_Helper_Url::get_url( 'creating-templates-with-toolset', 'popup' ),
|
38 |
+
),
|
39 |
+
array(
|
40 |
+
'type' => 'paragraph',
|
41 |
+
'content' => __( 'Or...', 'types' )
|
42 |
+
),
|
43 |
+
array(
|
44 |
+
'type' => 'link',
|
45 |
+
'external' => true,
|
46 |
+
'label' => __( 'Instructions to create a single-%POST-TYPE-NAME%.php in PHP', 'types' ),
|
47 |
+
'target' => Types_Helper_Url::get_url( 'creating-templates-with-php', 'popup' )
|
48 |
+
),
|
49 |
+
)
|
50 |
+
)
|
51 |
+
)
|
52 |
+
),
|
53 |
+
),
|
54 |
+
|
55 |
+
/* No Views, No Layouts, Single, without Fields */
|
56 |
+
'single-fields-missing' => array(
|
57 |
+
'type' => 'template',
|
58 |
+
|
59 |
+
'priority' => 'important',
|
60 |
+
|
61 |
+
'conditions'=> array(
|
62 |
+
'Types_Helper_Condition_Layouts_Missing',
|
63 |
+
'Types_Helper_Condition_Views_Missing',
|
64 |
+
'Types_Helper_Condition_Single_No_Fields',
|
65 |
+
),
|
66 |
+
|
67 |
+
'description' => array(
|
68 |
+
array(
|
69 |
+
'type' => 'paragraph',
|
70 |
+
'content' => __( 'Your theme’s template file for displaying %POST-LABEL-SINGULAR% items is missing custom fields.', 'types' )
|
71 |
+
),
|
72 |
+
array(
|
73 |
+
'type' => 'dialog',
|
74 |
+
'class' => 'button-primary types-button',
|
75 |
+
'label' => __( 'Resolve', 'types' ),
|
76 |
+
'dialog' => array(
|
77 |
+
'id' => 'resolve-single-no-fields',
|
78 |
+
'description' => array(
|
79 |
+
array(
|
80 |
+
'type' => 'paragraph',
|
81 |
+
'content' => __( 'Toolset plugins let you design templates for single items (%POST-LABEL-SINGULAR% pages),
|
82 |
+
with all the fields that you need to display.', 'types' )
|
83 |
+
),
|
84 |
+
array(
|
85 |
+
'type' => 'link',
|
86 |
+
'class' => 'button-primary types-button',
|
87 |
+
'external' => true,
|
88 |
+
'label' => __( 'Learn about creating templates with Toolset', 'types' ),
|
89 |
+
'target' => Types_Helper_Url::get_url( 'creating-templates-with-toolset', 'popup' ),
|
90 |
+
),
|
91 |
+
array(
|
92 |
+
'type' => 'paragraph',
|
93 |
+
'content' => __( 'Or...', 'types' )
|
94 |
+
),
|
95 |
+
array(
|
96 |
+
'type' => 'link',
|
97 |
+
'external' => true,
|
98 |
+
'label' => __( 'Instructions for adding custom fields to single-%POST-TYPE-NAME%.php in PHP', 'types' ),
|
99 |
+
'target' => Types_Helper_Url::get_url( 'adding-custom-fields-with-php', 'popup' )
|
100 |
+
),
|
101 |
+
)
|
102 |
+
)
|
103 |
+
)
|
104 |
+
),
|
105 |
+
),
|
106 |
+
|
107 |
+
/* No Views, No Layouts, Single with Fields */
|
108 |
+
'single-fields' => array(
|
109 |
+
'type' => 'template',
|
110 |
+
|
111 |
+
'conditions'=> array(
|
112 |
+
'Types_Helper_Condition_Layouts_Missing',
|
113 |
+
'Types_Helper_Condition_Views_Missing',
|
114 |
+
'Types_Helper_Condition_Single_Has_Fields',
|
115 |
+
),
|
116 |
+
|
117 |
+
'description' => array(
|
118 |
+
array(
|
119 |
+
'type' => 'paragraph',
|
120 |
+
'content' => __( '%POST-TEMPLATE-FILE%', 'types' )
|
121 |
+
),
|
122 |
+
),
|
123 |
+
),
|
124 |
+
|
125 |
+
/* Views, template missing */
|
126 |
+
'views-template-missing' => array(
|
127 |
+
'type' => 'template',
|
128 |
+
|
129 |
+
'priority' => 'important',
|
130 |
+
|
131 |
+
'conditions'=> array(
|
132 |
+
'Types_Helper_Condition_Layouts_Missing',
|
133 |
+
'Types_Helper_Condition_Views_Template_Missing'
|
134 |
+
),
|
135 |
+
|
136 |
+
'description' => array(
|
137 |
+
array(
|
138 |
+
'type' => 'paragraph',
|
139 |
+
'content' => __( 'There is no Content Template for %POST-LABEL-SINGULAR% items.', 'types' )
|
140 |
+
),
|
141 |
+
array(
|
142 |
+
'type' => 'link',
|
143 |
+
'class' => 'button',
|
144 |
+
'target' => '%POST-CREATE-CONTENT-TEMPLATE%',
|
145 |
+
'label' => __( 'Create template', 'types' )
|
146 |
+
)
|
147 |
+
),
|
148 |
+
|
149 |
+
),
|
150 |
+
|
151 |
+
/* Views, template */
|
152 |
+
'views-template' => array(
|
153 |
+
'type' => 'template',
|
154 |
+
|
155 |
+
'conditions'=> array(
|
156 |
+
'Types_Helper_Condition_Layouts_Missing',
|
157 |
+
'Types_Helper_Condition_Views_Template_Exists'
|
158 |
+
),
|
159 |
+
|
160 |
+
'description' => array(
|
161 |
+
array(
|
162 |
+
'type' => 'link',
|
163 |
+
'label' => '%POST-CONTENT-TEMPLATE-NAME%',
|
164 |
+
'target' => '%POST-EDIT-CONTENT-TEMPLATE%'
|
165 |
+
),
|
166 |
+
),
|
167 |
+
|
168 |
+
),
|
169 |
+
|
170 |
+
/* Layouts, template missing*/
|
171 |
+
'layouts-template-missing' => array(
|
172 |
+
'type' => 'template',
|
173 |
+
|
174 |
+
'priority' => 'important',
|
175 |
+
|
176 |
+
'conditions'=> array(
|
177 |
+
'Types_Helper_Condition_Layouts_Active',
|
178 |
+
'Types_Helper_Condition_Layouts_Template_Missing'
|
179 |
+
),
|
180 |
+
|
181 |
+
'description' => array(
|
182 |
+
array(
|
183 |
+
'type' => 'paragraph',
|
184 |
+
'content' => __( 'There is no template layout for %POST-LABEL-SINGULAR% items.', 'types' )
|
185 |
+
),
|
186 |
+
array(
|
187 |
+
'type' => 'link',
|
188 |
+
'class' => 'button',
|
189 |
+
'label' => __( 'Create template', 'types' ),
|
190 |
+
'target' => '%POST-CREATE-LAYOUT-TEMPLATE%',
|
191 |
+
)
|
192 |
+
),
|
193 |
+
),
|
194 |
+
|
195 |
+
/* Layouts, template */
|
196 |
+
'layouts-template' => array(
|
197 |
+
'type' => 'template',
|
198 |
+
|
199 |
+
'conditions'=> array(
|
200 |
+
'Types_Helper_Condition_Layouts_Active',
|
201 |
+
'Types_Helper_Condition_Layouts_Template_Exists'
|
202 |
+
),
|
203 |
+
|
204 |
+
'description' => array(
|
205 |
+
array(
|
206 |
+
'type' => 'link',
|
207 |
+
'label' => '%POST-LAYOUT-TEMPLATE%',
|
208 |
+
'target' => '%POST-EDIT-LAYOUT-TEMPLATE%'
|
209 |
+
),
|
210 |
+
),
|
211 |
+
),
|
212 |
+
);
|
application/data/dashboard/table/views.php
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
return array(
|
3 |
+
/* Views missing */
|
4 |
+
'views-missing' => array(
|
5 |
+
'type' => 'views',
|
6 |
+
|
7 |
+
'conditions'=> array(
|
8 |
+
'Types_Helper_Condition_Views_Missing'
|
9 |
+
),
|
10 |
+
|
11 |
+
'description' => array(
|
12 |
+
array(
|
13 |
+
'type' => 'dialog',
|
14 |
+
'class' => 'button',
|
15 |
+
'label' => __( 'Create View', 'types' ),
|
16 |
+
'dialog' => array(
|
17 |
+
'id' => 'create-view',
|
18 |
+
'description' => array(
|
19 |
+
array(
|
20 |
+
'type' => 'paragraph',
|
21 |
+
'content' => __( 'To create a View for this content type, you need have Views plugin installed. Views is part of the
|
22 |
+
complete Toolset package for adding and displaying custom content.', 'types' )
|
23 |
+
),
|
24 |
+
array(
|
25 |
+
'type' => 'link',
|
26 |
+
'external' => true,
|
27 |
+
'label' => __( 'Learn how Views work', 'types' ),
|
28 |
+
'target' => Types_Helper_Url::get_url( 'how-views-work', 'popup' )
|
29 |
+
),
|
30 |
+
/*
|
31 |
+
array(
|
32 |
+
'type' => 'link',
|
33 |
+
'external' => true,
|
34 |
+
'label' => __( 'Free Toolset Trial', 'types' ),
|
35 |
+
'target' => Types_Helper_Url::get_url( 'free-trial', 'popup' )
|
36 |
+
)
|
37 |
+
*/
|
38 |
+
)
|
39 |
+
)
|
40 |
+
)
|
41 |
+
),
|
42 |
+
|
43 |
+
),
|
44 |
+
|
45 |
+
/* Views, views missing */
|
46 |
+
'views-views-missing' => array(
|
47 |
+
'type' => 'views',
|
48 |
+
|
49 |
+
'conditions'=> array(
|
50 |
+
'Types_Helper_Condition_Layouts_Missing',
|
51 |
+
'Types_Helper_Condition_Views_Views_Missing',
|
52 |
+
),
|
53 |
+
|
54 |
+
'description' => array(
|
55 |
+
array(
|
56 |
+
'type' => 'link',
|
57 |
+
'class' => 'button',
|
58 |
+
'target' => '%POST-CREATE-VIEW%',
|
59 |
+
'label' => __( 'Create View', 'types' )
|
60 |
+
)
|
61 |
+
)
|
62 |
+
),
|
63 |
+
|
64 |
+
/* Views, views */
|
65 |
+
'views-views' => array(
|
66 |
+
'type' => 'views',
|
67 |
+
|
68 |
+
'conditions'=> array(
|
69 |
+
'Types_Helper_Condition_Layouts_Missing',
|
70 |
+
'Types_Helper_Condition_Views_Views_Exist',
|
71 |
+
),
|
72 |
+
|
73 |
+
'description' => array(
|
74 |
+
array(
|
75 |
+
'type' => 'paragraph',
|
76 |
+
'content' => '%POST-VIEWS-LIST%', 'types'
|
77 |
+
),
|
78 |
+
array(
|
79 |
+
'type' => 'link',
|
80 |
+
'class' => 'button',
|
81 |
+
'target' => '%POST-CREATE-VIEW%',
|
82 |
+
'label' => __( 'Create View', 'types' )
|
83 |
+
)
|
84 |
+
)
|
85 |
+
),
|
86 |
+
|
87 |
+
/* Views Layouts, views missing */
|
88 |
+
'views-layouts-views-missing' => array(
|
89 |
+
'type' => 'views',
|
90 |
+
|
91 |
+
'conditions'=> array(
|
92 |
+
'Types_Helper_Condition_Layouts_Active',
|
93 |
+
'Types_Helper_Condition_Views_Views_Missing'
|
94 |
+
),
|
95 |
+
|
96 |
+
'description' => array(
|
97 |
+
array(
|
98 |
+
'type' => 'paragraph',
|
99 |
+
'content' => __(
|
100 |
+
'Edit any layout and add a View cell to it, to display lists of %POST-LABEL-PLURAL%.', 'types'
|
101 |
+
)
|
102 |
+
),
|
103 |
+
array(
|
104 |
+
'type' => 'link',
|
105 |
+
'external' => true,
|
106 |
+
'target' => Types_Helper_Url::get_url( 'adding-views-to-layouts', 'table' ),
|
107 |
+
'label' => __( 'Learn how', 'types' )
|
108 |
+
),
|
109 |
+
)
|
110 |
+
),
|
111 |
+
|
112 |
+
/* Views Layouts, views */
|
113 |
+
'views-layouts-views' => array(
|
114 |
+
'type' => 'views',
|
115 |
+
|
116 |
+
'conditions'=> array(
|
117 |
+
'Types_Helper_Condition_Layouts_Active',
|
118 |
+
'Types_Helper_Condition_Views_Views_Exist'
|
119 |
+
),
|
120 |
+
|
121 |
+
'description' => array(
|
122 |
+
array(
|
123 |
+
'type' => 'paragraph',
|
124 |
+
'content' => '%POST-VIEWS-LIST%', 'types'
|
125 |
+
),
|
126 |
+
array(
|
127 |
+
'type' => 'link',
|
128 |
+
'external' => true,
|
129 |
+
'target' => Types_Helper_Url::get_url( 'adding-views-to-layouts', 'table' ),
|
130 |
+
'label' => __( 'How to add Views to layouts', 'types' )
|
131 |
+
),
|
132 |
+
)
|
133 |
+
),
|
134 |
+
);
|
application/data/documentation-urls.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Google Analytics
|
4 |
+
// ?utm_source=typesplugin&utm_campaign=types&utm_medium=%CURRENT-SCREEN%&utm_term=EMPTY&utm_content=EMPTY
|
5 |
+
|
6 |
+
return array(
|
7 |
+
'learn-how-template' => 'https://wp-types.com/documentation/user-guides/benefits-of-templates-for-custom-types/',
|
8 |
+
'learn-how-archive' => 'https://wp-types.com/documentation/user-guides/what-archives-are-and-why-they-are-so-important/',
|
9 |
+
'learn-how-views' => 'https://wp-types.com/documentation/user-guides/learn-what-you-can-do-with-views/',
|
10 |
+
'learn-how-forms' => 'https://wp-types.com/home/cred/',
|
11 |
+
'learn-how-post-types' => 'https://wp-types.com/documentation/user-guides/create-a-custom-post-type/',
|
12 |
+
'learn-how-fields' => 'https://wp-types.com/documentation/user-guides/using-custom-fields/',
|
13 |
+
'learn-how-taxonomies' => 'https://wp-types.com/documentation/user-guides/create-custom-taxonomies/',
|
14 |
+
'creating-templates-with-toolset' => 'https://wp-types.com/documentation/user-guides/learn-about-creating-templates-with-toolset/',
|
15 |
+
'creating-templates-with-php' => 'https://wp-types.com/documentation/user-guides/creating-templates-for-single-custom-posts-in-php/',
|
16 |
+
'creating-archives-with-toolset' => 'https://wp-types.com/documentation/user-guides/learn-about-creating-archives-with-toolset/',
|
17 |
+
'creating-archives-with-php' => 'https://wp-types.com/documentation/user-guides/creating-templates-custom-post-type-archives-php/',
|
18 |
+
'how-views-work' => 'https://wp-types.com/documentation/user-guides/learn-what-you-can-do-with-views/',
|
19 |
+
'how-to-add-views-to-layouts' => 'https://wp-types.com/documentation/user-guides/views/',
|
20 |
+
'learn-views' => 'https://wp-types.com/documentation/user-guides/learn-what-you-can-do-with-views/',
|
21 |
+
'how-cred-work' => 'https://wp-types.com/home/cred/',
|
22 |
+
'how-to-add-forms-to-layouts' => 'https://wp-types.com/documentation/user-guides/creating-cred-forms/',
|
23 |
+
'learn-cred' => 'https://wp-types.com/documentation/user-guides/learn-what-you-can-do-with-cred/',
|
24 |
+
'free-trial' => 'https://wp-types.com/?add-to-cart=363363&buy_now=1',
|
25 |
+
'adding-custom-fields-with-php' => 'https://wp-types.com/documentation/user-guides/displaying-wordpress-custom-fields/#1',
|
26 |
+
'themes-compatible-with-layouts' => 'https://wp-types.com/documentation/user-guides/layouts-theme-integration/#popular-integrated-themes',
|
27 |
+
'layouts-integration-instructions' => 'https://wp-types.com/documentation/user-guides/layouts-theme-integration/#replacing-wp-loop-with-layouts',
|
28 |
+
'adding-views-to-layouts' => 'https://wp-types.com/documentation/user-guides/adding-views-to-layouts/',
|
29 |
+
'adding-forms-to-layouts' => 'https://wp-types.com/documentation/user-guides/adding-cred-forms-to-layouts/',
|
30 |
+
'using-post-fields' => 'https://wp-types.com/user-guides/using-custom-fields/',
|
31 |
+
'adding-fields' => 'https://wp-types.com/documentation/user-guides/using-custom-fields/#introduction-to-wordpress-custom-fields',
|
32 |
+
'displaying-fields' => 'https://wp-types.com/documentation/user-guides/displaying-wordpress-custom-fields/',
|
33 |
+
'adding-user-fields' => 'https://wp-types.com/documentation/user-guides/user-fields/',
|
34 |
+
'displaying-user-fields' => 'https://wp-types.com/documentation/user-guides/displaying-wordpress-user-fields/',
|
35 |
+
'adding-term-fields' => 'https://wp-types.com/documentation/user-guides/term-fields/',
|
36 |
+
'displaying-term-fields' => 'https://wp-types.com/documentation/user-guides/displaying-wordpress-term-fields/',
|
37 |
+
'custom-post-types' => 'https://wp-types.com/documentation/user-guides/create-a-custom-post-type/',
|
38 |
+
'custom-taxonomy' => 'https://wp-types.com/documentation/user-guides/create-custom-taxonomies/',
|
39 |
+
'post-relationship' => 'https://wp-types.com/documentation/user-guides/creating-post-type-relationships/',
|
40 |
+
'compare-toolset-php' => 'https://wp-types.com/landing/toolset-vs-php/',
|
41 |
+
'types-fields-api' => 'https://wp-types.com/documentation/functions/',
|
42 |
+
'parent-child' => 'https://wp-types.com/documentation/user-guides/many-to-many-post-relationship/',
|
43 |
+
'custom-post-archives' => 'https://wp-types.com/documentation/user-guides/creating-wordpress-custom-post-archives/',
|
44 |
+
'using-taxonomy' => 'https://wp-types.com/documentation/user-guides/create-custom-taxonomies/',
|
45 |
+
'custom-taxonomy-archives' => 'https://wp-types.com/documentation/user-guides/creating-wordpress-custom-taxonomy-archives/',
|
46 |
+
'repeating-fields-group' => 'https://wp-types.com/documentation/user-guides/creating-groups-of-repeating-fields-using-fields-tables/',
|
47 |
+
'single-pages' => 'https://wp-types.com/documentation/user-guides/view-templates/',
|
48 |
+
'content-templates' => 'https://wp-types.com/documentation/user-guides/view-templates/',
|
49 |
+
'views-user-guide' => 'https://wp-types.com/documentation/user-guides/views/',
|
50 |
+
'wp-types' => 'https://wp-types.com/',
|
51 |
+
'date-filters' => 'http://wp-types.com/documentation/user-guides/date-filters/'
|
52 |
+
);
|
application/data/information/documentation-urls.php
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// Google Analytics
|
4 |
-
// ?utm_source=typesplugin&utm_campaign=types&utm_medium=%CURRENT-SCREEN%&utm_term=EMPTY&utm_content=EMPTY
|
5 |
-
|
6 |
-
return array(
|
7 |
-
'learn-how-template' => 'https://wp-types.com/documentation/user-guides/benefits-of-templates-for-custom-types/',
|
8 |
-
'learn-how-archive' => 'https://wp-types.com/documentation/user-guides/what-archives-are-and-why-they-are-so-important/',
|
9 |
-
'learn-how-views' => 'https://wp-types.com/documentation/user-guides/learn-what-you-can-do-with-views/',
|
10 |
-
'learn-how-forms' => 'https://wp-types.com/documentation/user-guides/learn-what-you-can-do-with-cred/',
|
11 |
-
'creating-templates-with-toolset' => 'https://wp-types.com/documentation/user-guides/learn-about-creating-templates-with-toolset/',
|
12 |
-
'creating-templates-with-php' => 'https://wp-types.com/documentation/user-guides/creating-templates-for-single-custom-posts-in-php/',
|
13 |
-
'creating-archives-with-toolset' => 'https://wp-types.com/documentation/user-guides/learn-about-creating-archives-with-toolset/',
|
14 |
-
'creating-archives-with-php' => 'https://wp-types.com/documentation/user-guides/creating-templates-custom-post-type-archives-php/',
|
15 |
-
'how-views-work' => 'https://wp-types.com/documentation/user-guides/views/',
|
16 |
-
'how-to-add-views-to-layouts' => 'https://wp-types.com/documentation/user-guides/views/',
|
17 |
-
'learn-views' => 'https://wp-types.com/documentation/user-guides/learn-what-you-can-do-with-views/',
|
18 |
-
'how-cred-work' => 'https://wp-types.com/documentation/user-guides/creating-cred-forms/',
|
19 |
-
'how-to-add-forms-to-layouts' => 'https://wp-types.com/documentation/user-guides/creating-cred-forms/',
|
20 |
-
'learn-cred' => 'https://wp-types.com/documentation/user-guides/learn-what-you-can-do-with-cred/',
|
21 |
-
'free-trial' => 'https://wp-types.com/?add-to-cart=363363&buy_now=1',
|
22 |
-
'adding-custom-fields-with-php' => 'https://wp-types.com/documentation/user-guides/displaying-wordpress-custom-fields/#1',
|
23 |
-
'themes-compatible-with-layouts' => 'https://wp-types.com/documentation/user-guides/layouts-theme-integration/#popular-integrated-themes',
|
24 |
-
'layouts-integration-instructions' => 'https://wp-types.com/documentation/user-guides/layouts-theme-integration/#replacing-wp-loop-with-layouts',
|
25 |
-
'adding-views-to-layouts' => 'https://wp-types.com/documentation/user-guides/adding-views-to-layouts/',
|
26 |
-
'adding-forms-to-layouts' => 'https://wp-types.com/documentation/user-guides/adding-cred-forms-to-layouts/',
|
27 |
-
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
application/data/information/table/template.php
CHANGED
@@ -78,7 +78,10 @@ return array(
|
|
78 |
array(
|
79 |
'type' => 'link',
|
80 |
'external' => true,
|
81 |
-
'label' =>
|
|
|
|
|
|
|
82 |
'target' => '%POST-PERMALINK%'
|
83 |
),
|
84 |
array(
|
@@ -189,7 +192,10 @@ return array(
|
|
189 |
array(
|
190 |
'type' => 'link',
|
191 |
'external' => true,
|
192 |
-
'label' =>
|
|
|
|
|
|
|
193 |
'target' => '%POST-PERMALINK%'
|
194 |
),
|
195 |
array(
|
78 |
array(
|
79 |
'type' => 'link',
|
80 |
'external' => true,
|
81 |
+
'label' => array(
|
82 |
+
'default' => __( 'Visit example %POST-LABEL-SINGULAR%', 'types' ),
|
83 |
+
'post-edit' => __( 'Visit this %POST-LABEL-SINGULAR%', 'types' ),
|
84 |
+
),
|
85 |
'target' => '%POST-PERMALINK%'
|
86 |
),
|
87 |
array(
|
192 |
array(
|
193 |
'type' => 'link',
|
194 |
'external' => true,
|
195 |
+
'label' => array(
|
196 |
+
'default' => __( 'Visit example %POST-LABEL-SINGULAR%', 'types' ),
|
197 |
+
'post-edit' => __( 'Visit this %POST-LABEL-SINGULAR%', 'types' ),
|
198 |
+
),
|
199 |
'target' => '%POST-PERMALINK%'
|
200 |
),
|
201 |
array(
|
application/functions.php
CHANGED
@@ -7,32 +7,6 @@
|
|
7 |
* @since 2.0
|
8 |
*/
|
9 |
|
10 |
-
|
11 |
-
if ( !function_exists( 'get_called_class' ) ) {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* PHP 5.2 support.
|
15 |
-
*
|
16 |
-
* get_called_class() is only in PHP >= 5.3, this is a workaround.
|
17 |
-
*
|
18 |
-
* @since 1.9
|
19 |
-
*/
|
20 |
-
function get_called_class() {
|
21 |
-
$bt = debug_backtrace();
|
22 |
-
$l = 0;
|
23 |
-
do {
|
24 |
-
$l++;
|
25 |
-
$lines = file( $bt[ $l ]['file'] );
|
26 |
-
$callerLine = $lines[ $bt[ $l ]['line'] - 1 ];
|
27 |
-
preg_match( '/([a-zA-Z0-9\_]+)::' . $bt[ $l ]['function'] . '/', $callerLine, $matches );
|
28 |
-
} while( $matches[1] === 'parent' && $matches[1] );
|
29 |
-
|
30 |
-
return $matches[1];
|
31 |
-
}
|
32 |
-
}
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
if( !function_exists( 'wpcf_getpost' ) ) {
|
37 |
|
38 |
/**
|
7 |
* @since 2.0
|
8 |
*/
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
if( !function_exists( 'wpcf_getpost' ) ) {
|
11 |
|
12 |
/**
|
{library/toolset/types/embedded/classes → application/models}/field/group.php
RENAMED
@@ -4,11 +4,13 @@
|
|
4 |
* Abstract representation of a field group (without defined type).
|
5 |
*
|
6 |
* Descendants of this class allways must be instantiated through appropriate factory class inheriting
|
7 |
-
* from
|
8 |
*
|
9 |
* Any method that permanently changes any group data needs to call execute_group_updated_action() afterwards.
|
|
|
|
|
10 |
*/
|
11 |
-
abstract class
|
12 |
|
13 |
/**
|
14 |
* Stores the slugs of the fields that belong to this group, as a comma separated list.
|
@@ -26,7 +28,7 @@ abstract class WPCF_Field_Group {
|
|
26 |
|
27 |
|
28 |
/**
|
29 |
-
*
|
30 |
*
|
31 |
* Note that it is protected - inheriting classes have to implement an override that should, additionally, check
|
32 |
* if the post has correct type.
|
@@ -138,7 +140,7 @@ abstract class WPCF_Field_Group {
|
|
138 |
* Change name of the field group.
|
139 |
*
|
140 |
* Do not confuse with the title. *All* changes of the name must happen through this method, otherwise
|
141 |
-
* unexpected behaviour of the
|
142 |
*
|
143 |
* @param string $value New value of the post name. Note that it may be further modified by WordPress before saving.
|
144 |
*/
|
@@ -209,6 +211,11 @@ abstract class WPCF_Field_Group {
|
|
209 |
public function get_field_slugs() {
|
210 |
if( null == $this->field_slugs ) {
|
211 |
$field_slug_list = get_post_meta( $this->get_id(), self::POSTMETA_FIELD_SLUGS_LIST, true );
|
|
|
|
|
|
|
|
|
|
|
212 |
$field_slugs = explode( self::FIELD_SLUG_DELIMITER, $field_slug_list );
|
213 |
|
214 |
// Remove empty slugs
|
@@ -322,11 +329,11 @@ abstract class WPCF_Field_Group {
|
|
322 |
*/
|
323 |
public function is_match( $search_string ) {
|
324 |
return (
|
325 |
-
|
326 |
-
||
|
327 |
-
||
|
328 |
-
||
|
329 |
-
||
|
330 |
);
|
331 |
}
|
332 |
|
@@ -353,10 +360,156 @@ abstract class WPCF_Field_Group {
|
|
353 |
* Executed after a group has been updated in the database.
|
354 |
*
|
355 |
* @param int $id Group ID.
|
356 |
-
* @param
|
|
|
357 |
* @since 1.9
|
358 |
*/
|
359 |
do_action( 'wpcf_group_updated', $this->get_id(), $this );
|
360 |
}
|
361 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
}
|
4 |
* Abstract representation of a field group (without defined type).
|
5 |
*
|
6 |
* Descendants of this class allways must be instantiated through appropriate factory class inheriting
|
7 |
+
* from Types_Field_Group_Factory.
|
8 |
*
|
9 |
* Any method that permanently changes any group data needs to call execute_group_updated_action() afterwards.
|
10 |
+
*
|
11 |
+
* @since 1.9
|
12 |
*/
|
13 |
+
abstract class Types_Field_Group {
|
14 |
|
15 |
/**
|
16 |
* Stores the slugs of the fields that belong to this group, as a comma separated list.
|
28 |
|
29 |
|
30 |
/**
|
31 |
+
* Types_Field_Group constructor.
|
32 |
*
|
33 |
* Note that it is protected - inheriting classes have to implement an override that should, additionally, check
|
34 |
* if the post has correct type.
|
140 |
* Change name of the field group.
|
141 |
*
|
142 |
* Do not confuse with the title. *All* changes of the name must happen through this method, otherwise
|
143 |
+
* unexpected behaviour of the Types_Field_Group_Factory can occur.
|
144 |
*
|
145 |
* @param string $value New value of the post name. Note that it may be further modified by WordPress before saving.
|
146 |
*/
|
211 |
public function get_field_slugs() {
|
212 |
if( null == $this->field_slugs ) {
|
213 |
$field_slug_list = get_post_meta( $this->get_id(), self::POSTMETA_FIELD_SLUGS_LIST, true );
|
214 |
+
|
215 |
+
if( !is_string( $field_slug_list ) ) {
|
216 |
+
$field_slug_list = '';
|
217 |
+
}
|
218 |
+
|
219 |
$field_slugs = explode( self::FIELD_SLUG_DELIMITER, $field_slug_list );
|
220 |
|
221 |
// Remove empty slugs
|
329 |
*/
|
330 |
public function is_match( $search_string ) {
|
331 |
return (
|
332 |
+
Types_Utils::is_string_match( $search_string, $this->get_id() )
|
333 |
+
|| Types_Utils::is_string_match( $search_string, $this->get_slug() )
|
334 |
+
|| Types_Utils::is_string_match( $search_string, $this->get_name() )
|
335 |
+
|| Types_Utils::is_string_match( $search_string, $this->get_display_name() )
|
336 |
+
|| Types_Utils::is_string_match( $search_string, $this->get_description() )
|
337 |
);
|
338 |
}
|
339 |
|
360 |
* Executed after a group has been updated in the database.
|
361 |
*
|
362 |
* @param int $id Group ID.
|
363 |
+
* @param Types_Field_Group $group The group object.
|
364 |
+
*
|
365 |
* @since 1.9
|
366 |
*/
|
367 |
do_action( 'wpcf_group_updated', $this->get_id(), $this );
|
368 |
}
|
369 |
|
370 |
+
|
371 |
+
/**
|
372 |
+
* @var null|false|string[] Cache for get_assigned_to_types().
|
373 |
+
*
|
374 |
+
* @since 2.1
|
375 |
+
*/
|
376 |
+
private $assigned_to_types = null;
|
377 |
+
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Fetch all post types assigned to this group from the database.
|
381 |
+
*
|
382 |
+
* @return false|string[] Array of post type slugs (empty array meaning "all post types") or false if not applicable.
|
383 |
+
* @since 2.1
|
384 |
+
*/
|
385 |
+
protected function fetch_assigned_to_types() {
|
386 |
+
return false;
|
387 |
+
}
|
388 |
+
|
389 |
+
|
390 |
+
/**
|
391 |
+
* Get all post types assigned to this group from the database.
|
392 |
+
*
|
393 |
+
* Cached.
|
394 |
+
*
|
395 |
+
* @return false|string[] Array of post type slugs (empty array meaning "all post types") or false if not applicable.
|
396 |
+
* @since 2.1
|
397 |
+
*/
|
398 |
+
public function get_assigned_to_types() {
|
399 |
+
if( null === $this->assigned_to_types ) {
|
400 |
+
$this->assigned_to_types = $this->fetch_assigned_to_types();
|
401 |
+
}
|
402 |
+
|
403 |
+
return $this->assigned_to_types;
|
404 |
+
}
|
405 |
+
|
406 |
+
|
407 |
+
private $assigned_to_items = null;
|
408 |
+
|
409 |
+
|
410 |
+
/**
|
411 |
+
* Fetch all items that are using this group.
|
412 |
+
*
|
413 |
+
* @return array|false Array of items (whose type varies upon the field domain) or false if not applicable.
|
414 |
+
* @since 2.1
|
415 |
+
*/
|
416 |
+
protected function fetch_assigned_to_items() {
|
417 |
+
return false;
|
418 |
+
}
|
419 |
+
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Get all items that are using this group.
|
423 |
+
*
|
424 |
+
* Cached.
|
425 |
+
*
|
426 |
+
* @return array|false Array of items (whose type varies upon the field domain) or false if not applicable.
|
427 |
+
* @since 2.1
|
428 |
+
*/
|
429 |
+
public function get_assigned_to_items() {
|
430 |
+
if( null === $this->assigned_to_items ) {
|
431 |
+
$this->fetch_assigned_to_items();
|
432 |
+
}
|
433 |
+
|
434 |
+
return $this->assigned_to_items;
|
435 |
+
}
|
436 |
+
|
437 |
+
/**
|
438 |
+
* Keys in the group export object.
|
439 |
+
*
|
440 |
+
* @since 2.1
|
441 |
+
*/
|
442 |
+
const XML_ID = 'ID';
|
443 |
+
const XML_SLUG = 'slug';
|
444 |
+
const XML_NAME = 'post_title';
|
445 |
+
const XML_TYPE = 'post_type';
|
446 |
+
const XML_DESCRIPTION = 'post_content';
|
447 |
+
const XML_IS_ACTIVE = 'is_active';
|
448 |
+
const XML_LEGACY_EXCERPT = 'post_excerpt';
|
449 |
+
const XML_LEGACY_POST_STATUS = 'post_status';
|
450 |
+
const XML_META_SECTION = 'meta';
|
451 |
+
|
452 |
+
|
453 |
+
/**
|
454 |
+
* Get raw data of this field group to be exported.
|
455 |
+
*
|
456 |
+
* @return array
|
457 |
+
* @since 2.1
|
458 |
+
*/
|
459 |
+
protected function get_export_fields() {
|
460 |
+
|
461 |
+
$field_slugs = $this->get_field_slugs();
|
462 |
+
$field_slugs = implode( ',', $field_slugs );
|
463 |
+
|
464 |
+
$result = array(
|
465 |
+
self::XML_ID => $this->get_id(),
|
466 |
+
self::XML_SLUG => $this->get_slug(),
|
467 |
+
self::XML_NAME => $this->get_name(),
|
468 |
+
self::XML_TYPE => $this->get_post_type(),
|
469 |
+
self::XML_IS_ACTIVE => $this->is_active(),
|
470 |
+
self::XML_LEGACY_EXCERPT => '',
|
471 |
+
self::XML_LEGACY_POST_STATUS => $this->get_post_status(),
|
472 |
+
self::XML_META_SECTION => array(
|
473 |
+
self::POSTMETA_FIELD_SLUGS_LIST => $field_slugs
|
474 |
+
),
|
475 |
+
WPCF_AUTHOR => $this->get_author()
|
476 |
+
);
|
477 |
+
|
478 |
+
return $result;
|
479 |
+
}
|
480 |
+
|
481 |
+
|
482 |
+
/**
|
483 |
+
* Get array of keys that should be used for generating field group checksum.
|
484 |
+
*
|
485 |
+
* @return string[]
|
486 |
+
* @since 2.1
|
487 |
+
*/
|
488 |
+
protected function get_keys_for_export_checksum() {
|
489 |
+
return array(
|
490 |
+
self::XML_NAME, self::XML_TYPE, self::XML_LEGACY_EXCERPT, self::XML_LEGACY_POST_STATUS, self::XML_IS_ACTIVE,
|
491 |
+
WPCF_AUTHOR, self::XML_META_SECTION
|
492 |
+
);
|
493 |
+
}
|
494 |
+
|
495 |
+
|
496 |
+
/**
|
497 |
+
* Create an export object for this group, containing complete information including checksum and annotation.
|
498 |
+
*
|
499 |
+
* @return array
|
500 |
+
* @since 2.1
|
501 |
+
*/
|
502 |
+
public function get_export_object() {
|
503 |
+
|
504 |
+
$data = $this->get_export_fields();
|
505 |
+
|
506 |
+
$ie_controller = Types_Import_Export::get_instance();
|
507 |
+
|
508 |
+
$data = $ie_controller->add_checksum_to_object( $data, $this->get_keys_for_export_checksum() );
|
509 |
+
|
510 |
+
$data = $ie_controller->annotate_object( $data, $this->get_name(), $this->get_slug() );
|
511 |
+
|
512 |
+
return $data;
|
513 |
+
}
|
514 |
+
|
515 |
}
|
library/toolset/types/embedded/classes/field/group_factory.php → application/models/field/group/factory.php
RENAMED
@@ -7,15 +7,17 @@
|
|
7 |
*
|
8 |
* Note: Cache is indexed by slugs, so if a field group can change it's slug, it is necessary to do
|
9 |
* an 'wpcf_field_group_renamed' action immediately after renaming.
|
|
|
|
|
10 |
*/
|
11 |
-
abstract class
|
12 |
|
13 |
|
14 |
/**
|
15 |
* Singleton parent.
|
16 |
*
|
17 |
* @link http://stackoverflow.com/questions/3126130/extending-singletons-in-php
|
18 |
-
* @return
|
19 |
*/
|
20 |
public static function get_instance() {
|
21 |
static $instances = array();
|
@@ -35,6 +37,27 @@ abstract class WPCF_Field_Group_Factory {
|
|
35 |
final private function __clone() { }
|
36 |
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
/**
|
39 |
* @return string Post type that holds information about this field group type.
|
40 |
*/
|
@@ -43,7 +66,7 @@ abstract class WPCF_Field_Group_Factory {
|
|
43 |
|
44 |
/**
|
45 |
* @return string Name of the class that represents this field group type (and that will be instantiated). It must
|
46 |
-
* be a child of
|
47 |
*/
|
48 |
abstract protected function get_field_group_class_name();
|
49 |
|
@@ -88,7 +111,8 @@ abstract class WPCF_Field_Group_Factory {
|
|
88 |
|
89 |
/**
|
90 |
* @param string $field_group_name Name of the field group.
|
91 |
-
*
|
|
|
92 |
*/
|
93 |
private function get_from_cache( $field_group_name ) {
|
94 |
return wpcf_getarr( $this->field_groups, $field_group_name, null );
|
@@ -97,7 +121,8 @@ abstract class WPCF_Field_Group_Factory {
|
|
97 |
|
98 |
/**
|
99 |
* Save a field group instance to cache.
|
100 |
-
*
|
|
|
101 |
*/
|
102 |
private function save_to_cache( $field_group ) {
|
103 |
$this->field_groups[ $field_group->get_slug() ] = $field_group;
|
@@ -118,7 +143,7 @@ abstract class WPCF_Field_Group_Factory {
|
|
118 |
*
|
119 |
* @param int|string|WP_Post $field_group_source Post ID of the field group, it's name or a WP_Post object.
|
120 |
*
|
121 |
-
* @return null|
|
122 |
*/
|
123 |
final public function load_field_group( $field_group_source ) {
|
124 |
|
@@ -169,7 +194,7 @@ abstract class WPCF_Field_Group_Factory {
|
|
169 |
* Update cache after a field group is renamed.
|
170 |
*
|
171 |
* @param string $original_name The old name of the field group.
|
172 |
-
* @param
|
173 |
*/
|
174 |
public function field_group_renamed( $original_name, $field_group ) {
|
175 |
if( $field_group->get_post_type() == $this->get_post_type() ) {
|
@@ -184,10 +209,11 @@ abstract class WPCF_Field_Group_Factory {
|
|
184 |
*
|
185 |
* @param string $name Sanitized field group name. Note that the final name may change when new post is inserted.
|
186 |
* @param string $title Field group title.
|
|
|
187 |
*
|
188 |
-
* @return null|
|
189 |
*/
|
190 |
-
final public function create_field_group( $name, $title = '' ) {
|
191 |
|
192 |
if( sanitize_title( $name ) != $name ) {
|
193 |
return null;
|
@@ -198,7 +224,8 @@ abstract class WPCF_Field_Group_Factory {
|
|
198 |
$post_id = wp_insert_post( array(
|
199 |
'post_type' => $this->get_post_type(),
|
200 |
'post_name' => $name,
|
201 |
-
'post_title' => empty( $title ) ? $name : $title
|
|
|
202 |
) );
|
203 |
|
204 |
if( 0 == $post_id ) {
|
@@ -206,7 +233,7 @@ abstract class WPCF_Field_Group_Factory {
|
|
206 |
}
|
207 |
|
208 |
// Store the mandatory postmeta, just to be safe. I'm not sure about invariants here.
|
209 |
-
update_post_meta( $post_id,
|
210 |
|
211 |
$field_group = $this->load_field_group( $post_id );
|
212 |
|
@@ -221,17 +248,24 @@ abstract class WPCF_Field_Group_Factory {
|
|
221 |
*
|
222 |
* @param array $query_args Optional. Arguments for the WP_Query that will be applied on the underlying posts.
|
223 |
* Post type query is added automatically.
|
224 |
-
*
|
225 |
-
*
|
|
|
|
|
|
|
226 |
*/
|
227 |
-
public function query_groups( $query_args = array()
|
|
|
|
|
|
|
|
|
228 |
|
229 |
// Query posts
|
230 |
-
$query_args = array_merge( $query_args, array( 'post_type' => $this->get_post_type() ) );
|
231 |
$query = new WP_Query( $query_args );
|
232 |
$posts = $query->get_posts();
|
233 |
|
234 |
-
// Transform posts into
|
235 |
$all_groups = array();
|
236 |
foreach( $posts as $post ) {
|
237 |
$field_group = $this->load_field_group( $post );
|
@@ -245,7 +279,7 @@ abstract class WPCF_Field_Group_Factory {
|
|
245 |
if( empty( $search_string ) ) {
|
246 |
$selected_groups = $all_groups;
|
247 |
} else {
|
248 |
-
/** @var
|
249 |
foreach ( $all_groups as $group ) {
|
250 |
if ( $group->is_match( $search_string ) ) {
|
251 |
$selected_groups[] = $group;
|
7 |
*
|
8 |
* Note: Cache is indexed by slugs, so if a field group can change it's slug, it is necessary to do
|
9 |
* an 'wpcf_field_group_renamed' action immediately after renaming.
|
10 |
+
*
|
11 |
+
* @since 1.9
|
12 |
*/
|
13 |
+
abstract class Types_Field_Group_Factory {
|
14 |
|
15 |
|
16 |
/**
|
17 |
* Singleton parent.
|
18 |
*
|
19 |
* @link http://stackoverflow.com/questions/3126130/extending-singletons-in-php
|
20 |
+
* @return Types_Field_Group_Factory Instance of calling class.
|
21 |
*/
|
22 |
public static function get_instance() {
|
23 |
static $instances = array();
|
37 |
final private function __clone() { }
|
38 |
|
39 |
|
40 |
+
/**
|
41 |
+
* For a given field domain, return the appropriate field group factory instance.
|
42 |
+
*
|
43 |
+
* @param string $domain Valid field domain
|
44 |
+
* @return Types_Field_Group_Factory
|
45 |
+
* @since 2.1
|
46 |
+
*/
|
47 |
+
public static function get_factory_by_domain( $domain ) {
|
48 |
+
switch( $domain ) {
|
49 |
+
case Types_Field_Utils::DOMAIN_POSTS:
|
50 |
+
return Types_Field_Group_Post_Factory::get_instance();
|
51 |
+
case Types_Field_Utils::DOMAIN_USERS:
|
52 |
+
return Types_Field_Group_User_Factory::get_instance();
|
53 |
+
case Types_Field_Utils::DOMAIN_TERMS:
|
54 |
+
return Types_Field_Group_Term_Factory::get_instance();
|
55 |
+
default:
|
56 |
+
throw new InvalidArgumentException( 'Invalid field domain.' );
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
/**
|
62 |
* @return string Post type that holds information about this field group type.
|
63 |
*/
|
66 |
|
67 |
/**
|
68 |
* @return string Name of the class that represents this field group type (and that will be instantiated). It must
|
69 |
+
* be a child of Types_Field_Group.
|
70 |
*/
|
71 |
abstract protected function get_field_group_class_name();
|
72 |
|
111 |
|
112 |
/**
|
113 |
* @param string $field_group_name Name of the field group.
|
114 |
+
*
|
115 |
+
* @return null|Types_Field_Group Field group instance or null if it's not cached.
|
116 |
*/
|
117 |
private function get_from_cache( $field_group_name ) {
|
118 |
return wpcf_getarr( $this->field_groups, $field_group_name, null );
|
121 |
|
122 |
/**
|
123 |
* Save a field group instance to cache.
|
124 |
+
*
|
125 |
+
* @param Types_Field_Group $field_group
|
126 |
*/
|
127 |
private function save_to_cache( $field_group ) {
|
128 |
$this->field_groups[ $field_group->get_slug() ] = $field_group;
|
143 |
*
|
144 |
* @param int|string|WP_Post $field_group_source Post ID of the field group, it's name or a WP_Post object.
|
145 |
*
|
146 |
+
* @return null|Types_Field_Group Field group or null if it can't be loaded.
|
147 |
*/
|
148 |
final public function load_field_group( $field_group_source ) {
|
149 |
|
194 |
* Update cache after a field group is renamed.
|
195 |
*
|
196 |
* @param string $original_name The old name of the field group.
|
197 |
+
* @param Types_Field_Group $field_group The field group involved, with already updated name.
|
198 |
*/
|
199 |
public function field_group_renamed( $original_name, $field_group ) {
|
200 |
if( $field_group->get_post_type() == $this->get_post_type() ) {
|
209 |
*
|
210 |
* @param string $name Sanitized field group name. Note that the final name may change when new post is inserted.
|
211 |
* @param string $title Field group title.
|
212 |
+
* @param string $status Only 'draft'|'publish' are expected. Groups with the 'draft' status will appear as deactivated.
|
213 |
*
|
214 |
+
* @return null|Types_Field_Group The new field group or null on error.
|
215 |
*/
|
216 |
+
final public function create_field_group( $name, $title = '', $status = 'draft' ) {
|
217 |
|
218 |
if( sanitize_title( $name ) != $name ) {
|
219 |
return null;
|
224 |
$post_id = wp_insert_post( array(
|
225 |
'post_type' => $this->get_post_type(),
|
226 |
'post_name' => $name,
|
227 |
+
'post_title' => empty( $title ) ? $name : $title,
|
228 |
+
'post_status' => $status,
|
229 |
) );
|
230 |
|
231 |
if( 0 == $post_id ) {
|
233 |
}
|
234 |
|
235 |
// Store the mandatory postmeta, just to be safe. I'm not sure about invariants here.
|
236 |
+
update_post_meta( $post_id, Types_Field_Group::POSTMETA_FIELD_SLUGS_LIST, '' );
|
237 |
|
238 |
$field_group = $this->load_field_group( $post_id );
|
239 |
|
248 |
*
|
249 |
* @param array $query_args Optional. Arguments for the WP_Query that will be applied on the underlying posts.
|
250 |
* Post type query is added automatically.
|
251 |
+
* Additional arguments are allowed:
|
252 |
+
* - 'types_search': String for extended search. See WPCF_Field_Group::is_match() for details.
|
253 |
+
*
|
254 |
+
* @return Types_Field_Group[]
|
255 |
+
* @since 1.9
|
256 |
*/
|
257 |
+
public function query_groups( $query_args = array() ) {
|
258 |
+
|
259 |
+
// Read specific arguments
|
260 |
+
$search_string = wpcf_getarr( $query_args, 'types_search' );
|
261 |
+
|
262 |
|
263 |
// Query posts
|
264 |
+
$query_args = array_merge( $query_args, array( 'post_type' => $this->get_post_type(), 'posts_per_page' => -1 ) );
|
265 |
$query = new WP_Query( $query_args );
|
266 |
$posts = $query->get_posts();
|
267 |
|
268 |
+
// Transform posts into Types_Field_Group
|
269 |
$all_groups = array();
|
270 |
foreach( $posts as $post ) {
|
271 |
$field_group = $this->load_field_group( $post );
|
279 |
if( empty( $search_string ) ) {
|
280 |
$selected_groups = $all_groups;
|
281 |
} else {
|
282 |
+
/** @var Types_Field_Group $group */
|
283 |
foreach ( $all_groups as $group ) {
|
284 |
if ( $group->is_match( $search_string ) ) {
|
285 |
$selected_groups[] = $group;
|
application/models/field/group/post.php
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Post field group.
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
+
final class Types_Field_Group_Post extends Types_Field_Group {
|
9 |
+
|
10 |
+
|
11 |
+
const POST_TYPE = 'wp-types-group';
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Postmeta that contains a comma-separated list of post type slugs where this field group is assigned.
|
15 |
+
*
|
16 |
+
* Note: There might be empty items in the list: ",,,post-type-slug,," Make sure to avoid those.
|
17 |
+
*
|
18 |
+
* Note: Empty value means "all groups". There also may be legacy value "all" with the same meaning.
|
19 |
+
*
|
20 |
+
* @since unknown
|
21 |
+
*/
|
22 |
+
const POSTMETA_POST_TYPE_LIST = '_wp_types_group_post_types';
|
23 |
+
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @param WP_Post $field_group_post Post object representing a post field group.
|
27 |
+
* @throws InvalidArgumentException
|
28 |
+
*/
|
29 |
+
public function __construct( $field_group_post ) {
|
30 |
+
parent::__construct( $field_group_post );
|
31 |
+
if( self::POST_TYPE != $field_group_post->post_type ) {
|
32 |
+
throw new InvalidArgumentException( 'incorrect post type' );
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @return WPCF_Field_Definition_Factory Field definition factory of the correct type.
|
39 |
+
*/
|
40 |
+
protected function get_field_definition_factory() {
|
41 |
+
return WPCF_Field_Definition_Factory_Post::get_instance();
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Assign a post type to the group
|
46 |
+
* @param $post_type
|
47 |
+
*/
|
48 |
+
public function assign_post_type( $post_type ) {
|
49 |
+
$post_types = $this->get_assigned_to_types();
|
50 |
+
$post_types[] = $post_type;
|
51 |
+
|
52 |
+
$this->store_post_types( $post_types );
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Stores an array of post types as list in database
|
57 |
+
*
|
58 |
+
* @param array $post_types
|
59 |
+
*/
|
60 |
+
protected function store_post_types( $post_types ) {
|
61 |
+
// validate post types
|
62 |
+
foreach( $post_types as $type ) {
|
63 |
+
if( empty( $type ) || ! get_post_type( $type ) )
|
64 |
+
unset( $post_types[$type] );
|
65 |
+
}
|
66 |
+
|
67 |
+
$post_types = empty( $post_types )
|
68 |
+
? ''
|
69 |
+
: implode( ',', $post_types );
|
70 |
+
|
71 |
+
update_post_meta( $this->get_id(), self::POSTMETA_POST_TYPE_LIST, $post_types );
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @inheritdoc
|
77 |
+
*
|
78 |
+
* @return array
|
79 |
+
* @since 2.1
|
80 |
+
*/
|
81 |
+
protected function fetch_assigned_to_types() {
|
82 |
+
$db_assigned_to = get_post_meta( $this->get_id(), self::POSTMETA_POST_TYPE_LIST, true );
|
83 |
+
|
84 |
+
// in old types version we store "all"
|
85 |
+
if ( 'all' == $db_assigned_to ) {
|
86 |
+
return array();
|
87 |
+
}
|
88 |
+
|
89 |
+
// Keep your eyes open on storing values,
|
90 |
+
// This is needed because legacy code produces values like ,,,,a-post-type,,
|
91 |
+
$db_assigned_to = trim( $db_assigned_to, ',' );
|
92 |
+
|
93 |
+
// empty means all post types are selected
|
94 |
+
if ( empty( $db_assigned_to ) ) {
|
95 |
+
return array();
|
96 |
+
}
|
97 |
+
|
98 |
+
// we have selected post types
|
99 |
+
return explode( ',', $db_assigned_to );
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @inheritdoc
|
106 |
+
* @return WP_Post[] Individual posts using this group.
|
107 |
+
* @since 2.1
|
108 |
+
*/
|
109 |
+
protected function fetch_assigned_to_items() {
|
110 |
+
$assigned_posts = $this->get_assigned_to_types();
|
111 |
+
|
112 |
+
if( empty( $assigned_posts ) ) {
|
113 |
+
$assigned_posts = array( 'all' );
|
114 |
+
}
|
115 |
+
|
116 |
+
$items = get_posts(
|
117 |
+
array(
|
118 |
+
'post_type' => $assigned_posts,
|
119 |
+
'post_status' => 'any',
|
120 |
+
'posts_per_page' => -1,
|
121 |
+
)
|
122 |
+
);
|
123 |
+
|
124 |
+
return $items;
|
125 |
+
}
|
126 |
+
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Get the backend edit link.
|
130 |
+
*
|
131 |
+
* @return string
|
132 |
+
* @since 2.1
|
133 |
+
*/
|
134 |
+
public function get_edit_link() {
|
135 |
+
return admin_url() . '/admin.php?page=wpcf-edit&group_id=' . $this->get_id();
|
136 |
+
}
|
137 |
+
|
138 |
+
}
|
library/toolset/types/embedded/classes/field/group_post_factory.php → application/models/field/group/post_factory.php
RENAMED
@@ -1,15 +1,15 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* Factory for the
|
5 |
*
|
6 |
* @since 2.0
|
7 |
*/
|
8 |
-
final class
|
9 |
|
10 |
|
11 |
/**
|
12 |
-
* @return
|
13 |
*/
|
14 |
public static function get_instance() {
|
15 |
return parent::get_instance();
|
@@ -27,14 +27,14 @@ final class WPCF_Field_Group_Post_Factory extends WPCF_Field_Group_Factory {
|
|
27 |
*
|
28 |
* @param int|string|WP_Post $field_group Post ID of the field group, it's name or a WP_Post object.
|
29 |
*
|
30 |
-
* @return null|
|
31 |
*/
|
32 |
public static function load( $field_group ) {
|
33 |
// we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
|
34 |
// we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
|
35 |
-
// instead of
|
36 |
// ends in an error because of parents (abstract) $var = new self();
|
37 |
-
return
|
38 |
}
|
39 |
|
40 |
|
@@ -44,24 +44,24 @@ final class WPCF_Field_Group_Post_Factory extends WPCF_Field_Group_Factory {
|
|
44 |
* @param string $name Sanitized field group name. Note that the final name may change when new post is inserted.
|
45 |
* @param string $title Field group title.
|
46 |
*
|
47 |
-
* @return null|
|
48 |
*/
|
49 |
-
public static function create( $name, $title = '' ) {
|
50 |
// we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
|
51 |
// we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
|
52 |
-
// instead of
|
53 |
// ends in an error because of parents (abstract) $var = new self();
|
54 |
-
return
|
55 |
}
|
56 |
|
57 |
|
58 |
public function get_post_type() {
|
59 |
-
return
|
60 |
}
|
61 |
|
62 |
|
63 |
protected function get_field_group_class_name() {
|
64 |
-
return '
|
65 |
}
|
66 |
|
67 |
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* Factory for the Types_Field_Group_Post class.
|
5 |
*
|
6 |
* @since 2.0
|
7 |
*/
|
8 |
+
final class Types_Field_Group_Post_Factory extends Types_Field_Group_Factory {
|
9 |
|
10 |
|
11 |
/**
|
12 |
+
* @return Types_Field_Group_Post_Factory
|
13 |
*/
|
14 |
public static function get_instance() {
|
15 |
return parent::get_instance();
|
27 |
*
|
28 |
* @param int|string|WP_Post $field_group Post ID of the field group, it's name or a WP_Post object.
|
29 |
*
|
30 |
+
* @return null|Types_Field_Group_Term Field group or null if it can't be loaded.
|
31 |
*/
|
32 |
public static function load( $field_group ) {
|
33 |
// we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
|
34 |
// we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
|
35 |
+
// instead of Types_Field_Group_Term_Factory like the original get_called_class() function does
|
36 |
// ends in an error because of parents (abstract) $var = new self();
|
37 |
+
return Types_Field_Group_Post_Factory::get_instance()->load_field_group( $field_group );
|
38 |
}
|
39 |
|
40 |
|
44 |
* @param string $name Sanitized field group name. Note that the final name may change when new post is inserted.
|
45 |
* @param string $title Field group title.
|
46 |
*
|
47 |
+
* @return null|Types_Field_Group The new field group or null on error.
|
48 |
*/
|
49 |
+
public static function create( $name, $title = '', $status = 'draft' ) {
|
50 |
// we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
|
51 |
// we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
|
52 |
+
// instead of Types_Field_Group_Term_Factory like the original get_called_class() function does
|
53 |
// ends in an error because of parents (abstract) $var = new self();
|
54 |
+
return Types_Field_Group_Post_Factory::get_instance()->create_field_group( $name, $title, $status );
|
55 |
}
|
56 |
|
57 |
|
58 |
public function get_post_type() {
|
59 |
+
return Types_Field_Group_Post::POST_TYPE;
|
60 |
}
|
61 |
|
62 |
|
63 |
protected function get_field_group_class_name() {
|
64 |
+
return 'Types_Field_Group_Post';
|
65 |
}
|
66 |
|
67 |
|
library/toolset/types/embedded/classes/field/group_term.php → application/models/field/group/term.php
RENAMED
@@ -5,7 +5,7 @@
|
|
5 |
*
|
6 |
* @since 1.9
|
7 |
*/
|
8 |
-
final class
|
9 |
|
10 |
|
11 |
const POST_TYPE = 'wp-types-term-group';
|
@@ -19,7 +19,7 @@ final class WPCF_Field_Group_Term extends WPCF_Field_Group {
|
|
19 |
|
20 |
|
21 |
/**
|
22 |
-
*
|
23 |
*
|
24 |
* @param WP_Post $field_group_post Post object representing a term field group.
|
25 |
* @throws InvalidArgumentException
|
@@ -112,4 +112,30 @@ final class WPCF_Field_Group_Term extends WPCF_Field_Group {
|
|
112 |
}
|
113 |
}
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
}
|
5 |
*
|
6 |
* @since 1.9
|
7 |
*/
|
8 |
+
final class Types_Field_Group_Term extends Types_Field_Group {
|
9 |
|
10 |
|
11 |
const POST_TYPE = 'wp-types-term-group';
|
19 |
|
20 |
|
21 |
/**
|
22 |
+
* Types_Field_Group_Term constructor.
|
23 |
*
|
24 |
* @param WP_Post $field_group_post Post object representing a term field group.
|
25 |
* @throws InvalidArgumentException
|
112 |
}
|
113 |
}
|
114 |
|
115 |
+
|
116 |
+
/** Element name for a single associated taxonomy. */
|
117 |
+
const XML_ASSOCIATED_TAXONOMY = 'taxonomy';
|
118 |
+
|
119 |
+
|
120 |
+
/**
|
121 |
+
* @inheritdoc
|
122 |
+
*
|
123 |
+
* Add term field group-specific information to the export object.
|
124 |
+
*
|
125 |
+
* @return array
|
126 |
+
* @since 2.1
|
127 |
+
*/
|
128 |
+
protected function get_export_fields() {
|
129 |
+
|
130 |
+
$data = parent::get_export_fields();
|
131 |
+
|
132 |
+
// Array of slugs of associated taxonomies.
|
133 |
+
$associated_taxonomy_data = implode( ',', $this->get_associated_taxonomies() );
|
134 |
+
|
135 |
+
// parent::XML_META_SECTION is ensured by the parent method
|
136 |
+
$data[ parent::XML_META_SECTION ][ self::POSTMETA_ASSOCIATED_TAXONOMY ] = $associated_taxonomy_data;
|
137 |
+
|
138 |
+
return $data;
|
139 |
+
}
|
140 |
+
|
141 |
}
|
library/toolset/types/embedded/classes/field/group_term_factory.php → application/models/field/group/term_factory.php
RENAMED
@@ -1,15 +1,15 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* Factory for the
|
5 |
*
|
6 |
* @since 1.9
|
7 |
*/
|
8 |
-
final class
|
9 |
|
10 |
|
11 |
/**
|
12 |
-
* @return
|
13 |
*/
|
14 |
public static function get_instance() {
|
15 |
return parent::get_instance();
|
@@ -27,14 +27,14 @@ final class WPCF_Field_Group_Term_Factory extends WPCF_Field_Group_Factory {
|
|
27 |
*
|
28 |
* @param int|string|WP_Post $field_group Post ID of the field group, it's name or a WP_Post object.
|
29 |
*
|
30 |
-
* @return null|
|
31 |
*/
|
32 |
public static function load( $field_group ) {
|
33 |
// we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
|
34 |
// we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
|
35 |
-
// instead of
|
36 |
// ends in an error because of parents (abstract) $var = new self();
|
37 |
-
return
|
38 |
}
|
39 |
|
40 |
|
@@ -44,29 +44,29 @@ final class WPCF_Field_Group_Term_Factory extends WPCF_Field_Group_Factory {
|
|
44 |
* @param string $name Sanitized field group name. Note that the final name may change when new post is inserted.
|
45 |
* @param string $title Field group title.
|
46 |
*
|
47 |
-
* @return null|
|
48 |
*/
|
49 |
public static function create( $name, $title = '' ) {
|
50 |
// we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
|
51 |
// we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
|
52 |
-
// instead of
|
53 |
// ends in an error because of parents (abstract) $var = new self();
|
54 |
-
return
|
55 |
}
|
56 |
|
57 |
|
58 |
public function get_post_type() {
|
59 |
-
return
|
60 |
}
|
61 |
|
62 |
|
63 |
protected function get_field_group_class_name() {
|
64 |
-
return '
|
65 |
}
|
66 |
|
67 |
|
68 |
/**
|
69 |
-
* @var null|
|
70 |
*/
|
71 |
private $taxonomy_assignment_cache = null;
|
72 |
|
@@ -74,7 +74,7 @@ final class WPCF_Field_Group_Term_Factory extends WPCF_Field_Group_Factory {
|
|
74 |
/**
|
75 |
* Produce a list of all taxonomies with groups that belong to them.
|
76 |
*
|
77 |
-
* @return
|
78 |
* groups that are associated with those taxonomies.
|
79 |
*/
|
80 |
public function get_groups_by_taxonomies() {
|
@@ -88,7 +88,7 @@ final class WPCF_Field_Group_Term_Factory extends WPCF_Field_Group_Factory {
|
|
88 |
$groups_for_taxonomy = array();
|
89 |
|
90 |
foreach( $groups as $group ) {
|
91 |
-
if( $group instanceof
|
92 |
&& $group->is_active()
|
93 |
&& $group->has_associated_taxonomy( $taxonomy_slug )
|
94 |
) {
|
@@ -108,7 +108,8 @@ final class WPCF_Field_Group_Term_Factory extends WPCF_Field_Group_Factory {
|
|
108 |
* Get array of groups that are associated with given taxonomy.
|
109 |
*
|
110 |
* @param string $taxonomy_slug Slug of the taxonomy
|
111 |
-
*
|
|
|
112 |
*/
|
113 |
public function get_groups_by_taxonomy( $taxonomy_slug ) {
|
114 |
$groups_by_taxonomies = $this->get_groups_by_taxonomies();
|
@@ -123,10 +124,10 @@ final class WPCF_Field_Group_Term_Factory extends WPCF_Field_Group_Factory {
|
|
123 |
* Erases cache for the get_groups_by_taxonomies() method.
|
124 |
*
|
125 |
* @param int $group_id Ignored
|
126 |
-
* @param
|
127 |
*/
|
128 |
public function on_group_updated( /** @noinspection PhpUnusedParameterInspection */ $group_id, $group ) {
|
129 |
-
if( $group instanceof
|
130 |
$this->taxonomy_assignment_cache = null;
|
131 |
}
|
132 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* Factory for the Types_Field_Group_Term class.
|
5 |
*
|
6 |
* @since 1.9
|
7 |
*/
|
8 |
+
final class Types_Field_Group_Term_Factory extends Types_Field_Group_Factory {
|
9 |
|
10 |
|
11 |
/**
|
12 |
+
* @return Types_Field_Group_Term_Factory
|
13 |
*/
|
14 |
public static function get_instance() {
|
15 |
return parent::get_instance();
|
27 |
*
|
28 |
* @param int|string|WP_Post $field_group Post ID of the field group, it's name or a WP_Post object.
|
29 |
*
|
30 |
+
* @return null|Types_Field_Group_Term Field group or null if it can't be loaded.
|
31 |
*/
|
32 |
public static function load( $field_group ) {
|
33 |
// we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
|
34 |
// we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
|
35 |
+
// instead of Types_Field_Group_Term_Factory like the original get_called_class() function does
|
36 |
// ends in an error because of parents (abstract) $var = new self();
|
37 |
+
return Types_Field_Group_Term_Factory::get_instance()->load_field_group( $field_group );
|
38 |
}
|
39 |
|
40 |
|
44 |
* @param string $name Sanitized field group name. Note that the final name may change when new post is inserted.
|
45 |
* @param string $title Field group title.
|
46 |
*
|
47 |
+
* @return null|Types_Field_Group The new field group or null on error.
|
48 |
*/
|
49 |
public static function create( $name, $title = '' ) {
|
50 |
// we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
|
51 |
// we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
|
52 |
+
// instead of Types_Field_Group_Term_Factory like the original get_called_class() function does
|
53 |
// ends in an error because of parents (abstract) $var = new self();
|
54 |
+
return Types_Field_Group_Term_Factory::get_instance()->create_field_group( $name, $title );
|
55 |
}
|
56 |
|
57 |
|
58 |
public function get_post_type() {
|
59 |
+
return Types_Field_Group_Term::POST_TYPE;
|
60 |
}
|
61 |
|
62 |
|
63 |
protected function get_field_group_class_name() {
|
64 |
+
return 'Types_Field_Group_Term';
|
65 |
}
|
66 |
|
67 |
|
68 |
/**
|
69 |
+
* @var null|Types_Field_Group_Term[][] Cache for the get_groups_by_taxonomies() method.
|
70 |
*/
|
71 |
private $taxonomy_assignment_cache = null;
|
72 |
|
74 |
/**
|
75 |
* Produce a list of all taxonomies with groups that belong to them.
|
76 |
*
|
77 |
+
* @return Types_Field_Group_Term[][] Associative array where keys are taxonomy slugs and values are arrays of field
|
78 |
* groups that are associated with those taxonomies.
|
79 |
*/
|
80 |
public function get_groups_by_taxonomies() {
|
88 |
$groups_for_taxonomy = array();
|
89 |
|
90 |
foreach( $groups as $group ) {
|
91 |
+
if( $group instanceof Types_Field_Group_Term
|
92 |
&& $group->is_active()
|
93 |
&& $group->has_associated_taxonomy( $taxonomy_slug )
|
94 |
) {
|
108 |
* Get array of groups that are associated with given taxonomy.
|
109 |
*
|
110 |
* @param string $taxonomy_slug Slug of the taxonomy
|
111 |
+
*
|
112 |
+
* @return Types_Field_Group_Term[] Associated term field groups.
|
113 |
*/
|
114 |
public function get_groups_by_taxonomy( $taxonomy_slug ) {
|
115 |
$groups_by_taxonomies = $this->get_groups_by_taxonomies();
|
124 |
* Erases cache for the get_groups_by_taxonomies() method.
|
125 |
*
|
126 |
* @param int $group_id Ignored
|
127 |
+
* @param Types_Field_Group $group Field group that has been just updated.
|
128 |
*/
|
129 |
public function on_group_updated( /** @noinspection PhpUnusedParameterInspection */ $group_id, $group ) {
|
130 |
+
if( $group instanceof Types_Field_Group_Term ) {
|
131 |
$this->taxonomy_assignment_cache = null;
|
132 |
}
|
133 |
}
|
library/toolset/types/embedded/classes/field/group_user.php → application/models/field/group/user.php
RENAMED
@@ -5,7 +5,7 @@
|
|
5 |
*
|
6 |
* @since 2.0
|
7 |
*/
|
8 |
-
final class
|
9 |
|
10 |
|
11 |
const POST_TYPE = 'wp-types-user-group';
|
5 |
*
|
6 |
* @since 2.0
|
7 |
*/
|
8 |
+
final class Types_Field_Group_User extends Types_Field_Group {
|
9 |
|
10 |
|
11 |
const POST_TYPE = 'wp-types-user-group';
|
library/toolset/types/embedded/classes/field/group_user_factory.php → application/models/field/group/user_factory.php
RENAMED
@@ -1,15 +1,15 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* Factory for the
|
5 |
*
|
6 |
* @since 2.0
|
7 |
*/
|
8 |
-
final class
|
9 |
|
10 |
|
11 |
/**
|
12 |
-
* @return
|
13 |
*/
|
14 |
public static function get_instance() {
|
15 |
return parent::get_instance();
|
@@ -27,14 +27,14 @@ final class WPCF_Field_Group_User_Factory extends WPCF_Field_Group_Factory {
|
|
27 |
*
|
28 |
* @param int|string|WP_Post $field_group Post ID of the field group, it's name or a WP_Post object.
|
29 |
*
|
30 |
-
* @return null|
|
31 |
*/
|
32 |
public static function load( $field_group ) {
|
33 |
// we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
|
34 |
// we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
|
35 |
-
// instead of
|
36 |
// ends in an error because of parents (abstract) $var = new self();
|
37 |
-
return
|
38 |
}
|
39 |
|
40 |
|
@@ -44,24 +44,24 @@ final class WPCF_Field_Group_User_Factory extends WPCF_Field_Group_Factory {
|
|
44 |
* @param string $name Sanitized field group name. Note that the final name may change when new post is inserted.
|
45 |
* @param string $title Field group title.
|
46 |
*
|
47 |
-
* @return null|
|
48 |
*/
|
49 |
public static function create( $name, $title = '' ) {
|
50 |
// we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
|
51 |
// we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
|
52 |
-
// instead of
|
53 |
// ends in an error because of parents (abstract) $var = new self();
|
54 |
-
return
|
55 |
}
|
56 |
|
57 |
|
58 |
public function get_post_type() {
|
59 |
-
return
|
60 |
}
|
61 |
|
62 |
|
63 |
protected function get_field_group_class_name() {
|
64 |
-
return '
|
65 |
}
|
66 |
|
67 |
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* Factory for the Types_Field_Group_User class.
|
5 |
*
|
6 |
* @since 2.0
|
7 |
*/
|
8 |
+
final class Types_Field_Group_User_Factory extends Types_Field_Group_Factory {
|
9 |
|
10 |
|
11 |
/**
|
12 |
+
* @return Types_Field_Group_User_Factory
|
13 |
*/
|
14 |
public static function get_instance() {
|
15 |
return parent::get_instance();
|
27 |
*
|
28 |
* @param int|string|WP_Post $field_group Post ID of the field group, it's name or a WP_Post object.
|
29 |
*
|
30 |
+
* @return null|Types_Field_Group_User Field group or null if it can't be loaded.
|
31 |
*/
|
32 |
public static function load( $field_group ) {
|
33 |
// we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
|
34 |
// we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
|
35 |
+
// instead of Types_Field_Group_Term_Factory like the original get_called_class() function does
|
36 |
// ends in an error because of parents (abstract) $var = new self();
|
37 |
+
return Types_Field_Group_User_Factory::get_instance()->load_field_group( $field_group );
|
38 |
}
|
39 |
|
40 |
|
44 |
* @param string $name Sanitized field group name. Note that the final name may change when new post is inserted.
|
45 |
* @param string $title Field group title.
|
46 |
*
|
47 |
+
* @return null|Types_Field_Group The new field group or null on error.
|
48 |
*/
|
49 |
public static function create( $name, $title = '' ) {
|
50 |
// we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
|
51 |
// we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
|
52 |
+
// instead of Types_Field_Group_Term_Factory like the original get_called_class() function does
|
53 |
// ends in an error because of parents (abstract) $var = new self();
|
54 |
+
return Types_Field_Group_User_Factory::get_instance()->create_field_group( $name, $title );
|
55 |
}
|
56 |
|
57 |
|
58 |
public function get_post_type() {
|
59 |
+
return Types_Field_Group_User::POST_TYPE;
|
60 |
}
|
61 |
|
62 |
|
63 |
protected function get_field_group_class_name() {
|
64 |
+
return 'Types_Field_Group_User';
|
65 |
}
|
66 |
|
67 |
|
application/models/field/type/definition.php
CHANGED
@@ -5,6 +5,8 @@
|
|
5 |
*
|
6 |
* This represents a single field type like "email", "audio", "checkbox" and so on. This class must be instantiated
|
7 |
* exclusively through Types_Field_Type_Definition_Factory.
|
|
|
|
|
8 |
*/
|
9 |
class Types_Field_Type_Definition {
|
10 |
|
@@ -119,28 +121,96 @@ class Types_Field_Type_Definition {
|
|
119 |
|
120 |
|
121 |
/**
|
122 |
-
*
|
123 |
*
|
124 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
*
|
126 |
-
*
|
127 |
*
|
128 |
-
*
|
129 |
-
*
|
130 |
-
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
*
|
|
|
|
|
|
|
132 |
* @param array $definition_array Field definition array
|
133 |
* @return array Field definition array that is safe to be used even with legacy code.
|
134 |
* @since 2.0
|
135 |
*/
|
136 |
-
public function sanitize_field_definition_array( $definition_array ) {
|
137 |
-
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
-
$definition_array['data']['validate'] = wpcf_ensarr( wpcf_getarr( $definition_array['data'], 'validate' ) );
|
141 |
-
|
142 |
$definition_array = $this->sanitize_numeric_validation( $definition_array );
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
return $definition_array;
|
145 |
}
|
146 |
|
@@ -164,4 +234,29 @@ class Types_Field_Type_Definition {
|
|
164 |
return $definition_array;
|
165 |
}
|
166 |
|
167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
*
|
6 |
* This represents a single field type like "email", "audio", "checkbox" and so on. This class must be instantiated
|
7 |
* exclusively through Types_Field_Type_Definition_Factory.
|
8 |
+
*
|
9 |
+
* @since 2.0
|
10 |
*/
|
11 |
class Types_Field_Type_Definition {
|
12 |
|
121 |
|
122 |
|
123 |
/**
|
124 |
+
* Perform field type-specific sanitization of the field definition array.
|
125 |
*
|
126 |
+
* @link https://git.onthegosystems.com/toolset/types/wikis/database-layer/field-definition-arrays
|
127 |
+
* @param $definition_array
|
128 |
+
* @return array Sanitized definition array
|
129 |
+
* @since 2.1
|
130 |
+
*/
|
131 |
+
protected function sanitize_field_definition_array_type_specific( $definition_array ) {
|
132 |
+
return $definition_array;
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Perform a very generic sanitization of the field definition array.
|
138 |
*
|
139 |
+
* Should be used only by sanitize_field_definition_array().
|
140 |
*
|
141 |
+
* @param array $definition_array
|
142 |
+
* @return array
|
143 |
+
* @since 2.1
|
144 |
+
*/
|
145 |
+
private function sanitize_field_definition_array_generic( $definition_array ) {
|
146 |
+
// slug: sanitize_title
|
147 |
+
$definition_array['slug'] = sanitize_title( wpcf_getarr( $definition_array, 'slug' ) );
|
148 |
+
|
149 |
+
// type: default to textfield
|
150 |
+
$definition_array['type'] = wpcf_getarr( $definition_array, 'type', Types_Field_Type_Definition_Factory::TEXTFIELD );
|
151 |
+
|
152 |
+
// name: sanitize_text_field
|
153 |
+
$definition_array['name'] = sanitize_text_field( wpcf_getarr( $definition_array, 'name' ) );
|
154 |
+
|
155 |
+
// description: ensure it is set
|
156 |
+
$definition_array['description'] = wpcf_getarr( $definition_array, 'description' );
|
157 |
+
|
158 |
+
// meta_key: default to wpcf-{$slug}
|
159 |
+
$definition_array['meta_key'] = wpcf_getarr( $definition_array, 'meta_key', WPCF_Field_Definition::FIELD_META_KEY_PREFIX . $definition_array['slug'] );
|
160 |
+
|
161 |
+
// data: must be an array
|
162 |
+
$definition_array['data'] = wpcf_ensarr( wpcf_getarr( $definition_array, 'data' ) );
|
163 |
+
|
164 |
+
// data[conditional_display]: must be an array
|
165 |
+
$definition_array['data']['conditional_display'] = wpcf_ensarr( wpcf_getarr( $definition_array['data'], 'conditional_display' ) );
|
166 |
+
|
167 |
+
// data[validate]: must be an array
|
168 |
+
$definition_array['data']['validate'] = wpcf_ensarr( wpcf_getarr( $definition_array['data'], 'validate' ) );
|
169 |
+
|
170 |
+
return $definition_array;
|
171 |
+
}
|
172 |
+
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Make sure that the field definition array contains all necessary information.
|
176 |
*
|
177 |
+
* Note: This is a WIP, currently it sanitizes only very specific cases. It should be extended in the future.
|
178 |
+
*
|
179 |
+
* @link https://git.onthegosystems.com/toolset/types/wikis/database-layer/field-definition-arrays
|
180 |
* @param array $definition_array Field definition array
|
181 |
* @return array Field definition array that is safe to be used even with legacy code.
|
182 |
* @since 2.0
|
183 |
*/
|
184 |
+
public final function sanitize_field_definition_array( $definition_array ) {
|
185 |
+
|
186 |
+
/**
|
187 |
+
* types_pre_sanitize_field_definition_array
|
188 |
+
*
|
189 |
+
* Allow for additional field definition array sanitization before the standard one runs.
|
190 |
+
*
|
191 |
+
* @param mixed $definition_array
|
192 |
+
* @return array
|
193 |
+
* @since 2.1
|
194 |
+
*/
|
195 |
+
$definition_array = wpcf_ensarr( apply_filters( 'types_pre_sanitize_field_definition_array', $definition_array ) );
|
196 |
+
|
197 |
+
$definition_array = $this->sanitize_field_definition_array_generic( $definition_array );
|
198 |
|
|
|
|
|
199 |
$definition_array = $this->sanitize_numeric_validation( $definition_array );
|
200 |
|
201 |
+
$definition_array = $this->sanitize_field_definition_array_type_specific( $definition_array );
|
202 |
+
|
203 |
+
/**
|
204 |
+
* types_post_sanitize_field_definition_array
|
205 |
+
*
|
206 |
+
* Allow for additional field definition array sanitization after the standard one runs.
|
207 |
+
*
|
208 |
+
* @param array $definition_array
|
209 |
+
* @return array
|
210 |
+
* @since 2.1
|
211 |
+
*/
|
212 |
+
$definition_array = wpcf_ensarr( apply_filters( 'types_post_sanitize_field_definition_array', $definition_array ) );
|
213 |
+
|
214 |
return $definition_array;
|
215 |
}
|
216 |
|
234 |
return $definition_array;
|
235 |
}
|
236 |
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Perform a basic "isset" sanitization of an array element.
|
240 |
+
*
|
241 |
+
* @param array $source
|
242 |
+
* @param string $element_name Name of the element to sanitize.
|
243 |
+
* @param string $default Default value for the element if not set or invalid.
|
244 |
+
* @param null|array $allowed If an array, defines the set of allowed values for the element.
|
245 |
+
* @param null|string $nested_key If not null, the element will be taken from $source[$nested_key][$element_name].
|
246 |
+
* @return array Updated source array.
|
247 |
+
* @since 2.1
|
248 |
+
*/
|
249 |
+
protected function sanitize_element_isset( $source, $element_name, $default = '', $allowed = null, $nested_key = null ) {
|
250 |
+
$src_array = ( null == $nested_key ? $source : $source[ $nested_key ] );
|
251 |
+
$value = wpcf_getarr( $src_array, $element_name, $default, $allowed );
|
252 |
+
|
253 |
+
if( null == $nested_key ) {
|
254 |
+
$source[ $element_name ] = $value;
|
255 |
+
} else {
|
256 |
+
$source[ $nested_key ][ $element_name ] = $value;
|
257 |
+
}
|
258 |
+
|
259 |
+
return $source;
|
260 |
+
}
|
261 |
+
|
262 |
+
}
|
application/models/field/type/definition/checkbox.php
CHANGED
@@ -8,6 +8,12 @@
|
|
8 |
final class Types_Field_Type_Definition_Checkbox extends Types_Field_Type_Definition_Singular {
|
9 |
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
public function __construct( $args ) {
|
12 |
parent::__construct( Types_Field_Type_Definition_Factory::CHECKBOX, $args );
|
13 |
}
|
@@ -16,18 +22,20 @@ final class Types_Field_Type_Definition_Checkbox extends Types_Field_Type_Defini
|
|
16 |
/**
|
17 |
* @inheritdoc
|
18 |
*
|
19 |
-
* Checkbox field definition needs to contain these keys:
|
20 |
-
*
|
21 |
-
* - data/set_value: The value that will be saved to database when the field is checked. Default is '1'
|
22 |
-
*
|
23 |
* @param array $definition_array
|
24 |
* @return array
|
25 |
* @since 2.0
|
26 |
*/
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
if( !is_string( $set_value ) && !is_numeric( $set_value ) ) {
|
32 |
$set_value = '1';
|
33 |
}
|
8 |
final class Types_Field_Type_Definition_Checkbox extends Types_Field_Type_Definition_Singular {
|
9 |
|
10 |
|
11 |
+
/**
|
12 |
+
* Types_Field_Type_Definition_Checkbox constructor.
|
13 |
+
*
|
14 |
+
* @param array $args
|
15 |
+
* @since 2.0
|
16 |
+
*/
|
17 |
public function __construct( $args ) {
|
18 |
parent::__construct( Types_Field_Type_Definition_Factory::CHECKBOX, $args );
|
19 |
}
|
22 |
/**
|
23 |
* @inheritdoc
|
24 |
*
|
|
|
|
|
|
|
|
|
25 |
* @param array $definition_array
|
26 |
* @return array
|
27 |
* @since 2.0
|
28 |
*/
|
29 |
+
protected function sanitize_field_definition_array_type_specific( $definition_array ) {
|
30 |
+
|
31 |
+
$definition_array['type'] = Types_Field_Type_Definition_Factory::CHECKBOX;
|
32 |
+
|
33 |
+
$definition_array = $this->sanitize_element_isset( $definition_array, 'display', 'db', array( 'db', 'value' ), 'data' );
|
34 |
+
$definition_array = $this->sanitize_element_isset( $definition_array, 'display_value_selected', '', null, 'data' );
|
35 |
+
$definition_array = $this->sanitize_element_isset( $definition_array, 'display_value_not_selected', '', null, 'data' );
|
36 |
+
$definition_array = $this->sanitize_element_isset( $definition_array, 'save_empty', 'no', array( 'yes', 'no' ), 'data' );
|
37 |
+
|
38 |
+
$set_value = wpcf_getnest( $definition_array, array( 'data', 'set_value' ) );
|
39 |
if( !is_string( $set_value ) && !is_numeric( $set_value ) ) {
|
40 |
$set_value = '1';
|
41 |
}
|
application/models/field/type/definition/checkboxes.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
final class Types_Field_Type_Definition_Checkboxes extends Types_Field_Type_Definition_Singular {
|
4 |
+
|
5 |
+
public function __construct( $args ) {
|
6 |
+
parent::__construct( Types_Field_Type_Definition_Factory::CHECKBOXES, $args );
|
7 |
+
}
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @inheritdoc
|
11 |
+
*
|
12 |
+
* @param array $definition_array
|
13 |
+
* @return array
|
14 |
+
* @since 2.1
|
15 |
+
*/
|
16 |
+
protected function sanitize_field_definition_array_type_specific( $definition_array ) {
|
17 |
+
|
18 |
+
$definition_array['type'] = Types_Field_Type_Definition_Factory::CHECKBOXES;
|
19 |
+
|
20 |
+
$definition_array = $this->sanitize_element_isset( $definition_array, 'save_empty', 'no', array( 'yes', 'no' ), 'data' );
|
21 |
+
|
22 |
+
$options = wpcf_ensarr( wpcf_getnest( $definition_array, array( 'data', 'options' ) ) );
|
23 |
+
|
24 |
+
foreach( $options as $key => $option ) {
|
25 |
+
$options[ $key ] = $this->sanitize_single_option( $option );
|
26 |
+
}
|
27 |
+
|
28 |
+
$definition_array['data']['options'] = $options;
|
29 |
+
|
30 |
+
return $definition_array;
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Sanitize single checkboxes option definition.
|
36 |
+
*
|
37 |
+
* @param array $option
|
38 |
+
* @return array Sanitized option.
|
39 |
+
* @since 2.1
|
40 |
+
*/
|
41 |
+
private function sanitize_single_option( $option ) {
|
42 |
+
$option = $this->sanitize_element_isset( wpcf_ensarr( $option ), 'set_value' );
|
43 |
+
$option = $this->sanitize_element_isset( $option, 'title', $option['set_value'] );
|
44 |
+
$option = $this->sanitize_element_isset( $option, 'display', 'db', array( 'db', 'value' ) );
|
45 |
+
$option = $this->sanitize_element_isset( $option, 'display_value_selected' );
|
46 |
+
$option = $this->sanitize_element_isset( $option, 'display_value_not_selected' );
|
47 |
+
return $option;
|
48 |
+
}
|
49 |
+
|
50 |
+
}
|
application/models/field/type/definition/date.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
final class Types_Field_Type_Definition_Date extends Types_Field_Type_Definition {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Types_Field_Type_Definition_Date constructor.
|
7 |
+
*
|
8 |
+
* @param array $args
|
9 |
+
*/
|
10 |
+
public function __construct( $args ) {
|
11 |
+
parent::__construct( Types_Field_Type_Definition_Factory::DATE, $args );
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @inheritdoc
|
16 |
+
*
|
17 |
+
* @param array $definition_array
|
18 |
+
* @return array
|
19 |
+
* @since 2.1
|
20 |
+
*/
|
21 |
+
public function sanitize_field_definition_array_type_specific( $definition_array ) {
|
22 |
+
|
23 |
+
$definition_array['type'] = Types_Field_Type_Definition_Factory::DATE;
|
24 |
+
|
25 |
+
$definition_array = $this->sanitize_element_isset( $definition_array, 'date_and_time', 'date', array( 'date', 'and_time' ), 'data' );
|
26 |
+
|
27 |
+
return $definition_array;
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
application/models/field/type/definition/numeric.php
CHANGED
@@ -6,13 +6,33 @@
|
|
6 |
* @since 2.0
|
7 |
*/
|
8 |
final class Types_Field_Type_Definition_Numeric extends Types_Field_Type_Definition {
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
11 |
public function __construct( $args ) {
|
12 |
parent::__construct( Types_Field_Type_Definition_Factory::NUMERIC, $args );
|
13 |
}
|
14 |
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
/**
|
17 |
* Add the 'number' validation if it was not already there, and activate it.
|
18 |
*
|
@@ -21,7 +41,7 @@ final class Types_Field_Type_Definition_Numeric extends Types_Field_Type_Definit
|
|
21 |
* @since 2.0
|
22 |
*/
|
23 |
protected function sanitize_numeric_validation( $definition_array ) {
|
24 |
-
|
25 |
// Get the original setting or a default one.
|
26 |
$validation_setting = wpcf_ensarr(
|
27 |
wpcf_getnest( $definition_array, array( 'data', 'validate', 'number' ) ),
|
6 |
* @since 2.0
|
7 |
*/
|
8 |
final class Types_Field_Type_Definition_Numeric extends Types_Field_Type_Definition {
|
9 |
+
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Types_Field_Type_Definition_Numeric constructor.
|
13 |
+
*
|
14 |
+
* @param array $args
|
15 |
+
*/
|
16 |
public function __construct( $args ) {
|
17 |
parent::__construct( Types_Field_Type_Definition_Factory::NUMERIC, $args );
|
18 |
}
|
19 |
|
20 |
|
21 |
+
/**
|
22 |
+
* @inheritdoc
|
23 |
+
*
|
24 |
+
* @param array $definition_array
|
25 |
+
* @return array
|
26 |
+
* @since 2.1
|
27 |
+
*/
|
28 |
+
protected function sanitize_field_definition_array_type_specific( $definition_array ) {
|
29 |
+
|
30 |
+
$definition_array['type'] = Types_Field_Type_Definition_Factory::NUMERIC;
|
31 |
+
|
32 |
+
return $definition_array;
|
33 |
+
}
|
34 |
+
|
35 |
+
|
36 |
/**
|
37 |
* Add the 'number' validation if it was not already there, and activate it.
|
38 |
*
|
41 |
* @since 2.0
|
42 |
*/
|
43 |
protected function sanitize_numeric_validation( $definition_array ) {
|
44 |
+
|
45 |
// Get the original setting or a default one.
|
46 |
$validation_setting = wpcf_ensarr(
|
47 |
wpcf_getnest( $definition_array, array( 'data', 'validate', 'number' ) ),
|
application/models/field/type/definition/radio.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
final class Types_Field_Type_Definition_Radio extends Types_Field_Type_Definition_Singular {
|
4 |
+
|
5 |
+
public function __construct( $args ) {
|
6 |
+
parent::__construct( Types_Field_Type_Definition_Factory::RADIO, $args );
|
7 |
+
}
|
8 |
+
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @inheritdoc
|
12 |
+
*
|
13 |
+
* @param array $definition_array
|
14 |
+
* @return array
|
15 |
+
* @since 2.1
|
16 |
+
*/
|
17 |
+
protected function sanitize_field_definition_array_type_specific( $definition_array ) {
|
18 |
+
|
19 |
+
$definition_array['type'] = Types_Field_Type_Definition_Factory::RADIO;
|
20 |
+
|
21 |
+
$options = wpcf_ensarr( wpcf_getnest( $definition_array, array( 'data', 'options' ) ) );
|
22 |
+
|
23 |
+
foreach( $options as $key => $option ) {
|
24 |
+
if( 'default' == $key ) {
|
25 |
+
continue;
|
26 |
+
}
|
27 |
+
|
28 |
+
$options[ $key ] = $this->sanitize_single_option( $option );
|
29 |
+
}
|
30 |
+
|
31 |
+
$default_option = wpcf_getarr( $options, 'default' );
|
32 |
+
if( !is_string( $default_option ) || !array_key_exists( $default_option, $options ) ) {
|
33 |
+
$default_option = 'no-default';
|
34 |
+
}
|
35 |
+
$options['default'] = $default_option;
|
36 |
+
|
37 |
+
$definition_array['data']['options'] = $options;
|
38 |
+
|
39 |
+
return $definition_array;
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Sanitize single checkboxes option definition.
|
45 |
+
*
|
46 |
+
* @param array $option
|
47 |
+
* @return array Sanitized option.
|
48 |
+
* @since 2.1
|
49 |
+
*/
|
50 |
+
private function sanitize_single_option( $option ) {
|
51 |
+
$option = $this->sanitize_element_isset( wpcf_ensarr( $option ), 'value' );
|
52 |
+
$option = $this->sanitize_element_isset( $option, 'title', $option['value'] );
|
53 |
+
$option = $this->sanitize_element_isset( $option, 'display_value', $option['value'] );
|
54 |
+
return $option;
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
application/models/field/type/definition/select.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
final class Types_Field_Type_Definition_Select extends Types_Field_Type_Definition_Singular {
|
4 |
+
|
5 |
+
|
6 |
+
public function __construct( $args ) {
|
7 |
+
parent::__construct( Types_Field_Type_Definition_Factory::SELECT, $args );
|
8 |
+
}
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @inheritdoc
|
12 |
+
*
|
13 |
+
* @param array $definition_array
|
14 |
+
* @return array
|
15 |
+
* @since 2.1
|
16 |
+
*/
|
17 |
+
protected function sanitize_field_definition_array_type_specific( $definition_array ) {
|
18 |
+
|
19 |
+
$definition_array['type'] = Types_Field_Type_Definition_Factory::SELECT;
|
20 |
+
|
21 |
+
$options = wpcf_ensarr( wpcf_getnest( $definition_array, array( 'data', 'options' ) ) );
|
22 |
+
|
23 |
+
foreach( $options as $key => $option ) {
|
24 |
+
if( 'default' == $key ) {
|
25 |
+
continue;
|
26 |
+
}
|
27 |
+
|
28 |
+
$options[ $key ] = $this->sanitize_single_option( $option );
|
29 |
+
}
|
30 |
+
|
31 |
+
$default_option = wpcf_getarr( $options, 'default' );
|
32 |
+
if( !is_string( $default_option ) || !array_key_exists( $default_option, $options ) ) {
|
33 |
+
$default_option = 'no-default';
|
34 |
+
}
|
35 |
+
$options['default'] = $default_option;
|
36 |
+
|
37 |
+
$definition_array['data']['options'] = $options;
|
38 |
+
|
39 |
+
return $definition_array;
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Sanitize single checkboxes option definition.
|
45 |
+
*
|
46 |
+
* @param array $option
|
47 |
+
* @return array Sanitized option.
|
48 |
+
* @since 2.1
|
49 |
+
*/
|
50 |
+
private function sanitize_single_option( $option ) {
|
51 |
+
$option = $this->sanitize_element_isset( wpcf_ensarr( $option ), 'value' );
|
52 |
+
$option = $this->sanitize_element_isset( $option, 'title', $option['value'] );
|
53 |
+
return $option;
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
application/models/field/type/definition_factory.php
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
*
|
12 |
* @since 1.9
|
13 |
*/
|
14 |
-
|
15 |
|
16 |
const AUDIO = 'audio';
|
17 |
const COLORPICKER = 'colorpicker';
|
@@ -146,18 +146,20 @@ final class Types_Field_Type_Definition_Factory {
|
|
146 |
*/
|
147 |
private function create_definition_instance( $field_type_slug, $field_type_configuration ) {
|
148 |
switch( $field_type_slug ) {
|
|
|
|
|
149 |
case self::CHECKBOX:
|
150 |
return new Types_Field_Type_Definition_Checkbox( $field_type_configuration );
|
151 |
-
|
|
|
152 |
case self::NUMERIC:
|
153 |
return new Types_Field_Type_Definition_Numeric( $field_type_configuration );
|
154 |
-
|
155 |
-
case self::CHECKBOXES:
|
156 |
case self::RADIO:
|
|
|
157 |
case self::SELECT:
|
|
|
158 |
case self::WYSIWYG:
|
159 |
return new Types_Field_Type_Definition_Singular( $field_type_slug, $field_type_configuration );
|
160 |
-
|
161 |
default:
|
162 |
return new Types_Field_Type_Definition( $field_type_slug, $field_type_configuration );
|
163 |
}
|
11 |
*
|
12 |
* @since 1.9
|
13 |
*/
|
14 |
+
class Types_Field_Type_Definition_Factory {
|
15 |
|
16 |
const AUDIO = 'audio';
|
17 |
const COLORPICKER = 'colorpicker';
|
146 |
*/
|
147 |
private function create_definition_instance( $field_type_slug, $field_type_configuration ) {
|
148 |
switch( $field_type_slug ) {
|
149 |
+
case self::DATE:
|
150 |
+
return new Types_Field_Type_Definition_Date( $field_type_configuration );
|
151 |
case self::CHECKBOX:
|
152 |
return new Types_Field_Type_Definition_Checkbox( $field_type_configuration );
|
153 |
+
case self::CHECKBOXES:
|
154 |
+
return new Types_Field_Type_Definition_Checkboxes( $field_type_configuration );
|
155 |
case self::NUMERIC:
|
156 |
return new Types_Field_Type_Definition_Numeric( $field_type_configuration );
|
|
|
|
|
157 |
case self::RADIO:
|
158 |
+
return new Types_Field_Type_Definition_Radio( $field_type_configuration );
|
159 |
case self::SELECT:
|
160 |
+
return new Types_Field_Type_Definition_Select( $field_type_configuration );
|
161 |
case self::WYSIWYG:
|
162 |
return new Types_Field_Type_Definition_Singular( $field_type_slug, $field_type_configuration );
|
|
|
163 |
default:
|
164 |
return new Types_Field_Type_Definition( $field_type_slug, $field_type_configuration );
|
165 |
}
|
application/models/helper/condition.php
CHANGED
@@ -1,11 +1,24 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
abstract class Types_Helper_Condition {
|
5 |
|
6 |
-
protected $condition;
|
7 |
public static $post_type;
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
public function set_condition( $value ) {
|
10 |
$this->condition = $value;
|
11 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
abstract class Types_Helper_Condition {
|
9 |
|
|
|
10 |
public static $post_type;
|
11 |
|
12 |
+
protected $condition;
|
13 |
+
|
14 |
+
protected static function get_type_name() {
|
15 |
+
// per post
|
16 |
+
if( isset( $_GET['post'] ) )
|
17 |
+
return get_post_type( $_GET['post'] );
|
18 |
+
|
19 |
+
return self::$post_type->name;
|
20 |
+
}
|
21 |
+
|
22 |
public function set_condition( $value ) {
|
23 |
$this->condition = $value;
|
24 |
}
|
application/models/helper/condition/archive/exists.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Archive_Exists extends Types_Helper_Condition_Template {
|
5 |
|
6 |
public function __construct() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Archive_Exists
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Archive_Exists extends Types_Helper_Condition_Template {
|
9 |
|
10 |
public function __construct() {
|
application/models/helper/condition/archive/has_fields.php
CHANGED
@@ -1,5 +1,10 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
class Types_Helper_Condition_Archive_Has_Fields extends Types_Helper_Condition_Archive_No_Fields {
|
4 |
|
5 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Archive_Has_Fields
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Archive_Has_Fields extends Types_Helper_Condition_Archive_No_Fields {
|
9 |
|
10 |
public function valid() {
|
application/models/helper/condition/archive/missing.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Archive_Missing extends Types_Helper_Condition_Archive_Exists {
|
5 |
// this is valid if no template is found
|
6 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Archive_Missing
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Archive_Missing extends Types_Helper_Condition_Archive_Exists {
|
9 |
// this is valid if no template is found
|
10 |
public function valid() {
|
application/models/helper/condition/archive/no_fields.php
CHANGED
@@ -1,4 +1,10 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
class Types_Helper_Condition_Archive_No_Fields extends Types_Helper_Condition_Archive_Missing {
|
3 |
|
4 |
public function valid() {
|
@@ -24,7 +30,7 @@ class Types_Helper_Condition_Archive_No_Fields extends Types_Helper_Condition_Ar
|
|
24 |
return false;
|
25 |
|
26 |
// check for fields, abort if there results in true
|
27 |
-
if( $file->search( 'types_render_field' ) )
|
28 |
return false;
|
29 |
|
30 |
return true;
|
1 |
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Archive_No_Fields
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Archive_No_Fields extends Types_Helper_Condition_Archive_Missing {
|
9 |
|
10 |
public function valid() {
|
30 |
return false;
|
31 |
|
32 |
// check for fields, abort if there results in true
|
33 |
+
if( $file->search( array( 'types_render_field', 'wpcf-' ) ) )
|
34 |
return false;
|
35 |
|
36 |
return true;
|
application/models/helper/condition/archive/no_support.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Archive_No_Support extends Types_Helper_Condition_Archive_Support {
|
5 |
|
6 |
public function __construct() {}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Archive_No_Support
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Archive_No_Support extends Types_Helper_Condition_Archive_Support {
|
9 |
|
10 |
public function __construct() {}
|
application/models/helper/condition/archive/support.php
CHANGED
@@ -1,6 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
|
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Archive_Support extends Types_Helper_Condition {
|
5 |
|
6 |
public function __construct() {}
|
@@ -8,7 +13,7 @@ class Types_Helper_Condition_Archive_Support extends Types_Helper_Condition {
|
|
8 |
public function valid() {
|
9 |
$cpt = Types_Helper_Condition::get_post_type();
|
10 |
|
11 |
-
if ( ! $cpt->has_archive && $cpt->name != 'post'
|
12 |
return false;
|
13 |
|
14 |
return true;
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
/**
|
5 |
+
* Types_Helper_Condition_Archive_Support
|
6 |
+
*
|
7 |
+
* @since 2.0
|
8 |
+
*/
|
9 |
class Types_Helper_Condition_Archive_Support extends Types_Helper_Condition {
|
10 |
|
11 |
public function __construct() {}
|
13 |
public function valid() {
|
14 |
$cpt = Types_Helper_Condition::get_post_type();
|
15 |
|
16 |
+
if ( ! $cpt->has_archive && $cpt->name != 'post' )
|
17 |
return false;
|
18 |
|
19 |
return true;
|
application/models/helper/condition/cred/active.php
CHANGED
@@ -1,6 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
|
|
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Cred_Active extends Types_Helper_Condition {
|
5 |
|
6 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
|
4 |
+
/**
|
5 |
+
* Types_Helper_Condition_Cred_Active
|
6 |
+
*
|
7 |
+
* @since 2.0
|
8 |
+
*/
|
9 |
class Types_Helper_Condition_Cred_Active extends Types_Helper_Condition {
|
10 |
|
11 |
public function valid() {
|
application/models/helper/condition/cred/forms_exist.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Cred_Forms_Exist extends Types_Helper_Condition_Cred_Active {
|
5 |
|
6 |
public static $forms_per_post_type;
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Cred_Forms_Exist
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Cred_Forms_Exist extends Types_Helper_Condition_Cred_Active {
|
9 |
|
10 |
public static $forms_per_post_type;
|
application/models/helper/condition/cred/forms_missing.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Cred_Forms_Missing extends Types_Helper_Condition_Cred_Forms_Exist {
|
5 |
|
6 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Cred_Forms_Missing
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Cred_Forms_Missing extends Types_Helper_Condition_Cred_Forms_Exist {
|
9 |
|
10 |
public function valid() {
|
application/models/helper/condition/cred/missing.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Cred_Missing extends Types_Helper_Condition_Cred_Active {
|
5 |
|
6 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Cred_Missing
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Cred_Missing extends Types_Helper_Condition_Cred_Active {
|
9 |
|
10 |
public function valid() {
|
application/models/helper/condition/layouts/active.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Layouts_Active extends Types_Helper_Condition {
|
5 |
|
6 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Layouts_Active
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Layouts_Active extends Types_Helper_Condition {
|
9 |
|
10 |
public function valid() {
|
application/models/helper/condition/layouts/archive_exists.php
CHANGED
@@ -1,39 +1,57 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
class Types_Helper_Condition_Layouts_Archive_Exists extends Types_Helper_Condition_Template {
|
4 |
|
5 |
-
private static $layout_id;
|
6 |
-
private static $layout_name;
|
7 |
|
8 |
public function valid() {
|
9 |
-
if( ! defined( '
|
10 |
return false;
|
11 |
|
12 |
-
$
|
13 |
|
14 |
$layouts = get_option( WPDDL_GENERAL_OPTIONS, array() );
|
15 |
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
|
|
|
|
|
|
|
20 |
|
21 |
-
return
|
22 |
}
|
23 |
|
24 |
public static function get_layout_id() {
|
25 |
-
|
|
|
|
|
26 |
$self = new Types_Helper_Condition_Layouts_Archive_Exists();
|
27 |
$self->valid();
|
28 |
}
|
29 |
|
30 |
-
return self::$layout_id;
|
31 |
}
|
32 |
|
33 |
public static function get_layout_name() {
|
34 |
-
|
35 |
-
|
|
|
|
|
36 |
|
37 |
-
return self::$layout_name;
|
38 |
}
|
39 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Layouts_Archive_Exists
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Layouts_Archive_Exists extends Types_Helper_Condition_Template {
|
9 |
|
10 |
+
private static $layout_id = array();
|
11 |
+
private static $layout_name = array();
|
12 |
|
13 |
public function valid() {
|
14 |
+
if( ! defined( 'WPDDL_DEVELOPMENT' ) && ! defined( 'WPDDL_PRODUCTION' ) )
|
15 |
return false;
|
16 |
|
17 |
+
$type = self::get_type_name();
|
18 |
|
19 |
$layouts = get_option( WPDDL_GENERAL_OPTIONS, array() );
|
20 |
|
21 |
+
// for type 'post'
|
22 |
+
if( $type == 'post' ) {
|
23 |
+
self::$layout_id[$type] = array_key_exists( 'layouts_home-blog-page', $layouts )
|
24 |
+
? $layouts['layouts_home-blog-page']
|
25 |
+
: false;
|
26 |
+
|
27 |
+
return self::$layout_id[$type];
|
28 |
+
}
|
29 |
|
30 |
+
// all cpts
|
31 |
+
self::$layout_id[$type] = array_key_exists( 'layouts_cpt_' . $type, $layouts )
|
32 |
+
? self::$layout_id[$type] = $layouts['layouts_cpt_' . $type]
|
33 |
+
: false;
|
34 |
|
35 |
+
return self::$layout_id[$type];
|
36 |
}
|
37 |
|
38 |
public static function get_layout_id() {
|
39 |
+
$type = self::get_type_name();
|
40 |
+
|
41 |
+
if( ! isset( self::$layout_id[$type] ) ) {
|
42 |
$self = new Types_Helper_Condition_Layouts_Archive_Exists();
|
43 |
$self->valid();
|
44 |
}
|
45 |
|
46 |
+
return self::$layout_id[$type];
|
47 |
}
|
48 |
|
49 |
public static function get_layout_name() {
|
50 |
+
$type = self::get_type_name();
|
51 |
+
|
52 |
+
if( !isset( self::$layout_name[$type] ) )
|
53 |
+
self::$layout_name[$type] = get_the_title( self::get_layout_id() );
|
54 |
|
55 |
+
return self::$layout_name[$type];
|
56 |
}
|
57 |
}
|
application/models/helper/condition/layouts/archive_missing.php
CHANGED
@@ -1,5 +1,10 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
class Types_Helper_Condition_Layouts_Archive_Missing extends Types_Helper_Condition_Layouts_Archive_Exists {
|
4 |
|
5 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Layouts_Archive_Missing
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Layouts_Archive_Missing extends Types_Helper_Condition_Layouts_Archive_Exists {
|
9 |
|
10 |
public function valid() {
|
application/models/helper/condition/layouts/compatible.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Layouts_Compatible extends Types_Helper_Condition_Template {
|
5 |
|
6 |
public function __construct() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Layouts_Compatible
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Layouts_Compatible extends Types_Helper_Condition_Template {
|
9 |
|
10 |
public function __construct() {
|
application/models/helper/condition/layouts/missing.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Layouts_Missing extends Types_Helper_Condition_Layouts_Active {
|
5 |
|
6 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Layouts_Missing
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Layouts_Missing extends Types_Helper_Condition_Layouts_Active {
|
9 |
|
10 |
public function valid() {
|
application/models/helper/condition/layouts/template_exists.php
CHANGED
@@ -1,38 +1,23 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
class Types_Helper_Condition_Layouts_Template_Exists extends Types_Helper_Condition_Template {
|
4 |
|
5 |
-
public static $layout_id;
|
6 |
-
public static $layout_name;
|
7 |
|
8 |
public function valid() {
|
9 |
-
if(
|
10 |
-
return true;
|
11 |
-
|
12 |
-
$post = wpcf_admin_get_edited_post();
|
13 |
-
if( ! empty( $post ) )
|
14 |
-
return $this->valid_per_post( $post );
|
15 |
-
|
16 |
-
return $this->valid_per_post_type();
|
17 |
-
|
18 |
-
}
|
19 |
-
|
20 |
-
// needed for single post edit screen
|
21 |
-
private function valid_per_post( $post ) {
|
22 |
-
if( ! class_exists( 'WPDD_Utils' ) || ! method_exists( 'WPDD_Utils', 'page_has_layout' ) || ! is_object( $post ) )
|
23 |
return false;
|
24 |
|
25 |
-
|
26 |
-
self::$layout_id = WPDD_Utils::get_layout_id_from_post_name( self::$layout_id );
|
27 |
-
return true;
|
28 |
-
}
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
// needed for cpt / fields group edit screen
|
34 |
-
private function valid_per_post_type() {
|
35 |
-
$cpt = Types_Helper_Condition::get_post_type();
|
36 |
|
37 |
global $wpdb;
|
38 |
|
@@ -43,34 +28,41 @@ class Types_Helper_Condition_Layouts_Template_Exists extends Types_Helper_Condit
|
|
43 |
$setting->meta_value = unserialize( $setting->meta_value );
|
44 |
|
45 |
if( is_array( $setting->meta_value )
|
46 |
-
&& in_array( $
|
47 |
|
48 |
if( get_post_status( $setting->post_id) == 'trash' )
|
49 |
continue;
|
50 |
|
51 |
$title = get_the_title( $setting->post_id );
|
52 |
-
self::$layout_id = $setting->post_id;
|
53 |
-
self::$layout_name = $title;
|
54 |
return true;
|
55 |
}
|
56 |
}
|
57 |
|
|
|
|
|
58 |
return false;
|
|
|
59 |
}
|
60 |
|
61 |
public static function get_layout_id() {
|
62 |
-
|
|
|
|
|
63 |
$self = new Types_Helper_Condition_Layouts_Template_Exists();
|
64 |
$self->valid();
|
65 |
}
|
66 |
|
67 |
-
return self::$layout_id;
|
68 |
}
|
69 |
|
70 |
public static function get_layout_name() {
|
71 |
-
|
72 |
-
|
|
|
|
|
73 |
|
74 |
-
return self::$layout_name;
|
75 |
}
|
76 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Layouts_Template_Exists
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Layouts_Template_Exists extends Types_Helper_Condition_Template {
|
9 |
|
10 |
+
public static $layout_id = array();
|
11 |
+
public static $layout_name = array();
|
12 |
|
13 |
public function valid() {
|
14 |
+
if( ! defined( 'WPDDL_DEVELOPMENT' ) && ! defined( 'WPDDL_PRODUCTION' ) )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
return false;
|
16 |
|
17 |
+
$type = self::get_type_name();
|
|
|
|
|
|
|
18 |
|
19 |
+
if( isset( self::$layout_id[$type] ) && self::$layout_id[$type] !== null && self::$layout_id !== false )
|
20 |
+
return true;
|
|
|
|
|
|
|
|
|
21 |
|
22 |
global $wpdb;
|
23 |
|
28 |
$setting->meta_value = unserialize( $setting->meta_value );
|
29 |
|
30 |
if( is_array( $setting->meta_value )
|
31 |
+
&& in_array( $type, $setting->meta_value ) ) {
|
32 |
|
33 |
if( get_post_status( $setting->post_id) == 'trash' )
|
34 |
continue;
|
35 |
|
36 |
$title = get_the_title( $setting->post_id );
|
37 |
+
self::$layout_id[$type] = $setting->post_id;
|
38 |
+
self::$layout_name[$type] = $title;
|
39 |
return true;
|
40 |
}
|
41 |
}
|
42 |
|
43 |
+
self::$layout_id[$type] = false;
|
44 |
+
self::$layout_name[$type] = false;
|
45 |
return false;
|
46 |
+
|
47 |
}
|
48 |
|
49 |
public static function get_layout_id() {
|
50 |
+
$type = self::get_type_name();
|
51 |
+
|
52 |
+
if( ! isset( self::$layout_id[$type] ) ) {
|
53 |
$self = new Types_Helper_Condition_Layouts_Template_Exists();
|
54 |
$self->valid();
|
55 |
}
|
56 |
|
57 |
+
return self::$layout_id[$type];
|
58 |
}
|
59 |
|
60 |
public static function get_layout_name() {
|
61 |
+
$type = self::get_type_name();
|
62 |
+
|
63 |
+
if( ! isset( self::$layout_name[$type] ) )
|
64 |
+
self::$layout_name[$type] = get_the_title( self::get_layout_id() );
|
65 |
|
66 |
+
return self::$layout_name[$type];
|
67 |
}
|
68 |
}
|
application/models/helper/condition/layouts/template_missing.php
CHANGED
@@ -1,9 +1,15 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
class Types_Helper_Condition_Layouts_Template_Missing extends Types_Helper_Condition_Layouts_Template_Exists {
|
4 |
|
5 |
public function valid() {
|
6 |
-
|
|
|
7 |
return false;
|
8 |
|
9 |
return ! parent::valid();
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Layouts_Template_Missing
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Layouts_Template_Missing extends Types_Helper_Condition_Layouts_Template_Exists {
|
9 |
|
10 |
public function valid() {
|
11 |
+
$type = self::get_type_name();
|
12 |
+
if( isset( parent::$layout_id[$type] ) && parent::$layout_id[$type] !== null && parent::$layout_id !== false )
|
13 |
return false;
|
14 |
|
15 |
return ! parent::valid();
|
application/models/helper/condition/screen.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Screen extends Types_Helper_Condition {
|
5 |
|
6 |
// check if current screen is screen
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Screen
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Screen extends Types_Helper_Condition {
|
9 |
|
10 |
// check if current screen is screen
|
application/models/helper/condition/single/exists.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Single_Exists extends Types_Helper_Condition_Template {
|
5 |
|
6 |
public function __construct() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Single_Exists
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Single_Exists extends Types_Helper_Condition_Template {
|
9 |
|
10 |
public function __construct() {
|
application/models/helper/condition/single/has_fields.php
CHANGED
@@ -1,5 +1,10 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
class Types_Helper_Condition_Single_Has_Fields extends Types_Helper_Condition_Single_No_Fields {
|
4 |
|
5 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Single_Has_Fields
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Single_Has_Fields extends Types_Helper_Condition_Single_No_Fields {
|
9 |
|
10 |
public function valid() {
|
application/models/helper/condition/single/missing.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Single_Missing extends Types_Helper_Condition_Single_Exists {
|
5 |
// this is valid if no template is found
|
6 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Single_Missing
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Single_Missing extends Types_Helper_Condition_Single_Exists {
|
9 |
// this is valid if no template is found
|
10 |
public function valid() {
|
application/models/helper/condition/single/no_fields.php
CHANGED
@@ -1,5 +1,10 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
class Types_Helper_Condition_Single_No_Fields extends Types_Helper_Condition_Single_Missing {
|
4 |
|
5 |
public function valid() {
|
@@ -22,7 +27,7 @@ class Types_Helper_Condition_Single_No_Fields extends Types_Helper_Condition_Sin
|
|
22 |
return false;
|
23 |
|
24 |
// check for fields, abort if there results in true
|
25 |
-
if( $file->search( 'types_render_field' ) )
|
26 |
return false;
|
27 |
|
28 |
return true;
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Single_No_Fields
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Single_No_Fields extends Types_Helper_Condition_Single_Missing {
|
9 |
|
10 |
public function valid() {
|
27 |
return false;
|
28 |
|
29 |
// check for fields, abort if there results in true
|
30 |
+
if( $file->search( array( 'types_render_field', 'wpcf-' ) ) )
|
31 |
return false;
|
32 |
|
33 |
return true;
|
application/models/helper/condition/template.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
abstract class Types_Helper_Condition_Template extends Types_Helper_Condition {
|
5 |
|
6 |
protected $templates;
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Template
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
abstract class Types_Helper_Condition_Template extends Types_Helper_Condition {
|
9 |
|
10 |
protected $templates;
|
application/models/helper/condition/type/fields_assigned.php
CHANGED
@@ -5,14 +5,27 @@ class Types_Helper_Condition_Type_Fields_Assigned extends Types_Helper_Condition
|
|
5 |
public function valid() {
|
6 |
$post_type = Types_Helper_Condition::get_post_type();
|
7 |
|
|
|
|
|
|
|
|
|
|
|
8 |
$query = new WP_Query( 'post_type=' . $post_type->name . '&posts_per_page=1' );
|
|
|
9 |
if( $query->have_posts() ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
-
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
}
|
16 |
|
17 |
if(
|
18 |
isset( $fields )
|
5 |
public function valid() {
|
6 |
$post_type = Types_Helper_Condition::get_post_type();
|
7 |
|
8 |
+
// false if we have no post type
|
9 |
+
if( ! isset( $post_type->name ) )
|
10 |
+
return false;
|
11 |
+
|
12 |
+
// query a post
|
13 |
$query = new WP_Query( 'post_type=' . $post_type->name . '&posts_per_page=1' );
|
14 |
+
|
15 |
if( $query->have_posts() ) {
|
16 |
+
$post = $query->posts[0];
|
17 |
+
|
18 |
+
// for the case no post created yet (post fields group edit page / post type edit page)
|
19 |
+
} else {
|
20 |
+
$post = new stdClass();
|
21 |
+
$post->ID = -1;
|
22 |
+
$post->post_type = $post_type->name;
|
23 |
+
}
|
24 |
|
25 |
+
if( !function_exists( 'wpcf_admin_post_get_post_groups_fields') )
|
26 |
+
include_once( WPCF_EMBEDDED_ABSPATH . '/includes/fields-post.php' );
|
27 |
|
28 |
+
$fields = wpcf_admin_post_get_post_groups_fields( $post );
|
|
|
29 |
|
30 |
if(
|
31 |
isset( $fields )
|
application/models/helper/condition/views/active.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Views_Active extends Types_Helper_Condition {
|
5 |
|
6 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Views_Active
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Views_Active extends Types_Helper_Condition {
|
9 |
|
10 |
public function valid() {
|
application/models/helper/condition/views/archive_exists.php
CHANGED
@@ -1,48 +1,57 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Views_Archive_Exists extends Types_Helper_Condition_Views_Views_Exist {
|
5 |
|
6 |
-
private static $template_id;
|
7 |
-
private static $template_name;
|
8 |
|
9 |
public function valid() {
|
10 |
-
if( self::$template_id !== null && self::$template_id !== false )
|
11 |
-
return true;
|
12 |
-
|
13 |
// if views not active
|
14 |
if( ! defined( 'WPV_VERSION' )
|
15 |
|| !function_exists( 'wpv_has_wordpress_archive') )
|
16 |
return false;
|
17 |
|
18 |
-
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
|
24 |
-
|
25 |
-
|
|
|
26 |
|
27 |
-
self::$template_id = $archive
|
|
|
|
|
28 |
|
29 |
-
return
|
30 |
}
|
31 |
|
32 |
public static function get_template_id() {
|
33 |
-
|
34 |
-
|
|
|
|
|
35 |
$self->valid();
|
36 |
}
|
37 |
|
38 |
-
return self::$template_id;
|
39 |
}
|
40 |
|
41 |
public static function get_template_name() {
|
42 |
-
|
43 |
-
|
|
|
|
|
44 |
|
45 |
-
return self::$template_name;
|
46 |
}
|
47 |
|
48 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Views_Archive_Exists
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Views_Archive_Exists extends Types_Helper_Condition_Views_Views_Exist {
|
9 |
|
10 |
+
private static $template_id = array();
|
11 |
+
private static $template_name = array();
|
12 |
|
13 |
public function valid() {
|
|
|
|
|
|
|
14 |
// if views not active
|
15 |
if( ! defined( 'WPV_VERSION' )
|
16 |
|| !function_exists( 'wpv_has_wordpress_archive') )
|
17 |
return false;
|
18 |
|
19 |
+
// get current type name
|
20 |
+
$type = self::get_type_name();
|
21 |
|
22 |
+
// check stored validation
|
23 |
+
if( isset( self::$template_id[$type] ) && self::$template_id[$type] !== null && self::$template_id[$type] !== false )
|
24 |
+
return true;
|
25 |
|
26 |
+
$archive = $type == 'post'
|
27 |
+
? wpv_has_wordpress_archive()
|
28 |
+
: wpv_has_wordpress_archive( 'post', $type );
|
29 |
|
30 |
+
self::$template_id[$type] = $archive && $archive !== 0
|
31 |
+
? $archive
|
32 |
+
: false;
|
33 |
|
34 |
+
return self::$template_id[$type];
|
35 |
}
|
36 |
|
37 |
public static function get_template_id() {
|
38 |
+
$type = self::get_type_name();
|
39 |
+
|
40 |
+
if( ! isset( self::$template_id[$type] ) ) {
|
41 |
+
$self = new Types_Helper_Condition_Views_Archive_Exists();
|
42 |
$self->valid();
|
43 |
}
|
44 |
|
45 |
+
return self::$template_id[$type];
|
46 |
}
|
47 |
|
48 |
public static function get_template_name() {
|
49 |
+
$type = self::get_type_name();
|
50 |
+
|
51 |
+
if( ! isset( self::$template_name[$type] ) )
|
52 |
+
self::$template_name[$type] = get_the_title( self::get_template_id() );
|
53 |
|
54 |
+
return self::$template_name[$type];
|
55 |
}
|
56 |
|
57 |
}
|
application/models/helper/condition/views/archive_missing.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Views_Archive_Missing extends Types_Helper_Condition_Views_Archive_Exists {
|
5 |
|
6 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Views_Archive_Missing
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Views_Archive_Missing extends Types_Helper_Condition_Views_Archive_Exists {
|
9 |
|
10 |
public function valid() {
|
application/models/helper/condition/views/missing.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Views_Missing extends Types_Helper_Condition_Views_Active {
|
5 |
|
6 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Views_Missing
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Views_Missing extends Types_Helper_Condition_Views_Active {
|
9 |
|
10 |
public function valid() {
|
application/models/helper/condition/views/template_exists.php
CHANGED
@@ -1,74 +1,65 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Views_Template_Exists extends Types_Helper_Condition_Views_Views_Exist {
|
5 |
|
6 |
-
private static $template_id;
|
7 |
-
private static $template_name;
|
8 |
|
9 |
public function valid() {
|
10 |
-
if( self::$template_id !== null && self::$template_id !== false )
|
11 |
-
return true;
|
12 |
-
|
13 |
// if views not active
|
14 |
if( ! defined( 'WPV_VERSION' ) )
|
15 |
return false;
|
16 |
|
17 |
-
|
18 |
-
return $this->valid_per_post();
|
19 |
-
|
20 |
-
return $this->valid_per_post_type();
|
21 |
-
}
|
22 |
-
|
23 |
-
// needed for single post edit screen
|
24 |
-
private function valid_per_post( ) {
|
25 |
-
if( function_exists( 'has_wpv_content_template' ) ) {
|
26 |
-
$template = has_wpv_content_template( $_GET['post'] );
|
27 |
-
|
28 |
-
if( ! $template
|
29 |
-
|| $template === 0
|
30 |
-
|| ! get_post_type( $template )
|
31 |
-
)
|
32 |
-
return false;
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
}
|
39 |
-
|
40 |
-
// needed for cpt / fields group edit screen
|
41 |
-
private function valid_per_post_type() {
|
42 |
-
$cpt = Types_Helper_Condition::get_post_type();
|
43 |
|
44 |
$wpv_options = get_option( 'wpv_options', array() );
|
45 |
|
46 |
if( empty( $wpv_options )
|
47 |
-
|| ! isset( $wpv_options['views_template_for_'.$
|
48 |
-
|| ! get_post_type( $wpv_options['views_template_for_'.$
|
49 |
-
)
|
|
|
|
|
50 |
return false;
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
$title = get_the_title( $wpv_options['views_template_for_'.$cpt->name] );
|
53 |
-
self::$template_id = $wpv_options['views_template_for_'.$cpt->name];
|
54 |
-
self::$template_name = $title;
|
55 |
return true;
|
56 |
}
|
57 |
|
58 |
public static function get_template_id() {
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
|
67 |
public static function get_template_name() {
|
68 |
-
|
69 |
-
|
|
|
|
|
70 |
|
71 |
-
return self::$template_name;
|
72 |
}
|
73 |
|
74 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Views_Template_Exists
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Views_Template_Exists extends Types_Helper_Condition_Views_Views_Exist {
|
9 |
|
10 |
+
private static $template_id = array();
|
11 |
+
private static $template_name = array();
|
12 |
|
13 |
public function valid() {
|
|
|
|
|
|
|
14 |
// if views not active
|
15 |
if( ! defined( 'WPV_VERSION' ) )
|
16 |
return false;
|
17 |
|
18 |
+
$type = self::get_type_name();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
if( isset( self::$template_id[$type] )
|
21 |
+
&& self::$template_id[$type] !== null
|
22 |
+
&& self::$template_id[$type] !== false )
|
23 |
+
return true;
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
$wpv_options = get_option( 'wpv_options', array() );
|
26 |
|
27 |
if( empty( $wpv_options )
|
28 |
+
|| ! isset( $wpv_options['views_template_for_'.$type] )
|
29 |
+
|| ! get_post_type( $wpv_options['views_template_for_'.$type] )
|
30 |
+
) {
|
31 |
+
self::$template_id[$type] = false;
|
32 |
+
self::$template_name[$type] = false;
|
33 |
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
$title = get_the_title( $wpv_options['views_template_for_'.$type] );
|
37 |
+
self::$template_id[$type] = $wpv_options['views_template_for_'.$type];
|
38 |
+
self::$template_name[$type] = $title;
|
39 |
|
|
|
|
|
|
|
40 |
return true;
|
41 |
}
|
42 |
|
43 |
public static function get_template_id() {
|
44 |
+
$type = self::get_type_name();
|
45 |
+
|
46 |
+
if( isset( self::$template_id[$type] ) )
|
47 |
+
return self::$template_id[$type];
|
48 |
|
49 |
+
// not set yet
|
50 |
+
$self = new Types_Helper_Condition_Views_Template_Exists();
|
51 |
+
|
52 |
+
if( $self->valid() )
|
53 |
+
return self::get_template_id();
|
54 |
}
|
55 |
|
56 |
public static function get_template_name() {
|
57 |
+
$type = self::get_type_name();
|
58 |
+
|
59 |
+
if( ! isset( self::$template_name[$type] ) )
|
60 |
+
self::$template_name[$type] = get_the_title( self::get_template_id() );
|
61 |
|
62 |
+
return self::$template_name[$type];
|
63 |
}
|
64 |
|
65 |
}
|
application/models/helper/condition/views/template_missing.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Views_Template_Missing extends Types_Helper_Condition_Views_Template_Exists {
|
5 |
|
6 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Views_Template_Missing
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Views_Template_Missing extends Types_Helper_Condition_Views_Template_Exists {
|
9 |
|
10 |
public function valid() {
|
application/models/helper/condition/views/views_exist.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Views_Views_Exist extends Types_Helper_Condition_Views_Active {
|
5 |
|
6 |
public static $views_per_post_type;
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Views_Views_Exist
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Views_Views_Exist extends Types_Helper_Condition_Views_Active {
|
9 |
|
10 |
public static $views_per_post_type;
|
application/models/helper/condition/views/views_missing.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Condition_Views_Views_Missing extends Types_Helper_Condition_Views_Views_Exist {
|
5 |
|
6 |
public function valid() {
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Condition_Views_Views_Missing
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Condition_Views_Views_Missing extends Types_Helper_Condition_Views_Views_Exist {
|
9 |
|
10 |
public function valid() {
|
application/models/helper/create/content_template.php
CHANGED
@@ -1,19 +1,37 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
class Types_Helper_Create_Content_Template {
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
public function for_post( $type, $name = false ) {
|
6 |
|
|
|
7 |
if( ! $this->needed_components_loaded() )
|
8 |
return false;
|
9 |
|
10 |
global $WPV_settings;
|
|
|
|
|
11 |
$option = sanitize_text_field( sprintf( 'views_template_for_%s', $type ) );
|
12 |
|
13 |
// already has an content template
|
14 |
if( isset( $WPV_settings[$option] ) && is_numeric( $WPV_settings[$option] ) && $WPV_settings[$option] > 0 )
|
15 |
return $WPV_settings[$option];
|
16 |
|
|
|
17 |
if( ! $name ) {
|
18 |
$type_object = get_post_type_object( $type );
|
19 |
$name = sprintf( __( 'Template for %s', 'types' ), $type_object->labels->name );
|
@@ -21,9 +39,11 @@ class Types_Helper_Create_Content_Template {
|
|
21 |
|
22 |
$name = $this->validate_name( $name );
|
23 |
|
|
|
24 |
if( ! $name )
|
25 |
return false;
|
26 |
|
|
|
27 |
$ct = WPV_Content_Template::create( $name );
|
28 |
$ct_post = get_post( $ct->id );
|
29 |
|
@@ -33,11 +53,13 @@ class Types_Helper_Create_Content_Template {
|
|
33 |
$WPV_settings[$option] = $ct_post->ID;
|
34 |
$WPV_settings->save();
|
35 |
|
|
|
36 |
$posts = get_posts( 'post_type=' . $type . '&post_status=any&posts_per_page=-1&fields=ids' );
|
37 |
|
38 |
foreach( $posts as $id ) {
|
39 |
$ct = get_post_meta( $id, '_views_template', true );
|
40 |
|
|
|
41 |
if( empty( $ct ) )
|
42 |
update_post_meta( $id, '_views_template', $ct_post->ID );
|
43 |
|
@@ -46,6 +68,12 @@ class Types_Helper_Create_Content_Template {
|
|
46 |
return $ct_post->ID;
|
47 |
}
|
48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
private function needed_components_loaded( ) {
|
50 |
global $WPV_settings;
|
51 |
if(
|
@@ -57,6 +85,17 @@ class Types_Helper_Create_Content_Template {
|
|
57 |
return true;
|
58 |
}
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
private function validate_name( $name, $id = 1 ) {
|
61 |
$name_exists = get_page_by_title( html_entity_decode( $name ), OBJECT, 'view-template' );
|
62 |
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Create_Content_Template
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Create_Content_Template {
|
9 |
|
10 |
+
/**
|
11 |
+
* Creates a content template for a given post type
|
12 |
+
*
|
13 |
+
* @param $type
|
14 |
+
* @param bool|string $name Name for the Content Template
|
15 |
+
*
|
16 |
+
* @return bool
|
17 |
+
* @since 2.0
|
18 |
+
*/
|
19 |
public function for_post( $type, $name = false ) {
|
20 |
|
21 |
+
// abort if any needed dependency is not available
|
22 |
if( ! $this->needed_components_loaded() )
|
23 |
return false;
|
24 |
|
25 |
global $WPV_settings;
|
26 |
+
|
27 |
+
// option key for Views Content Templates is "views_template_for_{post-type-name}"
|
28 |
$option = sanitize_text_field( sprintf( 'views_template_for_%s', $type ) );
|
29 |
|
30 |
// already has an content template
|
31 |
if( isset( $WPV_settings[$option] ) && is_numeric( $WPV_settings[$option] ) && $WPV_settings[$option] > 0 )
|
32 |
return $WPV_settings[$option];
|
33 |
|
34 |
+
// create name if not given
|
35 |
if( ! $name ) {
|
36 |
$type_object = get_post_type_object( $type );
|
37 |
$name = sprintf( __( 'Template for %s', 'types' ), $type_object->labels->name );
|
39 |
|
40 |
$name = $this->validate_name( $name );
|
41 |
|
42 |
+
// abort if name not valid (shouldn't happen, see validate_name())
|
43 |
if( ! $name )
|
44 |
return false;
|
45 |
|
46 |
+
// create template
|
47 |
$ct = WPV_Content_Template::create( $name );
|
48 |
$ct_post = get_post( $ct->id );
|
49 |
|
53 |
$WPV_settings[$option] = $ct_post->ID;
|
54 |
$WPV_settings->save();
|
55 |
|
56 |
+
// get all posts of post type to assign the new content template
|
57 |
$posts = get_posts( 'post_type=' . $type . '&post_status=any&posts_per_page=-1&fields=ids' );
|
58 |
|
59 |
foreach( $posts as $id ) {
|
60 |
$ct = get_post_meta( $id, '_views_template', true );
|
61 |
|
62 |
+
// only assign if there is not already an assigned content template
|
63 |
if( empty( $ct ) )
|
64 |
update_post_meta( $id, '_views_template', $ct_post->ID );
|
65 |
|
68 |
return $ct_post->ID;
|
69 |
}
|
70 |
|
71 |
+
/**
|
72 |
+
* Checks all dependencies
|
73 |
+
*
|
74 |
+
* @return bool
|
75 |
+
* @since 2.0
|
76 |
+
*/
|
77 |
private function needed_components_loaded( ) {
|
78 |
global $WPV_settings;
|
79 |
if(
|
85 |
return true;
|
86 |
}
|
87 |
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Will proof if given name is already in use.
|
91 |
+
* If so it adds an running number until name is available
|
92 |
+
*
|
93 |
+
* @param $name
|
94 |
+
* @param int $id | should not manually added
|
95 |
+
*
|
96 |
+
* @return string
|
97 |
+
* @since 2.0
|
98 |
+
*/
|
99 |
private function validate_name( $name, $id = 1 ) {
|
100 |
$name_exists = get_page_by_title( html_entity_decode( $name ), OBJECT, 'view-template' );
|
101 |
|
application/models/helper/create/form.php
CHANGED
@@ -1,20 +1,40 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
class Types_Helper_Create_Form {
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
public function for_post( $type, $name = false ) {
|
|
|
|
|
6 |
if( ! defined( 'CRED_CLASSES_PATH' ) )
|
7 |
return false;
|
8 |
|
|
|
9 |
if( ! file_exists( CRED_CLASSES_PATH . '/CredFormCreator.php' ) )
|
10 |
return false;
|
11 |
|
|
|
12 |
require_once( CRED_CLASSES_PATH . '/CredFormCreator.php' );
|
13 |
|
|
|
14 |
if( ! class_exists( 'CredFormCreator' )
|
15 |
|| ! method_exists( 'CredFormCreator', 'cred_create_form' ) )
|
16 |
return false;
|
17 |
|
|
|
18 |
if( ! $name ) {
|
19 |
$type_object = get_post_type_object( $type );
|
20 |
$name = sprintf( __( 'Form for %s', 'types' ), $type_object->labels->name );
|
@@ -26,6 +46,16 @@ class Types_Helper_Create_Form {
|
|
26 |
return $id;
|
27 |
}
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
private function validate_name( $name, $id = 1 ) {
|
30 |
$name_exists = get_page_by_title( html_entity_decode( $name ), OBJECT, CRED_FORMS_CUSTOM_POST_NAME );
|
31 |
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Create_Form
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Create_Form {
|
9 |
|
10 |
+
/**
|
11 |
+
* Creates a form for a given post type
|
12 |
+
*
|
13 |
+
* @param $type
|
14 |
+
* @param bool|string $name Name for the Form
|
15 |
+
*
|
16 |
+
* @return bool
|
17 |
+
* @since 2.0
|
18 |
+
*/
|
19 |
public function for_post( $type, $name = false ) {
|
20 |
+
|
21 |
+
// abort if CRED is not installed
|
22 |
if( ! defined( 'CRED_CLASSES_PATH' ) )
|
23 |
return false;
|
24 |
|
25 |
+
// abort if FormCreator does not exists
|
26 |
if( ! file_exists( CRED_CLASSES_PATH . '/CredFormCreator.php' ) )
|
27 |
return false;
|
28 |
|
29 |
+
// load form creator
|
30 |
require_once( CRED_CLASSES_PATH . '/CredFormCreator.php' );
|
31 |
|
32 |
+
// abort if cred_create_form is not available
|
33 |
if( ! class_exists( 'CredFormCreator' )
|
34 |
|| ! method_exists( 'CredFormCreator', 'cred_create_form' ) )
|
35 |
return false;
|
36 |
|
37 |
+
// create name if not given
|
38 |
if( ! $name ) {
|
39 |
$type_object = get_post_type_object( $type );
|
40 |
$name = sprintf( __( 'Form for %s', 'types' ), $type_object->labels->name );
|
46 |
return $id;
|
47 |
}
|
48 |
|
49 |
+
/**
|
50 |
+
* Will proof if given name is already in use.
|
51 |
+
* If so it adds an running number until name is available
|
52 |
+
*
|
53 |
+
* @param $name
|
54 |
+
* @param int $id
|
55 |
+
*
|
56 |
+
* @return string
|
57 |
+
* @since 2.0
|
58 |
+
*/
|
59 |
private function validate_name( $name, $id = 1 ) {
|
60 |
$name_exists = get_page_by_title( html_entity_decode( $name ), OBJECT, CRED_FORMS_CUSTOM_POST_NAME );
|
61 |
|
application/models/helper/create/layout.php
CHANGED
@@ -2,8 +2,18 @@
|
|
2 |
|
3 |
class Types_Helper_Create_Layout {
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
public function for_post( $type, $name = false ) {
|
6 |
|
|
|
7 |
if( ! $name ) {
|
8 |
$type_object = get_post_type_object( $type );
|
9 |
$name = sprintf( __( 'Template for %s', 'types' ), $type_object->labels->name );
|
@@ -14,12 +24,13 @@ class Types_Helper_Create_Layout {
|
|
14 |
if( ! $name )
|
15 |
return false;
|
16 |
|
|
|
17 |
$layout_id = $this->create_layout( $name );
|
18 |
|
19 |
if( ! $layout_id )
|
20 |
return false;
|
21 |
|
22 |
-
|
23 |
$posts = get_posts( 'post_type=' . $type . '&post_status=any&posts_per_page=-1&fields=ids' );
|
24 |
|
25 |
// store layout assignments before assign new
|
@@ -35,6 +46,7 @@ class Types_Helper_Create_Layout {
|
|
35 |
}
|
36 |
|
37 |
// assign the new layout to all post types
|
|
|
38 |
$wpddlayout->post_types_manager->handle_set_option_and_bulk_at_once( $layout_id, array( $type ), array( $type ) );
|
39 |
|
40 |
// restore previously assigned layouts
|
@@ -47,24 +59,40 @@ class Types_Helper_Create_Layout {
|
|
47 |
return $layout_id;
|
48 |
}
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
private function needed_components_loaded( ) {
|
51 |
global $wpddlayout;
|
52 |
if(
|
53 |
! is_object( $wpddlayout )
|
54 |
|| ! class_exists( 'WPDD_Layouts' )
|
|
|
55 |
|| ! class_exists( 'WPDD_Layouts_Users_Profiles' )
|
56 |
|| ! method_exists( 'WPDD_Layouts', 'create_layout' )
|
57 |
|| ! method_exists( 'WPDD_Layouts', 'save_layout_settings' )
|
58 |
|| ! method_exists( 'WPDD_Layouts_Users_Profiles', 'user_can_create' )
|
59 |
|| ! method_exists( 'WPDD_Layouts_Users_Profiles', 'user_can_assign' )
|
|
|
60 |
|| ! method_exists( $wpddlayout, 'get_css_framework' )
|
61 |
) return false;
|
62 |
|
63 |
return true;
|
64 |
}
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
private function create_layout( $name ) {
|
67 |
-
//
|
68 |
// currently there is only (which I found)
|
69 |
// - create_layout_auto(), which has a redirect
|
70 |
// - create_layout_callback() for ajax only -> uses die()
|
@@ -79,11 +107,17 @@ class Types_Helper_Create_Layout {
|
|
79 |
|
80 |
$layout = WPDD_Layouts::create_layout( 12, 'fluid' );
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
// Define layout parameters
|
83 |
$layout['type'] = 'fluid'; // layout_type
|
84 |
$layout['cssframework'] = $wpddlayout->get_css_framework();
|
85 |
$layout['template'] = '';
|
86 |
-
$layout['parent'] =
|
87 |
$layout['name'] = $name;
|
88 |
|
89 |
$args = array(
|
@@ -106,6 +140,16 @@ class Types_Helper_Create_Layout {
|
|
106 |
return $layout_id;
|
107 |
}
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
private function validate_name( $name, $id = 1 ) {
|
110 |
$name_exists = get_page_by_title( html_entity_decode( $name ), OBJECT, WPDDL_LAYOUTS_POST_TYPE );
|
111 |
|
2 |
|
3 |
class Types_Helper_Create_Layout {
|
4 |
|
5 |
+
/**
|
6 |
+
* Creates a layout for a given post type
|
7 |
+
*
|
8 |
+
* @param $type
|
9 |
+
* @param bool|string $name Name for the Layout
|
10 |
+
*
|
11 |
+
* @return bool
|
12 |
+
* @since 2.0
|
13 |
+
*/
|
14 |
public function for_post( $type, $name = false ) {
|
15 |
|
16 |
+
// set name if no available
|
17 |
if( ! $name ) {
|
18 |
$type_object = get_post_type_object( $type );
|
19 |
$name = sprintf( __( 'Template for %s', 'types' ), $type_object->labels->name );
|
24 |
if( ! $name )
|
25 |
return false;
|
26 |
|
27 |
+
// create layout
|
28 |
$layout_id = $this->create_layout( $name );
|
29 |
|
30 |
if( ! $layout_id )
|
31 |
return false;
|
32 |
|
33 |
+
// get all items of post type
|
34 |
$posts = get_posts( 'post_type=' . $type . '&post_status=any&posts_per_page=-1&fields=ids' );
|
35 |
|
36 |
// store layout assignments before assign new
|
46 |
}
|
47 |
|
48 |
// assign the new layout to all post types
|
49 |
+
global $wpddlayout;
|
50 |
$wpddlayout->post_types_manager->handle_set_option_and_bulk_at_once( $layout_id, array( $type ), array( $type ) );
|
51 |
|
52 |
// restore previously assigned layouts
|
59 |
return $layout_id;
|
60 |
}
|
61 |
|
62 |
+
/**
|
63 |
+
* Checks all dependencies
|
64 |
+
*
|
65 |
+
* @return bool
|
66 |
+
* @since 2.0
|
67 |
+
*/
|
68 |
private function needed_components_loaded( ) {
|
69 |
global $wpddlayout;
|
70 |
if(
|
71 |
! is_object( $wpddlayout )
|
72 |
|| ! class_exists( 'WPDD_Layouts' )
|
73 |
+
|| ! class_exists( 'WPDDL_Options' )
|
74 |
|| ! class_exists( 'WPDD_Layouts_Users_Profiles' )
|
75 |
|| ! method_exists( 'WPDD_Layouts', 'create_layout' )
|
76 |
|| ! method_exists( 'WPDD_Layouts', 'save_layout_settings' )
|
77 |
|| ! method_exists( 'WPDD_Layouts_Users_Profiles', 'user_can_create' )
|
78 |
|| ! method_exists( 'WPDD_Layouts_Users_Profiles', 'user_can_assign' )
|
79 |
+
|| ! method_exists( 'WPDD_Layouts_Cache_Singleton', 'get_name_by_id' )
|
80 |
|| ! method_exists( $wpddlayout, 'get_css_framework' )
|
81 |
) return false;
|
82 |
|
83 |
return true;
|
84 |
}
|
85 |
|
86 |
+
/**
|
87 |
+
* Create a layout with given name
|
88 |
+
*
|
89 |
+
* @param $name
|
90 |
+
*
|
91 |
+
* @return bool|int|WP_Error
|
92 |
+
* @since 2.0
|
93 |
+
*/
|
94 |
private function create_layout( $name ) {
|
95 |
+
// todo check with Ric to get a more handy class to create a new layout.
|
96 |
// currently there is only (which I found)
|
97 |
// - create_layout_auto(), which has a redirect
|
98 |
// - create_layout_callback() for ajax only -> uses die()
|
107 |
|
108 |
$layout = WPDD_Layouts::create_layout( 12, 'fluid' );
|
109 |
|
110 |
+
$parent_post_name = '';
|
111 |
+
$parent_ID = apply_filters('ddl-get-default-' . WPDDL_Options::PARENTS_OPTIONS, WPDDL_Options::PARENTS_OPTIONS);
|
112 |
+
if ($parent_ID) {
|
113 |
+
$parent_post_name = WPDD_Layouts_Cache_Singleton::get_name_by_id($parent_ID);
|
114 |
+
}
|
115 |
+
|
116 |
// Define layout parameters
|
117 |
$layout['type'] = 'fluid'; // layout_type
|
118 |
$layout['cssframework'] = $wpddlayout->get_css_framework();
|
119 |
$layout['template'] = '';
|
120 |
+
$layout['parent'] = $parent_post_name;
|
121 |
$layout['name'] = $name;
|
122 |
|
123 |
$args = array(
|
140 |
return $layout_id;
|
141 |
}
|
142 |
|
143 |
+
/**
|
144 |
+
* Will proof if given name is already in use.
|
145 |
+
* If so it adds an running number until name is available
|
146 |
+
*
|
147 |
+
* @param $name
|
148 |
+
* @param int $id | should not manually added
|
149 |
+
*
|
150 |
+
* @return string
|
151 |
+
* @since 2.0
|
152 |
+
*/
|
153 |
private function validate_name( $name, $id = 1 ) {
|
154 |
$name_exists = get_page_by_title( html_entity_decode( $name ), OBJECT, WPDDL_LAYOUTS_POST_TYPE );
|
155 |
|
application/models/helper/create/view.php
CHANGED
@@ -2,11 +2,22 @@
|
|
2 |
|
3 |
class Types_Helper_Create_View {
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
public function for_post( $type, $name = false ) {
|
|
|
6 |
if( ! class_exists( 'WPV_View' )
|
7 |
|| ! method_exists( 'WPV_View', 'create' ) )
|
8 |
return false;
|
9 |
|
|
|
10 |
if( ! $name ) {
|
11 |
$type_object = get_post_type_object( $type );
|
12 |
$name = sprintf( __( 'View for %s', 'types' ), $type_object->labels->name );
|
@@ -26,6 +37,16 @@ class Types_Helper_Create_View {
|
|
26 |
return $view->id;
|
27 |
}
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
private function validate_name( $name, $id = 1 ) {
|
30 |
$name_exists = get_page_by_title( html_entity_decode( $name ), OBJECT, 'view' );
|
31 |
if( $name_exists !== null ) {
|
2 |
|
3 |
class Types_Helper_Create_View {
|
4 |
|
5 |
+
/**
|
6 |
+
* Creates a View for a given post type
|
7 |
+
*
|
8 |
+
* @param $type
|
9 |
+
* @param bool|string $name Name for the View
|
10 |
+
*
|
11 |
+
* @return bool
|
12 |
+
* @since 2.0
|
13 |
+
*/
|
14 |
public function for_post( $type, $name = false ) {
|
15 |
+
// check if Views is active
|
16 |
if( ! class_exists( 'WPV_View' )
|
17 |
|| ! method_exists( 'WPV_View', 'create' ) )
|
18 |
return false;
|
19 |
|
20 |
+
// create name if not set
|
21 |
if( ! $name ) {
|
22 |
$type_object = get_post_type_object( $type );
|
23 |
$name = sprintf( __( 'View for %s', 'types' ), $type_object->labels->name );
|
37 |
return $view->id;
|
38 |
}
|
39 |
|
40 |
+
/**
|
41 |
+
* Will proof if given name is already in use.
|
42 |
+
* If so it adds an running number until name is available
|
43 |
+
*
|
44 |
+
* @param $name
|
45 |
+
* @param int $id | should not manually added
|
46 |
+
*
|
47 |
+
* @return string
|
48 |
+
* @since 2.0
|
49 |
+
*/
|
50 |
private function validate_name( $name, $id = 1 ) {
|
51 |
$name_exists = get_page_by_title( html_entity_decode( $name ), OBJECT, 'view' );
|
52 |
if( $name_exists !== null ) {
|
application/models/helper/create/wordpress_archive.php
CHANGED
@@ -2,18 +2,35 @@
|
|
2 |
|
3 |
class Types_Helper_Create_Wordpress_Archive {
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
public function for_post( $type, $name = false ) {
|
6 |
|
|
|
7 |
if( ! $this->needed_components_loaded() )
|
8 |
return false;
|
9 |
|
10 |
global $WPV_settings;
|
11 |
$option = sanitize_text_field( sprintf( 'view_cpt_%s', $type ) );
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
// already has an archive
|
14 |
if( isset( $WPV_settings[$option] ) && is_numeric( $WPV_settings[$option] ) && $WPV_settings[$option] > 0 )
|
15 |
return $WPV_settings[$option];
|
16 |
|
|
|
17 |
if( ! $name ) {
|
18 |
$type_object = get_post_type_object( $type );
|
19 |
$name = sprintf( __( 'Archive for %s', 'types' ), $type_object->labels->name );
|
@@ -30,13 +47,18 @@ class Types_Helper_Create_Wordpress_Archive {
|
|
30 |
if( $archive_post === null )
|
31 |
return false;
|
32 |
|
33 |
-
|
34 |
$WPV_settings[$option] = $archive_post->ID;
|
35 |
$WPV_settings->save();
|
36 |
|
37 |
return $archive_post->ID;
|
38 |
}
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
private function needed_components_loaded( ) {
|
41 |
global $WPV_settings;
|
42 |
if(
|
@@ -48,8 +70,18 @@ class Types_Helper_Create_Wordpress_Archive {
|
|
48 |
return true;
|
49 |
}
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
private function validate_name( $name, $id = 1 ) {
|
52 |
-
$name_exists = get_page_by_title( html_entity_decode( $name ), OBJECT, 'view
|
53 |
|
54 |
if( $name_exists ) {
|
55 |
$name = $id > 1 ? rtrim( rtrim( $name, $id - 1 ) ) : $name;
|
2 |
|
3 |
class Types_Helper_Create_Wordpress_Archive {
|
4 |
|
5 |
+
/**
|
6 |
+
* Creates a WordPress Archive for a given post type
|
7 |
+
*
|
8 |
+
* @param $type
|
9 |
+
* @param bool|string $name Name for the WordPress Archive
|
10 |
+
*
|
11 |
+
* @return bool
|
12 |
+
* @since 2.0
|
13 |
+
*/
|
14 |
public function for_post( $type, $name = false ) {
|
15 |
|
16 |
+
// check dependencies
|
17 |
if( ! $this->needed_components_loaded() )
|
18 |
return false;
|
19 |
|
20 |
global $WPV_settings;
|
21 |
$option = sanitize_text_field( sprintf( 'view_cpt_%s', $type ) );
|
22 |
|
23 |
+
// for type 'post'
|
24 |
+
if( $type == 'post' ) {
|
25 |
+
$name = __( 'Archive for Home/Blog', 'types' );
|
26 |
+
$option = 'view_home-blog-page';
|
27 |
+
}
|
28 |
+
|
29 |
// already has an archive
|
30 |
if( isset( $WPV_settings[$option] ) && is_numeric( $WPV_settings[$option] ) && $WPV_settings[$option] > 0 )
|
31 |
return $WPV_settings[$option];
|
32 |
|
33 |
+
// set name if not given
|
34 |
if( ! $name ) {
|
35 |
$type_object = get_post_type_object( $type );
|
36 |
$name = sprintf( __( 'Archive for %s', 'types' ), $type_object->labels->name );
|
47 |
if( $archive_post === null )
|
48 |
return false;
|
49 |
|
|
|
50 |
$WPV_settings[$option] = $archive_post->ID;
|
51 |
$WPV_settings->save();
|
52 |
|
53 |
return $archive_post->ID;
|
54 |
}
|
55 |
|
56 |
+
/**
|
57 |
+
* Checks all dependencies
|
58 |
+
*
|
59 |
+
* @return bool
|
60 |
+
* @since 2.0
|
61 |
+
*/
|
62 |
private function needed_components_loaded( ) {
|
63 |
global $WPV_settings;
|
64 |
if(
|
70 |
return true;
|
71 |
}
|
72 |
|
73 |
+
/**
|
74 |
+
* Will proof if given name is already in use.
|
75 |
+
* If so it adds an running number until name is available
|
76 |
+
*
|
77 |
+
* @param $name
|
78 |
+
* @param int $id | should not manually added
|
79 |
+
*
|
80 |
+
* @return string
|
81 |
+
* @since 2.0
|
82 |
+
*/
|
83 |
private function validate_name( $name, $id = 1 ) {
|
84 |
+
$name_exists = get_page_by_title( html_entity_decode( $name ), OBJECT, 'view' );
|
85 |
|
86 |
if( $name_exists ) {
|
87 |
$name = $id > 1 ? rtrim( rtrim( $name, $id - 1 ) ) : $name;
|
application/models/helper/output/interface.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
interface Types_Helper_Output_Interface {
|
5 |
public function set_content( $content );
|
6 |
public function output();
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Output_Interface
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
interface Types_Helper_Output_Interface {
|
9 |
public function set_content( $content );
|
10 |
public function output();
|
application/models/helper/output/meta_box.php
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Output_Meta_Box implements Types_Helper_Output_Interface {
|
5 |
|
6 |
private $output;
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Output_Meta_Box
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Output_Meta_Box implements Types_Helper_Output_Interface {
|
9 |
|
10 |
private $output;
|
application/models/helper/placeholder.php
CHANGED
@@ -1,25 +1,13 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Placeholder {
|
5 |
|
6 |
private static $post_type;
|
7 |
-
private static $post_type_template_file;
|
8 |
-
private static $post_type_archive_file;
|
9 |
-
private static $post_type_create_layout_template;
|
10 |
-
private static $post_type_create_layout_archive;
|
11 |
-
|
12 |
-
private static $archive_link;
|
13 |
-
private static $single_link;
|
14 |
-
|
15 |
-
private static $post_type_edit_layout_template;
|
16 |
-
private static $post_type_edit_layout_archive;
|
17 |
-
|
18 |
-
private static $post_type_edit_views_template;
|
19 |
-
private static $post_type_edit_views_archive;
|
20 |
-
private static $post_type_create_views_archive;
|
21 |
-
|
22 |
-
private static $post_type_create_view;
|
23 |
|
24 |
public static function set_post_type( $posttype = false ) {
|
25 |
|
@@ -61,8 +49,8 @@ class Types_Helper_Placeholder {
|
|
61 |
'%POST-TEMPLATE-FILE%' => '<nobr>' . self::get_post_template_file() . '</nobr>',
|
62 |
'%POST-ARCHIVE-FILE%' => '<nobr>' . self::get_post_archive_file() . '</nobr>',
|
63 |
'%POST-FORMS-LIST%' => self::get_post_type_forms_list(),
|
64 |
-
'%POST-CREATE-FORM%' => $admin_url . 'admin.php?page=types-helper&action=new-form&type=' . self::$post_type->name,
|
65 |
-
'%POST-TYPE-EDIT-HAS-ARCHIVE%' => $admin_url . 'admin.php?page=wpcf-edit-type&wpcf-post-type=' . self::$post_type->name . '#types_options',
|
66 |
);
|
67 |
|
68 |
// Views specifics
|
@@ -73,11 +61,11 @@ class Types_Helper_Placeholder {
|
|
73 |
'%POST-VIEWS-ARCHIVE%' => Types_Helper_Condition_Views_Archive_Exists::get_template_name(),
|
74 |
'%POST-EDIT-VIEWS-ARCHIVE%' => self::get_post_edit_views_archive(),
|
75 |
'%POST-EDIT-CONTENT-TEMPLATE%' => self::get_post_edit_views_template(),
|
76 |
-
'%POST-CREATE-CONTENT-TEMPLATE%' => $admin_url . 'admin.php?page=types-helper&action=new-content-template&type='.self::$post_type->name,
|
77 |
-
'%POST-CREATE-VIEWS-ARCHIVE%' => $admin_url . 'admin.php?page=types-helper&action=new-wordpress-archive&type='.self::$post_type->name,
|
78 |
//'%POST-CREATE-VIEWS-ARCHIVE%' => self::get_post_create_views_archive(),
|
79 |
'%POST-VIEWS-LIST%' => self::get_post_type_views_list(),
|
80 |
-
'%POST-CREATE-VIEW%' => $admin_url . 'admin.php?page=types-helper&action=new-view&type='.self::$post_type->name,
|
81 |
) );
|
82 |
|
83 |
}
|
@@ -86,8 +74,8 @@ class Types_Helper_Placeholder {
|
|
86 |
if( defined( 'WPDDL_DEVELOPMENT' ) || defined( 'WPDDL_PRODUCTION' ) ) {
|
87 |
$placeholders = array_merge( $placeholders, array(
|
88 |
//'%POST-CREATE-LAYOUT-TEMPLATE%' => self::get_post_create_layout_template(),
|
89 |
-
'%POST-CREATE-LAYOUT-TEMPLATE%' => $admin_url . 'admin.php?page=types-helper&action=new-layout-template&type='.self::$post_type->name,
|
90 |
-
'%POST-CREATE-LAYOUT-ARCHIVE%' => self::get_post_create_layout_archive(),
|
91 |
'%POST-EDIT-LAYOUT-TEMPLATE%' => self::get_post_edit_layout_template(),
|
92 |
'%POST-EDIT-LAYOUT-ARCHIVE%' => self::get_post_edit_layout_archive(),
|
93 |
'%POST-LAYOUT-TEMPLATE%' => Types_Helper_Condition_Layouts_Template_Exists::get_layout_name(),
|
@@ -99,92 +87,73 @@ class Types_Helper_Placeholder {
|
|
99 |
}
|
100 |
|
101 |
private static function get_post_create_views_archive() {
|
102 |
-
|
103 |
-
$tool_admin_bar = Toolset_Admin_Bar_Menu::get_instance();
|
104 |
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
|
109 |
-
|
|
|
|
|
|
|
|
|
110 |
}
|
111 |
|
112 |
private static function get_post_edit_views_archive() {
|
113 |
-
|
114 |
-
self::$post_type_edit_views_archive =
|
115 |
-
admin_url() . 'admin.php?page=view-archives-editor&view_id='
|
116 |
. Types_Helper_Condition_Views_Archive_Exists::get_template_id();
|
117 |
-
|
118 |
-
return self
|
119 |
}
|
120 |
|
121 |
private static function get_post_create_layout_archive() {
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
|
|
126 |
|
127 |
-
return
|
128 |
}
|
129 |
|
130 |
private static function get_post_edit_layout_archive() {
|
131 |
-
|
132 |
-
self::$post_type_edit_layout_archive =
|
133 |
-
admin_url() . 'admin.php?page=dd_layouts_edit&action=edit&layout_id='
|
134 |
. Types_Helper_Condition_Layouts_Archive_Exists::get_layout_id();
|
135 |
-
}
|
136 |
|
137 |
-
return self
|
138 |
}
|
139 |
|
140 |
private static function get_post_edit_layout_template() {
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
. Types_Helper_Condition_Layouts_Template_Exists::get_layout_id();
|
145 |
-
}
|
146 |
-
|
147 |
-
return self::$post_type_edit_layout_template;
|
148 |
}
|
149 |
|
150 |
-
private static function
|
151 |
-
if(
|
152 |
-
|
153 |
-
admin_url() . 'admin.php?page=ct-editor&ct_id='
|
154 |
-
. Types_Helper_Condition_Views_Template_Exists::get_template_id();
|
155 |
-
}
|
156 |
|
157 |
-
return
|
158 |
}
|
159 |
|
160 |
private static function get_post_template_file() {
|
161 |
-
|
162 |
-
|
163 |
-
self::$post_type_template_file = basename( $helper->find_template() );
|
164 |
-
}
|
165 |
-
|
166 |
-
return self::$post_type_template_file;
|
167 |
}
|
168 |
|
169 |
private static function get_post_archive_file() {
|
170 |
-
|
171 |
-
|
172 |
-
self::$post_type_archive_file = basename( $helper->find_template() );
|
173 |
-
}
|
174 |
-
|
175 |
-
return self::$post_type_archive_file;
|
176 |
}
|
177 |
|
178 |
public static function get_permalink( $id = 0 ) {
|
179 |
-
if( self::$single_link !== null )
|
180 |
-
return self::$single_link;
|
181 |
-
|
182 |
$permalink = get_permalink( $id );
|
183 |
|
184 |
if( $permalink ) {
|
185 |
$query_args['preview'] = 'true';
|
186 |
$permalink = add_query_arg( $query_args, $permalink );
|
187 |
-
self::$single_link = $permalink;
|
188 |
return $permalink;
|
189 |
}
|
190 |
|
@@ -205,24 +174,17 @@ class Types_Helper_Placeholder {
|
|
205 |
return self::get_permalink( $query->posts[0]->ID );
|
206 |
}
|
207 |
|
208 |
-
|
209 |
-
return self::$single_link ;
|
210 |
}
|
211 |
|
212 |
public static function get_archive_permalink() {
|
213 |
-
if( self::$archive_link !== null )
|
214 |
-
return self::$archive_link;
|
215 |
-
|
216 |
// cpt edit page
|
217 |
if( isset( $_GET['wpcf-post-type'] ) ) {
|
218 |
$query = new WP_Query( 'post_type=' . $_GET['wpcf-post-type'] . '&post_status=publish&posts_per_page=1' );
|
219 |
-
if( $query->have_posts() )
|
220 |
-
|
221 |
-
return self::$archive_link;
|
222 |
-
}
|
223 |
|
224 |
-
|
225 |
-
return self::$archive_link;
|
226 |
}
|
227 |
|
228 |
if( ! is_object( self::$post_type ) )
|
@@ -230,12 +192,10 @@ class Types_Helper_Placeholder {
|
|
230 |
|
231 |
$query = new WP_Query( 'post_type=' . self::$post_type->name . '&post_status=publish&posts_per_page=1' );
|
232 |
if( $query->have_posts() ) {
|
233 |
-
|
234 |
-
return self::$archive_link;
|
235 |
}
|
236 |
|
237 |
-
|
238 |
-
return self::$archive_link;
|
239 |
}
|
240 |
|
241 |
private static function get_post_type_views_list() {
|
@@ -244,7 +204,7 @@ class Types_Helper_Placeholder {
|
|
244 |
$output = '<ul>';
|
245 |
foreach( $views as $view ) {
|
246 |
$view_edit_link = admin_url() . 'admin.php?page=views-editor&view_id=' . $view['id'];
|
247 |
-
$output .= '<li><a href="'. $view_edit_link . '">'. $view['name'].'</a></li>';
|
248 |
}
|
249 |
$output .= '</ul>';
|
250 |
|
@@ -259,8 +219,8 @@ class Types_Helper_Placeholder {
|
|
259 |
if( $forms = Types_Helper_Condition_Cred_Forms_Exist::get_forms_of_post_type() ) {
|
260 |
$output = '<ul>';
|
261 |
foreach( $forms as $form ) {
|
262 |
-
$
|
263 |
-
$output .= '<li><a href="'. $
|
264 |
}
|
265 |
$output .= '</ul>';
|
266 |
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Placeholder
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Placeholder {
|
9 |
|
10 |
private static $post_type;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
public static function set_post_type( $posttype = false ) {
|
13 |
|
49 |
'%POST-TEMPLATE-FILE%' => '<nobr>' . self::get_post_template_file() . '</nobr>',
|
50 |
'%POST-ARCHIVE-FILE%' => '<nobr>' . self::get_post_archive_file() . '</nobr>',
|
51 |
'%POST-FORMS-LIST%' => self::get_post_type_forms_list(),
|
52 |
+
'%POST-CREATE-FORM%' => self::add_referer( $admin_url . 'admin.php?page=types-helper&action=new-form&type=' . self::$post_type->name.'&toolset_help_video=cred_form' ),
|
53 |
+
'%POST-TYPE-EDIT-HAS-ARCHIVE%' => self::add_referer( $admin_url . 'admin.php?page=wpcf-edit-type&wpcf-post-type=' . self::$post_type->name . '#types_options' ),
|
54 |
);
|
55 |
|
56 |
// Views specifics
|
61 |
'%POST-VIEWS-ARCHIVE%' => Types_Helper_Condition_Views_Archive_Exists::get_template_name(),
|
62 |
'%POST-EDIT-VIEWS-ARCHIVE%' => self::get_post_edit_views_archive(),
|
63 |
'%POST-EDIT-CONTENT-TEMPLATE%' => self::get_post_edit_views_template(),
|
64 |
+
'%POST-CREATE-CONTENT-TEMPLATE%' => self::add_referer( $admin_url . 'admin.php?page=types-helper&action=new-content-template&type='.self::$post_type->name.'&toolset_help_video=views_template' ),
|
65 |
+
'%POST-CREATE-VIEWS-ARCHIVE%' => self::add_referer( $admin_url . 'admin.php?page=types-helper&action=new-wordpress-archive&type='.self::$post_type->name.'&toolset_help_video=views_archives' ),
|
66 |
//'%POST-CREATE-VIEWS-ARCHIVE%' => self::get_post_create_views_archive(),
|
67 |
'%POST-VIEWS-LIST%' => self::get_post_type_views_list(),
|
68 |
+
'%POST-CREATE-VIEW%' => self::add_referer( $admin_url . 'admin.php?page=types-helper&action=new-view&type='.self::$post_type->name.'&toolset_help_video=views_view' ),
|
69 |
) );
|
70 |
|
71 |
}
|
74 |
if( defined( 'WPDDL_DEVELOPMENT' ) || defined( 'WPDDL_PRODUCTION' ) ) {
|
75 |
$placeholders = array_merge( $placeholders, array(
|
76 |
//'%POST-CREATE-LAYOUT-TEMPLATE%' => self::get_post_create_layout_template(),
|
77 |
+
'%POST-CREATE-LAYOUT-TEMPLATE%' => self::add_referer( $admin_url . 'admin.php?page=types-helper&action=new-layout-template&type='.self::$post_type->name.'&toolset_help_video=layouts_template' ),
|
78 |
+
'%POST-CREATE-LAYOUT-ARCHIVE%' => self::add_referer( self::get_post_create_layout_archive() . '&toolset_help_video=layouts_archive' ),
|
79 |
'%POST-EDIT-LAYOUT-TEMPLATE%' => self::get_post_edit_layout_template(),
|
80 |
'%POST-EDIT-LAYOUT-ARCHIVE%' => self::get_post_edit_layout_archive(),
|
81 |
'%POST-LAYOUT-TEMPLATE%' => Types_Helper_Condition_Layouts_Template_Exists::get_layout_name(),
|
87 |
}
|
88 |
|
89 |
private static function get_post_create_views_archive() {
|
90 |
+
$tool_admin_bar = Toolset_Admin_Bar_Menu::get_instance();
|
|
|
91 |
|
92 |
+
$post_type = self::$post_type->name == 'post' ? 'home-blog' : self::$post_type->name;
|
93 |
+
return $tool_admin_bar->get_edit_link( 'views', true, $post_type, 'archive', 0 );
|
94 |
+
}
|
95 |
|
96 |
+
private static function get_post_edit_views_template() {
|
97 |
+
$url = admin_url() . 'admin.php?page=ct-editor&ct_id='
|
98 |
+
. Types_Helper_Condition_Views_Template_Exists::get_template_id();
|
99 |
+
|
100 |
+
return self::add_referer( $url );
|
101 |
}
|
102 |
|
103 |
private static function get_post_edit_views_archive() {
|
104 |
+
$url = admin_url() . 'admin.php?page=view-archives-editor&view_id='
|
|
|
|
|
105 |
. Types_Helper_Condition_Views_Archive_Exists::get_template_id();
|
106 |
+
|
107 |
+
return self::add_referer( $url );
|
108 |
}
|
109 |
|
110 |
private static function get_post_create_layout_archive() {
|
111 |
+
$tool_admin_bar = Toolset_Admin_Bar_Menu::get_instance();
|
112 |
+
|
113 |
+
// change name to 'home-blog' for build-in "Posts"
|
114 |
+
$post_type = self::$post_type->name == 'post'
|
115 |
+
? 'home-blog'
|
116 |
+
: self::$post_type->name;
|
117 |
|
118 |
+
return $tool_admin_bar->get_edit_link( 'layouts', true, $post_type, 'archive', 0 );
|
119 |
}
|
120 |
|
121 |
private static function get_post_edit_layout_archive() {
|
122 |
+
$url = admin_url() . 'admin.php?page=dd_layouts_edit&action=edit&layout_id='
|
|
|
|
|
123 |
. Types_Helper_Condition_Layouts_Archive_Exists::get_layout_id();
|
|
|
124 |
|
125 |
+
return self::add_referer( $url );
|
126 |
}
|
127 |
|
128 |
private static function get_post_edit_layout_template() {
|
129 |
+
$url = admin_url() . 'admin.php?page=dd_layouts_edit&action=edit&layout_id='
|
130 |
+
. Types_Helper_Condition_Layouts_Template_Exists::get_layout_id();
|
131 |
+
return self::add_referer( $url );
|
|
|
|
|
|
|
|
|
132 |
}
|
133 |
|
134 |
+
private static function add_referer( $url ) {
|
135 |
+
if( isset( $_GET['page'] ) && $_GET['page'] == 'toolset-dashboard' )
|
136 |
+
$url = add_query_arg( 'ref', 'dashboard', $url );
|
|
|
|
|
|
|
137 |
|
138 |
+
return $url;
|
139 |
}
|
140 |
|
141 |
private static function get_post_template_file() {
|
142 |
+
$helper = new Types_Helper_Condition_Single_Exists();
|
143 |
+
return basename( $helper->find_template() );
|
|
|
|
|
|
|
|
|
144 |
}
|
145 |
|
146 |
private static function get_post_archive_file() {
|
147 |
+
$helper = new Types_Helper_Condition_Archive_Exists();
|
148 |
+
return basename( $helper->find_template() );
|
|
|
|
|
|
|
|
|
149 |
}
|
150 |
|
151 |
public static function get_permalink( $id = 0 ) {
|
|
|
|
|
|
|
152 |
$permalink = get_permalink( $id );
|
153 |
|
154 |
if( $permalink ) {
|
155 |
$query_args['preview'] = 'true';
|
156 |
$permalink = add_query_arg( $query_args, $permalink );
|
|
|
157 |
return $permalink;
|
158 |
}
|
159 |
|
174 |
return self::get_permalink( $query->posts[0]->ID );
|
175 |
}
|
176 |
|
177 |
+
return false;
|
|
|
178 |
}
|
179 |
|
180 |
public static function get_archive_permalink() {
|
|
|
|
|
|
|
181 |
// cpt edit page
|
182 |
if( isset( $_GET['wpcf-post-type'] ) ) {
|
183 |
$query = new WP_Query( 'post_type=' . $_GET['wpcf-post-type'] . '&post_status=publish&posts_per_page=1' );
|
184 |
+
if( $query->have_posts() )
|
185 |
+
return get_post_type_archive_link( $_GET['wpcf-post-type'] );
|
|
|
|
|
186 |
|
187 |
+
return false;
|
|
|
188 |
}
|
189 |
|
190 |
if( ! is_object( self::$post_type ) )
|
192 |
|
193 |
$query = new WP_Query( 'post_type=' . self::$post_type->name . '&post_status=publish&posts_per_page=1' );
|
194 |
if( $query->have_posts() ) {
|
195 |
+
return get_post_type_archive_link( self::$post_type->name );
|
|
|
196 |
}
|
197 |
|
198 |
+
return false;
|
|
|
199 |
}
|
200 |
|
201 |
private static function get_post_type_views_list() {
|
204 |
$output = '<ul>';
|
205 |
foreach( $views as $view ) {
|
206 |
$view_edit_link = admin_url() . 'admin.php?page=views-editor&view_id=' . $view['id'];
|
207 |
+
$output .= '<li><a href="'. self::add_referer( $view_edit_link ) . '">'. $view['name'].'</a></li>';
|
208 |
}
|
209 |
$output .= '</ul>';
|
210 |
|
219 |
if( $forms = Types_Helper_Condition_Cred_Forms_Exist::get_forms_of_post_type() ) {
|
220 |
$output = '<ul>';
|
221 |
foreach( $forms as $form ) {
|
222 |
+
$form_edit_link = get_edit_post_link( $form['id'] );
|
223 |
+
$output .= '<li><a href="'. self::add_referer( $form_edit_link ) . '">'. $form['name'].'</a></li>';
|
224 |
}
|
225 |
$output .= '</ul>';
|
226 |
|
application/models/helper/twig.php
CHANGED
@@ -1,17 +1,33 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
4 |
class Types_Helper_Twig {
|
5 |
|
6 |
private $filesystem;
|
7 |
private $twig;
|
8 |
|
9 |
public function __construct() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
$this->filesystem = new Twig_Loader_Filesystem();
|
11 |
$this->filesystem->addPath( TYPES_ABSPATH . '/application/views' );
|
12 |
$this->twig = new Twig_Environment( $this->filesystem );
|
|
|
13 |
}
|
14 |
|
|
|
|
|
|
|
|
|
15 |
public function render( $file, $data ) {
|
16 |
if( $this->filesystem->exists( $file ) )
|
17 |
return $this->twig->render( $file, $data );
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Types_Helper_Twig
|
5 |
+
*
|
6 |
+
* @since 2.0
|
7 |
+
*/
|
8 |
class Types_Helper_Twig {
|
9 |
|
10 |
private $filesystem;
|
11 |
private $twig;
|
12 |
|
13 |
public function __construct() {
|
14 |
+
// backwards compatibility for php5.2
|
15 |
+
if ( ! defined( 'E_DEPRECATED' ) )
|
16 |
+
define( 'E_DEPRECATED', 8192 );
|
17 |
+
|
18 |
+
if ( ! defined( 'E_USER_DEPRECATED' ) )
|
19 |
+
define( 'E_USER_DEPRECATED', 16384 );
|
20 |
+
|
21 |
$this->filesystem = new Twig_Loader_Filesystem();
|
22 |
$this->filesystem->addPath( TYPES_ABSPATH . '/application/views' );
|
23 |
$this->twig = new Twig_Environment( $this->filesystem );
|
24 |
+
$this->twig->addFunction( '__', new Twig_SimpleFunction( '__', array( $this, 'translate' ) ) );
|
25 |
}
|
26 |
|
27 |
+
public function translate( $text, $domain = 'types' ) {
|
28 |
+
return __( $text, $domain );
|
29 |
+
}
|
30 |
+
|
31 |
public function render( $file, $data ) {
|
32 |
if( $this->filesystem->exists( $file ) )
|
33 |
return $this->twig->render( $file, $data );
|
application/models/helper/type_hinting.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
class Types_Helper_Type_Hinting {
|
5 |
-
|
6 |
-
/**
|
7 |
-
* As we don't have type hinting in good old 5.2.4 here a little helper
|
8 |
-
* If a string is given for $object, the method check if class exists and than do the type check.
|
9 |
-
*
|
10 |
-
* @param $object string|object
|
11 |
-
* @param $type
|
12 |
-
*
|
13 |
-
* @return false|object
|
14 |
-
*/
|
15 |
-
public static function valid( $object, $type ) {
|
16 |
-
if( ! is_object( $object ) ) {
|
17 |
-
if( ! class_exists( $object ) )
|
18 |
-
return false;
|
19 |
-
|
20 |
-
$object = new $object();
|
21 |
-
return self::valid( $object, $type );
|
22 |
-
}
|
23 |
-
|
24 |
-
// type hinting the old way
|
25 |
-
if( ! is_a( $object, $type ) )
|
26 |
-
return false;
|
27 |
-
|
28 |
-
return $object;
|
29 |
-
}
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
application/models/helper/url.php
CHANGED
@@ -1,10 +1,16 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
class
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
private static $utm_medium;
|
10 |
private static $utm_term;
|
@@ -12,6 +18,18 @@ class Types_Helper_Url {
|
|
12 |
|
13 |
private static $urls = array();
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
public static function set_medium( $medium = false ) {
|
16 |
if( $medium ) {
|
17 |
self::$utm_medium = $medium;
|
@@ -28,65 +46,145 @@ class Types_Helper_Url {
|
|
28 |
}
|
29 |
|
30 |
private static function get_medium() {
|
31 |
-
if( self::$utm_medium === null )
|
32 |
self::set_medium();
|
|
|
33 |
|
34 |
return self::$utm_medium;
|
35 |
}
|
36 |
|
37 |
public static function add_urls( $urls ) {
|
38 |
-
if( is_array( $urls ))
|
39 |
self::$urls = array_merge( self::$urls, $urls );
|
|
|
40 |
}
|
41 |
|
|
|
42 |
private static function apply_analytics_arguments_to_url( $url ) {
|
43 |
-
if( ! self::get_medium() )
|
44 |
return $url;
|
|
|
45 |
|
46 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
-
|
49 |
-
$
|
|
|
|
|
50 |
|
51 |
-
|
52 |
-
$url .= 'utm_source='.self::$utm_source
|
53 |
-
.'&utm_campaign='.self::$utm_campaign
|
54 |
-
.'&utm_medium='.self::$utm_medium
|
55 |
-
.'&utm_term='.self::$utm_term
|
56 |
-
.'&utm_content='.self::$utm_content;
|
57 |
|
58 |
-
if( isset( $url_parts['fragment'] ) && !empty( $url_parts['fragment'] ) )
|
59 |
-
$url .= '#' . $url_parts['fragment'];
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
return $url;
|
62 |
}
|
63 |
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
return '';
|
|
|
|
|
|
|
67 |
|
68 |
-
$url
|
|
|
|
|
69 |
|
70 |
// return url if no arguments
|
71 |
-
if( ! $utm_content )
|
72 |
return $url;
|
|
|
73 |
|
74 |
// add utm content
|
75 |
self::$utm_content = $utm_content;
|
76 |
|
77 |
// use key for term, if no term isset
|
78 |
-
if( ! $utm_term )
|
79 |
$utm_term = $key;
|
|
|
80 |
|
81 |
self::$utm_term = $utm_term;
|
82 |
|
83 |
// apply medium only if medium isset
|
84 |
-
if( $utm_medium )
|
85 |
self::set_medium( $utm_medium );
|
|
|
86 |
|
87 |
// apply arguments
|
88 |
$url = self::apply_analytics_arguments_to_url( $url );
|
|
|
89 |
return $url;
|
90 |
|
91 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Helper class for building external links to documentation and elsewhere.
|
5 |
+
*
|
6 |
+
* Note that URLs first need to be loaded before you can use self::get_url().
|
7 |
+
*
|
8 |
+
* @since 2.0
|
9 |
+
*/
|
10 |
+
final class Types_Helper_Url {
|
11 |
+
|
12 |
+
const UTM_SOURCE = 'typesplugin';
|
13 |
+
const UTM_CAMPAIGN = 'types';
|
14 |
|
15 |
private static $utm_medium;
|
16 |
private static $utm_term;
|
18 |
|
19 |
private static $urls = array();
|
20 |
|
21 |
+
const ARG_SITE_URL = 'otgs-client-from-types';
|
22 |
+
const WP_TYPES_DOMAIN = 'wp-types.com';
|
23 |
+
|
24 |
+
|
25 |
+
// All values for utm_medium should be eventually defined here
|
26 |
+
const UTM_MEDIUM_HELP = 'help';
|
27 |
+
const UTM_MEDIUM_POSTEDIT = 'postedit';
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @param bool|string $medium
|
32 |
+
*/
|
33 |
public static function set_medium( $medium = false ) {
|
34 |
if( $medium ) {
|
35 |
self::$utm_medium = $medium;
|
46 |
}
|
47 |
|
48 |
private static function get_medium() {
|
49 |
+
if( self::$utm_medium === null ) {
|
50 |
self::set_medium();
|
51 |
+
}
|
52 |
|
53 |
return self::$utm_medium;
|
54 |
}
|
55 |
|
56 |
public static function add_urls( $urls ) {
|
57 |
+
if( is_array( $urls ) ) {
|
58 |
self::$urls = array_merge( self::$urls, $urls );
|
59 |
+
}
|
60 |
}
|
61 |
|
62 |
+
|
63 |
private static function apply_analytics_arguments_to_url( $url ) {
|
64 |
+
if( ! self::get_medium() ) {
|
65 |
return $url;
|
66 |
+
}
|
67 |
|
68 |
+
$args = array(
|
69 |
+
'utm_source' => self::UTM_SOURCE,
|
70 |
+
'utm_campaign' => self::UTM_CAMPAIGN,
|
71 |
+
'utm_medium' => self::$utm_medium,
|
72 |
+
'utm_term' => self::$utm_term
|
73 |
+
);
|
74 |
+
|
75 |
+
// This can === true, in which case we'll skip it, see self::get_url().
|
76 |
+
if( is_string( self::$utm_content ) ) {
|
77 |
+
$args['utm_content'] = self::$utm_content;
|
78 |
+
}
|
79 |
|
80 |
+
return add_query_arg(
|
81 |
+
$args,
|
82 |
+
$url
|
83 |
+
);
|
84 |
|
85 |
+
}
|
|
|
|
|
|
|
|
|
|
|
86 |
|
|
|
|
|
87 |
|
88 |
+
/**
|
89 |
+
* Add site's URL as an URL argument.
|
90 |
+
*
|
91 |
+
* @param string $url Source URL
|
92 |
+
* @param null|string $arg_name Name of the argument. Optional, defaults to ARG_SITE_URL.
|
93 |
+
* @return string
|
94 |
+
* @since 2.1
|
95 |
+
*/
|
96 |
+
private static function add_site_url_as_arg( $url, $arg_name = null ) {
|
97 |
+
if( is_string( $url ) ) {
|
98 |
+
if( !is_string( $arg_name ) || empty( $arg_name ) ) {
|
99 |
+
$arg_name = self::ARG_SITE_URL;
|
100 |
+
}
|
101 |
+
$url = add_query_arg( $arg_name, get_site_url(), $url );
|
102 |
+
}
|
103 |
return $url;
|
104 |
}
|
105 |
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Determines whether an URL points to the wp-types.com domain.
|
109 |
+
*
|
110 |
+
* @param string $url
|
111 |
+
* @return bool
|
112 |
+
* @since 2.1
|
113 |
+
*/
|
114 |
+
private static function is_link_to_wptypes( $url ) {
|
115 |
+
$url_parts = parse_url( $url );
|
116 |
+
return ( wpcf_getarr( $url_parts, 'host') == self::WP_TYPES_DOMAIN );
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Retrieve the URL with additional arguments.
|
122 |
+
*
|
123 |
+
* @param string $key URL key as defined in self::add_urls().
|
124 |
+
* @param bool|string $utm_content This is a bit more complex than we wanted:
|
125 |
+
* - false will skip *all* analytics arguments (default).
|
126 |
+
* - true will continue with adding the analytics arguments but omit the utm_content one
|
127 |
+
* - If a string is provided, it will be added as utm_content.
|
128 |
+
* @param bool|string $utm_term utm_term argument or false if $key should be used instead.
|
129 |
+
* @param bool|string $utm_medium utm_medium (to be set globally) or false to use a previously set value.
|
130 |
+
* @param bool $add_site_url If this is true and the URL points to wp-types.com, an additional argument with current
|
131 |
+
* site's URL will be added.
|
132 |
+
*
|
133 |
+
* @return mixed|string The URL or an empty string if the key was invalid.
|
134 |
+
* @since 2.0
|
135 |
+
*/
|
136 |
+
public static function get_url( $key, $utm_content = false, $utm_term = false, $utm_medium = false, $add_site_url = true ) {
|
137 |
+
if( !isset( self::$urls[ $key ] ) ) {
|
138 |
return '';
|
139 |
+
}
|
140 |
+
|
141 |
+
$url = self::$urls[ $key ];
|
142 |
|
143 |
+
if( self::is_link_to_wptypes( $url ) && $add_site_url ) {
|
144 |
+
$url = self::add_site_url_as_arg( $url );
|
145 |
+
}
|
146 |
|
147 |
// return url if no arguments
|
148 |
+
if( ! $utm_content ) {
|
149 |
return $url;
|
150 |
+
}
|
151 |
|
152 |
// add utm content
|
153 |
self::$utm_content = $utm_content;
|
154 |
|
155 |
// use key for term, if no term isset
|
156 |
+
if( ! $utm_term ) {
|
157 |
$utm_term = $key;
|
158 |
+
}
|
159 |
|
160 |
self::$utm_term = $utm_term;
|
161 |
|
162 |
// apply medium only if medium isset
|
163 |
+
if( $utm_medium ) {
|
164 |
self::set_medium( $utm_medium );
|
165 |
+
}
|
166 |
|
167 |
// apply arguments
|
168 |
$url = self::apply_analytics_arguments_to_url( $url );
|
169 |
+
|
170 |
return $url;
|
171 |
|
172 |
}
|
173 |
+
|
174 |
+
|
175 |
+
private static $documentation_urls_loaded = false;
|
176 |
+
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Load URLs to documentation links so they can be obtained via get_url().
|
180 |
+
*
|
181 |
+
* @since 2.1
|
182 |
+
*/
|
183 |
+
public static function load_documentation_urls() {
|
184 |
+
if( ! self::$documentation_urls_loaded ) {
|
185 |
+
$documentation_urls = include( TYPES_DATA . '/documentation-urls.php' );
|
186 |
+
Types_Helper_Url::add_urls( $documentation_urls );
|
187 |
+
self::$documentation_urls_loaded = true;
|
188 |
+
}
|
189 |
+
}
|
190 |
}
|
application/models/information/container.php
CHANGED
@@ -23,9 +23,8 @@ class Types_Information_Container {
|
|
23 |
}
|
24 |
|
25 |
// add message
|
26 |
-
public function add_message( $message ) {
|
27 |
-
|
28 |
-
$this->messages[] = $message;
|
29 |
}
|
30 |
|
31 |
public function get_messages() {
|
23 |
}
|
24 |
|
25 |
// add message
|
26 |
+
public function add_message( Types_Information_Message $message ) {
|
27 |
+
$this->messages[] = $message;
|
|
|
28 |
}
|
29 |
|
30 |
public function get_messages() {
|
application/models/information/message.php
CHANGED
@@ -34,6 +34,9 @@ class Types_Information_Message {
|
|
34 |
case 'archive':
|
35 |
case 'views':
|
36 |
case 'forms':
|
|
|
|
|
|
|
37 |
$this->type = $type;
|
38 |
break;
|
39 |
}
|
@@ -56,6 +59,7 @@ class Types_Information_Message {
|
|
56 |
|
57 |
if( is_array( $conditions ) ) {
|
58 |
foreach( $conditions as $condition ) {
|
|
|
59 |
$this->add_condition( $condition );
|
60 |
}
|
61 |
} else {
|
@@ -71,9 +75,8 @@ class Types_Information_Message {
|
|
71 |
*
|
72 |
* @return bool
|
73 |
*/
|
74 |
-
public function add_condition( $condition ) {
|
75 |
-
|
76 |
-
$this->conditions[] = $condition;
|
77 |
|
78 |
return $this;
|
79 |
}
|
@@ -121,8 +124,21 @@ class Types_Information_Message {
|
|
121 |
return;
|
122 |
}
|
123 |
|
124 |
-
|
|
|
125 |
foreach( $description as &$element ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
if( isset( $element['target'] ) ) {
|
127 |
switch( $element['target'] ) {
|
128 |
case '%POST-PERMALINK%':
|
@@ -133,6 +149,7 @@ class Types_Information_Message {
|
|
133 |
break;
|
134 |
}
|
135 |
}
|
|
|
136 |
|
137 |
}
|
138 |
|
@@ -186,7 +203,6 @@ class Types_Information_Message {
|
|
186 |
* true for $target[] = $link
|
187 |
*/
|
188 |
protected function add_link( &$target, $link, $in_array = false ) {
|
189 |
-
|
190 |
if( isset( $link['label'] ) && isset( $link['link'] ) ) {
|
191 |
$add = array(
|
192 |
'label' => $link['label'],
|
34 |
case 'archive':
|
35 |
case 'views':
|
36 |
case 'forms':
|
37 |
+
case 'type':
|
38 |
+
case 'fields':
|
39 |
+
case 'taxonomies':
|
40 |
$this->type = $type;
|
41 |
break;
|
42 |
}
|
59 |
|
60 |
if( is_array( $conditions ) ) {
|
61 |
foreach( $conditions as $condition ) {
|
62 |
+
$condition = new $condition();
|
63 |
$this->add_condition( $condition );
|
64 |
}
|
65 |
} else {
|
75 |
*
|
76 |
* @return bool
|
77 |
*/
|
78 |
+
public function add_condition( Types_Helper_Condition $condition ) {
|
79 |
+
$this->conditions[] = $condition;
|
|
|
80 |
|
81 |
return $this;
|
82 |
}
|
124 |
return;
|
125 |
}
|
126 |
|
127 |
+
$on_post_edit_screen = isset( $_GET['post'] ) ? true : false;
|
128 |
+
|
129 |
foreach( $description as &$element ) {
|
130 |
+
// apply correct label
|
131 |
+
if( isset( $element['label'] )
|
132 |
+
&& is_array( $element['label'] )
|
133 |
+
&& array_key_exists( 'default', $element['label'] )
|
134 |
+
&& array_key_exists( 'post-edit', $element['label'] )
|
135 |
+
) {
|
136 |
+
$element['label'] = $on_post_edit_screen
|
137 |
+
? $element['label']['post-edit']
|
138 |
+
: $element['label']['default'];
|
139 |
+
}
|
140 |
+
|
141 |
+
// todo Remove once placeholder replace comes before Twig rendering
|
142 |
if( isset( $element['target'] ) ) {
|
143 |
switch( $element['target'] ) {
|
144 |
case '%POST-PERMALINK%':
|
149 |
break;
|
150 |
}
|
151 |
}
|
152 |
+
// end remove
|
153 |
|
154 |
}
|
155 |
|
203 |
* true for $target[] = $link
|
204 |
*/
|
205 |
protected function add_link( &$target, $link, $in_array = false ) {
|
|
|
206 |
if( isset( $link['label'] ) && isset( $link['link'] ) ) {
|
207 |
$add = array(
|
208 |
'label' => $link['label'],
|
application/models/information/message/post_type.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
* unused class
|
5 |
+
*/
|
6 |
+
class Types_Information_Message_Post_Type extends Types_Information_Message {
|
7 |
+
|
8 |
+
private $post_type;
|
9 |
+
|
10 |
+
// dependency injection for post type
|
11 |
+
public function __construct( Types_Post_Type $post_type ) {
|
12 |
+
$this->post_type = $post_type;
|
13 |
+
}
|
14 |
+
|
15 |
+
}
|
application/models/information/table.php
CHANGED
@@ -13,10 +13,7 @@ class Types_Information_Table extends Types_Information_Container {
|
|
13 |
*
|
14 |
* @return bool
|
15 |
*/
|
16 |
-
public function add_message( $message ) {
|
17 |
-
if( ! $message = Types_Helper_Type_Hinting::valid( $message, 'Types_Information_Message' ) )
|
18 |
-
return false;
|
19 |
-
|
20 |
if( $message->get_type() )
|
21 |
switch( $message->get_type() ) {
|
22 |
case 'template':
|
@@ -38,14 +35,28 @@ class Types_Information_Table extends Types_Information_Container {
|
|
38 |
}
|
39 |
}
|
40 |
|
41 |
-
public function get_template() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
return $this->template;
|
43 |
}
|
44 |
|
45 |
-
public function get_archive() {
|
46 |
$post_type = Types_Helper_Condition::get_post_type();
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
return $this->archive;
|
51 |
}
|
13 |
*
|
14 |
* @return bool
|
15 |
*/
|
16 |
+
public function add_message( Types_Information_Message $message ) {
|
|
|
|
|
|
|
17 |
if( $message->get_type() )
|
18 |
switch( $message->get_type() ) {
|
19 |
case 'template':
|
35 |
}
|
36 |
}
|
37 |
|
38 |
+
public function get_template( $force = false ) {
|
39 |
+
$post_type = Types_Helper_Condition::get_post_type();
|
40 |
+
|
41 |
+
if( ! $force ) {
|
42 |
+
$allowed_columns = apply_filters( 'types_information_table_columns', array_fill_keys( array( 'template', 'archive', 'views', 'forms' ), '' ), $post_type->name );
|
43 |
+
|
44 |
+
if( ! isset( $allowed_columns['template'] ) )
|
45 |
+
return false;
|
46 |
+
}
|
47 |
+
|
48 |
return $this->template;
|
49 |
}
|
50 |
|
51 |
+
public function get_archive( $force = false ) {
|
52 |
$post_type = Types_Helper_Condition::get_post_type();
|
53 |
+
|
54 |
+
if( ! $force ) {
|
55 |
+
$allowed_columns = apply_filters( 'types_information_table_columns', array_fill_keys( array( 'template', 'archive', 'views', 'forms' ), '' ), $post_type->name );
|
56 |
+
|
57 |
+
if( ! isset( $allowed_columns['archive'] ) )
|
58 |
+
return false;
|
59 |
+
}
|
60 |
|
61 |
return $this->archive;
|
62 |
}
|
application/models/post_type.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Types_Post_Type {
|
4 |
+
|
5 |
+
protected $wp_post_type;
|
6 |
+
|
7 |
+
protected $name;
|
8 |
+
|
9 |
+
protected $field_groups;
|
10 |
+
protected $taxonomies;
|
11 |
+
|
12 |
+
public function __construct( $post_type ) {
|
13 |
+
if( is_object( $post_type ) && isset( $post_type->name ) ) {
|
14 |
+
$this->wp_post_type = $post_type;
|
15 |
+
$this->name = $post_type->name;
|
16 |
+
} else {
|
17 |
+
$this->name = $post_type;
|
18 |
+
$registered = get_post_type_object( $post_type );
|
19 |
+
|
20 |
+
if( $registered )
|
21 |
+
$this->wp_post_type = $registered;
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
public function __isset( $property ) {
|
26 |
+
if( $this->wp_post_type === null )
|
27 |
+
return false;
|
28 |
+
|
29 |
+
if( ! property_exists( $this->wp_post_type, 'labels' ) )
|
30 |
+
return false;
|
31 |
+
|
32 |
+
if( ! property_exists( $this->wp_post_type->labels, $property ) )
|
33 |
+
return false;
|
34 |
+
|
35 |
+
return true;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function __get( $property ) {
|
39 |
+
if( ! $this->__isset( $property ) )
|
40 |
+
return false;
|
41 |
+
|
42 |
+
return $this->wp_post_type->labels->$property;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function get_name() {
|
46 |
+
return $this->name;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Get the backend edit link.
|
51 |
+
*
|
52 |
+
* @return string
|
53 |
+
* @since 2.1
|
54 |
+
*/
|
55 |
+
public function get_edit_link() {
|
56 |
+
return admin_url() . 'admin.php?page=wpcf-edit-type&wpcf-post-type=' . $this->get_name();
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Register Post Type
|
61 |
+
*/
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Assigned Field Groups
|
65 |
+
*/
|
66 |
+
private function fetch_field_groups() {
|
67 |
+
global $wpdb;
|
68 |
+
$sql = 'SELECT post_id FROM ' .$wpdb->postmeta . '
|
69 |
+
WHERE meta_key="_wp_types_group_post_types"
|
70 |
+
AND (meta_value LIKE "%' . $this->name . '%" OR meta_value="all" OR meta_value REGEXP "^[,]+$")
|
71 |
+
ORDER BY post_id ASC';
|
72 |
+
$post_ids = $wpdb->get_col( $sql );
|
73 |
+
|
74 |
+
$this->field_groups = array();
|
75 |
+
foreach( $post_ids as $id ) {
|
76 |
+
$field_group = Types_Field_Group_Post_Factory::load( $id );
|
77 |
+
|
78 |
+
if( $field_group )
|
79 |
+
$this->field_groups[] = $field_group;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
|
83 |
+
public function get_field_groups() {
|
84 |
+
if( $this->field_groups == null )
|
85 |
+
$this->fetch_field_groups();
|
86 |
+
|
87 |
+
return $this->field_groups;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Assigned Taxonomies
|
92 |
+
*/
|
93 |
+
private function fetch_taxonomies() {
|
94 |
+
$taxonomies = array();
|
95 |
+
$all_taxonomies = get_taxonomies( '', 'objects' );
|
96 |
+
|
97 |
+
foreach( $all_taxonomies as $tax ) {
|
98 |
+
if( in_array( $this->get_name(), $tax->object_type ) )
|
99 |
+
$taxonomies[] = new Types_Taxonomy( $tax );
|
100 |
+
}
|
101 |
+
|
102 |
+
$this->taxonomies = $taxonomies;
|
103 |
+
}
|
104 |
+
|
105 |
+
public function get_taxonomies() {
|
106 |
+
if( $this->taxonomies == null )
|
107 |
+
$this->fetch_taxonomies();
|
108 |
+
|
109 |
+
return $this->taxonomies;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Assigned Templates
|
114 |
+
*/
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Assigned Archives
|
118 |
+
*/
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Assigned Views
|
122 |
+
*/
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Assigned Forms
|
126 |
+
*/
|
127 |
+
}
|
application/models/setting.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Types_Setting
|
5 |
+
*
|
6 |
+
* @since 2.1
|
7 |
+
*/
|
8 |
+
class Types_Setting implements Types_Setting_Interface {
|
9 |
+
|
10 |
+
private $id;
|
11 |
+
private $options = array();
|
12 |
+
|
13 |
+
public function __construct( $id ) {
|
14 |
+
$this->id = $id;
|
15 |
+
}
|
16 |
+
|
17 |
+
public function get_id() {
|
18 |
+
return $this->id;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function add_option( Types_Setting_Option_Interface $option ) {
|
22 |
+
$this->options[$option->get_id()] = $option;
|
23 |
+
}
|
24 |
+
|
25 |
+
public function get_options() {
|
26 |
+
return $this->options;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function get_value( $option_id ) {
|
30 |
+
return $this->options[$option_id]->get_stored_value( $this );
|
31 |
+
}
|
32 |
+
|
33 |
+
public function checked( $value, $option_id ) {
|
34 |
+
return checked( $value == $this->get_value( $option_id ), true, false );
|
35 |
+
}
|
36 |
+
}
|
application/models/setting/boolean.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Types_Setting_Boolean
|
5 |
+
*
|
6 |
+
* @since 2.1
|
7 |
+
*/
|
8 |
+
class Types_Setting_Boolean extends Types_Setting {
|
9 |
+
public function get_value( $option_id ) {
|
10 |
+
$value = parent::get_value( $option_id );
|
11 |
+
$value =
|
12 |
+
$value === null
|
13 |
+
|| $value === false
|
14 |
+
|| $value === 0
|
15 |
+
|| $value === '0'
|
16 |
+
|| $value === 'off'
|
17 |
+
|| $value === 'false'
|
18 |
+
|| $value === 'disabled'
|
19 |
+
? false
|
20 |
+
: true;
|
21 |
+
|
22 |
+
return $value;
|
23 |
+
}
|
24 |
+
}
|
application/models/setting/interface.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Interface Types_Setting_Interface
|
5 |
+
*
|
6 |
+
* @since 2.1
|
7 |
+
*/
|
8 |
+
interface Types_Setting_Interface {
|
9 |
+
public function __construct( $id );
|
10 |
+
public function get_id();
|
11 |
+
|
12 |
+
public function add_option( Types_Setting_Option_Interface $option );
|
13 |
+
public function get_options();
|
14 |
+
|
15 |
+
public function get_value( $option_id );
|
16 |
+
}
|
application/models/setting/option.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Types_Setting_Option
|
5 |
+
*
|
6 |
+
* @since 2.1
|
7 |
+
*/
|
8 |
+
class Types_Setting_Option implements Types_Setting_Option_Interface {
|
9 |
+
|
10 |
+
protected $id;
|
11 |
+
protected $description;
|
12 |
+
protected $value;
|
13 |
+
protected $stored_value;
|
14 |
+
protected $default = false;
|
15 |
+
|
16 |
+
public function __construct( $id ) {
|
17 |
+
$this->id = $id;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function get_id() {
|
21 |
+
return $this->id;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function set_default( $default ) {
|
25 |
+
$this->default = $default;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function get_value() {
|
29 |
+
if( $this->value === null )
|
30 |
+
$this->value = 1;
|
31 |
+
|
32 |
+
return $this->value;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function get_stored_value( Types_Setting_Interface $setting ) {
|
36 |
+
if( $this->stored_value === null ) {
|
37 |
+
if( class_exists( 'Toolset_Settings' )
|
38 |
+
&& method_exists( 'Toolset_Settings', 'get_instance' )
|
39 |
+
) {
|
40 |
+
$toolset_settings = Toolset_Settings::get_instance();
|
41 |
+
$full_setting = $toolset_settings->get( $setting->get_id() );
|
42 |
+
} else {
|
43 |
+
$full_setting = get_option( $setting->get_id() );
|
44 |
+
}
|
45 |
+
|
46 |
+
$value = isset( $full_setting[$this->get_id()] )
|
47 |
+
? $full_setting[$this->get_id()]
|
48 |
+
: $this->default;
|
49 |
+
|
50 |
+
$this->stored_value = $value;
|
51 |
+
}
|
52 |
+
|
53 |
+
return $this->stored_value;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function set_description( $description ) {
|
57 |
+
$this->description = $description;
|
58 |
+
}
|
59 |
+
|
60 |
+
public function get_description() {
|
61 |
+
return $this->description;
|
62 |
+
}
|
63 |
+
}
|
application/models/setting/option/interface.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Interface Types_Setting_Option_Interface
|
5 |
+
*
|
6 |
+
* @since 2.1
|
7 |
+
*/
|
8 |
+
interface Types_Setting_Option_Interface {
|
9 |
+
public function __construct( $id );
|
10 |
+
public function get_id();
|
11 |
+
public function get_value();
|
12 |
+
public function set_description( $description );
|
13 |
+
public function get_description();
|
14 |
+
}
|
application/models/setting/preset/information_table.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Types_Setting_Preset_Information_Table {
|
5 |
+
|
6 |
+
private $setting;
|
7 |
+
|
8 |
+
public function __construct() {
|
9 |
+
$this->setting = new Types_Setting_Boolean( 'types-information-table' );
|
10 |
+
|
11 |
+
$option_edit_post = new Types_Setting_Option( 'show-on-post' );
|
12 |
+
$option_edit_post->set_description( __( 'Edit Post pages', 'types' ) );
|
13 |
+
$option_edit_post->set_default( true );
|
14 |
+
|
15 |
+
$option_edit_post_type = new Types_Setting_Option( 'show-on-post-type' );
|
16 |
+
$option_edit_post_type->set_description( __( 'Edit Post Type pages', 'types' ) );
|
17 |
+
$option_edit_post_type->set_default( true );
|
18 |
+
|
19 |
+
$option_edit_field_group = new Types_Setting_Option( 'show-on-field-group' );
|
20 |
+
$option_edit_field_group->set_description( __( 'Edit Field Group pages', 'types' ) );
|
21 |
+
$option_edit_field_group->set_default( true );
|
22 |
+
|
23 |
+
$this->setting->add_option( $option_edit_post );
|
24 |
+
$this->setting->add_option( $option_edit_post_type );
|
25 |
+
$this->setting->add_option( $option_edit_field_group );
|
26 |
+
}
|
27 |
+
|
28 |
+
public function __call( $name, $arguments ) {
|
29 |
+
if( empty( $arguments ) )
|
30 |
+
return call_user_func( array( $this->setting, $name ) );
|
31 |
+
|
32 |
+
return call_user_func_array( array( $this->setting, $name ), $arguments );
|
33 |
+
}
|
34 |
+
}
|
application/models/taxonomy.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Types_Taxonomy {
|
4 |
+
|
5 |
+
protected $wp_taxonomy;
|
6 |
+
|
7 |
+
protected $name;
|
8 |
+
|
9 |
+
public function __construct( $taxonomy ) {
|
10 |
+
if( is_object( $taxonomy ) && isset( $taxonomy->name ) ) {
|
11 |
+
$this->wp_taxonomy = $taxonomy;
|
12 |
+
$this->name = $taxonomy->name;
|
13 |
+
} else {
|
14 |
+
$this->name = $taxonomy;
|
15 |
+
$registered = get_post_type_object( $taxonomy );
|
16 |
+
|
17 |
+
if( $registered )
|
18 |
+
$this->wp_taxonomy = $registered;
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
public function __isset( $property ) {
|
23 |
+
if( $this->wp_taxonomy === null )
|
24 |
+
return false;
|
25 |
+
|
26 |
+
if( ! property_exists( $this->wp_taxonomy, 'labels' ) )
|
27 |
+
return false;
|
28 |
+
|
29 |
+
if( ! property_exists( $this->wp_taxonomy->labels, $property ) )
|
30 |
+
return false;
|
31 |
+
|
32 |
+
return true;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function __get( $property ) {
|
36 |
+
if( ! $this->__isset( $property ) )
|
37 |
+
return false;
|
38 |
+
|
39 |
+
return $this->wp_taxonomy->labels->$property;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function get_name() {
|
43 |
+
return $this->name;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Get the backend edit link.
|
48 |
+
*
|
49 |
+
* @return string
|
50 |
+
* @since 2.1
|
51 |
+
*/
|
52 |
+
public function get_edit_link() {
|
53 |
+
return admin_url() . 'admin.php?page=wpcf-edit-tax&wpcf-tax=' . $this->get_name();
|
54 |
+
}
|
55 |
+
}
|
application/views/information/table.twig
CHANGED
@@ -12,11 +12,13 @@
|
|
12 |
</thead>
|
13 |
<tbody>
|
14 |
<tr>
|
|
|
15 |
<td>
|
16 |
{% for information in table.get_template() %}
|
17 |
{% include 'information/table/tbody-cell.twig' %}
|
18 |
{% endfor %}
|
19 |
</td>
|
|
|
20 |
{% if table.get_archive() %}
|
21 |
<td>
|
22 |
{% for information in table.get_archive() %}
|
12 |
</thead>
|
13 |
<tbody>
|
14 |
<tr>
|
15 |
+
{% if table.get_template() %}
|
16 |
<td>
|
17 |
{% for information in table.get_template() %}
|
18 |
{% include 'information/table/tbody-cell.twig' %}
|
19 |
{% endfor %}
|
20 |
</td>
|
21 |
+
{% endif %}
|
22 |
{% if table.get_archive() %}
|
23 |
<td>
|
24 |
{% for information in table.get_archive() %}
|
application/views/page/dashboard/help.twig
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<p>
|
2 |
+
{{ __( 'This is the main Toolset Dashboard page. The table below provides you with an overview of content types and Toolset components in your site. It also displays the links between all the elements.', 'types' ) }}
|
3 |
+
</p>
|
4 |
+
|
5 |
+
<p>
|
6 |
+
{{ __( 'The table has two parts:', 'types' ) }}
|
7 |
+
</p>
|
8 |
+
|
9 |
+
<ul>
|
10 |
+
<li>{{ __( '<b>WordPress admin</b> lists all of the content types and their relations: Post Types, Fields and Taxonomies.', 'types' )|raw }}</li>
|
11 |
+
<li>{{ __( '<b>Front-end</b> lists all of the Toolset elements you have and the content they are used for: Content Templates, WordPress Archives, Views and Forms.', 'types' )|raw }}</li>
|
12 |
+
</ul>
|
13 |
+
|
14 |
+
<p>
|
15 |
+
{{ __( 'The buttons in the table provide shortcuts to create specific content types or Toolset components.', 'types' ) }}
|
16 |
+
</p>
|
application/views/page/dashboard/main.twig
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{% extends "page/base.twig" %}
|
2 |
+
|
3 |
+
{% block title %}{{ page.get_title() }}{% endblock %}
|
4 |
+
|
5 |
+
{% block content %}
|
6 |
+
<div class="toolset-dashboard">
|
7 |
+
{% if table %}
|
8 |
+
{{ table|raw }}
|
9 |
+
{% else %}
|
10 |
+
<p>{{ labels.msg_no_custom_post_types }}</p>
|
11 |
+
{% endif %}
|
12 |
+
|
13 |
+
|
14 |
+
{# Add new post type #}
|
15 |
+
<p>
|
16 |
+
<a class="button-primary types-button" href="{{ admin_url }}admin.php?page=wpcf-edit-type">{{ labels.create_type }}</a>
|
17 |
+
</p>
|
18 |
+
</div>
|
19 |
+
{% endblock %}
|
20 |
+
|
application/views/page/dashboard/table.twig
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<div class="types-information">
|
3 |
+
<table width="100%">
|
4 |
+
<thead>
|
5 |
+
<tr>
|
6 |
+
<th colspan="3">
|
7 |
+
{{ labels.admin }}
|
8 |
+
</th>
|
9 |
+
<th colspan="4">
|
10 |
+
{{ labels.frontend }}
|
11 |
+
</th>
|
12 |
+
</tr>
|
13 |
+
<tr>
|
14 |
+
{% for content in thead %}
|
15 |
+
<th width="{{ 100 / thead|length }}%">
|
16 |
+
{% include 'page/dashboard/table/thead-cell.twig' %}
|
17 |
+
</th>
|
18 |
+
{% endfor %}
|
19 |
+
</tr>
|
20 |
+
</thead>
|
21 |
+
<tbody>
|
22 |
+
{{ rows|raw }}
|
23 |
+
</tbody>
|
24 |
+
</table>
|
25 |
+
</div>
|
26 |
+
|
27 |
+
|
28 |
+
|
29 |
+
|
application/views/page/dashboard/table/tbody-cell.twig
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="types-information-td-inner {% if information.priority %} types-information-{{ information.priority }}{% endif %}">
|
2 |
+
|
3 |
+
{% for description in information.description %}
|
4 |
+
{% if description.type %}
|
5 |
+
{% include 'information/description/' ~ description.type ~ '.twig' %}
|
6 |
+
{% endif %}
|
7 |
+
{% endfor %}
|
8 |
+
|
9 |
+
</div>
|
application/views/page/dashboard/table/tbody-row.twig
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<tr>
|
2 |
+
<td>
|
3 |
+
<div class="types-information-td-inner">
|
4 |
+
<p class="types-information-paragraph toolset-dashboard-post-type"><a href="{{ post_type.get_edit_link }}">{{ post_type.name }}</a></p>
|
5 |
+
</div>
|
6 |
+
</td>
|
7 |
+
<td>
|
8 |
+
<div class="types-information-td-inner">
|
9 |
+
<ul>
|
10 |
+
{% for field_group in post_type.get_field_groups() %}
|
11 |
+
<li><a href="{{ field_group.get_edit_link }}&ref=dashboard">{{ field_group.get_display_name() }}</a></li>
|
12 |
+
{% endfor %}
|
13 |
+
</ul>
|
14 |
+
|
15 |
+
<p class="types-information-link">
|
16 |
+
<a class="button" href="{{ admin_url }}admin.php?page=types-helper&action=new-post-field-group&type={{ post_type.get_name() }}&ref=dashboard">{{ labels.create_field_group }}</a>
|
17 |
+
</p>
|
18 |
+
</div>
|
19 |
+
</td>
|
20 |
+
<td>
|
21 |
+
<div class="types-information-td-inner">
|
22 |
+
<ul>
|
23 |
+
{% for taxonomy in post_type.get_taxonomies() %}
|
24 |
+
<li><a href="{{ taxonomy.get_edit_link }}&ref=dashboard">{{ taxonomy.name }}</a></li>
|
25 |
+
{% endfor %}
|
26 |
+
</ul>
|
27 |
+
|
28 |
+
<p class="types-information-link">
|
29 |
+
<a class="button" href="{{ admin_url }}admin.php?page=wpcf-edit-tax&assign_type={{ post_type.get_name() }}&ref=dashboard">{{ labels.create_taxonomy }}</a>
|
30 |
+
</p>
|
31 |
+
</div>
|
32 |
+
</td>
|
33 |
+
<td>
|
34 |
+
{% for information in table.get_template() %}
|
35 |
+
{% include 'page/dashboard/table/tbody-cell.twig' %}
|
36 |
+
{% endfor %}
|
37 |
+
</td>
|
38 |
+
{% if post_type.get_name() == 'page' or post_type.get_name() == 'attachment' %}
|
39 |
+
<td>
|
40 |
+
<div class="types-information-td-inner">
|
41 |
+
<p class="types-information-paragraph">{{ labels.no_archive_for|format( post_type.name ) }}</p>
|
42 |
+
</div>
|
43 |
+
</td>
|
44 |
+
{% elseif table.get_archive( 'show-also-for-builtin' ) %}
|
45 |
+
<td>
|
46 |
+
{% for information in table.get_archive( 'show-also-for-builtin' ) %}
|
47 |
+
{% include 'page/dashboard/table/tbody-cell.twig' %}
|
48 |
+
{% endfor %}
|
49 |
+
</td>
|
50 |
+
{% endif %}
|
51 |
+
<td>
|
52 |
+
{% for information in table.get_views() %}
|
53 |
+
{% include 'page/dashboard/table/tbody-cell.twig' %}
|
54 |
+
{% endfor %}
|
55 |
+
</td>
|
56 |
+
<td>
|
57 |
+
{% for information in table.get_forms() %}
|
58 |
+
{% include 'page/dashboard/table/tbody-cell.twig' %}
|
59 |
+
{% endfor %}
|
60 |
+
</td>
|
61 |
+
</tr>
|
application/views/page/dashboard/table/thead-cell.twig
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{{ content.title }}
|
2 |
+
|
3 |
+
<a id="types-pointer-target-{{ content.id }}" href="javascript:void(0)" class="dashicons dashicons-editor-help"
|
4 |
+
data-types-open-pointer="types-pointer-{{ content.id }}" style="position:relative;"></a>
|
5 |
+
|
6 |
+
<div id="types-pointer-{{ content.id }}" style="display:none;">
|
7 |
+
<div class="types-pointer-inner">
|
8 |
+
<div class="types-message-content types-table-cell">
|
9 |
+
|
10 |
+
{% for description in content.description %}
|
11 |
+
{% if description.type %}
|
12 |
+
{% include 'information/description/' ~ description.type ~ '.twig' %}
|
13 |
+
{% endif %}
|
14 |
+
{% endfor %}
|
15 |
+
</div>
|
16 |
+
</div>
|
17 |
+
</div>
|
application/views/setting/base.twig
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{% if description %}
|
2 |
+
<p>
|
3 |
+
{{ description }}
|
4 |
+
</p>
|
5 |
+
{% endif %}
|
6 |
+
|
7 |
+
|
8 |
+
{% block setting %}{% endblock %}
|
application/views/setting/checkbox.twig
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{% extends "/setting/base.twig" %}
|
2 |
+
|
3 |
+
{% block setting %}
|
4 |
+
{% if title %}<h3>{{ title }}</h3>{% endif %}
|
5 |
+
<ul>
|
6 |
+
{% for option in setting.get_options %}
|
7 |
+
<li>
|
8 |
+
<label>
|
9 |
+
<input type="hidden" data-types-setting-save="{{ setting.get_id() }}" name="{{ setting.get_id() }}[{{ option.get_id() }}]" value="off" />
|
10 |
+
<input type="checkbox" data-types-setting-save="{{ setting.get_id() }}" name="{{ setting.get_id() }}[{{ option.get_id() }}]" class="js-types-setting" {{ setting.checked( option.get_value(), option.get_id() ) }} value="on" autocomplete="off" />
|
11 |
+
{{ option.get_description() }}
|
12 |
+
</label>
|
13 |
+
</li>
|
14 |
+
{% endfor %}
|
15 |
+
</ul>
|
16 |
+
{% endblock %}
|
17 |
+
|
library/toolset/autoloader/autoloader.php
CHANGED
@@ -12,11 +12,39 @@ final class Toolset_Autoloader {
|
|
12 |
|
13 |
private static $instance;
|
14 |
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
spl_autoload_register( array( $this, 'autoload' ) );
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
|
22 |
public static function get_instance() {
|
@@ -31,81 +59,81 @@ final class Toolset_Autoloader {
|
|
31 |
/**
|
32 |
* Add base path to search for class files.
|
33 |
*
|
34 |
-
* @param string $
|
|
|
|
|
|
|
35 |
* @return bool True if path was added
|
36 |
-
*
|
37 |
* @since 2.0
|
38 |
*/
|
39 |
-
public function add_path( $path ) {
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
return true;
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
|
|
48 |
return true;
|
49 |
}
|
50 |
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
}
|
53 |
|
54 |
-
|
55 |
/**
|
56 |
* Add multiple base paths.
|
57 |
*
|
|
|
|
|
58 |
* @param array $paths
|
|
|
|
|
59 |
* @since 2.0
|
60 |
*/
|
61 |
-
public function add_paths(
|
62 |
// run this->addPath for each value
|
63 |
foreach( $paths as $path ) {
|
64 |
-
$this->add_path( $path );
|
65 |
}
|
66 |
}
|
67 |
-
|
68 |
-
|
69 |
-
public function get_paths() {
|
70 |
-
return $this->paths;
|
71 |
-
}
|
72 |
-
|
73 |
-
|
74 |
-
public function add_prefix( $prefix ) {
|
75 |
-
// abort if already exists
|
76 |
-
if( in_array( $prefix, $this->prefixes ) )
|
77 |
-
return $this;
|
78 |
-
|
79 |
-
array_push( $this->prefixes, $prefix );
|
80 |
-
|
81 |
-
// We assume that most specific (longest) prefixes will have higher probability of a match.
|
82 |
-
// This is useful when one prefix is substring of another.
|
83 |
-
rsort( $this->prefixes );
|
84 |
-
|
85 |
-
return $this;
|
86 |
-
}
|
87 |
-
|
88 |
-
|
89 |
-
public function get_prefixes() {
|
90 |
-
return $this->prefixes;
|
91 |
-
}
|
92 |
-
|
93 |
|
94 |
|
95 |
public function autoload( $class ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
-
|
98 |
-
return true;
|
99 |
}
|
100 |
|
101 |
-
|
|
|
102 |
|
103 |
// Will be equal to $class if no replacement happens.
|
104 |
$class_without_prefix = preg_replace( '#^'.$prefix.'_#', '', $class );
|
105 |
|
106 |
if( $class != $class_without_prefix ) {
|
107 |
|
108 |
-
$result = $this->try_autoload_without_prefix( $class, $class_without_prefix );
|
109 |
|
110 |
// false means we should try with other prefixes
|
111 |
if( false !== $result ) {
|
@@ -114,12 +142,6 @@ final class Toolset_Autoloader {
|
|
114 |
}
|
115 |
}
|
116 |
|
117 |
-
// no prefix used
|
118 |
-
$result = $this->try_autoload_without_prefix( $class, $class );
|
119 |
-
if( false !== $result )
|
120 |
-
return $result;
|
121 |
-
|
122 |
-
|
123 |
return false;
|
124 |
}
|
125 |
|
@@ -129,9 +151,13 @@ final class Toolset_Autoloader {
|
|
129 |
*
|
130 |
* @param string $full_class_name Full name of the class.
|
131 |
* @param string $class_name_without_prefix Name of the class without the registered prefix.
|
|
|
|
|
132 |
* @return bool|mixed include_once() result or false if the file was not found.
|
|
|
|
|
133 |
*/
|
134 |
-
private function try_autoload_without_prefix( $full_class_name, $class_name_without_prefix ) {
|
135 |
|
136 |
// explode class by _
|
137 |
$explode_class = explode( '_' , $class_name_without_prefix );
|
@@ -146,12 +172,11 @@ final class Toolset_Autoloader {
|
|
146 |
$class_path .= strtolower( $path ) . '/';
|
147 |
}
|
148 |
|
149 |
-
$file = $class_path . $class_filename;
|
150 |
-
|
151 |
// check for file in path
|
152 |
-
foreach( $
|
153 |
|
154 |
-
$
|
|
|
155 |
|
156 |
while( true ) {
|
157 |
$candidate_filename = $next_filename;
|
@@ -176,7 +201,6 @@ final class Toolset_Autoloader {
|
|
176 |
|
177 |
}
|
178 |
|
179 |
-
// Last attempt for legacy classes.
|
180 |
return false;
|
181 |
}
|
182 |
|
12 |
|
13 |
private static $instance;
|
14 |
|
15 |
+
/**
|
16 |
+
* @var array Multidimensional associative array:
|
17 |
+
*
|
18 |
+
* array(
|
19 |
+
* class prefix => array(
|
20 |
+
* path => array( ... options ... ),
|
21 |
+
* ...
|
22 |
+
* ),
|
23 |
+
* ...
|
24 |
+
* )
|
25 |
+
*
|
26 |
+
*/
|
27 |
+
private $paths_by_prefixes = array();
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* For production version of Types we use a class map
|
32 |
+
* you can disable using the classmap by simply deleting /autoload_classmap.php
|
33 |
+
*
|
34 |
+
* Note: Not using the classmap will lower the performance significant
|
35 |
+
*
|
36 |
+
* @var bool|array
|
37 |
+
* @since 2.1
|
38 |
+
*/
|
39 |
+
private $classmap = false;
|
40 |
+
|
41 |
|
42 |
+
private function __construct() {
|
43 |
spl_autoload_register( array( $this, 'autoload' ) );
|
44 |
+
|
45 |
+
if( file_exists( TYPES_ABSPATH . '/autoload_classmap.php' ) ) {
|
46 |
+
$this->classmap = include( TYPES_ABSPATH . '/autoload_classmap.php' );
|
47 |
+
}
|
48 |
}
|
49 |
|
50 |
public static function get_instance() {
|
59 |
/**
|
60 |
* Add base path to search for class files.
|
61 |
*
|
62 |
+
* @param string $prefix Class prefix
|
63 |
+
* @param string $path Path for given class prefix
|
64 |
+
* @param array [$options] Additional options. Currently supported are:
|
65 |
+
* - file_prefix: Value that will be prepended before each file name that will be checked.
|
66 |
* @return bool True if path was added
|
67 |
+
*
|
68 |
* @since 2.0
|
69 |
*/
|
70 |
+
public function add_path( $prefix, $path, $options = array() ) {
|
71 |
|
72 |
+
if( ! array_key_exists( $prefix, $this->paths_by_prefixes ) ) {
|
73 |
+
$this->paths_by_prefixes[ $prefix ] = array();
|
|
|
74 |
|
75 |
+
// We assume that most specific (longest) prefixes will have higher probability of a match.
|
76 |
+
// This is useful when one prefix is substring of another.
|
77 |
+
krsort( $this->paths_by_prefixes );
|
78 |
+
}
|
79 |
+
|
80 |
+
// Skip if already set
|
81 |
+
if( in_array( $path, array_keys( $this->paths_by_prefixes[ $prefix ] ) ) ) {
|
82 |
return true;
|
83 |
}
|
84 |
|
85 |
+
// Abort if the path is not readable
|
86 |
+
if( ! is_readable( $path ) ) {
|
87 |
+
return false;
|
88 |
+
}
|
89 |
+
|
90 |
+
if( !is_array( $options ) ) {
|
91 |
+
$options = array();
|
92 |
+
}
|
93 |
+
|
94 |
+
$this->paths_by_prefixes[ $prefix ][ $path ] = $options;
|
95 |
+
return true;
|
96 |
}
|
97 |
|
98 |
+
|
99 |
/**
|
100 |
* Add multiple base paths.
|
101 |
*
|
102 |
+
* @param $prefix
|
103 |
+
*
|
104 |
* @param array $paths
|
105 |
+
* @param array $options
|
106 |
+
*
|
107 |
* @since 2.0
|
108 |
*/
|
109 |
+
public function add_paths( $prefix, $paths, $options = array() ) {
|
110 |
// run this->addPath for each value
|
111 |
foreach( $paths as $path ) {
|
112 |
+
$this->add_path( $prefix, $path, $options );
|
113 |
}
|
114 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
|
116 |
|
117 |
public function autoload( $class ) {
|
118 |
+
// use class map if defined
|
119 |
+
if( $this->classmap ) {
|
120 |
+
if( isset( $this->classmap[$class] ) && file_exists( $this->classmap[$class] ) ) {
|
121 |
+
require_once( $this->classmap[$class] );
|
122 |
+
return true;
|
123 |
+
}
|
124 |
|
125 |
+
return false;
|
|
|
126 |
}
|
127 |
|
128 |
+
// no class map
|
129 |
+
foreach( $this->paths_by_prefixes as $prefix => $paths ) {
|
130 |
|
131 |
// Will be equal to $class if no replacement happens.
|
132 |
$class_without_prefix = preg_replace( '#^'.$prefix.'_#', '', $class );
|
133 |
|
134 |
if( $class != $class_without_prefix ) {
|
135 |
|
136 |
+
$result = $this->try_autoload_without_prefix( $class, $class_without_prefix, $paths );
|
137 |
|
138 |
// false means we should try with other prefixes
|
139 |
if( false !== $result ) {
|
142 |
}
|
143 |
}
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
return false;
|
146 |
}
|
147 |
|
151 |
*
|
152 |
* @param string $full_class_name Full name of the class.
|
153 |
* @param string $class_name_without_prefix Name of the class without the registered prefix.
|
154 |
+
* @param array $paths Path definitions for current prefix.
|
155 |
+
*
|
156 |
* @return bool|mixed include_once() result or false if the file was not found.
|
157 |
+
*
|
158 |
+
* @since 2.0
|
159 |
*/
|
160 |
+
private function try_autoload_without_prefix( $full_class_name, $class_name_without_prefix, $paths ) {
|
161 |
|
162 |
// explode class by _
|
163 |
$explode_class = explode( '_' , $class_name_without_prefix );
|
172 |
$class_path .= strtolower( $path ) . '/';
|
173 |
}
|
174 |
|
|
|
|
|
175 |
// check for file in path
|
176 |
+
foreach( $paths as $path => $options ) {
|
177 |
|
178 |
+
$file_prefix = wpcf_getarr( $options, 'file_prefix', '' );
|
179 |
+
$next_filename = $class_path . $file_prefix . $class_filename;
|
180 |
|
181 |
while( true ) {
|
182 |
$candidate_filename = $next_filename;
|
201 |
|
202 |
}
|
203 |
|
|
|
204 |
return false;
|
205 |
}
|
206 |
|
library/toolset/filesystem/file.php
CHANGED
@@ -20,7 +20,7 @@ class Toolset_Filesystem_File {
|
|
20 |
}
|
21 |
|
22 |
$this->path = $path;
|
23 |
-
return
|
24 |
}
|
25 |
|
26 |
/**
|
@@ -58,12 +58,17 @@ class Toolset_Filesystem_File {
|
|
58 |
public function search( $search, $return = 'bool' ) {
|
59 |
$this->open_file();
|
60 |
|
|
|
|
|
|
|
61 |
while( ( $line = fgets( $this->handle ) ) !== false) {
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
67 |
}
|
68 |
}
|
69 |
}
|
20 |
}
|
21 |
|
22 |
$this->path = $path;
|
23 |
+
return true;
|
24 |
}
|
25 |
|
26 |
/**
|
58 |
public function search( $search, $return = 'bool' ) {
|
59 |
$this->open_file();
|
60 |
|
61 |
+
if( ! is_array( $search ) )
|
62 |
+
$search = array( $search );
|
63 |
+
|
64 |
while( ( $line = fgets( $this->handle ) ) !== false) {
|
65 |
+
foreach( $search as $needle ) {
|
66 |
+
if( strpos( $line , $needle ) !== false ) {
|
67 |
+
switch( $return ) {
|
68 |
+
case 'bool':
|
69 |
+
$this->close_file();
|
70 |
+
return true;
|
71 |
+
}
|
72 |
}
|
73 |
}
|
74 |
}
|
library/toolset/installer/changelog.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
= 1.7.6 =
|
2 |
* Updated error messages when validating site keys and stopped removing site keys in case of communication errors
|
3 |
* Added a note for users who renewed or purchased new subscriptions and who need to revalidate their subscription from their websites
|
1 |
+
= 1.7.8 =
|
2 |
+
* Small fix for hiding the WPML registration notice
|
3 |
+
|
4 |
+
= 1.7.7 =
|
5 |
+
* Fixed js error showing up during registration
|
6 |
+
* Styles update for unified WPML messages
|
7 |
+
|
8 |
= 1.7.6 =
|
9 |
* Updated error messages when validating site keys and stopped removing site keys in case of communication errors
|
10 |
* Added a note for users who renewed or purchased new subscriptions and who need to revalidate their subscription from their websites
|
library/toolset/installer/includes/installer.class.php
CHANGED
@@ -603,13 +603,14 @@ final class WP_Installer{
|
|
603 |
$show = call_user_func($nag['condition_cb']);
|
604 |
}
|
605 |
|
606 |
-
if(empty($this->settings['dismissed_nags'][$nag['repository_id']]) && $show){
|
607 |
-
echo '<div class="updated error"><p>';
|
608 |
-
printf(__("To get automatic updates, you need to register %s for this site. %sRegister %s%s", 'sitepress'),
|
609 |
$nag['product_name'], '<a class="button-primary" href="' . $this->menu_url() . '">', $nag['product_name'], '</a>');
|
610 |
-
|
611 |
-
echo '
|
612 |
-
echo '</
|
|
|
613 |
}
|
614 |
}
|
615 |
|
603 |
$show = call_user_func($nag['condition_cb']);
|
604 |
}
|
605 |
|
606 |
+
if(empty($this->settings['dismissed_nags'][$nag['repository_id']]) && $show){
|
607 |
+
echo '<div class="updated error otgs-is-dismissible"><p>';
|
608 |
+
printf(__("To get automatic updates, you need to register %s for this site. %sRegister %s%s", 'sitepress'),
|
609 |
$nag['product_name'], '<a class="button-primary" href="' . $this->menu_url() . '">', $nag['product_name'], '</a>');
|
610 |
+
|
611 |
+
echo '</p>';
|
612 |
+
echo '<span class="installer-dismiss-nag notice-dismiss" data-repository="' . $nag['repository_id'] . '"><span class="screen-reader-text">' . __('Dismiss', 'sitepress') . '</span></span>';
|
613 |
+
echo '</div>';
|
614 |
}
|
615 |
}
|
616 |
|
library/toolset/installer/installer.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
define('WP_INSTALLER_VERSION', '1.7.
|
3 |
|
4 |
include_once dirname(__FILE__) . '/includes/installer.class.php';
|
5 |
|
1 |
<?php
|
2 |
+
define('WP_INSTALLER_VERSION', '1.7.8');
|
3 |
|
4 |
include_once dirname(__FILE__) . '/includes/installer.class.php';
|
5 |
|
library/toolset/installer/loader.php
CHANGED
@@ -1,14 +1,5 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
Plugin Name: Installer
|
4 |
-
Plugin URI: http://wp-compatibility.com/installer-plugin/
|
5 |
-
Description: Need help buying, installing and upgrading commercial themes and plugins? **Installer** handles all this for you, right from the WordPress admin. Installer lets you find themes and plugins from different sources, then, buy them from within the WordPress admin. Instead of manually uploading and unpacking, you'll see those themes and plugins available, just like any other plugin you're getting from WordPress.org.
|
6 |
-
Version: 1.7.6
|
7 |
-
Author: OnTheGoSystems Inc.
|
8 |
-
Author URI: http://www.onthegosystems.com/
|
9 |
-
*/
|
10 |
-
|
11 |
-
|
12 |
if ( ! defined( 'ABSPATH' ) ) {
|
13 |
exit; // Exit if accessed directly
|
14 |
}
|
@@ -28,7 +19,7 @@ $wp_installer_instance = dirname(__FILE__) . '/installer.php';
|
|
28 |
global $wp_installer_instances;
|
29 |
$wp_installer_instances[$wp_installer_instance] = array(
|
30 |
'bootfile' => $wp_installer_instance,
|
31 |
-
'version' => '1.7.
|
32 |
);
|
33 |
|
34 |
|
1 |
<?php
|
2 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
exit; // Exit if accessed directly
|
5 |
}
|
19 |
global $wp_installer_instances;
|
20 |
$wp_installer_instances[$wp_installer_instance] = array(
|
21 |
'bootfile' => $wp_installer_instance,
|
22 |
+
'version' => '1.7.8'
|
23 |
);
|
24 |
|
25 |
|
library/toolset/installer/res/css/admin.css
CHANGED
@@ -172,4 +172,15 @@
|
|
172 |
font-style: italic;
|
173 |
background: url('../img/spinner.gif') no-repeat;
|
174 |
padding-left:24px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
}
|
172 |
font-style: italic;
|
173 |
background: url('../img/spinner.gif') no-repeat;
|
174 |
padding-left:24px;
|
175 |
+
}
|
176 |
+
|
177 |
+
.otgs-is-dismissible {
|
178 |
+
position: relative;
|
179 |
+
padding-right: 38px;
|
180 |
+
}
|
181 |
+
.otgs-is-dismissible .notice-dismiss {
|
182 |
+
text-decoration: none;
|
183 |
+
}
|
184 |
+
.otgs-is-dismissible p [class*="button-"] {
|
185 |
+
margin: -5px 5px;
|
186 |
}
|
library/toolset/installer/res/js/admin.js
CHANGED
@@ -333,22 +333,18 @@
|
|
333 |
},
|
334 |
|
335 |
dismiss_nag: function(){
|
336 |
-
|
337 |
var thisa = jQuery(this);
|
338 |
-
|
339 |
-
jQuery('<span class="spinner"></span>').css({display: 'inline-block', float: 'left'}).appendTo(thisa);
|
340 |
-
|
341 |
data = {action: 'installer_dismiss_nag', repository: jQuery(this).data('repository')}
|
342 |
-
|
343 |
-
jQuery.ajax({url: ajaxurl, type: 'POST', dataType:'json', data: data, success:
|
344 |
function(ret){
|
345 |
-
thisa.
|
346 |
}
|
347 |
});
|
348 |
-
|
349 |
-
return false;
|
350 |
|
351 |
-
|
352 |
},
|
353 |
|
354 |
toggle_subpackages: function(){
|
333 |
},
|
334 |
|
335 |
dismiss_nag: function(){
|
336 |
+
|
337 |
var thisa = jQuery(this);
|
338 |
+
|
|
|
|
|
339 |
data = {action: 'installer_dismiss_nag', repository: jQuery(this).data('repository')}
|
340 |
+
|
341 |
+
jQuery.ajax({url: ajaxurl, type: 'POST', dataType:'json', data: data, success:
|
342 |
function(ret){
|
343 |
+
thisa.closest('.otgs-is-dismissible').remove();
|
344 |
}
|
345 |
});
|
|
|
|
|
346 |
|
347 |
+
return false;
|
348 |
},
|
349 |
|
350 |
toggle_subpackages: function(){
|
library/toolset/installer/res/js/installer_theme_install.js
CHANGED
@@ -79,16 +79,19 @@ var installer_theme_extended_object = {
|
|
79 |
//We only want to post to AJAX if its an OTGS tab
|
80 |
jQuery.post(installer_theme_install_localize.ajaxurl, data, function(response) {
|
81 |
//AJAX response
|
82 |
-
var myObject = jQuery.parseJSON(response);
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
92 |
});
|
93 |
}
|
94 |
};
|
79 |
//We only want to post to AJAX if its an OTGS tab
|
80 |
jQuery.post(installer_theme_install_localize.ajaxurl, data, function(response) {
|
81 |
//AJAX response
|
82 |
+
var myObject = jQuery.parseJSON(response);
|
83 |
+
if (typeof myObject != "undefined") {
|
84 |
+
if(myObject.hasOwnProperty("output")){
|
85 |
+
var tab_selected= myObject.output;
|
86 |
+
if (data_sort in js_array) {
|
87 |
+
if (!(installer_theme_install_localize.js_array_installer[tab_selected]['registration_status'])) {
|
88 |
+
//Not registered, no theme response
|
89 |
+
var unregistered_message= myObject.unregistered_messages;
|
90 |
+
jQuery('.no-themes').html(unregistered_message);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
});
|
96 |
}
|
97 |
};
|
library/toolset/onthego-resources/loader.php
CHANGED
@@ -17,9 +17,7 @@
|
|
17 |
// The version number will then be used to work out which plugin has the latest
|
18 |
// version of the code.
|
19 |
|
20 |
-
$onthegosystems_branding_version =
|
21 |
-
|
22 |
-
|
23 |
|
24 |
// ----------------------------------------------------------------------//
|
25 |
// WARNING * WARNING *WARNING
|
17 |
// The version number will then be used to work out which plugin has the latest
|
18 |
// version of the code.
|
19 |
|
20 |
+
$onthegosystems_branding_version = 15;
|
|
|
|
|
21 |
|
22 |
// ----------------------------------------------------------------------//
|
23 |
// WARNING * WARNING *WARNING
|
library/toolset/onthego-resources/onthego-styles/onthego-admin-styles.css
CHANGED
@@ -3,7 +3,8 @@
|
|
3 |
**
|
4 |
*/
|
5 |
/* ADMIN MENU ICONS */
|
6 |
-
li#toplevel_page_wpcf-cpt div.wp-menu-image:before, li#toplevel_page_wpcf-cpt .dashicons-admin-generic:before
|
|
|
7 |
font-family: "onthegosystems-icons"!important;
|
8 |
content: "\f12a";
|
9 |
font-size: 22px!important;
|
3 |
**
|
4 |
*/
|
5 |
/* ADMIN MENU ICONS */
|
6 |
+
li#toplevel_page_wpcf-cpt div.wp-menu-image:before, li#toplevel_page_wpcf-cpt .dashicons-admin-generic:before,
|
7 |
+
li#toplevel_page_toolset-dashboard div.wp-menu-image:before, li#toplevel_page_toolset-dashboard .dashicons-admin-generic:before{
|
8 |
font-family: "onthegosystems-icons"!important;
|
9 |
content: "\f12a";
|
10 |
font-size: 22px!important;
|
library/toolset/onthego-resources/readme.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
# OnTheGoSystem Resources loader
|
2 |
|
3 |
We have code and resources in GIT for branding of our plugins.
|
4 |
https://www.onthegosystems.com/misc_svn/onthegosystems-branding/
|
1 |
+
# OnTheGoSystem Resources loader master branch
|
2 |
|
3 |
We have code and resources in GIT for branding of our plugins.
|
4 |
https://www.onthegosystems.com/misc_svn/onthegosystems-branding/
|
library/toolset/toolset-common/bootstrap.php
CHANGED
@@ -101,7 +101,6 @@ class Toolset_Common_Bootstrap {
|
|
101 |
) {
|
102 |
$this->register_parser();
|
103 |
}
|
104 |
-
|
105 |
}
|
106 |
|
107 |
public function register_res() {
|
@@ -111,7 +110,7 @@ class Toolset_Common_Bootstrap {
|
|
111 |
// Use the class provided by Ric
|
112 |
require_once( TOOLSET_COMMON_PATH . '/inc/toolset.assets.manager.class.php' );
|
113 |
$this->assets_manager = Toolset_Assets_Manager::getInstance();
|
114 |
-
self::$sections_loaded = $sections_loaded;
|
115 |
}
|
116 |
}
|
117 |
|
@@ -137,7 +136,7 @@ class Toolset_Common_Bootstrap {
|
|
137 |
if ( ! class_exists( 'Toolset_Enlimbo_Forms' ) ) {
|
138 |
require_once( TOOLSET_COMMON_PATH . '/lib/enlimbo.forms.class.php' );
|
139 |
}
|
140 |
-
self::$sections_loaded = $sections_loaded;
|
141 |
}
|
142 |
}
|
143 |
|
@@ -189,7 +188,8 @@ class Toolset_Common_Bootstrap {
|
|
189 |
require_once( TOOLSET_COMMON_PATH . '/inc/toolset.compatibility.php' );
|
190 |
require_once( TOOLSET_COMMON_PATH . '/inc/toolset.function.helpers.php' );
|
191 |
require_once( TOOLSET_COMMON_PATH . '/deprecated.php' );
|
192 |
-
|
|
|
193 |
}
|
194 |
}
|
195 |
|
@@ -204,7 +204,11 @@ class Toolset_Common_Bootstrap {
|
|
204 |
$sections_loaded[] = 'toolset_dialogs';
|
205 |
require_once( TOOLSET_COMMON_PATH . '/utility/dialogs/toolset.dialog-boxes.class.php' );
|
206 |
}
|
207 |
-
|
|
|
|
|
|
|
|
|
208 |
}
|
209 |
|
210 |
public function register_debug() {
|
@@ -212,7 +216,7 @@ class Toolset_Common_Bootstrap {
|
|
212 |
if ( ! in_array( 'toolset_debug', $sections_loaded ) ) {
|
213 |
$sections_loaded[] = 'toolset_debug';
|
214 |
require_once( TOOLSET_COMMON_PATH . '/debug/debug-information.php' );
|
215 |
-
self::$sections_loaded = $sections_loaded;
|
216 |
}
|
217 |
}
|
218 |
|
@@ -223,7 +227,7 @@ class Toolset_Common_Bootstrap {
|
|
223 |
if ( ! class_exists( 'WPToolset_Forms_Bootstrap' ) ) {
|
224 |
require_once TOOLSET_COMMON_PATH . '/toolset-forms/bootstrap.php';
|
225 |
}
|
226 |
-
self::$sections_loaded = $sections_loaded;
|
227 |
}
|
228 |
}
|
229 |
|
@@ -234,7 +238,7 @@ class Toolset_Common_Bootstrap {
|
|
234 |
require_once( TOOLSET_COMMON_PATH . '/visual-editor/editor-addon-generic.class.php' );
|
235 |
require_once( TOOLSET_COMMON_PATH . '/visual-editor/editor-addon.class.php' );
|
236 |
require_once( TOOLSET_COMMON_PATH . '/visual-editor/views-editor-addon.class.php' );
|
237 |
-
self::$sections_loaded = $sections_loaded;
|
238 |
}
|
239 |
}
|
240 |
|
@@ -245,7 +249,7 @@ class Toolset_Common_Bootstrap {
|
|
245 |
if ( ! class_exists( 'Toolset_Regex' ) ) {
|
246 |
require_once( TOOLSET_COMMON_PATH . '/expression-parser/parser.php' );
|
247 |
}
|
248 |
-
self::$sections_loaded = $sections_loaded;
|
249 |
}
|
250 |
}
|
251 |
|
101 |
) {
|
102 |
$this->register_parser();
|
103 |
}
|
|
|
104 |
}
|
105 |
|
106 |
public function register_res() {
|
110 |
// Use the class provided by Ric
|
111 |
require_once( TOOLSET_COMMON_PATH . '/inc/toolset.assets.manager.class.php' );
|
112 |
$this->assets_manager = Toolset_Assets_Manager::getInstance();
|
113 |
+
self::$sections_loaded = apply_filters('toolset_register_assets_section', $sections_loaded);
|
114 |
}
|
115 |
}
|
116 |
|
136 |
if ( ! class_exists( 'Toolset_Enlimbo_Forms' ) ) {
|
137 |
require_once( TOOLSET_COMMON_PATH . '/lib/enlimbo.forms.class.php' );
|
138 |
}
|
139 |
+
self::$sections_loaded = apply_filters('toolset_register_library_section', $sections_loaded);
|
140 |
}
|
141 |
}
|
142 |
|
188 |
require_once( TOOLSET_COMMON_PATH . '/inc/toolset.compatibility.php' );
|
189 |
require_once( TOOLSET_COMMON_PATH . '/inc/toolset.function.helpers.php' );
|
190 |
require_once( TOOLSET_COMMON_PATH . '/deprecated.php' );
|
191 |
+
|
192 |
+
self::$sections_loaded = apply_filters('toolset_register_include_section', $sections_loaded);
|
193 |
}
|
194 |
}
|
195 |
|
204 |
$sections_loaded[] = 'toolset_dialogs';
|
205 |
require_once( TOOLSET_COMMON_PATH . '/utility/dialogs/toolset.dialog-boxes.class.php' );
|
206 |
}
|
207 |
+
if( ! in_array('toolset_help_videos', $sections_loaded) ){
|
208 |
+
$sections_loaded[] = 'toolset_help_videos';
|
209 |
+
require_once( TOOLSET_COMMON_PATH . '/utility/help-videos/toolset-help-videos.php' );
|
210 |
+
}
|
211 |
+
self::$sections_loaded = apply_filters('toolset_register_utility_section', $sections_loaded);
|
212 |
}
|
213 |
|
214 |
public function register_debug() {
|
216 |
if ( ! in_array( 'toolset_debug', $sections_loaded ) ) {
|
217 |
$sections_loaded[] = 'toolset_debug';
|
218 |
require_once( TOOLSET_COMMON_PATH . '/debug/debug-information.php' );
|
219 |
+
self::$sections_loaded = apply_filters('toolset_register_debug_section', $sections_loaded);
|
220 |
}
|
221 |
}
|
222 |
|
227 |
if ( ! class_exists( 'WPToolset_Forms_Bootstrap' ) ) {
|
228 |
require_once TOOLSET_COMMON_PATH . '/toolset-forms/bootstrap.php';
|
229 |
}
|
230 |
+
self::$sections_loaded = apply_filters('toolset_register_forms_section', $sections_loaded);
|
231 |
}
|
232 |
}
|
233 |
|
238 |
require_once( TOOLSET_COMMON_PATH . '/visual-editor/editor-addon-generic.class.php' );
|
239 |
require_once( TOOLSET_COMMON_PATH . '/visual-editor/editor-addon.class.php' );
|
240 |
require_once( TOOLSET_COMMON_PATH . '/visual-editor/views-editor-addon.class.php' );
|
241 |
+
self::$sections_loaded = apply_filters('toolset_register_visual_editor_section', $sections_loaded);
|
242 |
}
|
243 |
}
|
244 |
|
249 |
if ( ! class_exists( 'Toolset_Regex' ) ) {
|
250 |
require_once( TOOLSET_COMMON_PATH . '/expression-parser/parser.php' );
|
251 |
}
|
252 |
+
self::$sections_loaded = apply_filters('toolset_register_parsers_section', $sections_loaded);
|
253 |
}
|
254 |
}
|
255 |
|
library/toolset/toolset-common/changelog.md
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Common 2.1 (June 13, 2016)
|
2 |
+
- Refactored event-manager library to toolset-event manager to namespace it and avoid conficts with ACF Plugin
|
3 |
+
- Added a new class for promotional and help videos management
|
4 |
+
- Improved compatibility with PHP 5.2
|
5 |
+
- Improved compatibility with WPML, including admin language switchers and loading times
|
6 |
+
- Improved compatibility for CRED file uploads and bundled scripts
|
7 |
+
|
8 |
+
-------------------------------------------------------------------------------------------------------------------
|
9 |
+
|
10 |
+
Common 2.0 (April 7, 2016)
|
11 |
+
- Created new loader to load resources for all plugins when plugin loads
|
12 |
+
- Refactored in a more organised way files and resources to be compatible with the new loader
|
13 |
+
- Added scripts and styles manager class to register and enqueue static resources with a unified system
|
14 |
+
- Added Toolset Dialog Boxes to provide a unified way to create and render dialogs
|
15 |
+
- Fixed various bugs
|
16 |
+
|
17 |
+
-------------------------------------------------------------------------------------------------------------------
|
18 |
+
|
19 |
+
Common 1.9.2 (March 17, 2016)
|
20 |
+
- Fixed issue in validation messages on Amazon S3
|
21 |
+
|
22 |
+
-------------------------------------------------------------------------------------------------------------------
|
23 |
+
Common 1.9.1 (March 15, 2016)
|
24 |
+
- Added control to filter array to prevent exceptions
|
25 |
+
- Prevented error when object does not have property or key is not set in array filter callback
|
26 |
+
- Fixed glitch in validation library
|
27 |
+
- Absolute path to include toolset-forms/api.php
|
28 |
+
- Fixed search terms with language translation
|
29 |
+
|
30 |
+
-------------------------------------------------------------------------------------------------------------------
|
31 |
+
Common 1.9 (February 15, 2016)
|
32 |
+
- Tagged for Types 1.9, Views 1.12, CRED 1.5, Layouts 1.5 and Access 1.2.8
|
33 |
+
- Updated parser.php constructors for PHP7 compatibility.
|
34 |
+
- Updated the adodb time library for PHP7 compatibility.
|
35 |
+
- Introduced the Shortcode Generator class.
|
36 |
+
- New utils.
|
37 |
+
|
38 |
+
-------------------------------------------------------------------------------------------------------------------
|
39 |
+
Common 1.8 (November 10, 2015)
|
40 |
+
- Tagged for Views 1.11.1, Types 1.8.9 and CRED 1.4.2
|
41 |
+
- Improved the media manager script.
|
42 |
+
- Added helper functions for dealing with $_GET, $_POST and arrays.
|
43 |
+
- Improved CRED file uploads.
|
44 |
+
- Improved taxonomy management in CRED forms.
|
45 |
+
- Improved usermeta fields management in CRED forms.
|
46 |
+
|
47 |
+
-------------------------------------------------------------------------------------------------------------------
|
48 |
+
Common 1.7 (October 30, 2015)
|
49 |
+
- Tagged for Views 1.11 and Layouts 1.4
|
50 |
+
|
51 |
+
-------------------------------------------------------------------------------------------------------------------
|
52 |
+
Common 1.6.2 (September 25, 2015)
|
53 |
+
- Tagged for CRED 1.4, Types 1.8.2
|
54 |
+
|
55 |
+
Common 1.6.1 (August 17, 2015)
|
56 |
+
- Tagged for Composer Types 1.8, Views 1.10, CRED 1.4 and Layouts 1.3
|
57 |
+
|
58 |
+
Common 1.6 (June 11, 2015)
|
59 |
+
- Tagged for Types 1.7, Views 1.9 and Layouts 1.2
|
60 |
+
|
61 |
+
-------------------------------------------------------------------------------------------------------------------
|
62 |
+
Common 1.5 (Apr 1, 2015)
|
63 |
+
- Tagged for Types 1.6.6, Views 1.8, CRED 1.3.6 and Layouts 1.1.
|
64 |
+
- Fixed issue when there is more than one CRED form on a page with the same taxonomy.
|
65 |
+
- Fixed a little problem with edit skype button modal window - was too narrow.
|
66 |
+
- Fixed empty title problem for filter "wpt_field_options" on user edit/add screen.
|
67 |
+
https://wp-types.com/forums/topic/populate-select-field-in-wpcf-um-group/
|
68 |
+
- Added filter "toolset_editor_add_form_buttons" to disable Toolset buttons on the post editor.
|
69 |
+
- Added placeholder attributes to fields.
|
70 |
+
- Updated CakePHP validation URL method to allow new TLD's.
|
71 |
+
|
72 |
+
-------------------------------------------------------------------------------------------------------------------
|
73 |
+
Common 1.4 (Feb 2 2015)
|
74 |
+
- Tagged for Views 1.7, Types 1.6.5, CRED 1.3.5 and Layouts 1.0 beta1
|
75 |
+
- Updated Installer to 1.5
|
76 |
+
|
77 |
+
-------------------------------------------------------------------------------------------------------------------
|
78 |
+
Common 1.3.1 (Dec 16 2014)
|
79 |
+
- Tagged for Views 1.7 beta1 and Layouts 1.0 beta1
|
80 |
+
- Fixed issue about Editor addon and ACF compatibility
|
81 |
+
- Fixed issue about branding loader
|
82 |
+
|
83 |
+
-------------------------------------------------------------------------------------------------------------------
|
84 |
+
Common 1.3 (Dec 15 2014)
|
85 |
+
- Tagged for Views 1.7 beta1 and Layouts 1.0 beta1
|
library/toolset/toolset-common/changelog.txt
CHANGED
@@ -1,76 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
Common 2.0 (April 7, 2016)
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
|
8 |
-------------------------------------------------------------------------------------------------------------------
|
9 |
|
10 |
Common 1.9.2 (March 17, 2016)
|
11 |
-
|
12 |
|
13 |
-------------------------------------------------------------------------------------------------------------------
|
14 |
Common 1.9.1 (March 15, 2016)
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-------------------------------------------------------------------------------------------------------------------
|
22 |
Common 1.9 (February 15, 2016)
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-------------------------------------------------------------------------------------------------------------------
|
30 |
Common 1.8 (November 10, 2015)
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
|
38 |
-------------------------------------------------------------------------------------------------------------------
|
39 |
Common 1.7 (October 30, 2015)
|
40 |
-
|
41 |
|
42 |
-------------------------------------------------------------------------------------------------------------------
|
43 |
Common 1.6.2 (September 25, 2015)
|
44 |
-
|
45 |
|
46 |
Common 1.6.1 (August 17, 2015)
|
47 |
-
|
48 |
|
49 |
Common 1.6 (June 11, 2015)
|
50 |
-
|
51 |
|
52 |
-------------------------------------------------------------------------------------------------------------------
|
53 |
Common 1.5 (Apr 1, 2015)
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
|
63 |
-------------------------------------------------------------------------------------------------------------------
|
64 |
Common 1.4 (Feb 2 2015)
|
65 |
-
|
66 |
-
|
67 |
|
68 |
-------------------------------------------------------------------------------------------------------------------
|
69 |
Common 1.3.1 (Dec 16 2014)
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
|
74 |
-------------------------------------------------------------------------------------------------------------------
|
75 |
Common 1.3 (Dec 15 2014)
|
76 |
-
|
1 |
+
Common 2.1 (June 13, 2016)
|
2 |
+
- Refactored event-manager library to toolset-event manager to namespace it and avoid conficts with ACF Plugin
|
3 |
+
- Added a new class for promotional and help videos management
|
4 |
+
- Improved compatibility with PHP 5.2
|
5 |
+
- Improved compatibility with WPML, including admin language switchers and loading times
|
6 |
+
- Improved compatibility for CRED file uploads and bundled scripts
|
7 |
+
|
8 |
+
-------------------------------------------------------------------------------------------------------------------
|
9 |
+
|
10 |
Common 2.0 (April 7, 2016)
|
11 |
+
- Created new loader to load resources for all plugins when plugin loads
|
12 |
+
- Refactored in a more organised way files and resources to be compatible with the new loader
|
13 |
+
- Added scripts and styles manager class to register and enqueue static resources with a unified system
|
14 |
+
- Added Toolset Dialog Boxes to provide a unified way to create and render dialogs
|
15 |
+
- Fixed various bugs
|
16 |
|
17 |
-------------------------------------------------------------------------------------------------------------------
|
18 |
|
19 |
Common 1.9.2 (March 17, 2016)
|
20 |
+
- Fixed issue in validation messages on Amazon S3
|
21 |
|
22 |
-------------------------------------------------------------------------------------------------------------------
|
23 |
Common 1.9.1 (March 15, 2016)
|
24 |
+
- Added control to filter array to prevent exceptions
|
25 |
+
- Prevented error when object does not have property or key is not set in array filter callback
|
26 |
+
- Fixed glitch in validation library
|
27 |
+
- Absolute path to include toolset-forms/api.php
|
28 |
+
- Fixed search terms with language translation
|
29 |
|
30 |
-------------------------------------------------------------------------------------------------------------------
|
31 |
Common 1.9 (February 15, 2016)
|
32 |
+
- Tagged for Types 1.9, Views 1.12, CRED 1.5, Layouts 1.5 and Access 1.2.8
|
33 |
+
- Updated parser.php constructors for PHP7 compatibility.
|
34 |
+
- Updated the adodb time library for PHP7 compatibility.
|
35 |
+
- Introduced the Shortcode Generator class.
|
36 |
+
- New utils.
|
37 |
|
38 |
-------------------------------------------------------------------------------------------------------------------
|
39 |
Common 1.8 (November 10, 2015)
|
40 |
+
- Tagged for Views 1.11.1, Types 1.8.9 and CRED 1.4.2
|
41 |
+
- Improved the media manager script.
|
42 |
+
- Added helper functions for dealing with $_GET, $_POST and arrays.
|
43 |
+
- Improved CRED file uploads.
|
44 |
+
- Improved taxonomy management in CRED forms.
|
45 |
+
- Improved usermeta fields management in CRED forms.
|
46 |
|
47 |
-------------------------------------------------------------------------------------------------------------------
|
48 |
Common 1.7 (October 30, 2015)
|
49 |
+
- Tagged for Views 1.11 and Layouts 1.4
|
50 |
|
51 |
-------------------------------------------------------------------------------------------------------------------
|
52 |
Common 1.6.2 (September 25, 2015)
|
53 |
+
- Tagged for CRED 1.4, Types 1.8.2
|
54 |
|
55 |
Common 1.6.1 (August 17, 2015)
|
56 |
+
- Tagged for Composer Types 1.8, Views 1.10, CRED 1.4 and Layouts 1.3
|
57 |
|
58 |
Common 1.6 (June 11, 2015)
|
59 |
+
- Tagged for Types 1.7, Views 1.9 and Layouts 1.2
|
60 |
|
61 |
-------------------------------------------------------------------------------------------------------------------
|
62 |
Common 1.5 (Apr 1, 2015)
|
63 |
+
- Tagged for Types 1.6.6, Views 1.8, CRED 1.3.6 and Layouts 1.1.
|
64 |
+
- Fixed issue when there is more than one CRED form on a page with the same taxonomy.
|
65 |
+
- Fixed a little problem with edit skype button modal window - was too narrow.
|
66 |
+
- Fixed empty title problem for filter "wpt_field_options" on user edit/add screen.
|
67 |
+
https://wp-types.com/forums/topic/populate-select-field-in-wpcf-um-group/
|
68 |
+
- Added filter "toolset_editor_add_form_buttons" to disable Toolset buttons on the post editor.
|
69 |
+
- Added placeholder attributes to fields.
|
70 |
+
- Updated CakePHP validation URL method to allow new TLD's.
|
71 |
|
72 |
-------------------------------------------------------------------------------------------------------------------
|
73 |
Common 1.4 (Feb 2 2015)
|
74 |
+
- Tagged for Views 1.7, Types 1.6.5, CRED 1.3.5 and Layouts 1.0 beta1
|
75 |
+
- Updated Installer to 1.5
|
76 |
|
77 |
-------------------------------------------------------------------------------------------------------------------
|
78 |
Common 1.3.1 (Dec 16 2014)
|
79 |
+
- Tagged for Views 1.7 beta1 and Layouts 1.0 beta1
|
80 |
+
- Fixed issue about Editor addon and ACF compatibility
|
81 |
+
- Fixed issue about branding loader
|
82 |
|
83 |
-------------------------------------------------------------------------------------------------------------------
|
84 |
Common 1.3 (Dec 15 2014)
|
85 |
+
- Tagged for Views 1.7 beta1 and Layouts 1.0 beta1
|
library/toolset/toolset-common/debug/debug-information.php
CHANGED
@@ -22,14 +22,9 @@ $debug_information = new ICL_Debug_Information();
|
|
22 |
$debug_data = $debug_information->get_debug_info();
|
23 |
?>
|
24 |
<div class="wrap">
|
25 |
-
<
|
26 |
-
<div
|
27 |
-
<
|
28 |
-
|
29 |
-
|
30 |
-
<p><?php _e( 'This information allows our support team to see the versions of WordPress, plugins and theme on your site. Provide this information if requested in our support forum. No passwords or other confidential information is included.', 'sitepress', 'wpv-views' ) ?></p><br/>
|
31 |
-
<textarea style="font-size:10px;width:100%;height:250px;" rows="26" readonly="readonly"><?php echo esc_html( $debug_information->do_json_encode( $debug_data ) );?></textarea>
|
32 |
-
</div>
|
33 |
-
</div>
|
34 |
-
</div>
|
35 |
</div>
|
22 |
$debug_data = $debug_information->get_debug_info();
|
23 |
?>
|
24 |
<div class="wrap">
|
25 |
+
<h1><?php _e('Toolset Debug Information', 'wpv-views');?></h1>
|
26 |
+
<div class="inside">
|
27 |
+
<p><?php _e( 'This information allows our support team to see the versions of WordPress, plugins and theme on your site. Provide this information if requested in our support forum. No passwords or other confidential information is included.', 'sitepress', 'wpv-views' ) ?></p><br/>
|
28 |
+
<textarea style="font-size:10px;width:100%;height:250px;" rows="26" readonly="readonly"><?php echo esc_html( $debug_information->do_json_encode( $debug_data ) );?></textarea>
|
29 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
30 |
</div>
|
library/toolset/toolset-common/functions.php
CHANGED
@@ -1,753 +1,9 @@
|
|
1 |
<?php
|
2 |
-
/*
|
3 |
-
* Common functions.
|
4 |
-
*/
|
5 |
-
define( 'ICL_COMMON_FUNCTIONS', true );
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
return $path;
|
13 |
-
}
|
14 |
-
}
|
15 |
|
16 |
-
|
17 |
-
* Calculates relative path for given file.
|
18 |
-
*
|
19 |
-
* @param type $file Absolute path to file
|
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 |
-
|
48 |
-
/**
|
49 |
-
* Fix WP's multiarray parsing.
|
50 |
-
*
|
51 |
-
* @param type $arg
|
52 |
-
* @param type $defaults
|
53 |
-
* @return type
|
54 |
-
*/
|
55 |
-
function wpv_parse_args_recursive( $arg, $defaults ) {
|
56 |
-
$temp = false;
|
57 |
-
if ( isset( $arg[0] ) ) {
|
58 |
-
$temp = $arg[0];
|
59 |
-
} else if ( isset( $defaults[0] ) ) {
|
60 |
-
$temp = $defaults[0];
|
61 |
-
}
|
62 |
-
$arg = wp_parse_args( $arg, $defaults );
|
63 |
-
if ( $temp ) {
|
64 |
-
$arg[0] = $temp;
|
65 |
-
}
|
66 |
-
foreach ( $defaults as $default_setting_parent => $default_setting ) {
|
67 |
-
if ( !is_array( $default_setting ) ) {
|
68 |
-
if ( !isset( $arg[$default_setting_parent] ) ) {
|
69 |
-
$arg[$default_setting_parent] = $default_setting;
|
70 |
-
}
|
71 |
-
continue;
|
72 |
-
}
|
73 |
-
if ( !isset( $arg[$default_setting_parent] ) ) {
|
74 |
-
$arg[$default_setting_parent] = $defaults[$default_setting_parent];
|
75 |
-
}
|
76 |
-
$arg[$default_setting_parent] = wpv_parse_args_recursive( $arg[$default_setting_parent],
|
77 |
-
$defaults[$default_setting_parent] );
|
78 |
-
}
|
79 |
-
|
80 |
-
return $arg;
|
81 |
-
}
|
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 ) {
|
90 |
-
return wpv_filter_parse_date( $value );
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Condition function to evaluate and display given block based on expressions
|
95 |
-
* 'args' => arguments for evaluation fields
|
96 |
-
*
|
97 |
-
* Supported actions and symbols:
|
98 |
-
*
|
99 |
-
* Integer and floating-point numbers
|
100 |
-
* Math operators: +, -, *, /
|
101 |
-
* Comparison operators: <, >, =, <=, >=, !=
|
102 |
-
* Boolean operators: AND, OR, NOT
|
103 |
-
* Nested expressions - several levels of brackets
|
104 |
-
* Variables defined as shortcode parameters starting with a dollar sign
|
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(
|
112 |
-
shortcode_atts( array('evaluate' => FALSE), $atts )
|
113 |
-
);
|
114 |
-
|
115 |
-
// Do not overwrite global post
|
116 |
-
// global $post;
|
117 |
-
|
118 |
-
// if in admin, get the post from the URL
|
119 |
-
if ( is_admin() ) {
|
120 |
-
if ( empty($post_to_check->ID) ) {
|
121 |
-
// Get post
|
122 |
-
if ( isset( $_GET['post'] ) ) {
|
123 |
-
$post_id = (int) $_GET['post'];
|
124 |
-
} else if ( isset( $_POST['post_ID'] ) ) {
|
125 |
-
$post_id = (int) $_POST['post_ID'];
|
126 |
-
} else {
|
127 |
-
$post_id = 0;
|
128 |
-
}
|
129 |
-
if ( $post_id ) {
|
130 |
-
$post = get_post( $post_id );
|
131 |
-
}
|
132 |
-
} else {
|
133 |
-
$post = $post_to_check;
|
134 |
-
}
|
135 |
-
}
|
136 |
-
if ( empty($post->ID) ) {
|
137 |
-
global $post;
|
138 |
-
}
|
139 |
-
$has_post = true;
|
140 |
-
if ( empty($post->ID) ) {
|
141 |
-
// Will not execute any condition that involves custom fields
|
142 |
-
$has_post = false;
|
143 |
-
}
|
144 |
-
|
145 |
-
global $wplogger;
|
146 |
-
|
147 |
-
if ( $has_post ) {
|
148 |
-
do_action( 'wpv_condition', $post );
|
149 |
-
}
|
150 |
-
|
151 |
-
$logging_string = "Original expression: " . $evaluate;
|
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 ) {
|
160 |
-
$empties = preg_match_all( "/empty\(\s*\\$(\w+)\s*\)/", $evaluate, $matches );
|
161 |
-
if ( $empties && $empties > 0 ) {
|
162 |
-
for ( $i = 0; $i < $empties; $i++ ) {
|
163 |
-
$match_var = get_post_meta( $post->ID, $atts[$matches[1][$i]], true );
|
164 |
-
$is_empty = '1=0';
|
165 |
-
|
166 |
-
// mark as empty only nulls and ""
|
167 |
-
// if ( is_null( $match_var ) || strlen( $match_var ) == 0 ) {
|
168 |
-
if ( is_null( $match_var )
|
169 |
-
|| ( is_string( $match_var ) && strlen( $match_var ) == 0 )
|
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 |
-
}
|
178 |
-
|
179 |
-
// find variables that are to be used as strings.
|
180 |
-
// eg '$f1'
|
181 |
-
// will replace $f1 with the actual field value
|
182 |
-
if ( $has_post ) {
|
183 |
-
$strings_count = preg_match_all( '/(\'[\$\w^\']*\')/', $evaluate, $matches );
|
184 |
-
if ( $strings_count && $strings_count > 0 ) {
|
185 |
-
for ( $i = 0; $i < $strings_count; $i++ ) {
|
186 |
-
$string = $matches[1][$i];
|
187 |
-
// remove single quotes from string literals to get value only
|
188 |
-
$string = (strpos( $string, '\'' ) === 0) ? substr( $string, 1,
|
189 |
-
strlen( $string ) - 2 ) : $string;
|
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 |
-
}
|
199 |
-
}
|
200 |
-
}
|
201 |
-
|
202 |
-
// find string variables and evaluate
|
203 |
-
$strings_count = preg_match_all( '/((\$\w+)|(\'[^\']*\'))\s*([\!<>\=]+)\s*((\$\w+)|(\'[^\']*\'))/',
|
204 |
-
$evaluate, $matches );
|
205 |
-
|
206 |
-
// get all string comparisons - with variables and/or literals
|
207 |
-
if ( $strings_count && $strings_count > 0 ) {
|
208 |
-
for ( $i = 0; $i < $strings_count; $i++ ) {
|
209 |
-
|
210 |
-
// get both sides and sign
|
211 |
-
$first_string = $matches[1][$i];
|
212 |
-
$second_string = $matches[5][$i];
|
213 |
-
$math_sign = $matches[4][$i];
|
214 |
-
|
215 |
-
// remove single quotes from string literals to get value only
|
216 |
-
$first_string = (strpos( $first_string, '\'' ) === 0) ? substr( $first_string,
|
217 |
-
1, strlen( $first_string ) - 2 ) : $first_string;
|
218 |
-
$second_string = (strpos( $second_string, '\'' ) === 0) ? substr( $second_string,
|
219 |
-
1, strlen( $second_string ) - 2 ) : $second_string;
|
220 |
-
|
221 |
-
// replace variables with text representation
|
222 |
-
if ( strpos( $first_string, '$' ) === 0 && $has_post ) {
|
223 |
-
$variable_name = substr( $first_string, 1 ); // omit dollar sign
|
224 |
-
if ( isset( $atts[$variable_name] ) ) {
|
225 |
-
$first_string = get_post_meta( $post->ID,
|
226 |
-
$atts[$variable_name], true );
|
227 |
-
} else {
|
228 |
-
$first_string = '';
|
229 |
-
}
|
230 |
-
}
|
231 |
-
if ( strpos( $second_string, '$' ) === 0 && $has_post ) {
|
232 |
-
$variable_name = substr( $second_string, 1 );
|
233 |
-
if ( isset( $atts[$variable_name] ) ) {
|
234 |
-
$second_string = get_post_meta( $post->ID,
|
235 |
-
$atts[$variable_name], true );
|
236 |
-
} else {
|
237 |
-
$second_string = '';
|
238 |
-
}
|
239 |
-
}
|
240 |
-
|
241 |
-
// don't do string comparison if variables are numbers
|
242 |
-
if ( !(is_numeric( $first_string ) && is_numeric( $second_string )) ) {
|
243 |
-
// compare string and return true or false
|
244 |
-
$compared_str_result = wpv_compare_strings( $first_string,
|
245 |
-
$second_string, $math_sign );
|
246 |
-
|
247 |
-
if ( $compared_str_result ) {
|
248 |
-
$evaluate = str_replace( $matches[0][$i], '1=1', $evaluate );
|
249 |
-
} else {
|
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 |
-
|
260 |
-
// find remaining strings that maybe numeric values.
|
261 |
-
// This handles 1='1'
|
262 |
-
$strings_count = preg_match_all( '/(\'[^\']*\')/', $evaluate, $matches );
|
263 |
-
if ( $strings_count && $strings_count > 0 ) {
|
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 |
-
}
|
274 |
-
|
275 |
-
|
276 |
-
// find all variable placeholders in expression
|
277 |
-
if ( $has_post ) {
|
278 |
-
$count = preg_match_all( '/\$(\w+)/', $evaluate, $matches );
|
279 |
-
|
280 |
-
$logging_string .= "; Variable placeholders: " . var_export( $matches[1],
|
281 |
-
true );
|
282 |
-
|
283 |
-
// replace all variables with their values listed as shortcode parameters
|
284 |
-
if ( $count && $count > 0 ) {
|
285 |
-
// sort array by length desc, fix str_replace incorrect replacement
|
286 |
-
$matches[1] = wpv_sort_matches_by_length( $matches[1] );
|
287 |
-
|
288 |
-
foreach ( $matches[1] as $match ) {
|
289 |
-
if ( isset( $atts[$match] ) ) {
|
290 |
-
$meta = get_post_meta( $post->ID, $atts[$match], true );
|
291 |
-
if ( empty( $meta ) ) {
|
292 |
-
$meta = "0";
|
293 |
-
}
|
294 |
-
} else {
|
295 |
-
$meta = "0";
|
296 |
-
}
|
297 |
-
$evaluate = str_replace( '$' . $match, $meta, $evaluate );
|
298 |
-
$logging_string .= "; After variables IV: " . $evaluate;
|
299 |
-
}
|
300 |
-
}
|
301 |
-
}
|
302 |
-
|
303 |
-
$logging_string .= "; End evaluated expression: " . $evaluate;
|
304 |
-
|
305 |
-
$wplogger->log( $logging_string, WPLOG_DEBUG );
|
306 |
-
// evaluate the prepared expression using the custom eval script
|
307 |
-
$result = wpv_evaluate_expression( $evaluate );
|
308 |
-
|
309 |
-
if ( $has_post ) {
|
310 |
-
do_action( 'wpv_condition_end', $post );
|
311 |
-
}
|
312 |
-
|
313 |
-
// return true, false or error string to the conditional caller
|
314 |
-
return $result;
|
315 |
-
}
|
316 |
-
|
317 |
-
function wpv_eval_check_syntax( $code ) {
|
318 |
-
return @eval( 'return true;' . $code );
|
319 |
-
}
|
320 |
-
|
321 |
-
/**
|
322 |
-
*
|
323 |
-
* Sort matches array by length so evaluate longest variable names first
|
324 |
-
*
|
325 |
-
* Otherwise the str_replace would break a field named $f11 if there is another field named $f1
|
326 |
-
*
|
327 |
-
* @param array $matches all variable names
|
328 |
-
*/
|
329 |
-
function wpv_sort_matches_by_length( $matches ) {
|
330 |
-
$length = count( $matches );
|
331 |
-
for ( $i = 0; $i < $length; $i++ ) {
|
332 |
-
$max = strlen( $matches[$i] );
|
333 |
-
$max_index = $i;
|
334 |
-
|
335 |
-
// find the longest variable
|
336 |
-
for ( $j = $i + 1; $j < $length; $j++ ) {
|
337 |
-
if ( strlen( $matches[$j] ) > $max ) {
|
338 |
-
$max = $matches[$j];
|
339 |
-
$max_index = $j;
|
340 |
-
}
|
341 |
-
}
|
342 |
-
|
343 |
-
// swap
|
344 |
-
$temp = $matches[$i];
|
345 |
-
$matches[$i] = $matches[$max_index];
|
346 |
-
$matches[$max_index] = $temp;
|
347 |
-
}
|
348 |
-
|
349 |
-
return $matches;
|
350 |
-
|
351 |
-
}
|
352 |
-
|
353 |
-
/**
|
354 |
-
* Boolean function for string comparison
|
355 |
-
*
|
356 |
-
* @param string $first first string to be compared
|
357 |
-
* @param string $second second string for comparison
|
358 |
-
*
|
359 |
-
*
|
360 |
-
*/
|
361 |
-
function wpv_compare_strings( $first, $second, $sign ) {
|
362 |
-
// get comparison results
|
363 |
-
$comparison = strcmp( $first, $second );
|
364 |
-
|
365 |
-
// verify cases 'less than' and 'less than or equal': <, <=
|
366 |
-
if ( $comparison < 0 && ($sign == '<' || $sign == '<=') ) {
|
367 |
-
return true;
|
368 |
-
}
|
369 |
-
|
370 |
-
// verify cases 'greater than' and 'greater than or equal': >, >=
|
371 |
-
if ( $comparison > 0 && ($sign == '>' || $sign == '>=') ) {
|
372 |
-
return true;
|
373 |
-
}
|
374 |
-
|
375 |
-
// verify equal cases: =, <=, >=
|
376 |
-
if ( $comparison == 0 && ($sign == '=' || $sign == '<=' || $sign == '>=') ) {
|
377 |
-
return true;
|
378 |
-
}
|
379 |
-
|
380 |
-
// verify != case
|
381 |
-
if ( $comparison != 0 && $sign == '!=' ) {
|
382 |
-
return true;
|
383 |
-
}
|
384 |
-
|
385 |
-
// or result is incorrect
|
386 |
-
return false;
|
387 |
-
}
|
388 |
-
|
389 |
-
/**
|
390 |
-
*
|
391 |
-
* Function that prepares the expression and calls eval()
|
392 |
-
* Validates the input for a list of whitechars and handles internal errors if any
|
393 |
-
*
|
394 |
-
* @param string $expression the expression to be evaluated
|
395 |
-
*/
|
396 |
-
function wpv_evaluate_expression( $expression ){
|
397 |
-
//Replace AND, OR, ==
|
398 |
-
$expression = strtoupper( $expression );
|
399 |
-
$expression = str_replace( "AND", "&&", $expression );
|
400 |
-
$expression = str_replace( "OR", "||", $expression );
|
401 |
-
$expression = str_replace( "NOT", "!", $expression );
|
402 |
-
$expression = str_replace( "=", "==", $expression );
|
403 |
-
$expression = str_replace( "<==", "<=", $expression );
|
404 |
-
$expression = str_replace( ">==", ">=", $expression );
|
405 |
-
$expression = str_replace( "!==", "!=", $expression ); // due to the line above
|
406 |
-
// validate against allowed input characters
|
407 |
-
$count = preg_match( '/[0-9+-\=\*\/<>&\!\|\s\(\)]+/', $expression, $matches );
|
408 |
-
|
409 |
-
// find out if there is full match for the entire expression
|
410 |
-
if ( $count > 0 ) {
|
411 |
-
if ( strlen( $matches[0] ) == strlen( $expression ) ) {
|
412 |
-
$valid_eval = wpv_eval_check_syntax( "return $expression;" );
|
413 |
-
if ( $valid_eval ) {
|
414 |
-
return eval( "return $expression;" );
|
415 |
-
} else {
|
416 |
-
return __( "Error while parsing the evaluate expression",
|
417 |
-
'wpv-views' );
|
418 |
-
}
|
419 |
-
} else {
|
420 |
-
return __( "Conditional expression includes illegal characters",
|
421 |
-
'wpv-views' );
|
422 |
-
}
|
423 |
-
} else {
|
424 |
-
return __( "Correct conditional expression has not been found",
|
425 |
-
'wpv-views' );
|
426 |
-
}
|
427 |
-
|
428 |
-
}
|
429 |
-
|
430 |
-
/**
|
431 |
-
* class WPV_wpcf_switch_post_from_attr_id
|
432 |
-
*
|
433 |
-
* This class handles the "id" attribute in a wpv-post-xxxxx shortcode
|
434 |
-
* and sets the global $id, $post, and $authordata
|
435 |
-
*
|
436 |
-
* It also handles types. eg [types field='my-field' id='233']
|
437 |
-
*
|
438 |
-
* id can be a integer to refer directly to a post
|
439 |
-
* id can be $parent to refer to the parent
|
440 |
-
* id can be $current_page or refer to the current page
|
441 |
-
*
|
442 |
-
* id can also refer to a related post type
|
443 |
-
* eg. for a stay the related post types could be guest and room
|
444 |
-
* [types field='my-field' id='$guest']
|
445 |
-
* [types field='my-field' id='$room']
|
446 |
-
*/
|
447 |
-
class WPV_wpcf_switch_post_from_attr_id
|
448 |
-
{
|
449 |
-
function __construct( $atts ){
|
450 |
-
$this->found = false;
|
451 |
-
$this->reassign_original_post = false;
|
452 |
-
|
453 |
-
if ( isset( $atts['id'] ) ) {
|
454 |
-
global $post, $authordata, $id, $WPV_wpcf_post_relationship;
|
455 |
-
|
456 |
-
$post_id = 0;
|
457 |
-
|
458 |
-
if ( strpos( $atts['id'], '$' ) === 0 ) {
|
459 |
-
// Handle the parent if the id is $parent
|
460 |
-
if ( $atts['id'] == '$parent' && isset( $post->post_parent ) ) {
|
461 |
-
$post_id = $post->post_parent;
|
462 |
-
} else if ( $atts['id'] == '$current_page' ) {
|
463 |
-
if ( is_single() || is_page() ) {
|
464 |
-
global $wp_query;
|
465 |
-
|
466 |
-
if ( isset( $wp_query->posts[0] ) ) {
|
467 |
-
$current_post = $wp_query->posts[0];
|
468 |
-
$post_id = $current_post->ID;
|
469 |
-
}
|
470 |
-
}
|
471 |
-
} else {
|
472 |
-
// See if Views has the variable
|
473 |
-
global $WP_Views;
|
474 |
-
if ( isset( $WP_Views ) ) {
|
475 |
-
$post_id = $WP_Views->get_variable( $atts['id'] . '_id' );
|
476 |
-
}
|
477 |
-
if ( $post_id == 0 ) {
|
478 |
-
// Try the local storage.
|
479 |
-
if ( isset( $WPV_wpcf_post_relationship[$atts['id'] . '_id'] ) ) {
|
480 |
-
$post_id = $WPV_wpcf_post_relationship[$atts['id'] . '_id'];
|
481 |
-
}
|
482 |
-
}
|
483 |
-
}
|
484 |
-
} else {
|
485 |
-
$post_id = intval( $atts['id'] );
|
486 |
-
}
|
487 |
-
|
488 |
-
if ( $post_id > 0 ) {
|
489 |
-
|
490 |
-
// if post does not exists
|
491 |
-
if( get_post_status( $post_id ) === false ) {
|
492 |
-
|
493 |
-
// set to true to reapply backup post in __destruct()
|
494 |
-
$this->reassign_original_post = true;
|
495 |
-
|
496 |
-
// save original post
|
497 |
-
$this->post = ( isset( $post ) && ( $post instanceof WP_Post ) ) ? clone $post : null;
|
498 |
-
|
499 |
-
$msg_post_does_not_exists = __(
|
500 |
-
sprintf(
|
501 |
-
'A post with the ID %s does not exist.',
|
502 |
-
'<b>'.$atts['id'].'</b>'
|
503 |
-
)
|
504 |
-
, 'wpv-views'
|
505 |
-
);
|
506 |
-
|
507 |
-
$post->post_title = $post->post_content = $post->post_excerpt = $msg_post_does_not_exists;
|
508 |
-
|
509 |
-
return;
|
510 |
-
}
|
511 |
-
|
512 |
-
$this->found = true;
|
513 |
-
|
514 |
-
// save original post
|
515 |
-
$this->post = ( isset( $post ) && ( $post instanceof WP_Post ) ) ? clone $post : null;
|
516 |
-
if ( $authordata ) {
|
517 |
-
$this->authordata = clone $authordata;
|
518 |
-
} else {
|
519 |
-
$this->authordata = null;
|
520 |
-
}
|
521 |
-
$this->id = $id;
|
522 |
-
|
523 |
-
// set the global post values
|
524 |
-
$id = $post_id;
|
525 |
-
$post = get_post( $id );
|
526 |
-
|
527 |
-
$authordata = new WP_User( $post->post_author );
|
528 |
-
|
529 |
-
}
|
530 |
-
}
|
531 |
-
}
|
532 |
-
|
533 |
-
function __destruct(){
|
534 |
-
if ( $this->found ) {
|
535 |
-
global $post, $authordata, $id;
|
536 |
-
|
537 |
-
// restore the global post values.
|
538 |
-
$post = ( isset( $this->post ) && ( $this->post instanceof WP_Post ) ) ? clone $this->post : null;
|
539 |
-
if ( $this->authordata ) {
|
540 |
-
$authordata = clone $this->authordata;
|
541 |
-
} else {
|
542 |
-
$authordata = null;
|
543 |
-
}
|
544 |
-
$id = $this->id;
|
545 |
-
}
|
546 |
-
|
547 |
-
if( isset( $this->reassign_original_post ) && $this->reassign_original_post ) {
|
548 |
-
global $post;
|
549 |
-
|
550 |
-
$post = ( isset( $this->post ) && ( $this->post instanceof WP_Post ) ) ? clone $this->post : null;
|
551 |
-
}
|
552 |
-
|
553 |
-
}
|
554 |
-
|
555 |
-
}
|
556 |
-
|
557 |
-
/**
|
558 |
-
* Add a filter on the content so that we can record any related posts.
|
559 |
-
*
|
560 |
-
* These can then be used in id attributes of Types and Views shortcodes:
|
561 |
-
* [types field='my-field' id="$room"] displays my-field from the related room.
|
562 |
-
* [wpv-post-title id="$room"] display the title of the related room.
|
563 |
-
*
|
564 |
-
* Then, clear the recorded relationships and take care of nested structures by restoring states.
|
565 |
-
*
|
566 |
-
* Note that this is also done for the Views wpv_filter_wpv_the_content_suppressed filter
|
567 |
-
* used on [wpv-post-body view_template="..." suppress_filters="true"]
|
568 |
-
* so that we also have parent data stored and restored when nesting Content Templates without all the filters.
|
569 |
-
*/
|
570 |
-
|
571 |
-
$WPV_wpcf_post_relationship = array();
|
572 |
-
$WPV_wpcf_post_relationship_depth = 0;
|
573 |
-
$WPV_wpcf_post_relationship_track = array();
|
574 |
-
|
575 |
-
add_filter( 'the_content', 'WPV_wpcf_record_post_relationship_belongs', 0, 1 );
|
576 |
-
add_filter( 'wpv_filter_wpv_the_content_suppressed', 'WPV_wpcf_record_post_relationship_belongs', 0, 1 );
|
577 |
-
|
578 |
-
function WPV_wpcf_record_post_relationship_belongs( $content ) {
|
579 |
-
|
580 |
-
global $post, $WPV_wpcf_post_relationship, $WPV_wpcf_post_relationship_depth, $WPV_wpcf_post_relationship_track;
|
581 |
-
static $related = array();
|
582 |
-
$WPV_wpcf_post_relationship_depth++;
|
583 |
-
|
584 |
-
if ( !empty( $post->ID ) && function_exists( 'wpcf_pr_get_belongs' ) ) {
|
585 |
-
|
586 |
-
if ( !isset( $related[$post->post_type] ) ) {
|
587 |
-
$related[$post->post_type] = wpcf_pr_get_belongs( $post->post_type );
|
588 |
-
}
|
589 |
-
if ( is_array( $related[$post->post_type] ) ) {
|
590 |
-
foreach ( $related[$post->post_type] as $post_type => $data ) {
|
591 |
-
$related_id = wpcf_pr_post_get_belongs( $post->ID, $post_type );
|
592 |
-
if ( $related_id ) {
|
593 |
-
$WPV_wpcf_post_relationship['$' . $post_type . '_id'] = $related_id;
|
594 |
-
} else {
|
595 |
-
$WPV_wpcf_post_relationship['$' . $post_type . '_id'] = 0;
|
596 |
-
}
|
597 |
-
}
|
598 |
-
}
|
599 |
-
}
|
600 |
-
|
601 |
-
$WPV_wpcf_post_relationship_track[ $WPV_wpcf_post_relationship_depth ] = $WPV_wpcf_post_relationship;
|
602 |
-
|
603 |
-
return $content;
|
604 |
-
}
|
605 |
-
|
606 |
-
add_filter( 'the_content', 'WPV_wpcf_restore_post_relationship_belongs', PHP_INT_MAX, 1 );
|
607 |
-
add_filter( 'wpv_filter_wpv_the_content_suppressed', 'WPV_wpcf_restore_post_relationship_belongs', PHP_INT_MAX, 1 );
|
608 |
-
|
609 |
-
function WPV_wpcf_restore_post_relationship_belongs( $content ) {
|
610 |
-
global $WPV_wpcf_post_relationship, $WPV_wpcf_post_relationship_depth, $WPV_wpcf_post_relationship_track;
|
611 |
-
$WPV_wpcf_post_relationship_depth--;
|
612 |
-
if (
|
613 |
-
$WPV_wpcf_post_relationship_depth > 0
|
614 |
-
&& isset( $WPV_wpcf_post_relationship_track[ $WPV_wpcf_post_relationship_depth ] )
|
615 |
-
) {
|
616 |
-
$WPV_wpcf_post_relationship = $WPV_wpcf_post_relationship_track[ $WPV_wpcf_post_relationship_depth ];
|
617 |
-
} else {
|
618 |
-
$WPV_wpcf_post_relationship = array();
|
619 |
-
}
|
620 |
-
return $content;
|
621 |
-
}
|
622 |
-
|
623 |
-
/**
|
624 |
-
* Form for Enlimbo calls for wpv-control shortcode calls
|
625 |
-
*
|
626 |
-
* @param mixed $elements
|
627 |
-
* @return string
|
628 |
-
*/
|
629 |
-
function wpv_form_control( $elements ) {
|
630 |
-
static $form = NULL;
|
631 |
-
require_once 'classes/control_forms.php';
|
632 |
-
if ( is_null( $form ) ) {
|
633 |
-
$form = new Enlimbo_Control_Forms();
|
634 |
-
}
|
635 |
-
return $form->renderElements( $elements );
|
636 |
-
}
|
637 |
-
|
638 |
-
/**
|
639 |
-
* Dismiss message.
|
640 |
-
*
|
641 |
-
* @param type $message_id
|
642 |
-
* @param string $message
|
643 |
-
* @param type $class
|
644 |
-
*/
|
645 |
-
function wpv_add_dismiss_message( $message_id, $message,
|
646 |
-
$clear_dismissed = false, $class = 'updated' ) {
|
647 |
-
$dismissed_messages = get_option( 'wpv-dismissed-messages', array() );
|
648 |
-
if ( $clear_dismissed ) {
|
649 |
-
if ( isset( $dismissed_messages[$message_id] ) ) {
|
650 |
-
unset( $dismissed_messages[$message_id] );
|
651 |
-
update_option( 'wpv-dismissed-messages', $dismissed_messages );
|
652 |
-
}
|
653 |
-
}
|
654 |
-
if ( !array_key_exists( $message_id, $dismissed_messages ) ) {
|
655 |
-
$message = $message . '<div style="float:right; margin:-15px 0 0 15px;"><a onclick="jQuery(this).parent().parent().fadeOut();jQuery.get(\''
|
656 |
-
. admin_url( 'admin-ajax.php?action=wpv_dismiss_message&message_id='
|
657 |
-
. $message_id . '&_wpnonce='
|
658 |
-
. wp_create_nonce( 'dismiss_message' ) ) . '\');return false;"'
|
659 |
-
. 'class="button-secondary" href="javascript:void(0);">'
|
660 |
-
. __( "Don't show this message again", 'wpv-views' ) . '</a></div>';
|
661 |
-
wpv_admin_message_store( $message_id, $message, false );
|
662 |
-
}
|
663 |
-
}
|
664 |
-
|
665 |
-
add_action( 'wp_ajax_wpv_dismiss_message', 'wpv_dismiss_message_ajax' );
|
666 |
-
|
667 |
-
/**
|
668 |
-
* Dismiss message AJAX.
|
669 |
-
*/
|
670 |
-
function wpv_dismiss_message_ajax() {
|
671 |
-
if ( isset( $_GET['message_id'] ) && isset( $_GET['_wpnonce'] )
|
672 |
-
&& wp_verify_nonce( $_GET['_wpnonce'], 'dismiss_message' ) ) {
|
673 |
-
$dismissed_messages = get_option( 'wpv-dismissed-messages', array() );
|
674 |
-
$dismissed_image_val = isset( $_GET['timestamp'] ) ? $_GET['timestamp'] : 1;
|
675 |
-
$dismissed_messages[strval( $_GET['message_id'] )] = $dismissed_image_val;
|
676 |
-
update_option( 'wpv-dismissed-messages', $dismissed_messages );
|
677 |
-
}
|
678 |
-
die( 'ajax' );
|
679 |
-
}
|
680 |
-
|
681 |
-
|
682 |
-
// These functions are defined as pluggable in Views 1.12 for compatibility reason, hence they must be pluggable here as well.
|
683 |
-
|
684 |
-
if( !function_exists( 'toolset_getarr_safe' ) ) {
|
685 |
-
/**
|
686 |
-
* Safely retrieve a key from given array (meant for $_POST, $_GET, etc).
|
687 |
-
*
|
688 |
-
* Checks if the key is set in the source array. If not, default value is returned. Optionally validates against array
|
689 |
-
* of allowed values and returns default value if the validation fails.
|
690 |
-
*
|
691 |
-
* @param array $source The source array.
|
692 |
-
* @param string $key The key to be retrieved from the source array.
|
693 |
-
* @param mixed $default Default value to be returned if key is not set or the value is invalid. Optional.
|
694 |
-
* Default is empty string.
|
695 |
-
* @param null|array $valid If an array is provided, the value will be validated against it's elements.
|
696 |
-
*
|
697 |
-
* @return mixed The value of the given key or $default.
|
698 |
-
*
|
699 |
-
* @since 1.7
|
700 |
-
*/
|
701 |
-
function toolset_getarr_safe( &$source, $key, $default = '', $valid = null ) {
|
702 |
-
if( isset( $source[ $key ] ) ) {
|
703 |
-
$val = $source[ $key ];
|
704 |
-
if( is_array( $valid ) && !in_array( $val, $valid ) ) {
|
705 |
-
return $default;
|
706 |
-
}
|
707 |
-
|
708 |
-
return $val;
|
709 |
-
} else {
|
710 |
-
return $default;
|
711 |
-
}
|
712 |
-
}
|
713 |
-
}
|
714 |
-
|
715 |
-
/* IF PHP < 5.3 */
|
716 |
-
if ( !function_exists( 'array_replace_recursive' ) ) {
|
717 |
-
function wpcf_recurse( $array, $array1 ) {
|
718 |
-
foreach ($array1 as $key => $value)
|
719 |
-
{
|
720 |
-
// create new key in $array, if it is empty or not an array
|
721 |
-
if (!isset($array[$key]) || (isset($array[$key]) && !is_array($array[$key])))
|
722 |
-
{
|
723 |
-
$array[$key] = array();
|
724 |
-
}
|
725 |
-
|
726 |
-
// overwrite the value in the base array
|
727 |
-
if (is_array($value))
|
728 |
-
{
|
729 |
-
$value = array_replace_recursive($array[$key], $value);
|
730 |
-
}
|
731 |
-
$array[$key] = $value;
|
732 |
-
}
|
733 |
-
return $array;
|
734 |
-
}
|
735 |
-
|
736 |
-
function array_replace_recursive( $array, $array1 ) {
|
737 |
-
// handle the arguments, merge one by one
|
738 |
-
$args = func_get_args();
|
739 |
-
$array = $args[0];
|
740 |
-
if (!is_array($array))
|
741 |
-
{
|
742 |
-
return $array;
|
743 |
-
}
|
744 |
-
for ($i = 1; $i < count($args); $i++)
|
745 |
-
{
|
746 |
-
if (is_array($args[$i]))
|
747 |
-
{
|
748 |
-
$array = wpcf_recurse($array, $args[$i]);
|
749 |
-
}
|
750 |
-
}
|
751 |
-
return $array;
|
752 |
-
}
|
753 |
-
}
|
1 |
<?php
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
_doing_it_wrong(
|
4 |
+
'toolset-common/functions.php',
|
5 |
+
'The file functions.php in Toolset Common is deprecated and will be removed before next release. The functions are now defined in another file that\'s being automatically loaded by Toolset_Common_Bootstrap. Please stop including this file!',
|
6 |
+
'Toolset Common Library 2.1'
|
7 |
+
);
|
|
|
|
|
|
|
8 |
|
9 |
+
require_once dirname( __FILE__ ) . '/inc/toolset.function.helpers.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
library/toolset/toolset-common/inc/toolset.assets.manager.class.php
CHANGED
@@ -142,7 +142,7 @@ class Toolset_Assets_Manager
|
|
142 |
$this->assets_url = TOOLSET_COMMON_FRONTEND_URL;
|
143 |
}
|
144 |
|
145 |
-
add_action( 'init', array( $this, 'init' ) );
|
146 |
//be
|
147 |
add_action( 'admin_enqueue_scripts', array( $this, 'get_rid_of_default_scripts' ) );
|
148 |
add_action( 'admin_enqueue_scripts', array( $this, 'get_rid_of_default_styles' ) );
|
@@ -158,10 +158,19 @@ class Toolset_Assets_Manager
|
|
158 |
final public static function getInstance() {
|
159 |
static $instances = array();
|
160 |
$called_class = get_called_class();
|
161 |
-
|
162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
}
|
164 |
-
|
165 |
}
|
166 |
|
167 |
public function init() {
|
@@ -278,7 +287,12 @@ class Toolset_Assets_Manager
|
|
278 |
array(),
|
279 |
TOOLSET_COMMON_VERSION
|
280 |
);
|
281 |
-
|
|
|
|
|
|
|
|
|
|
|
282 |
'toolset-dialogs-overrides-css', $this->assets_url . '/res/css/toolset-dialogs.css', array(), TOOLSET_COMMON_VERSION
|
283 |
);
|
284 |
|
@@ -329,6 +343,16 @@ class Toolset_Assets_Manager
|
|
329 |
'1.0',
|
330 |
true
|
331 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
$this->scripts['toolset-codemirror-script'] = new Toolset_Script(
|
333 |
'toolset-codemirror-script',
|
334 |
$this->assets_url . '/visual-editor/res/js/codemirror/lib/codemirror.js',
|
142 |
$this->assets_url = TOOLSET_COMMON_FRONTEND_URL;
|
143 |
}
|
144 |
|
145 |
+
add_action( 'init', array( $this, 'init' ), 99 );
|
146 |
//be
|
147 |
add_action( 'admin_enqueue_scripts', array( $this, 'get_rid_of_default_scripts' ) );
|
148 |
add_action( 'admin_enqueue_scripts', array( $this, 'get_rid_of_default_styles' ) );
|
158 |
final public static function getInstance() {
|
159 |
static $instances = array();
|
160 |
$called_class = get_called_class();
|
161 |
+
|
162 |
+
if( isset( $instances[ $called_class ] ) ) {
|
163 |
+
return $instances[ $called_class ];
|
164 |
+
} else {
|
165 |
+
if( class_exists( $called_class ) ) {
|
166 |
+
$instances[ $called_class ] = new $called_class();
|
167 |
+
return $instances[ $called_class ];
|
168 |
+
} else {
|
169 |
+
// This can unfortunately happen when the get_called_class() workaround for PHP 5.2 misbehaves.
|
170 |
+
return false;
|
171 |
+
}
|
172 |
}
|
173 |
+
|
174 |
}
|
175 |
|
176 |
public function init() {
|
287 |
array(),
|
288 |
TOOLSET_COMMON_VERSION
|
289 |
);
|
290 |
+
|
291 |
+
$this->styles['ddl-dialogs-forms-css'] = new Toolset_Style('ddl-dialogs-forms-css', $this->assets_url . '/utility/dialogs/css/dd-dialogs-forms.css', TOOLSET_VERSION);
|
292 |
+
$this->styles['ddl-dialogs-general-css'] = new Toolset_Style('ddl-dialogs-general-css', $this->assets_url . '/utility/dialogs/css/dd-dialogs-general.css', array( 'wp-jquery-ui-dialog' ), TOOLSET_VERSION);
|
293 |
+
$this->styles['ddl-dialogs-css'] = new Toolset_Style('ddl-dialogs-css', $this->assets_url . '/utility/dialogs/css/dd-dialogs.css', array('ddl-dialogs-general-css'), TOOLSET_VERSION );
|
294 |
+
|
295 |
+
$this->styles['toolset-dialogs-overrides-css'] = new Toolset_Style(
|
296 |
'toolset-dialogs-overrides-css', $this->assets_url . '/res/css/toolset-dialogs.css', array(), TOOLSET_COMMON_VERSION
|
297 |
);
|
298 |
|
343 |
'1.0',
|
344 |
true
|
345 |
);
|
346 |
+
|
347 |
+
$this->scripts['toolset-event-manager'] = new Toolset_Script(
|
348 |
+
'toolset-event-manager',
|
349 |
+
$this->assets_url . "/res/lib/toolset-event-manager/toolset-event-manager.min.js",
|
350 |
+
array(),
|
351 |
+
'1.0',
|
352 |
+
true
|
353 |
+
);
|
354 |
+
|
355 |
+
|
356 |
$this->scripts['toolset-codemirror-script'] = new Toolset_Script(
|
357 |
'toolset-codemirror-script',
|
358 |
$this->assets_url . '/visual-editor/res/js/codemirror/lib/codemirror.js',
|
library/toolset/toolset-common/inc/toolset.export.import.screen.class.php
CHANGED
@@ -46,8 +46,8 @@ if ( ! class_exists( 'Toolset_Export_Import_Screen' ) ) {
|
|
46 |
public function register_export_import_page_in_menu( $pages ) {
|
47 |
$pages[] = array(
|
48 |
'slug' => 'toolset-export-import',
|
49 |
-
'menu_title' => __( 'Export / Import', '
|
50 |
-
'page_title' => __( 'Export / Import', '
|
51 |
'callback' => array( $this, 'export_import_page' )
|
52 |
);
|
53 |
return $pages;
|
@@ -118,6 +118,17 @@ if ( ! class_exists( 'Toolset_Export_Import_Screen' ) ) {
|
|
118 |
<?php echo $export_import_menu; ?>
|
119 |
</p>
|
120 |
<?php echo $export_import_content; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
</div>
|
122 |
<?php
|
123 |
}
|
46 |
public function register_export_import_page_in_menu( $pages ) {
|
47 |
$pages[] = array(
|
48 |
'slug' => 'toolset-export-import',
|
49 |
+
'menu_title' => __( 'Export / Import', 'wpv-views' ),
|
50 |
+
'page_title' => __( 'Export / Import', 'wpv-views' ),
|
51 |
'callback' => array( $this, 'export_import_page' )
|
52 |
);
|
53 |
return $pages;
|
118 |
<?php echo $export_import_menu; ?>
|
119 |
</p>
|
120 |
<?php echo $export_import_content; ?>
|
121 |
+
<div class="toolset-debug-info-helper">
|
122 |
+
<p>
|
123 |
+
<?php
|
124 |
+
echo sprintf(
|
125 |
+
__( 'Need help? Grab some %1$sdebug information%2$s.', 'wpv-views' ),
|
126 |
+
'<a href="' . admin_url( 'admin.php?page=toolset-debug-information' ) . '">',
|
127 |
+
'</a>'
|
128 |
+
);
|
129 |
+
?>
|
130 |
+
</p>
|
131 |
+
</div>
|
132 |
</div>
|
133 |
<?php
|
134 |
}
|
library/toolset/toolset-common/inc/toolset.function.helpers.php
CHANGED
@@ -544,7 +544,16 @@ if ( ! function_exists( 'wpv_condition' ) ) {
|
|
544 |
|
545 |
if ( ! function_exists( 'wpv_eval_check_syntax' ) ) {
|
546 |
function wpv_eval_check_syntax( $code ) {
|
547 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
548 |
}
|
549 |
}
|
550 |
|
544 |
|
545 |
if ( ! function_exists( 'wpv_eval_check_syntax' ) ) {
|
546 |
function wpv_eval_check_syntax( $code ) {
|
547 |
+
try {
|
548 |
+
return @eval( 'return true;' . $code );
|
549 |
+
} catch( ParseError $parse_error ) {
|
550 |
+
// PHP7 compatibility, eval() changed it's behaviour:
|
551 |
+
//
|
552 |
+
// http://php.net/manual/en/function.eval.php
|
553 |
+
// As of PHP 7, if there is a parse error in the evaluated code, eval() throws a ParseError exception.
|
554 |
+
// Before PHP 7, in this case eval() returned FALSE and execution of the following code continued normally.
|
555 |
+
return false;
|
556 |
+
}
|
557 |
}
|
558 |
}
|
559 |
|
library/toolset/toolset-common/inc/toolset.localization.class.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
* toolset.localization.class.php
|
5 |
-
*
|
6 |
-
* Common localization for shared code on the Toolset and also common way for adding textdomains
|
7 |
-
*
|
8 |
-
* @since unknown
|
9 |
-
*/
|
10 |
|
11 |
if ( ! defined( 'TOOLSET_I18N' ) ) {
|
12 |
define( 'TOOLSET_I18N', true );
|
@@ -16,24 +16,23 @@ if ( ! defined( 'TOOLSET_LOCALIZATION_ABSPATH' ) ) {
|
|
16 |
define( 'TOOLSET_LOCALIZATION_ABSPATH', TOOLSET_COMMON_PATH . '/languages' );
|
17 |
}
|
18 |
|
19 |
-
/*
|
20 |
-
* Toolset_Localization
|
21 |
-
*
|
22 |
-
* Methods for registering textdomains, defaults to register the wpv-views one.
|
23 |
-
*
|
24 |
-
* @since unknown
|
25 |
-
*/
|
26 |
|
27 |
if ( ! class_exists( 'Toolset_Localization' ) ) {
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
class Toolset_Localization {
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
function __construct( $textdomain = 'wpv-views', $path = TOOLSET_LOCALIZATION_ABSPATH , $mo_name = 'views-%s' ) {
|
38 |
// Set instance properties
|
39 |
$this->textdomain = $textdomain;
|
@@ -44,16 +43,13 @@ if ( ! class_exists( 'Toolset_Localization' ) ) {
|
|
44 |
add_action( 'init', array( $this, 'load_textdomain' ) );
|
45 |
}
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
* @since July 18, 2014
|
55 |
-
*/
|
56 |
-
|
57 |
function load_textdomain() {
|
58 |
$locale = get_locale();
|
59 |
$this->mo_processed_name = sprintf( $this->mo_name, $locale );
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* toolset.localization.class.php
|
5 |
+
*
|
6 |
+
* Common localization for shared code on the Toolset and also common way for adding textdomains
|
7 |
+
*
|
8 |
+
* @since unknown
|
9 |
+
*/
|
10 |
|
11 |
if ( ! defined( 'TOOLSET_I18N' ) ) {
|
12 |
define( 'TOOLSET_I18N', true );
|
16 |
define( 'TOOLSET_LOCALIZATION_ABSPATH', TOOLSET_COMMON_PATH . '/languages' );
|
17 |
}
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
if ( ! class_exists( 'Toolset_Localization' ) ) {
|
21 |
|
22 |
+
/**
|
23 |
+
* Toolset_Localization
|
24 |
+
*
|
25 |
+
* Methods for registering textdomains, defaults to register the wpv-views one.
|
26 |
+
*
|
27 |
+
* @since unknown
|
28 |
+
*/
|
29 |
class Toolset_Localization {
|
30 |
|
31 |
+
/**
|
32 |
+
* @param $textdomain (string) the textdomain to use
|
33 |
+
* @param $path (string) the path to the folder containing the mo files
|
34 |
+
* @param $mo_name (string) the .mo file name, using %s as a placeholder for the locale - do not add the .mo extension!
|
35 |
+
*/
|
|
|
36 |
function __construct( $textdomain = 'wpv-views', $path = TOOLSET_LOCALIZATION_ABSPATH , $mo_name = 'views-%s' ) {
|
37 |
// Set instance properties
|
38 |
$this->textdomain = $textdomain;
|
43 |
add_action( 'init', array( $this, 'load_textdomain' ) );
|
44 |
}
|
45 |
|
46 |
+
/**
|
47 |
+
* Initializes localization given a textdomain, a path and a .mo file name
|
48 |
+
*
|
49 |
+
* @uses load_textdomain
|
50 |
+
*
|
51 |
+
* @since July 18, 2014
|
52 |
+
*/
|
|
|
|
|
|
|
53 |
function load_textdomain() {
|
54 |
$locale = get_locale();
|
55 |
$this->mo_processed_name = sprintf( $this->mo_name, $locale );
|
library/toolset/toolset-common/inc/toolset.menu.class.php
CHANGED
@@ -5,12 +5,12 @@ if ( ! defined( 'WPT_MENU' ) ) {
|
|
5 |
}
|
6 |
|
7 |
/**
|
8 |
-
* Toolset_Menu
|
9 |
-
*
|
10 |
-
* Generic class for the shared menu entry for the Toolset family.
|
11 |
-
*
|
12 |
-
* @since 1.9
|
13 |
-
*/
|
14 |
|
15 |
if ( ! class_exists( 'Toolset_Menu' ) ) {
|
16 |
|
@@ -21,205 +21,239 @@ if ( ! class_exists( 'Toolset_Menu' ) ) {
|
|
21 |
* @access public
|
22 |
*/
|
23 |
class Toolset_Menu {
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
public function __construct() {
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
add_action( 'init', array(
|
32 |
-
add_action( 'admin_init', array(
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
41 |
}
|
42 |
-
|
43 |
-
public function init() {
|
44 |
-
$toolset_pages = array(
|
45 |
-
'toolset-settings', 'toolset-help', 'toolset-debug-information'
|
46 |
-
);
|
47 |
-
$toolset_pages = apply_filters( 'toolset_filter_register_common_page_slug', $toolset_pages );
|
48 |
-
$this->toolset_pages = $toolset_pages;
|
49 |
-
}
|
50 |
|
51 |
public function admin_init() {
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
-
|
63 |
-
public function admin_menu() {
|
64 |
-
/**
|
65 |
-
* Ordering menu items by plugin:
|
66 |
-
* 10: Toolset Types
|
67 |
-
* 20: Toolset Access
|
68 |
-
* 30: Toolset Layouts
|
69 |
-
* 40: Toolset Views
|
70 |
-
* 50: Toolset CRED
|
71 |
-
* 60: Toolset Common - Settings, Export/Import and Help
|
72 |
-
* 70: Toolset Module Manager
|
73 |
-
* 80: Toolset Reference Sites
|
74 |
-
* 90: Toolset ending pages - for anything else, like the debug page
|
75 |
-
*/
|
76 |
-
$registered_pages = apply_filters( 'toolset_filter_register_menu_pages', array() );
|
77 |
-
if ( count( $registered_pages ) > 0 ) {
|
78 |
-
|
79 |
-
$top_level_page_registered = false;
|
80 |
-
|
81 |
-
while (
|
82 |
-
count( $registered_pages ) > 0
|
83 |
-
&& ! $top_level_page_registered
|
84 |
-
) {
|
85 |
-
$top_level_page = array_shift( $registered_pages );
|
86 |
-
$top_level_page['capability'] = isset( $top_level_page['capability'] ) ? $top_level_page['capability'] : 'manage_options';
|
87 |
-
if ( current_user_can( $top_level_page['capability'] ) ) {
|
88 |
-
$hook = add_menu_page( $top_level_page['page_title'], __( 'Toolset', 'wpv-views' ), $top_level_page['capability'], $top_level_page['slug'], $top_level_page['callback'] );
|
89 |
-
$this->add_menu_page_hooks( $top_level_page, $hook );
|
90 |
-
$top_level_page_registered = true;
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
if (
|
95 |
-
$top_level_page_registered
|
96 |
-
&& is_array( $registered_pages )
|
97 |
-
) {
|
98 |
-
$this->add_submenu_page( $top_level_page, $top_level_page );
|
99 |
-
foreach ( $registered_pages as $page ) {
|
100 |
-
$this->add_submenu_page( $page, $top_level_page );
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
public function add_submenu_page( $page, $top_level_page ) {
|
108 |
-
$page['capability'] = isset( $page['capability'] ) ? $page['capability'] : 'manage_options';
|
109 |
-
$callback = isset( $page['callback'] ) ? $page['callback'] : null;
|
110 |
-
$hook = add_submenu_page( $top_level_page['slug'], $page['page_title'], $page['menu_title'], $page['capability'], $page['slug'], $callback );
|
111 |
-
$this->add_menu_page_hooks( $page, $hook );
|
112 |
-
}
|
113 |
-
|
114 |
-
public function add_menu_page_hooks( $page, $hook ) {
|
115 |
-
global $wp_version;
|
116 |
-
$load_action = sprintf(
|
117 |
-
'load-%s',
|
118 |
-
$hook
|
119 |
-
);
|
120 |
-
if (
|
121 |
-
! empty( $page['load_hook'] )
|
122 |
-
&& is_callable( $page['load_hook'] )
|
123 |
-
) {
|
124 |
-
add_action( $load_action, $page['load_hook'] );
|
125 |
-
}
|
126 |
-
|
127 |
-
if ( version_compare( $wp_version, '3.2.1', '>' ) ) {
|
128 |
-
if (
|
129 |
-
! empty( $page['contextual_help_hook'] )
|
130 |
-
&& is_callable( $page['contextual_help_hook'] )
|
131 |
-
) {
|
132 |
-
add_action( $load_action, $page['contextual_help_hook'] );
|
133 |
-
}
|
134 |
-
} else {
|
135 |
-
if ( ! empty( $page['contextual_help_legacy'] ) ) {
|
136 |
-
add_contextual_help( $hook, $page['contextual_help_legacy'] );
|
137 |
-
}
|
138 |
-
}
|
139 |
-
}
|
140 |
-
|
141 |
-
public function admin_enqueue_scripts() {
|
142 |
-
global $pagenow;
|
143 |
-
if (
|
144 |
-
$pagenow == 'admin.php'
|
145 |
-
&& isset( $_GET['page'] )
|
146 |
-
&& in_array( $_GET['page'], $this->toolset_pages )
|
147 |
-
) {
|
148 |
-
$current_page = sanitize_text_field( $_GET['page'] );
|
149 |
-
do_action( 'toolset_enqueue_styles', array( 'toolset-common', 'toolset-notifications-css' ) );
|
150 |
-
do_action( 'toolset_enqueue_scripts', $current_page );
|
151 |
-
}
|
152 |
-
}
|
153 |
-
|
154 |
-
public function disable_wpml_admin_lang_switcher( $state ) {
|
155 |
-
global $pagenow;
|
156 |
-
if (
|
157 |
-
$pagenow == 'admin.php'
|
158 |
-
&& isset( $_GET['page'] )
|
159 |
-
&& in_array( $_GET['page'], $this->toolset_pages )
|
160 |
-
) {
|
161 |
-
$state = false;
|
162 |
-
}
|
163 |
-
return $state;
|
164 |
-
}
|
165 |
-
|
166 |
-
public function register_shared_pages_in_menu( $args ) {
|
167 |
-
// Help - DEPRECATED
|
168 |
-
// add_submenu_page( $args['slug'], __( 'Help', 'wpv-views' ), __( 'Help', 'wpv-views' ), $args['capability'], 'toolset-help', array( $this, 'help_page' ) );
|
169 |
-
}
|
170 |
-
|
171 |
-
public function help_page() {
|
172 |
-
// @todo add tracking data, create a utils::static method for this
|
173 |
-
?>
|
174 |
-
<div class="wrap">
|
175 |
-
<h2><?php _e( 'Toolset Help', 'wpv-views' ) ?></h2>
|
176 |
-
<h3 style="margin-top:3em;"><?php _e('Documentation and Support', 'wpv-views'); ?></h3>
|
177 |
-
<ul>
|
178 |
-
<li>
|
179 |
-
<?php printf(
|
180 |
-
'<a target="_blank" href="http://wp-types.com/documentation/user-guides/"><strong>%s</strong></a>'.__( ' - everything you need to know about using Toolset', 'wpv-views' ),
|
181 |
-
__( 'User Guides', 'wpv-views')
|
182 |
-
); ?>
|
183 |
-
</li>
|
184 |
-
<li>
|
185 |
-
<?php printf(
|
186 |
-
'<a target="_blank" href="http://discover-wp.com/"><strong>%s</strong></a>'.__( ' - learn to use Toolset by experimenting with fully-functional learning sites', 'wpv-views' ),
|
187 |
-
__( 'Discover WP', 'wpv-views' )
|
188 |
-
); ?>
|
189 |
-
</li>
|
190 |
-
<li>
|
191 |
-
<?php printf(
|
192 |
-
'<a target="_blank" href="http://wp-types.com/forums/forum/support-2/"><strong>%s</strong></a>'.__( ' - online help by support staff', 'wpv-views' ),
|
193 |
-
__( 'Support forum', 'wpv-views' )
|
194 |
-
); ?>
|
195 |
-
</li>
|
196 |
-
</ul>
|
197 |
-
<h3 style="margin-top:3em;"><?php _e('Debug information', 'wpv-views'); ?></h3>
|
198 |
-
<p>
|
199 |
-
<?php printf(
|
200 |
-
__( 'For retrieving debug information if asked by a support person, use the <a href="%s">debug information</a> page.', 'wpv-views' ),
|
201 |
-
admin_url('admin.php?page=toolset-debug-information')
|
202 |
-
); ?>
|
203 |
-
</p>
|
204 |
-
</div>
|
205 |
-
<?php
|
206 |
-
}
|
207 |
-
|
208 |
-
public function register_final_pages_in_menu( $args ) {
|
209 |
-
$page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
|
210 |
-
if ( 'toolset-debug-information' == $page ) {
|
211 |
-
add_submenu_page( $args['slug'], __( 'Debug information', 'wpv-views' ), __( 'Debug information', 'wpv-views' ), $args['capability'], 'toolset-debug-information', array( $this, 'debug_page' ) );
|
212 |
-
}
|
213 |
-
}
|
214 |
-
|
215 |
-
public function debug_page() {
|
216 |
-
$toolset_common_bootstrap = Toolset_Common_Bootstrap::getInstance();
|
217 |
-
$toolset_common_sections = array(
|
218 |
-
'toolset_debug'
|
219 |
-
);
|
220 |
-
$toolset_common_bootstrap->load_sections( $toolset_common_sections );
|
221 |
-
}
|
222 |
|
223 |
}
|
224 |
|
225 |
-
}
|
5 |
}
|
6 |
|
7 |
/**
|
8 |
+
* Toolset_Menu
|
9 |
+
*
|
10 |
+
* Generic class for the shared menu entry for the Toolset family.
|
11 |
+
*
|
12 |
+
* @since 1.9
|
13 |
+
*/
|
14 |
|
15 |
if ( ! class_exists( 'Toolset_Menu' ) ) {
|
16 |
|
21 |
* @access public
|
22 |
*/
|
23 |
class Toolset_Menu {
|
24 |
+
|
25 |
+
public $toolset_pages;
|
26 |
+
|
27 |
public function __construct() {
|
28 |
+
|
29 |
+
$this->toolset_pages = array();
|
30 |
+
|
31 |
+
add_action( 'init', array( &$this, 'init' ), 1 );
|
32 |
+
add_action( 'admin_init', array( &$this, 'admin_init' ), 1 );
|
33 |
+
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
34 |
+
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
|
35 |
+
|
36 |
+
add_filter( 'toolset_filter_register_menu_pages', array( &$this, 'register_debug_page_in_menu' ), 100 );
|
37 |
+
}
|
38 |
+
|
39 |
+
public function init() {
|
40 |
+
$toolset_pages = array(
|
41 |
+
'toolset-settings', 'toolset-help', 'toolset-debug-information'
|
42 |
+
);
|
43 |
+
$toolset_pages = apply_filters( 'toolset_filter_register_common_page_slug', $toolset_pages );
|
44 |
+
$this->toolset_pages = $toolset_pages;
|
45 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
public function admin_init() {
|
48 |
+
global $pagenow;
|
49 |
+
if (
|
50 |
+
$pagenow == 'admin.php'
|
51 |
+
&& isset( $_GET['page'] )
|
52 |
+
&& in_array( $_GET['page'], $this->toolset_pages )
|
53 |
+
) {
|
54 |
+
$current_page = sanitize_text_field( $_GET['page'] );
|
55 |
+
do_action( 'toolset_action_admin_init_in_toolset_page', $current_page );
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
public function admin_menu() {
|
60 |
+
/**
|
61 |
+
* Ordering menu items by plugin:
|
62 |
+
* 10: Toolset Types
|
63 |
+
* 20: Toolset Access
|
64 |
+
* 30: Toolset Layouts
|
65 |
+
* 40: Toolset Views
|
66 |
+
* 50: Toolset CRED
|
67 |
+
* 60: Toolset Common - Settings, Export/Import and Help
|
68 |
+
* 70: Toolset Module Manager
|
69 |
+
* 80: Toolset Reference Sites
|
70 |
+
* 100: Toolset debug page
|
71 |
+
*/
|
72 |
+
$registered_pages = apply_filters( 'toolset_filter_register_menu_pages', array() );
|
73 |
+
if ( count( $registered_pages ) > 0 ) {
|
74 |
+
|
75 |
+
$top_level_page_registered = false;
|
76 |
+
|
77 |
+
while (
|
78 |
+
count( $registered_pages ) > 0
|
79 |
+
&& ! $top_level_page_registered
|
80 |
+
) {
|
81 |
+
$top_level_page = array_shift( $registered_pages );
|
82 |
+
$top_level_page['capability'] = isset( $top_level_page['capability'] ) ? $top_level_page['capability'] : 'manage_options';
|
83 |
+
if ( current_user_can( $top_level_page['capability'] ) ) {
|
84 |
+
$hook = add_menu_page( $top_level_page['page_title'], __( 'Toolset', 'wpv-views' ), $top_level_page['capability'], $top_level_page['slug'], $top_level_page['callback'] );
|
85 |
+
$this->add_menu_page_hooks( $top_level_page, $hook );
|
86 |
+
$top_level_page_registered = true;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
if (
|
91 |
+
$top_level_page_registered
|
92 |
+
&& is_array( $registered_pages )
|
93 |
+
) {
|
94 |
+
$this->add_submenu_page( $top_level_page, $top_level_page );
|
95 |
+
foreach ( $registered_pages as $page ) {
|
96 |
+
$this->add_submenu_page( $page, $top_level_page );
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
public function add_submenu_page( $page, $top_level_page ) {
|
104 |
+
$page['capability'] = isset( $page['capability'] ) ? $page['capability'] : 'manage_options';
|
105 |
+
$callback = isset( $page['callback'] ) ? $page['callback'] : null;
|
106 |
+
$hook = add_submenu_page( $top_level_page['slug'], $page['page_title'], $page['menu_title'], $page['capability'], $page['slug'], $callback );
|
107 |
+
$this->add_menu_page_hooks( $page, $hook );
|
108 |
+
}
|
109 |
+
|
110 |
+
public function add_menu_page_hooks( $page, $hook ) {
|
111 |
+
global $wp_version;
|
112 |
+
$load_action = sprintf(
|
113 |
+
'load-%s',
|
114 |
+
$hook
|
115 |
+
);
|
116 |
+
|
117 |
+
// Add the Help tab for the debug page link
|
118 |
+
add_action( $load_action, array( $this, 'add_debug_help_tab' ) );
|
119 |
+
|
120 |
+
if (
|
121 |
+
! empty( $page['load_hook'] )
|
122 |
+
&& is_callable( $page['load_hook'] )
|
123 |
+
) {
|
124 |
+
add_action( $load_action, $page['load_hook'] );
|
125 |
+
}
|
126 |
+
|
127 |
+
if ( version_compare( $wp_version, '3.2.1', '>' ) ) {
|
128 |
+
if (
|
129 |
+
! empty( $page['contextual_help_hook'] )
|
130 |
+
&& is_callable( $page['contextual_help_hook'] )
|
131 |
+
) {
|
132 |
+
add_action( $load_action, $page['contextual_help_hook'] );
|
133 |
+
}
|
134 |
+
} else {
|
135 |
+
if ( ! empty( $page['contextual_help_legacy'] ) ) {
|
136 |
+
add_contextual_help( $hook, $page['contextual_help_legacy'] );
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
public function admin_enqueue_scripts() {
|
142 |
+
global $pagenow;
|
143 |
+
if (
|
144 |
+
$pagenow == 'admin.php'
|
145 |
+
&& isset( $_GET['page'] )
|
146 |
+
&& in_array( $_GET['page'], $this->toolset_pages )
|
147 |
+
) {
|
148 |
+
$current_page = sanitize_text_field( $_GET['page'] );
|
149 |
+
do_action( 'toolset_enqueue_styles', array( 'toolset-common', 'toolset-notifications-css', 'font-awesome' ) );
|
150 |
+
do_action( 'toolset_enqueue_scripts', $current_page );
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
public function help_page() {
|
155 |
+
// @todo add tracking data, create a utils::static method for this
|
156 |
+
?>
|
157 |
+
<div class="wrap">
|
158 |
+
<h2><?php _e( 'Toolset Help', 'wpv-views' ) ?></h2>
|
159 |
+
<h3 style="margin-top:3em;"><?php _e('Documentation and Support', 'wpv-views'); ?></h3>
|
160 |
+
<ul>
|
161 |
+
<li>
|
162 |
+
<?php printf(
|
163 |
+
'<a target="_blank" href="http://wp-types.com/documentation/user-guides/"><strong>%s</strong></a>'.__( ' - everything you need to know about using Toolset', 'wpv-views' ),
|
164 |
+
__( 'User Guides', 'wpv-views')
|
165 |
+
); ?>
|
166 |
+
</li>
|
167 |
+
<li>
|
168 |
+
<?php printf(
|
169 |
+
'<a target="_blank" href="http://discover-wp.com/"><strong>%s</strong></a>'.__( ' - learn to use Toolset by experimenting with fully-functional learning sites', 'wpv-views' ),
|
170 |
+
__( 'Discover WP', 'wpv-views' )
|
171 |
+
); ?>
|
172 |
+
</li>
|
173 |
+
<li>
|
174 |
+
<?php printf(
|
175 |
+
'<a target="_blank" href="http://wp-types.com/forums/forum/support-2/"><strong>%s</strong></a>'.__( ' - online help by support staff', 'wpv-views' ),
|
176 |
+
__( 'Support forum', 'wpv-views' )
|
177 |
+
); ?>
|
178 |
+
</li>
|
179 |
+
</ul>
|
180 |
+
<h3 style="margin-top:3em;"><?php _e('Debug information', 'wpv-views'); ?></h3>
|
181 |
+
<p>
|
182 |
+
<?php printf(
|
183 |
+
__( 'For retrieving debug information if asked by a support person, use the <a href="%s">debug information</a> page.', 'wpv-views' ),
|
184 |
+
admin_url('admin.php?page=toolset-debug-information')
|
185 |
+
); ?>
|
186 |
+
</p>
|
187 |
+
</div>
|
188 |
+
<?php
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Add a help tab to any page on the Toolset menu, linking to the Toolset debug page.
|
193 |
+
*
|
194 |
+
* Note that we use a hook in admin_head so the help tab here is addded after the existing ones.
|
195 |
+
*
|
196 |
+
* @since 2.1
|
197 |
+
*/
|
198 |
+
|
199 |
+
public function add_debug_help_tab() {
|
200 |
+
|
201 |
+
add_action( 'admin_head', array( $this, 'add_debug_help_tab_in_admin_head' ), 90 );
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
public function add_debug_help_tab_in_admin_head() {
|
206 |
+
if (
|
207 |
+
isset( $_GET['page'] )
|
208 |
+
&& $_GET['page'] == 'toolset-debug-information'
|
209 |
+
) {
|
210 |
+
return;
|
211 |
+
}
|
212 |
+
$screen = get_current_screen();
|
213 |
+
$screen->add_help_tab(
|
214 |
+
array(
|
215 |
+
'id' => 'toolset-debug-information',
|
216 |
+
'title' => __('Toolset Debug', 'wpv-views'),
|
217 |
+
'content' => '<p>'
|
218 |
+
. sprintf(
|
219 |
+
__( 'Need help? Grab some %1$sdebug information%2$s.', 'wpv-views' ),
|
220 |
+
'<a href="' . admin_url( 'admin.php?page=toolset-debug-information' ) . '">',
|
221 |
+
'</a>'
|
222 |
+
)
|
223 |
+
. '</p>',
|
224 |
+
)
|
225 |
+
);
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Register the Toolset debug page on the Toolset menu, on demand.
|
230 |
+
*
|
231 |
+
* @since 2.1
|
232 |
+
*/
|
233 |
+
|
234 |
+
public function register_debug_page_in_menu( $pages ) {
|
235 |
+
if (
|
236 |
+
isset( $_GET['page'] )
|
237 |
+
&& $_GET['page'] == 'toolset-debug-information'
|
238 |
+
) {
|
239 |
+
$pages[] = array(
|
240 |
+
'slug' => 'toolset-debug-information',
|
241 |
+
'menu_title' => __( 'Toolset Debug', 'wpv-views' ),
|
242 |
+
'page_title' => __( 'Toolset Debug', 'wpv-views' ),
|
243 |
+
'callback' => array( $this, 'debug_page' )
|
244 |
+
);
|
245 |
+
}
|
246 |
+
return $pages;
|
247 |
+
}
|
248 |
+
|
249 |
+
public function debug_page() {
|
250 |
+
$toolset_common_bootstrap = Toolset_Common_Bootstrap::getInstance();
|
251 |
+
$toolset_common_sections = array(
|
252 |
+
'toolset_debug'
|
253 |
+
);
|
254 |
+
$toolset_common_bootstrap->load_sections( $toolset_common_sections );
|
255 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
|
257 |
}
|
258 |
|
259 |
+
}
|
library/toolset/toolset-common/inc/toolset.settings.screen.class.php
CHANGED
@@ -42,8 +42,8 @@ if ( ! class_exists( 'Toolset_Settings_Screen' ) ) {
|
|
42 |
public function register_settings_page_in_menu( $pages ) {
|
43 |
$pages[] = array(
|
44 |
'slug' => 'toolset-settings',
|
45 |
-
'menu_title' => __( 'Settings', '
|
46 |
-
'page_title' => __( 'Settings', '
|
47 |
'callback' => array( $this, 'settings_page' )
|
48 |
);
|
49 |
return $pages;
|
@@ -53,6 +53,7 @@ if ( ! class_exists( 'Toolset_Settings_Screen' ) ) {
|
|
53 |
// Admin bar settings
|
54 |
add_filter( 'toolset_filter_toolset_register_settings_general_section', array( $this, 'toolset_admin_bar_settings' ), 10, 2 );
|
55 |
add_action( 'wp_ajax_toolset_update_toolset_admin_bar_options', array( $this, 'toolset_update_toolset_admin_bar_options' ) );
|
|
|
56 |
}
|
57 |
|
58 |
|
@@ -116,7 +117,17 @@ if ( ! class_exists( 'Toolset_Settings_Screen' ) ) {
|
|
116 |
<?php echo $settings_menu; ?>
|
117 |
</p>
|
118 |
<?php echo $settings_content; ?>
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
</div>
|
121 |
<?php
|
122 |
}
|
@@ -215,7 +226,7 @@ if ( ! class_exists( 'Toolset_Settings_Screen' ) ) {
|
|
215 |
wp_send_json_error( $data );
|
216 |
}
|
217 |
$frontend = ( isset( $_POST['frontend'] ) ) ? sanitize_text_field( $_POST['frontend'] ) : 'true';
|
218 |
-
$backend =
|
219 |
if ( null != $backend ) {
|
220 |
$toolset_options['shortcodes_generator'] = $backend;
|
221 |
}
|
@@ -223,6 +234,13 @@ if ( ! class_exists( 'Toolset_Settings_Screen' ) ) {
|
|
223 |
$toolset_options->save();
|
224 |
wp_send_json_success();
|
225 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
|
227 |
}
|
228 |
|
42 |
public function register_settings_page_in_menu( $pages ) {
|
43 |
$pages[] = array(
|
44 |
'slug' => 'toolset-settings',
|
45 |
+
'menu_title' => __( 'Settings', 'wpv-views' ),
|
46 |
+
'page_title' => __( 'Settings', 'wpv-views' ),
|
47 |
'callback' => array( $this, 'settings_page' )
|
48 |
);
|
49 |
return $pages;
|
53 |
// Admin bar settings
|
54 |
add_filter( 'toolset_filter_toolset_register_settings_general_section', array( $this, 'toolset_admin_bar_settings' ), 10, 2 );
|
55 |
add_action( 'wp_ajax_toolset_update_toolset_admin_bar_options', array( $this, 'toolset_update_toolset_admin_bar_options' ) );
|
56 |
+
add_filter( 'toolset_filter_force_unset_shortcode_generator_option', array( $this, 'force_unset_shortcode_generator_option_to_disable' ), 99 );
|
57 |
}
|
58 |
|
59 |
|
117 |
<?php echo $settings_menu; ?>
|
118 |
</p>
|
119 |
<?php echo $settings_content; ?>
|
120 |
+
<div class="toolset-debug-info-helper">
|
121 |
+
<p>
|
122 |
+
<?php
|
123 |
+
echo sprintf(
|
124 |
+
__( 'Need help? Grab some %1$sdebug information%2$s.', 'wpv-views' ),
|
125 |
+
'<a href="' . admin_url( 'admin.php?page=toolset-debug-information' ) . '">',
|
126 |
+
'</a>'
|
127 |
+
);
|
128 |
+
?>
|
129 |
+
</p>
|
130 |
+
</div>
|
131 |
</div>
|
132 |
<?php
|
133 |
}
|
226 |
wp_send_json_error( $data );
|
227 |
}
|
228 |
$frontend = ( isset( $_POST['frontend'] ) ) ? sanitize_text_field( $_POST['frontend'] ) : 'true';
|
229 |
+
$backend = ( isset( $_POST['backend'] ) && in_array( $_POST['backend'], array( 'disable', 'editor', 'always' ) ) ) ? sanitize_text_field( $_POST['backend'] ) : null;
|
230 |
if ( null != $backend ) {
|
231 |
$toolset_options['shortcodes_generator'] = $backend;
|
232 |
}
|
234 |
$toolset_options->save();
|
235 |
wp_send_json_success();
|
236 |
}
|
237 |
+
|
238 |
+
public function force_unset_shortcode_generator_option_to_disable( $state ) {
|
239 |
+
if ( $state == 'unset' ) {
|
240 |
+
$state = 'disable';
|
241 |
+
}
|
242 |
+
return $state;
|
243 |
+
}
|
244 |
|
245 |
}
|
246 |
|
library/toolset/toolset-common/loader.php
CHANGED
@@ -29,8 +29,8 @@
|
|
29 |
* we define the version here
|
30 |
*/
|
31 |
|
|
|
32 |
|
33 |
-
$toolset_common_version = 200016;
|
34 |
|
35 |
// ----------------------------------------------------------------------//
|
36 |
// WARNING * WARNING * WARNING
|
@@ -66,8 +66,7 @@ if ( ! function_exists( 'toolset_common_plugins_loaded' ) ) {
|
|
66 |
toolset_common_set_constants_and_start( $toolset_common_paths[ $latest ]['url'] );
|
67 |
}
|
68 |
}
|
69 |
-
|
70 |
-
add_action( 'plugins_loaded', 'toolset_common_plugins_loaded' );
|
71 |
}
|
72 |
|
73 |
if ( ! function_exists( 'toolset_common_initialize' ) ) {
|
29 |
* we define the version here
|
30 |
*/
|
31 |
|
32 |
+
$toolset_common_version = 200093;
|
33 |
|
|
|
34 |
|
35 |
// ----------------------------------------------------------------------//
|
36 |
// WARNING * WARNING * WARNING
|
66 |
toolset_common_set_constants_and_start( $toolset_common_paths[ $latest ]['url'] );
|
67 |
}
|
68 |
}
|
69 |
+
add_action( 'plugins_loaded', 'toolset_common_plugins_loaded', -1 );
|
|
|
70 |
}
|
71 |
|
72 |
if ( ! function_exists( 'toolset_common_initialize' ) ) {
|
library/toolset/toolset-common/res/css/toolset-common.css
CHANGED
@@ -174,7 +174,8 @@ Common styles for all the Toolset family
|
|
174 |
Toolset Primary Button Style - use with .button.button-primary-toolset classnames
|
175 |
---------------------------------------------------------------------------- */
|
176 |
|
177 |
-
.wp-core-ui .button-primary-toolset
|
|
|
178 |
background: #f6921e;
|
179 |
border-color: #EF6223;
|
180 |
-webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5), 0 1px 0 rgba(0,0,0,.15);
|
@@ -187,7 +188,11 @@ Toolset Primary Button Style - use with .button.button-primary-toolset classname
|
|
187 |
.wp-core-ui .button-primary-toolset.hover,
|
188 |
.wp-core-ui .button-primary-toolset:hover,
|
189 |
.wp-core-ui .button-primary-toolset.focus,
|
190 |
-
.wp-core-ui .button-primary-toolset:focus
|
|
|
|
|
|
|
|
|
191 |
background: #EF6223;
|
192 |
border-color: #EF6223;
|
193 |
-webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5);
|
174 |
Toolset Primary Button Style - use with .button.button-primary-toolset classnames
|
175 |
---------------------------------------------------------------------------- */
|
176 |
|
177 |
+
.wp-core-ui .button-primary-toolset,
|
178 |
+
.wp-core-ui .button.button-primary-toolset {
|
179 |
background: #f6921e;
|
180 |
border-color: #EF6223;
|
181 |
-webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5), 0 1px 0 rgba(0,0,0,.15);
|
188 |
.wp-core-ui .button-primary-toolset.hover,
|
189 |
.wp-core-ui .button-primary-toolset:hover,
|
190 |
.wp-core-ui .button-primary-toolset.focus,
|
191 |
+
.wp-core-ui .button-primary-toolset:focus,
|
192 |
+
.wp-core-ui .button.button-primary-toolset.hover,
|
193 |
+
.wp-core-ui .button.button-primary-toolset:hover,
|
194 |
+
.wp-core-ui .button.button-primary-toolset.focus,
|
195 |
+
.wp-core-ui .button.button-primary-toolset:focus {
|
196 |
background: #EF6223;
|
197 |
border-color: #EF6223;
|
198 |
-webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5);
|
library/toolset/toolset-common/res/lib/toolset-event-manager/toolset-event-manager.js
ADDED
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
( function( window, undefined ) {
|
2 |
+
'use strict';
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Handles managing all events for whatever you plug it into. Priorities for hooks are based on lowest to highest in
|
6 |
+
* that, lowest priority hooks are fired first.
|
7 |
+
*/
|
8 |
+
var EventManager = function() {
|
9 |
+
var slice = Array.prototype.slice;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Maintain a reference to the object scope so our public methods never get confusing.
|
13 |
+
*/
|
14 |
+
var MethodsAvailable = {
|
15 |
+
removeFilter : removeFilter,
|
16 |
+
applyFilters : applyFilters,
|
17 |
+
addFilter : addFilter,
|
18 |
+
removeAction : removeAction,
|
19 |
+
doAction : doAction,
|
20 |
+
addAction : addAction
|
21 |
+
};
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Contains the hooks that get registered with this EventManager. The array for storage utilizes a "flat"
|
25 |
+
* object literal such that looking up the hook utilizes the native object literal hash.
|
26 |
+
*/
|
27 |
+
var STORAGE = {
|
28 |
+
actions : {},
|
29 |
+
filters : {}
|
30 |
+
};
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Adds an action to the event manager.
|
34 |
+
*
|
35 |
+
* @param action Must contain namespace.identifier
|
36 |
+
* @param callback Must be a valid callback function before this action is added
|
37 |
+
* @param [priority=10] Used to control when the function is executed in relation to other callbacks bound to the same hook
|
38 |
+
* @param [context] Supply a value to be used for this
|
39 |
+
*/
|
40 |
+
function addAction( action, callback, priority, context ) {
|
41 |
+
if( typeof action === 'string' && typeof callback === 'function' ) {
|
42 |
+
priority = parseInt( ( priority || 10 ), 10 );
|
43 |
+
_addHook( 'actions', action, callback, priority, context );
|
44 |
+
}
|
45 |
+
|
46 |
+
return MethodsAvailable;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Performs an action if it exists. You can pass as many arguments as you want to this function; the only rule is
|
51 |
+
* that the first argument must always be the action.
|
52 |
+
*/
|
53 |
+
function doAction( /* action, arg1, arg2, ... */ ) {
|
54 |
+
var args = slice.call( arguments );
|
55 |
+
var action = args.shift();
|
56 |
+
|
57 |
+
if( typeof action === 'string' ) {
|
58 |
+
_runHook( 'actions', action, args );
|
59 |
+
}
|
60 |
+
|
61 |
+
return MethodsAvailable;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Removes the specified action if it contains a namespace.identifier & exists.
|
66 |
+
*
|
67 |
+
* @param action The action to remove
|
68 |
+
* @param [callback] Callback function to remove
|
69 |
+
*/
|
70 |
+
function removeAction( action, callback ) {
|
71 |
+
if( typeof action === 'string' ) {
|
72 |
+
_removeHook( 'actions', action, callback );
|
73 |
+
}
|
74 |
+
|
75 |
+
return MethodsAvailable;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Adds a filter to the event manager.
|
80 |
+
*
|
81 |
+
* @param filter Must contain namespace.identifier
|
82 |
+
* @param callback Must be a valid callback function before this action is added
|
83 |
+
* @param [priority=10] Used to control when the function is executed in relation to other callbacks bound to the same hook
|
84 |
+
* @param [context] Supply a value to be used for this
|
85 |
+
*/
|
86 |
+
function addFilter( filter, callback, priority, context ) {
|
87 |
+
if( typeof filter === 'string' && typeof callback === 'function' ) {
|
88 |
+
priority = parseInt( ( priority || 10 ), 10 );
|
89 |
+
_addHook( 'filters', filter, callback, priority, context );
|
90 |
+
}
|
91 |
+
|
92 |
+
return MethodsAvailable;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Performs a filter if it exists. You should only ever pass 1 argument to be filtered. The only rule is that
|
97 |
+
* the first argument must always be the filter.
|
98 |
+
*/
|
99 |
+
function applyFilters( /* filter, filtered arg, arg2, ... */ ) {
|
100 |
+
var args = slice.call( arguments );
|
101 |
+
var filter = args.shift();
|
102 |
+
|
103 |
+
if( typeof filter === 'string' ) {
|
104 |
+
return _runHook( 'filters', filter, args );
|
105 |
+
}
|
106 |
+
|
107 |
+
return MethodsAvailable;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Removes the specified filter if it contains a namespace.identifier & exists.
|
112 |
+
*
|
113 |
+
* @param filter The action to remove
|
114 |
+
* @param [callback] Callback function to remove
|
115 |
+
*/
|
116 |
+
function removeFilter( filter, callback ) {
|
117 |
+
if( typeof filter === 'string') {
|
118 |
+
_removeHook( 'filters', filter, callback );
|
119 |
+
}
|
120 |
+
|
121 |
+
return MethodsAvailable;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Removes the specified hook by resetting the value of it.
|
126 |
+
*
|
127 |
+
* @param type Type of hook, either 'actions' or 'filters'
|
128 |
+
* @param hook The hook (namespace.identifier) to remove
|
129 |
+
* @private
|
130 |
+
*/
|
131 |
+
function _removeHook( type, hook, callback, context ) {
|
132 |
+
var handlers, handler, i;
|
133 |
+
|
134 |
+
if ( !STORAGE[ type ][ hook ] ) {
|
135 |
+
return;
|
136 |
+
}
|
137 |
+
if ( !callback ) {
|
138 |
+
STORAGE[ type ][ hook ] = [];
|
139 |
+
} else {
|
140 |
+
handlers = STORAGE[ type ][ hook ];
|
141 |
+
if ( !context ) {
|
142 |
+
for ( i = handlers.length; i--; ) {
|
143 |
+
if ( handlers[i].callback === callback ) {
|
144 |
+
handlers.splice( i, 1 );
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
else {
|
149 |
+
for ( i = handlers.length; i--; ) {
|
150 |
+
handler = handlers[i];
|
151 |
+
if ( handler.callback === callback && handler.context === context) {
|
152 |
+
handlers.splice( i, 1 );
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
/**
|
160 |
+
* Adds the hook to the appropriate storage container
|
161 |
+
*
|
162 |
+
* @param type 'actions' or 'filters'
|
163 |
+
* @param hook The hook (namespace.identifier) to add to our event manager
|
164 |
+
* @param callback The function that will be called when the hook is executed.
|
165 |
+
* @param priority The priority of this hook. Must be an integer.
|
166 |
+
* @param [context] A value to be used for this
|
167 |
+
* @private
|
168 |
+
*/
|
169 |
+
function _addHook( type, hook, callback, priority, context ) {
|
170 |
+
var hookObject = {
|
171 |
+
callback : callback,
|
172 |
+
priority : priority,
|
173 |
+
context : context
|
174 |
+
};
|
175 |
+
|
176 |
+
// Utilize 'prop itself' : http://jsperf.com/hasownproperty-vs-in-vs-undefined/19
|
177 |
+
var hooks = STORAGE[ type ][ hook ];
|
178 |
+
if( hooks ) {
|
179 |
+
hooks.push( hookObject );
|
180 |
+
hooks = _hookInsertSort( hooks );
|
181 |
+
}
|
182 |
+
else {
|
183 |
+
hooks = [ hookObject ];
|
184 |
+
}
|
185 |
+
|
186 |
+
STORAGE[ type ][ hook ] = hooks;
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Use an insert sort for keeping our hooks organized based on priority. This function is ridiculously faster
|
191 |
+
* than bubble sort, etc: http://jsperf.com/javascript-sort
|
192 |
+
*
|
193 |
+
* @param hooks The custom array containing all of the appropriate hooks to perform an insert sort on.
|
194 |
+
* @private
|
195 |
+
*/
|
196 |
+
function _hookInsertSort( hooks ) {
|
197 |
+
var tmpHook, j, prevHook;
|
198 |
+
for( var i = 1, len = hooks.length; i < len; i++ ) {
|
199 |
+
tmpHook = hooks[ i ];
|
200 |
+
j = i;
|
201 |
+
while( ( prevHook = hooks[ j - 1 ] ) && prevHook.priority > tmpHook.priority ) {
|
202 |
+
hooks[ j ] = hooks[ j - 1 ];
|
203 |
+
--j;
|
204 |
+
}
|
205 |
+
hooks[ j ] = tmpHook;
|
206 |
+
}
|
207 |
+
|
208 |
+
return hooks;
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Runs the specified hook. If it is an action, the value is not modified but if it is a filter, it is.
|
213 |
+
*
|
214 |
+
* @param type 'actions' or 'filters'
|
215 |
+
* @param hook The hook ( namespace.identifier ) to be ran.
|
216 |
+
* @param args Arguments to pass to the action/filter. If it's a filter, args is actually a single parameter.
|
217 |
+
* @private
|
218 |
+
*/
|
219 |
+
function _runHook( type, hook, args ) {
|
220 |
+
var handlers = STORAGE[ type ][ hook ], i, len;
|
221 |
+
|
222 |
+
if ( !handlers ) {
|
223 |
+
return (type === 'filters') ? args[0] : false;
|
224 |
+
}
|
225 |
+
|
226 |
+
len = handlers.length;
|
227 |
+
if ( type === 'filters' ) {
|
228 |
+
for ( i = 0; i < len; i++ ) {
|
229 |
+
args[ 0 ] = handlers[ i ].callback.apply( handlers[ i ].context, args );
|
230 |
+
}
|
231 |
+
} else {
|
232 |
+
for ( i = 0; i < len; i++ ) {
|
233 |
+
handlers[ i ].callback.apply( handlers[ i ].context, args );
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
return ( type === 'filters' ) ? args[ 0 ] : true;
|
238 |
+
}
|
239 |
+
|
240 |
+
// return all of the publicly available methods
|
241 |
+
return MethodsAvailable;
|
242 |
+
|
243 |
+
};
|
244 |
+
|
245 |
+
window.Toolset = window.Toolset || {};
|
246 |
+
window.Toolset.hooks = new EventManager();
|
247 |
+
|
248 |
+
} )( window );
|
library/toolset/toolset-common/res/lib/toolset-event-manager/toolset-event-manager.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
(function(b,c){var a=function(){var m=Array.prototype.slice;var n={removeFilter:e,applyFilters:g,addFilter:h,removeAction:f,doAction:j,addAction:k};var p={actions:{},filters:{}};function k(s,t,r,q){if(typeof s==="string"&&typeof t==="function"){r=parseInt((r||10),10);i("actions",s,t,r,q)}return n}function j(){var q=m.call(arguments);var r=q.shift();if(typeof r==="string"){d("actions",r,q)}return n}function f(q,r){if(typeof q==="string"){o("actions",q,r)}return n}function h(s,t,r,q){if(typeof s==="string"&&typeof t==="function"){r=parseInt((r||10),10);i("filters",s,t,r,q)}return n}function g(){var q=m.call(arguments);var r=q.shift();if(typeof r==="string"){return d("filters",r,q)}return n}function e(q,r){if(typeof q==="string"){o("filters",q,r)}return n}function o(u,v,w,s){var q,t,r;if(!p[u][v]){return}if(!w){p[u][v]=[]}else{q=p[u][v];if(!s){for(r=q.length;r--;){if(q[r].callback===w){q.splice(r,1)}}}else{for(r=q.length;r--;){t=q[r];if(t.callback===w&&t.context===s){q.splice(r,1)}}}}}function i(t,v,w,s,r){var u={callback:w,priority:s,context:r};var q=p[t][v];if(q){q.push(u);q=l(q)}else{q=[u]}p[t][v]=q}function l(r){var v,t,s;for(var u=1,q=r.length;u<q;u++){v=r[u];t=u;while((s=r[t-1])&&s.priority>v.priority){r[t]=r[t-1];--t}r[t]=v}return r}function d(u,v,s){var r=p[u][v],t,q;if(!r){return(u==="filters")?s[0]:false}q=r.length;if(u==="filters"){for(t=0;t<q;t++){s[0]=r[t].callback.apply(r[t].context,s)}}else{for(t=0;t<q;t++){r[t].callback.apply(r[t].context,s)}}return(u==="filters")?s[0]:true}return n};b.Toolset=b.Toolset||{};b.Toolset.hooks=new a()})(window);
|
library/toolset/toolset-common/toolset-common-loader.php
CHANGED
@@ -5,11 +5,11 @@ if ( class_exists( 'Toolset_Common_Bootstrap' ) ) {
|
|
5 |
};
|
6 |
|
7 |
if( !defined('TOOLSET_VERSION') ){
|
8 |
-
define('TOOLSET_VERSION', '2.
|
9 |
}
|
10 |
|
11 |
if ( ! defined('TOOLSET_COMMON_VERSION' ) ) {
|
12 |
-
define( 'TOOLSET_COMMON_VERSION', '1
|
13 |
}
|
14 |
|
15 |
if ( ! defined('TOOLSET_COMMON_PATH' ) ) {
|
@@ -22,7 +22,6 @@ if ( ! defined('TOOLSET_COMMON_DIR' ) ) {
|
|
22 |
|
23 |
require_once( TOOLSET_COMMON_PATH . '/bootstrap.php' );
|
24 |
|
25 |
-
|
26 |
if ( ! function_exists( 'toolset_common_boostrap' ) ) {
|
27 |
function toolset_common_boostrap() {
|
28 |
global $toolset_common_bootstrap;
|
@@ -61,4 +60,28 @@ if ( ! function_exists( 'toolset_common_boostrap' ) ) {
|
|
61 |
// Load early
|
62 |
// We register scripts and styles that are dependences for Toolset assets
|
63 |
add_action( 'after_setup_theme', 'toolset_common_boostrap' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
5 |
};
|
6 |
|
7 |
if( !defined('TOOLSET_VERSION') ){
|
8 |
+
define('TOOLSET_VERSION', '2.1');
|
9 |
}
|
10 |
|
11 |
if ( ! defined('TOOLSET_COMMON_VERSION' ) ) {
|
12 |
+
define( 'TOOLSET_COMMON_VERSION', '2.1' );
|
13 |
}
|
14 |
|
15 |
if ( ! defined('TOOLSET_COMMON_PATH' ) ) {
|
22 |
|
23 |
require_once( TOOLSET_COMMON_PATH . '/bootstrap.php' );
|
24 |
|
|
|
25 |
if ( ! function_exists( 'toolset_common_boostrap' ) ) {
|
26 |
function toolset_common_boostrap() {
|
27 |
global $toolset_common_bootstrap;
|
60 |
// Load early
|
61 |
// We register scripts and styles that are dependences for Toolset assets
|
62 |
add_action( 'after_setup_theme', 'toolset_common_boostrap' );
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
if( !function_exists('toolset_disable_wpml_admin_lang_switcher') ){
|
67 |
+
add_filter( 'wpml_show_admin_language_switcher', 'toolset_disable_wpml_admin_lang_switcher' );
|
68 |
+
function toolset_disable_wpml_admin_lang_switcher( $state ) {
|
69 |
+
global $pagenow;
|
70 |
+
|
71 |
+
$toolset_pages = array(
|
72 |
+
'toolset-settings', 'toolset-help', 'toolset-debug-information'
|
73 |
+
);
|
74 |
+
|
75 |
+
$toolset_pages = apply_filters( 'toolset_filter_disable_wpml_lang_switcher_in_admin', $toolset_pages );
|
76 |
+
|
77 |
+
if (
|
78 |
+
$pagenow == 'admin.php'
|
79 |
+
&& isset( $_GET['page'] )
|
80 |
+
&& in_array( $_GET['page'], $toolset_pages )
|
81 |
+
) {
|
82 |
+
$state = false;
|
83 |
+
}
|
84 |
+
return $state;
|
85 |
+
}
|
86 |
+
|
87 |
}
|
library/toolset/toolset-common/toolset-forms/classes/class.checkbox.php
CHANGED
@@ -18,6 +18,7 @@ class WPToolset_Field_Checkbox extends FieldFactory {
|
|
18 |
$value = $this->getValue();
|
19 |
$data = $this->getData();
|
20 |
$checked = null;
|
|
|
21 |
|
22 |
/**
|
23 |
* autocheck for new posts
|
@@ -35,7 +36,7 @@ class WPToolset_Field_Checkbox extends FieldFactory {
|
|
35 |
* if is a default value, there value is 1 or default_value
|
36 |
*/
|
37 |
if (
|
38 |
-
array_key_exists('default_value', $data) && ( 'y' === $value || $value === $data['default_value'])
|
39 |
) {
|
40 |
$checked = true;
|
41 |
}
|
@@ -44,6 +45,8 @@ class WPToolset_Field_Checkbox extends FieldFactory {
|
|
44 |
//if (!$checked&&$this->getValue()==1) {
|
45 |
// $checked=true;
|
46 |
//}
|
|
|
|
|
47 |
|
48 |
/**
|
49 |
* metaform
|
@@ -51,7 +54,7 @@ class WPToolset_Field_Checkbox extends FieldFactory {
|
|
51 |
$form = array(
|
52 |
'#type' => 'checkbox',
|
53 |
'#value' => $value,
|
54 |
-
'#default_value' =>
|
55 |
'#name' => $this->getName(),
|
56 |
'#description' => $this->getDescription(),
|
57 |
'#title' => $this->getTitle(),
|
18 |
$value = $this->getValue();
|
19 |
$data = $this->getData();
|
20 |
$checked = null;
|
21 |
+
$is_cred_generic_field = isset($data['options']['cred_generic']) && $data['options']['cred_generic']==1;
|
22 |
|
23 |
/**
|
24 |
* autocheck for new posts
|
36 |
* if is a default value, there value is 1 or default_value
|
37 |
*/
|
38 |
if (
|
39 |
+
array_key_exists('default_value', $data) && ( 'y' === $value || $value === $data['default_value']) && !$is_cred_generic_field
|
40 |
) {
|
41 |
$checked = true;
|
42 |
}
|
45 |
//if (!$checked&&$this->getValue()==1) {
|
46 |
// $checked=true;
|
47 |
//}
|
48 |
+
$default_value = array_key_exists('default_value', $data) ? $data['default_value'] : "";
|
49 |
+
if ($is_cred_generic_field && !$checked) $default_value = "";
|
50 |
|
51 |
/**
|
52 |
* metaform
|
54 |
$form = array(
|
55 |
'#type' => 'checkbox',
|
56 |
'#value' => $value,
|
57 |
+
'#default_value' => $default_value,
|
58 |
'#name' => $this->getName(),
|
59 |
'#description' => $this->getDescription(),
|
60 |
'#title' => $this->getTitle(),
|
library/toolset/toolset-common/toolset-forms/classes/class.credfile.php
CHANGED
@@ -68,11 +68,9 @@ class WPToolset_Field_Credfile extends WPToolset_Field_Textfield {
|
|
68 |
|
69 |
wp_enqueue_style('progress_bar-style', $stylepath . 'progress_bar.css');
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
wp_enqueue_script('jquery-ui-script', $scriptpath . 'jquery-ui.min.js', array('jquery'), '', true);
|
75 |
-
wp_enqueue_script('jquery-ui-widget-script', $scriptpath . 'jquery.ui.widget.js', array('jquery'), '', true);
|
76 |
//wp_enqueue_script('jtmpl-script', $scriptpath . 'tmpl.min.js', array('jquery'), '', true);
|
77 |
wp_enqueue_script('load-image-all-script', $scriptpath . 'load-image.all.min.js', array('jquery'), '', true);
|
78 |
//wp_enqueue_script('canvas-to-blob-script', $scriptpath . 'canvas-to-blob.min.js', array('jquery'), '', true);
|
@@ -137,14 +135,14 @@ class WPToolset_Field_Credfile extends WPToolset_Field_Textfield {
|
|
137 |
$delete_input_showhide = ' style="display:none"';
|
138 |
}
|
139 |
|
140 |
-
if ($name == '_featured_image') {
|
141 |
-
$title = __('Featured Image', 'wpv-views');
|
142 |
-
if (!$is_empty) {
|
143 |
-
if (preg_match('/src="([\w\d\:\/\._-]*)"/', $value, $_v)) {
|
144 |
-
$value = $_v[1];
|
145 |
-
}
|
146 |
-
}
|
147 |
-
}
|
148 |
|
149 |
if (!$is_empty) {
|
150 |
$pathinfo = pathinfo($value);
|
@@ -186,10 +184,10 @@ class WPToolset_Field_Credfile extends WPToolset_Field_Textfield {
|
|
186 |
'#type' => 'markup',
|
187 |
'#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')) . '" />',
|
188 |
);
|
189 |
-
$form[] = array(
|
190 |
-
'#type' => 'markup',
|
191 |
-
'#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')) . '" />',
|
192 |
-
);
|
193 |
$form[] = array(
|
194 |
'#type' => 'hidden',
|
195 |
'#name' => $name,
|
@@ -217,9 +215,12 @@ class WPToolset_Field_Credfile extends WPToolset_Field_Textfield {
|
|
217 |
}
|
218 |
|
219 |
if ($has_image) {
|
|
|
|
|
|
|
220 |
$form[] = array(
|
221 |
'#type' => 'markup',
|
222 |
-
'#markup' => '<span class="js-wpt-credfile-preview
|
223 |
);
|
224 |
} else {
|
225 |
//if ( !$is_empty )
|
68 |
|
69 |
wp_enqueue_style('progress_bar-style', $stylepath . 'progress_bar.css');
|
70 |
|
71 |
+
wp_enqueue_script('jquery-ui-core');
|
72 |
+
wp_enqueue_script('jquery-ui-widget');
|
73 |
+
wp_enqueue_script('jquery-ui-progressbar');
|
|
|
|
|
74 |
//wp_enqueue_script('jtmpl-script', $scriptpath . 'tmpl.min.js', array('jquery'), '', true);
|
75 |
wp_enqueue_script('load-image-all-script', $scriptpath . 'load-image.all.min.js', array('jquery'), '', true);
|
76 |
//wp_enqueue_script('canvas-to-blob-script', $scriptpath . 'canvas-to-blob.min.js', array('jquery'), '', true);
|
135 |
$delete_input_showhide = ' style="display:none"';
|
136 |
}
|
137 |
|
138 |
+
// if ($name == '_featured_image') {
|
139 |
+
// $title = __('Featured Image', 'wpv-views');
|
140 |
+
// if (!$is_empty) {
|
141 |
+
// if (preg_match('/src="([\w\d\:\/\._-]*)"/', $value, $_v)) {
|
142 |
+
// $value = $_v[1];
|
143 |
+
// }
|
144 |
+
// }
|
145 |
+
// }
|
146 |
|
147 |
if (!$is_empty) {
|
148 |
$pathinfo = pathinfo($value);
|
184 |
'#type' => 'markup',
|
185 |
'#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')) . '" />',
|
186 |
);
|
187 |
+
// $form[] = array(
|
188 |
+
// '#type' => 'markup',
|
189 |
+
// '#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')) . '" />',
|
190 |
+
// );
|
191 |
$form[] = array(
|
192 |
'#type' => 'hidden',
|
193 |
'#name' => $name,
|
215 |
}
|
216 |
|
217 |
if ($has_image) {
|
218 |
+
//$delete_butt = "<input id='butt_{$id}' style='width:100%;margin-top:2px;margin-bottom:2px;' type='button' value='" . __('delete', 'wpv-views') . "' rel='{$preview_file}' class='delete_ajax_file'>";
|
219 |
+
$delete_butt = '<input type="button"' . $delete_input_showhide . ' data-action="delete" class="js-wpt-credfile-delete wpt-credfile-delete' . $button_extra_classnames . '" value="' . __('delete', 'wpv-views') . '" style="width:100%;margin-top:2px;margin-bottom:2px;" />';
|
220 |
+
|
221 |
$form[] = array(
|
222 |
'#type' => 'markup',
|
223 |
+
'#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" style="max-width:150px"/>' . $delete_butt . '</span>',
|
224 |
);
|
225 |
} else {
|
226 |
//if ( !$is_empty )
|
library/toolset/toolset-common/toolset-forms/classes/class.fieldconfig.php
CHANGED
@@ -27,11 +27,20 @@ if (!class_exists("FieldConfig")) {
|
|
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) {
|
36 |
$this->repetitive = $repetitive;
|
37 |
}
|
@@ -59,11 +68,25 @@ if (!class_exists("FieldConfig")) {
|
|
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 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
break;
|
68 |
|
69 |
case 'select':
|
@@ -76,8 +99,17 @@ if (!class_exists("FieldConfig")) {
|
|
76 |
break;
|
77 |
}
|
78 |
}
|
79 |
-
} else
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
break;
|
82 |
|
83 |
case 'radios':
|
@@ -85,13 +117,11 @@ if (!class_exists("FieldConfig")) {
|
|
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 |
}
|
@@ -105,8 +135,8 @@ if (!class_exists("FieldConfig")) {
|
|
105 |
case 'checkboxes':
|
106 |
$actual_titles = isset($attrs['actual_titles']) ? $attrs['actual_titles'] : array();
|
107 |
foreach ($actual_titles as $refvalue => $title) {
|
108 |
-
$
|
109 |
-
$arr[$refvalue] = array('value' => $refvalue, 'title' => $title, 'name' => $name, 'data-value' => $
|
110 |
if (in_array($refvalue, $attrs['default'])) {
|
111 |
$arr[$refvalue]['checked'] = true;
|
112 |
}
|
@@ -126,11 +156,11 @@ if (!class_exists("FieldConfig")) {
|
|
126 |
$actual_titles = isset($attrs['actual_titles']) ? $attrs['actual_titles'] : array();
|
127 |
foreach ($actual_titles as $refvalue => $title) {
|
128 |
$arr[$refvalue] = array(
|
129 |
-
'value' => $refvalue,
|
130 |
'title' => $title,
|
131 |
'checked' => false,
|
132 |
'name' => $refvalue,
|
133 |
-
'types-value' => $
|
134 |
);
|
135 |
}
|
136 |
break;
|
@@ -157,7 +187,8 @@ if (!class_exists("FieldConfig")) {
|
|
157 |
'add_time' => $this->getAddTime(),
|
158 |
'validation' => array(),
|
159 |
'display' => $this->getDisplay(),
|
160 |
-
'attribute' => $this->getAttr()
|
|
|
161 |
);
|
162 |
return $this->config;
|
163 |
}
|
27 |
private $validation = array();
|
28 |
private $attr;
|
29 |
private $add_time = false;
|
30 |
+
private $form_settings;
|
31 |
|
32 |
public function __construct() {
|
33 |
|
34 |
}
|
35 |
|
36 |
+
public function getForm_settings() {
|
37 |
+
return $this->form_settings;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function setForm_settings($form_settings) {
|
41 |
+
$this->form_settings = $form_settings;
|
42 |
+
}
|
43 |
+
|
44 |
public function setRepetitive($repetitive) {
|
45 |
$this->repetitive = $repetitive;
|
46 |
}
|
68 |
if (isset($field_arr['data']['date_and_time']) && 'and_time' == $field_arr['data']['date_and_time']) {
|
69 |
$this->add_time = true;
|
70 |
}
|
71 |
+
if (isset($field_arr['value']['timestamp'])) {
|
72 |
+
$this->default_value = array('timestamp' => $field_arr['value']['timestamp']);
|
73 |
+
} else {
|
74 |
+
//In Edit + Ajax call the object contains array of 5 elements timestamps only 1 and 5 (starting from 0) contains number timestamp
|
75 |
+
if (isset($field_arr['value'][1]['timestamp']) &&
|
76 |
+
is_numeric($field_arr['value'][1]['timestamp']))
|
77 |
+
$this->default_value = array('timestamp' => $field_arr['value'][1]['timestamp']);
|
78 |
+
}
|
79 |
break;
|
80 |
case 'checkboxes':
|
81 |
+
/* Output for Toolset common must be:
|
82 |
+
* [option_key] => 1
|
83 |
+
*/
|
84 |
+
$def = array();
|
85 |
+
if (!empty($field_arr['value']))
|
86 |
+
foreach ($field_arr['value'] as $n => $value) {
|
87 |
+
$def[$value] = 1;
|
88 |
+
}
|
89 |
+
$this->default_value = $def;
|
90 |
break;
|
91 |
|
92 |
case 'select':
|
99 |
break;
|
100 |
}
|
101 |
}
|
102 |
+
} else {
|
103 |
+
if (isset($field_arr['attr']['actual_value'])) {
|
104 |
+
//This value is not array if from parent
|
105 |
+
if (is_array($field_arr['attr']['actual_value']))
|
106 |
+
$this->default_value = isset($field_arr['attr']['actual_value'][0]) ? $field_arr['attr']['actual_value'][0] : null;
|
107 |
+
else
|
108 |
+
$this->default_value = isset($field_arr['attr']['actual_value']) ? $field_arr['attr']['actual_value'] : null;
|
109 |
+
} else {
|
110 |
+
$this->default_value = null;
|
111 |
+
}
|
112 |
+
}
|
113 |
break;
|
114 |
|
115 |
case 'radios':
|
117 |
break;
|
118 |
|
119 |
case 'checkbox':
|
120 |
+
$this->default_value = $field_arr['value']; //isset($field_arr['data']['checked']) ? $field_arr['data']['checked'] : false;
|
|
|
|
|
121 |
break;
|
122 |
|
123 |
default:
|
124 |
+
$this->default_value = $field_arr['value'];
|
125 |
break;
|
126 |
}
|
127 |
}
|
135 |
case 'checkboxes':
|
136 |
$actual_titles = isset($attrs['actual_titles']) ? $attrs['actual_titles'] : array();
|
137 |
foreach ($actual_titles as $refvalue => $title) {
|
138 |
+
$_value = $attrs['actual_values'][$refvalue];
|
139 |
+
$arr[$refvalue] = array('value' => $refvalue, 'title' => $title, 'name' => $name, 'data-value' => $_value);
|
140 |
if (in_array($refvalue, $attrs['default'])) {
|
141 |
$arr[$refvalue]['checked'] = true;
|
142 |
}
|
156 |
$actual_titles = isset($attrs['actual_titles']) ? $attrs['actual_titles'] : array();
|
157 |
foreach ($actual_titles as $refvalue => $title) {
|
158 |
$arr[$refvalue] = array(
|
159 |
+
'value' => $attrs['actual_values'][$refvalue],
|
160 |
'title' => $title,
|
161 |
'checked' => false,
|
162 |
'name' => $refvalue,
|
163 |
+
'types-value' => $refvalue,
|
164 |
);
|
165 |
}
|
166 |
break;
|
187 |
'add_time' => $this->getAddTime(),
|
188 |
'validation' => array(),
|
189 |
'display' => $this->getDisplay(),
|
190 |
+
'attribute' => $this->getAttr(),
|
191 |
+
'form_settings' => $this->getForm_settings()
|
192 |
);
|
193 |
return $this->config;
|
194 |
}
|
library/toolset/toolset-common/toolset-forms/classes/class.form_factory.php
CHANGED
@@ -332,10 +332,10 @@ class FormFactory extends FormAbstract
|
|
332 |
return $field;
|
333 |
}
|
334 |
|
335 |
-
protected function _checkValidation( $config ) {
|
336 |
if ( isset( $config['validation'] ) && is_null( $this->_validation ) ) {
|
337 |
require_once 'class.validation.php';
|
338 |
-
$this->_validation = new WPToolset_Forms_Validation( $this->nameForm );
|
339 |
}
|
340 |
}
|
341 |
|
332 |
return $field;
|
333 |
}
|
334 |
|
335 |
+
protected function _checkValidation( $config ) {
|
336 |
if ( isset( $config['validation'] ) && is_null( $this->_validation ) ) {
|
337 |
require_once 'class.validation.php';
|
338 |
+
$this->_validation = new WPToolset_Forms_Validation( $this->nameForm , isset($config['form_settings']) ? $config['form_settings'] : "" );
|
339 |
}
|
340 |
}
|
341 |
|
library/toolset/toolset-common/toolset-forms/classes/class.radios.php
CHANGED
@@ -20,17 +20,17 @@ class WPToolset_Field_Radios extends FieldFactory {
|
|
20 |
$form = array();
|
21 |
$options = array();
|
22 |
|
23 |
-
if (!is_admin()) {
|
24 |
-
$new_options = array();
|
25 |
-
foreach ($data['options'] as $key => $option) {
|
26 |
-
$tmp = $option['value'];
|
27 |
-
$option['value'] = $option['types-value'];
|
28 |
-
$option['types-value'] = $tmp;
|
29 |
-
$new_options[$key] = $option;
|
30 |
-
unset($tmp);
|
31 |
-
}
|
32 |
-
$data['options'] = $new_options;
|
33 |
-
}
|
34 |
|
35 |
foreach ($data['options'] as $option) {
|
36 |
$one_option_data = array(
|
@@ -103,7 +103,7 @@ class WPToolset_Field_Radios extends FieldFactory {
|
|
103 |
'wpml_action' => $this->getWPMLAction(),
|
104 |
'#after' => '<input type="hidden" name="_wptoolset_radios[' . $this->getId() . ']" value="1" />',
|
105 |
);
|
106 |
-
|
107 |
if (!is_admin()) {// TODO maybe add a doing_ajax() check too, what if we want to load a form using AJAX?
|
108 |
$form_attr['#before'] = '<ul class="wpt-form-set wpt-form-set-radios wpt-form-set-radios-' . $name . '">';
|
109 |
$form_attr['#after'] = '</ul>';
|
20 |
$form = array();
|
21 |
$options = array();
|
22 |
|
23 |
+
// if (!is_admin()) {
|
24 |
+
// $new_options = array();
|
25 |
+
// foreach ($data['options'] as $key => $option) {
|
26 |
+
// $tmp = $option['value'];
|
27 |
+
// $option['value'] = $option['types-value'];
|
28 |
+
// $option['types-value'] = $tmp;
|
29 |
+
// $new_options[$key] = $option;
|
30 |
+
// unset($tmp);
|
31 |
+
// }
|
32 |
+
// $data['options'] = $new_options;
|
33 |
+
// }
|
34 |
|
35 |
foreach ($data['options'] as $option) {
|
36 |
$one_option_data = array(
|
103 |
'wpml_action' => $this->getWPMLAction(),
|
104 |
'#after' => '<input type="hidden" name="_wptoolset_radios[' . $this->getId() . ']" value="1" />',
|
105 |
);
|
106 |
+
|
107 |
if (!is_admin()) {// TODO maybe add a doing_ajax() check too, what if we want to load a form using AJAX?
|
108 |
$form_attr['#before'] = '<ul class="wpt-form-set wpt-form-set-radios wpt-form-set-radios-' . $name . '">';
|
109 |
$form_attr['#after'] = '</ul>';
|
library/toolset/toolset-common/toolset-forms/classes/class.recaptcha.php
CHANGED
@@ -23,7 +23,7 @@ class WPToolset_Field_Recaptcha extends WPToolset_Field_Textfield {
|
|
23 |
$this->privkey = isset($attr['private_key']) ? $attr['private_key'] : '';
|
24 |
|
25 |
global $sitepress;
|
26 |
-
$lang = substr(get_locale(), 0
|
27 |
if (isset($sitepress)) {
|
28 |
if (isset($_GET['source_lang'])) {
|
29 |
$src_lang = $_GET['source_lang'];
|
@@ -60,7 +60,7 @@ class WPToolset_Field_Recaptcha extends WPToolset_Field_Textfield {
|
|
60 |
$capture = '';
|
61 |
if ($this->pubkey || !is_admin()) {
|
62 |
try {
|
63 |
-
$capture = '<div class="g-recaptcha" data-sitekey="' . $this->pubkey . '"></div>';
|
64 |
} catch (Exception $e) {
|
65 |
//https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188424989/comments
|
66 |
if (current_user_can('manage_options')) {
|
23 |
$this->privkey = isset($attr['private_key']) ? $attr['private_key'] : '';
|
24 |
|
25 |
global $sitepress;
|
26 |
+
$lang = substr(get_locale(), 0, 2);
|
27 |
if (isset($sitepress)) {
|
28 |
if (isset($_GET['source_lang'])) {
|
29 |
$src_lang = $_GET['source_lang'];
|
60 |
$capture = '';
|
61 |
if ($this->pubkey || !is_admin()) {
|
62 |
try {
|
63 |
+
$capture = '<div class="g-recaptcha" data-sitekey="' . $this->pubkey . '"></div><div class="recaptcha_error" style="color:#aa0000;display:none;">' . __('Please validate reCAPTCHA', 'wpv-views') . '</div>';
|
64 |
} catch (Exception $e) {
|
65 |
//https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/188424989/comments
|
66 |
if (current_user_can('manage_options')) {
|
library/toolset/toolset-common/toolset-forms/classes/class.taxonomy.php
CHANGED
@@ -13,7 +13,7 @@ class WPToolset_Field_Taxonomy extends WPToolset_Field_Textfield {
|
|
13 |
public function init() {
|
14 |
$this->objValues = array();
|
15 |
|
16 |
-
$terms = wp_get_post_terms(CredForm::$current_postid, $this->getName(), array("fields" => "all"));
|
17 |
$i = 0;
|
18 |
foreach ($terms as $n => $term) {
|
19 |
$this->values .= ($i == 0) ? $term->slug : "," . $term->slug;
|
@@ -21,12 +21,10 @@ class WPToolset_Field_Taxonomy extends WPToolset_Field_Textfield {
|
|
21 |
$i++;
|
22 |
}
|
23 |
|
24 |
-
wp_register_script('wptoolset-taxonomy-field',
|
25 |
-
|
26 |
-
array('wptoolset-forms'), WPTOOLSET_FORMS_VERSION, true);
|
27 |
-
|
28 |
wp_localize_script('wptoolset-taxonomy-field', 'wptoolset_taxonomy_settings', array(
|
29 |
-
'ajaxurl' => admin_url(
|
30 |
'values' => $this->values,
|
31 |
'name' => $this->getName(),
|
32 |
'form' => WPTOOLSET_FORMS_RELPATH,
|
@@ -34,18 +32,26 @@ class WPToolset_Field_Taxonomy extends WPToolset_Field_Textfield {
|
|
34 |
));
|
35 |
|
36 |
wp_enqueue_script('wptoolset-taxonomy-field');
|
37 |
-
|
38 |
//add_action('wp_footer', array($this, 'javascript_autocompleter'));
|
39 |
}
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
44 |
initTaxonomies("' . $this->values . '", "' . $this->getName() . '", "' . WPTOOLSET_FORMS_RELPATH . '", "' . $this->_nameField . '");
|
45 |
-
}
|
46 |
</script>';
|
47 |
}
|
48 |
|
|
|
|
|
|
|
|
|
49 |
public function metaform() {
|
50 |
$use_bootstrap = array_key_exists('use_bootstrap', $this->_data) && $this->_data['use_bootstrap'];
|
51 |
$attributes = $this->getAttr();
|
@@ -121,7 +127,7 @@ class WPToolset_Field_Taxonomy extends WPToolset_Field_Textfield {
|
|
121 |
'style' => $show ? '' : 'display:none;'
|
122 |
),
|
123 |
'#before' => $before,
|
124 |
-
'#after' => $after,
|
125 |
);
|
126 |
|
127 |
$this->set_metaform($metaform);
|
@@ -150,10 +156,10 @@ class WPToolset_Field_Taxonomy extends WPToolset_Field_Textfield {
|
|
150 |
<div style='position:relative;line-height:0.9em;margin:2px 0;<?php if ($tid != 0) echo 'margin-left:15px'; ?>' class='myzebra-taxonomy-hierarchical-checkbox'>
|
151 |
<label class='myzebra-style-label'><input type='checkbox' name='<?php echo $name; ?>' value='<?php echo $tid; ?>' <?php if (isset($values[$tid])) echo 'checked="checked"'; ?> /><span class="myzebra-checkbox-replace"></span>
|
152 |
<span class='myzebra-checkbox-label-span' style='position:relative;font-size:12px;display:inline-block;margin:0;padding:0;margin-left:15px'><?php echo $names[$tid]; ?></span></label>
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
</div>
|
158 |
<?php
|
159 |
}
|
13 |
public function init() {
|
14 |
$this->objValues = array();
|
15 |
|
16 |
+
$terms = apply_filters('toolset_filter_taxonomy_terms', wp_get_post_terms(CredForm::$current_postid, $this->getName(), array("fields" => "all")));
|
17 |
$i = 0;
|
18 |
foreach ($terms as $n => $term) {
|
19 |
$this->values .= ($i == 0) ? $term->slug : "," . $term->slug;
|
21 |
$i++;
|
22 |
}
|
23 |
|
24 |
+
wp_register_script('wptoolset-taxonomy-field', WPTOOLSET_FORMS_RELPATH . '/js/taxonomy.js', array('wptoolset-forms'), WPTOOLSET_FORMS_VERSION, true);
|
25 |
+
|
|
|
|
|
26 |
wp_localize_script('wptoolset-taxonomy-field', 'wptoolset_taxonomy_settings', array(
|
27 |
+
'ajaxurl' => admin_url('admin-ajax.php', null),
|
28 |
'values' => $this->values,
|
29 |
'name' => $this->getName(),
|
30 |
'form' => WPTOOLSET_FORMS_RELPATH,
|
32 |
));
|
33 |
|
34 |
wp_enqueue_script('wptoolset-taxonomy-field');
|
35 |
+
|
36 |
//add_action('wp_footer', array($this, 'javascript_autocompleter'));
|
37 |
}
|
38 |
|
39 |
+
/**
|
40 |
+
* function used when ajax is on in order to init taxonomies
|
41 |
+
* @return type
|
42 |
+
*/
|
43 |
+
public function initTaxonomyFunction() {
|
44 |
+
return '<script type="text/javascript">
|
45 |
+
function initCurrentTaxonomy() {
|
46 |
initTaxonomies("' . $this->values . '", "' . $this->getName() . '", "' . WPTOOLSET_FORMS_RELPATH . '", "' . $this->_nameField . '");
|
47 |
+
}
|
48 |
</script>';
|
49 |
}
|
50 |
|
51 |
+
/**
|
52 |
+
* metaform
|
53 |
+
* @return type
|
54 |
+
*/
|
55 |
public function metaform() {
|
56 |
$use_bootstrap = array_key_exists('use_bootstrap', $this->_data) && $this->_data['use_bootstrap'];
|
57 |
$attributes = $this->getAttr();
|
127 |
'style' => $show ? '' : 'display:none;'
|
128 |
),
|
129 |
'#before' => $before,
|
130 |
+
'#after' => $after . $this->initTaxonomyFunction(),
|
131 |
);
|
132 |
|
133 |
$this->set_metaform($metaform);
|
156 |
<div style='position:relative;line-height:0.9em;margin:2px 0;<?php if ($tid != 0) echo 'margin-left:15px'; ?>' class='myzebra-taxonomy-hierarchical-checkbox'>
|
157 |
<label class='myzebra-style-label'><input type='checkbox' name='<?php echo $name; ?>' value='<?php echo $tid; ?>' <?php if (isset($values[$tid])) echo 'checked="checked"'; ?> /><span class="myzebra-checkbox-replace"></span>
|
158 |
<span class='myzebra-checkbox-label-span' style='position:relative;font-size:12px;display:inline-block;margin:0;padding:0;margin-left:15px'><?php echo $names[$tid]; ?></span></label>
|
159 |
+
<?php
|
160 |
+
if (isset($childs[$tid]))
|
161 |
+
echo $this->buildCheckboxes($tid, $childs, $names);
|
162 |
+
?>
|
163 |
</div>
|
164 |
<?php
|
165 |
}
|
library/toolset/toolset-common/toolset-forms/classes/class.taxonomyhierarchical.php
CHANGED
@@ -19,7 +19,7 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield {
|
|
19 |
|
20 |
$this->objValues = array();
|
21 |
if (isset($post)) {
|
22 |
-
$terms = wp_get_post_terms($post->ID, $this->getName(), array("fields" => "all"));
|
23 |
foreach ($terms as $n => $term) {
|
24 |
$this->values[] = $term->slug;
|
25 |
$this->valuesId[] = $term->term_id;
|
@@ -29,8 +29,6 @@ class WPToolset_Field_Taxonomyhierarchical extends WPToolset_Field_Textfield {
|
|
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) {
|
19 |
|
20 |
$this->objValues = array();
|
21 |
if (isset($post)) {
|
22 |
+
$terms = apply_filters('toolset_filter_taxonomyhierarchical_terms', wp_get_post_terms($post->ID, $this->getName(), array("fields" => "all")));
|
23 |
foreach ($terms as $n => $term) {
|
24 |
$this->values[] = $term->slug;
|
25 |
$this->valuesId[] = $term->term_id;
|
29 |
|
30 |
$all = $this->buildTerms(get_terms($this->getName(), array('hide_empty' => 0, 'fields' => 'all')));
|
31 |
|
|
|
|
|
32 |
$childs = array();
|
33 |
$names = array();
|
34 |
foreach ($all as $term) {
|
library/toolset/toolset-common/toolset-forms/classes/class.validation.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
* Libraries
|
4 |
* - CakePHP library for PHP validation
|
@@ -18,44 +19,55 @@
|
|
18 |
*
|
19 |
* @author Srdjan
|
20 |
*/
|
21 |
-
class WPToolset_Forms_Validation
|
22 |
-
|
23 |
private $__formID;
|
|
|
24 |
protected $_cake;
|
25 |
protected $_rules_map = array(
|
26 |
'rangelength' => 'between',
|
27 |
'number' => 'numeric'
|
28 |
);
|
29 |
|
30 |
-
function __construct(
|
31 |
-
$this->__formID = trim(
|
|
|
|
|
32 |
// Register
|
33 |
-
wp_register_script(
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
44 |
|
45 |
// Filter JS validation data
|
46 |
-
add_action(
|
47 |
-
array($this, 'filterJsValidation') );
|
48 |
// Filter form field PHP validation
|
49 |
-
add_filter(
|
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(
|
56 |
-
add_action(
|
|
|
57 |
|
58 |
-
wp_enqueue_script(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
|
61 |
/**
|
@@ -64,25 +76,24 @@ class WPToolset_Forms_Validation
|
|
64 |
* @param type $rules
|
65 |
* @return type
|
66 |
*/
|
67 |
-
public function filterJsValidation(
|
68 |
-
foreach (
|
69 |
// Possible change of rule (like DateITA)
|
70 |
-
$_r = apply_filters(
|
71 |
-
if (
|
72 |
$rules[$_r] = $rule;
|
73 |
-
unset(
|
74 |
continue;
|
75 |
}
|
76 |
}
|
77 |
-
foreach (
|
78 |
-
$rule['args'] = apply_filters(
|
79 |
-
$rule['args'], $r );
|
80 |
// Remove value in args - search string '$value' or unset first element
|
81 |
-
$replace = array_search(
|
82 |
-
if (
|
83 |
-
unset(
|
84 |
} else {
|
85 |
-
array_shift(
|
86 |
}
|
87 |
// unset( $rule['message'] );
|
88 |
}
|
@@ -100,26 +111,24 @@ class WPToolset_Forms_Validation
|
|
100 |
* @param type $value
|
101 |
* @return type
|
102 |
*/
|
103 |
-
public function filterFormField(
|
104 |
-
$rules = $this->_parseRules(
|
105 |
// If not required but empty - skip
|
106 |
-
if (
|
107 |
-
&& ( is_null( $value ) || $value === false || $value === '' ) ) {
|
108 |
return true;
|
109 |
}
|
110 |
try {
|
111 |
$errors = array();
|
112 |
-
foreach (
|
113 |
-
if (
|
114 |
$errors[] = $args['message'];
|
115 |
}
|
116 |
}
|
117 |
-
if (
|
118 |
throw new Exception();
|
119 |
}
|
120 |
-
} catch (
|
121 |
-
$element['error'] =
|
122 |
-
'Field not validated', $errors );
|
123 |
}
|
124 |
return $element;
|
125 |
}
|
@@ -132,19 +141,18 @@ class WPToolset_Forms_Validation
|
|
132 |
* @return \WP_Error|boolean
|
133 |
* @throws Exception
|
134 |
*/
|
135 |
-
public function validateField(
|
136 |
-
$value = apply_filters(
|
137 |
-
$rules = $this->_parseRules(
|
138 |
// If not required but empty - skip
|
139 |
-
if (
|
140 |
-
&& ( is_null( $value ) || $value === false || $value === '' ) ) {
|
141 |
return true;
|
142 |
}
|
143 |
|
144 |
try {
|
145 |
$errors = array();
|
146 |
-
foreach (
|
147 |
-
if (
|
148 |
/**
|
149 |
* Allow turn off field name.
|
150 |
*
|
@@ -154,32 +162,30 @@ class WPToolset_Forms_Validation
|
|
154 |
*
|
155 |
* @param boolean $var show field title in message, * default true.
|
156 |
*/
|
157 |
-
if (
|
158 |
-
$errors[] = $field->getTitle() .
|
159 |
} else {
|
160 |
$errors[] = $args['message'];
|
161 |
}
|
162 |
}
|
163 |
}
|
164 |
-
if (
|
165 |
throw new Exception();
|
166 |
}
|
167 |
-
} catch (
|
168 |
-
return new WP_Error(
|
169 |
-
'Field not validated', $errors );
|
170 |
}
|
171 |
return true;
|
172 |
}
|
173 |
|
174 |
-
protected function _parseRules(
|
175 |
$_rules = array();
|
176 |
-
foreach (
|
177 |
-
$rule = apply_filters(
|
178 |
-
$args['args'] = apply_filters(
|
179 |
-
$args['args'], $rule );
|
180 |
// Set value in args - search string '$value' or replace first element
|
181 |
-
$replace = array_search(
|
182 |
-
if (
|
183 |
$args['args'][$replace] = $value;
|
184 |
} else {
|
185 |
$args['args'][0] = $value;
|
@@ -198,16 +204,16 @@ class WPToolset_Forms_Validation
|
|
198 |
* @param type $args
|
199 |
* @return boolean
|
200 |
*/
|
201 |
-
public function validate(
|
202 |
$validator = $this->_cake();
|
203 |
-
$rule = $this->_map_rule_js_to_php(
|
204 |
|
205 |
-
if (
|
206 |
return $validator->custom($args[0]['skypename'], '/^([a-zA-Z0-9\,\.\-\_]+)$/');
|
207 |
}
|
208 |
|
209 |
-
if (
|
210 |
-
return call_user_func_array(
|
211 |
}
|
212 |
return false;
|
213 |
}
|
@@ -218,7 +224,7 @@ class WPToolset_Forms_Validation
|
|
218 |
* @return type
|
219 |
*/
|
220 |
protected function _cake() {
|
221 |
-
if (
|
222 |
require_once WPTOOLSET_FORMS_ABSPATH . '/lib/CakePHP-Validation.php';
|
223 |
$this->_cake = new WPToolset_Cake_Validation;
|
224 |
}
|
@@ -231,8 +237,8 @@ class WPToolset_Forms_Validation
|
|
231 |
* @param type $rule
|
232 |
* @return type
|
233 |
*/
|
234 |
-
protected function _map_rule_js_to_php(
|
235 |
-
return isset(
|
236 |
}
|
237 |
|
238 |
/**
|
@@ -242,8 +248,8 @@ class WPToolset_Forms_Validation
|
|
242 |
printf('<script type="text/javascript">wptValidationForms.push("#%s");</script>', $this->__formID);
|
243 |
}
|
244 |
|
245 |
-
public function actionFieldClass(
|
246 |
-
if (
|
247 |
foreach ($config['validation'] as $rule => $data) {
|
248 |
echo " wpt-validation-{$rule}";
|
249 |
}
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
* Libraries
|
5 |
* - CakePHP library for PHP validation
|
19 |
*
|
20 |
* @author Srdjan
|
21 |
*/
|
22 |
+
class WPToolset_Forms_Validation {
|
23 |
+
|
24 |
private $__formID;
|
25 |
+
private $__formSET;
|
26 |
protected $_cake;
|
27 |
protected $_rules_map = array(
|
28 |
'rangelength' => 'between',
|
29 |
'number' => 'numeric'
|
30 |
);
|
31 |
|
32 |
+
function __construct($formID, $formSET) {
|
33 |
+
$this->__formID = trim($formID, '#');
|
34 |
+
$this->__formSET = $formSET;
|
35 |
+
|
36 |
// Register
|
37 |
+
wp_register_script('wptoolset-form-jquery-validation', WPTOOLSET_FORMS_RELPATH . '/lib/js/jquery-form-validation/jquery.validate.js', array('jquery'), WPTOOLSET_FORMS_VERSION, true);
|
38 |
+
wp_register_script('wptoolset-form-jquery-validation-additional', WPTOOLSET_FORMS_RELPATH . '/lib/js/jquery-form-validation/additional-methods.min.js', array('wptoolset-form-jquery-validation'), WPTOOLSET_FORMS_VERSION, true);
|
39 |
+
wp_register_script('wptoolset-form-validation', WPTOOLSET_FORMS_RELPATH . '/js/validation.js', array('wptoolset-form-jquery-validation-additional', 'underscore', 'toolset-utils'), WPTOOLSET_FORMS_VERSION, true);
|
40 |
+
|
41 |
+
$my_formID = str_replace("-", "_", $formID);
|
42 |
+
wp_localize_script('wptoolset-form-validation', 'cred_settings_' . $my_formID, array(
|
43 |
+
'form_id' => $formID,
|
44 |
+
'use_ajax' => (!is_admin() && isset($formSET->form['use_ajax']) && $formSET->form['use_ajax'] == 1) ? true : false,
|
45 |
+
'operation_ok' => __('Operation completed successfully', 'wpv-views'),
|
46 |
+
'operation_ko' => __('Operation not completed successfully', 'wpv-views'),
|
47 |
+
'delay_message' => __('You are being redirectd. Please Wait.', 'wpv-views')
|
48 |
+
)
|
49 |
+
);
|
50 |
|
51 |
// Filter JS validation data
|
52 |
+
add_action('wptoolset_forms_field_js_validation_data_' . $this->__formID, array($this, 'filterJsValidation'));
|
|
|
53 |
// Filter form field PHP validation
|
54 |
+
add_filter('wptoolset_form_' . $this->__formID . '_validate_field', array($this, 'filterFormField'), 10, 2);
|
|
|
55 |
// Render classes
|
56 |
+
add_action('wptoolset_field_class', array($this, 'actionFieldClass'));
|
57 |
|
58 |
// Render settings
|
59 |
+
add_action('admin_print_footer_scripts', array($this, 'renderJsonData'), 30);
|
60 |
+
add_action('wp_footer', array($this, 'renderJsonData'), 30);
|
61 |
+
add_action('wp_footer', array($this, 'loadCustomAssets'), 30);
|
62 |
|
63 |
+
wp_enqueue_script('wptoolset-form-validation');
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* loadCustomAssets
|
68 |
+
*/
|
69 |
+
public function loadCustomAssets() {
|
70 |
+
echo '<div class="wpt-modal"></div>';
|
71 |
}
|
72 |
|
73 |
/**
|
76 |
* @param type $rules
|
77 |
* @return type
|
78 |
*/
|
79 |
+
public function filterJsValidation($rules) {
|
80 |
+
foreach ($rules as $r => $rule) {
|
81 |
// Possible change of rule (like DateITA)
|
82 |
+
$_r = apply_filters('wptoolset_validation_rule_js', $r);
|
83 |
+
if ($_r != $r) {
|
84 |
$rules[$_r] = $rule;
|
85 |
+
unset($rules[$r]);
|
86 |
continue;
|
87 |
}
|
88 |
}
|
89 |
+
foreach ($rules as $r => &$rule) {
|
90 |
+
$rule['args'] = apply_filters('wptoolset_validation_args_js', $rule['args'], $r);
|
|
|
91 |
// Remove value in args - search string '$value' or unset first element
|
92 |
+
$replace = array_search('$value', $rule['args']);
|
93 |
+
if ($replace !== false) {
|
94 |
+
unset($rule['args'][$replace]);
|
95 |
} else {
|
96 |
+
array_shift($rule['args']);
|
97 |
}
|
98 |
// unset( $rule['message'] );
|
99 |
}
|
111 |
* @param type $value
|
112 |
* @return type
|
113 |
*/
|
114 |
+
public function filterFormField($element, $value) {
|
115 |
+
$rules = $this->_parseRules($element['#validate'], $value);
|
116 |
// If not required but empty - skip
|
117 |
+
if (!isset($rules['required']) && ( is_null($value) || $value === false || $value === '' )) {
|
|
|
118 |
return true;
|
119 |
}
|
120 |
try {
|
121 |
$errors = array();
|
122 |
+
foreach ($rules as $rule => $args) {
|
123 |
+
if (!$this->validate($rule, $args['args'])) {
|
124 |
$errors[] = $args['message'];
|
125 |
}
|
126 |
}
|
127 |
+
if (!empty($errors)) {
|
128 |
throw new Exception();
|
129 |
}
|
130 |
+
} catch (Exception $e) {
|
131 |
+
$element['error'] = new WP_Error(__CLASS__ . '::' . __METHOD__, 'Field not validated', $errors);
|
|
|
132 |
}
|
133 |
return $element;
|
134 |
}
|
141 |
* @return \WP_Error|boolean
|
142 |
* @throws Exception
|
143 |
*/
|
144 |
+
public function validateField($field) {
|
145 |
+
$value = apply_filters('wptoolset_validation_value_' . $field->getType(), $field->getValue());
|
146 |
+
$rules = $this->_parseRules($field->getValidationData(), $value);
|
147 |
// If not required but empty - skip
|
148 |
+
if (!isset($rules['required']) && ( is_null($value) || $value === false || $value === '' )) {
|
|
|
149 |
return true;
|
150 |
}
|
151 |
|
152 |
try {
|
153 |
$errors = array();
|
154 |
+
foreach ($rules as $rule => $args) {
|
155 |
+
if (!$this->validate($rule, $args['args'])) {
|
156 |
/**
|
157 |
* Allow turn off field name.
|
158 |
*
|
162 |
*
|
163 |
* @param boolean $var show field title in message, * default true.
|
164 |
*/
|
165 |
+
if (apply_filters('toolset_common_validation_add_field_name_to_error', true)) {
|
166 |
+
$errors[] = $field->getTitle() . ' ' . $args['message'];
|
167 |
} else {
|
168 |
$errors[] = $args['message'];
|
169 |
}
|
170 |
}
|
171 |
}
|
172 |
+
if (!empty($errors)) {
|
173 |
throw new Exception();
|
174 |
}
|
175 |
+
} catch (Exception $e) {
|
176 |
+
return new WP_Error(__CLASS__ . '::' . __METHOD__, 'Field not validated', $errors);
|
|
|
177 |
}
|
178 |
return true;
|
179 |
}
|
180 |
|
181 |
+
protected function _parseRules($rules, $value) {
|
182 |
$_rules = array();
|
183 |
+
foreach ($rules as $rule => $args) {
|
184 |
+
$rule = apply_filters('wptoolset_validation_rule_php', $rule);
|
185 |
+
$args['args'] = apply_filters('wptoolset_validation_args_php', $args['args'], $rule);
|
|
|
186 |
// Set value in args - search string '$value' or replace first element
|
187 |
+
$replace = array_search('$value', $args['args']);
|
188 |
+
if ($replace !== false) {
|
189 |
$args['args'][$replace] = $value;
|
190 |
} else {
|
191 |
$args['args'][0] = $value;
|
204 |
* @param type $args
|
205 |
* @return boolean
|
206 |
*/
|
207 |
+
public function validate($rule, $args) {
|
208 |
$validator = $this->_cake();
|
209 |
+
$rule = $this->_map_rule_js_to_php($rule);
|
210 |
|
211 |
+
if ('skype' == $rule) {
|
212 |
return $validator->custom($args[0]['skypename'], '/^([a-zA-Z0-9\,\.\-\_]+)$/');
|
213 |
}
|
214 |
|
215 |
+
if (is_callable(array($validator, $rule))) {
|
216 |
+
return call_user_func_array(array($validator, $rule), $args);
|
217 |
}
|
218 |
return false;
|
219 |
}
|
224 |
* @return type
|
225 |
*/
|
226 |
protected function _cake() {
|
227 |
+
if (is_null($this->_cake)) {
|
228 |
require_once WPTOOLSET_FORMS_ABSPATH . '/lib/CakePHP-Validation.php';
|
229 |
$this->_cake = new WPToolset_Cake_Validation;
|
230 |
}
|
237 |
* @param type $rule
|
238 |
* @return type
|
239 |
*/
|
240 |
+
protected function _map_rule_js_to_php($rule) {
|
241 |
+
return isset($this->_rules_map[$rule]) ? $this->_rules_map[$rule] : $rule;
|
242 |
}
|
243 |
|
244 |
/**
|
248 |
printf('<script type="text/javascript">wptValidationForms.push("#%s");</script>', $this->__formID);
|
249 |
}
|
250 |
|
251 |
+
public function actionFieldClass($config) {
|
252 |
+
if (!empty($config['validation'])) {
|
253 |
foreach ($config['validation'] as $rule => $data) {
|
254 |
echo " wpt-validation-{$rule}";
|
255 |
}
|
library/toolset/toolset-common/toolset-forms/classes/class.wysiwyg.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
require_once 'class.textarea.php';
|
3 |
|
4 |
/**
|
@@ -8,65 +9,55 @@ require_once 'class.textarea.php';
|
|
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 = '';
|
21 |
-
|
22 |
-
|
23 |
-
if (
|
24 |
$markup .= '<div class="form-item form-item-markup">';
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
&& function_exists( 'wpcf_wpml_have_original' )
|
32 |
-
&& wpcf_wpml_have_original()
|
33 |
-
) {
|
34 |
-
$attributes['readonly'] = 'readonly';
|
35 |
-
$extra_markup .= sprintf(
|
36 |
'<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')
|
37 |
);
|
38 |
-
|
39 |
$markup .= sprintf(
|
40 |
-
|
41 |
-
stripcslashes($this->getTitle()),
|
42 |
-
$extra_markup
|
43 |
);
|
44 |
}
|
45 |
$markup .= stripcslashes($this->getDescription());
|
46 |
$markup .= $this->_editor($attributes);
|
47 |
-
if (
|
48 |
$markup .= '</div>';
|
49 |
}
|
50 |
$form[] = array(
|
51 |
-
'#type'
|
52 |
-
'#markup'
|
53 |
);
|
54 |
return $form;
|
55 |
}
|
56 |
|
57 |
-
protected function _editor(&$attributes)
|
58 |
-
|
|
|
|
|
59 |
|
60 |
-
$media_buttons = $this->_data['has_media_button'];
|
61 |
-
$quicktags = true;
|
62 |
-
|
63 |
if (
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
$quicktags = false;
|
70 |
}
|
71 |
|
72 |
//EMERSON: Rewritten to set do_concat to TRUE so WordPress won't echo styles directly to the browser
|
@@ -76,35 +67,33 @@ class WPToolset_Field_Wysiwyg extends WPToolset_Field_Textarea
|
|
76 |
//Using ob_start in that code will have some side effects of some styles from other plugins not being properly loaded.
|
77 |
|
78 |
global $wp_styles;
|
79 |
-
$wp_styles->do_concat=TRUE;
|
80 |
ob_start();
|
81 |
-
wp_editor(
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
) );
|
95 |
$return = ob_get_clean() . "\n\n";
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
$return = str_replace( '<textarea', '<textarea readonly="readonly"', $return );
|
102 |
}
|
103 |
-
$wp_styles->do_concat=FALSE;
|
104 |
-
|
105 |
-
|
106 |
|
107 |
-
public function tiny_mce_before_init_callback(
|
108 |
$args['readonly'] = 1;
|
109 |
return $args;
|
110 |
}
|
1 |
<?php
|
2 |
+
|
3 |
require_once 'class.textarea.php';
|
4 |
|
5 |
/**
|
9 |
*
|
10 |
*
|
11 |
*/
|
12 |
+
class WPToolset_Field_Wysiwyg extends WPToolset_Field_Textarea {
|
13 |
+
|
14 |
protected $_settings = array('min_wp_version' => '3.3');
|
15 |
|
16 |
+
public function metaform() {
|
|
|
17 |
|
18 |
$attributes = $this->getAttr();
|
19 |
$form = array();
|
20 |
$markup = '';
|
21 |
+
$wpml_action = $this->getWPMLAction();
|
22 |
+
|
23 |
+
if (is_admin()) {
|
24 |
$markup .= '<div class="form-item form-item-markup">';
|
25 |
+
$extra_markup = '';
|
26 |
+
if (
|
27 |
+
defined('WPML_TM_VERSION') && intval($wpml_action) === 1 && function_exists('wpcf_wpml_post_is_original') && !wpcf_wpml_post_is_original() && function_exists('wpcf_wpml_have_original') && wpcf_wpml_have_original()
|
28 |
+
) {
|
29 |
+
$attributes['readonly'] = 'readonly';
|
30 |
+
$extra_markup .= sprintf(
|
|
|
|
|
|
|
|
|
|
|
31 |
'<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')
|
32 |
);
|
33 |
+
}
|
34 |
$markup .= sprintf(
|
35 |
+
'<label class="wpt-form-label wpt-form-textfield-label">%1$s%2$s</label>', stripcslashes($this->getTitle()), $extra_markup
|
|
|
|
|
36 |
);
|
37 |
}
|
38 |
$markup .= stripcslashes($this->getDescription());
|
39 |
$markup .= $this->_editor($attributes);
|
40 |
+
if (is_admin()) {
|
41 |
$markup .= '</div>';
|
42 |
}
|
43 |
$form[] = array(
|
44 |
+
'#type' => 'markup',
|
45 |
+
'#markup' => $markup
|
46 |
);
|
47 |
return $form;
|
48 |
}
|
49 |
|
50 |
+
protected function _editor(&$attributes) {
|
51 |
+
|
52 |
+
$media_buttons = $this->_data['has_media_button'];
|
53 |
+
$quicktags = true;
|
54 |
|
|
|
|
|
|
|
55 |
if (
|
56 |
+
isset($attributes['readonly']) && $attributes['readonly'] == 'readonly'
|
57 |
+
) {
|
58 |
+
add_filter('tiny_mce_before_init', array(&$this, 'tiny_mce_before_init_callback'));
|
59 |
+
$media_buttons = false;
|
60 |
+
$quicktags = false;
|
|
|
61 |
}
|
62 |
|
63 |
//EMERSON: Rewritten to set do_concat to TRUE so WordPress won't echo styles directly to the browser
|
67 |
//Using ob_start in that code will have some side effects of some styles from other plugins not being properly loaded.
|
68 |
|
69 |
global $wp_styles;
|
70 |
+
$wp_styles->do_concat = TRUE;
|
71 |
ob_start();
|
72 |
+
wp_editor($this->getValue(), $this->getId(), array(
|
73 |
+
'wpautop' => true, // use wpautop?
|
74 |
+
'media_buttons' => $media_buttons, // show insert/upload button(s)
|
75 |
+
'textarea_name' => $this->getName(), // set the textarea name to something different, square brackets [] can be used here
|
76 |
+
'textarea_rows' => get_option('default_post_edit_rows', 10), // rows="..."
|
77 |
+
'tabindex' => '',
|
78 |
+
'editor_css' => '', // intended for extra styles for both visual and HTML editors buttons, needs to include the <style> tags, can use "scoped".
|
79 |
+
'editor_class' => 'wpt-wysiwyg', // add extra class(es) to the editor textarea
|
80 |
+
'teeny' => false, // output the minimal editor config used in Press This
|
81 |
+
'dfw' => false, // replace the default fullscreen with DFW (needs specific DOM elements and css)
|
82 |
+
'tinymce' => true, // load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
|
83 |
+
'quicktags' => $quicktags // load Quicktags, can be used to pass settings directly to Quicktags using an array(),
|
84 |
+
));
|
|
|
85 |
$return = ob_get_clean() . "\n\n";
|
86 |
+
if (
|
87 |
+
isset($attributes['readonly']) && $attributes['readonly'] == 'readonly'
|
88 |
+
) {
|
89 |
+
remove_filter('tiny_mce_before_init', array(&$this, 'tiny_mce_before_init_callback'));
|
90 |
+
$return = str_replace('<textarea', '<textarea readonly="readonly"', $return);
|
|
|
91 |
}
|
92 |
+
$wp_styles->do_concat = FALSE;
|
93 |
+
return $return;
|
94 |
+
}
|
95 |
|
96 |
+
public function tiny_mce_before_init_callback($args) {
|
97 |
$args['readonly'] = 1;
|
98 |
return $args;
|
99 |
}
|
library/toolset/toolset-common/toolset-forms/classes/submit.php
CHANGED
@@ -47,8 +47,8 @@ define('DOING_AJAX', true);
|
|
47 |
|
48 |
require_once( get_root_path() . 'wp-load.php' );
|
49 |
require_once( get_root_path() . 'wp-admin/includes/file.php' );
|
50 |
-
require_once
|
51 |
-
require_once
|
52 |
|
53 |
/** Allow for cross-domain requests (from the frontend). */
|
54 |
send_origin_headers();
|
@@ -59,6 +59,7 @@ if (isset($_REQUEST['nonce']) && check_ajax_referer('ajax_nonce', 'nonce', false
|
|
59 |
|
60 |
if (isset($_POST['action']) && $_POST['action'] == 'delete' && isset($_POST['file'])) {
|
61 |
$file = $_POST['file'];
|
|
|
62 |
|
63 |
$data = array('result' => true);
|
64 |
|
@@ -67,7 +68,7 @@ if (isset($_REQUEST['nonce']) && check_ajax_referer('ajax_nonce', 'nonce', false
|
|
67 |
//get all image attachments
|
68 |
$attachments = get_children(
|
69 |
array(
|
70 |
-
'post_parent' => $
|
71 |
//'post_mime_type' => 'image',
|
72 |
'post_type' => 'attachment'
|
73 |
)
|
@@ -176,16 +177,18 @@ if (isset($_REQUEST['nonce']) && check_ajax_referer('ajax_nonce', 'nonce', false
|
|
176 |
|
177 |
if (isset($_rewrited_url) && isset($_rewrited_url_prw)) {
|
178 |
$files[] = (is_array($_rewrited_url) && isset($_rewrited_url[0])) ? $_rewrited_url[0] : $_rewrited_url; //$res['url'];
|
|
|
179 |
$previews[] = (is_array($_rewrited_url_prw) && isset($_rewrited_url_prw[0])) ? $_rewrited_url_prw[0] : $_rewrited_url_prw; //$res['url'];
|
180 |
} else {
|
181 |
$files[] = $res['url'];
|
|
|
182 |
}
|
183 |
} else {
|
184 |
$error = true;
|
185 |
}
|
186 |
}
|
187 |
}
|
188 |
-
$data = ($error) ? array('result' => false, 'error' => __('There was an error uploading your files', 'wpv-views') . ': ' . $res['error']) : array('files' => $files, 'previews' => $previews, 'delete_nonce' => time());
|
189 |
} else {
|
190 |
$data = array('result' => false, 'error' => __('Error: Files is too big, Max upload size is', 'wpv-views') . ': ' . ini_get('post_max_size'));
|
191 |
}
|
47 |
|
48 |
require_once( get_root_path() . 'wp-load.php' );
|
49 |
require_once( get_root_path() . 'wp-admin/includes/file.php' );
|
50 |
+
require_once( get_root_path() . 'wp-admin/includes/media.php' );
|
51 |
+
require_once( get_root_path() . 'wp-admin/includes/image.php' );
|
52 |
|
53 |
/** Allow for cross-domain requests (from the frontend). */
|
54 |
send_origin_headers();
|
59 |
|
60 |
if (isset($_POST['action']) && $_POST['action'] == 'delete' && isset($_POST['file'])) {
|
61 |
$file = $_POST['file'];
|
62 |
+
$id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0;
|
63 |
|
64 |
$data = array('result' => true);
|
65 |
|
68 |
//get all image attachments
|
69 |
$attachments = get_children(
|
70 |
array(
|
71 |
+
'post_parent' => $id,
|
72 |
//'post_mime_type' => 'image',
|
73 |
'post_type' => 'attachment'
|
74 |
)
|
177 |
|
178 |
if (isset($_rewrited_url) && isset($_rewrited_url_prw)) {
|
179 |
$files[] = (is_array($_rewrited_url) && isset($_rewrited_url[0])) ? $_rewrited_url[0] : $_rewrited_url; //$res['url'];
|
180 |
+
$attaches[] = $attach_id;
|
181 |
$previews[] = (is_array($_rewrited_url_prw) && isset($_rewrited_url_prw[0])) ? $_rewrited_url_prw[0] : $_rewrited_url_prw; //$res['url'];
|
182 |
} else {
|
183 |
$files[] = $res['url'];
|
184 |
+
$attaches[] = $attach_id;
|
185 |
}
|
186 |
} else {
|
187 |
$error = true;
|
188 |
}
|
189 |
}
|
190 |
}
|
191 |
+
$data = ($error) ? array('result' => false, 'error' => __('There was an error uploading your files', 'wpv-views') . ': ' . $res['error']) : array('files' => $files, 'attaches' => $attaches, 'previews' => $previews, 'delete_nonce' => time());
|
192 |
} else {
|
193 |
$data = array('result' => false, 'error' => __('Error: Files is too big, Max upload size is', 'wpv-views') . ': ' . ini_get('post_max_size'));
|
194 |
}
|
library/toolset/toolset-common/toolset-forms/css/wpt-toolset-backend.css
CHANGED
@@ -279,7 +279,8 @@ img.ui-datepicker-trigger {
|
|
279 |
3.0 - Toolset Primary Button Style
|
280 |
---------------------------------------------------------------------------- */
|
281 |
|
282 |
-
.wp-core-ui .button-primary-toolset
|
|
|
283 |
background: #f6921e;
|
284 |
border-color: #EF6223;
|
285 |
-webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5), 0 1px 0 rgba(0,0,0,.15);
|
@@ -292,7 +293,11 @@ img.ui-datepicker-trigger {
|
|
292 |
.wp-core-ui .button-primary-toolset.hover,
|
293 |
.wp-core-ui .button-primary-toolset:hover,
|
294 |
.wp-core-ui .button-primary-toolset.focus,
|
295 |
-
.wp-core-ui .button-primary-toolset:focus
|
|
|
|
|
|
|
|
|
296 |
background: #EF6223;
|
297 |
border-color: #EF6223;
|
298 |
-webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5);
|
@@ -336,3 +341,11 @@ img.ui-datepicker-trigger {
|
|
336 |
text-shadow: 0 -1px 0 rgba(0,0,0,0.1) !important;
|
337 |
cursor: default;
|
338 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
3.0 - Toolset Primary Button Style
|
280 |
---------------------------------------------------------------------------- */
|
281 |
|
282 |
+
.wp-core-ui .button-primary-toolset,
|
283 |
+
.wp-core-ui .button.button-primary-toolset {
|
284 |
background: #f6921e;
|
285 |
border-color: #EF6223;
|
286 |
-webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5), 0 1px 0 rgba(0,0,0,.15);
|
293 |
.wp-core-ui .button-primary-toolset.hover,
|
294 |
.wp-core-ui .button-primary-toolset:hover,
|
295 |
.wp-core-ui .button-primary-toolset.focus,
|
296 |
+
.wp-core-ui .button-primary-toolset:focus,
|
297 |
+
.wp-core-ui .button.button-primary-toolset.hover,
|
298 |
+
.wp-core-ui .button.button-primary-toolset:hover,
|
299 |
+
.wp-core-ui .button.button-primary-toolset.focus,
|
300 |
+
.wp-core-ui .button.button-primary-toolset:focus {
|
301 |
background: #EF6223;
|
302 |
border-color: #EF6223;
|
303 |
-webkit-box-shadow: inset 0 1px 0 rgba(239, 239, 239, 0.5);
|
341 |
text-shadow: 0 -1px 0 rgba(0,0,0,0.1) !important;
|
342 |
cursor: default;
|
343 |
}
|
344 |
+
|
345 |
+
/* Repeatable Fields */
|
346 |
+
.wpt-repetitive .wpt-form-item {
|
347 |
+
margin-bottom: 0;
|
348 |
+
}
|
349 |
+
.wpt-repetitive .wpt-field-item:nth-child(1n+2) {
|
350 |
+
margin-top: 20px;
|
351 |
+
}
|
library/toolset/toolset-common/toolset-forms/css/wpt-toolset-frontend.css
CHANGED
@@ -68,7 +68,7 @@
|
|
68 |
width: 100%;
|
69 |
}
|
70 |
ul.wpt-form-set, ul.wpt-form-set-children {
|
71 |
-
|
72 |
}
|
73 |
.wpt-form-description-textarea,
|
74 |
.wpt-form-description-checkboxes,
|
@@ -125,7 +125,7 @@ input.wpt-form-error {
|
|
125 |
}
|
126 |
.ui-sortable .wpt-form-textarea
|
127 |
,.ui-sortable .wpt-form-textfield {
|
128 |
-
|
129 |
}
|
130 |
.wpt-form-fields-delete,
|
131 |
.wpt-fields-form-move-field {
|
@@ -142,17 +142,17 @@ input.wpt-form-error {
|
|
142 |
font-style: italic;
|
143 |
}
|
144 |
.wpt-form-textfield.wpt-new-taxonomy-title {
|
145 |
-
|
146 |
width: 100%;
|
147 |
}
|
148 |
.cred-taxonomy-auxilliary
|
149 |
,.wpt-hierarchical-taxonomy-add-new
|
150 |
,.wpt-taxonomy-show-popular-list {
|
151 |
-
|
152 |
}
|
153 |
.wpt-taxonomy-show-popular-list {
|
154 |
-
|
155 |
-
|
156 |
}
|
157 |
.wpt-message {
|
158 |
padding: 0 0.6em;
|
@@ -194,7 +194,7 @@ img.ui-datepicker-trigger, img.ui-datepicker-readonly
|
|
194 |
margin: 0 5px 0 0;
|
195 |
}
|
196 |
.wpt-repdelete, .wpt-date-clear {
|
197 |
-
|
198 |
}
|
199 |
.wpt-repadd {
|
200 |
margin-top: 5px !important;
|
@@ -211,7 +211,7 @@ img.ui-datepicker-trigger, img.ui-datepicker-readonly
|
|
211 |
z-index: 3;
|
212 |
}
|
213 |
.wp-editor-container {
|
214 |
-
|
215 |
}
|
216 |
|
217 |
/* Credfile */
|
@@ -262,7 +262,7 @@ img.wpt-credfile-preview-upload {
|
|
262 |
/* Taxonomy */
|
263 |
.tagchecklist {
|
264 |
margin-left:15px;
|
265 |
-
|
266 |
}
|
267 |
|
268 |
.tagchecklist span {
|
@@ -297,27 +297,47 @@ img.wpt-credfile-preview-upload {
|
|
297 |
|
298 |
/* Autocomplete */
|
299 |
.wpt-suggest-taxonomy-term {
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
}
|
308 |
|
309 |
.wpt-suggest-taxonomy-term li {
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
}
|
319 |
|
320 |
.wpt-suggest-taxonomy-term-select {
|
321 |
-
|
322 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
}
|
|
|
|
|
|
|
|
68 |
width: 100%;
|
69 |
}
|
70 |
ul.wpt-form-set, ul.wpt-form-set-children {
|
71 |
+
list-style-type: none;
|
72 |
}
|
73 |
.wpt-form-description-textarea,
|
74 |
.wpt-form-description-checkboxes,
|
125 |
}
|
126 |
.ui-sortable .wpt-form-textarea
|
127 |
,.ui-sortable .wpt-form-textfield {
|
128 |
+
width: 70%;
|
129 |
}
|
130 |
.wpt-form-fields-delete,
|
131 |
.wpt-fields-form-move-field {
|
142 |
font-style: italic;
|
143 |
}
|
144 |
.wpt-form-textfield.wpt-new-taxonomy-title {
|
145 |
+
max-width: 420px;
|
146 |
width: 100%;
|
147 |
}
|
148 |
.cred-taxonomy-auxilliary
|
149 |
,.wpt-hierarchical-taxonomy-add-new
|
150 |
,.wpt-taxonomy-show-popular-list {
|
151 |
+
margin-top: 10px;
|
152 |
}
|
153 |
.wpt-taxonomy-show-popular-list {
|
154 |
+
padding: 10px;
|
155 |
+
border: solid 1px #ccc;
|
156 |
}
|
157 |
.wpt-message {
|
158 |
padding: 0 0.6em;
|
194 |
margin: 0 5px 0 0;
|
195 |
}
|
196 |
.wpt-repdelete, .wpt-date-clear {
|
197 |
+
margin: 0 0 0 5px;
|
198 |
}
|
199 |
.wpt-repadd {
|
200 |
margin-top: 5px !important;
|
211 |
z-index: 3;
|
212 |
}
|
213 |
.wp-editor-container {
|
214 |
+
border: 1px solid #e5e5e5;
|
215 |
}
|
216 |
|
217 |
/* Credfile */
|
262 |
/* Taxonomy */
|
263 |
.tagchecklist {
|
264 |
margin-left:15px;
|
265 |
+
overflow:hidden;
|
266 |
}
|
267 |
|
268 |
.tagchecklist span {
|
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;
|
313 |
+
display: block;
|
314 |
+
width: 100%;
|
315 |
+
font: menu;
|
316 |
+
font-size: 12px;
|
317 |
+
overflow: hidden;
|
318 |
}
|
319 |
|
320 |
.wpt-suggest-taxonomy-term-select {
|
321 |
+
background-color: Highlight;
|
322 |
+
color: HighlightText;
|
323 |
+
}
|
324 |
+
|
325 |
+
.wpt-modal {
|
326 |
+
display: none;
|
327 |
+
position: fixed;
|
328 |
+
z-index: 1000;
|
329 |
+
top: 0;
|
330 |
+
left: 0;
|
331 |
+
height: 100%;
|
332 |
+
width: 100%;
|
333 |
+
background: rgba( 255, 255, 255, .3 )
|
334 |
+
url('../images/loading.png')
|
335 |
+
50% 50%
|
336 |
+
no-repeat;
|
337 |
+
}
|
338 |
+
body.wpt-loading {
|
339 |
}
|
340 |
+
|
341 |
+
body.wpt-loading .wpt-modal {
|
342 |
+
display: block;
|
343 |
+
}
|
library/toolset/toolset-common/toolset-forms/images/loading.png
ADDED
Binary file
|
library/toolset/toolset-common/toolset-forms/js/conditional.js
CHANGED
@@ -43,8 +43,8 @@ var wptCond = (function ($) {
|
|
43 |
$.fn.condSlideFadeDown = function (speed, easing, callback) {
|
44 |
easing = easing || 'linear';
|
45 |
return this.each(function () {
|
46 |
-
$(this).
|
47 |
-
|
48 |
if ($.browser.msie) {
|
49 |
this.style.removeAttribute('filter');
|
50 |
}
|
@@ -52,14 +52,24 @@ var wptCond = (function ($) {
|
|
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).
|
62 |
-
|
63 |
if ($.browser.msie) {
|
64 |
this.style.removeAttribute('filter');
|
65 |
}
|
@@ -67,6 +77,16 @@ var wptCond = (function ($) {
|
|
67 |
callback.call(this);
|
68 |
}
|
69 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
});
|
71 |
};
|
72 |
|
@@ -110,7 +130,7 @@ var wptCond = (function ($) {
|
|
110 |
*/
|
111 |
if ($trigger.length < 1) {
|
112 |
// make sure to try cred field only once tssupp-1142
|
113 |
-
if(
|
114 |
$trigger = _getTrigger('cred-' + trigger, formID);
|
115 |
|
116 |
if (wptCondDebug)
|
@@ -668,7 +688,7 @@ var wptCond = (function ($) {
|
|
668 |
var val_array = '';
|
669 |
|
670 |
if (wptCondDebug) {
|
671 |
-
console.log();
|
672 |
}
|
673 |
|
674 |
if (value instanceof Array) {
|
@@ -757,11 +777,11 @@ var wptCond = (function ($) {
|
|
757 |
} else {
|
758 |
effectmode = 'slide';
|
759 |
}
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
|
766 |
if (show) {
|
767 |
if ($el.hasClass('wpt-date') && 'object' == typeof wptDate) {
|
@@ -772,32 +792,33 @@ var wptCond = (function ($) {
|
|
772 |
switch (effectmode) {
|
773 |
case 'fade-slide':
|
774 |
setTimeout(function () {
|
775 |
-
$el.stop(true).condSlideFadeDown(
|
776 |
-
|
777 |
-
|
778 |
}, delay);
|
779 |
break;
|
780 |
case 'slide':
|
781 |
setTimeout(function () {
|
782 |
-
$el.stop(true).slideDown(
|
783 |
$el.css('height', 'auto');
|
784 |
-
|
785 |
});
|
786 |
}, delay);
|
787 |
break;
|
788 |
case 'fade':
|
789 |
setTimeout(function () {
|
790 |
-
$el.stop(true).fadeIn(
|
791 |
-
|
792 |
-
|
793 |
}, delay);
|
794 |
break;
|
795 |
case 'none':
|
|
|
796 |
break;
|
797 |
default:
|
798 |
-
$el.show('fast', function() {
|
799 |
-
|
800 |
-
|
801 |
break;
|
802 |
}
|
803 |
$($el).find('input, textarea, button, select').prop("disabled", false);
|
@@ -806,32 +827,33 @@ var wptCond = (function ($) {
|
|
806 |
switch (effectmode) {
|
807 |
case 'fade-slide':
|
808 |
setTimeout(function () {
|
809 |
-
$el.stop(true).condSlideFadeUp(
|
810 |
-
|
811 |
-
|
812 |
}, delay);
|
813 |
break;
|
814 |
case 'slide':
|
815 |
setTimeout(function () {
|
816 |
-
$el.stop(true).slideUp(
|
817 |
$el.css('height', 'auto');
|
818 |
-
|
819 |
});
|
820 |
}, delay);
|
821 |
break;
|
822 |
case 'fade':
|
823 |
setTimeout(function () {
|
824 |
-
$el.stop(true).fadeOut(
|
825 |
-
|
826 |
-
|
827 |
}, delay);
|
828 |
break;
|
829 |
case 'none':
|
|
|
830 |
break;
|
831 |
default:
|
832 |
-
$el.hide('fast', function() {
|
833 |
-
|
834 |
-
|
835 |
break;
|
836 |
}
|
837 |
$($el).find('input, textarea, button, select').prop('disabled', true);
|
43 |
$.fn.condSlideFadeDown = function (speed, easing, callback) {
|
44 |
easing = easing || 'linear';
|
45 |
return this.each(function () {
|
46 |
+
$(this).fadeIn(speed, function () {
|
47 |
+
//$(this).css('height', 'auto');
|
48 |
if ($.browser.msie) {
|
49 |
this.style.removeAttribute('filter');
|
50 |
}
|
52 |
callback.call(this);
|
53 |
}
|
54 |
});
|
55 |
+
|
56 |
+
// $(this).animate({opacity: 'show', height: 'show'}, speed, easing, function () {
|
57 |
+
// $(this).css('height', 'auto');
|
58 |
+
// if ($.browser.msie) {
|
59 |
+
// this.style.removeAttribute('filter');
|
60 |
+
// }
|
61 |
+
// if ($.isFunction(callback)) {
|
62 |
+
// callback.call(this);
|
63 |
+
// }
|
64 |
+
// });
|
65 |
});
|
66 |
};
|
67 |
|
68 |
$.fn.condSlideFadeUp = function (speed, easing, callback) {
|
69 |
easing = easing || 'linear';
|
70 |
return this.each(function () {
|
71 |
+
$(this).fadeOut(speed, function () {
|
72 |
+
//$(this).css('height', 'auto');
|
73 |
if ($.browser.msie) {
|
74 |
this.style.removeAttribute('filter');
|
75 |
}
|
77 |
callback.call(this);
|
78 |
}
|
79 |
});
|
80 |
+
|
81 |
+
// $(this).animate({opacity: 'hide', height: 'hide'}, speed, easing, function () {
|
82 |
+
// $(this).css('height', 'auto');
|
83 |
+
// if ($.browser.msie) {
|
84 |
+
// this.style.removeAttribute('filter');
|
85 |
+
// }
|
86 |
+
// if ($.isFunction(callback)) {
|
87 |
+
// callback.call(this);
|
88 |
+
// }
|
89 |
+
// });
|
90 |
});
|
91 |
};
|
92 |
|
130 |
*/
|
131 |
if ($trigger.length < 1) {
|
132 |
// make sure to try cred field only once tssupp-1142
|
133 |
+
if (trigger.indexOf('cred-') == -1)
|
134 |
$trigger = _getTrigger('cred-' + trigger, formID);
|
135 |
|
136 |
if (wptCondDebug)
|
688 |
var val_array = '';
|
689 |
|
690 |
if (wptCondDebug) {
|
691 |
+
//console.log();
|
692 |
}
|
693 |
|
694 |
if (value instanceof Array) {
|
777 |
} else {
|
778 |
effectmode = 'slide';
|
779 |
}
|
780 |
+
|
781 |
+
var data_for_events = {
|
782 |
+
container: $el,
|
783 |
+
visible: show
|
784 |
+
};
|
785 |
|
786 |
if (show) {
|
787 |
if ($el.hasClass('wpt-date') && 'object' == typeof wptDate) {
|
792 |
switch (effectmode) {
|
793 |
case 'fade-slide':
|
794 |
setTimeout(function () {
|
795 |
+
$el.stop(true).condSlideFadeDown('linear', function () {
|
796 |
+
$(document).trigger('js_event_toolset_forms_conditional_field_toggled', data_for_events);
|
797 |
+
});
|
798 |
}, delay);
|
799 |
break;
|
800 |
case 'slide':
|
801 |
setTimeout(function () {
|
802 |
+
$el.stop(true).slideDown('linear', function () {
|
803 |
$el.css('height', 'auto');
|
804 |
+
$(document).trigger('js_event_toolset_forms_conditional_field_toggled', data_for_events);
|
805 |
});
|
806 |
}, delay);
|
807 |
break;
|
808 |
case 'fade':
|
809 |
setTimeout(function () {
|
810 |
+
$el.stop(true).fadeIn('fast', function () {
|
811 |
+
$(document).trigger('js_event_toolset_forms_conditional_field_toggled', data_for_events);
|
812 |
+
});
|
813 |
}, delay);
|
814 |
break;
|
815 |
case 'none':
|
816 |
+
$el.show();
|
817 |
break;
|
818 |
default:
|
819 |
+
$el.show('fast', function () {
|
820 |
+
$(document).trigger('js_event_toolset_forms_conditional_field_toggled', data_for_events);
|
821 |
+
});
|
822 |
break;
|
823 |
}
|
824 |
$($el).find('input, textarea, button, select').prop("disabled", false);
|
827 |
switch (effectmode) {
|
828 |
case 'fade-slide':
|
829 |
setTimeout(function () {
|
830 |
+
$el.stop(true).condSlideFadeUp('linear', function () {
|
831 |
+
$(document).trigger('js_event_toolset_forms_conditional_field_toggled', data_for_events);
|
832 |
+
});
|
833 |
}, delay);
|
834 |
break;
|
835 |
case 'slide':
|
836 |
setTimeout(function () {
|
837 |
+
$el.stop(true).slideUp('linear', function () {
|
838 |
$el.css('height', 'auto');
|
839 |
+
$(document).trigger('js_event_toolset_forms_conditional_field_toggled', data_for_events);
|
840 |
});
|
841 |
}, delay);
|
842 |
break;
|
843 |
case 'fade':
|
844 |
setTimeout(function () {
|
845 |
+
$el.stop(true).fadeOut('fast', function () {
|
846 |
+
$(document).trigger('js_event_toolset_forms_conditional_field_toggled', data_for_events);
|
847 |
+
});
|
848 |
}, delay);
|
849 |
break;
|
850 |
case 'none':
|
851 |
+
$el.hide();
|
852 |
break;
|
853 |
default:
|
854 |
+
$el.hide('fast', function () {
|
855 |
+
$(document).trigger('js_event_toolset_forms_conditional_field_toggled', data_for_events);
|
856 |
+
});
|
857 |
break;
|
858 |
}
|
859 |
$($el).find('input, textarea, button, select').prop('disabled', true);
|
library/toolset/toolset-common/toolset-forms/js/credfile.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
|
2 |
var wptCredfile = (function ($) {
|
3 |
function init(selector) {
|
4 |
-
$(
|
5 |
e.preventDefault();
|
6 |
var thiz = $(this),
|
7 |
credfile_action = thiz.data('action'),
|
@@ -15,6 +15,7 @@ var wptCredfile = (function ($) {
|
|
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);
|
@@ -25,6 +26,10 @@ var wptCredfile = (function ($) {
|
|
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();
|
@@ -33,10 +38,14 @@ var wptCredfile = (function ($) {
|
|
33 |
thiz_preview.show();
|
34 |
thiz_delete_button.show();
|
35 |
thiz_undo_button.hide();
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
});
|
38 |
|
39 |
-
$(
|
40 |
e.preventDefault();
|
41 |
var thiz = $(this),
|
42 |
credfile_container = thiz.closest('.wpt-repctl');
|
1 |
|
2 |
var wptCredfile = (function ($) {
|
3 |
function init(selector) {
|
4 |
+
$('.js-wpt-credfile-delete, .js-wpt-credfile-undo').on('click', function (e) {
|
5 |
e.preventDefault();
|
6 |
var thiz = $(this),
|
7 |
credfile_action = thiz.data('action'),
|
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 |
+
var myid = thiz_hidden_input.attr('name');
|
19 |
if (credfile_action == 'delete') {
|
20 |
thiz_file_input.prop('disabled', false).show().val('');
|
21 |
thiz_hidden_input.prop('disabled', true);
|
26 |
} else {
|
27 |
thiz_undo_button.hide();
|
28 |
}
|
29 |
+
if (myid == '_featured_image')
|
30 |
+
$("<input type='hidden' id='attachid_" + myid + "' name='attachid_" + myid + "' value=''>").insertAfter('#' + thiz_hidden_input.attr('id'));
|
31 |
+
else
|
32 |
+
$("<input type='hidden' id='" + myid + "' name='" + myid + "' value=''>").insertAfter('#' + thiz_hidden_input.attr('id'));
|
33 |
thiz_file_input.trigger('change');
|
34 |
} else if (credfile_action == 'undo') {
|
35 |
thiz_file_input.prop('disabled', true).hide();
|
38 |
thiz_preview.show();
|
39 |
thiz_delete_button.show();
|
40 |
thiz_undo_button.hide();
|
41 |
+
if (myid == '_featured_image')
|
42 |
+
$('#attachid_' + myid).remove();
|
43 |
+
else
|
44 |
+
$('#' + myid).remove();
|
45 |
}
|
46 |
});
|
47 |
|
48 |
+
$('.js-wpt-credfile-upload-file').on('change', function (e) {
|
49 |
e.preventDefault();
|
50 |
var thiz = $(this),
|
51 |
credfile_container = thiz.closest('.wpt-repctl');
|
library/toolset/toolset-common/toolset-forms/js/jquery-ui-186.min.js
ADDED
@@ -0,0 +1,401 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*!
|
2 |
+
* jQuery UI 1.8.6
|
3 |
+
*
|
4 |
+
* Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
|
5 |
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
6 |
+
* http://jquery.org/license
|
7 |
+
*
|
8 |
+
* http://docs.jquery.com/UI
|
9 |
+
*/
|
10 |
+
(function(b,c){function f(g){return!b(g).parents().andSelf().filter(function(){return b.curCSS(this,"visibility")==="hidden"||b.expr.filters.hidden(this)}).length}b.ui=b.ui||{};if(!b.ui.version){b.extend(b.ui,{version:"1.8.6",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,
|
11 |
+
NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});b.fn.extend({_focus:b.fn.focus,focus:function(g,e){return typeof g==="number"?this.each(function(){var a=this;setTimeout(function(){b(a).focus();e&&e.call(a)},g)}):this._focus.apply(this,arguments)},scrollParent:function(){var g;g=b.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(b.curCSS(this,
|
12 |
+
"position",1))&&/(auto|scroll)/.test(b.curCSS(this,"overflow",1)+b.curCSS(this,"overflow-y",1)+b.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(b.curCSS(this,"overflow",1)+b.curCSS(this,"overflow-y",1)+b.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!g.length?b(document):g},zIndex:function(g){if(g!==c)return this.css("zIndex",g);if(this.length){g=b(this[0]);for(var e;g.length&&g[0]!==document;){e=g.css("position");
|
13 |
+
if(e==="absolute"||e==="relative"||e==="fixed"){e=parseInt(g.css("zIndex"),10);if(!isNaN(e)&&e!==0)return e}g=g.parent()}}return 0},disableSelection:function(){return this.bind((b.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(g){g.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});b.each(["Width","Height"],function(g,e){function a(j,n,q,l){b.each(d,function(){n-=parseFloat(b.curCSS(j,"padding"+this,true))||0;if(q)n-=parseFloat(b.curCSS(j,
|
14 |
+
"border"+this+"Width",true))||0;if(l)n-=parseFloat(b.curCSS(j,"margin"+this,true))||0});return n}var d=e==="Width"?["Left","Right"]:["Top","Bottom"],h=e.toLowerCase(),i={innerWidth:b.fn.innerWidth,innerHeight:b.fn.innerHeight,outerWidth:b.fn.outerWidth,outerHeight:b.fn.outerHeight};b.fn["inner"+e]=function(j){if(j===c)return i["inner"+e].call(this);return this.each(function(){b(this).css(h,a(this,j)+"px")})};b.fn["outer"+e]=function(j,n){if(typeof j!=="number")return i["outer"+e].call(this,j);return this.each(function(){b(this).css(h,
|
15 |
+
a(this,j,true,n)+"px")})}});b.extend(b.expr[":"],{data:function(g,e,a){return!!b.data(g,a[3])},focusable:function(g){var e=g.nodeName.toLowerCase(),a=b.attr(g,"tabindex");if("area"===e){e=g.parentNode;a=e.name;if(!g.href||!a||e.nodeName.toLowerCase()!=="map")return false;g=b("img[usemap=#"+a+"]")[0];return!!g&&f(g)}return(/input|select|textarea|button|object/.test(e)?!g.disabled:"a"==e?g.href||!isNaN(a):!isNaN(a))&&f(g)},tabbable:function(g){var e=b.attr(g,"tabindex");return(isNaN(e)||e>=0)&&b(g).is(":focusable")}});
|
16 |
+
b(function(){var g=document.body,e=g.appendChild(e=document.createElement("div"));b.extend(e.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});b.support.minHeight=e.offsetHeight===100;b.support.selectstart="onselectstart"in e;g.removeChild(e).style.display="none"});b.extend(b.ui,{plugin:{add:function(g,e,a){g=b.ui[g].prototype;for(var d in a){g.plugins[d]=g.plugins[d]||[];g.plugins[d].push([e,a[d]])}},call:function(g,e,a){if((e=g.plugins[e])&&g.element[0].parentNode)for(var d=0;d<e.length;d++)g.options[e[d][0]]&&
|
17 |
+
e[d][1].apply(g.element,a)}},contains:function(g,e){return document.compareDocumentPosition?g.compareDocumentPosition(e)&16:g!==e&&g.contains(e)},hasScroll:function(g,e){if(b(g).css("overflow")==="hidden")return false;e=e&&e==="left"?"scrollLeft":"scrollTop";var a=false;if(g[e]>0)return true;g[e]=1;a=g[e]>0;g[e]=0;return a},isOverAxis:function(g,e,a){return g>e&&g<e+a},isOver:function(g,e,a,d,h,i){return b.ui.isOverAxis(g,a,h)&&b.ui.isOverAxis(e,d,i)}})}})(jQuery);
|
18 |
+
(function(b,c){if(b.cleanData){var f=b.cleanData;b.cleanData=function(e){for(var a=0,d;(d=e[a])!=null;a++)b(d).triggerHandler("remove");f(e)}}else{var g=b.fn.remove;b.fn.remove=function(e,a){return this.each(function(){if(!a)if(!e||b.filter(e,[this]).length)b("*",this).add([this]).each(function(){b(this).triggerHandler("remove")});return g.call(b(this),e,a)})}}b.widget=function(e,a,d){var h=e.split(".")[0],i;e=e.split(".")[1];i=h+"-"+e;if(!d){d=a;a=b.Widget}b.expr[":"][i]=function(j){return!!b.data(j,
|
19 |
+
e)};b[h]=b[h]||{};b[h][e]=function(j,n){arguments.length&&this._createWidget(j,n)};a=new a;a.options=b.extend(true,{},a.options);b[h][e].prototype=b.extend(true,a,{namespace:h,widgetName:e,widgetEventPrefix:b[h][e].prototype.widgetEventPrefix||e,widgetBaseClass:i},d);b.widget.bridge(e,b[h][e])};b.widget.bridge=function(e,a){b.fn[e]=function(d){var h=typeof d==="string",i=Array.prototype.slice.call(arguments,1),j=this;d=!h&&i.length?b.extend.apply(null,[true,d].concat(i)):d;if(h&&d.charAt(0)==="_")return j;
|
20 |
+
h?this.each(function(){var n=b.data(this,e),q=n&&b.isFunction(n[d])?n[d].apply(n,i):n;if(q!==n&&q!==c){j=q;return false}}):this.each(function(){var n=b.data(this,e);n?n.option(d||{})._init():b.data(this,e,new a(d,this))});return j}};b.Widget=function(e,a){arguments.length&&this._createWidget(e,a)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(e,a){b.data(a,this.widgetName,this);this.element=b(a);this.options=b.extend(true,{},this.options,
|
21 |
+
this._getCreateOptions(),e);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},
|
22 |
+
widget:function(){return this.element},option:function(e,a){var d=e;if(arguments.length===0)return b.extend({},this.options);if(typeof e==="string"){if(a===c)return this.options[e];d={};d[e]=a}this._setOptions(d);return this},_setOptions:function(e){var a=this;b.each(e,function(d,h){a._setOption(d,h)});return this},_setOption:function(e,a){this.options[e]=a;if(e==="disabled")this.widget()[a?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",a);return this},
|
23 |
+
enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(e,a,d){var h=this.options[e];a=b.Event(a);a.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase();d=d||{};if(a.originalEvent){e=b.event.props.length;for(var i;e;){i=b.event.props[--e];a[i]=a.originalEvent[i]}}this.element.trigger(a,d);return!(b.isFunction(h)&&h.call(this.element[0],a,d)===false||a.isDefaultPrevented())}}})(jQuery);
|
24 |
+
(function(b){b.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var c=this;this.element.bind("mousedown."+this.widgetName,function(f){return c._mouseDown(f)}).bind("click."+this.widgetName,function(f){if(c._preventClickEvent){c._preventClickEvent=false;f.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(c){c.originalEvent=c.originalEvent||{};if(!c.originalEvent.mouseHandled){this._mouseStarted&&
|
25 |
+
this._mouseUp(c);this._mouseDownEvent=c;var f=this,g=c.which==1,e=typeof this.options.cancel=="string"?b(c.target).parents().add(c.target).filter(this.options.cancel).length:false;if(!g||e||!this._mouseCapture(c))return true;this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet)this._mouseDelayTimer=setTimeout(function(){f.mouseDelayMet=true},this.options.delay);if(this._mouseDistanceMet(c)&&this._mouseDelayMet(c)){this._mouseStarted=this._mouseStart(c)!==false;if(!this._mouseStarted){c.preventDefault();
|
26 |
+
return true}}this._mouseMoveDelegate=function(a){return f._mouseMove(a)};this._mouseUpDelegate=function(a){return f._mouseUp(a)};b(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);c.preventDefault();return c.originalEvent.mouseHandled=true}},_mouseMove:function(c){if(b.browser.msie&&!(document.documentMode>=9)&&!c.button)return this._mouseUp(c);if(this._mouseStarted){this._mouseDrag(c);return c.preventDefault()}if(this._mouseDistanceMet(c)&&
|
27 |
+
this._mouseDelayMet(c))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,c)!==false)?this._mouseDrag(c):this._mouseUp(c);return!this._mouseStarted},_mouseUp:function(c){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=c.target==this._mouseDownEvent.target;this._mouseStop(c)}return false},_mouseDistanceMet:function(c){return Math.max(Math.abs(this._mouseDownEvent.pageX-
|
28 |
+
c.pageX),Math.abs(this._mouseDownEvent.pageY-c.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
|
29 |
+
(function(b){b.widget("ui.draggable",b.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper==
|
30 |
+
"original"&&!/^(?: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._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(c){var f=
|
31 |
+
this.options;if(this.helper||f.disabled||b(c.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(c);if(!this.handle)return false;return true},_mouseStart:function(c){var f=this.options;this.helper=this._createHelper(c);this._cacheHelperProportions();if(b.ui.ddmanager)b.ui.ddmanager.current=this;this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-
|
32 |
+
this.margins.top,left:this.offset.left-this.margins.left};b.extend(this.offset,{click:{left:c.pageX-this.offset.left,top:c.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this.position=this._generatePosition(c);this.originalPageX=c.pageX;this.originalPageY=c.pageY;f.cursorAt&&this._adjustOffsetFromHelper(f.cursorAt);f.containment&&this._setContainment();if(this._trigger("start",c)===false){this._clear();return false}this._cacheHelperProportions();
|
33 |
+
b.ui.ddmanager&&!f.dropBehaviour&&b.ui.ddmanager.prepareOffsets(this,c);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(c,true);return true},_mouseDrag:function(c,f){this.position=this._generatePosition(c);this.positionAbs=this._convertPositionTo("absolute");if(!f){f=this._uiHash();if(this._trigger("drag",c,f)===false){this._mouseUp({});return false}this.position=f.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||
|
34 |
+
this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";b.ui.ddmanager&&b.ui.ddmanager.drag(this,c);return false},_mouseStop:function(c){var f=false;if(b.ui.ddmanager&&!this.options.dropBehaviour)f=b.ui.ddmanager.drop(this,c);if(this.dropped){f=this.dropped;this.dropped=false}if(!this.element[0]||!this.element[0].parentNode)return false;if(this.options.revert=="invalid"&&!f||this.options.revert=="valid"&&f||this.options.revert===true||b.isFunction(this.options.revert)&&this.options.revert.call(this.element,
|
35 |
+
f)){var g=this;b(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){g._trigger("stop",c)!==false&&g._clear()})}else this._trigger("stop",c)!==false&&this._clear();return false},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(c){var f=!this.options.handle||!b(this.options.handle,this.element).length?true:false;b(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==
|
36 |
+
c.target)f=true});return f},_createHelper:function(c){var f=this.options;c=b.isFunction(f.helper)?b(f.helper.apply(this.element[0],[c])):f.helper=="clone"?this.element.clone():this.element;c.parents("body").length||c.appendTo(f.appendTo=="parent"?this.element[0].parentNode:f.appendTo);c[0]!=this.element[0]&&!/(fixed|absolute)/.test(c.css("position"))&&c.css("position","absolute");return c},_adjustOffsetFromHelper:function(c){if(typeof c=="string")c=c.split(" ");if(b.isArray(c))c={left:+c[0],top:+c[1]||
|
37 |
+
0};if("left"in c)this.offset.click.left=c.left+this.margins.left;if("right"in c)this.offset.click.left=this.helperProportions.width-c.right+this.margins.left;if("top"in c)this.offset.click.top=c.top+this.margins.top;if("bottom"in c)this.offset.click.top=this.helperProportions.height-c.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var c=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&b.ui.contains(this.scrollParent[0],
|
38 |
+
this.offsetParent[0])){c.left+=this.scrollParent.scrollLeft();c.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&b.browser.msie)c={top:0,left:0};return{top:c.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:c.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var c=this.element.position();return{top:c.top-
|
39 |
+
(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:c.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var c=this.options;if(c.containment==
|
40 |
+
"parent")c.containment=this.helper[0].parentNode;if(c.containment=="document"||c.containment=="window")this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,b(c.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(b(c.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(c.containment)&&
|
41 |
+
c.containment.constructor!=Array){var f=b(c.containment)[0];if(f){c=b(c.containment).offset();var g=b(f).css("overflow")!="hidden";this.containment=[c.left+(parseInt(b(f).css("borderLeftWidth"),10)||0)+(parseInt(b(f).css("paddingLeft"),10)||0)-this.margins.left,c.top+(parseInt(b(f).css("borderTopWidth"),10)||0)+(parseInt(b(f).css("paddingTop"),10)||0)-this.margins.top,c.left+(g?Math.max(f.scrollWidth,f.offsetWidth):f.offsetWidth)-(parseInt(b(f).css("borderLeftWidth"),10)||0)-(parseInt(b(f).css("paddingRight"),
|
42 |
+
10)||0)-this.helperProportions.width-this.margins.left,c.top+(g?Math.max(f.scrollHeight,f.offsetHeight):f.offsetHeight)-(parseInt(b(f).css("borderTopWidth"),10)||0)-(parseInt(b(f).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}}else if(c.containment.constructor==Array)this.containment=c.containment},_convertPositionTo:function(c,f){if(!f)f=this.position;c=c=="absolute"?1:-1;var g=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&b.ui.contains(this.scrollParent[0],
|
43 |
+
this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(g[0].tagName);return{top:f.top+this.offset.relative.top*c+this.offset.parent.top*c-(b.browser.safari&&b.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():e?0:g.scrollTop())*c),left:f.left+this.offset.relative.left*c+this.offset.parent.left*c-(b.browser.safari&&b.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():
|
44 |
+
e?0:g.scrollLeft())*c)}},_generatePosition:function(c){var f=this.options,g=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&b.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(g[0].tagName),a=c.pageX,d=c.pageY;if(this.originalPosition){if(this.containment){if(c.pageX-this.offset.click.left<this.containment[0])a=this.containment[0]+this.offset.click.left;if(c.pageY-this.offset.click.top<this.containment[1])d=this.containment[1]+
|
45 |
+
this.offset.click.top;if(c.pageX-this.offset.click.left>this.containment[2])a=this.containment[2]+this.offset.click.left;if(c.pageY-this.offset.click.top>this.containment[3])d=this.containment[3]+this.offset.click.top}if(f.grid){d=this.originalPageY+Math.round((d-this.originalPageY)/f.grid[1])*f.grid[1];d=this.containment?!(d-this.offset.click.top<this.containment[1]||d-this.offset.click.top>this.containment[3])?d:!(d-this.offset.click.top<this.containment[1])?d-f.grid[1]:d+f.grid[1]:d;a=this.originalPageX+
|
46 |
+
Math.round((a-this.originalPageX)/f.grid[0])*f.grid[0];a=this.containment?!(a-this.offset.click.left<this.containment[0]||a-this.offset.click.left>this.containment[2])?a:!(a-this.offset.click.left<this.containment[0])?a-f.grid[0]:a+f.grid[0]:a}}return{top:d-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(b.browser.safari&&b.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():e?0:g.scrollTop()),left:a-this.offset.click.left-
|
47 |
+
this.offset.relative.left-this.offset.parent.left+(b.browser.safari&&b.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():e?0:g.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging");this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove();this.helper=null;this.cancelHelperRemoval=false},_trigger:function(c,f,g){g=g||this._uiHash();b.ui.plugin.call(this,c,[f,g]);if(c=="drag")this.positionAbs=
|
48 |
+
this._convertPositionTo("absolute");return b.Widget.prototype._trigger.call(this,c,f,g)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}});b.extend(b.ui.draggable,{version:"1.8.6"});b.ui.plugin.add("draggable","connectToSortable",{start:function(c,f){var g=b(this).data("draggable"),e=g.options,a=b.extend({},f,{item:g.element});g.sortables=[];b(e.connectToSortable).each(function(){var d=b.data(this,"sortable");
|
49 |
+
if(d&&!d.options.disabled){g.sortables.push({instance:d,shouldRevert:d.options.revert});d._refreshItems();d._trigger("activate",c,a)}})},stop:function(c,f){var g=b(this).data("draggable"),e=b.extend({},f,{item:g.element});b.each(g.sortables,function(){if(this.instance.isOver){this.instance.isOver=0;g.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert)this.instance.options.revert=true;this.instance._mouseStop(c);this.instance.options.helper=this.instance.options._helper;
|
50 |
+
g.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})}else{this.instance.cancelHelperRemoval=false;this.instance._trigger("deactivate",c,e)}})},drag:function(c,f){var g=b(this).data("draggable"),e=this;b.each(g.sortables,function(){this.instance.positionAbs=g.positionAbs;this.instance.helperProportions=g.helperProportions;this.instance.offset.click=g.offset.click;if(this.instance._intersectsWith(this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=
|
51 |
+
1;this.instance.currentItem=b(e).clone().appendTo(this.instance.element).data("sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return f.helper[0]};c.target=this.instance.currentItem[0];this.instance._mouseCapture(c,true);this.instance._mouseStart(c,true,true);this.instance.offset.click.top=g.offset.click.top;this.instance.offset.click.left=g.offset.click.left;this.instance.offset.parent.left-=g.offset.parent.left-this.instance.offset.parent.left;
|
52 |
+
this.instance.offset.parent.top-=g.offset.parent.top-this.instance.offset.parent.top;g._trigger("toSortable",c);g.dropped=this.instance.element;g.currentItem=g.element;this.instance.fromOutside=g}this.instance.currentItem&&this.instance._mouseDrag(c)}else if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._trigger("out",c,this.instance._uiHash(this.instance));this.instance._mouseStop(c,true);this.instance.options.helper=
|
53 |
+
this.instance.options._helper;this.instance.currentItem.remove();this.instance.placeholder&&this.instance.placeholder.remove();g._trigger("fromSortable",c);g.dropped=false}})}});b.ui.plugin.add("draggable","cursor",{start:function(){var c=b("body"),f=b(this).data("draggable").options;if(c.css("cursor"))f._cursor=c.css("cursor");c.css("cursor",f.cursor)},stop:function(){var c=b(this).data("draggable").options;c._cursor&&b("body").css("cursor",c._cursor)}});b.ui.plugin.add("draggable","iframeFix",{start:function(){var c=
|
54 |
+
b(this).data("draggable").options;b(c.iframeFix===true?"iframe":c.iframeFix).each(function(){b('<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(b(this).offset()).appendTo("body")})},stop:function(){b("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)})}});b.ui.plugin.add("draggable","opacity",{start:function(c,f){c=b(f.helper);f=b(this).data("draggable").options;
|
55 |
+
if(c.css("opacity"))f._opacity=c.css("opacity");c.css("opacity",f.opacity)},stop:function(c,f){c=b(this).data("draggable").options;c._opacity&&b(f.helper).css("opacity",c._opacity)}});b.ui.plugin.add("draggable","scroll",{start:function(){var c=b(this).data("draggable");if(c.scrollParent[0]!=document&&c.scrollParent[0].tagName!="HTML")c.overflowOffset=c.scrollParent.offset()},drag:function(c){var f=b(this).data("draggable"),g=f.options,e=false;if(f.scrollParent[0]!=document&&f.scrollParent[0].tagName!=
|
56 |
+
"HTML"){if(!g.axis||g.axis!="x")if(f.overflowOffset.top+f.scrollParent[0].offsetHeight-c.pageY<g.scrollSensitivity)f.scrollParent[0].scrollTop=e=f.scrollParent[0].scrollTop+g.scrollSpeed;else if(c.pageY-f.overflowOffset.top<g.scrollSensitivity)f.scrollParent[0].scrollTop=e=f.scrollParent[0].scrollTop-g.scrollSpeed;if(!g.axis||g.axis!="y")if(f.overflowOffset.left+f.scrollParent[0].offsetWidth-c.pageX<g.scrollSensitivity)f.scrollParent[0].scrollLeft=e=f.scrollParent[0].scrollLeft+g.scrollSpeed;else if(c.pageX-
|
57 |
+
f.overflowOffset.left<g.scrollSensitivity)f.scrollParent[0].scrollLeft=e=f.scrollParent[0].scrollLeft-g.scrollSpeed}else{if(!g.axis||g.axis!="x")if(c.pageY-b(document).scrollTop()<g.scrollSensitivity)e=b(document).scrollTop(b(document).scrollTop()-g.scrollSpeed);else if(b(window).height()-(c.pageY-b(document).scrollTop())<g.scrollSensitivity)e=b(document).scrollTop(b(document).scrollTop()+g.scrollSpeed);if(!g.axis||g.axis!="y")if(c.pageX-b(document).scrollLeft()<g.scrollSensitivity)e=b(document).scrollLeft(b(document).scrollLeft()-
|
58 |
+
g.scrollSpeed);else if(b(window).width()-(c.pageX-b(document).scrollLeft())<g.scrollSensitivity)e=b(document).scrollLeft(b(document).scrollLeft()+g.scrollSpeed)}e!==false&&b.ui.ddmanager&&!g.dropBehaviour&&b.ui.ddmanager.prepareOffsets(f,c)}});b.ui.plugin.add("draggable","snap",{start:function(){var c=b(this).data("draggable"),f=c.options;c.snapElements=[];b(f.snap.constructor!=String?f.snap.items||":data(draggable)":f.snap).each(function(){var g=b(this),e=g.offset();this!=c.element[0]&&c.snapElements.push({item:this,
|
59 |
+
width:g.outerWidth(),height:g.outerHeight(),top:e.top,left:e.left})})},drag:function(c,f){for(var g=b(this).data("draggable"),e=g.options,a=e.snapTolerance,d=f.offset.left,h=d+g.helperProportions.width,i=f.offset.top,j=i+g.helperProportions.height,n=g.snapElements.length-1;n>=0;n--){var q=g.snapElements[n].left,l=q+g.snapElements[n].width,k=g.snapElements[n].top,m=k+g.snapElements[n].height;if(q-a<d&&d<l+a&&k-a<i&&i<m+a||q-a<d&&d<l+a&&k-a<j&&j<m+a||q-a<h&&h<l+a&&k-a<i&&i<m+a||q-a<h&&h<l+a&&k-a<j&&
|
60 |
+
j<m+a){if(e.snapMode!="inner"){var o=Math.abs(k-j)<=a,p=Math.abs(m-i)<=a,s=Math.abs(q-h)<=a,r=Math.abs(l-d)<=a;if(o)f.position.top=g._convertPositionTo("relative",{top:k-g.helperProportions.height,left:0}).top-g.margins.top;if(p)f.position.top=g._convertPositionTo("relative",{top:m,left:0}).top-g.margins.top;if(s)f.position.left=g._convertPositionTo("relative",{top:0,left:q-g.helperProportions.width}).left-g.margins.left;if(r)f.position.left=g._convertPositionTo("relative",{top:0,left:l}).left-g.margins.left}var u=
|
61 |
+
o||p||s||r;if(e.snapMode!="outer"){o=Math.abs(k-i)<=a;p=Math.abs(m-j)<=a;s=Math.abs(q-d)<=a;r=Math.abs(l-h)<=a;if(o)f.position.top=g._convertPositionTo("relative",{top:k,left:0}).top-g.margins.top;if(p)f.position.top=g._convertPositionTo("relative",{top:m-g.helperProportions.height,left:0}).top-g.margins.top;if(s)f.position.left=g._convertPositionTo("relative",{top:0,left:q}).left-g.margins.left;if(r)f.position.left=g._convertPositionTo("relative",{top:0,left:l-g.helperProportions.width}).left-g.margins.left}if(!g.snapElements[n].snapping&&
|
62 |
+
(o||p||s||r||u))g.options.snap.snap&&g.options.snap.snap.call(g.element,c,b.extend(g._uiHash(),{snapItem:g.snapElements[n].item}));g.snapElements[n].snapping=o||p||s||r||u}else{g.snapElements[n].snapping&&g.options.snap.release&&g.options.snap.release.call(g.element,c,b.extend(g._uiHash(),{snapItem:g.snapElements[n].item}));g.snapElements[n].snapping=false}}}});b.ui.plugin.add("draggable","stack",{start:function(){var c=b(this).data("draggable").options;c=b.makeArray(b(c.stack)).sort(function(g,e){return(parseInt(b(g).css("zIndex"),
|
63 |
+
10)||0)-(parseInt(b(e).css("zIndex"),10)||0)});if(c.length){var f=parseInt(c[0].style.zIndex)||0;b(c).each(function(g){this.style.zIndex=f+g});this[0].style.zIndex=f+c.length}}});b.ui.plugin.add("draggable","zIndex",{start:function(c,f){c=b(f.helper);f=b(this).data("draggable").options;if(c.css("zIndex"))f._zIndex=c.css("zIndex");c.css("zIndex",f.zIndex)},stop:function(c,f){c=b(this).data("draggable").options;c._zIndex&&b(f.helper).css("zIndex",c._zIndex)}})})(jQuery);
|
64 |
+
(function(b){b.widget("ui.droppable",{widgetEventPrefix:"drop",options:{accept:"*",activeClass:false,addClasses:true,greedy:false,hoverClass:false,scope:"default",tolerance:"intersect"},_create:function(){var c=this.options,f=c.accept;this.isover=0;this.isout=1;this.accept=b.isFunction(f)?f:function(g){return g.is(f)};this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight};b.ui.ddmanager.droppables[c.scope]=b.ui.ddmanager.droppables[c.scope]||[];b.ui.ddmanager.droppables[c.scope].push(this);
|
65 |
+
c.addClasses&&this.element.addClass("ui-droppable")},destroy:function(){for(var c=b.ui.ddmanager.droppables[this.options.scope],f=0;f<c.length;f++)c[f]==this&&c.splice(f,1);this.element.removeClass("ui-droppable ui-droppable-disabled").removeData("droppable").unbind(".droppable");return this},_setOption:function(c,f){if(c=="accept")this.accept=b.isFunction(f)?f:function(g){return g.is(f)};b.Widget.prototype._setOption.apply(this,arguments)},_activate:function(c){var f=b.ui.ddmanager.current;this.options.activeClass&&
|
66 |
+
this.element.addClass(this.options.activeClass);f&&this._trigger("activate",c,this.ui(f))},_deactivate:function(c){var f=b.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass);f&&this._trigger("deactivate",c,this.ui(f))},_over:function(c){var f=b.ui.ddmanager.current;if(!(!f||(f.currentItem||f.element)[0]==this.element[0]))if(this.accept.call(this.element[0],f.currentItem||f.element)){this.options.hoverClass&&this.element.addClass(this.options.hoverClass);
|
67 |
+
this._trigger("over",c,this.ui(f))}},_out:function(c){var f=b.ui.ddmanager.current;if(!(!f||(f.currentItem||f.element)[0]==this.element[0]))if(this.accept.call(this.element[0],f.currentItem||f.element)){this.options.hoverClass&&this.element.removeClass(this.options.hoverClass);this._trigger("out",c,this.ui(f))}},_drop:function(c,f){var g=f||b.ui.ddmanager.current;if(!g||(g.currentItem||g.element)[0]==this.element[0])return false;var e=false;this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var a=
|
68 |
+
b.data(this,"droppable");if(a.options.greedy&&!a.options.disabled&&a.options.scope==g.options.scope&&a.accept.call(a.element[0],g.currentItem||g.element)&&b.ui.intersect(g,b.extend(a,{offset:a.element.offset()}),a.options.tolerance)){e=true;return false}});if(e)return false;if(this.accept.call(this.element[0],g.currentItem||g.element)){this.options.activeClass&&this.element.removeClass(this.options.activeClass);this.options.hoverClass&&this.element.removeClass(this.options.hoverClass);this._trigger("drop",
|
69 |
+
c,this.ui(g));return this.element}return false},ui:function(c){return{draggable:c.currentItem||c.element,helper:c.helper,position:c.position,offset:c.positionAbs}}});b.extend(b.ui.droppable,{version:"1.8.6"});b.ui.intersect=function(c,f,g){if(!f.offset)return false;var e=(c.positionAbs||c.position.absolute).left,a=e+c.helperProportions.width,d=(c.positionAbs||c.position.absolute).top,h=d+c.helperProportions.height,i=f.offset.left,j=i+f.proportions.width,n=f.offset.top,q=n+f.proportions.height;
|
70 |
+
switch(g){case "fit":return i<=e&&a<=j&&n<=d&&h<=q;case "intersect":return i<e+c.helperProportions.width/2&&a-c.helperProportions.width/2<j&&n<d+c.helperProportions.height/2&&h-c.helperProportions.height/2<q;case "pointer":return b.ui.isOver((c.positionAbs||c.position.absolute).top+(c.clickOffset||c.offset.click).top,(c.positionAbs||c.position.absolute).left+(c.clickOffset||c.offset.click).left,n,i,f.proportions.height,f.proportions.width);case "touch":return(d>=n&&d<=q||h>=n&&h<=q||d<n&&h>q)&&(e>=
|
71 |
+
i&&e<=j||a>=i&&a<=j||e<i&&a>j);default:return false}};b.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(c,f){var g=b.ui.ddmanager.droppables[c.options.scope]||[],e=f?f.type:null,a=(c.currentItem||c.element).find(":data(droppable)").andSelf(),d=0;a:for(;d<g.length;d++)if(!(g[d].options.disabled||c&&!g[d].accept.call(g[d].element[0],c.currentItem||c.element))){for(var h=0;h<a.length;h++)if(a[h]==g[d].element[0]){g[d].proportions.height=0;continue a}g[d].visible=g[d].element.css("display")!=
|
72 |
+
"none";if(g[d].visible){g[d].offset=g[d].element.offset();g[d].proportions={width:g[d].element[0].offsetWidth,height:g[d].element[0].offsetHeight};e=="mousedown"&&g[d]._activate.call(g[d],f)}}},drop:function(c,f){var g=false;b.each(b.ui.ddmanager.droppables[c.options.scope]||[],function(){if(this.options){if(!this.options.disabled&&this.visible&&b.ui.intersect(c,this,this.options.tolerance))g=g||this._drop.call(this,f);if(!this.options.disabled&&this.visible&&this.accept.call(this.element[0],c.currentItem||
|
73 |
+
c.element)){this.isout=1;this.isover=0;this._deactivate.call(this,f)}}});return g},drag:function(c,f){c.options.refreshPositions&&b.ui.ddmanager.prepareOffsets(c,f);b.each(b.ui.ddmanager.droppables[c.options.scope]||[],function(){if(!(this.options.disabled||this.greedyChild||!this.visible)){var g=b.ui.intersect(c,this,this.options.tolerance);if(g=!g&&this.isover==1?"isout":g&&this.isover==0?"isover":null){var e;if(this.options.greedy){var a=this.element.parents(":data(droppable):eq(0)");if(a.length){e=
|
74 |
+
b.data(a[0],"droppable");e.greedyChild=g=="isover"?1:0}}if(e&&g=="isover"){e.isover=0;e.isout=1;e._out.call(e,f)}this[g]=1;this[g=="isout"?"isover":"isout"]=0;this[g=="isover"?"_over":"_out"].call(this,f);if(e&&g=="isout"){e.isout=0;e.isover=1;e._over.call(e,f)}}}})}}})(jQuery);
|
75 |
+
(function(b){b.widget("ui.resizable",b.ui.mouse,{widgetEventPrefix:"resize",options:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,containment:false,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1E3},_create:function(){var g=this,e=this.options;this.element.addClass("ui-resizable");b.extend(this,{_aspectRatio:!!e.aspectRatio,aspectRatio:e.aspectRatio,originalElement:this.element,
|
76 |
+
_proportionallyResizeElements:[],_helper:e.helper||e.ghost||e.animate?e.helper||"ui-resizable-helper":null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){/relative/.test(this.element.css("position"))&&b.browser.opera&&this.element.css({position:"relative",top:"auto",left:"auto"});this.element.wrap(b('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),
|
77 |
+
top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;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=
|
78 |
+
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=e.handles||(!b(".ui-resizable-handle",this.element).length?"e,s,se":{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",
|
79 |
+
nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all")this.handles="n,e,s,w,se,sw,ne,nw";var a=this.handles.split(",");this.handles={};for(var d=0;d<a.length;d++){var h=b.trim(a[d]),i=b('<div class="ui-resizable-handle '+("ui-resizable-"+h)+'"></div>');/sw|se|ne|nw/.test(h)&&i.css({zIndex:++e.zIndex});"se"==h&&i.addClass("ui-icon ui-icon-gripsmall-diagonal-se");this.handles[h]=".ui-resizable-"+h;this.element.append(i)}}this._renderAxis=function(j){j=j||this.element;for(var n in this.handles){if(this.handles[n].constructor==
|
80 |
+
String)this.handles[n]=b(this.handles[n],this.element).show();if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var q=b(this.handles[n],this.element),l=0;l=/sw|ne|nw|se|n|s/.test(n)?q.outerHeight():q.outerWidth();q=["padding",/ne|nw|n/.test(n)?"Top":/se|sw|s/.test(n)?"Bottom":/^e$/.test(n)?"Right":"Left"].join("");j.css(q,l);this._proportionallyResize()}b(this.handles[n])}};this._renderAxis(this.element);this._handles=b(".ui-resizable-handle",this.element).disableSelection();
|
81 |
+
this._handles.mouseover(function(){if(!g.resizing){if(this.className)var j=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);g.axis=j&&j[1]?j[1]:"se"}});if(e.autoHide){this._handles.hide();b(this.element).addClass("ui-resizable-autohide").hover(function(){b(this).removeClass("ui-resizable-autohide");g._handles.show()},function(){if(!g.resizing){b(this).addClass("ui-resizable-autohide");g._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy();var g=function(a){b(a).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};
|
82 |
+
if(this.elementIsWrapper){g(this.element);var e=this.element;e.after(this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);g(this.originalElement);return this},_mouseCapture:function(g){var e=false;for(var a in this.handles)if(b(this.handles[a])[0]==g.target)e=true;return!this.options.disabled&&e},_mouseStart:function(g){var e=this.options,a=this.element.position(),
|
83 |
+
d=this.element;this.resizing=true;this.documentScroll={top:b(document).scrollTop(),left:b(document).scrollLeft()};if(d.is(".ui-draggable")||/absolute/.test(d.css("position")))d.css({position:"absolute",top:a.top,left:a.left});b.browser.opera&&/relative/.test(d.css("position"))&&d.css({position:"relative",top:"auto",left:"auto"});this._renderProxy();a=c(this.helper.css("left"));var h=c(this.helper.css("top"));if(e.containment){a+=b(e.containment).scrollLeft()||0;h+=b(e.containment).scrollTop()||0}this.offset=
|
84 |
+
this.helper.offset();this.position={left:a,top:h};this.size=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalSize=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalPosition={left:a,top:h};this.sizeDiff={width:d.outerWidth()-d.width(),height:d.outerHeight()-d.height()};this.originalMousePosition={left:g.pageX,top:g.pageY};this.aspectRatio=typeof e.aspectRatio=="number"?e.aspectRatio:
|
85 |
+
this.originalSize.width/this.originalSize.height||1;e=b(".ui-resizable-"+this.axis).css("cursor");b("body").css("cursor",e=="auto"?this.axis+"-resize":e);d.addClass("ui-resizable-resizing");this._propagate("start",g);return true},_mouseDrag:function(g){var e=this.helper,a=this.originalMousePosition,d=this._change[this.axis];if(!d)return false;a=d.apply(this,[g,g.pageX-a.left||0,g.pageY-a.top||0]);if(this._aspectRatio||g.shiftKey)a=this._updateRatio(a,g);a=this._respectSize(a,g);this._propagate("resize",
|
86 |
+
g);e.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize();this._updateCache(a);this._trigger("resize",g,this.ui());return false},_mouseStop:function(g){this.resizing=false;var e=this.options,a=this;if(this._helper){var d=this._proportionallyResizeElements,h=d.length&&/textarea/i.test(d[0].nodeName);d=h&&b.ui.hasScroll(d[0],"left")?0:a.sizeDiff.height;
|
87 |
+
h={width:a.size.width-(h?0:a.sizeDiff.width),height:a.size.height-d};d=parseInt(a.element.css("left"),10)+(a.position.left-a.originalPosition.left)||null;var i=parseInt(a.element.css("top"),10)+(a.position.top-a.originalPosition.top)||null;e.animate||this.element.css(b.extend(h,{top:i,left:d}));a.helper.height(a.size.height);a.helper.width(a.size.width);this._helper&&!e.animate&&this._proportionallyResize()}b("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",
|
88 |
+
g);this._helper&&this.helper.remove();return false},_updateCache:function(g){this.offset=this.helper.offset();if(f(g.left))this.position.left=g.left;if(f(g.top))this.position.top=g.top;if(f(g.height))this.size.height=g.height;if(f(g.width))this.size.width=g.width},_updateRatio:function(g){var e=this.position,a=this.size,d=this.axis;if(g.height)g.width=a.height*this.aspectRatio;else if(g.width)g.height=a.width/this.aspectRatio;if(d=="sw"){g.left=e.left+(a.width-g.width);g.top=null}if(d=="nw"){g.top=
|
89 |
+
e.top+(a.height-g.height);g.left=e.left+(a.width-g.width)}return g},_respectSize:function(g){var e=this.options,a=this.axis,d=f(g.width)&&e.maxWidth&&e.maxWidth<g.width,h=f(g.height)&&e.maxHeight&&e.maxHeight<g.height,i=f(g.width)&&e.minWidth&&e.minWidth>g.width,j=f(g.height)&&e.minHeight&&e.minHeight>g.height;if(i)g.width=e.minWidth;if(j)g.height=e.minHeight;if(d)g.width=e.maxWidth;if(h)g.height=e.maxHeight;var n=this.originalPosition.left+this.originalSize.width,q=this.position.top+this.size.height,
|
90 |
+
l=/sw|nw|w/.test(a);a=/nw|ne|n/.test(a);if(i&&l)g.left=n-e.minWidth;if(d&&l)g.left=n-e.maxWidth;if(j&&a)g.top=q-e.minHeight;if(h&&a)g.top=q-e.maxHeight;if((e=!g.width&&!g.height)&&!g.left&&g.top)g.top=null;else if(e&&!g.top&&g.left)g.left=null;return g},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var g=this.helper||this.element,e=0;e<this._proportionallyResizeElements.length;e++){var a=this._proportionallyResizeElements[e];if(!this.borderDif){var d=[a.css("borderTopWidth"),
|
91 |
+
a.css("borderRightWidth"),a.css("borderBottomWidth"),a.css("borderLeftWidth")],h=[a.css("paddingTop"),a.css("paddingRight"),a.css("paddingBottom"),a.css("paddingLeft")];this.borderDif=b.map(d,function(i,j){i=parseInt(i,10)||0;j=parseInt(h[j],10)||0;return i+j})}b.browser.msie&&(b(g).is(":hidden")||b(g).parents(":hidden").length)||a.css({height:g.height()-this.borderDif[0]-this.borderDif[2]||0,width:g.width()-this.borderDif[1]-this.borderDif[3]||0})}},_renderProxy:function(){var g=this.options;this.elementOffset=
|
92 |
+
this.element.offset();if(this._helper){this.helper=this.helper||b('<div style="overflow:hidden;"></div>');var e=b.browser.msie&&b.browser.version<7,a=e?1:0;e=e?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+e,height:this.element.outerHeight()+e,position:"absolute",left:this.elementOffset.left-a+"px",top:this.elementOffset.top-a+"px",zIndex:++g.zIndex});this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(g,e){return{width:this.originalSize.width+
|
93 |
+
e}},w:function(g,e){return{left:this.originalPosition.left+e,width:this.originalSize.width-e}},n:function(g,e,a){return{top:this.originalPosition.top+a,height:this.originalSize.height-a}},s:function(g,e,a){return{height:this.originalSize.height+a}},se:function(g,e,a){return b.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[g,e,a]))},sw:function(g,e,a){return b.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[g,e,a]))},ne:function(g,e,a){return b.extend(this._change.n.apply(this,
|
94 |
+
arguments),this._change.e.apply(this,[g,e,a]))},nw:function(g,e,a){return b.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[g,e,a]))}},_propagate:function(g,e){b.ui.plugin.call(this,g,[e,this.ui()]);g!="resize"&&this._trigger(g,e,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}}});b.extend(b.ui.resizable,
|
95 |
+
{version:"1.8.6"});b.ui.plugin.add("resizable","alsoResize",{start:function(){var g=b(this).data("resizable").options,e=function(a){b(a).each(function(){var d=b(this);d.data("resizable-alsoresize",{width:parseInt(d.width(),10),height:parseInt(d.height(),10),left:parseInt(d.css("left"),10),top:parseInt(d.css("top"),10),position:d.css("position")})})};if(typeof g.alsoResize=="object"&&!g.alsoResize.parentNode)if(g.alsoResize.length){g.alsoResize=g.alsoResize[0];e(g.alsoResize)}else b.each(g.alsoResize,
|
96 |
+
function(a){e(a)});else e(g.alsoResize)},resize:function(g,e){var a=b(this).data("resizable");g=a.options;var d=a.originalSize,h=a.originalPosition,i={height:a.size.height-d.height||0,width:a.size.width-d.width||0,top:a.position.top-h.top||0,left:a.position.left-h.left||0},j=function(n,q){b(n).each(function(){var l=b(this),k=b(this).data("resizable-alsoresize"),m={},o=q&&q.length?q:l.parents(e.originalElement[0]).length?["width","height"]:["width","height","top","left"];b.each(o,function(p,s){if((p=
|
97 |
+
(k[s]||0)+(i[s]||0))&&p>=0)m[s]=p||null});if(b.browser.opera&&/relative/.test(l.css("position"))){a._revertToRelativePosition=true;l.css({position:"absolute",top:"auto",left:"auto"})}l.css(m)})};typeof g.alsoResize=="object"&&!g.alsoResize.nodeType?b.each(g.alsoResize,function(n,q){j(n,q)}):j(g.alsoResize)},stop:function(){var g=b(this).data("resizable"),e=g.options,a=function(d){b(d).each(function(){var h=b(this);h.css({position:h.data("resizable-alsoresize").position})})};if(g._revertToRelativePosition){g._revertToRelativePosition=
|
98 |
+
false;typeof e.alsoResize=="object"&&!e.alsoResize.nodeType?b.each(e.alsoResize,function(d){a(d)}):a(e.alsoResize)}b(this).removeData("resizable-alsoresize")}});b.ui.plugin.add("resizable","animate",{stop:function(g){var e=b(this).data("resizable"),a=e.options,d=e._proportionallyResizeElements,h=d.length&&/textarea/i.test(d[0].nodeName),i=h&&b.ui.hasScroll(d[0],"left")?0:e.sizeDiff.height;h={width:e.size.width-(h?0:e.sizeDiff.width),height:e.size.height-i};i=parseInt(e.element.css("left"),10)+(e.position.left-
|
99 |
+
e.originalPosition.left)||null;var j=parseInt(e.element.css("top"),10)+(e.position.top-e.originalPosition.top)||null;e.element.animate(b.extend(h,j&&i?{top:j,left:i}:{}),{duration:a.animateDuration,easing:a.animateEasing,step:function(){var n={width:parseInt(e.element.css("width"),10),height:parseInt(e.element.css("height"),10),top:parseInt(e.element.css("top"),10),left:parseInt(e.element.css("left"),10)};d&&d.length&&b(d[0]).css({width:n.width,height:n.height});e._updateCache(n);e._propagate("resize",
|
100 |
+
g)}})}});b.ui.plugin.add("resizable","containment",{start:function(){var g=b(this).data("resizable"),e=g.element,a=g.options.containment;if(e=a instanceof b?a.get(0):/parent/.test(a)?e.parent().get(0):a){g.containerElement=b(e);if(/document/.test(a)||a==document){g.containerOffset={left:0,top:0};g.containerPosition={left:0,top:0};g.parentData={element:b(document),left:0,top:0,width:b(document).width(),height:b(document).height()||document.body.parentNode.scrollHeight}}else{var d=b(e),h=[];b(["Top",
|
101 |
+
"Right","Left","Bottom"]).each(function(n,q){h[n]=c(d.css("padding"+q))});g.containerOffset=d.offset();g.containerPosition=d.position();g.containerSize={height:d.innerHeight()-h[3],width:d.innerWidth()-h[1]};a=g.containerOffset;var i=g.containerSize.height,j=g.containerSize.width;j=b.ui.hasScroll(e,"left")?e.scrollWidth:j;i=b.ui.hasScroll(e)?e.scrollHeight:i;g.parentData={element:e,left:a.left,top:a.top,width:j,height:i}}}},resize:function(g){var e=b(this).data("resizable"),a=e.options,d=e.containerOffset,
|
102 |
+
h=e.position;g=e._aspectRatio||g.shiftKey;var i={top:0,left:0},j=e.containerElement;if(j[0]!=document&&/static/.test(j.css("position")))i=d;if(h.left<(e._helper?d.left:0)){e.size.width+=e._helper?e.position.left-d.left:e.position.left-i.left;if(g)e.size.height=e.size.width/a.aspectRatio;e.position.left=a.helper?d.left:0}if(h.top<(e._helper?d.top:0)){e.size.height+=e._helper?e.position.top-d.top:e.position.top;if(g)e.size.width=e.size.height*a.aspectRatio;e.position.top=e._helper?d.top:0}e.offset.left=
|
103 |
+
e.parentData.left+e.position.left;e.offset.top=e.parentData.top+e.position.top;a=Math.abs((e._helper?e.offset.left-i.left:e.offset.left-i.left)+e.sizeDiff.width);d=Math.abs((e._helper?e.offset.top-i.top:e.offset.top-d.top)+e.sizeDiff.height);h=e.containerElement.get(0)==e.element.parent().get(0);i=/relative|absolute/.test(e.containerElement.css("position"));if(h&&i)a-=e.parentData.left;if(a+e.size.width>=e.parentData.width){e.size.width=e.parentData.width-a;if(g)e.size.height=e.size.width/e.aspectRatio}if(d+
|
104 |
+
e.size.height>=e.parentData.height){e.size.height=e.parentData.height-d;if(g)e.size.width=e.size.height*e.aspectRatio}},stop:function(){var g=b(this).data("resizable"),e=g.options,a=g.containerOffset,d=g.containerPosition,h=g.containerElement,i=b(g.helper),j=i.offset(),n=i.outerWidth()-g.sizeDiff.width;i=i.outerHeight()-g.sizeDiff.height;g._helper&&!e.animate&&/relative/.test(h.css("position"))&&b(this).css({left:j.left-d.left-a.left,width:n,height:i});g._helper&&!e.animate&&/static/.test(h.css("position"))&&
|
105 |
+
b(this).css({left:j.left-d.left-a.left,width:n,height:i})}});b.ui.plugin.add("resizable","ghost",{start:function(){var g=b(this).data("resizable"),e=g.options,a=g.size;g.ghost=g.originalElement.clone();g.ghost.css({opacity:0.25,display:"block",position:"relative",height:a.height,width:a.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof e.ghost=="string"?e.ghost:"");g.ghost.appendTo(g.helper)},resize:function(){var g=b(this).data("resizable");g.ghost&&g.ghost.css({position:"relative",
|
106 |
+
height:g.size.height,width:g.size.width})},stop:function(){var g=b(this).data("resizable");g.ghost&&g.helper&&g.helper.get(0).removeChild(g.ghost.get(0))}});b.ui.plugin.add("resizable","grid",{resize:function(){var g=b(this).data("resizable"),e=g.options,a=g.size,d=g.originalSize,h=g.originalPosition,i=g.axis;e.grid=typeof e.grid=="number"?[e.grid,e.grid]:e.grid;var j=Math.round((a.width-d.width)/(e.grid[0]||1))*(e.grid[0]||1);e=Math.round((a.height-d.height)/(e.grid[1]||1))*(e.grid[1]||1);if(/^(se|s|e)$/.test(i)){g.size.width=
|
107 |
+
d.width+j;g.size.height=d.height+e}else if(/^(ne)$/.test(i)){g.size.width=d.width+j;g.size.height=d.height+e;g.position.top=h.top-e}else{if(/^(sw)$/.test(i)){g.size.width=d.width+j;g.size.height=d.height+e}else{g.size.width=d.width+j;g.size.height=d.height+e;g.position.top=h.top-e}g.position.left=h.left-j}}});var c=function(g){return parseInt(g,10)||0},f=function(g){return!isNaN(parseInt(g,10))}})(jQuery);
|
108 |
+
(function(b){b.widget("ui.selectable",b.ui.mouse,{options:{appendTo:"body",autoRefresh:true,distance:0,filter:"*",tolerance:"touch"},_create:function(){var c=this;this.element.addClass("ui-selectable");this.dragged=false;var f;this.refresh=function(){f=b(c.options.filter,c.element[0]);f.each(function(){var g=b(this),e=g.offset();b.data(this,"selectable-item",{element:this,$element:g,left:e.left,top:e.top,right:e.left+g.outerWidth(),bottom:e.top+g.outerHeight(),startselected:false,selected:g.hasClass("ui-selected"),
|
109 |
+
selecting:g.hasClass("ui-selecting"),unselecting:g.hasClass("ui-unselecting")})})};this.refresh();this.selectees=f.addClass("ui-selectee");this._mouseInit();this.helper=b("<div class='ui-selectable-helper'></div>")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(c){var f=this;this.opos=[c.pageX,
|
110 |
+
c.pageY];if(!this.options.disabled){var g=this.options;this.selectees=b(g.filter,this.element[0]);this._trigger("start",c);b(g.appendTo).append(this.helper);this.helper.css({left:c.clientX,top:c.clientY,width:0,height:0});g.autoRefresh&&this.refresh();this.selectees.filter(".ui-selected").each(function(){var e=b.data(this,"selectable-item");e.startselected=true;if(!c.metaKey){e.$element.removeClass("ui-selected");e.selected=false;e.$element.addClass("ui-unselecting");e.unselecting=true;f._trigger("unselecting",
|
111 |
+
c,{unselecting:e.element})}});b(c.target).parents().andSelf().each(function(){var e=b.data(this,"selectable-item");if(e){var a=!c.metaKey||!e.$element.hasClass("ui-selected");e.$element.removeClass(a?"ui-unselecting":"ui-selected").addClass(a?"ui-selecting":"ui-unselecting");e.unselecting=!a;e.selecting=a;(e.selected=a)?f._trigger("selecting",c,{selecting:e.element}):f._trigger("unselecting",c,{unselecting:e.element});return false}})}},_mouseDrag:function(c){var f=this;this.dragged=true;if(!this.options.disabled){var g=
|
112 |
+
this.options,e=this.opos[0],a=this.opos[1],d=c.pageX,h=c.pageY;if(e>d){var i=d;d=e;e=i}if(a>h){i=h;h=a;a=i}this.helper.css({left:e,top:a,width:d-e,height:h-a});this.selectees.each(function(){var j=b.data(this,"selectable-item");if(!(!j||j.element==f.element[0])){var n=false;if(g.tolerance=="touch")n=!(j.left>d||j.right<e||j.top>h||j.bottom<a);else if(g.tolerance=="fit")n=j.left>e&&j.right<d&&j.top>a&&j.bottom<h;if(n){if(j.selected){j.$element.removeClass("ui-selected");j.selected=false}if(j.unselecting){j.$element.removeClass("ui-unselecting");
|
113 |
+
j.unselecting=false}if(!j.selecting){j.$element.addClass("ui-selecting");j.selecting=true;f._trigger("selecting",c,{selecting:j.element})}}else{if(j.selecting)if(c.metaKey&&j.startselected){j.$element.removeClass("ui-selecting");j.selecting=false;j.$element.addClass("ui-selected");j.selected=true}else{j.$element.removeClass("ui-selecting");j.selecting=false;if(j.startselected){j.$element.addClass("ui-unselecting");j.unselecting=true}f._trigger("unselecting",c,{unselecting:j.element})}if(j.selected)if(!c.metaKey&&
|
114 |
+
!j.startselected){j.$element.removeClass("ui-selected");j.selected=false;j.$element.addClass("ui-unselecting");j.unselecting=true;f._trigger("unselecting",c,{unselecting:j.element})}}}});return false}},_mouseStop:function(c){var f=this;this.dragged=false;b(".ui-unselecting",this.element[0]).each(function(){var g=b.data(this,"selectable-item");g.$element.removeClass("ui-unselecting");g.unselecting=false;g.startselected=false;f._trigger("unselected",c,{unselected:g.element})});b(".ui-selecting",this.element[0]).each(function(){var g=
|
115 |
+
b.data(this,"selectable-item");g.$element.removeClass("ui-selecting").addClass("ui-selected");g.selecting=false;g.selected=true;g.startselected=true;f._trigger("selected",c,{selected:g.element})});this._trigger("stop",c);this.helper.remove();return false}});b.extend(b.ui.selectable,{version:"1.8.6"})})(jQuery);
|
116 |
+
(function(b){b.widget("ui.sortable",b.ui.mouse,{widgetEventPrefix:"sort",options:{appendTo:"parent",axis:false,connectWith:false,containment:false,cursor:"auto",cursorAt:false,dropOnEmpty:true,forcePlaceholderSize:false,forceHelperSize:false,grid:false,handle:false,helper:"original",items:"> *",opacity:false,placeholder:false,revert:false,scroll:true,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1E3},_create:function(){this.containerCache={};this.element.addClass("ui-sortable");
|
117 |
+
this.refresh();this.floating=this.items.length?/left|right/.test(this.items[0].item.css("float")):false;this.offset=this.element.offset();this._mouseInit()},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var c=this.items.length-1;c>=0;c--)this.items[c].item.removeData("sortable-item");return this},_setOption:function(c,f){if(c==="disabled"){this.options[c]=f;this.widget()[f?"addClass":"removeClass"]("ui-sortable-disabled")}else b.Widget.prototype._setOption.apply(this,
|
118 |
+
arguments)},_mouseCapture:function(c,f){if(this.reverting)return false;if(this.options.disabled||this.options.type=="static")return false;this._refreshItems(c);var g=null,e=this;b(c.target).parents().each(function(){if(b.data(this,"sortable-item")==e){g=b(this);return false}});if(b.data(c.target,"sortable-item")==e)g=b(c.target);if(!g)return false;if(this.options.handle&&!f){var a=false;b(this.options.handle,g).find("*").andSelf().each(function(){if(this==c.target)a=true});if(!a)return false}this.currentItem=
|
119 |
+
g;this._removeCurrentsFromItems();return true},_mouseStart:function(c,f,g){f=this.options;var e=this;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(c);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};this.helper.css("position","absolute");this.cssPosition=this.helper.css("position");b.extend(this.offset,
|
120 |
+
{click:{left:c.pageX-this.offset.left,top:c.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(c);this.originalPageX=c.pageX;this.originalPageY=c.pageY;f.cursorAt&&this._adjustOffsetFromHelper(f.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};this.helper[0]!=this.currentItem[0]&&this.currentItem.hide();this._createPlaceholder();f.containment&&this._setContainment();
|
121 |
+
if(f.cursor){if(b("body").css("cursor"))this._storedCursor=b("body").css("cursor");b("body").css("cursor",f.cursor)}if(f.opacity){if(this.helper.css("opacity"))this._storedOpacity=this.helper.css("opacity");this.helper.css("opacity",f.opacity)}if(f.zIndex){if(this.helper.css("zIndex"))this._storedZIndex=this.helper.css("zIndex");this.helper.css("zIndex",f.zIndex)}if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML")this.overflowOffset=this.scrollParent.offset();this._trigger("start",
|
122 |
+
c,this._uiHash());this._preserveHelperProportions||this._cacheHelperProportions();if(!g)for(g=this.containers.length-1;g>=0;g--)this.containers[g]._trigger("activate",c,e._uiHash(this));if(b.ui.ddmanager)b.ui.ddmanager.current=this;b.ui.ddmanager&&!f.dropBehaviour&&b.ui.ddmanager.prepareOffsets(this,c);this.dragging=true;this.helper.addClass("ui-sortable-helper");this._mouseDrag(c);return true},_mouseDrag:function(c){this.position=this._generatePosition(c);this.positionAbs=this._convertPositionTo("absolute");
|
123 |
+
if(!this.lastPositionAbs)this.lastPositionAbs=this.positionAbs;if(this.options.scroll){var f=this.options,g=false;if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"){if(this.overflowOffset.top+this.scrollParent[0].offsetHeight-c.pageY<f.scrollSensitivity)this.scrollParent[0].scrollTop=g=this.scrollParent[0].scrollTop+f.scrollSpeed;else if(c.pageY-this.overflowOffset.top<f.scrollSensitivity)this.scrollParent[0].scrollTop=g=this.scrollParent[0].scrollTop-f.scrollSpeed;if(this.overflowOffset.left+
|
124 |
+
this.scrollParent[0].offsetWidth-c.pageX<f.scrollSensitivity)this.scrollParent[0].scrollLeft=g=this.scrollParent[0].scrollLeft+f.scrollSpeed;else if(c.pageX-this.overflowOffset.left<f.scrollSensitivity)this.scrollParent[0].scrollLeft=g=this.scrollParent[0].scrollLeft-f.scrollSpeed}else{if(c.pageY-b(document).scrollTop()<f.scrollSensitivity)g=b(document).scrollTop(b(document).scrollTop()-f.scrollSpeed);else if(b(window).height()-(c.pageY-b(document).scrollTop())<f.scrollSensitivity)g=b(document).scrollTop(b(document).scrollTop()+
|
125 |
+
f.scrollSpeed);if(c.pageX-b(document).scrollLeft()<f.scrollSensitivity)g=b(document).scrollLeft(b(document).scrollLeft()-f.scrollSpeed);else if(b(window).width()-(c.pageX-b(document).scrollLeft())<f.scrollSensitivity)g=b(document).scrollLeft(b(document).scrollLeft()+f.scrollSpeed)}g!==false&&b.ui.ddmanager&&!f.dropBehaviour&&b.ui.ddmanager.prepareOffsets(this,c)}this.positionAbs=this._convertPositionTo("absolute");if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+
|
126 |
+
"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";for(f=this.items.length-1;f>=0;f--){g=this.items[f];var e=g.item[0],a=this._intersectsWithPointer(g);if(a)if(e!=this.currentItem[0]&&this.placeholder[a==1?"next":"prev"]()[0]!=e&&!b.ui.contains(this.placeholder[0],e)&&(this.options.type=="semi-dynamic"?!b.ui.contains(this.element[0],e):true)){this.direction=a==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(g))this._rearrange(c,
|
127 |
+
g);else break;this._trigger("change",c,this._uiHash());break}}this._contactContainers(c);b.ui.ddmanager&&b.ui.ddmanager.drag(this,c);this._trigger("sort",c,this._uiHash());this.lastPositionAbs=this.positionAbs;return false},_mouseStop:function(c,f){if(c){b.ui.ddmanager&&!this.options.dropBehaviour&&b.ui.ddmanager.drop(this,c);if(this.options.revert){var g=this;f=g.placeholder.offset();g.reverting=true;b(this.helper).animate({left:f.left-this.offset.parent.left-g.margins.left+(this.offsetParent[0]==
|
128 |
+
document.body?0:this.offsetParent[0].scrollLeft),top:f.top-this.offset.parent.top-g.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){g._clear(c)})}else this._clear(c,f);return false}},cancel:function(){var c=this;if(this.dragging){this._mouseUp();this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var f=this.containers.length-1;f>=0;f--){this.containers[f]._trigger("deactivate",
|
129 |
+
null,c._uiHash(this));if(this.containers[f].containerCache.over){this.containers[f]._trigger("out",null,c._uiHash(this));this.containers[f].containerCache.over=0}}}this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]);this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove();b.extend(this,{helper:null,dragging:false,reverting:false,_noFinalSort:null});this.domPosition.prev?b(this.domPosition.prev).after(this.currentItem):
|
130 |
+
b(this.domPosition.parent).prepend(this.currentItem);return this},serialize:function(c){var f=this._getItemsAsjQuery(c&&c.connected),g=[];c=c||{};b(f).each(function(){var e=(b(c.item||this).attr(c.attribute||"id")||"").match(c.expression||/(.+)[-=_](.+)/);if(e)g.push((c.key||e[1]+"[]")+"="+(c.key&&c.expression?e[1]:e[2]))});!g.length&&c.key&&g.push(c.key+"=");return g.join("&")},toArray:function(c){var f=this._getItemsAsjQuery(c&&c.connected),g=[];c=c||{};f.each(function(){g.push(b(c.item||this).attr(c.attribute||
|
131 |
+
"id")||"")});return g},_intersectsWith:function(c){var f=this.positionAbs.left,g=f+this.helperProportions.width,e=this.positionAbs.top,a=e+this.helperProportions.height,d=c.left,h=d+c.width,i=c.top,j=i+c.height,n=this.offset.click.top,q=this.offset.click.left;n=e+n>i&&e+n<j&&f+q>d&&f+q<h;return this.options.tolerance=="pointer"||this.options.forcePointerForContainers||this.options.tolerance!="pointer"&&this.helperProportions[this.floating?"width":"height"]>c[this.floating?"width":"height"]?n:d<f+
|
132 |
+
this.helperProportions.width/2&&g-this.helperProportions.width/2<h&&i<e+this.helperProportions.height/2&&a-this.helperProportions.height/2<j},_intersectsWithPointer:function(c){var f=b.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,c.top,c.height);c=b.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,c.left,c.width);f=f&&c;c=this._getDragVerticalDirection();var g=this._getDragHorizontalDirection();if(!f)return false;return this.floating?g&&g=="right"||c=="down"?2:1:c&&(c=="down"?
|
133 |
+
2:1)},_intersectsWithSides:function(c){var f=b.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,c.top+c.height/2,c.height);c=b.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,c.left+c.width/2,c.width);var g=this._getDragVerticalDirection(),e=this._getDragHorizontalDirection();return this.floating&&e?e=="right"&&c||e=="left"&&!c:g&&(g=="down"&&f||g=="up"&&!f)},_getDragVerticalDirection:function(){var c=this.positionAbs.top-this.lastPositionAbs.top;return c!=0&&(c>0?"down":"up")},
|
134 |
+
_getDragHorizontalDirection:function(){var c=this.positionAbs.left-this.lastPositionAbs.left;return c!=0&&(c>0?"right":"left")},refresh:function(c){this._refreshItems(c);this.refreshPositions();return this},_connectWith:function(){var c=this.options;return c.connectWith.constructor==String?[c.connectWith]:c.connectWith},_getItemsAsjQuery:function(c){var f=[],g=[],e=this._connectWith();if(e&&c)for(c=e.length-1;c>=0;c--)for(var a=b(e[c]),d=a.length-1;d>=0;d--){var h=b.data(a[d],"sortable");if(h&&h!=
|
135 |
+
this&&!h.options.disabled)g.push([b.isFunction(h.options.items)?h.options.items.call(h.element):b(h.options.items,h.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),h])}g.push([b.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):b(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(c=g.length-1;c>=0;c--)g[c][0].each(function(){f.push(this)});return b(f)},_removeCurrentsFromItems:function(){for(var c=
|
136 |
+
this.currentItem.find(":data(sortable-item)"),f=0;f<this.items.length;f++)for(var g=0;g<c.length;g++)c[g]==this.items[f].item[0]&&this.items.splice(f,1)},_refreshItems:function(c){this.items=[];this.containers=[this];var f=this.items,g=[[b.isFunction(this.options.items)?this.options.items.call(this.element[0],c,{item:this.currentItem}):b(this.options.items,this.element),this]],e=this._connectWith();if(e)for(var a=e.length-1;a>=0;a--)for(var d=b(e[a]),h=d.length-1;h>=0;h--){var i=b.data(d[h],"sortable");
|
137 |
+
if(i&&i!=this&&!i.options.disabled){g.push([b.isFunction(i.options.items)?i.options.items.call(i.element[0],c,{item:this.currentItem}):b(i.options.items,i.element),i]);this.containers.push(i)}}for(a=g.length-1;a>=0;a--){c=g[a][1];e=g[a][0];h=0;for(d=e.length;h<d;h++){i=b(e[h]);i.data("sortable-item",c);f.push({item:i,instance:c,width:0,height:0,left:0,top:0})}}},refreshPositions:function(c){if(this.offsetParent&&this.helper)this.offset.parent=this._getParentOffset();for(var f=this.items.length-1;f>=
|
138 |
+
0;f--){var g=this.items[f],e=this.options.toleranceElement?b(this.options.toleranceElement,g.item):g.item;if(!c){g.width=e.outerWidth();g.height=e.outerHeight()}e=e.offset();g.left=e.left;g.top=e.top}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(f=this.containers.length-1;f>=0;f--){e=this.containers[f].element.offset();this.containers[f].containerCache.left=e.left;this.containers[f].containerCache.top=e.top;this.containers[f].containerCache.width=
|
139 |
+
this.containers[f].element.outerWidth();this.containers[f].containerCache.height=this.containers[f].element.outerHeight()}return this},_createPlaceholder:function(c){var f=c||this,g=f.options;if(!g.placeholder||g.placeholder.constructor==String){var e=g.placeholder;g.placeholder={element:function(){var a=b(document.createElement(f.currentItem[0].nodeName)).addClass(e||f.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];if(!e)a.style.visibility="hidden";return a},
|
140 |
+
update:function(a,d){if(!(e&&!g.forcePlaceholderSize)){d.height()||d.height(f.currentItem.innerHeight()-parseInt(f.currentItem.css("paddingTop")||0,10)-parseInt(f.currentItem.css("paddingBottom")||0,10));d.width()||d.width(f.currentItem.innerWidth()-parseInt(f.currentItem.css("paddingLeft")||0,10)-parseInt(f.currentItem.css("paddingRight")||0,10))}}}}f.placeholder=b(g.placeholder.element.call(f.element,f.currentItem));f.currentItem.after(f.placeholder);g.placeholder.update(f,f.placeholder)},_contactContainers:function(c){for(var f=
|
141 |
+
null,g=null,e=this.containers.length-1;e>=0;e--)if(!b.ui.contains(this.currentItem[0],this.containers[e].element[0]))if(this._intersectsWith(this.containers[e].containerCache)){if(!(f&&b.ui.contains(this.containers[e].element[0],f.element[0]))){f=this.containers[e];g=e}}else if(this.containers[e].containerCache.over){this.containers[e]._trigger("out",c,this._uiHash(this));this.containers[e].containerCache.over=0}if(f)if(this.containers.length===1){this.containers[g]._trigger("over",c,this._uiHash(this));
|
142 |
+
this.containers[g].containerCache.over=1}else if(this.currentContainer!=this.containers[g]){f=1E4;e=null;for(var a=this.positionAbs[this.containers[g].floating?"left":"top"],d=this.items.length-1;d>=0;d--)if(b.ui.contains(this.containers[g].element[0],this.items[d].item[0])){var h=this.items[d][this.containers[g].floating?"left":"top"];if(Math.abs(h-a)<f){f=Math.abs(h-a);e=this.items[d]}}if(e||this.options.dropOnEmpty){this.currentContainer=this.containers[g];e?this._rearrange(c,e,null,true):this._rearrange(c,
|
143 |
+
null,this.containers[g].element,true);this._trigger("change",c,this._uiHash());this.containers[g]._trigger("change",c,this._uiHash(this));this.options.placeholder.update(this.currentContainer,this.placeholder);this.containers[g]._trigger("over",c,this._uiHash(this));this.containers[g].containerCache.over=1}}},_createHelper:function(c){var f=this.options;c=b.isFunction(f.helper)?b(f.helper.apply(this.element[0],[c,this.currentItem])):f.helper=="clone"?this.currentItem.clone():this.currentItem;c.parents("body").length||
|
144 |
+
b(f.appendTo!="parent"?f.appendTo:this.currentItem[0].parentNode)[0].appendChild(c[0]);if(c[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")};if(c[0].style.width==""||f.forceHelperSize)c.width(this.currentItem.width());if(c[0].style.height==""||f.forceHelperSize)c.height(this.currentItem.height());return c},_adjustOffsetFromHelper:function(c){if(typeof c==
|
145 |
+
"string")c=c.split(" ");if(b.isArray(c))c={left:+c[0],top:+c[1]||0};if("left"in c)this.offset.click.left=c.left+this.margins.left;if("right"in c)this.offset.click.left=this.helperProportions.width-c.right+this.margins.left;if("top"in c)this.offset.click.top=c.top+this.margins.top;if("bottom"in c)this.offset.click.top=this.helperProportions.height-c.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var c=this.offsetParent.offset();if(this.cssPosition==
|
146 |
+
"absolute"&&this.scrollParent[0]!=document&&b.ui.contains(this.scrollParent[0],this.offsetParent[0])){c.left+=this.scrollParent.scrollLeft();c.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&b.browser.msie)c={top:0,left:0};return{top:c.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:c.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition==
|
147 |
+
"relative"){var c=this.currentItem.position();return{top:c.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:c.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else 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()}},
|
148 |
+
_setContainment:function(){var c=this.options;if(c.containment=="parent")c.containment=this.helper[0].parentNode;if(c.containment=="document"||c.containment=="window")this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,b(c.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(b(c.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-
|
149 |
+
this.margins.top];if(!/^(document|window|parent)$/.test(c.containment)){var f=b(c.containment)[0];c=b(c.containment).offset();var g=b(f).css("overflow")!="hidden";this.containment=[c.left+(parseInt(b(f).css("borderLeftWidth"),10)||0)+(parseInt(b(f).css("paddingLeft"),10)||0)-this.margins.left,c.top+(parseInt(b(f).css("borderTopWidth"),10)||0)+(parseInt(b(f).css("paddingTop"),10)||0)-this.margins.top,c.left+(g?Math.max(f.scrollWidth,f.offsetWidth):f.offsetWidth)-(parseInt(b(f).css("borderLeftWidth"),
|
150 |
+
10)||0)-(parseInt(b(f).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,c.top+(g?Math.max(f.scrollHeight,f.offsetHeight):f.offsetHeight)-(parseInt(b(f).css("borderTopWidth"),10)||0)-(parseInt(b(f).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(c,f){if(!f)f=this.position;c=c=="absolute"?1:-1;var g=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&b.ui.contains(this.scrollParent[0],this.offsetParent[0]))?
|
151 |
+
this.offsetParent:this.scrollParent,e=/(html|body)/i.test(g[0].tagName);return{top:f.top+this.offset.relative.top*c+this.offset.parent.top*c-(b.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():e?0:g.scrollTop())*c),left:f.left+this.offset.relative.left*c+this.offset.parent.left*c-(b.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():e?0:g.scrollLeft())*c)}},_generatePosition:function(c){var f=
|
152 |
+
this.options,g=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&b.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(g[0].tagName);if(this.cssPosition=="relative"&&!(this.scrollParent[0]!=document&&this.scrollParent[0]!=this.offsetParent[0]))this.offset.relative=this._getRelativeOffset();var a=c.pageX,d=c.pageY;if(this.originalPosition){if(this.containment){if(c.pageX-this.offset.click.left<this.containment[0])a=this.containment[0]+
|
153 |
+
this.offset.click.left;if(c.pageY-this.offset.click.top<this.containment[1])d=this.containment[1]+this.offset.click.top;if(c.pageX-this.offset.click.left>this.containment[2])a=this.containment[2]+this.offset.click.left;if(c.pageY-this.offset.click.top>this.containment[3])d=this.containment[3]+this.offset.click.top}if(f.grid){d=this.originalPageY+Math.round((d-this.originalPageY)/f.grid[1])*f.grid[1];d=this.containment?!(d-this.offset.click.top<this.containment[1]||d-this.offset.click.top>this.containment[3])?
|
154 |
+
d:!(d-this.offset.click.top<this.containment[1])?d-f.grid[1]:d+f.grid[1]:d;a=this.originalPageX+Math.round((a-this.originalPageX)/f.grid[0])*f.grid[0];a=this.containment?!(a-this.offset.click.left<this.containment[0]||a-this.offset.click.left>this.containment[2])?a:!(a-this.offset.click.left<this.containment[0])?a-f.grid[0]:a+f.grid[0]:a}}return{top:d-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(b.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():
|
155 |
+
e?0:g.scrollTop()),left:a-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(b.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():e?0:g.scrollLeft())}},_rearrange:function(c,f,g,e){g?g[0].appendChild(this.placeholder[0]):f.item[0].parentNode.insertBefore(this.placeholder[0],this.direction=="down"?f.item[0]:f.item[0].nextSibling);this.counter=this.counter?++this.counter:1;var a=this,d=this.counter;window.setTimeout(function(){d==
|
156 |
+
a.counter&&a.refreshPositions(!e)},0)},_clear:function(c,f){this.reverting=false;var g=[];!this._noFinalSort&&this.currentItem[0].parentNode&&this.placeholder.before(this.currentItem);this._noFinalSort=null;if(this.helper[0]==this.currentItem[0]){for(var e in this._storedCSS)if(this._storedCSS[e]=="auto"||this._storedCSS[e]=="static")this._storedCSS[e]="";this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();this.fromOutside&&!f&&g.push(function(a){this._trigger("receive",
|
157 |
+
a,this._uiHash(this.fromOutside))});if((this.fromOutside||this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0])&&!f)g.push(function(a){this._trigger("update",a,this._uiHash())});if(!b.ui.contains(this.element[0],this.currentItem[0])){f||g.push(function(a){this._trigger("remove",a,this._uiHash())});for(e=this.containers.length-1;e>=0;e--)if(b.ui.contains(this.containers[e].element[0],this.currentItem[0])&&!f){g.push(function(a){return function(d){a._trigger("receive",
|
158 |
+
d,this._uiHash(this))}}.call(this,this.containers[e]));g.push(function(a){return function(d){a._trigger("update",d,this._uiHash(this))}}.call(this,this.containers[e]))}}for(e=this.containers.length-1;e>=0;e--){f||g.push(function(a){return function(d){a._trigger("deactivate",d,this._uiHash(this))}}.call(this,this.containers[e]));if(this.containers[e].containerCache.over){g.push(function(a){return function(d){a._trigger("out",d,this._uiHash(this))}}.call(this,this.containers[e]));this.containers[e].containerCache.over=
|
159 |
+
0}}this._storedCursor&&b("body").css("cursor",this._storedCursor);this._storedOpacity&&this.helper.css("opacity",this._storedOpacity);if(this._storedZIndex)this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex);this.dragging=false;if(this.cancelHelperRemoval){if(!f){this._trigger("beforeStop",c,this._uiHash());for(e=0;e<g.length;e++)g[e].call(this,c);this._trigger("stop",c,this._uiHash())}return false}f||this._trigger("beforeStop",c,this._uiHash());this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
|
160 |
+
this.helper[0]!=this.currentItem[0]&&this.helper.remove();this.helper=null;if(!f){for(e=0;e<g.length;e++)g[e].call(this,c);this._trigger("stop",c,this._uiHash())}this.fromOutside=false;return true},_trigger:function(){b.Widget.prototype._trigger.apply(this,arguments)===false&&this.cancel()},_uiHash:function(c){var f=c||this;return{helper:f.helper,placeholder:f.placeholder||b([]),position:f.position,originalPosition:f.originalPosition,offset:f.positionAbs,item:f.currentItem,sender:c?c.element:null}}});
|
161 |
+
b.extend(b.ui.sortable,{version:"1.8.6"})})(jQuery);
|
162 |
+
jQuery.effects||function(b,c){function f(l){var k;if(l&&l.constructor==Array&&l.length==3)return l;if(k=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(l))return[parseInt(k[1],10),parseInt(k[2],10),parseInt(k[3],10)];if(k=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(l))return[parseFloat(k[1])*2.55,parseFloat(k[2])*2.55,parseFloat(k[3])*2.55];if(k=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(l))return[parseInt(k[1],16),
|
163 |
+
parseInt(k[2],16),parseInt(k[3],16)];if(k=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(l))return[parseInt(k[1]+k[1],16),parseInt(k[2]+k[2],16),parseInt(k[3]+k[3],16)];if(/rgba\(0, 0, 0, 0\)/.exec(l))return j.transparent;return j[b.trim(l).toLowerCase()]}function g(l,k){var m;do{m=b.curCSS(l,k);if(m!=""&&m!="transparent"||b.nodeName(l,"body"))break;k="backgroundColor"}while(l=l.parentNode);return f(m)}function e(){var l=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,
|
164 |
+
k={},m,o;if(l&&l.length&&l[0]&&l[l[0]])for(var p=l.length;p--;){m=l[p];if(typeof l[m]=="string"){o=m.replace(/\-(\w)/g,function(s,r){return r.toUpperCase()});k[o]=l[m]}}else for(m in l)if(typeof l[m]==="string")k[m]=l[m];return k}function a(l){var k,m;for(k in l){m=l[k];if(m==null||b.isFunction(m)||k in q||/scrollbar/.test(k)||!/color/i.test(k)&&isNaN(parseFloat(m)))delete l[k]}return l}function d(l,k){var m={_:0},o;for(o in k)if(l[o]!=k[o])m[o]=k[o];return m}function h(l,k,m,o){if(typeof l=="object"){o=
|
165 |
+
k;m=null;k=l;l=k.effect}if(b.isFunction(k)){o=k;m=null;k={}}if(typeof k=="number"||b.fx.speeds[k]){o=m;m=k;k={}}if(b.isFunction(m)){o=m;m=null}k=k||{};m=m||k.duration;m=b.fx.off?0:typeof m=="number"?m:b.fx.speeds[m]||b.fx.speeds._default;o=o||k.complete;return[l,k,m,o]}function i(l){if(!l||typeof l==="number"||b.fx.speeds[l])return true;if(typeof l==="string"&&!b.effects[l])return true;return false}b.effects={};b.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor",
|
166 |
+
"borderColor","color","outlineColor"],function(l,k){b.fx.step[k]=function(m){if(!m.colorInit){m.start=g(m.elem,k);m.end=f(m.end);m.colorInit=true}m.elem.style[k]="rgb("+Math.max(Math.min(parseInt(m.pos*(m.end[0]-m.start[0])+m.start[0],10),255),0)+","+Math.max(Math.min(parseInt(m.pos*(m.end[1]-m.start[1])+m.start[1],10),255),0)+","+Math.max(Math.min(parseInt(m.pos*(m.end[2]-m.start[2])+m.start[2],10),255),0)+")"}});var j={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,
|
167 |
+
0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],
|
168 |
+
lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},n=["add","remove","toggle"],q={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};b.effects.animateClass=function(l,k,m,o){if(b.isFunction(m)){o=
|
169 |
+
m;m=null}return this.each(function(){var p=b(this),s=p.attr("style")||" ",r=a(e.call(this)),u,v=p.attr("className");b.each(n,function(w,y){l[y]&&p[y+"Class"](l[y])});u=a(e.call(this));p.attr("className",v);p.animate(d(r,u),k,m,function(){b.each(n,function(w,y){l[y]&&p[y+"Class"](l[y])});if(typeof p.attr("style")=="object"){p.attr("style").cssText="";p.attr("style").cssText=s}else p.attr("style",s);o&&o.apply(this,arguments)})})};b.fn.extend({_addClass:b.fn.addClass,addClass:function(l,k,m,o){return k?
|
170 |
+
b.effects.animateClass.apply(this,[{add:l},k,m,o]):this._addClass(l)},_removeClass:b.fn.removeClass,removeClass:function(l,k,m,o){return k?b.effects.animateClass.apply(this,[{remove:l},k,m,o]):this._removeClass(l)},_toggleClass:b.fn.toggleClass,toggleClass:function(l,k,m,o,p){return typeof k=="boolean"||k===c?m?b.effects.animateClass.apply(this,[k?{add:l}:{remove:l},m,o,p]):this._toggleClass(l,k):b.effects.animateClass.apply(this,[{toggle:l},k,m,o])},switchClass:function(l,k,m,o,p){return b.effects.animateClass.apply(this,
|
171 |
+
[{add:k,remove:l},m,o,p])}});b.extend(b.effects,{version:"1.8.6",save:function(l,k){for(var m=0;m<k.length;m++)k[m]!==null&&l.data("ec.storage."+k[m],l[0].style[k[m]])},restore:function(l,k){for(var m=0;m<k.length;m++)k[m]!==null&&l.css(k[m],l.data("ec.storage."+k[m]))},setMode:function(l,k){if(k=="toggle")k=l.is(":hidden")?"show":"hide";return k},getBaseline:function(l,k){var m;switch(l[0]){case "top":m=0;break;case "middle":m=0.5;break;case "bottom":m=1;break;default:m=l[0]/k.height}switch(l[1]){case "left":l=
|
172 |
+
0;break;case "center":l=0.5;break;case "right":l=1;break;default:l=l[1]/k.width}return{x:l,y:m}},createWrapper:function(l){if(l.parent().is(".ui-effects-wrapper"))return l.parent();var k={width:l.outerWidth(true),height:l.outerHeight(true),"float":l.css("float")},m=b("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0});l.wrap(m);m=l.parent();if(l.css("position")=="static"){m.css({position:"relative"});l.css({position:"relative"})}else{b.extend(k,
|
173 |
+
{position:l.css("position"),zIndex:l.css("z-index")});b.each(["top","left","bottom","right"],function(o,p){k[p]=l.css(p);if(isNaN(parseInt(k[p],10)))k[p]="auto"});l.css({position:"relative",top:0,left:0})}return m.css(k).show()},removeWrapper:function(l){if(l.parent().is(".ui-effects-wrapper"))return l.parent().replaceWith(l);return l},setTransition:function(l,k,m,o){o=o||{};b.each(k,function(p,s){unit=l.cssUnit(s);if(unit[0]>0)o[s]=unit[0]*m+unit[1]});return o}});b.fn.extend({effect:function(l){var k=
|
174 |
+
h.apply(this,arguments),m={options:k[1],duration:k[2],callback:k[3]};k=m.options.mode;var o=b.effects[l];if(b.fx.off||!o)return k?this[k](m.duration,m.callback):this.each(function(){m.callback&&m.callback.call(this)});return o.call(this,m)},_show:b.fn.show,show:function(l){if(i(l))return this._show.apply(this,arguments);else{var k=h.apply(this,arguments);k[1].mode="show";return this.effect.apply(this,k)}},_hide:b.fn.hide,hide:function(l){if(i(l))return this._hide.apply(this,arguments);else{var k=
|
175 |
+
h.apply(this,arguments);k[1].mode="hide";return this.effect.apply(this,k)}},__toggle:b.fn.toggle,toggle:function(l){if(i(l)||typeof l==="boolean"||b.isFunction(l))return this.__toggle.apply(this,arguments);else{var k=h.apply(this,arguments);k[1].mode="toggle";return this.effect.apply(this,k)}},cssUnit:function(l){var k=this.css(l),m=[];b.each(["em","px","%","pt"],function(o,p){if(k.indexOf(p)>0)m=[parseFloat(k),p]});return m}});b.easing.jswing=b.easing.swing;b.extend(b.easing,{def:"easeOutQuad",swing:function(l,
|
176 |
+
k,m,o,p){return b.easing[b.easing.def](l,k,m,o,p)},easeInQuad:function(l,k,m,o,p){return o*(k/=p)*k+m},easeOutQuad:function(l,k,m,o,p){return-o*(k/=p)*(k-2)+m},easeInOutQuad:function(l,k,m,o,p){if((k/=p/2)<1)return o/2*k*k+m;return-o/2*(--k*(k-2)-1)+m},easeInCubic:function(l,k,m,o,p){return o*(k/=p)*k*k+m},easeOutCubic:function(l,k,m,o,p){return o*((k=k/p-1)*k*k+1)+m},easeInOutCubic:function(l,k,m,o,p){if((k/=p/2)<1)return o/2*k*k*k+m;return o/2*((k-=2)*k*k+2)+m},easeInQuart:function(l,k,m,o,p){return o*
|
177 |
+
(k/=p)*k*k*k+m},easeOutQuart:function(l,k,m,o,p){return-o*((k=k/p-1)*k*k*k-1)+m},easeInOutQuart:function(l,k,m,o,p){if((k/=p/2)<1)return o/2*k*k*k*k+m;return-o/2*((k-=2)*k*k*k-2)+m},easeInQuint:function(l,k,m,o,p){return o*(k/=p)*k*k*k*k+m},easeOutQuint:function(l,k,m,o,p){return o*((k=k/p-1)*k*k*k*k+1)+m},easeInOutQuint:function(l,k,m,o,p){if((k/=p/2)<1)return o/2*k*k*k*k*k+m;return o/2*((k-=2)*k*k*k*k+2)+m},easeInSine:function(l,k,m,o,p){return-o*Math.cos(k/p*(Math.PI/2))+o+m},easeOutSine:function(l,
|
178 |
+
k,m,o,p){return o*Math.sin(k/p*(Math.PI/2))+m},easeInOutSine:function(l,k,m,o,p){return-o/2*(Math.cos(Math.PI*k/p)-1)+m},easeInExpo:function(l,k,m,o,p){return k==0?m:o*Math.pow(2,10*(k/p-1))+m},easeOutExpo:function(l,k,m,o,p){return k==p?m+o:o*(-Math.pow(2,-10*k/p)+1)+m},easeInOutExpo:function(l,k,m,o,p){if(k==0)return m;if(k==p)return m+o;if((k/=p/2)<1)return o/2*Math.pow(2,10*(k-1))+m;return o/2*(-Math.pow(2,-10*--k)+2)+m},easeInCirc:function(l,k,m,o,p){return-o*(Math.sqrt(1-(k/=p)*k)-1)+m},easeOutCirc:function(l,
|
179 |
+
k,m,o,p){return o*Math.sqrt(1-(k=k/p-1)*k)+m},easeInOutCirc:function(l,k,m,o,p){if((k/=p/2)<1)return-o/2*(Math.sqrt(1-k*k)-1)+m;return o/2*(Math.sqrt(1-(k-=2)*k)+1)+m},easeInElastic:function(l,k,m,o,p){l=1.70158;var s=0,r=o;if(k==0)return m;if((k/=p)==1)return m+o;s||(s=p*0.3);if(r<Math.abs(o)){r=o;l=s/4}else l=s/(2*Math.PI)*Math.asin(o/r);return-(r*Math.pow(2,10*(k-=1))*Math.sin((k*p-l)*2*Math.PI/s))+m},easeOutElastic:function(l,k,m,o,p){l=1.70158;var s=0,r=o;if(k==0)return m;if((k/=p)==1)return m+
|
180 |
+
o;s||(s=p*0.3);if(r<Math.abs(o)){r=o;l=s/4}else l=s/(2*Math.PI)*Math.asin(o/r);return r*Math.pow(2,-10*k)*Math.sin((k*p-l)*2*Math.PI/s)+o+m},easeInOutElastic:function(l,k,m,o,p){l=1.70158;var s=0,r=o;if(k==0)return m;if((k/=p/2)==2)return m+o;s||(s=p*0.3*1.5);if(r<Math.abs(o)){r=o;l=s/4}else l=s/(2*Math.PI)*Math.asin(o/r);if(k<1)return-0.5*r*Math.pow(2,10*(k-=1))*Math.sin((k*p-l)*2*Math.PI/s)+m;return r*Math.pow(2,-10*(k-=1))*Math.sin((k*p-l)*2*Math.PI/s)*0.5+o+m},easeInBack:function(l,k,m,o,p,s){if(s==
|
181 |
+
c)s=1.70158;return o*(k/=p)*k*((s+1)*k-s)+m},easeOutBack:function(l,k,m,o,p,s){if(s==c)s=1.70158;return o*((k=k/p-1)*k*((s+1)*k+s)+1)+m},easeInOutBack:function(l,k,m,o,p,s){if(s==c)s=1.70158;if((k/=p/2)<1)return o/2*k*k*(((s*=1.525)+1)*k-s)+m;return o/2*((k-=2)*k*(((s*=1.525)+1)*k+s)+2)+m},easeInBounce:function(l,k,m,o,p){return o-b.easing.easeOutBounce(l,p-k,0,o,p)+m},easeOutBounce:function(l,k,m,o,p){return(k/=p)<1/2.75?o*7.5625*k*k+m:k<2/2.75?o*(7.5625*(k-=1.5/2.75)*k+0.75)+m:k<2.5/2.75?o*(7.5625*
|
182 |
+
(k-=2.25/2.75)*k+0.9375)+m:o*(7.5625*(k-=2.625/2.75)*k+0.984375)+m},easeInOutBounce:function(l,k,m,o,p){if(k<p/2)return b.easing.easeInBounce(l,k*2,0,o,p)*0.5+m;return b.easing.easeOutBounce(l,k*2-p,0,o,p)*0.5+o*0.5+m}})}(jQuery);
|
183 |
+
(function(b){b.effects.blind=function(c){return this.queue(function(){var f=b(this),g=["position","top","left"],e=b.effects.setMode(f,c.options.mode||"hide"),a=c.options.direction||"vertical";b.effects.save(f,g);f.show();var d=b.effects.createWrapper(f).css({overflow:"hidden"}),h=a=="vertical"?"height":"width";a=a=="vertical"?d.height():d.width();e=="show"&&d.css(h,0);var i={};i[h]=e=="show"?a:0;d.animate(i,c.duration,c.options.easing,function(){e=="hide"&&f.hide();b.effects.restore(f,g);b.effects.removeWrapper(f);
|
184 |
+
c.callback&&c.callback.apply(f[0],arguments);f.dequeue()})})}})(jQuery);
|
185 |
+
(function(b){b.effects.bounce=function(c){return this.queue(function(){var f=b(this),g=["position","top","left"],e=b.effects.setMode(f,c.options.mode||"effect"),a=c.options.direction||"up",d=c.options.distance||20,h=c.options.times||5,i=c.duration||250;/show|hide/.test(e)&&g.push("opacity");b.effects.save(f,g);f.show();b.effects.createWrapper(f);var j=a=="up"||a=="down"?"top":"left";a=a=="up"||a=="left"?"pos":"neg";d=c.options.distance||(j=="top"?f.outerHeight({margin:true})/3:f.outerWidth({margin:true})/
|
186 |
+
3);if(e=="show")f.css("opacity",0).css(j,a=="pos"?-d:d);if(e=="hide")d/=h*2;e!="hide"&&h--;if(e=="show"){var n={opacity:1};n[j]=(a=="pos"?"+=":"-=")+d;f.animate(n,i/2,c.options.easing);d/=2;h--}for(n=0;n<h;n++){var q={},l={};q[j]=(a=="pos"?"-=":"+=")+d;l[j]=(a=="pos"?"+=":"-=")+d;f.animate(q,i/2,c.options.easing).animate(l,i/2,c.options.easing);d=e=="hide"?d*2:d/2}if(e=="hide"){n={opacity:0};n[j]=(a=="pos"?"-=":"+=")+d;f.animate(n,i/2,c.options.easing,function(){f.hide();b.effects.restore(f,g);b.effects.removeWrapper(f);
|
187 |
+
c.callback&&c.callback.apply(this,arguments)})}else{q={};l={};q[j]=(a=="pos"?"-=":"+=")+d;l[j]=(a=="pos"?"+=":"-=")+d;f.animate(q,i/2,c.options.easing).animate(l,i/2,c.options.easing,function(){b.effects.restore(f,g);b.effects.removeWrapper(f);c.callback&&c.callback.apply(this,arguments)})}f.queue("fx",function(){f.dequeue()});f.dequeue()})}})(jQuery);
|
188 |
+
(function(b){b.effects.clip=function(c){return this.queue(function(){var f=b(this),g=["position","top","left","height","width"],e=b.effects.setMode(f,c.options.mode||"hide"),a=c.options.direction||"vertical";b.effects.save(f,g);f.show();var d=b.effects.createWrapper(f).css({overflow:"hidden"});d=f[0].tagName=="IMG"?d:f;var h={size:a=="vertical"?"height":"width",position:a=="vertical"?"top":"left"};a=a=="vertical"?d.height():d.width();if(e=="show"){d.css(h.size,0);d.css(h.position,a/2)}var i={};i[h.size]=
|
189 |
+
e=="show"?a:0;i[h.position]=e=="show"?0:a/2;d.animate(i,{queue:false,duration:c.duration,easing:c.options.easing,complete:function(){e=="hide"&&f.hide();b.effects.restore(f,g);b.effects.removeWrapper(f);c.callback&&c.callback.apply(f[0],arguments);f.dequeue()}})})}})(jQuery);
|
190 |
+
(function(b){b.effects.drop=function(c){return this.queue(function(){var f=b(this),g=["position","top","left","opacity"],e=b.effects.setMode(f,c.options.mode||"hide"),a=c.options.direction||"left";b.effects.save(f,g);f.show();b.effects.createWrapper(f);var d=a=="up"||a=="down"?"top":"left";a=a=="up"||a=="left"?"pos":"neg";var h=c.options.distance||(d=="top"?f.outerHeight({margin:true})/2:f.outerWidth({margin:true})/2);if(e=="show")f.css("opacity",0).css(d,a=="pos"?-h:h);var i={opacity:e=="show"?1:
|
191 |
+
0};i[d]=(e=="show"?a=="pos"?"+=":"-=":a=="pos"?"-=":"+=")+h;f.animate(i,{queue:false,duration:c.duration,easing:c.options.easing,complete:function(){e=="hide"&&f.hide();b.effects.restore(f,g);b.effects.removeWrapper(f);c.callback&&c.callback.apply(this,arguments);f.dequeue()}})})}})(jQuery);
|
192 |
+
(function(b){b.effects.explode=function(c){return this.queue(function(){var f=c.options.pieces?Math.round(Math.sqrt(c.options.pieces)):3,g=c.options.pieces?Math.round(Math.sqrt(c.options.pieces)):3;c.options.mode=c.options.mode=="toggle"?b(this).is(":visible")?"hide":"show":c.options.mode;var e=b(this).show().css("visibility","hidden"),a=e.offset();a.top-=parseInt(e.css("marginTop"),10)||0;a.left-=parseInt(e.css("marginLeft"),10)||0;for(var d=e.outerWidth(true),h=e.outerHeight(true),i=0;i<f;i++)for(var j=
|
193 |
+
0;j<g;j++)e.clone().appendTo("body").wrap("<div></div>").css({position:"absolute",visibility:"visible",left:-j*(d/g),top:-i*(h/f)}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:d/g,height:h/f,left:a.left+j*(d/g)+(c.options.mode=="show"?(j-Math.floor(g/2))*(d/g):0),top:a.top+i*(h/f)+(c.options.mode=="show"?(i-Math.floor(f/2))*(h/f):0),opacity:c.options.mode=="show"?0:1}).animate({left:a.left+j*(d/g)+(c.options.mode=="show"?0:(j-Math.floor(g/2))*(d/g)),top:a.top+
|
194 |
+
i*(h/f)+(c.options.mode=="show"?0:(i-Math.floor(f/2))*(h/f)),opacity:c.options.mode=="show"?1:0},c.duration||500);setTimeout(function(){c.options.mode=="show"?e.css({visibility:"visible"}):e.css({visibility:"visible"}).hide();c.callback&&c.callback.apply(e[0]);e.dequeue();b("div.ui-effects-explode").remove()},c.duration||500)})}})(jQuery);
|
195 |
+
(function(b){b.effects.fade=function(c){return this.queue(function(){var f=b(this),g=b.effects.setMode(f,c.options.mode||"hide");f.animate({opacity:g},{queue:false,duration:c.duration,easing:c.options.easing,complete:function(){c.callback&&c.callback.apply(this,arguments);f.dequeue()}})})}})(jQuery);
|
196 |
+
(function(b){b.effects.fold=function(c){return this.queue(function(){var f=b(this),g=["position","top","left"],e=b.effects.setMode(f,c.options.mode||"hide"),a=c.options.size||15,d=!!c.options.horizFirst,h=c.duration?c.duration/2:b.fx.speeds._default/2;b.effects.save(f,g);f.show();var i=b.effects.createWrapper(f).css({overflow:"hidden"}),j=e=="show"!=d,n=j?["width","height"]:["height","width"];j=j?[i.width(),i.height()]:[i.height(),i.width()];var q=/([0-9]+)%/.exec(a);if(q)a=parseInt(q[1],10)/100*
|
197 |
+
j[e=="hide"?0:1];if(e=="show")i.css(d?{height:0,width:a}:{height:a,width:0});d={};q={};d[n[0]]=e=="show"?j[0]:a;q[n[1]]=e=="show"?j[1]:0;i.animate(d,h,c.options.easing).animate(q,h,c.options.easing,function(){e=="hide"&&f.hide();b.effects.restore(f,g);b.effects.removeWrapper(f);c.callback&&c.callback.apply(f[0],arguments);f.dequeue()})})}})(jQuery);
|
198 |
+
(function(b){b.effects.highlight=function(c){return this.queue(function(){var f=b(this),g=["backgroundImage","backgroundColor","opacity"],e=b.effects.setMode(f,c.options.mode||"show"),a={backgroundColor:f.css("backgroundColor")};if(e=="hide")a.opacity=0;b.effects.save(f,g);f.show().css({backgroundImage:"none",backgroundColor:c.options.color||"#ffff99"}).animate(a,{queue:false,duration:c.duration,easing:c.options.easing,complete:function(){e=="hide"&&f.hide();b.effects.restore(f,g);e=="show"&&!b.support.opacity&&
|
199 |
+
this.style.removeAttribute("filter");c.callback&&c.callback.apply(this,arguments);f.dequeue()}})})}})(jQuery);
|
200 |
+
(function(b){b.effects.pulsate=function(c){return this.queue(function(){var f=b(this),g=b.effects.setMode(f,c.options.mode||"show");times=(c.options.times||5)*2-1;duration=c.duration?c.duration/2:b.fx.speeds._default/2;isVisible=f.is(":visible");animateTo=0;if(!isVisible){f.css("opacity",0).show();animateTo=1}if(g=="hide"&&isVisible||g=="show"&&!isVisible)times--;for(g=0;g<times;g++){f.animate({opacity:animateTo},duration,c.options.easing);animateTo=(animateTo+1)%2}f.animate({opacity:animateTo},duration,
|
201 |
+
c.options.easing,function(){animateTo==0&&f.hide();c.callback&&c.callback.apply(this,arguments)});f.queue("fx",function(){f.dequeue()}).dequeue()})}})(jQuery);
|
202 |
+
(function(b){b.effects.puff=function(c){return this.queue(function(){var f=b(this),g=b.effects.setMode(f,c.options.mode||"hide"),e=parseInt(c.options.percent,10)||150,a=e/100,d={height:f.height(),width:f.width()};b.extend(c.options,{fade:true,mode:g,percent:g=="hide"?e:100,from:g=="hide"?d:{height:d.height*a,width:d.width*a}});f.effect("scale",c.options,c.duration,c.callback);f.dequeue()})};b.effects.scale=function(c){return this.queue(function(){var f=b(this),g=b.extend(true,{},c.options),e=b.effects.setMode(f,
|
203 |
+
c.options.mode||"effect"),a=parseInt(c.options.percent,10)||(parseInt(c.options.percent,10)==0?0:e=="hide"?0:100),d=c.options.direction||"both",h=c.options.origin;if(e!="effect"){g.origin=h||["middle","center"];g.restore=true}h={height:f.height(),width:f.width()};f.from=c.options.from||(e=="show"?{height:0,width:0}:h);a={y:d!="horizontal"?a/100:1,x:d!="vertical"?a/100:1};f.to={height:h.height*a.y,width:h.width*a.x};if(c.options.fade){if(e=="show"){f.from.opacity=0;f.to.opacity=1}if(e=="hide"){f.from.opacity=
|
204 |
+
1;f.to.opacity=0}}g.from=f.from;g.to=f.to;g.mode=e;f.effect("size",g,c.duration,c.callback);f.dequeue()})};b.effects.size=function(c){return this.queue(function(){var f=b(this),g=["position","top","left","width","height","overflow","opacity"],e=["position","top","left","overflow","opacity"],a=["width","height","overflow"],d=["fontSize"],h=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],i=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],j=b.effects.setMode(f,
|
205 |
+
c.options.mode||"effect"),n=c.options.restore||false,q=c.options.scale||"both",l=c.options.origin,k={height:f.height(),width:f.width()};f.from=c.options.from||k;f.to=c.options.to||k;if(l){l=b.effects.getBaseline(l,k);f.from.top=(k.height-f.from.height)*l.y;f.from.left=(k.width-f.from.width)*l.x;f.to.top=(k.height-f.to.height)*l.y;f.to.left=(k.width-f.to.width)*l.x}var m={from:{y:f.from.height/k.height,x:f.from.width/k.width},to:{y:f.to.height/k.height,x:f.to.width/k.width}};if(q=="box"||q=="both"){if(m.from.y!=
|
206 |
+
m.to.y){g=g.concat(h);f.from=b.effects.setTransition(f,h,m.from.y,f.from);f.to=b.effects.setTransition(f,h,m.to.y,f.to)}if(m.from.x!=m.to.x){g=g.concat(i);f.from=b.effects.setTransition(f,i,m.from.x,f.from);f.to=b.effects.setTransition(f,i,m.to.x,f.to)}}if(q=="content"||q=="both")if(m.from.y!=m.to.y){g=g.concat(d);f.from=b.effects.setTransition(f,d,m.from.y,f.from);f.to=b.effects.setTransition(f,d,m.to.y,f.to)}b.effects.save(f,n?g:e);f.show();b.effects.createWrapper(f);f.css("overflow","hidden").css(f.from);
|
207 |
+
if(q=="content"||q=="both"){h=h.concat(["marginTop","marginBottom"]).concat(d);i=i.concat(["marginLeft","marginRight"]);a=g.concat(h).concat(i);f.find("*[width]").each(function(){child=b(this);n&&b.effects.save(child,a);var o={height:child.height(),width:child.width()};child.from={height:o.height*m.from.y,width:o.width*m.from.x};child.to={height:o.height*m.to.y,width:o.width*m.to.x};if(m.from.y!=m.to.y){child.from=b.effects.setTransition(child,h,m.from.y,child.from);child.to=b.effects.setTransition(child,
|
208 |
+
h,m.to.y,child.to)}if(m.from.x!=m.to.x){child.from=b.effects.setTransition(child,i,m.from.x,child.from);child.to=b.effects.setTransition(child,i,m.to.x,child.to)}child.css(child.from);child.animate(child.to,c.duration,c.options.easing,function(){n&&b.effects.restore(child,a)})})}f.animate(f.to,{queue:false,duration:c.duration,easing:c.options.easing,complete:function(){f.to.opacity===0&&f.css("opacity",f.from.opacity);j=="hide"&&f.hide();b.effects.restore(f,n?g:e);b.effects.removeWrapper(f);c.callback&&
|
209 |
+
c.callback.apply(this,arguments);f.dequeue()}})})}})(jQuery);
|
210 |
+
(function(b){b.effects.shake=function(c){return this.queue(function(){var f=b(this),g=["position","top","left"];b.effects.setMode(f,c.options.mode||"effect");var e=c.options.direction||"left",a=c.options.distance||20,d=c.options.times||3,h=c.duration||c.options.duration||140;b.effects.save(f,g);f.show();b.effects.createWrapper(f);var i=e=="up"||e=="down"?"top":"left",j=e=="up"||e=="left"?"pos":"neg";e={};var n={},q={};e[i]=(j=="pos"?"-=":"+=")+a;n[i]=(j=="pos"?"+=":"-=")+a*2;q[i]=(j=="pos"?"-=":"+=")+
|
211 |
+
a*2;f.animate(e,h,c.options.easing);for(a=1;a<d;a++)f.animate(n,h,c.options.easing).animate(q,h,c.options.easing);f.animate(n,h,c.options.easing).animate(e,h/2,c.options.easing,function(){b.effects.restore(f,g);b.effects.removeWrapper(f);c.callback&&c.callback.apply(this,arguments)});f.queue("fx",function(){f.dequeue()});f.dequeue()})}})(jQuery);
|
212 |
+
(function(b){b.effects.slide=function(c){return this.queue(function(){var f=b(this),g=["position","top","left"],e=b.effects.setMode(f,c.options.mode||"show"),a=c.options.direction||"left";b.effects.save(f,g);f.show();b.effects.createWrapper(f).css({overflow:"hidden"});var d=a=="up"||a=="down"?"top":"left";a=a=="up"||a=="left"?"pos":"neg";var h=c.options.distance||(d=="top"?f.outerHeight({margin:true}):f.outerWidth({margin:true}));if(e=="show")f.css(d,a=="pos"?-h:h);var i={};i[d]=(e=="show"?a=="pos"?
|
213 |
+
"+=":"-=":a=="pos"?"-=":"+=")+h;f.animate(i,{queue:false,duration:c.duration,easing:c.options.easing,complete:function(){e=="hide"&&f.hide();b.effects.restore(f,g);b.effects.removeWrapper(f);c.callback&&c.callback.apply(this,arguments);f.dequeue()}})})}})(jQuery);
|
214 |
+
(function(b){b.effects.transfer=function(c){return this.queue(function(){var f=b(this),g=b(c.options.to),e=g.offset();g={top:e.top,left:e.left,height:g.innerHeight(),width:g.innerWidth()};e=f.offset();var a=b('<div class="ui-effects-transfer"></div>').appendTo(document.body).addClass(c.options.className).css({top:e.top,left:e.left,height:f.innerHeight(),width:f.innerWidth(),position:"absolute"}).animate(g,c.duration,c.options.easing,function(){a.remove();c.callback&&c.callback.apply(f[0],arguments);
|
215 |
+
f.dequeue()})})}})(jQuery);
|
216 |
+
(function(b){b.widget("ui.accordion",{options:{active:0,animated:"slide",autoHeight:true,clearStyle:false,collapsible:false,event:"click",fillSpace:false,header:"> li > :first-child,> :not(li):even",icons:{header:"ui-icon-triangle-1-e",headerSelected:"ui-icon-triangle-1-s"},navigation:false,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}},_create:function(){var c=this,f=c.options;c.running=0;c.element.addClass("ui-accordion ui-widget ui-helper-reset").children("li").addClass("ui-accordion-li-fix");c.headers=
|
217 |
+
c.element.find(f.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all").bind("mouseenter.accordion",function(){f.disabled||b(this).addClass("ui-state-hover")}).bind("mouseleave.accordion",function(){f.disabled||b(this).removeClass("ui-state-hover")}).bind("focus.accordion",function(){f.disabled||b(this).addClass("ui-state-focus")}).bind("blur.accordion",function(){f.disabled||b(this).removeClass("ui-state-focus")});c.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom");
|
218 |
+
if(f.navigation){var g=c.element.find("a").filter(f.navigationFilter).eq(0);if(g.length){var e=g.closest(".ui-accordion-header");c.active=e.length?e:g.closest(".ui-accordion-content").prev()}}c.active=c._findActive(c.active||f.active).addClass("ui-state-default ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top");c.active.next().addClass("ui-accordion-content-active");c._createIcons();c.resize();c.element.attr("role","tablist");c.headers.attr("role","tab").bind("keydown.accordion",
|
219 |
+
function(a){return c._keydown(a)}).next().attr("role","tabpanel");c.headers.not(c.active||"").attr({"aria-expanded":"false",tabIndex:-1}).next().hide();c.active.length?c.active.attr({"aria-expanded":"true",tabIndex:0}):c.headers.eq(0).attr("tabIndex",0);b.browser.safari||c.headers.find("a").attr("tabIndex",-1);f.event&&c.headers.bind(f.event.split(" ").join(".accordion ")+".accordion",function(a){c._clickHandler.call(c,a,this);a.preventDefault()})},_createIcons:function(){var c=this.options;if(c.icons){b("<span></span>").addClass("ui-icon "+
|
220 |
+
c.icons.header).prependTo(this.headers);this.active.children(".ui-icon").toggleClass(c.icons.header).toggleClass(c.icons.headerSelected);this.element.addClass("ui-accordion-icons")}},_destroyIcons:function(){this.headers.children(".ui-icon").remove();this.element.removeClass("ui-accordion-icons")},destroy:function(){var c=this.options;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role");this.headers.unbind(".accordion").removeClass("ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("tabIndex");
|
221 |
+
this.headers.find("a").removeAttr("tabIndex");this._destroyIcons();var f=this.headers.next().css("display","").removeAttr("role").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled");if(c.autoHeight||c.fillHeight)f.css("height","");return b.Widget.prototype.destroy.call(this)},_setOption:function(c,f){b.Widget.prototype._setOption.apply(this,arguments);c=="active"&&this.activate(f);if(c=="icons"){this._destroyIcons();
|
222 |
+
f&&this._createIcons()}if(c=="disabled")this.headers.add(this.headers.next())[f?"addClass":"removeClass"]("ui-accordion-disabled ui-state-disabled")},_keydown:function(c){if(!(this.options.disabled||c.altKey||c.ctrlKey)){var f=b.ui.keyCode,g=this.headers.length,e=this.headers.index(c.target),a=false;switch(c.keyCode){case f.RIGHT:case f.DOWN:a=this.headers[(e+1)%g];break;case f.LEFT:case f.UP:a=this.headers[(e-1+g)%g];break;case f.SPACE:case f.ENTER:this._clickHandler({target:c.target},c.target);
|
223 |
+
c.preventDefault()}if(a){b(c.target).attr("tabIndex",-1);b(a).attr("tabIndex",0);a.focus();return false}return true}},resize:function(){var c=this.options,f;if(c.fillSpace){if(b.browser.msie){var g=this.element.parent().css("overflow");this.element.parent().css("overflow","hidden")}f=this.element.parent().height();b.browser.msie&&this.element.parent().css("overflow",g);this.headers.each(function(){f-=b(this).outerHeight(true)});this.headers.next().each(function(){b(this).height(Math.max(0,f-b(this).innerHeight()+
|
224 |
+
b(this).height()))}).css("overflow","auto")}else if(c.autoHeight){f=0;this.headers.next().each(function(){f=Math.max(f,b(this).height("").height())}).height(f)}return this},activate:function(c){this.options.active=c;c=this._findActive(c)[0];this._clickHandler({target:c},c);return this},_findActive:function(c){return c?typeof c==="number"?this.headers.filter(":eq("+c+")"):this.headers.not(this.headers.not(c)):c===false?b([]):this.headers.filter(":eq(0)")},_clickHandler:function(c,f){var g=this.options;
|
225 |
+
if(!g.disabled)if(c.target){c=b(c.currentTarget||f);f=c[0]===this.active[0];g.active=g.collapsible&&f?false:this.headers.index(c);if(!(this.running||!g.collapsible&&f)){this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(g.icons.headerSelected).addClass(g.icons.header);if(!f){c.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top").children(".ui-icon").removeClass(g.icons.header).addClass(g.icons.headerSelected);
|
226 |
+
c.next().addClass("ui-accordion-content-active")}d=c.next();e=this.active.next();a={options:g,newHeader:f&&g.collapsible?b([]):c,oldHeader:this.active,newContent:f&&g.collapsible?b([]):d,oldContent:e};g=this.headers.index(this.active[0])>this.headers.index(c[0]);this.active=f?b([]):c;this._toggle(d,e,a,f,g)}}else if(g.collapsible){this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(g.icons.headerSelected).addClass(g.icons.header);
|
227 |
+
this.active.next().addClass("ui-accordion-content-active");var e=this.active.next(),a={options:g,newHeader:b([]),oldHeader:g.active,newContent:b([]),oldContent:e},d=this.active=b([]);this._toggle(d,e,a)}},_toggle:function(c,f,g,e,a){var d=this,h=d.options;d.toShow=c;d.toHide=f;d.data=g;var i=function(){if(d)return d._completed.apply(d,arguments)};d._trigger("changestart",null,d.data);d.running=f.size()===0?c.size():f.size();if(h.animated){g={};g=h.collapsible&&e?{toShow:b([]),toHide:f,complete:i,
|
228 |
+
down:a,autoHeight:h.autoHeight||h.fillSpace}:{toShow:c,toHide:f,complete:i,down:a,autoHeight:h.autoHeight||h.fillSpace};if(!h.proxied)h.proxied=h.animated;if(!h.proxiedDuration)h.proxiedDuration=h.duration;h.animated=b.isFunction(h.proxied)?h.proxied(g):h.proxied;h.duration=b.isFunction(h.proxiedDuration)?h.proxiedDuration(g):h.proxiedDuration;e=b.ui.accordion.animations;var j=h.duration,n=h.animated;if(n&&!e[n]&&!b.easing[n])n="slide";e[n]||(e[n]=function(q){this.slide(q,{easing:n,duration:j||700})});
|
229 |
+
e[n](g)}else{if(h.collapsible&&e)c.toggle();else{f.hide();c.show()}i(true)}f.prev().attr({"aria-expanded":"false",tabIndex:-1}).blur();c.prev().attr({"aria-expanded":"true",tabIndex:0}).focus()},_completed:function(c){this.running=c?0:--this.running;if(!this.running){this.options.clearStyle&&this.toShow.add(this.toHide).css({height:"",overflow:""});this.toHide.removeClass("ui-accordion-content-active");this._trigger("change",null,this.data)}}});b.extend(b.ui.accordion,{version:"1.8.6",animations:{slide:function(c,
|
230 |
+
f){c=b.extend({easing:"swing",duration:300},c,f);if(c.toHide.size())if(c.toShow.size()){var g=c.toShow.css("overflow"),e=0,a={},d={},h;f=c.toShow;h=f[0].style.width;f.width(parseInt(f.parent().width(),10)-parseInt(f.css("paddingLeft"),10)-parseInt(f.css("paddingRight"),10)-(parseInt(f.css("borderLeftWidth"),10)||0)-(parseInt(f.css("borderRightWidth"),10)||0));b.each(["height","paddingTop","paddingBottom"],function(i,j){d[j]="hide";i=(""+b.css(c.toShow[0],j)).match(/^([\d+-.]+)(.*)$/);a[j]={value:i[1],
|
231 |
+
unit:i[2]||"px"}});c.toShow.css({height:0,overflow:"hidden"}).show();c.toHide.filter(":hidden").each(c.complete).end().filter(":visible").animate(d,{step:function(i,j){if(j.prop=="height")e=j.end-j.start===0?0:(j.now-j.start)/(j.end-j.start);c.toShow[0].style[j.prop]=e*a[j.prop].value+a[j.prop].unit},duration:c.duration,easing:c.easing,complete:function(){c.autoHeight||c.toShow.css("height","");c.toShow.css({width:h,overflow:g});c.complete()}})}else c.toHide.animate({height:"hide",paddingTop:"hide",
|
232 |
+
paddingBottom:"hide"},c);else c.toShow.animate({height:"show",paddingTop:"show",paddingBottom:"show"},c)},bounceslide:function(c){this.slide(c,{easing:c.down?"easeOutBounce":"swing",duration:c.down?1E3:200})}}})})(jQuery);
|
233 |
+
(function(b){b.widget("ui.autocomplete",{options:{appendTo:"body",delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},_create:function(){var c=this,f=this.element[0].ownerDocument,g;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(e){if(!(c.options.disabled||c.element.attr("readonly"))){g=false;var a=b.ui.keyCode;switch(e.keyCode){case a.PAGE_UP:c._move("previousPage",
|
234 |
+
e);break;case a.PAGE_DOWN:c._move("nextPage",e);break;case a.UP:c._move("previous",e);e.preventDefault();break;case a.DOWN:c._move("next",e);e.preventDefault();break;case a.ENTER:case a.NUMPAD_ENTER:if(c.menu.active){g=true;e.preventDefault()}case a.TAB:if(!c.menu.active)return;c.menu.select(e);break;case a.ESCAPE:c.element.val(c.term);c.close(e);break;default:clearTimeout(c.searching);c.searching=setTimeout(function(){if(c.term!=c.element.val()){c.selectedItem=null;c.search(null,e)}},c.options.delay);
|
235 |
+
break}}}).bind("keypress.autocomplete",function(e){if(g){g=false;e.preventDefault()}}).bind("focus.autocomplete",function(){if(!c.options.disabled){c.selectedItem=null;c.previous=c.element.val()}}).bind("blur.autocomplete",function(e){if(!c.options.disabled){clearTimeout(c.searching);c.closing=setTimeout(function(){c.close(e);c._change(e)},150)}});this._initSource();this.response=function(){return c._response.apply(c,arguments)};this.menu=b("<ul></ul>").addClass("ui-autocomplete").appendTo(b(this.options.appendTo||
|
236 |
+
"body",f)[0]).mousedown(function(e){var a=c.menu.element[0];b(e.target).closest(".ui-menu-item").length||setTimeout(function(){b(document).one("mousedown",function(d){d.target!==c.element[0]&&d.target!==a&&!b.ui.contains(a,d.target)&&c.close()})},1);setTimeout(function(){clearTimeout(c.closing)},13)}).menu({focus:function(e,a){a=a.item.data("item.autocomplete");false!==c._trigger("focus",e,{item:a})&&/^key/.test(e.originalEvent.type)&&c.element.val(a.value)},selected:function(e,a){a=a.item.data("item.autocomplete");
|
237 |
+
var d=c.previous;if(c.element[0]!==f.activeElement){c.element.focus();c.previous=d;setTimeout(function(){c.previous=d},1)}false!==c._trigger("select",e,{item:a})&&c.element.val(a.value);c.term=c.element.val();c.close(e);c.selectedItem=a},blur:function(){c.menu.element.is(":visible")&&c.element.val()!==c.term&&c.element.val(c.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");b.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");
|
238 |
+
this.menu.element.remove();b.Widget.prototype.destroy.call(this)},_setOption:function(c,f){b.Widget.prototype._setOption.apply(this,arguments);c==="source"&&this._initSource();if(c==="appendTo")this.menu.element.appendTo(b(f||"body",this.element[0].ownerDocument)[0])},_initSource:function(){var c=this,f,g;if(b.isArray(this.options.source)){f=this.options.source;this.source=function(e,a){a(b.ui.autocomplete.filter(f,e.term))}}else if(typeof this.options.source==="string"){g=this.options.source;this.source=
|
239 |
+
function(e,a){c.xhr&&c.xhr.abort();c.xhr=b.getJSON(g,e,function(d,h,i){i===c.xhr&&a(d);c.xhr=null})}}else this.source=this.options.source},search:function(c,f){c=c!=null?c:this.element.val();this.term=this.element.val();if(c.length<this.options.minLength)return this.close(f);clearTimeout(this.closing);if(this._trigger("search",f)!==false)return this._search(c)},_search:function(c){this.element.addClass("ui-autocomplete-loading");this.source({term:c},this.response)},_response:function(c){if(c&&c.length){c=
|
240 |
+
this._normalize(c);this._suggest(c);this._trigger("open")}else this.close();this.element.removeClass("ui-autocomplete-loading")},close:function(c){clearTimeout(this.closing);if(this.menu.element.is(":visible")){this._trigger("close",c);this.menu.element.hide();this.menu.deactivate()}},_change:function(c){this.previous!==this.element.val()&&this._trigger("change",c,{item:this.selectedItem})},_normalize:function(c){if(c.length&&c[0].label&&c[0].value)return c;return b.map(c,function(f){if(typeof f===
|
241 |
+
"string")return{label:f,value:f};return b.extend({label:f.label||f.value,value:f.value||f.label},f)})},_suggest:function(c){this._renderMenu(this.menu.element.empty().zIndex(this.element.zIndex()+1),c);this.menu.deactivate();this.menu.refresh();this.menu.element.show().position(b.extend({of:this.element},this.options.position));this._resizeMenu()},_resizeMenu:function(){var c=this.menu.element;c.outerWidth(Math.max(c.width("").outerWidth(),this.element.outerWidth()))},_renderMenu:function(c,f){var g=
|
242 |
+
this;b.each(f,function(e,a){g._renderItem(c,a)})},_renderItem:function(c,f){return b("<li></li>").data("item.autocomplete",f).append(b("<a></a>").text(f.label)).appendTo(c)},_move:function(c,f){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(c)||this.menu.last()&&/^next/.test(c)){this.element.val(this.term);this.menu.deactivate()}else this.menu[c](f);else this.search(null,f)},widget:function(){return this.menu.element}});b.extend(b.ui.autocomplete,{escapeRegex:function(c){return c.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,
|
243 |
+
"\\$&")},filter:function(c,f){var g=new RegExp(b.ui.autocomplete.escapeRegex(f),"i");return b.grep(c,function(e){return g.test(e.label||e.value||e)})}})})(jQuery);
|
244 |
+
(function(b){b.widget("ui.menu",{_create:function(){var c=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(f){if(b(f.target).closest(".ui-menu-item a").length){f.preventDefault();c.select(f)}});this.refresh()},refresh:function(){var c=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex",
|
245 |
+
-1).mouseenter(function(f){c.activate(f,b(this).parent())}).mouseleave(function(){c.deactivate()})},activate:function(c,f){this.deactivate();if(this.hasScroll()){var g=f.offset().top-this.element.offset().top,e=this.element.attr("scrollTop"),a=this.element.height();if(g<0)this.element.attr("scrollTop",e+g);else g>=a&&this.element.attr("scrollTop",e+g-a+f.height())}this.active=f.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",c,{item:f})},
|
246 |
+
deactivate:function(){if(this.active){this.active.children("a").removeClass("ui-state-hover").removeAttr("id");this._trigger("blur");this.active=null}},next:function(c){this.move("next",".ui-menu-item:first",c)},previous:function(c){this.move("prev",".ui-menu-item:last",c)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(c,f,g){if(this.active){c=this.active[c+"All"](".ui-menu-item").eq(0);
|
247 |
+
c.length?this.activate(g,c):this.activate(g,this.element.children(f))}else this.activate(g,this.element.children(f))},nextPage:function(c){if(this.hasScroll())if(!this.active||this.last())this.activate(c,this.element.children(".ui-menu-item:first"));else{var f=this.active.offset().top,g=this.element.height(),e=this.element.children(".ui-menu-item").filter(function(){var a=b(this).offset().top-f-g+b(this).height();return a<10&&a>-10});e.length||(e=this.element.children(".ui-menu-item:last"));this.activate(c,
|
248 |
+
e)}else this.activate(c,this.element.children(".ui-menu-item").filter(!this.active||this.last()?":first":":last"))},previousPage:function(c){if(this.hasScroll())if(!this.active||this.first())this.activate(c,this.element.children(".ui-menu-item:last"));else{var f=this.active.offset().top,g=this.element.height();result=this.element.children(".ui-menu-item").filter(function(){var e=b(this).offset().top-f+g-b(this).height();return e<10&&e>-10});result.length||(result=this.element.children(".ui-menu-item:first"));
|
249 |
+
this.activate(c,result)}else this.activate(c,this.element.children(".ui-menu-item").filter(!this.active||this.first()?":last":":first"))},hasScroll:function(){return this.element.height()<this.element.attr("scrollHeight")},select:function(c){this._trigger("selected",c,{item:this.active})}})})(jQuery);
|
250 |
+
(function(b){var c,f=function(e){b(":ui-button",e.target.form).each(function(){var a=b(this).data("button");setTimeout(function(){a.refresh()},1)})},g=function(e){var a=e.name,d=e.form,h=b([]);if(a)h=d?b(d).find("[name='"+a+"']"):b("[name='"+a+"']",e.ownerDocument).filter(function(){return!this.form});return h};b.widget("ui.button",{options:{disabled:null,text:true,label:null,icons:{primary:null,secondary:null}},_create:function(){this.element.closest("form").unbind("reset.button").bind("reset.button",
|
251 |
+
f);if(typeof this.options.disabled!=="boolean")this.options.disabled=this.element.attr("disabled");this._determineButtonType();this.hasTitle=!!this.buttonElement.attr("title");var e=this,a=this.options,d=this.type==="checkbox"||this.type==="radio",h="ui-state-hover"+(!d?" ui-state-active":"");if(a.label===null)a.label=this.buttonElement.html();if(this.element.is(":disabled"))a.disabled=true;this.buttonElement.addClass("ui-button ui-widget ui-state-default ui-corner-all").attr("role","button").bind("mouseenter.button",
|
252 |
+
function(){if(!a.disabled){b(this).addClass("ui-state-hover");this===c&&b(this).addClass("ui-state-active")}}).bind("mouseleave.button",function(){a.disabled||b(this).removeClass(h)}).bind("focus.button",function(){b(this).addClass("ui-state-focus")}).bind("blur.button",function(){b(this).removeClass("ui-state-focus")});d&&this.element.bind("change.button",function(){e.refresh()});if(this.type==="checkbox")this.buttonElement.bind("click.button",function(){if(a.disabled)return false;b(this).toggleClass("ui-state-active");
|
253 |
+
e.buttonElement.attr("aria-pressed",e.element[0].checked)});else if(this.type==="radio")this.buttonElement.bind("click.button",function(){if(a.disabled)return false;b(this).addClass("ui-state-active");e.buttonElement.attr("aria-pressed",true);var i=e.element[0];g(i).not(i).map(function(){return b(this).button("widget")[0]}).removeClass("ui-state-active").attr("aria-pressed",false)});else{this.buttonElement.bind("mousedown.button",function(){if(a.disabled)return false;b(this).addClass("ui-state-active");
|
254 |
+
c=this;b(document).one("mouseup",function(){c=null})}).bind("mouseup.button",function(){if(a.disabled)return false;b(this).removeClass("ui-state-active")}).bind("keydown.button",function(i){if(a.disabled)return false;if(i.keyCode==b.ui.keyCode.SPACE||i.keyCode==b.ui.keyCode.ENTER)b(this).addClass("ui-state-active")}).bind("keyup.button",function(){b(this).removeClass("ui-state-active")});this.buttonElement.is("a")&&this.buttonElement.keyup(function(i){i.keyCode===b.ui.keyCode.SPACE&&b(this).click()})}this._setOption("disabled",
|
255 |
+
a.disabled)},_determineButtonType:function(){this.type=this.element.is(":checkbox")?"checkbox":this.element.is(":radio")?"radio":this.element.is("input")?"input":"button";if(this.type==="checkbox"||this.type==="radio"){this.buttonElement=this.element.parents().last().find("label[for="+this.element.attr("id")+"]");this.element.addClass("ui-helper-hidden-accessible");var e=this.element.is(":checked");e&&this.buttonElement.addClass("ui-state-active");this.buttonElement.attr("aria-pressed",e)}else this.buttonElement=
|
256 |
+
this.element},widget:function(){return this.buttonElement},destroy:function(){this.element.removeClass("ui-helper-hidden-accessible");this.buttonElement.removeClass("ui-button ui-widget ui-state-default ui-corner-all ui-state-hover ui-state-active 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").removeAttr("role").removeAttr("aria-pressed").html(this.buttonElement.find(".ui-button-text").html());this.hasTitle||
|
257 |
+
this.buttonElement.removeAttr("title");b.Widget.prototype.destroy.call(this)},_setOption:function(e,a){b.Widget.prototype._setOption.apply(this,arguments);if(e==="disabled")a?this.element.attr("disabled",true):this.element.removeAttr("disabled");this._resetButton()},refresh:function(){var e=this.element.is(":disabled");e!==this.options.disabled&&this._setOption("disabled",e);if(this.type==="radio")g(this.element[0]).each(function(){b(this).is(":checked")?b(this).button("widget").addClass("ui-state-active").attr("aria-pressed",
|
258 |
+
true):b(this).button("widget").removeClass("ui-state-active").attr("aria-pressed",false)});else if(this.type==="checkbox")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(this.type==="input")this.options.label&&this.element.val(this.options.label);else{var e=this.buttonElement.removeClass("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"),
|
259 |
+
a=b("<span></span>").addClass("ui-button-text").html(this.options.label).appendTo(e.empty()).text(),d=this.options.icons,h=d.primary&&d.secondary;if(d.primary||d.secondary){e.addClass("ui-button-text-icon"+(h?"s":d.primary?"-primary":"-secondary"));d.primary&&e.prepend("<span class='ui-button-icon-primary ui-icon "+d.primary+"'></span>");d.secondary&&e.append("<span class='ui-button-icon-secondary ui-icon "+d.secondary+"'></span>");if(!this.options.text){e.addClass(h?"ui-button-icons-only":"ui-button-icon-only").removeClass("ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary");
|
260 |
+
this.hasTitle||e.attr("title",a)}}else e.addClass("ui-button-text-only")}}});b.widget("ui.buttonset",{_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(e,a){e==="disabled"&&this.buttons.button("option",e,a);b.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){this.buttons=this.element.find(":button, :submit, :reset, :checkbox, :radio, a, :data(button)").filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return b(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":visible").filter(":first").addClass("ui-corner-left").end().filter(":last").addClass("ui-corner-right").end().end().end()},
|
261 |
+
destroy:function(){this.element.removeClass("ui-buttonset");this.buttons.map(function(){return b(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy");b.Widget.prototype.destroy.call(this)}})})(jQuery);
|
262 |
+
(function(b,c){function f(){this.debug=false;this._curInst=null;this._keyEvent=false;this._disabledInputs=[];this._inDialog=this._datepickerShowing=false;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=
|
263 |
+
"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",
|
264 |
+
"Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:false,showMonthAfterYear:false,yearSuffix:""};this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:false,hideIfNoPrevNext:false,navigationAsDateFormat:false,gotoCurrent:false,changeMonth:false,changeYear:false,yearRange:"c-10:c+10",showOtherMonths:false,selectOtherMonths:false,showWeek:false,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",
|
265 |
+
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:true,showButtonPanel:false,autoSize:false};b.extend(this._defaults,this.regional[""]);this.dpDiv=b('<div id="'+this._mainDivId+'" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all ui-helper-hidden-accessible"></div>')}function g(a,d){b.extend(a,
|
266 |
+
d);for(var h in d)if(d[h]==null||d[h]==c)a[h]=d[h];return a}b.extend(b.ui,{datepicker:{version:"1.8.6"}});var e=(new Date).getTime();b.extend(f.prototype,{markerClassName:"hasDatepicker",log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(a){g(this._defaults,a||{});return this},_attachDatepicker:function(a,d){var h=null;for(var i in this._defaults){var j=a.getAttribute("date:"+i);if(j){h=h||{};try{h[i]=eval(j)}catch(n){h[i]=
|
267 |
+
j}}}i=a.nodeName.toLowerCase();j=i=="div"||i=="span";if(!a.id){this.uuid+=1;a.id="dp"+this.uuid}var q=this._newInst(b(a),j);q.settings=b.extend({},d||{},h||{});if(i=="input")this._connectDatepicker(a,q);else j&&this._inlineDatepicker(a,q)},_newInst:function(a,d){return{id:a[0].id.replace(/([^A-Za-z0-9_-])/g,"\\\\$1"),input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:d,dpDiv:!d?this.dpDiv:b('<div class="'+this._inlineClass+' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>')}},
|
268 |
+
_connectDatepicker:function(a,d){var h=b(a);d.append=b([]);d.trigger=b([]);if(!h.hasClass(this.markerClassName)){this._attachments(h,d);h.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",function(i,j,n){d.settings[j]=n}).bind("getData.datepicker",function(i,j){return this._get(d,j)});this._autoSize(d);b.data(a,"datepicker",d)}},_attachments:function(a,d){var h=this._get(d,"appendText"),i=this._get(d,"isRTL");d.append&&
|
269 |
+
d.append.remove();if(h){d.append=b('<span class="'+this._appendClass+'">'+h+"</span>");a[i?"before":"after"](d.append)}a.unbind("focus",this._showDatepicker);d.trigger&&d.trigger.remove();h=this._get(d,"showOn");if(h=="focus"||h=="both")a.focus(this._showDatepicker);if(h=="button"||h=="both"){h=this._get(d,"buttonText");var j=this._get(d,"buttonImage");d.trigger=b(this._get(d,"buttonImageOnly")?b("<img/>").addClass(this._triggerClass).attr({src:j,alt:h,title:h}):b('<button type="button"></button>').addClass(this._triggerClass).html(j==
|
270 |
+
""?h:b("<img/>").attr({src:j,alt:h,title:h})));a[i?"before":"after"](d.trigger);d.trigger.click(function(){b.datepicker._datepickerShowing&&b.datepicker._lastInput==a[0]?b.datepicker._hideDatepicker():b.datepicker._showDatepicker(a[0]);return false})}},_autoSize:function(a){if(this._get(a,"autoSize")&&!a.inline){var d=new Date(2009,11,20),h=this._get(a,"dateFormat");if(h.match(/[DM]/)){var i=function(j){for(var n=0,q=0,l=0;l<j.length;l++)if(j[l].length>n){n=j[l].length;q=l}return q};d.setMonth(i(this._get(a,
|
271 |
+
h.match(/MM/)?"monthNames":"monthNamesShort")));d.setDate(i(this._get(a,h.match(/DD/)?"dayNames":"dayNamesShort"))+20-d.getDay())}a.input.attr("size",this._formatDate(a,d).length)}},_inlineDatepicker:function(a,d){var h=b(a);if(!h.hasClass(this.markerClassName)){h.addClass(this.markerClassName).append(d.dpDiv).bind("setData.datepicker",function(i,j,n){d.settings[j]=n}).bind("getData.datepicker",function(i,j){return this._get(d,j)});b.data(a,"datepicker",d);this._setDate(d,this._getDefaultDate(d),
|
272 |
+
true);this._updateDatepicker(d);this._updateAlternate(d)}},_dialogDatepicker:function(a,d,h,i,j){a=this._dialogInst;if(!a){this.uuid+=1;this._dialogInput=b('<input type="text" id="'+("dp"+this.uuid)+'" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');this._dialogInput.keydown(this._doKeyDown);b("body").append(this._dialogInput);a=this._dialogInst=this._newInst(this._dialogInput,false);a.settings={};b.data(this._dialogInput[0],"datepicker",a)}g(a.settings,i||{});d=d&&d.constructor==
|
273 |
+
Date?this._formatDate(a,d):d;this._dialogInput.val(d);this._pos=j?j.length?j:[j.pageX,j.pageY]:null;if(!this._pos)this._pos=[document.documentElement.clientWidth/2-100+(document.documentElement.scrollLeft||document.body.scrollLeft),document.documentElement.clientHeight/2-150+(document.documentElement.scrollTop||document.body.scrollTop)];this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px");a.settings.onSelect=h;this._inDialog=true;this.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);
|
274 |
+
b.blockUI&&b.blockUI(this.dpDiv);b.data(this._dialogInput[0],"datepicker",a);return this},_destroyDatepicker:function(a){var d=b(a),h=b.data(a,"datepicker");if(d.hasClass(this.markerClassName)){var i=a.nodeName.toLowerCase();b.removeData(a,"datepicker");if(i=="input"){h.append.remove();h.trigger.remove();d.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)}else if(i=="div"||i=="span")d.removeClass(this.markerClassName).empty()}},
|
275 |
+
_enableDatepicker:function(a){var d=b(a),h=b.data(a,"datepicker");if(d.hasClass(this.markerClassName)){var i=a.nodeName.toLowerCase();if(i=="input"){a.disabled=false;h.trigger.filter("button").each(function(){this.disabled=false}).end().filter("img").css({opacity:"1.0",cursor:""})}else if(i=="div"||i=="span")d.children("."+this._inlineClass).children().removeClass("ui-state-disabled");this._disabledInputs=b.map(this._disabledInputs,function(j){return j==a?null:j})}},_disableDatepicker:function(a){var d=
|
276 |
+
b(a),h=b.data(a,"datepicker");if(d.hasClass(this.markerClassName)){var i=a.nodeName.toLowerCase();if(i=="input"){a.disabled=true;h.trigger.filter("button").each(function(){this.disabled=true}).end().filter("img").css({opacity:"0.5",cursor:"default"})}else if(i=="div"||i=="span")d.children("."+this._inlineClass).children().addClass("ui-state-disabled");this._disabledInputs=b.map(this._disabledInputs,function(j){return j==a?null:j});this._disabledInputs[this._disabledInputs.length]=a}},_isDisabledDatepicker:function(a){if(!a)return false;
|
277 |
+
for(var d=0;d<this._disabledInputs.length;d++)if(this._disabledInputs[d]==a)return true;return false},_getInst:function(a){try{return b.data(a,"datepicker")}catch(d){throw"Missing instance data for this datepicker";}},_optionDatepicker:function(a,d,h){var i=this._getInst(a);if(arguments.length==2&&typeof d=="string")return d=="defaults"?b.extend({},b.datepicker._defaults):i?d=="all"?b.extend({},i.settings):this._get(i,d):null;var j=d||{};if(typeof d=="string"){j={};j[d]=h}if(i){this._curInst==i&&
|
278 |
+
this._hideDatepicker();var n=this._getDateDatepicker(a,true);g(i.settings,j);this._attachments(b(a),i);this._autoSize(i);this._setDateDatepicker(a,n);this._updateDatepicker(i)}},_changeDatepicker:function(a,d,h){this._optionDatepicker(a,d,h)},_refreshDatepicker:function(a){(a=this._getInst(a))&&this._updateDatepicker(a)},_setDateDatepicker:function(a,d){if(a=this._getInst(a)){this._setDate(a,d);this._updateDatepicker(a);this._updateAlternate(a)}},_getDateDatepicker:function(a,d){(a=this._getInst(a))&&
|
279 |
+
!a.inline&&this._setDateFromField(a,d);return a?this._getDate(a):null},_doKeyDown:function(a){var d=b.datepicker._getInst(a.target),h=true,i=d.dpDiv.is(".ui-datepicker-rtl");d._keyEvent=true;if(b.datepicker._datepickerShowing)switch(a.keyCode){case 9:b.datepicker._hideDatepicker();h=false;break;case 13:h=b("td."+b.datepicker._dayOverClass,d.dpDiv).add(b("td."+b.datepicker._currentClass,d.dpDiv));h[0]?b.datepicker._selectDay(a.target,d.selectedMonth,d.selectedYear,h[0]):b.datepicker._hideDatepicker();
|
280 |
+
return false;case 27:b.datepicker._hideDatepicker();break;case 33:b.datepicker._adjustDate(a.target,a.ctrlKey?-b.datepicker._get(d,"stepBigMonths"):-b.datepicker._get(d,"stepMonths"),"M");break;case 34:b.datepicker._adjustDate(a.target,a.ctrlKey?+b.datepicker._get(d,"stepBigMonths"):+b.datepicker._get(d,"stepMonths"),"M");break;case 35:if(a.ctrlKey||a.metaKey)b.datepicker._clearDate(a.target);h=a.ctrlKey||a.metaKey;break;case 36:if(a.ctrlKey||a.metaKey)b.datepicker._gotoToday(a.target);h=a.ctrlKey||
|
281 |
+
a.metaKey;break;case 37:if(a.ctrlKey||a.metaKey)b.datepicker._adjustDate(a.target,i?+1:-1,"D");h=a.ctrlKey||a.metaKey;if(a.originalEvent.altKey)b.datepicker._adjustDate(a.target,a.ctrlKey?-b.datepicker._get(d,"stepBigMonths"):-b.datepicker._get(d,"stepMonths"),"M");break;case 38:if(a.ctrlKey||a.metaKey)b.datepicker._adjustDate(a.target,-7,"D");h=a.ctrlKey||a.metaKey;break;case 39:if(a.ctrlKey||a.metaKey)b.datepicker._adjustDate(a.target,i?-1:+1,"D");h=a.ctrlKey||a.metaKey;if(a.originalEvent.altKey)b.datepicker._adjustDate(a.target,
|
282 |
+
a.ctrlKey?+b.datepicker._get(d,"stepBigMonths"):+b.datepicker._get(d,"stepMonths"),"M");break;case 40:if(a.ctrlKey||a.metaKey)b.datepicker._adjustDate(a.target,+7,"D");h=a.ctrlKey||a.metaKey;break;default:h=false}else if(a.keyCode==36&&a.ctrlKey)b.datepicker._showDatepicker(this);else h=false;if(h){a.preventDefault();a.stopPropagation()}},_doKeyPress:function(a){var d=b.datepicker._getInst(a.target);if(b.datepicker._get(d,"constrainInput")){d=b.datepicker._possibleChars(b.datepicker._get(d,"dateFormat"));
|
283 |
+
var h=String.fromCharCode(a.charCode==c?a.keyCode:a.charCode);return a.ctrlKey||h<" "||!d||d.indexOf(h)>-1}},_doKeyUp:function(a){a=b.datepicker._getInst(a.target);if(a.input.val()!=a.lastVal)try{if(b.datepicker.parseDate(b.datepicker._get(a,"dateFormat"),a.input?a.input.val():null,b.datepicker._getFormatConfig(a))){b.datepicker._setDateFromField(a);b.datepicker._updateAlternate(a);b.datepicker._updateDatepicker(a)}}catch(d){b.datepicker.log(d)}return true},_showDatepicker:function(a){a=a.target||
|
284 |
+
a;if(a.nodeName.toLowerCase()!="input")a=b("input",a.parentNode)[0];if(!(b.datepicker._isDisabledDatepicker(a)||b.datepicker._lastInput==a)){var d=b.datepicker._getInst(a);b.datepicker._curInst&&b.datepicker._curInst!=d&&b.datepicker._curInst.dpDiv.stop(true,true);var h=b.datepicker._get(d,"beforeShow");g(d.settings,h?h.apply(a,[a,d]):{});d.lastVal=null;b.datepicker._lastInput=a;b.datepicker._setDateFromField(d);if(b.datepicker._inDialog)a.value="";if(!b.datepicker._pos){b.datepicker._pos=b.datepicker._findPos(a);
|
285 |
+
b.datepicker._pos[1]+=a.offsetHeight}var i=false;b(a).parents().each(function(){i|=b(this).css("position")=="fixed";return!i});if(i&&b.browser.opera){b.datepicker._pos[0]-=document.documentElement.scrollLeft;b.datepicker._pos[1]-=document.documentElement.scrollTop}h={left:b.datepicker._pos[0],top:b.datepicker._pos[1]};b.datepicker._pos=null;d.dpDiv.css({position:"absolute",display:"block",top:"-1000px"});b.datepicker._updateDatepicker(d);h=b.datepicker._checkOffset(d,h,i);d.dpDiv.css({position:b.datepicker._inDialog&&
|
286 |
+
b.blockUI?"static":i?"fixed":"absolute",display:"none",left:h.left+"px",top:h.top+"px"});if(!d.inline){h=b.datepicker._get(d,"showAnim");var j=b.datepicker._get(d,"duration"),n=function(){b.datepicker._datepickerShowing=true;var q=b.datepicker._getBorders(d.dpDiv);d.dpDiv.find("iframe.ui-datepicker-cover").css({left:-q[0],top:-q[1],width:d.dpDiv.outerWidth(),height:d.dpDiv.outerHeight()})};d.dpDiv.zIndex(b(a).zIndex()+1);b.effects&&b.effects[h]?d.dpDiv.show(h,b.datepicker._get(d,"showOptions"),j,
|
287 |
+
n):d.dpDiv[h||"show"](h?j:null,n);if(!h||!j)n();d.input.is(":visible")&&!d.input.is(":disabled")&&d.input.focus();b.datepicker._curInst=d}}},_updateDatepicker:function(a){var d=this,h=b.datepicker._getBorders(a.dpDiv);a.dpDiv.empty().append(this._generateHTML(a)).find("iframe.ui-datepicker-cover").css({left:-h[0],top:-h[1],width:a.dpDiv.outerWidth(),height:a.dpDiv.outerHeight()}).end().find("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a").bind("mouseout",function(){b(this).removeClass("ui-state-hover");
|
288 |
+
this.className.indexOf("ui-datepicker-prev")!=-1&&b(this).removeClass("ui-datepicker-prev-hover");this.className.indexOf("ui-datepicker-next")!=-1&&b(this).removeClass("ui-datepicker-next-hover")}).bind("mouseover",function(){if(!d._isDisabledDatepicker(a.inline?a.dpDiv.parent()[0]:a.input[0])){b(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");b(this).addClass("ui-state-hover");this.className.indexOf("ui-datepicker-prev")!=-1&&b(this).addClass("ui-datepicker-prev-hover");
|
289 |
+
this.className.indexOf("ui-datepicker-next")!=-1&&b(this).addClass("ui-datepicker-next-hover")}}).end().find("."+this._dayOverClass+" a").trigger("mouseover").end();h=this._getNumberOfMonths(a);var i=h[1];i>1?a.dpDiv.addClass("ui-datepicker-multi-"+i).css("width",17*i+"em"):a.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");a.dpDiv[(h[0]!=1||h[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi");a.dpDiv[(this._get(a,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl");
|
290 |
+
a==b.datepicker._curInst&&b.datepicker._datepickerShowing&&a.input&&a.input.is(":visible")&&!a.input.is(":disabled")&&a.input.focus()},_getBorders:function(a){var d=function(h){return{thin:1,medium:2,thick:3}[h]||h};return[parseFloat(d(a.css("border-left-width"))),parseFloat(d(a.css("border-top-width")))]},_checkOffset:function(a,d,h){var i=a.dpDiv.outerWidth(),j=a.dpDiv.outerHeight(),n=a.input?a.input.outerWidth():0,q=a.input?a.input.outerHeight():0,l=document.documentElement.clientWidth+b(document).scrollLeft(),
|
291 |
+
k=document.documentElement.clientHeight+b(document).scrollTop();d.left-=this._get(a,"isRTL")?i-n:0;d.left-=h&&d.left==a.input.offset().left?b(document).scrollLeft():0;d.top-=h&&d.top==a.input.offset().top+q?b(document).scrollTop():0;d.left-=Math.min(d.left,d.left+i>l&&l>i?Math.abs(d.left+i-l):0);d.top-=Math.min(d.top,d.top+j>k&&k>j?Math.abs(j+q):0);return d},_findPos:function(a){for(var d=this._get(this._getInst(a),"isRTL");a&&(a.type=="hidden"||a.nodeType!=1);)a=a[d?"previousSibling":"nextSibling"];
|
292 |
+
a=b(a).offset();return[a.left,a.top]},_hideDatepicker:function(a){var d=this._curInst;if(!(!d||a&&d!=b.data(a,"datepicker")))if(this._datepickerShowing){a=this._get(d,"showAnim");var h=this._get(d,"duration"),i=function(){b.datepicker._tidyDialog(d);this._curInst=null};b.effects&&b.effects[a]?d.dpDiv.hide(a,b.datepicker._get(d,"showOptions"),h,i):d.dpDiv[a=="slideDown"?"slideUp":a=="fadeIn"?"fadeOut":"hide"](a?h:null,i);a||i();if(a=this._get(d,"onClose"))a.apply(d.input?d.input[0]:null,[d.input?d.input.val():
|
293 |
+
"",d]);this._datepickerShowing=false;this._lastInput=null;if(this._inDialog){this._dialogInput.css({position:"absolute",left:"0",top:"-100px"});if(b.blockUI){b.unblockUI();b("body").append(this.dpDiv)}}this._inDialog=false}},_tidyDialog:function(a){a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(a){if(b.datepicker._curInst){a=b(a.target);a[0].id!=b.datepicker._mainDivId&&a.parents("#"+b.datepicker._mainDivId).length==0&&!a.hasClass(b.datepicker.markerClassName)&&
|
294 |
+
!a.hasClass(b.datepicker._triggerClass)&&b.datepicker._datepickerShowing&&!(b.datepicker._inDialog&&b.blockUI)&&b.datepicker._hideDatepicker()}},_adjustDate:function(a,d,h){a=b(a);var i=this._getInst(a[0]);if(!this._isDisabledDatepicker(a[0])){this._adjustInstDate(i,d+(h=="M"?this._get(i,"showCurrentAtPos"):0),h);this._updateDatepicker(i)}},_gotoToday:function(a){a=b(a);var d=this._getInst(a[0]);if(this._get(d,"gotoCurrent")&&d.currentDay){d.selectedDay=d.currentDay;d.drawMonth=d.selectedMonth=d.currentMonth;
|
295 |
+
d.drawYear=d.selectedYear=d.currentYear}else{var h=new Date;d.selectedDay=h.getDate();d.drawMonth=d.selectedMonth=h.getMonth();d.drawYear=d.selectedYear=h.getFullYear()}this._notifyChange(d);this._adjustDate(a)},_selectMonthYear:function(a,d,h){a=b(a);var i=this._getInst(a[0]);i._selectingMonthYear=false;i["selected"+(h=="M"?"Month":"Year")]=i["draw"+(h=="M"?"Month":"Year")]=parseInt(d.options[d.selectedIndex].value,10);this._notifyChange(i);this._adjustDate(a)},_clickMonthYear:function(a){var d=
|
296 |
+
this._getInst(b(a)[0]);d.input&&d._selectingMonthYear&&setTimeout(function(){d.input.focus()},0);d._selectingMonthYear=!d._selectingMonthYear},_selectDay:function(a,d,h,i){var j=b(a);if(!(b(i).hasClass(this._unselectableClass)||this._isDisabledDatepicker(j[0]))){j=this._getInst(j[0]);j.selectedDay=j.currentDay=b("a",i).html();j.selectedMonth=j.currentMonth=d;j.selectedYear=j.currentYear=h;this._selectDate(a,this._formatDate(j,j.currentDay,j.currentMonth,j.currentYear))}},_clearDate:function(a){a=
|
297 |
+
b(a);this._getInst(a[0]);this._selectDate(a,"")},_selectDate:function(a,d){a=this._getInst(b(a)[0]);d=d!=null?d:this._formatDate(a);a.input&&a.input.val(d);this._updateAlternate(a);var h=this._get(a,"onSelect");if(h)h.apply(a.input?a.input[0]:null,[d,a]);else a.input&&a.input.trigger("change");if(a.inline)this._updateDatepicker(a);else{this._hideDatepicker();this._lastInput=a.input[0];typeof a.input[0]!="object"&&a.input.focus();this._lastInput=null}},_updateAlternate:function(a){var d=this._get(a,
|
298 |
+
"altField");if(d){var h=this._get(a,"altFormat")||this._get(a,"dateFormat"),i=this._getDate(a),j=this.formatDate(h,i,this._getFormatConfig(a));b(d).each(function(){b(this).val(j)})}},noWeekends:function(a){a=a.getDay();return[a>0&&a<6,""]},iso8601Week:function(a){a=new Date(a.getTime());a.setDate(a.getDate()+4-(a.getDay()||7));var d=a.getTime();a.setMonth(0);a.setDate(1);return Math.floor(Math.round((d-a)/864E5)/7)+1},parseDate:function(a,d,h){if(a==null||d==null)throw"Invalid arguments";d=typeof d==
|
299 |
+
"object"?d.toString():d+"";if(d=="")return null;for(var i=(h?h.shortYearCutoff:null)||this._defaults.shortYearCutoff,j=(h?h.dayNamesShort:null)||this._defaults.dayNamesShort,n=(h?h.dayNames:null)||this._defaults.dayNames,q=(h?h.monthNamesShort:null)||this._defaults.monthNamesShort,l=(h?h.monthNames:null)||this._defaults.monthNames,k=h=-1,m=-1,o=-1,p=false,s=function(x){(x=y+1<a.length&&a.charAt(y+1)==x)&&y++;return x},r=function(x){s(x);x=new RegExp("^\\d{1,"+(x=="@"?14:x=="!"?20:x=="y"?4:x=="o"?
|
300 |
+
3:2)+"}");x=d.substring(w).match(x);if(!x)throw"Missing number at position "+w;w+=x[0].length;return parseInt(x[0],10)},u=function(x,C,J){x=s(x)?J:C;for(C=0;C<x.length;C++)if(d.substr(w,x[C].length).toLowerCase()==x[C].toLowerCase()){w+=x[C].length;return C+1}throw"Unknown name at position "+w;},v=function(){if(d.charAt(w)!=a.charAt(y))throw"Unexpected literal at position "+w;w++},w=0,y=0;y<a.length;y++)if(p)if(a.charAt(y)=="'"&&!s("'"))p=false;else v();else switch(a.charAt(y)){case "d":m=r("d");
|
301 |
+
break;case "D":u("D",j,n);break;case "o":o=r("o");break;case "m":k=r("m");break;case "M":k=u("M",q,l);break;case "y":h=r("y");break;case "@":var B=new Date(r("@"));h=B.getFullYear();k=B.getMonth()+1;m=B.getDate();break;case "!":B=new Date((r("!")-this._ticksTo1970)/1E4);h=B.getFullYear();k=B.getMonth()+1;m=B.getDate();break;case "'":if(s("'"))v();else p=true;break;default:v()}if(h==-1)h=(new Date).getFullYear();else if(h<100)h+=(new Date).getFullYear()-(new Date).getFullYear()%100+(h<=i?0:-100);if(o>
|
302 |
+
-1){k=1;m=o;do{i=this._getDaysInMonth(h,k-1);if(m<=i)break;k++;m-=i}while(1)}B=this._daylightSavingAdjust(new Date(h,k-1,m));if(B.getFullYear()!=h||B.getMonth()+1!=k||B.getDate()!=m)throw"Invalid date";return B},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:(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*24*
|
303 |
+
60*60*1E7,formatDate:function(a,d,h){if(!d)return"";var i=(h?h.dayNamesShort:null)||this._defaults.dayNamesShort,j=(h?h.dayNames:null)||this._defaults.dayNames,n=(h?h.monthNamesShort:null)||this._defaults.monthNamesShort;h=(h?h.monthNames:null)||this._defaults.monthNames;var q=function(s){(s=p+1<a.length&&a.charAt(p+1)==s)&&p++;return s},l=function(s,r,u){r=""+r;if(q(s))for(;r.length<u;)r="0"+r;return r},k=function(s,r,u,v){return q(s)?v[r]:u[r]},m="",o=false;if(d)for(var p=0;p<a.length;p++)if(o)if(a.charAt(p)==
|
304 |
+
"'"&&!q("'"))o=false;else m+=a.charAt(p);else switch(a.charAt(p)){case "d":m+=l("d",d.getDate(),2);break;case "D":m+=k("D",d.getDay(),i,j);break;case "o":m+=l("o",(d.getTime()-(new Date(d.getFullYear(),0,0)).getTime())/864E5,3);break;case "m":m+=l("m",d.getMonth()+1,2);break;case "M":m+=k("M",d.getMonth(),n,h);break;case "y":m+=q("y")?d.getFullYear():(d.getYear()%100<10?"0":"")+d.getYear()%100;break;case "@":m+=d.getTime();break;case "!":m+=d.getTime()*1E4+this._ticksTo1970;break;case "'":if(q("'"))m+=
|
305 |
+
"'";else o=true;break;default:m+=a.charAt(p)}return m},_possibleChars:function(a){for(var d="",h=false,i=function(n){(n=j+1<a.length&&a.charAt(j+1)==n)&&j++;return n},j=0;j<a.length;j++)if(h)if(a.charAt(j)=="'"&&!i("'"))h=false;else d+=a.charAt(j);else switch(a.charAt(j)){case "d":case "m":case "y":case "@":d+="0123456789";break;case "D":case "M":return null;case "'":if(i("'"))d+="'";else h=true;break;default:d+=a.charAt(j)}return d},_get:function(a,d){return a.settings[d]!==c?a.settings[d]:this._defaults[d]},
|
306 |
+
_setDateFromField:function(a,d){if(a.input.val()!=a.lastVal){var h=this._get(a,"dateFormat"),i=a.lastVal=a.input?a.input.val():null,j,n;j=n=this._getDefaultDate(a);var q=this._getFormatConfig(a);try{j=this.parseDate(h,i,q)||n}catch(l){this.log(l);i=d?"":i}a.selectedDay=j.getDate();a.drawMonth=a.selectedMonth=j.getMonth();a.drawYear=a.selectedYear=j.getFullYear();a.currentDay=i?j.getDate():0;a.currentMonth=i?j.getMonth():0;a.currentYear=i?j.getFullYear():0;this._adjustInstDate(a)}},_getDefaultDate:function(a){return this._restrictMinMax(a,
|
307 |
+
this._determineDate(a,this._get(a,"defaultDate"),new Date))},_determineDate:function(a,d,h){var i=function(n){var q=new Date;q.setDate(q.getDate()+n);return q},j=function(n){try{return b.datepicker.parseDate(b.datepicker._get(a,"dateFormat"),n,b.datepicker._getFormatConfig(a))}catch(q){}var l=(n.toLowerCase().match(/^c/)?b.datepicker._getDate(a):null)||new Date,k=l.getFullYear(),m=l.getMonth();l=l.getDate();for(var o=/([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,p=o.exec(n);p;){switch(p[2]||"d"){case "d":case "D":l+=
|
308 |
+
parseInt(p[1],10);break;case "w":case "W":l+=parseInt(p[1],10)*7;break;case "m":case "M":m+=parseInt(p[1],10);l=Math.min(l,b.datepicker._getDaysInMonth(k,m));break;case "y":case "Y":k+=parseInt(p[1],10);l=Math.min(l,b.datepicker._getDaysInMonth(k,m));break}p=o.exec(n)}return new Date(k,m,l)};if(d=(d=d==null?h:typeof d=="string"?j(d):typeof d=="number"?isNaN(d)?h:i(d):d)&&d.toString()=="Invalid Date"?h:d){d.setHours(0);d.setMinutes(0);d.setSeconds(0);d.setMilliseconds(0)}return this._daylightSavingAdjust(d)},
|
309 |
+
_daylightSavingAdjust:function(a){if(!a)return null;a.setHours(a.getHours()>12?a.getHours()+2:0);return a},_setDate:function(a,d,h){var i=!d,j=a.selectedMonth,n=a.selectedYear;d=this._restrictMinMax(a,this._determineDate(a,d,new Date));a.selectedDay=a.currentDay=d.getDate();a.drawMonth=a.selectedMonth=a.currentMonth=d.getMonth();a.drawYear=a.selectedYear=a.currentYear=d.getFullYear();if((j!=a.selectedMonth||n!=a.selectedYear)&&!h)this._notifyChange(a);this._adjustInstDate(a);if(a.input)a.input.val(i?
|
310 |
+
"":this._formatDate(a))},_getDate:function(a){return!a.currentYear||a.input&&a.input.val()==""?null:this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay))},_generateHTML:function(a){var d=new Date;d=this._daylightSavingAdjust(new Date(d.getFullYear(),d.getMonth(),d.getDate()));var h=this._get(a,"isRTL"),i=this._get(a,"showButtonPanel"),j=this._get(a,"hideIfNoPrevNext"),n=this._get(a,"navigationAsDateFormat"),q=this._getNumberOfMonths(a),l=this._get(a,"showCurrentAtPos"),k=
|
311 |
+
this._get(a,"stepMonths"),m=q[0]!=1||q[1]!=1,o=this._daylightSavingAdjust(!a.currentDay?new Date(9999,9,9):new Date(a.currentYear,a.currentMonth,a.currentDay)),p=this._getMinMaxDate(a,"min"),s=this._getMinMaxDate(a,"max");l=a.drawMonth-l;var r=a.drawYear;if(l<0){l+=12;r--}if(s){var u=this._daylightSavingAdjust(new Date(s.getFullYear(),s.getMonth()-q[0]*q[1]+1,s.getDate()));for(u=p&&u<p?p:u;this._daylightSavingAdjust(new Date(r,l,1))>u;){l--;if(l<0){l=11;r--}}}a.drawMonth=l;a.drawYear=r;u=this._get(a,
|
312 |
+
"prevText");u=!n?u:this.formatDate(u,this._daylightSavingAdjust(new Date(r,l-k,1)),this._getFormatConfig(a));u=this._canAdjustMonth(a,-1,r,l)?'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_'+e+".datepicker._adjustDate('#"+a.id+"', -"+k+", 'M');\" title=\""+u+'"><span class="ui-icon ui-icon-circle-triangle-'+(h?"e":"w")+'">'+u+"</span></a>":j?"":'<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+u+'"><span class="ui-icon ui-icon-circle-triangle-'+(h?"e":"w")+'">'+
|
313 |
+
u+"</span></a>";var v=this._get(a,"nextText");v=!n?v:this.formatDate(v,this._daylightSavingAdjust(new Date(r,l+k,1)),this._getFormatConfig(a));j=this._canAdjustMonth(a,+1,r,l)?'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_'+e+".datepicker._adjustDate('#"+a.id+"', +"+k+", 'M');\" title=\""+v+'"><span class="ui-icon ui-icon-circle-triangle-'+(h?"w":"e")+'">'+v+"</span></a>":j?"":'<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+v+'"><span class="ui-icon ui-icon-circle-triangle-'+
|
314 |
+
(h?"w":"e")+'">'+v+"</span></a>";k=this._get(a,"currentText");v=this._get(a,"gotoCurrent")&&a.currentDay?o:d;k=!n?k:this.formatDate(k,v,this._getFormatConfig(a));n=!a.inline?'<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_'+e+'.datepicker._hideDatepicker();">'+this._get(a,"closeText")+"</button>":"";i=i?'<div class="ui-datepicker-buttonpane ui-widget-content">'+(h?n:"")+(this._isInRange(a,v)?'<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_'+
|
315 |
+
e+".datepicker._gotoToday('#"+a.id+"');\">"+k+"</button>":"")+(h?"":n)+"</div>":"";n=parseInt(this._get(a,"firstDay"),10);n=isNaN(n)?0:n;k=this._get(a,"showWeek");v=this._get(a,"dayNames");this._get(a,"dayNamesShort");var w=this._get(a,"dayNamesMin"),y=this._get(a,"monthNames"),B=this._get(a,"monthNamesShort"),x=this._get(a,"beforeShowDay"),C=this._get(a,"showOtherMonths"),J=this._get(a,"selectOtherMonths");this._get(a,"calculateWeek");for(var M=this._getDefaultDate(a),K="",G=0;G<q[0];G++){for(var N=
|
316 |
+
"",H=0;H<q[1];H++){var O=this._daylightSavingAdjust(new Date(r,l,a.selectedDay)),A=" ui-corner-all",D="";if(m){D+='<div class="ui-datepicker-group';if(q[1]>1)switch(H){case 0:D+=" ui-datepicker-group-first";A=" ui-corner-"+(h?"right":"left");break;case q[1]-1:D+=" ui-datepicker-group-last";A=" ui-corner-"+(h?"left":"right");break;default:D+=" ui-datepicker-group-middle";A="";break}D+='">'}D+='<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix'+A+'">'+(/all|left/.test(A)&&G==0?h?
|
317 |
+
j:u:"")+(/all|right/.test(A)&&G==0?h?u:j:"")+this._generateMonthYearHeader(a,l,r,p,s,G>0||H>0,y,B)+'</div><table class="ui-datepicker-calendar"><thead><tr>';var E=k?'<th class="ui-datepicker-week-col">'+this._get(a,"weekHeader")+"</th>":"";for(A=0;A<7;A++){var z=(A+n)%7;E+="<th"+((A+n+6)%7>=5?' class="ui-datepicker-week-end"':"")+'><span title="'+v[z]+'">'+w[z]+"</span></th>"}D+=E+"</tr></thead><tbody>";E=this._getDaysInMonth(r,l);if(r==a.selectedYear&&l==a.selectedMonth)a.selectedDay=Math.min(a.selectedDay,
|
318 |
+
E);A=(this._getFirstDayOfMonth(r,l)-n+7)%7;E=m?6:Math.ceil((A+E)/7);z=this._daylightSavingAdjust(new Date(r,l,1-A));for(var P=0;P<E;P++){D+="<tr>";var Q=!k?"":'<td class="ui-datepicker-week-col">'+this._get(a,"calculateWeek")(z)+"</td>";for(A=0;A<7;A++){var I=x?x.apply(a.input?a.input[0]:null,[z]):[true,""],F=z.getMonth()!=l,L=F&&!J||!I[0]||p&&z<p||s&&z>s;Q+='<td class="'+((A+n+6)%7>=5?" ui-datepicker-week-end":"")+(F?" ui-datepicker-other-month":"")+(z.getTime()==O.getTime()&&l==a.selectedMonth&&
|
319 |
+
a._keyEvent||M.getTime()==z.getTime()&&M.getTime()==O.getTime()?" "+this._dayOverClass:"")+(L?" "+this._unselectableClass+" ui-state-disabled":"")+(F&&!C?"":" "+I[1]+(z.getTime()==o.getTime()?" "+this._currentClass:"")+(z.getTime()==d.getTime()?" ui-datepicker-today":""))+'"'+((!F||C)&&I[2]?' title="'+I[2]+'"':"")+(L?"":' onclick="DP_jQuery_'+e+".datepicker._selectDay('#"+a.id+"',"+z.getMonth()+","+z.getFullYear()+', this);return false;"')+">"+(F&&!C?" ":L?'<span class="ui-state-default">'+z.getDate()+
|
320 |
+
"</span>":'<a class="ui-state-default'+(z.getTime()==d.getTime()?" ui-state-highlight":"")+(z.getTime()==o.getTime()?" ui-state-active":"")+(F?" ui-priority-secondary":"")+'" href="#">'+z.getDate()+"</a>")+"</td>";z.setDate(z.getDate()+1);z=this._daylightSavingAdjust(z)}D+=Q+"</tr>"}l++;if(l>11){l=0;r++}D+="</tbody></table>"+(m?"</div>"+(q[0]>0&&H==q[1]-1?'<div class="ui-datepicker-row-break"></div>':""):"");N+=D}K+=N}K+=i+(b.browser.msie&&parseInt(b.browser.version,10)<7&&!a.inline?'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>':
|
321 |
+
"");a._keyEvent=false;return K},_generateMonthYearHeader:function(a,d,h,i,j,n,q,l){var k=this._get(a,"changeMonth"),m=this._get(a,"changeYear"),o=this._get(a,"showMonthAfterYear"),p='<div class="ui-datepicker-title">',s="";if(n||!k)s+='<span class="ui-datepicker-month">'+q[d]+"</span>";else{q=i&&i.getFullYear()==h;var r=j&&j.getFullYear()==h;s+='<select class="ui-datepicker-month" onchange="DP_jQuery_'+e+".datepicker._selectMonthYear('#"+a.id+"', this, 'M');\" onclick=\"DP_jQuery_"+e+".datepicker._clickMonthYear('#"+
|
322 |
+
a.id+"');\">";for(var u=0;u<12;u++)if((!q||u>=i.getMonth())&&(!r||u<=j.getMonth()))s+='<option value="'+u+'"'+(u==d?' selected="selected"':"")+">"+l[u]+"</option>";s+="</select>"}o||(p+=s+(n||!(k&&m)?" ":""));if(n||!m)p+='<span class="ui-datepicker-year">'+h+"</span>";else{l=this._get(a,"yearRange").split(":");var v=(new Date).getFullYear();q=function(w){w=w.match(/c[+-].*/)?h+parseInt(w.substring(1),10):w.match(/[+-].*/)?v+parseInt(w,10):parseInt(w,10);return isNaN(w)?v:w};d=q(l[0]);l=Math.max(d,
|
323 |
+
q(l[1]||""));d=i?Math.max(d,i.getFullYear()):d;l=j?Math.min(l,j.getFullYear()):l;for(p+='<select class="ui-datepicker-year" onchange="DP_jQuery_'+e+".datepicker._selectMonthYear('#"+a.id+"', this, 'Y');\" onclick=\"DP_jQuery_"+e+".datepicker._clickMonthYear('#"+a.id+"');\">";d<=l;d++)p+='<option value="'+d+'"'+(d==h?' selected="selected"':"")+">"+d+"</option>";p+="</select>"}p+=this._get(a,"yearSuffix");if(o)p+=(n||!(k&&m)?" ":"")+s;p+="</div>";return p},_adjustInstDate:function(a,d,h){var i=
|
324 |
+
a.drawYear+(h=="Y"?d:0),j=a.drawMonth+(h=="M"?d:0);d=Math.min(a.selectedDay,this._getDaysInMonth(i,j))+(h=="D"?d:0);i=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(i,j,d)));a.selectedDay=i.getDate();a.drawMonth=a.selectedMonth=i.getMonth();a.drawYear=a.selectedYear=i.getFullYear();if(h=="M"||h=="Y")this._notifyChange(a)},_restrictMinMax:function(a,d){var h=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");d=h&&d<h?h:d;return d=a&&d>a?a:d},_notifyChange:function(a){var d=this._get(a,
|
325 |
+
"onChangeMonthYear");if(d)d.apply(a.input?a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])},_getNumberOfMonths:function(a){a=this._get(a,"numberOfMonths");return a==null?[1,1]:typeof a=="number"?[1,a]:a},_getMinMaxDate:function(a,d){return this._determineDate(a,this._get(a,d+"Date"),null)},_getDaysInMonth:function(a,d){return 32-(new Date(a,d,32)).getDate()},_getFirstDayOfMonth:function(a,d){return(new Date(a,d,1)).getDay()},_canAdjustMonth:function(a,d,h,i){var j=this._getNumberOfMonths(a);
|
326 |
+
h=this._daylightSavingAdjust(new Date(h,i+(d<0?d:j[0]*j[1]),1));d<0&&h.setDate(this._getDaysInMonth(h.getFullYear(),h.getMonth()));return this._isInRange(a,h)},_isInRange:function(a,d){var h=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");return(!h||d.getTime()>=h.getTime())&&(!a||d.getTime()<=a.getTime())},_getFormatConfig:function(a){var d=this._get(a,"shortYearCutoff");d=typeof d!="string"?d:(new Date).getFullYear()%100+parseInt(d,10);return{shortYearCutoff:d,dayNamesShort:this._get(a,
|
327 |
+
"dayNamesShort"),dayNames:this._get(a,"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,d,h,i){if(!d){a.currentDay=a.selectedDay;a.currentMonth=a.selectedMonth;a.currentYear=a.selectedYear}d=d?typeof d=="object"?d:this._daylightSavingAdjust(new Date(i,h,d)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),d,this._getFormatConfig(a))}});b.fn.datepicker=
|
328 |
+
function(a){if(!b.datepicker.initialized){b(document).mousedown(b.datepicker._checkExternalClick).find("body").append(b.datepicker.dpDiv);b.datepicker.initialized=true}var d=Array.prototype.slice.call(arguments,1);if(typeof a=="string"&&(a=="isDisabled"||a=="getDate"||a=="widget"))return b.datepicker["_"+a+"Datepicker"].apply(b.datepicker,[this[0]].concat(d));if(a=="option"&&arguments.length==2&&typeof arguments[1]=="string")return b.datepicker["_"+a+"Datepicker"].apply(b.datepicker,[this[0]].concat(d));
|
329 |
+
return this.each(function(){typeof a=="string"?b.datepicker["_"+a+"Datepicker"].apply(b.datepicker,[this].concat(d)):b.datepicker._attachDatepicker(this,a)})};b.datepicker=new f;b.datepicker.initialized=false;b.datepicker.uuid=(new Date).getTime();b.datepicker.version="1.8.6";window["DP_jQuery_"+e]=b})(jQuery);
|
330 |
+
(function(b,c){var f={buttons:true,height:true,maxHeight:true,maxWidth:true,minHeight:true,minWidth:true,width:true},g={maxHeight:true,maxWidth:true,minHeight:true,minWidth:true};b.widget("ui.dialog",{options:{autoOpen:true,buttons:{},closeOnEscape:true,closeText:"close",dialogClass:"",draggable:true,hide:null,height:"auto",maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false,position:{my:"center",at:"center",of:window,collision:"fit",using:function(e){var a=b(this).css(e).offset().top;
|
331 |
+
a<0&&b(this).css("top",e.top-a)}},resizable:true,show:null,stack:true,title:"",width:300,zIndex:1E3},_create:function(){this.originalTitle=this.element.attr("title");if(typeof this.originalTitle!=="string")this.originalTitle="";this.options.title=this.options.title||this.originalTitle;var e=this,a=e.options,d=a.title||" ",h=b.ui.dialog.getTitleId(e.element),i=(e.uiDialog=b("<div></div>")).appendTo(document.body).hide().addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+a.dialogClass).css({zIndex:a.zIndex}).attr("tabIndex",
|
332 |
+
-1).css("outline",0).keydown(function(q){if(a.closeOnEscape&&q.keyCode&&q.keyCode===b.ui.keyCode.ESCAPE){e.close(q);q.preventDefault()}}).attr({role:"dialog","aria-labelledby":h}).mousedown(function(q){e.moveToTop(false,q)});e.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(i);var j=(e.uiDialogTitlebar=b("<div></div>")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(i),n=b('<a href="#"></a>').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role",
|
333 |
+
"button").hover(function(){n.addClass("ui-state-hover")},function(){n.removeClass("ui-state-hover")}).focus(function(){n.addClass("ui-state-focus")}).blur(function(){n.removeClass("ui-state-focus")}).click(function(q){e.close(q);return false}).appendTo(j);(e.uiDialogTitlebarCloseText=b("<span></span>")).addClass("ui-icon ui-icon-closethick").text(a.closeText).appendTo(n);b("<span></span>").addClass("ui-dialog-title").attr("id",h).html(d).prependTo(j);if(b.isFunction(a.beforeclose)&&!b.isFunction(a.beforeClose))a.beforeClose=
|
334 |
+
a.beforeclose;j.find("*").add(j).disableSelection();a.draggable&&b.fn.draggable&&e._makeDraggable();a.resizable&&b.fn.resizable&&e._makeResizable();e._createButtons(a.buttons);e._isOpen=false;b.fn.bgiframe&&i.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){var e=this;e.overlay&&e.overlay.destroy();e.uiDialog.hide();e.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body");e.uiDialog.remove();e.originalTitle&&
|
335 |
+
e.element.attr("title",e.originalTitle);return e},widget:function(){return this.uiDialog},close:function(e){var a=this,d;if(false!==a._trigger("beforeClose",e)){a.overlay&&a.overlay.destroy();a.uiDialog.unbind("keypress.ui-dialog");a._isOpen=false;if(a.options.hide)a.uiDialog.hide(a.options.hide,function(){a._trigger("close",e)});else{a.uiDialog.hide();a._trigger("close",e)}b.ui.dialog.overlay.resize();if(a.options.modal){d=0;b(".ui-dialog").each(function(){if(this!==a.uiDialog[0])d=Math.max(d,b(this).css("z-index"))});
|
336 |
+
b.ui.dialog.maxZ=d}return a}},isOpen:function(){return this._isOpen},moveToTop:function(e,a){var d=this,h=d.options;if(h.modal&&!e||!h.stack&&!h.modal)return d._trigger("focus",a);if(h.zIndex>b.ui.dialog.maxZ)b.ui.dialog.maxZ=h.zIndex;if(d.overlay){b.ui.dialog.maxZ+=1;d.overlay.$el.css("z-index",b.ui.dialog.overlay.maxZ=b.ui.dialog.maxZ)}e={scrollTop:d.element.attr("scrollTop"),scrollLeft:d.element.attr("scrollLeft")};b.ui.dialog.maxZ+=1;d.uiDialog.css("z-index",b.ui.dialog.maxZ);d.element.attr(e);
|
337 |
+
d._trigger("focus",a);return d},open:function(){if(!this._isOpen){var e=this,a=e.options,d=e.uiDialog;e.overlay=a.modal?new b.ui.dialog.overlay(e):null;e._size();e._position(a.position);d.show(a.show);e.moveToTop(true);a.modal&&d.bind("keypress.ui-dialog",function(h){if(h.keyCode===b.ui.keyCode.TAB){var i=b(":tabbable",this),j=i.filter(":first");i=i.filter(":last");if(h.target===i[0]&&!h.shiftKey){j.focus(1);return false}else if(h.target===j[0]&&h.shiftKey){i.focus(1);return false}}});b(e.element.find(":tabbable").get().concat(d.find(".ui-dialog-buttonpane :tabbable").get().concat(d.get()))).eq(0).focus();
|
338 |
+
e._isOpen=true;e._trigger("open");return e}},_createButtons:function(e){var a=this,d=false,h=b("<div></div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),i=b("<div></div>").addClass("ui-dialog-buttonset").appendTo(h);a.uiDialog.find(".ui-dialog-buttonpane").remove();typeof e==="object"&&e!==null&&b.each(e,function(){return!(d=true)});if(d){b.each(e,function(j,n){n=b.isFunction(n)?{click:n,text:j}:n;j=b('<button type="button"></button>').attr(n,true).unbind("click").click(function(){n.click.apply(a.element[0],
|
339 |
+
arguments)}).appendTo(i);b.fn.button&&j.button()});h.appendTo(a.uiDialog)}},_makeDraggable:function(){function e(j){return{position:j.position,offset:j.offset}}var a=this,d=a.options,h=b(document),i;a.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",handle:".ui-dialog-titlebar",containment:"document",start:function(j,n){i=d.height==="auto"?"auto":b(this).height();b(this).height(b(this).height()).addClass("ui-dialog-dragging");a._trigger("dragStart",j,e(n))},drag:function(j,
|
340 |
+
n){a._trigger("drag",j,e(n))},stop:function(j,n){d.position=[n.position.left-h.scrollLeft(),n.position.top-h.scrollTop()];b(this).removeClass("ui-dialog-dragging").height(i);a._trigger("dragStop",j,e(n));b.ui.dialog.overlay.resize()}})},_makeResizable:function(e){function a(j){return{originalPosition:j.originalPosition,originalSize:j.originalSize,position:j.position,size:j.size}}e=e===c?this.options.resizable:e;var d=this,h=d.options,i=d.uiDialog.css("position");e=typeof e==="string"?e:"n,e,s,w,se,sw,ne,nw";
|
341 |
+
d.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:d.element,maxWidth:h.maxWidth,maxHeight:h.maxHeight,minWidth:h.minWidth,minHeight:d._minHeight(),handles:e,start:function(j,n){b(this).addClass("ui-dialog-resizing");d._trigger("resizeStart",j,a(n))},resize:function(j,n){d._trigger("resize",j,a(n))},stop:function(j,n){b(this).removeClass("ui-dialog-resizing");h.height=b(this).height();h.width=b(this).width();d._trigger("resizeStop",j,a(n));b.ui.dialog.overlay.resize()}}).css("position",
|
342 |
+
i).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var e=this.options;return e.height==="auto"?e.minHeight:Math.min(e.minHeight,e.height)},_position:function(e){var a=[],d=[0,0],h;if(e){if(typeof e==="string"||typeof e==="object"&&"0"in e){a=e.split?e.split(" "):[e[0],e[1]];if(a.length===1)a[1]=a[0];b.each(["left","top"],function(i,j){if(+a[i]===a[i]){d[i]=a[i];a[i]=j}});e={my:a.join(" "),at:a.join(" "),offset:d.join(" ")}}e=b.extend({},b.ui.dialog.prototype.options.position,
|
343 |
+
e)}else e=b.ui.dialog.prototype.options.position;(h=this.uiDialog.is(":visible"))||this.uiDialog.show();this.uiDialog.css({top:0,left:0}).position(e);h||this.uiDialog.hide()},_setOptions:function(e){var a=this,d={},h=false;b.each(e,function(i,j){a._setOption(i,j);if(i in f)h=true;if(i in g)d[i]=j});h&&this._size();this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",d)},_setOption:function(e,a){var d=this,h=d.uiDialog;switch(e){case "beforeclose":e="beforeClose";break;case "buttons":d._createButtons(a);
|
344 |
+
break;case "closeText":d.uiDialogTitlebarCloseText.text(""+a);break;case "dialogClass":h.removeClass(d.options.dialogClass).addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+a);break;case "disabled":a?h.addClass("ui-dialog-disabled"):h.removeClass("ui-dialog-disabled");break;case "draggable":var i=h.is(":data(draggable)");i&&!a&&h.draggable("destroy");!i&&a&&d._makeDraggable();break;case "position":d._position(a);break;case "resizable":(i=h.is(":data(resizable)"))&&!a&&h.resizable("destroy");
|
345 |
+
i&&typeof a==="string"&&h.resizable("option","handles",a);!i&&a!==false&&d._makeResizable(a);break;case "title":b(".ui-dialog-title",d.uiDialogTitlebar).html(""+(a||" "));break}b.Widget.prototype._setOption.apply(d,arguments)},_size:function(){var e=this.options,a,d;this.element.show().css({width:"auto",minHeight:0,height:0});if(e.minWidth>e.width)e.width=e.minWidth;a=this.uiDialog.css({height:"auto",width:e.width}).height();d=Math.max(0,e.minHeight-a);if(e.height==="auto")if(b.support.minHeight)this.element.css({minHeight:d,
|
346 |
+
height:"auto"});else{this.uiDialog.show();e=this.element.css("height","auto").height();this.uiDialog.hide();this.element.height(Math.max(e,d))}else this.element.height(Math.max(e.height-a,0));this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}});b.extend(b.ui.dialog,{version:"1.8.6",uuid:0,maxZ:0,getTitleId:function(e){e=e.attr("id");if(!e){this.uuid+=1;e=this.uuid}return"ui-dialog-title-"+e},overlay:function(e){this.$el=b.ui.dialog.overlay.create(e)}});
|
347 |
+
b.extend(b.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:b.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(e){return e+".dialog-overlay"}).join(" "),create:function(e){if(this.instances.length===0){setTimeout(function(){b.ui.dialog.overlay.instances.length&&b(document).bind(b.ui.dialog.overlay.events,function(d){if(b(d.target).zIndex()<b.ui.dialog.overlay.maxZ)return false})},1);b(document).bind("keydown.dialog-overlay",function(d){if(e.options.closeOnEscape&&
|
348 |
+
d.keyCode&&d.keyCode===b.ui.keyCode.ESCAPE){e.close(d);d.preventDefault()}});b(window).bind("resize.dialog-overlay",b.ui.dialog.overlay.resize)}var a=(this.oldInstances.pop()||b("<div></div>").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),height:this.height()});b.fn.bgiframe&&a.bgiframe();this.instances.push(a);return a},destroy:function(e){this.oldInstances.push(this.instances.splice(b.inArray(e,this.instances),1)[0]);this.instances.length===0&&b([document,window]).unbind(".dialog-overlay");
|
349 |
+
e.remove();var a=0;b.each(this.instances,function(){a=Math.max(a,this.css("z-index"))});this.maxZ=a},height:function(){var e,a;if(b.browser.msie&&b.browser.version<7){e=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);a=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);return e<a?b(window).height()+"px":e+"px"}else return b(document).height()+"px"},width:function(){var e,a;if(b.browser.msie&&b.browser.version<7){e=Math.max(document.documentElement.scrollWidth,
|
350 |
+
document.body.scrollWidth);a=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth);return e<a?b(window).width()+"px":e+"px"}else return b(document).width()+"px"},resize:function(){var e=b([]);b.each(b.ui.dialog.overlay.instances,function(){e=e.add(this)});e.css({width:0,height:0}).css({width:b.ui.dialog.overlay.width(),height:b.ui.dialog.overlay.height()})}});b.extend(b.ui.dialog.overlay.prototype,{destroy:function(){b.ui.dialog.overlay.destroy(this.$el)}})})(jQuery);
|
351 |
+
(function(b){b.ui=b.ui||{};var c=/left|center|right/,f=/top|center|bottom/,g=b.fn.position,e=b.fn.offset;b.fn.position=function(a){if(!a||!a.of)return g.apply(this,arguments);a=b.extend({},a);var d=b(a.of),h=d[0],i=(a.collision||"flip").split(" "),j=a.offset?a.offset.split(" "):[0,0],n,q,l;if(h.nodeType===9){n=d.width();q=d.height();l={top:0,left:0}}else if(h.setTimeout){n=d.width();q=d.height();l={top:d.scrollTop(),left:d.scrollLeft()}}else if(h.preventDefault){a.at="left top";n=q=0;l={top:a.of.pageY,
|
352 |
+
left:a.of.pageX}}else{n=d.outerWidth();q=d.outerHeight();l=d.offset()}b.each(["my","at"],function(){var k=(a[this]||"").split(" ");if(k.length===1)k=c.test(k[0])?k.concat(["center"]):f.test(k[0])?["center"].concat(k):["center","center"];k[0]=c.test(k[0])?k[0]:"center";k[1]=f.test(k[1])?k[1]:"center";a[this]=k});if(i.length===1)i[1]=i[0];j[0]=parseInt(j[0],10)||0;if(j.length===1)j[1]=j[0];j[1]=parseInt(j[1],10)||0;if(a.at[0]==="right")l.left+=n;else if(a.at[0]==="center")l.left+=n/2;if(a.at[1]==="bottom")l.top+=
|
353 |
+
q;else if(a.at[1]==="center")l.top+=q/2;l.left+=j[0];l.top+=j[1];return this.each(function(){var k=b(this),m=k.outerWidth(),o=k.outerHeight(),p=parseInt(b.curCSS(this,"marginLeft",true))||0,s=parseInt(b.curCSS(this,"marginTop",true))||0,r=m+p+parseInt(b.curCSS(this,"marginRight",true))||0,u=o+s+parseInt(b.curCSS(this,"marginBottom",true))||0,v=b.extend({},l),w;if(a.my[0]==="right")v.left-=m;else if(a.my[0]==="center")v.left-=m/2;if(a.my[1]==="bottom")v.top-=o;else if(a.my[1]==="center")v.top-=o/2;
|
354 |
+
v.left=parseInt(v.left);v.top=parseInt(v.top);w={left:v.left-p,top:v.top-s};b.each(["left","top"],function(y,B){b.ui.position[i[y]]&&b.ui.position[i[y]][B](v,{targetWidth:n,targetHeight:q,elemWidth:m,elemHeight:o,collisionPosition:w,collisionWidth:r,collisionHeight:u,offset:j,my:a.my,at:a.at})});b.fn.bgiframe&&k.bgiframe();k.offset(b.extend(v,{using:a.using}))})};b.ui.position={fit:{left:function(a,d){var h=b(window);h=d.collisionPosition.left+d.collisionWidth-h.width()-h.scrollLeft();a.left=h>0?
|
355 |
+
a.left-h:Math.max(a.left-d.collisionPosition.left,a.left)},top:function(a,d){var h=b(window);h=d.collisionPosition.top+d.collisionHeight-h.height()-h.scrollTop();a.top=h>0?a.top-h:Math.max(a.top-d.collisionPosition.top,a.top)}},flip:{left:function(a,d){if(d.at[0]!=="center"){var h=b(window);h=d.collisionPosition.left+d.collisionWidth-h.width()-h.scrollLeft();var i=d.my[0]==="left"?-d.elemWidth:d.my[0]==="right"?d.elemWidth:0,j=d.at[0]==="left"?d.targetWidth:-d.targetWidth,n=-2*d.offset[0];a.left+=
|
356 |
+
d.collisionPosition.left<0?i+j+n:h>0?i+j+n:0}},top:function(a,d){if(d.at[1]!=="center"){var h=b(window);h=d.collisionPosition.top+d.collisionHeight-h.height()-h.scrollTop();var i=d.my[1]==="top"?-d.elemHeight:d.my[1]==="bottom"?d.elemHeight:0,j=d.at[1]==="top"?d.targetHeight:-d.targetHeight,n=-2*d.offset[1];a.top+=d.collisionPosition.top<0?i+j+n:h>0?i+j+n:0}}}};if(!b.offset.setOffset){b.offset.setOffset=function(a,d){if(/static/.test(b.curCSS(a,"position")))a.style.position="relative";var h=b(a),
|
357 |
+
i=h.offset(),j=parseInt(b.curCSS(a,"top",true),10)||0,n=parseInt(b.curCSS(a,"left",true),10)||0;i={top:d.top-i.top+j,left:d.left-i.left+n};"using"in d?d.using.call(a,i):h.css(i)};b.fn.offset=function(a){var d=this[0];if(!d||!d.ownerDocument)return null;if(a)return this.each(function(){b.offset.setOffset(this,a)});return e.call(this)}}})(jQuery);
|
358 |
+
(function(b,c){b.widget("ui.progressbar",{options:{value:0},min:0,max:100,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.max,"aria-valuenow":this._value()});this.valueDiv=b("<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");
|
359 |
+
this.valueDiv.remove();b.Widget.prototype.destroy.apply(this,arguments)},value:function(f){if(f===c)return this._value();this._setOption("value",f);return this},_setOption:function(f,g){if(f==="value"){this.options.value=g;this._refreshValue();this._trigger("change");this._value()===this.max&&this._trigger("complete")}b.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var f=this.options.value;if(typeof f!=="number")f=0;return Math.min(this.max,Math.max(this.min,f))},_refreshValue:function(){var f=
|
360 |
+
this.value();this.valueDiv.toggleClass("ui-corner-right",f===this.max).width(f+"%");this.element.attr("aria-valuenow",f)}});b.extend(b.ui.progressbar,{version:"1.8.6"})})(jQuery);
|
361 |
+
(function(b){b.widget("ui.slider",b.ui.mouse,{widgetEventPrefix:"slide",options:{animate:false,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null},_create:function(){var c=this,f=this.options;this._mouseSliding=this._keySliding=false;this._animateOff=true;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+this.orientation+" ui-widget ui-widget-content ui-corner-all");f.disabled&&this.element.addClass("ui-slider-disabled ui-disabled");
|
362 |
+
this.range=b([]);if(f.range){if(f.range===true){this.range=b("<div></div>");if(!f.values)f.values=[this._valueMin(),this._valueMin()];if(f.values.length&&f.values.length!==2)f.values=[f.values[0],f.values[0]]}else this.range=b("<div></div>");this.range.appendTo(this.element).addClass("ui-slider-range");if(f.range==="min"||f.range==="max")this.range.addClass("ui-slider-range-"+f.range);this.range.addClass("ui-widget-header")}b(".ui-slider-handle",this.element).length===0&&b("<a href='#'></a>").appendTo(this.element).addClass("ui-slider-handle");
|
363 |
+
if(f.values&&f.values.length)for(;b(".ui-slider-handle",this.element).length<f.values.length;)b("<a href='#'></a>").appendTo(this.element).addClass("ui-slider-handle");this.handles=b(".ui-slider-handle",this.element).addClass("ui-state-default ui-corner-all");this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(g){g.preventDefault()}).hover(function(){f.disabled||b(this).addClass("ui-state-hover")},function(){b(this).removeClass("ui-state-hover")}).focus(function(){if(f.disabled)b(this).blur();
|
364 |
+
else{b(".ui-slider .ui-state-focus").removeClass("ui-state-focus");b(this).addClass("ui-state-focus")}}).blur(function(){b(this).removeClass("ui-state-focus")});this.handles.each(function(g){b(this).data("index.ui-slider-handle",g)});this.handles.keydown(function(g){var e=true,a=b(this).data("index.ui-slider-handle"),d,h,i;if(!c.options.disabled){switch(g.keyCode){case b.ui.keyCode.HOME:case b.ui.keyCode.END:case b.ui.keyCode.PAGE_UP:case b.ui.keyCode.PAGE_DOWN:case b.ui.keyCode.UP:case b.ui.keyCode.RIGHT:case b.ui.keyCode.DOWN:case b.ui.keyCode.LEFT:e=
|
365 |
+
false;if(!c._keySliding){c._keySliding=true;b(this).addClass("ui-state-active");d=c._start(g,a);if(d===false)return}break}i=c.options.step;d=c.options.values&&c.options.values.length?(h=c.values(a)):(h=c.value());switch(g.keyCode){case b.ui.keyCode.HOME:h=c._valueMin();break;case b.ui.keyCode.END:h=c._valueMax();break;case b.ui.keyCode.PAGE_UP:h=c._trimAlignValue(d+(c._valueMax()-c._valueMin())/5);break;case b.ui.keyCode.PAGE_DOWN:h=c._trimAlignValue(d-(c._valueMax()-c._valueMin())/5);break;case b.ui.keyCode.UP:case b.ui.keyCode.RIGHT:if(d===
|
366 |
+
c._valueMax())return;h=c._trimAlignValue(d+i);break;case b.ui.keyCode.DOWN:case b.ui.keyCode.LEFT:if(d===c._valueMin())return;h=c._trimAlignValue(d-i);break}c._slide(g,a,h);return e}}).keyup(function(g){var e=b(this).data("index.ui-slider-handle");if(c._keySliding){c._keySliding=false;c._stop(g,e);c._change(g,e);b(this).removeClass("ui-state-active")}});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");
|
367 |
+
this._mouseDestroy();return this},_mouseCapture:function(c){var f=this.options,g,e,a,d,h;if(f.disabled)return false;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();g=this._normValueFromMouse({x:c.pageX,y:c.pageY});e=this._valueMax()-this._valueMin()+1;d=this;this.handles.each(function(i){var j=Math.abs(g-d.values(i));if(e>j){e=j;a=b(this);h=i}});if(f.range===true&&this.values(1)===f.min){h+=1;a=b(this.handles[h])}if(this._start(c,
|
368 |
+
h)===false)return false;this._mouseSliding=true;d._handleIndex=h;a.addClass("ui-state-active").focus();f=a.offset();this._clickOffset=!b(c.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:c.pageX-f.left-a.width()/2,top:c.pageY-f.top-a.height()/2-(parseInt(a.css("borderTopWidth"),10)||0)-(parseInt(a.css("borderBottomWidth"),10)||0)+(parseInt(a.css("marginTop"),10)||0)};this._slide(c,h,g);return this._animateOff=true},_mouseStart:function(){return true},_mouseDrag:function(c){var f=
|
369 |
+
this._normValueFromMouse({x:c.pageX,y:c.pageY});this._slide(c,this._handleIndex,f);return false},_mouseStop:function(c){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(c,this._handleIndex);this._change(c,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=false},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(c){var f;if(this.orientation==="horizontal"){f=
|
370 |
+
this.elementSize.width;c=c.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{f=this.elementSize.height;c=c.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}f=c/f;if(f>1)f=1;if(f<0)f=0;if(this.orientation==="vertical")f=1-f;c=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+f*c)},_start:function(c,f){var g={handle:this.handles[f],value:this.value()};if(this.options.values&&this.options.values.length){g.value=this.values(f);
|
371 |
+
g.values=this.values()}return this._trigger("start",c,g)},_slide:function(c,f,g){var e;if(this.options.values&&this.options.values.length){e=this.values(f?0:1);if(this.options.values.length===2&&this.options.range===true&&(f===0&&g>e||f===1&&g<e))g=e;if(g!==this.values(f)){e=this.values();e[f]=g;c=this._trigger("slide",c,{handle:this.handles[f],value:g,values:e});this.values(f?0:1);c!==false&&this.values(f,g,true)}}else if(g!==this.value()){c=this._trigger("slide",c,{handle:this.handles[f],value:g});
|
372 |
+
c!==false&&this.value(g)}},_stop:function(c,f){var g={handle:this.handles[f],value:this.value()};if(this.options.values&&this.options.values.length){g.value=this.values(f);g.values=this.values()}this._trigger("stop",c,g)},_change:function(c,f){if(!this._keySliding&&!this._mouseSliding){var g={handle:this.handles[f],value:this.value()};if(this.options.values&&this.options.values.length){g.value=this.values(f);g.values=this.values()}this._trigger("change",c,g)}},value:function(c){if(arguments.length){this.options.value=
|
373 |
+
this._trimAlignValue(c);this._refreshValue();this._change(null,0)}return this._value()},values:function(c,f){var g,e,a;if(arguments.length>1){this.options.values[c]=this._trimAlignValue(f);this._refreshValue();this._change(null,c)}if(arguments.length)if(b.isArray(arguments[0])){g=this.options.values;e=arguments[0];for(a=0;a<g.length;a+=1){g[a]=this._trimAlignValue(e[a]);this._change(null,a)}this._refreshValue()}else return this.options.values&&this.options.values.length?this._values(c):this.value();
|
374 |
+
else return this._values()},_setOption:function(c,f){var g,e=0;if(b.isArray(this.options.values))e=this.options.values.length;b.Widget.prototype._setOption.apply(this,arguments);switch(c){case "disabled":if(f){this.handles.filter(".ui-state-focus").blur();this.handles.removeClass("ui-state-hover");this.handles.attr("disabled","disabled");this.element.addClass("ui-disabled")}else{this.handles.removeAttr("disabled");this.element.removeClass("ui-disabled")}break;case "orientation":this._detectOrientation();
|
375 |
+
this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue();break;case "value":this._animateOff=true;this._refreshValue();this._change(null,0);this._animateOff=false;break;case "values":this._animateOff=true;this._refreshValue();for(g=0;g<e;g+=1)this._change(null,g);this._animateOff=false;break}},_value:function(){var c=this.options.value;return c=this._trimAlignValue(c)},_values:function(c){var f,g;if(arguments.length){f=this.options.values[c];
|
376 |
+
return f=this._trimAlignValue(f)}else{f=this.options.values.slice();for(g=0;g<f.length;g+=1)f[g]=this._trimAlignValue(f[g]);return f}},_trimAlignValue:function(c){if(c<this._valueMin())return this._valueMin();if(c>this._valueMax())return this._valueMax();var f=this.options.step>0?this.options.step:1,g=c%f;c=c-g;if(Math.abs(g)*2>=f)c+=g>0?f:-f;return parseFloat(c.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var c=
|
377 |
+
this.options.range,f=this.options,g=this,e=!this._animateOff?f.animate:false,a,d={},h,i,j,n;if(this.options.values&&this.options.values.length)this.handles.each(function(q){a=(g.values(q)-g._valueMin())/(g._valueMax()-g._valueMin())*100;d[g.orientation==="horizontal"?"left":"bottom"]=a+"%";b(this).stop(1,1)[e?"animate":"css"](d,f.animate);if(g.options.range===true)if(g.orientation==="horizontal"){if(q===0)g.range.stop(1,1)[e?"animate":"css"]({left:a+"%"},f.animate);if(q===1)g.range[e?"animate":"css"]({width:a-
|
378 |
+
h+"%"},{queue:false,duration:f.animate})}else{if(q===0)g.range.stop(1,1)[e?"animate":"css"]({bottom:a+"%"},f.animate);if(q===1)g.range[e?"animate":"css"]({height:a-h+"%"},{queue:false,duration:f.animate})}h=a});else{i=this.value();j=this._valueMin();n=this._valueMax();a=n!==j?(i-j)/(n-j)*100:0;d[g.orientation==="horizontal"?"left":"bottom"]=a+"%";this.handle.stop(1,1)[e?"animate":"css"](d,f.animate);if(c==="min"&&this.orientation==="horizontal")this.range.stop(1,1)[e?"animate":"css"]({width:a+"%"},
|
379 |
+
f.animate);if(c==="max"&&this.orientation==="horizontal")this.range[e?"animate":"css"]({width:100-a+"%"},{queue:false,duration:f.animate});if(c==="min"&&this.orientation==="vertical")this.range.stop(1,1)[e?"animate":"css"]({height:a+"%"},f.animate);if(c==="max"&&this.orientation==="vertical")this.range[e?"animate":"css"]({height:100-a+"%"},{queue:false,duration:f.animate})}}});b.extend(b.ui.slider,{version:"1.8.6"})})(jQuery);
|
380 |
+
(function(b,c){function f(){return++e}function g(){return++a}var e=0,a=0;b.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:false,cookie:null,collapsible:false,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"<div></div>",remove:null,select:null,show:null,spinner:"<em>Loading…</em>",tabTemplate:"<li><a href='#{href}'><span>#{label}</span></a></li>"},_create:function(){this._tabify(true)},_setOption:function(d,h){if(d=="selected")this.options.collapsible&&
|
381 |
+
h==this.options.selected||this.select(h);else{this.options[d]=h;this._tabify()}},_tabId:function(d){return d.title&&d.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+f()},_sanitizeSelector:function(d){return d.replace(/:/g,"\\:")},_cookie:function(){var d=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+g());return b.cookie.apply(null,[d].concat(b.makeArray(arguments)))},_ui:function(d,h){return{tab:d,panel:h,index:this.anchors.index(d)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var d=
|
382 |
+
b(this);d.html(d.data("label.tabs")).removeData("label.tabs")})},_tabify:function(d){function h(r,u){r.css("display","");!b.support.opacity&&u.opacity&&r[0].style.removeAttribute("filter")}var i=this,j=this.options,n=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=b(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return b("a",this)[0]});this.panels=b([]);this.anchors.each(function(r,u){var v=b(u).attr("href"),w=v.split("#")[0],y;if(w&&(w===location.toString().split("#")[0]||
|
383 |
+
(y=b("base")[0])&&w===y.href)){v=u.hash;u.href=v}if(n.test(v))i.panels=i.panels.add(i._sanitizeSelector(v));else if(v&&v!=="#"){b.data(u,"href.tabs",v);b.data(u,"load.tabs",v.replace(/#.*$/,""));v=i._tabId(u);u.href="#"+v;u=b("#"+v);if(!u.length){u=b(j.panelTemplate).attr("id",v).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(i.panels[r-1]||i.list);u.data("destroy.tabs",true)}i.panels=i.panels.add(u)}else j.disabled.push(r)});if(d){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all");
|
384 |
+
this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(j.selected===c){location.hash&&this.anchors.each(function(r,u){if(u.hash==location.hash){j.selected=r;return false}});if(typeof j.selected!=="number"&&j.cookie)j.selected=parseInt(i._cookie(),10);if(typeof j.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length)j.selected=
|
385 |
+
this.lis.index(this.lis.filter(".ui-tabs-selected"));j.selected=j.selected||(this.lis.length?0:-1)}else if(j.selected===null)j.selected=-1;j.selected=j.selected>=0&&this.anchors[j.selected]||j.selected<0?j.selected:0;j.disabled=b.unique(j.disabled.concat(b.map(this.lis.filter(".ui-state-disabled"),function(r){return i.lis.index(r)}))).sort();b.inArray(j.selected,j.disabled)!=-1&&j.disabled.splice(b.inArray(j.selected,j.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active");
|
386 |
+
if(j.selected>=0&&this.anchors.length){b(i._sanitizeSelector(i.anchors[j.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(j.selected).addClass("ui-tabs-selected ui-state-active");i.element.queue("tabs",function(){i._trigger("show",null,i._ui(i.anchors[j.selected],b(i._sanitizeSelector(i.anchors[j.selected].hash))))});this.load(j.selected)}b(window).bind("unload",function(){i.lis.add(i.anchors).unbind(".tabs");i.lis=i.anchors=i.panels=null})}else j.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"));
|
387 |
+
this.element[j.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");j.cookie&&this._cookie(j.selected,j.cookie);d=0;for(var q;q=this.lis[d];d++)b(q)[b.inArray(d,j.disabled)!=-1&&!b(q).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");j.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(j.event!=="mouseover"){var l=function(r,u){u.is(":not(.ui-state-disabled)")&&u.addClass("ui-state-"+r)},k=function(r,u){u.removeClass("ui-state-"+
|
388 |
+
r)};this.lis.bind("mouseover.tabs",function(){l("hover",b(this))});this.lis.bind("mouseout.tabs",function(){k("hover",b(this))});this.anchors.bind("focus.tabs",function(){l("focus",b(this).closest("li"))});this.anchors.bind("blur.tabs",function(){k("focus",b(this).closest("li"))})}var m,o;if(j.fx)if(b.isArray(j.fx)){m=j.fx[0];o=j.fx[1]}else m=o=j.fx;var p=o?function(r,u){b(r).closest("li").addClass("ui-tabs-selected ui-state-active");u.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal",
|
389 |
+
function(){h(u,o);i._trigger("show",null,i._ui(r,u[0]))})}:function(r,u){b(r).closest("li").addClass("ui-tabs-selected ui-state-active");u.removeClass("ui-tabs-hide");i._trigger("show",null,i._ui(r,u[0]))},s=m?function(r,u){u.animate(m,m.duration||"normal",function(){i.lis.removeClass("ui-tabs-selected ui-state-active");u.addClass("ui-tabs-hide");h(u,m);i.element.dequeue("tabs")})}:function(r,u){i.lis.removeClass("ui-tabs-selected ui-state-active");u.addClass("ui-tabs-hide");i.element.dequeue("tabs")};
|
390 |
+
this.anchors.bind(j.event+".tabs",function(){var r=this,u=b(r).closest("li"),v=i.panels.filter(":not(.ui-tabs-hide)"),w=b(i._sanitizeSelector(r.hash));if(u.hasClass("ui-tabs-selected")&&!j.collapsible||u.hasClass("ui-state-disabled")||u.hasClass("ui-state-processing")||i.panels.filter(":animated").length||i._trigger("select",null,i._ui(this,w[0]))===false){this.blur();return false}j.selected=i.anchors.index(this);i.abort();if(j.collapsible)if(u.hasClass("ui-tabs-selected")){j.selected=-1;j.cookie&&
|
391 |
+
i._cookie(j.selected,j.cookie);i.element.queue("tabs",function(){s(r,v)}).dequeue("tabs");this.blur();return false}else if(!v.length){j.cookie&&i._cookie(j.selected,j.cookie);i.element.queue("tabs",function(){p(r,w)});i.load(i.anchors.index(this));this.blur();return false}j.cookie&&i._cookie(j.selected,j.cookie);if(w.length){v.length&&i.element.queue("tabs",function(){s(r,v)});i.element.queue("tabs",function(){p(r,w)});i.load(i.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier.";
|
392 |
+
b.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(d){if(typeof d=="string")d=this.anchors.index(this.anchors.filter("[href$="+d+"]"));return d},destroy:function(){var d=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var h=
|
393 |
+
b.data(this,"href.tabs");if(h)this.href=h;var i=b(this).unbind(".tabs");b.each(["href","load","cache"],function(j,n){i.removeData(n+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){b.data(this,"destroy.tabs")?b(this).remove():b(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});d.cookie&&this._cookie(null,d.cookie);return this},add:function(d,
|
394 |
+
h,i){if(i===c)i=this.anchors.length;var j=this,n=this.options;h=b(n.tabTemplate.replace(/#\{href\}/g,d).replace(/#\{label\}/g,h));d=!d.indexOf("#")?d.replace("#",""):this._tabId(b("a",h)[0]);h.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var q=b("#"+d);q.length||(q=b(n.panelTemplate).attr("id",d).data("destroy.tabs",true));q.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(i>=this.lis.length){h.appendTo(this.list);q.appendTo(this.list[0].parentNode)}else{h.insertBefore(this.lis[i]);
|
395 |
+
q.insertBefore(this.panels[i])}n.disabled=b.map(n.disabled,function(l){return l>=i?++l:l});this._tabify();if(this.anchors.length==1){n.selected=0;h.addClass("ui-tabs-selected ui-state-active");q.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){j._trigger("show",null,j._ui(j.anchors[0],j.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[i],this.panels[i]));return this},remove:function(d){d=this._getIndex(d);var h=this.options,i=this.lis.eq(d).remove(),j=this.panels.eq(d).remove();
|
396 |
+
if(i.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(d+(d+1<this.anchors.length?1:-1));h.disabled=b.map(b.grep(h.disabled,function(n){return n!=d}),function(n){return n>=d?--n:n});this._tabify();this._trigger("remove",null,this._ui(i.find("a")[0],j[0]));return this},enable:function(d){d=this._getIndex(d);var h=this.options;if(b.inArray(d,h.disabled)!=-1){this.lis.eq(d).removeClass("ui-state-disabled");h.disabled=b.grep(h.disabled,function(i){return i!=d});this._trigger("enable",null,
|
397 |
+
this._ui(this.anchors[d],this.panels[d]));return this}},disable:function(d){d=this._getIndex(d);var h=this.options;if(d!=h.selected){this.lis.eq(d).addClass("ui-state-disabled");h.disabled.push(d);h.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[d],this.panels[d]))}return this},select:function(d){d=this._getIndex(d);if(d==-1)if(this.options.collapsible&&this.options.selected!=-1)d=this.options.selected;else return this;this.anchors.eq(d).trigger(this.options.event+".tabs");return this},
|
398 |
+
load:function(d){d=this._getIndex(d);var h=this,i=this.options,j=this.anchors.eq(d)[0],n=b.data(j,"load.tabs");this.abort();if(!n||this.element.queue("tabs").length!==0&&b.data(j,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(d).addClass("ui-state-processing");if(i.spinner){var q=b("span",j);q.data("label.tabs",q.html()).html(i.spinner)}this.xhr=b.ajax(b.extend({},i.ajaxOptions,{url:n,success:function(l,k){b(h._sanitizeSelector(j.hash)).html(l);h._cleanup();i.cache&&b.data(j,"cache.tabs",
|
399 |
+
true);h._trigger("load",null,h._ui(h.anchors[d],h.panels[d]));try{i.ajaxOptions.success(l,k)}catch(m){}},error:function(l,k){h._cleanup();h._trigger("load",null,h._ui(h.anchors[d],h.panels[d]));try{i.ajaxOptions.error(l,k,d,j)}catch(m){}}}));h.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this},url:function(d,
|
400 |
+
h){this.anchors.eq(d).removeData("cache.tabs").data("load.tabs",h);return this},length:function(){return this.anchors.length}});b.extend(b.ui.tabs,{version:"1.8.6"});b.extend(b.ui.tabs.prototype,{rotation:null,rotate:function(d,h){var i=this,j=this.options,n=i._rotate||(i._rotate=function(q){clearTimeout(i.rotation);i.rotation=setTimeout(function(){var l=j.selected;i.select(++l<i.anchors.length?l:0)},d);q&&q.stopPropagation()});h=i._unrotate||(i._unrotate=!h?function(q){q.clientX&&i.rotate(null)}:
|
401 |
+
function(){t=j.selected;n()});if(d){this.element.bind("tabsshow",n);this.anchors.bind(j.event+".tabs",h);n()}else{clearTimeout(i.rotation);this.element.unbind("tabsshow",n);this.anchors.unbind(j.event+".tabs",h);delete this._rotate;delete this._unrotate}return this}})})(jQuery);
|
library/toolset/toolset-common/toolset-forms/js/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,"'")+"'")+(W?"":" data-handler='selectDay' data-event='click' data-month='"+H.getMonth()+"' data-year='"+H.getFullYear()+"'")+">"+(O&&!v?" ":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?"":" ")),!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?"":" ")+_),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(" "),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(" ")},_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> </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+"'>▲</span>"+"</a>"+"<a class='ui-spinner-button ui-spinner-down ui-corner-br'>"+"<span class='ui-icon "+this.options.icons.down+"'>▼</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()}})});
|
library/toolset/toolset-common/toolset-forms/js/jquery_upload/file_upload.js
CHANGED
@@ -56,12 +56,15 @@ jQuery(function () {
|
|
56 |
|
57 |
var myid = jQuery("input[name='_cred_cred_prefix_post_id']").val();
|
58 |
var myformid = jQuery("input[name='_cred_cred_prefix_form_id']").val();
|
|
|
59 |
|
60 |
jQuery(file).fileupload({
|
61 |
url: url + '?id=' + myid + '&formid=' + myformid + '&nonce=' + nonce,
|
62 |
dataType: 'json',
|
63 |
cache: false,
|
64 |
maxChunkSize: 0,
|
|
|
|
|
65 |
formData: {id: myid, formid: myformid},
|
66 |
//acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
|
67 |
done: function (e, data) {
|
@@ -117,28 +120,20 @@ jQuery(function () {
|
|
117 |
//add image/file uploaded and button to delete
|
118 |
if (isImage(file) && data.result.previews) {
|
119 |
var preview = data.result.previews[index];
|
|
|
120 |
jQuery("<img id='loaded_" + myid + "' src='" + preview + "'><input id='butt_" + myid + "' style='width:100%;margin-top:2px;margin-bottom:2px;' type='button' value='" + settings.delete_text + "' rel='" + preview + "' class='delete_ajax_file'>").insertAfter('#' + jQuery(curr_file).attr('id'));
|
|
|
121 |
} else {
|
122 |
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='" + settings.delete_text + "' rel='" + file + "' class='delete_ajax_file'>").insertAfter('#' + jQuery(curr_file).attr('id'));
|
123 |
}
|
124 |
|
125 |
-
// jQuery("#loaded_" + myid).each(function (i) {
|
126 |
-
// var max_size = settings.media_settings.width;
|
127 |
-
// if (jQuery(this).height() > jQuery(this).width()) {
|
128 |
-
// var h = max_size;
|
129 |
-
// var w = Math.ceil(jQuery(this).width() / jQuery(this).height() * max_size);
|
130 |
-
// } else {
|
131 |
-
// var w = max_size;
|
132 |
-
// var h = Math.ceil(jQuery(this).height() / jQuery(this).width() * max_size);
|
133 |
-
// }
|
134 |
-
// jQuery(this).css({height: h, width: w});
|
135 |
-
// });
|
136 |
-
|
137 |
//add function to delete button
|
138 |
-
jQuery("#butt_" + myid
|
|
|
139 |
if (confirm(settings.delete_confirm_text)) {
|
140 |
jQuery("#loaded_" + myid).remove();
|
141 |
jQuery("#butt_" + myid).remove();
|
|
|
142 |
|
143 |
jQuery('#' + id).show();
|
144 |
jQuery('#' + id).prop('disabled', false);
|
@@ -150,7 +145,7 @@ jQuery(function () {
|
|
150 |
url: url,
|
151 |
timeout: 10000,
|
152 |
type: 'POST',
|
153 |
-
data: {action: 'delete', file: file, nonce: nonce},
|
154 |
dataType: 'json',
|
155 |
success: function (data)
|
156 |
{
|
@@ -221,18 +216,24 @@ jQuery(function () {
|
|
221 |
}).prop('disabled', !jQuery.support.fileInput)
|
222 |
.parent().addClass(jQuery.support.fileInput ? undefined : 'disabled');
|
223 |
|
|
|
|
|
|
|
|
|
|
|
224 |
}
|
225 |
|
226 |
function credfile_fu_init() {
|
227 |
-
jQuery('input[type="file"]:visible
|
228 |
|
|
|
229 |
jQuery(document).on('click', '.js-wpt-credfile-delete, .js-wpt-credfile-undo', function (e) {
|
230 |
-
jQuery('input[type="file"]:visible
|
231 |
});
|
232 |
|
233 |
//AddRepetitive add event
|
234 |
wptCallbacks.addRepetitive.add(function () {
|
235 |
-
jQuery('input[type="file"]:visible
|
236 |
});
|
237 |
|
238 |
//AddRepetitive remove event
|
@@ -259,5 +260,11 @@ jQuery(function () {
|
|
259 |
// jQuery(this).css({height: h, width: w});
|
260 |
// });
|
261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
credfile_fu_init();
|
263 |
});
|
56 |
|
57 |
var myid = jQuery("input[name='_cred_cred_prefix_post_id']").val();
|
58 |
var myformid = jQuery("input[name='_cred_cred_prefix_form_id']").val();
|
59 |
+
var post_id = myid;
|
60 |
|
61 |
jQuery(file).fileupload({
|
62 |
url: url + '?id=' + myid + '&formid=' + myformid + '&nonce=' + nonce,
|
63 |
dataType: 'json',
|
64 |
cache: false,
|
65 |
maxChunkSize: 0,
|
66 |
+
drop: function (e, data) {return false},
|
67 |
+
dragover: function (e) {return false},
|
68 |
formData: {id: myid, formid: myformid},
|
69 |
//acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
|
70 |
done: function (e, data) {
|
120 |
//add image/file uploaded and button to delete
|
121 |
if (isImage(file) && data.result.previews) {
|
122 |
var preview = data.result.previews[index];
|
123 |
+
var attachid = data.result.attaches[index];
|
124 |
jQuery("<img id='loaded_" + myid + "' src='" + preview + "'><input id='butt_" + myid + "' style='width:100%;margin-top:2px;margin-bottom:2px;' type='button' value='" + settings.delete_text + "' rel='" + preview + "' class='delete_ajax_file'>").insertAfter('#' + jQuery(curr_file).attr('id'));
|
125 |
+
jQuery("<input type='hidden' id='attachid_" + myid + "' name='attachid_" + myid + "' value='" + attachid + "'>").insertAfter('#' + jQuery(curr_file).attr('id'));
|
126 |
} else {
|
127 |
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='" + settings.delete_text + "' rel='" + file + "' class='delete_ajax_file'>").insertAfter('#' + jQuery(curr_file).attr('id'));
|
128 |
}
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
//add function to delete button
|
131 |
+
jQuery(document).off('click', "#butt_" + myid, null);
|
132 |
+
jQuery(document).on('click', "#butt_" + myid, function () {
|
133 |
if (confirm(settings.delete_confirm_text)) {
|
134 |
jQuery("#loaded_" + myid).remove();
|
135 |
jQuery("#butt_" + myid).remove();
|
136 |
+
jQuery("#attachid_" + myid).remove();
|
137 |
|
138 |
jQuery('#' + id).show();
|
139 |
jQuery('#' + id).prop('disabled', false);
|
145 |
url: url,
|
146 |
timeout: 10000,
|
147 |
type: 'POST',
|
148 |
+
data: {action: 'delete', file: file, nonce: nonce, id: post_id},
|
149 |
dataType: 'json',
|
150 |
success: function (data)
|
151 |
{
|
216 |
}).prop('disabled', !jQuery.support.fileInput)
|
217 |
.parent().addClass(jQuery.support.fileInput ? undefined : 'disabled');
|
218 |
|
219 |
+
jQuery(document).bind('dragover', function (e) {
|
220 |
+
e.preventDefault();
|
221 |
+
e.stopPropagation();
|
222 |
+
return false;
|
223 |
+
});
|
224 |
}
|
225 |
|
226 |
function credfile_fu_init() {
|
227 |
+
jQuery('input[type="file"]:visible').each(o);
|
228 |
|
229 |
+
jQuery(document).off('click', '.js-wpt-credfile-delete, .js-wpt-credfile-undo', null);
|
230 |
jQuery(document).on('click', '.js-wpt-credfile-delete, .js-wpt-credfile-undo', function (e) {
|
231 |
+
jQuery('input[type="file"]:visible').each(o);
|
232 |
});
|
233 |
|
234 |
//AddRepetitive add event
|
235 |
wptCallbacks.addRepetitive.add(function () {
|
236 |
+
jQuery('input[type="file"]:visible').each(o);
|
237 |
});
|
238 |
|
239 |
//AddRepetitive remove event
|
260 |
// jQuery(this).css({height: h, width: w});
|
261 |
// });
|
262 |
|
263 |
+
//Fix the not visible field under false conditional
|
264 |
+
jQuery(document).off('click', 'input[type="file"]', null);
|
265 |
+
jQuery(document).on('click', 'input[type="file"]', function () {
|
266 |
+
credfile_fu_init();
|
267 |
+
});
|
268 |
+
|
269 |
credfile_fu_init();
|
270 |
});
|
library/toolset/toolset-common/toolset-forms/js/main.js
CHANGED
@@ -90,6 +90,11 @@ function showHideMostPopularButton(taxonomy, form)
|
|
90 |
}
|
91 |
}
|
92 |
|
|
|
|
|
|
|
|
|
|
|
93 |
jQuery(document).on('click', '.js-wpt-taxonomy-popular-show-hide', function () {
|
94 |
showHideMostPopularTaxonomy(this);
|
95 |
});
|
@@ -119,11 +124,11 @@ jQuery(document).on('click', '.js-wpt-taxonomy-popular-add', function () {
|
|
119 |
function setTaxonomyFromPopular(slug, taxonomy, el)
|
120 |
{
|
121 |
var form = jQuery(el).closest('form');
|
122 |
-
var tmp_tax = slug;
|
123 |
-
if (tmp_tax.trim() == '')
|
124 |
return;
|
125 |
var tax = jQuery('input[name=' + taxonomy + ']', form).val();
|
126 |
-
var arr = tax.split(',');
|
127 |
if (jQuery.inArray(tmp_tax, arr) !== -1)
|
128 |
return;
|
129 |
var toadd = (tax == '') ? tmp_tax : tax + ',' + tmp_tax;
|
@@ -171,6 +176,8 @@ function setTaxonomy(taxonomy, el)
|
|
171 |
{
|
172 |
var form = jQuery(el).closest('form');
|
173 |
var tmp_tax = jQuery('input[name=tmp_' + taxonomy + ']', form).val();
|
|
|
|
|
174 |
if (tmp_tax.trim() == '')
|
175 |
return;
|
176 |
var tax = jQuery('input[name=' + taxonomy + ']', form).val();
|
@@ -341,16 +348,6 @@ toolsetForms.CRED_taxonomy = function () {
|
|
341 |
});
|
342 |
}
|
343 |
|
344 |
-
jQuery(document).on('click', '.js-wpt-hierarchical-taxonomy-add-new-show-hide', function () {
|
345 |
-
if (jQuery(this).val() == jQuery(this).data('close')) {
|
346 |
-
jQuery(this).val(jQuery(this).data('open')).removeClass('btn-cancel');
|
347 |
-
} else {
|
348 |
-
jQuery(this).val(jQuery(this).data('close')).addClass('btn-cancel');
|
349 |
-
}
|
350 |
-
var thiz = jQuery(this), taxonomy = thiz.data('taxonomy');
|
351 |
-
self.add_new_show_hide(taxonomy, this);
|
352 |
-
});
|
353 |
-
|
354 |
//cred-286
|
355 |
// self.add_new_show_hide = function (taxonomy, button) {
|
356 |
// var form = jQuery(button).closest('form');
|
@@ -368,11 +365,22 @@ toolsetForms.CRED_taxonomy = function () {
|
|
368 |
self.hide_parent_button_if_no_terms(taxonomy, button);
|
369 |
}
|
370 |
|
371 |
-
jQuery(
|
372 |
var thiz = jQuery(this),
|
373 |
taxonomy = thiz.data('taxonomy');
|
374 |
self.add_taxonomy(taxonomy, this);
|
375 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
376 |
/*
|
377 |
jQuery(document).on('keypress', '.js-wpt-new-taxonomy-title', function(e) {
|
378 |
if( 13 === e.keyCode ) {
|
90 |
}
|
91 |
}
|
92 |
|
93 |
+
jQuery(document).off('click', '.js-wpt-taxonomy-popular-show-hide', null);
|
94 |
+
jQuery(document).off('click', '.js-wpt-taxonomy-popular-add', null);
|
95 |
+
jQuery(document).off('click', '.js-wpt-taxonomy-add-new', null);
|
96 |
+
jQuery(document).off('keypress', '.js-wpt-new-taxonomy-title', null);
|
97 |
+
|
98 |
jQuery(document).on('click', '.js-wpt-taxonomy-popular-show-hide', function () {
|
99 |
showHideMostPopularTaxonomy(this);
|
100 |
});
|
124 |
function setTaxonomyFromPopular(slug, taxonomy, el)
|
125 |
{
|
126 |
var form = jQuery(el).closest('form');
|
127 |
+
var tmp_tax = String(slug);
|
128 |
+
if (typeof tmp_tax === "undefined" || tmp_tax.trim() == '')
|
129 |
return;
|
130 |
var tax = jQuery('input[name=' + taxonomy + ']', form).val();
|
131 |
+
var arr = String(tax).split(',');
|
132 |
if (jQuery.inArray(tmp_tax, arr) !== -1)
|
133 |
return;
|
134 |
var toadd = (tax == '') ? tmp_tax : tax + ',' + tmp_tax;
|
176 |
{
|
177 |
var form = jQuery(el).closest('form');
|
178 |
var tmp_tax = jQuery('input[name=tmp_' + taxonomy + ']', form).val();
|
179 |
+
var rex = /<\/?(a|abbr|acronym|address|applet|area|article|aside|audio|b|base|basefont|bdi|bdo|bgsound|big|blink|blockquote|body|br|button|canvas|caption|center|cite|code|col|colgroup|data|datalist|dd|del|details|dfn|dir|div|dl|dt|em|embed|fieldset|figcaption|figure|font|footer|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|header|hgroup|hr|html|i|iframe|img|input|ins|isindex|kbd|keygen|label|legend|li|link|listing|main|map|mark|marquee|menu|menuitem|meta|meter|nav|nobr|noframes|noscript|object|ol|optgroup|option|output|p|param|plaintext|pre|progress|q|rp|rt|ruby|s|samp|script|section|select|small|source|spacer|span|strike|strong|style|sub|summary|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|track|tt|u|ul|var|video|wbr|xmp)\b[^<>]*>/ig;
|
180 |
+
tmp_tax = _.escape(tmp_tax.replace(rex, "")).trim();
|
181 |
if (tmp_tax.trim() == '')
|
182 |
return;
|
183 |
var tax = jQuery('input[name=' + taxonomy + ']', form).val();
|
348 |
});
|
349 |
}
|
350 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
//cred-286
|
352 |
// self.add_new_show_hide = function (taxonomy, button) {
|
353 |
// var form = jQuery(button).closest('form');
|
365 |
self.hide_parent_button_if_no_terms(taxonomy, button);
|
366 |
}
|
367 |
|
368 |
+
jQuery('.js-wpt-hierarchical-taxonomy-add-new').on('click', function () {
|
369 |
var thiz = jQuery(this),
|
370 |
taxonomy = thiz.data('taxonomy');
|
371 |
self.add_taxonomy(taxonomy, this);
|
372 |
});
|
373 |
+
|
374 |
+
jQuery('.js-wpt-hierarchical-taxonomy-add-new-show-hide').on('click', function () {
|
375 |
+
if (jQuery(this).val() == jQuery(this).data('close')) {
|
376 |
+
jQuery(this).val(jQuery(this).data('open')).removeClass('btn-cancel');
|
377 |
+
} else {
|
378 |
+
jQuery(this).val(jQuery(this).data('close')).addClass('btn-cancel');
|
379 |
+
}
|
380 |
+
var thiz = jQuery(this), taxonomy = thiz.data('taxonomy');
|
381 |
+
self.add_new_show_hide(taxonomy, this);
|
382 |
+
});
|
383 |
+
|
384 |
/*
|
385 |
jQuery(document).on('keypress', '.js-wpt-new-taxonomy-title', function(e) {
|
386 |
if( 13 === e.keyCode ) {
|
library/toolset/toolset-common/toolset-forms/js/repetitive.js
CHANGED
@@ -7,15 +7,16 @@ var wptRep = (function ($) {
|
|
7 |
var count = {};
|
8 |
function init() {
|
9 |
// Reorder label and description for repetitive
|
|
|
10 |
$('.js-wpt-repetitive').each(function () {
|
11 |
var $this = $(this),
|
12 |
$parent;
|
13 |
if ($('body').hasClass('wp-admin')) {
|
14 |
-
var title = $('label', $this).first().clone();
|
15 |
-
var description = $('.description', $this).first().clone();
|
16 |
$('.js-wpt-field-item', $this).each(function () {
|
17 |
-
$('label', $this).remove();
|
18 |
-
$('.description', $this).remove();
|
19 |
});
|
20 |
$this.prepend(description).prepend(title);
|
21 |
}
|
@@ -34,7 +35,8 @@ var wptRep = (function ($) {
|
|
34 |
}
|
35 |
});
|
36 |
// Add field
|
37 |
-
$('.js-wpt-repadd'
|
|
|
38 |
e.preventDefault();
|
39 |
var $this = $(this),
|
40 |
parent,
|
@@ -47,8 +49,9 @@ var wptRep = (function ($) {
|
|
47 |
// Get template from the footer templates by wpt-id data attribute
|
48 |
tpl = $('<div>' + $('#tpl-wpt-field-' + $this.data('wpt-id')).html() + '</div>');
|
49 |
// Remove label and descriptions from the template
|
50 |
-
|
51 |
-
$('.
|
|
|
52 |
// Adjust ids and labels where needed for the template content
|
53 |
$('[id]', tpl).each(function () {
|
54 |
var $this = $(this), uniqueId = _.uniqueId('wpt-form-el');
|
@@ -99,7 +102,9 @@ var wptRep = (function ($) {
|
|
99 |
return false;
|
100 |
});
|
101 |
// Delete field
|
102 |
-
$(
|
|
|
|
|
103 |
e.preventDefault();
|
104 |
$parent = $(this).closest('.js-wpt-field-items');
|
105 |
if ($('body').hasClass('wp-admin')) {
|
7 |
var count = {};
|
8 |
function init() {
|
9 |
// Reorder label and description for repetitive
|
10 |
+
// Note that we target usual labels and descriptions but a classname can be used to keep some auxiliar items
|
11 |
$('.js-wpt-repetitive').each(function () {
|
12 |
var $this = $(this),
|
13 |
$parent;
|
14 |
if ($('body').hasClass('wp-admin')) {
|
15 |
+
var title = $('label:not(.js-wpt-auxiliar-label)', $this).first().clone();
|
16 |
+
var description = $('.description:not(.js-wpt-auxiliar-description)', $this).first().clone();
|
17 |
$('.js-wpt-field-item', $this).each(function () {
|
18 |
+
$('label:not(.js-wpt-auxiliar-label)', $this).remove();
|
19 |
+
$('.description:not(.js-wpt-auxiliar-description)', $this).remove();
|
20 |
});
|
21 |
$this.prepend(description).prepend(title);
|
22 |
}
|
35 |
}
|
36 |
});
|
37 |
// Add field
|
38 |
+
$(document).off('click','.js-wpt-repadd', null);
|
39 |
+
$(document).on('click','.js-wpt-repadd', function (e) {
|
40 |
e.preventDefault();
|
41 |
var $this = $(this),
|
42 |
parent,
|
49 |
// Get template from the footer templates by wpt-id data attribute
|
50 |
tpl = $('<div>' + $('#tpl-wpt-field-' + $this.data('wpt-id')).html() + '</div>');
|
51 |
// Remove label and descriptions from the template
|
52 |
+
// Note that we target usual labels and descriptions but a classname can be used to keep some auxiliar items
|
53 |
+
$('label:not(.js-wpt-auxiliar-label)', tpl).first().remove();
|
54 |
+
$('.description:not(.js-wpt-auxiliar-description)', tpl).first().remove();
|
55 |
// Adjust ids and labels where needed for the template content
|
56 |
$('[id]', tpl).each(function () {
|
57 |
var $this = $(this), uniqueId = _.uniqueId('wpt-form-el');
|
102 |
return false;
|
103 |
});
|
104 |
// Delete field
|
105 |
+
$(document).off('click', '.js-wpt-repdelete', null);
|
106 |
+
$(document).on('click', '.js-wpt-repdelete', function (e) {
|
107 |
+
//$('.js-wpt-field-items').on('click', '.js-wpt-repdelete', function (e) {
|
108 |
e.preventDefault();
|
109 |
$parent = $(this).closest('.js-wpt-field-items');
|
110 |
if ($('body').hasClass('wp-admin')) {
|
library/toolset/toolset-common/toolset-forms/js/validation.js
CHANGED
@@ -19,7 +19,8 @@ var wptValidation = (function ($) {
|
|
19 |
*/
|
20 |
$.validator.addMethod("extension", function (value, element, param) {
|
21 |
param = typeof param === "string" ? param.replace(/,/g, "|") : param;
|
22 |
-
if ($(element).attr('res') && $(element).attr('res')!="")
|
|
|
23 |
return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
|
24 |
});
|
25 |
|
@@ -74,10 +75,10 @@ var wptValidation = (function ($) {
|
|
74 |
//Fixing YT cred-196
|
75 |
if (jQuery(element).hasClass("wpt-form-radio")) {
|
76 |
var $name = jQuery(element).attr("name");
|
77 |
-
var val = jQuery('input[name="'
|
78 |
return val && $.trim(val).length > 0;
|
79 |
}
|
80 |
-
|
81 |
//Fixing YT cred-104
|
82 |
element = jQuery(element).siblings('input[type="hidden"]');
|
83 |
if (element[0] &&
|
@@ -169,18 +170,127 @@ var wptValidation = (function ($) {
|
|
169 |
|
170 |
// On some pages the form may not be ready yet at this point (e.g. Edit Term page).
|
171 |
jQuery(document).ready(function () {
|
172 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
if ($form.valid()) {
|
|
|
|
|
174 |
$('.js-wpt-remove-on-submit', $(this)).remove();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
}
|
|
|
|
|
176 |
});
|
177 |
});
|
|
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
}
|
183 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
}
|
185 |
|
186 |
function isIgnored($el) {
|
@@ -237,4 +347,4 @@ jQuery(document).ready(function () {
|
|
237 |
wptCallbacks.conditionalCheck.add(function (container) {
|
238 |
wptValidation.applyRules(container);
|
239 |
});
|
240 |
-
});
|
19 |
*/
|
20 |
$.validator.addMethod("extension", function (value, element, param) {
|
21 |
param = typeof param === "string" ? param.replace(/,/g, "|") : param;
|
22 |
+
if ($(element).attr('res') && $(element).attr('res') != "")
|
23 |
+
return true;
|
24 |
return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
|
25 |
});
|
26 |
|
75 |
//Fixing YT cred-196
|
76 |
if (jQuery(element).hasClass("wpt-form-radio")) {
|
77 |
var $name = jQuery(element).attr("name");
|
78 |
+
var val = jQuery('input[name="' + $name + '"]:checked').val();
|
79 |
return val && $.trim(val).length > 0;
|
80 |
}
|
81 |
+
|
82 |
//Fixing YT cred-104
|
83 |
element = jQuery(element).siblings('input[type="hidden"]');
|
84 |
if (element[0] &&
|
170 |
|
171 |
// On some pages the form may not be ready yet at this point (e.g. Edit Term page).
|
172 |
jQuery(document).ready(function () {
|
173 |
+
//var formclone = $form.clone();
|
174 |
+
|
175 |
+
jQuery(document).off('submit', $form.selector, null);
|
176 |
+
jQuery(document).on('submit', $form.selector, function () {
|
177 |
+
|
178 |
+
var myformid = formID.replace('#', '');
|
179 |
+
myformid = myformid.replace('-', '_');
|
180 |
+
var cred_settings = eval('cred_settings_' + myformid);
|
181 |
+
|
182 |
+
if (typeof grecaptcha !== 'undefined') {
|
183 |
+
var $error_selector = jQuery(formID).find('div.recaptcha_error');
|
184 |
+
if (_recaptcha_id == -1) {
|
185 |
+
if (grecaptcha.getResponse() == '') {
|
186 |
+
$error_selector.show();
|
187 |
+
setTimeout(function () {
|
188 |
+
$error_selector.hide();
|
189 |
+
}, 5000);
|
190 |
+
return false;
|
191 |
+
}
|
192 |
+
} else {
|
193 |
+
if (grecaptcha.getResponse(_recaptcha_id) == '') {
|
194 |
+
$error_selector.show();
|
195 |
+
setTimeout(function () {
|
196 |
+
$error_selector.hide();
|
197 |
+
}, 5000);
|
198 |
+
return false;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
$error_selector.hide();
|
202 |
+
}
|
203 |
+
|
204 |
if ($form.valid()) {
|
205 |
+
//console.log("form valid 1");
|
206 |
+
|
207 |
$('.js-wpt-remove-on-submit', $(this)).remove();
|
208 |
+
|
209 |
+
if (cred_settings.use_ajax && cred_settings.use_ajax == 1) {
|
210 |
+
$('<input value="cred_ajax_form" name="action">').attr('type', 'hidden').appendTo(formID);
|
211 |
+
$('<input value="true" name="form_submit">').attr('type', 'hidden').appendTo(formID);
|
212 |
+
|
213 |
+
$body = $("body");
|
214 |
+
$body.addClass("wpt-loading");
|
215 |
+
|
216 |
+
$.ajax({
|
217 |
+
type: 'post',
|
218 |
+
url: $(formID).attr('action'),
|
219 |
+
data: $(formID).serialize(),
|
220 |
+
dataType: 'json',
|
221 |
+
complete: function (data) {
|
222 |
+
$body.removeClass("wpt-loading");
|
223 |
+
},
|
224 |
+
success: function (data) {
|
225 |
+
$body.removeClass("wpt-loading");
|
226 |
+
if (data) {
|
227 |
+
//console.log(data);
|
228 |
+
$(formID).replaceWith(data.output);
|
229 |
+
reload_tinyMCE(formID);
|
230 |
+
|
231 |
+
if (data.formtype == 'new') {
|
232 |
+
if (data.result == 'ok') {
|
233 |
+
// $(':input', formID)
|
234 |
+
// .not(':button, :submit, :reset, :hidden')
|
235 |
+
// .val('')
|
236 |
+
// .removeAttr('checked')
|
237 |
+
// .removeAttr('selected');
|
238 |
+
|
239 |
+
}
|
240 |
+
|
241 |
+
if (data.result != 'redirect') {
|
242 |
+
check_current_cred_post_id();
|
243 |
+
}
|
244 |
+
}
|
245 |
+
|
246 |
+
if (data.result == 'ok') {
|
247 |
+
alert(cred_settings.operation_ok);
|
248 |
+
} else {
|
249 |
+
if (data.result != 'redirect')
|
250 |
+
alert(cred_settings.operation_ko);
|
251 |
+
}
|
252 |
+
try_to_reload_reCAPTCHA(formID);
|
253 |
+
}
|
254 |
+
}
|
255 |
+
});
|
256 |
+
}
|
257 |
}
|
258 |
+
if (cred_settings.use_ajax && cred_settings.use_ajax == 1)
|
259 |
+
return false;
|
260 |
});
|
261 |
});
|
262 |
+
}
|
263 |
|
264 |
+
var _recaptcha_id = -1;
|
265 |
+
function try_to_reload_reCAPTCHA(formID) {
|
266 |
+
if (typeof grecaptcha !== 'undefined') {
|
267 |
+
var _sitekey = jQuery(formID).find('div.g-recaptcha').data('sitekey');
|
268 |
+
_recaptcha_id = grecaptcha.render($('.g-recaptcha')[0], {sitekey: _sitekey});
|
269 |
+
}
|
270 |
+
}
|
271 |
+
|
272 |
+
function reload_tinyMCE(formID) {
|
273 |
+
jQuery('.wpt-wysiwyg').each(function (index) {
|
274 |
+
var $area = jQuery(this),
|
275 |
+
area_id = $area.prop('id');
|
276 |
+
if (typeof area_id !== 'undefined') {
|
277 |
+
tinyMCE.remove();
|
278 |
+
tinyMCE.init(tinyMCEPreInit.mceInit[area_id]);
|
279 |
+
var quick = quicktags(tinyMCEPreInit.qtInit[area_id]);
|
280 |
+
Toolset.add_qt_editor_buttons(quick, area_id);
|
281 |
}
|
282 |
});
|
283 |
+
|
284 |
+
if (typeof tinyMCE !== 'undefined') {
|
285 |
+
var $area = jQuery('textarea[name="post_content"]'),
|
286 |
+
area_id = $area.prop('id');
|
287 |
+
if (typeof area_id !== 'undefined') {
|
288 |
+
tinyMCE.remove();
|
289 |
+
tinyMCE.init(tinyMCEPreInit.mceInit[area_id]);
|
290 |
+
var quick = quicktags(tinyMCEPreInit.qtInit[area_id]);
|
291 |
+
Toolset.add_qt_editor_buttons(quick, area_id);
|
292 |
+
}
|
293 |
+
}
|
294 |
}
|
295 |
|
296 |
function isIgnored($el) {
|
347 |
wptCallbacks.conditionalCheck.add(function (container) {
|
348 |
wptValidation.applyRules(container);
|
349 |
});
|
350 |
+
});
|
library/toolset/toolset-common/utility/dialogs/css/dd-dialogs-forms.css
CHANGED
@@ -74,12 +74,15 @@ ul.ddl-form { /* If .ddl-form class is added directly to <ul> element */
|
|
74 |
display: block;
|
75 |
float: left;
|
76 |
margin: 0 0px 0 0;
|
77 |
-
padding: 1px
|
78 |
width: 168px;
|
79 |
vertical-align: top;
|
80 |
font-weight: bold;
|
81 |
font-size: 13px;
|
|
|
82 |
}
|
|
|
|
|
83 |
|
84 |
.ddl-form input,
|
85 |
.ddl-form textarea, .ddl-form select {
|
@@ -192,6 +195,12 @@ ul.ddl-form { /* If .ddl-form class is added directly to <ul> element */
|
|
192 |
float: none;
|
193 |
}
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
/* Alternative vertical layout. .ddl-form-item-fullwidth should be added to: .ddl-form-item, <li> or <p> tag */
|
196 |
.ddl-form .ddl-form-item-fullwidth label,
|
197 |
.ddl-form .ddl-form-item-fullwidth legend,
|
@@ -476,5 +485,33 @@ a.ddl-duplicate-anchor{cursor:pointer;}
|
|
476 |
.ddl-setting-for-layouts-container-in-iframe .css-styling-controls{padding-top:0px;margin-top:0px;}
|
477 |
.ddl-setting-for-layouts-container-in-iframe span.desc{padding-bottom:6px;padding-top:0px;width:555px!important;}
|
478 |
input.css-id-control{width:555px!important;}
|
|
|
479 |
/*///////// OVERRIDES /////////////////*/
|
480 |
-
.ui-dialog-buttonpane{padding: 8px;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
display: block;
|
75 |
float: left;
|
76 |
margin: 0 0px 0 0;
|
77 |
+
padding: 1px 4px 1px 0px;
|
78 |
width: 168px;
|
79 |
vertical-align: top;
|
80 |
font-weight: bold;
|
81 |
font-size: 13px;
|
82 |
+
text-align:right;
|
83 |
}
|
84 |
+
.ddl-form .cred-popup-box label, .ddl-form .cred-popup-box legend{text-align: left;}
|
85 |
+
|
86 |
|
87 |
.ddl-form input,
|
88 |
.ddl-form textarea, .ddl-form select {
|
195 |
float: none;
|
196 |
}
|
197 |
|
198 |
+
.ddl-form .radio, /* radios and checkboxes should be wrapped in .radio or .checkbox element */
|
199 |
+
.ddl-form .checkbox,.ddl-form .fields-group .radio,
|
200 |
+
.ddl-form .fields-group .checkbox{
|
201 |
+
float:left;
|
202 |
+
}
|
203 |
+
|
204 |
/* Alternative vertical layout. .ddl-form-item-fullwidth should be added to: .ddl-form-item, <li> or <p> tag */
|
205 |
.ddl-form .ddl-form-item-fullwidth label,
|
206 |
.ddl-form .ddl-form-item-fullwidth legend,
|
485 |
.ddl-setting-for-layouts-container-in-iframe .css-styling-controls{padding-top:0px;margin-top:0px;}
|
486 |
.ddl-setting-for-layouts-container-in-iframe span.desc{padding-bottom:6px;padding-top:0px;width:555px!important;}
|
487 |
input.css-id-control{width:555px!important;}
|
488 |
+
.toolset-shortcode-gui-dialog-container{min-height:92px!important;max-height:370px!important;}
|
489 |
/*///////// OVERRIDES /////////////////*/
|
490 |
+
.ui-dialog-buttonpane{padding: 8px;}
|
491 |
+
|
492 |
+
.ddl-youtube-video-cell span.px_box {
|
493 |
+
display: block;
|
494 |
+
margin-top: 4px;
|
495 |
+
float: right;
|
496 |
+
clear: right;
|
497 |
+
width: auto;
|
498 |
+
text-align: left;
|
499 |
+
}
|
500 |
+
.ddl-youtube-video-cell .ddl-layout-video-input{
|
501 |
+
display: block;
|
502 |
+
float: left !important;
|
503 |
+
clear: right;
|
504 |
+
width: 515px !important;
|
505 |
+
color: #474747;
|
506 |
+
}
|
507 |
+
|
508 |
+
.ddl-youtube-video-cell .desc {
|
509 |
+
margin: 5px 0 0 0;
|
510 |
+
color: #999;
|
511 |
+
width: 545px !important;
|
512 |
+
font-size: 10px;
|
513 |
+
text-align: left;
|
514 |
+
}
|
515 |
+
.ddl-youtube-video-cell label{
|
516 |
+
width: 211px !important;
|
517 |
+
}
|
library/toolset/toolset-common/utility/dialogs/css/dd-dialogs-general.css
CHANGED
@@ -41,6 +41,16 @@
|
|
41 |
position:relative;
|
42 |
}
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
.ddl-dialog-content {
|
45 |
overflow-y: auto;
|
46 |
padding-right: 10px;
|
@@ -124,7 +134,7 @@
|
|
124 |
.ddl-dialog-content::-webkit-scrollbar-thumb:hover {
|
125 |
background-color: rgba(0, 0, 0, .2);
|
126 |
}
|
127 |
-
.ddl-dialog-content
|
128 |
background-color: rgba(0, 0, 0, .3);
|
129 |
}
|
130 |
|
@@ -167,7 +177,6 @@
|
|
167 |
}
|
168 |
|
169 |
.ddl-popup-tab {
|
170 |
-
border-left: 1px solid #ddd;
|
171 |
padding: 0px 0 0 10px;
|
172 |
}
|
173 |
|
@@ -215,17 +224,19 @@
|
|
215 |
top: 10px;
|
216 |
right: 10px;
|
217 |
cursor: pointer;
|
|
|
218 |
}
|
219 |
|
220 |
.ddl-dialog-header .icon-remove:hover {
|
221 |
-
color: #
|
222 |
}
|
223 |
|
224 |
.ddl-dialog-header h2 {
|
225 |
margin: 0;
|
226 |
padding: 0 20px 0 0;
|
227 |
font-weight: normal;
|
228 |
-
font-size:
|
|
|
229 |
}
|
230 |
|
231 |
.ddl-dialog-footer {
|
@@ -271,7 +282,7 @@ label.set-parent-layout-select{
|
|
271 |
since it completely changes the rules for the editor sidebar
|
272 |
*/
|
273 |
ul.post-types-list-in-layout-editor{padding: 0px 0px 10px 10px;}
|
274 |
-
.close-change-use{float:
|
275 |
.create-layout-form-dialog .change-layout-use-section{margin-left:15px;}
|
276 |
.assign-checkboxes-elements-wrap{display:block;clear:both;}
|
277 |
.assign-checkboxes-elements-wrap label{float:left;display:inline-block;clear:right;font-size: 13px;}
|
@@ -297,4 +308,5 @@ label.post-types-apply-to-all-selection-label input[type="checkbox"]{margin-left
|
|
297 |
}
|
298 |
|
299 |
/* GENERAL OVERRIDES FOR TOOLSET ELEMENTS DIALOGS */
|
300 |
-
.ddl-dialog-footer button.ddl-toolset-cell-button{margin-left:3px;}
|
|
41 |
position:relative;
|
42 |
}
|
43 |
|
44 |
+
.ddl-dialog-header{
|
45 |
+
padding-top: 9px;
|
46 |
+
padding-bottom: 9px;
|
47 |
+
}
|
48 |
+
|
49 |
+
.ddl-dialog-footer{
|
50 |
+
padding-top: 8px;
|
51 |
+
padding-bottom: 7px;
|
52 |
+
}
|
53 |
+
|
54 |
.ddl-dialog-content {
|
55 |
overflow-y: auto;
|
56 |
padding-right: 10px;
|
134 |
.ddl-dialog-content::-webkit-scrollbar-thumb:hover {
|
135 |
background-color: rgba(0, 0, 0, .2);
|
136 |
}
|
137 |
+
.ddl-dialog-content::-webkit-scrollbar-thumb:active {
|
138 |
background-color: rgba(0, 0, 0, .3);
|
139 |
}
|
140 |
|
177 |
}
|
178 |
|
179 |
.ddl-popup-tab {
|
|
|
180 |
padding: 0px 0 0 10px;
|
181 |
}
|
182 |
|
224 |
top: 10px;
|
225 |
right: 10px;
|
226 |
cursor: pointer;
|
227 |
+
font-size:14px;
|
228 |
}
|
229 |
|
230 |
.ddl-dialog-header .icon-remove:hover {
|
231 |
+
color: #00a0d2;
|
232 |
}
|
233 |
|
234 |
.ddl-dialog-header h2 {
|
235 |
margin: 0;
|
236 |
padding: 0 20px 0 0;
|
237 |
font-weight: normal;
|
238 |
+
font-size: 18px;
|
239 |
+
font-weight: 600;
|
240 |
}
|
241 |
|
242 |
.ddl-dialog-footer {
|
282 |
since it completely changes the rules for the editor sidebar
|
283 |
*/
|
284 |
ul.post-types-list-in-layout-editor{padding: 0px 0px 10px 10px;}
|
285 |
+
.close-change-use{float:left;}
|
286 |
.create-layout-form-dialog .change-layout-use-section{margin-left:15px;}
|
287 |
.assign-checkboxes-elements-wrap{display:block;clear:both;}
|
288 |
.assign-checkboxes-elements-wrap label{float:left;display:inline-block;clear:right;font-size: 13px;}
|
308 |
}
|
309 |
|
310 |
/* GENERAL OVERRIDES FOR TOOLSET ELEMENTS DIALOGS */
|
311 |
+
.ddl-dialog-footer button.ddl-toolset-cell-button{margin-left:3px;}
|
312 |
+
p.cleared{clear:both!important;padding-top:4px!important;}
|
library/toolset/toolset-common/utility/dialogs/css/dd-dialogs.css
CHANGED
@@ -221,8 +221,8 @@
|
|
221 |
|
222 |
.ddl-dialog .wpv-ct-inline-edit .quicktags-toolbar {
|
223 |
border: 1px solid #ccc;
|
224 |
-
|
225 |
-
|
226 |
}
|
227 |
|
228 |
.ddl-form .code-editor-toolbar>ul>li {
|
@@ -469,7 +469,7 @@ div.alert-no-loops p, div.alert-no-post-content p{}
|
|
469 |
div.alert-no-loops i.remove-alert-message, div.alert-no-post-content i.remove-alert-message{position:absolute;top:2px;right:4px;color:#999;cursor:pointer;}
|
470 |
div.alert-no-loops i.remove-alert-message:hover, div.alert-no-post-content i.remove-alert-message:hover{color:#999;}
|
471 |
div.alert-no-loops, div.alert-no-post-content{line-height: 1.2;position:relative;}
|
472 |
-
.
|
473 |
.save-archives-options-wrap{text-align: right;}
|
474 |
ul.post-types-list-in-layout-editor-alerted, ul.post-loops-list-in-layout-editor-alerted{border:1px solid;border-color: #fbeed5;background-color: #fcf8e3;}
|
475 |
|
@@ -484,12 +484,12 @@ div.dialog-change-use-messages p .toolset-alert-close{top:6px;}
|
|
484 |
.ddl-dialog .ui-widget-header{border:none;background:transparent;border-bottom:1px solid #ccc;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;}
|
485 |
.ddl-dialog .ddl-dialog-content-main{border:none;background: transparent;padding-left:0px !important;padding-right:0px !important;}
|
486 |
.ddl-dialog .ui-tabs-nav li.ddl-tab-right {margin-right:0px;}
|
487 |
-
.ddl-dialog .ddl-dialog-content-main .ddl-form{
|
488 |
p.desc a.fieldset-inputs{color:#0074a2;}
|
489 |
|
490 |
.individual-pages-wrap .ui-widget-content{background:transparent;border:none;}
|
491 |
.individual-pages-wrap .ui-widget-header{border:none;background:transparent;margin-bottom: 14px;padding-bottom: 0px;}
|
492 |
-
.individual-pages-wrap .ddl-individual-tab{border:none;border:1px solid #ccc;position: relative;top: -3px; background: white;border-radius: 3px;border-top-left-radius: 0px;}
|
493 |
.individual-pages-wrap .ui-tabs-nav li{padding-bottom:8px;}
|
494 |
.ddl-individual-tab div.ajax-loader{ bottom: 6px;position: relative;left: 45%;}
|
495 |
|
@@ -530,8 +530,11 @@ p.desc a.fieldset-inputs{color:#0074a2;}
|
|
530 |
|
531 |
.ddl-individual-quick-search {
|
532 |
margin-bottom: 5px;
|
|
|
533 |
}
|
534 |
|
|
|
|
|
535 |
/* RICH CONTENT CELL VISUAL EDITOR */
|
536 |
|
537 |
/* Comments cell preview */
|
@@ -819,45 +822,45 @@ ul.grid {
|
|
819 |
.class-views-content-grid-cell .item-insert,
|
820 |
.class-ddl-container .item-insert,
|
821 |
.class-cred-cell .item-insert {
|
822 |
-
|
823 |
}
|
824 |
.class-post-loop-views-cell .item-insert,
|
825 |
.class-child-layout .item-insert,
|
826 |
.class-cell-content-template .item-insert,
|
827 |
.class-post-loop-views-cell .item-insert {
|
828 |
-
|
829 |
}
|
830 |
|
831 |
.class-comments-cell .item-insert {
|
832 |
-
|
833 |
}
|
834 |
|
835 |
.class-text-cell .item-insert {
|
836 |
-
|
837 |
}
|
838 |
|
839 |
.class-menu-cell .item-insert {
|
840 |
-
|
841 |
}
|
842 |
|
843 |
.item-body .item-insert .dashicons,
|
844 |
.item-description .item-insert .dashicons{
|
845 |
-
|
846 |
-
|
847 |
}
|
848 |
.item-body .item-insert:hover,
|
849 |
.item-body .item-insert:focus,
|
850 |
.item-description .item-insert:hover,
|
851 |
.item-description .item-insert:focus {
|
852 |
-
|
853 |
}
|
854 |
|
855 |
.item-description-no-preview {
|
856 |
-
|
857 |
}
|
858 |
|
859 |
.item-description-no-preview p {
|
860 |
-
|
861 |
}
|
862 |
|
863 |
.grid .item-header h4,
|
@@ -891,7 +894,7 @@ ul.grid {
|
|
891 |
}
|
892 |
.item-header .item-close:hover,
|
893 |
.item-header .item-close:focus {
|
894 |
-
|
895 |
}
|
896 |
.preview .grid-category-item:not(.active) {
|
897 |
opacity: .6;
|
@@ -926,7 +929,7 @@ ul.grid {
|
|
926 |
}
|
927 |
.item-name-subtitle{font-size:10px!important;font-family:Verdana, Geneva, sans-serif;}
|
928 |
|
929 |
-
#wrapper-element-box-type .ddl-dialog-content{height:auto
|
930 |
|
931 |
a.ddl-show-item-desc, a.ddl-show-item-desc{
|
932 |
float:left;
|
@@ -962,7 +965,7 @@ a.ddl-show-item-desc, a.ddl-show-item-desc{
|
|
962 |
.ddl-move-box-down{top:8px;max-height:165px;}
|
963 |
|
964 |
.ddl-max-height-150, a.ddl-max-height-150, .ddl-max-height-150:hover{
|
965 |
-
|
966 |
}
|
967 |
.move-name-up{}
|
968 |
/* PREVIEW DIALOG IMAGE */
|
@@ -971,12 +974,12 @@ a.ddl-show-item-desc, a.ddl-show-item-desc{
|
|
971 |
/* CELL PREVIEWS */
|
972 |
|
973 |
.ddl-post-content-current-page-preview {
|
974 |
-
|
975 |
}
|
976 |
|
977 |
.ddl-post-content-current-page-preview > img {
|
978 |
-
|
979 |
-
|
980 |
}
|
981 |
|
982 |
/* Content template */
|
@@ -985,18 +988,18 @@ a.ddl-show-item-desc, a.ddl-show-item-desc{
|
|
985 |
}
|
986 |
|
987 |
.ddl-post-content-template-preview > img {
|
988 |
-
|
989 |
-
|
990 |
}
|
991 |
|
992 |
/* Views grid */
|
993 |
.ddl-views-grid-preview {
|
994 |
-
|
995 |
}
|
996 |
|
997 |
.ddl-views-grid-preview > img {
|
998 |
-
|
999 |
-
|
1000 |
}
|
1001 |
|
1002 |
/*Menu*/
|
@@ -1005,8 +1008,8 @@ a.ddl-show-item-desc, a.ddl-show-item-desc{
|
|
1005 |
}
|
1006 |
|
1007 |
.ddl-menu-preview > img {
|
1008 |
-
|
1009 |
-
|
1010 |
}
|
1011 |
|
1012 |
/*Slider*/
|
@@ -1015,8 +1018,8 @@ a.ddl-show-item-desc, a.ddl-show-item-desc{
|
|
1015 |
}
|
1016 |
|
1017 |
.ddl-slider-preview > img {
|
1018 |
-
|
1019 |
-
|
1020 |
}
|
1021 |
|
1022 |
/*Video*/
|
@@ -1025,7 +1028,7 @@ a.ddl-show-item-desc, a.ddl-show-item-desc{
|
|
1025 |
}
|
1026 |
|
1027 |
.ddl-video-preview > img {
|
1028 |
-
|
1029 |
}
|
1030 |
|
1031 |
/*Image box*/
|
@@ -1034,8 +1037,8 @@ a.ddl-show-item-desc, a.ddl-show-item-desc{
|
|
1034 |
}
|
1035 |
|
1036 |
.ddl-image-box-preview > img {
|
1037 |
-
|
1038 |
-
|
1039 |
}
|
1040 |
.ddl-image-box-preview-image{
|
1041 |
text-align: center;
|
@@ -1057,8 +1060,8 @@ a.ddl-show-item-desc, a.ddl-show-item-desc{
|
|
1057 |
}
|
1058 |
|
1059 |
.ddl-widget-preview > img {
|
1060 |
-
|
1061 |
-
|
1062 |
}
|
1063 |
|
1064 |
/*Widget*/
|
@@ -1067,8 +1070,8 @@ a.ddl-show-item-desc, a.ddl-show-item-desc{
|
|
1067 |
}
|
1068 |
|
1069 |
.ddl-widget-area-preview > img {
|
1070 |
-
|
1071 |
-
|
1072 |
}
|
1073 |
|
1074 |
/*Child Layout*/
|
@@ -1077,8 +1080,8 @@ a.ddl-show-item-desc, a.ddl-show-item-desc{
|
|
1077 |
}
|
1078 |
|
1079 |
.ddl-child-layout-preview > img {
|
1080 |
-
|
1081 |
-
|
1082 |
}
|
1083 |
|
1084 |
/*Comment*/
|
@@ -1087,7 +1090,7 @@ a.ddl-show-item-desc, a.ddl-show-item-desc{
|
|
1087 |
}
|
1088 |
|
1089 |
.ddl-comments-preview > img {
|
1090 |
-
|
1091 |
}
|
1092 |
|
1093 |
/*CRED form*/
|
@@ -1096,7 +1099,7 @@ a.ddl-show-item-desc, a.ddl-show-item-desc{
|
|
1096 |
}
|
1097 |
|
1098 |
.ddl-cred-preview > img {
|
1099 |
-
|
1100 |
}
|
1101 |
|
1102 |
/*post loop*/
|
@@ -1105,15 +1108,15 @@ a.ddl-show-item-desc, a.ddl-show-item-desc{
|
|
1105 |
}
|
1106 |
|
1107 |
.ddl-post-loop-preview > img {
|
1108 |
-
|
1109 |
}
|
1110 |
|
1111 |
.cell-preview p:first-child {
|
1112 |
-
|
1113 |
}
|
1114 |
|
1115 |
.ddl-parametric-search-preview {
|
1116 |
-
|
1117 |
}
|
1118 |
|
1119 |
/* FOOTER MESSAGE */
|
@@ -1159,61 +1162,61 @@ li.grid-category{}
|
|
1159 |
/* FORMATTING INSTUCTIONS SHORTCODES */
|
1160 |
|
1161 |
.ddl-form .wpv-editor-instructions-toggle {
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
}
|
1180 |
.ddl-form .wpv-toggle-toggler-icon {
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
}
|
1188 |
.ddl-form .wpv-editor-instructions {
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
}
|
1196 |
|
1197 |
-
.wpv-editor-instructions dl dt {
|
1198 |
-
|
1199 |
-
|
1200 |
}
|
1201 |
.ddl-form .wpv-editor-instructions .widefat {
|
1202 |
-
|
1203 |
}
|
1204 |
.ddl-form .wpv-editor-instructions h4 {
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
}
|
1209 |
.ddl-form .wpv-code {
|
1210 |
-
|
1211 |
}
|
1212 |
.ddl-form .wpv-shortcode {
|
1213 |
-
|
1214 |
}
|
1215 |
.ddl-form .wpv-html {
|
1216 |
-
|
1217 |
}
|
1218 |
a.js-show-cell-dialog, a.js-show-cell-dialog:hover{text-decoration: none;}
|
1219 |
|
@@ -1236,4 +1239,6 @@ a.ddl-help-link-link{font-size:12px;}
|
|
1236 |
-webkit-font-smoothing: antialiased;
|
1237 |
content: "\f00d";
|
1238 |
}
|
1239 |
-
.ddl-dialogs-container .ui-dialog-titlebar-close:hover{color
|
|
|
|
221 |
|
222 |
.ddl-dialog .wpv-ct-inline-edit .quicktags-toolbar {
|
223 |
border: 1px solid #ccc;
|
224 |
+
border-width: 1px 1px 0 1px;
|
225 |
+
background: #f4f4f4;
|
226 |
}
|
227 |
|
228 |
.ddl-form .code-editor-toolbar>ul>li {
|
469 |
div.alert-no-loops i.remove-alert-message, div.alert-no-post-content i.remove-alert-message{position:absolute;top:2px;right:4px;color:#999;cursor:pointer;}
|
470 |
div.alert-no-loops i.remove-alert-message:hover, div.alert-no-post-content i.remove-alert-message:hover{color:#999;}
|
471 |
div.alert-no-loops, div.alert-no-post-content{line-height: 1.2;position:relative;}
|
472 |
+
.toolset_page_dd_layouts div.alert-no-loops, .toolset_page_dd_layouts div.alert-no-post-content{}
|
473 |
.save-archives-options-wrap{text-align: right;}
|
474 |
ul.post-types-list-in-layout-editor-alerted, ul.post-loops-list-in-layout-editor-alerted{border:1px solid;border-color: #fbeed5;background-color: #fcf8e3;}
|
475 |
|
484 |
.ddl-dialog .ui-widget-header{border:none;background:transparent;border-bottom:1px solid #ccc;border-bottom-left-radius: 0px;border-bottom-right-radius: 0px;}
|
485 |
.ddl-dialog .ddl-dialog-content-main{border:none;background: transparent;padding-left:0px !important;padding-right:0px !important;}
|
486 |
.ddl-dialog .ui-tabs-nav li.ddl-tab-right {margin-right:0px;}
|
487 |
+
.ddl-dialog .ddl-dialog-content-main .ddl-form{padding:10px;margin-bottom:0;}
|
488 |
p.desc a.fieldset-inputs{color:#0074a2;}
|
489 |
|
490 |
.individual-pages-wrap .ui-widget-content{background:transparent;border:none;}
|
491 |
.individual-pages-wrap .ui-widget-header{border:none;background:transparent;margin-bottom: 14px;padding-bottom: 0px;}
|
492 |
+
.individual-pages-wrap .ddl-individual-tab{border:none;border:1px solid #ccc;position: relative;top: -3px; background: white;border-radius: 3px;border-top-left-radius: 0px;overflow-x: hidden;}
|
493 |
.individual-pages-wrap .ui-tabs-nav li{padding-bottom:8px;}
|
494 |
.ddl-individual-tab div.ajax-loader{ bottom: 6px;position: relative;left: 45%;}
|
495 |
|
530 |
|
531 |
.ddl-individual-quick-search {
|
532 |
margin-bottom: 5px;
|
533 |
+
width:50%;
|
534 |
}
|
535 |
|
536 |
+
span.individual-quick-search-desc{color: #999;font-size: 10px;float:left;margin:-5px 0px 0px 2px;width:100%;clear:both;}
|
537 |
+
|
538 |
/* RICH CONTENT CELL VISUAL EDITOR */
|
539 |
|
540 |
/* Comments cell preview */
|
822 |
.class-views-content-grid-cell .item-insert,
|
823 |
.class-ddl-container .item-insert,
|
824 |
.class-cred-cell .item-insert {
|
825 |
+
bottom: 26px;
|
826 |
}
|
827 |
.class-post-loop-views-cell .item-insert,
|
828 |
.class-child-layout .item-insert,
|
829 |
.class-cell-content-template .item-insert,
|
830 |
.class-post-loop-views-cell .item-insert {
|
831 |
+
bottom: 25px;
|
832 |
}
|
833 |
|
834 |
.class-comments-cell .item-insert {
|
835 |
+
bottom: 19px;
|
836 |
}
|
837 |
|
838 |
.class-text-cell .item-insert {
|
839 |
+
bottom: 23px;
|
840 |
}
|
841 |
|
842 |
.class-menu-cell .item-insert {
|
843 |
+
bottom: 20px;
|
844 |
}
|
845 |
|
846 |
.item-body .item-insert .dashicons,
|
847 |
.item-description .item-insert .dashicons{
|
848 |
+
margin-left: 5px;
|
849 |
+
line-height: 55px;
|
850 |
}
|
851 |
.item-body .item-insert:hover,
|
852 |
.item-body .item-insert:focus,
|
853 |
.item-description .item-insert:hover,
|
854 |
.item-description .item-insert:focus {
|
855 |
+
background: #d6410f;
|
856 |
}
|
857 |
|
858 |
.item-description-no-preview {
|
859 |
+
min-height: 80px;
|
860 |
}
|
861 |
|
862 |
.item-description-no-preview p {
|
863 |
+
width: 500px;
|
864 |
}
|
865 |
|
866 |
.grid .item-header h4,
|
894 |
}
|
895 |
.item-header .item-close:hover,
|
896 |
.item-header .item-close:focus {
|
897 |
+
background: #aaa;
|
898 |
}
|
899 |
.preview .grid-category-item:not(.active) {
|
900 |
opacity: .6;
|
929 |
}
|
930 |
.item-name-subtitle{font-size:10px!important;font-family:Verdana, Geneva, sans-serif;}
|
931 |
|
932 |
+
#wrapper-element-box-type .ddl-dialog-content{height:auto;/*max-height:600px;*/position:relative;}
|
933 |
|
934 |
a.ddl-show-item-desc, a.ddl-show-item-desc{
|
935 |
float:left;
|
965 |
.ddl-move-box-down{top:8px;max-height:165px;}
|
966 |
|
967 |
.ddl-max-height-150, a.ddl-max-height-150, .ddl-max-height-150:hover{
|
968 |
+
max-height:150px;margin-bottom:10px;
|
969 |
}
|
970 |
.move-name-up{}
|
971 |
/* PREVIEW DIALOG IMAGE */
|
974 |
/* CELL PREVIEWS */
|
975 |
|
976 |
.ddl-post-content-current-page-preview {
|
977 |
+
text-align: center;
|
978 |
}
|
979 |
|
980 |
.ddl-post-content-current-page-preview > img {
|
981 |
+
margin-top: -20px !important;
|
982 |
+
margin-bottom: -20px !important;
|
983 |
}
|
984 |
|
985 |
/* Content template */
|
988 |
}
|
989 |
|
990 |
.ddl-post-content-template-preview > img {
|
991 |
+
margin-top: -5px !important;
|
992 |
+
margin-bottom: -30px !important;
|
993 |
}
|
994 |
|
995 |
/* Views grid */
|
996 |
.ddl-views-grid-preview {
|
997 |
+
text-align: center;
|
998 |
}
|
999 |
|
1000 |
.ddl-views-grid-preview > img {
|
1001 |
+
margin-top: -5px !important;
|
1002 |
+
margin-bottom: -10px !important;
|
1003 |
}
|
1004 |
|
1005 |
/*Menu*/
|
1008 |
}
|
1009 |
|
1010 |
.ddl-menu-preview > img {
|
1011 |
+
margin-top: -20px !important;
|
1012 |
+
margin-bottom: -20px !important;
|
1013 |
}
|
1014 |
|
1015 |
/*Slider*/
|
1018 |
}
|
1019 |
|
1020 |
.ddl-slider-preview > img {
|
1021 |
+
margin-top: -20px !important;
|
1022 |
+
margin-bottom: -20px !important;
|
1023 |
}
|
1024 |
|
1025 |
/*Video*/
|
1028 |
}
|
1029 |
|
1030 |
.ddl-video-preview > img {
|
1031 |
+
margin-bottom: -20px !important;
|
1032 |
}
|
1033 |
|
1034 |
/*Image box*/
|
1037 |
}
|
1038 |
|
1039 |
.ddl-image-box-preview > img {
|
1040 |
+
margin-top: -20px !important;
|
1041 |
+
margin-bottom: -20px !important;
|
1042 |
}
|
1043 |
.ddl-image-box-preview-image{
|
1044 |
text-align: center;
|
1060 |
}
|
1061 |
|
1062 |
.ddl-widget-preview > img {
|
1063 |
+
margin-top: -20px !important;
|
1064 |
+
margin-bottom: -20px !important;
|
1065 |
}
|
1066 |
|
1067 |
/*Widget*/
|
1070 |
}
|
1071 |
|
1072 |
.ddl-widget-area-preview > img {
|
1073 |
+
margin-top: -20px !important;
|
1074 |
+
margin-bottom: -20px !important;
|
1075 |
}
|
1076 |
|
1077 |
/*Child Layout*/
|
1080 |
}
|
1081 |
|
1082 |
.ddl-child-layout-preview > img {
|
1083 |
+
margin-top: -20px !important;
|
1084 |
+
margin-bottom: -20px !important;
|
1085 |
}
|
1086 |
|
1087 |
/*Comment*/
|
1090 |
}
|
1091 |
|
1092 |
.ddl-comments-preview > img {
|
1093 |
+
margin-top: -10px !important;
|
1094 |
}
|
1095 |
|
1096 |
/*CRED form*/
|
1099 |
}
|
1100 |
|
1101 |
.ddl-cred-preview > img {
|
1102 |
+
margin-bottom: -5px !important;
|
1103 |
}
|
1104 |
|
1105 |
/*post loop*/
|
1108 |
}
|
1109 |
|
1110 |
.ddl-post-loop-preview > img {
|
1111 |
+
margin-bottom: -10px !important;
|
1112 |
}
|
1113 |
|
1114 |
.cell-preview p:first-child {
|
1115 |
+
margin-top:-5px;
|
1116 |
}
|
1117 |
|
1118 |
.ddl-parametric-search-preview {
|
1119 |
+
text-align: center;
|
1120 |
}
|
1121 |
|
1122 |
/* FOOTER MESSAGE */
|
1162 |
/* FORMATTING INSTUCTIONS SHORTCODES */
|
1163 |
|
1164 |
.ddl-form .wpv-editor-instructions-toggle {
|
1165 |
+
display: block;
|
1166 |
+
margin: 0;
|
1167 |
+
padding: 0 28px 0 0;
|
1168 |
+
height: 30px;
|
1169 |
+
line-height: 30px;
|
1170 |
+
border: solid 1px #ccc;
|
1171 |
+
border-top: none;
|
1172 |
+
font-weight: bold;
|
1173 |
+
cursor: pointer;
|
1174 |
+
background: #e5e5e5;
|
1175 |
+
background: -moz-linear-gradient(top, #e5e5e5 0%, #f4f4f4 100%);
|
1176 |
+
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#e5e5e5), color-stop(100%,#f4f4f4));
|
1177 |
+
background: -webkit-linear-gradient(top, #e5e5e5 0%,#f4f4f4 100%);
|
1178 |
+
background: -o-linear-gradient(top, #e5e5e5 0%,#f4f4f4 100%);
|
1179 |
+
background: -ms-linear-gradient(top, #e5e5e5 0%,#f4f4f4 100%);
|
1180 |
+
background: linear-gradient(to bottom, #e5e5e5 0%,#f4f4f4 100%);
|
1181 |
+
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e5e5e5', endColorstr='#f4f4f4',GradientType=0 );
|
1182 |
}
|
1183 |
.ddl-form .wpv-toggle-toggler-icon {
|
1184 |
+
display: inline-block;
|
1185 |
+
float: left;
|
1186 |
+
width: 28px;
|
1187 |
+
margin-right: 10px;
|
1188 |
+
text-align: center;
|
1189 |
+
border-right: solid 1px #ccc;
|
1190 |
}
|
1191 |
.ddl-form .wpv-editor-instructions {
|
1192 |
+
border: solid 1px #ccc;
|
1193 |
+
border-top: none;
|
1194 |
+
padding: 1px 28px 5px;
|
1195 |
+
background: #f6f6f6;
|
1196 |
+
max-height: 400px;
|
1197 |
+
overflow-y: auto;
|
1198 |
}
|
1199 |
|
1200 |
+
.wpv-editor-instructions dl dt {
|
1201 |
+
font-weight: bold;
|
1202 |
+
margin-top: 0.5em;
|
1203 |
}
|
1204 |
.ddl-form .wpv-editor-instructions .widefat {
|
1205 |
+
margin-bottom: 20px;
|
1206 |
}
|
1207 |
.ddl-form .wpv-editor-instructions h4 {
|
1208 |
+
color: #efefef;
|
1209 |
+
background: #999;
|
1210 |
+
padding: 1px 5px;
|
1211 |
}
|
1212 |
.ddl-form .wpv-code {
|
1213 |
+
font-family: Consolas,Monaco,monospace;
|
1214 |
}
|
1215 |
.ddl-form .wpv-shortcode {
|
1216 |
+
color: #ed8027;
|
1217 |
}
|
1218 |
.ddl-form .wpv-html {
|
1219 |
+
color: #170;
|
1220 |
}
|
1221 |
a.js-show-cell-dialog, a.js-show-cell-dialog:hover{text-decoration: none;}
|
1222 |
|
1239 |
-webkit-font-smoothing: antialiased;
|
1240 |
content: "\f00d";
|
1241 |
}
|
1242 |
+
.ddl-dialogs-container .ui-dialog-titlebar-close:hover{color:#00a0d2!important;}
|
1243 |
+
.ddl-fields-description-wrap h4{margin-bottom:2px;padding-bottom: 0px;margin-top:0px;padding-top: 0px;}
|
1244 |
+
p.ddl-fields-description{padding-top:2px;margin-top:0px;padding-bottom: 12px;font-size: 12px;}
|
library/toolset/toolset-common/utility/dialogs/toolset.dialog-boxes.class.php
CHANGED
@@ -8,10 +8,8 @@ if ( ! class_exists( 'Toolset_DialogBoxes' ) ) {
|
|
8 |
|
9 |
public function __construct( $screens = array() ) {
|
10 |
$this->screens = apply_filters( 'toolset_dialog-boxes_screen_ids', $screens );
|
11 |
-
|
12 |
-
add_filter( 'toolset_add_registered_script', array( &$this, 'register_scripts' ), 10, 1 );
|
13 |
add_filter( 'toolset_add_registered_styles', array( &$this, 'register_styles' ), 10, 1 );
|
14 |
-
|
15 |
}
|
16 |
|
17 |
function init_screen_render() {
|
@@ -37,11 +35,7 @@ if ( ! class_exists( 'Toolset_DialogBoxes' ) ) {
|
|
37 |
return $scripts;
|
38 |
}
|
39 |
|
40 |
-
function register_styles( $styles )
|
41 |
-
$styles['ddl-dialogs-css'] = new Toolset_Style( 'ddl-dialogs-css', TOOLSET_COMMON_URL . '/utility/dialogs/css/dd-dialogs.css', array( 'wp-jquery-ui-dialog' ) );
|
42 |
-
$styles['ddl-dialogs-general-css'] = new Toolset_Style( 'ddl-dialogs-general-css', TOOLSET_COMMON_URL . '/utility/dialogs/css/dd-dialogs-general.css', array( 'wp-jquery-ui-dialog' ) );
|
43 |
-
$styles['ddl-dialogs-forms-css'] = new Toolset_Style( 'ddl-dialogs-forms-css', TOOLSET_COMMON_URL . '/utility/dialogs/css/dd-dialogs-forms.css' );
|
44 |
-
|
45 |
return $styles;
|
46 |
}
|
47 |
|
@@ -74,5 +68,33 @@ if ( ! class_exists( 'Toolset_DialogBoxes' ) ) {
|
|
74 |
echo ob_get_clean();
|
75 |
}
|
76 |
}
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
public function __construct( $screens = array() ) {
|
10 |
$this->screens = apply_filters( 'toolset_dialog-boxes_screen_ids', $screens );
|
|
|
|
|
11 |
add_filter( 'toolset_add_registered_styles', array( &$this, 'register_styles' ), 10, 1 );
|
12 |
+
add_filter( 'toolset_add_registered_script', array( &$this, 'register_scripts' ), 10, 1 );
|
13 |
}
|
14 |
|
15 |
function init_screen_render() {
|
35 |
return $scripts;
|
36 |
}
|
37 |
|
38 |
+
function register_styles( $styles ){
|
|
|
|
|
|
|
|
|
39 |
return $styles;
|
40 |
}
|
41 |
|
68 |
echo ob_get_clean();
|
69 |
}
|
70 |
}
|
71 |
+
}
|
72 |
+
|
73 |
+
/*** COMMON CASES ***/
|
74 |
+
if( !class_exists('Toolset_PopUpBlockerAlert') ){
|
75 |
+
class Toolset_PopUpBlockerAlert extends Toolset_DialogBoxes{
|
76 |
+
const POPUP_MESSAGE_OPTION = 'toolset_popup_blocked_dismiss';
|
77 |
+
public function template(){
|
78 |
+
ob_start();?>
|
79 |
+
|
80 |
+
<script type="text/html" id="ddl-generic-dialog-tpl">
|
81 |
+
<div id="js-dialog-dialog-container">
|
82 |
+
<div class="ddl-dialog-content" id="js-dialog-content-dialog">
|
83 |
+
<?php printf(
|
84 |
+
__('%sTo see the preview, you need to allow this page to show popups.%sHow to enable popups in your browser%s', 'ddl-layouts'),
|
85 |
+
'<p>',
|
86 |
+
'<br><a href="https://wp-types.com/documentation/user-guides/enable-pop-ups-browser/?utm_source=layoutsplugin&utm_campaign=layouts&utm_medium=enable-pop-ups-browser&utm_term=help-link" title="enable popups" target="_blank">',
|
87 |
+
'</a></p>'
|
88 |
+
);
|
89 |
+
?>
|
90 |
+
<p>
|
91 |
+
<label for="disable-popup-message"><input type="checkbox" name="<?php echo self::POPUP_MESSAGE_OPTION; ?>" value="true" id="disable-popup-message"> <?php _e('Don\'t show this message again', 'ddl-layouts'); ?></label>
|
92 |
+
</p>
|
93 |
+
</div>
|
94 |
+
</div>
|
95 |
+
</script>
|
96 |
+
<?php
|
97 |
+
echo ob_get_clean();
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
library/toolset/toolset-common/utility/help-videos/res/css/toolset-help-videos.css
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.toolset-wrap{
|
2 |
+
position:relative;
|
3 |
+
}
|
4 |
+
.toolset-videos-wrapper{
|
5 |
+
clear: both;
|
6 |
+
margin: 10px 0 0 0;
|
7 |
+
width: 820px;
|
8 |
+
float:left;
|
9 |
+
}
|
10 |
+
.toolset-video-box-wrap{
|
11 |
+
position: relative;
|
12 |
+
display:block;
|
13 |
+
/*width:100%;*/
|
14 |
+
height:100%;
|
15 |
+
float:left;
|
16 |
+
clear:both;
|
17 |
+
overflow:hidden;
|
18 |
+
margin-top:20px;
|
19 |
+
margin-bottom:20px;
|
20 |
+
}
|
21 |
+
.toolset-wrap .toolset-video-box-wrap{overflow:visible;}
|
22 |
+
|
23 |
+
.toolset-box-video {
|
24 |
+
position: relative;
|
25 |
+
top: 10px;
|
26 |
+
overflow: hidden;
|
27 |
+
}
|
28 |
+
|
29 |
+
.toolset-box-container {
|
30 |
+
margin-bottom: 0px;
|
31 |
+
}
|
32 |
+
|
33 |
+
.toolset-box-container:empty {
|
34 |
+
margin: 0;
|
35 |
+
}
|
36 |
+
.toolset-box-content{margin-bottom:2px;}
|
37 |
+
.remove-video{float:right;}
|
38 |
+
.remove-video-icon{font-size:16px;margin-right:2px;}
|
39 |
+
.remove-video-icon:hover{color:#0073aa;}
|
40 |
+
.toolset-box-footer{
|
41 |
+
position: relative;
|
42 |
+
width:100%;
|
43 |
+
display: block;
|
44 |
+
overflow: hidden;
|
45 |
+
padding:4px 0px 0px 0px;
|
46 |
+
}
|
47 |
+
.toolset-box-header{
|
48 |
+
position: relative;
|
49 |
+
width:100%;
|
50 |
+
display: block;
|
51 |
+
overflow: hidden;
|
52 |
+
padding:0px 0px 4px 0px;
|
53 |
+
}
|
54 |
+
.remove-video{cursor:pointer;}
|
55 |
+
.button.remove-video{margin:0px 0px 0px 4px;}
|
56 |
+
.remove-video-icon{position:relative;bottom:-1px;font-size:16px;}
|
57 |
+
.video-box-title{
|
58 |
+
margin-bottom:0px;
|
59 |
+
padding-bottom:0px;
|
60 |
+
margin-top:0px;
|
61 |
+
padding-top:0px;
|
62 |
+
font-weight:normal;
|
63 |
+
font-size:13px;
|
64 |
+
}
|
65 |
+
.video-box-title-open{
|
66 |
+
margin-bottom:0px;
|
67 |
+
padding-bottom:0px;
|
68 |
+
margin-top:0px;
|
69 |
+
padding-top:0px;
|
70 |
+
position:relative;
|
71 |
+
top:30px;
|
72 |
+
color:white;
|
73 |
+
z-index:8888;
|
74 |
+
font-family: 'FontAwesome'!important;
|
75 |
+
font-style: normal!important;
|
76 |
+
float:left;
|
77 |
+
margin-left:30px;
|
78 |
+
font-size:24px;
|
79 |
+
display:block;
|
80 |
+
}
|
81 |
+
.video-box-title-open i{
|
82 |
+
font-family: 'FontAwesome'!important;
|
83 |
+
font-style: normal!important;
|
84 |
+
}
|
85 |
+
span.mejs-offscreen{display:none!important;}
|
86 |
+
.video-title-alone{cursor:pointer;}
|
87 |
+
/**** LIST *****/
|
88 |
+
.js-video-list{
|
89 |
+
color:#0073aa;
|
90 |
+
cursor:pointer;
|
91 |
+
}
|
92 |
+
.toolset-video-icon{
|
93 |
+
font-size:14px;
|
94 |
+
margin-left:6px;
|
95 |
+
}
|
96 |
+
/*** OVERLAY ****/
|
97 |
+
/*OVERLAY*/
|
98 |
+
/* ------- */
|
99 |
+
/* Overlay */
|
100 |
+
/* ------- */
|
101 |
+
.toolset-box-container .loader-overlay {
|
102 |
+
position: absolute;
|
103 |
+
top: 0;
|
104 |
+
right: 0;
|
105 |
+
bottom: 0;
|
106 |
+
left: 0;
|
107 |
+
z-index: 3;
|
108 |
+
background: #000;
|
109 |
+
text-align: center;
|
110 |
+
opacity: .4;
|
111 |
+
width:100%;
|
112 |
+
height:100%;
|
113 |
+
float:left;
|
114 |
+
}
|
115 |
+
.toolset-box-container .loader-overlay-high-z {
|
116 |
+
z-index: 8888;
|
117 |
+
}
|
118 |
+
|
119 |
+
.toolset-box-container .preloader {
|
120 |
+
position:absolute;
|
121 |
+
z-index: 100;
|
122 |
+
top:50%;
|
123 |
+
left:48%;
|
124 |
+
/*display: inline-block;*/
|
125 |
+
margin: -32px 0 0 -32px;
|
126 |
+
width: 64px;
|
127 |
+
height: 64px;
|
128 |
+
background: url('../images/ajax-loader-overlay2.gif') center center no-repeat;
|
129 |
+
font-family: 'FontAwesome'!important;
|
130 |
+
font-style: normal!important;
|
131 |
+
}
|
132 |
+
.toolset-box-container .preloader i.fa.fa-play-circle{
|
133 |
+
font-family: 'FontAwesome'!important;
|
134 |
+
font-style: normal!important;
|
135 |
+
font-size:7em;
|
136 |
+
cursor:pointer;
|
137 |
+
}
|
138 |
+
.toolset-box-container .preloader i.fa.fa-play-circle:hover{color:white;opacity: 1;}
|
library/toolset/toolset-common/utility/help-videos/res/images/ajax-loader-overlay.gif
ADDED
Binary file
|
library/toolset/toolset-common/utility/help-videos/res/images/ajax-loader-overlay2.gif
ADDED
Binary file
|
library/toolset/toolset-common/utility/help-videos/res/js/toolset-help-videos.js
ADDED
@@ -0,0 +1,373 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var WP_Toolset = WPV_Toolset || {};
|
2 |
+
|
3 |
+
WP_Toolset.HelpVideos = {};
|
4 |
+
|
5 |
+
if( typeof _ !== 'undefined' && _.templateSettings )
|
6 |
+
{
|
7 |
+
_.templateSettings = {
|
8 |
+
escape: /\{\{([^\}]+?)\}\}(?!\})/g,
|
9 |
+
evaluate: /<#([\s\S]+?)#>/g,
|
10 |
+
interpolate: /\{\{\{([\s\S]+?)\}\}\}/g
|
11 |
+
};
|
12 |
+
}
|
13 |
+
|
14 |
+
WP_Toolset.HelpVideosFactory = function ($) {
|
15 |
+
var self = this,
|
16 |
+
videos = WP_ToolsetVideoSettings.video_instances,
|
17 |
+
current = WP_ToolsetVideoSettings.current,
|
18 |
+
seen = WP_ToolsetVideoSettings.seen,
|
19 |
+
collection,
|
20 |
+
append_done = false,
|
21 |
+
triggered_manually = false,
|
22 |
+
collection_view = null;
|
23 |
+
|
24 |
+
self.init = function () {
|
25 |
+
return self.show_video(current);
|
26 |
+
};
|
27 |
+
|
28 |
+
self.get_seen = function(){
|
29 |
+
return seen;
|
30 |
+
}
|
31 |
+
|
32 |
+
self.populate_collection = function(){
|
33 |
+
collection = new WP_Toolset.HelpVideosCollection();
|
34 |
+
_.each(videos, function(v){
|
35 |
+
collection.add( new WP_Toolset.HelpVideo( v ) );
|
36 |
+
});
|
37 |
+
return collection;
|
38 |
+
};
|
39 |
+
|
40 |
+
self.get_videos = function(){
|
41 |
+
return collection;
|
42 |
+
};
|
43 |
+
|
44 |
+
self.create_on_the_fly = function(element,append_to){
|
45 |
+
if( append_done === false ){
|
46 |
+
var el = self.create_element(element);
|
47 |
+
jQuery(append_to).append(el);
|
48 |
+
append_done = true;
|
49 |
+
}
|
50 |
+
};
|
51 |
+
|
52 |
+
self.handle_list = function(){
|
53 |
+
var models = self.populate_collection();
|
54 |
+
collection_view = new WP_Toolset.HelpVideosListView({model:models});
|
55 |
+
jQuery( '.js-toolset-videos-wrapper' ).append( jQuery(WP_ToolsetVideoSettings.VIDEOS_LIST_TITLE), collection_view.$el );
|
56 |
+
};
|
57 |
+
|
58 |
+
self.show_video = function( video ){
|
59 |
+
if ( videos.hasOwnProperty(video) ) {
|
60 |
+
|
61 |
+
if( adminpage !== WP_ToolsetVideoSettings.detached_page && videos[video].hasOwnProperty('append_to') && videos[video].append_to !== '' ){
|
62 |
+
self.create_on_the_fly( videos[video].element ? videos[video].element : WP_ToolsetVideoSettings.GENERIC_ELEMENT, videos[video].append_to );
|
63 |
+
}
|
64 |
+
|
65 |
+
var model = WP_Toolset.HelpVideos.hasOwnProperty(video) ? WP_Toolset.HelpVideos[video] : new WP_Toolset.HelpVideo(videos[video]),
|
66 |
+
view = new WP_Toolset.HelpVideoView({
|
67 |
+
el: videos[video].element ? videos[video].element : WP_ToolsetVideoSettings.GENERIC_ELEMENT,
|
68 |
+
model: model
|
69 |
+
});
|
70 |
+
|
71 |
+
if( adminpage !== WP_ToolsetVideoSettings.detached_page && self.get_seen() === 'seen' && triggered_manually === false ){
|
72 |
+
view.$el.hide();
|
73 |
+
view.manual_trigger();
|
74 |
+
triggered_manually = true;
|
75 |
+
}
|
76 |
+
|
77 |
+
jQuery('.js-toolset-videos-wrapper').width( model.get('width') ).height( model.get('height') );
|
78 |
+
|
79 |
+
WP_Toolset.HelpVideos[video] = model;
|
80 |
+
|
81 |
+
return WP_Toolset.HelpVideos[video];
|
82 |
+
}
|
83 |
+
|
84 |
+
return null;
|
85 |
+
};
|
86 |
+
|
87 |
+
self.show_new_video = function( model ){
|
88 |
+
self.remove_list();
|
89 |
+
jQuery('.js-toolset-videos-wrapper').append( self.create_element( model.get('element') ) );
|
90 |
+
self.show_video( model.get('name') );
|
91 |
+
};
|
92 |
+
|
93 |
+
self.create_element = function( selector ){
|
94 |
+
var sel = selector.substring(1);
|
95 |
+
return jQuery('<div class="'+sel+'" id="'+sel+'"></div>')
|
96 |
+
};
|
97 |
+
|
98 |
+
self.remove_list = function(){
|
99 |
+
jQuery('.js-videos-list-title').remove();
|
100 |
+
collection_view.remove();
|
101 |
+
};
|
102 |
+
|
103 |
+
self.init();
|
104 |
+
};
|
105 |
+
|
106 |
+
WP_Toolset.HelpVideo = Backbone.Model.extend({
|
107 |
+
defaults: {
|
108 |
+
title:'',
|
109 |
+
name: '',
|
110 |
+
url: '',
|
111 |
+
element: '',
|
112 |
+
screens: [],
|
113 |
+
width:'600px',
|
114 |
+
height:'400px'
|
115 |
+
}
|
116 |
+
});
|
117 |
+
|
118 |
+
WP_Toolset.HelpVideosCollection = Backbone.Collection.extend({
|
119 |
+
model:WP_Toolset.HelpVideo,
|
120 |
+
current:null
|
121 |
+
});
|
122 |
+
|
123 |
+
|
124 |
+
WP_Toolset.HelpVideoView = Backbone.View.extend({
|
125 |
+
DELAY:200,
|
126 |
+
initialize: function (options) {
|
127 |
+
var self = this;
|
128 |
+
self.template_selector = '#toolset-video-template';
|
129 |
+
self.template = _.template(jQuery(self.template_selector).html());
|
130 |
+
self.deatch_url = WP_ToolsetVideoSettings.detach_url;
|
131 |
+
self.render(options).el;
|
132 |
+
},
|
133 |
+
render: function (options) {
|
134 |
+
var self = this;
|
135 |
+
self.$el.html(self.template(self.model.toJSON()));
|
136 |
+
self.wrap = jQuery('.js-toolset-box-container', self.$el);
|
137 |
+
self.handle_detach();
|
138 |
+
self.wrap.loaderOverlay('show', {
|
139 |
+
class:'loader-overlay-high-z',
|
140 |
+
css : {
|
141 |
+
"opacity" : "0.65",
|
142 |
+
height : self.model.get('height')
|
143 |
+
}
|
144 |
+
}
|
145 |
+
);
|
146 |
+
self.hidden_wrap = jQuery('.js-video-player-box', self.$el);
|
147 |
+
self.remove_button = jQuery('.js-remove-video', self.$el);
|
148 |
+
self.handle_video();
|
149 |
+
self.remove_video();
|
150 |
+
return self;
|
151 |
+
},
|
152 |
+
handle_detach:function(){
|
153 |
+
var self = this, $button = jQuery('.js-detach-video', self.$el);
|
154 |
+
if( adminpage === WP_ToolsetVideoSettings.detached_page ){
|
155 |
+
$button.hide();
|
156 |
+
} else {
|
157 |
+
$button.on('click', function(event){
|
158 |
+
event.stopImmediatePropagation();
|
159 |
+
event.preventDefault();
|
160 |
+
self.remove_button.trigger('click');
|
161 |
+
window.open( self.deatch_url );
|
162 |
+
});
|
163 |
+
}
|
164 |
+
},
|
165 |
+
handle_video:function(){
|
166 |
+
var self = this;
|
167 |
+
var video = jQuery('.js-video-player');
|
168 |
+
self.player = new MediaElementPlayer( video, {
|
169 |
+
alwaysShowHours: false,
|
170 |
+
width:self.model.get('width'),
|
171 |
+
height:self.model.get('height'),
|
172 |
+
success: function (mediaElement, domObject) {
|
173 |
+
mediaElement.addEventListener('loadeddata', function(e) {
|
174 |
+
mediaElement.pause();
|
175 |
+
self.hidden_wrap.fadeIn(self.DELAY, function(event){
|
176 |
+
self.setPlay( mediaElement );
|
177 |
+
|
178 |
+
});
|
179 |
+
}, false);
|
180 |
+
|
181 |
+
mediaElement.addEventListener('ended', function(e) {
|
182 |
+
self.setPlay( mediaElement );
|
183 |
+
}, false);
|
184 |
+
mediaElement.addEventListener('play', function(e) {
|
185 |
+
jQuery('.mejs-mediaelement').loaderOverlay('hide');
|
186 |
+
}, false);
|
187 |
+
},
|
188 |
+
// fires when a problem is detected
|
189 |
+
error: function () {
|
190 |
+
|
191 |
+
}
|
192 |
+
} );
|
193 |
+
},
|
194 |
+
setPlay:function( mediaElement ){
|
195 |
+
var play = jQuery('<i class="fa fa-play-circle js-toolset-play-video"></i>'),
|
196 |
+
$title = jQuery('.js-video-box-title-open').detach().clone();
|
197 |
+
|
198 |
+
jQuery('.js-video-box-title-open').remove();
|
199 |
+
|
200 |
+
jQuery('.mejs-mediaelement').loaderOverlay('show', {
|
201 |
+
class:'loader-overlay-high-z',
|
202 |
+
css : {
|
203 |
+
"opacity" : "0.7",
|
204 |
+
'height': jQuery('.mejs-mediaelement').height() - 30 + 'px'
|
205 |
+
}
|
206 |
+
});
|
207 |
+
|
208 |
+
jQuery('.toolset-box-container .loader-overlay').append($title);
|
209 |
+
|
210 |
+
jQuery('.toolset-box-container .preloader').css({
|
211 |
+
'background':'none'
|
212 |
+
}).append(play);
|
213 |
+
|
214 |
+
jQuery('.js-toolset-play-video').on('click', function(event){
|
215 |
+
event.stopImmediatePropagation();
|
216 |
+
event.preventDefault();
|
217 |
+
jQuery('.mejs-mediaelement').loaderOverlay('hide',{onRemove:function(){
|
218 |
+
|
219 |
+
mediaElement.play();
|
220 |
+
|
221 |
+
}});
|
222 |
+
});
|
223 |
+
|
224 |
+
this.wrap.loaderOverlay('hide',{onRemove:function(){
|
225 |
+
}, fadeOutSpeed:200});
|
226 |
+
},
|
227 |
+
remove_video:function(){
|
228 |
+
var self = this;
|
229 |
+
self.remove_button.on('click', function(event){
|
230 |
+
event.stopImmediatePropagation();
|
231 |
+
event.preventDefault();
|
232 |
+
self.$el.hide(400, function(){
|
233 |
+
if( adminpage === WP_ToolsetVideoSettings.detached_page ){
|
234 |
+
WP_Toolset.HelpVideos.main.handle_list();
|
235 |
+
} else {
|
236 |
+
self.insert_title_view();
|
237 |
+
}
|
238 |
+
self.remove();
|
239 |
+
});
|
240 |
+
});
|
241 |
+
},
|
242 |
+
manual_trigger:function(){
|
243 |
+
var self = this;
|
244 |
+
self.remove_button.trigger('click');
|
245 |
+
},
|
246 |
+
insert_title_view:function(){
|
247 |
+
var self = this,
|
248 |
+
index = self.$el.index(),
|
249 |
+
parent = self.$el.parent(),
|
250 |
+
element = self.model.get('element') ? self.model.get('element').substring(1) : WP_ToolsetVideoSettings.GENERIC_ELEMENT,
|
251 |
+
new_me = new WP_Toolset.HelpVideoListView({
|
252 |
+
model:self.model,
|
253 |
+
template_selector:'#toolset-video-header-template',
|
254 |
+
tagName:'div',
|
255 |
+
classes:element,
|
256 |
+
id:element
|
257 |
+
});
|
258 |
+
|
259 |
+
parent.insertAtIndex(index, new_me.$el);
|
260 |
+
return new_me;
|
261 |
+
}
|
262 |
+
});
|
263 |
+
|
264 |
+
WP_Toolset.HelpVideoListView = Backbone.View.extend({
|
265 |
+
initialize:function(options){
|
266 |
+
var self = this;
|
267 |
+
self.tagName = options.tagName;
|
268 |
+
self.$el.addClass(options.classes + ' video-title-alone');
|
269 |
+
if( options.hasOwnProperty('id') ){
|
270 |
+
self.$el.prop('id', options.id);
|
271 |
+
}
|
272 |
+
self.template_selector = options.template_selector;
|
273 |
+
self.template = _.template(jQuery(self.template_selector).html());
|
274 |
+
self.render( options ).el
|
275 |
+
return self;
|
276 |
+
},
|
277 |
+
render:function( options ){
|
278 |
+
var self = this;
|
279 |
+
self.$el.html(self.template(self.model.toJSON()));
|
280 |
+
self.show();
|
281 |
+
return self;
|
282 |
+
},
|
283 |
+
show:function(){
|
284 |
+
var self = this;
|
285 |
+
self.$el.on('click', function(event){
|
286 |
+
event.stopImmediatePropagation();
|
287 |
+
event.preventDefault();
|
288 |
+
if( adminpage === WP_ToolsetVideoSettings.detached_page ) {
|
289 |
+
WP_Toolset.HelpVideos.main.show_new_video(self.model);
|
290 |
+
} else {
|
291 |
+
self.insert_video_view();
|
292 |
+
}
|
293 |
+
});
|
294 |
+
},
|
295 |
+
insert_video_view:function(){
|
296 |
+
var self = this,
|
297 |
+
index = self.$el.index(),
|
298 |
+
parent = self.$el.parent();
|
299 |
+
|
300 |
+
self.$el.empty();
|
301 |
+
parent.insertAtIndex( index, self.$el.clone() );
|
302 |
+
self.remove();
|
303 |
+
WP_Toolset.HelpVideos.main.show_video( self.model.get('name') );
|
304 |
+
}
|
305 |
+
});
|
306 |
+
|
307 |
+
WP_Toolset.HelpVideosListView = Backbone.View.extend({
|
308 |
+
el:'.js-videos-list',
|
309 |
+
tagName: 'ul',
|
310 |
+
initialize:function(options){
|
311 |
+
var self = this;
|
312 |
+
self.$el = self.create_element();
|
313 |
+
self.el = self.$el[0];
|
314 |
+
self.render(options).el;
|
315 |
+
return self;
|
316 |
+
},
|
317 |
+
render:function( option ){
|
318 |
+
|
319 |
+
var self = this,
|
320 |
+
options = _.extend({}, option);
|
321 |
+
|
322 |
+
self.$el.empty();
|
323 |
+
|
324 |
+
self.fragment = document.createDocumentFragment();
|
325 |
+
|
326 |
+
self.appendModelElement( options );
|
327 |
+
|
328 |
+
self.$el.append( self.fragment );
|
329 |
+
|
330 |
+
return self;
|
331 |
+
},
|
332 |
+
appendModelElement:function( option ){
|
333 |
+
var self = this, view, el, options = option;
|
334 |
+
|
335 |
+
self.model.each(function(model){
|
336 |
+
|
337 |
+
try{
|
338 |
+
|
339 |
+
options = {
|
340 |
+
model:model
|
341 |
+
}
|
342 |
+
|
343 |
+
view = new WP_Toolset.HelpVideoListView({
|
344 |
+
model:model,
|
345 |
+
template_selector:'#toolset-video-list-template',
|
346 |
+
tagName:'li',
|
347 |
+
classes:'js-video-list toolset-video-list'
|
348 |
+
});
|
349 |
+
|
350 |
+
el = view.el;
|
351 |
+
|
352 |
+
self.fragment.appendChild( el );
|
353 |
+
|
354 |
+
}
|
355 |
+
catch( e )
|
356 |
+
{
|
357 |
+
console.error( e.message );
|
358 |
+
}
|
359 |
+
}, self)
|
360 |
+
|
361 |
+
return this;
|
362 |
+
},
|
363 |
+
create_element:function(){
|
364 |
+
return jQuery('<ul class="js-videos-list toolset-videos-list"></ul>');
|
365 |
+
}
|
366 |
+
});
|
367 |
+
|
368 |
+
(function ($) {
|
369 |
+
$(function () {
|
370 |
+
WP_Toolset.HelpVideos.main = {};
|
371 |
+
WP_Toolset.HelpVideosFactory.call(WP_Toolset.HelpVideos.main, $);
|
372 |
+
});
|
373 |
+
}(jQuery));
|
library/toolset/toolset-common/utility/help-videos/templates/help-video.tpl.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script type="text/html" id="toolset-video-template">
|
2 |
+
<# var wrap_height = parseInt(height) + 82;#>
|
3 |
+
<div class="toolset-box-container js-toolset-box-container" style="width:{{{width}}};height:{{{wrap_height}}}px;">
|
4 |
+
<div class="toolset-box toolset-box-video js-video-player-box hidden" id="js-video-player-box">
|
5 |
+
<div class="toolset-box-header">
|
6 |
+
<h2 class="js-video-box-title video-box-title-open js-video-box-title-open">{{{title}}}
|
7 |
+
<i class="fa fa-file-video-o toolset-video-icon"></i>
|
8 |
+
</h2>
|
9 |
+
|
10 |
+
</div>
|
11 |
+
|
12 |
+
<div class="toolset-box-content js-toolset-box-content">
|
13 |
+
<div class="js-video-container" style="width:{{{width}}};height:{{{height}}};">
|
14 |
+
<video class="js-video-player" src="{{{url}}}" width="{{{width}}}" height="{{{height}}}"/>
|
15 |
+
</div>
|
16 |
+
</div> <!-- .toolset-box-content -->
|
17 |
+
|
18 |
+
<div class="toolset-box-footer">
|
19 |
+
<button class="button js-edit-video-close js-remove-video remove-video"><?php _e('Minimize','ddl-layouts') ?></button>
|
20 |
+
<button class="button js-edit-video-detach js-detach-video remove-video"><?php _e('Open in a new window','ddl-layouts') ?></button>
|
21 |
+
</div>
|
22 |
+
|
23 |
+
</div> <!-- .toolset-box -->
|
24 |
+
|
25 |
+
</div> <!-- .toolset-boxs-container" -->
|
26 |
+
</script>
|
27 |
+
|
28 |
+
<script type="text/html" id="toolset-video-list-template">
|
29 |
+
{{{title}}}<i class="fa fa-file-video-o toolset-video-icon"></i>
|
30 |
+
</script>
|
31 |
+
|
32 |
+
<script type="text/html" id="toolset-video-header-template">
|
33 |
+
<h2 class="js-video-box-title video-box-title">{{{title}}}
|
34 |
+
<i class="fa fa-file-video-o toolset-video-icon"></i>
|
35 |
+
<i class="fa fa-caret-square-o-up toolset-video-closed js-edit-dialog-close remove-video-icon"></i>
|
36 |
+
</h2>
|
37 |
+
</script>
|
library/toolset/toolset-common/utility/help-videos/templates/tutorial-video-page.tpl.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="toolset-wrap">
|
2 |
+
<div class="toolset-videos-wrapper js-toolset-videos-wrapper">
|
3 |
+
<div id="<?php echo $element; ?>" class="<?php echo $element; ?>">
|
4 |
+
</div>
|
5 |
+
</div>
|
6 |
+
</div>
|
library/toolset/toolset-common/utility/help-videos/toolset-help-videos.php
ADDED
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if( !class_exists('Toolset_HelpVideo') ) {
|
4 |
+
|
5 |
+
class Toolset_HelpVideo extends stdClass
|
6 |
+
{
|
7 |
+
private $name = 'video';
|
8 |
+
private $url = '';
|
9 |
+
private $screens = array();
|
10 |
+
private $element = 'body';
|
11 |
+
private $width = 820;
|
12 |
+
private $height = 506;
|
13 |
+
private $title = 'Tutorial Video';
|
14 |
+
private $append_to = '';
|
15 |
+
private static $instances = array();
|
16 |
+
protected static $current = null;
|
17 |
+
const KEY = 'toolset_help_video';
|
18 |
+
const GENERIC_ELEMENT = 'toolset_video_wrap';
|
19 |
+
|
20 |
+
public function __construct(array $arguments = array())
|
21 |
+
{
|
22 |
+
|
23 |
+
if (empty($arguments)) return;
|
24 |
+
|
25 |
+
self::$current = isset($_REQUEST[self::KEY]) ? $_REQUEST[self::KEY] : null;
|
26 |
+
|
27 |
+
if (self::$current === null) return;
|
28 |
+
|
29 |
+
if (!empty($arguments)) {
|
30 |
+
foreach ($arguments as $property => $argument) {
|
31 |
+
$this->{$property} = $argument;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
add_filter('toolset_video_instances', array(&$this, 'push_tooolset_video_instances'), 10, 1);
|
36 |
+
add_filter('toolset_add_registered_script', array(&$this, 'add_register_scripts'));
|
37 |
+
add_filter('toolset_add_registered_styles', array(&$this, 'add_register_styles'));
|
38 |
+
add_action('admin_print_scripts', array(&$this, 'admin_enqueue_scripts'));
|
39 |
+
add_action('admin_footer', array(&$this, 'load_template'));
|
40 |
+
add_action( 'admin_footer', array(&$this, 'add_user_meta'), 999 );
|
41 |
+
}
|
42 |
+
|
43 |
+
public function add_user_meta(){
|
44 |
+
if( self::$current == null || $this->name != self::$current ) return;
|
45 |
+
add_user_meta( $this->get_current_user_id(), self::$current, 'seen', true );
|
46 |
+
}
|
47 |
+
|
48 |
+
private function get_current_user_id(){
|
49 |
+
global $current_user;
|
50 |
+
$current_user = wp_get_current_user();
|
51 |
+
$user_id = $current_user->ID;
|
52 |
+
return $user_id;
|
53 |
+
}
|
54 |
+
|
55 |
+
public function add_register_scripts($scripts)
|
56 |
+
{
|
57 |
+
$scripts[] = new Toolset_Script('toolset-help-video', TOOLSET_COMMON_URL . '/utility/help-videos/res/js/toolset-help-videos.js', array('jquery', 'underscore', 'backbone', 'wp-mediaelement', 'toolset-utils'), '1.0', true);
|
58 |
+
return $scripts;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function add_register_styles($styles)
|
62 |
+
{
|
63 |
+
$styles[] = new Toolset_Style('toolset-help-video', TOOLSET_COMMON_URL . '/utility/help-videos/res/css/toolset-help-videos.css');
|
64 |
+
return $styles;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function admin_enqueue_scripts()
|
68 |
+
{
|
69 |
+
if (
|
70 |
+
!is_admin()
|
71 |
+
|| !function_exists('get_current_screen')
|
72 |
+
) {
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
|
76 |
+
$screen = get_current_screen();
|
77 |
+
|
78 |
+
$this->screens[] = Toolset_VideoDetachedPage::get_screen();
|
79 |
+
|
80 |
+
if (!empty($this->screens) && !in_array($screen->id, $this->screens)) {
|
81 |
+
return;
|
82 |
+
}
|
83 |
+
|
84 |
+
$instances = apply_filters('toolset_video_instances', self::$instances);
|
85 |
+
$current = apply_filters('toolset_current_video', self::$current);
|
86 |
+
|
87 |
+
if (isset($instances[$current]) === false) return;
|
88 |
+
|
89 |
+
do_action('toolset_enqueue_scripts', array(
|
90 |
+
'toolset-help-video'
|
91 |
+
));
|
92 |
+
do_action('toolset_enqueue_styles', array(
|
93 |
+
'wp-mediaelement',
|
94 |
+
'font-awesome',
|
95 |
+
'toolset-help-video'
|
96 |
+
));
|
97 |
+
|
98 |
+
do_action('toolset_localize_script', 'toolset-help-video', 'WP_ToolsetVideoSettings', array(
|
99 |
+
'video_instances' => $instances,
|
100 |
+
'current' => $current,
|
101 |
+
'seen' => get_user_meta( $this->get_current_user_id(), self::$current, true ),
|
102 |
+
'detached_page' => Toolset_VideoDetachedPage::get_screen(),
|
103 |
+
'detach_url' => admin_url(sprintf('admin.php?page=toolset_video_tutorials&toolset_help_video=%s', $instances[$current]['name'])),
|
104 |
+
'GENERIC_ELEMENT' => self::GENERIC_ELEMENT,
|
105 |
+
'VIDEOS_LIST_TITLE' => sprintf(__('%sVideo Tutorials%s', 'toolset-common'), '<h2 class="js-videos-list-title">', '</h2>')
|
106 |
+
));
|
107 |
+
}
|
108 |
+
|
109 |
+
public function push_tooolset_video_instances($instances)
|
110 |
+
{
|
111 |
+
|
112 |
+
self::$instances[$this->name] = array(
|
113 |
+
'name' => $this->name,
|
114 |
+
'url' => $this->url,
|
115 |
+
'element' => $this->element,
|
116 |
+
'screens' => $this->screens,
|
117 |
+
'width' => $this->width,
|
118 |
+
'height' => $this->height,
|
119 |
+
'title' => $this->title,
|
120 |
+
'append_to' => $this->append_to
|
121 |
+
);
|
122 |
+
|
123 |
+
return self::$instances;
|
124 |
+
}
|
125 |
+
|
126 |
+
public function load_template()
|
127 |
+
{
|
128 |
+
include_once TOOLSET_COMMON_PATH . '/utility/help-videos/templates/help-video.tpl.php';
|
129 |
+
}
|
130 |
+
|
131 |
+
public static function get_current()
|
132 |
+
{
|
133 |
+
return isset(self::$instances[self::$current]) ? self::$instances[self::$current] : null;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
abstract class Toolset_HelpVideosFactoryAbstract
|
138 |
+
{
|
139 |
+
|
140 |
+
const WIDTH = '820px';
|
141 |
+
const HEIGHT = '506px';
|
142 |
+
protected $videos = array();
|
143 |
+
|
144 |
+
protected function __construct()
|
145 |
+
{
|
146 |
+
$this->process_videos();
|
147 |
+
}
|
148 |
+
|
149 |
+
final public static function getInstance()
|
150 |
+
{
|
151 |
+
static $instances = array();
|
152 |
+
$called_class = get_called_class();
|
153 |
+
if ( !isset($instances[$called_class]) && class_exists($called_class) ) {
|
154 |
+
$instances[$called_class] = new $called_class();
|
155 |
+
}
|
156 |
+
return isset( $instances[$called_class] ) ? $instances[$called_class] : null;
|
157 |
+
}
|
158 |
+
|
159 |
+
protected abstract function define_toolset_videos();
|
160 |
+
|
161 |
+
protected function process_videos()
|
162 |
+
{
|
163 |
+
|
164 |
+
$videos = $this->define_toolset_videos();
|
165 |
+
|
166 |
+
if (!$videos || empty($videos)) return;
|
167 |
+
|
168 |
+
foreach ($videos as $video) {
|
169 |
+
|
170 |
+
$video = wp_parse_args(
|
171 |
+
$video,
|
172 |
+
array('width' => self::WIDTH, 'height' => self::HEIGHT)
|
173 |
+
);
|
174 |
+
|
175 |
+
$this->videos[] = new Toolset_HelpVideo(
|
176 |
+
$video
|
177 |
+
);
|
178 |
+
}
|
179 |
+
return $this->videos;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
class Toolset_VideoDetachedPage
|
184 |
+
{
|
185 |
+
private static $instance;
|
186 |
+
const SLUG = 'toolset_video_tutorials';
|
187 |
+
const SCREEN = 'admin_page_toolset_video_tutorials';
|
188 |
+
|
189 |
+
protected function __construct()
|
190 |
+
{
|
191 |
+
if ( is_admin() && function_exists('add_submenu_page') ) {
|
192 |
+
add_submenu_page(null, __('Video Tutorial'), '', 'manage_options', self::SLUG, array(&$this, 'load_template'));
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
final public static function getInstance()
|
197 |
+
{
|
198 |
+
if (!self::$instance) {
|
199 |
+
self::$instance = new Toolset_VideoDetachedPage();
|
200 |
+
}
|
201 |
+
|
202 |
+
return self::$instance;
|
203 |
+
}
|
204 |
+
|
205 |
+
function load_template()
|
206 |
+
{
|
207 |
+
$current = Toolset_HelpVideo::get_current();
|
208 |
+
|
209 |
+
if (null === $current) {
|
210 |
+
printf(__('%sNo videos to play%s'), '<h2>', '</h2>');
|
211 |
+
} else {
|
212 |
+
$element = isset($current['element']) ? trim($current['element'], '.,#') : Toolset_HelpVideo::GENERIC_ELEMENT;
|
213 |
+
require_once TOOLSET_COMMON_PATH . '/utility/help-videos/templates/tutorial-video-page.tpl.php';
|
214 |
+
}
|
215 |
+
|
216 |
+
}
|
217 |
+
|
218 |
+
public static function get_screen()
|
219 |
+
{
|
220 |
+
return self::SCREEN;
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
add_action('init', array('Toolset_VideoDetachedPage', 'getInstance'), 99);
|
225 |
+
}
|
library/toolset/toolset-common/utility/js/utils.js
CHANGED
@@ -3,35 +3,10 @@
|
|
3 |
* @version 1.4
|
4 |
* @revision 18/01/2016 17:08
|
5 |
*/
|
6 |
-
|
7 |
//Backbone.Model Overrides
|
8 |
-
if( Backbone && Backbone.Model )
|
9 |
-
{
|
10 |
-
Backbone.Model.prototype._super = function(funcName){
|
11 |
-
if( funcName === undefined ) return null;
|
12 |
-
return this.constructor.prototype[funcName].apply(this, _.rest(arguments) );
|
13 |
-
};
|
14 |
-
// nested models! Might just override the internal representation of this...
|
15 |
-
_.extend(Backbone.Model.prototype, {
|
16 |
-
// Version of toJSON that traverses nested models
|
17 |
-
toJSON: function() {
|
18 |
-
var obj = _.clone(this.attributes);
|
19 |
-
_.each(_.keys(obj), function(key) {
|
20 |
-
if(!_.isUndefined(obj[key]) && !_.isNull(obj[key]) && _.isFunction(obj[key].toJSON)) {
|
21 |
-
obj[key] = obj[key].toJSON();
|
22 |
-
}
|
23 |
-
});
|
24 |
-
return obj;
|
25 |
-
}
|
26 |
-
});
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
toJSON: function() {
|
31 |
-
return this.map(function(model){ return model.toJSON(); });
|
32 |
-
}
|
33 |
-
});
|
34 |
-
}
|
35 |
//Backbone.View Overrides
|
36 |
if( Backbone && Backbone.View )
|
37 |
{
|
@@ -494,6 +469,9 @@ if (typeof jQuery.fn.wpvToolsetHelp === 'undefined') {
|
|
494 |
fadeInSpeed: 'fast',
|
495 |
fadeOutSpeed: 'fast',
|
496 |
displayLoader: true,
|
|
|
|
|
|
|
497 |
class: null
|
498 |
};
|
499 |
|
@@ -505,10 +483,14 @@ if (typeof jQuery.fn.wpvToolsetHelp === 'undefined') {
|
|
505 |
if (!$overlayContainer.data('has-overlay')) {
|
506 |
$overlayEl
|
507 |
.appendTo($overlayContainer)
|
|
|
508 |
.hide()
|
509 |
.fadeIn(prms.fadeInSpeed, function () {
|
510 |
$overlayContainer.data('has-overlay', true);
|
511 |
$overlayContainer.data('overlay-el', $overlayEl);
|
|
|
|
|
|
|
512 |
});
|
513 |
}
|
514 |
};
|
@@ -517,6 +499,9 @@ if (typeof jQuery.fn.wpvToolsetHelp === 'undefined') {
|
|
517 |
if ($overlayContainer.data('has-overlay')) {
|
518 |
$overlayContainer.data('overlay-el')
|
519 |
.fadeOut(prms.fadeOutSpeed, function () {
|
|
|
|
|
|
|
520 |
$overlayEl.remove();
|
521 |
$overlayContainer.data('has-overlay', false);
|
522 |
});
|
@@ -1232,7 +1217,7 @@ if (typeof _ !== 'undefined' && typeof _.capitalize === 'undefined') {
|
|
1232 |
WPV_Toolset.Utils.has_shortcode = function (string) {
|
1233 |
var search = /\[(\[?)(\w*?\-*?\w*?)*?(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*(?:\[(?!\/\2\])[^\[]*)*)(\[\/\2\]))?)(\]?)/g;
|
1234 |
return decodeURIComponent(string).search(search) !== -1;
|
1235 |
-
}
|
1236 |
|
1237 |
|
1238 |
/**
|
@@ -1261,23 +1246,455 @@ WPV_Toolset.Utils.versionCompare = function(left, right) {
|
|
1261 |
};
|
1262 |
|
1263 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1264 |
|
|
|
|
|
|
|
|
|
|
|
1265 |
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
|
|
|
|
|
|
1269 |
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1273 |
} else {
|
1274 |
-
|
|
|
|
|
|
|
|
|
|
|
1275 |
}
|
1276 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1277 |
|
1278 |
-
// override dialog whenever toolset is active and take possession
|
1279 |
-
jQuery.extend(jQuery.ui.dialog.prototype.options, {
|
1280 |
-
dialogClass:'toolset-ui-dialog'
|
1281 |
-
});
|
1282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1283 |
|
3 |
* @version 1.4
|
4 |
* @revision 18/01/2016 17:08
|
5 |
*/
|
|
|
6 |
//Backbone.Model Overrides
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
window.Toolset = window.Toolset || {};
|
9 |
+
|
|
|
|
|
|
|
|
|
|
|
10 |
//Backbone.View Overrides
|
11 |
if( Backbone && Backbone.View )
|
12 |
{
|
469 |
fadeInSpeed: 'fast',
|
470 |
fadeOutSpeed: 'fast',
|
471 |
displayLoader: true,
|
472 |
+
css:{
|
473 |
+
"opacity":"0.4"
|
474 |
+
},
|
475 |
class: null
|
476 |
};
|
477 |
|
483 |
if (!$overlayContainer.data('has-overlay')) {
|
484 |
$overlayEl
|
485 |
.appendTo($overlayContainer)
|
486 |
+
.css(prms.css)
|
487 |
.hide()
|
488 |
.fadeIn(prms.fadeInSpeed, function () {
|
489 |
$overlayContainer.data('has-overlay', true);
|
490 |
$overlayContainer.data('overlay-el', $overlayEl);
|
491 |
+
if( typeof options.onOpen === 'function' ){
|
492 |
+
options.onOpen.call(this, arguments);
|
493 |
+
}
|
494 |
});
|
495 |
}
|
496 |
};
|
499 |
if ($overlayContainer.data('has-overlay')) {
|
500 |
$overlayContainer.data('overlay-el')
|
501 |
.fadeOut(prms.fadeOutSpeed, function () {
|
502 |
+
if( options && typeof options.onRemove === 'function' ){
|
503 |
+
options.onRemove.call(this, arguments);
|
504 |
+
}
|
505 |
$overlayEl.remove();
|
506 |
$overlayContainer.data('has-overlay', false);
|
507 |
});
|
1217 |
WPV_Toolset.Utils.has_shortcode = function (string) {
|
1218 |
var search = /\[(\[?)(\w*?\-*?\w*?)*?(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*(?:\[(?!\/\2\])[^\[]*)*)(\[\/\2\]))?)(\]?)/g;
|
1219 |
return decodeURIComponent(string).search(search) !== -1;
|
1220 |
+
};
|
1221 |
|
1222 |
|
1223 |
/**
|
1246 |
};
|
1247 |
|
1248 |
|
1249 |
+
/**
|
1250 |
+
* Get a query argument value from a URL.
|
1251 |
+
*
|
1252 |
+
* @param {string} name Argument name.
|
1253 |
+
* @param {string} url Source URL. Optional. If missing, current page URL will be used.
|
1254 |
+
* @returns {string|null}
|
1255 |
+
* @since 2.1
|
1256 |
+
* @link http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
|
1257 |
+
*/
|
1258 |
+
WPV_Toolset.Utils.getParameterByName = function(name, url) {
|
1259 |
+
|
1260 |
+
if (!url) {
|
1261 |
+
url = window.location.href;
|
1262 |
+
}
|
1263 |
+
|
1264 |
+
name = name.replace(/[\[\]]/g, "\\$&");
|
1265 |
+
|
1266 |
+
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)", "i");
|
1267 |
|
1268 |
+
var results = regex.exec(url);
|
1269 |
+
|
1270 |
+
if(!results) {
|
1271 |
+
return null;
|
1272 |
+
}
|
1273 |
|
1274 |
+
if(!results[2]) {
|
1275 |
+
return '';
|
1276 |
+
}
|
1277 |
+
|
1278 |
+
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
1279 |
+
};
|
1280 |
|
1281 |
+
|
1282 |
+
/**
|
1283 |
+
* Add, update or remove query string argument.
|
1284 |
+
*
|
1285 |
+
* @param {string} key Argument name.
|
1286 |
+
* @param {string} [value] Argument value. Not supplying a value will remove the parameter, supplying one will
|
1287 |
+
* add/update the argument.
|
1288 |
+
* @param {string} [url] If no URL is supplied, it will be grabbed from window.location
|
1289 |
+
* @returns {string}
|
1290 |
+
* @link http://stackoverflow.com/a/11654596/3191395
|
1291 |
+
*/
|
1292 |
+
WPV_Toolset.Utils.updateUrlQuery = function(key, value, url) {
|
1293 |
+
if(!url) {
|
1294 |
+
url = window.location.href;
|
1295 |
+
}
|
1296 |
+
var re = new RegExp("([?&])" + key + "=.*?(&|#|$)(.*)", "gi");
|
1297 |
+
var hash;
|
1298 |
+
|
1299 |
+
if (re.test(url)) {
|
1300 |
+
if (typeof value !== 'undefined' && value !== null) {
|
1301 |
+
return url.replace(re, '$1' + key + "=" + value + '$2$3');
|
1302 |
} else {
|
1303 |
+
hash = url.split('#');
|
1304 |
+
url = hash[0].replace(re, '$1$3').replace(/(&|\?)$/, '');
|
1305 |
+
if(typeof hash[1] !== 'undefined' && hash[1] !== null) {
|
1306 |
+
url += '#' + hash[1];
|
1307 |
+
}
|
1308 |
+
return url;
|
1309 |
}
|
1310 |
+
} else {
|
1311 |
+
if (typeof value !== 'undefined' && value !== null) {
|
1312 |
+
var separator = url.indexOf('?') !== -1 ? '&' : '?';
|
1313 |
+
hash = url.split('#');
|
1314 |
+
url = hash[0] + separator + key + '=' + value;
|
1315 |
+
if (typeof hash[1] !== 'undefined' && hash[1] !== null) {
|
1316 |
+
url += '#' + hash[1];
|
1317 |
+
}
|
1318 |
+
return url;
|
1319 |
+
} else {
|
1320 |
+
return url;
|
1321 |
+
}
|
1322 |
+
}
|
1323 |
+
};
|
1324 |
|
|
|
|
|
|
|
|
|
1325 |
|
1326 |
+
/**
|
1327 |
+
* Tools for manipulating spinners in a native WP way.
|
1328 |
+
*
|
1329 |
+
* If WP changes the behaviour, we'll need only to update this object.
|
1330 |
+
*
|
1331 |
+
* @type {{create: WPV_Toolset.Utils.Spinner.create, show: WPV_Toolset.Utils.Spinner.show, hide: WPV_Toolset.Utils.Spinner.hide, find: WPV_Toolset.Utils.Spinner.find}}
|
1332 |
+
*/
|
1333 |
+
WPV_Toolset.Utils.Spinner = {
|
1334 |
+
create: function() {
|
1335 |
+
return jQuery('<span class="spinner"></span>');
|
1336 |
+
},
|
1337 |
+
show: function(spinner, show) {
|
1338 |
+
if(typeof(show) == 'undefined') {
|
1339 |
+
show = true;
|
1340 |
+
}
|
1341 |
+
|
1342 |
+
if(!show) {
|
1343 |
+
WPV_Toolset.Utils.Spinner.hide(spinner);
|
1344 |
+
return;
|
1345 |
+
}
|
1346 |
+
|
1347 |
+
spinner.addClass('is-active');
|
1348 |
+
},
|
1349 |
+
hide: function(spinner) {
|
1350 |
+
spinner.removeClass('is-active');
|
1351 |
+
},
|
1352 |
+
find: function(parentElement) {
|
1353 |
+
return parentElement.find('.spinner');
|
1354 |
+
}
|
1355 |
+
};
|
1356 |
+
|
1357 |
+
|
1358 |
+
/**
|
1359 |
+
* AJAX call helper.
|
1360 |
+
*
|
1361 |
+
* WIP, to be merged with WPV_Toolset.Utils.do_ajax_post().
|
1362 |
+
*
|
1363 |
+
* @type {{parseResponse: WPV_Toolset.Utils.Ajax.parseResponse, call: WPV_Toolset.Utils.Ajax.call}}
|
1364 |
+
* @since 2.1
|
1365 |
+
*/
|
1366 |
+
WPV_Toolset.Utils.Ajax = {
|
1367 |
+
|
1368 |
+
/**
|
1369 |
+
* Ensure that response is always an object with the success property.
|
1370 |
+
*
|
1371 |
+
* If it's not, return a dummy object indicating a failure.
|
1372 |
+
*
|
1373 |
+
* @param response {*} Response from the AJAX call.
|
1374 |
+
* @returns {{success: boolean}} Sanitized response.
|
1375 |
+
*
|
1376 |
+
* @since 2.1
|
1377 |
+
*/
|
1378 |
+
parseResponse: function(response) {
|
1379 |
+
if( typeof(response.success) === 'undefined' ) {
|
1380 |
+
console.log("parseResponse: no success value", response);
|
1381 |
+
return { success: false };
|
1382 |
+
} else {
|
1383 |
+
return response;
|
1384 |
+
}
|
1385 |
+
},
|
1386 |
+
|
1387 |
+
|
1388 |
+
/**
|
1389 |
+
* Perform an AJAX call on field definitions.
|
1390 |
+
*
|
1391 |
+
* @param {*} data AJAX call parameters. Needs to include 'action' and 'wpnonce'.
|
1392 |
+
* @param {function} successCallback Callback to be used after AJAX call is completed. It will get two parameters,
|
1393 |
+
* the complete AJAX response and the 'data' element for convenience.
|
1394 |
+
* @param {function} [failCallback] Analogous to successCallback for the case of failure. If missing,
|
1395 |
+
* successCallback will be used instead.
|
1396 |
+
*
|
1397 |
+
* @since 2.1
|
1398 |
+
*/
|
1399 |
+
call: function(data, successCallback, failCallback) {
|
1400 |
+
|
1401 |
+
if( typeof(failCallback) == 'undefined' ) {
|
1402 |
+
failCallback = successCallback;
|
1403 |
+
}
|
1404 |
+
|
1405 |
+
jQuery.post({
|
1406 |
+
async: true,
|
1407 |
+
url: ajaxurl,
|
1408 |
+
data: data,
|
1409 |
+
|
1410 |
+
success: function(originalResponse) {
|
1411 |
+
var response = WPV_Toolset.Utils.Ajax.parseResponse(originalResponse);
|
1412 |
+
|
1413 |
+
if(response.success) {
|
1414 |
+
successCallback(response, response.data || {});
|
1415 |
+
} else {
|
1416 |
+
failCallback(response, response.data || {});
|
1417 |
+
}
|
1418 |
+
},
|
1419 |
+
|
1420 |
+
error: function( ajaxContext ) {
|
1421 |
+
console.log('Error:', ajaxContext.responseText);
|
1422 |
+
failCallback({ success: false, data: {} }, {});
|
1423 |
+
}
|
1424 |
+
});
|
1425 |
+
|
1426 |
+
}
|
1427 |
+
|
1428 |
+
};
|
1429 |
+
|
1430 |
+
|
1431 |
+
WPV_Toolset.Utils._template = function( template, data, settings ){
|
1432 |
+
var options = _.defaults({}, settings, _.templateSettings),
|
1433 |
+
_template = null;
|
1434 |
+
|
1435 |
+
if( WPV_Toolset.Utils.versionCompare(_.VERSION, '1.7') >= 0 ){
|
1436 |
+
_template = _.template(template, options);
|
1437 |
+
return _template(data);
|
1438 |
+
} else {
|
1439 |
+
return _.template(template, data, options);
|
1440 |
+
}
|
1441 |
+
};
|
1442 |
+
|
1443 |
+
// override dialog whenever toolset is active and take possession
|
1444 |
+
jQuery.extend(jQuery.ui.dialog.prototype.options, {
|
1445 |
+
dialogClass:'toolset-ui-dialog'
|
1446 |
+
});
|
1447 |
+
|
1448 |
+
|
1449 |
+
if ( typeof Toolset.add_qt_editor_buttons !== 'function' ) {
|
1450 |
+
Toolset.add_qt_editor_buttons = function( qt_instance, editor_instance ) {
|
1451 |
+
var activeUrlEditor, html;
|
1452 |
+
QTags._buttonsInit();
|
1453 |
+
var editorInstance = {};
|
1454 |
+
editorInstance[qt_instance.id] = editor_instance;
|
1455 |
+
|
1456 |
+
for ( var button_name in qt_instance.theButtons ) {
|
1457 |
+
if ( qt_instance.theButtons.hasOwnProperty( button_name ) ) {
|
1458 |
+
qt_instance.theButtons[button_name].old_callback = qt_instance.theButtons[button_name].callback;
|
1459 |
+
if ( qt_instance.theButtons[button_name].id == 'img' ){
|
1460 |
+
qt_instance.theButtons[button_name].callback = function( element, canvas, ed ) {
|
1461 |
+
var t = this,
|
1462 |
+
id = jQuery( canvas ).attr( 'id' ),
|
1463 |
+
selection = editorInstance[id].getSelection(),
|
1464 |
+
e = "http://",
|
1465 |
+
g = prompt( quicktagsL10n.enterImageURL, e ),
|
1466 |
+
f = prompt( quicktagsL10n.enterImageDescription, "" );
|
1467 |
+
t.tagStart = '<img src="'+g+'" alt="'+f+'" />';
|
1468 |
+
selection = t.tagStart;
|
1469 |
+
t.closeTag( element, ed );
|
1470 |
+
editorInstance[id].replaceSelection( selection, 'end' );
|
1471 |
+
editorInstance[id].focus();
|
1472 |
+
}
|
1473 |
+
} else if ( qt_instance.theButtons[button_name].id == 'close' ) {
|
1474 |
+
|
1475 |
+
} else if ( qt_instance.theButtons[button_name].id == 'link' ) {
|
1476 |
+
var t = this;
|
1477 |
+
qt_instance.theButtons[button_name].callback =
|
1478 |
+
function ( b, c, d, e ) {
|
1479 |
+
activeUrlEditor = c;
|
1480 |
+
var f,g=this;
|
1481 |
+
return "undefined" != typeof wpLink ?void wpLink.open(d.id) : (e||(e="http://"), void(g.isOpen(d)===!1 ? (f=prompt(quicktagsL10n.enterURL,e), f && (g.tagStart='<a href="'+f+'">', a.TagButton.prototype.callback.call(g,b,c,d))) : a.TagButton.prototype.callback.call(g,b,c,d)))
|
1482 |
+
};
|
1483 |
+
jQuery( '#wp-link-submit' ).off();
|
1484 |
+
jQuery( '#wp-link-submit' ).on( 'click', function( event ) {
|
1485 |
+
event.preventDefault();
|
1486 |
+
if ( wpLink.isMCE() ) {
|
1487 |
+
wpLink.mceUpdate();
|
1488 |
+
} else {
|
1489 |
+
var id = jQuery( activeUrlEditor ).attr('id'),
|
1490 |
+
selection = editorInstance[id].getSelection(),
|
1491 |
+
inputs = {},
|
1492 |
+
attrs, text, title, html;
|
1493 |
+
inputs.wrap = jQuery('#wp-link-wrap');
|
1494 |
+
inputs.backdrop = jQuery( '#wp-link-backdrop' );
|
1495 |
+
if ( jQuery( '#link-target-checkbox' ).length > 0 ) {
|
1496 |
+
// Backwards compatibility - before WordPress 4.2
|
1497 |
+
inputs.text = jQuery( '#link-title-field' );
|
1498 |
+
attrs = wpLink.getAttrs();
|
1499 |
+
text = inputs.text.val();
|
1500 |
+
if ( ! attrs.href ) {
|
1501 |
+
return;
|
1502 |
+
}
|
1503 |
+
// Build HTML
|
1504 |
+
html = '<a href="' + attrs.href + '"';
|
1505 |
+
if ( attrs.target ) {
|
1506 |
+
html += ' target="' + attrs.target + '"';
|
1507 |
+
}
|
1508 |
+
if ( text ) {
|
1509 |
+
title = text.replace( /</g, '<' ).replace( />/g, '>' ).replace( /"/g, '"' );
|
1510 |
+
html += ' title="' + title + '"';
|
1511 |
+
}
|
1512 |
+
html += '>';
|
1513 |
+
html += text || selection;
|
1514 |
+
html += '</a>';
|
1515 |
+
t.tagStart = html;
|
1516 |
+
selection = t.tagStart;
|
1517 |
+
} else {
|
1518 |
+
// WordPress 4.2+
|
1519 |
+
inputs.text = jQuery( '#wp-link-text' );
|
1520 |
+
attrs = wpLink.getAttrs();
|
1521 |
+
text = inputs.text.val();
|
1522 |
+
if ( ! attrs.href ) {
|
1523 |
+
return;
|
1524 |
+
}
|
1525 |
+
// Build HTML
|
1526 |
+
html = '<a href="' + attrs.href + '"';
|
1527 |
+
if ( attrs.target ) {
|
1528 |
+
html += ' target="' + attrs.target + '"';
|
1529 |
+
}
|
1530 |
+
html += '>';
|
1531 |
+
html += text || selection;
|
1532 |
+
html += '</a>';
|
1533 |
+
selection = html;
|
1534 |
+
}
|
1535 |
+
jQuery( document.body ).removeClass( 'modal-open' );
|
1536 |
+
inputs.backdrop.hide();
|
1537 |
+
inputs.wrap.hide();
|
1538 |
+
jQuery( document ).trigger( 'wplink-close', inputs.wrap );
|
1539 |
+
editorInstance[id].replaceSelection( selection, 'end' );
|
1540 |
+
editorInstance[id].focus();
|
1541 |
+
return false;
|
1542 |
+
}
|
1543 |
+
});
|
1544 |
+
} else {
|
1545 |
+
qt_instance.theButtons[button_name].callback = function( element, canvas, ed ) {
|
1546 |
+
var id = jQuery( canvas ).attr( 'id' ),
|
1547 |
+
t = this,
|
1548 |
+
selection = editorInstance[id].getSelection();
|
1549 |
+
if ( selection.length > 0 ) {
|
1550 |
+
if ( !t.tagEnd ) {
|
1551 |
+
selection = selection + t.tagStart;
|
1552 |
+
} else {
|
1553 |
+
selection = t.tagStart + selection + t.tagEnd;
|
1554 |
+
}
|
1555 |
+
} else {
|
1556 |
+
if ( !t.tagEnd ) {
|
1557 |
+
selection = t.tagStart;
|
1558 |
+
} else if ( t.isOpen( ed ) === false ) {
|
1559 |
+
selection = t.tagStart;
|
1560 |
+
t.openTag( element, ed );
|
1561 |
+
} else {
|
1562 |
+
selection = t.tagEnd;
|
1563 |
+
t.closeTag( element, ed );
|
1564 |
+
}
|
1565 |
+
}
|
1566 |
+
editorInstance[id].replaceSelection(selection, 'end');
|
1567 |
+
editorInstance[id].focus();
|
1568 |
+
}
|
1569 |
+
}
|
1570 |
+
}
|
1571 |
+
}
|
1572 |
+
}
|
1573 |
+
}
|
1574 |
+
|
1575 |
+
if ( typeof Toolset.add_qt_editor_buttons !== 'function' ) {
|
1576 |
+
Toolset.add_qt_editor_buttons = function( qt_instance, editor_instance ) {
|
1577 |
+
var activeUrlEditor, html;
|
1578 |
+
QTags._buttonsInit();
|
1579 |
+
var editorInstance = {};
|
1580 |
+
editorInstance[qt_instance.id] = editor_instance;
|
1581 |
+
|
1582 |
+
for ( var button_name in qt_instance.theButtons ) {
|
1583 |
+
if ( qt_instance.theButtons.hasOwnProperty( button_name ) ) {
|
1584 |
+
qt_instance.theButtons[button_name].old_callback = qt_instance.theButtons[button_name].callback;
|
1585 |
+
if ( qt_instance.theButtons[button_name].id == 'img' ){
|
1586 |
+
qt_instance.theButtons[button_name].callback = function( element, canvas, ed ) {
|
1587 |
+
var t = this,
|
1588 |
+
id = jQuery( canvas ).attr( 'id' ),
|
1589 |
+
selection = editorInstance[id].getSelection(),
|
1590 |
+
e = "http://",
|
1591 |
+
g = prompt( quicktagsL10n.enterImageURL, e ),
|
1592 |
+
f = prompt( quicktagsL10n.enterImageDescription, "" );
|
1593 |
+
t.tagStart = '<img src="'+g+'" alt="'+f+'" />';
|
1594 |
+
selection = t.tagStart;
|
1595 |
+
t.closeTag( element, ed );
|
1596 |
+
editorInstance[id].replaceSelection( selection, 'end' );
|
1597 |
+
editorInstance[id].focus();
|
1598 |
+
}
|
1599 |
+
} else if ( qt_instance.theButtons[button_name].id == 'close' ) {
|
1600 |
+
|
1601 |
+
} else if ( qt_instance.theButtons[button_name].id == 'link' ) {
|
1602 |
+
var t = this;
|
1603 |
+
qt_instance.theButtons[button_name].callback =
|
1604 |
+
function ( b, c, d, e ) {
|
1605 |
+
activeUrlEditor = c;
|
1606 |
+
var f,g=this;
|
1607 |
+
return "undefined" != typeof wpLink ?void wpLink.open(d.id) : (e||(e="http://"), void(g.isOpen(d)===!1 ? (f=prompt(quicktagsL10n.enterURL,e), f && (g.tagStart='<a href="'+f+'">', a.TagButton.prototype.callback.call(g,b,c,d))) : a.TagButton.prototype.callback.call(g,b,c,d)))
|
1608 |
+
};
|
1609 |
+
jQuery( '#wp-link-submit' ).off();
|
1610 |
+
jQuery( '#wp-link-submit' ).on( 'click', function( event ) {
|
1611 |
+
event.preventDefault();
|
1612 |
+
if ( wpLink.isMCE() ) {
|
1613 |
+
wpLink.mceUpdate();
|
1614 |
+
} else {
|
1615 |
+
var id = jQuery( activeUrlEditor ).attr('id'),
|
1616 |
+
selection = editorInstance[id].getSelection(),
|
1617 |
+
inputs = {},
|
1618 |
+
attrs, text, title, html;
|
1619 |
+
inputs.wrap = jQuery('#wp-link-wrap');
|
1620 |
+
inputs.backdrop = jQuery( '#wp-link-backdrop' );
|
1621 |
+
if ( jQuery( '#link-target-checkbox' ).length > 0 ) {
|
1622 |
+
// Backwards compatibility - before WordPress 4.2
|
1623 |
+
inputs.text = jQuery( '#link-title-field' );
|
1624 |
+
attrs = wpLink.getAttrs();
|
1625 |
+
text = inputs.text.val();
|
1626 |
+
if ( ! attrs.href ) {
|
1627 |
+
return;
|
1628 |
+
}
|
1629 |
+
// Build HTML
|
1630 |
+
html = '<a href="' + attrs.href + '"';
|
1631 |
+
if ( attrs.target ) {
|
1632 |
+
html += ' target="' + attrs.target + '"';
|
1633 |
+
}
|
1634 |
+
if ( text ) {
|
1635 |
+
title = text.replace( /</g, '<' ).replace( />/g, '>' ).replace( /"/g, '"' );
|
1636 |
+
html += ' title="' + title + '"';
|
1637 |
+
}
|
1638 |
+
html += '>';
|
1639 |
+
html += text || selection;
|
1640 |
+
html += '</a>';
|
1641 |
+
t.tagStart = html;
|
1642 |
+
selection = t.tagStart;
|
1643 |
+
} else {
|
1644 |
+
// WordPress 4.2+
|
1645 |
+
inputs.text = jQuery( '#wp-link-text' );
|
1646 |
+
attrs = wpLink.getAttrs();
|
1647 |
+
text = inputs.text.val();
|
1648 |
+
if ( ! attrs.href ) {
|
1649 |
+
return;
|
1650 |
+
}
|
1651 |
+
// Build HTML
|
1652 |
+
html = '<a href="' + attrs.href + '"';
|
1653 |
+
if ( attrs.target ) {
|
1654 |
+
html += ' target="' + attrs.target + '"';
|
1655 |
+
}
|
1656 |
+
html += '>';
|
1657 |
+
html += text || selection;
|
1658 |
+
html += '</a>';
|
1659 |
+
selection = html;
|
1660 |
+
}
|
1661 |
+
jQuery( document.body ).removeClass( 'modal-open' );
|
1662 |
+
inputs.backdrop.hide();
|
1663 |
+
inputs.wrap.hide();
|
1664 |
+
jQuery( document ).trigger( 'wplink-close', inputs.wrap );
|
1665 |
+
editorInstance[id].replaceSelection( selection, 'end' );
|
1666 |
+
editorInstance[id].focus();
|
1667 |
+
return false;
|
1668 |
+
}
|
1669 |
+
});
|
1670 |
+
} else {
|
1671 |
+
qt_instance.theButtons[button_name].callback = function( element, canvas, ed ) {
|
1672 |
+
var id = jQuery( canvas ).attr( 'id' ),
|
1673 |
+
t = this,
|
1674 |
+
selection = editorInstance[id].getSelection();
|
1675 |
+
if ( selection.length > 0 ) {
|
1676 |
+
if ( !t.tagEnd ) {
|
1677 |
+
selection = selection + t.tagStart;
|
1678 |
+
} else {
|
1679 |
+
selection = t.tagStart + selection + t.tagEnd;
|
1680 |
+
}
|
1681 |
+
} else {
|
1682 |
+
if ( !t.tagEnd ) {
|
1683 |
+
selection = t.tagStart;
|
1684 |
+
} else if ( t.isOpen( ed ) === false ) {
|
1685 |
+
selection = t.tagStart;
|
1686 |
+
t.openTag( element, ed );
|
1687 |
+
} else {
|
1688 |
+
selection = t.tagEnd;
|
1689 |
+
t.closeTag( element, ed );
|
1690 |
+
}
|
1691 |
+
}
|
1692 |
+
editorInstance[id].replaceSelection(selection, 'end');
|
1693 |
+
editorInstance[id].focus();
|
1694 |
+
}
|
1695 |
+
}
|
1696 |
+
}
|
1697 |
+
}
|
1698 |
+
}
|
1699 |
+
}
|
1700 |
|
library/toolset/toolset-common/utility/utils.php
CHANGED
@@ -1,70 +1,69 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
-
|
4 |
-
return;
|
5 |
}
|
6 |
|
7 |
-
define(
|
8 |
|
9 |
/**
|
10 |
-
* utils.php
|
11 |
-
*
|
12 |
-
* A collection of .php utility functions for common use
|
13 |
-
*
|
14 |
-
* @package ToolsetCommon
|
15 |
-
*
|
16 |
-
* @since unknown
|
17 |
-
*/
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
public static function get_image_sizes(
|
68 |
|
69 |
global $_wp_additional_image_sizes;
|
70 |
|
@@ -72,205 +71,208 @@ if ( ! class_exists( 'Toolset_Utils' ) ) {
|
|
72 |
$get_intermediate_image_sizes = get_intermediate_image_sizes();
|
73 |
|
74 |
// Create the full array with sizes and crop info
|
75 |
-
foreach(
|
76 |
-
|
77 |
-
if ( in_array( $_size, array( 'thumbnail', 'medium', 'large' ) ) ) {
|
78 |
|
79 |
-
|
80 |
-
$sizes[ $_size ]['height'] = get_option( $_size . '_size_h' );
|
81 |
-
$sizes[ $_size ]['crop'] = (bool) get_option( $_size . '_crop' );
|
82 |
|
83 |
-
|
|
|
|
|
|
|
84 |
|
85 |
-
$sizes[
|
86 |
-
'width' => $_wp_additional_image_sizes[
|
87 |
-
'height' => $_wp_additional_image_sizes[
|
88 |
-
'crop' =>
|
89 |
);
|
90 |
-
|
91 |
}
|
92 |
-
|
93 |
}
|
94 |
|
95 |
// Get only 1 size if found
|
96 |
-
if (
|
97 |
|
98 |
-
if(
|
99 |
-
return $sizes[
|
100 |
} else {
|
101 |
return false;
|
102 |
}
|
103 |
-
|
104 |
}
|
105 |
|
106 |
return $sizes;
|
107 |
}
|
108 |
|
109 |
-
|
110 |
-
|
111 |
}
|
112 |
|
113 |
-
if (
|
114 |
-
|
|
|
115 |
/*
|
116 |
* json_encode() has had extra params added over the years.
|
117 |
* $options was added in 5.3, and $depth in 5.5.
|
118 |
* We need to make sure we call it with the correct arguments.
|
119 |
*/
|
120 |
-
if (
|
121 |
-
$args = array(
|
122 |
-
} elseif (
|
123 |
-
$args = array(
|
124 |
} else {
|
125 |
-
$args = array(
|
126 |
}
|
127 |
|
128 |
-
$json = call_user_func_array(
|
129 |
|
130 |
// If json_encode() was successful, no need to do more sanity checking.
|
131 |
// ... unless we're in an old version of PHP, and json_encode() returned
|
132 |
// a string containing 'null'. Then we need to do more sanity checking.
|
133 |
-
if (
|
134 |
return $json;
|
135 |
}
|
136 |
|
137 |
try {
|
138 |
-
$args[0] = _wp_json_sanity_check(
|
139 |
-
} catch (
|
140 |
return false;
|
141 |
}
|
142 |
|
143 |
-
return call_user_func_array(
|
144 |
}
|
145 |
|
146 |
-
if (
|
147 |
-
|
148 |
-
|
149 |
-
|
|
|
150 |
}
|
151 |
|
152 |
-
if (
|
153 |
$output = array();
|
154 |
-
foreach (
|
155 |
// Don't forget to sanitize the ID!
|
156 |
-
if (
|
157 |
-
$clean_id = _wp_json_convert_string(
|
158 |
} else {
|
159 |
$clean_id = $id;
|
160 |
}
|
161 |
|
162 |
// Check the element type, so that we're only recursing if we really have to.
|
163 |
-
if (
|
164 |
-
$output[
|
165 |
-
} elseif (
|
166 |
-
$output[
|
167 |
} else {
|
168 |
-
$output[
|
169 |
}
|
170 |
}
|
171 |
-
} elseif (
|
172 |
$output = new stdClass;
|
173 |
-
foreach (
|
174 |
-
if (
|
175 |
-
$clean_id = _wp_json_convert_string(
|
176 |
} else {
|
177 |
$clean_id = $id;
|
178 |
}
|
179 |
|
180 |
-
if (
|
181 |
-
$output->$clean_id = _wp_json_sanity_check(
|
182 |
-
} elseif (
|
183 |
-
$output->$clean_id = _wp_json_convert_string(
|
184 |
} else {
|
185 |
$output->$clean_id = $el;
|
186 |
}
|
187 |
}
|
188 |
-
} elseif (
|
189 |
-
return _wp_json_convert_string(
|
190 |
} else {
|
191 |
return $data;
|
192 |
}
|
193 |
|
194 |
return $output;
|
195 |
}
|
|
|
196 |
}
|
197 |
|
198 |
-
if(!function_exists('_wp_json_convert_string')) {
|
199 |
-
|
|
|
200 |
static $use_mb = null;
|
201 |
-
if (
|
202 |
-
$use_mb = function_exists(
|
203 |
}
|
204 |
|
205 |
-
if (
|
206 |
-
$encoding = mb_detect_encoding(
|
207 |
-
if (
|
208 |
-
return mb_convert_encoding(
|
209 |
} else {
|
210 |
-
return mb_convert_encoding(
|
211 |
}
|
212 |
} else {
|
213 |
-
return wp_check_invalid_utf8(
|
214 |
}
|
215 |
}
|
|
|
216 |
}
|
217 |
}
|
218 |
|
219 |
-
if(
|
220 |
-
|
|
|
|
|
221 |
private $value = null;
|
222 |
private $property = null;
|
223 |
|
224 |
-
function __construct($property = null, $value = null
|
225 |
$this->value = $value;
|
226 |
$this->property = $property;
|
227 |
}
|
228 |
|
229 |
-
function filter_array($element)
|
230 |
-
{
|
231 |
if (is_object($element)) {
|
232 |
|
233 |
-
if (property_exists($element, $this->property) === false)
|
|
|
234 |
|
235 |
return $element->{$this->property} === $this->value;
|
236 |
-
|
237 |
} elseif (is_array($element)) {
|
238 |
|
239 |
-
if (
|
|
|
240 |
|
241 |
return $element[$this->property] === $this->value;
|
242 |
-
|
243 |
} else {
|
244 |
|
245 |
throw new Exception(sprintf("Element parameter should be an object or an array, %s given.", gettype($element)));
|
246 |
-
|
247 |
}
|
248 |
}
|
249 |
|
250 |
-
public function remap_by_property(
|
251 |
return $data[$this->property];
|
252 |
}
|
253 |
|
254 |
-
function value_in_array(
|
255 |
-
return in_array(
|
256 |
}
|
257 |
|
258 |
-
function sort_string_ascendant(
|
259 |
return strcmp($a[$this->property], $b[$this->property]);
|
260 |
}
|
|
|
261 |
}
|
|
|
262 |
}
|
263 |
|
264 |
|
265 |
|
266 |
-
if(
|
267 |
|
268 |
/**
|
269 |
* ErrorHandler that can be used to catch internal PHP errors
|
270 |
* and convert to an ErrorException instance.
|
271 |
*/
|
272 |
-
abstract class Toolset_ErrorHandler
|
273 |
-
|
274 |
/**
|
275 |
* Active stack
|
276 |
*
|
@@ -283,8 +285,7 @@ if( !class_exists('Toolset_ErrorHandler') ){
|
|
283 |
*
|
284 |
* @return bool
|
285 |
*/
|
286 |
-
public static function started()
|
287 |
-
{
|
288 |
return (bool) self::getNestedLevel();
|
289 |
}
|
290 |
|
@@ -293,8 +294,7 @@ if( !class_exists('Toolset_ErrorHandler') ){
|
|
293 |
*
|
294 |
* @return int
|
295 |
*/
|
296 |
-
public static function getNestedLevel()
|
297 |
-
{
|
298 |
return count(self::$stack);
|
299 |
}
|
300 |
|
@@ -303,11 +303,10 @@ if( !class_exists('Toolset_ErrorHandler') ){
|
|
303 |
*
|
304 |
* @param int $errorLevel
|
305 |
*/
|
306 |
-
public static function start($errorLevel = E_WARNING)
|
307 |
-
{
|
308 |
if (!self::$stack) {
|
309 |
set_error_handler(array(get_called_class(), 'addError'), $errorLevel);
|
310 |
-
register_shutdown_function(
|
311 |
}
|
312 |
|
313 |
self::$stack[] = null;
|
@@ -320,8 +319,7 @@ if( !class_exists('Toolset_ErrorHandler') ){
|
|
320 |
* @return null|ErrorException
|
321 |
* @throws ErrorException If an error has been catched and $throw is true
|
322 |
*/
|
323 |
-
public static function stop($throw = false)
|
324 |
-
{
|
325 |
$errorException = null;
|
326 |
|
327 |
if (self::$stack) {
|
@@ -339,18 +337,17 @@ if( !class_exists('Toolset_ErrorHandler') ){
|
|
339 |
return $errorException;
|
340 |
}
|
341 |
|
342 |
-
|
343 |
-
|
344 |
-
if( self::is_fatal() ){
|
345 |
do_action('toolset-shutdown-hander');
|
346 |
}
|
347 |
exit;
|
348 |
}
|
349 |
|
350 |
-
public static function is_fatal(){
|
351 |
$error = error_get_last();
|
352 |
$ignore = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_STRICT | E_DEPRECATED | E_USER_DEPRECATED;
|
353 |
-
if (
|
354 |
return true;
|
355 |
}
|
356 |
return false;
|
@@ -361,8 +358,7 @@ if( !class_exists('Toolset_ErrorHandler') ){
|
|
361 |
*
|
362 |
* @return void
|
363 |
*/
|
364 |
-
public static function clean()
|
365 |
-
{
|
366 |
if (self::$stack) {
|
367 |
restore_error_handler();
|
368 |
}
|
@@ -379,16 +375,17 @@ if( !class_exists('Toolset_ErrorHandler') ){
|
|
379 |
* @param int $errline
|
380 |
* @return void
|
381 |
*/
|
382 |
-
public static function addError(
|
383 |
-
|
384 |
-
|
385 |
-
$stack = & self::$stack[count(self::$stack) - 1];
|
386 |
} else {
|
387 |
$stack = null;
|
388 |
}
|
389 |
-
$stack = new ErrorException(
|
390 |
}
|
|
|
391 |
}
|
|
|
392 |
}
|
393 |
|
394 |
/**
|
@@ -397,19 +394,24 @@ if( !class_exists('Toolset_ErrorHandler') ){
|
|
397 |
* get_called_class() is only in PHP >= 5.3, this is a workaround.
|
398 |
* This function is needed by WPDDL_Theme_Integration_Abstract.
|
399 |
*/
|
400 |
-
if (
|
|
|
401 |
function get_called_class() {
|
402 |
$bt = debug_backtrace();
|
403 |
$l = 0;
|
|
|
404 |
do {
|
405 |
$l++;
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
|
|
|
|
410 |
|
411 |
-
return $matches[1];
|
412 |
}
|
|
|
413 |
}
|
414 |
|
415 |
|
@@ -426,10 +428,12 @@ if ( !function_exists( 'get_called_class' ) ) {
|
|
426 |
*
|
427 |
* @since 1.8
|
428 |
*/
|
429 |
-
if(
|
430 |
-
|
431 |
-
|
|
|
432 |
}
|
|
|
433 |
}
|
434 |
|
435 |
|
@@ -450,9 +454,9 @@ if( !function_exists('toolset_getget') ){
|
|
450 |
*
|
451 |
* @since 1.8
|
452 |
*/
|
453 |
-
if(
|
454 |
-
|
455 |
-
{
|
456 |
if (isset($source[$key])) {
|
457 |
$val = $source[$key];
|
458 |
if (is_array($valid) && !in_array($val, $valid)) {
|
@@ -464,4 +468,5 @@ if( !function_exists('toolset_getarr') ) {
|
|
464 |
return $default;
|
465 |
}
|
466 |
}
|
|
|
467 |
}
|
1 |
<?php
|
2 |
+
if (defined('WPT_UTILS')) {
|
3 |
+
return;
|
|
|
4 |
}
|
5 |
|
6 |
+
define('WPT_UTILS', true);
|
7 |
|
8 |
/**
|
9 |
+
* utils.php
|
10 |
+
*
|
11 |
+
* A collection of .php utility functions for common use
|
12 |
+
*
|
13 |
+
* @package ToolsetCommon
|
14 |
+
*
|
15 |
+
* @since unknown
|
16 |
+
*/
|
17 |
+
if (!class_exists('Toolset_Utils')) {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* ToolsetUtils
|
21 |
+
*
|
22 |
+
* A collection of static methods to be used across Toolset plugins
|
23 |
+
*
|
24 |
+
* @since 1.7
|
25 |
+
*/
|
26 |
+
class Toolset_Utils {
|
27 |
+
|
28 |
+
/**
|
29 |
+
* help_box
|
30 |
+
*
|
31 |
+
* Creates the HTML version for the wpvToolsetHelp() javascript function
|
32 |
+
*
|
33 |
+
* @param data array containing the attributes
|
34 |
+
* text => The content to show inside the help box.
|
35 |
+
* tutorial-button-text => Optional button anchor text.
|
36 |
+
* tutorial-button-url => Optional button url.
|
37 |
+
* link-text => Optional link anchor text.
|
38 |
+
* link-url => Optional link url.
|
39 |
+
* footer => 'true'|'false' Whether the help box should have a footer with a Close button (managed) and a "dismiss forever" button (not managed). Defaults to 'false'.
|
40 |
+
* classname => Additional classnames for the help box in a space-separated list.
|
41 |
+
* close => 'true'|'false' Whether the help box should have a close button. Defaults to 'true'.
|
42 |
+
* hidden => 'true'|'false' Whether the help box should be hidden by default. Defaults to 'false'.
|
43 |
+
*
|
44 |
+
* @since 1.7
|
45 |
+
*/
|
46 |
+
public static function help_box($data = array()) {
|
47 |
+
if (is_array($data) && !empty($data)) {
|
48 |
+
$data_attr = '';
|
49 |
+
foreach ($data as $key => $value) {
|
50 |
+
if ('text' != $key) {
|
51 |
+
$data_attr .= ' data-' . $key . '="' . esc_attr($value) . '"';
|
52 |
+
}
|
53 |
+
}
|
54 |
+
?>
|
55 |
+
<div class="js-show-toolset-message"<?php echo $data_attr; ?>>
|
56 |
+
<?php
|
57 |
+
if (isset($data['text'])) {
|
58 |
+
echo $data['text'];
|
59 |
+
}
|
60 |
+
?>
|
61 |
+
</div>
|
62 |
+
<?php
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
public static function get_image_sizes($size = '') {
|
67 |
|
68 |
global $_wp_additional_image_sizes;
|
69 |
|
71 |
$get_intermediate_image_sizes = get_intermediate_image_sizes();
|
72 |
|
73 |
// Create the full array with sizes and crop info
|
74 |
+
foreach ($get_intermediate_image_sizes as $_size) {
|
|
|
|
|
75 |
|
76 |
+
if (in_array($_size, array('thumbnail', 'medium', 'large'))) {
|
|
|
|
|
77 |
|
78 |
+
$sizes[$_size]['width'] = get_option($_size . '_size_w');
|
79 |
+
$sizes[$_size]['height'] = get_option($_size . '_size_h');
|
80 |
+
$sizes[$_size]['crop'] = (bool) get_option($_size . '_crop');
|
81 |
+
} elseif (isset($_wp_additional_image_sizes[$_size])) {
|
82 |
|
83 |
+
$sizes[$_size] = array(
|
84 |
+
'width' => $_wp_additional_image_sizes[$_size]['width'],
|
85 |
+
'height' => $_wp_additional_image_sizes[$_size]['height'],
|
86 |
+
'crop' => $_wp_additional_image_sizes[$_size]['crop']
|
87 |
);
|
|
|
88 |
}
|
|
|
89 |
}
|
90 |
|
91 |
// Get only 1 size if found
|
92 |
+
if ($size) {
|
93 |
|
94 |
+
if (isset($sizes[$size])) {
|
95 |
+
return $sizes[$size];
|
96 |
} else {
|
97 |
return false;
|
98 |
}
|
|
|
99 |
}
|
100 |
|
101 |
return $sizes;
|
102 |
}
|
103 |
|
104 |
+
}
|
105 |
+
|
106 |
}
|
107 |
|
108 |
+
if (!function_exists('wp_json_encode')) {
|
109 |
+
|
110 |
+
function wp_json_encode($data, $options = 0, $depth = 512) {
|
111 |
/*
|
112 |
* json_encode() has had extra params added over the years.
|
113 |
* $options was added in 5.3, and $depth in 5.5.
|
114 |
* We need to make sure we call it with the correct arguments.
|
115 |
*/
|
116 |
+
if (version_compare(PHP_VERSION, '5.5', '>=')) {
|
117 |
+
$args = array($data, $options, $depth);
|
118 |
+
} elseif (version_compare(PHP_VERSION, '5.3', '>=')) {
|
119 |
+
$args = array($data, $options);
|
120 |
} else {
|
121 |
+
$args = array($data);
|
122 |
}
|
123 |
|
124 |
+
$json = call_user_func_array('json_encode', $args);
|
125 |
|
126 |
// If json_encode() was successful, no need to do more sanity checking.
|
127 |
// ... unless we're in an old version of PHP, and json_encode() returned
|
128 |
// a string containing 'null'. Then we need to do more sanity checking.
|
129 |
+
if (false !== $json && ( version_compare(PHP_VERSION, '5.5', '>=') || false === strpos($json, 'null') )) {
|
130 |
return $json;
|
131 |
}
|
132 |
|
133 |
try {
|
134 |
+
$args[0] = _wp_json_sanity_check($data, $depth);
|
135 |
+
} catch (Exception $e) {
|
136 |
return false;
|
137 |
}
|
138 |
|
139 |
+
return call_user_func_array('json_encode', $args);
|
140 |
}
|
141 |
|
142 |
+
if (!function_exists('_wp_json_sanity_check')) {
|
143 |
+
|
144 |
+
function _wp_json_sanity_check($data, $depth) {
|
145 |
+
if ($depth < 0) {
|
146 |
+
throw new Exception('Reached depth limit');
|
147 |
}
|
148 |
|
149 |
+
if (is_array($data)) {
|
150 |
$output = array();
|
151 |
+
foreach ($data as $id => $el) {
|
152 |
// Don't forget to sanitize the ID!
|
153 |
+
if (is_string($id)) {
|
154 |
+
$clean_id = _wp_json_convert_string($id);
|
155 |
} else {
|
156 |
$clean_id = $id;
|
157 |
}
|
158 |
|
159 |
// Check the element type, so that we're only recursing if we really have to.
|
160 |
+
if (is_array($el) || is_object($el)) {
|
161 |
+
$output[$clean_id] = _wp_json_sanity_check($el, $depth - 1);
|
162 |
+
} elseif (is_string($el)) {
|
163 |
+
$output[$clean_id] = _wp_json_convert_string($el);
|
164 |
} else {
|
165 |
+
$output[$clean_id] = $el;
|
166 |
}
|
167 |
}
|
168 |
+
} elseif (is_object($data)) {
|
169 |
$output = new stdClass;
|
170 |
+
foreach ($data as $id => $el) {
|
171 |
+
if (is_string($id)) {
|
172 |
+
$clean_id = _wp_json_convert_string($id);
|
173 |
} else {
|
174 |
$clean_id = $id;
|
175 |
}
|
176 |
|
177 |
+
if (is_array($el) || is_object($el)) {
|
178 |
+
$output->$clean_id = _wp_json_sanity_check($el, $depth - 1);
|
179 |
+
} elseif (is_string($el)) {
|
180 |
+
$output->$clean_id = _wp_json_convert_string($el);
|
181 |
} else {
|
182 |
$output->$clean_id = $el;
|
183 |
}
|
184 |
}
|
185 |
+
} elseif (is_string($data)) {
|
186 |
+
return _wp_json_convert_string($data);
|
187 |
} else {
|
188 |
return $data;
|
189 |
}
|
190 |
|
191 |
return $output;
|
192 |
}
|
193 |
+
|
194 |
}
|
195 |
|
196 |
+
if (!function_exists('_wp_json_convert_string')) {
|
197 |
+
|
198 |
+
function _wp_json_convert_string($string) {
|
199 |
static $use_mb = null;
|
200 |
+
if (is_null($use_mb)) {
|
201 |
+
$use_mb = function_exists('mb_convert_encoding');
|
202 |
}
|
203 |
|
204 |
+
if ($use_mb) {
|
205 |
+
$encoding = mb_detect_encoding($string, mb_detect_order(), true);
|
206 |
+
if ($encoding) {
|
207 |
+
return mb_convert_encoding($string, 'UTF-8', $encoding);
|
208 |
} else {
|
209 |
+
return mb_convert_encoding($string, 'UTF-8', 'UTF-8');
|
210 |
}
|
211 |
} else {
|
212 |
+
return wp_check_invalid_utf8($string, true);
|
213 |
}
|
214 |
}
|
215 |
+
|
216 |
}
|
217 |
}
|
218 |
|
219 |
+
if (!class_exists('Toolset_ArrayUtils')) {
|
220 |
+
|
221 |
+
Class Toolset_ArrayUtils {
|
222 |
+
|
223 |
private $value = null;
|
224 |
private $property = null;
|
225 |
|
226 |
+
function __construct($property = null, $value = null) {
|
227 |
$this->value = $value;
|
228 |
$this->property = $property;
|
229 |
}
|
230 |
|
231 |
+
function filter_array($element) {
|
|
|
232 |
if (is_object($element)) {
|
233 |
|
234 |
+
if (property_exists($element, $this->property) === false)
|
235 |
+
return null;
|
236 |
|
237 |
return $element->{$this->property} === $this->value;
|
|
|
238 |
} elseif (is_array($element)) {
|
239 |
|
240 |
+
if (isset($element[$this->property]) === false)
|
241 |
+
return null;
|
242 |
|
243 |
return $element[$this->property] === $this->value;
|
|
|
244 |
} else {
|
245 |
|
246 |
throw new Exception(sprintf("Element parameter should be an object or an array, %s given.", gettype($element)));
|
|
|
247 |
}
|
248 |
}
|
249 |
|
250 |
+
public function remap_by_property($data) {
|
251 |
return $data[$this->property];
|
252 |
}
|
253 |
|
254 |
+
function value_in_array($array) {
|
255 |
+
return in_array($this->value, array_values($array));
|
256 |
}
|
257 |
|
258 |
+
function sort_string_ascendant($a, $b) {
|
259 |
return strcmp($a[$this->property], $b[$this->property]);
|
260 |
}
|
261 |
+
|
262 |
}
|
263 |
+
|
264 |
}
|
265 |
|
266 |
|
267 |
|
268 |
+
if (!class_exists('Toolset_ErrorHandler')) {
|
269 |
|
270 |
/**
|
271 |
* ErrorHandler that can be used to catch internal PHP errors
|
272 |
* and convert to an ErrorException instance.
|
273 |
*/
|
274 |
+
abstract class Toolset_ErrorHandler {
|
275 |
+
|
276 |
/**
|
277 |
* Active stack
|
278 |
*
|
285 |
*
|
286 |
* @return bool
|
287 |
*/
|
288 |
+
public static function started() {
|
|
|
289 |
return (bool) self::getNestedLevel();
|
290 |
}
|
291 |
|
294 |
*
|
295 |
* @return int
|
296 |
*/
|
297 |
+
public static function getNestedLevel() {
|
|
|
298 |
return count(self::$stack);
|
299 |
}
|
300 |
|
303 |
*
|
304 |
* @param int $errorLevel
|
305 |
*/
|
306 |
+
public static function start($errorLevel = E_WARNING) {
|
|
|
307 |
if (!self::$stack) {
|
308 |
set_error_handler(array(get_called_class(), 'addError'), $errorLevel);
|
309 |
+
register_shutdown_function(array(get_called_class(), 'handle_shutdown'), true);
|
310 |
}
|
311 |
|
312 |
self::$stack[] = null;
|
319 |
* @return null|ErrorException
|
320 |
* @throws ErrorException If an error has been catched and $throw is true
|
321 |
*/
|
322 |
+
public static function stop($throw = false) {
|
|
|
323 |
$errorException = null;
|
324 |
|
325 |
if (self::$stack) {
|
337 |
return $errorException;
|
338 |
}
|
339 |
|
340 |
+
public static function handle_shutdown() {
|
341 |
+
if (self::is_fatal()) {
|
|
|
342 |
do_action('toolset-shutdown-hander');
|
343 |
}
|
344 |
exit;
|
345 |
}
|
346 |
|
347 |
+
public static function is_fatal() {
|
348 |
$error = error_get_last();
|
349 |
$ignore = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_STRICT | E_DEPRECATED | E_USER_DEPRECATED;
|
350 |
+
if (($error['type'] & $ignore) == 0) {
|
351 |
return true;
|
352 |
}
|
353 |
return false;
|
358 |
*
|
359 |
* @return void
|
360 |
*/
|
361 |
+
public static function clean() {
|
|
|
362 |
if (self::$stack) {
|
363 |
restore_error_handler();
|
364 |
}
|
375 |
* @param int $errline
|
376 |
* @return void
|
377 |
*/
|
378 |
+
public static function addError($errno, $errstr = '', $errfile = '', $errline = 0) {
|
379 |
+
if (count(self::$stack)) {
|
380 |
+
$stack = & self::$stack[count(self::$stack) - 1];
|
|
|
381 |
} else {
|
382 |
$stack = null;
|
383 |
}
|
384 |
+
$stack = new ErrorException((string) $errstr, 0, (int) $errno, (string) $errfile, (int) $errline);
|
385 |
}
|
386 |
+
|
387 |
}
|
388 |
+
|
389 |
}
|
390 |
|
391 |
/**
|
394 |
* get_called_class() is only in PHP >= 5.3, this is a workaround.
|
395 |
* This function is needed by WPDDL_Theme_Integration_Abstract.
|
396 |
*/
|
397 |
+
if (!function_exists('get_called_class')) {
|
398 |
+
|
399 |
function get_called_class() {
|
400 |
$bt = debug_backtrace();
|
401 |
$l = 0;
|
402 |
+
$matches = null;
|
403 |
do {
|
404 |
$l++;
|
405 |
+
if (isset($bt[$l]['file'])) {
|
406 |
+
$lines = file($bt[$l]['file']);
|
407 |
+
$callerLine = $lines[$bt[$l]['line'] - 1];
|
408 |
+
preg_match('/([a-zA-Z0-9\_]+)::' . $bt[$l]['function'] . '/', $callerLine, $matches);
|
409 |
+
}
|
410 |
+
} while (isset($matches[1]) && $matches[1] === 'parent');
|
411 |
|
412 |
+
return isset($matches[1]) ? $matches[1] : "";
|
413 |
}
|
414 |
+
|
415 |
}
|
416 |
|
417 |
|
428 |
*
|
429 |
* @since 1.8
|
430 |
*/
|
431 |
+
if (!function_exists('toolset_getget')) {
|
432 |
+
|
433 |
+
function toolset_getget($key, $default = '', $valid = null) {
|
434 |
+
return toolset_getarr($_GET, $key, $default, $valid);
|
435 |
}
|
436 |
+
|
437 |
}
|
438 |
|
439 |
|
454 |
*
|
455 |
* @since 1.8
|
456 |
*/
|
457 |
+
if (!function_exists('toolset_getarr')) {
|
458 |
+
|
459 |
+
function toolset_getarr(&$source, $key, $default = '', $valid = null) {
|
460 |
if (isset($source[$key])) {
|
461 |
$val = $source[$key];
|
462 |
if (is_array($valid) && !in_array($val, $valid)) {
|
468 |
return $default;
|
469 |
}
|
470 |
}
|
471 |
+
|
472 |
}
|
library/toolset/toolset-common/visual-editor/res/js/icl_media_manager.js
CHANGED
@@ -22,6 +22,7 @@ if ( typeof WPV_Toolset.only_img_src_allowed_here === "undefined" ) {
|
|
22 |
*/
|
23 |
WPV_Toolset.only_img_src_allowed_here = [
|
24 |
'wpv-pagination-spinner-image',
|
|
|
25 |
'wpv-dps-spinner-image',
|
26 |
'wpv_filter_meta_html_css',
|
27 |
'wpv_filter_meta_html_js',
|
22 |
*/
|
23 |
WPV_Toolset.only_img_src_allowed_here = [
|
24 |
'wpv-pagination-spinner-image',
|
25 |
+
'wpv-archive-pagination-uploaded-spinner-image',
|
26 |
'wpv-dps-spinner-image',
|
27 |
'wpv_filter_meta_html_css',
|
28 |
'wpv_filter_meta_html_js',
|
library/toolset/types/admin.php
CHANGED
@@ -97,7 +97,6 @@ function wpcf_admin_init_hook()
|
|
97 |
{
|
98 |
wp_register_style('wpcf-css-embedded', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION );
|
99 |
|
100 |
-
wp_enqueue_style( 'wpcf-promo-tabs', WPCF_EMBEDDED_RES_RELPATH . '/css/tabs.css', array(), WPCF_VERSION );
|
101 |
wp_enqueue_style('toolset-dashicons');
|
102 |
|
103 |
}
|
@@ -574,7 +573,6 @@ function wpcf_admin_page_add_options( $name, $label)
|
|
574 |
function wpcf_admin_menu_summary_cpt_ctt_hook()
|
575 |
{
|
576 |
do_action( 'wpcf_admin_page_init' );
|
577 |
-
wp_enqueue_style( 'wpcf-promo-tabs', WPCF_RES_RELPATH . '/css/tabs.css', array(), WPCF_VERSION );
|
578 |
wpcf_admin_load_collapsible();
|
579 |
require_once WPCF_INC_ABSPATH . '/custom-types.php';
|
580 |
require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
|
@@ -653,6 +651,11 @@ function wpcf_admin_menu_edit_type_hook()
|
|
653 |
wp_enqueue_style('wp-jquery-ui-dialog');
|
654 |
add_action( 'admin_footer', 'wpcf_admin_types_form_js_validation' );
|
655 |
wpcf_post_relationship_init();
|
|
|
|
|
|
|
|
|
|
|
656 |
/**
|
657 |
* add form
|
658 |
*/
|
@@ -712,6 +715,11 @@ function wpcf_admin_menu_edit_tax_hook()
|
|
712 |
wp_enqueue_script( 'wpcf-taxonomy-form',
|
713 |
WPCF_RES_RELPATH . '/js/'
|
714 |
. 'taxonomy-form.js', array( 'jquery' ), WPCF_VERSION );
|
|
|
|
|
|
|
|
|
|
|
715 |
add_action( 'admin_footer', 'wpcf_admin_tax_form_js_validation' );
|
716 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
|
717 |
require_once WPCF_INC_ABSPATH . '/custom-taxonomies-form.php';
|
@@ -1401,7 +1409,7 @@ function wpcf_settings_save_wpml_settings() {
|
|
1401 |
function wpcf_add_admin_header($title, $add_new = false, $add_new_title = false)
|
1402 |
{
|
1403 |
echo '<div class="wrap">';
|
1404 |
-
echo '<
|
1405 |
if ( !$add_new_title ) {
|
1406 |
$add_new_title = __('Add New', 'wpcf');
|
1407 |
}
|
97 |
{
|
98 |
wp_register_style('wpcf-css-embedded', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION );
|
99 |
|
|
|
100 |
wp_enqueue_style('toolset-dashicons');
|
101 |
|
102 |
}
|
573 |
function wpcf_admin_menu_summary_cpt_ctt_hook()
|
574 |
{
|
575 |
do_action( 'wpcf_admin_page_init' );
|
|
|
576 |
wpcf_admin_load_collapsible();
|
577 |
require_once WPCF_INC_ABSPATH . '/custom-types.php';
|
578 |
require_once WPCF_INC_ABSPATH . '/custom-taxonomies.php';
|
651 |
wp_enqueue_style('wp-jquery-ui-dialog');
|
652 |
add_action( 'admin_footer', 'wpcf_admin_types_form_js_validation' );
|
653 |
wpcf_post_relationship_init();
|
654 |
+
|
655 |
+
// New page controller script.
|
656 |
+
$asset_manager = Types_Asset_Manager::get_instance();
|
657 |
+
$asset_manager->enqueue_scripts( Types_Asset_Manager::SCRIPT_PAGE_EDIT_POST_TYPE );
|
658 |
+
|
659 |
/**
|
660 |
* add form
|
661 |
*/
|
715 |
wp_enqueue_script( 'wpcf-taxonomy-form',
|
716 |
WPCF_RES_RELPATH . '/js/'
|
717 |
. 'taxonomy-form.js', array( 'jquery' ), WPCF_VERSION );
|
718 |
+
|
719 |
+
// New page controller script.
|
720 |
+
$asset_manager = Types_Asset_Manager::get_instance();
|
721 |
+
$asset_manager->enqueue_scripts( Types_Asset_Manager::SCRIPT_PAGE_EDIT_TAXONOMY );
|
722 |
+
|
723 |
add_action( 'admin_footer', 'wpcf_admin_tax_form_js_validation' );
|
724 |
require_once WPCF_EMBEDDED_INC_ABSPATH . '/custom-taxonomies.php';
|
725 |
require_once WPCF_INC_ABSPATH . '/custom-taxonomies-form.php';
|
1409 |
function wpcf_add_admin_header($title, $add_new = false, $add_new_title = false)
|
1410 |
{
|
1411 |
echo '<div class="wrap">';
|
1412 |
+
echo '<h1>', $title;
|
1413 |
if ( !$add_new_title ) {
|
1414 |
$add_new_title = __('Add New', 'wpcf');
|
1415 |
}
|
library/toolset/types/embedded/admin.php
CHANGED
@@ -67,6 +67,15 @@ function wpcf_embedded_admin_init_hook() {
|
|
67 |
)
|
68 |
);
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
add_filter( 'icl_custom_fields_to_be_copied',
|
71 |
'wpcf_custom_fields_to_be_copied', 10, 2 );
|
72 |
|
@@ -191,6 +200,7 @@ function wpcf_admin_fields_userfields_styles(){
|
|
191 |
* @param string $id
|
192 |
* @param array $form
|
193 |
* @return Enlimbo_Forms_Wpcf
|
|
|
194 |
*/
|
195 |
function wpcf_form( $id, $form = array() ) {
|
196 |
static $wpcf_forms = array();
|
@@ -214,8 +224,9 @@ function wpcf_form( $id, $form = array() ) {
|
|
214 |
* Renders form elements.
|
215 |
*
|
216 |
* @staticvar string $form
|
217 |
-
* @param
|
218 |
-
* @return
|
|
|
219 |
*/
|
220 |
function wpcf_form_simple( $elements ) {
|
221 |
static $form = NULL;
|
@@ -232,6 +243,7 @@ function wpcf_form_simple( $elements ) {
|
|
232 |
* @staticvar string $form
|
233 |
* @param type $elements
|
234 |
* @return type
|
|
|
235 |
*/
|
236 |
function wpcf_form_simple_validate( &$elements ) {
|
237 |
static $form = NULL;
|
@@ -248,7 +260,8 @@ function wpcf_form_simple_validate( &$elements ) {
|
|
248 |
*
|
249 |
* @staticvar array $validation
|
250 |
* @param type $element
|
251 |
-
* @return array
|
|
|
252 |
*/
|
253 |
function wpcf_form_add_js_validation( $element ) {
|
254 |
static $validation = array();
|
@@ -267,6 +280,7 @@ function wpcf_form_add_js_validation( $element ) {
|
|
267 |
* @param type $selector Can be CSS class or element ID
|
268 |
* @param type $echo
|
269 |
* @return string
|
|
|
270 |
*/
|
271 |
function wpcf_form_render_js_validation( $selector = '.wpcf-form-validate',
|
272 |
$echo = true ) {
|
67 |
)
|
68 |
);
|
69 |
|
70 |
+
register_post_type(
|
71 |
+
TYPES_TERM_META_FIELD_GROUP_CPT_NAME,
|
72 |
+
array(
|
73 |
+
'public' => false,
|
74 |
+
'label' => 'Types Term Groups',
|
75 |
+
'can_export' => false,
|
76 |
+
)
|
77 |
+
);
|
78 |
+
|
79 |
add_filter( 'icl_custom_fields_to_be_copied',
|
80 |
'wpcf_custom_fields_to_be_copied', 10, 2 );
|
81 |
|
200 |
* @param string $id
|
201 |
* @param array $form
|
202 |
* @return Enlimbo_Forms_Wpcf
|
203 |
+
* @deprecated Please avoid using Enlimbo forms for new code. Consider using Twig templates instead.
|
204 |
*/
|
205 |
function wpcf_form( $id, $form = array() ) {
|
206 |
static $wpcf_forms = array();
|
224 |
* Renders form elements.
|
225 |
*
|
226 |
* @staticvar string $form
|
227 |
+
* @param array $elements
|
228 |
+
* @return array
|
229 |
+
* @deprecated Please avoid using Enlimbo forms for new code. Consider using Twig templates instead.
|
230 |
*/
|
231 |
function wpcf_form_simple( $elements ) {
|
232 |
static $form = NULL;
|
243 |
* @staticvar string $form
|
244 |
* @param type $elements
|
245 |
* @return type
|
246 |
+
* @deprecated Please avoid using Enlimbo forms for new code. Consider using Twig templates instead.
|
247 |
*/
|
248 |
function wpcf_form_simple_validate( &$elements ) {
|
249 |
static $form = NULL;
|
260 |
*
|
261 |
* @staticvar array $validation
|
262 |
* @param type $element
|
263 |
+
* @return array
|
264 |
+
* @deprecated Please avoid using Enlimbo forms for new code. Consider using Twig templates instead.
|
265 |
*/
|
266 |
function wpcf_form_add_js_validation( $element ) {
|
267 |
static $validation = array();
|
280 |
* @param type $selector Can be CSS class or element ID
|
281 |
* @param type $echo
|
282 |
* @return string
|
283 |
+
* @deprecated Please avoid using Enlimbo forms for new code. Consider using Twig templates instead.
|
284 |
*/
|
285 |
function wpcf_form_render_js_validation( $selector = '.wpcf-form-validate',
|
286 |
$echo = true ) {
|
library/toolset/types/embedded/classes/editor.php
CHANGED
@@ -335,8 +335,8 @@ class WPCF_Editor
|
|
335 |
// Add additional parameters if required
|
336 |
$shortcode = $this->_add_parameters_to_shortcode( $shortcode, $_POST );
|
337 |
// Insert shortcode
|
338 |
-
echo '<script type="text/javascript">jQuery(function(){tedFrame.close(
|
339 |
-
. $shortcode . '
|
340 |
} else {
|
341 |
echo '<div class="message error"><p>'
|
342 |
. __( 'Shortcode generation failed', 'wpcf' ) . '</p></div>';
|
@@ -400,6 +400,15 @@ class WPCF_Editor
|
|
400 |
$shortcode = preg_replace( '/\[types([^\]]*)/', '$0 ' . $post_id,
|
401 |
$shortcode );
|
402 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
return $shortcode;
|
404 |
}
|
405 |
|
335 |
// Add additional parameters if required
|
336 |
$shortcode = $this->_add_parameters_to_shortcode( $shortcode, $_POST );
|
337 |
// Insert shortcode
|
338 |
+
echo '<script type="text/javascript">jQuery(function(){tedFrame.close("'
|
339 |
+
. $shortcode . '", "' . esc_js( $shortcode ) . '");});</script>';
|
340 |
} else {
|
341 |
echo '<div class="message error"><p>'
|
342 |
. __( 'Shortcode generation failed', 'wpcf' ) . '</p></div>';
|
400 |
$shortcode = preg_replace( '/\[types([^\]]*)/', '$0 ' . $post_id,
|
401 |
$shortcode );
|
402 |
}
|
403 |
+
|
404 |
+
// replace double quotes with single quotes types-554
|
405 |
+
$search_for_double_quotes = array(
|
406 |
+
'#(?<=[A-z]\=)(\")#', // opening "
|
407 |
+
'#(\")(?= [A-z]{1,}\=)#', // closing " followed by another parameter
|
408 |
+
'#(\")(?=\s*\])#', // closing " for the last parameter
|
409 |
+
);
|
410 |
+
$shortcode = preg_replace( $search_for_double_quotes, "'", $shortcode );
|
411 |
+
|
412 |
return $shortcode;
|
413 |
}
|
414 |
|
library/toolset/types/embedded/classes/field/definition.php
CHANGED
@@ -33,39 +33,9 @@ abstract class WPCF_Field_Definition extends WPCF_Field_Definition_Abstract {
|
|
33 |
|
34 |
|
35 |
/**
|
36 |
-
* @var array The underlying array with complete information about this field.
|
37 |
-
* @
|
38 |
*/
|
39 |
-
/*
|
40 |
-
|
41 |
-
Example of an field definition:
|
42 |
-
|
43 |
-
array (
|
44 |
-
'id' => 'field-1',
|
45 |
-
'slug' => 'field-1',
|
46 |
-
'type' => 'textfield',
|
47 |
-
'name' => 'Field 1',
|
48 |
-
'description' => '',
|
49 |
-
'data' => array
|
50 |
-
(
|
51 |
-
'placeholder' => '',
|
52 |
-
'user_default_value' => '',
|
53 |
-
'repetitive' => '0',
|
54 |
-
'is_new' => '1',
|
55 |
-
'conditional_display' => array
|
56 |
-
(
|
57 |
-
'custom_use' => '0',
|
58 |
-
'relation' => 'AND',
|
59 |
-
'custom' => '',
|
60 |
-
),
|
61 |
-
'submit-key' => 'textfield-1955088717',
|
62 |
-
'disabled_by_type' => 0,
|
63 |
-
'set_value' => ... (optional, presence is relevant)
|
64 |
-
),
|
65 |
-
'meta_key' => 'wpcf-field-1',
|
66 |
-
'meta_type' => 'postmeta',
|
67 |
-
),
|
68 |
-
); */
|
69 |
private $definition_array;
|
70 |
|
71 |
|
@@ -98,21 +68,22 @@ abstract class WPCF_Field_Definition extends WPCF_Field_Definition_Abstract {
|
|
98 |
|
99 |
$this->type = $type;
|
100 |
|
101 |
-
$this->definition_array = wpcf_ensarr( $definition_array );
|
102 |
-
|
103 |
-
$this->slug = wpcf_getarr( $definition_array, 'slug' );
|
104 |
-
|
105 |
-
if( sanitize_title( $this->slug ) != $this->slug ) {
|
106 |
-
throw new InvalidArgumentException( 'Invalid slug.' );
|
107 |
-
}
|
108 |
-
|
109 |
-
$this->name = sanitize_text_field( wpcf_getarr( $definition_array, 'name', $this->get_slug() ) );
|
110 |
-
|
111 |
if( ! $factory instanceof WPCF_Field_Definition_Factory ) {
|
112 |
throw new InvalidArgumentException( 'Invalid field definition factory object.' );
|
113 |
}
|
114 |
|
115 |
$this->factory = $factory;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
117 |
|
118 |
|
@@ -326,7 +297,7 @@ abstract class WPCF_Field_Definition extends WPCF_Field_Definition_Abstract {
|
|
326 |
|
327 |
|
328 |
/**
|
329 |
-
* @return
|
330 |
*/
|
331 |
public function get_associated_groups() {
|
332 |
$field_groups = $this->get_factory()->get_group_factory()->query_groups();
|
@@ -341,6 +312,25 @@ abstract class WPCF_Field_Definition extends WPCF_Field_Definition_Abstract {
|
|
341 |
}
|
342 |
|
343 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
|
345 |
/**
|
346 |
* Get a mapper object that helps translating field data between database and rest of Types.
|
@@ -415,6 +405,87 @@ abstract class WPCF_Field_Definition extends WPCF_Field_Definition_Abstract {
|
|
415 |
return array_merge( $object_data, $additions );
|
416 |
}
|
417 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
418 |
|
419 |
/**
|
420 |
* @return WPCF_Field_Definition_Factory Factory object that is responsible for creating this object.
|
33 |
|
34 |
|
35 |
/**
|
36 |
+
* @var array The underlying array with complete information about this field. Must be kept sanitized at all times.
|
37 |
+
* @link https://git.onthegosystems.com/toolset/types/wikis/database-layer/field-definition-arrays
|
38 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
private $definition_array;
|
40 |
|
41 |
|
68 |
|
69 |
$this->type = $type;
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
if( ! $factory instanceof WPCF_Field_Definition_Factory ) {
|
72 |
throw new InvalidArgumentException( 'Invalid field definition factory object.' );
|
73 |
}
|
74 |
|
75 |
$this->factory = $factory;
|
76 |
+
|
77 |
+
$this->definition_array = $this->get_type()->sanitize_field_definition_array( wpcf_ensarr( $definition_array ) );
|
78 |
+
|
79 |
+
$this->slug = wpcf_getarr( $this->definition_array, 'slug' );
|
80 |
+
|
81 |
+
if( sanitize_title( $this->slug ) != $this->slug ) {
|
82 |
+
throw new InvalidArgumentException( 'Invalid slug.' );
|
83 |
+
}
|
84 |
+
|
85 |
+
$this->name = sanitize_text_field( wpcf_getarr( $this->definition_array, 'name', $this->get_slug() ) );
|
86 |
+
|
87 |
}
|
88 |
|
89 |
|
297 |
|
298 |
|
299 |
/**
|
300 |
+
* @return Types_Field_Group[]
|
301 |
*/
|
302 |
public function get_associated_groups() {
|
303 |
$field_groups = $this->get_factory()->get_group_factory()->query_groups();
|
312 |
}
|
313 |
|
314 |
|
315 |
+
/**
|
316 |
+
* Determine whether this field belongs to a specific group.
|
317 |
+
*
|
318 |
+
* @param Types_Field_Group $field_group
|
319 |
+
* @return bool
|
320 |
+
* @since 2.1
|
321 |
+
*/
|
322 |
+
public function belongs_to_group( $field_group ) {
|
323 |
+
$associated_groups = $this->get_associated_groups();
|
324 |
+
foreach( $associated_groups as $associated_group ) {
|
325 |
+
if( $associated_group === $field_group ) {
|
326 |
+
return true;
|
327 |
+
}
|
328 |
+
}
|
329 |
+
|
330 |
+
return false;
|
331 |
+
}
|
332 |
+
|
333 |
+
|
334 |
|
335 |
/**
|
336 |
* Get a mapper object that helps translating field data between database and rest of Types.
|
405 |
return array_merge( $object_data, $additions );
|
406 |
}
|
407 |
|
408 |
+
|
409 |
+
const XML_KEY_ID = 'id';
|
410 |
+
const XML_KEY_MENU_ICON = 'menu_icon';
|
411 |
+
const XML_KEY_WPML_ACTION = 'wpml_action';
|
412 |
+
const XML_KEY_DATA = 'data';
|
413 |
+
const XML_KEY_DATA_CONDITIONAL_DISPLAY = 'conditional_display';
|
414 |
+
const XML_KEY_DATA_IS_REPEATING = 'repetitive';
|
415 |
+
const XML_KEY_DATA_SUBMIT_KEY = 'submit-key';
|
416 |
+
|
417 |
+
|
418 |
+
/**
|
419 |
+
* Add checksum to an export object, with some custom adjustments for compatibility with
|
420 |
+
* older Module Manager versions.
|
421 |
+
*
|
422 |
+
* @param array $data
|
423 |
+
* @return array Updated $data with checksum information.
|
424 |
+
* @since 2.1
|
425 |
+
*/
|
426 |
+
private function add_checksum_to_export_object( $data ) {
|
427 |
+
|
428 |
+
$checksum_source = $data;
|
429 |
+
|
430 |
+
$ie_controller = Types_Import_Export::get_instance();
|
431 |
+
|
432 |
+
// Consider if this should go into the generic sanitization:
|
433 |
+
|
434 |
+
// Remove *empty* conditional_display for consistent checksum computation with Module manager 1.1 during import.
|
435 |
+
$conditional_display = wpcf_getnest( $checksum_source, array( self::XML_KEY_DATA, self::XML_KEY_DATA_CONDITIONAL_DISPLAY ), null );
|
436 |
+
if( null !== $conditional_display && empty( $conditional_display ) ) {
|
437 |
+
unset( $checksum_source[ self::XML_KEY_DATA ][ self::XML_KEY_DATA_CONDITIONAL_DISPLAY ] );
|
438 |
+
}
|
439 |
+
|
440 |
+
// Convert to integer value to provide correct checksum computation of this field during Module manager 1.1. import.
|
441 |
+
$checksum_source[ self::XML_KEY_DATA ][ self::XML_KEY_DATA_IS_REPEATING ] =
|
442 |
+
(int) wpcf_getnest( $checksum_source, array( self::XML_KEY_DATA, self::XML_KEY_DATA_IS_REPEATING ), 0 );
|
443 |
+
|
444 |
+
$checksum_source = $ie_controller->add_checksum_to_object(
|
445 |
+
$checksum_source,
|
446 |
+
null,
|
447 |
+
array(
|
448 |
+
self::XML_KEY_ID, self::XML_KEY_MENU_ICON, self::XML_KEY_WPML_ACTION,
|
449 |
+
self::XML_KEY_DATA => array( self::XML_KEY_DATA_SUBMIT_KEY )
|
450 |
+
)
|
451 |
+
);
|
452 |
+
|
453 |
+
$data[ Types_Import_Export::XML_KEY_CHECKSUM ] = $checksum_source[ Types_Import_Export::XML_KEY_CHECKSUM ];
|
454 |
+
$data[ Types_Import_Export::XML_KEY_HASH ] = $checksum_source[ Types_Import_Export::XML_KEY_HASH ];
|
455 |
+
|
456 |
+
return $data;
|
457 |
+
}
|
458 |
+
|
459 |
+
|
460 |
+
/**
|
461 |
+
* Create an export object for this field definition, including checksums and annotations.
|
462 |
+
*
|
463 |
+
* @return array
|
464 |
+
* @since 2.1
|
465 |
+
*/
|
466 |
+
public function get_export_object() {
|
467 |
+
|
468 |
+
$data = $this->get_definition_array();
|
469 |
+
|
470 |
+
// legacy filter
|
471 |
+
$data = apply_filters( 'wpcf_export_field', $data );
|
472 |
+
|
473 |
+
$ie_controller = Types_Import_Export::get_instance();
|
474 |
+
|
475 |
+
$data = $this->add_checksum_to_export_object( $data );
|
476 |
+
|
477 |
+
$data = $ie_controller->annotate_object( $data, $this->get_name(), $this->get_slug() );
|
478 |
+
|
479 |
+
// Export WPML TM setting for this field's translation, if available.
|
480 |
+
$wpml_tm_settings = apply_filters( 'wpml_setting', null, 'translation-management' );
|
481 |
+
$custom_field_translation_setting = wpcf_getnest( $wpml_tm_settings, array( 'custom_fields_translation', $this->get_meta_key() ), null );
|
482 |
+
if( null !== $custom_field_translation_setting ) {
|
483 |
+
$data[ self::XML_KEY_WPML_ACTION ] = $custom_field_translation_setting;
|
484 |
+
}
|
485 |
+
|
486 |
+
return $data;
|
487 |
+
}
|
488 |
+
|
489 |
|
490 |
/**
|
491 |
* @return WPCF_Field_Definition_Factory Factory object that is responsible for creating this object.
|
library/toolset/types/embedded/classes/field/definition_abstract.php
CHANGED
@@ -37,7 +37,7 @@ abstract class WPCF_Field_Definition_Abstract {
|
|
37 |
|
38 |
|
39 |
/**
|
40 |
-
* @return
|
41 |
*/
|
42 |
public abstract function get_associated_groups();
|
43 |
|
@@ -52,12 +52,26 @@ abstract class WPCF_Field_Definition_Abstract {
|
|
52 |
*/
|
53 |
public function is_match( $search_string ) {
|
54 |
return (
|
55 |
-
|
56 |
-
||
|
57 |
);
|
58 |
}
|
59 |
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
/**
|
62 |
* Get field definition data as an associative array for coversion to JSON.
|
63 |
*
|
@@ -71,18 +85,12 @@ abstract class WPCF_Field_Definition_Abstract {
|
|
71 |
*/
|
72 |
public function to_json() {
|
73 |
|
74 |
-
$groups = $this->get_associated_groups();
|
75 |
-
$group_slugs = array();
|
76 |
-
foreach( $groups as $group ) {
|
77 |
-
$group_slugs[] = $group->get_slug();
|
78 |
-
}
|
79 |
-
|
80 |
$object_data = array(
|
81 |
'isUnderTypesControl' => $this->is_under_types_control(),
|
82 |
'slug' => $this->get_slug(),
|
83 |
'metaKey' => $this->get_slug(),
|
84 |
'displayName' => $this->get_name(),
|
85 |
-
'groups' => $
|
86 |
);
|
87 |
|
88 |
return $object_data;
|
37 |
|
38 |
|
39 |
/**
|
40 |
+
* @return Types_Field_Group[]
|
41 |
*/
|
42 |
public abstract function get_associated_groups();
|
43 |
|
52 |
*/
|
53 |
public function is_match( $search_string ) {
|
54 |
return (
|
55 |
+
Types_Utils::is_string_match( $search_string, $this->get_name() )
|
56 |
+
|| Types_Utils::is_string_match( $search_string, $this->get_slug() )
|
57 |
);
|
58 |
}
|
59 |
|
60 |
|
61 |
+
/**
|
62 |
+
* @return string[] Slugs of field groups where this field belongs to.
|
63 |
+
* @since 2.1
|
64 |
+
*/
|
65 |
+
private function get_group_slugs() {
|
66 |
+
$groups = $this->get_associated_groups();
|
67 |
+
$group_slugs = array();
|
68 |
+
foreach( $groups as $group ) {
|
69 |
+
$group_slugs[] = $group->get_slug();
|
70 |
+
}
|
71 |
+
return $group_slugs;
|
72 |
+
}
|
73 |
+
|
74 |
+
|
75 |
/**
|
76 |
* Get field definition data as an associative array for coversion to JSON.
|
77 |
*
|
85 |
*/
|
86 |
public function to_json() {
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
$object_data = array(
|
89 |
'isUnderTypesControl' => $this->is_under_types_control(),
|
90 |
'slug' => $this->get_slug(),
|
91 |
'metaKey' => $this->get_slug(),
|
92 |
'displayName' => $this->get_name(),
|
93 |
+
'groups' => $this->get_group_slugs()
|
94 |
);
|
95 |
|
96 |
return $object_data;
|
library/toolset/types/embedded/classes/field/definition_factory.php
CHANGED
@@ -4,6 +4,8 @@
|
|
4 |
* Abstract factory for field definitions.
|
5 |
*
|
6 |
* Handles creation of the objects as well as their caching.
|
|
|
|
|
7 |
*/
|
8 |
abstract class WPCF_Field_Definition_Factory {
|
9 |
|
@@ -29,6 +31,28 @@ abstract class WPCF_Field_Definition_Factory {
|
|
29 |
final private function __clone() { }
|
30 |
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
/**
|
33 |
* @return string Name of the option that should be used to obtain field definitions.
|
34 |
*/
|
@@ -308,7 +332,7 @@ abstract class WPCF_Field_Definition_Factory {
|
|
308 |
|
309 |
|
310 |
/**
|
311 |
-
* @return
|
312 |
* @since 2.0
|
313 |
*/
|
314 |
public abstract function get_group_factory();
|
@@ -458,16 +482,23 @@ abstract class WPCF_Field_Definition_Factory {
|
|
458 |
* Query field definitions.
|
459 |
*
|
460 |
* @param array $args Following arguments are recognized:
|
|
|
461 |
* - filter: What field definitions should be retrieved: 'types'|'generic'|'all'
|
462 |
* - orderby: 'name'|'slug'|'is_under_types_control'|'field_type'
|
463 |
* - order: 'asc'|'desc'
|
464 |
* - search: String for fulltext search.
|
|
|
|
|
|
|
|
|
465 |
*
|
466 |
* @return WPCF_Field_Definition_Abstract[] Field definitions that match query arguments.
|
|
|
|
|
467 |
*/
|
468 |
public function query_definitions( $args ) {
|
469 |
|
470 |
-
$args = wp_parse_args( $args, array('filter' => 'all') );
|
471 |
|
472 |
// Get only certain type of field definitions (generic, Types or both)
|
473 |
switch( $args['filter'] ) {
|
@@ -487,7 +518,6 @@ abstract class WPCF_Field_Definition_Factory {
|
|
487 |
|
488 |
// Perform fulltext search if needed
|
489 |
$search_string = wpcf_getarr( $args, 'search', '' );
|
490 |
-
|
491 |
if( !empty( $search_string ) ) {
|
492 |
$matches = array();
|
493 |
foreach( $results as $definition ) {
|
@@ -498,6 +528,34 @@ abstract class WPCF_Field_Definition_Factory {
|
|
498 |
$results = $matches;
|
499 |
}
|
500 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
501 |
// Sort results
|
502 |
$orderby = wpcf_getarr( $args, 'orderby', 'name' );
|
503 |
$order = wpcf_getarr( $args, 'order', 'asc', array( 'asc', 'desc' ) );
|
@@ -601,4 +659,29 @@ abstract class WPCF_Field_Definition_Factory {
|
|
601 |
}
|
602 |
|
603 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
604 |
}
|
4 |
* Abstract factory for field definitions.
|
5 |
*
|
6 |
* Handles creation of the objects as well as their caching.
|
7 |
+
*
|
8 |
+
* @since 1.9
|
9 |
*/
|
10 |
abstract class WPCF_Field_Definition_Factory {
|
11 |
|
31 |
final private function __clone() { }
|
32 |
|
33 |
|
34 |
+
/**
|
35 |
+
* Get a field definition foctory for given field domain.
|
36 |
+
*
|
37 |
+
* @param string $domain Valid field domain.
|
38 |
+
* @return WPCF_Field_Definition_Factory Factory instance for given domain.
|
39 |
+
* @throws InvalidArgumentException when the domain is invalid
|
40 |
+
* @since 2.1
|
41 |
+
*/
|
42 |
+
public static function get_factory_by_domain( $domain ) {
|
43 |
+
switch( $domain ) {
|
44 |
+
case Types_Field_Utils::DOMAIN_POSTS:
|
45 |
+
return WPCF_Field_Definition_Factory_Post::get_instance();
|
46 |
+
case Types_Field_Utils::DOMAIN_USERS:
|
47 |
+
return WPCF_Field_Definition_Factory_User::get_instance();
|
48 |
+
case Types_Field_Utils::DOMAIN_TERMS:
|
49 |
+
return WPCF_Field_Definition_Factory_Term::get_instance();
|
50 |
+
default:
|
51 |
+
throw new InvalidArgumentException( 'Invalid field domain.' );
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
|
56 |
/**
|
57 |
* @return string Name of the option that should be used to obtain field definitions.
|
58 |
*/
|
332 |
|
333 |
|
334 |
/**
|
335 |
+
* @return Types_Field_Group_Factory
|
336 |
* @since 2.0
|
337 |
*/
|
338 |
public abstract function get_group_factory();
|
482 |
* Query field definitions.
|
483 |
*
|
484 |
* @param array $args Following arguments are recognized:
|
485 |
+
*
|
486 |
* - filter: What field definitions should be retrieved: 'types'|'generic'|'all'
|
487 |
* - orderby: 'name'|'slug'|'is_under_types_control'|'field_type'
|
488 |
* - order: 'asc'|'desc'
|
489 |
* - search: String for fulltext search.
|
490 |
+
* - field_type: string Field type slug.
|
491 |
+
* - group_id: int Field group ID where this field belongs to.
|
492 |
+
* - group_slug: string Slug of an existing firld group where this field belongs to. If defined, overrides
|
493 |
+
* the group_id argument.
|
494 |
*
|
495 |
* @return WPCF_Field_Definition_Abstract[] Field definitions that match query arguments.
|
496 |
+
*
|
497 |
+
* @since 1.9
|
498 |
*/
|
499 |
public function query_definitions( $args ) {
|
500 |
|
501 |
+
$args = wp_parse_args( $args, array( 'filter' => 'all' ) );
|
502 |
|
503 |
// Get only certain type of field definitions (generic, Types or both)
|
504 |
switch( $args['filter'] ) {
|
518 |
|
519 |
// Perform fulltext search if needed
|
520 |
$search_string = wpcf_getarr( $args, 'search', '' );
|
|
|
521 |
if( !empty( $search_string ) ) {
|
522 |
$matches = array();
|
523 |
foreach( $results as $definition ) {
|
528 |
$results = $matches;
|
529 |
}
|
530 |
|
531 |
+
// Select only fields of desired type
|
532 |
+
$field_type = wpcf_getarr( $args, 'field_type' );
|
533 |
+
if( !empty( $field_type ) ) {
|
534 |
+
$type_matches = array();
|
535 |
+
foreach( $results as $definition ) {
|
536 |
+
if( $definition->get_type()->get_slug() == $field_type ) {
|
537 |
+
$type_matches[] = $definition;
|
538 |
+
}
|
539 |
+
}
|
540 |
+
$results = $type_matches;
|
541 |
+
}
|
542 |
+
|
543 |
+
// Select fields by field group.
|
544 |
+
$group_source = wpcf_getarr( $args, 'group_slug', (int) wpcf_getarr( $args, 'group_id' ) );
|
545 |
+
if( !empty( $group_source ) ) {
|
546 |
+
$group_factory = $this->get_group_factory();
|
547 |
+
$group = $group_factory->load_field_group( $group_source );
|
548 |
+
$group_matches = array();
|
549 |
+
if( null != $group ) {
|
550 |
+
foreach( $results as $field_definition ) {
|
551 |
+
if( $field_definition->belongs_to_group( $group ) ) {
|
552 |
+
$group_matches[] = $field_definition;
|
553 |
+
}
|
554 |
+
}
|
555 |
+
}
|
556 |
+
$results = $group_matches;
|
557 |
+
}
|
558 |
+
|
559 |
// Sort results
|
560 |
$orderby = wpcf_getarr( $args, 'orderby', 'name' );
|
561 |
$order = wpcf_getarr( $args, 'order', 'asc', array( 'asc', 'desc' ) );
|
659 |
}
|
660 |
|
661 |
|
662 |
+
/**
|
663 |
+
* Temporary workaround to access field definitions on a very deep level.
|
664 |
+
*
|
665 |
+
* @param $field_slug
|
666 |
+
* @param $definition_array
|
667 |
+
* @deprecated Do not use, it will be removed.
|
668 |
+
* @since 2.1
|
669 |
+
*/
|
670 |
+
public function set_field_definition_workaround( $field_slug, $definition_array ) {
|
671 |
+
$this->set_field_definition( $field_slug, $definition_array );
|
672 |
+
}
|
673 |
+
|
674 |
+
|
675 |
+
/**
|
676 |
+
* Temporary workaround to access field definitions on a very deep level. Do not use, it will be removed.
|
677 |
+
*
|
678 |
+
* @return string
|
679 |
+
* @deprecated Do not use, it will be removed.
|
680 |
+
* @since 2.1
|
681 |
+
*/
|
682 |
+
public function get_option_name_workaround() {
|
683 |
+
return $this->get_option_name();
|
684 |
+
}
|
685 |
+
|
686 |
+
|
687 |
}
|
library/toolset/types/embedded/classes/field/definition_factory_post.php
CHANGED
@@ -38,11 +38,11 @@ final class WPCF_Field_Definition_Factory_Post extends WPCF_Field_Definition_Fac
|
|
38 |
|
39 |
/**
|
40 |
* @inheritdoc
|
41 |
-
* @return
|
42 |
* @since 2.0
|
43 |
*/
|
44 |
public function get_group_factory() {
|
45 |
-
return
|
46 |
}
|
47 |
|
48 |
|
38 |
|
39 |
/**
|
40 |
* @inheritdoc
|
41 |
+
* @return Types_Field_Group_Post_Factory
|
42 |
* @since 2.0
|
43 |
*/
|
44 |
public function get_group_factory() {
|
45 |
+
return Types_Field_Group_Post_Factory::get_instance();
|
46 |
}
|
47 |
|
48 |
|
library/toolset/types/embedded/classes/field/definition_factory_term.php
CHANGED
@@ -37,11 +37,11 @@ final class WPCF_Field_Definition_Factory_Term extends WPCF_Field_Definition_Fac
|
|
37 |
|
38 |
/**
|
39 |
* @inheritdoc
|
40 |
-
* @return
|
41 |
* @since 2.0
|
42 |
*/
|
43 |
public function get_group_factory() {
|
44 |
-
return
|
45 |
}
|
46 |
|
47 |
|
37 |
|
38 |
/**
|
39 |
* @inheritdoc
|
40 |
+
* @return Types_Field_Group_Post_Factory
|
41 |
* @since 2.0
|
42 |
*/
|
43 |
public function get_group_factory() {
|
44 |
+
return Types_Field_Group_Term_Factory::get_instance();
|
45 |
}
|
46 |
|
47 |
|
library/toolset/types/embedded/classes/field/definition_factory_user.php
CHANGED
@@ -38,11 +38,11 @@ final class WPCF_Field_Definition_Factory_User extends WPCF_Field_Definition_Fac
|
|
38 |
|
39 |
/**
|
40 |
* @inheritdoc
|
41 |
-
* @return
|
42 |
* @since 2.0
|
43 |
*/
|
44 |
public function get_group_factory() {
|
45 |
-
return
|
46 |
}
|
47 |
|
48 |
|
38 |
|
39 |
/**
|
40 |
* @inheritdoc
|
41 |
+
* @return Types_Field_Group_Post_Factory
|
42 |
* @since 2.0
|
43 |
*/
|
44 |
public function get_group_factory() {
|
45 |
+
return Types_Field_Group_User_Factory::get_instance();
|
46 |
}
|
47 |
|
48 |
|
library/toolset/types/embedded/classes/field/definition_term.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
*
|
6 |
* @since 1.9
|
7 |
*/
|
8 |
-
|
9 |
|
10 |
|
11 |
/**
|
5 |
*
|
6 |
* @since 1.9
|
7 |
*/
|
8 |
+
class WPCF_Field_Definition_Term extends WPCF_Field_Definition {
|
9 |
|
10 |
|
11 |
/**
|
library/toolset/types/embedded/classes/field/group_post.php
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Post field group.
|
5 |
-
*
|
6 |
-
* @since 2.0
|
7 |
-
*/
|
8 |
-
final class WPCF_Field_Group_Post extends WPCF_Field_Group {
|
9 |
-
|
10 |
-
|
11 |
-
const POST_TYPE = 'wp-types-group';
|
12 |
-
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @param WP_Post $field_group_post Post object representing a post field group.
|
16 |
-
* @throws InvalidArgumentException
|
17 |
-
*/
|
18 |
-
public function __construct( $field_group_post ) {
|
19 |
-
parent::__construct( $field_group_post );
|
20 |
-
if( self::POST_TYPE != $field_group_post->post_type ) {
|
21 |
-
throw new InvalidArgumentException( 'incorrect post type' );
|
22 |
-
}
|
23 |
-
}
|
24 |
-
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @return WPCF_Field_Definition_Factory Field definition factory of the correct type.
|
28 |
-
*/
|
29 |
-
protected function get_field_definition_factory() {
|
30 |
-
return WPCF_Field_Definition_Factory_Post::get_instance();
|
31 |
-
}
|
32 |
-
|
33 |
-
|
34 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
library/toolset/types/embedded/classes/field/instance_term.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
*
|
8 |
* @since 1.9
|
9 |
*/
|
10 |
-
|
11 |
|
12 |
|
13 |
/**
|
7 |
*
|
8 |
* @since 1.9
|
9 |
*/
|
10 |
+
class WPCF_Field_Instance_Term extends WPCF_Field_Instance {
|
11 |
|
12 |
|
13 |
/**
|
library/toolset/types/embedded/classes/field/renderer/factory.php
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
*
|
9 |
* @since 1.9.1
|
10 |
*/
|
11 |
-
|
12 |
|
13 |
private static $instance = null;
|
14 |
|
@@ -51,7 +51,7 @@ final class WPCF_Field_Renderer_Factory {
|
|
51 |
case Types_Field_Type_Definition_Factory::FILE:
|
52 |
case Types_Field_Type_Definition_Factory::VIDEO:
|
53 |
return new WPCF_Field_Renderer_Preview_File( $field, $args );
|
54 |
-
|
55 |
case Types_Field_Type_Definition_Factory::COLORPICKER:
|
56 |
return new WPCF_Field_Renderer_Preview_Colorpicker( $field, $args );
|
57 |
|
@@ -64,7 +64,7 @@ final class WPCF_Field_Renderer_Factory {
|
|
64 |
|
65 |
case Types_Field_Type_Definition_Factory::CHECKBOX:
|
66 |
return new WPCF_Field_Renderer_Preview_Checkbox( $field, $args );
|
67 |
-
|
68 |
case Types_Field_Type_Definition_Factory::CHECKBOXES:
|
69 |
return new WPCF_Field_Renderer_Preview_Checkboxes( $field, $args );
|
70 |
|
@@ -83,4 +83,4 @@ final class WPCF_Field_Renderer_Factory {
|
|
83 |
break;
|
84 |
}
|
85 |
}
|
86 |
-
}
|
8 |
*
|
9 |
* @since 1.9.1
|
10 |
*/
|
11 |
+
class WPCF_Field_Renderer_Factory {
|
12 |
|
13 |
private static $instance = null;
|
14 |
|
51 |
case Types_Field_Type_Definition_Factory::FILE:
|
52 |
case Types_Field_Type_Definition_Factory::VIDEO:
|
53 |
return new WPCF_Field_Renderer_Preview_File( $field, $args );
|
54 |
+
|
55 |
case Types_Field_Type_Definition_Factory::COLORPICKER:
|
56 |
return new WPCF_Field_Renderer_Preview_Colorpicker( $field, $args );
|
57 |
|
64 |
|
65 |
case Types_Field_Type_Definition_Factory::CHECKBOX:
|
66 |
return new WPCF_Field_Renderer_Preview_Checkbox( $field, $args );
|
67 |
+
|
68 |
case Types_Field_Type_Definition_Factory::CHECKBOXES:
|
69 |
return new WPCF_Field_Renderer_Preview_Checkboxes( $field, $args );
|
70 |
|
83 |
break;
|
84 |
}
|
85 |
}
|
86 |
+
}
|
library/toolset/types/embedded/classes/field/renderer/preview/address.php
CHANGED
@@ -16,7 +16,7 @@ final class WPCF_Field_Renderer_Preview_Address extends WPCF_Field_Renderer_Prev
|
|
16 |
*/
|
17 |
protected function render_single( $value ) {
|
18 |
|
19 |
-
if( !is_string( $value ) ) {
|
20 |
return '';
|
21 |
}
|
22 |
|
@@ -27,10 +27,19 @@ final class WPCF_Field_Renderer_Preview_Address extends WPCF_Field_Renderer_Prev
|
|
27 |
if( 0 < $max_length && $max_length < strlen( $label ) ) {
|
28 |
$label = substr( $label, 0, $max_length - 3 ) . '...';
|
29 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
$link = sprintf(
|
32 |
-
'<a target="_blank" href="
|
33 |
-
|
34 |
sanitize_text_field( $label )
|
35 |
);
|
36 |
|
16 |
*/
|
17 |
protected function render_single( $value ) {
|
18 |
|
19 |
+
if( !is_string( $value ) || empty( $value ) ) {
|
20 |
return '';
|
21 |
}
|
22 |
|
27 |
if( 0 < $max_length && $max_length < strlen( $label ) ) {
|
28 |
$label = substr( $label, 0, $max_length - 3 ) . '...';
|
29 |
}
|
30 |
+
|
31 |
+
$url = esc_url(
|
32 |
+
add_query_arg(
|
33 |
+
array(
|
34 |
+
'q' => $value
|
35 |
+
),
|
36 |
+
'http://maps.google.com/'
|
37 |
+
)
|
38 |
+
);
|
39 |
|
40 |
$link = sprintf(
|
41 |
+
'<a target="_blank" href="%s">%s</a>',
|
42 |
+
$url,
|
43 |
sanitize_text_field( $label )
|
44 |
);
|
45 |
|
library/toolset/types/embedded/classes/field/renderer/preview/base.php
CHANGED
@@ -22,22 +22,24 @@ abstract class WPCF_Field_Renderer_Preview_Base extends WPCF_Field_Renderer_Abst
|
|
22 |
* WPCF_Field_Renderer_Preview_Base constructor.
|
23 |
*
|
24 |
* @param WPCF_Field_Instance_Abstract $field
|
25 |
-
* @param array $args Preview renderer settings:
|
26 |
-
* - maximum_item_count => Maximum count of field values that should be displayed.
|
27 |
* - maximum_item_length => Maximum length of single item.
|
|
|
28 |
* - value_separator => Separator to be used between multiple field values.
|
29 |
* - ellipsis => Ellipsis to be added when some field values are omitted.
|
30 |
-
*
|
31 |
* Specialized renderers may interpret the settings in a different way or add their own.
|
32 |
*
|
33 |
-
* @since 1.9.1
|
34 |
*/
|
35 |
public function __construct( $field, $args = array() ) {
|
36 |
parent::__construct( $field );
|
37 |
-
|
38 |
$this->args = wpcf_ensarr( $args );
|
39 |
}
|
40 |
|
|
|
41 |
/**
|
42 |
* Render the field value. Handle both single and repetitive fields.
|
43 |
*
|
@@ -70,16 +72,18 @@ abstract class WPCF_Field_Renderer_Preview_Base extends WPCF_Field_Renderer_Abst
|
|
70 |
}
|
71 |
|
72 |
$output = implode( $this->get_value_separator(), $output_values );
|
73 |
-
|
74 |
-
|
75 |
-
$is_limited_by_max_total_length =
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
-
|
80 |
-
$needs_ellipsis = ( $is_limited_by_max_count || $is_limited_by_max_total_length );
|
81 |
if( $needs_ellipsis ) {
|
82 |
-
$output .= $
|
83 |
}
|
84 |
|
85 |
if( $echo ) {
|
@@ -90,6 +94,27 @@ abstract class WPCF_Field_Renderer_Preview_Base extends WPCF_Field_Renderer_Abst
|
|
90 |
}
|
91 |
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
/**
|
94 |
* @return string Separator to be used between multiple field values.
|
95 |
*/
|
@@ -140,7 +165,7 @@ abstract class WPCF_Field_Renderer_Preview_Base extends WPCF_Field_Renderer_Abst
|
|
140 |
* @since 1.9.1
|
141 |
*/
|
142 |
protected function get_ellipsis() {
|
143 |
-
return wpcf_getarr( $this->args, 'ellipsis',
|
144 |
}
|
145 |
-
|
146 |
-
}
|
22 |
* WPCF_Field_Renderer_Preview_Base constructor.
|
23 |
*
|
24 |
* @param WPCF_Field_Instance_Abstract $field
|
25 |
+
* @param array $args Preview renderer settings:
|
26 |
+
* - maximum_item_count => Maximum count of field values that should be displayed.
|
27 |
* - maximum_item_length => Maximum length of single item.
|
28 |
+
* - maximum_total_length => Maximum length of output.
|
29 |
* - value_separator => Separator to be used between multiple field values.
|
30 |
* - ellipsis => Ellipsis to be added when some field values are omitted.
|
31 |
+
*
|
32 |
* Specialized renderers may interpret the settings in a different way or add their own.
|
33 |
*
|
34 |
+
* @since 1.9.1
|
35 |
*/
|
36 |
public function __construct( $field, $args = array() ) {
|
37 |
parent::__construct( $field );
|
38 |
+
|
39 |
$this->args = wpcf_ensarr( $args );
|
40 |
}
|
41 |
|
42 |
+
|
43 |
/**
|
44 |
* Render the field value. Handle both single and repetitive fields.
|
45 |
*
|
72 |
}
|
73 |
|
74 |
$output = implode( $this->get_value_separator(), $output_values );
|
75 |
+
$ellipsis = $this->get_ellipsis();
|
76 |
+
|
77 |
+
$is_limited_by_max_total_length = $this->limit_by_maximum_total_length( $output );
|
78 |
+
|
79 |
+
$needs_separator = $is_limited_by_max_count && ! $is_limited_by_max_total_length;
|
80 |
+
$needs_ellipsis = ( $is_limited_by_max_count || $is_limited_by_max_total_length );
|
81 |
+
|
82 |
+
if( $needs_separator ) {
|
83 |
+
$output .= $this->get_value_separator();
|
84 |
}
|
|
|
|
|
85 |
if( $needs_ellipsis ) {
|
86 |
+
$output .= $ellipsis;
|
87 |
}
|
88 |
|
89 |
if( $echo ) {
|
94 |
}
|
95 |
|
96 |
|
97 |
+
/**
|
98 |
+
* Apply maximum total length limit on a value.
|
99 |
+
*
|
100 |
+
* @param string &$value Value to be shortened if needed.
|
101 |
+
* @return bool True if the limit was applied.
|
102 |
+
* @since 2.1
|
103 |
+
*/
|
104 |
+
protected function limit_by_maximum_total_length( &$value ) {
|
105 |
+
$ellipsis = $this->get_ellipsis();
|
106 |
+
$ellipsis_length = strlen( $ellipsis );
|
107 |
+
|
108 |
+
$maximum_total_length = $this->get_maximum_total_length();
|
109 |
+
$is_limited_by_max_total_length = ( 0 < $maximum_total_length && $maximum_total_length < strlen( $value ) );
|
110 |
+
if( $is_limited_by_max_total_length ) {
|
111 |
+
$value = substr( $value, 0, $maximum_total_length - $ellipsis_length );
|
112 |
+
}
|
113 |
+
|
114 |
+
return $is_limited_by_max_total_length;
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
/**
|
119 |
* @return string Separator to be used between multiple field values.
|
120 |
*/
|
165 |
* @since 1.9.1
|
166 |
*/
|
167 |
protected function get_ellipsis() {
|
168 |
+
return wpcf_getarr( $this->args, 'ellipsis', '...' );
|
169 |
}
|
170 |
+
|
171 |
+
}
|
library/toolset/types/embedded/classes/field/renderer/preview/checkboxes.php
CHANGED
@@ -22,7 +22,7 @@ final class WPCF_Field_Renderer_Preview_Checkboxes extends WPCF_Field_Renderer_P
|
|
22 |
|
23 |
// Let each checkbox option definition handle how it should be displayed.
|
24 |
foreach( $options as $option ) {
|
25 |
-
$display_value = ( $option->is_option_checked( $value )
|
26 |
if( !empty( $display_value ) ) {
|
27 |
$output[] = $display_value;
|
28 |
}
|
@@ -37,7 +37,22 @@ final class WPCF_Field_Renderer_Preview_Checkboxes extends WPCF_Field_Renderer_P
|
|
37 |
|
38 |
$output = implode( $this->get_value_separator(), $output );
|
39 |
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
$output .= $this->get_ellipsis();
|
42 |
}
|
43 |
|
22 |
|
23 |
// Let each checkbox option definition handle how it should be displayed.
|
24 |
foreach( $options as $option ) {
|
25 |
+
$display_value = $option->get_display_value( $option->is_option_checked( $value ) );
|
26 |
if( !empty( $display_value ) ) {
|
27 |
$output[] = $display_value;
|
28 |
}
|
37 |
|
38 |
$output = implode( $this->get_value_separator(), $output );
|
39 |
|
40 |
+
// We need to additionally apply a limit for maximum total length
|
41 |
+
// because if we only apply item length and count, and perhaps add separator and ellipsis at the end,
|
42 |
+
// the parent::render() method will see it as one item and it might add another ellipsis if
|
43 |
+
// output of this function hits the maximum total length limit there.
|
44 |
+
//
|
45 |
+
// Note: limit_by_maximum_total_length() should subtract the length of the ellipsis from the resulting
|
46 |
+
// total length, so we should be completely covered here.
|
47 |
+
$is_limited_by_max_total_length = $this->limit_by_maximum_total_length( $output );
|
48 |
+
|
49 |
+
$needs_separator = $is_limited_by_max_count && ! $is_limited_by_max_total_length;
|
50 |
+
$needs_ellipsis = ( $is_limited_by_max_count || $is_limited_by_max_total_length );
|
51 |
+
|
52 |
+
if( $needs_separator ) {
|
53 |
+
$output .= $this->get_value_separator();
|
54 |
+
}
|
55 |
+
if( $needs_ellipsis ) {
|
56 |
$output .= $this->get_ellipsis();
|
57 |
}
|
58 |
|
library/toolset/types/embedded/classes/field/renderer/preview/date.php
CHANGED
@@ -9,13 +9,17 @@ final class WPCF_Field_Renderer_Preview_Date extends WPCF_Field_Renderer_Preview
|
|
9 |
*/
|
10 |
protected function render_single( $value ) {
|
11 |
|
|
|
|
|
|
|
|
|
12 |
$timestamp = (int) $value;
|
13 |
-
|
14 |
// Skip empty values
|
15 |
if( 0 == $timestamp ) {
|
16 |
return '';
|
17 |
}
|
18 |
-
|
19 |
$output = date( get_option( 'date_format' ), $timestamp );
|
20 |
|
21 |
$add_time = ( $this->field->get_definition()->get_datetime_option() == 'date_and_time' );
|
@@ -37,4 +41,4 @@ final class WPCF_Field_Renderer_Preview_Date extends WPCF_Field_Renderer_Preview
|
|
37 |
return '; ';
|
38 |
}
|
39 |
|
40 |
-
}
|
9 |
*/
|
10 |
protected function render_single( $value ) {
|
11 |
|
12 |
+
if( !is_string( $value ) ) {
|
13 |
+
return '';
|
14 |
+
}
|
15 |
+
|
16 |
$timestamp = (int) $value;
|
17 |
+
|
18 |
// Skip empty values
|
19 |
if( 0 == $timestamp ) {
|
20 |
return '';
|
21 |
}
|
22 |
+
|
23 |
$output = date( get_option( 'date_format' ), $timestamp );
|
24 |
|
25 |
$add_time = ( $this->field->get_definition()->get_datetime_option() == 'date_and_time' );
|
41 |
return '; ';
|
42 |
}
|
43 |
|
44 |
+
}
|
library/toolset/types/embedded/classes/field/renderer/preview/image.php
CHANGED
@@ -4,8 +4,8 @@
|
|
4 |
* Preview renderer for image fields.
|
5 |
*
|
6 |
* Tries to be clever about WP attachments and use thumbnails instead of full size images whenever possible.
|
7 |
-
*
|
8 |
-
* For displaying the full image on clicking on the preview, you need to enqueue the 'wpcf-js' script and
|
9 |
* the 'wptoolset-forms-admin' style
|
10 |
*
|
11 |
* @since 1.9.1
|
@@ -24,7 +24,7 @@ final class WPCF_Field_Renderer_Preview_Image extends WPCF_Field_Renderer_Previe
|
|
24 |
*/
|
25 |
protected function render_single( $value ) {
|
26 |
|
27 |
-
if( !is_string( $value ) ) {
|
28 |
return '';
|
29 |
}
|
30 |
|
@@ -56,7 +56,7 @@ final class WPCF_Field_Renderer_Preview_Image extends WPCF_Field_Renderer_Previe
|
|
56 |
* @since 1.9.1
|
57 |
*/
|
58 |
protected function try_finding_attachment( $url ) {
|
59 |
-
$attachment_id =
|
60 |
if( 0 == $attachment_id ) {
|
61 |
return $url;
|
62 |
}
|
@@ -87,4 +87,4 @@ final class WPCF_Field_Renderer_Preview_Image extends WPCF_Field_Renderer_Previe
|
|
87 |
return 0;
|
88 |
}
|
89 |
|
90 |
-
}
|
4 |
* Preview renderer for image fields.
|
5 |
*
|
6 |
* Tries to be clever about WP attachments and use thumbnails instead of full size images whenever possible.
|
7 |
+
*
|
8 |
+
* For displaying the full image on clicking on the preview, you need to enqueue the 'wpcf-js' script and
|
9 |
* the 'wptoolset-forms-admin' style
|
10 |
*
|
11 |
* @since 1.9.1
|
24 |
*/
|
25 |
protected function render_single( $value ) {
|
26 |
|
27 |
+
if( !is_string( $value ) || empty( $value ) ) {
|
28 |
return '';
|
29 |
}
|
30 |
|
56 |
* @since 1.9.1
|
57 |
*/
|
58 |
protected function try_finding_attachment( $url ) {
|
59 |
+
$attachment_id = Types_Utils::get_attachment_id_by_url( $url );
|
60 |
if( 0 == $attachment_id ) {
|
61 |
return $url;
|
62 |
}
|
87 |
return 0;
|
88 |
}
|
89 |
|
90 |
+
}
|
library/toolset/types/embedded/classes/field/renderer/preview/radio.php
CHANGED
@@ -20,7 +20,7 @@ final class WPCF_Field_Renderer_Preview_Radio extends WPCF_Field_Renderer_Previe
|
|
20 |
return '';
|
21 |
}
|
22 |
|
23 |
-
$output = $option->
|
24 |
|
25 |
return sanitize_text_field( $output );
|
26 |
}
|
20 |
return '';
|
21 |
}
|
22 |
|
23 |
+
$output = $option->get_display_value( true );
|
24 |
|
25 |
return sanitize_text_field( $output );
|
26 |
}
|
library/toolset/types/embedded/classes/field/renderer/preview/textfield.php
CHANGED
@@ -22,10 +22,11 @@ class WPCF_Field_Renderer_Preview_Textfield extends WPCF_Field_Renderer_Preview_
|
|
22 |
// Keep maximum length per item
|
23 |
$max_length = $this->get_maximum_item_length();
|
24 |
if( 0 < $max_length && $max_length < strlen( $value ) ) {
|
25 |
-
$
|
|
|
26 |
}
|
27 |
-
|
28 |
return $value;
|
29 |
}
|
30 |
|
31 |
-
}
|
22 |
// Keep maximum length per item
|
23 |
$max_length = $this->get_maximum_item_length();
|
24 |
if( 0 < $max_length && $max_length < strlen( $value ) ) {
|
25 |
+
$ellipsis = $this->get_ellipsis();
|
26 |
+
$value = substr( $value, 0, $max_length - strlen( $ellipsis ) ) . $ellipsis;
|
27 |
}
|
28 |
+
|
29 |
return $value;
|
30 |
}
|
31 |
|
32 |
+
}
|
library/toolset/types/embedded/classes/field/renderer/preview/url.php
CHANGED
@@ -10,7 +10,7 @@ class WPCF_Field_Renderer_Preview_URL extends WPCF_Field_Renderer_Preview_Base {
|
|
10 |
protected function render_single( $value ) {
|
11 |
|
12 |
if( is_string( $value ) && !empty( $value ) ) {
|
13 |
-
|
14 |
$url_components = parse_url( $value );
|
15 |
if( false == $url_components ) {
|
16 |
return '';
|
@@ -55,7 +55,9 @@ class WPCF_Field_Renderer_Preview_URL extends WPCF_Field_Renderer_Preview_Base {
|
|
55 |
$url_query = ( empty( $url_query ) ? '' : '?' . $url_query );
|
56 |
|
57 |
$url_path = wpcf_getarr( $url_components, 'path' );
|
58 |
-
|
|
|
|
|
59 |
// Omit last slash when it would be the last label character
|
60 |
$url_path = substr( $url_path, 0, strlen( $url_path ) -1 );
|
61 |
}
|
10 |
protected function render_single( $value ) {
|
11 |
|
12 |
if( is_string( $value ) && !empty( $value ) ) {
|
13 |
+
|
14 |
$url_components = parse_url( $value );
|
15 |
if( false == $url_components ) {
|
16 |
return '';
|
55 |
$url_query = ( empty( $url_query ) ? '' : '?' . $url_query );
|
56 |
|
57 |
$url_path = wpcf_getarr( $url_components, 'path' );
|
58 |
+
$path_ends_with_slash = ( substr( $url_path, -1 ) == '/' );
|
59 |
+
|
60 |
+
if( empty( $url_query ) && $path_ends_with_slash ) {
|
61 |
// Omit last slash when it would be the last label character
|
62 |
$url_path = substr( $url_path, 0, strlen( $url_path ) -1 );
|
63 |
}
|
library/toolset/types/embedded/classes/forms.php
CHANGED
@@ -100,10 +100,12 @@ class Enlimbo_Forms_Wpcf
|
|
100 |
$this );
|
101 |
do_action( 'wpcf_form_autohandle_redirection_' . $id, $form,
|
102 |
$this );
|
103 |
-
if
|
104 |
-
|
105 |
-
|
106 |
-
|
|
|
|
|
107 |
}
|
108 |
}
|
109 |
}
|
@@ -764,7 +766,9 @@ class Enlimbo_Forms_Wpcf
|
|
764 |
}
|
765 |
|
766 |
$before = '';
|
767 |
-
$after = '
|
|
|
|
|
768 |
$list = false;
|
769 |
|
770 |
if (
|
100 |
$this );
|
101 |
do_action( 'wpcf_form_autohandle_redirection_' . $id, $form,
|
102 |
$this );
|
103 |
+
if( ! headers_sent() ) {
|
104 |
+
if ( !isset( $form['#form']['redirection'] ) ) {
|
105 |
+
header( 'Location: ' . $_SERVER['REQUEST_URI'] );
|
106 |
+
} else if ( $form['#form']['redirection'] != false ) {
|
107 |
+
header( 'Location: ' . $form['#form']['redirection'] );
|
108 |
+
}
|
109 |
}
|
110 |
}
|
111 |
}
|
766 |
}
|
767 |
|
768 |
$before = '';
|
769 |
+
$after = isset($element['#options-after'])
|
770 |
+
? $element['#options-after']
|
771 |
+
: '<br >';
|
772 |
$list = false;
|
773 |
|
774 |
if (
|
library/toolset/types/embedded/classes/gui/term_field_editing.php
CHANGED
@@ -24,25 +24,48 @@ final class WPCF_GUI_Term_Field_Editing {
|
|
24 |
const EDIT_FORM_ID = 'edittag';
|
25 |
const ADD_FORM_ID = 'addtag';
|
26 |
|
|
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
public static function initialize() {
|
29 |
if( null == self::$instance ) {
|
30 |
self::$instance = new self();
|
31 |
}
|
|
|
|
|
32 |
}
|
33 |
|
34 |
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
|
39 |
|
|
|
|
|
|
|
40 |
/**
|
41 |
* Hooks into taxonomy-specific actions if there are some term field groups associated.
|
42 |
*/
|
43 |
private function add_hooks() {
|
44 |
|
45 |
-
$factory =
|
46 |
$groups_by_taxonomies = $factory->get_groups_by_taxonomies();
|
47 |
|
48 |
$is_toolset_forms_support_needed = false;
|
@@ -53,7 +76,7 @@ final class WPCF_GUI_Term_Field_Editing {
|
|
53 |
|
54 |
add_action( "{$taxonomy}_add_form_fields", array( $this, 'on_term_add' ) );
|
55 |
add_action( "{$taxonomy}_edit_form_fields", array( $this, 'on_term_edit' ), 10, 2 );
|
56 |
-
|
57 |
add_action( "edit_{$taxonomy}", array( $this, 'on_term_update' ), 10, 2 );
|
58 |
|
59 |
$is_toolset_forms_support_needed = true;
|
@@ -61,11 +84,14 @@ final class WPCF_GUI_Term_Field_Editing {
|
|
61 |
}
|
62 |
|
63 |
// Columns on the term listing
|
64 |
-
$
|
|
|
|
|
65 |
if( $is_term_listing_page ) {
|
66 |
$screen = get_current_screen();
|
67 |
add_action( "manage_{$screen->id}_columns", array( $this, 'manage_term_listing_columns' ) );
|
68 |
-
add_filter( "manage_{$screen->taxonomy}_custom_column", array( $this, 'manage_term_listing_cell'), 10, 3 );
|
|
|
69 |
}
|
70 |
|
71 |
if( $is_toolset_forms_support_needed ) {
|
@@ -75,22 +101,19 @@ final class WPCF_GUI_Term_Field_Editing {
|
|
75 |
|
76 |
|
77 |
public function on_term_add( $taxonomy_slug ) {
|
78 |
-
$
|
|
|
79 |
|
80 |
-
if(
|
81 |
-
printf(
|
82 |
-
'<div class="wpcf-add-term-page-box"><strong>%s</strong></div>',
|
83 |
-
__( 'This taxonomy has custom fields. You will be able to edit them after the term is saved.', 'wpcf' )
|
84 |
-
);
|
85 |
-
}
|
86 |
-
|
87 |
-
/*if( empty( $groups ) ) {
|
88 |
return;
|
89 |
}
|
90 |
|
|
|
|
|
|
|
91 |
foreach( $groups as $group ) {
|
92 |
$this->render_field_group_add_page( $group, null );
|
93 |
-
}
|
94 |
}
|
95 |
|
96 |
|
@@ -105,7 +128,8 @@ final class WPCF_GUI_Term_Field_Editing {
|
|
105 |
* @param string $taxonomy_slug Taxonomy where the term belongs.
|
106 |
*/
|
107 |
public function on_term_edit( $term, $taxonomy_slug ) {
|
108 |
-
$
|
|
|
109 |
|
110 |
if( empty( $groups ) ) {
|
111 |
return;
|
@@ -124,7 +148,8 @@ final class WPCF_GUI_Term_Field_Editing {
|
|
124 |
if( ! $term instanceof WP_Term ) {
|
125 |
return;
|
126 |
}
|
127 |
-
$
|
|
|
128 |
if( empty( $groups ) ) {
|
129 |
return;
|
130 |
}
|
@@ -246,6 +271,19 @@ final class WPCF_GUI_Term_Field_Editing {
|
|
246 |
// Hacky, but better than re-registering the toolset-forms stylesheet elsewhere.
|
247 |
$faux_form_bootstrap = new WPToolset_Forms_Bootstrap();
|
248 |
$faux_form_bootstrap->form( 'faux' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
}
|
250 |
|
251 |
|
@@ -262,7 +300,7 @@ final class WPCF_GUI_Term_Field_Editing {
|
|
262 |
/**
|
263 |
* Render table rows with individual field group.
|
264 |
*
|
265 |
-
* @param
|
266 |
* @param int|null $term_id ID of the term whose fields are being rendered.
|
267 |
*/
|
268 |
private function render_field_group_edit_page( $field_group, $term_id ) {
|
@@ -287,25 +325,26 @@ final class WPCF_GUI_Term_Field_Editing {
|
|
287 |
/**
|
288 |
* Render table rows with individual field group.
|
289 |
*
|
290 |
-
* @param
|
291 |
* @param int|null $term_id ID of the term whose fields are being rendered.
|
|
|
292 |
*/
|
293 |
-
|
294 |
$field_definitions = $field_group->get_field_definitions();
|
295 |
|
296 |
printf(
|
297 |
'<hr /><h4>%s</h4>',
|
298 |
-
$field_group->
|
299 |
);
|
300 |
|
301 |
-
|
302 |
foreach( $field_definitions as $field_definition ) {
|
303 |
printf(
|
304 |
'<div class="form-field wpcf-add-term-form-field">%s</div>',
|
305 |
$this->get_toolset_forms_field( $field_definition, self::ADD_FORM_ID, $term_id, false )
|
306 |
);
|
307 |
}
|
308 |
-
}
|
309 |
|
310 |
|
311 |
/**
|
@@ -338,6 +377,9 @@ final class WPCF_GUI_Term_Field_Editing {
|
|
338 |
const LISTING_COLUMN_PREFIX = 'wpcf_field_';
|
339 |
|
340 |
|
|
|
|
|
|
|
341 |
/**
|
342 |
* Add a column for each term field on the term listing page.
|
343 |
*
|
@@ -349,7 +391,8 @@ final class WPCF_GUI_Term_Field_Editing {
|
|
349 |
public function manage_term_listing_columns( $columns ) {
|
350 |
|
351 |
$taxonomy_slug = wpcf_getget( 'taxonomy' );
|
352 |
-
$
|
|
|
353 |
|
354 |
$columns_to_insert = array();
|
355 |
foreach( $groups as $group ) {
|
@@ -358,9 +401,17 @@ final class WPCF_GUI_Term_Field_Editing {
|
|
358 |
}
|
359 |
}
|
360 |
|
|
|
|
|
361 |
// Insert before the last column, which displays counts of posts using the term (that's probably why column
|
362 |
// has the label "Count" and name "posts" :-P).
|
363 |
-
|
|
|
|
24 |
const EDIT_FORM_ID = 'edittag';
|
25 |
const ADD_FORM_ID = 'addtag';
|
26 |
|
27 |
+
const PAGE_SCRIPT_NAME = 'types-add-term-page';
|
28 |
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Initialize the page extension.
|
32 |
+
*
|
33 |
+
* @since 1.9
|
34 |
+
*/
|
35 |
public static function initialize() {
|
36 |
if( null == self::$instance ) {
|
37 |
self::$instance = new self();
|
38 |
}
|
39 |
+
|
40 |
+
self::$instance->add_hooks();
|
41 |
}
|
42 |
|
43 |
|
44 |
+
/**
|
45 |
+
* Get an instance of the page extension but don't initialize it.
|
46 |
+
*
|
47 |
+
* Useful for using some methods during AJAX call.
|
48 |
+
*
|
49 |
+
* @return WPCF_GUI_Term_Field_Editing
|
50 |
+
* @since 2.1
|
51 |
+
*/
|
52 |
+
public static function get_instance() {
|
53 |
+
if( null == self::$instance ) {
|
54 |
+
self::$instance = new self();
|
55 |
+
}
|
56 |
+
return self::$instance;
|
57 |
}
|
58 |
|
59 |
|
60 |
+
private function __construct() { }
|
61 |
+
|
62 |
+
|
63 |
/**
|
64 |
* Hooks into taxonomy-specific actions if there are some term field groups associated.
|
65 |
*/
|
66 |
private function add_hooks() {
|
67 |
|
68 |
+
$factory = Types_Field_Group_Term_Factory::get_instance();
|
69 |
$groups_by_taxonomies = $factory->get_groups_by_taxonomies();
|
70 |
|
71 |
$is_toolset_forms_support_needed = false;
|
76 |
|
77 |
add_action( "{$taxonomy}_add_form_fields", array( $this, 'on_term_add' ) );
|
78 |
add_action( "{$taxonomy}_edit_form_fields", array( $this, 'on_term_edit' ), 10, 2 );
|
79 |
+
add_action( "create_{$taxonomy}", array( $this, 'on_term_update' ), 10, 2 );
|
80 |
add_action( "edit_{$taxonomy}", array( $this, 'on_term_update' ), 10, 2 );
|
81 |
|
82 |
$is_toolset_forms_support_needed = true;
|
84 |
}
|
85 |
|
86 |
// Columns on the term listing
|
87 |
+
$main_controller = Types_Main::get_instance();
|
88 |
+
$is_term_listing_page = ( $main_controller->is_admin() && 'edit' != wpcf_getget( 'action' ) );
|
89 |
+
|
90 |
if( $is_term_listing_page ) {
|
91 |
$screen = get_current_screen();
|
92 |
add_action( "manage_{$screen->id}_columns", array( $this, 'manage_term_listing_columns' ) );
|
93 |
+
add_filter( "manage_{$screen->taxonomy}_custom_column", array( $this, 'manage_term_listing_cell' ), 10, 3 );
|
94 |
+
add_filter( 'hidden_columns', array( $this, 'filter_hidden_columns' ), 10, 3 );
|
95 |
}
|
96 |
|
97 |
if( $is_toolset_forms_support_needed ) {
|
101 |
|
102 |
|
103 |
public function on_term_add( $taxonomy_slug ) {
|
104 |
+
$factory = Types_Field_Group_Term_Factory::get_instance();
|
105 |
+
$groups = $factory->get_groups_by_taxonomy( $taxonomy_slug );
|
106 |
|
107 |
+
if( empty( $groups ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
return;
|
109 |
}
|
110 |
|
111 |
+
// Indicate (by existence of this id) that we need to clean up after custom fields on submit.
|
112 |
+
echo( '<input type="hidden" id="types-groups-exist" />' );
|
113 |
+
|
114 |
foreach( $groups as $group ) {
|
115 |
$this->render_field_group_add_page( $group, null );
|
116 |
+
}
|
117 |
}
|
118 |
|
119 |
|
128 |
* @param string $taxonomy_slug Taxonomy where the term belongs.
|
129 |
*/
|
130 |
public function on_term_edit( $term, $taxonomy_slug ) {
|
131 |
+
$factory = Types_Field_Group_Term_Factory::get_instance();
|
132 |
+
$groups = $factory->get_groups_by_taxonomy( $taxonomy_slug );
|
133 |
|
134 |
if( empty( $groups ) ) {
|
135 |
return;
|
148 |
if( ! $term instanceof WP_Term ) {
|
149 |
return;
|
150 |
}
|
151 |
+
$factory = Types_Field_Group_Term_Factory::get_instance();
|
152 |
+
$groups = $factory->get_groups_by_taxonomy( $term->taxonomy );
|
153 |
if( empty( $groups ) ) {
|
154 |
return;
|
155 |
}
|
271 |
// Hacky, but better than re-registering the toolset-forms stylesheet elsewhere.
|
272 |
$faux_form_bootstrap = new WPToolset_Forms_Bootstrap();
|
273 |
$faux_form_bootstrap->form( 'faux' );
|
274 |
+
|
275 |
+
$asset_manager = Types_Asset_Manager::get_instance();
|
276 |
+
|
277 |
+
// Enqueue the main page script
|
278 |
+
$asset_manager->register_script(
|
279 |
+
self::PAGE_SCRIPT_NAME,
|
280 |
+
TYPES_RELPATH . '/public/page/add_term.js',
|
281 |
+
array( 'jquery', 'toolset-utils' ),
|
282 |
+
TYPES_VERSION,
|
283 |
+
true
|
284 |
+
);
|
285 |
+
|
286 |
+
$asset_manager->enqueue_scripts( self::PAGE_SCRIPT_NAME );
|
287 |
}
|
288 |
|
289 |
|
300 |
/**
|
301 |
* Render table rows with individual field group.
|
302 |
*
|
303 |
+
* @param Types_Field_Group_Term $field_group
|
304 |
* @param int|null $term_id ID of the term whose fields are being rendered.
|
305 |
*/
|
306 |
private function render_field_group_edit_page( $field_group, $term_id ) {
|
325 |
/**
|
326 |
* Render table rows with individual field group.
|
327 |
*
|
328 |
+
* @param Types_Field_Group_Term $field_group
|
329 |
* @param int|null $term_id ID of the term whose fields are being rendered.
|
330 |
+
* @since 2.1
|
331 |
*/
|
332 |
+
private function render_field_group_add_page( $field_group, $term_id ) {
|
333 |
$field_definitions = $field_group->get_field_definitions();
|
334 |
|
335 |
printf(
|
336 |
'<hr /><h4>%s</h4>',
|
337 |
+
$field_group->get_display_name()
|
338 |
);
|
339 |
|
340 |
+
/** @var WPCF_Field_Definition_Term $field_definition */
|
341 |
foreach( $field_definitions as $field_definition ) {
|
342 |
printf(
|
343 |
'<div class="form-field wpcf-add-term-form-field">%s</div>',
|
344 |
$this->get_toolset_forms_field( $field_definition, self::ADD_FORM_ID, $term_id, false )
|
345 |
);
|
346 |
}
|
347 |
+
}
|
348 |
|
349 |
|
350 |
/**
|
377 |
const LISTING_COLUMN_PREFIX = 'wpcf_field_';
|
378 |
|
379 |
|
380 |
+
private $added_listing_columns = array();
|
381 |
+
|
382 |
+
|
383 |
/**
|
384 |
* Add a column for each term field on the term listing page.
|
385 |
*
|
391 |
public function manage_term_listing_columns( $columns ) {
|
392 |
|
393 |
$taxonomy_slug = wpcf_getget( 'taxonomy' );
|
394 |
+
$factory = Types_Field_Group_Term_Factory::get_instance();
|
395 |
+
$groups = $factory->get_groups_by_taxonomy( $taxonomy_slug );
|
396 |
|
397 |
$columns_to_insert = array();
|
398 |
foreach( $groups as $group ) {
|
401 |
}
|
402 |
}
|
403 |
|
404 |
+
$this->added_listing_columns = $columns_to_insert;
|
405 |
+
|
406 |
// Insert before the last column, which displays counts of posts using the term (that's probably why column
|
407 |
// has the label "Count" and name "posts" :-P).
|
408 |
+
// If there is no "posts"=>"Count" column, insert at the end.
|
409 |
+
if( isset ( $columns['posts'] ) && 'Count' == $columns['posts'] ){
|
410 |
+
$columns = Types_Utils::insert_at_position( $columns, $columns_to_insert, array( 'ke
|