r">
BIN
app/backend/migrations/__pycache__/__init__.cpython-39.pyc
Bestand weergeven

+ 50 - 39
app/backend/models.py

@@ -109,6 +109,8 @@ class Patient(models.Model):
109 109
     birth_date = models.DateField(null=True)
110 110
     age = models.IntegerField(null=True, blank=True)
111 111
     idcard = models.CharField(max_length=20, null=True, blank=False)
112
+    tel = models.CharField(max_length=100, null=True, blank=True)
113
+    line_id = models.CharField(max_length=100, null=True, blank=True)
112 114
     prefix = models.CharField(
113 115
         max_length=30,
114 116
         choices=GENDER_CHOICES,
@@ -148,51 +150,57 @@ class Patient(models.Model):
148 150
     def nearby_from_db(self, dlimit):
149 151
         bd = ""
150 152
         temps = []
151
-        for h0 in  Hospital.objects.all():
152
-            p2 = (h0.geolocation.lat, h0.geolocation.lon)
153
-            p1 = (self.geolocation.lat, self.geolocation.lon)
154
-            d = round(hs.haversine(p1,p2), 2)
155
-            if d < dlimit:
156
-                #bd += f"<tr><td>{h0.title}</td><td>{d}km</td></tr>"
157
-                temps.append({'title': h0.title, 'd': d, 'id': h0.id, 'beds': h0.free_beds()})
158
-                #print(f"to {h0.title} => {hs.haversine(p1, p2)}km")
159
-
160
-        temps.sort(key= lambda s: s['d'], reverse=False)
161
-        for t in temps:
162
-            bd += f"<tr><td><a href='/admin/backend/hospital/{t['id']}/change/' target='_blank'>{t['title']}</a></td><td>{t['d']} km</td><td>{t['beds']}</td></tr>"
163
-
164
-        rt = f'''
165
-<br>
166
-        <table><thead><tr><th>Hospital</th><th>Distance</th><th>Free Beds</th></tr></thead>
167
-        <tbody>
168
-            {bd}
169
-        </tbody>
170
-        </table>
171
-        '''
172
-        return rt
153
+        try:
154
+            for h0 in  Hospital.objects.all():
155
+                p2 = (h0.geolocation.lat, h0.geolocation.lon)
156
+                p1 = (self.geolocation.lat, self.geolocation.lon)
157
+                d = round(hs.haversine(p1,p2), 2)
158
+                if d < dlimit:
159
+                    #bd += f"<tr><td>{h0.title}</td><td>{d}km</td></tr>"
160
+                    temps.append({'title': h0.title, 'd': d, 'id': h0.id, 'beds': h0.free_beds()})
161
+                    #print(f"to {h0.title} => {hs.haversine(p1, p2)}km")
162
+
163
+            temps.sort(key= lambda s: s['d'], reverse=False)
164
+            for t in temps:
165
+                bd += f"<tr><td><a href='/admin/backend/hospital/{t['id']}/change/' target='_blank'>{t['title']}</a></td><td>{t['d']} km</td><td>{t['beds']}</td></tr>"
166
+
167
+            rt = f'''
168
+    <br>
169
+            <table><thead><tr><th>Hospital</th><th>Distance</th><th>Free Beds</th></tr></thead>
170
+            <tbody>
171
+                {bd}
172
+            </tbody>
173
+            </table>
174
+            '''
175
+            return rt
176
+        except:
177
+            return "-"
173 178
 
174 179
     def nearby(self):
175 180
         #self.nearby_from_db()
176
-        r = gmaps.places_nearby(location=(self.geolocation.lat, self.geolocation.lon), type="hospital", radius=10000)
177
-        bd = ""
178
-        for r0 in r['results']:
179
-            openh = "-"
180
-            if 'opening_hours' in r0:
181
-                openh = r0['opening_hours']['open_now']
182
-            else:
181
+        try:
182
+            r = gmaps.places_nearby(location=(self.geolocation.lat, self.geolocation.lon), type="hospital", radius=10000)
183
+            bd = ""
184
+            for r0 in r['results']:
183 185
                 openh = "-"
186
+                if 'opening_hours' in r0:
187
+                    openh = r0['opening_hours']['open_now']
188
+                else:
189
+                    openh = "-"
184 190
 
185
-            bd += f"<tr><td>{r0['name']}</td><td>{openh}</td><td>{r0['vicinity']}</td></tr>"
191
+                bd += f"<tr><td>{r0['name']}</td><td>{openh}</td><td>{r0['vicinity']}</td></tr>"
186 192
 
187
-        rt = f'''
188
-<br>
189
-        <table><thead><tr><th>Name</th><th>Opening Hours</th><th>Vicinity</th></tr></thead>
190
-        <tbody>
191
-            {bd}
192
-        </tbody>
193
-        </table>
194
-        '''
195
-        return rt
193
+            rt = f'''
194
+    <br>
195
+            <table><thead><tr><th>Name</th><th>Opening Hours</th><th>Vicinity</th></tr></thead>
196
+            <tbody>
197
+                {bd}
198
+            </tbody>
199
+            </table>
200
+            '''
201
+            return rt
202
+        except:
203
+            return "-"
196 204
 
197 205
 
198 206
 
@@ -250,6 +258,9 @@ class Hospital(models.Model):
250 258
     address = map_fields.AddressField(max_length=200)
251 259
     geolocation = map_fields.GeoLocationField(max_length=100)
252 260
 
261
+    tel = models.CharField(max_length=100, null=True, blank=True)
262
+    line_id = models.CharField(max_length=100, null=True, blank=True)
263
+
253 264
     created_at = models.DateTimeField(auto_now_add=True, null=True)
254 265
     updated_at = models.DateTimeField(auto_now=True)
255 266
 

BIN
app/front/__pycache__/urls.cpython-39.pyc


BIN
app/front/__pycache__/views.cpython-39.pyc


BIN
app/front/migrations/__pycache__/__init__.cpython-39.pyc


+ 8 - 0
app/front/templates/front/404.html

@@ -0,0 +1,8 @@
1
+
2
+{% extends "base.html" %}
3
+
4
+{% block content %}
5
+<div class="alert alert-success" role="alert">
6
+<h1>ไม่มี page นี้</h1>
7
+</div>
8
+{% endblock %}

+ 7 - 3
app/front/templates/front/index.html

@@ -11,8 +11,10 @@
11 11
         <br>
12 12
         <input type='text' name='lastName' class='form-control' placeholder='นามสกุล' required/>
13 13
         <br>
14
-        <input type='text' name='idCard' class='form-control' placeholder='หมายเลขบัตรประชาชน' required />
15
-        <br>
14
+        <!-- 
15
+        <input type='text' name='idCard' class='form-control' placeholder='หมายเลขบัตรประชาชน' required /> 
16
+        <br> -->
17
+        <label>วันเกิด</label>
16 18
         <input type='date' name='bd' class='form-control' placeholder='วันเกิด' required />
17 19
         <br>
18 20
         <textarea name='address' class='form-control' placeholder='ที่อยู่' required></textarea>  
@@ -21,8 +23,10 @@
21 23
         <br>
22 24
         <input type='tel' name='tel' class='form-control' placeholder='Tel.' required/>
23 25
         <br>
26
+        <input type='text' name='line_id' class='form-control' placeholder='Line ID'/>
27
+        <br>
24 28
         <label>อัพโหลดภาพ</label>
25
-        <input type="file" name='photo' accept="image/*;capture=camera" class='form-control' required> </br>
29
+        <input type="file" name='photo' accept="image/*;capture=camera" class='form-control'> </br>
26 30
         <span class="glyphicon glyphicon-map-marker"></span>
27 31
         <a class='btn btn-primary form-control' id="currentLocationBtn">
28 32
         <i class="bi bi-geo-alt-fill"></i>

+ 33 - 0
app/front/templates/front/tracking.html

@@ -0,0 +1,33 @@
1
+
2
+{% extends "base.html" %}
3
+
4
+{% block content %}
5
+<div class="alert alert-success" role="alert">
6
+<h1>Tracking</h1>
7
+        <input type='text' class='form-control' name='geo' id='geoText' readonly/><br>
8
+        <br>Last Update
9
+        <span id='lastUpdate'></span>
10
+</div>
11
+{% endblock %}
12
+{% block foot_script %}
13
+<script>
14
+    $(function() {
15
+
16
+        setInterval(function(){
17
+            console.log("Hello");
18
+            if ("geolocation" in navigator){ //check geolocation available
19
+                //try to get user current location using getCurrentPosition() method
20
+                console.log("current location");
21
+                navigator.geolocation.getCurrentPosition(function(position){
22
+                    console.log("xxxx");
23
+                    $("#geoText").val(position.coords.latitude+","+position.coords.longitude );
24
+                    $("#lastUpdate").html(new Date());
25
+
26
+                });
27
+            }else{
28
+                console.log("Browser doesn't support geolocation!");
29
+            }
30
+        }, 5000);
31
+    });
32
+</script>
33
+{% endblock %}

+ 1 - 0
app/front/urls.py

@@ -5,5 +5,6 @@ from . import views
5 5
 
6 6
 urlpatterns = [
7 7
     path('', views.index, name='index'),
8
+    path('tracking', views.tracking, name='tracking'),
8 9
     path('success', views.success, name='success'),
9 10
 ]

+ 11 - 1
app/front/views.py

@@ -10,11 +10,13 @@ def index(request):
10 10
         p = Patient()
11 11
         p.first_name = request.POST.get('firstName')
12 12
         p.last_name = request.POST.get('lastName')
13
-        p.idcard = request.POST.get('idCard')
13
+        #p.idcard = request.POST.get('idCard')
14 14
         p.address = request.POST.get('address')
15 15
         p.geolocation = request.POST.get('geo')
16 16
         p.birth_date = request.POST.get('bd')
17 17
         p.comment = request.POST.get('comment')
18
+        p.tel = request.POST.get('tel')
19
+        p.line_id = request.POST.get('line_id')
18 20
         p.photo = request.FILES.get('photo')
19 21
         p.patient_status = "request"
20 22
         p.save()
@@ -23,3 +25,11 @@ def index(request):
23 25
 
24 26
 def success(request):
25 27
     return render(request, 'front/success.html')
28
+
29
+def tracking(request):
30
+    return render(request, 'front/tracking.html')
31
+
32
+def my404(request,exception):
33
+    return render(request, 'front/404.html')
34
+    #return redirect("index")
35
+

BIN
app/shaqfindbed/__pycache__/settings.cpython-39.pyc


BIN
app/shaqfindbed/__pycache__/urls.cpython-39.pyc


+ 5 - 1
app/shaqfindbed/settings.py

@@ -27,7 +27,11 @@ SECRET_KEY = 'django-insecure-!=!d6rsewcddw=hr-j46#))^nd-32(kkjmnpxxioi(v&c9!*xn
27 27
 # SECURITY WARNING: don't run with debug turned on in production!
28 28
 DEBUG = True
29 29
 
30
-ALLOWED_HOSTS = []
30
+ALLOWED_HOSTS = [
31
+    "167.71.218.44",
32
+    "localhost",
33
+    '.findbed.xyz'
34
+]
31 35
 
32 36
 
33 37
 # Application definition

+ 6 - 1
app/shaqfindbed/urls.py

@@ -18,13 +18,18 @@ from django.urls import path, include
18 18
 from django.conf import settings
19 19
 from django.conf.urls import url
20 20
 from django.conf.urls.static import static
21
+from django.views.static import serve
22
+
21 23
 
22 24
 urlpatterns = [
25
+    path('', include('front.urls')),
23 26
     path('backend/', include('backend.urls')),
24
-    path('front/', include('front.urls')),
25 27
     path('admin/', admin.site.urls),
26 28
     url(r'^chaining/', include('smart_selects.urls')),
29
+    url(r'^media/(?P<path>.*)$', serve,{'document_root': settings.MEDIA_ROOT}),
27 30
 ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
28 31
 
32
+
29 33
 if settings.DEBUG:
30 34
     urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
35
+handler404 = 'front.views.my404'

+ 162 - 0
app/staticfile/autocomplete_light/autocomplete.init.js

@@ -0,0 +1,162 @@
1
+/*
2
+This script garantees that this will be called once in django admin.
3
+However, its the callback's responsability to clean up if the
4
+element was cloned with data - which should be the case.
5
+*/
6
+
7
+;(function ($) {
8
+    $.fn.getFormPrefix = function() {
9
+        /* Get the form prefix for a field.
10
+         *
11
+         * For example:
12
+         *
13
+         *     $(':input[name$=owner]').getFormsetPrefix()
14
+         *
15
+         * Would return an empty string for an input with name 'owner' but would return
16
+         * 'inline_model-0-' for an input named 'inline_model-0-owner'.
17
+         */
18
+        var parts = $(this).attr('name').split('-');
19
+        var prefix = '';
20
+
21
+        for (var i in parts) {
22
+            var testPrefix = parts.slice(0, -i).join('-');
23
+            if (! testPrefix.length) continue;
24
+            testPrefix += '-';
25
+
26
+            var result = $(':input[name^=' + testPrefix + ']')
27
+
28
+            if (result.length) {
29
+                return testPrefix;
30
+            }
31
+        }
32
+
33
+        return '';
34
+    }
35
+
36
+    $.fn.getFormPrefixes = function() {
37
+        /*
38
+         * Get the form prefixes for a field, from the most specific to the least.
39
+         *
40
+         * For example:
41
+         *
42
+         *      $(':input[name$=owner]').getFormPrefixes()
43
+         *
44
+         * Would return:
45
+         * - [''] for an input named 'owner'.
46
+         * - ['inline_model-0-', ''] for an input named 'inline_model-0-owner' (i.e. nested with a nested inline).
47
+         * - ['sections-0-items-0-', 'sections-0-', ''] for an input named 'sections-0-items-0-product'
48
+         *   (i.e. nested multiple time with django-nested-admin).
49
+         */
50
+        var parts = $(this).attr('name').split('-').slice(0, -1);
51
+        var prefixes = [];
52
+
53
+        for (i = 0; i < parts.length; i += 2) {
54
+            var testPrefix = parts.slice(0, -i || parts.length).join('-');
55
+            if (!testPrefix.length)
56
+                continue;
57
+
58
+            testPrefix += '-';
59
+
60
+            var result = $(':input[name^=' + testPrefix + ']')
61
+
62
+            if (result.length)
63
+                prefixes.push(testPrefix);
64
+        }
65
+
66
+        prefixes.push('');
67
+
68
+        return prefixes;
69
+    }
70
+
71
+    var initialized = [];
72
+
73
+    function initialize(element) {
74
+        if (typeof element === 'undefined' || typeof element === 'number') {
75
+            element = this;
76
+        }
77
+
78
+        if (window.__dal__initListenerIsSet !== true || initialized.indexOf(element) >= 0) {
79
+            return;
80
+        }
81
+
82
+        $(element).trigger('autocompleteLightInitialize');
83
+        initialized.push(element);
84
+    }
85
+
86
+    if (!window.__dal__initialize) {
87
+        window.__dal__initialize = initialize;
88
+
89
+        $(document).ready(function () {
90
+            $('[data-autocomplete-light-function=select2]:not([id*="__prefix__"])').each(initialize);
91
+        });
92
+
93
+        $(document).bind('DOMNodeInserted', function (e) {
94
+            $(e.target).find('[data-autocomplete-light-function=select2]').each(initialize);
95
+        });
96
+    }
97
+
98
+    // using jQuery
99
+    function getCookie(name) {
100
+        var cookieValue = null;
101
+        if (document.cookie && document.cookie != '') {
102
+            var cookies = document.cookie.split(';');
103
+            for (var i = 0; i < cookies.length; i++) {
104
+                var cookie = $.trim(cookies[i]);
105
+                // Does this cookie string begin with the name we want?
106
+                if (cookie.substring(0, name.length + 1) == (name + '=')) {
107
+                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
108
+                    break;
109
+                }
110
+            }
111
+        }
112
+        return cookieValue;
113
+    }
114
+
115
+    document.csrftoken = getCookie('csrftoken');
116
+    if (document.csrftoken === null) {
117
+        // Try to get CSRF token from DOM when cookie is missing
118
+        var $csrf = $('form :input[name="csrfmiddlewaretoken"]');
119
+        if ($csrf.length > 0) {
120
+            document.csrftoken = $csrf[0].value;
121
+        }
122
+    }
123
+})(yl.jQuery);
124
+
125
+// Does the same thing as django's admin/js/autocomplete.js, but uses yl.jQuery.
126
+(function($) {
127
+    'use strict';
128
+    var init = function($element, options) {
129
+        var settings = $.extend({
130
+            ajax: {
131
+                data: function(params) {
132
+                    return {
133
+                        term: params.term,
134
+                        page: params.page
135
+                    };
136
+                }
137
+            }
138
+        }, options);
139
+        $element.select2(settings);
140
+    };
141
+
142
+    $.fn.djangoAdminSelect2 = function(options) {
143
+        var settings = $.extend({}, options);
144
+        $.each(this, function(i, element) {
145
+            var $element = $(element);
146
+            init($element, settings);
147
+        });
148
+        return this;
149
+    };
150
+
151
+    $(function() {
152
+        // Initialize all autocomplete widgets except the one in the template
153
+        // form used when a new formset is added.
154
+        $('.admin-autocomplete').not('[name*=__prefix__]').djangoAdminSelect2();
155
+    });
156
+
157
+    $(document).on('formset:added', (function() {
158
+        return function(event, $newFormset) {
159
+            return $newFormset.find('.admin-autocomplete').djangoAdminSelect2();
160
+        };
161
+    })(this));
162
+}(yl.jQuery));

+ 191 - 0
app/staticfile/autocomplete_light/forward.js

@@ -0,0 +1,191 @@
1
+;(function($, yl) {
2
+    yl.forwardHandlerRegistry = yl.forwardHandlerRegistry || {};
3
+
4
+    yl.registerForwardHandler = function(name, handler) {
5
+        yl.forwardHandlerRegistry[name] = handler;
6
+    };
7
+
8
+    yl.getForwardHandler = function(name) {
9
+        return yl.forwardHandlerRegistry[name];
10
+    };
11
+
12
+    function getForwardStrategy(element) {
13
+        var checkForCheckboxes = function() {
14
+            var all = true;
15
+            $.each(element, function(ix, e) {
16
+                if ($(e).attr("type") !== "checkbox") {
17
+                    all = false;
18
+                }
19
+            });
20
+            return all;
21
+        };
22
+
23
+        if (element.length === 1 &&
24
+                element.attr("type") === "checkbox" &&
25
+                element.attr("value") === undefined) {
26
+            // Single checkbox without 'value' attribute
27
+            // Boolean field
28
+            return "exists";
29
+        } else if (element.length === 1 &&
30
+                element.attr("multiple") !== undefined) {
31
+            // Multiple by HTML semantics. E. g. multiple select
32
+            // Multiple choice field
33
+            return "multiple";
34
+        } else if (checkForCheckboxes()) {
35
+            // Multiple checkboxes or one checkbox with 'value' attribute.
36
+            // Multiple choice field represented by checkboxes
37
+            return "multiple";
38
+        } else {
39
+            // Other cases
40
+            return "single";
41
+        }
42
+    }
43
+
44
+    /**
45
+     * Get fields with name `name` relative to `element` with considering form
46
+     * prefixes.
47
+     * @param element the element
48
+     * @param name name of the field
49
+     * @returns jQuery object with found fields or empty jQuery object if no
50
+     * field was found
51
+     */
52
+    yl.getFieldRelativeTo = function(element, name) {
53
+        var prefixes = $(element).getFormPrefixes();
54
+
55
+        for (var i = 0; i < prefixes.length; i++) {
56
+            var fieldSelector = "[name=" + prefixes[i] + name + "]";
57
+            var field = $(fieldSelector);
58
+
59
+            if (field.length) {
60
+                return field;
61
+            }
62
+        }
63
+
64
+        return $();
65
+    };
66
+
67
+    /**
68
+     * Get field value which is put to forwarded dictionary
69
+     * @param field the field
70
+     * @returns forwarded value
71
+     */
72
+    yl.getValueFromField = function(field) {
73
+        var strategy = getForwardStrategy(field);
74
+        var serializedField = $(field).serializeArray();
75
+
76
+        if ((serializedField == false) && ($(field).prop('disabled'))) {
77
+            $(field).prop('disabled', false);
78
+            serializedField = $(field).serializeArray();
79
+            $(field).prop('disabled', true);
80
+        }
81
+
82
+        var getSerializedFieldElementAt = function (index) {
83
+            // Return serializedField[index]
84
+            // or null if something went wrong
85
+            if (serializedField.length > index) {
86
+                return serializedField[index];
87
+            } else {
88
+                return null;
89
+            }
90
+        };
91
+
92
+        var getValueOf = function (elem) {
93
+            // Return elem.value
94
+            // or null if something went wrong
95
+            if (elem.hasOwnProperty("value") &&
96
+                elem.value !== undefined
97
+            ) {
98
+                return elem.value;
99
+            } else {
100
+                return null;
101
+            }
102
+        };
103
+
104
+        var getSerializedFieldValueAt = function (index) {
105
+            // Return serializedField[index].value
106
+            // or null if something went wrong
107
+            var elem = getSerializedFieldElementAt(index);
108
+            if (elem !== null) {
109
+                return getValueOf(elem);
110
+            } else {
111
+                return null;
112
+            }
113
+        };
114
+
115
+        if (strategy === "multiple") {
116
+            return serializedField.map(
117
+                function (item) {
118
+                    return getValueOf(item);
119
+                }
120
+            );
121
+        } else if (strategy === "exists") {
122
+            return serializedField.length > 0;
123
+        } else {
124
+            return getSerializedFieldValueAt(0);
125
+        }
126
+    };
127
+
128
+    yl.getForwards = function(element) {
129
+        var forwardElem,
130
+            forwardList,
131
+            forwardedData,
132
+            divSelector,
133
+            form;
134
+        divSelector = "div.dal-forward-conf#dal-forward-conf-for-" +
135
+                element.attr("id") + ", " +
136
+                "div.dal-forward-conf#dal-forward-conf-for_" +
137
+                element.attr("id");
138
+        form = element.length > 0 ? $(element[0].form) : $();
139
+
140
+        forwardElem =
141
+            form.find(divSelector).find('script');
142
+        if (forwardElem.length === 0) {
143
+            return;
144
+        }
145
+        try {
146
+            forwardList = JSON.parse(forwardElem.text());
147
+        } catch (e) {
148
+            return;
149
+        }
150
+
151
+        if (!Array.isArray(forwardList)) {
152
+            return;
153
+        }
154
+
155
+        forwardedData = {};
156
+
157
+        $.each(forwardList, function(ix, field) {
158
+            var srcName, dstName;
159
+            if (field.type === "const") {
160
+                forwardedData[field.dst] = field.val;
161
+            } else if (field.type === "self") {
162
+                if (field.hasOwnProperty("dst")) {
163
+                    dstName = field.dst;
164
+                } else {
165
+                    dstName = "self";
166
+                }
167
+                forwardedData[dstName] = yl.getValueFromField(element);
168
+            } else if (field.type === "field") {
169
+                srcName = field.src;
170
+                if (field.hasOwnProperty("dst")) {
171
+                    dstName = field.dst;
172
+                } else {
173
+                    dstName = srcName;
174
+                }
175
+                var forwardedField = yl.getFieldRelativeTo(element, srcName);
176
+
177
+                if (!forwardedField.length) {
178
+                    return;
179
+                }
180
+
181
+                forwardedData[dstName] = yl.getValueFromField(forwardedField);
182
+            } else if (field.type === "javascript") {
183
+                var handler = yl.getForwardHandler(field.handler);
184
+                forwardedData[field.dst || field.handler] = handler(element);
185
+            }
186
+
187
+        });
188
+        return JSON.stringify(forwardedData);
189
+    };
190
+
191
+})(yl.jQuery, yl);

+ 36 - 0
app/staticfile/autocomplete_light/jquery.init.js

@@ -0,0 +1,36 @@
1
+var yl = yl || {};
2
+if (typeof django !== 'undefined' && typeof django.jQuery !== 'undefined') {
3
+    // If django.jQuery is already defined, use it.
4
+    yl.jQuery = django.jQuery;
5
+}
6
+else {
7
+    // We include jquery itself in our widget's media, because we need it.
8
+    // Normally, we expect our widget's reference to admin/js/vendor/jquery/jquery.js
9
+    // to be skipped, because django's own code has already included it.
10
+    // However, if django.jQuery is NOT defined, we know that jquery was not
11
+    // included before we did it ourselves. This can happen if we're not being
12
+    // rendered in a django admin form.
13
+    // However, someone ELSE'S jQuery may have been included before ours, in
14
+    // which case we must ensure that our jquery doesn't override theirs, since
15
+    // it might be a newer version that other code on the page relies on.
16
+    // Thus, we must run jQuery.noConflict(true) here to move our jQuery out of
17
+    // the way.
18
+    yl.jQuery = jQuery.noConflict(true);
19
+}
20
+
21
+// In addition to all of this, we must ensure that the global jQuery and $ are
22
+// defined, because Select2 requires that. jQuery will only be undefined at
23
+// this point if only we or django included it.
24
+if (typeof jQuery === 'undefined') {
25
+    jQuery = yl.jQuery;
26
+    $ = yl.jQuery;
27
+}
28
+else {
29
+    // jQuery IS still defined, which means someone else also included jQuery.
30
+    // In this situation, we need to store the old jQuery in a
31
+    // temp variable, set the global jQuery to our yl.jQuery, then let select2
32
+    // set itself up. We restore the global jQuery to its original value in
33
+    // jquery.post-setup.js.
34
+    dal_jquery_backup = jQuery.noConflict(true);
35
+    jQuery = yl.jQuery;
36
+}

+ 7 - 0
app/staticfile/autocomplete_light/jquery.post-setup.js

@@ -0,0 +1,7 @@
1
+if (typeof dal_jquery_backup !== 'undefined') {
2
+    // We made a backup of the original global jQuery before forcing it to our
3
+    // yl.jQuery value. Now that select2 has been set up, we need to restore
4
+    // our backup to its rightful place.
5
+    jQuery = dal_jquery_backup;
6
+    $ = dal_jquery_backup;
7
+}

+ 14 - 0
app/staticfile/autocomplete_light/select2.css

@@ -0,0 +1,14 @@
1
+.select2-container {
2
+    min-width: 20em;
3
+}
4
+
5
+ul li.select2-selection__choice,
6
+ul li.select2-search {
7
+    /* Cancel out django's style */
8
+    list-style-type: none;
9
+}
10
+
11
+.errors .select2-selection {
12
+    /* Highlight select box with error */
13
+    border-color: #ba2121;
14
+}

+ 122 - 0
app/staticfile/autocomplete_light/select2.js

@@ -0,0 +1,122 @@
1
+;(function ($) {
2
+    if (window.__dal__initListenerIsSet)
3
+        return;
4
+
5
+    $(document).on('autocompleteLightInitialize', '[data-autocomplete-light-function=select2]', function() {
6
+        var element = $(this);
7
+
8
+        // Templating helper
9
+        function template(text, is_html) {
10
+            if (is_html) {
11
+                var $result = $('<span>');
12
+                $result.html(text);
13
+                return $result;
14
+            } else {
15
+                return text;
16
+            }
17
+        }
18
+
19
+        function result_template(item) {
20
+            var text = template(item.text,
21
+                element.attr('data-html') !== undefined || element.attr('data-result-html') !== undefined
22
+            );
23
+
24
+            if (item.create_id) {
25
+                return $('<span></span>').text(text).addClass('dal-create')
26
+            } else {
27
+                return text
28
+            }
29
+        }
30
+
31
+        function selected_template(item) {
32
+            if (item.selected_text !== undefined) {
33
+                return template(item.selected_text,
34
+                    element.attr('data-html') !== undefined || element.attr('data-selected-html') !== undefined
35
+                );
36
+            } else {
37
+                return result_template(item);
38
+            }
39
+            return
40
+        }
41
+
42
+        var ajax = null;
43
+        if ($(this).attr('data-autocomplete-light-url')) {
44
+            ajax = {
45
+                url: $(this).attr('data-autocomplete-light-url'),
46
+                dataType: 'json',
47
+                delay: 250,
48
+
49
+                data: function (params) {
50
+                    var data = {
51
+                        q: params.term, // search term
52
+                        page: params.page,
53
+                        create: element.attr('data-autocomplete-light-create') && !element.attr('data-tags'),
54
+                        forward: yl.getForwards(element)
55
+                    };
56
+
57
+                    return data;
58
+                },
59
+                processResults: function (data, page) {
60
+                    if (element.attr('data-tags')) {
61
+                        $.each(data.results, function(index, value) {
62
+                            value.id = value.text;
63
+                        });
64
+                    }
65
+
66
+                    return data;
67
+                },
68
+                cache: true
69
+            };
70
+        }
71
+
72
+        $(this).select2({
73
+            tokenSeparators: element.attr('data-tags') ? [','] : null,
74
+            debug: true,
75
+            containerCssClass: ':all:',
76
+            placeholder: element.attr('data-placeholder') || '',
77
+            language: element.attr('data-autocomplete-light-language'),
78
+            minimumInputLength: element.attr('data-minimum-input-length') || 0,
79
+            allowClear: ! $(this).is('[required]'),
80
+            templateResult: result_template,
81
+            templateSelection: selected_template,
82
+            ajax: ajax,
83
+            tags: Boolean(element.attr('data-tags')),
84
+        });
85
+
86
+        $(this).on('select2:selecting', function (e) {
87
+            var data = e.params.args.data;
88
+
89
+            if (data.create_id !== true)
90
+                return;
91
+
92
+            e.preventDefault();
93
+
94
+            var select = $(this);
95
+
96
+            $.ajax({
97
+                url: $(this).attr('data-autocomplete-light-url'),
98
+                type: 'POST',
99
+                dataType: 'json',
100
+                data: {
101
+                    text: data.id,
102
+                    forward: yl.getForwards($(this))
103
+                },
104
+                beforeSend: function(xhr, settings) {
105
+                    xhr.setRequestHeader("X-CSRFToken", document.csrftoken);
106
+                },
107
+                success: function(data, textStatus, jqXHR ) {
108
+                    select.append(
109
+                        $('<option>', {value: data.id, text: data.text, selected: true})
110
+                    );
111
+                    select.trigger('change');
112
+                    select.select2('close');
113
+                }
114
+            });
115
+        });
116
+
117
+    });
118
+    window.__dal__initListenerIsSet = true;
119
+    $('[data-autocomplete-light-function=select2]:not([id*="__prefix__"])').each(function() {
120
+        window.__dal__initialize(this);
121
+    });
122
+})(yl.jQuery);

BIN
app/staticfile/img/heartbeat.png


+ 22 - 0
app/staticfile/import_export/action_formats.js

@@ -0,0 +1,22 @@
1
+(function($) {
2
+  $(document).ready(function() {
3
+    var $actionsSelect, $formatsElement;
4
+    if ($('body').hasClass('grp-change-list')) {
5
+        // using grappelli
6
+        $actionsSelect = $('#grp-changelist-form select[name="action"]');
7
+        $formatsElement = $('#grp-changelist-form select[name="file_format"]');
8
+    } else {
9
+        // using default admin
10
+        $actionsSelect = $('#changelist-form select[name="action"]');
11
+        $formatsElement = $('#changelist-form select[name="file_format"]').parent();
12
+    }
13
+    $actionsSelect.change(function() {
14
+      if ($(this).val() === 'export_admin_action') {
15
+        $formatsElement.show();
16
+      } else {
17
+        $formatsElement.hide();
18
+      }
19
+    });
20
+    $actionsSelect.change();
21
+  });
22
+})(django.jQuery);

+ 81 - 0
app/staticfile/import_export/import.css

@@ -0,0 +1,81 @@
1
+.import-preview .errors {
2
+  position: relative;
3
+}
4
+
5
+.validation-error-count {
6
+  display: inline-block;
7
+  background-color: #e40000;
8
+  border-radius: 6px;
9
+  color: white;
10
+  font-size: 0.9em;
11
+  position: relative;
12
+  font-weight: bold;
13
+  margin-top: -2px;
14
+  padding: 0.2em 0.4em;
15
+}
16
+
17
+.validation-error-container {
18
+  position: absolute;
19
+  opacity: 0;
20
+  pointer-events: none;
21
+  background-color: #ffc1c1;
22
+  padding: 14px 15px 10px;
23
+  top: 25px;
24
+  margin: 0 0 20px 0;
25
+  width: 200px;
26
+  z-index: 2;
27
+}
28
+
29
+table.import-preview tr.skip {
30
+  background-color: #d2d2d2;
31
+}
32
+
33
+table.import-preview tr.new {
34
+  background-color: #bdd8b2;
35
+}
36
+
37
+table.import-preview tr.delete {
38
+  background-color: #f9bebf;
39
+}
40
+
41
+table.import-preview tr.update {
42
+  background-color: #fdfdcf;
43
+}
44
+
45
+.import-preview td:hover .validation-error-count {
46
+  z-index: 3;
47
+}
48
+.import-preview td:hover .validation-error-container {
49
+  opacity: 1;
50
+  pointer-events: auto;
51
+}
52
+
53
+.validation-error-list {
54
+  margin: 0;
55
+  padding: 0;
56
+}
57
+
58
+.validation-error-list li {
59
+  list-style: none;
60
+  margin: 0;
61
+}
62
+
63
+.validation-error-list > li > ul {
64
+  margin: 8px 0;
65
+  padding: 0;
66
+}
67
+
68
+.validation-error-list > li > ul > li {
69
+  padding: 0;
70
+  margin: 0 0 10px;
71
+  line-height: 1.28em;
72
+}
73
+
74
+.validation-error-field-label {
75
+  display: block;
76
+  border-bottom: 1px solid #e40000;
77
+  color: #e40000;
78
+  text-transform: uppercase;
79
+  font-weight: bold;
80
+  font-size: 0.85em;
81
+}

+ 15 - 0
app/staticfile/js/main.js

@@ -0,0 +1,15 @@
1
+$(function(){
2
+    $("#currentLocationBtn").click(function(){
3
+        if ("geolocation" in navigator){ //check geolocation available
4
+            //try to get user current location using getCurrentPosition() method
5
+            console.log("current location");
6
+            navigator.geolocation.getCurrentPosition(function(position){
7
+                console.log("xxxx");
8
+                $("#geoText").val(position.coords.latitude+","+position.coords.longitude );
9
+
10
+            });
11
+        }else{
12
+            console.log("Browser doesn't support geolocation!");
13
+        }
14
+    });
15
+});

+ 262 - 0
app/staticfile/vendor/select2/Gruntfile.js

@@ -0,0 +1,262 @@
1
+const sass = require('node-sass');
2
+
3
+module.exports = function (grunt) {
4
+  // Full list of files that must be included by RequireJS
5
+  includes = [
6
+    'jquery.select2',
7
+    'almond',
8
+
9
+    'jquery-mousewheel' // shimmed for non-full builds
10
+  ];
11
+
12
+  fullIncludes = [
13
+    'jquery',
14
+
15
+    'select2/compat/containerCss',
16
+    'select2/compat/dropdownCss',
17
+
18
+    'select2/compat/initSelection',
19
+    'select2/compat/inputData',
20
+    'select2/compat/matcher',
21
+    'select2/compat/query',
22
+
23
+    'select2/dropdown/attachContainer',
24
+    'select2/dropdown/stopPropagation',
25
+
26
+    'select2/selection/stopPropagation'
27
+  ].concat(includes);
28
+
29
+  var i18nModules = [];
30
+  var i18nPaths = {};
31
+
32
+  var i18nFiles = grunt.file.expand({
33
+    cwd: 'src/js'
34
+  }, 'select2/i18n/*.js');
35
+
36
+  var testFiles = grunt.file.expand('tests/**/*.html');
37
+  var testUrls = testFiles.map(function (filePath) {
38
+    return 'http://localhost:9999/' + filePath;
39
+  });
40
+
41
+  var testBuildNumber = "unknown";
42
+
43
+  if (process.env.TRAVIS_JOB_ID) {
44
+    testBuildNumber = "travis-" + process.env.TRAVIS_JOB_ID;
45
+  } else {
46
+    var currentTime = new Date();
47
+
48
+    testBuildNumber = "manual-" + currentTime.getTime();
49
+  }
50
+
51
+  for (var i = 0; i < i18nFiles.length; i++) {
52
+    var file = i18nFiles[i];
53
+    var name = file.split('.')[0];
54
+
55
+    i18nModules.push({
56
+      name: name
57
+    });
58
+
59
+    i18nPaths[name] = '../../' + name;
60
+  }
61
+
62
+  var minifiedBanner = '/*! Select2 <%= package.version %> | https://github.com/select2/select2/blob/master/LICENSE.md */';
63
+
64
+  grunt.initConfig({
65
+    package: grunt.file.readJSON('package.json'),
66
+
67
+    concat: {
68
+      'dist': {
69
+        options: {
70
+          banner: grunt.file.read('src/js/wrapper.start.js'),
71
+        },
72
+        src: [
73
+          'dist/js/select2.js',
74
+          'src/js/wrapper.end.js'
75
+        ],
76
+        dest: 'dist/js/select2.js'
77
+      },
78
+      'dist.full': {
79
+        options: {
80
+          banner: grunt.file.read('src/js/wrapper.start.js'),
81
+        },
82
+        src: [
83
+          'dist/js/select2.full.js',
84
+          'src/js/wrapper.end.js'
85
+        ],
86
+        dest: 'dist/js/select2.full.js'
87
+      }
88
+    },
89
+
90
+    connect: {
91
+      tests: {
92
+        options: {
93
+          base: '.',
94
+          hostname: '127.0.0.1',
95
+          port: 9999
96
+        }
97
+      }
98
+    },
99
+
100
+    uglify: {
101
+      'dist': {
102
+        src: 'dist/js/select2.js',
103
+        dest: 'dist/js/select2.min.js',
104
+        options: {
105
+          banner: minifiedBanner
106
+        }
107
+      },
108
+      'dist.full': {
109
+        src: 'dist/js/select2.full.js',
110
+        dest: 'dist/js/select2.full.min.js',
111
+        options: {
112
+          banner: minifiedBanner
113
+        }
114
+      }
115
+    },
116
+
117
+    qunit: {
118
+      all: {
119
+        options: {
120
+          urls: testUrls
121
+        }
122
+      }
123
+    },
124
+
125
+    jshint: {
126
+      options: {
127
+        jshintrc: true,
128
+        reporterOutput: ''
129
+      },
130
+      code: {
131
+        src: ['src/js/**/*.js']
132
+      },
133
+      tests: {
134
+        src: ['tests/**/*.js']
135
+      }
136
+    },
137
+
138
+    sass: {
139
+      dist: {
140
+        options: {
141
+          implementation: sass,
142
+          outputStyle: 'compressed'
143
+        },
144
+        files: {
145
+          'dist/css/select2.min.css': [
146
+            'src/scss/core.scss',
147
+            'src/scss/theme/default/layout.css'
148
+          ]
149
+        }
150
+      },
151
+      dev: {
152
+        options: {
153
+          implementation: sass,
154
+          outputStyle: 'nested'
155
+        },
156
+        files: {
157
+          'dist/css/select2.css': [
158
+            'src/scss/core.scss',
159
+            'src/scss/theme/default/layout.css'
160
+          ]
161
+        }
162
+      }
163
+    },
164
+
165
+    requirejs: {
166
+      'dist': {
167
+        options: {
168
+          baseUrl: 'src/js',
169
+          optimize: 'none',
170
+          name: 'select2/core',
171
+          out: 'dist/js/select2.js',
172
+          include: includes,
173
+          namespace: 'S2',
174
+          paths: {
175
+            'almond': require.resolve('almond').slice(0, -3),
176
+            'jquery': 'jquery.shim',
177
+            'jquery-mousewheel': 'jquery.mousewheel.shim'
178
+          },
179
+          wrap: {
180
+            startFile: 'src/js/banner.start.js',
181
+            endFile: 'src/js/banner.end.js'
182
+          }
183
+        }
184
+      },
185
+      'dist.full': {
186
+        options: {
187
+          baseUrl: 'src/js',
188
+          optimize: 'none',
189
+          name: 'select2/core',
190
+          out: 'dist/js/select2.full.js',
191
+          include: fullIncludes,
192
+          namespace: 'S2',
193
+          paths: {
194
+            'almond': require.resolve('almond').slice(0, -3),
195
+            'jquery': 'jquery.shim',
196
+            'jquery-mousewheel': require.resolve('jquery-mousewheel').slice(0, -3)
197
+          },
198
+          wrap: {
199
+            startFile: 'src/js/banner.start.js',
200
+            endFile: 'src/js/banner.end.js'
201
+          }
202
+        }
203
+      },
204
+      'i18n': {
205
+        options: {
206
+          baseUrl: 'src/js/select2/i18n',
207
+          dir: 'dist/js/i18n',
208
+          paths: i18nPaths,
209
+          modules: i18nModules,
210
+          namespace: 'S2',
211
+          wrap: {
212
+            start: minifiedBanner + grunt.file.read('src/js/banner.start.js'),
213
+            end: grunt.file.read('src/js/banner.end.js')
214
+          }
215
+        }
216
+      }
217
+    },
218
+
219
+    watch: {
220
+      js: {
221
+        files: [
222
+          'src/js/select2/**/*.js',
223
+          'tests/**/*.js'
224
+        ],
225
+        tasks: [
226
+          'compile',
227
+          'test',
228
+          'minify'
229
+        ]
230
+      },
231
+      css: {
232
+        files: [
233
+          'src/scss/**/*.scss'
234
+        ],
235
+        tasks: [
236
+          'compile',
237
+          'minify'
238
+        ]
239
+      }
240
+    }
241
+  });
242
+
243
+  grunt.loadNpmTasks('grunt-contrib-concat');
244
+  grunt.loadNpmTasks('grunt-contrib-connect');
245
+  grunt.loadNpmTasks('grunt-contrib-jshint');
246
+  grunt.loadNpmTasks('grunt-contrib-qunit');
247
+  grunt.loadNpmTasks('grunt-contrib-requirejs');
248
+  grunt.loadNpmTasks('grunt-contrib-uglify');
249
+  grunt.loadNpmTasks('grunt-contrib-watch');
250
+
251
+  grunt.loadNpmTasks('grunt-sass');
252
+
253
+  grunt.registerTask('default', ['compile', 'test', 'minify']);
254
+
255
+  grunt.registerTask('compile', [
256
+    'requirejs:dist', 'requirejs:dist.full', 'requirejs:i18n',
257
+    'concat:dist', 'concat:dist.full',
258
+    'sass:dev'
259
+  ]);
260
+  grunt.registerTask('minify', ['uglify', 'sass:dist']);
261
+  grunt.registerTask('test', ['connect:tests', 'qunit', 'jshint']);
262
+};

+ 13 - 0
app/staticfile/vendor/select2/bower.json

@@ -0,0 +1,13 @@
1
+{
2
+    "name": "select2",
3
+    "description": "Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.",
4
+    "main": [
5
+        "dist/js/select2.js",
6
+        "src/scss/core.scss"
7
+    ],
8
+    "license": "MIT",
9
+    "repository": {
10
+        "type": "git",
11
+        "url": "git@github.com:select2/select2.git"
12
+    }
13
+}

+ 19 - 0
app/staticfile/vendor/select2/component.json

@@ -0,0 +1,19 @@
1
+{
2
+  "name": "select2",
3
+  "repo": "select/select2",
4
+  "description": "Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.",
5
+  "version": "4.0.7",
6
+  "demo": "https://select2.org/",
7
+  "keywords": [
8
+    "jquery"
9
+  ],
10
+  "main": "dist/js/select2.js",
11
+  "styles": [
12
+    "dist/css/select2.css"
13
+  ],
14
+  "scripts": [
15
+    "dist/js/select2.js",
16
+    "dist/js/i18n/*.js"
17
+  ],
18
+  "license": "MIT"
19
+}

+ 22 - 0
app/staticfile/vendor/select2/composer.json

@@ -0,0 +1,22 @@
1
+{
2
+  "name": "select2/select2",
3
+  "description": "Select2 is a jQuery based replacement for select boxes.",
4
+  "type": "component",
5
+  "homepage": "https://select2.org/",
6
+  "license": "MIT",
7
+  "extra": {
8
+    "component": {
9
+      "scripts": [
10
+        "dist/js/select2.js"
11
+      ],
12
+      "styles": [
13
+        "dist/css/select2.css"
14
+      ],
15
+      "files": [
16
+        "dist/js/select2.js",
17
+        "dist/js/i18n/*.js",
18
+        "dist/css/select2.css"
19
+      ]
20
+    }
21
+  }
22
+}

+ 484 - 0
app/staticfile/vendor/select2/dist/css/select2.css

@@ -0,0 +1,484 @@
1
+.select2-container {
2
+  box-sizing: border-box;
3
+  display: inline-block;
4
+  margin: 0;
5
+  position: relative;
6
+  vertical-align: middle; }
7
+  .select2-container .select2-selection--single {
8
+    box-sizing: border-box;
9
+    cursor: pointer;
10
+    display: block;
11
+    height: 28px;
12
+    user-select: none;
13
+    -webkit-user-select: none; }
14
+    .select2-container .select2-selection--single .select2-selection__rendered {
15
+      display: block;
16
+      padding-left: 8px;
17
+      padding-right: 20px;
18
+      overflow: hidden;
19
+      text-overflow: ellipsis;
20
+      white-space: nowrap; }
21
+    .select2-container .select2-selection--single .select2-selection__clear {
22
+      position: relative; }
23
+  .select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered {
24
+    padding-right: 8px;
25
+    padding-left: 20px; }
26
+  .select2-container .select2-selection--multiple {
27
+    box-sizing: border-box;
28
+    cursor: pointer;
29
+    display: block;
30
+    min-height: 32px;
31
+    user-select: none;
32
+    -webkit-user-select: none; }
33
+    .select2-container .select2-selection--multiple .select2-selection__rendered {
34
+      display: inline-block;
35
+      overflow: hidden;
36
+      padding-left: 8px;
37
+      text-overflow: ellipsis;
38
+      white-space: nowrap; }
39
+  .select2-container .select2-search--inline {
40
+    float: left; }
41
+    .select2-container .select2-search--inline .select2-search__field {
42
+      box-sizing: border-box;
43
+      border: none;
44
+      font-size: 100%;
45
+      margin-top: 5px;
46
+      padding: 0; }
47
+      .select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button {
48
+        -webkit-appearance: none; }
49
+
50
+.select2-dropdown {
51
+  background-color: white;
52
+  border: 1px solid #aaa;
53
+  border-radius: 4px;
54
+  box-sizing: border-box;
55
+  display: block;
56
+  position: absolute;
57
+  left: -100000px;
58
+  width: 100%;
59
+  z-index: 1051; }
60
+
61
+.select2-results {
62
+  display: block; }
63
+
64
+.select2-results__options {
65
+  list-style: none;
66
+  margin: 0;
67
+  padding: 0; }
68
+
69
+.select2-results__option {
70
+  padding: 6px;
71
+  user-select: none;
72
+  -webkit-user-select: none; }
73
+  .select2-results__option[aria-selected] {
74
+    cursor: pointer; }
75
+
76
+.select2-container--open .select2-dropdown {
77
+  left: 0; }
78
+
79
+.select2-container--open .select2-dropdown--above {
80
+  border-bottom: none;
81
+  border-bottom-left-radius: 0;
82
+  border-bottom-right-radius: 0; }
83
+
84
+.select2-container--open .select2-dropdown--below {
85
+  border-top: none;
86
+  border-top-left-radius: 0;
87
+  border-top-right-radius: 0; }
88
+
89
+.select2-search--dropdown {
90
+  display: block;
91
+  padding: 4px; }
92
+  .select2-search--dropdown .select2-search__field {
93
+    padding: 4px;
94
+    width: 100%;
95
+    box-sizing: border-box; }
96
+    .select2-search--dropdown .select2-search__field::-webkit-search-cancel-button {
97
+      -webkit-appearance: none; }
98
+  .select2-search--dropdown.select2-search--hide {
99
+    display: none; }
100
+
101
+.select2-close-mask {
102
+  border: 0;
103
+  margin: 0;
104
+  padding: 0;
105
+  display: block;
106
+  position: fixed;
107
+  left: 0;
108
+  top: 0;
109
+  min-height: 100%;
110
+  min-width: 100%;
111
+  height: auto;
112
+  width: auto;
113
+  opacity: 0;
114
+  z-index: 99;
115
+  background-color: #fff;
116
+  filter: alpha(opacity=0); }
117
+
118
+.select2-hidden-accessible {
119
+  border: 0 !important;
120
+  clip: rect(0 0 0 0) !important;
121
+  -webkit-clip-path: inset(50%) !important;
122
+  clip-path: inset(50%) !important;
123
+  height: 1px !important;
124
+  overflow: hidden !important;
125
+  padding: 0 !important;
126
+  position: absolute !important;
127
+  width: 1px !important;
128
+  white-space: nowrap !important; }
129
+
130
+.select2-container--default .select2-selection--single {
131
+  background-color: #fff;
132
+  border: 1px solid #aaa;
133
+  border-radius: 4px; }
134
+  .select2-container--default .select2-selection--single .select2-selection__rendered {
135
+    color: #444;
136
+    line-height: 28px; }
137
+  .select2-container--default .select2-selection--single .select2-selection__clear {
138
+    cursor: pointer;
139
+    float: right;
140
+    font-weight: bold; }
141
+  .select2-container--default .select2-selection--single .select2-selection__placeholder {
142
+    color: #999; }
143
+  .select2-container--default .select2-selection--single .select2-selection__arrow {
144
+    height: 26px;
145
+    position: absolute;
146
+    top: 1px;
147
+    right: 1px;
148
+    width: 20px; }
149
+    .select2-container--default .select2-selection--single .select2-selection__arrow b {
150
+      border-color: #888 transparent transparent transparent;
151
+      border-style: solid;
152
+      border-width: 5px 4px 0 4px;
153
+      height: 0;
154
+      left: 50%;
155
+      margin-left: -4px;
156
+      margin-top: -2px;
157
+      position: absolute;
158
+      top: 50%;
159
+      width: 0; }
160
+
161
+.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear {
162
+  float: left; }
163
+
164
+.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow {
165
+  left: 1px;
166
+  right: auto; }
167
+
168
+.select2-container--default.select2-container--disabled .select2-selection--single {
169
+  background-color: #eee;
170
+  cursor: default; }
171
+  .select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear {
172
+    display: none; }
173
+
174
+.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
175
+  border-color: transparent transparent #888 transparent;
176
+  border-width: 0 4px 5px 4px; }
177
+
178
+.select2-container--default .select2-selection--multiple {
179
+  background-color: white;
180
+  border: 1px solid #aaa;
181
+  border-radius: 4px;
182
+  cursor: text; }
183
+  .select2-container--default .select2-selection--multiple .select2-selection__rendered {
184
+    box-sizing: border-box;
185
+    list-style: none;
186
+    margin: 0;
187
+    padding: 0 5px;
188
+    width: 100%; }
189
+    .select2-container--default .select2-selection--multiple .select2-selection__rendered li {
190
+      list-style: none; }
191
+  .select2-container--default .select2-selection--multiple .select2-selection__placeholder {
192
+    color: #999;
193
+    margin-top: 5px;
194
+    float: left; }
195
+  .select2-container--default .select2-selection--multiple .select2-selection__clear {
196
+    cursor: pointer;
197
+    float: right;
198
+    font-weight: bold;
199
+    margin-top: 5px;
200
+    margin-right: 10px; }
201
+  .select2-container--default .select2-selection--multiple .select2-selection__choice {
202
+    background-color: #e4e4e4;
203
+    border: 1px solid #aaa;
204
+    border-radius: 4px;
205
+    cursor: default;
206
+    float: left;
207
+    margin-right: 5px;
208
+    margin-top: 5px;
209
+    padding: 0 5px; }
210
+  .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
211
+    color: #999;
212
+    cursor: pointer;
213
+    display: inline-block;
214
+    font-weight: bold;
215
+    margin-right: 2px; }
216
+    .select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
217
+      color: #333; }
218
+
219
+.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder, .select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline {
220
+  float: right; }
221
+
222
+.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
223
+  margin-left: 5px;
224
+  margin-right: auto; }
225
+
226
+.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
227
+  margin-left: 2px;
228
+  margin-right: auto; }
229
+
230
+.select2-container--default.select2-container--focus .select2-selection--multiple {
231
+  border: solid black 1px;
232
+  outline: 0; }
233
+
234
+.select2-container--default.select2-container--disabled .select2-selection--multiple {
235
+  background-color: #eee;
236
+  cursor: default; }
237
+
238
+.select2-container--default.select2-container--disabled .select2-selection__choice__remove {
239
+  display: none; }
240
+
241
+.select2-container--default.select2-container--open.select2-container--above .select2-selection--single, .select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple {
242
+  border-top-left-radius: 0;
243
+  border-top-right-radius: 0; }
244
+
245
+.select2-container--default.select2-container--open.select2-container--below .select2-selection--single, .select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple {
246
+  border-bottom-left-radius: 0;
247
+  border-bottom-right-radius: 0; }
248
+
249
+.select2-container--default .select2-search--dropdown .select2-search__field {
250
+  border: 1px solid #aaa; }
251
+
252
+.select2-container--default .select2-search--inline .select2-search__field {
253
+  background: transparent;
254
+  border: none;
255
+  outline: 0;
256
+  box-shadow: none;
257
+  -webkit-appearance: textfield; }
258
+
259
+.select2-container--default .select2-results > .select2-results__options {
260
+  max-height: 200px;
261
+  overflow-y: auto; }
262
+
263
+.select2-container--default .select2-results__option[role=group] {
264
+  padding: 0; }
265
+
266
+.select2-container--default .select2-results__option[aria-disabled=true] {
267
+  color: #999; }
268
+
269
+.select2-container--default .select2-results__option[aria-selected=true] {
270
+  background-color: #ddd; }
271
+
272
+.select2-container--default .select2-results__option .select2-results__option {
273
+  padding-left: 1em; }
274
+  .select2-container--default .select2-results__option .select2-results__option .select2-results__group {
275
+    padding-left: 0; }
276
+  .select2-container--default .select2-results__option .select2-results__option .select2-results__option {
277
+    margin-left: -1em;
278
+    padding-left: 2em; }
279
+    .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
280
+      margin-left: -2em;
281
+      padding-left: 3em; }
282
+      .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
283
+        margin-left: -3em;
284
+        padding-left: 4em; }
285
+        .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
286
+          margin-left: -4em;
287
+          padding-left: 5em; }
288
+          .select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option {
289
+            margin-left: -5em;
290
+            padding-left: 6em; }
291
+
292
+.select2-container--default .select2-results__option--highlighted[aria-selected] {
293
+  background-color: #5897fb;
294
+  color: white; }
295
+
296
+.select2-container--default .select2-results__group {
297
+  cursor: default;
298
+  display: block;
299
+  padding: 6px; }
300
+
301
+.select2-container--classic .select2-selection--single {
302
+  background-color: #f7f7f7;
303
+  border: 1px solid #aaa;
304
+  border-radius: 4px;
305
+  outline: 0;
306
+  background-image: -webkit-linear-gradient(top, white 50%, #eeeeee 100%);
307
+  background-image: -o-linear-gradient(top, white 50%, #eeeeee 100%);
308
+  background-image: linear-gradient(to bottom, white 50%, #eeeeee 100%);
309
+  background-repeat: repeat-x;
310
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); }
311
+  .select2-container--classic .select2-selection--single:focus {
312
+    border: 1px solid #5897fb; }
313
+  .select2-container--classic .select2-selection--single .select2-selection__rendered {
314
+    color: #444;
315
+    line-height: 28px; }
316
+  .select2-container--classic .select2-selection--single .select2-selection__clear {
317
+    cursor: pointer;
318
+    float: right;
319
+    font-weight: bold;
320
+    margin-right: 10px; }
321
+  .select2-container--classic .select2-selection--single .select2-selection__placeholder {
322
+    color: #999; }
323
+  .select2-container--classic .select2-selection--single .select2-selection__arrow {
324
+    background-color: #ddd;
325
+    border: none;
326
+    border-left: 1px solid #aaa;
327
+    border-top-right-radius: 4px;
328
+    border-bottom-right-radius: 4px;
329
+    height: 26px;
330
+    position: absolute;
331
+    top: 1px;
332
+    right: 1px;
333
+    width: 20px;
334
+    background-image: -webkit-linear-gradient(top, #eeeeee 50%, #cccccc 100%);
335
+    background-image: -o-linear-gradient(top, #eeeeee 50%, #cccccc 100%);
336
+    background-image: linear-gradient(to bottom, #eeeeee 50%, #cccccc 100%);
337
+    background-repeat: repeat-x;
338
+    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0); }
339
+    .select2-container--classic .select2-selection--single .select2-selection__arrow b {
340
+      border-color: #888 transparent transparent transparent;
341
+      border-style: solid;
342
+      border-width: 5px 4px 0 4px;
343
+      height: 0;
344
+      left: 50%;
345
+      margin-left: -4px;
346
+      margin-top: -2px;
347
+      position: absolute;
348
+      top: 50%;
349
+      width: 0; }
350
+
351
+.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear {
352
+  float: left; }
353
+
354
+.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow {
355
+  border: none;
356
+  border-right: 1px solid #aaa;
357
+  border-radius: 0;
358
+  border-top-left-radius: 4px;
359
+  border-bottom-left-radius: 4px;
360
+  left: 1px;
361
+  right: auto; }
362
+
363
+.select2-container--classic.select2-container--open .select2-selection--single {
364
+  border: 1px solid #5897fb; }
365
+  .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow {
366
+    background: transparent;
367
+    border: none; }
368
+    .select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b {
369
+      border-color: transparent transparent #888 transparent;
370
+      border-width: 0 4px 5px 4px; }
371
+
372
+.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single {
373
+  border-top: none;
374
+  border-top-left-radius: 0;
375
+  border-top-right-radius: 0;
376
+  background-image: -webkit-linear-gradient(top, white 0%, #eeeeee 50%);
377
+  background-image: -o-linear-gradient(top, white 0%, #eeeeee 50%);
378
+  background-image: linear-gradient(to bottom, white 0%, #eeeeee 50%);
379
+  background-repeat: repeat-x;
380
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0); }
381
+
382
+.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single {
383
+  border-bottom: none;
384
+  border-bottom-left-radius: 0;
385
+  border-bottom-right-radius: 0;
386
+  background-image: -webkit-linear-gradient(top, #eeeeee 50%, white 100%);
387
+  background-image: -o-linear-gradient(top, #eeeeee 50%, white 100%);
388
+  background-image: linear-gradient(to bottom, #eeeeee 50%, white 100%);
389
+  background-repeat: repeat-x;
390
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0); }
391
+
392
+.select2-container--classic .select2-selection--multiple {
393
+  background-color: white;
394
+  border: 1px solid #aaa;
395
+  border-radius: 4px;
396
+  cursor: text;
397
+  outline: 0; }
398
+  .select2-container--classic .select2-selection--multiple:focus {
399
+    border: 1px solid #5897fb; }
400
+  .select2-container--classic .select2-selection--multiple .select2-selection__rendered {
401
+    list-style: none;
402
+    margin: 0;
403
+    padding: 0 5px; }
404
+  .select2-container--classic .select2-selection--multiple .select2-selection__clear {
405
+    display: none; }
406
+  .select2-container--classic .select2-selection--multiple .select2-selection__choice {
407
+    background-color: #e4e4e4;
408
+    border: 1px solid #aaa;
409
+    border-radius: 4px;
410
+    cursor: default;
411
+    float: left;
412
+    margin-right: 5px;
413
+    margin-top: 5px;
414
+    padding: 0 5px; }
415
+  .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove {
416
+    color: #888;
417
+    cursor: pointer;
418
+    display: inline-block;
419
+    font-weight: bold;
420
+    margin-right: 2px; }
421
+    .select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover {
422
+      color: #555; }
423
+
424
+.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice {
425
+  float: right;
426
+  margin-left: 5px;
427
+  margin-right: auto; }
428
+
429
+.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove {
430
+  margin-left: 2px;
431
+  margin-right: auto; }
432
+
433
+.select2-container--classic.select2-container--open .select2-selection--multiple {
434
+  border: 1px solid #5897fb; }
435
+
436
+.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple {
437
+  border-top: none;
438
+  border-top-left-radius: 0;
439
+  border-top-right-radius: 0; }
440
+
441
+.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple {
442
+  border-bottom: none;
443
+  border-bottom-left-radius: 0;
444
+  border-bottom-right-radius: 0; }
445
+
446
+.select2-container--classic .select2-search--dropdown .select2-search__field {
447
+  border: 1px solid #aaa;
448
+  outline: 0; }
449
+
450
+.select2-container--classic .select2-search--inline .select2-search__field {
451
+  outline: 0;
452
+  box-shadow: none; }
453
+
454
+.select2-container--classic .select2-dropdown {
455
+  background-color: white;
456
+  border: 1px solid transparent; }
457
+
458
+.select2-container--classic .select2-dropdown--above {
459
+  border-bottom: none; }
460
+
461
+.select2-container--classic .select2-dropdown--below {
462
+  border-top: none; }
463
+
464
+.select2-container--classic .select2-results > .select2-results__options {
465
+  max-height: 200px;
466
+  overflow-y: auto; }
467
+
468
+.select2-container--classic .select2-results__option[role=group] {
469
+  padding: 0; }
470
+
471
+.select2-container--classic .select2-results__option[aria-disabled=true] {
472
+  color: grey; }
473
+
474
+.select2-container--classic .select2-results__option--highlighted[aria-selected] {
475
+  background-color: #3875d7;
476
+  color: white; }
477
+
478
+.select2-container--classic .select2-results__group {
479
+  cursor: default;
480
+  display: block;
481
+  padding: 6px; }
482
+
483
+.select2-container--classic.select2-container--open .select2-dropdown {
484
+  border-color: #5897fb; }

File diff suppressed because it is too large
+ 1 - 0
app/staticfile/vendor/select2/dist/css/select2.min.css


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/af.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/ar.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/az.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/bg.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/bn.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/bs.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/ca.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/cs.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/da.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/de.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/dsb.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/el.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/en.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/es.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/et.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/eu.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/fa.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/fi.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/fr.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/gl.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/he.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/hi.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/hr.js


File diff suppressed because it is too large
+ 3 - 0
app/staticfile/vendor/select2/dist/js/i18n/hsb.js


+ 0 - 0
app/staticfile/vendor/select2/dist/js/i18n/hu.js


Some files were not shown because too many files changed in this diff

tum/whitesports - Gogs: Simplico Git Service

Açıklama Yok

class-init.php 33KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520
  1. <?php if ( ! defined( 'ABSPATH' ) ) exit;
  2. if ( ! class_exists( 'UM' ) ) {
  3. /**
  4. * Main UM Class
  5. *
  6. * @class UM
  7. * @version 2.0
  8. *
  9. * @method UM_bbPress_API bbPress_API()
  10. * @method UM_Followers_API Followers_API()
  11. * @method UM_Friends_API Friends_API()
  12. * @method UM_Instagram_API Instagram_API()
  13. * @method UM_Mailchimp Mailchimp()
  14. * @method UM_Messaging_API Messaging_API()
  15. * @method UM_myCRED myCRED()
  16. * @method UM_Notices Notices()
  17. * @method UM_Notifications_API Notifications_API()
  18. * @method UM_Online Online()
  19. * @method UM_Profile_Completeness_API Profile_Completeness_API()
  20. * @method UM_reCAPTCHA reCAPTCHA()
  21. * @method UM_Reviews Reviews()
  22. * @method UM_Activity_API Activity_API()
  23. * @method UM_Social_Login_API Social_Login_API()
  24. * @method UM_User_Tags User_Tags()
  25. * @method UM_Verified_Users_API Verified_Users_API()
  26. * @method UM_WooCommerce_API WooCommerce_API()
  27. * @method UM_Terms_Conditions Terms_Conditions()
  28. * @method UM_Private_Content Private_Content()
  29. * @method UM_User_Locations User_Locations()
  30. * @method UM_Photos_API Photos_API()
  31. * @method UM_Groups Groups()
  32. * @method UM_Frontend_Posting Frontend_Posting()
  33. * @method UM_Notes Notes()
  34. * @method UM_User_Bookmarks User_Bookmarks()
  35. * @method UM_Unsplash Unsplash()
  36. * @method UM_ForumWP ForumWP()
  37. * @method UM_Profile_Tabs Profile_Tabs()
  38. * @method UM_JobBoardWP JobBoardWP()
  39. * @method UM_Google_Authenticator Google_Authenticator()
  40. */
  41. final class UM extends UM_Functions {
  42. /**
  43. * @var UM the single instance of the class
  44. */
  45. protected static $instance = null;
  46. /**
  47. * @var array all plugin's classes
  48. */
  49. public $classes = array();
  50. /**
  51. * @var bool Old variable
  52. *
  53. * @todo deprecate this variable
  54. */
  55. public $is_filtering;
  56. /**
  57. * WP Native permalinks turned on?
  58. *
  59. * @var
  60. */
  61. public $is_permalinks;
  62. /**
  63. * Main UM Instance
  64. *
  65. * Ensures only one instance of UM is loaded or can be loaded.
  66. *
  67. * @since 1.0
  68. * @static
  69. * @see UM()
  70. * @return UM - Main instance
  71. */
  72. static public function instance() {
  73. if ( is_null( self::$instance ) ) {
  74. self::$instance = new self();
  75. self::$instance->_um_construct();
  76. }
  77. return self::$instance;
  78. }
  79. /**
  80. * Create plugin classes - not sure if it needs!!!!!!!!!!!!!!!
  81. *
  82. * @since 1.0
  83. * @see UM()
  84. *
  85. * @param $name
  86. * @param array $params
  87. * @return mixed
  88. */
  89. public function __call( $name, array $params ) {
  90. if ( empty( $this->classes[ $name ] ) ) {
  91. /**
  92. * UM hook
  93. *
  94. * @type filter
  95. * @title um_call_object_{$class_name}
  96. * @description Extend call classes of Extensions for use UM()->class_name()->method|function
  97. * @input_vars
  98. * [{"var":"$class","type":"object","desc":"Class Instance"}]
  99. * @change_log
  100. * ["Since: 2.0"]
  101. * @usage add_filter( 'um_call_object_{$class_name}', 'function_name', 10, 1 );
  102. * @example
  103. * <?php
  104. * add_filter( 'um_call_object_{$class_name}', 'my_extension_class', 10, 1 );
  105. * function my_extension_class( $class ) {
  106. * // your code here
  107. * return $class;
  108. * }
  109. * ?>
  110. */
  111. $this->classes[ $name ] = apply_filters( 'um_call_object_' . $name, false );
  112. }
  113. return $this->classes[ $name ];
  114. }
  115. /**
  116. * Function for add classes to $this->classes
  117. * for run using UM()
  118. *
  119. * @since 2.0
  120. *
  121. * @param string $class_name
  122. * @param bool $instance
  123. */
  124. public function set_class( $class_name, $instance = false ) {
  125. if ( empty( $this->classes[ $class_name ] ) ) {
  126. $class = 'UM_' . $class_name;
  127. $this->classes[ $class_name ] = $instance ? $class::instance() : new $class;
  128. }
  129. }
  130. /**
  131. * Cloning is forbidden.
  132. * @since 1.0
  133. */
  134. public function __clone() {
  135. _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'ultimate-member' ), '1.0' );
  136. }
  137. /**
  138. * Unserializing instances of this class is forbidden.
  139. * @since 1.0
  140. */
  141. public function __wakeup() {
  142. _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'ultimate-member' ), '1.0' );
  143. }
  144. /**
  145. * UM constructor.
  146. *
  147. * @since 1.0
  148. */
  149. function __construct() {
  150. parent::__construct();
  151. }
  152. /**
  153. * UM pseudo-constructor.
  154. *
  155. * @since 2.0.18
  156. */
  157. function _um_construct() {
  158. //register autoloader for include UM classes
  159. spl_autoload_register( array( $this, 'um__autoloader' ) );
  160. if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
  161. if ( get_option( 'permalink_structure' ) ) {
  162. $this->is_permalinks = true;
  163. }
  164. $this->is_filtering = 0;
  165. $this->honeypot = 'um_request';
  166. // textdomain loading
  167. $this->localize();
  168. // include UM classes
  169. $this->includes();
  170. // include hook files
  171. add_action( 'plugins_loaded', array( &$this, 'init' ), 0 );
  172. //run hook for extensions init
  173. add_action( 'plugins_loaded', array( &$this, 'extensions_init' ), -19 );
  174. add_action( 'init', array( &$this, 'old_update_patch' ), 0 );
  175. //run activation
  176. register_activation_hook( um_plugin, array( &$this, 'activation' ) );
  177. if ( is_multisite() && ! defined( 'DOING_AJAX' ) ) {
  178. add_action( 'wp_loaded', array( $this, 'maybe_network_activation' ) );
  179. }
  180. // init widgets
  181. add_action( 'widgets_init', array( &$this, 'widgets_init' ) );
  182. //include short non class functions
  183. require_once 'um-short-functions.php';
  184. require_once 'um-deprecated-functions.php';
  185. }
  186. }
  187. /**
  188. * Loading UM textdomain
  189. *
  190. * 'ultimate-member' by default
  191. */
  192. function localize() {
  193. $language_locale = ( get_locale() != '' ) ? get_locale() : 'en_US';
  194. /**
  195. * UM hook
  196. *
  197. * @type filter
  198. * @title um_language_locale
  199. * @description Change UM language locale
  200. * @input_vars
  201. * [{"var":"$locale","type":"string","desc":"UM language locale"}]
  202. * @change_log
  203. * ["Since: 2.0"]
  204. * @usage add_filter( 'um_language_locale', 'function_name', 10, 1 );
  205. * @example
  206. * <?php
  207. * add_filter( 'um_language_locale', 'my_language_locale', 10, 1 );
  208. * function my_language_locale( $locale ) {
  209. * // your code here
  210. * return $locale;
  211. * }
  212. * ?>
  213. */
  214. $language_locale = apply_filters( 'um_language_locale', $language_locale );
  215. /**
  216. * UM hook
  217. *
  218. * @type filter
  219. * @title um_language_textdomain
  220. * @description Change UM textdomain
  221. * @input_vars
  222. * [{"var":"$domain","type":"string","desc":"UM Textdomain"}]
  223. * @change_log
  224. * ["Since: 2.0"]
  225. * @usage add_filter( 'um_language_textdomain', 'function_name', 10, 1 );
  226. * @example
  227. * <?php
  228. * add_filter( 'um_language_textdomain', 'my_textdomain', 10, 1 );
  229. * function my_textdomain( $domain ) {
  230. * // your code here
  231. * return $domain;
  232. * }
  233. * ?>
  234. */
  235. $language_domain = apply_filters( 'um_language_textdomain', 'ultimate-member' );
  236. $language_file = WP_LANG_DIR . '/plugins/' . $language_domain . '-' . $language_locale . '.mo';
  237. /**
  238. * UM hook
  239. *
  240. * @type filter
  241. * @title um_language_file
  242. * @description Change UM language file path
  243. * @input_vars
  244. * [{"var":"$language_file","type":"string","desc":"UM language file path"}]
  245. * @change_log
  246. * ["Since: 2.0"]
  247. * @usage add_filter( 'um_language_file', 'function_name', 10, 1 );
  248. * @example
  249. * <?php
  250. * add_filter( 'um_language_file', 'my_language_file', 10, 1 );
  251. * function my_language_file( $language_file ) {
  252. * // your code here
  253. * return $language_file;
  254. * }
  255. * ?>
  256. */
  257. $language_file = apply_filters( 'um_language_file', $language_file );
  258. load_textdomain( $language_domain, $language_file );
  259. }
  260. /**
  261. * 1.3.x active extensions deactivate for properly running 2.0.x AJAX upgrades
  262. */
  263. function old_update_patch() {
  264. global $um_woocommerce, $um_bbpress, $um_followers, $um_friends, $um_mailchimp, $um_messaging, $um_mycred, $um_notices, $um_notifications, $um_online, $um_private_content, $um_profile_completeness, $um_recaptcha, $um_reviews, $um_activity, $um_social_login, $um_user_tags, $um_verified;
  265. if ( is_object( $um_woocommerce ) ) {
  266. remove_action( 'init', array( $um_woocommerce, 'plugin_check' ), 1 );
  267. $um_woocommerce->plugin_inactive = true;
  268. }
  269. if ( is_object( $um_bbpress ) ) {
  270. remove_action( 'init', array( $um_bbpress, 'plugin_check' ), 4 );
  271. $um_bbpress->plugin_inactive = true;
  272. }
  273. if ( is_object( $um_followers ) ) {
  274. remove_action( 'init', array( $um_followers, 'plugin_check' ), 1 );
  275. $um_followers->plugin_inactive = true;
  276. }
  277. if ( is_object( $um_friends ) ) {
  278. remove_action( 'init', array( $um_friends, 'plugin_check' ), 1 );
  279. $um_friends->plugin_inactive = true;
  280. }
  281. if ( is_object( $um_mailchimp ) ) {
  282. remove_action( 'init', array( $um_mailchimp, 'plugin_check' ), 1 );
  283. $um_mailchimp->plugin_inactive = true;
  284. }
  285. if ( is_object( $um_messaging ) ) {
  286. remove_action( 'init', array( $um_messaging, 'plugin_check' ), 1 );
  287. $um_messaging->plugin_inactive = true;
  288. }
  289. if ( is_object( $um_mycred ) ) {
  290. remove_action( 'init', array( $um_mycred, 'plugin_check' ), 1 );
  291. $um_mycred->plugin_inactive = true;
  292. }
  293. if ( is_object( $um_notices ) ) {
  294. remove_action( 'init', array( $um_notices, 'plugin_check' ), 1 );
  295. $um_notices->plugin_inactive = true;
  296. }
  297. if ( is_object( $um_notifications ) ) {
  298. remove_action( 'init', array( $um_notifications, 'plugin_check' ), 1 );
  299. $um_notifications->plugin_inactive = true;
  300. }
  301. if ( is_object( $um_online ) ) {
  302. remove_action( 'init', array( $um_online, 'plugin_check' ), 1 );
  303. $um_online->plugin_inactive = true;
  304. }
  305. if ( is_object( $um_private_content ) ) {
  306. remove_action( 'init', array( $um_private_content, 'plugin_check' ), 1 );
  307. $um_private_content->plugin_inactive = true;
  308. }
  309. if ( is_object( $um_profile_completeness ) ) {
  310. remove_action( 'init', array( $um_profile_completeness, 'plugin_check' ), 1 );
  311. $um_profile_completeness->plugin_inactive = true;
  312. }
  313. if ( is_object( $um_recaptcha ) ) {
  314. remove_action( 'init', array( $um_recaptcha, 'plugin_check' ), 1 );
  315. $um_recaptcha->plugin_inactive = true;
  316. }
  317. if ( is_object( $um_reviews ) ) {
  318. remove_action( 'init', array( $um_reviews, 'plugin_check' ), 1 );
  319. $um_reviews->plugin_inactive = true;
  320. }
  321. if ( is_object( $um_activity ) ) {
  322. remove_action( 'init', array( $um_activity, 'plugin_check' ), 1 );
  323. $um_activity->plugin_inactive = true;
  324. }
  325. if ( is_object( $um_social_login ) ) {
  326. remove_action( 'init', array( $um_social_login, 'plugin_check' ), 1 );
  327. $um_social_login->plugin_inactive = true;
  328. }
  329. if ( is_object( $um_user_tags ) ) {
  330. remove_action( 'init', array( $um_user_tags, 'plugin_check' ), 1 );
  331. $um_user_tags->plugin_inactive = true;
  332. }
  333. if ( is_object( $um_verified ) ) {
  334. remove_action( 'init', array( $um_verified, 'plugin_check' ), 1 );
  335. $um_verified->plugin_inactive = true;
  336. }
  337. }
  338. /**
  339. * Autoload UM classes handler
  340. *
  341. * @since 2.0
  342. *
  343. * @param $class
  344. */
  345. function um__autoloader( $class ) {
  346. if ( strpos( $class, 'um' ) === 0 ) {
  347. $array = explode( '\\', strtolower( $class ) );
  348. $array[ count( $array ) - 1 ] = 'class-'. end( $array );
  349. if ( strpos( $class, 'um_ext' ) === 0 ) {
  350. $full_path = str_replace( 'ultimate-member', '', untrailingslashit( um_path ) ) . str_replace( '_', '-', $array[1] ) . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR;
  351. unset( $array[0], $array[1] );
  352. $path = implode( DIRECTORY_SEPARATOR, $array );
  353. $path = str_replace( '_', '-', $path );
  354. $full_path .= $path . '.php';
  355. } else if ( strpos( $class, 'um\\' ) === 0 ) {
  356. $class = implode( '\\', $array );
  357. $slash = DIRECTORY_SEPARATOR;
  358. $path = str_replace(
  359. array( 'um\\', '_', '\\' ),
  360. array( $slash, '-', $slash ),
  361. $class );
  362. $full_path = um_path . 'includes' . $path . '.php';
  363. }
  364. if( isset( $full_path ) && file_exists( $full_path ) ) {
  365. include_once $full_path;
  366. }
  367. }
  368. }
  369. /**
  370. * Plugin Activation
  371. *
  372. * @since 2.0
  373. */
  374. function activation() {
  375. $this->single_site_activation();
  376. if ( is_multisite() ) {
  377. update_network_option( get_current_network_id(), 'um_maybe_network_wide_activation', 1 );
  378. }
  379. }
  380. /**
  381. * Maybe need multisite activation process
  382. *
  383. * @since 2.1.7
  384. */
  385. function maybe_network_activation() {
  386. $maybe_activation = get_network_option( get_current_network_id(), 'um_maybe_network_wide_activation' );
  387. if ( $maybe_activation ) {
  388. delete_network_option( get_current_network_id(), 'um_maybe_network_wide_activation' );
  389. if ( is_plugin_active_for_network( um_plugin ) ) {
  390. // get all blogs
  391. $blogs = get_sites();
  392. if ( ! empty( $blogs ) ) {
  393. foreach( $blogs as $blog ) {
  394. switch_to_blog( $blog->blog_id );
  395. //make activation script for each sites blog
  396. $this->single_site_activation();
  397. restore_current_blog();
  398. }
  399. }
  400. }
  401. }
  402. }
  403. /**
  404. * Single site plugin activation handler
  405. */
  406. function single_site_activation() {
  407. //first install
  408. $version = get_option( 'um_version' );
  409. if ( ! $version ) {
  410. update_option( 'um_last_version_upgrade', ultimatemember_version );
  411. add_option( 'um_first_activation_date', time() );
  412. //show avatars on first install
  413. if ( ! get_option( 'show_avatars' ) ) {
  414. update_option( 'show_avatars', 1 );
  415. }
  416. } else {
  417. UM()->options()->update( 'rest_api_version', '1.0' );
  418. }
  419. if ( $version != ultimatemember_version ) {
  420. update_option( 'um_version', ultimatemember_version );
  421. }
  422. //run setup
  423. $this->common()->create_post_types();
  424. $this->setup()->run_setup();
  425. }
  426. /**
  427. *
  428. */
  429. function extensions_init() {
  430. do_action( 'um_core_loaded' );
  431. }
  432. /**
  433. * Include required core files used in admin and on the frontend.
  434. *
  435. * @since 2.0
  436. *
  437. * @return void
  438. */
  439. public function includes() {
  440. $this->common();
  441. $this->access();
  442. if ( $this->is_request( 'ajax' ) ) {
  443. $this->admin();
  444. $this->ajax_init();
  445. $this->admin_ajax_hooks();
  446. $this->metabox();
  447. $this->admin_upgrade()->init_packages_ajax_handlers();
  448. $this->admin_gdpr();
  449. $this->columns();
  450. $this->admin()->notices();
  451. $this->admin_navmenu();
  452. $this->plugin_updater();
  453. $this->theme_updater();
  454. } elseif ( $this->is_request( 'admin' ) ) {
  455. $this->admin();
  456. $this->admin_menu();
  457. $this->admin_upgrade();
  458. $this->admin_settings();
  459. $this->columns();
  460. $this->admin_enqueue();
  461. $this->metabox();
  462. $this->admin()->notices();
  463. $this->users();
  464. $this->dragdrop();
  465. $this->admin_gdpr();
  466. $this->admin_navmenu();
  467. $this->plugin_updater();
  468. $this->theme_updater();
  469. } elseif ( $this->is_request( 'frontend' ) ) {
  470. $this->enqueue();
  471. $this->account();
  472. $this->password();
  473. $this->login();
  474. $this->register();
  475. $this->user_posts();
  476. $this->logout();
  477. }
  478. //common includes
  479. $this->rewrite();
  480. $this->mail();
  481. $this->rest_api();
  482. $this->shortcodes();
  483. $this->roles();
  484. $this->user();
  485. $this->profile();
  486. $this->builtin();
  487. $this->form();
  488. $this->permalinks();
  489. $this->modal();
  490. $this->cron();
  491. $this->mobile();
  492. $this->external_integrations();
  493. $this->gdpr();
  494. $this->member_directory();
  495. //if multisite networks active
  496. if ( is_multisite() ) {
  497. $this->multisite();
  498. }
  499. }
  500. /**
  501. * @since 2.1.0
  502. *
  503. * @return um\core\Member_Directory()
  504. */
  505. function member_directory() {
  506. if ( empty( $this->classes['member_directory'] ) ) {
  507. $search_in_table = $this->options()->get( 'member_directory_own_table' );
  508. if ( ! empty( $search_in_table ) ) {
  509. $this->classes['member_directory'] = new um\core\Member_Directory_Meta();
  510. } else {
  511. $this->classes['member_directory'] = new um\core\Member_Directory();
  512. }
  513. }
  514. return $this->classes['member_directory'];
  515. }
  516. /**
  517. * Get extension API
  518. *
  519. * @since 2.0.34
  520. *
  521. * @param $slug
  522. *
  523. * @return um_ext\um_bbpress\Init
  524. */
  525. function extension( $slug ) {
  526. if ( empty( $this->classes[ $slug ] ) ) {
  527. $class = "um_ext\um_{$slug}\Init";
  528. /**
  529. * @var $class um_ext\um_bbpress\Init
  530. */
  531. $this->classes[ $slug ] = $class::instance();
  532. }
  533. return $this->classes[ $slug ];
  534. }
  535. /**
  536. * @param $class
  537. *
  538. * @return mixed
  539. */
  540. function call_class( $class ) {
  541. $key = strtolower( $class );
  542. if ( empty( $this->classes[ $key ] ) ) {
  543. $this->classes[ $key ] = new $class;
  544. }
  545. return $this->classes[ $key ];
  546. }
  547. /**
  548. * @since 2.0
  549. *
  550. * @return um\core\Common()
  551. */
  552. function common() {
  553. if ( empty( $this->classes['common'] ) ) {
  554. $this->classes['common'] = new um\core\Common();
  555. }
  556. return $this->classes['common'];
  557. }
  558. /**
  559. * @since 2.0
  560. *
  561. * @return um\core\External_Integrations()
  562. */
  563. function external_integrations() {
  564. if ( empty( $this->classes['external_integrations'] ) ) {
  565. $this->classes['external_integrations'] = new um\core\External_Integrations();
  566. }
  567. return $this->classes['external_integrations'];
  568. }
  569. /**
  570. * @since 2.0
  571. *
  572. * @return um\core\Options()
  573. */
  574. function options() {
  575. if ( empty( $this->classes['options'] ) ) {
  576. $this->classes['options'] = new um\core\Options();
  577. }
  578. return $this->classes['options'];
  579. }
  580. /**
  581. * @since 2.0
  582. *
  583. * @return um\core\Plugin_Updater()
  584. */
  585. function plugin_updater() {
  586. if ( empty( $this->classes['plugin_updater'] ) ) {
  587. $this->classes['plugin_updater'] = new um\core\Plugin_Updater();
  588. }
  589. return $this->classes['plugin_updater'];
  590. }
  591. /**
  592. * @since 2.0.45
  593. * @return um\admin\core\Admin_Theme_Updater()
  594. */
  595. function theme_updater() {
  596. if ( empty( $this->classes['theme_updater'] ) ) {
  597. $this->classes['theme_updater'] = new um\admin\core\Admin_Theme_Updater();
  598. }
  599. return $this->classes['theme_updater'];
  600. }
  601. /**
  602. * @since 2.0
  603. */
  604. function ajax_init() {
  605. new um\core\AJAX_Common();
  606. }
  607. /**
  608. * @since 2.0.30
  609. */
  610. function admin_ajax_hooks() {
  611. if ( empty( $this->classes['admin_ajax_hooks'] ) ) {
  612. $this->classes['admin_ajax_hooks'] = new um\admin\core\Admin_Ajax_Hooks();
  613. }
  614. return $this->classes['admin_ajax_hooks'];
  615. }
  616. /**
  617. * @since 2.0
  618. *
  619. * @return um\admin\Admin()
  620. */
  621. function admin() {
  622. if ( empty( $this->classes['admin'] ) ) {
  623. $this->classes['admin'] = new um\admin\Admin();
  624. }
  625. return $this->classes['admin'];
  626. }
  627. /**
  628. * @since 2.0
  629. *
  630. * @return um\admin\core\Admin_Menu()
  631. */
  632. function admin_menu() {
  633. if ( empty( $this->classes['admin_menu'] ) ) {
  634. $this->classes['admin_menu'] = new um\admin\core\Admin_Menu();
  635. }
  636. return $this->classes['admin_menu'];
  637. }
  638. /**
  639. * @since 2.0.26
  640. *
  641. * @return um\admin\core\Admin_Navmenu()
  642. */
  643. function admin_navmenu() {
  644. if ( empty( $this->classes['admin_navmenu'] ) ) {
  645. $this->classes['admin_navmenu'] = new um\admin\core\Admin_Navmenu();
  646. }
  647. return $this->classes['admin_navmenu'];
  648. }
  649. /**
  650. * @since 2.0
  651. *
  652. * @return um\admin\core\Admin_Settings()
  653. */
  654. function admin_settings() {
  655. if ( empty( $this->classes['admin_settings'] ) ) {
  656. $this->classes['admin_settings'] = new um\admin\core\Admin_Settings();
  657. }
  658. return $this->classes['admin_settings'];
  659. }
  660. /**
  661. * @since 2.0
  662. *
  663. * @return um\admin\core\Admin_Upgrade()
  664. */
  665. function admin_upgrade() {
  666. if ( empty( $this->classes['admin_upgrade'] ) ) {
  667. $this->classes['admin_upgrade'] = um\admin\core\Admin_Upgrade::instance();
  668. //$this->classes['admin_upgrade'] = new um\admin\core\Admin_Upgrade();
  669. }
  670. return $this->classes['admin_upgrade'];
  671. }
  672. /**
  673. * GDPR privacy policy
  674. *
  675. * @since 2.0.14
  676. *
  677. * @return bool|um\admin\core\Admin_GDPR()
  678. */
  679. function admin_gdpr() {
  680. global $wp_version;
  681. if ( version_compare( $wp_version, '4.9.6', '<' ) ) {
  682. return false;
  683. }
  684. if ( empty( $this->classes['admin_gdpr'] ) ) {
  685. $this->classes['admin_gdpr'] = new um\admin\core\Admin_GDPR();
  686. }
  687. return $this->classes['admin_gdpr'];
  688. }
  689. /**
  690. * GDPR privacy policy
  691. *
  692. * @since 2.0.14
  693. *
  694. * @return bool|um\core\GDPR()
  695. */
  696. function gdpr() {
  697. global $wp_version;
  698. if ( version_compare( $wp_version, '4.9.6', '<' ) ) {
  699. return false;
  700. }
  701. if ( empty( $this->classes['gdpr'] ) ) {
  702. $this->classes['gdpr'] = new um\core\GDPR();
  703. }
  704. return $this->classes['gdpr'];
  705. }
  706. /**
  707. * @since 2.0
  708. *
  709. * @return um\admin\core\Admin_Columns()
  710. */
  711. function columns() {
  712. if ( empty( $this->classes['admin_columns'] ) ) {
  713. $this->classes['admin_columns'] = new um\admin\core\Admin_Columns();
  714. }
  715. return $this->classes['admin_columns'];
  716. }
  717. /**
  718. * @since 2.0
  719. *
  720. * @return um\admin\core\Admin_Enqueue()
  721. */
  722. function admin_enqueue() {
  723. if ( empty( $this->classes['admin_enqueue'] ) ) {
  724. $this->classes['admin_enqueue'] = new um\admin\core\Admin_Enqueue();
  725. }
  726. return $this->classes['admin_enqueue'];
  727. }
  728. /**
  729. * @since 2.0
  730. *
  731. * @return um\admin\core\Admin_Metabox()
  732. */
  733. function metabox() {
  734. if ( empty( $this->classes['admin_metabox'] ) ) {
  735. $this->classes['admin_metabox'] = new um\admin\core\Admin_Metabox();
  736. }
  737. return $this->classes['admin_metabox'];
  738. }
  739. /**
  740. * @since 2.0
  741. *
  742. * @return um\admin\core\Admin_Users()
  743. */
  744. function users() {
  745. if ( empty( $this->classes['admin_users'] ) ) {
  746. $this->classes['admin_users'] = new um\admin\core\Admin_Users();
  747. }
  748. return $this->classes['admin_users'];
  749. }
  750. /**
  751. * @since 2.0
  752. *
  753. * @return um\admin\core\Admin_Builder()
  754. */
  755. function builder() {
  756. if ( empty( $this->classes['admin_builder'] ) ) {
  757. $this->classes['admin_builder'] = new um\admin\core\Admin_Builder();
  758. }
  759. return $this->classes['admin_builder'];
  760. }
  761. /**
  762. * @since 2.0
  763. *
  764. * @return um\admin\core\Admin_DragDrop()
  765. */
  766. function dragdrop() {
  767. if ( empty( $this->classes['admin_dragdrop'] ) ) {
  768. $this->classes['admin_dragdrop'] = new um\admin\core\Admin_DragDrop();
  769. }
  770. return $this->classes['admin_dragdrop'];
  771. }
  772. /**
  773. * @since 2.0
  774. *
  775. * @param bool|array $data
  776. * @return um\admin\core\Admin_Forms()
  777. */
  778. function admin_forms( $data = false ) {
  779. if ( ! isset( $this->classes[ 'admin_forms_' . $data['class'] ] ) || empty( $this->classes[ 'admin_forms_' . $data['class'] ] ) ) {
  780. $this->classes[ 'admin_forms_' . $data['class'] ] = new um\admin\core\Admin_Forms( $data );
  781. }
  782. return $this->classes[ 'admin_forms_' . $data['class'] ];
  783. }
  784. /**
  785. * @since 2.0
  786. *
  787. * @param bool|array $data
  788. * @return um\admin\core\Admin_Forms_Settings()
  789. */
  790. function admin_forms_settings( $data = false ) {
  791. if ( ! isset( $this->classes[ 'admin_forms_settings_' . $data['class'] ] ) || empty( $this->classes[ 'admin_forms_settings_' . $data['class'] ] ) ) {
  792. $this->classes[ 'admin_forms_settings_' . $data['class'] ] = new um\admin\core\Admin_Forms_Settings( $data );
  793. }
  794. return $this->classes[ 'admin_forms_settings_' . $data['class'] ];
  795. }
  796. /**
  797. * @since 2.0.34
  798. *
  799. * @return um\Extensions
  800. */
  801. function extensions() {
  802. if ( empty( $this->classes['extensions'] ) ) {
  803. $this->classes['extensions'] = new um\Extensions();
  804. }
  805. return $this->classes['extensions'];
  806. }
  807. /**
  808. * @since 2.0
  809. *
  810. * @return um\Dependencies
  811. */
  812. function dependencies() {
  813. if ( empty( $this->classes['dependencies'] ) ) {
  814. $this->classes['dependencies'] = new um\Dependencies();
  815. }
  816. return $this->classes['dependencies'];
  817. }
  818. /**
  819. * @since 2.0
  820. *
  821. * @return um\Config
  822. */
  823. function config() {
  824. if ( empty( $this->classes['config'] ) ) {
  825. $this->classes['config'] = new um\Config();
  826. }
  827. return $this->classes['config'];
  828. }
  829. /**
  830. * @since 2.0
  831. *
  832. * @return um\core\rest\API_v1|um\core\rest\API_v2
  833. */
  834. function rest_api() {
  835. $api_version = $this->options()->get( 'rest_api_version' );
  836. if ( empty( $this->classes['rest_api'] ) ) {
  837. if ( '1.0' === $api_version ) {
  838. $this->classes['rest_api'] = new um\core\rest\API_v1();
  839. } elseif ( '2.0' === $api_version ) {
  840. $this->classes['rest_api'] = new um\core\rest\API_v2();
  841. } else {
  842. $this->classes['rest_api'] = new um\core\rest\API_v1();
  843. }
  844. }
  845. return $this->classes['rest_api'];
  846. }
  847. /**
  848. * @since 2.0
  849. *
  850. * @return um\core\Rewrite
  851. */
  852. function rewrite() {
  853. if ( empty( $this->classes['rewrite'] ) ) {
  854. $this->classes['rewrite'] = new um\core\Rewrite();
  855. }
  856. return $this->classes['rewrite'];
  857. }
  858. /**
  859. * @since 2.0
  860. *
  861. * @return um\core\Setup
  862. */
  863. function setup() {
  864. if ( empty( $this->classes['setup'] ) ) {
  865. $this->classes['setup'] = new um\core\Setup();
  866. }
  867. return $this->classes['setup'];
  868. }
  869. /**
  870. * @since 2.0
  871. *
  872. * @return um\core\FontIcons
  873. */
  874. function fonticons() {
  875. if ( empty( $this->classes['fonticons'] ) ) {
  876. $this->classes['fonticons'] = new um\core\FontIcons();
  877. }
  878. return $this->classes['fonticons'];
  879. }
  880. /**
  881. * @since 2.0
  882. *
  883. * @return um\core\Login
  884. */
  885. function login() {
  886. if ( empty( $this->classes['login'] ) ) {
  887. $this->classes['login'] = new um\core\Login();
  888. }
  889. return $this->classes['login'];
  890. }
  891. /**
  892. * @since 2.0
  893. *
  894. * @return um\core\Register
  895. */
  896. function register() {
  897. if ( empty( $this->classes['register'] ) ) {
  898. $this->classes['register'] = new um\core\Register();
  899. }
  900. return $this->classes['register'];
  901. }
  902. /**
  903. * @since 2.0
  904. *
  905. * @return um\core\Enqueue
  906. */
  907. function enqueue() {
  908. if ( empty( $this->classes['enqueue'] ) ) {
  909. $this->classes['enqueue'] = new um\core\Enqueue();
  910. }
  911. return $this->classes['enqueue'];
  912. }
  913. /**
  914. * @since 2.0
  915. *
  916. * @return um\core\Shortcodes
  917. */
  918. function shortcodes() {
  919. if ( empty( $this->classes['shortcodes'] ) ) {
  920. $this->classes['shortcodes'] = new um\core\Shortcodes();
  921. }
  922. return $this->classes['shortcodes'];
  923. }
  924. /**
  925. * @since 2.0
  926. *
  927. * @return um\core\Account
  928. */
  929. function account() {
  930. if ( empty( $this->classes['account'] ) ) {
  931. $this->classes['account'] = new um\core\Account();
  932. }
  933. return $this->classes['account'];
  934. }
  935. /**
  936. * @since 2.0
  937. *
  938. * @return um\core\Password
  939. */
  940. function password() {
  941. if ( empty( $this->classes['password'] ) ) {
  942. $this->classes['password'] = new um\core\Password();
  943. }
  944. return $this->classes['password'];
  945. }
  946. /**
  947. * @since 2.0
  948. *
  949. * @return um\core\Form
  950. */
  951. function form() {
  952. if ( empty( $this->classes['form'] ) ) {
  953. $this->classes['form'] = new um\core\Form();
  954. }
  955. return $this->classes['form'];
  956. }
  957. /**
  958. * @since 2.0
  959. *
  960. * @return um\core\Fields
  961. */
  962. function fields() {
  963. if ( empty( $this->classes['fields'] ) ) {
  964. $this->classes['fields'] = new um\core\Fields();
  965. }
  966. return $this->classes['fields'];
  967. }
  968. /**
  969. * @since 2.0
  970. *
  971. * @return um\core\User
  972. */
  973. function user() {
  974. if ( empty( $this->classes['user'] ) ) {
  975. $this->classes['user'] = new um\core\User();
  976. }
  977. return $this->classes['user'];
  978. }
  979. /**
  980. * @since 2.0
  981. *
  982. * @return um\core\Roles_Capabilities
  983. */
  984. function roles() {
  985. if ( empty( $this->classes['roles'] ) ) {
  986. $this->classes['roles'] = new um\core\Roles_Capabilities();
  987. }
  988. return $this->classes['roles'];
  989. }
  990. /**
  991. * @since 2.0
  992. *
  993. * @return um\core\User_posts
  994. */
  995. function user_posts() {
  996. if ( empty( $this->classes['user_posts'] ) ) {
  997. $this->classes['user_posts'] = new um\core\User_posts();
  998. }
  999. return $this->classes['user_posts'];
  1000. }
  1001. /**
  1002. * @since 2.0
  1003. *
  1004. * @return um\core\Profile
  1005. */
  1006. function profile() {
  1007. if ( empty( $this->classes['profile'] ) ) {
  1008. $this->classes['profile'] = new um\core\Profile();
  1009. }
  1010. return $this->classes['profile'];
  1011. }
  1012. /**
  1013. * @since 2.0
  1014. *
  1015. * @return um\core\Query
  1016. */
  1017. function query() {
  1018. if ( empty( $this->classes['query'] ) ) {
  1019. $this->classes['query'] = new um\core\Query();
  1020. }
  1021. return $this->classes['query'];
  1022. }
  1023. /**
  1024. * @since 2.0
  1025. *
  1026. * @return um\core\Date_Time
  1027. */
  1028. function datetime() {
  1029. if ( empty( $this->classes['datetime'] ) ) {
  1030. $this->classes['datetime'] = new um\core\Date_Time();
  1031. }
  1032. return $this->classes['datetime'];
  1033. }
  1034. /**
  1035. * @since 2.0
  1036. *
  1037. * @return um\core\Builtin
  1038. */
  1039. function builtin() {
  1040. if ( empty( $this->classes['builtin'] ) ) {
  1041. $this->classes['builtin'] = new um\core\Builtin();
  1042. }
  1043. return $this->classes['builtin'];
  1044. }
  1045. /**
  1046. * @since 2.0
  1047. *
  1048. * @return um\core\Files
  1049. */
  1050. function files() {
  1051. if ( empty( $this->classes['files'] ) ) {
  1052. $this->classes['files'] = new um\core\Files();
  1053. }
  1054. return $this->classes['files'];
  1055. }
  1056. /**
  1057. * @since 2.0.21
  1058. *
  1059. * @return um\core\Uploader
  1060. */
  1061. function uploader() {
  1062. if ( empty( $this->classes['uploader'] ) ) {
  1063. $this->classes['uploader'] = new um\core\Uploader();
  1064. }
  1065. return $this->classes['uploader'];
  1066. }
  1067. /**
  1068. * @since 2.0
  1069. *
  1070. * @return um\core\Validation
  1071. */
  1072. function validation() {
  1073. if ( empty( $this->classes['validation'] ) ) {
  1074. $this->classes['validation'] = new um\core\Validation();
  1075. }
  1076. return $this->classes['validation'];
  1077. }
  1078. /**
  1079. * @since 2.0
  1080. *
  1081. * @return um\core\Access
  1082. */
  1083. function access() {
  1084. if ( empty( $this->classes['access'] ) ) {
  1085. $this->classes['access'] = new um\core\Access();
  1086. }
  1087. return $this->classes['access'];
  1088. }
  1089. /**
  1090. * @since 2.0
  1091. *
  1092. * @return um\core\Permalinks
  1093. */
  1094. function permalinks() {
  1095. if ( empty( $this->classes['permalinks'] ) ) {
  1096. $this->classes['permalinks'] = new um\core\Permalinks();
  1097. }
  1098. return $this->classes['permalinks'];
  1099. }
  1100. /**
  1101. * @since 2.0
  1102. *
  1103. * @return um\core\Mail
  1104. */
  1105. function mail() {
  1106. if ( empty( $this->classes['mail'] ) ) {
  1107. $this->classes['mail'] = new um\core\Mail();
  1108. }
  1109. return $this->classes['mail'];
  1110. }
  1111. /**
  1112. * @deprecated 2.1.0
  1113. *
  1114. * @since 2.0
  1115. *
  1116. * @return um\core\Members
  1117. */
  1118. function members() {
  1119. um_deprecated_function( 'UM()->members()', '2.1.0', 'UM()->member_directory()' );
  1120. if ( empty( $this->classes['members'] ) ) {
  1121. $this->classes['members'] = new um\core\Members();
  1122. }
  1123. return $this->classes['members'];
  1124. }
  1125. /**
  1126. * @since 2.0
  1127. *
  1128. * @return um\core\Logout
  1129. */
  1130. function logout() {
  1131. if ( empty( $this->classes['logout'] ) ) {
  1132. $this->classes['logout'] = new um\core\Logout();
  1133. }
  1134. return $this->classes['logout'];
  1135. }
  1136. /**
  1137. * @since 2.0
  1138. *
  1139. * @return um\core\Modal
  1140. */
  1141. function modal() {
  1142. if ( empty( $this->classes['modal'] ) ) {
  1143. $this->classes['modal'] = new um\core\Modal();
  1144. }
  1145. return $this->classes['modal'];
  1146. }
  1147. /**
  1148. * @since 2.0
  1149. *
  1150. * @return um\core\Cron
  1151. */
  1152. function cron() {
  1153. if ( empty( $this->classes['cron'] ) ) {
  1154. $this->classes['cron'] = new um\core\Cron();
  1155. }
  1156. return $this->classes['cron'];
  1157. }
  1158. /**
  1159. * @since 2.0
  1160. *
  1161. * @return um\core\Templates
  1162. */
  1163. function templates() {
  1164. if ( empty( $this->classes['templates'] ) ) {
  1165. $this->classes['templates'] = new um\core\Templates();
  1166. }
  1167. return $this->classes['templates'];
  1168. }
  1169. /**
  1170. * @since 2.0
  1171. *
  1172. * @return um\lib\mobiledetect\Um_Mobile_Detect
  1173. */
  1174. function mobile() {
  1175. if ( empty( $this->classes['mobile'] ) ) {
  1176. $this->classes['mobile'] = new um\lib\mobiledetect\Um_Mobile_Detect();
  1177. }
  1178. return $this->classes['mobile'];
  1179. }
  1180. /**
  1181. * @since 2.0.44
  1182. *
  1183. * @return um\core\Multisite
  1184. */
  1185. function multisite() {
  1186. if ( empty( $this->classes['multisite'] ) ) {
  1187. $this->classes['multisite'] = new um\core\Multisite();
  1188. }
  1189. return $this->classes['multisite'];
  1190. }
  1191. /**
  1192. * Include files with hooked filters/actions
  1193. *
  1194. * @since 2.0
  1195. */
  1196. function init() {
  1197. ob_start();
  1198. require_once 'core/um-actions-form.php';
  1199. require_once 'core/um-actions-access.php';
  1200. require_once 'core/um-actions-wpadmin.php';
  1201. require_once 'core/um-actions-core.php';
  1202. require_once 'core/um-actions-ajax.php';
  1203. require_once 'core/um-actions-login.php';
  1204. require_once 'core/um-actions-register.php';
  1205. require_once 'core/um-actions-profile.php';
  1206. require_once 'core/um-actions-account.php';
  1207. require_once 'core/um-actions-global.php';
  1208. require_once 'core/um-actions-user.php';
  1209. require_once 'core/um-actions-save-profile.php';
  1210. require_once 'core/um-actions-misc.php';
  1211. require_once 'core/um-filters-login.php';
  1212. require_once 'core/um-filters-fields.php';
  1213. require_once 'core/um-filters-files.php';
  1214. require_once 'core/um-filters-navmenu.php';
  1215. require_once 'core/um-filters-avatars.php';
  1216. require_once 'core/um-filters-user.php';
  1217. require_once 'core/um-filters-profile.php';
  1218. require_once 'core/um-filters-account.php';
  1219. require_once 'core/um-filters-misc.php';
  1220. require_once 'core/um-filters-commenting.php';
  1221. }
  1222. /**
  1223. * Init UM widgets
  1224. *
  1225. * @since 2.0
  1226. */
  1227. function widgets_init() {
  1228. register_widget( 'um\widgets\UM_Search_Widget' );
  1229. }
  1230. }
  1231. }
  1232. /**
  1233. * Function for calling UM methods and variables
  1234. *
  1235. * @since 2.0
  1236. *
  1237. * @return UM
  1238. */
  1239. function UM() {
  1240. return UM::instance();
  1241. }
  1242. // Global for backwards compatibility.
  1243. $GLOBALS['ultimatemember'] = UM();