Version Description
Download this release
Release Info
Developer | MotoPress |
Plugin | Timetable and Event Schedule by MotoPress |
Version | 2.3.16 |
Comparing to | |
See all releases |
Code changes from version 2.3.14 to 2.3.16
- admin/import/export.php +5 -5
- admin/import/footer.php +1 -1
- admin/import/greet.php +3 -3
- admin/import/header.php +2 -2
- admin/import/import.php +6 -6
- admin/import/index.php +14 -14
- changelog.txt +159 -0
- classes/blocks/class-timetable-block.php +4 -2
- classes/class-core.php +24 -1
- classes/class-hooks.php +14 -3
- classes/class-model.php +41 -41
- classes/class-module.php +20 -20
- classes/class-permalinks.php +138 -138
- classes/class-preprocessor.php +182 -182
- classes/class-shortcode.php +1 -0
- classes/class-state-factory.php +84 -84
- classes/class-view.php +235 -235
- classes/class-widgets-manager.php +28 -0
- classes/controllers/class-controller-column.php +42 -42
- classes/controllers/class-controller-events.php +112 -112
- classes/controllers/class-controller-help.php +28 -28
- classes/controllers/class-controller-import.php +34 -34
- classes/controllers/class-controller-popup.php +38 -38
- classes/controllers/class-controller-settings.php +72 -72
- classes/libs/class-gump.php +2029 -2029
- classes/models/class-column.php +217 -217
- classes/models/class-export.php +482 -482
- classes/models/class-import.php +968 -968
- classes/models/class-settings.php +105 -105
- classes/modules/class-menu.php +33 -33
- classes/modules/class-post.php +104 -104
- classes/modules/class-taxonomy.php +42 -42
- classes/widgets/class-mp-timetable-elementor-widget.php +473 -0
- classes/widgets/class-mp-timetable-widget.php +142 -142
- languages/mp-timetable.pot +268 -202
- media/js/blocks/dist/index.js +1 -1
- media/js/blocks/src/timetable/edit.js +2 -2
- media/js/blocks/src/timetable/inspector.js +1 -1
- media/js/events/event.js +971 -971
- media/js/events/event.min.js +1 -1
- media/js/mce-timeTable-buttons.js +141 -141
- media/js/mce-timeTable-buttons.min.js +1 -1
- media/js/mptt-elementor-editor.js +15 -0
- media/js/mptt-elementor-editor.min.js +1 -0
- media/js/mptt-functions.js +369 -369
- media/less/admin.less +119 -119
- media/less/no-js.less +31 -31
- media/less/style.less +480 -480
- media/less/theme.less +161 -161
- mp-timetable.php +7 -1
- readme.txt +10 -157
- templates-functions/action-mp-column-functions.php +79 -79
- templates-functions/action-shortcode-functions.php +11 -8
- templates-functions/action-widget-functions.php +55 -55
- templates-functions/actions-mp-event-functions.php +201 -201
- templates/column/metabox-column-options.php +55 -55
- templates/events/column-category.php +7 -7
- templates/events/metabox-event-options.php +49 -49
- templates/shortcodes/event-container.php +1 -1
- templates/shortcodes/index-timetable.php +8 -8
- templates/shortcodes/table-header.php +9 -9
- templates/single-mp-column.php +27 -27
- templates/single-mp-event.php +36 -36
- templates/templates-actions/action-sidebar.php +19 -19
- templates/theme/column-events.php +47 -47
- templates/theme/event-timeslots.php +44 -44
- templates/theme/widget-upcoming-view.php +58 -58
- templates/widgets/gallery-list.php +153 -153
- templates/widgets/widget-view.php +95 -95
admin/import/export.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<h3><?php _e('Export', 'mp-timetable') ?></h3>
|
2 |
-
<form novalidate="novalidate" method="post" id="mptt_export">
|
3 |
-
<input type="hidden" name="controller" value="import">
|
4 |
-
<input type="hidden" name="mptt_action" value="export">
|
5 |
-
<p class="submit"><input type="submit" value="<?php _e('Export', 'mp-timetable') ?>" class="button button-primary" id="submit" name="submit"></p>
|
6 |
</form>
|
1 |
+
<h3><?php _e('Export', 'mp-timetable') ?></h3>
|
2 |
+
<form novalidate="novalidate" method="post" id="mptt_export">
|
3 |
+
<input type="hidden" name="controller" value="import">
|
4 |
+
<input type="hidden" name="mptt_action" value="export">
|
5 |
+
<p class="submit"><input type="submit" value="<?php _e('Export', 'mp-timetable') ?>" class="button button-primary" id="submit" name="submit"></p>
|
6 |
</form>
|
admin/import/footer.php
CHANGED
@@ -1 +1 @@
|
|
1 |
-
</div>
|
1 |
+
</div>
|
admin/import/greet.php
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
<div class="narrow">
|
2 |
-
<p><?php _e('Choose a WXR (.xml) file to upload, then click Upload file and import.', 'mp-timetable') ?></p>
|
3 |
-
<?php wp_import_upload_form('admin.php?import=mptt-importer&step=1') ?>
|
4 |
</div>
|
1 |
+
<div class="narrow">
|
2 |
+
<p><?php _e('Choose a WXR (.xml) file to upload, then click Upload file and import.', 'mp-timetable') ?></p>
|
3 |
+
<?php wp_import_upload_form('admin.php?import=mptt-importer&step=1') ?>
|
4 |
</div>
|
admin/import/header.php
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
<div class="wrap">
|
2 |
-
<h1 class="wp-heading-inline"><?php _e('Import / Export Timetable Plugin Data', 'mp-timetable') ?></h1>
|
1 |
+
<div class="wrap">
|
2 |
+
<h1 class="wp-heading-inline"><?php _e('Import / Export Timetable Plugin Data', 'mp-timetable') ?></h1>
|
admin/import/import.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( current_user_can('import') ) { ?>
|
4 |
-
<h3><?php _e('Import', 'mp-timetable') ?></h3><?php
|
5 |
-
wp_import_upload_form('admin.php?import=mptt-importer&step=1');
|
6 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( current_user_can('import') ) { ?>
|
4 |
+
<h3><?php _e('Import', 'mp-timetable') ?></h3><?php
|
5 |
+
wp_import_upload_form('admin.php?import=mptt-importer&step=1');
|
6 |
+
}
|
admin/import/index.php
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
-
<?php
|
2 |
-
use mp_timetable\plugin_core\classes\View as View;
|
3 |
-
|
4 |
-
View::get_instance()->render_html('../admin/import/header', $data);
|
5 |
-
|
6 |
-
if ( current_user_can('export') ) {
|
7 |
-
View::get_instance()->render_html('../admin/import/export', $data);
|
8 |
-
}
|
9 |
-
|
10 |
-
if ( current_user_can('import') ) {
|
11 |
-
View::get_instance()->render_html('../admin/import/import', $data);
|
12 |
-
}
|
13 |
-
|
14 |
-
View::get_instance()->render_html('../admin/import/footer', $data);
|
1 |
+
<?php
|
2 |
+
use mp_timetable\plugin_core\classes\View as View;
|
3 |
+
|
4 |
+
View::get_instance()->render_html('../admin/import/header', $data);
|
5 |
+
|
6 |
+
if ( current_user_can('export') ) {
|
7 |
+
View::get_instance()->render_html('../admin/import/export', $data);
|
8 |
+
}
|
9 |
+
|
10 |
+
if ( current_user_can('import') ) {
|
11 |
+
View::get_instance()->render_html('../admin/import/import', $data);
|
12 |
+
}
|
13 |
+
|
14 |
+
View::get_instance()->render_html('../admin/import/footer', $data);
|
changelog.txt
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
= 2.3.14, Feb 4 2021 =
|
2 |
+
* Improved plugin internalization.
|
3 |
+
|
4 |
+
= 2.3.13, Feb 3 2021 =
|
5 |
+
* Bug fix: fixed an issue with double slashes in the assets' URLs.
|
6 |
+
* Improved plugin internalization.
|
7 |
+
|
8 |
+
= 2.3.12, Dec 11 2020 =
|
9 |
+
* Improved compatibility with WordPress 5.6.
|
10 |
+
|
11 |
+
= 2.3.11, May 18 2020 =
|
12 |
+
* Added the ability to duplicate events.
|
13 |
+
* Added the ability to set table layout fixed or auto.
|
14 |
+
* Bug fix: fixed an issue with an empty categories list in the widget.
|
15 |
+
|
16 |
+
= 2.3.10, Apr 24 2020 =
|
17 |
+
* Bug fix: fixed an issue when a user with the Editor role could not access the administration area.
|
18 |
+
* Improved compatibility with PHP 7.4.
|
19 |
+
|
20 |
+
= 2.3.9, Apr 21 2020 =
|
21 |
+
* Added the ability to sort events in the dropdown list or tabs.
|
22 |
+
* Improved user capability check.
|
23 |
+
|
24 |
+
= 2.3.8, Apr 1 2020 =
|
25 |
+
* Bug fix: fixed an issue with the missing Event tags field.
|
26 |
+
* Bug fix: fixed an issue when a user with the read capability could access a Help menu page.
|
27 |
+
|
28 |
+
= 2.3.7, Mar 10 2020 =
|
29 |
+
* Bug fix: fixed an issue with the erroneous positioning of events.
|
30 |
+
|
31 |
+
= 2.3.6, Feb 19 2020 =
|
32 |
+
* Bug fix: fixed an issue with the missing subtitle in mobile view.
|
33 |
+
|
34 |
+
= 2.3.5, Feb 19 2020 =
|
35 |
+
* Bug fix: fixed an issue with slashes in event description.
|
36 |
+
|
37 |
+
= 2.3.4, Sep 25 2019 =
|
38 |
+
* Bug fix: fixed an issue with UTC timezone offset.
|
39 |
+
|
40 |
+
= 2.3.3, Sep 20 2019 =
|
41 |
+
* Bug fix: fixed the issue with events disappearing on hover in Chrome.
|
42 |
+
|
43 |
+
= 2.3.2 =
|
44 |
+
* Bug fix: fixed an issue in IE browser.
|
45 |
+
|
46 |
+
= 2.3.1 =
|
47 |
+
* Bug fix: fixed the issue with opening PHP tag.
|
48 |
+
|
49 |
+
= 2.3.0 =
|
50 |
+
* Added support for WordPress 5.0.
|
51 |
+
|
52 |
+
= 2.2.1 =
|
53 |
+
* Bug fix: fixed an issue with URL hash (not-set:all).
|
54 |
+
|
55 |
+
= 2.2.0 =
|
56 |
+
* Added filters for register_post_type and register_taxonomy functions.
|
57 |
+
* Added permalink configuration option in Settings > Permalinks.
|
58 |
+
|
59 |
+
= 2.1.12 =
|
60 |
+
* Bug fix: fixed an issue in IE browser.
|
61 |
+
|
62 |
+
= 2.1.11 =
|
63 |
+
* Added translations into the Persian language.
|
64 |
+
|
65 |
+
= 2.1.10 =
|
66 |
+
* Improved compatibility with WooCommerce Memberships plugin.
|
67 |
+
* Better W3C validation.
|
68 |
+
|
69 |
+
= 2.1.9 =
|
70 |
+
* Bug fix: fixed the issue when event was not visible in the timetable if it starts at 00:00.
|
71 |
+
|
72 |
+
= 2.1.8 =
|
73 |
+
* Improved compatibility with javascript-disabled browsers.
|
74 |
+
|
75 |
+
= 2.1.7 =
|
76 |
+
* Bug fix: fixed the issue when events were not filtered by the selected category in a widget.
|
77 |
+
* Bug fix: fixed the issue when event was not visible in the timetable if it ends the next day.
|
78 |
+
* Minor bugfixes and improvements.
|
79 |
+
|
80 |
+
= 2.1.6 =
|
81 |
+
* New dashboard icons.
|
82 |
+
|
83 |
+
= 2.1.5 =
|
84 |
+
* Bug fix: fixed the issue when table is not visible if events filter is set to 'none'.
|
85 |
+
|
86 |
+
= 2.1.4 =
|
87 |
+
* Bug fix: fixed internal issue.
|
88 |
+
|
89 |
+
= 2.1.3 =
|
90 |
+
* Added the ability to merge cells with common events.
|
91 |
+
* Added the ability to set vertical alignment in the table.
|
92 |
+
* Added the ability to set custom CSS class for table shortcode.
|
93 |
+
* Added the ability to hide filter control on the top of the table.
|
94 |
+
* Bug fix: fixed the issue when table ID didn't output on the site.
|
95 |
+
|
96 |
+
= 2.1.2 =
|
97 |
+
* Bug fix: fixed the issue when plugin overrides default archive template.
|
98 |
+
* Bug fix: fixed the issue in upcoming events widget when events were not sorted by days.
|
99 |
+
|
100 |
+
= 2.1.1 =
|
101 |
+
* Bug fix: fixed the issue with shortcode tempalte.
|
102 |
+
|
103 |
+
= 2.1.0 =
|
104 |
+
* Added the ability to override templates in a theme.
|
105 |
+
* Bug fix: fixed the issue on WordPress multisite when Event wasn't saving.
|
106 |
+
* Bug fix: fixed the issue when timeslots didn't show if Event is in the Draft status.
|
107 |
+
|
108 |
+
= 2.0.4 =
|
109 |
+
* Bug fix: fixed an issue with post template on search results page.
|
110 |
+
|
111 |
+
= 2.0.3 =
|
112 |
+
* Bug fix: fixed a link to create new column from event screen.
|
113 |
+
* Improved usernames in Event Head dropdown.
|
114 |
+
|
115 |
+
= 2.0.2 =
|
116 |
+
* Minor bugfixes and improvements.
|
117 |
+
|
118 |
+
= 2.0.1 =
|
119 |
+
* Bug fix: fixed an issue with template override.
|
120 |
+
|
121 |
+
= 2.0.0 =
|
122 |
+
* We improved compatibility with your theme styles in this update. If you still stick to a previous version, simply change the template mode option in the plugin settings.
|
123 |
+
* Added the ability to set font size for timetable shortcode so you can make your text bigger or smaller.
|
124 |
+
|
125 |
+
= 1.1.6 =
|
126 |
+
* Bug fix: fixed an issue with empty rows.
|
127 |
+
|
128 |
+
= 1.1.5 =
|
129 |
+
* Bug fix: fixed an issue with post view in search results.
|
130 |
+
|
131 |
+
= 1.1.4 =
|
132 |
+
* Improved compatibility with Polylang plugin.
|
133 |
+
|
134 |
+
= 1.1.3 =
|
135 |
+
* Fixed an issue with categories filter in widget.
|
136 |
+
|
137 |
+
= 1.1.2 =
|
138 |
+
* Fixed an issue with posts order.
|
139 |
+
|
140 |
+
= 1.1.0 =
|
141 |
+
* Improved events sorting.
|
142 |
+
* Minor bugfixes and improvements.
|
143 |
+
|
144 |
+
= 1.0.7 =
|
145 |
+
* Improved events and columns sorting by date.
|
146 |
+
* Comments section added to event.
|
147 |
+
* Minor bugfixes and improvements.
|
148 |
+
|
149 |
+
= 1.0.6 =
|
150 |
+
* Fixed an issue in column view.
|
151 |
+
|
152 |
+
= 1.0.5 =
|
153 |
+
* Improved compatibility with IE10+
|
154 |
+
|
155 |
+
= 1.0.4 =
|
156 |
+
* Minor bugfixes and improvements.
|
157 |
+
|
158 |
+
= 1.0.3 =
|
159 |
+
* Minor bugfixes and improvements.
|
classes/blocks/class-timetable-block.php
CHANGED
@@ -162,7 +162,7 @@ class Timetable_Block {
|
|
162 |
),
|
163 |
'render_callback' => [ $this, 'render_timetable' ],
|
164 |
'editor_style' => 'mptt-blocks-editor',
|
165 |
-
'editor_script'
|
166 |
)
|
167 |
);
|
168 |
}
|
@@ -180,7 +180,7 @@ class Timetable_Block {
|
|
180 |
}
|
181 |
}
|
182 |
|
183 |
-
echo Shortcode::get_instance()->show_shortcode($attributes);
|
184 |
}
|
185 |
|
186 |
public function render_timetable( $attributes ) {
|
@@ -202,6 +202,8 @@ class Timetable_Block {
|
|
202 |
?></div><?php
|
203 |
|
204 |
$result = ob_get_clean();
|
|
|
205 |
return $result;
|
206 |
}
|
|
|
207 |
}
|
162 |
),
|
163 |
'render_callback' => [ $this, 'render_timetable' ],
|
164 |
'editor_style' => 'mptt-blocks-editor',
|
165 |
+
'editor_script' => 'mptt-blocks-js',
|
166 |
)
|
167 |
);
|
168 |
}
|
180 |
}
|
181 |
}
|
182 |
|
183 |
+
echo Shortcode::get_instance()->show_shortcode( $attributes );
|
184 |
}
|
185 |
|
186 |
public function render_timetable( $attributes ) {
|
202 |
?></div><?php
|
203 |
|
204 |
$result = ob_get_clean();
|
205 |
+
|
206 |
return $result;
|
207 |
}
|
208 |
+
|
209 |
}
|
classes/class-core.php
CHANGED
@@ -315,7 +315,12 @@ class Core {
|
|
315 |
if ( ! empty( $action ) && current_user_can('edit_posts') ) {
|
316 |
// call controller
|
317 |
Preprocessor::get_instance()->call_controller( $action, $controller );
|
318 |
-
|
|
|
|
|
|
|
|
|
|
|
319 |
}
|
320 |
}
|
321 |
|
@@ -638,6 +643,13 @@ class Core {
|
|
638 |
$this->add_plugin_js( 'shortcode' );
|
639 |
}
|
640 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
641 |
|
642 |
/**
|
643 |
* Add plugin js
|
@@ -659,6 +671,17 @@ class Core {
|
|
659 |
wp_enqueue_script( 'mptt-functions', Mp_Time_Table::get_plugin_url( 'media/js/mptt-functions' . $this->get_prefix() . '.js' ), array( 'jquery' ), $this->version );
|
660 |
wp_enqueue_script( 'mptt-event-object' );
|
661 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
662 |
}
|
663 |
}
|
664 |
|
315 |
if ( ! empty( $action ) && current_user_can('edit_posts') ) {
|
316 |
// call controller
|
317 |
Preprocessor::get_instance()->call_controller( $action, $controller );
|
318 |
+
|
319 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
320 |
+
wp_die();
|
321 |
+
} else {
|
322 |
+
die();
|
323 |
+
}
|
324 |
}
|
325 |
}
|
326 |
|
643 |
$this->add_plugin_js( 'shortcode' );
|
644 |
}
|
645 |
}
|
646 |
+
|
647 |
+
/**
|
648 |
+
* Hook elementor_enqueue_scripts
|
649 |
+
*/
|
650 |
+
public function elementor_enqueue_scripts() {
|
651 |
+
$this->add_plugin_js( 'elementor-widget' );
|
652 |
+
}
|
653 |
|
654 |
/**
|
655 |
* Add plugin js
|
671 |
wp_enqueue_script( 'mptt-functions', Mp_Time_Table::get_plugin_url( 'media/js/mptt-functions' . $this->get_prefix() . '.js' ), array( 'jquery' ), $this->version );
|
672 |
wp_enqueue_script( 'mptt-event-object' );
|
673 |
break;
|
674 |
+
case 'elementor-widget':
|
675 |
+
wp_enqueue_script( 'underscore' );
|
676 |
+
wp_enqueue_script( 'mptt-functions', Mp_Time_Table::get_plugin_url( 'media/js/mptt-functions' . $this->get_prefix() . '.js' ), array( 'jquery' ), $this->version );
|
677 |
+
wp_enqueue_script( 'mptt-event-object' );
|
678 |
+
wp_enqueue_script(
|
679 |
+
'mptt-editor-panel-js',
|
680 |
+
Mp_Time_Table::get_plugin_url( 'media/js/mptt-elementor-editor' . $this->get_prefix() . '.js' ),
|
681 |
+
array( 'jquery', 'mptt-functions', 'mptt-event-object' ),
|
682 |
+
$this->version
|
683 |
+
);
|
684 |
+
break;
|
685 |
}
|
686 |
}
|
687 |
|
classes/class-hooks.php
CHANGED
@@ -31,6 +31,8 @@ class Hooks extends Core {
|
|
31 |
* Install hooks
|
32 |
*/
|
33 |
public function install_hooks() {
|
|
|
|
|
34 |
|
35 |
// register custom post type and taxonomies
|
36 |
add_action( 'init', array( $this, 'init' ) );
|
@@ -67,7 +69,8 @@ class Hooks extends Core {
|
|
67 |
add_filter( 'pre_get_posts', array( Post::get_instance(), 'pre_get_posts' ), 9 );
|
68 |
add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 );
|
69 |
}
|
70 |
-
|
|
|
71 |
/**
|
72 |
* Register widgets and sidebar
|
73 |
*/
|
@@ -123,9 +126,17 @@ class Hooks extends Core {
|
|
123 |
add_action( 'mptt_widget_template_before_content', 'mptt_widget_template_before_content', 10 );
|
124 |
add_action( 'mptt_widget_template_content', 'mptt_widget_template_content', 10 );
|
125 |
add_action( 'mptt_widget_template_after_content', 'mptt_widget_template_after_content', 10 );
|
126 |
-
|
127 |
}
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
/**
|
130 |
* Init hook
|
131 |
*/
|
31 |
* Install hooks
|
32 |
*/
|
33 |
public function install_hooks() {
|
34 |
+
// Elementor widget register.
|
35 |
+
add_action( 'elementor/init', array( $this, 'elementor_loaded' ) );
|
36 |
|
37 |
// register custom post type and taxonomies
|
38 |
add_action( 'init', array( $this, 'init' ) );
|
69 |
add_filter( 'pre_get_posts', array( Post::get_instance(), 'pre_get_posts' ), 9 );
|
70 |
add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 );
|
71 |
}
|
72 |
+
|
73 |
+
|
74 |
/**
|
75 |
* Register widgets and sidebar
|
76 |
*/
|
126 |
add_action( 'mptt_widget_template_before_content', 'mptt_widget_template_before_content', 10 );
|
127 |
add_action( 'mptt_widget_template_content', 'mptt_widget_template_content', 10 );
|
128 |
add_action( 'mptt_widget_template_after_content', 'mptt_widget_template_after_content', 10 );
|
|
|
129 |
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Elementor Init hook.
|
133 |
+
*/
|
134 |
+
public function elementor_loaded() {
|
135 |
+
add_action( 'elementor/frontend/after_enqueue_scripts', [ Core::get_instance(), 'elementor_enqueue_scripts' ] );
|
136 |
+
|
137 |
+
new Widgets_Manager();
|
138 |
+
}
|
139 |
+
|
140 |
/**
|
141 |
* Init hook
|
142 |
*/
|
classes/class-model.php
CHANGED
@@ -1,41 +1,41 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\plugin_core\classes;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Model class
|
7 |
-
*/
|
8 |
-
class Model extends Core {
|
9 |
-
|
10 |
-
protected static $instance;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* @return Model
|
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 |
-
/**
|
23 |
-
* Install models by type
|
24 |
-
*/
|
25 |
-
public function install() {
|
26 |
-
// include all core models
|
27 |
-
Core::include_all(\Mp_Time_Table::get_plugin_part_path('classes/models'));
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Get return Array
|
32 |
-
*
|
33 |
-
* @param array $data
|
34 |
-
* @param bool|false $success
|
35 |
-
*
|
36 |
-
* @return array
|
37 |
-
*/
|
38 |
-
public function get_arr($data = array(), $success = false) {
|
39 |
-
return array('success' => $success, 'data' => $data);
|
40 |
-
}
|
41 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\plugin_core\classes;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Model class
|
7 |
+
*/
|
8 |
+
class Model extends Core {
|
9 |
+
|
10 |
+
protected static $instance;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @return Model
|
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 |
+
/**
|
23 |
+
* Install models by type
|
24 |
+
*/
|
25 |
+
public function install() {
|
26 |
+
// include all core models
|
27 |
+
Core::include_all(\Mp_Time_Table::get_plugin_part_path('classes/models'));
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Get return Array
|
32 |
+
*
|
33 |
+
* @param array $data
|
34 |
+
* @param bool|false $success
|
35 |
+
*
|
36 |
+
* @return array
|
37 |
+
*/
|
38 |
+
public function get_arr($data = array(), $success = false) {
|
39 |
+
return array('success' => $success, 'data' => $data);
|
40 |
+
}
|
41 |
+
}
|
classes/class-module.php
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\plugin_core\classes;
|
4 |
-
|
5 |
-
use Mp_Time_Table;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Class Module
|
9 |
-
* @package mp_timetable\plugin_core\classes
|
10 |
-
*/
|
11 |
-
class Module extends Core {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Install controllers
|
15 |
-
*/
|
16 |
-
public static function install() {
|
17 |
-
// include all core controllers
|
18 |
-
Core::include_all(Mp_Time_Table::get_plugin_part_path('classes/modules'));
|
19 |
-
}
|
20 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\plugin_core\classes;
|
4 |
+
|
5 |
+
use Mp_Time_Table;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Class Module
|
9 |
+
* @package mp_timetable\plugin_core\classes
|
10 |
+
*/
|
11 |
+
class Module extends Core {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Install controllers
|
15 |
+
*/
|
16 |
+
public static function install() {
|
17 |
+
// include all core controllers
|
18 |
+
Core::include_all(Mp_Time_Table::get_plugin_part_path('classes/modules'));
|
19 |
+
}
|
20 |
+
}
|
classes/class-permalinks.php
CHANGED
@@ -1,138 +1,138 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\plugin_core\classes;
|
4 |
-
|
5 |
-
class Permalinks {
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Permalink settings.
|
9 |
-
*
|
10 |
-
* @var array
|
11 |
-
*/
|
12 |
-
private $permalinks = array();
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Hook in tabs.
|
16 |
-
*/
|
17 |
-
public function __construct() {
|
18 |
-
$this->settings_init();
|
19 |
-
$this->settings_save();
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Init our settings.
|
24 |
-
*/
|
25 |
-
public function settings_init() {
|
26 |
-
add_settings_section( 'mp-timetable-permalinks', __( 'Timetable Permalinks', 'mp-timetable' ), array( $this, 'settings' ), 'permalink' );
|
27 |
-
|
28 |
-
add_settings_field(
|
29 |
-
'timetable_column_slug',
|
30 |
-
__( 'Column base', 'mp-timetable' ),
|
31 |
-
array( $this, 'timetable_column_slug_input' ),
|
32 |
-
'permalink',
|
33 |
-
'mp-timetable-permalinks'
|
34 |
-
);
|
35 |
-
add_settings_field(
|
36 |
-
'timetable_event_slug',
|
37 |
-
__( 'Event base', 'mp-timetable' ),
|
38 |
-
array( $this, 'timetable_event_slug_input' ),
|
39 |
-
'permalink',
|
40 |
-
'mp-timetable-permalinks'
|
41 |
-
);
|
42 |
-
add_settings_field(
|
43 |
-
'timetable_event_category_slug',
|
44 |
-
__( 'Event Category base', 'mp-timetable' ),
|
45 |
-
array( $this, 'timetable_event_category_slug_input' ),
|
46 |
-
'permalink',
|
47 |
-
'mp-timetable-permalinks'
|
48 |
-
);
|
49 |
-
add_settings_field(
|
50 |
-
'timetable_event_tag_slug',
|
51 |
-
__( 'Event Tag base', 'mp-timetable' ),
|
52 |
-
array( $this, 'timetable_event_tag_slug_input' ),
|
53 |
-
'permalink',
|
54 |
-
'mp-timetable-permalinks'
|
55 |
-
);
|
56 |
-
|
57 |
-
$this->permalinks = Core::get_instance()->get_permalink_structure();
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Show a Column slug input box.
|
62 |
-
*/
|
63 |
-
public function timetable_column_slug_input() {
|
64 |
-
?>
|
65 |
-
<input name="timetable_column_slug" type="text" class="regular-text" value="<?php echo esc_attr( $this->permalinks['column_base'] ); ?>" placeholder="timetable/column" />
|
66 |
-
<?php
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Show an Event slug input box.
|
71 |
-
*/
|
72 |
-
public function timetable_event_slug_input() {
|
73 |
-
?>
|
74 |
-
<input name="timetable_event_slug" type="text" class="regular-text" value="<?php echo esc_attr( $this->permalinks['event_base'] ); ?>" placeholder="timetable/event" />
|
75 |
-
<?php
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Show an Event Category slug input box.
|
80 |
-
*/
|
81 |
-
public function timetable_event_category_slug_input() {
|
82 |
-
?>
|
83 |
-
<input name="timetable_event_category_slug" type="text" class="regular-text" value="<?php echo esc_attr( $this->permalinks['event_category_base'] ); ?>" placeholder="timetable/category" />
|
84 |
-
<?php
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Show an Event Tag slug input box.
|
89 |
-
*/
|
90 |
-
public function timetable_event_tag_slug_input() {
|
91 |
-
?>
|
92 |
-
<input name="timetable_event_tag_slug" type="text" class="regular-text" value="<?php echo esc_attr( $this->permalinks['event_tag_base'] ); ?>" placeholder="timetable/tag" />
|
93 |
-
<?php
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Show the settings.
|
98 |
-
*/
|
99 |
-
public function settings() {
|
100 |
-
wp_nonce_field( 'timetable-permalinks', 'timetable-permalinks-nonce' );
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Save the settings.
|
105 |
-
*/
|
106 |
-
public function settings_save() {
|
107 |
-
if ( ! is_admin() ) {
|
108 |
-
return;
|
109 |
-
}
|
110 |
-
|
111 |
-
// We need to save the options ourselves; settings api does not trigger save for the permalinks page.
|
112 |
-
if ( isset( $_POST['permalink_structure'],
|
113 |
-
$_POST['timetable-permalinks-nonce'],
|
114 |
-
$_POST['timetable_column_slug'],
|
115 |
-
$_POST['timetable_event_slug'],
|
116 |
-
$_POST['timetable_event_category_slug'],
|
117 |
-
$_POST['timetable_event_tag_slug']
|
118 |
-
) && wp_verify_nonce( wp_unslash( $_POST['timetable-permalinks-nonce'] ), 'timetable-permalinks' )
|
119 |
-
) { // WPCS: input var ok, sanitization ok.
|
120 |
-
|
121 |
-
$permalinks = (array) get_option( 'mp_timetable_permalinks', array() );
|
122 |
-
|
123 |
-
$permalinks['column_base'] = $this->sanitize_permalink( wp_unslash( $_POST['timetable_column_slug'] ) ); // WPCS: input var ok, sanitization ok.
|
124 |
-
$permalinks['event_base'] = $this->sanitize_permalink( wp_unslash( $_POST['timetable_event_slug'] ) ); // WPCS: input var ok, sanitization ok.
|
125 |
-
$permalinks['event_category_base'] = $this->sanitize_permalink( wp_unslash( $_POST['timetable_event_category_slug'] ) ); // WPCS: input var ok, sanitization ok.
|
126 |
-
$permalinks['event_tag_base'] = $this->sanitize_permalink( wp_unslash( $_POST['timetable_event_tag_slug'] ) ); // WPCS: input var ok, sanitization ok.
|
127 |
-
|
128 |
-
update_option( 'mp_timetable_permalinks', $permalinks );
|
129 |
-
}
|
130 |
-
}
|
131 |
-
|
132 |
-
private function sanitize_permalink( $value ) {
|
133 |
-
|
134 |
-
$value = esc_url_raw( trim( $value ) );
|
135 |
-
$value = str_replace( 'http://', '', $value );
|
136 |
-
return untrailingslashit( $value );
|
137 |
-
}
|
138 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\plugin_core\classes;
|
4 |
+
|
5 |
+
class Permalinks {
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Permalink settings.
|
9 |
+
*
|
10 |
+
* @var array
|
11 |
+
*/
|
12 |
+
private $permalinks = array();
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Hook in tabs.
|
16 |
+
*/
|
17 |
+
public function __construct() {
|
18 |
+
$this->settings_init();
|
19 |
+
$this->settings_save();
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Init our settings.
|
24 |
+
*/
|
25 |
+
public function settings_init() {
|
26 |
+
add_settings_section( 'mp-timetable-permalinks', __( 'Timetable Permalinks', 'mp-timetable' ), array( $this, 'settings' ), 'permalink' );
|
27 |
+
|
28 |
+
add_settings_field(
|
29 |
+
'timetable_column_slug',
|
30 |
+
__( 'Column base', 'mp-timetable' ),
|
31 |
+
array( $this, 'timetable_column_slug_input' ),
|
32 |
+
'permalink',
|
33 |
+
'mp-timetable-permalinks'
|
34 |
+
);
|
35 |
+
add_settings_field(
|
36 |
+
'timetable_event_slug',
|
37 |
+
__( 'Event base', 'mp-timetable' ),
|
38 |
+
array( $this, 'timetable_event_slug_input' ),
|
39 |
+
'permalink',
|
40 |
+
'mp-timetable-permalinks'
|
41 |
+
);
|
42 |
+
add_settings_field(
|
43 |
+
'timetable_event_category_slug',
|
44 |
+
__( 'Event Category base', 'mp-timetable' ),
|
45 |
+
array( $this, 'timetable_event_category_slug_input' ),
|
46 |
+
'permalink',
|
47 |
+
'mp-timetable-permalinks'
|
48 |
+
);
|
49 |
+
add_settings_field(
|
50 |
+
'timetable_event_tag_slug',
|
51 |
+
__( 'Event Tag base', 'mp-timetable' ),
|
52 |
+
array( $this, 'timetable_event_tag_slug_input' ),
|
53 |
+
'permalink',
|
54 |
+
'mp-timetable-permalinks'
|
55 |
+
);
|
56 |
+
|
57 |
+
$this->permalinks = Core::get_instance()->get_permalink_structure();
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Show a Column slug input box.
|
62 |
+
*/
|
63 |
+
public function timetable_column_slug_input() {
|
64 |
+
?>
|
65 |
+
<input name="timetable_column_slug" type="text" class="regular-text" value="<?php echo esc_attr( $this->permalinks['column_base'] ); ?>" placeholder="timetable/column" />
|
66 |
+
<?php
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Show an Event slug input box.
|
71 |
+
*/
|
72 |
+
public function timetable_event_slug_input() {
|
73 |
+
?>
|
74 |
+
<input name="timetable_event_slug" type="text" class="regular-text" value="<?php echo esc_attr( $this->permalinks['event_base'] ); ?>" placeholder="timetable/event" />
|
75 |
+
<?php
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Show an Event Category slug input box.
|
80 |
+
*/
|
81 |
+
public function timetable_event_category_slug_input() {
|
82 |
+
?>
|
83 |
+
<input name="timetable_event_category_slug" type="text" class="regular-text" value="<?php echo esc_attr( $this->permalinks['event_category_base'] ); ?>" placeholder="timetable/category" />
|
84 |
+
<?php
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Show an Event Tag slug input box.
|
89 |
+
*/
|
90 |
+
public function timetable_event_tag_slug_input() {
|
91 |
+
?>
|
92 |
+
<input name="timetable_event_tag_slug" type="text" class="regular-text" value="<?php echo esc_attr( $this->permalinks['event_tag_base'] ); ?>" placeholder="timetable/tag" />
|
93 |
+
<?php
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Show the settings.
|
98 |
+
*/
|
99 |
+
public function settings() {
|
100 |
+
wp_nonce_field( 'timetable-permalinks', 'timetable-permalinks-nonce' );
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Save the settings.
|
105 |
+
*/
|
106 |
+
public function settings_save() {
|
107 |
+
if ( ! is_admin() ) {
|
108 |
+
return;
|
109 |
+
}
|
110 |
+
|
111 |
+
// We need to save the options ourselves; settings api does not trigger save for the permalinks page.
|
112 |
+
if ( isset( $_POST['permalink_structure'],
|
113 |
+
$_POST['timetable-permalinks-nonce'],
|
114 |
+
$_POST['timetable_column_slug'],
|
115 |
+
$_POST['timetable_event_slug'],
|
116 |
+
$_POST['timetable_event_category_slug'],
|
117 |
+
$_POST['timetable_event_tag_slug']
|
118 |
+
) && wp_verify_nonce( wp_unslash( $_POST['timetable-permalinks-nonce'] ), 'timetable-permalinks' )
|
119 |
+
) { // WPCS: input var ok, sanitization ok.
|
120 |
+
|
121 |
+
$permalinks = (array) get_option( 'mp_timetable_permalinks', array() );
|
122 |
+
|
123 |
+
$permalinks['column_base'] = $this->sanitize_permalink( wp_unslash( $_POST['timetable_column_slug'] ) ); // WPCS: input var ok, sanitization ok.
|
124 |
+
$permalinks['event_base'] = $this->sanitize_permalink( wp_unslash( $_POST['timetable_event_slug'] ) ); // WPCS: input var ok, sanitization ok.
|
125 |
+
$permalinks['event_category_base'] = $this->sanitize_permalink( wp_unslash( $_POST['timetable_event_category_slug'] ) ); // WPCS: input var ok, sanitization ok.
|
126 |
+
$permalinks['event_tag_base'] = $this->sanitize_permalink( wp_unslash( $_POST['timetable_event_tag_slug'] ) ); // WPCS: input var ok, sanitization ok.
|
127 |
+
|
128 |
+
update_option( 'mp_timetable_permalinks', $permalinks );
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
private function sanitize_permalink( $value ) {
|
133 |
+
|
134 |
+
$value = esc_url_raw( trim( $value ) );
|
135 |
+
$value = str_replace( 'http://', '', $value );
|
136 |
+
return untrailingslashit( $value );
|
137 |
+
}
|
138 |
+
}
|
classes/class-preprocessor.php
CHANGED
@@ -1,182 +1,182 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\plugin_core\classes;
|
4 |
-
|
5 |
-
use mp_timetable\classes\libs\GUMP;
|
6 |
-
use \Mp_Time_Table;
|
7 |
-
|
8 |
-
class Preprocessor extends GUMP {
|
9 |
-
|
10 |
-
protected static $instance;
|
11 |
-
|
12 |
-
public static function get_instance() {
|
13 |
-
if (null === self::$instance) {
|
14 |
-
self::$instance = new self();
|
15 |
-
}
|
16 |
-
return self::$instance;
|
17 |
-
}
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Install Preprocessors
|
21 |
-
*/
|
22 |
-
static function install() {
|
23 |
-
Core::include_all( Mp_Time_Table::get_plugin_part_path('classes/preprocessors') );
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Call controller
|
28 |
-
*
|
29 |
-
* @param string $action
|
30 |
-
* @param bool|false $controller
|
31 |
-
*
|
32 |
-
* @return mixed
|
33 |
-
*/
|
34 |
-
public function call_controller($action = 'content', $controller = false) {
|
35 |
-
if (empty($controller)) {
|
36 |
-
trigger_error("Wrong controller ");
|
37 |
-
}
|
38 |
-
$path = Mp_Time_Table::get_plugin_part_path('classes/controllers/');
|
39 |
-
// if controller exists
|
40 |
-
if ('controller' != $controller && !file_exists("{$path}class-controller-{$controller}.php")) {
|
41 |
-
$ControllerName = 'Controller_' . ucfirst($controller);
|
42 |
-
if (class_exists($ControllerName)) {
|
43 |
-
trigger_error("Wrong controller {$path}class-controller-{$controller}.php");
|
44 |
-
}
|
45 |
-
}
|
46 |
-
$action = "action_$action";
|
47 |
-
$controller = Core::get_instance()->get_state()->get_controller($controller);
|
48 |
-
// if method exists
|
49 |
-
if (method_exists($controller, $action)) {
|
50 |
-
return $controller->$action();
|
51 |
-
} else {
|
52 |
-
trigger_error("Wrong {$action} in {$path}class-controller-{$controller}.php");
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Progress
|
58 |
-
*
|
59 |
-
* @param array $params
|
60 |
-
* @param $name
|
61 |
-
* @param $type
|
62 |
-
*
|
63 |
-
* @return array
|
64 |
-
*/
|
65 |
-
protected function progress(array $params, $name, $type) {
|
66 |
-
$success = $this->run($params);
|
67 |
-
if ($success !== false) {
|
68 |
-
return Core::get_instance()->get_model($type)->$name($params);
|
69 |
-
} else {
|
70 |
-
$name = "on_error_{$name}";
|
71 |
-
if (!method_exists($this, $name)) {
|
72 |
-
$name = 'get_errors_array';
|
73 |
-
}
|
74 |
-
return array('success' => $success, 'data' => $this->$name());
|
75 |
-
}
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Process the validation errors and return an array of errors with field names as keys.
|
80 |
-
*
|
81 |
-
* @param $convert_to_string
|
82 |
-
*
|
83 |
-
* @return array | null (if empty)
|
84 |
-
*/
|
85 |
-
public function get_errors_array($convert_to_string = null) {
|
86 |
-
if (empty($this->errors)) {
|
87 |
-
return ($convert_to_string) ? null : array();
|
88 |
-
}
|
89 |
-
|
90 |
-
$resp = array();
|
91 |
-
|
92 |
-
foreach ($this->errors as $e) {
|
93 |
-
$field = ucwords(str_replace(array('_', '-'), chr(32), $e['field']));
|
94 |
-
$param = $e['param'];
|
95 |
-
|
96 |
-
// Let's fetch explicit field names if they exist
|
97 |
-
if (array_key_exists($e['field'], self::$fields)) {
|
98 |
-
$field = self::$fields[$e['field']];
|
99 |
-
}
|
100 |
-
|
101 |
-
switch ($e['rule']) {
|
102 |
-
case 'mismatch' :
|
103 |
-
$resp[$e['field']] = "There is no validation rule for $field";
|
104 |
-
break;
|
105 |
-
case 'validate_required':
|
106 |
-
$resp[$e['field']] = "Enter $field field";
|
107 |
-
break;
|
108 |
-
case 'validate_valid_email':
|
109 |
-
$resp[$e['field']] = "Enter a valid email address";
|
110 |
-
break;
|
111 |
-
case 'validate_max_len':
|
112 |
-
$resp[$e['field']] = "The $field field needs to be $param or shorter in length";
|
113 |
-
break;
|
114 |
-
case 'validate_min_len':
|
115 |
-
$resp[$e['field']] = "The $field field needs to be $param or longer in length";
|
116 |
-
break;
|
117 |
-
case 'validate_exact_len':
|
118 |
-
$resp[$e['field']] = "The $field field needs to be exactly $param characters in length";
|
119 |
-
break;
|
120 |
-
case 'validate_alpha':
|
121 |
-
$resp[$e['field']] = "The $field field may only contain alpha characters(a-z)";
|
122 |
-
break;
|
123 |
-
case 'validate_alpha_numeric':
|
124 |
-
$resp[$e['field']] = "The $field field may only contain alpha-numeric characters";
|
125 |
-
break;
|
126 |
-
case 'validate_alpha_dash':
|
127 |
-
$resp[$e['field']] = "The $field field may only contain alpha characters & dashes";
|
128 |
-
break;
|
129 |
-
case 'validate_numeric':
|
130 |
-
$resp[$e['field']] = "The $field field may only contain numeric characters";
|
131 |
-
break;
|
132 |
-
case 'validate_integer':
|
133 |
-
$resp[$e['field']] = "The $field field may only contain a numeric value";
|
134 |
-
break;
|
135 |
-
case 'validate_boolean':
|
136 |
-
$resp[$e['field']] = "The $field field may only contain a true or false value";
|
137 |
-
break;
|
138 |
-
case 'validate_float':
|
139 |
-
$resp[$e['field']] = "The $field field may only contain a float value";
|
140 |
-
break;
|
141 |
-
case 'validate_valid_url':
|
142 |
-
$resp[$e['field']] = "The $field field is required to be a valid URL";
|
143 |
-
break;
|
144 |
-
case 'validate_url_exists':
|
145 |
-
$resp[$e['field']] = "The $field URL does not exist";
|
146 |
-
break;
|
147 |
-
case 'validate_valid_ip':
|
148 |
-
$resp[$e['field']] = "The $field field needs to contain a valid IP address";
|
149 |
-
break;
|
150 |
-
case 'validate_valid_cc':
|
151 |
-
$resp[$e['field']] = "The $field field needs to contain a valid credit card number";
|
152 |
-
break;
|
153 |
-
case 'validate_valid_name':
|
154 |
-
$resp[$e['field']] = "The $field field needs to contain a valid human name";
|
155 |
-
break;
|
156 |
-
case 'validate_contains':
|
157 |
-
$resp[$e['field']] = "The $field field needs to contain one of these values: " . implode(', ', $param);
|
158 |
-
break;
|
159 |
-
case 'validate_street_address':
|
160 |
-
$resp[$e['field']] = "The $field field needs to be a valid street address";
|
161 |
-
break;
|
162 |
-
case 'validate_date':
|
163 |
-
$resp[$e['field']] = "The $field field needs to be a valid date";
|
164 |
-
break;
|
165 |
-
case 'validate_min_numeric':
|
166 |
-
$resp[$e['field']] = "The $field field needs to be a numeric value, equal to, or higher than $param";
|
167 |
-
break;
|
168 |
-
case 'validate_max_numeric':
|
169 |
-
$resp[$e['field']] = "The $field field needs to be a numeric value, equal to, or lower than $param";
|
170 |
-
break;
|
171 |
-
case 'validate_min_age':
|
172 |
-
$resp[$e['field']] = "The $field field needs to have an age greater than or equal to $param";
|
173 |
-
break;
|
174 |
-
default:
|
175 |
-
$resp[$e['field']] = "The $field field is invalid";
|
176 |
-
}
|
177 |
-
}
|
178 |
-
|
179 |
-
return $resp;
|
180 |
-
}
|
181 |
-
|
182 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\plugin_core\classes;
|
4 |
+
|
5 |
+
use mp_timetable\classes\libs\GUMP;
|
6 |
+
use \Mp_Time_Table;
|
7 |
+
|
8 |
+
class Preprocessor extends GUMP {
|
9 |
+
|
10 |
+
protected static $instance;
|
11 |
+
|
12 |
+
public static function get_instance() {
|
13 |
+
if (null === self::$instance) {
|
14 |
+
self::$instance = new self();
|
15 |
+
}
|
16 |
+
return self::$instance;
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Install Preprocessors
|
21 |
+
*/
|
22 |
+
static function install() {
|
23 |
+
Core::include_all( Mp_Time_Table::get_plugin_part_path('classes/preprocessors') );
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Call controller
|
28 |
+
*
|
29 |
+
* @param string $action
|
30 |
+
* @param bool|false $controller
|
31 |
+
*
|
32 |
+
* @return mixed
|
33 |
+
*/
|
34 |
+
public function call_controller($action = 'content', $controller = false) {
|
35 |
+
if (empty($controller)) {
|
36 |
+
trigger_error("Wrong controller ");
|
37 |
+
}
|
38 |
+
$path = Mp_Time_Table::get_plugin_part_path('classes/controllers/');
|
39 |
+
// if controller exists
|
40 |
+
if ('controller' != $controller && !file_exists("{$path}class-controller-{$controller}.php")) {
|
41 |
+
$ControllerName = 'Controller_' . ucfirst($controller);
|
42 |
+
if (class_exists($ControllerName)) {
|
43 |
+
trigger_error("Wrong controller {$path}class-controller-{$controller}.php");
|
44 |
+
}
|
45 |
+
}
|
46 |
+
$action = "action_$action";
|
47 |
+
$controller = Core::get_instance()->get_state()->get_controller($controller);
|
48 |
+
// if method exists
|
49 |
+
if (method_exists($controller, $action)) {
|
50 |
+
return $controller->$action();
|
51 |
+
} else {
|
52 |
+
trigger_error("Wrong {$action} in {$path}class-controller-{$controller}.php");
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Progress
|
58 |
+
*
|
59 |
+
* @param array $params
|
60 |
+
* @param $name
|
61 |
+
* @param $type
|
62 |
+
*
|
63 |
+
* @return array
|
64 |
+
*/
|
65 |
+
protected function progress(array $params, $name, $type) {
|
66 |
+
$success = $this->run($params);
|
67 |
+
if ($success !== false) {
|
68 |
+
return Core::get_instance()->get_model($type)->$name($params);
|
69 |
+
} else {
|
70 |
+
$name = "on_error_{$name}";
|
71 |
+
if (!method_exists($this, $name)) {
|
72 |
+
$name = 'get_errors_array';
|
73 |
+
}
|
74 |
+
return array('success' => $success, 'data' => $this->$name());
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Process the validation errors and return an array of errors with field names as keys.
|
80 |
+
*
|
81 |
+
* @param $convert_to_string
|
82 |
+
*
|
83 |
+
* @return array | null (if empty)
|
84 |
+
*/
|
85 |
+
public function get_errors_array($convert_to_string = null) {
|
86 |
+
if (empty($this->errors)) {
|
87 |
+
return ($convert_to_string) ? null : array();
|
88 |
+
}
|
89 |
+
|
90 |
+
$resp = array();
|
91 |
+
|
92 |
+
foreach ($this->errors as $e) {
|
93 |
+
$field = ucwords(str_replace(array('_', '-'), chr(32), $e['field']));
|
94 |
+
$param = $e['param'];
|
95 |
+
|
96 |
+
// Let's fetch explicit field names if they exist
|
97 |
+
if (array_key_exists($e['field'], self::$fields)) {
|
98 |
+
$field = self::$fields[$e['field']];
|
99 |
+
}
|
100 |
+
|
101 |
+
switch ($e['rule']) {
|
102 |
+
case 'mismatch' :
|
103 |
+
$resp[$e['field']] = "There is no validation rule for $field";
|
104 |
+
break;
|
105 |
+
case 'validate_required':
|
106 |
+
$resp[$e['field']] = "Enter $field field";
|
107 |
+
break;
|
108 |
+
case 'validate_valid_email':
|
109 |
+
$resp[$e['field']] = "Enter a valid email address";
|
110 |
+
break;
|
111 |
+
case 'validate_max_len':
|
112 |
+
$resp[$e['field']] = "The $field field needs to be $param or shorter in length";
|
113 |
+
break;
|
114 |
+
case 'validate_min_len':
|
115 |
+
$resp[$e['field']] = "The $field field needs to be $param or longer in length";
|
116 |
+
break;
|
117 |
+
case 'validate_exact_len':
|
118 |
+
$resp[$e['field']] = "The $field field needs to be exactly $param characters in length";
|
119 |
+
break;
|
120 |
+
case 'validate_alpha':
|
121 |
+
$resp[$e['field']] = "The $field field may only contain alpha characters(a-z)";
|
122 |
+
break;
|
123 |
+
case 'validate_alpha_numeric':
|
124 |
+
$resp[$e['field']] = "The $field field may only contain alpha-numeric characters";
|
125 |
+
break;
|
126 |
+
case 'validate_alpha_dash':
|
127 |
+
$resp[$e['field']] = "The $field field may only contain alpha characters & dashes";
|
128 |
+
break;
|
129 |
+
case 'validate_numeric':
|
130 |
+
$resp[$e['field']] = "The $field field may only contain numeric characters";
|
131 |
+
break;
|
132 |
+
case 'validate_integer':
|
133 |
+
$resp[$e['field']] = "The $field field may only contain a numeric value";
|
134 |
+
break;
|
135 |
+
case 'validate_boolean':
|
136 |
+
$resp[$e['field']] = "The $field field may only contain a true or false value";
|
137 |
+
break;
|
138 |
+
case 'validate_float':
|
139 |
+
$resp[$e['field']] = "The $field field may only contain a float value";
|
140 |
+
break;
|
141 |
+
case 'validate_valid_url':
|
142 |
+
$resp[$e['field']] = "The $field field is required to be a valid URL";
|
143 |
+
break;
|
144 |
+
case 'validate_url_exists':
|
145 |
+
$resp[$e['field']] = "The $field URL does not exist";
|
146 |
+
break;
|
147 |
+
case 'validate_valid_ip':
|
148 |
+
$resp[$e['field']] = "The $field field needs to contain a valid IP address";
|
149 |
+
break;
|
150 |
+
case 'validate_valid_cc':
|
151 |
+
$resp[$e['field']] = "The $field field needs to contain a valid credit card number";
|
152 |
+
break;
|
153 |
+
case 'validate_valid_name':
|
154 |
+
$resp[$e['field']] = "The $field field needs to contain a valid human name";
|
155 |
+
break;
|
156 |
+
case 'validate_contains':
|
157 |
+
$resp[$e['field']] = "The $field field needs to contain one of these values: " . implode(', ', $param);
|
158 |
+
break;
|
159 |
+
case 'validate_street_address':
|
160 |
+
$resp[$e['field']] = "The $field field needs to be a valid street address";
|
161 |
+
break;
|
162 |
+
case 'validate_date':
|
163 |
+
$resp[$e['field']] = "The $field field needs to be a valid date";
|
164 |
+
break;
|
165 |
+
case 'validate_min_numeric':
|
166 |
+
$resp[$e['field']] = "The $field field needs to be a numeric value, equal to, or higher than $param";
|
167 |
+
break;
|
168 |
+
case 'validate_max_numeric':
|
169 |
+
$resp[$e['field']] = "The $field field needs to be a numeric value, equal to, or lower than $param";
|
170 |
+
break;
|
171 |
+
case 'validate_min_age':
|
172 |
+
$resp[$e['field']] = "The $field field needs to have an age greater than or equal to $param";
|
173 |
+
break;
|
174 |
+
default:
|
175 |
+
$resp[$e['field']] = "The $field field is invalid";
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
return $resp;
|
180 |
+
}
|
181 |
+
|
182 |
+
}
|
classes/class-shortcode.php
CHANGED
@@ -367,6 +367,7 @@ class Shortcode extends Core {
|
|
367 |
'list' => array( '' => __( 'Default', 'mp-timetable' ), 'auto' => __( 'Auto', 'mp-timetable' ), 'fixed' => __( 'Fixed', 'mp-timetable' ) )
|
368 |
),
|
369 |
);
|
|
|
370 |
$mp_timetable = new \MPCEObject( 'mp-timetable', __( 'Timetable', 'mp-timetable' ), '', $attributes );
|
371 |
|
372 |
$motopressCELibrary->addObject( $mp_timetable, 'other' );
|
367 |
'list' => array( '' => __( 'Default', 'mp-timetable' ), 'auto' => __( 'Auto', 'mp-timetable' ), 'fixed' => __( 'Fixed', 'mp-timetable' ) )
|
368 |
),
|
369 |
);
|
370 |
+
|
371 |
$mp_timetable = new \MPCEObject( 'mp-timetable', __( 'Timetable', 'mp-timetable' ), '', $attributes );
|
372 |
|
373 |
$motopressCELibrary->addObject( $mp_timetable, 'other' );
|
classes/class-state-factory.php
CHANGED
@@ -1,84 +1,84 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\plugin_core\classes;
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Singleton factory
|
7 |
-
*/
|
8 |
-
class State_Factory {
|
9 |
-
|
10 |
-
protected static $instance;
|
11 |
-
protected $namespace;
|
12 |
-
|
13 |
-
/**
|
14 |
-
* State_Factory constructor.
|
15 |
-
*
|
16 |
-
* @param string $namespace
|
17 |
-
*/
|
18 |
-
public function __construct($namespace = 'plugin_core') {
|
19 |
-
$this->namespace = $namespace;
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @return State_Factory
|
24 |
-
*/
|
25 |
-
public static function get_instance() {
|
26 |
-
if (null === self::$instance) {
|
27 |
-
self::$instance = new self();
|
28 |
-
}
|
29 |
-
return self::$instance;
|
30 |
-
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Get register instance object
|
34 |
-
*
|
35 |
-
* @param null $value
|
36 |
-
*
|
37 |
-
* @return bool|\mp_timetable\plugin_core\classes\Model
|
38 |
-
*/
|
39 |
-
public function get_model($value = null) {
|
40 |
-
$model = false;
|
41 |
-
if ('model' == $value) {
|
42 |
-
$model = Model::get_instance();
|
43 |
-
} else {
|
44 |
-
$class = "{$this->namespace}\classes\models\\" . ucfirst($value);
|
45 |
-
if (class_exists($class)) {
|
46 |
-
$model = $class::get_instance();
|
47 |
-
}
|
48 |
-
}
|
49 |
-
return $model;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Get controller instance object
|
54 |
-
*
|
55 |
-
* @param null $value
|
56 |
-
*
|
57 |
-
* @return bool
|
58 |
-
*/
|
59 |
-
public function get_controller($value = null) {
|
60 |
-
$controller = false;
|
61 |
-
$class = "{$this->namespace}\classes\controllers\Controller_" . ucfirst($value);
|
62 |
-
if (class_exists($class)) {
|
63 |
-
$controller = $class::get_instance();
|
64 |
-
}
|
65 |
-
return $controller;
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Get Preprocessor instance object
|
70 |
-
*
|
71 |
-
* @param null $value
|
72 |
-
*
|
73 |
-
* @return bool
|
74 |
-
*/
|
75 |
-
public function get_preprocessor($value = null) {
|
76 |
-
$preprocessor = false;
|
77 |
-
$class = "{$this->namespace}\classes\preprocessors\Preprocessor_" . ucfirst($value);
|
78 |
-
if (class_exists($class)) {
|
79 |
-
$preprocessor = $class::get_instance();
|
80 |
-
}
|
81 |
-
return $preprocessor;
|
82 |
-
}
|
83 |
-
|
84 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\plugin_core\classes;
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Singleton factory
|
7 |
+
*/
|
8 |
+
class State_Factory {
|
9 |
+
|
10 |
+
protected static $instance;
|
11 |
+
protected $namespace;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* State_Factory constructor.
|
15 |
+
*
|
16 |
+
* @param string $namespace
|
17 |
+
*/
|
18 |
+
public function __construct($namespace = 'plugin_core') {
|
19 |
+
$this->namespace = $namespace;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @return State_Factory
|
24 |
+
*/
|
25 |
+
public static function get_instance() {
|
26 |
+
if (null === self::$instance) {
|
27 |
+
self::$instance = new self();
|
28 |
+
}
|
29 |
+
return self::$instance;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Get register instance object
|
34 |
+
*
|
35 |
+
* @param null $value
|
36 |
+
*
|
37 |
+
* @return bool|\mp_timetable\plugin_core\classes\Model
|
38 |
+
*/
|
39 |
+
public function get_model($value = null) {
|
40 |
+
$model = false;
|
41 |
+
if ('model' == $value) {
|
42 |
+
$model = Model::get_instance();
|
43 |
+
} else {
|
44 |
+
$class = "{$this->namespace}\classes\models\\" . ucfirst($value);
|
45 |
+
if (class_exists($class)) {
|
46 |
+
$model = $class::get_instance();
|
47 |
+
}
|
48 |
+
}
|
49 |
+
return $model;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Get controller instance object
|
54 |
+
*
|
55 |
+
* @param null $value
|
56 |
+
*
|
57 |
+
* @return bool
|
58 |
+
*/
|
59 |
+
public function get_controller($value = null) {
|
60 |
+
$controller = false;
|
61 |
+
$class = "{$this->namespace}\classes\controllers\Controller_" . ucfirst($value);
|
62 |
+
if (class_exists($class)) {
|
63 |
+
$controller = $class::get_instance();
|
64 |
+
}
|
65 |
+
return $controller;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Get Preprocessor instance object
|
70 |
+
*
|
71 |
+
* @param null $value
|
72 |
+
*
|
73 |
+
* @return bool
|
74 |
+
*/
|
75 |
+
public function get_preprocessor($value = null) {
|
76 |
+
$preprocessor = false;
|
77 |
+
$class = "{$this->namespace}\classes\preprocessors\Preprocessor_" . ucfirst($value);
|
78 |
+
if (class_exists($class)) {
|
79 |
+
$preprocessor = $class::get_instance();
|
80 |
+
}
|
81 |
+
return $preprocessor;
|
82 |
+
}
|
83 |
+
|
84 |
+
}
|
classes/class-view.php
CHANGED
@@ -1,235 +1,235 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\plugin_core\classes;
|
4 |
-
|
5 |
-
use Mp_Time_Table;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* View class
|
9 |
-
*/
|
10 |
-
class View {
|
11 |
-
|
12 |
-
protected static $instance;
|
13 |
-
protected $template_path;
|
14 |
-
protected $templates_path;
|
15 |
-
protected $prefix = 'mptt';
|
16 |
-
private $data;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* View constructor.
|
20 |
-
*/
|
21 |
-
public function __construct() {
|
22 |
-
$this->template_path = Mp_Time_Table::get_template_path();
|
23 |
-
$this->templates_path = Mp_Time_Table::get_templates_path();
|
24 |
-
$this->taxonomy_names = Core::get_instance()->get_taxonomy_names();
|
25 |
-
$this->post_types = Core::get_instance()->get_post_types();
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @return View
|
30 |
-
*/
|
31 |
-
public static function get_instance() {
|
32 |
-
if (null === self::$instance) {
|
33 |
-
self::$instance = new self();
|
34 |
-
}
|
35 |
-
return self::$instance;
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Render template
|
40 |
-
*
|
41 |
-
* @param null $template
|
42 |
-
* @param null $data
|
43 |
-
*/
|
44 |
-
function render_template($template = null, $data = null) {
|
45 |
-
$this->template = $template;
|
46 |
-
if (is_array($data)) {
|
47 |
-
extract($data);
|
48 |
-
}
|
49 |
-
$this->data = $data;
|
50 |
-
include_once $this->templates_path . 'index.php';
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Render html
|
55 |
-
*
|
56 |
-
* @param $template
|
57 |
-
* @param null $data
|
58 |
-
* @param bool $output
|
59 |
-
*
|
60 |
-
* @return string
|
61 |
-
*/
|
62 |
-
public function render_html($template, $data = null, $output = true) {
|
63 |
-
|
64 |
-
$this->data = $data;
|
65 |
-
if ( is_array($data) ) {
|
66 |
-
extract($data, EXTR_SKIP);
|
67 |
-
}
|
68 |
-
|
69 |
-
$includeFile = $this->templates_path . $template . '.php';
|
70 |
-
|
71 |
-
ob_start();
|
72 |
-
include($includeFile);
|
73 |
-
$out = ob_get_clean();
|
74 |
-
|
75 |
-
if ($output) {
|
76 |
-
echo $out;
|
77 |
-
} else {
|
78 |
-
return $out;
|
79 |
-
}
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Get template part theme/plugin
|
84 |
-
*
|
85 |
-
* @param string $name
|
86 |
-
* @param string $slug
|
87 |
-
*
|
88 |
-
* @return void
|
89 |
-
*/
|
90 |
-
public function get_template_part($slug, $name = '') {
|
91 |
-
$template = '';
|
92 |
-
|
93 |
-
if ($name) {
|
94 |
-
$template = locate_template(array("{$slug}-{$name}.php", $this->template_path . "{$slug}-{$name}.php"));
|
95 |
-
}
|
96 |
-
|
97 |
-
// Get default slug-name.php
|
98 |
-
if (!$template && $name && file_exists($this->templates_path . "{$slug}-{$name}.php")) {
|
99 |
-
$template = $this->templates_path . "{$slug}-{$name}.php";
|
100 |
-
}
|
101 |
-
|
102 |
-
if (!$template) {
|
103 |
-
$template = locate_template(array("{$slug}.php", $this->template_path . "{$slug}.php"));
|
104 |
-
}
|
105 |
-
|
106 |
-
// Allow 3rd party plugins to filter template file from their plugin.
|
107 |
-
$template = apply_filters($this->prefix . '_get_template_part', $template, $slug, $name);
|
108 |
-
|
109 |
-
if ($template) {
|
110 |
-
load_template($template, false);
|
111 |
-
}
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* @param $template_name
|
116 |
-
* @param array $args
|
117 |
-
* @param string $template_path
|
118 |
-
* @param string $default_path
|
119 |
-
*
|
120 |
-
* @return mixed/void
|
121 |
-
*/
|
122 |
-
public function get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
|
123 |
-
ob_start();
|
124 |
-
$this->get_template($template_name, $args, $template_path, $default_path);
|
125 |
-
return ob_get_clean();
|
126 |
-
}
|
127 |
-
|
128 |
-
/**
|
129 |
-
* Get template
|
130 |
-
*
|
131 |
-
* @param $template_name
|
132 |
-
* @param array $args
|
133 |
-
* @param string $template_path
|
134 |
-
* @param string $default_path
|
135 |
-
*/
|
136 |
-
public function get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
|
137 |
-
$template_name = $template_name . '.php';
|
138 |
-
|
139 |
-
if (!empty($args) && is_array($args)) {
|
140 |
-
extract($args);
|
141 |
-
}
|
142 |
-
|
143 |
-
$located = $this->locate_template($template_name, $template_path, $default_path);
|
144 |
-
|
145 |
-
if (!file_exists($located)) {
|
146 |
-
_doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1');
|
147 |
-
return;
|
148 |
-
}
|
149 |
-
|
150 |
-
// Allow 3rd party plugin filter template file from their plugin.
|
151 |
-
$located = apply_filters($this->prefix . '_get_template', $located, $template_name, $args, $template_path, $default_path);
|
152 |
-
|
153 |
-
do_action($this->prefix . '_before_template_part', $template_name, $template_path, $located, $args);
|
154 |
-
|
155 |
-
include($located);
|
156 |
-
|
157 |
-
do_action($this->prefix . '_after_template_part', $template_name, $template_path, $located, $args);
|
158 |
-
}
|
159 |
-
|
160 |
-
/**
|
161 |
-
* Locate template
|
162 |
-
*
|
163 |
-
* @param $template_name
|
164 |
-
* @param string $template_path
|
165 |
-
* @param string $default_path
|
166 |
-
*
|
167 |
-
* @return mixed|void
|
168 |
-
*/
|
169 |
-
function locate_template($template_name, $template_path = '', $default_path = '') {
|
170 |
-
if (!$template_path) {
|
171 |
-
$template_path = $this->template_path;
|
172 |
-
}
|
173 |
-
|
174 |
-
if (!$default_path) {
|
175 |
-
$default_path = $this->templates_path;
|
176 |
-
}
|
177 |
-
|
178 |
-
// Look within passed path within the theme - this is priority.
|
179 |
-
$template_args = array(trailingslashit($template_path) . $template_name, $template_name);
|
180 |
-
|
181 |
-
$template = locate_template($template_args);
|
182 |
-
|
183 |
-
// Get default template/
|
184 |
-
if (!$template) {
|
185 |
-
$template = $default_path . $template_name;
|
186 |
-
}
|
187 |
-
|
188 |
-
// Return what we found.
|
189 |
-
return apply_filters($this->prefix . '_locate_template', $template, $template_name, $template_path);
|
190 |
-
}
|
191 |
-
|
192 |
-
|
193 |
-
/**
|
194 |
-
* Include template
|
195 |
-
*
|
196 |
-
* @param $template
|
197 |
-
*
|
198 |
-
* @return string
|
199 |
-
*/
|
200 |
-
public function template_loader($template) {
|
201 |
-
global $post, $taxonomy;
|
202 |
-
$file = '';
|
203 |
-
$find = array();
|
204 |
-
if (is_embed()) {
|
205 |
-
return $template;
|
206 |
-
}
|
207 |
-
if (is_single() && in_array($post->post_type, $this->post_types)) {
|
208 |
-
$file = "single-{$post->post_type}.php";
|
209 |
-
$find[] = $file;
|
210 |
-
$find[] = $this->template_path . $file;
|
211 |
-
} elseif (in_array($taxonomy, $this->taxonomy_names)) {
|
212 |
-
$term = get_queried_object();
|
213 |
-
$file = "taxonomy-{$term->taxonomy}.php";
|
214 |
-
$find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
|
215 |
-
$find[] = $this->template_path . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
|
216 |
-
$find[] = 'taxonomy-' . $term->taxonomy . '.php';
|
217 |
-
$find[] = $this->template_path . 'taxonomy-' . $term->taxonomy . '.php';
|
218 |
-
$find[] = $file;
|
219 |
-
$find[] = $this->template_path . $file;
|
220 |
-
}
|
221 |
-
// elseif (is_post_type_archive($this->post_types)) {
|
222 |
-
// $file = 'archive.php';
|
223 |
-
// $find[] = $file;
|
224 |
-
// $find[] = $this->template_path . $file;
|
225 |
-
// }
|
226 |
-
if ($file) {
|
227 |
-
$find_template = locate_template(array_unique($find));
|
228 |
-
if (!empty($find_template)) {
|
229 |
-
$template = $find_template;
|
230 |
-
}
|
231 |
-
}
|
232 |
-
|
233 |
-
return $template;
|
234 |
-
}
|
235 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\plugin_core\classes;
|
4 |
+
|
5 |
+
use Mp_Time_Table;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* View class
|
9 |
+
*/
|
10 |
+
class View {
|
11 |
+
|
12 |
+
protected static $instance;
|
13 |
+
protected $template_path;
|
14 |
+
protected $templates_path;
|
15 |
+
protected $prefix = 'mptt';
|
16 |
+
private $data;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* View constructor.
|
20 |
+
*/
|
21 |
+
public function __construct() {
|
22 |
+
$this->template_path = Mp_Time_Table::get_template_path();
|
23 |
+
$this->templates_path = Mp_Time_Table::get_templates_path();
|
24 |
+
$this->taxonomy_names = Core::get_instance()->get_taxonomy_names();
|
25 |
+
$this->post_types = Core::get_instance()->get_post_types();
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @return View
|
30 |
+
*/
|
31 |
+
public static function get_instance() {
|
32 |
+
if (null === self::$instance) {
|
33 |
+
self::$instance = new self();
|
34 |
+
}
|
35 |
+
return self::$instance;
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Render template
|
40 |
+
*
|
41 |
+
* @param null $template
|
42 |
+
* @param null $data
|
43 |
+
*/
|
44 |
+
function render_template($template = null, $data = null) {
|
45 |
+
$this->template = $template;
|
46 |
+
if (is_array($data)) {
|
47 |
+
extract($data);
|
48 |
+
}
|
49 |
+
$this->data = $data;
|
50 |
+
include_once $this->templates_path . 'index.php';
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Render html
|
55 |
+
*
|
56 |
+
* @param $template
|
57 |
+
* @param null $data
|
58 |
+
* @param bool $output
|
59 |
+
*
|
60 |
+
* @return string
|
61 |
+
*/
|
62 |
+
public function render_html($template, $data = null, $output = true) {
|
63 |
+
|
64 |
+
$this->data = $data;
|
65 |
+
if ( is_array($data) ) {
|
66 |
+
extract($data, EXTR_SKIP);
|
67 |
+
}
|
68 |
+
|
69 |
+
$includeFile = $this->templates_path . $template . '.php';
|
70 |
+
|
71 |
+
ob_start();
|
72 |
+
include($includeFile);
|
73 |
+
$out = ob_get_clean();
|
74 |
+
|
75 |
+
if ($output) {
|
76 |
+
echo $out;
|
77 |
+
} else {
|
78 |
+
return $out;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Get template part theme/plugin
|
84 |
+
*
|
85 |
+
* @param string $name
|
86 |
+
* @param string $slug
|
87 |
+
*
|
88 |
+
* @return void
|
89 |
+
*/
|
90 |
+
public function get_template_part($slug, $name = '') {
|
91 |
+
$template = '';
|
92 |
+
|
93 |
+
if ($name) {
|
94 |
+
$template = locate_template(array("{$slug}-{$name}.php", $this->template_path . "{$slug}-{$name}.php"));
|
95 |
+
}
|
96 |
+
|
97 |
+
// Get default slug-name.php
|
98 |
+
if (!$template && $name && file_exists($this->templates_path . "{$slug}-{$name}.php")) {
|
99 |
+
$template = $this->templates_path . "{$slug}-{$name}.php";
|
100 |
+
}
|
101 |
+
|
102 |
+
if (!$template) {
|
103 |
+
$template = locate_template(array("{$slug}.php", $this->template_path . "{$slug}.php"));
|
104 |
+
}
|
105 |
+
|
106 |
+
// Allow 3rd party plugins to filter template file from their plugin.
|
107 |
+
$template = apply_filters($this->prefix . '_get_template_part', $template, $slug, $name);
|
108 |
+
|
109 |
+
if ($template) {
|
110 |
+
load_template($template, false);
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* @param $template_name
|
116 |
+
* @param array $args
|
117 |
+
* @param string $template_path
|
118 |
+
* @param string $default_path
|
119 |
+
*
|
120 |
+
* @return mixed/void
|
121 |
+
*/
|
122 |
+
public function get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
|
123 |
+
ob_start();
|
124 |
+
$this->get_template($template_name, $args, $template_path, $default_path);
|
125 |
+
return ob_get_clean();
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Get template
|
130 |
+
*
|
131 |
+
* @param $template_name
|
132 |
+
* @param array $args
|
133 |
+
* @param string $template_path
|
134 |
+
* @param string $default_path
|
135 |
+
*/
|
136 |
+
public function get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
|
137 |
+
$template_name = $template_name . '.php';
|
138 |
+
|
139 |
+
if (!empty($args) && is_array($args)) {
|
140 |
+
extract($args);
|
141 |
+
}
|
142 |
+
|
143 |
+
$located = $this->locate_template($template_name, $template_path, $default_path);
|
144 |
+
|
145 |
+
if (!file_exists($located)) {
|
146 |
+
_doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1');
|
147 |
+
return;
|
148 |
+
}
|
149 |
+
|
150 |
+
// Allow 3rd party plugin filter template file from their plugin.
|
151 |
+
$located = apply_filters($this->prefix . '_get_template', $located, $template_name, $args, $template_path, $default_path);
|
152 |
+
|
153 |
+
do_action($this->prefix . '_before_template_part', $template_name, $template_path, $located, $args);
|
154 |
+
|
155 |
+
include($located);
|
156 |
+
|
157 |
+
do_action($this->prefix . '_after_template_part', $template_name, $template_path, $located, $args);
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Locate template
|
162 |
+
*
|
163 |
+
* @param $template_name
|
164 |
+
* @param string $template_path
|
165 |
+
* @param string $default_path
|
166 |
+
*
|
167 |
+
* @return mixed|void
|
168 |
+
*/
|
169 |
+
function locate_template($template_name, $template_path = '', $default_path = '') {
|
170 |
+
if (!$template_path) {
|
171 |
+
$template_path = $this->template_path;
|
172 |
+
}
|
173 |
+
|
174 |
+
if (!$default_path) {
|
175 |
+
$default_path = $this->templates_path;
|
176 |
+
}
|
177 |
+
|
178 |
+
// Look within passed path within the theme - this is priority.
|
179 |
+
$template_args = array(trailingslashit($template_path) . $template_name, $template_name);
|
180 |
+
|
181 |
+
$template = locate_template($template_args);
|
182 |
+
|
183 |
+
// Get default template/
|
184 |
+
if (!$template) {
|
185 |
+
$template = $default_path . $template_name;
|
186 |
+
}
|
187 |
+
|
188 |
+
// Return what we found.
|
189 |
+
return apply_filters($this->prefix . '_locate_template', $template, $template_name, $template_path);
|
190 |
+
}
|
191 |
+
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Include template
|
195 |
+
*
|
196 |
+
* @param $template
|
197 |
+
*
|
198 |
+
* @return string
|
199 |
+
*/
|
200 |
+
public function template_loader($template) {
|
201 |
+
global $post, $taxonomy;
|
202 |
+
$file = '';
|
203 |
+
$find = array();
|
204 |
+
if (is_embed()) {
|
205 |
+
return $template;
|
206 |
+
}
|
207 |
+
if (is_single() && in_array($post->post_type, $this->post_types)) {
|
208 |
+
$file = "single-{$post->post_type}.php";
|
209 |
+
$find[] = $file;
|
210 |
+
$find[] = $this->template_path . $file;
|
211 |
+
} elseif (in_array($taxonomy, $this->taxonomy_names)) {
|
212 |
+
$term = get_queried_object();
|
213 |
+
$file = "taxonomy-{$term->taxonomy}.php";
|
214 |
+
$find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
|
215 |
+
$find[] = $this->template_path . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
|
216 |
+
$find[] = 'taxonomy-' . $term->taxonomy . '.php';
|
217 |
+
$find[] = $this->template_path . 'taxonomy-' . $term->taxonomy . '.php';
|
218 |
+
$find[] = $file;
|
219 |
+
$find[] = $this->template_path . $file;
|
220 |
+
}
|
221 |
+
// elseif (is_post_type_archive($this->post_types)) {
|
222 |
+
// $file = 'archive.php';
|
223 |
+
// $find[] = $file;
|
224 |
+
// $find[] = $this->template_path . $file;
|
225 |
+
// }
|
226 |
+
if ($file) {
|
227 |
+
$find_template = locate_template(array_unique($find));
|
228 |
+
if (!empty($find_template)) {
|
229 |
+
$template = $find_template;
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
return $template;
|
234 |
+
}
|
235 |
+
}
|
classes/class-widgets-manager.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\plugin_core\classes;
|
4 |
+
|
5 |
+
use \Elementor\Plugin;
|
6 |
+
|
7 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Elementor register widgets.
|
11 |
+
*/
|
12 |
+
class Widgets_Manager {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* WidgetsManager constructor.
|
16 |
+
*/
|
17 |
+
public function __construct() {
|
18 |
+
add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_widgets' ], 12 );
|
19 |
+
}
|
20 |
+
|
21 |
+
public function register_widgets() {
|
22 |
+
$path = \Mp_Time_Table::get_plugin_path() . 'classes/widgets/class-mp-timetable-elementor-widget.php';
|
23 |
+
|
24 |
+
if ( file_exists( $path ) ) {
|
25 |
+
require_once( $path );
|
26 |
+
}
|
27 |
+
}
|
28 |
+
}
|
classes/controllers/class-controller-column.php
CHANGED
@@ -1,43 +1,43 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\classes\controllers;
|
4 |
-
|
5 |
-
use mp_timetable\plugin_core\classes\Controller as Controller;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Created by PhpStorm.
|
9 |
-
* User: newmind
|
10 |
-
* Date: 12/9/2015
|
11 |
-
* Time: 5:34 PM
|
12 |
-
*/
|
13 |
-
class Controller_Column extends Controller {
|
14 |
-
|
15 |
-
protected static $instance;
|
16 |
-
private $data;
|
17 |
-
|
18 |
-
public static function get_instance() {
|
19 |
-
if (null === self::$instance) {
|
20 |
-
self::$instance = new self();
|
21 |
-
}
|
22 |
-
return self::$instance;
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Action template
|
27 |
-
*/
|
28 |
-
public function action_template() {
|
29 |
-
|
30 |
-
$this->data = $_REQUEST;
|
31 |
-
$this->get_view()->render_html("events/index", $this->data);
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @param $post
|
36 |
-
*/
|
37 |
-
public function action_page_view($post) {
|
38 |
-
|
39 |
-
$events = $this->get('events')->get_event_data(array('field' => 'column_id', 'id' => $post->ID));
|
40 |
-
return $events;
|
41 |
-
}
|
42 |
-
|
43 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\classes\controllers;
|
4 |
+
|
5 |
+
use mp_timetable\plugin_core\classes\Controller as Controller;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Created by PhpStorm.
|
9 |
+
* User: newmind
|
10 |
+
* Date: 12/9/2015
|
11 |
+
* Time: 5:34 PM
|
12 |
+
*/
|
13 |
+
class Controller_Column extends Controller {
|
14 |
+
|
15 |
+
protected static $instance;
|
16 |
+
private $data;
|
17 |
+
|
18 |
+
public static function get_instance() {
|
19 |
+
if (null === self::$instance) {
|
20 |
+
self::$instance = new self();
|
21 |
+
}
|
22 |
+
return self::$instance;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Action template
|
27 |
+
*/
|
28 |
+
public function action_template() {
|
29 |
+
|
30 |
+
$this->data = $_REQUEST;
|
31 |
+
$this->get_view()->render_html("events/index", $this->data);
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @param $post
|
36 |
+
*/
|
37 |
+
public function action_page_view($post) {
|
38 |
+
|
39 |
+
$events = $this->get('events')->get_event_data(array('field' => 'column_id', 'id' => $post->ID));
|
40 |
+
return $events;
|
41 |
+
}
|
42 |
+
|
43 |
}
|
classes/controllers/class-controller-events.php
CHANGED
@@ -1,113 +1,113 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\classes\controllers;
|
4 |
-
|
5 |
-
use mp_timetable\plugin_core\classes\Controller as Controller;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Created by PhpStorm.
|
9 |
-
* User: newmind
|
10 |
-
* Date: 12/9/2015
|
11 |
-
* Time: 5:34 PM
|
12 |
-
*/
|
13 |
-
class Controller_Events extends Controller {
|
14 |
-
|
15 |
-
protected static $instance;
|
16 |
-
private $data;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @return Controller_Events
|
20 |
-
*/
|
21 |
-
public static function get_instance() {
|
22 |
-
if (null === self::$instance) {
|
23 |
-
self::$instance = new self();
|
24 |
-
}
|
25 |
-
|
26 |
-
return self::$instance;
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Action template
|
31 |
-
*/
|
32 |
-
public function action_template() {
|
33 |
-
|
34 |
-
$this->data = $_REQUEST;
|
35 |
-
$this->get_view()->render_html("events/index", $this->data);
|
36 |
-
}
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Delete event data by ID
|
40 |
-
*/
|
41 |
-
public function action_delete() {
|
42 |
-
|
43 |
-
if ( current_user_can('edit_posts') ) {
|
44 |
-
|
45 |
-
$result = $this->get('events')->delete_event( filter_input(INPUT_POST, 'id', FILTER_VALIDATE_INT) );
|
46 |
-
|
47 |
-
if ($result === false) {
|
48 |
-
wp_send_json_error(array('status' => $result));
|
49 |
-
} else {
|
50 |
-
wp_send_json_success(array('status' => $result));
|
51 |
-
}
|
52 |
-
} else {
|
53 |
-
wp_die( sprintf( 'Access denied, %s, %s', __FUNCTION__, basename( __FILE__ ) ) );
|
54 |
-
}
|
55 |
-
}
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Get single event data
|
59 |
-
*/
|
60 |
-
public function action_get_event_data() {
|
61 |
-
|
62 |
-
if ( current_user_can('edit_posts') ) {
|
63 |
-
|
64 |
-
$id = filter_input(INPUT_POST, 'id', FILTER_VALIDATE_INT);
|
65 |
-
$result = $this->get('events')->get_event_data(array('field' => 'id', 'id' => $id), 'event_start', false);
|
66 |
-
|
67 |
-
if (!empty($result)) {
|
68 |
-
wp_send_json_success($result[ 0 ]);
|
69 |
-
} else {
|
70 |
-
wp_send_json_error(array('status' => false));
|
71 |
-
}
|
72 |
-
} else {
|
73 |
-
wp_die( sprintf( 'Access denied, %s, %s', __FUNCTION__, basename( __FILE__ ) ) );
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Get events by column id
|
79 |
-
*
|
80 |
-
* @param $post
|
81 |
-
*
|
82 |
-
* @return mixed
|
83 |
-
*/
|
84 |
-
public function get_all_event_by_post($post) {
|
85 |
-
|
86 |
-
// Show draft timeslots on preview
|
87 |
-
$show_public_only = ((get_post_status($post->ID) == 'draft') && is_preview()) ? false : true;
|
88 |
-
$result = $this->get('events')->get_event_data(array('field' => 'event_id', 'id' => $post->ID), 'event_start', $show_public_only);
|
89 |
-
|
90 |
-
return $result;
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Update Single Event data
|
95 |
-
*/
|
96 |
-
public function action_update_event_data() {
|
97 |
-
|
98 |
-
$request = $_REQUEST;
|
99 |
-
|
100 |
-
if ( current_user_can('edit_posts') ) {
|
101 |
-
|
102 |
-
$result = $this->get('events')->update_event_data($request[ 'data' ]);
|
103 |
-
|
104 |
-
if ($result === false) {
|
105 |
-
wp_send_json_error(array('status' => false));
|
106 |
-
} else {
|
107 |
-
wp_send_json_success(array('data' => $result));
|
108 |
-
}
|
109 |
-
} else {
|
110 |
-
wp_die( sprintf( 'Access denied, %s, %s', __FUNCTION__, basename( __FILE__ ) ) );
|
111 |
-
}
|
112 |
-
}
|
113 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\classes\controllers;
|
4 |
+
|
5 |
+
use mp_timetable\plugin_core\classes\Controller as Controller;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Created by PhpStorm.
|
9 |
+
* User: newmind
|
10 |
+
* Date: 12/9/2015
|
11 |
+
* Time: 5:34 PM
|
12 |
+
*/
|
13 |
+
class Controller_Events extends Controller {
|
14 |
+
|
15 |
+
protected static $instance;
|
16 |
+
private $data;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @return Controller_Events
|
20 |
+
*/
|
21 |
+
public static function get_instance() {
|
22 |
+
if (null === self::$instance) {
|
23 |
+
self::$instance = new self();
|
24 |
+
}
|
25 |
+
|
26 |
+
return self::$instance;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Action template
|
31 |
+
*/
|
32 |
+
public function action_template() {
|
33 |
+
|
34 |
+
$this->data = $_REQUEST;
|
35 |
+
$this->get_view()->render_html("events/index", $this->data);
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Delete event data by ID
|
40 |
+
*/
|
41 |
+
public function action_delete() {
|
42 |
+
|
43 |
+
if ( current_user_can('edit_posts') ) {
|
44 |
+
|
45 |
+
$result = $this->get('events')->delete_event( filter_input(INPUT_POST, 'id', FILTER_VALIDATE_INT) );
|
46 |
+
|
47 |
+
if ($result === false) {
|
48 |
+
wp_send_json_error(array('status' => $result));
|
49 |
+
} else {
|
50 |
+
wp_send_json_success(array('status' => $result));
|
51 |
+
}
|
52 |
+
} else {
|
53 |
+
wp_die( sprintf( 'Access denied, %s, %s', __FUNCTION__, basename( __FILE__ ) ) );
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Get single event data
|
59 |
+
*/
|
60 |
+
public function action_get_event_data() {
|
61 |
+
|
62 |
+
if ( current_user_can('edit_posts') ) {
|
63 |
+
|
64 |
+
$id = filter_input(INPUT_POST, 'id', FILTER_VALIDATE_INT);
|
65 |
+
$result = $this->get('events')->get_event_data(array('field' => 'id', 'id' => $id), 'event_start', false);
|
66 |
+
|
67 |
+
if (!empty($result)) {
|
68 |
+
wp_send_json_success($result[ 0 ]);
|
69 |
+
} else {
|
70 |
+
wp_send_json_error(array('status' => false));
|
71 |
+
}
|
72 |
+
} else {
|
73 |
+
wp_die( sprintf( 'Access denied, %s, %s', __FUNCTION__, basename( __FILE__ ) ) );
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Get events by column id
|
79 |
+
*
|
80 |
+
* @param $post
|
81 |
+
*
|
82 |
+
* @return mixed
|
83 |
+
*/
|
84 |
+
public function get_all_event_by_post($post) {
|
85 |
+
|
86 |
+
// Show draft timeslots on preview
|
87 |
+
$show_public_only = ((get_post_status($post->ID) == 'draft') && is_preview()) ? false : true;
|
88 |
+
$result = $this->get('events')->get_event_data(array('field' => 'event_id', 'id' => $post->ID), 'event_start', $show_public_only);
|
89 |
+
|
90 |
+
return $result;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Update Single Event data
|
95 |
+
*/
|
96 |
+
public function action_update_event_data() {
|
97 |
+
|
98 |
+
$request = $_REQUEST;
|
99 |
+
|
100 |
+
if ( current_user_can('edit_posts') ) {
|
101 |
+
|
102 |
+
$result = $this->get('events')->update_event_data($request[ 'data' ]);
|
103 |
+
|
104 |
+
if ($result === false) {
|
105 |
+
wp_send_json_error(array('status' => false));
|
106 |
+
} else {
|
107 |
+
wp_send_json_success(array('data' => $result));
|
108 |
+
}
|
109 |
+
} else {
|
110 |
+
wp_die( sprintf( 'Access denied, %s, %s', __FUNCTION__, basename( __FILE__ ) ) );
|
111 |
+
}
|
112 |
+
}
|
113 |
}
|
classes/controllers/class-controller-help.php
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\classes\controllers;
|
4 |
-
|
5 |
-
use mp_timetable\plugin_core\classes\Controller as Controller;
|
6 |
-
use mp_timetable\plugin_core\classes\View;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class Controller_Help
|
10 |
-
* @package mp_timetable\classes\controllers
|
11 |
-
*/
|
12 |
-
class Controller_Help extends Controller {
|
13 |
-
|
14 |
-
protected 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 |
-
* Action template
|
25 |
-
*/
|
26 |
-
public function action_content() {
|
27 |
-
View::get_instance()->render_html('../admin/help/index');
|
28 |
-
}
|
29 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\classes\controllers;
|
4 |
+
|
5 |
+
use mp_timetable\plugin_core\classes\Controller as Controller;
|
6 |
+
use mp_timetable\plugin_core\classes\View;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class Controller_Help
|
10 |
+
* @package mp_timetable\classes\controllers
|
11 |
+
*/
|
12 |
+
class Controller_Help extends Controller {
|
13 |
+
|
14 |
+
protected 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 |
+
* Action template
|
25 |
+
*/
|
26 |
+
public function action_content() {
|
27 |
+
View::get_instance()->render_html('../admin/help/index');
|
28 |
+
}
|
29 |
}
|
classes/controllers/class-controller-import.php
CHANGED
@@ -1,35 +1,35 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\classes\controllers;
|
4 |
-
|
5 |
-
use mp_timetable\classes\models\Export;
|
6 |
-
use mp_timetable\plugin_core\classes\Controller as Controller;
|
7 |
-
use mp_timetable\plugin_core\classes\View;
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class Controller_Import
|
11 |
-
* @package mp_timetable\classes\controllers
|
12 |
-
*/
|
13 |
-
class Controller_Import extends Controller {
|
14 |
-
|
15 |
-
protected static $instance;
|
16 |
-
|
17 |
-
public static function get_instance() {
|
18 |
-
if (null === self::$instance) {
|
19 |
-
self::$instance = new self();
|
20 |
-
}
|
21 |
-
return self::$instance;
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Action template
|
26 |
-
*/
|
27 |
-
public function action_content() {
|
28 |
-
$data = array();
|
29 |
-
View::get_instance()->render_html('../admin/import/index', $data);
|
30 |
-
}
|
31 |
-
|
32 |
-
public function action_export() {
|
33 |
-
Export::get_instance()->export();
|
34 |
-
}
|
35 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\classes\controllers;
|
4 |
+
|
5 |
+
use mp_timetable\classes\models\Export;
|
6 |
+
use mp_timetable\plugin_core\classes\Controller as Controller;
|
7 |
+
use mp_timetable\plugin_core\classes\View;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class Controller_Import
|
11 |
+
* @package mp_timetable\classes\controllers
|
12 |
+
*/
|
13 |
+
class Controller_Import extends Controller {
|
14 |
+
|
15 |
+
protected static $instance;
|
16 |
+
|
17 |
+
public static function get_instance() {
|
18 |
+
if (null === self::$instance) {
|
19 |
+
self::$instance = new self();
|
20 |
+
}
|
21 |
+
return self::$instance;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Action template
|
26 |
+
*/
|
27 |
+
public function action_content() {
|
28 |
+
$data = array();
|
29 |
+
View::get_instance()->render_html('../admin/import/index', $data);
|
30 |
+
}
|
31 |
+
|
32 |
+
public function action_export() {
|
33 |
+
Export::get_instance()->export();
|
34 |
+
}
|
35 |
}
|
classes/controllers/class-controller-popup.php
CHANGED
@@ -1,39 +1,39 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\classes\controllers;
|
4 |
-
|
5 |
-
use mp_timetable\plugin_core\classes\Controller as Controller;
|
6 |
-
use mp_timetable\plugin_core\classes\Model as Model;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Class Controller_Popup
|
10 |
-
* @package mp_timetable\classes\controllers
|
11 |
-
*/
|
12 |
-
class Controller_Popup extends Controller {
|
13 |
-
|
14 |
-
protected static $instance;
|
15 |
-
private $data;
|
16 |
-
|
17 |
-
public static function get_instance() {
|
18 |
-
if (null === self::$instance) {
|
19 |
-
self::$instance = new self();
|
20 |
-
}
|
21 |
-
return self::$instance;
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Action template
|
26 |
-
*/
|
27 |
-
public function action_get_popup_html_content() {
|
28 |
-
|
29 |
-
if ( is_user_logged_in() ) {
|
30 |
-
|
31 |
-
$this->data['column'] = $this->get('column')->get_all_column();
|
32 |
-
$this->data['events'] = $this->get('events')->get_all_events();
|
33 |
-
$this->data['category'] = get_terms('mp-event_category', 'orderby=count&hide_empty=0');
|
34 |
-
$data["html"] = $this->get_view()->render_html("popup/index", $this->data, false);
|
35 |
-
$this->send_json(Model::get_instance()->get_arr($data, true));
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\classes\controllers;
|
4 |
+
|
5 |
+
use mp_timetable\plugin_core\classes\Controller as Controller;
|
6 |
+
use mp_timetable\plugin_core\classes\Model as Model;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Class Controller_Popup
|
10 |
+
* @package mp_timetable\classes\controllers
|
11 |
+
*/
|
12 |
+
class Controller_Popup extends Controller {
|
13 |
+
|
14 |
+
protected static $instance;
|
15 |
+
private $data;
|
16 |
+
|
17 |
+
public static function get_instance() {
|
18 |
+
if (null === self::$instance) {
|
19 |
+
self::$instance = new self();
|
20 |
+
}
|
21 |
+
return self::$instance;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Action template
|
26 |
+
*/
|
27 |
+
public function action_get_popup_html_content() {
|
28 |
+
|
29 |
+
if ( is_user_logged_in() ) {
|
30 |
+
|
31 |
+
$this->data['column'] = $this->get('column')->get_all_column();
|
32 |
+
$this->data['events'] = $this->get('events')->get_all_events();
|
33 |
+
$this->data['category'] = get_terms('mp-event_category', 'orderby=count&hide_empty=0');
|
34 |
+
$data["html"] = $this->get_view()->render_html("popup/index", $this->data, false);
|
35 |
+
$this->send_json(Model::get_instance()->get_arr($data, true));
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
}
|
classes/controllers/class-controller-settings.php
CHANGED
@@ -1,73 +1,73 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\classes\controllers;
|
4 |
-
|
5 |
-
use mp_timetable\classes\models\Settings;
|
6 |
-
use mp_timetable\plugin_core\classes\Controller as Controller;
|
7 |
-
use mp_timetable\plugin_core\classes\View;
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class Controller_Settings
|
11 |
-
* @package mp_timetable\classes\controllers
|
12 |
-
*/
|
13 |
-
class Controller_Settings extends Controller {
|
14 |
-
|
15 |
-
protected static $instance;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @return Controller_Settings
|
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 |
-
* Action template
|
29 |
-
*/
|
30 |
-
public function action_content() {
|
31 |
-
|
32 |
-
if ( current_user_can('manage_options') ) {
|
33 |
-
|
34 |
-
$data = Settings::get_instance()->get_settings();
|
35 |
-
$theme_supports = $this->get('Settings')->is_theme_supports();
|
36 |
-
|
37 |
-
View::get_instance()->render_html('../templates/settings/general', array('settings' => $data, 'theme_supports' => $theme_supports));
|
38 |
-
|
39 |
-
} else {
|
40 |
-
wp_die( sprintf( 'Access denied, %s, %s', __FUNCTION__, basename( __FILE__ ) ) );
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Save settings
|
46 |
-
*/
|
47 |
-
public function action_save() {
|
48 |
-
|
49 |
-
if ( isset( $_POST['mp-timetable-save-settings'] ) &&
|
50 |
-
wp_verify_nonce( $_POST['mp-timetable-save-settings'], 'mp_timetable_nonce_settings') ) {
|
51 |
-
|
52 |
-
$redirect = Settings::get_instance()->save_settings();
|
53 |
-
|
54 |
-
wp_safe_redirect(
|
55 |
-
add_query_arg(
|
56 |
-
array(
|
57 |
-
'page' => $_GET['page'],
|
58 |
-
'settings-updated' => 'true'
|
59 |
-
),
|
60 |
-
admin_url( 'edit.php?post_type=mp-event')
|
61 |
-
)
|
62 |
-
);
|
63 |
-
exit;
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Show success message
|
68 |
-
*/
|
69 |
-
if ( isset( $_GET['settings-updated'] ) && ( $_GET['settings-updated'] == TRUE ) ) {
|
70 |
-
add_settings_error('mpTimetableSettings', esc_attr('settings_updated'), __('Settings saved.', 'mp-timetable'), 'updated');
|
71 |
-
}
|
72 |
-
}
|
73 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\classes\controllers;
|
4 |
+
|
5 |
+
use mp_timetable\classes\models\Settings;
|
6 |
+
use mp_timetable\plugin_core\classes\Controller as Controller;
|
7 |
+
use mp_timetable\plugin_core\classes\View;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class Controller_Settings
|
11 |
+
* @package mp_timetable\classes\controllers
|
12 |
+
*/
|
13 |
+
class Controller_Settings extends Controller {
|
14 |
+
|
15 |
+
protected static $instance;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @return Controller_Settings
|
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 |
+
* Action template
|
29 |
+
*/
|
30 |
+
public function action_content() {
|
31 |
+
|
32 |
+
if ( current_user_can('manage_options') ) {
|
33 |
+
|
34 |
+
$data = Settings::get_instance()->get_settings();
|
35 |
+
$theme_supports = $this->get('Settings')->is_theme_supports();
|
36 |
+
|
37 |
+
View::get_instance()->render_html('../templates/settings/general', array('settings' => $data, 'theme_supports' => $theme_supports));
|
38 |
+
|
39 |
+
} else {
|
40 |
+
wp_die( sprintf( 'Access denied, %s, %s', __FUNCTION__, basename( __FILE__ ) ) );
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Save settings
|
46 |
+
*/
|
47 |
+
public function action_save() {
|
48 |
+
|
49 |
+
if ( isset( $_POST['mp-timetable-save-settings'] ) &&
|
50 |
+
wp_verify_nonce( $_POST['mp-timetable-save-settings'], 'mp_timetable_nonce_settings') ) {
|
51 |
+
|
52 |
+
$redirect = Settings::get_instance()->save_settings();
|
53 |
+
|
54 |
+
wp_safe_redirect(
|
55 |
+
add_query_arg(
|
56 |
+
array(
|
57 |
+
'page' => $_GET['page'],
|
58 |
+
'settings-updated' => 'true'
|
59 |
+
),
|
60 |
+
admin_url( 'edit.php?post_type=mp-event')
|
61 |
+
)
|
62 |
+
);
|
63 |
+
exit;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Show success message
|
68 |
+
*/
|
69 |
+
if ( isset( $_GET['settings-updated'] ) && ( $_GET['settings-updated'] == TRUE ) ) {
|
70 |
+
add_settings_error('mpTimetableSettings', esc_attr('settings_updated'), __('Settings saved.', 'mp-timetable'), 'updated');
|
71 |
+
}
|
72 |
+
}
|
73 |
}
|
classes/libs/class-gump.php
CHANGED
@@ -1,2029 +1,2029 @@
|
|
1 |
-
<?php
|
2 |
-
namespace mp_timetable\classes\libs;
|
3 |
-
/**
|
4 |
-
* GUMP - A fast, extensible PHP input validation class.
|
5 |
-
*
|
6 |
-
* @author Sean Nieuwoudt (http://twitter.com/SeanNieuwoudt)
|
7 |
-
* @copyright Copyright (c) 2015 wixelhq.com
|
8 |
-
*
|
9 |
-
* @link http://github.com/Wixel/GUMP
|
10 |
-
*
|
11 |
-
* @version 1.0
|
12 |
-
*/
|
13 |
-
class GUMP {
|
14 |
-
// Validation rules for execution
|
15 |
-
protected $validation_rules = array();
|
16 |
-
|
17 |
-
// Filter rules for execution
|
18 |
-
protected $filter_rules = array();
|
19 |
-
|
20 |
-
// Instance attribute containing errors from last run
|
21 |
-
protected $errors = array();
|
22 |
-
|
23 |
-
// Contain readable field names that have been set manually
|
24 |
-
protected static $fields = array();
|
25 |
-
|
26 |
-
// Custom validation methods
|
27 |
-
protected static $validation_methods = array();
|
28 |
-
|
29 |
-
// Customer filter methods
|
30 |
-
protected static $filter_methods = array();
|
31 |
-
|
32 |
-
// ** ------------------------- Validation Data ------------------------------- ** //
|
33 |
-
|
34 |
-
public static $basic_tags = '<br><p><a><strong><b><i><em><img><blockquote><code><dd><dl><hr><h1><h2><h3><h4><h5><h6><label><ul><li><span><sub><sup>';
|
35 |
-
|
36 |
-
public static $en_noise_words = "about,after,all,also,an,and,another,any,are,as,at,be,because,been,before,
|
37 |
-
being,between,both,but,by,came,can,come,could,did,do,each,for,from,get,
|
38 |
-
got,has,had,he,have,her,here,him,himself,his,how,if,in,into,is,it,its,it's,like,
|
39 |
-
make,many,me,might,more,most,much,must,my,never,now,of,on,only,or,other,
|
40 |
-
our,out,over,said,same,see,should,since,some,still,such,take,than,that,
|
41 |
-
the,their,them,then,there,these,they,this,those,through,to,too,under,up,
|
42 |
-
very,was,way,we,well,were,what,where,which,while,who,with,would,you,your,a,
|
43 |
-
b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,$,1,2,3,4,5,6,7,8,9,0,_";
|
44 |
-
|
45 |
-
// field characters below will be replaced with a space.
|
46 |
-
protected $fieldCharsToRemove = array('_', '-');
|
47 |
-
|
48 |
-
// ** ------------------------- Validation Helpers ---------------------------- ** //
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Shorthand method for inline validation.
|
52 |
-
*
|
53 |
-
* @param array $data The data to be validated
|
54 |
-
* @param array $validators The GUMP validators
|
55 |
-
*
|
56 |
-
* @return mixed True(boolean) or the array of error messages
|
57 |
-
*/
|
58 |
-
public static function is_valid(array $data, array $validators) {
|
59 |
-
$gump = new self();
|
60 |
-
|
61 |
-
$gump->validation_rules($validators);
|
62 |
-
|
63 |
-
if ($gump->run($data) === false) {
|
64 |
-
return $gump->get_readable_errors(false);
|
65 |
-
} else {
|
66 |
-
return true;
|
67 |
-
}
|
68 |
-
}
|
69 |
-
|
70 |
-
/**
|
71 |
-
* Shorthand method for running only the data filters.
|
72 |
-
*
|
73 |
-
* @param array $data
|
74 |
-
* @param array $filters
|
75 |
-
*
|
76 |
-
* @return mixed
|
77 |
-
*/
|
78 |
-
public static function filter_input(array $data, array $filters) {
|
79 |
-
$gump = new self();
|
80 |
-
|
81 |
-
return $gump->filter($data, $filters);
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Magic method to generate the validation error messages.
|
86 |
-
*
|
87 |
-
* @return string
|
88 |
-
*/
|
89 |
-
public function __toString() {
|
90 |
-
return $this->get_readable_errors(true);
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Perform XSS clean to prevent cross site scripting.
|
95 |
-
*
|
96 |
-
* @static
|
97 |
-
*
|
98 |
-
* @param array $data
|
99 |
-
*
|
100 |
-
* @return array
|
101 |
-
*/
|
102 |
-
public static function xss_clean(array $data) {
|
103 |
-
foreach ($data as $k => $v) {
|
104 |
-
$data[$k] = filter_var($v, FILTER_SANITIZE_STRING);
|
105 |
-
}
|
106 |
-
|
107 |
-
return $data;
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Adds a custom validation rule using a callback function.
|
112 |
-
*
|
113 |
-
* @param string $rule
|
114 |
-
* @param callable $callback
|
115 |
-
*
|
116 |
-
* @return bool
|
117 |
-
*
|
118 |
-
* @throws Exception
|
119 |
-
*/
|
120 |
-
public static function add_validator($rule, $callback) {
|
121 |
-
$method = 'validate_' . $rule;
|
122 |
-
|
123 |
-
if (method_exists(__CLASS__, $method) || isset(self::$validation_methods[$rule])) {
|
124 |
-
throw new Exception("Validator rule '$rule' already exists.");
|
125 |
-
}
|
126 |
-
|
127 |
-
self::$validation_methods[$rule] = $callback;
|
128 |
-
|
129 |
-
return true;
|
130 |
-
}
|
131 |
-
|
132 |
-
/**
|
133 |
-
* Adds a custom filter using a callback function.
|
134 |
-
*
|
135 |
-
* @param string $rule
|
136 |
-
* @param callable $callback
|
137 |
-
*
|
138 |
-
* @return bool
|
139 |
-
*
|
140 |
-
* @throws Exception
|
141 |
-
*/
|
142 |
-
public static function add_filter($rule, $callback) {
|
143 |
-
$method = 'filter_' . $rule;
|
144 |
-
|
145 |
-
if (method_exists(__CLASS__, $method) || isset(self::$filter_methods[$rule])) {
|
146 |
-
throw new Exception("Filter rule '$rule' already exists.");
|
147 |
-
}
|
148 |
-
|
149 |
-
self::$filter_methods[$rule] = $callback;
|
150 |
-
|
151 |
-
return true;
|
152 |
-
}
|
153 |
-
|
154 |
-
/**
|
155 |
-
* Helper method to extract an element from an array safely
|
156 |
-
*
|
157 |
-
* @param mixed $key
|
158 |
-
* @param array $array
|
159 |
-
* @param mixed $default
|
160 |
-
*
|
161 |
-
* @return mixed
|
162 |
-
*/
|
163 |
-
public static function field($key, array $array, $default = null) {
|
164 |
-
if (!is_array($array)) {
|
165 |
-
return null;
|
166 |
-
}
|
167 |
-
|
168 |
-
if (isset($array[$key])) {
|
169 |
-
return $array[$key];
|
170 |
-
} else {
|
171 |
-
return $default;
|
172 |
-
}
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Getter/Setter for the validation rules.
|
177 |
-
*
|
178 |
-
* @param array $rules
|
179 |
-
*
|
180 |
-
* @return array
|
181 |
-
*/
|
182 |
-
public function validation_rules(array $rules = array()) {
|
183 |
-
if (empty($rules)) {
|
184 |
-
return $this->validation_rules;
|
185 |
-
}
|
186 |
-
|
187 |
-
$this->validation_rules = $rules;
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Getter/Setter for the filter rules.
|
192 |
-
*
|
193 |
-
* @param array $rules
|
194 |
-
*
|
195 |
-
* @return array
|
196 |
-
*/
|
197 |
-
public function filter_rules(array $rules = array()) {
|
198 |
-
if (empty($rules)) {
|
199 |
-
return $this->filter_rules;
|
200 |
-
}
|
201 |
-
|
202 |
-
$this->filter_rules = $rules;
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* Run the filtering and validation after each other.
|
207 |
-
*
|
208 |
-
* @param array $data
|
209 |
-
* @param bool $check_fields
|
210 |
-
*
|
211 |
-
* @return array
|
212 |
-
*
|
213 |
-
* @throws Exception
|
214 |
-
*/
|
215 |
-
public function run(array $data, $check_fields = false) {
|
216 |
-
$data = $this->filter($data, $this->filter_rules());
|
217 |
-
|
218 |
-
$validated = $this->validate(
|
219 |
-
$data, $this->validation_rules()
|
220 |
-
);
|
221 |
-
|
222 |
-
if ($check_fields === true) {
|
223 |
-
$this->check_fields($data);
|
224 |
-
}
|
225 |
-
|
226 |
-
if ($validated !== true) {
|
227 |
-
return false;
|
228 |
-
}
|
229 |
-
|
230 |
-
return $data;
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* Ensure that the field counts match the validation rule counts.
|
235 |
-
*
|
236 |
-
* @param array $data
|
237 |
-
*/
|
238 |
-
private function check_fields(array $data) {
|
239 |
-
$ruleset = $this->validation_rules();
|
240 |
-
$mismatch = array_diff_key($data, $ruleset);
|
241 |
-
$fields = array_keys($mismatch);
|
242 |
-
|
243 |
-
foreach ($fields as $field) {
|
244 |
-
$this->errors[] = array(
|
245 |
-
'field' => $field,
|
246 |
-
'value' => $data[$field],
|
247 |
-
'rule' => 'mismatch',
|
248 |
-
'param' => null,
|
249 |
-
);
|
250 |
-
}
|
251 |
-
}
|
252 |
-
|
253 |
-
/**
|
254 |
-
* Sanitize the input data.
|
255 |
-
*
|
256 |
-
* @param array $input
|
257 |
-
* @param null $fields
|
258 |
-
* @param bool $utf8_encode
|
259 |
-
*
|
260 |
-
* @return array
|
261 |
-
*/
|
262 |
-
public function sanitize(array $input, array $fields = array(), $utf8_encode = true) {
|
263 |
-
$magic_quotes = (bool)get_magic_quotes_gpc();
|
264 |
-
|
265 |
-
if (empty($fields)) {
|
266 |
-
$fields = array_keys($input);
|
267 |
-
}
|
268 |
-
|
269 |
-
$return = array();
|
270 |
-
|
271 |
-
foreach ($fields as $field) {
|
272 |
-
if (!isset($input[$field])) {
|
273 |
-
continue;
|
274 |
-
} else {
|
275 |
-
$value = $input[$field];
|
276 |
-
if (is_array($value)) {
|
277 |
-
$value = null;
|
278 |
-
}
|
279 |
-
if (is_string($value)) {
|
280 |
-
if ($magic_quotes === true) {
|
281 |
-
$value = stripslashes($value);
|
282 |
-
}
|
283 |
-
|
284 |
-
if (strpos($value, "\r") !== false) {
|
285 |
-
$value = trim($value);
|
286 |
-
}
|
287 |
-
|
288 |
-
if (function_exists('iconv') && function_exists('mb_detect_encoding') && $utf8_encode) {
|
289 |
-
$current_encoding = mb_detect_encoding($value);
|
290 |
-
|
291 |
-
if ($current_encoding != 'UTF-8' && $current_encoding != 'UTF-16') {
|
292 |
-
$value = iconv($current_encoding, 'UTF-8', $value);
|
293 |
-
}
|
294 |
-
}
|
295 |
-
|
296 |
-
$value = filter_var($value, FILTER_SANITIZE_STRING);
|
297 |
-
}
|
298 |
-
|
299 |
-
$return[$field] = $value;
|
300 |
-
}
|
301 |
-
}
|
302 |
-
|
303 |
-
return $return;
|
304 |
-
}
|
305 |
-
|
306 |
-
/**
|
307 |
-
* Return the error array from the last validation run.
|
308 |
-
*
|
309 |
-
* @return array
|
310 |
-
*/
|
311 |
-
public function errors() {
|
312 |
-
return $this->errors;
|
313 |
-
}
|
314 |
-
|
315 |
-
/**
|
316 |
-
* Perform data validation against the provided ruleset.
|
317 |
-
*
|
318 |
-
* @param mixed $input
|
319 |
-
* @param array $ruleset
|
320 |
-
*
|
321 |
-
* @return mixed
|
322 |
-
*
|
323 |
-
* @throws Exception
|
324 |
-
*/
|
325 |
-
public function validate(array $input, array $ruleset) {
|
326 |
-
$this->errors = array();
|
327 |
-
|
328 |
-
foreach ($ruleset as $field => $rules) {
|
329 |
-
|
330 |
-
$rules = explode('|', $rules);
|
331 |
-
|
332 |
-
if (in_array('required', $rules) || (isset($input[$field]) && !is_array($input[$field]))) {
|
333 |
-
foreach ($rules as $rule) {
|
334 |
-
$method = null;
|
335 |
-
$param = null;
|
336 |
-
|
337 |
-
// Check if we have rule parameters
|
338 |
-
if (strstr($rule, ',') !== false) {
|
339 |
-
$rule = explode(',', $rule);
|
340 |
-
$method = 'validate_' . $rule[0];
|
341 |
-
$param = $rule[1];
|
342 |
-
$rule = $rule[0];
|
343 |
-
} else {
|
344 |
-
$method = 'validate_' . $rule;
|
345 |
-
}
|
346 |
-
|
347 |
-
//self::$validation_methods[$rule] = $callback;
|
348 |
-
|
349 |
-
if (is_callable(array($this, $method))) {
|
350 |
-
$result = $this->$method(
|
351 |
-
$field, $input, $param
|
352 |
-
);
|
353 |
-
|
354 |
-
if (is_array($result)) {
|
355 |
-
$this->errors[] = $result;
|
356 |
-
}
|
357 |
-
} elseif (isset(self::$validation_methods[$rule])) {
|
358 |
-
|
359 |
-
$result = call_user_func(self::$validation_methods[$rule], $field, $input, $param);
|
360 |
-
|
361 |
-
if ($result === false) {
|
362 |
-
$this->errors[] = array(
|
363 |
-
'field' => $field,
|
364 |
-
'value' => $input,
|
365 |
-
'rule' => self::$validation_methods[$rule],
|
366 |
-
'param' => $param,
|
367 |
-
);
|
368 |
-
}
|
369 |
-
|
370 |
-
} else {
|
371 |
-
throw new Exception("Validator method '$method' does not exist.");
|
372 |
-
}
|
373 |
-
}
|
374 |
-
}
|
375 |
-
}
|
376 |
-
|
377 |
-
return (count($this->errors) > 0) ? $this->errors : true;
|
378 |
-
}
|
379 |
-
|
380 |
-
/**
|
381 |
-
* Overloadable method to invoke validation.
|
382 |
-
*
|
383 |
-
* @param array $input
|
384 |
-
* @param $rules
|
385 |
-
* @param $field
|
386 |
-
*
|
387 |
-
* @return bool
|
388 |
-
*/
|
389 |
-
protected function shouldRunValidation(array $input, $rules, $field) {
|
390 |
-
return in_array('required', $rules) || (isset($input[$field]) && trim($input[$field]) != '');
|
391 |
-
}
|
392 |
-
|
393 |
-
/**
|
394 |
-
* Set a readable name for a specified field names.
|
395 |
-
*
|
396 |
-
* @param string $field
|
397 |
-
* @param string $readable_name
|
398 |
-
*/
|
399 |
-
public static function set_field_name($field, $readable_name) {
|
400 |
-
self::$fields[$field] = $readable_name;
|
401 |
-
}
|
402 |
-
|
403 |
-
/**
|
404 |
-
* Set readable name for specified fields in an array.
|
405 |
-
*
|
406 |
-
* Usage:
|
407 |
-
*
|
408 |
-
* GUMP::set_field_names(array(
|
409 |
-
* "name" => "My Lovely Name",
|
410 |
-
* "username" => "My Beloved Username",
|
411 |
-
* ));
|
412 |
-
*
|
413 |
-
* @param array $array
|
414 |
-
*/
|
415 |
-
public static function set_field_names(array $array) {
|
416 |
-
foreach ($array as $field => $readable_name) {
|
417 |
-
self::$fields[$field] = $readable_name;
|
418 |
-
}
|
419 |
-
}
|
420 |
-
|
421 |
-
/**
|
422 |
-
* Process the validation errors and return human readable error messages.
|
423 |
-
*
|
424 |
-
* @param bool $convert_to_string = false
|
425 |
-
* @param string $field_class
|
426 |
-
* @param string $error_class
|
427 |
-
*
|
428 |
-
* @return array
|
429 |
-
* @return string
|
430 |
-
*/
|
431 |
-
public function get_readable_errors($convert_to_string = false, $field_class = 'gump-field', $error_class = 'gump-error-message') {
|
432 |
-
if (empty($this->errors)) {
|
433 |
-
return ($convert_to_string) ? null : array();
|
434 |
-
}
|
435 |
-
|
436 |
-
$resp = array();
|
437 |
-
|
438 |
-
foreach ($this->errors as $e) {
|
439 |
-
$field = ucwords(str_replace($this->fieldCharsToRemove, chr(32), $e['field']));
|
440 |
-
$param = $e['param'];
|
441 |
-
|
442 |
-
// Let's fetch explicit field names if they exist
|
443 |
-
if (array_key_exists($e['field'], self::$fields)) {
|
444 |
-
$field = self::$fields[$e['field']];
|
445 |
-
}
|
446 |
-
|
447 |
-
|
448 |
-
switch ($e['rule']) {
|
449 |
-
case 'mismatch' :
|
450 |
-
$resp[] = sprintf( 'There is no validation rule for <span class="%1$s">%2$s</span>', $field_class, $field );
|
451 |
-
break;
|
452 |
-
case 'validate_required' :
|
453 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field is required', $field_class, $field );
|
454 |
-
break;
|
455 |
-
case 'validate_valid_email':
|
456 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field is required to be a valid email address', $field_class, $field );
|
457 |
-
break;
|
458 |
-
case 'validate_max_len':
|
459 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to be %d or shorter in length', $field_class, $field, $param );
|
460 |
-
break;
|
461 |
-
case 'validate_min_len':
|
462 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to be %d or longer in length', $field_class, $field, $param );
|
463 |
-
break;
|
464 |
-
case 'validate_exact_len':
|
465 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to be exactly %d characters in length', $field_class, $field, $param );
|
466 |
-
break;
|
467 |
-
case 'validate_alpha':
|
468 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field may only contain alpha characters(a-z)', $field_class, $field );
|
469 |
-
break;
|
470 |
-
case 'validate_alpha_numeric':
|
471 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field may only contain alpha-numeric characters', $field_class, $field );
|
472 |
-
break;
|
473 |
-
case 'validate_alpha_dash':
|
474 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field may only contain alpha characters & dashes', $field_class, $field );
|
475 |
-
break;
|
476 |
-
case 'validate_numeric':
|
477 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field may only contain numeric characters', $field_class, $field );
|
478 |
-
break;
|
479 |
-
case 'validate_integer':
|
480 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field may only contain a numeric value', $field_class, $field );
|
481 |
-
break;
|
482 |
-
case 'validate_boolean':
|
483 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field may only contain a true or false value', $field_class, $field );
|
484 |
-
break;
|
485 |
-
case 'validate_float':
|
486 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field may only contain a float value', $field_class, $field );
|
487 |
-
break;
|
488 |
-
case 'validate_valid_url':
|
489 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field is required to be a valid URL', $field_class, $field );
|
490 |
-
break;
|
491 |
-
case 'validate_url_exists':
|
492 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> URL does not exist', $field_class, $field );
|
493 |
-
break;
|
494 |
-
case 'validate_valid_ip':
|
495 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to contain a valid IP address', $field_class, $field );
|
496 |
-
break;
|
497 |
-
case 'validate_valid_cc':
|
498 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to contain a valid credit card number', $field_class, $field );
|
499 |
-
break;
|
500 |
-
case 'validate_valid_name':
|
501 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to contain a valid human name', $field_class, $field );
|
502 |
-
break;
|
503 |
-
case 'validate_contains':
|
504 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to contain one of these values:', $field_class, $field ) . ' ' . implode(', ', $param);
|
505 |
-
break;
|
506 |
-
case 'validate_contains_list':
|
507 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs contain a value from its drop down list', $field_class, $field );
|
508 |
-
break;
|
509 |
-
case 'validate_doesnt_contain_list':
|
510 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field contains a value that is not accepted', $field_class, $field );
|
511 |
-
break;
|
512 |
-
case 'validate_street_address':
|
513 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to be a valid street address', $field_class, $field );
|
514 |
-
break;
|
515 |
-
case 'validate_date':
|
516 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to be a valid date', $field_class, $field );
|
517 |
-
break;
|
518 |
-
case 'validate_min_numeric':
|
519 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to be a numeric value, equal to, or higher than', $field_class, $field ) . $param;
|
520 |
-
break;
|
521 |
-
case 'validate_max_numeric':
|
522 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to be a numeric value, equal to, or lower than', $field_class, $field ) . ' ' . $param;
|
523 |
-
break;
|
524 |
-
case 'validate_starts':
|
525 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to start with', $field_class, $field ) . ' ' . $param;
|
526 |
-
break;
|
527 |
-
case 'validate_extension':
|
528 |
-
$resp[] = sprintf( 'The <span class"%1$s">%2$s</span> field can have the following extensions', $field_class, $field ) . ' '. $param;
|
529 |
-
break;
|
530 |
-
case 'validate_required_file':
|
531 |
-
$resp[] = sprintf( 'The <span class"%1$s">%2$s</span> field is required', $field_class, $field ) .' ' . $param;
|
532 |
-
break;
|
533 |
-
case 'validate_equalsfield':
|
534 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field does not equal %d field', $field_class, $field, $param ) ;
|
535 |
-
break;
|
536 |
-
case 'validate_min_age':
|
537 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to have an age greater than or equal to', $field_class, $field ) . ' '. $param;;
|
538 |
-
break;
|
539 |
-
default:
|
540 |
-
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field is invalid', $field_class, $field );
|
541 |
-
}
|
542 |
-
}
|
543 |
-
|
544 |
-
if (!$convert_to_string) {
|
545 |
-
return $resp;
|
546 |
-
} else {
|
547 |
-
$buffer = '';
|
548 |
-
foreach ($resp as $s) {
|
549 |
-
$buffer .= "<span class=\"$error_class\">$s</span>";
|
550 |
-
}
|
551 |
-
|
552 |
-
return $buffer;
|
553 |
-
}
|
554 |
-
}
|
555 |
-
|
556 |
-
/**
|
557 |
-
* Process the validation errors and return an array of errors with field names as keys.
|
558 |
-
*
|
559 |
-
* @param $convert_to_string
|
560 |
-
*
|
561 |
-
* @return array | null (if empty)
|
562 |
-
*/
|
563 |
-
public function get_errors_array($convert_to_string = null) {
|
564 |
-
if (empty($this->errors)) {
|
565 |
-
return ($convert_to_string) ? null : array();
|
566 |
-
}
|
567 |
-
|
568 |
-
$resp = array();
|
569 |
-
|
570 |
-
foreach ($this->errors as $e) {
|
571 |
-
$field = ucwords(str_replace(array('_', '-'), chr(32), $e['field']));
|
572 |
-
$param = $e['param'];
|
573 |
-
|
574 |
-
// Let's fetch explicit field names if they exist
|
575 |
-
if (array_key_exists($e['field'], self::$fields)) {
|
576 |
-
$field = self::$fields[$e['field']];
|
577 |
-
}
|
578 |
-
|
579 |
-
switch ($e['rule']) {
|
580 |
-
case 'mismatch' :
|
581 |
-
$resp[$field] = 'There is no validation rule for' . ' ' . $field;
|
582 |
-
break;
|
583 |
-
case 'validate_required':
|
584 |
-
$resp[$field] = sprintf( 'The %s field is required', $field);
|
585 |
-
break;
|
586 |
-
case 'validate_valid_email':
|
587 |
-
$resp[$field] = sprintf( 'The %s field is required to be a valid email address', $field);
|
588 |
-
break;
|
589 |
-
case 'validate_max_len':
|
590 |
-
$resp[$field] = sprintf( 'The %s field needs to be %d or shorter in length', $field, $param);
|
591 |
-
break;
|
592 |
-
case 'validate_min_len':
|
593 |
-
$resp[$field] = sprintf( 'The %s field needs to be %d or longer in length', $field, $param);
|
594 |
-
break;
|
595 |
-
case 'validate_exact_len':
|
596 |
-
$resp[$field] = sprintf( 'The %s field needs to be exactly %d characters in length', $field, $param);
|
597 |
-
break;
|
598 |
-
case 'validate_alpha':
|
599 |
-
$resp[$field] = sprintf( 'The %s field may only contain alpha characters(a-z)', $field);
|
600 |
-
break;
|
601 |
-
case 'validate_alpha_numeric':
|
602 |
-
$resp[$field] = sprintf( 'The %s field may only contain alpha-numeric characters', $field);
|
603 |
-
break;
|
604 |
-
case 'validate_alpha_dash':
|
605 |
-
$resp[$field] = sprintf( 'The %s field may only contain alpha characters & dashes', $field);
|
606 |
-
break;
|
607 |
-
case 'validate_numeric':
|
608 |
-
$resp[$field] = sprintf( 'The %s field may only contain numeric characters', $field);
|
609 |
-
break;
|
610 |
-
case 'validate_integer':
|
611 |
-
$resp[$field] = sprintf( 'The %s field may only contain a numeric value', $field);
|
612 |
-
break;
|
613 |
-
case 'validate_boolean':
|
614 |
-
$resp[$field] = sprintf( 'The %s field may only contain a true or false value', $field);
|
615 |
-
break;
|
616 |
-
case 'validate_float':
|
617 |
-
$resp[$field] = sprintf( 'The %s field may only contain a float value', $field);
|
618 |
-
break;
|
619 |
-
case 'validate_valid_url':
|
620 |
-
$resp[$field] = sprintf( 'The %s field is required to be a valid URL', $field);
|
621 |
-
break;
|
622 |
-
case 'validate_url_exists':
|
623 |
-
$resp[$field] = sprintf( 'The %s URL does not exist', $field);
|
624 |
-
break;
|
625 |
-
case 'validate_valid_ip':
|
626 |
-
$resp[$field] = sprintf( 'The %s field needs to contain a valid IP address', $field);
|
627 |
-
break;
|
628 |
-
case 'validate_valid_cc':
|
629 |
-
$resp[$field] = sprintf( 'The %s field needs to contain a valid credit card number', $field);
|
630 |
-
break;
|
631 |
-
case 'validate_valid_name':
|
632 |
-
$resp[$field] = sprintf( 'The %s field needs to contain a valid human name', $field);
|
633 |
-
break;
|
634 |
-
case 'validate_contains':
|
635 |
-
$resp[$field] = sprintf( 'The %s field needs to contain one of these values:', $field) . ' ' . implode(', ', $param);
|
636 |
-
break;
|
637 |
-
case 'validate_street_address':
|
638 |
-
$resp[$field] = sprintf( 'The %s field needs to be a valid street address', $field);
|
639 |
-
break;
|
640 |
-
case 'validate_date':
|
641 |
-
$resp[$field] = sprintf( 'The %s field needs to be a valid date', $field);
|
642 |
-
break;
|
643 |
-
case 'validate_min_numeric':
|
644 |
-
$resp[$field] = sprintf( 'The %s field needs to be a numeric value, equal to, or higher than %d', $field, $param);
|
645 |
-
break;
|
646 |
-
case 'validate_max_numeric':
|
647 |
-
$resp[$field] = sprintf( 'The %s field needs to be a numeric value, equal to, or lower than %d', $field, $param);
|
648 |
-
break;
|
649 |
-
case 'validate_min_age':
|
650 |
-
$resp[$field] = sprintf( 'The %s field needs to have an age greater than or equal to %d', $field, $param);
|
651 |
-
break;
|
652 |
-
default:
|
653 |
-
$resp[$field] = sprintf( 'The %s field is invalid', $field );
|
654 |
-
}
|
655 |
-
}
|
656 |
-
|
657 |
-
return $resp;
|
658 |
-
}
|
659 |
-
|
660 |
-
|
661 |
-
/**
|
662 |
-
* Filter the input data according to the specified filter set.
|
663 |
-
*
|
664 |
-
* @param mixed $input
|
665 |
-
* @param array $filterset
|
666 |
-
*
|
667 |
-
* @throws Exception
|
668 |
-
*
|
669 |
-
* @return mixed
|
670 |
-
*
|
671 |
-
* @throws Exception
|
672 |
-
*/
|
673 |
-
public function filter(array $input, array $filterset) {
|
674 |
-
foreach ($filterset as $field => $filters) {
|
675 |
-
if (!array_key_exists($field, $input)) {
|
676 |
-
continue;
|
677 |
-
}
|
678 |
-
|
679 |
-
$filters = explode('|', $filters);
|
680 |
-
|
681 |
-
foreach ($filters as $filter) {
|
682 |
-
$params = null;
|
683 |
-
|
684 |
-
if (strstr($filter, ',') !== false) {
|
685 |
-
$filter = explode(',', $filter);
|
686 |
-
|
687 |
-
$params = array_slice($filter, 1, count($filter) - 1);
|
688 |
-
|
689 |
-
$filter = $filter[0];
|
690 |
-
}
|
691 |
-
|
692 |
-
if (is_callable(array($this, 'filter_' . $filter))) {
|
693 |
-
$method = 'filter_' . $filter;
|
694 |
-
$input[$field] = $this->$method($input[$field], $params);
|
695 |
-
} elseif (function_exists($filter)) {
|
696 |
-
$input[$field] = $filter($input[$field]);
|
697 |
-
} elseif (isset(self::$filter_methods[$filter])) {
|
698 |
-
$input[$field] = call_user_func(self::$filter_methods[$filter], $input[$field], $params);
|
699 |
-
} else {
|
700 |
-
throw new Exception("Filter method '$filter' does not exist.");
|
701 |
-
}
|
702 |
-
}
|
703 |
-
}
|
704 |
-
|
705 |
-
return $input;
|
706 |
-
}
|
707 |
-
|
708 |
-
// ** ------------------------- Filters --------------------------------------- ** //
|
709 |
-
|
710 |
-
/**
|
711 |
-
* Replace noise words in a string (http://tax.cchgroup.com/help/Avoiding_noise_words_in_your_search.htm).
|
712 |
-
*
|
713 |
-
* Usage: '<index>' => 'noise_words'
|
714 |
-
*
|
715 |
-
* @param string $value
|
716 |
-
* @param array $params
|
717 |
-
*
|
718 |
-
* @return string
|
719 |
-
*/
|
720 |
-
protected function filter_noise_words($value, $params = null) {
|
721 |
-
$value = preg_replace('/\s\s+/u', chr(32), $value);
|
722 |
-
|
723 |
-
$value = " $value ";
|
724 |
-
|
725 |
-
$words = explode(',', self::$en_noise_words);
|
726 |
-
|
727 |
-
foreach ($words as $word) {
|
728 |
-
$word = trim($word);
|
729 |
-
|
730 |
-
$word = " $word "; // Normalize
|
731 |
-
|
732 |
-
if (stripos($value, $word) !== false) {
|
733 |
-
$value = str_ireplace($word, chr(32), $value);
|
734 |
-
}
|
735 |
-
}
|
736 |
-
|
737 |
-
return trim($value);
|
738 |
-
}
|
739 |
-
|
740 |
-
/**
|
741 |
-
* Remove all known punctuation from a string.
|
742 |
-
*
|
743 |
-
* Usage: '<index>' => 'rmpunctuataion'
|
744 |
-
*
|
745 |
-
* @param string $value
|
746 |
-
* @param array $params
|
747 |
-
*
|
748 |
-
* @return string
|
749 |
-
*/
|
750 |
-
protected function filter_rmpunctuation($value, $params = null) {
|
751 |
-
return preg_replace("/(?![.=$'€%-])\p{P}/u", '', $value);
|
752 |
-
}
|
753 |
-
|
754 |
-
/**
|
755 |
-
* Translate an input string to a desired language [DEPRECIATED].
|
756 |
-
*
|
757 |
-
* Any ISO 639-1 2 character language code may be used
|
758 |
-
*
|
759 |
-
* See: http://www.science.co.il/language/Codes.asp?s=code2
|
760 |
-
*
|
761 |
-
* @param string $value
|
762 |
-
* @param array $params
|
763 |
-
*
|
764 |
-
* @return string
|
765 |
-
*/
|
766 |
-
/*
|
767 |
-
protected function filter_translate($value, $params = NULL)
|
768 |
-
{
|
769 |
-
$input_lang = 'en';
|
770 |
-
$output_lang = 'en';
|
771 |
-
|
772 |
-
if(is_null($params))
|
773 |
-
{
|
774 |
-
return $value;
|
775 |
-
}
|
776 |
-
|
777 |
-
switch(count($params))
|
778 |
-
{
|
779 |
-
case 1:
|
780 |
-
$input_lang = $params[0];
|
781 |
-
break;
|
782 |
-
case 2:
|
783 |
-
$input_lang = $params[0];
|
784 |
-
$output_lang = $params[1];
|
785 |
-
break;
|
786 |
-
}
|
787 |
-
|
788 |
-
$text = urlencode($value);
|
789 |
-
|
790 |
-
$translation = file_get_contents(
|
791 |
-
"http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q={$text}&langpair={$input_lang}|{$output_lang}"
|
792 |
-
);
|
793 |
-
|
794 |
-
$json = json_decode($translation, true);
|
795 |
-
|
796 |
-
if($json['responseStatus'] != 200)
|
797 |
-
{
|
798 |
-
return $value;
|
799 |
-
}
|
800 |
-
else
|
801 |
-
{
|
802 |
-
return $json['responseData']['translatedText'];
|
803 |
-
}
|
804 |
-
}
|
805 |
-
*/
|
806 |
-
|
807 |
-
/**
|
808 |
-
* Sanitize the string by removing any script tags.
|
809 |
-
*
|
810 |
-
* Usage: '<index>' => 'sanitize_string'
|
811 |
-
*
|
812 |
-
* @param string $value
|
813 |
-
* @param array $params
|
814 |
-
*
|
815 |
-
* @return string
|
816 |
-
*/
|
817 |
-
protected function filter_sanitize_string($value, $params = null) {
|
818 |
-
return filter_var($value, FILTER_SANITIZE_STRING);
|
819 |
-
}
|
820 |
-
|
821 |
-
/**
|
822 |
-
* Sanitize the string by urlencoding characters.
|
823 |
-
*
|
824 |
-
* Usage: '<index>' => 'urlencode'
|
825 |
-
*
|
826 |
-
* @param string $value
|
827 |
-
* @param array $params
|
828 |
-
*
|
829 |
-
* @return string
|
830 |
-
*/
|
831 |
-
protected function filter_urlencode($value, $params = null) {
|
832 |
-
return filter_var($value, FILTER_SANITIZE_ENCODED);
|
833 |
-
}
|
834 |
-
|
835 |
-
/**
|
836 |
-
* Sanitize the string by converting HTML characters to their HTML entities.
|
837 |
-
*
|
838 |
-
* Usage: '<index>' => 'htmlencode'
|
839 |
-
*
|
840 |
-
* @param string $value
|
841 |
-
* @param array $params
|
842 |
-
*
|
843 |
-
* @return string
|
844 |
-
*/
|
845 |
-
protected function filter_htmlencode($value, $params = null) {
|
846 |
-
return filter_var($value, FILTER_SANITIZE_SPECIAL_CHARS);
|
847 |
-
}
|
848 |
-
|
849 |
-
/**
|
850 |
-
* Sanitize the string by removing illegal characters from emails.
|
851 |
-
*
|
852 |
-
* Usage: '<index>' => 'sanitize_email'
|
853 |
-
*
|
854 |
-
* @param string $value
|
855 |
-
* @param array $params
|
856 |
-
*
|
857 |
-
* @return string
|
858 |
-
*/
|
859 |
-
protected function filter_sanitize_email($value, $params = null) {
|
860 |
-
return filter_var($value, FILTER_SANITIZE_EMAIL);
|
861 |
-
}
|
862 |
-
|
863 |
-
/**
|
864 |
-
* Sanitize the string by removing illegal characters from numbers.
|
865 |
-
*
|
866 |
-
* @param string $value
|
867 |
-
* @param array $params
|
868 |
-
*
|
869 |
-
* @return string
|
870 |
-
*/
|
871 |
-
protected function filter_sanitize_numbers($value, $params = null) {
|
872 |
-
return filter_var($value, FILTER_SANITIZE_NUMBER_INT);
|
873 |
-
}
|
874 |
-
|
875 |
-
/**
|
876 |
-
* Filter out all HTML tags except the defined basic tags.
|
877 |
-
*
|
878 |
-
* @param string $value
|
879 |
-
* @param array $params
|
880 |
-
*
|
881 |
-
* @return string
|
882 |
-
*/
|
883 |
-
protected function filter_basic_tags($value, $params = null) {
|
884 |
-
return strip_tags($value, self::$basic_tags);
|
885 |
-
}
|
886 |
-
|
887 |
-
/**
|
888 |
-
* Convert the provided numeric value to a whole number.
|
889 |
-
*
|
890 |
-
* @param string $value
|
891 |
-
* @param array $params
|
892 |
-
*
|
893 |
-
* @return string
|
894 |
-
*/
|
895 |
-
protected function filter_whole_number($value, $params = null) {
|
896 |
-
return intval($value);
|
897 |
-
}
|
898 |
-
|
899 |
-
// ** ------------------------- Validators ------------------------------------ ** //
|
900 |
-
|
901 |
-
|
902 |
-
/**
|
903 |
-
* Verify that a value is contained within the pre-defined value set.
|
904 |
-
*
|
905 |
-
* Usage: '<index>' => 'contains,value value value'
|
906 |
-
*
|
907 |
-
* @param string $field
|
908 |
-
* @param array $input
|
909 |
-
* @param null $param
|
910 |
-
*
|
911 |
-
* @return mixed
|
912 |
-
*/
|
913 |
-
protected function validate_contains($field, $input, $param = null) {
|
914 |
-
if (!isset($input[$field])) {
|
915 |
-
return;
|
916 |
-
}
|
917 |
-
|
918 |
-
$param = trim(strtolower($param));
|
919 |
-
|
920 |
-
$value = trim(strtolower($input[$field]));
|
921 |
-
|
922 |
-
if (preg_match_all('#\'(.+?)\'#', $param, $matches, PREG_PATTERN_ORDER)) {
|
923 |
-
$param = $matches[1];
|
924 |
-
} else {
|
925 |
-
$param = explode(chr(32), $param);
|
926 |
-
}
|
927 |
-
|
928 |
-
if (in_array($value, $param)) { // valid, return nothing
|
929 |
-
return;
|
930 |
-
}
|
931 |
-
|
932 |
-
return array(
|
933 |
-
'field' => $field,
|
934 |
-
'value' => $value,
|
935 |
-
'rule' => __FUNCTION__,
|
936 |
-
'param' => $param,
|
937 |
-
);
|
938 |
-
}
|
939 |
-
|
940 |
-
/**
|
941 |
-
* Verify that a value is contained within the pre-defined value set.
|
942 |
-
* OUTPUT: will NOT show the list of values.
|
943 |
-
*
|
944 |
-
* Usage: '<index>' => 'contains_list,value;value;value'
|
945 |
-
*
|
946 |
-
* @param string $field
|
947 |
-
* @param array $input
|
948 |
-
*
|
949 |
-
* @return mixed
|
950 |
-
*/
|
951 |
-
protected function validate_contains_list($field, $input, $param = null) {
|
952 |
-
$param = trim(strtolower($param));
|
953 |
-
|
954 |
-
$value = trim(strtolower($input[$field]));
|
955 |
-
|
956 |
-
$param = explode(';', $param);
|
957 |
-
|
958 |
-
// consider: in_array(strtolower($value), array_map('strtolower', $param)
|
959 |
-
|
960 |
-
if (in_array($value, $param)) { // valid, return nothing
|
961 |
-
return;
|
962 |
-
} else {
|
963 |
-
return array(
|
964 |
-
'field' => $field,
|
965 |
-
'value' => $value,
|
966 |
-
'rule' => __FUNCTION__,
|
967 |
-
'param' => $param,
|
968 |
-
);
|
969 |
-
}
|
970 |
-
}
|
971 |
-
|
972 |
-
/**
|
973 |
-
* Verify that a value is NOT contained within the pre-defined value set.
|
974 |
-
* OUTPUT: will NOT show the list of values.
|
975 |
-
*
|
976 |
-
* Usage: '<index>' => 'doesnt_contain_list,value;value;value'
|
977 |
-
*
|
978 |
-
* @param string $field
|
979 |
-
* @param array $input
|
980 |
-
*
|
981 |
-
* @return mixed
|
982 |
-
*/
|
983 |
-
protected function validate_doesnt_contain_list($field, $input, $param = null) {
|
984 |
-
$param = trim(strtolower($param));
|
985 |
-
|
986 |
-
$value = trim(strtolower($input[$field]));
|
987 |
-
|
988 |
-
$param = explode(';', $param);
|
989 |
-
|
990 |
-
if (!in_array($value, $param)) { // valid, return nothing
|
991 |
-
return;
|
992 |
-
} else {
|
993 |
-
return array(
|
994 |
-
'field' => $field,
|
995 |
-
'value' => $value,
|
996 |
-
'rule' => __FUNCTION__,
|
997 |
-
'param' => $param,
|
998 |
-
);
|
999 |
-
}
|
1000 |
-
}
|
1001 |
-
|
1002 |
-
/**
|
1003 |
-
* Check if the specified key is present and not empty.
|
1004 |
-
*
|
1005 |
-
* Usage: '<index>' => 'required'
|
1006 |
-
*
|
1007 |
-
* @param string $field
|
1008 |
-
* @param array $input
|
1009 |
-
* @param null $param
|
1010 |
-
*
|
1011 |
-
* @return mixed
|
1012 |
-
*/
|
1013 |
-
protected function validate_required($field, $input, $param = null) {
|
1014 |
-
if (isset($input[$field]) && ($input[$field] === false || $input[$field] === 0 || $input[$field] === 0.0 || $input[$field] === '0' || !empty($input[$field]))) {
|
1015 |
-
return;
|
1016 |
-
}
|
1017 |
-
|
1018 |
-
return array(
|
1019 |
-
'field' => $field,
|
1020 |
-
'value' => null,
|
1021 |
-
'rule' => __FUNCTION__,
|
1022 |
-
'param' => $param,
|
1023 |
-
);
|
1024 |
-
}
|
1025 |
-
|
1026 |
-
/**
|
1027 |
-
* Determine if the provided email is valid.
|
1028 |
-
*
|
1029 |
-
* Usage: '<index>' => 'valid_email'
|
1030 |
-
*
|
1031 |
-
* @param string $field
|
1032 |
-
* @param array $input
|
1033 |
-
* @param null $param
|
1034 |
-
*
|
1035 |
-
* @return mixed
|
1036 |
-
*/
|
1037 |
-
protected function validate_valid_email($field, $input, $param = null) {
|
1038 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1039 |
-
return;
|
1040 |
-
}
|
1041 |
-
|
1042 |
-
if (!filter_var($input[$field], FILTER_VALIDATE_EMAIL)) {
|
1043 |
-
return array(
|
1044 |
-
'field' => $field,
|
1045 |
-
'value' => $input[$field],
|
1046 |
-
'rule' => __FUNCTION__,
|
1047 |
-
'param' => $param,
|
1048 |
-
);
|
1049 |
-
}
|
1050 |
-
}
|
1051 |
-
|
1052 |
-
/**
|
1053 |
-
* Determine if the provided value length is less or equal to a specific value.
|
1054 |
-
*
|
1055 |
-
* Usage: '<index>' => 'max_len,240'
|
1056 |
-
*
|
1057 |
-
* @param string $field
|
1058 |
-
* @param array $input
|
1059 |
-
* @param null $param
|
1060 |
-
*
|
1061 |
-
* @return mixed
|
1062 |
-
*/
|
1063 |
-
protected function validate_max_len($field, $input, $param = null) {
|
1064 |
-
if (!isset($input[$field])) {
|
1065 |
-
return;
|
1066 |
-
}
|
1067 |
-
|
1068 |
-
if (function_exists('mb_strlen')) {
|
1069 |
-
if (mb_strlen($input[$field]) <= (int)$param) {
|
1070 |
-
return;
|
1071 |
-
}
|
1072 |
-
} else {
|
1073 |
-
if (strlen($input[$field]) <= (int)$param) {
|
1074 |
-
return;
|
1075 |
-
}
|
1076 |
-
}
|
1077 |
-
|
1078 |
-
return array(
|
1079 |
-
'field' => $field,
|
1080 |
-
'value' => $input[$field],
|
1081 |
-
'rule' => __FUNCTION__,
|
1082 |
-
'param' => $param,
|
1083 |
-
);
|
1084 |
-
}
|
1085 |
-
|
1086 |
-
/**
|
1087 |
-
* Determine if the provided value length is more or equal to a specific value.
|
1088 |
-
*
|
1089 |
-
* Usage: '<index>' => 'min_len,4'
|
1090 |
-
*
|
1091 |
-
* @param string $field
|
1092 |
-
* @param array $input
|
1093 |
-
* @param null $param
|
1094 |
-
*
|
1095 |
-
* @return mixed
|
1096 |
-
*/
|
1097 |
-
protected function validate_min_len($field, $input, $param = null) {
|
1098 |
-
if (!isset($input[$field])) {
|
1099 |
-
return;
|
1100 |
-
}
|
1101 |
-
|
1102 |
-
if (function_exists('mb_strlen')) {
|
1103 |
-
if (mb_strlen($input[$field]) >= (int)$param) {
|
1104 |
-
return;
|
1105 |
-
}
|
1106 |
-
} else {
|
1107 |
-
if (strlen($input[$field]) >= (int)$param) {
|
1108 |
-
return;
|
1109 |
-
}
|
1110 |
-
}
|
1111 |
-
|
1112 |
-
return array(
|
1113 |
-
'field' => $field,
|
1114 |
-
'value' => $input[$field],
|
1115 |
-
'rule' => __FUNCTION__,
|
1116 |
-
'param' => $param,
|
1117 |
-
);
|
1118 |
-
}
|
1119 |
-
|
1120 |
-
/**
|
1121 |
-
* Determine if the provided value length matches a specific value.
|
1122 |
-
*
|
1123 |
-
* Usage: '<index>' => 'exact_len,5'
|
1124 |
-
*
|
1125 |
-
* @param string $field
|
1126 |
-
* @param array $input
|
1127 |
-
* @param null $param
|
1128 |
-
*
|
1129 |
-
* @return mixed
|
1130 |
-
*/
|
1131 |
-
protected function validate_exact_len($field, $input, $param = null) {
|
1132 |
-
if (!isset($input[$field])) {
|
1133 |
-
return;
|
1134 |
-
}
|
1135 |
-
|
1136 |
-
if (function_exists('mb_strlen')) {
|
1137 |
-
if (mb_strlen($input[$field]) == (int)$param) {
|
1138 |
-
return;
|
1139 |
-
}
|
1140 |
-
} else {
|
1141 |
-
if (strlen($input[$field]) == (int)$param) {
|
1142 |
-
return;
|
1143 |
-
}
|
1144 |
-
}
|
1145 |
-
|
1146 |
-
return array(
|
1147 |
-
'field' => $field,
|
1148 |
-
'value' => $input[$field],
|
1149 |
-
'rule' => __FUNCTION__,
|
1150 |
-
'param' => $param,
|
1151 |
-
);
|
1152 |
-
}
|
1153 |
-
|
1154 |
-
/**
|
1155 |
-
* Determine if the provided value contains only alpha characters.
|
1156 |
-
*
|
1157 |
-
* Usage: '<index>' => 'alpha'
|
1158 |
-
*
|
1159 |
-
* @param string $field
|
1160 |
-
* @param array $input
|
1161 |
-
* @param null $param
|
1162 |
-
*
|
1163 |
-
* @return mixed
|
1164 |
-
*/
|
1165 |
-
protected function validate_alpha($field, $input, $param = null) {
|
1166 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1167 |
-
return;
|
1168 |
-
}
|
1169 |
-
|
1170 |
-
if (!preg_match('/^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$/i', $input[$field]) !== false) {
|
1171 |
-
return array(
|
1172 |
-
'field' => $field,
|
1173 |
-
'value' => $input[$field],
|
1174 |
-
'rule' => __FUNCTION__,
|
1175 |
-
'param' => $param,
|
1176 |
-
);
|
1177 |
-
}
|
1178 |
-
}
|
1179 |
-
|
1180 |
-
/**
|
1181 |
-
* Determine if the provided value contains only alpha-numeric characters.
|
1182 |
-
*
|
1183 |
-
* Usage: '<index>' => 'alpha_numeric'
|
1184 |
-
*
|
1185 |
-
* @param string $field
|
1186 |
-
* @param array $input
|
1187 |
-
* @param null $param
|
1188 |
-
*
|
1189 |
-
* @return mixed
|
1190 |
-
*/
|
1191 |
-
protected function validate_alpha_numeric($field, $input, $param = null) {
|
1192 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1193 |
-
return;
|
1194 |
-
}
|
1195 |
-
|
1196 |
-
if (!preg_match('/^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$/i', $input[$field]) !== false) {
|
1197 |
-
return array(
|
1198 |
-
'field' => $field,
|
1199 |
-
'value' => $input[$field],
|
1200 |
-
'rule' => __FUNCTION__,
|
1201 |
-
'param' => $param,
|
1202 |
-
);
|
1203 |
-
}
|
1204 |
-
}
|
1205 |
-
|
1206 |
-
/**
|
1207 |
-
* Determine if the provided value contains only alpha characters with dashed and underscores.
|
1208 |
-
*
|
1209 |
-
* Usage: '<index>' => 'alpha_dash'
|
1210 |
-
*
|
1211 |
-
* @param string $field
|
1212 |
-
* @param array $input
|
1213 |
-
* @param null $param
|
1214 |
-
*
|
1215 |
-
* @return mixed
|
1216 |
-
*/
|
1217 |
-
protected function validate_alpha_dash($field, $input, $param = null) {
|
1218 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1219 |
-
return;
|
1220 |
-
}
|
1221 |
-
|
1222 |
-
if (!preg_match('/^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ_-])+$/i', $input[$field]) !== false) {
|
1223 |
-
return array(
|
1224 |
-
'field' => $field,
|
1225 |
-
'value' => $input[$field],
|
1226 |
-
'rule' => __FUNCTION__,
|
1227 |
-
'param' => $param,
|
1228 |
-
);
|
1229 |
-
}
|
1230 |
-
}
|
1231 |
-
|
1232 |
-
/**
|
1233 |
-
* Determine if the provided value contains only alpha numeric characters with spaces.
|
1234 |
-
*
|
1235 |
-
* Usage: '<index>' => 'alpha_space'
|
1236 |
-
*
|
1237 |
-
* @param string $field
|
1238 |
-
* @param array $input
|
1239 |
-
* @param null $param
|
1240 |
-
*
|
1241 |
-
* @return mixed
|
1242 |
-
*/
|
1243 |
-
protected function validate_alpha_space($field, $input, $param = null) {
|
1244 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1245 |
-
return;
|
1246 |
-
}
|
1247 |
-
|
1248 |
-
if (!preg_match("/^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\s])+$/i", $input[$field]) !== false) {
|
1249 |
-
return array(
|
1250 |
-
'field' => $field,
|
1251 |
-
'value' => $input[$field],
|
1252 |
-
'rule' => __FUNCTION__,
|
1253 |
-
'param' => $param,
|
1254 |
-
);
|
1255 |
-
}
|
1256 |
-
}
|
1257 |
-
|
1258 |
-
/**
|
1259 |
-
* Determine if the provided value is a valid number or numeric string.
|
1260 |
-
*
|
1261 |
-
* Usage: '<index>' => 'numeric'
|
1262 |
-
*
|
1263 |
-
* @param string $field
|
1264 |
-
* @param array $input
|
1265 |
-
* @param null $param
|
1266 |
-
*
|
1267 |
-
* @return mixed
|
1268 |
-
*/
|
1269 |
-
protected function validate_numeric($field, $input, $param = null) {
|
1270 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1271 |
-
return;
|
1272 |
-
}
|
1273 |
-
|
1274 |
-
if (!is_numeric($input[$field])) {
|
1275 |
-
return array(
|
1276 |
-
'field' => $field,
|
1277 |
-
'value' => $input[$field],
|
1278 |
-
'rule' => __FUNCTION__,
|
1279 |
-
'param' => $param,
|
1280 |
-
);
|
1281 |
-
}
|
1282 |
-
}
|
1283 |
-
|
1284 |
-
/**
|
1285 |
-
* Determine if the provided value is a valid integer.
|
1286 |
-
*
|
1287 |
-
* Usage: '<index>' => 'integer'
|
1288 |
-
*
|
1289 |
-
* @param string $field
|
1290 |
-
* @param array $input
|
1291 |
-
* @param null $param
|
1292 |
-
*
|
1293 |
-
* @return mixed
|
1294 |
-
*/
|
1295 |
-
protected function validate_integer($field, $input, $param = null) {
|
1296 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1297 |
-
return;
|
1298 |
-
}
|
1299 |
-
|
1300 |
-
if (filter_var($input[$field], FILTER_VALIDATE_INT) === false) {
|
1301 |
-
return array(
|
1302 |
-
'field' => $field,
|
1303 |
-
'value' => $input[$field],
|
1304 |
-
'rule' => __FUNCTION__,
|
1305 |
-
'param' => $param,
|
1306 |
-
);
|
1307 |
-
}
|
1308 |
-
}
|
1309 |
-
|
1310 |
-
/**
|
1311 |
-
* Determine if the provided value is a PHP accepted boolean.
|
1312 |
-
*
|
1313 |
-
* Usage: '<index>' => 'boolean'
|
1314 |
-
*
|
1315 |
-
* @param string $field
|
1316 |
-
* @param array $input
|
1317 |
-
* @param null $param
|
1318 |
-
*
|
1319 |
-
* @return mixed
|
1320 |
-
*/
|
1321 |
-
protected function validate_boolean($field, $input, $param = null) {
|
1322 |
-
if (!isset($input[$field]) || empty($input[$field]) && $input[$field] !== 0) {
|
1323 |
-
return;
|
1324 |
-
}
|
1325 |
-
|
1326 |
-
if ($input[$field] === true || $input[$field] === false) {
|
1327 |
-
return;
|
1328 |
-
}
|
1329 |
-
|
1330 |
-
return array(
|
1331 |
-
'field' => $field,
|
1332 |
-
'value' => $input[$field],
|
1333 |
-
'rule' => __FUNCTION__,
|
1334 |
-
'param' => $param,
|
1335 |
-
);
|
1336 |
-
}
|
1337 |
-
|
1338 |
-
/**
|
1339 |
-
* Determine if the provided value is a valid float.
|
1340 |
-
*
|
1341 |
-
* Usage: '<index>' => 'float'
|
1342 |
-
*
|
1343 |
-
* @param string $field
|
1344 |
-
* @param array $input
|
1345 |
-
* @param null $param
|
1346 |
-
*
|
1347 |
-
* @return mixed
|
1348 |
-
*/
|
1349 |
-
protected function validate_float($field, $input, $param = null) {
|
1350 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1351 |
-
return;
|
1352 |
-
}
|
1353 |
-
|
1354 |
-
if (filter_var($input[$field], FILTER_VALIDATE_FLOAT) === false) {
|
1355 |
-
return array(
|
1356 |
-
'field' => $field,
|
1357 |
-
'value' => $input[$field],
|
1358 |
-
'rule' => __FUNCTION__,
|
1359 |
-
'param' => $param,
|
1360 |
-
);
|
1361 |
-
}
|
1362 |
-
}
|
1363 |
-
|
1364 |
-
/**
|
1365 |
-
* Determine if the provided value is a valid URL.
|
1366 |
-
*
|
1367 |
-
* Usage: '<index>' => 'valid_url'
|
1368 |
-
*
|
1369 |
-
* @param string $field
|
1370 |
-
* @param array $input
|
1371 |
-
* @param null $param
|
1372 |
-
*
|
1373 |
-
* @return mixed
|
1374 |
-
*/
|
1375 |
-
protected function validate_valid_url($field, $input, $param = null) {
|
1376 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1377 |
-
return;
|
1378 |
-
}
|
1379 |
-
|
1380 |
-
if (!filter_var($input[$field], FILTER_VALIDATE_URL)) {
|
1381 |
-
return array(
|
1382 |
-
'field' => $field,
|
1383 |
-
'value' => $input[$field],
|
1384 |
-
'rule' => __FUNCTION__,
|
1385 |
-
'param' => $param,
|
1386 |
-
);
|
1387 |
-
}
|
1388 |
-
}
|
1389 |
-
|
1390 |
-
/**
|
1391 |
-
* Determine if a URL exists & is accessible.
|
1392 |
-
*
|
1393 |
-
* Usage: '<index>' => 'url_exists'
|
1394 |
-
*
|
1395 |
-
* @param string $field
|
1396 |
-
* @param array $input
|
1397 |
-
* @param null $param
|
1398 |
-
*
|
1399 |
-
* @return mixed
|
1400 |
-
*/
|
1401 |
-
protected function validate_url_exists($field, $input, $param = null) {
|
1402 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1403 |
-
return;
|
1404 |
-
}
|
1405 |
-
|
1406 |
-
$url = parse_url(strtolower($input[$field]));
|
1407 |
-
|
1408 |
-
if (isset($url['host'])) {
|
1409 |
-
$url = $url['host'];
|
1410 |
-
}
|
1411 |
-
|
1412 |
-
if (function_exists('checkdnsrr')) {
|
1413 |
-
if (checkdnsrr($url) === false) {
|
1414 |
-
return array(
|
1415 |
-
'field' => $field,
|
1416 |
-
'value' => $input[$field],
|
1417 |
-
'rule' => __FUNCTION__,
|
1418 |
-
'param' => $param,
|
1419 |
-
);
|
1420 |
-
}
|
1421 |
-
} else {
|
1422 |
-
if (gethostbyname($url) == $url) {
|
1423 |
-
return array(
|
1424 |
-
'field' => $field,
|
1425 |
-
'value' => $input[$field],
|
1426 |
-
'rule' => __FUNCTION__,
|
1427 |
-
'param' => $param,
|
1428 |
-
);
|
1429 |
-
}
|
1430 |
-
}
|
1431 |
-
}
|
1432 |
-
|
1433 |
-
/**
|
1434 |
-
* Determine if the provided value is a valid IP address.
|
1435 |
-
*
|
1436 |
-
* Usage: '<index>' => 'valid_ip'
|
1437 |
-
*
|
1438 |
-
* @param string $field
|
1439 |
-
* @param array $input
|
1440 |
-
*
|
1441 |
-
* @return mixed
|
1442 |
-
*/
|
1443 |
-
protected function validate_valid_ip($field, $input, $param = null) {
|
1444 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1445 |
-
return;
|
1446 |
-
}
|
1447 |
-
|
1448 |
-
if (!filter_var($input[$field], FILTER_VALIDATE_IP) !== false) {
|
1449 |
-
return array(
|
1450 |
-
'field' => $field,
|
1451 |
-
'value' => $input[$field],
|
1452 |
-
'rule' => __FUNCTION__,
|
1453 |
-
'param' => $param,
|
1454 |
-
);
|
1455 |
-
}
|
1456 |
-
}
|
1457 |
-
|
1458 |
-
/**
|
1459 |
-
* Determine if the provided value is a valid IPv4 address.
|
1460 |
-
*
|
1461 |
-
* Usage: '<index>' => 'valid_ipv4'
|
1462 |
-
*
|
1463 |
-
* @param string $field
|
1464 |
-
* @param array $input
|
1465 |
-
*
|
1466 |
-
* @return mixed
|
1467 |
-
*
|
1468 |
-
* @see http://pastebin.com/UvUPPYK0
|
1469 |
-
*/
|
1470 |
-
|
1471 |
-
/*
|
1472 |
-
* What about private networks? http://en.wikipedia.org/wiki/Private_network
|
1473 |
-
* What about loop-back address? 127.0.0.1
|
1474 |
-
*/
|
1475 |
-
protected function validate_valid_ipv4($field, $input, $param = null) {
|
1476 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1477 |
-
return;
|
1478 |
-
}
|
1479 |
-
|
1480 |
-
if (!filter_var($input[$field], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
1481 |
-
// removed !== FALSE
|
1482 |
-
|
1483 |
-
return array(
|
1484 |
-
'field' => $field,
|
1485 |
-
'value' => $input[$field],
|
1486 |
-
'rule' => __FUNCTION__,
|
1487 |
-
'param' => $param,
|
1488 |
-
);
|
1489 |
-
}
|
1490 |
-
}
|
1491 |
-
|
1492 |
-
/**
|
1493 |
-
* Determine if the provided value is a valid IPv6 address.
|
1494 |
-
*
|
1495 |
-
* Usage: '<index>' => 'valid_ipv6'
|
1496 |
-
*
|
1497 |
-
* @param string $field
|
1498 |
-
* @param array $input
|
1499 |
-
*
|
1500 |
-
* @return mixed
|
1501 |
-
*/
|
1502 |
-
protected function validate_valid_ipv6($field, $input, $param = null) {
|
1503 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1504 |
-
return;
|
1505 |
-
}
|
1506 |
-
|
1507 |
-
if (!filter_var($input[$field], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
1508 |
-
return array(
|
1509 |
-
'field' => $field,
|
1510 |
-
'value' => $input[$field],
|
1511 |
-
'rule' => __FUNCTION__,
|
1512 |
-
'param' => $param,
|
1513 |
-
);
|
1514 |
-
}
|
1515 |
-
}
|
1516 |
-
|
1517 |
-
/**
|
1518 |
-
* Determine if the input is a valid credit card number.
|
1519 |
-
*
|
1520 |
-
* See: http://stackoverflow.com/questions/174730/what-is-the-best-way-to-validate-a-credit-card-in-php
|
1521 |
-
* Usage: '<index>' => 'valid_cc'
|
1522 |
-
*
|
1523 |
-
* @param string $field
|
1524 |
-
* @param array $input
|
1525 |
-
*
|
1526 |
-
* @return mixed
|
1527 |
-
*/
|
1528 |
-
protected function validate_valid_cc($field, $input, $param = null) {
|
1529 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1530 |
-
return;
|
1531 |
-
}
|
1532 |
-
|
1533 |
-
$number = preg_replace('/\D/', '', $input[$field]);
|
1534 |
-
|
1535 |
-
if (function_exists('mb_strlen')) {
|
1536 |
-
$number_length = mb_strlen($number);
|
1537 |
-
} else {
|
1538 |
-
$number_length = strlen($number);
|
1539 |
-
}
|
1540 |
-
|
1541 |
-
$parity = $number_length % 2;
|
1542 |
-
|
1543 |
-
$total = 0;
|
1544 |
-
|
1545 |
-
for ($i = 0; $i < $number_length; ++$i) {
|
1546 |
-
$digit = $number[$i];
|
1547 |
-
|
1548 |
-
if ($i % 2 == $parity) {
|
1549 |
-
$digit *= 2;
|
1550 |
-
|
1551 |
-
if ($digit > 9) {
|
1552 |
-
$digit -= 9;
|
1553 |
-
}
|
1554 |
-
}
|
1555 |
-
|
1556 |
-
$total += $digit;
|
1557 |
-
}
|
1558 |
-
|
1559 |
-
if ($total % 10 == 0) {
|
1560 |
-
return; // Valid
|
1561 |
-
}
|
1562 |
-
|
1563 |
-
return array(
|
1564 |
-
'field' => $field,
|
1565 |
-
'value' => $input[$field],
|
1566 |
-
'rule' => __FUNCTION__,
|
1567 |
-
'param' => $param,
|
1568 |
-
);
|
1569 |
-
}
|
1570 |
-
|
1571 |
-
/**
|
1572 |
-
* Determine if the input is a valid human name [Credits to http://github.com/ben-s].
|
1573 |
-
*
|
1574 |
-
* See: https://github.com/Wixel/GUMP/issues/5
|
1575 |
-
* Usage: '<index>' => 'valid_name'
|
1576 |
-
*
|
1577 |
-
* @param string $field
|
1578 |
-
* @param array $input
|
1579 |
-
*
|
1580 |
-
* @return mixed
|
1581 |
-
*/
|
1582 |
-
protected function validate_valid_name($field, $input, $param = null) {
|
1583 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1584 |
-
return;
|
1585 |
-
}
|
1586 |
-
|
1587 |
-
if (!preg_match("/^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïñðòóôõöùúûüýÿ '-])+$/i", $input[$field]) !== false) {
|
1588 |
-
return array(
|
1589 |
-
'field' => $field,
|
1590 |
-
'value' => $input[$field],
|
1591 |
-
'rule' => __FUNCTION__,
|
1592 |
-
'param' => $param,
|
1593 |
-
);
|
1594 |
-
}
|
1595 |
-
}
|
1596 |
-
|
1597 |
-
/**
|
1598 |
-
* Determine if the provided input is likely to be a street address using weak detection.
|
1599 |
-
*
|
1600 |
-
* Usage: '<index>' => 'street_address'
|
1601 |
-
*
|
1602 |
-
* @param string $field
|
1603 |
-
* @param array $input
|
1604 |
-
*
|
1605 |
-
* @return mixed
|
1606 |
-
*/
|
1607 |
-
protected function validate_street_address($field, $input, $param = null) {
|
1608 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1609 |
-
return;
|
1610 |
-
}
|
1611 |
-
|
1612 |
-
// Theory: 1 number, 1 or more spaces, 1 or more words
|
1613 |
-
$hasLetter = preg_match('/[a-zA-Z]/', $input[$field]);
|
1614 |
-
$hasDigit = preg_match('/\d/', $input[$field]);
|
1615 |
-
$hasSpace = preg_match('/\s/', $input[$field]);
|
1616 |
-
|
1617 |
-
$passes = $hasLetter && $hasDigit && $hasSpace;
|
1618 |
-
|
1619 |
-
if (!$passes) {
|
1620 |
-
return array(
|
1621 |
-
'field' => $field,
|
1622 |
-
'value' => $input[$field],
|
1623 |
-
'rule' => __FUNCTION__,
|
1624 |
-
'param' => $param,
|
1625 |
-
);
|
1626 |
-
}
|
1627 |
-
}
|
1628 |
-
|
1629 |
-
/**
|
1630 |
-
* Determine if the provided value is a valid IBAN.
|
1631 |
-
*
|
1632 |
-
* Usage: '<index>' => 'iban'
|
1633 |
-
*
|
1634 |
-
* @param string $field
|
1635 |
-
* @param array $input
|
1636 |
-
*
|
1637 |
-
* @return mixed
|
1638 |
-
*/
|
1639 |
-
protected function validate_iban($field, $input, $param = null) {
|
1640 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1641 |
-
return;
|
1642 |
-
}
|
1643 |
-
|
1644 |
-
static $character = array(
|
1645 |
-
'A' => 10, 'C' => 12, 'D' => 13, 'E' => 14, 'F' => 15, 'G' => 16,
|
1646 |
-
'H' => 17, 'I' => 18, 'J' => 19, 'K' => 20, 'L' => 21, 'M' => 22,
|
1647 |
-
'N' => 23, 'O' => 24, 'P' => 25, 'Q' => 26, 'R' => 27, 'S' => 28,
|
1648 |
-
'T' => 29, 'U' => 30, 'V' => 31, 'W' => 32, 'X' => 33, 'Y' => 34,
|
1649 |
-
'Z' => 35, 'B' => 11
|
1650 |
-
);
|
1651 |
-
|
1652 |
-
if (!preg_match("/\A[A-Z]{2}\d{2} ?[A-Z\d]{4}( ?\d{4}){1,} ?\d{1,4}\z/", $input[$field])) {
|
1653 |
-
return array(
|
1654 |
-
'field' => $field,
|
1655 |
-
'value' => $input[$field],
|
1656 |
-
'rule' => __FUNCTION__,
|
1657 |
-
'param' => $param,
|
1658 |
-
);
|
1659 |
-
}
|
1660 |
-
|
1661 |
-
$iban = str_replace(' ', '', $input[$field]);
|
1662 |
-
$iban = substr($iban, 4) . substr($iban, 0, 4);
|
1663 |
-
$iban = strtr($iban, $character);
|
1664 |
-
|
1665 |
-
if (bcmod($iban, 97) != 1) {
|
1666 |
-
return array(
|
1667 |
-
'field' => $field,
|
1668 |
-
'value' => $input[$field],
|
1669 |
-
'rule' => __FUNCTION__,
|
1670 |
-
'param' => $param,
|
1671 |
-
);
|
1672 |
-
}
|
1673 |
-
}
|
1674 |
-
|
1675 |
-
/**
|
1676 |
-
* Determine if the provided input is a valid date (ISO 8601).
|
1677 |
-
*
|
1678 |
-
* Usage: '<index>' => 'date'
|
1679 |
-
*
|
1680 |
-
* @param string $field
|
1681 |
-
* @param string $input date ('Y-m-d') or datetime ('Y-m-d H:i:s')
|
1682 |
-
* @param null $param
|
1683 |
-
*
|
1684 |
-
* @return mixed
|
1685 |
-
*/
|
1686 |
-
protected function validate_date($field, $input, $param = null) {
|
1687 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1688 |
-
return;
|
1689 |
-
}
|
1690 |
-
|
1691 |
-
$cdate1 = date('Y-m-d', strtotime($input[$field]));
|
1692 |
-
$cdate2 = date('Y-m-d H:i:s', strtotime($input[$field]));
|
1693 |
-
|
1694 |
-
if ($cdate1 != $input[$field] && $cdate2 != $input[$field]) {
|
1695 |
-
return array(
|
1696 |
-
'field' => $field,
|
1697 |
-
'value' => $input[$field],
|
1698 |
-
'rule' => __FUNCTION__,
|
1699 |
-
'param' => $param,
|
1700 |
-
);
|
1701 |
-
}
|
1702 |
-
}
|
1703 |
-
|
1704 |
-
/**
|
1705 |
-
* Determine if the provided input meets age requirement (ISO 8601).
|
1706 |
-
*
|
1707 |
-
* Usage: '<index>' => 'min_age,13'
|
1708 |
-
*
|
1709 |
-
* @param string $field
|
1710 |
-
* @param string $input date ('Y-m-d') or datetime ('Y-m-d H:i:s')
|
1711 |
-
* @param string $param int
|
1712 |
-
*
|
1713 |
-
* @return mixed
|
1714 |
-
*/
|
1715 |
-
protected function validate_min_age($field, $input, $param = null) {
|
1716 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1717 |
-
return;
|
1718 |
-
}
|
1719 |
-
|
1720 |
-
$cdate1 = new DateTime(date('Y-m-d', strtotime($input[$field])));
|
1721 |
-
$today = new DateTime(date('d-m-Y'));
|
1722 |
-
|
1723 |
-
$interval = $cdate1->diff($today);
|
1724 |
-
$age = $interval->y;
|
1725 |
-
|
1726 |
-
if ($age <= $param) {
|
1727 |
-
return array(
|
1728 |
-
'field' => $field,
|
1729 |
-
'value' => $input[$field],
|
1730 |
-
'rule' => __FUNCTION__,
|
1731 |
-
'param' => $param,
|
1732 |
-
);
|
1733 |
-
}
|
1734 |
-
}
|
1735 |
-
|
1736 |
-
/**
|
1737 |
-
* Determine if the provided numeric value is lower or equal to a specific value.
|
1738 |
-
*
|
1739 |
-
* Usage: '<index>' => 'max_numeric,50'
|
1740 |
-
*
|
1741 |
-
* @param string $field
|
1742 |
-
* @param array $input
|
1743 |
-
* @param null $param
|
1744 |
-
*
|
1745 |
-
* @return mixed
|
1746 |
-
*/
|
1747 |
-
protected function validate_max_numeric($field, $input, $param = null) {
|
1748 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1749 |
-
return;
|
1750 |
-
}
|
1751 |
-
|
1752 |
-
if (is_numeric($input[$field]) && is_numeric($param) && ($input[$field] <= $param)) {
|
1753 |
-
return;
|
1754 |
-
}
|
1755 |
-
|
1756 |
-
return array(
|
1757 |
-
'field' => $field,
|
1758 |
-
'value' => $input[$field],
|
1759 |
-
'rule' => __FUNCTION__,
|
1760 |
-
'param' => $param,
|
1761 |
-
);
|
1762 |
-
}
|
1763 |
-
|
1764 |
-
/**
|
1765 |
-
* Determine if the provided numeric value is higher or equal to a specific value.
|
1766 |
-
*
|
1767 |
-
* Usage: '<index>' => 'min_numeric,1'
|
1768 |
-
*
|
1769 |
-
* @param string $field
|
1770 |
-
* @param array $input
|
1771 |
-
* @param null $param
|
1772 |
-
*
|
1773 |
-
* @return mixed
|
1774 |
-
*/
|
1775 |
-
protected function validate_min_numeric($field, $input, $param = null) {
|
1776 |
-
if (!isset($input[$field])) {
|
1777 |
-
return;
|
1778 |
-
}
|
1779 |
-
|
1780 |
-
if (is_numeric($input[$field]) && is_numeric($param) && ($input[$field] >= $param)) {
|
1781 |
-
return;
|
1782 |
-
}
|
1783 |
-
|
1784 |
-
return array(
|
1785 |
-
'field' => $field,
|
1786 |
-
'value' => $input[$field],
|
1787 |
-
'rule' => __FUNCTION__,
|
1788 |
-
'param' => $param,
|
1789 |
-
);
|
1790 |
-
}
|
1791 |
-
|
1792 |
-
/**
|
1793 |
-
* Determine if the provided value starts with param.
|
1794 |
-
*
|
1795 |
-
* Usage: '<index>' => 'starts,Z'
|
1796 |
-
*
|
1797 |
-
* @param string $field
|
1798 |
-
* @param array $input
|
1799 |
-
*
|
1800 |
-
* @return mixed
|
1801 |
-
*/
|
1802 |
-
protected function validate_starts($field, $input, $param = null) {
|
1803 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1804 |
-
return;
|
1805 |
-
}
|
1806 |
-
|
1807 |
-
if (strpos($input[$field], $param) !== 0) {
|
1808 |
-
return array(
|
1809 |
-
'field' => $field,
|
1810 |
-
'value' => $input[$field],
|
1811 |
-
'rule' => __FUNCTION__,
|
1812 |
-
'param' => $param,
|
1813 |
-
);
|
1814 |
-
}
|
1815 |
-
}
|
1816 |
-
|
1817 |
-
/**
|
1818 |
-
* checks if a file was uploaded.
|
1819 |
-
*
|
1820 |
-
* Usage: '<index>' => 'required_file'
|
1821 |
-
*
|
1822 |
-
* @param string $field
|
1823 |
-
* @param array $input
|
1824 |
-
*
|
1825 |
-
* @return mixed
|
1826 |
-
*/
|
1827 |
-
protected function validate_required_file($field, $input, $param = null) {
|
1828 |
-
if ($input[$field]['error'] !== 4) {
|
1829 |
-
return;
|
1830 |
-
}
|
1831 |
-
|
1832 |
-
return array(
|
1833 |
-
'field' => $field,
|
1834 |
-
'value' => $input[$field],
|
1835 |
-
'rule' => __FUNCTION__,
|
1836 |
-
'param' => $param,
|
1837 |
-
);
|
1838 |
-
}
|
1839 |
-
|
1840 |
-
/**
|
1841 |
-
* check the uploaded file for extension
|
1842 |
-
* for now checks onlt the ext should add mime type check.
|
1843 |
-
*
|
1844 |
-
* Usage: '<index>' => 'starts,Z'
|
1845 |
-
*
|
1846 |
-
* @param string $field
|
1847 |
-
* @param array $input
|
1848 |
-
*
|
1849 |
-
* @return mixed
|
1850 |
-
*/
|
1851 |
-
protected function validate_extension($field, $input, $param = null) {
|
1852 |
-
if ($input[$field]['error'] !== 4) {
|
1853 |
-
$param = trim(strtolower($param));
|
1854 |
-
$allowed_extensions = explode(';', $param);
|
1855 |
-
|
1856 |
-
$path_info = pathinfo($input[$field]['name']);
|
1857 |
-
$extension = $path_info['extension'];
|
1858 |
-
|
1859 |
-
if (in_array($extension, $allowed_extensions)) {
|
1860 |
-
return;
|
1861 |
-
}
|
1862 |
-
|
1863 |
-
return array(
|
1864 |
-
'field' => $field,
|
1865 |
-
'value' => $input[$field],
|
1866 |
-
'rule' => __FUNCTION__,
|
1867 |
-
'param' => $param,
|
1868 |
-
);
|
1869 |
-
}
|
1870 |
-
}
|
1871 |
-
|
1872 |
-
/**
|
1873 |
-
* Determine if the provided field value equals current field value.
|
1874 |
-
*
|
1875 |
-
* Usage: '<index>' => 'equalsfield,Z'
|
1876 |
-
*
|
1877 |
-
* @param string $field
|
1878 |
-
* @param string $input
|
1879 |
-
* @param string $param field to compare with
|
1880 |
-
*
|
1881 |
-
* @return mixed
|
1882 |
-
*/
|
1883 |
-
protected function validate_equalsfield($field, $input, $param = null) {
|
1884 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1885 |
-
return;
|
1886 |
-
}
|
1887 |
-
|
1888 |
-
if ($input[$field] == $input[$param]) {
|
1889 |
-
return;
|
1890 |
-
}
|
1891 |
-
|
1892 |
-
return array(
|
1893 |
-
'field' => $field,
|
1894 |
-
'value' => $input[$field],
|
1895 |
-
'rule' => __FUNCTION__,
|
1896 |
-
'param' => $param,
|
1897 |
-
);
|
1898 |
-
}
|
1899 |
-
|
1900 |
-
/**
|
1901 |
-
* Determine if the provided field value is a valid GUID (v4)
|
1902 |
-
*
|
1903 |
-
* Usage: '<index>' => 'guidv4'
|
1904 |
-
*
|
1905 |
-
* @param string $field
|
1906 |
-
* @param string $input
|
1907 |
-
* @param string $param field to compare with
|
1908 |
-
*
|
1909 |
-
* @return mixed
|
1910 |
-
*/
|
1911 |
-
protected function validate_guidv4($field, $input, $param = null) {
|
1912 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1913 |
-
return;
|
1914 |
-
}
|
1915 |
-
|
1916 |
-
if (preg_match("/\{?[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}\}?$/", $input[$field])) {
|
1917 |
-
return;
|
1918 |
-
}
|
1919 |
-
|
1920 |
-
return array(
|
1921 |
-
'field' => $field,
|
1922 |
-
'value' => $input[$field],
|
1923 |
-
'rule' => __FUNCTION__,
|
1924 |
-
'param' => $param,
|
1925 |
-
);
|
1926 |
-
}
|
1927 |
-
|
1928 |
-
/**
|
1929 |
-
* Trims whitespace only when the value is a scalar.
|
1930 |
-
*
|
1931 |
-
* @param mixed $value
|
1932 |
-
*
|
1933 |
-
* @return mixed
|
1934 |
-
*/
|
1935 |
-
private function trimScalar($value) {
|
1936 |
-
if (is_scalar($value)) {
|
1937 |
-
$value = trim($value);
|
1938 |
-
}
|
1939 |
-
|
1940 |
-
return $value;
|
1941 |
-
}
|
1942 |
-
|
1943 |
-
/**
|
1944 |
-
* Determine if the provided value is a valid phone number.
|
1945 |
-
*
|
1946 |
-
* Usage: '<index>' => 'phone_number'
|
1947 |
-
*
|
1948 |
-
* @param string $field
|
1949 |
-
* @param array $input
|
1950 |
-
*
|
1951 |
-
* @return mixed
|
1952 |
-
*
|
1953 |
-
* Examples:
|
1954 |
-
*
|
1955 |
-
* 555-555-5555: valid
|
1956 |
-
* 5555425555: valid
|
1957 |
-
* 555 555 5555: valid
|
1958 |
-
* 1(519) 555-4444: valid
|
1959 |
-
* 1 (519) 555-4422: valid
|
1960 |
-
* 1-555-555-5555: valid
|
1961 |
-
* 1-(555)-555-5555: valid
|
1962 |
-
*/
|
1963 |
-
protected function validate_phone_number($field, $input, $param = null) {
|
1964 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1965 |
-
return;
|
1966 |
-
}
|
1967 |
-
|
1968 |
-
$regex = '/^(\d[\s-]?)?[\(\[\s-]{0,2}?\d{3}[\)\]\s-]{0,2}?\d{3}[\s-]?\d{4}$/i';
|
1969 |
-
if (!preg_match($regex, $input[$field])) {
|
1970 |
-
return array(
|
1971 |
-
'field' => $field,
|
1972 |
-
'value' => $input[$field],
|
1973 |
-
'rule' => __FUNCTION__,
|
1974 |
-
'param' => $param,
|
1975 |
-
);
|
1976 |
-
}
|
1977 |
-
}
|
1978 |
-
|
1979 |
-
/**
|
1980 |
-
* Custom regex validator.
|
1981 |
-
*
|
1982 |
-
* Usage: '<index>' => 'regex&&&/regex/'
|
1983 |
-
*
|
1984 |
-
* @param string $field
|
1985 |
-
* @param array $input
|
1986 |
-
*
|
1987 |
-
* @return mixed
|
1988 |
-
*/
|
1989 |
-
protected function validate_regex($field, $input, $param = null) {
|
1990 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
1991 |
-
return;
|
1992 |
-
}
|
1993 |
-
|
1994 |
-
$regex = $param;
|
1995 |
-
if (!preg_match($regex, $input[$field])) {
|
1996 |
-
return array(
|
1997 |
-
'field' => $field,
|
1998 |
-
'value' => $input[$field],
|
1999 |
-
'rule' => __FUNCTION__,
|
2000 |
-
'param' => $param,
|
2001 |
-
);
|
2002 |
-
}
|
2003 |
-
}
|
2004 |
-
|
2005 |
-
/**
|
2006 |
-
* Json validatior.
|
2007 |
-
*
|
2008 |
-
* Usage: '<index>' => 'valid_json_string'
|
2009 |
-
*
|
2010 |
-
* @param string $field
|
2011 |
-
* @param array $input
|
2012 |
-
*
|
2013 |
-
* @return mixed
|
2014 |
-
*/
|
2015 |
-
protected function validate_valid_json_string($field, $input, $param = null) {
|
2016 |
-
if (!isset($input[$field]) || empty($input[$field])) {
|
2017 |
-
return;
|
2018 |
-
}
|
2019 |
-
|
2020 |
-
if (!is_string($input[$field]) || !is_object(json_decode($input[$field]))) {
|
2021 |
-
return array(
|
2022 |
-
'field' => $field,
|
2023 |
-
'value' => $input[$field],
|
2024 |
-
'rule' => __FUNCTION__,
|
2025 |
-
'param' => $param,
|
2026 |
-
);
|
2027 |
-
}
|
2028 |
-
}
|
2029 |
-
} // EOC
|
1 |
+
<?php
|
2 |
+
namespace mp_timetable\classes\libs;
|
3 |
+
/**
|
4 |
+
* GUMP - A fast, extensible PHP input validation class.
|
5 |
+
*
|
6 |
+
* @author Sean Nieuwoudt (http://twitter.com/SeanNieuwoudt)
|
7 |
+
* @copyright Copyright (c) 2015 wixelhq.com
|
8 |
+
*
|
9 |
+
* @link http://github.com/Wixel/GUMP
|
10 |
+
*
|
11 |
+
* @version 1.0
|
12 |
+
*/
|
13 |
+
class GUMP {
|
14 |
+
// Validation rules for execution
|
15 |
+
protected $validation_rules = array();
|
16 |
+
|
17 |
+
// Filter rules for execution
|
18 |
+
protected $filter_rules = array();
|
19 |
+
|
20 |
+
// Instance attribute containing errors from last run
|
21 |
+
protected $errors = array();
|
22 |
+
|
23 |
+
// Contain readable field names that have been set manually
|
24 |
+
protected static $fields = array();
|
25 |
+
|
26 |
+
// Custom validation methods
|
27 |
+
protected static $validation_methods = array();
|
28 |
+
|
29 |
+
// Customer filter methods
|
30 |
+
protected static $filter_methods = array();
|
31 |
+
|
32 |
+
// ** ------------------------- Validation Data ------------------------------- ** //
|
33 |
+
|
34 |
+
public static $basic_tags = '<br><p><a><strong><b><i><em><img><blockquote><code><dd><dl><hr><h1><h2><h3><h4><h5><h6><label><ul><li><span><sub><sup>';
|
35 |
+
|
36 |
+
public static $en_noise_words = "about,after,all,also,an,and,another,any,are,as,at,be,because,been,before,
|
37 |
+
being,between,both,but,by,came,can,come,could,did,do,each,for,from,get,
|
38 |
+
got,has,had,he,have,her,here,him,himself,his,how,if,in,into,is,it,its,it's,like,
|
39 |
+
make,many,me,might,more,most,much,must,my,never,now,of,on,only,or,other,
|
40 |
+
our,out,over,said,same,see,should,since,some,still,such,take,than,that,
|
41 |
+
the,their,them,then,there,these,they,this,those,through,to,too,under,up,
|
42 |
+
very,was,way,we,well,were,what,where,which,while,who,with,would,you,your,a,
|
43 |
+
b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,$,1,2,3,4,5,6,7,8,9,0,_";
|
44 |
+
|
45 |
+
// field characters below will be replaced with a space.
|
46 |
+
protected $fieldCharsToRemove = array('_', '-');
|
47 |
+
|
48 |
+
// ** ------------------------- Validation Helpers ---------------------------- ** //
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Shorthand method for inline validation.
|
52 |
+
*
|
53 |
+
* @param array $data The data to be validated
|
54 |
+
* @param array $validators The GUMP validators
|
55 |
+
*
|
56 |
+
* @return mixed True(boolean) or the array of error messages
|
57 |
+
*/
|
58 |
+
public static function is_valid(array $data, array $validators) {
|
59 |
+
$gump = new self();
|
60 |
+
|
61 |
+
$gump->validation_rules($validators);
|
62 |
+
|
63 |
+
if ($gump->run($data) === false) {
|
64 |
+
return $gump->get_readable_errors(false);
|
65 |
+
} else {
|
66 |
+
return true;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Shorthand method for running only the data filters.
|
72 |
+
*
|
73 |
+
* @param array $data
|
74 |
+
* @param array $filters
|
75 |
+
*
|
76 |
+
* @return mixed
|
77 |
+
*/
|
78 |
+
public static function filter_input(array $data, array $filters) {
|
79 |
+
$gump = new self();
|
80 |
+
|
81 |
+
return $gump->filter($data, $filters);
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Magic method to generate the validation error messages.
|
86 |
+
*
|
87 |
+
* @return string
|
88 |
+
*/
|
89 |
+
public function __toString() {
|
90 |
+
return $this->get_readable_errors(true);
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Perform XSS clean to prevent cross site scripting.
|
95 |
+
*
|
96 |
+
* @static
|
97 |
+
*
|
98 |
+
* @param array $data
|
99 |
+
*
|
100 |
+
* @return array
|
101 |
+
*/
|
102 |
+
public static function xss_clean(array $data) {
|
103 |
+
foreach ($data as $k => $v) {
|
104 |
+
$data[$k] = filter_var($v, FILTER_SANITIZE_STRING);
|
105 |
+
}
|
106 |
+
|
107 |
+
return $data;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Adds a custom validation rule using a callback function.
|
112 |
+
*
|
113 |
+
* @param string $rule
|
114 |
+
* @param callable $callback
|
115 |
+
*
|
116 |
+
* @return bool
|
117 |
+
*
|
118 |
+
* @throws Exception
|
119 |
+
*/
|
120 |
+
public static function add_validator($rule, $callback) {
|
121 |
+
$method = 'validate_' . $rule;
|
122 |
+
|
123 |
+
if (method_exists(__CLASS__, $method) || isset(self::$validation_methods[$rule])) {
|
124 |
+
throw new Exception("Validator rule '$rule' already exists.");
|
125 |
+
}
|
126 |
+
|
127 |
+
self::$validation_methods[$rule] = $callback;
|
128 |
+
|
129 |
+
return true;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Adds a custom filter using a callback function.
|
134 |
+
*
|
135 |
+
* @param string $rule
|
136 |
+
* @param callable $callback
|
137 |
+
*
|
138 |
+
* @return bool
|
139 |
+
*
|
140 |
+
* @throws Exception
|
141 |
+
*/
|
142 |
+
public static function add_filter($rule, $callback) {
|
143 |
+
$method = 'filter_' . $rule;
|
144 |
+
|
145 |
+
if (method_exists(__CLASS__, $method) || isset(self::$filter_methods[$rule])) {
|
146 |
+
throw new Exception("Filter rule '$rule' already exists.");
|
147 |
+
}
|
148 |
+
|
149 |
+
self::$filter_methods[$rule] = $callback;
|
150 |
+
|
151 |
+
return true;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Helper method to extract an element from an array safely
|
156 |
+
*
|
157 |
+
* @param mixed $key
|
158 |
+
* @param array $array
|
159 |
+
* @param mixed $default
|
160 |
+
*
|
161 |
+
* @return mixed
|
162 |
+
*/
|
163 |
+
public static function field($key, array $array, $default = null) {
|
164 |
+
if (!is_array($array)) {
|
165 |
+
return null;
|
166 |
+
}
|
167 |
+
|
168 |
+
if (isset($array[$key])) {
|
169 |
+
return $array[$key];
|
170 |
+
} else {
|
171 |
+
return $default;
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Getter/Setter for the validation rules.
|
177 |
+
*
|
178 |
+
* @param array $rules
|
179 |
+
*
|
180 |
+
* @return array
|
181 |
+
*/
|
182 |
+
public function validation_rules(array $rules = array()) {
|
183 |
+
if (empty($rules)) {
|
184 |
+
return $this->validation_rules;
|
185 |
+
}
|
186 |
+
|
187 |
+
$this->validation_rules = $rules;
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Getter/Setter for the filter rules.
|
192 |
+
*
|
193 |
+
* @param array $rules
|
194 |
+
*
|
195 |
+
* @return array
|
196 |
+
*/
|
197 |
+
public function filter_rules(array $rules = array()) {
|
198 |
+
if (empty($rules)) {
|
199 |
+
return $this->filter_rules;
|
200 |
+
}
|
201 |
+
|
202 |
+
$this->filter_rules = $rules;
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Run the filtering and validation after each other.
|
207 |
+
*
|
208 |
+
* @param array $data
|
209 |
+
* @param bool $check_fields
|
210 |
+
*
|
211 |
+
* @return array
|
212 |
+
*
|
213 |
+
* @throws Exception
|
214 |
+
*/
|
215 |
+
public function run(array $data, $check_fields = false) {
|
216 |
+
$data = $this->filter($data, $this->filter_rules());
|
217 |
+
|
218 |
+
$validated = $this->validate(
|
219 |
+
$data, $this->validation_rules()
|
220 |
+
);
|
221 |
+
|
222 |
+
if ($check_fields === true) {
|
223 |
+
$this->check_fields($data);
|
224 |
+
}
|
225 |
+
|
226 |
+
if ($validated !== true) {
|
227 |
+
return false;
|
228 |
+
}
|
229 |
+
|
230 |
+
return $data;
|
231 |
+
}
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Ensure that the field counts match the validation rule counts.
|
235 |
+
*
|
236 |
+
* @param array $data
|
237 |
+
*/
|
238 |
+
private function check_fields(array $data) {
|
239 |
+
$ruleset = $this->validation_rules();
|
240 |
+
$mismatch = array_diff_key($data, $ruleset);
|
241 |
+
$fields = array_keys($mismatch);
|
242 |
+
|
243 |
+
foreach ($fields as $field) {
|
244 |
+
$this->errors[] = array(
|
245 |
+
'field' => $field,
|
246 |
+
'value' => $data[$field],
|
247 |
+
'rule' => 'mismatch',
|
248 |
+
'param' => null,
|
249 |
+
);
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* Sanitize the input data.
|
255 |
+
*
|
256 |
+
* @param array $input
|
257 |
+
* @param null $fields
|
258 |
+
* @param bool $utf8_encode
|
259 |
+
*
|
260 |
+
* @return array
|
261 |
+
*/
|
262 |
+
public function sanitize(array $input, array $fields = array(), $utf8_encode = true) {
|
263 |
+
$magic_quotes = (bool)get_magic_quotes_gpc();
|
264 |
+
|
265 |
+
if (empty($fields)) {
|
266 |
+
$fields = array_keys($input);
|
267 |
+
}
|
268 |
+
|
269 |
+
$return = array();
|
270 |
+
|
271 |
+
foreach ($fields as $field) {
|
272 |
+
if (!isset($input[$field])) {
|
273 |
+
continue;
|
274 |
+
} else {
|
275 |
+
$value = $input[$field];
|
276 |
+
if (is_array($value)) {
|
277 |
+
$value = null;
|
278 |
+
}
|
279 |
+
if (is_string($value)) {
|
280 |
+
if ($magic_quotes === true) {
|
281 |
+
$value = stripslashes($value);
|
282 |
+
}
|
283 |
+
|
284 |
+
if (strpos($value, "\r") !== false) {
|
285 |
+
$value = trim($value);
|
286 |
+
}
|
287 |
+
|
288 |
+
if (function_exists('iconv') && function_exists('mb_detect_encoding') && $utf8_encode) {
|
289 |
+
$current_encoding = mb_detect_encoding($value);
|
290 |
+
|
291 |
+
if ($current_encoding != 'UTF-8' && $current_encoding != 'UTF-16') {
|
292 |
+
$value = iconv($current_encoding, 'UTF-8', $value);
|
293 |
+
}
|
294 |
+
}
|
295 |
+
|
296 |
+
$value = filter_var($value, FILTER_SANITIZE_STRING);
|
297 |
+
}
|
298 |
+
|
299 |
+
$return[$field] = $value;
|
300 |
+
}
|
301 |
+
}
|
302 |
+
|
303 |
+
return $return;
|
304 |
+
}
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Return the error array from the last validation run.
|
308 |
+
*
|
309 |
+
* @return array
|
310 |
+
*/
|
311 |
+
public function errors() {
|
312 |
+
return $this->errors;
|
313 |
+
}
|
314 |
+
|
315 |
+
/**
|
316 |
+
* Perform data validation against the provided ruleset.
|
317 |
+
*
|
318 |
+
* @param mixed $input
|
319 |
+
* @param array $ruleset
|
320 |
+
*
|
321 |
+
* @return mixed
|
322 |
+
*
|
323 |
+
* @throws Exception
|
324 |
+
*/
|
325 |
+
public function validate(array $input, array $ruleset) {
|
326 |
+
$this->errors = array();
|
327 |
+
|
328 |
+
foreach ($ruleset as $field => $rules) {
|
329 |
+
|
330 |
+
$rules = explode('|', $rules);
|
331 |
+
|
332 |
+
if (in_array('required', $rules) || (isset($input[$field]) && !is_array($input[$field]))) {
|
333 |
+
foreach ($rules as $rule) {
|
334 |
+
$method = null;
|
335 |
+
$param = null;
|
336 |
+
|
337 |
+
// Check if we have rule parameters
|
338 |
+
if (strstr($rule, ',') !== false) {
|
339 |
+
$rule = explode(',', $rule);
|
340 |
+
$method = 'validate_' . $rule[0];
|
341 |
+
$param = $rule[1];
|
342 |
+
$rule = $rule[0];
|
343 |
+
} else {
|
344 |
+
$method = 'validate_' . $rule;
|
345 |
+
}
|
346 |
+
|
347 |
+
//self::$validation_methods[$rule] = $callback;
|
348 |
+
|
349 |
+
if (is_callable(array($this, $method))) {
|
350 |
+
$result = $this->$method(
|
351 |
+
$field, $input, $param
|
352 |
+
);
|
353 |
+
|
354 |
+
if (is_array($result)) {
|
355 |
+
$this->errors[] = $result;
|
356 |
+
}
|
357 |
+
} elseif (isset(self::$validation_methods[$rule])) {
|
358 |
+
|
359 |
+
$result = call_user_func(self::$validation_methods[$rule], $field, $input, $param);
|
360 |
+
|
361 |
+
if ($result === false) {
|
362 |
+
$this->errors[] = array(
|
363 |
+
'field' => $field,
|
364 |
+
'value' => $input,
|
365 |
+
'rule' => self::$validation_methods[$rule],
|
366 |
+
'param' => $param,
|
367 |
+
);
|
368 |
+
}
|
369 |
+
|
370 |
+
} else {
|
371 |
+
throw new Exception("Validator method '$method' does not exist.");
|
372 |
+
}
|
373 |
+
}
|
374 |
+
}
|
375 |
+
}
|
376 |
+
|
377 |
+
return (count($this->errors) > 0) ? $this->errors : true;
|
378 |
+
}
|
379 |
+
|
380 |
+
/**
|
381 |
+
* Overloadable method to invoke validation.
|
382 |
+
*
|
383 |
+
* @param array $input
|
384 |
+
* @param $rules
|
385 |
+
* @param $field
|
386 |
+
*
|
387 |
+
* @return bool
|
388 |
+
*/
|
389 |
+
protected function shouldRunValidation(array $input, $rules, $field) {
|
390 |
+
return in_array('required', $rules) || (isset($input[$field]) && trim($input[$field]) != '');
|
391 |
+
}
|
392 |
+
|
393 |
+
/**
|
394 |
+
* Set a readable name for a specified field names.
|
395 |
+
*
|
396 |
+
* @param string $field
|
397 |
+
* @param string $readable_name
|
398 |
+
*/
|
399 |
+
public static function set_field_name($field, $readable_name) {
|
400 |
+
self::$fields[$field] = $readable_name;
|
401 |
+
}
|
402 |
+
|
403 |
+
/**
|
404 |
+
* Set readable name for specified fields in an array.
|
405 |
+
*
|
406 |
+
* Usage:
|
407 |
+
*
|
408 |
+
* GUMP::set_field_names(array(
|
409 |
+
* "name" => "My Lovely Name",
|
410 |
+
* "username" => "My Beloved Username",
|
411 |
+
* ));
|
412 |
+
*
|
413 |
+
* @param array $array
|
414 |
+
*/
|
415 |
+
public static function set_field_names(array $array) {
|
416 |
+
foreach ($array as $field => $readable_name) {
|
417 |
+
self::$fields[$field] = $readable_name;
|
418 |
+
}
|
419 |
+
}
|
420 |
+
|
421 |
+
/**
|
422 |
+
* Process the validation errors and return human readable error messages.
|
423 |
+
*
|
424 |
+
* @param bool $convert_to_string = false
|
425 |
+
* @param string $field_class
|
426 |
+
* @param string $error_class
|
427 |
+
*
|
428 |
+
* @return array
|
429 |
+
* @return string
|
430 |
+
*/
|
431 |
+
public function get_readable_errors($convert_to_string = false, $field_class = 'gump-field', $error_class = 'gump-error-message') {
|
432 |
+
if (empty($this->errors)) {
|
433 |
+
return ($convert_to_string) ? null : array();
|
434 |
+
}
|
435 |
+
|
436 |
+
$resp = array();
|
437 |
+
|
438 |
+
foreach ($this->errors as $e) {
|
439 |
+
$field = ucwords(str_replace($this->fieldCharsToRemove, chr(32), $e['field']));
|
440 |
+
$param = $e['param'];
|
441 |
+
|
442 |
+
// Let's fetch explicit field names if they exist
|
443 |
+
if (array_key_exists($e['field'], self::$fields)) {
|
444 |
+
$field = self::$fields[$e['field']];
|
445 |
+
}
|
446 |
+
|
447 |
+
|
448 |
+
switch ($e['rule']) {
|
449 |
+
case 'mismatch' :
|
450 |
+
$resp[] = sprintf( 'There is no validation rule for <span class="%1$s">%2$s</span>', $field_class, $field );
|
451 |
+
break;
|
452 |
+
case 'validate_required' :
|
453 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field is required', $field_class, $field );
|
454 |
+
break;
|
455 |
+
case 'validate_valid_email':
|
456 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field is required to be a valid email address', $field_class, $field );
|
457 |
+
break;
|
458 |
+
case 'validate_max_len':
|
459 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to be %d or shorter in length', $field_class, $field, $param );
|
460 |
+
break;
|
461 |
+
case 'validate_min_len':
|
462 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to be %d or longer in length', $field_class, $field, $param );
|
463 |
+
break;
|
464 |
+
case 'validate_exact_len':
|
465 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to be exactly %d characters in length', $field_class, $field, $param );
|
466 |
+
break;
|
467 |
+
case 'validate_alpha':
|
468 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field may only contain alpha characters(a-z)', $field_class, $field );
|
469 |
+
break;
|
470 |
+
case 'validate_alpha_numeric':
|
471 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field may only contain alpha-numeric characters', $field_class, $field );
|
472 |
+
break;
|
473 |
+
case 'validate_alpha_dash':
|
474 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field may only contain alpha characters & dashes', $field_class, $field );
|
475 |
+
break;
|
476 |
+
case 'validate_numeric':
|
477 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field may only contain numeric characters', $field_class, $field );
|
478 |
+
break;
|
479 |
+
case 'validate_integer':
|
480 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field may only contain a numeric value', $field_class, $field );
|
481 |
+
break;
|
482 |
+
case 'validate_boolean':
|
483 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field may only contain a true or false value', $field_class, $field );
|
484 |
+
break;
|
485 |
+
case 'validate_float':
|
486 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field may only contain a float value', $field_class, $field );
|
487 |
+
break;
|
488 |
+
case 'validate_valid_url':
|
489 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field is required to be a valid URL', $field_class, $field );
|
490 |
+
break;
|
491 |
+
case 'validate_url_exists':
|
492 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> URL does not exist', $field_class, $field );
|
493 |
+
break;
|
494 |
+
case 'validate_valid_ip':
|
495 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to contain a valid IP address', $field_class, $field );
|
496 |
+
break;
|
497 |
+
case 'validate_valid_cc':
|
498 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to contain a valid credit card number', $field_class, $field );
|
499 |
+
break;
|
500 |
+
case 'validate_valid_name':
|
501 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to contain a valid human name', $field_class, $field );
|
502 |
+
break;
|
503 |
+
case 'validate_contains':
|
504 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to contain one of these values:', $field_class, $field ) . ' ' . implode(', ', $param);
|
505 |
+
break;
|
506 |
+
case 'validate_contains_list':
|
507 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs contain a value from its drop down list', $field_class, $field );
|
508 |
+
break;
|
509 |
+
case 'validate_doesnt_contain_list':
|
510 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field contains a value that is not accepted', $field_class, $field );
|
511 |
+
break;
|
512 |
+
case 'validate_street_address':
|
513 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to be a valid street address', $field_class, $field );
|
514 |
+
break;
|
515 |
+
case 'validate_date':
|
516 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to be a valid date', $field_class, $field );
|
517 |
+
break;
|
518 |
+
case 'validate_min_numeric':
|
519 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to be a numeric value, equal to, or higher than', $field_class, $field ) . $param;
|
520 |
+
break;
|
521 |
+
case 'validate_max_numeric':
|
522 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to be a numeric value, equal to, or lower than', $field_class, $field ) . ' ' . $param;
|
523 |
+
break;
|
524 |
+
case 'validate_starts':
|
525 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to start with', $field_class, $field ) . ' ' . $param;
|
526 |
+
break;
|
527 |
+
case 'validate_extension':
|
528 |
+
$resp[] = sprintf( 'The <span class"%1$s">%2$s</span> field can have the following extensions', $field_class, $field ) . ' '. $param;
|
529 |
+
break;
|
530 |
+
case 'validate_required_file':
|
531 |
+
$resp[] = sprintf( 'The <span class"%1$s">%2$s</span> field is required', $field_class, $field ) .' ' . $param;
|
532 |
+
break;
|
533 |
+
case 'validate_equalsfield':
|
534 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field does not equal %d field', $field_class, $field, $param ) ;
|
535 |
+
break;
|
536 |
+
case 'validate_min_age':
|
537 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field needs to have an age greater than or equal to', $field_class, $field ) . ' '. $param;;
|
538 |
+
break;
|
539 |
+
default:
|
540 |
+
$resp[] = sprintf( 'The <span class="%1$s">%2$s</span> field is invalid', $field_class, $field );
|
541 |
+
}
|
542 |
+
}
|
543 |
+
|
544 |
+
if (!$convert_to_string) {
|
545 |
+
return $resp;
|
546 |
+
} else {
|
547 |
+
$buffer = '';
|
548 |
+
foreach ($resp as $s) {
|
549 |
+
$buffer .= "<span class=\"$error_class\">$s</span>";
|
550 |
+
}
|
551 |
+
|
552 |
+
return $buffer;
|
553 |
+
}
|
554 |
+
}
|
555 |
+
|
556 |
+
/**
|
557 |
+
* Process the validation errors and return an array of errors with field names as keys.
|
558 |
+
*
|
559 |
+
* @param $convert_to_string
|
560 |
+
*
|
561 |
+
* @return array | null (if empty)
|
562 |
+
*/
|
563 |
+
public function get_errors_array($convert_to_string = null) {
|
564 |
+
if (empty($this->errors)) {
|
565 |
+
return ($convert_to_string) ? null : array();
|
566 |
+
}
|
567 |
+
|
568 |
+
$resp = array();
|
569 |
+
|
570 |
+
foreach ($this->errors as $e) {
|
571 |
+
$field = ucwords(str_replace(array('_', '-'), chr(32), $e['field']));
|
572 |
+
$param = $e['param'];
|
573 |
+
|
574 |
+
// Let's fetch explicit field names if they exist
|
575 |
+
if (array_key_exists($e['field'], self::$fields)) {
|
576 |
+
$field = self::$fields[$e['field']];
|
577 |
+
}
|
578 |
+
|
579 |
+
switch ($e['rule']) {
|
580 |
+
case 'mismatch' :
|
581 |
+
$resp[$field] = 'There is no validation rule for' . ' ' . $field;
|
582 |
+
break;
|
583 |
+
case 'validate_required':
|
584 |
+
$resp[$field] = sprintf( 'The %s field is required', $field);
|
585 |
+
break;
|
586 |
+
case 'validate_valid_email':
|
587 |
+
$resp[$field] = sprintf( 'The %s field is required to be a valid email address', $field);
|
588 |
+
break;
|
589 |
+
case 'validate_max_len':
|
590 |
+
$resp[$field] = sprintf( 'The %s field needs to be %d or shorter in length', $field, $param);
|
591 |
+
break;
|
592 |
+
case 'validate_min_len':
|
593 |
+
$resp[$field] = sprintf( 'The %s field needs to be %d or longer in length', $field, $param);
|
594 |
+
break;
|
595 |
+
case 'validate_exact_len':
|
596 |
+
$resp[$field] = sprintf( 'The %s field needs to be exactly %d characters in length', $field, $param);
|
597 |
+
break;
|
598 |
+
case 'validate_alpha':
|
599 |
+
$resp[$field] = sprintf( 'The %s field may only contain alpha characters(a-z)', $field);
|
600 |
+
break;
|
601 |
+
case 'validate_alpha_numeric':
|
602 |
+
$resp[$field] = sprintf( 'The %s field may only contain alpha-numeric characters', $field);
|
603 |
+
break;
|
604 |
+
case 'validate_alpha_dash':
|
605 |
+
$resp[$field] = sprintf( 'The %s field may only contain alpha characters & dashes', $field);
|
606 |
+
break;
|
607 |
+
case 'validate_numeric':
|
608 |
+
$resp[$field] = sprintf( 'The %s field may only contain numeric characters', $field);
|
609 |
+
break;
|
610 |
+
case 'validate_integer':
|
611 |
+
$resp[$field] = sprintf( 'The %s field may only contain a numeric value', $field);
|
612 |
+
break;
|
613 |
+
case 'validate_boolean':
|
614 |
+
$resp[$field] = sprintf( 'The %s field may only contain a true or false value', $field);
|
615 |
+
break;
|
616 |
+
case 'validate_float':
|
617 |
+
$resp[$field] = sprintf( 'The %s field may only contain a float value', $field);
|
618 |
+
break;
|
619 |
+
case 'validate_valid_url':
|
620 |
+
$resp[$field] = sprintf( 'The %s field is required to be a valid URL', $field);
|
621 |
+
break;
|
622 |
+
case 'validate_url_exists':
|
623 |
+
$resp[$field] = sprintf( 'The %s URL does not exist', $field);
|
624 |
+
break;
|
625 |
+
case 'validate_valid_ip':
|
626 |
+
$resp[$field] = sprintf( 'The %s field needs to contain a valid IP address', $field);
|
627 |
+
break;
|
628 |
+
case 'validate_valid_cc':
|
629 |
+
$resp[$field] = sprintf( 'The %s field needs to contain a valid credit card number', $field);
|
630 |
+
break;
|
631 |
+
case 'validate_valid_name':
|
632 |
+
$resp[$field] = sprintf( 'The %s field needs to contain a valid human name', $field);
|
633 |
+
break;
|
634 |
+
case 'validate_contains':
|
635 |
+
$resp[$field] = sprintf( 'The %s field needs to contain one of these values:', $field) . ' ' . implode(', ', $param);
|
636 |
+
break;
|
637 |
+
case 'validate_street_address':
|
638 |
+
$resp[$field] = sprintf( 'The %s field needs to be a valid street address', $field);
|
639 |
+
break;
|
640 |
+
case 'validate_date':
|
641 |
+
$resp[$field] = sprintf( 'The %s field needs to be a valid date', $field);
|
642 |
+
break;
|
643 |
+
case 'validate_min_numeric':
|
644 |
+
$resp[$field] = sprintf( 'The %s field needs to be a numeric value, equal to, or higher than %d', $field, $param);
|
645 |
+
break;
|
646 |
+
case 'validate_max_numeric':
|
647 |
+
$resp[$field] = sprintf( 'The %s field needs to be a numeric value, equal to, or lower than %d', $field, $param);
|
648 |
+
break;
|
649 |
+
case 'validate_min_age':
|
650 |
+
$resp[$field] = sprintf( 'The %s field needs to have an age greater than or equal to %d', $field, $param);
|
651 |
+
break;
|
652 |
+
default:
|
653 |
+
$resp[$field] = sprintf( 'The %s field is invalid', $field );
|
654 |
+
}
|
655 |
+
}
|
656 |
+
|
657 |
+
return $resp;
|
658 |
+
}
|
659 |
+
|
660 |
+
|
661 |
+
/**
|
662 |
+
* Filter the input data according to the specified filter set.
|
663 |
+
*
|
664 |
+
* @param mixed $input
|
665 |
+
* @param array $filterset
|
666 |
+
*
|
667 |
+
* @throws Exception
|
668 |
+
*
|
669 |
+
* @return mixed
|
670 |
+
*
|
671 |
+
* @throws Exception
|
672 |
+
*/
|
673 |
+
public function filter(array $input, array $filterset) {
|
674 |
+
foreach ($filterset as $field => $filters) {
|
675 |
+
if (!array_key_exists($field, $input)) {
|
676 |
+
continue;
|
677 |
+
}
|
678 |
+
|
679 |
+
$filters = explode('|', $filters);
|
680 |
+
|
681 |
+
foreach ($filters as $filter) {
|
682 |
+
$params = null;
|
683 |
+
|
684 |
+
if (strstr($filter, ',') !== false) {
|
685 |
+
$filter = explode(',', $filter);
|
686 |
+
|
687 |
+
$params = array_slice($filter, 1, count($filter) - 1);
|
688 |
+
|
689 |
+
$filter = $filter[0];
|
690 |
+
}
|
691 |
+
|
692 |
+
if (is_callable(array($this, 'filter_' . $filter))) {
|
693 |
+
$method = 'filter_' . $filter;
|
694 |
+
$input[$field] = $this->$method($input[$field], $params);
|
695 |
+
} elseif (function_exists($filter)) {
|
696 |
+
$input[$field] = $filter($input[$field]);
|
697 |
+
} elseif (isset(self::$filter_methods[$filter])) {
|
698 |
+
$input[$field] = call_user_func(self::$filter_methods[$filter], $input[$field], $params);
|
699 |
+
} else {
|
700 |
+
throw new Exception("Filter method '$filter' does not exist.");
|
701 |
+
}
|
702 |
+
}
|
703 |
+
}
|
704 |
+
|
705 |
+
return $input;
|
706 |
+
}
|
707 |
+
|
708 |
+
// ** ------------------------- Filters --------------------------------------- ** //
|
709 |
+
|
710 |
+
/**
|
711 |
+
* Replace noise words in a string (http://tax.cchgroup.com/help/Avoiding_noise_words_in_your_search.htm).
|
712 |
+
*
|
713 |
+
* Usage: '<index>' => 'noise_words'
|
714 |
+
*
|
715 |
+
* @param string $value
|
716 |
+
* @param array $params
|
717 |
+
*
|
718 |
+
* @return string
|
719 |
+
*/
|
720 |
+
protected function filter_noise_words($value, $params = null) {
|
721 |
+
$value = preg_replace('/\s\s+/u', chr(32), $value);
|
722 |
+
|
723 |
+
$value = " $value ";
|
724 |
+
|
725 |
+
$words = explode(',', self::$en_noise_words);
|
726 |
+
|
727 |
+
foreach ($words as $word) {
|
728 |
+
$word = trim($word);
|
729 |
+
|
730 |
+
$word = " $word "; // Normalize
|
731 |
+
|
732 |
+
if (stripos($value, $word) !== false) {
|
733 |
+
$value = str_ireplace($word, chr(32), $value);
|
734 |
+
}
|
735 |
+
}
|
736 |
+
|
737 |
+
return trim($value);
|
738 |
+
}
|
739 |
+
|
740 |
+
/**
|
741 |
+
* Remove all known punctuation from a string.
|
742 |
+
*
|
743 |
+
* Usage: '<index>' => 'rmpunctuataion'
|
744 |
+
*
|
745 |
+
* @param string $value
|
746 |
+
* @param array $params
|
747 |
+
*
|
748 |
+
* @return string
|
749 |
+
*/
|
750 |
+
protected function filter_rmpunctuation($value, $params = null) {
|
751 |
+
return preg_replace("/(?![.=$'€%-])\p{P}/u", '', $value);
|
752 |
+
}
|
753 |
+
|
754 |
+
/**
|
755 |
+
* Translate an input string to a desired language [DEPRECIATED].
|
756 |
+
*
|
757 |
+
* Any ISO 639-1 2 character language code may be used
|
758 |
+
*
|
759 |
+
* See: http://www.science.co.il/language/Codes.asp?s=code2
|
760 |
+
*
|
761 |
+
* @param string $value
|
762 |
+
* @param array $params
|
763 |
+
*
|
764 |
+
* @return string
|
765 |
+
*/
|
766 |
+
/*
|
767 |
+
protected function filter_translate($value, $params = NULL)
|
768 |
+
{
|
769 |
+
$input_lang = 'en';
|
770 |
+
$output_lang = 'en';
|
771 |
+
|
772 |
+
if(is_null($params))
|
773 |
+
{
|
774 |
+
return $value;
|
775 |
+
}
|
776 |
+
|
777 |
+
switch(count($params))
|
778 |
+
{
|
779 |
+
case 1:
|
780 |
+
$input_lang = $params[0];
|
781 |
+
break;
|
782 |
+
case 2:
|
783 |
+
$input_lang = $params[0];
|
784 |
+
$output_lang = $params[1];
|
785 |
+
break;
|
786 |
+
}
|
787 |
+
|
788 |
+
$text = urlencode($value);
|
789 |
+
|
790 |
+
$translation = file_get_contents(
|
791 |
+
"http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q={$text}&langpair={$input_lang}|{$output_lang}"
|
792 |
+
);
|
793 |
+
|
794 |
+
$json = json_decode($translation, true);
|
795 |
+
|
796 |
+
if($json['responseStatus'] != 200)
|
797 |
+
{
|
798 |
+
return $value;
|
799 |
+
}
|
800 |
+
else
|
801 |
+
{
|
802 |
+
return $json['responseData']['translatedText'];
|
803 |
+
}
|
804 |
+
}
|
805 |
+
*/
|
806 |
+
|
807 |
+
/**
|
808 |
+
* Sanitize the string by removing any script tags.
|
809 |
+
*
|
810 |
+
* Usage: '<index>' => 'sanitize_string'
|
811 |
+
*
|
812 |
+
* @param string $value
|
813 |
+
* @param array $params
|
814 |
+
*
|
815 |
+
* @return string
|
816 |
+
*/
|
817 |
+
protected function filter_sanitize_string($value, $params = null) {
|
818 |
+
return filter_var($value, FILTER_SANITIZE_STRING);
|
819 |
+
}
|
820 |
+
|
821 |
+
/**
|
822 |
+
* Sanitize the string by urlencoding characters.
|
823 |
+
*
|
824 |
+
* Usage: '<index>' => 'urlencode'
|
825 |
+
*
|
826 |
+
* @param string $value
|
827 |
+
* @param array $params
|
828 |
+
*
|
829 |
+
* @return string
|
830 |
+
*/
|
831 |
+
protected function filter_urlencode($value, $params = null) {
|
832 |
+
return filter_var($value, FILTER_SANITIZE_ENCODED);
|
833 |
+
}
|
834 |
+
|
835 |
+
/**
|
836 |
+
* Sanitize the string by converting HTML characters to their HTML entities.
|
837 |
+
*
|
838 |
+
* Usage: '<index>' => 'htmlencode'
|
839 |
+
*
|
840 |
+
* @param string $value
|
841 |
+
* @param array $params
|
842 |
+
*
|
843 |
+
* @return string
|
844 |
+
*/
|
845 |
+
protected function filter_htmlencode($value, $params = null) {
|
846 |
+
return filter_var($value, FILTER_SANITIZE_SPECIAL_CHARS);
|
847 |
+
}
|
848 |
+
|
849 |
+
/**
|
850 |
+
* Sanitize the string by removing illegal characters from emails.
|
851 |
+
*
|
852 |
+
* Usage: '<index>' => 'sanitize_email'
|
853 |
+
*
|
854 |
+
* @param string $value
|
855 |
+
* @param array $params
|
856 |
+
*
|
857 |
+
* @return string
|
858 |
+
*/
|
859 |
+
protected function filter_sanitize_email($value, $params = null) {
|
860 |
+
return filter_var($value, FILTER_SANITIZE_EMAIL);
|
861 |
+
}
|
862 |
+
|
863 |
+
/**
|
864 |
+
* Sanitize the string by removing illegal characters from numbers.
|
865 |
+
*
|
866 |
+
* @param string $value
|
867 |
+
* @param array $params
|
868 |
+
*
|
869 |
+
* @return string
|
870 |
+
*/
|
871 |
+
protected function filter_sanitize_numbers($value, $params = null) {
|
872 |
+
return filter_var($value, FILTER_SANITIZE_NUMBER_INT);
|
873 |
+
}
|
874 |
+
|
875 |
+
/**
|
876 |
+
* Filter out all HTML tags except the defined basic tags.
|
877 |
+
*
|
878 |
+
* @param string $value
|
879 |
+
* @param array $params
|
880 |
+
*
|
881 |
+
* @return string
|
882 |
+
*/
|
883 |
+
protected function filter_basic_tags($value, $params = null) {
|
884 |
+
return strip_tags($value, self::$basic_tags);
|
885 |
+
}
|
886 |
+
|
887 |
+
/**
|
888 |
+
* Convert the provided numeric value to a whole number.
|
889 |
+
*
|
890 |
+
* @param string $value
|
891 |
+
* @param array $params
|
892 |
+
*
|
893 |
+
* @return string
|
894 |
+
*/
|
895 |
+
protected function filter_whole_number($value, $params = null) {
|
896 |
+
return intval($value);
|
897 |
+
}
|
898 |
+
|
899 |
+
// ** ------------------------- Validators ------------------------------------ ** //
|
900 |
+
|
901 |
+
|
902 |
+
/**
|
903 |
+
* Verify that a value is contained within the pre-defined value set.
|
904 |
+
*
|
905 |
+
* Usage: '<index>' => 'contains,value value value'
|
906 |
+
*
|
907 |
+
* @param string $field
|
908 |
+
* @param array $input
|
909 |
+
* @param null $param
|
910 |
+
*
|
911 |
+
* @return mixed
|
912 |
+
*/
|
913 |
+
protected function validate_contains($field, $input, $param = null) {
|
914 |
+
if (!isset($input[$field])) {
|
915 |
+
return;
|
916 |
+
}
|
917 |
+
|
918 |
+
$param = trim(strtolower($param));
|
919 |
+
|
920 |
+
$value = trim(strtolower($input[$field]));
|
921 |
+
|
922 |
+
if (preg_match_all('#\'(.+?)\'#', $param, $matches, PREG_PATTERN_ORDER)) {
|
923 |
+
$param = $matches[1];
|
924 |
+
} else {
|
925 |
+
$param = explode(chr(32), $param);
|
926 |
+
}
|
927 |
+
|
928 |
+
if (in_array($value, $param)) { // valid, return nothing
|
929 |
+
return;
|
930 |
+
}
|
931 |
+
|
932 |
+
return array(
|
933 |
+
'field' => $field,
|
934 |
+
'value' => $value,
|
935 |
+
'rule' => __FUNCTION__,
|
936 |
+
'param' => $param,
|
937 |
+
);
|
938 |
+
}
|
939 |
+
|
940 |
+
/**
|
941 |
+
* Verify that a value is contained within the pre-defined value set.
|
942 |
+
* OUTPUT: will NOT show the list of values.
|
943 |
+
*
|
944 |
+
* Usage: '<index>' => 'contains_list,value;value;value'
|
945 |
+
*
|
946 |
+
* @param string $field
|
947 |
+
* @param array $input
|
948 |
+
*
|
949 |
+
* @return mixed
|
950 |
+
*/
|
951 |
+
protected function validate_contains_list($field, $input, $param = null) {
|
952 |
+
$param = trim(strtolower($param));
|
953 |
+
|
954 |
+
$value = trim(strtolower($input[$field]));
|
955 |
+
|
956 |
+
$param = explode(';', $param);
|
957 |
+
|
958 |
+
// consider: in_array(strtolower($value), array_map('strtolower', $param)
|
959 |
+
|
960 |
+
if (in_array($value, $param)) { // valid, return nothing
|
961 |
+
return;
|
962 |
+
} else {
|
963 |
+
return array(
|
964 |
+
'field' => $field,
|
965 |
+
'value' => $value,
|
966 |
+
'rule' => __FUNCTION__,
|
967 |
+
'param' => $param,
|
968 |
+
);
|
969 |
+
}
|
970 |
+
}
|
971 |
+
|
972 |
+
/**
|
973 |
+
* Verify that a value is NOT contained within the pre-defined value set.
|
974 |
+
* OUTPUT: will NOT show the list of values.
|
975 |
+
*
|
976 |
+
* Usage: '<index>' => 'doesnt_contain_list,value;value;value'
|
977 |
+
*
|
978 |
+
* @param string $field
|
979 |
+
* @param array $input
|
980 |
+
*
|
981 |
+
* @return mixed
|
982 |
+
*/
|
983 |
+
protected function validate_doesnt_contain_list($field, $input, $param = null) {
|
984 |
+
$param = trim(strtolower($param));
|
985 |
+
|
986 |
+
$value = trim(strtolower($input[$field]));
|
987 |
+
|
988 |
+
$param = explode(';', $param);
|
989 |
+
|
990 |
+
if (!in_array($value, $param)) { // valid, return nothing
|
991 |
+
return;
|
992 |
+
} else {
|
993 |
+
return array(
|
994 |
+
'field' => $field,
|
995 |
+
'value' => $value,
|
996 |
+
'rule' => __FUNCTION__,
|
997 |
+
'param' => $param,
|
998 |
+
);
|
999 |
+
}
|
1000 |
+
}
|
1001 |
+
|
1002 |
+
/**
|
1003 |
+
* Check if the specified key is present and not empty.
|
1004 |
+
*
|
1005 |
+
* Usage: '<index>' => 'required'
|
1006 |
+
*
|
1007 |
+
* @param string $field
|
1008 |
+
* @param array $input
|
1009 |
+
* @param null $param
|
1010 |
+
*
|
1011 |
+
* @return mixed
|
1012 |
+
*/
|
1013 |
+
protected function validate_required($field, $input, $param = null) {
|
1014 |
+
if (isset($input[$field]) && ($input[$field] === false || $input[$field] === 0 || $input[$field] === 0.0 || $input[$field] === '0' || !empty($input[$field]))) {
|
1015 |
+
return;
|
1016 |
+
}
|
1017 |
+
|
1018 |
+
return array(
|
1019 |
+
'field' => $field,
|
1020 |
+
'value' => null,
|
1021 |
+
'rule' => __FUNCTION__,
|
1022 |
+
'param' => $param,
|
1023 |
+
);
|
1024 |
+
}
|
1025 |
+
|
1026 |
+
/**
|
1027 |
+
* Determine if the provided email is valid.
|
1028 |
+
*
|
1029 |
+
* Usage: '<index>' => 'valid_email'
|
1030 |
+
*
|
1031 |
+
* @param string $field
|
1032 |
+
* @param array $input
|
1033 |
+
* @param null $param
|
1034 |
+
*
|
1035 |
+
* @return mixed
|
1036 |
+
*/
|
1037 |
+
protected function validate_valid_email($field, $input, $param = null) {
|
1038 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1039 |
+
return;
|
1040 |
+
}
|
1041 |
+
|
1042 |
+
if (!filter_var($input[$field], FILTER_VALIDATE_EMAIL)) {
|
1043 |
+
return array(
|
1044 |
+
'field' => $field,
|
1045 |
+
'value' => $input[$field],
|
1046 |
+
'rule' => __FUNCTION__,
|
1047 |
+
'param' => $param,
|
1048 |
+
);
|
1049 |
+
}
|
1050 |
+
}
|
1051 |
+
|
1052 |
+
/**
|
1053 |
+
* Determine if the provided value length is less or equal to a specific value.
|
1054 |
+
*
|
1055 |
+
* Usage: '<index>' => 'max_len,240'
|
1056 |
+
*
|
1057 |
+
* @param string $field
|
1058 |
+
* @param array $input
|
1059 |
+
* @param null $param
|
1060 |
+
*
|
1061 |
+
* @return mixed
|
1062 |
+
*/
|
1063 |
+
protected function validate_max_len($field, $input, $param = null) {
|
1064 |
+
if (!isset($input[$field])) {
|
1065 |
+
return;
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
if (function_exists('mb_strlen')) {
|
1069 |
+
if (mb_strlen($input[$field]) <= (int)$param) {
|
1070 |
+
return;
|
1071 |
+
}
|
1072 |
+
} else {
|
1073 |
+
if (strlen($input[$field]) <= (int)$param) {
|
1074 |
+
return;
|
1075 |
+
}
|
1076 |
+
}
|
1077 |
+
|
1078 |
+
return array(
|
1079 |
+
'field' => $field,
|
1080 |
+
'value' => $input[$field],
|
1081 |
+
'rule' => __FUNCTION__,
|
1082 |
+
'param' => $param,
|
1083 |
+
);
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
/**
|
1087 |
+
* Determine if the provided value length is more or equal to a specific value.
|
1088 |
+
*
|
1089 |
+
* Usage: '<index>' => 'min_len,4'
|
1090 |
+
*
|
1091 |
+
* @param string $field
|
1092 |
+
* @param array $input
|
1093 |
+
* @param null $param
|
1094 |
+
*
|
1095 |
+
* @return mixed
|
1096 |
+
*/
|
1097 |
+
protected function validate_min_len($field, $input, $param = null) {
|
1098 |
+
if (!isset($input[$field])) {
|
1099 |
+
return;
|
1100 |
+
}
|
1101 |
+
|
1102 |
+
if (function_exists('mb_strlen')) {
|
1103 |
+
if (mb_strlen($input[$field]) >= (int)$param) {
|
1104 |
+
return;
|
1105 |
+
}
|
1106 |
+
} else {
|
1107 |
+
if (strlen($input[$field]) >= (int)$param) {
|
1108 |
+
return;
|
1109 |
+
}
|
1110 |
+
}
|
1111 |
+
|
1112 |
+
return array(
|
1113 |
+
'field' => $field,
|
1114 |
+
'value' => $input[$field],
|
1115 |
+
'rule' => __FUNCTION__,
|
1116 |
+
'param' => $param,
|
1117 |
+
);
|
1118 |
+
}
|
1119 |
+
|
1120 |
+
/**
|
1121 |
+
* Determine if the provided value length matches a specific value.
|
1122 |
+
*
|
1123 |
+
* Usage: '<index>' => 'exact_len,5'
|
1124 |
+
*
|
1125 |
+
* @param string $field
|
1126 |
+
* @param array $input
|
1127 |
+
* @param null $param
|
1128 |
+
*
|
1129 |
+
* @return mixed
|
1130 |
+
*/
|
1131 |
+
protected function validate_exact_len($field, $input, $param = null) {
|
1132 |
+
if (!isset($input[$field])) {
|
1133 |
+
return;
|
1134 |
+
}
|
1135 |
+
|
1136 |
+
if (function_exists('mb_strlen')) {
|
1137 |
+
if (mb_strlen($input[$field]) == (int)$param) {
|
1138 |
+
return;
|
1139 |
+
}
|
1140 |
+
} else {
|
1141 |
+
if (strlen($input[$field]) == (int)$param) {
|
1142 |
+
return;
|
1143 |
+
}
|
1144 |
+
}
|
1145 |
+
|
1146 |
+
return array(
|
1147 |
+
'field' => $field,
|
1148 |
+
'value' => $input[$field],
|
1149 |
+
'rule' => __FUNCTION__,
|
1150 |
+
'param' => $param,
|
1151 |
+
);
|
1152 |
+
}
|
1153 |
+
|
1154 |
+
/**
|
1155 |
+
* Determine if the provided value contains only alpha characters.
|
1156 |
+
*
|
1157 |
+
* Usage: '<index>' => 'alpha'
|
1158 |
+
*
|
1159 |
+
* @param string $field
|
1160 |
+
* @param array $input
|
1161 |
+
* @param null $param
|
1162 |
+
*
|
1163 |
+
* @return mixed
|
1164 |
+
*/
|
1165 |
+
protected function validate_alpha($field, $input, $param = null) {
|
1166 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1167 |
+
return;
|
1168 |
+
}
|
1169 |
+
|
1170 |
+
if (!preg_match('/^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$/i', $input[$field]) !== false) {
|
1171 |
+
return array(
|
1172 |
+
'field' => $field,
|
1173 |
+
'value' => $input[$field],
|
1174 |
+
'rule' => __FUNCTION__,
|
1175 |
+
'param' => $param,
|
1176 |
+
);
|
1177 |
+
}
|
1178 |
+
}
|
1179 |
+
|
1180 |
+
/**
|
1181 |
+
* Determine if the provided value contains only alpha-numeric characters.
|
1182 |
+
*
|
1183 |
+
* Usage: '<index>' => 'alpha_numeric'
|
1184 |
+
*
|
1185 |
+
* @param string $field
|
1186 |
+
* @param array $input
|
1187 |
+
* @param null $param
|
1188 |
+
*
|
1189 |
+
* @return mixed
|
1190 |
+
*/
|
1191 |
+
protected function validate_alpha_numeric($field, $input, $param = null) {
|
1192 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1193 |
+
return;
|
1194 |
+
}
|
1195 |
+
|
1196 |
+
if (!preg_match('/^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ])+$/i', $input[$field]) !== false) {
|
1197 |
+
return array(
|
1198 |
+
'field' => $field,
|
1199 |
+
'value' => $input[$field],
|
1200 |
+
'rule' => __FUNCTION__,
|
1201 |
+
'param' => $param,
|
1202 |
+
);
|
1203 |
+
}
|
1204 |
+
}
|
1205 |
+
|
1206 |
+
/**
|
1207 |
+
* Determine if the provided value contains only alpha characters with dashed and underscores.
|
1208 |
+
*
|
1209 |
+
* Usage: '<index>' => 'alpha_dash'
|
1210 |
+
*
|
1211 |
+
* @param string $field
|
1212 |
+
* @param array $input
|
1213 |
+
* @param null $param
|
1214 |
+
*
|
1215 |
+
* @return mixed
|
1216 |
+
*/
|
1217 |
+
protected function validate_alpha_dash($field, $input, $param = null) {
|
1218 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1219 |
+
return;
|
1220 |
+
}
|
1221 |
+
|
1222 |
+
if (!preg_match('/^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ_-])+$/i', $input[$field]) !== false) {
|
1223 |
+
return array(
|
1224 |
+
'field' => $field,
|
1225 |
+
'value' => $input[$field],
|
1226 |
+
'rule' => __FUNCTION__,
|
1227 |
+
'param' => $param,
|
1228 |
+
);
|
1229 |
+
}
|
1230 |
+
}
|
1231 |
+
|
1232 |
+
/**
|
1233 |
+
* Determine if the provided value contains only alpha numeric characters with spaces.
|
1234 |
+
*
|
1235 |
+
* Usage: '<index>' => 'alpha_space'
|
1236 |
+
*
|
1237 |
+
* @param string $field
|
1238 |
+
* @param array $input
|
1239 |
+
* @param null $param
|
1240 |
+
*
|
1241 |
+
* @return mixed
|
1242 |
+
*/
|
1243 |
+
protected function validate_alpha_space($field, $input, $param = null) {
|
1244 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1245 |
+
return;
|
1246 |
+
}
|
1247 |
+
|
1248 |
+
if (!preg_match("/^([a-z0-9ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ\s])+$/i", $input[$field]) !== false) {
|
1249 |
+
return array(
|
1250 |
+
'field' => $field,
|
1251 |
+
'value' => $input[$field],
|
1252 |
+
'rule' => __FUNCTION__,
|
1253 |
+
'param' => $param,
|
1254 |
+
);
|
1255 |
+
}
|
1256 |
+
}
|
1257 |
+
|
1258 |
+
/**
|
1259 |
+
* Determine if the provided value is a valid number or numeric string.
|
1260 |
+
*
|
1261 |
+
* Usage: '<index>' => 'numeric'
|
1262 |
+
*
|
1263 |
+
* @param string $field
|
1264 |
+
* @param array $input
|
1265 |
+
* @param null $param
|
1266 |
+
*
|
1267 |
+
* @return mixed
|
1268 |
+
*/
|
1269 |
+
protected function validate_numeric($field, $input, $param = null) {
|
1270 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1271 |
+
return;
|
1272 |
+
}
|
1273 |
+
|
1274 |
+
if (!is_numeric($input[$field])) {
|
1275 |
+
return array(
|
1276 |
+
'field' => $field,
|
1277 |
+
'value' => $input[$field],
|
1278 |
+
'rule' => __FUNCTION__,
|
1279 |
+
'param' => $param,
|
1280 |
+
);
|
1281 |
+
}
|
1282 |
+
}
|
1283 |
+
|
1284 |
+
/**
|
1285 |
+
* Determine if the provided value is a valid integer.
|
1286 |
+
*
|
1287 |
+
* Usage: '<index>' => 'integer'
|
1288 |
+
*
|
1289 |
+
* @param string $field
|
1290 |
+
* @param array $input
|
1291 |
+
* @param null $param
|
1292 |
+
*
|
1293 |
+
* @return mixed
|
1294 |
+
*/
|
1295 |
+
protected function validate_integer($field, $input, $param = null) {
|
1296 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1297 |
+
return;
|
1298 |
+
}
|
1299 |
+
|
1300 |
+
if (filter_var($input[$field], FILTER_VALIDATE_INT) === false) {
|
1301 |
+
return array(
|
1302 |
+
'field' => $field,
|
1303 |
+
'value' => $input[$field],
|
1304 |
+
'rule' => __FUNCTION__,
|
1305 |
+
'param' => $param,
|
1306 |
+
);
|
1307 |
+
}
|
1308 |
+
}
|
1309 |
+
|
1310 |
+
/**
|
1311 |
+
* Determine if the provided value is a PHP accepted boolean.
|
1312 |
+
*
|
1313 |
+
* Usage: '<index>' => 'boolean'
|
1314 |
+
*
|
1315 |
+
* @param string $field
|
1316 |
+
* @param array $input
|
1317 |
+
* @param null $param
|
1318 |
+
*
|
1319 |
+
* @return mixed
|
1320 |
+
*/
|
1321 |
+
protected function validate_boolean($field, $input, $param = null) {
|
1322 |
+
if (!isset($input[$field]) || empty($input[$field]) && $input[$field] !== 0) {
|
1323 |
+
return;
|
1324 |
+
}
|
1325 |
+
|
1326 |
+
if ($input[$field] === true || $input[$field] === false) {
|
1327 |
+
return;
|
1328 |
+
}
|
1329 |
+
|
1330 |
+
return array(
|
1331 |
+
'field' => $field,
|
1332 |
+
'value' => $input[$field],
|
1333 |
+
'rule' => __FUNCTION__,
|
1334 |
+
'param' => $param,
|
1335 |
+
);
|
1336 |
+
}
|
1337 |
+
|
1338 |
+
/**
|
1339 |
+
* Determine if the provided value is a valid float.
|
1340 |
+
*
|
1341 |
+
* Usage: '<index>' => 'float'
|
1342 |
+
*
|
1343 |
+
* @param string $field
|
1344 |
+
* @param array $input
|
1345 |
+
* @param null $param
|
1346 |
+
*
|
1347 |
+
* @return mixed
|
1348 |
+
*/
|
1349 |
+
protected function validate_float($field, $input, $param = null) {
|
1350 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1351 |
+
return;
|
1352 |
+
}
|
1353 |
+
|
1354 |
+
if (filter_var($input[$field], FILTER_VALIDATE_FLOAT) === false) {
|
1355 |
+
return array(
|
1356 |
+
'field' => $field,
|
1357 |
+
'value' => $input[$field],
|
1358 |
+
'rule' => __FUNCTION__,
|
1359 |
+
'param' => $param,
|
1360 |
+
);
|
1361 |
+
}
|
1362 |
+
}
|
1363 |
+
|
1364 |
+
/**
|
1365 |
+
* Determine if the provided value is a valid URL.
|
1366 |
+
*
|
1367 |
+
* Usage: '<index>' => 'valid_url'
|
1368 |
+
*
|
1369 |
+
* @param string $field
|
1370 |
+
* @param array $input
|
1371 |
+
* @param null $param
|
1372 |
+
*
|
1373 |
+
* @return mixed
|
1374 |
+
*/
|
1375 |
+
protected function validate_valid_url($field, $input, $param = null) {
|
1376 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1377 |
+
return;
|
1378 |
+
}
|
1379 |
+
|
1380 |
+
if (!filter_var($input[$field], FILTER_VALIDATE_URL)) {
|
1381 |
+
return array(
|
1382 |
+
'field' => $field,
|
1383 |
+
'value' => $input[$field],
|
1384 |
+
'rule' => __FUNCTION__,
|
1385 |
+
'param' => $param,
|
1386 |
+
);
|
1387 |
+
}
|
1388 |
+
}
|
1389 |
+
|
1390 |
+
/**
|
1391 |
+
* Determine if a URL exists & is accessible.
|
1392 |
+
*
|
1393 |
+
* Usage: '<index>' => 'url_exists'
|
1394 |
+
*
|
1395 |
+
* @param string $field
|
1396 |
+
* @param array $input
|
1397 |
+
* @param null $param
|
1398 |
+
*
|
1399 |
+
* @return mixed
|
1400 |
+
*/
|
1401 |
+
protected function validate_url_exists($field, $input, $param = null) {
|
1402 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1403 |
+
return;
|
1404 |
+
}
|
1405 |
+
|
1406 |
+
$url = parse_url(strtolower($input[$field]));
|
1407 |
+
|
1408 |
+
if (isset($url['host'])) {
|
1409 |
+
$url = $url['host'];
|
1410 |
+
}
|
1411 |
+
|
1412 |
+
if (function_exists('checkdnsrr')) {
|
1413 |
+
if (checkdnsrr($url) === false) {
|
1414 |
+
return array(
|
1415 |
+
'field' => $field,
|
1416 |
+
'value' => $input[$field],
|
1417 |
+
'rule' => __FUNCTION__,
|
1418 |
+
'param' => $param,
|
1419 |
+
);
|
1420 |
+
}
|
1421 |
+
} else {
|
1422 |
+
if (gethostbyname($url) == $url) {
|
1423 |
+
return array(
|
1424 |
+
'field' => $field,
|
1425 |
+
'value' => $input[$field],
|
1426 |
+
'rule' => __FUNCTION__,
|
1427 |
+
'param' => $param,
|
1428 |
+
);
|
1429 |
+
}
|
1430 |
+
}
|
1431 |
+
}
|
1432 |
+
|
1433 |
+
/**
|
1434 |
+
* Determine if the provided value is a valid IP address.
|
1435 |
+
*
|
1436 |
+
* Usage: '<index>' => 'valid_ip'
|
1437 |
+
*
|
1438 |
+
* @param string $field
|
1439 |
+
* @param array $input
|
1440 |
+
*
|
1441 |
+
* @return mixed
|
1442 |
+
*/
|
1443 |
+
protected function validate_valid_ip($field, $input, $param = null) {
|
1444 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1445 |
+
return;
|
1446 |
+
}
|
1447 |
+
|
1448 |
+
if (!filter_var($input[$field], FILTER_VALIDATE_IP) !== false) {
|
1449 |
+
return array(
|
1450 |
+
'field' => $field,
|
1451 |
+
'value' => $input[$field],
|
1452 |
+
'rule' => __FUNCTION__,
|
1453 |
+
'param' => $param,
|
1454 |
+
);
|
1455 |
+
}
|
1456 |
+
}
|
1457 |
+
|
1458 |
+
/**
|
1459 |
+
* Determine if the provided value is a valid IPv4 address.
|
1460 |
+
*
|
1461 |
+
* Usage: '<index>' => 'valid_ipv4'
|
1462 |
+
*
|
1463 |
+
* @param string $field
|
1464 |
+
* @param array $input
|
1465 |
+
*
|
1466 |
+
* @return mixed
|
1467 |
+
*
|
1468 |
+
* @see http://pastebin.com/UvUPPYK0
|
1469 |
+
*/
|
1470 |
+
|
1471 |
+
/*
|
1472 |
+
* What about private networks? http://en.wikipedia.org/wiki/Private_network
|
1473 |
+
* What about loop-back address? 127.0.0.1
|
1474 |
+
*/
|
1475 |
+
protected function validate_valid_ipv4($field, $input, $param = null) {
|
1476 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1477 |
+
return;
|
1478 |
+
}
|
1479 |
+
|
1480 |
+
if (!filter_var($input[$field], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
1481 |
+
// removed !== FALSE
|
1482 |
+
|
1483 |
+
return array(
|
1484 |
+
'field' => $field,
|
1485 |
+
'value' => $input[$field],
|
1486 |
+
'rule' => __FUNCTION__,
|
1487 |
+
'param' => $param,
|
1488 |
+
);
|
1489 |
+
}
|
1490 |
+
}
|
1491 |
+
|
1492 |
+
/**
|
1493 |
+
* Determine if the provided value is a valid IPv6 address.
|
1494 |
+
*
|
1495 |
+
* Usage: '<index>' => 'valid_ipv6'
|
1496 |
+
*
|
1497 |
+
* @param string $field
|
1498 |
+
* @param array $input
|
1499 |
+
*
|
1500 |
+
* @return mixed
|
1501 |
+
*/
|
1502 |
+
protected function validate_valid_ipv6($field, $input, $param = null) {
|
1503 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1504 |
+
return;
|
1505 |
+
}
|
1506 |
+
|
1507 |
+
if (!filter_var($input[$field], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
|
1508 |
+
return array(
|
1509 |
+
'field' => $field,
|
1510 |
+
'value' => $input[$field],
|
1511 |
+
'rule' => __FUNCTION__,
|
1512 |
+
'param' => $param,
|
1513 |
+
);
|
1514 |
+
}
|
1515 |
+
}
|
1516 |
+
|
1517 |
+
/**
|
1518 |
+
* Determine if the input is a valid credit card number.
|
1519 |
+
*
|
1520 |
+
* See: http://stackoverflow.com/questions/174730/what-is-the-best-way-to-validate-a-credit-card-in-php
|
1521 |
+
* Usage: '<index>' => 'valid_cc'
|
1522 |
+
*
|
1523 |
+
* @param string $field
|
1524 |
+
* @param array $input
|
1525 |
+
*
|
1526 |
+
* @return mixed
|
1527 |
+
*/
|
1528 |
+
protected function validate_valid_cc($field, $input, $param = null) {
|
1529 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1530 |
+
return;
|
1531 |
+
}
|
1532 |
+
|
1533 |
+
$number = preg_replace('/\D/', '', $input[$field]);
|
1534 |
+
|
1535 |
+
if (function_exists('mb_strlen')) {
|
1536 |
+
$number_length = mb_strlen($number);
|
1537 |
+
} else {
|
1538 |
+
$number_length = strlen($number);
|
1539 |
+
}
|
1540 |
+
|
1541 |
+
$parity = $number_length % 2;
|
1542 |
+
|
1543 |
+
$total = 0;
|
1544 |
+
|
1545 |
+
for ($i = 0; $i < $number_length; ++$i) {
|
1546 |
+
$digit = $number[$i];
|
1547 |
+
|
1548 |
+
if ($i % 2 == $parity) {
|
1549 |
+
$digit *= 2;
|
1550 |
+
|
1551 |
+
if ($digit > 9) {
|
1552 |
+
$digit -= 9;
|
1553 |
+
}
|
1554 |
+
}
|
1555 |
+
|
1556 |
+
$total += $digit;
|
1557 |
+
}
|
1558 |
+
|
1559 |
+
if ($total % 10 == 0) {
|
1560 |
+
return; // Valid
|
1561 |
+
}
|
1562 |
+
|
1563 |
+
return array(
|
1564 |
+
'field' => $field,
|
1565 |
+
'value' => $input[$field],
|
1566 |
+
'rule' => __FUNCTION__,
|
1567 |
+
'param' => $param,
|
1568 |
+
);
|
1569 |
+
}
|
1570 |
+
|
1571 |
+
/**
|
1572 |
+
* Determine if the input is a valid human name [Credits to http://github.com/ben-s].
|
1573 |
+
*
|
1574 |
+
* See: https://github.com/Wixel/GUMP/issues/5
|
1575 |
+
* Usage: '<index>' => 'valid_name'
|
1576 |
+
*
|
1577 |
+
* @param string $field
|
1578 |
+
* @param array $input
|
1579 |
+
*
|
1580 |
+
* @return mixed
|
1581 |
+
*/
|
1582 |
+
protected function validate_valid_name($field, $input, $param = null) {
|
1583 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1584 |
+
return;
|
1585 |
+
}
|
1586 |
+
|
1587 |
+
if (!preg_match("/^([a-zÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïñðòóôõöùúûüýÿ '-])+$/i", $input[$field]) !== false) {
|
1588 |
+
return array(
|
1589 |
+
'field' => $field,
|
1590 |
+
'value' => $input[$field],
|
1591 |
+
'rule' => __FUNCTION__,
|
1592 |
+
'param' => $param,
|
1593 |
+
);
|
1594 |
+
}
|
1595 |
+
}
|
1596 |
+
|
1597 |
+
/**
|
1598 |
+
* Determine if the provided input is likely to be a street address using weak detection.
|
1599 |
+
*
|
1600 |
+
* Usage: '<index>' => 'street_address'
|
1601 |
+
*
|
1602 |
+
* @param string $field
|
1603 |
+
* @param array $input
|
1604 |
+
*
|
1605 |
+
* @return mixed
|
1606 |
+
*/
|
1607 |
+
protected function validate_street_address($field, $input, $param = null) {
|
1608 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1609 |
+
return;
|
1610 |
+
}
|
1611 |
+
|
1612 |
+
// Theory: 1 number, 1 or more spaces, 1 or more words
|
1613 |
+
$hasLetter = preg_match('/[a-zA-Z]/', $input[$field]);
|
1614 |
+
$hasDigit = preg_match('/\d/', $input[$field]);
|
1615 |
+
$hasSpace = preg_match('/\s/', $input[$field]);
|
1616 |
+
|
1617 |
+
$passes = $hasLetter && $hasDigit && $hasSpace;
|
1618 |
+
|
1619 |
+
if (!$passes) {
|
1620 |
+
return array(
|
1621 |
+
'field' => $field,
|
1622 |
+
'value' => $input[$field],
|
1623 |
+
'rule' => __FUNCTION__,
|
1624 |
+
'param' => $param,
|
1625 |
+
);
|
1626 |
+
}
|
1627 |
+
}
|
1628 |
+
|
1629 |
+
/**
|
1630 |
+
* Determine if the provided value is a valid IBAN.
|
1631 |
+
*
|
1632 |
+
* Usage: '<index>' => 'iban'
|
1633 |
+
*
|
1634 |
+
* @param string $field
|
1635 |
+
* @param array $input
|
1636 |
+
*
|
1637 |
+
* @return mixed
|
1638 |
+
*/
|
1639 |
+
protected function validate_iban($field, $input, $param = null) {
|
1640 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1641 |
+
return;
|
1642 |
+
}
|
1643 |
+
|
1644 |
+
static $character = array(
|
1645 |
+
'A' => 10, 'C' => 12, 'D' => 13, 'E' => 14, 'F' => 15, 'G' => 16,
|
1646 |
+
'H' => 17, 'I' => 18, 'J' => 19, 'K' => 20, 'L' => 21, 'M' => 22,
|
1647 |
+
'N' => 23, 'O' => 24, 'P' => 25, 'Q' => 26, 'R' => 27, 'S' => 28,
|
1648 |
+
'T' => 29, 'U' => 30, 'V' => 31, 'W' => 32, 'X' => 33, 'Y' => 34,
|
1649 |
+
'Z' => 35, 'B' => 11
|
1650 |
+
);
|
1651 |
+
|
1652 |
+
if (!preg_match("/\A[A-Z]{2}\d{2} ?[A-Z\d]{4}( ?\d{4}){1,} ?\d{1,4}\z/", $input[$field])) {
|
1653 |
+
return array(
|
1654 |
+
'field' => $field,
|
1655 |
+
'value' => $input[$field],
|
1656 |
+
'rule' => __FUNCTION__,
|
1657 |
+
'param' => $param,
|
1658 |
+
);
|
1659 |
+
}
|
1660 |
+
|
1661 |
+
$iban = str_replace(' ', '', $input[$field]);
|
1662 |
+
$iban = substr($iban, 4) . substr($iban, 0, 4);
|
1663 |
+
$iban = strtr($iban, $character);
|
1664 |
+
|
1665 |
+
if (bcmod($iban, 97) != 1) {
|
1666 |
+
return array(
|
1667 |
+
'field' => $field,
|
1668 |
+
'value' => $input[$field],
|
1669 |
+
'rule' => __FUNCTION__,
|
1670 |
+
'param' => $param,
|
1671 |
+
);
|
1672 |
+
}
|
1673 |
+
}
|
1674 |
+
|
1675 |
+
/**
|
1676 |
+
* Determine if the provided input is a valid date (ISO 8601).
|
1677 |
+
*
|
1678 |
+
* Usage: '<index>' => 'date'
|
1679 |
+
*
|
1680 |
+
* @param string $field
|
1681 |
+
* @param string $input date ('Y-m-d') or datetime ('Y-m-d H:i:s')
|
1682 |
+
* @param null $param
|
1683 |
+
*
|
1684 |
+
* @return mixed
|
1685 |
+
*/
|
1686 |
+
protected function validate_date($field, $input, $param = null) {
|
1687 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1688 |
+
return;
|
1689 |
+
}
|
1690 |
+
|
1691 |
+
$cdate1 = date('Y-m-d', strtotime($input[$field]));
|
1692 |
+
$cdate2 = date('Y-m-d H:i:s', strtotime($input[$field]));
|
1693 |
+
|
1694 |
+
if ($cdate1 != $input[$field] && $cdate2 != $input[$field]) {
|
1695 |
+
return array(
|
1696 |
+
'field' => $field,
|
1697 |
+
'value' => $input[$field],
|
1698 |
+
'rule' => __FUNCTION__,
|
1699 |
+
'param' => $param,
|
1700 |
+
);
|
1701 |
+
}
|
1702 |
+
}
|
1703 |
+
|
1704 |
+
/**
|
1705 |
+
* Determine if the provided input meets age requirement (ISO 8601).
|
1706 |
+
*
|
1707 |
+
* Usage: '<index>' => 'min_age,13'
|
1708 |
+
*
|
1709 |
+
* @param string $field
|
1710 |
+
* @param string $input date ('Y-m-d') or datetime ('Y-m-d H:i:s')
|
1711 |
+
* @param string $param int
|
1712 |
+
*
|
1713 |
+
* @return mixed
|
1714 |
+
*/
|
1715 |
+
protected function validate_min_age($field, $input, $param = null) {
|
1716 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1717 |
+
return;
|
1718 |
+
}
|
1719 |
+
|
1720 |
+
$cdate1 = new DateTime(date('Y-m-d', strtotime($input[$field])));
|
1721 |
+
$today = new DateTime(date('d-m-Y'));
|
1722 |
+
|
1723 |
+
$interval = $cdate1->diff($today);
|
1724 |
+
$age = $interval->y;
|
1725 |
+
|
1726 |
+
if ($age <= $param) {
|
1727 |
+
return array(
|
1728 |
+
'field' => $field,
|
1729 |
+
'value' => $input[$field],
|
1730 |
+
'rule' => __FUNCTION__,
|
1731 |
+
'param' => $param,
|
1732 |
+
);
|
1733 |
+
}
|
1734 |
+
}
|
1735 |
+
|
1736 |
+
/**
|
1737 |
+
* Determine if the provided numeric value is lower or equal to a specific value.
|
1738 |
+
*
|
1739 |
+
* Usage: '<index>' => 'max_numeric,50'
|
1740 |
+
*
|
1741 |
+
* @param string $field
|
1742 |
+
* @param array $input
|
1743 |
+
* @param null $param
|
1744 |
+
*
|
1745 |
+
* @return mixed
|
1746 |
+
*/
|
1747 |
+
protected function validate_max_numeric($field, $input, $param = null) {
|
1748 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1749 |
+
return;
|
1750 |
+
}
|
1751 |
+
|
1752 |
+
if (is_numeric($input[$field]) && is_numeric($param) && ($input[$field] <= $param)) {
|
1753 |
+
return;
|
1754 |
+
}
|
1755 |
+
|
1756 |
+
return array(
|
1757 |
+
'field' => $field,
|
1758 |
+
'value' => $input[$field],
|
1759 |
+
'rule' => __FUNCTION__,
|
1760 |
+
'param' => $param,
|
1761 |
+
);
|
1762 |
+
}
|
1763 |
+
|
1764 |
+
/**
|
1765 |
+
* Determine if the provided numeric value is higher or equal to a specific value.
|
1766 |
+
*
|
1767 |
+
* Usage: '<index>' => 'min_numeric,1'
|
1768 |
+
*
|
1769 |
+
* @param string $field
|
1770 |
+
* @param array $input
|
1771 |
+
* @param null $param
|
1772 |
+
*
|
1773 |
+
* @return mixed
|
1774 |
+
*/
|
1775 |
+
protected function validate_min_numeric($field, $input, $param = null) {
|
1776 |
+
if (!isset($input[$field])) {
|
1777 |
+
return;
|
1778 |
+
}
|
1779 |
+
|
1780 |
+
if (is_numeric($input[$field]) && is_numeric($param) && ($input[$field] >= $param)) {
|
1781 |
+
return;
|
1782 |
+
}
|
1783 |
+
|
1784 |
+
return array(
|
1785 |
+
'field' => $field,
|
1786 |
+
'value' => $input[$field],
|
1787 |
+
'rule' => __FUNCTION__,
|
1788 |
+
'param' => $param,
|
1789 |
+
);
|
1790 |
+
}
|
1791 |
+
|
1792 |
+
/**
|
1793 |
+
* Determine if the provided value starts with param.
|
1794 |
+
*
|
1795 |
+
* Usage: '<index>' => 'starts,Z'
|
1796 |
+
*
|
1797 |
+
* @param string $field
|
1798 |
+
* @param array $input
|
1799 |
+
*
|
1800 |
+
* @return mixed
|
1801 |
+
*/
|
1802 |
+
protected function validate_starts($field, $input, $param = null) {
|
1803 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1804 |
+
return;
|
1805 |
+
}
|
1806 |
+
|
1807 |
+
if (strpos($input[$field], $param) !== 0) {
|
1808 |
+
return array(
|
1809 |
+
'field' => $field,
|
1810 |
+
'value' => $input[$field],
|
1811 |
+
'rule' => __FUNCTION__,
|
1812 |
+
'param' => $param,
|
1813 |
+
);
|
1814 |
+
}
|
1815 |
+
}
|
1816 |
+
|
1817 |
+
/**
|
1818 |
+
* checks if a file was uploaded.
|
1819 |
+
*
|
1820 |
+
* Usage: '<index>' => 'required_file'
|
1821 |
+
*
|
1822 |
+
* @param string $field
|
1823 |
+
* @param array $input
|
1824 |
+
*
|
1825 |
+
* @return mixed
|
1826 |
+
*/
|
1827 |
+
protected function validate_required_file($field, $input, $param = null) {
|
1828 |
+
if ($input[$field]['error'] !== 4) {
|
1829 |
+
return;
|
1830 |
+
}
|
1831 |
+
|
1832 |
+
return array(
|
1833 |
+
'field' => $field,
|
1834 |
+
'value' => $input[$field],
|
1835 |
+
'rule' => __FUNCTION__,
|
1836 |
+
'param' => $param,
|
1837 |
+
);
|
1838 |
+
}
|
1839 |
+
|
1840 |
+
/**
|
1841 |
+
* check the uploaded file for extension
|
1842 |
+
* for now checks onlt the ext should add mime type check.
|
1843 |
+
*
|
1844 |
+
* Usage: '<index>' => 'starts,Z'
|
1845 |
+
*
|
1846 |
+
* @param string $field
|
1847 |
+
* @param array $input
|
1848 |
+
*
|
1849 |
+
* @return mixed
|
1850 |
+
*/
|
1851 |
+
protected function validate_extension($field, $input, $param = null) {
|
1852 |
+
if ($input[$field]['error'] !== 4) {
|
1853 |
+
$param = trim(strtolower($param));
|
1854 |
+
$allowed_extensions = explode(';', $param);
|
1855 |
+
|
1856 |
+
$path_info = pathinfo($input[$field]['name']);
|
1857 |
+
$extension = $path_info['extension'];
|
1858 |
+
|
1859 |
+
if (in_array($extension, $allowed_extensions)) {
|
1860 |
+
return;
|
1861 |
+
}
|
1862 |
+
|
1863 |
+
return array(
|
1864 |
+
'field' => $field,
|
1865 |
+
'value' => $input[$field],
|
1866 |
+
'rule' => __FUNCTION__,
|
1867 |
+
'param' => $param,
|
1868 |
+
);
|
1869 |
+
}
|
1870 |
+
}
|
1871 |
+
|
1872 |
+
/**
|
1873 |
+
* Determine if the provided field value equals current field value.
|
1874 |
+
*
|
1875 |
+
* Usage: '<index>' => 'equalsfield,Z'
|
1876 |
+
*
|
1877 |
+
* @param string $field
|
1878 |
+
* @param string $input
|
1879 |
+
* @param string $param field to compare with
|
1880 |
+
*
|
1881 |
+
* @return mixed
|
1882 |
+
*/
|
1883 |
+
protected function validate_equalsfield($field, $input, $param = null) {
|
1884 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1885 |
+
return;
|
1886 |
+
}
|
1887 |
+
|
1888 |
+
if ($input[$field] == $input[$param]) {
|
1889 |
+
return;
|
1890 |
+
}
|
1891 |
+
|
1892 |
+
return array(
|
1893 |
+
'field' => $field,
|
1894 |
+
'value' => $input[$field],
|
1895 |
+
'rule' => __FUNCTION__,
|
1896 |
+
'param' => $param,
|
1897 |
+
);
|
1898 |
+
}
|
1899 |
+
|
1900 |
+
/**
|
1901 |
+
* Determine if the provided field value is a valid GUID (v4)
|
1902 |
+
*
|
1903 |
+
* Usage: '<index>' => 'guidv4'
|
1904 |
+
*
|
1905 |
+
* @param string $field
|
1906 |
+
* @param string $input
|
1907 |
+
* @param string $param field to compare with
|
1908 |
+
*
|
1909 |
+
* @return mixed
|
1910 |
+
*/
|
1911 |
+
protected function validate_guidv4($field, $input, $param = null) {
|
1912 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1913 |
+
return;
|
1914 |
+
}
|
1915 |
+
|
1916 |
+
if (preg_match("/\{?[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}\}?$/", $input[$field])) {
|
1917 |
+
return;
|
1918 |
+
}
|
1919 |
+
|
1920 |
+
return array(
|
1921 |
+
'field' => $field,
|
1922 |
+
'value' => $input[$field],
|
1923 |
+
'rule' => __FUNCTION__,
|
1924 |
+
'param' => $param,
|
1925 |
+
);
|
1926 |
+
}
|
1927 |
+
|
1928 |
+
/**
|
1929 |
+
* Trims whitespace only when the value is a scalar.
|
1930 |
+
*
|
1931 |
+
* @param mixed $value
|
1932 |
+
*
|
1933 |
+
* @return mixed
|
1934 |
+
*/
|
1935 |
+
private function trimScalar($value) {
|
1936 |
+
if (is_scalar($value)) {
|
1937 |
+
$value = trim($value);
|
1938 |
+
}
|
1939 |
+
|
1940 |
+
return $value;
|
1941 |
+
}
|
1942 |
+
|
1943 |
+
/**
|
1944 |
+
* Determine if the provided value is a valid phone number.
|
1945 |
+
*
|
1946 |
+
* Usage: '<index>' => 'phone_number'
|
1947 |
+
*
|
1948 |
+
* @param string $field
|
1949 |
+
* @param array $input
|
1950 |
+
*
|
1951 |
+
* @return mixed
|
1952 |
+
*
|
1953 |
+
* Examples:
|
1954 |
+
*
|
1955 |
+
* 555-555-5555: valid
|
1956 |
+
* 5555425555: valid
|
1957 |
+
* 555 555 5555: valid
|
1958 |
+
* 1(519) 555-4444: valid
|
1959 |
+
* 1 (519) 555-4422: valid
|
1960 |
+
* 1-555-555-5555: valid
|
1961 |
+
* 1-(555)-555-5555: valid
|
1962 |
+
*/
|
1963 |
+
protected function validate_phone_number($field, $input, $param = null) {
|
1964 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1965 |
+
return;
|
1966 |
+
}
|
1967 |
+
|
1968 |
+
$regex = '/^(\d[\s-]?)?[\(\[\s-]{0,2}?\d{3}[\)\]\s-]{0,2}?\d{3}[\s-]?\d{4}$/i';
|
1969 |
+
if (!preg_match($regex, $input[$field])) {
|
1970 |
+
return array(
|
1971 |
+
'field' => $field,
|
1972 |
+
'value' => $input[$field],
|
1973 |
+
'rule' => __FUNCTION__,
|
1974 |
+
'param' => $param,
|
1975 |
+
);
|
1976 |
+
}
|
1977 |
+
}
|
1978 |
+
|
1979 |
+
/**
|
1980 |
+
* Custom regex validator.
|
1981 |
+
*
|
1982 |
+
* Usage: '<index>' => 'regex&&&/regex/'
|
1983 |
+
*
|
1984 |
+
* @param string $field
|
1985 |
+
* @param array $input
|
1986 |
+
*
|
1987 |
+
* @return mixed
|
1988 |
+
*/
|
1989 |
+
protected function validate_regex($field, $input, $param = null) {
|
1990 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
1991 |
+
return;
|
1992 |
+
}
|
1993 |
+
|
1994 |
+
$regex = $param;
|
1995 |
+
if (!preg_match($regex, $input[$field])) {
|
1996 |
+
return array(
|
1997 |
+
'field' => $field,
|
1998 |
+
'value' => $input[$field],
|
1999 |
+
'rule' => __FUNCTION__,
|
2000 |
+
'param' => $param,
|
2001 |
+
);
|
2002 |
+
}
|
2003 |
+
}
|
2004 |
+
|
2005 |
+
/**
|
2006 |
+
* Json validatior.
|
2007 |
+
*
|
2008 |
+
* Usage: '<index>' => 'valid_json_string'
|
2009 |
+
*
|
2010 |
+
* @param string $field
|
2011 |
+
* @param array $input
|
2012 |
+
*
|
2013 |
+
* @return mixed
|
2014 |
+
*/
|
2015 |
+
protected function validate_valid_json_string($field, $input, $param = null) {
|
2016 |
+
if (!isset($input[$field]) || empty($input[$field])) {
|
2017 |
+
return;
|
2018 |
+
}
|
2019 |
+
|
2020 |
+
if (!is_string($input[$field]) || !is_object(json_decode($input[$field]))) {
|
2021 |
+
return array(
|
2022 |
+
'field' => $field,
|
2023 |
+
'value' => $input[$field],
|
2024 |
+
'rule' => __FUNCTION__,
|
2025 |
+
'param' => $param,
|
2026 |
+
);
|
2027 |
+
}
|
2028 |
+
}
|
2029 |
+
} // EOC
|
classes/models/class-column.php
CHANGED
@@ -1,218 +1,218 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\classes\models;
|
4 |
-
|
5 |
-
use mp_timetable\plugin_core\classes\Model as Model;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Model Events
|
9 |
-
*/
|
10 |
-
class Column extends Model {
|
11 |
-
|
12 |
-
protected static $instance;
|
13 |
-
protected $wpdb;
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Column constructor.
|
17 |
-
*/
|
18 |
-
public function __construct() {
|
19 |
-
parent::__construct();
|
20 |
-
global $wpdb;
|
21 |
-
$this->wpdb = $wpdb;
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @return Column
|
26 |
-
*/
|
27 |
-
public static function get_instance() {
|
28 |
-
if (null === self::$instance) {
|
29 |
-
self::$instance = new self();
|
30 |
-
}
|
31 |
-
return self::$instance;
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Add column
|
36 |
-
*
|
37 |
-
* @param $columns
|
38 |
-
*
|
39 |
-
* @return array
|
40 |
-
*/
|
41 |
-
public function set_column_columns($columns) {
|
42 |
-
$columns = array_slice($columns, 0, 2, true) + array("mp-column_timeslots_number" => __('Timeslots', 'mp-timetable')) + array_slice($columns, 2, count($columns) - 1, true);
|
43 |
-
|
44 |
-
return $columns;
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Create event category admin link
|
49 |
-
*
|
50 |
-
* @param $column
|
51 |
-
*/
|
52 |
-
public function get_column_columns($column) {
|
53 |
-
|
54 |
-
global $post;
|
55 |
-
|
56 |
-
switch ($column) {
|
57 |
-
case 'mp-column_timeslots_number':
|
58 |
-
$metaData = $this->count_events($post);
|
59 |
-
echo empty($metaData) ? "—" : $metaData;
|
60 |
-
break;
|
61 |
-
}
|
62 |
-
}
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Count events
|
66 |
-
*
|
67 |
-
* @param $post
|
68 |
-
*
|
69 |
-
* @return int
|
70 |
-
*/
|
71 |
-
public function count_events($post) {
|
72 |
-
|
73 |
-
$table_name = $this->get('events')->table_name;
|
74 |
-
$event_ids = $this->wpdb->get_results("SELECT `event_id` FROM {$table_name} WHERE `column_id` = {$post->ID}", ARRAY_A);
|
75 |
-
|
76 |
-
$count = 0;
|
77 |
-
if ( !empty( $event_ids ) ) {
|
78 |
-
foreach( $event_ids as $event ) {
|
79 |
-
$event_id = $event['event_id'];
|
80 |
-
if ( get_post_type( $event_id ) == 'mp-event' ) {
|
81 |
-
$count++;
|
82 |
-
}
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
-
return intval($count);
|
87 |
-
}
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Client area order
|
91 |
-
*
|
92 |
-
* @param object $query
|
93 |
-
*
|
94 |
-
* @return mixed
|
95 |
-
*/
|
96 |
-
public function clientarea_default_order($query) {
|
97 |
-
if (is_admin() || $query->is_main_query()) {
|
98 |
-
if ($query->get('post_type') === 'mp-column') {
|
99 |
-
$query->set('orderby', 'menu_order');
|
100 |
-
$query->set('order', 'ASC');
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
return $query;
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* @param array $params
|
109 |
-
*
|
110 |
-
* @return array
|
111 |
-
*/
|
112 |
-
public function get_all_column($params = array()) {
|
113 |
-
$args = array(
|
114 |
-
'post_type' => 'mp-column',
|
115 |
-
'post_status' => 'publish',
|
116 |
-
'order' => 'ASC',
|
117 |
-
'orderby' => 'menu_order date',
|
118 |
-
'posts_per_page' => -1,
|
119 |
-
'post__in' => ''
|
120 |
-
);
|
121 |
-
|
122 |
-
$args = array_merge($args, $params);
|
123 |
-
return get_posts($args);
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Columns by event category
|
128 |
-
*
|
129 |
-
* @param $terms
|
130 |
-
*
|
131 |
-
* @return array
|
132 |
-
*/
|
133 |
-
public function get_columns_by_event_category($terms) {
|
134 |
-
$columns = array();
|
135 |
-
if (!is_array($terms)) {
|
136 |
-
$terms = explode(',', $terms);
|
137 |
-
}
|
138 |
-
$posts_array = get_posts(
|
139 |
-
array(
|
140 |
-
'fields' => 'ids',
|
141 |
-
'posts_per_page' => -1,
|
142 |
-
'post_type' => 'mp-event',
|
143 |
-
'post_status' => 'publish',
|
144 |
-
'tax_query' => array(
|
145 |
-
array(
|
146 |
-
'taxonomy' => 'mp-event_category',
|
147 |
-
'field' => 'term_id',
|
148 |
-
'terms' => $terms,
|
149 |
-
)
|
150 |
-
)
|
151 |
-
)
|
152 |
-
);
|
153 |
-
$ids = implode(',', $posts_array);
|
154 |
-
$event_data = $this->get('events')->get_events_data(array('column' => 'event_id', 'list' => $ids));
|
155 |
-
if (!empty($event_data)) {
|
156 |
-
foreach ($event_data as $event) {
|
157 |
-
if (in_array($event->event_id, $posts_array)) {
|
158 |
-
$columns[] = $event->column_id;
|
159 |
-
}
|
160 |
-
}
|
161 |
-
}
|
162 |
-
return array_unique($columns);
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* Render column metabox
|
167 |
-
*
|
168 |
-
* @param $post
|
169 |
-
*/
|
170 |
-
public function render_column_options($post) {
|
171 |
-
$this->get_view()->render_html("column/metabox-column-options", array('post' => $post), true);
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Render meta data
|
176 |
-
*/
|
177 |
-
public function render_column_metas() {
|
178 |
-
$this->append_events();
|
179 |
-
}
|
180 |
-
|
181 |
-
public function append_events() {
|
182 |
-
global $post;
|
183 |
-
$data = $this->get('events')->get_event_data(array('field' => 'column_id', 'id' => $post->ID));
|
184 |
-
$events = (!empty($data)) ? $data : array();
|
185 |
-
|
186 |
-
$this->get_view()->get_template("theme/column-events", array('events' => $events));
|
187 |
-
}
|
188 |
-
|
189 |
-
/**
|
190 |
-
* Save meta data Column post type
|
191 |
-
*
|
192 |
-
* @param array $params
|
193 |
-
*/
|
194 |
-
public function save_column_data(array $params) {
|
195 |
-
if (!empty($params['data'])) {
|
196 |
-
foreach ($params['data'] as $meta_key => $meta) {
|
197 |
-
if (!empty($meta)) {
|
198 |
-
update_post_meta($params['post']->ID, $meta_key, $meta);
|
199 |
-
} else {
|
200 |
-
delete_post_meta($params['post']->ID, $meta_key, $meta);
|
201 |
-
}
|
202 |
-
}
|
203 |
-
}
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Delete time-slots of the Column
|
208 |
-
*
|
209 |
-
* @param $post_id
|
210 |
-
*
|
211 |
-
* @return false|int
|
212 |
-
*/
|
213 |
-
public function before_delete_column($post_id) {
|
214 |
-
$table_name = $this->get('events')->table_name;
|
215 |
-
|
216 |
-
return $this->wpdb->delete($table_name, array('column_id' => $post_id), array('%d'));
|
217 |
-
}
|
218 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\classes\models;
|
4 |
+
|
5 |
+
use mp_timetable\plugin_core\classes\Model as Model;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Model Events
|
9 |
+
*/
|
10 |
+
class Column extends Model {
|
11 |
+
|
12 |
+
protected static $instance;
|
13 |
+
protected $wpdb;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Column constructor.
|
17 |
+
*/
|
18 |
+
public function __construct() {
|
19 |
+
parent::__construct();
|
20 |
+
global $wpdb;
|
21 |
+
$this->wpdb = $wpdb;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @return Column
|
26 |
+
*/
|
27 |
+
public static function get_instance() {
|
28 |
+
if (null === self::$instance) {
|
29 |
+
self::$instance = new self();
|
30 |
+
}
|
31 |
+
return self::$instance;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Add column
|
36 |
+
*
|
37 |
+
* @param $columns
|
38 |
+
*
|
39 |
+
* @return array
|
40 |
+
*/
|
41 |
+
public function set_column_columns($columns) {
|
42 |
+
$columns = array_slice($columns, 0, 2, true) + array("mp-column_timeslots_number" => __('Timeslots', 'mp-timetable')) + array_slice($columns, 2, count($columns) - 1, true);
|
43 |
+
|
44 |
+
return $columns;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Create event category admin link
|
49 |
+
*
|
50 |
+
* @param $column
|
51 |
+
*/
|
52 |
+
public function get_column_columns($column) {
|
53 |
+
|
54 |
+
global $post;
|
55 |
+
|
56 |
+
switch ($column) {
|
57 |
+
case 'mp-column_timeslots_number':
|
58 |
+
$metaData = $this->count_events($post);
|
59 |
+
echo empty($metaData) ? "—" : $metaData;
|
60 |
+
break;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Count events
|
66 |
+
*
|
67 |
+
* @param $post
|
68 |
+
*
|
69 |
+
* @return int
|
70 |
+
*/
|
71 |
+
public function count_events($post) {
|
72 |
+
|
73 |
+
$table_name = $this->get('events')->table_name;
|
74 |
+
$event_ids = $this->wpdb->get_results("SELECT `event_id` FROM {$table_name} WHERE `column_id` = {$post->ID}", ARRAY_A);
|
75 |
+
|
76 |
+
$count = 0;
|
77 |
+
if ( !empty( $event_ids ) ) {
|
78 |
+
foreach( $event_ids as $event ) {
|
79 |
+
$event_id = $event['event_id'];
|
80 |
+
if ( get_post_type( $event_id ) == 'mp-event' ) {
|
81 |
+
$count++;
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
return intval($count);
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Client area order
|
91 |
+
*
|
92 |
+
* @param object $query
|
93 |
+
*
|
94 |
+
* @return mixed
|
95 |
+
*/
|
96 |
+
public function clientarea_default_order($query) {
|
97 |
+
if (is_admin() || $query->is_main_query()) {
|
98 |
+
if ($query->get('post_type') === 'mp-column') {
|
99 |
+
$query->set('orderby', 'menu_order');
|
100 |
+
$query->set('order', 'ASC');
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
return $query;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* @param array $params
|
109 |
+
*
|
110 |
+
* @return array
|
111 |
+
*/
|
112 |
+
public function get_all_column($params = array()) {
|
113 |
+
$args = array(
|
114 |
+
'post_type' => 'mp-column',
|
115 |
+
'post_status' => 'publish',
|
116 |
+
'order' => 'ASC',
|
117 |
+
'orderby' => 'menu_order date',
|
118 |
+
'posts_per_page' => -1,
|
119 |
+
'post__in' => ''
|
120 |
+
);
|
121 |
+
|
122 |
+
$args = array_merge($args, $params);
|
123 |
+
return get_posts($args);
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Columns by event category
|
128 |
+
*
|
129 |
+
* @param $terms
|
130 |
+
*
|
131 |
+
* @return array
|
132 |
+
*/
|
133 |
+
public function get_columns_by_event_category($terms) {
|
134 |
+
$columns = array();
|
135 |
+
if (!is_array($terms)) {
|
136 |
+
$terms = explode(',', $terms);
|
137 |
+
}
|
138 |
+
$posts_array = get_posts(
|
139 |
+
array(
|
140 |
+
'fields' => 'ids',
|
141 |
+
'posts_per_page' => -1,
|
142 |
+
'post_type' => 'mp-event',
|
143 |
+
'post_status' => 'publish',
|
144 |
+
'tax_query' => array(
|
145 |
+
array(
|
146 |
+
'taxonomy' => 'mp-event_category',
|
147 |
+
'field' => 'term_id',
|
148 |
+
'terms' => $terms,
|
149 |
+
)
|
150 |
+
)
|
151 |
+
)
|
152 |
+
);
|
153 |
+
$ids = implode(',', $posts_array);
|
154 |
+
$event_data = $this->get('events')->get_events_data(array('column' => 'event_id', 'list' => $ids));
|
155 |
+
if (!empty($event_data)) {
|
156 |
+
foreach ($event_data as $event) {
|
157 |
+
if (in_array($event->event_id, $posts_array)) {
|
158 |
+
$columns[] = $event->column_id;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
return array_unique($columns);
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Render column metabox
|
167 |
+
*
|
168 |
+
* @param $post
|
169 |
+
*/
|
170 |
+
public function render_column_options($post) {
|
171 |
+
$this->get_view()->render_html("column/metabox-column-options", array('post' => $post), true);
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Render meta data
|
176 |
+
*/
|
177 |
+
public function render_column_metas() {
|
178 |
+
$this->append_events();
|
179 |
+
}
|
180 |
+
|
181 |
+
public function append_events() {
|
182 |
+
global $post;
|
183 |
+
$data = $this->get('events')->get_event_data(array('field' => 'column_id', 'id' => $post->ID));
|
184 |
+
$events = (!empty($data)) ? $data : array();
|
185 |
+
|
186 |
+
$this->get_view()->get_template("theme/column-events", array('events' => $events));
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Save meta data Column post type
|
191 |
+
*
|
192 |
+
* @param array $params
|
193 |
+
*/
|
194 |
+
public function save_column_data(array $params) {
|
195 |
+
if (!empty($params['data'])) {
|
196 |
+
foreach ($params['data'] as $meta_key => $meta) {
|
197 |
+
if (!empty($meta)) {
|
198 |
+
update_post_meta($params['post']->ID, $meta_key, $meta);
|
199 |
+
} else {
|
200 |
+
delete_post_meta($params['post']->ID, $meta_key, $meta);
|
201 |
+
}
|
202 |
+
}
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Delete time-slots of the Column
|
208 |
+
*
|
209 |
+
* @param $post_id
|
210 |
+
*
|
211 |
+
* @return false|int
|
212 |
+
*/
|
213 |
+
public function before_delete_column($post_id) {
|
214 |
+
$table_name = $this->get('events')->table_name;
|
215 |
+
|
216 |
+
return $this->wpdb->delete($table_name, array('column_id' => $post_id), array('%d'));
|
217 |
+
}
|
218 |
}
|
classes/models/class-export.php
CHANGED
@@ -1,483 +1,483 @@
|
|
1 |
-
<?php
|
2 |
-
namespace mp_timetable\classes\models;
|
3 |
-
|
4 |
-
use mp_timetable\classes\libs;
|
5 |
-
use mp_timetable\plugin_core\classes\Model as Model;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Export model
|
9 |
-
*/
|
10 |
-
class Export extends Model {
|
11 |
-
protected static $instance;
|
12 |
-
private $table;
|
13 |
-
|
14 |
-
public static function get_instance() {
|
15 |
-
if (null === self::$instance) {
|
16 |
-
self::$instance = new self();
|
17 |
-
}
|
18 |
-
return self::$instance;
|
19 |
-
}
|
20 |
-
|
21 |
-
function __construct() {
|
22 |
-
$this->table = Events::get_instance()->table_name;
|
23 |
-
parent::__construct();
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Export file
|
28 |
-
*/
|
29 |
-
public function export() {
|
30 |
-
|
31 |
-
global $wpdb, $post;
|
32 |
-
|
33 |
-
if ( !defined('ABSPATH') ) exit;
|
34 |
-
|
35 |
-
if ( !current_user_can('export') ) exit;
|
36 |
-
|
37 |
-
if ( !function_exists('export_wp') ) {
|
38 |
-
include_once(ABSPATH . 'wp-admin/includes/export.php');
|
39 |
-
}
|
40 |
-
|
41 |
-
$args = array('content' => $this->post_types, 'author' => false, 'category' => false,
|
42 |
-
'start_date' => false, 'end_date' => false, 'status' => false);
|
43 |
-
|
44 |
-
|
45 |
-
$defaults = array('content' => 'all', 'author' => false, 'category' => false,
|
46 |
-
'start_date' => false, 'end_date' => false, 'status' => false,
|
47 |
-
);
|
48 |
-
$args = wp_parse_args($args, $defaults);
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Fires at the beginning of an export, before any headers are sent.
|
52 |
-
*
|
53 |
-
* @since 2.3.0
|
54 |
-
*
|
55 |
-
* @param array $args An array of export arguments.
|
56 |
-
*/
|
57 |
-
do_action('export_wp', $args);
|
58 |
-
|
59 |
-
$filename = $this->file_name();
|
60 |
-
|
61 |
-
header('Content-Description: File Transfer');
|
62 |
-
header('Content-Disposition: attachment; filename=' . $filename);
|
63 |
-
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
|
64 |
-
|
65 |
-
if ('all' != $args['content'] && post_type_exists($args['content'])) {
|
66 |
-
$ptype = get_post_type_object($args['content']);
|
67 |
-
if (!$ptype->can_export)
|
68 |
-
$args['content'] = 'post';
|
69 |
-
|
70 |
-
$where = $wpdb->prepare("{$wpdb->posts}.post_type = %s", $args['content']);
|
71 |
-
} else {
|
72 |
-
$post_types = get_post_types(array('can_export' => true));
|
73 |
-
$post_types = array_intersect($post_types, $args['content']);
|
74 |
-
$esses = array_fill(0, count($post_types), '%s');
|
75 |
-
$where = $wpdb->prepare("{$wpdb->posts}.post_type IN (" . implode(',', $esses) . ')', $post_types);
|
76 |
-
}
|
77 |
-
|
78 |
-
if ($args['status'] && ('post' == $args['content'] || 'page' == $args['content']))
|
79 |
-
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_status = %s", $args['status']);
|
80 |
-
else
|
81 |
-
$where .= " AND {$wpdb->posts}.post_status != 'auto-draft'";
|
82 |
-
|
83 |
-
$join = '';
|
84 |
-
if ($args['category'] && 'post' == $args['content']) {
|
85 |
-
if ($term = term_exists($args['category'], 'category')) {
|
86 |
-
$join = "INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)";
|
87 |
-
$where .= $wpdb->prepare(" AND {$wpdb->term_relationships}.term_taxonomy_id = %d", $term['term_taxonomy_id']);
|
88 |
-
}
|
89 |
-
}
|
90 |
-
|
91 |
-
if ('post' == $args['content'] || 'page' == $args['content'] || 'attachment' == $args['content']) {
|
92 |
-
if ($args['author'])
|
93 |
-
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_author = %d", $args['author']);
|
94 |
-
|
95 |
-
if ($args['start_date'])
|
96 |
-
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_date >= %s", date('Y-m-d', strtotime($args['start_date'])));
|
97 |
-
|
98 |
-
if ($args['end_date'])
|
99 |
-
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_date < %s", date('Y-m-d', strtotime('+1 month', strtotime($args['end_date']))));
|
100 |
-
}
|
101 |
-
|
102 |
-
// Grab a snapshot of post IDs, just in case it changes during the export.
|
103 |
-
$post_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} $join WHERE $where");
|
104 |
-
|
105 |
-
/*
|
106 |
-
* Get the requested terms ready, empty unless posts filtered by category
|
107 |
-
* or all content.
|
108 |
-
*/
|
109 |
-
$thumbnail_ids = array();
|
110 |
-
foreach ($post_ids as $ID) {
|
111 |
-
$thumbnail_id = get_post_thumbnail_id($ID);
|
112 |
-
if (empty($thumbnail_id)) {
|
113 |
-
continue;
|
114 |
-
}
|
115 |
-
$thumbnail_ids[] = $thumbnail_id;
|
116 |
-
}
|
117 |
-
if (!empty($thumbnail_ids)) {
|
118 |
-
$post_ids = array_merge($post_ids, $thumbnail_ids);
|
119 |
-
}
|
120 |
-
$cats = $tags = $terms = array();
|
121 |
-
|
122 |
-
if (!empty($this->taxonomy_names)) {
|
123 |
-
$custom_taxonomies = get_taxonomies(array('_builtin' => false));
|
124 |
-
$custom_terms = (array)get_terms($this->taxonomy_names, array('get' => 'all'));
|
125 |
-
|
126 |
-
// Put terms in order with no child going before its parent.
|
127 |
-
while ($t = array_shift($custom_terms)) {
|
128 |
-
if ($t->parent == 0 || isset($terms[$t->parent]))
|
129 |
-
$terms[$t->term_id] = $t;
|
130 |
-
else
|
131 |
-
$custom_terms[] = $t;
|
132 |
-
}
|
133 |
-
|
134 |
-
unset($categories, $custom_taxonomies, $custom_terms);
|
135 |
-
}
|
136 |
-
|
137 |
-
add_filter('mptt_export_skip_postmeta', array($this, 'mptt_filter_postmeta'), 10, 2);
|
138 |
-
|
139 |
-
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n"; ?>
|
140 |
-
<?php the_generator('export'); ?>
|
141 |
-
|
142 |
-
<rss version="2.0"
|
143 |
-
xmlns:excerpt="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/excerpt/"
|
144 |
-
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
145 |
-
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
146 |
-
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
147 |
-
xmlns:wp="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/">
|
148 |
-
<channel>
|
149 |
-
<title><?php bloginfo_rss('name'); ?></title>
|
150 |
-
<link><?php bloginfo_rss('url'); ?></link>
|
151 |
-
<description><?php bloginfo_rss('description'); ?></description>
|
152 |
-
<pubDate><?php echo date('D, d M Y H:i:s +0000'); ?></pubDate>
|
153 |
-
<language><?php bloginfo_rss('language'); ?></language>
|
154 |
-
<wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
|
155 |
-
<wp:base_site_url><?php echo $this->mptt_site_url(); ?></wp:base_site_url>
|
156 |
-
<wp:base_blog_url><?php bloginfo_rss('url'); ?></wp:base_blog_url>
|
157 |
-
|
158 |
-
<?php $this->mptt_authors_list($post_ids); ?>
|
159 |
-
<?php foreach ($terms as $t) : ?>
|
160 |
-
<wp:term>
|
161 |
-
<wp:term_id><?php echo $this->mptt_cdata($t->term_id); ?></wp:term_id>
|
162 |
-
<wp:term_taxonomy><?php echo $this->mptt_cdata($t->taxonomy); ?></wp:term_taxonomy>
|
163 |
-
<wp:term_slug><?php echo $this->mptt_cdata($t->slug); ?></wp:term_slug>
|
164 |
-
<wp:term_parent><?php echo $this->mptt_cdata($t->parent ? $terms[$t->parent]->slug : ''); ?></wp:term_parent><?php $this->mptt_term_name($t); ?><?php $this->mptt_term_description($t); ?> </wp:term>
|
165 |
-
<?php endforeach; ?>
|
166 |
-
|
167 |
-
|
168 |
-
<?php
|
169 |
-
/** This action is documented in wp-includes/feed-rss2.php */
|
170 |
-
do_action('rss2_head');
|
171 |
-
?>
|
172 |
-
|
173 |
-
<?php if ($post_ids) {
|
174 |
-
/**
|
175 |
-
* @global WP_Query $wp_query
|
176 |
-
*/
|
177 |
-
global $wp_query;
|
178 |
-
|
179 |
-
// Fake being in the loop.
|
180 |
-
$wp_query->in_the_loop = true;
|
181 |
-
|
182 |
-
// Fetch 20 posts at a time rather than loading the entire table into memory.
|
183 |
-
while ($next_posts = array_splice($post_ids, 0, 20)) {
|
184 |
-
$where = 'WHERE ID IN (' . join(',', $next_posts) . ')';
|
185 |
-
$posts = $wpdb->get_results("SELECT * FROM {$wpdb->posts} $where");
|
186 |
-
|
187 |
-
// Begin Loop.
|
188 |
-
foreach ($posts as $post) {
|
189 |
-
setup_postdata($post);
|
190 |
-
$is_sticky = is_sticky($post->ID) ? 1 : 0; ?>
|
191 |
-
<item>
|
192 |
-
<title><?php
|
193 |
-
/** This filter is documented in wp-includes/feed.php */
|
194 |
-
echo apply_filters('the_title_rss', $post->post_title); ?></title>
|
195 |
-
<link><?php the_permalink_rss() ?></link>
|
196 |
-
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
|
197 |
-
<dc:creator><?php echo $this->mptt_cdata(get_the_author_meta('login')); ?></dc:creator>
|
198 |
-
<guid isPermaLink="false"><?php the_guid(); ?></guid>
|
199 |
-
<description></description>
|
200 |
-
<content:encoded><?php
|
201 |
-
/**
|
202 |
-
* Filter the post content used for WXR exports.
|
203 |
-
*
|
204 |
-
* @since 2.5.0
|
205 |
-
*
|
206 |
-
* @param string $post_content Content of the current post.
|
207 |
-
*/
|
208 |
-
echo $this->mptt_cdata(apply_filters('the_content_export', $post->post_content));
|
209 |
-
?></content:encoded>
|
210 |
-
<excerpt:encoded><?php
|
211 |
-
/**
|
212 |
-
* Filter the post excerpt used for WXR exports.
|
213 |
-
*
|
214 |
-
* @since 2.6.0
|
215 |
-
*
|
216 |
-
* @param string $post_excerpt Excerpt for the current post.
|
217 |
-
*/
|
218 |
-
echo $this->mptt_cdata(apply_filters('the_excerpt_export', $post->post_excerpt));
|
219 |
-
?></excerpt:encoded>
|
220 |
-
<wp:post_id><?php echo intval($post->ID); ?></wp:post_id>
|
221 |
-
<wp:post_date><?php echo $this->mptt_cdata($post->post_date); ?></wp:post_date>
|
222 |
-
<wp:post_date_gmt><?php echo $this->mptt_cdata($post->post_date_gmt); ?></wp:post_date_gmt>
|
223 |
-
<wp:comment_status><?php echo $this->mptt_cdata($post->comment_status); ?></wp:comment_status>
|
224 |
-
<wp:ping_status><?php echo $this->mptt_cdata($post->ping_status); ?></wp:ping_status>
|
225 |
-
<wp:post_name><?php echo $this->mptt_cdata($post->post_name); ?></wp:post_name>
|
226 |
-
<wp:status><?php echo $this->mptt_cdata($post->post_status); ?></wp:status>
|
227 |
-
<wp:post_parent><?php echo intval($post->post_parent); ?></wp:post_parent>
|
228 |
-
<wp:menu_order><?php echo intval($post->menu_order); ?></wp:menu_order>
|
229 |
-
<wp:post_type><?php echo $this->mptt_cdata($post->post_type); ?></wp:post_type>
|
230 |
-
<wp:post_password><?php echo $this->mptt_cdata($post->post_password); ?></wp:post_password>
|
231 |
-
<wp:is_sticky><?php echo intval($is_sticky); ?></wp:is_sticky>
|
232 |
-
<?php if ($post->post_type == 'attachment') : ?>
|
233 |
-
<wp:attachment_url><?php echo $this->mptt_cdata(wp_get_attachment_url($post->ID)); ?></wp:attachment_url>
|
234 |
-
<?php endif; ?>
|
235 |
-
<?php $this->mptt_post_taxonomy(); ?>
|
236 |
-
|
237 |
-
<?php $postmeta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID));
|
238 |
-
foreach ($postmeta as $meta) :
|
239 |
-
/**
|
240 |
-
* Filter whether to selectively skip post meta used for WXR exports.
|
241 |
-
*
|
242 |
-
* Returning a truthy value to the filter will skip the current meta
|
243 |
-
* object from being exported.
|
244 |
-
*
|
245 |
-
* @since 3.3.0
|
246 |
-
*
|
247 |
-
* @param bool $skip Whether to skip the current post meta. Default false.
|
248 |
-
* @param string $meta_key Current meta key.
|
249 |
-
* @param object $meta Current meta object.
|
250 |
-
*/
|
251 |
-
if (apply_filters('mptt_export_skip_postmeta', false, $meta->meta_key, $meta))
|
252 |
-
continue;
|
253 |
-
?>
|
254 |
-
<wp:postmeta>
|
255 |
-
<wp:meta_key><?php echo $this->mptt_cdata($meta->meta_key); ?></wp:meta_key>
|
256 |
-
<wp:meta_value><?php echo $this->mptt_cdata($meta->meta_value); ?></wp:meta_value>
|
257 |
-
</wp:postmeta>
|
258 |
-
<?php endforeach; ?>
|
259 |
-
<?php
|
260 |
-
|
261 |
-
$_comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID));
|
262 |
-
$comments = array_map('get_comment', $_comments);
|
263 |
-
foreach ($comments as $c) : ?>
|
264 |
-
<wp:comment>
|
265 |
-
<wp:comment_id><?php echo intval($c->comment_ID); ?></wp:comment_id>
|
266 |
-
<wp:comment_author><?php echo $this->mptt_cdata($c->comment_author); ?></wp:comment_author>
|
267 |
-
<wp:comment_author_email><?php echo $this->mptt_cdata($c->comment_author_email); ?></wp:comment_author_email>
|
268 |
-
<wp:comment_author_url><?php echo esc_url_raw($c->comment_author_url); ?></wp:comment_author_url>
|
269 |
-
<wp:comment_author_IP><?php echo $this->mptt_cdata($c->comment_author_IP); ?></wp:comment_author_IP>
|
270 |
-
<wp:comment_date><?php echo $this->mptt_cdata($c->comment_date); ?></wp:comment_date>
|
271 |
-
<wp:comment_date_gmt><?php echo $this->mptt_cdata($c->comment_date_gmt); ?></wp:comment_date_gmt>
|
272 |
-
<wp:comment_content><?php echo $this->mptt_cdata($c->comment_content) ?></wp:comment_content>
|
273 |
-
<wp:comment_approved><?php echo $this->mptt_cdata($c->comment_approved); ?></wp:comment_approved>
|
274 |
-
<wp:comment_type><?php echo $this->mptt_cdata($c->comment_type); ?></wp:comment_type>
|
275 |
-
<wp:comment_parent><?php echo intval($c->comment_parent); ?></wp:comment_parent>
|
276 |
-
<wp:comment_user_id><?php echo intval($c->user_id); ?></wp:comment_user_id>
|
277 |
-
<?php $c_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID));
|
278 |
-
foreach ($c_meta as $meta) :
|
279 |
-
/**
|
280 |
-
* Filter whether to selectively skip comment meta used for WXR exports.
|
281 |
-
*
|
282 |
-
* Returning a truthy value to the filter will skip the current meta
|
283 |
-
* object from being exported.
|
284 |
-
*
|
285 |
-
* @since 4.0.0
|
286 |
-
*
|
287 |
-
* @param bool $skip Whether to skip the current comment meta. Default false.
|
288 |
-
* @param string $meta_key Current meta key.
|
289 |
-
* @param object $meta Current meta object.
|
290 |
-
*/
|
291 |
-
if (apply_filters('mptt_export_skip_commentmeta', false, $meta->meta_key, $meta)) {
|
292 |
-
continue;
|
293 |
-
}
|
294 |
-
?>
|
295 |
-
<wp:commentmeta>
|
296 |
-
<wp:meta_key><?php echo $this->mptt_cdata($meta->meta_key); ?></wp:meta_key>
|
297 |
-
<wp:meta_value><?php echo $this->mptt_cdata($meta->meta_value); ?></wp:meta_value>
|
298 |
-
</wp:commentmeta>
|
299 |
-
<?php endforeach; ?>
|
300 |
-
</wp:comment>
|
301 |
-
<?php endforeach; ?>
|
302 |
-
</item>
|
303 |
-
<?php
|
304 |
-
}
|
305 |
-
}
|
306 |
-
|
307 |
-
}
|
308 |
-
$time_slots = $wpdb->get_results("SELECT * FROM $this->table WHERE 1");
|
309 |
-
if (!empty($time_slots)) {
|
310 |
-
foreach ($time_slots as $time_slot) : ?>
|
311 |
-
<timeslot>
|
312 |
-
<column><?php echo $this->mptt_cdata($time_slot->column_id); ?></column>
|
313 |
-
<event><?php echo $this->mptt_cdata($time_slot->event_id); ?></event>
|
314 |
-
<event_start><?php echo $this->mptt_cdata($time_slot->event_start); ?></event_start>
|
315 |
-
<event_end><?php echo $this->mptt_cdata($time_slot->event_end); ?></event_end>
|
316 |
-
<user_id><?php echo $this->mptt_cdata($time_slot->user_id); ?></user_id>
|
317 |
-
<description><?php echo $this->mptt_cdata($time_slot->description); ?></description>
|
318 |
-
</timeslot>
|
319 |
-
<?php endforeach;
|
320 |
-
}
|
321 |
-
?>
|
322 |
-
</channel>
|
323 |
-
</rss>
|
324 |
-
<?php
|
325 |
-
}
|
326 |
-
|
327 |
-
/**
|
328 |
-
* Generate file name
|
329 |
-
* @return mixed|void
|
330 |
-
*/
|
331 |
-
public function file_name() {
|
332 |
-
$sitename = sanitize_key(get_bloginfo('name'));
|
333 |
-
if (!empty($sitename)) {
|
334 |
-
$sitename .= '_';
|
335 |
-
}
|
336 |
-
$date = date('d.m.Y_H.i', time());
|
337 |
-
|
338 |
-
$wp_filename = $sitename . 'timetable_' . $date . '.xml';
|
339 |
-
/**
|
340 |
-
* Filter the export filename.
|
341 |
-
*
|
342 |
-
* @since 4.4.0
|
343 |
-
*
|
344 |
-
* @param string $wp_filename The name of the file for download.
|
345 |
-
* @param string $sitename The site name.
|
346 |
-
* @param string $date Today's date, formatted.
|
347 |
-
*/
|
348 |
-
$filename = apply_filters('export_wp_filename', $wp_filename, $sitename, $date);
|
349 |
-
return $filename;
|
350 |
-
}
|
351 |
-
|
352 |
-
/**
|
353 |
-
* Output list of authors with posts
|
354 |
-
*
|
355 |
-
* @since 3.1.0
|
356 |
-
*
|
357 |
-
* @global wpdb $wpdb WordPress database abstraction object.
|
358 |
-
*
|
359 |
-
* @param array $post_ids Array of post IDs to filter the query by. Optional.
|
360 |
-
*/
|
361 |
-
public function mptt_authors_list(array $post_ids = null) {
|
362 |
-
global $wpdb;
|
363 |
-
|
364 |
-
if (!empty($post_ids)) {
|
365 |
-
$post_ids = array_map('absint', $post_ids);
|
366 |
-
$and = 'AND ID IN ( ' . implode(', ', $post_ids) . ')';
|
367 |
-
} else {
|
368 |
-
$and = '';
|
369 |
-
}
|
370 |
-
|
371 |
-
$authors = array();
|
372 |
-
$results = $wpdb->get_results("SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft' $and");
|
373 |
-
foreach ((array)$results as $result)
|
374 |
-
$authors[] = get_userdata($result->post_author);
|
375 |
-
|
376 |
-
$authors = array_filter($authors);
|
377 |
-
|
378 |
-
foreach ($authors as $author) {
|
379 |
-
echo "\t<wp:author>";
|
380 |
-
echo '<wp:author_id>' . intval($author->ID) . '</wp:author_id>';
|
381 |
-
echo '<wp:author_login>' . $this->mptt_cdata($author->user_login) . '</wp:author_login>';
|
382 |
-
echo '<wp:author_email>' . $this->mptt_cdata($author->user_email) . '</wp:author_email>';
|
383 |
-
echo '<wp:author_display_name>' . $this->mptt_cdata($author->display_name) . '</wp:author_display_name>';
|
384 |
-
echo '<wp:author_first_name>' . $this->mptt_cdata($author->first_name) . '</wp:author_first_name>';
|
385 |
-
echo '<wp:author_last_name>' . $this->mptt_cdata($author->last_name) . '</wp:author_last_name>';
|
386 |
-
echo "</wp:author>\n";
|
387 |
-
}
|
388 |
-
}
|
389 |
-
|
390 |
-
/**
|
391 |
-
* Return the URL of the site
|
392 |
-
*
|
393 |
-
* @since 2.5.0
|
394 |
-
*
|
395 |
-
* @return string Site URL.
|
396 |
-
*/
|
397 |
-
public function mptt_site_url() {
|
398 |
-
// Multisite: the base URL.
|
399 |
-
if (is_multisite())
|
400 |
-
return network_home_url();
|
401 |
-
// WordPress (single site): the blog URL.
|
402 |
-
else
|
403 |
-
return get_bloginfo_rss('url');
|
404 |
-
}
|
405 |
-
|
406 |
-
/**
|
407 |
-
* Output a term_description XML tag from a given term object
|
408 |
-
*
|
409 |
-
* @since 2.9.0
|
410 |
-
*
|
411 |
-
* @param object $term Term Object
|
412 |
-
*/
|
413 |
-
public function mptt_term_description($term) {
|
414 |
-
if (empty($term->description))
|
415 |
-
return;
|
416 |
-
|
417 |
-
echo '<wp:term_description>' . $this->mptt_cdata($term->description) . '</wp:term_description>';
|
418 |
-
}
|
419 |
-
|
420 |
-
/**
|
421 |
-
* Output a term_name XML tag from a given term object
|
422 |
-
*
|
423 |
-
* @since 2.9.0
|
424 |
-
*
|
425 |
-
* @param object $term Term Object
|
426 |
-
*/
|
427 |
-
public function mptt_term_name($term) {
|
428 |
-
if (empty($term->name))
|
429 |
-
return;
|
430 |
-
|
431 |
-
echo '<wp:term_name>' . $this->mptt_cdata($term->name) . '</wp:term_name>';
|
432 |
-
}
|
433 |
-
|
434 |
-
/**
|
435 |
-
* Wrap given string in XML CDATA tag.
|
436 |
-
*
|
437 |
-
* @since 2.1.0
|
438 |
-
*
|
439 |
-
* @param string $str String to wrap in XML CDATA tag.
|
440 |
-
*
|
441 |
-
* @return string
|
442 |
-
*/
|
443 |
-
public function mptt_cdata($str) {
|
444 |
-
if (!seems_utf8($str)) {
|
445 |
-
$str = utf8_encode($str);
|
446 |
-
}
|
447 |
-
// $str = ent2ncr(esc_html($str));
|
448 |
-
$str = '<![CDATA[' . str_replace(']]>', ']]]]><![CDATA[>', $str) . ']]>';
|
449 |
-
|
450 |
-
return $str;
|
451 |
-
}
|
452 |
-
|
453 |
-
/**
|
454 |
-
*
|
455 |
-
* @param bool $return_me
|
456 |
-
* @param string $meta_key
|
457 |
-
*
|
458 |
-
* @return bool
|
459 |
-
*/
|
460 |
-
public function mptt_filter_postmeta($return_me, $meta_key) {
|
461 |
-
if ('_edit_lock' == $meta_key)
|
462 |
-
$return_me = true;
|
463 |
-
return $return_me;
|
464 |
-
}
|
465 |
-
|
466 |
-
/**
|
467 |
-
* Output list of taxonomy terms, in XML tag format, associated with a post
|
468 |
-
*
|
469 |
-
* @since 2.3.0
|
470 |
-
*/
|
471 |
-
public function mptt_post_taxonomy() {
|
472 |
-
$post = get_post();
|
473 |
-
|
474 |
-
$taxonomies = get_object_taxonomies($post->post_type);
|
475 |
-
if (empty($taxonomies))
|
476 |
-
return;
|
477 |
-
$terms = wp_get_object_terms($post->ID, $taxonomies);
|
478 |
-
|
479 |
-
foreach ((array)$terms as $term) {
|
480 |
-
echo "\t\t<category domain=\"{$term->taxonomy}\" nicename=\"{$term->slug}\">" . $this->mptt_cdata($term->name) . "</category>\n";
|
481 |
-
}
|
482 |
-
}
|
483 |
}
|
1 |
+
<?php
|
2 |
+
namespace mp_timetable\classes\models;
|
3 |
+
|
4 |
+
use mp_timetable\classes\libs;
|
5 |
+
use mp_timetable\plugin_core\classes\Model as Model;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Export model
|
9 |
+
*/
|
10 |
+
class Export extends Model {
|
11 |
+
protected static $instance;
|
12 |
+
private $table;
|
13 |
+
|
14 |
+
public static function get_instance() {
|
15 |
+
if (null === self::$instance) {
|
16 |
+
self::$instance = new self();
|
17 |
+
}
|
18 |
+
return self::$instance;
|
19 |
+
}
|
20 |
+
|
21 |
+
function __construct() {
|
22 |
+
$this->table = Events::get_instance()->table_name;
|
23 |
+
parent::__construct();
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Export file
|
28 |
+
*/
|
29 |
+
public function export() {
|
30 |
+
|
31 |
+
global $wpdb, $post;
|
32 |
+
|
33 |
+
if ( !defined('ABSPATH') ) exit;
|
34 |
+
|
35 |
+
if ( !current_user_can('export') ) exit;
|
36 |
+
|
37 |
+
if ( !function_exists('export_wp') ) {
|
38 |
+
include_once(ABSPATH . 'wp-admin/includes/export.php');
|
39 |
+
}
|
40 |
+
|
41 |
+
$args = array('content' => $this->post_types, 'author' => false, 'category' => false,
|
42 |
+
'start_date' => false, 'end_date' => false, 'status' => false);
|
43 |
+
|
44 |
+
|
45 |
+
$defaults = array('content' => 'all', 'author' => false, 'category' => false,
|
46 |
+
'start_date' => false, 'end_date' => false, 'status' => false,
|
47 |
+
);
|
48 |
+
$args = wp_parse_args($args, $defaults);
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Fires at the beginning of an export, before any headers are sent.
|
52 |
+
*
|
53 |
+
* @since 2.3.0
|
54 |
+
*
|
55 |
+
* @param array $args An array of export arguments.
|
56 |
+
*/
|
57 |
+
do_action('export_wp', $args);
|
58 |
+
|
59 |
+
$filename = $this->file_name();
|
60 |
+
|
61 |
+
header('Content-Description: File Transfer');
|
62 |
+
header('Content-Disposition: attachment; filename=' . $filename);
|
63 |
+
header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
|
64 |
+
|
65 |
+
if ('all' != $args['content'] && post_type_exists($args['content'])) {
|
66 |
+
$ptype = get_post_type_object($args['content']);
|
67 |
+
if (!$ptype->can_export)
|
68 |
+
$args['content'] = 'post';
|
69 |
+
|
70 |
+
$where = $wpdb->prepare("{$wpdb->posts}.post_type = %s", $args['content']);
|
71 |
+
} else {
|
72 |
+
$post_types = get_post_types(array('can_export' => true));
|
73 |
+
$post_types = array_intersect($post_types, $args['content']);
|
74 |
+
$esses = array_fill(0, count($post_types), '%s');
|
75 |
+
$where = $wpdb->prepare("{$wpdb->posts}.post_type IN (" . implode(',', $esses) . ')', $post_types);
|
76 |
+
}
|
77 |
+
|
78 |
+
if ($args['status'] && ('post' == $args['content'] || 'page' == $args['content']))
|
79 |
+
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_status = %s", $args['status']);
|
80 |
+
else
|
81 |
+
$where .= " AND {$wpdb->posts}.post_status != 'auto-draft'";
|
82 |
+
|
83 |
+
$join = '';
|
84 |
+
if ($args['category'] && 'post' == $args['content']) {
|
85 |
+
if ($term = term_exists($args['category'], 'category')) {
|
86 |
+
$join = "INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)";
|
87 |
+
$where .= $wpdb->prepare(" AND {$wpdb->term_relationships}.term_taxonomy_id = %d", $term['term_taxonomy_id']);
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
if ('post' == $args['content'] || 'page' == $args['content'] || 'attachment' == $args['content']) {
|
92 |
+
if ($args['author'])
|
93 |
+
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_author = %d", $args['author']);
|
94 |
+
|
95 |
+
if ($args['start_date'])
|
96 |
+
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_date >= %s", date('Y-m-d', strtotime($args['start_date'])));
|
97 |
+
|
98 |
+
if ($args['end_date'])
|
99 |
+
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_date < %s", date('Y-m-d', strtotime('+1 month', strtotime($args['end_date']))));
|
100 |
+
}
|
101 |
+
|
102 |
+
// Grab a snapshot of post IDs, just in case it changes during the export.
|
103 |
+
$post_ids = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} $join WHERE $where");
|
104 |
+
|
105 |
+
/*
|
106 |
+
* Get the requested terms ready, empty unless posts filtered by category
|
107 |
+
* or all content.
|
108 |
+
*/
|
109 |
+
$thumbnail_ids = array();
|
110 |
+
foreach ($post_ids as $ID) {
|
111 |
+
$thumbnail_id = get_post_thumbnail_id($ID);
|
112 |
+
if (empty($thumbnail_id)) {
|
113 |
+
continue;
|
114 |
+
}
|
115 |
+
$thumbnail_ids[] = $thumbnail_id;
|
116 |
+
}
|
117 |
+
if (!empty($thumbnail_ids)) {
|
118 |
+
$post_ids = array_merge($post_ids, $thumbnail_ids);
|
119 |
+
}
|
120 |
+
$cats = $tags = $terms = array();
|
121 |
+
|
122 |
+
if (!empty($this->taxonomy_names)) {
|
123 |
+
$custom_taxonomies = get_taxonomies(array('_builtin' => false));
|
124 |
+
$custom_terms = (array)get_terms($this->taxonomy_names, array('get' => 'all'));
|
125 |
+
|
126 |
+
// Put terms in order with no child going before its parent.
|
127 |
+
while ($t = array_shift($custom_terms)) {
|
128 |
+
if ($t->parent == 0 || isset($terms[$t->parent]))
|
129 |
+
$terms[$t->term_id] = $t;
|
130 |
+
else
|
131 |
+
$custom_terms[] = $t;
|
132 |
+
}
|
133 |
+
|
134 |
+
unset($categories, $custom_taxonomies, $custom_terms);
|
135 |
+
}
|
136 |
+
|
137 |
+
add_filter('mptt_export_skip_postmeta', array($this, 'mptt_filter_postmeta'), 10, 2);
|
138 |
+
|
139 |
+
echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n"; ?>
|
140 |
+
<?php the_generator('export'); ?>
|
141 |
+
|
142 |
+
<rss version="2.0"
|
143 |
+
xmlns:excerpt="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/excerpt/"
|
144 |
+
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
145 |
+
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
146 |
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
147 |
+
xmlns:wp="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/">
|
148 |
+
<channel>
|
149 |
+
<title><?php bloginfo_rss('name'); ?></title>
|
150 |
+
<link><?php bloginfo_rss('url'); ?></link>
|
151 |
+
<description><?php bloginfo_rss('description'); ?></description>
|
152 |
+
<pubDate><?php echo date('D, d M Y H:i:s +0000'); ?></pubDate>
|
153 |
+
<language><?php bloginfo_rss('language'); ?></language>
|
154 |
+
<wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
|
155 |
+
<wp:base_site_url><?php echo $this->mptt_site_url(); ?></wp:base_site_url>
|
156 |
+
<wp:base_blog_url><?php bloginfo_rss('url'); ?></wp:base_blog_url>
|
157 |
+
|
158 |
+
<?php $this->mptt_authors_list($post_ids); ?>
|
159 |
+
<?php foreach ($terms as $t) : ?>
|
160 |
+
<wp:term>
|
161 |
+
<wp:term_id><?php echo $this->mptt_cdata($t->term_id); ?></wp:term_id>
|
162 |
+
<wp:term_taxonomy><?php echo $this->mptt_cdata($t->taxonomy); ?></wp:term_taxonomy>
|
163 |
+
<wp:term_slug><?php echo $this->mptt_cdata($t->slug); ?></wp:term_slug>
|
164 |
+
<wp:term_parent><?php echo $this->mptt_cdata($t->parent ? $terms[$t->parent]->slug : ''); ?></wp:term_parent><?php $this->mptt_term_name($t); ?><?php $this->mptt_term_description($t); ?> </wp:term>
|
165 |
+
<?php endforeach; ?>
|
166 |
+
|
167 |
+
|
168 |
+
<?php
|
169 |
+
/** This action is documented in wp-includes/feed-rss2.php */
|
170 |
+
do_action('rss2_head');
|
171 |
+
?>
|
172 |
+
|
173 |
+
<?php if ($post_ids) {
|
174 |
+
/**
|
175 |
+
* @global WP_Query $wp_query
|
176 |
+
*/
|
177 |
+
global $wp_query;
|
178 |
+
|
179 |
+
// Fake being in the loop.
|
180 |
+
$wp_query->in_the_loop = true;
|
181 |
+
|
182 |
+
// Fetch 20 posts at a time rather than loading the entire table into memory.
|
183 |
+
while ($next_posts = array_splice($post_ids, 0, 20)) {
|
184 |
+
$where = 'WHERE ID IN (' . join(',', $next_posts) . ')';
|
185 |
+
$posts = $wpdb->get_results("SELECT * FROM {$wpdb->posts} $where");
|
186 |
+
|
187 |
+
// Begin Loop.
|
188 |
+
foreach ($posts as $post) {
|
189 |
+
setup_postdata($post);
|
190 |
+
$is_sticky = is_sticky($post->ID) ? 1 : 0; ?>
|
191 |
+
<item>
|
192 |
+
<title><?php
|
193 |
+
/** This filter is documented in wp-includes/feed.php */
|
194 |
+
echo apply_filters('the_title_rss', $post->post_title); ?></title>
|
195 |
+
<link><?php the_permalink_rss() ?></link>
|
196 |
+
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
|
197 |
+
<dc:creator><?php echo $this->mptt_cdata(get_the_author_meta('login')); ?></dc:creator>
|
198 |
+
<guid isPermaLink="false"><?php the_guid(); ?></guid>
|
199 |
+
<description></description>
|
200 |
+
<content:encoded><?php
|
201 |
+
/**
|
202 |
+
* Filter the post content used for WXR exports.
|
203 |
+
*
|
204 |
+
* @since 2.5.0
|
205 |
+
*
|
206 |
+
* @param string $post_content Content of the current post.
|
207 |
+
*/
|
208 |
+
echo $this->mptt_cdata(apply_filters('the_content_export', $post->post_content));
|
209 |
+
?></content:encoded>
|
210 |
+
<excerpt:encoded><?php
|
211 |
+
/**
|
212 |
+
* Filter the post excerpt used for WXR exports.
|
213 |
+
*
|
214 |
+
* @since 2.6.0
|
215 |
+
*
|
216 |
+
* @param string $post_excerpt Excerpt for the current post.
|
217 |
+
*/
|
218 |
+
echo $this->mptt_cdata(apply_filters('the_excerpt_export', $post->post_excerpt));
|
219 |
+
?></excerpt:encoded>
|
220 |
+
<wp:post_id><?php echo intval($post->ID); ?></wp:post_id>
|
221 |
+
<wp:post_date><?php echo $this->mptt_cdata($post->post_date); ?></wp:post_date>
|
222 |
+
<wp:post_date_gmt><?php echo $this->mptt_cdata($post->post_date_gmt); ?></wp:post_date_gmt>
|
223 |
+
<wp:comment_status><?php echo $this->mptt_cdata($post->comment_status); ?></wp:comment_status>
|
224 |
+
<wp:ping_status><?php echo $this->mptt_cdata($post->ping_status); ?></wp:ping_status>
|
225 |
+
<wp:post_name><?php echo $this->mptt_cdata($post->post_name); ?></wp:post_name>
|
226 |
+
<wp:status><?php echo $this->mptt_cdata($post->post_status); ?></wp:status>
|
227 |
+
<wp:post_parent><?php echo intval($post->post_parent); ?></wp:post_parent>
|
228 |
+
<wp:menu_order><?php echo intval($post->menu_order); ?></wp:menu_order>
|
229 |
+
<wp:post_type><?php echo $this->mptt_cdata($post->post_type); ?></wp:post_type>
|
230 |
+
<wp:post_password><?php echo $this->mptt_cdata($post->post_password); ?></wp:post_password>
|
231 |
+
<wp:is_sticky><?php echo intval($is_sticky); ?></wp:is_sticky>
|
232 |
+
<?php if ($post->post_type == 'attachment') : ?>
|
233 |
+
<wp:attachment_url><?php echo $this->mptt_cdata(wp_get_attachment_url($post->ID)); ?></wp:attachment_url>
|
234 |
+
<?php endif; ?>
|
235 |
+
<?php $this->mptt_post_taxonomy(); ?>
|
236 |
+
|
237 |
+
<?php $postmeta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID));
|
238 |
+
foreach ($postmeta as $meta) :
|
239 |
+
/**
|
240 |
+
* Filter whether to selectively skip post meta used for WXR exports.
|
241 |
+
*
|
242 |
+
* Returning a truthy value to the filter will skip the current meta
|
243 |
+
* object from being exported.
|
244 |
+
*
|
245 |
+
* @since 3.3.0
|
246 |
+
*
|
247 |
+
* @param bool $skip Whether to skip the current post meta. Default false.
|
248 |
+
* @param string $meta_key Current meta key.
|
249 |
+
* @param object $meta Current meta object.
|
250 |
+
*/
|
251 |
+
if (apply_filters('mptt_export_skip_postmeta', false, $meta->meta_key, $meta))
|
252 |
+
continue;
|
253 |
+
?>
|
254 |
+
<wp:postmeta>
|
255 |
+
<wp:meta_key><?php echo $this->mptt_cdata($meta->meta_key); ?></wp:meta_key>
|
256 |
+
<wp:meta_value><?php echo $this->mptt_cdata($meta->meta_value); ?></wp:meta_value>
|
257 |
+
</wp:postmeta>
|
258 |
+
<?php endforeach; ?>
|
259 |
+
<?php
|
260 |
+
|
261 |
+
$_comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID));
|
262 |
+
$comments = array_map('get_comment', $_comments);
|
263 |
+
foreach ($comments as $c) : ?>
|
264 |
+
<wp:comment>
|
265 |
+
<wp:comment_id><?php echo intval($c->comment_ID); ?></wp:comment_id>
|
266 |
+
<wp:comment_author><?php echo $this->mptt_cdata($c->comment_author); ?></wp:comment_author>
|
267 |
+
<wp:comment_author_email><?php echo $this->mptt_cdata($c->comment_author_email); ?></wp:comment_author_email>
|
268 |
+
<wp:comment_author_url><?php echo esc_url_raw($c->comment_author_url); ?></wp:comment_author_url>
|
269 |
+
<wp:comment_author_IP><?php echo $this->mptt_cdata($c->comment_author_IP); ?></wp:comment_author_IP>
|
270 |
+
<wp:comment_date><?php echo $this->mptt_cdata($c->comment_date); ?></wp:comment_date>
|
271 |
+
<wp:comment_date_gmt><?php echo $this->mptt_cdata($c->comment_date_gmt); ?></wp:comment_date_gmt>
|
272 |
+
<wp:comment_content><?php echo $this->mptt_cdata($c->comment_content) ?></wp:comment_content>
|
273 |
+
<wp:comment_approved><?php echo $this->mptt_cdata($c->comment_approved); ?></wp:comment_approved>
|
274 |
+
<wp:comment_type><?php echo $this->mptt_cdata($c->comment_type); ?></wp:comment_type>
|
275 |
+
<wp:comment_parent><?php echo intval($c->comment_parent); ?></wp:comment_parent>
|
276 |
+
<wp:comment_user_id><?php echo intval($c->user_id); ?></wp:comment_user_id>
|
277 |
+
<?php $c_meta = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID));
|
278 |
+
foreach ($c_meta as $meta) :
|
279 |
+
/**
|
280 |
+
* Filter whether to selectively skip comment meta used for WXR exports.
|
281 |
+
*
|
282 |
+
* Returning a truthy value to the filter will skip the current meta
|
283 |
+
* object from being exported.
|
284 |
+
*
|
285 |
+
* @since 4.0.0
|
286 |
+
*
|
287 |
+
* @param bool $skip Whether to skip the current comment meta. Default false.
|
288 |
+
* @param string $meta_key Current meta key.
|
289 |
+
* @param object $meta Current meta object.
|
290 |
+
*/
|
291 |
+
if (apply_filters('mptt_export_skip_commentmeta', false, $meta->meta_key, $meta)) {
|
292 |
+
continue;
|
293 |
+
}
|
294 |
+
?>
|
295 |
+
<wp:commentmeta>
|
296 |
+
<wp:meta_key><?php echo $this->mptt_cdata($meta->meta_key); ?></wp:meta_key>
|
297 |
+
<wp:meta_value><?php echo $this->mptt_cdata($meta->meta_value); ?></wp:meta_value>
|
298 |
+
</wp:commentmeta>
|
299 |
+
<?php endforeach; ?>
|
300 |
+
</wp:comment>
|
301 |
+
<?php endforeach; ?>
|
302 |
+
</item>
|
303 |
+
<?php
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
}
|
308 |
+
$time_slots = $wpdb->get_results("SELECT * FROM $this->table WHERE 1");
|
309 |
+
if (!empty($time_slots)) {
|
310 |
+
foreach ($time_slots as $time_slot) : ?>
|
311 |
+
<timeslot>
|
312 |
+
<column><?php echo $this->mptt_cdata($time_slot->column_id); ?></column>
|
313 |
+
<event><?php echo $this->mptt_cdata($time_slot->event_id); ?></event>
|
314 |
+
<event_start><?php echo $this->mptt_cdata($time_slot->event_start); ?></event_start>
|
315 |
+
<event_end><?php echo $this->mptt_cdata($time_slot->event_end); ?></event_end>
|
316 |
+
<user_id><?php echo $this->mptt_cdata($time_slot->user_id); ?></user_id>
|
317 |
+
<description><?php echo $this->mptt_cdata($time_slot->description); ?></description>
|
318 |
+
</timeslot>
|
319 |
+
<?php endforeach;
|
320 |
+
}
|
321 |
+
?>
|
322 |
+
</channel>
|
323 |
+
</rss>
|
324 |
+
<?php
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Generate file name
|
329 |
+
* @return mixed|void
|
330 |
+
*/
|
331 |
+
public function file_name() {
|
332 |
+
$sitename = sanitize_key(get_bloginfo('name'));
|
333 |
+
if (!empty($sitename)) {
|
334 |
+
$sitename .= '_';
|
335 |
+
}
|
336 |
+
$date = date('d.m.Y_H.i', time());
|
337 |
+
|
338 |
+
$wp_filename = $sitename . 'timetable_' . $date . '.xml';
|
339 |
+
/**
|
340 |
+
* Filter the export filename.
|
341 |
+
*
|
342 |
+
* @since 4.4.0
|
343 |
+
*
|
344 |
+
* @param string $wp_filename The name of the file for download.
|
345 |
+
* @param string $sitename The site name.
|
346 |
+
* @param string $date Today's date, formatted.
|
347 |
+
*/
|
348 |
+
$filename = apply_filters('export_wp_filename', $wp_filename, $sitename, $date);
|
349 |
+
return $filename;
|
350 |
+
}
|
351 |
+
|
352 |
+
/**
|
353 |
+
* Output list of authors with posts
|
354 |
+
*
|
355 |
+
* @since 3.1.0
|
356 |
+
*
|
357 |
+
* @global wpdb $wpdb WordPress database abstraction object.
|
358 |
+
*
|
359 |
+
* @param array $post_ids Array of post IDs to filter the query by. Optional.
|
360 |
+
*/
|
361 |
+
public function mptt_authors_list(array $post_ids = null) {
|
362 |
+
global $wpdb;
|
363 |
+
|
364 |
+
if (!empty($post_ids)) {
|
365 |
+
$post_ids = array_map('absint', $post_ids);
|
366 |
+
$and = 'AND ID IN ( ' . implode(', ', $post_ids) . ')';
|
367 |
+
} else {
|
368 |
+
$and = '';
|
369 |
+
}
|
370 |
+
|
371 |
+
$authors = array();
|
372 |
+
$results = $wpdb->get_results("SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft' $and");
|
373 |
+
foreach ((array)$results as $result)
|
374 |
+
$authors[] = get_userdata($result->post_author);
|
375 |
+
|
376 |
+
$authors = array_filter($authors);
|
377 |
+
|
378 |
+
foreach ($authors as $author) {
|
379 |
+
echo "\t<wp:author>";
|
380 |
+
echo '<wp:author_id>' . intval($author->ID) . '</wp:author_id>';
|
381 |
+
echo '<wp:author_login>' . $this->mptt_cdata($author->user_login) . '</wp:author_login>';
|
382 |
+
echo '<wp:author_email>' . $this->mptt_cdata($author->user_email) . '</wp:author_email>';
|
383 |
+
echo '<wp:author_display_name>' . $this->mptt_cdata($author->display_name) . '</wp:author_display_name>';
|
384 |
+
echo '<wp:author_first_name>' . $this->mptt_cdata($author->first_name) . '</wp:author_first_name>';
|
385 |
+
echo '<wp:author_last_name>' . $this->mptt_cdata($author->last_name) . '</wp:author_last_name>';
|
386 |
+
echo "</wp:author>\n";
|
387 |
+
}
|
388 |
+
}
|
389 |
+
|
390 |
+
/**
|
391 |
+
* Return the URL of the site
|
392 |
+
*
|
393 |
+
* @since 2.5.0
|
394 |
+
*
|
395 |
+
* @return string Site URL.
|
396 |
+
*/
|
397 |
+
public function mptt_site_url() {
|
398 |
+
// Multisite: the base URL.
|
399 |
+
if (is_multisite())
|
400 |
+
return network_home_url();
|
401 |
+
// WordPress (single site): the blog URL.
|
402 |
+
else
|
403 |
+
return get_bloginfo_rss('url');
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* Output a term_description XML tag from a given term object
|
408 |
+
*
|
409 |
+
* @since 2.9.0
|
410 |
+
*
|
411 |
+
* @param object $term Term Object
|
412 |
+
*/
|
413 |
+
public function mptt_term_description($term) {
|
414 |
+
if (empty($term->description))
|
415 |
+
return;
|
416 |
+
|
417 |
+
echo '<wp:term_description>' . $this->mptt_cdata($term->description) . '</wp:term_description>';
|
418 |
+
}
|
419 |
+
|
420 |
+
/**
|
421 |
+
* Output a term_name XML tag from a given term object
|
422 |
+
*
|
423 |
+
* @since 2.9.0
|
424 |
+
*
|
425 |
+
* @param object $term Term Object
|
426 |
+
*/
|
427 |
+
public function mptt_term_name($term) {
|
428 |
+
if (empty($term->name))
|
429 |
+
return;
|
430 |
+
|
431 |
+
echo '<wp:term_name>' . $this->mptt_cdata($term->name) . '</wp:term_name>';
|
432 |
+
}
|
433 |
+
|
434 |
+
/**
|
435 |
+
* Wrap given string in XML CDATA tag.
|
436 |
+
*
|
437 |
+
* @since 2.1.0
|
438 |
+
*
|
439 |
+
* @param string $str String to wrap in XML CDATA tag.
|
440 |
+
*
|
441 |
+
* @return string
|
442 |
+
*/
|
443 |
+
public function mptt_cdata($str) {
|
444 |
+
if (!seems_utf8($str)) {
|
445 |
+
$str = utf8_encode($str);
|
446 |
+
}
|
447 |
+
// $str = ent2ncr(esc_html($str));
|
448 |
+
$str = '<![CDATA[' . str_replace(']]>', ']]]]><![CDATA[>', $str) . ']]>';
|
449 |
+
|
450 |
+
return $str;
|
451 |
+
}
|
452 |
+
|
453 |
+
/**
|
454 |
+
*
|
455 |
+
* @param bool $return_me
|
456 |
+
* @param string $meta_key
|
457 |
+
*
|
458 |
+
* @return bool
|
459 |
+
*/
|
460 |
+
public function mptt_filter_postmeta($return_me, $meta_key) {
|
461 |
+
if ('_edit_lock' == $meta_key)
|
462 |
+
$return_me = true;
|
463 |
+
return $return_me;
|
464 |
+
}
|
465 |
+
|
466 |
+
/**
|
467 |
+
* Output list of taxonomy terms, in XML tag format, associated with a post
|
468 |
+
*
|
469 |
+
* @since 2.3.0
|
470 |
+
*/
|
471 |
+
public function mptt_post_taxonomy() {
|
472 |
+
$post = get_post();
|
473 |
+
|
474 |
+
$taxonomies = get_object_taxonomies($post->post_type);
|
475 |
+
if (empty($taxonomies))
|
476 |
+
return;
|
477 |
+
$terms = wp_get_object_terms($post->ID, $taxonomies);
|
478 |
+
|
479 |
+
foreach ((array)$terms as $term) {
|
480 |
+
echo "\t\t<category domain=\"{$term->taxonomy}\" nicename=\"{$term->slug}\">" . $this->mptt_cdata($term->name) . "</category>\n";
|
481 |
+
}
|
482 |
+
}
|
483 |
}
|
classes/models/class-import.php
CHANGED
@@ -1,968 +1,968 @@
|
|
1 |
-
<?php
|
2 |
-
namespace mp_timetable\classes\models;
|
3 |
-
|
4 |
-
use mp_timetable\classes\libs;
|
5 |
-
use mp_timetable\plugin_core\classes\Model as Model;
|
6 |
-
use mp_timetable\plugin_core\classes\View as View;
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Model Events
|
10 |
-
*/
|
11 |
-
class Import extends Model {
|
12 |
-
|
13 |
-
protected static $instance;
|
14 |
-
protected $table;
|
15 |
-
var $max_wxr_version = 1.2; // max. supported WXR version
|
16 |
-
var $id; // WXR attachment ID
|
17 |
-
var $file;
|
18 |
-
|
19 |
-
var $import_data;
|
20 |
-
// information to import from WXR file
|
21 |
-
var $version;
|
22 |
-
var $authors = array();
|
23 |
-
var $posts = array();
|
24 |
-
var $terms = array();
|
25 |
-
var $time_slots = array();
|
26 |
-
var $categories = array();
|
27 |
-
var $tags = array();
|
28 |
-
var $base_url = '';
|
29 |
-
|
30 |
-
var $processed_authors = array();
|
31 |
-
var $author_mapping = array();
|
32 |
-
var $processed_terms = array();
|
33 |
-
var $processed_posts = array();
|
34 |
-
var $post_orphans = array();
|
35 |
-
var $processed_menu_items = array();
|
36 |
-
var $menu_item_orphans = array();
|
37 |
-
var $missing_menu_items = array();
|
38 |
-
|
39 |
-
var $fetch_attachments = false;
|
40 |
-
var $url_remap = array();
|
41 |
-
var $featured_images = array();
|
42 |
-
|
43 |
-
public static function get_instance() {
|
44 |
-
if (null === self::$instance) {
|
45 |
-
self::$instance = new self();
|
46 |
-
}
|
47 |
-
return self::$instance;
|
48 |
-
}
|
49 |
-
|
50 |
-
function __construct() {
|
51 |
-
parent::__construct();
|
52 |
-
$this->table = Events::get_instance()->table_name;
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
*
|
57 |
-
* @param bool $return_me
|
58 |
-
* @param string $meta_key
|
59 |
-
*
|
60 |
-
* @return bool
|
61 |
-
*/
|
62 |
-
public function mptt_filter_postmeta($return_me, $meta_key) {
|
63 |
-
if ('_edit_lock' == $meta_key)
|
64 |
-
$return_me = true;
|
65 |
-
return $return_me;
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* Exist time slot
|
70 |
-
*
|
71 |
-
* @param array $time_slot
|
72 |
-
*
|
73 |
-
* @return bool
|
74 |
-
*/
|
75 |
-
public function post_time_slot_exist($time_slot = array()) {
|
76 |
-
global $wpdb;
|
77 |
-
if (empty($time_slot)) {
|
78 |
-
return false;
|
79 |
-
}
|
80 |
-
$data = $wpdb->get_results('SELECT id FROM ' . $this->table . ' WHERE column_id = "' . $time_slot['column'] . '" AND event_id = "' . $time_slot['event'] . '" AND event_start = "' . $time_slot['event_start'] . '" AND event_end = "' . $time_slot['event_end'] . '"');
|
81 |
-
return empty($data) ? false : true;
|
82 |
-
}
|
83 |
-
|
84 |
-
public function header() {
|
85 |
-
View::get_instance()->render_html('../admin/import/header');
|
86 |
-
}
|
87 |
-
|
88 |
-
public function footer() {
|
89 |
-
View::get_instance()->render_html('../admin/import/footer');
|
90 |
-
}
|
91 |
-
|
92 |
-
public function greet() {
|
93 |
-
View::get_instance()->render_html('../admin/import/greet');
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Decide whether or not the importer is allowed to create users.
|
98 |
-
* Default is true, can be filtered via import_allow_create_users
|
99 |
-
*
|
100 |
-
* @return bool True if creating users is allowed
|
101 |
-
*/
|
102 |
-
public function allow_create_users() {
|
103 |
-
return apply_filters('import_allow_create_users', true);
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Decide whether or not the importer should attempt to download attachment files.
|
108 |
-
* Default is true, can be filtered via import_allow_fetch_attachments. The choice
|
109 |
-
* made at the import options screen must also be true, false here hides that checkbox.
|
110 |
-
*
|
111 |
-
* @return bool True if downloading attachments is allowed
|
112 |
-
*/
|
113 |
-
public function allow_fetch_attachments() {
|
114 |
-
return apply_filters('import_allow_fetch_attachments', true);
|
115 |
-
}
|
116 |
-
|
117 |
-
public function import_options() {
|
118 |
-
$j = 0;
|
119 |
-
?>
|
120 |
-
<form action="<?php echo admin_url('admin.php?import=mptt-importer&step=2'); ?>" method="post">
|
121 |
-
<?php wp_nonce_field('mptt-importer'); ?>
|
122 |
-
<input type="hidden" name="import_id" value="<?php echo $this->id; ?>"/>
|
123 |
-
|
124 |
-
<?php if (!empty($this->authors)) : ?>
|
125 |
-
<h3><?php _e('Assign Authors', 'mp-timetable'); ?></h3>
|
126 |
-
<p><?php _e('To make it easier for you to edit and save the imported content, you may want to reassign the author of the imported item to an existing user of this site. For example, you may want to import all the entries as <code>admin</code>s entries.', 'mp-timetable'); ?></p>
|
127 |
-
<?php if ($this->allow_create_users()) : ?>
|
128 |
-
<p><?php printf(__('If a new user is created by WordPress, a new password will be randomly generated and the new user’s role will be set as %s. Manually changing the new user’s details will be necessary.', 'mp-timetable'), esc_html(get_option('default_role'))); ?></p>
|
129 |
-
<?php endif; ?>
|
130 |
-
<ol id="authors">
|
131 |
-
<?php foreach ($this->authors as $author) : ?>
|
132 |
-
<li><?php $this->author_select($j++, $author); ?></li>
|
133 |
-
<?php endforeach; ?>
|
134 |
-
</ol>
|
135 |
-
<?php endif; ?>
|
136 |
-
|
137 |
-
<?php if ($this->allow_fetch_attachments()) : ?>
|
138 |
-
<h3><?php _e('Import Attachments', 'mp-timetable'); ?></h3>
|
139 |
-
<p>
|
140 |
-
<input type="checkbox" value="1" name="fetch_attachments" id="import-attachments"/>
|
141 |
-
<label for="import-attachments"><?php _e('Download and import file attachments', 'mp-timetable'); ?></label>
|
142 |
-
</p>
|
143 |
-
<?php endif; ?>
|
144 |
-
|
145 |
-
<p class="submit"><input type="submit" class="button" value="<?php esc_attr_e('Submit', 'mp-timetable'); ?>"/></p>
|
146 |
-
</form>
|
147 |
-
<?php
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Display import options for an individual author. That is, either create
|
152 |
-
* a new user based on import info or map to an existing user
|
153 |
-
*
|
154 |
-
* @param int $n Index for each author in the form
|
155 |
-
* @param array $author Author information, e.g. login, display name, email
|
156 |
-
*/
|
157 |
-
function author_select($n, $author) {
|
158 |
-
_e('Import author:', 'mp-timetable');
|
159 |
-
echo ' <strong>' . esc_html($author['author_display_name']);
|
160 |
-
if ($this->version != '1.0') echo ' (' . esc_html($author['author_login']) . ')';
|
161 |
-
echo '</strong><br />';
|
162 |
-
|
163 |
-
if ($this->version != '1.0')
|
164 |
-
echo '<div style="margin-left:18px">';
|
165 |
-
|
166 |
-
$create_users = $this->allow_create_users();
|
167 |
-
if ($create_users) {
|
168 |
-
if ($this->version != '1.0') {
|
169 |
-
_e('or create new user with login name:', 'mp-timetable');
|
170 |
-
$value = '';
|
171 |
-
} else {
|
172 |
-
_e('as a new user:', 'mp-timetable');
|
173 |
-
$value = esc_attr(sanitize_user($author['author_login'], true));
|
174 |
-
}
|
175 |
-
|
176 |
-
echo ' <input type="text" name="user_new[' . $n . ']" value="' . $value . '" /><br />';
|
177 |
-
}
|
178 |
-
|
179 |
-
if (!$create_users && $this->version == '1.0')
|
180 |
-
_e('assign posts to an existing user:', 'mp-timetable');
|
181 |
-
else
|
182 |
-
_e('or assign posts to an existing user:', 'mp-timetable');
|
183 |
-
wp_dropdown_users(array('name' => "user_map[$n]", 'multi' => true, 'show_option_all' => __('- Select -', 'mp-timetable')));
|
184 |
-
echo '<input type="hidden" name="imported_authors[' . $n . ']" value="' . esc_attr($author['author_login']) . '" />';
|
185 |
-
|
186 |
-
if ($this->version != '1.0')
|
187 |
-
echo '</div>';
|
188 |
-
}
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Import
|
192 |
-
*/
|
193 |
-
public function import() {
|
194 |
-
$this->header();
|
195 |
-
$step = empty($_GET['step']) ? 0 : (int)$_GET['step'];
|
196 |
-
switch ($step) {
|
197 |
-
case 0:
|
198 |
-
$this->greet();
|
199 |
-
break;
|
200 |
-
case 1:
|
201 |
-
check_admin_referer('import-upload');
|
202 |
-
if ($this->handle_upload()) {
|
203 |
-
$this->import_options();
|
204 |
-
}
|
205 |
-
break;
|
206 |
-
case 2:
|
207 |
-
if (!empty($_POST['import_id'])) {
|
208 |
-
check_admin_referer('mptt-importer');
|
209 |
-
$this->fetch_attachments = (!empty($_POST['fetch_attachments']) && $this->allow_fetch_attachments());
|
210 |
-
$this->id = (int)$_POST['import_id'];
|
211 |
-
$file = get_attached_file($this->id);
|
212 |
-
} else {
|
213 |
-
check_admin_referer('import-upload');
|
214 |
-
$this->handle_upload();
|
215 |
-
$this->fetch_attachments = $this->allow_fetch_attachments();
|
216 |
-
$file = $this->file;
|
217 |
-
}
|
218 |
-
set_time_limit(0);
|
219 |
-
add_filter('import_post_meta_key', array($this, 'is_valid_meta_key'));
|
220 |
-
add_filter('http_request_timeout', array(&$this, 'bump_request_timeout'));
|
221 |
-
|
222 |
-
$this->get_author_mapping();
|
223 |
-
|
224 |
-
$this->process_start($file);
|
225 |
-
$this->process_end();
|
226 |
-
break;
|
227 |
-
}
|
228 |
-
$this->footer();
|
229 |
-
}
|
230 |
-
|
231 |
-
/**
|
232 |
-
* Import start
|
233 |
-
*
|
234 |
-
* @param $file
|
235 |
-
*/
|
236 |
-
public function process_start($file) {
|
237 |
-
$this->import_data = $this->parse($file);
|
238 |
-
$this->get_authors_from_import();
|
239 |
-
$this->version = $this->import_data['version'];
|
240 |
-
$this->posts = $this->import_data['posts'];
|
241 |
-
$this->terms = $this->import_data['terms'];
|
242 |
-
$this->time_slots = $this->import_data['time_slots'];
|
243 |
-
|
244 |
-
wp_suspend_cache_invalidation(true);
|
245 |
-
$this->process_terms();
|
246 |
-
$this->process_posts();
|
247 |
-
$this->process_time_slot();
|
248 |
-
wp_suspend_cache_invalidation(false);
|
249 |
-
$this->backfill_parents();
|
250 |
-
$this->backfill_attachment_urls();
|
251 |
-
$this->remap_featured_images();
|
252 |
-
wp_defer_term_counting(true);
|
253 |
-
wp_defer_comment_counting(true);
|
254 |
-
|
255 |
-
do_action('import_start');
|
256 |
-
}
|
257 |
-
|
258 |
-
public function process_end() {
|
259 |
-
wp_import_cleanup($this->id);
|
260 |
-
|
261 |
-
wp_cache_flush();
|
262 |
-
foreach (get_taxonomies() as $tax) {
|
263 |
-
delete_option("{$tax}_children");
|
264 |
-
_get_term_hierarchy($tax);
|
265 |
-
}
|
266 |
-
wp_defer_term_counting(false);
|
267 |
-
wp_defer_comment_counting(false);
|
268 |
-
|
269 |
-
echo '<p>' . __('All done.', 'mp-timetable') . ' <a href="' . admin_url() . '">' . __('Have fun!', 'mp-timetable') . '</a>' . '</p>';
|
270 |
-
echo '<p>' . __('Remember to update the passwords and roles of imported users.', 'mp-timetable') . '</p>';
|
271 |
-
|
272 |
-
do_action('import_end');
|
273 |
-
}
|
274 |
-
|
275 |
-
/**
|
276 |
-
* If fetching attachments is enabled then attempt to create a new attachment
|
277 |
-
*
|
278 |
-
* @param array $post Attachment post details from WXR
|
279 |
-
* @param string $url URL to fetch attachment from
|
280 |
-
*
|
281 |
-
* @return int|/WP_Error Post ID on success, WP_Error otherwise
|
282 |
-
*/
|
283 |
-
public function process_attachment($post, $url) {
|
284 |
-
if (!$this->fetch_attachments)
|
285 |
-
return new \WP_Error('attachment_processing_error',
|
286 |
-
__('Fetching attachments is not enabled', 'mp-timetable'));
|
287 |
-
|
288 |
-
// if the URL is absolute, but does not contain address, then upload it assuming base_site_url
|
289 |
-
if (preg_match('|^/[\w\W]+$|', $url))
|
290 |
-
$url = rtrim($this->base_url, '/') . $url;
|
291 |
-
|
292 |
-
$upload = $this->fetch_remote_file($url, $post);
|
293 |
-
if (is_wp_error($upload))
|
294 |
-
return $upload;
|
295 |
-
|
296 |
-
if ($info = wp_check_filetype($upload['file']))
|
297 |
-
$post['post_mime_type'] = $info['type'];
|
298 |
-
else
|
299 |
-
return new \WP_Error('attachment_processing_error', __('Invalid file type', 'mp-timetable'));
|
300 |
-
|
301 |
-
$post['guid'] = $upload['url'];
|
302 |
-
|
303 |
-
// as per wp-admin/includes/upload.php
|
304 |
-
$post_id = wp_insert_attachment($post, $upload['file']);
|
305 |
-
wp_update_attachment_metadata($post_id, wp_generate_attachment_metadata($post_id, $upload['file']));
|
306 |
-
|
307 |
-
// remap resized image URLs, works by stripping the extension and remapping the URL stub.
|
308 |
-
if (preg_match('!^image/!', $info['type'])) {
|
309 |
-
$parts = pathinfo($url);
|
310 |
-
$name = basename($parts['basename'], ".{$parts['extension']}"); // PATHINFO_FILENAME in PHP 5.2
|
311 |
-
|
312 |
-
$parts_new = pathinfo($upload['url']);
|
313 |
-
$name_new = basename($parts_new['basename'], ".{$parts_new['extension']}");
|
314 |
-
|
315 |
-
$this->url_remap[$parts['dirname'] . '/' . $name] = $parts_new['dirname'] . '/' . $name_new;
|
316 |
-
}
|
317 |
-
|
318 |
-
return $post_id;
|
319 |
-
}
|
320 |
-
|
321 |
-
/**
|
322 |
-
* Get file by URL and write upload
|
323 |
-
*
|
324 |
-
* @param $url
|
325 |
-
* @param $upload
|
326 |
-
* @param int $redirection
|
327 |
-
*
|
328 |
-
* @return bool
|
329 |
-
*/
|
330 |
-
private function write_file($url, $upload, $redirection = 5) {
|
331 |
-
$options = array();
|
332 |
-
$options['redirection'] = $redirection;
|
333 |
-
|
334 |
-
if (false == $upload['file'])
|
335 |
-
$options['method'] = 'HEAD';
|
336 |
-
else
|
337 |
-
$options['method'] = 'GET';
|
338 |
-
|
339 |
-
$response = wp_safe_remote_request($url, $options);
|
340 |
-
|
341 |
-
if (false == $upload['file']) {
|
342 |
-
return false;
|
343 |
-
}
|
344 |
-
// GET request - write it to the supplied filename
|
345 |
-
$out_fp = fopen($upload['file'], 'w');
|
346 |
-
if (!$out_fp) {
|
347 |
-
return false;
|
348 |
-
}
|
349 |
-
|
350 |
-
fwrite($out_fp, wp_remote_retrieve_body($response));
|
351 |
-
fclose($out_fp);
|
352 |
-
clearstatcache();
|
353 |
-
return true;
|
354 |
-
}
|
355 |
-
|
356 |
-
/**
|
357 |
-
* Attempt to download a remote file attachment
|
358 |
-
*
|
359 |
-
* @param string $url URL of item to fetch
|
360 |
-
* @param array $post Attachment details
|
361 |
-
*
|
362 |
-
* @return array|\WP_Error Local file location details on success, WP_Error otherwise
|
363 |
-
*/
|
364 |
-
public function fetch_remote_file($url, $post) {
|
365 |
-
// extract the file name and extension from the url
|
366 |
-
$file_name = basename($url);
|
367 |
-
|
368 |
-
// get placeholder file in the upload dir with a unique, sanitized filename
|
369 |
-
$upload = wp_upload_bits($file_name, 0, '', $post['upload_date']);
|
370 |
-
if ($upload['error'])
|
371 |
-
return new \WP_Error('upload_dir_error', $upload['error']);
|
372 |
-
|
373 |
-
// fetch the remote url and write it to the placeholder file
|
374 |
-
$response_data = wp_safe_remote_head($url);
|
375 |
-
$headers = wp_remote_retrieve_headers($response_data);
|
376 |
-
$headers['response'] = wp_remote_retrieve_response_code($response_data);
|
377 |
-
if (!$headers) {
|
378 |
-
@unlink($upload['file']);
|
379 |
-
return new \WP_Error('import_file_error', __('Remote server did not respond', 'mp-timetable'));
|
380 |
-
}
|
381 |
-
|
382 |
-
// make sure the fetch was successful
|
383 |
-
if ($headers['response'] != '200') {
|
384 |
-
@unlink($upload['file']);
|
385 |
-
return new \WP_Error('import_file_error', sprintf(__('Remote server returned error response %1$d %2$s', 'mp-timetable'), esc_html($headers['response']), get_status_header_desc($headers['response'])));
|
386 |
-
}
|
387 |
-
|
388 |
-
$this->write_file($url, $upload);
|
389 |
-
|
390 |
-
$filesize = filesize($upload['file']);
|
391 |
-
|
392 |
-
if (isset($headers['content-length']) && $filesize != $headers['content-length']) {
|
393 |
-
@unlink($upload['file']);
|
394 |
-
return new \WP_Error('import_file_error', __('Remote file is incorrect size', 'mp-timetable'));
|
395 |
-
}
|
396 |
-
|
397 |
-
if (0 == $filesize) {
|
398 |
-
@unlink($upload['file']);
|
399 |
-
return new \WP_Error('import_file_error', __('Zero size file downloaded', 'mp-timetable'));
|
400 |
-
}
|
401 |
-
|
402 |
-
$max_size = (int)$this->max_attachment_size();
|
403 |
-
if (!empty($max_size) && $filesize > $max_size) {
|
404 |
-
@unlink($upload['file']);
|
405 |
-
return new \WP_Error('import_file_error', sprintf(__('Remote file is too large, limit is %s', 'mp-timetable'), size_format($max_size)));
|
406 |
-
}
|
407 |
-
|
408 |
-
// keep track of the old and new urls so we can substitute them later
|
409 |
-
$this->url_remap[$url] = $upload['url'];
|
410 |
-
$this->url_remap[$post['guid']] = $upload['url']; // r13735, really needed?
|
411 |
-
// keep track of the destination if the remote url is redirected somewhere else
|
412 |
-
if (isset($headers['x-final-location']) && $headers['x-final-location'] != $url)
|
413 |
-
$this->url_remap[$headers['x-final-location']] = $upload['url'];
|
414 |
-
|
415 |
-
return $upload;
|
416 |
-
}
|
417 |
-
|
418 |
-
public function handle_upload() {
|
419 |
-
$file = wp_import_handle_upload();
|
420 |
-
|
421 |
-
if (isset($file['error'])) {
|
422 |
-
echo '<p><strong>' . __('Sorry, there has been an error.', 'mp-timetable') . '</strong><br />';
|
423 |
-
echo esc_html($file['error']) . '</p>';
|
424 |
-
return false;
|
425 |
-
} else if (!file_exists($file['file'])) {
|
426 |
-
echo '<p><strong>' . __('Sorry, there has been an error.', 'mp-timetable') . '</strong><br />';
|
427 |
-
printf(__('The export file could not be found at <code>%s</code>. It is likely that this was caused by a permissions problem.', 'mp-timetable'), esc_html($file['file']));
|
428 |
-
echo '</p>';
|
429 |
-
return false;
|
430 |
-
}
|
431 |
-
$this->file = $file['file'];
|
432 |
-
$this->id = (int)$file['id'];
|
433 |
-
$this->import_data = $this->parse($file['file']);
|
434 |
-
|
435 |
-
if (is_wp_error($this->import_data)) {
|
436 |
-
echo '<p><strong>' . __('Sorry, there has been an error.', 'mp-timetable') . '</strong><br />';
|
437 |
-
echo esc_html($this->import_data->get_error_message()) . '</p>';
|
438 |
-
return false;
|
439 |
-
}
|
440 |
-
|
441 |
-
$this->version = $this->import_data['version'];
|
442 |
-
if ($this->version > $this->max_wxr_version) {
|
443 |
-
echo '<div class="error"><p><strong>';
|
444 |
-
printf(__('This WXR file (version %s) may not be supported by this version of the importer. Please consider updating.', 'mp-timetable'), esc_html($this->import_data['version']));
|
445 |
-
echo '</strong></p></div>';
|
446 |
-
}
|
447 |
-
$this->get_authors_from_import();
|
448 |
-
return true;
|
449 |
-
}
|
450 |
-
|
451 |
-
/**
|
452 |
-
* Parse a WXR file
|
453 |
-
*
|
454 |
-
* @param string $file Path to WXR file for parsing
|
455 |
-
*
|
456 |
-
* @return array Information gathered from the WXR file
|
457 |
-
*/
|
458 |
-
function parse($file) {
|
459 |
-
$parser = new libs\WXR_Parser();
|
460 |
-
return $parser->parse($file);
|
461 |
-
}
|
462 |
-
|
463 |
-
/**
|
464 |
-
* Decide if the given meta key maps to information we will want to import
|
465 |
-
*
|
466 |
-
* @param string $key The meta key to check
|
467 |
-
*
|
468 |
-
* @return string|bool The key if we do want to import, false if not
|
469 |
-
*/
|
470 |
-
function is_valid_meta_key($key) {
|
471 |
-
// skip attachment metadata since we'll regenerate it from scratch
|
472 |
-
// skip _edit_lock as not relevant for import
|
473 |
-
if (in_array($key, array('_wp_attached_file', '_wp_attachment_metadata', '_edit_lock')))
|
474 |
-
return false;
|
475 |
-
return $key;
|
476 |
-
}
|
477 |
-
|
478 |
-
/**
|
479 |
-
* Added to http_request_timeout filter to force timeout at 60 seconds during import
|
480 |
-
* @return int 60
|
481 |
-
*/
|
482 |
-
function bump_request_timeout() {
|
483 |
-
return 60;
|
484 |
-
}
|
485 |
-
|
486 |
-
/**
|
487 |
-
* Retrieve authors from parsed WXR data
|
488 |
-
*
|
489 |
-
* Uses the provided author information from WXR 1.1 files
|
490 |
-
* or extracts info from each post for WXR 1.0 files
|
491 |
-
*
|
492 |
-
*/
|
493 |
-
function get_authors_from_import() {
|
494 |
-
if (!empty($this->import_data['authors'])) {
|
495 |
-
$this->authors = $this->import_data['authors'];
|
496 |
-
// no author information, grab it from the posts
|
497 |
-
} else {
|
498 |
-
foreach ($this->import_data['posts'] as $post) {
|
499 |
-
$login = sanitize_user($post['post_author'], true);
|
500 |
-
if (empty($login)) {
|
501 |
-
printf(__('Failed to import author %s. Their posts will be attributed to the current user.', 'mp-timetable'), esc_html($post['post_author']));
|
502 |
-
echo '<br />';
|
503 |
-
continue;
|
504 |
-
}
|
505 |
-
|
506 |
-
if (!isset($this->authors[$login]))
|
507 |
-
$this->authors[$login] = array(
|
508 |
-
'author_login' => $login,
|
509 |
-
'author_display_name' => $post['post_author']
|
510 |
-
);
|
511 |
-
}
|
512 |
-
}
|
513 |
-
}
|
514 |
-
|
515 |
-
/**
|
516 |
-
* Map old author logins to local user IDs based on decisions made
|
517 |
-
* in import options form. Can map to an existing user, create a new user
|
518 |
-
* or falls back to the current user in case of error with either of the previous
|
519 |
-
*/
|
520 |
-
function get_author_mapping() {
|
521 |
-
if ( ! isset( $_POST['imported_authors'] ) )
|
522 |
-
return;
|
523 |
-
|
524 |
-
$create_users = $this->allow_create_users();
|
525 |
-
|
526 |
-
foreach ( (array) $_POST['imported_authors'] as $i => $old_login ) {
|
527 |
-
// Multisite adds strtolower to sanitize_user. Need to sanitize here to stop breakage in process_posts.
|
528 |
-
$santized_old_login = sanitize_user( $old_login, true );
|
529 |
-
$old_id = isset( $this->authors[$old_login]['author_id'] ) ? intval($this->authors[$old_login]['author_id']) : false;
|
530 |
-
|
531 |
-
if ( ! empty( $_POST['user_map'][$i] ) ) {
|
532 |
-
$user = get_userdata( intval($_POST['user_map'][$i]) );
|
533 |
-
if ( isset( $user->ID ) ) {
|
534 |
-
if ( $old_id )
|
535 |
-
$this->processed_authors[$old_id] = $user->ID;
|
536 |
-
$this->author_mapping[$santized_old_login] = $user->ID;
|
537 |
-
}
|
538 |
-
} else if ( $create_users ) {
|
539 |
-
if ( ! empty($_POST['user_new'][$i]) ) {
|
540 |
-
$user_id = wp_create_user( $_POST['user_new'][$i], wp_generate_password() );
|
541 |
-
} else if ( $this->version != '1.0' ) {
|
542 |
-
$user_data = array(
|
543 |
-
'user_login' => $old_login,
|
544 |
-
'user_pass' => wp_generate_password(),
|
545 |
-
'user_email' => isset( $this->authors[$old_login]['author_email'] ) ? $this->authors[$old_login]['author_email'] : '',
|
546 |
-
'display_name' => $this->authors[$old_login]['author_display_name'],
|
547 |
-
'first_name' => isset( $this->authors[$old_login]['author_first_name'] ) ? $this->authors[$old_login]['author_first_name'] : '',
|
548 |
-
'last_name' => isset( $this->authors[$old_login]['author_last_name'] ) ? $this->authors[$old_login]['author_last_name'] : '',
|
549 |
-
);
|
550 |
-
$user_id = wp_insert_user( $user_data );
|
551 |
-
}
|
552 |
-
|
553 |
-
if ( ! is_wp_error( $user_id ) ) {
|
554 |
-
if ( $old_id )
|
555 |
-
$this->processed_authors[$old_id] = $user_id;
|
556 |
-
$this->author_mapping[$santized_old_login] = $user_id;
|
557 |
-
} else {
|
558 |
-
printf( __( 'Failed to create new user for %s. Their posts will be attributed to the current user.', 'mp-timetable' ), esc_html($this->authors[$old_login]['author_display_name']) );
|
559 |
-
if ( defined('IMPORT_DEBUG') && IMPORT_DEBUG )
|
560 |
-
echo ' ' . $user_id->get_error_message();
|
561 |
-
echo '<br />';
|
562 |
-
}
|
563 |
-
}
|
564 |
-
|
565 |
-
// failsafe: if the user_id was invalid, default to the current user
|
566 |
-
if ( ! isset( $this->author_mapping[$santized_old_login] ) ) {
|
567 |
-
if ( $old_id )
|
568 |
-
$this->processed_authors[$old_id] = (int) get_current_user_id();
|
569 |
-
$this->author_mapping[$santized_old_login] = (int) get_current_user_id();
|
570 |
-
}
|
571 |
-
}
|
572 |
-
}
|
573 |
-
|
574 |
-
/**
|
575 |
-
* Create new terms based on import information
|
576 |
-
*
|
577 |
-
* Doesn't create a term its slug already exists
|
578 |
-
*/
|
579 |
-
function process_terms() {
|
580 |
-
$this->terms = apply_filters('wp_import_terms', $this->terms);
|
581 |
-
|
582 |
-
if (empty($this->terms))
|
583 |
-
return;
|
584 |
-
|
585 |
-
foreach ($this->terms as $term) {
|
586 |
-
// if the term already exists in the correct taxonomy leave it alone
|
587 |
-
$term_id = term_exists($term['slug'], $term['term_taxonomy']);
|
588 |
-
if ($term_id) {
|
589 |
-
if (is_array($term_id)) $term_id = $term_id['term_id'];
|
590 |
-
if (isset($term['term_id']))
|
591 |
-
$this->processed_terms[intval($term['term_id'])] = (int)$term_id;
|
592 |
-
continue;
|
593 |
-
}
|
594 |
-
|
595 |
-
if (empty($term['term_parent'])) {
|
596 |
-
$parent = 0;
|
597 |
-
} else {
|
598 |
-
$parent = term_exists($term['term_parent'], $term['term_taxonomy']);
|
599 |
-
if (is_array($parent)) $parent = $parent['term_id'];
|
600 |
-
}
|
601 |
-
$description = isset($term['term_description']) ? $term['term_description'] : '';
|
602 |
-
$termarr = array('slug' => $term['slug'], 'description' => $description, 'parent' => intval($parent));
|
603 |
-
|
604 |
-
$id = wp_insert_term($term['term_name'], $term['term_taxonomy'], $termarr);
|
605 |
-
if (!is_wp_error($id)) {
|
606 |
-
if (isset($term['term_id']))
|
607 |
-
$this->processed_terms[intval($term['term_id'])] = $id['term_id'];
|
608 |
-
} else {
|
609 |
-
printf(__('Failed to import %s %s', 'mp-timetable'), esc_html($term['term_taxonomy']), esc_html($term['term_name']));
|
610 |
-
if (defined('IMPORT_DEBUG') && IMPORT_DEBUG)
|
611 |
-
echo ': ' . $id->get_error_message();
|
612 |
-
echo '<br />';
|
613 |
-
continue;
|
614 |
-
}
|
615 |
-
}
|
616 |
-
|
617 |
-
unset($this->terms);
|
618 |
-
}
|
619 |
-
|
620 |
-
public function process_time_slot() {
|
621 |
-
global $wpdb;
|
622 |
-
$rows_affected = array();
|
623 |
-
$time_slots = $this->import_data['time_slots'];
|
624 |
-
if (!empty($this->import_data['time_slots'])) {
|
625 |
-
foreach ($time_slots as $time_slot) {
|
626 |
-
$exist_time_slot = $this->post_time_slot_exist($time_slot);
|
627 |
-
if (!$exist_time_slot) {
|
628 |
-
$rows_affected[] = $wpdb->insert($this->table, array(
|
629 |
-
'column_id' => $time_slot['column'],
|
630 |
-
'event_id' => $time_slot['event'],
|
631 |
-
'event_start' => date('H:i:s', strtotime($time_slot['event_start'])),
|
632 |
-
'event_end' => date('H:i:s', strtotime($time_slot['event_end'])),
|
633 |
-
'user_id' => $time_slot['user_id'],
|
634 |
-
'description' => $time_slot['description']
|
635 |
-
));
|
636 |
-
}
|
637 |
-
}
|
638 |
-
}
|
639 |
-
}
|
640 |
-
|
641 |
-
/**
|
642 |
-
* Create new posts based on import information
|
643 |
-
*
|
644 |
-
* Posts marked as having a parent which doesn't exist will become top level items.
|
645 |
-
* Doesn't create a new post if: the post type doesn't exist, the given post ID
|
646 |
-
* is already noted as imported or a post with the same title and date already exists.
|
647 |
-
* Note that new/updated terms, comments and meta are imported for the last of the above.
|
648 |
-
*/
|
649 |
-
public function process_posts() {
|
650 |
-
$this->posts = apply_filters('wp_import_posts', $this->posts);
|
651 |
-
|
652 |
-
foreach ($this->posts as $post) {
|
653 |
-
$post = apply_filters('wp_import_post_data_raw', $post);
|
654 |
-
|
655 |
-
if (!post_type_exists($post['post_type'])) {
|
656 |
-
printf(__('Failed to import “%s”: Invalid post type %s', 'mp-timetable'),
|
657 |
-
esc_html($post['post_title']), esc_html($post['post_type']));
|
658 |
-
echo '<br />';
|
659 |
-
do_action('wp_import_post_exists', $post);
|
660 |
-
continue;
|
661 |
-
}
|
662 |
-
|
663 |
-
if (isset($this->processed_posts[$post['post_id']]) && !empty($post['post_id']))
|
664 |
-
continue;
|
665 |
-
|
666 |
-
if ($post['status'] == 'auto-draft')
|
667 |
-
continue;
|
668 |
-
|
669 |
-
$post_type_object = get_post_type_object($post['post_type']);
|
670 |
-
|
671 |
-
$post_exists = post_exists($post['post_title'], '', $post['post_date']);
|
672 |
-
if ($post_exists && get_post_type($post_exists) == $post['post_type']) {
|
673 |
-
printf(__('%s “%s” already exists.', 'mp-timetable'), $post_type_object->labels->singular_name, esc_html($post['post_title']));
|
674 |
-
echo '<br />';
|
675 |
-
$comment_post_ID = $post_id = $post_exists;
|
676 |
-
} else {
|
677 |
-
$post_parent = (int)$post['post_parent'];
|
678 |
-
if ($post_parent) {
|
679 |
-
// if we already know the parent, map it to the new local ID
|
680 |
-
if (isset($this->processed_posts[$post_parent])) {
|
681 |
-
$post_parent = $this->processed_posts[$post_parent];
|
682 |
-
// otherwise record the parent for later
|
683 |
-
} else {
|
684 |
-
$this->post_orphans[intval($post['post_id'])] = $post_parent;
|
685 |
-
$post_parent = 0;
|
686 |
-
}
|
687 |
-
}
|
688 |
-
|
689 |
-
// map the post author
|
690 |
-
$author = sanitize_user($post['post_author'], true);
|
691 |
-
if (isset($this->author_mapping[$author]))
|
692 |
-
$author = $this->author_mapping[$author];
|
693 |
-
else
|
694 |
-
$author = (int)get_current_user_id();
|
695 |
-
|
696 |
-
$postdata = array(
|
697 |
-
'import_id' => $post['post_id'], 'post_author' => $author, 'post_date' => $post['post_date'],
|
698 |
-
'post_date_gmt' => $post['post_date_gmt'], 'post_content' => $post['post_content'],
|
699 |
-
'post_excerpt' => $post['post_excerpt'], 'post_title' => $post['post_title'],
|
700 |
-
'post_status' => $post['status'], 'post_name' => $post['post_name'],
|
701 |
-
'comment_status' => $post['comment_status'], 'ping_status' => $post['ping_status'],
|
702 |
-
'guid' => $post['guid'], 'post_parent' => $post_parent, 'menu_order' => $post['menu_order'],
|
703 |
-
'post_type' => $post['post_type'], 'post_password' => $post['post_password']
|
704 |
-
);
|
705 |
-
|
706 |
-
$original_post_ID = $post['post_id'];
|
707 |
-
$postdata = apply_filters('wp_import_post_data_processed', $postdata, $post);
|
708 |
-
|
709 |
-
if ('attachment' == $postdata['post_type']) {
|
710 |
-
$remote_url = !empty($post['attachment_url']) ? $post['attachment_url'] : $post['guid'];
|
711 |
-
|
712 |
-
// try to use _wp_attached file for upload folder placement to ensure the same location as the export site
|
713 |
-
// e.g. location is 2003/05/image.jpg but the attachment post_date is 2010/09, see media_handle_upload()
|
714 |
-
$postdata['upload_date'] = $post['post_date'];
|
715 |
-
if (isset($post['postmeta'])) {
|
716 |
-
foreach ($post['postmeta'] as $meta) {
|
717 |
-
if ($meta['key'] == '_wp_attached_file') {
|
718 |
-
if (preg_match('%^[0-9]{4}/[0-9]{2}%', $meta['value'], $matches))
|
719 |
-
$postdata['upload_date'] = $matches[0];
|
720 |
-
break;
|
721 |
-
}
|
722 |
-
}
|
723 |
-
}
|
724 |
-
|
725 |
-
$comment_post_ID = $post_id = $this->process_attachment($postdata, $remote_url);
|
726 |
-
} else {
|
727 |
-
$comment_post_ID = $post_id = wp_insert_post($postdata, true);
|
728 |
-
do_action('wp_import_insert_post', $post_id, $original_post_ID, $postdata, $post);
|
729 |
-
}
|
730 |
-
|
731 |
-
if (is_wp_error($post_id)) {
|
732 |
-
printf(__('Failed to import %s “%s”', 'mp-timetable'),
|
733 |
-
$post_type_object->labels->singular_name, esc_html($post['post_title']));
|
734 |
-
if (defined('IMPORT_DEBUG') && IMPORT_DEBUG)
|
735 |
-
echo ': ' . $post_id->get_error_message();
|
736 |
-
echo '<br />';
|
737 |
-
continue;
|
738 |
-
}
|
739 |
-
|
740 |
-
if ($post['is_sticky'] == 1)
|
741 |
-
stick_post($post_id);
|
742 |
-
}
|
743 |
-
|
744 |
-
// map pre-import ID to local ID
|
745 |
-
$this->processed_posts[intval($post['post_id'])] = (int)$post_id;
|
746 |
-
|
747 |
-
if (!isset($post['terms']))
|
748 |
-
$post['terms'] = array();
|
749 |
-
|
750 |
-
$post['terms'] = apply_filters('wp_import_post_terms', $post['terms'], $post_id, $post);
|
751 |
-
|
752 |
-
// add categories, tags and other terms
|
753 |
-
if (!empty($post['terms'])) {
|
754 |
-
$terms_to_set = array();
|
755 |
-
foreach ($post['terms'] as $term) {
|
756 |
-
// back compat with WXR 1.0 map 'tag' to 'post_tag'
|
757 |
-
$taxonomy = ('tag' == $term['domain']) ? 'post_tag' : $term['domain'];
|
758 |
-
$term_exists = term_exists($term['slug'], $taxonomy);
|
759 |
-
$term_id = is_array($term_exists) ? $term_exists['term_id'] : $term_exists;
|
760 |
-
if (!$term_id) {
|
761 |
-
$t = wp_insert_term($term['name'], $taxonomy, array('slug' => $term['slug']));
|
762 |
-
if (!is_wp_error($t)) {
|
763 |
-
$term_id = $t['term_id'];
|
764 |
-
do_action('wp_import_insert_term', $t, $term, $post_id, $post);
|
765 |
-
} else {
|
766 |
-
printf(__('Failed to import %s %s', 'mp-timetable'), esc_html($taxonomy), esc_html($term['name']));
|
767 |
-
if (defined('IMPORT_DEBUG') && IMPORT_DEBUG)
|
768 |
-
echo ': ' . $t->get_error_message();
|
769 |
-
echo '<br />';
|
770 |
-
do_action('wp_import_insert_term_failed', $t, $term, $post_id, $post);
|
771 |
-
continue;
|
772 |
-
}
|
773 |
-
}
|
774 |
-
$terms_to_set[$taxonomy][] = intval($term_id);
|
775 |
-
}
|
776 |
-
|
777 |
-
foreach ($terms_to_set as $tax => $ids) {
|
778 |
-
$tt_ids = wp_set_post_terms($post_id, $ids, $tax);
|
779 |
-
do_action('wp_import_set_post_terms', $tt_ids, $ids, $tax, $post_id, $post);
|
780 |
-
}
|
781 |
-
unset($post['terms'], $terms_to_set);
|
782 |
-
}
|
783 |
-
|
784 |
-
if (!isset($post['comments']))
|
785 |
-
$post['comments'] = array();
|
786 |
-
|
787 |
-
$post['comments'] = apply_filters('wp_import_post_comments', $post['comments'], $post_id, $post);
|
788 |
-
|
789 |
-
// add/update comments
|
790 |
-
if (!empty($post['comments'])) {
|
791 |
-
$num_comments = 0;
|
792 |
-
$inserted_comments = array();
|
793 |
-
foreach ($post['comments'] as $comment) {
|
794 |
-
$comment_id = $comment['comment_id'];
|
795 |
-
$newcomments[$comment_id]['comment_post_ID'] = $comment_post_ID;
|
796 |
-
$newcomments[$comment_id]['comment_author'] = $comment['comment_author'];
|
797 |
-
$newcomments[$comment_id]['comment_author_email'] = $comment['comment_author_email'];
|
798 |
-
$newcomments[$comment_id]['comment_author_IP'] = $comment['comment_author_IP'];
|
799 |
-
$newcomments[$comment_id]['comment_author_url'] = $comment['comment_author_url'];
|
800 |
-
$newcomments[$comment_id]['comment_date'] = $comment['comment_date'];
|
801 |
-
$newcomments[$comment_id]['comment_date_gmt'] = $comment['comment_date_gmt'];
|
802 |
-
$newcomments[$comment_id]['comment_content'] = $comment['comment_content'];
|
803 |
-
$newcomments[$comment_id]['comment_approved'] = $comment['comment_approved'];
|
804 |
-
$newcomments[$comment_id]['comment_type'] = $comment['comment_type'];
|
805 |
-
$newcomments[$comment_id]['comment_parent'] = $comment['comment_parent'];
|
806 |
-
$newcomments[$comment_id]['commentmeta'] = isset($comment['commentmeta']) ? $comment['commentmeta'] : array();
|
807 |
-
if (isset($this->processed_authors[$comment['comment_user_id']]))
|
808 |
-
$newcomments[$comment_id]['user_id'] = $this->processed_authors[$comment['comment_user_id']];
|
809 |
-
}
|
810 |
-
ksort($newcomments);
|
811 |
-
|
812 |
-
foreach ($newcomments as $key => $comment) {
|
813 |
-
// if this is a new post we can skip the comment_exists() check
|
814 |
-
if (!$post_exists || !comment_exists($comment['comment_author'], $comment['comment_date'])) {
|
815 |
-
if (isset($inserted_comments[$comment['comment_parent']]))
|
816 |
-
$comment['comment_parent'] = $inserted_comments[$comment['comment_parent']];
|
817 |
-
$comment = wp_filter_comment($comment);
|
818 |
-
$inserted_comments[$key] = wp_insert_comment($comment);
|
819 |
-
do_action('wp_import_insert_comment', $inserted_comments[$key], $comment, $comment_post_ID, $post);
|
820 |
-
|
821 |
-
foreach ($comment['commentmeta'] as $meta) {
|
822 |
-
$value = maybe_unserialize($meta['value']);
|
823 |
-
add_comment_meta($inserted_comments[$key], $meta['key'], $value);
|
824 |
-
}
|
825 |
-
|
826 |
-
$num_comments++;
|
827 |
-
}
|
828 |
-
}
|
829 |
-
unset($newcomments, $inserted_comments, $post['comments']);
|
830 |
-
}
|
831 |
-
|
832 |
-
// change time_slot data if post ID change
|
833 |
-
|
834 |
-
if (!empty($original_post_ID)) {
|
835 |
-
if ($original_post_ID != $post_id) {
|
836 |
-
foreach ($this->import_data['time_slots'] as $key => $time_slot) {
|
837 |
-
if ($post['post_type'] == 'mp-event' && $time_slot['event'] == $original_post_ID) {
|
838 |
-
$time_slot['event'] = $post_id;
|
839 |
-
} elseif ($post['post_type'] == 'mp-column' && $time_slot['column'] == $original_post_ID) {
|
840 |
-
$time_slot['column'] = $post_id;
|
841 |
-
} else {
|
842 |
-
continue;
|
843 |
-
}
|
844 |
-
$this->import_data['time_slots'][$key] = $time_slot;
|
845 |
-
}
|
846 |
-
}
|
847 |
-
}
|
848 |
-
|
849 |
-
|
850 |
-
if (!isset($post['postmeta'])) {
|
851 |
-
$post['postmeta'] = array();
|
852 |
-
}
|
853 |
-
$post['postmeta'] = apply_filters('wp_import_post_meta', $post['postmeta'], $post_id, $post);
|
854 |
-
// add/update post meta
|
855 |
-
if (!empty($post['postmeta'])) {
|
856 |
-
foreach ($post['postmeta'] as $meta) {
|
857 |
-
$key = apply_filters('import_post_meta_key', $meta['key'], $post_id, $post);
|
858 |
-
$value = false;
|
859 |
-
|
860 |
-
if ('_edit_last' == $key) {
|
861 |
-
if (isset($this->processed_authors[intval($meta['value'])]))
|
862 |
-
$value = $this->processed_authors[intval($meta['value'])];
|
863 |
-
else
|
864 |
-
$key = false;
|
865 |
-
}
|
866 |
-
|
867 |
-
if ($key) {
|
868 |
-
// export gets meta straight from the DB so could have a serialized string
|
869 |
-
if (!$value)
|
870 |
-
$value = maybe_unserialize($meta['value']);
|
871 |
-
|
872 |
-
add_post_meta($post_id, $key, $value);
|
873 |
-
do_action('import_post_meta', $post_id, $key, $value);
|
874 |
-
|
875 |
-
// if the post has a featured image, take note of this in case of remap
|
876 |
-
if ('_thumbnail_id' == $key)
|
877 |
-
$this->featured_images[$post_id] = (int)$value;
|
878 |
-
}
|
879 |
-
}
|
880 |
-
}
|
881 |
-
}
|
882 |
-
|
883 |
-
unset($this->posts);
|
884 |
-
}
|
885 |
-
|
886 |
-
/**
|
887 |
-
* Attempt to associate posts and menu items with previously missing parents
|
888 |
-
*
|
889 |
-
* An imported post's parent may not have been imported when it was first created
|
890 |
-
* so try again. Similarly for child menu items and menu items which were missing
|
891 |
-
* the object (e.g. post) they represent in the menu
|
892 |
-
*/
|
893 |
-
function backfill_parents() {
|
894 |
-
global $wpdb;
|
895 |
-
|
896 |
-
// find parents for post orphans
|
897 |
-
foreach ($this->post_orphans as $child_id => $parent_id) {
|
898 |
-
$local_child_id = $local_parent_id = false;
|
899 |
-
if (isset($this->processed_posts[$child_id]))
|
900 |
-
$local_child_id = $this->processed_posts[$child_id];
|
901 |
-
if (isset($this->processed_posts[$parent_id]))
|
902 |
-
$local_parent_id = $this->processed_posts[$parent_id];
|
903 |
-
|
904 |
-
if ($local_child_id && $local_parent_id)
|
905 |
-
$wpdb->update($wpdb->posts, array('post_parent' => $local_parent_id), array('ID' => $local_child_id), '%d', '%d');
|
906 |
-
}
|
907 |
-
|
908 |
-
// all other posts/terms are imported, retry menu items with missing associated object
|
909 |
-
$missing_menu_items = $this->missing_menu_items;
|
910 |
-
// foreach ($missing_menu_items as $item)
|
911 |
-
// $this->process_menu_item($item);
|
912 |
-
|
913 |
-
// find parents for menu item orphans
|
914 |
-
foreach ($this->menu_item_orphans as $child_id => $parent_id) {
|
915 |
-
$local_child_id = $local_parent_id = 0;
|
916 |
-
if (isset($this->processed_menu_items[$child_id]))
|
917 |
-
$local_child_id = $this->processed_menu_items[$child_id];
|
918 |
-
if (isset($this->processed_menu_items[$parent_id]))
|
919 |
-
$local_parent_id = $this->processed_menu_items[$parent_id];
|
920 |
-
|
921 |
-
if ($local_child_id && $local_parent_id)
|
922 |
-
update_post_meta($local_child_id, '_menu_item_menu_item_parent', (int)$local_parent_id);
|
923 |
-
}
|
924 |
-
}
|
925 |
-
|
926 |
-
/**
|
927 |
-
* Use stored mapping information to update old attachment URLs
|
928 |
-
*/
|
929 |
-
function backfill_attachment_urls() {
|
930 |
-
global $wpdb;
|
931 |
-
$result = array();
|
932 |
-
// make sure we do the longest urls first, in case one is a substring of another
|
933 |
-
uksort($this->url_remap, array(&$this, 'cmpr_strlen'));
|
934 |
-
|
935 |
-
foreach ($this->url_remap as $from_url => $to_url) {
|
936 |
-
// remap urls in post_content
|
937 |
-
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)", $from_url, $to_url));
|
938 |
-
// remap enclosure urls
|
939 |
-
$result = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'", $from_url, $to_url));
|
940 |
-
}
|
941 |
-
return $result;
|
942 |
-
}
|
943 |
-
|
944 |
-
// return the difference in length between two strings
|
945 |
-
public function cmpr_strlen($a, $b) {
|
946 |
-
return strlen($b) - strlen($a);
|
947 |
-
}
|
948 |
-
|
949 |
-
/**
|
950 |
-
* Update _thumbnail_id meta to new, imported attachment IDs
|
951 |
-
*/
|
952 |
-
function remap_featured_images() {
|
953 |
-
// cycle through posts that have a featured image
|
954 |
-
foreach ($this->featured_images as $post_id => $value) {
|
955 |
-
if (isset($this->processed_posts[$value])) {
|
956 |
-
$new_id = $this->processed_posts[$value];
|
957 |
-
// only update if there's a difference
|
958 |
-
if ($new_id != $value)
|
959 |
-
update_post_meta($post_id, '_thumbnail_id', $new_id);
|
960 |
-
}
|
961 |
-
}
|
962 |
-
}
|
963 |
-
|
964 |
-
function max_attachment_size() {
|
965 |
-
return apply_filters('import_attachment_size_limit', 0);
|
966 |
-
}
|
967 |
-
}
|
968 |
-
|
1 |
+
<?php
|
2 |
+
namespace mp_timetable\classes\models;
|
3 |
+
|
4 |
+
use mp_timetable\classes\libs;
|
5 |
+
use mp_timetable\plugin_core\classes\Model as Model;
|
6 |
+
use mp_timetable\plugin_core\classes\View as View;
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Model Events
|
10 |
+
*/
|
11 |
+
class Import extends Model {
|
12 |
+
|
13 |
+
protected static $instance;
|
14 |
+
protected $table;
|
15 |
+
var $max_wxr_version = 1.2; // max. supported WXR version
|
16 |
+
var $id; // WXR attachment ID
|
17 |
+
var $file;
|
18 |
+
|
19 |
+
var $import_data;
|
20 |
+
// information to import from WXR file
|
21 |
+
var $version;
|
22 |
+
var $authors = array();
|
23 |
+
var $posts = array();
|
24 |
+
var $terms = array();
|
25 |
+
var $time_slots = array();
|
26 |
+
var $categories = array();
|
27 |
+
var $tags = array();
|
28 |
+
var $base_url = '';
|
29 |
+
|
30 |
+
var $processed_authors = array();
|
31 |
+
var $author_mapping = array();
|
32 |
+
var $processed_terms = array();
|
33 |
+
var $processed_posts = array();
|
34 |
+
var $post_orphans = array();
|
35 |
+
var $processed_menu_items = array();
|
36 |
+
var $menu_item_orphans = array();
|
37 |
+
var $missing_menu_items = array();
|
38 |
+
|
39 |
+
var $fetch_attachments = false;
|
40 |
+
var $url_remap = array();
|
41 |
+
var $featured_images = array();
|
42 |
+
|
43 |
+
public static function get_instance() {
|
44 |
+
if (null === self::$instance) {
|
45 |
+
self::$instance = new self();
|
46 |
+
}
|
47 |
+
return self::$instance;
|
48 |
+
}
|
49 |
+
|
50 |
+
function __construct() {
|
51 |
+
parent::__construct();
|
52 |
+
$this->table = Events::get_instance()->table_name;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
*
|
57 |
+
* @param bool $return_me
|
58 |
+
* @param string $meta_key
|
59 |
+
*
|
60 |
+
* @return bool
|
61 |
+
*/
|
62 |
+
public function mptt_filter_postmeta($return_me, $meta_key) {
|
63 |
+
if ('_edit_lock' == $meta_key)
|
64 |
+
$return_me = true;
|
65 |
+
return $return_me;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Exist time slot
|
70 |
+
*
|
71 |
+
* @param array $time_slot
|
72 |
+
*
|
73 |
+
* @return bool
|
74 |
+
*/
|
75 |
+
public function post_time_slot_exist($time_slot = array()) {
|
76 |
+
global $wpdb;
|
77 |
+
if (empty($time_slot)) {
|
78 |
+
return false;
|
79 |
+
}
|
80 |
+
$data = $wpdb->get_results('SELECT id FROM ' . $this->table . ' WHERE column_id = "' . $time_slot['column'] . '" AND event_id = "' . $time_slot['event'] . '" AND event_start = "' . $time_slot['event_start'] . '" AND event_end = "' . $time_slot['event_end'] . '"');
|
81 |
+
return empty($data) ? false : true;
|
82 |
+
}
|
83 |
+
|
84 |
+
public function header() {
|
85 |
+
View::get_instance()->render_html('../admin/import/header');
|
86 |
+
}
|
87 |
+
|
88 |
+
public function footer() {
|
89 |
+
View::get_instance()->render_html('../admin/import/footer');
|
90 |
+
}
|
91 |
+
|
92 |
+
public function greet() {
|
93 |
+
View::get_instance()->render_html('../admin/import/greet');
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Decide whether or not the importer is allowed to create users.
|
98 |
+
* Default is true, can be filtered via import_allow_create_users
|
99 |
+
*
|
100 |
+
* @return bool True if creating users is allowed
|
101 |
+
*/
|
102 |
+
public function allow_create_users() {
|
103 |
+
return apply_filters('import_allow_create_users', true);
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Decide whether or not the importer should attempt to download attachment files.
|
108 |
+
* Default is true, can be filtered via import_allow_fetch_attachments. The choice
|
109 |
+
* made at the import options screen must also be true, false here hides that checkbox.
|
110 |
+
*
|
111 |
+
* @return bool True if downloading attachments is allowed
|
112 |
+
*/
|
113 |
+
public function allow_fetch_attachments() {
|
114 |
+
return apply_filters('import_allow_fetch_attachments', true);
|
115 |
+
}
|
116 |
+
|
117 |
+
public function import_options() {
|
118 |
+
$j = 0;
|
119 |
+
?>
|
120 |
+
<form action="<?php echo admin_url('admin.php?import=mptt-importer&step=2'); ?>" method="post">
|
121 |
+
<?php wp_nonce_field('mptt-importer'); ?>
|
122 |
+
<input type="hidden" name="import_id" value="<?php echo $this->id; ?>"/>
|
123 |
+
|
124 |
+
<?php if (!empty($this->authors)) : ?>
|
125 |
+
<h3><?php _e('Assign Authors', 'mp-timetable'); ?></h3>
|
126 |
+
<p><?php _e('To make it easier for you to edit and save the imported content, you may want to reassign the author of the imported item to an existing user of this site. For example, you may want to import all the entries as <code>admin</code>s entries.', 'mp-timetable'); ?></p>
|
127 |
+
<?php if ($this->allow_create_users()) : ?>
|
128 |
+
<p><?php printf(__('If a new user is created by WordPress, a new password will be randomly generated and the new user’s role will be set as %s. Manually changing the new user’s details will be necessary.', 'mp-timetable'), esc_html(get_option('default_role'))); ?></p>
|
129 |
+
<?php endif; ?>
|
130 |
+
<ol id="authors">
|
131 |
+
<?php foreach ($this->authors as $author) : ?>
|
132 |
+
<li><?php $this->author_select($j++, $author); ?></li>
|
133 |
+
<?php endforeach; ?>
|
134 |
+
</ol>
|
135 |
+
<?php endif; ?>
|
136 |
+
|
137 |
+
<?php if ($this->allow_fetch_attachments()) : ?>
|
138 |
+
<h3><?php _e('Import Attachments', 'mp-timetable'); ?></h3>
|
139 |
+
<p>
|
140 |
+
<input type="checkbox" value="1" name="fetch_attachments" id="import-attachments"/>
|
141 |
+
<label for="import-attachments"><?php _e('Download and import file attachments', 'mp-timetable'); ?></label>
|
142 |
+
</p>
|
143 |
+
<?php endif; ?>
|
144 |
+
|
145 |
+
<p class="submit"><input type="submit" class="button" value="<?php esc_attr_e('Submit', 'mp-timetable'); ?>"/></p>
|
146 |
+
</form>
|
147 |
+
<?php
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Display import options for an individual author. That is, either create
|
152 |
+
* a new user based on import info or map to an existing user
|
153 |
+
*
|
154 |
+
* @param int $n Index for each author in the form
|
155 |
+
* @param array $author Author information, e.g. login, display name, email
|
156 |
+
*/
|
157 |
+
function author_select($n, $author) {
|
158 |
+
_e('Import author:', 'mp-timetable');
|
159 |
+
echo ' <strong>' . esc_html($author['author_display_name']);
|
160 |
+
if ($this->version != '1.0') echo ' (' . esc_html($author['author_login']) . ')';
|
161 |
+
echo '</strong><br />';
|
162 |
+
|
163 |
+
if ($this->version != '1.0')
|
164 |
+
echo '<div style="margin-left:18px">';
|
165 |
+
|
166 |
+
$create_users = $this->allow_create_users();
|
167 |
+
if ($create_users) {
|
168 |
+
if ($this->version != '1.0') {
|
169 |
+
_e('or create new user with login name:', 'mp-timetable');
|
170 |
+
$value = '';
|
171 |
+
} else {
|
172 |
+
_e('as a new user:', 'mp-timetable');
|
173 |
+
$value = esc_attr(sanitize_user($author['author_login'], true));
|
174 |
+
}
|
175 |
+
|
176 |
+
echo ' <input type="text" name="user_new[' . $n . ']" value="' . $value . '" /><br />';
|
177 |
+
}
|
178 |
+
|
179 |
+
if (!$create_users && $this->version == '1.0')
|
180 |
+
_e('assign posts to an existing user:', 'mp-timetable');
|
181 |
+
else
|
182 |
+
_e('or assign posts to an existing user:', 'mp-timetable');
|
183 |
+
wp_dropdown_users(array('name' => "user_map[$n]", 'multi' => true, 'show_option_all' => __('- Select -', 'mp-timetable')));
|
184 |
+
echo '<input type="hidden" name="imported_authors[' . $n . ']" value="' . esc_attr($author['author_login']) . '" />';
|
185 |
+
|
186 |
+
if ($this->version != '1.0')
|
187 |
+
echo '</div>';
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Import
|
192 |
+
*/
|
193 |
+
public function import() {
|
194 |
+
$this->header();
|
195 |
+
$step = empty($_GET['step']) ? 0 : (int)$_GET['step'];
|
196 |
+
switch ($step) {
|
197 |
+
case 0:
|
198 |
+
$this->greet();
|
199 |
+
break;
|
200 |
+
case 1:
|
201 |
+
check_admin_referer('import-upload');
|
202 |
+
if ($this->handle_upload()) {
|
203 |
+
$this->import_options();
|
204 |
+
}
|
205 |
+
break;
|
206 |
+
case 2:
|
207 |
+
if (!empty($_POST['import_id'])) {
|
208 |
+
check_admin_referer('mptt-importer');
|
209 |
+
$this->fetch_attachments = (!empty($_POST['fetch_attachments']) && $this->allow_fetch_attachments());
|
210 |
+
$this->id = (int)$_POST['import_id'];
|
211 |
+
$file = get_attached_file($this->id);
|
212 |
+
} else {
|
213 |
+
check_admin_referer('import-upload');
|
214 |
+
$this->handle_upload();
|
215 |
+
$this->fetch_attachments = $this->allow_fetch_attachments();
|
216 |
+
$file = $this->file;
|
217 |
+
}
|
218 |
+
set_time_limit(0);
|
219 |
+
add_filter('import_post_meta_key', array($this, 'is_valid_meta_key'));
|
220 |
+
add_filter('http_request_timeout', array(&$this, 'bump_request_timeout'));
|
221 |
+
|
222 |
+
$this->get_author_mapping();
|
223 |
+
|
224 |
+
$this->process_start($file);
|
225 |
+
$this->process_end();
|
226 |
+
break;
|
227 |
+
}
|
228 |
+
$this->footer();
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Import start
|
233 |
+
*
|
234 |
+
* @param $file
|
235 |
+
*/
|
236 |
+
public function process_start($file) {
|
237 |
+
$this->import_data = $this->parse($file);
|
238 |
+
$this->get_authors_from_import();
|
239 |
+
$this->version = $this->import_data['version'];
|
240 |
+
$this->posts = $this->import_data['posts'];
|
241 |
+
$this->terms = $this->import_data['terms'];
|
242 |
+
$this->time_slots = $this->import_data['time_slots'];
|
243 |
+
|
244 |
+
wp_suspend_cache_invalidation(true);
|
245 |
+
$this->process_terms();
|
246 |
+
$this->process_posts();
|
247 |
+
$this->process_time_slot();
|
248 |
+
wp_suspend_cache_invalidation(false);
|
249 |
+
$this->backfill_parents();
|
250 |
+
$this->backfill_attachment_urls();
|
251 |
+
$this->remap_featured_images();
|
252 |
+
wp_defer_term_counting(true);
|
253 |
+
wp_defer_comment_counting(true);
|
254 |
+
|
255 |
+
do_action('import_start');
|
256 |
+
}
|
257 |
+
|
258 |
+
public function process_end() {
|
259 |
+
wp_import_cleanup($this->id);
|
260 |
+
|
261 |
+
wp_cache_flush();
|
262 |
+
foreach (get_taxonomies() as $tax) {
|
263 |
+
delete_option("{$tax}_children");
|
264 |
+
_get_term_hierarchy($tax);
|
265 |
+
}
|
266 |
+
wp_defer_term_counting(false);
|
267 |
+
wp_defer_comment_counting(false);
|
268 |
+
|
269 |
+
echo '<p>' . __('All done.', 'mp-timetable') . ' <a href="' . admin_url() . '">' . __('Have fun!', 'mp-timetable') . '</a>' . '</p>';
|
270 |
+
echo '<p>' . __('Remember to update the passwords and roles of imported users.', 'mp-timetable') . '</p>';
|
271 |
+
|
272 |
+
do_action('import_end');
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* If fetching attachments is enabled then attempt to create a new attachment
|
277 |
+
*
|
278 |
+
* @param array $post Attachment post details from WXR
|
279 |
+
* @param string $url URL to fetch attachment from
|
280 |
+
*
|
281 |
+
* @return int|/WP_Error Post ID on success, WP_Error otherwise
|
282 |
+
*/
|
283 |
+
public function process_attachment($post, $url) {
|
284 |
+
if (!$this->fetch_attachments)
|
285 |
+
return new \WP_Error('attachment_processing_error',
|
286 |
+
__('Fetching attachments is not enabled', 'mp-timetable'));
|
287 |
+
|
288 |
+
// if the URL is absolute, but does not contain address, then upload it assuming base_site_url
|
289 |
+
if (preg_match('|^/[\w\W]+$|', $url))
|
290 |
+
$url = rtrim($this->base_url, '/') . $url;
|
291 |
+
|
292 |
+
$upload = $this->fetch_remote_file($url, $post);
|
293 |
+
if (is_wp_error($upload))
|
294 |
+
return $upload;
|
295 |
+
|
296 |
+
if ($info = wp_check_filetype($upload['file']))
|
297 |
+
$post['post_mime_type'] = $info['type'];
|
298 |
+
else
|
299 |
+
return new \WP_Error('attachment_processing_error', __('Invalid file type', 'mp-timetable'));
|
300 |
+
|
301 |
+
$post['guid'] = $upload['url'];
|
302 |
+
|
303 |
+
// as per wp-admin/includes/upload.php
|
304 |
+
$post_id = wp_insert_attachment($post, $upload['file']);
|
305 |
+
wp_update_attachment_metadata($post_id, wp_generate_attachment_metadata($post_id, $upload['file']));
|
306 |
+
|
307 |
+
// remap resized image URLs, works by stripping the extension and remapping the URL stub.
|
308 |
+
if (preg_match('!^image/!', $info['type'])) {
|
309 |
+
$parts = pathinfo($url);
|
310 |
+
$name = basename($parts['basename'], ".{$parts['extension']}"); // PATHINFO_FILENAME in PHP 5.2
|
311 |
+
|
312 |
+
$parts_new = pathinfo($upload['url']);
|
313 |
+
$name_new = basename($parts_new['basename'], ".{$parts_new['extension']}");
|
314 |
+
|
315 |
+
$this->url_remap[$parts['dirname'] . '/' . $name] = $parts_new['dirname'] . '/' . $name_new;
|
316 |
+
}
|
317 |
+
|
318 |
+
return $post_id;
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* Get file by URL and write upload
|
323 |
+
*
|
324 |
+
* @param $url
|
325 |
+
* @param $upload
|
326 |
+
* @param int $redirection
|
327 |
+
*
|
328 |
+
* @return bool
|
329 |
+
*/
|
330 |
+
private function write_file($url, $upload, $redirection = 5) {
|
331 |
+
$options = array();
|
332 |
+
$options['redirection'] = $redirection;
|
333 |
+
|
334 |
+
if (false == $upload['file'])
|
335 |
+
$options['method'] = 'HEAD';
|
336 |
+
else
|
337 |
+
$options['method'] = 'GET';
|
338 |
+
|
339 |
+
$response = wp_safe_remote_request($url, $options);
|
340 |
+
|
341 |
+
if (false == $upload['file']) {
|
342 |
+
return false;
|
343 |
+
}
|
344 |
+
// GET request - write it to the supplied filename
|
345 |
+
$out_fp = fopen($upload['file'], 'w');
|
346 |
+
if (!$out_fp) {
|
347 |
+
return false;
|
348 |
+
}
|
349 |
+
|
350 |
+
fwrite($out_fp, wp_remote_retrieve_body($response));
|
351 |
+
fclose($out_fp);
|
352 |
+
clearstatcache();
|
353 |
+
return true;
|
354 |
+
}
|
355 |
+
|
356 |
+
/**
|
357 |
+
* Attempt to download a remote file attachment
|
358 |
+
*
|
359 |
+
* @param string $url URL of item to fetch
|
360 |
+
* @param array $post Attachment details
|
361 |
+
*
|
362 |
+
* @return array|\WP_Error Local file location details on success, WP_Error otherwise
|
363 |
+
*/
|
364 |
+
public function fetch_remote_file($url, $post) {
|
365 |
+
// extract the file name and extension from the url
|
366 |
+
$file_name = basename($url);
|
367 |
+
|
368 |
+
// get placeholder file in the upload dir with a unique, sanitized filename
|
369 |
+
$upload = wp_upload_bits($file_name, 0, '', $post['upload_date']);
|
370 |
+
if ($upload['error'])
|
371 |
+
return new \WP_Error('upload_dir_error', $upload['error']);
|
372 |
+
|
373 |
+
// fetch the remote url and write it to the placeholder file
|
374 |
+
$response_data = wp_safe_remote_head($url);
|
375 |
+
$headers = wp_remote_retrieve_headers($response_data);
|
376 |
+
$headers['response'] = wp_remote_retrieve_response_code($response_data);
|
377 |
+
if (!$headers) {
|
378 |
+
@unlink($upload['file']);
|
379 |
+
return new \WP_Error('import_file_error', __('Remote server did not respond', 'mp-timetable'));
|
380 |
+
}
|
381 |
+
|
382 |
+
// make sure the fetch was successful
|
383 |
+
if ($headers['response'] != '200') {
|
384 |
+
@unlink($upload['file']);
|
385 |
+
return new \WP_Error('import_file_error', sprintf(__('Remote server returned error response %1$d %2$s', 'mp-timetable'), esc_html($headers['response']), get_status_header_desc($headers['response'])));
|
386 |
+
}
|
387 |
+
|
388 |
+
$this->write_file($url, $upload);
|
389 |
+
|
390 |
+
$filesize = filesize($upload['file']);
|
391 |
+
|
392 |
+
if (isset($headers['content-length']) && $filesize != $headers['content-length']) {
|
393 |
+
@unlink($upload['file']);
|
394 |
+
return new \WP_Error('import_file_error', __('Remote file is incorrect size', 'mp-timetable'));
|
395 |
+
}
|
396 |
+
|
397 |
+
if (0 == $filesize) {
|
398 |
+
@unlink($upload['file']);
|
399 |
+
return new \WP_Error('import_file_error', __('Zero size file downloaded', 'mp-timetable'));
|
400 |
+
}
|
401 |
+
|
402 |
+
$max_size = (int)$this->max_attachment_size();
|
403 |
+
if (!empty($max_size) && $filesize > $max_size) {
|
404 |
+
@unlink($upload['file']);
|
405 |
+
return new \WP_Error('import_file_error', sprintf(__('Remote file is too large, limit is %s', 'mp-timetable'), size_format($max_size)));
|
406 |
+
}
|
407 |
+
|
408 |
+
// keep track of the old and new urls so we can substitute them later
|
409 |
+
$this->url_remap[$url] = $upload['url'];
|
410 |
+
$this->url_remap[$post['guid']] = $upload['url']; // r13735, really needed?
|
411 |
+
// keep track of the destination if the remote url is redirected somewhere else
|
412 |
+
if (isset($headers['x-final-location']) && $headers['x-final-location'] != $url)
|
413 |
+
$this->url_remap[$headers['x-final-location']] = $upload['url'];
|
414 |
+
|
415 |
+
return $upload;
|
416 |
+
}
|
417 |
+
|
418 |
+
public function handle_upload() {
|
419 |
+
$file = wp_import_handle_upload();
|
420 |
+
|
421 |
+
if (isset($file['error'])) {
|
422 |
+
echo '<p><strong>' . __('Sorry, there has been an error.', 'mp-timetable') . '</strong><br />';
|
423 |
+
echo esc_html($file['error']) . '</p>';
|
424 |
+
return false;
|
425 |
+
} else if (!file_exists($file['file'])) {
|
426 |
+
echo '<p><strong>' . __('Sorry, there has been an error.', 'mp-timetable') . '</strong><br />';
|
427 |
+
printf(__('The export file could not be found at <code>%s</code>. It is likely that this was caused by a permissions problem.', 'mp-timetable'), esc_html($file['file']));
|
428 |
+
echo '</p>';
|
429 |
+
return false;
|
430 |
+
}
|
431 |
+
$this->file = $file['file'];
|
432 |
+
$this->id = (int)$file['id'];
|
433 |
+
$this->import_data = $this->parse($file['file']);
|
434 |
+
|
435 |
+
if (is_wp_error($this->import_data)) {
|
436 |
+
echo '<p><strong>' . __('Sorry, there has been an error.', 'mp-timetable') . '</strong><br />';
|
437 |
+
echo esc_html($this->import_data->get_error_message()) . '</p>';
|
438 |
+
return false;
|
439 |
+
}
|
440 |
+
|
441 |
+
$this->version = $this->import_data['version'];
|
442 |
+
if ($this->version > $this->max_wxr_version) {
|
443 |
+
echo '<div class="error"><p><strong>';
|
444 |
+
printf(__('This WXR file (version %s) may not be supported by this version of the importer. Please consider updating.', 'mp-timetable'), esc_html($this->import_data['version']));
|
445 |
+
echo '</strong></p></div>';
|
446 |
+
}
|
447 |
+
$this->get_authors_from_import();
|
448 |
+
return true;
|
449 |
+
}
|
450 |
+
|
451 |
+
/**
|
452 |
+
* Parse a WXR file
|
453 |
+
*
|
454 |
+
* @param string $file Path to WXR file for parsing
|
455 |
+
*
|
456 |
+
* @return array Information gathered from the WXR file
|
457 |
+
*/
|
458 |
+
function parse($file) {
|
459 |
+
$parser = new libs\WXR_Parser();
|
460 |
+
return $parser->parse($file);
|
461 |
+
}
|
462 |
+
|
463 |
+
/**
|
464 |
+
* Decide if the given meta key maps to information we will want to import
|
465 |
+
*
|
466 |
+
* @param string $key The meta key to check
|
467 |
+
*
|
468 |
+
* @return string|bool The key if we do want to import, false if not
|
469 |
+
*/
|
470 |
+
function is_valid_meta_key($key) {
|
471 |
+
// skip attachment metadata since we'll regenerate it from scratch
|
472 |
+
// skip _edit_lock as not relevant for import
|
473 |
+
if (in_array($key, array('_wp_attached_file', '_wp_attachment_metadata', '_edit_lock')))
|
474 |
+
return false;
|
475 |
+
return $key;
|
476 |
+
}
|
477 |
+
|
478 |
+
/**
|
479 |
+
* Added to http_request_timeout filter to force timeout at 60 seconds during import
|
480 |
+
* @return int 60
|
481 |
+
*/
|
482 |
+
function bump_request_timeout() {
|
483 |
+
return 60;
|
484 |
+
}
|
485 |
+
|
486 |
+
/**
|
487 |
+
* Retrieve authors from parsed WXR data
|
488 |
+
*
|
489 |
+
* Uses the provided author information from WXR 1.1 files
|
490 |
+
* or extracts info from each post for WXR 1.0 files
|
491 |
+
*
|
492 |
+
*/
|
493 |
+
function get_authors_from_import() {
|
494 |
+
if (!empty($this->import_data['authors'])) {
|
495 |
+
$this->authors = $this->import_data['authors'];
|
496 |
+
// no author information, grab it from the posts
|
497 |
+
} else {
|
498 |
+
foreach ($this->import_data['posts'] as $post) {
|
499 |
+
$login = sanitize_user($post['post_author'], true);
|
500 |
+
if (empty($login)) {
|
501 |
+
printf(__('Failed to import author %s. Their posts will be attributed to the current user.', 'mp-timetable'), esc_html($post['post_author']));
|
502 |
+
echo '<br />';
|
503 |
+
continue;
|
504 |
+
}
|
505 |
+
|
506 |
+
if (!isset($this->authors[$login]))
|
507 |
+
$this->authors[$login] = array(
|
508 |
+
'author_login' => $login,
|
509 |
+
'author_display_name' => $post['post_author']
|
510 |
+
);
|
511 |
+
}
|
512 |
+
}
|
513 |
+
}
|
514 |
+
|
515 |
+
/**
|
516 |
+
* Map old author logins to local user IDs based on decisions made
|
517 |
+
* in import options form. Can map to an existing user, create a new user
|
518 |
+
* or falls back to the current user in case of error with either of the previous
|
519 |
+
*/
|
520 |
+
function get_author_mapping() {
|
521 |
+
if ( ! isset( $_POST['imported_authors'] ) )
|
522 |
+
return;
|
523 |
+
|
524 |
+
$create_users = $this->allow_create_users();
|
525 |
+
|
526 |
+
foreach ( (array) $_POST['imported_authors'] as $i => $old_login ) {
|
527 |
+
// Multisite adds strtolower to sanitize_user. Need to sanitize here to stop breakage in process_posts.
|
528 |
+
$santized_old_login = sanitize_user( $old_login, true );
|
529 |
+
$old_id = isset( $this->authors[$old_login]['author_id'] ) ? intval($this->authors[$old_login]['author_id']) : false;
|
530 |
+
|
531 |
+
if ( ! empty( $_POST['user_map'][$i] ) ) {
|
532 |
+
$user = get_userdata( intval($_POST['user_map'][$i]) );
|
533 |
+
if ( isset( $user->ID ) ) {
|
534 |
+
if ( $old_id )
|
535 |
+
$this->processed_authors[$old_id] = $user->ID;
|
536 |
+
$this->author_mapping[$santized_old_login] = $user->ID;
|
537 |
+
}
|
538 |
+
} else if ( $create_users ) {
|
539 |
+
if ( ! empty($_POST['user_new'][$i]) ) {
|
540 |
+
$user_id = wp_create_user( $_POST['user_new'][$i], wp_generate_password() );
|
541 |
+
} else if ( $this->version != '1.0' ) {
|
542 |
+
$user_data = array(
|
543 |
+
'user_login' => $old_login,
|
544 |
+
'user_pass' => wp_generate_password(),
|
545 |
+
'user_email' => isset( $this->authors[$old_login]['author_email'] ) ? $this->authors[$old_login]['author_email'] : '',
|
546 |
+
'display_name' => $this->authors[$old_login]['author_display_name'],
|
547 |
+
'first_name' => isset( $this->authors[$old_login]['author_first_name'] ) ? $this->authors[$old_login]['author_first_name'] : '',
|
548 |
+
'last_name' => isset( $this->authors[$old_login]['author_last_name'] ) ? $this->authors[$old_login]['author_last_name'] : '',
|
549 |
+
);
|
550 |
+
$user_id = wp_insert_user( $user_data );
|
551 |
+
}
|
552 |
+
|
553 |
+
if ( ! is_wp_error( $user_id ) ) {
|
554 |
+
if ( $old_id )
|
555 |
+
$this->processed_authors[$old_id] = $user_id;
|
556 |
+
$this->author_mapping[$santized_old_login] = $user_id;
|
557 |
+
} else {
|
558 |
+
printf( __( 'Failed to create new user for %s. Their posts will be attributed to the current user.', 'mp-timetable' ), esc_html($this->authors[$old_login]['author_display_name']) );
|
559 |
+
if ( defined('IMPORT_DEBUG') && IMPORT_DEBUG )
|
560 |
+
echo ' ' . $user_id->get_error_message();
|
561 |
+
echo '<br />';
|
562 |
+
}
|
563 |
+
}
|
564 |
+
|
565 |
+
// failsafe: if the user_id was invalid, default to the current user
|
566 |
+
if ( ! isset( $this->author_mapping[$santized_old_login] ) ) {
|
567 |
+
if ( $old_id )
|
568 |
+
$this->processed_authors[$old_id] = (int) get_current_user_id();
|
569 |
+
$this->author_mapping[$santized_old_login] = (int) get_current_user_id();
|
570 |
+
}
|
571 |
+
}
|
572 |
+
}
|
573 |
+
|
574 |
+
/**
|
575 |
+
* Create new terms based on import information
|
576 |
+
*
|
577 |
+
* Doesn't create a term its slug already exists
|
578 |
+
*/
|
579 |
+
function process_terms() {
|
580 |
+
$this->terms = apply_filters('wp_import_terms', $this->terms);
|
581 |
+
|
582 |
+
if (empty($this->terms))
|
583 |
+
return;
|
584 |
+
|
585 |
+
foreach ($this->terms as $term) {
|
586 |
+
// if the term already exists in the correct taxonomy leave it alone
|
587 |
+
$term_id = term_exists($term['slug'], $term['term_taxonomy']);
|
588 |
+
if ($term_id) {
|
589 |
+
if (is_array($term_id)) $term_id = $term_id['term_id'];
|
590 |
+
if (isset($term['term_id']))
|
591 |
+
$this->processed_terms[intval($term['term_id'])] = (int)$term_id;
|
592 |
+
continue;
|
593 |
+
}
|
594 |
+
|
595 |
+
if (empty($term['term_parent'])) {
|
596 |
+
$parent = 0;
|
597 |
+
} else {
|
598 |
+
$parent = term_exists($term['term_parent'], $term['term_taxonomy']);
|
599 |
+
if (is_array($parent)) $parent = $parent['term_id'];
|
600 |
+
}
|
601 |
+
$description = isset($term['term_description']) ? $term['term_description'] : '';
|
602 |
+
$termarr = array('slug' => $term['slug'], 'description' => $description, 'parent' => intval($parent));
|
603 |
+
|
604 |
+
$id = wp_insert_term($term['term_name'], $term['term_taxonomy'], $termarr);
|
605 |
+
if (!is_wp_error($id)) {
|
606 |
+
if (isset($term['term_id']))
|
607 |
+
$this->processed_terms[intval($term['term_id'])] = $id['term_id'];
|
608 |
+
} else {
|
609 |
+
printf(__('Failed to import %s %s', 'mp-timetable'), esc_html($term['term_taxonomy']), esc_html($term['term_name']));
|
610 |
+
if (defined('IMPORT_DEBUG') && IMPORT_DEBUG)
|
611 |
+
echo ': ' . $id->get_error_message();
|
612 |
+
echo '<br />';
|
613 |
+
continue;
|
614 |
+
}
|
615 |
+
}
|
616 |
+
|
617 |
+
unset($this->terms);
|
618 |
+
}
|
619 |
+
|
620 |
+
public function process_time_slot() {
|
621 |
+
global $wpdb;
|
622 |
+
$rows_affected = array();
|
623 |
+
$time_slots = $this->import_data['time_slots'];
|
624 |
+
if (!empty($this->import_data['time_slots'])) {
|
625 |
+
foreach ($time_slots as $time_slot) {
|
626 |
+
$exist_time_slot = $this->post_time_slot_exist($time_slot);
|
627 |
+
if (!$exist_time_slot) {
|
628 |
+
$rows_affected[] = $wpdb->insert($this->table, array(
|
629 |
+
'column_id' => $time_slot['column'],
|
630 |
+
'event_id' => $time_slot['event'],
|
631 |
+
'event_start' => date('H:i:s', strtotime($time_slot['event_start'])),
|
632 |
+
'event_end' => date('H:i:s', strtotime($time_slot['event_end'])),
|
633 |
+
'user_id' => $time_slot['user_id'],
|
634 |
+
'description' => $time_slot['description']
|
635 |
+
));
|
636 |
+
}
|
637 |
+
}
|
638 |
+
}
|
639 |
+
}
|
640 |
+
|
641 |
+
/**
|
642 |
+
* Create new posts based on import information
|
643 |
+
*
|
644 |
+
* Posts marked as having a parent which doesn't exist will become top level items.
|
645 |
+
* Doesn't create a new post if: the post type doesn't exist, the given post ID
|
646 |
+
* is already noted as imported or a post with the same title and date already exists.
|
647 |
+
* Note that new/updated terms, comments and meta are imported for the last of the above.
|
648 |
+
*/
|
649 |
+
public function process_posts() {
|
650 |
+
$this->posts = apply_filters('wp_import_posts', $this->posts);
|
651 |
+
|
652 |
+
foreach ($this->posts as $post) {
|
653 |
+
$post = apply_filters('wp_import_post_data_raw', $post);
|
654 |
+
|
655 |
+
if (!post_type_exists($post['post_type'])) {
|
656 |
+
printf(__('Failed to import “%s”: Invalid post type %s', 'mp-timetable'),
|
657 |
+
esc_html($post['post_title']), esc_html($post['post_type']));
|
658 |
+
echo '<br />';
|
659 |
+
do_action('wp_import_post_exists', $post);
|
660 |
+
continue;
|
661 |
+
}
|
662 |
+
|
663 |
+
if (isset($this->processed_posts[$post['post_id']]) && !empty($post['post_id']))
|
664 |
+
continue;
|
665 |
+
|
666 |
+
if ($post['status'] == 'auto-draft')
|
667 |
+
continue;
|
668 |
+
|
669 |
+
$post_type_object = get_post_type_object($post['post_type']);
|
670 |
+
|
671 |
+
$post_exists = post_exists($post['post_title'], '', $post['post_date']);
|
672 |
+
if ($post_exists && get_post_type($post_exists) == $post['post_type']) {
|
673 |
+
printf(__('%s “%s” already exists.', 'mp-timetable'), $post_type_object->labels->singular_name, esc_html($post['post_title']));
|
674 |
+
echo '<br />';
|
675 |
+
$comment_post_ID = $post_id = $post_exists;
|
676 |
+
} else {
|
677 |
+
$post_parent = (int)$post['post_parent'];
|
678 |
+
if ($post_parent) {
|
679 |
+
// if we already know the parent, map it to the new local ID
|
680 |
+
if (isset($this->processed_posts[$post_parent])) {
|
681 |
+
$post_parent = $this->processed_posts[$post_parent];
|
682 |
+
// otherwise record the parent for later
|
683 |
+
} else {
|
684 |
+
$this->post_orphans[intval($post['post_id'])] = $post_parent;
|
685 |
+
$post_parent = 0;
|
686 |
+
}
|
687 |
+
}
|
688 |
+
|
689 |
+
// map the post author
|
690 |
+
$author = sanitize_user($post['post_author'], true);
|
691 |
+
if (isset($this->author_mapping[$author]))
|
692 |
+
$author = $this->author_mapping[$author];
|
693 |
+
else
|
694 |
+
$author = (int)get_current_user_id();
|
695 |
+
|
696 |
+
$postdata = array(
|
697 |
+
'import_id' => $post['post_id'], 'post_author' => $author, 'post_date' => $post['post_date'],
|
698 |
+
'post_date_gmt' => $post['post_date_gmt'], 'post_content' => $post['post_content'],
|
699 |
+
'post_excerpt' => $post['post_excerpt'], 'post_title' => $post['post_title'],
|
700 |
+
'post_status' => $post['status'], 'post_name' => $post['post_name'],
|
701 |
+
'comment_status' => $post['comment_status'], 'ping_status' => $post['ping_status'],
|
702 |
+
'guid' => $post['guid'], 'post_parent' => $post_parent, 'menu_order' => $post['menu_order'],
|
703 |
+
'post_type' => $post['post_type'], 'post_password' => $post['post_password']
|
704 |
+
);
|
705 |
+
|
706 |
+
$original_post_ID = $post['post_id'];
|
707 |
+
$postdata = apply_filters('wp_import_post_data_processed', $postdata, $post);
|
708 |
+
|
709 |
+
if ('attachment' == $postdata['post_type']) {
|
710 |
+
$remote_url = !empty($post['attachment_url']) ? $post['attachment_url'] : $post['guid'];
|
711 |
+
|
712 |
+
// try to use _wp_attached file for upload folder placement to ensure the same location as the export site
|
713 |
+
// e.g. location is 2003/05/image.jpg but the attachment post_date is 2010/09, see media_handle_upload()
|
714 |
+
$postdata['upload_date'] = $post['post_date'];
|
715 |
+
if (isset($post['postmeta'])) {
|
716 |
+
foreach ($post['postmeta'] as $meta) {
|
717 |
+
if ($meta['key'] == '_wp_attached_file') {
|
718 |
+
if (preg_match('%^[0-9]{4}/[0-9]{2}%', $meta['value'], $matches))
|
719 |
+
$postdata['upload_date'] = $matches[0];
|
720 |
+
break;
|
721 |
+
}
|
722 |
+
}
|
723 |
+
}
|
724 |
+
|
725 |
+
$comment_post_ID = $post_id = $this->process_attachment($postdata, $remote_url);
|
726 |
+
} else {
|
727 |
+
$comment_post_ID = $post_id = wp_insert_post($postdata, true);
|
728 |
+
do_action('wp_import_insert_post', $post_id, $original_post_ID, $postdata, $post);
|
729 |
+
}
|
730 |
+
|
731 |
+
if (is_wp_error($post_id)) {
|
732 |
+
printf(__('Failed to import %s “%s”', 'mp-timetable'),
|
733 |
+
$post_type_object->labels->singular_name, esc_html($post['post_title']));
|
734 |
+
if (defined('IMPORT_DEBUG') && IMPORT_DEBUG)
|
735 |
+
echo ': ' . $post_id->get_error_message();
|
736 |
+
echo '<br />';
|
737 |
+
continue;
|
738 |
+
}
|
739 |
+
|
740 |
+
if ($post['is_sticky'] == 1)
|
741 |
+
stick_post($post_id);
|
742 |
+
}
|
743 |
+
|
744 |
+
// map pre-import ID to local ID
|
745 |
+
$this->processed_posts[intval($post['post_id'])] = (int)$post_id;
|
746 |
+
|
747 |
+
if (!isset($post['terms']))
|
748 |
+
$post['terms'] = array();
|
749 |
+
|
750 |
+
$post['terms'] = apply_filters('wp_import_post_terms', $post['terms'], $post_id, $post);
|
751 |
+
|
752 |
+
// add categories, tags and other terms
|
753 |
+
if (!empty($post['terms'])) {
|
754 |
+
$terms_to_set = array();
|
755 |
+
foreach ($post['terms'] as $term) {
|
756 |
+
// back compat with WXR 1.0 map 'tag' to 'post_tag'
|
757 |
+
$taxonomy = ('tag' == $term['domain']) ? 'post_tag' : $term['domain'];
|
758 |
+
$term_exists = term_exists($term['slug'], $taxonomy);
|
759 |
+
$term_id = is_array($term_exists) ? $term_exists['term_id'] : $term_exists;
|
760 |
+
if (!$term_id) {
|
761 |
+
$t = wp_insert_term($term['name'], $taxonomy, array('slug' => $term['slug']));
|
762 |
+
if (!is_wp_error($t)) {
|
763 |
+
$term_id = $t['term_id'];
|
764 |
+
do_action('wp_import_insert_term', $t, $term, $post_id, $post);
|
765 |
+
} else {
|
766 |
+
printf(__('Failed to import %s %s', 'mp-timetable'), esc_html($taxonomy), esc_html($term['name']));
|
767 |
+
if (defined('IMPORT_DEBUG') && IMPORT_DEBUG)
|
768 |
+
echo ': ' . $t->get_error_message();
|
769 |
+
echo '<br />';
|
770 |
+
do_action('wp_import_insert_term_failed', $t, $term, $post_id, $post);
|
771 |
+
continue;
|
772 |
+
}
|
773 |
+
}
|
774 |
+
$terms_to_set[$taxonomy][] = intval($term_id);
|
775 |
+
}
|
776 |
+
|
777 |
+
foreach ($terms_to_set as $tax => $ids) {
|
778 |
+
$tt_ids = wp_set_post_terms($post_id, $ids, $tax);
|
779 |
+
do_action('wp_import_set_post_terms', $tt_ids, $ids, $tax, $post_id, $post);
|
780 |
+
}
|
781 |
+
unset($post['terms'], $terms_to_set);
|
782 |
+
}
|
783 |
+
|
784 |
+
if (!isset($post['comments']))
|
785 |
+
$post['comments'] = array();
|
786 |
+
|
787 |
+
$post['comments'] = apply_filters('wp_import_post_comments', $post['comments'], $post_id, $post);
|
788 |
+
|
789 |
+
// add/update comments
|
790 |
+
if (!empty($post['comments'])) {
|
791 |
+
$num_comments = 0;
|
792 |
+
$inserted_comments = array();
|
793 |
+
foreach ($post['comments'] as $comment) {
|
794 |
+
$comment_id = $comment['comment_id'];
|
795 |
+
$newcomments[$comment_id]['comment_post_ID'] = $comment_post_ID;
|
796 |
+
$newcomments[$comment_id]['comment_author'] = $comment['comment_author'];
|
797 |
+
$newcomments[$comment_id]['comment_author_email'] = $comment['comment_author_email'];
|
798 |
+
$newcomments[$comment_id]['comment_author_IP'] = $comment['comment_author_IP'];
|
799 |
+
$newcomments[$comment_id]['comment_author_url'] = $comment['comment_author_url'];
|
800 |
+
$newcomments[$comment_id]['comment_date'] = $comment['comment_date'];
|
801 |
+
$newcomments[$comment_id]['comment_date_gmt'] = $comment['comment_date_gmt'];
|
802 |
+
$newcomments[$comment_id]['comment_content'] = $comment['comment_content'];
|
803 |
+
$newcomments[$comment_id]['comment_approved'] = $comment['comment_approved'];
|
804 |
+
$newcomments[$comment_id]['comment_type'] = $comment['comment_type'];
|
805 |
+
$newcomments[$comment_id]['comment_parent'] = $comment['comment_parent'];
|
806 |
+
$newcomments[$comment_id]['commentmeta'] = isset($comment['commentmeta']) ? $comment['commentmeta'] : array();
|
807 |
+
if (isset($this->processed_authors[$comment['comment_user_id']]))
|
808 |
+
$newcomments[$comment_id]['user_id'] = $this->processed_authors[$comment['comment_user_id']];
|
809 |
+
}
|
810 |
+
ksort($newcomments);
|
811 |
+
|
812 |
+
foreach ($newcomments as $key => $comment) {
|
813 |
+
// if this is a new post we can skip the comment_exists() check
|
814 |
+
if (!$post_exists || !comment_exists($comment['comment_author'], $comment['comment_date'])) {
|
815 |
+
if (isset($inserted_comments[$comment['comment_parent']]))
|
816 |
+
$comment['comment_parent'] = $inserted_comments[$comment['comment_parent']];
|
817 |
+
$comment = wp_filter_comment($comment);
|
818 |
+
$inserted_comments[$key] = wp_insert_comment($comment);
|
819 |
+
do_action('wp_import_insert_comment', $inserted_comments[$key], $comment, $comment_post_ID, $post);
|
820 |
+
|
821 |
+
foreach ($comment['commentmeta'] as $meta) {
|
822 |
+
$value = maybe_unserialize($meta['value']);
|
823 |
+
add_comment_meta($inserted_comments[$key], $meta['key'], $value);
|
824 |
+
}
|
825 |
+
|
826 |
+
$num_comments++;
|
827 |
+
}
|
828 |
+
}
|
829 |
+
unset($newcomments, $inserted_comments, $post['comments']);
|
830 |
+
}
|
831 |
+
|
832 |
+
// change time_slot data if post ID change
|
833 |
+
|
834 |
+
if (!empty($original_post_ID)) {
|
835 |
+
if ($original_post_ID != $post_id) {
|
836 |
+
foreach ($this->import_data['time_slots'] as $key => $time_slot) {
|
837 |
+
if ($post['post_type'] == 'mp-event' && $time_slot['event'] == $original_post_ID) {
|
838 |
+
$time_slot['event'] = $post_id;
|
839 |
+
} elseif ($post['post_type'] == 'mp-column' && $time_slot['column'] == $original_post_ID) {
|
840 |
+
$time_slot['column'] = $post_id;
|
841 |
+
} else {
|
842 |
+
continue;
|
843 |
+
}
|
844 |
+
$this->import_data['time_slots'][$key] = $time_slot;
|
845 |
+
}
|
846 |
+
}
|
847 |
+
}
|
848 |
+
|
849 |
+
|
850 |
+
if (!isset($post['postmeta'])) {
|
851 |
+
$post['postmeta'] = array();
|
852 |
+
}
|
853 |
+
$post['postmeta'] = apply_filters('wp_import_post_meta', $post['postmeta'], $post_id, $post);
|
854 |
+
// add/update post meta
|
855 |
+
if (!empty($post['postmeta'])) {
|
856 |
+
foreach ($post['postmeta'] as $meta) {
|
857 |
+
$key = apply_filters('import_post_meta_key', $meta['key'], $post_id, $post);
|
858 |
+
$value = false;
|
859 |
+
|
860 |
+
if ('_edit_last' == $key) {
|
861 |
+
if (isset($this->processed_authors[intval($meta['value'])]))
|
862 |
+
$value = $this->processed_authors[intval($meta['value'])];
|
863 |
+
else
|
864 |
+
$key = false;
|
865 |
+
}
|
866 |
+
|
867 |
+
if ($key) {
|
868 |
+
// export gets meta straight from the DB so could have a serialized string
|
869 |
+
if (!$value)
|
870 |
+
$value = maybe_unserialize($meta['value']);
|
871 |
+
|
872 |
+
add_post_meta($post_id, $key, $value);
|
873 |
+
do_action('import_post_meta', $post_id, $key, $value);
|
874 |
+
|
875 |
+
// if the post has a featured image, take note of this in case of remap
|
876 |
+
if ('_thumbnail_id' == $key)
|
877 |
+
$this->featured_images[$post_id] = (int)$value;
|
878 |
+
}
|
879 |
+
}
|
880 |
+
}
|
881 |
+
}
|
882 |
+
|
883 |
+
unset($this->posts);
|
884 |
+
}
|
885 |
+
|
886 |
+
/**
|
887 |
+
* Attempt to associate posts and menu items with previously missing parents
|
888 |
+
*
|
889 |
+
* An imported post's parent may not have been imported when it was first created
|
890 |
+
* so try again. Similarly for child menu items and menu items which were missing
|
891 |
+
* the object (e.g. post) they represent in the menu
|
892 |
+
*/
|
893 |
+
function backfill_parents() {
|
894 |
+
global $wpdb;
|
895 |
+
|
896 |
+
// find parents for post orphans
|
897 |
+
foreach ($this->post_orphans as $child_id => $parent_id) {
|
898 |
+
$local_child_id = $local_parent_id = false;
|
899 |
+
if (isset($this->processed_posts[$child_id]))
|
900 |
+
$local_child_id = $this->processed_posts[$child_id];
|
901 |
+
if (isset($this->processed_posts[$parent_id]))
|
902 |
+
$local_parent_id = $this->processed_posts[$parent_id];
|
903 |
+
|
904 |
+
if ($local_child_id && $local_parent_id)
|
905 |
+
$wpdb->update($wpdb->posts, array('post_parent' => $local_parent_id), array('ID' => $local_child_id), '%d', '%d');
|
906 |
+
}
|
907 |
+
|
908 |
+
// all other posts/terms are imported, retry menu items with missing associated object
|
909 |
+
$missing_menu_items = $this->missing_menu_items;
|
910 |
+
// foreach ($missing_menu_items as $item)
|
911 |
+
// $this->process_menu_item($item);
|
912 |
+
|
913 |
+
// find parents for menu item orphans
|
914 |
+
foreach ($this->menu_item_orphans as $child_id => $parent_id) {
|
915 |
+
$local_child_id = $local_parent_id = 0;
|
916 |
+
if (isset($this->processed_menu_items[$child_id]))
|
917 |
+
$local_child_id = $this->processed_menu_items[$child_id];
|
918 |
+
if (isset($this->processed_menu_items[$parent_id]))
|
919 |
+
$local_parent_id = $this->processed_menu_items[$parent_id];
|
920 |
+
|
921 |
+
if ($local_child_id && $local_parent_id)
|
922 |
+
update_post_meta($local_child_id, '_menu_item_menu_item_parent', (int)$local_parent_id);
|
923 |
+
}
|
924 |
+
}
|
925 |
+
|
926 |
+
/**
|
927 |
+
* Use stored mapping information to update old attachment URLs
|
928 |
+
*/
|
929 |
+
function backfill_attachment_urls() {
|
930 |
+
global $wpdb;
|
931 |
+
$result = array();
|
932 |
+
// make sure we do the longest urls first, in case one is a substring of another
|
933 |
+
uksort($this->url_remap, array(&$this, 'cmpr_strlen'));
|
934 |
+
|
935 |
+
foreach ($this->url_remap as $from_url => $to_url) {
|
936 |
+
// remap urls in post_content
|
937 |
+
$wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)", $from_url, $to_url));
|
938 |
+
// remap enclosure urls
|
939 |
+
$result = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'", $from_url, $to_url));
|
940 |
+
}
|
941 |
+
return $result;
|
942 |
+
}
|
943 |
+
|
944 |
+
// return the difference in length between two strings
|
945 |
+
public function cmpr_strlen($a, $b) {
|
946 |
+
return strlen($b) - strlen($a);
|
947 |
+
}
|
948 |
+
|
949 |
+
/**
|
950 |
+
* Update _thumbnail_id meta to new, imported attachment IDs
|
951 |
+
*/
|
952 |
+
function remap_featured_images() {
|
953 |
+
// cycle through posts that have a featured image
|
954 |
+
foreach ($this->featured_images as $post_id => $value) {
|
955 |
+
if (isset($this->processed_posts[$value])) {
|
956 |
+
$new_id = $this->processed_posts[$value];
|
957 |
+
// only update if there's a difference
|
958 |
+
if ($new_id != $value)
|
959 |
+
update_post_meta($post_id, '_thumbnail_id', $new_id);
|
960 |
+
}
|
961 |
+
}
|
962 |
+
}
|
963 |
+
|
964 |
+
function max_attachment_size() {
|
965 |
+
return apply_filters('import_attachment_size_limit', 0);
|
966 |
+
}
|
967 |
+
}
|
968 |
+
|
classes/models/class-settings.php
CHANGED
@@ -1,106 +1,106 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\classes\models;
|
4 |
-
|
5 |
-
use mp_timetable\plugin_core\classes\Model as Model;
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Model Events
|
9 |
-
*/
|
10 |
-
class Settings extends Model {
|
11 |
-
|
12 |
-
protected static $instance;
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Settings constructor.
|
16 |
-
*/
|
17 |
-
public function __construct() {
|
18 |
-
parent::__construct();
|
19 |
-
}
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Get instance
|
23 |
-
*
|
24 |
-
* @return Settings
|
25 |
-
*/
|
26 |
-
public static function get_instance() {
|
27 |
-
if (null === self::$instance) {
|
28 |
-
self::$instance = new self();
|
29 |
-
}
|
30 |
-
return self::$instance;
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Render settings
|
35 |
-
*/
|
36 |
-
public function render_settings() {
|
37 |
-
$data = $this->get_settings();
|
38 |
-
|
39 |
-
$this->get_view()->render_html("settings/general", array('settings' => $data), true);
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Get Settings
|
44 |
-
*
|
45 |
-
* @return mixed
|
46 |
-
*/
|
47 |
-
public function get_settings() {
|
48 |
-
|
49 |
-
$mp_timetable_general = array(
|
50 |
-
'theme_mode' => 'theme',
|
51 |
-
);
|
52 |
-
|
53 |
-
$settings = get_option('mp_timetable_general', $mp_timetable_general);
|
54 |
-
|
55 |
-
if ($this->is_theme_supports()) {
|
56 |
-
$settings['theme_mode'] = 'plugin';
|
57 |
-
}
|
58 |
-
|
59 |
-
return $settings;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Theme supports plugin mode.
|
64 |
-
*
|
65 |
-
* @return string
|
66 |
-
*/
|
67 |
-
public function is_theme_supports() {
|
68 |
-
|
69 |
-
return current_theme_supports('mp-timetable');
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Save meta data Column post type
|
74 |
-
*
|
75 |
-
*/
|
76 |
-
public function save_settings() {
|
77 |
-
|
78 |
-
if ( current_user_can('manage_options') && !empty( $_POST['theme_mode'] ) ) {
|
79 |
-
|
80 |
-
$options = array();
|
81 |
-
$options['theme_mode'] = $_POST['theme_mode'];
|
82 |
-
|
83 |
-
update_option('mp_timetable_general', $options);
|
84 |
-
}
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Check whether to use single room template from plugin
|
89 |
-
*
|
90 |
-
* @return bool
|
91 |
-
*/
|
92 |
-
public function is_plugin_template_mode() {
|
93 |
-
return ($this->get_template_mode() === 'plugin');
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Retrieve template mode. Possible values: plugin, theme.
|
98 |
-
*
|
99 |
-
* @return string
|
100 |
-
*/
|
101 |
-
public function get_template_mode() {
|
102 |
-
$options = $this->get_settings();
|
103 |
-
|
104 |
-
return isset($options['theme_mode']) ? $options['theme_mode'] : 'theme';
|
105 |
-
}
|
106 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\classes\models;
|
4 |
+
|
5 |
+
use mp_timetable\plugin_core\classes\Model as Model;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Model Events
|
9 |
+
*/
|
10 |
+
class Settings extends Model {
|
11 |
+
|
12 |
+
protected static $instance;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Settings constructor.
|
16 |
+
*/
|
17 |
+
public function __construct() {
|
18 |
+
parent::__construct();
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Get instance
|
23 |
+
*
|
24 |
+
* @return Settings
|
25 |
+
*/
|
26 |
+
public static function get_instance() {
|
27 |
+
if (null === self::$instance) {
|
28 |
+
self::$instance = new self();
|
29 |
+
}
|
30 |
+
return self::$instance;
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Render settings
|
35 |
+
*/
|
36 |
+
public function render_settings() {
|
37 |
+
$data = $this->get_settings();
|
38 |
+
|
39 |
+
$this->get_view()->render_html("settings/general", array('settings' => $data), true);
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Get Settings
|
44 |
+
*
|
45 |
+
* @return mixed
|
46 |
+
*/
|
47 |
+
public function get_settings() {
|
48 |
+
|
49 |
+
$mp_timetable_general = array(
|
50 |
+
'theme_mode' => 'theme',
|
51 |
+
);
|
52 |
+
|
53 |
+
$settings = get_option('mp_timetable_general', $mp_timetable_general);
|
54 |
+
|
55 |
+
if ($this->is_theme_supports()) {
|
56 |
+
$settings['theme_mode'] = 'plugin';
|
57 |
+
}
|
58 |
+
|
59 |
+
return $settings;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Theme supports plugin mode.
|
64 |
+
*
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function is_theme_supports() {
|
68 |
+
|
69 |
+
return current_theme_supports('mp-timetable');
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Save meta data Column post type
|
74 |
+
*
|
75 |
+
*/
|
76 |
+
public function save_settings() {
|
77 |
+
|
78 |
+
if ( current_user_can('manage_options') && !empty( $_POST['theme_mode'] ) ) {
|
79 |
+
|
80 |
+
$options = array();
|
81 |
+
$options['theme_mode'] = $_POST['theme_mode'];
|
82 |
+
|
83 |
+
update_option('mp_timetable_general', $options);
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Check whether to use single room template from plugin
|
89 |
+
*
|
90 |
+
* @return bool
|
91 |
+
*/
|
92 |
+
public function is_plugin_template_mode() {
|
93 |
+
return ($this->get_template_mode() === 'plugin');
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Retrieve template mode. Possible values: plugin, theme.
|
98 |
+
*
|
99 |
+
* @return string
|
100 |
+
*/
|
101 |
+
public function get_template_mode() {
|
102 |
+
$options = $this->get_settings();
|
103 |
+
|
104 |
+
return isset($options['theme_mode']) ? $options['theme_mode'] : 'theme';
|
105 |
+
}
|
106 |
}
|
classes/modules/class-menu.php
CHANGED
@@ -1,33 +1,33 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\plugin_core\classes\modules;
|
4 |
-
|
5 |
-
class Menu {
|
6 |
-
|
7 |
-
protected static $instance;
|
8 |
-
|
9 |
-
public static function get_instance() {
|
10 |
-
if (null === self::$instance) {
|
11 |
-
self::$instance = new self();
|
12 |
-
}
|
13 |
-
return self::$instance;
|
14 |
-
}
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Add menu page
|
18 |
-
*
|
19 |
-
* @param $params
|
20 |
-
*/
|
21 |
-
public function add_menu_page(array $params) {
|
22 |
-
add_menu_page($params['page_title'], $params['menu_title'], $params['capability'], $params['menu_slug'], $params['function'], $params['icon_url'], $params['position']);
|
23 |
-
}
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Add submenu page
|
27 |
-
*
|
28 |
-
* @param $params
|
29 |
-
*/
|
30 |
-
public function add_submenu_page(array $params) {
|
31 |
-
add_submenu_page($params['parent_slug'], $params['page_title'], $params['menu_title'], $params['capability'], $params['menu_slug'], $params['function']);
|
32 |
-
}
|
33 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\plugin_core\classes\modules;
|
4 |
+
|
5 |
+
class Menu {
|
6 |
+
|
7 |
+
protected static $instance;
|
8 |
+
|
9 |
+
public static function get_instance() {
|
10 |
+
if (null === self::$instance) {
|
11 |
+
self::$instance = new self();
|
12 |
+
}
|
13 |
+
return self::$instance;
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Add menu page
|
18 |
+
*
|
19 |
+
* @param $params
|
20 |
+
*/
|
21 |
+
public function add_menu_page(array $params) {
|
22 |
+
add_menu_page($params['page_title'], $params['menu_title'], $params['capability'], $params['menu_slug'], $params['function'], $params['icon_url'], $params['position']);
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Add submenu page
|
27 |
+
*
|
28 |
+
* @param $params
|
29 |
+
*/
|
30 |
+
public function add_submenu_page(array $params) {
|
31 |
+
add_submenu_page($params['parent_slug'], $params['page_title'], $params['menu_title'], $params['capability'], $params['menu_slug'], $params['function']);
|
32 |
+
}
|
33 |
+
}
|
classes/modules/class-post.php
CHANGED
@@ -1,104 +1,104 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\plugin_core\classes\modules;
|
4 |
-
|
5 |
-
use Mp_Time_Table;
|
6 |
-
use mp_timetable\plugin_core\classes\Module as Module;
|
7 |
-
|
8 |
-
class Post extends Module {
|
9 |
-
|
10 |
-
protected static $instance;
|
11 |
-
|
12 |
-
public static function get_instance() {
|
13 |
-
if (null === self::$instance) {
|
14 |
-
self::$instance = new self();
|
15 |
-
}
|
16 |
-
return self::$instance;
|
17 |
-
}
|
18 |
-
|
19 |
-
public function pre_get_posts($query) {
|
20 |
-
if ($query->is_author() && $query->is_main_query() && !is_admin()) {
|
21 |
-
|
22 |
-
$post_types = $query->get('post_type');
|
23 |
-
if ( !is_array($post_types) && !empty($post_types) ) {
|
24 |
-
$post_types = explode(',', $post_types);
|
25 |
-
}
|
26 |
-
if ( empty($post_types) )
|
27 |
-
$post_types = array('post');
|
28 |
-
|
29 |
-
$post_types[] = 'mp-event';
|
30 |
-
$query->set('post_type', $post_types);
|
31 |
-
}
|
32 |
-
|
33 |
-
return $query;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* add meta _boxes
|
38 |
-
*/
|
39 |
-
public function add_meta_boxes() {
|
40 |
-
add_meta_box('mp-event_data', __('Timeslots', 'mp-timetable'), array($this->get('events'), 'render_event_data'), 'mp-event', 'normal', 'high', array('post_type' => 'mp-event'));
|
41 |
-
add_meta_box('mp_event_options', __('Settings', 'mp-timetable'), array($this->get('events'), 'render_event_options'), 'mp-event', 'normal', 'high', array('post_type' => 'mp-event'));
|
42 |
-
add_meta_box('mp-columns', __('Column Type', 'mp-timetable'), array($this->get('column'), 'render_column_options'), 'mp-column', 'normal', 'high', array('post_type' => 'mp-column'));
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Save custom_post
|
47 |
-
*
|
48 |
-
* @param $post_id
|
49 |
-
* @param $post
|
50 |
-
*/
|
51 |
-
public function save_custom_post($post_id, $post) {
|
52 |
-
|
53 |
-
$request = $_REQUEST;
|
54 |
-
|
55 |
-
if ( !empty( $request[Mp_Time_Table::get_plugin_name() . '_noncename'] ) ) {
|
56 |
-
|
57 |
-
$post_type = $request['post_type'];
|
58 |
-
|
59 |
-
if ( !wp_verify_nonce($request[Mp_Time_Table::get_plugin_name() . '_noncename'], Mp_Time_Table::get_plugin_path())) {
|
60 |
-
return $post->ID;
|
61 |
-
}
|
62 |
-
|
63 |
-
// Is the user allowed to edit the post or page?
|
64 |
-
if (!current_user_can('edit_post', $post->ID)) {
|
65 |
-
return $post->ID;
|
66 |
-
}
|
67 |
-
// verify if this is an auto save routine. If it is our form has not been submitted, so we dont want to do anything
|
68 |
-
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
69 |
-
return $post->ID;
|
70 |
-
}
|
71 |
-
|
72 |
-
//Save post by post_type
|
73 |
-
switch ($post_type) {
|
74 |
-
case 'mp-event':
|
75 |
-
$this->get('events')->save_event_data(array('post' => $post,
|
76 |
-
'event_data' => (!empty($request['event_data'])) ? $request['event_data'] : null,
|
77 |
-
'event_meta' => (!empty($request['event_meta'])) ? $request['event_meta'] : null));
|
78 |
-
break;
|
79 |
-
case 'mp-column':
|
80 |
-
$this->get('column')->save_column_data(array('post' => $post, 'data' => $request['column']));
|
81 |
-
break;
|
82 |
-
default:
|
83 |
-
break;
|
84 |
-
}
|
85 |
-
}
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Before delete custom post
|
90 |
-
*
|
91 |
-
* @param $post_id
|
92 |
-
* @param $post
|
93 |
-
*/
|
94 |
-
public function before_delete_custom_post($post_id) {
|
95 |
-
global $post_type;
|
96 |
-
if ($post_type === 'mp-column') {
|
97 |
-
$this->get('column')->before_delete_column($post_id);
|
98 |
-
} elseif ($post_type === 'mp-event') {
|
99 |
-
$this->get('events')->before_delete_event($post_id);
|
100 |
-
}
|
101 |
-
|
102 |
-
return;
|
103 |
-
}
|
104 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\plugin_core\classes\modules;
|
4 |
+
|
5 |
+
use Mp_Time_Table;
|
6 |
+
use mp_timetable\plugin_core\classes\Module as Module;
|
7 |
+
|
8 |
+
class Post extends Module {
|
9 |
+
|
10 |
+
protected static $instance;
|
11 |
+
|
12 |
+
public static function get_instance() {
|
13 |
+
if (null === self::$instance) {
|
14 |
+
self::$instance = new self();
|
15 |
+
}
|
16 |
+
return self::$instance;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function pre_get_posts($query) {
|
20 |
+
if ($query->is_author() && $query->is_main_query() && !is_admin()) {
|
21 |
+
|
22 |
+
$post_types = $query->get('post_type');
|
23 |
+
if ( !is_array($post_types) && !empty($post_types) ) {
|
24 |
+
$post_types = explode(',', $post_types);
|
25 |
+
}
|
26 |
+
if ( empty($post_types) )
|
27 |
+
$post_types = array('post');
|
28 |
+
|
29 |
+
$post_types[] = 'mp-event';
|
30 |
+
$query->set('post_type', $post_types);
|
31 |
+
}
|
32 |
+
|
33 |
+
return $query;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* add meta _boxes
|
38 |
+
*/
|
39 |
+
public function add_meta_boxes() {
|
40 |
+
add_meta_box('mp-event_data', __('Timeslots', 'mp-timetable'), array($this->get('events'), 'render_event_data'), 'mp-event', 'normal', 'high', array('post_type' => 'mp-event'));
|
41 |
+
add_meta_box('mp_event_options', __('Settings', 'mp-timetable'), array($this->get('events'), 'render_event_options'), 'mp-event', 'normal', 'high', array('post_type' => 'mp-event'));
|
42 |
+
add_meta_box('mp-columns', __('Column Type', 'mp-timetable'), array($this->get('column'), 'render_column_options'), 'mp-column', 'normal', 'high', array('post_type' => 'mp-column'));
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Save custom_post
|
47 |
+
*
|
48 |
+
* @param $post_id
|
49 |
+
* @param $post
|
50 |
+
*/
|
51 |
+
public function save_custom_post($post_id, $post) {
|
52 |
+
|
53 |
+
$request = $_REQUEST;
|
54 |
+
|
55 |
+
if ( !empty( $request[Mp_Time_Table::get_plugin_name() . '_noncename'] ) ) {
|
56 |
+
|
57 |
+
$post_type = $request['post_type'];
|
58 |
+
|
59 |
+
if ( !wp_verify_nonce($request[Mp_Time_Table::get_plugin_name() . '_noncename'], Mp_Time_Table::get_plugin_path())) {
|
60 |
+
return $post->ID;
|
61 |
+
}
|
62 |
+
|
63 |
+
// Is the user allowed to edit the post or page?
|
64 |
+
if (!current_user_can('edit_post', $post->ID)) {
|
65 |
+
return $post->ID;
|
66 |
+
}
|
67 |
+
// verify if this is an auto save routine. If it is our form has not been submitted, so we dont want to do anything
|
68 |
+
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
69 |
+
return $post->ID;
|
70 |
+
}
|
71 |
+
|
72 |
+
//Save post by post_type
|
73 |
+
switch ($post_type) {
|
74 |
+
case 'mp-event':
|
75 |
+
$this->get('events')->save_event_data(array('post' => $post,
|
76 |
+
'event_data' => (!empty($request['event_data'])) ? $request['event_data'] : null,
|
77 |
+
'event_meta' => (!empty($request['event_meta'])) ? $request['event_meta'] : null));
|
78 |
+
break;
|
79 |
+
case 'mp-column':
|
80 |
+
$this->get('column')->save_column_data(array('post' => $post, 'data' => $request['column']));
|
81 |
+
break;
|
82 |
+
default:
|
83 |
+
break;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Before delete custom post
|
90 |
+
*
|
91 |
+
* @param $post_id
|
92 |
+
* @param $post
|
93 |
+
*/
|
94 |
+
public function before_delete_custom_post($post_id) {
|
95 |
+
global $post_type;
|
96 |
+
if ($post_type === 'mp-column') {
|
97 |
+
$this->get('column')->before_delete_column($post_id);
|
98 |
+
} elseif ($post_type === 'mp-event') {
|
99 |
+
$this->get('events')->before_delete_event($post_id);
|
100 |
+
}
|
101 |
+
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
}
|
classes/modules/class-taxonomy.php
CHANGED
@@ -1,42 +1,42 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace mp_timetable\plugin_core\classes\modules;
|
4 |
-
|
5 |
-
use mp_timetable\plugin_core\classes\Module;
|
6 |
-
use mp_timetable\plugin_core\classes\View;
|
7 |
-
|
8 |
-
class Taxonomy extends Module {
|
9 |
-
|
10 |
-
protected static $instance;
|
11 |
-
|
12 |
-
public static function get_instance() {
|
13 |
-
if (null === self::$instance) {
|
14 |
-
self::$instance = new self();
|
15 |
-
}
|
16 |
-
return self::$instance;
|
17 |
-
}
|
18 |
-
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Render html for filter taxonomy link
|
22 |
-
*
|
23 |
-
* @param $post
|
24 |
-
* @param $tax_name
|
25 |
-
*
|
26 |
-
* @return string
|
27 |
-
*/
|
28 |
-
public function get_the_term_filter_list($post, $tax_name) {
|
29 |
-
$taxonomies = wp_get_post_terms($post->ID, $tax_name);
|
30 |
-
$taxonomies_html = "";
|
31 |
-
$last_key = key(array_slice($taxonomies, -1, 1, TRUE));
|
32 |
-
|
33 |
-
foreach ($taxonomies as $key => $tax) {
|
34 |
-
$data["wp"] = $tax;
|
35 |
-
$data["filter_link"] = admin_url('edit.php?post_type=' . $post->post_type . '&' . $tax->taxonomy . '=' . $tax->slug);
|
36 |
-
$taxonomies_html .= View::get_instance()->render_html("taxonomies/taxonomy-link", $data, false);
|
37 |
-
$taxonomies_html .= ($last_key != $key) ? ', ' : '';
|
38 |
-
}
|
39 |
-
return (!empty($taxonomies_html)) ? $taxonomies_html : "—";
|
40 |
-
}
|
41 |
-
|
42 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace mp_timetable\plugin_core\classes\modules;
|
4 |
+
|
5 |
+
use mp_timetable\plugin_core\classes\Module;
|
6 |
+
use mp_timetable\plugin_core\classes\View;
|
7 |
+
|
8 |
+
class Taxonomy extends Module {
|
9 |
+
|
10 |
+
protected static $instance;
|
11 |
+
|
12 |
+
public static function get_instance() {
|
13 |
+
if (null === self::$instance) {
|
14 |
+
self::$instance = new self();
|
15 |
+
}
|
16 |
+
return self::$instance;
|
17 |
+
}
|
18 |
+
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Render html for filter taxonomy link
|
22 |
+
*
|
23 |
+
* @param $post
|
24 |
+
* @param $tax_name
|
25 |
+
*
|
26 |
+
* @return string
|
27 |
+
*/
|
28 |
+
public function get_the_term_filter_list($post, $tax_name) {
|
29 |
+
$taxonomies = wp_get_post_terms($post->ID, $tax_name);
|
30 |
+
$taxonomies_html = "";
|
31 |
+
$last_key = key(array_slice($taxonomies, -1, 1, TRUE));
|
32 |
+
|
33 |
+
foreach ($taxonomies as $key => $tax) {
|
34 |
+
$data["wp"] = $tax;
|
35 |
+
$data["filter_link"] = admin_url('edit.php?post_type=' . $post->post_type . '&' . $tax->taxonomy . '=' . $tax->slug);
|
36 |
+
$taxonomies_html .= View::get_instance()->render_html("taxonomies/taxonomy-link", $data, false);
|
37 |
+
$taxonomies_html .= ($last_key != $key) ? ', ' : '';
|
38 |
+
}
|
39 |
+
return (!empty($taxonomies_html)) ? $taxonomies_html : "—";
|
40 |
+
}
|
41 |
+
|
42 |
+
}
|
classes/widgets/class-mp-timetable-elementor-widget.php
ADDED
@@ -0,0 +1,473 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace timetable\classes\widgets;
|
4 |
+
|
5 |
+
use \Elementor\Controls_Manager;
|
6 |
+
use \Elementor\Plugin;
|
7 |
+
use \Elementor\Group_Control_Typography;
|
8 |
+
use \Elementor\Widget_Base;
|
9 |
+
|
10 |
+
use \mp_timetable\plugin_core\classes\Shortcode;
|
11 |
+
|
12 |
+
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
13 |
+
|
14 |
+
class Mp_Timetable_Widget extends Widget_Base {
|
15 |
+
|
16 |
+
public function get_name() {
|
17 |
+
return 'timetable';
|
18 |
+
}
|
19 |
+
|
20 |
+
public function get_title() {
|
21 |
+
return __( 'Timetable', 'mp-timetable' );
|
22 |
+
}
|
23 |
+
|
24 |
+
public function get_icon() {
|
25 |
+
return 'eicon-table';
|
26 |
+
}
|
27 |
+
|
28 |
+
public function get_categories() {
|
29 |
+
return [ 'basic' ];
|
30 |
+
}
|
31 |
+
|
32 |
+
public function get_posts_type( $post_type ) {
|
33 |
+
$args = [ 'post_type' => $post_type, 'numberposts' => '-1' ];
|
34 |
+
$posts = get_posts( $args );
|
35 |
+
$return = [];
|
36 |
+
|
37 |
+
if ( ! empty( $posts ) ) {
|
38 |
+
foreach ( $posts as $post ) {
|
39 |
+
$return[ $post->ID ] = $post->post_title;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
return $return;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function get_terms_type( $term_type ) {
|
47 |
+
$terms = get_terms( $term_type, 'orderby=count&hide_empty=0' );
|
48 |
+
|
49 |
+
$return = [];
|
50 |
+
|
51 |
+
if ( ! empty( $terms ) ) {
|
52 |
+
foreach ( $terms as $term ) {
|
53 |
+
$return[ $term->term_id ] = $term->name;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
return $return;
|
58 |
+
}
|
59 |
+
|
60 |
+
private static function show_shortcode( $attributes ) {
|
61 |
+
foreach ( $attributes as $key => $value ) {
|
62 |
+
// [] -> '1,2,3'
|
63 |
+
if ( is_array( $value ) ) {
|
64 |
+
$attributes[ $key ] = implode( ',', $value );
|
65 |
+
}
|
66 |
+
// 'sub_title' -> 'sub-title'
|
67 |
+
if ( $key == 'sub_title' ) {
|
68 |
+
$attributes[ 'sub-title' ] = $attributes[ $key ];
|
69 |
+
unset( $attributes[ $key ] );
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
echo Shortcode::get_instance()->show_shortcode( $attributes );
|
74 |
+
}
|
75 |
+
|
76 |
+
public static function elementor_render_timetable( $attributes ) {
|
77 |
+
|
78 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
79 |
+
|
80 |
+
self::show_shortcode( $attributes );
|
81 |
+
}
|
82 |
+
|
83 |
+
protected function _register_controls() {
|
84 |
+
$controls = $this;
|
85 |
+
|
86 |
+
$controls->start_controls_section(
|
87 |
+
'content_settings',
|
88 |
+
[
|
89 |
+
'label' => __( 'Settings', 'mp-timetable' ),
|
90 |
+
'tab' => Controls_Manager::TAB_CONTENT,
|
91 |
+
]
|
92 |
+
);
|
93 |
+
|
94 |
+
$controls->add_control(
|
95 |
+
'label',
|
96 |
+
[
|
97 |
+
'label' => esc_html__( 'Filter title to display all events', 'mp-timetable' ),
|
98 |
+
'label_block' => true,
|
99 |
+
'type' => Controls_Manager::TEXT,
|
100 |
+
'default' => esc_html__( 'All Events', 'mp-timetable' ),
|
101 |
+
]
|
102 |
+
);
|
103 |
+
|
104 |
+
$controls->add_control(
|
105 |
+
'hide_label',
|
106 |
+
[
|
107 |
+
'label' => esc_html__( 'Hide \'All Events\' option', 'mp-timetable' ),
|
108 |
+
'type' => Controls_Manager::SWITCHER,
|
109 |
+
'default' => 'no',
|
110 |
+
]
|
111 |
+
);
|
112 |
+
|
113 |
+
$controls->add_control(
|
114 |
+
'col',
|
115 |
+
[
|
116 |
+
'label' => esc_html__( 'Columns', 'mp-timetable' ),
|
117 |
+
'label_block' => true,
|
118 |
+
'type' => Controls_Manager::SELECT2,
|
119 |
+
'multiple' => true,
|
120 |
+
'options' => $this->get_posts_type( 'mp-column' ),
|
121 |
+
'separator' => 'before',
|
122 |
+
]
|
123 |
+
);
|
124 |
+
|
125 |
+
$controls->add_control(
|
126 |
+
'events',
|
127 |
+
[
|
128 |
+
'label' => esc_html__( 'Specific events', 'mp-timetable' ),
|
129 |
+
'label_block' => true,
|
130 |
+
'type' => Controls_Manager::SELECT2,
|
131 |
+
'multiple' => true,
|
132 |
+
'options' => $this->get_posts_type( 'mp-event' ),
|
133 |
+
]
|
134 |
+
);
|
135 |
+
|
136 |
+
$controls->add_control(
|
137 |
+
'event_categ',
|
138 |
+
[
|
139 |
+
'label' => esc_html__( 'Event categories', 'mp-timetable' ),
|
140 |
+
'label_block' => true,
|
141 |
+
'type' => Controls_Manager::SELECT2,
|
142 |
+
'multiple' => true,
|
143 |
+
'options' => $this->get_terms_type( 'mp-event_category' ),
|
144 |
+
'separator' => 'after',
|
145 |
+
]
|
146 |
+
);
|
147 |
+
|
148 |
+
$controls->add_control(
|
149 |
+
'title',
|
150 |
+
[
|
151 |
+
'label' => esc_html__( 'Title', 'mp-timetable' ),
|
152 |
+
'type' => Controls_Manager::SWITCHER,
|
153 |
+
'label_off' => esc_html__( 'Hide', 'mp-timetable' ),
|
154 |
+
'label_on' => esc_html__( 'Show', 'mp-timetable' ),
|
155 |
+
'default' => 'yes',
|
156 |
+
]
|
157 |
+
);
|
158 |
+
|
159 |
+
$controls->add_control(
|
160 |
+
'time',
|
161 |
+
[
|
162 |
+
'label' => esc_html__( 'Time', 'mp-timetable' ),
|
163 |
+
'type' => Controls_Manager::SWITCHER,
|
164 |
+
'label_off' => esc_html__( 'Hide', 'mp-timetable' ),
|
165 |
+
'label_on' => esc_html__( 'Show', 'mp-timetable' ),
|
166 |
+
'default' => 'yes',
|
167 |
+
]
|
168 |
+
);
|
169 |
+
|
170 |
+
$controls->add_control(
|
171 |
+
'sub_title',
|
172 |
+
[
|
173 |
+
'label' => esc_html__( 'Subtitle', 'mp-timetable' ),
|
174 |
+
'type' => Controls_Manager::SWITCHER,
|
175 |
+
'label_off' => esc_html__( 'Hide', 'mp-timetable' ),
|
176 |
+
'label_on' => esc_html__( 'Show', 'mp-timetable' ),
|
177 |
+
'default' => 'no',
|
178 |
+
]
|
179 |
+
);
|
180 |
+
|
181 |
+
$controls->add_control(
|
182 |
+
'description',
|
183 |
+
[
|
184 |
+
'label' => esc_html__( 'Description', 'mp-timetable' ),
|
185 |
+
'type' => Controls_Manager::SWITCHER,
|
186 |
+
'label_off' => esc_html__( 'Hide', 'mp-timetable' ),
|
187 |
+
'label_on' => esc_html__( 'Show', 'mp-timetable' ),
|
188 |
+
'default' => 'yes',
|
189 |
+
]
|
190 |
+
);
|
191 |
+
|
192 |
+
$controls->add_control(
|
193 |
+
'user',
|
194 |
+
[
|
195 |
+
'label' => esc_html__( 'Event Head', 'mp-timetable' ),
|
196 |
+
'type' => Controls_Manager::SWITCHER,
|
197 |
+
'label_off' => esc_html__( 'Hide', 'mp-timetable' ),
|
198 |
+
'label_on' => esc_html__( 'Show', 'mp-timetable' ),
|
199 |
+
'default' => 'no',
|
200 |
+
]
|
201 |
+
);
|
202 |
+
|
203 |
+
$controls->add_control(
|
204 |
+
'hide_hrs',
|
205 |
+
[
|
206 |
+
'label' => esc_html__( 'Hide column with hours', 'mp-timetable' ),
|
207 |
+
'type' => Controls_Manager::SWITCHER,
|
208 |
+
'default' => 'no',
|
209 |
+
]
|
210 |
+
);
|
211 |
+
|
212 |
+
$controls->add_control(
|
213 |
+
'hide_empty_rows',
|
214 |
+
[
|
215 |
+
'label' => esc_html__( 'Do not display empty rows', 'mp-timetable' ),
|
216 |
+
'type' => Controls_Manager::SWITCHER,
|
217 |
+
'default' => 'yes',
|
218 |
+
]
|
219 |
+
);
|
220 |
+
|
221 |
+
$controls->add_control(
|
222 |
+
'group',
|
223 |
+
[
|
224 |
+
'label' => esc_html__( 'Merge cells with common events', 'mp-timetable' ),
|
225 |
+
'type' => Controls_Manager::SWITCHER,
|
226 |
+
'default' => 'no',
|
227 |
+
]
|
228 |
+
);
|
229 |
+
|
230 |
+
$controls->add_control(
|
231 |
+
'disable_event_url',
|
232 |
+
[
|
233 |
+
'label' => esc_html__( 'Disable event link', 'mp-timetable' ),
|
234 |
+
'type' => Controls_Manager::SWITCHER,
|
235 |
+
'default' => 'no',
|
236 |
+
]
|
237 |
+
);
|
238 |
+
|
239 |
+
$controls->add_control(
|
240 |
+
'font_size',
|
241 |
+
[
|
242 |
+
'label' => esc_html__( 'Base font size', 'mp-timetable' ),
|
243 |
+
'label_block' => true,
|
244 |
+
'type' => Controls_Manager::TEXT,
|
245 |
+
'description' => __( 'Base font size for the table. Example 12px, 2em, 80%.', 'mp-timetable' ),
|
246 |
+
'separator' => 'before',
|
247 |
+
]
|
248 |
+
);
|
249 |
+
|
250 |
+
$controls->add_control(
|
251 |
+
'row_height',
|
252 |
+
[
|
253 |
+
'label' => esc_html__( 'Block height in pixels', 'mp-timetable' ),
|
254 |
+
'type' => Controls_Manager::NUMBER,
|
255 |
+
'default' => 45,
|
256 |
+
]
|
257 |
+
);
|
258 |
+
|
259 |
+
$controls->add_control(
|
260 |
+
'increment',
|
261 |
+
[
|
262 |
+
'label' => esc_html__( 'Time frame for event', 'mp-timetable' ),
|
263 |
+
'type' => Controls_Manager::SELECT,
|
264 |
+
'default' => '1',
|
265 |
+
'label_block' => false,
|
266 |
+
'options' => [
|
267 |
+
'1' => esc_html__( 'Hour (1h)', 'mp-timetable' ),
|
268 |
+
'0.5' => esc_html__( 'Half hour (30min)', 'mp-timetable' ),
|
269 |
+
'0.25' => esc_html__( 'Quarter hour (15min)', 'mp-timetable' ),
|
270 |
+
],
|
271 |
+
]
|
272 |
+
);
|
273 |
+
|
274 |
+
$controls->add_control(
|
275 |
+
'view',
|
276 |
+
[
|
277 |
+
'label' => esc_html__( 'Filter events style', 'mp-timetable' ),
|
278 |
+
'type' => Controls_Manager::SELECT,
|
279 |
+
'default' => 'dropdown_list',
|
280 |
+
'label_block' => false,
|
281 |
+
'options' => [
|
282 |
+
'dropdown_list' => esc_html__( 'Dropdown', 'mp-timetable' ),
|
283 |
+
'tabs' => esc_html__( 'Tabs', 'mp-timetable' ),
|
284 |
+
],
|
285 |
+
]
|
286 |
+
);
|
287 |
+
|
288 |
+
$controls->add_control(
|
289 |
+
'view_sort',
|
290 |
+
[
|
291 |
+
'label' => esc_html__( 'Order of items in filter', 'mp-timetable' ),
|
292 |
+
'type' => Controls_Manager::SELECT,
|
293 |
+
'default' => '',
|
294 |
+
'label_block' => false,
|
295 |
+
'options' => [
|
296 |
+
'' => esc_html__( 'Default', 'mp-timetable' ),
|
297 |
+
'menu_order' => esc_html__( 'Menu Order', 'mp-timetable' ),
|
298 |
+
'post_title' => esc_html__( 'Title', 'mp-timetable' ),
|
299 |
+
],
|
300 |
+
]
|
301 |
+
);
|
302 |
+
|
303 |
+
$controls->add_control(
|
304 |
+
'column_width',
|
305 |
+
[
|
306 |
+
'label' => esc_html__( 'Column width', 'mp-timetable' ),
|
307 |
+
'type' => Controls_Manager::SELECT,
|
308 |
+
'default' => '',
|
309 |
+
'label_block' => false,
|
310 |
+
'options' => [
|
311 |
+
'' => esc_html__( 'Default', 'mp-timetable' ),
|
312 |
+
'auto' => esc_html__( 'Auto', 'mp-timetable' ),
|
313 |
+
'fixed' => esc_html__( 'Fixed', 'mp-timetable' ),
|
314 |
+
],
|
315 |
+
]
|
316 |
+
);
|
317 |
+
|
318 |
+
$controls->add_control(
|
319 |
+
'responsive',
|
320 |
+
[
|
321 |
+
'label' => esc_html__( 'Mobile behavior', 'mp-timetable' ),
|
322 |
+
'type' => Controls_Manager::SELECT,
|
323 |
+
'default' => '0',
|
324 |
+
'label_block' => false,
|
325 |
+
'options' => [
|
326 |
+
'0' => esc_html__( 'Table', 'mp-timetable' ),
|
327 |
+
'1' => esc_html__( 'List', 'mp-timetable' ),
|
328 |
+
],
|
329 |
+
'separator' => 'before',
|
330 |
+
]
|
331 |
+
);
|
332 |
+
|
333 |
+
$controls->add_control(
|
334 |
+
'text_align_horizontal',
|
335 |
+
[
|
336 |
+
'label' => esc_html__( 'Horizontal align', 'mp-timetable' ),
|
337 |
+
'type' => Controls_Manager::CHOOSE,
|
338 |
+
'default' => 'center',
|
339 |
+
'toggle' => false,
|
340 |
+
'options' => [
|
341 |
+
'left' => [
|
342 |
+
'title' => esc_html__( 'left', 'mp-timetable' ),
|
343 |
+
'icon' => 'fa fa-align-left',
|
344 |
+
],
|
345 |
+
'center' => [
|
346 |
+
'title' => esc_html__( 'center', 'mp-timetable' ),
|
347 |
+
'icon' => 'fa fa-align-center',
|
348 |
+
],
|
349 |
+
'right' => [
|
350 |
+
'title' => esc_html__( 'right', 'mp-timetable' ),
|
351 |
+
'icon' => 'fa fa-align-right',
|
352 |
+
],
|
353 |
+
],
|
354 |
+
'separator' => 'before',
|
355 |
+
]
|
356 |
+
);
|
357 |
+
|
358 |
+
$controls->add_control(
|
359 |
+
'text_align_vertical',
|
360 |
+
[
|
361 |
+
'label' => esc_html__( 'Vertical align', 'mp-timetable' ),
|
362 |
+
'type' => Controls_Manager::CHOOSE,
|
363 |
+
'default' => 'default',
|
364 |
+
'toggle' => false,
|
365 |
+
'options' => [
|
366 |
+
'default' => [
|
367 |
+
'title' => esc_html__( 'default', 'mp-timetable' ),
|
368 |
+
'icon' => 'eicon-v-align-stretch',
|
369 |
+
],
|
370 |
+
'top' => [
|
371 |
+
'title' => esc_html__( 'top', 'mp-timetable' ),
|
372 |
+
'icon' => 'eicon-v-align-top',
|
373 |
+
],
|
374 |
+
'middle' => [
|
375 |
+
'title' => esc_html__( 'middle', 'mp-timetable' ),
|
376 |
+
'icon' => 'eicon-v-align-middle',
|
377 |
+
],
|
378 |
+
'bottom' => [
|
379 |
+
'title' => esc_html__( 'bottom', 'mp-timetable' ),
|
380 |
+
'icon' => 'eicon-v-align-bottom',
|
381 |
+
],
|
382 |
+
],
|
383 |
+
]
|
384 |
+
);
|
385 |
+
|
386 |
+
$controls->add_control(
|
387 |
+
'unique_id',
|
388 |
+
[
|
389 |
+
'label' => esc_html__( 'Unique ID', 'mp-timetable' ),
|
390 |
+
'label_block' => true,
|
391 |
+
'type' => Controls_Manager::TEXT,
|
392 |
+
'description' => __( 'If you use more than one table on a page specify the unique ID for a timetable. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'mp-timetable' ),
|
393 |
+
'dynamic' => [ 'active' => true ],
|
394 |
+
'separator' => 'before',
|
395 |
+
]
|
396 |
+
);
|
397 |
+
|
398 |
+
$controls->add_control(
|
399 |
+
'custom_class',
|
400 |
+
[
|
401 |
+
'label' => esc_html__( 'CSS class', 'mp-timetable' ),
|
402 |
+
'label_block' => true,
|
403 |
+
'type' => Controls_Manager::TEXT,
|
404 |
+
'dynamic' => [ 'active' => true ]
|
405 |
+
]
|
406 |
+
);
|
407 |
+
|
408 |
+
$controls->end_controls_section();
|
409 |
+
}
|
410 |
+
|
411 |
+
protected function render() {
|
412 |
+
$settings = $this->get_settings();
|
413 |
+
|
414 |
+
$label = $settings[ 'label' ];
|
415 |
+
$font_size = $settings[ 'font_size' ];
|
416 |
+
$col = $settings[ 'col' ];
|
417 |
+
$events = $settings[ 'events' ];
|
418 |
+
$event_categ = $settings[ 'event_categ' ];
|
419 |
+
$title = $settings[ 'title' ] === 'yes' ? '1' : '0';
|
420 |
+
$time = $settings[ 'time' ] === 'yes' ? '1' : '0';
|
421 |
+
$subtitle = $settings[ 'sub_title' ] === 'yes' ? '1' : '0';
|
422 |
+
$description = $settings[ 'description' ] === 'yes' ? '1' : '0';
|
423 |
+
$user = $settings[ 'user' ] === 'yes' ? '1' : '0';
|
424 |
+
$hide_label = $settings[ 'hide_label' ] === 'yes' ? '1' : '0';
|
425 |
+
$hide_hrs = $settings[ 'hide_hrs' ] === 'yes' ? '1' : '0';
|
426 |
+
$hide_empty_rows = $settings[ 'hide_empty_rows' ] === 'yes' ? '1' : '0';
|
427 |
+
$group = $settings[ 'group' ] === 'yes' ? '1' : '0';
|
428 |
+
$disable_event_url = $settings[ 'disable_event_url' ] === 'yes' ? '1' : '0';
|
429 |
+
$row_height = $settings[ 'row_height' ];
|
430 |
+
$view_sort = $settings[ 'view_sort' ];
|
431 |
+
$increment = $settings[ 'increment' ];
|
432 |
+
$view = $settings[ 'view' ];
|
433 |
+
$text_align_horizontal = $settings[ 'text_align_horizontal' ];
|
434 |
+
$text_align_vertical = $settings[ 'text_align_vertical' ];
|
435 |
+
$column_width = $settings[ 'column_width' ];
|
436 |
+
$responsive = $settings[ 'responsive' ];
|
437 |
+
$id = $settings[ 'unique_id' ];
|
438 |
+
$custom_class = $settings[ 'custom_class' ];
|
439 |
+
|
440 |
+
$attributes = array(
|
441 |
+
'col' => $col,
|
442 |
+
'events' => $events,
|
443 |
+
'event_categ' => $event_categ,
|
444 |
+
'label' => $label,
|
445 |
+
'font_size' => $font_size,
|
446 |
+
'time' => $time,
|
447 |
+
'custom_class' => $custom_class,
|
448 |
+
'id' => $id,
|
449 |
+
'table_layout' => $column_width,
|
450 |
+
'increment' => $increment,
|
451 |
+
'view' => $view,
|
452 |
+
'view_sort' => $view_sort,
|
453 |
+
'hide_label' => $hide_label,
|
454 |
+
'hide_hrs' => $hide_hrs,
|
455 |
+
'hide_empty_rows' => $hide_empty_rows,
|
456 |
+
'title' => $title,
|
457 |
+
'sub_title' => $subtitle,
|
458 |
+
'description' => $description,
|
459 |
+
'user' => $user,
|
460 |
+
'group' => $group,
|
461 |
+
'disable_event_url' => $disable_event_url,
|
462 |
+
'text_align' => $text_align_horizontal,
|
463 |
+
'row_height' => $row_height,
|
464 |
+
'responsive' => $responsive,
|
465 |
+
'text_align_vertical' => $text_align_vertical,
|
466 |
+
);
|
467 |
+
|
468 |
+
$this->elementor_render_timetable( $attributes );
|
469 |
+
}
|
470 |
+
|
471 |
+
}
|
472 |
+
|
473 |
+
Plugin::instance()->widgets_manager->register_widget_type( new Mp_Timetable_Widget() );
|
classes/widgets/class-mp-timetable-widget.php
CHANGED
@@ -1,142 +1,142 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
namespace timetable\classes\widgets;
|
4 |
-
|
5 |
-
use mp_timetable\classes\models\Column;
|
6 |
-
use mp_timetable\classes\models\Events;
|
7 |
-
use mp_timetable\classes\models\Settings;
|
8 |
-
use mp_timetable\plugin_core\classes\Core;
|
9 |
-
use mp_timetable\plugin_core\classes\View;
|
10 |
-
|
11 |
-
class Timetable_widget extends \WP_Widget {
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Widget constructor.
|
15 |
-
*/
|
16 |
-
public function __construct() {
|
17 |
-
|
18 |
-
$classname = Settings::get_instance()->is_plugin_template_mode() ? 'mptt-container' : 'widget_recent_entries';
|
19 |
-
|
20 |
-
$widget_ops = array(
|
21 |
-
'classname' => $classname,
|
22 |
-
'description' => __( 'Display upcoming events.', 'mp-timetable' )
|
23 |
-
);
|
24 |
-
parent::__construct( 'mp-timetable', __( 'Timetable Events', 'mp-timetable' ), $widget_ops );
|
25 |
-
add_action( 'save_post', array( &$this, 'flush_widget_cache' ) );
|
26 |
-
add_action( 'deleted_post', array( &$this, 'flush_widget_cache' ) );
|
27 |
-
add_action( 'switch_theme', array( &$this, 'flush_widget_cache' ) );
|
28 |
-
}
|
29 |
-
|
30 |
-
public function form( $instance ) {
|
31 |
-
$instance = shortcode_atts( array(
|
32 |
-
'title' => '',
|
33 |
-
'limit' => '3',
|
34 |
-
'view_settings' => '',
|
35 |
-
'mp_categories' => '',
|
36 |
-
'next_days' => '1',
|
37 |
-
'time_settings' => '',
|
38 |
-
'custom_url' => '',
|
39 |
-
'disable_url' => '',
|
40 |
-
'background_color' => '',
|
41 |
-
'hover_background_color' => '',
|
42 |
-
'text_color' => '',
|
43 |
-
'hover_text_color' => '',
|
44 |
-
'item_border_color' => '',
|
45 |
-
'hover_item_border_color' => '',
|
46 |
-
), $instance );
|
47 |
-
|
48 |
-
/*$data[ 'columns' ] = Column::get_instance()->get_all_column();
|
49 |
-
$data[ 'events' ] = Events::get_instance()->get_all_events();
|
50 |
-
$data[ 'categories' ] = get_terms( 'mp-event_category', 'orderby=count&hide_empty=0' );
|
51 |
-
$data[ 'localtime' ] = date( get_option( 'time_format' ), current_time( 'timestamp', 0 ) );
|
52 |
-
$data[ 'utc_time' ] = date( get_option( 'time_format' ), current_time( 'timestamp', 1 ) );
|
53 |
-
|
54 |
-
View::get_instance()->render_html( 'widgets/gallery-list', array( 'widget_object' => $this, 'data' => $data, 'instance' => $instance ), true );*/
|
55 |
-
|
56 |
-
$event_categories = get_terms( 'mp-event_category', 'orderby=title&hide_empty=0' );
|
57 |
-
|
58 |
-
View::get_instance()->render_html('widgets/gallery-list', array(
|
59 |
-
'widget_object' => $this,
|
60 |
-
'event_categories' => $event_categories,
|
61 |
-
'instance' => $instance
|
62 |
-
), true);
|
63 |
-
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Update widget
|
68 |
-
*
|
69 |
-
* @param array $new_instance
|
70 |
-
* @param array $old_instance
|
71 |
-
*
|
72 |
-
* @return array
|
73 |
-
*/
|
74 |
-
public function update( $new_instance, $old_instance ) {
|
75 |
-
|
76 |
-
$instance = $old_instance;
|
77 |
-
$instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] );
|
78 |
-
$instance[ 'limit' ] = strip_tags( $new_instance[ 'limit' ] );
|
79 |
-
$instance[ 'mp_categories' ] = empty( $new_instance[ 'mp_categories' ] ) ? "" : $new_instance[ 'mp_categories' ];
|
80 |
-
$instance[ 'view_settings' ] = strip_tags( $new_instance[ 'view_settings' ] );
|
81 |
-
$instance[ 'next_days' ] = strip_tags( $new_instance[ 'next_days' ] );
|
82 |
-
$instance[ 'time_settings' ] = empty( $new_instance[ 'time_settings' ] ) ? "" : strip_tags( $new_instance[ 'time_settings' ] );
|
83 |
-
$instance[ 'custom_url' ] = strip_tags( $new_instance[ 'custom_url' ] );
|
84 |
-
$instance[ 'disable_url' ] = strip_tags( $new_instance[ 'disable_url' ] );
|
85 |
-
$instance[ 'background_color' ] = strip_tags( $new_instance[ 'background_color' ] );
|
86 |
-
$instance[ 'hover_background_color' ] = strip_tags( $new_instance[ 'hover_background_color' ] );
|
87 |
-
$instance[ 'text_color' ] = strip_tags( $new_instance[ 'text_color' ] );
|
88 |
-
$instance[ 'hover_text_color' ] = strip_tags( $new_instance[ 'hover_text_color' ] );
|
89 |
-
$instance[ 'item_border_color' ] = strip_tags( $new_instance[ 'item_border_color' ] );
|
90 |
-
$instance[ 'hover_item_border_color' ] = strip_tags( $new_instance[ 'hover_item_border_color' ] );
|
91 |
-
|
92 |
-
return $instance;
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Flush widget cache.
|
97 |
-
*
|
98 |
-
* @since Twenty Eleven 1.0
|
99 |
-
*/
|
100 |
-
function flush_widget_cache() {
|
101 |
-
wp_cache_delete( 'mp-timetable', 'widget' );
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Display widget
|
106 |
-
*
|
107 |
-
* @param array $args
|
108 |
-
* @param array $instance
|
109 |
-
*/
|
110 |
-
public function widget( $args, $instance ) {
|
111 |
-
$cache = wp_cache_get( 'mp-timetable', 'widget' );
|
112 |
-
|
113 |
-
if ( ! is_array( $cache ) ) {
|
114 |
-
$cache = array();
|
115 |
-
}
|
116 |
-
|
117 |
-
if ( ! isset( $args[ 'widget_id' ] ) ) {
|
118 |
-
$args[ 'widget_id' ] = null;
|
119 |
-
}
|
120 |
-
|
121 |
-
if ( isset( $cache[ $args[ 'widget_id' ] ] ) ) {
|
122 |
-
echo $cache[ $args[ 'widget_id' ] ];
|
123 |
-
|
124 |
-
return;
|
125 |
-
}
|
126 |
-
|
127 |
-
ob_start();
|
128 |
-
$data[ 'args' ] = $args;
|
129 |
-
$data[ 'instance' ] = mptt_widget_settings( $instance );
|
130 |
-
$data[ 'events' ] = Events::get_instance()->get_widget_events( $data[ 'instance' ] );
|
131 |
-
if ( Settings::get_instance()->is_plugin_template_mode() ) {
|
132 |
-
Core::get_instance()->add_plugin_js( 'widget' );
|
133 |
-
View::get_instance()->get_template( "widgets/widget-view", $data );
|
134 |
-
} else {
|
135 |
-
View::get_instance()->get_template( "theme/widget-upcoming-view", $data );
|
136 |
-
}
|
137 |
-
|
138 |
-
$cache[ $args[ 'widget_id' ] ] = ob_get_flush();
|
139 |
-
wp_cache_set( 'mp-timetable', $cache, 'widget' );
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace timetable\classes\widgets;
|
4 |
+
|
5 |
+
use mp_timetable\classes\models\Column;
|
6 |
+
use mp_timetable\classes\models\Events;
|
7 |
+
use mp_timetable\classes\models\Settings;
|
8 |
+
use mp_timetable\plugin_core\classes\Core;
|
9 |
+
use mp_timetable\plugin_core\classes\View;
|
10 |
+
|
11 |
+
class Timetable_widget extends \WP_Widget {
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Widget constructor.
|
15 |
+
*/
|
16 |
+
public function __construct() {
|
17 |
+
|
18 |
+
$classname = Settings::get_instance()->is_plugin_template_mode() ? 'mptt-container' : 'widget_recent_entries';
|
19 |
+
|
20 |
+
$widget_ops = array(
|
21 |
+
'classname' => $classname,
|
22 |
+
'description' => __( 'Display upcoming events.', 'mp-timetable' )
|
23 |
+
);
|
24 |
+
parent::__construct( 'mp-timetable', __( 'Timetable Events', 'mp-timetable' ), $widget_ops );
|
25 |
+
add_action( 'save_post', array( &$this, 'flush_widget_cache' ) );
|
26 |
+
add_action( 'deleted_post', array( &$this, 'flush_widget_cache' ) );
|
27 |
+
add_action( 'switch_theme', array( &$this, 'flush_widget_cache' ) );
|
28 |
+
}
|
29 |
+
|
30 |
+
public function form( $instance ) {
|
31 |
+
$instance = shortcode_atts( array(
|
32 |
+
'title' => '',
|
33 |
+
'limit' => '3',
|
34 |
+
'view_settings' => '',
|
35 |
+
'mp_categories' => '',
|
36 |
+
'next_days' => '1',
|
37 |
+
'time_settings' => '',
|
38 |
+
'custom_url' => '',
|
39 |
+
'disable_url' => '',
|
40 |
+
'background_color' => '',
|
41 |
+
'hover_background_color' => '',
|
42 |
+
'text_color' => '',
|
43 |
+
'hover_text_color' => '',
|
44 |
+
'item_border_color' => '',
|
45 |
+
'hover_item_border_color' => '',
|
46 |
+
), $instance );
|
47 |
+
|
48 |
+
/*$data[ 'columns' ] = Column::get_instance()->get_all_column();
|
49 |
+
$data[ 'events' ] = Events::get_instance()->get_all_events();
|
50 |
+
$data[ 'categories' ] = get_terms( 'mp-event_category', 'orderby=count&hide_empty=0' );
|
51 |
+
$data[ 'localtime' ] = date( get_option( 'time_format' ), current_time( 'timestamp', 0 ) );
|
52 |
+
$data[ 'utc_time' ] = date( get_option( 'time_format' ), current_time( 'timestamp', 1 ) );
|
53 |
+
|
54 |
+
View::get_instance()->render_html( 'widgets/gallery-list', array( 'widget_object' => $this, 'data' => $data, 'instance' => $instance ), true );*/
|
55 |
+
|
56 |
+
$event_categories = get_terms( 'mp-event_category', 'orderby=title&hide_empty=0' );
|
57 |
+
|
58 |
+
View::get_instance()->render_html('widgets/gallery-list', array(
|
59 |
+
'widget_object' => $this,
|
60 |
+
'event_categories' => $event_categories,
|
61 |
+
'instance' => $instance
|
62 |
+
), true);
|
63 |
+
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Update widget
|
68 |
+
*
|
69 |
+
* @param array $new_instance
|
70 |
+
* @param array $old_instance
|
71 |
+
*
|
72 |
+
* @return array
|
73 |
+
*/
|
74 |
+
public function update( $new_instance, $old_instance ) {
|
75 |
+
|
76 |
+
$instance = $old_instance;
|
77 |
+
$instance[ 'title' ] = strip_tags( $new_instance[ 'title' ] );
|
78 |
+
$instance[ 'limit' ] = strip_tags( $new_instance[ 'limit' ] );
|
79 |
+
$instance[ 'mp_categories' ] = empty( $new_instance[ 'mp_categories' ] ) ? "" : $new_instance[ 'mp_categories' ];
|
80 |
+
$instance[ 'view_settings' ] = strip_tags( $new_instance[ 'view_settings' ] );
|
81 |
+
$instance[ 'next_days' ] = strip_tags( $new_instance[ 'next_days' ] );
|
82 |
+
$instance[ 'time_settings' ] = empty( $new_instance[ 'time_settings' ] ) ? "" : strip_tags( $new_instance[ 'time_settings' ] );
|
83 |
+
$instance[ 'custom_url' ] = strip_tags( $new_instance[ 'custom_url' ] );
|
84 |
+
$instance[ 'disable_url' ] = strip_tags( $new_instance[ 'disable_url' ] );
|
85 |
+
$instance[ 'background_color' ] = strip_tags( $new_instance[ 'background_color' ] );
|
86 |
+
$instance[ 'hover_background_color' ] = strip_tags( $new_instance[ 'hover_background_color' ] );
|
87 |
+
$instance[ 'text_color' ] = strip_tags( $new_instance[ 'text_color' ] );
|
88 |
+
$instance[ 'hover_text_color' ] = strip_tags( $new_instance[ 'hover_text_color' ] );
|
89 |
+
$instance[ 'item_border_color' ] = strip_tags( $new_instance[ 'item_border_color' ] );
|
90 |
+
$instance[ 'hover_item_border_color' ] = strip_tags( $new_instance[ 'hover_item_border_color' ] );
|
91 |
+
|
92 |
+
return $instance;
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Flush widget cache.
|
97 |
+
*
|
98 |
+
* @since Twenty Eleven 1.0
|
99 |
+
*/
|
100 |
+
function flush_widget_cache() {
|
101 |
+
wp_cache_delete( 'mp-timetable', 'widget' );
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* Display widget
|
106 |
+
*
|
107 |
+
* @param array $args
|
108 |
+
* @param array $instance
|
109 |
+
*/
|
110 |
+
public function widget( $args, $instance ) {
|
111 |
+
$cache = wp_cache_get( 'mp-timetable', 'widget' );
|
112 |
+
|
113 |
+
if ( ! is_array( $cache ) ) {
|
114 |
+
$cache = array();
|
115 |
+
}
|
116 |
+
|
117 |
+
if ( ! isset( $args[ 'widget_id' ] ) ) {
|
118 |
+
$args[ 'widget_id' ] = null;
|
119 |
+
}
|
120 |
+
|
121 |
+
if ( isset( $cache[ $args[ 'widget_id' ] ] ) ) {
|
122 |
+
echo $cache[ $args[ 'widget_id' ] ];
|
123 |
+
|
124 |
+
return;
|
125 |
+
}
|
126 |
+
|
127 |
+
ob_start();
|
128 |
+
$data[ 'args' ] = $args;
|
129 |
+
$data[ 'instance' ] = mptt_widget_settings( $instance );
|
130 |
+
$data[ 'events' ] = Events::get_instance()->get_widget_events( $data[ 'instance' ] );
|
131 |
+
if ( Settings::get_instance()->is_plugin_template_mode() ) {
|
132 |
+
Core::get_instance()->add_plugin_js( 'widget' );
|
133 |
+
View::get_instance()->get_template( "widgets/widget-view", $data );
|
134 |
+
} else {
|
135 |
+
View::get_instance()->get_template( "theme/widget-upcoming-view", $data );
|
136 |
+
}
|
137 |
+
|
138 |
+
$cache[ $args[ 'widget_id' ] ] = ob_get_flush();
|
139 |
+
wp_cache_set( 'mp-timetable', $cache, 'widget' );
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
languages/mp-timetable.pot
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
# This file is distributed under the same license as the Timetable and Event Schedule plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Timetable and Event Schedule 2.3.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mp-timetable\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"POT-Creation-Date: 2021-02-
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.4.0\n"
|
15 |
"X-Domain: mp-timetable\n"
|
@@ -58,245 +58,250 @@ msgid "Import"
|
|
58 |
msgstr ""
|
59 |
|
60 |
#: classes/blocks/class-timetable-block.php:92
|
61 |
-
#: classes/class-core.php:
|
62 |
#: classes/class-shortcode.php:70
|
63 |
#: classes/class-shortcode.php:286
|
64 |
-
#:
|
65 |
-
#: templates-functions/action-shortcode-functions.php:
|
66 |
-
#: templates-functions/action-shortcode-functions.php:
|
|
|
67 |
msgid "All Events"
|
68 |
msgstr ""
|
69 |
|
70 |
-
#: classes/class-core.php:
|
71 |
-
#: classes/class-core.php:
|
72 |
-
#: classes/class-core.php:
|
73 |
#: classes/class-shortcode.php:265
|
|
|
74 |
#: templates/popup/index.php:27
|
75 |
#: media/js/blocks/dist/index.js:1
|
76 |
msgid "Event categories"
|
77 |
msgstr ""
|
78 |
|
79 |
-
#: classes/class-core.php:
|
80 |
msgid "Event category"
|
81 |
msgstr ""
|
82 |
|
83 |
-
#: classes/class-core.php:
|
84 |
-
#: classes/class-core.php:
|
85 |
msgid "Add New Event category"
|
86 |
msgstr ""
|
87 |
|
88 |
-
#: classes/class-core.php:
|
89 |
msgid "Edit Event category"
|
90 |
msgstr ""
|
91 |
|
92 |
-
#: classes/class-core.php:
|
93 |
msgid "New Event category"
|
94 |
msgstr ""
|
95 |
|
96 |
-
#: classes/class-core.php:
|
97 |
msgid "All Event categories"
|
98 |
msgstr ""
|
99 |
|
100 |
-
#: classes/class-core.php:
|
101 |
msgid "View Event category"
|
102 |
msgstr ""
|
103 |
|
104 |
-
#: classes/class-core.php:
|
105 |
msgid "Search Event category"
|
106 |
msgstr ""
|
107 |
|
108 |
-
#: classes/class-core.php:
|
109 |
msgid "No Event categories found"
|
110 |
msgstr ""
|
111 |
|
112 |
-
#: classes/class-core.php:
|
113 |
msgid "No Event categories found in Trash"
|
114 |
msgstr ""
|
115 |
|
116 |
-
#: classes/class-core.php:
|
117 |
-
#: classes/class-core.php:
|
118 |
-
#: classes/class-core.php:
|
119 |
msgid "Event tags"
|
120 |
msgstr ""
|
121 |
|
122 |
-
#: classes/class-core.php:
|
123 |
msgid "Event tag"
|
124 |
msgstr ""
|
125 |
|
126 |
-
#: classes/class-core.php:
|
127 |
-
#: classes/class-core.php:
|
128 |
msgid "Add New Event tag"
|
129 |
msgstr ""
|
130 |
|
131 |
-
#: classes/class-core.php:
|
132 |
msgid "Edit Event tag"
|
133 |
msgstr ""
|
134 |
|
135 |
-
#: classes/class-core.php:
|
136 |
msgid "New Event tag"
|
137 |
msgstr ""
|
138 |
|
139 |
-
#: classes/class-core.php:
|
140 |
msgid "All Event tags"
|
141 |
msgstr ""
|
142 |
|
143 |
-
#: classes/class-core.php:
|
144 |
msgid "View Event tag"
|
145 |
msgstr ""
|
146 |
|
147 |
-
#: classes/class-core.php:
|
148 |
msgid "Search Event tag"
|
149 |
msgstr ""
|
150 |
|
151 |
-
#: classes/class-core.php:
|
152 |
msgid "No Event tags found"
|
153 |
msgstr ""
|
154 |
|
155 |
-
#: classes/class-core.php:
|
156 |
msgid "No Event tags found in Trash"
|
157 |
msgstr ""
|
158 |
|
159 |
-
#: classes/class-core.php:
|
160 |
-
#: classes/class-core.php:
|
161 |
-
#: classes/class-hooks.php:
|
162 |
#: classes/class-shortcode.php:260
|
163 |
msgid "Events"
|
164 |
msgstr ""
|
165 |
|
166 |
-
#: classes/class-core.php:
|
167 |
msgid "Event"
|
168 |
msgstr ""
|
169 |
|
170 |
-
#: classes/class-core.php:
|
171 |
-
#: classes/class-core.php:
|
172 |
msgid "Add New Event"
|
173 |
msgstr ""
|
174 |
|
175 |
-
#: classes/class-core.php:
|
176 |
msgid "Edit Event"
|
177 |
msgstr ""
|
178 |
|
179 |
-
#: classes/class-core.php:
|
180 |
msgid "New Event"
|
181 |
msgstr ""
|
182 |
|
183 |
-
#: classes/class-core.php:
|
184 |
msgid "View Event"
|
185 |
msgstr ""
|
186 |
|
187 |
-
#: classes/class-core.php:
|
188 |
msgid "Search Event"
|
189 |
msgstr ""
|
190 |
|
191 |
-
#: classes/class-core.php:
|
192 |
msgid "No Events found"
|
193 |
msgstr ""
|
194 |
|
195 |
-
#: classes/class-core.php:
|
196 |
msgid "No Events found in Trash"
|
197 |
msgstr ""
|
198 |
|
199 |
-
#: classes/class-core.php:
|
200 |
-
#: classes/class-core.php:
|
201 |
-
#: classes/class-hooks.php:
|
|
|
202 |
#: templates/popup/index.php:5
|
203 |
#: media/js/blocks/dist/index.js:1
|
204 |
msgid "Columns"
|
205 |
msgstr ""
|
206 |
|
207 |
-
#: classes/class-core.php:
|
208 |
#: classes/class-shortcode.php:255
|
209 |
#: templates/events/event-data.php:4
|
210 |
msgid "Column"
|
211 |
msgstr ""
|
212 |
|
213 |
-
#: classes/class-core.php:
|
214 |
-
#: classes/class-core.php:
|
215 |
msgid "Add New Column"
|
216 |
msgstr ""
|
217 |
|
218 |
-
#: classes/class-core.php:
|
219 |
msgid "Edit Column"
|
220 |
msgstr ""
|
221 |
|
222 |
-
#: classes/class-core.php:
|
223 |
msgid "New Column"
|
224 |
msgstr ""
|
225 |
|
226 |
-
#: classes/class-core.php:
|
227 |
msgid "All Columns"
|
228 |
msgstr ""
|
229 |
|
230 |
-
#: classes/class-core.php:
|
231 |
msgid "View Column"
|
232 |
msgstr ""
|
233 |
|
234 |
-
#: classes/class-core.php:
|
235 |
msgid "Search Column"
|
236 |
msgstr ""
|
237 |
|
238 |
-
#: classes/class-core.php:
|
239 |
msgid "No Columns found"
|
240 |
msgstr ""
|
241 |
|
242 |
-
#: classes/class-core.php:
|
243 |
msgid "No Columns found in Trash"
|
244 |
msgstr ""
|
245 |
|
246 |
-
#: classes/class-hooks.php:
|
247 |
msgid "Timetable Sidebar"
|
248 |
msgstr ""
|
249 |
|
250 |
-
#: classes/class-hooks.php:
|
251 |
-
#: classes/class-hooks.php:
|
252 |
-
#: classes/class-shortcode.php:
|
|
|
253 |
#: media/js/blocks/dist/index.js:1
|
254 |
msgid "Timetable"
|
255 |
msgstr ""
|
256 |
|
257 |
-
#: classes/class-hooks.php:
|
258 |
msgid "Import Timetable events, categories, tags and images."
|
259 |
msgstr ""
|
260 |
|
261 |
-
#: classes/class-hooks.php:
|
262 |
msgid "Add Event"
|
263 |
msgstr ""
|
264 |
|
265 |
-
#: classes/class-hooks.php:
|
266 |
msgid "Add Column"
|
267 |
msgstr ""
|
268 |
|
269 |
-
#: classes/class-hooks.php:
|
270 |
msgid "Event Categories"
|
271 |
msgstr ""
|
272 |
|
273 |
-
#: classes/class-hooks.php:
|
274 |
msgid "Event Tags"
|
275 |
msgstr ""
|
276 |
|
277 |
-
#: classes/class-hooks.php:
|
278 |
#: classes/modules/class-post.php:41
|
|
|
279 |
#: media/js/blocks/dist/index.js:1
|
280 |
msgid "Settings"
|
281 |
msgstr ""
|
282 |
|
283 |
-
#: classes/class-hooks.php:
|
284 |
msgid "Export / Import"
|
285 |
msgstr ""
|
286 |
|
287 |
-
#: classes/class-hooks.php:
|
288 |
msgid "Help & Shortcode"
|
289 |
msgstr ""
|
290 |
|
291 |
-
#: classes/class-hooks.php:
|
292 |
msgid "Quick Start Guide"
|
293 |
msgstr ""
|
294 |
|
295 |
-
#: classes/class-hooks.php:
|
296 |
msgid "Help"
|
297 |
msgstr ""
|
298 |
|
299 |
-
#: classes/class-hooks.php:
|
300 |
msgid "Leave a Review"
|
301 |
msgstr ""
|
302 |
|
@@ -325,18 +330,21 @@ msgid "Hour measure"
|
|
325 |
msgstr ""
|
326 |
|
327 |
#: classes/class-shortcode.php:271
|
|
|
328 |
#: templates/popup/index.php:71
|
329 |
#: media/js/blocks/dist/index.js:1
|
330 |
msgid "Hour (1h)"
|
331 |
msgstr ""
|
332 |
|
333 |
#: classes/class-shortcode.php:271
|
|
|
334 |
#: templates/popup/index.php:72
|
335 |
#: media/js/blocks/dist/index.js:1
|
336 |
msgid "Half hour (30min)"
|
337 |
msgstr ""
|
338 |
|
339 |
#: classes/class-shortcode.php:271
|
|
|
340 |
#: templates/popup/index.php:73
|
341 |
#: media/js/blocks/dist/index.js:1
|
342 |
msgid "Quarter hour (15min)"
|
@@ -352,12 +360,14 @@ msgid "Dropdown list"
|
|
352 |
msgstr ""
|
353 |
|
354 |
#: classes/class-shortcode.php:276
|
|
|
355 |
#: templates/popup/index.php:82
|
356 |
#: media/js/blocks/dist/index.js:1
|
357 |
msgid "Tabs"
|
358 |
msgstr ""
|
359 |
|
360 |
#: classes/class-shortcode.php:280
|
|
|
361 |
#: templates/popup/index.php:88
|
362 |
#: media/js/blocks/dist/index.js:1
|
363 |
msgid "Order of items in filter"
|
@@ -365,6 +375,8 @@ msgstr ""
|
|
365 |
|
366 |
#: classes/class-shortcode.php:281
|
367 |
#: classes/class-shortcode.php:367
|
|
|
|
|
368 |
#: templates/popup/index.php:91
|
369 |
#: templates/popup/index.php:172
|
370 |
#: media/js/blocks/dist/index.js:1
|
@@ -372,6 +384,7 @@ msgid "Default"
|
|
372 |
msgstr ""
|
373 |
|
374 |
#: classes/class-shortcode.php:281
|
|
|
375 |
#: templates/popup/index.php:92
|
376 |
#: media/js/blocks/dist/index.js:1
|
377 |
msgid "Menu Order"
|
@@ -379,6 +392,8 @@ msgstr ""
|
|
379 |
|
380 |
#: classes/class-shortcode.php:281
|
381 |
#: classes/class-shortcode.php:306
|
|
|
|
|
382 |
#: templates/popup/index.php:40
|
383 |
#: templates/popup/index.php:93
|
384 |
#: templates/widgets/gallery-list.php:3
|
@@ -445,18 +460,21 @@ msgid "Hide empty rows"
|
|
445 |
msgstr ""
|
446 |
|
447 |
#: classes/class-shortcode.php:312
|
|
|
448 |
#: templates/popup/index.php:41
|
449 |
#: media/js/blocks/dist/index.js:1
|
450 |
msgid "Time"
|
451 |
msgstr ""
|
452 |
|
453 |
#: classes/class-shortcode.php:318
|
|
|
454 |
#: templates/popup/index.php:42
|
455 |
#: media/js/blocks/dist/index.js:1
|
456 |
msgid "Subtitle"
|
457 |
msgstr ""
|
458 |
|
459 |
#: classes/class-shortcode.php:324
|
|
|
460 |
#: templates/events/event-data.php:7
|
461 |
#: templates/popup/index.php:43
|
462 |
#: media/js/blocks/dist/index.js:1
|
@@ -476,18 +494,21 @@ msgid "Text align"
|
|
476 |
msgstr ""
|
477 |
|
478 |
#: classes/class-shortcode.php:342
|
|
|
479 |
#: templates/popup/index.php:152
|
480 |
#: media/js/blocks/dist/index.js:1
|
481 |
msgid "center"
|
482 |
msgstr ""
|
483 |
|
484 |
#: classes/class-shortcode.php:342
|
|
|
485 |
#: templates/popup/index.php:153
|
486 |
#: media/js/blocks/dist/index.js:1
|
487 |
msgid "left"
|
488 |
msgstr ""
|
489 |
|
490 |
#: classes/class-shortcode.php:342
|
|
|
491 |
#: templates/popup/index.php:154
|
492 |
#: media/js/blocks/dist/index.js:1
|
493 |
msgid "right"
|
@@ -510,18 +531,21 @@ msgid "Responsive"
|
|
510 |
msgstr ""
|
511 |
|
512 |
#: classes/class-shortcode.php:366
|
|
|
513 |
#: templates/popup/index.php:169
|
514 |
#: media/js/blocks/dist/index.js:1
|
515 |
msgid "Column width"
|
516 |
msgstr ""
|
517 |
|
518 |
#: classes/class-shortcode.php:367
|
|
|
519 |
#: templates/popup/index.php:173
|
520 |
#: media/js/blocks/dist/index.js:1
|
521 |
msgid "Auto"
|
522 |
msgstr ""
|
523 |
|
524 |
#: classes/class-shortcode.php:367
|
|
|
525 |
#: templates/popup/index.php:174
|
526 |
#: media/js/blocks/dist/index.js:1
|
527 |
msgid "Fixed"
|
@@ -710,6 +734,178 @@ msgstr ""
|
|
710 |
msgid "Column Type"
|
711 |
msgstr ""
|
712 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
713 |
#: classes/widgets/class-mp-timetable-widget.php:22
|
714 |
msgid "Display upcoming events."
|
715 |
msgstr ""
|
@@ -871,152 +1067,22 @@ msgstr ""
|
|
871 |
msgid "Hold the Ctrl or Command key to select/deselect multiple options."
|
872 |
msgstr ""
|
873 |
|
874 |
-
#: templates/popup/index.php:16
|
875 |
-
#: media/js/blocks/dist/index.js:1
|
876 |
-
msgid "Specific events"
|
877 |
-
msgstr ""
|
878 |
-
|
879 |
#: templates/popup/index.php:38
|
880 |
msgid "Fields to display:"
|
881 |
msgstr ""
|
882 |
|
883 |
-
#. translators: Head means the leader of the event.
|
884 |
-
#: templates/popup/index.php:47
|
885 |
-
#: media/js/blocks/dist/index.js:1
|
886 |
-
msgid "Event Head"
|
887 |
-
msgstr ""
|
888 |
-
|
889 |
#: templates/popup/index.php:50
|
890 |
msgid "Check the event parameter(s) to be displayed in the timetable."
|
891 |
msgstr ""
|
892 |
|
893 |
-
#: templates/popup/index.php:54
|
894 |
-
#: media/js/blocks/dist/index.js:1
|
895 |
-
msgid "Block height in pixels"
|
896 |
-
msgstr ""
|
897 |
-
|
898 |
#: templates/popup/index.php:57
|
899 |
msgid "Set height of the block"
|
900 |
msgstr ""
|
901 |
|
902 |
-
#: templates/popup/index.php:61
|
903 |
-
#: media/js/blocks/dist/index.js:1
|
904 |
-
msgid "Base font size"
|
905 |
-
msgstr ""
|
906 |
-
|
907 |
-
#: templates/popup/index.php:64
|
908 |
-
#: media/js/blocks/dist/index.js:1
|
909 |
-
msgid "Base font size for the table. Example 12px, 2em, 80%."
|
910 |
-
msgstr ""
|
911 |
-
|
912 |
-
#: templates/popup/index.php:68
|
913 |
-
#: media/js/blocks/dist/index.js:1
|
914 |
-
msgid "Time frame for event"
|
915 |
-
msgstr ""
|
916 |
-
|
917 |
-
#: templates/popup/index.php:78
|
918 |
-
#: media/js/blocks/dist/index.js:1
|
919 |
-
msgid "Filter events style"
|
920 |
-
msgstr ""
|
921 |
-
|
922 |
-
#: templates/popup/index.php:81
|
923 |
-
msgid "Dropdown"
|
924 |
-
msgstr ""
|
925 |
-
|
926 |
#: templates/popup/index.php:83
|
927 |
msgid "None"
|
928 |
msgstr ""
|
929 |
|
930 |
-
#: templates/popup/index.php:98
|
931 |
-
#: media/js/blocks/dist/index.js:1
|
932 |
-
msgid "Filter title to display all events"
|
933 |
-
msgstr ""
|
934 |
-
|
935 |
-
#: templates/popup/index.php:104
|
936 |
-
#: media/js/blocks/dist/index.js:1
|
937 |
-
msgid "Hide 'All Events' option"
|
938 |
-
msgstr ""
|
939 |
-
|
940 |
-
#: templates/popup/index.php:114
|
941 |
-
#: media/js/blocks/dist/index.js:1
|
942 |
-
msgid "Hide column with hours"
|
943 |
-
msgstr ""
|
944 |
-
|
945 |
-
#: templates/popup/index.php:123
|
946 |
-
#: media/js/blocks/dist/index.js:1
|
947 |
-
msgid "Do not display empty rows"
|
948 |
-
msgstr ""
|
949 |
-
|
950 |
-
#: templates/popup/index.php:132
|
951 |
-
#: media/js/blocks/dist/index.js:1
|
952 |
-
msgid "Merge cells with common events"
|
953 |
-
msgstr ""
|
954 |
-
|
955 |
-
#: templates/popup/index.php:141
|
956 |
-
#: templates/widgets/gallery-list.php:59
|
957 |
-
#: media/js/blocks/dist/index.js:1
|
958 |
-
msgid "Disable event link"
|
959 |
-
msgstr ""
|
960 |
-
|
961 |
-
#: templates/popup/index.php:150
|
962 |
-
#: media/js/blocks/dist/index.js:1
|
963 |
-
msgid "Horizontal align"
|
964 |
-
msgstr ""
|
965 |
-
|
966 |
-
#: templates/popup/index.php:159
|
967 |
-
#: media/js/blocks/dist/index.js:1
|
968 |
-
msgid "Vertical align"
|
969 |
-
msgstr ""
|
970 |
-
|
971 |
-
#: templates/popup/index.php:161
|
972 |
-
msgid "default"
|
973 |
-
msgstr ""
|
974 |
-
|
975 |
-
#: templates/popup/index.php:162
|
976 |
-
#: media/js/blocks/dist/index.js:1
|
977 |
-
msgid "top"
|
978 |
-
msgstr ""
|
979 |
-
|
980 |
-
#: templates/popup/index.php:163
|
981 |
-
#: media/js/blocks/dist/index.js:1
|
982 |
-
msgid "middle"
|
983 |
-
msgstr ""
|
984 |
-
|
985 |
-
#: templates/popup/index.php:164
|
986 |
-
#: media/js/blocks/dist/index.js:1
|
987 |
-
msgid "bottom"
|
988 |
-
msgstr ""
|
989 |
-
|
990 |
-
#: templates/popup/index.php:179
|
991 |
-
#: media/js/blocks/dist/index.js:1
|
992 |
-
msgid "Unique ID"
|
993 |
-
msgstr ""
|
994 |
-
|
995 |
-
#: templates/popup/index.php:182
|
996 |
-
#: media/js/blocks/dist/index.js:1
|
997 |
-
msgid "If you use more than one table on a page specify the unique ID for a timetable. It is usually all lowercase and contains only letters, numbers, and hyphens."
|
998 |
-
msgstr ""
|
999 |
-
|
1000 |
-
#: templates/popup/index.php:186
|
1001 |
-
#: media/js/blocks/dist/index.js:1
|
1002 |
-
msgid "CSS class"
|
1003 |
-
msgstr ""
|
1004 |
-
|
1005 |
-
#: templates/popup/index.php:192
|
1006 |
-
#: media/js/blocks/dist/index.js:1
|
1007 |
-
msgid "Mobile behavior"
|
1008 |
-
msgstr ""
|
1009 |
-
|
1010 |
-
#: templates/popup/index.php:195
|
1011 |
-
#: media/js/blocks/dist/index.js:1
|
1012 |
-
msgid "List"
|
1013 |
-
msgstr ""
|
1014 |
-
|
1015 |
-
#: templates/popup/index.php:196
|
1016 |
-
#: media/js/blocks/dist/index.js:1
|
1017 |
-
msgid "Table"
|
1018 |
-
msgstr ""
|
1019 |
-
|
1020 |
#: templates/popup/index.php:198
|
1021 |
msgid "Tick \"List\" to display events in a list view on mobile devices. Tick \"Table\" to display events in a table."
|
1022 |
msgstr ""
|
2 |
# This file is distributed under the same license as the Timetable and Event Schedule plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Timetable and Event Schedule 2.3.15\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mp-timetable\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"POT-Creation-Date: 2021-02-17T15:43:58+00:00\n"
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.4.0\n"
|
15 |
"X-Domain: mp-timetable\n"
|
58 |
msgstr ""
|
59 |
|
60 |
#: classes/blocks/class-timetable-block.php:92
|
61 |
+
#: classes/class-core.php:448
|
62 |
#: classes/class-shortcode.php:70
|
63 |
#: classes/class-shortcode.php:286
|
64 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:100
|
65 |
+
#: templates-functions/action-shortcode-functions.php:60
|
66 |
+
#: templates-functions/action-shortcode-functions.php:74
|
67 |
+
#: templates-functions/action-shortcode-functions.php:75
|
68 |
msgid "All Events"
|
69 |
msgstr ""
|
70 |
|
71 |
+
#: classes/class-core.php:337
|
72 |
+
#: classes/class-core.php:348
|
73 |
+
#: classes/class-core.php:352
|
74 |
#: classes/class-shortcode.php:265
|
75 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:139
|
76 |
#: templates/popup/index.php:27
|
77 |
#: media/js/blocks/dist/index.js:1
|
78 |
msgid "Event categories"
|
79 |
msgstr ""
|
80 |
|
81 |
+
#: classes/class-core.php:338
|
82 |
msgid "Event category"
|
83 |
msgstr ""
|
84 |
|
85 |
+
#: classes/class-core.php:339
|
86 |
+
#: classes/class-core.php:340
|
87 |
msgid "Add New Event category"
|
88 |
msgstr ""
|
89 |
|
90 |
+
#: classes/class-core.php:341
|
91 |
msgid "Edit Event category"
|
92 |
msgstr ""
|
93 |
|
94 |
+
#: classes/class-core.php:342
|
95 |
msgid "New Event category"
|
96 |
msgstr ""
|
97 |
|
98 |
+
#: classes/class-core.php:343
|
99 |
msgid "All Event categories"
|
100 |
msgstr ""
|
101 |
|
102 |
+
#: classes/class-core.php:344
|
103 |
msgid "View Event category"
|
104 |
msgstr ""
|
105 |
|
106 |
+
#: classes/class-core.php:345
|
107 |
msgid "Search Event category"
|
108 |
msgstr ""
|
109 |
|
110 |
+
#: classes/class-core.php:346
|
111 |
msgid "No Event categories found"
|
112 |
msgstr ""
|
113 |
|
114 |
+
#: classes/class-core.php:347
|
115 |
msgid "No Event categories found in Trash"
|
116 |
msgstr ""
|
117 |
|
118 |
+
#: classes/class-core.php:381
|
119 |
+
#: classes/class-core.php:392
|
120 |
+
#: classes/class-core.php:396
|
121 |
msgid "Event tags"
|
122 |
msgstr ""
|
123 |
|
124 |
+
#: classes/class-core.php:382
|
125 |
msgid "Event tag"
|
126 |
msgstr ""
|
127 |
|
128 |
+
#: classes/class-core.php:383
|
129 |
+
#: classes/class-core.php:384
|
130 |
msgid "Add New Event tag"
|
131 |
msgstr ""
|
132 |
|
133 |
+
#: classes/class-core.php:385
|
134 |
msgid "Edit Event tag"
|
135 |
msgstr ""
|
136 |
|
137 |
+
#: classes/class-core.php:386
|
138 |
msgid "New Event tag"
|
139 |
msgstr ""
|
140 |
|
141 |
+
#: classes/class-core.php:387
|
142 |
msgid "All Event tags"
|
143 |
msgstr ""
|
144 |
|
145 |
+
#: classes/class-core.php:388
|
146 |
msgid "View Event tag"
|
147 |
msgstr ""
|
148 |
|
149 |
+
#: classes/class-core.php:389
|
150 |
msgid "Search Event tag"
|
151 |
msgstr ""
|
152 |
|
153 |
+
#: classes/class-core.php:390
|
154 |
msgid "No Event tags found"
|
155 |
msgstr ""
|
156 |
|
157 |
+
#: classes/class-core.php:391
|
158 |
msgid "No Event tags found in Trash"
|
159 |
msgstr ""
|
160 |
|
161 |
+
#: classes/class-core.php:442
|
162 |
+
#: classes/class-core.php:453
|
163 |
+
#: classes/class-hooks.php:203
|
164 |
#: classes/class-shortcode.php:260
|
165 |
msgid "Events"
|
166 |
msgstr ""
|
167 |
|
168 |
+
#: classes/class-core.php:443
|
169 |
msgid "Event"
|
170 |
msgstr ""
|
171 |
|
172 |
+
#: classes/class-core.php:444
|
173 |
+
#: classes/class-core.php:445
|
174 |
msgid "Add New Event"
|
175 |
msgstr ""
|
176 |
|
177 |
+
#: classes/class-core.php:446
|
178 |
msgid "Edit Event"
|
179 |
msgstr ""
|
180 |
|
181 |
+
#: classes/class-core.php:447
|
182 |
msgid "New Event"
|
183 |
msgstr ""
|
184 |
|
185 |
+
#: classes/class-core.php:449
|
186 |
msgid "View Event"
|
187 |
msgstr ""
|
188 |
|
189 |
+
#: classes/class-core.php:450
|
190 |
msgid "Search Event"
|
191 |
msgstr ""
|
192 |
|
193 |
+
#: classes/class-core.php:451
|
194 |
msgid "No Events found"
|
195 |
msgstr ""
|
196 |
|
197 |
+
#: classes/class-core.php:452
|
198 |
msgid "No Events found in Trash"
|
199 |
msgstr ""
|
200 |
|
201 |
+
#: classes/class-core.php:481
|
202 |
+
#: classes/class-core.php:492
|
203 |
+
#: classes/class-hooks.php:211
|
204 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:116
|
205 |
#: templates/popup/index.php:5
|
206 |
#: media/js/blocks/dist/index.js:1
|
207 |
msgid "Columns"
|
208 |
msgstr ""
|
209 |
|
210 |
+
#: classes/class-core.php:482
|
211 |
#: classes/class-shortcode.php:255
|
212 |
#: templates/events/event-data.php:4
|
213 |
msgid "Column"
|
214 |
msgstr ""
|
215 |
|
216 |
+
#: classes/class-core.php:483
|
217 |
+
#: classes/class-core.php:484
|
218 |
msgid "Add New Column"
|
219 |
msgstr ""
|
220 |
|
221 |
+
#: classes/class-core.php:485
|
222 |
msgid "Edit Column"
|
223 |
msgstr ""
|
224 |
|
225 |
+
#: classes/class-core.php:486
|
226 |
msgid "New Column"
|
227 |
msgstr ""
|
228 |
|
229 |
+
#: classes/class-core.php:487
|
230 |
msgid "All Columns"
|
231 |
msgstr ""
|
232 |
|
233 |
+
#: classes/class-core.php:488
|
234 |
msgid "View Column"
|
235 |
msgstr ""
|
236 |
|
237 |
+
#: classes/class-core.php:489
|
238 |
msgid "Search Column"
|
239 |
msgstr ""
|
240 |
|
241 |
+
#: classes/class-core.php:490
|
242 |
msgid "No Columns found"
|
243 |
msgstr ""
|
244 |
|
245 |
+
#: classes/class-core.php:491
|
246 |
msgid "No Columns found in Trash"
|
247 |
msgstr ""
|
248 |
|
249 |
+
#: classes/class-hooks.php:81
|
250 |
msgid "Timetable Sidebar"
|
251 |
msgstr ""
|
252 |
|
253 |
+
#: classes/class-hooks.php:83
|
254 |
+
#: classes/class-hooks.php:199
|
255 |
+
#: classes/class-shortcode.php:371
|
256 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:21
|
257 |
#: media/js/blocks/dist/index.js:1
|
258 |
msgid "Timetable"
|
259 |
msgstr ""
|
260 |
|
261 |
+
#: classes/class-hooks.php:190
|
262 |
msgid "Import Timetable events, categories, tags and images."
|
263 |
msgstr ""
|
264 |
|
265 |
+
#: classes/class-hooks.php:207
|
266 |
msgid "Add Event"
|
267 |
msgstr ""
|
268 |
|
269 |
+
#: classes/class-hooks.php:215
|
270 |
msgid "Add Column"
|
271 |
msgstr ""
|
272 |
|
273 |
+
#: classes/class-hooks.php:219
|
274 |
msgid "Event Categories"
|
275 |
msgstr ""
|
276 |
|
277 |
+
#: classes/class-hooks.php:223
|
278 |
msgid "Event Tags"
|
279 |
msgstr ""
|
280 |
|
281 |
+
#: classes/class-hooks.php:227
|
282 |
#: classes/modules/class-post.php:41
|
283 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:89
|
284 |
#: media/js/blocks/dist/index.js:1
|
285 |
msgid "Settings"
|
286 |
msgstr ""
|
287 |
|
288 |
+
#: classes/class-hooks.php:231
|
289 |
msgid "Export / Import"
|
290 |
msgstr ""
|
291 |
|
292 |
+
#: classes/class-hooks.php:235
|
293 |
msgid "Help & Shortcode"
|
294 |
msgstr ""
|
295 |
|
296 |
+
#: classes/class-hooks.php:299
|
297 |
msgid "Quick Start Guide"
|
298 |
msgstr ""
|
299 |
|
300 |
+
#: classes/class-hooks.php:300
|
301 |
msgid "Help"
|
302 |
msgstr ""
|
303 |
|
304 |
+
#: classes/class-hooks.php:301
|
305 |
msgid "Leave a Review"
|
306 |
msgstr ""
|
307 |
|
330 |
msgstr ""
|
331 |
|
332 |
#: classes/class-shortcode.php:271
|
333 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:267
|
334 |
#: templates/popup/index.php:71
|
335 |
#: media/js/blocks/dist/index.js:1
|
336 |
msgid "Hour (1h)"
|
337 |
msgstr ""
|
338 |
|
339 |
#: classes/class-shortcode.php:271
|
340 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:268
|
341 |
#: templates/popup/index.php:72
|
342 |
#: media/js/blocks/dist/index.js:1
|
343 |
msgid "Half hour (30min)"
|
344 |
msgstr ""
|
345 |
|
346 |
#: classes/class-shortcode.php:271
|
347 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:269
|
348 |
#: templates/popup/index.php:73
|
349 |
#: media/js/blocks/dist/index.js:1
|
350 |
msgid "Quarter hour (15min)"
|
360 |
msgstr ""
|
361 |
|
362 |
#: classes/class-shortcode.php:276
|
363 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:283
|
364 |
#: templates/popup/index.php:82
|
365 |
#: media/js/blocks/dist/index.js:1
|
366 |
msgid "Tabs"
|
367 |
msgstr ""
|
368 |
|
369 |
#: classes/class-shortcode.php:280
|
370 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:291
|
371 |
#: templates/popup/index.php:88
|
372 |
#: media/js/blocks/dist/index.js:1
|
373 |
msgid "Order of items in filter"
|
375 |
|
376 |
#: classes/class-shortcode.php:281
|
377 |
#: classes/class-shortcode.php:367
|
378 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:296
|
379 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:311
|
380 |
#: templates/popup/index.php:91
|
381 |
#: templates/popup/index.php:172
|
382 |
#: media/js/blocks/dist/index.js:1
|
384 |
msgstr ""
|
385 |
|
386 |
#: classes/class-shortcode.php:281
|
387 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:297
|
388 |
#: templates/popup/index.php:92
|
389 |
#: media/js/blocks/dist/index.js:1
|
390 |
msgid "Menu Order"
|
392 |
|
393 |
#: classes/class-shortcode.php:281
|
394 |
#: classes/class-shortcode.php:306
|
395 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:151
|
396 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:298
|
397 |
#: templates/popup/index.php:40
|
398 |
#: templates/popup/index.php:93
|
399 |
#: templates/widgets/gallery-list.php:3
|
460 |
msgstr ""
|
461 |
|
462 |
#: classes/class-shortcode.php:312
|
463 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:162
|
464 |
#: templates/popup/index.php:41
|
465 |
#: media/js/blocks/dist/index.js:1
|
466 |
msgid "Time"
|
467 |
msgstr ""
|
468 |
|
469 |
#: classes/class-shortcode.php:318
|
470 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:173
|
471 |
#: templates/popup/index.php:42
|
472 |
#: media/js/blocks/dist/index.js:1
|
473 |
msgid "Subtitle"
|
474 |
msgstr ""
|
475 |
|
476 |
#: classes/class-shortcode.php:324
|
477 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:184
|
478 |
#: templates/events/event-data.php:7
|
479 |
#: templates/popup/index.php:43
|
480 |
#: media/js/blocks/dist/index.js:1
|
494 |
msgstr ""
|
495 |
|
496 |
#: classes/class-shortcode.php:342
|
497 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:346
|
498 |
#: templates/popup/index.php:152
|
499 |
#: media/js/blocks/dist/index.js:1
|
500 |
msgid "center"
|
501 |
msgstr ""
|
502 |
|
503 |
#: classes/class-shortcode.php:342
|
504 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:342
|
505 |
#: templates/popup/index.php:153
|
506 |
#: media/js/blocks/dist/index.js:1
|
507 |
msgid "left"
|
508 |
msgstr ""
|
509 |
|
510 |
#: classes/class-shortcode.php:342
|
511 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:350
|
512 |
#: templates/popup/index.php:154
|
513 |
#: media/js/blocks/dist/index.js:1
|
514 |
msgid "right"
|
531 |
msgstr ""
|
532 |
|
533 |
#: classes/class-shortcode.php:366
|
534 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:306
|
535 |
#: templates/popup/index.php:169
|
536 |
#: media/js/blocks/dist/index.js:1
|
537 |
msgid "Column width"
|
538 |
msgstr ""
|
539 |
|
540 |
#: classes/class-shortcode.php:367
|
541 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:312
|
542 |
#: templates/popup/index.php:173
|
543 |
#: media/js/blocks/dist/index.js:1
|
544 |
msgid "Auto"
|
545 |
msgstr ""
|
546 |
|
547 |
#: classes/class-shortcode.php:367
|
548 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:313
|
549 |
#: templates/popup/index.php:174
|
550 |
#: media/js/blocks/dist/index.js:1
|
551 |
msgid "Fixed"
|
734 |
msgid "Column Type"
|
735 |
msgstr ""
|
736 |
|
737 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:97
|
738 |
+
#: templates/popup/index.php:98
|
739 |
+
#: media/js/blocks/dist/index.js:1
|
740 |
+
msgid "Filter title to display all events"
|
741 |
+
msgstr ""
|
742 |
+
|
743 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:107
|
744 |
+
#: templates/popup/index.php:104
|
745 |
+
#: media/js/blocks/dist/index.js:1
|
746 |
+
msgid "Hide 'All Events' option"
|
747 |
+
msgstr ""
|
748 |
+
|
749 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:128
|
750 |
+
#: templates/popup/index.php:16
|
751 |
+
#: media/js/blocks/dist/index.js:1
|
752 |
+
msgid "Specific events"
|
753 |
+
msgstr ""
|
754 |
+
|
755 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:153
|
756 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:164
|
757 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:175
|
758 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:186
|
759 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:197
|
760 |
+
msgid "Hide"
|
761 |
+
msgstr ""
|
762 |
+
|
763 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:154
|
764 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:165
|
765 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:176
|
766 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:187
|
767 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:198
|
768 |
+
msgid "Show"
|
769 |
+
msgstr ""
|
770 |
+
|
771 |
+
#. translators: Head means the leader of the event.
|
772 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:195
|
773 |
+
#: templates/popup/index.php:47
|
774 |
+
#: media/js/blocks/dist/index.js:1
|
775 |
+
msgid "Event Head"
|
776 |
+
msgstr ""
|
777 |
+
|
778 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:206
|
779 |
+
#: templates/popup/index.php:114
|
780 |
+
#: media/js/blocks/dist/index.js:1
|
781 |
+
msgid "Hide column with hours"
|
782 |
+
msgstr ""
|
783 |
+
|
784 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:215
|
785 |
+
#: templates/popup/index.php:123
|
786 |
+
#: media/js/blocks/dist/index.js:1
|
787 |
+
msgid "Do not display empty rows"
|
788 |
+
msgstr ""
|
789 |
+
|
790 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:224
|
791 |
+
#: templates/popup/index.php:132
|
792 |
+
#: media/js/blocks/dist/index.js:1
|
793 |
+
msgid "Merge cells with common events"
|
794 |
+
msgstr ""
|
795 |
+
|
796 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:233
|
797 |
+
#: templates/popup/index.php:141
|
798 |
+
#: templates/widgets/gallery-list.php:59
|
799 |
+
#: media/js/blocks/dist/index.js:1
|
800 |
+
msgid "Disable event link"
|
801 |
+
msgstr ""
|
802 |
+
|
803 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:242
|
804 |
+
#: templates/popup/index.php:61
|
805 |
+
#: media/js/blocks/dist/index.js:1
|
806 |
+
msgid "Base font size"
|
807 |
+
msgstr ""
|
808 |
+
|
809 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:245
|
810 |
+
#: templates/popup/index.php:64
|
811 |
+
#: media/js/blocks/dist/index.js:1
|
812 |
+
msgid "Base font size for the table. Example 12px, 2em, 80%."
|
813 |
+
msgstr ""
|
814 |
+
|
815 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:253
|
816 |
+
#: templates/popup/index.php:54
|
817 |
+
#: media/js/blocks/dist/index.js:1
|
818 |
+
msgid "Block height in pixels"
|
819 |
+
msgstr ""
|
820 |
+
|
821 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:262
|
822 |
+
#: templates/popup/index.php:68
|
823 |
+
#: media/js/blocks/dist/index.js:1
|
824 |
+
msgid "Time frame for event"
|
825 |
+
msgstr ""
|
826 |
+
|
827 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:277
|
828 |
+
#: templates/popup/index.php:78
|
829 |
+
#: media/js/blocks/dist/index.js:1
|
830 |
+
msgid "Filter events style"
|
831 |
+
msgstr ""
|
832 |
+
|
833 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:282
|
834 |
+
#: templates/popup/index.php:81
|
835 |
+
msgid "Dropdown"
|
836 |
+
msgstr ""
|
837 |
+
|
838 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:321
|
839 |
+
#: templates/popup/index.php:192
|
840 |
+
#: media/js/blocks/dist/index.js:1
|
841 |
+
msgid "Mobile behavior"
|
842 |
+
msgstr ""
|
843 |
+
|
844 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:326
|
845 |
+
#: templates/popup/index.php:196
|
846 |
+
#: media/js/blocks/dist/index.js:1
|
847 |
+
msgid "Table"
|
848 |
+
msgstr ""
|
849 |
+
|
850 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:327
|
851 |
+
#: templates/popup/index.php:195
|
852 |
+
#: media/js/blocks/dist/index.js:1
|
853 |
+
msgid "List"
|
854 |
+
msgstr ""
|
855 |
+
|
856 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:336
|
857 |
+
#: templates/popup/index.php:150
|
858 |
+
#: media/js/blocks/dist/index.js:1
|
859 |
+
msgid "Horizontal align"
|
860 |
+
msgstr ""
|
861 |
+
|
862 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:361
|
863 |
+
#: templates/popup/index.php:159
|
864 |
+
#: media/js/blocks/dist/index.js:1
|
865 |
+
msgid "Vertical align"
|
866 |
+
msgstr ""
|
867 |
+
|
868 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:367
|
869 |
+
#: templates/popup/index.php:161
|
870 |
+
msgid "default"
|
871 |
+
msgstr ""
|
872 |
+
|
873 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:371
|
874 |
+
#: templates/popup/index.php:162
|
875 |
+
#: media/js/blocks/dist/index.js:1
|
876 |
+
msgid "top"
|
877 |
+
msgstr ""
|
878 |
+
|
879 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:375
|
880 |
+
#: templates/popup/index.php:163
|
881 |
+
#: media/js/blocks/dist/index.js:1
|
882 |
+
msgid "middle"
|
883 |
+
msgstr ""
|
884 |
+
|
885 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:379
|
886 |
+
#: templates/popup/index.php:164
|
887 |
+
#: media/js/blocks/dist/index.js:1
|
888 |
+
msgid "bottom"
|
889 |
+
msgstr ""
|
890 |
+
|
891 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:389
|
892 |
+
#: templates/popup/index.php:179
|
893 |
+
#: media/js/blocks/dist/index.js:1
|
894 |
+
msgid "Unique ID"
|
895 |
+
msgstr ""
|
896 |
+
|
897 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:392
|
898 |
+
#: templates/popup/index.php:182
|
899 |
+
#: media/js/blocks/dist/index.js:1
|
900 |
+
msgid "If you use more than one table on a page specify the unique ID for a timetable. It is usually all lowercase and contains only letters, numbers, and hyphens."
|
901 |
+
msgstr ""
|
902 |
+
|
903 |
+
#: classes/widgets/class-mp-timetable-elementor-widget.php:401
|
904 |
+
#: templates/popup/index.php:186
|
905 |
+
#: media/js/blocks/dist/index.js:1
|
906 |
+
msgid "CSS class"
|
907 |
+
msgstr ""
|
908 |
+
|
909 |
#: classes/widgets/class-mp-timetable-widget.php:22
|
910 |
msgid "Display upcoming events."
|
911 |
msgstr ""
|
1067 |
msgid "Hold the Ctrl or Command key to select/deselect multiple options."
|
1068 |
msgstr ""
|
1069 |
|
|
|
|
|
|
|
|
|
|
|
1070 |
#: templates/popup/index.php:38
|
1071 |
msgid "Fields to display:"
|
1072 |
msgstr ""
|
1073 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1074 |
#: templates/popup/index.php:50
|
1075 |
msgid "Check the event parameter(s) to be displayed in the timetable."
|
1076 |
msgstr ""
|
1077 |
|
|
|
|
|
|
|
|
|
|
|
1078 |
#: templates/popup/index.php:57
|
1079 |
msgid "Set height of the block"
|
1080 |
msgstr ""
|
1081 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1082 |
#: templates/popup/index.php:83
|
1083 |
msgid "None"
|
1084 |
msgstr ""
|
1085 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1086 |
#: templates/popup/index.php:198
|
1087 |
msgid "Tick \"List\" to display events in a list view on mobile devices. Tick \"Table\" to display events in a table."
|
1088 |
msgstr ""
|
media/js/blocks/dist/index.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
window.wp=window.wp||{},window.wp["./media/js/blocks/dist/index.js"]=function(e){var t={};function n(l){if(t[l])return t[l].exports;var a=t[l]={i:l,l:!1,exports:{}};return e[l].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,l){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:l})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var l=Object.create(null);if(n.r(l),Object.defineProperty(l,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(l,a,function(t){return e[t]}.bind(null,a));return l},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=5)}([function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.lodash},,,,function(e,t,n){"use strict";n.r(t);var l=n(1),a=n(0);function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var l=t[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(e,l.key,l)}}function c(e,t){return!t||"object"!==o(t)&&"function"!=typeof t?u(e):t}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var s=wp.element.Component,f=wp.editor.InspectorControls,_=wp.components,v=_.SelectControl,d=_.CheckboxControl,h=_.PanelBody,y=_.TextControl,O=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&m(e,t)}(O,e);var t,n,o,s,_=(t=O,function(){var e,n=p(t);if(b()){var l=p(this).constructor;e=Reflect.construct(n,arguments,l)}else e=n.apply(this,arguments);return c(this,e)});function O(){var e;return r(this,O),(e=_.apply(this,arguments)).setOptions=e.setOptions.bind(u(e)),e}return n=O,(o=[{key:"setOptions",value:function(e){var t=[];return e&&(t=e.map((function(e){return{value:e.id.toString(),label:Object(l.get)(e,["title","raw"])||Object(l.get)(e,["name"])}}))),t}},{key:"render",value:function(){var e=this.props,t=e.attributes,n=t.col,l=t.events,o=t.event_categ,r=t.increment,i=t.view,c=t.view_sort,u=t.label,b=t.hide_label,p=t.hide_hrs,m=t.hide_empty_rows,s=t.title,_=t.time,O=t.sub_title,j=t.description,g=t.user,w=t.group,C=t.disable_event_url,E=t.text_align,R=t.text_align_vertical,S=t.id,k=t.custom_class,x=t.row_height,T=t.font_size,P=t.responsive,D=t.table_layout,I=e.selectedEvents,N=e.selectedColumns,H=e.selectedEventCategories,z=e.setAttributes;return React.createElement(f,null,React.createElement(h,{title:Object(a.__)("Settings","mp-timetable")},React.createElement(v,{className:"timetable-wp56-fix",multiple:!0,size:"7",label:Object(a.__)("Columns","mp-timetable"),help:Object(a.__)("Hold the Ctrl or Command key to select/deselect multiple options.","mp-timetable"),value:n,onChange:function(e){return z({col:e})},options:this.setOptions(N)}),React.createElement(v,{className:"timetable-wp56-fix",multiple:!0,size:"7",label:Object(a.__)("Specific events","mp-timetable"),help:Object(a.__)("Hold the Ctrl or Command key to select/deselect multiple options.","mp-timetable"),value:l,onChange:function(e){return z({events:e})},options:this.setOptions(I)}),React.createElement(v,{className:"timetable-wp56-fix",multiple:!0,size:"7",label:Object(a.__)("Event categories","mp-timetable"),help:Object(a.__)("Hold the Ctrl or Command key to select/deselect multiple options.","mp-timetable"),value:o,onChange:function(e){return z({event_categ:e})},options:this.setOptions(H)}),React.createElement(d,{label:Object(a.__)("Title","mp-timetable"),checked:"1"==s,onChange:function(e){z({title:e?"1":"0"})}}),React.createElement(d,{label:Object(a.__)("Time","mp-timetable"),checked:"1"==_,onChange:function(e){z({time:e?"1":"0"})}}),React.createElement(d,{label:Object(a.__)("Subtitle","mp-timetable"),checked:"1"==O,onChange:function(e){z({sub_title:e?"1":"0"})}}),React.createElement(d,{label:Object(a.__)("Description","mp-timetable"),checked:"1"==j,onChange:function(e){z({description:e?"1":"0"})}}),React.createElement(d,{label:Object(a.__)("Event Head","mp-timetable"),checked:"1"==g,onChange:function(e){z({user:e?"1":"0"})}}),React.createElement(y,{label:Object(a.__)("Block height in pixels","mp-timetable"),type:"number",value:isNaN(x)?0:parseInt(x),onChange:function(e){z({row_height:e.toString()})},min:1,step:1}),React.createElement(y,{label:Object(a.__)("Base font size","mp-timetable"),help:Object(a.__)("Base font size for the table. Example 12px, 2em, 80%.","mp-timetable"),value:T,onChange:function(e){return z({font_size:e})}}),React.createElement(v,{label:Object(a.__)("Time frame for event","mp-timetable"),value:r,onChange:function(e){return z({increment:e})},options:[{value:"1",label:Object(a.__)("Hour (1h)","mp-timetable")},{value:"0.5",label:Object(a.__)("Half hour (30min)","mp-timetable")},{value:"0.25",label:Object(a.__)("Quarter hour (15min)","mp-timetable")}]}),React.createElement(v,{label:Object(a.__)("Filter events style","mp-timetable"),value:i,onChange:function(e){return z({view:e})},options:[{value:"dropdown_list",label:Object(a.__)("Dropdown list","mp-timetable")},{value:"tabs",label:Object(a.__)("Tabs","mp-timetable")}]}),React.createElement(v,{label:Object(a.__)("Order of items in filter","mp-timetable"),value:c,onChange:function(e){return z({view_sort:e})},options:[{value:"",label:Object(a.__)("Default","mp-timetable")},{value:"menu_order",label:Object(a.__)("Menu Order","mp-timetable")},{value:"post_title",label:Object(a.__)("Title","mp-timetable")}]}),React.createElement(y,{label:Object(a.__)("Filter title to display all events","mp-timetable"),value:u,onChange:function(e){return z({label:e})}}),React.createElement(v,{label:Object(a.__)("Hide 'All Events' option","mp-timetable"),value:b,onChange:function(e){return z({hide_label:e})},options:[{value:"0",label:Object(a.__)("No","mp-timetable")},{value:"1",label:Object(a.__)("Yes","mp-timetable")}]}),React.createElement(v,{label:Object(a.__)("Hide column with hours","mp-timetable"),value:p,onChange:function(e){return z({hide_hrs:e})},options:[{value:"0",label:Object(a.__)("No","mp-timetable")},{value:"1",label:Object(a.__)("Yes","mp-timetable")}]}),React.createElement(v,{label:Object(a.__)("Do not display empty rows","mp-timetable"),value:m,onChange:function(e){return z({hide_empty_rows:e})},options:[{value:"0",label:Object(a.__)("No","mp-timetable")},{value:"1",label:Object(a.__)("Yes","mp-timetable")}]}),React.createElement(v,{label:Object(a.__)("Merge cells with common events","mp-timetable"),value:w,onChange:function(e){return z({group:e})},options:[{value:"0",label:Object(a.__)("No","mp-timetable")},{value:"1",label:Object(a.__)("Yes","mp-timetable")}]}),React.createElement(v,{label:Object(a.__)("Disable event link","mp-timetable"),value:C,onChange:function(e){return z({disable_event_url:e})},options:[{value:"0",label:Object(a.__)("No","mp-timetable")},{value:"1",label:Object(a.__)("Yes","mp-timetable")}]}),React.createElement(v,{label:Object(a.__)("Horizontal align","mp-timetable"),value:E,onChange:function(e){return z({text_align:e})},options:[{value:"center",label:Object(a.__)("center","mp-timetable")},{value:"left",label:Object(a.__)("left","mp-timetable")},{value:"right",label:Object(a.__)("right","mp-timetable")}]}),React.createElement(v,{label:Object(a.__)("Vertical align","mp-timetable"),value:R,onChange:function(e){return z({text_align_vertical:e})},options:[{value:"default",label:Object(a.__)("Default","mp-timetable")},{value:"top",label:Object(a.__)("top","mp-timetable")},{value:"middle",label:Object(a.__)("middle","mp-timetable")},{value:"bottom",label:Object(a.__)("bottom","mp-timetable")}]}),React.createElement(v,{label:Object(a.__)("Column width","mp-timetable"),value:D,onChange:function(e){return z({table_layout:e})},options:[{value:"",label:Object(a.__)("Default","mp-timetable")},{value:"auto",label:Object(a.__)("Auto","mp-timetable")},{value:"fixed",label:Object(a.__)("Fixed","mp-timetable")}]}),React.createElement(y,{label:Object(a.__)("Unique ID","mp-timetable"),help:Object(a.__)("If you use more than one table on a page specify the unique ID for a timetable. It is usually all lowercase and contains only letters, numbers, and hyphens.","mp-timetable"),value:S,onChange:function(e){return z({id:e})}}),React.createElement(y,{label:Object(a.__)("CSS class","mp-timetable"),value:k,onChange:function(e){return z({custom_class:e})}}),React.createElement(v,{label:Object(a.__)("Mobile behavior","mp-timetable"),value:P,onChange:function(e){return z({responsive:e})},options:[{value:"0",label:Object(a.__)("Table","mp-timetable")},{value:"1",label:Object(a.__)("List","mp-timetable")}]})))}}])&&i(n.prototype,o),s&&i(n,s),O}(s);function j(e){return(j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function g(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t){for(var n=0;n<t.length;n++){var l=t[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(e,l.key,l)}}function C(e,t){return!t||"object"!==j(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function E(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function R(e){return(R=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var k=wp.element,x=k.Component,T=k.Fragment,P=wp.compose.compose,D=wp.components,I=D.Disabled,N=D.ServerSideRender,H=wp.data.withSelect,z=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&S(e,t)}(i,e);var t,n,a,o,r=(t=i,function(){var e,n=R(t);if(E()){var l=R(this).constructor;e=Reflect.construct(n,arguments,l)}else e=n.apply(this,arguments);return C(this,e)});function i(){return g(this,i),r.apply(this,arguments)}return n=i,(a=[{key:"initTable",value:function(){var e=this.props.clientId,t=jQuery("#block-".concat(e)),n=setInterval((function(){t.find(".mptt-shortcode-wrapper").length&&!t.find(".mptt-shortcode-wrapper").hasClass("table-init")&&(clearInterval(n),window.mptt.tableInit())}),1)}},{key:"componentDidUpdate",value:function(e,t){Object(l.isEqual)(this.props.attributes,e.attributes)||this.initTable()}},{key:"componentDidMount",value:function(){this.initTable()}},{key:"render",value:function(){var e=this.props.attributes;return e.events,e.event_categ,React.createElement(T,null,React.createElement(O,this.props),React.createElement(I,null,React.createElement(N,{block:"mp-timetable/timetable",attributes:this.props.attributes})))}}])&&w(n.prototype,a),o&&w(n,o),i}(x),M=P([H((function(e,t){var n=e("core"),a=n.getEntityRecords,o=(n.getCategories,a("postType","mp-event",{per_page:-1,orderby:"title",order:"asc"})),r=a("postType","mp-column",{per_page:-1}),i=a("taxonomy","mp-event_category",{per_page:-1});return{selectedEvents:o?o.map((function(e){return Object(l.pick)(e,["id","title"])})):null,selectedColumns:r?r.map((function(e){return Object(l.pick)(e,["id","title"])})):null,selectedEventCategories:i?i.map((function(e){return Object(l.pick)(e,["id","name"])})):null}}))])(z);(0,wp.blocks.registerBlockType)("mp-timetable/timetable",{title:Object(a.__)("Timetable","mp-timetable"),category:"common",icon:"calendar",supports:{align:["wide","full"]},getEditWrapperProps:function(e){var t=e.align;if(["wide","full"].includes(t))return{"data-align":t}},edit:M,save:function(){return null}})}]);
|
1 |
+
window.wp=window.wp||{},window.wp["./media/js/blocks/dist/index.js"]=function(e){var t={};function n(l){if(t[l])return t[l].exports;var o=t[l]={i:l,l:!1,exports:{}};return e[l].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,l){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:l})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var l=Object.create(null);if(n.r(l),Object.defineProperty(l,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(l,o,function(t){return e[t]}.bind(null,o));return l},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t){e.exports=window.wp.i18n},function(e,t){e.exports=window.lodash},,,,,function(e,t,n){"use strict";n.r(t);var l=n(1),o=n(0);function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var l=t[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(e,l.key,l)}}function c(e,t){return!t||"object"!==a(t)&&"function"!=typeof t?u(e):t}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var s=wp.element.Component,f=(wp.blockEditor||wp.editor).InspectorControls,_=wp.components,v=_.SelectControl,d=_.CheckboxControl,h=_.PanelBody,y=_.TextControl,O=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&m(e,t)}(O,e);var t,n,a,s,_=(t=O,function(){var e,n=p(t);if(b()){var l=p(this).constructor;e=Reflect.construct(n,arguments,l)}else e=n.apply(this,arguments);return c(this,e)});function O(){var e;return r(this,O),(e=_.apply(this,arguments)).setOptions=e.setOptions.bind(u(e)),e}return n=O,(a=[{key:"setOptions",value:function(e){var t=[];return e&&(t=e.map((function(e){return{value:e.id.toString(),label:Object(l.get)(e,["title","raw"])||Object(l.get)(e,["name"])}}))),t}},{key:"render",value:function(){var e=this.props,t=e.attributes,n=t.col,l=t.events,a=t.event_categ,r=t.increment,i=t.view,c=t.view_sort,u=t.label,b=t.hide_label,p=t.hide_hrs,m=t.hide_empty_rows,s=t.title,_=t.time,O=t.sub_title,j=t.description,g=t.user,w=t.group,C=t.disable_event_url,E=t.text_align,R=t.text_align_vertical,S=t.id,k=t.custom_class,x=t.row_height,T=t.font_size,P=t.responsive,D=t.table_layout,I=e.selectedEvents,N=e.selectedColumns,H=e.selectedEventCategories,z=e.setAttributes;return React.createElement(f,null,React.createElement(h,{title:Object(o.__)("Settings","mp-timetable")},React.createElement(v,{className:"timetable-wp56-fix",multiple:!0,size:"7",label:Object(o.__)("Columns","mp-timetable"),help:Object(o.__)("Hold the Ctrl or Command key to select/deselect multiple options.","mp-timetable"),value:n,onChange:function(e){return z({col:e})},options:this.setOptions(N)}),React.createElement(v,{className:"timetable-wp56-fix",multiple:!0,size:"7",label:Object(o.__)("Specific events","mp-timetable"),help:Object(o.__)("Hold the Ctrl or Command key to select/deselect multiple options.","mp-timetable"),value:l,onChange:function(e){return z({events:e})},options:this.setOptions(I)}),React.createElement(v,{className:"timetable-wp56-fix",multiple:!0,size:"7",label:Object(o.__)("Event categories","mp-timetable"),help:Object(o.__)("Hold the Ctrl or Command key to select/deselect multiple options.","mp-timetable"),value:a,onChange:function(e){return z({event_categ:e})},options:this.setOptions(H)}),React.createElement(d,{label:Object(o.__)("Title","mp-timetable"),checked:"1"==s,onChange:function(e){z({title:e?"1":"0"})}}),React.createElement(d,{label:Object(o.__)("Time","mp-timetable"),checked:"1"==_,onChange:function(e){z({time:e?"1":"0"})}}),React.createElement(d,{label:Object(o.__)("Subtitle","mp-timetable"),checked:"1"==O,onChange:function(e){z({sub_title:e?"1":"0"})}}),React.createElement(d,{label:Object(o.__)("Description","mp-timetable"),checked:"1"==j,onChange:function(e){z({description:e?"1":"0"})}}),React.createElement(d,{label:Object(o.__)("Event Head","mp-timetable"),checked:"1"==g,onChange:function(e){z({user:e?"1":"0"})}}),React.createElement(y,{label:Object(o.__)("Block height in pixels","mp-timetable"),type:"number",value:isNaN(x)?0:parseInt(x),onChange:function(e){z({row_height:e.toString()})},min:1,step:1}),React.createElement(y,{label:Object(o.__)("Base font size","mp-timetable"),help:Object(o.__)("Base font size for the table. Example 12px, 2em, 80%.","mp-timetable"),value:T,onChange:function(e){return z({font_size:e})}}),React.createElement(v,{label:Object(o.__)("Time frame for event","mp-timetable"),value:r,onChange:function(e){return z({increment:e})},options:[{value:"1",label:Object(o.__)("Hour (1h)","mp-timetable")},{value:"0.5",label:Object(o.__)("Half hour (30min)","mp-timetable")},{value:"0.25",label:Object(o.__)("Quarter hour (15min)","mp-timetable")}]}),React.createElement(v,{label:Object(o.__)("Filter events style","mp-timetable"),value:i,onChange:function(e){return z({view:e})},options:[{value:"dropdown_list",label:Object(o.__)("Dropdown list","mp-timetable")},{value:"tabs",label:Object(o.__)("Tabs","mp-timetable")}]}),React.createElement(v,{label:Object(o.__)("Order of items in filter","mp-timetable"),value:c,onChange:function(e){return z({view_sort:e})},options:[{value:"",label:Object(o.__)("Default","mp-timetable")},{value:"menu_order",label:Object(o.__)("Menu Order","mp-timetable")},{value:"post_title",label:Object(o.__)("Title","mp-timetable")}]}),React.createElement(y,{label:Object(o.__)("Filter title to display all events","mp-timetable"),value:u,onChange:function(e){return z({label:e})}}),React.createElement(v,{label:Object(o.__)("Hide 'All Events' option","mp-timetable"),value:b,onChange:function(e){return z({hide_label:e})},options:[{value:"0",label:Object(o.__)("No","mp-timetable")},{value:"1",label:Object(o.__)("Yes","mp-timetable")}]}),React.createElement(v,{label:Object(o.__)("Hide column with hours","mp-timetable"),value:p,onChange:function(e){return z({hide_hrs:e})},options:[{value:"0",label:Object(o.__)("No","mp-timetable")},{value:"1",label:Object(o.__)("Yes","mp-timetable")}]}),React.createElement(v,{label:Object(o.__)("Do not display empty rows","mp-timetable"),value:m,onChange:function(e){return z({hide_empty_rows:e})},options:[{value:"0",label:Object(o.__)("No","mp-timetable")},{value:"1",label:Object(o.__)("Yes","mp-timetable")}]}),React.createElement(v,{label:Object(o.__)("Merge cells with common events","mp-timetable"),value:w,onChange:function(e){return z({group:e})},options:[{value:"0",label:Object(o.__)("No","mp-timetable")},{value:"1",label:Object(o.__)("Yes","mp-timetable")}]}),React.createElement(v,{label:Object(o.__)("Disable event link","mp-timetable"),value:C,onChange:function(e){return z({disable_event_url:e})},options:[{value:"0",label:Object(o.__)("No","mp-timetable")},{value:"1",label:Object(o.__)("Yes","mp-timetable")}]}),React.createElement(v,{label:Object(o.__)("Horizontal align","mp-timetable"),value:E,onChange:function(e){return z({text_align:e})},options:[{value:"center",label:Object(o.__)("center","mp-timetable")},{value:"left",label:Object(o.__)("left","mp-timetable")},{value:"right",label:Object(o.__)("right","mp-timetable")}]}),React.createElement(v,{label:Object(o.__)("Vertical align","mp-timetable"),value:R,onChange:function(e){return z({text_align_vertical:e})},options:[{value:"default",label:Object(o.__)("Default","mp-timetable")},{value:"top",label:Object(o.__)("top","mp-timetable")},{value:"middle",label:Object(o.__)("middle","mp-timetable")},{value:"bottom",label:Object(o.__)("bottom","mp-timetable")}]}),React.createElement(v,{label:Object(o.__)("Column width","mp-timetable"),value:D,onChange:function(e){return z({table_layout:e})},options:[{value:"",label:Object(o.__)("Default","mp-timetable")},{value:"auto",label:Object(o.__)("Auto","mp-timetable")},{value:"fixed",label:Object(o.__)("Fixed","mp-timetable")}]}),React.createElement(y,{label:Object(o.__)("Unique ID","mp-timetable"),help:Object(o.__)("If you use more than one table on a page specify the unique ID for a timetable. It is usually all lowercase and contains only letters, numbers, and hyphens.","mp-timetable"),value:S,onChange:function(e){return z({id:e})}}),React.createElement(y,{label:Object(o.__)("CSS class","mp-timetable"),value:k,onChange:function(e){return z({custom_class:e})}}),React.createElement(v,{label:Object(o.__)("Mobile behavior","mp-timetable"),value:P,onChange:function(e){return z({responsive:e})},options:[{value:"0",label:Object(o.__)("Table","mp-timetable")},{value:"1",label:Object(o.__)("List","mp-timetable")}]})))}}])&&i(n.prototype,a),s&&i(n,s),O}(s);function j(e){return(j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function g(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t){for(var n=0;n<t.length;n++){var l=t[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(e,l.key,l)}}function C(e,t){return!t||"object"!==j(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function E(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function R(e){return(R=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function S(e,t){return(S=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var k=wp.serverSideRender,x=wp.element,T=x.Component,P=x.Fragment,D=wp.compose.compose,I=wp.components.Disabled,N=wp.data.withSelect,H=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&S(e,t)}(i,e);var t,n,o,a,r=(t=i,function(){var e,n=R(t);if(E()){var l=R(this).constructor;e=Reflect.construct(n,arguments,l)}else e=n.apply(this,arguments);return C(this,e)});function i(){return g(this,i),r.apply(this,arguments)}return n=i,(o=[{key:"initTable",value:function(){var e=this.props.clientId,t=jQuery("#block-".concat(e)),n=setInterval((function(){t.find(".mptt-shortcode-wrapper").length&&!t.find(".mptt-shortcode-wrapper").hasClass("table-init")&&(clearInterval(n),window.mptt.tableInit())}),1)}},{key:"componentDidUpdate",value:function(e,t){Object(l.isEqual)(this.props.attributes,e.attributes)||this.initTable()}},{key:"componentDidMount",value:function(){this.initTable()}},{key:"render",value:function(){var e=this.props.attributes;return e.events,e.event_categ,React.createElement(P,null,React.createElement(O,this.props),React.createElement(I,null,React.createElement(k,{block:"mp-timetable/timetable",attributes:this.props.attributes})))}}])&&w(n.prototype,o),a&&w(n,a),i}(T),z=D([N((function(e,t){var n=e("core"),o=n.getEntityRecords,a=(n.getCategories,o("postType","mp-event",{per_page:-1,orderby:"title",order:"asc"})),r=o("postType","mp-column",{per_page:-1}),i=o("taxonomy","mp-event_category",{per_page:-1});return{selectedEvents:a?a.map((function(e){return Object(l.pick)(e,["id","title"])})):null,selectedColumns:r?r.map((function(e){return Object(l.pick)(e,["id","title"])})):null,selectedEventCategories:i?i.map((function(e){return Object(l.pick)(e,["id","name"])})):null}}))])(H);(0,wp.blocks.registerBlockType)("mp-timetable/timetable",{title:Object(o.__)("Timetable","mp-timetable"),category:"common",icon:"calendar",supports:{align:["wide","full"]},getEditWrapperProps:function(e){var t=e.align;if(["wide","full"].includes(t))return{"data-align":t}},edit:z,save:function(){return null}})}]);
|
media/js/blocks/src/timetable/edit.js
CHANGED
@@ -3,12 +3,12 @@ import Inspector from './inspector';
|
|
3 |
import { pick, isEqual } from "lodash";
|
4 |
import { __ } from 'wp.i18n';
|
5 |
|
|
|
6 |
const { Component, Fragment } = wp.element;
|
7 |
const { compose } = wp.compose;
|
8 |
|
9 |
const {
|
10 |
-
Disabled
|
11 |
-
ServerSideRender
|
12 |
} = wp.components;
|
13 |
|
14 |
const {
|
3 |
import { pick, isEqual } from "lodash";
|
4 |
import { __ } from 'wp.i18n';
|
5 |
|
6 |
+
const { serverSideRender: ServerSideRender } = wp;
|
7 |
const { Component, Fragment } = wp.element;
|
8 |
const { compose } = wp.compose;
|
9 |
|
10 |
const {
|
11 |
+
Disabled
|
|
|
12 |
} = wp.components;
|
13 |
|
14 |
const {
|
media/js/blocks/src/timetable/inspector.js
CHANGED
@@ -5,7 +5,7 @@ const {Component} = wp.element;
|
|
5 |
|
6 |
const {
|
7 |
InspectorControls,
|
8 |
-
} = wp.editor;
|
9 |
|
10 |
const {
|
11 |
SelectControl,
|
5 |
|
6 |
const {
|
7 |
InspectorControls,
|
8 |
+
} = wp.blockEditor || wp.editor;
|
9 |
|
10 |
const {
|
11 |
SelectControl,
|
media/js/events/event.js
CHANGED
@@ -1,972 +1,972 @@
|
|
1 |
-
/*global jQuery:false, console:false, _:false, CommonManager:false,Registry:false, wp:false, MPTT:false*/
|
2 |
-
|
3 |
-
Registry.register("Event",
|
4 |
-
(function($) {
|
5 |
-
"use strict";
|
6 |
-
|
7 |
-
var state;
|
8 |
-
|
9 |
-
function createInstance() {
|
10 |
-
|
11 |
-
return {
|
12 |
-
event_id: '',
|
13 |
-
eventsData: {},
|
14 |
-
/**
|
15 |
-
* Init
|
16 |
-
*/
|
17 |
-
init: function() {
|
18 |
-
state.initTimePicker();
|
19 |
-
state.addEventButton();
|
20 |
-
state.initDeleteButtons();
|
21 |
-
state.initEditButtons();
|
22 |
-
state.initColorPicker();
|
23 |
-
state.initDatePicker();
|
24 |
-
state.columnRadioBox();
|
25 |
-
},
|
26 |
-
/**
|
27 |
-
* Init time picker
|
28 |
-
*/
|
29 |
-
initTimePicker: function() {
|
30 |
-
var timeFormat = Boolean(parseInt($('#time_format').val()));
|
31 |
-
$('#event_start').timepicker({
|
32 |
-
showPeriod: timeFormat, // Define whether or not to show AM/PM with selected time. (default: false)
|
33 |
-
showPeriodLabels: timeFormat,
|
34 |
-
defaultTime: '00:00'
|
35 |
-
});
|
36 |
-
|
37 |
-
$('#event_end').timepicker({
|
38 |
-
showPeriod: timeFormat, // Define whether or not to show AM/PM with selected time. (default: false)
|
39 |
-
showPeriodLabels: timeFormat,
|
40 |
-
defaultTime: '00:00'
|
41 |
-
});
|
42 |
-
},
|
43 |
-
/**
|
44 |
-
* Init widget slider
|
45 |
-
* @param selector
|
46 |
-
* @param autoScroll
|
47 |
-
*/
|
48 |
-
initSlider: function(selector, autoScroll) {
|
49 |
-
var play = _.isUndefined(autoScroll) ? false : Boolean(autoScroll);
|
50 |
-
var id = selector.replace(/^\D+/g, '');
|
51 |
-
$(selector).carouFredSel({
|
52 |
-
items: {
|
53 |
-
visible: 3
|
54 |
-
},
|
55 |
-
direction: "up",
|
56 |
-
scroll: {
|
57 |
-
items: 1,
|
58 |
-
easing: "swing",
|
59 |
-
pauseOnHover: true,
|
60 |
-
onAfter: function(data) {
|
61 |
-
data.items.old.each(function() {
|
62 |
-
$(this).removeClass('visible');
|
63 |
-
}
|
64 |
-
);
|
65 |
-
data.items.visible.each(function() {
|
66 |
-
$(this).addClass('visible');
|
67 |
-
}
|
68 |
-
);
|
69 |
-
}
|
70 |
-
},
|
71 |
-
auto: {
|
72 |
-
play: play,
|
73 |
-
timeoutDuration: 3000
|
74 |
-
},
|
75 |
-
prev: {
|
76 |
-
button: "#mp_prev_button" + id
|
77 |
-
},
|
78 |
-
next: {
|
79 |
-
button: "#mp_next_button" + id
|
80 |
-
}
|
81 |
-
});
|
82 |
-
|
83 |
-
$(selector).trigger("currentVisible", function(items) {
|
84 |
-
items.addClass("visible");
|
85 |
-
});
|
86 |
-
state.setColorSettings(selector + ' ' + '.mptt-colorized');
|
87 |
-
},
|
88 |
-
/**
|
89 |
-
* init Delete Button
|
90 |
-
*/
|
91 |
-
initDeleteButton: function() {
|
92 |
-
var $events = $('#events-list');
|
93 |
-
|
94 |
-
$events.find('li.event').find('i.operation-button.dashicons-no.dashicons').off('click').on('click', function() {
|
95 |
-
if ($events.find('li.event').length > 1) {
|
96 |
-
$(this).parents('li.event').remove();
|
97 |
-
} else {
|
98 |
-
$events.remove();
|
99 |
-
}
|
100 |
-
});
|
101 |
-
},
|
102 |
-
/**
|
103 |
-
* Init color picker
|
104 |
-
*/
|
105 |
-
initColorPicker: function(parent) {
|
106 |
-
if (_.isUndefined(parent)) {
|
107 |
-
parent = '';
|
108 |
-
}
|
109 |
-
var selectorColorInput = $(parent + ' input.clr-picker');
|
110 |
-
var selectorTextInput = $(parent + ' input.regular-text');
|
111 |
-
selectorColorInput.spectrum("destroy");
|
112 |
-
|
113 |
-
// init color picker
|
114 |
-
selectorColorInput.spectrum({
|
115 |
-
preferredFormat: "rgb",
|
116 |
-
showInput: true,
|
117 |
-
showAlpha: true,
|
118 |
-
allowEmpty: true,
|
119 |
-
palette: [
|
120 |
-
["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
|
121 |
-
["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
|
122 |
-
["#f4cccc", "#fce5cd", "#fff2cc", "#d9ead3", "#d0e0e3", "#cfe2f3", "#d9d2e9", "#ead1dc"],
|
123 |
-
["#ea9999", "#f9cb9c", "#ffe599", "#b6d7a8", "#a2c4c9", "#9fc5e8", "#b4a7d6", "#d5a6bd"],
|
124 |
-
["#e06666", "#f6b26b", "#ffd966", "#93c47d", "#76a5af", "#6fa8dc", "#8e7cc3", "#c27ba0"],
|
125 |
-
["#c00", "#e69138", "#f1c232", "#6aa84f", "#45818e", "#3d85c6", "#674ea7", "#a64d79"],
|
126 |
-
["#900", "#b45f06", "#bf9000", "#38761d", "#134f5c", "#0b5394", "#351c75", "#741b47"],
|
127 |
-
["#600", "#783f04", "#7f6000", "#274e13", "#0c343d", "#073763", "#20124d", "#4c1130"]
|
128 |
-
],
|
129 |
-
showPalette: true,
|
130 |
-
show: function(color) {
|
131 |
-
$(this).val(color);
|
132 |
-
},
|
133 |
-
hide: function(color) {
|
134 |
-
var parent = $(this).parents('.select-color');
|
135 |
-
parent.find('.regular-text').val($(this).val());
|
136 |
-
},
|
137 |
-
change: function(color) {
|
138 |
-
var parent = $(this).parents('.select-color');
|
139 |
-
parent.find('input:not([type="hidden"])').val($(this).val());
|
140 |
-
}
|
141 |
-
});
|
142 |
-
|
143 |
-
//change color preview block
|
144 |
-
selectorTextInput.off('keyup').on('keyup', function() {
|
145 |
-
var parentTr = $(this).parents('.select-color');
|
146 |
-
var spectrumElement = parentTr.find('.clr-picker');
|
147 |
-
var colorElement = parentTr.find(".regular-text").val();
|
148 |
-
var preview_inner = parentTr.find(".sp-preview-inner");
|
149 |
-
preview_inner.css({
|
150 |
-
'background-color': colorElement
|
151 |
-
});
|
152 |
-
spectrumElement.spectrum("set", colorElement);
|
153 |
-
});
|
154 |
-
},
|
155 |
-
/**
|
156 |
-
* Add event
|
157 |
-
*/
|
158 |
-
addEventButton: function() {
|
159 |
-
$(document).on('click.admin', '#add_mp_event', function() {
|
160 |
-
if ($(this).hasClass('edit')) {
|
161 |
-
state.updateEventData();
|
162 |
-
} else {
|
163 |
-
state.renderEventItem();
|
164 |
-
}
|
165 |
-
});
|
166 |
-
},
|
167 |
-
/**
|
168 |
-
* init event data delete button
|
169 |
-
*/
|
170 |
-
initDeleteButtons: function() {
|
171 |
-
$(document).on('click.admin', '#events-list .delete-event-button', function() {
|
172 |
-
var id = $(this).attr('data-id');
|
173 |
-
state.deleteEvent(id);
|
174 |
-
});
|
175 |
-
},
|
176 |
-
/**
|
177 |
-
* init event data edit button
|
178 |
-
*/
|
179 |
-
initEditButtons: function() {
|
180 |
-
$(document).on('click.admin', '#events-list .edit-event-button', function() {
|
181 |
-
var id = $(this).attr('data-id'),
|
182 |
-
$tr = $(this).parent().parent();
|
183 |
-
$(this).parent().find('.spinner').addClass('is-active');
|
184 |
-
|
185 |
-
Registry._get("adminFunctions").wpAjax({
|
186 |
-
controller: "events",
|
187 |
-
action: "get_event_data",
|
188 |
-
id: id
|
189 |
-
},
|
190 |
-
function(data) {
|
191 |
-
var $addMpEvent = $('#add_mp_event');
|
192 |
-
var $events = $('#events-list');
|
193 |
-
$events.find('.spinner').removeClass('is-active');
|
194 |
-
$events.find(' tr').removeClass('active');
|
195 |
-
$tr.addClass('active');
|
196 |
-
|
197 |
-
$('#event_start').val(data.event_start);
|
198 |
-
$('#event_end').val(data.event_end);
|
199 |
-
$('#description').val(data.description);
|
200 |
-
$('#user_id').val(data.user_id);
|
201 |
-
$('#weekday_id').val(data.column_id);
|
202 |
-
|
203 |
-
$addMpEvent.addClass('edit');
|
204 |
-
$addMpEvent.val('Update');
|
205 |
-
|
206 |
-
state.event_id = data.id;
|
207 |
-
},
|
208 |
-
function(data) {
|
209 |
-
console.warn(data);
|
210 |
-
}
|
211 |
-
);
|
212 |
-
});
|
213 |
-
},
|
214 |
-
/**
|
215 |
-
* Delete event data by id
|
216 |
-
*
|
217 |
-
* @param id
|
218 |
-
*/
|
219 |
-
deleteEvent: function(id) {
|
220 |
-
Registry._get("adminFunctions").wpAjax(
|
221 |
-
{
|
222 |
-
controller: "events",
|
223 |
-
action: "delete",
|
224 |
-
id: id
|
225 |
-
},
|
226 |
-
function(data) {
|
227 |
-
var $deleteEvent = $('#events-list').find('tr[data-id="' + id + '"]');
|
228 |
-
if ($deleteEvent.length) {
|
229 |
-
$deleteEvent.remove();
|
230 |
-
}
|
231 |
-
},
|
232 |
-
function(data) {
|
233 |
-
console.log(data);
|
234 |
-
}
|
235 |
-
);
|
236 |
-
},
|
237 |
-
/**
|
238 |
-
* Update event item
|
239 |
-
*/
|
240 |
-
updateEventItem: function() {
|
241 |
-
var item = $('#events-list').find('tr[data-id="' + state.event_id + '"]');
|
242 |
-
var $userId = $('#user_id');
|
243 |
-
|
244 |
-
item.find('td.event-column').text($('#weekday_id').find('option:selected').text());
|
245 |
-
item.find('td.event-start').text($('#event_start').val());
|
246 |
-
item.find('td.event-end').text($('#event_end').val());
|
247 |
-
|
248 |
-
item.find('td.event-user-id').text(( $userId.val() === '-1') ? '' : $userId.find('option:selected').text());
|
249 |
-
item.find('td.event-description').text($('#description').val());
|
250 |
-
|
251 |
-
state.event_id = null;
|
252 |
-
$('#add_mp_event').removeClass('edit').val('Add New');
|
253 |
-
},
|
254 |
-
/**
|
255 |
-
* Update Event data
|
256 |
-
*/
|
257 |
-
updateEventData: function() {
|
258 |
-
var $addEventTable = $('#add_event_table').find('.spinner');
|
259 |
-
|
260 |
-
$addEventTable.addClass('is-active');
|
261 |
-
|
262 |
-
Registry._get("adminFunctions").wpAjax({
|
263 |
-
controller: "events",
|
264 |
-
action: "update_event_data",
|
265 |
-
data: {
|
266 |
-
id: Registry._get("Event").event_id,
|
267 |
-
event_start: $('#event_start').val(),
|
268 |
-
event_end: $('#event_end').val(),
|
269 |
-
description: $('#description').val(),
|
270 |
-
user_id: $('#user_id').val(),
|
271 |
-
weekday_ids: $('#weekday_id').val()
|
272 |
-
}
|
273 |
-
},
|
274 |
-
function() {
|
275 |
-
$addEventTable.removeClass('is-active');
|
276 |
-
state.updateEventItem();
|
277 |
-
state.clearTable();
|
278 |
-
},
|
279 |
-
function(data) {
|
280 |
-
$addEventTable.removeClass('is-active');
|
281 |
-
console.log(data);
|
282 |
-
}
|
283 |
-
);
|
284 |
-
},
|
285 |
-
/**
|
286 |
-
* Render event item
|
287 |
-
*/
|
288 |
-
renderEventItem: function() {
|
289 |
-
var $weekdayId = $('#weekday_id');
|
290 |
-
var $userId = $('#user_id');
|
291 |
-
var column_ID = $weekdayId.find('option:selected').val();
|
292 |
-
var $eventStart = $('#event_start');
|
293 |
-
var $eventEnd = $('#event_end');
|
294 |
-
var $description = $('#description');
|
295 |
-
|
296 |
-
var template = {
|
297 |
-
tag: 'tr',
|
298 |
-
attrs: {},
|
299 |
-
content: [
|
300 |
-
{
|
301 |
-
tag: 'td',
|
302 |
-
attrs: {'style': 'display:none;'},
|
303 |
-
content: [
|
304 |
-
{
|
305 |
-
tag: 'input',
|
306 |
-
attrs: {
|
307 |
-
'type': 'hidden',
|
308 |
-
'name': 'event_data[' + column_ID + '][weekday_ids][]',
|
309 |
-
'value': column_ID
|
310 |
-
}
|
311 |
-
},
|
312 |
-
{
|
313 |
-
tag: 'input',
|
314 |
-
attrs: {
|
315 |
-
'type': 'hidden',
|
316 |
-
'name': 'event_data[' + column_ID + '][event_start][]',
|
317 |
-
'value': $eventStart.val()
|
318 |
-
}
|
319 |
-
},
|
320 |
-
{
|
321 |
-
tag: 'input',
|
322 |
-
attrs: {
|
323 |
-
'type': 'hidden',
|
324 |
-
'name': 'event_data[' + column_ID + '][event_end][]',
|
325 |
-
'value': $eventEnd.val()
|
326 |
-
}
|
327 |
-
},
|
328 |
-
{
|
329 |
-
tag: 'input',
|
330 |
-
attrs: {
|
331 |
-
'type': 'hidden',
|
332 |
-
'name': 'event_data[' + column_ID + '][description][]',
|
333 |
-
'value': $description.val()
|
334 |
-
}
|
335 |
-
},
|
336 |
-
{
|
337 |
-
tag: 'input',
|
338 |
-
attrs: {
|
339 |
-
'type': 'hidden',
|
340 |
-
'name': 'event_data[' + column_ID + '][user_id][]',
|
341 |
-
'value': $userId.val()
|
342 |
-
}
|
343 |
-
}
|
344 |
-
]
|
345 |
-
},
|
346 |
-
{
|
347 |
-
tag: 'td',
|
348 |
-
attrs: {
|
349 |
-
'class': 'event-column'
|
350 |
-
},
|
351 |
-
content: [$weekdayId.find('option:selected').text()]
|
352 |
-
},
|
353 |
-
{
|
354 |
-
tag: 'td',
|
355 |
-
attrs: {
|
356 |
-
'class': 'event-start'
|
357 |
-
},
|
358 |
-
content: [$eventStart.val()]
|
359 |
-
},
|
360 |
-
{
|
361 |
-
tag: 'td',
|
362 |
-
attrs: {
|
363 |
-
'class': 'event-end'
|
364 |
-
},
|
365 |
-
content: [$eventEnd.val()]
|
366 |
-
},
|
367 |
-
{
|
368 |
-
tag: 'td',
|
369 |
-
attrs: {
|
370 |
-
'class': 'event-description'
|
371 |
-
},
|
372 |
-
content: [$description.val()]
|
373 |
-
},
|
374 |
-
{
|
375 |
-
tag: 'td',
|
376 |
-
attrs: {
|
377 |
-
'class': 'event-user-id'
|
378 |
-
},
|
379 |
-
content: [( $userId.val() === '-1') ? '' : $userId.find('option:selected').text()]
|
380 |
-
},
|
381 |
-
{
|
382 |
-
tag: 'td',
|
383 |
-
attrs: {},
|
384 |
-
content: []
|
385 |
-
}
|
386 |
-
]
|
387 |
-
};
|
388 |
-
|
389 |
-
var htmlObject = Registry._get("adminFunctions").getHtml(template);
|
390 |
-
$('#events-list').find('tbody').append(htmlObject);
|
391 |
-
$('.events-list-wrapper').scrollTop(1E10);
|
392 |
-
state.clearTable();
|
393 |
-
},
|
394 |
-
/**
|
395 |
-
* Set event height
|
396 |
-
*
|
397 |
-
* @param element
|
398 |
-
*/
|
399 |
-
setEventHeight: function(element) {
|
400 |
-
var parent_height = element.parent().outerHeight(),
|
401 |
-
body = $('body');
|
402 |
-
|
403 |
-
var elementHeight = element.height();
|
404 |
-
var min_height = element.data('min-height');
|
405 |
-
var inner_height = element.find('.mptt-inner-event-content').height();
|
406 |
-
|
407 |
-
element.css('position', '').css('width', '').css('min-height', '');
|
408 |
-
|
409 |
-
if (!body.hasClass('mprm_ie_browser')) {
|
410 |
-
if (inner_height <= min_height) {
|
411 |
-
element.css('min-height', min_height);
|
412 |
-
} else {
|
413 |
-
element.css('min-height', inner_height);
|
414 |
-
}
|
415 |
-
} else {
|
416 |
-
/** IE block **/
|
417 |
-
inner_height = element.css('height', '').find('.mptt-inner-event-content').height();
|
418 |
-
element.height(elementHeight);
|
419 |
-
|
420 |
-
if (inner_height <= min_height) {
|
421 |
-
element.css('max-height', min_height);
|
422 |
-
} else {
|
423 |
-
element.css('height', '');
|
424 |
-
element.css('max-height', inner_height);
|
425 |
-
}
|
426 |
-
}
|
427 |
-
|
428 |
-
if (parent_height < elementHeight) {
|
429 |
-
element.height(elementHeight);
|
430 |
-
}
|
431 |
-
},
|
432 |
-
/**
|
433 |
-
* Recalculate Height
|
434 |
-
* @param tdParent
|
435 |
-
* @param element
|
436 |
-
*/
|
437 |
-
recalculate_Height: function(tdParent, element) {
|
438 |
-
var events = $('.mptt-event-container', tdParent),
|
439 |
-
eventCount = events.length,
|
440 |
-
heightItem = 0,
|
441 |
-
top = 0,
|
442 |
-
tdHeight = tdParent.height();
|
443 |
-
|
444 |
-
if (!$('body').hasClass('mprm_ie_browser')) {
|
445 |
-
|
446 |
-
heightItem = 100 / ((eventCount > 0) ? eventCount : 1);
|
447 |
-
|
448 |
-
if (!_.isUndefined(element)) {
|
449 |
-
element.height(heightItem + '%');
|
450 |
-
|
451 |
-
} else {
|
452 |
-
|
453 |
-
$.each(events, function() {
|
454 |
-
var $event = $(this);
|
455 |
-
$event.height(heightItem + '%');
|
456 |
-
|
457 |
-
if (_.isEmpty($event.data('min-height'))) {
|
458 |
-
$event.data('min-height', $event.height());
|
459 |
-
}
|
460 |
-
|
461 |
-
$event.css('top', top + '%');
|
462 |
-
$event.removeClass('mptt-hidden');
|
463 |
-
top += heightItem;
|
464 |
-
});
|
465 |
-
}
|
466 |
-
|
467 |
-
} else {
|
468 |
-
|
469 |
-
heightItem = tdHeight / ((eventCount > 0) ? eventCount : 1);
|
470 |
-
|
471 |
-
if (!_.isUndefined(element)) {
|
472 |
-
element.height(heightItem);
|
473 |
-
} else {
|
474 |
-
$.each(events, function() {
|
475 |
-
var $event = $(this);
|
476 |
-
$event.height(heightItem);
|
477 |
-
|
478 |
-
if (_.isEmpty($event.data('min-height'))) {
|
479 |
-
var min_height = $event.height();
|
480 |
-
if (min_height === 0) {
|
481 |
-
$event.data('min-height', heightItem);
|
482 |
-
} else {
|
483 |
-
$event.data('min-height', min_height);
|
484 |
-
}
|
485 |
-
}
|
486 |
-
|
487 |
-
$event.css('top', top + 'px');
|
488 |
-
$event.removeClass('mptt-hidden');
|
489 |
-
top += heightItem;
|
490 |
-
});
|
491 |
-
}
|
492 |
-
}
|
493 |
-
},
|
494 |
-
/**
|
495 |
-
* Fill all possible height in ceil
|
496 |
-
*/
|
497 |
-
setEventsHeight: function() {
|
498 |
-
var events = $('.mptt-shortcode-wrapper').find('table').find('td.event');
|
499 |
-
$.each(events, function() {
|
500 |
-
var td = $(this);
|
501 |
-
state.recalculate_Height(td);
|
502 |
-
});
|
503 |
-
},
|
504 |
-
/**
|
505 |
-
* Set user color settings
|
506 |
-
* @param selector
|
507 |
-
*/
|
508 |
-
setColorSettings: function(selector) {
|
509 |
-
if (_.isUndefined(selector)) {
|
510 |
-
selector = '.mptt-colorized';
|
511 |
-
}
|
512 |
-
|
513 |
-
var elements = $(selector);
|
514 |
-
// var height = '';
|
515 |
-
$.each(elements, function() {
|
516 |
-
var element = $(this),
|
517 |
-
bg = element.attr('data-bg_hover_color'),
|
518 |
-
color = element.attr('data-hover_color'),
|
519 |
-
tdParent = element.parent();
|
520 |
-
// parentHeight = tdParent.height(),
|
521 |
-
// elementHeight = '';
|
522 |
-
|
523 |
-
switch (element.attr('data-type')) {
|
524 |
-
case "column":
|
525 |
-
case "event":
|
526 |
-
element.hover(
|
527 |
-
function() {
|
528 |
-
if (!_.isEmpty(bg)) {
|
529 |
-
element.css('background-color', bg);
|
530 |
-
}
|
531 |
-
if (!_.isEmpty(color)) {
|
532 |
-
element.css('color', color);
|
533 |
-
}
|
534 |
-
|
535 |
-
state.setEventHeight(element);
|
536 |
-
|
537 |
-
}, function() {
|
538 |
-
element.css('max-height', '').css('min-height', '');
|
539 |
-
state.recalculate_Height(tdParent, element);
|
540 |
-
|
541 |
-
element.css('background-color', element.attr('data-bg_color'));
|
542 |
-
element.css('color', element.attr('data-color'));
|
543 |
-
}
|
544 |
-
);
|
545 |
-
break;
|
546 |
-
case "widget":
|
547 |
-
element.hover(
|
548 |
-
function() {
|
549 |
-
element.css('background-color', element.attr('data-background-hover-color'));
|
550 |
-
element.css('color', $(this).attr('data-hover-color'));
|
551 |
-
element.css('border-left-color', element.attr('data-hover-border-color'));
|
552 |
-
},
|
553 |
-
function() {
|
554 |
-
element.css('background-color', element.attr('data-background-color'));
|
555 |
-
element.css('color', element.attr('data-color'));
|
556 |
-
element.css('border-left-color', element.attr('data-border-color'));
|
557 |
-
}
|
558 |
-
);
|
559 |
-
break;
|
560 |
-
default:
|
561 |
-
break;
|
562 |
-
}
|
563 |
-
});
|
564 |
-
},
|
565 |
-
/**
|
566 |
-
* Clear input data
|
567 |
-
*/
|
568 |
-
clearTable: function() {
|
569 |
-
var $weekdayId = $("#weekday_id");
|
570 |
-
$('#add_event_table input:not(.button),#add_event_table textarea').val('');
|
571 |
-
$weekdayId.val($weekdayId.find('option:first').attr('value'));
|
572 |
-
},
|
573 |
-
/**
|
574 |
-
* get Row span
|
575 |
-
*
|
576 |
-
* @param events
|
577 |
-
* @returns {number}
|
578 |
-
*/
|
579 |
-
getRowSpan: function(events, td) {
|
580 |
-
var arrMax = [];
|
581 |
-
var arrMin = [];
|
582 |
-
var columnId = td.attr('data-column-id');
|
583 |
-
|
584 |
-
/*
|
585 |
-
* Erroneous Positioning of Events
|
586 |
-
* https://wordpress.org/support/topic/erroneous-positioning-of-events/
|
587 |
-
*/
|
588 |
-
var nextTr = td.closest('tr').next('tr');
|
589 |
-
var nextTd = nextTr.find('td[data-column-id="' + columnId + '"]');
|
590 |
-
var nextTdSet = (nextTr.length > 0) && (nextTd.length > 0) && (nextTd.children().length > 0);
|
591 |
-
|
592 |
-
while ( !nextTdSet ) {
|
593 |
-
if( nextTr.next('tr').length == 0 ){
|
594 |
-
nextTdSet = true;
|
595 |
-
nextTr = false;
|
596 |
-
break;
|
597 |
-
}
|
598 |
-
|
599 |
-
nextTr = nextTr.next('tr');
|
600 |
-
nextTd = nextTr.find('td[data-column-id="' + columnId + '"]');
|
601 |
-
nextTdSet = nextTd.children().length > 0;
|
602 |
-
}
|
603 |
-
|
604 |
-
var nextEventIndex = false
|
605 |
-
if (nextTr) {
|
606 |
-
nextEventIndex = nextTr.data('index');
|
607 |
-
}
|
608 |
-
//console.log(td, nextEventIndex)
|
609 |
-
|
610 |
-
/* End of "Erroneous Positioning of Events" */
|
611 |
-
|
612 |
-
$.each(events, function(index) {
|
613 |
-
var start = $(this).attr('data-start');
|
614 |
-
var end = $(this).attr('data-end');
|
615 |
-
|
616 |
-
arrMin[index] = start;
|
617 |
-
arrMax[index] = end;
|
618 |
-
});
|
619 |
-
|
620 |
-
var min = Math.min.apply(Math, arrMin);
|
621 |
-
var max = Math.max.apply(Math, arrMax);
|
622 |
-
|
623 |
-
if ( nextEventIndex && max > nextEventIndex ) {
|
624 |
-
max = nextEventIndex;
|
625 |
-
}
|
626 |
-
|
627 |
-
var rowSpan = (max - min);
|
628 |
-
|
629 |
-
return rowSpan < 1 ? 1 : rowSpan;
|
630 |
-
},
|
631 |
-
/**
|
632 |
-
* Responsive filter
|
633 |
-
*
|
634 |
-
* @param element
|
635 |
-
*/
|
636 |
-
responsiveFilter: function(element) {
|
637 |
-
var eventID = 'all';
|
638 |
-
var parentShortcode = element.parents('.mptt-shortcode-wrapper');
|
639 |
-
|
640 |
-
if (element.is("select")) {
|
641 |
-
eventID = element.val();
|
642 |
-
} else {
|
643 |
-
eventID = element.attr('href').replace("#", "");
|
644 |
-
}
|
645 |
-
|
646 |
-
var $listEvent = parentShortcode.find('.mptt-list-event');
|
647 |
-
|
648 |
-
if (eventID !== 'all') {
|
649 |
-
$listEvent.hide();
|
650 |
-
parentShortcode.find('.mptt-list-event[data-event-id="' + eventID + '"]').show();
|
651 |
-
} else {
|
652 |
-
$listEvent.show();
|
653 |
-
}
|
654 |
-
|
655 |
-
$.each(parentShortcode.find('.mptt-column'), function() {
|
656 |
-
$(this).show();
|
657 |
-
if ($(this).find('.mptt-list-event:visible').length < 1) {
|
658 |
-
$(this).hide();
|
659 |
-
}
|
660 |
-
});
|
661 |
-
|
662 |
-
},
|
663 |
-
/**
|
664 |
-
* Filter static version
|
665 |
-
*
|
666 |
-
* @param element
|
667 |
-
*/
|
668 |
-
filterStatic: function(element, event) {
|
669 |
-
|
670 |
-
var parentShortcode = element.parents('.mptt-shortcode-wrapper');
|
671 |
-
var eventID = '#all';
|
672 |
-
var id = _.isEmpty(parentShortcode.attr('id')) ? 'not-set' : parentShortcode.attr('id');
|
673 |
-
|
674 |
-
if (element.is("select")) {
|
675 |
-
eventID = element.val();
|
676 |
-
} else {
|
677 |
-
eventID = element.attr('href').replace("#", "");
|
678 |
-
}
|
679 |
-
|
680 |
-
if (event == false || event.originalEvent === undefined) {
|
681 |
-
//console.log('skip');
|
682 |
-
} else {
|
683 |
-
window.location.hash = id + ':' + eventID;
|
684 |
-
}
|
685 |
-
|
686 |
-
parentShortcode.find('table').hide();
|
687 |
-
|
688 |
-
parentShortcode.find('table[id="#' + eventID + '"]').fadeIn();
|
689 |
-
|
690 |
-
state.setEventsHeight();
|
691 |
-
},
|
692 |
-
/**
|
693 |
-
* Add class if exists events in <TD>
|
694 |
-
*/
|
695 |
-
setClassTd: function() {
|
696 |
-
$.each($('.mptt-event-container'), function() {
|
697 |
-
$(this).parents('td').addClass('event');
|
698 |
-
});
|
699 |
-
},
|
700 |
-
/**
|
701 |
-
* Init TimeTable
|
702 |
-
*/
|
703 |
-
initTableData: function() {
|
704 |
-
state.setClassTd();
|
705 |
-
state.setRowSpanTd();
|
706 |
-
var table_class = '.' + MPTT.table_class;
|
707 |
-
|
708 |
-
if ($(table_class).data('hide_empty_row')) {
|
709 |
-
state.hideEmptyRows();
|
710 |
-
}
|
711 |
-
},
|
712 |
-
/**
|
713 |
-
* init Filters
|
714 |
-
*/
|
715 |
-
filterShortcodeEvents: function() {
|
716 |
-
var selector = $('.mptt-menu');
|
717 |
-
|
718 |
-
if (selector.length) {
|
719 |
-
|
720 |
-
selector.off('change').on('change', function(event) {
|
721 |
-
state.filterStatic($(this), event);
|
722 |
-
state.responsiveFilter($(this));
|
723 |
-
});
|
724 |
-
|
725 |
-
$('.mptt-navigation-tabs.mptt-menu a').off('click').on('click', function(event) {
|
726 |
-
|
727 |
-
var $currentTab = $(this);
|
728 |
-
$currentTab.parents('.mptt-navigation-tabs.mptt-menu').find('li').removeClass('active');
|
729 |
-
|
730 |
-
$currentTab.parents('li').addClass('active');
|
731 |
-
state.filterStatic($currentTab, event);
|
732 |
-
state.responsiveFilter($currentTab);
|
733 |
-
|
734 |
-
});
|
735 |
-
|
736 |
-
}
|
737 |
-
},
|
738 |
-
/**
|
739 |
-
* Show events in shortcode container by current event
|
740 |
-
* @param shortcode_wrapper
|
741 |
-
* @param event
|
742 |
-
*/
|
743 |
-
showCurrentEvent: function(shortcode_wrapper, event) {
|
744 |
-
if (shortcode_wrapper.find('.mptt-menu').hasClass('mptt-navigation-tabs')) {
|
745 |
-
shortcode_wrapper.find('.mptt-navigation-tabs').find('a[href="#' + event + '"]').click();
|
746 |
-
} else if (shortcode_wrapper.find('.mptt-menu').hasClass('mptt-navigation-select')) {
|
747 |
-
if (shortcode_wrapper.find('.mptt-navigation-select option[value="' + event + '"]')) {
|
748 |
-
shortcode_wrapper.find('.mptt-navigation-select').val(event).change();
|
749 |
-
} else {
|
750 |
-
shortcode_wrapper.find('table[id="#all"]').fadeIn();
|
751 |
-
}
|
752 |
-
} else {
|
753 |
-
shortcode_wrapper.find('table[id="#all"]').fadeIn();
|
754 |
-
}
|
755 |
-
},
|
756 |
-
/**
|
757 |
-
* Filter by hash
|
758 |
-
*/
|
759 |
-
getFilterByHash: function() {
|
760 |
-
var is_single = 1;
|
761 |
-
var hash = window.location.hash;
|
762 |
-
|
763 |
-
if (!_.isUndefined(hash)) {
|
764 |
-
var HashArray = hash.split(':');
|
765 |
-
var id = HashArray[0];
|
766 |
-
var event = HashArray[1];
|
767 |
-
var shortcode_wrapper = $('.mptt-shortcode-wrapper');
|
768 |
-
event = _.isUndefined(event) ? 'all' : event;
|
769 |
-
|
770 |
-
if (shortcode_wrapper.length === is_single) {
|
771 |
-
state.showCurrentEvent(shortcode_wrapper, event);
|
772 |
-
} else {
|
773 |
-
|
774 |
-
$.each(shortcode_wrapper, function(index, object) {
|
775 |
-
var element = $(object);
|
776 |
-
var element_id = '#' + element.attr('id');
|
777 |
-
|
778 |
-
if (element_id === id) {
|
779 |
-
state.showCurrentEvent(element, event);
|
780 |
-
} else {
|
781 |
-
state.showCurrentEvent(element, 'all');
|
782 |
-
}
|
783 |
-
});
|
784 |
-
|
785 |
-
}
|
786 |
-
}
|
787 |
-
state.setEventsHeight();
|
788 |
-
},
|
789 |
-
/**
|
790 |
-
* Clear table after change colSpan
|
791 |
-
*
|
792 |
-
* @param columnIndex
|
793 |
-
* @param toColSpan
|
794 |
-
* @param $table
|
795 |
-
* @param row
|
796 |
-
*/
|
797 |
-
removeCellsAfterChangeColSpan: function(columnIndex, toColSpan, $table, row) {
|
798 |
-
for (columnIndex; columnIndex < toColSpan; columnIndex++) {
|
799 |
-
var columnId = $table.find('th[data-index="' + columnIndex + '"]').data('column-id');
|
800 |
-
row.find('td:not(.event)[data-column-id="' + columnId + '"]').remove();
|
801 |
-
}
|
802 |
-
},
|
803 |
-
/**
|
804 |
-
* Set rowSpan
|
805 |
-
* @param td
|
806 |
-
* @param rowSpan
|
807 |
-
* @param $table
|
808 |
-
* @param columnId
|
809 |
-
* @returns rowSpan
|
810 |
-
*/
|
811 |
-
removeCellsAfterChangeRowSpan: function(td, rowSpan, $table, columnId) {
|
812 |
-
var index = td.parents('tr').attr('data-index'),
|
813 |
-
toRowSpan = rowSpan + parseInt(index) - 1,
|
814 |
-
colSpan = td.attr('colspan'),
|
815 |
-
columnIndex = $table.find('th[data-column-id="' + columnId + '"]').data('index'),
|
816 |
-
toColSpan = parseInt(columnIndex) + parseInt(colSpan);
|
817 |
-
|
818 |
-
for (index; index < toRowSpan; index++) {
|
819 |
-
|
820 |
-
var row = $table.find('tr.mptt-shortcode-row-' + (parseInt(index) + 1));
|
821 |
-
|
822 |
-
if (row.length) {
|
823 |
-
|
824 |
-
if (row.find('td.event[data-column-id="' + columnId + '"]').length) {
|
825 |
-
rowSpan -= (toRowSpan - index);
|
826 |
-
|
827 |
-
if (rowSpan < 2) {
|
828 |
-
rowSpan = 1;
|
829 |
-
break;
|
830 |
-
}
|
831 |
-
}
|
832 |
-
|
833 |
-
if (colSpan > 1) {
|
834 |
-
state.removeCellsAfterChangeColSpan(columnIndex, toColSpan, $table, row);
|
835 |
-
}
|
836 |
-
|
837 |
-
row.find('td:not(.event)[data-column-id="' + columnId + '"]').remove();
|
838 |
-
}
|
839 |
-
}
|
840 |
-
return rowSpan;
|
841 |
-
},
|
842 |
-
/**
|
843 |
-
* Set rowSpan td
|
844 |
-
*/
|
845 |
-
setRowSpanTd: function() {
|
846 |
-
var table_class = '.' + MPTT.table_class;
|
847 |
-
$.each($(table_class), function() {
|
848 |
-
var $table = $(this);
|
849 |
-
|
850 |
-
$.each($table.find('td.event'), function() {
|
851 |
-
var td = $(this),
|
852 |
-
events = td.find('.mptt-event-container'),
|
853 |
-
columnId = td.attr('data-column-id'),
|
854 |
-
rowHeight = td.attr('data-row_height'),
|
855 |
-
rowSpan = state.getRowSpan(events, td);
|
856 |
-
|
857 |
-
if (!_.isUndefined(rowSpan) && rowSpan > 1) {
|
858 |
-
|
859 |
-
rowSpan = state.removeCellsAfterChangeRowSpan(td, rowSpan, $table, columnId);
|
860 |
-
|
861 |
-
if (!isNaN(rowHeight)) {
|
862 |
-
td.css('height', rowSpan * rowHeight);
|
863 |
-
}
|
864 |
-
}
|
865 |
-
|
866 |
-
td.attr('rowspan', rowSpan);
|
867 |
-
});
|
868 |
-
});
|
869 |
-
},
|
870 |
-
/**
|
871 |
-
* Remove empty rows
|
872 |
-
*/
|
873 |
-
hideEmptyRows: function() {
|
874 |
-
var table_class = '.' + MPTT.table_class;
|
875 |
-
|
876 |
-
var trs = $(table_class + ' tbody tr'),
|
877 |
-
col_count = $(table_class).first().find('th').length;
|
878 |
-
|
879 |
-
$.each(trs, function(index, value) {
|
880 |
-
// if all columns in the row are empty
|
881 |
-
if ($(value).find('td.event').length === 0 && $(value).find('td').length === col_count) {
|
882 |
-
$(value).remove();
|
883 |
-
}
|
884 |
-
});
|
885 |
-
},
|
886 |
-
/**
|
887 |
-
* Widget settings
|
888 |
-
*/
|
889 |
-
displaySettings: function() {
|
890 |
-
var $viewSettings = $('.view_settings');
|
891 |
-
if ($viewSettings.length) {
|
892 |
-
$viewSettings.change(function() {
|
893 |
-
if ($(this).val() === "all") {
|
894 |
-
var id = $(this).attr('id');
|
895 |
-
$(this).parents('.mptt-container').find('.next-days').css("display", "block");
|
896 |
-
}
|
897 |
-
else {
|
898 |
-
$(this).parents('.mptt-container').find(".next-days").css("display", "none");
|
899 |
-
}
|
900 |
-
});
|
901 |
-
}
|
902 |
-
},
|
903 |
-
/**
|
904 |
-
* Widget time settings
|
905 |
-
* @param selector
|
906 |
-
*/
|
907 |
-
timeMode: function(selector) {
|
908 |
-
if (selector) {
|
909 |
-
var selector_id = "." + $(this).attr('id');
|
910 |
-
$('#' + selector).change(function() {
|
911 |
-
if ($(this).val() === "server") {
|
912 |
-
var id = $(this).attr('id');
|
913 |
-
$(this).parents('.mptt-container').find(selector_id).css("display", "block");
|
914 |
-
}
|
915 |
-
else {
|
916 |
-
$(this).parents('.mptt-container').find(selector_id).css("display", "none");
|
917 |
-
}
|
918 |
-
});
|
919 |
-
}
|
920 |
-
},
|
921 |
-
/**
|
922 |
-
* init DatePicker for column
|
923 |
-
*/
|
924 |
-
initDatePicker: function() {
|
925 |
-
var $date_picker = $("#datepicker");
|
926 |
-
|
927 |
-
if ($date_picker.length) {
|
928 |
-
$date_picker.datepicker({
|
929 |
-
dateFormat: 'd/m/yy',
|
930 |
-
setDate: Date.parse($date_picker.val())
|
931 |
-
});
|
932 |
-
}
|
933 |
-
},
|
934 |
-
/**
|
935 |
-
* init Column radio box change
|
936 |
-
*/
|
937 |
-
columnRadioBox: function() {
|
938 |
-
var $date_picker = $('#datepicker');
|
939 |
-
var $column_option = $('input.option-input[name="column[column_option]"]');
|
940 |
-
var $weekday = $('select.mp-weekday');
|
941 |
-
|
942 |
-
if ($column_option.length) {
|
943 |
-
$column_option.on('change', function() {
|
944 |
-
switch ($(this).val()) {
|
945 |
-
case 'simple':
|
946 |
-
$weekday.prop("disabled", true);
|
947 |
-
$date_picker.prop("disabled", true);
|
948 |
-
break;
|
949 |
-
case 'weekday':
|
950 |
-
$weekday.prop("disabled", false);
|
951 |
-
$date_picker.val('').prop("disabled", true);
|
952 |
-
break;
|
953 |
-
case 'date':
|
954 |
-
$weekday.prop("disabled", true);
|
955 |
-
$date_picker.prop("disabled", false);
|
956 |
-
break;
|
957 |
-
}
|
958 |
-
});
|
959 |
-
}
|
960 |
-
}
|
961 |
-
};
|
962 |
-
}
|
963 |
-
|
964 |
-
return {
|
965 |
-
getInstance: function() {
|
966 |
-
if (!state) {
|
967 |
-
state = createInstance();
|
968 |
-
}
|
969 |
-
return state;
|
970 |
-
}
|
971 |
-
};
|
972 |
})(jQuery));
|
1 |
+
/*global jQuery:false, console:false, _:false, CommonManager:false,Registry:false, wp:false, MPTT:false*/
|
2 |
+
|
3 |
+
Registry.register("Event",
|
4 |
+
(function($) {
|
5 |
+
"use strict";
|
6 |
+
|
7 |
+
var state;
|
8 |
+
|
9 |
+
function createInstance() {
|
10 |
+
|
11 |
+
return {
|
12 |
+
event_id: '',
|
13 |
+
eventsData: {},
|
14 |
+
/**
|
15 |
+
* Init
|
16 |
+
*/
|
17 |
+
init: function() {
|
18 |
+
state.initTimePicker();
|
19 |
+
state.addEventButton();
|
20 |
+
state.initDeleteButtons();
|
21 |
+
state.initEditButtons();
|
22 |
+
state.initColorPicker();
|
23 |
+
state.initDatePicker();
|
24 |
+
state.columnRadioBox();
|
25 |
+
},
|
26 |
+
/**
|
27 |
+
* Init time picker
|
28 |
+
*/
|
29 |
+
initTimePicker: function() {
|
30 |
+
var timeFormat = Boolean(parseInt($('#time_format').val()));
|
31 |
+
$('#event_start').timepicker({
|
32 |
+
showPeriod: timeFormat, // Define whether or not to show AM/PM with selected time. (default: false)
|
33 |
+
showPeriodLabels: timeFormat,
|
34 |
+
defaultTime: '00:00'
|
35 |
+
});
|
36 |
+
|
37 |
+
$('#event_end').timepicker({
|
38 |
+
showPeriod: timeFormat, // Define whether or not to show AM/PM with selected time. (default: false)
|
39 |
+
showPeriodLabels: timeFormat,
|
40 |
+
defaultTime: '00:00'
|
41 |
+
});
|
42 |
+
},
|
43 |
+
/**
|
44 |
+
* Init widget slider
|
45 |
+
* @param selector
|
46 |
+
* @param autoScroll
|
47 |
+
*/
|
48 |
+
initSlider: function(selector, autoScroll) {
|
49 |
+
var play = _.isUndefined(autoScroll) ? false : Boolean(autoScroll);
|
50 |
+
var id = selector.replace(/^\D+/g, '');
|
51 |
+
$(selector).carouFredSel({
|
52 |
+
items: {
|
53 |
+
visible: 3
|
54 |
+
},
|
55 |
+
direction: "up",
|
56 |
+
scroll: {
|
57 |
+
items: 1,
|
58 |
+
easing: "swing",
|
59 |
+
pauseOnHover: true,
|
60 |
+
onAfter: function(data) {
|
61 |
+
data.items.old.each(function() {
|
62 |
+
$(this).removeClass('visible');
|
63 |
+
}
|
64 |
+
);
|
65 |
+
data.items.visible.each(function() {
|
66 |
+
$(this).addClass('visible');
|
67 |
+
}
|
68 |
+
);
|
69 |
+
}
|
70 |
+
},
|
71 |
+
auto: {
|
72 |
+
play: play,
|
73 |
+
timeoutDuration: 3000
|
74 |
+
},
|
75 |
+
prev: {
|
76 |
+
button: "#mp_prev_button" + id
|
77 |
+
},
|
78 |
+
next: {
|
79 |
+
button: "#mp_next_button" + id
|
80 |
+
}
|
81 |
+
});
|
82 |
+
|
83 |
+
$(selector).trigger("currentVisible", function(items) {
|
84 |
+
items.addClass("visible");
|
85 |
+
});
|
86 |
+
state.setColorSettings(selector + ' ' + '.mptt-colorized');
|
87 |
+
},
|
88 |
+
/**
|
89 |
+
* init Delete Button
|
90 |
+
*/
|
91 |
+
initDeleteButton: function() {
|
92 |
+
var $events = $('#events-list');
|
93 |
+
|
94 |
+
$events.find('li.event').find('i.operation-button.dashicons-no.dashicons').off('click').on('click', function() {
|
95 |
+
if ($events.find('li.event').length > 1) {
|
96 |
+
$(this).parents('li.event').remove();
|
97 |
+
} else {
|
98 |
+
$events.remove();
|
99 |
+
}
|
100 |
+
});
|
101 |
+
},
|
102 |
+
/**
|
103 |
+
* Init color picker
|
104 |
+
*/
|
105 |
+
initColorPicker: function(parent) {
|
106 |
+
if (_.isUndefined(parent)) {
|
107 |
+
parent = '';
|
108 |
+
}
|
109 |
+
var selectorColorInput = $(parent + ' input.clr-picker');
|
110 |
+
var selectorTextInput = $(parent + ' input.regular-text');
|
111 |
+
selectorColorInput.spectrum("destroy");
|
112 |
+
|
113 |
+
// init color picker
|
114 |
+
selectorColorInput.spectrum({
|
115 |
+
preferredFormat: "rgb",
|
116 |
+
showInput: true,
|
117 |
+
showAlpha: true,
|
118 |
+
allowEmpty: true,
|
119 |
+
palette: [
|
120 |
+
["#000", "#444", "#666", "#999", "#ccc", "#eee", "#f3f3f3", "#fff"],
|
121 |
+
["#f00", "#f90", "#ff0", "#0f0", "#0ff", "#00f", "#90f", "#f0f"],
|
122 |
+
["#f4cccc", "#fce5cd", "#fff2cc", "#d9ead3", "#d0e0e3", "#cfe2f3", "#d9d2e9", "#ead1dc"],
|
123 |
+
["#ea9999", "#f9cb9c", "#ffe599", "#b6d7a8", "#a2c4c9", "#9fc5e8", "#b4a7d6", "#d5a6bd"],
|
124 |
+
["#e06666", "#f6b26b", "#ffd966", "#93c47d", "#76a5af", "#6fa8dc", "#8e7cc3", "#c27ba0"],
|
125 |
+
["#c00", "#e69138", "#f1c232", "#6aa84f", "#45818e", "#3d85c6", "#674ea7", "#a64d79"],
|
126 |
+
["#900", "#b45f06", "#bf9000", "#38761d", "#134f5c", "#0b5394", "#351c75", "#741b47"],
|
127 |
+
["#600", "#783f04", "#7f6000", "#274e13", "#0c343d", "#073763", "#20124d", "#4c1130"]
|
128 |
+
],
|
129 |
+
showPalette: true,
|
130 |
+
show: function(color) {
|
131 |
+
$(this).val(color);
|
132 |
+
},
|
133 |
+
hide: function(color) {
|
134 |
+
var parent = $(this).parents('.select-color');
|
135 |
+
parent.find('.regular-text').val($(this).val());
|
136 |
+
},
|
137 |
+
change: function(color) {
|
138 |
+
var parent = $(this).parents('.select-color');
|
139 |
+
parent.find('input:not([type="hidden"])').val($(this).val());
|
140 |
+
}
|
141 |
+
});
|
142 |
+
|
143 |
+
//change color preview block
|
144 |
+
selectorTextInput.off('keyup').on('keyup', function() {
|
145 |
+
var parentTr = $(this).parents('.select-color');
|
146 |
+
var spectrumElement = parentTr.find('.clr-picker');
|
147 |
+
var colorElement = parentTr.find(".regular-text").val();
|
148 |
+
var preview_inner = parentTr.find(".sp-preview-inner");
|
149 |
+
preview_inner.css({
|
150 |
+
'background-color': colorElement
|
151 |
+
});
|
152 |
+
spectrumElement.spectrum("set", colorElement);
|
153 |
+
});
|
154 |
+
},
|
155 |
+
/**
|
156 |
+
* Add event
|
157 |
+
*/
|
158 |
+
addEventButton: function() {
|
159 |
+
$(document).on('click.admin', '#add_mp_event', function() {
|
160 |
+
if ($(this).hasClass('edit')) {
|
161 |
+
state.updateEventData();
|
162 |
+
} else {
|
163 |
+
state.renderEventItem();
|
164 |
+
}
|
165 |
+
});
|
166 |
+
},
|
167 |
+
/**
|
168 |
+
* init event data delete button
|
169 |
+
*/
|
170 |
+
initDeleteButtons: function() {
|
171 |
+
$(document).on('click.admin', '#events-list .delete-event-button', function() {
|
172 |
+
var id = $(this).attr('data-id');
|
173 |
+
state.deleteEvent(id);
|
174 |
+
});
|
175 |
+
},
|
176 |
+
/**
|
177 |
+
* init event data edit button
|
178 |
+
*/
|
179 |
+
initEditButtons: function() {
|
180 |
+
$(document).on('click.admin', '#events-list .edit-event-button', function() {
|
181 |
+
var id = $(this).attr('data-id'),
|
182 |
+
$tr = $(this).parent().parent();
|
183 |
+
$(this).parent().find('.spinner').addClass('is-active');
|
184 |
+
|
185 |
+
Registry._get("adminFunctions").wpAjax({
|
186 |
+
controller: "events",
|
187 |
+
action: "get_event_data",
|
188 |
+
id: id
|
189 |
+
},
|
190 |
+
function(data) {
|
191 |
+
var $addMpEvent = $('#add_mp_event');
|
192 |
+
var $events = $('#events-list');
|
193 |
+
$events.find('.spinner').removeClass('is-active');
|
194 |
+
$events.find(' tr').removeClass('active');
|
195 |
+
$tr.addClass('active');
|
196 |
+
|
197 |
+
$('#event_start').val(data.event_start);
|
198 |
+
$('#event_end').val(data.event_end);
|
199 |
+
$('#description').val(data.description);
|
200 |
+
$('#user_id').val(data.user_id);
|
201 |
+
$('#weekday_id').val(data.column_id);
|
202 |
+
|
203 |
+
$addMpEvent.addClass('edit');
|
204 |
+
$addMpEvent.val('Update');
|
205 |
+
|
206 |
+
state.event_id = data.id;
|
207 |
+
},
|
208 |
+
function(data) {
|
209 |
+
console.warn(data);
|
210 |
+
}
|
211 |
+
);
|
212 |
+
});
|
213 |
+
},
|
214 |
+
/**
|
215 |
+
* Delete event data by id
|
216 |
+
*
|
217 |
+
* @param id
|
218 |
+
*/
|
219 |
+
deleteEvent: function(id) {
|
220 |
+
Registry._get("adminFunctions").wpAjax(
|
221 |
+
{
|
222 |
+
controller: "events",
|
223 |
+
action: "delete",
|
224 |
+
id: id
|
225 |
+
},
|
226 |
+
function(data) {
|
227 |
+
var $deleteEvent = $('#events-list').find('tr[data-id="' + id + '"]');
|
228 |
+
if ($deleteEvent.length) {
|
229 |
+
$deleteEvent.remove();
|
230 |
+
}
|
231 |
+
},
|
232 |
+
function(data) {
|
233 |
+
console.log(data);
|
234 |
+
}
|
235 |
+
);
|
236 |
+
},
|
237 |
+
/**
|
238 |
+
* Update event item
|
239 |
+
*/
|
240 |
+
updateEventItem: function() {
|
241 |
+
var item = $('#events-list').find('tr[data-id="' + state.event_id + '"]');
|
242 |
+
var $userId = $('#user_id');
|
243 |
+
|
244 |
+
item.find('td.event-column').text($('#weekday_id').find('option:selected').text());
|
245 |
+
item.find('td.event-start').text($('#event_start').val());
|
246 |
+
item.find('td.event-end').text($('#event_end').val());
|
247 |
+
|
248 |
+
item.find('td.event-user-id').text(( $userId.val() === '-1') ? '' : $userId.find('option:selected').text());
|
249 |
+
item.find('td.event-description').text($('#description').val());
|
250 |
+
|
251 |
+
state.event_id = null;
|
252 |
+
$('#add_mp_event').removeClass('edit').val('Add New');
|
253 |
+
},
|
254 |
+
/**
|
255 |
+
* Update Event data
|
256 |
+
*/
|
257 |
+
updateEventData: function() {
|
258 |
+
var $addEventTable = $('#add_event_table').find('.spinner');
|
259 |
+
|
260 |
+
$addEventTable.addClass('is-active');
|
261 |
+
|
262 |
+
Registry._get("adminFunctions").wpAjax({
|
263 |
+
controller: "events",
|
264 |
+
action: "update_event_data",
|
265 |
+
data: {
|
266 |
+
id: Registry._get("Event").event_id,
|
267 |
+
event_start: $('#event_start').val(),
|
268 |
+
event_end: $('#event_end').val(),
|
269 |
+
description: $('#description').val(),
|
270 |
+
user_id: $('#user_id').val(),
|
271 |
+
weekday_ids: $('#weekday_id').val()
|
272 |
+
}
|
273 |
+
},
|
274 |
+
function() {
|
275 |
+
$addEventTable.removeClass('is-active');
|
276 |
+
state.updateEventItem();
|
277 |
+
state.clearTable();
|
278 |
+
},
|
279 |
+
function(data) {
|
280 |
+
$addEventTable.removeClass('is-active');
|
281 |
+
console.log(data);
|
282 |
+
}
|
283 |
+
);
|
284 |
+
},
|
285 |
+
/**
|
286 |
+
* Render event item
|
287 |
+
*/
|
288 |
+
renderEventItem: function() {
|
289 |
+
var $weekdayId = $('#weekday_id');
|
290 |
+
var $userId = $('#user_id');
|
291 |
+
var column_ID = $weekdayId.find('option:selected').val();
|
292 |
+
var $eventStart = $('#event_start');
|
293 |
+
var $eventEnd = $('#event_end');
|
294 |
+
var $description = $('#description');
|
295 |
+
|
296 |
+
var template = {
|
297 |
+
tag: 'tr',
|
298 |
+
attrs: {},
|
299 |
+
content: [
|
300 |
+
{
|
301 |
+
tag: 'td',
|
302 |
+
attrs: {'style': 'display:none;'},
|
303 |
+
content: [
|
304 |
+
{
|
305 |
+
tag: 'input',
|
306 |
+
attrs: {
|
307 |
+
'type': 'hidden',
|
308 |
+
'name': 'event_data[' + column_ID + '][weekday_ids][]',
|
309 |
+
'value': column_ID
|
310 |
+
}
|
311 |
+
},
|
312 |
+
{
|
313 |
+
tag: 'input',
|
314 |
+
attrs: {
|
315 |
+
'type': 'hidden',
|
316 |
+
'name': 'event_data[' + column_ID + '][event_start][]',
|
317 |
+
'value': $eventStart.val()
|
318 |
+
}
|
319 |
+
},
|
320 |
+
{
|
321 |
+
tag: 'input',
|
322 |
+
attrs: {
|
323 |
+
'type': 'hidden',
|
324 |
+
'name': 'event_data[' + column_ID + '][event_end][]',
|
325 |
+
'value': $eventEnd.val()
|
326 |
+
}
|
327 |
+
},
|
328 |
+
{
|
329 |
+
tag: 'input',
|
330 |
+
attrs: {
|
331 |
+
'type': 'hidden',
|
332 |
+
'name': 'event_data[' + column_ID + '][description][]',
|
333 |
+
'value': $description.val()
|
334 |
+
}
|
335 |
+
},
|
336 |
+
{
|
337 |
+
tag: 'input',
|
338 |
+
attrs: {
|
339 |
+
'type': 'hidden',
|
340 |
+
'name': 'event_data[' + column_ID + '][user_id][]',
|
341 |
+
'value': $userId.val()
|
342 |
+
}
|
343 |
+
}
|
344 |
+
]
|
345 |
+
},
|
346 |
+
{
|
347 |
+
tag: 'td',
|
348 |
+
attrs: {
|
349 |
+
'class': 'event-column'
|
350 |
+
},
|
351 |
+
content: [$weekdayId.find('option:selected').text()]
|
352 |
+
},
|
353 |
+
{
|
354 |
+
tag: 'td',
|
355 |
+
attrs: {
|
356 |
+
'class': 'event-start'
|
357 |
+
},
|
358 |
+
content: [$eventStart.val()]
|
359 |
+
},
|
360 |
+
{
|
361 |
+
tag: 'td',
|
362 |
+
attrs: {
|
363 |
+
'class': 'event-end'
|
364 |
+
},
|
365 |
+
content: [$eventEnd.val()]
|
366 |
+
},
|
367 |
+
{
|
368 |
+
tag: 'td',
|
369 |
+
attrs: {
|
370 |
+
'class': 'event-description'
|
371 |
+
},
|
372 |
+
content: [$description.val()]
|
373 |
+
},
|
374 |
+
{
|
375 |
+
tag: 'td',
|
376 |
+
attrs: {
|
377 |
+
'class': 'event-user-id'
|
378 |
+
},
|
379 |
+
content: [( $userId.val() === '-1') ? '' : $userId.find('option:selected').text()]
|
380 |
+
},
|
381 |
+
{
|
382 |
+
tag: 'td',
|
383 |
+
attrs: {},
|
384 |
+
content: []
|
385 |
+
}
|
386 |
+
]
|
387 |
+
};
|
388 |
+
|
389 |
+
var htmlObject = Registry._get("adminFunctions").getHtml(template);
|
390 |
+
$('#events-list').find('tbody').append(htmlObject);
|
391 |
+
$('.events-list-wrapper').scrollTop(1E10);
|
392 |
+
state.clearTable();
|
393 |
+
},
|
394 |
+
/**
|
395 |
+
* Set event height
|
396 |
+
*
|
397 |
+
* @param element
|
398 |
+
*/
|
399 |
+
setEventHeight: function(element) {
|
400 |
+
var parent_height = element.parent().outerHeight(),
|
401 |
+
body = $('body');
|
402 |
+
|
403 |
+
var elementHeight = element.height();
|
404 |
+
var min_height = element.data('min-height');
|
405 |
+
var inner_height = element.find('.mptt-inner-event-content').height();
|
406 |
+
|
407 |
+
element.css('position', '').css('width', '').css('min-height', '');
|
408 |
+
|
409 |
+
if (!body.hasClass('mprm_ie_browser')) {
|
410 |
+
if (inner_height <= min_height) {
|
411 |
+
element.css('min-height', min_height);
|
412 |
+
} else {
|
413 |
+
element.css('min-height', inner_height);
|
414 |
+
}
|
415 |
+
} else {
|
416 |
+
/** IE block **/
|
417 |
+
inner_height = element.css('height', '').find('.mptt-inner-event-content').height();
|
418 |
+
element.height(elementHeight);
|
419 |
+
|
420 |
+
if (inner_height <= min_height) {
|
421 |
+
element.css('max-height', min_height);
|
422 |
+
} else {
|
423 |
+
element.css('height', '');
|
424 |
+
element.css('max-height', inner_height);
|
425 |
+
}
|
426 |
+
}
|
427 |
+
|
428 |
+
if (parent_height < elementHeight) {
|
429 |
+
element.height(elementHeight);
|
430 |
+
}
|
431 |
+
},
|
432 |
+
/**
|
433 |
+
* Recalculate Height
|
434 |
+
* @param tdParent
|
435 |
+
* @param element
|
436 |
+
*/
|
437 |
+
recalculate_Height: function(tdParent, element) {
|
438 |
+
var events = $('.mptt-event-container', tdParent),
|
439 |
+
eventCount = events.length,
|
440 |
+
heightItem = 0,
|
441 |
+
top = 0,
|
442 |
+
tdHeight = tdParent.height();
|
443 |
+
|
444 |
+
if (!$('body').hasClass('mprm_ie_browser')) {
|
445 |
+
|
446 |
+
heightItem = 100 / ((eventCount > 0) ? eventCount : 1);
|
447 |
+
|
448 |
+
if (!_.isUndefined(element)) {
|
449 |
+
element.height(heightItem + '%');
|
450 |
+
|
451 |
+
} else {
|
452 |
+
|
453 |
+
$.each(events, function() {
|
454 |
+
var $event = $(this);
|
455 |
+
$event.height(heightItem + '%');
|
456 |
+
|
457 |
+
if (_.isEmpty($event.data('min-height'))) {
|
458 |
+
$event.data('min-height', $event.height());
|
459 |
+
}
|
460 |
+
|
461 |
+
$event.css('top', top + '%');
|
462 |
+
$event.removeClass('mptt-hidden');
|
463 |
+
top += heightItem;
|
464 |
+
});
|
465 |
+
}
|
466 |
+
|
467 |
+
} else {
|
468 |
+
|
469 |
+
heightItem = tdHeight / ((eventCount > 0) ? eventCount : 1);
|
470 |
+
|
471 |
+
if (!_.isUndefined(element)) {
|
472 |
+
element.height(heightItem);
|
473 |
+
} else {
|
474 |
+
$.each(events, function() {
|
475 |
+
var $event = $(this);
|
476 |
+
$event.height(heightItem);
|
477 |
+
|
478 |
+
if (_.isEmpty($event.data('min-height'))) {
|
479 |
+
var min_height = $event.height();
|
480 |
+
if (min_height === 0) {
|
481 |
+
$event.data('min-height', heightItem);
|
482 |
+
} else {
|
483 |
+
$event.data('min-height', min_height);
|
484 |
+
}
|
485 |
+
}
|
486 |
+
|
487 |
+
$event.css('top', top + 'px');
|
488 |
+
$event.removeClass('mptt-hidden');
|
489 |
+
top += heightItem;
|
490 |
+
});
|
491 |
+
}
|
492 |
+
}
|
493 |
+
},
|
494 |
+
/**
|
495 |
+
* Fill all possible height in ceil
|
496 |
+
*/
|
497 |
+
setEventsHeight: function() {
|
498 |
+
var events = $('.mptt-shortcode-wrapper').find('table').find('td.event');
|
499 |
+
$.each(events, function() {
|
500 |
+
var td = $(this);
|
501 |
+
state.recalculate_Height(td);
|
502 |
+
});
|
503 |
+
},
|
504 |
+
/**
|
505 |
+
* Set user color settings
|
506 |
+
* @param selector
|
507 |
+
*/
|
508 |
+
setColorSettings: function(selector) {
|
509 |
+
if (_.isUndefined(selector)) {
|
510 |
+
selector = '.mptt-colorized';
|
511 |
+
}
|
512 |
+
|
513 |
+
var elements = $(selector);
|
514 |
+
// var height = '';
|
515 |
+
$.each(elements, function() {
|
516 |
+
var element = $(this),
|
517 |
+
bg = element.attr('data-bg_hover_color'),
|
518 |
+
color = element.attr('data-hover_color'),
|
519 |
+
tdParent = element.parent();
|
520 |
+
// parentHeight = tdParent.height(),
|
521 |
+
// elementHeight = '';
|
522 |
+
|
523 |
+
switch (element.attr('data-type')) {
|
524 |
+
case "column":
|
525 |
+
case "event":
|
526 |
+
element.hover(
|
527 |
+
function() {
|
528 |
+
if (!_.isEmpty(bg)) {
|
529 |
+
element.css('background-color', bg);
|
530 |
+
}
|
531 |
+
if (!_.isEmpty(color)) {
|
532 |
+
element.css('color', color);
|
533 |
+
}
|
534 |
+
|
535 |
+
state.setEventHeight(element);
|
536 |
+
|
537 |
+
}, function() {
|
538 |
+
element.css('max-height', '').css('min-height', '');
|
539 |
+
state.recalculate_Height(tdParent, element);
|
540 |
+
|
541 |
+
element.css('background-color', element.attr('data-bg_color'));
|
542 |
+
element.css('color', element.attr('data-color'));
|
543 |
+
}
|
544 |
+
);
|
545 |
+
break;
|
546 |
+
case "widget":
|
547 |
+
element.hover(
|
548 |
+
function() {
|
549 |
+
element.css('background-color', element.attr('data-background-hover-color'));
|
550 |
+
element.css('color', $(this).attr('data-hover-color'));
|
551 |
+
element.css('border-left-color', element.attr('data-hover-border-color'));
|
552 |
+
},
|
553 |
+
function() {
|
554 |
+
element.css('background-color', element.attr('data-background-color'));
|
555 |
+
element.css('color', element.attr('data-color'));
|
556 |
+
element.css('border-left-color', element.attr('data-border-color'));
|
557 |
+
}
|
558 |
+
);
|
559 |
+
break;
|
560 |
+
default:
|
561 |
+
break;
|
562 |
+
}
|
563 |
+
});
|
564 |
+
},
|
565 |
+
/**
|
566 |
+
* Clear input data
|
567 |
+
*/
|
568 |
+
clearTable: function() {
|
569 |
+
var $weekdayId = $("#weekday_id");
|
570 |
+
$('#add_event_table input:not(.button),#add_event_table textarea').val('');
|
571 |
+
$weekdayId.val($weekdayId.find('option:first').attr('value'));
|
572 |
+
},
|
573 |
+
/**
|
574 |
+
* get Row span
|
575 |
+
*
|
576 |
+
* @param events
|
577 |
+
* @returns {number}
|
578 |
+
*/
|
579 |
+
getRowSpan: function(events, td) {
|
580 |
+
var arrMax = [];
|
581 |
+
var arrMin = [];
|
582 |
+
var columnId = td.attr('data-column-id');
|
583 |
+
|
584 |
+
/*
|
585 |
+
* Erroneous Positioning of Events
|
586 |
+
* https://wordpress.org/support/topic/erroneous-positioning-of-events/
|
587 |
+
*/
|
588 |
+
var nextTr = td.closest('tr').next('tr');
|
589 |
+
var nextTd = nextTr.find('td[data-column-id="' + columnId + '"]');
|
590 |
+
var nextTdSet = (nextTr.length > 0) && (nextTd.length > 0) && (nextTd.children().length > 0);
|
591 |
+
|
592 |
+
while ( !nextTdSet ) {
|
593 |
+
if( nextTr.next('tr').length == 0 ){
|
594 |
+
nextTdSet = true;
|
595 |
+
nextTr = false;
|
596 |
+
break;
|
597 |
+
}
|
598 |
+
|
599 |
+
nextTr = nextTr.next('tr');
|
600 |
+
nextTd = nextTr.find('td[data-column-id="' + columnId + '"]');
|
601 |
+
nextTdSet = nextTd.children().length > 0;
|
602 |
+
}
|
603 |
+
|
604 |
+
var nextEventIndex = false
|
605 |
+
if (nextTr) {
|
606 |
+
nextEventIndex = nextTr.data('index');
|
607 |
+
}
|
608 |
+
//console.log(td, nextEventIndex)
|
609 |
+
|
610 |
+
/* End of "Erroneous Positioning of Events" */
|
611 |
+
|
612 |
+
$.each(events, function(index) {
|
613 |
+
var start = $(this).attr('data-start');
|
614 |
+
var end = $(this).attr('data-end');
|
615 |
+
|
616 |
+
arrMin[index] = start;
|
617 |
+
arrMax[index] = end;
|
618 |
+
});
|
619 |
+
|
620 |
+
var min = Math.min.apply(Math, arrMin);
|
621 |
+
var max = Math.max.apply(Math, arrMax);
|
622 |
+
|
623 |
+
if ( nextEventIndex && max > nextEventIndex ) {
|
624 |
+
max = nextEventIndex;
|
625 |
+
}
|
626 |
+
|
627 |
+
var rowSpan = (max - min);
|
628 |
+
|
629 |
+
return rowSpan < 1 ? 1 : rowSpan;
|
630 |
+
},
|
631 |
+
/**
|
632 |
+
* Responsive filter
|
633 |
+
*
|
634 |
+
* @param element
|
635 |
+
*/
|
636 |
+
responsiveFilter: function(element) {
|
637 |
+
var eventID = 'all';
|
638 |
+
var parentShortcode = element.parents('.mptt-shortcode-wrapper');
|
639 |
+
|
640 |
+
if (element.is("select")) {
|
641 |
+
eventID = element.val();
|
642 |
+
} else {
|
643 |
+
eventID = element.attr('href').replace("#", "");
|
644 |
+
}
|
645 |
+
|
646 |
+
var $listEvent = parentShortcode.find('.mptt-list-event');
|
647 |
+
|
648 |
+
if (eventID !== 'all') {
|
649 |
+
$listEvent.hide();
|
650 |
+
parentShortcode.find('.mptt-list-event[data-event-id="' + eventID + '"]').show();
|
651 |
+
} else {
|
652 |
+
$listEvent.show();
|
653 |
+
}
|
654 |
+
|
655 |
+
$.each(parentShortcode.find('.mptt-column'), function() {
|
656 |
+
$(this).show();
|
657 |
+
if ($(this).find('.mptt-list-event:visible').length < 1) {
|
658 |
+
$(this).hide();
|
659 |
+
}
|
660 |
+
});
|
661 |
+
|
662 |
+
},
|
663 |
+
/**
|
664 |
+
* Filter static version
|
665 |
+
*
|
666 |
+
* @param element
|
667 |
+
*/
|
668 |
+
filterStatic: function(element, event) {
|
669 |
+
|
670 |
+
var parentShortcode = element.parents('.mptt-shortcode-wrapper');
|
671 |
+
var eventID = '#all';
|
672 |
+
var id = _.isEmpty(parentShortcode.attr('id')) ? 'not-set' : parentShortcode.attr('id');
|
673 |
+
|
674 |
+
if (element.is("select")) {
|
675 |
+
eventID = element.val();
|
676 |
+
} else {
|
677 |
+
eventID = element.attr('href').replace("#", "");
|
678 |
+
}
|
679 |
+
|
680 |
+
if (event == false || event.originalEvent === undefined) {
|
681 |
+
//console.log('skip');
|
682 |
+
} else {
|
683 |
+
window.location.hash = id + ':' + eventID;
|
684 |
+
}
|
685 |
+
|
686 |
+
parentShortcode.find('table').hide();
|
687 |
+
|
688 |
+
parentShortcode.find('table[id="#' + eventID + '"]').fadeIn();
|
689 |
+
|
690 |
+
state.setEventsHeight();
|
691 |
+
},
|
692 |
+
/**
|
693 |
+
* Add class if exists events in <TD>
|
694 |
+
*/
|
695 |
+
setClassTd: function() {
|
696 |
+
$.each($('.mptt-event-container'), function() {
|
697 |
+
$(this).parents('td').addClass('event');
|
698 |
+
});
|
699 |
+
},
|
700 |
+
/**
|
701 |
+
* Init TimeTable
|
702 |
+
*/
|
703 |
+
initTableData: function() {
|
704 |
+
state.setClassTd();
|
705 |
+
state.setRowSpanTd();
|
706 |
+
var table_class = '.' + MPTT.table_class;
|
707 |
+
|
708 |
+
if ($(table_class).data('hide_empty_row')) {
|
709 |
+
state.hideEmptyRows();
|
710 |
+
}
|
711 |
+
},
|
712 |
+
/**
|
713 |
+
* init Filters
|
714 |
+
*/
|
715 |
+
filterShortcodeEvents: function() {
|
716 |
+
var selector = $('.mptt-menu');
|
717 |
+
|
718 |
+
if (selector.length) {
|
719 |
+
|
720 |
+
selector.off('change').on('change', function(event) {
|
721 |
+
state.filterStatic($(this), event);
|
722 |
+
state.responsiveFilter($(this));
|
723 |
+
});
|
724 |
+
|
725 |
+
$('.mptt-navigation-tabs.mptt-menu a').off('click').on('click', function(event) {
|
726 |
+
|
727 |
+
var $currentTab = $(this);
|
728 |
+
$currentTab.parents('.mptt-navigation-tabs.mptt-menu').find('li').removeClass('active');
|
729 |
+
|
730 |
+
$currentTab.parents('li').addClass('active');
|
731 |
+
state.filterStatic($currentTab, event);
|
732 |
+
state.responsiveFilter($currentTab);
|
733 |
+
|
734 |
+
});
|
735 |
+
|
736 |
+
}
|
737 |
+
},
|
738 |
+
/**
|
739 |
+
* Show events in shortcode container by current event
|
740 |
+
* @param shortcode_wrapper
|
741 |
+
* @param event
|
742 |
+
*/
|
743 |
+
showCurrentEvent: function(shortcode_wrapper, event) {
|
744 |
+
if (shortcode_wrapper.find('.mptt-menu').hasClass('mptt-navigation-tabs')) {
|
745 |
+
shortcode_wrapper.find('.mptt-navigation-tabs').find('a[href="#' + event + '"]').click();
|
746 |
+
} else if (shortcode_wrapper.find('.mptt-menu').hasClass('mptt-navigation-select')) {
|
747 |
+
if (shortcode_wrapper.find('.mptt-navigation-select option[value="' + event + '"]')) {
|
748 |
+
shortcode_wrapper.find('.mptt-navigation-select').val(event).change();
|
749 |
+
} else {
|
750 |
+
shortcode_wrapper.find('table[id="#all"]').fadeIn();
|
751 |
+
}
|
752 |
+
} else {
|
753 |
+
shortcode_wrapper.find('table[id="#all"]').fadeIn();
|
754 |
+
}
|
755 |
+
},
|
756 |
+
/**
|
757 |
+
* Filter by hash
|
758 |
+
*/
|
759 |
+
getFilterByHash: function() {
|
760 |
+
var is_single = 1;
|
761 |
+
var hash = window.location.hash;
|
762 |
+
|
763 |
+
if (!_.isUndefined(hash)) {
|
764 |
+
var HashArray = hash.split(':');
|
765 |
+
var id = HashArray[0];
|
766 |
+
var event = HashArray[1];
|
767 |
+
var shortcode_wrapper = $('.mptt-shortcode-wrapper');
|
768 |
+
event = _.isUndefined(event) ? 'all' : event;
|
769 |
+
|
770 |
+
if (shortcode_wrapper.length === is_single) {
|
771 |
+
state.showCurrentEvent(shortcode_wrapper, event);
|
772 |
+
} else {
|
773 |
+
|
774 |
+
$.each(shortcode_wrapper, function(index, object) {
|
775 |
+
var element = $(object);
|
776 |
+
var element_id = '#' + element.attr('id');
|
777 |
+
|
778 |
+
if (element_id === id) {
|
779 |
+
state.showCurrentEvent(element, event);
|
780 |
+
} else {
|
781 |
+
state.showCurrentEvent(element, 'all');
|
782 |
+
}
|
783 |
+
});
|
784 |
+
|
785 |
+
}
|
786 |
+
}
|
787 |
+
state.setEventsHeight();
|
788 |
+
},
|
789 |
+
/**
|
790 |
+
* Clear table after change colSpan
|
791 |
+
*
|
792 |
+
* @param columnIndex
|
793 |
+
* @param toColSpan
|
794 |
+
* @param $table
|
795 |
+
* @param row
|
796 |
+
*/
|
797 |
+
removeCellsAfterChangeColSpan: function(columnIndex, toColSpan, $table, row) {
|
798 |
+
for (columnIndex; columnIndex < toColSpan; columnIndex++) {
|
799 |
+
var columnId = $table.find('th[data-index="' + columnIndex + '"]').data('column-id');
|
800 |
+
row.find('td:not(.event)[data-column-id="' + columnId + '"]').remove();
|
801 |
+
}
|
802 |
+
},
|
803 |
+
/**
|
804 |
+
* Set rowSpan
|
805 |
+
* @param td
|
806 |
+
* @param rowSpan
|
807 |
+
* @param $table
|
808 |
+
* @param columnId
|
809 |
+
* @returns rowSpan
|
810 |
+
*/
|
811 |
+
removeCellsAfterChangeRowSpan: function(td, rowSpan, $table, columnId) {
|
812 |
+
var index = td.parents('tr').attr('data-index'),
|
813 |
+
toRowSpan = rowSpan + parseInt(index) - 1,
|
814 |
+
colSpan = td.attr('colspan'),
|
815 |
+
columnIndex = $table.find('th[data-column-id="' + columnId + '"]').data('index'),
|
816 |
+
toColSpan = parseInt(columnIndex) + parseInt(colSpan);
|
817 |
+
|
818 |
+
for (index; index < toRowSpan; index++) {
|
819 |
+
|
820 |
+
var row = $table.find('tr.mptt-shortcode-row-' + (parseInt(index) + 1));
|
821 |
+
|
822 |
+
if (row.length) {
|
823 |
+
|
824 |
+
if (row.find('td.event[data-column-id="' + columnId + '"]').length) {
|
825 |
+
rowSpan -= (toRowSpan - index);
|
826 |
+
|
827 |
+
if (rowSpan < 2) {
|
828 |
+
rowSpan = 1;
|
829 |
+
break;
|
830 |
+
}
|
831 |
+
}
|
832 |
+
|
833 |
+
if (colSpan > 1) {
|
834 |
+
state.removeCellsAfterChangeColSpan(columnIndex, toColSpan, $table, row);
|
835 |
+
}
|
836 |
+
|
837 |
+
row.find('td:not(.event)[data-column-id="' + columnId + '"]').remove();
|
838 |
+
}
|
839 |
+
}
|
840 |
+
return rowSpan;
|
841 |
+
},
|
842 |
+
/**
|
843 |
+
* Set rowSpan td
|
844 |
+
*/
|
845 |
+
setRowSpanTd: function() {
|
846 |
+
var table_class = '.' + MPTT.table_class;
|
847 |
+
$.each($(table_class), function() {
|
848 |
+
var $table = $(this);
|
849 |
+
|
850 |
+
$.each($table.find('td.event'), function() {
|
851 |
+
var td = $(this),
|
852 |
+
events = td.find('.mptt-event-container'),
|
853 |
+
columnId = td.attr('data-column-id'),
|
854 |
+
rowHeight = td.attr('data-row_height'),
|
855 |
+
rowSpan = state.getRowSpan(events, td);
|
856 |
+
|
857 |
+
if (!_.isUndefined(rowSpan) && rowSpan > 1) {
|
858 |
+
|
859 |
+
rowSpan = state.removeCellsAfterChangeRowSpan(td, rowSpan, $table, columnId);
|
860 |
+
|
861 |
+
if (!isNaN(rowHeight)) {
|
862 |
+
td.css('height', rowSpan * rowHeight);
|
863 |
+
}
|
864 |
+
}
|
865 |
+
|
866 |
+
td.attr('rowspan', rowSpan);
|
867 |
+
});
|
868 |
+
});
|
869 |
+
},
|
870 |
+
/**
|
871 |
+
* Remove empty rows
|
872 |
+
*/
|
873 |
+
hideEmptyRows: function() {
|
874 |
+
var table_class = '.' + MPTT.table_class;
|
875 |
+
|
876 |
+
var trs = $(table_class + ' tbody tr'),
|
877 |
+
col_count = $(table_class).first().find('th').length;
|
878 |
+
|
879 |
+
$.each(trs, function(index, value) {
|
880 |
+
// if all columns in the row are empty
|
881 |
+
if ($(value).find('td.event').length === 0 && $(value).find('td').length === col_count) {
|
882 |
+
$(value).remove();
|
883 |
+
}
|
884 |
+
});
|
885 |
+
},
|
886 |
+
/**
|
887 |
+
* Widget settings
|
888 |
+
*/
|
889 |
+
displaySettings: function() {
|
890 |
+
var $viewSettings = $('.view_settings');
|
891 |
+
if ($viewSettings.length) {
|
892 |
+
$viewSettings.change(function() {
|
893 |
+
if ($(this).val() === "all") {
|
894 |
+
var id = $(this).attr('id');
|
895 |
+
$(this).parents('.mptt-container').find('.next-days').css("display", "block");
|
896 |
+
}
|
897 |
+
else {
|
898 |
+
$(this).parents('.mptt-container').find(".next-days").css("display", "none");
|
899 |
+
}
|
900 |
+
});
|
901 |
+
}
|
902 |
+
},
|
903 |
+
/**
|
904 |
+
* Widget time settings
|
905 |
+
* @param selector
|
906 |
+
*/
|
907 |
+
timeMode: function(selector) {
|
908 |
+
if (selector) {
|
909 |
+
var selector_id = "." + $(this).attr('id');
|
910 |
+
$('#' + selector).change(function() {
|
911 |
+
if ($(this).val() === "server") {
|
912 |
+
var id = $(this).attr('id');
|
913 |
+
$(this).parents('.mptt-container').find(selector_id).css("display", "block");
|
914 |
+
}
|
915 |
+
else {
|
916 |
+
$(this).parents('.mptt-container').find(selector_id).css("display", "none");
|
917 |
+
}
|
918 |
+
});
|
919 |
+
}
|
920 |
+
},
|
921 |
+
/**
|
922 |
+
* init DatePicker for column
|
923 |
+
*/
|
924 |
+
initDatePicker: function() {
|
925 |
+
var $date_picker = $("#datepicker");
|
926 |
+
|
927 |
+
if ($date_picker.length) {
|
928 |
+
$date_picker.datepicker({
|
929 |
+
dateFormat: 'd/m/yy',
|
930 |
+
setDate: Date.parse($date_picker.val())
|
931 |
+
});
|
932 |
+
}
|
933 |
+
},
|
934 |
+
/**
|
935 |
+
* init Column radio box change
|
936 |
+
*/
|
937 |
+
columnRadioBox: function() {
|
938 |
+
var $date_picker = $('#datepicker');
|
939 |
+
var $column_option = $('input.option-input[name="column[column_option]"]');
|
940 |
+
var $weekday = $('select.mp-weekday');
|
941 |
+
|
942 |
+
if ($column_option.length) {
|
943 |
+
$column_option.on('change', function() {
|
944 |
+
switch ($(this).val()) {
|
945 |
+
case 'simple':
|
946 |
+
$weekday.prop("disabled", true);
|
947 |
+
$date_picker.prop("disabled", true);
|
948 |
+
break;
|
949 |
+
case 'weekday':
|
950 |
+
$weekday.prop("disabled", false);
|
951 |
+
$date_picker.val('').prop("disabled", true);
|
952 |
+
break;
|
953 |
+
case 'date':
|
954 |
+
$weekday.prop("disabled", true);
|
955 |
+
$date_picker.prop("disabled", false);
|
956 |
+
break;
|
957 |
+
}
|
958 |
+
});
|
959 |
+
}
|
960 |
+
}
|
961 |
+
};
|
962 |
+
}
|
963 |
+
|
964 |
+
return {
|
965 |
+
getInstance: function() {
|
966 |
+
if (!state) {
|
967 |
+
state = createInstance();
|
968 |
+
}
|
969 |
+
return state;
|
970 |
+
}
|
971 |
+
};
|
972 |
})(jQuery));
|
media/js/events/event.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
window.wp=window.wp||{},window.wp["./media/js/events/event.min.js"]=function(t){var e={};function n(i){if(e[i])return e[i].exports;var a=e[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(i,a,function(e){return t[e]}.bind(null,a));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=4)}({4:function(t,e){Registry.register("Event",function(t){"use strict";var e;return{getInstance:function(){return e||(e={event_id:"",eventsData:{},init:function(){e.initTimePicker(),e.addEventButton(),e.initDeleteButtons(),e.initEditButtons(),e.initColorPicker(),e.initDatePicker(),e.columnRadioBox()},initTimePicker:function(){var e=Boolean(parseInt(t("#time_format").val()));t("#event_start").timepicker({showPeriod:e,showPeriodLabels:e,defaultTime:"00:00"}),t("#event_end").timepicker({showPeriod:e,showPeriodLabels:e,defaultTime:"00:00"})},initSlider:function(n,i){var a=!_.isUndefined(i)&&Boolean(i),r=n.replace(/^\D+/g,"");t(n).carouFredSel({items:{visible:3},direction:"up",scroll:{items:1,easing:"swing",pauseOnHover:!0,onAfter:function(e){e.items.old.each((function(){t(this).removeClass("visible")})),e.items.visible.each((function(){t(this).addClass("visible")}))}},auto:{play:a,timeoutDuration:3e3},prev:{button:"#mp_prev_button"+r},next:{button:"#mp_next_button"+r}}),t(n).trigger("currentVisible",(function(t){t.addClass("visible")})),e.setColorSettings(n+" .mptt-colorized")},initDeleteButton:function(){var e=t("#events-list");e.find("li.event").find("i.operation-button.dashicons-no.dashicons").off("click").on("click",(function(){e.find("li.event").length>1?t(this).parents("li.event").remove():e.remove()}))},initColorPicker:function(e){_.isUndefined(e)&&(e="");var n=t(e+" input.clr-picker"),i=t(e+" input.regular-text");n.spectrum("destroy"),n.spectrum({preferredFormat:"rgb",showInput:!0,showAlpha:!0,allowEmpty:!0,palette:[["#000","#444","#666","#999","#ccc","#eee","#f3f3f3","#fff"],["#f00","#f90","#ff0","#0f0","#0ff","#00f","#90f","#f0f"],["#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#cfe2f3","#d9d2e9","#ead1dc"],["#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#9fc5e8","#b4a7d6","#d5a6bd"],["#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6fa8dc","#8e7cc3","#c27ba0"],["#c00","#e69138","#f1c232","#6aa84f","#45818e","#3d85c6","#674ea7","#a64d79"],["#900","#b45f06","#bf9000","#38761d","#134f5c","#0b5394","#351c75","#741b47"],["#600","#783f04","#7f6000","#274e13","#0c343d","#073763","#20124d","#4c1130"]],showPalette:!0,show:function(e){t(this).val(e)},hide:function(e){t(this).parents(".select-color").find(".regular-text").val(t(this).val())},change:function(e){t(this).parents(".select-color").find('input:not([type="hidden"])').val(t(this).val())}}),i.off("keyup").on("keyup",(function(){var e=t(this).parents(".select-color"),n=e.find(".clr-picker"),i=e.find(".regular-text").val();e.find(".sp-preview-inner").css({"background-color":i}),n.spectrum("set",i)}))},addEventButton:function(){t(document).on("click.admin","#add_mp_event",(function(){t(this).hasClass("edit")?e.updateEventData():e.renderEventItem()}))},initDeleteButtons:function(){t(document).on("click.admin","#events-list .delete-event-button",(function(){var n=t(this).attr("data-id");e.deleteEvent(n)}))},initEditButtons:function(){t(document).on("click.admin","#events-list .edit-event-button",(function(){var n=t(this).attr("data-id"),i=t(this).parent().parent();t(this).parent().find(".spinner").addClass("is-active"),Registry._get("adminFunctions").wpAjax({controller:"events",action:"get_event_data",id:n},(function(n){var a=t("#add_mp_event"),r=t("#events-list");r.find(".spinner").removeClass("is-active"),r.find(" tr").removeClass("active"),i.addClass("active"),t("#event_start").val(n.event_start),t("#event_end").val(n.event_end),t("#description").val(n.description),t("#user_id").val(n.user_id),t("#weekday_id").val(n.column_id),a.addClass("edit"),a.val("Update"),e.event_id=n.id}),(function(t){console.warn(t)}))}))},deleteEvent:function(e){Registry._get("adminFunctions").wpAjax({controller:"events",action:"delete",id:e},(function(n){var i=t("#events-list").find('tr[data-id="'+e+'"]');i.length&&i.remove()}),(function(t){console.log(t)}))},updateEventItem:function(){var n=t("#events-list").find('tr[data-id="'+e.event_id+'"]'),i=t("#user_id");n.find("td.event-column").text(t("#weekday_id").find("option:selected").text()),n.find("td.event-start").text(t("#event_start").val()),n.find("td.event-end").text(t("#event_end").val()),n.find("td.event-user-id").text("-1"===i.val()?"":i.find("option:selected").text()),n.find("td.event-description").text(t("#description").val()),e.event_id=null,t("#add_mp_event").removeClass("edit").val("Add New")},updateEventData:function(){var n=t("#add_event_table").find(".spinner");n.addClass("is-active"),Registry._get("adminFunctions").wpAjax({controller:"events",action:"update_event_data",data:{id:Registry._get("Event").event_id,event_start:t("#event_start").val(),event_end:t("#event_end").val(),description:t("#description").val(),user_id:t("#user_id").val(),weekday_ids:t("#weekday_id").val()}},(function(){n.removeClass("is-active"),e.updateEventItem(),e.clearTable()}),(function(t){n.removeClass("is-active"),console.log(t)}))},renderEventItem:function(){var n=t("#weekday_id"),i=t("#user_id"),a=n.find("option:selected").val(),r=t("#event_start"),s=t("#event_end"),o=t("#description"),d={tag:"tr",attrs:{},content:[{tag:"td",attrs:{style:"display:none;"},content:[{tag:"input",attrs:{type:"hidden",name:"event_data["+a+"][weekday_ids][]",value:a}},{tag:"input",attrs:{type:"hidden",name:"event_data["+a+"][event_start][]",value:r.val()}},{tag:"input",attrs:{type:"hidden",name:"event_data["+a+"][event_end][]",value:s.val()}},{tag:"input",attrs:{type:"hidden",name:"event_data["+a+"][description][]",value:o.val()}},{tag:"input",attrs:{type:"hidden",name:"event_data["+a+"][user_id][]",value:i.val()}}]},{tag:"td",attrs:{class:"event-column"},content:[n.find("option:selected").text()]},{tag:"td",attrs:{class:"event-start"},content:[r.val()]},{tag:"td",attrs:{class:"event-end"},content:[s.val()]},{tag:"td",attrs:{class:"event-description"},content:[o.val()]},{tag:"td",attrs:{class:"event-user-id"},content:["-1"===i.val()?"":i.find("option:selected").text()]},{tag:"td",attrs:{},content:[]}]},c=Registry._get("adminFunctions").getHtml(d);t("#events-list").find("tbody").append(c),t(".events-list-wrapper").scrollTop(1e10),e.clearTable()},setEventHeight:function(e){var n=e.parent().outerHeight(),i=t("body"),a=e.height(),r=e.data("min-height"),s=e.find(".mptt-inner-event-content").height();e.css("position","").css("width","").css("min-height",""),i.hasClass("mprm_ie_browser")?(s=e.css("height","").find(".mptt-inner-event-content").height(),e.height(a),s<=r?e.css("max-height",r):(e.css("height",""),e.css("max-height",s))):s<=r?e.css("min-height",r):e.css("min-height",s),n<a&&e.height(a)},recalculate_Height:function(e,n){var i=t(".mptt-event-container",e),a=i.length,r=0,s=0,o=e.height();t("body").hasClass("mprm_ie_browser")?(r=o/(a>0?a:1),_.isUndefined(n)?t.each(i,(function(){var e=t(this);if(e.height(r),_.isEmpty(e.data("min-height"))){var n=e.height();0===n?e.data("min-height",r):e.data("min-height",n)}e.css("top",s+"px"),e.removeClass("mptt-hidden"),s+=r})):n.height(r)):(r=100/(a>0?a:1),_.isUndefined(n)?t.each(i,(function(){var e=t(this);e.height(r+"%"),_.isEmpty(e.data("min-height"))&&e.data("min-height",e.height()),e.css("top",s+"%"),e.removeClass("mptt-hidden"),s+=r})):n.height(r+"%"))},setEventsHeight:function(){var n=t(".mptt-shortcode-wrapper").find("table").find("td.event");t.each(n,(function(){var n=t(this);e.recalculate_Height(n)}))},setColorSettings:function(n){_.isUndefined(n)&&(n=".mptt-colorized");var i=t(n);t.each(i,(function(){var n=t(this),i=n.attr("data-bg_hover_color"),a=n.attr("data-hover_color"),r=n.parent();switch(n.attr("data-type")){case"column":case"event":n.hover((function(){_.isEmpty(i)||n.css("background-color",i),_.isEmpty(a)||n.css("color",a),e.setEventHeight(n)}),(function(){n.css("max-height","").css("min-height",""),e.recalculate_Height(r,n),n.css("background-color",n.attr("data-bg_color")),n.css("color",n.attr("data-color"))}));break;case"widget":n.hover((function(){n.css("background-color",n.attr("data-background-hover-color")),n.css("color",t(this).attr("data-hover-color")),n.css("border-left-color",n.attr("data-hover-border-color"))}),(function(){n.css("background-color",n.attr("data-background-color")),n.css("color",n.attr("data-color")),n.css("border-left-color",n.attr("data-border-color"))}))}}))},clearTable:function(){var e=t("#weekday_id");t("#add_event_table input:not(.button),#add_event_table textarea").val(""),e.val(e.find("option:first").attr("value"))},getRowSpan:function(e,n){for(var i=[],a=[],r=n.attr("data-column-id"),s=n.closest("tr").next("tr"),o=s.find('td[data-column-id="'+r+'"]'),d=s.length>0&&o.length>0&&o.children().length>0;!d;){if(0==s.next("tr").length){d=!0,s=!1;break}d=(o=(s=s.next("tr")).find('td[data-column-id="'+r+'"]')).children().length>0}var c=!1;s&&(c=s.data("index")),t.each(e,(function(e){var n=t(this).attr("data-start"),r=t(this).attr("data-end");a[e]=n,i[e]=r}));var l=Math.min.apply(Math,a),v=Math.max.apply(Math,i);c&&v>c&&(v=c);var f=v-l;return f<1?1:f},responsiveFilter:function(e){var n="all",i=e.parents(".mptt-shortcode-wrapper");n=e.is("select")?e.val():e.attr("href").replace("#","");var a=i.find(".mptt-list-event");"all"!==n?(a.hide(),i.find('.mptt-list-event[data-event-id="'+n+'"]').show()):a.show(),t.each(i.find(".mptt-column"),(function(){t(this).show(),t(this).find(".mptt-list-event:visible").length<1&&t(this).hide()}))},filterStatic:function(t,n){var i=t.parents(".mptt-shortcode-wrapper"),a="#all",r=_.isEmpty(i.attr("id"))?"not-set":i.attr("id");a=t.is("select")?t.val():t.attr("href").replace("#",""),0==n||void 0===n.originalEvent||(window.location.hash=r+":"+a),i.find("table").hide(),i.find('table[id="#'+a+'"]').fadeIn(),e.setEventsHeight()},setClassTd:function(){t.each(t(".mptt-event-container"),(function(){t(this).parents("td").addClass("event")}))},initTableData:function(){e.setClassTd(),e.setRowSpanTd();var n="."+MPTT.table_class;t(n).data("hide_empty_row")&&e.hideEmptyRows()},filterShortcodeEvents:function(){var n=t(".mptt-menu");n.length&&(n.off("change").on("change",(function(n){e.filterStatic(t(this),n),e.responsiveFilter(t(this))})),t(".mptt-navigation-tabs.mptt-menu a").off("click").on("click",(function(n){var i=t(this);i.parents(".mptt-navigation-tabs.mptt-menu").find("li").removeClass("active"),i.parents("li").addClass("active"),e.filterStatic(i,n),e.responsiveFilter(i)})))},showCurrentEvent:function(t,e){t.find(".mptt-menu").hasClass("mptt-navigation-tabs")?t.find(".mptt-navigation-tabs").find('a[href="#'+e+'"]').click():t.find(".mptt-menu").hasClass("mptt-navigation-select")&&t.find('.mptt-navigation-select option[value="'+e+'"]')?t.find(".mptt-navigation-select").val(e).change():t.find('table[id="#all"]').fadeIn()},getFilterByHash:function(){var n=window.location.hash;if(!_.isUndefined(n)){var i=n.split(":"),a=i[0],r=i[1],s=t(".mptt-shortcode-wrapper");r=_.isUndefined(r)?"all":r,1===s.length?e.showCurrentEvent(s,r):t.each(s,(function(n,i){var s=t(i);"#"+s.attr("id")===a?e.showCurrentEvent(s,r):e.showCurrentEvent(s,"all")}))}e.setEventsHeight()},removeCellsAfterChangeColSpan:function(t,e,n,i){for(;t<e;t++){var a=n.find('th[data-index="'+t+'"]').data("column-id");i.find('td:not(.event)[data-column-id="'+a+'"]').remove()}},removeCellsAfterChangeRowSpan:function(t,n,i,a){for(var r=t.parents("tr").attr("data-index"),s=n+parseInt(r)-1,o=t.attr("colspan"),d=i.find('th[data-column-id="'+a+'"]').data("index"),c=parseInt(d)+parseInt(o);r<s;r++){var l=i.find("tr.mptt-shortcode-row-"+(parseInt(r)+1));if(l.length){if(l.find('td.event[data-column-id="'+a+'"]').length&&(n-=s-r)<2){n=1;break}o>1&&e.removeCellsAfterChangeColSpan(d,c,i,l),l.find('td:not(.event)[data-column-id="'+a+'"]').remove()}}return n},setRowSpanTd:function(){var n="."+MPTT.table_class;t.each(t(n),(function(){var n=t(this);t.each(n.find("td.event"),(function(){var i=t(this),a=i.find(".mptt-event-container"),r=i.attr("data-column-id"),s=i.attr("data-row_height"),o=e.getRowSpan(a,i);!_.isUndefined(o)&&o>1&&(o=e.removeCellsAfterChangeRowSpan(i,o,n,r),isNaN(s)||i.css("height",o*s)),i.attr("rowspan",o)}))}))},hideEmptyRows:function(){var e="."+MPTT.table_class,n=t(e+" tbody tr"),i=t(e).first().find("th").length;t.each(n,(function(e,n){0===t(n).find("td.event").length&&t(n).find("td").length===i&&t(n).remove()}))},displaySettings:function(){var e=t(".view_settings");e.length&&e.change((function(){"all"===t(this).val()?(t(this).attr("id"),t(this).parents(".mptt-container").find(".next-days").css("display","block")):t(this).parents(".mptt-container").find(".next-days").css("display","none")}))},timeMode:function(e){if(e){var n="."+t(this).attr("id");t("#"+e).change((function(){"server"===t(this).val()?(t(this).attr("id"),t(this).parents(".mptt-container").find(n).css("display","block")):t(this).parents(".mptt-container").find(n).css("display","none")}))}},initDatePicker:function(){var e=t("#datepicker");e.length&&e.datepicker({dateFormat:"d/m/yy",setDate:Date.parse(e.val())})},columnRadioBox:function(){var e=t("#datepicker"),n=t('input.option-input[name="column[column_option]"]'),i=t("select.mp-weekday");n.length&&n.on("change",(function(){switch(t(this).val()){case"simple":i.prop("disabled",!0),e.prop("disabled",!0);break;case"weekday":i.prop("disabled",!1),e.val("").prop("disabled",!0);break;case"date":i.prop("disabled",!0),e.prop("disabled",!1)}}))}}),e}}}(jQuery))}});
|
1 |
+
window.wp=window.wp||{},window.wp["./media/js/events/event.min.js"]=function(t){var e={};function n(i){if(e[i])return e[i].exports;var a=e[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)n.d(i,a,function(e){return t[e]}.bind(null,a));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=5)}({5:function(t,e){Registry.register("Event",function(t){"use strict";var e;return{getInstance:function(){return e||(e={event_id:"",eventsData:{},init:function(){e.initTimePicker(),e.addEventButton(),e.initDeleteButtons(),e.initEditButtons(),e.initColorPicker(),e.initDatePicker(),e.columnRadioBox()},initTimePicker:function(){var e=Boolean(parseInt(t("#time_format").val()));t("#event_start").timepicker({showPeriod:e,showPeriodLabels:e,defaultTime:"00:00"}),t("#event_end").timepicker({showPeriod:e,showPeriodLabels:e,defaultTime:"00:00"})},initSlider:function(n,i){var a=!_.isUndefined(i)&&Boolean(i),r=n.replace(/^\D+/g,"");t(n).carouFredSel({items:{visible:3},direction:"up",scroll:{items:1,easing:"swing",pauseOnHover:!0,onAfter:function(e){e.items.old.each((function(){t(this).removeClass("visible")})),e.items.visible.each((function(){t(this).addClass("visible")}))}},auto:{play:a,timeoutDuration:3e3},prev:{button:"#mp_prev_button"+r},next:{button:"#mp_next_button"+r}}),t(n).trigger("currentVisible",(function(t){t.addClass("visible")})),e.setColorSettings(n+" .mptt-colorized")},initDeleteButton:function(){var e=t("#events-list");e.find("li.event").find("i.operation-button.dashicons-no.dashicons").off("click").on("click",(function(){e.find("li.event").length>1?t(this).parents("li.event").remove():e.remove()}))},initColorPicker:function(e){_.isUndefined(e)&&(e="");var n=t(e+" input.clr-picker"),i=t(e+" input.regular-text");n.spectrum("destroy"),n.spectrum({preferredFormat:"rgb",showInput:!0,showAlpha:!0,allowEmpty:!0,palette:[["#000","#444","#666","#999","#ccc","#eee","#f3f3f3","#fff"],["#f00","#f90","#ff0","#0f0","#0ff","#00f","#90f","#f0f"],["#f4cccc","#fce5cd","#fff2cc","#d9ead3","#d0e0e3","#cfe2f3","#d9d2e9","#ead1dc"],["#ea9999","#f9cb9c","#ffe599","#b6d7a8","#a2c4c9","#9fc5e8","#b4a7d6","#d5a6bd"],["#e06666","#f6b26b","#ffd966","#93c47d","#76a5af","#6fa8dc","#8e7cc3","#c27ba0"],["#c00","#e69138","#f1c232","#6aa84f","#45818e","#3d85c6","#674ea7","#a64d79"],["#900","#b45f06","#bf9000","#38761d","#134f5c","#0b5394","#351c75","#741b47"],["#600","#783f04","#7f6000","#274e13","#0c343d","#073763","#20124d","#4c1130"]],showPalette:!0,show:function(e){t(this).val(e)},hide:function(e){t(this).parents(".select-color").find(".regular-text").val(t(this).val())},change:function(e){t(this).parents(".select-color").find('input:not([type="hidden"])').val(t(this).val())}}),i.off("keyup").on("keyup",(function(){var e=t(this).parents(".select-color"),n=e.find(".clr-picker"),i=e.find(".regular-text").val();e.find(".sp-preview-inner").css({"background-color":i}),n.spectrum("set",i)}))},addEventButton:function(){t(document).on("click.admin","#add_mp_event",(function(){t(this).hasClass("edit")?e.updateEventData():e.renderEventItem()}))},initDeleteButtons:function(){t(document).on("click.admin","#events-list .delete-event-button",(function(){var n=t(this).attr("data-id");e.deleteEvent(n)}))},initEditButtons:function(){t(document).on("click.admin","#events-list .edit-event-button",(function(){var n=t(this).attr("data-id"),i=t(this).parent().parent();t(this).parent().find(".spinner").addClass("is-active"),Registry._get("adminFunctions").wpAjax({controller:"events",action:"get_event_data",id:n},(function(n){var a=t("#add_mp_event"),r=t("#events-list");r.find(".spinner").removeClass("is-active"),r.find(" tr").removeClass("active"),i.addClass("active"),t("#event_start").val(n.event_start),t("#event_end").val(n.event_end),t("#description").val(n.description),t("#user_id").val(n.user_id),t("#weekday_id").val(n.column_id),a.addClass("edit"),a.val("Update"),e.event_id=n.id}),(function(t){console.warn(t)}))}))},deleteEvent:function(e){Registry._get("adminFunctions").wpAjax({controller:"events",action:"delete",id:e},(function(n){var i=t("#events-list").find('tr[data-id="'+e+'"]');i.length&&i.remove()}),(function(t){console.log(t)}))},updateEventItem:function(){var n=t("#events-list").find('tr[data-id="'+e.event_id+'"]'),i=t("#user_id");n.find("td.event-column").text(t("#weekday_id").find("option:selected").text()),n.find("td.event-start").text(t("#event_start").val()),n.find("td.event-end").text(t("#event_end").val()),n.find("td.event-user-id").text("-1"===i.val()?"":i.find("option:selected").text()),n.find("td.event-description").text(t("#description").val()),e.event_id=null,t("#add_mp_event").removeClass("edit").val("Add New")},updateEventData:function(){var n=t("#add_event_table").find(".spinner");n.addClass("is-active"),Registry._get("adminFunctions").wpAjax({controller:"events",action:"update_event_data",data:{id:Registry._get("Event").event_id,event_start:t("#event_start").val(),event_end:t("#event_end").val(),description:t("#description").val(),user_id:t("#user_id").val(),weekday_ids:t("#weekday_id").val()}},(function(){n.removeClass("is-active"),e.updateEventItem(),e.clearTable()}),(function(t){n.removeClass("is-active"),console.log(t)}))},renderEventItem:function(){var n=t("#weekday_id"),i=t("#user_id"),a=n.find("option:selected").val(),r=t("#event_start"),s=t("#event_end"),o=t("#description"),d={tag:"tr",attrs:{},content:[{tag:"td",attrs:{style:"display:none;"},content:[{tag:"input",attrs:{type:"hidden",name:"event_data["+a+"][weekday_ids][]",value:a}},{tag:"input",attrs:{type:"hidden",name:"event_data["+a+"][event_start][]",value:r.val()}},{tag:"input",attrs:{type:"hidden",name:"event_data["+a+"][event_end][]",value:s.val()}},{tag:"input",attrs:{type:"hidden",name:"event_data["+a+"][description][]",value:o.val()}},{tag:"input",attrs:{type:"hidden",name:"event_data["+a+"][user_id][]",value:i.val()}}]},{tag:"td",attrs:{class:"event-column"},content:[n.find("option:selected").text()]},{tag:"td",attrs:{class:"event-start"},content:[r.val()]},{tag:"td",attrs:{class:"event-end"},content:[s.val()]},{tag:"td",attrs:{class:"event-description"},content:[o.val()]},{tag:"td",attrs:{class:"event-user-id"},content:["-1"===i.val()?"":i.find("option:selected").text()]},{tag:"td",attrs:{},content:[]}]},c=Registry._get("adminFunctions").getHtml(d);t("#events-list").find("tbody").append(c),t(".events-list-wrapper").scrollTop(1e10),e.clearTable()},setEventHeight:function(e){var n=e.parent().outerHeight(),i=t("body"),a=e.height(),r=e.data("min-height"),s=e.find(".mptt-inner-event-content").height();e.css("position","").css("width","").css("min-height",""),i.hasClass("mprm_ie_browser")?(s=e.css("height","").find(".mptt-inner-event-content").height(),e.height(a),s<=r?e.css("max-height",r):(e.css("height",""),e.css("max-height",s))):s<=r?e.css("min-height",r):e.css("min-height",s),n<a&&e.height(a)},recalculate_Height:function(e,n){var i=t(".mptt-event-container",e),a=i.length,r=0,s=0,o=e.height();t("body").hasClass("mprm_ie_browser")?(r=o/(a>0?a:1),_.isUndefined(n)?t.each(i,(function(){var e=t(this);if(e.height(r),_.isEmpty(e.data("min-height"))){var n=e.height();0===n?e.data("min-height",r):e.data("min-height",n)}e.css("top",s+"px"),e.removeClass("mptt-hidden"),s+=r})):n.height(r)):(r=100/(a>0?a:1),_.isUndefined(n)?t.each(i,(function(){var e=t(this);e.height(r+"%"),_.isEmpty(e.data("min-height"))&&e.data("min-height",e.height()),e.css("top",s+"%"),e.removeClass("mptt-hidden"),s+=r})):n.height(r+"%"))},setEventsHeight:function(){var n=t(".mptt-shortcode-wrapper").find("table").find("td.event");t.each(n,(function(){var n=t(this);e.recalculate_Height(n)}))},setColorSettings:function(n){_.isUndefined(n)&&(n=".mptt-colorized");var i=t(n);t.each(i,(function(){var n=t(this),i=n.attr("data-bg_hover_color"),a=n.attr("data-hover_color"),r=n.parent();switch(n.attr("data-type")){case"column":case"event":n.hover((function(){_.isEmpty(i)||n.css("background-color",i),_.isEmpty(a)||n.css("color",a),e.setEventHeight(n)}),(function(){n.css("max-height","").css("min-height",""),e.recalculate_Height(r,n),n.css("background-color",n.attr("data-bg_color")),n.css("color",n.attr("data-color"))}));break;case"widget":n.hover((function(){n.css("background-color",n.attr("data-background-hover-color")),n.css("color",t(this).attr("data-hover-color")),n.css("border-left-color",n.attr("data-hover-border-color"))}),(function(){n.css("background-color",n.attr("data-background-color")),n.css("color",n.attr("data-color")),n.css("border-left-color",n.attr("data-border-color"))}))}}))},clearTable:function(){var e=t("#weekday_id");t("#add_event_table input:not(.button),#add_event_table textarea").val(""),e.val(e.find("option:first").attr("value"))},getRowSpan:function(e,n){for(var i=[],a=[],r=n.attr("data-column-id"),s=n.closest("tr").next("tr"),o=s.find('td[data-column-id="'+r+'"]'),d=s.length>0&&o.length>0&&o.children().length>0;!d;){if(0==s.next("tr").length){d=!0,s=!1;break}d=(o=(s=s.next("tr")).find('td[data-column-id="'+r+'"]')).children().length>0}var c=!1;s&&(c=s.data("index")),t.each(e,(function(e){var n=t(this).attr("data-start"),r=t(this).attr("data-end");a[e]=n,i[e]=r}));var l=Math.min.apply(Math,a),v=Math.max.apply(Math,i);c&&v>c&&(v=c);var f=v-l;return f<1?1:f},responsiveFilter:function(e){var n="all",i=e.parents(".mptt-shortcode-wrapper");n=e.is("select")?e.val():e.attr("href").replace("#","");var a=i.find(".mptt-list-event");"all"!==n?(a.hide(),i.find('.mptt-list-event[data-event-id="'+n+'"]').show()):a.show(),t.each(i.find(".mptt-column"),(function(){t(this).show(),t(this).find(".mptt-list-event:visible").length<1&&t(this).hide()}))},filterStatic:function(t,n){var i=t.parents(".mptt-shortcode-wrapper"),a="#all",r=_.isEmpty(i.attr("id"))?"not-set":i.attr("id");a=t.is("select")?t.val():t.attr("href").replace("#",""),0==n||void 0===n.originalEvent||(window.location.hash=r+":"+a),i.find("table").hide(),i.find('table[id="#'+a+'"]').fadeIn(),e.setEventsHeight()},setClassTd:function(){t.each(t(".mptt-event-container"),(function(){t(this).parents("td").addClass("event")}))},initTableData:function(){e.setClassTd(),e.setRowSpanTd();var n="."+MPTT.table_class;t(n).data("hide_empty_row")&&e.hideEmptyRows()},filterShortcodeEvents:function(){var n=t(".mptt-menu");n.length&&(n.off("change").on("change",(function(n){e.filterStatic(t(this),n),e.responsiveFilter(t(this))})),t(".mptt-navigation-tabs.mptt-menu a").off("click").on("click",(function(n){var i=t(this);i.parents(".mptt-navigation-tabs.mptt-menu").find("li").removeClass("active"),i.parents("li").addClass("active"),e.filterStatic(i,n),e.responsiveFilter(i)})))},showCurrentEvent:function(t,e){t.find(".mptt-menu").hasClass("mptt-navigation-tabs")?t.find(".mptt-navigation-tabs").find('a[href="#'+e+'"]').click():t.find(".mptt-menu").hasClass("mptt-navigation-select")&&t.find('.mptt-navigation-select option[value="'+e+'"]')?t.find(".mptt-navigation-select").val(e).change():t.find('table[id="#all"]').fadeIn()},getFilterByHash:function(){var n=window.location.hash;if(!_.isUndefined(n)){var i=n.split(":"),a=i[0],r=i[1],s=t(".mptt-shortcode-wrapper");r=_.isUndefined(r)?"all":r,1===s.length?e.showCurrentEvent(s,r):t.each(s,(function(n,i){var s=t(i);"#"+s.attr("id")===a?e.showCurrentEvent(s,r):e.showCurrentEvent(s,"all")}))}e.setEventsHeight()},removeCellsAfterChangeColSpan:function(t,e,n,i){for(;t<e;t++){var a=n.find('th[data-index="'+t+'"]').data("column-id");i.find('td:not(.event)[data-column-id="'+a+'"]').remove()}},removeCellsAfterChangeRowSpan:function(t,n,i,a){for(var r=t.parents("tr").attr("data-index"),s=n+parseInt(r)-1,o=t.attr("colspan"),d=i.find('th[data-column-id="'+a+'"]').data("index"),c=parseInt(d)+parseInt(o);r<s;r++){var l=i.find("tr.mptt-shortcode-row-"+(parseInt(r)+1));if(l.length){if(l.find('td.event[data-column-id="'+a+'"]').length&&(n-=s-r)<2){n=1;break}o>1&&e.removeCellsAfterChangeColSpan(d,c,i,l),l.find('td:not(.event)[data-column-id="'+a+'"]').remove()}}return n},setRowSpanTd:function(){var n="."+MPTT.table_class;t.each(t(n),(function(){var n=t(this);t.each(n.find("td.event"),(function(){var i=t(this),a=i.find(".mptt-event-container"),r=i.attr("data-column-id"),s=i.attr("data-row_height"),o=e.getRowSpan(a,i);!_.isUndefined(o)&&o>1&&(o=e.removeCellsAfterChangeRowSpan(i,o,n,r),isNaN(s)||i.css("height",o*s)),i.attr("rowspan",o)}))}))},hideEmptyRows:function(){var e="."+MPTT.table_class,n=t(e+" tbody tr"),i=t(e).first().find("th").length;t.each(n,(function(e,n){0===t(n).find("td.event").length&&t(n).find("td").length===i&&t(n).remove()}))},displaySettings:function(){var e=t(".view_settings");e.length&&e.change((function(){"all"===t(this).val()?(t(this).attr("id"),t(this).parents(".mptt-container").find(".next-days").css("display","block")):t(this).parents(".mptt-container").find(".next-days").css("display","none")}))},timeMode:function(e){if(e){var n="."+t(this).attr("id");t("#"+e).change((function(){"server"===t(this).val()?(t(this).attr("id"),t(this).parents(".mptt-container").find(n).css("display","block")):t(this).parents(".mptt-container").find(n).css("display","none")}))}},initDatePicker:function(){var e=t("#datepicker");e.length&&e.datepicker({dateFormat:"d/m/yy",setDate:Date.parse(e.val())})},columnRadioBox:function(){var e=t("#datepicker"),n=t('input.option-input[name="column[column_option]"]'),i=t("select.mp-weekday");n.length&&n.on("change",(function(){switch(t(this).val()){case"simple":i.prop("disabled",!0),e.prop("disabled",!0);break;case"weekday":i.prop("disabled",!1),e.val("").prop("disabled",!0);break;case"date":i.prop("disabled",!0),e.prop("disabled",!1)}}))}}),e}}}(jQuery))}});
|
media/js/mce-timeTable-buttons.js
CHANGED
@@ -1,142 +1,142 @@
|
|
1 |
-
/*global tinymce:false, wp:false, console: false, md5:false, jBox:false, _:false, CommonManager:false, PopupEvents:false,Registry:false*/
|
2 |
-
(function($) {
|
3 |
-
"use strict";
|
4 |
-
|
5 |
-
tinymce.PluginManager.add('mp_timetable', function(editor, url) {
|
6 |
-
editor.addButton('addTimeTableButton', {
|
7 |
-
title: 'TimeTable',
|
8 |
-
icon: false,
|
9 |
-
//text: 'Add Time Table',
|
10 |
-
image: url + '/../img/shortcode-icon.png',
|
11 |
-
onclick: function() {
|
12 |
-
|
13 |
-
Registry._get("adminFunctions").callModal("", function(container) {
|
14 |
-
//callback open
|
15 |
-
var jbox = this;
|
16 |
-
|
17 |
-
Registry._get("adminFunctions").wpAjax(
|
18 |
-
{
|
19 |
-
controller: "popup",
|
20 |
-
action: "get_popup_html_content"
|
21 |
-
},
|
22 |
-
function(data) {
|
23 |
-
jbox.setContent(data.html);
|
24 |
-
//click on insert button
|
25 |
-
Registry._get("adminFunctions").initJBox(jbox, container, function(item) {
|
26 |
-
|
27 |
-
var shortcode_obj = {
|
28 |
-
tag: 'mp-timetable',
|
29 |
-
attrs: {},
|
30 |
-
type: "single"
|
31 |
-
};
|
32 |
-
|
33 |
-
$.each(item, function(index, parameters) {
|
34 |
-
switch (parameters.name) {
|
35 |
-
case 'event':
|
36 |
-
if (shortcode_obj.attrs.events === '' || typeof shortcode_obj.attrs.events === 'undefined') {
|
37 |
-
shortcode_obj.attrs.events = parameters.value;
|
38 |
-
} else {
|
39 |
-
shortcode_obj.attrs.events += ',' + parameters.value;
|
40 |
-
}
|
41 |
-
break;
|
42 |
-
case 'event_category':
|
43 |
-
if (shortcode_obj.attrs.event_categ === '' || typeof shortcode_obj.attrs.event_categ === 'undefined') {
|
44 |
-
shortcode_obj.attrs.event_categ = parameters.value;
|
45 |
-
} else {
|
46 |
-
shortcode_obj.attrs.event_categ += ',' + parameters.value;
|
47 |
-
}
|
48 |
-
break;
|
49 |
-
case 'weekday':
|
50 |
-
if (shortcode_obj.attrs.col === '' || typeof shortcode_obj.attrs.col === 'undefined') {
|
51 |
-
shortcode_obj.attrs.col = parameters.value;
|
52 |
-
} else {
|
53 |
-
shortcode_obj.attrs.col += ',' + parameters.value;
|
54 |
-
}
|
55 |
-
break;
|
56 |
-
case 'measure':
|
57 |
-
shortcode_obj.attrs.increment = parameters.value;
|
58 |
-
break;
|
59 |
-
case 'filter_style':
|
60 |
-
shortcode_obj.attrs.view = parameters.value;
|
61 |
-
break;
|
62 |
-
case 'filter_style_sort':
|
63 |
-
shortcode_obj.attrs.view_sort = parameters.value;
|
64 |
-
break;
|
65 |
-
case 'filter_label':
|
66 |
-
shortcode_obj.attrs.label = parameters.value;
|
67 |
-
break;
|
68 |
-
case 'hide_all_events_view':
|
69 |
-
shortcode_obj.attrs.hide_label = parameters.value;
|
70 |
-
break;
|
71 |
-
case 'hide_hours_column':
|
72 |
-
shortcode_obj.attrs.hide_hrs = parameters.value;
|
73 |
-
break;
|
74 |
-
case 'group_events':
|
75 |
-
shortcode_obj.attrs.group = parameters.value;
|
76 |
-
break;
|
77 |
-
case 'hide_empty':
|
78 |
-
shortcode_obj.attrs.hide_empty_rows = parameters.value;
|
79 |
-
break;
|
80 |
-
case 'title':
|
81 |
-
shortcode_obj.attrs.title = parameters.value;
|
82 |
-
break;
|
83 |
-
case 'time':
|
84 |
-
shortcode_obj.attrs.time = parameters.value;
|
85 |
-
break;
|
86 |
-
case 'sub-title':
|
87 |
-
shortcode_obj.attrs['sub-title'] = parameters.value;
|
88 |
-
break;
|
89 |
-
case 'description':
|
90 |
-
shortcode_obj.attrs.description = parameters.value;
|
91 |
-
break;
|
92 |
-
case 'user':
|
93 |
-
shortcode_obj.attrs.user = parameters.value;
|
94 |
-
break;
|
95 |
-
case 'disable_event_url':
|
96 |
-
shortcode_obj.attrs.disable_event_url = parameters.value;
|
97 |
-
break;
|
98 |
-
case 'text_align':
|
99 |
-
shortcode_obj.attrs.text_align = parameters.value;
|
100 |
-
break;
|
101 |
-
case 'text_align_vertical':
|
102 |
-
shortcode_obj.attrs.text_align_vertical = parameters.value;
|
103 |
-
break;
|
104 |
-
case 'id':
|
105 |
-
shortcode_obj.attrs.id = parameters.value;
|
106 |
-
break;
|
107 |
-
case 'custom_class':
|
108 |
-
shortcode_obj.attrs.custom_class = parameters.value;
|
109 |
-
break;
|
110 |
-
case 'row_height':
|
111 |
-
shortcode_obj.attrs.row_height = parameters.value;
|
112 |
-
break;
|
113 |
-
case 'font_size':
|
114 |
-
shortcode_obj.attrs.font_size = parameters.value;
|
115 |
-
break;
|
116 |
-
case 'responsive':
|
117 |
-
shortcode_obj.attrs.responsive = parameters.value;
|
118 |
-
break;
|
119 |
-
case 'table_layout':
|
120 |
-
shortcode_obj.attrs.table_layout = parameters.value;
|
121 |
-
break;
|
122 |
-
}
|
123 |
-
});
|
124 |
-
|
125 |
-
var shortcode = wp.shortcode.string(shortcode_obj);
|
126 |
-
|
127 |
-
editor.insertContent(shortcode);
|
128 |
-
|
129 |
-
jbox.close();
|
130 |
-
|
131 |
-
});
|
132 |
-
},
|
133 |
-
function(data) {
|
134 |
-
console.warn(data);
|
135 |
-
}
|
136 |
-
);
|
137 |
-
}
|
138 |
-
);
|
139 |
-
}
|
140 |
-
});
|
141 |
-
});
|
142 |
})(window.jQuery);
|
1 |
+
/*global tinymce:false, wp:false, console: false, md5:false, jBox:false, _:false, CommonManager:false, PopupEvents:false,Registry:false*/
|
2 |
+
(function($) {
|
3 |
+
"use strict";
|
4 |
+
|
5 |
+
tinymce.PluginManager.add('mp_timetable', function(editor, url) {
|
6 |
+
editor.addButton('addTimeTableButton', {
|
7 |
+
title: 'TimeTable',
|
8 |
+
icon: false,
|
9 |
+
//text: 'Add Time Table',
|
10 |
+
image: url + '/../img/shortcode-icon.png',
|
11 |
+
onclick: function() {
|
12 |
+
|
13 |
+
Registry._get("adminFunctions").callModal("", function(container) {
|
14 |
+
//callback open
|
15 |
+
var jbox = this;
|
16 |
+
|
17 |
+
Registry._get("adminFunctions").wpAjax(
|
18 |
+
{
|
19 |
+
controller: "popup",
|
20 |
+
action: "get_popup_html_content"
|
21 |
+
},
|
22 |
+
function(data) {
|
23 |
+
jbox.setContent(data.html);
|
24 |
+
//click on insert button
|
25 |
+
Registry._get("adminFunctions").initJBox(jbox, container, function(item) {
|
26 |
+
|
27 |
+
var shortcode_obj = {
|
28 |
+
tag: 'mp-timetable',
|
29 |
+
attrs: {},
|
30 |
+
type: "single"
|
31 |
+
};
|
32 |
+
|
33 |
+
$.each(item, function(index, parameters) {
|
34 |
+
switch (parameters.name) {
|
35 |
+
case 'event':
|
36 |
+
if (shortcode_obj.attrs.events === '' || typeof shortcode_obj.attrs.events === 'undefined') {
|
37 |
+
shortcode_obj.attrs.events = parameters.value;
|
38 |
+
} else {
|
39 |
+
shortcode_obj.attrs.events += ',' + parameters.value;
|
40 |
+
}
|
41 |
+
break;
|
42 |
+
case 'event_category':
|
43 |
+
if (shortcode_obj.attrs.event_categ === '' || typeof shortcode_obj.attrs.event_categ === 'undefined') {
|
44 |
+
shortcode_obj.attrs.event_categ = parameters.value;
|
45 |
+
} else {
|
46 |
+
shortcode_obj.attrs.event_categ += ',' + parameters.value;
|
47 |
+
}
|
48 |
+
break;
|
49 |
+
case 'weekday':
|
50 |
+
if (shortcode_obj.attrs.col === '' || typeof shortcode_obj.attrs.col === 'undefined') {
|
51 |
+
shortcode_obj.attrs.col = parameters.value;
|
52 |
+
} else {
|
53 |
+
shortcode_obj.attrs.col += ',' + parameters.value;
|
54 |
+
}
|
55 |
+
break;
|
56 |
+
case 'measure':
|
57 |
+
shortcode_obj.attrs.increment = parameters.value;
|
58 |
+
break;
|
59 |
+
case 'filter_style':
|
60 |
+
shortcode_obj.attrs.view = parameters.value;
|
61 |
+
break;
|
62 |
+
case 'filter_style_sort':
|
63 |
+
shortcode_obj.attrs.view_sort = parameters.value;
|
64 |
+
break;
|
65 |
+
case 'filter_label':
|
66 |
+
shortcode_obj.attrs.label = parameters.value;
|
67 |
+
break;
|
68 |
+
case 'hide_all_events_view':
|
69 |
+
shortcode_obj.attrs.hide_label = parameters.value;
|
70 |
+
break;
|
71 |
+
case 'hide_hours_column':
|
72 |
+
shortcode_obj.attrs.hide_hrs = parameters.value;
|
73 |
+
break;
|
74 |
+
case 'group_events':
|
75 |
+
shortcode_obj.attrs.group = parameters.value;
|
76 |
+
break;
|
77 |
+
case 'hide_empty':
|
78 |
+
shortcode_obj.attrs.hide_empty_rows = parameters.value;
|
79 |
+
break;
|
80 |
+
case 'title':
|
81 |
+
shortcode_obj.attrs.title = parameters.value;
|
82 |
+
break;
|
83 |
+
case 'time':
|
84 |
+
shortcode_obj.attrs.time = parameters.value;
|
85 |
+
break;
|
86 |
+
case 'sub-title':
|
87 |
+
shortcode_obj.attrs['sub-title'] = parameters.value;
|
88 |
+
break;
|
89 |
+
case 'description':
|
90 |
+
shortcode_obj.attrs.description = parameters.value;
|
91 |
+
break;
|
92 |
+
case 'user':
|
93 |
+
shortcode_obj.attrs.user = parameters.value;
|
94 |
+
break;
|
95 |
+
case 'disable_event_url':
|
96 |
+
shortcode_obj.attrs.disable_event_url = parameters.value;
|
97 |
+
break;
|
98 |
+
case 'text_align':
|
99 |
+
shortcode_obj.attrs.text_align = parameters.value;
|
100 |
+
break;
|
101 |
+
case 'text_align_vertical':
|
102 |
+
shortcode_obj.attrs.text_align_vertical = parameters.value;
|
103 |
+
break;
|
104 |
+
case 'id':
|
105 |
+
shortcode_obj.attrs.id = parameters.value;
|
106 |
+
break;
|
107 |
+
case 'custom_class':
|
108 |
+
shortcode_obj.attrs.custom_class = parameters.value;
|
109 |
+
break;
|
110 |
+
case 'row_height':
|
111 |
+
shortcode_obj.attrs.row_height = parameters.value;
|
112 |
+
break;
|
113 |
+
case 'font_size':
|
114 |
+
shortcode_obj.attrs.font_size = parameters.value;
|
115 |
+
break;
|
116 |
+
case 'responsive':
|
117 |
+
shortcode_obj.attrs.responsive = parameters.value;
|
118 |
+
break;
|
119 |
+
case 'table_layout':
|
120 |
+
shortcode_obj.attrs.table_layout = parameters.value;
|
121 |
+
break;
|
122 |
+
}
|
123 |
+
});
|
124 |
+
|
125 |
+
var shortcode = wp.shortcode.string(shortcode_obj);
|
126 |
+
|
127 |
+
editor.insertContent(shortcode);
|
128 |
+
|
129 |
+
jbox.close();
|
130 |
+
|
131 |
+
});
|
132 |
+
},
|
133 |
+
function(data) {
|
134 |
+
console.warn(data);
|
135 |
+
}
|
136 |
+
);
|
137 |
+
}
|
138 |
+
);
|
139 |
+
}
|
140 |
+
});
|
141 |
+
});
|
142 |
})(window.jQuery);
|
media/js/mce-timeTable-buttons.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
window.wp=window.wp||{},window.wp["./media/js/mce-timeTable-buttons.min.js"]=function(e){var t={};function a(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,a),n.l=!0,n.exports}return a.m=e,a.c=t,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)a.d(r,n,function(t){return e[t]}.bind(null,n));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=
|
1 |
+
window.wp=window.wp||{},window.wp["./media/js/mce-timeTable-buttons.min.js"]=function(e){var t={};function a(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,a),n.l=!0,n.exports}return a.m=e,a.c=t,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)a.d(r,n,function(t){return e[t]}.bind(null,n));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=4)}({4:function(e,t){!function(e){"use strict";tinymce.PluginManager.add("mp_timetable",(function(t,a){t.addButton("addTimeTableButton",{title:"TimeTable",icon:!1,image:a+"/../img/shortcode-icon.png",onclick:function(){Registry._get("adminFunctions").callModal("",(function(a){var r=this;Registry._get("adminFunctions").wpAjax({controller:"popup",action:"get_popup_html_content"},(function(n){r.setContent(n.html),Registry._get("adminFunctions").initJBox(r,a,(function(a){var n={tag:"mp-timetable",attrs:{},type:"single"};e.each(a,(function(e,t){switch(t.name){case"event":""===n.attrs.events||void 0===n.attrs.events?n.attrs.events=t.value:n.attrs.events+=","+t.value;break;case"event_category":""===n.attrs.event_categ||void 0===n.attrs.event_categ?n.attrs.event_categ=t.value:n.attrs.event_categ+=","+t.value;break;case"weekday":""===n.attrs.col||void 0===n.attrs.col?n.attrs.col=t.value:n.attrs.col+=","+t.value;break;case"measure":n.attrs.increment=t.value;break;case"filter_style":n.attrs.view=t.value;break;case"filter_style_sort":n.attrs.view_sort=t.value;break;case"filter_label":n.attrs.label=t.value;break;case"hide_all_events_view":n.attrs.hide_label=t.value;break;case"hide_hours_column":n.attrs.hide_hrs=t.value;break;case"group_events":n.attrs.group=t.value;break;case"hide_empty":n.attrs.hide_empty_rows=t.value;break;case"title":n.attrs.title=t.value;break;case"time":n.attrs.time=t.value;break;case"sub-title":n.attrs["sub-title"]=t.value;break;case"description":n.attrs.description=t.value;break;case"user":n.attrs.user=t.value;break;case"disable_event_url":n.attrs.disable_event_url=t.value;break;case"text_align":n.attrs.text_align=t.value;break;case"text_align_vertical":n.attrs.text_align_vertical=t.value;break;case"id":n.attrs.id=t.value;break;case"custom_class":n.attrs.custom_class=t.value;break;case"row_height":n.attrs.row_height=t.value;break;case"font_size":n.attrs.font_size=t.value;break;case"responsive":n.attrs.responsive=t.value;break;case"table_layout":n.attrs.table_layout=t.value}}));var s=wp.shortcode.string(n);t.insertContent(s),r.close()}))}),(function(e){console.warn(e)}))}))}})}))}(window.jQuery)}});
|
media/js/mptt-elementor-editor.js
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
'use strict';
|
2 |
+
|
3 |
+
$ = jQuery;
|
4 |
+
|
5 |
+
// Check if Frontend init.
|
6 |
+
$( window ).on( 'elementor/frontend/init', () => {
|
7 |
+
elementorFrontend.hooks.addAction( 'frontend/element_ready/timetable.default', $scope => {
|
8 |
+
const waitLoadTable = setInterval( () => {
|
9 |
+
if ( $scope.find( '.mptt-shortcode-wrapper' ).length && ! $scope.find( '.mptt-shortcode-wrapper' ).hasClass('table-init') ) {
|
10 |
+
clearInterval( waitLoadTable );
|
11 |
+
window.mptt.tableInit();
|
12 |
+
}
|
13 |
+
}, 1 );
|
14 |
+
} );
|
15 |
+
} );
|
media/js/mptt-elementor-editor.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
window.wp=window.wp||{},window.wp["./media/js/mptt-elementor-editor.min.js"]=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}({3:function(e,t,n){"use strict";$=jQuery,$(window).on("elementor/frontend/init",(function(){elementorFrontend.hooks.addAction("frontend/element_ready/timetable.default",(function(e){var t=setInterval((function(){e.find(".mptt-shortcode-wrapper").length&&!e.find(".mptt-shortcode-wrapper").hasClass("table-init")&&(clearInterval(t),window.mptt.tableInit())}),1)}))}))}});
|
media/js/mptt-functions.js
CHANGED
@@ -1,370 +1,370 @@
|
|
1 |
-
/* global console:false,$:false,jQuery:false, _:false, Registry:false, wp:false,pagenow:false,typenow:false, jBox:false */
|
2 |
-
window.Registry = (function() {
|
3 |
-
"use strict";
|
4 |
-
var modules = {};
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Test module
|
8 |
-
* @param module
|
9 |
-
* @returns {boolean}
|
10 |
-
* @private
|
11 |
-
*/
|
12 |
-
function _testModule(module) {
|
13 |
-
var status = false;
|
14 |
-
|
15 |
-
if (typeof module.getInstance === 'function') {
|
16 |
-
status = true;
|
17 |
-
}
|
18 |
-
|
19 |
-
return status;
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Register module
|
24 |
-
* @param name
|
25 |
-
* @param module
|
26 |
-
*/
|
27 |
-
function register(name, module) {
|
28 |
-
if (_testModule(module)) {
|
29 |
-
modules[name] = module;
|
30 |
-
} else {
|
31 |
-
throw new Error('Invalide module "' + name + '". The function "getInstance" is not defined.');
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Register modules
|
37 |
-
* @param map
|
38 |
-
*/
|
39 |
-
function registryMap(map) {
|
40 |
-
for (var name in map) {
|
41 |
-
if (!map.hasOwnProperty(name)) {
|
42 |
-
continue;
|
43 |
-
}
|
44 |
-
if (_testModule(map[name])) {
|
45 |
-
modules[name] = map[name];
|
46 |
-
} else {
|
47 |
-
throw new Error('Invalide module "' + name + '" inside the collection. The function "getInstance" is not defined.');
|
48 |
-
}
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Unregister
|
54 |
-
* @param name
|
55 |
-
*/
|
56 |
-
function unregister(name) {
|
57 |
-
delete modules[name];
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Get instance module
|
62 |
-
* @param name
|
63 |
-
* @returns {*|wp.mce.View}
|
64 |
-
*/
|
65 |
-
function _get(name) {
|
66 |
-
var module = modules[name];
|
67 |
-
if (!module) {
|
68 |
-
throw new Error('The module "' + name + '" has not been registered or it was unregistered.');
|
69 |
-
}
|
70 |
-
|
71 |
-
if (typeof module.getInstance !== 'function') {
|
72 |
-
throw new Error('The module "' + name + '" can not be instantiated. ' + 'The function "getInstance" is not defined.');
|
73 |
-
}
|
74 |
-
|
75 |
-
return modules[name].getInstance();
|
76 |
-
}
|
77 |
-
|
78 |
-
return {
|
79 |
-
register: register,
|
80 |
-
unregister: unregister,
|
81 |
-
_get: _get,
|
82 |
-
registryMap: registryMap
|
83 |
-
};
|
84 |
-
})();
|
85 |
-
|
86 |
-
Registry.register("adminFunctions", (function($) {
|
87 |
-
"use strict";
|
88 |
-
|
89 |
-
var state, $jBox, container;
|
90 |
-
|
91 |
-
function createInstance() {
|
92 |
-
return {
|
93 |
-
/**
|
94 |
-
* WP Ajax
|
95 |
-
*
|
96 |
-
* @param {object} params
|
97 |
-
* @param {function} callbackSuccess
|
98 |
-
* @param {function} callbackError
|
99 |
-
* @returns {undefined}
|
100 |
-
*/
|
101 |
-
wpAjax: function(params, callbackSuccess, callbackError) {
|
102 |
-
|
103 |
-
params.mptt_action = params.action;
|
104 |
-
|
105 |
-
delete params.action;
|
106 |
-
|
107 |
-
wp.ajax.send("route_url", {
|
108 |
-
|
109 |
-
success: function(data) {
|
110 |
-
if (!_.isUndefined(callbackError) && _.isFunction(callbackError)) {
|
111 |
-
callbackSuccess(data);
|
112 |
-
}
|
113 |
-
},
|
114 |
-
error: function(data) {
|
115 |
-
if (!_.isUndefined(callbackError) && _.isFunction(callbackError)) {
|
116 |
-
callbackError(data);
|
117 |
-
} else {
|
118 |
-
console.log(data);
|
119 |
-
}
|
120 |
-
},
|
121 |
-
data: params
|
122 |
-
});
|
123 |
-
},
|
124 |
-
/**
|
125 |
-
* Init Jbox
|
126 |
-
*
|
127 |
-
* @param jbox
|
128 |
-
* @param html_container
|
129 |
-
* @param buttonCallback
|
130 |
-
*/
|
131 |
-
initJBox: function(jbox, html_container, buttonCallback) {
|
132 |
-
$jBox = jbox;
|
133 |
-
container = html_container;
|
134 |
-
state.buttonEvents(buttonCallback);
|
135 |
-
},
|
136 |
-
/**
|
137 |
-
* Button save event
|
138 |
-
* @param buttonCallback
|
139 |
-
*/
|
140 |
-
buttonEvents: function(buttonCallback) {
|
141 |
-
container.find("#insert-into").off("click").on("click", function() {
|
142 |
-
buttonCallback($(this).parents('form').serializeArray());
|
143 |
-
});
|
144 |
-
},
|
145 |
-
/**
|
146 |
-
* Open popup window function
|
147 |
-
*
|
148 |
-
* @param start_content
|
149 |
-
* @param open_callback
|
150 |
-
* @param args
|
151 |
-
*/
|
152 |
-
callModal: function(start_content, open_callback, args) {
|
153 |
-
var height = $(window).outerHeight() - 100,
|
154 |
-
width = $(window).outerWidth() - 60,
|
155 |
-
spinner = wp.html.string({
|
156 |
-
'tag': "span",
|
157 |
-
'attrs': {
|
158 |
-
'class': "spinner is-active"
|
159 |
-
},
|
160 |
-
'content': ""
|
161 |
-
}
|
162 |
-
),
|
163 |
-
params = {
|
164 |
-
content: start_content,
|
165 |
-
closeOnEsc: true,
|
166 |
-
animation: {open: 'zoomIn', close: 'zoomOut'},
|
167 |
-
width: width,
|
168 |
-
height: height,
|
169 |
-
closeButton: "title",
|
170 |
-
title: 'Shortcode Settings',
|
171 |
-
onOpen: function() {
|
172 |
-
var jbox_container = $("#" + this.id);
|
173 |
-
|
174 |
-
open_callback.call(this, jbox_container);
|
175 |
-
},
|
176 |
-
onClose: function() {
|
177 |
-
//Registry._get('ContentDML').nonceAjax = Math.random().toString(36).slice(2);
|
178 |
-
$("#" + this.id).remove();
|
179 |
-
}
|
180 |
-
};
|
181 |
-
if (!_.isUndefined(args)) {
|
182 |
-
$.extend(params, args);
|
183 |
-
}
|
184 |
-
|
185 |
-
var popup = new jBox('Modal', params);
|
186 |
-
|
187 |
-
popup.open();
|
188 |
-
},
|
189 |
-
/**
|
190 |
-
* Parse Url Request
|
191 |
-
*
|
192 |
-
* @param {type} value - get params name
|
193 |
-
*/
|
194 |
-
parseRequest: function(value) {
|
195 |
-
var request = location.search;
|
196 |
-
var array,
|
197 |
-
result = {};
|
198 |
-
if (_.isEmpty(request) || request === "?") {
|
199 |
-
return result;
|
200 |
-
}
|
201 |
-
request = request.replace("?", "");
|
202 |
-
array = request.split("&");
|
203 |
-
$.each(array, function() {
|
204 |
-
var value = this;
|
205 |
-
value = value.split("=");
|
206 |
-
result[value[0]] = value[1];
|
207 |
-
});
|
208 |
-
if (_.isUndefined(value)) {
|
209 |
-
return result;
|
210 |
-
} else {
|
211 |
-
return result[value];
|
212 |
-
}
|
213 |
-
|
214 |
-
}, /**
|
215 |
-
* Generate HTML
|
216 |
-
*
|
217 |
-
* @param params - json
|
218 |
-
* @returns {string|*|n|string}
|
219 |
-
*/
|
220 |
-
generateHTML: function(params) {
|
221 |
-
var content = "",
|
222 |
-
result;
|
223 |
-
if (_.isObject(params)) {
|
224 |
-
var element = document.createElement(params.tag);
|
225 |
-
if (!_.isUndefined(params.attrs)) {
|
226 |
-
$.each(params.attrs, function(key, value) {
|
227 |
-
if (!_.isUndefined(value) && value !== '') {
|
228 |
-
element.setAttribute(key, value);
|
229 |
-
}
|
230 |
-
});
|
231 |
-
}
|
232 |
-
if (_.isArray(params.content)) {
|
233 |
-
|
234 |
-
$.each(params.content, function(key, value) {
|
235 |
-
content += state.generateHTML(value);
|
236 |
-
});
|
237 |
-
$(element).html(content);
|
238 |
-
} else if (_.isObject(params.content)) {
|
239 |
-
content = state.generateHTML(params.content);
|
240 |
-
$(element).html(content);
|
241 |
-
} else {
|
242 |
-
if (!_.isUndefined(params.content)) {
|
243 |
-
$(element).html(params.content);
|
244 |
-
} else {
|
245 |
-
$(element).html("");
|
246 |
-
}
|
247 |
-
}
|
248 |
-
result = $(element).get(0).outerHTML;
|
249 |
-
} else if (_.isString(params)) {
|
250 |
-
result = params;
|
251 |
-
} else {
|
252 |
-
result = false;
|
253 |
-
}
|
254 |
-
return result;
|
255 |
-
},
|
256 |
-
/**
|
257 |
-
* Put the data to html code and return here
|
258 |
-
*
|
259 |
-
* @param $template
|
260 |
-
* @param $data
|
261 |
-
* @returns {boolean}
|
262 |
-
*/
|
263 |
-
getHtml: function($template, $data) {
|
264 |
-
if (_.isUndefined($template)) {
|
265 |
-
return false;
|
266 |
-
}
|
267 |
-
var result = false;
|
268 |
-
if (_.isUndefined($data)) {
|
269 |
-
if (_.isArray($template)) {
|
270 |
-
result = "";
|
271 |
-
$.each($template, function(key, value) {
|
272 |
-
result += state.generateHTML(value);
|
273 |
-
});
|
274 |
-
} else {
|
275 |
-
result = state.generateHTML($template);
|
276 |
-
}
|
277 |
-
}
|
278 |
-
if (_.isObject($data)) {
|
279 |
-
var template = _.template(result);
|
280 |
-
result = template($data);
|
281 |
-
}
|
282 |
-
return result;
|
283 |
-
}
|
284 |
-
};
|
285 |
-
}
|
286 |
-
|
287 |
-
return {
|
288 |
-
getInstance: function() {
|
289 |
-
if (!state) {
|
290 |
-
state = createInstance();
|
291 |
-
}
|
292 |
-
return state;
|
293 |
-
}
|
294 |
-
};
|
295 |
-
})(jQuery));
|
296 |
-
|
297 |
-
|
298 |
-
(function($) {
|
299 |
-
"use strict";
|
300 |
-
|
301 |
-
$(document).ready(function() {
|
302 |
-
|
303 |
-
var mptt_table_init = function() {
|
304 |
-
var body = $('body');
|
305 |
-
|
306 |
-
if(detectIE()){
|
307 |
-
if(!body.hasClass('mprm_ie_browser')){
|
308 |
-
body.addClass('mprm_ie_browser');
|
309 |
-
}
|
310 |
-
}else{
|
311 |
-
body.removeClass('mprm_ie_browser');
|
312 |
-
}
|
313 |
-
|
314 |
-
var $mptt_shortcode_wrapper = $('.mptt-shortcode-wrapper');
|
315 |
-
|
316 |
-
if ((typeof typenow) !== "undefined") {
|
317 |
-
if (pagenow === typenow) {
|
318 |
-
switch (typenow) {
|
319 |
-
case 'mp-event':
|
320 |
-
Registry._get("Event").init();
|
321 |
-
break;
|
322 |
-
case 'mp-column':
|
323 |
-
Registry._get("Event").initDatePicker();
|
324 |
-
Registry._get("Event").columnRadioBox();
|
325 |
-
break;
|
326 |
-
default:
|
327 |
-
break;
|
328 |
-
}
|
329 |
-
}
|
330 |
-
}
|
331 |
-
|
332 |
-
if ($mptt_shortcode_wrapper.length) {
|
333 |
-
Registry._get("Event").initTableData();
|
334 |
-
Registry._get("Event").filterShortcodeEvents();
|
335 |
-
Registry._get("Event").getFilterByHash();
|
336 |
-
|
337 |
-
$mptt_shortcode_wrapper.show();
|
338 |
-
$mptt_shortcode_wrapper.addClass('table-init');
|
339 |
-
}
|
340 |
-
|
341 |
-
if ($('.upcoming-events-widget').length || $mptt_shortcode_wrapper.length) {
|
342 |
-
Registry._get("Event").setColorSettings();
|
343 |
-
}
|
344 |
-
}
|
345 |
-
|
346 |
-
window.mptt = {};
|
347 |
-
|
348 |
-
window.mptt.tableInit = mptt_table_init;
|
349 |
-
mptt_table_init();
|
350 |
-
});
|
351 |
-
})(jQuery);
|
352 |
-
|
353 |
-
function detectIE() {
|
354 |
-
var ua = window.navigator.userAgent;
|
355 |
-
|
356 |
-
var msie = ua.indexOf('MSIE ');
|
357 |
-
if (msie > 0) {
|
358 |
-
// IE 10 or older => return version number
|
359 |
-
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
|
360 |
-
}
|
361 |
-
|
362 |
-
var trident = ua.indexOf('Trident/');
|
363 |
-
if (trident > 0) {
|
364 |
-
// IE 11 => return version number
|
365 |
-
var rv = ua.indexOf('rv:');
|
366 |
-
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
|
367 |
-
}
|
368 |
-
// other browser
|
369 |
-
return false;
|
370 |
}
|
1 |
+
/* global console:false,$:false,jQuery:false, _:false, Registry:false, wp:false,pagenow:false,typenow:false, jBox:false */
|
2 |
+
window.Registry = (function() {
|
3 |
+
"use strict";
|
4 |
+
var modules = {};
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Test module
|
8 |
+
* @param module
|
9 |
+
* @returns {boolean}
|
10 |
+
* @private
|
11 |
+
*/
|
12 |
+
function _testModule(module) {
|
13 |
+
var status = false;
|
14 |
+
|
15 |
+
if (typeof module.getInstance === 'function') {
|
16 |
+
status = true;
|
17 |
+
}
|
18 |
+
|
19 |
+
return status;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Register module
|
24 |
+
* @param name
|
25 |
+
* @param module
|
26 |
+
*/
|
27 |
+
function register(name, module) {
|
28 |
+
if (_testModule(module)) {
|
29 |
+
modules[name] = module;
|
30 |
+
} else {
|
31 |
+
throw new Error('Invalide module "' + name + '". The function "getInstance" is not defined.');
|
32 |
+
}
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Register modules
|
37 |
+
* @param map
|
38 |
+
*/
|
39 |
+
function registryMap(map) {
|
40 |
+
for (var name in map) {
|
41 |
+
if (!map.hasOwnProperty(name)) {
|
42 |
+
continue;
|
43 |
+
}
|
44 |
+
if (_testModule(map[name])) {
|
45 |
+
modules[name] = map[name];
|
46 |
+
} else {
|
47 |
+
throw new Error('Invalide module "' + name + '" inside the collection. The function "getInstance" is not defined.');
|
48 |
+
}
|
49 |
+
}
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Unregister
|
54 |
+
* @param name
|
55 |
+
*/
|
56 |
+
function unregister(name) {
|
57 |
+
delete modules[name];
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Get instance module
|
62 |
+
* @param name
|
63 |
+
* @returns {*|wp.mce.View}
|
64 |
+
*/
|
65 |
+
function _get(name) {
|
66 |
+
var module = modules[name];
|
67 |
+
if (!module) {
|
68 |
+
throw new Error('The module "' + name + '" has not been registered or it was unregistered.');
|
69 |
+
}
|
70 |
+
|
71 |
+
if (typeof module.getInstance !== 'function') {
|
72 |
+
throw new Error('The module "' + name + '" can not be instantiated. ' + 'The function "getInstance" is not defined.');
|
73 |
+
}
|
74 |
+
|
75 |
+
return modules[name].getInstance();
|
76 |
+
}
|
77 |
+
|
78 |
+
return {
|
79 |
+
register: register,
|
80 |
+
unregister: unregister,
|
81 |
+
_get: _get,
|
82 |
+
registryMap: registryMap
|
83 |
+
};
|
84 |
+
})();
|
85 |
+
|
86 |
+
Registry.register("adminFunctions", (function($) {
|
87 |
+
"use strict";
|
88 |
+
|
89 |
+
var state, $jBox, container;
|
90 |
+
|
91 |
+
function createInstance() {
|
92 |
+
return {
|
93 |
+
/**
|
94 |
+
* WP Ajax
|
95 |
+
*
|
96 |
+
* @param {object} params
|
97 |
+
* @param {function} callbackSuccess
|
98 |
+
* @param {function} callbackError
|
99 |
+
* @returns {undefined}
|
100 |
+
*/
|
101 |
+
wpAjax: function(params, callbackSuccess, callbackError) {
|
102 |
+
|
103 |
+
params.mptt_action = params.action;
|
104 |
+
|
105 |
+
delete params.action;
|
106 |
+
|
107 |
+
wp.ajax.send("route_url", {
|
108 |
+
|
109 |
+
success: function(data) {
|
110 |
+
if (!_.isUndefined(callbackError) && _.isFunction(callbackError)) {
|
111 |
+
callbackSuccess(data);
|
112 |
+
}
|
113 |
+
},
|
114 |
+
error: function(data) {
|
115 |
+
if (!_.isUndefined(callbackError) && _.isFunction(callbackError)) {
|
116 |
+
callbackError(data);
|
117 |
+
} else {
|
118 |
+
console.log(data);
|
119 |
+
}
|
120 |
+
},
|
121 |
+
data: params
|
122 |
+
});
|
123 |
+
},
|
124 |
+
/**
|
125 |
+
* Init Jbox
|
126 |
+
*
|
127 |
+
* @param jbox
|
128 |
+
* @param html_container
|
129 |
+
* @param buttonCallback
|
130 |
+
*/
|
131 |
+
initJBox: function(jbox, html_container, buttonCallback) {
|
132 |
+
$jBox = jbox;
|
133 |
+
container = html_container;
|
134 |
+
state.buttonEvents(buttonCallback);
|
135 |
+
},
|
136 |
+
/**
|
137 |
+
* Button save event
|
138 |
+
* @param buttonCallback
|
139 |
+
*/
|
140 |
+
buttonEvents: function(buttonCallback) {
|
141 |
+
container.find("#insert-into").off("click").on("click", function() {
|
142 |
+
buttonCallback($(this).parents('form').serializeArray());
|
143 |
+
});
|
144 |
+
},
|
145 |
+
/**
|
146 |
+
* Open popup window function
|
147 |
+
*
|
148 |
+
* @param start_content
|
149 |
+
* @param open_callback
|
150 |
+
* @param args
|
151 |
+
*/
|
152 |
+
callModal: function(start_content, open_callback, args) {
|
153 |
+
var height = $(window).outerHeight() - 100,
|
154 |
+
width = $(window).outerWidth() - 60,
|
155 |
+
spinner = wp.html.string({
|
156 |
+
'tag': "span",
|
157 |
+
'attrs': {
|
158 |
+
'class': "spinner is-active"
|
159 |
+
},
|
160 |
+
'content': ""
|
161 |
+
}
|
162 |
+
),
|
163 |
+
params = {
|
164 |
+
content: start_content,
|
165 |
+
closeOnEsc: true,
|
166 |
+
animation: {open: 'zoomIn', close: 'zoomOut'},
|
167 |
+
width: width,
|
168 |
+
height: height,
|
169 |
+
closeButton: "title",
|
170 |
+
title: 'Shortcode Settings',
|
171 |
+
onOpen: function() {
|
172 |
+
var jbox_container = $("#" + this.id);
|
173 |
+
|
174 |
+
open_callback.call(this, jbox_container);
|
175 |
+
},
|
176 |
+
onClose: function() {
|
177 |
+
//Registry._get('ContentDML').nonceAjax = Math.random().toString(36).slice(2);
|
178 |
+
$("#" + this.id).remove();
|
179 |
+
}
|
180 |
+
};
|
181 |
+
if (!_.isUndefined(args)) {
|
182 |
+
$.extend(params, args);
|
183 |
+
}
|
184 |
+
|
185 |
+
var popup = new jBox('Modal', params);
|
186 |
+
|
187 |
+
popup.open();
|
188 |
+
},
|
189 |
+
/**
|
190 |
+
* Parse Url Request
|
191 |
+
*
|
192 |
+
* @param {type} value - get params name
|
193 |
+
*/
|
194 |
+
parseRequest: function(value) {
|
195 |
+
var request = location.search;
|
196 |
+
var array,
|
197 |
+
result = {};
|
198 |
+
if (_.isEmpty(request) || request === "?") {
|
199 |
+
return result;
|
200 |
+
}
|
201 |
+
request = request.replace("?", "");
|
202 |
+
array = request.split("&");
|
203 |
+
$.each(array, function() {
|
204 |
+
var value = this;
|
205 |
+
value = value.split("=");
|
206 |
+
result[value[0]] = value[1];
|
207 |
+
});
|
208 |
+
if (_.isUndefined(value)) {
|
209 |
+
return result;
|
210 |
+
} else {
|
211 |
+
return result[value];
|
212 |
+
}
|
213 |
+
|
214 |
+
}, /**
|
215 |
+
* Generate HTML
|
216 |
+
*
|
217 |
+
* @param params - json
|
218 |
+
* @returns {string|*|n|string}
|
219 |
+
*/
|
220 |
+
generateHTML: function(params) {
|
221 |
+
var content = "",
|
222 |
+
result;
|
223 |
+
if (_.isObject(params)) {
|
224 |
+
var element = document.createElement(params.tag);
|
225 |
+
if (!_.isUndefined(params.attrs)) {
|
226 |
+
$.each(params.attrs, function(key, value) {
|
227 |
+
if (!_.isUndefined(value) && value !== '') {
|
228 |
+
element.setAttribute(key, value);
|
229 |
+
}
|
230 |
+
});
|
231 |
+
}
|
232 |
+
if (_.isArray(params.content)) {
|
233 |
+
|
234 |
+
$.each(params.content, function(key, value) {
|
235 |
+
content += state.generateHTML(value);
|
236 |
+
});
|
237 |
+
$(element).html(content);
|
238 |
+
} else if (_.isObject(params.content)) {
|
239 |
+
content = state.generateHTML(params.content);
|
240 |
+
$(element).html(content);
|
241 |
+
} else {
|
242 |
+
if (!_.isUndefined(params.content)) {
|
243 |
+
$(element).html(params.content);
|
244 |
+
} else {
|
245 |
+
$(element).html("");
|
246 |
+
}
|
247 |
+
}
|
248 |
+
result = $(element).get(0).outerHTML;
|
249 |
+
} else if (_.isString(params)) {
|
250 |
+
result = params;
|
251 |
+
} else {
|
252 |
+
result = false;
|
253 |
+
}
|
254 |
+
return result;
|
255 |
+
},
|
256 |
+
/**
|
257 |
+
* Put the data to html code and return here
|
258 |
+
*
|
259 |
+
* @param $template
|
260 |
+
* @param $data
|
261 |
+
* @returns {boolean}
|
262 |
+
*/
|
263 |
+
getHtml: function($template, $data) {
|
264 |
+
if (_.isUndefined($template)) {
|
265 |
+
return false;
|
266 |
+
}
|
267 |
+
var result = false;
|
268 |
+
if (_.isUndefined($data)) {
|
269 |
+
if (_.isArray($template)) {
|
270 |
+
result = "";
|
271 |
+
$.each($template, function(key, value) {
|
272 |
+
result += state.generateHTML(value);
|
273 |
+
});
|
274 |
+
} else {
|
275 |
+
result = state.generateHTML($template);
|
276 |
+
}
|
277 |
+
}
|
278 |
+
if (_.isObject($data)) {
|
279 |
+
var template = _.template(result);
|
280 |
+
result = template($data);
|
281 |
+
}
|
282 |
+
return result;
|
283 |
+
}
|
284 |
+
};
|
285 |
+
}
|
286 |
+
|
287 |
+
return {
|
288 |
+
getInstance: function() {
|
289 |
+
if (!state) {
|
290 |
+
state = createInstance();
|
291 |
+
}
|
292 |
+
return state;
|
293 |
+
}
|
294 |
+
};
|
295 |
+
})(jQuery));
|
296 |
+
|
297 |
+
|
298 |
+
(function($) {
|
299 |
+
"use strict";
|
300 |
+
|
301 |
+
$(document).ready(function() {
|
302 |
+
|
303 |
+
var mptt_table_init = function() {
|
304 |
+
var body = $('body');
|
305 |
+
|
306 |
+
if(detectIE()){
|
307 |
+
if(!body.hasClass('mprm_ie_browser')){
|
308 |
+
body.addClass('mprm_ie_browser');
|
309 |
+
}
|
310 |
+
}else{
|
311 |
+
body.removeClass('mprm_ie_browser');
|
312 |
+
}
|
313 |
+
|
314 |
+
var $mptt_shortcode_wrapper = $('.mptt-shortcode-wrapper');
|
315 |
+
|
316 |
+
if ((typeof typenow) !== "undefined") {
|
317 |
+
if (pagenow === typenow) {
|
318 |
+
switch (typenow) {
|
319 |
+
case 'mp-event':
|
320 |
+
Registry._get("Event").init();
|
321 |
+
break;
|
322 |
+
case 'mp-column':
|
323 |
+
Registry._get("Event").initDatePicker();
|
324 |
+
Registry._get("Event").columnRadioBox();
|
325 |
+
break;
|
326 |
+
default:
|
327 |
+
break;
|
328 |
+
}
|
329 |
+
}
|
330 |
+
}
|
331 |
+
|
332 |
+
if ($mptt_shortcode_wrapper.length) {
|
333 |
+
Registry._get("Event").initTableData();
|
334 |
+
Registry._get("Event").filterShortcodeEvents();
|
335 |
+
Registry._get("Event").getFilterByHash();
|
336 |
+
|
337 |
+
$mptt_shortcode_wrapper.show();
|
338 |
+
$mptt_shortcode_wrapper.addClass('table-init');
|
339 |
+
}
|
340 |
+
|
341 |
+
if ($('.upcoming-events-widget').length || $mptt_shortcode_wrapper.length) {
|
342 |
+
Registry._get("Event").setColorSettings();
|
343 |
+
}
|
344 |
+
}
|
345 |
+
|
346 |
+
window.mptt = {};
|
347 |
+
|
348 |
+
window.mptt.tableInit = mptt_table_init;
|
349 |
+
mptt_table_init();
|
350 |
+
});
|
351 |
+
})(jQuery);
|
352 |
+
|
353 |
+
function detectIE() {
|
354 |
+
var ua = window.navigator.userAgent;
|
355 |
+
|
356 |
+
var msie = ua.indexOf('MSIE ');
|
357 |
+
if (msie > 0) {
|
358 |
+
// IE 10 or older => return version number
|
359 |
+
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
|
360 |
+
}
|
361 |
+
|
362 |
+
var trident = ua.indexOf('Trident/');
|
363 |
+
if (trident > 0) {
|
364 |
+
// IE 11 => return version number
|
365 |
+
var rv = ua.indexOf('rv:');
|
366 |
+
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
|
367 |
+
}
|
368 |
+
// other browser
|
369 |
+
return false;
|
370 |
}
|
media/less/admin.less
CHANGED
@@ -1,120 +1,120 @@
|
|
1 |
-
#mp-event_data {
|
2 |
-
#add_event_table {
|
3 |
-
#event_start, #event_end {
|
4 |
-
min-width: 100px;
|
5 |
-
}
|
6 |
-
}
|
7 |
-
.spinner.left {
|
8 |
-
float: none;
|
9 |
-
}
|
10 |
-
|
11 |
-
.events-list-wrapper {
|
12 |
-
max-height: 360px;
|
13 |
-
overflow-y: auto;
|
14 |
-
overflow-x: hidden;
|
15 |
-
margin-bottom: 1em;
|
16 |
-
}
|
17 |
-
#events-list {
|
18 |
-
|
19 |
-
.active {
|
20 |
-
* {
|
21 |
-
background-color: #F7FCFE;
|
22 |
-
}
|
23 |
-
td:first-child {
|
24 |
-
border-left: 4px solid #0091cd;
|
25 |
-
}
|
26 |
-
}
|
27 |
-
|
28 |
-
.edit-event-button, .delete-event-button {
|
29 |
-
margin: 0 5px 10px 0;
|
30 |
-
position: relative;
|
31 |
-
width: 2em;
|
32 |
-
height: 2em;
|
33 |
-
|
34 |
-
&.icon:before {
|
35 |
-
font-family: Dashicons;
|
36 |
-
font-variant: normal;
|
37 |
-
font-weight: 400;
|
38 |
-
height: 100%;
|
39 |
-
left: 0;
|
40 |
-
line-height: 1.85;
|
41 |
-
margin: 0;
|
42 |
-
position: absolute;
|
43 |
-
text-align: center;
|
44 |
-
text-indent: 0;
|
45 |
-
text-transform: none;
|
46 |
-
top: 0;
|
47 |
-
width: 100%;
|
48 |
-
}
|
49 |
-
}
|
50 |
-
}
|
51 |
-
}
|
52 |
-
|
53 |
-
@media screen and (max-width: 1200px) {
|
54 |
-
#mp-event_data {
|
55 |
-
#events-list {
|
56 |
-
.event-description {
|
57 |
-
overflow: hidden;
|
58 |
-
text-overflow: ellipsis;
|
59 |
-
white-space: nowrap;
|
60 |
-
}
|
61 |
-
}
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
#column-options {
|
66 |
-
.mp-weekday, .mp-date {
|
67 |
-
margin: 10px 0 0;
|
68 |
-
}
|
69 |
-
}
|
70 |
-
|
71 |
-
div[id^="jBoxID"] {
|
72 |
-
&.jBox-Modal {
|
73 |
-
.jBox-container {
|
74 |
-
overflow: hidden;
|
75 |
-
}
|
76 |
-
.jBox-content {
|
77 |
-
max-width: 980px;
|
78 |
-
max-height: 800px;
|
79 |
-
padding: 0;
|
80 |
-
overflow: hidden;
|
81 |
-
& > form {
|
82 |
-
height: 100%;
|
83 |
-
overflow: hidden;
|
84 |
-
position: relative;
|
85 |
-
.mptt-shortcode-settings-wrapper {
|
86 |
-
height: ~"calc(100% - 60px)";
|
87 |
-
overflow-y: scroll;
|
88 |
-
padding: 0 15px 0 10px;
|
89 |
-
}
|
90 |
-
.mptt-shortcode-submit-wrapper {
|
91 |
-
background: #f4f5f6 none repeat scroll 0 0;
|
92 |
-
border-top: 1px solid #ddd;
|
93 |
-
padding: 15px;
|
94 |
-
position: relative;
|
95 |
-
text-align: left;
|
96 |
-
}
|
97 |
-
}
|
98 |
-
}
|
99 |
-
}
|
100 |
-
}
|
101 |
-
|
102 |
-
#add_event_options_table, #add_event_table {
|
103 |
-
&.form-table {
|
104 |
-
tr {
|
105 |
-
> :first-child {
|
106 |
-
vertical-align: top;
|
107 |
-
text-align: left;
|
108 |
-
padding: 20px 10px 20px 0;
|
109 |
-
width: 200px;
|
110 |
-
line-height: 1.3;
|
111 |
-
font-weight: 600;
|
112 |
-
}
|
113 |
-
}
|
114 |
-
}
|
115 |
-
}
|
116 |
-
|
117 |
-
select.mptt-resize-vertical {
|
118 |
-
resize: vertical;
|
119 |
-
min-height: 4em;
|
120 |
}
|
1 |
+
#mp-event_data {
|
2 |
+
#add_event_table {
|
3 |
+
#event_start, #event_end {
|
4 |
+
min-width: 100px;
|
5 |
+
}
|
6 |
+
}
|
7 |
+
.spinner.left {
|
8 |
+
float: none;
|
9 |
+
}
|
10 |
+
|
11 |
+
.events-list-wrapper {
|
12 |
+
max-height: 360px;
|
13 |
+
overflow-y: auto;
|
14 |
+
overflow-x: hidden;
|
15 |
+
margin-bottom: 1em;
|
16 |
+
}
|
17 |
+
#events-list {
|
18 |
+
|
19 |
+
.active {
|
20 |
+
* {
|
21 |
+
background-color: #F7FCFE;
|
22 |
+
}
|
23 |
+
td:first-child {
|
24 |
+
border-left: 4px solid #0091cd;
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
.edit-event-button, .delete-event-button {
|
29 |
+
margin: 0 5px 10px 0;
|
30 |
+
position: relative;
|
31 |
+
width: 2em;
|
32 |
+
height: 2em;
|
33 |
+
|
34 |
+
&.icon:before {
|
35 |
+
font-family: Dashicons;
|
36 |
+
font-variant: normal;
|
37 |
+
font-weight: 400;
|
38 |
+
height: 100%;
|
39 |
+
left: 0;
|
40 |
+
line-height: 1.85;
|
41 |
+
margin: 0;
|
42 |
+
position: absolute;
|
43 |
+
text-align: center;
|
44 |
+
text-indent: 0;
|
45 |
+
text-transform: none;
|
46 |
+
top: 0;
|
47 |
+
width: 100%;
|
48 |
+
}
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
@media screen and (max-width: 1200px) {
|
54 |
+
#mp-event_data {
|
55 |
+
#events-list {
|
56 |
+
.event-description {
|
57 |
+
overflow: hidden;
|
58 |
+
text-overflow: ellipsis;
|
59 |
+
white-space: nowrap;
|
60 |
+
}
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
#column-options {
|
66 |
+
.mp-weekday, .mp-date {
|
67 |
+
margin: 10px 0 0;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
+
div[id^="jBoxID"] {
|
72 |
+
&.jBox-Modal {
|
73 |
+
.jBox-container {
|
74 |
+
overflow: hidden;
|
75 |
+
}
|
76 |
+
.jBox-content {
|
77 |
+
max-width: 980px;
|
78 |
+
max-height: 800px;
|
79 |
+
padding: 0;
|
80 |
+
overflow: hidden;
|
81 |
+
& > form {
|
82 |
+
height: 100%;
|
83 |
+
overflow: hidden;
|
84 |
+
position: relative;
|
85 |
+
.mptt-shortcode-settings-wrapper {
|
86 |
+
height: ~"calc(100% - 60px)";
|
87 |
+
overflow-y: scroll;
|
88 |
+
padding: 0 15px 0 10px;
|
89 |
+
}
|
90 |
+
.mptt-shortcode-submit-wrapper {
|
91 |
+
background: #f4f5f6 none repeat scroll 0 0;
|
92 |
+
border-top: 1px solid #ddd;
|
93 |
+
padding: 15px;
|
94 |
+
position: relative;
|
95 |
+
text-align: left;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
#add_event_options_table, #add_event_table {
|
103 |
+
&.form-table {
|
104 |
+
tr {
|
105 |
+
> :first-child {
|
106 |
+
vertical-align: top;
|
107 |
+
text-align: left;
|
108 |
+
padding: 20px 10px 20px 0;
|
109 |
+
width: 200px;
|
110 |
+
line-height: 1.3;
|
111 |
+
font-weight: 600;
|
112 |
+
}
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
select.mptt-resize-vertical {
|
118 |
+
resize: vertical;
|
119 |
+
min-height: 4em;
|
120 |
}
|
media/less/no-js.less
CHANGED
@@ -1,31 +1,31 @@
|
|
1 |
-
.mptt-shortcode-wrapper {
|
2 |
-
.mptt-shortcode-table {
|
3 |
-
&:first-of-type {
|
4 |
-
display: table !important;
|
5 |
-
}
|
6 |
-
.mptt-event-container {
|
7 |
-
&:hover {
|
8 |
-
height: auto !important;
|
9 |
-
min-height: 100% !important;
|
10 |
-
}
|
11 |
-
}
|
12 |
-
}
|
13 |
-
}
|
14 |
-
body {
|
15 |
-
&.mprm_ie_browser {
|
16 |
-
.mptt-shortcode-wrapper {
|
17 |
-
.mptt-event-container {
|
18 |
-
height: auto !important;
|
19 |
-
}
|
20 |
-
}
|
21 |
-
}
|
22 |
-
}
|
23 |
-
@media (max-width: 767px) {
|
24 |
-
.mptt-shortcode-wrapper {
|
25 |
-
.mptt-shortcode-table {
|
26 |
-
&:first-of-type {
|
27 |
-
display: none !important;
|
28 |
-
}
|
29 |
-
}
|
30 |
-
}
|
31 |
-
}
|
1 |
+
.mptt-shortcode-wrapper {
|
2 |
+
.mptt-shortcode-table {
|
3 |
+
&:first-of-type {
|
4 |
+
display: table !important;
|
5 |
+
}
|
6 |
+
.mptt-event-container {
|
7 |
+
&:hover {
|
8 |
+
height: auto !important;
|
9 |
+
min-height: 100% !important;
|
10 |
+
}
|
11 |
+
}
|
12 |
+
}
|
13 |
+
}
|
14 |
+
body {
|
15 |
+
&.mprm_ie_browser {
|
16 |
+
.mptt-shortcode-wrapper {
|
17 |
+
.mptt-event-container {
|
18 |
+
height: auto !important;
|
19 |
+
}
|
20 |
+
}
|
21 |
+
}
|
22 |
+
}
|
23 |
+
@media (max-width: 767px) {
|
24 |
+
.mptt-shortcode-wrapper {
|
25 |
+
.mptt-shortcode-table {
|
26 |
+
&:first-of-type {
|
27 |
+
display: none !important;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
media/less/style.less
CHANGED
@@ -1,480 +1,480 @@
|
|
1 |
-
@default_color: #3b5998;
|
2 |
-
|
3 |
-
@import 'theme.less';
|
4 |
-
//@import "no-js";
|
5 |
-
.mptt-main-wrapper {
|
6 |
-
&.mp-event-item {
|
7 |
-
img:not(.avatar ) {
|
8 |
-
width: 100%;
|
9 |
-
height: auto;
|
10 |
-
}
|
11 |
-
}
|
12 |
-
.mptt-content {
|
13 |
-
width: 66.999%;
|
14 |
-
margin-right: 3%;
|
15 |
-
float: left;
|
16 |
-
}
|
17 |
-
.mptt-sidebar {
|
18 |
-
width: 30%;
|
19 |
-
float: left;
|
20 |
-
}
|
21 |
-
|
22 |
-
.event-title {
|
23 |
-
margin: 0 0 2rem;
|
24 |
-
}
|
25 |
-
.thumbnail-wrapper {
|
26 |
-
margin-bottom: 1rem;
|
27 |
-
}
|
28 |
-
.event-content {
|
29 |
-
margin: 1rem 0;
|
30 |
-
}
|
31 |
-
.timeslots-title {
|
32 |
-
margin: 1rem 0;
|
33 |
-
}
|
34 |
-
.mptt-event.events-list {
|
35 |
-
margin: 0 0 1rem 2rem;
|
36 |
-
list-style: none;
|
37 |
-
padding: 0;
|
38 |
-
|
39 |
-
.event {
|
40 |
-
list-style: outside;
|
41 |
-
padding: 1rem;
|
42 |
-
|
43 |
-
.event-title {
|
44 |
-
margin: 0.25rem 0 0;
|
45 |
-
padding: 0;
|
46 |
-
}
|
47 |
-
.event-subtitle {
|
48 |
-
margin: 0.25rem 0 0;
|
49 |
-
padding: 0;
|
50 |
-
}
|
51 |
-
.timeslot,
|
52 |
-
.event-user {
|
53 |
-
margin: 0.25rem 0 0;
|
54 |
-
padding: 0;
|
55 |
-
}
|
56 |
-
.event-description {
|
57 |
-
margin: 0.25rem 0 0;
|
58 |
-
padding: 0;
|
59 |
-
hyphens: auto;
|
60 |
-
}
|
61 |
-
.event-user {
|
62 |
-
.avatar {
|
63 |
-
border-radius: 50%;
|
64 |
-
}
|
65 |
-
}
|
66 |
-
}
|
67 |
-
.event:last-child {
|
68 |
-
margin-bottom: 0;
|
69 |
-
}
|
70 |
-
}
|
71 |
-
|
72 |
-
.column-title {
|
73 |
-
margin: 0 0 2rem 0;
|
74 |
-
}
|
75 |
-
.column-content {
|
76 |
-
margin: 1rem 0;
|
77 |
-
}
|
78 |
-
.mptt-column.events-list {
|
79 |
-
margin: 0 0 2rem 0;
|
80 |
-
list-style: none;
|
81 |
-
padding: 0;
|
82 |
-
.event {
|
83 |
-
list-style: none;
|
84 |
-
padding: 1rem;
|
85 |
-
|
86 |
-
.event-thumbnail {
|
87 |
-
float: left;
|
88 |
-
margin: 0 2rem 2rem 0;
|
89 |
-
}
|
90 |
-
.event-title {
|
91 |
-
clear: none;
|
92 |
-
margin: 0 0 0.25rem 0;
|
93 |
-
padding: 0;
|
94 |
-
}
|
95 |
-
.event-subtitle {
|
96 |
-
margin: 0.25rem 0 0;
|
97 |
-
padding: 0;
|
98 |
-
}
|
99 |
-
.timeslot,
|
100 |
-
.event-user {
|
101 |
-
margin: 0.25rem 0 0;
|
102 |
-
padding: 0;
|
103 |
-
}
|
104 |
-
.event-description {
|
105 |
-
margin: 0.25rem 0 0;
|
106 |
-
padding: 0;
|
107 |
-
hyphens: auto;
|
108 |
-
}
|
109 |
-
.event-user {
|
110 |
-
.avatar {
|
111 |
-
border-radius: 50%;
|
112 |
-
}
|
113 |
-
}
|
114 |
-
}
|
115 |
-
}
|
116 |
-
}
|
117 |
-
|
118 |
-
.upcoming-events-widget {
|
119 |
-
margin-top: 2rem;
|
120 |
-
.mptt-widget.events-list {
|
121 |
-
list-style: none;
|
122 |
-
margin: 0;
|
123 |
-
padding: 0;
|
124 |
-
.event {
|
125 |
-
list-style: none;
|
126 |
-
margin-bottom: 2rem;
|
127 |
-
padding: 0.5rem 2rem;
|
128 |
-
border: none;
|
129 |
-
border-left: 3px solid @default_color;
|
130 |
-
|
131 |
-
.event-title {
|
132 |
-
margin: 0 0 0.25rem 0;
|
133 |
-
padding: 0;
|
134 |
-
}
|
135 |
-
.column-title {
|
136 |
-
margin: 0.25rem 0 0;
|
137 |
-
padding: 0;
|
138 |
-
}
|
139 |
-
.timeslot,
|
140 |
-
.event-user {
|
141 |
-
margin: 0.25rem 0 0;
|
142 |
-
padding: 0;
|
143 |
-
}
|
144 |
-
&.mptt-colorized {
|
145 |
-
.event-title {
|
146 |
-
margin: 0 0 0.25rem 0;
|
147 |
-
padding: 0;
|
148 |
-
color: inherit;
|
149 |
-
|
150 |
-
.event-link {
|
151 |
-
color: inherit;
|
152 |
-
}
|
153 |
-
}
|
154 |
-
}
|
155 |
-
}
|
156 |
-
}
|
157 |
-
}
|
158 |
-
|
159 |
-
.mptt-hidden {
|
160 |
-
display: none;
|
161 |
-
opacity: 0;
|
162 |
-
clear: both;
|
163 |
-
}
|
164 |
-
|
165 |
-
.mprm_ie_browser {
|
166 |
-
.mptt-inner-event-content {
|
167 |
-
width: 100%;
|
168 |
-
}
|
169 |
-
}
|
170 |
-
|
171 |
-
.mptt-container {
|
172 |
-
list-style: none;
|
173 |
-
}
|
174 |
-
|
175 |
-
/*====== Widget End ======*/
|
176 |
-
|
177 |
-
/* ====== Shortcode start ====== */
|
178 |
-
.mptt-shortcode-wrapper {
|
179 |
-
.mptt-shortcode-event {
|
180 |
-
.mptt-event-container {
|
181 |
-
display: flex;
|
182 |
-
flex-direction: column;
|
183 |
-
&:hover {
|
184 |
-
//min-height: 100%;
|
185 |
-
display: flex;
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
&.mptt-event-vertical-top {
|
190 |
-
.mptt-event-container {
|
191 |
-
justify-content: flex-start;
|
192 |
-
align-content: flex-start;
|
193 |
-
}
|
194 |
-
}
|
195 |
-
&.mptt-event-vertical-middle {
|
196 |
-
.mptt-event-container {
|
197 |
-
justify-content: center;
|
198 |
-
align-content: center;
|
199 |
-
}
|
200 |
-
}
|
201 |
-
&.mptt-event-vertical-bottom {
|
202 |
-
.mptt-event-container {
|
203 |
-
justify-content: flex-end;
|
204 |
-
align-content: flex-end;
|
205 |
-
}
|
206 |
-
}
|
207 |
-
}
|
208 |
-
|
209 |
-
.mptt-shortcode-table {
|
210 |
-
margin-top: 1rem;
|
211 |
-
tr.mptt-shortcode-row {
|
212 |
-
th {
|
213 |
-
background-color: #f0f0f0;
|
214 |
-
border: 1px solid #ffffff;
|
215 |
-
text-align: center;
|
216 |
-
color: #404040;
|
217 |
-
padding: 0.25rem 1rem;
|
218 |
-
overflow-wrap: normal;
|
219 |
-
hyphens: none;
|
220 |
-
}
|
221 |
-
|
222 |
-
}
|
223 |
-
tbody {
|
224 |
-
tr:nth-child(2n+2) {
|
225 |
-
background-color: #f0f0f0;
|
226 |
-
}
|
227 |
-
td {
|
228 |
-
position: relative;
|
229 |
-
border: 1px solid #ffffff;
|
230 |
-
padding: 0;
|
231 |
-
line-height: normal;
|
232 |
-
box-sizing: initial;
|
233 |
-
&.event {
|
234 |
-
background-color: @default_color;
|
235 |
-
}
|
236 |
-
&.mptt-shortcode-hours {
|
237 |
-
padding: 0 1rem !important;
|
238 |
-
white-space: nowrap;
|
239 |
-
width: 1%;
|
240 |
-
vertical-align: middle;
|
241 |
-
}
|
242 |
-
}
|
243 |
-
.mptt-event-container {
|
244 |
-
position: absolute;
|
245 |
-
top: 0;
|
246 |
-
right: 0;
|
247 |
-
left: 0;
|
248 |
-
z-index: 3;
|
249 |
-
overflow: hidden;
|
250 |
-
outline: 1px solid #fff;
|
251 |
-
color: inherit;
|
252 |
-
/*word-break: break-all;
|
253 |
-
word-wrap: break-word;*/
|
254 |
-
|
255 |
-
&:hover {
|
256 |
-
background-color: inherit;
|
257 |
-
overflow: visible;
|
258 |
-
z-index: 10;
|
259 |
-
.event-title {
|
260 |
-
text-decoration: underline;
|
261 |
-
}
|
262 |
-
}
|
263 |
-
|
264 |
-
p {
|
265 |
-
color: inherit;
|
266 |
-
}
|
267 |
-
|
268 |
-
.event-title {
|
269 |
-
color: inherit;
|
270 |
-
display: inline-block;
|
271 |
-
margin: 0.5rem 0.25rem 0.25rem 0.25rem;
|
272 |
-
text-decoration: none;
|
273 |
-
font-size: 1.1em;
|
274 |
-
//word-break: break-all;
|
275 |
-
}
|
276 |
-
.event-subtitle {
|
277 |
-
margin: 0.25rem;
|
278 |
-
font-size: 0.8em;
|
279 |
-
}
|
280 |
-
.event-user {
|
281 |
-
margin: 0.25rem;
|
282 |
-
font-size: 0.8em;
|
283 |
-
.avatar {
|
284 |
-
border-radius: 50%;
|
285 |
-
margin-right: 3px;
|
286 |
-
display: inline-block;
|
287 |
-
vertical-align: middle;
|
288 |
-
}
|
289 |
-
}
|
290 |
-
.event-description {
|
291 |
-
font-size: 0.8em;
|
292 |
-
margin: 0.25rem;
|
293 |
-
hyphens: auto;
|
294 |
-
}
|
295 |
-
.timeslot {
|
296 |
-
font-size: 0.9em;
|
297 |
-
margin: 0.25rem;
|
298 |
-
}
|
299 |
-
}
|
300 |
-
}
|
301 |
-
|
302 |
-
&.mptt-theme-mode tbody {
|
303 |
-
tr:nth-child(2n+2) {
|
304 |
-
td.event {
|
305 |
-
background-color: inherit;
|
306 |
-
}
|
307 |
-
}
|
308 |
-
td.event {
|
309 |
-
background-color: #ffffff;
|
310 |
-
|
311 |
-
.event-user img {
|
312 |
-
position: relative;
|
313 |
-
}
|
314 |
-
}
|
315 |
-
}
|
316 |
-
&.mptt-table-layout-auto {
|
317 |
-
table-layout: auto;
|
318 |
-
}
|
319 |
-
&.mptt-table-layout-fixed {
|
320 |
-
table-layout: fixed;
|
321 |
-
}
|
322 |
-
}
|
323 |
-
.mptt-navigation-tabs {
|
324 |
-
margin: 0 0 1rem;
|
325 |
-
list-style-type: none;
|
326 |
-
li {
|
327 |
-
|
328 |
-
display: inline-block;
|
329 |
-
padding: 0.25rem 0.5rem 0.25rem 0;
|
330 |
-
}
|
331 |
-
}
|
332 |
-
.mptt-shortcode-list {
|
333 |
-
display: none;
|
334 |
-
|
335 |
-
.mptt-column {
|
336 |
-
margin: 2rem 0;
|
337 |
-
.mptt-column-title {
|
338 |
-
margin: 2rem 0;
|
339 |
-
}
|
340 |
-
|
341 |
-
.mptt-events-list {
|
342 |
-
list-style: none;
|
343 |
-
margin: 2rem;
|
344 |
-
padding: 0;
|
345 |
-
.mptt-list-event {
|
346 |
-
list-style: none;
|
347 |
-
margin-bottom: 2rem;
|
348 |
-
padding: 0 0 0 2rem;
|
349 |
-
border-left: 3px solid @default_color;
|
350 |
-
|
351 |
-
.mptt-event-title {
|
352 |
-
margin: 0.25rem 0 0;
|
353 |
-
padding: 0;
|
354 |
-
}
|
355 |
-
.timeslot,
|
356 |
-
.event-user {
|
357 |
-
margin: 0.25rem 0 0;
|
358 |
-
padding: 0;
|
359 |
-
}
|
360 |
-
.event-subtitle {
|
361 |
-
margin: 0.25rem 0 0;
|
362 |
-
padding: 0;
|
363 |
-
hyphens: auto;
|
364 |
-
}
|
365 |
-
.event-description {
|
366 |
-
margin: 0.25rem 0 0;
|
367 |
-
padding: 0;
|
368 |
-
hyphens: auto;
|
369 |
-
}
|
370 |
-
.event-user {
|
371 |
-
margin: 0.25rem 0 0;
|
372 |
-
padding: 0;
|
373 |
-
.avatar {
|
374 |
-
border-radius: 50%;
|
375 |
-
margin-right: 3px;
|
376 |
-
display: inline-block;
|
377 |
-
vertical-align: middle;
|
378 |
-
}
|
379 |
-
}
|
380 |
-
}
|
381 |
-
}
|
382 |
-
}
|
383 |
-
}
|
384 |
-
|
385 |
-
&.mptt-table-fixed {
|
386 |
-
overflow-x: scroll;
|
387 |
-
.mptt-shortcode-table {
|
388 |
-
table-layout: auto;
|
389 |
-
}
|
390 |
-
thead, tbody {
|
391 |
-
width: 100%;
|
392 |
-
}
|
393 |
-
}
|
394 |
-
|
395 |
-
td{
|
396 |
-
vertical-align: middle;
|
397 |
-
}
|
398 |
-
}
|
399 |
-
|
400 |
-
/* ====== Shortcode end ====== */
|
401 |
-
|
402 |
-
/* ====== Media start ===== */
|
403 |
-
@media (max-width: 767px) {
|
404 |
-
|
405 |
-
.mptt-main-wrapper {
|
406 |
-
.mptt-content {
|
407 |
-
padding: 0 2rem 2rem;
|
408 |
-
width: 100%;
|
409 |
-
}
|
410 |
-
.mptt-sidebar {
|
411 |
-
padding: 0 2rem 2rem;
|
412 |
-
width: 100%;
|
413 |
-
}
|
414 |
-
}
|
415 |
-
|
416 |
-
.mptt-shortcode-wrapper {
|
417 |
-
.mptt-shortcode-list {
|
418 |
-
display: block;
|
419 |
-
}
|
420 |
-
|
421 |
-
&.mptt-table-fixed {
|
422 |
-
.mptt-shortcode-list {
|
423 |
-
display: none !important;;
|
424 |
-
}
|
425 |
-
.mptt-shortcode-table {
|
426 |
-
display: table;
|
427 |
-
td.event {
|
428 |
-
min-width: 200px;
|
429 |
-
}
|
430 |
-
}
|
431 |
-
}
|
432 |
-
&.mptt-table-responsive {
|
433 |
-
.mptt-shortcode-table {
|
434 |
-
display: none !important;
|
435 |
-
}
|
436 |
-
}
|
437 |
-
}
|
438 |
-
}
|
439 |
-
|
440 |
-
.mptt-clearfix {
|
441 |
-
*zoom: 1;
|
442 |
-
&:before,
|
443 |
-
&:after {
|
444 |
-
display: table;
|
445 |
-
content: "";
|
446 |
-
line-height: 0;
|
447 |
-
}
|
448 |
-
&:after {
|
449 |
-
clear: both;
|
450 |
-
}
|
451 |
-
}
|
452 |
-
|
453 |
-
.twentysixteen {
|
454 |
-
&.mptt-shortcode-wrapper {
|
455 |
-
.event-title {
|
456 |
-
box-shadow: none;
|
457 |
-
}
|
458 |
-
}
|
459 |
-
}
|
460 |
-
|
461 |
-
.mptt-theme-mode-event.event {
|
462 |
-
.event-user img {
|
463 |
-
position: relative;
|
464 |
-
}
|
465 |
-
}
|
466 |
-
|
467 |
-
.twentyfifteen {
|
468 |
-
&.mptt-shortcode-wrapper {
|
469 |
-
.event-title {
|
470 |
-
border-bottom: none;
|
471 |
-
}
|
472 |
-
}
|
473 |
-
}
|
474 |
-
|
475 |
-
.twentyfourteen {
|
476 |
-
.mptt-content {
|
477 |
-
width: 100%;
|
478 |
-
margin: 0;
|
479 |
-
}
|
480 |
-
}
|
1 |
+
@default_color: #3b5998;
|
2 |
+
|
3 |
+
@import 'theme.less';
|
4 |
+
//@import "no-js";
|
5 |
+
.mptt-main-wrapper {
|
6 |
+
&.mp-event-item {
|
7 |
+
img:not(.avatar ) {
|
8 |
+
width: 100%;
|
9 |
+
height: auto;
|
10 |
+
}
|
11 |
+
}
|
12 |
+
.mptt-content {
|
13 |
+
width: 66.999%;
|
14 |
+
margin-right: 3%;
|
15 |
+
float: left;
|
16 |
+
}
|
17 |
+
.mptt-sidebar {
|
18 |
+
width: 30%;
|
19 |
+
float: left;
|
20 |
+
}
|
21 |
+
|
22 |
+
.event-title {
|
23 |
+
margin: 0 0 2rem;
|
24 |
+
}
|
25 |
+
.thumbnail-wrapper {
|
26 |
+
margin-bottom: 1rem;
|
27 |
+
}
|
28 |
+
.event-content {
|
29 |
+
margin: 1rem 0;
|
30 |
+
}
|
31 |
+
.timeslots-title {
|
32 |
+
margin: 1rem 0;
|
33 |
+
}
|
34 |
+
.mptt-event.events-list {
|
35 |
+
margin: 0 0 1rem 2rem;
|
36 |
+
list-style: none;
|
37 |
+
padding: 0;
|
38 |
+
|
39 |
+
.event {
|
40 |
+
list-style: outside;
|
41 |
+
padding: 1rem;
|
42 |
+
|
43 |
+
.event-title {
|
44 |
+
margin: 0.25rem 0 0;
|
45 |
+
padding: 0;
|
46 |
+
}
|
47 |
+
.event-subtitle {
|
48 |
+
margin: 0.25rem 0 0;
|
49 |
+
padding: 0;
|
50 |
+
}
|
51 |
+
.timeslot,
|
52 |
+
.event-user {
|
53 |
+
margin: 0.25rem 0 0;
|
54 |
+
padding: 0;
|
55 |
+
}
|
56 |
+
.event-description {
|
57 |
+
margin: 0.25rem 0 0;
|
58 |
+
padding: 0;
|
59 |
+
hyphens: auto;
|
60 |
+
}
|
61 |
+
.event-user {
|
62 |
+
.avatar {
|
63 |
+
border-radius: 50%;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
.event:last-child {
|
68 |
+
margin-bottom: 0;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
.column-title {
|
73 |
+
margin: 0 0 2rem 0;
|
74 |
+
}
|
75 |
+
.column-content {
|
76 |
+
margin: 1rem 0;
|
77 |
+
}
|
78 |
+
.mptt-column.events-list {
|
79 |
+
margin: 0 0 2rem 0;
|
80 |
+
list-style: none;
|
81 |
+
padding: 0;
|
82 |
+
.event {
|
83 |
+
list-style: none;
|
84 |
+
padding: 1rem;
|
85 |
+
|
86 |
+
.event-thumbnail {
|
87 |
+
float: left;
|
88 |
+
margin: 0 2rem 2rem 0;
|
89 |
+
}
|
90 |
+
.event-title {
|
91 |
+
clear: none;
|
92 |
+
margin: 0 0 0.25rem 0;
|
93 |
+
padding: 0;
|
94 |
+
}
|
95 |
+
.event-subtitle {
|
96 |
+
margin: 0.25rem 0 0;
|
97 |
+
padding: 0;
|
98 |
+
}
|
99 |
+
.timeslot,
|
100 |
+
.event-user {
|
101 |
+
margin: 0.25rem 0 0;
|
102 |
+
padding: 0;
|
103 |
+
}
|
104 |
+
.event-description {
|
105 |
+
margin: 0.25rem 0 0;
|
106 |
+
padding: 0;
|
107 |
+
hyphens: auto;
|
108 |
+
}
|
109 |
+
.event-user {
|
110 |
+
.avatar {
|
111 |
+
border-radius: 50%;
|
112 |
+
}
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
|
118 |
+
.upcoming-events-widget {
|
119 |
+
margin-top: 2rem;
|
120 |
+
.mptt-widget.events-list {
|
121 |
+
list-style: none;
|
122 |
+
margin: 0;
|
123 |
+
padding: 0;
|
124 |
+
.event {
|
125 |
+
list-style: none;
|
126 |
+
margin-bottom: 2rem;
|
127 |
+
padding: 0.5rem 2rem;
|
128 |
+
border: none;
|
129 |
+
border-left: 3px solid @default_color;
|
130 |
+
|
131 |
+
.event-title {
|
132 |
+
margin: 0 0 0.25rem 0;
|
133 |
+
padding: 0;
|
134 |
+
}
|
135 |
+
.column-title {
|
136 |
+
margin: 0.25rem 0 0;
|
137 |
+
padding: 0;
|
138 |
+
}
|
139 |
+
.timeslot,
|
140 |
+
.event-user {
|
141 |
+
margin: 0.25rem 0 0;
|
142 |
+
padding: 0;
|
143 |
+
}
|
144 |
+
&.mptt-colorized {
|
145 |
+
.event-title {
|
146 |
+
margin: 0 0 0.25rem 0;
|
147 |
+
padding: 0;
|
148 |
+
color: inherit;
|
149 |
+
|
150 |
+
.event-link {
|
151 |
+
color: inherit;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
.mptt-hidden {
|
160 |
+
display: none;
|
161 |
+
opacity: 0;
|
162 |
+
clear: both;
|
163 |
+
}
|
164 |
+
|
165 |
+
.mprm_ie_browser {
|
166 |
+
.mptt-inner-event-content {
|
167 |
+
width: 100%;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
.mptt-container {
|
172 |
+
list-style: none;
|
173 |
+
}
|
174 |
+
|
175 |
+
/*====== Widget End ======*/
|
176 |
+
|
177 |
+
/* ====== Shortcode start ====== */
|
178 |
+
.mptt-shortcode-wrapper {
|
179 |
+
.mptt-shortcode-event {
|
180 |
+
.mptt-event-container {
|
181 |
+
display: flex;
|
182 |
+
flex-direction: column;
|
183 |
+
&:hover {
|
184 |
+
//min-height: 100%;
|
185 |
+
display: flex;
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
&.mptt-event-vertical-top {
|
190 |
+
.mptt-event-container {
|
191 |
+
justify-content: flex-start;
|
192 |
+
align-content: flex-start;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
&.mptt-event-vertical-middle {
|
196 |
+
.mptt-event-container {
|
197 |
+
justify-content: center;
|
198 |
+
align-content: center;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
&.mptt-event-vertical-bottom {
|
202 |
+
.mptt-event-container {
|
203 |
+
justify-content: flex-end;
|
204 |
+
align-content: flex-end;
|
205 |
+
}
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
.mptt-shortcode-table {
|
210 |
+
margin-top: 1rem;
|
211 |
+
tr.mptt-shortcode-row {
|
212 |
+
th {
|
213 |
+
background-color: #f0f0f0;
|
214 |
+
border: 1px solid #ffffff;
|
215 |
+
text-align: center;
|
216 |
+
color: #404040;
|
217 |
+
padding: 0.25rem 1rem;
|
218 |
+
overflow-wrap: normal;
|
219 |
+
hyphens: none;
|
220 |
+
}
|
221 |
+
|
222 |
+
}
|
223 |
+
tbody {
|
224 |
+
tr:nth-child(2n+2) {
|
225 |
+
background-color: #f0f0f0;
|
226 |
+
}
|
227 |
+
td {
|
228 |
+
position: relative;
|
229 |
+
border: 1px solid #ffffff;
|
230 |
+
padding: 0;
|
231 |
+
line-height: normal;
|
232 |
+
box-sizing: initial;
|
233 |
+
&.event {
|
234 |
+
background-color: @default_color;
|
235 |
+
}
|
236 |
+
&.mptt-shortcode-hours {
|
237 |
+
padding: 0 1rem !important;
|
238 |
+
white-space: nowrap;
|
239 |
+
width: 1%;
|
240 |
+
vertical-align: middle;
|
241 |
+
}
|
242 |
+
}
|
243 |
+
.mptt-event-container {
|
244 |
+
position: absolute;
|
245 |
+
top: 0;
|
246 |
+
right: 0;
|
247 |
+
left: 0;
|
248 |
+
z-index: 3;
|
249 |
+
overflow: hidden;
|
250 |
+
outline: 1px solid #fff;
|
251 |
+
color: inherit;
|
252 |
+
/*word-break: break-all;
|
253 |
+
word-wrap: break-word;*/
|
254 |
+
|
255 |
+
&:hover {
|
256 |
+
background-color: inherit;
|
257 |
+
overflow: visible;
|
258 |
+
z-index: 10;
|
259 |
+
.event-title {
|
260 |
+
text-decoration: underline;
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
p {
|
265 |
+
color: inherit;
|
266 |
+
}
|
267 |
+
|
268 |
+
.event-title {
|
269 |
+
color: inherit;
|
270 |
+
display: inline-block;
|
271 |
+
margin: 0.5rem 0.25rem 0.25rem 0.25rem;
|
272 |
+
text-decoration: none;
|
273 |
+
font-size: 1.1em;
|
274 |
+
//word-break: break-all;
|
275 |
+
}
|
276 |
+
.event-subtitle {
|
277 |
+
margin: 0.25rem;
|
278 |
+
font-size: 0.8em;
|
279 |
+
}
|
280 |
+
.event-user {
|
281 |
+
margin: 0.25rem;
|
282 |
+
font-size: 0.8em;
|
283 |
+
.avatar {
|
284 |
+
border-radius: 50%;
|
285 |
+
margin-right: 3px;
|
286 |
+
display: inline-block;
|
287 |
+
vertical-align: middle;
|
288 |
+
}
|
289 |
+
}
|
290 |
+
.event-description {
|
291 |
+
font-size: 0.8em;
|
292 |
+
margin: 0.25rem;
|
293 |
+
hyphens: auto;
|
294 |
+
}
|
295 |
+
.timeslot {
|
296 |
+
font-size: 0.9em;
|
297 |
+
margin: 0.25rem;
|
298 |
+
}
|
299 |
+
}
|
300 |
+
}
|
301 |
+
|
302 |
+
&.mptt-theme-mode tbody {
|
303 |
+
tr:nth-child(2n+2) {
|
304 |
+
td.event {
|
305 |
+
background-color: inherit;
|
306 |
+
}
|
307 |
+
}
|
308 |
+
td.event {
|
309 |
+
background-color: #ffffff;
|
310 |
+
|
311 |
+
.event-user img {
|
312 |
+
position: relative;
|
313 |
+
}
|
314 |
+
}
|
315 |
+
}
|
316 |
+
&.mptt-table-layout-auto {
|
317 |
+
table-layout: auto;
|
318 |
+
}
|
319 |
+
&.mptt-table-layout-fixed {
|
320 |
+
table-layout: fixed;
|
321 |
+
}
|
322 |
+
}
|
323 |
+
.mptt-navigation-tabs {
|
324 |
+
margin: 0 0 1rem;
|
325 |
+
list-style-type: none;
|
326 |
+
li {
|
327 |
+
|
328 |
+
display: inline-block;
|
329 |
+
padding: 0.25rem 0.5rem 0.25rem 0;
|
330 |
+
}
|
331 |
+
}
|
332 |
+
.mptt-shortcode-list {
|
333 |
+
display: none;
|
334 |
+
|
335 |
+
.mptt-column {
|
336 |
+
margin: 2rem 0;
|
337 |
+
.mptt-column-title {
|
338 |
+
margin: 2rem 0;
|
339 |
+
}
|
340 |
+
|
341 |
+
.mptt-events-list {
|
342 |
+
list-style: none;
|
343 |
+
margin: 2rem;
|
344 |
+
padding: 0;
|
345 |
+
.mptt-list-event {
|
346 |
+
list-style: none;
|
347 |
+
margin-bottom: 2rem;
|
348 |
+
padding: 0 0 0 2rem;
|
349 |
+
border-left: 3px solid @default_color;
|
350 |
+
|
351 |
+
.mptt-event-title {
|
352 |
+
margin: 0.25rem 0 0;
|
353 |
+
padding: 0;
|
354 |
+
}
|
355 |
+
.timeslot,
|
356 |
+
.event-user {
|
357 |
+
margin: 0.25rem 0 0;
|
358 |
+
padding: 0;
|
359 |
+
}
|
360 |
+
.event-subtitle {
|
361 |
+
margin: 0.25rem 0 0;
|
362 |
+
padding: 0;
|
363 |
+
hyphens: auto;
|
364 |
+
}
|
365 |
+
.event-description {
|
366 |
+
margin: 0.25rem 0 0;
|
367 |
+
padding: 0;
|
368 |
+
hyphens: auto;
|
369 |
+
}
|
370 |
+
.event-user {
|
371 |
+
margin: 0.25rem 0 0;
|
372 |
+
padding: 0;
|
373 |
+
.avatar {
|
374 |
+
border-radius: 50%;
|
375 |
+
margin-right: 3px;
|
376 |
+
display: inline-block;
|
377 |
+
vertical-align: middle;
|
378 |
+
}
|
379 |
+
}
|
380 |
+
}
|
381 |
+
}
|
382 |
+
}
|
383 |
+
}
|
384 |
+
|
385 |
+
&.mptt-table-fixed {
|
386 |
+
overflow-x: scroll;
|
387 |
+
.mptt-shortcode-table {
|
388 |
+
table-layout: auto;
|
389 |
+
}
|
390 |
+
thead, tbody {
|
391 |
+
width: 100%;
|
392 |
+
}
|
393 |
+
}
|
394 |
+
|
395 |
+
td{
|
396 |
+
vertical-align: middle;
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
/* ====== Shortcode end ====== */
|
401 |
+
|
402 |
+
/* ====== Media start ===== */
|
403 |
+
@media (max-width: 767px) {
|
404 |
+
|
405 |
+
.mptt-main-wrapper {
|
406 |
+
.mptt-content {
|
407 |
+
padding: 0 2rem 2rem;
|
408 |
+
width: 100%;
|
409 |
+
}
|
410 |
+
.mptt-sidebar {
|
411 |
+
padding: 0 2rem 2rem;
|
412 |
+
width: 100%;
|
413 |
+
}
|
414 |
+
}
|
415 |
+
|
416 |
+
.mptt-shortcode-wrapper {
|
417 |
+
.mptt-shortcode-list {
|
418 |
+
display: block;
|
419 |
+
}
|
420 |
+
|
421 |
+
&.mptt-table-fixed {
|
422 |
+
.mptt-shortcode-list {
|
423 |
+
display: none !important;;
|
424 |
+
}
|
425 |
+
.mptt-shortcode-table {
|
426 |
+
display: table;
|
427 |
+
td.event {
|
428 |
+
min-width: 200px;
|
429 |
+
}
|
430 |
+
}
|
431 |
+
}
|
432 |
+
&.mptt-table-responsive {
|
433 |
+
.mptt-shortcode-table {
|
434 |
+
display: none !important;
|
435 |
+
}
|
436 |
+
}
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
.mptt-clearfix {
|
441 |
+
*zoom: 1;
|
442 |
+
&:before,
|
443 |
+
&:after {
|
444 |
+
display: table;
|
445 |
+
content: "";
|
446 |
+
line-height: 0;
|
447 |
+
}
|
448 |
+
&:after {
|
449 |
+
clear: both;
|
450 |
+
}
|
451 |
+
}
|
452 |
+
|
453 |
+
.twentysixteen {
|
454 |
+
&.mptt-shortcode-wrapper {
|
455 |
+
.event-title {
|
456 |
+
box-shadow: none;
|
457 |
+
}
|
458 |
+
}
|
459 |
+
}
|
460 |
+
|
461 |
+
.mptt-theme-mode-event.event {
|
462 |
+
.event-user img {
|
463 |
+
position: relative;
|
464 |
+
}
|
465 |
+
}
|
466 |
+
|
467 |
+
.twentyfifteen {
|
468 |
+
&.mptt-shortcode-wrapper {
|
469 |
+
.event-title {
|
470 |
+
border-bottom: none;
|
471 |
+
}
|
472 |
+
}
|
473 |
+
}
|
474 |
+
|
475 |
+
.twentyfourteen {
|
476 |
+
.mptt-content {
|
477 |
+
width: 100%;
|
478 |
+
margin: 0;
|
479 |
+
}
|
480 |
+
}
|
media/less/theme.less
CHANGED
@@ -1,162 +1,162 @@
|
|
1 |
-
/**
|
2 |
-
* Twenty Fourteen specific styles
|
3 |
-
*/
|
4 |
-
.twentyfourteen {
|
5 |
-
.tfmp {
|
6 |
-
padding: 12px 10px 0;
|
7 |
-
max-width: 474px;
|
8 |
-
margin: 0 auto;
|
9 |
-
|
10 |
-
div.product.hentry.has-post-thumbnail {
|
11 |
-
margin-top: 0;
|
12 |
-
}
|
13 |
-
|
14 |
-
}
|
15 |
-
}
|
16 |
-
|
17 |
-
.twentyeleven {
|
18 |
-
}
|
19 |
-
|
20 |
-
.twentytwelve {
|
21 |
-
|
22 |
-
}
|
23 |
-
|
24 |
-
.twentythirteen {
|
25 |
-
h1 {
|
26 |
-
margin: 0;
|
27 |
-
}
|
28 |
-
ul {
|
29 |
-
padding: 0;
|
30 |
-
}
|
31 |
-
}
|
32 |
-
|
33 |
-
@media screen and (min-width: 673px) {
|
34 |
-
.twentyfourteen {
|
35 |
-
.tfmp {
|
36 |
-
padding-right: 30px;
|
37 |
-
padding-left: 30px;
|
38 |
-
}
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
-
@media screen and (min-width: 1040px) {
|
43 |
-
.twentyfourteen {
|
44 |
-
.tfmp {
|
45 |
-
padding-right: 15px;
|
46 |
-
padding-left: 15px;
|
47 |
-
}
|
48 |
-
}
|
49 |
-
}
|
50 |
-
|
51 |
-
@media screen and (min-width: 1110px) {
|
52 |
-
.twentyfourteen {
|
53 |
-
.tfmp {
|
54 |
-
padding-right: 30px;
|
55 |
-
padding-left: 30px;
|
56 |
-
}
|
57 |
-
}
|
58 |
-
}
|
59 |
-
|
60 |
-
@media screen and (min-width: 1218px) {
|
61 |
-
.twentyfourteen {
|
62 |
-
.tfmp {
|
63 |
-
margin-right: 54px;
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
.full-width {
|
68 |
-
.twentyfourteen {
|
69 |
-
.tfmp {
|
70 |
-
margin-right: auto;
|
71 |
-
}
|
72 |
-
}
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* Twenty Fifteen specific styles
|
78 |
-
*/
|
79 |
-
.twentyfifteen {
|
80 |
-
.t15mp {
|
81 |
-
padding-left: 7.6923%;
|
82 |
-
padding-right: 7.6923%;
|
83 |
-
padding-top: 7.6923%;
|
84 |
-
margin-bottom: 7.6923%;
|
85 |
-
background: #fff;
|
86 |
-
box-shadow: 0 0 1px rgba(0, 0, 0, 0.15);
|
87 |
-
}
|
88 |
-
.mptt-sidebar .widget.mptt-container {
|
89 |
-
padding: 0;
|
90 |
-
}
|
91 |
-
}
|
92 |
-
|
93 |
-
@media screen and (min-width: 38.75em) {
|
94 |
-
.twentyfifteen {
|
95 |
-
.t15mp {
|
96 |
-
margin-right: 7.6923%;
|
97 |
-
margin-left: 7.6923%;
|
98 |
-
margin-top: 8.3333%;
|
99 |
-
}
|
100 |
-
}
|
101 |
-
}
|
102 |
-
|
103 |
-
@media screen and (min-width: 59.6875em) {
|
104 |
-
.twentyfifteen {
|
105 |
-
.t15mp {
|
106 |
-
margin-left: 8.3333%;
|
107 |
-
margin-right: 8.3333%;
|
108 |
-
padding: 10%;
|
109 |
-
}
|
110 |
-
}
|
111 |
-
|
112 |
-
.single-product {
|
113 |
-
.twentyfifteen {
|
114 |
-
.entry-summary {
|
115 |
-
padding: 0 !important;
|
116 |
-
}
|
117 |
-
}
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Twenty Sixteen specific styles
|
123 |
-
*/
|
124 |
-
.twentysixteen {
|
125 |
-
.site-main {
|
126 |
-
margin-right: 7.6923%;
|
127 |
-
margin-left: 7.6923%;
|
128 |
-
}
|
129 |
-
|
130 |
-
.entry-summary {
|
131 |
-
margin-right: 0;
|
132 |
-
margin-left: 0;
|
133 |
-
}
|
134 |
-
}
|
135 |
-
|
136 |
-
@media screen and (min-width: 44.375em) {
|
137 |
-
.twentysixteen {
|
138 |
-
.site-main {
|
139 |
-
margin-right: 23.0769%;
|
140 |
-
}
|
141 |
-
}
|
142 |
-
}
|
143 |
-
|
144 |
-
@media screen and (min-width: 56.875em) {
|
145 |
-
.twentysixteen {
|
146 |
-
.site-main {
|
147 |
-
margin-right: 0;
|
148 |
-
margin-left: 0;
|
149 |
-
}
|
150 |
-
}
|
151 |
-
}
|
152 |
-
|
153 |
-
/* theme styles */
|
154 |
-
.mptt-column {
|
155 |
-
.event[id^="event_columns_"] {
|
156 |
-
overflow: auto;
|
157 |
-
}
|
158 |
-
}
|
159 |
-
|
160 |
-
.mptt-theme-mode-event.event {
|
161 |
-
overflow: auto;
|
162 |
}
|
1 |
+
/**
|
2 |
+
* Twenty Fourteen specific styles
|
3 |
+
*/
|
4 |
+
.twentyfourteen {
|
5 |
+
.tfmp {
|
6 |
+
padding: 12px 10px 0;
|
7 |
+
max-width: 474px;
|
8 |
+
margin: 0 auto;
|
9 |
+
|
10 |
+
div.product.hentry.has-post-thumbnail {
|
11 |
+
margin-top: 0;
|
12 |
+
}
|
13 |
+
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
.twentyeleven {
|
18 |
+
}
|
19 |
+
|
20 |
+
.twentytwelve {
|
21 |
+
|
22 |
+
}
|
23 |
+
|
24 |
+
.twentythirteen {
|
25 |
+
h1 {
|
26 |
+
margin: 0;
|
27 |
+
}
|
28 |
+
ul {
|
29 |
+
padding: 0;
|
30 |
+
}
|
31 |
+
}
|
32 |
+
|
33 |
+
@media screen and (min-width: 673px) {
|
34 |
+
.twentyfourteen {
|
35 |
+
.tfmp {
|
36 |
+
padding-right: 30px;
|
37 |
+
padding-left: 30px;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
@media screen and (min-width: 1040px) {
|
43 |
+
.twentyfourteen {
|
44 |
+
.tfmp {
|
45 |
+
padding-right: 15px;
|
46 |
+
padding-left: 15px;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
@media screen and (min-width: 1110px) {
|
52 |
+
.twentyfourteen {
|
53 |
+
.tfmp {
|
54 |
+
padding-right: 30px;
|
55 |
+
padding-left: 30px;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
@media screen and (min-width: 1218px) {
|
61 |
+
.twentyfourteen {
|
62 |
+
.tfmp {
|
63 |
+
margin-right: 54px;
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
.full-width {
|
68 |
+
.twentyfourteen {
|
69 |
+
.tfmp {
|
70 |
+
margin-right: auto;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Twenty Fifteen specific styles
|
78 |
+
*/
|
79 |
+
.twentyfifteen {
|
80 |
+
.t15mp {
|
81 |
+
padding-left: 7.6923%;
|
82 |
+
padding-right: 7.6923%;
|
83 |
+
padding-top: 7.6923%;
|
84 |
+
margin-bottom: 7.6923%;
|
85 |
+
background: #fff;
|
86 |
+
box-shadow: 0 0 1px rgba(0, 0, 0, 0.15);
|
87 |
+
}
|
88 |
+
.mptt-sidebar .widget.mptt-container {
|
89 |
+
padding: 0;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
@media screen and (min-width: 38.75em) {
|
94 |
+
.twentyfifteen {
|
95 |
+
.t15mp {
|
96 |
+
margin-right: 7.6923%;
|
97 |
+
margin-left: 7.6923%;
|
98 |
+
margin-top: 8.3333%;
|
99 |
+
}
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
@media screen and (min-width: 59.6875em) {
|
104 |
+
.twentyfifteen {
|
105 |
+
.t15mp {
|
106 |
+
margin-left: 8.3333%;
|
107 |
+
margin-right: 8.3333%;
|
108 |
+
padding: 10%;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
.single-product {
|
113 |
+
.twentyfifteen {
|
114 |
+
.entry-summary {
|
115 |
+
padding: 0 !important;
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Twenty Sixteen specific styles
|
123 |
+
*/
|
124 |
+
.twentysixteen {
|
125 |
+
.site-main {
|
126 |
+
margin-right: 7.6923%;
|
127 |
+
margin-left: 7.6923%;
|
128 |
+
}
|
129 |
+
|
130 |
+
.entry-summary {
|
131 |
+
margin-right: 0;
|
132 |
+
margin-left: 0;
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
@media screen and (min-width: 44.375em) {
|
137 |
+
.twentysixteen {
|
138 |
+
.site-main {
|
139 |
+
margin-right: 23.0769%;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
@media screen and (min-width: 56.875em) {
|
145 |
+
.twentysixteen {
|
146 |
+
.site-main {
|
147 |
+
margin-right: 0;
|
148 |
+
margin-left: 0;
|
149 |
+
}
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
/* theme styles */
|
154 |
+
.mptt-column {
|
155 |
+
.event[id^="event_columns_"] {
|
156 |
+
overflow: auto;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
.mptt-theme-mode-event.event {
|
161 |
+
overflow: auto;
|
162 |
}
|
mp-timetable.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Timetable and Event Schedule
|
5 |
* Plugin URI: https://motopress.com/products/timetable-event-schedule/
|
6 |
* Description: Smart time-management tool with a clean minimalist design for featuring your timetables and upcoming events.
|
7 |
-
* Version: 2.3.
|
8 |
* Author: MotoPress
|
9 |
* Author URI: https://motopress.com
|
10 |
* License: GPLv2 or later
|
@@ -130,6 +130,11 @@ class Mp_Time_Table {
|
|
130 |
* Include blocks
|
131 |
*/
|
132 |
require_once self::get_plugin_path() . 'classes/blocks/class-timetable-block.php';
|
|
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
|
135 |
/**
|
@@ -270,4 +275,5 @@ class Mp_Time_Table {
|
|
270 |
static function get_plugin_url( $path = false, $pluginName = 'mp-timetable', $sync = '' ) {
|
271 |
return plugins_url() . '/' . $pluginName . '/' . $path . $sync;
|
272 |
}
|
|
|
273 |
}
|
4 |
* Plugin Name: Timetable and Event Schedule
|
5 |
* Plugin URI: https://motopress.com/products/timetable-event-schedule/
|
6 |
* Description: Smart time-management tool with a clean minimalist design for featuring your timetables and upcoming events.
|
7 |
+
* Version: 2.3.16
|
8 |
* Author: MotoPress
|
9 |
* Author URI: https://motopress.com
|
10 |
* License: GPLv2 or later
|
130 |
* Include blocks
|
131 |
*/
|
132 |
require_once self::get_plugin_path() . 'classes/blocks/class-timetable-block.php';
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Include Widgets Managers
|
136 |
+
*/
|
137 |
+
require_once self::get_plugin_path() . 'classes/class-widgets-manager.php';
|
138 |
}
|
139 |
|
140 |
/**
|
275 |
static function get_plugin_url( $path = false, $pluginName = 'mp-timetable', $sync = '' ) {
|
276 |
return plugins_url() . '/' . $pluginName . '/' . $path . $sync;
|
277 |
}
|
278 |
+
|
279 |
}
|
readme.txt
CHANGED
@@ -66,13 +66,15 @@ Want to take automatic online appointment reservations through your website for
|
|
66 |
|
67 |
== Copyright ==
|
68 |
|
69 |
-
Timetable and Event Schedule plugin, Copyright (C)
|
70 |
Timetable and Event Schedule plugin is distributed under the terms of the GNU GPL.
|
71 |
|
72 |
== Screenshots ==
|
73 |
1. Timetable
|
74 |
2. Column
|
75 |
3. Timeslots
|
|
|
|
|
76 |
|
77 |
== Credits ==
|
78 |
|
@@ -87,162 +89,13 @@ Plugin bundles the following third-party resources:
|
|
87 |
|
88 |
== Changelog ==
|
89 |
|
90 |
-
= 2.3.
|
91 |
-
*
|
92 |
|
93 |
-
= 2.3.
|
94 |
-
*
|
95 |
-
*
|
96 |
|
97 |
-
|
98 |
-
* Improved compatibility with WordPress 5.6.
|
99 |
|
100 |
-
|
101 |
-
* Added the ability to duplicate events.
|
102 |
-
* Added the ability to set table layout fixed or auto.
|
103 |
-
* Bug fix: fixed an issue with an empty categories list in the widget.
|
104 |
-
|
105 |
-
= 2.3.10, Apr 24 2020 =
|
106 |
-
* Bug fix: fixed an issue when a user with the Editor role could not access the administration area.
|
107 |
-
* Improved compatibility with PHP 7.4.
|
108 |
-
|
109 |
-
= 2.3.9, Apr 21 2020 =
|
110 |
-
* Added the ability to sort events in the dropdown list or tabs.
|
111 |
-
* Improved user capability check.
|
112 |
-
|
113 |
-
= 2.3.8, Apr 1 2020 =
|
114 |
-
* Bug fix: fixed an issue with the missing Event tags field.
|
115 |
-
* Bug fix: fixed an issue when a user with the read capability could access a Help menu page.
|
116 |
-
|
117 |
-
= 2.3.7, Mar 10 2020 =
|
118 |
-
* Bug fix: fixed an issue with the erroneous positioning of events.
|
119 |
-
|
120 |
-
= 2.3.6, Feb 19 2020 =
|
121 |
-
* Bug fix: fixed an issue with the missing subtitle in mobile view.
|
122 |
-
|
123 |
-
= 2.3.5, Feb 19 2020 =
|
124 |
-
* Bug fix: fixed an issue with slashes in event description.
|
125 |
-
|
126 |
-
= 2.3.4, Sep 25 2019 =
|
127 |
-
* Bug fix: fixed an issue with UTC timezone offset.
|
128 |
-
|
129 |
-
= 2.3.3, Sep 20 2019 =
|
130 |
-
* Bug fix: fixed the issue with events disappearing on hover in Chrome.
|
131 |
-
|
132 |
-
= 2.3.2 =
|
133 |
-
* Bug fix: fixed an issue in IE browser.
|
134 |
-
|
135 |
-
= 2.3.1 =
|
136 |
-
* Bug fix: fixed the issue with opening PHP tag.
|
137 |
-
|
138 |
-
= 2.3.0 =
|
139 |
-
* Added support for WordPress 5.0.
|
140 |
-
|
141 |
-
= 2.2.1 =
|
142 |
-
* Bug fix: fixed an issue with URL hash (not-set:all).
|
143 |
-
|
144 |
-
= 2.2.0 =
|
145 |
-
* Added filters for register_post_type and register_taxonomy functions.
|
146 |
-
* Added permalink configuration option in Settings > Permalinks.
|
147 |
-
|
148 |
-
= 2.1.12 =
|
149 |
-
* Bug fix: fixed an issue in IE browser.
|
150 |
-
|
151 |
-
= 2.1.11 =
|
152 |
-
* Added translations into the Persian language.
|
153 |
-
|
154 |
-
= 2.1.10 =
|
155 |
-
* Improved compatibility with WooCommerce Memberships plugin.
|
156 |
-
* Better W3C validation.
|
157 |
-
|
158 |
-
= 2.1.9 =
|
159 |
-
* Bug fix: fixed the issue when event was not visible in the timetable if it starts at 00:00.
|
160 |
-
|
161 |
-
= 2.1.8 =
|
162 |
-
* Improved compatibility with javascript-disabled browsers.
|
163 |
-
|
164 |
-
= 2.1.7 =
|
165 |
-
* Bug fix: fixed the issue when events were not filtered by the selected category in a widget.
|
166 |
-
* Bug fix: fixed the issue when event was not visible in the timetable if it ends the next day.
|
167 |
-
* Minor bugfixes and improvements.
|
168 |
-
|
169 |
-
= 2.1.6 =
|
170 |
-
* New dashboard icons.
|
171 |
-
|
172 |
-
= 2.1.5 =
|
173 |
-
* Bug fix: fixed the issue when table is not visible if events filter is set to 'none'.
|
174 |
-
|
175 |
-
= 2.1.4 =
|
176 |
-
* Bug fix: fixed internal issue.
|
177 |
-
|
178 |
-
= 2.1.3 =
|
179 |
-
* Added the ability to merge cells with common events.
|
180 |
-
* Added the ability to set vertical alignment in the table.
|
181 |
-
* Added the ability to set custom CSS class for table shortcode.
|
182 |
-
* Added the ability to hide filter control on the top of the table.
|
183 |
-
* Bug fix: fixed the issue when table ID didn't output on the site.
|
184 |
-
|
185 |
-
= 2.1.2 =
|
186 |
-
* Bug fix: fixed the issue when plugin overrides default archive template.
|
187 |
-
* Bug fix: fixed the issue in upcoming events widget when events were not sorted by days.
|
188 |
-
|
189 |
-
= 2.1.1 =
|
190 |
-
* Bug fix: fixed the issue with shortcode tempalte.
|
191 |
-
|
192 |
-
= 2.1.0 =
|
193 |
-
* Added the ability to override templates in a theme.
|
194 |
-
* Bug fix: fixed the issue on WordPress multisite when Event wasn't saving.
|
195 |
-
* Bug fix: fixed the issue when timeslots didn't show if Event is in the Draft status.
|
196 |
-
|
197 |
-
= 2.0.4 =
|
198 |
-
* Bug fix: fixed an issue with post template on search results page.
|
199 |
-
|
200 |
-
= 2.0.3 =
|
201 |
-
* Bug fix: fixed a link to create new column from event screen.
|
202 |
-
* Improved usernames in Event Head dropdown.
|
203 |
-
|
204 |
-
= 2.0.2 =
|
205 |
-
* Minor bugfixes and improvements.
|
206 |
-
|
207 |
-
= 2.0.1 =
|
208 |
-
* Bug fix: fixed an issue with template override.
|
209 |
-
|
210 |
-
= 2.0.0 =
|
211 |
-
* We improved compatibility with your theme styles in this update. If you still stick to a previous version, simply change the template mode option in the plugin settings.
|
212 |
-
* Added the ability to set font size for timetable shortcode so you can make your text bigger or smaller.
|
213 |
-
|
214 |
-
= 1.1.6 =
|
215 |
-
* Bug fix: fixed an issue with empty rows.
|
216 |
-
|
217 |
-
= 1.1.5 =
|
218 |
-
* Bug fix: fixed an issue with post view in search results.
|
219 |
-
|
220 |
-
= 1.1.4 =
|
221 |
-
* Improved compatibility with Polylang plugin.
|
222 |
-
|
223 |
-
= 1.1.3 =
|
224 |
-
* Fixed an issue with categories filter in widget.
|
225 |
-
|
226 |
-
= 1.1.2 =
|
227 |
-
* Fixed an issue with posts order.
|
228 |
-
|
229 |
-
= 1.1.0 =
|
230 |
-
* Improved events sorting.
|
231 |
-
* Minor bugfixes and improvements.
|
232 |
-
|
233 |
-
= 1.0.7 =
|
234 |
-
* Improved events and columns sorting by date.
|
235 |
-
* Comments section added to event.
|
236 |
-
* Minor bugfixes and improvements.
|
237 |
-
|
238 |
-
= 1.0.6 =
|
239 |
-
* Fixed an issue in column view.
|
240 |
-
|
241 |
-
= 1.0.5 =
|
242 |
-
* Improved compatibility with IE10+
|
243 |
-
|
244 |
-
= 1.0.4 =
|
245 |
-
* Minor bugfixes and improvements.
|
246 |
-
|
247 |
-
= 1.0.3 =
|
248 |
-
* Minor bugfixes and improvements.
|
66 |
|
67 |
== Copyright ==
|
68 |
|
69 |
+
Timetable and Event Schedule plugin, Copyright (C) 2016, MotoPress https://motopress.com/
|
70 |
Timetable and Event Schedule plugin is distributed under the terms of the GNU GPL.
|
71 |
|
72 |
== Screenshots ==
|
73 |
1. Timetable
|
74 |
2. Column
|
75 |
3. Timeslots
|
76 |
+
4. Elementor Widget
|
77 |
+
5. Gutenberg Block
|
78 |
|
79 |
== Credits ==
|
80 |
|
89 |
|
90 |
== Changelog ==
|
91 |
|
92 |
+
= 2.3.16, Feb 18 2021 =
|
93 |
+
* Bug fix: fixed PHP parse error in PHP 7.2.
|
94 |
|
95 |
+
= 2.3.15, Feb 17 2021 =
|
96 |
+
* Added Timetable Elementor widget.
|
97 |
+
* Bug fix: fixed an issue with invalid XML file while exporting data.
|
98 |
|
99 |
+
--------
|
|
|
100 |
|
101 |
+
[See the previous changelogs here](https://plugins.svn.wordpress.org/mp-timetable/trunk/changelog.txt).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
templates-functions/action-mp-column-functions.php
CHANGED
@@ -1,80 +1,80 @@
|
|
1 |
-
<?php
|
2 |
-
use mp_timetable\classes\controllers\Controller_Column;
|
3 |
-
|
4 |
-
function mptt_column_template_content_title() { ?>
|
5 |
-
<h1 class="column-title"><?php the_title(); ?></h1>
|
6 |
-
<?php }
|
7 |
-
|
8 |
-
function mptt_column_template_content_post_content() { ?>
|
9 |
-
<div class="column-content">
|
10 |
-
<?php the_content(); ?>
|
11 |
-
</div>
|
12 |
-
<?php }
|
13 |
-
|
14 |
-
function mptt_column_template_content_events_list() {
|
15 |
-
$events = mptt_get_column_events();
|
16 |
-
do_action('mptt-before-column-events', $events);
|
17 |
-
?>
|
18 |
-
<ul class="mptt-column <?php echo apply_filters('mptt_events_list_class', 'events-list') ?>">
|
19 |
-
<?php foreach ($events as $event): ?>
|
20 |
-
<li class="event" id="event_columns_<?php echo $event->event_id ?>">
|
21 |
-
|
22 |
-
<?php if (has_post_thumbnail($event->event_id)) {
|
23 |
-
|
24 |
-
echo wp_get_attachment_image(
|
25 |
-
get_post_thumbnail_id($event->event_id),
|
26 |
-
apply_filters('mptt_event_thumbnail_size', 'thumbnail'),
|
27 |
-
false,
|
28 |
-
array('class' => "alignleft event-thumbnail", 'alt' => get_the_title($event->event_id))
|
29 |
-
);
|
30 |
-
|
31 |
-
} else { ?>
|
32 |
-
<img class="event-thumbnail event-thumbnail-default"
|
33 |
-
src="<?php echo Mp_Time_Table::get_plugin_url() . 'media/css/images/column_icon.png' ?>"
|
34 |
-
alt="<?php echo get_the_title($event->event_id); ?>">
|
35 |
-
<?php } ?>
|
36 |
-
|
37 |
-
<h4 class="event-title">
|
38 |
-
<a href="<?php echo $event->post->timetable_disable_url == '1' ? '#' : ($event->post->timetable_custom_url != "" ? $event->post->timetable_custom_url : get_permalink($event->event_id)) ?>"
|
39 |
-
class="event-link">
|
40 |
-
<?php echo get_the_title($event->event_id); ?>
|
41 |
-
</a>
|
42 |
-
</h4>
|
43 |
-
|
44 |
-
<p class="timeslot">
|
45 |
-
<time datetime="<?php echo $event->event_start; ?>"
|
46 |
-
class="timeslot-start"><?php echo date(get_option('time_format'), strtotime($event->event_start)); ?></time><?php echo apply_filters('mptt_timeslot_delimiter', ' - '); ?>
|
47 |
-
<time datetime="<?php echo $event->event_end; ?>" class="timeslot-end"><?php echo date(get_option('time_format'), strtotime($event->event_end)); ?></time>
|
48 |
-
</p>
|
49 |
-
|
50 |
-
<?php if (!empty($event->post->sub_title)) { ?>
|
51 |
-
<p class="event-subtitle"><?php echo $event->post->sub_title ?></p>
|
52 |
-
<?php } ?>
|
53 |
-
|
54 |
-
<?php if (!empty($event->description)) { ?>
|
55 |
-
<p class="event-description"><?php echo stripslashes( $event->description ); ?></p>
|
56 |
-
<?php } ?>
|
57 |
-
|
58 |
-
<?php if (!empty($event->user)) { ?>
|
59 |
-
<p class="event-user"><a href="<?php echo get_author_posts_url($event->user->ID); ?>"
|
60 |
-
title="<?php the_title_attribute(array('post' => $event->event_id)); ?>"><?php echo get_avatar($event->user->ID, apply_filters('mptt-column-user-avatar-size', 32), '', $event->user->display_name); ?>
|
61 |
-
<?php echo $event->user->display_name ?></a></p>
|
62 |
-
<?php } ?>
|
63 |
-
<div class="mptt-clearfix"></div>
|
64 |
-
</li>
|
65 |
-
<?php endforeach; ?>
|
66 |
-
</ul>
|
67 |
-
<?php
|
68 |
-
do_action('mptt-after-column-events', $events);
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Get column events
|
73 |
-
*
|
74 |
-
* @return array
|
75 |
-
*/
|
76 |
-
function mptt_get_column_events() {
|
77 |
-
global $post;
|
78 |
-
$data = Controller_Column::get_instance()->action_page_view($post);
|
79 |
-
return !empty($data) ? $data : array();
|
80 |
}
|
1 |
+
<?php
|
2 |
+
use mp_timetable\classes\controllers\Controller_Column;
|
3 |
+
|
4 |
+
function mptt_column_template_content_title() { ?>
|
5 |
+
<h1 class="column-title"><?php the_title(); ?></h1>
|
6 |
+
<?php }
|
7 |
+
|
8 |
+
function mptt_column_template_content_post_content() { ?>
|
9 |
+
<div class="column-content">
|
10 |
+
<?php the_content(); ?>
|
11 |
+
</div>
|
12 |
+
<?php }
|
13 |
+
|
14 |
+
function mptt_column_template_content_events_list() {
|
15 |
+
$events = mptt_get_column_events();
|
16 |
+
do_action('mptt-before-column-events', $events);
|
17 |
+
?>
|
18 |
+
<ul class="mptt-column <?php echo apply_filters('mptt_events_list_class', 'events-list') ?>">
|
19 |
+
<?php foreach ($events as $event): ?>
|
20 |
+
<li class="event" id="event_columns_<?php echo $event->event_id ?>">
|
21 |
+
|
22 |
+
<?php if (has_post_thumbnail($event->event_id)) {
|
23 |
+
|
24 |
+
echo wp_get_attachment_image(
|
25 |
+
get_post_thumbnail_id($event->event_id),
|
26 |
+
apply_filters('mptt_event_thumbnail_size', 'thumbnail'),
|
27 |
+
false,
|
28 |
+
array('class' => "alignleft event-thumbnail", 'alt' => get_the_title($event->event_id))
|
29 |
+
);
|
30 |
+
|
31 |
+
} else { ?>
|
32 |
+
<img class="event-thumbnail event-thumbnail-default"
|
33 |
+
src="<?php echo Mp_Time_Table::get_plugin_url() . 'media/css/images/column_icon.png' ?>"
|
34 |
+
alt="<?php echo get_the_title($event->event_id); ?>">
|
35 |
+
<?php } ?>
|
36 |
+
|
37 |
+
<h4 class="event-title">
|
38 |
+
<a href="<?php echo $event->post->timetable_disable_url == '1' ? '#' : ($event->post->timetable_custom_url != "" ? $event->post->timetable_custom_url : get_permalink($event->event_id)) ?>"
|
39 |
+
class="event-link">
|
40 |
+
<?php echo get_the_title($event->event_id); ?>
|
41 |
+
</a>
|
42 |
+
</h4>
|
43 |
+
|
44 |
+
<p class="timeslot">
|
45 |
+
<time datetime="<?php echo $event->event_start; ?>"
|
46 |
+
class="timeslot-start"><?php echo date(get_option('time_format'), strtotime($event->event_start)); ?></time><?php echo apply_filters('mptt_timeslot_delimiter', ' - '); ?>
|
47 |
+
<time datetime="<?php echo $event->event_end; ?>" class="timeslot-end"><?php echo date(get_option('time_format'), strtotime($event->event_end)); ?></time>
|
48 |
+
</p>
|
49 |
+
|
50 |
+
<?php if (!empty($event->post->sub_title)) { ?>
|
51 |
+
<p class="event-subtitle"><?php echo $event->post->sub_title ?></p>
|
52 |
+
<?php } ?>
|
53 |
+
|
54 |
+
<?php if (!empty($event->description)) { ?>
|
55 |
+
<p class="event-description"><?php echo stripslashes( $event->description ); ?></p>
|
56 |
+
<?php } ?>
|
57 |
+
|
58 |
+
<?php if (!empty($event->user)) { ?>
|
59 |
+
<p class="event-user"><a href="<?php echo get_author_posts_url($event->user->ID); ?>"
|
60 |
+
title="<?php the_title_attribute(array('post' => $event->event_id)); ?>"><?php echo get_avatar($event->user->ID, apply_filters('mptt-column-user-avatar-size', 32), '', $event->user->display_name); ?>
|
61 |
+
<?php echo $event->user->display_name ?></a></p>
|
62 |
+
<?php } ?>
|
63 |
+
<div class="mptt-clearfix"></div>
|
64 |
+
</li>
|
65 |
+
<?php endforeach; ?>
|
66 |
+
</ul>
|
67 |
+
<?php
|
68 |
+
do_action('mptt-after-column-events', $events);
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Get column events
|
73 |
+
*
|
74 |
+
* @return array
|
75 |
+
*/
|
76 |
+
function mptt_get_column_events() {
|
77 |
+
global $post;
|
78 |
+
$data = Controller_Column::get_instance()->action_page_view($post);
|
79 |
+
return !empty($data) ? $data : array();
|
80 |
}
|
templates-functions/action-shortcode-functions.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
use mp_timetable\classes\models\Settings;
|
3 |
use mp_timetable\plugin_core\classes\View;
|
4 |
|
@@ -7,10 +8,12 @@ use mp_timetable\plugin_core\classes\View;
|
|
7 |
*/
|
8 |
function mptt_shortcode_template_before_content() {
|
9 |
global $mptt_shortcode_data;
|
|
|
10 |
$wrapper_class = mptt_popular_theme_class();
|
11 |
$id = empty( $mptt_shortcode_data[ 'params' ][ 'id' ] ) ? '' : $mptt_shortcode_data[ 'params' ][ 'id' ];
|
|
|
12 |
?>
|
13 |
-
|
14 |
<?php
|
15 |
}
|
16 |
|
@@ -119,18 +122,19 @@ function mptt_shortcode_template_event( $mptt_shortcode_data, $post = 'all' ) {
|
|
119 |
$table_class .= Settings::get_instance()->is_plugin_template_mode() ? '' : ' mptt-theme-mode';
|
120 |
|
121 |
$table_layout = $params['table_layout'];
|
|
|
122 |
if ( !empty($table_layout) && ($table_layout == 'fixed' || $table_layout == 'auto') ) {
|
123 |
$table_class .= ' mptt-table-layout-' . $table_layout;
|
124 |
}
|
125 |
|
126 |
$data_grouped_by_row = mptt_make_data_shortcode( $bounds, $mptt_shortcode_data, $column_events );
|
127 |
-
|
128 |
?>
|
129 |
<table class="<?php echo ! empty( $table_class ) ? $table_class : ''; ?>" id="#<?php echo is_object( $post ) ? $post->post_name : $post; ?>" style="display:none; <?php echo $font_size; ?>" data-hide_empty_row="<?php echo $hide_empty_rows; ?>">
|
130 |
<?php echo View::get_instance()->get_template_html( 'shortcodes/table-header', array( 'header_items' => $data_grouped_by_row[ 'table_header' ], 'params' => $params ) ); ?>
|
131 |
<tbody>
|
132 |
<?php if ( isset( $data_grouped_by_row[ 'rows' ] ) && is_array( $data_grouped_by_row[ 'rows' ] ) ) {
|
133 |
-
|
134 |
foreach ( $data_grouped_by_row[ 'rows' ] as $row_key => $row ) {
|
135 |
if ( ! $row[ 'show' ] && $params[ 'hide_empty_rows' ] ) {
|
136 |
continue;
|
@@ -151,7 +155,6 @@ function mptt_shortcode_template_event( $mptt_shortcode_data, $post = 'all' ) {
|
|
151 |
$height = 100 / count( $cell[ 'events' ] );
|
152 |
$top = 0;
|
153 |
foreach ( $cell[ 'events' ] as $event ) {
|
154 |
-
|
155 |
if ( ! empty( $event[ 'id' ] ) && filter_var( $event[ 'id' ], FILTER_VALIDATE_INT ) ) {
|
156 |
View::get_instance()->get_template( 'shortcodes/event-container', array( 'item' => $event, 'params' => $params, 'height' => $height, 'top' => $top ) );
|
157 |
$top += $height;
|
@@ -206,7 +209,7 @@ function mptt_shortcode_row_has_items( $i, $column_events ) {
|
|
206 |
*/
|
207 |
function mptt_shortcode_get_table_cell_bounds( $column_events, $params ) {
|
208 |
$hide_empty_rows = $params[ 'hide_empty_rows' ];
|
209 |
-
|
210 |
if ( $hide_empty_rows ) {
|
211 |
$min = - 1;
|
212 |
$max = - 1;
|
@@ -224,7 +227,7 @@ function mptt_shortcode_get_table_cell_bounds( $column_events, $params ) {
|
|
224 |
$min = 0;
|
225 |
$max = 23 / $params[ 'increment' ];
|
226 |
}
|
227 |
-
|
228 |
return array( 'start' => $min, 'end' => $max );
|
229 |
}
|
230 |
|
@@ -618,7 +621,7 @@ function mptt_get_columns_events( $mptt_shortcode_data, $post ) {
|
|
618 |
function mptt_check_exists_column( $needle, $events ) {
|
619 |
$exist = false;
|
620 |
$const_available_difference = 1;
|
621 |
-
|
622 |
foreach ( $events as $key => $event ) {
|
623 |
$difference_data = array_diff( $needle, $event );
|
624 |
if ( isset( $difference_data[ 'id' ] ) && ( count( $difference_data ) === $const_available_difference ) ) {
|
@@ -626,7 +629,7 @@ function mptt_check_exists_column( $needle, $events ) {
|
|
626 |
break;
|
627 |
}
|
628 |
}
|
629 |
-
|
630 |
return $exist;
|
631 |
}
|
632 |
|
1 |
<?php
|
2 |
+
|
3 |
use mp_timetable\classes\models\Settings;
|
4 |
use mp_timetable\plugin_core\classes\View;
|
5 |
|
8 |
*/
|
9 |
function mptt_shortcode_template_before_content() {
|
10 |
global $mptt_shortcode_data;
|
11 |
+
|
12 |
$wrapper_class = mptt_popular_theme_class();
|
13 |
$id = empty( $mptt_shortcode_data[ 'params' ][ 'id' ] ) ? '' : $mptt_shortcode_data[ 'params' ][ 'id' ];
|
14 |
+
|
15 |
?>
|
16 |
+
<div <?php if ( !empty($id) ) echo 'id="' . $id . '" '; ?>class="<?php echo apply_filters( 'mptt_shortcode_wrapper_class', 'mptt-shortcode-wrapper' . $wrapper_class . ( $mptt_shortcode_data[ 'params' ][ 'responsive' ] == '0' ? ' mptt-table-fixed' : ' mptt-table-responsive' ) ) ?>">
|
17 |
<?php
|
18 |
}
|
19 |
|
122 |
$table_class .= Settings::get_instance()->is_plugin_template_mode() ? '' : ' mptt-theme-mode';
|
123 |
|
124 |
$table_layout = $params['table_layout'];
|
125 |
+
|
126 |
if ( !empty($table_layout) && ($table_layout == 'fixed' || $table_layout == 'auto') ) {
|
127 |
$table_class .= ' mptt-table-layout-' . $table_layout;
|
128 |
}
|
129 |
|
130 |
$data_grouped_by_row = mptt_make_data_shortcode( $bounds, $mptt_shortcode_data, $column_events );
|
131 |
+
|
132 |
?>
|
133 |
<table class="<?php echo ! empty( $table_class ) ? $table_class : ''; ?>" id="#<?php echo is_object( $post ) ? $post->post_name : $post; ?>" style="display:none; <?php echo $font_size; ?>" data-hide_empty_row="<?php echo $hide_empty_rows; ?>">
|
134 |
<?php echo View::get_instance()->get_template_html( 'shortcodes/table-header', array( 'header_items' => $data_grouped_by_row[ 'table_header' ], 'params' => $params ) ); ?>
|
135 |
<tbody>
|
136 |
<?php if ( isset( $data_grouped_by_row[ 'rows' ] ) && is_array( $data_grouped_by_row[ 'rows' ] ) ) {
|
137 |
+
|
138 |
foreach ( $data_grouped_by_row[ 'rows' ] as $row_key => $row ) {
|
139 |
if ( ! $row[ 'show' ] && $params[ 'hide_empty_rows' ] ) {
|
140 |
continue;
|
155 |
$height = 100 / count( $cell[ 'events' ] );
|
156 |
$top = 0;
|
157 |
foreach ( $cell[ 'events' ] as $event ) {
|
|
|
158 |
if ( ! empty( $event[ 'id' ] ) && filter_var( $event[ 'id' ], FILTER_VALIDATE_INT ) ) {
|
159 |
View::get_instance()->get_template( 'shortcodes/event-container', array( 'item' => $event, 'params' => $params, 'height' => $height, 'top' => $top ) );
|
160 |
$top += $height;
|
209 |
*/
|
210 |
function mptt_shortcode_get_table_cell_bounds( $column_events, $params ) {
|
211 |
$hide_empty_rows = $params[ 'hide_empty_rows' ];
|
212 |
+
|
213 |
if ( $hide_empty_rows ) {
|
214 |
$min = - 1;
|
215 |
$max = - 1;
|
227 |
$min = 0;
|
228 |
$max = 23 / $params[ 'increment' ];
|
229 |
}
|
230 |
+
|
231 |
return array( 'start' => $min, 'end' => $max );
|
232 |
}
|
233 |
|
621 |
function mptt_check_exists_column( $needle, $events ) {
|
622 |
$exist = false;
|
623 |
$const_available_difference = 1;
|
624 |
+
|
625 |
foreach ( $events as $key => $event ) {
|
626 |
$difference_data = array_diff( $needle, $event );
|
627 |
if ( isset( $difference_data[ 'id' ] ) && ( count( $difference_data ) === $const_available_difference ) ) {
|
629 |
break;
|
630 |
}
|
631 |
}
|
632 |
+
|
633 |
return $exist;
|
634 |
}
|
635 |
|
templates-functions/action-widget-functions.php
CHANGED
@@ -1,56 +1,56 @@
|
|
1 |
-
<?php use mp_timetable\classes\models\Settings;
|
2 |
-
|
3 |
-
function mptt_widget_template_before_content() {
|
4 |
-
$wrapper_class = mptt_popular_theme_class();
|
5 |
-
if (Settings::get_instance()->is_plugin_template_mode()) {
|
6 |
-
?>
|
7 |
-
<div class="<?php echo apply_filters('mptt_widget_wrapper_class', 'upcoming-events-widget' . $wrapper_class) ?>">
|
8 |
-
<ul class="mptt-widget <?php echo apply_filters('mptt_events_list_class', 'events-list') ?>">
|
9 |
-
<?php
|
10 |
-
} else {
|
11 |
-
?>
|
12 |
-
<div class="widget_recent_entries <?php echo apply_filters('mptt_widget_theme_wrapper_class', 'theme-upcoming-events-widget' . $wrapper_class) ?>">
|
13 |
-
<ul class="mptt-widget <?php echo apply_filters('mptt_events_list_class', '') ?>">
|
14 |
-
<?php
|
15 |
-
}
|
16 |
-
}
|
17 |
-
|
18 |
-
function mptt_widget_template_after_content() { ?>
|
19 |
-
</ul>
|
20 |
-
</div>
|
21 |
-
<?php if(Settings::get_instance()->is_plugin_template_mode()):?>
|
22 |
-
<div class="mptt-clearfix"></div><?php
|
23 |
-
endif;
|
24 |
-
}
|
25 |
-
|
26 |
-
function mptt_widget_template_content() {
|
27 |
-
}
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Widget settings
|
31 |
-
*
|
32 |
-
* @param $params
|
33 |
-
*
|
34 |
-
* @return array
|
35 |
-
*/
|
36 |
-
function mptt_widget_settings($params) {
|
37 |
-
|
38 |
-
$params = shortcode_atts(array(
|
39 |
-
'title' => '',
|
40 |
-
'limit' => '3',
|
41 |
-
'view_settings' => 'today',
|
42 |
-
'next_days' => '1',
|
43 |
-
'time_settings' => '',
|
44 |
-
'mp_categories' => '',
|
45 |
-
'custom_url' => '',
|
46 |
-
'disable_url' => '',
|
47 |
-
'background_color' => '',
|
48 |
-
'hover_background_color' => '',
|
49 |
-
'text_color' => '',
|
50 |
-
'hover_text_color' => '',
|
51 |
-
'item_border_color' => '',
|
52 |
-
'hover_item_border_color' => '',
|
53 |
-
), $params);
|
54 |
-
|
55 |
-
return $params;
|
56 |
}
|
1 |
+
<?php use mp_timetable\classes\models\Settings;
|
2 |
+
|
3 |
+
function mptt_widget_template_before_content() {
|
4 |
+
$wrapper_class = mptt_popular_theme_class();
|
5 |
+
if (Settings::get_instance()->is_plugin_template_mode()) {
|
6 |
+
?>
|
7 |
+
<div class="<?php echo apply_filters('mptt_widget_wrapper_class', 'upcoming-events-widget' . $wrapper_class) ?>">
|
8 |
+
<ul class="mptt-widget <?php echo apply_filters('mptt_events_list_class', 'events-list') ?>">
|
9 |
+
<?php
|
10 |
+
} else {
|
11 |
+
?>
|
12 |
+
<div class="widget_recent_entries <?php echo apply_filters('mptt_widget_theme_wrapper_class', 'theme-upcoming-events-widget' . $wrapper_class) ?>">
|
13 |
+
<ul class="mptt-widget <?php echo apply_filters('mptt_events_list_class', '') ?>">
|
14 |
+
<?php
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
function mptt_widget_template_after_content() { ?>
|
19 |
+
</ul>
|
20 |
+
</div>
|
21 |
+
<?php if(Settings::get_instance()->is_plugin_template_mode()):?>
|
22 |
+
<div class="mptt-clearfix"></div><?php
|
23 |
+
endif;
|
24 |
+
}
|
25 |
+
|
26 |
+
function mptt_widget_template_content() {
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Widget settings
|
31 |
+
*
|
32 |
+
* @param $params
|
33 |
+
*
|
34 |
+
* @return array
|
35 |
+
*/
|
36 |
+
function mptt_widget_settings($params) {
|
37 |
+
|
38 |
+
$params = shortcode_atts(array(
|
39 |
+
'title' => '',
|
40 |
+
'limit' => '3',
|
41 |
+
'view_settings' => 'today',
|
42 |
+
'next_days' => '1',
|
43 |
+
'time_settings' => '',
|
44 |
+
'mp_categories' => '',
|
45 |
+
'custom_url' => '',
|
46 |
+
'disable_url' => '',
|
47 |
+
'background_color' => '',
|
48 |
+
'hover_background_color' => '',
|
49 |
+
'text_color' => '',
|
50 |
+
'hover_text_color' => '',
|
51 |
+
'item_border_color' => '',
|
52 |
+
'hover_item_border_color' => '',
|
53 |
+
), $params);
|
54 |
+
|
55 |
+
return $params;
|
56 |
}
|
templates-functions/actions-mp-event-functions.php
CHANGED
@@ -1,202 +1,202 @@
|
|
1 |
-
<?php use mp_timetable\classes\models\Settings;
|
2 |
-
use mp_timetable\plugin_core\classes\Core;
|
3 |
-
|
4 |
-
function mptt_event_template_content_title() { ?>
|
5 |
-
<h1 class="event-title"><?php the_title() ?></h1>
|
6 |
-
<?php
|
7 |
-
}
|
8 |
-
|
9 |
-
function mptt_event_template_content_thumbnail() { ?>
|
10 |
-
<div class="thumbnail-wrapper">
|
11 |
-
<?php if (has_post_thumbnail()) {
|
12 |
-
the_post_thumbnail(apply_filters('mptt_event_template_content_thumbnail_size', 'large'), array('class' => "event-thumbnail"));
|
13 |
-
} ?>
|
14 |
-
</div>
|
15 |
-
<?php
|
16 |
-
}
|
17 |
-
|
18 |
-
function mptt_event_template_content_post_content() { ?>
|
19 |
-
<div class="event-content"><?php the_content(); ?></div>
|
20 |
-
<?php
|
21 |
-
}
|
22 |
-
|
23 |
-
function mptt_event_template_content_time_title() {
|
24 |
-
$count = count(mptt_get_event_data());
|
25 |
-
if (!empty($count)) {
|
26 |
-
?>
|
27 |
-
<h3 class="timeslots-title"><?php printf(__('Event Timeslots (%s)', 'mp-timetable'), $count); ?></h3>
|
28 |
-
<?php
|
29 |
-
}
|
30 |
-
}
|
31 |
-
|
32 |
-
function mptt_event_template_content_time_list() {
|
33 |
-
$events = mptt_get_event_data();
|
34 |
-
do_action('mptt-before-timeslots', $events);
|
35 |
-
?>
|
36 |
-
<ul class="mptt-event <?php echo apply_filters('mptt_events_list_class', 'events-list') ?>">
|
37 |
-
<?php foreach ($events as $event): ?>
|
38 |
-
<li class="event mptt-colorized" id="event_hours_<?php echo $event->event_id ?>">
|
39 |
-
|
40 |
-
<h4 class="event-title">
|
41 |
-
<a class="event-link" href="<?php echo get_permalink($event->column_id); ?>" title="<?php the_title_attribute(array('post' => $event->event_id)); ?>"><?php echo get_the_title($event->column_id); ?></a>
|
42 |
-
</h4>
|
43 |
-
<p class="timeslot">
|
44 |
-
<time datetime="<?php echo $event->event_start; ?>" class="timeslot-start"><?php
|
45 |
-
echo date(get_option('time_format'), strtotime($event->event_start)); ?></time><?php
|
46 |
-
echo apply_filters('mptt_timeslot_delimiter', ' - '); ?>
|
47 |
-
<time datetime="<?php echo $event->event_end; ?>" class="timeslot-end"><?php
|
48 |
-
echo date(get_option('time_format'), strtotime($event->event_end)); ?></time>
|
49 |
-
</p>
|
50 |
-
<?php if (!empty($event->post->sub_title)) { ?>
|
51 |
-
<p class="event-subtitle"><?php echo $event->post->sub_title; ?></p>
|
52 |
-
<?php } ?>
|
53 |
-
|
54 |
-
<?php if (!empty($event->description)) { ?>
|
55 |
-
<p class="event-description"><?php echo stripslashes( $event->description ); ?></p>
|
56 |
-
<?php } ?>
|
57 |
-
<?php if (!empty($event->user)) { ?>
|
58 |
-
<p class="event-user"><a href="<?php echo get_author_posts_url($event->user->ID); ?>" title="<?php echo $event->user->display_name; ?>"><?php echo get_avatar($event->user->ID, apply_filters('mptt-column-user-avatar-size', 32), '', $event->user->display_name) . ' ';
|
59 |
-
echo $event->user->display_name ?></a></p>
|
60 |
-
<?php } ?>
|
61 |
-
</li>
|
62 |
-
<?php endforeach; ?>
|
63 |
-
</ul>
|
64 |
-
<?php
|
65 |
-
do_action('mptt-after-timeslots', $events);
|
66 |
-
}
|
67 |
-
|
68 |
-
function mptt_event_template_content_comments() {
|
69 |
-
// If comments are open or we have at least one comment, load up the comment template.
|
70 |
-
if (comments_open() || get_comments_number()) {
|
71 |
-
comments_template();
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Get post event data
|
77 |
-
*
|
78 |
-
* @return array
|
79 |
-
*/
|
80 |
-
function mptt_get_event_data() {
|
81 |
-
global $post;
|
82 |
-
$data = Core::get_instance()->get_controller('events')->get_all_event_by_post($post);
|
83 |
-
return !empty($data) ? $data : array();
|
84 |
-
}
|
85 |
-
|
86 |
-
function mptt_theme_wrapper_before() {
|
87 |
-
$template = get_option('template');
|
88 |
-
switch ($template) {
|
89 |
-
case 'twentyeleven' :
|
90 |
-
echo '<div id="primary"><div id="content" role="main" class="twentyeleven">';
|
91 |
-
break;
|
92 |
-
case 'twentytwelve' :
|
93 |
-
echo '<div id="primary" class="site-content"><div id="content" role="main" class="twentytwelve">';
|
94 |
-
break;
|
95 |
-
case 'twentythirteen' :
|
96 |
-
echo '<div id="primary" class="site-content"><div id="content" role="main" class="entry-content twentythirteen">';
|
97 |
-
break;
|
98 |
-
case 'twentyfourteen' :
|
99 |
-
echo '<div id="primary" class="content-area"><div id="content" role="main" class="site-content twentyfourteen"><div class="tfmp">';
|
100 |
-
break;
|
101 |
-
case 'twentyfifteen' :
|
102 |
-
echo '<div id="primary" role="main" class="content-area twentyfifteen"><div id="main" class="site-main t15mp">';
|
103 |
-
break;
|
104 |
-
case 'twentysixteen' :
|
105 |
-
echo '<div id="primary" class="content-area twentysixteen"><main id="main" class="site-main" role="main">';
|
106 |
-
break;
|
107 |
-
default :
|
108 |
-
echo '<div id="container"><div id="content" role="main">';
|
109 |
-
break;
|
110 |
-
}
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Theme popular class
|
115 |
-
* @return string
|
116 |
-
*/
|
117 |
-
function mptt_popular_theme_class() {
|
118 |
-
$template = get_option('template');
|
119 |
-
|
120 |
-
switch ($template) {
|
121 |
-
case 'twentyeleven' :
|
122 |
-
$class = ' twentyeleven';
|
123 |
-
break;
|
124 |
-
case 'twentytwelve' :
|
125 |
-
$class = ' twentytwelve';
|
126 |
-
break;
|
127 |
-
case 'twentythirteen' :
|
128 |
-
$class = ' twentythirteen';
|
129 |
-
break;
|
130 |
-
case 'twentyfourteen' :
|
131 |
-
$class = ' twentyfourteen';
|
132 |
-
break;
|
133 |
-
case 'twentyfifteen' :
|
134 |
-
$class = ' twentyfifteen';
|
135 |
-
break;
|
136 |
-
case 'twentysixteen' :
|
137 |
-
$class = ' twentysixteen';
|
138 |
-
break;
|
139 |
-
default :
|
140 |
-
$class = '';
|
141 |
-
break;
|
142 |
-
}
|
143 |
-
return $class;
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* Filter post class
|
148 |
-
*
|
149 |
-
* @param $classes
|
150 |
-
* @param string $class
|
151 |
-
* @param string $post_id
|
152 |
-
*
|
153 |
-
* @return mixed
|
154 |
-
*/
|
155 |
-
function mptt_post_class($classes, $class = '', $post_id = '') {
|
156 |
-
|
157 |
-
if (!$post_id || !in_array(get_post_type($post_id), Core::get_instance()->post_types)) {
|
158 |
-
return $classes;
|
159 |
-
}
|
160 |
-
if ('mp-column' == get_post_type($post_id)) {
|
161 |
-
$classes[] = 'mp-column-item';
|
162 |
-
} elseif ('mp-event' == get_post_type($post_id)) {
|
163 |
-
$classes[] = 'mp-event-item';
|
164 |
-
}
|
165 |
-
if (!is_search() && is_single() && Settings::get_instance()->is_plugin_template_mode()) {
|
166 |
-
if (false !== ($key = array_search('hentry', $classes))) {
|
167 |
-
unset($classes[$key]);
|
168 |
-
}
|
169 |
-
}
|
170 |
-
|
171 |
-
return $classes;
|
172 |
-
}
|
173 |
-
|
174 |
-
function mptt_theme_wrapper_after() {
|
175 |
-
|
176 |
-
$template = get_option('template');
|
177 |
-
|
178 |
-
switch ($template) {
|
179 |
-
case 'twentyeleven' :
|
180 |
-
echo '</div></div>';
|
181 |
-
break;
|
182 |
-
case 'twentytwelve' :
|
183 |
-
echo '</div></div>';
|
184 |
-
break;
|
185 |
-
case 'twentythirteen' :
|
186 |
-
echo '</div></div>';
|
187 |
-
break;
|
188 |
-
case 'twentyfourteen' :
|
189 |
-
echo '</div></div></div>';
|
190 |
-
get_sidebar('content');
|
191 |
-
break;
|
192 |
-
case 'twentyfifteen' :
|
193 |
-
echo '</div></div>';
|
194 |
-
break;
|
195 |
-
case 'twentysixteen' :
|
196 |
-
echo '</div></main>';
|
197 |
-
break;
|
198 |
-
default :
|
199 |
-
echo '</div></div>';
|
200 |
-
break;
|
201 |
-
}
|
202 |
}
|
1 |
+
<?php use mp_timetable\classes\models\Settings;
|
2 |
+
use mp_timetable\plugin_core\classes\Core;
|
3 |
+
|
4 |
+
function mptt_event_template_content_title() { ?>
|
5 |
+
<h1 class="event-title"><?php the_title() ?></h1>
|
6 |
+
<?php
|
7 |
+
}
|
8 |
+
|
9 |
+
function mptt_event_template_content_thumbnail() { ?>
|
10 |
+
<div class="thumbnail-wrapper">
|
11 |
+
<?php if (has_post_thumbnail()) {
|
12 |
+
the_post_thumbnail(apply_filters('mptt_event_template_content_thumbnail_size', 'large'), array('class' => "event-thumbnail"));
|
13 |
+
} ?>
|
14 |
+
</div>
|
15 |
+
<?php
|
16 |
+
}
|
17 |
+
|
18 |
+
function mptt_event_template_content_post_content() { ?>
|
19 |
+
<div class="event-content"><?php the_content(); ?></div>
|
20 |
+
<?php
|
21 |
+
}
|
22 |
+
|
23 |
+
function mptt_event_template_content_time_title() {
|
24 |
+
$count = count(mptt_get_event_data());
|
25 |
+
if (!empty($count)) {
|
26 |
+
?>
|
27 |
+
<h3 class="timeslots-title"><?php printf(__('Event Timeslots (%s)', 'mp-timetable'), $count); ?></h3>
|
28 |
+
<?php
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
function mptt_event_template_content_time_list() {
|
33 |
+
$events = mptt_get_event_data();
|
34 |
+
do_action('mptt-before-timeslots', $events);
|
35 |
+
?>
|
36 |
+
<ul class="mptt-event <?php echo apply_filters('mptt_events_list_class', 'events-list') ?>">
|
37 |
+
<?php foreach ($events as $event): ?>
|
38 |
+
<li class="event mptt-colorized" id="event_hours_<?php echo $event->event_id ?>">
|
39 |
+
|
40 |
+
<h4 class="event-title">
|
41 |
+
<a class="event-link" href="<?php echo get_permalink($event->column_id); ?>" title="<?php the_title_attribute(array('post' => $event->event_id)); ?>"><?php echo get_the_title($event->column_id); ?></a>
|
42 |
+
</h4>
|
43 |
+
<p class="timeslot">
|
44 |
+
<time datetime="<?php echo $event->event_start; ?>" class="timeslot-start"><?php
|
45 |
+
echo date(get_option('time_format'), strtotime($event->event_start)); ?></time><?php
|
46 |
+
echo apply_filters('mptt_timeslot_delimiter', ' - '); ?>
|
47 |
+
<time datetime="<?php echo $event->event_end; ?>" class="timeslot-end"><?php
|
48 |
+
echo date(get_option('time_format'), strtotime($event->event_end)); ?></time>
|
49 |
+
</p>
|
50 |
+
<?php if (!empty($event->post->sub_title)) { ?>
|
51 |
+
<p class="event-subtitle"><?php echo $event->post->sub_title; ?></p>
|
52 |
+
<?php } ?>
|
53 |
+
|
54 |
+
<?php if (!empty($event->description)) { ?>
|
55 |
+
<p class="event-description"><?php echo stripslashes( $event->description ); ?></p>
|
56 |
+
<?php } ?>
|
57 |
+
<?php if (!empty($event->user)) { ?>
|
58 |
+
<p class="event-user"><a href="<?php echo get_author_posts_url($event->user->ID); ?>" title="<?php echo $event->user->display_name; ?>"><?php echo get_avatar($event->user->ID, apply_filters('mptt-column-user-avatar-size', 32), '', $event->user->display_name) . ' ';
|
59 |
+
echo $event->user->display_name ?></a></p>
|
60 |
+
<?php } ?>
|
61 |
+
</li>
|
62 |
+
<?php endforeach; ?>
|
63 |
+
</ul>
|
64 |
+
<?php
|
65 |
+
do_action('mptt-after-timeslots', $events);
|
66 |
+
}
|
67 |
+
|
68 |
+
function mptt_event_template_content_comments() {
|
69 |
+
// If comments are open or we have at least one comment, load up the comment template.
|
70 |
+
if (comments_open() || get_comments_number()) {
|
71 |
+
comments_template();
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Get post event data
|
77 |
+
*
|
78 |
+
* @return array
|
79 |
+
*/
|
80 |
+
function mptt_get_event_data() {
|
81 |
+
global $post;
|
82 |
+
$data = Core::get_instance()->get_controller('events')->get_all_event_by_post($post);
|
83 |
+
return !empty($data) ? $data : array();
|
84 |
+
}
|
85 |
+
|
86 |
+
function mptt_theme_wrapper_before() {
|
87 |
+
$template = get_option('template');
|
88 |
+
switch ($template) {
|
89 |
+
case 'twentyeleven' :
|
90 |
+
echo '<div id="primary"><div id="content" role="main" class="twentyeleven">';
|
91 |
+
break;
|
92 |
+
case 'twentytwelve' :
|
93 |
+
echo '<div id="primary" class="site-content"><div id="content" role="main" class="twentytwelve">';
|
94 |
+
break;
|
95 |
+
case 'twentythirteen' :
|
96 |
+
echo '<div id="primary" class="site-content"><div id="content" role="main" class="entry-content twentythirteen">';
|
97 |
+
break;
|
98 |
+
case 'twentyfourteen' :
|
99 |
+
echo '<div id="primary" class="content-area"><div id="content" role="main" class="site-content twentyfourteen"><div class="tfmp">';
|
100 |
+
break;
|
101 |
+
case 'twentyfifteen' :
|
102 |
+
echo '<div id="primary" role="main" class="content-area twentyfifteen"><div id="main" class="site-main t15mp">';
|
103 |
+
break;
|
104 |
+
case 'twentysixteen' :
|
105 |
+
echo '<div id="primary" class="content-area twentysixteen"><main id="main" class="site-main" role="main">';
|
106 |
+
break;
|
107 |
+
default :
|
108 |
+
echo '<div id="container"><div id="content" role="main">';
|
109 |
+
break;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Theme popular class
|
115 |
+
* @return string
|
116 |
+
*/
|
117 |
+
function mptt_popular_theme_class() {
|
118 |
+
$template = get_option('template');
|
119 |
+
|
120 |
+
switch ($template) {
|
121 |
+
case 'twentyeleven' :
|
122 |
+
$class = ' twentyeleven';
|
123 |
+
break;
|
124 |
+
case 'twentytwelve' :
|
125 |
+
$class = ' twentytwelve';
|
126 |
+
break;
|
127 |
+
case 'twentythirteen' :
|
128 |
+
$class = ' twentythirteen';
|
129 |
+
break;
|
130 |
+
case 'twentyfourteen' :
|
131 |
+
$class = ' twentyfourteen';
|
132 |
+
break;
|
133 |
+
case 'twentyfifteen' :
|
134 |
+
$class = ' twentyfifteen';
|
135 |
+
break;
|
136 |
+
case 'twentysixteen' :
|
137 |
+
$class = ' twentysixteen';
|
138 |
+
break;
|
139 |
+
default :
|
140 |
+
$class = '';
|
141 |
+
break;
|
142 |
+
}
|
143 |
+
return $class;
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Filter post class
|
148 |
+
*
|
149 |
+
* @param $classes
|
150 |
+
* @param string $class
|
151 |
+
* @param string $post_id
|
152 |
+
*
|
153 |
+
* @return mixed
|
154 |
+
*/
|
155 |
+
function mptt_post_class($classes, $class = '', $post_id = '') {
|
156 |
+
|
157 |
+
if (!$post_id || !in_array(get_post_type($post_id), Core::get_instance()->post_types)) {
|
158 |
+
return $classes;
|
159 |
+
}
|
160 |
+
if ('mp-column' == get_post_type($post_id)) {
|
161 |
+
$classes[] = 'mp-column-item';
|
162 |
+
} elseif ('mp-event' == get_post_type($post_id)) {
|
163 |
+
$classes[] = 'mp-event-item';
|
164 |
+
}
|
165 |
+
if (!is_search() && is_single() && Settings::get_instance()->is_plugin_template_mode()) {
|
166 |
+
if (false !== ($key = array_search('hentry', $classes))) {
|
167 |
+
unset($classes[$key]);
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
return $classes;
|
172 |
+
}
|
173 |
+
|
174 |
+
function mptt_theme_wrapper_after() {
|
175 |
+
|
176 |
+
$template = get_option('template');
|
177 |
+
|
178 |
+
switch ($template) {
|
179 |
+
case 'twentyeleven' :
|
180 |
+
echo '</div></div>';
|
181 |
+
break;
|
182 |
+
case 'twentytwelve' :
|
183 |
+
echo '</div></div>';
|
184 |
+
break;
|
185 |
+
case 'twentythirteen' :
|
186 |
+
echo '</div></div>';
|
187 |
+
break;
|
188 |
+
case 'twentyfourteen' :
|
189 |
+
echo '</div></div></div>';
|
190 |
+
get_sidebar('content');
|
191 |
+
break;
|
192 |
+
case 'twentyfifteen' :
|
193 |
+
echo '</div></div>';
|
194 |
+
break;
|
195 |
+
case 'twentysixteen' :
|
196 |
+
echo '</div></main>';
|
197 |
+
break;
|
198 |
+
default :
|
199 |
+
echo '</div></div>';
|
200 |
+
break;
|
201 |
+
}
|
202 |
}
|
templates/column/metabox-column-options.php
CHANGED
@@ -1,56 +1,56 @@
|
|
1 |
-
<input type="hidden" name="<?php echo Mp_Time_Table::get_plugin_name() . '_noncename' ?>" value="<?php echo wp_create_nonce(Mp_Time_Table::get_plugin_path()) ?>"/>
|
2 |
-
<input type="hidden" id="date-format" value="<?php echo get_option('date_format') ?>">
|
3 |
-
|
4 |
-
<table id="column-options" class="column-options form-table">
|
5 |
-
|
6 |
-
<tr>
|
7 |
-
<td class="column-option">
|
8 |
-
<p>
|
9 |
-
<input class="option-input" value="simple" type="radio" name="column[column_option]" id="simple_column"
|
10 |
-
<?php echo ($post->column_option === 'simple' || empty($post->column_option)) ? 'checked="checked"' : '' ?>">
|
11 |
-
<label for="simple_column" class="option-label"><?php _e('Simple Column', 'mp-timetable') ?></label>
|
12 |
-
</p>
|
13 |
-
</td>
|
14 |
-
</tr>
|
15 |
-
<tr>
|
16 |
-
<td class="column-option">
|
17 |
-
<p>
|
18 |
-
<input class="option-input" value="weekday" type="radio" name="column[column_option]" id="mp_weekday"
|
19 |
-
<?php echo ($post->column_option === 'weekday') ? 'checked="checked"' : '' ?>>
|
20 |
-
<label for="mp_weekday" class="option-label"><?php _e('Day of the week', 'mp-timetable') ?></label>
|
21 |
-
</p>
|
22 |
-
<select class="option-select mp-weekday" name="column[weekday]" <?php echo ($post->column_option != 'weekday') ? 'disabled="disabled"' : '' ?>>
|
23 |
-
<option value=""><?php _e('- Select -', 'mp-timetable') ?></option>
|
24 |
-
<option value="sunday" <?php selected( $post->weekday, 'sunday' ); ?>><?php _e('Sunday', 'mp-timetable') ?></option>
|
25 |
-
<option value="monday" <?php selected( $post->weekday, 'monday' ); ?>><?php _e('Monday', 'mp-timetable') ?></option>
|
26 |
-
<option value="tuesday" <?php selected( $post->weekday, 'tuesday' ); ?>><?php _e('Tuesday', 'mp-timetable') ?></option>
|
27 |
-
<option value="wednesday" <?php selected( $post->weekday, 'wednesday' ); ?>><?php _e('Wednesday', 'mp-timetable') ?></option>
|
28 |
-
<option value="thursday" <?php selected( $post->weekday, 'thursday' ); ?>><?php _e('Thursday', 'mp-timetable') ?></option>
|
29 |
-
<option value="friday" <?php selected( $post->weekday, 'friday' ); ?>><?php _e('Friday', 'mp-timetable') ?></option>
|
30 |
-
<option value="saturday" <?php selected( $post->weekday, 'saturday' ); ?>><?php _e('Saturday', 'mp-timetable') ?></option>
|
31 |
-
</select>
|
32 |
-
</td>
|
33 |
-
</tr>
|
34 |
-
<tr>
|
35 |
-
<td class="column-option">
|
36 |
-
<p>
|
37 |
-
<input class="option-input" value="date" type="radio" name="column[column_option]" id="mp_date"
|
38 |
-
<?php echo ($post->column_option === 'date') ? 'checked="checked"' : '' ?>>
|
39 |
-
<label for="mp_date" class="option-label"><?php _e('Date', 'mp-timetable') ?></label>
|
40 |
-
</p>
|
41 |
-
<div class="column-datepick mp-date">
|
42 |
-
<?php
|
43 |
-
$datepicker_value = '';
|
44 |
-
if ( !empty($post->option_day) ) {
|
45 |
-
$datepicker_value = date('d/m/Y', strtotime(str_replace('/', '-', $post->option_day)));
|
46 |
-
}
|
47 |
-
?>
|
48 |
-
<input id="datepicker" class="option-input" type="text" name="column[option_day]"
|
49 |
-
value="<?php echo $datepicker_value ?>"
|
50 |
-
<?php echo ($post->column_option != 'date') ? 'disabled="disabled"' : '' ?>
|
51 |
-
placeholder="<?php echo date('d/m/Y', current_time( 'timestamp' ) ) ?>">
|
52 |
-
</div>
|
53 |
-
</td>
|
54 |
-
</tr>
|
55 |
-
|
56 |
</table>
|
1 |
+
<input type="hidden" name="<?php echo Mp_Time_Table::get_plugin_name() . '_noncename' ?>" value="<?php echo wp_create_nonce(Mp_Time_Table::get_plugin_path()) ?>"/>
|
2 |
+
<input type="hidden" id="date-format" value="<?php echo get_option('date_format') ?>">
|
3 |
+
|
4 |
+
<table id="column-options" class="column-options form-table">
|
5 |
+
|
6 |
+
<tr>
|
7 |
+
<td class="column-option">
|
8 |
+
<p>
|
9 |
+
<input class="option-input" value="simple" type="radio" name="column[column_option]" id="simple_column"
|
10 |
+
<?php echo ($post->column_option === 'simple' || empty($post->column_option)) ? 'checked="checked"' : '' ?>">
|
11 |
+
<label for="simple_column" class="option-label"><?php _e('Simple Column', 'mp-timetable') ?></label>
|
12 |
+
</p>
|
13 |
+
</td>
|
14 |
+
</tr>
|
15 |
+
<tr>
|
16 |
+
<td class="column-option">
|
17 |
+
<p>
|
18 |
+
<input class="option-input" value="weekday" type="radio" name="column[column_option]" id="mp_weekday"
|
19 |
+
<?php echo ($post->column_option === 'weekday') ? 'checked="checked"' : '' ?>>
|
20 |
+
<label for="mp_weekday" class="option-label"><?php _e('Day of the week', 'mp-timetable') ?></label>
|
21 |
+
</p>
|
22 |
+
<select class="option-select mp-weekday" name="column[weekday]" <?php echo ($post->column_option != 'weekday') ? 'disabled="disabled"' : '' ?>>
|
23 |
+
<option value=""><?php _e('- Select -', 'mp-timetable') ?></option>
|
24 |
+
<option value="sunday" <?php selected( $post->weekday, 'sunday' ); ?>><?php _e('Sunday', 'mp-timetable') ?></option>
|
25 |
+
<option value="monday" <?php selected( $post->weekday, 'monday' ); ?>><?php _e('Monday', 'mp-timetable') ?></option>
|
26 |
+
<option value="tuesday" <?php selected( $post->weekday, 'tuesday' ); ?>><?php _e('Tuesday', 'mp-timetable') ?></option>
|
27 |
+
<option value="wednesday" <?php selected( $post->weekday, 'wednesday' ); ?>><?php _e('Wednesday', 'mp-timetable') ?></option>
|
28 |
+
<option value="thursday" <?php selected( $post->weekday, 'thursday' ); ?>><?php _e('Thursday', 'mp-timetable') ?></option>
|
29 |
+
<option value="friday" <?php selected( $post->weekday, 'friday' ); ?>><?php _e('Friday', 'mp-timetable') ?></option>
|
30 |
+
<option value="saturday" <?php selected( $post->weekday, 'saturday' ); ?>><?php _e('Saturday', 'mp-timetable') ?></option>
|
31 |
+
</select>
|
32 |
+
</td>
|
33 |
+
</tr>
|
34 |
+
<tr>
|
35 |
+
<td class="column-option">
|
36 |
+
<p>
|
37 |
+
<input class="option-input" value="date" type="radio" name="column[column_option]" id="mp_date"
|
38 |
+
<?php echo ($post->column_option === 'date') ? 'checked="checked"' : '' ?>>
|
39 |
+
<label for="mp_date" class="option-label"><?php _e('Date', 'mp-timetable') ?></label>
|
40 |
+
</p>
|
41 |
+
<div class="column-datepick mp-date">
|
42 |
+
<?php
|
43 |
+
$datepicker_value = '';
|
44 |
+
if ( !empty($post->option_day) ) {
|
45 |
+
$datepicker_value = date('d/m/Y', strtotime(str_replace('/', '-', $post->option_day)));
|
46 |
+
}
|
47 |
+
?>
|
48 |
+
<input id="datepicker" class="option-input" type="text" name="column[option_day]"
|
49 |
+
value="<?php echo $datepicker_value ?>"
|
50 |
+
<?php echo ($post->column_option != 'date') ? 'disabled="disabled"' : '' ?>
|
51 |
+
placeholder="<?php echo date('d/m/Y', current_time( 'timestamp' ) ) ?>">
|
52 |
+
</div>
|
53 |
+
</td>
|
54 |
+
</tr>
|
55 |
+
|
56 |
</table>
|
templates/events/column-category.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
foreach ($terms as $term) {
|
4 |
-
?><a href="<?php echo get_term_link($term->term_id) ?>" rel="tag" title="<?php echo $term->name; ?>"><?php
|
5 |
-
echo $term->name ?></a><?php echo ($term !== end($terms)) ? ', ' : '' ?>
|
6 |
-
<?php
|
7 |
-
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
foreach ($terms as $term) {
|
4 |
+
?><a href="<?php echo get_term_link($term->term_id) ?>" rel="tag" title="<?php echo $term->name; ?>"><?php
|
5 |
+
echo $term->name ?></a><?php echo ($term !== end($terms)) ? ', ' : '' ?>
|
6 |
+
<?php
|
7 |
+
}
|
templates/events/metabox-event-options.php
CHANGED
@@ -1,50 +1,50 @@
|
|
1 |
-
<?php ?>
|
2 |
-
<table id="add_event_options_table" class="form-table">
|
3 |
-
<tr>
|
4 |
-
<td><label for="sub_title"><?php _e('Event Subtitle:', 'mp-timetable') ?></label></td>
|
5 |
-
<td><input id="sub_title" class="widefat" type="text" value="<?php echo esc_attr( $post->sub_title ); ?>" name="event_meta[sub_title]"></td>
|
6 |
-
</tr>
|
7 |
-
<tr class="select-color">
|
8 |
-
<td><label for="color"><?php _e('Background Color:', 'mp-timetable'); ?></label></td>
|
9 |
-
<td>
|
10 |
-
<input type="hidden" class="clr-picker" value="<?php echo esc_attr( $post->color ); ?>">
|
11 |
-
<input type="text" id="color" name="event_meta[color]" value="<?php echo esc_attr( $post->color ); ?>" data-default-color="transparent">
|
12 |
-
</td>
|
13 |
-
</tr>
|
14 |
-
<tr class="select-color">
|
15 |
-
<td><label for="hover_color"><?php _e('Background Hover Color:', 'mp-timetable'); ?></label></td>
|
16 |
-
<td>
|
17 |
-
<input type="hidden" class="clr-picker" value="<?php echo esc_attr( $post->hover_color ); ?>">
|
18 |
-
<input type="text" id="hover_color" name="event_meta[hover_color]" value="<?php echo esc_attr( $post->hover_color ); ?>" data-default-color="transparent">
|
19 |
-
</td>
|
20 |
-
</tr>
|
21 |
-
<tr class="select-color">
|
22 |
-
<td><label for="text_color"><?php _e('Text Color:', 'mp-timetable'); ?></label></td>
|
23 |
-
<td>
|
24 |
-
<input type="hidden" class="clr-picker" value="<?php echo esc_attr( $post->text_color ); ?>">
|
25 |
-
<input type="text" id="text_color" name="event_meta[text_color]" value="<?php echo esc_attr( $post->text_color ); ?>" data-default-color="transparent">
|
26 |
-
</td>
|
27 |
-
</tr>
|
28 |
-
<tr class="select-color">
|
29 |
-
<td><label for="hover_text_color"><?php _e('Text Hover Color:', 'mp-timetable'); ?></label></td>
|
30 |
-
<td>
|
31 |
-
<input type="hidden" class="clr-picker" value="<?php echo esc_attr( $post->hover_text_color ); ?>">
|
32 |
-
<input type="text" id="hover_text_color" name="event_meta[hover_text_color]" value="<?php echo esc_attr( $post->hover_text_color ); ?>" data-default-color="transparent">
|
33 |
-
</td>
|
34 |
-
</tr>
|
35 |
-
<tr>
|
36 |
-
<td><label for="timetable_custom_url"><?php _e('Custom Event URL:', 'mp-timetable'); ?></label></td>
|
37 |
-
<td>
|
38 |
-
<input type="text" id="timetable_custom_url" class="widefat" placeholder="http://mywebsite.com" name="event_meta[timetable_custom_url]" value="<?php echo esc_attr( $post->timetable_custom_url ); ?>">
|
39 |
-
</td>
|
40 |
-
</tr>
|
41 |
-
<tr>
|
42 |
-
<td><label for="select-disable-url"><?php _e('Disable link to this event:', 'mp-timetable'); ?></label></td>
|
43 |
-
<td>
|
44 |
-
<select id="select-disable-url" name="event_meta[timetable_disable_url]">
|
45 |
-
<option value="0" <?php echo !($post->timetable_disable_url) ? 'selected="selected"' : '' ?> ><?php _e('No', 'mp-timetable') ?></option>
|
46 |
-
<option value="1" <?php echo ($post->timetable_disable_url) ? 'selected="selected"' : '' ?>><?php _e('Yes', 'mp-timetable') ?></option>
|
47 |
-
</select>
|
48 |
-
</td>
|
49 |
-
</tr>
|
50 |
</table>
|
1 |
+
<?php ?>
|
2 |
+
<table id="add_event_options_table" class="form-table">
|
3 |
+
<tr>
|
4 |
+
<td><label for="sub_title"><?php _e('Event Subtitle:', 'mp-timetable') ?></label></td>
|
5 |
+
<td><input id="sub_title" class="widefat" type="text" value="<?php echo esc_attr( $post->sub_title ); ?>" name="event_meta[sub_title]"></td>
|
6 |
+
</tr>
|
7 |
+
<tr class="select-color">
|
8 |
+
<td><label for="color"><?php _e('Background Color:', 'mp-timetable'); ?></label></td>
|
9 |
+
<td>
|
10 |
+
<input type="hidden" class="clr-picker" value="<?php echo esc_attr( $post->color ); ?>">
|
11 |
+
<input type="text" id="color" name="event_meta[color]" value="<?php echo esc_attr( $post->color ); ?>" data-default-color="transparent">
|
12 |
+
</td>
|
13 |
+
</tr>
|
14 |
+
<tr class="select-color">
|
15 |
+
<td><label for="hover_color"><?php _e('Background Hover Color:', 'mp-timetable'); ?></label></td>
|
16 |
+
<td>
|
17 |
+
<input type="hidden" class="clr-picker" value="<?php echo esc_attr( $post->hover_color ); ?>">
|
18 |
+
<input type="text" id="hover_color" name="event_meta[hover_color]" value="<?php echo esc_attr( $post->hover_color ); ?>" data-default-color="transparent">
|
19 |
+
</td>
|
20 |
+
</tr>
|
21 |
+
<tr class="select-color">
|
22 |
+
<td><label for="text_color"><?php _e('Text Color:', 'mp-timetable'); ?></label></td>
|
23 |
+
<td>
|
24 |
+
<input type="hidden" class="clr-picker" value="<?php echo esc_attr( $post->text_color ); ?>">
|
25 |
+
<input type="text" id="text_color" name="event_meta[text_color]" value="<?php echo esc_attr( $post->text_color ); ?>" data-default-color="transparent">
|
26 |
+
</td>
|
27 |
+
</tr>
|
28 |
+
<tr class="select-color">
|
29 |
+
<td><label for="hover_text_color"><?php _e('Text Hover Color:', 'mp-timetable'); ?></label></td>
|
30 |
+
<td>
|
31 |
+
<input type="hidden" class="clr-picker" value="<?php echo esc_attr( $post->hover_text_color ); ?>">
|
32 |
+
<input type="text" id="hover_text_color" name="event_meta[hover_text_color]" value="<?php echo esc_attr( $post->hover_text_color ); ?>" data-default-color="transparent">
|
33 |
+
</td>
|
34 |
+
</tr>
|
35 |
+
<tr>
|
36 |
+
<td><label for="timetable_custom_url"><?php _e('Custom Event URL:', 'mp-timetable'); ?></label></td>
|
37 |
+
<td>
|
38 |
+
<input type="text" id="timetable_custom_url" class="widefat" placeholder="http://mywebsite.com" name="event_meta[timetable_custom_url]" value="<?php echo esc_attr( $post->timetable_custom_url ); ?>">
|
39 |
+
</td>
|
40 |
+
</tr>
|
41 |
+
<tr>
|
42 |
+
<td><label for="select-disable-url"><?php _e('Disable link to this event:', 'mp-timetable'); ?></label></td>
|
43 |
+
<td>
|
44 |
+
<select id="select-disable-url" name="event_meta[timetable_disable_url]">
|
45 |
+
<option value="0" <?php echo !($post->timetable_disable_url) ? 'selected="selected"' : '' ?> ><?php _e('No', 'mp-timetable') ?></option>
|
46 |
+
<option value="1" <?php echo ($post->timetable_disable_url) ? 'selected="selected"' : '' ?>><?php _e('Yes', 'mp-timetable') ?></option>
|
47 |
+
</select>
|
48 |
+
</td>
|
49 |
+
</tr>
|
50 |
</table>
|
templates/shortcodes/event-container.php
CHANGED
@@ -30,7 +30,7 @@
|
|
30 |
<p class="timeslot">
|
31 |
<time datetime="<?php echo $item[ 'event_start' ]; ?>" class="timeslot-start"><?php echo date( get_option( 'time_format' ), strtotime( $item[ 'event_start' ] ) ); ?></time>
|
32 |
<span class="timeslot-delimiter"><?php echo apply_filters( 'mptt_timeslot_delimiter', ' - ' ); ?></span>
|
33 |
-
<time datetime="<?php echo $item[ 'event_end' ]; ?>" class="timeslot-end"><?php echo date( get_option( 'time_format' ), strtotime( $item[ 'event_end' ] ) )
|
34 |
</p>
|
35 |
<?php endif;
|
36 |
|
30 |
<p class="timeslot">
|
31 |
<time datetime="<?php echo $item[ 'event_start' ]; ?>" class="timeslot-start"><?php echo date( get_option( 'time_format' ), strtotime( $item[ 'event_start' ] ) ); ?></time>
|
32 |
<span class="timeslot-delimiter"><?php echo apply_filters( 'mptt_timeslot_delimiter', ' - ' ); ?></span>
|
33 |
+
<time datetime="<?php echo $item[ 'event_end' ]; ?>" class="timeslot-end"><?php echo date( get_option( 'time_format' ), strtotime( $item[ 'event_end' ] ) ); ?></time>
|
34 |
</p>
|
35 |
<?php endif;
|
36 |
|
templates/shortcodes/index-timetable.php
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
do_action('mptt_shortcode_template_before_content');
|
4 |
-
|
5 |
-
do_action('mptt_shortcode_template_content');
|
6 |
-
|
7 |
-
do_action('mptt_shortcode_template_after_content');
|
8 |
-
|
1 |
+
<?php
|
2 |
+
|
3 |
+
do_action('mptt_shortcode_template_before_content');
|
4 |
+
|
5 |
+
do_action('mptt_shortcode_template_content');
|
6 |
+
|
7 |
+
do_action('mptt_shortcode_template_after_content');
|
8 |
+
|
templates/shortcodes/table-header.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
-
<thead>
|
2 |
-
<tr class="mptt-shortcode-row">
|
3 |
-
<?php foreach ($header_items as $key => $column):
|
4 |
-
if (!$column[ 'output' ]) {
|
5 |
-
continue;
|
6 |
-
} ?>
|
7 |
-
<th data-index="<?php echo $key ?>" data-column-id="<?php echo $column[ 'id' ] ?>"><?php echo $column[ 'title' ] ?></th>
|
8 |
-
<?php endforeach; ?>
|
9 |
-
</tr>
|
10 |
</thead>
|
1 |
+
<thead>
|
2 |
+
<tr class="mptt-shortcode-row">
|
3 |
+
<?php foreach ($header_items as $key => $column):
|
4 |
+
if (!$column[ 'output' ]) {
|
5 |
+
continue;
|
6 |
+
} ?>
|
7 |
+
<th data-index="<?php echo $key ?>" data-column-id="<?php echo $column[ 'id' ] ?>"><?php echo $column[ 'title' ] ?></th>
|
8 |
+
<?php endforeach; ?>
|
9 |
+
</tr>
|
10 |
</thead>
|
templates/single-mp-column.php
CHANGED
@@ -1,28 +1,28 @@
|
|
1 |
-
<?php get_header();
|
2 |
-
|
3 |
-
do_action('mptt-single-mp-column-before-wrapper');
|
4 |
-
|
5 |
-
do_action('mptt-single-before-wrapper');
|
6 |
-
|
7 |
-
while (have_posts()) : the_post();
|
8 |
-
?>
|
9 |
-
<div <?php post_class(apply_filters('mptt_main_wrapper_class', 'mptt-main-wrapper')) ?>>
|
10 |
-
<?php
|
11 |
-
/**
|
12 |
-
* add_action('mptt_single_column_template_content', 'mptt_column_template_content_title', 10);
|
13 |
-
* add_action('mptt_single_column_template_content', 'mptt_column_template_content_post_content', 20);
|
14 |
-
* add_action('mptt_single_column_template_content', 'mptt_column_template_content_events_list', 30);
|
15 |
-
*/
|
16 |
-
do_action('mptt_single_column_template_content');
|
17 |
-
?>
|
18 |
-
<div class="mptt-clearfix"></div>
|
19 |
-
</div>
|
20 |
-
|
21 |
-
<?php
|
22 |
-
endwhile;
|
23 |
-
|
24 |
-
do_action('mptt_after_main_wrapper'); ?>
|
25 |
-
<div class="mptt-clearfix"></div>
|
26 |
-
<?php
|
27 |
-
do_action('mptt-single-mp-column-after-wrapper');
|
28 |
get_footer(); ?>
|
1 |
+
<?php get_header();
|
2 |
+
|
3 |
+
do_action('mptt-single-mp-column-before-wrapper');
|
4 |
+
|
5 |
+
do_action('mptt-single-before-wrapper');
|
6 |
+
|
7 |
+
while (have_posts()) : the_post();
|
8 |
+
?>
|
9 |
+
<div <?php post_class(apply_filters('mptt_main_wrapper_class', 'mptt-main-wrapper')) ?>>
|
10 |
+
<?php
|
11 |
+
/**
|
12 |
+
* add_action('mptt_single_column_template_content', 'mptt_column_template_content_title', 10);
|
13 |
+
* add_action('mptt_single_column_template_content', 'mptt_column_template_content_post_content', 20);
|
14 |
+
* add_action('mptt_single_column_template_content', 'mptt_column_template_content_events_list', 30);
|
15 |
+
*/
|
16 |
+
do_action('mptt_single_column_template_content');
|
17 |
+
?>
|
18 |
+
<div class="mptt-clearfix"></div>
|
19 |
+
</div>
|
20 |
+
|
21 |
+
<?php
|
22 |
+
endwhile;
|
23 |
+
|
24 |
+
do_action('mptt_after_main_wrapper'); ?>
|
25 |
+
<div class="mptt-clearfix"></div>
|
26 |
+
<?php
|
27 |
+
do_action('mptt-single-mp-column-after-wrapper');
|
28 |
get_footer(); ?>
|
templates/single-mp-event.php
CHANGED
@@ -1,37 +1,37 @@
|
|
1 |
-
<?php get_header();
|
2 |
-
|
3 |
-
do_action('mptt-single-mp-event-before-wrapper');
|
4 |
-
|
5 |
-
do_action('mptt_before_main_wrapper');
|
6 |
-
|
7 |
-
while (have_posts()) : the_post();
|
8 |
-
?>
|
9 |
-
<div <?php post_class(apply_filters('mptt_main_wrapper_class', 'mptt-main-wrapper')) ?>>
|
10 |
-
<div class="<?php echo apply_filters('mptt_event_template_content_class', 'mptt-content') ?>">
|
11 |
-
<?php
|
12 |
-
/**
|
13 |
-
* add_action('mptt_event_item_content', 'mptt_event_template_content_title', 10);
|
14 |
-
* add_action('mptt_event_item_content', 'mptt_event_template_content_thumbnail', 20);
|
15 |
-
* add_action('mptt_event_item_content', 'mptt_event_template_content_post_content', 30);
|
16 |
-
* add_action('mptt_event_item_content', 'mptt_event_template_content_title', 40);
|
17 |
-
* add_action('mptt_event_item_content', 'mptt_event_template_content_time_list', 50);
|
18 |
-
*/
|
19 |
-
do_action('mptt_event_item_content');
|
20 |
-
?>
|
21 |
-
</div>
|
22 |
-
<div class="<?php echo apply_filters('mptt_sidebar_class', 'mptt-sidebar') ?>">
|
23 |
-
<?php
|
24 |
-
do_action('mptt_sidebar');
|
25 |
-
?>
|
26 |
-
</div>
|
27 |
-
<div class="mptt-clearfix"></div>
|
28 |
-
</div>
|
29 |
-
|
30 |
-
<?php
|
31 |
-
endwhile;
|
32 |
-
|
33 |
-
do_action('mptt_after_main_wrapper');
|
34 |
-
|
35 |
-
do_action('mptt-single-mp-event-after-wrapper');
|
36 |
-
|
37 |
get_footer(); ?>
|
1 |
+
<?php get_header();
|
2 |
+
|
3 |
+
do_action('mptt-single-mp-event-before-wrapper');
|
4 |
+
|
5 |
+
do_action('mptt_before_main_wrapper');
|
6 |
+
|
7 |
+
while (have_posts()) : the_post();
|
8 |
+
?>
|
9 |
+
<div <?php post_class(apply_filters('mptt_main_wrapper_class', 'mptt-main-wrapper')) ?>>
|
10 |
+
<div class="<?php echo apply_filters('mptt_event_template_content_class', 'mptt-content') ?>">
|
11 |
+
<?php
|
12 |
+
/**
|
13 |
+
* add_action('mptt_event_item_content', 'mptt_event_template_content_title', 10);
|
14 |
+
* add_action('mptt_event_item_content', 'mptt_event_template_content_thumbnail', 20);
|
15 |
+
* add_action('mptt_event_item_content', 'mptt_event_template_content_post_content', 30);
|
16 |
+
* add_action('mptt_event_item_content', 'mptt_event_template_content_title', 40);
|
17 |
+
* add_action('mptt_event_item_content', 'mptt_event_template_content_time_list', 50);
|
18 |
+
*/
|
19 |
+
do_action('mptt_event_item_content');
|
20 |
+
?>
|
21 |
+
</div>
|
22 |
+
<div class="<?php echo apply_filters('mptt_sidebar_class', 'mptt-sidebar') ?>">
|
23 |
+
<?php
|
24 |
+
do_action('mptt_sidebar');
|
25 |
+
?>
|
26 |
+
</div>
|
27 |
+
<div class="mptt-clearfix"></div>
|
28 |
+
</div>
|
29 |
+
|
30 |
+
<?php
|
31 |
+
endwhile;
|
32 |
+
|
33 |
+
do_action('mptt_after_main_wrapper');
|
34 |
+
|
35 |
+
do_action('mptt-single-mp-event-after-wrapper');
|
36 |
+
|
37 |
get_footer(); ?>
|
templates/templates-actions/action-sidebar.php
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
<?php
|
2 |
-
if (is_active_sidebar('mptt-sidebar')) {
|
3 |
-
dynamic_sidebar('mptt-sidebar');
|
4 |
-
|
5 |
-
} elseif (get_option('template') != 'twentyfourteen') {
|
6 |
-
|
7 |
-
the_widget('timetable\classes\widgets\Timetable_widget', apply_filters('mptt_widget_settings', array(
|
8 |
-
'title' => __('Today upcoming events', 'mp-timetable'),
|
9 |
-
'limit' => '3')
|
10 |
-
), array('widget_id' => 'wp-timetable-1' . $post->ID));
|
11 |
-
|
12 |
-
the_widget('timetable\classes\widgets\Timetable_widget', apply_filters('mptt_widget_settings', array(
|
13 |
-
'title' => __('All upcoming events', 'mp-timetable'),
|
14 |
-
'view_settings' => 'all',
|
15 |
-
'limit' => '10',
|
16 |
-
'next_days' => '5',
|
17 |
-
)), array('widget_id' => 'wp-timetable-2' . $post->ID));
|
18 |
-
|
19 |
-
};
|
1 |
+
<?php
|
2 |
+
if (is_active_sidebar('mptt-sidebar')) {
|
3 |
+
dynamic_sidebar('mptt-sidebar');
|
4 |
+
|
5 |
+
} elseif (get_option('template') != 'twentyfourteen') {
|
6 |
+
|
7 |
+
the_widget('timetable\classes\widgets\Timetable_widget', apply_filters('mptt_widget_settings', array(
|
8 |
+
'title' => __('Today upcoming events', 'mp-timetable'),
|
9 |
+
'limit' => '3')
|
10 |
+
), array('widget_id' => 'wp-timetable-1' . $post->ID));
|
11 |
+
|
12 |
+
the_widget('timetable\classes\widgets\Timetable_widget', apply_filters('mptt_widget_settings', array(
|
13 |
+
'title' => __('All upcoming events', 'mp-timetable'),
|
14 |
+
'view_settings' => 'all',
|
15 |
+
'limit' => '10',
|
16 |
+
'next_days' => '5',
|
17 |
+
)), array('widget_id' => 'wp-timetable-2' . $post->ID));
|
18 |
+
|
19 |
+
};
|
templates/theme/column-events.php
CHANGED
@@ -1,48 +1,48 @@
|
|
1 |
-
<?php
|
2 |
-
$time_format = get_option('time_format');
|
3 |
-
|
4 |
-
do_action('mptt_column_events_before_events', $events);
|
5 |
-
|
6 |
-
if ( !empty($events) ) {
|
7 |
-
|
8 |
-
foreach ($events as $event): ?>
|
9 |
-
<p class="event mptt-theme-mode-event" id="event_<?php echo $event->event_id ?>">
|
10 |
-
|
11 |
-
<?php if (has_post_thumbnail($event->event_id)) {
|
12 |
-
echo wp_get_attachment_image( get_post_thumbnail_id($event->event_id), apply_filters('mptt_event_thumbnail_size', 'thumbnail'), false, array('class' => "alignleft event-thumbnail", 'alt' => get_the_title($event->event_id)));
|
13 |
-
} else { ?>
|
14 |
-
<img class="alignleft event-thumbnail event-thumbnail-default" src="<?php echo \Mp_Time_Table::get_plugin_url() . 'media/css/images/column_icon.png' ?>">
|
15 |
-
<?php } ?>
|
16 |
-
|
17 |
-
<a href="<?php echo $event->post->timetable_disable_url == '1' ? '#' : ($event->post->timetable_custom_url != "" ? $event->post->timetable_custom_url : get_permalink($event->event_id)) ?>" class="event-link">
|
18 |
-
<?php echo get_the_title($event->event_id); ?>
|
19 |
-
</a>
|
20 |
-
|
21 |
-
<br/>
|
22 |
-
|
23 |
-
<time datetime="<?php echo $event->event_start; ?>" class="timeslot-start"><?php echo date($time_format, strtotime($event->event_start)); ?></time><?php echo apply_filters('mptt_timeslot_delimiter', ' - '); ?>
|
24 |
-
<time datetime="<?php echo $event->event_end; ?>" class="timeslot-end"><?php echo date($time_format, strtotime($event->event_end)); ?></time>
|
25 |
-
|
26 |
-
<?php if (!empty($event->post->sub_title)) { ?>
|
27 |
-
<br/>
|
28 |
-
<span class="event-subtitle"><?php echo $event->post->sub_title ?></span>
|
29 |
-
<?php } ?>
|
30 |
-
|
31 |
-
<?php if (!empty($event->description)) { ?>
|
32 |
-
<br/>
|
33 |
-
<span class="event-description"><?php echo stripslashes( $event->description ); ?></span>
|
34 |
-
<?php } ?>
|
35 |
-
|
36 |
-
<?php if (!empty($event->user)) { ?>
|
37 |
-
<br/>
|
38 |
-
<span class="event-user vcard">
|
39 |
-
<?php echo get_avatar($event->user->ID, apply_filters('mptt_column_events_avatar_size', 32), '', $event->user->display_name); ?>
|
40 |
-
<?php echo $event->user->display_name ?>
|
41 |
-
</span>
|
42 |
-
<?php } ?>
|
43 |
-
</p>
|
44 |
-
<?php endforeach;
|
45 |
-
|
46 |
-
}
|
47 |
-
|
48 |
do_action('mptt_column_events_after_events', $events);
|
1 |
+
<?php
|
2 |
+
$time_format = get_option('time_format');
|
3 |
+
|
4 |
+
do_action('mptt_column_events_before_events', $events);
|
5 |
+
|
6 |
+
if ( !empty($events) ) {
|
7 |
+
|
8 |
+
foreach ($events as $event): ?>
|
9 |
+
<p class="event mptt-theme-mode-event" id="event_<?php echo $event->event_id ?>">
|
10 |
+
|
11 |
+
<?php if (has_post_thumbnail($event->event_id)) {
|
12 |
+
echo wp_get_attachment_image( get_post_thumbnail_id($event->event_id), apply_filters('mptt_event_thumbnail_size', 'thumbnail'), false, array('class' => "alignleft event-thumbnail", 'alt' => get_the_title($event->event_id)));
|
13 |
+
} else { ?>
|
14 |
+
<img class="alignleft event-thumbnail event-thumbnail-default" src="<?php echo \Mp_Time_Table::get_plugin_url() . 'media/css/images/column_icon.png' ?>">
|
15 |
+
<?php } ?>
|
16 |
+
|
17 |
+
<a href="<?php echo $event->post->timetable_disable_url == '1' ? '#' : ($event->post->timetable_custom_url != "" ? $event->post->timetable_custom_url : get_permalink($event->event_id)) ?>" class="event-link">
|
18 |
+
<?php echo get_the_title($event->event_id); ?>
|
19 |
+
</a>
|
20 |
+
|
21 |
+
<br/>
|
22 |
+
|
23 |
+
<time datetime="<?php echo $event->event_start; ?>" class="timeslot-start"><?php echo date($time_format, strtotime($event->event_start)); ?></time><?php echo apply_filters('mptt_timeslot_delimiter', ' - '); ?>
|
24 |
+
<time datetime="<?php echo $event->event_end; ?>" class="timeslot-end"><?php echo date($time_format, strtotime($event->event_end)); ?></time>
|
25 |
+
|
26 |
+
<?php if (!empty($event->post->sub_title)) { ?>
|
27 |
+
<br/>
|
28 |
+
<span class="event-subtitle"><?php echo $event->post->sub_title ?></span>
|
29 |
+
<?php } ?>
|
30 |
+
|
31 |
+
<?php if (!empty($event->description)) { ?>
|
32 |
+
<br/>
|
33 |
+
<span class="event-description"><?php echo stripslashes( $event->description ); ?></span>
|
34 |
+
<?php } ?>
|
35 |
+
|
36 |
+
<?php if (!empty($event->user)) { ?>
|
37 |
+
<br/>
|
38 |
+
<span class="event-user vcard">
|
39 |
+
<?php echo get_avatar($event->user->ID, apply_filters('mptt_column_events_avatar_size', 32), '', $event->user->display_name); ?>
|
40 |
+
<?php echo $event->user->display_name ?>
|
41 |
+
</span>
|
42 |
+
<?php } ?>
|
43 |
+
</p>
|
44 |
+
<?php endforeach;
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
do_action('mptt_column_events_after_events', $events);
|
templates/theme/event-timeslots.php
CHANGED
@@ -1,45 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
do_action('mptt_event_timeslots_before_title');
|
4 |
-
|
5 |
-
if ( !empty($count) ) {
|
6 |
-
?>
|
7 |
-
<h3 class="timeslots-title"><?php printf(__('Event Timeslots (%s)', 'mp-timetable'), $count); ?></h3>
|
8 |
-
<?php
|
9 |
-
}
|
10 |
-
$time_format = get_option('time_format');
|
11 |
-
|
12 |
-
do_action('mptt_event_timeslots_before_timeslots', $events);
|
13 |
-
|
14 |
-
if ( !empty($events) ) {
|
15 |
-
foreach ($events as $event): ?>
|
16 |
-
<p class="timeslot">
|
17 |
-
|
18 |
-
<a class="timeslot-link" href="<?php echo get_permalink($event->column_id); ?>"><?php echo get_the_title($event->column_id); ?></a>
|
19 |
-
|
20 |
-
<br/>
|
21 |
-
<time datetime="<?php echo $event->event_start; ?>" class="timeslot-start"><?php echo date($time_format, strtotime($event->event_start)); ?></time>
|
22 |
-
<?php echo apply_filters('mptt_timeslot_delimiter', ' - '); ?>
|
23 |
-
<time datetime="<?php echo $event->event_start; ?>" class="timeslot-end"><?php echo date($time_format, strtotime($event->event_end)); ?></time>
|
24 |
-
|
25 |
-
<?php if (!empty($event->post->sub_title)) { ?>
|
26 |
-
<br/>
|
27 |
-
<span class="timeslot-subtitle"><?php echo $event->post->sub_title; ?></span>
|
28 |
-
<?php } ?>
|
29 |
-
|
30 |
-
<?php if (!empty($event->description)) { ?>
|
31 |
-
<br/>
|
32 |
-
<span class="timeslot-description"><?php echo stripslashes( $event->description ); ?></span>
|
33 |
-
<?php } ?>
|
34 |
-
<?php if (!empty($event->user)) { ?>
|
35 |
-
<br/>
|
36 |
-
<span class="timeslot-user vcard">
|
37 |
-
<?php echo get_avatar($event->user->ID, apply_filters('mptt_event_timeslots_avatar_size', 32), '', $event->user->display_name); ?> <?php echo $event->user->display_name; ?>
|
38 |
-
</span>
|
39 |
-
<?php } ?>
|
40 |
-
|
41 |
-
</p>
|
42 |
-
<?php endforeach;
|
43 |
-
}
|
44 |
-
|
45 |
do_action('mptt_event_timeslots_after_timeslots', $events);
|
1 |
+
<?php
|
2 |
+
|
3 |
+
do_action('mptt_event_timeslots_before_title');
|
4 |
+
|
5 |
+
if ( !empty($count) ) {
|
6 |
+
?>
|
7 |
+
<h3 class="timeslots-title"><?php printf(__('Event Timeslots (%s)', 'mp-timetable'), $count); ?></h3>
|
8 |
+
<?php
|
9 |
+
}
|
10 |
+
$time_format = get_option('time_format');
|
11 |
+
|
12 |
+
do_action('mptt_event_timeslots_before_timeslots', $events);
|
13 |
+
|
14 |
+
if ( !empty($events) ) {
|
15 |
+
foreach ($events as $event): ?>
|
16 |
+
<p class="timeslot">
|
17 |
+
|
18 |
+
<a class="timeslot-link" href="<?php echo get_permalink($event->column_id); ?>"><?php echo get_the_title($event->column_id); ?></a>
|
19 |
+
|
20 |
+
<br/>
|
21 |
+
<time datetime="<?php echo $event->event_start; ?>" class="timeslot-start"><?php echo date($time_format, strtotime($event->event_start)); ?></time>
|
22 |
+
<?php echo apply_filters('mptt_timeslot_delimiter', ' - '); ?>
|
23 |
+
<time datetime="<?php echo $event->event_start; ?>" class="timeslot-end"><?php echo date($time_format, strtotime($event->event_end)); ?></time>
|
24 |
+
|
25 |
+
<?php if (!empty($event->post->sub_title)) { ?>
|
26 |
+
<br/>
|
27 |
+
<span class="timeslot-subtitle"><?php echo $event->post->sub_title; ?></span>
|
28 |
+
<?php } ?>
|
29 |
+
|
30 |
+
<?php if (!empty($event->description)) { ?>
|
31 |
+
<br/>
|
32 |
+
<span class="timeslot-description"><?php echo stripslashes( $event->description ); ?></span>
|
33 |
+
<?php } ?>
|
34 |
+
<?php if (!empty($event->user)) { ?>
|
35 |
+
<br/>
|
36 |
+
<span class="timeslot-user vcard">
|
37 |
+
<?php echo get_avatar($event->user->ID, apply_filters('mptt_event_timeslots_avatar_size', 32), '', $event->user->display_name); ?> <?php echo $event->user->display_name; ?>
|
38 |
+
</span>
|
39 |
+
<?php } ?>
|
40 |
+
|
41 |
+
</p>
|
42 |
+
<?php endforeach;
|
43 |
+
}
|
44 |
+
|
45 |
do_action('mptt_event_timeslots_after_timeslots', $events);
|
templates/theme/widget-upcoming-view.php
CHANGED
@@ -1,59 +1,59 @@
|
|
1 |
-
<?php echo $args['before_widget'];
|
2 |
-
|
3 |
-
if (!empty($instance['title'])) {
|
4 |
-
echo $args['before_title'] . $instance['title'] . $args['after_title'];
|
5 |
-
}
|
6 |
-
|
7 |
-
do_action('mptt_widget_upcoming_before_content', $events);
|
8 |
-
|
9 |
-
$time_format = get_option('time_format');
|
10 |
-
|
11 |
-
$events_group_by_categories = array();
|
12 |
-
|
13 |
-
foreach ($events as $event) {
|
14 |
-
if (!isset($temp[$event->column_id])) {
|
15 |
-
$events_group_by_categories[$event->column_id][] = $event;
|
16 |
-
} else {
|
17 |
-
$events_group_by_categories[$event->column_id][] = $event;
|
18 |
-
}
|
19 |
-
}
|
20 |
-
|
21 |
-
if (!empty($events)): ?>
|
22 |
-
<?php foreach ($events_group_by_categories as $key_category => $cat_events) { ?>
|
23 |
-
<ul>
|
24 |
-
<?php foreach ($cat_events as $key => $event):
|
25 |
-
$event_class = 'event';
|
26 |
-
?>
|
27 |
-
<li class="<?php echo apply_filters('mptt_widget_upcoming_event_class', $event_class) ?>">
|
28 |
-
<?php
|
29 |
-
|
30 |
-
$disable_url = (bool)$event->post->timetable_disable_url || (bool)$instance['disable_url'];
|
31 |
-
$url = ($instance['custom_url'] != "") ? $instance['custom_url'] : (($event->post->timetable_custom_url != "") ? $event->post->timetable_custom_url : get_permalink($event->event_id));
|
32 |
-
|
33 |
-
if (!$disable_url) { ?>
|
34 |
-
<a href="<?php echo $url ?>" title="<?php echo get_the_title($event->event_id) ?>" class="event-link">
|
35 |
-
<?php }
|
36 |
-
echo get_the_title($event->event_id);
|
37 |
-
if (!$disable_url) { ?>
|
38 |
-
</a><br/>
|
39 |
-
<?php } ?>
|
40 |
-
<span class="post-date">
|
41 |
-
<?php if ($instance['view_settings'] !== 'today' && $instance['view_settings'] !== 'current'): ?><?php echo get_the_title($event->column_id) ?>
|
42 |
-
<br/>
|
43 |
-
<?php endif; ?>
|
44 |
-
<time datetime="<?php echo $event->event_start; ?>" class="timeslot-start"><?php echo date($time_format, strtotime($event->event_start)); ?></time>
|
45 |
-
<?php echo apply_filters('mptt_timeslot_delimiter', ' - '); ?>
|
46 |
-
<time datetime="<?php echo $event->event_end; ?>" class="timeslot-end"><?php echo date($time_format, strtotime($event->event_end)); ?></time>
|
47 |
-
</span>
|
48 |
-
</li>
|
49 |
-
<?php endforeach; ?>
|
50 |
-
</ul>
|
51 |
-
<?php
|
52 |
-
}
|
53 |
-
else:
|
54 |
-
_e('no events found', 'mp-timetable');
|
55 |
-
endif;
|
56 |
-
|
57 |
-
do_action('mptt_widget_upcoming_after_content', $events);
|
58 |
-
|
59 |
echo $args['after_widget'] ?>
|
1 |
+
<?php echo $args['before_widget'];
|
2 |
+
|
3 |
+
if (!empty($instance['title'])) {
|
4 |
+
echo $args['before_title'] . $instance['title'] . $args['after_title'];
|
5 |
+
}
|
6 |
+
|
7 |
+
do_action('mptt_widget_upcoming_before_content', $events);
|
8 |
+
|
9 |
+
$time_format = get_option('time_format');
|
10 |
+
|
11 |
+
$events_group_by_categories = array();
|
12 |
+
|
13 |
+
foreach ($events as $event) {
|
14 |
+
if (!isset($temp[$event->column_id])) {
|
15 |
+
$events_group_by_categories[$event->column_id][] = $event;
|
16 |
+
} else {
|
17 |
+
$events_group_by_categories[$event->column_id][] = $event;
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
if (!empty($events)): ?>
|
22 |
+
<?php foreach ($events_group_by_categories as $key_category => $cat_events) { ?>
|
23 |
+
<ul>
|
24 |
+
<?php foreach ($cat_events as $key => $event):
|
25 |
+
$event_class = 'event';
|
26 |
+
?>
|
27 |
+
<li class="<?php echo apply_filters('mptt_widget_upcoming_event_class', $event_class) ?>">
|
28 |
+
<?php
|
29 |
+
|
30 |
+
$disable_url = (bool)$event->post->timetable_disable_url || (bool)$instance['disable_url'];
|
31 |
+
$url = ($instance['custom_url'] != "") ? $instance['custom_url'] : (($event->post->timetable_custom_url != "") ? $event->post->timetable_custom_url : get_permalink($event->event_id));
|
32 |
+
|
33 |
+
if (!$disable_url) { ?>
|
34 |
+
<a href="<?php echo $url ?>" title="<?php echo get_the_title($event->event_id) ?>" class="event-link">
|
35 |
+
<?php }
|
36 |
+
echo get_the_title($event->event_id);
|
37 |
+
if (!$disable_url) { ?>
|
38 |
+
</a><br/>
|
39 |
+
<?php } ?>
|
40 |
+
<span class="post-date">
|
41 |
+
<?php if ($instance['view_settings'] !== 'today' && $instance['view_settings'] !== 'current'): ?><?php echo get_the_title($event->column_id) ?>
|
42 |
+
<br/>
|
43 |
+
<?php endif; ?>
|
44 |
+
<time datetime="<?php echo $event->event_start; ?>" class="timeslot-start"><?php echo date($time_format, strtotime($event->event_start)); ?></time>
|
45 |
+
<?php echo apply_filters('mptt_timeslot_delimiter', ' - '); ?>
|
46 |
+
<time datetime="<?php echo $event->event_end; ?>" class="timeslot-end"><?php echo date($time_format, strtotime($event->event_end)); ?></time>
|
47 |
+
</span>
|
48 |
+
</li>
|
49 |
+
<?php endforeach; ?>
|
50 |
+
</ul>
|
51 |
+
<?php
|
52 |
+
}
|
53 |
+
else:
|
54 |
+
_e('no events found', 'mp-timetable');
|
55 |
+
endif;
|
56 |
+
|
57 |
+
do_action('mptt_widget_upcoming_after_content', $events);
|
58 |
+
|
59 |
echo $args['after_widget'] ?>
|
templates/widgets/gallery-list.php
CHANGED
@@ -1,154 +1,154 @@
|
|
1 |
-
<div class="<?php echo $widget_object->widget_options['classname'] ?>">
|
2 |
-
<p>
|
3 |
-
<label for="<?php echo $widget_object->get_field_id('title') ?>"><?php _e('Title', "mp-timetable") ?></label>
|
4 |
-
<input class="widefat" id="<?php echo $widget_object->get_field_id('title') ?>"
|
5 |
-
name="<?php echo $widget_object->get_field_name('title') ?>" type="text"
|
6 |
-
value="<?php echo $instance['title'] ?>">
|
7 |
-
</p>
|
8 |
-
<p>
|
9 |
-
<label
|
10 |
-
for="<?php echo $widget_object->get_field_id('view_settings') ?>"><?php _e('Events to display', "mp-timetable") ?></label>
|
11 |
-
<select class="view_settings widefat" id="<?php echo $widget_object->get_field_id('view_settings') ?>"
|
12 |
-
name="<?php echo $widget_object->get_field_name('view_settings') ?>">
|
13 |
-
<option
|
14 |
-
value="today" <?php echo $instance['view_settings'] === 'today' ? 'selected="selected"' : '' ?> ><?php _e('Today upcoming events', "mp-timetable") ?></option>
|
15 |
-
<option
|
16 |
-
value="all" <?php echo $instance['view_settings'] === 'all' ? 'selected="selected"' : '' ?> ><?php _e('All upcoming events', "mp-timetable") ?></option>
|
17 |
-
<option
|
18 |
-
value="current"<?php echo $instance['view_settings'] === 'current' ? 'selected="selected"' : '' ?>><?php _e('Ongoing events', "mp-timetable") ?></option>
|
19 |
-
</select>
|
20 |
-
</p>
|
21 |
-
<p class="next-days" style="display: <?php echo $instance['view_settings'] === 'all' ? 'block' : 'none' ?> ;">
|
22 |
-
<label for="<?php echo $widget_object->get_field_id('next_days') ?>">
|
23 |
-
<?php _e('Input number of days', "mp-timetable") ?>
|
24 |
-
</label>
|
25 |
-
<input class="widefat" id="<?php echo $widget_object->get_field_id('next_days') ?>"
|
26 |
-
name="<?php echo $widget_object->get_field_name('next_days') ?>" type="text"
|
27 |
-
value="<?php echo $instance['next_days'] ?>">
|
28 |
-
<?php _n('day', 'days', $instance['next_days'], "mp-timetable") ?>
|
29 |
-
</p>
|
30 |
-
<p>
|
31 |
-
<label class="widget-categories"
|
32 |
-
for="<?php echo $widget_object->get_field_id('mp_categories') ?>"><?php _e('Event categories. Leave blank to display all.', "mp-timetable") ?></label>
|
33 |
-
<select class="widefat mptt-resize-vertical" multiple="multiple" id="<?php echo $widget_object->get_field_id('mp_categories') ?>"
|
34 |
-
name="<?php echo $widget_object->get_field_name('mp_categories') ?>[]">
|
35 |
-
<?php
|
36 |
-
if ( !empty($event_categories) ):
|
37 |
-
foreach ( $event_categories as $category ) :
|
38 |
-
if ( empty($instance['mp_categories']) ):
|
39 |
-
$instance['mp_categories'] = array();
|
40 |
-
endif ?>
|
41 |
-
<option value="<?php echo $category->term_id ?>"<?php
|
42 |
-
echo in_array($category->term_id, $instance['mp_categories']) ? 'selected="selected"' : '' ?> ><?php
|
43 |
-
echo $category->name
|
44 |
-
?></option>
|
45 |
-
<?php endforeach;
|
46 |
-
endif; ?>
|
47 |
-
</select>
|
48 |
-
<small><?php _e('Hold the Ctrl or Command key to select/deselect multiple options.', 'mp-timetable'); ?></small>
|
49 |
-
</p>
|
50 |
-
<p>
|
51 |
-
<label
|
52 |
-
for="<?php echo $widget_object->get_field_id('limit') ?>"><?php _e('Number of events to display', "mp-timetable") ?></label>
|
53 |
-
<input class="widefat" id="<?php echo $widget_object->get_field_id('limit') ?>"
|
54 |
-
name="<?php echo $widget_object->get_field_name('limit') ?>" type="text"
|
55 |
-
value="<?php echo $instance['limit'] ?>">
|
56 |
-
</p>
|
57 |
-
<p>
|
58 |
-
<label
|
59 |
-
for="<?php echo $widget_object->get_field_id('disable_url') ?>"><?php _e('Disable event link', "mp-timetable") ?></label>
|
60 |
-
<select class="widefat" id="<?php echo $widget_object->get_field_id('disable_url') ?>"
|
61 |
-
name="<?php echo $widget_object->get_field_name('disable_url') ?>">
|
62 |
-
<option
|
63 |
-
value="0" <?php echo $instance['disable_url'] === '0' ? 'selected="selected"' : '' ?>> <?php _e('No', "mp-timetable") ?> </option>
|
64 |
-
<option
|
65 |
-
value="1" <?php echo $instance['disable_url'] === '1' ? 'selected="selected"' : '' ?>> <?php _e('Yes', "mp-timetable") ?> </option>
|
66 |
-
</select>
|
67 |
-
</p>
|
68 |
-
<p>
|
69 |
-
<label
|
70 |
-
for="<?php echo $widget_object->get_field_id('custom_url') ?>"><?php _e('Custom link for events', "mp-timetable") ?></label>
|
71 |
-
<input class="widefat" id="<?php echo $widget_object->get_field_id('custom_url') ?>"
|
72 |
-
name="<?php echo $widget_object->get_field_name('custom_url') ?>" type="text"
|
73 |
-
value="<?php echo $instance['custom_url'] ?>">
|
74 |
-
</p>
|
75 |
-
<?php if (\mp_timetable\classes\models\Settings::get_instance()->is_plugin_template_mode()): ?>
|
76 |
-
<p style="margin-bottom:0px;">
|
77 |
-
<label
|
78 |
-
for="<?php echo $widget_object->get_field_id('background_color'); ?>"><?php _e('Event background color', "mp-timetable"); ?></label>
|
79 |
-
</p>
|
80 |
-
<p class="select-color" style="margin-top:0px;">
|
81 |
-
<input type="hidden" class="clr-picker" value="<?php echo $instance['background_color']; ?>">
|
82 |
-
<input class="regular-text" id="<?php echo $widget_object->get_field_id('background_color'); ?>"
|
83 |
-
name="<?php echo $widget_object->get_field_name('background_color'); ?>" type="text"
|
84 |
-
value="<?php echo $instance['background_color']; ?>"/>
|
85 |
-
</p>
|
86 |
-
<p style="margin-bottom:0px;">
|
87 |
-
<label
|
88 |
-
for="<?php echo $widget_object->get_field_id('hover_background_color'); ?>"><?php _e('Event background color on hover', "mp-timetable"); ?></label>
|
89 |
-
</p>
|
90 |
-
<p class="select-color" style="margin-top:0px;">
|
91 |
-
<input type="hidden" class="clr-picker" value="<?php echo $instance['hover_background_color']; ?>">
|
92 |
-
<input class="regular-text" id="<?php echo $widget_object->get_field_id('hover_background_color'); ?>"
|
93 |
-
name="<?php echo $widget_object->get_field_name('hover_background_color'); ?>" type="text"
|
94 |
-
value="<?php echo $instance['hover_background_color']; ?>"/>
|
95 |
-
</p>
|
96 |
-
<p style="margin-bottom:0px;">
|
97 |
-
<label
|
98 |
-
for="<?php echo $widget_object->get_field_id('text_color'); ?>"><?php _e('Event text color', "mp-timetable"); ?></label>
|
99 |
-
</p>
|
100 |
-
<p class="select-color" style="margin-top:0px;">
|
101 |
-
<input type="hidden" class="clr-picker" value="<?php echo $instance['text_color']; ?>">
|
102 |
-
<input class="regular-text" id="<?php echo $widget_object->get_field_id('text_color'); ?>"
|
103 |
-
name="<?php echo $widget_object->get_field_name('text_color'); ?>" type="text"
|
104 |
-
value="<?php echo $instance['text_color']; ?>"/>
|
105 |
-
</p>
|
106 |
-
<p style="margin-bottom:0px;">
|
107 |
-
<label
|
108 |
-
for="<?php echo $widget_object->get_field_id('hover_text_color'); ?>"><?php _e('Event text color on hover', "mp-timetable"); ?></label>
|
109 |
-
</p>
|
110 |
-
<p class="select-color" style="margin-top:0px;">
|
111 |
-
<input type="hidden" class="clr-picker" value="<?php echo $instance['hover_text_color']; ?>">
|
112 |
-
<input class="regular-text" id="<?php echo $widget_object->get_field_id('hover_text_color'); ?>"
|
113 |
-
name="<?php echo $widget_object->get_field_name('hover_text_color'); ?>" type="text"
|
114 |
-
value="<?php echo $instance['hover_text_color']; ?>"/>
|
115 |
-
</p>
|
116 |
-
<p style="margin-bottom:0px;">
|
117 |
-
<label
|
118 |
-
for="<?php echo $widget_object->get_field_id('item_border_color'); ?>"><?php _e('Event border color', "mp-timetable"); ?></label>
|
119 |
-
</p>
|
120 |
-
<P class="select-color" style="margin-top:0px;">
|
121 |
-
<input type="hidden" class="clr-picker" value="<?php echo $instance['item_border_color']; ?>">
|
122 |
-
<input class="regular-text" id="<?php echo $widget_object->get_field_id('item_border_color'); ?>"
|
123 |
-
name="<?php echo $widget_object->get_field_name('item_border_color'); ?>" type="text"
|
124 |
-
value="<?php echo $instance['item_border_color']; ?>"/>
|
125 |
-
</P>
|
126 |
-
<p style="margin-bottom:0px;">
|
127 |
-
<label
|
128 |
-
for="<?php echo $widget_object->get_field_id('hover_item_border_color'); ?>"><?php _e('Event border color on hover', "mp-timetable"); ?></label>
|
129 |
-
</p>
|
130 |
-
<p class="select-color" style="margin-top:0px;">
|
131 |
-
<input type="hidden" class="clr-picker" value="<?php echo $instance['hover_item_border_color']; ?>">
|
132 |
-
<input class="regular-text" id="<?php echo $widget_object->get_field_id('hover_item_border_color'); ?>"
|
133 |
-
name="<?php echo $widget_object->get_field_name('hover_item_border_color'); ?>" type="text"
|
134 |
-
value="<?php echo $instance['hover_item_border_color']; ?>"/>
|
135 |
-
</p>
|
136 |
-
<?php else: ?>
|
137 |
-
<input type="hidden" name="<?php echo $widget_object->get_field_name('background_color'); ?>" value=""/>
|
138 |
-
<input type="hidden" name="<?php echo $widget_object->get_field_name('hover_background_color'); ?>" value=""/>
|
139 |
-
<input type="hidden" name="<?php echo $widget_object->get_field_name('text_color'); ?>" value=""/>
|
140 |
-
<input type="hidden" name="<?php echo $widget_object->get_field_name('hover_text_color'); ?>" value=""/>
|
141 |
-
<input type="hidden" name="<?php echo $widget_object->get_field_name('item_border_color'); ?>" value=""/>
|
142 |
-
<input type="hidden" name="<?php echo $widget_object->get_field_name('hover_item_border_color'); ?>" value=""/>
|
143 |
-
<?php endif; ?>
|
144 |
-
</div>
|
145 |
-
<script type="application/javascript">
|
146 |
-
(function($) {
|
147 |
-
"use strict";
|
148 |
-
$(document).ready(function() {
|
149 |
-
Registry._get("Event").initColorPicker('#widgets-right .mptt-container');
|
150 |
-
Registry._get("Event").displaySettings("<?php echo $widget_object->get_field_id('view_settings') ?>");
|
151 |
-
Registry._get("Event").timeMode("<?php echo $widget_object->get_field_id('time_settings');?>");
|
152 |
-
});
|
153 |
-
})(jQuery);
|
154 |
</script>
|
1 |
+
<div class="<?php echo $widget_object->widget_options['classname'] ?>">
|
2 |
+
<p>
|
3 |
+
<label for="<?php echo $widget_object->get_field_id('title') ?>"><?php _e('Title', "mp-timetable") ?></label>
|
4 |
+
<input class="widefat" id="<?php echo $widget_object->get_field_id('title') ?>"
|
5 |
+
name="<?php echo $widget_object->get_field_name('title') ?>" type="text"
|
6 |
+
value="<?php echo $instance['title'] ?>">
|
7 |
+
</p>
|
8 |
+
<p>
|
9 |
+
<label
|
10 |
+
for="<?php echo $widget_object->get_field_id('view_settings') ?>"><?php _e('Events to display', "mp-timetable") ?></label>
|
11 |
+
<select class="view_settings widefat" id="<?php echo $widget_object->get_field_id('view_settings') ?>"
|
12 |
+
name="<?php echo $widget_object->get_field_name('view_settings') ?>">
|
13 |
+
<option
|
14 |
+
value="today" <?php echo $instance['view_settings'] === 'today' ? 'selected="selected"' : '' ?> ><?php _e('Today upcoming events', "mp-timetable") ?></option>
|
15 |
+
<option
|
16 |
+
value="all" <?php echo $instance['view_settings'] === 'all' ? 'selected="selected"' : '' ?> ><?php _e('All upcoming events', "mp-timetable") ?></option>
|
17 |
+
<option
|
18 |
+
value="current"<?php echo $instance['view_settings'] === 'current' ? 'selected="selected"' : '' ?>><?php _e('Ongoing events', "mp-timetable") ?></option>
|
19 |
+
</select>
|
20 |
+
</p>
|
21 |
+
<p class="next-days" style="display: <?php echo $instance['view_settings'] === 'all' ? 'block' : 'none' ?> ;">
|
22 |
+
<label for="<?php echo $widget_object->get_field_id('next_days') ?>">
|
23 |
+
<?php _e('Input number of days', "mp-timetable") ?>
|
24 |
+
</label>
|
25 |
+
<input class="widefat" id="<?php echo $widget_object->get_field_id('next_days') ?>"
|
26 |
+
name="<?php echo $widget_object->get_field_name('next_days') ?>" type="text"
|
27 |
+
value="<?php echo $instance['next_days'] ?>">
|
28 |
+
<?php _n('day', 'days', $instance['next_days'], "mp-timetable") ?>
|
29 |
+
</p>
|
30 |
+
<p>
|
31 |
+
<label class="widget-categories"
|
32 |
+
for="<?php echo $widget_object->get_field_id('mp_categories') ?>"><?php _e('Event categories. Leave blank to display all.', "mp-timetable") ?></label>
|
33 |
+
<select class="widefat mptt-resize-vertical" multiple="multiple" id="<?php echo $widget_object->get_field_id('mp_categories') ?>"
|
34 |
+
name="<?php echo $widget_object->get_field_name('mp_categories') ?>[]">
|
35 |
+
<?php
|
36 |
+
if ( !empty($event_categories) ):
|
37 |
+
foreach ( $event_categories as $category ) :
|
38 |
+
if ( empty($instance['mp_categories']) ):
|
39 |
+
$instance['mp_categories'] = array();
|
40 |
+
endif ?>
|
41 |
+
<option value="<?php echo $category->term_id ?>"<?php
|
42 |
+
echo in_array($category->term_id, $instance['mp_categories']) ? 'selected="selected"' : '' ?> ><?php
|
43 |
+
echo $category->name
|
44 |
+
?></option>
|
45 |
+
<?php endforeach;
|
46 |
+
endif; ?>
|
47 |
+
</select>
|
48 |
+
<small><?php _e('Hold the Ctrl or Command key to select/deselect multiple options.', 'mp-timetable'); ?></small>
|
49 |
+
</p>
|
50 |
+
<p>
|
51 |
+
<label
|
52 |
+
for="<?php echo $widget_object->get_field_id('limit') ?>"><?php _e('Number of events to display', "mp-timetable") ?></label>
|
53 |
+
<input class="widefat" id="<?php echo $widget_object->get_field_id('limit') ?>"
|
54 |
+
name="<?php echo $widget_object->get_field_name('limit') ?>" type="text"
|
55 |
+
value="<?php echo $instance['limit'] ?>">
|
56 |
+
</p>
|
57 |
+
<p>
|
58 |
+
<label
|
59 |
+
for="<?php echo $widget_object->get_field_id('disable_url') ?>"><?php _e('Disable event link', "mp-timetable") ?></label>
|
60 |
+
<select class="widefat" id="<?php echo $widget_object->get_field_id('disable_url') ?>"
|
61 |
+
name="<?php echo $widget_object->get_field_name('disable_url') ?>">
|
62 |
+
<option
|
63 |
+
value="0" <?php echo $instance['disable_url'] === '0' ? 'selected="selected"' : '' ?>> <?php _e('No', "mp-timetable") ?> </option>
|
64 |
+
<option
|
65 |
+
value="1" <?php echo $instance['disable_url'] === '1' ? 'selected="selected"' : '' ?>> <?php _e('Yes', "mp-timetable") ?> </option>
|
66 |
+
</select>
|
67 |
+
</p>
|
68 |
+
<p>
|
69 |
+
<label
|
70 |
+
for="<?php echo $widget_object->get_field_id('custom_url') ?>"><?php _e('Custom link for events', "mp-timetable") ?></label>
|
71 |
+
<input class="widefat" id="<?php echo $widget_object->get_field_id('custom_url') ?>"
|
72 |
+
name="<?php echo $widget_object->get_field_name('custom_url') ?>" type="text"
|
73 |
+
value="<?php echo $instance['custom_url'] ?>">
|
74 |
+
</p>
|
75 |
+
<?php if (\mp_timetable\classes\models\Settings::get_instance()->is_plugin_template_mode()): ?>
|
76 |
+
<p style="margin-bottom:0px;">
|
77 |
+
<label
|
78 |
+
for="<?php echo $widget_object->get_field_id('background_color'); ?>"><?php _e('Event background color', "mp-timetable"); ?></label>
|
79 |
+
</p>
|
80 |
+
<p class="select-color" style="margin-top:0px;">
|
81 |
+
<input type="hidden" class="clr-picker" value="<?php echo $instance['background_color']; ?>">
|
82 |
+
<input class="regular-text" id="<?php echo $widget_object->get_field_id('background_color'); ?>"
|
83 |
+
name="<?php echo $widget_object->get_field_name('background_color'); ?>" type="text"
|
84 |
+
value="<?php echo $instance['background_color']; ?>"/>
|
85 |
+
</p>
|
86 |
+
<p style="margin-bottom:0px;">
|
87 |
+
<label
|
88 |
+
for="<?php echo $widget_object->get_field_id('hover_background_color'); ?>"><?php _e('Event background color on hover', "mp-timetable"); ?></label>
|
89 |
+
</p>
|
90 |
+
<p class="select-color" style="margin-top:0px;">
|
91 |
+
<input type="hidden" class="clr-picker" value="<?php echo $instance['hover_background_color']; ?>">
|
92 |
+
<input class="regular-text" id="<?php echo $widget_object->get_field_id('hover_background_color'); ?>"
|
93 |
+
name="<?php echo $widget_object->get_field_name('hover_background_color'); ?>" type="text"
|
94 |
+
value="<?php echo $instance['hover_background_color']; ?>"/>
|
95 |
+
</p>
|
96 |
+
<p style="margin-bottom:0px;">
|
97 |
+
<label
|
98 |
+
for="<?php echo $widget_object->get_field_id('text_color'); ?>"><?php _e('Event text color', "mp-timetable"); ?></label>
|
99 |
+
</p>
|
100 |
+
<p class="select-color" style="margin-top:0px;">
|
101 |
+
<input type="hidden" class="clr-picker" value="<?php echo $instance['text_color']; ?>">
|
102 |
+
<input class="regular-text" id="<?php echo $widget_object->get_field_id('text_color'); ?>"
|
103 |
+
name="<?php echo $widget_object->get_field_name('text_color'); ?>" type="text"
|
104 |
+
value="<?php echo $instance['text_color']; ?>"/>
|
105 |
+
</p>
|
106 |
+
<p style="margin-bottom:0px;">
|
107 |
+
<label
|
108 |
+
for="<?php echo $widget_object->get_field_id('hover_text_color'); ?>"><?php _e('Event text color on hover', "mp-timetable"); ?></label>
|
109 |
+
</p>
|
110 |
+
<p class="select-color" style="margin-top:0px;">
|
111 |
+
<input type="hidden" class="clr-picker" value="<?php echo $instance['hover_text_color']; ?>">
|
112 |
+
<input class="regular-text" id="<?php echo $widget_object->get_field_id('hover_text_color'); ?>"
|
113 |
+
name="<?php echo $widget_object->get_field_name('hover_text_color'); ?>" type="text"
|
114 |
+
value="<?php echo $instance['hover_text_color']; ?>"/>
|
115 |
+
</p>
|
116 |
+
<p style="margin-bottom:0px;">
|
117 |
+
<label
|
118 |
+
for="<?php echo $widget_object->get_field_id('item_border_color'); ?>"><?php _e('Event border color', "mp-timetable"); ?></label>
|
119 |
+
</p>
|
120 |
+
<P class="select-color" style="margin-top:0px;">
|
121 |
+
<input type="hidden" class="clr-picker" value="<?php echo $instance['item_border_color']; ?>">
|
122 |
+
<input class="regular-text" id="<?php echo $widget_object->get_field_id('item_border_color'); ?>"
|
123 |
+
name="<?php echo $widget_object->get_field_name('item_border_color'); ?>" type="text"
|
124 |
+
value="<?php echo $instance['item_border_color']; ?>"/>
|
125 |
+
</P>
|
126 |
+
<p style="margin-bottom:0px;">
|
127 |
+
<label
|
128 |
+
for="<?php echo $widget_object->get_field_id('hover_item_border_color'); ?>"><?php _e('Event border color on hover', "mp-timetable"); ?></label>
|
129 |
+
</p>
|
130 |
+
<p class="select-color" style="margin-top:0px;">
|
131 |
+
<input type="hidden" class="clr-picker" value="<?php echo $instance['hover_item_border_color']; ?>">
|
132 |
+
<input class="regular-text" id="<?php echo $widget_object->get_field_id('hover_item_border_color'); ?>"
|
133 |
+
name="<?php echo $widget_object->get_field_name('hover_item_border_color'); ?>" type="text"
|
134 |
+
value="<?php echo $instance['hover_item_border_color']; ?>"/>
|
135 |
+
</p>
|
136 |
+
<?php else: ?>
|
137 |
+
<input type="hidden" name="<?php echo $widget_object->get_field_name('background_color'); ?>" value=""/>
|
138 |
+
<input type="hidden" name="<?php echo $widget_object->get_field_name('hover_background_color'); ?>" value=""/>
|
139 |
+
<input type="hidden" name="<?php echo $widget_object->get_field_name('text_color'); ?>" value=""/>
|
140 |
+
<input type="hidden" name="<?php echo $widget_object->get_field_name('hover_text_color'); ?>" value=""/>
|
141 |
+
<input type="hidden" name="<?php echo $widget_object->get_field_name('item_border_color'); ?>" value=""/>
|
142 |
+
<input type="hidden" name="<?php echo $widget_object->get_field_name('hover_item_border_color'); ?>" value=""/>
|
143 |
+
<?php endif; ?>
|
144 |
+
</div>
|
145 |
+
<script type="application/javascript">
|
146 |
+
(function($) {
|
147 |
+
"use strict";
|
148 |
+
$(document).ready(function() {
|
149 |
+
Registry._get("Event").initColorPicker('#widgets-right .mptt-container');
|
150 |
+
Registry._get("Event").displaySettings("<?php echo $widget_object->get_field_id('view_settings') ?>");
|
151 |
+
Registry._get("Event").timeMode("<?php echo $widget_object->get_field_id('time_settings');?>");
|
152 |
+
});
|
153 |
+
})(jQuery);
|
154 |
</script>
|
templates/widgets/widget-view.php
CHANGED
@@ -1,96 +1,96 @@
|
|
1 |
-
<?php echo $args['before_widget'] ?>
|
2 |
-
|
3 |
-
<?php use mp_timetable\classes\models\Events as Events;
|
4 |
-
|
5 |
-
if (!empty($instance['title'])) {
|
6 |
-
echo $args['before_title'] . $instance['title'] . $args['after_title'];
|
7 |
-
}
|
8 |
-
|
9 |
-
do_action('mptt_widget_template_before_content', $events);
|
10 |
-
|
11 |
-
$events_group_by_categories = array();
|
12 |
-
|
13 |
-
foreach ($events as $event) {
|
14 |
-
if (!isset($temp[$event->column_id])) {
|
15 |
-
$events_group_by_categories[$event->column_id][] = $event;
|
16 |
-
} else {
|
17 |
-
$events_group_by_categories[$event->column_id][] = $event;
|
18 |
-
}
|
19 |
-
}
|
20 |
-
|
21 |
-
if (!empty($events)): ?>
|
22 |
-
<?php foreach ($events_group_by_categories as $key_category => $cat_events) { ?>
|
23 |
-
<ul>
|
24 |
-
<?php foreach ($cat_events as $key => $event):
|
25 |
-
$widget = false;
|
26 |
-
$background_color = Events::get_instance()->choose_event_color(array('event_color' => $event->post->color, 'widget_color' => $instance['background_color']));
|
27 |
-
$background_hover_color = Events::get_instance()->choose_event_color(array('event_color' => $event->post->hover_color, 'widget_color' => $instance['hover_background_color']));
|
28 |
-
$color = Events::get_instance()->choose_event_color(array('event_color' => $event->post->text_color, 'widget_color' => $instance['text_color']));
|
29 |
-
$hover_color = Events::get_instance()->choose_event_color(array('event_color' => $event->post->hover_text_color, 'widget_color' => $instance['hover_text_color']));
|
30 |
-
$style = 'style="';
|
31 |
-
|
32 |
-
if ($instance['background_color'] != ''
|
33 |
-
|| $instance['hover_background_color'] != ''
|
34 |
-
|| $instance['text_color'] != ''
|
35 |
-
|| $instance['hover_text_color'] != ''
|
36 |
-
|| $instance['item_border_color'] != ''
|
37 |
-
|| $instance['hover_item_border_color'] !== ''
|
38 |
-
) {
|
39 |
-
$widget = true;
|
40 |
-
}
|
41 |
-
|
42 |
-
$event_class = 'event' . ($widget ? ' mptt-colorized' : '');
|
43 |
-
?>
|
44 |
-
|
45 |
-
<li class="<?php echo apply_filters('mptt_widget_upcoming_event_element', $event_class) ?>"
|
46 |
-
<?php if ($widget): ?> data-type="widget"
|
47 |
-
data-background-color="<?php echo $background_color ?>"
|
48 |
-
data-background-hover-color="<?php echo $background_hover_color ?>"
|
49 |
-
data-color="<?php echo $color ?>"
|
50 |
-
data-hover-color="<?php echo $hover_color ?>"
|
51 |
-
data-border-color="<?php echo $instance['item_border_color'] ?>"
|
52 |
-
data-hover-border-color="<?php echo $instance['hover_item_border_color'] ?>"
|
53 |
-
<?php
|
54 |
-
$style .= !empty($instance['item_border_color']) ? ' border-left-color:' . $instance['item_border_color'] . ' ;' : '';
|
55 |
-
$style .= !empty($background_color) ? ' background:' . $background_color . ' ;' : '';
|
56 |
-
$style .= !empty($color) ? ' color:' . $color . ' ;' : '';
|
57 |
-
|
58 |
-
else:
|
59 |
-
$style .= !empty($event->post->color) ? ' border-left-color:' . $event->post->color . ' ;' : '';
|
60 |
-
endif;
|
61 |
-
|
62 |
-
echo $style . '"';
|
63 |
-
?>>
|
64 |
-
|
65 |
-
<?php
|
66 |
-
$disable_url = (bool)$event->post->timetable_disable_url || (bool)$instance['disable_url'];
|
67 |
-
$url = ($instance['custom_url'] != "") ? $instance['custom_url'] : (($event->post->timetable_custom_url != "") ? $event->post->timetable_custom_url : get_permalink($event->event_id)); ?>
|
68 |
-
<h4 class="event-title">
|
69 |
-
<?php if (!$disable_url) { ?>
|
70 |
-
<a href="<?php echo $url ?>" title="<?php echo get_the_title($event->event_id) ?>" class="event-link">
|
71 |
-
<?php }
|
72 |
-
echo get_the_title($event->event_id);
|
73 |
-
if (!$disable_url) { ?>
|
74 |
-
</a>
|
75 |
-
<?php } ?>
|
76 |
-
|
77 |
-
</h4>
|
78 |
-
<?php if ($instance['view_settings'] !== 'today'): ?><p class="column-title"><?php echo get_the_title($event->column_id) ?></p><?php endif; ?>
|
79 |
-
|
80 |
-
<p class="timeslot">
|
81 |
-
<span class="timeslot-start"><?php echo date(get_option('time_format'), strtotime($event->event_start)); ?></span><?php echo apply_filters('mptt_timeslot_delimiter', ' - '); ?><span class="timeslot-end"><?php echo date(get_option('time_format'), strtotime($event->event_end)); ?>
|
82 |
-
</p>
|
83 |
-
|
84 |
-
</li>
|
85 |
-
|
86 |
-
<?php endforeach; ?>
|
87 |
-
</ul>
|
88 |
-
<?php
|
89 |
-
}
|
90 |
-
else:
|
91 |
-
_e('no events found', 'mp-timetable');
|
92 |
-
endif;
|
93 |
-
|
94 |
-
do_action('mptt_widget_template_after_content', $events); ?>
|
95 |
-
|
96 |
<?php echo $args['after_widget'] ?>
|
1 |
+
<?php echo $args['before_widget'] ?>
|
2 |
+
|
3 |
+
<?php use mp_timetable\classes\models\Events as Events;
|
4 |
+
|
5 |
+
if (!empty($instance['title'])) {
|
6 |
+
echo $args['before_title'] . $instance['title'] . $args['after_title'];
|
7 |
+
}
|
8 |
+
|
9 |
+
do_action('mptt_widget_template_before_content', $events);
|
10 |
+
|
11 |
+
$events_group_by_categories = array();
|
12 |
+
|
13 |
+
foreach ($events as $event) {
|
14 |
+
if (!isset($temp[$event->column_id])) {
|
15 |
+
$events_group_by_categories[$event->column_id][] = $event;
|
16 |
+
} else {
|
17 |
+
$events_group_by_categories[$event->column_id][] = $event;
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
if (!empty($events)): ?>
|
22 |
+
<?php foreach ($events_group_by_categories as $key_category => $cat_events) { ?>
|
23 |
+
<ul>
|
24 |
+
<?php foreach ($cat_events as $key => $event):
|
25 |
+
$widget = false;
|
26 |
+
$background_color = Events::get_instance()->choose_event_color(array('event_color' => $event->post->color, 'widget_color' => $instance['background_color']));
|
27 |
+
$background_hover_color = Events::get_instance()->choose_event_color(array('event_color' => $event->post->hover_color, 'widget_color' => $instance['hover_background_color']));
|
28 |
+
$color = Events::get_instance()->choose_event_color(array('event_color' => $event->post->text_color, 'widget_color' => $instance['text_color']));
|
29 |
+
$hover_color = Events::get_instance()->choose_event_color(array('event_color' => $event->post->hover_text_color, 'widget_color' => $instance['hover_text_color']));
|
30 |
+
$style = 'style="';
|
31 |
+
|
32 |
+
if ($instance['background_color'] != ''
|
33 |
+
|| $instance['hover_background_color'] != ''
|
34 |
+
|| $instance['text_color'] != ''
|
35 |
+
|| $instance['hover_text_color'] != ''
|
36 |
+
|| $instance['item_border_color'] != ''
|
37 |
+
|| $instance['hover_item_border_color'] !== ''
|
38 |
+
) {
|
39 |
+
$widget = true;
|
40 |
+
}
|
41 |
+
|
42 |
+
$event_class = 'event' . ($widget ? ' mptt-colorized' : '');
|
43 |
+
?>
|
44 |
+
|
45 |
+
<li class="<?php echo apply_filters('mptt_widget_upcoming_event_element', $event_class) ?>"
|
46 |
+
<?php if ($widget): ?> data-type="widget"
|
47 |
+
data-background-color="<?php echo $background_color ?>"
|
48 |
+
data-background-hover-color="<?php echo $background_hover_color ?>"
|
49 |
+
data-color="<?php echo $color ?>"
|
50 |
+
data-hover-color="<?php echo $hover_color ?>"
|
51 |
+
data-border-color="<?php echo $instance['item_border_color'] ?>"
|
52 |
+
data-hover-border-color="<?php echo $instance['hover_item_border_color'] ?>"
|
53 |
+
<?php
|
54 |
+
$style .= !empty($instance['item_border_color']) ? ' border-left-color:' . $instance['item_border_color'] . ' ;' : '';
|
55 |
+
$style .= !empty($background_color) ? ' background:' . $background_color . ' ;' : '';
|
56 |
+
$style .= !empty($color) ? ' color:' . $color . ' ;' : '';
|
57 |
+
|
58 |
+
else:
|
59 |
+
$style .= !empty($event->post->color) ? ' border-left-color:' . $event->post->color . ' ;' : '';
|
60 |
+
endif;
|
61 |
+
|
62 |
+
echo $style . '"';
|
63 |
+
?>>
|
64 |
+
|
65 |
+
<?php
|
66 |
+
$disable_url = (bool)$event->post->timetable_disable_url || (bool)$instance['disable_url'];
|
67 |
+
$url = ($instance['custom_url'] != "") ? $instance['custom_url'] : (($event->post->timetable_custom_url != "") ? $event->post->timetable_custom_url : get_permalink($event->event_id)); ?>
|
68 |
+
<h4 class="event-title">
|
69 |
+
<?php if (!$disable_url) { ?>
|
70 |
+
<a href="<?php echo $url ?>" title="<?php echo get_the_title($event->event_id) ?>" class="event-link">
|
71 |
+
<?php }
|
72 |
+
echo get_the_title($event->event_id);
|
73 |
+
if (!$disable_url) { ?>
|
74 |
+
</a>
|
75 |
+
<?php } ?>
|
76 |
+
|
77 |
+
</h4>
|
78 |
+
<?php if ($instance['view_settings'] !== 'today'): ?><p class="column-title"><?php echo get_the_title($event->column_id) ?></p><?php endif; ?>
|
79 |
+
|
80 |
+
<p class="timeslot">
|
81 |
+
<span class="timeslot-start"><?php echo date(get_option('time_format'), strtotime($event->event_start)); ?></span><?php echo apply_filters('mptt_timeslot_delimiter', ' - '); ?><span class="timeslot-end"><?php echo date(get_option('time_format'), strtotime($event->event_end)); ?>
|
82 |
+
</p>
|
83 |
+
|
84 |
+
</li>
|
85 |
+
|
86 |
+
<?php endforeach; ?>
|
87 |
+
</ul>
|
88 |
+
<?php
|
89 |
+
}
|
90 |
+
else:
|
91 |
+
_e('no events found', 'mp-timetable');
|
92 |
+
endif;
|
93 |
+
|
94 |
+
do_action('mptt_widget_template_after_content', $events); ?>
|
95 |
+
|
96 |
<?php echo $args['after_widget'] ?>
|